@mortenbrudvik/waveui 0.8.0 → 0.10.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 (206) hide show
  1. package/README.md +634 -167
  2. package/dist/components/data-display/InfoButton.cjs +2 -0
  3. package/dist/components/data-display/InfoButton.cjs.map +1 -0
  4. package/dist/components/data-display/InfoButton.mjs +173 -0
  5. package/dist/components/data-display/InfoButton.mjs.map +1 -0
  6. package/dist/components/data-display/InfoLabel.cjs +1 -1
  7. package/dist/components/data-display/InfoLabel.cjs.map +1 -1
  8. package/dist/components/data-display/InfoLabel.mjs +39 -96
  9. package/dist/components/data-display/InfoLabel.mjs.map +1 -1
  10. package/dist/components/input/Calendar.cjs +2 -0
  11. package/dist/components/input/Calendar.cjs.map +1 -0
  12. package/dist/components/input/Calendar.mjs +352 -0
  13. package/dist/components/input/Calendar.mjs.map +1 -0
  14. package/dist/components/input/Calendar.views.cjs +2 -0
  15. package/dist/components/input/Calendar.views.cjs.map +1 -0
  16. package/dist/components/input/Calendar.views.mjs +194 -0
  17. package/dist/components/input/Calendar.views.mjs.map +1 -0
  18. package/dist/components/input/Checkbox.cjs +1 -1
  19. package/dist/components/input/Checkbox.cjs.map +1 -1
  20. package/dist/components/input/Checkbox.mjs +91 -75
  21. package/dist/components/input/Checkbox.mjs.map +1 -1
  22. package/dist/components/input/ColorArea.cjs +1 -1
  23. package/dist/components/input/ColorArea.cjs.map +1 -1
  24. package/dist/components/input/ColorArea.mjs +18 -18
  25. package/dist/components/input/ColorArea.mjs.map +1 -1
  26. package/dist/components/input/ColorPicker.parts.cjs +1 -1
  27. package/dist/components/input/ColorPicker.parts.cjs.map +1 -1
  28. package/dist/components/input/ColorPicker.parts.mjs +1 -1
  29. package/dist/components/input/ColorPicker.parts.mjs.map +1 -1
  30. package/dist/components/input/Combobox.cjs +1 -1
  31. package/dist/components/input/Combobox.cjs.map +1 -1
  32. package/dist/components/input/Combobox.expand.cjs +1 -1
  33. package/dist/components/input/Combobox.expand.cjs.map +1 -1
  34. package/dist/components/input/Combobox.expand.mjs +20 -20
  35. package/dist/components/input/Combobox.expand.mjs.map +1 -1
  36. package/dist/components/input/Combobox.mjs +219 -138
  37. package/dist/components/input/Combobox.mjs.map +1 -1
  38. package/dist/components/input/Combobox.text.cjs +2 -0
  39. package/dist/components/input/Combobox.text.cjs.map +1 -0
  40. package/dist/components/input/Combobox.text.mjs +24 -0
  41. package/dist/components/input/Combobox.text.mjs.map +1 -0
  42. package/dist/components/input/DatePicker.cjs +1 -1
  43. package/dist/components/input/DatePicker.cjs.map +1 -1
  44. package/dist/components/input/DatePicker.mjs +205 -286
  45. package/dist/components/input/DatePicker.mjs.map +1 -1
  46. package/dist/components/input/Dropdown.cjs +1 -1
  47. package/dist/components/input/Dropdown.cjs.map +1 -1
  48. package/dist/components/input/Dropdown.mjs +137 -105
  49. package/dist/components/input/Dropdown.mjs.map +1 -1
  50. package/dist/components/input/Field.cjs +1 -1
  51. package/dist/components/input/Field.cjs.map +1 -1
  52. package/dist/components/input/Field.mjs +99 -66
  53. package/dist/components/input/Field.mjs.map +1 -1
  54. package/dist/components/input/Input.cjs +1 -1
  55. package/dist/components/input/Input.cjs.map +1 -1
  56. package/dist/components/input/Input.mjs +79 -55
  57. package/dist/components/input/Input.mjs.map +1 -1
  58. package/dist/components/input/Label.cjs +1 -1
  59. package/dist/components/input/Label.cjs.map +1 -1
  60. package/dist/components/input/Label.mjs +19 -13
  61. package/dist/components/input/Label.mjs.map +1 -1
  62. package/dist/components/input/Listbox.cjs +2 -0
  63. package/dist/components/input/Listbox.cjs.map +1 -0
  64. package/dist/components/input/Listbox.mjs +134 -0
  65. package/dist/components/input/Listbox.mjs.map +1 -0
  66. package/dist/components/input/Option.cjs +1 -1
  67. package/dist/components/input/Option.cjs.map +1 -1
  68. package/dist/components/input/Option.mjs +158 -97
  69. package/dist/components/input/Option.mjs.map +1 -1
  70. package/dist/components/input/Rating.cjs +1 -1
  71. package/dist/components/input/Rating.cjs.map +1 -1
  72. package/dist/components/input/Rating.item.cjs +2 -0
  73. package/dist/components/input/Rating.item.cjs.map +1 -0
  74. package/dist/components/input/Rating.item.mjs +255 -0
  75. package/dist/components/input/Rating.item.mjs.map +1 -0
  76. package/dist/components/input/Rating.mjs +150 -151
  77. package/dist/components/input/Rating.mjs.map +1 -1
  78. package/dist/components/input/SearchBox.cjs +1 -1
  79. package/dist/components/input/SearchBox.cjs.map +1 -1
  80. package/dist/components/input/SearchBox.mjs +146 -115
  81. package/dist/components/input/SearchBox.mjs.map +1 -1
  82. package/dist/components/input/Select.cjs +1 -1
  83. package/dist/components/input/Select.cjs.map +1 -1
  84. package/dist/components/input/Select.mjs +34 -25
  85. package/dist/components/input/Select.mjs.map +1 -1
  86. package/dist/components/input/Slider.cjs +1 -1
  87. package/dist/components/input/Slider.cjs.map +1 -1
  88. package/dist/components/input/Slider.mjs +77 -54
  89. package/dist/components/input/Slider.mjs.map +1 -1
  90. package/dist/components/input/SpinButton.cjs +1 -1
  91. package/dist/components/input/SpinButton.cjs.map +1 -1
  92. package/dist/components/input/SpinButton.mjs +198 -96
  93. package/dist/components/input/SpinButton.mjs.map +1 -1
  94. package/dist/components/input/SwatchPicker.cjs +1 -1
  95. package/dist/components/input/SwatchPicker.cjs.map +1 -1
  96. package/dist/components/input/SwatchPicker.context.cjs +2 -0
  97. package/dist/components/input/SwatchPicker.context.cjs.map +1 -0
  98. package/dist/components/input/SwatchPicker.context.mjs +35 -0
  99. package/dist/components/input/SwatchPicker.context.mjs.map +1 -0
  100. package/dist/components/input/SwatchPicker.mjs +131 -103
  101. package/dist/components/input/SwatchPicker.mjs.map +1 -1
  102. package/dist/components/input/SwatchPicker.swatches.cjs +2 -0
  103. package/dist/components/input/SwatchPicker.swatches.cjs.map +1 -0
  104. package/dist/components/input/SwatchPicker.swatches.mjs +207 -0
  105. package/dist/components/input/SwatchPicker.swatches.mjs.map +1 -0
  106. package/dist/components/input/Switch.cjs +1 -1
  107. package/dist/components/input/Switch.cjs.map +1 -1
  108. package/dist/components/input/Switch.mjs +71 -55
  109. package/dist/components/input/Switch.mjs.map +1 -1
  110. package/dist/components/input/TagPicker.cjs +1 -1
  111. package/dist/components/input/TagPicker.cjs.map +1 -1
  112. package/dist/components/input/TagPicker.mjs +154 -123
  113. package/dist/components/input/TagPicker.mjs.map +1 -1
  114. package/dist/components/input/Textarea.cjs +1 -1
  115. package/dist/components/input/Textarea.cjs.map +1 -1
  116. package/dist/components/input/Textarea.mjs +28 -21
  117. package/dist/components/input/Textarea.mjs.map +1 -1
  118. package/dist/components/input/TimePicker.cjs +1 -1
  119. package/dist/components/input/TimePicker.cjs.map +1 -1
  120. package/dist/components/input/TimePicker.mjs +204 -199
  121. package/dist/components/input/TimePicker.mjs.map +1 -1
  122. package/dist/components/input/dateUtils.cjs +1 -1
  123. package/dist/components/input/dateUtils.cjs.map +1 -1
  124. package/dist/components/input/dateUtils.mjs +114 -96
  125. package/dist/components/input/dateUtils.mjs.map +1 -1
  126. package/dist/components/input/fieldLabel.cjs +2 -0
  127. package/dist/components/input/fieldLabel.cjs.map +1 -0
  128. package/dist/components/input/fieldLabel.mjs +17 -0
  129. package/dist/components/input/fieldLabel.mjs.map +1 -0
  130. package/dist/components/input/inputLook.cjs +2 -0
  131. package/dist/components/input/inputLook.cjs.map +1 -0
  132. package/dist/components/input/inputLook.mjs +28 -0
  133. package/dist/components/input/inputLook.mjs.map +1 -0
  134. package/dist/components/input/pickerLabels.cjs +2 -0
  135. package/dist/components/input/pickerLabels.cjs.map +1 -0
  136. package/dist/components/input/pickerLabels.mjs +16 -0
  137. package/dist/components/input/pickerLabels.mjs.map +1 -0
  138. package/dist/components/input/pickerStyles.cjs +1 -1
  139. package/dist/components/input/pickerStyles.cjs.map +1 -1
  140. package/dist/components/input/pickerStyles.mjs +42 -4
  141. package/dist/components/input/pickerStyles.mjs.map +1 -1
  142. package/dist/components/input/pickerValues.cjs +2 -0
  143. package/dist/components/input/pickerValues.cjs.map +1 -0
  144. package/dist/components/input/pickerValues.mjs +24 -0
  145. package/dist/components/input/pickerValues.mjs.map +1 -0
  146. package/dist/components/navigation/Menu.popover.cjs +1 -1
  147. package/dist/components/navigation/Menu.popover.cjs.map +1 -1
  148. package/dist/components/navigation/Menu.popover.mjs +10 -10
  149. package/dist/components/navigation/Menu.root.cjs +1 -1
  150. package/dist/components/navigation/Menu.root.cjs.map +1 -1
  151. package/dist/components/navigation/Menu.root.mjs +10 -10
  152. package/dist/components/overlays/Popover.cjs +1 -1
  153. package/dist/components/overlays/Popover.cjs.map +1 -1
  154. package/dist/components/overlays/Popover.mjs +203 -208
  155. package/dist/components/overlays/Popover.mjs.map +1 -1
  156. package/dist/components/overlays/Popover.shared.cjs +1 -1
  157. package/dist/components/overlays/Popover.shared.cjs.map +1 -1
  158. package/dist/components/overlays/Popover.shared.mjs +82 -77
  159. package/dist/components/overlays/Popover.shared.mjs.map +1 -1
  160. package/dist/components/provider/WaveProvider.cjs +1 -1
  161. package/dist/components/provider/WaveProvider.cjs.map +1 -1
  162. package/dist/components/provider/WaveProvider.mjs +25 -19
  163. package/dist/components/provider/WaveProvider.mjs.map +1 -1
  164. package/dist/components/table/useGridNavigation.cjs +1 -1
  165. package/dist/components/table/useGridNavigation.cjs.map +1 -1
  166. package/dist/components/table/useGridNavigation.mjs +67 -70
  167. package/dist/components/table/useGridNavigation.mjs.map +1 -1
  168. package/dist/hooks/useActiveDescendant.cjs +2 -0
  169. package/dist/hooks/useActiveDescendant.cjs.map +1 -0
  170. package/dist/hooks/useActiveDescendant.mjs +56 -0
  171. package/dist/hooks/useActiveDescendant.mjs.map +1 -0
  172. package/dist/hooks/useFieldControl.cjs.map +1 -1
  173. package/dist/hooks/useFieldControl.mjs.map +1 -1
  174. package/dist/hooks/useListbox.cjs +1 -1
  175. package/dist/hooks/useListbox.cjs.map +1 -1
  176. package/dist/hooks/useListbox.mjs +250 -210
  177. package/dist/hooks/useListbox.mjs.map +1 -1
  178. package/dist/hooks/useRovingGrid.cjs +2 -0
  179. package/dist/hooks/useRovingGrid.cjs.map +1 -0
  180. package/dist/hooks/useRovingGrid.mjs +69 -0
  181. package/dist/hooks/useRovingGrid.mjs.map +1 -0
  182. package/dist/index.cjs +1 -1
  183. package/dist/index.d.cts +2901 -203
  184. package/dist/index.d.ts +2901 -203
  185. package/dist/index.mjs +107 -99
  186. package/dist/lib/classNames.cjs +1 -1
  187. package/dist/lib/classNames.cjs.map +1 -1
  188. package/dist/lib/classNames.mjs +111 -67
  189. package/dist/lib/classNames.mjs.map +1 -1
  190. package/dist/lib/date.cjs +2 -0
  191. package/dist/lib/date.cjs.map +1 -0
  192. package/dist/lib/date.mjs +44 -0
  193. package/dist/lib/date.mjs.map +1 -0
  194. package/dist/lib/focus.cjs +1 -1
  195. package/dist/lib/focus.cjs.map +1 -1
  196. package/dist/lib/focus.mjs +5 -2
  197. package/dist/lib/focus.mjs.map +1 -1
  198. package/dist/lib/layers.cjs.map +1 -1
  199. package/dist/lib/layers.mjs.map +1 -1
  200. package/dist/lib/styles.cjs +1 -1
  201. package/dist/lib/styles.cjs.map +1 -1
  202. package/dist/lib/styles.mjs +21 -4
  203. package/dist/lib/styles.mjs.map +1 -1
  204. package/dist/styles.css +1 -1
  205. package/package.json +1 -1
  206. package/src/styles/tokens.css +13 -0
@@ -1,192 +1,273 @@
1
1
  "use client";
2
2
  import { cn as e } from "../../lib/cn.mjs";
3
- import { warnDeprecated as t } from "../../lib/dev.mjs";
4
- import { composeEventHandlers as n } from "../../lib/composeEventHandlers.mjs";
5
- import { comboboxClassNames as r } from "../../lib/classNames.mjs";
6
- import { useControllable as i } from "../../hooks/useControllable.mjs";
7
- import { useMergedRefs as a } from "../../hooks/useMergedRefs.mjs";
8
- import { useFieldContext as ee, useFieldControl as te } from "../../hooks/useFieldControl.mjs";
9
- import { disabledStyles as ne, inputBase as re, inputFocus as ie } from "../../lib/styles.mjs";
10
- import { DismissIcon as ae } from "../../lib/icons.mjs";
11
- import { isInvalidLook as oe } from "./Input.mjs";
12
- import { useFormReset as se } from "../../hooks/useFormReset.mjs";
13
- import { HiddenInput as ce } from "../internal/HiddenInput.mjs";
14
- import { collectOptionLabels as le, useListbox as ue } from "../../hooks/useListbox.mjs";
15
- import { pickerEndPadding as de } from "./pickerStyles.mjs";
16
- import { PickerExpandButton as fe, showsExpandButton as pe } from "./Combobox.expand.mjs";
17
- import { ListboxSurface as me, Option as o, OptionGroup as s, useListboxPopup as he } from "./Option.mjs";
3
+ import { warnDeprecated as t, warnOnce as n } from "../../lib/dev.mjs";
4
+ import { composeEventHandlers as r } from "../../lib/composeEventHandlers.mjs";
5
+ import { comboboxClassNames as i } from "../../lib/classNames.mjs";
6
+ import { useEventCallback as ee } from "../../hooks/useEventCallback.mjs";
7
+ import { useControllable as a } from "../../hooks/useControllable.mjs";
8
+ import { isFocused as te } from "../../lib/focus.mjs";
9
+ import { useMergedRefs as ne } from "../../hooks/useMergedRefs.mjs";
10
+ import { useFieldContext as re, useFieldControl as ie } from "../../hooks/useFieldControl.mjs";
11
+ import { collectOptionLabels as ae, useListbox as oe } from "../../hooks/useListbox.mjs";
12
+ import { disabledStyles as se, inputAppearanceClasses as ce, inputFocus as le, inputHeightClasses as ue, inputPaddingClasses as de, inputTextClasses as fe } from "../../lib/styles.mjs";
13
+ import { DismissIcon as pe } from "../../lib/icons.mjs";
14
+ import { useInputLook as me } from "./inputLook.mjs";
15
+ import { isInvalidLook as he } from "./Input.mjs";
16
+ import { useFormReset as ge } from "../../hooks/useFormReset.mjs";
17
+ import { HiddenInput as _e } from "../internal/HiddenInput.mjs";
18
+ import { pickerButtonOffset as ve, pickerEndPadding as ye, pickerGlyphSize as be, pickerIconButtonClasses as xe } from "./pickerStyles.mjs";
19
+ import { PickerExpandButton as Se, showsExpandButton as Ce } from "./Combobox.expand.mjs";
20
+ import { insertedText as we, replacedText as Te } from "./Combobox.text.mjs";
21
+ import { ListboxSurface as Ee, Option as o, OptionGroup as s, useListboxPopup as De } from "./Option.mjs";
22
+ import { PickerAnnouncer as Oe, announceToggle as ke, defaultSelectionLabel as Ae } from "./pickerLabels.mjs";
23
+ import { EMPTY_VALUES as je, resetValues as Me, toValues as Ne, toggleValue as Pe } from "./pickerValues.mjs";
18
24
  import * as c from "react";
19
- import { jsx as l, jsxs as u } from "react/jsx-runtime";
25
+ import { jsx as l, jsxs as Fe } from "react/jsx-runtime";
20
26
  //#region src/components/input/Combobox.tsx
21
- function ge(e, t) {
27
+ var u = /* @__PURE__ */ new Set(["historyUndo", "historyRedo"]);
28
+ function Ie(e, t) {
22
29
  return (e.textValue ?? e.label).toLowerCase().includes(t.toLowerCase());
23
30
  }
24
31
  var d = (o) => {
25
- let { value: s, defaultValue: d, onValueChange: f, onOptionSelect: p, open: m, defaultOpen: _e, onOpenChange: ve, placeholder: ye, disabled: h = !1, freeform: g = !1, name: be, form: _, required: v, autoComplete: xe = "off", autoCapitalize: Se, autoCorrect: Ce, maxLength: we, readOnly: y, clearable: Te = !1, expandIcon: b, labels: x, inputMode: Ee, spellCheck: De, enterKeyHint: S, autoFocus: C, tabIndex: w, id: T, "aria-label": E, "aria-labelledby": Oe, "aria-describedby": ke, "aria-invalid": Ae, "aria-required": je, "aria-errormessage": Me, "aria-details": Ne, onFocus: Pe, onBlur: Fe, onKeyDown: Ie, onKeyUp: Le, controlRef: Re, className: ze, children: D, ref: Be, ...Ve } = o;
32
+ let { multiselect: s = !1, value: d, defaultValue: f, onValueChange: Le, onOptionSelect: p, open: Re, defaultOpen: ze, onOpenChange: Be, placeholder: Ve, disabled: m = !1, size: He, appearance: Ue, freeform: We = !1, filter: Ge, query: Ke, defaultQuery: qe, onQueryChange: Je, onActiveOptionChange: Ye, disabledOptionsFocusable: Xe = !1, name: Ze, form: h, required: Qe, autoComplete: $e = "off", autoCapitalize: et, autoCorrect: tt, maxLength: nt, readOnly: g, clearable: rt = !1, expandIcon: it, labels: _, 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: v, ref: wt, ...Tt } = o;
26
33
  p !== void 0 && t("Combobox", "onOptionSelect", "onValueChange");
27
- let O = ee(), He = (v ?? O?.required ?? !1) && !y, k = te({
28
- id: T,
29
- "aria-label": E,
30
- "aria-labelledby": Oe,
31
- "aria-describedby": ke,
32
- "aria-invalid": Ae,
33
- "aria-required": je ?? v
34
- }), Ue = oe(!1, k["aria-invalid"]), [A, j] = i(s, d ?? "", f), M = !h && !y, [N, P] = i(m, (_e ?? !1) && M, ve), F = N && M, [I, L] = c.useState(null), [We, Ge] = c.useState(M);
35
- We !== M && (Ge(M), M || L(null));
36
- let R = !M && N;
34
+ let y = We && !s, Et = We && s;
37
35
  c.useEffect(() => {
38
- R && P(!1);
39
- }, [R, P]);
40
- let [Ke, z] = c.useState(null), B = c.useRef(null), V = c.useRef(null), qe = c.useMemo(() => le(D), [D]), Je = c.useMemo(() => I ? (e) => ge(e, I) : void 0, [I]), H = (e) => {
41
- z(e), j(e), p?.(e);
42
- }, U = () => {
43
- P(!1), L(null);
44
- }, W;
45
- g ? W = () => {
46
- L(null), H("");
47
- } : I && (W = () => L(null));
48
- let G = ue({
49
- open: F,
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 = y && (Ke !== void 0 || qe !== void 0);
39
+ c.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 b = re(), Ot = (Qe ?? b?.required ?? !1) && !g, x = ie({
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
+ }), kt = he(!1, x["aria-invalid"]), { size: S, appearance: C } = me(He, Ue), [At, w] = a(d, f ?? (s ? je : ""), (e) => {
50
+ Le?.(typeof e == "string" ? e : [...e]);
51
+ }), T = Ne(At), E = s ? "" : At, D = !m && !g, [O, k] = a(Re, (ze ?? !1) && D, Be), A = O && D, [jt, j] = a(y ? void 0 : Ke, D ? qe ?? "" : "", y ? void 0 : Je), [Mt, M] = c.useState(!1), [N, P] = c.useState(null), F = y ? N : D && (Mt || jt !== "") ? jt : null, [I, Nt] = c.useState(D ? "unlocked" : "mounted-locked");
52
+ D && I !== "unlocked" ? Nt("unlocked") : !D && I === "unlocked" && (Nt("locked"), M(!1), P(null)), c.useEffect(() => {
53
+ I === "locked" && j("");
54
+ }, [I, j]);
55
+ let Pt = !D && O;
56
+ c.useEffect(() => {
57
+ Pt && k(!1);
58
+ }, [Pt, k]);
59
+ let [Ft, L] = c.useState(null), It = c.useRef(null), R = c.useRef(null), Lt = c.useMemo(() => ae(v), [v]), z = F ?? "", Rt = c.useMemo(() => z ? (e) => (Ge ?? Ie)(e, z) : void 0, [z, Ge]), B = (e) => {
60
+ y ? P(e) : (M(!0), j(e));
61
+ }, V = () => {
62
+ y ? P(null) : (M(!1), j(""));
63
+ }, zt = (e) => {
64
+ L(e), w(e), p?.(e);
65
+ }, H = () => {
66
+ k(!1), V();
67
+ }, U;
68
+ y ? U = () => {
69
+ P(null), zt("");
70
+ } : F && (U = V);
71
+ let W = oe({
72
+ open: A,
50
73
  onOpenChange: (e) => {
51
- e ? P(!0) : U();
74
+ e ? k(!0) : H();
52
75
  },
53
76
  mode: "editable",
54
- selectedValues: A ? [A] : [],
55
- onSelect: (e) => {
56
- j(e), p?.(e), L(null), z(null);
77
+ multiselect: s,
78
+ disabledOptionsFocusable: Xe,
79
+ selectedValues: T,
80
+ onSelect: (e, t) => {
81
+ if (!s) {
82
+ w(e), p?.(e), V(), L(null);
83
+ return;
84
+ }
85
+ let { values: n, added: r } = Pe(T, e);
86
+ w(n), p?.(e), ke(_, t?.item.label ?? Lt.get(e) ?? e, r, n.length), V();
57
87
  },
58
- filter: Je,
59
- autoHighlight: !g && I ? "first" : !1,
88
+ filter: Rt,
89
+ autoHighlight: !y && F ? "first" : !1,
90
+ onActiveValueChange: Ye,
60
91
  idPrefix: "combobox-listbox",
61
- onClearDraft: W
62
- }), K = A ? G.getItem(A)?.label ?? qe.get(A) : void 0, q;
63
- q = g ? A === Ke ? A : K ?? A : I ?? K ?? "", g && I !== null && I !== q && L(q);
64
- let J = F && G.items.length > 0, Y = x?.noMatches ?? "No matches", X = F && (J || !!I), Ye = X && !J, { layerId: Xe, setReference: Ze, surfaceRef: Qe, floatingProps: $e } = he({
65
- open: F,
66
- surfaceOpen: X,
67
- onDismiss: U,
68
- rootRef: B,
69
- anchorRef: V
70
- }), Z = a(B, Be), et = a(V, Re, Ze);
71
- se(V, () => {
72
- j(d ?? ""), L(null), z(null);
73
- }, _);
74
- let tt = (e) => {
75
- if (e.key === "Escape" && F && !X && !e.nativeEvent.isComposing) {
76
- U(), W && e.currentTarget.value !== "" && (e.preventDefault(), W());
92
+ onClearDraft: U
93
+ }), Bt = (e) => W.getItem(e)?.label ?? Lt.get(e), G = "";
94
+ if (s) {
95
+ let e = T.map(Bt).filter((e) => e !== void 0);
96
+ e.length > 0 && (G = (_?.selection ?? Ae)(e));
97
+ }
98
+ let K = s && F === null && G !== "", Vt = E ? Bt(E) : void 0, q;
99
+ q = s ? F ?? G : y ? E === Ft ? E : Vt ?? E : F ?? Vt ?? "", y && N !== null && N !== q && P(q);
100
+ let J = A && W.items.length > 0, Ht = _?.noMatches ?? "No matches", Y = A && (J || !!F), Ut = Y && !J, { layerId: Wt, setReference: Gt, surfaceRef: Kt, floatingProps: qt } = De({
101
+ open: A,
102
+ surfaceOpen: Y,
103
+ onDismiss: H,
104
+ rootRef: It,
105
+ anchorRef: R
106
+ }), Jt = ne(It, wt), Yt = ne(R, St, Gt);
107
+ ge(R, () => {
108
+ w(s ? (e) => Me(e, f) : f ?? ""), V(), L(null);
109
+ }, h);
110
+ let X = c.useRef(!1), Xt = (e) => {
111
+ X.current = K && !te(e.currentTarget);
112
+ }, Zt = (e) => {
113
+ K && e.currentTarget.select();
114
+ }, Qt = (e) => {
115
+ X.current && (X.current = !1, e.preventDefault());
116
+ };
117
+ c.useLayoutEffect(() => {
118
+ let e = R.current;
119
+ K && e && te(e) && e.select();
120
+ }, [K, G]);
121
+ let Z = c.useRef(null), $t = c.useRef(null), Q = ee((e) => {
122
+ let t = e.currentTarget;
123
+ K && t.value === G && (Z.current = null, !u.has(e.inputType ?? "") && ($t.current = e, B(G), A || k(!0)));
124
+ });
125
+ c.useEffect(() => {
126
+ let e = R.current;
127
+ if (!s || !e) return;
128
+ let t = (t) => {
129
+ let { inputType: n } = t, { selectionStart: r, selectionEnd: i } = e;
130
+ Z.current = {
131
+ inputType: n,
132
+ range: n === "insertFromDrop" || u.has(n) || r === null || i === null ? null : [r, i]
133
+ };
134
+ };
135
+ return e.addEventListener("beforeinput", t), e.addEventListener("input", Q), () => {
136
+ e.removeEventListener("beforeinput", t), e.removeEventListener("input", Q);
137
+ };
138
+ }, [s, Q]);
139
+ let en = (e) => {
140
+ if (e.key === "Escape" && A && !Y && !e.nativeEvent.isComposing) {
141
+ H(), U && e.currentTarget.value !== "" && (e.preventDefault(), U());
77
142
  return;
78
143
  }
79
- G.onKeyDown(e);
80
- }, nt = (e) => {
81
- let t = e.target.value;
82
- L(t), F || P(!0), g && H(t);
83
- }, rt = () => {
84
- M && (F ? U() : P(!0), V.current?.focus());
85
- }, it = () => {
86
- j(""), z(null), L(null), P(!1), V.current?.focus();
87
- }, Q = pe(b), $ = Te && A !== "" && !y, at = k["aria-label"] === void 0 ? k["aria-labelledby"] ?? O?.labelId : k["aria-labelledby"];
88
- return /* @__PURE__ */ u("div", {
89
- ...Ve,
90
- ref: Z,
91
- className: e(r.root, "relative inline-flex flex-col", ze),
144
+ W.onKeyDown(e);
145
+ }, tn = (e) => {
146
+ if (e.nativeEvent === $t.current) return;
147
+ let t = e.target.value, n = Z.current;
148
+ Z.current = null;
149
+ let r = n && n.inputType === e.nativeEvent.inputType ? n : null;
150
+ if (!s) B(t);
151
+ else if (t === G && (r === null || u.has(r.inputType))) V();
152
+ else if (K) {
153
+ let e = r?.range;
154
+ B((e && Te(G, t, e[0], e[1])) ?? we(G, t));
155
+ } else B(t);
156
+ A || k(!0), y && zt(t);
157
+ }, nn = () => {
158
+ D && (A ? H() : k(!0), R.current?.focus());
159
+ }, rn = () => {
160
+ w(s ? je : ""), L(null), V(), k(!1), R.current?.focus();
161
+ }, $ = Ce(it), an = rt && (s ? T.length > 0 : E !== "") && !g, on = x["aria-label"] === void 0 ? x["aria-labelledby"] ?? b?.labelId : x["aria-labelledby"];
162
+ return /* @__PURE__ */ Fe("div", {
163
+ "data-size": S,
164
+ "data-appearance": C,
165
+ ...Tt,
166
+ ref: Jt,
167
+ className: e(i.root, "relative inline-flex flex-col", Ct),
92
168
  children: [
93
- /* @__PURE__ */ u("div", {
169
+ s && /* @__PURE__ */ l(Oe, {}),
170
+ /* @__PURE__ */ Fe("div", {
94
171
  className: "relative flex items-center",
95
172
  children: [
96
173
  /* @__PURE__ */ l("input", {
97
174
  type: "text",
98
- autoComplete: xe,
99
- ...k,
100
- ...G.getComboboxProps(),
175
+ autoComplete: $e,
176
+ ...x,
177
+ ...W.getComboboxProps(),
101
178
  "aria-expanded": J,
102
- "aria-errormessage": Me,
103
- "aria-details": Ne,
104
- ref: et,
105
- disabled: h,
106
- readOnly: y,
107
- placeholder: ye,
108
- autoCapitalize: Se,
109
- autoCorrect: Ce,
110
- maxLength: we,
111
- inputMode: Ee,
112
- spellCheck: De,
113
- enterKeyHint: S,
114
- autoFocus: C,
115
- tabIndex: w,
179
+ "aria-errormessage": gt,
180
+ "aria-details": _t,
181
+ ref: Yt,
182
+ disabled: m,
183
+ readOnly: g,
184
+ placeholder: s && G !== "" ? void 0 : Ve,
185
+ autoCapitalize: et,
186
+ autoCorrect: tt,
187
+ maxLength: K ? void 0 : nt,
188
+ inputMode: at,
189
+ spellCheck: ot,
190
+ enterKeyHint: st,
191
+ autoFocus: ct,
192
+ tabIndex: lt,
116
193
  value: q,
117
- onChange: nt,
194
+ onChange: tn,
118
195
  onClick: () => {
119
- !F && M && P(!0);
196
+ !A && D && k(!0);
120
197
  },
121
- onKeyDown: n(Ie, y ? void 0 : tt),
122
- onKeyUp: n(Le, G.onKeyUp),
123
- onFocus: Pe,
124
- onBlur: n(Fe, () => L(null), { checkDefaultPrevented: !1 }),
125
- className: e(r.input, re, "border-b-stroke-accessible", ie, ne, Ue && "border-destructive focus:border-b-destructive", de(Number($) + Number(Q)))
198
+ onMouseDown: Xt,
199
+ onMouseUp: Qt,
200
+ onKeyDown: r(bt, g ? void 0 : en),
201
+ onKeyUp: r(xt, W.onKeyUp),
202
+ onFocus: r(vt, Zt),
203
+ onBlur: r(yt, V, { checkDefaultPrevented: !1 }),
204
+ className: e(i.input, ue[S], "w-full", de[S], fe[S], ce[C], "text-foreground placeholder:text-muted-foreground", le, se, kt && "border-destructive", ye(Number(an) + Number($), S))
126
205
  }),
127
- $ && /* @__PURE__ */ l("button", {
206
+ an && /* @__PURE__ */ l("button", {
128
207
  type: "button",
129
- "aria-label": x?.clear ?? "Clear selection",
130
- disabled: h,
208
+ "aria-label": _?.clear ?? "Clear selection",
209
+ disabled: m,
131
210
  onMouseDown: (e) => e.preventDefault(),
132
- onClick: it,
133
- className: e(r.clearButton, "absolute flex h-6 w-6 items-center justify-center rounded bg-transparent p-0 text-muted-foreground not-disabled:not-aria-disabled:hover:bg-subtle-hover not-disabled:not-aria-disabled:hover:text-foreground", Q ? "end-7" : "end-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"),
134
- children: /* @__PURE__ */ l(ae, {})
211
+ onClick: rn,
212
+ className: e(i.clearButton, xe(S, C), ve(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"),
213
+ children: /* @__PURE__ */ l(pe, { size: be(S, "icon") })
135
214
  }),
136
- Q && /* @__PURE__ */ l(fe, {
215
+ $ && /* @__PURE__ */ l(Se, {
137
216
  component: "Combobox",
138
- expandIcon: b,
139
- label: x?.expand ?? "Show options",
217
+ expandIcon: it,
218
+ label: _?.expand ?? "Show options",
140
219
  expanded: J,
141
- listboxId: G.listboxId,
142
- disabled: h || !!y,
143
- onToggle: rt,
144
- className: r.expandButton,
145
- iconClassName: r.expandIcon
220
+ listboxId: W.listboxId,
221
+ disabled: m || !!g,
222
+ onToggle: nn,
223
+ size: S,
224
+ appearance: C,
225
+ className: i.expandButton,
226
+ iconClassName: i.expandIcon
146
227
  })
147
228
  ]
148
229
  }),
149
230
  /* @__PURE__ */ l("span", {
150
231
  role: "status",
151
232
  className: "sr-only",
152
- children: Ye && Y
233
+ children: Ut && Ht
153
234
  }),
154
- /* @__PURE__ */ l(me, {
155
- listbox: G,
156
- layerId: Xe,
157
- surfaceRef: Qe,
158
- floatingProps: $e,
159
- open: F,
235
+ /* @__PURE__ */ l(Ee, {
236
+ listbox: W,
237
+ layerId: Wt,
238
+ surfaceRef: Kt,
239
+ floatingProps: qt,
240
+ open: A,
160
241
  expanded: J,
161
- listboxClassName: r.listbox,
162
- surfaceClassName: r.surface,
163
- emptyContent: I ? /* @__PURE__ */ l("div", {
242
+ listClassName: i.listbox,
243
+ surfaceClassName: i.surface,
244
+ emptyContent: F ? /* @__PURE__ */ l("div", {
164
245
  "aria-hidden": "true",
165
- className: e(r.emptyMessage, "px-3 py-1.5 text-body-1 text-muted-foreground"),
166
- children: Y
246
+ className: e(i.emptyMessage, "px-3 py-1.5 text-body-1 text-muted-foreground"),
247
+ children: Ht
167
248
  }) : void 0,
168
- "aria-label": k["aria-label"],
169
- "aria-labelledby": at,
170
- children: D
249
+ "aria-label": x["aria-label"],
250
+ "aria-labelledby": on,
251
+ children: v
171
252
  }),
172
- /* @__PURE__ */ l(ce, {
173
- name: be,
174
- form: _,
175
- disabled: h,
176
- value: A,
253
+ /* @__PURE__ */ l(_e, {
254
+ name: Ze,
255
+ form: h,
256
+ disabled: m,
257
+ value: s ? T : E,
177
258
  type: "text",
178
- required: He,
179
- onInvalid: () => V.current?.focus()
259
+ required: Ot,
260
+ onInvalid: () => R.current?.focus()
180
261
  })
181
262
  ]
182
263
  });
183
264
  };
184
265
  d.displayName = "Combobox";
185
- var f = o, p = s, m = /* @__PURE__ */ Object.assign(d, {
266
+ var f = o, Le = s, p = /* @__PURE__ */ Object.assign(d, {
186
267
  Option: o,
187
268
  OptionGroup: s
188
269
  });
189
270
  //#endregion
190
- export { m as Combobox, f as ComboboxOption, p as ComboboxOptionGroup, o as Option, s as OptionGroup };
271
+ export { p as Combobox, f as ComboboxOption, Le as ComboboxOptionGroup, o as Option, s as OptionGroup };
191
272
 
192
273
  //# sourceMappingURL=Combobox.mjs.map