@strapi/design-system 1.8.2 → 1.9.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/dist/BaseCheckbox/BaseCheckbox.cjs +4 -4
- package/dist/BaseCheckbox/BaseCheckbox.js +19 -18
- package/dist/CarouselInput/Carousel.cjs +4 -4
- package/dist/CarouselInput/Carousel.js +13 -13
- package/dist/CarouselInput/CarouselInput.cjs +1 -1
- package/dist/CarouselInput/CarouselInput.js +14 -13
- package/dist/Checkbox/Checkbox.cjs +2 -2
- package/dist/Checkbox/Checkbox.js +22 -21
- package/dist/Combobox/Combobox.cjs +10 -10
- package/dist/Combobox/Combobox.js +56 -55
- package/dist/DatePicker/DatePicker.cjs +2 -2
- package/dist/DatePicker/DatePicker.js +2 -2
- package/dist/DateTimePicker/DateTimePicker.cjs +3 -3
- package/dist/DateTimePicker/DateTimePicker.js +46 -42
- package/dist/JSONInput/JSONInput.cjs +33 -1
- package/dist/JSONInput/JSONInput.js +85 -46
- package/dist/Select/MultiSelect.cjs +6 -6
- package/dist/Select/MultiSelect.js +35 -34
- package/dist/Select/SingleSelect.cjs +1 -1
- package/dist/Select/SingleSelect.js +31 -30
- package/dist/TextInput/TextInput.cjs +1 -1
- package/dist/TextInput/TextInput.js +15 -14
- package/dist/TimePicker/TimePicker.cjs +2 -2
- package/dist/TimePicker/TimePicker.js +38 -38
- package/dist/ToggleInput/ToggleInput.cjs +8 -8
- package/dist/ToggleInput/ToggleInput.js +26 -25
- package/dist/themes/utils.cjs +9 -9
- package/dist/themes/utils.js +9 -9
- package/package.json +5 -5
- package/dist/JSONInput/JSONInputContainer.cjs +0 -33
- package/dist/JSONInput/JSONInputContainer.js +0 -39
|
@@ -1,44 +1,45 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import * as
|
|
3
|
-
import {
|
|
1
|
+
import { jsx as e, jsxs as h } from "react/jsx-runtime";
|
|
2
|
+
import * as o from "react";
|
|
3
|
+
import { Root as q, Trigger as W, Value as _, Portal as H, Content as M, Viewport as P, Item as z, ItemText as A } from "./SelectParts.js";
|
|
4
4
|
import { stripReactIdOfColon as D } from "../helpers/strings.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { Typography as J } from "../Typography/Typography.js";
|
|
5
|
+
import { useComposedRefs as G } from "../hooks/useComposeRefs.js";
|
|
6
|
+
import { useId as C } from "../hooks/useId.js";
|
|
7
|
+
import { useIntersection as J } from "../hooks/useIntersection.js";
|
|
9
8
|
import { Field as K } from "../Field/Field.js";
|
|
10
9
|
import { Flex as Q } from "../Flex/Flex.js";
|
|
11
10
|
import { FieldLabel as U } from "../Field/FieldLabel.js";
|
|
12
11
|
import { FieldHint as X } from "../Field/FieldHint.js";
|
|
13
12
|
import { FieldError as Y } from "../Field/FieldError.js";
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
},
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}, E =
|
|
25
|
-
|
|
26
|
-
},
|
|
27
|
-
|
|
28
|
-
|
|
13
|
+
import { Box as T } from "../Box/Box.js";
|
|
14
|
+
import { Typography as Z } from "../Typography/Typography.js";
|
|
15
|
+
const Ie = o.forwardRef(({ error: d, hint: r, id: c, label: n, labelAction: i, required: s, selectButtonTitle: R, ...m }, a) => {
|
|
16
|
+
const l = C(c), f = o.useRef(null), g = () => {
|
|
17
|
+
f.current.focus();
|
|
18
|
+
}, I = G(a, f);
|
|
19
|
+
return e(K, { hint: r, error: d, id: l, required: s, children: h(Q, { direction: "column", alignItems: "stretch", gap: 1, children: [n ? e(U, { onClick: g, action: i, children: n }) : null, e(ee, { label: n, id: l, ref: I, required: s, ...m }), e(X, {}), e(Y, {})] }) });
|
|
20
|
+
}), ee = o.forwardRef(({ "aria-label": d, id: r, children: c, clearLabel: n = "Clear", customizeContent: i, disabled: s, error: R, label: m, onChange: a, onClear: l, onReachEnd: f, placeholder: g, required: I, selectButtonTitle: re, startIcon: B, size: O = "M", value: p, ...w }, F) => {
|
|
21
|
+
const [$, S] = o.useState(), [y, k] = o.useState(!1), v = (t) => {
|
|
22
|
+
k(t);
|
|
23
|
+
}, E = (t) => {
|
|
24
|
+
l && l(t), a || S("");
|
|
25
|
+
}, L = `${r}-hint`, N = `${r}-error`, V = (t) => {
|
|
26
|
+
a ? a(typeof p == "number" ? Number(t) : t) : S(t);
|
|
27
|
+
}, b = o.useRef(null), j = C(), x = `intersection-${D(j)}`;
|
|
28
|
+
J(b, (t) => {
|
|
29
|
+
f && f(t);
|
|
29
30
|
}, {
|
|
30
|
-
selectorToWatch: `#${
|
|
31
|
+
selectorToWatch: `#${x}`,
|
|
31
32
|
/**
|
|
32
33
|
* We need to know when the select is open because only then will viewportRef
|
|
33
34
|
* not be null. Because it uses a portal that (sensibly) is not mounted 24/7.
|
|
34
35
|
*/
|
|
35
|
-
skipWhen: !
|
|
36
|
+
skipWhen: !y
|
|
36
37
|
});
|
|
37
|
-
const
|
|
38
|
-
return h(
|
|
39
|
-
},
|
|
38
|
+
const u = (typeof p < "u" && p !== null ? p.toString() : $) ?? "";
|
|
39
|
+
return h(q, { onOpenChange: v, disabled: s, required: I, onValueChange: V, value: u, ...w, children: [e(W, { ref: F, "aria-label": m ?? d, "aria-describedby": r ? `${L} ${N}` : void 0, id: r, startIcon: B, size: O, hasError: !!R, disabled: s, clearLabel: n, onClear: u && l ? E : void 0, children: e(_, { placeholder: g, textColor: u ? "neutral800" : "neutral600", children: u && i ? i(u) : void 0 }) }), e(H, { children: e(M, { position: "popper", sideOffset: 4, children: h(P, { ref: b, children: [c, e(T, { id: x, width: "100%", height: "1px" })] }) }) })] });
|
|
40
|
+
}), Re = o.forwardRef(({ value: d, startIcon: r, children: c, ...n }, i) => h(z, { ref: i, value: d.toString(), ...n, children: [r && e(T, { as: "span", "aria-hidden": !0, children: r }), e(Z, { textColor: "neutral800", children: e(A, { children: c }) })] }));
|
|
40
41
|
export {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
Ie as SingleSelect,
|
|
43
|
+
ee as SingleSelectInput,
|
|
44
|
+
Re as SingleSelectOption
|
|
44
45
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("react"),I=require("../hooks/useId.cjs"),f=require("../Field/Field.cjs"),q=require("../Flex/Flex.cjs"),j=require("../Field/FieldLabel.cjs"),h=require("../Field/FieldInput.cjs"),m=require("../Field/FieldHint.cjs"),R=require("../Field/FieldError.cjs"),u=r.forwardRef(({name:l,hint:o,error:d,label:n,labelAction:c,id:a,required:p,...t},x)=>{const F=I.useId(a),i=r.useRef(null),s=r.useRef(null);if(!n&&!t["aria-label"])throw new Error('The TextInput component needs a "label" or an "aria-label" props');return r.useImperativeHandle(x,()=>({input:s,inputWrapperRef:i}),[]),e.jsx("div",{ref:i,children:e.jsx(f.Field,{name:l,hint:o,error:d,id:F,required:p,children:e.jsxs(q.Flex,{direction:"column",alignItems:"stretch",gap:1,children:[n&&e.jsx(j.FieldLabel,{action:c,children:n}),e.jsx(h.FieldInput,{ref:s,...t}),e.jsx(m.FieldHint,{}),e.jsx(R.FieldError,{})]})})})});u.displayName="TextInput";exports.TextInput=u;
|
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
import { jsx as r, jsxs as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import { useId as
|
|
4
|
-
import { Field as
|
|
5
|
-
import { Flex as
|
|
1
|
+
import { jsx as r, jsxs as c } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as h, useRef as n, useImperativeHandle as I } from "react";
|
|
3
|
+
import { useId as x } from "../hooks/useId.js";
|
|
4
|
+
import { Field as F } from "../Field/Field.js";
|
|
5
|
+
import { Flex as R } from "../Flex/Flex.js";
|
|
6
6
|
import { FieldLabel as T } from "../Field/FieldLabel.js";
|
|
7
7
|
import { FieldInput as g } from "../Field/FieldInput.js";
|
|
8
8
|
import { FieldHint as w } from "../Field/FieldHint.js";
|
|
9
|
-
import { FieldError as
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
if (!e && !
|
|
9
|
+
import { FieldError as b } from "../Field/FieldError.js";
|
|
10
|
+
const j = h(({ name: m, hint: p, error: l, label: e, labelAction: d, id: a, required: f, ...t }, u) => {
|
|
11
|
+
const s = x(a), i = n(null), o = n(null);
|
|
12
|
+
if (!e && !t["aria-label"])
|
|
13
13
|
throw new Error('The TextInput component needs a "label" or an "aria-label" props');
|
|
14
|
-
return
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
return I(u, () => ({
|
|
15
|
+
input: o,
|
|
16
|
+
inputWrapperRef: i
|
|
17
|
+
}), []), r("div", { ref: i, children: r(F, { name: m, hint: p, error: l, id: s, required: f, children: c(R, { direction: "column", alignItems: "stretch", gap: 1, children: [e && r(T, { action: d, children: e }), r(g, { ref: o, ...t }), r(w, {}), r(b, {})] }) }) });
|
|
17
18
|
});
|
|
18
|
-
|
|
19
|
+
j.displayName = "TextInput";
|
|
19
20
|
export {
|
|
20
|
-
|
|
21
|
+
j as TextInput
|
|
21
22
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),M=require("react"),O=require("@strapi/icons"),N=require("styled-components"),T=require("../Combobox/Combobox.cjs"),v=require("../DesignSystemProvider.cjs"),A=require("../hooks/useControllableState.cjs"),B=require("../hooks/useDateFormatter.cjs"),F=require("../hooks/useId.cjs"),R=require("../Field/Field.cjs"),L=require("../Flex/Flex.cjs"),$=require("../Field/FieldLabel.cjs"),E=require("../Field/FieldHint.cjs"),z=require("../Field/FieldError.cjs"),H=t=>t&&t.__esModule?t:{default:t};function Z(t){if(t&&t.__esModule)return t;const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const s in t)if(s!=="default"){const l=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(n,s,l.get?l:{enumerable:!0,get:()=>t[s]})}}return n.default=t,Object.freeze(n)}const u=Z(M),G=H(N),g=t=>!!t.match(/^[^a-zA-Z]*$/),_=u.forwardRef(({id:t,step:n=15,ariaLabel:s,selectButtonTitle:l,value:a,defaultValue:m,onChange:p,...h},f)=>{const w=v.useDesignSystem("TimePicker"),k=F.useId(t),[I,c]=u.useState(""),[y,b]=A.useControllableState({prop:a,defaultProp:m,onChange:p}),d=B.useDateFormatter(w.locale,{hour:"2-digit",minute:"2-digit",hour12:!1}),x=u.useMemo(()=>{const e=d.formatToParts(new Date),{value:r}=e.find(i=>i.type==="literal");return r},[d]),S=u.useMemo(()=>{const e=60/n;return[...Array(24).keys()].flatMap(r=>[...Array(e).keys()].map(i=>d.format(new Date(0,0,0,r,i*n))))},[n,d]),D=e=>{(!e||g(e))&&c(e)},j=e=>{const[r,i]=e.split(x);if(!r&&!i)return;const q=Number(r??"0"),C=Number(i??"0");if(!(q>23||C>59))return d.format(new Date(0,0,0,q,C))},P=e=>{const r=j(e.target.value);r?(c(r),b(r)):c(y)},V=e=>{if(typeof e<"u"){const r=j(e);b(r)}else b(e)};return u.useEffect(()=>{const e=typeof a>"u"?"":a;g(e)&&c(e)},[a,c]),o.jsx(T.ComboboxInput,{...h,ref:f,value:y,onChange:V,isPrintableCharacter:g,allowCustomValue:!0,placeholder:`--${x}--`,autocomplete:"none",startIcon:o.jsx(J,{}),id:k,inputMode:"numeric",pattern:`\\d{2}\\${x}\\d{2}`,textValue:I,onTextValueChange:D,onBlur:P,children:S.map(e=>o.jsx(T.Option,{value:e,children:e},e))})}),J=G.default(O.Clock)`
|
|
2
2
|
height: 1rem;
|
|
3
3
|
width: 1rem;
|
|
4
4
|
|
|
5
5
|
& > path {
|
|
6
6
|
fill: ${({theme:t})=>t.colors.neutral500};
|
|
7
7
|
}
|
|
8
|
-
`,
|
|
8
|
+
`,K=u.forwardRef(({label:t,error:n,hint:s,id:l,required:a,labelAction:m,...p},h)=>{const f=F.useId(l);return o.jsx(R.Field,{hint:s,error:n,id:f,required:a,children:o.jsxs(L.Flex,{direction:"column",alignItems:"stretch",gap:1,children:[o.jsx($.FieldLabel,{action:m,children:t}),o.jsx(_,{ref:h,id:f,error:n,required:a,...p}),o.jsx(E.FieldHint,{}),o.jsx(z.FieldError,{})]})})});exports.TimePicker=K;exports.TimePickerInput=_;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { jsx as r, jsxs as
|
|
2
|
-
import * as
|
|
3
|
-
import { Clock as
|
|
4
|
-
import
|
|
5
|
-
import { ComboboxInput as
|
|
6
|
-
import { useDesignSystem as
|
|
7
|
-
import { useControllableState as
|
|
1
|
+
import { jsx as r, jsxs as M } from "react/jsx-runtime";
|
|
2
|
+
import * as l from "react";
|
|
3
|
+
import { Clock as S } from "@strapi/icons";
|
|
4
|
+
import $ from "styled-components";
|
|
5
|
+
import { ComboboxInput as v, Option as L } from "../Combobox/Combobox.js";
|
|
6
|
+
import { useDesignSystem as P } from "../DesignSystemProvider.js";
|
|
7
|
+
import { useControllableState as R } from "../hooks/useControllableState.js";
|
|
8
8
|
import { useDateFormatter as j } from "../hooks/useDateFormatter.js";
|
|
9
9
|
import { useId as V } from "../hooks/useId.js";
|
|
10
10
|
import { Field as E } from "../Field/Field.js";
|
|
@@ -12,73 +12,73 @@ import { Flex as O } from "../Flex/Flex.js";
|
|
|
12
12
|
import { FieldLabel as _ } from "../Field/FieldLabel.js";
|
|
13
13
|
import { FieldHint as q } from "../Field/FieldHint.js";
|
|
14
14
|
import { FieldError as z } from "../Field/FieldError.js";
|
|
15
|
-
const
|
|
15
|
+
const b = (o) => !!o.match(/^[^a-zA-Z]*$/), H = l.forwardRef(({
|
|
16
16
|
id: o,
|
|
17
17
|
step: a = 15,
|
|
18
18
|
/**
|
|
19
19
|
* @preserve
|
|
20
20
|
* @deprecated This is no longer used.
|
|
21
21
|
*/
|
|
22
|
-
ariaLabel:
|
|
22
|
+
ariaLabel: C,
|
|
23
23
|
/**
|
|
24
24
|
* @preserve
|
|
25
25
|
* @deprecated This is no longer used.
|
|
26
26
|
*/
|
|
27
|
-
selectButtonTitle:
|
|
27
|
+
selectButtonTitle: x,
|
|
28
28
|
value: n,
|
|
29
29
|
defaultValue: c,
|
|
30
|
-
onChange:
|
|
31
|
-
...
|
|
32
|
-
}) => {
|
|
33
|
-
const
|
|
30
|
+
onChange: f,
|
|
31
|
+
...d
|
|
32
|
+
}, m) => {
|
|
33
|
+
const k = P("TimePicker"), I = V(o), [A, s] = l.useState(""), [w, p] = R({
|
|
34
34
|
prop: n,
|
|
35
35
|
defaultProp: c,
|
|
36
|
-
onChange:
|
|
37
|
-
}),
|
|
36
|
+
onChange: f
|
|
37
|
+
}), u = j(k.locale, {
|
|
38
38
|
hour: "2-digit",
|
|
39
39
|
minute: "2-digit",
|
|
40
40
|
hour12: !1
|
|
41
|
-
}),
|
|
42
|
-
const e =
|
|
41
|
+
}), h = l.useMemo(() => {
|
|
42
|
+
const e = u.formatToParts(/* @__PURE__ */ new Date()), { value: t } = e.find((i) => i.type === "literal");
|
|
43
43
|
return t;
|
|
44
|
-
}, [
|
|
44
|
+
}, [u]), F = l.useMemo(() => {
|
|
45
45
|
const e = 60 / a;
|
|
46
|
-
return [...Array(24).keys()].flatMap((t) => [...Array(e).keys()].map((i) =>
|
|
47
|
-
}, [a,
|
|
48
|
-
(!e ||
|
|
46
|
+
return [...Array(24).keys()].flatMap((t) => [...Array(e).keys()].map((i) => u.format(new Date(0, 0, 0, t, i * a))));
|
|
47
|
+
}, [a, u]), N = (e) => {
|
|
48
|
+
(!e || b(e)) && s(e);
|
|
49
49
|
}, y = (e) => {
|
|
50
|
-
const [t, i] = e.split(
|
|
50
|
+
const [t, i] = e.split(h);
|
|
51
51
|
if (!t && !i)
|
|
52
52
|
return;
|
|
53
53
|
const T = Number(t ?? "0"), g = Number(i ?? "0");
|
|
54
54
|
if (!(T > 23 || g > 59))
|
|
55
|
-
return
|
|
56
|
-
}, N = (e) => {
|
|
57
|
-
const t = y(e.target.value);
|
|
58
|
-
t ? (l(t), f(t)) : l(x);
|
|
55
|
+
return u.format(new Date(0, 0, 0, T, g));
|
|
59
56
|
}, B = (e) => {
|
|
57
|
+
const t = y(e.target.value);
|
|
58
|
+
t ? (s(t), p(t)) : s(w);
|
|
59
|
+
}, D = (e) => {
|
|
60
60
|
if (typeof e < "u") {
|
|
61
61
|
const t = y(e);
|
|
62
|
-
|
|
62
|
+
p(t);
|
|
63
63
|
} else
|
|
64
|
-
|
|
64
|
+
p(e);
|
|
65
65
|
};
|
|
66
|
-
return
|
|
66
|
+
return l.useEffect(() => {
|
|
67
67
|
const e = typeof n > "u" ? "" : n;
|
|
68
|
-
|
|
69
|
-
}, [n,
|
|
70
|
-
},
|
|
68
|
+
b(e) && s(e);
|
|
69
|
+
}, [n, s]), r(v, { ...d, ref: m, value: w, onChange: D, isPrintableCharacter: b, allowCustomValue: !0, placeholder: `--${h}--`, autocomplete: "none", startIcon: r(Z, {}), id: I, inputMode: "numeric", pattern: `\\d{2}\\${h}\\d{2}`, textValue: A, onTextValueChange: N, onBlur: B, children: F.map((e) => r(L, { value: e, children: e }, e)) });
|
|
70
|
+
}), Z = $(S)`
|
|
71
71
|
height: 1rem;
|
|
72
72
|
width: 1rem;
|
|
73
73
|
|
|
74
74
|
& > path {
|
|
75
75
|
fill: ${({ theme: o }) => o.colors.neutral500};
|
|
76
76
|
}
|
|
77
|
-
`,
|
|
78
|
-
const
|
|
79
|
-
return r(E, { hint:
|
|
80
|
-
};
|
|
77
|
+
`, ae = l.forwardRef(({ label: o, error: a, hint: C, id: x, required: n, labelAction: c, ...f }, d) => {
|
|
78
|
+
const m = V(x);
|
|
79
|
+
return r(E, { hint: C, error: a, id: m, required: n, children: M(O, { direction: "column", alignItems: "stretch", gap: 1, children: [r(_, { action: c, children: o }), r(H, { ref: d, id: m, error: a, required: n, ...f }), r(q, {}), r(z, {})] }) });
|
|
80
|
+
});
|
|
81
81
|
export {
|
|
82
|
-
|
|
82
|
+
ae as TimePicker,
|
|
83
83
|
H as TimePickerInput
|
|
84
84
|
};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
2
|
-
${
|
|
3
|
-
`,
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),w=require("react"),C=require("styled-components"),k=require("../hooks/useControllableState.cjs"),I=require("../hooks/useId.cjs"),R=require("../Field/FieldContext.cjs"),b=require("../Typography/Typography.cjs"),c=require("../Flex/Flex.cjs"),S=require("../themes/utils.cjs"),_=require("../Field/Field.cjs"),$=require("../Field/FieldLabel.cjs"),v=require("../Field/FieldHint.cjs"),B=require("../Field/FieldError.cjs"),O=require("../TextButton/TextButton.cjs"),W=e=>e&&e.__esModule?e:{default:e};function M(e){if(e&&e.__esModule)return e;const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const a=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(o,t,a.get?a:{enumerable:!0,get:()=>e[t]})}}return o.default=e,Object.freeze(o)}const q=M(w),p=W(C),z=q.forwardRef(({offLabel:e,onLabel:o,disabled:t,checked:a,onChange:h,size:u="M",...g},f)=>{const[n=!1,s]=k.useControllableState({prop:a}),{error:d,id:i,name:x,required:j}=R.useField(),l=n!==null&&!n,F=`${i}-hint`,T=`${i}-error`;return r.jsxs(E,{position:"relative",hasRadius:!0,padding:1,background:t?"neutral150":"neutral100",borderStyle:"solid",borderWidth:"1px",borderColor:"neutral200",wrap:"wrap",cursor:t?"not-allowed":"pointer",hasError:!!d,children:[r.jsx(m,{hasRadius:!0,flex:"1 1 50%",paddingTop:2,paddingBottom:2,paddingLeft:3,paddingRight:3,justifyContent:"center",background:t&&l?"neutral200":l?"neutral0":"transparent",borderColor:t&&l?"neutral300":l?"neutral200":t?"neutral150":"neutral100",size:u,children:r.jsx(b.Typography,{variant:"pi",fontWeight:"bold",textTransform:"uppercase",textColor:t?"neutral700":l?"danger700":"neutral600",children:e})}),r.jsx(m,{hasRadius:!0,flex:"1 1 50%",paddingLeft:3,paddingRight:3,justifyContent:"center",background:t&&n?"neutral200":n?"neutral0":"transparent",borderColor:t&&n?"neutral300":n?"neutral200":t?"neutral150":"neutral100",size:u,children:r.jsx(b.Typography,{variant:"pi",fontWeight:"bold",textTransform:"uppercase",textColor:t?"neutral700":n?"primary600":"neutral600",children:o})}),r.jsx(L,{...g,ref:f,onChange:y=>{s(y.currentTarget.checked),h?.(y)},type:"checkbox",id:i,name:x,"aria-required":j,disabled:t,"aria-disabled":t,"aria-describedby":i?`${F} ${T}`:void 0,checked:!!n})]})}),E=p.default(c.Flex)`
|
|
2
|
+
${S.inputFocusStyle()}
|
|
3
|
+
`,m=p.default(c.Flex)`
|
|
4
4
|
/**
|
|
5
5
|
We declare the defined value because we want the height of the input when
|
|
6
6
|
the values are in a row to be 40px. But defining a height on the label
|
|
7
7
|
would break the input when it wraps.
|
|
8
8
|
*/
|
|
9
|
-
padding-top: ${({size:
|
|
10
|
-
padding-bottom: ${({size:
|
|
11
|
-
`,
|
|
9
|
+
padding-top: ${({size:e})=>`${e==="S"?"2px":"6px"}`};
|
|
10
|
+
padding-bottom: ${({size:e})=>`${e==="S"?"2px":"6px"}`};
|
|
11
|
+
`,L=p.default.input`
|
|
12
12
|
height: 100%;
|
|
13
13
|
left: 0;
|
|
14
14
|
opacity: 0;
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
top: 0;
|
|
17
17
|
z-index: 0;
|
|
18
18
|
width: 100%;
|
|
19
|
-
`,
|
|
19
|
+
`,P=q.forwardRef(({disabled:e=!1,error:o,hint:t,label:a,name:h,labelAction:u,required:g=!1,id:f,onClear:n,clearLabel:s,checked:d,...i},x)=>{const j=I.useId(f);return r.jsx(_.Field,{name:h,hint:t,error:o,id:j,required:g,maxWidth:"320px",children:r.jsxs(c.Flex,{direction:"column",alignItems:"stretch",gap:1,children:[r.jsxs(c.Flex,{children:[a?r.jsx($.FieldLabel,{action:u,children:a}):null,s&&n&&d!==null&&!e&&r.jsx(D,{onClick:n,children:s})]}),r.jsx(z,{ref:x,checked:d,disabled:e,...i}),r.jsx(v.FieldHint,{}),r.jsx(B.FieldError,{})]})})}),D=p.default(O.TextButton)`
|
|
20
20
|
align-self: flex-end;
|
|
21
21
|
margin-left: auto;
|
|
22
|
-
`;exports.ToggleInput=
|
|
22
|
+
`;exports.ToggleInput=P;
|
|
@@ -1,26 +1,27 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsxs as w, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import * as b from "react";
|
|
2
3
|
import c from "styled-components";
|
|
3
|
-
import { useControllableState as
|
|
4
|
-
import { useId as
|
|
5
|
-
import {
|
|
6
|
-
import { inputFocusStyle as $ } from "../themes/utils.js";
|
|
7
|
-
import { TextButton as F } from "../TextButton/TextButton.js";
|
|
8
|
-
import { Field as B } from "../Field/Field.js";
|
|
9
|
-
import { FieldLabel as W } from "../Field/FieldLabel.js";
|
|
10
|
-
import { FieldHint as v } from "../Field/FieldHint.js";
|
|
11
|
-
import { FieldError as R } from "../Field/FieldError.js";
|
|
12
|
-
import { useField as S } from "../Field/FieldContext.js";
|
|
4
|
+
import { useControllableState as $ } from "../hooks/useControllableState.js";
|
|
5
|
+
import { useId as F } from "../hooks/useId.js";
|
|
6
|
+
import { useField as R } from "../Field/FieldContext.js";
|
|
13
7
|
import { Typography as y } from "../Typography/Typography.js";
|
|
14
|
-
|
|
15
|
-
|
|
8
|
+
import { Flex as u } from "../Flex/Flex.js";
|
|
9
|
+
import { inputFocusStyle as B } from "../themes/utils.js";
|
|
10
|
+
import { Field as W } from "../Field/Field.js";
|
|
11
|
+
import { FieldLabel as v } from "../Field/FieldLabel.js";
|
|
12
|
+
import { FieldHint as S } from "../Field/FieldHint.js";
|
|
13
|
+
import { FieldError as j } from "../Field/FieldError.js";
|
|
14
|
+
import { TextButton as q } from "../TextButton/TextButton.js";
|
|
15
|
+
const z = b.forwardRef(({ offLabel: n, onLabel: h, disabled: e, checked: a, onChange: s, size: l = "M", ...f }, m) => {
|
|
16
|
+
const [r = !1, p] = $({
|
|
16
17
|
prop: a
|
|
17
|
-
}), { error:
|
|
18
|
-
return
|
|
18
|
+
}), { error: d, id: o, name: g, required: x } = R(), i = r !== null && !r, T = `${o}-hint`, I = `${o}-error`;
|
|
19
|
+
return w(E, { position: "relative", hasRadius: !0, padding: 1, background: e ? "neutral150" : "neutral100", borderStyle: "solid", borderWidth: "1px", borderColor: "neutral200", wrap: "wrap", cursor: e ? "not-allowed" : "pointer", hasError: !!d, children: [t(C, { hasRadius: !0, flex: "1 1 50%", paddingTop: 2, paddingBottom: 2, paddingLeft: 3, paddingRight: 3, justifyContent: "center", background: e && i ? "neutral200" : i ? "neutral0" : "transparent", borderColor: e && i ? "neutral300" : i ? "neutral200" : e ? "neutral150" : "neutral100", size: l, children: t(y, { variant: "pi", fontWeight: "bold", textTransform: "uppercase", textColor: e ? "neutral700" : i ? "danger700" : "neutral600", children: n }) }), t(C, { hasRadius: !0, flex: "1 1 50%", paddingLeft: 3, paddingRight: 3, justifyContent: "center", background: e && r ? "neutral200" : r ? "neutral0" : "transparent", borderColor: e && r ? "neutral300" : r ? "neutral200" : e ? "neutral150" : "neutral100", size: l, children: t(y, { variant: "pi", fontWeight: "bold", textTransform: "uppercase", textColor: e ? "neutral700" : r ? "primary600" : "neutral600", children: h }) }), t(L, { ...f, ref: m, onChange: (k) => {
|
|
19
20
|
p(k.currentTarget.checked), s?.(k);
|
|
20
|
-
}, type: "checkbox", id: o, name: g, "aria-required":
|
|
21
|
-
},
|
|
22
|
-
${
|
|
23
|
-
`, C = c(
|
|
21
|
+
}, type: "checkbox", id: o, name: g, "aria-required": x, disabled: e, "aria-disabled": e, "aria-describedby": o ? `${T} ${I}` : void 0, checked: !!r })] });
|
|
22
|
+
}), E = c(u)`
|
|
23
|
+
${B()}
|
|
24
|
+
`, C = c(u)`
|
|
24
25
|
/**
|
|
25
26
|
We declare the defined value because we want the height of the input when
|
|
26
27
|
the values are in a row to be 40px. But defining a height on the label
|
|
@@ -28,7 +29,7 @@ const j = ({ offLabel: n, onLabel: h, disabled: e, checked: a, onChange: s, size
|
|
|
28
29
|
*/
|
|
29
30
|
padding-top: ${({ size: n }) => `${n === "S" ? "2px" : "6px"}`};
|
|
30
31
|
padding-bottom: ${({ size: n }) => `${n === "S" ? "2px" : "6px"}`};
|
|
31
|
-
`,
|
|
32
|
+
`, L = c.input`
|
|
32
33
|
height: 100%;
|
|
33
34
|
left: 0;
|
|
34
35
|
opacity: 0;
|
|
@@ -36,13 +37,13 @@ const j = ({ offLabel: n, onLabel: h, disabled: e, checked: a, onChange: s, size
|
|
|
36
37
|
top: 0;
|
|
37
38
|
z-index: 0;
|
|
38
39
|
width: 100%;
|
|
39
|
-
`,
|
|
40
|
-
const
|
|
41
|
-
return
|
|
42
|
-
},
|
|
40
|
+
`, Y = b.forwardRef(({ disabled: n = !1, error: h, hint: e, label: a, name: s, labelAction: l, required: f = !1, id: m, onClear: r, clearLabel: p, checked: d, ...o }, g) => {
|
|
41
|
+
const x = F(m);
|
|
42
|
+
return t(W, { name: s, hint: e, error: h, id: x, required: f, maxWidth: "320px", children: w(u, { direction: "column", alignItems: "stretch", gap: 1, children: [w(u, { children: [a ? t(v, { action: l, children: a }) : null, p && r && d !== null && !n && t(H, { onClick: r, children: p })] }), t(z, { ref: g, checked: d, disabled: n, ...o }), t(S, {}), t(j, {})] }) });
|
|
43
|
+
}), H = c(q)`
|
|
43
44
|
align-self: flex-end;
|
|
44
45
|
margin-left: auto;
|
|
45
46
|
`;
|
|
46
47
|
export {
|
|
47
|
-
|
|
48
|
+
Y as ToggleInput
|
|
48
49
|
};
|
package/dist/themes/utils.cjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("styled-components"),s=t=>({theme:o,size:r})=>o.sizes[t][r],i=(t="&")=>({theme:o,hasError:r=!1})=>e.css`
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
outline: none;
|
|
3
|
+
box-shadow: 0;
|
|
4
|
+
transition-property: border-color, box-shadow, fill;
|
|
5
|
+
transition-duration: 0.2s;
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
${t}:focus-within {
|
|
8
|
+
border: 1px solid ${r?o.colors.danger600:o.colors.primary600};
|
|
9
|
+
box-shadow: ${r?o.colors.danger600:o.colors.primary600} 0px 0px 0px 2px;
|
|
10
|
+
}
|
|
11
|
+
`,n=({theme:t})=>e.css`
|
|
12
12
|
position: relative;
|
|
13
13
|
outline: none;
|
|
14
14
|
|
package/dist/themes/utils.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { css as i } from "styled-components";
|
|
2
2
|
const s = (t) => ({ theme: o, size: r }) => o.sizes[t][r], p = (t = "&") => ({ theme: o, hasError: r = !1 }) => i`
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
outline: none;
|
|
4
|
+
box-shadow: 0;
|
|
5
|
+
transition-property: border-color, box-shadow, fill;
|
|
6
|
+
transition-duration: 0.2s;
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
${t}:focus-within {
|
|
9
|
+
border: 1px solid ${r ? o.colors.danger600 : o.colors.primary600};
|
|
10
|
+
box-shadow: ${r ? o.colors.danger600 : o.colors.primary600} 0px 0px 0px 2px;
|
|
11
|
+
}
|
|
12
|
+
`, e = ({ theme: t }) => i`
|
|
13
13
|
position: relative;
|
|
14
14
|
outline: none;
|
|
15
15
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/design-system",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"@radix-ui/react-dismissable-layer": "^1.0.4",
|
|
26
26
|
"@radix-ui/react-dropdown-menu": "^2.0.5",
|
|
27
27
|
"@radix-ui/react-focus-scope": "1.0.3",
|
|
28
|
-
"@strapi/ui-primitives": "^1.
|
|
29
|
-
"@uiw/react-codemirror": "^4.21.
|
|
28
|
+
"@strapi/ui-primitives": "^1.9.0",
|
|
29
|
+
"@uiw/react-codemirror": "^4.21.9",
|
|
30
30
|
"aria-hidden": "^1.2.3",
|
|
31
31
|
"compute-scroll-into-view": "^3.0.3",
|
|
32
32
|
"prop-types": "^15.8.1",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@playwright/test": "1.35.1",
|
|
37
|
-
"@strapi/icons": "^1.
|
|
37
|
+
"@strapi/icons": "^1.9.0",
|
|
38
38
|
"@types/react-router-dom": "^5.3.3",
|
|
39
39
|
"@types/styled-components": "^5.1.26",
|
|
40
40
|
"axe-playwright": "^1.2.3",
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
"test:e2e:watch": "chokidar '**/__tests__/*.e2e.js' -c 'npm run test:e2e -- --retries=0 {path}'",
|
|
66
66
|
"test:e2e:debug": "cross-env PWDEBUG=1 playwright test"
|
|
67
67
|
},
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "13f4821716ce30a1b2f7dd3c30d51de79baadee5"
|
|
69
69
|
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("styled-components"),o=require("../themes/utils.cjs"),s=require("../Flex/Flex.cjs"),n=e=>e&&e.__esModule?e:{default:e},c=n(r),l=c.default(s.Flex)`
|
|
2
|
-
line-height: ${({theme:e})=>e.lineHeights[2]};
|
|
3
|
-
|
|
4
|
-
.cm-editor {
|
|
5
|
-
/**
|
|
6
|
-
* Hard coded since the color is the same between themes,
|
|
7
|
-
* theme.colors.neutral800 changes between themes
|
|
8
|
-
*/
|
|
9
|
-
background-color: #32324d;
|
|
10
|
-
width: 100%;
|
|
11
|
-
outline: none;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.cm-scroller {
|
|
15
|
-
border: 1px solid ${({theme:e,hasError:t})=>t?e.colors.danger600:e.colors.neutral200};
|
|
16
|
-
/* inputFocusStyle will receive hasError prop */
|
|
17
|
-
${o.inputFocusStyle()}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
.cm-editor,
|
|
21
|
-
.cm-scroller {
|
|
22
|
-
border-radius: ${({theme:e})=>e.borderRadius};
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.cm-gutters,
|
|
26
|
-
.cm-activeLineGutter {
|
|
27
|
-
/**
|
|
28
|
-
* Hard coded since the color is the same between themes,
|
|
29
|
-
* theme.colors.neutral700 changes between themes
|
|
30
|
-
*/
|
|
31
|
-
background-color: #4a4a6a;
|
|
32
|
-
}
|
|
33
|
-
`;exports.JSONInputContainer=l;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import o from "styled-components";
|
|
2
|
-
import { inputFocusStyle as t } from "../themes/utils.js";
|
|
3
|
-
import { Flex as c } from "../Flex/Flex.js";
|
|
4
|
-
const l = o(c)`
|
|
5
|
-
line-height: ${({ theme: e }) => e.lineHeights[2]};
|
|
6
|
-
|
|
7
|
-
.cm-editor {
|
|
8
|
-
/**
|
|
9
|
-
* Hard coded since the color is the same between themes,
|
|
10
|
-
* theme.colors.neutral800 changes between themes
|
|
11
|
-
*/
|
|
12
|
-
background-color: #32324d;
|
|
13
|
-
width: 100%;
|
|
14
|
-
outline: none;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
.cm-scroller {
|
|
18
|
-
border: 1px solid ${({ theme: e, hasError: r }) => r ? e.colors.danger600 : e.colors.neutral200};
|
|
19
|
-
/* inputFocusStyle will receive hasError prop */
|
|
20
|
-
${t()}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
.cm-editor,
|
|
24
|
-
.cm-scroller {
|
|
25
|
-
border-radius: ${({ theme: e }) => e.borderRadius};
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
.cm-gutters,
|
|
29
|
-
.cm-activeLineGutter {
|
|
30
|
-
/**
|
|
31
|
-
* Hard coded since the color is the same between themes,
|
|
32
|
-
* theme.colors.neutral700 changes between themes
|
|
33
|
-
*/
|
|
34
|
-
background-color: #4a4a6a;
|
|
35
|
-
}
|
|
36
|
-
`;
|
|
37
|
-
export {
|
|
38
|
-
l as JSONInputContainer
|
|
39
|
-
};
|