@strapi/design-system 1.8.0 → 1.8.1

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 (57) hide show
  1. package/dist/Button/Button.cjs +2 -2
  2. package/dist/Button/Button.js +4 -4
  3. package/dist/Combobox/Combobox.cjs +3 -3
  4. package/dist/Combobox/Combobox.js +12 -12
  5. package/dist/DatePicker/DatePicker.cjs +14 -14
  6. package/dist/DatePicker/DatePicker.js +257 -224
  7. package/dist/DateTimePicker/DateTimePicker.cjs +3 -3
  8. package/dist/DateTimePicker/DateTimePicker.js +69 -63
  9. package/dist/Grid/Grid.cjs +3 -3
  10. package/dist/Grid/Grid.js +6 -3
  11. package/dist/MainNav/MainNav.cjs +2 -2
  12. package/dist/MainNav/MainNav.js +9 -31
  13. package/dist/MainNav/MainNavContext.cjs +1 -1
  14. package/dist/MainNav/MainNavContext.js +1 -1
  15. package/dist/MainNav/NavBrand.cjs +3 -3
  16. package/dist/MainNav/NavBrand.js +12 -38
  17. package/dist/MainNav/NavCondense.cjs +2 -2
  18. package/dist/MainNav/NavCondense.js +15 -23
  19. package/dist/MainNav/NavFooter.cjs +1 -1
  20. package/dist/MainNav/NavFooter.js +4 -10
  21. package/dist/MainNav/NavLink.cjs +9 -9
  22. package/dist/MainNav/NavLink.js +13 -35
  23. package/dist/MainNav/NavSection.cjs +1 -1
  24. package/dist/MainNav/NavSection.js +9 -43
  25. package/dist/MainNav/NavSections.cjs +2 -2
  26. package/dist/MainNav/NavSections.js +7 -21
  27. package/dist/MainNav/NavUser.cjs +2 -2
  28. package/dist/MainNav/NavUser.js +13 -27
  29. package/dist/SimpleMenu/SimpleMenu.cjs +9 -9
  30. package/dist/SimpleMenu/SimpleMenu.js +62 -151
  31. package/dist/SubNav/SubNav.cjs +5 -5
  32. package/dist/SubNav/SubNav.js +8 -13
  33. package/dist/SubNav/SubNavHeader.cjs +3 -3
  34. package/dist/SubNav/SubNavHeader.js +29 -76
  35. package/dist/SubNav/SubNavLink.cjs +13 -13
  36. package/dist/SubNav/SubNavLink.js +20 -52
  37. package/dist/SubNav/SubNavLinkSection.cjs +4 -4
  38. package/dist/SubNav/SubNavLinkSection.js +19 -35
  39. package/dist/SubNav/SubNavSection.cjs +2 -2
  40. package/dist/SubNav/SubNavSection.js +15 -55
  41. package/dist/SubNav/SubNavSectionLabel.cjs +3 -3
  42. package/dist/SubNav/SubNavSectionLabel.js +10 -38
  43. package/dist/SubNav/SubNavSections.cjs +1 -1
  44. package/dist/SubNav/SubNavSections.js +4 -18
  45. package/dist/v2/Breadcrumbs/Breadcrumbs.cjs +2 -2
  46. package/dist/v2/Breadcrumbs/Breadcrumbs.js +15 -23
  47. package/dist/v2/Breadcrumbs/Crumb.cjs +1 -1
  48. package/dist/v2/Breadcrumbs/Crumb.js +6 -25
  49. package/dist/v2/Breadcrumbs/CrumbLink.cjs +2 -2
  50. package/dist/v2/Breadcrumbs/CrumbLink.js +6 -15
  51. package/dist/v2/Breadcrumbs/CrumbSimpleMenu.cjs +4 -3
  52. package/dist/v2/Breadcrumbs/CrumbSimpleMenu.js +8 -14
  53. package/dist/v2/Breadcrumbs/Divider.cjs +1 -1
  54. package/dist/v2/Breadcrumbs/Divider.js +3 -4
  55. package/dist/v2/SimpleMenu/Menu.cjs +10 -10
  56. package/dist/v2/SimpleMenu/Menu.js +11 -11
  57. package/package.json +10 -10
@@ -1,32 +1,33 @@
1
- import { jsxs as A, jsx as l } from "react/jsx-runtime";
2
- import * as d from "react";
3
- import { useFloating as be, offset as xe, shift as we, flip as ke, autoUpdate as Te } from "@floating-ui/react-dom";
4
- import { today as j, minDate as U, maxDate as W, startOfMonth as Ee, startOfWeek as re, getDayOfWeek as Ie, isSameDay as ne, endOfMonth as Pe, parseAbsoluteToLocal as Se, toCalendarDate as Ae } from "@internationalized/date";
5
- import { useFocusGuards as Re } from "@radix-ui/react-focus-guards";
6
- import { FocusScope as Me } from "@radix-ui/react-focus-scope";
7
- import { Cross as ve, Calendar as $e } from "@strapi/icons";
8
- import { composeEventHandlers as R } from "@strapi/ui-primitives";
1
+ import { jsxs as F, jsx as i } from "react/jsx-runtime";
2
+ import * as c from "react";
3
+ import { useFloating as be, offset as we, shift as xe, flip as ke, autoUpdate as Te } from "@floating-ui/react-dom";
4
+ import { getLocalTimeZone as Ee, today as J, minDate as H, maxDate as X, startOfMonth as Pe, startOfWeek as le, getDayOfWeek as Ie, isSameDay as se, endOfMonth as Ae, parseAbsolute as Re, toCalendarDate as Se } from "@internationalized/date";
5
+ import { useFocusGuards as Me } from "@radix-ui/react-focus-guards";
6
+ import { FocusScope as ve } from "@radix-ui/react-focus-scope";
7
+ import { Cross as $e, Calendar as Fe } from "@strapi/icons";
8
+ import { composeEventHandlers as L } from "@strapi/ui-primitives";
9
9
  import { createPortal as Le } from "react-dom";
10
- import { RemoveScroll as Fe } from "react-remove-scroll";
11
- import E from "styled-components";
12
- import { useDesignSystem as Ne } from "../DesignSystemProvider.js";
10
+ import { RemoveScroll as Ne } from "react-remove-scroll";
11
+ import I from "styled-components";
12
+ import { useDesignSystem as Oe } from "../DesignSystemProvider.js";
13
13
  import { DismissibleLayer as _e } from "../DismissibleLayer/index.js";
14
- import { createContext as Oe } from "../helpers/context.js";
15
- import { useComposedRefs as B } from "../hooks/useComposeRefs.js";
16
- import { useControllableState as Ve } from "../hooks/useControllableState.js";
17
- import { useDateFormatter as _ } from "../hooks/useDateFormatter.js";
18
- import { useId as ae } from "../hooks/useId.js";
19
- import { SingleSelectInput as J, SingleSelectOption as Q } from "../Select/SingleSelect.js";
20
- import { Portal as Ye } from "../Portal/Portal.js";
21
- import { Flex as V } from "../Flex/Flex.js";
22
- import { getThemeSize as ze, inputFocusStyle as Ue } from "../themes/utils.js";
23
- import { Box as Y } from "../Box/Box.js";
24
- import { Typography as z } from "../Typography/Typography.js";
25
- import { Field as We } from "../Field/Field.js";
26
- import { FieldLabel as je } from "../Field/FieldLabel.js";
27
- import { FieldHint as Be } from "../Field/FieldHint.js";
28
- import { FieldError as qe } from "../Field/FieldError.js";
29
- const Ke = 200, ee = 15, [Ge, M] = Oe("DatePicker"), Ze = d.forwardRef(({
14
+ import { createContext as Ve } from "../helpers/context.js";
15
+ import { once as Ye } from "../helpers/deprecations.js";
16
+ import { useComposedRefs as Q } from "../hooks/useComposeRefs.js";
17
+ import { useControllableState as ze } from "../hooks/useControllableState.js";
18
+ import { useDateFormatter as S } from "../hooks/useDateFormatter.js";
19
+ import { useId as ce } from "../hooks/useId.js";
20
+ import { SingleSelectInput as ne, SingleSelectOption as ae } from "../Select/SingleSelect.js";
21
+ import { Portal as Ue } from "../Portal/Portal.js";
22
+ import { Flex as U } from "../Flex/Flex.js";
23
+ import { getThemeSize as We, inputFocusStyle as Be } from "../themes/utils.js";
24
+ import { Box as W } from "../Box/Box.js";
25
+ import { Typography as B } from "../Typography/Typography.js";
26
+ import { Field as Ze } from "../Field/Field.js";
27
+ import { FieldLabel as qe } from "../Field/FieldLabel.js";
28
+ import { FieldHint as Ke } from "../Field/FieldHint.js";
29
+ import { FieldError as Ge } from "../Field/FieldError.js";
30
+ const je = 200, oe = 15, [He, N] = Ve("DatePicker"), Xe = c.forwardRef(({
30
31
  /**
31
32
  * DatePickerCalendar props
32
33
  */
@@ -34,101 +35,100 @@ const Ke = 200, ee = 15, [Ge, M] = Oe("DatePicker"), Ze = d.forwardRef(({
34
35
  className: r,
35
36
  initialDate: n,
36
37
  locale: t,
37
- maxDate: o,
38
- minDate: c,
39
- monthSelectLabel: h = "Month",
38
+ maxDate: a,
39
+ minDate: s,
40
+ monthSelectLabel: g = "Month",
40
41
  onChange: u,
41
- selectedDate: i,
42
- yearSelectLabel: p = "Year",
42
+ selectedDate: l,
43
+ yearSelectLabel: b = "Year",
43
44
  /**
44
45
  * Combobox props
45
46
  */
46
- error: y,
47
- id: C,
48
- disabled: a = !1,
49
- placeholder: f,
50
- required: b = !1,
51
- onClear: D,
52
- clearLabel: k = "Clear",
53
- size: x,
47
+ error: x,
48
+ id: y,
49
+ disabled: m = !1,
50
+ placeholder: k,
51
+ required: w = !1,
52
+ onClear: E,
53
+ clearLabel: P = "Clear",
54
+ size: d,
54
55
  /**
55
56
  * @preserve
56
57
  * @deprecated This is no longer used.
57
58
  */
58
- ariaLabel: T,
59
+ ariaLabel: h,
59
60
  /**
60
61
  * @preserve
61
62
  * @deprecated This is no longer used.
62
63
  */
63
- selectedDateLabel: s,
64
- ...m
65
- }, w) => {
66
- const v = Ne("DatePicker"), P = t ?? v.locale, q = _(P, {
67
- dateStyle: "short"
68
- }), $ = d.useMemo(() => {
69
- const g = q.formatToParts(/* @__PURE__ */ new Date()), { value: S } = g.find((N) => N.type === "literal");
70
- return S;
71
- }, [q]), [le, se] = d.useState(!1), [ie, ce] = d.useState(null), [K, de] = d.useState(null), [ue, fe] = d.useState(null), [O, L] = d.useState(), [F, G] = Ve({
72
- defaultProp: n ? I(n) : void 0,
73
- prop: i && I(i),
74
- onChange(g) {
75
- u && u(g?.toDate("UTC"));
64
+ selectedDateLabel: o,
65
+ ...f
66
+ }, p) => {
67
+ const T = Ee(), M = Oe("DatePicker"), v = t ?? M.locale, $ = S(v, {
68
+ day: "2-digit",
69
+ month: "2-digit",
70
+ year: "numeric"
71
+ }), [O, Z] = c.useState(!1), [q, C] = c.useState(null), [A, K] = c.useState(null), [ue, me] = c.useState(null), [Y, _] = c.useState(), [V, ee] = ze({
72
+ defaultProp: n ? R(n) : void 0,
73
+ prop: l ? R(l) : void 0,
74
+ onChange(D) {
75
+ u && u(D?.toDate(T));
76
76
  }
77
- }), [Z, H] = d.useMemo(() => {
78
- const g = n ? I(n) : j("UTC"), S = c ? I(c) : g.set({ day: 1, month: 1, year: g.year - Ke });
79
- let N = o ? I(o) : g.set({ day: 31, month: 12, year: g.year + ee });
80
- return N.compare(S) < 0 && (N = S.set({ day: 31, month: 12, year: S.year + ee })), [S, N];
81
- }, [c, o, n]), [me, X] = d.useState(He({
82
- currentValue: F,
83
- minDate: Z,
84
- maxDate: H
85
- })), he = ae(), pe = d.useRef(null), ge = (g) => {
86
- D && !a && (L(""), G(void 0), D(g), K?.focus());
87
- }, De = d.useCallback((g) => {
88
- g && F && X(F), se(g);
89
- }, [F]);
90
- d.useLayoutEffect(() => {
91
- if (i) {
92
- const g = I(i);
93
- L(g.toString().split("-").reverse().join($));
77
+ }), [te, re] = c.useMemo(() => {
78
+ const D = n ? R(n) : J("UTC"), z = s ? R(s) : D.set({ day: 1, month: 1, year: D.year - je });
79
+ let j = a ? R(a) : D.set({ day: 31, month: 12, year: D.year + oe });
80
+ return j.compare(z) < 0 && (j = z.set({ day: 31, month: 12, year: z.year + oe })), [z, j];
81
+ }, [s, a, n]), [fe, G] = c.useState(Je({
82
+ currentValue: V,
83
+ minDate: te,
84
+ maxDate: re
85
+ })), pe = ce(), he = c.useRef(null), ge = (D) => {
86
+ E && !m && (_(""), ee(void 0), E(D), A?.focus());
87
+ }, De = c.useCallback((D) => {
88
+ D && V && G(V), Z(D);
89
+ }, [V]);
90
+ c.useLayoutEffect(() => {
91
+ if (l) {
92
+ const D = R(l);
93
+ _($.format(D.toDate(T))), G(D);
94
94
  } else
95
- L("");
96
- }, [$, i]), d.useLayoutEffect(() => {
97
- if (n && O === void 0) {
98
- const g = I(n);
99
- L(g.toString().split("-").reverse().join($));
95
+ _("");
96
+ }, [l, $, T]), c.useLayoutEffect(() => {
97
+ if (n && Y === void 0) {
98
+ const D = R(n);
99
+ _($.format(D.toDate(T)));
100
100
  }
101
- }, [$, n, O]);
102
- const Ce = `${C}-hint`, ye = `${C}-error`;
103
- return A(Ge, { calendarDate: me, content: ue, contentId: he, disabled: a, locale: P, minDate: Z, maxDate: H, open: le, onCalendarDateChange: X, onContentChange: fe, onOpenChange: De, onTextInputChange: de, onTextValueChange: L, onTriggerChange: ce, onValueChange: G, required: b, separator: $, textInput: K, textValue: O, timeZone: "UTC", trigger: ie, value: F, children: [A(Je, { className: r, size: x, hasError: !!y, children: [l(tt, { "aria-hidden": !0 }), l(nt, { ref: w, placeholder: f, "aria-describedby": `${Ce} ${ye}`, id: C, ...m }), O && D ? l(et, { as: "button", hasRadius: !0, background: "transparent", type: "button", onClick: ge, "aria-disabled": a, "aria-label": k, title: k, ref: pe, children: l(ve, {}) }) : null] }), l(Ye, { children: l(st, { label: e, children: l(ft, { monthSelectLabel: h, yearSelectLabel: p }) }) })] });
104
- }), te = (e) => !!e.match(/^[^a-zA-Z]*$/), He = ({ currentValue: e, minDate: r, maxDate: n }) => {
105
- const t = j("UTC");
106
- return e || (U(r, t) === r && W(n, t) === n ? t : U(r, t) === t ? r : W(n, t) === t ? n : t);
107
- }, Xe = "DatePickerTrigger", Je = d.forwardRef(({ hasError: e, size: r = "M", ...n }, t) => {
108
- const o = M(Xe), c = B(t, (u) => o.onTriggerChange(u)), h = () => {
109
- o.disabled || o.onOpenChange(!0);
101
+ }, [n, Y, $, T]);
102
+ const ye = `${y}-hint`, Ce = `${y}-error`;
103
+ return F(He, { calendarDate: fe, content: ue, contentId: pe, disabled: m, locale: v, minDate: te, maxDate: re, open: O, onCalendarDateChange: G, onContentChange: me, onOpenChange: De, onTextInputChange: K, onTextValueChange: _, onTriggerChange: C, onValueChange: ee, required: w, textInput: A, textValue: Y, timeZone: T, trigger: q, value: V, children: [F(et, { className: r, size: d, hasError: !!x, children: [i(nt, { "aria-hidden": !0 }), i(ot, { ref: p, placeholder: k, "aria-describedby": `${ye} ${Ce}`, id: y, ...f }), Y && E ? i(rt, { as: "button", hasRadius: !0, background: "transparent", type: "button", onClick: ge, "aria-disabled": m, "aria-label": P, title: P, ref: he, children: i($e, {}) }) : null] }), i(Ue, { children: i(ct, { label: e, children: i(pt, { monthSelectLabel: g, yearSelectLabel: b }) }) })] });
104
+ }), ie = (e) => !!e.match(/^[^a-zA-Z]*$/), Je = ({ currentValue: e, minDate: r, maxDate: n }) => {
105
+ const t = J("UTC");
106
+ return e || (H(r, t) === r && X(n, t) === n ? t : H(r, t) === t ? r : X(n, t) === t ? n : t);
107
+ }, Qe = "DatePickerTrigger", et = c.forwardRef(({ hasError: e, size: r = "M", ...n }, t) => {
108
+ const a = N(Qe), s = Q(t, (u) => a.onTriggerChange(u)), g = () => {
109
+ a.disabled || a.onOpenChange(!0);
110
110
  };
111
- return l(Me, {
111
+ return i(ve, {
112
112
  asChild: !0,
113
113
  // we make sure we're not trapping once it's been closed
114
114
  // (closed !== unmounted when animating out)
115
- trapped: o.open,
115
+ trapped: a.open,
116
116
  onMountAutoFocus: (u) => {
117
117
  u.preventDefault();
118
118
  },
119
119
  onUnmountAutoFocus: (u) => {
120
120
  document.getSelection()?.empty(), u.preventDefault();
121
121
  },
122
- children: l(Qe, { ref: c, $hasError: e, $size: r, ...n, paddingLeft: 3, paddingRight: 3, hasRadius: !0, gap: 3, overflow: "hidden", background: o.disabled ? "neutral150" : "neutral0", onClick: R(n.onClick, () => {
123
- o.textInput?.focus();
124
- }), onPointerDown: R(n.onPointerDown, (u) => {
125
- const i = u.target;
126
- i.hasPointerCapture(u.pointerId) && i.releasePointerCapture(u.pointerId), (i.closest("button") ?? i.closest("div")) === u.currentTarget && u.button === 0 && u.ctrlKey === !1 && (h(), o.textInput?.focus());
122
+ children: i(tt, { ref: s, $hasError: e, $size: r, ...n, paddingLeft: 3, paddingRight: 3, hasRadius: !0, gap: 3, overflow: "hidden", background: a.disabled ? "neutral150" : "neutral0", onClick: L(n.onClick, () => {
123
+ a.textInput?.focus();
124
+ }), onPointerDown: L(n.onPointerDown, (u) => {
125
+ const l = u.target;
126
+ l.hasPointerCapture(u.pointerId) && l.releasePointerCapture(u.pointerId), (l.closest("button") ?? l.closest("div")) === u.currentTarget && u.button === 0 && u.ctrlKey === !1 && (g(), a.textInput?.focus());
127
127
  }) })
128
128
  });
129
- }), Qe = E(V)`
129
+ }), tt = I(U)`
130
130
  border: 1px solid ${({ theme: e, $hasError: r }) => r ? e.colors.danger600 : e.colors.neutral200};
131
- min-height: ${({ theme: e, $size: r }) => ze("input")({ theme: e, size: r })};
131
+ min-height: ${({ theme: e, $size: r }) => We("input")({ theme: e, size: r })};
132
132
 
133
133
  &[data-disabled] {
134
134
  color: ${({ theme: e }) => e.colors.neutral600};
@@ -141,8 +141,8 @@ const Ke = 200, ee = 15, [Ge, M] = Oe("DatePicker"), Ze = d.forwardRef(({
141
141
  outline: none;
142
142
  }
143
143
 
144
- ${({ theme: e, $hasError: r }) => Ue()({ theme: e, hasError: r })};
145
- `, et = E(Y)`
144
+ ${({ theme: e, $hasError: r }) => Be()({ theme: e, hasError: r })};
145
+ `, rt = I(W)`
146
146
  border: none;
147
147
 
148
148
  svg {
@@ -153,81 +153,105 @@ const Ke = 200, ee = 15, [Ge, M] = Oe("DatePicker"), Ze = d.forwardRef(({
153
153
  svg path {
154
154
  fill: ${({ theme: e }) => e.colors.neutral600};
155
155
  }
156
- `, tt = E($e)`
156
+ `, nt = I(Fe)`
157
157
  & > path {
158
158
  fill: ${({ theme: e }) => e.colors.neutral500};
159
159
  }
160
- `, rt = "DatePickerTextInput", nt = d.forwardRef(({ placeholder: e, ...r }, n) => {
161
- const t = M(rt), { onTextValueChange: o, textValue: c, onTextInputChange: h, onOpenChange: u, disabled: i, separator: p } = t, y = B(n, (a) => h(a)), C = () => {
162
- i || u(!0);
163
- };
164
- return l(ot, { role: "combobox", type: "text", inputMode: "numeric", ref: y, "aria-autocomplete": "none", "aria-controls": t.contentId, "aria-disabled": t.disabled, "aria-expanded": t.open, "aria-required": t.required, "aria-haspopup": "dialog", "data-state": t.open ? "open" : "closed", disabled: i, "data-disabled": i ? "" : void 0, pattern: `\\d{2}${p}\\d{2}${p}\\d{4}`, placeholder: e ?? `DD${p}MM${p}YYYY`, ...r, value: c ?? "", onBlur: R(r.onBlur, () => {
160
+ `, at = "DatePickerTextInput", ot = c.forwardRef(({ placeholder: e, ...r }, n) => {
161
+ const t = N(at), { onTextValueChange: a, textValue: s, onTextInputChange: g, onOpenChange: u, disabled: l, locale: b } = t, x = Q(n, (d) => g(d)), y = () => {
162
+ l || u(!0);
163
+ }, m = S(b, {
164
+ year: "numeric",
165
+ month: "2-digit",
166
+ day: "2-digit"
167
+ }), [k, w, E] = c.useMemo(() => {
168
+ const d = m.formatToParts(/* @__PURE__ */ new Date()), h = d.filter((p) => p.type === "year" || p.type === "month" || p.type === "day"), o = h.map((p) => {
169
+ switch (p.type) {
170
+ case "day":
171
+ return "DD";
172
+ case "month":
173
+ return "MM";
174
+ case "year":
175
+ return "YYYY";
176
+ default:
177
+ return "";
178
+ }
179
+ }), f = d.find((p) => p.type === "literal")?.value ?? "";
180
+ return [o, f, h];
181
+ }, [m]), P = k.map((d) => `\\d${d.length}`).join(w);
182
+ return i(lt, { role: "combobox", type: "text", inputMode: "numeric", ref: x, "aria-autocomplete": "none", "aria-controls": t.contentId, "aria-disabled": t.disabled, "aria-expanded": t.open, "aria-required": t.required, "aria-haspopup": "dialog", "data-state": t.open ? "open" : "closed", disabled: l, "data-disabled": l ? "" : void 0, pattern: P, placeholder: e ?? k.join(w), ...r, value: s ?? "", onBlur: L(r.onBlur, () => {
165
183
  if (!t.textValue) {
166
184
  t.onValueChange(void 0);
167
185
  return;
168
186
  }
169
- t.onTextValueChange(t.calendarDate.toString().split("-").reverse().join(p)), t.onValueChange(t.calendarDate);
170
- }), onChange: R(r.onChange, (a) => {
171
- if (te(a.target.value)) {
172
- const [f, b, D] = a.target.value.split(p), k = t.calendarDate.year;
173
- let x = t.calendarDate.year;
174
- if (D) {
175
- let P = D.length === 1 ? `0${D}` : D;
176
- x = D.length < 3 ? Number(`${k}`.slice(0, 4 - P.length) + P) : Number(P);
187
+ t.onTextValueChange(m.format(t.calendarDate.toDate(t.timeZone))), t.onValueChange(t.calendarDate);
188
+ }), onChange: L(r.onChange, (d) => {
189
+ if (ie(d.target.value)) {
190
+ const h = d.target.value.split(w), [o, f, p] = E.map((C, A) => {
191
+ const K = h[A];
192
+ return {
193
+ ...C,
194
+ value: K
195
+ };
196
+ }).sort((C, A) => C.type === "year" ? 1 : A.type === "year" ? -1 : C.type === "month" ? 1 : A.type === "month" ? -1 : 0).map((C) => C.value), T = t.calendarDate.year;
197
+ let M = t.calendarDate.year;
198
+ if (p) {
199
+ let C = p.length === 1 ? `0${p}` : p;
200
+ M = p.length < 3 ? Number(`${T}`.slice(0, 4 - C.length) + C) : Number(C);
177
201
  }
178
- D && D.length < 3 && x > t.maxDate.year && (x -= 100);
179
- const T = t.calendarDate.set({ year: x }), s = T.calendar.getMonthsInYear(T), m = T.set({
180
- month: b && Number(b) <= s ? Number(b) : void 0
181
- }), w = m.calendar.getDaysInMonth(m), v = m.set({
182
- day: f && Number(f) <= w ? Number(f) : void 0
202
+ p && p.length < 3 && M > t.maxDate.year && (M -= 100);
203
+ const v = t.calendarDate.set({ year: M }), $ = v.calendar.getMonthsInYear(v), O = v.set({
204
+ month: f && Number(f) <= $ ? Number(f) : void 0
205
+ }), Z = O.calendar.getDaysInMonth(O), q = O.set({
206
+ day: o && Number(o) <= Z ? Number(o) : void 0
183
207
  });
184
- t.onCalendarDateChange(at(v, t.minDate, t.maxDate)), t.onTextValueChange(a.target.value);
208
+ t.onCalendarDateChange(it(q, t.minDate, t.maxDate)), t.onTextValueChange(d.target.value);
185
209
  }
186
- }), onKeyDown: R(r.onKeyDown, (a) => {
187
- if (!t.open && (te(a.key) || ["ArrowDown", "Backspace"].includes(a.key)))
188
- C();
189
- else if (["Tab"].includes(a.key) && t.open)
190
- a.preventDefault();
191
- else if (["Escape"].includes(a.key))
192
- t.open ? t.onOpenChange(!1) : (t.onValueChange(void 0), t.onTextValueChange("")), a.preventDefault();
193
- else if (t.open && ["ArrowDown", "ArrowUp", "ArrowLeft", "ArrowRight"].includes(a.key))
194
- switch (a.preventDefault(), a.key) {
210
+ }), onKeyDown: L(r.onKeyDown, (d) => {
211
+ if (!t.open && (ie(d.key) || ["ArrowDown", "Backspace"].includes(d.key)))
212
+ y();
213
+ else if (["Tab"].includes(d.key) && t.open)
214
+ d.preventDefault();
215
+ else if (["Escape"].includes(d.key))
216
+ t.open ? t.onOpenChange(!1) : (t.onValueChange(void 0), t.onTextValueChange("")), d.preventDefault();
217
+ else if (t.open && ["ArrowDown", "ArrowUp", "ArrowLeft", "ArrowRight"].includes(d.key))
218
+ switch (d.preventDefault(), d.key) {
195
219
  case "ArrowDown": {
196
- const f = t.calendarDate.add({ weeks: 1 });
197
- if (t.maxDate && f.compare(t.maxDate) > 0)
220
+ const h = t.calendarDate.add({ weeks: 1 });
221
+ if (t.maxDate && h.compare(t.maxDate) > 0)
198
222
  return;
199
- t.onCalendarDateChange(f);
223
+ t.onCalendarDateChange(h);
200
224
  return;
201
225
  }
202
226
  case "ArrowRight": {
203
- const f = t.calendarDate.add({ days: 1 });
204
- if (t.maxDate && f.compare(t.maxDate) > 0)
227
+ const h = t.calendarDate.add({ days: 1 });
228
+ if (t.maxDate && h.compare(t.maxDate) > 0)
205
229
  return;
206
- t.onCalendarDateChange(f);
230
+ t.onCalendarDateChange(h);
207
231
  return;
208
232
  }
209
233
  case "ArrowUp": {
210
- const f = t.calendarDate.subtract({ weeks: 1 });
211
- if (t.minDate && f.compare(t.minDate) < 0)
234
+ const h = t.calendarDate.subtract({ weeks: 1 });
235
+ if (t.minDate && h.compare(t.minDate) < 0)
212
236
  return;
213
- t.onCalendarDateChange(f);
237
+ t.onCalendarDateChange(h);
214
238
  return;
215
239
  }
216
240
  case "ArrowLeft": {
217
- const f = t.calendarDate.subtract({ days: 1 });
218
- if (t.minDate && f.compare(t.minDate) < 0)
241
+ const h = t.calendarDate.subtract({ days: 1 });
242
+ if (t.minDate && h.compare(t.minDate) < 0)
219
243
  return;
220
- t.onCalendarDateChange(f);
244
+ t.onCalendarDateChange(h);
221
245
  }
222
246
  }
223
247
  else
224
- t.open && ["Enter"].includes(a.key) && (a.preventDefault(), o(t.calendarDate.toString().split("-").reverse().join(p)), t.onValueChange(t.calendarDate), t.onOpenChange(!1));
248
+ t.open && ["Enter"].includes(d.key) && (d.preventDefault(), a(m.format(t.calendarDate.toDate(t.timeZone))), t.onValueChange(t.calendarDate), t.onOpenChange(!1));
225
249
  }) });
226
250
  });
227
- function at(e, r, n) {
228
- return r && (e = W(e, r)), n && (e = U(e, n)), e;
251
+ function it(e, r, n) {
252
+ return r && (e = X(e, r)), n && (e = H(e, n)), e;
229
253
  }
230
- const ot = E.input`
254
+ const lt = I.input`
231
255
  width: 100%;
232
256
  font-size: ${14 / 16}rem;
233
257
  color: ${({ theme: e }) => e.colors.neutral800};
@@ -242,104 +266,104 @@ const ot = E.input`
242
266
  &[aria-disabled='true'] {
243
267
  cursor: inherit;
244
268
  }
245
- `, lt = "DatePickerContent", st = d.forwardRef((e, r) => {
246
- const [n, t] = d.useState(), o = M(lt);
247
- if (d.useLayoutEffect(() => {
269
+ `, st = "DatePickerContent", ct = c.forwardRef((e, r) => {
270
+ const [n, t] = c.useState(), a = N(st);
271
+ if (c.useLayoutEffect(() => {
248
272
  t(new DocumentFragment());
249
- }, []), !o.open) {
250
- const c = n;
251
- return c ? Le(l("div", { children: e.children }), c) : null;
273
+ }, []), !a.open) {
274
+ const s = n;
275
+ return s ? Le(i("div", { children: e.children }), s) : null;
252
276
  }
253
- return l(ct, { ...e, ref: r });
254
- }), it = "DatePickerContent", ct = d.forwardRef((e, r) => {
255
- const { label: n = "Choose date", ...t } = e, { onOpenChange: o, ...c } = M(it), { x: h, y: u, reference: i, floating: p, strategy: y } = be({
277
+ return i(ut, { ...e, ref: r });
278
+ }), dt = "DatePickerContent", ut = c.forwardRef((e, r) => {
279
+ const { label: n = "Choose date", ...t } = e, { onOpenChange: a, ...s } = N(dt), { x: g, y: u, reference: l, floating: b, strategy: x } = be({
256
280
  strategy: "fixed",
257
281
  placement: "bottom-start",
258
282
  middleware: [
259
- xe({
283
+ we({
260
284
  mainAxis: 4
261
285
  }),
262
- we(),
286
+ xe(),
263
287
  ke()
264
288
  ],
265
289
  whileElementsMounted: Te
266
290
  });
267
- d.useEffect(() => {
268
- const a = () => {
269
- o(!1);
291
+ c.useEffect(() => {
292
+ const m = () => {
293
+ a(!1);
270
294
  };
271
- return window.addEventListener("blur", a), window.addEventListener("resize", a), () => {
272
- window.removeEventListener("blur", a), window.removeEventListener("resize", a);
295
+ return window.addEventListener("blur", m), window.addEventListener("resize", m), () => {
296
+ window.removeEventListener("blur", m), window.removeEventListener("resize", m);
273
297
  };
274
- }, [o]), d.useLayoutEffect(() => {
275
- i(c.trigger);
276
- }, [i, c.trigger]);
277
- const C = B(r, (a) => c.onContentChange(a), p);
278
- return Re(), l(Fe, { allowPinchZoom: !0, children: l(_e, {
298
+ }, [a]), c.useLayoutEffect(() => {
299
+ l(s.trigger);
300
+ }, [l, s.trigger]);
301
+ const y = Q(r, (m) => s.onContentChange(m), b);
302
+ return Me(), i(Ne, { allowPinchZoom: !0, children: i(_e, {
279
303
  asChild: !0,
280
304
  // When focus is trapped, a focusout event may still happen.
281
305
  // We make sure we don't trigger our `onDismiss` in such case.
282
- onFocusOutside: (a) => {
283
- a.preventDefault();
306
+ onFocusOutside: (m) => {
307
+ m.preventDefault();
284
308
  },
285
309
  onDismiss: () => {
286
- o(!1);
310
+ a(!1);
287
311
  },
288
- children: l(dt, { ref: C, "data-state": c.open ? "open" : "closed", onContextMenu: (a) => a.preventDefault(), id: c.contentId, role: "dialog", "aria-modal": "true", "aria-label": n, style: {
289
- left: h,
312
+ children: i(mt, { ref: y, "data-state": s.open ? "open" : "closed", onContextMenu: (m) => m.preventDefault(), id: s.contentId, role: "dialog", "aria-modal": "true", "aria-label": n, style: {
313
+ left: g,
290
314
  top: u,
291
- position: y
315
+ position: x
292
316
  }, hasRadius: !0, background: "neutral0", padding: 1, ...t })
293
317
  }) });
294
- }), dt = E(Y)`
318
+ }), mt = I(W)`
295
319
  box-shadow: ${({ theme: e }) => e.shadows.filterShadow};
296
320
  z-index: ${({ theme: e }) => e.zIndices[0]};
297
321
  border: 1px solid ${({ theme: e }) => e.colors.neutral150};
298
- `, ut = "DatePickerCalendar", ft = d.forwardRef(({ monthSelectLabel: e, yearSelectLabel: r, ...n }, t) => {
299
- const { locale: o, timeZone: c, minDate: h, maxDate: u, calendarDate: i, onCalendarDateChange: p } = M(ut), y = Ee(i), C = d.useMemo(() => {
300
- const s = h.year, m = u.year;
301
- return [...Array(m - s + 1).keys()].map((w) => (s + w).toString());
302
- }, [h, u]), a = _(o, { month: "long" }), f = d.useMemo(() => [...Array(i.calendar.getMonthsInYear(i)).keys()].map((s) => a.format(i.set({ month: s + 1 }).toDate(c))), [i, a, c]), b = _(o, { weekday: "short" }), D = d.useMemo(() => {
303
- let s = re(j(c), o);
304
- return [...new Array(7).keys()].map((m) => {
305
- let v = s.add({ days: m }).toDate(c);
306
- return b.format(v);
322
+ `, ft = "DatePickerCalendar", pt = c.forwardRef(({ monthSelectLabel: e, yearSelectLabel: r, ...n }, t) => {
323
+ const { locale: a, timeZone: s, minDate: g, maxDate: u, calendarDate: l, onCalendarDateChange: b } = N(ft), x = Pe(l), y = c.useMemo(() => {
324
+ const o = g.year, f = u.year;
325
+ return [...Array(f - o + 1).keys()].map((p) => (o + p).toString());
326
+ }, [g, u]), m = S(a, { month: "long" }), k = c.useMemo(() => [...Array(l.calendar.getMonthsInYear(l)).keys()].map((o) => m.format(l.set({ month: o + 1 }).toDate(s))), [l, m, s]), w = S(a, { weekday: "short" }), E = c.useMemo(() => {
327
+ let o = le(J(s), a);
328
+ return [...new Array(7).keys()].map((f) => {
329
+ let T = o.add({ days: f }).toDate(s);
330
+ return w.format(T);
307
331
  });
308
- }, [c, o, b]), k = (s) => {
309
- if (typeof s == "number")
332
+ }, [s, a, w]), P = (o) => {
333
+ if (typeof o == "number")
310
334
  return;
311
- const m = i.set({ month: f.indexOf(s) + 1 });
312
- p(m);
313
- }, x = (s) => {
314
- if (typeof s == "number")
335
+ const f = l.set({ month: k.indexOf(o) + 1 });
336
+ b(f);
337
+ }, d = (o) => {
338
+ if (typeof o == "number")
315
339
  return;
316
- const m = i.set({ year: parseInt(s, 10) });
317
- p(m);
318
- }, T = mt(y, o);
319
- return A(V, { ref: t, direction: "column", alignItems: "stretch", padding: 4, ...n, children: [A(ht, { justifyContent: "flex-start", paddingBottom: 4, paddingLeft: 2, paddingRight: 2, gap: 2, children: [l(J, { label: e, size: "S", value: f[i.month - 1], onChange: k, children: f.map((s) => l(Q, { value: s, children: s }, s)) }), l(J, { size: "S", value: i.year.toString(), label: r, onChange: x, children: C.map((s) => l(Q, { value: s, children: s }, s)) })] }), A("table", { role: "grid", children: [l("thead", { "aria-hidden": !0, children: l("tr", { "aria-rowindex": 0, children: D.map((s, m) => l(pt, { "aria-colindex": m, children: s }, s)) }) }), l("tbody", { children: [...new Array(6).keys()].map((s) => l("tr", { "aria-rowindex": s + 2, children: T(s).map((m, w) => m ? l(Ct, { "aria-colindex": w + 1, date: m, startDate: y }, m.toString()) : l(oe, { "aria-colindex": w + 1 })) }, s)) })] })] });
320
- }), mt = (e, r) => (n) => {
321
- let t = e.add({ weeks: n }), o = [];
322
- t = re(t, r);
323
- let c = Ie(t, r);
324
- for (let h = 0; h < c; h++)
325
- o.push(null);
326
- for (; o.length < 7; ) {
327
- o.push(t);
328
- let h = t.add({ days: 1 });
329
- if (ne(t, h))
340
+ const f = l.set({ year: parseInt(o, 10) });
341
+ b(f);
342
+ }, h = ht(x, a);
343
+ return F(U, { ref: t, direction: "column", alignItems: "stretch", padding: 4, ...n, children: [F(gt, { justifyContent: "flex-start", paddingBottom: 4, paddingLeft: 2, paddingRight: 2, gap: 2, children: [i(ne, { label: e, size: "S", value: k[l.month - 1], onChange: P, children: k.map((o) => i(ae, { value: o, children: o }, o)) }), i(ne, { size: "S", value: l.year.toString(), label: r, onChange: d, children: y.map((o) => i(ae, { value: o, children: o }, o)) })] }), F("table", { role: "grid", children: [i("thead", { "aria-hidden": !0, children: i("tr", { "aria-rowindex": 0, children: E.map((o, f) => i(Dt, { "aria-colindex": f, children: o }, o)) }) }), i("tbody", { children: [...new Array(6).keys()].map((o) => i("tr", { "aria-rowindex": o + 2, children: h(o).map((f, p) => f ? i(bt, { "aria-colindex": p + 1, date: f, startDate: x }, f.toString()) : i(de, { "aria-colindex": p + 1 })) }, o)) })] })] });
344
+ }), ht = (e, r) => (n) => {
345
+ let t = e.add({ weeks: n }), a = [];
346
+ t = le(t, r);
347
+ let s = Ie(t, r);
348
+ for (let g = 0; g < s; g++)
349
+ a.push(null);
350
+ for (; a.length < 7; ) {
351
+ a.push(t);
352
+ let g = t.add({ days: 1 });
353
+ if (se(t, g))
330
354
  break;
331
- t = h;
355
+ t = g;
332
356
  }
333
- for (; o.length < 7; )
334
- o.push(null);
335
- return o;
336
- }, ht = E(V)`
357
+ for (; a.length < 7; )
358
+ a.push(null);
359
+ return a;
360
+ }, gt = I(U)`
337
361
  div[role='combobox'] {
338
362
  border: 1px solid transparent;
339
363
  background: transparent;
340
364
  font-weight: ${(e) => e.theme.fontWeights.bold};
341
365
 
342
- ${z} {
366
+ ${B} {
343
367
  color: ${({ theme: e }) => e.colors.neutral800};
344
368
  }
345
369
 
@@ -354,24 +378,28 @@ const ot = E.input`
354
378
  background-color: ${({ theme: e }) => e.colors.neutral100};
355
379
  }
356
380
  }
357
- `, pt = d.forwardRef(({ children: e, ...r }, n) => l(gt, { as: "th", role: "gridcell", ref: n, ...r, height: `${24 / 16}rem`, width: `${32 / 16}rem`, children: l(z, { variant: "pi", fontWeight: "bold", color: "neutral800", children: e.slice(0, 2) }) })), gt = E(Y)`
381
+ `, Dt = c.forwardRef(({ children: e, ...r }, n) => i(yt, { as: "th", role: "gridcell", ref: n, ...r, height: `${24 / 16}rem`, width: `${32 / 16}rem`, children: i(B, { variant: "pi", fontWeight: "bold", color: "neutral800", children: e.slice(0, 2) }) })), yt = I(W)`
358
382
  border-radius: ${({ theme: e }) => e.borderRadius};
359
383
  text-transform: capitalize;
360
- `, Dt = "DatePickerCalendarCell", Ct = d.forwardRef(({ date: e, startDate: r, ...n }, t) => {
361
- const { timeZone: o, locale: c, calendarDate: h, onValueChange: u, onOpenChange: i, onTextValueChange: p, separator: y, onCalendarDateChange: C } = M(Dt), a = ne(h, e), f = _(c, {
384
+ `, Ct = "DatePickerCalendarCell", bt = c.forwardRef(({ date: e, startDate: r, ...n }, t) => {
385
+ const { timeZone: a, locale: s, calendarDate: g, onValueChange: u, onOpenChange: l, onTextValueChange: b, onCalendarDateChange: x } = N(Ct), y = se(g, e), m = S(s, {
362
386
  weekday: "long",
363
387
  day: "numeric",
364
388
  month: "long",
365
389
  year: "numeric"
366
- }), b = d.useMemo(() => f.format(e.toDate(o)), [f, e, o]), D = _(c, {
390
+ }), k = c.useMemo(() => m.format(e.toDate(a)), [m, e, a]), w = S(s, {
367
391
  day: "numeric",
368
392
  calendar: e.calendar.identifier
369
- }), k = d.useMemo(() => D.formatToParts(e.toDate(o)).find((m) => m.type === "day").value, [D, e, o]), x = Pe(r), T = e.compare(r) < 0 || e.compare(x) > 0;
370
- let s = "neutral900";
371
- return a ? s = "primary600" : T && (s = "neutral600"), l(oe, { as: "td", role: "gridcell", ref: t, "aria-selected": a, ...n, hasRadius: !0, "aria-label": b, tabIndex: a ? 0 : -1, background: a ? "primary100" : "neutral0", cursor: "pointer", onPointerDown: R(n.onPointerDown, (m) => {
372
- m.preventDefault(), C(e), u(e), p(e.toString().split("-").reverse().join(y)), i(!1);
373
- }), children: l(z, { variant: "pi", textColor: s, children: k }) });
374
- }), oe = E(Y)`
393
+ }), E = c.useMemo(() => w.formatToParts(e.toDate(a)).find((f) => f.type === "day").value, [w, e, a]), P = S(s, {
394
+ day: "2-digit",
395
+ month: "2-digit",
396
+ year: "numeric"
397
+ }), d = Ae(r), h = e.compare(r) < 0 || e.compare(d) > 0;
398
+ let o = "neutral900";
399
+ return y ? o = "primary600" : h && (o = "neutral600"), i(de, { as: "td", role: "gridcell", ref: t, "aria-selected": y, ...n, hasRadius: !0, "aria-label": k, tabIndex: y ? 0 : -1, background: y ? "primary100" : "neutral0", cursor: "pointer", onPointerDown: L(n.onPointerDown, (f) => {
400
+ f.preventDefault(), x(e), u(e), b(P.format(e.toDate(a))), l(!1);
401
+ }), children: i(B, { variant: "pi", textColor: o, children: E }) });
402
+ }), de = I(W)`
375
403
  text-align: center;
376
404
  padding: ${7 / 16}rem;
377
405
  // Trick to prevent the outline from overflowing because of the general outline-offset
@@ -380,18 +408,23 @@ const ot = E.input`
380
408
  &:hover {
381
409
  background: ${({ theme: e }) => e.colors.primary100};
382
410
 
383
- & > ${z} {
411
+ & > ${B} {
384
412
  color: ${({ theme: e }) => e.colors.primary600};
385
413
  }
386
414
  }
387
- `, yt = d.forwardRef((e, r) => {
388
- const { error: n, hint: t, id: o, required: c, label: h, ...u } = e, i = ae(o);
389
- return l(We, { error: n, hint: t, required: c, ref: r, id: i, children: A(V, { direction: "column", alignItems: "stretch", gap: 1, children: [l(je, { children: h }), l(Ze, { id: i, error: n, required: c, ...u }), l(Be, {}), l(qe, {})] }) });
390
- }), I = (e) => {
391
- const r = e.toISOString(), n = Se(r);
392
- return Ae(n);
393
- }, Kt = yt;
415
+ `, wt = c.forwardRef((e, r) => {
416
+ const { error: n, hint: t, id: a, required: s, label: g, ...u } = e, l = ce(a);
417
+ return i(Ze, { error: n, hint: t, required: s, ref: r, id: l, children: F(U, { direction: "column", alignItems: "stretch", gap: 1, children: [i(qe, { children: g }), i(Xe, { id: l, error: n, required: s, ...u }), i(Ke, {}), i(Ge, {})] }) });
418
+ }), xt = Ye(console.warn), R = (e) => {
419
+ if (typeof e == "string") {
420
+ xt("It looks like you're passing a string as representation of a Date to the DatePicker. This is deprecated, look to passing a Date instead.");
421
+ const t = Date.parse(e);
422
+ Number.isNaN(t) ? e = /* @__PURE__ */ new Date() : e = new Date(t);
423
+ }
424
+ const r = e.toISOString(), n = Re(r, "UTC");
425
+ return Se(n);
426
+ }, Xt = wt;
394
427
  export {
395
- Kt as DatePicker,
396
- Ze as DatePickerInput
428
+ Xt as DatePicker,
429
+ Xe as DatePickerInput
397
430
  };