import * as React from 'react'; import type { PolymorphicForwardRefComponent } from '../../utils/index.js'; import { Text } from '../Typography/Text.js'; import type { FocusEntry, PanelsInstance, TriggerMapEntry } from './helpers.js'; type PanelsWrapperProps = { /** * Function that gets called when the active panel is changed. */ onActiveIdChange?: (newActiveId: string) => void; children: React.ReactNode; /** * Pass an instance created by `useInstance` to control the panels imperatively. * * @example * const panels = Panels.useInstance(); * */ instance?: PanelsInstance; }; export declare const PanelsWrapper: PolymorphicForwardRefComponent<"div", PanelsWrapperProps>; export declare const PanelsWrapperContext: React.Context<{ activePanelId: string | undefined; setActivePanelId: React.Dispatch>; /** * Simpler alternative to a full history stack. * * ``` * Record< * string, // Id of a panel * { * triggerId: string, // Id of the trigger element that points to this panel * panelId: string, // Id of the panel element in which the trigger is present * } * > * ``` */ triggers: Record; setTriggers: React.Dispatch>>; changeActivePanel: (newActiveId: string) => void; shouldFocus: FocusEntry; setShouldFocus: React.Dispatch>; panels: React.MutableRefObject>; } | undefined>; type PanelProps = { id: string; }; type PanelTriggerProps = { for: string; children: React.ReactElement; }; type PanelHeaderProps = { titleProps?: React.ComponentProps; }; export declare const Panels: { /** * Component that manages the logic for layered panels. * It can be used anywhere to create layers. E.g. `Menu`, `InformationPanel`, `Popover`, etc. * * Requirements: * - The initial displayed Panel should be the first `Panel` in the `Panels.Wrapper`. * - A panel can have only one trigger pointing to it. i.e. out of all the triggers across all panels, * only one can point to a particular panel. * - The `Panels.Panel`s within the wrapper should be in the order of the navigation. E.g.: * ```jsx * * // Must come before moreDetails since it contains the trigger to moreDetails * // Must come after root since it is navigated to from root * * ``` * * @example * * * Root * * * * More details * * * * * * * More details * * Content * * * */ Wrapper: PolymorphicForwardRefComponent<"div", PanelsWrapperProps>; /** * Takes an `id` and the panel content. * Match this `id` with a `Panels.Triggers`'s `for` prop to create a link between them. * * @example * * Root * * * * More details * * * * */ Panel: PolymorphicForwardRefComponent<"div", PanelProps>; /** * Wraps the clickable element and appends an `onClick` to change the active panel to the one specified in the `for` * prop. Also appends some attributes for accessibility. * * @example * * * * * @example * * * More details * * */ Trigger: { (props: PanelTriggerProps): string | number | bigint | true | React.ReactElement> | Iterable | Promise> | Iterable | null | undefined> | null; displayName: string; }; /** * Required component to add an accessible name and also a back button (if previous panel exists) to the panel. * * @example * * Root * … * * * @example * * More details * * Content * * */ Header: PolymorphicForwardRefComponent<"div", PanelHeaderProps>; /** * You can use methods from `Panels.useInstance()` to control the state programmatically. * * @example * const panels = Panels.useInstance(); * * * {…}; */ useInstance: () => PanelsInstance; }; export {};