Skip to content

Commit

Permalink
fix(Accordion): enhance TypeScript type definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
tujoworker committed May 31, 2023
1 parent f97f6ea commit 035c0fb
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ export const AccordionContainerExample = () => (
>
{() => {
function AccordionWithContainer() {
const ref1 = React.useRef()
const ref2 = React.useRef()
const ref1 = React.useRef(null)
const ref2 = React.useRef(null)
const [changeHeight] = React.useState(() => ({ ref1, ref2 }))
return (
<Accordion.Group
Expand Down
12 changes: 10 additions & 2 deletions packages/dnb-eufemia/src/components/accordion/Accordion.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ export interface AccordionProps extends React.HTMLProps<HTMLElement> {
*/
title?: React.ReactNode;

/**
* A description as a string or React element. It will be used as an additional text.
*/
description?: React.ReactNode;

/**
* If set to `true` the accordion will be expanded as its initial state.
*/
Expand Down Expand Up @@ -221,14 +226,15 @@ export default class Accordion extends React.Component<
static Content = AccordionContent;
static Header = AccordionHeader;
static Provider = AccordionProvider;
static Group: (props: GroupProps) => JSX.Element;
render(): JSX.Element;
}
export type GroupRememberState = string | boolean;
/**
* NB: Do not change the docs (comments) in here. The docs are updated during build time by "generateTypes.js" and "fetchPropertiesFromDocs.js".
*/

export interface GroupProps {
export type GroupProps = {
/**
* A unique `id` that will be used on the button element. If you use `remember_state`, an id is required.
*/
Expand All @@ -239,7 +245,9 @@ export interface GroupProps {
* If set to `true`, it will remember a changed state initiated by the user. It requires a unique `id`. It will store the sate in the local storage.
*/
remember_state?: GroupRememberState;
}

children: React.ReactNode;
} & AccordionProps;

declare class Group extends React.Component<GroupProps, any> {
static defaultProps: object;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export type AccordionContentChildren =

export interface AccordionContentProps
extends React.HTMLProps<HTMLElement> {
instance?: Record<string, unknown>;
instance?: React.LegacyRef;
space?: AccordionContentSpace;
top?: AccordionContentTop;
right?: AccordionContentRight;
Expand Down
15 changes: 15 additions & 0 deletions packages/dnb-eufemia/src/components/accordion/AccordionHeader.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,5 +179,20 @@ export default class AccordionHeader extends React.Component<
any
> {
static defaultProps: object;
static Container: ({
children
}: {
children: React.ReactNode;
}) => JSX.Element;
static Title: ({
children
}: {
children: React.ReactNode;
}) => JSX.Element;
static Description: ({
children
}: {
children: React.ReactNode;
}) => JSX.Element;
render(): JSX.Element;
}

0 comments on commit 035c0fb

Please sign in to comment.