se-design 1.0.94 → 1.0.95

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/index39.js CHANGED
@@ -1,44 +1,46 @@
1
- import o, { forwardRef as Ce, useState as R, useRef as M, useCallback as U, useEffect as W, useImperativeHandle as De } from "react";
2
- import { Popover as $e } from "./index19.js";
1
+ import r, { forwardRef as Oe, useState as R, useRef as U, useCallback as W, useEffect as x, useImperativeHandle as Ie } from "react";
2
+ import { Popover as Ae } from "./index19.js";
3
3
  import { Icon as Te } from "./index6.js";
4
- import { Checkbox as Ie } from "./index24.js";
5
- import { Button as ee } from "./index4.js";
6
- import { getA11yNameAttributes as Oe } from "./index86.js";
4
+ import { Checkbox as Re } from "./index24.js";
5
+ import { Button as ne } from "./index4.js";
6
+ import { getA11yNameAttributes as Le } from "./index86.js";
7
7
  import "./index77.js";
8
- import { useCombobox as Ae } from "./index73.js";
9
- import { useStableId as te } from "./index212.js";
10
- import { announce as Re } from "./index80.js";
8
+ import { useCombobox as He } from "./index73.js";
9
+ import { useStableId as le } from "./index212.js";
10
+ import { announce as Ke } from "./index80.js";
11
11
  /* empty css */
12
12
  function d() {
13
13
  return d = Object.assign ? Object.assign.bind() : function(v) {
14
14
  for (var i = 1; i < arguments.length; i++) {
15
- var E = arguments[i];
16
- for (var k in E) ({}).hasOwnProperty.call(E, k) && (v[k] = E[k]);
15
+ var b = arguments[i];
16
+ for (var k in b) ({}).hasOwnProperty.call(b, k) && (v[k] = b[k]);
17
17
  }
18
18
  return v;
19
19
  }, d.apply(null, arguments);
20
20
  }
21
- const Ge = /* @__PURE__ */ Ce(({
21
+ const Qe = /* @__PURE__ */ Oe(({
22
22
  value: v,
23
23
  onChange: i,
24
- placeholder: E = "Type to search or add custom tags...",
24
+ placeholder: b = "Type to search or add custom tags...",
25
25
  className: k = "",
26
26
  options: g = [],
27
- renderOption: x,
27
+ renderOption: j,
28
28
  label: D,
29
- ariaLabel: ne,
29
+ ariaLabel: re,
30
30
  ariaLabelledBy: oe,
31
- ariaDescribedBy: le,
31
+ ariaDescribedBy: ae,
32
32
  automationId: c = "",
33
33
  noOptionsMessage: L = "No options found",
34
- allowCustomTags: j = !0,
35
- disabled: l = !1,
34
+ allowCustomTags: z = !0,
35
+ disabled: o = !1,
36
36
  type: H = "select",
37
- showInput: z = !0,
38
- displayTagBy: B = "label",
39
- isWithPortal: ae = !1
40
- }, re) => {
41
- const G = (e) => e.map((t) => {
37
+ showInput: B = !0,
38
+ displayTagBy: G = "label",
39
+ nonRemovableTags: K = [],
40
+ hideSelectedOptions: se = !1,
41
+ isWithPortal: ie = !1
42
+ }, ce) => {
43
+ const q = (e) => e.map((t) => {
42
44
  const n = g.find((s) => s.value === t);
43
45
  return n ? {
44
46
  label: n.label,
@@ -47,30 +49,30 @@ const Ge = /* @__PURE__ */ Ce(({
47
49
  label: t,
48
50
  value: t
49
51
  };
50
- }), [a, f] = R(() => G(v || [])), [r, y] = R(""), [K, se] = R(g), [u, p] = R(!1), ie = M(null), $ = M(null), T = M(!1), S = H === "multi-select-without-cta", m = H === "multi-select" || S, ce = te(c, "dropdown-input-tags-listbox"), q = te(c ? `${c}-label` : void 0, "dropdown-input-tags-label"), I = U((e) => {
51
- if (l) return;
52
- const t = [...a];
52
+ }), [l, f] = R(() => q(v || [])), [a, y] = R(""), [V, ue] = R(g), [u, p] = R(!1), pe = U(null), $ = U(null), O = U(!1), S = H === "multi-select-without-cta", m = H === "multi-select" || S, me = le(c, "dropdown-input-tags-listbox"), J = le(c ? `${c}-label` : void 0, "dropdown-input-tags-label"), I = W((e) => {
53
+ if (o) return;
54
+ const t = [...l];
53
55
  t.some((n) => n.value === e.value) || (t.push({
54
56
  label: e.label,
55
57
  value: e.value
56
58
  }), f(t), i?.(t.map((n) => n.value))), y(""), p(!1);
57
- }, [l, a, i]), V = U((e, t) => {
59
+ }, [o, l, i]), F = W((e, t) => {
58
60
  let n = [];
59
- e ? n = [...a, {
61
+ e ? n = [...l, {
60
62
  label: t.label,
61
63
  value: t.value
62
- }] : n = a.filter((s) => s.value !== t.value), f(n), y(""), S && (T.current = !0, i?.(n.map((s) => s.value)));
63
- }, [a, S, i]), O = "__add_custom_tag__", J = "__no_results__", ue = {
64
- id: J,
64
+ }] : n = l.filter((s) => s.value !== t.value), f(n), y(""), S && (O.current = !0, i?.(n.map((s) => s.value)));
65
+ }, [l, S, i]), A = "__add_custom_tag__", Q = "__no_results__", de = {
66
+ id: Q,
65
67
  label: L,
66
- value: J,
68
+ value: Q,
67
69
  __noResults: !0
68
- }, pe = (e) => !!e?.__noResults, Q = U((e) => {
69
- if (!l) {
70
- if (e.value === O) {
71
- const t = r.trim();
70
+ }, fe = (e) => !!e?.__noResults, X = W((e) => {
71
+ if (!o) {
72
+ if (e.value === A) {
73
+ const t = a.trim();
72
74
  if (!t) return;
73
- const n = [...a];
75
+ const n = [...l];
74
76
  n.some((s) => s.value === t) || (n.push({
75
77
  label: t,
76
78
  value: t
@@ -78,126 +80,126 @@ const Ge = /* @__PURE__ */ Ce(({
78
80
  return;
79
81
  }
80
82
  if (m) {
81
- const t = a.some((n) => n.value === e.value);
82
- V(!t, e);
83
+ const t = l.some((n) => n.value === e.value);
84
+ F(!t, e);
83
85
  } else
84
86
  I(e);
85
87
  }
86
- }, [l, m, a, r, i, V, I]), w = K.length > 0 ? K : j && r.trim() ? [{
87
- id: O,
88
- label: `Add "${r.trim()}"`,
89
- value: O
90
- }] : [], X = w.length === 0 && u ? [ue] : w, {
91
- containerProps: me,
92
- inputProps: Y,
93
- listboxProps: de,
88
+ }, [o, m, l, a, i, F, I]), Y = se ? V.filter((e) => !l.some((t) => t.value === e.value)) : V, w = Y.length > 0 ? Y : z && a.trim() ? [{
89
+ id: A,
90
+ label: `Add "${a.trim()}"`,
91
+ value: A
92
+ }] : [], Z = w.length === 0 && u ? [de] : w, {
93
+ containerProps: ge,
94
+ inputProps: ee,
95
+ listboxProps: he,
94
96
  getOptionProps: N,
95
97
  highlightedIndex: h,
96
- setHighlightedIndex: b,
97
- isKeyboardFocused: Z
98
- } = Ae({
99
- items: X,
98
+ setHighlightedIndex: E,
99
+ isKeyboardFocused: te
100
+ } = He({
101
+ items: Z,
100
102
  isOpen: u,
101
103
  onOpenChange: p,
102
- onSelect: Q,
103
- listboxId: ce,
104
- hasItems: X.length > 0,
104
+ onSelect: X,
105
+ listboxId: me,
106
+ hasItems: Z.length > 0,
105
107
  keepHighlightOnSelect: m,
106
108
  closeOnTab: H !== "multi-select",
107
- isItemDisabled: pe
108
- }), _ = (e) => e ? `highlighted${Z ? " keyboard-highlight" : ""}` : "";
109
- W(() => {
110
- if (T.current) {
111
- T.current = !1;
109
+ isItemDisabled: fe
110
+ }), _ = (e) => e ? `highlighted${te ? " keyboard-highlight" : ""}` : "";
111
+ x(() => {
112
+ if (O.current) {
113
+ O.current = !1;
112
114
  return;
113
115
  }
114
- f(G(v || []));
115
- }, [v, g, u]), W(() => {
116
- const e = g.filter((t) => t.label.toLowerCase().includes(r.toLowerCase()) || t.value.toLowerCase().includes(r.toLowerCase()));
117
- se(e);
118
- }, [r, g]), W(() => {
119
- u && w.length === 0 && r.trim() && h === -1 && Re(L, {
116
+ f(q(v || []));
117
+ }, [v, g, u]), x(() => {
118
+ const e = g.filter((t) => t.label.toLowerCase().includes(a.toLowerCase()) || t.value.toLowerCase().includes(a.toLowerCase()));
119
+ ue(e);
120
+ }, [a, g]), x(() => {
121
+ u && w.length === 0 && a.trim() && h === -1 && Ke(L, {
120
122
  assertiveness: "polite",
121
123
  batchId: "dropdown-input-tags-empty-state",
122
124
  delay: 300
123
125
  });
124
- }, [w.length, u, r, h]);
125
- const fe = (e) => {
126
- if (l) return;
127
- const t = a.filter((n, s) => s !== e);
126
+ }, [w.length, u, a, h]);
127
+ const ve = (e) => {
128
+ if (o || K.includes(l[e]?.value)) return;
129
+ const t = l.filter((n, s) => s !== e);
128
130
  f(t), (!m || S || m && !u) && i?.(t.map((n) => n.value));
129
- }, ge = (e) => {
130
- if (!l) {
131
- if (e.key === "Backspace" && r === "" && a.length > 0) {
132
- e.preventDefault();
133
- const t = a.slice(0, -1);
131
+ }, we = (e) => {
132
+ if (!o) {
133
+ if (e.key === "Backspace" && a === "" && l.length > 0) {
134
+ if (e.preventDefault(), K.includes(l[l.length - 1]?.value)) return;
135
+ const t = l.slice(0, -1);
134
136
  f(t), i?.(t.map((n) => n.value));
135
137
  return;
136
138
  }
137
- if (e.key === "Enter" && r.trim() && K.length === 0 && j) {
139
+ if (e.key === "Enter" && a.trim() && V.length === 0 && z) {
138
140
  e.preventDefault();
139
- const t = [...a];
140
- t.some((n) => n.value === r.trim()) || (t.push({
141
- label: r.trim(),
142
- value: r.trim()
143
- }), f(t), i?.(t.map((n) => n.value))), y(""), b(-1), p(!1);
141
+ const t = [...l];
142
+ t.some((n) => n.value === a.trim()) || (t.push({
143
+ label: a.trim(),
144
+ value: a.trim()
145
+ }), f(t), i?.(t.map((n) => n.value))), y(""), E(-1), p(!1);
144
146
  return;
145
147
  }
146
- Y.onKeyDown(e);
148
+ ee.onKeyDown(e);
147
149
  }
148
- }, he = (e) => {
149
- if (l) return;
150
+ }, Ee = (e) => {
151
+ if (o) return;
150
152
  const t = e.target.value;
151
- y(t), b(-1), t.trim() && !u && p(!0);
152
- }, ve = () => {
153
- l || (r.trim() || g.length > 0) && p(!0);
154
- }, we = (e) => {
155
- l || (e.stopPropagation(), $.current?.focus(), !u && (r.trim() || g.length > 0) && p(!0));
156
- }, be = (e) => {
157
- if (l) {
153
+ y(t), E(-1), t.trim() && !u && p(!0);
154
+ }, be = () => {
155
+ o || (a.trim() || g.length > 0) && p(!0);
156
+ }, ke = (e) => {
157
+ o || (e.stopPropagation(), $.current?.focus(), !u && (a.trim() || g.length > 0) && p(!0));
158
+ }, ye = (e) => {
159
+ if (o) {
158
160
  e.preventDefault(), e.stopPropagation();
159
161
  return;
160
162
  }
161
163
  e.target.closest(".input-with-tags-container") && e.stopPropagation();
162
- }, Ee = () => {
163
- l || p(!u);
164
+ }, Se = () => {
165
+ o || p(!u);
164
166
  };
165
- De(re, () => ({
166
- toggleDropdown: Ee
167
+ Ie(ce, () => ({
168
+ toggleDropdown: Se
167
169
  }), []);
168
- const ke = (e, t, n, s) => {
169
- const P = a.some((C) => C.value === e.value), A = h === t, F = N(t, P);
170
- return /* @__PURE__ */ o.createElement("div", d({
170
+ const Ne = (e, t, n, s) => {
171
+ const P = l.some((C) => C.value === e.value), T = h === t, M = N(t, P);
172
+ return /* @__PURE__ */ r.createElement("div", d({
171
173
  key: e.id
172
- }, F, {
173
- className: `dropdown-with-input-tags-option ${_(A)}`,
174
+ }, M, {
175
+ className: `dropdown-with-input-tags-option ${_(T)}`,
174
176
  onClick: () => !s && n(e),
175
- onMouseEnter: () => b(t),
177
+ onMouseEnter: () => E(t),
176
178
  "data-automation-id": `${c}-option-${e.id}`
177
- }), /* @__PURE__ */ o.createElement("span", {
179
+ }), /* @__PURE__ */ r.createElement("span", {
178
180
  className: "option-label"
179
- }, e.label), e.value !== e.label && /* @__PURE__ */ o.createElement("span", {
181
+ }, e.label), e.value !== e.label && /* @__PURE__ */ r.createElement("span", {
180
182
  className: "option-value"
181
183
  }, e.value));
182
- }, ye = () => {
183
- T.current = !0;
184
- const e = a.map((t) => t.value);
184
+ }, _e = () => {
185
+ O.current = !0;
186
+ const e = l.map((t) => t.value);
185
187
  i?.(e), p(!1);
186
- }, Se = () => {
188
+ }, Pe = () => {
187
189
  f([]);
188
- }, Ne = (e, t) => {
189
- const n = a.some((A) => A.value === e.value), s = h === t, P = N(t, n);
190
- return /* @__PURE__ */ o.createElement("div", d({
190
+ }, Ce = (e, t) => {
191
+ const n = l.some((T) => T.value === e.value), s = h === t, P = N(t, n);
192
+ return /* @__PURE__ */ r.createElement("div", d({
191
193
  key: e.id
192
194
  }, P, {
193
195
  className: `dropdown-with-input-tags-option dropdown-with-input-tags-multi-select-option ${_(s)}`,
194
196
  "aria-checked": n,
195
197
  onClick: () => {
196
- l || (V(!n, e), $.current?.focus());
198
+ o || (F(!n, e), $.current?.focus());
197
199
  },
198
- onMouseEnter: () => b(t),
200
+ onMouseEnter: () => E(t),
199
201
  "data-automation-id": `${c}-option-${e.id}`
200
- }), /* @__PURE__ */ o.createElement(Ie, {
202
+ }), /* @__PURE__ */ r.createElement(Re, {
201
203
  automationId: "checkbox",
202
204
  className: "checkbox",
203
205
  checked: n,
@@ -206,113 +208,113 @@ const Ge = /* @__PURE__ */ Ce(({
206
208
  label: e.label,
207
209
  tabIndex: -1
208
210
  }));
209
- }, _e = () => /* @__PURE__ */ o.createElement("div", {
211
+ }, De = () => /* @__PURE__ */ r.createElement("div", {
210
212
  className: "dropdown-with-input-tags-ctas-container",
211
213
  onKeyDown: (e) => {
212
214
  (e.key === "ArrowDown" || e.key === "ArrowUp" || e.key === "Home" || e.key === "End") && e.stopPropagation();
213
215
  }
214
- }, /* @__PURE__ */ o.createElement(ee, {
216
+ }, /* @__PURE__ */ r.createElement(ne, {
215
217
  label: "Clear",
216
218
  type: "link",
217
219
  size: "sm",
218
- onClick: Se,
220
+ onClick: Pe,
219
221
  automationId: `${c}-clear-button`
220
- }), /* @__PURE__ */ o.createElement(ee, {
222
+ }), /* @__PURE__ */ r.createElement(ne, {
221
223
  label: "Apply",
222
224
  type: "primary",
223
225
  size: "sm",
224
- onClick: ye,
226
+ onClick: _e,
225
227
  automationId: `${c}-apply-button`
226
228
  }));
227
- return /* @__PURE__ */ o.createElement("div", d({
228
- className: `dropdown-with-input-tags-wrapper ${k} ${l ? "disabled-wrapper" : ""}`,
229
+ return /* @__PURE__ */ r.createElement("div", d({
230
+ className: `dropdown-with-input-tags-wrapper ${k} ${o ? "disabled-wrapper" : ""}`,
229
231
  "data-automation-id": c
230
- }, me), D && /* @__PURE__ */ o.createElement("label", {
231
- id: q,
232
+ }, ge), D && /* @__PURE__ */ r.createElement("label", {
233
+ id: J,
232
234
  className: "dropdown-with-input-tags-label"
233
- }, D), /* @__PURE__ */ o.createElement("div", {
234
- onClick: be
235
- }, /* @__PURE__ */ o.createElement($e, {
236
- ref: ie,
235
+ }, D), /* @__PURE__ */ r.createElement("div", {
236
+ onClick: ye
237
+ }, /* @__PURE__ */ r.createElement(Ae, {
238
+ ref: pe,
237
239
  className: "dropdown-with-input-tags-popover",
238
240
  contentWidth: "full",
239
241
  position: "bottom-left",
240
- isPopoverOpen: !l && u,
241
- onPopoverToggle: l ? () => {
242
+ isPopoverOpen: !o && u,
243
+ onPopoverToggle: o ? () => {
242
244
  } : p,
243
245
  disableClickToggle: !0,
244
- isWithPortal: ae,
246
+ isWithPortal: ie,
245
247
  renderPopoverContents: ({
246
248
  closePopoverCb: e
247
- }) => /* @__PURE__ */ o.createElement(o.Fragment, null, /* @__PURE__ */ o.createElement("div", d({}, de, {
249
+ }) => /* @__PURE__ */ r.createElement(r.Fragment, null, /* @__PURE__ */ r.createElement("div", d({}, he, {
248
250
  className: "dropdown-with-input-tags-content"
249
251
  }, m && {
250
252
  "aria-multiselectable": "true"
251
253
  }), w.length > 0 ? w.map((t, n) => {
252
- if (t.value === O) {
253
- const C = h === n, Pe = N(n, !1);
254
- return /* @__PURE__ */ o.createElement("div", d({
254
+ if (t.value === A) {
255
+ const C = h === n, $e = N(n, !1);
256
+ return /* @__PURE__ */ r.createElement("div", d({
255
257
  key: t.id
256
- }, Pe, {
258
+ }, $e, {
257
259
  className: `dropdown-with-input-tags-option dropdown-with-input-tags-custom-option ${_(C)}`,
258
260
  onClick: () => {
259
- l || (Q(t), e());
261
+ o || (X(t), e());
260
262
  },
261
- onMouseEnter: () => b(n)
262
- }), 'Add "', r.trim(), '"');
263
+ onMouseEnter: () => E(n)
264
+ }), 'Add "', a.trim(), '"');
263
265
  }
264
266
  if (m)
265
- return Ne(t, n);
266
- const s = a.some((C) => C.value === t.value), P = h === n, F = {
267
+ return Ce(t, n);
268
+ const s = l.some((C) => C.value === t.value), P = h === n, M = {
267
269
  ...N(n, s),
268
- onMouseEnter: () => b(n),
270
+ onMouseEnter: () => E(n),
269
271
  className: `dropdown-with-input-tags-option ${_(P)}`
270
272
  };
271
- return x ? x(t, F, I) : ke(t, n, I, l);
272
- }) : /* @__PURE__ */ o.createElement("div", d({}, N(0, !1), {
273
+ return j ? j(t, M, I) : Ne(t, n, I, o);
274
+ }) : /* @__PURE__ */ r.createElement("div", d({}, N(0, !1), {
273
275
  className: `dropdown-with-input-tags-no-options ${_(h === 0)}`
274
- }), /* @__PURE__ */ o.createElement("div", {
276
+ }), /* @__PURE__ */ r.createElement("div", {
275
277
  className: "dropdown-with-input-tags-no-options-text"
276
- }, L))), m && !S && _e()),
277
- renderPopoverSrcElement: () => /* @__PURE__ */ o.createElement("div", {
278
+ }, L))), m && !S && De()),
279
+ renderPopoverSrcElement: () => /* @__PURE__ */ r.createElement("div", {
278
280
  className: "dropdown-with-input-tags-input-container"
279
- }, /* @__PURE__ */ o.createElement("div", {
280
- className: `input-with-tags-container ${l ? "disabled-input-with-tags-container" : ""} ${Z ? "keyboard-focused" : ""}`,
281
- onClick: we,
281
+ }, /* @__PURE__ */ r.createElement("div", {
282
+ className: `input-with-tags-container ${o ? "disabled-input-with-tags-container" : ""} ${te ? "keyboard-focused" : ""}`,
283
+ onClick: ke,
282
284
  onKeyDown: (e) => {
283
285
  e.key.length === 1 && !e.ctrlKey && !e.metaKey && !e.altKey && $.current?.focus();
284
286
  }
285
- }, a.map((e, t) => /* @__PURE__ */ o.createElement("span", {
287
+ }, l.map((e, t) => /* @__PURE__ */ r.createElement("span", {
286
288
  key: t,
287
289
  className: "tag-in-inputwithtags"
288
- }, e[B], !l && /* @__PURE__ */ o.createElement(Te, {
290
+ }, e[G], !o && !K.includes(e.value) && /* @__PURE__ */ r.createElement(Te, {
289
291
  name: "close",
290
292
  className: "close-icon-in-inputwithtags",
291
- ariaLabel: `Remove tag ${e[B]}`,
292
- onClick: () => fe(t),
293
+ ariaLabel: `Remove tag ${e[G]}`,
294
+ onClick: () => ve(t),
293
295
  shouldStopPropagation: !0
294
- }))), (z || !a.length || m) && /* @__PURE__ */ o.createElement("input", d({
296
+ }))), (B || !l.length || m) && /* @__PURE__ */ r.createElement("input", d({
295
297
  ref: $
296
- }, Y, {
298
+ }, ee, {
297
299
  type: "text",
298
- value: r,
299
- onChange: he,
300
- onKeyDown: ge,
301
- onFocus: ve,
302
- placeholder: a.length === 0 ? E : "",
303
- className: `input-with-tags-input${!z && a.length > 0 && !r ? " sr-only" : ""}`,
304
- disabled: l
305
- }, Oe({
306
- ariaLabel: ne || (D ? void 0 : "Search and select options"),
300
+ value: a,
301
+ onChange: Ee,
302
+ onKeyDown: we,
303
+ onFocus: be,
304
+ placeholder: l.length === 0 ? b : "",
305
+ className: `input-with-tags-input${!B && l.length > 0 && !a ? " sr-only" : ""}`,
306
+ disabled: o
307
+ }, Le({
308
+ ariaLabel: re || (D ? void 0 : "Search and select options"),
307
309
  ariaLabelledBy: oe,
308
- internalLabelId: D ? q : void 0,
309
- ariaDescribedBy: le
310
+ internalLabelId: D ? J : void 0,
311
+ ariaDescribedBy: ae
310
312
  }))))),
311
313
  automationId: c,
312
314
  popoverContentAutomationId: `${c}-content`
313
315
  })));
314
316
  });
315
317
  export {
316
- Ge as DropdownWithInputTags
318
+ Qe as DropdownWithInputTags
317
319
  };
318
320
  //# sourceMappingURL=index39.js.map