@strapi/design-system 1.3.1 → 1.4.0-beta.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.
- package/dist/Accordion/Accordion.cjs +8 -8
- package/dist/Accordion/Accordion.js +6 -7
- package/dist/Alert/Alert.cjs +3 -3
- package/dist/Alert/Alert.js +10 -10
- package/dist/Badge/Badge.cjs +4 -1
- package/dist/Badge/Badge.js +46 -38
- package/dist/BaseCheckbox/BaseCheckbox.cjs +1 -1
- package/dist/BaseCheckbox/BaseCheckbox.js +1 -1
- package/dist/BaseRadio/RadioGroup.cjs +1 -1
- package/dist/BaseRadio/RadioGroup.js +5 -5
- package/dist/Card/CardContent.cjs +1 -1
- package/dist/Card/CardContent.js +3 -3
- package/dist/CarouselInput/CarouselImage.cjs +1 -1
- package/dist/CarouselInput/CarouselImage.js +3 -3
- package/dist/CarouselInput/CarouselInput.cjs +1 -1
- package/dist/CarouselInput/CarouselInput.js +27 -26
- package/dist/CarouselInput/CarouselSlide.cjs +1 -1
- package/dist/CarouselInput/CarouselSlide.js +3 -3
- package/dist/Combobox/Combobox.cjs +1 -1
- package/dist/Combobox/Combobox.js +137 -119
- package/dist/Combobox/ComboboxList.cjs +1 -1
- package/dist/Combobox/ComboboxList.js +5 -5
- package/dist/Combobox/components.cjs +2 -2
- package/dist/Combobox/components.js +1 -1
- package/dist/Combobox/utils.cjs +1 -1
- package/dist/Combobox/utils.js +18 -18
- package/dist/DatePicker/DatePicker.cjs +1 -1
- package/dist/DatePicker/DatePicker.js +53 -54
- package/dist/DatePicker/DatePickerCalendar.cjs +1 -1
- package/dist/DatePicker/DatePickerCalendar.js +17 -12
- package/dist/DatePicker/DatePickerTd.cjs +3 -3
- package/dist/DatePicker/DatePickerTd.js +24 -24
- package/dist/DateTimePicker/DateTimePicker.cjs +1 -0
- package/dist/DateTimePicker/DateTimePicker.js +143 -0
- package/dist/DateTimePicker/DateTimePickerProps.cjs +1 -0
- package/dist/DateTimePicker/DateTimePickerProps.js +51 -0
- package/dist/DateTimePicker/__tests__/parseDate.test.cjs +1 -0
- package/dist/DateTimePicker/__tests__/parseDate.test.js +8 -0
- package/dist/DateTimePicker/index.cjs +1 -0
- package/dist/DateTimePicker/index.js +4 -0
- package/dist/DateTimePicker/parseDate.cjs +1 -0
- package/dist/DateTimePicker/parseDate.js +7 -0
- package/dist/Dialog/DialogBody.cjs +2 -2
- package/dist/Dialog/DialogBody.js +14 -11
- package/dist/DismissibleLayer/DismissibleLayer.cjs +1 -1
- package/dist/DismissibleLayer/DismissibleLayer.js +26 -34
- package/dist/Divider/Divider.cjs +1 -1
- package/dist/Divider/Divider.js +3 -3
- package/dist/Field/Field.cjs +1 -1
- package/dist/Field/Field.js +26 -26
- package/dist/Field/FieldError.cjs +1 -1
- package/dist/Field/FieldError.js +4 -4
- package/dist/Field/FieldInput.cjs +1 -1
- package/dist/Field/FieldInput.js +1 -1
- package/dist/Flex/FlexProps.cjs +1 -1
- package/dist/Flex/FlexProps.js +9 -8
- package/dist/FocusTrap/ExampleComponent.cjs +1 -1
- package/dist/FocusTrap/ExampleComponent.js +3 -2
- package/dist/FocusTrap/FocusTrap.cjs +1 -1
- package/dist/FocusTrap/FocusTrap.js +27 -26
- package/dist/Icon/Icon.cjs +1 -1
- package/dist/Icon/Icon.js +3 -3
- package/dist/IconButton/IconButton.cjs +2 -2
- package/dist/IconButton/IconButton.js +13 -14
- package/dist/Link/Link.cjs +3 -3
- package/dist/Link/Link.js +19 -17
- package/dist/LinkButton/LinkButton.cjs +2 -2
- package/dist/LinkButton/LinkButton.js +2 -2
- package/dist/NumberInput/NumberInput.cjs +2 -2
- package/dist/NumberInput/NumberInput.js +134 -136
- package/dist/Popover/Popover.cjs +2 -2
- package/dist/Popover/Popover.js +10 -9
- package/dist/RawTable/RawCell.cjs +1 -1
- package/dist/RawTable/RawCell.js +91 -76
- package/dist/RawTable/RawTable.cjs +1 -1
- package/dist/RawTable/RawTable.js +24 -23
- package/dist/RawTable/RawTableContext.cjs +1 -1
- package/dist/RawTable/RawTableContext.js +1 -1
- package/dist/RawTable/RawTr.cjs +1 -1
- package/dist/RawTable/RawTr.js +1 -1
- package/dist/Select/Select.cjs +2 -2
- package/dist/Select/Select.js +147 -142
- package/dist/SimpleMenu/SimpleMenu.cjs +7 -7
- package/dist/SimpleMenu/SimpleMenu.js +128 -113
- package/dist/Status/Status.cjs +4 -4
- package/dist/Status/Status.js +1 -1
- package/dist/SubNav/SubNavHeader.cjs +2 -2
- package/dist/SubNav/SubNavHeader.js +21 -21
- package/dist/SubNav/SubNavLink.cjs +4 -4
- package/dist/SubNav/SubNavLink.js +22 -23
- package/dist/SubNav/SubNavLinkSection.cjs +4 -4
- package/dist/SubNav/SubNavLinkSection.js +8 -7
- package/dist/SubNav/SubNavSection.cjs +2 -2
- package/dist/SubNav/SubNavSection.js +11 -10
- package/dist/SubNav/SubNavSectionLabel.cjs +1 -1
- package/dist/SubNav/SubNavSectionLabel.js +1 -1
- package/dist/Table/TFooter.cjs +2 -2
- package/dist/Table/TFooter.js +1 -1
- package/dist/Table/Table.cjs +3 -3
- package/dist/Table/Table.js +20 -17
- package/dist/Tabs/TabGroup.cjs +1 -1
- package/dist/Tabs/TabGroup.js +1 -1
- package/dist/Tabs/useTabsFocus.cjs +1 -1
- package/dist/Tabs/useTabsFocus.js +12 -11
- package/dist/TextInput/TextInput.cjs +1 -1
- package/dist/TextInput/TextInput.js +36 -36
- package/dist/Textarea/Textarea.cjs +2 -2
- package/dist/Textarea/Textarea.js +14 -14
- package/dist/TimePicker/TimePicker.cjs +3 -3
- package/dist/TimePicker/TimePicker.js +47 -42
- package/dist/ToggleCheckbox/ToggleCheckbox.cjs +2 -2
- package/dist/Tooltip/hooks/useTooltipLayout.cjs +1 -1
- package/dist/Tooltip/hooks/useTooltipLayout.js +9 -9
- package/dist/helpers/useIntersection.cjs +1 -1
- package/dist/helpers/useIntersection.js +13 -11
- package/dist/helpers/useResizeObserver.cjs +1 -1
- package/dist/helpers/useResizeObserver.js +10 -8
- package/dist/hooks/useControllableState.cjs +1 -0
- package/dist/hooks/useControllableState.js +25 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +289 -286
- package/dist/themes/ColorButton.cjs +2 -2
- package/dist/themes/ColorButton.js +4 -4
- package/dist/themes/extendTheme.cjs +3 -3
- package/dist/themes/extendTheme.js +6 -6
- package/dist/themes/sizes.cjs +1 -1
- package/dist/themes/sizes.js +4 -0
- package/dist/v2/Breadcrumbs/CrumbSimpleMenu.cjs +2 -2
- package/dist/v2/Breadcrumbs/CrumbSimpleMenu.js +6 -6
- package/dist/v2/LinkButton/LinkButton.cjs +1 -1
- package/dist/v2/LinkButton/LinkButton.js +19 -19
- package/dist/v2/SimpleMenu/SimpleMenu.cjs +7 -7
- package/dist/v2/SimpleMenu/SimpleMenu.js +101 -92
- package/dist/v2/SubNav/SubNavHeader.cjs +2 -2
- package/dist/v2/SubNav/SubNavHeader.js +21 -21
- package/dist/v2/SubNav/SubNavLink.cjs +2 -2
- package/dist/v2/SubNav/SubNavLink.js +16 -17
- package/dist/v2/SubNav/SubNavLinkSection.cjs +4 -4
- package/dist/v2/SubNav/SubNavLinkSection.js +8 -8
- package/dist/v2/SubNav/SubNavSection.cjs +2 -2
- package/dist/v2/SubNav/SubNavSection.js +1 -1
- package/dist/v2/SubNav/SubNavSectionLabel.cjs +1 -1
- package/dist/v2/SubNav/SubNavSectionLabel.js +1 -1
- package/package.json +6 -13
package/dist/Select/Select.js
CHANGED
|
@@ -1,74 +1,75 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
1
|
+
var se = Object.defineProperty;
|
|
2
|
+
var B = Object.getOwnPropertySymbols;
|
|
3
|
+
var G = Object.prototype.hasOwnProperty, H = Object.prototype.propertyIsEnumerable;
|
|
4
|
+
var z = (o, l, i) => l in o ? se(o, l, { enumerable: !0, configurable: !0, writable: !0, value: i }) : o[l] = i, W = (o, l) => {
|
|
5
5
|
for (var i in l || (l = {}))
|
|
6
|
-
|
|
7
|
-
if (
|
|
8
|
-
for (var i of
|
|
9
|
-
|
|
6
|
+
G.call(l, i) && z(o, i, l[i]);
|
|
7
|
+
if (B)
|
|
8
|
+
for (var i of B(l))
|
|
9
|
+
H.call(l, i) && z(o, i, l[i]);
|
|
10
10
|
return o;
|
|
11
11
|
};
|
|
12
|
-
var
|
|
12
|
+
var N = (o, l) => {
|
|
13
13
|
var i = {};
|
|
14
|
-
for (var
|
|
15
|
-
|
|
16
|
-
if (o != null &&
|
|
17
|
-
for (var
|
|
18
|
-
l.indexOf(
|
|
14
|
+
for (var s in o)
|
|
15
|
+
G.call(o, s) && l.indexOf(s) < 0 && (i[s] = o[s]);
|
|
16
|
+
if (o != null && B)
|
|
17
|
+
for (var s of B(o))
|
|
18
|
+
l.indexOf(s) < 0 && H.call(o, s) && (i[s] = o[s]);
|
|
19
19
|
return i;
|
|
20
20
|
};
|
|
21
|
-
import r, { useState as
|
|
21
|
+
import r, { useState as ae, useRef as pe, Children as J, cloneElement as K } from "react";
|
|
22
22
|
import e from "prop-types";
|
|
23
|
-
import
|
|
24
|
-
import
|
|
25
|
-
import
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
23
|
+
import ce from "@strapi/icons/CarretDown";
|
|
24
|
+
import me from "@strapi/icons/Cross";
|
|
25
|
+
import de from "styled-components";
|
|
26
|
+
import { sizes as fe } from "../themes/sizes.js";
|
|
27
|
+
import { SelectButton as ue } from "./SelectButton.js";
|
|
28
|
+
import { Field as he } from "../Field/Field.js";
|
|
29
|
+
import { FieldLabel as Ee } from "../Field/FieldLabel.js";
|
|
29
30
|
import "../Field/FieldInput.js";
|
|
30
|
-
import { FieldHint as
|
|
31
|
-
import { FieldError as
|
|
31
|
+
import { FieldHint as be } from "../Field/FieldHint.js";
|
|
32
|
+
import { FieldError as ye } from "../Field/FieldError.js";
|
|
32
33
|
import "../Field/FieldContext.js";
|
|
33
34
|
import "../Field/FieldAction.js";
|
|
34
|
-
import { Popover as
|
|
35
|
-
import { Stack as
|
|
36
|
-
import { Typography as
|
|
37
|
-
import { Flex as
|
|
38
|
-
import { Box as
|
|
39
|
-
import { useId as
|
|
40
|
-
import { SelectList as
|
|
41
|
-
import { SelectButtonWrapper as
|
|
42
|
-
import { useButtonRef as
|
|
43
|
-
import { VisuallyHidden as
|
|
44
|
-
import { DownState as
|
|
45
|
-
import { escapeSelector as
|
|
46
|
-
import { SelectTags as
|
|
47
|
-
|
|
48
|
-
const Te = Be($)`
|
|
35
|
+
import { Popover as ge } from "../Popover/Popover.js";
|
|
36
|
+
import { Stack as ve } from "../Stack/Stack.js";
|
|
37
|
+
import { Typography as Q } from "../Typography/Typography.js";
|
|
38
|
+
import { Flex as R } from "../Flex/Flex.js";
|
|
39
|
+
import { Box as U } from "../Box/Box.js";
|
|
40
|
+
import { useId as Be } from "../helpers/useId.js";
|
|
41
|
+
import { SelectList as Oe } from "./SelectList.js";
|
|
42
|
+
import { SelectButtonWrapper as Te, IconBox as Ce, CaretBox as Ie } from "./components.js";
|
|
43
|
+
import { useButtonRef as Se } from "./hooks/useButtonRef.js";
|
|
44
|
+
import { VisuallyHidden as X } from "../VisuallyHidden/VisuallyHidden.js";
|
|
45
|
+
import { DownState as xe } from "./constants.js";
|
|
46
|
+
import { escapeSelector as Y } from "../helpers/escapeSelector.js";
|
|
47
|
+
import { SelectTags as $e } from "./SelectTags.js";
|
|
48
|
+
const Re = de(R)`
|
|
49
49
|
width: 100%;
|
|
50
|
-
`,
|
|
51
|
-
var
|
|
50
|
+
`, Z = (we) => {
|
|
51
|
+
var F = we, {
|
|
52
52
|
label: o,
|
|
53
53
|
labelAction: l,
|
|
54
54
|
id: i,
|
|
55
|
-
children:
|
|
55
|
+
children: s,
|
|
56
56
|
customizeContent: h,
|
|
57
57
|
placeholder: O,
|
|
58
|
-
onChange:
|
|
58
|
+
onChange: T,
|
|
59
59
|
value: n,
|
|
60
|
-
hint:
|
|
61
|
-
error:
|
|
60
|
+
hint: C,
|
|
61
|
+
error: E,
|
|
62
62
|
disabled: m,
|
|
63
|
-
clearLabel:
|
|
64
|
-
onClear:
|
|
65
|
-
onReachEnd:
|
|
63
|
+
clearLabel: w,
|
|
64
|
+
onClear: D,
|
|
65
|
+
onReachEnd: V,
|
|
66
66
|
multi: p,
|
|
67
|
-
required:
|
|
68
|
-
|
|
67
|
+
required: ee,
|
|
68
|
+
selectButtonTitle: te,
|
|
69
|
+
size: re,
|
|
69
70
|
startIcon: L,
|
|
70
|
-
withTags:
|
|
71
|
-
} =
|
|
71
|
+
withTags: b
|
|
72
|
+
} = F, oe = N(F, [
|
|
72
73
|
"label",
|
|
73
74
|
"labelAction",
|
|
74
75
|
"id",
|
|
@@ -85,134 +86,136 @@ const Te = Be($)`
|
|
|
85
86
|
"onReachEnd",
|
|
86
87
|
"multi",
|
|
87
88
|
"required",
|
|
89
|
+
"selectButtonTitle",
|
|
88
90
|
"size",
|
|
89
91
|
"startIcon",
|
|
90
92
|
"withTags"
|
|
91
93
|
]);
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
+
const a = Be("select", i), [y, g] = ae(void 0), M = Se(y), k = pe(null), I = `${a}-label`, v = `${a}-content`, j = typeof E == "string";
|
|
95
|
+
let S;
|
|
96
|
+
if (j ? S = `${a}-error` : C && (S = `${a}-hint`), b && !p)
|
|
94
97
|
throw new Error('The "withTags" props can only be used when the "multi" prop is present');
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
},
|
|
98
|
-
m || (
|
|
99
|
-
},
|
|
100
|
-
t.preventDefault(), !m && (t.nativeEvent.which === 3 || t.nativeEvent.button === 2 ||
|
|
101
|
-
},
|
|
102
|
-
p ?
|
|
103
|
-
},
|
|
104
|
-
|
|
105
|
-
n.includes(t[0]) ? n.filter(
|
|
106
|
-
return this.indexOf(c) < 0;
|
|
107
|
-
}, t) : [...n, ...t]
|
|
98
|
+
const ne = () => {
|
|
99
|
+
g(void 0);
|
|
100
|
+
}, ie = () => {
|
|
101
|
+
m || (D(), M.current.focus());
|
|
102
|
+
}, A = (t) => {
|
|
103
|
+
t.preventDefault(), !m && (t.nativeEvent.which === 3 || t.nativeEvent.button === 2 || g(xe.Mouse));
|
|
104
|
+
}, x = (t, c = !0) => {
|
|
105
|
+
p ? T(n.includes(t) ? n.filter((d) => d !== t) : [...n, t]) : (T(t), c && g(void 0));
|
|
106
|
+
}, P = (t) => {
|
|
107
|
+
T(
|
|
108
|
+
n.includes(t[0]) ? n.filter((c, d, u) => u.indexOf(c) < 0, t) : [...n, ...t]
|
|
108
109
|
);
|
|
109
110
|
};
|
|
110
|
-
let
|
|
111
|
-
const
|
|
112
|
-
const
|
|
113
|
-
return
|
|
114
|
-
id:
|
|
115
|
-
onClick: () =>
|
|
116
|
-
selected:
|
|
111
|
+
let $, _ = [];
|
|
112
|
+
const q = (t, c) => {
|
|
113
|
+
const d = `${a}-option-${t.props.value}`, u = p ? n.includes(t.props.value) : t.props.value === n;
|
|
114
|
+
return u && (b ? _.push({ label: t.props.children, value: t.props.value }) : $ = t.props.children), K(t, {
|
|
115
|
+
id: Y(d),
|
|
116
|
+
onClick: () => x(t.props.value),
|
|
117
|
+
selected: u,
|
|
117
118
|
multi: p,
|
|
118
119
|
isChild: c
|
|
119
120
|
});
|
|
120
|
-
},
|
|
121
|
+
}, le = J.toArray(s).map((t) => {
|
|
121
122
|
if (t.type.displayName === "OptGroup") {
|
|
122
|
-
const c = `${
|
|
123
|
-
return
|
|
124
|
-
id:
|
|
125
|
-
onClick: () =>
|
|
126
|
-
selected:
|
|
127
|
-
indeterminate:
|
|
123
|
+
const c = `${a}-option-${t.props.label}`, d = t.props.children.every((f) => n.includes(f.props.value)), u = !d && t.props.children.some((f) => n.includes(f.props.value));
|
|
124
|
+
return K(t, {
|
|
125
|
+
id: Y(c),
|
|
126
|
+
onClick: () => P(t.props.children.map((f) => f.props.value)),
|
|
127
|
+
selected: d,
|
|
128
|
+
indeterminate: u,
|
|
128
129
|
multi: p,
|
|
129
|
-
children:
|
|
130
|
+
children: J.toArray(t.props.children).map((f) => q(f, !0)),
|
|
130
131
|
value: t.props.label
|
|
131
132
|
});
|
|
132
|
-
}
|
|
133
|
-
|
|
133
|
+
}
|
|
134
|
+
return q(t);
|
|
134
135
|
});
|
|
135
|
-
return /* @__PURE__ */ r.createElement(
|
|
136
|
-
hint:
|
|
137
|
-
error:
|
|
138
|
-
id:
|
|
139
|
-
}, /* @__PURE__ */ r.createElement(
|
|
140
|
-
spacing: o ||
|
|
141
|
-
}, o && /* @__PURE__ */ r.createElement(
|
|
142
|
-
required:
|
|
136
|
+
return /* @__PURE__ */ r.createElement(he, {
|
|
137
|
+
hint: C,
|
|
138
|
+
error: E,
|
|
139
|
+
id: a
|
|
140
|
+
}, /* @__PURE__ */ r.createElement(ve, {
|
|
141
|
+
spacing: o || C || j ? 1 : 0
|
|
142
|
+
}, o && /* @__PURE__ */ r.createElement(Ee, {
|
|
143
|
+
required: ee,
|
|
143
144
|
as: "span",
|
|
144
|
-
id:
|
|
145
|
+
id: I,
|
|
145
146
|
action: l
|
|
146
|
-
}, o), /* @__PURE__ */ r.createElement(
|
|
147
|
-
size:
|
|
148
|
-
hasError: Boolean(
|
|
147
|
+
}, o), /* @__PURE__ */ r.createElement(Te, {
|
|
148
|
+
size: re,
|
|
149
|
+
hasError: Boolean(E),
|
|
149
150
|
disabled: m,
|
|
150
|
-
ref:
|
|
151
|
-
}, /* @__PURE__ */ r.createElement(
|
|
152
|
-
ref:
|
|
153
|
-
labelledBy: `${
|
|
154
|
-
"aria-describedby":
|
|
155
|
-
expanded: Boolean(
|
|
156
|
-
onTrigger:
|
|
157
|
-
id:
|
|
158
|
-
hasError: Boolean(
|
|
151
|
+
ref: k
|
|
152
|
+
}, /* @__PURE__ */ r.createElement(ue, W({
|
|
153
|
+
ref: M,
|
|
154
|
+
labelledBy: `${I} ${v}`,
|
|
155
|
+
"aria-describedby": S,
|
|
156
|
+
expanded: Boolean(y),
|
|
157
|
+
onTrigger: g,
|
|
158
|
+
id: a,
|
|
159
|
+
hasError: Boolean(E),
|
|
159
160
|
disabled: m,
|
|
160
|
-
onMouseDown:
|
|
161
|
-
},
|
|
161
|
+
onMouseDown: A
|
|
162
|
+
}, oe)), /* @__PURE__ */ r.createElement(Re, {
|
|
162
163
|
justifyContent: "space-between"
|
|
163
|
-
}, /* @__PURE__ */ r.createElement(
|
|
164
|
+
}, /* @__PURE__ */ r.createElement(R, null, L && /* @__PURE__ */ r.createElement(U, {
|
|
164
165
|
paddingLeft: 3,
|
|
165
166
|
"aria-hidden": !0
|
|
166
|
-
}, L),
|
|
167
|
-
tags:
|
|
168
|
-
onRemoveTag:
|
|
167
|
+
}, L), b && /* @__PURE__ */ r.createElement($e, {
|
|
168
|
+
tags: _,
|
|
169
|
+
onRemoveTag: x,
|
|
169
170
|
disabled: m
|
|
170
|
-
}), /* @__PURE__ */ r.createElement(
|
|
171
|
+
}), /* @__PURE__ */ r.createElement(U, {
|
|
171
172
|
paddingLeft: 4,
|
|
172
173
|
paddingRight: 4
|
|
173
|
-
},
|
|
174
|
+
}, b ? /* @__PURE__ */ r.createElement(r.Fragment, null, !n || n.length === 0 ? /* @__PURE__ */ r.createElement(Q, {
|
|
174
175
|
ellipsis: !0,
|
|
175
|
-
id:
|
|
176
|
+
id: v,
|
|
176
177
|
textColor: "neutral600"
|
|
177
|
-
}, O) : null, /* @__PURE__ */ r.createElement(
|
|
178
|
+
}, O) : null, /* @__PURE__ */ r.createElement(X, {
|
|
178
179
|
as: "span",
|
|
179
|
-
id:
|
|
180
|
-
}, h ? h(n) :
|
|
180
|
+
id: v
|
|
181
|
+
}, h ? h(n) : $ || O, n.join(", "))) : /* @__PURE__ */ r.createElement(Q, {
|
|
181
182
|
ellipsis: !0,
|
|
182
|
-
id:
|
|
183
|
+
id: v,
|
|
183
184
|
textColor: n ? "neutral800" : "neutral600"
|
|
184
|
-
}, h ? h(n) :
|
|
185
|
+
}, h ? h(n) : $ || O, p && /* @__PURE__ */ r.createElement(X, {
|
|
185
186
|
as: "span"
|
|
186
|
-
}, n.join(", "))))), /* @__PURE__ */ r.createElement(
|
|
187
|
+
}, n.join(", "))))), /* @__PURE__ */ r.createElement(R, null, (p && n && n.length || !p && n) && D && /* @__PURE__ */ r.createElement(Ce, {
|
|
187
188
|
as: "button",
|
|
188
189
|
type: "button",
|
|
189
|
-
onClick:
|
|
190
|
-
"aria-label":
|
|
191
|
-
"aria-disabled": m
|
|
192
|
-
|
|
190
|
+
onClick: ie,
|
|
191
|
+
"aria-label": w,
|
|
192
|
+
"aria-disabled": m,
|
|
193
|
+
title: w
|
|
194
|
+
}, /* @__PURE__ */ r.createElement(me, null)), /* @__PURE__ */ r.createElement(Ie, {
|
|
193
195
|
paddingLeft: 3,
|
|
194
196
|
"aria-hidden": !0,
|
|
195
197
|
as: "button",
|
|
196
198
|
type: "button",
|
|
197
|
-
onMouseDown:
|
|
199
|
+
onMouseDown: A,
|
|
198
200
|
tabIndex: -1,
|
|
199
|
-
disabled: m
|
|
200
|
-
|
|
201
|
-
|
|
201
|
+
disabled: m,
|
|
202
|
+
title: te
|
|
203
|
+
}, /* @__PURE__ */ r.createElement(ce, null))))), /* @__PURE__ */ r.createElement(be, null), /* @__PURE__ */ r.createElement(ye, null)), y && /* @__PURE__ */ r.createElement(ge, {
|
|
204
|
+
source: k,
|
|
202
205
|
spacing: 4,
|
|
203
206
|
fullWidth: !0,
|
|
204
|
-
intersectionId: `select-list-intersection-${
|
|
205
|
-
onReachEnd:
|
|
206
|
-
}, /* @__PURE__ */ r.createElement(
|
|
207
|
-
selectId:
|
|
208
|
-
labelledBy: o ?
|
|
209
|
-
onEscape:
|
|
210
|
-
expanded:
|
|
211
|
-
onSelectItem: (t, c) => c ?
|
|
207
|
+
intersectionId: `select-list-intersection-${a}`,
|
|
208
|
+
onReachEnd: V
|
|
209
|
+
}, /* @__PURE__ */ r.createElement(Oe, {
|
|
210
|
+
selectId: a,
|
|
211
|
+
labelledBy: o ? I : void 0,
|
|
212
|
+
onEscape: ne,
|
|
213
|
+
expanded: y,
|
|
214
|
+
onSelectItem: (t, c) => c ? P(t) : x(t, !1),
|
|
212
215
|
multi: p
|
|
213
|
-
},
|
|
216
|
+
}, le)));
|
|
214
217
|
};
|
|
215
|
-
|
|
218
|
+
Z.defaultProps = {
|
|
216
219
|
"aria-label": void 0,
|
|
217
220
|
children: [],
|
|
218
221
|
clearLabel: "Clear",
|
|
@@ -222,7 +225,7 @@ U.defaultProps = {
|
|
|
222
225
|
label: void 0,
|
|
223
226
|
labelAction: void 0,
|
|
224
227
|
multi: !1,
|
|
225
|
-
onChange
|
|
228
|
+
onChange() {
|
|
226
229
|
},
|
|
227
230
|
onClear: void 0,
|
|
228
231
|
onReachEnd: void 0,
|
|
@@ -231,17 +234,18 @@ U.defaultProps = {
|
|
|
231
234
|
error: void 0,
|
|
232
235
|
placeholder: "Select...",
|
|
233
236
|
required: !1,
|
|
237
|
+
selectButtonTitle: "Carret Down Button",
|
|
234
238
|
size: "M",
|
|
235
239
|
startIcon: void 0,
|
|
236
240
|
withTags: !1
|
|
237
241
|
};
|
|
238
|
-
|
|
242
|
+
Z.propTypes = {
|
|
239
243
|
"aria-label": e.string,
|
|
240
244
|
children: e.oneOfType([e.arrayOf(e.node), e.node]),
|
|
241
245
|
clearLabel: e.string,
|
|
242
246
|
customizeContent: e.func,
|
|
243
247
|
disabled: e.bool,
|
|
244
|
-
error: e.string,
|
|
248
|
+
error: e.oneOfType([e.string, e.bool]),
|
|
245
249
|
hint: e.oneOfType([e.string, e.node, e.arrayOf(e.node)]),
|
|
246
250
|
id: e.oneOfType([e.string, e.number]),
|
|
247
251
|
label: e.string,
|
|
@@ -252,7 +256,8 @@ U.propTypes = {
|
|
|
252
256
|
onReachEnd: e.func,
|
|
253
257
|
placeholder: e.string,
|
|
254
258
|
required: e.bool,
|
|
255
|
-
|
|
259
|
+
selectButtonTitle: e.string,
|
|
260
|
+
size: e.oneOf(Object.keys(fe.input)),
|
|
256
261
|
startIcon: e.element,
|
|
257
262
|
value: e.oneOfType([
|
|
258
263
|
e.arrayOf(e.oneOfType([e.string, e.number])),
|
|
@@ -262,5 +267,5 @@ U.propTypes = {
|
|
|
262
267
|
withTags: e.bool
|
|
263
268
|
};
|
|
264
269
|
export {
|
|
265
|
-
|
|
270
|
+
Z as Select
|
|
266
271
|
};
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var Z=Object.defineProperty;var v=Object.getOwnPropertySymbols;var F=Object.prototype.hasOwnProperty,A=Object.prototype.propertyIsEnumerable;var j=(e,a,n)=>a in e?Z(e,a,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[a]=n,E=(e,a)=>{for(var n in a||(a={}))F.call(a,n)&&j(e,n,a[n]);if(v)for(var n of v(a))A.call(a,n)&&j(e,n,a[n]);return e};var I=(e,a)=>{var n={};for(var r in e)F.call(e,r)&&a.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&v)for(var r of v(e))a.indexOf(r)<0&&A.call(e,r)&&(n[r]=e[r]);return n};Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("react"),ee=require("prop-types"),te=require("styled-components"),ne=require("react-router-dom"),N=require("@radix-ui/react-use-callback-ref"),oe=require("@strapi/icons/CarretDown"),$=require("../Typography/Typography.cjs"),q=require("../Box/Box.cjs"),ae=require("../Flex/Flex.cjs"),L=require("../Button/Button.cjs"),V=require("../Popover/Popover.cjs"),W=require("./utils.cjs"),re=require("../helpers/useId.cjs"),c=require("../helpers/keyboardKeys.cjs"),K=e=>e&&typeof e=="object"&&"default"in e?e:{default:e},s=K(l),t=K(ee),C=K(te),se=K(oe),ue=C.default.button`
|
|
2
2
|
border: none;
|
|
3
3
|
padding: 0;
|
|
4
4
|
background: transparent;
|
|
5
5
|
cursor: pointer;
|
|
6
|
-
${
|
|
7
|
-
`,
|
|
6
|
+
${W.getOptionStyle}
|
|
7
|
+
`,le=C.default(ne.NavLink)`
|
|
8
8
|
text-decoration: none;
|
|
9
|
-
${
|
|
10
|
-
`,
|
|
9
|
+
${W.getOptionStyle}
|
|
10
|
+
`,ce=C.default.span`
|
|
11
11
|
display: flex;
|
|
12
12
|
align-items: center;
|
|
13
13
|
svg {
|
|
14
14
|
height: 4px;
|
|
15
15
|
width: 6px;
|
|
16
16
|
}
|
|
17
|
-
`,
|
|
17
|
+
`,de=C.default(L.Button)`
|
|
18
18
|
padding: ${({theme:e})=>`${e.spaces[1]} ${e.spaces[3]}`};
|
|
19
|
-
`,
|
|
19
|
+
`,B=S=>{var h=S,{children:e,onClick:a,to:n,isFocused:r}=h,P=I(h,["children","onClick","to","isFocused"]);const i=l.useRef();l.useEffect(()=>{r&&i.current&&i.current.focus()},[r]);const d=E({tabIndex:r?0:-1,ref:i,role:"menuitem"},P),k=R=>{(R.key===c.KeyboardKeys.SPACE||R.key===c.KeyboardKeys.ENTER)&&a()};return n?s.default.createElement(le,E({to:n},d),s.default.createElement(q.Box,{padding:2},s.default.createElement($.Typography,null,e))):s.default.createElement(ue,E({onKeyDown:k,onMouseDown:a,type:"button"},d),s.default.createElement(q.Box,{padding:2},s.default.createElement($.Typography,null,e)))};B.defaultProps={as:void 0,onClick(){},isFocused:!1,to:void 0};B.propTypes={as:t.default.elementType,children:t.default.node.isRequired,isFocused:t.default.bool,onClick:t.default.func,to:t.default.string};const g=R=>{var O=R,{label:e,children:a,id:n,as:r,onOpen:P=()=>{},onClose:S=()=>{},size:h,popoverPlacement:i,onReachEnd:d}=O,k=I(O,["label","children","id","as","onOpen","onClose","size","popoverPlacement","onReachEnd"]);const f=l.useRef(),x=re.useId("simplemenu",n),p=l.useRef(!1),[y,m]=l.useState(!1),[T,D]=l.useState(0),b=l.Children.toArray(a),z=h==="S"?de:L.Button,U=r||z,w=!!d&&typeof d=="function";l.useEffect(()=>{if(["string","number"].includes(typeof e)){const o=b.findIndex(u=>u.props.children===e);o!==-1&&D(o)}},[e]);const M=N.useCallbackRef(P),_=N.useCallbackRef(S);l.useEffect(()=>{p!=null&&p.current?y?M():_():p.current=!0},[p,_,M,y]),l.useEffect(()=>{s.default.isValidElement(e)&&T===-1&&f.current.focus()},[e,T]);const H=o=>{y&&(o.key===c.KeyboardKeys.ESCAPE&&(o.stopPropagation(),m(!1),f.current.focus()),o.key===c.KeyboardKeys.DOWN&&D(u=>u===b.length-1?0:u+1),o.key===c.KeyboardKeys.UP&&D(u=>u===0?b.length-1:u-1))},G=o=>{(o.key===c.KeyboardKeys.ENTER||o.key===c.KeyboardKeys.SPACE)&&m(u=>!u)},J=o=>{o.preventDefault(),o.currentTarget.contains(o.relatedTarget)||m(!1)},Q=o=>{o.preventDefault(),m(u=>!u)},X=()=>{w&&d()},Y=b.map((o,u)=>s.default.createElement(ae.Flex,{as:"li",key:u,justifyContent:"center",role:"menuitem"},l.cloneElement(o,{onClick(){o.props.onClick(),m(!1),f.current.focus()},isFocused:T===u})));return s.default.createElement("div",{onKeyDown:H},s.default.createElement(U,E({label:s.default.isValidElement(e)?null:e,"aria-haspopup":!0,"aria-expanded":y,"aria-controls":x,onKeyDown:G,onMouseDown:Q,ref:f,type:"button",variant:"ghost",endIcon:s.default.createElement(ce,null,s.default.createElement(se.default,{"aria-hidden":!0}))},k),e),y&&s.default.createElement(V.Popover,{onBlur:J,placement:i,source:f,onReachEnd:X,intersectionId:w?`popover-${x}`:void 0,spacing:4},s.default.createElement(q.Box,{role:"menu",as:"ul",padding:1,id:x},Y)))};g.defaultProps={as:void 0};g.displayName="SimpleMenu";g.defaultProps={id:void 0,onOpen:void 0,onClose:void 0,onReachEnd:void 0,popoverPlacement:"bottom-start",size:"M"};g.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(V.POPOVER_PLACEMENTS),size:t.default.oneOf(["S","M"])};exports.MenuItem=B;exports.SimpleMenu=g;
|