se-design 1.0.85 → 1.0.86
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/components/DropdownWithInputTags/index.d.ts +2 -1
- package/dist/index25.js +207 -204
- package/dist/index25.js.map +1 -1
- package/dist/index38.js +195 -189
- package/dist/index38.js.map +1 -1
- package/dist/index68.js +73 -63
- package/dist/index68.js.map +1 -1
- package/dist/index79.js +31 -25
- package/dist/index79.js.map +1 -1
- package/package.json +1 -1
|
@@ -17,7 +17,8 @@ export interface DropdownWithInputTagsProps {
|
|
|
17
17
|
renderOption?: (option: DropdownOption, props: {
|
|
18
18
|
id: string;
|
|
19
19
|
role: 'option';
|
|
20
|
-
'aria-selected'
|
|
20
|
+
'aria-selected'?: boolean;
|
|
21
|
+
'aria-disabled'?: true;
|
|
21
22
|
onMouseEnter: () => void;
|
|
22
23
|
className: string;
|
|
23
24
|
}, onSelect: (option: DropdownOption) => void) => React.ReactNode;
|
package/dist/index25.js
CHANGED
|
@@ -1,145 +1,150 @@
|
|
|
1
|
-
import n, { useState as
|
|
2
|
-
import { Popover as
|
|
3
|
-
import { Icon as
|
|
4
|
-
import { Checkbox as
|
|
5
|
-
import { Button as
|
|
6
|
-
import { InputWithIcon as
|
|
7
|
-
import { useStableId as
|
|
8
|
-
import { useCombobox as
|
|
9
|
-
import { getFocusableElements as
|
|
1
|
+
import n, { useState as Q, useRef as ve, useEffect as _, useLayoutEffect as Re } from "react";
|
|
2
|
+
import { Popover as qe } from "./index19.js";
|
|
3
|
+
import { Icon as we } from "./index6.js";
|
|
4
|
+
import { Checkbox as He } from "./index23.js";
|
|
5
|
+
import { Button as Se } from "./index4.js";
|
|
6
|
+
import { InputWithIcon as Me } from "./index52.js";
|
|
7
|
+
import { useStableId as X } from "./index205.js";
|
|
8
|
+
import { useCombobox as xe } from "./index68.js";
|
|
9
|
+
import { getFocusableElements as Ue } from "./index71.js";
|
|
10
10
|
import "./index72.js";
|
|
11
|
-
import { announce as
|
|
12
|
-
function
|
|
13
|
-
return
|
|
11
|
+
import { announce as je } from "./index75.js";
|
|
12
|
+
function y() {
|
|
13
|
+
return y = Object.assign ? Object.assign.bind() : function(t) {
|
|
14
14
|
for (var h = 1; h < arguments.length; h++) {
|
|
15
15
|
var x = arguments[h];
|
|
16
|
-
for (var
|
|
16
|
+
for (var I in x) ({}).hasOwnProperty.call(x, I) && (t[I] = x[I]);
|
|
17
17
|
}
|
|
18
18
|
return t;
|
|
19
|
-
},
|
|
19
|
+
}, y.apply(null, arguments);
|
|
20
20
|
}
|
|
21
|
-
const
|
|
22
|
-
const h = t.selectedValue !== void 0, x = t.isOpen !== void 0, [
|
|
23
|
-
x ||
|
|
24
|
-
},
|
|
25
|
-
h ||
|
|
21
|
+
const rt = (t) => {
|
|
22
|
+
const h = t.selectedValue !== void 0, x = t.isOpen !== void 0, [I, Ee] = Q(!1), [E, G] = Q(""), [Ie, Y] = Q(() => t?.defaultSelectedValue ? Array.isArray(t?.defaultSelectedValue) ? t?.defaultSelectedValue : [t.defaultSelectedValue] : []), d = ve(null), C = ve(null), T = X(void 0, "dropdown-label"), Z = X(void 0, "dropdown-value"), D = X(void 0, "dropdown-listbox"), a = x ? t.isOpen : I, s = h ? Array.isArray(t.selectedValue) ? t.selectedValue : t.selectedValue ? [t.selectedValue] : [] : Ie, V = (e) => {
|
|
23
|
+
x || Ee(e), t.onOpenChange?.(e);
|
|
24
|
+
}, B = (e) => {
|
|
25
|
+
h || Y(e);
|
|
26
26
|
}, {
|
|
27
|
-
selectBy:
|
|
27
|
+
selectBy: p = "",
|
|
28
28
|
optionsUniqueBy: u = "",
|
|
29
|
-
displaySelected:
|
|
30
|
-
dropDownOptions:
|
|
31
|
-
defaultText:
|
|
32
|
-
iconColor:
|
|
33
|
-
disabled:
|
|
34
|
-
dropdownClassName:
|
|
35
|
-
hasError:
|
|
36
|
-
errorMessage:
|
|
37
|
-
customDropdownContent:
|
|
38
|
-
isBorderless:
|
|
39
|
-
shouldShowSearch:
|
|
40
|
-
showSearchIcon:
|
|
41
|
-
searchPlaceholder:
|
|
42
|
-
searchResultEmptyMessage:
|
|
29
|
+
displaySelected: Ce = !1,
|
|
30
|
+
dropDownOptions: k,
|
|
31
|
+
defaultText: g = "Select",
|
|
32
|
+
iconColor: ee = "var(--color-gray-700)",
|
|
33
|
+
disabled: A = !1,
|
|
34
|
+
dropdownClassName: De = "",
|
|
35
|
+
hasError: te = !1,
|
|
36
|
+
errorMessage: ke = "",
|
|
37
|
+
customDropdownContent: oe = null,
|
|
38
|
+
isBorderless: Pe = !1,
|
|
39
|
+
shouldShowSearch: c = !1,
|
|
40
|
+
showSearchIcon: Ne = !0,
|
|
41
|
+
searchPlaceholder: ne = "Search...",
|
|
42
|
+
searchResultEmptyMessage: re = "No results found",
|
|
43
43
|
ariaLabel: v = "",
|
|
44
44
|
customSelectedValue: R = "",
|
|
45
|
-
isWithPortal:
|
|
46
|
-
firstOptionAsHeading:
|
|
45
|
+
isWithPortal: q = !1,
|
|
46
|
+
firstOptionAsHeading: le = !1
|
|
47
47
|
} = t;
|
|
48
|
-
|
|
48
|
+
_(() => {
|
|
49
49
|
if (!h) {
|
|
50
50
|
const e = t?.defaultSelectedValue ? Array.isArray(t?.defaultSelectedValue) ? t?.defaultSelectedValue : [t.defaultSelectedValue] : [];
|
|
51
|
-
|
|
51
|
+
Y(e);
|
|
52
52
|
}
|
|
53
|
-
}, [t?.defaultSelectedValue, h]),
|
|
54
|
-
|
|
55
|
-
}, [
|
|
56
|
-
|
|
57
|
-
}, [
|
|
53
|
+
}, [t?.defaultSelectedValue, h]), _(() => {
|
|
54
|
+
a || G("");
|
|
55
|
+
}, [a]), _(() => {
|
|
56
|
+
a && c && C.current && requestAnimationFrame(() => C.current?.focus());
|
|
57
|
+
}, [a, c]), Re(() => {
|
|
58
58
|
t.popoverElementRef && (t.popoverElementRef.current = d.current?.element ?? null);
|
|
59
59
|
});
|
|
60
|
-
const
|
|
61
|
-
|
|
60
|
+
const i = t?.type === "multi-select", ae = {
|
|
61
|
+
__noResults: !0,
|
|
62
|
+
id: "__no_results__",
|
|
63
|
+
value: "__no_results__"
|
|
64
|
+
}, se = (e) => !!e?.__noResults, $e = () => E.trim() ? (k || []).filter((e) => (e?.[p]?.toString().toLowerCase() || "").includes(E.toLowerCase())) : k || [], K = (e) => {
|
|
65
|
+
B([e]), V(!1), t?.onOptionClick?.(e), requestAnimationFrame(() => {
|
|
62
66
|
requestAnimationFrame(() => {
|
|
63
67
|
d.current?.focusTrigger();
|
|
64
68
|
});
|
|
65
69
|
});
|
|
66
|
-
},
|
|
67
|
-
listboxProps:
|
|
68
|
-
getOptionProps:
|
|
69
|
-
highlightedIndex:
|
|
70
|
-
setHighlightedIndex:
|
|
70
|
+
}, l = $e(), ie = l.length === 0 && (E.trim() || k?.length === 0), H = i ? [] : l.length > 0 ? l : ie ? [ae] : [], M = i ? l.length > 0 ? l : ie ? [ae] : [] : [], {
|
|
71
|
+
listboxProps: U,
|
|
72
|
+
getOptionProps: ce,
|
|
73
|
+
highlightedIndex: w,
|
|
74
|
+
setHighlightedIndex: de,
|
|
71
75
|
containerProps: j,
|
|
72
76
|
inputProps: L,
|
|
73
|
-
isKeyboardFocused:
|
|
74
|
-
} =
|
|
75
|
-
items:
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
onOpenChange: $,
|
|
77
|
+
isKeyboardFocused: W
|
|
78
|
+
} = xe({
|
|
79
|
+
items: H,
|
|
80
|
+
isOpen: a && !i,
|
|
81
|
+
onOpenChange: V,
|
|
79
82
|
onSelect: (e) => {
|
|
80
|
-
|
|
83
|
+
K(e);
|
|
81
84
|
},
|
|
82
|
-
listboxId:
|
|
83
|
-
disabled:
|
|
84
|
-
hasItems:
|
|
85
|
+
listboxId: D,
|
|
86
|
+
disabled: i || A,
|
|
87
|
+
hasItems: H.length > 0,
|
|
88
|
+
isItemDisabled: se
|
|
85
89
|
}), {
|
|
86
|
-
inputProps:
|
|
87
|
-
listboxProps:
|
|
88
|
-
containerProps:
|
|
89
|
-
highlightedIndex:
|
|
90
|
-
setHighlightedIndex:
|
|
91
|
-
isKeyboardFocused:
|
|
92
|
-
} =
|
|
93
|
-
items:
|
|
94
|
-
isOpen:
|
|
95
|
-
onOpenChange:
|
|
90
|
+
inputProps: z,
|
|
91
|
+
listboxProps: P,
|
|
92
|
+
containerProps: N,
|
|
93
|
+
highlightedIndex: S,
|
|
94
|
+
setHighlightedIndex: Ve,
|
|
95
|
+
isKeyboardFocused: J
|
|
96
|
+
} = xe({
|
|
97
|
+
items: M,
|
|
98
|
+
isOpen: a && i,
|
|
99
|
+
onOpenChange: V,
|
|
96
100
|
onSelect: () => {
|
|
97
101
|
},
|
|
98
|
-
listboxId:
|
|
99
|
-
disabled: !
|
|
102
|
+
listboxId: D,
|
|
103
|
+
disabled: !i,
|
|
100
104
|
loop: !1,
|
|
101
|
-
hasItems:
|
|
102
|
-
closeOnTab: !1
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
105
|
+
hasItems: M.length > 0,
|
|
106
|
+
closeOnTab: !1,
|
|
107
|
+
isItemDisabled: se
|
|
108
|
+
}), ue = i ? S : w;
|
|
109
|
+
_(() => {
|
|
110
|
+
a && l.length === 0 && (E.trim() || k?.length === 0) && ue === -1 && je(re, {
|
|
106
111
|
assertiveness: "polite",
|
|
107
112
|
batchId: "dropdown-empty-state",
|
|
108
113
|
delay: 300
|
|
109
114
|
});
|
|
110
|
-
}, [
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
},
|
|
115
|
+
}, [l.length, a, E, k?.length, ue]);
|
|
116
|
+
const Ae = (e, o = !1) => i ? g : o && R ? R : e?.[p] || g, Ke = () => {
|
|
117
|
+
B([]), t?.onClear?.();
|
|
118
|
+
}, me = (e, o = !1) => {
|
|
114
119
|
if (t?.renderOptionChip)
|
|
115
120
|
return t?.renderOptionChip(e, o);
|
|
116
|
-
if (
|
|
117
|
-
const f = s[0]?.[
|
|
121
|
+
if (i && s?.length > 0) {
|
|
122
|
+
const f = s[0]?.[p] || "", $ = s.length - 1;
|
|
118
123
|
return /* @__PURE__ */ n.createElement("div", {
|
|
119
124
|
className: "option-chip flex items-center w-full"
|
|
120
125
|
}, /* @__PURE__ */ n.createElement("div", {
|
|
121
|
-
className: `${
|
|
122
|
-
}, `${
|
|
126
|
+
className: `${$ > 0 ? "w-full" : "flex-1"} truncate`
|
|
127
|
+
}, `${g}: ${f}`), $ > 0 && /* @__PURE__ */ n.createElement("div", {
|
|
123
128
|
className: "flex-shrink-0"
|
|
124
|
-
}, "+",
|
|
129
|
+
}, "+", $));
|
|
125
130
|
}
|
|
126
|
-
const r =
|
|
131
|
+
const r = Ae(e, o), m = !!t?.label || !!t?.ariaLabelledBy, b = o && g && e?.[p] && !R && !m;
|
|
127
132
|
return /* @__PURE__ */ n.createElement("p", {
|
|
128
133
|
className: "option-chip flex flex-1 items-center justify-between"
|
|
129
|
-
},
|
|
130
|
-
},
|
|
134
|
+
}, b ? `${g}: ${r}` : r);
|
|
135
|
+
}, fe = (e) => /* @__PURE__ */ n.createElement("div", {
|
|
131
136
|
className: " w-full relative flex items-center border-b border-[var(--color-gray-300)]"
|
|
132
|
-
}, /* @__PURE__ */ n.createElement(
|
|
133
|
-
leftIcon:
|
|
137
|
+
}, /* @__PURE__ */ n.createElement(Me, {
|
|
138
|
+
leftIcon: Ne ? {
|
|
134
139
|
name: "search",
|
|
135
140
|
position: "left",
|
|
136
141
|
style: {
|
|
137
142
|
color: "var(--color-gray-500)"
|
|
138
143
|
}
|
|
139
144
|
} : void 0,
|
|
140
|
-
value:
|
|
141
|
-
onChange: (o) =>
|
|
142
|
-
placeholder:
|
|
145
|
+
value: E,
|
|
146
|
+
onChange: (o) => G(o),
|
|
147
|
+
placeholder: ne,
|
|
143
148
|
style: {
|
|
144
149
|
margin: 0,
|
|
145
150
|
gap: 0
|
|
@@ -150,45 +155,51 @@ const Ge = (t) => {
|
|
|
150
155
|
outline: "none"
|
|
151
156
|
},
|
|
152
157
|
automationId: "se-design-dropdown-search",
|
|
153
|
-
ariaLabel:
|
|
154
|
-
inputRef:
|
|
158
|
+
ariaLabel: ne,
|
|
159
|
+
inputRef: C,
|
|
155
160
|
inputProps: e
|
|
156
|
-
})),
|
|
157
|
-
...
|
|
158
|
-
onKeyDown: (e) =>
|
|
161
|
+
})), ge = () => fe(i ? {
|
|
162
|
+
...z,
|
|
163
|
+
onKeyDown: (e) => be(e, !0)
|
|
159
164
|
} : {
|
|
160
165
|
...L,
|
|
161
166
|
onKeyDown: (e) => {
|
|
162
167
|
L.onKeyDown(e), e.key === "Escape" && requestAnimationFrame(() => d.current?.focusTrigger());
|
|
163
168
|
}
|
|
164
|
-
}),
|
|
165
|
-
const r = e[
|
|
166
|
-
return /* @__PURE__ */ n.createElement("div",
|
|
169
|
+
}), ye = (e, o) => {
|
|
170
|
+
const r = e[p], m = s[0]?.[p] || g, b = u?.length ? e[u] == s[0]?.[u] : !0, f = Ce && r === m && b, $ = w === o, Be = i ? {} : ce(o, f);
|
|
171
|
+
return /* @__PURE__ */ n.createElement("div", y({
|
|
167
172
|
key: e.id || e.value,
|
|
168
|
-
className: `option break-words px-3 py-2 hover:bg-[var(--color-gray-100)] cursor-pointer select-none flex items-center justify-between ${f ? "selected" : ""} ${
|
|
169
|
-
onClick: () =>
|
|
170
|
-
onKeyDown: (
|
|
171
|
-
|
|
173
|
+
className: `option break-words px-3 py-2 hover:bg-[var(--color-gray-100)] cursor-pointer select-none flex items-center justify-between ${f ? "selected" : ""} ${$ ? `bg-[var(--color-gray-100)]${W ? " outline outline-[length:var(--focus-width)] -outline-offset-2 outline-[var(--focus-color)]" : ""}` : ""}`,
|
|
174
|
+
onClick: () => K(e),
|
|
175
|
+
onKeyDown: (F) => {
|
|
176
|
+
F.key === "Enter" || F.key === " " ? (F.preventDefault(), K(e)) : F.key === "Escape" && requestAnimationFrame(() => d.current?.focusTrigger());
|
|
172
177
|
},
|
|
173
178
|
tabIndex: -1,
|
|
174
179
|
"data-automation-id": `dropdown-option-${e?.automationId || o}`
|
|
175
|
-
},
|
|
180
|
+
}, Be, {
|
|
176
181
|
"aria-selected": f ? "true" : "false"
|
|
177
|
-
}),
|
|
182
|
+
}), me({
|
|
178
183
|
...e,
|
|
179
184
|
isOptionSelected: f
|
|
180
|
-
}, !1), f && /* @__PURE__ */ n.createElement(
|
|
185
|
+
}, !1), f && /* @__PURE__ */ n.createElement(we, {
|
|
181
186
|
name: "checkmark",
|
|
182
|
-
stroke:
|
|
187
|
+
stroke: ee
|
|
183
188
|
}));
|
|
184
|
-
},
|
|
189
|
+
}, O = (e, o, r) => /* @__PURE__ */ n.createElement("div", y({}, r ? {
|
|
190
|
+
id: `${D}-option-0`,
|
|
191
|
+
role: "option",
|
|
192
|
+
"aria-disabled": !0
|
|
193
|
+
} : ce(0, !1), {
|
|
194
|
+
className: `px-3 py-4 text-center text-[var(--color-gray-700)] text-sm${e === 0 ? ` bg-[var(--color-gray-100)]${o ? " outline outline-[length:var(--focus-width)] -outline-offset-2 outline-[var(--focus-color)]" : ""}` : ""}`
|
|
195
|
+
}), re), Le = () => /* @__PURE__ */ n.createElement(n.Fragment, null, t?.label && le && /* @__PURE__ */ n.createElement("div", {
|
|
185
196
|
"aria-hidden": "true",
|
|
186
197
|
className: "px-3 pt-2 pb-1 text-[var(--color-gray-650)] text-xs cursor-default select-none"
|
|
187
|
-
}, t.label),
|
|
188
|
-
className: `dropdown-content dropdown-options${
|
|
189
|
-
},
|
|
190
|
-
...
|
|
191
|
-
"aria-label": `${
|
|
198
|
+
}, t.label), c && ge(), /* @__PURE__ */ n.createElement("div", y({
|
|
199
|
+
className: `dropdown-content dropdown-options${c ? "" : " flex flex-col max-h-80 overflow-y-auto"}`
|
|
200
|
+
}, c ? {} : {
|
|
201
|
+
...U,
|
|
202
|
+
"aria-label": `${g} options`,
|
|
192
203
|
style: {
|
|
193
204
|
outline: "none"
|
|
194
205
|
},
|
|
@@ -196,48 +207,44 @@ const Ge = (t) => {
|
|
|
196
207
|
"aria-activedescendant": L["aria-activedescendant"],
|
|
197
208
|
onKeyDown: (e) => {
|
|
198
209
|
if (j.onKeyDownCapture?.(e), e.key === " ") {
|
|
199
|
-
e.preventDefault(),
|
|
210
|
+
e.preventDefault(), w >= 0 && l[w] && K(l[w]);
|
|
200
211
|
return;
|
|
201
212
|
}
|
|
202
213
|
L.onKeyDown(e);
|
|
203
214
|
},
|
|
204
215
|
onFocus: () => {
|
|
205
|
-
|
|
216
|
+
w === -1 && H.length > 0 && de(0);
|
|
206
217
|
}
|
|
207
|
-
}),
|
|
218
|
+
}), c ? /* @__PURE__ */ n.createElement("div", y({
|
|
208
219
|
className: "flex flex-col max-h-80 overflow-y-auto",
|
|
209
|
-
"aria-label": `${
|
|
210
|
-
},
|
|
211
|
-
className: "px-3 py-4 text-center text-[var(--color-gray-700)] text-sm"
|
|
212
|
-
}, C)) : a.length > 0 ? a.map((e, o) => ae(e, o)) : /* @__PURE__ */ n.createElement("div", {
|
|
213
|
-
className: "px-3 py-4 text-center text-[var(--color-gray-700)] text-sm"
|
|
214
|
-
}, C))), le = (e, o) => {
|
|
220
|
+
"aria-label": `${g} options`
|
|
221
|
+
}, U), l.length > 0 ? l.map((e, o) => ye(e, o)) : O(w, W, !1)) : l.length > 0 ? l.map((e, o) => ye(e, o)) : O(w, W, !1))), pe = (e, o) => {
|
|
215
222
|
let r = [];
|
|
216
|
-
e ? r = [...s, o] : r = s?.filter((m) => m[u] !== o[u]),
|
|
217
|
-
},
|
|
223
|
+
e ? r = [...s, o] : r = s?.filter((m) => m[u] !== o[u]), B(r);
|
|
224
|
+
}, Oe = () => {
|
|
218
225
|
d.current?.togglePopover(), d.current?.focusTrigger(), t?.onApply?.(s);
|
|
219
|
-
},
|
|
226
|
+
}, be = (e, o = !1) => {
|
|
220
227
|
if (!(o && e.key === " ")) {
|
|
221
228
|
if (e.key === "Enter" || e.key === " ") {
|
|
222
|
-
if (e.preventDefault(),
|
|
223
|
-
const r =
|
|
224
|
-
|
|
229
|
+
if (e.preventDefault(), S >= 0 && S < l.length) {
|
|
230
|
+
const r = l[S], m = s.some((b) => b[u] === r[u]);
|
|
231
|
+
pe(!m, r);
|
|
225
232
|
}
|
|
226
233
|
return;
|
|
227
234
|
}
|
|
228
|
-
|
|
235
|
+
z.onKeyDown(e), e.key === "Escape" && (e.stopPropagation(), requestAnimationFrame(() => d.current?.focusTrigger()));
|
|
229
236
|
}
|
|
230
|
-
},
|
|
231
|
-
const r = s.some((f) => f[u] === e[u]), m = `${
|
|
237
|
+
}, he = (e, o) => {
|
|
238
|
+
const r = s.some((f) => f[u] === e[u]), m = `${D}-option-${o}`, b = S === o;
|
|
232
239
|
return /* @__PURE__ */ n.createElement("div", {
|
|
233
240
|
key: e.id || e.value,
|
|
234
241
|
id: m,
|
|
235
242
|
role: "option",
|
|
236
243
|
"aria-selected": r,
|
|
237
|
-
className: `option px-3 py-2 hover:bg-[var(--color-gray-100)] cursor-pointer select-none flex items-center gap-2 ${
|
|
238
|
-
onClick: () =>
|
|
244
|
+
className: `option px-3 py-2 hover:bg-[var(--color-gray-100)] cursor-pointer select-none flex items-center gap-2 ${b ? `bg-[var(--color-gray-100)]${J ? " outline outline-[length:var(--focus-width)] -outline-offset-2 outline-[var(--focus-color)]" : ""}` : ""}`,
|
|
245
|
+
onClick: () => pe(!r, e),
|
|
239
246
|
"data-automation-id": `dropdown-option-${e?.automationId || o}`
|
|
240
|
-
}, /* @__PURE__ */ n.createElement(
|
|
247
|
+
}, /* @__PURE__ */ n.createElement(He, {
|
|
241
248
|
tabIndex: -1,
|
|
242
249
|
ariaHidden: !0,
|
|
243
250
|
checked: r,
|
|
@@ -247,35 +254,31 @@ const Ge = (t) => {
|
|
|
247
254
|
}), /* @__PURE__ */ n.createElement("span", {
|
|
248
255
|
className: "checkbox-label"
|
|
249
256
|
}, e?.label));
|
|
250
|
-
},
|
|
257
|
+
}, Fe = () => /* @__PURE__ */ n.createElement("div", {
|
|
251
258
|
onKeyDown: (e) => {
|
|
252
259
|
e.key === "Tab" && e.stopPropagation();
|
|
253
260
|
}
|
|
254
|
-
},
|
|
255
|
-
className: `dropdown-content dropdown-options${
|
|
256
|
-
},
|
|
257
|
-
...
|
|
258
|
-
"aria-label": `${
|
|
261
|
+
}, c && ge(), /* @__PURE__ */ n.createElement("div", y({
|
|
262
|
+
className: `dropdown-content dropdown-options${c ? "" : " flex flex-col max-h-80 overflow-y-auto"}`
|
|
263
|
+
}, c ? {} : {
|
|
264
|
+
...P,
|
|
265
|
+
"aria-label": `${g} options`,
|
|
259
266
|
"aria-multiselectable": "true",
|
|
260
267
|
style: {
|
|
261
268
|
outline: "none"
|
|
262
269
|
},
|
|
263
270
|
tabIndex: -1,
|
|
264
|
-
"aria-activedescendant":
|
|
265
|
-
onKeyDown: (e) =>
|
|
271
|
+
"aria-activedescendant": z["aria-activedescendant"],
|
|
272
|
+
onKeyDown: (e) => be(e, !1),
|
|
266
273
|
onFocus: () => {
|
|
267
|
-
|
|
274
|
+
S === -1 && M.length > 0 && Ve(0);
|
|
268
275
|
}
|
|
269
|
-
}),
|
|
276
|
+
}), c ? /* @__PURE__ */ n.createElement("div", y({
|
|
270
277
|
className: "flex flex-col max-h-80 overflow-y-auto"
|
|
271
|
-
},
|
|
272
|
-
"aria-label": `${
|
|
278
|
+
}, P, {
|
|
279
|
+
"aria-label": `${g} options`,
|
|
273
280
|
"aria-multiselectable": "true"
|
|
274
|
-
}),
|
|
275
|
-
className: "px-3 py-4 text-center text-[var(--color-gray-700)] text-sm"
|
|
276
|
-
}, C)) : a.length > 0 ? a.map((e, o) => ce(e, o)) : /* @__PURE__ */ n.createElement("div", {
|
|
277
|
-
className: "px-3 py-4 text-center text-[var(--color-gray-700)] text-sm"
|
|
278
|
-
}, C)), /* @__PURE__ */ n.createElement("div", {
|
|
281
|
+
}), l.length > 0 ? l.map((e, o) => he(e, o)) : O(S, J, !0)) : l.length > 0 ? l.map((e, o) => he(e, o)) : O(S, J, !0)), /* @__PURE__ */ n.createElement("div", {
|
|
279
282
|
className: "flex items-center justify-end gap-4 p-3 border-t border-[var(--color-gray-200)]",
|
|
280
283
|
onKeyDown: (e) => {
|
|
281
284
|
if (e.key === "ArrowDown" || e.key === "ArrowUp" || e.key === "Home" || e.key === "End") {
|
|
@@ -284,121 +287,121 @@ const Ge = (t) => {
|
|
|
284
287
|
}
|
|
285
288
|
if (e.key === "Tab" && !e.shiftKey) {
|
|
286
289
|
const o = e.currentTarget.querySelector('[data-automation-id="se-design-dropdown-apply-button"]');
|
|
287
|
-
if (document.activeElement === o && (e.stopPropagation(), d.current?.togglePopover(),
|
|
290
|
+
if (document.activeElement === o && (e.stopPropagation(), d.current?.togglePopover(), q)) {
|
|
288
291
|
e.preventDefault();
|
|
289
|
-
const r = d.current?.element, m =
|
|
292
|
+
const r = d.current?.element, m = Ue({
|
|
290
293
|
container: document.body,
|
|
291
294
|
filterHidden: !0
|
|
292
|
-
}),
|
|
295
|
+
}), b = r ? m.indexOf(r) : -1, f = m[b + 1];
|
|
293
296
|
f ? f.focus() : r?.focus();
|
|
294
297
|
}
|
|
295
|
-
} else e.key === "Tab" && e.shiftKey && (e.preventDefault(), e.stopPropagation(),
|
|
298
|
+
} else e.key === "Tab" && e.shiftKey && (e.preventDefault(), e.stopPropagation(), c ? C.current?.focus() : P.ref.current?.focus());
|
|
296
299
|
}
|
|
297
|
-
}, /* @__PURE__ */ n.createElement(
|
|
300
|
+
}, /* @__PURE__ */ n.createElement(Se, {
|
|
298
301
|
label: "Clear",
|
|
299
302
|
type: "link",
|
|
300
303
|
size: "sm",
|
|
301
|
-
onClick:
|
|
304
|
+
onClick: Ke,
|
|
302
305
|
automationId: "se-design-dropdown-clear-button"
|
|
303
|
-
}), /* @__PURE__ */ n.createElement(
|
|
306
|
+
}), /* @__PURE__ */ n.createElement(Se, {
|
|
304
307
|
label: "Apply",
|
|
305
308
|
type: "primary",
|
|
306
309
|
size: "sm",
|
|
307
|
-
onClick:
|
|
310
|
+
onClick: Oe,
|
|
308
311
|
automationId: "se-design-dropdown-apply-button"
|
|
309
|
-
}))),
|
|
310
|
-
const e =
|
|
312
|
+
}))), _e = () => {
|
|
313
|
+
const e = a ? "border-[var(--color-blue-500)]" : A ? "border-[var(--color-gray-300)]" : "border-[var(--color-gray-600)]", o = te ? "border-[var(--color-red-500)]" : "", r = `dropdown-src-element bg-[var(--color-white)] flex px-3 py-2 ${Pe ? "border-0" : `border rounded-md ${o || e}`} flex items-center ${De}`;
|
|
311
314
|
return /* @__PURE__ */ n.createElement("div", {
|
|
312
315
|
className: r
|
|
313
316
|
}, /* @__PURE__ */ n.createElement("div", {
|
|
314
|
-
id:
|
|
317
|
+
id: Z,
|
|
315
318
|
className: "flex-1 min-w-0",
|
|
316
319
|
"data-automation-id": t?.dropDownSelectAutomationId || "selected-dropdown-value"
|
|
317
|
-
},
|
|
320
|
+
}, me(s[0], !0)), /* @__PURE__ */ n.createElement("div", {
|
|
318
321
|
className: "flex-shrink-0 ml-2",
|
|
319
322
|
"aria-hidden": "true"
|
|
320
|
-
}, /* @__PURE__ */ n.createElement(
|
|
323
|
+
}, /* @__PURE__ */ n.createElement(we, {
|
|
321
324
|
name: "chevron",
|
|
322
|
-
rotation:
|
|
325
|
+
rotation: a ? "180" : "0",
|
|
323
326
|
className: "transition-transform",
|
|
324
|
-
stroke:
|
|
327
|
+
stroke: ee
|
|
325
328
|
})));
|
|
326
|
-
},
|
|
327
|
-
const e = s[0]?.[
|
|
328
|
-
return v && e ? `${v}, ${e}` : v ||
|
|
329
|
+
}, Te = () => {
|
|
330
|
+
const e = s[0]?.[p];
|
|
331
|
+
return v && e ? `${v}, ${e}` : v || g || "Select option";
|
|
329
332
|
};
|
|
330
333
|
return /* @__PURE__ */ n.createElement("div", {
|
|
331
334
|
className: `se-design-dropdown-container${t?.className ? ` ${t?.className}` : ""}`,
|
|
332
335
|
style: t?.style
|
|
333
336
|
}, t?.label ? /* @__PURE__ */ n.createElement("div", {
|
|
334
337
|
id: T,
|
|
335
|
-
className: `se-design-dropdown-label ${
|
|
338
|
+
className: `se-design-dropdown-label ${le ? "sr-only" : "mb-[3px] text-[var(--color-gray-700)] text-sm"}`
|
|
336
339
|
}, t?.label) : !t?.ariaLabelledBy && v ? /* @__PURE__ */ n.createElement("span", {
|
|
337
340
|
id: T,
|
|
338
341
|
className: "sr-only"
|
|
339
|
-
}, v) : null, /* @__PURE__ */ n.createElement("div",
|
|
342
|
+
}, v) : null, /* @__PURE__ */ n.createElement("div", y({
|
|
340
343
|
style: t?.style,
|
|
341
|
-
className: `${
|
|
342
|
-
},
|
|
344
|
+
className: `${A ? "bg-[var(--color-gray-50)] rounded-md cursor-not-allowed" : ""}`
|
|
345
|
+
}, i ? {
|
|
343
346
|
// Multi-select: only spread focus-tracking handlers for isKeyboardFocused.
|
|
344
347
|
// Dismiss is handled by Popover — don't spread onBlurCapture.
|
|
345
|
-
onPointerMove:
|
|
346
|
-
onPointerDown:
|
|
347
|
-
onPointerUp:
|
|
348
|
-
onFocusCapture:
|
|
348
|
+
onPointerMove: N.onPointerMove,
|
|
349
|
+
onPointerDown: N.onPointerDown,
|
|
350
|
+
onPointerUp: N.onPointerUp,
|
|
351
|
+
onFocusCapture: N.onFocusCapture,
|
|
349
352
|
onKeyDownCapture: (e) => {
|
|
350
|
-
if (e.key === "Escape" &&
|
|
351
|
-
const o =
|
|
353
|
+
if (e.key === "Escape" && a && (e.stopPropagation(), d.current?.focusTrigger()), (e.key === "ArrowDown" || e.key === "ArrowUp") && a) {
|
|
354
|
+
const o = c ? C.current : P.ref.current;
|
|
352
355
|
o && document.activeElement !== o && !o.contains(document.activeElement) && o.focus();
|
|
353
356
|
}
|
|
354
|
-
|
|
357
|
+
N.onKeyDownCapture?.(e);
|
|
355
358
|
}
|
|
356
359
|
} : {
|
|
357
360
|
...j,
|
|
358
361
|
onKeyDownCapture: (e) => {
|
|
359
|
-
(e.key === "Escape" || e.key === "Tab") &&
|
|
362
|
+
(e.key === "Escape" || e.key === "Tab") && a && (e.stopPropagation(), d.current?.focusTrigger()), j.onKeyDownCapture?.(e);
|
|
360
363
|
},
|
|
361
364
|
// Portal content lives in document.body — focus moving into it looks like "focus out" to
|
|
362
365
|
// the container's blur handler, causing immediate close. Suppress it; the Popover's own
|
|
363
366
|
// onBlur handler checks both source and portal content and handles dismissal correctly.
|
|
364
|
-
...
|
|
367
|
+
...q ? {
|
|
365
368
|
onBlurCapture: void 0
|
|
366
369
|
} : {}
|
|
367
|
-
}), /* @__PURE__ */ n.createElement(
|
|
370
|
+
}), /* @__PURE__ */ n.createElement(qe, y({
|
|
368
371
|
ref: d,
|
|
369
|
-
isPopoverOpen:
|
|
370
|
-
isWithPortal:
|
|
371
|
-
renderPopoverContents:
|
|
372
|
+
isPopoverOpen: a,
|
|
373
|
+
isWithPortal: q,
|
|
374
|
+
renderPopoverContents: oe || (i ? Fe : Le),
|
|
372
375
|
contentWidth: "full",
|
|
373
376
|
popoverContentStyleProperty: t.popoverContentStyleProperty,
|
|
374
377
|
renderPopoverSrcElement: t.renderSrcElement ? () => t.renderSrcElement({
|
|
375
|
-
isOpen:
|
|
378
|
+
isOpen: a,
|
|
376
379
|
selectedValue: s
|
|
377
|
-
}) :
|
|
380
|
+
}) : _e,
|
|
378
381
|
onPopoverToggle: (e) => {
|
|
379
|
-
if (
|
|
380
|
-
const o =
|
|
381
|
-
o >= 0 &&
|
|
382
|
+
if (V(e), e && !i && s.length > 0) {
|
|
383
|
+
const o = l.findIndex((r) => u ? r[u] === s[0]?.[u] : r[p] === s[0]?.[p]);
|
|
384
|
+
o >= 0 && de(o);
|
|
382
385
|
}
|
|
383
|
-
if (e && !
|
|
384
|
-
const o =
|
|
386
|
+
if (e && !c) {
|
|
387
|
+
const o = i ? P.ref : U.ref;
|
|
385
388
|
requestAnimationFrame(() => requestAnimationFrame(() => o.current?.focus()));
|
|
386
389
|
}
|
|
387
390
|
},
|
|
388
|
-
disabled:
|
|
391
|
+
disabled: A,
|
|
389
392
|
automationId: t?.dropDownSrcAutomationId,
|
|
390
393
|
popoverContentAutomationId: t?.dropDownContentAutomationId,
|
|
391
|
-
ariaLabelledBy: t?.label || t?.ariaLabelledBy || v ? [t?.label || !t?.ariaLabelledBy && v ? T : t?.ariaLabelledBy,
|
|
392
|
-
ariaLabel: !t?.label && !v && !t?.ariaLabelledBy ?
|
|
394
|
+
ariaLabelledBy: t?.label || t?.ariaLabelledBy || v ? [t?.label || !t?.ariaLabelledBy && v ? T : t?.ariaLabelledBy, Z].filter(Boolean).join(" ") : void 0,
|
|
395
|
+
ariaLabel: !t?.label && !v && !t?.ariaLabelledBy ? Te() : void 0,
|
|
393
396
|
sourceRole: "button",
|
|
394
397
|
"aria-haspopup": "listbox"
|
|
395
|
-
},
|
|
396
|
-
"aria-controls":
|
|
397
|
-
} : {}))),
|
|
398
|
+
}, a ? {
|
|
399
|
+
"aria-controls": D
|
|
400
|
+
} : {}))), te && /* @__PURE__ */ n.createElement("div", {
|
|
398
401
|
className: "text-[var(--color-red-500)] text-sm"
|
|
399
|
-
},
|
|
402
|
+
}, ke));
|
|
400
403
|
};
|
|
401
404
|
export {
|
|
402
|
-
|
|
405
|
+
rt as Dropdown
|
|
403
406
|
};
|
|
404
407
|
//# sourceMappingURL=index25.js.map
|