@strapi/design-system 1.6.5 → 1.7.0-alpha.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.
Files changed (113) hide show
  1. package/README.md +55 -0
  2. package/dist/BaseButton/BaseButton.cjs +4 -4
  3. package/dist/BaseButton/BaseButton.js +18 -17
  4. package/dist/BaseLink/BaseLink.cjs +1 -3
  5. package/dist/BaseLink/BaseLink.js +14 -14
  6. package/dist/Combobox/Combobox.cjs +104 -1
  7. package/dist/Combobox/Combobox.js +348 -278
  8. package/dist/Combobox/ComboboxList.cjs +1 -1
  9. package/dist/Combobox/ComboboxList.js +7 -6
  10. package/dist/Combobox/ComboboxOption.cjs +1 -1
  11. package/dist/Combobox/ComboboxOption.js +3 -29
  12. package/dist/DatePicker/DatePicker.cjs +12 -1
  13. package/dist/DatePicker/DatePicker.js +79 -100
  14. package/dist/DatePicker/DatePickerCalendar.cjs +1 -1
  15. package/dist/DatePicker/DatePickerCalendar.js +124 -57
  16. package/dist/DatePicker/DatePickerTd.cjs +4 -4
  17. package/dist/DatePicker/DatePickerTd.js +42 -24
  18. package/dist/DatePicker/DatePickerTh.cjs +3 -3
  19. package/dist/DatePicker/DatePickerTh.js +29 -12
  20. package/dist/DatePicker/components.cjs +8 -6
  21. package/dist/DatePicker/components.js +15 -13
  22. package/dist/DatePicker/utils/getDayOfWeek.js +8 -8
  23. package/dist/DatePicker/utils/getMonths.cjs +1 -1
  24. package/dist/DatePicker/utils/getMonths.js +3 -3
  25. package/dist/DatePicker/utils/getYears.cjs +1 -1
  26. package/dist/DatePicker/utils/getYears.js +1 -1
  27. package/dist/DateTimePicker/DateTimePicker.cjs +1 -1
  28. package/dist/DateTimePicker/DateTimePicker.js +97 -104
  29. package/dist/DateTimePicker/parseDate.cjs +1 -1
  30. package/dist/DateTimePicker/parseDate.js +2 -1
  31. package/dist/Field/FieldHint.cjs +1 -1
  32. package/dist/Field/FieldHint.js +3 -3
  33. package/dist/Field/FieldLabel.cjs +5 -2
  34. package/dist/Field/FieldLabel.js +27 -27
  35. package/dist/IconButton/IconButton.cjs +4 -4
  36. package/dist/IconButton/IconButton.js +32 -30
  37. package/dist/NumberInput/NumberInput.cjs +2 -2
  38. package/dist/NumberInput/NumberInput.js +31 -31
  39. package/dist/RawTable/RawCell.cjs +1 -1
  40. package/dist/RawTable/RawCell.js +4 -1
  41. package/dist/Select/MultiSelect.cjs +30 -0
  42. package/dist/Select/MultiSelect.js +239 -0
  43. package/dist/Select/MultiSelectNested.cjs +3 -1
  44. package/dist/Select/MultiSelectNested.js +25 -12
  45. package/dist/Select/OptGroup.cjs +1 -1
  46. package/dist/Select/OptGroup.js +3 -22
  47. package/dist/Select/Option.cjs +1 -45
  48. package/dist/Select/Option.js +12 -100
  49. package/dist/Select/Select.cjs +1 -3
  50. package/dist/Select/Select.js +9 -205
  51. package/dist/Select/SelectList.cjs +1 -1
  52. package/dist/Select/SelectList.js +98 -80
  53. package/dist/Select/SelectParts.cjs +79 -0
  54. package/dist/Select/SelectParts.js +221 -0
  55. package/dist/Select/SingleSelect.cjs +1 -0
  56. package/dist/Select/SingleSelect.js +129 -0
  57. package/dist/Select/index.cjs +1 -1
  58. package/dist/Select/index.js +15 -10
  59. package/dist/TextButton/TextButton.cjs +6 -12
  60. package/dist/TextButton/TextButton.js +32 -46
  61. package/dist/TextInput/TextInput.cjs +1 -1
  62. package/dist/TextInput/TextInput.js +47 -46
  63. package/dist/TimePicker/TimePicker.cjs +5 -7
  64. package/dist/TimePicker/TimePicker.js +53 -103
  65. package/dist/helpers/objects.cjs +1 -1
  66. package/dist/helpers/objects.js +6 -22
  67. package/dist/hooks/useComposeRefs.cjs +1 -0
  68. package/dist/hooks/useComposeRefs.js +14 -0
  69. package/dist/hooks/useIntersection.cjs +1 -1
  70. package/dist/hooks/useIntersection.js +7 -7
  71. package/dist/index.cjs +1 -1
  72. package/dist/index.js +143 -138
  73. package/dist/themes/extendTheme.cjs +4 -4
  74. package/dist/themes/extendTheme.js +21 -13
  75. package/dist/themes/utils.cjs +6 -6
  76. package/dist/themes/utils.js +7 -6
  77. package/dist/v2/Link/Link.cjs +13 -11
  78. package/dist/v2/Link/Link.js +52 -37
  79. package/dist/v2/SimpleMenu/Menu.cjs +65 -0
  80. package/dist/v2/SimpleMenu/Menu.js +229 -0
  81. package/dist/v2/SimpleMenu/SimpleMenu.cjs +1 -33
  82. package/dist/v2/SimpleMenu/SimpleMenu.js +37 -176
  83. package/dist/v2/SimpleMenu/index.cjs +1 -1
  84. package/dist/v2/SimpleMenu/index.js +5 -3
  85. package/dist/v2/index.cjs +1 -1
  86. package/dist/v2/index.js +53 -51
  87. package/package.json +7 -19
  88. package/dist/Combobox/components.cjs +0 -53
  89. package/dist/Combobox/components.js +0 -64
  90. package/dist/Combobox/utils.cjs +0 -1
  91. package/dist/Combobox/utils.js +0 -78
  92. package/dist/DateTimePicker/DateTimePickerProps.cjs +0 -1
  93. package/dist/DateTimePicker/DateTimePickerProps.js +0 -40
  94. package/dist/DateTimePicker/__tests__/parseDate.test.cjs +0 -1
  95. package/dist/DateTimePicker/__tests__/parseDate.test.js +0 -8
  96. package/dist/Select/SelectButton.cjs +0 -19
  97. package/dist/Select/SelectButton.js +0 -67
  98. package/dist/Select/SelectTags.cjs +0 -6
  99. package/dist/Select/SelectTags.js +0 -38
  100. package/dist/Select/components.cjs +0 -39
  101. package/dist/Select/components.js +0 -48
  102. package/dist/Select/constants.cjs +0 -1
  103. package/dist/Select/constants.js +0 -8
  104. package/dist/Select/hooks/useButtonRef.cjs +0 -1
  105. package/dist/Select/hooks/useButtonRef.js +0 -13
  106. package/dist/Select/hooks/useListRef.cjs +0 -1
  107. package/dist/Select/hooks/useListRef.js +0 -18
  108. package/dist/Select/utils.cjs +0 -1
  109. package/dist/Select/utils.js +0 -17
  110. package/dist/helpers/arrays.cjs +0 -1
  111. package/dist/helpers/arrays.js +0 -6
  112. package/dist/v2/SimpleMenu/utils.cjs +0 -12
  113. package/dist/v2/SimpleMenu/utils.js +0 -15
@@ -1,50 +1,65 @@
1
- import r from "react";
2
- import { ExternalLink as c } from "@strapi/icons";
3
- import t from "prop-types";
4
- import s from "styled-components";
5
- import { BaseLink as f } from "../../BaseLink/BaseLink.js";
6
- import { Box as y } from "../../Box/Box.js";
7
- import { buttonFocusStyle as u } from "../../themes/utils.js";
8
- import { Typography as v } from "../../Typography/Typography.js";
9
- const g = s(f)`
1
+ import { jsxs as s, jsx as n } from "react/jsx-runtime";
2
+ import m from "react";
3
+ import { ExternalLink as f } from "@strapi/icons";
4
+ import c from "styled-components";
5
+ import { BaseLink as y } from "../../BaseLink/BaseLink.js";
6
+ import { buttonFocusStyle as d } from "../../themes/utils.js";
7
+ import { Typography as u } from "../../Typography/Typography.js";
8
+ const x = c(y)`
10
9
  display: inline-flex;
11
10
  align-items: center;
12
11
  text-decoration: none;
13
- pointer-events: ${({ disabled: e }) => e ? "none" : void 0};
14
-
15
- svg path {
16
- fill: ${({ disabled: e, theme: o }) => e ? o.colors.neutral600 : o.colors.primary600};
17
- }
12
+ gap: ${({
13
+ theme: r
14
+ }) => r.spaces[2]};
15
+ pointer-events: ${({
16
+ disabled: r
17
+ }) => r ? "none" : void 0};
18
18
 
19
19
  svg {
20
20
  font-size: ${10 / 16}rem;
21
+
22
+ path {
23
+ fill: ${({
24
+ disabled: r,
25
+ theme: o
26
+ }) => r ? o.colors.neutral600 : o.colors.primary600};
27
+ }
28
+ }
29
+
30
+ &:hover {
31
+ color: ${({
32
+ theme: r
33
+ }) => r.colors.primary500};
21
34
  }
22
35
 
23
- &:hover,
24
36
  &:active {
25
- color: ${({ theme: e }) => e.colors.primary800};
37
+ color: ${({
38
+ theme: r
39
+ }) => r.colors.primary700};
26
40
  }
27
41
 
28
- ${u};
29
- `, a = s(y)`
30
- display: flex;
31
- `, i = r.forwardRef(({ children: e, href: o, disabled: l, startIcon: p, endIcon: n, ...d }, m) => /* @__PURE__ */ r.createElement(g, { ref: m, href: o, disabled: l, ...d }, p && /* @__PURE__ */ r.createElement(a, { as: "span", "aria-hidden": !0, paddingRight: 2 }, p), /* @__PURE__ */ r.createElement(v, { textColor: l ? "neutral600" : "primary600" }, e), n && /* @__PURE__ */ r.createElement(a, { as: "span", "aria-hidden": !0, paddingLeft: 2 }, n), o && !n && /* @__PURE__ */ r.createElement(a, { as: "span", "aria-hidden": !0, paddingLeft: 2 }, /* @__PURE__ */ r.createElement(c, null))));
32
- i.displayName = "Link";
33
- i.defaultProps = {
34
- as: void 0,
35
- href: void 0,
36
- disabled: !1,
37
- startIcon: void 0,
38
- endIcon: void 0
39
- };
40
- i.propTypes = {
41
- as: t.elementType,
42
- children: t.node.isRequired,
43
- disabled: t.bool,
44
- endIcon: t.element,
45
- href: t.string,
46
- startIcon: t.element
47
- };
42
+ ${d};
43
+ `, $ = m.forwardRef(({
44
+ children: r,
45
+ href: o,
46
+ disabled: e = !1,
47
+ startIcon: a,
48
+ endIcon: t,
49
+ isExternal: i = !0,
50
+ ...l
51
+ }, p) => s(x, {
52
+ ref: p,
53
+ href: o,
54
+ disabled: e,
55
+ isExternal: i,
56
+ ...l,
57
+ children: [a, n(u, {
58
+ textColor: e ? "neutral600" : "primary600",
59
+ children: r
60
+ }), t, o && !t && i && n(f, {})]
61
+ }));
62
+ $.displayName = "Link";
48
63
  export {
49
- i as Link
64
+ $ as Link
50
65
  };
@@ -0,0 +1,65 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("react/jsx-runtime"),a=require("react"),y=require("@radix-ui/react-dropdown-menu"),c=require("@strapi/icons"),d=require("styled-components"),j=require("../../Box/Box.cjs"),m=require("../../Button/Button.cjs"),u=require("../../Flex/Flex.cjs"),S=require("../../helpers/theme.cjs"),i=require("../../Typography/Typography.cjs"),w=require("../Link/Link.cjs"),T=e=>e&&typeof e=="object"&&"default"in e?e:{default:e};function C(e){if(e&&e.__esModule)return e;const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const o in e)if(o!=="default"){const l=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(r,o,l.get?l:{enumerable:!0,get:()=>e[o]})}}return r.default=e,Object.freeze(r)}const n=C(y),s=T(d),R=n.Root,k=a.forwardRef(({size:e,...r},o)=>t.jsx(n.Trigger,{asChild:!0,children:t.jsx(m.Button,{ref:o,type:"button",variant:"ghost",endIcon:t.jsx(c.CarretDown,{width:`${6/16}rem`,height:`${4/16}rem`,"aria-hidden":!0}),paddingTop:e==="S"?1:2,paddingBottom:e==="S"?1:2,paddingLeft:e==="S"?3:4,paddingRight:e==="S"?3:4,...r})})),v=a.forwardRef(({children:e,intersectionId:r,popoverPlacement:o="bottom-start",...l},b)=>{const[f,x]=o.split("-");return t.jsx(n.Portal,{children:t.jsx(n.Content,{align:x,side:f,loop:!0,asChild:!0,children:t.jsxs(h,{ref:b,direction:"column",borderStyle:"solid",borderWidth:"1px",borderColor:"neutral150",hasRadius:!0,background:"neutral0",shadow:"filterShadow",maxHeight:"15rem",padding:1,alignItems:"flex-start",position:"relative",overflow:"auto",...l,children:[e,t.jsx(j.Box,{id:r,width:"100%",height:"1px"})]})})})}),h=s.default(u.Flex)`
2
+ scrollbar-width: none;
3
+ -ms-overflow-style: none;
4
+ -webkit-overflow-scrolling: touch;
5
+
6
+ &::-webkit-scrollbar {
7
+ display: none;
8
+ }
9
+ `,$=({onSelect:e,disabled:r=!1,...o})=>t.jsx(n.Item,{asChild:!0,onSelect:e,disabled:r,children:o.isLink||o.isExternal?t.jsx(L,{color:"neutral800",...o,isExternal:o.isExternal??!1,children:t.jsx(i.Typography,{children:o.children})}):t.jsx(p,{cursor:"pointer",color:"neutral800",background:"transparent",borderStyle:"none",...o,children:t.jsx(i.Typography,{children:o.children})})}),g=({theme:e})=>d.css`
10
+ text-align: left;
11
+ width: 100%;
12
+ border-radius: ${e.borderRadius};
13
+ padding: ${e.spaces[2]} ${e.spaces[4]};
14
+
15
+ ${i.Typography} {
16
+ color: inherit;
17
+ }
18
+
19
+ &[aria-disabled] {
20
+ cursor: not-allowed;
21
+
22
+ ${i.Typography} {
23
+ color: ${e.colors.neutral500};
24
+ }
25
+ }
26
+
27
+ &[data-highlighted] {
28
+ background-color: ${e.colors.primary100};
29
+ }
30
+
31
+ &:focus-visible {
32
+ outline: none;
33
+
34
+ &:after {
35
+ content: none;
36
+ }
37
+ }
38
+ `,p=s.default(u.Flex)`
39
+ ${g}
40
+ `,L=s.default(w.Link)`
41
+ /* We include this here again because typically when people use OptionLink they provide an as prop which cancels the Box props */
42
+ color: ${({theme:e,color:r})=>S.extractStyleFromTheme(e.colors,r,void 0)};
43
+ text-decoration: none;
44
+
45
+ &:hover {
46
+ color: unset;
47
+ }
48
+
49
+ svg > path,
50
+ &:focus-visible svg > path {
51
+ fill: currentColor;
52
+ }
53
+
54
+ ${g}
55
+ `,M=a.forwardRef((e,r)=>t.jsx(n.Label,{asChild:!0,children:t.jsx(q,{ref:r,variant:"sigma",textColor:"neutral600",...e})})),q=s.default(i.Typography)`
56
+ padding: ${({theme:e})=>e.spaces[2]} ${({theme:e})=>e.spaces[4]};
57
+ `,B=n.Sub,O=a.forwardRef(({disabled:e=!1,...r},o)=>t.jsx(n.SubTrigger,{asChild:!0,disabled:e,children:t.jsxs(_,{ref:o,color:"neutral800",as:"button",type:"button",background:"transparent",borderStyle:"none",gap:5,...r,children:[t.jsx(i.Typography,{children:r.children}),t.jsx(I,{height:12,width:12})]})})),_=s.default(p)`
58
+ &[data-state='open'] {
59
+ background-color: ${({theme:e})=>e.colors.primary100};
60
+ }
61
+ `,I=s.default(c.ChevronRight)`
62
+ path {
63
+ fill: ${({theme:e})=>e.colors.neutral500};
64
+ }
65
+ `,F=a.forwardRef((e,r)=>t.jsx(n.Portal,{children:t.jsx(n.SubContent,{sideOffset:8,asChild:!0,children:t.jsx(h,{ref:r,direction:"column",borderStyle:"solid",borderWidth:"1px",borderColor:"neutral150",hasRadius:!0,background:"neutral0",shadow:"filterShadow",maxHeight:"15rem",padding:1,alignItems:"flex-start",...e})})})),D=R,P=k,E=v,W=$,H=M,A=B,N=O,V=F;exports.Content=E;exports.Item=W;exports.Label=H;exports.Root=D;exports.SubContent=V;exports.SubRoot=A;exports.SubTrigger=N;exports.Trigger=P;
@@ -0,0 +1,229 @@
1
+ import { jsx as e, jsxs as d } from "react/jsx-runtime";
2
+ import { forwardRef as a } from "react";
3
+ import * as n from "@radix-ui/react-dropdown-menu";
4
+ import { CarretDown as f, ChevronRight as S } from "@strapi/icons";
5
+ import l, { css as w } from "styled-components";
6
+ import { Box as x } from "../../Box/Box.js";
7
+ import { Button as y } from "../../Button/Button.js";
8
+ import { Flex as s } from "../../Flex/Flex.js";
9
+ import { extractStyleFromTheme as C } from "../../helpers/theme.js";
10
+ import { Typography as i } from "../../Typography/Typography.js";
11
+ import { Link as $ } from "../Link/Link.js";
12
+ const v = n.Root, k = a(({
13
+ size: r,
14
+ ...o
15
+ }, t) => e(n.Trigger, {
16
+ asChild: !0,
17
+ children: e(y, {
18
+ ref: t,
19
+ type: "button",
20
+ variant: "ghost",
21
+ endIcon: e(f, {
22
+ width: `${6 / 16}rem`,
23
+ height: `${4 / 16}rem`,
24
+ "aria-hidden": !0
25
+ }),
26
+ paddingTop: r === "S" ? 1 : 2,
27
+ paddingBottom: r === "S" ? 1 : 2,
28
+ paddingLeft: r === "S" ? 3 : 4,
29
+ paddingRight: r === "S" ? 3 : 4,
30
+ ...o
31
+ })
32
+ })), R = a(({
33
+ children: r,
34
+ intersectionId: o,
35
+ popoverPlacement: t = "bottom-start",
36
+ ...g
37
+ }, p) => {
38
+ const [b, m] = t.split("-");
39
+ return e(n.Portal, {
40
+ children: e(n.Content, {
41
+ align: m,
42
+ side: b,
43
+ loop: !0,
44
+ asChild: !0,
45
+ children: d(c, {
46
+ ref: p,
47
+ direction: "column",
48
+ borderStyle: "solid",
49
+ borderWidth: "1px",
50
+ borderColor: "neutral150",
51
+ hasRadius: !0,
52
+ background: "neutral0",
53
+ shadow: "filterShadow",
54
+ maxHeight: "15rem",
55
+ padding: 1,
56
+ alignItems: "flex-start",
57
+ position: "relative",
58
+ overflow: "auto",
59
+ ...g,
60
+ children: [r, e(x, {
61
+ id: o,
62
+ width: "100%",
63
+ height: "1px"
64
+ })]
65
+ })
66
+ })
67
+ });
68
+ }), c = l(s)`
69
+ scrollbar-width: none;
70
+ -ms-overflow-style: none;
71
+ -webkit-overflow-scrolling: touch;
72
+
73
+ &::-webkit-scrollbar {
74
+ display: none;
75
+ }
76
+ `, T = ({
77
+ onSelect: r,
78
+ disabled: o = !1,
79
+ ...t
80
+ }) => e(n.Item, {
81
+ asChild: !0,
82
+ onSelect: r,
83
+ disabled: o,
84
+ children: t.isLink || t.isExternal ? e(L, {
85
+ color: "neutral800",
86
+ ...t,
87
+ isExternal: t.isExternal ?? !1,
88
+ children: e(i, {
89
+ children: t.children
90
+ })
91
+ }) : e(h, {
92
+ cursor: "pointer",
93
+ color: "neutral800",
94
+ background: "transparent",
95
+ borderStyle: "none",
96
+ ...t,
97
+ children: e(i, {
98
+ children: t.children
99
+ })
100
+ })
101
+ }), u = ({
102
+ theme: r
103
+ }) => w`
104
+ text-align: left;
105
+ width: 100%;
106
+ border-radius: ${r.borderRadius};
107
+ padding: ${r.spaces[2]} ${r.spaces[4]};
108
+
109
+ ${i} {
110
+ color: inherit;
111
+ }
112
+
113
+ &[aria-disabled] {
114
+ cursor: not-allowed;
115
+
116
+ ${i} {
117
+ color: ${r.colors.neutral500};
118
+ }
119
+ }
120
+
121
+ &[data-highlighted] {
122
+ background-color: ${r.colors.primary100};
123
+ }
124
+
125
+ &:focus-visible {
126
+ outline: none;
127
+
128
+ &:after {
129
+ content: none;
130
+ }
131
+ }
132
+ `, h = l(s)`
133
+ ${u}
134
+ `, L = l($)`
135
+ /* We include this here again because typically when people use OptionLink they provide an as prop which cancels the Box props */
136
+ color: ${({
137
+ theme: r,
138
+ color: o
139
+ }) => C(r.colors, o, void 0)};
140
+ text-decoration: none;
141
+
142
+ &:hover {
143
+ color: unset;
144
+ }
145
+
146
+ svg > path,
147
+ &:focus-visible svg > path {
148
+ fill: currentColor;
149
+ }
150
+
151
+ ${u}
152
+ `, M = a((r, o) => e(n.Label, {
153
+ asChild: !0,
154
+ children: e(I, {
155
+ ref: o,
156
+ variant: "sigma",
157
+ textColor: "neutral600",
158
+ ...r
159
+ })
160
+ })), I = l(i)`
161
+ padding: ${({
162
+ theme: r
163
+ }) => r.spaces[2]} ${({
164
+ theme: r
165
+ }) => r.spaces[4]};
166
+ `, B = n.Sub, O = a(({
167
+ disabled: r = !1,
168
+ ...o
169
+ }, t) => e(n.SubTrigger, {
170
+ asChild: !0,
171
+ disabled: r,
172
+ children: d(E, {
173
+ ref: t,
174
+ color: "neutral800",
175
+ as: "button",
176
+ type: "button",
177
+ background: "transparent",
178
+ borderStyle: "none",
179
+ gap: 5,
180
+ ...o,
181
+ children: [e(i, {
182
+ children: o.children
183
+ }), e(W, {
184
+ height: 12,
185
+ width: 12
186
+ })]
187
+ })
188
+ })), E = l(h)`
189
+ &[data-state='open'] {
190
+ background-color: ${({
191
+ theme: r
192
+ }) => r.colors.primary100};
193
+ }
194
+ `, W = l(S)`
195
+ path {
196
+ fill: ${({
197
+ theme: r
198
+ }) => r.colors.neutral500};
199
+ }
200
+ `, j = a((r, o) => e(n.Portal, {
201
+ children: e(n.SubContent, {
202
+ sideOffset: 8,
203
+ asChild: !0,
204
+ children: e(c, {
205
+ ref: o,
206
+ direction: "column",
207
+ borderStyle: "solid",
208
+ borderWidth: "1px",
209
+ borderColor: "neutral150",
210
+ hasRadius: !0,
211
+ background: "neutral0",
212
+ shadow: "filterShadow",
213
+ maxHeight: "15rem",
214
+ padding: 1,
215
+ alignItems: "flex-start",
216
+ ...r
217
+ })
218
+ })
219
+ })), N = v, Q = k, U = R, X = T, Y = M, Z = B, _ = O, z = j;
220
+ export {
221
+ U as Content,
222
+ X as Item,
223
+ Y as Label,
224
+ N as Root,
225
+ z as SubContent,
226
+ Z as SubRoot,
227
+ _ as SubTrigger,
228
+ Q as Trigger
229
+ };
@@ -1,33 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("react"),D=require("@radix-ui/react-use-callback-ref"),z=require("@strapi/icons"),U=require("prop-types"),H=require("styled-components"),T=require("./utils.cjs"),G=require("../../BaseLink/BaseLink.cjs"),k=require("../../Box/Box.cjs"),M=require("../../Button/Button.cjs"),J=require("../../Flex/Flex.cjs"),u=require("../../helpers/keyboardKeys.cjs"),Q=require("../../hooks/useId.cjs"),j=require("../../Popover/Popover.cjs"),C=require("../../Typography/Typography.cjs"),X=require("../Link/Link.cjs"),q=e=>e&&typeof e=="object"&&"default"in e?e:{default:e},o=q(a),t=q(U),y=q(H),Y=y.default.button`
2
- border: none;
3
- padding: 0;
4
- background: transparent;
5
- cursor: pointer;
6
- ${T.getOptionStyle}
7
- `,Z=y.default(G.BaseLink)`
8
- text-decoration: none;
9
- ${T.getOptionStyle}
10
- `,ee=y.default(X.Link)`
11
- &:focus-visible {
12
- /* Removes Link focus-visible after properties and reset to global outline */
13
- outline: 2px solid ${({theme:e})=>e.colors.primary600};
14
- outline-offset: 2px;
15
- &:after {
16
- content: none;
17
- }
18
- }
19
- /* Removes Link svg color */
20
- svg path {
21
- fill: currentColor;
22
- }
23
- ${T.getOptionStyle}
24
- `,te=y.default.span`
25
- display: flex;
26
- align-items: center;
27
- svg {
28
- height: 4px;
29
- width: 6px;
30
- }
31
- `,ne=y.default(M.Button)`
32
- padding: ${({theme:e})=>`${e.spaces[1]} ${e.spaces[3]}`};
33
- `,I=({as:e,children:i,onClick:E,isFocused:c,isLink:h,isExternal:b,...x})=>{const d=a.useRef();a.useEffect(()=>{c&&d.current&&d.current.focus()},[c]);const l={tabIndex:c?0:-1,ref:d,role:"menuitem",...x},v=r=>{(r.key===u.KeyboardKeys.SPACE||r.key===u.KeyboardKeys.ENTER)&&E()};return h?o.default.createElement(Z,{as:e,...l},o.default.createElement(k.Box,{padding:2},o.default.createElement(C.Typography,null,i))):b?o.default.createElement(ee,{isExternal:!0,...l},o.default.createElement(k.Box,{padding:2},o.default.createElement(C.Typography,null,i))):o.default.createElement(Y,{onKeyDown:v,onMouseDown:E,type:"button",...l},o.default.createElement(k.Box,{padding:2},o.default.createElement(C.Typography,null,i)))};I.defaultProps={as:void 0,onClick(){},isExternal:!1,isFocused:!1,isLink:!1};I.propTypes={as:t.default.elementType,children:t.default.node.isRequired,isExternal:t.default.bool,isFocused:t.default.bool,isLink:t.default.bool,onClick:t.default.func};const m=({label:e,children:i,id:E,as:c,onOpen:h=()=>{},onClose:b=()=>{},size:x,popoverPlacement:d,onReachEnd:l,...v})=>{const r=a.useRef(),B=Q.useId(E),K=a.useRef(!1),[f,p]=a.useState(!1),[P,R]=a.useState(0),g=a.Children.toArray(i),w=x==="S"?ne:M.Button,_=c||w,O=!!l&&typeof l=="function";a.useEffect(()=>{if(["string","number"].includes(typeof e)){const n=g.findIndex(s=>s.props.children===e);n!==-1&&R(n)}},[e]);const S=D.useCallbackRef(h),L=D.useCallbackRef(b);a.useEffect(()=>{K?.current?f?S():L():K.current=!0},[K,f,S,L]),a.useEffect(()=>{o.default.isValidElement(e)&&P===-1&&r.current.focus()},[e,P]);const $=n=>{f&&(n.key===u.KeyboardKeys.ESCAPE&&(n.stopPropagation(),p(!1),r.current.focus()),n.key===u.KeyboardKeys.DOWN&&R(s=>s===g.length-1?0:s+1),n.key===u.KeyboardKeys.UP&&R(s=>s===0?g.length-1:s-1))},F=n=>{(n.key===u.KeyboardKeys.ENTER||n.key===u.KeyboardKeys.SPACE)&&p(s=>!s)},A=n=>{n.preventDefault(),n.currentTarget.contains(n.relatedTarget)||p(!1)},N=n=>{n.preventDefault(),p(s=>!s)},V=()=>{O&&l()},W=g.map((n,s)=>o.default.createElement(J.Flex,{as:"li",key:s,justifyContent:"center",role:"menuitem"},a.cloneElement(n,{onClick(){n.props.onClick(),p(!1),r.current.focus()},isFocused:P===s})));return o.default.createElement("div",{onKeyDown:$},o.default.createElement(_,{label:o.default.isValidElement(e)?null:e,"aria-haspopup":!0,"aria-expanded":f,"aria-controls":B,onKeyDown:F,onMouseDown:N,ref:r,type:"button",variant:"ghost",endIcon:o.default.createElement(te,null,o.default.createElement(z.CarretDown,{"aria-hidden":!0})),...v},e),f&&o.default.createElement(j.Popover,{onBlur:A,placement:d,source:r,onReachEnd:V,intersectionId:O?`popover-${B}`:void 0,spacing:4},o.default.createElement(k.Box,{role:"menu",as:"ul",padding:1,id:B},W)))};m.defaultProps={as:void 0};m.displayName="SimpleMenu";m.defaultProps={id:void 0,onClose(){},onOpen(){},onReachEnd:void 0,popoverPlacement:"bottom-start",size:"M"};m.propTypes={as:t.default.any,children:t.default.oneOfType([t.default.arrayOf(t.default.node),t.default.node]).isRequired,id:t.default.string,label:t.default.oneOfType([t.default.string,t.default.number,t.default.element]).isRequired,onClose:t.default.func,onOpen:t.default.func,onReachEnd:t.default.func,popoverPlacement:t.default.oneOf(j.POPOVER_PLACEMENTS),size:t.default.oneOf(["S","M"])};exports.MenuItem=I;exports.SimpleMenu=m;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("react/jsx-runtime"),i=require("react"),n=require("./Menu.cjs"),M=require("../../hooks/useId.cjs"),g=require("../../hooks/useIntersection.cjs"),p=({children:l,id:a,onOpen:s,onClose:c,popoverPlacement:d,onReachEnd:o,...r})=>{const I=i.useRef(null),[f,h]=i.useState(!1),j=e=>{o&&o(e)},m=e=>{e&&typeof s=="function"?s():!e&&typeof c=="function"&&c(),h(e)},u=`intersection-${M.useId(a)}`;return g.useIntersection(I,j,{selectorToWatch:`#${u}`,skipWhen:!f}),t.jsxs(n.Root,{onOpenChange:m,children:[t.jsx(n.Trigger,{...r,children:r.label}),t.jsx(n.Content,{intersectionId:u,popoverPlacement:d,children:l})]})},q=n.Item;exports.Menu=n;exports.MenuItem=q;exports.SimpleMenu=p;
@@ -1,179 +1,40 @@
1
- import t, { useRef as b, useEffect as E, useState as B, Children as z, cloneElement as j } from "react";
2
- import { useCallbackRef as L } from "@radix-ui/react-use-callback-ref";
3
- import { CarretDown as H } from "@strapi/icons";
4
- import e from "prop-types";
5
- import m from "styled-components";
6
- import { getOptionStyle as T } from "./utils.js";
7
- import { BaseLink as U } from "../../BaseLink/BaseLink.js";
8
- import { Box as g } from "../../Box/Box.js";
9
- import { Button as K } from "../../Button/Button.js";
10
- import { Flex as G } from "../../Flex/Flex.js";
11
- import { KeyboardKeys as a } from "../../helpers/keyboardKeys.js";
12
- import { useId as J } from "../../hooks/useId.js";
13
- import { POPOVER_PLACEMENTS as Q, Popover as X } from "../../Popover/Popover.js";
14
- import { Typography as O } from "../../Typography/Typography.js";
15
- import { Link as Y } from "../Link/Link.js";
16
- const Z = m.button`
17
- border: none;
18
- padding: 0;
19
- background: transparent;
20
- cursor: pointer;
21
- ${T}
22
- `, ee = m(U)`
23
- text-decoration: none;
24
- ${T}
25
- `, ne = m(Y)`
26
- &:focus-visible {
27
- /* Removes Link focus-visible after properties and reset to global outline */
28
- outline: 2px solid ${({ theme: o }) => o.colors.primary600};
29
- outline-offset: 2px;
30
- &:after {
31
- content: none;
32
- }
33
- }
34
- /* Removes Link svg color */
35
- svg path {
36
- fill: currentColor;
37
- }
38
- ${T}
39
- `, te = m.span`
40
- display: flex;
41
- align-items: center;
42
- svg {
43
- height: 4px;
44
- width: 6px;
45
- }
46
- `, oe = m(K)`
47
- padding: ${({ theme: o }) => `${o.spaces[1]} ${o.spaces[3]}`};
48
- `, $ = ({ as: o, children: l, onClick: d, isFocused: c, isLink: k, isExternal: v, ...C }) => {
49
- const p = b();
50
- E(() => {
51
- c && p.current && p.current.focus();
52
- }, [c]);
53
- const i = {
54
- tabIndex: c ? 0 : -1,
55
- ref: p,
56
- role: "menuitem",
57
- ...C
58
- }, x = (s) => {
59
- (s.key === a.SPACE || s.key === a.ENTER) && d();
60
- };
61
- return k ? /* @__PURE__ */ t.createElement(ee, { as: o, ...i }, /* @__PURE__ */ t.createElement(g, { padding: 2 }, /* @__PURE__ */ t.createElement(O, null, l))) : v ? /* @__PURE__ */ t.createElement(ne, { isExternal: !0, ...i }, /* @__PURE__ */ t.createElement(g, { padding: 2 }, /* @__PURE__ */ t.createElement(O, null, l))) : /* @__PURE__ */ t.createElement(Z, { onKeyDown: x, onMouseDown: d, type: "button", ...i }, /* @__PURE__ */ t.createElement(g, { padding: 2 }, /* @__PURE__ */ t.createElement(O, null, l)));
62
- };
63
- $.defaultProps = {
64
- as: void 0,
65
- onClick() {
66
- },
67
- isExternal: !1,
68
- isFocused: !1,
69
- isLink: !1
70
- };
71
- $.propTypes = {
72
- as: e.elementType,
73
- children: e.node.isRequired,
74
- isExternal: e.bool,
75
- isFocused: e.bool,
76
- isLink: e.bool,
77
- onClick: e.func
78
- };
79
- const h = ({
80
- label: o,
81
- children: l,
82
- id: d,
83
- as: c,
84
- onOpen: k = () => {
85
- },
86
- onClose: v = () => {
87
- },
88
- size: C,
89
- popoverPlacement: p,
90
- onReachEnd: i,
91
- ...x
1
+ import { jsxs as I, jsx as s } from "react/jsx-runtime";
2
+ import { useRef as h, useState as g } from "react";
3
+ import { Root as x, Trigger as M, Content as R, Item as j } from "./Menu.js";
4
+ import * as b from "./Menu.js";
5
+ import { useId as y } from "../../hooks/useId.js";
6
+ import { useIntersection as C } from "../../hooks/useIntersection.js";
7
+ const O = ({
8
+ children: c,
9
+ id: f,
10
+ onOpen: t,
11
+ onClose: n,
12
+ popoverPlacement: m,
13
+ onReachEnd: o,
14
+ ...r
92
15
  }) => {
93
- const s = b(), P = J(d), R = b(!1), [u, f] = B(!1), [D, I] = B(0), y = z.toArray(l), A = c || (C === "S" ? oe : K), S = !!i && typeof i == "function";
94
- E(() => {
95
- if (["string", "number"].includes(typeof o)) {
96
- const n = y.findIndex((r) => r.props.children === o);
97
- n !== -1 && I(n);
98
- }
99
- }, [o]);
100
- const w = L(k), M = L(v);
101
- E(() => {
102
- R?.current ? u ? w() : M() : R.current = !0;
103
- }, [R, u, w, M]), E(() => {
104
- t.isValidElement(o) && D === -1 && s.current.focus();
105
- }, [o, D]);
106
- const N = (n) => {
107
- u && (n.key === a.ESCAPE && (n.stopPropagation(), f(!1), s.current.focus()), n.key === a.DOWN && I((r) => r === y.length - 1 ? 0 : r + 1), n.key === a.UP && I((r) => r === 0 ? y.length - 1 : r - 1));
108
- }, F = (n) => {
109
- (n.key === a.ENTER || n.key === a.SPACE) && f((r) => !r);
110
- }, V = (n) => {
111
- n.preventDefault(), n.currentTarget.contains(n.relatedTarget) || f(!1);
112
- }, q = (n) => {
113
- n.preventDefault(), f((r) => !r);
114
- }, W = () => {
115
- S && i();
116
- }, _ = y.map((n, r) => /* @__PURE__ */ t.createElement(G, { as: "li", key: r, justifyContent: "center", role: "menuitem" }, j(n, {
117
- onClick() {
118
- n.props.onClick(), f(!1), s.current.focus();
119
- },
120
- isFocused: D === r
121
- })));
122
- return /* @__PURE__ */ t.createElement("div", { onKeyDown: N }, /* @__PURE__ */ t.createElement(
123
- A,
124
- {
125
- label: t.isValidElement(o) ? null : o,
126
- "aria-haspopup": !0,
127
- "aria-expanded": u,
128
- "aria-controls": P,
129
- onKeyDown: F,
130
- onMouseDown: q,
131
- ref: s,
132
- type: "button",
133
- variant: "ghost",
134
- endIcon: /* @__PURE__ */ t.createElement(te, null, /* @__PURE__ */ t.createElement(H, { "aria-hidden": !0 })),
135
- ...x
136
- },
137
- o
138
- ), u && /* @__PURE__ */ t.createElement(
139
- X,
140
- {
141
- onBlur: V,
142
- placement: p,
143
- source: s,
144
- onReachEnd: W,
145
- intersectionId: S ? `popover-${P}` : void 0,
146
- spacing: 4
147
- },
148
- /* @__PURE__ */ t.createElement(g, { role: "menu", as: "ul", padding: 1, id: P }, _)
149
- ));
150
- };
151
- h.defaultProps = {
152
- as: void 0
153
- };
154
- h.displayName = "SimpleMenu";
155
- h.defaultProps = {
156
- id: void 0,
157
- onClose() {
158
- },
159
- onOpen() {
160
- },
161
- onReachEnd: void 0,
162
- popoverPlacement: "bottom-start",
163
- size: "M"
164
- };
165
- h.propTypes = {
166
- as: e.any,
167
- children: e.oneOfType([e.arrayOf(e.node), e.node]).isRequired,
168
- id: e.string,
169
- label: e.oneOfType([e.string, e.number, e.element]).isRequired,
170
- onClose: e.func,
171
- onOpen: e.func,
172
- onReachEnd: e.func,
173
- popoverPlacement: e.oneOf(Q),
174
- size: e.oneOf(["S", "M"])
175
- };
16
+ const l = h(null), [a, p] = g(!1), d = (e) => {
17
+ o && o(e);
18
+ }, u = (e) => {
19
+ e && typeof t == "function" ? t() : !e && typeof n == "function" && n(), p(e);
20
+ }, i = `intersection-${y(f)}`;
21
+ return C(l, d, {
22
+ selectorToWatch: `#${i}`,
23
+ skipWhen: !a
24
+ }), I(x, {
25
+ onOpenChange: u,
26
+ children: [s(M, {
27
+ ...r,
28
+ children: r.label
29
+ }), s(R, {
30
+ intersectionId: i,
31
+ popoverPlacement: m,
32
+ children: c
33
+ })]
34
+ });
35
+ }, P = j;
176
36
  export {
177
- $ as MenuItem,
178
- h as SimpleMenu
37
+ b as Menu,
38
+ P as MenuItem,
39
+ O as SimpleMenu
179
40
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./SimpleMenu.cjs");exports.MenuItem=e.MenuItem;exports.SimpleMenu=e.SimpleMenu;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./SimpleMenu.cjs"),u=require("./Menu.cjs");exports.MenuItem=e.MenuItem;exports.SimpleMenu=e.SimpleMenu;exports.Menu=u;
@@ -1,5 +1,7 @@
1
- import { MenuItem as n, SimpleMenu as o } from "./SimpleMenu.js";
1
+ import { MenuItem as r, SimpleMenu as p } from "./SimpleMenu.js";
2
+ import * as e from "./Menu.js";
2
3
  export {
3
- n as MenuItem,
4
- o as SimpleMenu
4
+ e as Menu,
5
+ r as MenuItem,
6
+ p as SimpleMenu
5
7
  };