@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,107 +1,128 @@
|
|
|
1
1
|
var J = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
var A = Object.prototype.hasOwnProperty,
|
|
4
|
-
var
|
|
5
|
-
for (var
|
|
6
|
-
A.call(
|
|
7
|
-
if (
|
|
8
|
-
for (var
|
|
9
|
-
|
|
2
|
+
var C = Object.getOwnPropertySymbols;
|
|
3
|
+
var A = Object.prototype.hasOwnProperty, N = Object.prototype.propertyIsEnumerable;
|
|
4
|
+
var $ = (e, t, o) => t in e ? J(e, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : e[t] = o, u = (e, t) => {
|
|
5
|
+
for (var o in t || (t = {}))
|
|
6
|
+
A.call(t, o) && $(e, o, t[o]);
|
|
7
|
+
if (C)
|
|
8
|
+
for (var o of C(t))
|
|
9
|
+
N.call(t, o) && $(e, o, t[o]);
|
|
10
10
|
return e;
|
|
11
11
|
};
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
for (var
|
|
15
|
-
A.call(e,
|
|
16
|
-
if (e != null &&
|
|
17
|
-
for (var
|
|
18
|
-
|
|
19
|
-
return
|
|
12
|
+
var T = (e, t) => {
|
|
13
|
+
var o = {};
|
|
14
|
+
for (var i in e)
|
|
15
|
+
A.call(e, i) && t.indexOf(i) < 0 && (o[i] = e[i]);
|
|
16
|
+
if (e != null && C)
|
|
17
|
+
for (var i of C(e))
|
|
18
|
+
t.indexOf(i) < 0 && N.call(e, i) && (o[i] = e[i]);
|
|
19
|
+
return o;
|
|
20
20
|
};
|
|
21
|
-
import
|
|
22
|
-
import
|
|
23
|
-
import
|
|
24
|
-
import { useCallbackRef as
|
|
21
|
+
import s, { useRef as w, useEffect as x, useState as F, Children as Q, cloneElement as X } from "react";
|
|
22
|
+
import n from "prop-types";
|
|
23
|
+
import E from "styled-components";
|
|
24
|
+
import { useCallbackRef as V } from "@radix-ui/react-use-callback-ref";
|
|
25
25
|
import Y from "@strapi/icons/CarretDown";
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
26
|
+
import { Link as Z } from "../Link/Link.js";
|
|
27
|
+
import { Typography as S } from "../../Typography/Typography.js";
|
|
28
|
+
import { Box as v } from "../../Box/Box.js";
|
|
29
|
+
import { Flex as ee } from "../../Flex/Flex.js";
|
|
30
|
+
import { Button as q } from "../../Button/Button.js";
|
|
31
|
+
import { BaseLink as ne } from "../../BaseLink/BaseLink.js";
|
|
32
|
+
import { POPOVER_PLACEMENTS as te, Popover as oe } from "../../Popover/Popover.js";
|
|
33
|
+
import { getOptionStyle as B } from "./utils.js";
|
|
34
|
+
import { useId as re } from "../../helpers/useId.js";
|
|
34
35
|
import { KeyboardKeys as c } from "../../helpers/keyboardKeys.js";
|
|
35
|
-
const
|
|
36
|
+
const se = E.button`
|
|
36
37
|
border: none;
|
|
37
38
|
padding: 0;
|
|
38
39
|
background: transparent;
|
|
39
40
|
cursor: pointer;
|
|
40
|
-
${
|
|
41
|
-
`,
|
|
41
|
+
${B}
|
|
42
|
+
`, ie = E(ne)`
|
|
42
43
|
text-decoration: none;
|
|
43
|
-
${
|
|
44
|
-
`,
|
|
44
|
+
${B}
|
|
45
|
+
`, ae = E(Z)`
|
|
46
|
+
&:focus-visible {
|
|
47
|
+
/* Removes Link focus-visible after properties and reset to global outline */
|
|
48
|
+
outline: 2px solid ${({ theme: e }) => e.colors.primary600};
|
|
49
|
+
outline-offset: 2px;
|
|
50
|
+
&:after {
|
|
51
|
+
content: none;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/* Removes Link svg color */
|
|
55
|
+
svg path {
|
|
56
|
+
fill: currentColor;
|
|
57
|
+
}
|
|
58
|
+
${B}
|
|
59
|
+
`, le = E.span`
|
|
45
60
|
display: flex;
|
|
46
61
|
align-items: center;
|
|
47
62
|
svg {
|
|
48
63
|
height: 4px;
|
|
49
64
|
width: 6px;
|
|
50
65
|
}
|
|
51
|
-
`,
|
|
66
|
+
`, ce = E(q)`
|
|
52
67
|
padding: ${({ theme: e }) => `${e.spaces[1]} ${e.spaces[3]}`};
|
|
53
|
-
`, W = (
|
|
54
|
-
var
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}, [
|
|
59
|
-
const
|
|
60
|
-
tabIndex:
|
|
61
|
-
ref:
|
|
68
|
+
`, W = (L) => {
|
|
69
|
+
var g = L, { as: e, children: t, onClick: o, isFocused: i, isLink: D, isExternal: O } = g, b = T(g, ["as", "children", "onClick", "isFocused", "isLink", "isExternal"]);
|
|
70
|
+
const k = w();
|
|
71
|
+
x(() => {
|
|
72
|
+
i && k.current && k.current.focus();
|
|
73
|
+
}, [i]);
|
|
74
|
+
const p = u({
|
|
75
|
+
tabIndex: i ? 0 : -1,
|
|
76
|
+
ref: k,
|
|
62
77
|
role: "menuitem"
|
|
63
|
-
},
|
|
64
|
-
(
|
|
78
|
+
}, b), l = (m) => {
|
|
79
|
+
(m.key === c.SPACE || m.key === c.ENTER) && o();
|
|
65
80
|
};
|
|
66
|
-
return D ? /* @__PURE__ */
|
|
81
|
+
return D ? /* @__PURE__ */ s.createElement(ie, u({
|
|
67
82
|
as: e
|
|
68
|
-
},
|
|
83
|
+
}, p), /* @__PURE__ */ s.createElement(v, {
|
|
84
|
+
padding: 2
|
|
85
|
+
}, /* @__PURE__ */ s.createElement(S, null, t))) : O ? /* @__PURE__ */ s.createElement(ae, u({
|
|
86
|
+
isExternal: !0
|
|
87
|
+
}, p), /* @__PURE__ */ s.createElement(v, {
|
|
69
88
|
padding: 2
|
|
70
|
-
}, /* @__PURE__ */
|
|
71
|
-
onKeyDown:
|
|
72
|
-
onMouseDown:
|
|
89
|
+
}, /* @__PURE__ */ s.createElement(S, null, t))) : /* @__PURE__ */ s.createElement(se, u({
|
|
90
|
+
onKeyDown: l,
|
|
91
|
+
onMouseDown: o,
|
|
73
92
|
type: "button"
|
|
74
|
-
},
|
|
93
|
+
}, p), /* @__PURE__ */ s.createElement(v, {
|
|
75
94
|
padding: 2
|
|
76
|
-
}, /* @__PURE__ */
|
|
95
|
+
}, /* @__PURE__ */ s.createElement(S, null, t)));
|
|
77
96
|
};
|
|
78
97
|
W.defaultProps = {
|
|
79
98
|
as: void 0,
|
|
80
99
|
onClick() {
|
|
81
100
|
},
|
|
101
|
+
isExternal: !1,
|
|
82
102
|
isFocused: !1,
|
|
83
103
|
isLink: !1
|
|
84
104
|
};
|
|
85
105
|
W.propTypes = {
|
|
86
|
-
as:
|
|
87
|
-
children:
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
106
|
+
as: n.elementType,
|
|
107
|
+
children: n.node.isRequired,
|
|
108
|
+
isExternal: n.bool,
|
|
109
|
+
isFocused: n.bool,
|
|
110
|
+
isLink: n.bool,
|
|
111
|
+
onClick: n.func
|
|
91
112
|
};
|
|
92
|
-
const P = (
|
|
93
|
-
var
|
|
113
|
+
const P = (k) => {
|
|
114
|
+
var p = k, {
|
|
94
115
|
label: e,
|
|
95
|
-
children:
|
|
96
|
-
id:
|
|
97
|
-
as:
|
|
116
|
+
children: t,
|
|
117
|
+
id: o,
|
|
118
|
+
as: i,
|
|
98
119
|
onOpen: D = () => {
|
|
99
120
|
},
|
|
100
|
-
onClose:
|
|
121
|
+
onClose: O = () => {
|
|
101
122
|
},
|
|
102
123
|
size: b,
|
|
103
|
-
popoverPlacement:
|
|
104
|
-
} =
|
|
124
|
+
popoverPlacement: L
|
|
125
|
+
} = p, g = T(p, [
|
|
105
126
|
"label",
|
|
106
127
|
"children",
|
|
107
128
|
"id",
|
|
@@ -111,63 +132,63 @@ const P = (O) => {
|
|
|
111
132
|
"size",
|
|
112
133
|
"popoverPlacement"
|
|
113
134
|
]);
|
|
114
|
-
const l =
|
|
115
|
-
|
|
135
|
+
const l = w(), m = re("simplemenu", o), f = w(!1), [d, y] = F(!1), [I, R] = F(0), h = Q.toArray(t), _ = i || (b === "S" ? ce : q);
|
|
136
|
+
x(() => {
|
|
116
137
|
if (["string", "number"].includes(typeof e)) {
|
|
117
|
-
const
|
|
118
|
-
|
|
138
|
+
const r = h.findIndex((a) => a.props.children === e);
|
|
139
|
+
r !== -1 && R(r);
|
|
119
140
|
}
|
|
120
141
|
}, [e]);
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}, [
|
|
125
|
-
|
|
126
|
-
}, [e,
|
|
127
|
-
const z = (
|
|
128
|
-
|
|
129
|
-
}, j = (
|
|
130
|
-
(
|
|
131
|
-
}, U = (
|
|
132
|
-
|
|
133
|
-
}, G = (
|
|
134
|
-
|
|
135
|
-
}, H =
|
|
142
|
+
const M = V(D), K = V(O);
|
|
143
|
+
x(() => {
|
|
144
|
+
f != null && f.current ? d ? M() : K() : f.current = !0;
|
|
145
|
+
}, [f, d, M, K]), x(() => {
|
|
146
|
+
s.isValidElement(e) && I === -1 && l.current.focus();
|
|
147
|
+
}, [e, I]);
|
|
148
|
+
const z = (r) => {
|
|
149
|
+
d && (r.key === c.ESCAPE && (r.stopPropagation(), y(!1), l.current.focus()), r.key === c.DOWN && R((a) => a === h.length - 1 ? 0 : a + 1), r.key === c.UP && R((a) => a === 0 ? h.length - 1 : a - 1));
|
|
150
|
+
}, j = (r) => {
|
|
151
|
+
(r.key === c.ENTER || r.key === c.SPACE) && y((a) => !a);
|
|
152
|
+
}, U = (r) => {
|
|
153
|
+
r.preventDefault(), r.currentTarget.contains(r.relatedTarget) || y(!1);
|
|
154
|
+
}, G = (r) => {
|
|
155
|
+
r.preventDefault(), y((a) => !a);
|
|
156
|
+
}, H = h.map((r, a) => /* @__PURE__ */ s.createElement(ee, {
|
|
136
157
|
as: "li",
|
|
137
158
|
key: a,
|
|
138
159
|
justifyContent: "center",
|
|
139
160
|
role: "menuitem"
|
|
140
|
-
}, X(
|
|
161
|
+
}, X(r, {
|
|
141
162
|
onClick() {
|
|
142
|
-
|
|
163
|
+
r.props.onClick(), y(!1), l.current.focus();
|
|
143
164
|
},
|
|
144
|
-
isFocused:
|
|
165
|
+
isFocused: I === a
|
|
145
166
|
})));
|
|
146
|
-
return /* @__PURE__ */
|
|
167
|
+
return /* @__PURE__ */ s.createElement("div", {
|
|
147
168
|
onKeyDown: z
|
|
148
|
-
}, /* @__PURE__ */
|
|
149
|
-
label:
|
|
169
|
+
}, /* @__PURE__ */ s.createElement(_, u({
|
|
170
|
+
label: s.isValidElement(e) ? null : e,
|
|
150
171
|
"aria-haspopup": !0,
|
|
151
|
-
"aria-expanded":
|
|
152
|
-
"aria-controls":
|
|
172
|
+
"aria-expanded": d,
|
|
173
|
+
"aria-controls": m,
|
|
153
174
|
onKeyDown: j,
|
|
154
175
|
onMouseDown: G,
|
|
155
176
|
ref: l,
|
|
156
177
|
type: "button",
|
|
157
178
|
variant: "ghost",
|
|
158
|
-
endIcon: /* @__PURE__ */
|
|
179
|
+
endIcon: /* @__PURE__ */ s.createElement(le, null, /* @__PURE__ */ s.createElement(Y, {
|
|
159
180
|
"aria-hidden": !0
|
|
160
181
|
}))
|
|
161
|
-
},
|
|
182
|
+
}, g), e), d && /* @__PURE__ */ s.createElement(oe, {
|
|
162
183
|
onBlur: U,
|
|
163
|
-
placement:
|
|
184
|
+
placement: L,
|
|
164
185
|
source: l,
|
|
165
186
|
spacing: 4
|
|
166
|
-
}, /* @__PURE__ */
|
|
187
|
+
}, /* @__PURE__ */ s.createElement(v, {
|
|
167
188
|
role: "menu",
|
|
168
189
|
as: "ul",
|
|
169
190
|
padding: 1,
|
|
170
|
-
id:
|
|
191
|
+
id: m
|
|
171
192
|
}, H)));
|
|
172
193
|
};
|
|
173
194
|
P.defaultProps = {
|
|
@@ -184,14 +205,14 @@ P.defaultProps = {
|
|
|
184
205
|
size: "M"
|
|
185
206
|
};
|
|
186
207
|
P.propTypes = {
|
|
187
|
-
as:
|
|
188
|
-
children:
|
|
189
|
-
id:
|
|
190
|
-
label:
|
|
191
|
-
onClose:
|
|
192
|
-
onOpen:
|
|
193
|
-
popoverPlacement:
|
|
194
|
-
size:
|
|
208
|
+
as: n.any,
|
|
209
|
+
children: n.oneOfType([n.arrayOf(n.node), n.node]).isRequired,
|
|
210
|
+
id: n.string,
|
|
211
|
+
label: n.oneOfType([n.string, n.number, n.element]).isRequired,
|
|
212
|
+
onClose: n.func,
|
|
213
|
+
onOpen: n.func,
|
|
214
|
+
popoverPlacement: n.oneOf(te),
|
|
215
|
+
size: n.oneOf(["S", "M"])
|
|
195
216
|
};
|
|
196
217
|
export {
|
|
197
218
|
W as MenuItem,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/design-system",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"@storybook/addon-essentials": "^6.5.13",
|
|
32
32
|
"@storybook/addon-links": "^6.5.13",
|
|
33
33
|
"@storybook/react": "^6.5.13",
|
|
34
|
-
"@strapi/icons": "^1.4.
|
|
34
|
+
"@strapi/icons": "^1.4.2",
|
|
35
35
|
"@swc/core": "^1.3.11",
|
|
36
36
|
"@swc/jest": "^0.2.23",
|
|
37
37
|
"@testing-library/jest-dom": "5.16.5",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"styled-components": "^5.2.1"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
|
-
"@strapi/icons": "^1.
|
|
54
|
+
"@strapi/icons": "^1.4.2",
|
|
55
55
|
"react": "^17.0.1",
|
|
56
56
|
"react-dom": "^17.0.1",
|
|
57
57
|
"react-router-dom": "^5.2.0",
|
|
@@ -71,5 +71,5 @@
|
|
|
71
71
|
"test:e2e:watch": "chokidar '**/__tests__/*.e2e.js' -c 'npm run test:e2e -- --retries=0 {path}'",
|
|
72
72
|
"test:e2e:debug": "cross-env PWDEBUG=1 playwright test"
|
|
73
73
|
},
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "7f8ee2fc8d6e79e5931955f6224ddffee8f9ac3d"
|
|
75
75
|
}
|