@mortenbrudvik/waveui 0.11.0 → 0.12.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 (116) hide show
  1. package/README.md +97 -2
  2. package/dist/components/button/Link.cjs +1 -1
  3. package/dist/components/button/Link.cjs.map +1 -1
  4. package/dist/components/button/Link.mjs +4 -4
  5. package/dist/components/data-display/AvatarGroup.cjs +1 -1
  6. package/dist/components/data-display/AvatarGroup.cjs.map +1 -1
  7. package/dist/components/data-display/AvatarGroup.mjs +10 -10
  8. package/dist/components/data-display/InfoButton.cjs +1 -1
  9. package/dist/components/data-display/InfoButton.cjs.map +1 -1
  10. package/dist/components/data-display/InfoButton.mjs +12 -12
  11. package/dist/components/feedback/Toaster.cjs +1 -1
  12. package/dist/components/feedback/Toaster.cjs.map +1 -1
  13. package/dist/components/feedback/Toaster.mjs +235 -235
  14. package/dist/components/feedback/Toaster.mjs.map +1 -1
  15. package/dist/components/input/Combobox.cjs +1 -1
  16. package/dist/components/input/Combobox.cjs.map +1 -1
  17. package/dist/components/input/Combobox.mjs +176 -175
  18. package/dist/components/input/Combobox.mjs.map +1 -1
  19. package/dist/components/input/DatePicker.cjs +1 -1
  20. package/dist/components/input/DatePicker.cjs.map +1 -1
  21. package/dist/components/input/DatePicker.mjs +188 -187
  22. package/dist/components/input/DatePicker.mjs.map +1 -1
  23. package/dist/components/input/Dropdown.cjs +1 -1
  24. package/dist/components/input/Dropdown.cjs.map +1 -1
  25. package/dist/components/input/Dropdown.mjs +41 -40
  26. package/dist/components/input/Dropdown.mjs.map +1 -1
  27. package/dist/components/input/Option.cjs +1 -1
  28. package/dist/components/input/Option.cjs.map +1 -1
  29. package/dist/components/input/Option.mjs +89 -87
  30. package/dist/components/input/Option.mjs.map +1 -1
  31. package/dist/components/input/TagPicker.root.cjs +1 -1
  32. package/dist/components/input/TagPicker.root.cjs.map +1 -1
  33. package/dist/components/input/TagPicker.root.mjs +136 -135
  34. package/dist/components/input/TagPicker.root.mjs.map +1 -1
  35. package/dist/components/input/TimePicker.cjs +1 -1
  36. package/dist/components/input/TimePicker.cjs.map +1 -1
  37. package/dist/components/input/TimePicker.mjs +156 -154
  38. package/dist/components/input/TimePicker.mjs.map +1 -1
  39. package/dist/components/navigation/Menu.popover.cjs +1 -1
  40. package/dist/components/navigation/Menu.popover.cjs.map +1 -1
  41. package/dist/components/navigation/Menu.popover.mjs +137 -127
  42. package/dist/components/navigation/Menu.popover.mjs.map +1 -1
  43. package/dist/components/navigation/Menu.root.cjs +1 -1
  44. package/dist/components/navigation/Menu.root.cjs.map +1 -1
  45. package/dist/components/navigation/Menu.root.mjs +4 -4
  46. package/dist/components/overlays/Dialog.cjs +1 -1
  47. package/dist/components/overlays/Dialog.cjs.map +1 -1
  48. package/dist/components/overlays/Dialog.mjs +123 -123
  49. package/dist/components/overlays/Dialog.mjs.map +1 -1
  50. package/dist/components/overlays/Drawer.panel.cjs +1 -1
  51. package/dist/components/overlays/Drawer.panel.cjs.map +1 -1
  52. package/dist/components/overlays/Drawer.panel.mjs +12 -12
  53. package/dist/components/overlays/Drawer.panel.mjs.map +1 -1
  54. package/dist/components/overlays/Popover.cjs +1 -1
  55. package/dist/components/overlays/Popover.cjs.map +1 -1
  56. package/dist/components/overlays/Popover.mjs +173 -162
  57. package/dist/components/overlays/Popover.mjs.map +1 -1
  58. package/dist/components/overlays/TeachingPopover.cjs +1 -1
  59. package/dist/components/overlays/TeachingPopover.cjs.map +1 -1
  60. package/dist/components/overlays/TeachingPopover.mjs +96 -91
  61. package/dist/components/overlays/TeachingPopover.mjs.map +1 -1
  62. package/dist/components/overlays/Tooltip.cjs +1 -1
  63. package/dist/components/overlays/Tooltip.cjs.map +1 -1
  64. package/dist/components/overlays/Tooltip.mjs +47 -47
  65. package/dist/components/overlays/Tooltip.mjs.map +1 -1
  66. package/dist/components/portal/Portal.cjs +1 -1
  67. package/dist/components/portal/Portal.cjs.map +1 -1
  68. package/dist/components/portal/Portal.mjs +5 -5
  69. package/dist/components/table/DataGrid.cjs +1 -1
  70. package/dist/components/table/DataGrid.cjs.map +1 -1
  71. package/dist/components/table/DataGrid.mjs +1 -1
  72. package/dist/hooks/useDismiss.cjs.map +1 -1
  73. package/dist/hooks/useDismiss.mjs.map +1 -1
  74. package/dist/hooks/useFocusTrap.cjs.map +1 -1
  75. package/dist/hooks/useFocusTrap.mjs.map +1 -1
  76. package/dist/hooks/useFocusVisible.cjs +2 -0
  77. package/dist/hooks/useFocusVisible.cjs.map +1 -0
  78. package/dist/hooks/useFocusVisible.mjs +49 -0
  79. package/dist/hooks/useFocusVisible.mjs.map +1 -0
  80. package/dist/hooks/useFocusableGroup.cjs +2 -0
  81. package/dist/hooks/useFocusableGroup.cjs.map +1 -0
  82. package/dist/hooks/useFocusableGroup.mjs +70 -0
  83. package/dist/hooks/useFocusableGroup.mjs.map +1 -0
  84. package/dist/hooks/useModalLayer.cjs +1 -1
  85. package/dist/hooks/useModalLayer.cjs.map +1 -1
  86. package/dist/hooks/useModalLayer.mjs +4 -4
  87. package/dist/hooks/useModalOpen.cjs +2 -0
  88. package/dist/hooks/useModalOpen.cjs.map +1 -0
  89. package/dist/hooks/useModalOpen.mjs +14 -0
  90. package/dist/hooks/useModalOpen.mjs.map +1 -0
  91. package/dist/hooks/usePopupPosition.cjs +1 -1
  92. package/dist/hooks/usePopupPosition.cjs.map +1 -1
  93. package/dist/hooks/usePopupPosition.mjs +82 -53
  94. package/dist/hooks/usePopupPosition.mjs.map +1 -1
  95. package/dist/hooks/useResolvedTarget.cjs +2 -0
  96. package/dist/hooks/useResolvedTarget.cjs.map +1 -0
  97. package/dist/hooks/useResolvedTarget.mjs +37 -0
  98. package/dist/hooks/useResolvedTarget.mjs.map +1 -0
  99. package/dist/hooks/useRovingGrid.cjs +1 -1
  100. package/dist/hooks/useRovingGrid.cjs.map +1 -1
  101. package/dist/hooks/useRovingGrid.mjs +8 -57
  102. package/dist/hooks/useRovingGrid.mjs.map +1 -1
  103. package/dist/hooks/useRovingTabIndex.cjs +1 -1
  104. package/dist/hooks/useRovingTabIndex.cjs.map +1 -1
  105. package/dist/hooks/useRovingTabIndex.mjs +142 -107
  106. package/dist/hooks/useRovingTabIndex.mjs.map +1 -1
  107. package/dist/index.cjs +1 -1
  108. package/dist/index.d.cts +814 -18
  109. package/dist/index.d.ts +814 -18
  110. package/dist/index.mjs +120 -108
  111. package/dist/lib/layers.cjs +1 -1
  112. package/dist/lib/layers.cjs.map +1 -1
  113. package/dist/lib/layers.mjs +112 -109
  114. package/dist/lib/layers.mjs.map +1 -1
  115. package/dist/styles.css +1 -1
  116. package/package.json +1 -1
@@ -7,29 +7,29 @@ import { isSameDay as ee, startOfDay as a } from "../../lib/date.mjs";
7
7
  import { useControllable as o } from "../../hooks/useControllable.mjs";
8
8
  import { useId as s } from "../../hooks/useId.mjs";
9
9
  import { FOCUSABLE_SELECTOR as te } from "../../lib/focus.mjs";
10
- import { useMergedRefs as ne } from "../../hooks/useMergedRefs.mjs";
11
- import { useIsClient as re } from "../../hooks/useIsClient.mjs";
12
- import { joinIds as ie } from "../../lib/aria.mjs";
13
- import { useFieldContext as ae, useFieldControl as oe } from "../../hooks/useFieldControl.mjs";
14
- import { useDismiss as se } from "../../hooks/useDismiss.mjs";
15
- import { Portal as ce } from "../portal/Portal.mjs";
16
- import { disabledStyles as le, focusRing as ue, inputAppearanceClasses as de, inputFocus as fe, inputHeightClasses as pe, inputPaddingClasses as me, inputTextClasses as he } from "../../lib/styles.mjs";
17
- import { CalendarIcon as ge, DismissIcon as _e } from "../../lib/icons.mjs";
18
- import { useInputLook as ve } from "./inputLook.mjs";
19
- import { isInvalidLook as ye } from "./Input.mjs";
20
- import { useFormReset as be } from "../../hooks/useFormReset.mjs";
21
- import { HiddenInput as xe } from "../internal/HiddenInput.mjs";
22
- import { pickerButtonOffset as c, pickerEndPadding as Se, pickerGlyphSize as l, pickerIconButtonClasses as u } from "./pickerStyles.mjs";
23
- import { usePopupPosition as Ce } from "../../hooks/usePopupPosition.mjs";
24
- import { formatDate as we, formatISODate as d, getLocaleDateFormat as Te, isDateInRange as Ee, isValidLocaleTag as De, parseDate as Oe } from "./dateUtils.mjs";
25
- import { useFocusTrap as ke } from "../../hooks/useFocusTrap.mjs";
26
- import { useRestoreFocus as Ae } from "../../hooks/useRestoreFocus.mjs";
27
- import { CalendarView as je } from "./Calendar.mjs";
28
- import * as f from "react";
29
- import { jsx as p, jsxs as m } from "react/jsx-runtime";
30
- import { flushSync as Me } from "react-dom";
10
+ import { useMergedRefs as c } from "../../hooks/useMergedRefs.mjs";
11
+ import { useIsClient as ne } from "../../hooks/useIsClient.mjs";
12
+ import { joinIds as re } from "../../lib/aria.mjs";
13
+ import { useFieldContext as ie, useFieldControl as ae } from "../../hooks/useFieldControl.mjs";
14
+ import { resolvePositioning as oe, usePopupPosition as se } from "../../hooks/usePopupPosition.mjs";
15
+ import { useDismiss as ce } from "../../hooks/useDismiss.mjs";
16
+ import { useFocusTrap as le } from "../../hooks/useFocusTrap.mjs";
17
+ import { useRestoreFocus as ue } from "../../hooks/useRestoreFocus.mjs";
18
+ import { disabledStyles as de, focusRing as fe, inputAppearanceClasses as pe, inputFocus as me, inputHeightClasses as he, inputPaddingClasses as ge, inputTextClasses as _e } from "../../lib/styles.mjs";
19
+ import { Portal as ve } from "../portal/Portal.mjs";
20
+ import { CalendarIcon as ye, DismissIcon as be } from "../../lib/icons.mjs";
21
+ import { useInputLook as xe } from "./inputLook.mjs";
22
+ import { isInvalidLook as Se } from "./Input.mjs";
23
+ import { useFormReset as Ce } from "../../hooks/useFormReset.mjs";
24
+ import { HiddenInput as we } from "../internal/HiddenInput.mjs";
25
+ import { pickerButtonOffset as Te, pickerEndPadding as Ee, pickerGlyphSize as De, pickerIconButtonClasses as Oe } from "./pickerStyles.mjs";
26
+ import { formatDate as ke, formatISODate as Ae, getLocaleDateFormat as je, isDateInRange as Me, isValidLocaleTag as Ne, parseDate as Pe } from "./dateUtils.mjs";
27
+ import { CalendarView as Fe } from "./Calendar.mjs";
28
+ import * as l from "react";
29
+ import { jsx as u, jsxs as d } from "react/jsx-runtime";
30
+ import { flushSync as Ie } from "react-dom";
31
31
  //#region src/components/input/DatePicker.tsx
32
- var Ne = (e) => e ? `Enter a date in the format ${e}.` : "Enter a valid date.", Pe = (e, t) => e !== void 0 && t !== void 0 ? `Enter a date between ${e} and ${t}.` : e === void 0 ? `Enter a date on or before ${t}.` : `Enter a date on or after ${e}.`, Fe = {
32
+ var Le = (e) => e ? `Enter a date in the format ${e}.` : "Enter a valid date.", Re = (e, t) => e !== void 0 && t !== void 0 ? `Enter a date between ${e} and ${t}.` : e === void 0 ? `Enter a date on or before ${t}.` : `Enter a date on or after ${e}.`, ze = {
33
33
  header: i.header,
34
34
  previousMonthButton: i.previousMonthButton,
35
35
  heading: i.heading,
@@ -46,215 +46,216 @@ var Ne = (e) => e ? `Enter a date in the format ${e}.` : "Enter a valid date.",
46
46
  footer: i.footer,
47
47
  todayButton: i.todayButton,
48
48
  closeButton: i.closeButton
49
- }, h = (h) => {
50
- let { value: Ie, defaultValue: Le, onValueChange: Re, onChange: g, formatDate: _, parseDate: v, locale: y, minDate: b, maxDate: x, disabledDates: S, placeholder: ze = "Select a date", disabled: C = !1, size: Be, appearance: Ve, readOnly: w, clearable: He = !1, firstDayOfWeek: Ue = 0, today: We, initialVisibleDate: Ge, showMonthPicker: Ke, showWeekNumbers: qe, firstWeekOfYear: Je, showGoToToday: Ye, showCloseButton: Xe = !1, markedDates: Ze, renderDay: Qe, dayLabel: $e, open: T, defaultOpen: et, onOpenChange: tt, onInvalidInput: nt, labels: E, name: rt, form: it, required: at, autoComplete: ot = "off", autoCapitalize: st, autoCorrect: ct, enterKeyHint: lt, inputMode: ut, spellCheck: dt, autoFocus: ft, tabIndex: pt, id: mt, "aria-label": ht, "aria-labelledby": gt, "aria-describedby": _t, "aria-invalid": vt, "aria-required": yt, "aria-errormessage": bt, "aria-details": xt, onFocus: St, onBlur: Ct, onKeyDown: wt, onKeyUp: Tt, controlRef: Et, className: Dt, ref: Ot, ...kt } = h;
51
- g !== void 0 && t("DatePicker", "onChange", "onValueChange");
52
- let { size: D, appearance: O } = ve(Be, Ve), k = _ !== void 0, A = v !== void 0;
53
- f.useEffect(() => {
54
- k && !A && n("DatePicker:formatDate-without-parseDate", "DatePicker: `formatDate` is set without `parseDate`. Typed dates are parsed with the default parser for `locale` (its numeric format or yyyy-mm-dd), which may not read your format; pass `parseDate` as the inverse of `formatDate`.");
55
- }, [k, A]), f.useEffect(() => {
56
- y !== void 0 && !De(y) && n(`DatePicker:invalid-locale:${y}`, `DatePicker: \`locale\` "${y}" is not a valid BCP 47 language tag (use hyphens, as in "en-US"). The runtime default locale formats and parses the dates instead, so the server and the browser may render different text.`);
57
- }, [y]);
58
- let [j, At] = o(Ie, Le ?? null, (e) => {
59
- Re?.(e), g?.(e);
60
- }), M = !C && !w, [N, P] = o(T, (et ?? !1) && M, tt), jt = re(), F = N && M && jt, Mt = T !== void 0;
61
- f.useEffect(() => {
62
- !M && N && !Mt && P(!1);
49
+ }, f = (f) => {
50
+ let { value: Be, defaultValue: p, onValueChange: Ve, onChange: m, formatDate: h, parseDate: g, locale: _, minDate: v, maxDate: y, disabledDates: b, placeholder: He = "Select a date", disabled: x = !1, size: Ue, positioning: We, appearance: Ge, readOnly: S, clearable: Ke = !1, firstDayOfWeek: qe = 0, today: Je, initialVisibleDate: Ye, showMonthPicker: Xe, showWeekNumbers: Ze, firstWeekOfYear: Qe, showGoToToday: $e, showCloseButton: et = !1, markedDates: tt, renderDay: nt, dayLabel: rt, open: C, defaultOpen: it, onOpenChange: at, onInvalidInput: ot, labels: w, name: st, form: T, required: E, autoComplete: ct = "off", autoCapitalize: lt, autoCorrect: ut, enterKeyHint: dt, inputMode: ft, spellCheck: pt, autoFocus: mt, tabIndex: ht, id: gt, "aria-label": _t, "aria-labelledby": vt, "aria-describedby": yt, "aria-invalid": bt, "aria-required": xt, "aria-errormessage": St, "aria-details": Ct, onFocus: wt, onBlur: Tt, onKeyDown: Et, onKeyUp: Dt, controlRef: Ot, className: kt, ref: At, ...jt } = f;
51
+ m !== void 0 && t("DatePicker", "onChange", "onValueChange");
52
+ let { size: D, appearance: O } = xe(Ue, Ge), Mt = h !== void 0, k = g !== void 0;
53
+ l.useEffect(() => {
54
+ Mt && !k && n("DatePicker:formatDate-without-parseDate", "DatePicker: `formatDate` is set without `parseDate`. Typed dates are parsed with the default parser for `locale` (its numeric format or yyyy-mm-dd), which may not read your format; pass `parseDate` as the inverse of `formatDate`.");
55
+ }, [Mt, k]), l.useEffect(() => {
56
+ _ !== void 0 && !Ne(_) && n(`DatePicker:invalid-locale:${_}`, `DatePicker: \`locale\` "${_}" is not a valid BCP 47 language tag (use hyphens, as in "en-US"). The runtime default locale formats and parses the dates instead, so the server and the browser may render different text.`);
57
+ }, [_]);
58
+ let [A, Nt] = o(Be, p ?? null, (e) => {
59
+ Ve?.(e), m?.(e);
60
+ }), j = !x && !S, [M, N] = o(C, (it ?? !1) && j, at), Pt = ne(), P = M && j && Pt, Ft = C !== void 0;
61
+ l.useEffect(() => {
62
+ !j && M && !Ft && N(!1);
63
63
  }, [
64
+ j,
64
65
  M,
65
- N,
66
- Mt,
67
- P
66
+ Ft,
67
+ N
68
68
  ]);
69
- let I = (e) => _ ? _(e) : we(e, y), Nt = (e) => v ? v(e) : Oe(e, y), [L, R] = f.useState(null), [z, B] = f.useState(null), [Pt, Ft] = f.useState(M);
70
- Pt !== M && (Ft(M), M || (R(null), B(null)));
71
- let V = j ? d(j) : "", [It, Lt] = f.useState(V);
72
- It !== V && (Lt(V), z !== null && (R(null), B(null)));
73
- let H = (e) => {
69
+ let F = (e) => h ? h(e) : ke(e, _), It = (e) => g ? g(e) : Pe(e, _), [I, L] = l.useState(null), [R, z] = l.useState(null), [Lt, Rt] = l.useState(j);
70
+ Lt !== j && (Rt(j), j || (L(null), z(null)));
71
+ let B = A ? Ae(A) : "", [zt, Bt] = l.useState(B);
72
+ zt !== B && (Bt(B), R !== null && (L(null), z(null)));
73
+ let V = (e) => {
74
74
  let t = e ? a(e) : null;
75
- (t ? ee(t, j) : j === null) || At(t), R(null), B(null);
76
- }, U = (e) => {
77
- if (!e.trim()) return H(null), !0;
78
- let t = Nt(e), n = null;
79
- if (!t || Number.isNaN(t.getTime()) ? n = "unparseable" : Ee(t, b, x) ? S?.(a(t)) && (n = "disabled") : n = "out-of-range", n || !t) {
75
+ (t ? ee(t, A) : A === null) || Nt(t), L(null), z(null);
76
+ }, H = (e) => {
77
+ if (!e.trim()) return V(null), !0;
78
+ let t = It(e), n = null;
79
+ if (!t || Number.isNaN(t.getTime()) ? n = "unparseable" : Me(t, v, y) ? b?.(a(t)) && (n = "disabled") : n = "out-of-range", n || !t) {
80
80
  let t = n ?? "unparseable";
81
- return B(t), nt?.(e, t), !1;
81
+ return z(t), ot?.(e, t), !1;
82
82
  }
83
- return H(t), !0;
84
- }, [W, G] = f.useState(!1);
85
- W && !F && G(!1);
86
- let K = f.useRef(null), q = f.useRef(null), J = f.useRef(null), Y = f.useRef(null), [Rt, zt] = f.useState(null), Bt = ne(Et, K), Vt = s("datepicker-dialog"), Ht = s("datepicker-heading"), X = s("datepicker-error"), Z = (e) => {
87
- Y.current = e, P(!1);
88
- }, { layerId: Ut } = se({
89
- open: F,
83
+ return V(t), !0;
84
+ }, [U, W] = l.useState(!1);
85
+ U && !P && W(!1);
86
+ let G = l.useRef(null), K = l.useRef(null), q = l.useRef(null), J = l.useRef(null), [Vt, Ht] = l.useState(null), Ut = c(Ot, G), Y = s("datepicker-dialog"), Wt = s("datepicker-heading"), Gt = s("datepicker-error"), X = (e) => {
87
+ J.current = e, N(!1);
88
+ }, { layerId: Kt } = ce({
89
+ open: P,
90
90
  onDismiss: (e, t) => {
91
91
  let n = e === "outside-press" && t.target instanceof Element ? t.target.closest(te) : null;
92
- Z(n ?? (W ? K.current : null));
92
+ X(n ?? (U ? G.current : null));
93
93
  },
94
- refs: [J, q],
95
- anchorRef: q,
94
+ refs: [q, K],
95
+ anchorRef: K,
96
96
  kind: "modal"
97
- }), { setReference: Wt, setFloating: Gt, floatingProps: Kt } = Ce({
98
- open: F,
97
+ }), { setReference: qt, setFloating: Jt, floatingProps: Yt } = se({
98
+ open: P,
99
99
  side: "bottom",
100
- align: "start"
101
- }), qt = ne(J, zt, Gt);
102
- ke(Rt, {
103
- enabled: F,
104
- layerId: Ut,
105
- initialFocus: () => J.current?.querySelector("[data-wave-calendar-grid] button[tabindex=\"0\"]") ?? null
106
- }), Ae({
107
- enabled: F,
108
- container: Rt,
109
- triggerRef: q,
110
- finalFocusRef: Y,
100
+ align: "start",
101
+ ...oe(We, {})
102
+ }), Xt = c(q, Ht, Jt);
103
+ le(Vt, {
104
+ enabled: P,
105
+ layerId: Kt,
106
+ initialFocus: () => q.current?.querySelector("[data-wave-calendar-grid] button[tabindex=\"0\"]") ?? null
107
+ }), ue({
108
+ enabled: P,
109
+ container: Vt,
110
+ triggerRef: K,
111
+ finalFocusRef: J,
111
112
  onlyIfFocusInside: !0
112
- }), f.useLayoutEffect(() => {
113
- F && (Y.current = null);
114
- }, [F]);
115
- let Jt = ae(), Yt = (at ?? Jt?.required ?? !1) && !w, Xt = z !== null && !Jt?.hasErrorMessage, Zt = oe({
116
- id: mt,
117
- "aria-label": ht,
118
- "aria-labelledby": gt,
119
- "aria-describedby": ie(_t, Xt ? X : void 0),
120
- "aria-invalid": z !== null || vt,
121
- "aria-required": yt ?? at
122
- }), Qt = ye(!1, Zt["aria-invalid"]);
123
- be(K, () => H(Le ?? null), it);
124
- let Q = He && !w && j !== null, $t = (e) => {
125
- M && (R(e.target.value), B(null));
126
- }, en = r(wt, (e) => {
127
- M && !e.nativeEvent.isComposing && (e.key === "Enter" && L !== null ? (e.preventDefault(), U(L)) : e.key === "Tab" && !e.shiftKey && Q && L !== null && !L.trim() ? Me(() => U(L)) : e.key === "ArrowDown" && e.altKey && !F && (e.preventDefault(), L !== null && z === null && U(L), G(!0), P(!0)));
128
- }), tn = r(Ct, () => {
129
- M && L !== null && z === null && U(L);
130
- }), nn = () => {
131
- M && (Y.current = null, G(!1), P(!F));
132
- }, rn = () => {
133
- M && (H(null), K.current?.focus());
134
- }, an = (e) => {
113
+ }), l.useLayoutEffect(() => {
114
+ P && (J.current = null);
115
+ }, [P]);
116
+ let Zt = ie(), Qt = (E ?? Zt?.required ?? !1) && !S, $t = R !== null && !Zt?.hasErrorMessage, en = ae({
117
+ id: gt,
118
+ "aria-label": _t,
119
+ "aria-labelledby": vt,
120
+ "aria-describedby": re(yt, $t ? Gt : void 0),
121
+ "aria-invalid": R !== null || bt,
122
+ "aria-required": xt ?? E
123
+ }), tn = Se(!1, en["aria-invalid"]);
124
+ Ce(G, () => V(p ?? null), T);
125
+ let Z = Ke && !S && A !== null, nn = (e) => {
126
+ j && (L(e.target.value), z(null));
127
+ }, rn = r(Et, (e) => {
128
+ j && !e.nativeEvent.isComposing && (e.key === "Enter" && I !== null ? (e.preventDefault(), H(I)) : e.key === "Tab" && !e.shiftKey && Z && I !== null && !I.trim() ? Ie(() => H(I)) : e.key === "ArrowDown" && e.altKey && !P && (e.preventDefault(), I !== null && R === null && H(I), W(!0), N(!0)));
129
+ }), an = r(Tt, () => {
130
+ j && I !== null && R === null && H(I);
131
+ }), on = () => {
132
+ j && (J.current = null, W(!1), N(!P));
133
+ }, sn = () => {
134
+ j && (V(null), G.current?.focus());
135
+ }, cn = (e) => {
135
136
  e.preventDefault();
136
- }, on = (e) => {
137
- M && (H(e), Z(K.current));
138
- }, sn = () => Z(W ? K.current : null), cn = (e) => {
139
- e.key !== "Escape" || e.defaultPrevented || e.nativeEvent.isComposing || (e.preventDefault(), sn());
140
- }, ln = L ?? (j ? I(j) : ""), $ = "";
141
- return z === "unparseable" ? $ = (E?.invalidDate ?? Ne)(A ? void 0 : Te(y).pattern) : z === "out-of-range" && (b || x) ? $ = (E?.outOfRange ?? Pe)(b ? I(a(b)) : void 0, x ? I(a(x)) : void 0) : z === "disabled" && ($ = E?.unavailableDate ?? "This date is not available."), /* @__PURE__ */ m("div", {
137
+ }, ln = (e) => {
138
+ j && (V(e), X(G.current));
139
+ }, Q = () => X(U ? G.current : null), un = (e) => {
140
+ e.key !== "Escape" || e.defaultPrevented || e.nativeEvent.isComposing || (e.preventDefault(), Q());
141
+ }, dn = I ?? (A ? F(A) : ""), $ = "";
142
+ return R === "unparseable" ? $ = (w?.invalidDate ?? Le)(k ? void 0 : je(_).pattern) : R === "out-of-range" && (v || y) ? $ = (w?.outOfRange ?? Re)(v ? F(a(v)) : void 0, y ? F(a(y)) : void 0) : R === "disabled" && ($ = w?.unavailableDate ?? "This date is not available."), /* @__PURE__ */ d("div", {
142
143
  "data-size": D,
143
144
  "data-appearance": O,
144
- ...kt,
145
- ref: Ot,
146
- className: e(i.root, "relative inline-flex flex-col", Dt),
145
+ ...jt,
146
+ ref: At,
147
+ className: e(i.root, "relative inline-flex flex-col", kt),
147
148
  children: [
148
- /* @__PURE__ */ m("div", {
149
- ref: Wt,
149
+ /* @__PURE__ */ d("div", {
150
+ ref: qt,
150
151
  className: "relative flex items-center",
151
152
  children: [
152
- /* @__PURE__ */ p("input", {
153
- ref: Bt,
153
+ /* @__PURE__ */ u("input", {
154
+ ref: Ut,
154
155
  type: "text",
155
- ...Zt,
156
- "aria-errormessage": bt,
157
- "aria-details": xt,
158
- value: ln,
159
- onChange: $t,
160
- onFocus: St,
161
- onBlur: tn,
162
- onKeyDown: en,
163
- onKeyUp: Tt,
164
- placeholder: ze,
165
- disabled: C,
166
- readOnly: w,
167
- autoComplete: ot,
168
- autoCapitalize: st,
169
- autoCorrect: ct,
170
- enterKeyHint: lt,
171
- inputMode: ut,
172
- spellCheck: dt,
173
- autoFocus: ft,
174
- tabIndex: pt,
175
- className: e(i.input, pe[D], "w-full", me[D], he[D], de[O], "text-foreground placeholder:text-muted-foreground", fe, le, Qt && "border-destructive", Se(Q ? 2 : 1, D))
156
+ ...en,
157
+ "aria-errormessage": St,
158
+ "aria-details": Ct,
159
+ value: dn,
160
+ onChange: nn,
161
+ onFocus: wt,
162
+ onBlur: an,
163
+ onKeyDown: rn,
164
+ onKeyUp: Dt,
165
+ placeholder: He,
166
+ disabled: x,
167
+ readOnly: S,
168
+ autoComplete: ct,
169
+ autoCapitalize: lt,
170
+ autoCorrect: ut,
171
+ enterKeyHint: dt,
172
+ inputMode: ft,
173
+ spellCheck: pt,
174
+ autoFocus: mt,
175
+ tabIndex: ht,
176
+ className: e(i.input, he[D], "w-full", ge[D], _e[D], pe[O], "text-foreground placeholder:text-muted-foreground", me, de, tn && "border-destructive", Ee(Z ? 2 : 1, D))
176
177
  }),
177
- Q && /* @__PURE__ */ p("button", {
178
+ Z && /* @__PURE__ */ u("button", {
178
179
  type: "button",
179
- "aria-label": E?.clear ?? "Clear date",
180
- disabled: C,
181
- onMouseDown: an,
182
- onClick: rn,
183
- className: e(i.clearButton, u(D, O), c(D, 2), "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"),
184
- children: /* @__PURE__ */ p(_e, { size: l(D, "icon") })
180
+ "aria-label": w?.clear ?? "Clear date",
181
+ disabled: x,
182
+ onMouseDown: cn,
183
+ onClick: sn,
184
+ className: e(i.clearButton, Oe(D, O), Te(D, 2), "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"),
185
+ children: /* @__PURE__ */ u(be, { size: De(D, "icon") })
185
186
  }),
186
- /* @__PURE__ */ p("button", {
187
- ref: q,
187
+ /* @__PURE__ */ u("button", {
188
+ ref: K,
188
189
  type: "button",
189
- "aria-label": E?.openCalendar ?? "Open calendar",
190
+ "aria-label": w?.openCalendar ?? "Open calendar",
190
191
  "aria-haspopup": "dialog",
191
- "aria-expanded": F,
192
- "aria-controls": F ? Vt : void 0,
193
- disabled: C || w,
194
- onClick: nn,
195
- className: e(i.openCalendarButton, u(D, O), c(D, 1), ue, le),
196
- children: /* @__PURE__ */ p(ge, { size: l(D, "icon") })
192
+ "aria-expanded": P,
193
+ "aria-controls": P ? Y : void 0,
194
+ disabled: x || S,
195
+ onClick: on,
196
+ className: e(i.openCalendarButton, Oe(D, O), Te(D, 1), fe, de),
197
+ children: /* @__PURE__ */ u(ye, { size: De(D, "icon") })
197
198
  })
198
199
  ]
199
200
  }),
200
- Xt && /* @__PURE__ */ p("p", {
201
- id: X,
201
+ $t && /* @__PURE__ */ u("p", {
202
+ id: Gt,
202
203
  role: "alert",
203
204
  className: e(i.errorMessage, "mt-1 text-caption-1 text-error"),
204
205
  children: $
205
206
  }),
206
- /* @__PURE__ */ p(xe, {
207
- name: rt,
208
- form: it,
209
- disabled: C,
210
- value: j ? d(j) : "",
207
+ /* @__PURE__ */ u(we, {
208
+ name: st,
209
+ form: T,
210
+ disabled: x,
211
+ value: A ? Ae(A) : "",
211
212
  type: "text",
212
- required: Yt,
213
- onInvalid: () => K.current?.focus()
213
+ required: Qt,
214
+ onInvalid: () => G.current?.focus()
214
215
  }),
215
- F && /* @__PURE__ */ p(ce, {
216
- layerId: Ut,
217
- children: /* @__PURE__ */ p("div", {
218
- ref: qt,
219
- id: Vt,
216
+ P && /* @__PURE__ */ u(ve, {
217
+ layerId: Kt,
218
+ children: /* @__PURE__ */ u("div", {
219
+ ref: Xt,
220
+ id: Y,
220
221
  role: "dialog",
221
222
  "aria-modal": "true",
222
- "aria-labelledby": Ht,
223
- ...Kt,
223
+ "aria-labelledby": Wt,
224
+ ...Yt,
224
225
  "data-state": "open",
225
- onKeyDown: cn,
226
+ onKeyDown: un,
226
227
  className: e(i.surface, "rounded-md border border-border bg-background p-3 text-foreground shadow-16"),
227
- children: /* @__PURE__ */ p(je, {
228
- value: j,
229
- onPick: on,
230
- minDate: b,
231
- maxDate: x,
232
- disabledDates: S,
233
- firstDayOfWeek: Ue,
234
- locale: y,
235
- today: We,
236
- initialVisibleDate: Ge,
237
- showMonthPicker: Ke,
238
- showWeekNumbers: qe,
239
- firstWeekOfYear: Je,
240
- showGoToToday: Ye,
241
- markedDates: Ze,
242
- renderDay: Qe,
243
- dayLabel: $e,
244
- onClose: Xe ? sn : void 0,
245
- closeLabel: E?.close,
246
- labels: E,
228
+ children: /* @__PURE__ */ u(Fe, {
229
+ value: A,
230
+ onPick: ln,
231
+ minDate: v,
232
+ maxDate: y,
233
+ disabledDates: b,
234
+ firstDayOfWeek: qe,
235
+ locale: _,
236
+ today: Je,
237
+ initialVisibleDate: Ye,
238
+ showMonthPicker: Xe,
239
+ showWeekNumbers: Ze,
240
+ firstWeekOfYear: Qe,
241
+ showGoToToday: $e,
242
+ markedDates: tt,
243
+ renderDay: nt,
244
+ dayLabel: rt,
245
+ onClose: et ? Q : void 0,
246
+ closeLabel: w?.close,
247
+ labels: w,
247
248
  headingAs: "h2",
248
- headingId: Ht,
249
- partClassNames: Fe
249
+ headingId: Wt,
250
+ partClassNames: ze
250
251
  })
251
252
  })
252
253
  })
253
254
  ]
254
255
  });
255
256
  };
256
- h.displayName = "DatePicker";
257
+ f.displayName = "DatePicker";
257
258
  //#endregion
258
- export { h as DatePicker };
259
+ export { f as DatePicker };
259
260
 
260
261
  //# sourceMappingURL=DatePicker.mjs.map