@midas-ds/components 15.2.6 → 15.2.8

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,672 +0,0 @@
1
- import { jsx as r, jsxs as p, Fragment as D } from "react/jsx-runtime";
2
- import * as P from "react";
3
- import x, { useMemo as E, useState as V, useCallback as L, useEffect as k, useRef as O } from "react";
4
- import { c as B } from "./clsx-jbLnTBqA.js";
5
- import { b as R } from "./utils-BJ6_Ry69.js";
6
- import { a as j, $ as G, T as W } from "./Tag-DbNUEevV.js";
7
- import { $ as H } from "./TextField-1_-3gKYa.js";
8
- import { c as U } from "./Collection-CXAXUgCh.js";
9
- import { C as I } from "./Checkbox-CsITchPQ.js";
10
- import { L as q } from "./ListBox-TsgvK95f.js";
11
- import { b as X, L as J, a as Q } from "./ListBoxSection-C-7JFypr.js";
12
- import { C as Y } from "./check-BxlvVsvD.js";
13
- import { d as Z } from "./useHover-BkQu__4t.js";
14
- import { p as ee, q as te } from "./Dialog-F3u8agGf.js";
15
- import { $ as le, a as ae } from "./ListKeyboardDelegate-RT2g6YNq.js";
16
- import { h as ie } from "./SelectionManager-bnxBDhgb.js";
17
- import { a as w, c as re, e as oe } from "./mergeProps-oYrDoKjU.js";
18
- import { $ as ne } from "./filterDOMProps-BSVCO5jK.js";
19
- import { $ as ce } from "./useField-Bf6sH2Px.js";
20
- import { $ as se, a as de, b as ue } from "./useFormValidation-BgOffXI-.js";
21
- import { $ as fe } from "./useListState-DeBExb3v.js";
22
- import { a as me } from "./VisuallyHidden-BCa6ThRH.js";
23
- import { a as be, L as he } from "./Label-knQhhLVp.js";
24
- import { T as ge } from "./Text-6Fdknq88.js";
25
- import { X as pe } from "./x-BXShoIAM.js";
26
- import { u as N } from "./useLocalizedStringFormatter-m7LExKN3.js";
27
- import { $ as ye } from "./useButton-aiD_OMdm.js";
28
- import { C as $e } from "./chevron-down-DgT-uSF9.js";
29
- import { $ as ve, F as xe } from "./FieldError-DQ61agyq.js";
30
- import './assets/Select2.css';function A(e) {
31
- return null;
32
- }
33
- A.getCollectionNode = function* (t, i) {
34
- let { childItems: o, title: a, children: n } = t, l = t.title || t.children, s = t.textValue || (typeof l == "string" ? l : "") || t["aria-label"] || "";
35
- !s && !i?.suppressTextValueWarning && process.env.NODE_ENV !== "production" && console.warn("<Item> with non-plain text contents is unsupported by type to select for accessibility. Please add a `textValue` prop."), yield {
36
- type: "item",
37
- props: t,
38
- rendered: l,
39
- textValue: s,
40
- "aria-label": t["aria-label"],
41
- hasChildNodes: Se(t),
42
- *childNodes() {
43
- if (o) for (let c of o) yield {
44
- type: "item",
45
- value: c
46
- };
47
- else if (a) {
48
- let c = [];
49
- x.Children.forEach(n, (u) => {
50
- c.push({
51
- type: "item",
52
- element: u
53
- });
54
- }), yield* c;
55
- }
56
- }
57
- };
58
- };
59
- function Se(e) {
60
- return e.hasChildItems != null ? e.hasChildItems : !!(e.childItems || e.title && x.Children.count(e.children) > 0);
61
- }
62
- let _ = A;
63
- function M(e) {
64
- return null;
65
- }
66
- M.getCollectionNode = function* (t) {
67
- let { children: i, title: o, items: a } = t;
68
- yield {
69
- type: "section",
70
- props: t,
71
- hasChildNodes: !0,
72
- rendered: o,
73
- "aria-label": t["aria-label"],
74
- *childNodes() {
75
- if (typeof i == "function") {
76
- if (!a) throw new Error("props.children was a function but props.items is missing");
77
- for (let n of a) yield {
78
- type: "item",
79
- value: n,
80
- renderer: i
81
- };
82
- } else {
83
- let n = [];
84
- x.Children.forEach(i, (l) => {
85
- n.push({
86
- type: "item",
87
- element: l
88
- });
89
- }), yield* n;
90
- }
91
- }
92
- };
93
- };
94
- let Ce = M;
95
- const we = "_wrapper_1rw0v_7", _e = "_trigger_1rw0v_18", Ke = "_medium_1rw0v_32", Pe = "_icon_1rw0v_68", Ve = "_tagGroup_1rw0v_74", ke = "_listBoxItemCheckmark_1rw0v_90", Be = "_triggerContainer_1rw0v_95", Ie = "_selectValueTag_1rw0v_101", Ne = "_clearButton_1rw0v_117", Ae = "_truncate_1rw0v_129", Me = "_checkboxContainer_1rw0v_166", Te = "_selectAll_1rw0v_172", b = {
96
- wrapper: we,
97
- trigger: _e,
98
- medium: Ke,
99
- icon: Pe,
100
- tagGroup: Ve,
101
- listBoxItemCheckmark: ke,
102
- triggerContainer: Be,
103
- selectValueTag: Ie,
104
- clearButton: Ne,
105
- truncate: Ae,
106
- checkboxContainer: Me,
107
- selectAll: Te
108
- }, T = ({ item: e }) => /* @__PURE__ */ r(
109
- J,
110
- {
111
- ...e.value,
112
- textValue: e.textValue,
113
- "aria-label": e.textValue,
114
- children: ({ isDisabled: t, isSelected: i, selectionMode: o }) => /* @__PURE__ */ p(D, { children: [
115
- o === "multiple" ? /* @__PURE__ */ r(
116
- "div",
117
- {
118
- className: b.checkboxContainer,
119
- "aria-hidden": !0,
120
- children: /* @__PURE__ */ r(
121
- I,
122
- {
123
- isDisabled: t,
124
- isSelected: i,
125
- isReadOnly: !0,
126
- excludeFromTabOrder: !0,
127
- "aria-label": e.textValue
128
- }
129
- )
130
- }
131
- ) : null,
132
- e.rendered,
133
- i && o === "single" ? /* @__PURE__ */ r(
134
- Y,
135
- {
136
- size: 20,
137
- className: b.listBoxItemCheckmark
138
- }
139
- ) : null
140
- ] })
141
- }
142
- ), ze = ({ section: e, state: t }) => /* @__PURE__ */ r(X, { ...e.value, children: t.collection.getChildren ? /* @__PURE__ */ r(U, { items: t.collection.getChildren(e.key), children: (i) => /* @__PURE__ */ r(T, { item: i }) }) : null }), Fe = ({
143
- state: e,
144
- ...t
145
- }) => /* @__PURE__ */ r(
146
- q,
147
- {
148
- ...t,
149
- ...e,
150
- escapeKeyBehavior: "none",
151
- onSelectionChange: e.setSelectedKeys,
152
- items: e.collection,
153
- children: (i) => i.type === "section" ? /* @__PURE__ */ r(
154
- ze,
155
- {
156
- state: e,
157
- section: i
158
- }
159
- ) : /* @__PURE__ */ r(T, { item: i })
160
- }
161
- );
162
- function De(e, t, i) {
163
- const { disallowEmptySelection: o, isDisabled: a } = e, n = le({ usage: "search", sensitivity: "base" }), l = E(
164
- () => new ae(
165
- t.collection,
166
- t.disabledKeys,
167
- null,
168
- n
169
- ),
170
- [t.collection, t.disabledKeys, n]
171
- ), { menuTriggerProps: s, menuProps: c } = ee(
172
- {
173
- isDisabled: a,
174
- type: "listbox"
175
- },
176
- t,
177
- i
178
- ), u = (m) => {
179
- const { selectedKeys: v, selectionMode: F } = t, C = v.values().next().value;
180
- if (F === "single")
181
- switch (m.key) {
182
- case "ArrowLeft": {
183
- m.preventDefault();
184
- const $ = v.size > 0 ? l.getKeyAbove(C) : l.getFirstKey();
185
- $ && t.setSelectedKeys([$]);
186
- break;
187
- }
188
- case "ArrowRight": {
189
- m.preventDefault();
190
- const $ = v.size > 0 ? l.getKeyBelow(C) : l.getFirstKey();
191
- $ && t.setSelectedKeys([$]);
192
- break;
193
- }
194
- }
195
- }, { typeSelectProps: d } = ie({
196
- keyboardDelegate: l,
197
- selectionManager: t.selectionManager,
198
- onTypeSelect(m) {
199
- t.setSelectedKeys([m]);
200
- }
201
- }), { labelProps: y, fieldProps: h } = ce({
202
- ...e,
203
- labelElementType: "span"
204
- });
205
- d.onKeyDown = d.onKeyDownCapture, delete d.onKeyDownCapture;
206
- const f = ne(e, { labelable: !0 }), g = w(d, s, h), S = re();
207
- return {
208
- labelProps: {
209
- ...y,
210
- onClick: () => {
211
- e.isDisabled || (i.current?.focus(), Z("keyboard"));
212
- }
213
- },
214
- triggerProps: w(f, {
215
- ...g,
216
- onKeyDown: oe(
217
- g.onKeyDown,
218
- u,
219
- e.onKeyDown
220
- ),
221
- onKeyUp: e.onKeyUp,
222
- "aria-labelledby": [
223
- g["aria-labelledby"],
224
- g["aria-label"] && !g["aria-labelledby"] ? g.id : null,
225
- S
226
- ].filter(Boolean).join(" "),
227
- onFocus(m) {
228
- t.isFocused || (e.onFocus && e.onFocus(m), t.setFocused(!0));
229
- },
230
- onBlur(m) {
231
- t.isOpen || (e.onBlur && e.onBlur(m), t.setFocused(!1));
232
- }
233
- }),
234
- valueProps: {
235
- id: S
236
- },
237
- menuProps: {
238
- ...c,
239
- disallowEmptySelection: o,
240
- autoFocus: t.focusStrategy || !0,
241
- shouldSelectOnPressUp: !0,
242
- shouldFocusOnHover: !0,
243
- onBlur: (m) => {
244
- m.currentTarget.contains(m.relatedTarget) || (e.onBlur && e.onBlur(m), t.setFocused(!1));
245
- },
246
- "aria-labelledby": [
247
- h["aria-labelledby"],
248
- g["aria-label"] && !h["aria-labelledby"] ? g.id : null
249
- ].filter(Boolean).join(" ")
250
- }
251
- };
252
- }
253
- function Ee(e) {
254
- const {
255
- collection: t,
256
- disabledKeys: i,
257
- selectionManager: o,
258
- selectionManager: { setSelectedKeys: a, selectedKeys: n, selectionMode: l }
259
- } = fe(e), s = [], c = n.size !== 0 ? Array.from(n).map((u) => {
260
- const d = t.getItem(u);
261
- return d || s.push(u), d;
262
- }).filter(Boolean) : null;
263
- return s.length && console.warn(
264
- `Select: Keys "${s.join(
265
- ", "
266
- )}" passed to "selectedKeys" are not present in the collection.`
267
- ), {
268
- collection: t,
269
- disabledKeys: i,
270
- selectionManager: o,
271
- selectionMode: l,
272
- selectedKeys: n,
273
- setSelectedKeys: a.bind(o),
274
- selectedItems: c
275
- };
276
- }
277
- function Le(e) {
278
- const [t, i] = V(!1), o = te(e), a = e.selectionMode === "single", n = Ee({
279
- ...e,
280
- onSelectionChange: (d) => {
281
- e.onSelectionChange && e.onSelectionChange(d), a && o.close();
282
- }
283
- }), l = se({
284
- ...e,
285
- validationBehavior: "native",
286
- value: n.selectedKeys
287
- }), s = n.collection.size === 0, c = !!n.selectedKeys.size, u = L(() => {
288
- l.resetValidation(), l.commitValidation();
289
- }, [l]);
290
- return k(() => {
291
- a && c && u();
292
- }, [c, a, u]), {
293
- ...n,
294
- ...o,
295
- close() {
296
- o.close(), c && u();
297
- },
298
- open() {
299
- s || o.open();
300
- },
301
- toggle(d) {
302
- s || o.toggle(d);
303
- },
304
- isFocused: t,
305
- setFocused: i,
306
- ...l
307
- };
308
- }
309
- function Oe(e, t = {}) {
310
- const [i, o] = V({ width: 0, height: 0 }), a = t.delay === void 0 ? 500 : t.delay, n = !!t.includePadding;
311
- return k(() => {
312
- if (!e) return;
313
- const l = new ResizeObserver(
314
- Re(([s]) => {
315
- const { inlineSize: c, blockSize: u } = n ? s.borderBoxSize[0] : s.contentBoxSize[0];
316
- o({ width: c, height: u });
317
- }, a)
318
- );
319
- return l.observe(e), () => {
320
- l.disconnect();
321
- };
322
- }, [a, e, n]), i;
323
- }
324
- function Re(e, t) {
325
- let i;
326
- return (o, a) => {
327
- clearTimeout(i), i = setTimeout(() => {
328
- e(o, a);
329
- }, t);
330
- };
331
- }
332
- function je({
333
- autoComplete: e,
334
- name: t,
335
- isDisabled: i,
336
- isRequired: o,
337
- selectRef: a
338
- }, n, l) {
339
- const { visuallyHiddenProps: s } = me();
340
- return de(a, n.selectedKeys, n.setSelectedKeys), ue(
341
- {
342
- validationBehavior: "native",
343
- focus: () => l.current?.focus()
344
- },
345
- n,
346
- a
347
- ), {
348
- containerProps: {
349
- ...s,
350
- "aria-hidden": !0,
351
- // @ts-expect-error - data-a11y-ignore is not a standard attribute
352
- "data-react-aria-prevent-focus": !0,
353
- "data-a11y-ignore": "aria-hidden-focus"
354
- },
355
- inputProps: {
356
- style: { display: "none" }
357
- },
358
- selectProps: {
359
- tabIndex: -1,
360
- autoComplete: e,
361
- disabled: i,
362
- required: o,
363
- name: t,
364
- value: Array.from(n.selectedKeys).map((c) => c.toString()),
365
- onChange: (c) => n.setSelectedKeys(c.target.value),
366
- multiple: !0
367
- }
368
- };
369
- }
370
- function Ge(e) {
371
- const { state: t, triggerRef: i, name: o, isDisabled: a } = e, n = `${e.label}-hidden`, l = O(null), { containerProps: s, selectProps: c } = je(
372
- { ...e, selectRef: l },
373
- t,
374
- i
375
- );
376
- return t.collection.size <= 300 ? /* @__PURE__ */ r(
377
- "div",
378
- {
379
- ...s,
380
- "data-testid": "hidden-select-container",
381
- children: /* @__PURE__ */ p("label", { children: [
382
- n,
383
- /* @__PURE__ */ p(
384
- "select",
385
- {
386
- ...c,
387
- ref: l,
388
- children: [
389
- /* @__PURE__ */ r("option", {}),
390
- [...t.collection.getKeys()].map((u) => {
391
- const d = t.collection.getItem(u);
392
- return d && d.type === "item" ? /* @__PURE__ */ r(
393
- "option",
394
- {
395
- value: d.key,
396
- children: d.textValue
397
- },
398
- d.key
399
- ) : null;
400
- })
401
- ]
402
- }
403
- )
404
- ] })
405
- }
406
- ) : o ? /* @__PURE__ */ r(
407
- "input",
408
- {
409
- type: "hidden",
410
- autoComplete: c.autoComplete,
411
- name: o,
412
- disabled: a,
413
- value: Array.from(t.selectedKeys).map((u) => u.toString()) ?? [""]
414
- }
415
- ) : null;
416
- }
417
- const We = { clearAll: "Clear all", selectAll: "Select all", selectedItems: "Selected items", chosen: "chosen" }, He = { clearAll: "Rensa alla", selectAll: "Välj alla", selectedItems: "Valda objekt", chosen: "valda" }, z = {
418
- en: We,
419
- sv: He
420
- }, Ue = ({
421
- state: { selectedItems: e },
422
- isDisabled: t,
423
- parentWidth: i,
424
- onClear: o,
425
- triggerRef: a,
426
- isClearable: n
427
- }) => {
428
- const l = N(z);
429
- return /* @__PURE__ */ p(
430
- "div",
431
- {
432
- className: b.selectValueTag,
433
- "data-disabled": t || void 0,
434
- children: [
435
- /* @__PURE__ */ r(
436
- "span",
437
- {
438
- className: b.truncate,
439
- style: { maxWidth: i - 92 },
440
- children: e?.length && e.length > 1 ? `${e.length} ${l.format("chosen")}` : e?.[0].textValue
441
- }
442
- ),
443
- n && /* @__PURE__ */ r(
444
- "button",
445
- {
446
- disabled: t,
447
- "aria-label": l.format("clearAll"),
448
- className: b.clearButton,
449
- onClick: () => {
450
- o(), a?.current?.focus();
451
- },
452
- children: /* @__PURE__ */ r(
453
- pe,
454
- {
455
- width: 20,
456
- height: 20
457
- }
458
- )
459
- }
460
- )
461
- ]
462
- }
463
- );
464
- }, qe = ({
465
- autoFocus: e,
466
- excludeFromTabOrder: t,
467
- isDisabled: i,
468
- size: o = "large",
469
- isOpen: a,
470
- isInvalid: n,
471
- selectionMode: l,
472
- state: { selectedItems: s },
473
- placeholder: c,
474
- children: u,
475
- triggerRef: d,
476
- ...y
477
- }) => {
478
- const { buttonProps: h } = ye(
479
- { autoFocus: e, excludeFromTabOrder: t, isDisabled: i, ...y },
480
- d
481
- ), f = l === "multiple";
482
- return /* @__PURE__ */ p(
483
- "div",
484
- {
485
- className: b.triggerContainer,
486
- "data-disabled": i || void 0,
487
- children: [
488
- /* @__PURE__ */ p(
489
- "button",
490
- {
491
- ...h,
492
- autoFocus: e,
493
- className: B(b.trigger, {
494
- [b.medium]: o === "medium"
495
- }),
496
- "data-disabled": i || void 0,
497
- "data-invalid": n || void 0,
498
- "data-open": a || void 0,
499
- ref: d,
500
- type: "button",
501
- children: [
502
- f && !s ? /* @__PURE__ */ r("span", { children: c }) : null,
503
- f ? null : /* @__PURE__ */ r("span", { children: s ? s[0].textValue : c }),
504
- /* @__PURE__ */ r(
505
- "div",
506
- {
507
- className: b.icon,
508
- "aria-hidden": "true",
509
- children: /* @__PURE__ */ r($e, { size: 20 })
510
- }
511
- )
512
- ]
513
- }
514
- ),
515
- u
516
- ]
517
- }
518
- );
519
- }, K = ({
520
- state: e,
521
- errorMessage: t
522
- }) => /* @__PURE__ */ r(ve.Provider, { value: { ...e.displayValidation }, children: /* @__PURE__ */ r(xe, { children: t }) }), Xe = P.forwardRef(
523
- ({ isClearable: e = !0, popover: t, ...i }, o) => {
524
- const a = {
525
- selectionMode: "single",
526
- errorPosition: "top",
527
- disallowEmptySelection: !e,
528
- isClearable: e,
529
- size: "large",
530
- popover: t,
531
- ...i
532
- }, n = R(o), l = Le(a), s = N(z), { labelProps: c, triggerProps: u, valueProps: d, menuProps: y } = De(
533
- a,
534
- l,
535
- n
536
- ), { width: h } = Oe(n.current, {
537
- includePadding: !0
538
- });
539
- return /* @__PURE__ */ p(
540
- H,
541
- {
542
- ...a,
543
- className: B(b.wrapper, a.className),
544
- children: [
545
- /* @__PURE__ */ r(
546
- Ge,
547
- {
548
- ...a,
549
- state: l,
550
- triggerRef: n
551
- }
552
- ),
553
- /* @__PURE__ */ r(be, { popover: t, children: a.label && /* @__PURE__ */ r(
554
- he,
555
- {
556
- ...c,
557
- "data-disabled": a.isDisabled || void 0,
558
- children: a.label
559
- }
560
- ) }),
561
- a.description && /* @__PURE__ */ r(ge, { slot: "description", children: a.description }),
562
- a.errorPosition === "top" && /* @__PURE__ */ r(
563
- K,
564
- {
565
- ...a,
566
- state: l
567
- }
568
- ),
569
- /* @__PURE__ */ r(
570
- qe,
571
- {
572
- ...a,
573
- ...u,
574
- isInvalid: l.displayValidation.isInvalid,
575
- triggerRef: n,
576
- state: l,
577
- children: a.selectionMode === "multiple" && l.selectedItems ? /* @__PURE__ */ r("span", { ...d, children: /* @__PURE__ */ r(
578
- Ue,
579
- {
580
- ...a,
581
- state: l,
582
- parentWidth: h,
583
- onClear: () => l.selectionManager.clearSelection(),
584
- triggerRef: n
585
- }
586
- ) }) : null
587
- }
588
- ),
589
- a.errorPosition === "bottom" && /* @__PURE__ */ r(
590
- K,
591
- {
592
- ...a,
593
- state: l
594
- }
595
- ),
596
- /* @__PURE__ */ p(
597
- Q,
598
- {
599
- isOpen: l.isOpen,
600
- onOpenChange: (f) => {
601
- f || l.close();
602
- },
603
- triggerRef: n,
604
- style: { width: h },
605
- children: [
606
- a.isSelectableAll && /* @__PURE__ */ r(
607
- I,
608
- {
609
- isSelected: l.selectionManager.isSelectAll,
610
- isIndeterminate: !l.selectionManager.isSelectAll && !l.selectionManager.isEmpty,
611
- className: b.selectAll,
612
- onChange: () => l.selectionManager.toggleSelectAll(),
613
- children: s.format("selectAll")
614
- }
615
- ),
616
- /* @__PURE__ */ r(
617
- Fe,
618
- {
619
- ...y,
620
- state: l
621
- }
622
- )
623
- ]
624
- }
625
- ),
626
- a.showTags && !!l.selectedItems && /* @__PURE__ */ r(
627
- j,
628
- {
629
- "aria-label": s.format("selectedItems"),
630
- selectionBehavior: "toggle",
631
- onRemove: (f) => l.selectionManager.toggleSelection(Array.from(f)[0]),
632
- className: b.tagGroup,
633
- children: /* @__PURE__ */ r(G, { items: l.selectedItems, children: (f) => /* @__PURE__ */ r(
634
- W,
635
- {
636
- textValue: f.textValue,
637
- id: f.key,
638
- dismissable: !0,
639
- isDisabled: a.isDisabled,
640
- children: f.textValue
641
- },
642
- f.key
643
- ) })
644
- }
645
- )
646
- ]
647
- }
648
- );
649
- }
650
- ), Je = P.forwardRef(
651
- ({ options: e, ...t }, i) => /* @__PURE__ */ r(
652
- Xe,
653
- {
654
- ...t,
655
- items: e,
656
- ref: i,
657
- children: (o) => o.children ? /* @__PURE__ */ r(
658
- Ce,
659
- {
660
- items: o.children,
661
- title: o.name,
662
- children: (a) => /* @__PURE__ */ r(_, { textValue: a.textValue, children: a.name })
663
- },
664
- o.name
665
- ) : /* @__PURE__ */ r(_, { textValue: o.textValue, children: o.name })
666
- }
667
- )
668
- );
669
- Je.displayName = "Select";
670
- export {
671
- Je as S
672
- };
@@ -1 +0,0 @@
1
- "use strict";require('./assets/Select2.css');const i=require("react/jsx-runtime"),h=require("react"),q=require("./clsx-DKOfLqne.cjs"),E=require("./utils-ZN3Na38z.cjs"),S=require("./Tag-Bd8ql_zX.cjs"),R=require("./TextField-6v1u8c__.cjs"),H=require("./Collection-Dq97IKYm.cjs"),I=require("./Checkbox-LGIr8OfT.cjs"),G=require("./ListBox-BDEzuwgf.cjs"),C=require("./ListBoxSection-DcajcZMK.cjs"),W=require("./check-DA2sdqW6.cjs"),U=require("./useHover-DIDiFsU7.cjs"),M=require("./Dialog-XOUP-FA_.cjs"),K=require("./ListKeyboardDelegate-6U5oNrPf.cjs"),X=require("./SelectionManager-C4hvFZl0.cjs"),$=require("./mergeProps-D9EPHb19.cjs"),J=require("./filterDOMProps-WUskt27c.cjs"),Q=require("./useField-yjDSH-M4.cjs"),j=require("./useFormValidation-pVNhWoaN.cjs"),Y=require("./useListState-BCVYtjD-.cjs"),Z=require("./VisuallyHidden-CrRi8fmq.cjs"),P=require("./Label-DkNtFYv5.cjs"),ee=require("./Text-D29KP4_q.cjs"),te=require("./x-DRkCcaDU.cjs"),N=require("./useLocalizedStringFormatter-Dfow0G-0.cjs"),le=require("./useButton-BuHg3SHI.cjs"),ne=require("./chevron-down-DyBh7agb.cjs"),k=require("./FieldError-DwYQXCwP.cjs");function ie(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const s=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,s.get?s:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const F=ie(h);function T(e){return null}T.getCollectionNode=function*(t,r){let{childItems:s,title:n,children:o}=t,l=t.title||t.children,a=t.textValue||(typeof l=="string"?l:"")||t["aria-label"]||"";!a&&!r?.suppressTextValueWarning&&process.env.NODE_ENV!=="production"&&console.warn("<Item> with non-plain text contents is unsupported by type to select for accessibility. Please add a `textValue` prop."),yield{type:"item",props:t,rendered:l,textValue:a,"aria-label":t["aria-label"],hasChildNodes:re(t),*childNodes(){if(s)for(let c of s)yield{type:"item",value:c};else if(n){let c=[];h.Children.forEach(o,u=>{c.push({type:"item",element:u})}),yield*c}}}};function re(e){return e.hasChildItems!=null?e.hasChildItems:!!(e.childItems||e.title&&h.Children.count(e.children)>0)}let V=T;function A(e){return null}A.getCollectionNode=function*(t){let{children:r,title:s,items:n}=t;yield{type:"section",props:t,hasChildNodes:!0,rendered:s,"aria-label":t["aria-label"],*childNodes(){if(typeof r=="function"){if(!n)throw new Error("props.children was a function but props.items is missing");for(let o of n)yield{type:"item",value:o,renderer:r}}else{let o=[];h.Children.forEach(r,l=>{o.push({type:"item",element:l})}),yield*o}}}};let se=A;const oe="_wrapper_1rw0v_7",ce="_trigger_1rw0v_18",ae="_medium_1rw0v_32",de="_icon_1rw0v_68",ue="_tagGroup_1rw0v_74",fe="_listBoxItemCheckmark_1rw0v_90",be="_triggerContainer_1rw0v_95",ge="_selectValueTag_1rw0v_101",he="_clearButton_1rw0v_117",xe="_truncate_1rw0v_129",me="_checkboxContainer_1rw0v_166",ye="_selectAll_1rw0v_172",g={wrapper:oe,trigger:ce,medium:ae,icon:de,tagGroup:ue,listBoxItemCheckmark:fe,triggerContainer:be,selectValueTag:ge,clearButton:he,truncate:xe,checkboxContainer:me,selectAll:ye},z=({item:e})=>i.jsx(C.ListBoxItem,{...e.value,textValue:e.textValue,"aria-label":e.textValue,children:({isDisabled:t,isSelected:r,selectionMode:s})=>i.jsxs(i.Fragment,{children:[s==="multiple"?i.jsx("div",{className:g.checkboxContainer,"aria-hidden":!0,children:i.jsx(I.Checkbox,{isDisabled:t,isSelected:r,isReadOnly:!0,excludeFromTabOrder:!0,"aria-label":e.textValue})}):null,e.rendered,r&&s==="single"?i.jsx(W.Check,{size:20,className:g.listBoxItemCheckmark}):null]})}),pe=({section:e,state:t})=>i.jsx(C.ListBoxSection,{...e.value,children:t.collection.getChildren?i.jsx(H.$e1995378a142960e$export$fb8073518f34e6ec,{items:t.collection.getChildren(e.key),children:r=>i.jsx(z,{item:r})}):null}),$e=({state:e,...t})=>i.jsx(G.ListBox,{...t,...e,escapeKeyBehavior:"none",onSelectionChange:e.setSelectedKeys,items:e.collection,children:r=>r.type==="section"?i.jsx(pe,{state:e,section:r}):i.jsx(z,{item:r})});function ve(e,t,r){const{disallowEmptySelection:s,isDisabled:n}=e,o=K.$325a3faab7a68acd$export$a16aca283550c30d({usage:"search",sensitivity:"base"}),l=h.useMemo(()=>new K.$2a25aae57d74318e$export$a05409b8bb224a5a(t.collection,t.disabledKeys,null,o),[t.collection,t.disabledKeys,o]),{menuTriggerProps:a,menuProps:c}=M.$168583247155ddda$export$dc9c12ed27dd1b49({isDisabled:n,type:"listbox"},t,r),u=b=>{const{selectedKeys:v,selectionMode:L}=t,_=v.values().next().value;if(L==="single")switch(b.key){case"ArrowLeft":{b.preventDefault();const p=v.size>0?l.getKeyAbove(_):l.getFirstKey();p&&t.setSelectedKeys([p]);break}case"ArrowRight":{b.preventDefault();const p=v.size>0?l.getKeyBelow(_):l.getFirstKey();p&&t.setSelectedKeys([p]);break}}},{typeSelectProps:d}=X.$fb3050f43d946246$export$e32c88dfddc6e1d8({keyboardDelegate:l,selectionManager:t.selectionManager,onTypeSelect(b){t.setSelectedKeys([b])}}),{labelProps:y,fieldProps:x}=Q.$2baaea4c71418dea$export$294aa081a6c6f55d({...e,labelElementType:"span"});d.onKeyDown=d.onKeyDownCapture,delete d.onKeyDownCapture;const f=J.$65484d02dcb7eb3e$export$457c3d6518dd4c6f(e,{labelable:!0}),m=$.$3ef42575df84b30b$export$9d1611c77c2fe928(d,a,x),w=$.$bdb11010cef70236$export$f680877a34711e37();return{labelProps:{...y,onClick:()=>{e.isDisabled||(r.current?.focus(),U.$507fabe10e71c6fb$export$8397ddfc504fdb9a("keyboard"))}},triggerProps:$.$3ef42575df84b30b$export$9d1611c77c2fe928(f,{...m,onKeyDown:$.$ff5963eb1fccf552$export$e08e3b67e392101e(m.onKeyDown,u,e.onKeyDown),onKeyUp:e.onKeyUp,"aria-labelledby":[m["aria-labelledby"],m["aria-label"]&&!m["aria-labelledby"]?m.id:null,w].filter(Boolean).join(" "),onFocus(b){t.isFocused||(e.onFocus&&e.onFocus(b),t.setFocused(!0))},onBlur(b){t.isOpen||(e.onBlur&&e.onBlur(b),t.setFocused(!1))}}),valueProps:{id:w},menuProps:{...c,disallowEmptySelection:s,autoFocus:t.focusStrategy||!0,shouldSelectOnPressUp:!0,shouldFocusOnHover:!0,onBlur:b=>{b.currentTarget.contains(b.relatedTarget)||(e.onBlur&&e.onBlur(b),t.setFocused(!1))},"aria-labelledby":[x["aria-labelledby"],m["aria-label"]&&!x["aria-labelledby"]?m.id:null].filter(Boolean).join(" ")}}}function Se(e){const{collection:t,disabledKeys:r,selectionManager:s,selectionManager:{setSelectedKeys:n,selectedKeys:o,selectionMode:l}}=Y.$e72dd72e1c76a225$export$2f645645f7bca764(e),a=[],c=o.size!==0?Array.from(o).map(u=>{const d=t.getItem(u);return d||a.push(u),d}).filter(Boolean):null;return a.length&&console.warn(`Select: Keys "${a.join(", ")}" passed to "selectedKeys" are not present in the collection.`),{collection:t,disabledKeys:r,selectionManager:s,selectionMode:l,selectedKeys:o,setSelectedKeys:n.bind(s),selectedItems:c}}function je(e){const[t,r]=h.useState(!1),s=M.$a28c903ee9ad8dc5$export$79fefeb1c2091ac3(e),n=e.selectionMode==="single",o=Se({...e,onSelectionChange:d=>{e.onSelectionChange&&e.onSelectionChange(d),n&&s.close()}}),l=j.$e5be200c675c3b3a$export$fc1a364ae1f3ff10({...e,validationBehavior:"native",value:o.selectedKeys}),a=o.collection.size===0,c=!!o.selectedKeys.size,u=h.useCallback(()=>{l.resetValidation(),l.commitValidation()},[l]);return h.useEffect(()=>{n&&c&&u()},[c,n,u]),{...o,...s,close(){s.close(),c&&u()},open(){a||s.open()},toggle(d){a||s.toggle(d)},isFocused:t,setFocused:r,...l}}function Ce(e,t={}){const[r,s]=h.useState({width:0,height:0}),n=t.delay===void 0?500:t.delay,o=!!t.includePadding;return h.useEffect(()=>{if(!e)return;const l=new ResizeObserver(we(([a])=>{const{inlineSize:c,blockSize:u}=o?a.borderBoxSize[0]:a.contentBoxSize[0];s({width:c,height:u})},n));return l.observe(e),()=>{l.disconnect()}},[n,e,o]),r}function we(e,t){let r;return(s,n)=>{clearTimeout(r),r=setTimeout(()=>{e(s,n)},t)}}function _e({autoComplete:e,name:t,isDisabled:r,isRequired:s,selectRef:n},o,l){const{visuallyHiddenProps:a}=Z.$5c3e21d68f1c4674$export$a966af930f325cab();return j.$99facab73266f662$export$5add1d006293d136(n,o.selectedKeys,o.setSelectedKeys),j.$e93e671b31057976$export$b8473d3665f3a75a({validationBehavior:"native",focus:()=>l.current?.focus()},o,n),{containerProps:{...a,"aria-hidden":!0,"data-react-aria-prevent-focus":!0,"data-a11y-ignore":"aria-hidden-focus"},inputProps:{style:{display:"none"}},selectProps:{tabIndex:-1,autoComplete:e,disabled:r,required:s,name:t,value:Array.from(o.selectedKeys).map(c=>c.toString()),onChange:c=>o.setSelectedKeys(c.target.value),multiple:!0}}}function Ke(e){const{state:t,triggerRef:r,name:s,isDisabled:n}=e,o=`${e.label}-hidden`,l=h.useRef(null),{containerProps:a,selectProps:c}=_e({...e,selectRef:l},t,r);return t.collection.size<=300?i.jsx("div",{...a,"data-testid":"hidden-select-container",children:i.jsxs("label",{children:[o,i.jsxs("select",{...c,ref:l,children:[i.jsx("option",{}),[...t.collection.getKeys()].map(u=>{const d=t.collection.getItem(u);return d&&d.type==="item"?i.jsx("option",{value:d.key,children:d.textValue},d.key):null})]})]})}):s?i.jsx("input",{type:"hidden",autoComplete:c.autoComplete,name:s,disabled:n,value:Array.from(t.selectedKeys).map(u=>u.toString())??[""]}):null}const Pe={clearAll:"Clear all",selectAll:"Select all",selectedItems:"Selected items",chosen:"chosen"},ke={clearAll:"Rensa alla",selectAll:"Välj alla",selectedItems:"Valda objekt",chosen:"valda"},D={en:Pe,sv:ke},Ve=({state:{selectedItems:e},isDisabled:t,parentWidth:r,onClear:s,triggerRef:n,isClearable:o})=>{const l=N.useLocalizedStringFormatter(D);return i.jsxs("div",{className:g.selectValueTag,"data-disabled":t||void 0,children:[i.jsx("span",{className:g.truncate,style:{maxWidth:r-92},children:e?.length&&e.length>1?`${e.length} ${l.format("chosen")}`:e?.[0].textValue}),o&&i.jsx("button",{disabled:t,"aria-label":l.format("clearAll"),className:g.clearButton,onClick:()=>{s(),n?.current?.focus()},children:i.jsx(te.X,{width:20,height:20})})]})},Be=({autoFocus:e,excludeFromTabOrder:t,isDisabled:r,size:s="large",isOpen:n,isInvalid:o,selectionMode:l,state:{selectedItems:a},placeholder:c,children:u,triggerRef:d,...y})=>{const{buttonProps:x}=le.$701a24aa0da5b062$export$ea18c227d4417cc3({autoFocus:e,excludeFromTabOrder:t,isDisabled:r,...y},d),f=l==="multiple";return i.jsxs("div",{className:g.triggerContainer,"data-disabled":r||void 0,children:[i.jsxs("button",{...x,autoFocus:e,className:q.clsx(g.trigger,{[g.medium]:s==="medium"}),"data-disabled":r||void 0,"data-invalid":o||void 0,"data-open":n||void 0,ref:d,type:"button",children:[f&&!a?i.jsx("span",{children:c}):null,f?null:i.jsx("span",{children:a?a[0].textValue:c}),i.jsx("div",{className:g.icon,"aria-hidden":"true",children:i.jsx(ne.ChevronDown,{size:20})})]}),u]})},B=({state:e,errorMessage:t})=>i.jsx(k.$ee014567cb39d3f0$export$ff05c3ac10437e03.Provider,{value:{...e.displayValidation},children:i.jsx(k.FieldError,{children:t})}),qe=F.forwardRef(({isClearable:e=!0,popover:t,...r},s)=>{const n={selectionMode:"single",errorPosition:"top",disallowEmptySelection:!e,isClearable:e,size:"large",popover:t,...r},o=E.$df56164dff5785e2$export$4338b53315abf666(s),l=je(n),a=N.useLocalizedStringFormatter(D),{labelProps:c,triggerProps:u,valueProps:d,menuProps:y}=ve(n,l,o),{width:x}=Ce(o.current,{includePadding:!0});return i.jsxs(R.$bcdf0525bf22703d$export$2c73285ae9390cec,{...n,className:q.clsx(g.wrapper,n.className),children:[i.jsx(Ke,{...n,state:l,triggerRef:o}),i.jsx(P.LabelWrapper,{popover:t,children:n.label&&i.jsx(P.Label,{...c,"data-disabled":n.isDisabled||void 0,children:n.label})}),n.description&&i.jsx(ee.Text,{slot:"description",children:n.description}),n.errorPosition==="top"&&i.jsx(B,{...n,state:l}),i.jsx(Be,{...n,...u,isInvalid:l.displayValidation.isInvalid,triggerRef:o,state:l,children:n.selectionMode==="multiple"&&l.selectedItems?i.jsx("span",{...d,children:i.jsx(Ve,{...n,state:l,parentWidth:x,onClear:()=>l.selectionManager.clearSelection(),triggerRef:o})}):null}),n.errorPosition==="bottom"&&i.jsx(B,{...n,state:l}),i.jsxs(C.ListBoxPopover,{isOpen:l.isOpen,onOpenChange:f=>{f||l.close()},triggerRef:o,style:{width:x},children:[n.isSelectableAll&&i.jsx(I.Checkbox,{isSelected:l.selectionManager.isSelectAll,isIndeterminate:!l.selectionManager.isSelectAll&&!l.selectionManager.isEmpty,className:g.selectAll,onChange:()=>l.selectionManager.toggleSelectAll(),children:a.format("selectAll")}),i.jsx($e,{...y,state:l})]}),n.showTags&&!!l.selectedItems&&i.jsx(S.TagGroup,{"aria-label":a.format("selectedItems"),selectionBehavior:"toggle",onRemove:f=>l.selectionManager.toggleSelection(Array.from(f)[0]),className:g.tagGroup,children:i.jsx(S.$eaf9e70818b436db$export$f9fef0f55402315b,{items:l.selectedItems,children:f=>i.jsx(S.Tag,{textValue:f.textValue,id:f.key,dismissable:!0,isDisabled:n.isDisabled,children:f.textValue},f.key)})})]})}),O=F.forwardRef(({options:e,...t},r)=>i.jsx(qe,{...t,items:e,ref:r,children:s=>s.children?i.jsx(se,{items:s.children,title:s.name,children:n=>i.jsx(V,{textValue:n.textValue,children:n.name})},s.name):i.jsx(V,{textValue:s.textValue,children:s.name})}));O.displayName="Select";exports.Select=O;