/
ExpansionList.tsx
35 lines (32 loc) · 960 Bytes
/
ExpansionList.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import {
forwardRef,
HTMLAttributes,
KeyboardEventHandler,
ReactNode,
} from "react";
export interface ExpansionListProps extends HTMLAttributes<HTMLDivElement> {
/**
* This should be 2 or more expansion panel components.
*/
children: ReactNode;
/**
* The keydown event handler that allows for focusing the next/previous panel
* as well as the first/last with keyboard shortcuts. This is provided by the
* `usePanels` hook automatically.
*/
onKeyDown: KeyboardEventHandler<HTMLDivElement>;
}
/**
* This component is honestly not very helpful since it does not apply any
* styles. It is a simple wrapper for a `<div>` that updates the props to
* require the `children` and `onKeyDown` props.
*/
export const ExpansionList = forwardRef<HTMLDivElement, ExpansionListProps>(
function ExpansionList({ children, ...props }, ref) {
return (
<div {...props} ref={ref}>
{children}
</div>
);
}
);