@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,576 @@
1
+ "use client";
2
+ //#region src/components/reui/cascader/cascader-lib.tsx
3
+ /** Root level key in `childrenOf`. NUL-prefixed so no real value collides. */
4
+ const CASCADER_ROOT_KEY = "\0root";
5
+ /**
6
+ * Paging pseudo-node prefix. Written as an escape sequence, not a raw 0x00
7
+ * byte: a literal NUL makes this module read as binary and `grep -I` skips it.
8
+ */
9
+ const CASCADER_MORE_PREFIX = "\0more:";
10
+ /**
11
+ * The four scroll classes. In the lib because `cascader-columns.tsx` needs them
12
+ * too and must not import `cascader.tsx`. Shell > bound > scrollport > rows.
13
+ */
14
+ /**
15
+ * The bound. `min()` over an undefined custom property is an INVALID
16
+ * declaration that drops the whole max-height, hence the `100vh` fallback: an
17
+ * inline panel has no positioner, so no `--available-height`. `24rem` is the
18
+ * default cap, so the common case sets no variable at all.
19
+ */
20
+ const CASCADER_LIST_HEIGHT_CLASS = "max-h-[min(var(--available-height,100vh),var(--cascader-max-height,24rem))]";
21
+ /**
22
+ * Each style's list padding: rows take it as `padding`, the scrollport as
23
+ * `scroll-padding` floored at 4px so lyra's `0` does not strand a row.
24
+ * Mirrored per style from `registry/styles/style-*.css`; keep them in step.
25
+ */
26
+ const CASCADER_LIST_PAD_CLASS = "[--cascader-list-pad:4px]";
27
+ /** The scrollport: a `max-h-*` on the ScrollArea ROOT bounds nothing. */
28
+ const CASCADER_SCROLL_CLASS = "size-full min-h-0 **:data-[slot=scroll-area-viewport]:h-full **:data-[slot=scroll-area-viewport]:overscroll-contain **:data-[slot=scroll-area-viewport]:scroll-py-[max(var(--cascader-list-pad,4px),4px)]";
29
+ /** The rows' box; `data-empty:p-0` keeps an empty state from double inset. */
30
+ const CASCADER_ROWS_CLASS = "p-(--cascader-list-pad,4px) data-empty:p-0";
31
+ /**
32
+ * What counts as a keyboard stop. Base UI's ScrollArea viewport makes ITSELF
33
+ * tabbable when content overflows (`hiddenState.x && hiddenState.y ? -1 : 0`),
34
+ * an unnamed stop per level that `ui/scroll-area.tsx` will not let us suppress.
35
+ */
36
+ const CASCADER_TAB_STOP_SELECTOR = "a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex=\"-1\"])";
37
+ /** The stop to step over: nothing here focuses the scrollport on purpose. */
38
+ const CASCADER_TAB_SKIP_SELECTOR = "[data-slot=\"scroll-area-viewport\"]";
39
+ /** Out of the tab order whatever they contain; layout is never consulted. */
40
+ const CASCADER_TAB_HIDDEN_SELECTOR = "[hidden],[inert],[aria-hidden='true']";
41
+ /** The panel's real keyboard stops, in DOM order. */
42
+ function getCascaderTabStops(panel) {
43
+ return Array.from(panel.querySelectorAll(CASCADER_TAB_STOP_SELECTOR)).filter((stop) => stop.getAttribute("tabindex") !== "-1" && !stop.matches(CASCADER_TAB_SKIP_SELECTOR) && !stop.closest(CASCADER_TAB_HIDDEN_SELECTOR));
44
+ }
45
+ /** The footer's own stops; an `aria-disabled` command still counts as one. */
46
+ function getCascaderFooterStops(scope) {
47
+ const footer = scope.matches("[data-slot=\"cascader-footer\"]") ? scope : scope.querySelector("[data-slot=\"cascader-footer\"]");
48
+ if (!footer) return [];
49
+ return getCascaderTabStops(footer);
50
+ }
51
+ /** Where Tab lands, or `null` to let the browser out: focus is never trapped. */
52
+ function getCascaderTabTarget(panel, from, backwards) {
53
+ const stops = getCascaderTabStops(panel);
54
+ if (stops.length === 0 || !from) return null;
55
+ const index = stops.indexOf(from);
56
+ if (index !== -1) return stops[index + (backwards ? -1 : 1)] ?? null;
57
+ if (backwards) {
58
+ for (let i = stops.length - 1; i >= 0; i -= 1) if (from.compareDocumentPosition(stops[i]) & Node.DOCUMENT_POSITION_PRECEDING) return stops[i];
59
+ return null;
60
+ }
61
+ for (const stop of stops) if (from.compareDocumentPosition(stop) & Node.DOCUMENT_POSITION_FOLLOWING) return stop;
62
+ return null;
63
+ }
64
+ /**
65
+ * The writing direction at `element`. `DirectionProvider` may only vote yes:
66
+ * unmounted it answers `"ltr"`, which would override a real `<html dir="rtl">`.
67
+ */
68
+ function isCascaderRtl(element, provided) {
69
+ if (provided === "rtl") return true;
70
+ const explicit = element.closest("[dir]")?.getAttribute("dir")?.toLowerCase();
71
+ if (explicit === "rtl") return true;
72
+ if (explicit === "ltr") return false;
73
+ return element.ownerDocument?.defaultView?.getComputedStyle(element).direction === "rtl";
74
+ }
75
+ /**
76
+ * The paging row as a REAL node, not a DOM-only row after the list: every index
77
+ * Base UI hands out indexes the RENDERED array, so a DOM-only row shifts them.
78
+ */
79
+ function createCascaderMoreNode(parentKey, loadedCount = 0) {
80
+ return {
81
+ value: `${CASCADER_MORE_PREFIX}${parentKey}`,
82
+ label: "",
83
+ count: loadedCount
84
+ };
85
+ }
86
+ function isCascaderMoreNode(node) {
87
+ return node.value.startsWith(CASCADER_MORE_PREFIX);
88
+ }
89
+ /** The level key a paging pseudo-node belongs to, or `null` for a real node. */
90
+ function getCascaderMoreParent(node) {
91
+ if (!isCascaderMoreNode(node)) return null;
92
+ return node.value.slice(6);
93
+ }
94
+ /** Either input shape into one index. Cycle-guarded depths; first wins. */
95
+ function buildCascaderIndex(items, getParent) {
96
+ const byValue = /* @__PURE__ */ new Map();
97
+ const childrenOf = /* @__PURE__ */ new Map();
98
+ const parentOf = /* @__PURE__ */ new Map();
99
+ const depthOf = /* @__PURE__ */ new Map();
100
+ const all = [];
101
+ const push = (parentKey, node) => {
102
+ const bucket = childrenOf.get(parentKey);
103
+ if (bucket) bucket.push(node);
104
+ else childrenOf.set(parentKey, [node]);
105
+ };
106
+ if (getParent) {
107
+ for (const node of items ?? []) {
108
+ if (node == null) {
109
+ if (process.env.NODE_ENV !== "production") warnCascaderOnce("nullish-entry", "Ignored a null or undefined entry in `items` or `children`. Check the arrays you pass in.");
110
+ continue;
111
+ }
112
+ if (byValue.has(node.value)) continue;
113
+ byValue.set(node.value, node);
114
+ all.push(node);
115
+ }
116
+ for (const node of all) {
117
+ const rawParent = getParent(node);
118
+ const parent = rawParent != null && byValue.has(rawParent) ? rawParent : null;
119
+ parentOf.set(node.value, parent);
120
+ push(parent ?? "\0root", node);
121
+ }
122
+ for (const node of all) {
123
+ let depth = 0;
124
+ let cursor = parentOf.get(node.value) ?? null;
125
+ const seen = /* @__PURE__ */ new Set([node.value]);
126
+ while (cursor != null && !seen.has(cursor)) {
127
+ seen.add(cursor);
128
+ depth += 1;
129
+ cursor = parentOf.get(cursor) ?? null;
130
+ }
131
+ depthOf.set(node.value, depth);
132
+ }
133
+ } else {
134
+ const walk = (nodes, parent, depth) => {
135
+ for (const node of nodes ?? []) {
136
+ if (node == null) {
137
+ if (process.env.NODE_ENV !== "production") warnCascaderOnce("nullish-entry", "Ignored a null or undefined entry in `items` or `children`. Check the arrays you pass in.");
138
+ continue;
139
+ }
140
+ if (byValue.has(node.value)) continue;
141
+ byValue.set(node.value, node);
142
+ parentOf.set(node.value, parent);
143
+ depthOf.set(node.value, depth);
144
+ all.push(node);
145
+ push(parent ?? "\0root", node);
146
+ if (node.children?.length) walk(node.children, node.value, depth + 1);
147
+ }
148
+ };
149
+ walk(items, null, 0);
150
+ }
151
+ return {
152
+ byValue,
153
+ childrenOf,
154
+ parentOf,
155
+ depthOf,
156
+ roots: childrenOf.get("\0root") ?? [],
157
+ all
158
+ };
159
+ }
160
+ /**
161
+ * Folds loaded pages into an index built from `items`, so a re-render with a
162
+ * new `items` array keeps what the user drilled into. Static `items` wins;
163
+ * `detached` is `byValue` ONLY, or deep search doubles it and `childrenOf` lies.
164
+ */
165
+ function mergeCascaderIndex(base, pages, detached) {
166
+ if (pages.size === 0 && !detached?.size) return base;
167
+ const byValue = new Map(base.byValue);
168
+ const childrenOf = new Map(base.childrenOf);
169
+ const parentOf = new Map(base.parentOf);
170
+ const depthOf = new Map(base.depthOf);
171
+ const copied = /* @__PURE__ */ new Set();
172
+ const append = (parentKey, node) => {
173
+ let bucket = childrenOf.get(parentKey);
174
+ if (!copied.has(parentKey)) {
175
+ bucket = bucket ? bucket.slice() : [];
176
+ childrenOf.set(parentKey, bucket);
177
+ copied.add(parentKey);
178
+ }
179
+ bucket.push(node);
180
+ };
181
+ const insert = (parentKey, nodes) => {
182
+ for (const node of nodes) {
183
+ if (byValue.has(node.value)) continue;
184
+ byValue.set(node.value, node);
185
+ parentOf.set(node.value, parentKey === "\0root" ? null : parentKey);
186
+ append(parentKey, node);
187
+ if (node.children?.length) insert(node.value, node.children);
188
+ }
189
+ };
190
+ for (const [parentKey, nodes] of pages) insert(parentKey, nodes);
191
+ for (const value of byValue.keys()) {
192
+ if (depthOf.has(value)) continue;
193
+ let depth = 0;
194
+ let cursor = parentOf.get(value) ?? null;
195
+ const seen = /* @__PURE__ */ new Set([value]);
196
+ while (cursor != null && !seen.has(cursor)) {
197
+ seen.add(cursor);
198
+ depth += 1;
199
+ cursor = parentOf.get(cursor) ?? null;
200
+ }
201
+ depthOf.set(value, depth);
202
+ }
203
+ const roots = childrenOf.get("\0root") ?? [];
204
+ const all = [];
205
+ const visited = /* @__PURE__ */ new Set();
206
+ const walk = (nodes) => {
207
+ for (const node of nodes) {
208
+ if (visited.has(node.value)) continue;
209
+ visited.add(node.value);
210
+ all.push(node);
211
+ const children = childrenOf.get(node.value);
212
+ if (children?.length) walk(children);
213
+ }
214
+ };
215
+ walk(roots);
216
+ for (const [value, node] of byValue) {
217
+ if (visited.has(value)) continue;
218
+ visited.add(value);
219
+ all.push(node);
220
+ }
221
+ if (detached) for (const [value, node] of detached) {
222
+ if (byValue.has(value)) continue;
223
+ byValue.set(value, node);
224
+ }
225
+ return {
226
+ byValue,
227
+ childrenOf,
228
+ parentOf,
229
+ depthOf,
230
+ roots,
231
+ all
232
+ };
233
+ }
234
+ /** Children of `parent`, or the root level when `parent` is nullish. */
235
+ function getCascaderChildren(index, parent) {
236
+ return index.childrenOf.get(parent ?? "\0root") ?? [];
237
+ }
238
+ /** A branch has known children, or `hasChildren` for an unfetched level. */
239
+ function isCascaderBranch(index, node) {
240
+ if (node.hasChildren) return true;
241
+ return (index.childrenOf.get(node.value)?.length ?? 0) > 0;
242
+ }
243
+ /** Trailing count for the default row. Explicit `count` wins over the tree. */
244
+ function getCascaderCount(index, node) {
245
+ if (typeof node.count === "number") return node.count;
246
+ return index.childrenOf.get(node.value)?.length ?? 0;
247
+ }
248
+ /** Whether a node may be committed as a selection. */
249
+ function isCascaderSelectable(index, node, selectable) {
250
+ if (isCascaderMoreNode(node)) return false;
251
+ if (node.disabled) return false;
252
+ {
253
+ const seen = /* @__PURE__ */ new Set([node.value]);
254
+ let cursor = index.parentOf.get(node.value) ?? null;
255
+ while (cursor != null && !seen.has(cursor)) {
256
+ seen.add(cursor);
257
+ if (index.byValue.get(cursor)?.disabled) return false;
258
+ cursor = index.parentOf.get(cursor) ?? null;
259
+ }
260
+ }
261
+ if (typeof selectable === "function") return selectable(node);
262
+ if (selectable === "any") return true;
263
+ return !isCascaderBranch(index, node);
264
+ }
265
+ /** Ancestor chain for `value`, root first. Empty while async data loads. */
266
+ function getCascaderPath(index, value) {
267
+ if (value == null) return [];
268
+ const chain = [];
269
+ const seen = /* @__PURE__ */ new Set();
270
+ let cursor = value;
271
+ while (cursor != null && !seen.has(cursor)) {
272
+ seen.add(cursor);
273
+ const node = index.byValue.get(cursor);
274
+ if (!node) break;
275
+ chain.push(node);
276
+ cursor = index.parentOf.get(cursor) ?? null;
277
+ }
278
+ return chain.reverse();
279
+ }
280
+ /**
281
+ * `toLocaleLowerCase`, not `toLowerCase`: the invariant mapping turns Turkish
282
+ * "I" into "i" not "ı", so "ışık" would never match "IŞIK". Both sides fold here.
283
+ */
284
+ function foldCascaderText(text) {
285
+ return text.toLocaleLowerCase();
286
+ }
287
+ /** Folds once so callers can hoist the cost out of a per-node loop. */
288
+ function normalizeCascaderQuery(query) {
289
+ return foldCascaderText(query.trim());
290
+ }
291
+ /** Case-insensitive substring over label and keywords; pre-fold the query. */
292
+ function matchesCascaderQuery(node, normalized) {
293
+ if (!normalized) return true;
294
+ if (foldCascaderText(node.label ?? "").includes(normalized)) return true;
295
+ if (node.keywords) {
296
+ for (const keyword of node.keywords) if (foldCascaderText(keyword).includes(normalized)) return true;
297
+ }
298
+ return false;
299
+ }
300
+ /** Filters one level in place-order. Returns the input when the query is empty. */
301
+ function filterCascaderLevel(nodes, query, matches = matchesCascaderQuery) {
302
+ const normalized = normalizeCascaderQuery(query);
303
+ if (!normalized) return nodes;
304
+ return nodes.filter((node) => matches(node, normalized));
305
+ }
306
+ /** Searches every node, optionally under `within`, in one pass over `all`. */
307
+ function searchCascaderDeep(index, query, options = {}) {
308
+ const normalized = normalizeCascaderQuery(query);
309
+ if (!normalized) return [];
310
+ const { within, limit = 200, matches = matchesCascaderQuery } = options;
311
+ const results = [];
312
+ const ancestry = within == null ? null : /* @__PURE__ */ new Map();
313
+ const isWithin = (node) => {
314
+ if (within == null || !ancestry) return true;
315
+ const trail = [];
316
+ let answer = false;
317
+ let cursor = index.parentOf.get(node.value);
318
+ while (cursor != null) {
319
+ if (cursor === within) {
320
+ answer = true;
321
+ break;
322
+ }
323
+ const cached = ancestry.get(cursor);
324
+ if (cached !== void 0) {
325
+ answer = cached;
326
+ break;
327
+ }
328
+ ancestry.set(cursor, false);
329
+ trail.push(cursor);
330
+ cursor = index.parentOf.get(cursor) ?? null;
331
+ }
332
+ if (answer) for (const value of trail) ancestry.set(value, true);
333
+ return answer;
334
+ };
335
+ for (const node of index.all) {
336
+ if (results.length >= limit) break;
337
+ if (!matches(node, normalized)) continue;
338
+ if (!isWithin(node)) continue;
339
+ results.push(node);
340
+ }
341
+ return results;
342
+ }
343
+ /**
344
+ * Flattens the tree into tree mode's visible rows. A `sentinels` paging row
345
+ * COUNTS as a sibling in `aria-setsize`: it holds an index of its own.
346
+ */
347
+ function flattenCascaderTree(index, expanded, sentinels) {
348
+ const rows = [];
349
+ const walk = (nodes, parentKey, depth) => {
350
+ const sentinel = sentinels?.has(parentKey) ?? false;
351
+ const setSize = nodes.length + (sentinel ? 1 : 0);
352
+ for (let i = 0; i < nodes.length; i += 1) {
353
+ const node = nodes[i];
354
+ const branch = isCascaderBranch(index, node);
355
+ const isExpanded = branch && expanded.has(node.value);
356
+ rows.push({
357
+ node,
358
+ depth,
359
+ branch,
360
+ expanded: isExpanded,
361
+ setSize,
362
+ posInSet: i + 1
363
+ });
364
+ if (isExpanded) walk(index.childrenOf.get(node.value) ?? [], node.value, depth + 1);
365
+ }
366
+ if (sentinel) rows.push({
367
+ node: createCascaderMoreNode(parentKey, nodes.length),
368
+ depth,
369
+ branch: false,
370
+ expanded: false,
371
+ setSize,
372
+ posInSet: setSize
373
+ });
374
+ };
375
+ walk(index.roots, CASCADER_ROOT_KEY, 0);
376
+ return rows;
377
+ }
378
+ /** Shortens a path; the ellipsis segment still carries the hidden nodes. */
379
+ function collapseCascaderPath(path, options = {}) {
380
+ const { maxSegments = 3, collapse = "middle" } = options;
381
+ const asNodes = (nodes) => nodes.map((node) => ({
382
+ type: "node",
383
+ node
384
+ }));
385
+ if (collapse === "none" || maxSegments <= 0 || path.length <= maxSegments) return asNodes(path);
386
+ if (collapse === "start") {
387
+ const tail = path.slice(path.length - maxSegments);
388
+ return [{
389
+ type: "ellipsis",
390
+ hidden: path.slice(0, path.length - maxSegments)
391
+ }, ...asNodes(tail)];
392
+ }
393
+ const head = path.slice(0, 1);
394
+ const tailCount = maxSegments - 1;
395
+ const tail = path.slice(path.length - tailCount);
396
+ const hidden = path.slice(1, path.length - tailCount);
397
+ if (hidden.length === 0) return asNodes(path);
398
+ return [
399
+ ...asNodes(head),
400
+ {
401
+ type: "ellipsis",
402
+ hidden
403
+ },
404
+ ...asNodes(tail)
405
+ ];
406
+ }
407
+ /**
408
+ * Every LOADED node under `value`, root first. Reaching an unfetched descendant
409
+ * would mean a network request per level of the subtree on every selection.
410
+ */
411
+ function collectCascaderSubtree(index, value) {
412
+ const root = index.byValue.get(value);
413
+ if (!root) return [];
414
+ const out = [];
415
+ const seen = /* @__PURE__ */ new Set();
416
+ const walk = (node) => {
417
+ if (seen.has(node.value)) return;
418
+ seen.add(node.value);
419
+ out.push(node);
420
+ const children = index.childrenOf.get(node.value);
421
+ if (children) for (const child of children) walk(child);
422
+ };
423
+ walk(root);
424
+ return out;
425
+ }
426
+ /**
427
+ * Toggles `value` with its loaded subtree, then reconciles ancestors. One flat
428
+ * array, no hidden "checked" state: a branch is in the selection exactly when
429
+ * every selectable loaded child of it is, which keeps a row's checked state an
430
+ * O(1) lookup. Nodes `isSelectable` rejects are skipped down AND ignored up,
431
+ * the pressed node excepted.
432
+ */
433
+ function applyCascadeSelection(index, selected, value, select, isSelectable = () => true) {
434
+ const next = new Set(selected);
435
+ const subtree = collectCascaderSubtree(index, value);
436
+ if (subtree.length === 0) {
437
+ if (select) next.add(value);
438
+ else next.delete(value);
439
+ }
440
+ for (const node of subtree) {
441
+ if (node.value !== value && !isSelectable(node)) continue;
442
+ if (select) next.add(node.value);
443
+ else next.delete(node.value);
444
+ }
445
+ const seen = /* @__PURE__ */ new Set([value]);
446
+ let cursor = index.parentOf.get(value) ?? null;
447
+ while (cursor != null && !seen.has(cursor)) {
448
+ seen.add(cursor);
449
+ const parent = index.byValue.get(cursor);
450
+ const selectable = (index.childrenOf.get(cursor) ?? []).filter((child) => isSelectable(child));
451
+ if (selectable.length > 0 && selectable.every((child) => next.has(child.value)) && !!parent && isSelectable(parent)) next.add(cursor);
452
+ else next.delete(cursor);
453
+ cursor = index.parentOf.get(cursor) ?? null;
454
+ }
455
+ return Array.from(next);
456
+ }
457
+ /**
458
+ * How many selected nodes each value has BELOW it, itself excluded. Walks UP
459
+ * from each selection: a per-row subtree scan would be quadratic and re-paid.
460
+ */
461
+ function getCascaderSelectedDescendants(index, selected) {
462
+ const counts = /* @__PURE__ */ new Map();
463
+ for (const value of selected) {
464
+ const seen = /* @__PURE__ */ new Set([value]);
465
+ let cursor = index.parentOf.get(value) ?? null;
466
+ while (cursor != null && !seen.has(cursor)) {
467
+ seen.add(cursor);
468
+ counts.set(cursor, (counts.get(cursor) ?? 0) + 1);
469
+ cursor = index.parentOf.get(cursor) ?? null;
470
+ }
471
+ }
472
+ return counts;
473
+ }
474
+ /** The PARTIALLY selected values, read off counts the caller already holds. */
475
+ function getCascaderIndeterminateFrom(counts, selected) {
476
+ const selectedSet = new Set(selected);
477
+ const partial = /* @__PURE__ */ new Set();
478
+ for (const [value, count] of counts) if (count > 0 && !selectedSet.has(value)) partial.add(value);
479
+ return partial;
480
+ }
481
+ /** The one-call form; the root uses the two halves above and its own counts. */
482
+ function getCascaderIndeterminate(index, selected) {
483
+ return getCascaderIndeterminateFrom(getCascaderSelectedDescendants(index, selected), selected);
484
+ }
485
+ /**
486
+ * The cascade selection under a reporting strategy. DERIVED OUTPUT ONLY: the
487
+ * STORED value stays the full closure, which keeps a checked state an O(1)
488
+ * lookup. `"all"` is the closure; `"parent"` drops a value whose parent is
489
+ * selected; `"child"` drops one with a selected child.
490
+ */
491
+ function getCascaderCheckedValues(index, selected, strategy) {
492
+ if (strategy === "all") return selected;
493
+ const set = new Set(selected);
494
+ if (strategy === "parent") return selected.filter((value) => {
495
+ const parent = index.parentOf.get(value);
496
+ return parent == null || !set.has(parent);
497
+ });
498
+ return selected.filter((value) => {
499
+ const children = index.childrenOf.get(value);
500
+ if (!children?.length) return true;
501
+ return !children.some((child) => set.has(child.value));
502
+ });
503
+ }
504
+ /** Values in `nodes` whose label collides, so the chip must show its path. */
505
+ function findAmbiguousCascaderLabels(nodes) {
506
+ const firstByLabel = /* @__PURE__ */ new Map();
507
+ const ambiguous = /* @__PURE__ */ new Set();
508
+ for (const node of nodes) {
509
+ const first = firstByLabel.get(node.label);
510
+ if (first === void 0) {
511
+ firstByLabel.set(node.label, node.value);
512
+ continue;
513
+ }
514
+ ambiguous.add(node.value);
515
+ ambiguous.add(first);
516
+ }
517
+ return ambiguous;
518
+ }
519
+ /** Warnings already emitted. Module scoped, or they repeat once per render. */
520
+ const CASCADER_WARNED = /* @__PURE__ */ new Set();
521
+ /** Warns once per `key`, never in production, never by throwing. */
522
+ function warnCascaderOnce(key, message) {
523
+ if (process.env.NODE_ENV === "production") return;
524
+ if (CASCADER_WARNED.has(key)) return;
525
+ CASCADER_WARNED.add(key);
526
+ console.warn(`[Cascader] ${message}`);
527
+ }
528
+ /** Empties the ledger. Tests only; a warning is meant to be seen once. */
529
+ function resetCascaderWarnings() {
530
+ CASCADER_WARNED.clear();
531
+ }
532
+ /** Dev-time scan, kept out of `buildCascaderIndex` so the build stays hot. */
533
+ function findCascaderDataIssues(items, getParent) {
534
+ const seen = /* @__PURE__ */ new Set();
535
+ const duplicates = /* @__PURE__ */ new Set();
536
+ const flat = [];
537
+ const visit = (nodes) => {
538
+ for (const node of nodes ?? []) {
539
+ if (node == null) continue;
540
+ if (seen.has(node.value)) duplicates.add(node.value);
541
+ else seen.add(node.value);
542
+ flat.push(node);
543
+ if (node.children?.length) visit(node.children);
544
+ }
545
+ };
546
+ visit(items);
547
+ const cycles = [];
548
+ if (getParent) {
549
+ const parentOf = /* @__PURE__ */ new Map();
550
+ for (const node of flat) {
551
+ if (parentOf.has(node.value)) continue;
552
+ const raw = getParent(node);
553
+ parentOf.set(node.value, raw != null && seen.has(raw) ? raw : null);
554
+ }
555
+ for (const node of flat) {
556
+ const walked = /* @__PURE__ */ new Set([node.value]);
557
+ let cursor = parentOf.get(node.value) ?? null;
558
+ while (cursor != null) {
559
+ if (walked.has(cursor)) {
560
+ cycles.push(node.value);
561
+ break;
562
+ }
563
+ walked.add(cursor);
564
+ cursor = parentOf.get(cursor) ?? null;
565
+ }
566
+ }
567
+ }
568
+ return {
569
+ duplicates: Array.from(duplicates),
570
+ cycles
571
+ };
572
+ }
573
+ //#endregion
574
+ export { CASCADER_LIST_HEIGHT_CLASS, CASCADER_LIST_PAD_CLASS, CASCADER_MORE_PREFIX, CASCADER_ROOT_KEY, CASCADER_ROWS_CLASS, CASCADER_SCROLL_CLASS, applyCascadeSelection, buildCascaderIndex, collapseCascaderPath, collectCascaderSubtree, createCascaderMoreNode, filterCascaderLevel, findAmbiguousCascaderLabels, findCascaderDataIssues, flattenCascaderTree, foldCascaderText, getCascaderCheckedValues, getCascaderChildren, getCascaderCount, getCascaderFooterStops, getCascaderIndeterminate, getCascaderIndeterminateFrom, getCascaderMoreParent, getCascaderPath, getCascaderSelectedDescendants, getCascaderTabTarget, isCascaderBranch, isCascaderMoreNode, isCascaderRtl, isCascaderSelectable, matchesCascaderQuery, mergeCascaderIndex, normalizeCascaderQuery, resetCascaderWarnings, searchCascaderDeep, warnCascaderOnce };
575
+
576
+ //# sourceMappingURL=cascader-lib.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cascader-lib.js","names":[],"sources":["../../../../src/components/reui/cascader/cascader-lib.tsx"],"sourcesContent":["\"use client\";\n\nimport type {\n CascaderCollapse,\n CascaderFlatNode,\n CascaderIndex,\n CascaderNode,\n CascaderPathSegment,\n CascaderSelectable,\n} from \"./cascader-types\";\n\n/** Root level key in `childrenOf`. NUL-prefixed so no real value collides. */\nexport const CASCADER_ROOT_KEY = \"\\u0000root\";\n\n/**\n * Paging pseudo-node prefix. Written as an escape sequence, not a raw 0x00\n * byte: a literal NUL makes this module read as binary and `grep -I` skips it.\n */\nexport const CASCADER_MORE_PREFIX = \"\\u0000more:\";\n\n/* -------------------------------------------------------------------------- */\n/* Scroll layout */\n/* -------------------------------------------------------------------------- */\n\n/**\n * The four scroll classes. In the lib because `cascader-columns.tsx` needs them\n * too and must not import `cascader.tsx`. Shell > bound > scrollport > rows.\n */\n\n/**\n * The bound. `min()` over an undefined custom property is an INVALID\n * declaration that drops the whole max-height, hence the `100vh` fallback: an\n * inline panel has no positioner, so no `--available-height`. `24rem` is the\n * default cap, so the common case sets no variable at all.\n */\nexport const CASCADER_LIST_HEIGHT_CLASS =\n \"max-h-[min(var(--available-height,100vh),var(--cascader-max-height,24rem))]\";\n\n/**\n * Each style's list padding: rows take it as `padding`, the scrollport as\n * `scroll-padding` floored at 4px so lyra's `0` does not strand a row.\n * Mirrored per style from `registry/styles/style-*.css`; keep them in step.\n */\nexport const CASCADER_LIST_PAD_CLASS = \"[--cascader-list-pad:4px]\";\n\n/** The scrollport: a `max-h-*` on the ScrollArea ROOT bounds nothing. */\nexport const CASCADER_SCROLL_CLASS =\n \"size-full min-h-0 **:data-[slot=scroll-area-viewport]:h-full **:data-[slot=scroll-area-viewport]:overscroll-contain **:data-[slot=scroll-area-viewport]:scroll-py-[max(var(--cascader-list-pad,4px),4px)]\";\n\n/** The rows' box; `data-empty:p-0` keeps an empty state from double inset. */\nexport const CASCADER_ROWS_CLASS = \"p-(--cascader-list-pad,4px) data-empty:p-0\";\n\n/* -------------------------------------------------------------------------- */\n/* Tab order */\n/* -------------------------------------------------------------------------- */\n\n/**\n * What counts as a keyboard stop. Base UI's ScrollArea viewport makes ITSELF\n * tabbable when content overflows (`hiddenState.x && hiddenState.y ? -1 : 0`),\n * an unnamed stop per level that `ui/scroll-area.tsx` will not let us suppress.\n */\nconst CASCADER_TAB_STOP_SELECTOR =\n 'a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex=\"-1\"])';\n\n/** The stop to step over: nothing here focuses the scrollport on purpose. */\nconst CASCADER_TAB_SKIP_SELECTOR = '[data-slot=\"scroll-area-viewport\"]';\n\n/** Out of the tab order whatever they contain; layout is never consulted. */\nconst CASCADER_TAB_HIDDEN_SELECTOR = \"[hidden],[inert],[aria-hidden='true']\";\n\n/** The panel's real keyboard stops, in DOM order. */\nfunction getCascaderTabStops(panel: HTMLElement): HTMLElement[] {\n const stops = Array.from(panel.querySelectorAll<HTMLElement>(CASCADER_TAB_STOP_SELECTOR));\n return stops.filter(\n (stop) =>\n // Option and trail rows are real `<button>`s with `tabindex=\"-1\"`.\n stop.getAttribute(\"tabindex\") !== \"-1\" &&\n !stop.matches(CASCADER_TAB_SKIP_SELECTOR) &&\n !stop.closest(CASCADER_TAB_HIDDEN_SELECTOR),\n );\n}\n\n/** The footer's own stops; an `aria-disabled` command still counts as one. */\nexport function getCascaderFooterStops(scope: HTMLElement): HTMLElement[] {\n const footer = scope.matches('[data-slot=\"cascader-footer\"]')\n ? scope\n : scope.querySelector<HTMLElement>('[data-slot=\"cascader-footer\"]');\n if (!footer) return [];\n return getCascaderTabStops(footer);\n}\n\n/** Where Tab lands, or `null` to let the browser out: focus is never trapped. */\nexport function getCascaderTabTarget(\n panel: HTMLElement,\n from: Element | null,\n backwards: boolean,\n): HTMLElement | null {\n const stops = getCascaderTabStops(panel);\n if (stops.length === 0 || !from) return null;\n\n const index = stops.indexOf(from as HTMLElement);\n if (index !== -1) return stops[index + (backwards ? -1 : 1)] ?? null;\n\n if (backwards) {\n for (let i = stops.length - 1; i >= 0; i -= 1) {\n const position = from.compareDocumentPosition(stops[i]);\n if (position & Node.DOCUMENT_POSITION_PRECEDING) return stops[i];\n }\n return null;\n }\n\n for (const stop of stops) {\n const position = from.compareDocumentPosition(stop);\n if (position & Node.DOCUMENT_POSITION_FOLLOWING) return stop;\n }\n return null;\n}\n\n/**\n * The writing direction at `element`. `DirectionProvider` may only vote yes:\n * unmounted it answers `\"ltr\"`, which would override a real `<html dir=\"rtl\">`.\n */\nexport function isCascaderRtl(element: Element, provided: string): boolean {\n if (provided === \"rtl\") return true;\n const explicit = element.closest(\"[dir]\")?.getAttribute(\"dir\")?.toLowerCase();\n if (explicit === \"rtl\") return true;\n if (explicit === \"ltr\") return false;\n return element.ownerDocument?.defaultView?.getComputedStyle(element).direction === \"rtl\";\n}\n\n/**\n * The paging row as a REAL node, not a DOM-only row after the list: every index\n * Base UI hands out indexes the RENDERED array, so a DOM-only row shifts them.\n */\nexport function createCascaderMoreNode<T = unknown>(\n parentKey: string,\n loadedCount = 0,\n): CascaderNode<T> {\n return {\n value: `${CASCADER_MORE_PREFIX}${parentKey}`,\n // Empty on purpose: a typeahead letter must never reach the paging row.\n label: \"\",\n // Feeds the row's \"Loading more...\" wording, with no second prop to thread.\n count: loadedCount,\n };\n}\n\nexport function isCascaderMoreNode<T>(node: CascaderNode<T>): boolean {\n return node.value.startsWith(CASCADER_MORE_PREFIX);\n}\n\n/** The level key a paging pseudo-node belongs to, or `null` for a real node. */\nexport function getCascaderMoreParent<T>(node: CascaderNode<T>): string | null {\n if (!isCascaderMoreNode(node)) return null;\n return node.value.slice(CASCADER_MORE_PREFIX.length);\n}\n\n/** Either input shape into one index. Cycle-guarded depths; first wins. */\nexport function buildCascaderIndex<T = unknown>(\n items: readonly CascaderNode<T>[] | undefined,\n getParent?: (node: CascaderNode<T>) => string | null | undefined,\n): CascaderIndex<T> {\n const byValue = new Map<string, CascaderNode<T>>();\n const childrenOf = new Map<string, CascaderNode<T>[]>();\n const parentOf = new Map<string, string | null>();\n const depthOf = new Map<string, number>();\n const all: CascaderNode<T>[] = [];\n\n const push = (parentKey: string, node: CascaderNode<T>) => {\n const bucket = childrenOf.get(parentKey);\n if (bucket) {\n bucket.push(node);\n } else {\n childrenOf.set(parentKey, [node]);\n }\n };\n\n if (getParent) {\n for (const node of items ?? []) {\n // A nullish entry is a data bug: skip it like a duplicate, say so in dev.\n if (node == null) {\n if (process.env.NODE_ENV !== \"production\") {\n warnCascaderOnce(\n \"nullish-entry\",\n \"Ignored a null or undefined entry in `items` or `children`. Check the arrays you pass in.\",\n );\n }\n continue;\n }\n if (byValue.has(node.value)) continue;\n byValue.set(node.value, node);\n all.push(node);\n }\n\n for (const node of all) {\n const rawParent = getParent(node);\n // An unknown parent makes the node a root rather than dropping the row.\n const parent = rawParent != null && byValue.has(rawParent) ? rawParent : null;\n parentOf.set(node.value, parent);\n push(parent ?? CASCADER_ROOT_KEY, node);\n }\n\n for (const node of all) {\n let depth = 0;\n let cursor = parentOf.get(node.value) ?? null;\n const seen = new Set<string>([node.value]);\n while (cursor != null && !seen.has(cursor)) {\n seen.add(cursor);\n depth += 1;\n cursor = parentOf.get(cursor) ?? null;\n }\n depthOf.set(node.value, depth);\n }\n } else {\n const walk = (\n nodes: readonly CascaderNode<T>[] | undefined,\n parent: string | null,\n depth: number,\n ) => {\n for (const node of nodes ?? []) {\n // Same degradation as the flat path above.\n if (node == null) {\n if (process.env.NODE_ENV !== \"production\") {\n warnCascaderOnce(\n \"nullish-entry\",\n \"Ignored a null or undefined entry in `items` or `children`. Check the arrays you pass in.\",\n );\n }\n continue;\n }\n if (byValue.has(node.value)) continue;\n byValue.set(node.value, node);\n parentOf.set(node.value, parent);\n depthOf.set(node.value, depth);\n all.push(node);\n push(parent ?? CASCADER_ROOT_KEY, node);\n if (node.children?.length) walk(node.children, node.value, depth + 1);\n }\n };\n walk(items, null, 0);\n }\n\n return {\n byValue,\n childrenOf,\n parentOf,\n depthOf,\n roots: childrenOf.get(CASCADER_ROOT_KEY) ?? [],\n all,\n };\n}\n\n/**\n * Folds loaded pages into an index built from `items`, so a re-render with a\n * new `items` array keeps what the user drilled into. Static `items` wins;\n * `detached` is `byValue` ONLY, or deep search doubles it and `childrenOf` lies.\n */\nexport function mergeCascaderIndex<T = unknown>(\n base: CascaderIndex<T>,\n pages: ReadonlyMap<string, readonly CascaderNode<T>[]>,\n detached?: ReadonlyMap<string, CascaderNode<T>>,\n): CascaderIndex<T> {\n // Identity stability: every downstream `useMemo` is keyed on this index.\n if (pages.size === 0 && !detached?.size) return base;\n\n const byValue = new Map(base.byValue);\n const childrenOf = new Map(base.childrenOf);\n const parentOf = new Map(base.parentOf);\n const depthOf = new Map(base.depthOf);\n\n // Copy-on-write per bucket: only levels that got a page pay for a new array.\n const copied = new Set<string>();\n const append = (parentKey: string, node: CascaderNode<T>) => {\n let bucket = childrenOf.get(parentKey);\n if (!copied.has(parentKey)) {\n bucket = bucket ? bucket.slice() : [];\n childrenOf.set(parentKey, bucket);\n copied.add(parentKey);\n }\n bucket!.push(node);\n };\n\n const insert = (parentKey: string, nodes: readonly CascaderNode<T>[]) => {\n for (const node of nodes) {\n if (byValue.has(node.value)) continue;\n byValue.set(node.value, node);\n parentOf.set(node.value, parentKey === CASCADER_ROOT_KEY ? null : parentKey);\n append(parentKey, node);\n if (node.children?.length) insert(node.value, node.children);\n }\n };\n\n for (const [parentKey, nodes] of pages) insert(parentKey, nodes);\n\n for (const value of byValue.keys()) {\n if (depthOf.has(value)) continue;\n let depth = 0;\n let cursor = parentOf.get(value) ?? null;\n const seen = new Set<string>([value]);\n while (cursor != null && !seen.has(cursor)) {\n seen.add(cursor);\n depth += 1;\n cursor = parentOf.get(cursor) ?? null;\n }\n depthOf.set(value, depth);\n }\n\n const roots = childrenOf.get(CASCADER_ROOT_KEY) ?? [];\n\n // Depth first over the MERGED tree, so `all` keeps document order.\n const all: CascaderNode<T>[] = [];\n const visited = new Set<string>();\n const walk = (nodes: readonly CascaderNode<T>[]) => {\n for (const node of nodes) {\n if (visited.has(node.value)) continue;\n visited.add(node.value);\n all.push(node);\n const children = childrenOf.get(node.value);\n if (children?.length) walk(children);\n }\n };\n walk(roots);\n\n // A page whose parent never arrived stays searchable rather than vanishing.\n for (const [value, node] of byValue) {\n if (visited.has(value)) continue;\n visited.add(value);\n all.push(node);\n }\n\n if (detached) {\n for (const [value, node] of detached) {\n if (byValue.has(value)) continue;\n byValue.set(value, node);\n }\n }\n\n return { byValue, childrenOf, parentOf, depthOf, roots, all };\n}\n\n/** Children of `parent`, or the root level when `parent` is nullish. */\nexport function getCascaderChildren<T>(\n index: CascaderIndex<T>,\n parent?: string | null,\n): CascaderNode<T>[] {\n return index.childrenOf.get(parent ?? CASCADER_ROOT_KEY) ?? [];\n}\n\n/** A branch has known children, or `hasChildren` for an unfetched level. */\nexport function isCascaderBranch<T>(index: CascaderIndex<T>, node: CascaderNode<T>): boolean {\n if (node.hasChildren) return true;\n return (index.childrenOf.get(node.value)?.length ?? 0) > 0;\n}\n\n/** Trailing count for the default row. Explicit `count` wins over the tree. */\nexport function getCascaderCount<T>(index: CascaderIndex<T>, node: CascaderNode<T>): number {\n if (typeof node.count === \"number\") return node.count;\n return index.childrenOf.get(node.value)?.length ?? 0;\n}\n\n/** Whether a node may be committed as a selection. */\nexport function isCascaderSelectable<T>(\n index: CascaderIndex<T>,\n node: CascaderNode<T>,\n selectable: CascaderSelectable<T>,\n): boolean {\n // Before the branches a consumer controls: `selectable=\"any\"` says yes to\n // every node, and committing the paging row would select a level's name.\n if (isCascaderMoreNode(node)) return false;\n if (node.disabled) return false;\n // A disabled ANCESTOR refuses the whole subtree: `searchCascaderDeep` still\n // surfaces children of a branch the UI will not let anyone open.\n {\n const seen = new Set<string>([node.value]);\n let cursor = index.parentOf.get(node.value) ?? null;\n while (cursor != null && !seen.has(cursor)) {\n seen.add(cursor);\n if (index.byValue.get(cursor)?.disabled) return false;\n cursor = index.parentOf.get(cursor) ?? null;\n }\n }\n if (typeof selectable === \"function\") return selectable(node);\n if (selectable === \"any\") return true;\n return !isCascaderBranch(index, node);\n}\n\n/** Ancestor chain for `value`, root first. Empty while async data loads. */\nexport function getCascaderPath<T>(\n index: CascaderIndex<T>,\n value: string | null | undefined,\n): CascaderNode<T>[] {\n if (value == null) return [];\n const chain: CascaderNode<T>[] = [];\n const seen = new Set<string>();\n let cursor: string | null | undefined = value;\n while (cursor != null && !seen.has(cursor)) {\n seen.add(cursor);\n const node = index.byValue.get(cursor);\n if (!node) break;\n chain.push(node);\n cursor = index.parentOf.get(cursor) ?? null;\n }\n return chain.reverse();\n}\n\n/**\n * `toLocaleLowerCase`, not `toLowerCase`: the invariant mapping turns Turkish\n * \"I\" into \"i\" not \"ı\", so \"ışık\" would never match \"IŞIK\". Both sides fold here.\n */\nexport function foldCascaderText(text: string): string {\n return text.toLocaleLowerCase();\n}\n\n/** Folds once so callers can hoist the cost out of a per-node loop. */\nexport function normalizeCascaderQuery(query: string): string {\n return foldCascaderText(query.trim());\n}\n\n/** Case-insensitive substring over label and keywords; pre-fold the query. */\nexport function matchesCascaderQuery<T>(node: CascaderNode<T>, normalized: string): boolean {\n if (!normalized) return true;\n // Coerced, not trusted: a label-less node is malformed data, not a crash.\n if (foldCascaderText(node.label ?? \"\").includes(normalized)) return true;\n if (node.keywords) {\n for (const keyword of node.keywords) {\n if (foldCascaderText(keyword).includes(normalized)) return true;\n }\n }\n return false;\n}\n\n/** Filters one level in place-order. Returns the input when the query is empty. */\nexport function filterCascaderLevel<T>(\n nodes: readonly CascaderNode<T>[],\n query: string,\n matches: (node: CascaderNode<T>, normalized: string) => boolean = matchesCascaderQuery,\n): CascaderNode<T>[] {\n const normalized = normalizeCascaderQuery(query);\n if (!normalized) return nodes as CascaderNode<T>[];\n return nodes.filter((node) => matches(node, normalized));\n}\n\n/** Searches every node, optionally under `within`, in one pass over `all`. */\nexport function searchCascaderDeep<T>(\n index: CascaderIndex<T>,\n query: string,\n options: {\n within?: string | null;\n limit?: number;\n matches?: (node: CascaderNode<T>, normalized: string) => boolean;\n } = {},\n): CascaderNode<T>[] {\n const normalized = normalizeCascaderQuery(query);\n if (!normalized) return [];\n\n const { within, limit = 200, matches = matchesCascaderQuery } = options;\n const results: CascaderNode<T>[] = [];\n\n // One memoised ancestry map per query. The provisional `false` written on the\n // way up doubles as the cycle guard; the trail is promoted once `within` hits.\n const ancestry = within == null ? null : new Map<string, boolean>();\n const isWithin = (node: CascaderNode<T>) => {\n if (within == null || !ancestry) return true;\n const trail: string[] = [];\n let answer = false;\n let cursor: string | null | undefined = index.parentOf.get(node.value);\n while (cursor != null) {\n if (cursor === within) {\n answer = true;\n break;\n }\n const cached = ancestry.get(cursor);\n if (cached !== undefined) {\n answer = cached;\n break;\n }\n ancestry.set(cursor, false);\n trail.push(cursor);\n cursor = index.parentOf.get(cursor) ?? null;\n }\n if (answer) for (const value of trail) ancestry.set(value, true);\n return answer;\n };\n\n for (const node of index.all) {\n if (results.length >= limit) break;\n if (!matches(node, normalized)) continue;\n if (!isWithin(node)) continue;\n results.push(node);\n }\n\n return results;\n}\n\n/**\n * Flattens the tree into tree mode's visible rows. A `sentinels` paging row\n * COUNTS as a sibling in `aria-setsize`: it holds an index of its own.\n */\nexport function flattenCascaderTree<T>(\n index: CascaderIndex<T>,\n expanded: ReadonlySet<string>,\n sentinels?: ReadonlySet<string>,\n): CascaderFlatNode<T>[] {\n const rows: CascaderFlatNode<T>[] = [];\n\n const walk = (nodes: readonly CascaderNode<T>[], parentKey: string, depth: number) => {\n const sentinel = sentinels?.has(parentKey) ?? false;\n const setSize = nodes.length + (sentinel ? 1 : 0);\n for (let i = 0; i < nodes.length; i += 1) {\n const node = nodes[i];\n const branch = isCascaderBranch(index, node);\n const isExpanded = branch && expanded.has(node.value);\n rows.push({\n node,\n depth,\n branch,\n expanded: isExpanded,\n setSize,\n posInSet: i + 1,\n });\n if (isExpanded) {\n walk(index.childrenOf.get(node.value) ?? [], node.value, depth + 1);\n }\n }\n if (sentinel) {\n rows.push({\n node: createCascaderMoreNode<T>(parentKey, nodes.length),\n depth,\n branch: false,\n expanded: false,\n setSize,\n posInSet: setSize,\n });\n }\n };\n\n walk(index.roots, CASCADER_ROOT_KEY, 0);\n return rows;\n}\n\n/** Shortens a path; the ellipsis segment still carries the hidden nodes. */\nexport function collapseCascaderPath<T>(\n path: readonly CascaderNode<T>[],\n options: { maxSegments?: number; collapse?: CascaderCollapse } = {},\n): CascaderPathSegment<T>[] {\n const { maxSegments = 3, collapse = \"middle\" } = options;\n\n const asNodes = (nodes: readonly CascaderNode<T>[]): CascaderPathSegment<T>[] =>\n nodes.map((node) => ({ type: \"node\" as const, node }));\n\n if (collapse === \"none\" || maxSegments <= 0 || path.length <= maxSegments) {\n return asNodes(path);\n }\n\n if (collapse === \"start\") {\n const tail = path.slice(path.length - maxSegments);\n return [\n { type: \"ellipsis\", hidden: path.slice(0, path.length - maxSegments) },\n ...asNodes(tail),\n ];\n }\n\n // \"middle\": keep the root for orientation and as much of the tail as fits.\n const head = path.slice(0, 1);\n const tailCount = maxSegments - 1;\n const tail = path.slice(path.length - tailCount);\n const hidden = path.slice(1, path.length - tailCount);\n\n if (hidden.length === 0) return asNodes(path);\n\n return [...asNodes(head), { type: \"ellipsis\", hidden }, ...asNodes(tail)];\n}\n\n/* -------------------------------------------------------------------------- */\n/* Cascade selection */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Every LOADED node under `value`, root first. Reaching an unfetched descendant\n * would mean a network request per level of the subtree on every selection.\n */\nexport function collectCascaderSubtree<T>(\n index: CascaderIndex<T>,\n value: string,\n): CascaderNode<T>[] {\n const root = index.byValue.get(value);\n if (!root) return [];\n\n const out: CascaderNode<T>[] = [];\n const seen = new Set<string>();\n const walk = (node: CascaderNode<T>) => {\n if (seen.has(node.value)) return;\n seen.add(node.value);\n out.push(node);\n const children = index.childrenOf.get(node.value);\n if (children) for (const child of children) walk(child);\n };\n walk(root);\n return out;\n}\n\n/**\n * Toggles `value` with its loaded subtree, then reconciles ancestors. One flat\n * array, no hidden \"checked\" state: a branch is in the selection exactly when\n * every selectable loaded child of it is, which keeps a row's checked state an\n * O(1) lookup. Nodes `isSelectable` rejects are skipped down AND ignored up,\n * the pressed node excepted.\n */\nexport function applyCascadeSelection<T>(\n index: CascaderIndex<T>,\n selected: readonly string[],\n value: string,\n select: boolean,\n isSelectable: (node: CascaderNode<T>) => boolean = () => true,\n): string[] {\n const next = new Set(selected);\n const subtree = collectCascaderSubtree(index, value);\n\n // An unknown value still toggles itself, so an early async selection lands.\n if (subtree.length === 0) {\n if (select) next.add(value);\n else next.delete(value);\n }\n\n for (const node of subtree) {\n // The pressed node is exempt: it was committed, so it is selectable.\n if (node.value !== value && !isSelectable(node)) continue;\n if (select) next.add(node.value);\n else next.delete(node.value);\n }\n\n // Bottom up: a parent can only answer once its children have.\n const seen = new Set<string>([value]);\n let cursor = index.parentOf.get(value) ?? null;\n while (cursor != null && !seen.has(cursor)) {\n seen.add(cursor);\n const parent = index.byValue.get(cursor);\n const children = index.childrenOf.get(cursor) ?? [];\n const selectable = children.filter((child) => isSelectable(child));\n const full =\n selectable.length > 0 &&\n selectable.every((child) => next.has(child.value)) &&\n // Never promote a node the consumer said may not be committed. Under\n // `selectable=\"leaf\"` no branch qualifies, hence the `cascade` warning.\n !!parent &&\n isSelectable(parent);\n if (full) next.add(cursor);\n else next.delete(cursor);\n cursor = index.parentOf.get(cursor) ?? null;\n }\n\n return Array.from(next);\n}\n\n/**\n * How many selected nodes each value has BELOW it, itself excluded. Walks UP\n * from each selection: a per-row subtree scan would be quadratic and re-paid.\n */\nexport function getCascaderSelectedDescendants<T>(\n index: CascaderIndex<T>,\n selected: readonly string[],\n): Map<string, number> {\n const counts = new Map<string, number>();\n\n for (const value of selected) {\n const seen = new Set<string>([value]);\n let cursor = index.parentOf.get(value) ?? null;\n while (cursor != null && !seen.has(cursor)) {\n seen.add(cursor);\n counts.set(cursor, (counts.get(cursor) ?? 0) + 1);\n cursor = index.parentOf.get(cursor) ?? null;\n }\n }\n\n return counts;\n}\n\n/** The PARTIALLY selected values, read off counts the caller already holds. */\nexport function getCascaderIndeterminateFrom(\n counts: ReadonlyMap<string, number>,\n selected: readonly string[],\n): Set<string> {\n const selectedSet = new Set(selected);\n const partial = new Set<string>();\n\n for (const [value, count] of counts) {\n if (count > 0 && !selectedSet.has(value)) partial.add(value);\n }\n\n return partial;\n}\n\n/** The one-call form; the root uses the two halves above and its own counts. */\nexport function getCascaderIndeterminate<T>(\n index: CascaderIndex<T>,\n selected: readonly string[],\n): Set<string> {\n return getCascaderIndeterminateFrom(getCascaderSelectedDescendants(index, selected), selected);\n}\n\n/** How `getCascaderCheckedValues` condenses a full-closure selection. */\nexport type CascaderCheckedStrategy = \"all\" | \"parent\" | \"child\";\n\n/**\n * The cascade selection under a reporting strategy. DERIVED OUTPUT ONLY: the\n * STORED value stays the full closure, which keeps a checked state an O(1)\n * lookup. `\"all\"` is the closure; `\"parent\"` drops a value whose parent is\n * selected; `\"child\"` drops one with a selected child.\n */\nexport function getCascaderCheckedValues<T>(\n index: CascaderIndex<T>,\n selected: readonly string[],\n strategy: CascaderCheckedStrategy,\n): readonly string[] {\n if (strategy === \"all\") return selected;\n\n const set = new Set(selected);\n if (strategy === \"parent\") {\n return selected.filter((value) => {\n const parent = index.parentOf.get(value);\n return parent == null || !set.has(parent);\n });\n }\n\n return selected.filter((value) => {\n const children = index.childrenOf.get(value);\n if (!children?.length) return true;\n return !children.some((child) => set.has(child.value));\n });\n}\n\n/** Values in `nodes` whose label collides, so the chip must show its path. */\nexport function findAmbiguousCascaderLabels<T>(nodes: readonly CascaderNode<T>[]): Set<string> {\n const firstByLabel = new Map<string, string>();\n const ambiguous = new Set<string>();\n\n for (const node of nodes) {\n const first = firstByLabel.get(node.label);\n if (first === undefined) {\n firstByLabel.set(node.label, node.value);\n continue;\n }\n ambiguous.add(node.value);\n ambiguous.add(first);\n }\n\n return ambiguous;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Development only */\n/* -------------------------------------------------------------------------- */\n\n/** Warnings already emitted. Module scoped, or they repeat once per render. */\nconst CASCADER_WARNED = new Set<string>();\n\n/** Warns once per `key`, never in production, never by throwing. */\nexport function warnCascaderOnce(key: string, message: string): void {\n if (process.env.NODE_ENV === \"production\") return;\n if (CASCADER_WARNED.has(key)) return;\n CASCADER_WARNED.add(key);\n console.warn(`[Cascader] ${message}`);\n}\n\n/** Empties the ledger. Tests only; a warning is meant to be seen once. */\nexport function resetCascaderWarnings(): void {\n CASCADER_WARNED.clear();\n}\n\n/** What a dev-time scan of the consumer's `items` found wrong with it. */\nexport interface CascaderDataIssues {\n /** Values appearing more than once. First wins, so a duplicate drops a row. */\n duplicates: string[];\n /** Values on a `getParent` cycle. Depth is clamped, so the tree reads wrong. */\n cycles: string[];\n}\n\n/** Dev-time scan, kept out of `buildCascaderIndex` so the build stays hot. */\nexport function findCascaderDataIssues<T>(\n items: readonly CascaderNode<T>[] | undefined,\n getParent?: (node: CascaderNode<T>) => string | null | undefined,\n): CascaderDataIssues {\n const seen = new Set<string>();\n const duplicates = new Set<string>();\n const flat: CascaderNode<T>[] = [];\n\n const visit = (nodes: readonly CascaderNode<T>[] | undefined) => {\n for (const node of nodes ?? []) {\n // The build skips a nullish entry, and this runs BEFORE its warning.\n if (node == null) continue;\n if (seen.has(node.value)) duplicates.add(node.value);\n else seen.add(node.value);\n flat.push(node);\n // Flat mode walks them too: BOTH `children` and `getParent` is a bug.\n if (node.children?.length) visit(node.children);\n }\n };\n visit(items);\n\n const cycles: string[] = [];\n if (getParent) {\n const parentOf = new Map<string, string | null>();\n for (const node of flat) {\n if (parentOf.has(node.value)) continue;\n const raw = getParent(node);\n parentOf.set(node.value, raw != null && seen.has(raw) ? raw : null);\n }\n for (const node of flat) {\n const walked = new Set<string>([node.value]);\n let cursor = parentOf.get(node.value) ?? null;\n while (cursor != null) {\n if (walked.has(cursor)) {\n cycles.push(node.value);\n break;\n }\n walked.add(cursor);\n cursor = parentOf.get(cursor) ?? null;\n }\n }\n }\n\n return { duplicates: Array.from(duplicates), cycles };\n}\n"],"mappings":";;;AAYA,MAAa,oBAAoB;;;;;AAMjC,MAAa,uBAAuB;;;;;;;;;;;AAiBpC,MAAa,6BACX;;;;;;AAOF,MAAa,0BAA0B;;AAGvC,MAAa,wBACX;;AAGF,MAAa,sBAAsB;;;;;;AAWnC,MAAM,6BACJ;;AAGF,MAAM,6BAA6B;;AAGnC,MAAM,+BAA+B;;AAGrC,SAAS,oBAAoB,OAAmC;CAE9D,OADc,MAAM,KAAK,MAAM,iBAA8B,0BAA0B,CAC5E,CAAC,CAAC,QACV,SAEC,KAAK,aAAa,UAAU,MAAM,QAClC,CAAC,KAAK,QAAQ,0BAA0B,KACxC,CAAC,KAAK,QAAQ,4BAA4B,CAC9C;AACF;;AAGA,SAAgB,uBAAuB,OAAmC;CACxE,MAAM,SAAS,MAAM,QAAQ,iCAA+B,I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