@strapi/design-system 1.4.0-beta.2 → 1.4.1

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.
Files changed (36) hide show
  1. package/LICENSE +4 -17
  2. package/dist/CarouselInput/CarouselInput.cjs +1 -1
  3. package/dist/CarouselInput/CarouselInput.js +2 -2
  4. package/dist/Combobox/Combobox.cjs +1 -1
  5. package/dist/Combobox/Combobox.js +80 -80
  6. package/dist/DateTimePicker/DateTimePicker.cjs +1 -1
  7. package/dist/DateTimePicker/DateTimePicker.js +58 -56
  8. package/dist/Field/Field.cjs +1 -1
  9. package/dist/Field/Field.js +22 -20
  10. package/dist/Field/FieldInput.cjs +4 -4
  11. package/dist/Field/FieldInput.js +31 -30
  12. package/dist/Field/FieldLabel.cjs +3 -3
  13. package/dist/Field/FieldLabel.js +43 -42
  14. package/dist/Link/Link.cjs +5 -5
  15. package/dist/Link/Link.js +19 -18
  16. package/dist/NumberInput/NumberInput.cjs +1 -1
  17. package/dist/NumberInput/NumberInput.js +2 -2
  18. package/dist/Select/Select.cjs +2 -2
  19. package/dist/Select/Select.js +32 -33
  20. package/dist/SimpleMenu/SimpleMenu.cjs +23 -7
  21. package/dist/SimpleMenu/SimpleMenu.js +121 -97
  22. package/dist/TextInput/TextInput.cjs +1 -1
  23. package/dist/TextInput/TextInput.js +2 -2
  24. package/dist/Textarea/Textarea.cjs +1 -1
  25. package/dist/Textarea/Textarea.js +2 -2
  26. package/dist/Textarea/TextareaInput.cjs +4 -4
  27. package/dist/Textarea/TextareaInput.js +23 -22
  28. package/dist/TimePicker/TimePicker.cjs +2 -2
  29. package/dist/TimePicker/TimePicker.js +44 -39
  30. package/dist/ToggleCheckbox/ToggleCheckbox.cjs +6 -6
  31. package/dist/ToggleCheckbox/ToggleCheckbox.js +44 -37
  32. package/dist/ToggleInput/ToggleInput.cjs +3 -3
  33. package/dist/ToggleInput/ToggleInput.js +25 -26
  34. package/dist/v2/SimpleMenu/SimpleMenu.cjs +21 -7
  35. package/dist/v2/SimpleMenu/SimpleMenu.js +126 -105
  36. package/package.json +4 -4
@@ -1,107 +1,128 @@
1
1
  var J = Object.defineProperty;
2
- var h = Object.getOwnPropertySymbols;
3
- var A = Object.prototype.hasOwnProperty, L = Object.prototype.propertyIsEnumerable;
4
- var K = (e, r, n) => r in e ? J(e, r, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[r] = n, d = (e, r) => {
5
- for (var n in r || (r = {}))
6
- A.call(r, n) && K(e, n, r[n]);
7
- if (h)
8
- for (var n of h(r))
9
- L.call(r, n) && K(e, n, r[n]);
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 w = (e, r) => {
13
- var n = {};
14
- for (var s in e)
15
- A.call(e, s) && r.indexOf(s) < 0 && (n[s] = e[s]);
16
- if (e != null && h)
17
- for (var s of h(e))
18
- r.indexOf(s) < 0 && L.call(e, s) && (n[s] = e[s]);
19
- return n;
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 i, { useRef as x, useEffect as C, useState as N, Children as Q, cloneElement as X } from "react";
22
- import o from "prop-types";
23
- import k from "styled-components";
24
- import { useCallbackRef as $ } from "@radix-ui/react-use-callback-ref";
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 { Typography as F } from "../../Typography/Typography.js";
27
- import { Box as R } from "../../Box/Box.js";
28
- import { Flex as Z } from "../../Flex/Flex.js";
29
- import { Button as V } from "../../Button/Button.js";
30
- import { BaseLink as ee } from "../../BaseLink/BaseLink.js";
31
- import { POPOVER_PLACEMENTS as ne, Popover as te } from "../../Popover/Popover.js";
32
- import { getOptionStyle as q } from "./utils.js";
33
- import { useId as oe } from "../../helpers/useId.js";
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 re = k.button`
36
+ const se = E.button`
36
37
  border: none;
37
38
  padding: 0;
38
39
  background: transparent;
39
40
  cursor: pointer;
40
- ${q}
41
- `, se = k(ee)`
41
+ ${B}
42
+ `, ie = E(ne)`
42
43
  text-decoration: none;
43
- ${q}
44
- `, ie = k.span`
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
- `, ae = k(V)`
66
+ `, ce = E(q)`
52
67
  padding: ${({ theme: e }) => `${e.spaces[1]} ${e.spaces[3]}`};
53
- `, W = (b) => {
54
- var y = b, { as: e, children: r, onClick: n, isFocused: s, isLink: D } = y, I = w(y, ["as", "children", "onClick", "isFocused", "isLink"]);
55
- const p = x();
56
- C(() => {
57
- s && p.current && p.current.focus();
58
- }, [s]);
59
- const O = d({
60
- tabIndex: s ? 0 : -1,
61
- ref: p,
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
- }, I), E = (l) => {
64
- (l.key === c.SPACE || l.key === c.ENTER) && n();
78
+ }, b), l = (m) => {
79
+ (m.key === c.SPACE || m.key === c.ENTER) && o();
65
80
  };
66
- return D ? /* @__PURE__ */ i.createElement(se, d({
81
+ return D ? /* @__PURE__ */ s.createElement(ie, u({
67
82
  as: e
68
- }, O), /* @__PURE__ */ i.createElement(R, {
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__ */ i.createElement(F, null, r))) : /* @__PURE__ */ i.createElement(re, d({
71
- onKeyDown: E,
72
- onMouseDown: n,
89
+ }, /* @__PURE__ */ s.createElement(S, null, t))) : /* @__PURE__ */ s.createElement(se, u({
90
+ onKeyDown: l,
91
+ onMouseDown: o,
73
92
  type: "button"
74
- }, O), /* @__PURE__ */ i.createElement(R, {
93
+ }, p), /* @__PURE__ */ s.createElement(v, {
75
94
  padding: 2
76
- }, /* @__PURE__ */ i.createElement(F, null, r)));
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: o.elementType,
87
- children: o.node.isRequired,
88
- isFocused: o.bool,
89
- isLink: o.bool,
90
- onClick: o.func
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 = (O) => {
93
- var E = O, {
113
+ const P = (k) => {
114
+ var p = k, {
94
115
  label: e,
95
- children: r,
96
- id: n,
97
- as: s,
116
+ children: t,
117
+ id: o,
118
+ as: i,
98
119
  onOpen: D = () => {
99
120
  },
100
- onClose: I = () => {
121
+ onClose: O = () => {
101
122
  },
102
123
  size: b,
103
- popoverPlacement: y
104
- } = E, p = w(E, [
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 = x(), v = oe("simplemenu", n), u = x(!1), [m, f] = N(!1), [T, S] = N(0), g = Q.toArray(r), _ = s || (b === "S" ? ae : V);
115
- C(() => {
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 t = g.findIndex((a) => a.props.children === e);
118
- t !== -1 && S(t);
138
+ const r = h.findIndex((a) => a.props.children === e);
139
+ r !== -1 && R(r);
119
140
  }
120
141
  }, [e]);
121
- const B = $(D), M = $(I);
122
- C(() => {
123
- u != null && u.current ? m ? B() : M() : u.current = !0;
124
- }, [u, m, B, M]), C(() => {
125
- i.isValidElement(e) && T === -1 && l.current.focus();
126
- }, [e, T]);
127
- const z = (t) => {
128
- m && (t.key === c.ESCAPE && (t.stopPropagation(), f(!1), l.current.focus()), t.key === c.DOWN && S((a) => a === g.length - 1 ? 0 : a + 1), t.key === c.UP && S((a) => a === 0 ? g.length - 1 : a - 1));
129
- }, j = (t) => {
130
- (t.key === c.ENTER || t.key === c.SPACE) && f((a) => !a);
131
- }, U = (t) => {
132
- t.preventDefault(), t.currentTarget.contains(t.relatedTarget) || f(!1);
133
- }, G = (t) => {
134
- t.preventDefault(), f((a) => !a);
135
- }, H = g.map((t, a) => /* @__PURE__ */ i.createElement(Z, {
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(t, {
161
+ }, X(r, {
141
162
  onClick() {
142
- t.props.onClick(), f(!1), l.current.focus();
163
+ r.props.onClick(), y(!1), l.current.focus();
143
164
  },
144
- isFocused: T === a
165
+ isFocused: I === a
145
166
  })));
146
- return /* @__PURE__ */ i.createElement("div", {
167
+ return /* @__PURE__ */ s.createElement("div", {
147
168
  onKeyDown: z
148
- }, /* @__PURE__ */ i.createElement(_, d({
149
- label: i.isValidElement(e) ? null : e,
169
+ }, /* @__PURE__ */ s.createElement(_, u({
170
+ label: s.isValidElement(e) ? null : e,
150
171
  "aria-haspopup": !0,
151
- "aria-expanded": m,
152
- "aria-controls": v,
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__ */ i.createElement(ie, null, /* @__PURE__ */ i.createElement(Y, {
179
+ endIcon: /* @__PURE__ */ s.createElement(le, null, /* @__PURE__ */ s.createElement(Y, {
159
180
  "aria-hidden": !0
160
181
  }))
161
- }, p), e), m && /* @__PURE__ */ i.createElement(te, {
182
+ }, g), e), d && /* @__PURE__ */ s.createElement(oe, {
162
183
  onBlur: U,
163
- placement: y,
184
+ placement: L,
164
185
  source: l,
165
186
  spacing: 4
166
- }, /* @__PURE__ */ i.createElement(R, {
187
+ }, /* @__PURE__ */ s.createElement(v, {
167
188
  role: "menu",
168
189
  as: "ul",
169
190
  padding: 1,
170
- id: v
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: o.any,
188
- children: o.oneOfType([o.arrayOf(o.node), o.node]).isRequired,
189
- id: o.string,
190
- label: o.oneOfType([o.string, o.number, o.element]).isRequired,
191
- onClose: o.func,
192
- onOpen: o.func,
193
- popoverPlacement: o.oneOf(ne),
194
- size: o.oneOf(["S", "M"])
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.0-beta.2",
3
+ "version": "1.4.1",
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.0-beta.2",
34
+ "@strapi/icons": "^1.4.1",
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.3.1",
54
+ "@strapi/icons": "^1.4.1",
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": "55fb4e9e0ce47e86387205a922e7cf936df94fc8"
74
+ "gitHead": "50393ea4408afcbc45386001bb5d30559b6f02da"
75
75
  }