import { type Dispatch, type RefObject, type SetStateAction } from 'react'; import type { DetailsRegionContextValue } from '../../details-region/DetailsRegionContext.js'; import type { ExtractedDetailsSlot } from '../../details-region/slots.js'; import type { ExtractedSidebarSlot } from '../../sidebar-region/slots.js'; import type { RenderedMode, SidebarRenderedMode } from './panel-mode.js'; /** @internal */ export interface UsePanelStateArgs { /** Controlled / uncontrolled props for the collapsed state. */ collapsed: { value: boolean | undefined; defaultValue: boolean; onChange: ((value: boolean) => void) | undefined; }; /** Container width below which the panel renders as a drawer. */ breakpoint: number; /** Container element observed for size changes. */ containerRef: RefObject; onBreakpointTransition: ((belowBreakpoint: boolean) => void) | undefined; /** See `useBreakpointCollapse`. `true` for the sidebar only. */ autoCollapse: boolean; /** * Whether the consumer drives the panel width. A controlled width keeps * `intendedWidth` unset so the consumer's value stays authoritative. */ isControlled: boolean; /** Mode rendered while the panel is open and above the breakpoint. */ baseMode: TBaseMode; onResize: ((value: number) => void) | undefined; } /** * Panel state of one collapsible, resizable panel, parameterized over the mode * it renders in while open: the sidebar only ever renders `'split'`, while the * details panel follows its preferred layout. Keeping the base mode a type * parameter is what lets each panel publish exactly the modes it can reach. * * @internal */ export interface PanelState { /** Most recent measured container width (`0` until first measurement). */ containerWidth: number; collapsed: boolean; setCollapsed: Dispatch>; mode: TBaseMode | 'collapsed' | 'drawer'; /** Width the user last dragged to, in px. `undefined` until dragged. */ intendedWidth: number | undefined; commitWidth: (value: number) => void; } /** * The single owner of panel state for `PageLayout`: the collapsed state, the * container measurement, the drag width and the resulting rendered mode. Both * the sidebar and the details panel are this hook plus a slot-specific * projection of its result. * * @internal */ export declare function usePanelState({ collapsed: collapsedProps, breakpoint, containerRef, onBreakpointTransition, autoCollapse, isControlled, baseMode, onResize, }: UsePanelStateArgs): PanelState; /** * Panel state of the sidebar. Owned by the `PageLayout.Sidebar` slot component * and published to the layout through the slot registry, so that unmounting or * key-replacing the slot discards it. * * @internal */ export type SidebarPanelState = Omit, 'containerWidth'>; /** @internal */ export declare function useSidebarPanelState({ sidebar, containerRef, }: { sidebar: Pick; containerRef: RefObject; }): SidebarPanelState; /** * Panel state of the details panel. Owned by the `PageLayout.Details` slot * component and published to the layout through the slot registry, so that * unmounting or key-replacing the slot discards it. * * A superset of `DetailsRegionContextValue`, so it can be handed straight to * `DetailsRegionContext.Provider`. * * @internal */ export interface DetailsPanelState extends DetailsRegionContextValue { containerWidth: number; /** Width the user last dragged to, in px. `undefined` until dragged. */ intendedWidth: number | undefined; commitWidth: (value: number) => void; } /** @internal */ export declare function useDetailsPanelState({ details, containerRef, }: { details: Pick; containerRef: RefObject; }): DetailsPanelState; //# sourceMappingURL=usePanelState.d.ts.map