@mortenbrudvik/waveui 0.15.0 → 0.16.0

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 (155) hide show
  1. package/README.md +274 -24
  2. package/dist/components/data-display/List.cjs +1 -1
  3. package/dist/components/data-display/List.cjs.map +1 -1
  4. package/dist/components/data-display/List.mjs +405 -219
  5. package/dist/components/data-display/List.mjs.map +1 -1
  6. package/dist/components/data-display/List.registry.cjs +1 -1
  7. package/dist/components/data-display/List.registry.cjs.map +1 -1
  8. package/dist/components/data-display/List.registry.mjs +12 -6
  9. package/dist/components/data-display/List.registry.mjs.map +1 -1
  10. package/dist/components/input/Combobox.cjs +1 -1
  11. package/dist/components/input/Combobox.cjs.map +1 -1
  12. package/dist/components/input/Combobox.mjs +163 -148
  13. package/dist/components/input/Combobox.mjs.map +1 -1
  14. package/dist/components/input/Dropdown.cjs +1 -1
  15. package/dist/components/input/Dropdown.cjs.map +1 -1
  16. package/dist/components/input/Dropdown.mjs +132 -117
  17. package/dist/components/input/Dropdown.mjs.map +1 -1
  18. package/dist/components/input/Listbox.cjs +1 -1
  19. package/dist/components/input/Listbox.cjs.map +1 -1
  20. package/dist/components/input/Listbox.mjs +90 -78
  21. package/dist/components/input/Listbox.mjs.map +1 -1
  22. package/dist/components/input/Option.cjs +1 -1
  23. package/dist/components/input/Option.cjs.map +1 -1
  24. package/dist/components/input/Option.data.cjs +2 -0
  25. package/dist/components/input/Option.data.cjs.map +1 -0
  26. package/dist/components/input/Option.data.mjs +114 -0
  27. package/dist/components/input/Option.data.mjs.map +1 -0
  28. package/dist/components/input/Option.mjs +21 -17
  29. package/dist/components/input/Option.mjs.map +1 -1
  30. package/dist/components/layout/FlatTree.cjs +2 -0
  31. package/dist/components/layout/FlatTree.cjs.map +1 -0
  32. package/dist/components/layout/FlatTree.context.cjs +2 -0
  33. package/dist/components/layout/FlatTree.context.cjs.map +1 -0
  34. package/dist/components/layout/FlatTree.context.mjs +20 -0
  35. package/dist/components/layout/FlatTree.context.mjs.map +1 -0
  36. package/dist/components/layout/FlatTree.item.cjs +2 -0
  37. package/dist/components/layout/FlatTree.item.cjs.map +1 -0
  38. package/dist/components/layout/FlatTree.item.mjs +90 -0
  39. package/dist/components/layout/FlatTree.item.mjs.map +1 -0
  40. package/dist/components/layout/FlatTree.mjs +276 -0
  41. package/dist/components/layout/FlatTree.mjs.map +1 -0
  42. package/dist/components/layout/Tree.core.cjs +1 -1
  43. package/dist/components/layout/Tree.core.cjs.map +1 -1
  44. package/dist/components/layout/Tree.core.mjs +166 -165
  45. package/dist/components/layout/Tree.core.mjs.map +1 -1
  46. package/dist/components/layout/Tree.selection.cjs +1 -1
  47. package/dist/components/layout/Tree.selection.cjs.map +1 -1
  48. package/dist/components/layout/Tree.selection.mjs +11 -57
  49. package/dist/components/layout/Tree.selection.mjs.map +1 -1
  50. package/dist/components/layout/useFlatTree.cjs +2 -0
  51. package/dist/components/layout/useFlatTree.cjs.map +1 -0
  52. package/dist/components/layout/useFlatTree.mjs +83 -0
  53. package/dist/components/layout/useFlatTree.mjs.map +1 -0
  54. package/dist/components/table/DataGrid.cjs +1 -1
  55. package/dist/components/table/DataGrid.cjs.map +1 -1
  56. package/dist/components/table/DataGrid.context.cjs +2 -0
  57. package/dist/components/table/DataGrid.context.cjs.map +1 -0
  58. package/dist/components/table/DataGrid.context.mjs +74 -0
  59. package/dist/components/table/DataGrid.context.mjs.map +1 -0
  60. package/dist/components/table/DataGrid.header.cjs +2 -0
  61. package/dist/components/table/DataGrid.header.cjs.map +1 -0
  62. package/dist/components/table/DataGrid.header.mjs +168 -0
  63. package/dist/components/table/DataGrid.header.mjs.map +1 -0
  64. package/dist/components/table/DataGrid.mjs +488 -591
  65. package/dist/components/table/DataGrid.mjs.map +1 -1
  66. package/dist/components/table/DataGrid.sizing.cjs +2 -0
  67. package/dist/components/table/DataGrid.sizing.cjs.map +1 -0
  68. package/dist/components/table/DataGrid.sizing.mjs +187 -0
  69. package/dist/components/table/DataGrid.sizing.mjs.map +1 -0
  70. package/dist/components/table/DataGrid.store.cjs +2 -0
  71. package/dist/components/table/DataGrid.store.cjs.map +1 -0
  72. package/dist/components/table/DataGrid.store.mjs +108 -0
  73. package/dist/components/table/DataGrid.store.mjs.map +1 -0
  74. package/dist/components/table/DataGrid.window.cjs +2 -0
  75. package/dist/components/table/DataGrid.window.cjs.map +1 -0
  76. package/dist/components/table/DataGrid.window.mjs +165 -0
  77. package/dist/components/table/DataGrid.window.mjs.map +1 -0
  78. package/dist/components/table/Table.cjs +1 -1
  79. package/dist/components/table/Table.cjs.map +1 -1
  80. package/dist/components/table/Table.mjs +74 -72
  81. package/dist/components/table/Table.mjs.map +1 -1
  82. package/dist/components/table/Table.resize.cjs +2 -0
  83. package/dist/components/table/Table.resize.cjs.map +1 -0
  84. package/dist/components/table/Table.resize.mjs +98 -0
  85. package/dist/components/table/Table.resize.mjs.map +1 -0
  86. package/dist/components/table/useGridNavigation.cjs +1 -1
  87. package/dist/components/table/useGridNavigation.cjs.map +1 -1
  88. package/dist/components/table/useGridNavigation.mjs +343 -140
  89. package/dist/components/table/useGridNavigation.mjs.map +1 -1
  90. package/dist/components/table/useTableColumnSizing.cjs +2 -0
  91. package/dist/components/table/useTableColumnSizing.cjs.map +1 -0
  92. package/dist/components/table/useTableColumnSizing.mjs +76 -0
  93. package/dist/components/table/useTableColumnSizing.mjs.map +1 -0
  94. package/dist/components/table/useTableFeatures.cjs +2 -0
  95. package/dist/components/table/useTableFeatures.cjs.map +1 -0
  96. package/dist/components/table/useTableFeatures.mjs +110 -0
  97. package/dist/components/table/useTableFeatures.mjs.map +1 -0
  98. package/dist/components/table/useTableSelection.cjs +2 -0
  99. package/dist/components/table/useTableSelection.cjs.map +1 -0
  100. package/dist/components/table/useTableSelection.mjs +39 -0
  101. package/dist/components/table/useTableSelection.mjs.map +1 -0
  102. package/dist/components/table/useTableSort.cjs +2 -0
  103. package/dist/components/table/useTableSort.cjs.map +1 -0
  104. package/dist/components/table/useTableSort.mjs +58 -0
  105. package/dist/components/table/useTableSort.mjs.map +1 -0
  106. package/dist/hooks/useActiveDescendant.cjs +1 -1
  107. package/dist/hooks/useActiveDescendant.cjs.map +1 -1
  108. package/dist/hooks/useActiveDescendant.mjs +33 -25
  109. package/dist/hooks/useActiveDescendant.mjs.map +1 -1
  110. package/dist/hooks/useListbox.cjs +1 -1
  111. package/dist/hooks/useListbox.cjs.map +1 -1
  112. package/dist/hooks/useListbox.mjs +140 -130
  113. package/dist/hooks/useListbox.mjs.map +1 -1
  114. package/dist/hooks/useRovingTabIndex.cjs +1 -1
  115. package/dist/hooks/useRovingTabIndex.cjs.map +1 -1
  116. package/dist/hooks/useRovingTabIndex.mjs +1 -1
  117. package/dist/hooks/useRovingTabIndex.mjs.map +1 -1
  118. package/dist/hooks/useSelection.cjs +2 -0
  119. package/dist/hooks/useSelection.cjs.map +1 -0
  120. package/dist/hooks/useSelection.mjs +57 -0
  121. package/dist/hooks/useSelection.mjs.map +1 -0
  122. package/dist/hooks/useVirtualWindow.cjs +2 -0
  123. package/dist/hooks/useVirtualWindow.cjs.map +1 -0
  124. package/dist/hooks/useVirtualWindow.mjs +102 -0
  125. package/dist/hooks/useVirtualWindow.mjs.map +1 -0
  126. package/dist/index.cjs +1 -1
  127. package/dist/index.d.cts +1542 -53
  128. package/dist/index.d.ts +1542 -53
  129. package/dist/index.mjs +147 -136
  130. package/dist/lib/classNames.cjs +1 -1
  131. package/dist/lib/classNames.cjs.map +1 -1
  132. package/dist/lib/classNames.mjs +68 -49
  133. package/dist/lib/classNames.mjs.map +1 -1
  134. package/dist/lib/columnSizing.cjs +2 -0
  135. package/dist/lib/columnSizing.cjs.map +1 -0
  136. package/dist/lib/columnSizing.mjs +27 -0
  137. package/dist/lib/columnSizing.mjs.map +1 -0
  138. package/dist/lib/flatTree.cjs +2 -0
  139. package/dist/lib/flatTree.cjs.map +1 -0
  140. package/dist/lib/flatTree.mjs +118 -0
  141. package/dist/lib/flatTree.mjs.map +1 -0
  142. package/dist/lib/selection.cjs +2 -0
  143. package/dist/lib/selection.cjs.map +1 -0
  144. package/dist/lib/selection.mjs +28 -0
  145. package/dist/lib/selection.mjs.map +1 -0
  146. package/dist/lib/treeCascade.cjs +2 -0
  147. package/dist/lib/treeCascade.cjs.map +1 -0
  148. package/dist/lib/treeCascade.mjs +52 -0
  149. package/dist/lib/treeCascade.mjs.map +1 -0
  150. package/dist/lib/virtual.cjs +2 -0
  151. package/dist/lib/virtual.cjs.map +1 -0
  152. package/dist/lib/virtual.mjs +54 -0
  153. package/dist/lib/virtual.mjs.map +1 -0
  154. package/dist/styles.css +1 -1
  155. package/package.json +1 -1
@@ -19,208 +19,222 @@ import { pickerButtonOffset as _e, pickerEndPadding as ve, pickerGlyphSize as ye
19
19
  import { PickerExpandButton as xe, showsExpandButton as Se } from "./Combobox.expand.mjs";
20
20
  import { insertedText as Ce, replacedText as we } from "./Combobox.text.mjs";
21
21
  import { ListboxSurface as Te, Option as s, OptionGroup as c, useListboxPopup as Ee } from "./Option.mjs";
22
- import { PickerAnnouncer as De, announceToggle as Oe, defaultSelectionLabel as ke } from "./pickerLabels.mjs";
23
- import { EMPTY_VALUES as Ae, resetValues as je, toValues as Me, toggleValue as Ne } from "./pickerValues.mjs";
22
+ import { renderListboxItems as De, renderListboxWindow as Oe, useDataModeWarnings as ke, useItemsAndChildrenWarning as Ae, useShownListScroll as je } from "./Option.data.mjs";
23
+ import { PickerAnnouncer as Me, announceToggle as Ne, defaultSelectionLabel as Pe } from "./pickerLabels.mjs";
24
+ import { EMPTY_VALUES as Fe, resetValues as Ie, toValues as Le, toggleValue as Re } from "./pickerValues.mjs";
24
25
  import * as l from "react";
25
- import { jsx as u, jsxs as Pe } from "react/jsx-runtime";
26
+ import { jsx as u, jsxs as ze } from "react/jsx-runtime";
26
27
  //#region src/components/input/Combobox.tsx
27
- var d = /* @__PURE__ */ new Set(["historyUndo", "historyRedo"]);
28
- function Fe(e, t) {
28
+ var d = /* @__PURE__ */ new Set(["historyUndo", "historyRedo"]), Be = /* @__PURE__ */ new Map();
29
+ function Ve(e, t) {
29
30
  return (e.textValue ?? e.label).toLowerCase().includes(t.toLowerCase());
30
31
  }
31
32
  var f = (s) => {
32
- let { multiselect: c = !1, value: f, defaultValue: p, onValueChange: Ie, onOptionSelect: m, open: Le, defaultOpen: Re, onOpenChange: ze, placeholder: Be, disabled: h = !1, size: Ve, positioning: He, appearance: Ue, freeform: g = !1, filter: We, query: Ge, defaultQuery: Ke, onQueryChange: qe, onActiveOptionChange: Je, disabledOptionsFocusable: Ye = !1, name: Xe, form: Ze, required: Qe, autoComplete: $e = "off", autoCapitalize: et, autoCorrect: tt, maxLength: nt, readOnly: _, clearable: rt = !1, expandIcon: it, labels: v, inputMode: at, spellCheck: ot, enterKeyHint: st, autoFocus: ct, tabIndex: lt, id: ut, "aria-label": dt, "aria-labelledby": ft, "aria-describedby": pt, "aria-invalid": mt, "aria-required": ht, "aria-errormessage": gt, "aria-details": _t, onFocus: vt, onBlur: yt, onKeyDown: bt, onKeyUp: xt, controlRef: St, className: Ct, children: y, ref: wt, ...Tt } = s;
33
+ let { multiselect: c = !1, value: f, defaultValue: p, onValueChange: He, onOptionSelect: m, open: Ue, defaultOpen: We, onOpenChange: Ge, placeholder: Ke, disabled: h = !1, size: qe, positioning: Je, appearance: Ye, freeform: Xe = !1, filter: Ze, query: Qe, defaultQuery: $e, onQueryChange: et, onActiveOptionChange: tt, disabledOptionsFocusable: nt = !1, name: rt, form: it, required: at, autoComplete: ot = "off", autoCapitalize: st, autoCorrect: ct, maxLength: lt, readOnly: g, clearable: ut = !1, expandIcon: dt, labels: _, items: v, renderOption: ft, virtualWindow: pt, inputMode: mt, spellCheck: ht, enterKeyHint: gt, autoFocus: _t, tabIndex: vt, id: yt, "aria-label": bt, "aria-labelledby": xt, "aria-describedby": St, "aria-invalid": Ct, "aria-required": wt, "aria-errormessage": Tt, "aria-details": Et, onFocus: Dt, onBlur: Ot, onKeyDown: kt, onKeyUp: At, controlRef: jt, className: Mt, children: y, ref: Nt, ...Pt } = s;
33
34
  m !== void 0 && t("Combobox", "onOptionSelect", "onValueChange");
34
- let b = g && !c, Et = g && c;
35
+ let b = Xe && !c, Ft = Xe && c;
35
36
  l.useEffect(() => {
36
- Et && n("Combobox:freeform-multiselect", "Combobox: `freeform` is not available with `multiselect`: a multi-select Combobox selects options only.");
37
- }, [Et]);
38
- let Dt = b && (Ge !== void 0 || Ke !== void 0);
37
+ Ft && n("Combobox:freeform-multiselect", "Combobox: `freeform` is not available with `multiselect`: a multi-select Combobox selects options only.");
38
+ }, [Ft]);
39
+ let It = b && (Qe !== void 0 || $e !== void 0);
39
40
  l.useEffect(() => {
40
- Dt && n("Combobox:query-freeform", "Combobox: `query` and `defaultQuery` are not used with `freeform`: the typed text is the value (`value`, `onValueChange`).");
41
- }, [Dt]);
42
- let Ot = ne(), kt = (Qe ?? Ot?.required ?? !1) && !_, x = re({
43
- id: ut,
44
- "aria-label": dt,
45
- "aria-labelledby": ft,
46
- "aria-describedby": pt,
47
- "aria-invalid": mt,
48
- "aria-required": ht ?? Qe
49
- }), At = me(!1, x["aria-invalid"]), { size: S, appearance: C } = pe(Ve, Ue), [jt, w] = a(f, p ?? (c ? Ae : ""), (e) => {
50
- Ie?.(typeof e == "string" ? e : [...e]);
51
- }), T = Me(jt), E = c ? "" : jt, D = !h && !_, [Mt, O] = a(Le, (Re ?? !1) && D, ze), k = Mt && D, [Nt, A] = a(b ? void 0 : Ge, D ? Ke ?? "" : "", b ? void 0 : qe), [Pt, j] = l.useState(!1), [M, N] = l.useState(null), P = b ? M : D && (Pt || Nt !== "") ? Nt : null, [F, Ft] = l.useState(D ? "unlocked" : "mounted-locked");
52
- D && F !== "unlocked" ? Ft("unlocked") : !D && F === "unlocked" && (Ft("locked"), j(!1), N(null)), l.useEffect(() => {
41
+ It && n("Combobox:query-freeform", "Combobox: `query` and `defaultQuery` are not used with `freeform`: the typed text is the value (`value`, `onValueChange`).");
42
+ }, [It]);
43
+ let Lt = ne(), Rt = (at ?? Lt?.required ?? !1) && !g, x = re({
44
+ id: yt,
45
+ "aria-label": bt,
46
+ "aria-labelledby": xt,
47
+ "aria-describedby": St,
48
+ "aria-invalid": Ct,
49
+ "aria-required": wt ?? at
50
+ }), zt = me(!1, x["aria-invalid"]), { size: S, appearance: C } = pe(qe, Ye), [Bt, w] = a(f, p ?? (c ? Fe : ""), (e) => {
51
+ He?.(typeof e == "string" ? e : [...e]);
52
+ }), T = Le(Bt), E = c ? "" : Bt, D = !h && !g, [Vt, O] = a(Ue, (We ?? !1) && D, Ge), k = Vt && D, [Ht, A] = a(b ? void 0 : Qe, D ? $e ?? "" : "", b ? void 0 : et), [Ut, j] = l.useState(!1), [M, N] = l.useState(null), P = b ? M : D && (Ut || Ht !== "") ? Ht : null, [F, Wt] = l.useState(D ? "unlocked" : "mounted-locked");
53
+ D && F !== "unlocked" ? Wt("unlocked") : !D && F === "unlocked" && (Wt("locked"), j(!1), N(null)), l.useEffect(() => {
53
54
  F === "locked" && A("");
54
55
  }, [F, A]);
55
- let It = !D && Mt;
56
+ let Gt = !D && Vt;
56
57
  l.useEffect(() => {
57
- It && O(!1);
58
- }, [It, O]);
59
- let [Lt, I] = l.useState(null), Rt = l.useRef(null), L = l.useRef(null), zt = l.useMemo(() => ie(y), [y]), R = P ?? "", Bt = l.useMemo(() => R ? (e) => (We ?? Fe)(e, R) : void 0, [R, We]), z = (e) => {
58
+ Gt && O(!1);
59
+ }, [Gt, O]);
60
+ let [Kt, I] = l.useState(null), qt = l.useRef(null), L = l.useRef(null), R = v !== void 0, Jt = l.useMemo(() => R ? Be : ie(y), [R, y]);
61
+ Ae("Combobox", v, y), ke("Combobox", {
62
+ items: v,
63
+ renderOption: ft,
64
+ virtualWindow: pt,
65
+ children: y
66
+ });
67
+ let z = R ? pt : void 0, B = P ?? "", Yt = l.useMemo(() => B ? (e) => (Ze ?? Ve)(e, B) : void 0, [B, Ze]), V = (e) => {
60
68
  b ? N(e) : (j(!0), A(e));
61
- }, B = () => {
69
+ }, H = () => {
62
70
  b ? N(null) : (j(!1), A(""));
63
- }, Vt = (e) => {
71
+ }, Xt = (e) => {
64
72
  I(e), w(e), m?.(e);
65
- }, V = () => {
66
- O(!1), B();
67
- }, H;
68
- b ? H = () => {
69
- N(null), Vt("");
70
- } : P && (H = B);
71
- let U = ae({
73
+ }, U = () => {
74
+ O(!1), H();
75
+ }, W;
76
+ b ? W = () => {
77
+ N(null), Xt("");
78
+ } : P && (W = H);
79
+ let G = ae({
72
80
  open: k,
73
81
  onOpenChange: (e) => {
74
- e ? O(!0) : V();
82
+ e ? O(!0) : U();
75
83
  },
76
84
  mode: "editable",
77
85
  multiselect: c,
78
- disabledOptionsFocusable: Ye,
86
+ disabledOptionsFocusable: nt,
87
+ items: v,
79
88
  selectedValues: T,
80
89
  onSelect: (e, t) => {
81
90
  if (!c) {
82
- w(e), m?.(e), B(), I(null);
91
+ w(e), m?.(e), H(), I(null);
83
92
  return;
84
93
  }
85
- let { values: n, added: r } = Ne(T, e);
86
- w(n), m?.(e), Oe(v, t?.item.label ?? zt.get(e) ?? e, r, n.length), B();
94
+ let { values: n, added: r } = Re(T, e);
95
+ w(n), m?.(e), Ne(_, t?.item.label ?? Jt.get(e) ?? e, r, n.length), H();
87
96
  },
88
- filter: Bt,
97
+ filter: Yt,
89
98
  autoHighlight: !b && P ? "first" : !1,
90
- onActiveValueChange: Je,
99
+ onActiveValueChange: tt,
100
+ onScrollToItem: z ? (e) => z.scrollToIndex(e, { align: "auto" }) : void 0,
91
101
  idPrefix: "combobox-listbox",
92
- onClearDraft: H
93
- }), Ht = (e) => U.getItem(e)?.label ?? zt.get(e), W = "";
102
+ onClearDraft: W
103
+ }), Zt = (e) => G.getItem(e)?.label ?? Jt.get(e), K = "";
94
104
  if (c) {
95
- let e = T.map(Ht).filter((e) => e !== void 0);
96
- e.length > 0 && (W = (v?.selection ?? ke)(e));
105
+ let e = T.map(Zt).filter((e) => e !== void 0);
106
+ e.length > 0 && (K = (_?.selection ?? Pe)(e));
97
107
  }
98
- let G = c && P === null && W !== "", Ut = E ? Ht(E) : void 0, K;
99
- K = c ? P ?? W : b ? E === Lt ? E : Ut ?? E : P ?? Ut ?? "", b && M !== null && M !== K && N(K);
100
- let q = k && U.items.length > 0, Wt = v?.noMatches ?? "No matches", J = k && (q || !!P), Gt = J && !q, { layerId: Kt, setReference: qt, surfaceRef: Jt, floatingProps: Yt } = Ee({
101
- positioning: He,
108
+ let q = c && P === null && K !== "", Qt = E ? Zt(E) : void 0, J;
109
+ J = c ? P ?? K : b ? E === Kt ? E : Qt ?? E : P ?? Qt ?? "", b && M !== null && M !== J && N(J);
110
+ let Y = k && G.items.length > 0, $t = _?.noMatches ?? "No matches", X = k && (Y || !!P), en = X && !Y, { layerId: tn, setReference: nn, surfaceRef: rn, floatingProps: an } = Ee({
111
+ positioning: Je,
102
112
  open: k,
103
- surfaceOpen: J,
104
- onDismiss: V,
105
- rootRef: Rt,
113
+ surfaceOpen: X,
114
+ onDismiss: U,
115
+ rootRef: qt,
106
116
  anchorRef: L
107
- }), Xt = o(Rt, wt), Zt = o(L, St, qt);
108
- he(L, () => {
109
- w(c ? (e) => je(e, p) : p ?? ""), B(), I(null);
110
- }, Ze);
111
- let Y = l.useRef(!1), Qt = (e) => {
112
- Y.current = G && !te(e.currentTarget);
113
- }, $t = (e) => {
114
- G && e.currentTarget.select();
115
- }, en = (e) => {
116
- Y.current && (Y.current = !1, e.preventDefault());
117
+ }), on = o(qt, Nt), sn = o(L, jt, nn), cn = o(Y ? z?.scrollRef : void 0);
118
+ je(Y, z, G.items, G.activeValue, T), he(L, () => {
119
+ w(c ? (e) => Ie(e, p) : p ?? ""), H(), I(null);
120
+ }, it);
121
+ let Z = l.useRef(!1), ln = (e) => {
122
+ Z.current = q && !te(e.currentTarget);
123
+ }, un = (e) => {
124
+ q && e.currentTarget.select();
125
+ }, dn = (e) => {
126
+ Z.current && (Z.current = !1, e.preventDefault());
117
127
  };
118
128
  l.useLayoutEffect(() => {
119
129
  let e = L.current;
120
- G && e && te(e) && e.select();
121
- }, [G, W]);
122
- let X = l.useRef(null), tn = l.useRef(null), Z = ee((e) => {
130
+ q && e && te(e) && e.select();
131
+ }, [q, K]);
132
+ let Q = l.useRef(null), fn = l.useRef(null), pn = ee((e) => {
123
133
  let t = e.currentTarget;
124
- G && t.value === W && (X.current = null, !d.has(e.inputType ?? "") && (tn.current = e, z(W), k || O(!0)));
134
+ q && t.value === K && (Q.current = null, !d.has(e.inputType ?? "") && (fn.current = e, V(K), k || O(!0)));
125
135
  });
126
136
  l.useEffect(() => {
127
137
  let e = L.current;
128
138
  if (!c || !e) return;
129
139
  let t = (t) => {
130
140
  let { inputType: n } = t, { selectionStart: r, selectionEnd: i } = e;
131
- X.current = {
141
+ Q.current = {
132
142
  inputType: n,
133
143
  range: n === "insertFromDrop" || d.has(n) || r === null || i === null ? null : [r, i]
134
144
  };
135
145
  };
136
- return e.addEventListener("beforeinput", t), e.addEventListener("input", Z), () => {
137
- e.removeEventListener("beforeinput", t), e.removeEventListener("input", Z);
146
+ return e.addEventListener("beforeinput", t), e.addEventListener("input", pn), () => {
147
+ e.removeEventListener("beforeinput", t), e.removeEventListener("input", pn);
138
148
  };
139
- }, [c, Z]);
140
- let nn = (e) => {
141
- if (e.key === "Escape" && k && !J && !e.nativeEvent.isComposing) {
142
- V(), H && e.currentTarget.value !== "" && (e.preventDefault(), H());
149
+ }, [c, pn]);
150
+ let mn = (e) => {
151
+ if (e.key === "Escape" && k && !X && !e.nativeEvent.isComposing) {
152
+ U(), W && e.currentTarget.value !== "" && (e.preventDefault(), W());
143
153
  return;
144
154
  }
145
- U.onKeyDown(e);
146
- }, rn = (e) => {
147
- if (e.nativeEvent === tn.current) return;
148
- let t = e.target.value, n = X.current;
149
- X.current = null;
155
+ G.onKeyDown(e);
156
+ }, hn = (e) => {
157
+ if (e.nativeEvent === fn.current) return;
158
+ let t = e.target.value, n = Q.current;
159
+ Q.current = null;
150
160
  let r = n && n.inputType === e.nativeEvent.inputType ? n : null;
151
- if (!c) z(t);
152
- else if (t === W && (r === null || d.has(r.inputType))) B();
153
- else if (G) {
161
+ if (!c) V(t);
162
+ else if (t === K && (r === null || d.has(r.inputType))) H();
163
+ else if (q) {
154
164
  let e = r?.range;
155
- z((e && we(W, t, e[0], e[1])) ?? Ce(W, t));
156
- } else z(t);
157
- k || O(!0), b && Vt(t);
158
- }, an = () => {
159
- D && (k ? V() : O(!0), L.current?.focus());
160
- }, on = () => {
161
- w(c ? Ae : ""), I(null), B(), O(!1), L.current?.focus();
162
- }, Q = Se(it), $ = rt && (c ? T.length > 0 : E !== "") && !_, sn = x["aria-label"] === void 0 ? x["aria-labelledby"] ?? Ot?.labelId : x["aria-labelledby"];
163
- return /* @__PURE__ */ Pe("div", {
165
+ V((e && we(K, t, e[0], e[1])) ?? Ce(K, t));
166
+ } else V(t);
167
+ k || O(!0), b && Xt(t);
168
+ }, gn = () => {
169
+ D && (k ? U() : O(!0), L.current?.focus());
170
+ }, _n = () => {
171
+ w(c ? Fe : ""), I(null), H(), O(!1), L.current?.focus();
172
+ }, $ = Se(dt), vn = ut && (c ? T.length > 0 : E !== "") && !g, yn = x["aria-label"] === void 0 ? x["aria-labelledby"] ?? Lt?.labelId : x["aria-labelledby"], bn = {
173
+ selected: new Set(T),
174
+ activeValue: G.activeValue,
175
+ renderOption: ft
176
+ };
177
+ return /* @__PURE__ */ ze("div", {
164
178
  "data-size": S,
165
179
  "data-appearance": C,
166
- ...Tt,
167
- ref: Xt,
168
- className: e(i.root, "relative inline-flex flex-col", Ct),
180
+ ...Pt,
181
+ ref: on,
182
+ className: e(i.root, "relative inline-flex flex-col", Mt),
169
183
  children: [
170
- c && /* @__PURE__ */ u(De, {}),
171
- /* @__PURE__ */ Pe("div", {
184
+ c && /* @__PURE__ */ u(Me, {}),
185
+ /* @__PURE__ */ ze("div", {
172
186
  className: "relative flex items-center",
173
187
  children: [
174
188
  /* @__PURE__ */ u("input", {
175
189
  type: "text",
176
- autoComplete: $e,
190
+ autoComplete: ot,
177
191
  ...x,
178
- ...U.getComboboxProps(),
179
- "aria-expanded": q,
180
- "aria-errormessage": gt,
181
- "aria-details": _t,
182
- ref: Zt,
192
+ ...G.getComboboxProps(),
193
+ "aria-expanded": Y,
194
+ "aria-errormessage": Tt,
195
+ "aria-details": Et,
196
+ ref: sn,
183
197
  disabled: h,
184
- readOnly: _,
185
- placeholder: c && W !== "" ? void 0 : Be,
186
- autoCapitalize: et,
187
- autoCorrect: tt,
188
- maxLength: G ? void 0 : nt,
189
- inputMode: at,
190
- spellCheck: ot,
191
- enterKeyHint: st,
192
- autoFocus: ct,
193
- tabIndex: lt,
194
- value: K,
195
- onChange: rn,
198
+ readOnly: g,
199
+ placeholder: c && K !== "" ? void 0 : Ke,
200
+ autoCapitalize: st,
201
+ autoCorrect: ct,
202
+ maxLength: q ? void 0 : lt,
203
+ inputMode: mt,
204
+ spellCheck: ht,
205
+ enterKeyHint: gt,
206
+ autoFocus: _t,
207
+ tabIndex: vt,
208
+ value: J,
209
+ onChange: hn,
196
210
  onClick: () => {
197
211
  !k && D && O(!0);
198
212
  },
199
- onMouseDown: Qt,
200
- onMouseUp: en,
201
- onKeyDown: r(bt, _ ? void 0 : nn),
202
- onKeyUp: r(xt, U.onKeyUp),
203
- onFocus: r(vt, $t),
204
- onBlur: r(yt, B, { checkDefaultPrevented: !1 }),
205
- className: e(i.input, le[S], "w-full", ue[S], de[S], se[C], "text-foreground placeholder:text-muted-foreground", ce, oe, At && "border-destructive", ve(Number($) + Number(Q), S))
213
+ onMouseDown: ln,
214
+ onMouseUp: dn,
215
+ onKeyDown: r(kt, g ? void 0 : mn),
216
+ onKeyUp: r(At, G.onKeyUp),
217
+ onFocus: r(Dt, un),
218
+ onBlur: r(Ot, H, { checkDefaultPrevented: !1 }),
219
+ className: e(i.input, le[S], "w-full", ue[S], de[S], se[C], "text-foreground placeholder:text-muted-foreground", ce, oe, zt && "border-destructive", ve(Number(vn) + Number($), S))
206
220
  }),
207
- $ && /* @__PURE__ */ u("button", {
221
+ vn && /* @__PURE__ */ u("button", {
208
222
  type: "button",
209
- "aria-label": v?.clear ?? "Clear selection",
223
+ "aria-label": _?.clear ?? "Clear selection",
210
224
  disabled: h,
211
225
  onMouseDown: (e) => e.preventDefault(),
212
- onClick: on,
213
- className: e(i.clearButton, be(S, C), _e(S, Q ? 2 : 1), "focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring", "disabled:cursor-not-allowed disabled:opacity-50 aria-disabled:cursor-not-allowed aria-disabled:opacity-50 aria-disabled:focus-visible:opacity-100"),
226
+ onClick: _n,
227
+ className: e(i.clearButton, be(S, C), _e(S, $ ? 2 : 1), "focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring", "disabled:cursor-not-allowed disabled:opacity-50 aria-disabled:cursor-not-allowed aria-disabled:opacity-50 aria-disabled:focus-visible:opacity-100"),
214
228
  children: /* @__PURE__ */ u(fe, { size: ye(S, "icon") })
215
229
  }),
216
- Q && /* @__PURE__ */ u(xe, {
230
+ $ && /* @__PURE__ */ u(xe, {
217
231
  component: "Combobox",
218
- expandIcon: it,
219
- label: v?.expand ?? "Show options",
220
- expanded: q,
221
- listboxId: U.listboxId,
222
- disabled: h || !!_,
223
- onToggle: an,
232
+ expandIcon: dt,
233
+ label: _?.expand ?? "Show options",
234
+ expanded: Y,
235
+ listboxId: G.listboxId,
236
+ disabled: h || !!g,
237
+ onToggle: gn,
224
238
  size: S,
225
239
  appearance: C,
226
240
  className: i.expandButton,
@@ -231,44 +245,45 @@ var f = (s) => {
231
245
  /* @__PURE__ */ u("span", {
232
246
  role: "status",
233
247
  className: "sr-only",
234
- children: Gt && Wt
248
+ children: en && $t
235
249
  }),
236
250
  /* @__PURE__ */ u(Te, {
237
- listbox: U,
238
- layerId: Kt,
239
- surfaceRef: Jt,
240
- floatingProps: Yt,
251
+ listbox: G,
252
+ layerId: tn,
253
+ surfaceRef: rn,
254
+ floatingProps: an,
241
255
  open: k,
242
- expanded: q,
243
- listClassName: i.listbox,
256
+ expanded: Y,
257
+ listClassName: e(i.listbox, z && "[overflow-anchor:none]"),
244
258
  surfaceClassName: i.surface,
245
259
  emptyContent: P ? /* @__PURE__ */ u("div", {
246
260
  "aria-hidden": "true",
247
261
  className: e(i.emptyMessage, "px-3 py-1.5 text-body-1 text-muted-foreground"),
248
- children: Wt
262
+ children: $t
249
263
  }) : void 0,
250
264
  "aria-label": x["aria-label"],
251
- "aria-labelledby": sn,
252
- children: y
265
+ "aria-labelledby": yn,
266
+ listProps: z ? { ref: cn } : void 0,
267
+ children: R ? Y && (z ? Oe(G.items, z, bn, i.spacer) : De(G.items, bn)) : y
253
268
  }),
254
269
  /* @__PURE__ */ u(ge, {
255
- name: Xe,
256
- form: Ze,
270
+ name: rt,
271
+ form: it,
257
272
  disabled: h,
258
273
  value: c ? T : E,
259
274
  type: "text",
260
- required: kt,
275
+ required: Rt,
261
276
  onInvalid: () => L.current?.focus()
262
277
  })
263
278
  ]
264
279
  });
265
280
  };
266
281
  f.displayName = "Combobox";
267
- var p = s, Ie = c, m = /* @__PURE__ */ Object.assign(f, {
282
+ var p = s, He = c, m = /* @__PURE__ */ Object.assign(f, {
268
283
  Option: s,
269
284
  OptionGroup: c
270
285
  });
271
286
  //#endregion
272
- export { m as Combobox, p as ComboboxOption, Ie as ComboboxOptionGroup, s as Option, c as OptionGroup };
287
+ export { m as Combobox, p as ComboboxOption, He as ComboboxOptionGroup, s as Option, c as OptionGroup };
273
288
 
274
289
  //# sourceMappingURL=Combobox.mjs.map