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