@strapi/design-system 1.6.5 → 1.6.6
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/BaseButton/BaseButton.cjs +3 -3
- package/dist/BaseButton/BaseButton.js +17 -16
- package/dist/DatePicker/DatePicker.cjs +8 -1
- package/dist/DatePicker/DatePicker.js +71 -98
- package/dist/DatePicker/DatePickerCalendar.cjs +1 -1
- package/dist/DatePicker/DatePickerCalendar.js +124 -57
- package/dist/DatePicker/DatePickerTd.cjs +4 -4
- package/dist/DatePicker/DatePickerTd.js +42 -24
- package/dist/DatePicker/DatePickerTh.cjs +3 -3
- package/dist/DatePicker/DatePickerTh.js +29 -12
- package/dist/DatePicker/components.cjs +8 -6
- package/dist/DatePicker/components.js +15 -13
- package/dist/DatePicker/utils/getDayOfWeek.js +8 -8
- package/dist/DatePicker/utils/getMonths.cjs +1 -1
- package/dist/DatePicker/utils/getMonths.js +3 -3
- package/dist/DatePicker/utils/getYears.cjs +1 -1
- package/dist/DatePicker/utils/getYears.js +1 -1
- package/dist/DateTimePicker/DateTimePicker.cjs +1 -1
- package/dist/DateTimePicker/DateTimePicker.js +97 -104
- package/dist/Field/FieldHint.cjs +1 -1
- package/dist/Field/FieldHint.js +3 -3
- package/dist/Field/FieldLabel.cjs +5 -2
- package/dist/Field/FieldLabel.js +27 -27
- package/dist/IconButton/IconButton.cjs +4 -4
- package/dist/IconButton/IconButton.js +32 -30
- package/dist/RawTable/RawCell.cjs +1 -1
- package/dist/RawTable/RawCell.js +4 -1
- package/dist/Select/Select.cjs +2 -2
- package/dist/Select/Select.js +57 -55
- package/dist/Select/SelectButton.cjs +3 -3
- package/dist/Select/SelectButton.js +17 -15
- package/dist/TextButton/TextButton.cjs +6 -12
- package/dist/TextButton/TextButton.js +32 -46
- package/dist/TextInput/TextInput.cjs +1 -1
- package/dist/TextInput/TextInput.js +47 -46
- package/dist/TimePicker/TimePicker.cjs +5 -7
- package/dist/TimePicker/TimePicker.js +48 -100
- package/package.json +4 -3
- package/dist/DateTimePicker/DateTimePickerProps.cjs +0 -1
- package/dist/DateTimePicker/DateTimePickerProps.js +0 -40
- package/dist/DateTimePicker/__tests__/parseDate.test.cjs +0 -1
- package/dist/DateTimePicker/__tests__/parseDate.test.js +0 -8
- package/dist/DateTimePicker/parseDate.cjs +0 -1
- package/dist/DateTimePicker/parseDate.js +0 -7
|
@@ -1,51 +1,52 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { jsx as r, jsxs as s } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as c, useRef as u, useImperativeHandle as h } from "react";
|
|
3
3
|
import { Field as I } from "../Field/Field.js";
|
|
4
|
-
import { FieldLabel as
|
|
5
|
-
import { FieldInput as
|
|
6
|
-
import { FieldHint as
|
|
7
|
-
import { FieldError as
|
|
4
|
+
import { FieldLabel as x } from "../Field/FieldLabel.js";
|
|
5
|
+
import { FieldInput as F } from "../Field/FieldInput.js";
|
|
6
|
+
import { FieldHint as T } from "../Field/FieldHint.js";
|
|
7
|
+
import { FieldError as g } from "../Field/FieldError.js";
|
|
8
8
|
import "../Field/FieldContext.js";
|
|
9
9
|
import "../Field/FieldAction.js";
|
|
10
|
-
import { Flex as
|
|
11
|
-
import { useId as
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
};
|
|
10
|
+
import { Flex as w } from "../Flex/Flex.js";
|
|
11
|
+
import { useId as R } from "../hooks/useId.js";
|
|
12
|
+
const b = c(({
|
|
13
|
+
name: t,
|
|
14
|
+
hint: n,
|
|
15
|
+
error: m,
|
|
16
|
+
label: e,
|
|
17
|
+
labelAction: p,
|
|
18
|
+
id: d,
|
|
19
|
+
required: a,
|
|
20
|
+
...i
|
|
21
|
+
}, l) => {
|
|
22
|
+
const f = R(d), o = u(null);
|
|
23
|
+
if (!e && !i["aria-label"])
|
|
24
|
+
throw new Error('The TextInput component needs a "label" or an "aria-label" props');
|
|
25
|
+
return h(l, () => ({
|
|
26
|
+
inputWrapperRef: o
|
|
27
|
+
})), r("div", {
|
|
28
|
+
ref: o,
|
|
29
|
+
children: r(I, {
|
|
30
|
+
name: t,
|
|
31
|
+
hint: n,
|
|
32
|
+
error: m,
|
|
33
|
+
id: f,
|
|
34
|
+
required: a,
|
|
35
|
+
children: s(w, {
|
|
36
|
+
direction: "column",
|
|
37
|
+
alignItems: "stretch",
|
|
38
|
+
gap: 1,
|
|
39
|
+
children: [e && r(x, {
|
|
40
|
+
action: p,
|
|
41
|
+
children: e
|
|
42
|
+
}), r(F, {
|
|
43
|
+
...i
|
|
44
|
+
}), r(T, {}), r(g, {})]
|
|
45
|
+
})
|
|
46
|
+
})
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
b.displayName = "TextInput";
|
|
49
50
|
export {
|
|
50
|
-
|
|
51
|
+
b as TextInput
|
|
51
52
|
};
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
2
|
-
|
|
3
|
-
align-items: center;
|
|
4
|
-
svg {
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("react/jsx-runtime"),q=require("@strapi/icons"),x=require("styled-components"),f=require("../Flex/Flex.cjs"),g=require("../hooks/useId.cjs"),M=require("../Select/Select.cjs"),b=require("../Select/Option.cjs");require("../Select/OptGroup.cjs");require("../Select/MultiSelectNested.cjs");require("../Select/SelectList.cjs");const $=t=>t&&typeof t=="object"&&"default"in t?t:{default:t},y=$(x),I=({id:t,value:i,step:a=15,...d})=>{const p=g.useId(t),h=24,s=[];let c=0;for(let e=0;e<h;e++)for(c=0;c<60;)s.push(`${e<10?`0${e}`:e}:${c<10?`0${c}`:c}`),c+=a;const j=()=>{const[e,u]=i?.split(":")??[],m=s.reduce((r,o)=>{const[l]=o.split(":");return Math.abs(l-e)<Math.abs(r-e)?l:r},s[0].split(":")[0]),S=s.reduce((r,o)=>{const l=o.split(":")[1];return Math.abs(l-u)<Math.abs(r-u)?l:r},s[0].split(":")[1]);return`${m}:${S}`};return n.jsx(M.Select,{id:p,placeholder:"--:--",value:i?j():null,startIcon:n.jsx(v,{children:n.jsx(q.Clock,{})}),...d,children:s.map(e=>n.jsx(b.Option,{value:e,children:e},e))})},v=y.default(f.Flex)`
|
|
2
|
+
& > svg {
|
|
5
3
|
height: 1rem;
|
|
6
4
|
width: 1rem;
|
|
7
5
|
}
|
|
8
6
|
|
|
9
|
-
svg path {
|
|
10
|
-
fill: ${({theme:
|
|
7
|
+
& > svg path {
|
|
8
|
+
fill: ${({theme:t})=>t.colors.neutral500};
|
|
11
9
|
}
|
|
12
|
-
|
|
10
|
+
`;exports.TimePicker=I;
|
|
@@ -1,110 +1,58 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Clock as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import { useId as
|
|
6
|
-
import { Select as
|
|
7
|
-
import { Option as
|
|
1
|
+
import { jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import { Clock as $ } from "@strapi/icons";
|
|
3
|
+
import g from "styled-components";
|
|
4
|
+
import { Flex as M } from "../Flex/Flex.js";
|
|
5
|
+
import { useId as b } from "../hooks/useId.js";
|
|
6
|
+
import { Select as C } from "../Select/Select.js";
|
|
7
|
+
import { Option as I } from "../Select/Option.js";
|
|
8
8
|
import "../Select/OptGroup.js";
|
|
9
9
|
import "../Select/MultiSelectNested.js";
|
|
10
10
|
import "../Select/SelectList.js";
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
const S = ({
|
|
12
|
+
id: l,
|
|
13
|
+
value: m,
|
|
14
|
+
step: u = 15,
|
|
15
|
+
...p
|
|
16
|
+
}) => {
|
|
17
|
+
const a = b(l), h = 24, o = [];
|
|
18
|
+
let r = 0;
|
|
19
|
+
for (let t = 0; t < h; t++)
|
|
20
|
+
for (r = 0; r < 60; )
|
|
21
|
+
o.push(`${t < 10 ? `0${t}` : t}:${r < 10 ? `0${r}` : r}`), r += u;
|
|
22
|
+
return i(C, {
|
|
23
|
+
id: a,
|
|
24
|
+
placeholder: "--:--",
|
|
25
|
+
value: m ? (() => {
|
|
26
|
+
const [t, c] = m?.split(":") ?? [], d = o.reduce((e, n) => {
|
|
27
|
+
const [s] = n.split(":");
|
|
28
|
+
return Math.abs(s - t) < Math.abs(e - t) ? s : e;
|
|
29
|
+
}, o[0].split(":")[0]), f = o.reduce((e, n) => {
|
|
30
|
+
const s = n.split(":")[1];
|
|
31
|
+
return Math.abs(s - c) < Math.abs(e - c) ? s : e;
|
|
32
|
+
}, o[0].split(":")[1]);
|
|
33
|
+
return `${d}:${f}`;
|
|
34
|
+
})() : null,
|
|
35
|
+
startIcon: i(v, {
|
|
36
|
+
children: i($, {})
|
|
37
|
+
}),
|
|
38
|
+
...p,
|
|
39
|
+
children: o.map((t) => i(I, {
|
|
40
|
+
value: t,
|
|
41
|
+
children: t
|
|
42
|
+
}, t))
|
|
43
|
+
});
|
|
44
|
+
}, v = g(M)`
|
|
45
|
+
& > svg {
|
|
16
46
|
height: 1rem;
|
|
17
47
|
width: 1rem;
|
|
18
48
|
}
|
|
19
49
|
|
|
20
|
-
svg path {
|
|
21
|
-
fill: ${({
|
|
50
|
+
& > svg path {
|
|
51
|
+
fill: ${({
|
|
52
|
+
theme: l
|
|
53
|
+
}) => l.colors.neutral500};
|
|
22
54
|
}
|
|
23
|
-
|
|
24
|
-
disabled: l,
|
|
25
|
-
error: c,
|
|
26
|
-
hint: d,
|
|
27
|
-
id: f,
|
|
28
|
-
onClear: b,
|
|
29
|
-
onChange: h,
|
|
30
|
-
value: a,
|
|
31
|
-
clearLabel: g,
|
|
32
|
-
label: y,
|
|
33
|
-
required: v,
|
|
34
|
-
selectButtonTitle: T,
|
|
35
|
-
step: O,
|
|
36
|
-
size: $,
|
|
37
|
-
...C
|
|
38
|
-
}) => {
|
|
39
|
-
const M = R(f), k = 24, r = [];
|
|
40
|
-
let o = 0;
|
|
41
|
-
for (let t = 0; t < k; t++)
|
|
42
|
-
for (o = 0; o < 60; )
|
|
43
|
-
r.push(`${t < 10 ? `0${t}` : t}:${o < 10 ? `0${o}` : o}`), o += O;
|
|
44
|
-
const q = () => {
|
|
45
|
-
const t = a.split(":")[0], p = a.split(":")[1], E = r.reduce((i, u) => {
|
|
46
|
-
const s = u.split(":")[0];
|
|
47
|
-
return Math.abs(s - t) < Math.abs(i - t) ? s : i;
|
|
48
|
-
}, r[0].split(":")[0]), I = r.reduce((i, u) => {
|
|
49
|
-
const s = u.split(":")[1];
|
|
50
|
-
return Math.abs(s - p) < Math.abs(i - p) ? s : i;
|
|
51
|
-
}, r[0].split(":")[1]);
|
|
52
|
-
return `${E}:${I}`;
|
|
53
|
-
};
|
|
54
|
-
return /* @__PURE__ */ n.createElement(
|
|
55
|
-
w,
|
|
56
|
-
{
|
|
57
|
-
id: M,
|
|
58
|
-
label: y,
|
|
59
|
-
placeholder: "--:--",
|
|
60
|
-
hint: d,
|
|
61
|
-
onClear: b,
|
|
62
|
-
clearLabel: g,
|
|
63
|
-
error: c,
|
|
64
|
-
value: a ? q() : null,
|
|
65
|
-
size: $,
|
|
66
|
-
onChange: h,
|
|
67
|
-
disabled: l,
|
|
68
|
-
required: v,
|
|
69
|
-
selectButtonTitle: T,
|
|
70
|
-
startIcon: /* @__PURE__ */ n.createElement(_, null, /* @__PURE__ */ n.createElement(z, null)),
|
|
71
|
-
...C
|
|
72
|
-
},
|
|
73
|
-
r.map((t) => /* @__PURE__ */ n.createElement(x, { value: t, key: t }, t))
|
|
74
|
-
);
|
|
75
|
-
};
|
|
76
|
-
m.defaultProps = {
|
|
77
|
-
disabled: !1,
|
|
78
|
-
error: void 0,
|
|
79
|
-
hint: void 0,
|
|
80
|
-
id: void 0,
|
|
81
|
-
label: void 0,
|
|
82
|
-
onClear: void 0,
|
|
83
|
-
required: !1,
|
|
84
|
-
size: "M",
|
|
85
|
-
selectButtonTitle: void 0,
|
|
86
|
-
step: 15,
|
|
87
|
-
value: void 0
|
|
88
|
-
};
|
|
89
|
-
m.propTypes = {
|
|
90
|
-
clearLabel: e.string.isRequired,
|
|
91
|
-
disabled: e.bool,
|
|
92
|
-
error: e.oneOfType([e.string, e.bool]),
|
|
93
|
-
hint: e.oneOfType([e.string, e.bool, e.node, e.arrayOf(e.node)]),
|
|
94
|
-
id: e.oneOfType([e.string, e.number]),
|
|
95
|
-
label: e.string,
|
|
96
|
-
onChange: e.func.isRequired,
|
|
97
|
-
onClear: e.func,
|
|
98
|
-
required: e.bool,
|
|
99
|
-
selectButtonTitle: e.string,
|
|
100
|
-
size: e.oneOf(Object.keys(B.input)),
|
|
101
|
-
step: e.number,
|
|
102
|
-
value: e.oneOfType([
|
|
103
|
-
e.arrayOf(e.oneOfType([e.string, e.number])),
|
|
104
|
-
e.string,
|
|
105
|
-
e.number
|
|
106
|
-
])
|
|
107
|
-
};
|
|
55
|
+
`;
|
|
108
56
|
export {
|
|
109
|
-
|
|
57
|
+
S as TimePicker
|
|
110
58
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/design-system",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.6",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@juggle/resize-observer": "^3.4.0",
|
|
31
31
|
"@playwright/test": "1.27.1",
|
|
32
|
-
"@strapi/icons": "^1.6.
|
|
32
|
+
"@strapi/icons": "^1.6.6",
|
|
33
33
|
"@swc/core": "^1.3.11",
|
|
34
34
|
"@swc/jest": "^0.2.23",
|
|
35
35
|
"@testing-library/jest-dom": "5.16.5",
|
|
@@ -62,6 +62,7 @@
|
|
|
62
62
|
"develop": "vite build --watch",
|
|
63
63
|
"build": "yarn build:prod",
|
|
64
64
|
"build:prod": "vite build",
|
|
65
|
+
"clean": "rm -rf dist node_modules",
|
|
65
66
|
"generate:types": "tsc --noEmit false --emitDeclarationOnly --declarationDir dist",
|
|
66
67
|
"lint": "eslint . --ext .js,.jsx,.tsx,.ts",
|
|
67
68
|
"format": "yarn lint --fix",
|
|
@@ -77,5 +78,5 @@
|
|
|
77
78
|
"@types/react": "17.0.2",
|
|
78
79
|
"@types/react-dom": "17.0.2"
|
|
79
80
|
},
|
|
80
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "be5ac8aa421db6f7c845c29a8df3c9528882d856"
|
|
81
82
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("react"),d=require("prop-types"),l=t=>t&&typeof t=="object"&&"default"in t?t:{default:t},u=l(o),e=l(d),a=t=>u.default.createElement("div",{...t}),r={ariaLabel:void 0,clearLabel:"clear",disabled:!1,error:void 0,hint:void 0,label:void 0,labelAction:void 0,onClear:void 0,required:!1,selectButtonTitle:"select",size:"M",step:1,value:void 0},i={ariaLabel:e.default.string,clearLabel:e.default.string,disabled:e.default.bool,error:e.default.oneOfType([e.default.string,e.default.bool]),hint:e.default.string,label:e.default.string,labelAction:e.default.element,name:e.default.string.isRequired,onChange:e.default.func.isRequired,onClear:e.default.func,required:e.default.bool,selectButtonTitle:e.default.string,size:e.default.oneOf(["S","M"]),step:e.default.number,value:e.default.instanceOf(Date)};a.defaultProps=r;a.propTypes=i;exports.DateTimePickerProps=a;exports.dateTimePickerDefaultProps=r;exports.dateTimePickerPropTypes=i;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import t from "react";
|
|
2
|
-
import e from "prop-types";
|
|
3
|
-
const i = (r) => /* @__PURE__ */ t.createElement("div", { ...r }), o = {
|
|
4
|
-
ariaLabel: void 0,
|
|
5
|
-
clearLabel: "clear",
|
|
6
|
-
disabled: !1,
|
|
7
|
-
error: void 0,
|
|
8
|
-
hint: void 0,
|
|
9
|
-
label: void 0,
|
|
10
|
-
labelAction: void 0,
|
|
11
|
-
onClear: void 0,
|
|
12
|
-
required: !1,
|
|
13
|
-
selectButtonTitle: "select",
|
|
14
|
-
size: "M",
|
|
15
|
-
step: 1,
|
|
16
|
-
value: void 0
|
|
17
|
-
}, l = {
|
|
18
|
-
ariaLabel: e.string,
|
|
19
|
-
clearLabel: e.string,
|
|
20
|
-
disabled: e.bool,
|
|
21
|
-
error: e.oneOfType([e.string, e.bool]),
|
|
22
|
-
hint: e.string,
|
|
23
|
-
label: e.string,
|
|
24
|
-
labelAction: e.element,
|
|
25
|
-
name: e.string.isRequired,
|
|
26
|
-
onChange: e.func.isRequired,
|
|
27
|
-
onClear: e.func,
|
|
28
|
-
required: e.bool,
|
|
29
|
-
selectButtonTitle: e.string,
|
|
30
|
-
size: e.oneOf(["S", "M"]),
|
|
31
|
-
step: e.number,
|
|
32
|
-
value: e.instanceOf(Date)
|
|
33
|
-
};
|
|
34
|
-
i.defaultProps = o;
|
|
35
|
-
i.propTypes = l;
|
|
36
|
-
export {
|
|
37
|
-
i as DateTimePickerProps,
|
|
38
|
-
o as dateTimePickerDefaultProps,
|
|
39
|
-
l as dateTimePickerPropTypes
|
|
40
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const e=require("../parseDate.cjs");describe("parseDate",()=>{it("should return a date",()=>{expect(e.parseDate("2021-11-05T15:37:29.592Z")instanceof Date).toBeTruthy()}),it("should return null if the passed params has not the right format",()=>{expect(e.parseDate("test")).toBeNull()})});
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { parseDate as t } from "../parseDate.js";
|
|
2
|
-
describe("parseDate", () => {
|
|
3
|
-
it("should return a date", () => {
|
|
4
|
-
expect(t("2021-11-05T15:37:29.592Z") instanceof Date).toBeTruthy();
|
|
5
|
-
}), it("should return null if the passed params has not the right format", () => {
|
|
6
|
-
expect(t("test")).toBeNull();
|
|
7
|
-
});
|
|
8
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=t=>{const e=Date.parse(t);return Number.isNaN(e)?null:new Date(e)};exports.parseDate=r;
|