/** * Pixel-based edge-resize for fixed-width chrome surfaces (the Sidebar's * inline-end edge, the ToolRail panel's inner edge). Mirrors the * separator semantics of `Resizable`'s Handle — `role="separator"`, * arrow keys with RTL flip, Shift for coarse steps, Home/End to the * extremes, Enter or double-click to reset — but sizes a single target * element in pixels instead of distributing percentages across a panel * group. * * The hook owns the interaction and writes the resolved width to a CSS * custom property on the target element (the same property the * component's width classes already read), so the component keeps its * `var(--…)`-driven classes and no inline `width` ever appears. Reset * removes the override entirely, returning the surface to its * token-driven default. */ import { type KeyboardEvent, type PointerEvent as ReactPointerEvent, type RefObject } from 'react'; export interface UseEdgeResizeOptions { /** * Which logical edge of the target carries the handle. `inline-end` * for a start-docked surface (Sidebar); `inline-start` for an * end-docked one (ToolRail panel with `side="end"`). */ edge: 'inline-start' | 'inline-end'; /** The element being resized. The width override lands on its style. */ targetRef: RefObject; /** * CSS custom property the target's width classes read * (e.g. `--sidebar-modern-expanded-size`). Written as `px` on * resize, removed on reset. */ cssProperty: string; /** Clamp floor, px. */ minSize: number; /** Clamp ceiling, px. */ maxSize: number; /** * Nominal default width, px — used for `aria-valuenow` before the * element has been measured (SSR / jsdom) and as the reset target. */ defaultSize: number; /** Disables the interaction (handlers no-op, `aria-disabled` set). */ disabled?: boolean; /** Fired with the committed px width; `null` means reset-to-default. */ onResize?: (size: number | null) => void; /** * Controlled committed width, px; `null` for the token-driven default. * When provided (including `null`), the hook applies it to the target's * CSS property on mount and on every change — mirroring the "re-assert * on remount" effect components already run for the uncontrolled case. * Dragging and keyboard steps still update the CSS property and fire * `onResize` immediately for a responsive handle; the host is expected * to feed the committed value back through `size` on its next render, * the same contract as a controlled form input. Omit for uncontrolled * (internally-owned) sizing — the hook's default and existing behaviour. */ size?: number | null; } export interface EdgeResizeSeparatorProps { role: 'separator'; tabIndex: number; 'aria-orientation': 'vertical'; 'aria-valuemin': number; 'aria-valuemax': number; 'aria-valuenow': number; 'aria-valuetext': string; 'aria-disabled': boolean | undefined; onPointerDown: (event: ReactPointerEvent) => void; onPointerMove: (event: ReactPointerEvent) => void; onPointerUp: (event: ReactPointerEvent) => void; onPointerCancel: (event: ReactPointerEvent) => void; onLostPointerCapture: (event: ReactPointerEvent) => void; /** Ends a drag whose handle is removed before the pointer is released. */ ref: (node: HTMLElement | null) => void; onKeyDown: (event: KeyboardEvent) => void; onDoubleClick: () => void; } export interface UseEdgeResizeReturn { /** * Spread onto the handle element (a plain `
`; it carries its own * `ref`, so give the handle no other). Add `aria-label`, * and give the handle a `ds:touch-none` class — touch browsers decide * scroll-vs-drag at gesture start, before any pointer handler runs. */ separatorProps: EdgeResizeSeparatorProps; /** True while a pointer drag is in flight — suppress width transitions. */ isResizing: boolean; /** True once the user has overridden the token-driven default. */ isResized: boolean; /** Programmatic reset to the token-driven default width. */ reset: () => void; } export declare function useEdgeResize({ edge, targetRef, cssProperty, minSize, maxSize, defaultSize, disabled, onResize, size: controlledSize, }: UseEdgeResizeOptions): UseEdgeResizeReturn; //# sourceMappingURL=use-edge-resize.d.ts.map