@strapi/design-system 1.4.0 → 1.4.2
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/LICENSE +4 -17
- package/dist/Alert/Alert.cjs +3 -3
- package/dist/Alert/Alert.js +16 -16
- package/dist/Alert/utils.cjs +1 -1
- package/dist/Alert/utils.js +3 -3
- package/dist/Avatar/Avatar.cjs +4 -4
- package/dist/Avatar/Avatar.js +41 -35
- package/dist/CarouselInput/CarouselInput.cjs +1 -1
- package/dist/CarouselInput/CarouselInput.js +2 -2
- package/dist/Combobox/Combobox.cjs +1 -1
- package/dist/Combobox/Combobox.js +80 -80
- package/dist/DatePicker/DatePicker.cjs +1 -1
- package/dist/DatePicker/DatePicker.js +83 -73
- package/dist/DateTimePicker/DateTimePicker.cjs +1 -1
- package/dist/DateTimePicker/DateTimePicker.js +58 -56
- package/dist/Field/Field.cjs +1 -1
- package/dist/Field/Field.js +22 -20
- package/dist/Field/FieldInput.cjs +4 -4
- package/dist/Field/FieldInput.js +31 -30
- package/dist/Field/FieldLabel.cjs +3 -3
- package/dist/Field/FieldLabel.js +43 -42
- package/dist/Link/Link.cjs +5 -5
- package/dist/Link/Link.js +19 -18
- package/dist/NumberInput/NumberInput.cjs +1 -1
- package/dist/NumberInput/NumberInput.js +2 -2
- package/dist/Select/Select.cjs +2 -2
- package/dist/Select/Select.js +32 -33
- package/dist/SimpleMenu/SimpleMenu.cjs +23 -7
- package/dist/SimpleMenu/SimpleMenu.js +121 -97
- package/dist/TextInput/TextInput.cjs +1 -1
- package/dist/TextInput/TextInput.js +2 -2
- package/dist/Textarea/Textarea.cjs +1 -1
- package/dist/Textarea/Textarea.js +2 -2
- package/dist/Textarea/TextareaInput.cjs +4 -4
- package/dist/Textarea/TextareaInput.js +23 -22
- package/dist/TimePicker/TimePicker.cjs +2 -2
- package/dist/TimePicker/TimePicker.js +44 -39
- package/dist/ToggleCheckbox/ToggleCheckbox.cjs +6 -6
- package/dist/ToggleCheckbox/ToggleCheckbox.js +44 -37
- package/dist/ToggleInput/ToggleInput.cjs +3 -3
- package/dist/ToggleInput/ToggleInput.js +25 -26
- package/dist/v2/SimpleMenu/SimpleMenu.cjs +21 -7
- package/dist/v2/SimpleMenu/SimpleMenu.js +126 -105
- package/package.json +4 -4
|
@@ -1,37 +1,37 @@
|
|
|
1
1
|
var Le = Object.defineProperty, we = Object.defineProperties;
|
|
2
2
|
var $e = Object.getOwnPropertyDescriptors;
|
|
3
3
|
var w = Object.getOwnPropertySymbols;
|
|
4
|
-
var
|
|
5
|
-
var
|
|
4
|
+
var J = Object.prototype.hasOwnProperty, Q = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var G = (o, i, a) => i in o ? Le(o, i, { enumerable: !0, configurable: !0, writable: !0, value: a }) : o[i] = a, B = (o, i) => {
|
|
6
6
|
for (var a in i || (i = {}))
|
|
7
|
-
|
|
7
|
+
J.call(i, a) && G(o, a, i[a]);
|
|
8
8
|
if (w)
|
|
9
9
|
for (var a of w(i))
|
|
10
|
-
|
|
10
|
+
Q.call(i, a) && G(o, a, i[a]);
|
|
11
11
|
return o;
|
|
12
|
-
},
|
|
13
|
-
var
|
|
12
|
+
}, D = (o, i) => we(o, $e(i));
|
|
13
|
+
var X = (o, i) => {
|
|
14
14
|
var a = {};
|
|
15
15
|
for (var p in o)
|
|
16
|
-
|
|
16
|
+
J.call(o, p) && i.indexOf(p) < 0 && (a[p] = o[p]);
|
|
17
17
|
if (o != null && w)
|
|
18
18
|
for (var p of w(o))
|
|
19
|
-
i.indexOf(p) < 0 &&
|
|
19
|
+
i.indexOf(p) < 0 && Q.call(o, p) && (a[p] = o[p]);
|
|
20
20
|
return a;
|
|
21
21
|
};
|
|
22
|
-
import r, { useState as k, useRef as y, useEffect as
|
|
22
|
+
import r, { useState as k, useRef as y, useEffect as Y, useLayoutEffect as Re, Children as Z, cloneElement as Se } from "react";
|
|
23
23
|
import e from "prop-types";
|
|
24
24
|
import Be from "@strapi/icons/CarretDown";
|
|
25
25
|
import De from "@strapi/icons/Cross";
|
|
26
26
|
import { useId as Fe } from "../helpers/useId.js";
|
|
27
|
-
import { filterOptions as
|
|
28
|
-
import { Flex as
|
|
27
|
+
import { filterOptions as ee, maintainScrollVisibility as Te, getActionFromKey as Ae, MenuActions as h, getUpdatedIndex as F } from "./utils.js";
|
|
28
|
+
import { Flex as te } from "../Flex/Flex.js";
|
|
29
29
|
import { IconBox as Pe, CaretBox as Ve } from "../Select/components.js";
|
|
30
30
|
import { Popover as Ke } from "../Popover/Popover.js";
|
|
31
31
|
import { Box as Ne } from "../Box/Box.js";
|
|
32
|
-
import { Typography as
|
|
33
|
-
import { Loader as
|
|
34
|
-
import { MainRow as
|
|
32
|
+
import { Typography as oe } from "../Typography/Typography.js";
|
|
33
|
+
import { Loader as He } from "../Loader/Loader.js";
|
|
34
|
+
import { MainRow as Ue, InputContainer as _e, ValueContainer as je, Input as qe } from "./components.js";
|
|
35
35
|
import { ComboboxOption as ze } from "./ComboboxOption.js";
|
|
36
36
|
import { ComboboxList as We } from "./ComboboxList.js";
|
|
37
37
|
import { Field as Ge } from "../Field/Field.js";
|
|
@@ -52,22 +52,22 @@ const O = (tt) => {
|
|
|
52
52
|
createMessage: p,
|
|
53
53
|
disabled: u,
|
|
54
54
|
error: $,
|
|
55
|
-
hasMoreItems:
|
|
56
|
-
hint:
|
|
55
|
+
hasMoreItems: ne,
|
|
56
|
+
hint: T,
|
|
57
57
|
label: E,
|
|
58
|
-
labelAction:
|
|
58
|
+
labelAction: ae,
|
|
59
59
|
loading: R,
|
|
60
|
-
loadingMessage:
|
|
61
|
-
noOptionsMessage:
|
|
62
|
-
onChange:
|
|
63
|
-
onClear:
|
|
64
|
-
onCreateOption:
|
|
65
|
-
onInputChange:
|
|
66
|
-
onLoadMore:
|
|
67
|
-
placeholder:
|
|
68
|
-
required:
|
|
60
|
+
loadingMessage: ie,
|
|
61
|
+
noOptionsMessage: le,
|
|
62
|
+
onChange: A,
|
|
63
|
+
onClear: P,
|
|
64
|
+
onCreateOption: se,
|
|
65
|
+
onInputChange: V,
|
|
66
|
+
onLoadMore: ce,
|
|
67
|
+
placeholder: pe,
|
|
68
|
+
required: K,
|
|
69
69
|
value: m
|
|
70
|
-
} = N, de =
|
|
70
|
+
} = N, de = X(N, [
|
|
71
71
|
"children",
|
|
72
72
|
"clearLabel",
|
|
73
73
|
"creatable",
|
|
@@ -96,31 +96,31 @@ const O = (tt) => {
|
|
|
96
96
|
var l;
|
|
97
97
|
return ((l = n.props) == null ? void 0 : l.value.toLowerCase()) === m.toLowerCase();
|
|
98
98
|
}).props) == null ? void 0 : t.children;
|
|
99
|
-
}, [c,
|
|
99
|
+
}, [c, H] = k(0), [ue, me] = k(null), [f, U] = k(o), [g, be] = k(!1), [s, M] = k(""), x = y(), L = y(!1), I = y(), _ = y(), ge = y(), j = y(!0), d = Fe("combobox"), q = `${d}-label`;
|
|
100
100
|
if (!E && !de["aria-label"])
|
|
101
101
|
throw new Error('The Combobox component needs a "label" or an "aria-label" props');
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}, [s, o]),
|
|
102
|
+
Y(() => {
|
|
103
|
+
U(ee(o, s));
|
|
104
|
+
}, [s, o]), Y(() => {
|
|
105
105
|
g && x.current && Te(x.current);
|
|
106
106
|
}, [c, g]), Re(() => {
|
|
107
|
-
|
|
107
|
+
j.current && (j.current = !1);
|
|
108
108
|
}, [m]);
|
|
109
|
-
const Ce = g ? `${d}-${c}` : "",
|
|
110
|
-
|
|
109
|
+
const Ce = g ? `${d}-${c}` : "", z = () => {
|
|
110
|
+
A(null), M("");
|
|
111
111
|
}, he = (t) => {
|
|
112
|
-
|
|
112
|
+
V && V(t);
|
|
113
113
|
const n = I.current.value;
|
|
114
|
-
|
|
114
|
+
U(ee(o, n)), H(0), me(null), s !== n && M(n), g || b(!0, !1);
|
|
115
115
|
}, Ee = (t) => {
|
|
116
116
|
const { key: n } = t, l = a && s ? f.length : f.length - 1, v = Ae(n, g);
|
|
117
|
-
switch (m && !s && n === Ze.BACKSPACE &&
|
|
117
|
+
switch (m && !s && n === Ze.BACKSPACE && z(), v) {
|
|
118
118
|
case h.Next: {
|
|
119
119
|
if (c === l) {
|
|
120
120
|
C(0);
|
|
121
121
|
break;
|
|
122
122
|
}
|
|
123
|
-
C(
|
|
123
|
+
C(F(c, l, v));
|
|
124
124
|
break;
|
|
125
125
|
}
|
|
126
126
|
case h.Previous: {
|
|
@@ -128,7 +128,7 @@ const O = (tt) => {
|
|
|
128
128
|
C(l);
|
|
129
129
|
break;
|
|
130
130
|
}
|
|
131
|
-
C(
|
|
131
|
+
C(F(c, l, v));
|
|
132
132
|
break;
|
|
133
133
|
}
|
|
134
134
|
case h.Last:
|
|
@@ -137,11 +137,11 @@ const O = (tt) => {
|
|
|
137
137
|
C(0);
|
|
138
138
|
break;
|
|
139
139
|
}
|
|
140
|
-
C(
|
|
140
|
+
C(F(c, l, v));
|
|
141
141
|
break;
|
|
142
142
|
}
|
|
143
143
|
case h.CloseSelect:
|
|
144
|
-
t.preventDefault(),
|
|
144
|
+
t.preventDefault(), S(c);
|
|
145
145
|
break;
|
|
146
146
|
case h.Close:
|
|
147
147
|
t.preventDefault(), b(!1);
|
|
@@ -157,36 +157,36 @@ const O = (tt) => {
|
|
|
157
157
|
}
|
|
158
158
|
b(!1, !1);
|
|
159
159
|
}, C = (t) => {
|
|
160
|
-
|
|
160
|
+
H(t);
|
|
161
161
|
}, ve = (t) => {
|
|
162
|
-
C(t),
|
|
163
|
-
},
|
|
162
|
+
C(t), S(t);
|
|
163
|
+
}, W = () => {
|
|
164
164
|
L.current = !0;
|
|
165
|
-
},
|
|
165
|
+
}, S = (t) => {
|
|
166
166
|
const n = f[t];
|
|
167
167
|
if (M(""), n) {
|
|
168
|
-
|
|
168
|
+
A(n.props.value), b(!1);
|
|
169
169
|
return;
|
|
170
170
|
}
|
|
171
|
-
a && (
|
|
171
|
+
a && (se(s), b(!1));
|
|
172
172
|
}, b = (t, n = !0) => {
|
|
173
173
|
be(t), n && I.current.focus();
|
|
174
|
-
}, ye =
|
|
174
|
+
}, ye = Z.toArray(f).map((t, n) => {
|
|
175
175
|
const l = c === n;
|
|
176
176
|
return Se(t, {
|
|
177
177
|
id: `${d}-${n}`,
|
|
178
178
|
"aria-selected": ue === n,
|
|
179
179
|
"aria-posinset": n + 1,
|
|
180
|
-
"aria-setsize":
|
|
180
|
+
"aria-setsize": Z.toArray(f).length,
|
|
181
181
|
ref(v) {
|
|
182
182
|
l && (x.current = v);
|
|
183
183
|
},
|
|
184
184
|
onClick: () => ve(n),
|
|
185
|
-
onMouseDown:
|
|
185
|
+
onMouseDown: W,
|
|
186
186
|
isSelected: l
|
|
187
187
|
});
|
|
188
188
|
}), Ie = () => {
|
|
189
|
-
I.current.focus(),
|
|
189
|
+
I.current.focus(), P && P(), z();
|
|
190
190
|
}, ke = () => {
|
|
191
191
|
I.current.focus(), b(!0);
|
|
192
192
|
}, Oe = () => {
|
|
@@ -199,50 +199,50 @@ const O = (tt) => {
|
|
|
199
199
|
t.preventDefault(), b(t, !0);
|
|
200
200
|
};
|
|
201
201
|
return /* @__PURE__ */ r.createElement(Ge, {
|
|
202
|
-
hint:
|
|
202
|
+
hint: T,
|
|
203
203
|
error: $,
|
|
204
|
-
id: d
|
|
204
|
+
id: d,
|
|
205
|
+
required: K
|
|
205
206
|
}, /* @__PURE__ */ r.createElement(et, {
|
|
206
207
|
"aria-live": "polite",
|
|
207
208
|
"aria-atomic": "false",
|
|
208
209
|
"aria-relevant": "additions text"
|
|
209
210
|
}, m), /* @__PURE__ */ r.createElement(Ye, {
|
|
210
|
-
spacing: E ||
|
|
211
|
+
spacing: E || T || $ ? 1 : 0
|
|
211
212
|
}, E && /* @__PURE__ */ r.createElement(Je, {
|
|
212
|
-
action:
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
}, E), /* @__PURE__ */ r.createElement(He, {
|
|
216
|
-
ref: U,
|
|
213
|
+
action: ae
|
|
214
|
+
}, E), /* @__PURE__ */ r.createElement(Ue, {
|
|
215
|
+
ref: _,
|
|
217
216
|
$disabled: u,
|
|
218
217
|
hasError: $
|
|
219
|
-
}, /* @__PURE__ */ r.createElement(
|
|
218
|
+
}, /* @__PURE__ */ r.createElement(_e, {
|
|
220
219
|
wrap: "wrap"
|
|
221
|
-
}, !s && m && /* @__PURE__ */ r.createElement(
|
|
220
|
+
}, !s && m && /* @__PURE__ */ r.createElement(je, {
|
|
222
221
|
id: `${d}-selected-value`
|
|
223
|
-
}, /* @__PURE__ */ r.createElement(
|
|
222
|
+
}, /* @__PURE__ */ r.createElement(oe, null, fe())), /* @__PURE__ */ r.createElement(qe, {
|
|
224
223
|
"aria-activedescendant": Ce,
|
|
225
224
|
"aria-autocomplete": "list",
|
|
226
225
|
"aria-controls": `${d}-listbox`,
|
|
227
226
|
"aria-disabled": u,
|
|
228
227
|
"aria-expanded": g,
|
|
229
228
|
"aria-haspopup": "listbox",
|
|
230
|
-
"aria-labelledby": E ?
|
|
229
|
+
"aria-labelledby": E ? q : void 0,
|
|
230
|
+
autoComplete: "off",
|
|
231
|
+
autoCorrect: "off",
|
|
231
232
|
id: d,
|
|
232
233
|
onBlur: u ? void 0 : xe,
|
|
233
234
|
onClick: u ? void 0 : Me,
|
|
234
235
|
onInput: u ? void 0 : he,
|
|
235
236
|
onKeyDown: u ? void 0 : Ee,
|
|
236
|
-
placeholder: m ? "" :
|
|
237
|
+
placeholder: m ? "" : pe,
|
|
237
238
|
readOnly: u,
|
|
238
239
|
ref: I,
|
|
240
|
+
required: K,
|
|
239
241
|
role: "combobox",
|
|
240
|
-
autoComplete: "off",
|
|
241
|
-
autoCorrect: "off",
|
|
242
242
|
spellCheck: "off",
|
|
243
243
|
type: "text",
|
|
244
244
|
value: s
|
|
245
|
-
})), /* @__PURE__ */ r.createElement(
|
|
245
|
+
})), /* @__PURE__ */ r.createElement(te, null, (m || s) && /* @__PURE__ */ r.createElement(Pe, {
|
|
246
246
|
id: `${d}-clear`,
|
|
247
247
|
"aria-label": i,
|
|
248
248
|
disabled: u,
|
|
@@ -260,16 +260,16 @@ const O = (tt) => {
|
|
|
260
260
|
type: "button"
|
|
261
261
|
}, /* @__PURE__ */ r.createElement(Be, null)))), /* @__PURE__ */ r.createElement(Qe, null), /* @__PURE__ */ r.createElement(Xe, null)), g && /* @__PURE__ */ r.createElement(Ke, {
|
|
262
262
|
id: `${d}-popover`,
|
|
263
|
-
source:
|
|
263
|
+
source: _,
|
|
264
264
|
spacing: 4,
|
|
265
265
|
fullWidth: !0,
|
|
266
266
|
intersectionId: `${d}-listbox-popover-intersection`,
|
|
267
|
-
onReachEnd:
|
|
267
|
+
onReachEnd: ne && !R ? ce : void 0
|
|
268
268
|
}, /* @__PURE__ */ r.createElement("div", {
|
|
269
269
|
role: "listbox",
|
|
270
270
|
ref: ge,
|
|
271
271
|
id: `${d}-listbox`,
|
|
272
|
-
"aria-labelledby": E ?
|
|
272
|
+
"aria-labelledby": E ? q : void 0
|
|
273
273
|
}, (Boolean(f.length) || a) && /* @__PURE__ */ r.createElement(r.Fragment, null, /* @__PURE__ */ r.createElement(We, {
|
|
274
274
|
activeOptionRef: x,
|
|
275
275
|
options: ye
|
|
@@ -278,8 +278,8 @@ const O = (tt) => {
|
|
|
278
278
|
ref: (t) => {
|
|
279
279
|
c === f.length && (x.current = t);
|
|
280
280
|
},
|
|
281
|
-
onMouseDown:
|
|
282
|
-
onClick: () =>
|
|
281
|
+
onMouseDown: W,
|
|
282
|
+
onClick: () => S(),
|
|
283
283
|
taindex: 0
|
|
284
284
|
}, p(s))), !f.length && !a && !R && /* @__PURE__ */ r.createElement(Ne, {
|
|
285
285
|
paddingLeft: 4,
|
|
@@ -287,17 +287,17 @@ const O = (tt) => {
|
|
|
287
287
|
paddingTop: 2,
|
|
288
288
|
paddingBottom: 2,
|
|
289
289
|
ref: x
|
|
290
|
-
}, /* @__PURE__ */ r.createElement(
|
|
290
|
+
}, /* @__PURE__ */ r.createElement(oe, {
|
|
291
291
|
textColor: "neutral800"
|
|
292
|
-
},
|
|
292
|
+
}, le(s))), R && /* @__PURE__ */ r.createElement(te, {
|
|
293
293
|
justifyContent: "center",
|
|
294
294
|
alignItems: "center",
|
|
295
295
|
paddingTop: 2,
|
|
296
296
|
paddingBottom: 2
|
|
297
|
-
}, /* @__PURE__ */ r.createElement(
|
|
297
|
+
}, /* @__PURE__ */ r.createElement(He, {
|
|
298
298
|
small: !0
|
|
299
|
-
},
|
|
300
|
-
},
|
|
299
|
+
}, ie)))));
|
|
300
|
+
}, re = (o) => /* @__PURE__ */ r.createElement(O, D(B({}, o), {
|
|
301
301
|
creatable: !0
|
|
302
302
|
}));
|
|
303
303
|
O.defaultProps = {
|
|
@@ -320,7 +320,7 @@ O.defaultProps = {
|
|
|
320
320
|
placeholder: "Select or enter a value",
|
|
321
321
|
value: void 0
|
|
322
322
|
};
|
|
323
|
-
|
|
323
|
+
re.defaultProps = O.defaultProps;
|
|
324
324
|
O.propTypes = {
|
|
325
325
|
"aria-label": e.string,
|
|
326
326
|
children: e.oneOfType([e.arrayOf(e.node), e.node]),
|
|
@@ -344,10 +344,10 @@ O.propTypes = {
|
|
|
344
344
|
placeholder: e.string,
|
|
345
345
|
value: e.string
|
|
346
346
|
};
|
|
347
|
-
|
|
347
|
+
re.propTypes = D(B({}, O.propTypes), {
|
|
348
348
|
onCreateOption: e.func.isRequired
|
|
349
349
|
});
|
|
350
350
|
export {
|
|
351
351
|
O as Combobox,
|
|
352
|
-
|
|
352
|
+
re as CreatableCombobox
|
|
353
353
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var V=Object.defineProperty;var s=Object.getOwnPropertySymbols;var I=Object.prototype.hasOwnProperty,_=Object.prototype.propertyIsEnumerable;var P=(e,a,t)=>a in e?V(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t,j=(e,a)=>{for(var t in a||(a={}))I.call(a,t)&&P(e,t,a[t]);if(s)for(var t of s(a))_.call(a,t)&&P(e,t,a[t]);return e};var y=(e,a)=>{var t={};for(var r in e)I.call(e,r)&&a.indexOf(r)<0&&(t[r]=e[r]);if(e!=null&&s)for(var r of s(e))a.indexOf(r)<0&&_.call(e,r)&&(t[r]=e[r]);return t};Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const c=require("react"),w=require("prop-types"),F=require("@strapi/icons/Calendar"),G=require("@strapi/icons/Cross"),H=require("../themes/sizes.cjs"),J=require("../TextInput/TextInput.cjs"),D=require("./components.cjs"),K=require("./DatePickerCalendar.cjs"),R=require("./utils/formatDate.cjs"),N=require("../helpers/useId.cjs"),Q=require("../helpers/getDefaultLocale.cjs"),u=e=>e&&typeof e=="object"&&"default"in e?e:{default:e},l=u(c),n=u(w),U=u(F),X=u(G),m=Y=>{var b=Y,{ariaLabel:e,initialDate:a,selectedDate:t,onChange:r,label:d,locale:E,selectedDateLabel:T,onClear:g,clearLabel:x,disabled:o,id:L,minDate:O,maxDate:z}=b,S=y(b,["ariaLabel","initialDate","selectedDate","onChange","label","locale","selectedDateLabel","onClear","clearLabel","disabled","id","minDate","maxDate"]);const B=N.useId("datepicker",L),[C,f]=c.useState(!1),i=c.useRef(null),v=c.useRef(null),h=E||Q.getDefaultLocale(),k=t?R.formatDate(t,h):"",q=()=>{o||f(p=>!p)},M=()=>{o||(g(),v.current.focus())},W=p=>{r(p),f(!1)},A=()=>{f(!1)};return l.default.createElement(D.DatePickerWrapper,{bold:C},l.default.createElement(J.TextInput,j({ref:i,onClick:q,onChange:()=>{},value:k,startAction:l.default.createElement(D.DatePickerButton,{ref:v,onClick:q,"aria-label":t?T(R.formatDate(t,h)):d||e,type:"button","aria-disabled":o},l.default.createElement(U.default,{"aria-hidden":!0})),endAction:g&&k?l.default.createElement(D.IconBox,{as:"button",onClick:M,"aria-label":x,"aria-disabled":o},l.default.createElement(X.default,null)):void 0,"aria-autocomplete":"none",label:d,"aria-label":e,disabled:o,id:B},S)),i.current&&i.current.inputWrapperRef&&C&&l.default.createElement(K.DatePickerCalendar,{selectedDate:t,initialDate:a,onChange:W,onEscape:A,popoverSource:i.current.inputWrapperRef,label:d||e,minDate:O,maxDate:z}))};m.defaultProps={ariaLabel:void 0,clearLabel:void 0,disabled:!1,id:void 0,label:void 0,locale:void 0,initialDate:new Date,minDate:void 0,maxDate:void 0,onClear:void 0,placeholder:void 0,selectedDate:void 0,size:"M"};m.propTypes={ariaLabel:n.default.string,clearLabel:n.default.string,disabled:n.default.bool,id:n.default.string,initialDate:n.default.instanceOf(Date),label:n.default.string,locale:n.default.string,maxDate:n.default.instanceOf(Date),minDate:n.default.instanceOf(Date),onChange:n.default.func.isRequired,onClear:n.default.func,placeholder:n.default.string,selectedDate:n.default.instanceOf(Date),selectedDateLabel:n.default.func.isRequired,size:n.default.oneOf(Object.keys(H.sizes.input))};exports.DatePicker=m;
|
|
@@ -1,48 +1,50 @@
|
|
|
1
|
-
var
|
|
1
|
+
var _ = Object.defineProperty;
|
|
2
2
|
var c = Object.getOwnPropertySymbols;
|
|
3
3
|
var h = Object.prototype.hasOwnProperty, k = Object.prototype.propertyIsEnumerable;
|
|
4
|
-
var
|
|
5
|
-
for (var e in
|
|
6
|
-
h.call(
|
|
4
|
+
var C = (t, a, e) => a in t ? _(t, a, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[a] = e, E = (t, a) => {
|
|
5
|
+
for (var e in a || (a = {}))
|
|
6
|
+
h.call(a, e) && C(t, e, a[e]);
|
|
7
7
|
if (c)
|
|
8
|
-
for (var e of c(
|
|
9
|
-
k.call(
|
|
8
|
+
for (var e of c(a))
|
|
9
|
+
k.call(a, e) && C(t, e, a[e]);
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
var R = (t,
|
|
12
|
+
var R = (t, a) => {
|
|
13
13
|
var e = {};
|
|
14
14
|
for (var o in t)
|
|
15
|
-
h.call(t, o) &&
|
|
15
|
+
h.call(t, o) && a.indexOf(o) < 0 && (e[o] = t[o]);
|
|
16
16
|
if (t != null && c)
|
|
17
17
|
for (var o of c(t))
|
|
18
|
-
|
|
18
|
+
a.indexOf(o) < 0 && k.call(t, o) && (e[o] = t[o]);
|
|
19
19
|
return e;
|
|
20
20
|
};
|
|
21
|
-
import n, { useState as
|
|
22
|
-
import
|
|
23
|
-
import
|
|
24
|
-
import
|
|
25
|
-
import { sizes as
|
|
26
|
-
import { TextInput as
|
|
27
|
-
import { DatePickerWrapper as
|
|
28
|
-
import { DatePickerCalendar as
|
|
29
|
-
import { formatDate as
|
|
30
|
-
import { useId as
|
|
31
|
-
import { getDefaultLocale as
|
|
32
|
-
const
|
|
33
|
-
var
|
|
21
|
+
import n, { useState as j, useRef as P } from "react";
|
|
22
|
+
import r from "prop-types";
|
|
23
|
+
import w from "@strapi/icons/Calendar";
|
|
24
|
+
import M from "@strapi/icons/Cross";
|
|
25
|
+
import { sizes as F } from "../themes/sizes.js";
|
|
26
|
+
import { TextInput as G } from "../TextInput/TextInput.js";
|
|
27
|
+
import { DatePickerWrapper as H, DatePickerButton as J, IconBox as K } from "./components.js";
|
|
28
|
+
import { DatePickerCalendar as N } from "./DatePickerCalendar.js";
|
|
29
|
+
import { formatDate as O } from "./utils/formatDate.js";
|
|
30
|
+
import { useId as Q } from "../helpers/useId.js";
|
|
31
|
+
import { getDefaultLocale as U } from "../helpers/getDefaultLocale.js";
|
|
32
|
+
const x = (X) => {
|
|
33
|
+
var u = X, {
|
|
34
34
|
ariaLabel: t,
|
|
35
|
-
initialDate:
|
|
35
|
+
initialDate: a,
|
|
36
36
|
selectedDate: e,
|
|
37
37
|
onChange: o,
|
|
38
38
|
label: s,
|
|
39
|
-
locale:
|
|
40
|
-
selectedDateLabel:
|
|
41
|
-
onClear:
|
|
42
|
-
clearLabel:
|
|
39
|
+
locale: y,
|
|
40
|
+
selectedDateLabel: I,
|
|
41
|
+
onClear: m,
|
|
42
|
+
clearLabel: L,
|
|
43
43
|
disabled: i,
|
|
44
|
-
id: z
|
|
45
|
-
|
|
44
|
+
id: z,
|
|
45
|
+
minDate: B,
|
|
46
|
+
maxDate: T
|
|
47
|
+
} = u, W = R(u, [
|
|
46
48
|
"ariaLabel",
|
|
47
49
|
"initialDate",
|
|
48
50
|
"selectedDate",
|
|
@@ -53,55 +55,59 @@ const I = (Q) => {
|
|
|
53
55
|
"onClear",
|
|
54
56
|
"clearLabel",
|
|
55
57
|
"disabled",
|
|
56
|
-
"id"
|
|
58
|
+
"id",
|
|
59
|
+
"minDate",
|
|
60
|
+
"maxDate"
|
|
57
61
|
]);
|
|
58
|
-
const
|
|
59
|
-
i ||
|
|
60
|
-
}, W = () => {
|
|
61
|
-
i || (u(), b.current.focus());
|
|
62
|
-
}, q = (f) => {
|
|
63
|
-
o(f), p(!1);
|
|
62
|
+
const q = Q("datepicker", z), [d, f] = j(!1), l = P(null), D = P(null), b = y || U(), g = e ? O(e, b) : "", v = () => {
|
|
63
|
+
i || f((p) => !p);
|
|
64
64
|
}, A = () => {
|
|
65
|
-
|
|
65
|
+
i || (m(), D.current.focus());
|
|
66
|
+
}, S = (p) => {
|
|
67
|
+
o(p), f(!1);
|
|
68
|
+
}, V = () => {
|
|
69
|
+
f(!1);
|
|
66
70
|
};
|
|
67
|
-
return /* @__PURE__ */ n.createElement(
|
|
68
|
-
bold:
|
|
69
|
-
}, /* @__PURE__ */ n.createElement(
|
|
71
|
+
return /* @__PURE__ */ n.createElement(H, {
|
|
72
|
+
bold: d
|
|
73
|
+
}, /* @__PURE__ */ n.createElement(G, E({
|
|
70
74
|
ref: l,
|
|
71
|
-
onClick:
|
|
75
|
+
onClick: v,
|
|
72
76
|
onChange: () => {
|
|
73
77
|
},
|
|
74
|
-
value:
|
|
75
|
-
startAction: /* @__PURE__ */ n.createElement(
|
|
76
|
-
ref:
|
|
77
|
-
onClick:
|
|
78
|
-
"aria-label": e ? O(
|
|
78
|
+
value: g,
|
|
79
|
+
startAction: /* @__PURE__ */ n.createElement(J, {
|
|
80
|
+
ref: D,
|
|
81
|
+
onClick: v,
|
|
82
|
+
"aria-label": e ? I(O(e, b)) : s || t,
|
|
79
83
|
type: "button",
|
|
80
84
|
"aria-disabled": i
|
|
81
|
-
}, /* @__PURE__ */ n.createElement(
|
|
85
|
+
}, /* @__PURE__ */ n.createElement(w, {
|
|
82
86
|
"aria-hidden": !0
|
|
83
87
|
})),
|
|
84
|
-
endAction:
|
|
88
|
+
endAction: m && g ? /* @__PURE__ */ n.createElement(K, {
|
|
85
89
|
as: "button",
|
|
86
|
-
onClick:
|
|
87
|
-
"aria-label":
|
|
90
|
+
onClick: A,
|
|
91
|
+
"aria-label": L,
|
|
88
92
|
"aria-disabled": i
|
|
89
|
-
}, /* @__PURE__ */ n.createElement(
|
|
93
|
+
}, /* @__PURE__ */ n.createElement(M, null)) : void 0,
|
|
90
94
|
"aria-autocomplete": "none",
|
|
91
95
|
label: s,
|
|
92
96
|
"aria-label": t,
|
|
93
97
|
disabled: i,
|
|
94
|
-
id:
|
|
95
|
-
},
|
|
98
|
+
id: q
|
|
99
|
+
}, W)), l.current && l.current.inputWrapperRef && d && /* @__PURE__ */ n.createElement(N, {
|
|
96
100
|
selectedDate: e,
|
|
97
|
-
initialDate:
|
|
98
|
-
onChange:
|
|
99
|
-
onEscape:
|
|
101
|
+
initialDate: a,
|
|
102
|
+
onChange: S,
|
|
103
|
+
onEscape: V,
|
|
100
104
|
popoverSource: l.current.inputWrapperRef,
|
|
101
|
-
label: s || t
|
|
105
|
+
label: s || t,
|
|
106
|
+
minDate: B,
|
|
107
|
+
maxDate: T
|
|
102
108
|
}));
|
|
103
109
|
};
|
|
104
|
-
|
|
110
|
+
x.defaultProps = {
|
|
105
111
|
ariaLabel: void 0,
|
|
106
112
|
clearLabel: void 0,
|
|
107
113
|
disabled: !1,
|
|
@@ -109,26 +115,30 @@ I.defaultProps = {
|
|
|
109
115
|
label: void 0,
|
|
110
116
|
locale: void 0,
|
|
111
117
|
initialDate: new Date(),
|
|
118
|
+
minDate: void 0,
|
|
119
|
+
maxDate: void 0,
|
|
112
120
|
onClear: void 0,
|
|
113
121
|
placeholder: void 0,
|
|
114
122
|
selectedDate: void 0,
|
|
115
123
|
size: "M"
|
|
116
124
|
};
|
|
117
|
-
|
|
118
|
-
ariaLabel:
|
|
119
|
-
clearLabel:
|
|
120
|
-
disabled:
|
|
121
|
-
id:
|
|
122
|
-
initialDate:
|
|
123
|
-
label:
|
|
124
|
-
locale:
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
125
|
+
x.propTypes = {
|
|
126
|
+
ariaLabel: r.string,
|
|
127
|
+
clearLabel: r.string,
|
|
128
|
+
disabled: r.bool,
|
|
129
|
+
id: r.string,
|
|
130
|
+
initialDate: r.instanceOf(Date),
|
|
131
|
+
label: r.string,
|
|
132
|
+
locale: r.string,
|
|
133
|
+
maxDate: r.instanceOf(Date),
|
|
134
|
+
minDate: r.instanceOf(Date),
|
|
135
|
+
onChange: r.func.isRequired,
|
|
136
|
+
onClear: r.func,
|
|
137
|
+
placeholder: r.string,
|
|
138
|
+
selectedDate: r.instanceOf(Date),
|
|
139
|
+
selectedDateLabel: r.func.isRequired,
|
|
140
|
+
size: r.oneOf(Object.keys(F.input))
|
|
131
141
|
};
|
|
132
142
|
export {
|
|
133
|
-
|
|
143
|
+
x as DatePicker
|
|
134
144
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var B=Object.defineProperty;var F=Object.getOwnPropertySymbols;var
|
|
1
|
+
"use strict";var B=Object.defineProperty;var F=Object.getOwnPropertySymbols;var H=Object.prototype.hasOwnProperty,y=Object.prototype.propertyIsEnumerable;var $=(e,a,i)=>a in e?B(e,a,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[a]=i,M=(e,a)=>{for(var i in a||(a={}))H.call(a,i)&&$(e,i,a[i]);if(F)for(var i of F(a))y.call(a,i)&&$(e,i,a[i]);return e};var I=(e,a)=>{var i={};for(var r in e)H.call(e,r)&&a.indexOf(r)<0&&(i[r]=e[r]);if(e!=null&&F)for(var r of F(e))a.indexOf(r)<0&&y.call(e,r)&&(i[r]=e[r]);return i};Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const p=require("react"),b=require("../Stack/Stack.cjs"),G=require("../DatePicker/DatePicker.cjs"),J=require("../TimePicker/TimePicker.cjs"),K=require("../Field/Field.cjs"),N=require("../Field/FieldLabel.cjs");require("../Field/FieldInput.cjs");const Q=require("../Field/FieldHint.cjs"),U=require("../Field/FieldError.cjs");require("../Field/FieldContext.cjs");require("../Field/FieldAction.cjs");const h=require("../helpers/useId.cjs"),w=require("./parseDate.cjs"),_=require("./DateTimePickerProps.cjs"),W=e=>e&&typeof e=="object"&&"default"in e?e:{default:e},l=W(p),g=X=>{var E=X,{ariaLabel:e,clearLabel:a,disabled:i,error:r,hint:L,label:m,labelAction:V,onChange:d,onClear:P,name:j,required:T,selectButtonTitle:v,size:S,step:C,value:n}=E,D=I(E,["ariaLabel","clearLabel","disabled","error","hint","label","labelAction","onChange","onClear","name","required","selectButtonTitle","size","step","value"]);const u=w.parseDate(n),[c,f]=p.useState(u),[k,o]=p.useState(u?`${u.getHours()}:${u.getMinutes()}:${u.getSeconds()}`:null),R=t=>{f(t);let s;k?(s=new Date(t),s.setHours(k.split(":")[0]),s.setMinutes(k.split(":")[1])):(s=new Date(t),o(`${s.getHours()}:${s.getMinutes()}:${s.getSeconds()}`)),d&&d(s)},x=t=>{o(t);const s=c?new Date(c):new Date;s.setHours(t.split(":")[0]),s.setMinutes(t.split(":")[1]),c||f(s),d&&d(s)},A=()=>{f(void 0),o(void 0),P()},O=()=>{o(void 0);let t;c&&(t=new Date(c),t.setHours("00"),t.setMinutes("00")),d&&d(t)};p.useEffect(()=>{if(n&&+n!=+c){const t=w.parseDate(n);f(t),o(t?`${t.getHours()}:${t.getMinutes()}:${t.getSeconds()}`:null)}else n||(f(void 0),o(void 0))},[n,c]);const q=h.useId("datetime-label",D==null?void 0:D.id),z=h.useId("datetimepicker");return l.default.createElement(K.Field,{name:j,role:"group",id:q,"aria-labelledby":q,hint:L,error:r,required:T},l.default.createElement(b.Stack,{spacing:1},m&&l.default.createElement(N.FieldLabel,{action:V},m),l.default.createElement(b.Stack,{horizontal:!0,spacing:2},l.default.createElement(G.DatePicker,M({"data-testid":"datetimepicker-date",name:j,ariaLabel:m||e,error:typeof r=="string",selectedDate:c,selectedDateLabel:t=>`Date picker, current is ${t}`,onChange:R,required:T,size:S,onClear:P&&A,clearLabel:a,disabled:i},D)),l.default.createElement(J.TimePicker,{"data-testid":"datetimepicker-time",size:S,"aria-label":m||e,error:typeof r=="string",value:k,onChange:x,onClear:P&&O,clearLabel:a,required:T,selectButtonTitle:v,disabled:i,step:C})),l.default.createElement(Q.FieldHint,null),l.default.createElement(U.FieldError,{id:z})))};g.defaultProps=_.dateTimePickerDefaultProps;g.propTypes=_.dateTimePickerPropTypes;exports.DateTimePicker=g;
|