import React from 'react'; import PropTypes from 'prop-types'; import SingleOpenPanelGroup, { SingleOpenPanelGroupChangeHandler } from './SingleOpenPanelGroup'; import { ComponentProps } from '../utils/types'; /** @public */ type CollapsiblePanelChangeHandler = (event: React.MouseEvent, data: { action: 'open' | 'close'; panelId?: string | number; reason: 'toggleClick'; }) => void; interface CollapsiblePanelPropsBase { /** * Style object applied to `TransitionOpen` inner styles. */ innerBodyStyles?: React.CSSProperties; /** * Renders the toggle button and interactive elements separate from `title`, reserving the `title` prop for text only. */ actions?: React.ReactNode; /** * Changes the style of the panel. */ appearance?: 'default' | 'subtle'; children?: React.ReactNode; /** * Sets the initial state of a panel to expanded. Incompatible with * `open`. Use `open` or `defaultOpen`, not both. Incompatible with `SingleOpenPanelGroup` * and will be ignored for any children in `SingleOpenPanelGroup`. */ defaultOpen?: boolean; /** Displays right-aligned text in the title bar of the `panel`. */ description?: string; /** * Prevents the panel from expanding or collapsing. */ disabled?: boolean | 'dimmed' | 'disabled'; /** * A React ref which is set to the DOM element when the component mounts and null when it unmounts. */ elementRef?: React.Ref; /** * Sets the `aria-level` of a panel to make heading level fit the outline of the page. * If set, the heading element contains `role="heading"`. */ headingLevel?: number; /** * By default, adds padding to panel content. If set to false, renders panel content without padding. */ inset?: boolean; /** * Identifies a specific panel. Splunk UI uses `panelId` for callbacks and managing expanded and collapsed states. */ panelId?: string | number; /** * Invoked on a change of the open panel. * Callback is passed the `panelId` of the `CollapsiblePanel` that originated the expand request and the `action` ("open" or "close") */ onChange?: CollapsiblePanelChangeHandler; /** * Controls the expanded state of a panel. Incompatible with * `defaultOpen`. Use `open` or `defaultOpen`, not both. Incompatible with `SingleOpenPanelGroup` * and will be ignored for any children in `SingleOpenPanelGroup`. */ open?: boolean; /** * Controls how panel overflow is handled. Default is `auto`, allowing * fixed-height Accordions to scroll their content if the panel is too * high to fit properly. Any value allowed by the CSS `overflow` property * is permitted, as is `null` (which will use the CSS default of "visible"). */ overflow?: string; /** * When true, children are always rendered whether collapsed or not. * Setting this to `true` can improve the performance of expanding panels at the cost of initial loading performance. */ renderChildrenWhenCollapsed?: boolean; /** * Displays the name of the panel in its title bar. */ title: React.ReactNode; } interface CollapsiblePanelControlledProps extends CollapsiblePanelPropsBase { defaultOpen?: never; onChange: CollapsiblePanelChangeHandler; open?: boolean; } interface CollapsiblePanelUncontrolledProps extends CollapsiblePanelPropsBase { defaultOpen?: boolean; open?: never; } type CollapsiblePanelProps = ComponentProps; declare function CollapsiblePanel({ innerBodyStyles, actions, appearance, children, defaultOpen, description, disabled, elementRef, headingLevel, onChange, open, overflow, panelId, renderChildrenWhenCollapsed, title, inset, ...otherProps }: CollapsiblePanelProps): React.JSX.Element; declare namespace CollapsiblePanel { var propTypes: { innerBodyStyles: PropTypes.Requireable; actions: PropTypes.Requireable; appearance: PropTypes.Requireable; children: PropTypes.Requireable; defaultOpen: PropTypes.Requireable; description: PropTypes.Requireable; disabled: PropTypes.Requireable>; elementRef: PropTypes.Requireable; headingLevel: PropTypes.Requireable; inset: PropTypes.Requireable; onChange: PropTypes.Requireable<(...args: any[]) => any>; open: PropTypes.Requireable; overflow: PropTypes.Requireable; panelId: PropTypes.Requireable; renderChildrenWhenCollapsed: PropTypes.Requireable; title: PropTypes.Validator>; }; } export default CollapsiblePanel; export { SingleOpenPanelGroup }; export type { CollapsiblePanelChangeHandler, SingleOpenPanelGroupChangeHandler };