@midas-ds/components 15.2.6 → 15.2.7

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