@kumix/ui 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -30
- package/dist/{cascader-types-DVT-znZ-.d.ts → cascader-types-zhnUQ4sP.d.ts} +11 -3
- package/dist/cascader-types-zhnUQ4sP.d.ts.map +1 -0
- package/dist/components/agents/agent-code.js +1 -1
- package/dist/components/charts/candlestick-chart/context.d.ts.map +1 -1
- package/dist/components/charts/donut-chart/context.d.ts.map +1 -1
- package/dist/components/charts/liquidity-heatmap.d.ts.map +1 -1
- package/dist/components/charts/order-book.d.ts.map +1 -1
- package/dist/components/charts/treemap.d.ts.map +1 -1
- package/dist/components/charts/volume-profile.d.ts.map +1 -1
- package/dist/components/motion/action-swap.d.ts +1 -1
- package/dist/components/motion/action-swap.d.ts.map +1 -1
- package/dist/components/motion/action-swap.js +43 -20
- package/dist/components/motion/action-swap.js.map +1 -1
- package/dist/components/motion/animated-badge.d.ts +1 -1
- package/dist/components/motion/animated-badge.d.ts.map +1 -1
- package/dist/components/motion/animated-badge.js +60 -101
- package/dist/components/motion/animated-badge.js.map +1 -1
- package/dist/components/motion/animated-sidebar.js +1 -1
- package/dist/components/motion/animated-toast-stack.js +1 -1
- package/dist/components/motion/attachment-upload.js +1 -1
- package/dist/components/motion/availability-scheduler/copy-menu.js +1 -1
- package/dist/components/motion/availability-scheduler/day-row.js +1 -1
- package/dist/components/motion/availability-scheduler/index.js +1 -1
- package/dist/components/motion/bloom-menu.d.ts.map +1 -1
- package/dist/components/motion/bloom-menu.js +73 -8
- package/dist/components/motion/bloom-menu.js.map +1 -1
- package/dist/components/motion/bottom-sheet.d.ts.map +1 -1
- package/dist/components/motion/bottom-sheet.js +6 -10
- package/dist/components/motion/bottom-sheet.js.map +1 -1
- package/dist/components/motion/bouncy-accordion.d.ts.map +1 -1
- package/dist/components/motion/bouncy-accordion.js +35 -22
- package/dist/components/motion/bouncy-accordion.js.map +1 -1
- package/dist/components/motion/center-morph-modal.js +1 -1
- package/dist/components/motion/color-picker.d.ts.map +1 -1
- package/dist/components/motion/command-palette.js +1 -1
- package/dist/components/motion/context-menu.js +1 -1
- package/dist/components/motion/date-range-picker.d.ts.map +1 -1
- package/dist/components/motion/drawer.d.ts +1 -1
- package/dist/components/motion/drawer.d.ts.map +1 -1
- package/dist/components/motion/drawer.js +10 -10
- package/dist/components/motion/drawer.js.map +1 -1
- package/dist/components/motion/expandable-action-bar.d.ts.map +1 -1
- package/dist/components/motion/feedback-widget.js +4 -1
- package/dist/components/motion/feedback-widget.js.map +1 -1
- package/dist/components/motion/morphing-lightbox.d.ts.map +1 -1
- package/dist/components/motion/morphing-lightbox.js +1 -1
- package/dist/components/motion/morphing-modal.d.ts +6 -1
- package/dist/components/motion/morphing-modal.d.ts.map +1 -1
- package/dist/components/motion/morphing-modal.js +37 -5
- package/dist/components/motion/morphing-modal.js.map +1 -1
- package/dist/components/motion/morphing-search.js +1 -1
- package/dist/components/motion/morphing-tabs.js +1 -1
- package/dist/components/motion/otp-input.js +19 -11
- package/dist/components/motion/otp-input.js.map +1 -1
- package/dist/components/motion/popover-morph.d.ts +4 -3
- package/dist/components/motion/popover-morph.d.ts.map +1 -1
- package/dist/components/motion/popover-morph.js +47 -55
- package/dist/components/motion/popover-morph.js.map +1 -1
- package/dist/components/motion/popover.js +7 -1
- package/dist/components/motion/popover.js.map +1 -1
- package/dist/components/motion/prediction-market-card.js +1 -1
- package/dist/components/motion/prediction-market.js +1 -1
- package/dist/components/motion/project-folder.js +1 -1
- package/dist/components/motion/radio.d.ts +5 -1
- package/dist/components/motion/radio.d.ts.map +1 -1
- package/dist/components/motion/radio.js +53 -5
- package/dist/components/motion/radio.js.map +1 -1
- package/dist/components/motion/select-morph.d.ts +1 -1
- package/dist/components/motion/select-morph.d.ts.map +1 -1
- package/dist/components/motion/select-morph.js +89 -21
- package/dist/components/motion/select-morph.js.map +1 -1
- package/dist/components/motion/select.d.ts.map +1 -1
- package/dist/components/motion/select.js +153 -135
- package/dist/components/motion/select.js.map +1 -1
- package/dist/components/motion/shader-background.d.ts +3 -2
- package/dist/components/motion/shader-background.d.ts.map +1 -1
- package/dist/components/motion/shader-background.js +9 -3
- package/dist/components/motion/shader-background.js.map +1 -1
- package/dist/components/motion/shared-layout-bg.d.ts.map +1 -1
- package/dist/components/motion/shared-layout-bg.js +17 -3
- package/dist/components/motion/shared-layout-bg.js.map +1 -1
- package/dist/components/motion/swipeable-list.d.ts.map +1 -1
- package/dist/components/motion/swipeable-list.js +61 -4
- package/dist/components/motion/swipeable-list.js.map +1 -1
- package/dist/components/motion/table/row-handle.js +1 -1
- package/dist/components/motion/table/table-header.js +1 -1
- package/dist/components/motion/tabs.d.ts +12 -3
- package/dist/components/motion/tabs.d.ts.map +1 -1
- package/dist/components/motion/tabs.js +248 -26
- package/dist/components/motion/tabs.js.map +1 -1
- package/dist/components/motion/theme-toggle.js +1 -1
- package/dist/components/reui/alert.d.ts +1 -1
- package/dist/components/reui/autocomplete.d.ts +1 -1
- package/dist/components/reui/autocomplete.d.ts.map +1 -1
- package/dist/components/reui/autocomplete.js +1 -1
- package/dist/components/reui/autocomplete.js.map +1 -1
- package/dist/components/reui/badge.d.ts +2 -2
- package/dist/components/reui/cascader/cascader-async.d.ts +21 -5
- package/dist/components/reui/cascader/cascader-async.d.ts.map +1 -1
- package/dist/components/reui/cascader/cascader-async.js +61 -34
- package/dist/components/reui/cascader/cascader-async.js.map +1 -1
- package/dist/components/reui/cascader/cascader-columns.d.ts.map +1 -1
- package/dist/components/reui/cascader/cascader-columns.js +5 -2
- package/dist/components/reui/cascader/cascader-columns.js.map +1 -1
- package/dist/components/reui/cascader/cascader-context.d.ts +3 -1
- package/dist/components/reui/cascader/cascader-context.d.ts.map +1 -1
- package/dist/components/reui/cascader/cascader-context.js.map +1 -1
- package/dist/components/reui/cascader/cascader-i18n.d.ts +1 -1
- package/dist/components/reui/cascader/cascader-item.d.ts +1 -1
- package/dist/components/reui/cascader/cascader-lib.d.ts +34 -8
- package/dist/components/reui/cascader/cascader-lib.d.ts.map +1 -1
- package/dist/components/reui/cascader/cascader-lib.js +145 -29
- package/dist/components/reui/cascader/cascader-lib.js.map +1 -1
- package/dist/components/reui/cascader/cascader-nav.d.ts +1 -1
- package/dist/components/reui/cascader/cascader-types.d.ts +1 -1
- package/dist/components/reui/cascader/cascader.d.ts +13 -8
- package/dist/components/reui/cascader/cascader.d.ts.map +1 -1
- package/dist/components/reui/cascader/cascader.js +31 -16
- package/dist/components/reui/cascader/cascader.js.map +1 -1
- package/dist/components/reui/code-block/code-block.d.ts.map +1 -1
- package/dist/components/reui/color-picker.js +1 -1
- package/dist/components/reui/data-grid/data-grid-cell-selection.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-cell-selection.js +1 -0
- package/dist/components/reui/data-grid/data-grid-cell-selection.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-column-filter.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-column-filter.js +1 -0
- package/dist/components/reui/data-grid/data-grid-column-filter.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-column-header.d.ts +6 -8
- package/dist/components/reui/data-grid/data-grid-column-header.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-column-header.js +7 -8
- package/dist/components/reui/data-grid/data-grid-column-header.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-column-visibility.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-column-visibility.js +1 -0
- package/dist/components/reui/data-grid/data-grid-column-visibility.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-pagination.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-pagination.js +1 -0
- package/dist/components/reui/data-grid/data-grid-pagination.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-scroll-area.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-scroll-area.js +1 -0
- package/dist/components/reui/data-grid/data-grid-scroll-area.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-dnd-rows.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-dnd-rows.js +3 -2
- package/dist/components/reui/data-grid/data-grid-table-dnd-rows.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-dnd.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-dnd.js +2 -1
- package/dist/components/reui/data-grid/data-grid-table-dnd.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-virtual.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-virtual.js +2 -1
- package/dist/components/reui/data-grid/data-grid-table-virtual.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table.d.ts +6 -11
- package/dist/components/reui/data-grid/data-grid-table.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table.js +22 -22
- package/dist/components/reui/data-grid/data-grid-table.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid.d.ts +16 -1
- package/dist/components/reui/data-grid/data-grid.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid.js +80 -22
- package/dist/components/reui/data-grid/data-grid.js.map +1 -1
- package/dist/components/reui/date-selector.d.ts.map +1 -1
- package/dist/components/reui/date-selector.js +21 -15
- package/dist/components/reui/date-selector.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-agenda-view.js +3 -5
- package/dist/components/reui/event-calendar/event-calendar-agenda-view.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-nav.d.ts.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-nav.js +2 -2
- package/dist/components/reui/event-calendar/event-calendar-nav.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar.d.ts.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar.js +34 -31
- package/dist/components/reui/event-calendar/event-calendar.js.map +1 -1
- package/dist/components/reui/file-type.d.ts +302 -6
- package/dist/components/reui/file-type.d.ts.map +1 -1
- package/dist/components/reui/file-type.js +416 -13
- package/dist/components/reui/file-type.js.map +1 -1
- package/dist/components/reui/filters/filters-builder.d.ts +1 -1
- package/dist/components/reui/filters/filters-lib.d.ts +1 -1
- package/dist/components/reui/frame.d.ts +1 -1
- package/dist/components/reui/gantt/gantt-nav.d.ts.map +1 -1
- package/dist/components/reui/gantt/gantt-nav.js +2 -2
- package/dist/components/reui/gantt/gantt-nav.js.map +1 -1
- package/dist/components/reui/gantt/gantt.d.ts.map +1 -1
- package/dist/components/reui/gantt/gantt.js +5 -2
- package/dist/components/reui/gantt/gantt.js.map +1 -1
- package/dist/components/reui/icon-tile.d.ts +2 -2
- package/dist/components/reui/number-field.d.ts +3 -3
- package/dist/components/reui/phone-input.js +30 -27
- package/dist/components/reui/phone-input.js.map +1 -1
- package/dist/components/reui/rating.d.ts +1 -1
- package/dist/components/reui/time-picker.js +1 -1
- package/dist/components/ui/attachment.d.ts +2 -2
- package/dist/components/ui/badge.d.ts +1 -1
- package/dist/components/ui/bubble.d.ts +1 -1
- package/dist/components/ui/button.d.ts +2 -2
- package/dist/components/ui/chart.d.ts.map +1 -1
- package/dist/components/ui/code-block.d.ts +29 -0
- package/dist/components/ui/code-block.d.ts.map +1 -0
- package/dist/components/ui/code-block.js +124 -0
- package/dist/components/ui/code-block.js.map +1 -0
- package/dist/components/ui/empty.d.ts +1 -1
- package/dist/components/ui/item.d.ts +2 -2
- package/dist/components/ui/marker.d.ts +1 -1
- package/dist/components/ui/sidebar.d.ts +1 -1
- package/dist/components/ui/toggle.d.ts +1 -1
- package/dist/components/ui/trace.d.ts +21 -0
- package/dist/components/ui/trace.d.ts.map +1 -0
- package/dist/components/ui/trace.js +77 -0
- package/dist/components/ui/trace.js.map +1 -0
- package/dist/context-BYXeJQnz.d.ts.map +1 -1
- package/dist/{copy-menu-BXUh52bu.js → copy-menu-DOg9Jh-U.js} +2 -2
- package/dist/{copy-menu-BXUh52bu.js.map → copy-menu-DOg9Jh-U.js.map} +1 -1
- package/dist/hooks/use-focus-trap.d.ts +22 -0
- package/dist/hooks/use-focus-trap.d.ts.map +1 -0
- package/dist/hooks/use-focus-trap.js +80 -0
- package/dist/hooks/use-focus-trap.js.map +1 -0
- package/dist/hooks/use-highlighted-code.d.ts +5 -0
- package/dist/hooks/use-highlighted-code.d.ts.map +1 -0
- package/dist/hooks/use-highlighted-code.js +128 -0
- package/dist/hooks/use-highlighted-code.js.map +1 -0
- package/dist/hooks/use-listbox.d.ts +29 -0
- package/dist/hooks/use-listbox.d.ts.map +1 -0
- package/dist/hooks/use-listbox.js +75 -0
- package/dist/hooks/use-listbox.js.map +1 -0
- package/dist/tooltip-C01qUgsW.d.ts.map +1 -1
- package/package.json +8 -8
- package/dist/cascader-types-DVT-znZ-.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cascader.js","names":["React","ComboboxPrimitive"],"sources":["../../../../src/components/reui/cascader/cascader.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { Combobox as ComboboxPrimitive } from \"@base-ui/react\";\nimport { mergeProps } from \"@base-ui/react/merge-props\";\nimport { useRender } from \"@base-ui/react/use-render\";\nimport { ChevronDownIcon, XIcon } from \"lucide-react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { ScrollArea } from \"../../ui/scroll-area\";\nimport type { CascaderGetChildren, CascaderOnSearch, CascaderResolveValue } from \"./cascader-async\";\nimport { useCascaderLoader, useCascaderLoadState } from \"./cascader-async\";\nimport type {\n CascaderActionsContextValue,\n CascaderColumn,\n CascaderHighlight,\n CascaderHighlightStore,\n CascaderItemState,\n CascaderRenderContextValue,\n CascaderStateContextValue,\n} from \"./cascader-context\";\nimport {\n CascaderActionsContext,\n CascaderHighlightContext,\n CascaderRenderContext,\n CascaderStateContext,\n createCascaderHighlightStore,\n useCascaderActions,\n useCascaderHighlight,\n useCascaderRender,\n useCascaderState,\n} from \"./cascader-context\";\nimport { resolveCascaderLabels } from \"./cascader-i18n\";\nimport type { CascaderCheckedStrategy } from \"./cascader-lib\";\nimport {\n applyCascadeSelection,\n buildCascaderIndex,\n CASCADER_LIST_HEIGHT_CLASS,\n CASCADER_LIST_PAD_CLASS,\n CASCADER_ROOT_KEY,\n CASCADER_ROWS_CLASS,\n CASCADER_SCROLL_CLASS,\n collapseCascaderPath,\n createCascaderMoreNode,\n filterCascaderLevel,\n findAmbiguousCascaderLabels,\n findCascaderDataIssues,\n flattenCascaderTree,\n getCascaderCheckedValues,\n getCascaderChildren,\n getCascaderCount,\n getCascaderIndeterminateFrom,\n getCascaderPath,\n getCascaderSelectedDescendants,\n getCascaderTabTarget,\n isCascaderBranch,\n isCascaderDisabled,\n isCascaderMoreNode,\n isCascaderSelectable,\n matchesCascaderQuery,\n mergeCascaderIndex,\n normalizeCascaderQuery,\n searchCascaderDeep,\n warnCascaderOnce,\n} from \"./cascader-lib\";\nimport type {\n CascaderActionItem,\n CascaderChangeDetails,\n CascaderChangeReason,\n CascaderFlatNode,\n CascaderIndex,\n CascaderLabels,\n CascaderLoadState,\n CascaderMode,\n CascaderNode,\n CascaderSearchScope,\n CascaderSelectable,\n} from \"./cascader-types\";\n\n/** Stable `filteredItems` for a level swap; a fixed identity cannot loop. */\nconst EMPTY: CascaderNode<never>[] = [];\n\n/** Stable empty array for the `actions` prop, so a cascader with no footer\n * does not republish the actions context on every render. */\nconst EMPTY_ACTIONS: CascaderActionItem[] = [];\n\n/** The `onSearch` scope of a global search: no path, so the whole tree. */\nconst GLOBAL_SEARCH_PATH: string[] = [];\n\n// Word joiner. A polite region reads only MUTATIONS, so alternate it.\nconst ANNOUNCE_MARKER = \"\\u2060\";\n\n// Delay before a query result-count reaches the live region: polite\n// announcements queue, and re-announcing per keystroke plays back stale\n// counts. Only the count defers; every event-shaped one stays immediate.\nconst ANNOUNCE_DEBOUNCE = 150;\n\n/* -------------------------------------------------------------------------- */\n/* State */\n/* -------------------------------------------------------------------------- */\n\n// Minimal controlled/uncontrolled resolver, hand-rolled because the repo has\n// no shared `useControllableState`; the root needs it five times.\nfunction useControllable<V>(\n controlled: V | undefined,\n defaultValue: V,\n onChange?: (value: V) => void,\n /** Prop name, used only by the development-time switching warning. */\n devName?: string,\n): [V, (next: V | ((prev: V) => V)) => void] {\n const [uncontrolled, setUncontrolled] = React.useState(defaultValue);\n const isControlled = controlled !== undefined;\n const value = isControlled ? controlled : uncontrolled;\n\n // Switching controlled/uncontrolled mid-life strands half the state.\n const wasControlled = React.useRef(isControlled);\n React.useEffect(() => {\n if (process.env.NODE_ENV === \"production\") return;\n if (wasControlled.current === isControlled || !devName) return;\n const from = wasControlled.current ? \"controlled\" : \"uncontrolled\";\n const to = isControlled ? \"controlled\" : \"uncontrolled\";\n wasControlled.current = isControlled;\n warnCascaderOnce(\n `controlled-switch:${devName}`,\n `\\`${devName}\\` switched from ${from} to ${to}. Decide once: pass \\`${devName}\\` for the whole life of the component, or pass only the default and let the cascader own it.`,\n );\n }, [isControlled, devName]);\n\n // Written in an EFFECT: a discarded render would still have mutated a ref.\n const latest = React.useRef({ value, isControlled, onChange });\n React.useEffect(() => {\n latest.current = { value, isControlled, onChange };\n });\n\n // The last PROP seen: it differs from the optimistic advance exactly when a\n // controlled parent declines a change and re-renders nothing.\n const lastProp = React.useRef(controlled);\n React.useEffect(() => {\n lastProp.current = controlled;\n });\n\n const set = React.useCallback((next: V | ((prev: V) => V)) => {\n const current = latest.current.value;\n const resolved = typeof next === \"function\" ? (next as (prev: V) => V)(current) : next;\n if (Object.is(resolved, current)) {\n // Dedup against the last PROP, not the optimistic advance: a parent that\n // declines re-renders nothing, so deduping on the advance left the popup\n // un-dismissable from the second Escape on.\n if (!latest.current.isControlled || Object.is(resolved, lastProp.current)) {\n return;\n }\n }\n\n // Advance now so two updates in ONE batch compose, rather than the second\n // reading a stale value and its `Object.is` dedup dropping it.\n latest.current = { ...latest.current, value: resolved };\n\n if (!latest.current.isControlled) setUncontrolled(resolved);\n latest.current.onChange?.(resolved);\n }, []);\n\n return [value, set];\n}\n\n/* -------------------------------------------------------------------------- */\n/* Shallow stability */\n/* -------------------------------------------------------------------------- */\n\nfunction shallowEqualRecords(a: object, b: object): boolean {\n const left = a as Record<string, unknown>;\n const right = b as Record<string, unknown>;\n const keys = Object.keys(left);\n if (keys.length !== Object.keys(right).length) return false;\n for (const key of keys) {\n if (!Object.is(left[key], right[key])) return false;\n }\n return true;\n}\n\nfunction shallowEqualItemLists(a: readonly object[], b: readonly object[]): boolean {\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i += 1) {\n if (a[i] !== b[i] && !shallowEqualRecords(a[i], b[i])) return false;\n }\n return true;\n}\n\n// Reuses the previous value while the next merely says the same thing: an\n// inline `labels`/`actions` otherwise republishes the actions context, and\n// with it every row. Adjust-state-during-render, not a ref.\nfunction useShallowStable<V>(value: V, equal: (a: V & object, b: V & object) => boolean): V {\n const [stable, setStable] = React.useState(value);\n if (Object.is(value, stable)) return stable;\n const comparable =\n typeof value === \"object\" && value !== null && typeof stable === \"object\" && stable !== null;\n if (comparable && equal(value as V & object, stable as V & object)) {\n return stable;\n }\n setStable(value);\n return value;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Context */\n/* -------------------------------------------------------------------------- */\n\n/** The pre-split shape, merged, so `useCascader()` returns what it always did. */\nexport interface CascaderContextValue<T = unknown>\n extends CascaderActionsContextValue<T>,\n CascaderStateContextValue<T> {}\n\n/**\n * The cascader's internals, typed for the caller's own item payload.\n * @deprecated Reads BOTH halves, so a caller re-renders on every keystroke.\n * Prefer `useCascaderActions()` or `useCascaderState()`. Kept for compat.\n */\nexport function useCascader<T = unknown>(): CascaderContextValue<T> {\n const actions = useCascaderActions<T>();\n const state = useCascaderState<T>();\n\n return React.useMemo(() => ({ ...actions, ...state }), [actions, state]);\n}\n\n/* -------------------------------------------------------------------------- */\n/* Headless selection */\n/* -------------------------------------------------------------------------- */\n\nexport interface CascaderSelection<T = unknown> {\n /** The selected nodes, resolved. Empty when nothing is selected. */\n selected: CascaderNode<T>[];\n /** Ancestor chain per selected node, root first, node last. */\n paths: CascaderNode<T>[][];\n /** The single selection, or the first one in `multiple` mode. */\n first: CascaderNode<T> | null;\n /** Ancestor chain of `first`. */\n firstPath: CascaderNode<T>[];\n count: number;\n isEmpty: boolean;\n multiple: boolean;\n remove: (value: string) => void;\n clear: () => void;\n}\n\n/** Headless access to the selection, for a trigger that is not\n * `CascaderValue`. Pass the payload explicitly to get `node.data` typed. */\nexport function useCascaderSelection<T = unknown>(): CascaderSelection<T> {\n const { multiple, setSelection } = useCascaderActions<T>();\n const { index, selectedValues } = useCascaderState<T>();\n\n return React.useMemo(() => {\n const selected = selectedValues\n .map((value) => index.byValue.get(value))\n .filter(Boolean) as CascaderNode<T>[];\n const paths = selectedValues.map((value) => getCascaderPath(index, value));\n\n return {\n selected,\n paths,\n first: selected[0] ?? null,\n firstPath: paths[0] ?? [],\n count: selectedValues.length,\n isEmpty: selectedValues.length === 0,\n multiple,\n remove: (value: string) => setSelection(selectedValues.filter((entry) => entry !== value)),\n // Explicit reason: emptying on purpose is not \"deselect the last node\".\n clear: () => setSelection([], \"clear\"),\n };\n }, [index, selectedValues, multiple, setSelection]);\n}\n\n/* -------------------------------------------------------------------------- */\n/* Root */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Why the navigation path changed.\n * - `\"drill\"`: a branch was entered (row press, level arrow, search hit).\n * - `\"back\"`: one level up (back control, Backspace on an empty query).\n * - `\"breadcrumb\"`: a jump to an exact depth in the trail.\n * - `\"reveal\"`: the reopen navigated to the level holding the selection.\n * - `\"external\"`: `setPath` called from outside the primitive's own flows.\n */\nexport type CascaderPathChangeReason = \"drill\" | \"back\" | \"breadcrumb\" | \"reveal\" | \"external\";\n\n/** Everything independent of the selection mode; the rest is on the two arms. */\nexport interface CascaderBaseProps<T = unknown> {\n /** Nested tree, or a flat list when `getParent` is supplied. */\n items: CascaderNode<T>[];\n /** Opt in to flat adjacency input by returning each node's parent value. */\n getParent?: (node: CascaderNode<T>) => string | null | undefined;\n\n /**\n * Fetches one level on demand; `node` is `null` for the root. Return an\n * array, or a `CascaderLoadResult` when the level pages. Pages cache apart\n * from `items`; mark unfetched branches `hasChildren` or they read as leaves.\n */\n getChildren?: CascaderGetChildren<T>;\n /**\n * Server-side search, debounced by `searchDebounce`; replaces the local scan\n * while the query is set. Results are detached: resolvable by value, in no\n * level. Ignored in `mode=\"tree\"`, where a hit belongs to no visible branch.\n */\n onSearch?: CascaderOnSearch<T>;\n /** Milliseconds of quiet before `onSearch` fires. */\n searchDebounce?: number;\n /**\n * Resolves a value the loader has never seen into its ancestor chain, root\n * first, so the trigger can path a server-supplied selection. Does NOT mark\n * those levels loaded: opening one still fetches.\n */\n resolveValue?: CascaderResolveValue<T>;\n /** Cache key. Changing it drops every page and aborts anything in flight. */\n loadKey?: unknown;\n /** Prefetch a highlighted branch's children after a pause. Off by default. */\n prefetch?: boolean;\n /**\n * Called when a load fails. `context.parent` is the level (`null` for root);\n * `context.reason` is `\"level\"`, `\"more\"`, `\"retry\"`, `\"prefetch\"`,\n * `\"search\"` or `\"resolve\"`. Never for an aborted or superseded request.\n */\n onLoadError?: (error: unknown, context: { parent: string | null; reason: string }) => void;\n\n /** Which nodes may be committed. Defaults to leaves only. */\n selectable?: CascaderSelectable<T>;\n\n /**\n * Whether the built-in SINGLE-SELECT check is drawn. Defaults to true.\n * `false` also gives back the inline-end gutter every style reserves for it;\n * `data-selected` and `aria-selected` stay. A no-op under `multiple`, where\n * the checkbox is the selection CONTROL rather than a decoration.\n */\n indicator?: boolean;\n\n /**\n * Footer ACTIONS: commands pinned below the list, never rows in it, and never\n * touching the data tree. A childless `<CascaderFooter />` draws these; an\n * action with `items` opens a side-anchored flyout rather than firing.\n */\n actions?: CascaderActionItem[];\n\n /**\n * Parent/child cascading. Multi-select only, off by default, and it needs\n * committable branches (`selectable=\"any\"` or a predicate). A commit selects\n * or deselects every SELECTABLE node in the LOADED subtree and reconciles\n * ancestors. LOADED is the semantic, not a hedge: a commit must not fan out\n * into a request per level, so children arriving later arrive unchecked.\n */\n cascade?: boolean;\n\n mode?: CascaderMode;\n\n /** How a branch opens from the pointer in columns mode's ACTIVE column.\n * `\"click\"` is the default, and neither value ever commits a selection. */\n expandTrigger?: \"click\" | \"hover\";\n\n path?: string[];\n defaultPath?: string[];\n /** The second argument says WHY. An existing `(path) => void` still works. */\n onPathChange?: (path: string[], details: { reason: CascaderPathChangeReason }) => void;\n\n expanded?: string[];\n defaultExpanded?: string[];\n onExpandedChange?: (expanded: string[]) => void;\n\n open?: boolean;\n defaultOpen?: boolean;\n /** Forwards Base UI's reason; a leaf commit's close says `\"item-press\"`. */\n onOpenChange?: (open: boolean, details: { reason: string }) => void;\n\n /**\n * Whether a SINGLE-SELECT leaf commit closes the popup. Defaults to true.\n * `false` is for a compare-and-repick flow; Escape, outside press and the\n * trigger still close. Ignored under `multiple`, which never closes.\n */\n closeOnSelect?: boolean;\n\n inputValue?: string;\n defaultInputValue?: string;\n onInputValueChange?: (value: string) => void;\n\n /**\n * `\"level\"` (default) filters the level on screen, `\"deep\"` also searches\n * below it, `\"global\"` searches the whole tree from any level.\n */\n searchScope?: CascaderSearchScope;\n /** Custom matcher, replacing label + keywords substring matching. */\n filter?: (node: CascaderNode<T>, normalizedQuery: string) => boolean;\n\n /** On open, navigate to the level holding the selection. Default true. */\n revealSelected?: boolean;\n\n maxHeight?: number | string;\n\n /**\n * Window the rendered rows. `undefined` decides per level from\n * `virtualizeThreshold`; `true`/`false` force it. Also opt-in at the markup\n * level, so the base install pulls in no virtualization library.\n */\n virtualize?: boolean;\n /** Row count at which windowing turns itself on. */\n virtualizeThreshold?: number;\n /** Row height handed to the virtualizer before a row has been measured. */\n estimateRowSize?: number;\n /** Rows rendered beyond each edge of the viewport. */\n overscan?: number;\n\n labels?: Partial<CascaderLabels>;\n /** Replaces the entire row, affordances included. */\n renderItem?: (node: CascaderNode<T>, state: CascaderItemState<T>) => React.ReactNode;\n /** Replaces only the label block; icon, count, chevron and check stay. */\n renderLabel?: (node: CascaderNode<T>, state: CascaderItemState<T>) => React.ReactNode;\n\n disabled?: boolean;\n /** Native form field name. Submits the selected value(s). */\n name?: string;\n /** Id of the owning form, for a cascader rendered outside it. */\n form?: string;\n /** Id of the control. Pairs the field with a `<label htmlFor>`. */\n id?: string;\n /** Marks the field required for native form validation. */\n required?: boolean;\n /** The value can be read and submitted, but not changed. */\n readOnly?: boolean;\n /** Marks the field invalid: `aria-invalid` and `data-invalid` on the trigger,\n * the chips and the input, which every style's error treatment reads. */\n invalid?: boolean;\n /** Ref to the hidden input Base UI submits with, for form-library focus. */\n inputRef?: React.Ref<HTMLInputElement>;\n /** Renders without a floating popup, for an embedded `CascaderPanel`. */\n inline?: boolean;\n\n children?: React.ReactNode;\n}\n\nexport interface CascaderSingleProps<T = unknown> extends CascaderBaseProps<T> {\n multiple?: false;\n value?: string;\n defaultValue?: string;\n onValueChange?: (value: string, details: CascaderChangeDetails<T>) => void;\n /** `never` so passing it is a compile error, not a silent no-op. */\n max?: never;\n}\n\n/** Multi-select props. Enables checkbox rows and chip display. */\nexport interface CascaderMultipleProps<T = unknown> extends CascaderBaseProps<T> {\n multiple: true;\n value?: string[];\n defaultValue?: string[];\n onValueChange?: (value: string[], details: CascaderChangeDetails<T>) => void;\n /** Cap on selections. Further picks are refused, the existing ones survive. */\n max?: number;\n}\n\n/** `multiple` discriminates: `value`, `onValueChange` and `max` narrow with it. */\nexport type CascaderProps<T = unknown> = CascaderSingleProps<T> | CascaderMultipleProps<T>;\n\n/** Normalizes to an array. `\"\"` is \"no selection\", not a node: it is the\n * uncontrolled default, and resolving it would render a blank chip. */\nfunction toArray(value: string | string[] | undefined): string[] {\n if (value == null) return [];\n if (Array.isArray(value)) return value.filter((entry) => entry !== \"\");\n return value === \"\" ? [] : [value];\n}\n\n/* -------------------------------------------------------------------------- */\n/* Development warnings */\n/* -------------------------------------------------------------------------- */\n\ninterface CascaderDevOptions<T> {\n items: CascaderNode<T>[];\n getParent?: (node: CascaderNode<T>) => string | null | undefined;\n mode: CascaderMode;\n multiple: boolean;\n cascade: boolean;\n indicator: boolean;\n selectable: CascaderSelectable<T>;\n searchScope: CascaderSearchScope;\n max: number | undefined;\n value: string | string[] | undefined;\n defaultValue: string | string[] | undefined;\n hasExpanded: boolean;\n hasPath: boolean;\n hasOnSearch: boolean;\n}\n\n/** Misconfigurations that are SILENT by design. Once each, never in prod. */\nfunction useCascaderDevWarnings<T>(options: CascaderDevOptions<T>) {\n const {\n items,\n getParent,\n mode,\n multiple,\n cascade,\n indicator,\n selectable,\n searchScope,\n max,\n value,\n defaultValue,\n hasExpanded,\n hasPath,\n hasOnSearch,\n } = options;\n\n // O(n) over the raw input, so the memo is skipped outright in production.\n const issues = React.useMemo(\n () => (process.env.NODE_ENV === \"production\" ? null : findCascaderDataIssues(items, getParent)),\n [items, getParent],\n );\n\n React.useEffect(() => {\n if (process.env.NODE_ENV === \"production\") return;\n\n for (const duplicate of issues?.duplicates ?? []) {\n warnCascaderOnce(\n `duplicate-value:${duplicate}`,\n `Duplicate node value ${JSON.stringify(duplicate)}. \\`value\\` is the selection key, so only the first occurrence is indexed and the rest never render.`,\n );\n }\n\n for (const cycle of issues?.cycles ?? []) {\n warnCascaderOnce(\n `cycle:${cycle}`,\n `\\`getParent\\` puts ${JSON.stringify(cycle)} on a cycle. The depth walk is cycle-guarded so nothing hangs, but every depth on that chain is clamped rather than derived.`,\n );\n }\n }, [issues]);\n\n React.useEffect(() => {\n if (process.env.NODE_ENV === \"production\") return;\n\n for (const [prop, current] of [\n [\"value\", value],\n [\"defaultValue\", defaultValue],\n ] as const) {\n if (current == null) continue;\n if (multiple && !Array.isArray(current)) {\n warnCascaderOnce(\n `value-shape:multiple:${prop}`,\n `\\`multiple\\` is set but \\`${prop}\\` is a string. Multi-select reads and writes a \\`string[]\\`; a string is treated as no selection at all.`,\n );\n } else if (!multiple && Array.isArray(current)) {\n warnCascaderOnce(\n `value-shape:single:${prop}`,\n `\\`${prop}\\` is an array but \\`multiple\\` is not set. Single-select reads and writes a \\`string\\`; only the first entry would survive a commit.`,\n );\n }\n }\n\n if (cascade && !multiple) {\n warnCascaderOnce(\n \"cascade-without-multiple\",\n \"`cascade` does nothing without `multiple`: a single selection has no subtree to propagate over.\",\n );\n }\n\n if (cascade && selectable === \"leaf\") {\n warnCascaderOnce(\n \"cascade-with-leaf-selectable\",\n '`cascade` does nothing while `selectable=\"leaf\"`: no branch can be committed, so no commit ever has a subtree under it. Pass `selectable=\"any\"` or a predicate that accepts branches.',\n );\n }\n\n if (!indicator && multiple) {\n warnCascaderOnce(\n \"indicator-false-with-multiple\",\n \"`indicator={false}` does nothing with `multiple`: the checkbox is the selection control rather than a decoration, so it and its gutter stay. Mark selection your own way from `data-selected` on the row, and drop the prop.\",\n );\n }\n\n if (max != null && !multiple) {\n warnCascaderOnce(\n \"max-without-multiple\",\n \"`max` does nothing without `multiple`: there is only ever one selection to cap.\",\n );\n }\n\n if (hasExpanded && mode !== \"tree\") {\n warnCascaderOnce(\n `expanded-outside-tree:${mode}`,\n `\\`expanded\\` only does something in \\`mode=\"tree\"\\`, and this cascader is in \\`mode=\"${mode}\"\\`. Drill and columns navigate with \\`path\\`.`,\n );\n }\n\n if (hasPath && mode === \"tree\") {\n warnCascaderOnce(\n \"path-in-tree\",\n '`path` does nothing in `mode=\"tree\"`: branches expand in place rather than replacing the level. Use `expanded`.',\n );\n }\n\n if (searchScope === \"deep\" && mode === \"tree\") {\n warnCascaderOnce(\n \"deep-search-in-tree\",\n '`searchScope=\"deep\"` does nothing in `mode=\"tree\"`: a tree query already matches at any depth and auto-expands the ancestors of every hit.',\n );\n }\n\n if (searchScope === \"global\" && mode === \"tree\") {\n warnCascaderOnce(\n \"global-search-in-tree\",\n '`searchScope=\"global\"` does nothing in `mode=\"tree\"`: a tree query already searches the whole tree and auto-expands the ancestors of every hit.',\n );\n }\n\n if (hasOnSearch && mode === \"tree\") {\n warnCascaderOnce(\n \"onsearch-in-tree\",\n '`onSearch` does nothing in `mode=\"tree\"`: a tree query filters the loaded tree in place, and a server hit belongs to no visible branch, so its results would never render. The request is not fired. Filter the tree locally, or use drill or columns for server search.',\n );\n }\n }, [\n mode,\n multiple,\n cascade,\n indicator,\n selectable,\n searchScope,\n max,\n value,\n defaultValue,\n hasExpanded,\n hasPath,\n hasOnSearch,\n ]);\n}\n\n/** What the `[]`-dep callbacks would otherwise close over. One ref, one\n * effect, so \"the last committed render\" is defined in exactly one place. */\ninterface CascaderLatest<T> {\n index: CascaderIndex<T>;\n state: CascaderStateContextValue<T>;\n mode: CascaderMode;\n multiple: boolean;\n cascade: boolean;\n max: number | undefined;\n labels: CascaderLabels;\n closeOnSelect: boolean;\n selectedValues: string[];\n deepResults: CascaderNode<T>[] | null;\n onValueChange:\n | ((value: string | string[], details: CascaderChangeDetails<T>) => void)\n | undefined;\n resolveNode: (value: string) => CascaderNode<T>;\n isSelectable: (node: CascaderNode<T>) => boolean;\n needsChildren: (node: CascaderNode<T>) => boolean;\n expanded: ReadonlySet<string>;\n}\n\n/** A navigation waiting on a fetch. The `kind`s differ: a drill appends, a\n * columns press replaces the trail from `depth`, a search hit swaps in its own\n * `trail`, a tree press expands. */\ntype CascaderPendingNavigation =\n | {\n value: string;\n kind: \"push\" | \"at\" | \"expand\";\n /** `kind: \"at\"` only. The depth the pressed row belongs to. */\n depth: number;\n }\n | {\n value: string;\n kind: \"trail\";\n /** The hit's ancestor chain, root first, the hit itself last. */\n trail: string[];\n };\n\n/** No default on `T`: inferred from `items`, so `node.data` arrives typed. */\nfunction Cascader<T>({\n items,\n getParent,\n getChildren,\n onSearch,\n searchDebounce,\n resolveValue,\n loadKey,\n prefetch,\n onLoadError,\n value: valueProp,\n defaultValue,\n onValueChange: onValueChangeProp,\n multiple = false,\n selectable = \"leaf\",\n indicator = true,\n actions,\n cascade = false,\n max,\n mode = \"drill\",\n expandTrigger,\n path: pathProp,\n defaultPath,\n onPathChange,\n expanded: expandedProp,\n defaultExpanded,\n onExpandedChange,\n open: openProp,\n defaultOpen = false,\n onOpenChange,\n closeOnSelect = true,\n inputValue: inputValueProp,\n defaultInputValue = \"\",\n onInputValueChange,\n searchScope = \"level\",\n filter,\n revealSelected = true,\n maxHeight,\n virtualize,\n virtualizeThreshold = 100,\n estimateRowSize = 32,\n overscan = 8,\n labels: labelsProp,\n renderItem,\n renderLabel,\n disabled,\n name,\n form,\n id,\n required,\n readOnly,\n invalid,\n inputRef,\n inline,\n children,\n}: CascaderProps<T>) {\n const baseIndex = React.useMemo(\n () => buildCascaderIndex(items, getParent),\n // `getParent` is stable by design: an inline accessor must not rebuild a\n // 50k-node index.\n [items, getParent],\n );\n\n const baseId = React.useId();\n\n // Shallow-stabilized first: an inline `labels` would republish the context.\n const stableLabelsProp = useShallowStable(labelsProp, shallowEqualRecords);\n\n const labels = React.useMemo(() => resolveCascaderLabels(stableLabelsProp), [stableLabelsProp]);\n\n useCascaderDevWarnings({\n items,\n getParent,\n mode,\n multiple,\n cascade,\n indicator,\n selectable,\n searchScope,\n max,\n value: valueProp,\n defaultValue,\n hasExpanded:\n expandedProp !== undefined || defaultExpanded !== undefined || onExpandedChange !== undefined,\n hasPath: pathProp !== undefined || defaultPath !== undefined || onPathChange !== undefined,\n hasOnSearch: onSearch !== undefined,\n });\n\n // Public props are discriminated, internals are not: one assertion.\n const onValueChange = onValueChangeProp as\n | ((value: string | string[], details: CascaderChangeDetails<T>) => void)\n | undefined;\n\n // No `onChange`: `onValueChange` takes a second argument, so `emitSelection`\n // invokes it rather than the state hook, which only knows the value.\n const [value, setValue] = useControllable<string | string[]>(\n valueProp,\n defaultValue ?? (multiple ? [] : \"\"),\n undefined,\n \"value\",\n );\n // Why the current path (or open) change is happening. Refs, not arguments:\n // `useControllable` only passes a value, and its onChange runs synchronously\n // inside the setter, so a ref written just before is exact. The path ref\n // resets to `\"external\"`, which is what the consumer's `setPath` reports.\n const pathReasonRef = React.useRef<CascaderPathChangeReason>(\"external\");\n const openReasonRef = React.useRef<string>(\"none\");\n\n const [path, setPath] = useControllable<string[]>(\n pathProp,\n defaultPath ?? [],\n (next) => onPathChange?.(next, { reason: pathReasonRef.current }),\n \"path\",\n );\n const [expandedList, setExpandedList] = useControllable<string[]>(\n expandedProp,\n defaultExpanded ?? [],\n onExpandedChange,\n \"expanded\",\n );\n const [open, setOpen] = useControllable<boolean>(\n openProp,\n defaultOpen,\n (next) => onOpenChange?.(next, { reason: openReasonRef.current }),\n \"open\",\n );\n\n /** The internal `setPath`: names its reason, then hands back to \"external\". */\n const setPathWithReason = React.useCallback(\n (next: string[] | ((prev: string[]) => string[]), reason: CascaderPathChangeReason) => {\n pathReasonRef.current = reason;\n try {\n setPath(next);\n } finally {\n pathReasonRef.current = \"external\";\n }\n },\n [setPath],\n );\n const [query, setQuery] = useControllable<string>(\n inputValueProp,\n defaultInputValue,\n onInputValueChange,\n \"inputValue\",\n );\n\n const expanded = React.useMemo(() => new Set(expandedList), [expandedList]);\n const selectedValues = React.useMemo(() => toArray(value), [value]);\n\n /* --------------------------------- async -------------------------------- */\n\n // On-screen levels, so the ones worth fetching. Columns shows the whole\n // trail at once, which is why the loader is per-level, not one flag.\n const levels = React.useMemo(() => {\n if (mode === \"tree\") return [CASCADER_ROOT_KEY, ...expandedList];\n if (mode === \"columns\") return [CASCADER_ROOT_KEY, ...path];\n return [path.length ? path[path.length - 1] : CASCADER_ROOT_KEY];\n }, [mode, path, expandedList]);\n\n // A SIBLING of the index build, never a step inside it: the build stays pure\n // in `items`, the loader owns the pages, the merge is pure in both, and that\n // is what makes loaded data survive an `items` change.\n const loader = useCascaderLoader<T>({\n base: baseIndex,\n getChildren,\n // Gated, not merely unrendered: a tree hit belongs to no visible branch.\n onSearch: mode === \"tree\" ? undefined : onSearch,\n resolveValue,\n searchDebounce,\n loadKey,\n prefetch,\n onLoadError,\n // An inline cascader is never \"open\", but its panel is live.\n enabled: open || !!inline,\n query,\n levels,\n path: searchScope === \"global\" ? GLOBAL_SEARCH_PATH : path,\n values: selectedValues,\n });\n\n const loadStates = loader.states;\n\n // Destructured here, not at the actions memo, because `navigate` sits above\n // it. All three are `[]`-dep inside the loader, so identity is stable.\n const { ensureLevel, retryLevel: retryLoaderLevel, invalidateLevel } = loader;\n\n /**\n * Whether pressing this branch has to FETCH first: in flight, failed, or\n * never asked. `baseIndex`, NOT the merged `index`: `resolveValue` writes an\n * ancestor chain into `pages` without touching `states`, so the merged index\n * shows children for levels never requested. Must agree with `ensureLevel`'s\n * own guards or a press parks a navigation nothing will ever settle.\n */\n const needsChildren = React.useCallback(\n (node: CascaderNode<T>) => {\n if (!loader.active) return false;\n const state = loadStates.get(node.value);\n if (state) return state.loading || state.error;\n return !baseIndex.childrenOf.has(node.value);\n },\n [loader.active, loadStates, baseIndex],\n );\n\n // Keyed on the two maps the merge reads, NOT the store: `withLoadState`\n // returns a fresh store over the SAME maps, so keying on it rebuilt the\n // whole index on every loading flip that changed no data.\n const index = React.useMemo(\n () => mergeCascaderIndex(baseIndex, loader.store.pages, loader.store.detached),\n [baseIndex, loader.store.pages, loader.store.detached],\n );\n\n /** Whether a level needs the paging pseudo-row. A never-fetched level gets\n * nothing; that is the empty state's job. Tree has no per-level empty state,\n * so there the row is also the branch's loading and error surface. */\n const needsMoreRow = React.useCallback(\n (key: string, childCount: number) => {\n const state = loadStates.get(key);\n if (!state) return false;\n if (childCount > 0) return state.hasMore || state.loading || state.error;\n return mode === \"tree\" && (state.loading || state.error);\n },\n [loadStates, mode],\n );\n\n // Remembers every selected node, so the trigger keeps a label after it\n // leaves the loaded set (or was never in it).\n const labelCacheRef = React.useRef(new Map<string, CascaderNode<T>>());\n\n // Populated during render, since the trigger reads it while rendering.\n // Idempotent and prop-derived, so a discarded render is harmless.\n for (const selected of selectedValues) {\n const node = index.byValue.get(selected);\n if (node) labelCacheRef.current.set(selected, node);\n }\n\n const resolveNode = React.useCallback(\n (nodeValue: string): CascaderNode<T> =>\n index.byValue.get(nodeValue) ??\n labelCacheRef.current.get(nodeValue) ?? {\n value: nodeValue,\n label: nodeValue,\n },\n [index],\n );\n\n /* ------------------------------ derived view ----------------------------- */\n\n const currentParentValue = path.length ? path[path.length - 1] : null;\n const currentParent = currentParentValue ? (index.byValue.get(currentParentValue) ?? null) : null;\n\n const currentLevelKey = currentParentValue ?? CASCADER_ROOT_KEY;\n\n const isDeepSearching =\n (searchScope === \"deep\" || searchScope === \"global\") &&\n query.trim().length > 0 &&\n mode !== \"tree\";\n // Global is the same scan from the root, whatever level is on screen.\n const deepSearchWithin = searchScope === \"global\" ? null : currentParentValue;\n\n const localDeepResults = React.useMemo(() => {\n if (!isDeepSearching) return null;\n return searchCascaderDeep(index, query, {\n within: deepSearchWithin,\n matches: filter,\n });\n }, [isDeepSearching, index, query, deepSearchWithin, filter]);\n\n // Server search wins over the local scan, or each hit shows up twice.\n const deepResults = loader.searchResults ?? localDeepResults;\n\n const levelItems = React.useMemo(() => {\n const level = getCascaderChildren(index, currentParentValue);\n return filterCascaderLevel(level, query, filter);\n }, [index, currentParentValue, query, filter]);\n\n /** The active level's rows plus the paging pseudo-row, appended HERE because\n * every index Base UI hands out indexes this array: a DOM row missing from\n * it shifts the highlight and every windowed row by one. */\n const levelRendered = React.useMemo(() => {\n if (deepResults) return deepResults;\n if (!needsMoreRow(currentLevelKey, levelItems.length)) return levelItems;\n return [...levelItems, createCascaderMoreNode<T>(currentLevelKey, levelItems.length)];\n }, [deepResults, levelItems, currentLevelKey, needsMoreRow]);\n\n // Columns renders the whole trail, but only the deepest column is\n // interactive through Base UI, so `renderedItems` stays what drill uses.\n const columns = React.useMemo<CascaderColumn<T>[]>(() => {\n if (mode !== \"columns\") return [];\n const trail: CascaderColumn<T>[] = [];\n for (let depth = 0; depth <= path.length; depth += 1) {\n const parentValue = depth === 0 ? null : path[depth - 1];\n const parent = parentValue ? (index.byValue.get(parentValue) ?? null) : null;\n const isActive = depth === path.length;\n let columnItems: CascaderNode<T>[];\n if (isActive) {\n columnItems = levelRendered;\n } else {\n // A trail column pages on its own, without losing the columns right of it.\n const key = parentValue ?? CASCADER_ROOT_KEY;\n const children = getCascaderChildren(index, parentValue);\n columnItems = needsMoreRow(key, children.length)\n ? [...children, createCascaderMoreNode<T>(key, children.length)]\n : children;\n }\n trail.push({\n parent,\n depth,\n activeValue: path[depth] ?? null,\n active: isActive,\n // Only the active column is filtered: a query narrows what you type\n // into, never the trail behind it.\n items: columnItems,\n });\n }\n return trail;\n }, [mode, path, index, levelRendered, needsMoreRow]);\n\n // Tree level keys needing a paging pseudo-row. With no per-level empty\n // state, this is also where a still-loading branch says so.\n const treeSentinels = React.useMemo(() => {\n if (mode !== \"tree\") return undefined;\n const keys = new Set<string>();\n const consider = (key: string) => {\n if (needsMoreRow(key, index.childrenOf.get(key)?.length ?? 0)) {\n keys.add(key);\n }\n };\n consider(CASCADER_ROOT_KEY);\n for (const value of expanded) consider(value);\n return keys.size ? keys : undefined;\n }, [mode, index, expanded, needsMoreRow]);\n\n const treeRows = React.useMemo<CascaderFlatNode<T>[]>(() => {\n if (mode !== \"tree\") return [];\n const rows = flattenCascaderTree(index, expanded, treeSentinels);\n // Same normalizer as the level filter, so the two cannot disagree.\n const normalized = normalizeCascaderQuery(query);\n if (!normalized) return rows;\n // Matches every node, not just visible rows, and keeps the ancestors, or a\n // hit inside a collapsed branch disappears. Same matcher as every other\n // path, so keyword-only hits do not vanish in tree mode alone.\n const keep = new Set<string>();\n for (const node of index.all) {\n if (!(filter ? filter(node, normalized) : matchesCascaderQuery(node, normalized))) {\n continue;\n }\n for (const ancestor of getCascaderPath(index, node.value)) {\n keep.add(ancestor.value);\n }\n }\n // No sentinels while filtering: that page would not have the query applied.\n return flattenCascaderTree(index, new Set([...expanded, ...keep])).filter((row) =>\n keep.has(row.node.value),\n );\n }, [mode, index, expanded, treeSentinels, query, filter]);\n\n // What `Combobox.Root` receives. Tree flattens to the same linear list, so\n // selection and highlighting need no per-mode case.\n const renderedItems = React.useMemo(\n () => (mode === \"tree\" ? treeRows.map((row) => row.node) : levelRendered),\n [mode, treeRows, levelRendered],\n );\n\n /* ---------------------------- level swap reset --------------------------- */\n\n /** Base UI never resets the highlighted index on an `items` change and has\n * no imperative setter; its one automatic reset is an out-of-range clamp, so\n * a single empty frame trips it. The frame rides `filteredItems`, so the\n * `items` identity stays put. */\n const levelKey = currentParentValue ?? \"\";\n\n // STATE, not a ref: a replayed render would see a ref advanced and skip it.\n const [swap, setSwap] = React.useState({ key: levelKey, active: false });\n\n if (swap.key !== levelKey) {\n setSwap({ key: levelKey, active: true });\n }\n const swapping = swap.active && swap.key === levelKey;\n\n React.useLayoutEffect(() => {\n if (swap.active) setSwap((prev) => ({ ...prev, active: false }));\n }, [swap.active]);\n\n // The same frame on demand, for a navigation that lands on the level already\n // on screen: the key never moves, so the check above never fires.\n const resetHighlight = React.useCallback(() => {\n setSwap((prev) => (prev.active ? prev : { ...prev, active: true }));\n }, []);\n\n /* ----------------------------- virtualization ---------------------------- */\n\n // A COUNT: columns mounts one per column, and StrictMode remounts effects.\n const [virtualRenderers, setVirtualRenderers] = React.useState(0);\n\n const registerVirtualRenderer = React.useCallback(() => {\n setVirtualRenderers((count) => count + 1);\n return () => setVirtualRenderers((count) => Math.max(0, count - 1));\n }, []);\n\n const hasVirtualRenderer = virtualRenderers > 0;\n const wantsVirtual = virtualize ?? renderedItems.length >= virtualizeThreshold;\n\n // LATCHED per level: otherwise a query narrowing a 5,000 row level past the\n // threshold tears the virtualizer down and rebuilds it on backspace, losing\n // every measurement. State, not a ref, like `swap`.\n const [virtualLatch, setVirtualLatch] = React.useState({\n key: levelKey,\n on: false,\n });\n\n const virtualized =\n hasVirtualRenderer &&\n (virtualLatch.key === levelKey ? virtualLatch.on || wantsVirtual : wantsVirtual);\n\n if (!hasVirtualRenderer) {\n // Nothing is windowing, so nothing may stay latched.\n if (virtualLatch.on || virtualLatch.key !== levelKey) {\n setVirtualLatch({ key: levelKey, on: false });\n }\n } else if (virtualLatch.key !== levelKey) {\n setVirtualLatch({ key: levelKey, on: virtualized });\n } else if (virtualized && !virtualLatch.on) {\n setVirtualLatch({ key: levelKey, on: true });\n }\n\n /**\n * One forced re-render, one commit AFTER windowing turns on. Base UI sizes\n * `listRef` from `filteredItems` in a layout effect keyed on that array's\n * identity, but `virtualized` reaches the list a commit later and the\n * `CompositeList` teardown REPLACES `listRef` with an empty array nothing\n * re-sizes, so ArrowDown stops at the last WINDOWED row. A passive effect is\n * late enough: the teardown is scheduled from a layout effect.\n */\n const [_virtualSyncs, setVirtualSyncs] = React.useState(0);\n\n React.useEffect(() => {\n if (!virtualized) return;\n setVirtualSyncs((count) => count + 1);\n }, [virtualized]);\n\n React.useEffect(() => {\n if (process.env.NODE_ENV === \"production\") return undefined;\n if (virtualize !== true || hasVirtualRenderer) return undefined;\n // Deferred a tick: the renderer registers from a layout effect, so a\n // synchronous check would report every correctly wired cascader.\n const timeout = setTimeout(() => {\n console.error(\n \"[Cascader] `virtualize` is true but no windowing renderer is mounted. \" +\n \"Render <CascaderVirtualItems /> inside <CascaderList>, or \" +\n \"<CascaderVirtualColumn /> through the <CascaderColumns> slot.\",\n );\n }, 0);\n return () => clearTimeout(timeout);\n }, [virtualize, hasVirtualRenderer]);\n\n /* ------------------------------ navigation ------------------------------ */\n\n /** One signal per navigation, feeding the live region, bumped EXACTLY once\n * per action. `seq` alternates the invisible marker so two identical\n * announcements are still two mutations; `toggled` names the tree branch. */\n const [announceSignal, setAnnounceSignal] = React.useState<{\n seq: number;\n toggled: string | null;\n /** A one-off verbatim message: a `max` refusal, a cascade fan-out. STATE,\n * so an unrelated render cannot clear it mid-read. */\n notice: string | null;\n }>({ seq: 0, toggled: null, notice: null });\n\n const bumpAnnouncement = React.useCallback((toggled: string | null) => {\n setAnnounceSignal((prev) => ({ seq: prev.seq + 1, toggled, notice: null }));\n }, []);\n\n /** Speaks for interactions that change nothing on screen: a refusal returns\n * before any state moves, a cascade sweep is invisible from the row pressed.\n * The seq bump keeps two identical refusals two mutations. */\n const announceNotice = React.useCallback((notice: string) => {\n setAnnounceSignal((prev) => ({ seq: prev.seq + 1, toggled: null, notice }));\n }, []);\n\n /**\n * The navigation a press asked for and a fetch has not answered yet. Load\n * BEFORE you move: drilling in first threw away the list the user was\n * reading and, on failure, stranded them on an error screen for a level they\n * had never seen. Holding here keeps the old rows and puts the progress on\n * the pressed row, whose chevron `CascaderItem` swaps for a spinner.\n */\n const [pendingNavigation, setPendingNavigation] =\n React.useState<CascaderPendingNavigation | null>(null);\n\n /** Asks for a branch's children and parks the navigation until they land.\n * BOTH entry points are called unconditionally: `retryLevel` no-ops unless\n * the level errored, `ensureLevel` no-ops if it has state, so a repeat press\n * is free and the readiness decision stays inside the loader. */\n const requestChildren = React.useCallback(\n (node: CascaderNode<T>, pending: CascaderPendingNavigation) => {\n setPendingNavigation(pending);\n retryLoaderLevel(node.value);\n ensureLevel(node.value, \"level\");\n // Otherwise the panel is silent from the press until the level swaps.\n bumpAnnouncement(null);\n },\n [retryLoaderLevel, ensureLevel, bumpAnnouncement],\n );\n\n const pushLevel = React.useCallback(\n (nodeValue: string) => {\n setPathWithReason((prev) => [...prev, nodeValue], \"drill\");\n setQuery(\"\");\n bumpAnnouncement(null);\n },\n [setPathWithReason, setQuery, bumpAnnouncement],\n );\n\n const popLevel = React.useCallback(() => {\n setPathWithReason((prev) => (prev.length ? prev.slice(0, -1) : prev), \"back\");\n setQuery(\"\");\n // Going BACK abandons a held navigation, or an in-flight branch drills in\n // the moment it lands, long after the user moved on.\n setPendingNavigation(null);\n bumpAnnouncement(null);\n }, [setPathWithReason, setQuery, bumpAnnouncement]);\n\n const goToDepth = React.useCallback(\n (depth: number) => {\n setPathWithReason((prev) => prev.slice(0, Math.max(0, depth)), \"breadcrumb\");\n setQuery(\"\");\n setPendingNavigation(null);\n bumpAnnouncement(null);\n },\n [setPathWithReason, setQuery, bumpAnnouncement],\n );\n\n const toggleExpanded = React.useCallback(\n (nodeValue: string) => {\n setExpandedList((prev) =>\n prev.includes(nodeValue) ? prev.filter((v) => v !== nodeValue) : [...prev, nodeValue],\n );\n bumpAnnouncement(nodeValue);\n },\n [setExpandedList, bumpAnnouncement],\n );\n\n const isBranch = React.useCallback(\n (node: CascaderNode<T>) => isCascaderBranch(index, node),\n [index],\n );\n\n const isSelectable = React.useCallback(\n (node: CascaderNode<T>) => isCascaderSelectable(index, node, selectable),\n [index, selectable],\n );\n\n const isDisabled = React.useCallback(\n (node: CascaderNode<T>) => isCascaderDisabled(index, node),\n [index],\n );\n\n // Whether a branch can be committed AT ALL here. `\"leaf\"` is the only\n // setting that answers no in advance; a predicate is opaque, so the check\n // gutter is reserved uniformly rather than per row.\n const branchesSelectable = selectable !== \"leaf\";\n\n // Open flyouts, by key. A ref, not state: `handleOpenChange` needs the\n // answer as of the Escape being handled, and opening a footer menu must not\n // re-render the root.\n const openFlyoutsRef = React.useRef<Set<string>>(new Set());\n\n const setFlyoutOpen = React.useCallback((key: string, open: boolean) => {\n if (open) openFlyoutsRef.current.add(key);\n else openFlyoutsRef.current.delete(key);\n }, []);\n\n const hasOpenFlyout = React.useCallback(() => openFlyoutsRef.current.size > 0, []);\n\n // Shallow-stabilized like `labels`: an inline array republished the context.\n const stableActions = useShallowStable(actions, shallowEqualItemLists);\n\n const resolvedActions = React.useMemo<CascaderActionItem[]>(\n () => stableActions ?? EMPTY_ACTIONS,\n [stableActions],\n );\n\n // A Set, not an `includes` scan: `isSelected` runs once per rendered row.\n const selectedSet = React.useMemo(() => new Set(selectedValues), [selectedValues]);\n\n const isSelected = React.useCallback(\n (node: CascaderNode<T>) => selectedSet.has(node.value),\n [selectedSet],\n );\n\n /** Selected-descendant counts, walked ONCE per selection change and never\n * stored, so the flat value array stays the only source of truth. The walk\n * is `selections x depth`, up from each selection rather than down from each\n * row, which keeps the count and `isIndeterminate` O(1). */\n const selectedDescendants = React.useMemo(\n () => getCascaderSelectedDescendants(index, selectedValues),\n [index, selectedValues],\n );\n\n const selectedDescendantCount = React.useCallback(\n (node: CascaderNode<T>) => selectedDescendants.get(node.value) ?? 0,\n [selectedDescendants],\n );\n\n // Partial selections read off the SAME map, so the dash and the number are\n // two readings of one traversal and cannot drift apart.\n const indeterminateSet = React.useMemo(() => {\n if (!cascade || !multiple) return null;\n return getCascaderIndeterminateFrom(selectedDescendants, selectedValues);\n }, [cascade, multiple, selectedDescendants, selectedValues]);\n\n const isIndeterminate = React.useCallback(\n (node: CascaderNode<T>) => indeterminateSet?.has(node.value) ?? false,\n [indeterminateSet],\n );\n\n // Base UI owns the highlight; mirrored so handlers can read it unsubscribed.\n const highlightedRef = React.useRef<CascaderNode<T> | null>(null);\n const getHighlighted = React.useCallback(() => highlightedRef.current, []);\n\n // The same highlight as an external store, for the consumer that must\n // RE-RENDER on it. `useState`, not `useMemo`: React may drop a memo, and a\n // second store would silently orphan every subscriber.\n const [highlightStore] = React.useState<CascaderHighlightStore>(createCascaderHighlightStore);\n\n /* ------------------------------ announcement ---------------------------- */\n\n const currentLoadState = React.useMemo<CascaderLoadState | null>(\n () => loadStates.get(currentLevelKey) ?? null,\n [loadStates, currentLevelKey],\n );\n const searchLoadState = loader.searchState;\n\n /** What the query announcement COUNTS: matches, not rows, since the list\n * also carries a tree query's ancestor context and the Load-more row. Server\n * hits count as-is; re-judging them locally would drop what it matched on\n * data the client cannot see. */\n const announcedMatches = React.useMemo(() => {\n if (deepResults) return deepResults.length;\n const normalized = normalizeCascaderQuery(query);\n if (!normalized) return 0;\n const matches = filter ?? matchesCascaderQuery;\n return renderedItems.filter((node) => !isCascaderMoreNode(node) && matches(node, normalized))\n .length;\n }, [deepResults, renderedItems, query, filter]);\n\n // The live-region text plus whether it may be DEFERRED; see\n // `ANNOUNCE_DEBOUNCE`. The committed string is state, set below.\n const announcementTarget = React.useMemo(() => {\n // An INLINE cascader is never \"open\", so `open` alone silenced its tree.\n if (!open && !inline) return { text: \"\", defer: false };\n\n const total = renderedItems.length;\n const marker = ANNOUNCE_MARKER.repeat(announceSignal.seq % 2);\n\n // A notice outranks everything below: it exists because nothing else on\n // screen changed. It rides the signal, so the next navigation replaces it.\n if (announceSignal.notice) {\n return { text: `${announceSignal.notice}${marker}`, defer: false };\n }\n\n // A tree toggle changes neither level nor query, so it rides the signal.\n const toggled =\n mode === \"tree\" && announceSignal.toggled\n ? (index.byValue.get(announceSignal.toggled) ?? null)\n : null;\n\n // Async states outrank everything below, or a fetching level announces \"0\n // results\" and contradicts itself. A HELD navigation outranks even those:\n // nothing on screen has moved yet, so \"loading\" is the only truth.\n const pendingState = pendingNavigation\n ? (loadStates.get(pendingNavigation.value) ?? null)\n : null;\n const levelState = query.trim() ? searchLoadState : currentLoadState;\n let text: string;\n let defer = false;\n if (pendingState?.error) {\n text = labels.error;\n } else if (pendingNavigation) {\n // Always the FIRST-page string: the rows on screen belong to the level\n // being left behind, so their count says nothing about this request.\n text = labels.loading;\n } else if (levelState?.error) {\n text = labels.error;\n } else if (levelState?.loading) {\n // With a query set the in-flight load IS the server search, and calling\n // that \"Loading more\" misreads what is being waited on.\n text = query.trim()\n ? labels.searchingAnnouncement\n : total > 0\n ? labels.loadingMore\n : labels.loading;\n } else if (query.trim()) {\n // An empty result set is the more useful thing to say than \"0 results\".\n text = announcedMatches === 0 ? labels.empty : labels.resultsAnnouncement(announcedMatches);\n // The ONE deferred branch: only a stream of keystrokes needs coalescing.\n defer = true;\n } else if (toggled) {\n text = expanded.has(toggled.value)\n ? labels.expandedAnnouncement(toggled.label, getCascaderCount(index, toggled))\n : labels.collapsedAnnouncement(toggled.label);\n } else if (currentParent) {\n // `path.length + 1` matches tree mode's `aria-level`: the rows are\n // `currentParent`'s CHILDREN, one level below it.\n text = labels.levelAnnouncement(currentParent.label, path.length + 1, total);\n } else {\n // Returning to the root would otherwise announce nothing at all.\n text = labels.rootAnnouncement(total);\n }\n\n return { text: `${text}${marker}`, defer };\n }, [\n open,\n inline,\n mode,\n index,\n expanded,\n announceSignal,\n query,\n labels,\n renderedItems.length,\n announcedMatches,\n currentParent,\n path.length,\n currentLoadState,\n searchLoadState,\n pendingNavigation,\n loadStates,\n ]);\n\n /** The COMMITTED announcement. Immediate texts commit during render (the\n * pattern `swap` uses), so an async settle announces in the very commit that\n * shows the rows. Only the deferred query count uses the timer below. */\n const [announced, setAnnounced] = React.useState(announcementTarget);\n\n if (!announcementTarget.defer && announced.text !== announcementTarget.text) {\n // Terminates: after the set the condition is false on the re-render.\n setAnnounced(announcementTarget);\n }\n\n React.useEffect(() => {\n if (!announcementTarget.defer) return undefined;\n const timer = setTimeout(() => setAnnounced(announcementTarget), ANNOUNCE_DEBOUNCE);\n return () => clearTimeout(timer);\n }, [announcementTarget]);\n\n const announcement = announced.text;\n\n /* --------------------------------- state -------------------------------- */\n\n // The volatile half: rebuilt by a keystroke, hence split from the actions.\n const stateValue = React.useMemo<CascaderStateContextValue<T>>(\n () => ({\n index,\n path,\n expanded,\n query,\n currentParent,\n levelItems,\n deepResults,\n renderedItems,\n columns,\n treeRows,\n selectedValues,\n selectedDescendants,\n loadStates,\n searchState: searchLoadState,\n announcement,\n }),\n [\n index,\n path,\n expanded,\n query,\n currentParent,\n levelItems,\n deepResults,\n renderedItems,\n columns,\n treeRows,\n selectedValues,\n selectedDescendants,\n loadStates,\n searchLoadState,\n announcement,\n ],\n );\n\n /* ------------------------------ latest props ---------------------------- */\n\n /**\n * Latest committed props and derived state, WRITTEN IN AN EFFECT. That is\n * what keeps the callbacks below `[]`-dep and stable for the life of the\n * cascader; writing during render is unsafe under concurrent rendering. The\n * cost: a read sees the PREVIOUS commit until the effect runs, so ONLY event\n * handlers may read it. Anything used during render is memoised instead.\n */\n const latest = React.useRef<CascaderLatest<T>>({\n index,\n state: stateValue,\n mode,\n multiple,\n cascade,\n max,\n labels,\n closeOnSelect,\n selectedValues,\n deepResults,\n onValueChange,\n resolveNode,\n isSelectable,\n needsChildren,\n expanded,\n });\n\n React.useEffect(() => {\n latest.current = {\n index,\n state: stateValue,\n mode,\n multiple,\n cascade,\n max,\n labels,\n closeOnSelect,\n selectedValues,\n deepResults,\n onValueChange,\n resolveNode,\n isSelectable,\n needsChildren,\n expanded,\n };\n });\n\n const getIndex = React.useCallback(() => latest.current.index, []);\n const getState = React.useCallback(() => latest.current.state, []);\n\n const goToLevelAt = React.useCallback(\n (nodeValue: string, depth: number) => {\n setPathWithReason((prev) => [...prev.slice(0, Math.max(0, depth)), nodeValue], \"drill\");\n setQuery(\"\");\n bumpAnnouncement(null);\n },\n [setPathWithReason, setQuery, bumpAnnouncement],\n );\n\n const goToTrail = React.useCallback(\n (trail: string[]) => {\n // A global hit can BE the level on screen. Then nothing moved, so no path\n // change is reported, and no level swap clears the highlight the hit\n // list left at its index, where Enter would commit some other row.\n const { path: current } = latest.current.state;\n const stays =\n trail.length === current.length && trail.every((entry, i) => entry === current[i]);\n if (stays) resetHighlight();\n else setPathWithReason(trail, \"drill\");\n setQuery(\"\");\n bumpAnnouncement(null);\n },\n [setPathWithReason, resetHighlight, setQuery, bumpAnnouncement],\n );\n\n const navigateAt = React.useCallback(\n (node: CascaderNode<T>, depth: number) => {\n if (isCascaderDisabled(latest.current.index, node)) return;\n if (latest.current.mode === \"tree\") {\n toggleExpanded(node.value);\n return;\n }\n if (latest.current.needsChildren(node)) {\n requestChildren(node, { value: node.value, kind: \"at\", depth });\n return;\n }\n goToLevelAt(node.value, depth);\n },\n [toggleExpanded, goToLevelAt, requestChildren],\n );\n\n const navigate = React.useCallback(\n (node: CascaderNode<T>) => {\n const {\n mode: currentMode,\n deepResults: currentDeepResults,\n index: currentIndex,\n expanded: currentExpanded,\n needsChildren: pending,\n } = latest.current;\n\n // Every drill and expand passes here, from a search hit, a key or a hover\n // timer alike, so this is where a disabled subtree stays shut.\n if (isCascaderDisabled(currentIndex, node)) return;\n\n if (currentMode === \"tree\") {\n // Collapsing never needs data. Opening waits WITHOUT expanding, so\n // the branch stays shut with a spinner rather than opening onto no rows.\n if (!currentExpanded.has(node.value) && pending(node)) {\n requestChildren(node, {\n value: node.value,\n kind: \"expand\",\n depth: 0,\n });\n return;\n }\n toggleExpanded(node.value);\n return;\n }\n\n // A search hit sits at any depth, and under a global search outside the\n // current path, so drilling in swaps in the hit's own trail. A held drill\n // carries it too: splicing the hit into the current path at its depth\n // kept the wrong ancestors for anything below a direct child.\n if (currentDeepResults) {\n const trail = getCascaderPath(currentIndex, node.value).map((entry) => entry.value);\n if (pending(node)) {\n requestChildren(node, { value: node.value, kind: \"trail\", trail });\n return;\n }\n goToTrail(trail);\n return;\n }\n\n if (pending(node)) {\n requestChildren(node, { value: node.value, kind: \"push\", depth: 0 });\n return;\n }\n pushLevel(node.value);\n },\n [toggleExpanded, goToTrail, pushLevel, requestChildren],\n );\n\n /**\n * The other half of `requestChildren`: the fetch settled, so the held\n * navigation happens or is dropped. Reads the load STATE, not a promise:\n * only the loader knows a request was superseded, aborted or retried, and no\n * entry at all means it has not reached the store yet. On failure nothing\n * moves and the intent is KEPT, which is what makes the row's retry\n * affordance mean something; only `popLevel`, `goToDepth` and a close drop it.\n */\n React.useEffect(() => {\n if (!pendingNavigation) return;\n const state = loadStates.get(pendingNavigation.value);\n if (!state || state.loading || state.error) return;\n\n setPendingNavigation(null);\n\n // Asked again against the index as it is NOW: a new `items` or a landed\n // page can disable the target while its fetch was in flight.\n const target = index.byValue.get(pendingNavigation.value);\n if (target && isDisabled(target)) return;\n\n if (pendingNavigation.kind === \"expand\") {\n toggleExpanded(pendingNavigation.value);\n return;\n }\n if (pendingNavigation.kind === \"trail\") {\n goToTrail(pendingNavigation.trail);\n return;\n }\n if (pendingNavigation.kind === \"at\") {\n goToLevelAt(pendingNavigation.value, pendingNavigation.depth);\n return;\n }\n pushLevel(pendingNavigation.value);\n }, [\n pendingNavigation,\n loadStates,\n index,\n isDisabled,\n toggleExpanded,\n goToTrail,\n goToLevelAt,\n pushLevel,\n ]);\n\n // A popup that closes mid-flight must not drill in when the answer arrives;\n // the loader aborts the request, this drops the intent.\n React.useEffect(() => {\n if (!open && !inline) setPendingNavigation(null);\n }, [open, inline]);\n\n /* ------------------------------- selection ------------------------------ */\n\n // The one place the selection changes, so `onValueChange` reports the same\n // shape whatever caused it: a row press, drag-select, or the headless hooks.\n const emitSelection = React.useCallback(\n (nextValues: string[], node: CascaderNode<T> | null, reason: CascaderChangeReason) => {\n const {\n selectedValues: current,\n multiple: currentMultiple,\n onValueChange: emit,\n index: currentIndex,\n resolveNode: resolve,\n } = latest.current;\n\n // Nothing changed. The dedup lives here now, not in `useControllable`.\n const unchanged =\n nextValues.length === current.length &&\n nextValues.every((entry, i) => entry === current[i]);\n if (unchanged) return;\n\n const next = currentMultiple ? nextValues : (nextValues[0] ?? \"\");\n setValue(next);\n\n if (!emit) return;\n\n const chain = node ? getCascaderPath(currentIndex, node.value) : [];\n emit(next, {\n node,\n // A node absent from `items` has no chain, so fall back to the node\n // rather than report an empty path for a change that had one.\n path: node ? (chain.length ? chain : [node]) : [],\n // `resolveNode`, not `index.byValue`: a selected value missing from\n // `items` must still come back rather than be dropped.\n nodes: nextValues.map(resolve),\n reason,\n });\n },\n [setValue],\n );\n\n const setSelection = React.useCallback(\n (values: string[], reason?: CascaderChangeReason) => {\n const { selectedValues: current, resolveNode: resolve } = latest.current;\n const before = new Set(current);\n const after = new Set(values);\n const added = values.find((entry) => !before.has(entry));\n const removed = current.find((entry) => !after.has(entry));\n\n if (reason === \"clear\") {\n emitSelection(values, null, \"clear\");\n return;\n }\n if (added) {\n emitSelection(values, resolve(added), reason ?? \"select\");\n return;\n }\n if (removed) {\n emitSelection(values, resolve(removed), reason ?? \"deselect\");\n return;\n }\n // Same set: a no-op, but routed so an explicit `reason` still applies.\n emitSelection(values, null, reason ?? \"select\");\n },\n [emitSelection],\n );\n\n const commit = React.useCallback(\n (node: CascaderNode<T>) => {\n const {\n multiple: currentMultiple,\n cascade: currentCascade,\n selectedValues: current,\n max: currentMax,\n index: currentIndex,\n isSelectable: currentIsSelectable,\n labels: currentLabels,\n closeOnSelect: currentCloseOnSelect,\n } = latest.current;\n\n // Refuses a SELECT, never a removal: a disabled value set from outside\n // must stay removable, and a cascade chip's removal arrives here.\n const selecting = !currentMultiple || !current.includes(node.value);\n if (selecting && isCascaderDisabled(currentIndex, node)) return;\n\n if (!currentMultiple) {\n emitSelection([node.value], node, \"select\");\n if (currentCloseOnSelect) {\n openReasonRef.current = \"item-press\";\n setOpen(false);\n } else {\n // The popup stays up, so clear the query the way a multiple commit\n // does; the next pick then starts from the full level.\n setQuery(\"\");\n }\n return;\n }\n\n if (currentCascade) {\n const next = applyCascadeSelection(\n currentIndex,\n current,\n node.value,\n selecting,\n currentIsSelectable,\n );\n // `max` caps the whole gesture rather than truncating it: an arbitrary\n // prefix of a subtree is a selection nobody asked for. The refusal\n // changes nothing on screen, so the live region is its only witness.\n if (\n selecting &&\n currentMax != null &&\n next.length > currentMax &&\n next.length > current.length\n ) {\n announceNotice(currentLabels.maxReachedAnnouncement(currentMax));\n return;\n }\n emitSelection(next, node, selecting ? \"select\" : \"deselect\");\n // How many values the closure swept along is invisible from the one\n // row pressed, so the sweep says its number out loud, itself excluded.\n const before = new Set(current);\n const after = new Set(next);\n let swept = 0;\n for (const entry of selecting ? next : current) {\n if (entry === node.value) continue;\n if (selecting ? !before.has(entry) : !after.has(entry)) swept += 1;\n }\n if (swept > 0) {\n announceNotice(\n currentLabels.cascadeAnnouncement(node.label ?? node.value, swept, selecting),\n );\n }\n setQuery(\"\");\n return;\n }\n\n if (current.includes(node.value)) {\n emitSelection(\n current.filter((v) => v !== node.value),\n node,\n \"deselect\",\n );\n } else if (currentMax == null || current.length < currentMax) {\n emitSelection([...current, node.value], node, \"select\");\n } else {\n // The plain-multiple twin of the cascade refusal above: just as silent.\n announceNotice(currentLabels.maxReachedAnnouncement(currentMax));\n }\n setQuery(\"\");\n },\n [emitSelection, setOpen, setQuery, announceNotice],\n );\n\n /** Safety net for paths that bypass the row-level veto (the drag-select\n * mouseup). `details.cancel()` suppresses the commit and the close together:\n * Base UI shares one event-details object between them. */\n const handleComboboxValueChange = React.useCallback(\n (\n next: CascaderNode<T> | CascaderNode<T>[] | null,\n details: ComboboxPrimitive.Root.ChangeEventDetails,\n ) => {\n if (!multiple) {\n const node = Array.isArray(next) ? (next[0] ?? null) : next;\n // The paging row is a real option, so Base UI reports it as a\n // selection. Same safety net branches get, for paths a row cannot veto.\n if (node && isCascaderMoreNode(node)) {\n details.cancel();\n return;\n }\n // The row is Base UI `disabled` already, so only a path around it gets\n // here, a custom row re-enabling it for one: refused, never navigated.\n if (node && isDisabled(node)) {\n details.cancel();\n return;\n }\n if (node && !isSelectable(node) && isBranch(node)) {\n details.cancel();\n navigate(node);\n return;\n }\n if (node) {\n // `closeOnSelect={false}` must also stop Base UI's OWN close; one\n // shared details object, so cancelling suppresses both, and our value\n // is controlled, so Base UI's half had nothing to keep.\n if (!closeOnSelect) details.cancel();\n commit(node);\n }\n return;\n }\n\n // Take Base UI's whole array as the answer and inspect only what was\n // ADDED. Deriving the toggle from the tail works for an add but on a\n // remove drops the wrong node, leaving the last selection unclearable.\n const nextNodes = Array.isArray(next) ? next : [];\n const before = new Set(selectedValues);\n const added = nextNodes.find((node) => !before.has(node.value));\n\n if (added && (isCascaderMoreNode(added) || isDisabled(added))) {\n details.cancel();\n return;\n }\n\n if (added && !isSelectable(added) && isBranch(added)) {\n details.cancel();\n navigate(added);\n return;\n }\n\n // Cascading reads Base UI's array only as the REPORT of which row was\n // pressed: it differs by exactly one value either way, and the real\n // commit covers a whole subtree.\n if (cascade) {\n const nextValues = new Set(nextNodes.map((node) => node.value));\n const removed = selectedValues.find((entry) => !nextValues.has(entry));\n const toggled = added ?? (removed != null ? resolveNode(removed) : null);\n if (toggled) commit(toggled);\n return;\n }\n\n if (max != null && nextNodes.length > selectedValues.length && nextNodes.length > max) {\n details.cancel();\n // The third silent refusal site: cancelling reverts the press with no\n // state change, so the live region is the only witness.\n announceNotice(labels.maxReachedAnnouncement(max));\n return;\n }\n\n setSelection(nextNodes.map((node) => node.value));\n setQuery(\"\");\n },\n [\n multiple,\n selectedValues,\n max,\n cascade,\n closeOnSelect,\n labels,\n announceNotice,\n isSelectable,\n isDisabled,\n isBranch,\n navigate,\n commit,\n resolveNode,\n setSelection,\n setQuery,\n ],\n );\n\n const handleOpenChange = React.useCallback(\n (nextOpen: boolean, details: ComboboxPrimitive.Root.ChangeEventDetails) => {\n if (details.isCanceled) return;\n\n // Escape closes ONE popup at a time. `Combobox` builds no `FloatingTree`,\n // so one Escape reaches the flyout and the cascader; the flyout clears\n // its registration in an effect, so the set holds for exactly this event.\n if (!nextOpen && details.reason === \"escape-key\" && hasOpenFlyout()) {\n details.cancel();\n return;\n }\n\n // Captured for the wrapped `onOpenChange`, which runs synchronously\n // inside `setOpen`, so a ref written just before the call is exact.\n openReasonRef.current = details.reason ?? \"none\";\n setOpen(nextOpen);\n\n if (!nextOpen) {\n setQuery(\"\");\n return;\n }\n\n // Opening onto the level holding the selection is the difference\n // between \"edit this\" and \"start over\".\n if (revealSelected) {\n setQuery(\"\");\n const first = toArray(value)[0];\n setPathWithReason(\n first\n ? getCascaderPath(index, first)\n .slice(0, -1)\n .map((node) => node.value)\n : [],\n \"reveal\",\n );\n }\n },\n [setOpen, setQuery, revealSelected, value, index, setPathWithReason, hasOpenFlyout],\n );\n\n /* -------------------------------- context ------------------------------- */\n\n // NOT memoised further: render props must be the current closure, and only\n // rows consume this. See `CascaderRenderContextValue`.\n const renderContext = React.useMemo(\n () => ({ renderItem, renderLabel }),\n [renderItem, renderLabel],\n );\n\n /** The stable half: nothing in these deps moves on a keystroke, a level\n * change or a highlight, which is what makes `React.memo` on `CascaderItem`\n * hold while the user types. Destructured off `loader` so the memo depends\n * on its `[]`-dep callbacks, not the object it republishes per load. */\n const { active: hasLoader, loadMore, retryLevel, prefetchNode } = loader;\n\n const actionsValue = React.useMemo<CascaderActionsContextValue<T>>(\n () => ({\n index,\n mode,\n multiple,\n cascade,\n branchesSelectable,\n indicator,\n expandTrigger,\n actions: resolvedActions,\n searchScope,\n maxHeight,\n inline: !!inline,\n invalid: !!invalid,\n baseId,\n labels,\n virtualized,\n registerVirtualRenderer,\n virtualize,\n virtualizeThreshold,\n estimateRowSize,\n overscan,\n hasLoader,\n loadMore,\n retryLevel,\n invalidateLevel,\n getIndex,\n getState,\n getHighlighted,\n setPath,\n pushLevel,\n popLevel,\n goToDepth,\n toggleExpanded,\n setFlyoutOpen,\n hasOpenFlyout,\n setQuery,\n setSelection,\n commit,\n navigate,\n navigateAt,\n resolveNode,\n isBranch,\n isSelectable,\n isDisabled,\n isSelected,\n isIndeterminate,\n selectedDescendantCount,\n }),\n [\n index,\n mode,\n multiple,\n cascade,\n branchesSelectable,\n indicator,\n expandTrigger,\n resolvedActions,\n searchScope,\n maxHeight,\n inline,\n invalid,\n baseId,\n labels,\n virtualized,\n registerVirtualRenderer,\n virtualize,\n virtualizeThreshold,\n estimateRowSize,\n overscan,\n hasLoader,\n loadMore,\n retryLevel,\n invalidateLevel,\n getIndex,\n getState,\n getHighlighted,\n setPath,\n pushLevel,\n popLevel,\n goToDepth,\n toggleExpanded,\n setFlyoutOpen,\n hasOpenFlyout,\n setQuery,\n setSelection,\n commit,\n navigate,\n navigateAt,\n resolveNode,\n isBranch,\n isSelectable,\n isDisabled,\n isSelected,\n isIndeterminate,\n selectedDescendantCount,\n ],\n );\n\n // A fresh array identity each time windowing turns on, and once more after:\n // that identity is the ONLY thing that re-runs Base UI's `listRef` sizing\n // effect. See `virtualSyncs`.\n const comboboxItems = React.useMemo(\n () => (virtualized ? renderedItems.slice() : renderedItems),\n [renderedItems, virtualized],\n );\n\n const comboboxValue = React.useMemo(() => {\n if (multiple) return selectedValues.map(resolveNode);\n return selectedValues.length ? resolveNode(selectedValues[0]) : null;\n }, [multiple, selectedValues, resolveNode]);\n\n return (\n // Providers store values with the item generic erased; the hooks re-apply\n // the caller's own `T` on the way back out.\n <CascaderActionsContext.Provider value={actionsValue as unknown as CascaderActionsContextValue}>\n <CascaderStateContext.Provider value={stateValue as unknown as CascaderStateContextValue}>\n <CascaderHighlightContext.Provider value={highlightStore}>\n <CascaderRenderContext.Provider\n value={renderContext as unknown as CascaderRenderContextValue}\n >\n <ComboboxPrimitive.Root\n items={renderedItems}\n /* The empty frame that resets the highlight. See the comment above. */\n filteredItems={swapping ? EMPTY : comboboxItems}\n /* Filtering is ours: the level, deep and global scopes cannot\n be expressed through Base UI's single matcher. */\n filter={null}\n value={comboboxValue}\n onValueChange={handleComboboxValueChange}\n open={open}\n onOpenChange={handleOpenChange}\n inputValue={query}\n onInputValueChange={(next: string) => setQuery(next)}\n multiple={multiple}\n disabled={disabled}\n /* Form wiring, straight to Base UI's hidden input. Conditional\n spreads: an explicit `undefined` on a controlled prop reads as\n \"deleted\" rather than \"not supplied\". */\n name={name}\n {...(form != null ? { form } : null)}\n {...(id != null ? { id } : null)}\n {...(required != null ? { required } : null)}\n {...(readOnly != null ? { readOnly } : null)}\n {...(inputRef ? { inputRef } : null)}\n inline={inline}\n /* Stops Base UI rendering its composite list, which is what makes\n an explicit row `index` legal. `items`/`filteredItems` stay full:\n they size `listRef`, or ArrowDown stops at the last RENDERED row. */\n virtualized={virtualized}\n itemToStringValue={(item: CascaderNode<T>) => item?.value ?? \"\"}\n itemToStringLabel={(item: CascaderNode<T>) => item?.label ?? \"\"}\n isItemEqualToValue={(a: CascaderNode<T>, b: CascaderNode<T>) => a?.value === b?.value}\n // Fires on every arrow key AND every pointer move, so it must\n // never call setState. The ref serves keyboard handlers, the\n // de-duping store anything that has to re-render.\n onItemHighlighted={(\n item: CascaderNode<T> | undefined,\n details: ComboboxPrimitive.Root.HighlightEventDetails,\n ) => {\n highlightedRef.current = item ?? null;\n highlightStore.set({\n index: details.index,\n value: item?.value ?? null,\n });\n // Schedules a TIMEOUT and returns: inside a layout effect, a\n // synchronous setState would cascade before paint.\n prefetchNode(item);\n }}\n >\n {children}\n </ComboboxPrimitive.Root>\n </CascaderRenderContext.Provider>\n </CascaderHighlightContext.Provider>\n </CascaderStateContext.Provider>\n </CascaderActionsContext.Provider>\n );\n}\n\n/* -------------------------------------------------------------------------- */\n/* Trigger */\n/* -------------------------------------------------------------------------- */\n\n/** `Trigger.Props` stops short of `ref`, so it is intersected in, as the\n * shadcn combobox wrapper also does: a form library needs a ref here, and\n * `onBlur`, the \"touched\" signal, lands here too. */\nexport interface CascaderTriggerProps\n extends ComboboxPrimitive.Trigger.Props,\n Pick<React.ComponentPropsWithRef<\"button\">, \"ref\"> {\n /** Hides the trailing chevron, for a trigger that supplies its own. */\n showIcon?: boolean;\n}\n\nfunction CascaderTrigger({\n className,\n children,\n showIcon = true,\n ref,\n ...props\n}: CascaderTriggerProps) {\n const { invalid } = useCascaderActions();\n\n // `ref` is the one prop `mergeProps` does not merge, so chain it by hand.\n const triggerRef = React.useRef<HTMLButtonElement | null>(null);\n const setTrigger = React.useCallback(\n (node: HTMLButtonElement | null) => {\n triggerRef.current = node;\n if (typeof ref === \"function\") ref(node);\n else if (ref) ref.current = node;\n },\n [ref],\n );\n\n /** 18 of 19 audited examples shipped an unnamed combobox: the trigger's\n * contents are the field's VALUE, so a screen reader never hears its NAME.\n * Checked in the DOM, since the name may arrive as a `<label for>`. */\n React.useEffect(() => {\n if (process.env.NODE_ENV === \"production\") return;\n const element = triggerRef.current;\n if (!element) return;\n const named =\n element.hasAttribute(\"aria-label\") ||\n element.hasAttribute(\"aria-labelledby\") ||\n element.closest(\"label\") !== null ||\n (element.id !== \"\" &&\n element.ownerDocument.querySelector(`label[for=\"${CSS.escape(element.id)}\"]`) !== null);\n if (named) return;\n warnCascaderOnce(\n \"trigger-unnamed\",\n \"`CascaderTrigger` has no accessible name. Its contents are the field's VALUE - they change with the selection - so a screen reader hears what is picked but never what the field is for. Pass `aria-label` or `aria-labelledby`, or reference the trigger's `id` from a `<label>`.\",\n );\n });\n\n return (\n <ComboboxPrimitive.Trigger\n ref={setTrigger}\n data-slot=\"cascader-trigger\"\n /* Conditional spread: an explicit `undefined` would DELETE whatever a\n `Field` wrapper had already put here. */\n {...(invalid ? { \"aria-invalid\": true, \"data-invalid\": \"\" } : null)}\n className={cn(TRIGGER_ICON_FALLBACK_CLASS, className)}\n {...props}\n >\n {children}\n {showIcon ? (\n <ChevronDownIcon className={`${TRIGGER_ICON_CLASS} pointer-events-none shrink-0`} />\n ) : null}\n </ComboboxPrimitive.Trigger>\n );\n}\n\n/* -------------------------------------------------------------------------- */\n/* Resolved theme */\n/* -------------------------------------------------------------------------- */\n\n/* The eight registry styles each state a combobox surface differently, so the\n * classes below spell every one out with `style-<name>:` variants. Nothing\n * depends on ReUI's theme CSS; `build-registry` flattens one in on install. */\n\n/** Icon size for a combobox surface: 14px in mira and sera, 16px elsewhere. */\nconst TRIGGER_ICON_CLASS = \"text-muted-foreground size-4\";\n\n/** The same ladder, applied only to trigger children that carry no size. */\nconst TRIGGER_ICON_FALLBACK_CLASS = \"[&_svg:not([class*='size-'])]:size-4\";\n\n/** The chips field: a form-control surface, so it carries the invalid states. */\nconst CHIPS_CLASS =\n \"flex flex-wrap items-center border bg-clip-padding dark:bg-input/30 border-input focus-within:border-ring focus-within:ring-ring/50 has-aria-invalid:ring-destructive/20 dark:has-aria-invalid:ring-destructive/40 has-aria-invalid:border-destructive dark:has-aria-invalid:border-destructive/50 bg-transparent px-2.5 text-sm focus-within:ring-3 has-aria-invalid:ring-3 min-h-8 gap-1 rounded-lg py-1 transition-colors has-data-[slot=combobox-chip]:px-1\";\n\nconst CHIP_CLASS =\n \"text-foreground flex w-fit items-center justify-center gap-1 font-medium whitespace-nowrap bg-muted rounded-sm px-1.5 text-xs has-data-[slot=combobox-chip-remove]:pr-0 h-[calc(--spacing(5.25))]\";\n\nconst CHIP_REMOVE_CLASS = \"opacity-50 hover:opacity-100 -ml-1\";\n\n/** The floating panel's surface. The shared popup's `InputGroup` sizing is\n * left out (mirrored in `cascader-nav.tsx`), as are its `max-h-72` and\n * `min-w-*`: `CascaderContent` sets both from the positioner's variables. */\nconst CONTENT_SURFACE_CLASS =\n \"bg-popover text-popover-foreground data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 overflow-hidden ring-1 duration-100 ring-foreground/10 shadow-md rounded-lg data-[side=inline-start]:slide-in-from-right-2 data-[side=inline-end]:slide-in-from-left-2\";\n\nconst EMPTY_CLASS =\n \"text-muted-foreground hidden w-full justify-center py-2 text-center group-data-empty/combobox-content:flex text-sm\";\n\n/* -------------------------------------------------------------------------- */\n/* Chips */\n/* -------------------------------------------------------------------------- */\n\n/** Ref for the chips container: they replace the trigger, so the popup has to\n * be anchored to them. Hand it to `CascaderContent`'s `anchor`. */\nexport function useCascaderAnchor() {\n return React.useRef<HTMLDivElement | null>(null);\n}\n\nexport interface CascaderChipsProps\n extends Omit<ComboboxPrimitive.Chips.Props, \"children\">,\n Pick<React.ComponentPropsWithRef<\"div\">, \"ref\"> {\n /** Shown in place of the chips when nothing is selected. */\n placeholder?: React.ReactNode;\n /**\n * How a `cascade` selection is condensed into chips. DISPLAY ONLY: the\n * stored value stays the full closure, which keeps a row's checked state an\n * O(1) lookup. `\"all\"` (default) is one chip per value, `\"parent\"` collapses\n * a fully selected branch, `\"child\"` chips only the deepest frontier.\n * Removing a condensed chip removes its whole closure and reconciles.\n */\n strategy?: CascaderCheckedStrategy;\n /** Replaces the chip list, receiving the resolved selection IN SELECTION\n * ORDER. Keep that order: Base UI removes a chip by sibling position. */\n children?: React.ReactNode | ((nodes: CascaderNode[]) => React.ReactNode);\n}\n\n/**\n * The multi-select trigger surface: one removable chip per selection, where\n * `CascaderValue` would collapse to \"3 selected\". A component rather than a\n * recipe because of three easy misses: the popup anchored to the chips, an\n * accessible name on every remove button, and labels that disambiguate when\n * two branches use the same one.\n *\n * ```tsx\n * const anchor = useCascaderAnchor()\n * <Cascader multiple items={items}>\n * <CascaderChips ref={anchor} placeholder=\"Select attributes\" />\n * <CascaderContent anchor={anchor}>...</CascaderContent>\n * </Cascader>\n * ```\n */\nfunction CascaderChips({\n className,\n children,\n placeholder,\n strategy = \"all\",\n ...props\n}: CascaderChipsProps) {\n const { labels, multiple, invalid, resolveNode, index, isSelectable, setSelection } =\n useCascaderActions();\n const { selectedValues } = useCascaderState();\n\n React.useEffect(() => {\n if (process.env.NODE_ENV === \"production\") return;\n if (multiple) return;\n warnCascaderOnce(\n \"chips-without-multiple\",\n \"`CascaderChips` renders one chip per selection and there is only ever one without `multiple`. Use `CascaderValue` for a single-select trigger.\",\n );\n }, [multiple]);\n\n // DERIVED display: the selection stays the full closure, the chips condense.\n const displayedValues =\n strategy === \"all\" ? selectedValues : getCascaderCheckedValues(index, selectedValues, strategy);\n\n // Not memoised: one entry per SELECTION, not per row, so the pass is short.\n const nodes = displayedValues.map(resolveNode);\n const ambiguous = findAmbiguousCascaderLabels(nodes);\n\n // Removal for a CONDENSED chip: Base UI's `ChipRemove` maps a press onto the\n // STORED array, which is wrong once the chips are fewer, so this removes the\n // chip's whole subtree closure instead.\n const removeClosure = (node: CascaderNode) => {\n setSelection(\n applyCascadeSelection(index, selectedValues, node.value, false, isSelectable),\n \"deselect\",\n );\n };\n\n const content = typeof children === \"function\" ? children(nodes) : children;\n\n return (\n <ComboboxPrimitive.Chips\n data-slot=\"cascader-chips\"\n /* An unnamed `role=\"toolbar\"` announces as just \"toolbar\". */\n aria-label={labels.chipsLabel}\n /* Conditional spread: the error treatment is keyed on\n `has-aria-invalid:`, so the attribute must be absent, not empty. */\n {...(invalid ? { \"aria-invalid\": true, \"data-invalid\": \"\" } : null)}\n className={cn(CHIPS_CLASS, className)}\n {...props}\n >\n {content ??\n (nodes.length === 0 ? (\n <span data-slot=\"cascader-chips-placeholder\" className=\"truncate text-muted-foreground\">\n {placeholder}\n </span>\n ) : (\n nodes.map((node) => (\n <CascaderChip\n key={node.value}\n node={node}\n showPath={ambiguous.has(node.value)}\n /* Only a condensed chip needs the remover; the default shape\n keeps Base UI's positional removal. */\n {...(strategy !== \"all\" ? { onRemove: () => removeClosure(node) } : null)}\n />\n ))\n ))}\n </ComboboxPrimitive.Chips>\n );\n}\n\nexport interface CascaderChipProps extends Omit<ComboboxPrimitive.Chip.Props, \"children\"> {\n node: CascaderNode;\n /** Prefix the label with its ancestor trail. */\n showPath?: boolean;\n /** Trail segments to show, the node itself included. */\n maxSegments?: number;\n /** Hides the remove button, for a read-only chip. */\n showRemove?: boolean;\n /** Replaces Base UI's positional removal for this chip (remove button and\n * Backspace/Delete). Supplied for a `strategy`-condensed chip, whose\n * position no longer maps onto the stored array. */\n onRemove?: () => void;\n /** Replaces the chip's label. The remove button is still rendered. */\n children?: React.ReactNode;\n}\n\n/** Base UI hands its chip handlers events carrying the veto hook. */\ntype CascaderChipKeyEvent = Parameters<NonNullable<ComboboxPrimitive.Chip.Props[\"onKeyDown\"]>>[0];\n\ntype CascaderChipRemoveClickEvent = Parameters<\n NonNullable<ComboboxPrimitive.ChipRemove.Props[\"onClick\"]>\n>[0];\n\n/** One chip. Removal goes through Base UI's `ChipRemove`, which reports the\n * shortened selection to the root, so it lands in the same `setSelection` as\n * every other deselection and `cascade` applies to it. */\nfunction CascaderChip({\n className,\n node,\n showPath = false,\n maxSegments = 2,\n showRemove = true,\n onRemove,\n children,\n ...props\n}: CascaderChipProps) {\n const { labels, index } = useCascaderActions();\n\n const chain = showPath ? getCascaderPath(index, node.value) : [];\n const segments = collapseCascaderPath(chain, {\n maxSegments,\n collapse: \"start\",\n });\n\n const label = segments.length\n ? segments\n .map((segment) => (segment.type === \"node\" ? segment.node.label : \"…\"))\n .join(` ${labels.pathSeparator} `)\n : node.label;\n\n return (\n <ComboboxPrimitive.Chip\n data-slot=\"cascader-chip\"\n /* Keyboard half of `onRemove`: Base UI's chip removes ITSELF by position\n on Backspace/Delete, the arithmetic a condensed chip must not use. The\n veto runs first, so the closure removal replaces it. */\n {...(onRemove\n ? {\n onKeyDown: (event: CascaderChipKeyEvent) => {\n if (event.key !== \"Backspace\" && event.key !== \"Delete\") return;\n event.preventBaseUIHandler();\n onRemove();\n },\n }\n : null)}\n className={cn(\n CHIP_CLASS,\n \"has-disabled:pointer-events-none has-disabled:cursor-not-allowed has-disabled:opacity-50\",\n className,\n )}\n {...props}\n >\n {children ?? <span className=\"truncate\">{label}</span>}\n {showRemove ? (\n <ComboboxPrimitive.ChipRemove\n data-slot=\"cascader-chip-remove\"\n /* Named after what the chip DISPLAYS, not the bare node label, or\n two disambiguated chips both announce \"Remove Created at\". */\n aria-label={labels.removeChip(label)}\n /* The pointer half of `onRemove`, same veto, same reason. */\n {...(onRemove\n ? {\n onClick: (event: CascaderChipRemoveClickEvent) => {\n event.preventBaseUIHandler();\n onRemove();\n },\n }\n : null)}\n className={CHIP_REMOVE_CLASS}\n >\n <XIcon className=\"pointer-events-none\" />\n </ComboboxPrimitive.ChipRemove>\n ) : null}\n </ComboboxPrimitive.Chip>\n );\n}\n\n/* -------------------------------------------------------------------------- */\n/* Content */\n/* -------------------------------------------------------------------------- */\n\nexport interface CascaderContentProps\n extends ComboboxPrimitive.Popup.Props,\n /** Positioner surface forwarded as-is, so an unusual anchor does not force\n * a rebuild of the content stack. No `trackAnchor`: Base UI 1.5.0 has\n * none. */\n Pick<\n ComboboxPrimitive.Positioner.Props,\n | \"side\"\n | \"align\"\n | \"sideOffset\"\n | \"alignOffset\"\n | \"anchor\"\n | \"collisionBoundary\"\n | \"collisionPadding\"\n | \"sticky\"\n | \"positionMethod\"\n >,\n /** Where the portal mounts, for a shadow root or a scoped stacking context. */\n Pick<ComboboxPrimitive.Portal.Props, \"container\"> {}\n\n/** Portal + Positioner + floating panel. Unlike shadcn's `ComboboxContent` it\n * does NOT clamp the popup to the anchor width (a cascader panel is routinely\n * wider), but it keeps `group/combobox-content`, which `CascaderEmpty` needs. */\nfunction CascaderContent({\n className,\n side = \"bottom\",\n sideOffset = 6,\n align = \"start\",\n alignOffset = 0,\n anchor,\n collisionBoundary,\n collisionPadding,\n sticky,\n positionMethod,\n container,\n ref,\n ...props\n}: CascaderContentProps) {\n const { labels } = useCascaderActions();\n const popupRef = React.useRef<HTMLDivElement | null>(null);\n\n // `initialFocus` needs the popup element, and `ref` is the one prop\n // `mergeProps` does NOT merge, so it is chained by hand rather than spread.\n const setPopup = React.useCallback(\n (node: HTMLDivElement | null) => {\n popupRef.current = node;\n if (typeof ref === \"function\") ref(node);\n else if (ref) ref.current = node;\n },\n [ref],\n );\n\n /**\n * Focus goes to the search field, where the level keys and\n * `aria-activedescendant` live. Base UI's own default agrees but is COMPUTED\n * FROM THE FIRST RENDER, when the field has not mounted, and collapses to\n * \"do not move focus\": measured, a KEYBOARD open left focus on the trigger\n * and cost two Tabs to reach the footer where a pointer open cost one.\n *\n * `initialFocus` rather than an effect, because anything scheduled alongside\n * Base UI's focus manager is a race; the field is resolved INSIDE the\n * callback, which runs after the layout effects. Touch is handed back to\n * Base UI on purpose - focusing the popup keeps the Android keyboard shut.\n */\n const initialFocus = React.useCallback((openType: string) => {\n const popup = popupRef.current;\n if (!popup) return true;\n if (openType === \"touch\") return popup;\n return popup.querySelector<HTMLElement>('[data-slot=\"cascader-input\"]') ?? true;\n }, []);\n\n return (\n // Conditional spreads throughout: `mergeProps` iterates own keys, so an\n // explicit `undefined` reads as \"deleted\" rather than \"not supplied\".\n <ComboboxPrimitive.Portal {...(container !== undefined ? { container } : null)}>\n <ComboboxPrimitive.Positioner\n side={side}\n sideOffset={sideOffset}\n align={align}\n alignOffset={alignOffset}\n anchor={anchor}\n {...(collisionBoundary !== undefined ? { collisionBoundary } : null)}\n {...(collisionPadding !== undefined ? { collisionPadding } : null)}\n {...(sticky !== undefined ? { sticky } : null)}\n {...(positionMethod !== undefined ? { positionMethod } : null)}\n className=\"isolate z-50\"\n >\n <ComboboxPrimitive.Popup\n ref={setPopup}\n data-slot=\"cascader-content\"\n /* Marks a menu surface for the docs design-system picker. An\n attribute, not a class, so the panel's look stays self-contained. */\n data-menu-target=\"\"\n /* The input inside makes this a `role=\"dialog\"`, unnamed by default. */\n aria-label={labels.panelLabel}\n initialFocus={initialFocus}\n className={cn(\n CONTENT_SURFACE_CLASS,\n \"group/combobox-content relative flex max-h-(--available-height) min-w-(--anchor-width) max-w-(--available-width) origin-(--transform-origin) flex-col\",\n className,\n )}\n {...props}\n />\n </ComboboxPrimitive.Positioner>\n </ComboboxPrimitive.Portal>\n );\n}\n\n/* -------------------------------------------------------------------------- */\n/* Panel */\n/* -------------------------------------------------------------------------- */\n\nexport type CascaderPanelProps = useRender.ComponentProps<\"div\">;\n\n/**\n * The nav + list(s) + footer container, with no positioning of its own: inside\n * `CascaderContent` for the popup case, alone for the embedded one.\n *\n * `min-h-0` and `max-h-full` are load-bearing. A flex child without `min-h-0`\n * refuses to shrink below its content, which is the usual reason a scroll area\n * never scrolls - worst embedded, where no positioner publishes\n * `--available-height`. It also owns the panel's TAB ORDER: the scroll area\n * makes itself a tab stop whenever the level overflows, stranding the footer,\n * and the panel is the only ancestor of both ends of that move in BOTH shapes.\n */\nfunction CascaderPanel({ className, ...props }: CascaderPanelProps) {\n const { mode } = useCascaderActions();\n\n const handleKeyDown = React.useCallback((event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.key !== \"Tab\" || event.defaultPrevented) return;\n // A browser-level move (Ctrl+Tab switches tabs) is never ours.\n if (event.altKey || event.ctrlKey || event.metaKey) return;\n\n const panel = event.currentTarget;\n const target = event.target as HTMLElement | null;\n if (!target || !panel.contains(target)) return;\n\n const next = getCascaderTabTarget(panel, target, event.shiftKey);\n // Off either end: left to the browser, since focus is never trapped.\n if (!next) return;\n\n event.preventDefault();\n next.focus();\n }, []);\n\n const defaultProps = {\n \"data-slot\": \"cascader-panel\",\n \"data-mode\": mode,\n // In `defaultProps`, not around `props.onKeyDown`: `mergeProps` chains\n // right to left, so a consumer's handler runs FIRST and can drop this one.\n onKeyDown: handleKeyDown,\n className: cn(\"flex max-h-full min-h-0 w-full flex-col\", className),\n };\n\n return useRender({\n defaultTagName: \"div\",\n render: props.render,\n props: mergeProps<\"div\">(defaultProps, props),\n });\n}\n\n/* -------------------------------------------------------------------------- */\n/* List */\n/* -------------------------------------------------------------------------- */\n\nexport interface CascaderListProps extends Omit<ComboboxPrimitive.List.Props, \"style\"> {\n /** Applied to the OUTER shell, which owns the height, so an inline\n * `--cascader-max-height` lands where the bound can read it. Narrowed from\n * Base UI's `style`: the shell is a plain `<div>` with no list state. */\n style?: React.CSSProperties;\n /** Caps this level's height; the panel still shrinks to fit. Default 24rem. */\n maxHeight?: number | string;\n}\n\n/**\n * Scroll container for one level: pattern 3 of the house scroll reference,\n * viewport-bounded popup scroll. The height is `min()` of `--available-height`\n * (the positioner's space between anchor and viewport edge) and `maxHeight`,\n * so neither can be ignored; a fixed pixel cap alone still reserved 288px for\n * a panel opened 200px above the fold and spilled off screen, and wasted room\n * in a tall window. The four classes are shared with `CascaderColumns` and\n * live in `cascader-lib.tsx`.\n */\nfunction CascaderList({ className, style, maxHeight: maxHeightProp, ...props }: CascaderListProps) {\n const { maxHeight, mode, labels, baseId, virtualized, searchScope } = useCascaderActions();\n const { currentParent, deepResults } = useCascaderState();\n const resolved = maxHeightProp ?? maxHeight;\n // Global hits come from the whole tree, so the parent would understate them.\n const listName =\n searchScope === \"global\" && deepResults\n ? labels.rootLevel\n : (currentParent?.label ?? labels.rootLevel);\n\n return (\n <div\n data-slot=\"cascader-list-shell\"\n style={\n resolved != null\n ? ({\n ...style,\n \"--cascader-max-height\": typeof resolved === \"number\" ? `${resolved}px` : resolved,\n } as React.CSSProperties)\n : style\n }\n className={cn(\"relative flex max-h-full min-h-0\", CASCADER_LIST_PAD_CLASS)}\n >\n <div\n data-slot=\"cascader-list-bounds\"\n className={cn(\n \"flex w-full min-w-0 flex-col overscroll-contain\",\n CASCADER_LIST_HEIGHT_CLASS,\n )}\n >\n <ScrollArea className={CASCADER_SCROLL_CLASS}>\n <ComboboxPrimitive.List\n data-slot=\"cascader-list\"\n /* Base UI names the list nothing, so every mode shipped an unnamed\n listbox. The level's parent is the name; the root borrows one. */\n aria-label={listName}\n /* Replaces Base UI's floating id. `aria-controls` reads the live\n id, so the columns trail gets a predictable target. */\n id={`${baseId}-column-0`}\n /* NEVER a ternary ending in `undefined`: `mergeProps` iterates own\n keys, so that DELETES Base UI's `role=\"listbox\"`. */\n {...(mode === \"tree\" ? { role: \"tree\" as const } : null)}\n {...(virtualized ? { \"data-virtualized\": true } : null)}\n className={cn(\n CASCADER_ROWS_CLASS,\n /* A windowed row is absolutely positioned, so the ROWS' box is\n the containing block, not the scrollport: it carries the\n padding the geometry is measured against. */\n virtualized && \"relative\",\n className,\n )}\n {...props}\n />\n </ScrollArea>\n </div>\n </div>\n );\n}\n\n/* -------------------------------------------------------------------------- */\n/* Empty / Loading */\n/* -------------------------------------------------------------------------- */\n\nexport interface CascaderEmptyProps extends ComboboxPrimitive.Empty.Props {\n /** @deprecated Ignored: the loading surface no longer draws skeletons. They\n * promised a shape the level might not have and cost a second layout; the\n * progress lives on the branch row instead. Kept so call sites compile. */\n skeletonRows?: number;\n}\n\n/** The empty, loading and error surface, in ONE element that never unmounts.\n * `Combobox.Empty` renders whenever `filteredItems.length === 0`, as true of a\n * fetching level as of an empty one, so swapping siblings would announce \"No\n * results found.\" over every async level. Swap the CHILDREN. */\nfunction CascaderEmpty({\n className,\n children,\n // Accepted and ignored; destructured so it is never spread onto the DOM.\n skeletonRows,\n ...props\n}: CascaderEmptyProps) {\n const { labels, retryLevel } = useCascaderActions();\n const { query, path, searchState } = useCascaderState();\n // The level whose emptiness is on screen; tree always shows the root.\n const levelKey = path.length ? path[path.length - 1] : CASCADER_ROOT_KEY;\n const loadState = useCascaderLoadState(levelKey);\n const state = query.trim() ? (searchState ?? loadState) : loadState;\n\n let body: React.ReactNode = children ?? labels.empty;\n\n if (state?.error) {\n body = (\n <span data-slot=\"cascader-error\" className=\"flex flex-col items-center gap-1.5\">\n <span>{labels.error}</span>\n <button\n type=\"button\"\n data-slot=\"cascader-retry\"\n /* A real button because this lives OUTSIDE the listbox; a focusable\n element inside a `role=\"option\"` is `nested-interactive`. */\n onClick={() => retryLevel(levelKey)}\n className=\"rounded-md px-2 py-0.5 font-medium text-foreground outline-hidden transition-colors hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring/50\"\n >\n {labels.retry}\n </button>\n </span>\n );\n } else if (state?.loading) {\n body = (\n <span data-slot=\"cascader-loading\" className=\"flex w-full items-center justify-center\">\n {labels.loading}\n </span>\n );\n }\n\n return (\n <ComboboxPrimitive.Empty\n data-slot=\"cascader-empty\"\n data-state={state?.error ? \"error\" : state?.loading ? \"loading\" : \"empty\"}\n className={cn(EMPTY_CLASS, className)}\n // biome-ignore lint/a11y/useValidAriaValues: <>\n aria-live={undefined}\n // biome-ignore lint/a11y/useValidAriaValues: <>\n aria-atomic={undefined}\n {...props}\n >\n {body}\n </ComboboxPrimitive.Empty>\n );\n}\n\nexport type CascaderStatusProps = ComboboxPrimitive.Status.Props;\n\n/**\n * Polite live region for the current level and result count, which drill-down\n * otherwise hides in a visual breadcrumb. Built on `Combobox.Status` for its\n * initial-mutation marker: Safari and VoiceOver need a text change ~200ms\n * after mount before reading a polite region at all.\n */\nfunction CascaderStatus({ className, children, ...props }: CascaderStatusProps) {\n const { announcement } = useCascaderState();\n\n return (\n <ComboboxPrimitive.Status\n data-slot=\"cascader-status\"\n className={cn(\"sr-only\", className)}\n {...props}\n >\n {children ?? announcement}\n </ComboboxPrimitive.Status>\n );\n}\n\nexport type {\n CascaderActionsContextValue,\n CascaderColumn,\n CascaderHighlight,\n CascaderHighlightStore,\n CascaderItemState,\n CascaderRenderContextValue,\n CascaderStateContextValue,\n};\n/** Re-exported from `cascader-context.tsx`: existing import paths keep\n * working, and the row component avoids an import cycle through this file. */\nexport {\n Cascader,\n CascaderChip,\n CascaderChips,\n CascaderContent,\n CascaderEmpty,\n CascaderList,\n CascaderPanel,\n CascaderStatus,\n CascaderTrigger,\n createCascaderHighlightStore,\n useCascaderActions,\n useCascaderHighlight,\n useCascaderRender,\n useCascaderState,\n};\n"],"mappings":";;;;;;;;;;;;;;;AAgFA,MAAM,QAA+B,CAAC;;;AAItC,MAAM,gBAAsC,CAAC;;AA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SAAS,KAAK,KAAK,SAAS,KAAK;CACvD,MAAM,YAAY,qBAAqB,QAAQ;CAC/C,MAAM,QAAQ,MAAM,KAAK,IAAK,eAAe,YAAa;CAE1D,IAAI,OAAwB,YAAY,OAAO;CAE/C,IAAI,OAAO,OACT,OACE,qBAAC,QAAD;EAAM,aAAU;EAAiB,WAAU;EAA3C,UAAA,CACE,oBAAC,QAAD,EAAA,UAAO,OAAO,MAAY,CAAA,GAC1B,oBAAC,UAAD;GACE,MAAK;GACL,aAAU;GAGV,eAAe,WAAW,QAAQ;GAClC,WAAU;GAET,UAAA,OAAO;EACF,CAAA,CACJ;;MAEH,IAAI,OAAO,SAChB,OACE,oBAAC,QAAD;EAAM,aAAU;EAAmB,WAAU;EAC1C,UAAA,OAAO;CACJ,CAAA;CAIV,OACE,oBAACA,SAAkB,OAAnB;EACE,aAAU;EACV,cAAY,OAAO,QAAQ,UAAU,OAAO,UAAU,YAAY;EAClE,WAAW,GAAG,aAAa,SAAS;EAEpC,aAAW,KAAA;EAEX,eAAa,KAAA;EACb,GAAI;EAEH,UAAA;CACsB,CAAA;AAE7B;;;;;;;AAUA,SAAS,eAAe,EAAE,WAAW,UAAU,GAAG,SAA8B;CAC9E,MAAM,EAAE,iBAAiB,iBAAiB;CAE1C,OACE,oBAACA,SAAkB,QAAnB;EACE,aAAU;EACV,WAAW,GAAG,WAAW,SAAS;EAClC,GAAI;EAEH,UAAA,YAAY;CACW,CAAA;AAE9B"}
|
|
1
|
+
{"version":3,"file":"cascader.js","names":["React","ComboboxPrimitive"],"sources":["../../../../src/components/reui/cascader/cascader.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { Combobox as ComboboxPrimitive } from \"@base-ui/react\";\nimport { mergeProps } from \"@base-ui/react/merge-props\";\nimport { useRender } from \"@base-ui/react/use-render\";\nimport { ChevronDownIcon, XIcon } from \"lucide-react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { ScrollArea } from \"../../ui/scroll-area\";\nimport type { CascaderGetChildren, CascaderOnSearch, CascaderResolveValue } from \"./cascader-async\";\nimport { useCascaderLoader, useCascaderLoadState } from \"./cascader-async\";\nimport type {\n CascaderActionsContextValue,\n CascaderColumn,\n CascaderHighlight,\n CascaderHighlightStore,\n CascaderItemState,\n CascaderRenderContextValue,\n CascaderStateContextValue,\n} from \"./cascader-context\";\nimport {\n CascaderActionsContext,\n CascaderHighlightContext,\n CascaderRenderContext,\n CascaderStateContext,\n createCascaderHighlightStore,\n useCascaderActions,\n useCascaderHighlight,\n useCascaderRender,\n useCascaderState,\n} from \"./cascader-context\";\nimport { resolveCascaderLabels } from \"./cascader-i18n\";\nimport type { CascaderCheckedStrategy } from \"./cascader-lib\";\nimport {\n applyCascadeSelection,\n buildCascaderIndex,\n CASCADER_LIST_HEIGHT_CLASS,\n CASCADER_LIST_PAD_CLASS,\n CASCADER_ROOT_KEY,\n CASCADER_ROWS_CLASS,\n CASCADER_SCROLL_CLASS,\n collapseCascaderPath,\n createCascaderMoreNode,\n filterCascaderLevel,\n findAmbiguousCascaderLabels,\n findCascaderDataIssues,\n flattenCascaderTree,\n focusCascaderHome,\n getCascaderCheckedValues,\n getCascaderChildren,\n getCascaderCount,\n getCascaderIndeterminateFrom,\n getCascaderListedValues,\n getCascaderPath,\n getCascaderSelectedDescendants,\n getCascaderTabTarget,\n isCascaderBranch,\n isCascaderDisabled,\n isCascaderMoreNode,\n isCascaderSelectable,\n matchesCascaderQuery,\n mergeCascaderIndex,\n normalizeCascaderQuery,\n searchCascaderDeep,\n warnCascaderOnce,\n withCascaderMoreRow,\n} from \"./cascader-lib\";\nimport type {\n CascaderActionItem,\n CascaderChangeDetails,\n CascaderChangeReason,\n CascaderFlatNode,\n CascaderIndex,\n CascaderLabels,\n CascaderLoadState,\n CascaderMode,\n CascaderNode,\n CascaderSearchScope,\n CascaderSelectable,\n} from \"./cascader-types\";\n\n/** Stable `filteredItems` for a level swap; a fixed identity cannot loop. */\nconst EMPTY: CascaderNode<never>[] = [];\n\n/** Stable empty array for the `actions` prop, so a cascader with no footer\n * does not republish the actions context on every render. */\nconst EMPTY_ACTIONS: CascaderActionItem[] = [];\n\n/** The `onSearch` scope of a global search: no path, so the whole tree. */\nconst GLOBAL_SEARCH_PATH: string[] = [];\n\n// Word joiner. A polite region reads only MUTATIONS, so alternate it.\nconst ANNOUNCE_MARKER = \"\\u2060\";\n\n// Delay before a query result-count reaches the live region: polite\n// announcements queue, and re-announcing per keystroke plays back stale\n// counts. Only the count defers; every event-shaped one stays immediate.\nconst ANNOUNCE_DEBOUNCE = 150;\n\n/* -------------------------------------------------------------------------- */\n/* State */\n/* -------------------------------------------------------------------------- */\n\n// Minimal controlled/uncontrolled resolver, hand-rolled because the repo has\n// no shared `useControllableState`; the root needs it five times.\nfunction useControllable<V>(\n controlled: V | undefined,\n defaultValue: V,\n onChange?: (value: V) => void,\n /** Prop name, used only by the development-time switching warning. */\n devName?: string,\n): [V, (next: V | ((prev: V) => V)) => void] {\n const [uncontrolled, setUncontrolled] = React.useState(defaultValue);\n const isControlled = controlled !== undefined;\n const value = isControlled ? controlled : uncontrolled;\n\n // Switching controlled/uncontrolled mid-life strands half the state.\n const wasControlled = React.useRef(isControlled);\n React.useEffect(() => {\n if (process.env.NODE_ENV === \"production\") return;\n if (wasControlled.current === isControlled || !devName) return;\n const from = wasControlled.current ? \"controlled\" : \"uncontrolled\";\n const to = isControlled ? \"controlled\" : \"uncontrolled\";\n wasControlled.current = isControlled;\n warnCascaderOnce(\n `controlled-switch:${devName}`,\n `\\`${devName}\\` switched from ${from} to ${to}. Decide once: pass \\`${devName}\\` for the whole life of the component, or pass only the default and let the cascader own it.`,\n );\n }, [isControlled, devName]);\n\n // Written in an EFFECT: a discarded render would still have mutated a ref.\n const latest = React.useRef({ value, isControlled, onChange });\n React.useEffect(() => {\n latest.current = { value, isControlled, onChange };\n });\n\n // The last PROP seen: it differs from the optimistic advance exactly when a\n // controlled parent declines a change and re-renders nothing.\n const lastProp = React.useRef(controlled);\n React.useEffect(() => {\n lastProp.current = controlled;\n });\n\n const set = React.useCallback((next: V | ((prev: V) => V)) => {\n const current = latest.current.value;\n const resolved = typeof next === \"function\" ? (next as (prev: V) => V)(current) : next;\n if (Object.is(resolved, current)) {\n // Dedup against the last PROP, not the optimistic advance: a parent that\n // declines re-renders nothing, so deduping on the advance left the popup\n // un-dismissable from the second Escape on.\n if (!latest.current.isControlled || Object.is(resolved, lastProp.current)) {\n return;\n }\n }\n\n // Advance now so two updates in ONE batch compose, rather than the second\n // reading a stale value and its `Object.is` dedup dropping it.\n latest.current = { ...latest.current, value: resolved };\n\n if (!latest.current.isControlled) setUncontrolled(resolved);\n latest.current.onChange?.(resolved);\n }, []);\n\n return [value, set];\n}\n\n/* -------------------------------------------------------------------------- */\n/* Shallow stability */\n/* -------------------------------------------------------------------------- */\n\nfunction shallowEqualRecords(a: object, b: object): boolean {\n const left = a as Record<string, unknown>;\n const right = b as Record<string, unknown>;\n const keys = Object.keys(left);\n if (keys.length !== Object.keys(right).length) return false;\n for (const key of keys) {\n if (!Object.is(left[key], right[key])) return false;\n }\n return true;\n}\n\nfunction shallowEqualItemLists(a: readonly object[], b: readonly object[]): boolean {\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i += 1) {\n if (a[i] !== b[i] && !shallowEqualRecords(a[i], b[i])) return false;\n }\n return true;\n}\n\n// Reuses the previous value while the next merely says the same thing: an\n// inline `labels`/`actions` otherwise republishes the actions context, and\n// with it every row. Adjust-state-during-render, not a ref.\nfunction useShallowStable<V>(value: V, equal: (a: V & object, b: V & object) => boolean): V {\n const [stable, setStable] = React.useState(value);\n if (Object.is(value, stable)) return stable;\n const comparable =\n typeof value === \"object\" && value !== null && typeof stable === \"object\" && stable !== null;\n if (comparable && equal(value as V & object, stable as V & object)) {\n return stable;\n }\n setStable(value);\n return value;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Context */\n/* -------------------------------------------------------------------------- */\n\n/** The pre-split shape, merged, so `useCascader()` returns what it always did. */\nexport interface CascaderContextValue<T = unknown>\n extends CascaderActionsContextValue<T>,\n CascaderStateContextValue<T> {}\n\n/**\n * The cascader's internals, typed for the caller's own item payload.\n * @deprecated Reads BOTH halves, so a caller re-renders on every keystroke.\n * Prefer `useCascaderActions()` or `useCascaderState()`. Kept for compat.\n */\nexport function useCascader<T = unknown>(): CascaderContextValue<T> {\n const actions = useCascaderActions<T>();\n const state = useCascaderState<T>();\n\n return React.useMemo(() => ({ ...actions, ...state }), [actions, state]);\n}\n\n/* -------------------------------------------------------------------------- */\n/* Headless selection */\n/* -------------------------------------------------------------------------- */\n\nexport interface CascaderSelection<T = unknown> {\n /** The selected nodes, resolved. Empty when nothing is selected. */\n selected: CascaderNode<T>[];\n /** Ancestor chain per selected node, root first, node last. */\n paths: CascaderNode<T>[][];\n /** The single selection, or the first one in `multiple` mode. */\n first: CascaderNode<T> | null;\n /** Ancestor chain of `first`. */\n firstPath: CascaderNode<T>[];\n count: number;\n isEmpty: boolean;\n multiple: boolean;\n remove: (value: string) => void;\n clear: () => void;\n}\n\n/** Headless access to the selection, for a trigger that is not\n * `CascaderValue`. Pass the payload explicitly to get `node.data` typed. */\nexport function useCascaderSelection<T = unknown>(): CascaderSelection<T> {\n const { multiple, setSelection } = useCascaderActions<T>();\n const { index, selectedValues } = useCascaderState<T>();\n\n return React.useMemo(() => {\n const selected = selectedValues\n .map((value) => index.byValue.get(value))\n .filter(Boolean) as CascaderNode<T>[];\n const paths = selectedValues.map((value) => getCascaderPath(index, value));\n\n return {\n selected,\n paths,\n first: selected[0] ?? null,\n firstPath: paths[0] ?? [],\n count: selectedValues.length,\n isEmpty: selectedValues.length === 0,\n multiple,\n remove: (value: string) => setSelection(selectedValues.filter((entry) => entry !== value)),\n // Explicit reason: emptying on purpose is not \"deselect the last node\".\n clear: () => setSelection([], \"clear\"),\n };\n }, [index, selectedValues, multiple, setSelection]);\n}\n\n/* -------------------------------------------------------------------------- */\n/* Root */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Why the navigation path changed.\n * - `\"drill\"`: a branch was entered (row press, level arrow, search hit).\n * - `\"back\"`: one level up (back control, Backspace on an empty query).\n * - `\"breadcrumb\"`: a jump to an exact depth in the trail.\n * - `\"reveal\"`: the reopen navigated to the level holding the selection.\n * - `\"external\"`: `setPath` called from outside the primitive's own flows.\n */\nexport type CascaderPathChangeReason = \"drill\" | \"back\" | \"breadcrumb\" | \"reveal\" | \"external\";\n\n/** Everything independent of the selection mode; the rest is on the two arms. */\nexport interface CascaderBaseProps<T = unknown> {\n /** Nested tree, or a flat list when `getParent` is supplied. */\n items: CascaderNode<T>[];\n /** Opt in to flat adjacency input by returning each node's parent value. */\n getParent?: (node: CascaderNode<T>) => string | null | undefined;\n\n /**\n * Fetches one level on demand; `node` is `null` for the root, and only\n * `{ value, label: value }` for a level on screen whose node has not loaded\n * (a deep link, or a page-loaded level after a `loadKey` change). Return an\n * array, or a `CascaderLoadResult` when the level pages. Pages cache apart\n * from `items`; mark unfetched branches `hasChildren` or they read as leaves.\n */\n getChildren?: CascaderGetChildren<T>;\n /**\n * Server-side search, debounced by `searchDebounce`; replaces the local scan\n * while the query is set. Results are detached: resolvable by value, in no\n * level. Ignored in `mode=\"tree\"`, where a hit belongs to no visible branch.\n */\n onSearch?: CascaderOnSearch<T>;\n /** Milliseconds of quiet before `onSearch` fires. */\n searchDebounce?: number;\n /**\n * Resolves a value the loader has never seen into its ancestor chain, root\n * first, so the trigger can path a server-supplied selection. Runs with the\n * popup closed too. Does NOT mark those levels loaded: opening one still\n * fetches, and lists the node after its rows while it has pages left.\n */\n resolveValue?: CascaderResolveValue<T>;\n /** Cache key. Changing it drops every page and aborts anything in flight. */\n loadKey?: unknown;\n /** Prefetch a highlighted branch's children after a pause. Off by default. */\n prefetch?: boolean;\n /**\n * Called when a load fails. `context.parent` is the level (`null` for root);\n * `context.reason` is `\"level\"`, `\"more\"`, `\"retry\"`, `\"prefetch\"`,\n * `\"search\"` or `\"resolve\"`. Never for an aborted or superseded request.\n */\n onLoadError?: (error: unknown, context: { parent: string | null; reason: string }) => void;\n\n /** Which nodes may be committed. Defaults to leaves only. */\n selectable?: CascaderSelectable<T>;\n\n /**\n * Whether the built-in SINGLE-SELECT check is drawn. Defaults to true.\n * `false` also gives back the inline-end gutter every style reserves for it;\n * `data-selected` and `aria-selected` stay. A no-op under `multiple`, where\n * the checkbox is the selection CONTROL rather than a decoration.\n */\n indicator?: boolean;\n\n /**\n * Footer ACTIONS: commands pinned below the list, never rows in it, and never\n * touching the data tree. A childless `<CascaderFooter />` draws these; an\n * action with `items` opens a side-anchored flyout rather than firing.\n */\n actions?: CascaderActionItem[];\n\n /**\n * Parent/child cascading. Multi-select only, off by default, and it needs\n * committable branches (`selectable=\"any\"` or a predicate). A commit selects\n * or deselects every SELECTABLE node in the KNOWN subtree (loaded, or on a\n * resolved chain) and reconciles ancestors. KNOWN is the semantic, not a\n * hedge: a commit must not fan out into a request per level, so children\n * arriving later arrive unchecked.\n */\n cascade?: boolean;\n\n mode?: CascaderMode;\n\n /** How a branch opens from the pointer in columns mode's ACTIVE column.\n * `\"click\"` is the default, and neither value ever commits a selection. */\n expandTrigger?: \"click\" | \"hover\";\n\n path?: string[];\n defaultPath?: string[];\n /** The second argument says WHY. An existing `(path) => void` still works. */\n onPathChange?: (path: string[], details: { reason: CascaderPathChangeReason }) => void;\n\n expanded?: string[];\n defaultExpanded?: string[];\n onExpandedChange?: (expanded: string[]) => void;\n\n open?: boolean;\n defaultOpen?: boolean;\n /** Forwards Base UI's reason; a leaf commit's close says `\"item-press\"`. */\n onOpenChange?: (open: boolean, details: { reason: string }) => void;\n\n /**\n * Whether a SINGLE-SELECT leaf commit closes the popup. Defaults to true.\n * `false` is for a compare-and-repick flow; Escape, outside press and the\n * trigger still close. Ignored under `multiple`, which never closes.\n */\n closeOnSelect?: boolean;\n\n inputValue?: string;\n defaultInputValue?: string;\n onInputValueChange?: (value: string) => void;\n\n /**\n * `\"level\"` (default) filters the level on screen, `\"deep\"` also searches\n * below it, `\"global\"` searches the whole tree from any level.\n */\n searchScope?: CascaderSearchScope;\n /** Custom matcher, replacing label + keywords substring matching. */\n filter?: (node: CascaderNode<T>, normalizedQuery: string) => boolean;\n\n /** On open, navigate to the level holding the selection. Default true.\n * Not in `mode=\"tree\"`, which has no levels to navigate. */\n revealSelected?: boolean;\n\n maxHeight?: number | string;\n\n /**\n * Window the rendered rows. `undefined` decides per level from\n * `virtualizeThreshold`; `true`/`false` force it. Also opt-in at the markup\n * level, so the base install pulls in no virtualization library.\n */\n virtualize?: boolean;\n /** Row count at which windowing turns itself on. */\n virtualizeThreshold?: number;\n /** Row height handed to the virtualizer before a row has been measured. */\n estimateRowSize?: number;\n /** Rows rendered beyond each edge of the viewport. */\n overscan?: number;\n\n labels?: Partial<CascaderLabels>;\n /** Replaces the entire row, affordances included. */\n renderItem?: (node: CascaderNode<T>, state: CascaderItemState<T>) => React.ReactNode;\n /** Replaces only the label block; icon, count, chevron and check stay. */\n renderLabel?: (node: CascaderNode<T>, state: CascaderItemState<T>) => React.ReactNode;\n\n disabled?: boolean;\n /** Native form field name. Submits the selected value(s). */\n name?: string;\n /** Id of the owning form, for a cascader rendered outside it. */\n form?: string;\n /** Id of the control. Pairs the field with a `<label htmlFor>`. */\n id?: string;\n /** Marks the field required for native form validation. */\n required?: boolean;\n /** The value can be read and submitted, but not changed. */\n readOnly?: boolean;\n /** Marks the field invalid: `aria-invalid` and `data-invalid` on the trigger,\n * the chips and the input, which every style's error treatment reads. */\n invalid?: boolean;\n /** Ref to the hidden input Base UI submits with, for form-library focus. */\n inputRef?: React.Ref<HTMLInputElement>;\n /** Renders without a floating popup, for an embedded `CascaderPanel`. */\n inline?: boolean;\n\n children?: React.ReactNode;\n}\n\nexport interface CascaderSingleProps<T = unknown> extends CascaderBaseProps<T> {\n multiple?: false;\n value?: string;\n defaultValue?: string;\n onValueChange?: (value: string, details: CascaderChangeDetails<T>) => void;\n /** `never` so passing it is a compile error, not a silent no-op. */\n max?: never;\n}\n\n/** Multi-select props. Enables checkbox rows and chip display. */\nexport interface CascaderMultipleProps<T = unknown> extends CascaderBaseProps<T> {\n multiple: true;\n value?: string[];\n defaultValue?: string[];\n onValueChange?: (value: string[], details: CascaderChangeDetails<T>) => void;\n /** Cap on selections. Further picks are refused, the existing ones survive. */\n max?: number;\n}\n\n/** `multiple` discriminates: `value`, `onValueChange` and `max` narrow with it. */\nexport type CascaderProps<T = unknown> = CascaderSingleProps<T> | CascaderMultipleProps<T>;\n\n/** Normalizes to an array. `\"\"` is \"no selection\", not a node: it is the\n * uncontrolled default, and resolving it would render a blank chip. */\nfunction toArray(value: string | string[] | undefined): string[] {\n if (value == null) return [];\n if (Array.isArray(value)) return value.filter((entry) => entry !== \"\");\n return value === \"\" ? [] : [value];\n}\n\n/* -------------------------------------------------------------------------- */\n/* Development warnings */\n/* -------------------------------------------------------------------------- */\n\ninterface CascaderDevOptions<T> {\n items: CascaderNode<T>[];\n getParent?: (node: CascaderNode<T>) => string | null | undefined;\n mode: CascaderMode;\n multiple: boolean;\n cascade: boolean;\n indicator: boolean;\n selectable: CascaderSelectable<T>;\n searchScope: CascaderSearchScope;\n max: number | undefined;\n value: string | string[] | undefined;\n defaultValue: string | string[] | undefined;\n hasExpanded: boolean;\n hasPath: boolean;\n hasOnSearch: boolean;\n}\n\n/** Misconfigurations that are SILENT by design. Once each, never in prod. */\nfunction useCascaderDevWarnings<T>(options: CascaderDevOptions<T>) {\n const {\n items,\n getParent,\n mode,\n multiple,\n cascade,\n indicator,\n selectable,\n searchScope,\n max,\n value,\n defaultValue,\n hasExpanded,\n hasPath,\n hasOnSearch,\n } = options;\n\n // O(n) over the raw input, so the memo is skipped outright in production.\n const issues = React.useMemo(\n () => (process.env.NODE_ENV === \"production\" ? null : findCascaderDataIssues(items, getParent)),\n [items, getParent],\n );\n\n React.useEffect(() => {\n if (process.env.NODE_ENV === \"production\") return;\n\n for (const duplicate of issues?.duplicates ?? []) {\n warnCascaderOnce(\n `duplicate-value:${duplicate}`,\n `Duplicate node value ${JSON.stringify(duplicate)}. \\`value\\` is the selection key, so only the first occurrence is indexed and the rest never render.`,\n );\n }\n\n for (const cycle of issues?.cycles ?? []) {\n warnCascaderOnce(\n `cycle:${cycle}`,\n `\\`getParent\\` puts ${JSON.stringify(cycle)} on a cycle. The depth walk is cycle-guarded so nothing hangs, but every depth on that chain is clamped rather than derived.`,\n );\n }\n }, [issues]);\n\n React.useEffect(() => {\n if (process.env.NODE_ENV === \"production\") return;\n\n for (const [prop, current] of [\n [\"value\", value],\n [\"defaultValue\", defaultValue],\n ] as const) {\n if (current == null) continue;\n if (multiple && !Array.isArray(current)) {\n warnCascaderOnce(\n `value-shape:multiple:${prop}`,\n `\\`multiple\\` is set but \\`${prop}\\` is a string. Multi-select reads and writes a \\`string[]\\`; a string is treated as no selection at all.`,\n );\n } else if (!multiple && Array.isArray(current)) {\n warnCascaderOnce(\n `value-shape:single:${prop}`,\n `\\`${prop}\\` is an array but \\`multiple\\` is not set. Single-select reads and writes a \\`string\\`; only the first entry would survive a commit.`,\n );\n }\n }\n\n if (cascade && !multiple) {\n warnCascaderOnce(\n \"cascade-without-multiple\",\n \"`cascade` does nothing without `multiple`: a single selection has no subtree to propagate over.\",\n );\n }\n\n if (cascade && selectable === \"leaf\") {\n warnCascaderOnce(\n \"cascade-with-leaf-selectable\",\n '`cascade` does nothing while `selectable=\"leaf\"`: no branch can be committed, so no commit ever has a subtree under it. Pass `selectable=\"any\"` or a predicate that accepts branches.',\n );\n }\n\n if (!indicator && multiple) {\n warnCascaderOnce(\n \"indicator-false-with-multiple\",\n \"`indicator={false}` does nothing with `multiple`: the checkbox is the selection control rather than a decoration, so it and its gutter stay. Mark selection your own way from `data-selected` on the row, and drop the prop.\",\n );\n }\n\n if (max != null && !multiple) {\n warnCascaderOnce(\n \"max-without-multiple\",\n \"`max` does nothing without `multiple`: there is only ever one selection to cap.\",\n );\n }\n\n if (hasExpanded && mode !== \"tree\") {\n warnCascaderOnce(\n `expanded-outside-tree:${mode}`,\n `\\`expanded\\` only does something in \\`mode=\"tree\"\\`, and this cascader is in \\`mode=\"${mode}\"\\`. Drill and columns navigate with \\`path\\`.`,\n );\n }\n\n if (hasPath && mode === \"tree\") {\n warnCascaderOnce(\n \"path-in-tree\",\n '`path` does nothing in `mode=\"tree\"`: branches expand in place rather than replacing the level. Use `expanded`.',\n );\n }\n\n if (searchScope === \"deep\" && mode === \"tree\") {\n warnCascaderOnce(\n \"deep-search-in-tree\",\n '`searchScope=\"deep\"` does nothing in `mode=\"tree\"`: a tree query already matches at any depth and auto-expands the ancestors of every hit.',\n );\n }\n\n if (searchScope === \"global\" && mode === \"tree\") {\n warnCascaderOnce(\n \"global-search-in-tree\",\n '`searchScope=\"global\"` does nothing in `mode=\"tree\"`: a tree query already searches the whole tree and auto-expands the ancestors of every hit.',\n );\n }\n\n if (hasOnSearch && mode === \"tree\") {\n warnCascaderOnce(\n \"onsearch-in-tree\",\n '`onSearch` does nothing in `mode=\"tree\"`: a tree query filters the loaded tree in place, and a server hit belongs to no visible branch, so its results would never render. The request is not fired. Filter the tree locally, or use drill or columns for server search.',\n );\n }\n }, [\n mode,\n multiple,\n cascade,\n indicator,\n selectable,\n searchScope,\n max,\n value,\n defaultValue,\n hasExpanded,\n hasPath,\n hasOnSearch,\n ]);\n}\n\n/** What the `[]`-dep callbacks would otherwise close over. One ref, one\n * effect, so \"the last committed render\" is defined in exactly one place. */\ninterface CascaderLatest<T> {\n index: CascaderIndex<T>;\n state: CascaderStateContextValue<T>;\n mode: CascaderMode;\n multiple: boolean;\n cascade: boolean;\n max: number | undefined;\n labels: CascaderLabels;\n closeOnSelect: boolean;\n selectedValues: string[];\n deepResults: CascaderNode<T>[] | null;\n onValueChange:\n | ((value: string | string[], details: CascaderChangeDetails<T>) => void)\n | undefined;\n resolveNode: (value: string) => CascaderNode<T>;\n isSelectable: (node: CascaderNode<T>) => boolean;\n needsChildren: (node: CascaderNode<T>) => boolean;\n expanded: ReadonlySet<string>;\n}\n\n/** A navigation waiting on a fetch. The `kind`s differ: a drill appends, a\n * columns press replaces the trail from `depth`, a search hit swaps in its own\n * `trail`, a tree press expands. */\ntype CascaderPendingNavigation =\n | {\n value: string;\n kind: \"push\" | \"at\" | \"expand\";\n /** `kind: \"at\"` only. The depth the pressed row belongs to. */\n depth: number;\n }\n | {\n value: string;\n kind: \"trail\";\n /** The hit's ancestor chain, root first, the hit itself last. */\n trail: string[];\n };\n\n/** No default on `T`: inferred from `items`, so `node.data` arrives typed. */\nfunction Cascader<T>({\n items,\n getParent,\n getChildren,\n onSearch,\n searchDebounce,\n resolveValue,\n loadKey,\n prefetch,\n onLoadError,\n value: valueProp,\n defaultValue,\n onValueChange: onValueChangeProp,\n multiple = false,\n selectable = \"leaf\",\n indicator = true,\n actions,\n cascade = false,\n max,\n mode = \"drill\",\n expandTrigger,\n path: pathProp,\n defaultPath,\n onPathChange,\n expanded: expandedProp,\n defaultExpanded,\n onExpandedChange,\n open: openProp,\n defaultOpen = false,\n onOpenChange,\n closeOnSelect = true,\n inputValue: inputValueProp,\n defaultInputValue = \"\",\n onInputValueChange,\n searchScope = \"level\",\n filter,\n revealSelected = true,\n maxHeight,\n virtualize,\n virtualizeThreshold = 100,\n estimateRowSize = 32,\n overscan = 8,\n labels: labelsProp,\n renderItem,\n renderLabel,\n disabled,\n name,\n form,\n id,\n required,\n readOnly,\n invalid,\n inputRef,\n inline,\n children,\n}: CascaderProps<T>) {\n const baseIndex = React.useMemo(\n () => buildCascaderIndex(items, getParent),\n // `getParent` is stable by design: an inline accessor must not rebuild a\n // 50k-node index.\n [items, getParent],\n );\n\n const baseId = React.useId();\n\n // Shallow-stabilized first: an inline `labels` would republish the context.\n const stableLabelsProp = useShallowStable(labelsProp, shallowEqualRecords);\n\n const labels = React.useMemo(() => resolveCascaderLabels(stableLabelsProp), [stableLabelsProp]);\n\n useCascaderDevWarnings({\n items,\n getParent,\n mode,\n multiple,\n cascade,\n indicator,\n selectable,\n searchScope,\n max,\n value: valueProp,\n defaultValue,\n hasExpanded:\n expandedProp !== undefined || defaultExpanded !== undefined || onExpandedChange !== undefined,\n hasPath: pathProp !== undefined || defaultPath !== undefined || onPathChange !== undefined,\n hasOnSearch: onSearch !== undefined,\n });\n\n // Public props are discriminated, internals are not: one assertion.\n const onValueChange = onValueChangeProp as\n | ((value: string | string[], details: CascaderChangeDetails<T>) => void)\n | undefined;\n\n // No `onChange`: `onValueChange` takes a second argument, so `emitSelection`\n // invokes it rather than the state hook, which only knows the value.\n const [value, setValue] = useControllable<string | string[]>(\n valueProp,\n defaultValue ?? (multiple ? [] : \"\"),\n undefined,\n \"value\",\n );\n // Why the current path (or open) change is happening. Refs, not arguments:\n // `useControllable` only passes a value, and its onChange runs synchronously\n // inside the setter, so a ref written just before is exact. The path ref\n // resets to `\"external\"`, which is what the consumer's `setPath` reports.\n const pathReasonRef = React.useRef<CascaderPathChangeReason>(\"external\");\n const openReasonRef = React.useRef<string>(\"none\");\n\n const [path, setPath] = useControllable<string[]>(\n pathProp,\n defaultPath ?? [],\n (next) => onPathChange?.(next, { reason: pathReasonRef.current }),\n \"path\",\n );\n const [expandedList, setExpandedList] = useControllable<string[]>(\n expandedProp,\n defaultExpanded ?? [],\n onExpandedChange,\n \"expanded\",\n );\n const [open, setOpen] = useControllable<boolean>(\n openProp,\n defaultOpen,\n (next) => onOpenChange?.(next, { reason: openReasonRef.current }),\n \"open\",\n );\n\n /** The internal `setPath`: names its reason, then hands back to \"external\". */\n const setPathWithReason = React.useCallback(\n (next: string[] | ((prev: string[]) => string[]), reason: CascaderPathChangeReason) => {\n pathReasonRef.current = reason;\n try {\n setPath(next);\n } finally {\n pathReasonRef.current = \"external\";\n }\n },\n [setPath],\n );\n const [query, setQuery] = useControllable<string>(\n inputValueProp,\n defaultInputValue,\n onInputValueChange,\n \"inputValue\",\n );\n\n const expanded = React.useMemo(() => new Set(expandedList), [expandedList]);\n const selectedValues = React.useMemo(() => toArray(value), [value]);\n\n /* --------------------------------- async -------------------------------- */\n\n // On-screen levels, so the ones worth fetching. Columns shows the whole\n // trail at once, which is why the loader is per-level, not one flag.\n const levels = React.useMemo(() => {\n if (mode === \"tree\") return [CASCADER_ROOT_KEY, ...expandedList];\n if (mode === \"columns\") return [CASCADER_ROOT_KEY, ...path];\n return [path.length ? path[path.length - 1] : CASCADER_ROOT_KEY];\n }, [mode, path, expandedList]);\n\n // A SIBLING of the index build, never a step inside it: the build stays pure\n // in `items`, the loader owns the pages, the merge is pure in both, and that\n // is what makes loaded data survive an `items` change.\n const loader = useCascaderLoader<T>({\n base: baseIndex,\n getChildren,\n // Gated, not merely unrendered: a tree hit belongs to no visible branch.\n onSearch: mode === \"tree\" ? undefined : onSearch,\n resolveValue,\n searchDebounce,\n loadKey,\n prefetch,\n onLoadError,\n // An inline cascader is never \"open\", but its panel is live.\n enabled: open || !!inline,\n query,\n levels,\n path: searchScope === \"global\" ? GLOBAL_SEARCH_PATH : path,\n values: selectedValues,\n });\n\n const loadStates = loader.states;\n\n // Destructured here, not at the actions memo, because `navigate` sits above\n // it. All three are `[]`-dep inside the loader, so identity is stable.\n const { ensureLevel, retryLevel: retryLoaderLevel, invalidateLevel } = loader;\n\n /**\n * Whether pressing this branch has to FETCH first: in flight, failed, or\n * never asked. `baseIndex`, as `ensureLevel` asks it: the two must agree or a\n * press parks a navigation nothing will ever settle.\n */\n const needsChildren = React.useCallback(\n (node: CascaderNode<T>) => {\n if (!loader.active) return false;\n const state = loadStates.get(node.value);\n if (state) return state.loading || state.error;\n return !baseIndex.childrenOf.has(node.value);\n },\n [loader.active, loadStates, baseIndex],\n );\n\n // Levels with pages left, the only ones a resolved chain node is listed in.\n // A string first, so a loading flip that leaves `hasMore` alone keeps the\n // set, and the index, as they were.\n const pagingKey = JSON.stringify(\n Array.from(loadStates)\n .filter(([, state]) => state.hasMore)\n .map(([key]) => key),\n );\n const paging = React.useMemo(\n () => new Set<string>(JSON.parse(pagingKey) as string[]),\n [pagingKey],\n );\n\n // Keyed on the maps the merge reads, NOT the store: `withLoadState`\n // returns a fresh store over the SAME maps, so keying on it rebuilt the\n // whole index on every loading flip that changed no data.\n const { pages, detached, links } = loader.store;\n const index = React.useMemo(\n () => mergeCascaderIndex(baseIndex, pages, detached, links, paging),\n [baseIndex, pages, detached, links, paging],\n );\n\n /** Whether a level needs the paging pseudo-row. A never-fetched level gets\n * nothing; that is the empty state's job. Tree has no per-level empty state,\n * so there the row is also the branch's loading and error surface. */\n const needsMoreRow = React.useCallback(\n (key: string, childCount: number) => {\n const state = loadStates.get(key);\n if (!state) return false;\n if (childCount > 0) return state.hasMore || state.loading || state.error;\n return mode === \"tree\" && (state.loading || state.error);\n },\n [loadStates, mode],\n );\n\n // Remembers every selected node, so the trigger keeps a label after it\n // leaves the loaded set (or was never in it).\n const labelCacheRef = React.useRef(new Map<string, CascaderNode<T>>());\n\n // Populated during render, since the trigger reads it while rendering.\n // Idempotent and prop-derived, so a discarded render is harmless.\n for (const selected of selectedValues) {\n const node = index.byValue.get(selected);\n if (node) labelCacheRef.current.set(selected, node);\n }\n\n const resolveNode = React.useCallback(\n (nodeValue: string): CascaderNode<T> =>\n index.byValue.get(nodeValue) ??\n labelCacheRef.current.get(nodeValue) ?? {\n value: nodeValue,\n label: nodeValue,\n },\n [index],\n );\n\n /* ------------------------------ derived view ----------------------------- */\n\n const currentParentValue = path.length ? path[path.length - 1] : null;\n const currentParent = currentParentValue ? (index.byValue.get(currentParentValue) ?? null) : null;\n\n const currentLevelKey = currentParentValue ?? CASCADER_ROOT_KEY;\n\n const isDeepSearching =\n (searchScope === \"deep\" || searchScope === \"global\") &&\n query.trim().length > 0 &&\n mode !== \"tree\";\n // Global is the same scan from the root, whatever level is on screen.\n const deepSearchWithin = searchScope === \"global\" ? null : currentParentValue;\n\n const localDeepResults = React.useMemo(() => {\n if (!isDeepSearching) return null;\n return searchCascaderDeep(index, query, {\n within: deepSearchWithin,\n matches: filter,\n });\n }, [isDeepSearching, index, query, deepSearchWithin, filter]);\n\n // Server search wins over the local scan, or each hit shows up twice.\n const deepResults = loader.searchResults ?? localDeepResults;\n\n const levelItems = React.useMemo(() => {\n const level = getCascaderChildren(index, currentParentValue);\n return filterCascaderLevel(level, query, filter);\n }, [index, currentParentValue, query, filter]);\n\n /** The active level's rows plus the paging pseudo-row, appended HERE because\n * every index Base UI hands out indexes this array: a DOM row missing from\n * it shifts the highlight and every windowed row by one. */\n const levelRendered = React.useMemo(() => {\n if (deepResults) return deepResults;\n if (!needsMoreRow(currentLevelKey, levelItems.length)) return levelItems;\n return withCascaderMoreRow(\n levelItems,\n createCascaderMoreNode<T>(currentLevelKey, levelItems.length),\n index.pinned,\n );\n }, [deepResults, levelItems, currentLevelKey, needsMoreRow, index.pinned]);\n\n // Columns renders the whole trail, but only the deepest column is\n // interactive through Base UI, so `renderedItems` stays what drill uses.\n const columns = React.useMemo<CascaderColumn<T>[]>(() => {\n if (mode !== \"columns\") return [];\n const trail: CascaderColumn<T>[] = [];\n for (let depth = 0; depth <= path.length; depth += 1) {\n const parentValue = depth === 0 ? null : path[depth - 1];\n const parent = parentValue ? (index.byValue.get(parentValue) ?? null) : null;\n const isActive = depth === path.length;\n let columnItems: CascaderNode<T>[];\n if (isActive) {\n columnItems = levelRendered;\n } else {\n // A trail column pages on its own, without losing the columns right of it.\n const key = parentValue ?? CASCADER_ROOT_KEY;\n const children = getCascaderChildren(index, parentValue);\n columnItems = needsMoreRow(key, children.length)\n ? withCascaderMoreRow(\n children,\n createCascaderMoreNode<T>(key, children.length),\n index.pinned,\n )\n : children;\n }\n trail.push({\n parent,\n depth,\n activeValue: path[depth] ?? null,\n active: isActive,\n // Only the active column is filtered: a query narrows what you type\n // into, never the trail behind it.\n items: columnItems,\n });\n }\n return trail;\n }, [mode, path, index, levelRendered, needsMoreRow]);\n\n // Tree level keys needing a paging pseudo-row. With no per-level empty\n // state, this is also where a still-loading branch says so.\n const treeSentinels = React.useMemo(() => {\n if (mode !== \"tree\") return undefined;\n const keys = new Set<string>();\n const consider = (key: string) => {\n if (needsMoreRow(key, index.childrenOf.get(key)?.length ?? 0)) {\n keys.add(key);\n }\n };\n consider(CASCADER_ROOT_KEY);\n for (const value of expanded) consider(value);\n return keys.size ? keys : undefined;\n }, [mode, index, expanded, needsMoreRow]);\n\n const treeRows = React.useMemo<CascaderFlatNode<T>[]>(() => {\n if (mode !== \"tree\") return [];\n const rows = flattenCascaderTree(index, expanded, treeSentinels);\n // Same normalizer as the level filter, so the two cannot disagree.\n const normalized = normalizeCascaderQuery(query);\n if (!normalized) return rows;\n // Matches every node, not just visible rows, and keeps the ancestors, or a\n // hit inside a collapsed branch disappears. Same matcher as every other\n // path, so keyword-only hits do not vanish in tree mode alone.\n const keep = new Set<string>();\n // Only a hit some level shows: a resolved node no loaded level lists kept\n // its ancestors expanded over nothing, while the status said no results.\n const listed = getCascaderListedValues(index);\n for (const node of index.all) {\n if (!listed.has(node.value)) continue;\n if (!(filter ? filter(node, normalized) : matchesCascaderQuery(node, normalized))) {\n continue;\n }\n for (const ancestor of getCascaderPath(index, node.value)) {\n keep.add(ancestor.value);\n }\n }\n // No sentinels while filtering: that page would not have the query applied.\n return flattenCascaderTree(index, new Set([...expanded, ...keep])).filter((row) =>\n keep.has(row.node.value),\n );\n }, [mode, index, expanded, treeSentinels, query, filter]);\n\n // What `Combobox.Root` receives. Tree flattens to the same linear list, so\n // selection and highlighting need no per-mode case.\n const renderedItems = React.useMemo(\n () => (mode === \"tree\" ? treeRows.map((row) => row.node) : levelRendered),\n [mode, treeRows, levelRendered],\n );\n\n /* ---------------------------- level swap reset --------------------------- */\n\n /** Base UI never resets the highlighted index on an `items` change and has\n * no imperative setter; its one automatic reset is an out-of-range clamp, so\n * a single empty frame trips it. The frame rides `filteredItems`, so the\n * `items` identity stays put. */\n const levelKey = currentParentValue ?? \"\";\n\n // STATE, not a ref: a replayed render would see a ref advanced and skip it.\n const [swap, setSwap] = React.useState({ key: levelKey, active: false });\n\n if (swap.key !== levelKey) {\n setSwap({ key: levelKey, active: true });\n }\n const swapping = swap.active && swap.key === levelKey;\n\n React.useLayoutEffect(() => {\n if (swap.active) setSwap((prev) => ({ ...prev, active: false }));\n }, [swap.active]);\n\n // The same frame on demand, for a navigation that lands on the level already\n // on screen: the key never moves, so the check above never fires.\n const resetHighlight = React.useCallback(() => {\n setSwap((prev) => (prev.active ? prev : { ...prev, active: true }));\n }, []);\n\n /* ----------------------------- virtualization ---------------------------- */\n\n // A COUNT: columns mounts one per column, and StrictMode remounts effects.\n const [virtualRenderers, setVirtualRenderers] = React.useState(0);\n\n const registerVirtualRenderer = React.useCallback(() => {\n setVirtualRenderers((count) => count + 1);\n return () => setVirtualRenderers((count) => Math.max(0, count - 1));\n }, []);\n\n const hasVirtualRenderer = virtualRenderers > 0;\n const wantsVirtual = virtualize ?? renderedItems.length >= virtualizeThreshold;\n\n // LATCHED per level: otherwise a query narrowing a 5,000 row level past the\n // threshold tears the virtualizer down and rebuilds it on backspace, losing\n // every measurement. State, not a ref, like `swap`.\n const [virtualLatch, setVirtualLatch] = React.useState({\n key: levelKey,\n on: false,\n });\n\n const virtualized =\n hasVirtualRenderer &&\n (virtualLatch.key === levelKey ? virtualLatch.on || wantsVirtual : wantsVirtual);\n\n if (!hasVirtualRenderer) {\n // Nothing is windowing, so nothing may stay latched.\n if (virtualLatch.on || virtualLatch.key !== levelKey) {\n setVirtualLatch({ key: levelKey, on: false });\n }\n } else if (virtualLatch.key !== levelKey) {\n setVirtualLatch({ key: levelKey, on: virtualized });\n } else if (virtualized && !virtualLatch.on) {\n setVirtualLatch({ key: levelKey, on: true });\n }\n\n /**\n * One forced re-render, one commit AFTER windowing turns on. Base UI sizes\n * `listRef` from `filteredItems` in a layout effect keyed on that array's\n * identity, but `virtualized` reaches the list a commit later and the\n * `CompositeList` teardown REPLACES `listRef` with an empty array nothing\n * re-sizes, so ArrowDown stops at the last WINDOWED row. A passive effect is\n * late enough: the teardown is scheduled from a layout effect.\n */\n const [_virtualSyncs, setVirtualSyncs] = React.useState(0);\n\n React.useEffect(() => {\n if (!virtualized) return;\n setVirtualSyncs((count) => count + 1);\n }, [virtualized]);\n\n React.useEffect(() => {\n if (process.env.NODE_ENV === \"production\") return undefined;\n if (virtualize !== true || hasVirtualRenderer) return undefined;\n // Deferred a tick: the renderer registers from a layout effect, so a\n // synchronous check would report every correctly wired cascader.\n const timeout = setTimeout(() => {\n console.error(\n \"[Cascader] `virtualize` is true but no windowing renderer is mounted. \" +\n \"Render <CascaderVirtualItems /> inside <CascaderList>, or \" +\n \"<CascaderVirtualColumn /> through the <CascaderColumns> slot.\",\n );\n }, 0);\n return () => clearTimeout(timeout);\n }, [virtualize, hasVirtualRenderer]);\n\n /* ------------------------------ navigation ------------------------------ */\n\n /** One signal per navigation, feeding the live region, bumped EXACTLY once\n * per action. `seq` alternates the invisible marker so two identical\n * announcements are still two mutations; `toggled` names the tree branch. */\n const [announceSignal, setAnnounceSignal] = React.useState<{\n seq: number;\n toggled: string | null;\n /** A one-off verbatim message: a `max` refusal, a cascade fan-out. STATE,\n * so an unrelated render cannot clear it mid-read. */\n notice: string | null;\n }>({ seq: 0, toggled: null, notice: null });\n\n const bumpAnnouncement = React.useCallback((toggled: string | null) => {\n setAnnounceSignal((prev) => ({ seq: prev.seq + 1, toggled, notice: null }));\n }, []);\n\n /** Speaks for interactions that change nothing on screen: a refusal returns\n * before any state moves, a cascade sweep is invisible from the row pressed.\n * The seq bump keeps two identical refusals two mutations. */\n const announceNotice = React.useCallback((notice: string) => {\n setAnnounceSignal((prev) => ({ seq: prev.seq + 1, toggled: null, notice }));\n }, []);\n\n /**\n * The navigation a press asked for and a fetch has not answered yet. Load\n * BEFORE you move: drilling in first threw away the list the user was\n * reading and, on failure, stranded them on an error screen for a level they\n * had never seen. Holding here keeps the old rows and puts the progress on\n * the pressed row, whose chevron `CascaderItem` swaps for a spinner.\n */\n const [pendingNavigation, setPendingNavigation] =\n React.useState<CascaderPendingNavigation | null>(null);\n\n /** Asks for a branch's children and parks the navigation until they land.\n * BOTH entry points are called unconditionally: `retryLevel` no-ops unless\n * the level errored, `ensureLevel` no-ops if it has state, so a repeat press\n * is free and the readiness decision stays inside the loader. */\n const requestChildren = React.useCallback(\n (node: CascaderNode<T>, pending: CascaderPendingNavigation) => {\n setPendingNavigation(pending);\n retryLoaderLevel(node.value);\n ensureLevel(node.value, \"level\");\n // Otherwise the panel is silent from the press until the level swaps.\n bumpAnnouncement(null);\n },\n [retryLoaderLevel, ensureLevel, bumpAnnouncement],\n );\n\n const pushLevel = React.useCallback(\n (nodeValue: string) => {\n setPathWithReason((prev) => [...prev, nodeValue], \"drill\");\n setQuery(\"\");\n bumpAnnouncement(null);\n },\n [setPathWithReason, setQuery, bumpAnnouncement],\n );\n\n const popLevel = React.useCallback(() => {\n setPathWithReason((prev) => (prev.length ? prev.slice(0, -1) : prev), \"back\");\n setQuery(\"\");\n // Going BACK abandons a held navigation, or an in-flight branch drills in\n // the moment it lands, long after the user moved on.\n setPendingNavigation(null);\n bumpAnnouncement(null);\n }, [setPathWithReason, setQuery, bumpAnnouncement]);\n\n const goToDepth = React.useCallback(\n (depth: number) => {\n setPathWithReason((prev) => prev.slice(0, Math.max(0, depth)), \"breadcrumb\");\n setQuery(\"\");\n setPendingNavigation(null);\n bumpAnnouncement(null);\n },\n [setPathWithReason, setQuery, bumpAnnouncement],\n );\n\n const toggleExpanded = React.useCallback(\n (nodeValue: string) => {\n setExpandedList((prev) =>\n prev.includes(nodeValue) ? prev.filter((v) => v !== nodeValue) : [...prev, nodeValue],\n );\n bumpAnnouncement(nodeValue);\n },\n [setExpandedList, bumpAnnouncement],\n );\n\n const isBranch = React.useCallback(\n (node: CascaderNode<T>) => isCascaderBranch(index, node),\n [index],\n );\n\n const isSelectable = React.useCallback(\n (node: CascaderNode<T>) => isCascaderSelectable(index, node, selectable),\n [index, selectable],\n );\n\n const isDisabled = React.useCallback(\n (node: CascaderNode<T>) => isCascaderDisabled(index, node),\n [index],\n );\n\n // Whether a branch can be committed AT ALL here. `\"leaf\"` is the only\n // setting that answers no in advance; a predicate is opaque, so the check\n // gutter is reserved uniformly rather than per row.\n const branchesSelectable = selectable !== \"leaf\";\n\n // Open flyouts, by key. A ref, not state: `handleOpenChange` needs the\n // answer as of the Escape being handled, and opening a footer menu must not\n // re-render the root.\n const openFlyoutsRef = React.useRef<Set<string>>(new Set());\n\n const setFlyoutOpen = React.useCallback((key: string, open: boolean) => {\n if (open) openFlyoutsRef.current.add(key);\n else openFlyoutsRef.current.delete(key);\n }, []);\n\n const hasOpenFlyout = React.useCallback(() => openFlyoutsRef.current.size > 0, []);\n\n // Shallow-stabilized like `labels`: an inline array republished the context.\n const stableActions = useShallowStable(actions, shallowEqualItemLists);\n\n const resolvedActions = React.useMemo<CascaderActionItem[]>(\n () => stableActions ?? EMPTY_ACTIONS,\n [stableActions],\n );\n\n // A Set, not an `includes` scan: `isSelected` runs once per rendered row.\n const selectedSet = React.useMemo(() => new Set(selectedValues), [selectedValues]);\n\n const isSelected = React.useCallback(\n (node: CascaderNode<T>) => selectedSet.has(node.value),\n [selectedSet],\n );\n\n /** Selected-descendant counts, walked ONCE per selection change and never\n * stored, so the flat value array stays the only source of truth. The walk\n * is `selections x depth`, up from each selection rather than down from each\n * row, which keeps the count and `isIndeterminate` O(1). */\n const selectedDescendants = React.useMemo(\n () => getCascaderSelectedDescendants(index, selectedValues),\n [index, selectedValues],\n );\n\n const selectedDescendantCount = React.useCallback(\n (node: CascaderNode<T>) => selectedDescendants.get(node.value) ?? 0,\n [selectedDescendants],\n );\n\n // Partial selections read off the SAME map, so the dash and the number are\n // two readings of one traversal and cannot drift apart.\n const indeterminateSet = React.useMemo(() => {\n if (!cascade || !multiple) return null;\n return getCascaderIndeterminateFrom(selectedDescendants, selectedValues);\n }, [cascade, multiple, selectedDescendants, selectedValues]);\n\n const isIndeterminate = React.useCallback(\n (node: CascaderNode<T>) => indeterminateSet?.has(node.value) ?? false,\n [indeterminateSet],\n );\n\n // Base UI owns the highlight; mirrored so handlers can read it unsubscribed.\n const highlightedRef = React.useRef<CascaderNode<T> | null>(null);\n const getHighlighted = React.useCallback(() => highlightedRef.current, []);\n\n // The same highlight as an external store, for the consumer that must\n // RE-RENDER on it. `useState`, not `useMemo`: React may drop a memo, and a\n // second store would silently orphan every subscriber.\n const [highlightStore] = React.useState<CascaderHighlightStore>(createCascaderHighlightStore);\n\n /* ------------------------------ announcement ---------------------------- */\n\n const currentLoadState = React.useMemo<CascaderLoadState | null>(\n () => loadStates.get(currentLevelKey) ?? null,\n [loadStates, currentLevelKey],\n );\n const searchLoadState = loader.searchState;\n\n /** What the query announcement COUNTS: matches, not rows, since the list\n * also carries a tree query's ancestor context and the Load-more row. Server\n * hits count as-is; re-judging them locally would drop what it matched on\n * data the client cannot see. */\n const announcedMatches = React.useMemo(() => {\n if (deepResults) return deepResults.length;\n const normalized = normalizeCascaderQuery(query);\n if (!normalized) return 0;\n const matches = filter ?? matchesCascaderQuery;\n return renderedItems.filter((node) => !isCascaderMoreNode(node) && matches(node, normalized))\n .length;\n }, [deepResults, renderedItems, query, filter]);\n\n // Real rows only: a tree's first load renders its loading row, and counting\n // that one called the first fetch \"Loading more\".\n const hasRows = renderedItems.some((node) => !isCascaderMoreNode(node));\n\n // The live-region text plus whether it may be DEFERRED; see\n // `ANNOUNCE_DEBOUNCE`. The committed string is state, set below.\n const announcementTarget = React.useMemo(() => {\n // An INLINE cascader is never \"open\", so `open` alone silenced its tree.\n if (!open && !inline) return { text: \"\", defer: false };\n\n const total = renderedItems.length;\n const marker = ANNOUNCE_MARKER.repeat(announceSignal.seq % 2);\n\n // A notice outranks everything below: it exists because nothing else on\n // screen changed. It rides the signal, so the next navigation replaces it.\n if (announceSignal.notice) {\n return { text: `${announceSignal.notice}${marker}`, defer: false };\n }\n\n // A tree toggle changes neither level nor query, so it rides the signal.\n const toggled =\n mode === \"tree\" && announceSignal.toggled\n ? (index.byValue.get(announceSignal.toggled) ?? null)\n : null;\n\n // Async states outrank everything below, or a fetching level announces \"0\n // results\" and contradicts itself. A HELD navigation outranks even those:\n // nothing on screen has moved yet, so \"loading\" is the only truth.\n const pendingState = pendingNavigation\n ? (loadStates.get(pendingNavigation.value) ?? null)\n : null;\n const levelState = query.trim() ? searchLoadState : currentLoadState;\n let text: string;\n let defer = false;\n if (pendingState?.error) {\n text = labels.error;\n } else if (pendingNavigation) {\n // Always the FIRST-page string: the rows on screen belong to the level\n // being left behind, so their count says nothing about this request.\n text = labels.loading;\n } else if (levelState?.error) {\n text = labels.error;\n } else if (levelState?.loading) {\n // With a query set the in-flight load IS the server search, and calling\n // that \"Loading more\" misreads what is being waited on.\n text = query.trim()\n ? labels.searchingAnnouncement\n : hasRows\n ? labels.loadingMore\n : labels.loading;\n } else if (query.trim()) {\n // An empty result set is the more useful thing to say than \"0 results\".\n text = announcedMatches === 0 ? labels.empty : labels.resultsAnnouncement(announcedMatches);\n // The ONE deferred branch: only a stream of keystrokes needs coalescing.\n defer = true;\n } else if (toggled) {\n text = expanded.has(toggled.value)\n ? labels.expandedAnnouncement(toggled.label, getCascaderCount(index, toggled))\n : labels.collapsedAnnouncement(toggled.label);\n } else if (currentParent) {\n // `path.length + 1` matches tree mode's `aria-level`: the rows are\n // `currentParent`'s CHILDREN, one level below it.\n text = labels.levelAnnouncement(currentParent.label, path.length + 1, total);\n } else {\n // Returning to the root would otherwise announce nothing at all.\n text = labels.rootAnnouncement(total);\n }\n\n return { text: `${text}${marker}`, defer };\n }, [\n open,\n inline,\n mode,\n index,\n expanded,\n announceSignal,\n query,\n labels,\n renderedItems.length,\n hasRows,\n announcedMatches,\n currentParent,\n path.length,\n currentLoadState,\n searchLoadState,\n pendingNavigation,\n loadStates,\n ]);\n\n /** The COMMITTED announcement. Immediate texts commit during render (the\n * pattern `swap` uses), so an async settle announces in the very commit that\n * shows the rows. Only the deferred query count uses the timer below. */\n const [announced, setAnnounced] = React.useState(announcementTarget);\n\n if (!announcementTarget.defer && announced.text !== announcementTarget.text) {\n // Terminates: after the set the condition is false on the re-render.\n setAnnounced(announcementTarget);\n }\n\n React.useEffect(() => {\n if (!announcementTarget.defer) return undefined;\n const timer = setTimeout(() => setAnnounced(announcementTarget), ANNOUNCE_DEBOUNCE);\n return () => clearTimeout(timer);\n }, [announcementTarget]);\n\n const announcement = announced.text;\n\n /* --------------------------------- state -------------------------------- */\n\n // The volatile half: rebuilt by a keystroke, hence split from the actions.\n const stateValue = React.useMemo<CascaderStateContextValue<T>>(\n () => ({\n index,\n path,\n expanded,\n query,\n currentParent,\n levelItems,\n deepResults,\n renderedItems,\n columns,\n treeRows,\n selectedValues,\n selectedDescendants,\n loadStates,\n searchState: searchLoadState,\n announcement,\n }),\n [\n index,\n path,\n expanded,\n query,\n currentParent,\n levelItems,\n deepResults,\n renderedItems,\n columns,\n treeRows,\n selectedValues,\n selectedDescendants,\n loadStates,\n searchLoadState,\n announcement,\n ],\n );\n\n /* ------------------------------ latest props ---------------------------- */\n\n /**\n * Latest committed props and derived state, WRITTEN IN AN EFFECT. That is\n * what keeps the callbacks below `[]`-dep and stable for the life of the\n * cascader; writing during render is unsafe under concurrent rendering. The\n * cost: a read sees the PREVIOUS commit until the effect runs, so ONLY event\n * handlers may read it. Anything used during render is memoised instead.\n */\n const latest = React.useRef<CascaderLatest<T>>({\n index,\n state: stateValue,\n mode,\n multiple,\n cascade,\n max,\n labels,\n closeOnSelect,\n selectedValues,\n deepResults,\n onValueChange,\n resolveNode,\n isSelectable,\n needsChildren,\n expanded,\n });\n\n React.useEffect(() => {\n latest.current = {\n index,\n state: stateValue,\n mode,\n multiple,\n cascade,\n max,\n labels,\n closeOnSelect,\n selectedValues,\n deepResults,\n onValueChange,\n resolveNode,\n isSelectable,\n needsChildren,\n expanded,\n };\n });\n\n const getIndex = React.useCallback(() => latest.current.index, []);\n const getState = React.useCallback(() => latest.current.state, []);\n\n const goToLevelAt = React.useCallback(\n (nodeValue: string, depth: number) => {\n setPathWithReason((prev) => [...prev.slice(0, Math.max(0, depth)), nodeValue], \"drill\");\n setQuery(\"\");\n bumpAnnouncement(null);\n },\n [setPathWithReason, setQuery, bumpAnnouncement],\n );\n\n const goToTrail = React.useCallback(\n (trail: string[]) => {\n // A global hit can BE the level on screen. Then nothing moved, so no path\n // change is reported, and no level swap clears the highlight the hit\n // list left at its index, where Enter would commit some other row.\n const { path: current } = latest.current.state;\n const stays =\n trail.length === current.length && trail.every((entry, i) => entry === current[i]);\n if (stays) resetHighlight();\n else setPathWithReason(trail, \"drill\");\n setQuery(\"\");\n bumpAnnouncement(null);\n },\n [setPathWithReason, resetHighlight, setQuery, bumpAnnouncement],\n );\n\n const navigateAt = React.useCallback(\n (node: CascaderNode<T>, depth: number) => {\n if (isCascaderDisabled(latest.current.index, node)) return;\n if (latest.current.mode === \"tree\") {\n toggleExpanded(node.value);\n return;\n }\n if (latest.current.needsChildren(node)) {\n requestChildren(node, { value: node.value, kind: \"at\", depth });\n return;\n }\n goToLevelAt(node.value, depth);\n },\n [toggleExpanded, goToLevelAt, requestChildren],\n );\n\n const navigate = React.useCallback(\n (node: CascaderNode<T>) => {\n const {\n mode: currentMode,\n deepResults: currentDeepResults,\n index: currentIndex,\n expanded: currentExpanded,\n needsChildren: pending,\n } = latest.current;\n\n // Every drill and expand passes here, from a search hit, a key or a hover\n // timer alike, so this is where a disabled subtree stays shut.\n if (isCascaderDisabled(currentIndex, node)) return;\n\n if (currentMode === \"tree\") {\n // Collapsing never needs data. Opening waits WITHOUT expanding, so\n // the branch stays shut with a spinner rather than opening onto no rows.\n if (!currentExpanded.has(node.value) && pending(node)) {\n requestChildren(node, {\n value: node.value,\n kind: \"expand\",\n depth: 0,\n });\n return;\n }\n toggleExpanded(node.value);\n return;\n }\n\n // A search hit sits at any depth, and under a global search outside the\n // current path, so drilling in swaps in the hit's own trail. A held drill\n // carries it too: splicing the hit into the current path at its depth\n // kept the wrong ancestors for anything below a direct child.\n if (currentDeepResults) {\n const trail = getCascaderPath(currentIndex, node.value).map((entry) => entry.value);\n if (pending(node)) {\n requestChildren(node, { value: node.value, kind: \"trail\", trail });\n return;\n }\n goToTrail(trail);\n return;\n }\n\n if (pending(node)) {\n requestChildren(node, { value: node.value, kind: \"push\", depth: 0 });\n return;\n }\n pushLevel(node.value);\n },\n [toggleExpanded, goToTrail, pushLevel, requestChildren],\n );\n\n /**\n * The other half of `requestChildren`: the fetch settled, so the held\n * navigation happens or is dropped. Reads the load STATE, not a promise:\n * only the loader knows a request was superseded, aborted or retried, and no\n * entry at all means it has not reached the store yet. On failure nothing\n * moves and the intent is KEPT, which is what makes the row's retry\n * affordance mean something; only `popLevel`, `goToDepth` and a close drop it.\n */\n React.useEffect(() => {\n if (!pendingNavigation) return;\n const state = loadStates.get(pendingNavigation.value);\n if (!state || state.loading || state.error) return;\n\n setPendingNavigation(null);\n\n // Asked again against the index as it is NOW: a new `items` or a landed\n // page can disable the target while its fetch was in flight.\n const target = index.byValue.get(pendingNavigation.value);\n if (target && isDisabled(target)) return;\n\n if (pendingNavigation.kind === \"expand\") {\n toggleExpanded(pendingNavigation.value);\n return;\n }\n if (pendingNavigation.kind === \"trail\") {\n goToTrail(pendingNavigation.trail);\n return;\n }\n if (pendingNavigation.kind === \"at\") {\n goToLevelAt(pendingNavigation.value, pendingNavigation.depth);\n return;\n }\n pushLevel(pendingNavigation.value);\n }, [\n pendingNavigation,\n loadStates,\n index,\n isDisabled,\n toggleExpanded,\n goToTrail,\n goToLevelAt,\n pushLevel,\n ]);\n\n // A popup that closes mid-flight must not drill in when the answer arrives;\n // the loader aborts the request, this drops the intent.\n React.useEffect(() => {\n if (!open && !inline) setPendingNavigation(null);\n }, [open, inline]);\n\n /* ------------------------------- selection ------------------------------ */\n\n // The one place the selection changes, so `onValueChange` reports the same\n // shape whatever caused it: a row press, drag-select, or the headless hooks.\n const emitSelection = React.useCallback(\n (nextValues: string[], node: CascaderNode<T> | null, reason: CascaderChangeReason) => {\n const {\n selectedValues: current,\n multiple: currentMultiple,\n onValueChange: emit,\n index: currentIndex,\n resolveNode: resolve,\n } = latest.current;\n\n // Nothing changed. The dedup lives here now, not in `useControllable`.\n const unchanged =\n nextValues.length === current.length &&\n nextValues.every((entry, i) => entry === current[i]);\n if (unchanged) return;\n\n const next = currentMultiple ? nextValues : (nextValues[0] ?? \"\");\n setValue(next);\n\n if (!emit) return;\n\n const chain = node ? getCascaderPath(currentIndex, node.value) : [];\n emit(next, {\n node,\n // A node absent from `items` has no chain, so fall back to the node\n // rather than report an empty path for a change that had one.\n path: node ? (chain.length ? chain : [node]) : [],\n // `resolveNode`, not `index.byValue`: a selected value missing from\n // `items` must still come back rather than be dropped.\n nodes: nextValues.map(resolve),\n reason,\n });\n },\n [setValue],\n );\n\n const setSelection = React.useCallback(\n (values: string[], reason?: CascaderChangeReason) => {\n const { selectedValues: current, resolveNode: resolve } = latest.current;\n const before = new Set(current);\n const after = new Set(values);\n const added = values.find((entry) => !before.has(entry));\n const removed = current.find((entry) => !after.has(entry));\n\n if (reason === \"clear\") {\n emitSelection(values, null, \"clear\");\n return;\n }\n if (added) {\n emitSelection(values, resolve(added), reason ?? \"select\");\n return;\n }\n if (removed) {\n emitSelection(values, resolve(removed), reason ?? \"deselect\");\n return;\n }\n // Same set: a no-op, but routed so an explicit `reason` still applies.\n emitSelection(values, null, reason ?? \"select\");\n },\n [emitSelection],\n );\n\n const commit = React.useCallback(\n (node: CascaderNode<T>) => {\n const {\n multiple: currentMultiple,\n cascade: currentCascade,\n selectedValues: current,\n max: currentMax,\n index: currentIndex,\n isSelectable: currentIsSelectable,\n labels: currentLabels,\n closeOnSelect: currentCloseOnSelect,\n } = latest.current;\n\n // Refuses a SELECT, never a removal: a disabled value set from outside\n // must stay removable, and a cascade chip's removal arrives here.\n const selecting = !currentMultiple || !current.includes(node.value);\n if (selecting && isCascaderDisabled(currentIndex, node)) return;\n\n if (!currentMultiple) {\n emitSelection([node.value], node, \"select\");\n if (currentCloseOnSelect) {\n openReasonRef.current = \"item-press\";\n setOpen(false);\n } else {\n // The popup stays up, so clear the query the way a multiple commit\n // does; the next pick then starts from the full level.\n setQuery(\"\");\n }\n return;\n }\n\n if (currentCascade) {\n const next = applyCascadeSelection(\n currentIndex,\n current,\n node.value,\n selecting,\n currentIsSelectable,\n );\n // `max` caps the whole gesture rather than truncating it: an arbitrary\n // prefix of a subtree is a selection nobody asked for. The refusal\n // changes nothing on screen, so the live region is its only witness.\n if (\n selecting &&\n currentMax != null &&\n next.length > currentMax &&\n next.length > current.length\n ) {\n announceNotice(currentLabels.maxReachedAnnouncement(currentMax));\n return;\n }\n emitSelection(next, node, selecting ? \"select\" : \"deselect\");\n // How many values the closure swept along is invisible from the one\n // row pressed, so the sweep says its number out loud, itself excluded.\n const before = new Set(current);\n const after = new Set(next);\n let swept = 0;\n for (const entry of selecting ? next : current) {\n if (entry === node.value) continue;\n if (selecting ? !before.has(entry) : !after.has(entry)) swept += 1;\n }\n if (swept > 0) {\n announceNotice(\n currentLabels.cascadeAnnouncement(node.label ?? node.value, swept, selecting),\n );\n }\n setQuery(\"\");\n return;\n }\n\n if (current.includes(node.value)) {\n emitSelection(\n current.filter((v) => v !== node.value),\n node,\n \"deselect\",\n );\n } else if (currentMax == null || current.length < currentMax) {\n emitSelection([...current, node.value], node, \"select\");\n } else {\n // The plain-multiple twin of the cascade refusal above: just as silent.\n announceNotice(currentLabels.maxReachedAnnouncement(currentMax));\n }\n setQuery(\"\");\n },\n [emitSelection, setOpen, setQuery, announceNotice],\n );\n\n /** Safety net for paths that bypass the row-level veto (the drag-select\n * mouseup). `details.cancel()` suppresses the commit and the close together:\n * Base UI shares one event-details object between them. */\n const handleComboboxValueChange = React.useCallback(\n (\n next: CascaderNode<T> | CascaderNode<T>[] | null,\n details: ComboboxPrimitive.Root.ChangeEventDetails,\n ) => {\n if (!multiple) {\n const node = Array.isArray(next) ? (next[0] ?? null) : next;\n // The paging row is a real option, so Base UI reports it as a\n // selection. Same safety net branches get, for paths a row cannot veto.\n if (node && isCascaderMoreNode(node)) {\n details.cancel();\n return;\n }\n // The row is Base UI `disabled` already, so only a path around it gets\n // here, a custom row re-enabling it for one: refused, never navigated.\n if (node && isDisabled(node)) {\n details.cancel();\n return;\n }\n if (node && !isSelectable(node) && isBranch(node)) {\n details.cancel();\n navigate(node);\n return;\n }\n if (node) {\n // `closeOnSelect={false}` must also stop Base UI's OWN close; one\n // shared details object, so cancelling suppresses both, and our value\n // is controlled, so Base UI's half had nothing to keep.\n if (!closeOnSelect) details.cancel();\n commit(node);\n }\n return;\n }\n\n // Take Base UI's whole array as the answer and inspect only what was\n // ADDED. Deriving the toggle from the tail works for an add but on a\n // remove drops the wrong node, leaving the last selection unclearable.\n const nextNodes = Array.isArray(next) ? next : [];\n const before = new Set(selectedValues);\n const added = nextNodes.find((node) => !before.has(node.value));\n\n if (added && (isCascaderMoreNode(added) || isDisabled(added))) {\n details.cancel();\n return;\n }\n\n if (added && !isSelectable(added) && isBranch(added)) {\n details.cancel();\n navigate(added);\n return;\n }\n\n // Cascading reads Base UI's array only as the REPORT of which row was\n // pressed: it differs by exactly one value either way, and the real\n // commit covers a whole subtree.\n if (cascade) {\n const nextValues = new Set(nextNodes.map((node) => node.value));\n const removed = selectedValues.find((entry) => !nextValues.has(entry));\n const toggled = added ?? (removed != null ? resolveNode(removed) : null);\n if (toggled) commit(toggled);\n return;\n }\n\n if (max != null && nextNodes.length > selectedValues.length && nextNodes.length > max) {\n details.cancel();\n // The third silent refusal site: cancelling reverts the press with no\n // state change, so the live region is the only witness.\n announceNotice(labels.maxReachedAnnouncement(max));\n return;\n }\n\n setSelection(nextNodes.map((node) => node.value));\n setQuery(\"\");\n },\n [\n multiple,\n selectedValues,\n max,\n cascade,\n closeOnSelect,\n labels,\n announceNotice,\n isSelectable,\n isDisabled,\n isBranch,\n navigate,\n commit,\n resolveNode,\n setSelection,\n setQuery,\n ],\n );\n\n const handleOpenChange = React.useCallback(\n (nextOpen: boolean, details: ComboboxPrimitive.Root.ChangeEventDetails) => {\n if (details.isCanceled) return;\n\n // Escape closes ONE popup at a time. `Combobox` builds no `FloatingTree`,\n // so one Escape reaches the flyout and the cascader; the flyout clears\n // its registration in an effect, so the set holds for exactly this event.\n if (!nextOpen && details.reason === \"escape-key\" && hasOpenFlyout()) {\n details.cancel();\n return;\n }\n\n // Captured for the wrapped `onOpenChange`, which runs synchronously\n // inside `setOpen`, so a ref written just before the call is exact.\n openReasonRef.current = details.reason ?? \"none\";\n setOpen(nextOpen);\n\n if (!nextOpen) {\n setQuery(\"\");\n return;\n }\n\n // Opening onto the level holding the selection is the difference\n // between \"edit this\" and \"start over\". Not in a tree, where `path`\n // does nothing and the live region announced a level nobody could see.\n if (revealSelected) {\n setQuery(\"\");\n const first = toArray(value)[0];\n if (mode !== \"tree\") {\n setPathWithReason(\n first\n ? getCascaderPath(index, first)\n .slice(0, -1)\n .map((node) => node.value)\n : [],\n \"reveal\",\n );\n }\n }\n },\n [setOpen, setQuery, revealSelected, value, index, mode, setPathWithReason, hasOpenFlyout],\n );\n\n /* -------------------------------- context ------------------------------- */\n\n // NOT memoised further: render props must be the current closure, and only\n // rows consume this. See `CascaderRenderContextValue`.\n const renderContext = React.useMemo(\n () => ({ renderItem, renderLabel }),\n [renderItem, renderLabel],\n );\n\n /** The stable half: nothing in these deps moves on a keystroke, a level\n * change or a highlight, which is what makes `React.memo` on `CascaderItem`\n * hold while the user types. Destructured off `loader` so the memo depends\n * on its `[]`-dep callbacks, not the object it republishes per load. */\n const { active: hasLoader, loadMore, retryLevel, retrySearch, prefetchNode } = loader;\n\n const actionsValue = React.useMemo<CascaderActionsContextValue<T>>(\n () => ({\n index,\n mode,\n multiple,\n cascade,\n branchesSelectable,\n indicator,\n expandTrigger,\n actions: resolvedActions,\n searchScope,\n maxHeight,\n inline: !!inline,\n invalid: !!invalid,\n baseId,\n labels,\n virtualized,\n registerVirtualRenderer,\n virtualize,\n virtualizeThreshold,\n estimateRowSize,\n overscan,\n hasLoader,\n loadMore,\n retryLevel,\n retrySearch,\n invalidateLevel,\n getIndex,\n getState,\n getHighlighted,\n setPath,\n pushLevel,\n popLevel,\n goToDepth,\n toggleExpanded,\n setFlyoutOpen,\n hasOpenFlyout,\n setQuery,\n setSelection,\n commit,\n navigate,\n navigateAt,\n resolveNode,\n isBranch,\n isSelectable,\n isDisabled,\n isSelected,\n isIndeterminate,\n selectedDescendantCount,\n }),\n [\n index,\n mode,\n multiple,\n cascade,\n branchesSelectable,\n indicator,\n expandTrigger,\n resolvedActions,\n searchScope,\n maxHeight,\n inline,\n invalid,\n baseId,\n labels,\n virtualized,\n registerVirtualRenderer,\n virtualize,\n virtualizeThreshold,\n estimateRowSize,\n overscan,\n hasLoader,\n loadMore,\n retryLevel,\n retrySearch,\n invalidateLevel,\n getIndex,\n getState,\n getHighlighted,\n setPath,\n pushLevel,\n popLevel,\n goToDepth,\n toggleExpanded,\n setFlyoutOpen,\n hasOpenFlyout,\n setQuery,\n setSelection,\n commit,\n navigate,\n navigateAt,\n resolveNode,\n isBranch,\n isSelectable,\n isDisabled,\n isSelected,\n isIndeterminate,\n selectedDescendantCount,\n ],\n );\n\n // A fresh array identity each time windowing turns on, and once more after:\n // that identity is the ONLY thing that re-runs Base UI's `listRef` sizing\n // effect. See `virtualSyncs`.\n const comboboxItems = React.useMemo(\n () => (virtualized ? renderedItems.slice() : renderedItems),\n [renderedItems, virtualized],\n );\n\n const comboboxValue = React.useMemo(() => {\n if (multiple) return selectedValues.map(resolveNode);\n return selectedValues.length ? resolveNode(selectedValues[0]) : null;\n }, [multiple, selectedValues, resolveNode]);\n\n return (\n // Providers store values with the item generic erased; the hooks re-apply\n // the caller's own `T` on the way back out.\n <CascaderActionsContext.Provider value={actionsValue as unknown as CascaderActionsContextValue}>\n <CascaderStateContext.Provider value={stateValue as unknown as CascaderStateContextValue}>\n <CascaderHighlightContext.Provider value={highlightStore}>\n <CascaderRenderContext.Provider\n value={renderContext as unknown as CascaderRenderContextValue}\n >\n <ComboboxPrimitive.Root\n items={renderedItems}\n /* The empty frame that resets the highlight. See the comment above. */\n filteredItems={swapping ? EMPTY : comboboxItems}\n /* Filtering is ours: the level, deep and global scopes cannot\n be expressed through Base UI's single matcher. */\n filter={null}\n value={comboboxValue}\n onValueChange={handleComboboxValueChange}\n open={open}\n onOpenChange={handleOpenChange}\n inputValue={query}\n onInputValueChange={(next: string) => setQuery(next)}\n multiple={multiple}\n disabled={disabled}\n /* Form wiring, straight to Base UI's hidden input. Conditional\n spreads: an explicit `undefined` on a controlled prop reads as\n \"deleted\" rather than \"not supplied\". */\n name={name}\n {...(form != null ? { form } : null)}\n {...(id != null ? { id } : null)}\n {...(required != null ? { required } : null)}\n {...(readOnly != null ? { readOnly } : null)}\n {...(inputRef ? { inputRef } : null)}\n inline={inline}\n /* Stops Base UI rendering its composite list, which is what makes\n an explicit row `index` legal. `items`/`filteredItems` stay full:\n they size `listRef`, or ArrowDown stops at the last RENDERED row. */\n virtualized={virtualized}\n itemToStringValue={(item: CascaderNode<T>) => item?.value ?? \"\"}\n itemToStringLabel={(item: CascaderNode<T>) => item?.label ?? \"\"}\n isItemEqualToValue={(a: CascaderNode<T>, b: CascaderNode<T>) => a?.value === b?.value}\n // Fires on every arrow key AND every pointer move, so it must\n // never call setState. The ref serves keyboard handlers, the\n // de-duping store anything that has to re-render.\n onItemHighlighted={(\n item: CascaderNode<T> | undefined,\n details: ComboboxPrimitive.Root.HighlightEventDetails,\n ) => {\n highlightedRef.current = item ?? null;\n highlightStore.set({\n index: details.index,\n value: item?.value ?? null,\n });\n // Schedules a TIMEOUT and returns: inside a layout effect, a\n // synchronous setState would cascade before paint.\n prefetchNode(item);\n }}\n >\n {children}\n </ComboboxPrimitive.Root>\n </CascaderRenderContext.Provider>\n </CascaderHighlightContext.Provider>\n </CascaderStateContext.Provider>\n </CascaderActionsContext.Provider>\n );\n}\n\n/* -------------------------------------------------------------------------- */\n/* Trigger */\n/* -------------------------------------------------------------------------- */\n\n/** `Trigger.Props` stops short of `ref`, so it is intersected in, as the\n * shadcn combobox wrapper also does: a form library needs a ref here, and\n * `onBlur`, the \"touched\" signal, lands here too. */\nexport interface CascaderTriggerProps\n extends ComboboxPrimitive.Trigger.Props,\n Pick<React.ComponentPropsWithRef<\"button\">, \"ref\"> {\n /** Hides the trailing chevron, for a trigger that supplies its own. */\n showIcon?: boolean;\n}\n\nfunction CascaderTrigger({\n className,\n children,\n showIcon = true,\n ref,\n ...props\n}: CascaderTriggerProps) {\n const { invalid } = useCascaderActions();\n\n // `ref` is the one prop `mergeProps` does not merge, so chain it by hand.\n const triggerRef = React.useRef<HTMLButtonElement | null>(null);\n const setTrigger = React.useCallback(\n (node: HTMLButtonElement | null) => {\n triggerRef.current = node;\n if (typeof ref === \"function\") ref(node);\n else if (ref) ref.current = node;\n },\n [ref],\n );\n\n /** 18 of 19 audited examples shipped an unnamed combobox: the trigger's\n * contents are the field's VALUE, so a screen reader never hears its NAME.\n * Checked in the DOM, since the name may arrive as a `<label for>`. */\n React.useEffect(() => {\n if (process.env.NODE_ENV === \"production\") return;\n const element = triggerRef.current;\n if (!element) return;\n const named =\n element.hasAttribute(\"aria-label\") ||\n element.hasAttribute(\"aria-labelledby\") ||\n element.closest(\"label\") !== null ||\n (element.id !== \"\" &&\n element.ownerDocument.querySelector(`label[for=\"${CSS.escape(element.id)}\"]`) !== null);\n if (named) return;\n warnCascaderOnce(\n \"trigger-unnamed\",\n \"`CascaderTrigger` has no accessible name. Its contents are the field's VALUE - they change with the selection - so a screen reader hears what is picked but never what the field is for. Pass `aria-label` or `aria-labelledby`, or reference the trigger's `id` from a `<label>`.\",\n );\n });\n\n return (\n <ComboboxPrimitive.Trigger\n ref={setTrigger}\n data-slot=\"cascader-trigger\"\n /* Conditional spread: an explicit `undefined` would DELETE whatever a\n `Field` wrapper had already put here. */\n {...(invalid ? { \"aria-invalid\": true, \"data-invalid\": \"\" } : null)}\n className={cn(TRIGGER_ICON_FALLBACK_CLASS, className)}\n {...props}\n >\n {children}\n {showIcon ? (\n <ChevronDownIcon className={`${TRIGGER_ICON_CLASS} pointer-events-none shrink-0`} />\n ) : null}\n </ComboboxPrimitive.Trigger>\n );\n}\n\n/* -------------------------------------------------------------------------- */\n/* Resolved theme */\n/* -------------------------------------------------------------------------- */\n\n/* The eight registry styles each state a combobox surface differently, so the\n * classes below spell every one out with `style-<name>:` variants. Nothing\n * depends on ReUI's theme CSS; `build-registry` flattens one in on install. */\n\n/** Icon size for a combobox surface: 14px in mira and sera, 16px elsewhere. */\nconst TRIGGER_ICON_CLASS = \"text-muted-foreground size-4\";\n\n/** The same ladder, applied only to trigger children that carry no size. */\nconst TRIGGER_ICON_FALLBACK_CLASS = \"[&_svg:not([class*='size-'])]:size-4\";\n\n/** The chips field: a form-control surface, so it carries the invalid states. */\nconst CHIPS_CLASS =\n \"flex flex-wrap items-center border bg-clip-padding dark:bg-input/30 border-input focus-within:border-ring focus-within:ring-ring/50 has-aria-invalid:ring-destructive/20 dark:has-aria-invalid:ring-destructive/40 has-aria-invalid:border-destructive dark:has-aria-invalid:border-destructive/50 bg-transparent px-2.5 text-sm focus-within:ring-3 has-aria-invalid:ring-3 min-h-8 gap-1 rounded-lg py-1 transition-colors has-data-[slot=combobox-chip]:px-1\";\n\nconst CHIP_CLASS =\n \"text-foreground flex w-fit items-center justify-center gap-1 font-medium whitespace-nowrap bg-muted rounded-sm px-1.5 text-xs has-data-[slot=combobox-chip-remove]:pr-0 h-[calc(--spacing(5.25))]\";\n\nconst CHIP_REMOVE_CLASS = \"opacity-50 hover:opacity-100 -ml-1\";\n\n/** The floating panel's surface. The shared popup's `InputGroup` sizing is\n * left out (mirrored in `cascader-nav.tsx`), as are its `max-h-72` and\n * `min-w-*`: `CascaderContent` sets both from the positioner's variables. */\nconst CONTENT_SURFACE_CLASS =\n \"bg-popover text-popover-foreground data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 overflow-hidden ring-1 duration-100 ring-foreground/10 shadow-md rounded-lg data-[side=inline-start]:slide-in-from-right-2 data-[side=inline-end]:slide-in-from-left-2\";\n\nconst EMPTY_CLASS =\n \"text-muted-foreground hidden w-full justify-center py-2 text-center group-data-empty/combobox-content:flex text-sm\";\n\n/* -------------------------------------------------------------------------- */\n/* Chips */\n/* -------------------------------------------------------------------------- */\n\n/** Ref for the chips container: they replace the trigger, so the popup has to\n * be anchored to them. Hand it to `CascaderContent`'s `anchor`. */\nexport function useCascaderAnchor() {\n return React.useRef<HTMLDivElement | null>(null);\n}\n\nexport interface CascaderChipsProps\n extends Omit<ComboboxPrimitive.Chips.Props, \"children\">,\n Pick<React.ComponentPropsWithRef<\"div\">, \"ref\"> {\n /** Shown in place of the chips when nothing is selected. */\n placeholder?: React.ReactNode;\n /**\n * How a `cascade` selection is condensed into chips. DISPLAY ONLY: the\n * stored value stays the full closure, which keeps a row's checked state an\n * O(1) lookup. `\"all\"` (default) is one chip per value, `\"parent\"` collapses\n * a fully selected branch, `\"child\"` chips only the deepest frontier.\n * Removing a condensed chip removes its whole closure and reconciles.\n */\n strategy?: CascaderCheckedStrategy;\n /** Replaces the chip list, receiving the resolved selection IN SELECTION\n * ORDER. Keep that order: Base UI removes a chip by sibling position. */\n children?: React.ReactNode | ((nodes: CascaderNode[]) => React.ReactNode);\n}\n\n/**\n * The multi-select trigger surface: one removable chip per selection, where\n * `CascaderValue` would collapse to \"3 selected\". A component rather than a\n * recipe because of three easy misses: the popup anchored to the chips, an\n * accessible name on every remove button, and labels that disambiguate when\n * two branches use the same one.\n *\n * ```tsx\n * const anchor = useCascaderAnchor()\n * <Cascader multiple items={items}>\n * <CascaderChips ref={anchor} placeholder=\"Select attributes\" />\n * <CascaderContent anchor={anchor}>...</CascaderContent>\n * </Cascader>\n * ```\n */\nfunction CascaderChips({\n className,\n children,\n placeholder,\n strategy = \"all\",\n ...props\n}: CascaderChipsProps) {\n const { labels, multiple, invalid, resolveNode, index, isSelectable, setSelection } =\n useCascaderActions();\n const { selectedValues } = useCascaderState();\n\n React.useEffect(() => {\n if (process.env.NODE_ENV === \"production\") return;\n if (multiple) return;\n warnCascaderOnce(\n \"chips-without-multiple\",\n \"`CascaderChips` renders one chip per selection and there is only ever one without `multiple`. Use `CascaderValue` for a single-select trigger.\",\n );\n }, [multiple]);\n\n // DERIVED display: the selection stays the full closure, the chips condense.\n const displayedValues =\n strategy === \"all\" ? selectedValues : getCascaderCheckedValues(index, selectedValues, strategy);\n\n // Not memoised: one entry per SELECTION, not per row, so the pass is short.\n const nodes = displayedValues.map(resolveNode);\n const ambiguous = findAmbiguousCascaderLabels(nodes);\n\n // Removal for a CONDENSED chip: Base UI's `ChipRemove` maps a press onto the\n // STORED array, which is wrong once the chips are fewer, so this removes the\n // chip's whole subtree closure instead.\n const removeClosure = (node: CascaderNode) => {\n setSelection(\n applyCascadeSelection(index, selectedValues, node.value, false, isSelectable),\n \"deselect\",\n );\n };\n\n const content = typeof children === \"function\" ? children(nodes) : children;\n\n return (\n <ComboboxPrimitive.Chips\n data-slot=\"cascader-chips\"\n /* An unnamed `role=\"toolbar\"` announces as just \"toolbar\". */\n aria-label={labels.chipsLabel}\n /* Conditional spread: the error treatment is keyed on\n `has-aria-invalid:`, so the attribute must be absent, not empty. */\n {...(invalid ? { \"aria-invalid\": true, \"data-invalid\": \"\" } : null)}\n className={cn(CHIPS_CLASS, className)}\n {...props}\n >\n {content ??\n (nodes.length === 0 ? (\n <span data-slot=\"cascader-chips-placeholder\" className=\"truncate text-muted-foreground\">\n {placeholder}\n </span>\n ) : (\n nodes.map((node) => (\n <CascaderChip\n key={node.value}\n node={node}\n showPath={ambiguous.has(node.value)}\n /* Only a condensed chip needs the remover; the default shape\n keeps Base UI's positional removal. */\n {...(strategy !== \"all\" ? { onRemove: () => removeClosure(node) } : null)}\n />\n ))\n ))}\n </ComboboxPrimitive.Chips>\n );\n}\n\nexport interface CascaderChipProps extends Omit<ComboboxPrimitive.Chip.Props, \"children\"> {\n node: CascaderNode;\n /** Prefix the label with its ancestor trail. */\n showPath?: boolean;\n /** Trail segments to show, the node itself included. */\n maxSegments?: number;\n /** Hides the remove button, for a read-only chip. */\n showRemove?: boolean;\n /** Replaces Base UI's positional removal for this chip (remove button and\n * Backspace/Delete). Supplied for a `strategy`-condensed chip, whose\n * position no longer maps onto the stored array. */\n onRemove?: () => void;\n /** Replaces the chip's label. The remove button is still rendered. */\n children?: React.ReactNode;\n}\n\n/** Base UI hands its chip handlers events carrying the veto hook. */\ntype CascaderChipKeyEvent = Parameters<NonNullable<ComboboxPrimitive.Chip.Props[\"onKeyDown\"]>>[0];\n\ntype CascaderChipRemoveClickEvent = Parameters<\n NonNullable<ComboboxPrimitive.ChipRemove.Props[\"onClick\"]>\n>[0];\n\n/** One chip. Removal goes through Base UI's `ChipRemove`, which reports the\n * shortened selection to the root, so it lands in the same `setSelection` as\n * every other deselection and `cascade` applies to it. */\nfunction CascaderChip({\n className,\n node,\n showPath = false,\n maxSegments = 2,\n showRemove = true,\n onRemove,\n children,\n ...props\n}: CascaderChipProps) {\n const { labels, index } = useCascaderActions();\n\n const chain = showPath ? getCascaderPath(index, node.value) : [];\n const segments = collapseCascaderPath(chain, {\n maxSegments,\n collapse: \"start\",\n });\n\n const label = segments.length\n ? segments\n .map((segment) => (segment.type === \"node\" ? segment.node.label : \"…\"))\n .join(` ${labels.pathSeparator} `)\n : node.label;\n\n return (\n <ComboboxPrimitive.Chip\n data-slot=\"cascader-chip\"\n /* Keyboard half of `onRemove`: Base UI's chip removes ITSELF by position\n on Backspace/Delete, the arithmetic a condensed chip must not use. The\n veto runs first, so the closure removal replaces it. */\n {...(onRemove\n ? {\n onKeyDown: (event: CascaderChipKeyEvent) => {\n if (event.key !== \"Backspace\" && event.key !== \"Delete\") return;\n event.preventBaseUIHandler();\n onRemove();\n },\n }\n : null)}\n className={cn(\n CHIP_CLASS,\n \"has-disabled:pointer-events-none has-disabled:cursor-not-allowed has-disabled:opacity-50\",\n className,\n )}\n {...props}\n >\n {children ?? <span className=\"truncate\">{label}</span>}\n {showRemove ? (\n <ComboboxPrimitive.ChipRemove\n data-slot=\"cascader-chip-remove\"\n /* Named after what the chip DISPLAYS, not the bare node label, or\n two disambiguated chips both announce \"Remove Created at\". */\n aria-label={labels.removeChip(label)}\n /* The pointer half of `onRemove`, same veto, same reason. */\n {...(onRemove\n ? {\n onClick: (event: CascaderChipRemoveClickEvent) => {\n event.preventBaseUIHandler();\n onRemove();\n },\n }\n : null)}\n className={CHIP_REMOVE_CLASS}\n >\n <XIcon className=\"pointer-events-none\" />\n </ComboboxPrimitive.ChipRemove>\n ) : null}\n </ComboboxPrimitive.Chip>\n );\n}\n\n/* -------------------------------------------------------------------------- */\n/* Content */\n/* -------------------------------------------------------------------------- */\n\nexport interface CascaderContentProps\n extends ComboboxPrimitive.Popup.Props,\n /** Positioner surface forwarded as-is, so an unusual anchor does not force\n * a rebuild of the content stack. No `trackAnchor`: Base UI 1.5.0 has\n * none. */\n Pick<\n ComboboxPrimitive.Positioner.Props,\n | \"side\"\n | \"align\"\n | \"sideOffset\"\n | \"alignOffset\"\n | \"anchor\"\n | \"collisionBoundary\"\n | \"collisionPadding\"\n | \"sticky\"\n | \"positionMethod\"\n >,\n /** Where the portal mounts, for a shadow root or a scoped stacking context. */\n Pick<ComboboxPrimitive.Portal.Props, \"container\"> {}\n\n/** Portal + Positioner + floating panel. Unlike shadcn's `ComboboxContent` it\n * does NOT clamp the popup to the anchor width (a cascader panel is routinely\n * wider), but it keeps `group/combobox-content`, which `CascaderEmpty` needs. */\nfunction CascaderContent({\n className,\n side = \"bottom\",\n sideOffset = 6,\n align = \"start\",\n alignOffset = 0,\n anchor,\n collisionBoundary,\n collisionPadding,\n sticky,\n positionMethod,\n container,\n ref,\n ...props\n}: CascaderContentProps) {\n const { labels } = useCascaderActions();\n const popupRef = React.useRef<HTMLDivElement | null>(null);\n\n // `initialFocus` needs the popup element, and `ref` is the one prop\n // `mergeProps` does NOT merge, so it is chained by hand rather than spread.\n const setPopup = React.useCallback(\n (node: HTMLDivElement | null) => {\n popupRef.current = node;\n if (typeof ref === \"function\") ref(node);\n else if (ref) ref.current = node;\n },\n [ref],\n );\n\n /**\n * Focus goes to the search field, where the level keys and\n * `aria-activedescendant` live. Base UI's own default agrees but is COMPUTED\n * FROM THE FIRST RENDER, when the field has not mounted, and collapses to\n * \"do not move focus\": measured, a KEYBOARD open left focus on the trigger\n * and cost two Tabs to reach the footer where a pointer open cost one.\n *\n * `initialFocus` rather than an effect, because anything scheduled alongside\n * Base UI's focus manager is a race; the field is resolved INSIDE the\n * callback, which runs after the layout effects. Touch is handed back to\n * Base UI on purpose - focusing the popup keeps the Android keyboard shut.\n */\n const initialFocus = React.useCallback((openType: string) => {\n const popup = popupRef.current;\n if (!popup) return true;\n if (openType === \"touch\") return popup;\n return popup.querySelector<HTMLElement>('[data-slot=\"cascader-input\"]') ?? true;\n }, []);\n\n return (\n // Conditional spreads throughout: `mergeProps` iterates own keys, so an\n // explicit `undefined` reads as \"deleted\" rather than \"not supplied\".\n <ComboboxPrimitive.Portal {...(container !== undefined ? { container } : null)}>\n <ComboboxPrimitive.Positioner\n side={side}\n sideOffset={sideOffset}\n align={align}\n alignOffset={alignOffset}\n anchor={anchor}\n {...(collisionBoundary !== undefined ? { collisionBoundary } : null)}\n {...(collisionPadding !== undefined ? { collisionPadding } : null)}\n {...(sticky !== undefined ? { sticky } : null)}\n {...(positionMethod !== undefined ? { positionMethod } : null)}\n className=\"isolate z-50\"\n >\n <ComboboxPrimitive.Popup\n ref={setPopup}\n data-slot=\"cascader-content\"\n /* Marks a menu surface for the docs design-system picker. An\n attribute, not a class, so the panel's look stays self-contained. */\n data-menu-target=\"\"\n /* The input inside makes this a `role=\"dialog\"`, unnamed by default. */\n aria-label={labels.panelLabel}\n initialFocus={initialFocus}\n className={cn(\n CONTENT_SURFACE_CLASS,\n \"group/combobox-content relative flex max-h-(--available-height) min-w-(--anchor-width) max-w-(--available-width) origin-(--transform-origin) flex-col\",\n className,\n )}\n {...props}\n />\n </ComboboxPrimitive.Positioner>\n </ComboboxPrimitive.Portal>\n );\n}\n\n/* -------------------------------------------------------------------------- */\n/* Panel */\n/* -------------------------------------------------------------------------- */\n\nexport type CascaderPanelProps = useRender.ComponentProps<\"div\">;\n\n/**\n * The nav + list(s) + footer container, with no positioning of its own: inside\n * `CascaderContent` for the popup case, alone for the embedded one.\n *\n * `min-h-0` and `max-h-full` are load-bearing. A flex child without `min-h-0`\n * refuses to shrink below its content, which is the usual reason a scroll area\n * never scrolls - worst embedded, where no positioner publishes\n * `--available-height`. It also owns the panel's TAB ORDER: the scroll area\n * makes itself a tab stop whenever the level overflows, stranding the footer,\n * and the panel is the only ancestor of both ends of that move in BOTH shapes.\n */\nfunction CascaderPanel({ className, ...props }: CascaderPanelProps) {\n const { mode } = useCascaderActions();\n\n const handleKeyDown = React.useCallback((event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.key !== \"Tab\" || event.defaultPrevented) return;\n // A browser-level move (Ctrl+Tab switches tabs) is never ours.\n if (event.altKey || event.ctrlKey || event.metaKey) return;\n\n const panel = event.currentTarget;\n const target = event.target as HTMLElement | null;\n if (!target || !panel.contains(target)) return;\n\n const next = getCascaderTabTarget(panel, target, event.shiftKey);\n // Off either end: left to the browser, since focus is never trapped.\n if (!next) return;\n\n event.preventDefault();\n next.focus();\n }, []);\n\n const defaultProps = {\n \"data-slot\": \"cascader-panel\",\n \"data-mode\": mode,\n // In `defaultProps`, not around `props.onKeyDown`: `mergeProps` chains\n // right to left, so a consumer's handler runs FIRST and can drop this one.\n onKeyDown: handleKeyDown,\n className: cn(\"flex max-h-full min-h-0 w-full flex-col\", className),\n };\n\n return useRender({\n defaultTagName: \"div\",\n render: props.render,\n props: mergeProps<\"div\">(defaultProps, props),\n });\n}\n\n/* -------------------------------------------------------------------------- */\n/* List */\n/* -------------------------------------------------------------------------- */\n\nexport interface CascaderListProps extends Omit<ComboboxPrimitive.List.Props, \"style\"> {\n /** Applied to the OUTER shell, which owns the height, so an inline\n * `--cascader-max-height` lands where the bound can read it. Narrowed from\n * Base UI's `style`: the shell is a plain `<div>` with no list state. */\n style?: React.CSSProperties;\n /** Caps this level's height; the panel still shrinks to fit. Default 24rem. */\n maxHeight?: number | string;\n}\n\n/**\n * Scroll container for one level: pattern 3 of the house scroll reference,\n * viewport-bounded popup scroll. The height is `min()` of `--available-height`\n * (the positioner's space between anchor and viewport edge) and `maxHeight`,\n * so neither can be ignored; a fixed pixel cap alone still reserved 288px for\n * a panel opened 200px above the fold and spilled off screen, and wasted room\n * in a tall window. The four classes are shared with `CascaderColumns` and\n * live in `cascader-lib.tsx`.\n */\nfunction CascaderList({ className, style, maxHeight: maxHeightProp, ...props }: CascaderListProps) {\n const { maxHeight, mode, labels, baseId, virtualized, searchScope } = useCascaderActions();\n const { currentParent, deepResults } = useCascaderState();\n const resolved = maxHeightProp ?? maxHeight;\n // Global hits come from the whole tree, so the parent would understate them.\n const listName =\n searchScope === \"global\" && deepResults\n ? labels.rootLevel\n : (currentParent?.label ?? labels.rootLevel);\n\n return (\n <div\n data-slot=\"cascader-list-shell\"\n style={\n resolved != null\n ? ({\n ...style,\n \"--cascader-max-height\": typeof resolved === \"number\" ? `${resolved}px` : resolved,\n } as React.CSSProperties)\n : style\n }\n className={cn(\"relative flex max-h-full min-h-0\", CASCADER_LIST_PAD_CLASS)}\n >\n <div\n data-slot=\"cascader-list-bounds\"\n className={cn(\n \"flex w-full min-w-0 flex-col overscroll-contain\",\n CASCADER_LIST_HEIGHT_CLASS,\n )}\n >\n <ScrollArea className={CASCADER_SCROLL_CLASS}>\n <ComboboxPrimitive.List\n data-slot=\"cascader-list\"\n /* Base UI names the list nothing, so every mode shipped an unnamed\n listbox. The level's parent is the name; the root borrows one. */\n aria-label={listName}\n /* Replaces Base UI's floating id. `aria-controls` reads the live\n id, so the columns trail gets a predictable target. */\n id={`${baseId}-column-0`}\n /* NEVER a ternary ending in `undefined`: `mergeProps` iterates own\n keys, so that DELETES Base UI's `role=\"listbox\"`. */\n {...(mode === \"tree\" ? { role: \"tree\" as const } : null)}\n {...(virtualized ? { \"data-virtualized\": true } : null)}\n className={cn(\n CASCADER_ROWS_CLASS,\n /* A windowed row is absolutely positioned, so the ROWS' box is\n the containing block, not the scrollport: it carries the\n padding the geometry is measured against. */\n virtualized && \"relative\",\n className,\n )}\n {...props}\n />\n </ScrollArea>\n </div>\n </div>\n );\n}\n\n/* -------------------------------------------------------------------------- */\n/* Empty / Loading */\n/* -------------------------------------------------------------------------- */\n\nexport interface CascaderEmptyProps extends ComboboxPrimitive.Empty.Props {\n /** @deprecated Ignored: the loading surface no longer draws skeletons. They\n * promised a shape the level might not have and cost a second layout; the\n * progress lives on the branch row instead. Kept so call sites compile. */\n skeletonRows?: number;\n}\n\n/** The empty, loading and error surface, in ONE element that never unmounts.\n * `Combobox.Empty` renders whenever `filteredItems.length === 0`, as true of a\n * fetching level as of an empty one, so swapping siblings would announce \"No\n * results found.\" over every async level. Swap the CHILDREN. */\nfunction CascaderEmpty({\n className,\n children,\n // Accepted and ignored; destructured so it is never spread onto the DOM.\n skeletonRows,\n ...props\n}: CascaderEmptyProps) {\n const { labels, retryLevel, retrySearch } = useCascaderActions();\n const { query, path, searchState } = useCascaderState();\n // The level whose emptiness is on screen; tree always shows the root.\n const levelKey = path.length ? path[path.length - 1] : CASCADER_ROOT_KEY;\n const loadState = useCascaderLoadState(levelKey);\n const state = query.trim() ? (searchState ?? loadState) : loadState;\n\n let body: React.ReactNode = children ?? labels.empty;\n\n if (state?.error) {\n body = (\n <span data-slot=\"cascader-error\" className=\"flex flex-col items-center gap-1.5\">\n <span>{labels.error}</span>\n <button\n type=\"button\"\n data-slot=\"cascader-retry\"\n /* A real button because this lives OUTSIDE the listbox; a focusable\n element inside a `role=\"option\"` is `nested-interactive`. */\n onClick={(event) => {\n focusCascaderHome(event.currentTarget);\n // With a query set the error shown is the SEARCH's, so that is\n // what to ask again; the level behind it never failed.\n if (query.trim() && searchState?.error) retrySearch();\n else retryLevel(levelKey);\n }}\n className=\"rounded-md px-2 py-0.5 font-medium text-foreground outline-hidden transition-colors hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring/50\"\n >\n {labels.retry}\n </button>\n </span>\n );\n } else if (state?.loading) {\n body = (\n <span data-slot=\"cascader-loading\" className=\"flex w-full items-center justify-center\">\n {labels.loading}\n </span>\n );\n }\n\n return (\n <ComboboxPrimitive.Empty\n data-slot=\"cascader-empty\"\n data-state={state?.error ? \"error\" : state?.loading ? \"loading\" : \"empty\"}\n className={cn(EMPTY_CLASS, className)}\n // biome-ignore lint/a11y/useValidAriaValues: <>\n aria-live={undefined}\n // biome-ignore lint/a11y/useValidAriaValues: <>\n aria-atomic={undefined}\n {...props}\n >\n {body}\n </ComboboxPrimitive.Empty>\n );\n}\n\nexport type CascaderStatusProps = ComboboxPrimitive.Status.Props;\n\n/**\n * Polite live region for the current level and result count, which drill-down\n * otherwise hides in a visual breadcrumb. Built on `Combobox.Status` for its\n * initial-mutation marker: Safari and VoiceOver need a text change ~200ms\n * after mount before reading a polite region at all.\n */\nfunction CascaderStatus({ className, children, ...props }: CascaderStatusProps) {\n const { announcement } = useCascaderState();\n\n return (\n <ComboboxPrimitive.Status\n data-slot=\"cascader-status\"\n className={cn(\"sr-only\", className)}\n {...props}\n >\n {children ?? announcement}\n </ComboboxPrimitive.Status>\n );\n}\n\nexport type {\n CascaderActionsContextValue,\n CascaderColumn,\n CascaderHighlight,\n CascaderHighlightStore,\n CascaderItemState,\n CascaderRenderContextValue,\n CascaderStateContextValue,\n};\n/** Re-exported from `cascader-context.tsx`: existing import paths keep\n * working, and the row component avoids an import cycle through this file. */\nexport {\n Cascader,\n CascaderChip,\n CascaderChips,\n CascaderContent,\n CascaderEmpty,\n CascaderList,\n CascaderPanel,\n CascaderStatus,\n CascaderTrigger,\n createCascaderHighlightStore,\n useCascaderActions,\n useCascaderHighlight,\n useCascaderRender,\n useCascaderState,\n};\n"],"mappings":";;;;;;;;;;;;;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C,CAC1B,MAAM,GAAG,EAAE,CAAC,CACZ,KAAK,SAAS,KAAK,KAAK,IAC3B,CAAC,GACL,QACF;EAEJ;CACF,GACA;EAAC;EAAS;EAAU;EAAgB;EAAO;EAAO;EAAM;EAAmB;CAAa,CAC1F;CAMA,MAAM,gBAAgBA,QAAM,eACnB;EAAE;EAAY;CAAY,IACjC,CAAC,YAAY,WAAW,CAC1B;;;;;CAMA,MAAM,EAAE,QAAQ,WAAW,UAAU,YAAY,aAAa,iBAAiB;CAE/E,MAAM,eAAeA,QAAM,eAClB;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA,SAAS;EACT;EACA;EACA,QAAQ,CAAC,CAAC;EACV,SAAS,CAAC,CAAC;EACX;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,IACA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CACF;CAKA,MAAM,gBAAgBA,QAAM,cACnB,cAAc,cAAc,MAAM,IAAI,eAC7C,CAAC,eAAe,WAAW,CAC7B;CAEA,MAAM,gBAAgBA,QAAM,cAAc;EACxC,IAAI,UAAU,OAAO,eAAe,IAAI,WAAW;EACnD,OAAO,eAAe,SAAS,YAAY,eAAe,EAAE,IAAI;CAClE,GAAG;EAAC;EAAU;EAAgB;CAAW,CAAC;CAE1C,OAGE,oBAAC,uBAAuB,UAAxB;EAAiC,OAAO;EACtC,UAAA,oBAAC,qBAAqB,UAAtB;GAA+B,OAAO;GACpC,UAAA,oBAA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