@strapi/design-system 1.7.9 → 1.8.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.
- package/README.md +9 -17
- package/dist/Alert/Alert.cjs +23 -29
- package/dist/Alert/Alert.js +33 -39
- package/dist/Alert/utils.cjs +1 -1
- package/dist/Alert/utils.js +14 -3
- package/dist/Button/Button.cjs +9 -4
- package/dist/Button/Button.js +28 -23
- package/dist/CarouselInput/CarouselImage.cjs +1 -1
- package/dist/CarouselInput/CarouselImage.js +3 -3
- package/dist/CarouselInput/CarouselSlide.cjs +1 -1
- package/dist/CarouselInput/CarouselSlide.js +2 -2
- package/dist/Combobox/Combobox.cjs +14 -13
- package/dist/Combobox/Combobox.js +73 -68
- package/dist/DatePicker/DatePicker.cjs +82 -6
- package/dist/DatePicker/DatePicker.js +381 -55
- package/dist/DateTimePicker/DateTimePicker.cjs +7 -1
- package/dist/DateTimePicker/DateTimePicker.js +91 -53
- package/dist/DateTimePicker/index.cjs +1 -1
- package/dist/DateTimePicker/index.js +3 -2
- package/dist/DesignSystemProvider.cjs +1 -0
- package/dist/DesignSystemProvider.js +10 -0
- package/dist/Flex/Flex.cjs +1 -1
- package/dist/Flex/Flex.js +1 -1
- package/dist/NumberInput/NumberInput.cjs +2 -2
- package/dist/NumberInput/NumberInput.js +40 -40
- package/dist/Popover/Popover.cjs +3 -4
- package/dist/Popover/Popover.js +46 -48
- package/dist/Popover/index.cjs +1 -1
- package/dist/Popover/index.js +5 -9
- package/dist/Popover/primitives.cjs +1 -0
- package/dist/Popover/primitives.js +5 -0
- package/dist/Searchbar/Searchbar.cjs +2 -2
- package/dist/Searchbar/Searchbar.js +5 -5
- package/dist/Select/SelectParts.cjs +1 -1
- package/dist/Select/SelectParts.js +1 -1
- package/dist/Select/SingleSelect.cjs +1 -1
- package/dist/Select/SingleSelect.js +36 -32
- package/dist/TextInput/TextInput.cjs +1 -1
- package/dist/TextInput/TextInput.js +5 -5
- package/dist/ThemeProvider/ThemeProvider.cjs +2 -2
- package/dist/ThemeProvider/ThemeProvider.js +4 -3
- package/dist/TimePicker/TimePicker.cjs +5 -7
- package/dist/TimePicker/TimePicker.js +79 -33
- package/dist/TimePicker/index.cjs +1 -1
- package/dist/TimePicker/index.js +3 -2
- package/dist/helpers/context.cjs +1 -0
- package/dist/helpers/context.js +21 -0
- package/dist/helpers/getDefaultLocale.cjs +4 -1
- package/dist/helpers/getDefaultLocale.js +7 -2
- package/dist/hooks/useDateFormatter.cjs +1 -0
- package/dist/hooks/useDateFormatter.js +20 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +309 -304
- package/package.json +6 -5
- package/dist/DatePicker/DatePickerCalendar.cjs +0 -1
- package/dist/DatePicker/DatePickerCalendar.js +0 -43
- package/dist/DatePicker/DatePickerTd.cjs +0 -19
- package/dist/DatePicker/DatePickerTd.js +0 -29
- package/dist/DatePicker/DatePickerTh.cjs +0 -9
- package/dist/DatePicker/DatePickerTh.js +0 -18
- package/dist/DatePicker/compareDates.cjs +0 -1
- package/dist/DatePicker/compareDates.js +0 -4
- package/dist/DatePicker/components.cjs +0 -39
- package/dist/DatePicker/components.js +0 -53
- package/dist/DatePicker/utils/formatDate.cjs +0 -1
- package/dist/DatePicker/utils/formatDate.js +0 -4
- package/dist/DatePicker/utils/generateWeeks.cjs +0 -1
- package/dist/DatePicker/utils/generateWeeks.js +0 -17
- package/dist/DatePicker/utils/getDayOfWeek.cjs +0 -1
- package/dist/DatePicker/utils/getDayOfWeek.js +0 -15
- package/dist/DatePicker/utils/getMonths.cjs +0 -1
- package/dist/DatePicker/utils/getMonths.js +0 -7
- package/dist/DatePicker/utils/getYears.cjs +0 -1
- package/dist/DatePicker/utils/getYears.js +0 -9
- package/dist/DatePicker/utils/index.cjs +0 -1
- package/dist/DatePicker/utils/index.js +0 -12
- package/dist/DateTimePicker/parseDate.cjs +0 -1
- package/dist/DateTimePicker/parseDate.js +0 -8
|
@@ -1,62 +1,65 @@
|
|
|
1
|
-
import { jsx as r, jsxs as
|
|
2
|
-
import * as
|
|
3
|
-
import { Cross as
|
|
4
|
-
import { Combobox as
|
|
1
|
+
import { jsx as r, jsxs as d } from "react/jsx-runtime";
|
|
2
|
+
import * as f from "react";
|
|
3
|
+
import { Cross as me, CarretDown as ge } from "@strapi/icons";
|
|
4
|
+
import { Combobox as n } from "@strapi/ui-primitives";
|
|
5
5
|
import l from "styled-components";
|
|
6
|
-
import { stripReactIdOfColon as
|
|
6
|
+
import { stripReactIdOfColon as be } from "../helpers/strings.js";
|
|
7
7
|
import { useControllableState as I } from "../hooks/useControllableState.js";
|
|
8
|
-
import { useId as
|
|
9
|
-
import { useIntersection as
|
|
10
|
-
import { inputFocusStyle as
|
|
11
|
-
import { Loader as
|
|
12
|
-
import { Box as
|
|
13
|
-
import { Typography as
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import { FieldLabel as
|
|
17
|
-
import { FieldHint as
|
|
18
|
-
import { FieldError as
|
|
19
|
-
const
|
|
20
|
-
const [
|
|
21
|
-
prop:
|
|
22
|
-
defaultProp:
|
|
23
|
-
onChange:
|
|
24
|
-
}), [
|
|
25
|
-
prop:
|
|
26
|
-
defaultProp:
|
|
27
|
-
onChange: Y
|
|
28
|
-
}), [ee, P] = I({
|
|
29
|
-
prop: W,
|
|
30
|
-
defaultProp: m,
|
|
8
|
+
import { useId as w } from "../hooks/useId.js";
|
|
9
|
+
import { useIntersection as $e } from "../hooks/useIntersection.js";
|
|
10
|
+
import { getThemeSize as Ce, inputFocusStyle as xe } from "../themes/utils.js";
|
|
11
|
+
import { Loader as Ie } from "../Loader/Loader.js";
|
|
12
|
+
import { Box as R } from "../Box/Box.js";
|
|
13
|
+
import { Typography as h } from "../Typography/Typography.js";
|
|
14
|
+
import { Flex as m } from "../Flex/Flex.js";
|
|
15
|
+
import { Field as we } from "../Field/Field.js";
|
|
16
|
+
import { FieldLabel as Re } from "../Field/FieldLabel.js";
|
|
17
|
+
import { FieldHint as ve } from "../Field/FieldHint.js";
|
|
18
|
+
import { FieldError as ye } from "../Field/FieldError.js";
|
|
19
|
+
const ke = ({ allowCustomValue: e, autocomplete: o, children: c, className: u, clearLabel: a = "clear", creatable: i = !1, createMessage: g = (x) => `Create "${x}"`, defaultFilterValue: p, defaultTextValue: y, defaultOpen: W = !1, open: L, onOpenChange: U, disabled: b = !1, error: k, filterValue: A, hasMoreItems: G = !1, id: V, isPrintableCharacter: J, loading: $ = !1, loadingMessage: K = "Loading content...", noOptionsMessage: M = () => "No results found", onChange: T, onClear: C, onCreateOption: F, onFilterValueChange: Q, onInputChange: O, onTextValueChange: X, onLoadMore: z, placeholder: Y = "Select or enter a value", required: Z = !1, size: _ = "M", startIcon: B, textValue: ee, value: P, ...re }) => {
|
|
20
|
+
const [x, oe] = I({
|
|
21
|
+
prop: L,
|
|
22
|
+
defaultProp: W,
|
|
23
|
+
onChange: U
|
|
24
|
+
}), [s, S] = I({
|
|
25
|
+
prop: ee,
|
|
26
|
+
defaultProp: e && !y ? P : y,
|
|
31
27
|
onChange: X
|
|
32
|
-
}),
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}, ne = (
|
|
37
|
-
|
|
38
|
-
}, le = (
|
|
39
|
-
|
|
40
|
-
},
|
|
41
|
-
|
|
42
|
-
},
|
|
43
|
-
|
|
44
|
-
},
|
|
45
|
-
|
|
46
|
-
},
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
28
|
+
}), [te, j] = I({
|
|
29
|
+
prop: A,
|
|
30
|
+
defaultProp: p,
|
|
31
|
+
onChange: Q
|
|
32
|
+
}), E = f.useRef(null), q = f.useRef(null), ne = f.useRef(null), ie = (t) => {
|
|
33
|
+
C && !b && (S(""), j(""), C(t), q.current.focus());
|
|
34
|
+
}, le = (t) => {
|
|
35
|
+
oe(t);
|
|
36
|
+
}, ae = (t) => {
|
|
37
|
+
S(t);
|
|
38
|
+
}, se = (t) => {
|
|
39
|
+
j(t);
|
|
40
|
+
}, de = (t) => {
|
|
41
|
+
O && O(t);
|
|
42
|
+
}, ce = (t) => {
|
|
43
|
+
T && T(t);
|
|
44
|
+
}, ue = (t) => {
|
|
45
|
+
z && G && !$ && z(t);
|
|
46
|
+
}, N = () => {
|
|
47
|
+
F && s && F(s);
|
|
48
|
+
}, D = w(V), he = w(), H = `intersection-${be(he)}`;
|
|
49
|
+
$e(E, ue, {
|
|
50
|
+
selectorToWatch: `#${H}`,
|
|
51
51
|
/**
|
|
52
52
|
* We need to know when the select is open because only then will viewportRef
|
|
53
53
|
* not be null. Because it uses a portal that (sensibly) is not mounted 24/7.
|
|
54
54
|
*/
|
|
55
|
-
skipWhen: !
|
|
55
|
+
skipWhen: !x
|
|
56
56
|
});
|
|
57
|
-
const
|
|
58
|
-
return
|
|
59
|
-
},
|
|
57
|
+
const pe = `${D}-hint`, fe = `${D}-error`;
|
|
58
|
+
return d(n.Root, { autocomplete: o || (i ? "list" : "both"), onOpenChange: le, onTextValueChange: ae, textValue: s, allowCustomValue: i || e, disabled: b, required: Z, value: P, onValueChange: ce, filterValue: te, onFilterValueChange: se, isPrintableCharacter: J, children: [d(Fe, { $hasError: !!k, $size: _, className: u, children: [d(m, { flex: "1", as: "span", gap: 3, children: [B ? r(R, { as: "span", "aria-hidden": !0, children: B }) : null, r(Oe, { placeholder: Y, id: V, "aria-invalid": !!k, "aria-describedby": `${pe} ${fe}`, onChange: de, ref: q, ...re })] }), d(m, { as: "span", gap: 3, children: [s && C ? r(Te, { as: "button", hasRadius: !0, background: "transparent", type: "button", onClick: ie, "aria-disabled": b, "aria-label": a, title: a, ref: ne, children: r(me, {}) }) : null, r(ze, { children: r(ge, {}) })] })] }), r(n.Portal, { children: r(Be, { sideOffset: 4, children: d(Pe, { ref: E, children: [c, i ? r(n.CreateItem, { onPointerUp: N, onClick: N, asChild: !0, children: r(v, { children: r(h, { children: g(s ?? "") }) }) }) : null, !i && !$ ? r(n.NoValueFound, { asChild: !0, children: r(v, { $hasHover: !1, children: r(h, { children: M(s ?? "") }) }) }) : null, $ ? r(m, { justifyContent: "center", alignItems: "center", paddingTop: 2, paddingBottom: 2, children: r(Ie, { small: !0, children: K }) }) : null, r(R, { id: H, width: "100%", height: "1px" })] }) }) })] });
|
|
59
|
+
}, Ve = ({ error: e, hint: o, id: c, label: u, labelAction: a, required: i = !1, ...g }) => {
|
|
60
|
+
const p = w(c);
|
|
61
|
+
return r(we, { hint: o, error: e, id: p, required: i, children: d(m, { direction: "column", alignItems: "stretch", gap: 1, children: [r(Re, { action: a, children: u }), r(ke, { id: p, error: e, required: i, ...g }), r(ve, {}), r(ye, {})] }) });
|
|
62
|
+
}, Ye = (e) => r(Ve, { ...e, creatable: !0 }), Te = l(R)`
|
|
60
63
|
border: none;
|
|
61
64
|
|
|
62
65
|
svg {
|
|
@@ -67,9 +70,9 @@ const we = ({ children: e, clearLabel: n = "clear", creatable: s = !1, createMes
|
|
|
67
70
|
svg path {
|
|
68
71
|
fill: ${({ theme: e }) => e.colors.neutral600};
|
|
69
72
|
}
|
|
70
|
-
`,
|
|
73
|
+
`, Fe = l(n.Trigger)`
|
|
71
74
|
position: relative;
|
|
72
|
-
border: 1px solid ${({ theme: e, $hasError:
|
|
75
|
+
border: 1px solid ${({ theme: e, $hasError: o }) => o ? e.colors.danger600 : e.colors.neutral200};
|
|
73
76
|
padding-right: ${({ theme: e }) => e.spaces[3]};
|
|
74
77
|
padding-left: ${({ theme: e }) => e.spaces[3]};
|
|
75
78
|
border-radius: ${({ theme: e }) => e.borderRadius};
|
|
@@ -79,6 +82,7 @@ const we = ({ children: e, clearLabel: n = "clear", creatable: s = !1, createMes
|
|
|
79
82
|
align-items: center;
|
|
80
83
|
justify-content: space-between;
|
|
81
84
|
gap: ${({ theme: e }) => e.spaces[4]};
|
|
85
|
+
min-height: ${({ theme: e, $size: o }) => Ce("input")({ theme: e, size: o })};
|
|
82
86
|
|
|
83
87
|
&[data-disabled] {
|
|
84
88
|
color: ${({ theme: e }) => e.colors.neutral600};
|
|
@@ -91,12 +95,12 @@ const we = ({ children: e, clearLabel: n = "clear", creatable: s = !1, createMes
|
|
|
91
95
|
outline: none;
|
|
92
96
|
}
|
|
93
97
|
|
|
94
|
-
${({ theme: e, $hasError:
|
|
95
|
-
`,
|
|
98
|
+
${({ theme: e, $hasError: o }) => xe()({ theme: e, hasError: o })};
|
|
99
|
+
`, Oe = l(n.TextInput)`
|
|
96
100
|
width: 100%;
|
|
97
101
|
font-size: ${14 / 16}rem;
|
|
98
102
|
color: ${({ theme: e }) => e.colors.neutral800};
|
|
99
|
-
|
|
103
|
+
padding: 0;
|
|
100
104
|
border: none;
|
|
101
105
|
background-color: transparent;
|
|
102
106
|
|
|
@@ -107,7 +111,7 @@ const we = ({ children: e, clearLabel: n = "clear", creatable: s = !1, createMes
|
|
|
107
111
|
&[aria-disabled='true'] {
|
|
108
112
|
cursor: inherit;
|
|
109
113
|
}
|
|
110
|
-
`,
|
|
114
|
+
`, ze = l(n.Icon)`
|
|
111
115
|
& > svg {
|
|
112
116
|
width: ${6 / 16}rem;
|
|
113
117
|
|
|
@@ -119,7 +123,7 @@ const we = ({ children: e, clearLabel: n = "clear", creatable: s = !1, createMes
|
|
|
119
123
|
&[aria-disabled='true'] {
|
|
120
124
|
cursor: inherit;
|
|
121
125
|
}
|
|
122
|
-
`,
|
|
126
|
+
`, Be = l(n.Content)`
|
|
123
127
|
background: ${({ theme: e }) => e.colors.neutral0};
|
|
124
128
|
box-shadow: ${({ theme: e }) => e.shadows.filterShadow};
|
|
125
129
|
border: 1px solid ${({ theme: e }) => e.colors.neutral150};
|
|
@@ -128,9 +132,9 @@ const we = ({ children: e, clearLabel: n = "clear", creatable: s = !1, createMes
|
|
|
128
132
|
/* This is from the design-system figma file. */
|
|
129
133
|
max-height: 15rem;
|
|
130
134
|
z-index: ${({ theme: e }) => e.zIndices[1]};
|
|
131
|
-
`,
|
|
135
|
+
`, Pe = l(n.Viewport)`
|
|
132
136
|
padding: ${({ theme: e }) => e.spaces[1]};
|
|
133
|
-
`,
|
|
137
|
+
`, Ze = f.forwardRef(({ children: e, value: o, disabled: c, textValue: u, ...a }, i) => r(n.ComboboxItem, { asChild: !0, value: o, disabled: c, textValue: u, children: r(v, { ref: i, ...a, children: r(n.ItemText, { asChild: !0, children: r(h, { children: e }) }) }) })), v = l.div`
|
|
134
138
|
width: 100%;
|
|
135
139
|
border: none;
|
|
136
140
|
text-align: left;
|
|
@@ -140,10 +144,10 @@ const we = ({ children: e, clearLabel: n = "clear", creatable: s = !1, createMes
|
|
|
140
144
|
border-radius: ${({ theme: e }) => e.borderRadius};
|
|
141
145
|
user-select: none;
|
|
142
146
|
|
|
143
|
-
&[data-
|
|
147
|
+
&[data-state='checked'] {
|
|
144
148
|
background-color: ${({ theme: e }) => e.colors.primary100};
|
|
145
149
|
|
|
146
|
-
${
|
|
150
|
+
${h} {
|
|
147
151
|
color: ${({ theme: e }) => e.colors.primary600};
|
|
148
152
|
font-weight: bold;
|
|
149
153
|
}
|
|
@@ -152,19 +156,20 @@ const we = ({ children: e, clearLabel: n = "clear", creatable: s = !1, createMes
|
|
|
152
156
|
&:hover,
|
|
153
157
|
&[data-highlighted] {
|
|
154
158
|
outline: none;
|
|
155
|
-
background-color: ${({ theme: e, $hasHover:
|
|
159
|
+
background-color: ${({ theme: e, $hasHover: o = !0 }) => o ? e.colors.primary100 : e.colors.neutral0};
|
|
156
160
|
}
|
|
157
161
|
|
|
158
162
|
&[data-highlighted] {
|
|
159
|
-
${
|
|
163
|
+
${h} {
|
|
160
164
|
color: ${({ theme: e }) => e.colors.primary600};
|
|
161
165
|
font-weight: bold;
|
|
162
166
|
}
|
|
163
167
|
}
|
|
164
168
|
`;
|
|
165
169
|
export {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
+
Ve as Combobox,
|
|
171
|
+
ke as ComboboxInput,
|
|
172
|
+
Ye as CreatableCombobox,
|
|
173
|
+
Ze as Option,
|
|
174
|
+
v as OptionBox
|
|
170
175
|
};
|
|
@@ -1,12 +1,88 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),xe=require("react"),O=require("@floating-ui/react-dom"),g=require("@internationalized/date"),Ce=require("@radix-ui/react-focus-guards"),ye=require("@radix-ui/react-focus-scope"),ee=require("@strapi/icons"),R=require("@strapi/ui-primitives"),be=require("react-dom"),we=require("react-remove-scroll"),ke=require("styled-components"),Te=require("../DesignSystemProvider.cjs"),Se=require("../DismissibleLayer/index.cjs"),je=require("../helpers/context.cjs"),U=require("../hooks/useComposeRefs.cjs"),Ee=require("../hooks/useControllableState.cjs"),L=require("../hooks/useDateFormatter.cjs"),te=require("../hooks/useId.cjs"),N=require("../Select/SingleSelect.cjs"),Pe=require("../Portal/Portal.cjs"),V=require("../Flex/Flex.cjs"),X=require("../themes/utils.cjs"),z=require("../Box/Box.cjs"),Y=require("../Typography/Typography.cjs"),Ie=require("../Field/Field.cjs"),Re=require("../Field/FieldLabel.cjs"),ve=require("../Field/FieldHint.cjs"),Fe=require("../Field/FieldError.cjs"),Ae=e=>e&&e.__esModule?e:{default:e};function Me(e){if(e&&e.__esModule)return e;const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const t=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,t.get?t:{enumerable:!0,get:()=>e[r]})}}return n.default=e,Object.freeze(n)}const u=Me(xe),j=Ae(ke),qe=200,J=15,[_e,v]=je.createContext("DatePicker"),re=u.forwardRef(({calendarLabel:e,className:n,initialDate:r,locale:t,maxDate:s,minDate:c,monthSelectLabel:p="Month",onChange:d,selectedDate:i,yearSelectLabel:m="Year",error:y,id:C,disabled:o=!1,placeholder:f,required:b=!1,onClear:x,clearLabel:T="Clear",size:w,ariaLabel:S,selectedDateLabel:l,...h},k)=>{const F=Te.useDesignSystem("DatePicker"),P=t??F.locale,B=L.useDateFormatter(P,{dateStyle:"short"}),A=u.useMemo(()=>{const D=B.formatToParts(new Date),{value:I}=D.find(_=>_.type==="literal");return I},[B]),[ae,oe]=u.useState(!1),[se,le]=u.useState(null),[W,ie]=u.useState(null),[ce,ue]=u.useState(null),[$,M]=u.useState(),[q,H]=Ee.useControllableState({defaultProp:r?E(r):void 0,prop:i&&E(i),onChange(D){d&&d(D?.toDate("UTC"))}}),[G,K]=u.useMemo(()=>{const D=r?E(r):g.today("UTC"),I=c?E(c):D.set({day:1,month:1,year:D.year-qe});let _=s?E(s):D.set({day:31,month:12,year:D.year+J});return _.compare(I)<0&&(_=I.set({day:31,month:12,year:I.year+J})),[I,_]},[c,s,r]),[de,Z]=u.useState(Oe({currentValue:q,minDate:G,maxDate:K})),fe=te.useId(),he=u.useRef(null),pe=D=>{x&&!o&&(M(""),H(void 0),x(D),W?.focus())},ge=u.useCallback(D=>{D&&q&&Z(q),oe(D)},[q]);u.useLayoutEffect(()=>{if(i){const D=E(i);M(D.toString().split("-").reverse().join(A))}else M("")},[A,i]),u.useLayoutEffect(()=>{if(r&&$===void 0){const D=E(r);M(D.toString().split("-").reverse().join(A))}},[A,r,$]);const me=`${C}-hint`,De=`${C}-error`;return a.jsxs(_e,{calendarDate:de,content:ce,contentId:fe,disabled:o,locale:P,minDate:G,maxDate:K,open:ae,onCalendarDateChange:Z,onContentChange:ue,onOpenChange:ge,onTextInputChange:ie,onTextValueChange:M,onTriggerChange:le,onValueChange:H,required:b,separator:A,textInput:W,textValue:$,timeZone:"UTC",trigger:se,value:q,children:[a.jsxs($e,{className:n,size:w,hasError:!!y,children:[a.jsx(ze,{"aria-hidden":!0}),a.jsx(Ue,{ref:k,placeholder:f,"aria-describedby":`${me} ${De}`,id:C,...h}),$&&x?a.jsx(Ve,{as:"button",hasRadius:!0,background:"transparent",type:"button",onClick:pe,"aria-disabled":o,"aria-label":T,title:T,ref:he,children:a.jsx(ee.Cross,{})}):null]}),a.jsx(Pe.Portal,{children:a.jsx(Ge,{label:e,children:a.jsx(Qe,{monthSelectLabel:p,yearSelectLabel:m})})})]})}),Q=e=>!!e.match(/^[^a-zA-Z]*$/),Oe=({currentValue:e,minDate:n,maxDate:r})=>{const t=g.today("UTC");return e||(g.minDate(n,t)===n&&g.maxDate(r,t)===r?t:g.minDate(n,t)===t?n:g.maxDate(r,t)===t?r:t)},Le="DatePickerTrigger",$e=u.forwardRef(({hasError:e,size:n="M",...r},t)=>{const s=v(Le),c=U.useComposedRefs(t,d=>s.onTriggerChange(d)),p=()=>{s.disabled||s.onOpenChange(!0)};return a.jsx(ye.FocusScope,{asChild:!0,trapped:s.open,onMountAutoFocus:d=>{d.preventDefault()},onUnmountAutoFocus:d=>{document.getSelection()?.empty(),d.preventDefault()},children:a.jsx(Ne,{ref:c,$hasError:e,$size:n,...r,paddingLeft:3,paddingRight:3,hasRadius:!0,gap:3,overflow:"hidden",background:s.disabled?"neutral150":"neutral0",onClick:R.composeEventHandlers(r.onClick,()=>{s.textInput?.focus()}),onPointerDown:R.composeEventHandlers(r.onPointerDown,d=>{const i=d.target;i.hasPointerCapture(d.pointerId)&&i.releasePointerCapture(d.pointerId),(i.closest("button")??i.closest("div"))===d.currentTarget&&d.button===0&&d.ctrlKey===!1&&(p(),s.textInput?.focus())})})})}),Ne=j.default(V.Flex)`
|
|
2
|
+
border: 1px solid ${({theme:e,$hasError:n})=>n?e.colors.danger600:e.colors.neutral200};
|
|
3
|
+
min-height: ${({theme:e,$size:n})=>X.getThemeSize("input")({theme:e,size:n})};
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
&[data-disabled] {
|
|
6
|
+
color: ${({theme:e})=>e.colors.neutral600};
|
|
7
|
+
background: ${({theme:e})=>e.colors.neutral150};
|
|
8
|
+
cursor: not-allowed;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/* Required to ensure the below inputFocusStyles are adhered too */
|
|
12
|
+
&:focus-visible {
|
|
13
|
+
outline: none;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
${({theme:e,$hasError:n})=>X.inputFocusStyle()({theme:e,hasError:n})};
|
|
17
|
+
`,Ve=j.default(z.Box)`
|
|
18
|
+
border: none;
|
|
19
|
+
|
|
20
|
+
svg {
|
|
21
|
+
height: ${11/16}rem;
|
|
22
|
+
width: ${11/16}rem;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
svg path {
|
|
6
26
|
fill: ${({theme:e})=>e.colors.neutral600};
|
|
7
27
|
}
|
|
8
|
-
`,
|
|
28
|
+
`,ze=j.default(ee.Calendar)`
|
|
9
29
|
& > path {
|
|
10
30
|
fill: ${({theme:e})=>e.colors.neutral500};
|
|
11
31
|
}
|
|
12
|
-
|
|
32
|
+
`,Ye="DatePickerTextInput",Ue=u.forwardRef(({placeholder:e,...n},r)=>{const t=v(Ye),{onTextValueChange:s,textValue:c,onTextInputChange:p,onOpenChange:d,disabled:i,separator:m}=t,y=U.useComposedRefs(r,o=>p(o)),C=()=>{i||d(!0)};return a.jsx(We,{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}${m}\\d{2}${m}\\d{4}`,placeholder:e??`DD${m}MM${m}YYYY`,...n,value:c??"",onBlur:R.composeEventHandlers(n.onBlur,()=>{if(!t.textValue){t.onValueChange(void 0);return}t.onTextValueChange(t.calendarDate.toString().split("-").reverse().join(m)),t.onValueChange(t.calendarDate)}),onChange:R.composeEventHandlers(n.onChange,o=>{if(Q(o.target.value)){const[f,b,x]=o.target.value.split(m),T=t.calendarDate.year;let w=t.calendarDate.year;if(x){let P=x.length===1?`0${x}`:x;w=x.length<3?Number(`${T}`.slice(0,4-P.length)+P):Number(P)}x&&x.length<3&&w>t.maxDate.year&&(w-=100);const S=t.calendarDate.set({year:w}),l=S.calendar.getMonthsInYear(S),h=S.set({month:b&&Number(b)<=l?Number(b):void 0}),k=h.calendar.getDaysInMonth(h),F=h.set({day:f&&Number(f)<=k?Number(f):void 0});t.onCalendarDateChange(Be(F,t.minDate,t.maxDate)),t.onTextValueChange(o.target.value)}}),onKeyDown:R.composeEventHandlers(n.onKeyDown,o=>{if(!t.open&&(Q(o.key)||["ArrowDown","Backspace"].includes(o.key)))C();else if(["Tab"].includes(o.key)&&t.open)o.preventDefault();else if(["Escape"].includes(o.key))t.open?t.onOpenChange(!1):(t.onValueChange(void 0),t.onTextValueChange("")),o.preventDefault();else if(t.open&&["ArrowDown","ArrowUp","ArrowLeft","ArrowRight"].includes(o.key))switch(o.preventDefault(),o.key){case"ArrowDown":{const f=t.calendarDate.add({weeks:1});if(t.maxDate&&f.compare(t.maxDate)>0)return;t.onCalendarDateChange(f);return}case"ArrowRight":{const f=t.calendarDate.add({days:1});if(t.maxDate&&f.compare(t.maxDate)>0)return;t.onCalendarDateChange(f);return}case"ArrowUp":{const f=t.calendarDate.subtract({weeks:1});if(t.minDate&&f.compare(t.minDate)<0)return;t.onCalendarDateChange(f);return}case"ArrowLeft":{const f=t.calendarDate.subtract({days:1});if(t.minDate&&f.compare(t.minDate)<0)return;t.onCalendarDateChange(f)}}else t.open&&["Enter"].includes(o.key)&&(o.preventDefault(),s(t.calendarDate.toString().split("-").reverse().join(m)),t.onValueChange(t.calendarDate),t.onOpenChange(!1))})})});function Be(e,n,r){return n&&(e=g.maxDate(e,n)),r&&(e=g.minDate(e,r)),e}const We=j.default.input`
|
|
33
|
+
width: 100%;
|
|
34
|
+
font-size: ${14/16}rem;
|
|
35
|
+
color: ${({theme:e})=>e.colors.neutral800};
|
|
36
|
+
height: 100%;
|
|
37
|
+
border: none;
|
|
38
|
+
background-color: transparent;
|
|
39
|
+
|
|
40
|
+
&:focus-visible {
|
|
41
|
+
outline: none;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
&[aria-disabled='true'] {
|
|
45
|
+
cursor: inherit;
|
|
46
|
+
}
|
|
47
|
+
`,He="DatePickerContent",Ge=u.forwardRef((e,n)=>{const[r,t]=u.useState(),s=v(He);if(u.useLayoutEffect(()=>{t(new DocumentFragment)},[]),!s.open){const c=r;return c?be.createPortal(a.jsx("div",{children:e.children}),c):null}return a.jsx(Ze,{...e,ref:n})}),Ke="DatePickerContent",Ze=u.forwardRef((e,n)=>{const{label:r="Choose date",...t}=e,{onOpenChange:s,...c}=v(Ke),{x:p,y:d,reference:i,floating:m,strategy:y}=O.useFloating({strategy:"fixed",placement:"bottom-start",middleware:[O.offset({mainAxis:4}),O.shift(),O.flip()],whileElementsMounted:O.autoUpdate});u.useEffect(()=>{const o=()=>{s(!1)};return window.addEventListener("blur",o),window.addEventListener("resize",o),()=>{window.removeEventListener("blur",o),window.removeEventListener("resize",o)}},[s]),u.useLayoutEffect(()=>{i(c.trigger)},[i,c.trigger]);const C=U.useComposedRefs(n,o=>c.onContentChange(o),m);return Ce.useFocusGuards(),a.jsx(we.RemoveScroll,{allowPinchZoom:!0,children:a.jsx(Se.DismissibleLayer,{asChild:!0,onFocusOutside:o=>{o.preventDefault()},onDismiss:()=>{s(!1)},children:a.jsx(Xe,{ref:C,"data-state":c.open?"open":"closed",onContextMenu:o=>o.preventDefault(),id:c.contentId,role:"dialog","aria-modal":"true","aria-label":r,style:{left:p,top:d,position:y},hasRadius:!0,background:"neutral0",padding:1,...t})})})}),Xe=j.default(z.Box)`
|
|
48
|
+
box-shadow: ${({theme:e})=>e.shadows.filterShadow};
|
|
49
|
+
z-index: ${({theme:e})=>e.zIndices[0]};
|
|
50
|
+
border: 1px solid ${({theme:e})=>e.colors.neutral150};
|
|
51
|
+
`,Je="DatePickerCalendar",Qe=u.forwardRef(({monthSelectLabel:e,yearSelectLabel:n,...r},t)=>{const{locale:s,timeZone:c,minDate:p,maxDate:d,calendarDate:i,onCalendarDateChange:m}=v(Je),y=g.startOfMonth(i),C=u.useMemo(()=>{const l=p.year,h=d.year;return[...Array(h-l+1).keys()].map(k=>(l+k).toString())},[p,d]),o=L.useDateFormatter(s,{month:"long"}),f=u.useMemo(()=>[...Array(i.calendar.getMonthsInYear(i)).keys()].map(l=>o.format(i.set({month:l+1}).toDate(c))),[i,o,c]),b=L.useDateFormatter(s,{weekday:"short"}),x=u.useMemo(()=>{let l=g.startOfWeek(g.today(c),s);return[...new Array(7).keys()].map(h=>{let F=l.add({days:h}).toDate(c);return b.format(F)})},[c,s,b]),T=l=>{if(typeof l=="number")return;const h=i.set({month:f.indexOf(l)+1});m(h)},w=l=>{if(typeof l=="number")return;const h=i.set({year:parseInt(l,10)});m(h)},S=et(y,s);return a.jsxs(V.Flex,{ref:t,direction:"column",alignItems:"stretch",padding:4,...r,children:[a.jsxs(tt,{justifyContent:"flex-start",paddingBottom:4,paddingLeft:2,paddingRight:2,gap:2,children:[a.jsx(N.SingleSelectInput,{label:e,size:"S",value:f[i.month-1],onChange:T,children:f.map(l=>a.jsx(N.SingleSelectOption,{value:l,children:l},l))}),a.jsx(N.SingleSelectInput,{size:"S",value:i.year.toString(),label:n,onChange:w,children:C.map(l=>a.jsx(N.SingleSelectOption,{value:l,children:l},l))})]}),a.jsxs("table",{role:"grid",children:[a.jsx("thead",{"aria-hidden":!0,children:a.jsx("tr",{"aria-rowindex":0,children:x.map((l,h)=>a.jsx(rt,{"aria-colindex":h,children:l},l))})}),a.jsx("tbody",{children:[...new Array(6).keys()].map(l=>a.jsx("tr",{"aria-rowindex":l+2,children:S(l).map((h,k)=>h?a.jsx(ot,{"aria-colindex":k+1,date:h,startDate:y},h.toString()):a.jsx(ne,{"aria-colindex":k+1}))},l))})]})]})}),et=(e,n)=>r=>{let t=e.add({weeks:r}),s=[];t=g.startOfWeek(t,n);let c=g.getDayOfWeek(t,n);for(let p=0;p<c;p++)s.push(null);for(;s.length<7;){s.push(t);let p=t.add({days:1});if(g.isSameDay(t,p))break;t=p}for(;s.length<7;)s.push(null);return s},tt=j.default(V.Flex)`
|
|
52
|
+
div[role='combobox'] {
|
|
53
|
+
border: 1px solid transparent;
|
|
54
|
+
background: transparent;
|
|
55
|
+
font-weight: ${e=>e.theme.fontWeights.bold};
|
|
56
|
+
|
|
57
|
+
${Y.Typography} {
|
|
58
|
+
color: ${({theme:e})=>e.colors.neutral800};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
svg {
|
|
62
|
+
> g,
|
|
63
|
+
path {
|
|
64
|
+
fill: ${({theme:e})=>e.colors.neutral500};
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
&:hover {
|
|
69
|
+
background-color: ${({theme:e})=>e.colors.neutral100};
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
`,rt=u.forwardRef(({children:e,...n},r)=>a.jsx(nt,{as:"th",role:"gridcell",ref:r,...n,height:`${24/16}rem`,width:`${32/16}rem`,children:a.jsx(Y.Typography,{variant:"pi",fontWeight:"bold",color:"neutral800",children:e.slice(0,2)})})),nt=j.default(z.Box)`
|
|
73
|
+
border-radius: ${({theme:e})=>e.borderRadius};
|
|
74
|
+
text-transform: capitalize;
|
|
75
|
+
`,at="DatePickerCalendarCell",ot=u.forwardRef(({date:e,startDate:n,...r},t)=>{const{timeZone:s,locale:c,calendarDate:p,onValueChange:d,onOpenChange:i,onTextValueChange:m,separator:y,onCalendarDateChange:C}=v(at),o=g.isSameDay(p,e),f=L.useDateFormatter(c,{weekday:"long",day:"numeric",month:"long",year:"numeric"}),b=u.useMemo(()=>f.format(e.toDate(s)),[f,e,s]),x=L.useDateFormatter(c,{day:"numeric",calendar:e.calendar.identifier}),T=u.useMemo(()=>x.formatToParts(e.toDate(s)).find(h=>h.type==="day").value,[x,e,s]),w=g.endOfMonth(n),S=e.compare(n)<0||e.compare(w)>0;let l="neutral900";return o?l="primary600":S&&(l="neutral600"),a.jsx(ne,{as:"td",role:"gridcell",ref:t,"aria-selected":o,...r,hasRadius:!0,"aria-label":b,tabIndex:o?0:-1,background:o?"primary100":"neutral0",cursor:"pointer",onPointerDown:R.composeEventHandlers(r.onPointerDown,h=>{h.preventDefault(),C(e),d(e),m(e.toString().split("-").reverse().join(y)),i(!1)}),children:a.jsx(Y.Typography,{variant:"pi",textColor:l,children:T})})}),ne=j.default(z.Box)`
|
|
76
|
+
text-align: center;
|
|
77
|
+
padding: ${7/16}rem;
|
|
78
|
+
// Trick to prevent the outline from overflowing because of the general outline-offset
|
|
79
|
+
outline-offset: -2px !important;
|
|
80
|
+
|
|
81
|
+
&:hover {
|
|
82
|
+
background: ${({theme:e})=>e.colors.primary100};
|
|
83
|
+
|
|
84
|
+
& > ${Y.Typography} {
|
|
85
|
+
color: ${({theme:e})=>e.colors.primary600};
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
`,st=u.forwardRef((e,n)=>{const{error:r,hint:t,id:s,required:c,label:p,...d}=e,i=te.useId(s);return a.jsx(Ie.Field,{error:r,hint:t,required:c,ref:n,id:i,children:a.jsxs(V.Flex,{direction:"column",alignItems:"stretch",gap:1,children:[a.jsx(Re.FieldLabel,{children:p}),a.jsx(re,{id:i,error:r,required:c,...d}),a.jsx(ve.FieldHint,{}),a.jsx(Fe.FieldError,{})]})})}),E=e=>{const n=e.toISOString(),r=g.parseAbsoluteToLocal(n);return g.toCalendarDate(r)},lt=st;exports.DatePicker=lt;exports.DatePickerInput=re;
|