import * as React from "react"; import { cx } from "@emotion/css"; import { display } from "../../shared/styles/styleUtils"; import { toggler } from "../style"; import { ResetButton } from "../../button"; import { Icon } from "../../icon"; import { SystemIcons } from "../../icons/dist/system-icons-enum"; import { Flex, FlexItem } from "../../styleUtils/layout"; export interface ExpandableProps { children: React.ReactElement | string; controlledIsOpen?: boolean; indicatorPosition?: "left" | "right"; isOpen?: boolean; label: React.ReactElement | string; labelClassName?: string; onChange?: (open: boolean) => void; } const Expandable = ({ labelClassName, children, label, isOpen, controlledIsOpen, onChange, indicatorPosition = "left" }: ExpandableProps) => { const [open, setOpen] = React.useState(Boolean(isOpen)); React.useEffect(() => { if (controlledIsOpen !== undefined) { setOpen(controlledIsOpen); } }, [controlledIsOpen]); const handleToggle = () => { const newOpen = !open; if (controlledIsOpen === undefined) { setOpen(newOpen); } if (onChange) { onChange(newOpen); } }; return (
{label}
{children}
); }; export default Expandable;