@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.
- package/dist/Button/Button.cjs +2 -2
- package/dist/Button/Button.js +4 -4
- package/dist/Combobox/Combobox.cjs +3 -3
- package/dist/Combobox/Combobox.js +12 -12
- package/dist/DatePicker/DatePicker.cjs +14 -14
- package/dist/DatePicker/DatePicker.js +257 -224
- package/dist/DateTimePicker/DateTimePicker.cjs +3 -3
- package/dist/DateTimePicker/DateTimePicker.js +69 -63
- package/dist/Grid/Grid.cjs +3 -3
- package/dist/Grid/Grid.js +6 -3
- package/dist/MainNav/MainNav.cjs +2 -2
- package/dist/MainNav/MainNav.js +9 -31
- package/dist/MainNav/MainNavContext.cjs +1 -1
- package/dist/MainNav/MainNavContext.js +1 -1
- package/dist/MainNav/NavBrand.cjs +3 -3
- package/dist/MainNav/NavBrand.js +12 -38
- package/dist/MainNav/NavCondense.cjs +2 -2
- package/dist/MainNav/NavCondense.js +15 -23
- package/dist/MainNav/NavFooter.cjs +1 -1
- package/dist/MainNav/NavFooter.js +4 -10
- package/dist/MainNav/NavLink.cjs +9 -9
- package/dist/MainNav/NavLink.js +13 -35
- package/dist/MainNav/NavSection.cjs +1 -1
- package/dist/MainNav/NavSection.js +9 -43
- package/dist/MainNav/NavSections.cjs +2 -2
- package/dist/MainNav/NavSections.js +7 -21
- package/dist/MainNav/NavUser.cjs +2 -2
- package/dist/MainNav/NavUser.js +13 -27
- package/dist/SimpleMenu/SimpleMenu.cjs +9 -9
- package/dist/SimpleMenu/SimpleMenu.js +62 -151
- package/dist/SubNav/SubNav.cjs +5 -5
- package/dist/SubNav/SubNav.js +8 -13
- package/dist/SubNav/SubNavHeader.cjs +3 -3
- package/dist/SubNav/SubNavHeader.js +29 -76
- package/dist/SubNav/SubNavLink.cjs +13 -13
- package/dist/SubNav/SubNavLink.js +20 -52
- package/dist/SubNav/SubNavLinkSection.cjs +4 -4
- package/dist/SubNav/SubNavLinkSection.js +19 -35
- package/dist/SubNav/SubNavSection.cjs +2 -2
- package/dist/SubNav/SubNavSection.js +15 -55
- package/dist/SubNav/SubNavSectionLabel.cjs +3 -3
- package/dist/SubNav/SubNavSectionLabel.js +10 -38
- package/dist/SubNav/SubNavSections.cjs +1 -1
- package/dist/SubNav/SubNavSections.js +4 -18
- package/dist/v2/Breadcrumbs/Breadcrumbs.cjs +2 -2
- package/dist/v2/Breadcrumbs/Breadcrumbs.js +15 -23
- package/dist/v2/Breadcrumbs/Crumb.cjs +1 -1
- package/dist/v2/Breadcrumbs/Crumb.js +6 -25
- package/dist/v2/Breadcrumbs/CrumbLink.cjs +2 -2
- package/dist/v2/Breadcrumbs/CrumbLink.js +6 -15
- package/dist/v2/Breadcrumbs/CrumbSimpleMenu.cjs +4 -3
- package/dist/v2/Breadcrumbs/CrumbSimpleMenu.js +8 -14
- package/dist/v2/Breadcrumbs/Divider.cjs +1 -1
- package/dist/v2/Breadcrumbs/Divider.js +3 -4
- package/dist/v2/SimpleMenu/Menu.cjs +10 -10
- package/dist/v2/SimpleMenu/Menu.js +11 -11
- package/package.json +10 -10
|
@@ -1,32 +1,33 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import * as
|
|
3
|
-
import { useFloating as be, offset as
|
|
4
|
-
import { today as
|
|
5
|
-
import { useFocusGuards as
|
|
6
|
-
import { FocusScope as
|
|
7
|
-
import { Cross as
|
|
8
|
-
import { composeEventHandlers as
|
|
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
|
|
11
|
-
import
|
|
12
|
-
import { useDesignSystem as
|
|
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
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
|
|
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:
|
|
38
|
-
minDate:
|
|
39
|
-
monthSelectLabel:
|
|
38
|
+
maxDate: a,
|
|
39
|
+
minDate: s,
|
|
40
|
+
monthSelectLabel: g = "Month",
|
|
40
41
|
onChange: u,
|
|
41
|
-
selectedDate:
|
|
42
|
-
yearSelectLabel:
|
|
42
|
+
selectedDate: l,
|
|
43
|
+
yearSelectLabel: b = "Year",
|
|
43
44
|
/**
|
|
44
45
|
* Combobox props
|
|
45
46
|
*/
|
|
46
|
-
error:
|
|
47
|
-
id:
|
|
48
|
-
disabled:
|
|
49
|
-
placeholder:
|
|
50
|
-
required:
|
|
51
|
-
onClear:
|
|
52
|
-
clearLabel:
|
|
53
|
-
size:
|
|
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:
|
|
59
|
+
ariaLabel: h,
|
|
59
60
|
/**
|
|
60
61
|
* @preserve
|
|
61
62
|
* @deprecated This is no longer used.
|
|
62
63
|
*/
|
|
63
|
-
selectedDateLabel:
|
|
64
|
-
...
|
|
65
|
-
},
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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
|
-
}), [
|
|
78
|
-
const
|
|
79
|
-
let
|
|
80
|
-
return
|
|
81
|
-
}, [
|
|
82
|
-
currentValue:
|
|
83
|
-
minDate:
|
|
84
|
-
maxDate:
|
|
85
|
-
})),
|
|
86
|
-
|
|
87
|
-
}, De =
|
|
88
|
-
|
|
89
|
-
}, [
|
|
90
|
-
|
|
91
|
-
if (
|
|
92
|
-
const
|
|
93
|
-
|
|
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
|
-
|
|
96
|
-
}, [$,
|
|
97
|
-
if (n &&
|
|
98
|
-
const
|
|
99
|
-
|
|
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
|
-
}, [
|
|
102
|
-
const
|
|
103
|
-
return
|
|
104
|
-
}),
|
|
105
|
-
const t =
|
|
106
|
-
return e || (
|
|
107
|
-
},
|
|
108
|
-
const
|
|
109
|
-
|
|
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
|
|
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:
|
|
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:
|
|
123
|
-
|
|
124
|
-
}), onPointerDown:
|
|
125
|
-
const
|
|
126
|
-
|
|
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
|
-
}),
|
|
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 }) =>
|
|
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 }) =>
|
|
145
|
-
`,
|
|
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
|
-
`,
|
|
156
|
+
`, nt = I(Fe)`
|
|
157
157
|
& > path {
|
|
158
158
|
fill: ${({ theme: e }) => e.colors.neutral500};
|
|
159
159
|
}
|
|
160
|
-
`,
|
|
161
|
-
const t =
|
|
162
|
-
|
|
163
|
-
}
|
|
164
|
-
|
|
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.
|
|
170
|
-
}), onChange:
|
|
171
|
-
if (
|
|
172
|
-
const
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
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
|
-
|
|
179
|
-
const
|
|
180
|
-
month:
|
|
181
|
-
}),
|
|
182
|
-
day:
|
|
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(
|
|
208
|
+
t.onCalendarDateChange(it(q, t.minDate, t.maxDate)), t.onTextValueChange(d.target.value);
|
|
185
209
|
}
|
|
186
|
-
}), onKeyDown:
|
|
187
|
-
if (!t.open && (
|
|
188
|
-
|
|
189
|
-
else if (["Tab"].includes(
|
|
190
|
-
|
|
191
|
-
else if (["Escape"].includes(
|
|
192
|
-
t.open ? t.onOpenChange(!1) : (t.onValueChange(void 0), t.onTextValueChange("")),
|
|
193
|
-
else if (t.open && ["ArrowDown", "ArrowUp", "ArrowLeft", "ArrowRight"].includes(
|
|
194
|
-
switch (
|
|
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
|
|
197
|
-
if (t.maxDate &&
|
|
220
|
+
const h = t.calendarDate.add({ weeks: 1 });
|
|
221
|
+
if (t.maxDate && h.compare(t.maxDate) > 0)
|
|
198
222
|
return;
|
|
199
|
-
t.onCalendarDateChange(
|
|
223
|
+
t.onCalendarDateChange(h);
|
|
200
224
|
return;
|
|
201
225
|
}
|
|
202
226
|
case "ArrowRight": {
|
|
203
|
-
const
|
|
204
|
-
if (t.maxDate &&
|
|
227
|
+
const h = t.calendarDate.add({ days: 1 });
|
|
228
|
+
if (t.maxDate && h.compare(t.maxDate) > 0)
|
|
205
229
|
return;
|
|
206
|
-
t.onCalendarDateChange(
|
|
230
|
+
t.onCalendarDateChange(h);
|
|
207
231
|
return;
|
|
208
232
|
}
|
|
209
233
|
case "ArrowUp": {
|
|
210
|
-
const
|
|
211
|
-
if (t.minDate &&
|
|
234
|
+
const h = t.calendarDate.subtract({ weeks: 1 });
|
|
235
|
+
if (t.minDate && h.compare(t.minDate) < 0)
|
|
212
236
|
return;
|
|
213
|
-
t.onCalendarDateChange(
|
|
237
|
+
t.onCalendarDateChange(h);
|
|
214
238
|
return;
|
|
215
239
|
}
|
|
216
240
|
case "ArrowLeft": {
|
|
217
|
-
const
|
|
218
|
-
if (t.minDate &&
|
|
241
|
+
const h = t.calendarDate.subtract({ days: 1 });
|
|
242
|
+
if (t.minDate && h.compare(t.minDate) < 0)
|
|
219
243
|
return;
|
|
220
|
-
t.onCalendarDateChange(
|
|
244
|
+
t.onCalendarDateChange(h);
|
|
221
245
|
}
|
|
222
246
|
}
|
|
223
247
|
else
|
|
224
|
-
t.open && ["Enter"].includes(
|
|
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
|
|
228
|
-
return r && (e =
|
|
251
|
+
function it(e, r, n) {
|
|
252
|
+
return r && (e = X(e, r)), n && (e = H(e, n)), e;
|
|
229
253
|
}
|
|
230
|
-
const
|
|
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
|
-
`,
|
|
246
|
-
const [n, t] =
|
|
247
|
-
if (
|
|
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
|
-
}, []), !
|
|
250
|
-
const
|
|
251
|
-
return
|
|
273
|
+
}, []), !a.open) {
|
|
274
|
+
const s = n;
|
|
275
|
+
return s ? Le(i("div", { children: e.children }), s) : null;
|
|
252
276
|
}
|
|
253
|
-
return
|
|
254
|
-
}),
|
|
255
|
-
const { label: n = "Choose date", ...t } = e, { onOpenChange:
|
|
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
|
-
|
|
283
|
+
we({
|
|
260
284
|
mainAxis: 4
|
|
261
285
|
}),
|
|
262
|
-
|
|
286
|
+
xe(),
|
|
263
287
|
ke()
|
|
264
288
|
],
|
|
265
289
|
whileElementsMounted: Te
|
|
266
290
|
});
|
|
267
|
-
|
|
268
|
-
const
|
|
269
|
-
|
|
291
|
+
c.useEffect(() => {
|
|
292
|
+
const m = () => {
|
|
293
|
+
a(!1);
|
|
270
294
|
};
|
|
271
|
-
return window.addEventListener("blur",
|
|
272
|
-
window.removeEventListener("blur",
|
|
295
|
+
return window.addEventListener("blur", m), window.addEventListener("resize", m), () => {
|
|
296
|
+
window.removeEventListener("blur", m), window.removeEventListener("resize", m);
|
|
273
297
|
};
|
|
274
|
-
}, [
|
|
275
|
-
|
|
276
|
-
}, [
|
|
277
|
-
const
|
|
278
|
-
return
|
|
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: (
|
|
283
|
-
|
|
306
|
+
onFocusOutside: (m) => {
|
|
307
|
+
m.preventDefault();
|
|
284
308
|
},
|
|
285
309
|
onDismiss: () => {
|
|
286
|
-
|
|
310
|
+
a(!1);
|
|
287
311
|
},
|
|
288
|
-
children:
|
|
289
|
-
left:
|
|
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:
|
|
315
|
+
position: x
|
|
292
316
|
}, hasRadius: !0, background: "neutral0", padding: 1, ...t })
|
|
293
317
|
}) });
|
|
294
|
-
}),
|
|
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
|
-
`,
|
|
299
|
-
const { locale:
|
|
300
|
-
const
|
|
301
|
-
return [...Array(
|
|
302
|
-
}, [
|
|
303
|
-
let
|
|
304
|
-
return [...new Array(7).keys()].map((
|
|
305
|
-
let
|
|
306
|
-
return
|
|
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
|
-
}, [
|
|
309
|
-
if (typeof
|
|
332
|
+
}, [s, a, w]), P = (o) => {
|
|
333
|
+
if (typeof o == "number")
|
|
310
334
|
return;
|
|
311
|
-
const
|
|
312
|
-
|
|
313
|
-
},
|
|
314
|
-
if (typeof
|
|
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
|
|
317
|
-
|
|
318
|
-
},
|
|
319
|
-
return
|
|
320
|
-
}),
|
|
321
|
-
let t = e.add({ weeks: n }),
|
|
322
|
-
t =
|
|
323
|
-
let
|
|
324
|
-
for (let
|
|
325
|
-
|
|
326
|
-
for (;
|
|
327
|
-
|
|
328
|
-
let
|
|
329
|
-
if (
|
|
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 =
|
|
355
|
+
t = g;
|
|
332
356
|
}
|
|
333
|
-
for (;
|
|
334
|
-
|
|
335
|
-
return
|
|
336
|
-
},
|
|
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
|
-
${
|
|
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
|
-
`,
|
|
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
|
-
`,
|
|
361
|
-
const { timeZone:
|
|
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
|
-
}),
|
|
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
|
-
}),
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
}),
|
|
374
|
-
|
|
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
|
-
& > ${
|
|
411
|
+
& > ${B} {
|
|
384
412
|
color: ${({ theme: e }) => e.colors.primary600};
|
|
385
413
|
}
|
|
386
414
|
}
|
|
387
|
-
`,
|
|
388
|
-
const { error: n, hint: t, id:
|
|
389
|
-
return
|
|
390
|
-
}),
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
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
|
-
|
|
396
|
-
|
|
428
|
+
Xt as DatePicker,
|
|
429
|
+
Xe as DatePickerInput
|
|
397
430
|
};
|