@ledgerhq/lumen-ui-react 0.1.15 → 0.1.17

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 (149) hide show
  1. package/ai-rules/RULES.md +2 -2
  2. package/dist/i18n/i18n.d.ts.map +1 -1
  3. package/dist/index.d.ts +0 -1
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +146 -142
  6. package/dist/lib/Components/AmountInput/AmountInput.d.ts.map +1 -1
  7. package/dist/lib/Components/Avatar/Avatar.js +24 -24
  8. package/dist/lib/Components/BaseInput/BaseInput.d.ts.map +1 -1
  9. package/dist/lib/Components/BaseInput/BaseInput.js +78 -85
  10. package/dist/lib/Components/CardButton/CardButton.js +10 -10
  11. package/dist/lib/Components/Dialog/Dialog.js +39 -39
  12. package/dist/lib/Components/Dialog/types.d.ts +3 -3
  13. package/dist/lib/Components/Icon/Icon.js +5 -5
  14. package/dist/lib/Components/Icon/createIcon.d.ts.map +1 -1
  15. package/dist/lib/Components/Link/Link.d.ts.map +1 -1
  16. package/dist/lib/Components/Link/Link.js +25 -32
  17. package/dist/lib/Components/ListItem/ListItem.d.ts +17 -28
  18. package/dist/lib/Components/ListItem/ListItem.d.ts.map +1 -1
  19. package/dist/lib/Components/ListItem/ListItem.js +81 -93
  20. package/dist/lib/Components/ListItem/types.d.ts +13 -32
  21. package/dist/lib/Components/ListItem/types.d.ts.map +1 -1
  22. package/dist/lib/Components/MediaImage/MediaImage.d.ts +19 -0
  23. package/dist/lib/Components/MediaImage/MediaImage.d.ts.map +1 -0
  24. package/dist/lib/Components/MediaImage/MediaImage.js +75 -0
  25. package/dist/lib/Components/MediaImage/index.d.ts +3 -0
  26. package/dist/lib/Components/MediaImage/index.d.ts.map +1 -0
  27. package/dist/lib/Components/MediaImage/types.d.ts +38 -0
  28. package/dist/lib/Components/MediaImage/types.d.ts.map +1 -0
  29. package/dist/lib/Components/Menu/Menu.d.ts +4 -4
  30. package/dist/lib/Components/Menu/Menu.d.ts.map +1 -1
  31. package/dist/lib/Components/NavBar/NavBar.d.ts +0 -1
  32. package/dist/lib/Components/NavBar/NavBar.d.ts.map +1 -1
  33. package/dist/lib/Components/Popover/Popover.js +7 -7
  34. package/dist/lib/Components/Popover/types.d.ts +3 -3
  35. package/dist/lib/Components/SearchInput/SearchInput.d.ts +1 -1
  36. package/dist/lib/Components/SearchInput/SearchInput.d.ts.map +1 -1
  37. package/dist/lib/Components/SearchInput/SearchInput.js +24 -20
  38. package/dist/lib/Components/SearchInput/types.d.ts +1 -1
  39. package/dist/lib/Components/SearchInput/types.d.ts.map +1 -1
  40. package/dist/lib/Components/SegmentedControl/SegmentedControl.d.ts +1 -1
  41. package/dist/lib/Components/SegmentedControl/SegmentedControl.d.ts.map +1 -1
  42. package/dist/lib/Components/SegmentedControl/SegmentedControl.js +97 -81
  43. package/dist/lib/Components/SegmentedControl/SegmentedControlContext.d.ts +1 -0
  44. package/dist/lib/Components/SegmentedControl/SegmentedControlContext.d.ts.map +1 -1
  45. package/dist/lib/Components/SegmentedControl/types.d.ts +7 -0
  46. package/dist/lib/Components/SegmentedControl/types.d.ts.map +1 -1
  47. package/dist/lib/Components/SegmentedControl/usePillElementLayoutEffect.d.ts +5 -6
  48. package/dist/lib/Components/SegmentedControl/usePillElementLayoutEffect.d.ts.map +1 -1
  49. package/dist/lib/Components/SegmentedControl/usePillElementLayoutEffect.js +30 -25
  50. package/dist/lib/Components/Select/Select.d.ts +27 -12
  51. package/dist/lib/Components/Select/Select.d.ts.map +1 -1
  52. package/dist/lib/Components/Select/Select.js +356 -202
  53. package/dist/lib/Components/Select/SelectContext.d.ts +3 -1
  54. package/dist/lib/Components/Select/SelectContext.d.ts.map +1 -1
  55. package/dist/lib/Components/Select/index.d.ts +1 -1
  56. package/dist/lib/Components/Select/index.d.ts.map +1 -1
  57. package/dist/lib/Components/Select/types.d.ts +171 -140
  58. package/dist/lib/Components/Select/types.d.ts.map +1 -1
  59. package/dist/lib/Components/Select/useSelectItems/index.d.ts +2 -0
  60. package/dist/lib/Components/Select/useSelectItems/index.d.ts.map +1 -0
  61. package/dist/lib/Components/Select/useSelectItems/useSelectItems.d.ts +30 -0
  62. package/dist/lib/Components/Select/useSelectItems/useSelectItems.d.ts.map +1 -0
  63. package/dist/lib/Components/Select/useSelectItems/useSelectItems.js +42 -0
  64. package/dist/lib/Components/Select/utils/groupItems.d.ts +13 -0
  65. package/dist/lib/Components/Select/utils/groupItems.d.ts.map +1 -0
  66. package/dist/lib/Components/Select/utils/groupItems.js +16 -0
  67. package/dist/lib/Components/Select/utils/index.d.ts +2 -0
  68. package/dist/lib/Components/Select/utils/index.d.ts.map +1 -0
  69. package/dist/lib/Components/SideBar/SideBar.d.ts +1 -1
  70. package/dist/lib/Components/SideBar/SideBar.d.ts.map +1 -1
  71. package/dist/lib/Components/SideBar/SideBar.js +93 -89
  72. package/dist/lib/Components/SideBar/types.d.ts +7 -1
  73. package/dist/lib/Components/SideBar/types.d.ts.map +1 -1
  74. package/dist/lib/Components/Stepper/Stepper.d.ts +5 -6
  75. package/dist/lib/Components/Stepper/Stepper.d.ts.map +1 -1
  76. package/dist/lib/Components/Stepper/Stepper.js +100 -102
  77. package/dist/lib/Components/Stepper/types.d.ts +2 -2
  78. package/dist/lib/Components/Stepper/types.d.ts.map +1 -1
  79. package/dist/lib/Components/Tag/Tag.d.ts.map +1 -1
  80. package/dist/lib/Components/Tag/Tag.js +1 -1
  81. package/dist/lib/Components/Tooltip/Tooltip.d.ts +2 -2
  82. package/dist/lib/Components/Tooltip/Tooltip.d.ts.map +1 -1
  83. package/dist/lib/Components/TriggerButton/TriggerButton.js +8 -8
  84. package/dist/lib/Components/index.d.ts +1 -0
  85. package/dist/lib/Components/index.d.ts.map +1 -1
  86. package/dist/libs/utils-shared/dist/index.js +151 -124
  87. package/dist/node_modules/@base-ui/react/esm/combobox/chips/ComboboxChipsContext.js +10 -0
  88. package/dist/node_modules/@base-ui/react/esm/combobox/collection/ComboboxCollection.js +17 -0
  89. package/dist/node_modules/@base-ui/react/esm/combobox/collection/GroupCollectionContext.js +23 -0
  90. package/dist/node_modules/@base-ui/react/esm/combobox/empty/ComboboxEmpty.js +26 -0
  91. package/dist/node_modules/@base-ui/react/esm/combobox/group/ComboboxGroup.js +34 -0
  92. package/dist/node_modules/@base-ui/react/esm/combobox/group/ComboboxGroupContext.js +14 -0
  93. package/dist/node_modules/@base-ui/react/esm/combobox/group-label/ComboboxGroupLabel.js +27 -0
  94. package/dist/node_modules/@base-ui/react/esm/combobox/input/ComboboxInput.js +221 -0
  95. package/dist/node_modules/@base-ui/react/esm/combobox/item/ComboboxItem.js +113 -0
  96. package/dist/node_modules/@base-ui/react/esm/combobox/item/ComboboxItemContext.js +14 -0
  97. package/dist/node_modules/@base-ui/react/esm/combobox/item-indicator/ComboboxItemIndicator.js +52 -0
  98. package/dist/node_modules/@base-ui/react/esm/combobox/list/ComboboxList.js +65 -0
  99. package/dist/node_modules/@base-ui/react/esm/combobox/popup/ComboboxPopup.js +76 -0
  100. package/dist/node_modules/@base-ui/react/esm/combobox/portal/ComboboxPortal.js +24 -0
  101. package/dist/node_modules/@base-ui/react/esm/combobox/portal/ComboboxPortalContext.js +14 -0
  102. package/dist/node_modules/@base-ui/react/esm/combobox/positioner/ComboboxPositioner.js +102 -0
  103. package/dist/node_modules/@base-ui/react/esm/combobox/positioner/ComboboxPositionerContext.js +14 -0
  104. package/dist/node_modules/@base-ui/react/esm/combobox/root/AriaCombobox.js +596 -0
  105. package/dist/node_modules/@base-ui/react/esm/combobox/root/ComboboxRoot.js +23 -0
  106. package/dist/node_modules/@base-ui/react/esm/combobox/root/ComboboxRootContext.js +41 -0
  107. package/dist/node_modules/@base-ui/react/esm/combobox/root/utils/constants.js +8 -0
  108. package/dist/node_modules/@base-ui/react/esm/combobox/root/utils/index.js +23 -0
  109. package/dist/node_modules/@base-ui/react/esm/combobox/root/utils/useFilter.js +43 -0
  110. package/dist/node_modules/@base-ui/react/esm/combobox/row/ComboboxRowContext.js +10 -0
  111. package/dist/node_modules/@base-ui/react/esm/combobox/store.js +74 -0
  112. package/dist/node_modules/@base-ui/react/esm/combobox/trigger/ComboboxTrigger.js +135 -0
  113. package/dist/node_modules/@base-ui/react/esm/combobox/utils/ComboboxInternalDismissButton.js +32 -0
  114. package/dist/node_modules/@base-ui/react/esm/combobox/utils/stateAttributesMapping.js +15 -0
  115. package/dist/node_modules/@base-ui/react/esm/combobox/value/ComboboxValue.js +19 -0
  116. package/dist/node_modules/@base-ui/react/esm/composite/list/CompositeList.js +81 -0
  117. package/dist/node_modules/@base-ui/react/esm/composite/list/CompositeListContext.js +23 -0
  118. package/dist/node_modules/@base-ui/react/esm/composite/list/useCompositeListItem.js +55 -0
  119. package/dist/node_modules/@base-ui/react/esm/field/control/FieldControlDataAttributes.js +6 -0
  120. package/dist/node_modules/@base-ui/react/esm/field/root/FieldRootContext.js +53 -0
  121. package/dist/node_modules/@base-ui/react/esm/field/useField.js +51 -0
  122. package/dist/node_modules/@base-ui/react/esm/field/utils/constants.js +37 -0
  123. package/dist/node_modules/@base-ui/react/esm/field/utils/getCombinedFieldValidityData.js +12 -0
  124. package/dist/node_modules/@base-ui/react/esm/floating-ui-react/hooks/useListNavigation.js +287 -0
  125. package/dist/node_modules/@base-ui/react/esm/floating-ui-react/hooks/useTypeahead.js +71 -0
  126. package/dist/node_modules/@base-ui/react/esm/floating-ui-react/utils/composite.js +218 -4
  127. package/dist/node_modules/@base-ui/react/esm/floating-ui-react/utils/constants.js +7 -3
  128. package/dist/node_modules/@base-ui/react/esm/floating-ui-react/utils/element.js +3 -3
  129. package/dist/node_modules/@base-ui/react/esm/form/FormContext.js +23 -0
  130. package/dist/node_modules/@base-ui/react/esm/labelable-provider/LabelableContext.js +19 -0
  131. package/dist/node_modules/@base-ui/react/esm/labelable-provider/useLabelableId.js +44 -0
  132. package/dist/node_modules/@base-ui/react/esm/utils/constants.js +11 -8
  133. package/dist/node_modules/@base-ui/react/esm/utils/createBaseUIEventDetails.js +22 -13
  134. package/dist/node_modules/@base-ui/react/esm/utils/getPseudoElementBounds.js +18 -0
  135. package/dist/node_modules/@base-ui/react/esm/utils/itemEquality.js +20 -0
  136. package/dist/node_modules/@base-ui/react/esm/utils/reason-parts.js +13 -6
  137. package/dist/node_modules/@base-ui/react/esm/utils/resolveAriaLabelledBy.js +6 -0
  138. package/dist/node_modules/@base-ui/react/esm/utils/resolveValueLabel.js +73 -0
  139. package/dist/node_modules/@base-ui/react/esm/utils/serializeValue.js +14 -0
  140. package/dist/node_modules/@base-ui/utils/esm/detectBrowser.js +8 -7
  141. package/dist/node_modules/@base-ui/utils/esm/empty.js +3 -2
  142. package/dist/node_modules/@base-ui/utils/esm/useControlled.js +31 -0
  143. package/dist/node_modules/@base-ui/utils/esm/visuallyHidden.js +5 -1
  144. package/dist/node_modules/i18next/dist/esm/i18next.js +45 -47
  145. package/dist/package.json +1 -2
  146. package/dist/utils/icon-template.d.ts.map +1 -1
  147. package/package.json +1 -2
  148. package/dist/lib/Patterns/index.d.ts +0 -3
  149. package/dist/lib/Patterns/index.d.ts.map +0 -1
@@ -0,0 +1,287 @@
1
+ import * as m from "react";
2
+ import { isHTMLElement as ve } from "../../../../../@floating-ui/utils/dist/floating-ui.utils.dom.js";
3
+ import { useValueAsRef as z } from "../../../../utils/esm/useValueAsRef.js";
4
+ import { useStableCallback as ae } from "../../../../utils/esm/useStableCallback.js";
5
+ import { useIsoLayoutEffect as A } from "../../../../utils/esm/useIsoLayoutEffect.js";
6
+ import { ownerDocument as Pe } from "../../../../utils/esm/owner.js";
7
+ import { useFloatingParentNodeId as Ke, useFloatingTree as Ve } from "../components/FloatingTree.js";
8
+ import { createChangeEventDetails as X } from "../../utils/createBaseUIEventDetails.js";
9
+ import { enqueueFocus as Ce } from "../utils/enqueueFocus.js";
10
+ import { ARROW_DOWN as ee, ARROW_LEFT as G, ARROW_RIGHT as W, ARROW_UP as Se } from "../utils/constants.js";
11
+ import { isIndexOutOfListBounds as Te, getMinListIndex as fe, getMaxListIndex as Fe, createGridCellMap as ze, isListIndexDisabled as de, getGridNavigatedIndex as Ge, getGridCellIndexOfCorner as We, getGridCellIndices as _e, findNonDisabledListIndex as Y } from "../utils/composite.js";
12
+ import { getFloatingFocusElement as qe, isTypeableCombobox as He, activeElement as me, contains as pe, getTarget as $e } from "../utils/element.js";
13
+ import { stopEvent as T, isVirtualClick as Be, isVirtualPointerEvent as Ue } from "../utils/event.js";
14
+ import { listNavigation as ge, focusOut as je } from "../../utils/reason-parts.js";
15
+ const Je = "Escape";
16
+ function re(o, p, u) {
17
+ switch (o) {
18
+ case "vertical":
19
+ return p;
20
+ case "horizontal":
21
+ return u;
22
+ default:
23
+ return p || u;
24
+ }
25
+ }
26
+ function Z(o, p) {
27
+ return re(p, o === Se || o === ee, o === G || o === W);
28
+ }
29
+ function Re(o, p, u) {
30
+ return re(p, o === ee, u ? o === G : o === W) || o === "Enter" || o === " " || o === "";
31
+ }
32
+ function Qe(o, p, u) {
33
+ return re(p, u ? o === G : o === W, o === ee);
34
+ }
35
+ function Xe(o, p, u, l) {
36
+ const g = u ? o === W : o === G, E = o === Se;
37
+ return p === "both" || p === "horizontal" && l && l > 1 ? o === Je : re(p, g, E);
38
+ }
39
+ function fr(o, p) {
40
+ const u = "rootStore" in o ? o.rootStore : o, l = u.useState("open"), g = u.useState("floatingElement"), E = u.useState("domReferenceElement"), he = u.context.dataRef, {
41
+ listRef: n,
42
+ activeIndex: w,
43
+ onNavigate: Ae = () => {
44
+ },
45
+ enabled: O = !0,
46
+ selectedIndex: L = null,
47
+ allowEscape: te = !1,
48
+ loopFocus: _ = !1,
49
+ nested: b = !1,
50
+ rtl: x = !1,
51
+ virtual: f = !1,
52
+ focusItemOnOpen: M = "auto",
53
+ focusItemOnHover: ne = !0,
54
+ openOnArrowKeyDown: oe = !0,
55
+ disabledIndices: R = void 0,
56
+ orientation: d = "vertical",
57
+ parentOrientation: Ie,
58
+ cols: F = 1,
59
+ id: Ee,
60
+ resetOnPointerLeave: Le = !0,
61
+ externalTree: Ne
62
+ } = p;
63
+ process.env.NODE_ENV !== "production" && (te && (_ || console.warn("`useListNavigation` looping must be enabled to allow escaping."), f || console.warn("`useListNavigation` must be virtual to allow escaping.")), d === "vertical" && F > 1 && console.warn("In grid list navigation mode (`cols` > 1), the `orientation` should", 'be either "horizontal" or "both".'));
64
+ const ke = qe(g), N = z(ke), q = Ke(), v = Ve(Ne);
65
+ A(() => {
66
+ he.current.orientation = d;
67
+ }, [he, d]);
68
+ const ie = He(E), P = m.useRef(M), t = m.useRef(L ?? -1), C = m.useRef(null), S = m.useRef(!0), a = ae((e) => {
69
+ Ae(t.current === -1 ? null : t.current, e);
70
+ }), xe = m.useRef(a), k = m.useRef(!!g), Oe = m.useRef(l), I = m.useRef(!1), H = m.useRef(!1), ce = z(R), $ = z(l), D = z(L), ye = z(Le), ue = ae(() => {
71
+ function e(c) {
72
+ f ? v?.events.emit("virtualfocus", c) : Ce(c, {
73
+ sync: I.current,
74
+ preventScroll: !0
75
+ });
76
+ }
77
+ const i = n.current[t.current], r = H.current;
78
+ i && e(i), (I.current ? (c) => c() : requestAnimationFrame)(() => {
79
+ const c = n.current[t.current] || i;
80
+ if (!c)
81
+ return;
82
+ i || e(c), // eslint-disable-next-line @typescript-eslint/no-use-before-define
83
+ se && (r || !S.current) && c.scrollIntoView?.({
84
+ block: "nearest",
85
+ inline: "nearest"
86
+ });
87
+ });
88
+ });
89
+ A(() => {
90
+ O && (l && g ? (t.current = L ?? -1, P.current && L != null && (H.current = !0, a())) : k.current && (t.current = -1, xe.current()));
91
+ }, [O, l, g, L, a]), A(() => {
92
+ if (O) {
93
+ if (!l) {
94
+ I.current = !1;
95
+ return;
96
+ }
97
+ if (g)
98
+ if (w == null) {
99
+ if (I.current = !1, D.current != null)
100
+ return;
101
+ if (k.current && (t.current = -1, ue()), (!Oe.current || !k.current) && P.current && (C.current != null || P.current === !0 && C.current == null)) {
102
+ let e = 0;
103
+ const i = () => {
104
+ n.current[0] == null ? (e < 2 && (e ? requestAnimationFrame : queueMicrotask)(i), e += 1) : (t.current = C.current == null || Re(C.current, d, x) || b ? fe(n) : Fe(n), C.current = null, a());
105
+ };
106
+ i();
107
+ }
108
+ } else Te(n, w) || (t.current = w, ue(), H.current = !1);
109
+ }
110
+ }, [O, l, g, w, D, b, n, d, x, a, ue, ce]), A(() => {
111
+ if (!O || g || !v || f || !k.current)
112
+ return;
113
+ const e = v.nodesRef.current, i = e.find((c) => c.id === q)?.context?.elements.floating, r = me(Pe(g)), s = e.some((c) => c.context && pe(c.context.elements.floating, r));
114
+ i && !s && S.current && i.focus({
115
+ preventScroll: !0
116
+ });
117
+ }, [O, g, v, q, f]), A(() => {
118
+ xe.current = a, Oe.current = l, k.current = !!g;
119
+ }), A(() => {
120
+ l || (C.current = null, P.current = M);
121
+ }, [l, M]);
122
+ const we = w != null, se = m.useMemo(() => {
123
+ function e(r) {
124
+ if (!$.current)
125
+ return;
126
+ const s = n.current.indexOf(r.currentTarget);
127
+ s !== -1 && t.current !== s && (t.current = s, a(r));
128
+ }
129
+ return {
130
+ onFocus(r) {
131
+ I.current = !0, e(r);
132
+ },
133
+ onClick: ({
134
+ currentTarget: r
135
+ }) => r.focus({
136
+ preventScroll: !0
137
+ }),
138
+ // Safari
139
+ onMouseMove(r) {
140
+ I.current = !0, H.current = !1, ne && e(r);
141
+ },
142
+ onPointerLeave(r) {
143
+ if (!$.current || !S.current || r.pointerType === "touch")
144
+ return;
145
+ I.current = !0;
146
+ const s = r.relatedTarget;
147
+ if (!(!ne || n.current.includes(s)) && ye.current && (Ce(null, {
148
+ sync: !0
149
+ }), t.current = -1, a(r), !f)) {
150
+ const c = N.current, h = me(Pe(c));
151
+ c && pe(c, h) && c.focus({
152
+ preventScroll: !0
153
+ });
154
+ }
155
+ }
156
+ };
157
+ }, [$, N, ne, n, a, ye, f]), B = m.useCallback(() => Ie ?? v?.nodesRef.current.find((e) => e.id === q)?.context?.dataRef?.current.orientation, [q, v, Ie]), K = ae((e) => {
158
+ if (S.current = !1, I.current = !0, e.which === 229 || !$.current && e.currentTarget === N.current)
159
+ return;
160
+ if (b && Xe(e.key, d, x, F)) {
161
+ Z(e.key, B()) || T(e), u.setOpen(!1, X(ge, e.nativeEvent)), ve(E) && (f ? v?.events.emit("virtualfocus", E) : E.focus());
162
+ return;
163
+ }
164
+ const i = t.current, r = fe(n, R), s = Fe(n, R);
165
+ if (ie || (e.key === "Home" && (T(e), t.current = r, a(e)), e.key === "End" && (T(e), t.current = s, a(e))), F > 1) {
166
+ const c = Array.from({
167
+ length: n.current.length
168
+ }, () => ({
169
+ width: 1,
170
+ height: 1
171
+ })), h = ze(c, F), J = h.findIndex((y) => y != null && !de(n, y, R)), le = h.reduce((y, V, De) => V != null && !de(n, V, R) ? De : y, -1), Q = h[Ge({
172
+ current: h.map((y) => y != null ? n.current[y] : null)
173
+ }, {
174
+ event: e,
175
+ orientation: d,
176
+ loopFocus: _,
177
+ rtl: x,
178
+ cols: F,
179
+ // treat undefined (empty grid spaces) as disabled indices so we
180
+ // don't end up in them
181
+ disabledIndices: _e([...(typeof R != "function" ? R : null) || n.current.map((y, V) => de(n, V, R) ? V : void 0), void 0], h),
182
+ minIndex: J,
183
+ maxIndex: le,
184
+ prevIndex: We(
185
+ t.current > s ? r : t.current,
186
+ c,
187
+ h,
188
+ F,
189
+ // use a corner matching the edge closest to the direction
190
+ // we're moving in so we don't end up in the same item. Prefer
191
+ // top/left over bottom/right.
192
+ // eslint-disable-next-line no-nested-ternary
193
+ e.key === ee ? "bl" : e.key === (x ? G : W) ? "tr" : "tl"
194
+ ),
195
+ stopEvent: !0
196
+ })];
197
+ if (Q != null && (t.current = Q, a(e)), d === "both")
198
+ return;
199
+ }
200
+ if (Z(e.key, d)) {
201
+ if (T(e), l && !f && me(e.currentTarget.ownerDocument) === e.currentTarget) {
202
+ t.current = Re(e.key, d, x) ? r : s, a(e);
203
+ return;
204
+ }
205
+ Re(e.key, d, x) ? _ ? i >= s ? te && i !== n.current.length ? t.current = -1 : (I.current = !1, t.current = r) : t.current = Y(n, {
206
+ startingIndex: i,
207
+ disabledIndices: R
208
+ }) : t.current = Math.min(s, Y(n, {
209
+ startingIndex: i,
210
+ disabledIndices: R
211
+ })) : _ ? i <= r ? te && i !== -1 ? t.current = n.current.length : (I.current = !1, t.current = s) : t.current = Y(n, {
212
+ startingIndex: i,
213
+ decrement: !0,
214
+ disabledIndices: R
215
+ }) : t.current = Math.max(r, Y(n, {
216
+ startingIndex: i,
217
+ decrement: !0,
218
+ disabledIndices: R
219
+ })), Te(n, t.current) && (t.current = -1), a(e);
220
+ }
221
+ }), U = m.useMemo(() => f && l && we && {
222
+ "aria-activedescendant": `${Ee}-${w}`
223
+ }, [f, l, we, Ee, w]), be = m.useMemo(() => ({
224
+ "aria-orientation": d === "both" ? void 0 : d,
225
+ ...ie ? {} : U,
226
+ onKeyDown(e) {
227
+ if (e.key === "Tab" && e.shiftKey && l && !f) {
228
+ const i = $e(e.nativeEvent);
229
+ if (i && !pe(N.current, i))
230
+ return;
231
+ T(e), u.setOpen(!1, X(je, e.nativeEvent)), ve(E) && E.focus();
232
+ return;
233
+ }
234
+ K(e);
235
+ },
236
+ onPointerMove() {
237
+ S.current = !0;
238
+ }
239
+ }), [U, K, N, d, ie, u, l, f, E]), j = m.useMemo(() => {
240
+ function e(r) {
241
+ M === "auto" && Be(r.nativeEvent) && (P.current = !f);
242
+ }
243
+ function i(r) {
244
+ P.current = M, M === "auto" && Ue(r.nativeEvent) && (P.current = !0);
245
+ }
246
+ return {
247
+ onKeyDown(r) {
248
+ const s = u.select("open");
249
+ S.current = !1;
250
+ const c = r.key.startsWith("Arrow"), h = Qe(r.key, B(), x), J = Z(r.key, d), le = (b ? h : J) || r.key === "Enter" || r.key.trim() === "";
251
+ if (f && s)
252
+ return K(r);
253
+ if (!(!s && !oe && c)) {
254
+ if (le) {
255
+ const Q = Z(r.key, B());
256
+ C.current = b && Q ? null : r.key;
257
+ }
258
+ if (b) {
259
+ h && (T(r), s ? (t.current = fe(n, ce.current), a(r)) : u.setOpen(!0, X(ge, r.nativeEvent, r.currentTarget)));
260
+ return;
261
+ }
262
+ J && (D.current != null && (t.current = D.current), T(r), !s && oe ? u.setOpen(!0, X(ge, r.nativeEvent, r.currentTarget)) : K(r), s && a(r));
263
+ }
264
+ },
265
+ onFocus(r) {
266
+ u.select("open") && !f && (t.current = -1, a(r));
267
+ },
268
+ onPointerDown: i,
269
+ onPointerEnter: i,
270
+ onMouseDown: e,
271
+ onClick: e
272
+ };
273
+ }, [K, ce, M, n, b, a, u, oe, d, B, x, D, f]), Me = m.useMemo(() => ({
274
+ ...U,
275
+ ...j
276
+ }), [U, j]);
277
+ return m.useMemo(() => O ? {
278
+ reference: Me,
279
+ floating: be,
280
+ item: se,
281
+ trigger: j
282
+ } : {}, [O, Me, be, j, se]);
283
+ }
284
+ export {
285
+ Je as ESCAPE,
286
+ fr as useListNavigation
287
+ };
@@ -0,0 +1,71 @@
1
+ import * as u from "react";
2
+ import { useStableCallback as k } from "../../../../utils/esm/useStableCallback.js";
3
+ import { useIsoLayoutEffect as F } from "../../../../utils/esm/useIsoLayoutEffect.js";
4
+ import { useTimeout as A } from "../../../../utils/esm/useTimeout.js";
5
+ import { stopEvent as K } from "../utils/event.js";
6
+ import { contains as D } from "../utils/element.js";
7
+ import { isElementVisible as G } from "../utils/composite.js";
8
+ function $(w, O) {
9
+ const a = "rootStore" in w ? w.rootStore : w, m = a.context.dataRef, i = a.useState("open"), {
10
+ listRef: V,
11
+ elementsRef: z,
12
+ activeIndex: f,
13
+ onMatch: B,
14
+ onTypingChange: C,
15
+ enabled: E = !0,
16
+ resetMs: N = 750,
17
+ selectedIndex: n = null
18
+ } = O, g = A(), t = u.useRef(""), o = u.useRef(n ?? f ?? -1), l = u.useRef(null);
19
+ F(() => {
20
+ !i && n !== null || (g.clear(), l.current = null, t.current !== "" && (t.current = ""));
21
+ }, [i, n, g]), F(() => {
22
+ i && t.current === "" && (o.current = n ?? f ?? -1);
23
+ }, [i, n, f]);
24
+ const c = k((e) => {
25
+ e ? m.current.typing || (m.current.typing = e, C?.(e)) : m.current.typing && (m.current.typing = e, C?.(e));
26
+ }), p = k((e) => {
27
+ function y(r) {
28
+ const x = z?.current[r];
29
+ return !x || G(x);
30
+ }
31
+ function h(r, x, W = 0) {
32
+ if (r.length === 0)
33
+ return -1;
34
+ const j = (W % r.length + r.length) % r.length, q = x.toLocaleLowerCase();
35
+ for (let I = 0; I < r.length; I += 1) {
36
+ const S = (j + I) % r.length;
37
+ if (!(!r[S]?.toLocaleLowerCase().startsWith(q) || !y(S)))
38
+ return S;
39
+ }
40
+ return -1;
41
+ }
42
+ const s = V.current;
43
+ if (t.current.length > 0 && e.key === " " && (K(e), c(!0)), t.current.length > 0 && t.current[0] !== " " && h(s, t.current) === -1 && e.key !== " " && c(!1), s == null || // Character key.
44
+ e.key.length !== 1 || // Modifier key.
45
+ e.ctrlKey || e.metaKey || e.altKey)
46
+ return;
47
+ i && e.key !== " " && (K(e), c(!0));
48
+ const R = t.current === "";
49
+ R && (o.current = n ?? f ?? -1), s.every((r) => r ? r[0]?.toLocaleLowerCase() !== r[1]?.toLocaleLowerCase() : !0) && t.current === e.key && (t.current = "", o.current = l.current), t.current += e.key, g.start(N, () => {
50
+ t.current = "", o.current = l.current, c(!1);
51
+ });
52
+ const P = ((R ? n ?? f ?? -1 : o.current) ?? 0) + 1, L = h(s, t.current, P);
53
+ L !== -1 ? (B?.(L), l.current = L) : e.key !== " " && (t.current = "", c(!1));
54
+ }), d = k((e) => {
55
+ const y = e.relatedTarget, h = a.select("domReferenceElement"), s = a.select("floatingElement"), R = D(h, y), T = D(s, y);
56
+ R || T || (g.clear(), t.current = "", o.current = l.current, c(!1));
57
+ }), M = u.useMemo(() => ({
58
+ onKeyDown: p,
59
+ onBlur: d
60
+ }), [p, d]), b = u.useMemo(() => ({
61
+ onKeyDown: p,
62
+ onBlur: d
63
+ }), [p, d]);
64
+ return u.useMemo(() => E ? {
65
+ reference: M,
66
+ floating: b
67
+ } : {}, [E, M, b]);
68
+ }
69
+ export {
70
+ $ as useTypeahead
71
+ };
@@ -1,7 +1,221 @@
1
- import { getComputedStyle as t } from "../../../../../@floating-ui/utils/dist/floating-ui.utils.dom.js";
2
- function n(e) {
3
- return t(e).display !== "none";
1
+ import { floor as V } from "../../../../../@floating-ui/utils/dist/floating-ui.utils.js";
2
+ import { getComputedStyle as q } from "../../../../../@floating-ui/utils/dist/floating-ui.utils.dom.js";
3
+ import { stopEvent as _ } from "./event.js";
4
+ import { ARROW_LEFT as S, ARROW_RIGHT as z, ARROW_UP as J, ARROW_DOWN as K } from "./constants.js";
5
+ function W(t, e, l) {
6
+ return Math.floor(t / e) !== l;
7
+ }
8
+ function H(t, e) {
9
+ return e < 0 || e >= t.current.length;
10
+ }
11
+ function F(t, e) {
12
+ return y(t, {
13
+ disabledIndices: e
14
+ });
15
+ }
16
+ function p(t, e) {
17
+ return y(t, {
18
+ decrement: !0,
19
+ startingIndex: t.current.length,
20
+ disabledIndices: e
21
+ });
22
+ }
23
+ function y(t, {
24
+ startingIndex: e = -1,
25
+ decrement: l = !1,
26
+ disabledIndices: u,
27
+ amount: a = 1
28
+ } = {}) {
29
+ let n = e;
30
+ do
31
+ n += l ? -a : a;
32
+ while (n >= 0 && n <= t.current.length - 1 && P(t, n, u));
33
+ return n;
34
+ }
35
+ function I(t, {
36
+ event: e,
37
+ orientation: l,
38
+ loopFocus: u,
39
+ rtl: a,
40
+ cols: n,
41
+ disabledIndices: o,
42
+ minIndex: R,
43
+ maxIndex: c,
44
+ prevIndex: r,
45
+ stopEvent: m = !1
46
+ }) {
47
+ let i = r, O;
48
+ if (e.key === J ? O = "up" : e.key === K && (O = "down"), O) {
49
+ const g = [], A = [];
50
+ let T = !1, U = 0;
51
+ {
52
+ let h = null, f = -1;
53
+ t.current.forEach((C, D) => {
54
+ if (C == null)
55
+ return;
56
+ U += 1;
57
+ const w = C.closest('[role="row"]');
58
+ w && (T = !0), (w !== h || f === -1) && (h = w, f += 1, g[f] = []), g[f].push(D), A[D] = f;
59
+ });
60
+ }
61
+ let k = !1, N = 0;
62
+ if (T)
63
+ for (const h of g) {
64
+ const f = h.length;
65
+ f > N && (N = f), f !== n && (k = !0);
66
+ }
67
+ const j = k && U < t.current.length, s = N || n, $ = (h) => {
68
+ if (!k || r === -1)
69
+ return;
70
+ const f = A[r];
71
+ if (f == null)
72
+ return;
73
+ const C = g[f].indexOf(r), D = h === "up" ? -1 : 1;
74
+ for (let w = f + D, E = 0; E < g.length; E += 1, w += D) {
75
+ if (w < 0 || w >= g.length) {
76
+ if (!u || j)
77
+ return;
78
+ w = w < 0 ? g.length - 1 : 0;
79
+ }
80
+ const G = g[w];
81
+ for (let L = Math.min(C, G.length - 1); L >= 0; L -= 1) {
82
+ const M = G[L];
83
+ if (!P(t, M, o))
84
+ return M;
85
+ }
86
+ }
87
+ }, b = (h) => {
88
+ if (!j || r === -1)
89
+ return;
90
+ const f = r % s, C = h === "up" ? -s : s, D = c - c % s, w = V(c / s) + 1;
91
+ for (let E = r - f + C, G = 0; G < w; G += 1, E += C) {
92
+ if (E < 0 || E > c) {
93
+ if (!u)
94
+ return;
95
+ E = E < 0 ? D : 0;
96
+ }
97
+ const L = Math.min(E + s - 1, c);
98
+ for (let M = Math.min(E + f, L); M >= E; M -= 1)
99
+ if (!P(t, M, o))
100
+ return M;
101
+ }
102
+ };
103
+ m && _(e);
104
+ const B = $(O) ?? b(O);
105
+ if (B !== void 0)
106
+ i = B;
107
+ else if (r === -1)
108
+ i = O === "up" ? c : R;
109
+ else if (i = y(t, {
110
+ startingIndex: r,
111
+ amount: s,
112
+ decrement: O === "up",
113
+ disabledIndices: o
114
+ }), u) {
115
+ if (O === "up" && (r - s < R || i < 0)) {
116
+ const h = r % s, f = c % s, C = c - (f - h);
117
+ f === h ? i = c : i = f > h ? C : C - s;
118
+ }
119
+ O === "down" && r + s > c && (i = y(t, {
120
+ startingIndex: r % s - s,
121
+ amount: s,
122
+ disabledIndices: o
123
+ }));
124
+ }
125
+ H(t, i) && (i = r);
126
+ }
127
+ if (l === "both") {
128
+ const g = V(r / n);
129
+ e.key === (a ? S : z) && (m && _(e), r % n !== n - 1 ? (i = y(t, {
130
+ startingIndex: r,
131
+ disabledIndices: o
132
+ }), u && W(i, n, g) && (i = y(t, {
133
+ startingIndex: r - r % n - 1,
134
+ disabledIndices: o
135
+ }))) : u && (i = y(t, {
136
+ startingIndex: r - r % n - 1,
137
+ disabledIndices: o
138
+ })), W(i, n, g) && (i = r)), e.key === (a ? z : S) && (m && _(e), r % n !== 0 ? (i = y(t, {
139
+ startingIndex: r,
140
+ decrement: !0,
141
+ disabledIndices: o
142
+ }), u && W(i, n, g) && (i = y(t, {
143
+ startingIndex: r + (n - r % n),
144
+ decrement: !0,
145
+ disabledIndices: o
146
+ }))) : u && (i = y(t, {
147
+ startingIndex: r + (n - r % n),
148
+ decrement: !0,
149
+ disabledIndices: o
150
+ })), W(i, n, g) && (i = r));
151
+ const A = V(c / n) === g;
152
+ H(t, i) && (u && A ? i = e.key === (a ? z : S) ? c : y(t, {
153
+ startingIndex: r - r % n - 1,
154
+ disabledIndices: o
155
+ }) : i = r);
156
+ }
157
+ return i;
158
+ }
159
+ function v(t, e, l) {
160
+ const u = [];
161
+ let a = 0;
162
+ return t.forEach(({
163
+ width: n,
164
+ height: o
165
+ }, R) => {
166
+ if (n > e && process.env.NODE_ENV !== "production")
167
+ throw new Error(`[Floating UI]: Invalid grid - item width at index ${R} is greater than grid columns`);
168
+ let c = !1;
169
+ for (; !c; ) {
170
+ const r = [];
171
+ for (let m = 0; m < n; m += 1)
172
+ for (let i = 0; i < o; i += 1)
173
+ r.push(a + m + i * e);
174
+ a % e + n <= e && r.every((m) => u[m] == null) ? (r.forEach((m) => {
175
+ u[m] = R;
176
+ }), c = !0) : a += 1;
177
+ }
178
+ }), [...u];
179
+ }
180
+ function x(t, e, l, u, a) {
181
+ if (t === -1)
182
+ return -1;
183
+ const n = l.indexOf(t), o = e[t];
184
+ switch (a) {
185
+ case "tl":
186
+ return n;
187
+ case "tr":
188
+ return o ? n + o.width - 1 : n;
189
+ case "bl":
190
+ return o ? n + (o.height - 1) * u : n;
191
+ case "br":
192
+ return l.lastIndexOf(t);
193
+ default:
194
+ return -1;
195
+ }
196
+ }
197
+ function tt(t, e) {
198
+ return e.flatMap((l, u) => t.includes(l) ? [u] : []);
199
+ }
200
+ function P(t, e, l) {
201
+ if (typeof l == "function" ? l(e) : l?.includes(e) ?? !1)
202
+ return !0;
203
+ const a = t.current[e];
204
+ return a ? Q(a) ? !l && (a.hasAttribute("disabled") || a.getAttribute("aria-disabled") === "true") : !0 : !1;
205
+ }
206
+ function Q(t) {
207
+ return q(t).display !== "none";
4
208
  }
5
209
  export {
6
- n as isElementVisible
210
+ v as createGridCellMap,
211
+ y as findNonDisabledListIndex,
212
+ x as getGridCellIndexOfCorner,
213
+ tt as getGridCellIndices,
214
+ I as getGridNavigatedIndex,
215
+ p as getMaxListIndex,
216
+ F as getMinListIndex,
217
+ W as isDifferentGridRow,
218
+ Q as isElementVisible,
219
+ H as isIndexOutOfListBounds,
220
+ P as isListIndexDisabled
7
221
  };
@@ -1,7 +1,11 @@
1
- const t = "data-base-ui-focusable", e = "active", n = "selected", a = "input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";
1
+ const t = "data-base-ui-focusable", e = "active", o = "selected", n = "input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])", s = "ArrowLeft", c = "ArrowRight", E = "ArrowUp", a = "ArrowDown";
2
2
  export {
3
3
  e as ACTIVE_KEY,
4
+ a as ARROW_DOWN,
5
+ s as ARROW_LEFT,
6
+ c as ARROW_RIGHT,
7
+ E as ARROW_UP,
4
8
  t as FOCUSABLE_ATTRIBUTE,
5
- n as SELECTED_KEY,
6
- a as TYPEABLE_SELECTOR
9
+ o as SELECTED_KEY,
10
+ n as TYPEABLE_SELECTOR
7
11
  };
@@ -1,4 +1,4 @@
1
- import { isHTMLElement as i, isShadowRoot as u, isElement as s } from "../../../../../@floating-ui/utils/dist/floating-ui.utils.dom.js";
1
+ import { isShadowRoot as i, isHTMLElement as u, isElement as s } from "../../../../../@floating-ui/utils/dist/floating-ui.utils.dom.js";
2
2
  import { TYPEABLE_SELECTOR as a, FOCUSABLE_ATTRIBUTE as o } from "./constants.js";
3
3
  function d(t) {
4
4
  let e = t.activeElement;
@@ -12,7 +12,7 @@ function c(t, e) {
12
12
  const r = e.getRootNode?.();
13
13
  if (t.contains(e))
14
14
  return !0;
15
- if (r && u(r)) {
15
+ if (r && i(r)) {
16
16
  let n = e;
17
17
  for (; n; ) {
18
18
  if (t === n)
@@ -48,7 +48,7 @@ function E(t) {
48
48
  return t.matches("html,body");
49
49
  }
50
50
  function f(t) {
51
- return i(t) && t.matches(a);
51
+ return u(t) && t.matches(a);
52
52
  }
53
53
  function T(t) {
54
54
  return t ? t.getAttribute("role") === "combobox" && f(t) : !1;
@@ -0,0 +1,23 @@
1
+ import * as e from "react";
2
+ import { NOOP as r } from "../../../utils/esm/empty.js";
3
+ const t = /* @__PURE__ */ e.createContext({
4
+ formRef: {
5
+ current: {
6
+ fields: /* @__PURE__ */ new Map()
7
+ }
8
+ },
9
+ errors: {},
10
+ clearErrors: r,
11
+ validationMode: "onSubmit",
12
+ submitAttemptedRef: {
13
+ current: !1
14
+ }
15
+ });
16
+ process.env.NODE_ENV !== "production" && (t.displayName = "FormContext");
17
+ function n() {
18
+ return e.useContext(t);
19
+ }
20
+ export {
21
+ t as FormContext,
22
+ n as useFormContext
23
+ };
@@ -0,0 +1,19 @@
1
+ import * as t from "react";
2
+ import { NOOP as e } from "../../../utils/esm/empty.js";
3
+ const o = /* @__PURE__ */ t.createContext({
4
+ controlId: void 0,
5
+ registerControlId: e,
6
+ labelId: void 0,
7
+ setLabelId: e,
8
+ messageIds: [],
9
+ setMessageIds: e,
10
+ getDescriptionProps: (n) => n
11
+ });
12
+ process.env.NODE_ENV !== "production" && (o.displayName = "LabelableContext");
13
+ function r() {
14
+ return t.useContext(o);
15
+ }
16
+ export {
17
+ o as LabelableContext,
18
+ r as useLabelableContext
19
+ };