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