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