@purpur/library 9.1.2 → 9.1.3

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.
@@ -1,771 +0,0 @@
1
- import { jsxs as M, jsx as a, Fragment as he } from "react/jsx-runtime";
2
- import { useState as le, forwardRef as _e, useId as ue, useRef as Z, useCallback as fe, useEffect as Oe } from "react";
3
- import { L as ee } from "./listbox-DG4KmQP_.mjs";
4
- import { e as De } from "./use-autocomplete.es-CVv3z8t6.mjs";
5
- import { C as ke } from "./checkbox-D6qWgpWR.mjs";
6
- import { a as ge } from "./dismissable-chip-group-D-gD93ON.mjs";
7
- import { F as Re } from "./field-error-text-CBSX8dGx.mjs";
8
- import { F as Ne } from "./field-helper-text-C5ee4SFV.mjs";
9
- import { r as Se } from "./check-circle-filled.es-umBwOv5_.mjs";
10
- import { l as Le } from "./chevron-down.es-PCIIj6oG.mjs";
11
- import { L as Te } from "./label-7sJe5-pX.mjs";
12
- import { a as Be } from "./spinner-DRQN6YdK.mjs";
13
- import { c as Ee } from "./bind-CU-R61T-.mjs";
14
- const Fe = {
15
- "purpur-dropdown": "_purpur-dropdown_1fi2v_1",
16
- "purpur-dropdown--negative": "_purpur-dropdown--negative_1fi2v_11",
17
- "purpur-dropdown__label": "_purpur-dropdown__label_1fi2v_14",
18
- "purpur-dropdown__field-row": "_purpur-dropdown__field-row_1fi2v_19",
19
- "purpur-dropdown__frame": "_purpur-dropdown__frame_1fi2v_23",
20
- "purpur-dropdown__frame--negative": "_purpur-dropdown__frame--negative_1fi2v_30",
21
- "purpur-dropdown__trigger-container": "_purpur-dropdown__trigger-container_1fi2v_33",
22
- "purpur-dropdown__chip-group": "_purpur-dropdown__chip-group_1fi2v_44",
23
- "purpur-dropdown__trigger-container--has-tags": "_purpur-dropdown__trigger-container--has-tags_1fi2v_49",
24
- "purpur-dropdown__trigger-container--disabled": "_purpur-dropdown__trigger-container--disabled_1fi2v_52",
25
- "purpur-dropdown__trigger-container--readonly": "_purpur-dropdown__trigger-container--readonly_1fi2v_52",
26
- "purpur-dropdown__trigger-container--negative": "_purpur-dropdown__trigger-container--negative_1fi2v_59",
27
- "purpur-dropdown__trigger-container--error": "_purpur-dropdown__trigger-container--error_1fi2v_62",
28
- "purpur-dropdown__trigger-container--is-valid": "_purpur-dropdown__trigger-container--is-valid_1fi2v_65",
29
- "purpur-dropdown__input": "_purpur-dropdown__input_1fi2v_68",
30
- "purpur-dropdown__trigger": "_purpur-dropdown__trigger_1fi2v_33",
31
- "purpur-dropdown__trigger--placeholder": "_purpur-dropdown__trigger--placeholder_1fi2v_109",
32
- "purpur-dropdown__trigger--is-valid": "_purpur-dropdown__trigger--is-valid_1fi2v_112",
33
- "purpur-dropdown__trigger--disabled": "_purpur-dropdown__trigger--disabled_1fi2v_115",
34
- "purpur-dropdown__trigger--readonly": "_purpur-dropdown__trigger--readonly_1fi2v_119",
35
- "purpur-dropdown__trigger--negative": "_purpur-dropdown__trigger--negative_1fi2v_123",
36
- "purpur-dropdown__trigger-text": "_purpur-dropdown__trigger-text_1fi2v_136",
37
- "purpur-dropdown__combobox-container": "_purpur-dropdown__combobox-container_1fi2v_142",
38
- "purpur-dropdown__combobox-container--disabled": "_purpur-dropdown__combobox-container--disabled_1fi2v_152",
39
- "purpur-dropdown__combobox-container--readonly": "_purpur-dropdown__combobox-container--readonly_1fi2v_159",
40
- "purpur-dropdown__combobox-container--error": "_purpur-dropdown__combobox-container--error_1fi2v_166",
41
- "purpur-dropdown__combobox-container--is-valid": "_purpur-dropdown__combobox-container--is-valid_1fi2v_169",
42
- "purpur-dropdown__combobox-container--negative": "_purpur-dropdown__combobox-container--negative_1fi2v_172",
43
- "purpur-dropdown__input--negative": "_purpur-dropdown__input--negative_1fi2v_211",
44
- "purpur-dropdown__chip-group--select": "_purpur-dropdown__chip-group--select_1fi2v_228",
45
- "purpur-dropdown__end-adornments": "_purpur-dropdown__end-adornments_1fi2v_231",
46
- "purpur-dropdown__chevron-icon": "_purpur-dropdown__chevron-icon_1fi2v_242",
47
- "purpur-dropdown__chevron-icon--open": "_purpur-dropdown__chevron-icon--open_1fi2v_247",
48
- "purpur-dropdown__chevron-icon--disabled": "_purpur-dropdown__chevron-icon--disabled_1fi2v_250",
49
- "purpur-dropdown__chevron-icon--readonly": "_purpur-dropdown__chevron-icon--readonly_1fi2v_253",
50
- "purpur-dropdown__chevron-icon--negative": "_purpur-dropdown__chevron-icon--negative_1fi2v_256",
51
- "purpur-dropdown__valid-icon": "_purpur-dropdown__valid-icon_1fi2v_259",
52
- "purpur-dropdown__listbox": "_purpur-dropdown__listbox_1fi2v_262",
53
- "purpur-dropdown__checkbox-item-multiple": "_purpur-dropdown__checkbox-item-multiple_1fi2v_272",
54
- "purpur-dropdown__checkbox-container": "_purpur-dropdown__checkbox-container_1fi2v_275"
55
- }, h = Ee.bind(Fe), o = "purpur-dropdown", be = ({
56
- fieldId: r,
57
- htmlForSuffix: t,
58
- label: i,
59
- getTestId: s,
60
- disabled: d,
61
- negative: n,
62
- required: g
63
- }) => i ? /* @__PURE__ */ M(
64
- Te,
65
- {
66
- htmlFor: t ? `${r}-${t}` : r,
67
- className: h(`${o}__label`),
68
- "data-testid": s("label"),
69
- disabled: d,
70
- negative: n,
71
- children: [
72
- g && /* @__PURE__ */ a("span", { "aria-hidden": !0, children: "*" }),
73
- i
74
- ]
75
- }
76
- ) : null, ve = ({
77
- getTestId: r,
78
- loading: t,
79
- disabled: i,
80
- negative: s,
81
- isValid: d,
82
- isOpen: n,
83
- readOnly: g,
84
- showChevronOpen: $
85
- }) => /* @__PURE__ */ a("span", { className: h(`${o}__end-adornments`), children: t ? /* @__PURE__ */ a(
86
- Be,
87
- {
88
- disabled: i,
89
- size: "xxs",
90
- negative: s,
91
- "data-testid": r("spinner")
92
- }
93
- ) : /* @__PURE__ */ M(he, { children: [
94
- d && /* @__PURE__ */ a(
95
- Se,
96
- {
97
- "data-testid": r("valid-icon"),
98
- className: h(`${o}__valid-icon`)
99
- }
100
- ),
101
- /* @__PURE__ */ a(
102
- Le,
103
- {
104
- className: h(`${o}__chevron-icon`, {
105
- [`${o}__chevron-icon--open`]: $ && n,
106
- [`${o}__chevron-icon--disabled`]: i,
107
- [`${o}__chevron-icon--readonly`]: g && !i,
108
- [`${o}__chevron-icon--is-valid`]: d,
109
- [`${o}__chevron-icon--negative`]: s
110
- }),
111
- "data-testid": r("dropdown-icon"),
112
- size: "sm"
113
- }
114
- )
115
- ] }) }), me = ({
116
- selectedItems: r,
117
- getTestId: t,
118
- disabled: i,
119
- onRemove: s,
120
- isSelect: d
121
- }) => r.length ? /* @__PURE__ */ a(
122
- ge,
123
- {
124
- className: h(`${o}__chip-group`, {
125
- [`${o}__chip-group--select`]: d
126
- }),
127
- "data-testid": t("tags"),
128
- size: "sm",
129
- children: r.map((n) => /* @__PURE__ */ a(
130
- ge.Item,
131
- {
132
- id: n.id,
133
- "data-testid": t(`tag-${n.id}`),
134
- "aria-label": `Remove ${n.label}`,
135
- onDismiss: () => {
136
- s(n);
137
- },
138
- disabled: i,
139
- children: n.label
140
- },
141
- n.id
142
- ))
143
- }
144
- ) : null, we = ({
145
- errorText: r,
146
- helperText: t,
147
- helperTextId: i,
148
- negative: s
149
- }) => /* @__PURE__ */ M(he, { children: [
150
- r && /* @__PURE__ */ a(Re, { negative: s, children: r }),
151
- t && !r && /* @__PURE__ */ a(Ne, { id: i, negative: s, children: t })
152
- ] }), xe = ({
153
- optionsToShow: r,
154
- getListboxItemProps: t,
155
- multiple: i,
156
- fieldId: s,
157
- noOptionsText: d
158
- }) => d !== void 0 && !r.length ? /* @__PURE__ */ a(ee.Item, { noninteractive: !0, children: d }) : r.map((n, g) => {
159
- const { key: $, selected: x, ...u } = t(n, g);
160
- return i ? /* @__PURE__ */ a(
161
- ee.Item,
162
- {
163
- ...u,
164
- className: h(`${o}__checkbox-item-multiple`),
165
- selected: !!x,
166
- hideSelectedIcon: !0,
167
- children: /* @__PURE__ */ M("span", { className: h(`${o}__checkbox-container`), children: [
168
- /* @__PURE__ */ a(ke, { id: `${s}-checkbox-${n.id}`, checked: !!x, "aria-hidden": !0 }),
169
- n.label
170
- ] })
171
- },
172
- $
173
- ) : /* @__PURE__ */ a(ee.Item, { ...u, selected: !!x, children: n.label }, $);
174
- }), Ae = (r, t, i) => {
175
- if (i)
176
- return r.filter((d) => i(t, d));
177
- if (!t) return r;
178
- const s = t.toUpperCase().split(" ");
179
- return r.filter(
180
- (d) => s.every((n) => (d.value || d.label).toUpperCase().includes(n))
181
- );
182
- }, ye = ({
183
- options: r,
184
- searchTerm: t,
185
- filterOption: i,
186
- selectedOption: s,
187
- multiple: d
188
- }) => !d && s && s.label === t ? r : Ae(r, t, i), $e = ({
189
- controlledInputValue: r,
190
- defaultInputValue: t,
191
- selectedOption: i,
192
- onInputChange: s
193
- }) => {
194
- const [d, n] = le(
195
- (typeof r == "string" ? r : t ?? i?.label) ?? ""
196
- );
197
- return {
198
- displayInputValue: typeof r == "string" ? r : d,
199
- populateInputField: (x) => {
200
- s?.(x), n(x);
201
- }
202
- };
203
- }, Ie = _e((r, t) => {
204
- const {
205
- id: i,
206
- label: s,
207
- options: d,
208
- className: n,
209
- errorText: g,
210
- helperText: $,
211
- placeholder: x,
212
- negative: u = !1,
213
- readOnly: S = !1,
214
- disabled: f = !1,
215
- required: l = !1,
216
- valid: I,
217
- loading: b,
218
- multiple: c = !1,
219
- selectedOption: _,
220
- selectedOptions: E = [],
221
- onSelect: F,
222
- openOnFocus: C = !1,
223
- listboxMaxHeight: j,
224
- listboxLabel: q,
225
- filterOption: K,
226
- inputValue: A,
227
- defaultInputValue: p,
228
- onInputChange: V,
229
- noOptionsText: L,
230
- highlightFirstOption: T = !1,
231
- ["data-testid"]: P
232
- } = r, D = ue(), m = i ?? D, k = (e) => P ? `${P}-${e}` : void 0, H = !!I && !g, y = `${m}-helper-text`, v = c ? E : _ ? [_] : [], { displayInputValue: R, populateInputField: U } = $e({
233
- controlledInputValue: A,
234
- defaultInputValue: p,
235
- selectedOption: _,
236
- onInputChange: V
237
- }), Y = ye({
238
- options: d,
239
- searchTerm: R,
240
- filterOption: K,
241
- selectedOption: _,
242
- multiple: c
243
- }), G = (e) => {
244
- if (c) {
245
- const B = v.some((w) => w.id === e.id) ? v.filter((w) => w.id !== e.id) : [...v, e];
246
- F?.(e, B), U("");
247
- } else
248
- F?.(e, [e]), U(e.label);
249
- }, {
250
- rootRef: W,
251
- inputRef: J,
252
- inputProps: O,
253
- listboxProps: Q,
254
- getListboxItemProps: X,
255
- isOpen: z,
256
- openListbox: re,
257
- anchorStyle: oe
258
- } = De({
259
- id: m,
260
- options: Y,
261
- listboxLabel: q || s || "Options",
262
- selectedOption: c ? void 0 : _,
263
- disabled: f,
264
- readOnly: S,
265
- openOnFocus: C,
266
- listboxMaxHeight: j,
267
- highlightFirstOption: T,
268
- closeOnSelect: !c,
269
- noOptionsText: L,
270
- onSelect: G,
271
- "data-testid": P
272
- }), te = (e) => {
273
- W.current = e, typeof t == "function" ? t(e) : t && (t.current = e);
274
- }, de = (e, N) => {
275
- const B = X(e, N);
276
- if (c) {
277
- const w = v.some((ce) => ce.id === e.id);
278
- return { ...B, selected: w, "aria-selected": w };
279
- }
280
- return B;
281
- }, ne = (e) => {
282
- const N = v.filter((B) => B.id !== e.id);
283
- F?.(e, N);
284
- }, se = (e) => {
285
- c && e.key === "Backspace" && e.currentTarget.value === "" && v.length > 0 && ne(v[v.length - 1]), O?.onKeyDown?.(e);
286
- }, ae = (e) => {
287
- U(e.target.value), z || re();
288
- }, pe = h(o, n, {
289
- [`${o}--negative`]: u
290
- });
291
- return /* @__PURE__ */ M("div", { ref: te, className: pe, children: [
292
- /* @__PURE__ */ a(
293
- be,
294
- {
295
- fieldId: m,
296
- htmlForSuffix: "input",
297
- label: s,
298
- getTestId: k,
299
- disabled: f,
300
- negative: u,
301
- required: l
302
- }
303
- ),
304
- /* @__PURE__ */ a("div", { className: h(`${o}__field-row`), children: /* @__PURE__ */ M(
305
- "div",
306
- {
307
- className: h(`${o}__combobox-container`, {
308
- [`${o}__combobox-container--error`]: !!g,
309
- [`${o}__combobox-container--is-valid`]: H,
310
- [`${o}__combobox-container--negative`]: u,
311
- [`${o}__combobox-container--disabled`]: f,
312
- [`${o}__combobox-container--readonly`]: S && !f
313
- }),
314
- style: oe,
315
- children: [
316
- c && /* @__PURE__ */ a(
317
- me,
318
- {
319
- selectedItems: v,
320
- getTestId: k,
321
- disabled: f,
322
- onRemove: ne
323
- }
324
- ),
325
- /* @__PURE__ */ a(
326
- "input",
327
- {
328
- ...O,
329
- ref: J,
330
- id: `${m}-input`,
331
- "data-testid": k("input"),
332
- onKeyDown: se,
333
- onChange: ae,
334
- value: R,
335
- placeholder: x,
336
- className: h(`${o}__input`, {
337
- [`${o}__input--negative`]: u
338
- }),
339
- "aria-describedby": y,
340
- "aria-invalid": !!g,
341
- disabled: f,
342
- readOnly: S
343
- }
344
- ),
345
- /* @__PURE__ */ a(
346
- ve,
347
- {
348
- getTestId: k,
349
- loading: b,
350
- disabled: f,
351
- negative: u,
352
- isValid: H,
353
- isOpen: z,
354
- showChevronOpen: !0
355
- }
356
- ),
357
- /* @__PURE__ */ a(
358
- "span",
359
- {
360
- className: h(`${o}__frame`, {
361
- [`${o}__frame--negative`]: u
362
- })
363
- }
364
- )
365
- ]
366
- }
367
- ) }),
368
- z && /* @__PURE__ */ a(ee, { ...Q, className: h(`${o}__listbox`), children: xe({
369
- optionsToShow: Y,
370
- getListboxItemProps: de,
371
- multiple: c,
372
- fieldId: m,
373
- noOptionsText: L
374
- }) }),
375
- /* @__PURE__ */ a(
376
- we,
377
- {
378
- errorText: g,
379
- helperText: $,
380
- helperTextId: y,
381
- negative: u
382
- }
383
- )
384
- ] });
385
- });
386
- Ie.displayName = "DropdownCombobox";
387
- const Pe = ({
388
- options: r,
389
- highlightFirstOption: t
390
- }) => {
391
- const i = Z(null), s = Z({}), [d, n] = le(
392
- t ? r[0] : void 0
393
- ), g = (l) => {
394
- if (l) {
395
- const I = l.getBoundingClientRect(), b = i.current?.getBoundingClientRect() || { top: 0, bottom: 0 };
396
- (I.top < b.top || I.bottom > b.bottom) && l.scrollIntoView({ block: "nearest" });
397
- }
398
- };
399
- return {
400
- highlightedOption: d,
401
- listboxRef: i,
402
- optionRefs: s,
403
- findNextOption: (l, I) => {
404
- const b = I.filter((_) => !_.disabled);
405
- if (!b.length) return;
406
- const c = d ? b.findIndex((_) => _.id === d.id) : -1;
407
- return l === "ArrowDown" ? b[(c + 1) % b.length] : b[(c - 1 + b.length) % b.length];
408
- },
409
- highlightOption: (l) => {
410
- n(l ? { ...l } : void 0), l && g(s.current[l.id]);
411
- },
412
- highlightByClick: (l) => {
413
- l.id !== d?.id && n({ ...l, isSetByClickEvent: !0 });
414
- },
415
- highlightSelected: (l, I) => {
416
- requestAnimationFrame(() => {
417
- n({ ...l, isSetByClickEvent: I === "CLICK" }), g(s.current[l.id]);
418
- });
419
- },
420
- resetHighlight: () => {
421
- n(void 0);
422
- }
423
- };
424
- }, Ke = (r, t) => {
425
- const i = fe(
426
- (s) => {
427
- r && !r.contains(s.target) && t();
428
- },
429
- [t, r]
430
- );
431
- Oe(() => (document.addEventListener("mousedown", i), () => {
432
- document.removeEventListener("mousedown", i);
433
- }), [i]);
434
- }, Ve = ({
435
- id: r,
436
- variant: t,
437
- options: i,
438
- listboxLabel: s,
439
- multiple: d = !1,
440
- selectedOption: n,
441
- selectedOptions: g = [],
442
- onSelect: $,
443
- filterOption: x,
444
- inputValue: u,
445
- defaultInputValue: S,
446
- onInputChange: f,
447
- noOptionsText: l,
448
- highlightFirstOption: I = !1,
449
- openOnFocus: b = !1,
450
- listboxMaxHeight: c,
451
- disabled: _ = !1,
452
- readOnly: E = !1,
453
- ["data-testid"]: F
454
- }) => {
455
- const C = t === "combobox", j = ue(), q = Z(null), K = Z(null), A = Z(null), p = Pe({ options: i, highlightFirstOption: I }), { displayInputValue: V, populateInputField: L } = $e({
456
- controlledInputValue: u,
457
- defaultInputValue: S,
458
- selectedOption: n,
459
- onInputChange: f
460
- }), [T, P] = le(!1), D = () => {
461
- P(!1), p.resetHighlight();
462
- };
463
- Ke(q.current, D);
464
- const m = ({ eventType: e }) => {
465
- P(!0);
466
- const N = d ? void 0 : n;
467
- N && p.highlightSelected(N, e);
468
- }, k = d ? g : n ? [n] : [], H = C ? ye({
469
- options: i,
470
- searchTerm: V,
471
- filterOption: x,
472
- selectedOption: n,
473
- multiple: d
474
- }) : i, y = T && (!!H.length || !!l), v = (e) => F ? `${F}-${e}` : void 0, R = (e) => {
475
- if (!(!e || e.disabled))
476
- if (d) {
477
- const B = k.some((w) => w.id === e.id) ? k.filter((w) => w.id !== e.id) : [...k, e];
478
- $?.(e, B), C && (L(""), A.current?.focus());
479
- } else
480
- $?.(e, [e]), C && L(e.label), D(), (C ? A : K).current?.focus();
481
- }, U = (e) => {
482
- y || m({ eventType: "KEYBOARD" });
483
- const N = p.findNextOption(e, H);
484
- p.highlightOption(N);
485
- }, Y = (e) => {
486
- if (!(_ || E))
487
- switch (e.key) {
488
- case "ArrowUp":
489
- case "ArrowDown":
490
- e.preventDefault(), U(e.key);
491
- break;
492
- case "Enter": {
493
- e.preventDefault(), y && p.highlightedOption ? R(p.highlightedOption) : y || m({ eventType: "KEYBOARD" });
494
- break;
495
- }
496
- case " ": {
497
- C || (e.preventDefault(), y && p.highlightedOption ? R(p.highlightedOption) : y || m({ eventType: "KEYBOARD" }));
498
- break;
499
- }
500
- case "Escape":
501
- e.preventDefault(), D();
502
- break;
503
- case "Tab":
504
- D();
505
- break;
506
- case "Home":
507
- case "End":
508
- C && D();
509
- break;
510
- }
511
- }, G = (e) => {
512
- L(e.target.value), p.resetHighlight(), T || m({ eventType: "KEYBOARD" });
513
- }, W = () => {
514
- _ || E || (T ? D() : m({ eventType: "CLICK" }));
515
- }, J = () => {
516
- !T && b && !_ && !E && m({ eventType: "KEYBOARD" }), A.current?.select();
517
- }, O = () => {
518
- setTimeout(() => {
519
- const e = document.activeElement;
520
- e !== document.body && !A.current?.contains(e) && !p.listboxRef.current?.contains(e) && !q.current?.contains(e) && (D(), C && !d && L(n ? n.label : ""));
521
- });
522
- }, Q = () => {
523
- _ || E || (T ? D() : m({ eventType: "CLICK" }));
524
- }, X = () => {
525
- !T && b && !_ && !E && m({ eventType: "KEYBOARD" });
526
- }, z = `${r}-listbox`, re = (e) => `${r}-listbox-item-${e.id}`, oe = `--purpur-dropdown-${j.replace(/:/g, "")}`, te = { anchorName: oe }, de = fe(
527
- (e) => {
528
- if (p.listboxRef.current = e, e && typeof e.showPopover == "function")
529
- try {
530
- e.showPopover();
531
- } catch {
532
- }
533
- },
534
- [p.listboxRef]
535
- ), ne = {
536
- "aria-label": s,
537
- "aria-expanded": y,
538
- "data-testid": v("listbox"),
539
- id: z,
540
- ref: de,
541
- onMouseLeave: () => p.resetHighlight(),
542
- popover: "manual",
543
- style: {
544
- ...c ? {
545
- maxHeight: typeof c == "number" ? `${c}px` : c
546
- } : {},
547
- positionAnchor: oe
548
- }
549
- }, se = (e, N) => {
550
- const B = k.some((ie) => ie.id === e.id), { highlightedOption: w } = p, ce = (e.id === w?.id || I && !w && N === 0) && !w?.isSetByClickEvent;
551
- return {
552
- "data-testid": v(`listbox-item-${e.id}`),
553
- id: re(e),
554
- key: e.id,
555
- onMouseMove: () => p.highlightByClick(e),
556
- onMouseUp: () => R(e),
557
- ref: (ie) => {
558
- ie && (p.optionRefs.current[e.id] = ie);
559
- },
560
- tabIndex: -1,
561
- selected: B,
562
- disabled: e.disabled,
563
- highlighted: ce,
564
- hovered: e.id === w?.id && !!w?.isSetByClickEvent,
565
- "aria-selected": B
566
- };
567
- }, ae = C ? {} : {
568
- ref: K,
569
- type: "button",
570
- role: "combobox",
571
- "aria-haspopup": "listbox",
572
- "aria-expanded": y,
573
- "aria-controls": z,
574
- "aria-disabled": _,
575
- "data-testid": v("trigger"),
576
- id: `${r}-trigger`,
577
- onClick: Q,
578
- onKeyDown: Y,
579
- onFocus: X,
580
- disabled: _,
581
- tabIndex: _ ? -1 : 0,
582
- style: te
583
- }, pe = C ? {
584
- ref: A,
585
- role: "combobox",
586
- "aria-autocomplete": "list",
587
- "aria-expanded": y,
588
- "aria-controls": z,
589
- "aria-activedescendant": p.highlightedOption ? re(p.highlightedOption) : void 0,
590
- "data-testid": v("input"),
591
- autoComplete: "off",
592
- id: `${r}-input`,
593
- type: "text",
594
- value: V,
595
- onChange: G,
596
- onMouseDown: W,
597
- onFocus: J,
598
- onBlur: O,
599
- onKeyDown: Y,
600
- disabled: _,
601
- readOnly: E
602
- } : null;
603
- return {
604
- rootRef: q,
605
- triggerProps: ae,
606
- inputProps: pe,
607
- listboxProps: ne,
608
- getListboxItemProps: se,
609
- optionsToShow: H,
610
- isOpen: y,
611
- highlightedOption: p.highlightedOption,
612
- selectedItems: k,
613
- anchorStyle: te
614
- };
615
- }, Ce = _e((r, t) => {
616
- const {
617
- id: i,
618
- label: s,
619
- options: d,
620
- className: n,
621
- errorText: g,
622
- helperText: $,
623
- placeholder: x,
624
- negative: u = !1,
625
- readOnly: S = !1,
626
- disabled: f = !1,
627
- required: l = !1,
628
- valid: I = !1,
629
- loading: b = !1,
630
- multiple: c = !1,
631
- selectedOption: _,
632
- selectedOptions: E = [],
633
- onSelect: F,
634
- openOnFocus: C = !1,
635
- listboxMaxHeight: j,
636
- listboxLabel: q,
637
- ["data-testid"]: K
638
- } = r, A = ue(), p = i ?? A, V = (O) => K ? `${K}-${O}` : void 0, L = !!I && !g, T = `${p}-helper-text`, P = Ve({
639
- id: p,
640
- variant: "select",
641
- options: d,
642
- listboxLabel: q || s || "Options",
643
- multiple: c,
644
- selectedOption: _,
645
- selectedOptions: E,
646
- onSelect: F,
647
- openOnFocus: C,
648
- listboxMaxHeight: j,
649
- disabled: f,
650
- readOnly: S,
651
- "data-testid": K
652
- }), D = (O) => {
653
- P.rootRef.current = O, typeof t == "function" ? t(O) : t && (t.current = O);
654
- }, {
655
- triggerProps: m,
656
- listboxProps: k,
657
- getListboxItemProps: H,
658
- optionsToShow: y,
659
- isOpen: v,
660
- selectedItems: R,
661
- anchorStyle: U
662
- } = P, Y = {
663
- ...m
664
- };
665
- delete Y.style;
666
- const G = (O) => {
667
- const Q = R.filter((X) => X.id !== O.id);
668
- F?.(O, Q);
669
- }, W = c ? R.length === 0 && x || "" : _?.label || x || "", J = h(o, n, {
670
- [`${o}--negative`]: u
671
- });
672
- return /* @__PURE__ */ M("div", { ref: D, className: J, children: [
673
- /* @__PURE__ */ a(
674
- be,
675
- {
676
- fieldId: p,
677
- htmlForSuffix: "trigger",
678
- label: s,
679
- getTestId: V,
680
- disabled: f,
681
- negative: u,
682
- required: l
683
- }
684
- ),
685
- /* @__PURE__ */ a("div", { className: h(`${o}__field-row`), children: /* @__PURE__ */ M(
686
- "div",
687
- {
688
- className: h(`${o}__trigger-container`, {
689
- [`${o}__trigger-container--error`]: !!g,
690
- [`${o}__trigger-container--is-valid`]: L,
691
- [`${o}__trigger-container--negative`]: u,
692
- [`${o}__trigger-container--disabled`]: f,
693
- [`${o}__trigger-container--readonly`]: S && !f,
694
- [`${o}__trigger-container--has-tags`]: c && R.length > 0
695
- }),
696
- style: U,
697
- children: [
698
- c && /* @__PURE__ */ a(
699
- me,
700
- {
701
- selectedItems: R,
702
- getTestId: V,
703
- disabled: f,
704
- onRemove: G,
705
- isSelect: !0
706
- }
707
- ),
708
- /* @__PURE__ */ a(
709
- "button",
710
- {
711
- ...Y,
712
- className: h(`${o}__trigger`, {
713
- [`${o}__trigger--is-valid`]: L,
714
- [`${o}__trigger--negative`]: u,
715
- [`${o}__trigger--disabled`]: f,
716
- [`${o}__trigger--readonly`]: S && !f,
717
- [`${o}__trigger--placeholder`]: !R.length
718
- }),
719
- "aria-describedby": T,
720
- children: /* @__PURE__ */ a("span", { className: h(`${o}__trigger-text`), children: W })
721
- }
722
- ),
723
- /* @__PURE__ */ a(
724
- ve,
725
- {
726
- getTestId: V,
727
- loading: b,
728
- disabled: f,
729
- negative: u,
730
- isValid: L,
731
- isOpen: v,
732
- readOnly: S,
733
- showChevronOpen: !0
734
- }
735
- ),
736
- /* @__PURE__ */ a(
737
- "span",
738
- {
739
- className: h(`${o}__frame`, {
740
- [`${o}__frame--negative`]: u
741
- })
742
- }
743
- )
744
- ]
745
- }
746
- ) }),
747
- v && /* @__PURE__ */ a(ee, { ...k, className: h(`${o}__listbox`), children: xe({
748
- optionsToShow: y,
749
- getListboxItemProps: H,
750
- multiple: c,
751
- fieldId: p
752
- }) }),
753
- /* @__PURE__ */ a(
754
- we,
755
- {
756
- errorText: g,
757
- helperText: $,
758
- helperTextId: T,
759
- negative: u
760
- }
761
- )
762
- ] });
763
- });
764
- Ce.displayName = "DropdownSelect";
765
- const He = _e((r, t) => r.combobox ? /* @__PURE__ */ a(Ie, { ref: t, ...r }) : /* @__PURE__ */ a(Ce, { ref: t, ...r }));
766
- He.displayName = "Dropdown";
767
- export {
768
- He as D,
769
- Ve as u
770
- };
771
- //# sourceMappingURL=dropdown-C-Ze4gvG.mjs.map