@kumix/ui 0.3.7 → 0.3.8

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.
Files changed (173) hide show
  1. package/README.md +25 -24
  2. package/dist/cascader-types-BnH6wYD-.d.ts +183 -0
  3. package/dist/cascader-types-BnH6wYD-.d.ts.map +1 -0
  4. package/dist/components/motion/animated-sidebar.d.ts.map +1 -1
  5. package/dist/components/motion/animated-sidebar.js +12 -3
  6. package/dist/components/motion/animated-sidebar.js.map +1 -1
  7. package/dist/components/motion/attachment-upload.d.ts.map +1 -1
  8. package/dist/components/motion/attachment-upload.js +9 -5
  9. package/dist/components/motion/attachment-upload.js.map +1 -1
  10. package/dist/components/motion/bottom-sheet.d.ts.map +1 -1
  11. package/dist/components/motion/bottom-sheet.js +77 -74
  12. package/dist/components/motion/bottom-sheet.js.map +1 -1
  13. package/dist/components/motion/center-morph-modal.d.ts.map +1 -1
  14. package/dist/components/motion/center-morph-modal.js +82 -88
  15. package/dist/components/motion/center-morph-modal.js.map +1 -1
  16. package/dist/components/motion/command-palette.d.ts.map +1 -1
  17. package/dist/components/motion/command-palette.js +48 -26
  18. package/dist/components/motion/command-palette.js.map +1 -1
  19. package/dist/components/motion/drawer.d.ts.map +1 -1
  20. package/dist/components/motion/drawer.js +30 -30
  21. package/dist/components/motion/drawer.js.map +1 -1
  22. package/dist/components/motion/loader.js +20 -22
  23. package/dist/components/motion/loader.js.map +1 -1
  24. package/dist/components/motion/morphing-modal.d.ts.map +1 -1
  25. package/dist/components/motion/morphing-modal.js +83 -83
  26. package/dist/components/motion/morphing-modal.js.map +1 -1
  27. package/dist/components/motion/morphing-search.d.ts +28 -0
  28. package/dist/components/motion/morphing-search.d.ts.map +1 -0
  29. package/dist/components/motion/morphing-search.js +418 -0
  30. package/dist/components/motion/morphing-search.js.map +1 -0
  31. package/dist/components/motion/project-folder.js +20 -20
  32. package/dist/components/motion/project-folder.js.map +1 -1
  33. package/dist/components/reui/badge.d.ts +1 -1
  34. package/dist/components/reui/cascader/cascader-async.d.ts +90 -0
  35. package/dist/components/reui/cascader/cascader-async.d.ts.map +1 -0
  36. package/dist/components/reui/cascader/cascader-async.js +549 -0
  37. package/dist/components/reui/cascader/cascader-async.js.map +1 -0
  38. package/dist/components/reui/cascader/cascader-columns.d.ts +29 -0
  39. package/dist/components/reui/cascader/cascader-columns.d.ts.map +1 -0
  40. package/dist/components/reui/cascader/cascader-columns.js +135 -0
  41. package/dist/components/reui/cascader/cascader-columns.js.map +1 -0
  42. package/dist/components/reui/cascader/cascader-context.d.ts +193 -0
  43. package/dist/components/reui/cascader/cascader-context.d.ts.map +1 -0
  44. package/dist/components/reui/cascader/cascader-context.js +59 -0
  45. package/dist/components/reui/cascader/cascader-context.js.map +1 -0
  46. package/dist/components/reui/cascader/cascader-footer.d.ts +85 -0
  47. package/dist/components/reui/cascader/cascader-footer.d.ts.map +1 -0
  48. package/dist/components/reui/cascader/cascader-footer.js +456 -0
  49. package/dist/components/reui/cascader/cascader-footer.js.map +1 -0
  50. package/dist/components/reui/cascader/cascader-i18n.d.ts +17 -0
  51. package/dist/components/reui/cascader/cascader-i18n.d.ts.map +1 -0
  52. package/dist/components/reui/cascader/cascader-i18n.js +68 -0
  53. package/dist/components/reui/cascader/cascader-i18n.js.map +1 -0
  54. package/dist/components/reui/cascader/cascader-item.d.ts +115 -0
  55. package/dist/components/reui/cascader/cascader-item.d.ts.map +1 -0
  56. package/dist/components/reui/cascader/cascader-item.js +530 -0
  57. package/dist/components/reui/cascader/cascader-item.js.map +1 -0
  58. package/dist/components/reui/cascader/cascader-lib.d.ts +141 -0
  59. package/dist/components/reui/cascader/cascader-lib.d.ts.map +1 -0
  60. package/dist/components/reui/cascader/cascader-lib.js +576 -0
  61. package/dist/components/reui/cascader/cascader-lib.js.map +1 -0
  62. package/dist/components/reui/cascader/cascader-nav.d.ts +59 -0
  63. package/dist/components/reui/cascader/cascader-nav.d.ts.map +1 -0
  64. package/dist/components/reui/cascader/cascader-nav.js +312 -0
  65. package/dist/components/reui/cascader/cascader-nav.js.map +1 -0
  66. package/dist/components/reui/cascader/cascader-types.d.ts +2 -0
  67. package/dist/components/reui/cascader/cascader-types.js +2 -0
  68. package/dist/components/reui/cascader/cascader-virtual.d.ts +65 -0
  69. package/dist/components/reui/cascader/cascader-virtual.d.ts.map +1 -0
  70. package/dist/components/reui/cascader/cascader-virtual.js +240 -0
  71. package/dist/components/reui/cascader/cascader-virtual.js.map +1 -0
  72. package/dist/components/reui/cascader/cascader.d.ts +322 -0
  73. package/dist/components/reui/cascader/cascader.d.ts.map +1 -0
  74. package/dist/components/reui/cascader/cascader.js +1459 -0
  75. package/dist/components/reui/cascader/cascader.js.map +1 -0
  76. package/dist/components/reui/event-calendar/event-calendar-event.d.ts +28 -47
  77. package/dist/components/reui/event-calendar/event-calendar-event.d.ts.map +1 -1
  78. package/dist/components/reui/event-calendar/event-calendar-event.js +26 -44
  79. package/dist/components/reui/event-calendar/event-calendar-event.js.map +1 -1
  80. package/dist/components/reui/event-calendar/event-calendar-nav.js +1 -1
  81. package/dist/components/reui/event-calendar/event-calendar-types.d.ts +19 -57
  82. package/dist/components/reui/event-calendar/event-calendar-types.d.ts.map +1 -1
  83. package/dist/components/reui/filters/filters-advanced.d.ts +52 -0
  84. package/dist/components/reui/filters/filters-advanced.d.ts.map +1 -0
  85. package/dist/components/reui/filters/filters-advanced.js +1191 -0
  86. package/dist/components/reui/filters/filters-advanced.js.map +1 -0
  87. package/dist/components/reui/filters/filters-builder.d.ts +43 -0
  88. package/dist/components/reui/filters/filters-builder.d.ts.map +1 -0
  89. package/dist/components/reui/filters/filters-builder.js +152 -0
  90. package/dist/components/reui/filters/filters-builder.js.map +1 -0
  91. package/dist/components/reui/filters/filters-chip.d.ts +79 -0
  92. package/dist/components/reui/filters/filters-chip.d.ts.map +1 -0
  93. package/dist/components/reui/filters/filters-chip.js +553 -0
  94. package/dist/components/reui/filters/filters-chip.js.map +1 -0
  95. package/dist/components/reui/filters/filters-context.d.ts +290 -0
  96. package/dist/components/reui/filters/filters-context.d.ts.map +1 -0
  97. package/dist/components/reui/filters/filters-context.js +277 -0
  98. package/dist/components/reui/filters/filters-context.js.map +1 -0
  99. package/dist/components/reui/filters/filters-date.d.ts +43 -0
  100. package/dist/components/reui/filters/filters-date.d.ts.map +1 -0
  101. package/dist/components/reui/filters/filters-date.js +143 -0
  102. package/dist/components/reui/filters/filters-date.js.map +1 -0
  103. package/dist/components/reui/filters/filters-dnd.d.ts +101 -0
  104. package/dist/components/reui/filters/filters-dnd.d.ts.map +1 -0
  105. package/dist/components/reui/filters/filters-dnd.js +454 -0
  106. package/dist/components/reui/filters/filters-dnd.js.map +1 -0
  107. package/dist/components/reui/filters/filters-draft.d.ts +2 -0
  108. package/dist/components/reui/filters/filters-draft.js +128 -0
  109. package/dist/components/reui/filters/filters-draft.js.map +1 -0
  110. package/dist/components/reui/filters/filters-editors.d.ts +91 -0
  111. package/dist/components/reui/filters/filters-editors.d.ts.map +1 -0
  112. package/dist/components/reui/filters/filters-editors.js +773 -0
  113. package/dist/components/reui/filters/filters-editors.js.map +1 -0
  114. package/dist/components/reui/filters/filters-i18n.d.ts +24 -0
  115. package/dist/components/reui/filters/filters-i18n.d.ts.map +1 -0
  116. package/dist/components/reui/filters/filters-i18n.js +127 -0
  117. package/dist/components/reui/filters/filters-i18n.js.map +1 -0
  118. package/dist/components/reui/filters/filters-lib.d.ts +171 -0
  119. package/dist/components/reui/filters/filters-lib.d.ts.map +1 -0
  120. package/dist/components/reui/filters/filters-lib.js +336 -0
  121. package/dist/components/reui/filters/filters-lib.js.map +1 -0
  122. package/dist/components/reui/filters/filters-operators.d.ts +49 -0
  123. package/dist/components/reui/filters/filters-operators.d.ts.map +1 -0
  124. package/dist/components/reui/filters/filters-operators.js +300 -0
  125. package/dist/components/reui/filters/filters-operators.js.map +1 -0
  126. package/dist/components/reui/filters/filters-query.d.ts +132 -0
  127. package/dist/components/reui/filters/filters-query.d.ts.map +1 -0
  128. package/dist/components/reui/filters/filters-query.js +476 -0
  129. package/dist/components/reui/filters/filters-query.js.map +1 -0
  130. package/dist/components/reui/filters/filters-types.d.ts +452 -0
  131. package/dist/components/reui/filters/filters-types.d.ts.map +1 -0
  132. package/dist/components/reui/filters/filters-types.js +2 -0
  133. package/dist/components/reui/filters/filters.d.ts +114 -0
  134. package/dist/components/reui/filters/filters.d.ts.map +1 -0
  135. package/dist/components/reui/filters/filters.js +638 -0
  136. package/dist/components/reui/filters/filters.js.map +1 -0
  137. package/dist/components/reui/frame.d.ts +1 -1
  138. package/dist/components/reui/gantt/gantt-bar.js +1 -1
  139. package/dist/components/reui/gantt/gantt-nav.js +1 -1
  140. package/dist/components/reui/gantt/gantt-types.d.ts +25 -71
  141. package/dist/components/reui/gantt/gantt-types.d.ts.map +1 -1
  142. package/dist/components/reui/gantt/gantt-view.js +1 -1
  143. package/dist/components/ui/attachment.d.ts +1 -1
  144. package/dist/components/ui/badge.d.ts +1 -1
  145. package/dist/components/ui/bubble.d.ts +1 -1
  146. package/dist/components/ui/button-group.d.ts +1 -1
  147. package/dist/components/ui/button.d.ts +2 -2
  148. package/dist/components/ui/checkbox.js +1 -1
  149. package/dist/components/ui/checkbox.js.map +1 -1
  150. package/dist/components/ui/field.d.ts +1 -1
  151. package/dist/components/ui/field.js +2 -2
  152. package/dist/components/ui/field.js.map +1 -1
  153. package/dist/components/ui/item.d.ts +1 -1
  154. package/dist/components/ui/radio-group.js +1 -1
  155. package/dist/components/ui/radio-group.js.map +1 -1
  156. package/dist/components/ui/sidebar.d.ts +1 -1
  157. package/dist/components/ui/sidebar.js +1 -1
  158. package/dist/components/ui/switch.js +1 -1
  159. package/dist/components/ui/switch.js.map +1 -1
  160. package/dist/components/ui/toggle.d.ts +1 -1
  161. package/dist/filters-draft-DEAl3TO-.d.ts +70 -0
  162. package/dist/filters-draft-DEAl3TO-.d.ts.map +1 -0
  163. package/dist/lib/text-shimmer.d.ts +2 -2
  164. package/dist/lib/text-shimmer.d.ts.map +1 -1
  165. package/dist/lib/text-shimmer.js +2 -2
  166. package/dist/lib/text-shimmer.js.map +1 -1
  167. package/dist/presence-gate-BekdC4Bo.js +24 -0
  168. package/dist/presence-gate-BekdC4Bo.js.map +1 -0
  169. package/package.json +9 -9
  170. package/dist/components/reui/filters.d.ts +0 -176
  171. package/dist/components/reui/filters.d.ts.map +0 -1
  172. package/dist/components/reui/filters.js +0 -1223
  173. package/dist/components/reui/filters.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cascader-async.js","names":["React"],"sources":["../../../../src/components/reui/cascader/cascader-async.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\n\nimport { useCascaderState } from \"./cascader-context\";\nimport { CASCADER_ROOT_KEY, isCascaderMoreNode } from \"./cascader-lib\";\nimport type {\n CascaderIndex,\n CascaderLoadContext,\n CascaderLoadReason,\n CascaderLoadResult,\n CascaderLoadState,\n CascaderNode,\n CascaderSearchContext,\n} from \"./cascader-types\";\n\n/**\n * Async data for the cascader. Loaded pages live in their own store and are\n * MERGED onto the index built from `items`, never folded into that build:\n * `items` changes identity on any parent re-render, and folding would discard\n * every level the user drilled into. Map membership is the load discriminator:\n * no `states` entry means never fetched, while an entry with no `loading`, no\n * `error` and no children means empty for real.\n */\n\n/* -------------------------------------------------------------------------- */\n/* Types */\n/* -------------------------------------------------------------------------- */\n\n/** Fetches one level. `node` is `null` for the root level. */\nexport type CascaderGetChildren<T = unknown> = (\n node: CascaderNode<T> | null,\n context: CascaderLoadContext,\n) => CascaderNode<T>[] | CascaderLoadResult<T> | Promise<CascaderNode<T>[] | CascaderLoadResult<T>>;\n\n/** Server-side search, replacing the local index scan while the query is set. */\nexport type CascaderOnSearch<T = unknown> = (\n query: string,\n context: CascaderSearchContext,\n) => CascaderNode<T>[] | CascaderLoadResult<T> | Promise<CascaderNode<T>[] | CascaderLoadResult<T>>;\n\n/** Resolves a selected value to its ancestor chain, root first, node last. */\nexport type CascaderResolveValue<T = unknown> = (\n value: string,\n context: CascaderLoadContext,\n) => CascaderNode<T>[] | Promise<CascaderNode<T>[]>;\n\nexport interface CascaderLoaderStore<T = unknown> {\n /** Keyed by LEVEL: a parent's value, or `CASCADER_ROOT_KEY` for the root. */\n pages: Map<string, CascaderNode<T>[]>;\n states: Map<string, CascaderLoadState>;\n /** Keyed by node value: search hits and resolved selections, level-less. */\n detached: Map<string, CascaderNode<T>>;\n}\n\nexport interface UseCascaderLoaderOptions<T = unknown> {\n /** The index built from `items`, before any pages are merged in. */\n base: CascaderIndex<T>;\n getChildren?: CascaderGetChildren<T>;\n onSearch?: CascaderOnSearch<T>;\n resolveValue?: CascaderResolveValue<T>;\n /** Milliseconds of quiet before `onSearch` fires. */\n searchDebounce?: number;\n /** Changing this drops every cached page, state and detached node. */\n loadKey?: unknown;\n /** Speculatively fetch a branch's children when it is highlighted. */\n prefetch?: boolean;\n /** Called when a request fails. Never for an aborted or superseded one. */\n onLoadError?: (error: unknown, context: { parent: string | null; reason: string }) => void;\n /** Whether the panel is live: the popup is open, or the cascader is inline. */\n enabled: boolean;\n query: string;\n /** Level keys that are currently on screen. Root is `CASCADER_ROOT_KEY`. */\n levels: string[];\n /** The navigation path, handed to `onSearch` as its scope. */\n path: string[];\n /** Current selection, for `resolveValue`. */\n values: string[];\n}\n\nexport interface CascaderLoader<T = unknown> {\n /** Whether a `getChildren` loader is configured at all. */\n active: boolean;\n store: CascaderLoaderStore<T>;\n states: ReadonlyMap<string, CascaderLoadState>;\n /**\n * Async search hits, `null` when no `onSearch` is running. EMPTY while the\n * first request is in flight, so the level behind is not shown as the answer.\n */\n searchResults: CascaderNode<T>[] | null;\n searchState: CascaderLoadState | null;\n /**\n * Fetches a level's FIRST page. No-ops on a `states` entry (in flight,\n * loaded or failed) or when `items` fills the level; pages are never\n * consulted, so a `resolveValue` chain still fetches. The level effect fires\n * only for on-screen levels, so a branch merely PRESSED is asked for by hand.\n */\n ensureLevel: (parentKey: string, reason: CascaderLoadReason) => void;\n /** Fetches the next page of a level. No-ops unless one is available. */\n loadMore: (parentKey: string) => void;\n /** Refires a failed level. No-ops unless that level is in an error state. */\n retryLevel: (parentKey: string) => void;\n /** Schedules a speculative fetch. Safe to call on every highlight move. */\n prefetchNode: (node: CascaderNode<T> | null | undefined) => void;\n /**\n * Evicts ONE level: aborts its request, drops its `states`/`pages` entries\n * and paging latch, so the level effect refetches it. `null` = root level.\n */\n invalidateLevel: (value: string | null) => void;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Constants */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Highlight dwell before `prefetch` fetches: long enough that holding ArrowDown\n * does not fire a request per row, short enough to beat the ArrowRight press.\n */\nconst PREFETCH_DELAY = 150;\n\n/** Request keys for the two non-level requests. Never collide with a value. */\nconst SEARCH_KEY = \"\\u0000search\";\nconst RESOLVE_PREFIX = \"\\u0000resolve:\";\n\nconst NO_STATE: CascaderLoadState = {\n loading: false,\n error: false,\n hasMore: false,\n};\n\n/** Stable empty result, so an idle search never churns the state context. */\nconst NO_RESULTS: CascaderNode<never>[] = [];\n\nfunction createStore<T>(): CascaderLoaderStore<T> {\n return { pages: new Map(), states: new Map(), detached: new Map() };\n}\n\nfunction sameLoadState(a: CascaderLoadState, b: CascaderLoadState): boolean {\n return (\n a.loading === b.loading &&\n a.error === b.error &&\n a.hasMore === b.hasMore &&\n a.cursor === b.cursor\n );\n}\n\n/* -------------------------------------------------------------------------- */\n/* Store transitions */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Copy-on-write, and a NO-OP when nothing changed: the merged index is memoised\n * on store identity, so a fresh object for an unchanged state would rebuild it.\n */\nfunction withLoadState<T>(\n store: CascaderLoaderStore<T>,\n key: string,\n update: (state: CascaderLoadState) => CascaderLoadState,\n): CascaderLoaderStore<T> {\n const current = store.states.get(key) ?? NO_STATE;\n const next = update(current);\n if (store.states.has(key) && sameLoadState(current, next)) return store;\n const states = new Map(store.states);\n states.set(key, next);\n return { pages: store.pages, states, detached: store.detached };\n}\n\nfunction withPage<T>(\n store: CascaderLoaderStore<T>,\n key: string,\n items: readonly CascaderNode<T>[],\n options: { append: boolean; hasMore: boolean; cursor?: string },\n): CascaderLoaderStore<T> {\n // A fresh level REPLACES its page so a `resolveValue` stub can be superseded.\n const previous = options.append ? (store.pages.get(key) ?? []) : [];\n const seen = new Set(previous.map((node) => node.value));\n const merged = previous.slice();\n for (const item of items) {\n if (seen.has(item.value)) continue;\n seen.add(item.value);\n merged.push(item);\n }\n\n const pages = new Map(store.pages);\n pages.set(key, merged);\n const states = new Map(store.states);\n states.set(key, {\n loading: false,\n error: false,\n hasMore: options.hasMore,\n cursor: options.cursor,\n });\n return { pages, states, detached: store.detached };\n}\n\nfunction withDetached<T>(\n store: CascaderLoaderStore<T>,\n items: readonly CascaderNode<T>[],\n): CascaderLoaderStore<T> {\n let detached: Map<string, CascaderNode<T>> | null = null;\n for (const item of items) {\n if (store.detached.get(item.value) === item) continue;\n detached = detached ?? new Map(store.detached);\n detached.set(item.value, item);\n }\n if (!detached) return store;\n return { pages: store.pages, states: store.states, detached };\n}\n\n/**\n * Places a resolved ancestor chain into `pages`, root first. Writes no\n * `states`, so those levels still read as unloaded and a drill-in still fetches\n * for real. Mirrored into `detached` so the trigger keeps its label.\n */\nfunction withChain<T>(\n store: CascaderLoaderStore<T>,\n chain: readonly CascaderNode<T>[],\n): CascaderLoaderStore<T> {\n if (chain.length === 0) return store;\n const pages = new Map(store.pages);\n const detached = new Map(store.detached);\n let parentKey = CASCADER_ROOT_KEY;\n\n for (const node of chain) {\n const bucket = pages.get(parentKey);\n if (!bucket) {\n pages.set(parentKey, [node]);\n } else if (!bucket.some((entry) => entry.value === node.value)) {\n pages.set(parentKey, [...bucket, node]);\n }\n detached.set(node.value, node);\n parentKey = node.value;\n }\n\n return { pages, states: store.states, detached };\n}\n\n/* -------------------------------------------------------------------------- */\n/* Hook */\n/* -------------------------------------------------------------------------- */\n\ninterface CascaderLoaderLatest<T> {\n base: CascaderIndex<T>;\n store: CascaderLoaderStore<T>;\n getChildren?: CascaderGetChildren<T>;\n onSearch?: CascaderOnSearch<T>;\n resolveValue?: CascaderResolveValue<T>;\n onLoadError?: (error: unknown, context: { parent: string | null; reason: string }) => void;\n prefetch: boolean;\n path: string[];\n}\n\ninterface CascaderSearchSlice<T> {\n query: string;\n results: CascaderNode<T>[];\n loading: boolean;\n error: boolean;\n}\n\n/**\n * The loader. A SIBLING of the `buildCascaderIndex` memo, never inside it: the\n * build stays pure in `items`, the merge pure in that build plus this store.\n */\nexport function useCascaderLoader<T = unknown>({\n base,\n getChildren,\n onSearch,\n resolveValue,\n searchDebounce = 250,\n loadKey,\n prefetch = false,\n onLoadError,\n enabled,\n query,\n levels,\n path,\n values,\n}: UseCascaderLoaderOptions<T>): CascaderLoader<T> {\n const [store, setStore] = React.useState<CascaderLoaderStore<T>>(createStore);\n const [search, setSearch] = React.useState<CascaderSearchSlice<T> | null>(null);\n\n /**\n * Latest callbacks, WRITTEN IN AN EFFECT: `getChildren` is inline in most\n * consumers, so closing over it would refire every in-flight request per\n * re-render. The ref is what keeps the request machinery `[]`-dep. Declared\n * FIRST, since effects run in declaration order, so the level effect below\n * already sees the current commit.\n */\n const latest = React.useRef<CascaderLoaderLatest<T>>({\n base,\n store,\n getChildren,\n onSearch,\n resolveValue,\n onLoadError,\n prefetch,\n path,\n });\n\n React.useEffect(() => {\n latest.current = {\n base,\n store,\n getChildren,\n onSearch,\n resolveValue,\n onLoadError,\n prefetch,\n path,\n };\n });\n\n /** One AbortController PER KEY: columns mode runs several levels at once. */\n const controllers = React.useRef(new Map<string, AbortController>());\n /** Monotonic per key. The stale guard for out-of-order responses. */\n const requestIds = React.useRef(new Map<string, number>());\n /** In-flight `(level, cursor)` signatures, so a duplicate ask is free. */\n const inflight = React.useRef(new Map<string, string>());\n /**\n * The `(child count, cursor)` signature at the last paging fire, per level.\n * Guards what `hasMore` cannot: a page of zero new items while the server\n * still says `hasMore`. Cursor is IN the signature because an all-duplicates\n * page advances it while the count stands still - real progress, which a\n * count-only latch would brick forever.\n */\n const moreLatch = React.useRef(new Map<string, string>());\n /** Values `resolveValue` has already been asked about, so it asks once. */\n const attempted = React.useRef(new Set<string>());\n /** Every node the loader has seen, so a level key can name its own node. */\n const known = React.useRef(new Map<string, CascaderNode<T>>());\n const timers = React.useRef<{\n prefetch: ReturnType<typeof setTimeout> | null;\n }>({ prefetch: null });\n /** Bumped by a `loadKey` change, so responses from before it are dropped. */\n const epoch = React.useRef(0);\n\n const remember = React.useCallback((nodes: readonly CascaderNode<T>[]) => {\n const map = known.current;\n const walk = (list: readonly CascaderNode<T>[]) => {\n for (const node of list) {\n map.set(node.value, node);\n if (node.children?.length) walk(node.children);\n }\n };\n walk(nodes);\n }, []);\n\n const abortKey = React.useCallback((key: string) => {\n const controller = controllers.current.get(key);\n if (!controller) return;\n controllers.current.delete(key);\n inflight.current.delete(key);\n controller.abort();\n }, []);\n\n /* ------------------------------- level load ------------------------------ */\n\n const runLoad = React.useCallback(\n (key: string, reason: CascaderLoadReason, cursor: string | undefined, append: boolean) => {\n const { getChildren: loader, base: currentBase } = latest.current;\n if (!loader) return;\n\n const signature = `${append ? \"1\" : \"0\"}:${cursor ?? \"\"}`;\n if (inflight.current.get(key) === signature) return;\n\n abortKey(key);\n const controller = new AbortController();\n controllers.current.set(key, controller);\n inflight.current.set(key, signature);\n\n const requestId = (requestIds.current.get(key) ?? 0) + 1;\n requestIds.current.set(key, requestId);\n const startEpoch = epoch.current;\n\n const node =\n key === CASCADER_ROOT_KEY\n ? null\n : (currentBase.byValue.get(key) ?? known.current.get(key) ?? null);\n\n setStore((prev) =>\n withLoadState(prev, key, (state) => ({\n ...state,\n loading: true,\n error: false,\n })),\n );\n\n const settle = () => {\n if (inflight.current.get(key) === signature) inflight.current.delete(key);\n if (controllers.current.get(key) === controller) {\n controllers.current.delete(key);\n }\n };\n\n const stale = () =>\n controller.signal.aborted ||\n startEpoch !== epoch.current ||\n requestId !== requestIds.current.get(key);\n\n // `Promise.resolve().then(...)`, not a direct call: it normalises a\n // SYNCHRONOUS throw into a rejection instead of taking the render down.\n Promise.resolve()\n .then(() => loader(node, { signal: controller.signal, cursor, reason }))\n .then((result) => {\n settle();\n if (stale()) return;\n const items = Array.isArray(result) ? result : result.items;\n const nextCursor = Array.isArray(result) ? undefined : result.nextCursor;\n const hasMore = Array.isArray(result) ? false : (result.hasMore ?? nextCursor != null);\n\n if (!append) moreLatch.current.delete(key);\n remember(items);\n setStore((prev) => withPage(prev, key, items, { append, hasMore, cursor: nextCursor }));\n })\n .catch((error: unknown) => {\n settle();\n if (stale()) return;\n setStore((prev) =>\n withLoadState(prev, key, (state) => ({\n ...state,\n loading: false,\n error: true,\n })),\n );\n // Behind the stale guard: an abort is navigation, not a failure.\n latest.current.onLoadError?.(error, {\n parent: key === CASCADER_ROOT_KEY ? null : key,\n reason,\n });\n });\n },\n [abortKey, remember],\n );\n\n const ensureLevel = React.useCallback(\n (key: string, reason: CascaderLoadReason) => {\n const { getChildren: loader, store: current, base: index } = latest.current;\n if (!loader) return;\n if (current.states.has(key)) return;\n // A level `items` already fills is not the loader's business: that is how\n // a static root plus `getChildren` for the branches works with no flag.\n if (index.childrenOf.has(key)) return;\n runLoad(key, reason, undefined, false);\n },\n [runLoad],\n );\n\n const loadMore = React.useCallback(\n (key: string) => {\n const { getChildren: loader, store: current } = latest.current;\n if (!loader) return;\n const state = current.states.get(key);\n if (!state || state.loading || !state.hasMore) return;\n\n const loaded = current.pages.get(key)?.length ?? 0;\n const signature = `${loaded}:${state.cursor ?? \"\"}`;\n if (moreLatch.current.get(key) === signature) return;\n moreLatch.current.set(key, signature);\n\n runLoad(key, \"more\", state.cursor, true);\n },\n [runLoad],\n );\n\n const retryLevel = React.useCallback(\n (key: string) => {\n const { getChildren: loader, store: current } = latest.current;\n if (!loader) return;\n const state = current.states.get(key);\n if (!state?.error) return;\n\n const loaded = current.pages.get(key)?.length ?? 0;\n // A retry must be able to re-fire the page the latch just blocked.\n moreLatch.current.delete(key);\n runLoad(key, \"retry\", loaded > 0 ? state.cursor : undefined, loaded > 0);\n },\n [runLoad],\n );\n\n /**\n * `detached` is deliberately untouched: chains and search hits belong to no\n * level, and the trigger needs their labels while the new page is in flight.\n */\n const invalidateLevel = React.useCallback(\n (value: string | null) => {\n const key = value ?? CASCADER_ROOT_KEY;\n abortKey(key);\n // Bump the id too: a response past its signal check must still be stale.\n requestIds.current.set(key, (requestIds.current.get(key) ?? 0) + 1);\n moreLatch.current.delete(key);\n setStore((prev) => {\n if (!prev.states.has(key) && !prev.pages.has(key)) return prev;\n const states = new Map(prev.states);\n states.delete(key);\n const pages = new Map(prev.pages);\n pages.delete(key);\n return { pages, states, detached: prev.detached };\n });\n },\n [abortKey],\n );\n\n const prefetchNode = React.useCallback(\n (node: CascaderNode<T> | null | undefined) => {\n const { prefetch: on, getChildren: loader, store: current } = latest.current;\n if (!on || !loader || !node) return;\n if (isCascaderMoreNode(node)) return;\n if (!node.hasChildren) return;\n if (current.states.has(node.value)) return;\n\n const holder = timers.current;\n if (holder.prefetch) clearTimeout(holder.prefetch);\n // A TIMEOUT, not a direct call: `onItemHighlighted` fires from a layout\n // effect, where a synchronous setState is a render-phase cascade.\n holder.prefetch = setTimeout(() => {\n holder.prefetch = null;\n ensureLevel(node.value, \"prefetch\");\n }, PREFETCH_DELAY);\n },\n [ensureLevel],\n );\n\n /* --------------------------------- search -------------------------------- */\n\n const runSearch = React.useCallback(\n (text: string) => {\n const { onSearch: searcher, path: currentPath } = latest.current;\n if (!searcher) return;\n\n abortKey(SEARCH_KEY);\n const controller = new AbortController();\n controllers.current.set(SEARCH_KEY, controller);\n const requestId = (requestIds.current.get(SEARCH_KEY) ?? 0) + 1;\n requestIds.current.set(SEARCH_KEY, requestId);\n const startEpoch = epoch.current;\n\n setSearch((prev) => ({\n query: text,\n results: prev?.results ?? [],\n loading: true,\n error: false,\n }));\n\n const settle = () => {\n if (controllers.current.get(SEARCH_KEY) === controller) {\n controllers.current.delete(SEARCH_KEY);\n }\n };\n const stale = () =>\n controller.signal.aborted ||\n startEpoch !== epoch.current ||\n requestId !== requestIds.current.get(SEARCH_KEY);\n\n Promise.resolve()\n .then(() => searcher(text, { signal: controller.signal, path: currentPath }))\n .then((result) => {\n settle();\n if (stale()) return;\n const items = Array.isArray(result) ? result : result.items;\n remember(items);\n // Search hits go to `detached`, never a level: a hit lives anywhere in\n // the tree, and filing it under the open level would misplace it.\n setStore((prev) => withDetached(prev, items));\n setSearch({\n query: text,\n results: items,\n loading: false,\n error: false,\n });\n })\n .catch((error: unknown) => {\n settle();\n if (stale()) return;\n setSearch((prev) => ({\n query: text,\n results: prev?.results ?? [],\n loading: false,\n error: true,\n }));\n latest.current.onLoadError?.(error, {\n parent: null,\n reason: \"search\",\n });\n });\n },\n [abortKey, remember],\n );\n\n /* --------------------------------- resolve ------------------------------- */\n\n const runResolve = React.useCallback(\n (value: string) => {\n const { resolveValue: resolver } = latest.current;\n if (!resolver) return;\n\n const key = `${RESOLVE_PREFIX}${value}`;\n abortKey(key);\n const controller = new AbortController();\n controllers.current.set(key, controller);\n const startEpoch = epoch.current;\n\n const settle = () => {\n if (controllers.current.get(key) === controller) {\n controllers.current.delete(key);\n }\n };\n\n Promise.resolve()\n .then(() => resolver(value, { signal: controller.signal, reason: \"resolve\" }))\n .then((chain) => {\n settle();\n if (controller.signal.aborted || startEpoch !== epoch.current) return;\n if (!chain?.length) return;\n remember(chain);\n setStore((prev) => withChain(prev, chain));\n })\n .catch((error: unknown) => {\n settle();\n // Un-attempt on failure: `attempted` is written BEFORE the call, so\n // without this a resolver that failed once could never be retried.\n attempted.current.delete(value);\n if (controller.signal.aborted || startEpoch !== epoch.current) return;\n latest.current.onLoadError?.(error, {\n parent: null,\n reason: \"resolve\",\n });\n });\n },\n [abortKey, remember],\n );\n\n /* --------------------------------- resets -------------------------------- */\n\n const cancelAll = React.useCallback(() => {\n const keys = Array.from(controllers.current.keys());\n for (const controller of controllers.current.values()) controller.abort();\n controllers.current.clear();\n inflight.current.clear();\n\n const holder = timers.current;\n if (holder.prefetch) {\n clearTimeout(holder.prefetch);\n holder.prefetch = null;\n }\n if (keys.length === 0) return;\n\n setStore((prev) => {\n let states: Map<string, CascaderLoadState> | null = null;\n for (const key of keys) {\n const state = prev.states.get(key);\n if (!state?.loading) continue;\n states = states ?? new Map(prev.states);\n if ((prev.pages.get(key)?.length ?? 0) > 0) {\n states.set(key, { ...state, loading: false });\n } else {\n // No entry AT ALL: membership is what says \"loaded\", so a stranded\n // `loading: true` would read as loaded-and-empty forever.\n states.delete(key);\n }\n }\n return states ? { ...prev, states } : prev;\n });\n setSearch((prev) => (prev?.loading ? { ...prev, loading: false } : prev));\n }, []);\n\n // A `loadKey` change drops everything. Declared BEFORE the level effect, so\n // a reset always lands before the levels are asked for again.\n const loadKeyRef = React.useRef<{ key: unknown } | null>(null);\n React.useEffect(() => {\n const previous = loadKeyRef.current;\n loadKeyRef.current = { key: loadKey };\n if (!previous || Object.is(previous.key, loadKey)) return;\n\n epoch.current += 1;\n for (const controller of controllers.current.values()) controller.abort();\n controllers.current.clear();\n inflight.current.clear();\n // `requestIds` is deliberately NOT cleared: the ids are stale-response\n // guards, not cache. Reusing an aborted predecessor's id would leave only\n // the epoch bump and the abort to reject the old response; monotonic per\n // key keeps all three guards independent. The unmount cleanup clears them.\n moreLatch.current.clear();\n attempted.current.clear();\n known.current.clear();\n\n const holder = timers.current;\n if (holder.prefetch) {\n clearTimeout(holder.prefetch);\n holder.prefetch = null;\n }\n\n setStore(createStore);\n setSearch(null);\n }, [loadKey]);\n\n // Closing the popup aborts every request but does NOT drop the cache:\n // reopening onto an already-loaded level is the point of keeping it.\n React.useEffect(() => {\n if (enabled) return;\n if (controllers.current.size === 0) return;\n cancelAll();\n }, [enabled, cancelAll]);\n\n React.useEffect(() => {\n const active = controllers.current;\n const holder = timers.current;\n const pending = inflight.current;\n const ids = requestIds.current;\n return () => {\n for (const controller of active.values()) controller.abort();\n active.clear();\n // Cleared WITH the controllers, for StrictMode's dev remount: a stale\n // inflight signature would make `runLoad` skip the refetch forever. The\n // aborted promises are stale-guarded, so emptying the ids is safe.\n pending.clear();\n ids.clear();\n if (holder.prefetch) clearTimeout(holder.prefetch);\n };\n }, []);\n\n /* ------------------------------- the effects ----------------------------- */\n\n const hasLoader = typeof getChildren === \"function\";\n const hasSearch = typeof onSearch === \"function\";\n const hasResolve = typeof resolveValue === \"function\";\n const trimmed = query.trim();\n\n // THE load trigger: one declarative effect on the levels on screen, not a\n // call from `pushLevel`/`navigate`, which a controlled `path` never touches.\n React.useEffect(() => {\n if (!enabled || !hasLoader) return;\n for (const key of levels) ensureLevel(key, \"level\");\n // `levels` enters through `levelsKey`; `store` re-runs after a load lands.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [enabled, hasLoader, ensureLevel, levels]);\n\n React.useEffect(() => {\n if (!hasSearch) return undefined;\n if (!enabled || !trimmed) {\n abortKey(SEARCH_KEY);\n setSearch((prev) => (prev === null ? prev : null));\n return undefined;\n }\n const timer = setTimeout(() => runSearch(trimmed), searchDebounce);\n return () => {\n clearTimeout(timer);\n abortKey(SEARCH_KEY);\n };\n }, [hasSearch, enabled, trimmed, searchDebounce, abortKey, runSearch]);\n\n React.useEffect(() => {\n if (!enabled || !hasResolve) return;\n for (const value of values) {\n if (!value) continue;\n if (attempted.current.has(value)) continue;\n if (base.byValue.has(value) || known.current.has(value)) continue;\n attempted.current.add(value);\n runResolve(value);\n }\n // `values` is depended on through `valuesKey`.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [enabled, hasResolve, base, runResolve, values]);\n\n /* -------------------------------- the value ------------------------------ */\n\n const searchResults = React.useMemo(() => {\n if (!hasSearch || !trimmed) return null;\n if (!search || search.query !== trimmed) {\n return NO_RESULTS as CascaderNode<T>[];\n }\n return search.results;\n }, [hasSearch, trimmed, search]);\n\n const searchState = React.useMemo<CascaderLoadState | null>(() => {\n if (!hasSearch || !trimmed) return null;\n const settled = search?.query === trimmed;\n return {\n loading: !settled || !!search?.loading,\n error: settled && !!search?.error,\n hasMore: false,\n };\n }, [hasSearch, trimmed, search]);\n\n return React.useMemo(\n () => ({\n active: hasLoader,\n store,\n states: store.states,\n searchResults,\n searchState,\n ensureLevel,\n loadMore,\n retryLevel,\n invalidateLevel,\n prefetchNode,\n }),\n [\n hasLoader,\n store,\n searchResults,\n searchState,\n ensureLevel,\n loadMore,\n retryLevel,\n invalidateLevel,\n prefetchNode,\n ],\n );\n}\n\n/* -------------------------------------------------------------------------- */\n/* Consumers */\n/* -------------------------------------------------------------------------- */\n\n/** One level's load state, `null` when never fetched. Omit for the root. */\nexport function useCascaderLoadState(parent?: string | null): CascaderLoadState | null {\n const { loadStates } = useCascaderState();\n return loadStates.get(parent ?? CASCADER_ROOT_KEY) ?? null;\n}\n"],"mappings":";;;;;;;;;AAuHA,MAAM,iBAAiB;;AAGvB,MAAM,aAAa;AACnB,MAAM,iBAAiB;AAEvB,MAAM,WAA8B;CAClC,SAAS;CACT,OAAO;CACP,SAAS;AACX;;AAGA,MAAM,aAAoC,CAAC;AAE3C,SAAS,cAAyC;CAChD,OAAO;EAAE,uBAAO,IAAI,IAAI;EAAG,wBAAQ,IAAI,IAAI;EAAG,0BAAU,IAAI,IAAI;CAAE;AACpE;AAEA,SAAS,cAAc,GAAsB,GAA+B;CAC1E,OACE,EAAE,YAAY,EAAE,WAChB,EAAE,UAAU,EAAE,SACd,EAAE,YAAY,EAAE,WAChB,EAAE,WAAW,EAAE;AAEnB;;;;;AAUA,SAAS,cACP,OACA,KACA,QACwB;CACxB,MAAM,UAAU,MAAM,OAAO,IAAI,GAAG,KAAK;CACzC,MAAM,OAAO,OAAO,OAAO;CAC3B,IAAI,MAAM,OAAO,IAAI,GAAG,KAAK,cAAc,SAAS,IAAI,GAAG,OAAO;CAClE,MAAM,SAAS,IAAI,IAAI,MAAM,MAAM;CACnC,OAAO,IAAI,KAAK,IAAI;CACpB,OAAO;EAAE,OAAO,MAAM;EAAO;EAAQ,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B;CACF,GAAG;EAAC;EAAW;EAAS;EAAS;EAAgB;EAAU;CAAS,CAAC;CAErE,QAAM,gBAAgB;EACpB,IAAI,CAAC,WAAW,CAAC,YAAY;EAC7B,KAAK,MAAM,SAAS,QAAQ;GAC1B,IAAI,CAAC,OAAO;GACZ,IAAI,UAAU,QAAQ,IAAI,KAAK,GAAG;GAClC,IAAI,KAAK,QAAQ,IAAI,KAAK,KAAK,MAAM,QAAQ,IAAI,KAAK,GAAG;GACzD,UAAU,QAAQ,IAAI,KAAK;GAC3B,WAAW,KAAK;EAClB;CAGF,GAAG;EAAC;EAAS;EAAY;EAAM;EAAY;CAAM,CAAC;CAIlD,MAAM,gBAAgBA,QAAM,cAAc;EACxC,IAAI,CAAC,aAAa,CAAC,SAAS,OAAO;EACnC,IAAI,CAAC,UAAU,OAAO,UAAU,SAC9B,OAAO;EAET,OAAO,OAAO;CAChB,GAAG;EAAC;EAAW;EAAS;CAAM,CAAC;CAE/B,MAAM,cAAcA,QAAM,cAAwC;EAChE,IAAI,CAAC,aAAa,CAAC,SAAS,OAAO;EACnC,MAAM,UAAU,QAAQ,UAAU;EAClC,OAAO;GACL,SAAS,CAAC,WAAW,CAAC,CAAC,QAAQ;GAC/B,OAAO,WAAW,CAAC,CAAC,QAAQ;GAC5B,SAAS;EACX;CACF,GAAG;EAAC;EAAW;EAAS;CAAM,CAAC;CAE/B,OAAOA,QAAM,eACJ;EACL,QAAQ;EACR;EACA,QAAQ,MAAM;EACd;EACA;EACA;EACA;EACA;EACA;EACA;CACF,IACA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CACF;AACF;;AAOA,SAAgB,qBAAqB,QAAkD;CACrF,MAAM,EAAE,eAAe,iBAAiB;CACxC,OAAO,WAAW,IAAI,UAAA,QAA2B,KAAK;AACxD"}
@@ -0,0 +1,29 @@
1
+ import { CascaderColumn } from "./cascader-context.js";
2
+ import * as React$1 from "react";
3
+ //#region src/components/reui/cascader/cascader-columns.d.ts
4
+ interface CascaderColumnsProps extends Omit<React$1.ComponentProps<"div">, "children"> {
5
+ /** Width of each column. */
6
+ columnWidth?: number | string;
7
+ /** Height CAP per column. Falls back to the root `maxHeight`, then 24rem. */
8
+ maxHeight?: number | string;
9
+ /** Replaces the default panel; the seam a windowed column plugs into. */
10
+ children?: (column: CascaderColumn) => React$1.ReactNode;
11
+ }
12
+ /**
13
+ * Miller columns: the open trail side by side, one panel per level. Only the
14
+ * DEEPEST column is a real listbox (Base UI owns exactly one list); the trail
15
+ * behind is plain buttons, which keeps one state machine instead of a second,
16
+ * 2D one. `CascaderInput` moves between columns with ArrowLeft/ArrowRight.
17
+ */
18
+ declare function CascaderColumns({ className, columnWidth, maxHeight: maxHeightProp, children, ...props }: CascaderColumnsProps): React$1.JSX.Element | null;
19
+ interface CascaderColumnPanelProps {
20
+ column: CascaderColumn;
21
+ /** Replaces the panel's rows; the empty state still wins on an empty column. */
22
+ children?: React$1.ReactNode;
23
+ /** Containing block for the windowed column's absolutely positioned rows. */
24
+ virtualized?: boolean;
25
+ }
26
+ declare function CascaderColumnPanel({ column, children, virtualized }: CascaderColumnPanelProps): React$1.JSX.Element;
27
+ //#endregion
28
+ export { CascaderColumnPanel, CascaderColumnPanelProps, CascaderColumns, CascaderColumnsProps };
29
+ //# sourceMappingURL=cascader-columns.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cascader-columns.d.ts","names":[],"sources":["../../../../src/components/reui/cascader/cascader-columns.tsx"],"mappings":";;;UAoBiB,6BAA6B,KAAK,QAAM;;EAEvD;;EAEA;;EAEA,YAAY,QAAQ,mBAAmB,QAAM;;;;;;;;iBAStC,kBACP,WACA,aACA,WAAW,eACX,aACG,SACF,uBAAoB,QAAA,IAAA;UA8DN;EACf,QAAQ;;EAER,WAAW,QAAM;;EAEjB;;iBAGO,sBAAsB,QAAQ,UAAU,eAAe,2BAAwB,QAAA,IAAA"}
@@ -0,0 +1,135 @@
1
+ "use client";
2
+ import { ScrollArea } from "../../ui/scroll-area.js";
3
+ import { useCascaderActions, useCascaderState } from "./cascader-context.js";
4
+ import { CASCADER_LIST_HEIGHT_CLASS, CASCADER_LIST_PAD_CLASS, CASCADER_ROWS_CLASS, CASCADER_SCROLL_CLASS, warnCascaderOnce } from "./cascader-lib.js";
5
+ import { CascaderItem, getCascaderMoreProps } from "./cascader-item.js";
6
+ import * as React$1 from "react";
7
+ import { cn } from "@kumix/utils";
8
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
9
+ import { LoaderCircleIcon } from "lucide-react";
10
+ import { Combobox } from "@base-ui/react";
11
+ //#region src/components/reui/cascader/cascader-columns.tsx
12
+ /**
13
+ * Miller columns: the open trail side by side, one panel per level. Only the
14
+ * DEEPEST column is a real listbox (Base UI owns exactly one list); the trail
15
+ * behind is plain buttons, which keeps one state machine instead of a second,
16
+ * 2D one. `CascaderInput` moves between columns with ArrowLeft/ArrowRight.
17
+ */
18
+ function CascaderColumns({ className, columnWidth = 220, maxHeight: maxHeightProp, children, ...props }) {
19
+ const { maxHeight, mode, labels } = useCascaderActions();
20
+ const { columns } = useCascaderState();
21
+ React$1.useEffect(() => {
22
+ if (process.env.NODE_ENV === "production") return;
23
+ if (mode === "columns") return;
24
+ warnCascaderOnce(`columns-outside-columns-mode:${mode}`, `\`CascaderColumns\` renders nothing in \`mode="${mode}"\`, so \`columnWidth\` and everything else on it does nothing. Set \`mode="columns"\` on the root, or render \`CascaderList\` instead.`);
25
+ }, [mode]);
26
+ if (mode !== "columns") return null;
27
+ const height = maxHeightProp ?? maxHeight;
28
+ const toCss = (value) => typeof value === "number" ? `${value}px` : value;
29
+ return /* @__PURE__ */ jsx("div", {
30
+ "data-slot": "cascader-columns",
31
+ role: "group",
32
+ "aria-label": labels.columnsLabel,
33
+ style: {
34
+ "--cascader-column-width": toCss(columnWidth),
35
+ ...height != null ? { "--cascader-max-height": toCss(height) } : null
36
+ },
37
+ className: cn("flex max-h-full min-h-0 items-stretch overflow-x-auto overscroll-x-contain", CASCADER_LIST_PAD_CLASS, className),
38
+ ...props,
39
+ children: columns.map((column) => children ? /* @__PURE__ */ jsx(React$1.Fragment, { children: children(column) }, column.depth) : /* @__PURE__ */ jsx(CascaderColumnPanel, { column }, column.depth))
40
+ });
41
+ }
42
+ /**
43
+ * One column's box. `columnWidth` is the width of the LIST, not the box: under
44
+ * `border-box` the 1px inline-start divider on every column but the first would
45
+ * come out of the rows, so bordered columns are widened by that pixel. The box
46
+ * is also the BOUND, the same `min(--available-height, cap)` the single list
47
+ * uses, and the `ScrollArea` inside scrolls, so every column shows a thumb.
48
+ */
49
+ const PANEL_CLASS = `flex w-(--cascader-column-width) shrink-0 flex-col overscroll-contain not-first:w-[calc(var(--cascader-column-width)_+_1px)] not-first:border-border/60 not-first:border-s ${CASCADER_LIST_HEIGHT_CLASS}`;
50
+ function CascaderColumnPanel({ column, children, virtualized }) {
51
+ const { labels, baseId, isBranch, isSelectable, isSelected, isIndeterminate, retryLevel } = useCascaderActions();
52
+ const { loadStates } = useCascaderState();
53
+ const columnKey = column.parent?.value ?? "\0root";
54
+ const loadState = loadStates.get(columnKey);
55
+ let emptyBody = labels.empty;
56
+ if (loadState?.error) emptyBody = /* @__PURE__ */ jsxs(Fragment$1, { children: [
57
+ labels.error,
58
+ " ",
59
+ /* @__PURE__ */ jsx("button", {
60
+ type: "button",
61
+ "data-slot": "cascader-retry",
62
+ onClick: () => retryLevel(columnKey),
63
+ className: "rounded-md px-1 font-medium text-foreground outline-hidden transition-colors hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring/50",
64
+ children: labels.retry
65
+ })
66
+ ] });
67
+ else if (loadState?.loading) emptyBody = /* @__PURE__ */ jsxs("span", {
68
+ className: "flex items-center gap-1.5",
69
+ children: [/* @__PURE__ */ jsx(LoaderCircleIcon, {
70
+ className: "size-3.5 animate-spin",
71
+ "aria-hidden": true
72
+ }), labels.loading]
73
+ });
74
+ const rows = column.items.length === 0 ? /* @__PURE__ */ jsx("p", {
75
+ "data-slot": "cascader-column-empty",
76
+ "data-state": loadState?.error ? "error" : loadState?.loading ? "loading" : "empty",
77
+ className: "px-2 py-1.5 text-muted-foreground text-sm",
78
+ children: emptyBody
79
+ }) : children ?? column.items.map((node, i) => {
80
+ const open = node.value === column.activeValue;
81
+ return /* @__PURE__ */ jsx(CascaderItem, {
82
+ node,
83
+ as: column.active ? "option" : "button",
84
+ depth: column.depth,
85
+ branch: isBranch(node),
86
+ selectable: isSelectable(node),
87
+ selected: isSelected(node),
88
+ indeterminate: isIndeterminate(node),
89
+ ...getCascaderMoreProps(node, loadStates),
90
+ "data-open": open || void 0,
91
+ className: open ? "bg-accent/60 text-accent-foreground" : void 0,
92
+ ...column.active ? {
93
+ "aria-setsize": column.items.length,
94
+ "aria-posinset": i + 1
95
+ } : null,
96
+ ...!column.active && open ? {
97
+ "aria-expanded": true,
98
+ "aria-controls": `${baseId}-column-${column.depth + 1}`
99
+ } : null
100
+ }, node.value);
101
+ });
102
+ const shared = {
103
+ "data-slot": "cascader-column",
104
+ "data-active": column.active || void 0,
105
+ "data-depth": column.depth,
106
+ id: `${baseId}-column-${column.depth}`,
107
+ "aria-label": column.parent?.label ?? labels.rootLevel,
108
+ ...virtualized ? { "data-virtualized": true } : null
109
+ };
110
+ const rowsClass = cn(CASCADER_ROWS_CLASS, virtualized && "relative");
111
+ const body = column.active ? /* @__PURE__ */ jsx(Combobox.List, {
112
+ ...shared,
113
+ className: rowsClass,
114
+ children: rows
115
+ }) : /* @__PURE__ */ jsx("div", {
116
+ ...shared,
117
+ role: "group",
118
+ className: rowsClass,
119
+ children: rows
120
+ });
121
+ return /* @__PURE__ */ jsx("div", {
122
+ "data-slot": "cascader-column-bounds",
123
+ "data-active": column.active || void 0,
124
+ "data-depth": column.depth,
125
+ className: PANEL_CLASS,
126
+ children: /* @__PURE__ */ jsx(ScrollArea, {
127
+ className: CASCADER_SCROLL_CLASS,
128
+ children: body
129
+ })
130
+ });
131
+ }
132
+ //#endregion
133
+ export { CascaderColumnPanel, CascaderColumns };
134
+
135
+ //# sourceMappingURL=cascader-columns.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cascader-columns.js","names":["React","ComboboxPrimitive"],"sources":["../../../../src/components/reui/cascader/cascader-columns.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { Combobox as ComboboxPrimitive } from \"@base-ui/react\";\nimport { LoaderCircleIcon } from \"lucide-react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { ScrollArea } from \"../../ui/scroll-area\";\nimport type { CascaderColumn } from \"./cascader-context\";\nimport { useCascaderActions, useCascaderState } from \"./cascader-context\";\nimport { CascaderItem, getCascaderMoreProps } from \"./cascader-item\";\nimport {\n CASCADER_LIST_HEIGHT_CLASS,\n CASCADER_LIST_PAD_CLASS,\n CASCADER_ROOT_KEY,\n CASCADER_ROWS_CLASS,\n CASCADER_SCROLL_CLASS,\n warnCascaderOnce,\n} from \"./cascader-lib\";\n\nexport interface CascaderColumnsProps extends Omit<React.ComponentProps<\"div\">, \"children\"> {\n /** Width of each column. */\n columnWidth?: number | string;\n /** Height CAP per column. Falls back to the root `maxHeight`, then 24rem. */\n maxHeight?: number | string;\n /** Replaces the default panel; the seam a windowed column plugs into. */\n children?: (column: CascaderColumn) => React.ReactNode;\n}\n\n/**\n * Miller columns: the open trail side by side, one panel per level. Only the\n * DEEPEST column is a real listbox (Base UI owns exactly one list); the trail\n * behind is plain buttons, which keeps one state machine instead of a second,\n * 2D one. `CascaderInput` moves between columns with ArrowLeft/ArrowRight.\n */\nfunction CascaderColumns({\n className,\n columnWidth = 220,\n maxHeight: maxHeightProp,\n children,\n ...props\n}: CascaderColumnsProps) {\n const { maxHeight, mode, labels } = useCascaderActions();\n const { columns } = useCascaderState();\n\n // Before the early return, so the hook count is the same in both modes.\n React.useEffect(() => {\n if (process.env.NODE_ENV === \"production\") return;\n if (mode === \"columns\") return;\n warnCascaderOnce(\n `columns-outside-columns-mode:${mode}`,\n `\\`CascaderColumns\\` renders nothing in \\`mode=\"${mode}\"\\`, so \\`columnWidth\\` and everything else on it does nothing. Set \\`mode=\"columns\"\\` on the root, or render \\`CascaderList\\` instead.`,\n );\n }, [mode]);\n\n if (mode !== \"columns\") return null;\n\n const height = maxHeightProp ?? maxHeight;\n const toCss = (value: number | string) => (typeof value === \"number\" ? `${value}px` : value);\n\n return (\n <div\n data-slot=\"cascader-columns\"\n role=\"group\"\n aria-label={labels.columnsLabel}\n style={\n {\n \"--cascader-column-width\": toCss(columnWidth),\n /* Set only from an EXPLICIT cap: unset means \"24rem or what the\n viewport leaves\", via the `min()` fallback on the panel. A `?? 280`\n default here ignored short viewports and wasted tall ones. */\n ...(height != null ? { \"--cascader-max-height\": toCss(height) } : null),\n } as React.CSSProperties\n }\n className={cn(\n /* `max-h-full` with `min-h-0`: the trail is the panel's shrinking\n child, and the columns inside it size against this box. */\n \"flex max-h-full min-h-0 items-stretch overflow-x-auto overscroll-x-contain\",\n CASCADER_LIST_PAD_CLASS,\n className,\n )}\n {...props}\n >\n {columns.map((column) =>\n children ? (\n <React.Fragment key={column.depth}>{children(column)}</React.Fragment>\n ) : (\n <CascaderColumnPanel key={column.depth} column={column} />\n ),\n )}\n </div>\n );\n}\n\n/**\n * One column's box. `columnWidth` is the width of the LIST, not the box: under\n * `border-box` the 1px inline-start divider on every column but the first would\n * come out of the rows, so bordered columns are widened by that pixel. The box\n * is also the BOUND, the same `min(--available-height, cap)` the single list\n * uses, and the `ScrollArea` inside scrolls, so every column shows a thumb.\n */\nconst PANEL_CLASS = `flex w-(--cascader-column-width) shrink-0 flex-col overscroll-contain not-first:w-[calc(var(--cascader-column-width)_+_1px)] not-first:border-border/60 not-first:border-s ${CASCADER_LIST_HEIGHT_CLASS}`;\n\nexport interface CascaderColumnPanelProps {\n column: CascaderColumn;\n /** Replaces the panel's rows; the empty state still wins on an empty column. */\n children?: React.ReactNode;\n /** Containing block for the windowed column's absolutely positioned rows. */\n virtualized?: boolean;\n}\n\nfunction CascaderColumnPanel({ column, children, virtualized }: CascaderColumnPanelProps) {\n const { labels, baseId, isBranch, isSelectable, isSelected, isIndeterminate, retryLevel } =\n useCascaderActions();\n const { loadStates } = useCascaderState();\n\n // Keyed per level, not one global flag: columns load and land independently.\n const columnKey = column.parent?.value ?? CASCADER_ROOT_KEY;\n const loadState = loadStates.get(columnKey);\n\n let emptyBody: React.ReactNode = labels.empty;\n if (loadState?.error) {\n emptyBody = (\n <>\n {labels.error}{\" \"}\n <button\n type=\"button\"\n data-slot=\"cascader-retry\"\n onClick={() => retryLevel(columnKey)}\n className=\"rounded-md px-1 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 </>\n );\n } else if (loadState?.loading) {\n emptyBody = (\n <span className=\"flex items-center gap-1.5\">\n <LoaderCircleIcon className=\"size-3.5 animate-spin\" aria-hidden />\n {labels.loading}\n </span>\n );\n }\n\n const rows =\n column.items.length === 0 ? (\n <p\n data-slot=\"cascader-column-empty\"\n data-state={loadState?.error ? \"error\" : loadState?.loading ? \"loading\" : \"empty\"}\n className=\"px-2 py-1.5 text-muted-foreground text-sm\"\n >\n {emptyBody}\n </p>\n ) : (\n (children ??\n column.items.map((node, i) => {\n const open = node.value === column.activeValue;\n return (\n <CascaderItem\n key={node.value}\n node={node}\n /* A trail row must not compete for `aria-activedescendant`. */\n as={column.active ? \"option\" : \"button\"}\n depth={column.depth}\n /* Answered here, not in the row: the trail rows are memoised too. */\n branch={isBranch(node)}\n selectable={isSelectable(node)}\n selected={isSelected(node)}\n indeterminate={isIndeterminate(node)}\n {...getCascaderMoreProps(node, loadStates)}\n data-open={open || undefined}\n className={open ? \"bg-accent/60 text-accent-foreground\" : undefined}\n /* Set metadata is option-only; a trail row is a `role=\"button\"`. */\n {...(column.active\n ? {\n \"aria-setsize\": column.items.length,\n \"aria-posinset\": i + 1,\n }\n : null)}\n {...(!column.active && open\n ? {\n \"aria-expanded\": true,\n \"aria-controls\": `${baseId}-column-${column.depth + 1}`,\n }\n : null)}\n />\n );\n }))\n );\n\n const shared = {\n \"data-slot\": \"cascader-column\",\n \"data-active\": column.active || undefined,\n \"data-depth\": column.depth,\n // Addressable so the opening trail row can point `aria-controls` here, and\n // named even at the root, which has no parent label to borrow.\n id: `${baseId}-column-${column.depth}`,\n \"aria-label\": column.parent?.label ?? labels.rootLevel,\n // Conditional spread, never an explicit `undefined`: the active column is a\n // Base UI element, and its `mergeProps` iterates own keys.\n ...(virtualized ? { \"data-virtualized\": true } : null),\n };\n\n // A windowed row is absolutely positioned, so the ROWS' box is the containing\n // block, not the scrollport: it carries the padding the geometry is measured\n // against.\n const rowsClass = cn(CASCADER_ROWS_CLASS, virtualized && \"relative\");\n\n // The active column IS the Combobox list: only rows inside `Combobox.List`\n // reach the CompositeList, arrow-key navigation and `aria-activedescendant`.\n const body = column.active ? (\n <ComboboxPrimitive.List {...shared} className={rowsClass}>\n {rows}\n </ComboboxPrimitive.List>\n ) : (\n // A named `group`, not a second listbox competing with the active column.\n <div {...shared} role=\"group\" className={rowsClass}>\n {rows}\n </div>\n );\n\n return (\n <div\n data-slot=\"cascader-column-bounds\"\n /* Repeated from `shared`: this box, not the semantic element, owns the\n width, the divider and the height, so style hooks must reach it, and\n `:first-child` on the semantic element no longer means \"first column\"\n (it is its own scrollport's only child). */\n data-active={column.active || undefined}\n data-depth={column.depth}\n className={PANEL_CLASS}\n >\n <ScrollArea className={CASCADER_SCROLL_CLASS}>{body}</ScrollArea>\n </div>\n );\n}\n\nexport { CascaderColumnPanel, CascaderColumns };\n"],"mappings":";;;;;;;;;;;;;;;;;AAmCA,SAAS,gBAAgB,EACvB,WACA,cAAc,KACd,WAAW,eACX,UACA,GAAG,SACoB;CACvB,MAAM,EAAE,WAAW,MAAM,WAAW,mBAAmB;CACvD,MAAM,EAAE,YAAY,iBAAiB;CAGrC,QAAM,gBAAgB;EACpB,IAAI,QAAQ,IAAI,aAAa,cAAc;EAC3C,IAAI,SA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OAAO;EACnB,WAAW;EAEX,UAAA,oBAAC,YAAD;GAAY,WAAW;GAAwB,UAAA;EAAiB,CAAA;CAC7D,CAAA;AAET"}
@@ -0,0 +1,193 @@
1
+ import { a as CascaderFlatNode, d as CascaderLoadState, f as CascaderMode, g as CascaderSearchScope, o as CascaderIndex, p as CascaderNode, r as CascaderChangeReason, s as CascaderLabels, t as CascaderActionItem } from "../../../cascader-types-BnH6wYD-.js";
2
+ import * as React$1 from "react";
3
+ //#region src/components/reui/cascader/cascader-context.d.ts
4
+ /**
5
+ * Four contexts, not one: actions (config and callbacks, near-stable), state
6
+ * (every keystroke), render (`renderItem` identity) and highlight (every arrow
7
+ * key and pointer move). One combined context re-rendered every row on every
8
+ * keystroke, which is what made `React.memo` on the row worth nothing.
9
+ */
10
+ interface CascaderColumn<T = unknown> {
11
+ parent: CascaderNode<T> | null;
12
+ items: CascaderNode<T>[];
13
+ depth: number;
14
+ /** The node in this column that is drilled into, if any. */
15
+ activeValue: string | null;
16
+ /** Whether this is the deepest column, the one Base UI owns. */
17
+ active: boolean;
18
+ }
19
+ interface CascaderItemState<T = unknown> {
20
+ branch: boolean;
21
+ selected: boolean;
22
+ disabled: boolean;
23
+ depth: number;
24
+ count: number;
25
+ /** Ancestor chain, root first. Populated for deep-search rows. */
26
+ path: CascaderNode<T>[];
27
+ }
28
+ /**
29
+ * Everything derived from the query, the path and the selection. One keystroke
30
+ * rebuilds most of it, so never subscribe to it from a row.
31
+ */
32
+ interface CascaderStateContextValue<T = unknown> {
33
+ /** Same `useMemo` identity as the actions context's `index`. */
34
+ index: CascaderIndex<T>;
35
+ path: string[];
36
+ expanded: ReadonlySet<string>;
37
+ query: string;
38
+ currentParent: CascaderNode<T> | null;
39
+ /** Rows for the current level, already filtered. */
40
+ levelItems: CascaderNode<T>[];
41
+ deepResults: CascaderNode<T>[] | null;
42
+ /** What `Combobox.Root` is currently rendering, in render order. */
43
+ renderedItems: CascaderNode<T>[];
44
+ columns: CascaderColumn<T>[];
45
+ treeRows: CascaderFlatNode<T>[];
46
+ selectedValues: string[];
47
+ /** Selected nodes below each value, at any depth. Absent means zero. */
48
+ selectedDescendants: ReadonlyMap<string, number>;
49
+ /**
50
+ * Per level, keyed by parent value or `CASCADER_ROOT_KEY`. MEMBERSHIP is the
51
+ * discriminator: no entry means never fetched, an entry with no `loading`, no
52
+ * `error` and no children means fetched and genuinely empty.
53
+ */
54
+ loadStates: ReadonlyMap<string, CascaderLoadState>;
55
+ /** Async search, `null` when idle. Separate: a search belongs to no level. */
56
+ searchState: CascaderLoadState | null;
57
+ announcement: string;
58
+ }
59
+ declare const CascaderStateContext: React$1.Context<CascaderStateContextValue<unknown> | undefined>;
60
+ /**
61
+ * One provider serves every `T`, so the context holds an erased `unknown` value
62
+ * and this cast restores it. The primitive never inspects the payload.
63
+ */
64
+ declare function useCascaderState<T = unknown>(): CascaderStateContextValue<T>;
65
+ /**
66
+ * Config and callbacks, slow enough that a memoised row can subscribe: the
67
+ * mutators are `[]`-dep callbacks over a latest-props ref. The three predicates
68
+ * are the exception, read DURING RENDER where a ref written in an effect would
69
+ * return the previous commit's answer, so each is memoised on its own input.
70
+ */
71
+ interface CascaderActionsContextValue<T = unknown> {
72
+ index: CascaderIndex<T>;
73
+ mode: CascaderMode;
74
+ multiple: boolean;
75
+ /** Multi-select only: a commit propagates over the LOADED subtree. */
76
+ cascade: boolean;
77
+ /** Whether a BRANCH is committable. Per-LIST: the check gutter is a COLUMN. */
78
+ branchesSelectable: boolean;
79
+ /** Draws the SINGLE-SELECT check and its gutter. Ignored in multi-select. */
80
+ indicator: boolean;
81
+ expandTrigger?: "click" | "hover";
82
+ actions: CascaderActionItem[];
83
+ searchScope: CascaderSearchScope;
84
+ maxHeight?: number | string;
85
+ inline: boolean;
86
+ invalid: boolean;
87
+ /**
88
+ * Id prefix; columns are `${baseId}-column-${depth}`. The SCHEME is contract:
89
+ * the filters primitive's `FilterMenuPinKeeper` restores its highlight across
90
+ * a live re-pin through `${baseId}-column-0` and the `cascader-item` slot.
91
+ */
92
+ baseId: string;
93
+ labels: CascaderLabels;
94
+ /**
95
+ * Whether rows are WINDOWED. Also handed to `Combobox.Root`, which is what
96
+ * makes an explicit row `index` legal: forwarding one while this is false
97
+ * makes `aria-activedescendant` resolve to nothing. Latched per level.
98
+ */
99
+ virtualized: boolean;
100
+ /** Mounts a windowing renderer, returns its unregister. LAYOUT effect only. */
101
+ registerVirtualRenderer: () => () => void;
102
+ /** The root's `virtualize` prop. `undefined` means "decide by count". */
103
+ virtualize?: boolean;
104
+ virtualizeThreshold: number;
105
+ estimateRowSize: number;
106
+ overscan: number;
107
+ /** Tells "this level is empty" from "not fetched yet" before a load state. */
108
+ hasLoader: boolean;
109
+ /** Next page of a level. Latched: a page with nothing new is not re-asked. */
110
+ loadMore: (parentKey: string) => void;
111
+ retryLevel: (parentKey: string) => void;
112
+ /**
113
+ * Evicts one level's async cache, `null` for the root, so membership reads
114
+ * never-loaded. A level that is on screen when evicted refetches at once.
115
+ */
116
+ invalidateLevel: (value: string | null) => void;
117
+ /** Index as of the last commit. Use in the stable callbacks, not `index`. */
118
+ getIndex: () => CascaderIndex<T>;
119
+ getState: () => CascaderStateContextValue<T>;
120
+ /** Highlighted row or null. A getter: the highlight moves per arrow key. */
121
+ getHighlighted: () => CascaderNode<T> | null;
122
+ setPath: (next: string[] | ((prev: string[]) => string[])) => void;
123
+ pushLevel: (value: string) => void;
124
+ popLevel: () => void;
125
+ goToDepth: (depth: number) => void;
126
+ toggleExpanded: (value: string) => void;
127
+ /**
128
+ * Registers a footer submenu as open or closed. `Combobox` has no
129
+ * `FloatingTree`, so one Escape would dismiss the flyout AND the cascader;
130
+ * the root's `onOpenChange` guard cancels the close while any is open, from a
131
+ * ref so it reads as of that event without re-rendering the root.
132
+ */
133
+ setFlyoutOpen: (key: string, open: boolean) => void;
134
+ hasOpenFlyout: () => boolean;
135
+ setQuery: (next: string) => void;
136
+ /**
137
+ * Replaces the selection. `onValueChange` diffs it against the current one
138
+ * for its node and reason; pass `reason` only when the caller knows better.
139
+ */
140
+ setSelection: (values: string[], reason?: CascaderChangeReason) => void;
141
+ /** Commits a node, for rows outside the listbox such as ancestor columns. */
142
+ commit: (node: CascaderNode<T>) => void;
143
+ navigate: (node: CascaderNode<T>) => void;
144
+ /** Into `node` as a child of `depth`, replacing anything deeper. */
145
+ navigateAt: (node: CascaderNode<T>, depth: number) => void;
146
+ /** Never undefined: falls back to a remembered label, then a synthetic node. */
147
+ resolveNode: (value: string) => CascaderNode<T>;
148
+ isBranch: (node: CascaderNode<T>) => boolean;
149
+ isSelectable: (node: CascaderNode<T>) => boolean;
150
+ isSelected: (node: CascaderNode<T>) => boolean;
151
+ /** Always `false` without `cascade`: partial selection needs propagation. */
152
+ isIndeterminate: (node: CascaderNode<T>) => boolean;
153
+ /**
154
+ * O(1) read of `selectedDescendants`; a memoised row may not subscribe.
155
+ * Unlike `isIndeterminate` this answers in every mode.
156
+ */
157
+ selectedDescendantCount: (node: CascaderNode<T>) => number;
158
+ }
159
+ declare const CascaderActionsContext: React$1.Context<CascaderActionsContextValue<unknown> | undefined>;
160
+ declare function useCascaderActions<T = unknown>(): CascaderActionsContextValue<T>;
161
+ /**
162
+ * Their own context, republished every render. They cannot ride on the actions
163
+ * context: an inline closure read off a memoised object is whichever closure
164
+ * that object captured, so the row would call a stale prop over stale state.
165
+ */
166
+ interface CascaderRenderContextValue<T = unknown> {
167
+ renderItem?: (node: CascaderNode<T>, state: CascaderItemState<T>) => React$1.ReactNode;
168
+ renderLabel?: (node: CascaderNode<T>, state: CascaderItemState<T>) => React$1.ReactNode;
169
+ }
170
+ declare const CascaderRenderContext: React$1.Context<CascaderRenderContextValue<unknown>>;
171
+ declare function useCascaderRender<T = unknown>(): CascaderRenderContextValue<T>;
172
+ interface CascaderHighlight {
173
+ index: number;
174
+ value: string | null;
175
+ }
176
+ /**
177
+ * An external store, deliberately NOT React state: `onItemHighlighted` fires on
178
+ * every arrow key AND every pointer move over the list, so `setState` would
179
+ * re-render the whole root at mousemove rate. A store re-renders subscribers
180
+ * only, which inside the primitive is the virtualizer.
181
+ */
182
+ interface CascaderHighlightStore {
183
+ subscribe: (onStoreChange: () => void) => () => void;
184
+ getSnapshot: () => CascaderHighlight;
185
+ set: (next: CascaderHighlight) => void;
186
+ }
187
+ declare function createCascaderHighlightStore(): CascaderHighlightStore;
188
+ declare const CascaderHighlightContext: React$1.Context<CascaderHighlightStore>;
189
+ /** Subscribes to the highlight. Re-renders ONLY the calling component. */
190
+ declare function useCascaderHighlight(): CascaderHighlight;
191
+ //#endregion
192
+ export { CascaderActionsContext, CascaderActionsContextValue, CascaderColumn, CascaderHighlight, CascaderHighlightContext, CascaderHighlightStore, CascaderItemState, CascaderRenderContext, CascaderRenderContextValue, CascaderStateContext, CascaderStateContextValue, createCascaderHighlightStore, useCascaderActions, useCascaderHighlight, useCascaderRender, useCascaderState };
193
+ //# sourceMappingURL=cascader-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cascader-context.d.ts","names":[],"sources":["../../../../src/components/reui/cascader/cascader-context.tsx"],"mappings":";;;;;;;;;UA2BiB,eAAe;EAC9B,QAAQ,aAAa;EACrB,OAAO,aAAa;EACpB;;EAEA;;EAEA;;UAGe,kBAAkB;EACjC;EACA;EACA;EACA;EACA;;EAEA,MAAM,aAAa;;;;;;UAWJ,0BAA0B;;EAEzC,OAAO,cAAc;EACrB;EACA,UAAU;EACV;EACA,eAAe,aAAa;;EAE5B,YAAY,aAAa;EACzB,aAAa,aAAa;;EAE1B,eAAe,aAAa;EAC5B,SAAS,eAAe;EACxB,UAAU,iBAAiB;EAC3B;;EAEA,qBAAqB;;;;;;EAMrB,YAAY,oBAAoB;;EAEhC,aAAa;EACb;;cAGI,sBAAoB,QAAA,QAAA;;;;;iBAMV,iBAAiB,gBAAgB,0BAA0B;;;;;;;UAkB1D,4BAA4B;EAC3C,OAAO,cAAc;EACrB,MAAM;EACN;;EAEA;;EAEA;;EAEA;EACA;EACA,SAAS;EACT,aAAa;EACb;EACA;EACA;;;;;;EAMA;EACA,QAAQ;;;;;;EAOR;;EAEA;;EAEA;EACA;EACA;EACA;;EAGA;;EAEA,WAAW;EACX,aAAa;;;;;EAKb,kBAAkB;;EAGlB,gBAAgB,cAAc;EAC9B,gBAAgB,0BAA0B;;EAE1C,sBAAsB,aAAa;EAEnC,UAAU,mBAAmB;EAC7B,YAAY;EACZ;EACA,YAAY;EACZ,iBAAiB;;;;;;;EAOjB,gBAAgB,aAAa;EAC7B;EACA,WAAW;;;;;EAKX,eAAe,kBAAkB,SAAS;;EAE1C,SAAS,MAAM,aAAa;EAC5B,WAAW,MAAM,aAAa;;EAE9B,aAAa,MAAM,aAAa,IAAI;;EAEpC,cAAc,kBAAkB,aAAa;EAC7C,WAAW,MAAM,aAAa;EAC9B,eAAe,MAAM,aAAa;EAClC,aAAa,MAAM,aAAa;;EAEhC,kBAAkB,MAAM,aAAa;;;;;EAKrC,0BAA0B,MAAM,aAAa;;cAGzC,wBAAsB,QAAA,QAAA;iBAIZ,mBAAmB,gBAAgB,4BAA4B;;;;;;UAiB9D,2BAA2B;EAC1C,cAAc,MAAM,aAAa,IAAI,OAAO,kBAAkB,OAAO,QAAM;EAC3E,eAAe,MAAM,aAAa,IAAI,OAAO,kBAAkB,OAAO,QAAM;;cAGxE,uBAAqB,QAAA,QAAA;iBAEX,kBAAkB,gBAAgB,2BAA2B;UAQ5D;EACf;EACA;;;;;;;;UASe;EACf,YAAY;EACZ,mBAAmB;EACnB,MAAM,MAAM;;iBAKE,gCAAgC;cA0B1C,0BAAwB,QAAA,QAAA;;iBAId,wBAAwB"}
@@ -0,0 +1,59 @@
1
+ "use client";
2
+ import * as React$1 from "react";
3
+ //#region src/components/reui/cascader/cascader-context.tsx
4
+ const CascaderStateContext = React$1.createContext(void 0);
5
+ /**
6
+ * One provider serves every `T`, so the context holds an erased `unknown` value
7
+ * and this cast restores it. The primitive never inspects the payload.
8
+ */
9
+ function useCascaderState() {
10
+ const context = React$1.useContext(CascaderStateContext);
11
+ if (!context) throw new Error("useCascaderState must be used within a Cascader");
12
+ return context;
13
+ }
14
+ const CascaderActionsContext = React$1.createContext(void 0);
15
+ function useCascaderActions() {
16
+ const context = React$1.useContext(CascaderActionsContext);
17
+ if (!context) throw new Error("useCascaderActions must be used within a Cascader");
18
+ return context;
19
+ }
20
+ const CascaderRenderContext = React$1.createContext({});
21
+ function useCascaderRender() {
22
+ return React$1.useContext(CascaderRenderContext);
23
+ }
24
+ const NO_HIGHLIGHT = {
25
+ index: -1,
26
+ value: null
27
+ };
28
+ function createCascaderHighlightStore() {
29
+ let snapshot = NO_HIGHLIGHT;
30
+ const listeners = /* @__PURE__ */ new Set();
31
+ return {
32
+ subscribe(onStoreChange) {
33
+ listeners.add(onStoreChange);
34
+ return () => {
35
+ listeners.delete(onStoreChange);
36
+ };
37
+ },
38
+ getSnapshot() {
39
+ return snapshot;
40
+ },
41
+ set(next) {
42
+ if (next.index === snapshot.index && next.value === snapshot.value) return;
43
+ snapshot = next;
44
+ for (const listener of listeners) listener();
45
+ }
46
+ };
47
+ }
48
+ /** Shared and permanently empty, so the hook degrades outside a `Cascader`. */
49
+ const FALLBACK_HIGHLIGHT_STORE = createCascaderHighlightStore();
50
+ const CascaderHighlightContext = React$1.createContext(FALLBACK_HIGHLIGHT_STORE);
51
+ /** Subscribes to the highlight. Re-renders ONLY the calling component. */
52
+ function useCascaderHighlight() {
53
+ const store = React$1.useContext(CascaderHighlightContext);
54
+ return React$1.useSyncExternalStore(store.subscribe, store.getSnapshot, store.getSnapshot);
55
+ }
56
+ //#endregion
57
+ export { CascaderActionsContext, CascaderHighlightContext, CascaderRenderContext, CascaderStateContext, createCascaderHighlightStore, useCascaderActions, useCascaderHighlight, useCascaderRender, useCascaderState };
58
+
59
+ //# sourceMappingURL=cascader-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cascader-context.js","names":["React"],"sources":["../../../../src/components/reui/cascader/cascader-context.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\n\nimport type {\n CascaderActionItem,\n CascaderChangeReason,\n CascaderFlatNode,\n CascaderIndex,\n CascaderLabels,\n CascaderLoadState,\n CascaderMode,\n CascaderNode,\n CascaderSearchScope,\n} from \"./cascader-types\";\n\n/**\n * Four contexts, not one: actions (config and callbacks, near-stable), state\n * (every keystroke), render (`renderItem` identity) and highlight (every arrow\n * key and pointer move). One combined context re-rendered every row on every\n * keystroke, which is what made `React.memo` on the row worth nothing.\n */\n\n/* -------------------------------------------------------------------------- */\n/* Shared types */\n/* -------------------------------------------------------------------------- */\n\nexport interface CascaderColumn<T = unknown> {\n parent: CascaderNode<T> | null;\n items: CascaderNode<T>[];\n depth: number;\n /** The node in this column that is drilled into, if any. */\n activeValue: string | null;\n /** Whether this is the deepest column, the one Base UI owns. */\n active: boolean;\n}\n\nexport interface CascaderItemState<T = unknown> {\n branch: boolean;\n selected: boolean;\n disabled: boolean;\n depth: number;\n count: number;\n /** Ancestor chain, root first. Populated for deep-search rows. */\n path: CascaderNode<T>[];\n}\n\n/* -------------------------------------------------------------------------- */\n/* State */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Everything derived from the query, the path and the selection. One keystroke\n * rebuilds most of it, so never subscribe to it from a row.\n */\nexport interface CascaderStateContextValue<T = unknown> {\n /** Same `useMemo` identity as the actions context's `index`. */\n index: CascaderIndex<T>;\n path: string[];\n expanded: ReadonlySet<string>;\n query: string;\n currentParent: CascaderNode<T> | null;\n /** Rows for the current level, already filtered. */\n levelItems: CascaderNode<T>[];\n deepResults: CascaderNode<T>[] | null;\n /** What `Combobox.Root` is currently rendering, in render order. */\n renderedItems: CascaderNode<T>[];\n columns: CascaderColumn<T>[];\n treeRows: CascaderFlatNode<T>[];\n selectedValues: string[];\n /** Selected nodes below each value, at any depth. Absent means zero. */\n selectedDescendants: ReadonlyMap<string, number>;\n /**\n * Per level, keyed by parent value or `CASCADER_ROOT_KEY`. MEMBERSHIP is the\n * discriminator: no entry means never fetched, an entry with no `loading`, no\n * `error` and no children means fetched and genuinely empty.\n */\n loadStates: ReadonlyMap<string, CascaderLoadState>;\n /** Async search, `null` when idle. Separate: a search belongs to no level. */\n searchState: CascaderLoadState | null;\n announcement: string;\n}\n\nconst CascaderStateContext = React.createContext<CascaderStateContextValue | undefined>(undefined);\n\n/**\n * One provider serves every `T`, so the context holds an erased `unknown` value\n * and this cast restores it. The primitive never inspects the payload.\n */\nexport function useCascaderState<T = unknown>(): CascaderStateContextValue<T> {\n const context = React.useContext(CascaderStateContext);\n if (!context) {\n throw new Error(\"useCascaderState must be used within a Cascader\");\n }\n return context as unknown as CascaderStateContextValue<T>;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Actions */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Config and callbacks, slow enough that a memoised row can subscribe: the\n * mutators are `[]`-dep callbacks over a latest-props ref. The three predicates\n * are the exception, read DURING RENDER where a ref written in an effect would\n * return the previous commit's answer, so each is memoised on its own input.\n */\nexport interface CascaderActionsContextValue<T = unknown> {\n index: CascaderIndex<T>;\n mode: CascaderMode;\n multiple: boolean;\n /** Multi-select only: a commit propagates over the LOADED subtree. */\n cascade: boolean;\n /** Whether a BRANCH is committable. Per-LIST: the check gutter is a COLUMN. */\n branchesSelectable: boolean;\n /** Draws the SINGLE-SELECT check and its gutter. Ignored in multi-select. */\n indicator: boolean;\n expandTrigger?: \"click\" | \"hover\";\n actions: CascaderActionItem[];\n searchScope: CascaderSearchScope;\n maxHeight?: number | string;\n inline: boolean;\n invalid: boolean;\n /**\n * Id prefix; columns are `${baseId}-column-${depth}`. The SCHEME is contract:\n * the filters primitive's `FilterMenuPinKeeper` restores its highlight across\n * a live re-pin through `${baseId}-column-0` and the `cascader-item` slot.\n */\n baseId: string;\n labels: CascaderLabels;\n\n /**\n * Whether rows are WINDOWED. Also handed to `Combobox.Root`, which is what\n * makes an explicit row `index` legal: forwarding one while this is false\n * makes `aria-activedescendant` resolve to nothing. Latched per level.\n */\n virtualized: boolean;\n /** Mounts a windowing renderer, returns its unregister. LAYOUT effect only. */\n registerVirtualRenderer: () => () => void;\n /** The root's `virtualize` prop. `undefined` means \"decide by count\". */\n virtualize?: boolean;\n virtualizeThreshold: number;\n estimateRowSize: number;\n overscan: number;\n\n /** Tells \"this level is empty\" from \"not fetched yet\" before a load state. */\n hasLoader: boolean;\n /** Next page of a level. Latched: a page with nothing new is not re-asked. */\n loadMore: (parentKey: string) => void;\n retryLevel: (parentKey: string) => void;\n /**\n * Evicts one level's async cache, `null` for the root, so membership reads\n * never-loaded. A level that is on screen when evicted refetches at once.\n */\n invalidateLevel: (value: string | null) => void;\n\n /** Index as of the last commit. Use in the stable callbacks, not `index`. */\n getIndex: () => CascaderIndex<T>;\n getState: () => CascaderStateContextValue<T>;\n /** Highlighted row or null. A getter: the highlight moves per arrow key. */\n getHighlighted: () => CascaderNode<T> | null;\n\n setPath: (next: string[] | ((prev: string[]) => string[])) => void;\n pushLevel: (value: string) => void;\n popLevel: () => void;\n goToDepth: (depth: number) => void;\n toggleExpanded: (value: string) => void;\n /**\n * Registers a footer submenu as open or closed. `Combobox` has no\n * `FloatingTree`, so one Escape would dismiss the flyout AND the cascader;\n * the root's `onOpenChange` guard cancels the close while any is open, from a\n * ref so it reads as of that event without re-rendering the root.\n */\n setFlyoutOpen: (key: string, open: boolean) => void;\n hasOpenFlyout: () => boolean;\n setQuery: (next: string) => void;\n /**\n * Replaces the selection. `onValueChange` diffs it against the current one\n * for its node and reason; pass `reason` only when the caller knows better.\n */\n setSelection: (values: string[], reason?: CascaderChangeReason) => void;\n /** Commits a node, for rows outside the listbox such as ancestor columns. */\n commit: (node: CascaderNode<T>) => void;\n navigate: (node: CascaderNode<T>) => void;\n /** Into `node` as a child of `depth`, replacing anything deeper. */\n navigateAt: (node: CascaderNode<T>, depth: number) => void;\n /** Never undefined: falls back to a remembered label, then a synthetic node. */\n resolveNode: (value: string) => CascaderNode<T>;\n isBranch: (node: CascaderNode<T>) => boolean;\n isSelectable: (node: CascaderNode<T>) => boolean;\n isSelected: (node: CascaderNode<T>) => boolean;\n /** Always `false` without `cascade`: partial selection needs propagation. */\n isIndeterminate: (node: CascaderNode<T>) => boolean;\n /**\n * O(1) read of `selectedDescendants`; a memoised row may not subscribe.\n * Unlike `isIndeterminate` this answers in every mode.\n */\n selectedDescendantCount: (node: CascaderNode<T>) => number;\n}\n\nconst CascaderActionsContext = React.createContext<CascaderActionsContextValue | undefined>(\n undefined,\n);\n\nexport function useCascaderActions<T = unknown>(): CascaderActionsContextValue<T> {\n const context = React.useContext(CascaderActionsContext);\n if (!context) {\n throw new Error(\"useCascaderActions must be used within a Cascader\");\n }\n return context as unknown as CascaderActionsContextValue<T>;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Render props */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Their own context, republished every render. They cannot ride on the actions\n * context: an inline closure read off a memoised object is whichever closure\n * that object captured, so the row would call a stale prop over stale state.\n */\nexport interface CascaderRenderContextValue<T = unknown> {\n renderItem?: (node: CascaderNode<T>, state: CascaderItemState<T>) => React.ReactNode;\n renderLabel?: (node: CascaderNode<T>, state: CascaderItemState<T>) => React.ReactNode;\n}\n\nconst CascaderRenderContext = React.createContext<CascaderRenderContextValue>({});\n\nexport function useCascaderRender<T = unknown>(): CascaderRenderContextValue<T> {\n return React.useContext(CascaderRenderContext) as CascaderRenderContextValue<T>;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Highlight store */\n/* -------------------------------------------------------------------------- */\n\nexport interface CascaderHighlight {\n index: number;\n value: string | null;\n}\n\n/**\n * An external store, deliberately NOT React state: `onItemHighlighted` fires on\n * every arrow key AND every pointer move over the list, so `setState` would\n * re-render the whole root at mousemove rate. A store re-renders subscribers\n * only, which inside the primitive is the virtualizer.\n */\nexport interface CascaderHighlightStore {\n subscribe: (onStoreChange: () => void) => () => void;\n getSnapshot: () => CascaderHighlight;\n set: (next: CascaderHighlight) => void;\n}\n\nconst NO_HIGHLIGHT: CascaderHighlight = { index: -1, value: null };\n\nexport function createCascaderHighlightStore(): CascaderHighlightStore {\n let snapshot: CascaderHighlight = NO_HIGHLIGHT;\n const listeners = new Set<() => void>();\n\n return {\n subscribe(onStoreChange) {\n listeners.add(onStoreChange);\n return () => {\n listeners.delete(onStoreChange);\n };\n },\n // The SAME object until something changes; `useSyncExternalStore` needs it.\n getSnapshot() {\n return snapshot;\n },\n set(next) {\n if (next.index === snapshot.index && next.value === snapshot.value) return;\n snapshot = next;\n for (const listener of listeners) listener();\n },\n };\n}\n\n/** Shared and permanently empty, so the hook degrades outside a `Cascader`. */\nconst FALLBACK_HIGHLIGHT_STORE = createCascaderHighlightStore();\n\nconst CascaderHighlightContext =\n React.createContext<CascaderHighlightStore>(FALLBACK_HIGHLIGHT_STORE);\n\n/** Subscribes to the highlight. Re-renders ONLY the calling component. */\nexport function useCascaderHighlight(): CascaderHighlight {\n const store = React.useContext(CascaderHighlightContext);\n return React.useSyncExternalStore(store.subscribe, store.getSnapshot, store.getSnapshot);\n}\n\nexport {\n CascaderActionsContext,\n CascaderHighlightContext,\n CascaderRenderContext,\n CascaderStateContext,\n};\n"],"mappings":";;;AAmFA,MAAM,uBAAuBA,QAAM,cAAqD,KAAA,CAAS;;;;;AAMjG,SAAgB,mBAA8D;CAC5E,MAAM,UAAUA,QAAM,WAAW,oBAAoB;CACrD,IAAI,CAAC,SACH,MAAM,IAAI,MAAM,iDAAiD;CAEnE,OAAO;AACT;AAyGA,MAAM,yBAAyBA,QAAM,cACnC,KAAA,CACF;AAEA,SAAgB,qBAAkE;CAChF,MAAM,UAAUA,QAAM,WAAW,sBAAsB;CACvD,IAAI,CAAC,SACH,MAAM,IAAI,MAAM,mDAAmD;CAErE,OAAO;AACT;AAgBA,MAAM,wBAAwBA,QAAM,cAA0C,CAAC,CAAC;AAEhF,SAAgB,oBAAgE;CAC9E,OAAOA,QAAM,WAAW,qBAAqB;AAC/C;AAuBA,MAAM,eAAkC;CAAE,OAAO;CAAI,OAAO;AAAK;AAEjE,SAAgB,+BAAuD;CACrE,IAAI,WAA8B;CAClC,MAAM,4BAAY,IAAI,IAAgB;CAEtC,OAAO;EACL,UAAU,eAAe;GACvB,UAAU,IAAI,aAAa;GAC3B,aAAa;IACX,UAAU,OAAO,aAAa;GAChC;EACF;EAEA,cAAc;GACZ,OAAO;EACT;EACA,IAAI,MAAM;GACR,IAAI,KAAK,UAAU,SAAS,SAAS,KAAK,UAAU,SAAS,OAAO;GACpE,WAAW;GACX,KAAK,MAAM,YAAY,WAAW,SAAS;EAC7C;CACF;AACF;;AAGA,MAAM,2BAA2B,6BAA6B;AAE9D,MAAM,2BACJA,QAAM,cAAsC,wBAAwB;;AAGtE,SAAgB,uBAA0C;CACxD,MAAM,QAAQA,QAAM,WAAW,wBAAwB;CACvD,OAAOA,QAAM,qBAAqB,MAAM,WAAW,MAAM,aAAa,MAAM,WAAW;AACzF"}