@kumix/ui 0.3.7 → 0.3.9

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 (186) hide show
  1. package/README.md +26 -25
  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/agents/ai-sidebar.js +3 -5
  5. package/dist/components/agents/ai-sidebar.js.map +1 -1
  6. package/dist/components/motion/animated-sidebar.d.ts.map +1 -1
  7. package/dist/components/motion/animated-sidebar.js +12 -3
  8. package/dist/components/motion/animated-sidebar.js.map +1 -1
  9. package/dist/components/motion/attachment-upload.d.ts.map +1 -1
  10. package/dist/components/motion/attachment-upload.js +9 -5
  11. package/dist/components/motion/attachment-upload.js.map +1 -1
  12. package/dist/components/motion/bottom-sheet.d.ts.map +1 -1
  13. package/dist/components/motion/bottom-sheet.js +77 -74
  14. package/dist/components/motion/bottom-sheet.js.map +1 -1
  15. package/dist/components/motion/center-morph-modal.d.ts.map +1 -1
  16. package/dist/components/motion/center-morph-modal.js +82 -88
  17. package/dist/components/motion/center-morph-modal.js.map +1 -1
  18. package/dist/components/motion/combobox/content.js +1 -1
  19. package/dist/components/motion/combobox/context.d.ts +6 -0
  20. package/dist/components/motion/combobox/context.d.ts.map +1 -1
  21. package/dist/components/motion/combobox/context.js +1 -233
  22. package/dist/components/motion/combobox/list.js +1 -1
  23. package/dist/components/motion/combobox/trigger.js +7 -8
  24. package/dist/components/motion/combobox/trigger.js.map +1 -1
  25. package/dist/components/motion/combobox.js +1 -1
  26. package/dist/components/motion/command-palette.d.ts.map +1 -1
  27. package/dist/components/motion/command-palette.js +62 -45
  28. package/dist/components/motion/command-palette.js.map +1 -1
  29. package/dist/components/motion/drawer.d.ts.map +1 -1
  30. package/dist/components/motion/drawer.js +30 -30
  31. package/dist/components/motion/drawer.js.map +1 -1
  32. package/dist/components/motion/loader.js +20 -22
  33. package/dist/components/motion/loader.js.map +1 -1
  34. package/dist/components/motion/morphing-modal.d.ts.map +1 -1
  35. package/dist/components/motion/morphing-modal.js +83 -83
  36. package/dist/components/motion/morphing-modal.js.map +1 -1
  37. package/dist/components/motion/morphing-search.d.ts +28 -0
  38. package/dist/components/motion/morphing-search.d.ts.map +1 -0
  39. package/dist/components/motion/morphing-search.js +422 -0
  40. package/dist/components/motion/morphing-search.js.map +1 -0
  41. package/dist/components/motion/project-folder.js +20 -20
  42. package/dist/components/motion/project-folder.js.map +1 -1
  43. package/dist/components/reui/alert.d.ts +1 -1
  44. package/dist/components/reui/badge.d.ts +1 -1
  45. package/dist/components/reui/cascader/cascader-async.d.ts +90 -0
  46. package/dist/components/reui/cascader/cascader-async.d.ts.map +1 -0
  47. package/dist/components/reui/cascader/cascader-async.js +549 -0
  48. package/dist/components/reui/cascader/cascader-async.js.map +1 -0
  49. package/dist/components/reui/cascader/cascader-columns.d.ts +29 -0
  50. package/dist/components/reui/cascader/cascader-columns.d.ts.map +1 -0
  51. package/dist/components/reui/cascader/cascader-columns.js +135 -0
  52. package/dist/components/reui/cascader/cascader-columns.js.map +1 -0
  53. package/dist/components/reui/cascader/cascader-context.d.ts +193 -0
  54. package/dist/components/reui/cascader/cascader-context.d.ts.map +1 -0
  55. package/dist/components/reui/cascader/cascader-context.js +59 -0
  56. package/dist/components/reui/cascader/cascader-context.js.map +1 -0
  57. package/dist/components/reui/cascader/cascader-footer.d.ts +85 -0
  58. package/dist/components/reui/cascader/cascader-footer.d.ts.map +1 -0
  59. package/dist/components/reui/cascader/cascader-footer.js +456 -0
  60. package/dist/components/reui/cascader/cascader-footer.js.map +1 -0
  61. package/dist/components/reui/cascader/cascader-i18n.d.ts +17 -0
  62. package/dist/components/reui/cascader/cascader-i18n.d.ts.map +1 -0
  63. package/dist/components/reui/cascader/cascader-i18n.js +68 -0
  64. package/dist/components/reui/cascader/cascader-i18n.js.map +1 -0
  65. package/dist/components/reui/cascader/cascader-item.d.ts +115 -0
  66. package/dist/components/reui/cascader/cascader-item.d.ts.map +1 -0
  67. package/dist/components/reui/cascader/cascader-item.js +530 -0
  68. package/dist/components/reui/cascader/cascader-item.js.map +1 -0
  69. package/dist/components/reui/cascader/cascader-lib.d.ts +141 -0
  70. package/dist/components/reui/cascader/cascader-lib.d.ts.map +1 -0
  71. package/dist/components/reui/cascader/cascader-lib.js +576 -0
  72. package/dist/components/reui/cascader/cascader-lib.js.map +1 -0
  73. package/dist/components/reui/cascader/cascader-nav.d.ts +59 -0
  74. package/dist/components/reui/cascader/cascader-nav.d.ts.map +1 -0
  75. package/dist/components/reui/cascader/cascader-nav.js +312 -0
  76. package/dist/components/reui/cascader/cascader-nav.js.map +1 -0
  77. package/dist/components/reui/cascader/cascader-types.d.ts +2 -0
  78. package/dist/components/reui/cascader/cascader-types.js +2 -0
  79. package/dist/components/reui/cascader/cascader-virtual.d.ts +65 -0
  80. package/dist/components/reui/cascader/cascader-virtual.d.ts.map +1 -0
  81. package/dist/components/reui/cascader/cascader-virtual.js +240 -0
  82. package/dist/components/reui/cascader/cascader-virtual.js.map +1 -0
  83. package/dist/components/reui/cascader/cascader.d.ts +322 -0
  84. package/dist/components/reui/cascader/cascader.d.ts.map +1 -0
  85. package/dist/components/reui/cascader/cascader.js +1459 -0
  86. package/dist/components/reui/cascader/cascader.js.map +1 -0
  87. package/dist/components/reui/event-calendar/event-calendar-event.d.ts +28 -47
  88. package/dist/components/reui/event-calendar/event-calendar-event.d.ts.map +1 -1
  89. package/dist/components/reui/event-calendar/event-calendar-event.js +26 -44
  90. package/dist/components/reui/event-calendar/event-calendar-event.js.map +1 -1
  91. package/dist/components/reui/event-calendar/event-calendar-nav.js +1 -1
  92. package/dist/components/reui/event-calendar/event-calendar-types.d.ts +19 -57
  93. package/dist/components/reui/event-calendar/event-calendar-types.d.ts.map +1 -1
  94. package/dist/components/reui/filters/filters-advanced.d.ts +52 -0
  95. package/dist/components/reui/filters/filters-advanced.d.ts.map +1 -0
  96. package/dist/components/reui/filters/filters-advanced.js +1191 -0
  97. package/dist/components/reui/filters/filters-advanced.js.map +1 -0
  98. package/dist/components/reui/filters/filters-builder.d.ts +43 -0
  99. package/dist/components/reui/filters/filters-builder.d.ts.map +1 -0
  100. package/dist/components/reui/filters/filters-builder.js +152 -0
  101. package/dist/components/reui/filters/filters-builder.js.map +1 -0
  102. package/dist/components/reui/filters/filters-chip.d.ts +79 -0
  103. package/dist/components/reui/filters/filters-chip.d.ts.map +1 -0
  104. package/dist/components/reui/filters/filters-chip.js +553 -0
  105. package/dist/components/reui/filters/filters-chip.js.map +1 -0
  106. package/dist/components/reui/filters/filters-context.d.ts +290 -0
  107. package/dist/components/reui/filters/filters-context.d.ts.map +1 -0
  108. package/dist/components/reui/filters/filters-context.js +277 -0
  109. package/dist/components/reui/filters/filters-context.js.map +1 -0
  110. package/dist/components/reui/filters/filters-date.d.ts +43 -0
  111. package/dist/components/reui/filters/filters-date.d.ts.map +1 -0
  112. package/dist/components/reui/filters/filters-date.js +143 -0
  113. package/dist/components/reui/filters/filters-date.js.map +1 -0
  114. package/dist/components/reui/filters/filters-dnd.d.ts +101 -0
  115. package/dist/components/reui/filters/filters-dnd.d.ts.map +1 -0
  116. package/dist/components/reui/filters/filters-dnd.js +454 -0
  117. package/dist/components/reui/filters/filters-dnd.js.map +1 -0
  118. package/dist/components/reui/filters/filters-draft.d.ts +2 -0
  119. package/dist/components/reui/filters/filters-draft.js +128 -0
  120. package/dist/components/reui/filters/filters-draft.js.map +1 -0
  121. package/dist/components/reui/filters/filters-editors.d.ts +91 -0
  122. package/dist/components/reui/filters/filters-editors.d.ts.map +1 -0
  123. package/dist/components/reui/filters/filters-editors.js +773 -0
  124. package/dist/components/reui/filters/filters-editors.js.map +1 -0
  125. package/dist/components/reui/filters/filters-i18n.d.ts +24 -0
  126. package/dist/components/reui/filters/filters-i18n.d.ts.map +1 -0
  127. package/dist/components/reui/filters/filters-i18n.js +127 -0
  128. package/dist/components/reui/filters/filters-i18n.js.map +1 -0
  129. package/dist/components/reui/filters/filters-lib.d.ts +171 -0
  130. package/dist/components/reui/filters/filters-lib.d.ts.map +1 -0
  131. package/dist/components/reui/filters/filters-lib.js +336 -0
  132. package/dist/components/reui/filters/filters-lib.js.map +1 -0
  133. package/dist/components/reui/filters/filters-operators.d.ts +49 -0
  134. package/dist/components/reui/filters/filters-operators.d.ts.map +1 -0
  135. package/dist/components/reui/filters/filters-operators.js +300 -0
  136. package/dist/components/reui/filters/filters-operators.js.map +1 -0
  137. package/dist/components/reui/filters/filters-query.d.ts +132 -0
  138. package/dist/components/reui/filters/filters-query.d.ts.map +1 -0
  139. package/dist/components/reui/filters/filters-query.js +476 -0
  140. package/dist/components/reui/filters/filters-query.js.map +1 -0
  141. package/dist/components/reui/filters/filters-types.d.ts +452 -0
  142. package/dist/components/reui/filters/filters-types.d.ts.map +1 -0
  143. package/dist/components/reui/filters/filters-types.js +2 -0
  144. package/dist/components/reui/filters/filters.d.ts +114 -0
  145. package/dist/components/reui/filters/filters.d.ts.map +1 -0
  146. package/dist/components/reui/filters/filters.js +638 -0
  147. package/dist/components/reui/filters/filters.js.map +1 -0
  148. package/dist/components/reui/gantt/gantt-bar.js +1 -1
  149. package/dist/components/reui/gantt/gantt-nav.js +1 -1
  150. package/dist/components/reui/gantt/gantt-types.d.ts +25 -71
  151. package/dist/components/reui/gantt/gantt-types.d.ts.map +1 -1
  152. package/dist/components/reui/gantt/gantt-view.js +1 -1
  153. package/dist/components/ui/button.d.ts +1 -1
  154. package/dist/components/ui/checkbox.js +1 -1
  155. package/dist/components/ui/checkbox.js.map +1 -1
  156. package/dist/components/ui/field.js +2 -2
  157. package/dist/components/ui/field.js.map +1 -1
  158. package/dist/components/ui/radio-group.js +1 -1
  159. package/dist/components/ui/radio-group.js.map +1 -1
  160. package/dist/components/ui/sidebar.js +1 -1
  161. package/dist/components/ui/switch.js +1 -1
  162. package/dist/components/ui/switch.js.map +1 -1
  163. package/dist/context-BizvUNZv.js +298 -0
  164. package/dist/context-BizvUNZv.js.map +1 -0
  165. package/dist/filters-draft-DEAl3TO-.d.ts +70 -0
  166. package/dist/filters-draft-DEAl3TO-.d.ts.map +1 -0
  167. package/dist/hooks/use-on-open.d.ts +18 -0
  168. package/dist/hooks/use-on-open.d.ts.map +1 -0
  169. package/dist/hooks/use-on-open.js +27 -0
  170. package/dist/hooks/use-on-open.js.map +1 -0
  171. package/dist/hooks/use-row-cursor.d.ts +39 -0
  172. package/dist/hooks/use-row-cursor.d.ts.map +1 -0
  173. package/dist/hooks/use-row-cursor.js +77 -0
  174. package/dist/hooks/use-row-cursor.js.map +1 -0
  175. package/dist/lib/text-shimmer.d.ts +2 -2
  176. package/dist/lib/text-shimmer.d.ts.map +1 -1
  177. package/dist/lib/text-shimmer.js +2 -2
  178. package/dist/lib/text-shimmer.js.map +1 -1
  179. package/dist/presence-gate-BekdC4Bo.js +24 -0
  180. package/dist/presence-gate-BekdC4Bo.js.map +1 -0
  181. package/package.json +11 -11
  182. package/dist/components/motion/combobox/context.js.map +0 -1
  183. package/dist/components/reui/filters.d.ts +0 -176
  184. package/dist/components/reui/filters.d.ts.map +0 -1
  185. package/dist/components/reui/filters.js +0 -1223
  186. package/dist/components/reui/filters.js.map +0 -1
@@ -0,0 +1,456 @@
1
+ "use client";
2
+ import { useCascaderActions } from "./cascader-context.js";
3
+ import { CASCADER_LIST_PAD_CLASS, getCascaderFooterStops, isCascaderRtl } from "./cascader-lib.js";
4
+ import { CASCADER_ACTION_CLASS, CascaderGroup, CascaderLabel } from "./cascader-item.js";
5
+ import * as React$1 from "react";
6
+ import { cn } from "@kumix/utils";
7
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
8
+ import { ChevronRightIcon } from "lucide-react";
9
+ import { Popover } from "@base-ui/react";
10
+ import { useDirection } from "@base-ui/react/direction-provider";
11
+ //#region src/components/reui/cascader/cascader-footer.tsx
12
+ /**
13
+ * The pinned footer, and the side-anchored flyout a footer row can open. These
14
+ * are COMMANDS: nothing here joins the selection, the filter set or the
15
+ * highlight. The flyout is a Base UI `Popover` rendered as a REACT CHILD of
16
+ * `Combobox.Popup` with its OWN `Portal` and NO `container`: a nested portal
17
+ * resolves to the parent portal node, so it is a DOM sibling of the combobox
18
+ * popup (not clipped, not `aria-hidden`) but a React descendant, which is what
19
+ * the outside-press and focus-out whitelists read. `Combobox` builds no
20
+ * `FloatingTree`, so the flyout is not consulted first and one Escape would
21
+ * dismiss both; hence `CascaderSubmenu` registering with the root to turn one
22
+ * Escape into two. `Combobox.List` clicks its highlighted row on Enter, hence
23
+ * the footer sitting outside `CascaderList`. And a `Positioner` throws without
24
+ * its `Portal`, while `modal` stays `false` on the `Root` so the combobox
25
+ * keeps its own dismissal behaviour.
26
+ */
27
+ /**
28
+ * Keys the option list acts on, swallowed at the footer boundary. Escape and
29
+ * Tab are absent on purpose: Escape must reach the root, Tab must keep moving.
30
+ */
31
+ const FOOTER_SWALLOWED_KEYS = /* @__PURE__ */ new Set([
32
+ "Enter",
33
+ " ",
34
+ "ArrowUp",
35
+ "ArrowDown",
36
+ "Home",
37
+ "End",
38
+ "PageUp",
39
+ "PageDown"
40
+ ]);
41
+ /**
42
+ * Actions pinned below the list, a SIBLING of `CascaderList`. Children win
43
+ * over the root's `actions` prop; with neither it renders nothing.
44
+ */
45
+ function CascaderFooter({ className, children, onKeyDown, ...props }) {
46
+ const { actions, labels } = useCascaderActions();
47
+ const hasChildren = React$1.Children.count(children) > 0;
48
+ const handleKeyDown = React$1.useCallback((event) => {
49
+ onKeyDown?.(event);
50
+ if (event.defaultPrevented) return;
51
+ if (!FOOTER_SWALLOWED_KEYS.has(event.key)) return;
52
+ event.stopPropagation();
53
+ if (event.key !== "ArrowDown" && event.key !== "ArrowUp") return;
54
+ const footer = event.currentTarget;
55
+ const stops = getCascaderFooterStops(footer);
56
+ const active = document.activeElement;
57
+ const index = active ? stops.indexOf(active) : -1;
58
+ if (index === -1) return;
59
+ event.preventDefault();
60
+ const next = event.key === "ArrowDown" ? stops[index + 1] : stops[index - 1];
61
+ if (next) {
62
+ next.focus();
63
+ return;
64
+ }
65
+ if (event.key === "ArrowUp" && index > 0) return;
66
+ footer.closest("[data-slot=\"cascader-panel\"]")?.querySelector("[data-slot=\"cascader-input\"]")?.focus();
67
+ }, [onKeyDown]);
68
+ if (!hasChildren && actions.length === 0) return null;
69
+ return /* @__PURE__ */ jsx("div", {
70
+ "data-slot": "cascader-footer",
71
+ role: "group",
72
+ "aria-label": labels.actionsLabel,
73
+ onKeyDown: handleKeyDown,
74
+ className: cn("flex shrink-0 flex-col gap-0.5 border-border/60 border-t", CASCADER_LIST_PAD_CLASS, "p-(--cascader-list-pad,4px)", className),
75
+ ...props,
76
+ children: hasChildren ? children : /* @__PURE__ */ jsx(CascaderFooterActions, { actions })
77
+ });
78
+ }
79
+ function CascaderFooterActions({ actions }) {
80
+ return /* @__PURE__ */ jsx(Fragment$1, { children: actions.map((action, i) => action.items?.length ? /* @__PURE__ */ jsxs(CascaderSubmenu, { children: [/* @__PURE__ */ jsx(CascaderSubmenuTrigger, {
81
+ icon: action.icon,
82
+ disabled: action.disabled,
83
+ children: action.label
84
+ }), /* @__PURE__ */ jsx(CascaderSubmenuContent, { children: /* @__PURE__ */ jsx(CascaderActionList, { items: action.items }) })] }, actionKey(action, i)) : /* @__PURE__ */ jsx(CascaderAction, {
85
+ icon: action.icon,
86
+ disabled: action.disabled,
87
+ onSelect: action.onSelect,
88
+ children: action.label
89
+ }, actionKey(action, i))) });
90
+ }
91
+ function actionKey(action, index) {
92
+ if (action.value != null) return action.value;
93
+ if (typeof action.label === "string") return action.label;
94
+ return String(index);
95
+ }
96
+ /**
97
+ * Consecutive entries sharing a `group`, as runs not buckets: two separated
98
+ * runs with the same name stay two, so the author's order survives.
99
+ */
100
+ function groupActionRuns(items) {
101
+ const runs = [];
102
+ for (const item of items) {
103
+ const last = runs[runs.length - 1];
104
+ if (last && last.group === item.group) last.items.push(item);
105
+ else runs.push({
106
+ group: item.group,
107
+ items: [item]
108
+ });
109
+ }
110
+ return runs;
111
+ }
112
+ /**
113
+ * Flyout body for a data-driven submenu. A named run becomes a real
114
+ * `CascaderGroup`; unnamed runs stay unwrapped, as an unnamed group is noise.
115
+ */
116
+ function CascaderActionList({ items }) {
117
+ const { close } = useCascaderSubmenu();
118
+ const runs = React$1.useMemo(() => groupActionRuns(items), [items]);
119
+ const renderAction = (item, i) => /* @__PURE__ */ jsx(CascaderAction, {
120
+ icon: item.icon,
121
+ disabled: item.disabled,
122
+ onSelect: () => {
123
+ item.onSelect?.();
124
+ close();
125
+ },
126
+ children: item.label
127
+ }, actionKey(item, i));
128
+ return /* @__PURE__ */ jsx(Fragment$1, { children: runs.map((run, runIndex) => run.group ? /* @__PURE__ */ jsxs(CascaderGroup, {
129
+ className: "gap-0.5",
130
+ children: [/* @__PURE__ */ jsx(CascaderLabel, { children: run.group }), run.items.map(renderAction)]
131
+ }, `${run.group}-${runIndex}`) : /* @__PURE__ */ jsx(React$1.Fragment, { children: run.items.map(renderAction) }, `run-${runIndex}`)) });
132
+ }
133
+ /**
134
+ * The cascader popup's panel per style, spelled with `style-<name>:` variants
135
+ * rather than ReUI theme CSS so an installed footer needs only Tailwind.
136
+ */
137
+ const FLYOUT_SURFACE_CLASS = "bg-popover text-popover-foreground data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 max-h-72 overflow-hidden ring-1 duration-100 ring-foreground/10 shadow-md rounded-lg";
138
+ /**
139
+ * One footer command, shaped like a row and deliberately NOT one. A real
140
+ * `<button>`, never a `Combobox.Item`: an item would join the arrow-key ring,
141
+ * appear in `filteredItems`, and vanish the moment a query matched nothing -
142
+ * exactly when "Create new attribute" is most useful. Disabled is
143
+ * `aria-disabled`, never the native attribute: that one is not a tab stop and
144
+ * the panel's Tab order reads `button:not([disabled])`, so a footer whose ONLY
145
+ * row is a disabled command had no stop after the search field (measured on
146
+ * `c-cascader-8`). Staying focusable costs the guards below, plus the
147
+ * greyed-out look: `CASCADER_ACTION_CLASS` keys that off `aria-disabled`
148
+ * instead of `:disabled`.
149
+ */
150
+ function CascaderAction({ className, icon, children, onSelect, onClick, onKeyDown, disabled, ...props }) {
151
+ const inMenu = React$1.useContext(CascaderMenuContext);
152
+ const handleClick = React$1.useCallback((event) => {
153
+ if (disabled) {
154
+ event.preventDefault();
155
+ return;
156
+ }
157
+ onClick?.(event);
158
+ if (event.defaultPrevented) return;
159
+ onSelect?.();
160
+ }, [
161
+ disabled,
162
+ onClick,
163
+ onSelect
164
+ ]);
165
+ const handleKeyDown = React$1.useCallback((event) => {
166
+ if (disabled) {
167
+ if (event.key === "Enter" || event.key === " ") event.preventDefault();
168
+ return;
169
+ }
170
+ onKeyDown?.(event);
171
+ }, [disabled, onKeyDown]);
172
+ return /* @__PURE__ */ jsxs("button", {
173
+ type: "button",
174
+ "data-slot": "cascader-action",
175
+ ...disabled ? {
176
+ "aria-disabled": true,
177
+ "data-disabled": ""
178
+ } : null,
179
+ onClick: handleClick,
180
+ onKeyDown: handleKeyDown,
181
+ ...inMenu ? {
182
+ role: "menuitem",
183
+ tabIndex: -1
184
+ } : null,
185
+ className: cn(CASCADER_ACTION_CLASS, className),
186
+ ...props,
187
+ children: [icon ? /* @__PURE__ */ jsx("span", {
188
+ "data-slot": "cascader-action-icon",
189
+ className: "flex shrink-0 items-center justify-center text-muted-foreground",
190
+ children: icon
191
+ }) : null, /* @__PURE__ */ jsx("span", {
192
+ className: "min-w-0 flex-1 truncate text-start",
193
+ children
194
+ })]
195
+ });
196
+ }
197
+ /** Marks the subtree INSIDE a flyout. See `inMenu` in `CascaderAction`. */
198
+ const CascaderMenuContext = React$1.createContext(false);
199
+ /**
200
+ * Every entry a menu's roving focus may land on, in DOM order, read from the
201
+ * DOM because the entries are whatever the consumer composed. A disabled
202
+ * `CascaderAction` is INCLUDED: it carries `aria-disabled`, not the native
203
+ * attribute, so `:not([disabled])` excludes only a consumer's own natively
204
+ * disabled `menuitem`, which cannot take focus.
205
+ */
206
+ function menuItems(popup) {
207
+ if (!popup) return [];
208
+ return Array.from(popup.querySelectorAll("[role=\"menuitem\"]:not([disabled])"));
209
+ }
210
+ const CascaderSubmenuContext = React$1.createContext(void 0);
211
+ /** The flyout's own state. `close()` is the one a custom entry usually wants. */
212
+ function useCascaderSubmenu() {
213
+ const context = React$1.useContext(CascaderSubmenuContext);
214
+ if (!context) throw new Error("useCascaderSubmenu must be used within a CascaderSubmenu");
215
+ return context;
216
+ }
217
+ /**
218
+ * A footer row plus the flyout it opens. Registers with the cascader root
219
+ * while open, which turns one Escape into two. Cleared in an EFFECT, so the
220
+ * flyout still reads as open during the event that closed it.
221
+ */
222
+ function CascaderSubmenu({ open: openProp, defaultOpen = false, onOpenChange, children }) {
223
+ const { setFlyoutOpen } = useCascaderActions();
224
+ const key = React$1.useId();
225
+ const triggerId = React$1.useId();
226
+ const rowRef = React$1.useRef(null);
227
+ const keyboardRef = React$1.useRef(false);
228
+ const [uncontrolled, setUncontrolled] = React$1.useState(defaultOpen);
229
+ const open = openProp ?? uncontrolled;
230
+ const setOpen = React$1.useCallback((next) => {
231
+ if (openProp == null) setUncontrolled(next);
232
+ onOpenChange?.(next);
233
+ }, [openProp, onOpenChange]);
234
+ const close = React$1.useCallback(() => setOpen(false), [setOpen]);
235
+ React$1.useEffect(() => {
236
+ setFlyoutOpen(key, open);
237
+ return () => setFlyoutOpen(key, false);
238
+ }, [
239
+ setFlyoutOpen,
240
+ key,
241
+ open
242
+ ]);
243
+ const context = React$1.useMemo(() => ({
244
+ rowRef,
245
+ open,
246
+ setOpen,
247
+ close,
248
+ triggerId,
249
+ keyboardRef
250
+ }), [
251
+ open,
252
+ setOpen,
253
+ close,
254
+ triggerId
255
+ ]);
256
+ return /* @__PURE__ */ jsx(CascaderSubmenuContext.Provider, {
257
+ value: context,
258
+ children: /* @__PURE__ */ jsx(Popover.Root, {
259
+ open,
260
+ onOpenChange: setOpen,
261
+ modal: false,
262
+ children
263
+ })
264
+ });
265
+ }
266
+ /**
267
+ * The footer row that opens the flyout, and its anchor. `aria-haspopup="menu"`
268
+ * rather than the `dialog` Base UI would announce: what opens is a list of
269
+ * commands with roving focus. `disabled` is intercepted, not forwarded:
270
+ * `Popover.Trigger` runs it through `useButton`, which writes the NATIVE
271
+ * attribute for a native `<button>` and takes the row out of the panel's Tab
272
+ * ring, the defect `CascaderAction` documents, and this component exposes no
273
+ * `focusableWhenDisabled` to opt out. Published as `aria-disabled`, with the
274
+ * arrow keys, Enter and Space, and the click closed by hand (`useClick`
275
+ * ignores `defaultPrevented`).
276
+ */
277
+ function CascaderSubmenuTrigger({ className, icon, children, onKeyDown, onClick, disabled, ...props }) {
278
+ const { labels } = useCascaderActions();
279
+ const { rowRef, setOpen, triggerId, keyboardRef } = useCascaderSubmenu();
280
+ const direction = useDirection();
281
+ const handleClick = React$1.useCallback((event) => {
282
+ if (disabled) {
283
+ event.preventDefault();
284
+ event.preventBaseUIHandler();
285
+ return;
286
+ }
287
+ onClick?.(event);
288
+ }, [disabled, onClick]);
289
+ const handleKeyDown = React$1.useCallback((event) => {
290
+ if (disabled) {
291
+ if (event.key === "Enter" || event.key === " ") event.preventDefault();
292
+ return;
293
+ }
294
+ onKeyDown?.(event);
295
+ if (event.defaultPrevented) return;
296
+ const openKey = isCascaderRtl(event.currentTarget, direction) ? "ArrowLeft" : "ArrowRight";
297
+ if (event.key === "Enter" || event.key === " ") {
298
+ keyboardRef.current = true;
299
+ return;
300
+ }
301
+ if (event.key !== openKey) return;
302
+ event.preventDefault();
303
+ keyboardRef.current = true;
304
+ setOpen(true);
305
+ }, [
306
+ disabled,
307
+ onKeyDown,
308
+ direction,
309
+ setOpen,
310
+ keyboardRef
311
+ ]);
312
+ return /* @__PURE__ */ jsxs(Popover.Trigger, {
313
+ ref: rowRef,
314
+ id: triggerId,
315
+ "data-slot": "cascader-submenu-trigger",
316
+ "aria-haspopup": "menu",
317
+ ...disabled ? {
318
+ "aria-disabled": true,
319
+ "data-disabled": ""
320
+ } : null,
321
+ onClick: handleClick,
322
+ onKeyDown: handleKeyDown,
323
+ className: cn(CASCADER_ACTION_CLASS, "aria-expanded:bg-accent aria-expanded:text-accent-foreground", className),
324
+ ...props,
325
+ children: [
326
+ icon ? /* @__PURE__ */ jsx("span", {
327
+ "data-slot": "cascader-action-icon",
328
+ className: "flex shrink-0 items-center justify-center text-muted-foreground",
329
+ children: icon
330
+ }) : null,
331
+ /* @__PURE__ */ jsx("span", {
332
+ className: "min-w-0 flex-1 truncate text-start",
333
+ children
334
+ }),
335
+ /* @__PURE__ */ jsxs("span", {
336
+ className: "sr-only",
337
+ children: [", ", labels.submenuAffordance]
338
+ }),
339
+ /* @__PURE__ */ jsx(ChevronRightIcon, {
340
+ "aria-hidden": "true",
341
+ className: "-me-0.5 size-4 shrink-0 text-muted-foreground rtl:-scale-x-100"
342
+ })
343
+ ]
344
+ });
345
+ }
346
+ /**
347
+ * The flyout itself. `Portal` with NO `container`: a nested portal resolves to
348
+ * the parent portal node, the mechanism the file header describes.
349
+ */
350
+ function CascaderSubmenuContent({ className, children, onKeyDown, side = "inline-end", align = "end", sideOffset = 8, alignOffset = 0, ...props }) {
351
+ const { rowRef, close, triggerId, keyboardRef } = useCascaderSubmenu();
352
+ const direction = useDirection();
353
+ const popupRef = React$1.useRef(null);
354
+ const typeaheadRef = React$1.useRef({
355
+ buffer: "",
356
+ at: 0
357
+ });
358
+ /**
359
+ * Keyboard opens land on the first entry; a pointer open falls through to
360
+ * Base UI's default, the popup, so a click paints no focus ring. Not an
361
+ * effect of our own: Base UI's focus manager runs on open and wins the race.
362
+ */
363
+ const initialFocus = React$1.useCallback(() => {
364
+ const byKeyboard = keyboardRef.current;
365
+ keyboardRef.current = false;
366
+ if (!byKeyboard) return true;
367
+ return menuItems(popupRef.current)[0] ?? true;
368
+ }, [keyboardRef]);
369
+ const closeAndReturn = React$1.useCallback(() => {
370
+ close();
371
+ rowRef.current?.focus();
372
+ }, [close, rowRef]);
373
+ const handleKeyDown = React$1.useCallback((event) => {
374
+ onKeyDown?.(event);
375
+ event.stopPropagation();
376
+ if (event.defaultPrevented) return;
377
+ const popup = popupRef.current;
378
+ const items = menuItems(popup);
379
+ if (items.length === 0) return;
380
+ const active = document.activeElement;
381
+ const index = active ? items.indexOf(active) : -1;
382
+ const move = (next) => {
383
+ event.preventDefault();
384
+ items[(next + items.length) % items.length]?.focus();
385
+ };
386
+ const closeKey = isCascaderRtl(event.currentTarget, direction) ? "ArrowRight" : "ArrowLeft";
387
+ switch (event.key) {
388
+ case "ArrowDown": return move(index + 1);
389
+ case "ArrowUp": return move(index === -1 ? items.length - 1 : index - 1);
390
+ case "Home": return move(0);
391
+ case "End": return move(items.length - 1);
392
+ case closeKey:
393
+ event.preventDefault();
394
+ return closeAndReturn();
395
+ case "Tab":
396
+ close();
397
+ rowRef.current?.focus();
398
+ return;
399
+ }
400
+ if (event.key.length !== 1 || event.metaKey || event.ctrlKey || event.altKey) return;
401
+ const now = event.timeStamp;
402
+ const state = typeaheadRef.current;
403
+ state.buffer = now - state.at > 500 ? event.key : state.buffer + event.key;
404
+ state.at = now;
405
+ const prefix = state.buffer.toLowerCase();
406
+ const from = index === -1 ? 0 : index;
407
+ const hit = [...items.slice(state.buffer.length > 1 ? from : from + 1), ...items.slice(0, state.buffer.length > 1 ? from : from + 1)].find((item) => (item.textContent ?? "").trim().toLowerCase().startsWith(prefix));
408
+ if (hit) {
409
+ event.preventDefault();
410
+ hit.focus();
411
+ }
412
+ }, [
413
+ onKeyDown,
414
+ direction,
415
+ close,
416
+ closeAndReturn,
417
+ rowRef
418
+ ]);
419
+ return /* @__PURE__ */ jsx(Popover.Portal, { children: /* @__PURE__ */ jsx(Popover.Positioner, {
420
+ anchor: rowRef,
421
+ side,
422
+ align,
423
+ sideOffset,
424
+ alignOffset,
425
+ className: "isolate z-50",
426
+ children: /* @__PURE__ */ jsx(Popover.Popup, {
427
+ ref: popupRef,
428
+ initialFocus,
429
+ "data-slot": "cascader-submenu-content",
430
+ role: "menu",
431
+ "aria-orientation": "vertical",
432
+ "aria-labelledby": triggerId,
433
+ tabIndex: -1,
434
+ onKeyDown: handleKeyDown,
435
+ "data-menu-target": "",
436
+ className: cn(FLYOUT_SURFACE_CLASS, "flex min-w-48 max-w-(--available-width) flex-col gap-0.5 outline-hidden", CASCADER_LIST_PAD_CLASS, "p-(--cascader-list-pad,4px)", className),
437
+ ...props,
438
+ children: /* @__PURE__ */ jsx(CascaderMenuContext.Provider, {
439
+ value: true,
440
+ children
441
+ })
442
+ })
443
+ }) });
444
+ }
445
+ /**
446
+ * Whether the footer would render anything, for a wrapper (a separator, a grid
447
+ * row) that has to make the same call `CascaderFooter` already makes.
448
+ */
449
+ function useCascaderHasActions() {
450
+ const { actions } = useCascaderActions();
451
+ return actions.length > 0;
452
+ }
453
+ //#endregion
454
+ export { CascaderAction, CascaderFooter, CascaderSubmenu, CascaderSubmenuContent, CascaderSubmenuTrigger, useCascaderHasActions, useCascaderSubmenu };
455
+
456
+ //# sourceMappingURL=cascader-footer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cascader-footer.js","names":["React","PopoverPrimitive"],"sources":["../../../../src/components/reui/cascader/cascader-footer.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { Popover as PopoverPrimitive } from \"@base-ui/react\";\nimport { useDirection } from \"@base-ui/react/direction-provider\";\nimport { ChevronRightIcon } from \"lucide-react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { useCascaderActions } from \"./cascader-context\";\nimport { CASCADER_ACTION_CLASS, CascaderGroup, CascaderLabel } from \"./cascader-item\";\nimport { CASCADER_LIST_PAD_CLASS, getCascaderFooterStops, isCascaderRtl } from \"./cascader-lib\";\nimport type { CascaderActionItem } from \"./cascader-types\";\n\n/**\n * The pinned footer, and the side-anchored flyout a footer row can open. These\n * are COMMANDS: nothing here joins the selection, the filter set or the\n * highlight. The flyout is a Base UI `Popover` rendered as a REACT CHILD of\n * `Combobox.Popup` with its OWN `Portal` and NO `container`: a nested portal\n * resolves to the parent portal node, so it is a DOM sibling of the combobox\n * popup (not clipped, not `aria-hidden`) but a React descendant, which is what\n * the outside-press and focus-out whitelists read. `Combobox` builds no\n * `FloatingTree`, so the flyout is not consulted first and one Escape would\n * dismiss both; hence `CascaderSubmenu` registering with the root to turn one\n * Escape into two. `Combobox.List` clicks its highlighted row on Enter, hence\n * the footer sitting outside `CascaderList`. And a `Positioner` throws without\n * its `Portal`, while `modal` stays `false` on the `Root` so the combobox\n * keeps its own dismissal behaviour.\n */\n\n/* -------------------------------------------------------------------------- */\n/* Footer */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Keys the option list acts on, swallowed at the footer boundary. Escape and\n * Tab are absent on purpose: Escape must reach the root, Tab must keep moving.\n */\nconst FOOTER_SWALLOWED_KEYS = new Set([\n \"Enter\",\n \" \",\n \"ArrowUp\",\n \"ArrowDown\",\n \"Home\",\n \"End\",\n \"PageUp\",\n \"PageDown\",\n]);\n\nexport type CascaderFooterProps = React.ComponentProps<\"div\">;\n\n/**\n * Actions pinned below the list, a SIBLING of `CascaderList`. Children win\n * over the root's `actions` prop; with neither it renders nothing.\n */\nfunction CascaderFooter({ className, children, onKeyDown, ...props }: CascaderFooterProps) {\n const { actions, labels } = useCascaderActions();\n const hasChildren = React.Children.count(children) > 0;\n\n const handleKeyDown = React.useCallback(\n (event: React.KeyboardEvent<HTMLDivElement>) => {\n onKeyDown?.(event);\n if (event.defaultPrevented) return;\n if (!FOOTER_SWALLOWED_KEYS.has(event.key)) return;\n event.stopPropagation();\n\n // The strip's own vertical movement, and the way back from the list's\n // hand-off: either end returns focus to the search field, from which\n // Base UI's empty highlight resumes the list. Down wraps to the FIELD,\n // not a command (traps the arrows) or a row (no imperative highlight).\n if (event.key !== \"ArrowDown\" && event.key !== \"ArrowUp\") return;\n const footer = event.currentTarget;\n const stops = getCascaderFooterStops(footer);\n const active = document.activeElement as HTMLElement | null;\n const index = active ? stops.indexOf(active) : -1;\n if (index === -1) return;\n event.preventDefault();\n const next = event.key === \"ArrowDown\" ? stops[index + 1] : stops[index - 1];\n if (next) {\n next.focus();\n return;\n }\n if (event.key === \"ArrowUp\" && index > 0) return;\n footer\n .closest<HTMLElement>('[data-slot=\"cascader-panel\"]')\n ?.querySelector<HTMLElement>('[data-slot=\"cascader-input\"]')\n ?.focus();\n },\n [onKeyDown],\n );\n\n if (!hasChildren && actions.length === 0) return null;\n\n return (\n <div\n data-slot=\"cascader-footer\"\n /* Named, not a bare div: without it a screen reader reaches the actions\n with nothing to say they are not more options. */\n role=\"group\"\n aria-label={labels.actionsLabel}\n onKeyDown={handleKeyDown}\n className={cn(\n \"flex shrink-0 flex-col gap-0.5 border-border/60 border-t\",\n /* The LIST's padding, not a flat `p-1`: with a padding of its own the\n two columns of text were 2px out in luma and sera and 4px out in\n lyra. It also gives a separator in here a number to cancel. */\n CASCADER_LIST_PAD_CLASS,\n \"p-(--cascader-list-pad,4px)\",\n className,\n )}\n {...props}\n >\n {hasChildren ? children : <CascaderFooterActions actions={actions} />}\n </div>\n );\n}\n\nfunction CascaderFooterActions({ actions }: { actions: CascaderActionItem[] }) {\n return (\n <>\n {actions.map((action, i) =>\n action.items?.length ? (\n <CascaderSubmenu key={actionKey(action, i)}>\n <CascaderSubmenuTrigger icon={action.icon} disabled={action.disabled}>\n {action.label}\n </CascaderSubmenuTrigger>\n <CascaderSubmenuContent>\n <CascaderActionList items={action.items} />\n </CascaderSubmenuContent>\n </CascaderSubmenu>\n ) : (\n <CascaderAction\n key={actionKey(action, i)}\n icon={action.icon}\n disabled={action.disabled}\n onSelect={action.onSelect}\n >\n {action.label}\n </CascaderAction>\n ),\n )}\n </>\n );\n}\n\nfunction actionKey(action: CascaderActionItem, index: number): string {\n if (action.value != null) return action.value;\n if (typeof action.label === \"string\") return action.label;\n return String(index);\n}\n\n/**\n * Consecutive entries sharing a `group`, as runs not buckets: two separated\n * runs with the same name stay two, so the author's order survives.\n */\nfunction groupActionRuns(\n items: CascaderActionItem[],\n): { group?: string; items: CascaderActionItem[] }[] {\n const runs: { group?: string; items: CascaderActionItem[] }[] = [];\n for (const item of items) {\n const last = runs[runs.length - 1];\n if (last && last.group === item.group) last.items.push(item);\n else runs.push({ group: item.group, items: [item] });\n }\n return runs;\n}\n\n/**\n * Flyout body for a data-driven submenu. A named run becomes a real\n * `CascaderGroup`; unnamed runs stay unwrapped, as an unnamed group is noise.\n */\nfunction CascaderActionList({ items }: { items: CascaderActionItem[] }) {\n const { close } = useCascaderSubmenu();\n const runs = React.useMemo(() => groupActionRuns(items), [items]);\n\n const renderAction = (item: CascaderActionItem, i: number) => (\n <CascaderAction\n key={actionKey(item, i)}\n icon={item.icon}\n disabled={item.disabled}\n onSelect={() => {\n item.onSelect?.();\n /* Closes behind the command, or the entries would read as toggles. */\n close();\n }}\n >\n {item.label}\n </CascaderAction>\n );\n\n return (\n <>\n {runs.map((run, runIndex) =>\n run.group ? (\n <CascaderGroup key={`${run.group}-${runIndex}`} className=\"gap-0.5\">\n <CascaderLabel>{run.group}</CascaderLabel>\n {run.items.map(renderAction)}\n </CascaderGroup>\n ) : (\n <React.Fragment key={`run-${runIndex}`}>{run.items.map(renderAction)}</React.Fragment>\n ),\n )}\n </>\n );\n}\n\n/* -------------------------------------------------------------------------- */\n/* Action */\n/* -------------------------------------------------------------------------- */\n\nexport interface CascaderActionProps extends Omit<React.ComponentProps<\"button\">, \"onSelect\"> {\n icon?: React.ReactNode;\n /** Fires on press, after `onClick`, and not at all when disabled. */\n onSelect?: () => void;\n}\n\n/**\n * The cascader popup's panel per style, spelled with `style-<name>:` variants\n * rather than ReUI theme CSS so an installed footer needs only Tailwind.\n */\nconst FLYOUT_SURFACE_CLASS =\n \"bg-popover text-popover-foreground data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 max-h-72 overflow-hidden ring-1 duration-100 ring-foreground/10 shadow-md rounded-lg\";\n\n/**\n * One footer command, shaped like a row and deliberately NOT one. A real\n * `<button>`, never a `Combobox.Item`: an item would join the arrow-key ring,\n * appear in `filteredItems`, and vanish the moment a query matched nothing -\n * exactly when \"Create new attribute\" is most useful. Disabled is\n * `aria-disabled`, never the native attribute: that one is not a tab stop and\n * the panel's Tab order reads `button:not([disabled])`, so a footer whose ONLY\n * row is a disabled command had no stop after the search field (measured on\n * `c-cascader-8`). Staying focusable costs the guards below, plus the\n * greyed-out look: `CASCADER_ACTION_CLASS` keys that off `aria-disabled`\n * instead of `:disabled`.\n */\nfunction CascaderAction({\n className,\n icon,\n children,\n onSelect,\n onClick,\n onKeyDown,\n disabled,\n ...props\n}: CascaderActionProps) {\n // Set by `CascaderSubmenuContent`: a plain button in the footer's Tab ring,\n // a roving-focus `menuitem` inside a flyout, never both.\n const inMenu = React.useContext(CascaderMenuContext);\n\n const handleClick = React.useCallback(\n (event: React.MouseEvent<HTMLButtonElement>) => {\n // Before the consumer's handler: a disabled command runs none of them.\n if (disabled) {\n event.preventDefault();\n return;\n }\n onClick?.(event);\n if (event.defaultPrevented) return;\n onSelect?.();\n },\n [disabled, onClick, onSelect],\n );\n\n const handleKeyDown = React.useCallback(\n (event: React.KeyboardEvent<HTMLButtonElement>) => {\n if (disabled) {\n // The two keys a `<button>` activates on, and only those.\n if (event.key === \"Enter\" || event.key === \" \") event.preventDefault();\n return;\n }\n onKeyDown?.(event);\n },\n [disabled, onKeyDown],\n );\n\n return (\n <button\n type=\"button\"\n data-slot=\"cascader-action\"\n /* Conditional spread: `false` would publish `aria-disabled=\"false\"`. */\n {...(disabled ? { \"aria-disabled\": true, \"data-disabled\": \"\" } : null)}\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n /* Conditional spread, so a consumer's own `role` or `tabIndex` wins. */\n {...(inMenu ? { role: \"menuitem\" as const, tabIndex: -1 } : null)}\n className={cn(CASCADER_ACTION_CLASS, className)}\n {...props}\n >\n {icon ? (\n <span\n data-slot=\"cascader-action-icon\"\n className=\"flex shrink-0 items-center justify-center text-muted-foreground\"\n >\n {icon}\n </span>\n ) : null}\n <span className=\"min-w-0 flex-1 truncate text-start\">{children}</span>\n </button>\n );\n}\n\n/* -------------------------------------------------------------------------- */\n/* Submenu */\n/* -------------------------------------------------------------------------- */\n\ninterface CascaderSubmenuContextValue {\n rowRef: React.RefObject<HTMLButtonElement | null>;\n open: boolean;\n setOpen: (open: boolean) => void;\n close: () => void;\n /** Names the flyout: a menu is labelled by the control that opens it. */\n triggerId: string;\n /**\n * Whether the pending open came from the KEYBOARD. Base UI's own `openType`\n * calls the opening arrow a POINTER open, because the trigger intercepts it\n * and calls `setOpen` (measured: focus landed on the popup, not the first\n * entry). A ref, so reading it in the focus phase cannot render.\n */\n keyboardRef: React.RefObject<boolean>;\n}\n\n/** Marks the subtree INSIDE a flyout. See `inMenu` in `CascaderAction`. */\nconst CascaderMenuContext = React.createContext(false);\n\n/**\n * Every entry a menu's roving focus may land on, in DOM order, read from the\n * DOM because the entries are whatever the consumer composed. A disabled\n * `CascaderAction` is INCLUDED: it carries `aria-disabled`, not the native\n * attribute, so `:not([disabled])` excludes only a consumer's own natively\n * disabled `menuitem`, which cannot take focus.\n */\nfunction menuItems(popup: HTMLElement | null): HTMLElement[] {\n if (!popup) return [];\n return Array.from(popup.querySelectorAll<HTMLElement>('[role=\"menuitem\"]:not([disabled])'));\n}\n\nconst CascaderSubmenuContext = React.createContext<CascaderSubmenuContextValue | undefined>(\n undefined,\n);\n\n/** The flyout's own state. `close()` is the one a custom entry usually wants. */\nexport function useCascaderSubmenu(): CascaderSubmenuContextValue {\n const context = React.useContext(CascaderSubmenuContext);\n if (!context) {\n throw new Error(\"useCascaderSubmenu must be used within a CascaderSubmenu\");\n }\n return context;\n}\n\nexport interface CascaderSubmenuProps {\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n children?: React.ReactNode;\n}\n\n/**\n * A footer row plus the flyout it opens. Registers with the cascader root\n * while open, which turns one Escape into two. Cleared in an EFFECT, so the\n * flyout still reads as open during the event that closed it.\n */\nfunction CascaderSubmenu({\n open: openProp,\n defaultOpen = false,\n onOpenChange,\n children,\n}: CascaderSubmenuProps) {\n const { setFlyoutOpen } = useCascaderActions();\n const key = React.useId();\n const triggerId = React.useId();\n const rowRef = React.useRef<HTMLButtonElement | null>(null);\n const keyboardRef = React.useRef(false);\n const [uncontrolled, setUncontrolled] = React.useState(defaultOpen);\n const open = openProp ?? uncontrolled;\n\n const setOpen = React.useCallback(\n (next: boolean) => {\n if (openProp == null) setUncontrolled(next);\n onOpenChange?.(next);\n },\n [openProp, onOpenChange],\n );\n\n const close = React.useCallback(() => setOpen(false), [setOpen]);\n\n React.useEffect(() => {\n setFlyoutOpen(key, open);\n return () => setFlyoutOpen(key, false);\n }, [setFlyoutOpen, key, open]);\n\n const context = React.useMemo<CascaderSubmenuContextValue>(\n () => ({ rowRef, open, setOpen, close, triggerId, keyboardRef }),\n [open, setOpen, close, triggerId],\n );\n\n return (\n <CascaderSubmenuContext.Provider value={context}>\n <PopoverPrimitive.Root\n open={open}\n onOpenChange={setOpen}\n /* NEVER modal: it would disable the combobox that owns it. */\n modal={false}\n >\n {children}\n </PopoverPrimitive.Root>\n </CascaderSubmenuContext.Provider>\n );\n}\n\nexport interface CascaderSubmenuTriggerProps\n extends Omit<React.ComponentProps<\"button\">, \"onSelect\"> {\n icon?: React.ReactNode;\n}\n\n/** Carries the handler-veto hook, derived so a Base UI bump cannot drift. */\ntype CascaderSubmenuTriggerClickEvent = Parameters<\n NonNullable<PopoverPrimitive.Trigger.Props[\"onClick\"]>\n>[0];\n\n/**\n * The footer row that opens the flyout, and its anchor. `aria-haspopup=\"menu\"`\n * rather than the `dialog` Base UI would announce: what opens is a list of\n * commands with roving focus. `disabled` is intercepted, not forwarded:\n * `Popover.Trigger` runs it through `useButton`, which writes the NATIVE\n * attribute for a native `<button>` and takes the row out of the panel's Tab\n * ring, the defect `CascaderAction` documents, and this component exposes no\n * `focusableWhenDisabled` to opt out. Published as `aria-disabled`, with the\n * arrow keys, Enter and Space, and the click closed by hand (`useClick`\n * ignores `defaultPrevented`).\n */\nfunction CascaderSubmenuTrigger({\n className,\n icon,\n children,\n onKeyDown,\n onClick,\n disabled,\n ...props\n}: CascaderSubmenuTriggerProps) {\n const { labels } = useCascaderActions();\n const { rowRef, setOpen, triggerId, keyboardRef } = useCascaderSubmenu();\n const direction = useDirection();\n\n const handleClick = React.useCallback(\n (event: CascaderSubmenuTriggerClickEvent) => {\n if (disabled) {\n // `mergeProps` runs right to left, so this drops Base UI's own handler.\n event.preventDefault();\n event.preventBaseUIHandler();\n return;\n }\n onClick?.(event);\n },\n [disabled, onClick],\n );\n\n const handleKeyDown = React.useCallback(\n (event: React.KeyboardEvent<HTMLButtonElement>) => {\n if (disabled) {\n if (event.key === \"Enter\" || event.key === \" \") event.preventDefault();\n return;\n }\n\n onKeyDown?.(event);\n if (event.defaultPrevented) return;\n\n // The opening key points AT the flyout, so it flips with the writing\n // direction; ArrowDown stays \"next command\". Resolved per keydown, never\n // `useDirection()` alone: with no provider that answers \"ltr\" in RTL.\n const openKey = isCascaderRtl(event.currentTarget, direction) ? \"ArrowLeft\" : \"ArrowRight\";\n\n // Enter and Space open through the button's own click, so only FLAGGED.\n if (event.key === \"Enter\" || event.key === \" \") {\n keyboardRef.current = true;\n return;\n }\n\n if (event.key !== openKey) return;\n\n event.preventDefault();\n keyboardRef.current = true;\n setOpen(true);\n },\n [disabled, onKeyDown, direction, setOpen, keyboardRef],\n );\n\n return (\n <PopoverPrimitive.Trigger\n ref={rowRef}\n id={triggerId}\n data-slot=\"cascader-submenu-trigger\"\n aria-haspopup=\"menu\"\n /* NOT `disabled={disabled}`: Base UI writes the native attribute. */\n {...(disabled ? { \"aria-disabled\": true, \"data-disabled\": \"\" } : null)}\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n className={cn(\n CASCADER_ACTION_CLASS,\n /* Painted while the flyout is open, as shadcn paints a SubTrigger.\n Keyed off `aria-expanded`, not shadcn's `data-[state=open]`: the\n popover trigger carries `aria-expanded` in both states. */\n \"aria-expanded:bg-accent aria-expanded:text-accent-foreground\",\n className,\n )}\n {...props}\n >\n {icon ? (\n <span\n data-slot=\"cascader-action-icon\"\n className=\"flex shrink-0 items-center justify-center text-muted-foreground\"\n >\n {icon}\n </span>\n ) : null}\n <span className=\"min-w-0 flex-1 truncate text-start\">{children}</span>\n {/* Nothing else says the row opens a MENU, not another tree level. */}\n <span className=\"sr-only\">, {labels.submenuAffordance}</span>\n <ChevronRightIcon\n aria-hidden=\"true\"\n className=\"-me-0.5 size-4 shrink-0 text-muted-foreground rtl:-scale-x-100\"\n />\n </PopoverPrimitive.Trigger>\n );\n}\n\nexport interface CascaderSubmenuContentProps\n extends PopoverPrimitive.Popup.Props,\n Pick<PopoverPrimitive.Positioner.Props, \"side\" | \"align\" | \"sideOffset\" | \"alignOffset\"> {}\n\n/** Carries Base UI's handler-veto hook, so a plain React event will not do. */\ntype CascaderSubmenuKeyEvent = Parameters<\n NonNullable<PopoverPrimitive.Popup.Props[\"onKeyDown\"]>\n>[0];\n\n/**\n * The flyout itself. `Portal` with NO `container`: a nested portal resolves to\n * the parent portal node, the mechanism the file header describes.\n */\nfunction CascaderSubmenuContent({\n className,\n children,\n onKeyDown,\n side = \"inline-end\",\n align = \"end\",\n sideOffset = 8,\n alignOffset = 0,\n ...props\n}: CascaderSubmenuContentProps) {\n const { rowRef, close, triggerId, keyboardRef } = useCascaderSubmenu();\n const direction = useDirection();\n const popupRef = React.useRef<HTMLDivElement | null>(null);\n const typeaheadRef = React.useRef({ buffer: \"\", at: 0 });\n\n /**\n * Keyboard opens land on the first entry; a pointer open falls through to\n * Base UI's default, the popup, so a click paints no focus ring. Not an\n * effect of our own: Base UI's focus manager runs on open and wins the race.\n */\n const initialFocus = React.useCallback(() => {\n const byKeyboard = keyboardRef.current;\n keyboardRef.current = false;\n if (!byKeyboard) return true;\n return menuItems(popupRef.current)[0] ?? true;\n }, [keyboardRef]);\n\n const closeAndReturn = React.useCallback(() => {\n close();\n rowRef.current?.focus();\n }, [close, rowRef]);\n\n const handleKeyDown = React.useCallback(\n (event: CascaderSubmenuKeyEvent) => {\n onKeyDown?.(event);\n // A DOM sibling of the combobox popup but a REACT descendant, so keys in\n // here reach its handlers unless stopped. Enter would commit a row.\n event.stopPropagation();\n if (event.defaultPrevented) return;\n\n const popup = popupRef.current;\n const items = menuItems(popup);\n if (items.length === 0) return;\n\n const active = document.activeElement as HTMLElement | null;\n const index = active ? items.indexOf(active) : -1;\n const move = (next: number) => {\n event.preventDefault();\n items[(next + items.length) % items.length]?.focus();\n };\n\n // Mirrors the open key on the SAME per-keydown answer as the trigger.\n const closeKey = isCascaderRtl(event.currentTarget, direction) ? \"ArrowRight\" : \"ArrowLeft\";\n\n switch (event.key) {\n case \"ArrowDown\":\n return move(index + 1);\n case \"ArrowUp\":\n // From the popup itself (a pointer open) Up means the LAST entry.\n return move(index === -1 ? items.length - 1 : index - 1);\n case \"Home\":\n return move(0);\n case \"End\":\n return move(items.length - 1);\n case closeKey:\n event.preventDefault();\n return closeAndReturn();\n case \"Tab\":\n // A menu never holds Tab: it closes and focus carries on from its row.\n close();\n rowRef.current?.focus();\n return;\n default:\n break;\n }\n\n // Typeahead, after the switch so it can never swallow a navigation key.\n if (event.key.length !== 1 || event.metaKey || event.ctrlKey || event.altKey) return;\n const now = event.timeStamp;\n const state = typeaheadRef.current;\n state.buffer = now - state.at > 500 ? event.key : state.buffer + event.key;\n state.at = now;\n const prefix = state.buffer.toLowerCase();\n const from = index === -1 ? 0 : index;\n // Starts AFTER the current entry so one letter cycles rather than sticks.\n const ordered = [\n ...items.slice(state.buffer.length > 1 ? from : from + 1),\n ...items.slice(0, state.buffer.length > 1 ? from : from + 1),\n ];\n const hit = ordered.find((item) =>\n (item.textContent ?? \"\").trim().toLowerCase().startsWith(prefix),\n );\n if (hit) {\n event.preventDefault();\n hit.focus();\n }\n },\n [onKeyDown, direction, close, closeAndReturn, rowRef],\n );\n\n return (\n <PopoverPrimitive.Portal>\n <PopoverPrimitive.Positioner\n /* The ROW, not whatever Base UI last treated as the trigger. */\n anchor={rowRef}\n side={side}\n align={align}\n sideOffset={sideOffset}\n alignOffset={alignOffset}\n className=\"isolate z-50\"\n >\n <PopoverPrimitive.Popup\n ref={popupRef}\n initialFocus={initialFocus}\n data-slot=\"cascader-submenu-content\"\n /* Roving focus, named by the row that opens it. `tabIndex={-1}` lets\n a pointer open park focus here without adding a Tab stop. */\n role=\"menu\"\n aria-orientation=\"vertical\"\n aria-labelledby={triggerId}\n tabIndex={-1}\n onKeyDown={handleKeyDown}\n /* Marks a menu surface for the docs design-system picker, which\n repaints menus by walking the DOM. An attribute, not a class. */\n data-menu-target=\"\"\n className={cn(\n FLYOUT_SURFACE_CLASS,\n \"flex min-w-48 max-w-(--available-width) flex-col gap-0.5 outline-hidden\",\n CASCADER_LIST_PAD_CLASS,\n \"p-(--cascader-list-pad,4px)\",\n className,\n )}\n {...props}\n >\n <CascaderMenuContext.Provider value={true}>{children}</CascaderMenuContext.Provider>\n </PopoverPrimitive.Popup>\n </PopoverPrimitive.Positioner>\n </PopoverPrimitive.Portal>\n );\n}\n\n/**\n * Whether the footer would render anything, for a wrapper (a separator, a grid\n * row) that has to make the same call `CascaderFooter` already makes.\n */\nexport function useCascaderHasActions(): boolean {\n const { actions } = useCascaderActions();\n return actions.length > 0;\n}\n\nexport {\n CascaderAction,\n CascaderFooter,\n CascaderSubmenu,\n CascaderSubmenuContent,\n CascaderSubmenuTrigger,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,MAAM,wCAAwB,IAAI,IAAI;CACpC;CACA;CACA;CACA;CACA;CACA;CAC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AAE,YAAY,mBAAmB;CACvC,OAAO,QAAQ,SAAS;AAC1B"}
@@ -0,0 +1,17 @@
1
+ import { s as CascaderLabels } from "../../../cascader-types-BnH6wYD-.js";
2
+ //#region src/components/reui/cascader/cascader-i18n.d.ts
3
+ /**
4
+ * English defaults. Every string the primitive can render lives here, so a
5
+ * consumer can translate the whole surface by passing `labels`.
6
+ */
7
+ declare const CASCADER_LABELS: CascaderLabels;
8
+ /**
9
+ * Shallow-merges consumer overrides over the defaults, so `labels` can carry a
10
+ * single key without restating the rest.
11
+ */
12
+ declare function resolveCascaderLabels(labels?: Partial<CascaderLabels>): CascaderLabels;
13
+ /** Resolves the search placeholder, which may be a string or a function. */
14
+ declare function resolveCascaderSearchLabel(labels: CascaderLabels, parentLabel?: string): string;
15
+ //#endregion
16
+ export { CASCADER_LABELS, resolveCascaderLabels, resolveCascaderSearchLabel };
17
+ //# sourceMappingURL=cascader-i18n.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cascader-i18n.d.ts","names":[],"sources":["../../../../src/components/reui/cascader/cascader-i18n.tsx"],"mappings":";;;;;;cAca,iBAAiB;;;;;iBAyDd,sBAAsB,SAAS,QAAQ,kBAAkB;;iBAMzD,2BAA2B,QAAQ,gBAAgB"}
@@ -0,0 +1,68 @@
1
+ "use client";
2
+ //#region src/components/reui/cascader/cascader-i18n.tsx
3
+ /** Name of the root level. Hoisted so the root announcement can reuse it. */
4
+ const ROOT_LEVEL = "Top level";
5
+ /** Hoisted for the same reason: several defaults end in an item count. */
6
+ const itemCount = (count) => `${count} ${count === 1 ? "item" : "items"}`;
7
+ /**
8
+ * English defaults. Every string the primitive can render lives here, so a
9
+ * consumer can translate the whole surface by passing `labels`.
10
+ */
11
+ const CASCADER_LABELS = {
12
+ search: (parentLabel) => parentLabel ? `Search ${parentLabel}...` : "Search...",
13
+ back: "Back",
14
+ loading: "Loading...",
15
+ loadingMore: "Loading more...",
16
+ loadMore: "Load more",
17
+ error: "Could not load items.",
18
+ retry: "Retry",
19
+ empty: "No results found.",
20
+ selectedCount: (count) => `${count} selected`,
21
+ breadcrumbLabel: "Breadcrumb",
22
+ chipsLabel: "Selected items",
23
+ removeChip: (label) => `Remove ${label}`,
24
+ pathSeparator: "/",
25
+ rootLevel: ROOT_LEVEL,
26
+ itemCount,
27
+ branchAffordance: "submenu",
28
+ selectedState: "selected",
29
+ partiallySelectedState: "partially selected",
30
+ columnsLabel: "Levels",
31
+ actionsLabel: "Actions",
32
+ submenuAffordance: "opens a menu",
33
+ panelLabel: "Options",
34
+ keyboardHint: (mode, dir) => {
35
+ const open = dir === "rtl" ? "Left" : "Right";
36
+ const back = dir === "rtl" ? "Right" : "Left";
37
+ if (mode === "tree") return `Use the ${open} Arrow key to expand and the ${back} Arrow key to collapse.`;
38
+ if (mode === "columns") return `Use the ${open} Arrow key to open the next column and the ${back} Arrow key to go back.`;
39
+ return `Use the ${open} Arrow key to open a branch and the ${back} Arrow key to go back.`;
40
+ },
41
+ rootAnnouncement: (count) => `${ROOT_LEVEL}, ${itemCount(count)}`,
42
+ expandedAnnouncement: (label, count) => `${label} expanded, ${itemCount(count)}`,
43
+ collapsedAnnouncement: (label) => `${label} collapsed`,
44
+ levelAnnouncement: (parentLabel, depth, count) => `${parentLabel}, level ${depth}, ${itemCount(count)}`,
45
+ resultsAnnouncement: (count) => count === 1 ? "1 result" : `${count} results`,
46
+ maxReachedAnnouncement: (max) => `Selection limit of ${max} reached`,
47
+ cascadeAnnouncement: (label, count, selecting) => `${label} ${selecting ? "selected" : "deselected"}, ${itemCount(count)} followed`,
48
+ searchingAnnouncement: "Searching..."
49
+ };
50
+ /**
51
+ * Shallow-merges consumer overrides over the defaults, so `labels` can carry a
52
+ * single key without restating the rest.
53
+ */
54
+ function resolveCascaderLabels(labels) {
55
+ if (!labels) return CASCADER_LABELS;
56
+ return {
57
+ ...CASCADER_LABELS,
58
+ ...labels
59
+ };
60
+ }
61
+ /** Resolves the search placeholder, which may be a string or a function. */
62
+ function resolveCascaderSearchLabel(labels, parentLabel) {
63
+ return typeof labels.search === "function" ? labels.search(parentLabel) : labels.search;
64
+ }
65
+ //#endregion
66
+ export { CASCADER_LABELS, resolveCascaderLabels, resolveCascaderSearchLabel };
67
+
68
+ //# sourceMappingURL=cascader-i18n.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cascader-i18n.js","names":[],"sources":["../../../../src/components/reui/cascader/cascader-i18n.tsx"],"sourcesContent":["\"use client\";\n\nimport type { CascaderLabels, CascaderMode } from \"./cascader-types\";\n\n/** Name of the root level. Hoisted so the root announcement can reuse it. */\nconst ROOT_LEVEL = \"Top level\";\n\n/** Hoisted for the same reason: several defaults end in an item count. */\nconst itemCount = (count: number) => `${count} ${count === 1 ? \"item\" : \"items\"}`;\n\n/**\n * English defaults. Every string the primitive can render lives here, so a\n * consumer can translate the whole surface by passing `labels`.\n */\nexport const CASCADER_LABELS: CascaderLabels = {\n // Deliberately NOT lowercased. `toLowerCase()` is locale-hostile - it maps\n // Turkish \"İ\" to a two-code-point sequence and German \"İstanbul\" style\n // proper nouns lose their casing - and a label is already written the way\n // its author wants it read.\n search: (parentLabel) => (parentLabel ? `Search ${parentLabel}...` : \"Search...\"),\n back: \"Back\",\n loading: \"Loading...\",\n loadingMore: \"Loading more...\",\n loadMore: \"Load more\",\n error: \"Could not load items.\",\n retry: \"Retry\",\n empty: \"No results found.\",\n selectedCount: (count) => `${count} selected`,\n breadcrumbLabel: \"Breadcrumb\",\n chipsLabel: \"Selected items\",\n removeChip: (label) => `Remove ${label}`,\n pathSeparator: \"/\",\n rootLevel: ROOT_LEVEL,\n itemCount,\n branchAffordance: \"submenu\",\n selectedState: \"selected\",\n partiallySelectedState: \"partially selected\",\n columnsLabel: \"Levels\",\n actionsLabel: \"Actions\",\n submenuAffordance: \"opens a menu\",\n panelLabel: \"Options\",\n keyboardHint: (mode: CascaderMode, dir: \"ltr\" | \"rtl\") => {\n // \"Deeper\" is the direction the text runs, so the level keys mirror in\n // RTL and the hint has to name the mirrored pair there - an LTR-worded\n // hint would teach exactly the wrong keys.\n const open = dir === \"rtl\" ? \"Left\" : \"Right\";\n const back = dir === \"rtl\" ? \"Right\" : \"Left\";\n if (mode === \"tree\") {\n return `Use the ${open} Arrow key to expand and the ${back} Arrow key to collapse.`;\n }\n if (mode === \"columns\") {\n return `Use the ${open} Arrow key to open the next column and the ${back} Arrow key to go back.`;\n }\n return `Use the ${open} Arrow key to open a branch and the ${back} Arrow key to go back.`;\n },\n rootAnnouncement: (count) => `${ROOT_LEVEL}, ${itemCount(count)}`,\n expandedAnnouncement: (label, count) => `${label} expanded, ${itemCount(count)}`,\n collapsedAnnouncement: (label) => `${label} collapsed`,\n levelAnnouncement: (parentLabel, depth, count) =>\n `${parentLabel}, level ${depth}, ${itemCount(count)}`,\n resultsAnnouncement: (count) => (count === 1 ? \"1 result\" : `${count} results`),\n maxReachedAnnouncement: (max) => `Selection limit of ${max} reached`,\n cascadeAnnouncement: (label, count, selecting) =>\n `${label} ${selecting ? \"selected\" : \"deselected\"}, ${itemCount(count)} followed`,\n searchingAnnouncement: \"Searching...\",\n};\n\n/**\n * Shallow-merges consumer overrides over the defaults, so `labels` can carry a\n * single key without restating the rest.\n */\nexport function resolveCascaderLabels(labels?: Partial<CascaderLabels>): CascaderLabels {\n if (!labels) return CASCADER_LABELS;\n return { ...CASCADER_LABELS, ...labels };\n}\n\n/** Resolves the search placeholder, which may be a string or a function. */\nexport function resolveCascaderSearchLabel(labels: CascaderLabels, parentLabel?: string): string {\n return typeof labels.search === \"function\" ? labels.search(parentLabel) : labels.search;\n}\n"],"mappings":";;;AAKA,MAAM,aAAa;;AAGnB,MAAM,aAAa,UAAkB,GAAG,MAAM,GAAG,UAAU,IAAI,SAAS;;;;;AAMxE,MAAa,kBAAkC;CAK7C,SAAS,gBAAiB,cAAc,UAAU,YAAY,OAAO;CACrE,MAAM;CACN,SAAS;CACT,aAAa;CACb,UAAU;CACV,OAAO;CACP,OAAO;CACP,OAAO;CACP,g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