super-select-react 0.9.0 → 0.9.1
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 +8 -0
- package/README.md +20 -27
- package/dist/super-select-react.cjs +1 -1
- package/dist/super-select-react.d.ts +6 -0
- package/dist/super-select-react.js +20 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.9.1 - 2026-07-05
|
|
4
|
+
|
|
5
|
+
- Added a `useOptionSource` hook that creates a stable option source from a fetch function, keeping one source
|
|
6
|
+
instance across renders while always calling the latest fetch function.
|
|
7
|
+
- Added a development-only console warning when the `optionSource` prop changes identity on many renders in a short
|
|
8
|
+
time, which usually means the source is being recreated during render.
|
|
9
|
+
- Fix issue with aborted requests being cached
|
|
10
|
+
|
|
3
11
|
## 0.9.0 - 2026-07-04
|
|
4
12
|
|
|
5
13
|
First public release.
|
package/README.md
CHANGED
|
@@ -62,33 +62,26 @@ compact button group. `native` renders a real browser `<select>`.
|
|
|
62
62
|
If your options come from an API or other data source, pass an `optionSource`.
|
|
63
63
|
|
|
64
64
|
```tsx
|
|
65
|
-
import {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
})),
|
|
86
|
-
hasMore: data.hasMore,
|
|
87
|
-
};
|
|
88
|
-
},
|
|
89
|
-
}),
|
|
90
|
-
[],
|
|
91
|
-
);
|
|
65
|
+
import { SuperSelect, useOptionSource } from "super-select-react";
|
|
66
|
+
|
|
67
|
+
export function PersonSelect() {
|
|
68
|
+
const peopleSource = useOptionSource(async ({ values, search = "", offset = 0, limit = 100, signal }) => {
|
|
69
|
+
const query = values
|
|
70
|
+
? values.map((value) => `ids=${encodeURIComponent(value)}`).join("&")
|
|
71
|
+
: `search=${encodeURIComponent(search)}&offset=${offset}&limit=${limit}`;
|
|
72
|
+
const response = await fetch(`/api/people?${query}`, { signal });
|
|
73
|
+
if (!response.ok) {
|
|
74
|
+
throw new Error(`Unable to load people: ${response.status}`);
|
|
75
|
+
}
|
|
76
|
+
const data = await response.json();
|
|
77
|
+
return {
|
|
78
|
+
options: data.items.map((person: { id: string; name: string }) => ({
|
|
79
|
+
value: person.id,
|
|
80
|
+
label: person.name,
|
|
81
|
+
})),
|
|
82
|
+
hasMore: data.hasMore,
|
|
83
|
+
};
|
|
84
|
+
});
|
|
92
85
|
|
|
93
86
|
return <SuperSelect name="person" optionSource={peopleSource} />;
|
|
94
87
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require("react");c=s(c,1);let l=require("react/jsx-runtime");function u(...e){return e.filter(Boolean).join(` `)}function d({className:e,style:t,disabled:n,tabIndex:r,title:i,onClick:a,customization:o}){let s=o?.classNamePrefix??`super-select`,c=s.length>0?`${s}__`:``;return(0,l.jsx)(`button`,{type:`button`,className:u(`${c}btn-close`,e),style:t,disabled:n,onClick:a,tabIndex:r,title:i,children:(0,l.jsx)(`span`,{className:`${c}visually-hidden`,children:o?.content??(0,l.jsx)(l.Fragment,{children:`×`})})})}function f({customization:e,headerContent:t,footerContent:n,children:r,open:i,className:a,ref:o,...s}){let f=e?.classNamePrefix??`super-select`,p=f.length>0?`${f}__`:``,m=(0,c.useRef)(null),{onClose:h,onCancel:g,onClick:_,...v}=s,y=e?.closeButton?.component??d,b=(0,c.useCallback)(e=>{if(m.current=e,o){if(typeof o==`function`){o(e);return}o.current=e}},[o]);(0,c.useEffect)(()=>{let e=m.current;e&&(i&&!e.open&&e.showModal(),!i&&e.open&&e.close())},[i]);let x=(0,c.useCallback)(()=>{let e=m.current;e?.open&&e.close()},[]);return(0,l.jsx)(`dialog`,{...v,ref:b,"aria-modal":`true`,onClose:h,onCancel:e=>{g&&(e.preventDefault(),g())},onClick:_,className:u(`${p}modal`,`${p}border-0`,`${p}bg-transparent`,`${p}fade`,i?`${p}show`:void 0,i?`${p}d-block`:void 0,a),children:(0,l.jsx)(`div`,{className:u(`${p}modal-dialog`,`${p}modal-dialog-scrollable`,e?.dialog?.className),style:e?.dialog?.style,children:(0,l.jsxs)(`div`,{className:u(`${p}modal-content`,e?.content?.className),style:e?.content?.style,children:[(0,l.jsxs)(`div`,{className:u(`${p}modal-header`,e?.header?.className),style:e?.header?.style,children:[t,(0,l.jsx)(y,{className:e?.closeButton?.className,style:e?.closeButton?.style,title:e?.closeButton?.title,onClick:x,tabIndex:-1,customization:{classNamePrefix:f,content:e?.closeButton?.content}})]}),(0,l.jsx)(`div`,{className:u(`${p}modal-body`,e?.body?.className),style:e?.body?.style,children:r}),n&&(0,l.jsx)(`div`,{className:u(`${p}modal-footer`,e?.footer?.className),style:e?.footer?.style,children:n})]})})})}var p=`−`,m=`↻`;function h({className:e,style:t,onRetry:n,customization:r}){let i=r?.classNamePrefix??`super-select`,a=i.length>0?`${i}__`:``;return(0,l.jsxs)(`div`,{className:u(`${a}alert`,`${a}alert-info`,n&&`${a}alert-dismissible`,e),style:t,children:[r?.content??(0,l.jsx)(`span`,{"aria-hidden":!0,children:p}),` `,n&&(0,l.jsx)(`button`,{type:`button`,className:u(`${a}btn`,`${a}btn-outline-secondary`,`${a}btn-sm`,r?.retryButton?.className),style:r?.retryButton?.style,title:r?.retryButton?.title,onClick:n,children:r?.retryButton?.content??m})]})}var g=`+`;function _({className:e,style:t,disabled:n,onLoadMore:r,customization:i}){let a=i?.classNamePrefix??`super-select`,o=a.length>0?`${a}__`:``;return r?(0,l.jsx)(`button`,{type:`button`,className:u(`${o}btn`,`${o}btn-outline-secondary`,`${o}btn-sm`,e,i?.loadMoreButton?.className),style:t||i?.loadMoreButton?.style?{...t,...i?.loadMoreButton?.style}:void 0,title:i?.loadMoreButton?.title,onClick:r,disabled:n,children:i?.loadMoreButton?.content??g}):(0,l.jsx)(`div`,{className:u(`${o}text-body-secondary`,`${o}overflow-indicator`,e,i?.overflowIndicator?.className),style:t||i?.overflowIndicator?.style?{...t,...i?.overflowIndicator?.style}:void 0,title:i?.overflowIndicator?.title,children:i?.overflowIndicator?.content??(0,l.jsx)(l.Fragment,{children:`…`})})}function v(e){return Array.isArray(e)?e.map(String):typeof e==`string`&&e.length>0?[e]:typeof e==`number`?[String(e)]:[]}function y({autoComplete:e,autoFocus:t,className:n,disabled:r,form:i,id:a,multiple:o,name:s,required:d,style:f,tabIndex:p,title:m,options:h,value:g,onValueChange:_,onOptionClick:y,onOptionKeyDown:x,indicator:S,customization:C,ref:w,...T}){let E=C?.classNamePrefix??`super-select`,D=E.length>0?`${E}__`:``,O=(0,c.useRef)(null),[k,A]=(0,c.useState)(void 0),j=(0,c.useId)(),M=(0,c.useMemo)(()=>h.find(e=>e.hidden)?h.filter(e=>!e.hidden):h,[h]),N=(0,c.useMemo)(()=>b(M),[M]),P=(0,c.useMemo)(()=>N.length>1?N.flatMap(e=>e.options):M,[N,M]),F=(0,c.useMemo)(()=>{let e=v(g);return o?e:e.slice(0,1)},[o,g]),I=(0,c.useMemo)(()=>new Set(F),[F]),L=(0,c.useMemo)(()=>P.find(e=>!e.disabled)?.value,[P]),R=(0,c.useMemo)(()=>{if(!(p===void 0||p===-1))return o?L:P.find(e=>I.has(e.value)&&!e.disabled)?.value??L},[L,o,P,I,p]),z=(0,c.useMemo)(()=>new Set(P.map(e=>e.value)),[P]),B=(0,c.useMemo)(()=>s?F.filter(e=>!z.has(e)):[],[z,s,F]),V=(0,c.useMemo)(()=>{if(t)return P.find(e=>!(r||e.disabled))?.value},[t,r,P]),H=(0,c.useMemo)(()=>P.find(e=>e.value===k&&!e.disabled)?.value||P.find(e=>I.has(e.value)&&!e.disabled)?.value||L,[L,k,P,I]);(0,c.useEffect)(()=>{!H||k===void 0||O.current?.scrollIntoView({block:`nearest`})},[H,k]);let U=e=>{r||_(o?F.includes(e)?F.filter(t=>t!==e):[...F,e]:[e])},ee=o?s:s??`option-list-${j}`,W=T[`aria-label`]??s;return(0,l.jsxs)(`fieldset`,{ref:w,...T,id:a,role:o?`group`:`radiogroup`,"aria-label":W,"aria-disabled":r||void 0,"aria-required":d||void 0,disabled:r,className:u(`${D}list-group`,n),style:f,title:m,tabIndex:-1,children:[N.map((t,n)=>(0,l.jsxs)(`div`,{children:[t.label?(0,l.jsx)(`div`,{className:u(`${D}list-group-item`,`${D}list-group-item-secondary`,C?.groupHeader?.className),style:C?.groupHeader?.style,children:t.label}):null,t.options.map(t=>{let n=I.has(t.value),a=r||t.disabled;return(0,l.jsxs)(`label`,{ref:e=>{t.value===H?O.current=e:O.current===e&&(O.current=null)},className:u(`${D}list-group-item`,`${D}list-group-item-action`,n?`${D}active`:void 0,t.value===H?`${D}focus-ring`:void 0,a?`${D}disabled`:void 0,C?.optionItem?.className),style:C?.optionItem?.style,onClick:()=>{a||A(t.value)},children:[(0,l.jsx)(`input`,{type:o?`checkbox`:`radio`,name:ee,value:t.value,checked:n,disabled:a,form:i,autoComplete:e,autoFocus:t.value===V,tabIndex:p===void 0?void 0:p===-1?-1:t.value===R?p:-1,onClick:y,onKeyDown:x,onChange:()=>U(t.value),onFocus:()=>{a||A(t.value)},className:u(`${D}form-check-input`,`${D}me-1`)}),(0,l.jsx)(`span`,{className:`${D}form-check-label`,children:t.children??t.label})]},t.value)})]},t.label||`group-${n}`)),B.map(e=>(0,l.jsx)(`input`,{type:`hidden`,name:s,value:e,form:i,disabled:r},`hidden-selected-${e}`)),S?(0,l.jsx)(`div`,{className:u(`${D}list-group-item`),children:S}):null]})}function b(e){let t=[],n;for(let r of e){let e=r.groupLabel??``;if(n&&n.label===e){n.options.push(r);continue}if(n=t.find(t=>t.label===e),n){n.options.push(r);continue}n={label:e,options:[r]},t.push(n)}return t}var x=`⏳`,S=150;function C({className:e,style:t,title:n,inline:r,content:i,customization:a}){let o=a?.classNamePrefix??`super-select`,s=o.length>0?`${o}__`:``,d=r?`span`:`div`,[f,p]=(0,c.useState)(!1);return(0,c.useEffect)(()=>{let e=window.setTimeout(()=>p(!0),S);return()=>window.clearTimeout(e)},[]),(0,l.jsx)(d,{className:u(`${s}spinner-border`,`${s}spinner-border-sm`,`${s}fade`,f?`${s}show`:void 0,e),style:t,title:n,role:`status`,children:(0,l.jsx)(`span`,{className:`${s}visually-hidden`,children:i??(0,l.jsx)(l.Fragment,{children:x})})})}function w({className:e,style:t,search:n,onSearchChange:r,isSearching:i,disabled:a,ref:o,onKeyDown:s,customization:c}){let d=c?.classNamePrefix??`super-select`,f=d.length>0?`${d}__`:``,p=c?.pendingIndicator?.component??C;return(0,l.jsxs)(`div`,{className:u(`${f}input-group`,e),style:t,children:[(0,l.jsx)(`input`,{ref:o,type:`search`,value:n??``,onChange:e=>r(e.target.value),onKeyDown:s,className:`${f}form-control`,disabled:a,placeholder:c?.placeholder,title:c?.title,"aria-label":c?.title}),i&&(0,l.jsx)(`div`,{className:`${f}input-group-text`,children:(0,l.jsx)(p,{inline:!0,className:c?.pendingIndicator?.className,style:c?.pendingIndicator?.style,title:c?.pendingIndicator?.title,content:c?.pendingIndicator?.content,customization:c?{classNamePrefix:d}:void 0})})]})}var T=class{defaultQueryData;cacheByValue=new Map;getAll(){let e=new Map;if(this.defaultQueryData)for(let t of this.defaultQueryData.options)e.set(t.value,t);for(let t of this.cacheByValue.values())e.set(t.value,t);return Array.from(e.values())}getByValue(e){let t=this.cacheByValue.get(e);return!t&&this.defaultQueryData&&(t=this.defaultQueryData.options.find(t=>t.value===e)),t}hasDefault(){return!!this.defaultQueryData}getByPageQuery(e){if(!this.defaultQueryData||e&&(e.search||e.offset&&e.offset>0||e.after))return;let t=this.defaultQueryData.options,n=this.defaultQueryData.hasMore;if(e?.limit!==void 0){if(this.defaultQueryData.limit!==void 0&&this.defaultQueryData.limit<e.limit)return;e.limit<t.length&&(t=t.slice(0,e.limit),n=!0)}return{options:t,hasMore:n}}tryResolveValues(e){if(!e||this.cacheByValue.size===0&&!this.defaultQueryData)return{options:void 0,missingValues:e};let t=[],n=[];for(let r of e){let e=this.getByValue(r);e?t.push(e):n.push(r)}return{options:t,missingValues:n}}set(e){if(e)for(let t of e){if(this.cacheByValue.size>=1e3)break;this.cacheByValue.set(t.value,t)}}setQueryResult(e,t){return(!t||!t.search&&!t.offset&&!t.after)&&e.options&&e.options.length>0?(this.defaultQueryData={options:e.options,hasMore:e.hasMore,limit:t?.limit},!0):!1}clear(){this.defaultQueryData=void 0,this.cacheByValue.clear()}},E=class{fetcher;runChain=Promise.resolve();pendingQueryRuns=[];constructor(e){this.fetcher=e}fetch(e){let t=e?.signal,n={...e,values:e?.values?[...e.values]:void 0};for(let e=0;e<this.pendingQueryRuns.length;e++){let r=this.pendingQueryRuns[e],i=r.query.values,a=n.values,o=!1;if(i===a)o=!0;else if(i&&a&&i.length===a.length){o=!0;for(let e=0;e<i.length;e++)if(i[e]!==a[e]){o=!1;break}}if(r.query.search===n.search&&r.query.offset===n.offset&&r.query.after===n.after&&r.query.limit===n.limit&&o)return this.createSubscriberPromise(r,n,t);let s=!!r.query.values&&!r.query.search&&r.query.offset===void 0&&r.query.after===void 0&&r.query.limit===void 0,c=!!n.values&&!n.search&&n.offset===void 0&&n.after===void 0&&n.limit===void 0;if((e>0||!r.started)&&s&&c){let e=Array.from(new Set([...r.query.values,...n.values]));return e.length!==r.query.values.length&&(r.query={values:e}),this.createSubscriberPromise(r,n,t)}}let r=new AbortController,i={query:n,promise:Promise.resolve({options:[]}),abortController:r,subscribers:new Set,started:!1},a=this.runSequentially(()=>(i.started=!0,this.fetcher({...i.query,signal:r.signal})));i.promise=a,this.pendingQueryRuns.push(i);let o=()=>{let e=this.pendingQueryRuns.findIndex(e=>e.promise===a);e>=0&&this.pendingQueryRuns.splice(e,1)};return a.then(o,o),this.createSubscriberPromise(i,n,t)}createSubscriberPromise(e,t,n){let r={query:t,signal:n,aborted:!1};e.subscribers.add(r);let i,a=new Promise((t,a)=>{if(n){if(i=()=>{r.aborted=!0,this.abortUnderlyingRequestIfUnused(e),a(new DOMException(`The operation was aborted.`,`AbortError`))},n.aborted){i();return}n.addEventListener(`abort`,i,{once:!0})}});return(n?Promise.race([e.promise,a]):e.promise).then(e=>this.filterResultForSubscriber(e,r.query)).finally(()=>{e.subscribers.delete(r),n&&i&&n.removeEventListener(`abort`,i),this.abortUnderlyingRequestIfUnused(e)})}filterResultForSubscriber(e,t){if(!t.values||t.search||t.offset!==void 0||t.after!==void 0||t.limit!==void 0)return e;let n=new Set(t.values),r=new Map(t.values.map((e,t)=>[e,t]));return{...e,options:e.options.filter(e=>n.has(e.value)).sort((e,t)=>(r.get(e.value)??0)-(r.get(t.value)??0))}}abortUnderlyingRequestIfUnused(e){if(e.subscribers.size===0){e.abortController.abort();return}Array.from(e.subscribers).every(e=>e.aborted)&&e.abortController.abort()}runSequentially(e){let t=this.runChain.then(e,e);return this.runChain=t.then(()=>void 0,()=>void 0),t}},D=class extends Error{userMessage;code;httpStatus;constructor(e,t){super(e,{cause:t?.cause}),this.name=`OptionSourceError`,this.userMessage=t?.userMessage,this.code=t?.code,this.httpStatus=t?.httpStatus,this.cause=t?.cause}};function O(e){return e instanceof D?!0:!(!e||typeof e!=`object`||`message`in e&&typeof e.message!=`string`&&e.message!==void 0||`userMessage`in e&&typeof e.userMessage!=`string`&&e.userMessage!==void 0||`code`in e&&typeof e.code!=`string`&&e.code!==void 0||`httpStatus`in e&&typeof e.httpStatus!=`number`&&e.httpStatus!==void 0)}var k=`An error occurred fetching options`;function A(e){if(e instanceof D)return e;if(!e)return new D(k);if(typeof e==`string`)return new D(e);if(typeof e!=`object`)return new D(k);if(`name`in e&&e.name===`AbortError`)return e;let t;t=`message`in e&&typeof e.message==`string`?e.message??k:k;let n;if(O(e)?n=e:(n={},`userMessage`in e&&typeof e.userMessage==`string`&&(n.userMessage=e.userMessage),`code`in e&&typeof e.code==`string`&&(n.code=e.code),`httpStatus`in e&&typeof e.httpStatus==`number`&&(n.httpStatus=e.httpStatus),`cause`in e&&(n.cause=e.cause)),n.httpStatus&&!n.code){let e;n.httpStatus===401?e=`unauthorized`:n.httpStatus===403?e=`forbidden`:n.httpStatus===404?e=`not-found`:n.httpStatus===408?e=`timeout`:n.httpStatus===429?e=`rate-limited`:n.httpStatus>=500&&n.httpStatus<=599&&(e=`server`),e&&(n={...n,code:e})}return e instanceof Error&&(!n.cause||e.cause===n.cause)&&(n={...n,cause:e}),new D(t,n)}var j=class e{innerFetcher;fetcher;cache;constructor(e){this.innerFetcher=e.fetch,this.fetcher=new E(this.innerFetcher),this.cache=e.noCache?void 0:new T}async getOptionPage(e){if(this.cache){let t=this.cache.getByPageQuery(e);if(t)return{...t,nextPage:this.createFetchNextPage(t,e)}}try{let t=await this.fetcher.fetch(e);return this.cache&&this.cache.setQueryResult(t,e),{...t,nextPage:this.createFetchNextPage(t,e)}}catch(e){throw A(e)}}createFetchNextPage(e,t){if(!e||e.hasMore!==!0)return;let n=(t?.offset??0)+e.options.length,r=e.options.length>0?e.options[e.options.length-1]:void 0,i={search:t?.search,offset:n,after:r,limit:t?.limit};return e=>this.getOptionPage({...i,limit:e?.limit??i.limit,signal:e?.signal})}async resolveValues(e,t){if(!e||e.length===0)return[];let n=Array.from(new Set(e)),r=n,i;if(this.cache){if(!this.cache.hasDefault())try{let e=await this.fetcher.fetch({signal:t});this.cache.setQueryResult(e,void 0)}catch(e){if(t?.aborted)throw A(e)}let{options:e,missingValues:n}=this.cache.tryResolveValues(r);e&&(i=e,r=n)}let a=[];if(r&&r.length>0){let e=new Set(r),n={values:r,signal:t};for(;e.size>0;){let i;try{i=await this.fetcher.fetch(n)}catch(e){throw A(e)}let o=i.options,s=0;for(let t of o)e.delete(t.value)&&(a.push(t),s++);if(i.hasMore!==!0||s===0)break;n={values:r,offset:(n.offset??0)+o.length,after:o[o.length-1],signal:t}}this.cache&&this.cache.set(a)}let o=new Map([...i??[],...a].map(e=>[e.value,e]));return n.flatMap(e=>{let t=o.get(e);return t?[t]:[]})}getCachedOptions(){return this.cache?.getAll()}clearCache(){this.cache?.clear()}withNoCache(){return this.cache?new e({fetch:this.innerFetcher,noCache:!0}):this}};function M(e){if(typeof e==`function`)return new j({fetch:e});if(N(e))return e;if(P(e))return new j(e);throw Error(`Invalid option source init.`)}function N(e){return!e||typeof e!=`object`?!1:`getOptionPage`in e&&typeof e.getOptionPage==`function`&&`resolveValues`in e&&typeof e.resolveValues==`function`}function P(e){return!e||typeof e!=`object`?!1:`fetch`in e&&typeof e.fetch==`function`}function F(e,t){let n=[],r=new Set;for(let t of e)r.has(t.value)||(r.add(t.value),n.push(t));for(let e of t)r.has(e.value)||(r.add(e.value),n.push(e));return n}var I=2,L=250;function R({optionSource:e,staticOptions:t,searchMatcher:n,maxAdditionalPages:r=I,value:i,defaultValue:a,multiple:o,isOptionListActive:s=!0}){let l=s&&!!e,u=i!==void 0,[d,f]=(0,c.useState)(()=>{let e=v(u?i:a);return o?e:e.slice(0,1)}),p=(0,c.useMemo)(()=>{let e=v(u?i:d);return o?e:e.slice(0,1)},[u,o,d,i]),[m,h]=(0,c.useState)(``),[g,_]=(0,c.useState)(()=>l?``:void 0),[y,b]=(0,c.useState)({items:[],result:void 0,error:void 0,isPending:l,additionalPagesLoaded:0,lastAttemptedQuery:l?{search:void 0,initiatedBySearch:!1}:void 0}),[x,S]=(0,c.useState)(0),[C,w]=(0,c.useState)(()=>[...p]),[T,E]=(0,c.useState)({key:``,options:[],error:void 0}),[D,O]=(0,c.useState)(!1),k=(0,c.useRef)(void 0),j=(0,c.useRef)(void 0),M=(0,c.useRef)(void 0),N=(0,c.useRef)(new Map),P=(0,c.useRef)({isOptionListActive:s,optionSource:e}),R=(0,c.useMemo)(()=>JSON.stringify(p),[p]),z=s&&!!e&&g===void 0&&y.result===void 0&&y.error===void 0,H=!z&&!y.isPending&&y.error===void 0,U=y.error!==void 0,ee=(0,c.useCallback)(e=>{let t=o?e:e.slice(0,1);u||f(t)},[u,o]);(0,c.useEffect)(()=>{let t=P.current,n=s!==t.isOptionListActive,r=e!==t.optionSource;if(!n&&!r)return;P.current={isOptionListActive:s,optionSource:e},(!s||r)&&(k.current?.abort(),k.current=void 0,j.current?.abort(),j.current=void 0);let i=!1;return queueMicrotask(()=>{if(!i){if(!s){b(e=>({...e,isPending:!1}));return}if(h(``),w(p),_(``),e){b(e=>({...e,items:[],result:void 0,error:void 0,isPending:!0,additionalPagesLoaded:0,lastAttemptedQuery:{search:void 0,initiatedBySearch:!1}}));return}b(e=>({...e,error:void 0,isPending:!1}))}}),()=>{i=!0}},[s,e,p]),(0,c.useEffect)(()=>{if(!s||m===g)return;let t=window.setTimeout(()=>{e&&(b(e=>({...e,isPending:!0,error:void 0,lastAttemptedQuery:{search:m||void 0,initiatedBySearch:!0}})),S(e=>e+1)),_(m)},L);return()=>{window.clearTimeout(t)}},[g,s,e,m]),(0,c.useEffect)(()=>{if(!s||!e||g===void 0)return;let t=!1;k.current?.abort();let n=new AbortController;k.current=n;let r=g?{search:g,signal:n.signal}:{signal:n.signal};return e.getOptionPage(r).then(e=>{t||b(t=>({...t,items:e.options,result:e,error:void 0,isPending:!1,additionalPagesLoaded:0}))}).catch(e=>{t||n.signal.aborted||b(t=>({...t,items:[],result:void 0,isPending:!1,error:A(e)}))}),()=>{t=!0,n.abort(),k.current===n&&(k.current=void 0)}},[g,s,e,x]);let W=(0,c.useCallback)(e=>{w(e=>{if(p.length===0)return e;let t=[...e],n=new Set(e);for(let e of p)n.has(e)||(n.add(e),t.push(e));return t}),h(e)},[p]),te=(0,c.useCallback)(()=>{!e||!s||(b(e=>({...e,items:[],result:void 0,error:void 0,isPending:!0,additionalPagesLoaded:0,lastAttemptedQuery:{search:g,initiatedBySearch:!!e.lastAttemptedQuery?.initiatedBySearch}})),S(e=>e+1),_(e=>e??``))},[g,s,e]),G=!!y.result?.nextPage&&y.additionalPagesLoaded<r&&y.items.length>0&&H&&!y.isPending,K=!!y.result?.nextPage&&y.items.length>0&&H,ne=(0,c.useCallback)(()=>{if(!y.result?.nextPage||!G||y.isPending)return;b(e=>({...e,isPending:!0,lastAttemptedQuery:{search:g,initiatedBySearch:!1}})),j.current?.abort();let e=new AbortController;j.current=e,y.result.nextPage({signal:e.signal}).then(t=>{j.current===e&&b(e=>({...e,items:[...e.items,...t.options],result:t,additionalPagesLoaded:e.additionalPagesLoaded+1,error:void 0,isPending:!1}))}).catch(t=>{e.signal.aborted||j.current!==e||b(e=>({...e,error:A(t),isPending:!1}))}).finally(()=>{j.current===e&&(j.current=void 0)})},[G,g,y.isPending,y.result]);(0,c.useEffect)(()=>{let e=new Map;for(let n of t)e.has(n.value)||e.set(n.value,n);N.current=e},[e,t]);let q=g??``,J=(0,c.useMemo)(()=>B(t.find(e=>e.hidden)?t.filter(e=>!e.hidden):t,q,n),[q,n,t]),Y=(0,c.useMemo)(()=>{if(!e)return J;let t=y.items.find(e=>e.hidden)?y.items.filter(e=>!e.hidden):y.items;return F(J,t)},[J,e,y.items]);(0,c.useEffect)(()=>{if(!(!e||Y.length===0))for(let e of Y)N.current.has(e.value)||N.current.set(e.value,e)},[e,Y]),(0,c.useEffect)(()=>{if(!e||p.length===0)return;let t=!1;M.current?.abort();let n=new AbortController;M.current=n;let r=JSON.stringify(p),i=N.current,a=new Map;for(let e of p){let t=i.get(e);t&&a.set(e,t)}let o=p.filter(e=>!a.has(e));if(o.length===0){M.current=void 0,queueMicrotask(()=>{t||(O(!1),E({key:r,options:p.map(e=>a.get(e)).filter(e=>e!==void 0),error:void 0}))});return}return queueMicrotask(()=>{O(!0)}),e.resolveValues(o,n.signal).then(e=>{if(t)return;let n=new Map(e.map(e=>[e.value,e]));for(let t of e)i.set(t.value,t);let o=p.map(e=>a.get(e)??n.get(e)).filter(e=>e!==void 0),s=p.filter(e=>!n.has(e)).filter(e=>!a.has(e));O(!1),E({key:r,options:o,error:s.length>0?A(Error()):void 0})}).catch(e=>{t||n.signal.aborted||(O(!1),E({key:r,options:[],error:A(e)}))}),()=>{t=!0,n.abort(),M.current===n&&(M.current=void 0)}},[e,p]);let re=(0,c.useMemo)(()=>{if(e)return p.length===0||T.key!==R?[]:T.options;let n=new Map(t.map(e=>[e.value,e]));return p.map(e=>n.get(e)||{value:e,label:``,disabled:!1})},[e,T.key,T.options,p,R,t]),ie=(0,c.useMemo)(()=>{if(U)return y.error??A()},[U,y.error]),X=q.trim().length>0&&!(y.isPending&&y.lastAttemptedQuery?.initiatedBySearch),ae=(0,c.useMemo)(()=>{if(C.length===0)return[];let e=new Set(C),t=new Map;for(let n of Y)e.has(n.value)&&t.set(n.value,n);for(let n of re)e.has(n.value)&&t.set(n.value,n);return C.map(e=>t.get(e)).filter(e=>e!==void 0)},[re,C,Y]),Z=(0,c.useMemo)(()=>ie&&(y.lastAttemptedQuery?.initiatedBySearch||Y.length===0)?[]:V(Y,C,e?ae:void 0,X),[X,e,ie,y.lastAttemptedQuery?.initiatedBySearch,ae,C,Y]),oe=(0,c.useMemo)(()=>{if(!(!e||p.length===0||T.key!==R||T.error===void 0))return T.error},[e,T.error,T.key,p.length,R]),Q=s&&!!e&&(z||y.isPending),se=Q&&!!y.lastAttemptedQuery?.initiatedBySearch,$=!!e&&p.length>0&&D;return(0,c.useEffect)(()=>()=>{k.current?.abort(),j.current?.abort(),M.current?.abort()},[]),{searchValue:m,selectedValues:p,options:Z,isOptionsPending:Q,isSearching:se,isResolveValuesPending:$,optionsError:ie,resolveValuesError:oe,canLoadMore:G,hasMore:K,handleSelectedValuesChange:ee,handleSearchChange:W,handleRetryOptions:e?te:void 0,handleLoadMore:ne}}function z(e,t){let n=t.trim().toLowerCase();return n?e.label.toLowerCase().includes(n):!0}function B(e,t,n){return t.trim()?n?e.filter(e=>n(e,t)):e.filter(e=>z(e,t)):e}function V(e,t,n,r){if(!t||t.length===0||r)return e;let i=new Set(t),a=e.filter(e=>i.has(e.value)),o=new Set(a.map(e=>e.value)),s=[];for(let e of n??[])!i.has(e.value)||o.has(e.value)||(o.add(e.value),s.push(e));let c=e.filter(e=>!o.has(e.value));return a.length===0&&s.length===0?e:[...a,...s,...c]}function H(e){let{value:t,disabled:n,...r}=e;return{addEventListener:()=>void 0,removeEventListener:()=>void 0,dispatchEvent:()=>!0,...U(t),disabled:n??!1,...r}}function U(e){let t,n=[];typeof e==`string`?(t=e,n.push({value:e,label:``,selected:!0,disabled:!1})):Array.isArray(e)?(t=e[0]??``,n.push(...e.map(e=>({value:e,label:``,selected:!0,disabled:!1})))):t=``;let r=Object.assign(n,{selectedIndex:n.length>0?0:-1,item:e=>n[e]??null,namedItem:()=>null,length:n.length,[Symbol.iterator]:n[Symbol.iterator].bind(n)});return{value:t,selectedOptions:r}}function ee(e){return G(`change`,e)}function W(e,t){let n=G(`input`,e),r={...n.nativeEvent,data:t.data,dataTransfer:null,detail:0,inputType:`insertText`,isComposing:!1,view:null,which:0,getTargetRanges:()=>[],initUIEvent:()=>void 0};return{...n,nativeEvent:r,data:t.data}}function te(e){return G(`invalid`,e)}function G(e,t){let n=e,r=!1,i=!0,a=!0,o={get type(){return n},currentTarget:t,target:t,get cancelable(){return a},get defaultPrevented(){return r},preventDefault(){r=!0},get bubbles(){return i},stopPropagation(){i=!1},eventPhase:Event.NONE,isTrusted:!0,timeStamp:Date.now(),get cancelBubble(){return!i},set cancelBubble(e){i=!e},composed:!1,get returnValue(){return!r},set returnValue(e){r=!e},srcElement:t,composedPath(){return[t]},initEvent(e,t,r){n=e,i=t??!1,a=r??!0},stopImmediatePropagation(){i=!1},AT_TARGET:Event.AT_TARGET,BUBBLING_PHASE:Event.BUBBLING_PHASE,CAPTURING_PHASE:Event.CAPTURING_PHASE,NONE:Event.NONE};return{get type(){return n},currentTarget:t,target:t,get cancelable(){return a},get defaultPrevented(){return r},preventDefault(){r=!0},get bubbles(){return i},stopPropagation(){i=!1},eventPhase:Event.NONE,isTrusted:!0,timeStamp:o.timeStamp,nativeEvent:o,isDefaultPrevented(){return r},isPropagationStopped(){return!i},persist:()=>void 0}}function K(e,t){let n=Object.create(e);return Object.defineProperties(n,{currentTarget:{get(){return t}},target:{get(){return t}}}),n}function ne(e,t){let n={};for(let r of Object.keys(t)){let i=t[r];typeof i==`function`&&(n[r]=(t=>{i(K(t,e))}))}return n}var q=`⚠`,J=`↻`;function Y({className:e,style:t,message:n,inline:r,onRetry:i,customization:a}){let o=a?.classNamePrefix??`super-select`,s=o.length>0?`${o}__`:``;return(0,l.jsxs)(r?`span`:`div`,{className:u(`${s}alert`,`${s}alert-danger`,i&&`${s}alert-dismissible`,r&&`${s}d-block`,e),style:t,children:[a?.icon??(0,l.jsx)(`span`,{"aria-hidden":!!n,children:q}),` `,n&&(0,l.jsx)(l.Fragment,{children:n}),` `,i&&(0,l.jsx)(`button`,{type:`button`,className:u(`${s}btn`,`${s}btn-outline-secondary`,`${s}btn-sm`,a?.retryButton?.className),style:a?.retryButton?.style,title:a?.retryButton?.title,onClick:i,children:a?.retryButton?.content??J})]})}function re({form:e,onReset:t}){let n=(0,c.useRef)(null);return(0,c.useEffect)(()=>{let e=n.current?.form,r=e?.ownerDocument.defaultView;if(!e||!r)return;let i=n=>{n.target===e&&!n.defaultPrevented&&t()};return r.addEventListener(`reset`,i),()=>r.removeEventListener(`reset`,i)},[e,t]),(0,l.jsx)(`input`,{ref:n,type:`hidden`,form:e})}function ie(e){return X(e,new Set)}function X(e,t){let n=[];for(let r of c.Children.toArray(e))if((0,c.isValidElement)(r)){if(r.type===c.Fragment){let e=r;n.push(...X(e.props.children,t));continue}if(r.type===`option`){let e=r,i=Z(e.props.children),a=e.props.value===void 0?i:String(e.props.value);if(t.has(a))continue;t.add(a);let o=e.props.label===void 0?i:String(e.props.label),s=e.props,c=Object.entries(s).reduce((e,[t,n])=>(!t.startsWith(`data-`)||n===void 0||(e[t.slice(5)]=n),e),{}),l=e.props.data===void 0?Object.keys(c).length>0?c:void 0:{...c,value:e.props.data};n.push({value:a,label:o,children:ae(e.props.children)?e.props.children:void 0,disabled:!!e.props.disabled,hidden:!!e.props.hidden,data:l});continue}if(r.type===`optgroup`){let e=r,i=String(e.props.label??``),a=c.Children.toArray(e.props.children);for(let e of a){let r=X(e,t);for(let e of r)e.groupLabel=i,n.push(e)}}}return n}function ae(e){return e==null||typeof e==`boolean`||typeof e==`string`||typeof e==`number`?!1:Array.isArray(e)?e.some(e=>ae(e)):!0}function Z(e){return e==null||typeof e==`boolean`?``:typeof e==`string`?e:typeof e==`number`?String(e):Array.isArray(e)?e.map(e=>Z(e)).join(``):(0,c.isValidElement)(e)?Z(e.props.children):``}function oe({ref:e,customization:t,children:n,className:r,...i}){let a=t?.classNamePrefix??`super-select`,o=a.length>0?`${a}__`:``;return(0,l.jsx)(`button`,{ref:e,type:`button`,className:u(`${o}form-select`,`${o}text-start`,r),...i,children:n})}var Q=`✓`;function se({className:e,style:t,disabled:n,title:r,onClick:i,customization:a}){let o=a?.classNamePrefix??`super-select`,s=o.length>0?`${o}__`:``;return(0,l.jsx)(`button`,{type:`button`,className:u(`${s}btn`,`${s}btn-secondary`,e),style:t,onClick:i,disabled:n,title:r,children:a?.content??Q})}function $({customization:e,selectedOptions:t,className:n,style:r}){let i=e?.classNamePrefix??`super-select`,a=i.length>0?`${i}__`:``;return t.length>1?(0,l.jsx)(`ul`,{className:u(`${a}list-inline`,`${a}d-inline`,n),style:r,children:t.map(e=>(0,l.jsx)(`li`,{className:`${a}list-inline-item`,children:e.children??e.label},e.value))}):(0,l.jsx)(`span`,{className:n,style:r,children:t[0]?.children??t[0]?.label??e?.placeholder??``})}function ce({optionSource:e,children:t,customization:n,ref:r,multiple:i,disabled:a,required:o,value:s,defaultValue:d,name:f,id:p,form:m,autoFocus:h,autoComplete:g,onInput:_,onInvalid:y,onChange:b,onValueChange:x,className:S,style:w,...T}){let[E,D]=(0,c.useState)(!1),[O,k]=(0,c.useState)(!1),A=(0,c.useMemo)(()=>ie(t),[t]),j=s!==void 0,M=(0,c.useRef)(d),N=R({optionSource:e,staticOptions:A,searchMatcher:n?.searchMatcher,maxAdditionalPages:n?.maxAdditionalPages,value:s,defaultValue:d,multiple:i,isOptionListActive:E}),P=(0,c.useCallback)(()=>{a||D(!0)},[a]),F=(0,c.useCallback)(()=>{D(!1)},[]),I=(0,c.useCallback)(()=>{if(j)return;let e=v(M.current);N.handleSelectedValuesChange(i?e:e.slice(0,1)),k(!1)},[N,j,i,k]),L=(0,c.useCallback)(e=>{if(a)return;N.handleSelectedValuesChange(e),(!o||e.length>0)&&k(!1);let t=H({id:p,name:f,value:i?e:e[0]??``,multiple:i,disabled:a,required:o});_&&_(W(t,{data:``})),b&&b(ee(t)),x&&x(i?e:e[0]??``)},[N,a,p,i,f,b,_,x,o,k]),z=(0,c.useCallback)(e=>{let t=Array.from(e.currentTarget.selectedOptions).map(e=>e?.value??``),n=i?t:t.length>0?[t[0]??``]:e.currentTarget.value===``?[]:[e.currentTarget.value];L(n)},[L,i]),B=(0,c.useMemo)(()=>{if(N.selectedValues.length===0)return[];let e=new Map;for(let t of A)e.has(t.value)||e.set(t.value,t);for(let t of N.options)e.set(t.value,t);let t=N.selectedValues.map(t=>e.get(t)).filter(e=>e!==void 0);return t.length>0?t:le(N.selectedValues,A)},[N.options,N.selectedValues,A]),V=(0,c.useMemo)(()=>H({id:p,name:f,value:i?N.selectedValues:N.selectedValues[0]??``,multiple:i,disabled:a,required:o}),[N.selectedValues,a,p,i,f,o]),U={...T,size:void 0},G=T[`aria-label`],K=T[`aria-labelledby`]??(G?void 0:p),q=ne(V,U),J=(0,c.useCallback)(e=>{P(),q.onClick?.(e)},[P,q]),X=(0,c.useCallback)(e=>{e.preventDefault(),k(!0),y&&y(te(V))},[V,y,k]),ae=O&&!!o&&N.selectedValues.length===0,Z=n?.classNamePrefix??`super-select`,Q=Z.length>0?`${Z}__`:``,se=(0,c.useMemo)(()=>A.find(e=>e.value===``)?.label,[A]),ce=n?.modalSelectButton?.selectedContent?.placeholder??se,de=B.length>0,fe=!!N.resolveValuesError,pe=fe||ae,me=n?.errorIndicator?.component??Y,he=n?.pendingIndicator?.component??C,ge=n?.modalSelectButton?.component??oe,_e=n?.modalSelectButton?.selectedContent?.component??$;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(ge,{...U,...q,id:p,autoFocus:h,"aria-haspopup":`dialog`,"aria-expanded":E,"aria-busy":N.isResolveValuesPending||void 0,"aria-invalid":pe||void 0,disabled:a,className:u(a?`${Q}disabled`:void 0,pe?`${Q}is-invalid`:void 0,S,n?.modalSelectButton?.className),style:w&&n?.modalSelectButton?.style?{...w,...n.modalSelectButton.style}:w??n?.modalSelectButton?.style,onClick:J,ref:r,customization:{classNamePrefix:Z},children:fe&&N.resolveValuesError?(0,l.jsx)(me,{inline:!0,className:n?.errorIndicator?.className,style:n?.errorIndicator?.style,error:N.resolveValuesError,message:N.resolveValuesError.userMessage??n?.errorIndicator?.defaultMessage,customization:{classNamePrefix:Z,icon:n?.errorIndicator?.icon}}):N.isResolveValuesPending?(0,l.jsx)(he,{inline:!0,className:n?.pendingIndicator?.className,style:n?.pendingIndicator?.style,title:n?.pendingIndicator?.title,content:n?.pendingIndicator?.content,customization:{classNamePrefix:Z}}):(0,l.jsx)(_e,{selectedOptions:B,className:u(!de||fe?`${Q}text-body-secondary`:void 0,n?.modalSelectButton?.selectedContent?.className),style:n?.modalSelectButton?.selectedContent?.style,customization:{classNamePrefix:Z,placeholder:ce}})}),(0,l.jsx)(ue,{customization:n,isOpen:E,dir:T.dir,lang:T.lang,ariaLabel:G,ariaLabelledBy:K,onClose:F,searchValue:N.searchValue,onSearchChange:N.handleSearchChange,options:N.options,selectedValues:N.selectedValues,multiple:i,isOptionsPending:N.isOptionsPending,isSearching:N.isSearching,isResolveValuesPending:N.isResolveValuesPending,onRefresh:N.handleRetryOptions,optionsError:N.optionsError,onOptionListChange:z,canLoadMore:N.canLoadMore,hasMore:N.hasMore,onLoadMore:N.handleLoadMore}),f||o?(0,l.jsx)(`select`,{name:f,form:m,autoComplete:g,...T,required:o,disabled:a,onInvalid:X,multiple:i,value:i?N.selectedValues:N.selectedValues[0]??``,onChange:()=>void 0,"aria-hidden":!0,hidden:!0,tabIndex:-1,className:`${Q}visually-hidden`,children:N.selectedValues.map(e=>(0,l.jsx)(`option`,{value:e,children:e},e))}):null,j?null:(0,l.jsx)(re,{form:m,onReset:I})]})}function le(e,t){if(e.length===0)return[];let n=new Map(t.map(e=>[e.value,e]));return e.map(e=>n.get(e)).filter(e=>e!==void 0)}function ue({customization:e,isOpen:t,dir:n,lang:r,ariaLabel:i,ariaLabelledBy:a,onClose:o,searchValue:s,onSearchChange:u,options:d,selectedValues:p,multiple:m,isOptionsPending:g,isSearching:b,isResolveValuesPending:x,onRefresh:S,optionsError:T,onOptionListChange:E,canLoadMore:D,onLoadMore:O,hasMore:k}){let A=e?.classNamePrefix??`super-select`,j=A.length>0?`${A}__`:``,M=e?.searchInput?.component??w,N=e?.modal?.okButton?.component??se,P=e?.modal?.component??f,F=e?.optionListInput?.component??y,I=e?.errorIndicator?.component??Y,L=e?.emptyIndicator?.component??h,R=e?.moreIndicator?.component??_,z=e?.pendingIndicator?.component??C,B=(0,c.useRef)(null),V=(0,c.useRef)(!1),U=!!b,W=!!(g||x),te=(0,c.useMemo)(()=>{let e=v(p);return m?e:e.slice(0,1)},[m,p]),G=d.length>0,K=W,ne=T,q=!!ne,J=!q&&!K&&!G,re=!q&&!K&&!J&&!!k;(0,c.useEffect)(()=>{if(!t)return;let e=B.current;if(!e)return;let n=window.setTimeout(()=>{e.focus()},0);return()=>{window.clearTimeout(n)}},[t]);let ie=(0,c.useCallback)(e=>{if(e.shiftKey||e.ctrlKey||e.altKey||e.metaKey)return;if(e.key===`Enter`){e.preventDefault();return}let t=e.key===`ArrowDown`?1:e.key===`ArrowUp`?-1:0;if(!t)return;let n=e.currentTarget.closest([`.${j}modal-content`,`[class*='modal-content']`,`[class*='modal-body']`,`dialog`,`[role='dialog']`,`[aria-modal='true']`].join(`,`))??e.currentTarget.parentElement;if(!n)return;let r=n.querySelector([`[role='listbox']`,`[role='radiogroup']`,`[role='group']`,`fieldset`,`[class*='modal-body']`].join(`,`))??n,i=Array.from(r.querySelectorAll([`input[type='radio']:not(:disabled):not([tabindex='-1'])`,`input[type='checkbox']:not(:disabled):not([tabindex='-1'])`,`[role='radio']:not([aria-disabled='true']):not([tabindex='-1'])`,`[role='checkbox']:not([aria-disabled='true']):not([tabindex='-1'])`,`[role='option']:not([aria-disabled='true']):not([tabindex='-1'])`].join(`,`))).filter(e=>{if(e.hidden||e.getAttribute(`aria-hidden`)===`true`)return!1;let t=window.getComputedStyle(e);return t.display!==`none`&&t.visibility!==`hidden`}),a=t>0?i[0]:i[i.length-1];a&&(e.preventDefault(),a.focus())},[j]),X=(0,c.useCallback)(e=>{if(E(e),!m){if(V.current){V.current=!1;return}o()}},[m,o,E]),ae=(0,c.useCallback)(e=>{let t=m?e:e.slice(0,1),n=H({value:m?t:t[0]??``,multiple:m});X(ee(n))},[X,m]),Z=(0,c.useCallback)(e=>{if(m||e.detail<=0)return;V.current=!1;let t=e.currentTarget,n;n=`checked`in t&&typeof t.checked==`boolean`?t.checked:`selected`in t&&typeof t.selected==`boolean`?t.selected:!1,n&&o()},[m,o]),oe=(0,c.useCallback)(e=>{if(!m){if(e.key===`ArrowDown`||e.key===`ArrowUp`||e.key===`ArrowLeft`||e.key===`ArrowRight`){V.current=!0;return}if(V.current=!1,e.key===`Enter`||e.key===` `||e.key===`Spacebar`){let t=e.currentTarget,n;n=`checked`in t&&typeof t.checked==`boolean`?t.checked:`selected`in t&&typeof t.selected==`boolean`?t.selected:!1,n&&(e.preventDefault(),e.stopPropagation(),o())}}},[m,o]),Q;return Q=K?(0,l.jsx)(z,{inline:!0,className:e?.pendingIndicator?.className,style:e?.pendingIndicator?.style,title:e?.pendingIndicator?.title,content:e?.pendingIndicator?.content,customization:{classNamePrefix:A}}):q?(0,l.jsx)(I,{className:e?.errorIndicator?.className,style:e?.errorIndicator?.style,error:ne,message:ne?.userMessage??e?.errorIndicator?.defaultMessage,onRetry:S,customization:{classNamePrefix:A,icon:e?.errorIndicator?.icon,retryButton:e?.errorIndicator?.retryButton}}):J?(0,l.jsx)(L,{className:e?.emptyIndicator?.className,style:e?.emptyIndicator?.style,onRetry:S,customization:{classNamePrefix:A,content:e?.emptyIndicator?.content,retryButton:e?.emptyIndicator?.retryButton}}):re?(0,l.jsx)(R,{onLoadMore:D?O:void 0,className:e?.moreIndicator?.className,style:e?.moreIndicator?.style,disabled:W,customization:{classNamePrefix:A,loadMoreButton:e?.moreIndicator?.loadMoreButton,overflowIndicator:e?.moreIndicator?.overflowIndicator}}):void 0,(0,l.jsx)(P,{open:t,dir:n,lang:r,"aria-label":i,"aria-labelledby":a,"aria-busy":g||x||void 0,className:e?.modal?.className,style:e?.modal?.style,customization:{classNamePrefix:A,dialog:e?.modal?.dialog,content:e?.modal?.content,header:e?.modal?.header,body:e?.modal?.body,footer:e?.modal?.footer,closeButton:e?.modal?.closeButton},onClose:()=>{o()},onCancel:o,onClick:e=>{e.target===e.currentTarget&&o()},headerContent:(0,l.jsx)(M,{ref:B,className:e?.searchInput?.className,style:e?.searchInput?.style,search:s,onSearchChange:e=>u(e??``),onKeyDown:ie,isSearching:U,customization:{classNamePrefix:A,placeholder:e?.searchInput?.placeholder,title:e?.searchInput?.title,pendingIndicator:{className:e?.pendingIndicator?.className,style:e?.pendingIndicator?.style,title:e?.pendingIndicator?.title,content:e?.pendingIndicator?.content,component:e?.pendingIndicator?.component}}}),footerContent:m?(0,l.jsx)(N,{className:e?.modal?.okButton?.className,style:e?.modal?.okButton?.style,title:e?.modal?.okButton?.title,onClick:o,customization:{classNamePrefix:A,content:e?.modal?.okButton?.content}}):void 0,children:(0,l.jsx)(F,{options:d,value:te,onValueChange:ae,multiple:m,form:``,onKeyDown:e=>{if(e.key===`Enter`&&e.preventDefault(),e.key===`ArrowDown`||e.key===`ArrowUp`||e.key===`ArrowLeft`||e.key===`ArrowRight`){V.current=!0;return}V.current=!1},onOptionClick:Z,onOptionKeyDown:oe,customization:{classNamePrefix:A,optionItem:e?.optionListInput?.optionItem,groupHeader:e?.optionListInput?.groupHeader},className:e?.optionListInput?.className,style:e?.optionListInput?.style,"aria-busy":W,indicator:Q})})}function de({searchInput:e,optionList:t,className:n,customization:r,ref:i,children:a,...o}){let s=r?.classNamePrefix??`super-select`;return(0,l.jsxs)(`div`,{ref:i,...o,className:u(s,n),children:[e,t,a]})}function fe({optionSource:e,children:t,customization:n,ref:r,onBlur:i,onFocus:a,onClick:o,onMouseDown:s,onMouseUp:d,onPointerDown:f,onPointerUp:p,onContextMenu:m,onKeyDown:g,onKeyUp:b,onBeforeInput:x,onSelect:S,onCompositionStart:T,onCompositionUpdate:E,onCompositionEnd:D,onChange:O,onInput:k,onInvalid:A,onValueChange:j,className:M,style:N,...P}){let F=(0,c.useMemo)(()=>ie(t),[t]),I=(0,c.useRef)(null),L=n?.searchInput?.component??w,z=n?.classNamePrefix??`super-select`,B=z.length>0?`${z}__`:``,{multiple:V,disabled:U,value:G,defaultValue:K}=P,q=G!==void 0,J=(0,c.useRef)(K),X=R({optionSource:e,staticOptions:F,searchMatcher:n?.searchMatcher,maxAdditionalPages:n?.maxAdditionalPages,value:G,defaultValue:K,multiple:V}),ae=(0,c.useCallback)(e=>{if(r){if(typeof r==`function`){r(e);return}r.current=e}},[r]),Z=(0,c.useMemo)(()=>V?X.selectedValues:X.selectedValues.slice(0,1),[X.selectedValues,V]),oe=(0,c.useCallback)(()=>{if(!q){let e=v(J.current);X.handleSelectedValuesChange(V?e:e.slice(0,1))}},[X,q,V]),Q=(0,c.useCallback)(e=>{e.preventDefault(),A&&A(te(H({id:P.id,name:P.name,value:V?Z:Z[0]??``,multiple:V,disabled:U,required:P.required})))},[U,V,A,P,Z]),se=(0,c.useMemo)(()=>H({id:P.id,name:P.name,value:V?Z:Z[0]??``,multiple:V,disabled:U,required:P.required}),[U,V,P.id,P.name,P.required,Z]),$={...P,value:void 0,defaultValue:void 0,size:void 0},ce=$,le=ne(se,{...$,onFocus:a,onBlur:i,onClick:o,onMouseDown:s,onMouseUp:d,onPointerDown:f,onPointerUp:p,onContextMenu:m,onKeyDown:g,onKeyUp:b,onBeforeInput:x,onSelect:S,onCompositionStart:T,onCompositionUpdate:E,onCompositionEnd:D}),ue=!!e,fe=X.isOptionsPending||X.isResolveValuesPending,pe=X.options.length>0,me=X.optionsError,he=!!me,ge=fe,_e=!he&&!ge&&!pe,ve=!he&&!ge&&!_e&&!!X.hasMore,ye=U||fe,be=n?.optionList?.component??de,xe=n?.optionListInput?.component??y,Se=n?.errorIndicator?.component??Y,Ce=n?.emptyIndicator?.component??h,we=n?.moreIndicator?.component??_,Te=n?.pendingIndicator?.component??C,Ee;Ee=ge?(0,l.jsx)(Te,{inline:!0,className:n?.pendingIndicator?.className,style:n?.pendingIndicator?.style,title:n?.pendingIndicator?.title,content:n?.pendingIndicator?.content,customization:{classNamePrefix:z}}):he?(0,l.jsx)(Se,{className:n?.errorIndicator?.className,style:n?.errorIndicator?.style,error:me,message:me?.userMessage??n?.errorIndicator?.defaultMessage,onRetry:X.handleRetryOptions,customization:{classNamePrefix:z,icon:n?.errorIndicator?.icon,retryButton:n?.errorIndicator?.retryButton}}):_e?(0,l.jsx)(Ce,{className:n?.emptyIndicator?.className,style:n?.emptyIndicator?.style,onRetry:X.handleRetryOptions,customization:{classNamePrefix:z,content:n?.emptyIndicator?.content,retryButton:n?.emptyIndicator?.retryButton}}):ve?(0,l.jsx)(we,{onLoadMore:X.canLoadMore?X.handleLoadMore:void 0,className:n?.moreIndicator?.className,style:n?.moreIndicator?.style,disabled:ye,customization:{classNamePrefix:z,loadMoreButton:n?.moreIndicator?.loadMoreButton,overflowIndicator:n?.moreIndicator?.overflowIndicator}}):void 0;let De=(0,c.useCallback)(e=>{let t=V?e:e.slice(0,1);X.handleSelectedValuesChange(t);let n=H({id:P.id,name:P.name,multiple:V,disabled:U,required:P.required,value:V?t:t[0]??``});k&&k(W(n,{data:``})),O&&O(ee(n)),j&&j(V?t:t[0]??``)},[X,U,V,O,k,j,P]),Oe=(0,c.useCallback)(e=>{if(e.shiftKey||e.ctrlKey||e.altKey||e.metaKey)return;let t=e.key===`ArrowDown`?1:e.key===`ArrowUp`?-1:0;if(!t)return;let n=I.current;if(!n)return;let r=n.querySelector([`[role='listbox']`,`[role='radiogroup']`,`[role='group']`,`fieldset`,`[class*='list-group']`].join(`,`))??n,i=Array.from(r.querySelectorAll([`input[type='radio']:not(:disabled):not([tabindex='-1'])`,`input[type='checkbox']:not(:disabled):not([tabindex='-1'])`,`[role='radio']:not([aria-disabled='true']):not([tabindex='-1'])`,`[role='checkbox']:not([aria-disabled='true']):not([tabindex='-1'])`,`[role='option']:not([aria-disabled='true']):not([tabindex='-1'])`].join(`,`))).filter(e=>{if(e.hidden||e.getAttribute(`aria-hidden`)===`true`)return!1;let t=window.getComputedStyle(e);return t.display!==`none`&&t.visibility!==`hidden`}),a=t>0?i[0]:i[i.length-1];a&&(e.preventDefault(),a.focus())},[]);return(0,l.jsxs)(be,{ref:I,className:u(n?.optionList?.className,M),style:N&&n?.optionList?.style?{...N,...n.optionList.style}:N??n?.optionList?.style,"aria-label":P[`aria-label`]??P.name,dir:P.dir,lang:P.lang,customization:{classNamePrefix:z},searchInput:ue?(0,l.jsx)(L,{className:n?.searchInput?.className,style:n?.searchInput?.style,search:X.searchValue,onSearchChange:e=>X.handleSearchChange(e??``),onKeyDown:Oe,disabled:U,isSearching:X.isSearching,customization:{classNamePrefix:z,placeholder:n?.searchInput?.placeholder,title:n?.searchInput?.title,pendingIndicator:{className:n?.pendingIndicator?.className,style:n?.pendingIndicator?.style,title:n?.pendingIndicator?.title,content:n?.pendingIndicator?.content,component:n?.pendingIndicator?.component}}}):void 0,optionList:(0,l.jsx)(xe,{...ce,...le,ref:ae,id:P.id,name:P.name,multiple:V,disabled:U,required:P.required,form:P.form,autoComplete:P.autoComplete,autoFocus:P.autoFocus,tabIndex:P.tabIndex,title:P.title,options:X.options,value:Z,onValueChange:De,className:n?.optionListInput?.className,style:n?.optionListInput?.style,customization:{classNamePrefix:z,optionItem:n?.optionListInput?.optionItem,groupHeader:n?.optionListInput?.groupHeader},"aria-busy":fe,indicator:Ee}),children:[P.required?(0,l.jsx)(`input`,{type:`checkbox`,checked:Z.length>0,required:!0,disabled:U,form:P.form,tabIndex:-1,"aria-hidden":!0,onChange:()=>void 0,onInvalid:Q,hidden:!0,className:`${B}visually-hidden`}):null,q?null:(0,l.jsx)(re,{form:P.form,onReset:oe})]})}function pe({autoComplete:e,autoFocus:t,className:n,customization:r,disabled:i,form:a,id:o,multiple:s,name:d,onValueToggle:f,options:p,value:m,required:h,style:g,tabIndex:_,title:v,ref:y,...b}){let x=r?.classNamePrefix??`super-select`,S=x.length>0?`${x}__`:``,C=(0,c.useMemo)(()=>new Set(m),[m]),w=(0,c.useMemo)(()=>p.find(e=>e.hidden)?p.filter(e=>!e.hidden):p,[p]),T=(0,c.useMemo)(()=>{if(t)return w.find(e=>!(i||e.disabled))?.value},[t,i,w]),E=(0,c.useMemo)(()=>me(w),[w]),D=b[`aria-label`]??d;return(0,l.jsx)(`fieldset`,{ref:y,...b,id:o,disabled:i,role:s?`group`:`radiogroup`,"aria-disabled":i||void 0,"aria-required":h||void 0,"aria-label":D,className:u(x,`${S}btn-toolbar`,n),style:g,title:v,tabIndex:_,children:E.map(({label:t,options:n})=>(0,l.jsx)(`div`,{className:u(`${S}btn-group`,r?.buttonGroup?.className),style:r?.buttonGroup?.style,children:n.map(t=>{let n=C.has(t.value),o=i||t.disabled,c=s?`checkbox`:`radio`;return(0,l.jsxs)(`label`,{className:u(`${S}btn`,`${S}btn-outline-secondary`,n&&`${S}active`,o&&`${S}disabled`,r?.button?.className),style:r?.button?.style,children:[(0,l.jsx)(`input`,{value:t.value,className:`${S}btn-check`,checked:n,autoComplete:e,autoFocus:t.value===T,disabled:o,form:a,name:d,type:c,onChange:()=>f(t.value),onClick:e=>{s||!n||o||(e.preventDefault(),window.setTimeout(()=>{f(t.value)},0))}}),(0,l.jsx)(`span`,{children:t.children??t.label})]},t.value)})},t))})}function me(e){let t=[],n;for(let r of e){let e=r.groupLabel??``;if(n&&n.label===e){n.options.push(r);continue}if(n=t.find(t=>t.label===e),n){n.options.push(r);continue}n={label:e,options:[r]},t.push(n)}return t}function he({autoComplete:e,autoFocus:t,children:n,className:r,customization:i,defaultValue:a,disabled:o,form:s,id:u,multiple:d,name:f,required:p,style:m,tabIndex:h,title:g,value:_,onChange:y,onInput:b,onValueChange:x,onInvalid:S,ref:C,...w}){let T=(0,c.useMemo)(()=>ie(n),[n]),E=_!==void 0,D=(0,c.useRef)(a),[O,k]=(0,c.useState)(()=>{let e=v(E?_:a);return d?e:e.slice(0,1)}),A=(0,c.useMemo)(()=>E?v(_):O,[O,E,_]),j=(0,c.useId)(),M=d?f:f??`_toggle-button-select-${j}`,N=i?.classNamePrefix??`super-select`,P=N.length>0?`${N}__`:``,F=(0,c.useCallback)(e=>H({id:u,name:f,multiple:d,disabled:o,required:p,value:d?e:e[0]}),[u,f,d,p,o]),I=(0,c.useCallback)(e=>{e.preventDefault(),S&&S(te(F(A)))},[F,S,A]),L=(0,c.useCallback)(()=>{if(!E){let e=v(D.current);k(d?e:e.slice(0,1))}},[E,d]),R=(0,c.useCallback)(e=>{if(o)return;let t;t=d?A.includes(e)?A.filter(t=>t!==e):[...A,e]:A.includes(e)?[]:[e],E||k(t);let n=F(t);b&&b(W(n,{data:``})),y&&y(ee(n)),x&&x(d?t:t[0]??``)},[F,o,E,d,y,b,x,A]),z=!!p,B=i?.component??pe,V={...w,size:void 0},U=V,G=ne(F(A),V);return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(B,{...U,...G,autoComplete:e,autoFocus:t,className:r,customization:i,disabled:o,form:s,id:u,multiple:d,name:M,value:A,onValueToggle:R,options:T,required:p,style:m,tabIndex:h,title:g,ref:C}),z?(0,l.jsx)(`input`,{type:`checkbox`,checked:A.length>0,required:!0,disabled:o,form:s,tabIndex:-1,"aria-hidden":!0,hidden:!0,onChange:()=>void 0,onInvalid:I,className:`${P}visually-hidden`}):null,E?null:(0,l.jsx)(re,{form:s,onReset:L})]})}function ge({"aria-busy":e,"aria-describedby":t,"aria-label":n,"aria-labelledby":r,accessKey:i,children:a,className:o,dir:s,hidden:c,id:d,lang:f,style:p,tabIndex:m,title:h,customization:g}){let _=g?.classNamePrefix??`super-select`,v=_.length>0?`${_}__`:``;return(0,l.jsx)(`div`,{id:d,"aria-busy":e,"aria-describedby":t,"aria-label":n,"aria-labelledby":r,accessKey:i,className:u(`${v}list-group`,o),dir:s,hidden:c,lang:f,style:p,tabIndex:m,title:h,children:(0,l.jsx)(`div`,{className:`${v}list-group-item`,children:a})})}function _e({mode:e,optionSource:t,customization:n,ref:r,children:i,multiple:a,disabled:o,required:s,value:d,defaultValue:f,onChange:p,onInvalid:m,onValueChange:h,className:g,style:_,...y}){let b=typeof e==`function`?void 0:e,x=typeof e==`function`?e:void 0,S=!!t&&(!!x||b!==void 0&&!be(b)),[w,T]=(0,c.useState)(0),E=(0,c.useMemo)(()=>({optionSource:t,retryCount:w,shouldLoadOptions:S}),[w,t,S]),[D,O]=(0,c.useState)(()=>S?we(E):Se);(0,c.useEffect)(()=>{if(!t||!S)return;let e=new AbortController,n=!1;return Promise.resolve().then(()=>{if(!(n||e.signal.aborted))return O(we(E)),t.getOptionPage({signal:e.signal})}).then(t=>{!t||n||e.signal.aborted||O({loadKey:E,options:t.options,hasMore:!!t.hasMore,isPending:!1,error:void 0})}).catch(t=>{n||e.signal.aborted||O({loadKey:E,options:[],hasMore:!1,isPending:!1,error:A(t)})}),()=>{n=!0,e.abort()}},[t,E,S]);let k=(0,c.useMemo)(()=>ie(i),[i]),j=Se;S&&(j=D.loadKey===E?D:we(E));let M=(0,c.useMemo)(()=>F(k,j.options),[j.options,k]),N=(0,c.useMemo)(()=>{if(b)return b;if(x){let e=x({options:M,hasMore:j.hasMore,multiple:!!a,disabled:!!o,required:!!s,optionSource:t,error:j.error});if(e)return e}return`modal`},[o,M,x,a,t,b,s,j.error,j.hasMore]),P=d!==void 0,I=(0,c.useRef)(f),[L,R]=(0,c.useState)(void 0),[z,B]=(0,c.useState)(0),V=(0,c.useCallback)(e=>{let t=Array.from(e.currentTarget.selectedOptions).map(e=>e?.value??``),n=[];a&&t.length>0?n=t:e.currentTarget.value&&e.currentTarget.value.length>0&&(n=[e.currentTarget.value]),P||R(a?n:n[0]??``),h&&h(a?n:n[0]??``),p&&p(e)},[P,a,p,h]),U=S&&!j.isPending&&j.error===void 0&&(!be(N)||!j.hasMore),ee=t&&be(N)&&!U?t:void 0,W=U?xe(i,k,j.options):i,G=L===void 0?f:L,K=(0,c.useMemo)(()=>{let e=v(P?d:G);return a?e:e.slice(0,1)},[G,P,a,d]),ne=(0,c.useCallback)(()=>{T(e=>e+1)},[]),q=(0,c.useCallback)(()=>{P||(R(I.current),B(e=>e+1))},[P]),J=n?.classNamePrefix??`super-select`,X=J.length>0?`${J}__`:``,ae=n?.fallback?.component??ge,Z=n?.pendingIndicator?.component??C,oe=n?.errorIndicator?.component??Y,Q=u(g,n?.fallback?.className),se=_&&n?.fallback?.style?{..._,...n.fallback.style}:_??n?.fallback?.style,$;S&&j.isPending?$=(0,l.jsx)(Z,{inline:!0,className:n?.pendingIndicator?.className,style:n?.pendingIndicator?.style,title:n?.pendingIndicator?.title,content:n?.pendingIndicator?.content,customization:{classNamePrefix:J}}):S&&j.error&&($=(0,l.jsx)(oe,{className:n?.errorIndicator?.className,style:n?.errorIndicator?.style,error:j.error,message:j.error.userMessage??n?.errorIndicator?.defaultMessage,onRetry:ne,customization:{classNamePrefix:J,icon:n?.errorIndicator?.icon,retryButton:n?.errorIndicator?.retryButton}}));let ce=y.name&&K.length>0?a?K.map((e,t)=>(0,l.jsx)(`input`,{type:`hidden`,name:y.name,value:e,form:y.form,disabled:o},`super-select-async-hidden-value-${e}-${t}`)):(0,l.jsx)(`input`,{type:`hidden`,name:y.name,value:K[0]??``,form:y.form,disabled:o}):null;return $?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(ae,{id:y.id,"aria-busy":j.isPending||void 0,"aria-describedby":y[`aria-describedby`],"aria-label":y[`aria-label`],"aria-labelledby":y[`aria-labelledby`],accessKey:y.accessKey,className:Q,dir:y.dir,hidden:y.hidden,lang:y.lang,style:se,tabIndex:y.tabIndex,title:y.title,customization:{classNamePrefix:J},children:$}),ce,s?(0,l.jsx)(`select`,{required:!0,disabled:o,form:y.form,multiple:a,value:a?K:K[0]??``,onChange:()=>void 0,onInvalid:e=>{e.preventDefault(),m&&m(te(H({id:y.id,name:y.name,value:a?K:K[0]??``,multiple:a,disabled:o,required:s})))},"aria-hidden":!0,tabIndex:-1,className:`${X}visually-hidden`,children:K.map(e=>(0,l.jsx)(`option`,{value:e,children:e},e))}):null,P?null:(0,l.jsx)(re,{form:y.form,onReset:q})]}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(ve,{ref:r,...y,mode:N,className:g,style:_,multiple:a,disabled:o,required:s,value:d,defaultValue:P?void 0:G,onChange:V,onInvalid:m,optionSource:ee,customization:n,children:W},z),P?null:(0,l.jsx)(re,{form:y.form,onReset:q})]})}function ve({mode:e,onChange:t,optionSource:n,customization:r,children:i,ref:a,...o}){let s=r?.classNamePrefix??`super-select`;if(e===`option-list`)return(0,l.jsx)(fe,{ref:a,...o,onChange:t,optionSource:n,customization:r,children:i});if(e===`toggle-button`)return(0,l.jsx)(he,{ref:a,...o,className:r?.toggleButtonInput?.className??o.className,style:o.style&&r?.toggleButtonInput?.style?{...o.style,...r.toggleButtonInput.style}:o.style??r?.toggleButtonInput?.style,onChange:t,customization:r?{classNamePrefix:s,...r.toggleButtonInput}:void 0,children:i});if(e===`native`){let e=s.length>0?`${s}__`:``,n=r?.selectInput?.component??ye,c=r?.selectInput?.className??o.className;return n===ye&&(c=u(`${e}form-select`,c)),(0,l.jsx)(n,{ref:a,...o,className:c,style:o.style&&r?.selectInput?.style?{...o.style,...r.selectInput.style}:o.style??r?.selectInput?.style,onChange:t,children:i})}return(0,l.jsx)(ce,{ref:a,...o,onChange:t,optionSource:n,customization:r,children:i})}function ye({ref:e,...t}){return(0,l.jsx)(`select`,{ref:e,...t})}function be(e){return e===`modal`||e===`option-list`}function xe(e,t,n){if(n.length===0)return e;let r=[],i=new Set(t.map(e=>e.value));for(let e of n)i.has(e.value)||(i.add(e.value),r.push(e));if(r.length===0)return e;let a=[],o=0,s=0;for(;o<r.length;){let e=r[o],t=e.groupLabel;if(!t){a.push((0,l.jsx)(`option`,{value:e.value,disabled:e.disabled,hidden:e.hidden,label:e.label,children:e.children??e.label},`super-select-async-option-${s}-${e.value}`)),o+=1,s+=1;continue}let n=[];for(;o<r.length&&r[o].groupLabel===t;)n.push(r[o]),o+=1,s+=1;a.push((0,l.jsx)(`optgroup`,{label:t,children:n.map((e,t)=>(0,l.jsx)(`option`,{value:e.value,disabled:e.disabled,hidden:e.hidden,label:e.label,children:e.children??e.label},`super-select-async-group-option-${s}-${t}-${e.value}`))},`super-select-async-group-${s}-${t}`))}if(!e)return a;let u=c.Children.toArray(e);return u.length===0?a:[...u,...a]}var Se={options:[],hasMore:!1,isPending:!1,error:void 0},Ce={options:[],hasMore:!1,isPending:!0,error:void 0};function we(e){return{...Ce,loadKey:e}}exports.CloseButton=d,exports.EmptyIndicator=h,exports.ErrorIndicator=Y,exports.Fallback=ge,exports.Modal=f,exports.ModalSelect=ce,exports.ModalSelectButton=oe,exports.MoreIndicator=_,exports.OkButton=se,exports.OptionList=de,exports.OptionListInput=y,exports.OptionListSelect=fe,exports.OptionSource=j,exports.OptionSourceError=D,exports.PendingIndicator=C,exports.SearchInput=w,exports.SelectedContent=$,exports.SuperSelect=_e,exports.ToggleButtonInput=pe,exports.ToggleButtonSelect=he,exports.convertToOptionSourceError=A,exports.createOptionSource=M,exports.isOptionSourceErrorLike=O;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require("react");c=s(c,1);let l=require("react/jsx-runtime");function u(...e){return e.filter(Boolean).join(` `)}function d({className:e,style:t,disabled:n,tabIndex:r,title:i,onClick:a,customization:o}){let s=o?.classNamePrefix??`super-select`,c=s.length>0?`${s}__`:``;return(0,l.jsx)(`button`,{type:`button`,className:u(`${c}btn-close`,e),style:t,disabled:n,onClick:a,tabIndex:r,title:i,children:(0,l.jsx)(`span`,{className:`${c}visually-hidden`,children:o?.content??(0,l.jsx)(l.Fragment,{children:`×`})})})}function f({customization:e,headerContent:t,footerContent:n,children:r,open:i,className:a,ref:o,...s}){let f=e?.classNamePrefix??`super-select`,p=f.length>0?`${f}__`:``,m=(0,c.useRef)(null),{onClose:h,onCancel:g,onClick:_,...v}=s,y=e?.closeButton?.component??d,b=(0,c.useCallback)(e=>{if(m.current=e,o){if(typeof o==`function`){o(e);return}o.current=e}},[o]);(0,c.useEffect)(()=>{let e=m.current;e&&(i&&!e.open&&e.showModal(),!i&&e.open&&e.close())},[i]);let x=(0,c.useCallback)(()=>{let e=m.current;e?.open&&e.close()},[]);return(0,l.jsx)(`dialog`,{...v,ref:b,"aria-modal":`true`,onClose:h,onCancel:e=>{g&&(e.preventDefault(),g())},onClick:_,className:u(`${p}modal`,`${p}border-0`,`${p}bg-transparent`,`${p}fade`,i?`${p}show`:void 0,i?`${p}d-block`:void 0,a),children:(0,l.jsx)(`div`,{className:u(`${p}modal-dialog`,`${p}modal-dialog-scrollable`,e?.dialog?.className),style:e?.dialog?.style,children:(0,l.jsxs)(`div`,{className:u(`${p}modal-content`,e?.content?.className),style:e?.content?.style,children:[(0,l.jsxs)(`div`,{className:u(`${p}modal-header`,e?.header?.className),style:e?.header?.style,children:[t,(0,l.jsx)(y,{className:e?.closeButton?.className,style:e?.closeButton?.style,title:e?.closeButton?.title,onClick:x,tabIndex:-1,customization:{classNamePrefix:f,content:e?.closeButton?.content}})]}),(0,l.jsx)(`div`,{className:u(`${p}modal-body`,e?.body?.className),style:e?.body?.style,children:r}),n&&(0,l.jsx)(`div`,{className:u(`${p}modal-footer`,e?.footer?.className),style:e?.footer?.style,children:n})]})})})}var p=`−`,m=`↻`;function h({className:e,style:t,onRetry:n,customization:r}){let i=r?.classNamePrefix??`super-select`,a=i.length>0?`${i}__`:``;return(0,l.jsxs)(`div`,{className:u(`${a}alert`,`${a}alert-info`,n&&`${a}alert-dismissible`,e),style:t,children:[r?.content??(0,l.jsx)(`span`,{"aria-hidden":!0,children:p}),` `,n&&(0,l.jsx)(`button`,{type:`button`,className:u(`${a}btn`,`${a}btn-outline-secondary`,`${a}btn-sm`,r?.retryButton?.className),style:r?.retryButton?.style,title:r?.retryButton?.title,onClick:n,children:r?.retryButton?.content??m})]})}var g=`+`;function _({className:e,style:t,disabled:n,onLoadMore:r,customization:i}){let a=i?.classNamePrefix??`super-select`,o=a.length>0?`${a}__`:``;return r?(0,l.jsx)(`button`,{type:`button`,className:u(`${o}btn`,`${o}btn-outline-secondary`,`${o}btn-sm`,e,i?.loadMoreButton?.className),style:t||i?.loadMoreButton?.style?{...t,...i?.loadMoreButton?.style}:void 0,title:i?.loadMoreButton?.title,onClick:r,disabled:n,children:i?.loadMoreButton?.content??g}):(0,l.jsx)(`div`,{className:u(`${o}text-body-secondary`,`${o}overflow-indicator`,e,i?.overflowIndicator?.className),style:t||i?.overflowIndicator?.style?{...t,...i?.overflowIndicator?.style}:void 0,title:i?.overflowIndicator?.title,children:i?.overflowIndicator?.content??(0,l.jsx)(l.Fragment,{children:`…`})})}function v(e){return Array.isArray(e)?e.map(String):typeof e==`string`&&e.length>0?[e]:typeof e==`number`?[String(e)]:[]}function y({autoComplete:e,autoFocus:t,className:n,disabled:r,form:i,id:a,multiple:o,name:s,required:d,style:f,tabIndex:p,title:m,options:h,value:g,onValueChange:_,onOptionClick:y,onOptionKeyDown:x,indicator:S,customization:C,ref:w,...T}){let E=C?.classNamePrefix??`super-select`,D=E.length>0?`${E}__`:``,O=(0,c.useRef)(null),[k,A]=(0,c.useState)(void 0),j=(0,c.useId)(),M=(0,c.useMemo)(()=>h.find(e=>e.hidden)?h.filter(e=>!e.hidden):h,[h]),N=(0,c.useMemo)(()=>b(M),[M]),P=(0,c.useMemo)(()=>N.length>1?N.flatMap(e=>e.options):M,[N,M]),F=(0,c.useMemo)(()=>{let e=v(g);return o?e:e.slice(0,1)},[o,g]),I=(0,c.useMemo)(()=>new Set(F),[F]),L=(0,c.useMemo)(()=>P.find(e=>!e.disabled)?.value,[P]),R=(0,c.useMemo)(()=>{if(!(p===void 0||p===-1))return o?L:P.find(e=>I.has(e.value)&&!e.disabled)?.value??L},[L,o,P,I,p]),z=(0,c.useMemo)(()=>new Set(P.map(e=>e.value)),[P]),B=(0,c.useMemo)(()=>s?F.filter(e=>!z.has(e)):[],[z,s,F]),V=(0,c.useMemo)(()=>{if(t)return P.find(e=>!(r||e.disabled))?.value},[t,r,P]),H=(0,c.useMemo)(()=>P.find(e=>e.value===k&&!e.disabled)?.value||P.find(e=>I.has(e.value)&&!e.disabled)?.value||L,[L,k,P,I]);(0,c.useEffect)(()=>{!H||k===void 0||O.current?.scrollIntoView({block:`nearest`})},[H,k]);let U=e=>{r||_(o?F.includes(e)?F.filter(t=>t!==e):[...F,e]:[e])},ee=o?s:s??`option-list-${j}`,W=T[`aria-label`]??s;return(0,l.jsxs)(`fieldset`,{ref:w,...T,id:a,role:o?`group`:`radiogroup`,"aria-label":W,"aria-disabled":r||void 0,"aria-required":d||void 0,disabled:r,className:u(`${D}list-group`,n),style:f,title:m,tabIndex:-1,children:[N.map((t,n)=>(0,l.jsxs)(`div`,{children:[t.label?(0,l.jsx)(`div`,{className:u(`${D}list-group-item`,`${D}list-group-item-secondary`,C?.groupHeader?.className),style:C?.groupHeader?.style,children:t.label}):null,t.options.map(t=>{let n=I.has(t.value),a=r||t.disabled;return(0,l.jsxs)(`label`,{ref:e=>{t.value===H?O.current=e:O.current===e&&(O.current=null)},className:u(`${D}list-group-item`,`${D}list-group-item-action`,n?`${D}active`:void 0,t.value===H?`${D}focus-ring`:void 0,a?`${D}disabled`:void 0,C?.optionItem?.className),style:C?.optionItem?.style,onClick:()=>{a||A(t.value)},children:[(0,l.jsx)(`input`,{type:o?`checkbox`:`radio`,name:ee,value:t.value,checked:n,disabled:a,form:i,autoComplete:e,autoFocus:t.value===V,tabIndex:p===void 0?void 0:p===-1?-1:t.value===R?p:-1,onClick:y,onKeyDown:x,onChange:()=>U(t.value),onFocus:()=>{a||A(t.value)},className:u(`${D}form-check-input`,`${D}me-1`)}),(0,l.jsx)(`span`,{className:`${D}form-check-label`,children:t.children??t.label})]},t.value)})]},t.label||`group-${n}`)),B.map(e=>(0,l.jsx)(`input`,{type:`hidden`,name:s,value:e,form:i,disabled:r},`hidden-selected-${e}`)),S?(0,l.jsx)(`div`,{className:u(`${D}list-group-item`),children:S}):null]})}function b(e){let t=[],n;for(let r of e){let e=r.groupLabel??``;if(n&&n.label===e){n.options.push(r);continue}if(n=t.find(t=>t.label===e),n){n.options.push(r);continue}n={label:e,options:[r]},t.push(n)}return t}var x=`⏳`,S=150;function C({className:e,style:t,title:n,inline:r,content:i,customization:a}){let o=a?.classNamePrefix??`super-select`,s=o.length>0?`${o}__`:``,d=r?`span`:`div`,[f,p]=(0,c.useState)(!1);return(0,c.useEffect)(()=>{let e=window.setTimeout(()=>p(!0),S);return()=>window.clearTimeout(e)},[]),(0,l.jsx)(d,{className:u(`${s}spinner-border`,`${s}spinner-border-sm`,`${s}fade`,f?`${s}show`:void 0,e),style:t,title:n,role:`status`,children:(0,l.jsx)(`span`,{className:`${s}visually-hidden`,children:i??(0,l.jsx)(l.Fragment,{children:x})})})}function w({className:e,style:t,search:n,onSearchChange:r,isSearching:i,disabled:a,ref:o,onKeyDown:s,customization:c}){let d=c?.classNamePrefix??`super-select`,f=d.length>0?`${d}__`:``,p=c?.pendingIndicator?.component??C;return(0,l.jsxs)(`div`,{className:u(`${f}input-group`,e),style:t,children:[(0,l.jsx)(`input`,{ref:o,type:`search`,value:n??``,onChange:e=>r(e.target.value),onKeyDown:s,className:`${f}form-control`,disabled:a,placeholder:c?.placeholder,title:c?.title,"aria-label":c?.title}),i&&(0,l.jsx)(`div`,{className:`${f}input-group-text`,children:(0,l.jsx)(p,{inline:!0,className:c?.pendingIndicator?.className,style:c?.pendingIndicator?.style,title:c?.pendingIndicator?.title,content:c?.pendingIndicator?.content,customization:c?{classNamePrefix:d}:void 0})})]})}var T=class{defaultQueryData;cacheByValue=new Map;getAll(){let e=new Map;if(this.defaultQueryData)for(let t of this.defaultQueryData.options)e.set(t.value,t);for(let t of this.cacheByValue.values())e.set(t.value,t);return Array.from(e.values())}getByValue(e){let t=this.cacheByValue.get(e);return!t&&this.defaultQueryData&&(t=this.defaultQueryData.options.find(t=>t.value===e)),t}hasDefault(){return!!this.defaultQueryData}getByPageQuery(e){if(!this.defaultQueryData||e&&(e.search||e.offset&&e.offset>0||e.after))return;let t=this.defaultQueryData.options,n=this.defaultQueryData.hasMore;if(e?.limit!==void 0){if(this.defaultQueryData.limit!==void 0&&this.defaultQueryData.limit<e.limit)return;e.limit<t.length&&(t=t.slice(0,e.limit),n=!0)}return{options:t,hasMore:n}}tryResolveValues(e){if(!e||this.cacheByValue.size===0&&!this.defaultQueryData)return{options:void 0,missingValues:e};let t=[],n=[];for(let r of e){let e=this.getByValue(r);e?t.push(e):n.push(r)}return{options:t,missingValues:n}}set(e){if(e)for(let t of e){if(this.cacheByValue.size>=1e3)break;this.cacheByValue.set(t.value,t)}}setQueryResult(e,t){return(!t||!t.search&&!t.offset&&!t.after)&&e.options&&e.options.length>0?(this.defaultQueryData={options:e.options,hasMore:e.hasMore,limit:t?.limit},!0):!1}clear(){this.defaultQueryData=void 0,this.cacheByValue.clear()}},E=class{fetcher;runChain=Promise.resolve();pendingQueryRuns=[];constructor(e){this.fetcher=e}fetch(e){let t=e?.signal,n={...e,values:e?.values?[...e.values]:void 0};for(let e=0;e<this.pendingQueryRuns.length;e++){let r=this.pendingQueryRuns[e];if(r.abortController.signal.aborted)continue;let i=r.query.values,a=n.values,o=!1;if(i===a)o=!0;else if(i&&a&&i.length===a.length){o=!0;for(let e=0;e<i.length;e++)if(i[e]!==a[e]){o=!1;break}}if(r.query.search===n.search&&r.query.offset===n.offset&&r.query.after===n.after&&r.query.limit===n.limit&&o)return this.createSubscriberPromise(r,n,t);let s=!!r.query.values&&!r.query.search&&r.query.offset===void 0&&r.query.after===void 0&&r.query.limit===void 0,c=!!n.values&&!n.search&&n.offset===void 0&&n.after===void 0&&n.limit===void 0;if((e>0||!r.started)&&s&&c){let e=Array.from(new Set([...r.query.values,...n.values]));return e.length!==r.query.values.length&&(r.query={values:e}),this.createSubscriberPromise(r,n,t)}}let r=new AbortController,i={query:n,promise:Promise.resolve({options:[]}),abortController:r,subscribers:new Set,started:!1},a=this.runSequentially(()=>(i.started=!0,this.fetcher({...i.query,signal:r.signal})));i.promise=a,this.pendingQueryRuns.push(i);let o=()=>{let e=this.pendingQueryRuns.findIndex(e=>e.promise===a);e>=0&&this.pendingQueryRuns.splice(e,1)};return a.then(o,o),this.createSubscriberPromise(i,n,t)}createSubscriberPromise(e,t,n){let r={query:t,signal:n,aborted:!1};e.subscribers.add(r);let i,a=new Promise((t,a)=>{if(n){if(i=()=>{r.aborted=!0,this.abortUnderlyingRequestIfUnused(e),a(new DOMException(`The operation was aborted.`,`AbortError`))},n.aborted){i();return}n.addEventListener(`abort`,i,{once:!0})}});return(n?Promise.race([e.promise,a]):e.promise).then(e=>this.filterResultForSubscriber(e,r.query)).finally(()=>{e.subscribers.delete(r),n&&i&&n.removeEventListener(`abort`,i),this.abortUnderlyingRequestIfUnused(e)})}filterResultForSubscriber(e,t){if(!t.values||t.search||t.offset!==void 0||t.after!==void 0||t.limit!==void 0)return e;let n=new Set(t.values),r=new Map(t.values.map((e,t)=>[e,t]));return{...e,options:e.options.filter(e=>n.has(e.value)).sort((e,t)=>(r.get(e.value)??0)-(r.get(t.value)??0))}}abortUnderlyingRequestIfUnused(e){if(e.subscribers.size===0){e.abortController.abort();return}Array.from(e.subscribers).every(e=>e.aborted)&&e.abortController.abort()}runSequentially(e){let t=this.runChain.then(e,e);return this.runChain=t.then(()=>void 0,()=>void 0),t}},D=class extends Error{userMessage;code;httpStatus;constructor(e,t){super(e,{cause:t?.cause}),this.name=`OptionSourceError`,this.userMessage=t?.userMessage,this.code=t?.code,this.httpStatus=t?.httpStatus,this.cause=t?.cause}};function O(e){return e instanceof D?!0:!(!e||typeof e!=`object`||`message`in e&&typeof e.message!=`string`&&e.message!==void 0||`userMessage`in e&&typeof e.userMessage!=`string`&&e.userMessage!==void 0||`code`in e&&typeof e.code!=`string`&&e.code!==void 0||`httpStatus`in e&&typeof e.httpStatus!=`number`&&e.httpStatus!==void 0)}var k=`An error occurred fetching options`;function A(e){if(e instanceof D)return e;if(!e)return new D(k);if(typeof e==`string`)return new D(e);if(typeof e!=`object`)return new D(k);if(`name`in e&&e.name===`AbortError`)return e;let t;t=`message`in e&&typeof e.message==`string`?e.message??k:k;let n;if(O(e)?n=e:(n={},`userMessage`in e&&typeof e.userMessage==`string`&&(n.userMessage=e.userMessage),`code`in e&&typeof e.code==`string`&&(n.code=e.code),`httpStatus`in e&&typeof e.httpStatus==`number`&&(n.httpStatus=e.httpStatus),`cause`in e&&(n.cause=e.cause)),n.httpStatus&&!n.code){let e;n.httpStatus===401?e=`unauthorized`:n.httpStatus===403?e=`forbidden`:n.httpStatus===404?e=`not-found`:n.httpStatus===408?e=`timeout`:n.httpStatus===429?e=`rate-limited`:n.httpStatus>=500&&n.httpStatus<=599&&(e=`server`),e&&(n={...n,code:e})}return e instanceof Error&&(!n.cause||e.cause===n.cause)&&(n={...n,cause:e}),new D(t,n)}var j=class e{innerFetcher;fetcher;cache;constructor(e){this.innerFetcher=e.fetch,this.fetcher=new E(this.innerFetcher),this.cache=e.noCache?void 0:new T}async getOptionPage(e){if(this.cache){let t=this.cache.getByPageQuery(e);if(t)return{...t,nextPage:this.createFetchNextPage(t,e)}}try{let t=await this.fetcher.fetch(e);return this.cache&&this.cache.setQueryResult(t,e),{...t,nextPage:this.createFetchNextPage(t,e)}}catch(e){throw A(e)}}createFetchNextPage(e,t){if(!e||e.hasMore!==!0)return;let n=(t?.offset??0)+e.options.length,r=e.options.length>0?e.options[e.options.length-1]:void 0,i={search:t?.search,offset:n,after:r,limit:t?.limit};return e=>this.getOptionPage({...i,limit:e?.limit??i.limit,signal:e?.signal})}async resolveValues(e,t){if(!e||e.length===0)return[];let n=Array.from(new Set(e)),r=n,i;if(this.cache){if(!this.cache.hasDefault())try{let e=await this.fetcher.fetch({signal:t});this.cache.setQueryResult(e,void 0)}catch(e){if(t?.aborted)throw A(e)}let{options:e,missingValues:n}=this.cache.tryResolveValues(r);e&&(i=e,r=n)}let a=[];if(r&&r.length>0){let e=new Set(r),n={values:r,signal:t};for(;e.size>0;){let i;try{i=await this.fetcher.fetch(n)}catch(e){throw A(e)}let o=i.options,s=0;for(let t of o)e.delete(t.value)&&(a.push(t),s++);if(i.hasMore!==!0||s===0)break;n={values:r,offset:(n.offset??0)+o.length,after:o[o.length-1],signal:t}}this.cache&&this.cache.set(a)}let o=new Map([...i??[],...a].map(e=>[e.value,e]));return n.flatMap(e=>{let t=o.get(e);return t?[t]:[]})}getCachedOptions(){return this.cache?.getAll()}clearCache(){this.cache?.clear()}withNoCache(){return this.cache?new e({fetch:this.innerFetcher,noCache:!0}):this}};function M(e){if(typeof e==`function`)return new j({fetch:e});if(N(e))return e;if(P(e))return new j(e);throw Error(`Invalid option source init.`)}function N(e){return!e||typeof e!=`object`?!1:`getOptionPage`in e&&typeof e.getOptionPage==`function`&&`resolveValues`in e&&typeof e.resolveValues==`function`}function P(e){return!e||typeof e!=`object`?!1:`fetch`in e&&typeof e.fetch==`function`}function F(e,t){let n=[],r=new Set;for(let t of e)r.has(t.value)||(r.add(t.value),n.push(t));for(let e of t)r.has(e.value)||(r.add(e.value),n.push(e));return n}var I=2,L=250;function R({optionSource:e,staticOptions:t,searchMatcher:n,maxAdditionalPages:r=I,value:i,defaultValue:a,multiple:o,isOptionListActive:s=!0}){let l=s&&!!e,u=i!==void 0,[d,f]=(0,c.useState)(()=>{let e=v(u?i:a);return o?e:e.slice(0,1)}),p=(0,c.useMemo)(()=>{let e=v(u?i:d);return o?e:e.slice(0,1)},[u,o,d,i]),[m,h]=(0,c.useState)(``),[g,_]=(0,c.useState)(()=>l?``:void 0),[y,b]=(0,c.useState)({items:[],result:void 0,error:void 0,isPending:l,additionalPagesLoaded:0,lastAttemptedQuery:l?{search:void 0,initiatedBySearch:!1}:void 0}),[x,S]=(0,c.useState)(0),[C,w]=(0,c.useState)(()=>[...p]),[T,E]=(0,c.useState)({key:``,options:[],error:void 0}),[D,O]=(0,c.useState)(!1),k=(0,c.useRef)(void 0),j=(0,c.useRef)(void 0),M=(0,c.useRef)(void 0),N=(0,c.useRef)(new Map),P=(0,c.useRef)({isOptionListActive:s,optionSource:e}),R=(0,c.useMemo)(()=>JSON.stringify(p),[p]),z=s&&!!e&&g===void 0&&y.result===void 0&&y.error===void 0,H=!z&&!y.isPending&&y.error===void 0,U=y.error!==void 0,ee=(0,c.useCallback)(e=>{let t=o?e:e.slice(0,1);u||f(t)},[u,o]);(0,c.useEffect)(()=>{let t=P.current,n=s!==t.isOptionListActive,r=e!==t.optionSource;if(!n&&!r)return;P.current={isOptionListActive:s,optionSource:e},(!s||r)&&(k.current?.abort(),k.current=void 0,j.current?.abort(),j.current=void 0);let i=!1;return queueMicrotask(()=>{if(!i){if(!s){b(e=>({...e,isPending:!1}));return}if(h(``),w(p),_(``),e){b(e=>({...e,items:[],result:void 0,error:void 0,isPending:!0,additionalPagesLoaded:0,lastAttemptedQuery:{search:void 0,initiatedBySearch:!1}}));return}b(e=>({...e,error:void 0,isPending:!1}))}}),()=>{i=!0}},[s,e,p]),(0,c.useEffect)(()=>{if(!s||m===g)return;let t=window.setTimeout(()=>{e&&(b(e=>({...e,isPending:!0,error:void 0,lastAttemptedQuery:{search:m||void 0,initiatedBySearch:!0}})),S(e=>e+1)),_(m)},L);return()=>{window.clearTimeout(t)}},[g,s,e,m]),(0,c.useEffect)(()=>{if(!s||!e||g===void 0)return;let t=!1;k.current?.abort();let n=new AbortController;k.current=n;let r=g?{search:g,signal:n.signal}:{signal:n.signal};return e.getOptionPage(r).then(e=>{t||b(t=>({...t,items:e.options,result:e,error:void 0,isPending:!1,additionalPagesLoaded:0}))}).catch(e=>{t||n.signal.aborted||b(t=>({...t,items:[],result:void 0,isPending:!1,error:A(e)}))}),()=>{t=!0,n.abort(),k.current===n&&(k.current=void 0)}},[g,s,e,x]);let W=(0,c.useCallback)(e=>{w(e=>{if(p.length===0)return e;let t=[...e],n=new Set(e);for(let e of p)n.has(e)||(n.add(e),t.push(e));return t}),h(e)},[p]),te=(0,c.useCallback)(()=>{!e||!s||(b(e=>({...e,items:[],result:void 0,error:void 0,isPending:!0,additionalPagesLoaded:0,lastAttemptedQuery:{search:g,initiatedBySearch:!!e.lastAttemptedQuery?.initiatedBySearch}})),S(e=>e+1),_(e=>e??``))},[g,s,e]),G=!!y.result?.nextPage&&y.additionalPagesLoaded<r&&y.items.length>0&&H&&!y.isPending,K=!!y.result?.nextPage&&y.items.length>0&&H,ne=(0,c.useCallback)(()=>{if(!y.result?.nextPage||!G||y.isPending)return;b(e=>({...e,isPending:!0,lastAttemptedQuery:{search:g,initiatedBySearch:!1}})),j.current?.abort();let e=new AbortController;j.current=e,y.result.nextPage({signal:e.signal}).then(t=>{j.current===e&&b(e=>({...e,items:[...e.items,...t.options],result:t,additionalPagesLoaded:e.additionalPagesLoaded+1,error:void 0,isPending:!1}))}).catch(t=>{e.signal.aborted||j.current!==e||b(e=>({...e,error:A(t),isPending:!1}))}).finally(()=>{j.current===e&&(j.current=void 0)})},[G,g,y.isPending,y.result]);(0,c.useEffect)(()=>{let e=new Map;for(let n of t)e.has(n.value)||e.set(n.value,n);N.current=e},[e,t]);let q=g??``,J=(0,c.useMemo)(()=>B(t.find(e=>e.hidden)?t.filter(e=>!e.hidden):t,q,n),[q,n,t]),Y=(0,c.useMemo)(()=>{if(!e)return J;let t=y.items.find(e=>e.hidden)?y.items.filter(e=>!e.hidden):y.items;return F(J,t)},[J,e,y.items]);(0,c.useEffect)(()=>{if(!(!e||Y.length===0))for(let e of Y)N.current.has(e.value)||N.current.set(e.value,e)},[e,Y]),(0,c.useEffect)(()=>{if(!e||p.length===0)return;let t=!1;M.current?.abort();let n=new AbortController;M.current=n;let r=JSON.stringify(p),i=N.current,a=new Map;for(let e of p){let t=i.get(e);t&&a.set(e,t)}let o=p.filter(e=>!a.has(e));if(o.length===0){M.current=void 0,queueMicrotask(()=>{t||(O(!1),E({key:r,options:p.map(e=>a.get(e)).filter(e=>e!==void 0),error:void 0}))});return}return queueMicrotask(()=>{O(!0)}),e.resolveValues(o,n.signal).then(e=>{if(t)return;let n=new Map(e.map(e=>[e.value,e]));for(let t of e)i.set(t.value,t);let o=p.map(e=>a.get(e)??n.get(e)).filter(e=>e!==void 0),s=p.filter(e=>!n.has(e)).filter(e=>!a.has(e));O(!1),E({key:r,options:o,error:s.length>0?A(Error()):void 0})}).catch(e=>{t||n.signal.aborted||(O(!1),E({key:r,options:[],error:A(e)}))}),()=>{t=!0,n.abort(),M.current===n&&(M.current=void 0)}},[e,p]);let re=(0,c.useMemo)(()=>{if(e)return p.length===0||T.key!==R?[]:T.options;let n=new Map(t.map(e=>[e.value,e]));return p.map(e=>n.get(e)||{value:e,label:``,disabled:!1})},[e,T.key,T.options,p,R,t]),ie=(0,c.useMemo)(()=>{if(U)return y.error??A()},[U,y.error]),X=q.trim().length>0&&!(y.isPending&&y.lastAttemptedQuery?.initiatedBySearch),ae=(0,c.useMemo)(()=>{if(C.length===0)return[];let e=new Set(C),t=new Map;for(let n of Y)e.has(n.value)&&t.set(n.value,n);for(let n of re)e.has(n.value)&&t.set(n.value,n);return C.map(e=>t.get(e)).filter(e=>e!==void 0)},[re,C,Y]),Z=(0,c.useMemo)(()=>ie&&(y.lastAttemptedQuery?.initiatedBySearch||Y.length===0)?[]:V(Y,C,e?ae:void 0,X),[X,e,ie,y.lastAttemptedQuery?.initiatedBySearch,ae,C,Y]),oe=(0,c.useMemo)(()=>{if(!(!e||p.length===0||T.key!==R||T.error===void 0))return T.error},[e,T.error,T.key,p.length,R]),Q=s&&!!e&&(z||y.isPending),se=Q&&!!y.lastAttemptedQuery?.initiatedBySearch,$=!!e&&p.length>0&&D;return(0,c.useEffect)(()=>()=>{k.current?.abort(),j.current?.abort(),M.current?.abort()},[]),{searchValue:m,selectedValues:p,options:Z,isOptionsPending:Q,isSearching:se,isResolveValuesPending:$,optionsError:ie,resolveValuesError:oe,canLoadMore:G,hasMore:K,handleSelectedValuesChange:ee,handleSearchChange:W,handleRetryOptions:e?te:void 0,handleLoadMore:ne}}function z(e,t){let n=t.trim().toLowerCase();return n?e.label.toLowerCase().includes(n):!0}function B(e,t,n){return t.trim()?n?e.filter(e=>n(e,t)):e.filter(e=>z(e,t)):e}function V(e,t,n,r){if(!t||t.length===0||r)return e;let i=new Set(t),a=e.filter(e=>i.has(e.value)),o=new Set(a.map(e=>e.value)),s=[];for(let e of n??[])!i.has(e.value)||o.has(e.value)||(o.add(e.value),s.push(e));let c=e.filter(e=>!o.has(e.value));return a.length===0&&s.length===0?e:[...a,...s,...c]}function H(e){let{value:t,disabled:n,...r}=e;return{addEventListener:()=>void 0,removeEventListener:()=>void 0,dispatchEvent:()=>!0,...U(t),disabled:n??!1,...r}}function U(e){let t,n=[];typeof e==`string`?(t=e,n.push({value:e,label:``,selected:!0,disabled:!1})):Array.isArray(e)?(t=e[0]??``,n.push(...e.map(e=>({value:e,label:``,selected:!0,disabled:!1})))):t=``;let r=Object.assign(n,{selectedIndex:n.length>0?0:-1,item:e=>n[e]??null,namedItem:()=>null,length:n.length,[Symbol.iterator]:n[Symbol.iterator].bind(n)});return{value:t,selectedOptions:r}}function ee(e){return G(`change`,e)}function W(e,t){let n=G(`input`,e),r={...n.nativeEvent,data:t.data,dataTransfer:null,detail:0,inputType:`insertText`,isComposing:!1,view:null,which:0,getTargetRanges:()=>[],initUIEvent:()=>void 0};return{...n,nativeEvent:r,data:t.data}}function te(e){return G(`invalid`,e)}function G(e,t){let n=e,r=!1,i=!0,a=!0,o={get type(){return n},currentTarget:t,target:t,get cancelable(){return a},get defaultPrevented(){return r},preventDefault(){r=!0},get bubbles(){return i},stopPropagation(){i=!1},eventPhase:Event.NONE,isTrusted:!0,timeStamp:Date.now(),get cancelBubble(){return!i},set cancelBubble(e){i=!e},composed:!1,get returnValue(){return!r},set returnValue(e){r=!e},srcElement:t,composedPath(){return[t]},initEvent(e,t,r){n=e,i=t??!1,a=r??!0},stopImmediatePropagation(){i=!1},AT_TARGET:Event.AT_TARGET,BUBBLING_PHASE:Event.BUBBLING_PHASE,CAPTURING_PHASE:Event.CAPTURING_PHASE,NONE:Event.NONE};return{get type(){return n},currentTarget:t,target:t,get cancelable(){return a},get defaultPrevented(){return r},preventDefault(){r=!0},get bubbles(){return i},stopPropagation(){i=!1},eventPhase:Event.NONE,isTrusted:!0,timeStamp:o.timeStamp,nativeEvent:o,isDefaultPrevented(){return r},isPropagationStopped(){return!i},persist:()=>void 0}}function K(e,t){let n=Object.create(e);return Object.defineProperties(n,{currentTarget:{get(){return t}},target:{get(){return t}}}),n}function ne(e,t){let n={};for(let r of Object.keys(t)){let i=t[r];typeof i==`function`&&(n[r]=(t=>{i(K(t,e))}))}return n}var q=`⚠`,J=`↻`;function Y({className:e,style:t,message:n,inline:r,onRetry:i,customization:a}){let o=a?.classNamePrefix??`super-select`,s=o.length>0?`${o}__`:``;return(0,l.jsxs)(r?`span`:`div`,{className:u(`${s}alert`,`${s}alert-danger`,i&&`${s}alert-dismissible`,r&&`${s}d-block`,e),style:t,children:[a?.icon??(0,l.jsx)(`span`,{"aria-hidden":!!n,children:q}),` `,n&&(0,l.jsx)(l.Fragment,{children:n}),` `,i&&(0,l.jsx)(`button`,{type:`button`,className:u(`${s}btn`,`${s}btn-outline-secondary`,`${s}btn-sm`,a?.retryButton?.className),style:a?.retryButton?.style,title:a?.retryButton?.title,onClick:i,children:a?.retryButton?.content??J})]})}function re({form:e,onReset:t}){let n=(0,c.useRef)(null);return(0,c.useEffect)(()=>{let e=n.current?.form,r=e?.ownerDocument.defaultView;if(!e||!r)return;let i=n=>{n.target===e&&!n.defaultPrevented&&t()};return r.addEventListener(`reset`,i),()=>r.removeEventListener(`reset`,i)},[e,t]),(0,l.jsx)(`input`,{ref:n,type:`hidden`,form:e})}function ie(e){return X(e,new Set)}function X(e,t){let n=[];for(let r of c.Children.toArray(e))if((0,c.isValidElement)(r)){if(r.type===c.Fragment){let e=r;n.push(...X(e.props.children,t));continue}if(r.type===`option`){let e=r,i=Z(e.props.children),a=e.props.value===void 0?i:String(e.props.value);if(t.has(a))continue;t.add(a);let o=e.props.label===void 0?i:String(e.props.label),s=e.props,c=Object.entries(s).reduce((e,[t,n])=>(!t.startsWith(`data-`)||n===void 0||(e[t.slice(5)]=n),e),{}),l=e.props.data===void 0?Object.keys(c).length>0?c:void 0:{...c,value:e.props.data};n.push({value:a,label:o,children:ae(e.props.children)?e.props.children:void 0,disabled:!!e.props.disabled,hidden:!!e.props.hidden,data:l});continue}if(r.type===`optgroup`){let e=r,i=String(e.props.label??``),a=c.Children.toArray(e.props.children);for(let e of a){let r=X(e,t);for(let e of r)e.groupLabel=i,n.push(e)}}}return n}function ae(e){return e==null||typeof e==`boolean`||typeof e==`string`||typeof e==`number`?!1:Array.isArray(e)?e.some(e=>ae(e)):!0}function Z(e){return e==null||typeof e==`boolean`?``:typeof e==`string`?e:typeof e==`number`?String(e):Array.isArray(e)?e.map(e=>Z(e)).join(``):(0,c.isValidElement)(e)?Z(e.props.children):``}function oe({ref:e,customization:t,children:n,className:r,...i}){let a=t?.classNamePrefix??`super-select`,o=a.length>0?`${a}__`:``;return(0,l.jsx)(`button`,{ref:e,type:`button`,className:u(`${o}form-select`,`${o}text-start`,r),...i,children:n})}var Q=`✓`;function se({className:e,style:t,disabled:n,title:r,onClick:i,customization:a}){let o=a?.classNamePrefix??`super-select`,s=o.length>0?`${o}__`:``;return(0,l.jsx)(`button`,{type:`button`,className:u(`${s}btn`,`${s}btn-secondary`,e),style:t,onClick:i,disabled:n,title:r,children:a?.content??Q})}function $({customization:e,selectedOptions:t,className:n,style:r}){let i=e?.classNamePrefix??`super-select`,a=i.length>0?`${i}__`:``;return t.length>1?(0,l.jsx)(`ul`,{className:u(`${a}list-inline`,`${a}d-inline`,n),style:r,children:t.map(e=>(0,l.jsx)(`li`,{className:`${a}list-inline-item`,children:e.children??e.label},e.value))}):(0,l.jsx)(`span`,{className:n,style:r,children:t[0]?.children??t[0]?.label??e?.placeholder??``})}function ce({optionSource:e,children:t,customization:n,ref:r,multiple:i,disabled:a,required:o,value:s,defaultValue:d,name:f,id:p,form:m,autoFocus:h,autoComplete:g,onInput:_,onInvalid:y,onChange:b,onValueChange:x,className:S,style:w,...T}){let[E,D]=(0,c.useState)(!1),[O,k]=(0,c.useState)(!1),A=(0,c.useMemo)(()=>ie(t),[t]),j=s!==void 0,M=(0,c.useRef)(d),N=R({optionSource:e,staticOptions:A,searchMatcher:n?.searchMatcher,maxAdditionalPages:n?.maxAdditionalPages,value:s,defaultValue:d,multiple:i,isOptionListActive:E}),P=(0,c.useCallback)(()=>{a||D(!0)},[a]),F=(0,c.useCallback)(()=>{D(!1)},[]),I=(0,c.useCallback)(()=>{if(j)return;let e=v(M.current);N.handleSelectedValuesChange(i?e:e.slice(0,1)),k(!1)},[N,j,i,k]),L=(0,c.useCallback)(e=>{if(a)return;N.handleSelectedValuesChange(e),(!o||e.length>0)&&k(!1);let t=H({id:p,name:f,value:i?e:e[0]??``,multiple:i,disabled:a,required:o});_&&_(W(t,{data:``})),b&&b(ee(t)),x&&x(i?e:e[0]??``)},[N,a,p,i,f,b,_,x,o,k]),z=(0,c.useCallback)(e=>{let t=Array.from(e.currentTarget.selectedOptions).map(e=>e?.value??``),n=i?t:t.length>0?[t[0]??``]:e.currentTarget.value===``?[]:[e.currentTarget.value];L(n)},[L,i]),B=(0,c.useMemo)(()=>{if(N.selectedValues.length===0)return[];let e=new Map;for(let t of A)e.has(t.value)||e.set(t.value,t);for(let t of N.options)e.set(t.value,t);let t=N.selectedValues.map(t=>e.get(t)).filter(e=>e!==void 0);return t.length>0?t:le(N.selectedValues,A)},[N.options,N.selectedValues,A]),V=(0,c.useMemo)(()=>H({id:p,name:f,value:i?N.selectedValues:N.selectedValues[0]??``,multiple:i,disabled:a,required:o}),[N.selectedValues,a,p,i,f,o]),U={...T,size:void 0},G=T[`aria-label`],K=T[`aria-labelledby`]??(G?void 0:p),q=ne(V,U),J=(0,c.useCallback)(e=>{P(),q.onClick?.(e)},[P,q]),X=(0,c.useCallback)(e=>{e.preventDefault(),k(!0),y&&y(te(V))},[V,y,k]),ae=O&&!!o&&N.selectedValues.length===0,Z=n?.classNamePrefix??`super-select`,Q=Z.length>0?`${Z}__`:``,se=(0,c.useMemo)(()=>A.find(e=>e.value===``)?.label,[A]),ce=n?.modalSelectButton?.selectedContent?.placeholder??se,de=B.length>0,fe=!!N.resolveValuesError,pe=fe||ae,me=n?.errorIndicator?.component??Y,he=n?.pendingIndicator?.component??C,ge=n?.modalSelectButton?.component??oe,_e=n?.modalSelectButton?.selectedContent?.component??$;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(ge,{...U,...q,id:p,autoFocus:h,"aria-haspopup":`dialog`,"aria-expanded":E,"aria-busy":N.isResolveValuesPending||void 0,"aria-invalid":pe||void 0,disabled:a,className:u(a?`${Q}disabled`:void 0,pe?`${Q}is-invalid`:void 0,S,n?.modalSelectButton?.className),style:w&&n?.modalSelectButton?.style?{...w,...n.modalSelectButton.style}:w??n?.modalSelectButton?.style,onClick:J,ref:r,customization:{classNamePrefix:Z},children:fe&&N.resolveValuesError?(0,l.jsx)(me,{inline:!0,className:n?.errorIndicator?.className,style:n?.errorIndicator?.style,error:N.resolveValuesError,message:N.resolveValuesError.userMessage??n?.errorIndicator?.defaultMessage,customization:{classNamePrefix:Z,icon:n?.errorIndicator?.icon}}):N.isResolveValuesPending?(0,l.jsx)(he,{inline:!0,className:n?.pendingIndicator?.className,style:n?.pendingIndicator?.style,title:n?.pendingIndicator?.title,content:n?.pendingIndicator?.content,customization:{classNamePrefix:Z}}):(0,l.jsx)(_e,{selectedOptions:B,className:u(!de||fe?`${Q}text-body-secondary`:void 0,n?.modalSelectButton?.selectedContent?.className),style:n?.modalSelectButton?.selectedContent?.style,customization:{classNamePrefix:Z,placeholder:ce}})}),(0,l.jsx)(ue,{customization:n,isOpen:E,dir:T.dir,lang:T.lang,ariaLabel:G,ariaLabelledBy:K,onClose:F,searchValue:N.searchValue,onSearchChange:N.handleSearchChange,options:N.options,selectedValues:N.selectedValues,multiple:i,isOptionsPending:N.isOptionsPending,isSearching:N.isSearching,isResolveValuesPending:N.isResolveValuesPending,onRefresh:N.handleRetryOptions,optionsError:N.optionsError,onOptionListChange:z,canLoadMore:N.canLoadMore,hasMore:N.hasMore,onLoadMore:N.handleLoadMore}),f||o?(0,l.jsx)(`select`,{name:f,form:m,autoComplete:g,...T,required:o,disabled:a,onInvalid:X,multiple:i,value:i?N.selectedValues:N.selectedValues[0]??``,onChange:()=>void 0,"aria-hidden":!0,hidden:!0,tabIndex:-1,className:`${Q}visually-hidden`,children:N.selectedValues.map(e=>(0,l.jsx)(`option`,{value:e,children:e},e))}):null,j?null:(0,l.jsx)(re,{form:m,onReset:I})]})}function le(e,t){if(e.length===0)return[];let n=new Map(t.map(e=>[e.value,e]));return e.map(e=>n.get(e)).filter(e=>e!==void 0)}function ue({customization:e,isOpen:t,dir:n,lang:r,ariaLabel:i,ariaLabelledBy:a,onClose:o,searchValue:s,onSearchChange:u,options:d,selectedValues:p,multiple:m,isOptionsPending:g,isSearching:b,isResolveValuesPending:x,onRefresh:S,optionsError:T,onOptionListChange:E,canLoadMore:D,onLoadMore:O,hasMore:k}){let A=e?.classNamePrefix??`super-select`,j=A.length>0?`${A}__`:``,M=e?.searchInput?.component??w,N=e?.modal?.okButton?.component??se,P=e?.modal?.component??f,F=e?.optionListInput?.component??y,I=e?.errorIndicator?.component??Y,L=e?.emptyIndicator?.component??h,R=e?.moreIndicator?.component??_,z=e?.pendingIndicator?.component??C,B=(0,c.useRef)(null),V=(0,c.useRef)(!1),U=!!b,W=!!(g||x),te=(0,c.useMemo)(()=>{let e=v(p);return m?e:e.slice(0,1)},[m,p]),G=d.length>0,K=W,ne=T,q=!!ne,J=!q&&!K&&!G,re=!q&&!K&&!J&&!!k;(0,c.useEffect)(()=>{if(!t)return;let e=B.current;if(!e)return;let n=window.setTimeout(()=>{e.focus()},0);return()=>{window.clearTimeout(n)}},[t]);let ie=(0,c.useCallback)(e=>{if(e.shiftKey||e.ctrlKey||e.altKey||e.metaKey)return;if(e.key===`Enter`){e.preventDefault();return}let t=e.key===`ArrowDown`?1:e.key===`ArrowUp`?-1:0;if(!t)return;let n=e.currentTarget.closest([`.${j}modal-content`,`[class*='modal-content']`,`[class*='modal-body']`,`dialog`,`[role='dialog']`,`[aria-modal='true']`].join(`,`))??e.currentTarget.parentElement;if(!n)return;let r=n.querySelector([`[role='listbox']`,`[role='radiogroup']`,`[role='group']`,`fieldset`,`[class*='modal-body']`].join(`,`))??n,i=Array.from(r.querySelectorAll([`input[type='radio']:not(:disabled):not([tabindex='-1'])`,`input[type='checkbox']:not(:disabled):not([tabindex='-1'])`,`[role='radio']:not([aria-disabled='true']):not([tabindex='-1'])`,`[role='checkbox']:not([aria-disabled='true']):not([tabindex='-1'])`,`[role='option']:not([aria-disabled='true']):not([tabindex='-1'])`].join(`,`))).filter(e=>{if(e.hidden||e.getAttribute(`aria-hidden`)===`true`)return!1;let t=window.getComputedStyle(e);return t.display!==`none`&&t.visibility!==`hidden`}),a=t>0?i[0]:i[i.length-1];a&&(e.preventDefault(),a.focus())},[j]),X=(0,c.useCallback)(e=>{if(E(e),!m){if(V.current){V.current=!1;return}o()}},[m,o,E]),ae=(0,c.useCallback)(e=>{let t=m?e:e.slice(0,1),n=H({value:m?t:t[0]??``,multiple:m});X(ee(n))},[X,m]),Z=(0,c.useCallback)(e=>{if(m||e.detail<=0)return;V.current=!1;let t=e.currentTarget,n;n=`checked`in t&&typeof t.checked==`boolean`?t.checked:`selected`in t&&typeof t.selected==`boolean`?t.selected:!1,n&&o()},[m,o]),oe=(0,c.useCallback)(e=>{if(!m){if(e.key===`ArrowDown`||e.key===`ArrowUp`||e.key===`ArrowLeft`||e.key===`ArrowRight`){V.current=!0;return}if(V.current=!1,e.key===`Enter`||e.key===` `||e.key===`Spacebar`){let t=e.currentTarget,n;n=`checked`in t&&typeof t.checked==`boolean`?t.checked:`selected`in t&&typeof t.selected==`boolean`?t.selected:!1,n&&(e.preventDefault(),e.stopPropagation(),o())}}},[m,o]),Q;return Q=K?(0,l.jsx)(z,{inline:!0,className:e?.pendingIndicator?.className,style:e?.pendingIndicator?.style,title:e?.pendingIndicator?.title,content:e?.pendingIndicator?.content,customization:{classNamePrefix:A}}):q?(0,l.jsx)(I,{className:e?.errorIndicator?.className,style:e?.errorIndicator?.style,error:ne,message:ne?.userMessage??e?.errorIndicator?.defaultMessage,onRetry:S,customization:{classNamePrefix:A,icon:e?.errorIndicator?.icon,retryButton:e?.errorIndicator?.retryButton}}):J?(0,l.jsx)(L,{className:e?.emptyIndicator?.className,style:e?.emptyIndicator?.style,onRetry:S,customization:{classNamePrefix:A,content:e?.emptyIndicator?.content,retryButton:e?.emptyIndicator?.retryButton}}):re?(0,l.jsx)(R,{onLoadMore:D?O:void 0,className:e?.moreIndicator?.className,style:e?.moreIndicator?.style,disabled:W,customization:{classNamePrefix:A,loadMoreButton:e?.moreIndicator?.loadMoreButton,overflowIndicator:e?.moreIndicator?.overflowIndicator}}):void 0,(0,l.jsx)(P,{open:t,dir:n,lang:r,"aria-label":i,"aria-labelledby":a,"aria-busy":g||x||void 0,className:e?.modal?.className,style:e?.modal?.style,customization:{classNamePrefix:A,dialog:e?.modal?.dialog,content:e?.modal?.content,header:e?.modal?.header,body:e?.modal?.body,footer:e?.modal?.footer,closeButton:e?.modal?.closeButton},onClose:()=>{o()},onCancel:o,onClick:e=>{e.target===e.currentTarget&&o()},headerContent:(0,l.jsx)(M,{ref:B,className:e?.searchInput?.className,style:e?.searchInput?.style,search:s,onSearchChange:e=>u(e??``),onKeyDown:ie,isSearching:U,customization:{classNamePrefix:A,placeholder:e?.searchInput?.placeholder,title:e?.searchInput?.title,pendingIndicator:{className:e?.pendingIndicator?.className,style:e?.pendingIndicator?.style,title:e?.pendingIndicator?.title,content:e?.pendingIndicator?.content,component:e?.pendingIndicator?.component}}}),footerContent:m?(0,l.jsx)(N,{className:e?.modal?.okButton?.className,style:e?.modal?.okButton?.style,title:e?.modal?.okButton?.title,onClick:o,customization:{classNamePrefix:A,content:e?.modal?.okButton?.content}}):void 0,children:(0,l.jsx)(F,{options:d,value:te,onValueChange:ae,multiple:m,form:``,onKeyDown:e=>{if(e.key===`Enter`&&e.preventDefault(),e.key===`ArrowDown`||e.key===`ArrowUp`||e.key===`ArrowLeft`||e.key===`ArrowRight`){V.current=!0;return}V.current=!1},onOptionClick:Z,onOptionKeyDown:oe,customization:{classNamePrefix:A,optionItem:e?.optionListInput?.optionItem,groupHeader:e?.optionListInput?.groupHeader},className:e?.optionListInput?.className,style:e?.optionListInput?.style,"aria-busy":W,indicator:Q})})}function de({searchInput:e,optionList:t,className:n,customization:r,ref:i,children:a,...o}){let s=r?.classNamePrefix??`super-select`;return(0,l.jsxs)(`div`,{ref:i,...o,className:u(s,n),children:[e,t,a]})}function fe({optionSource:e,children:t,customization:n,ref:r,onBlur:i,onFocus:a,onClick:o,onMouseDown:s,onMouseUp:d,onPointerDown:f,onPointerUp:p,onContextMenu:m,onKeyDown:g,onKeyUp:b,onBeforeInput:x,onSelect:S,onCompositionStart:T,onCompositionUpdate:E,onCompositionEnd:D,onChange:O,onInput:k,onInvalid:A,onValueChange:j,className:M,style:N,...P}){let F=(0,c.useMemo)(()=>ie(t),[t]),I=(0,c.useRef)(null),L=n?.searchInput?.component??w,z=n?.classNamePrefix??`super-select`,B=z.length>0?`${z}__`:``,{multiple:V,disabled:U,value:G,defaultValue:K}=P,q=G!==void 0,J=(0,c.useRef)(K),X=R({optionSource:e,staticOptions:F,searchMatcher:n?.searchMatcher,maxAdditionalPages:n?.maxAdditionalPages,value:G,defaultValue:K,multiple:V}),ae=(0,c.useCallback)(e=>{if(r){if(typeof r==`function`){r(e);return}r.current=e}},[r]),Z=(0,c.useMemo)(()=>V?X.selectedValues:X.selectedValues.slice(0,1),[X.selectedValues,V]),oe=(0,c.useCallback)(()=>{if(!q){let e=v(J.current);X.handleSelectedValuesChange(V?e:e.slice(0,1))}},[X,q,V]),Q=(0,c.useCallback)(e=>{e.preventDefault(),A&&A(te(H({id:P.id,name:P.name,value:V?Z:Z[0]??``,multiple:V,disabled:U,required:P.required})))},[U,V,A,P,Z]),se=(0,c.useMemo)(()=>H({id:P.id,name:P.name,value:V?Z:Z[0]??``,multiple:V,disabled:U,required:P.required}),[U,V,P.id,P.name,P.required,Z]),$={...P,value:void 0,defaultValue:void 0,size:void 0},ce=$,le=ne(se,{...$,onFocus:a,onBlur:i,onClick:o,onMouseDown:s,onMouseUp:d,onPointerDown:f,onPointerUp:p,onContextMenu:m,onKeyDown:g,onKeyUp:b,onBeforeInput:x,onSelect:S,onCompositionStart:T,onCompositionUpdate:E,onCompositionEnd:D}),ue=!!e,fe=X.isOptionsPending||X.isResolveValuesPending,pe=X.options.length>0,me=X.optionsError,he=!!me,ge=fe,_e=!he&&!ge&&!pe,ve=!he&&!ge&&!_e&&!!X.hasMore,ye=U||fe,be=n?.optionList?.component??de,xe=n?.optionListInput?.component??y,Se=n?.errorIndicator?.component??Y,Ce=n?.emptyIndicator?.component??h,we=n?.moreIndicator?.component??_,Te=n?.pendingIndicator?.component??C,Ee;Ee=ge?(0,l.jsx)(Te,{inline:!0,className:n?.pendingIndicator?.className,style:n?.pendingIndicator?.style,title:n?.pendingIndicator?.title,content:n?.pendingIndicator?.content,customization:{classNamePrefix:z}}):he?(0,l.jsx)(Se,{className:n?.errorIndicator?.className,style:n?.errorIndicator?.style,error:me,message:me?.userMessage??n?.errorIndicator?.defaultMessage,onRetry:X.handleRetryOptions,customization:{classNamePrefix:z,icon:n?.errorIndicator?.icon,retryButton:n?.errorIndicator?.retryButton}}):_e?(0,l.jsx)(Ce,{className:n?.emptyIndicator?.className,style:n?.emptyIndicator?.style,onRetry:X.handleRetryOptions,customization:{classNamePrefix:z,content:n?.emptyIndicator?.content,retryButton:n?.emptyIndicator?.retryButton}}):ve?(0,l.jsx)(we,{onLoadMore:X.canLoadMore?X.handleLoadMore:void 0,className:n?.moreIndicator?.className,style:n?.moreIndicator?.style,disabled:ye,customization:{classNamePrefix:z,loadMoreButton:n?.moreIndicator?.loadMoreButton,overflowIndicator:n?.moreIndicator?.overflowIndicator}}):void 0;let De=(0,c.useCallback)(e=>{let t=V?e:e.slice(0,1);X.handleSelectedValuesChange(t);let n=H({id:P.id,name:P.name,multiple:V,disabled:U,required:P.required,value:V?t:t[0]??``});k&&k(W(n,{data:``})),O&&O(ee(n)),j&&j(V?t:t[0]??``)},[X,U,V,O,k,j,P]),Oe=(0,c.useCallback)(e=>{if(e.shiftKey||e.ctrlKey||e.altKey||e.metaKey)return;let t=e.key===`ArrowDown`?1:e.key===`ArrowUp`?-1:0;if(!t)return;let n=I.current;if(!n)return;let r=n.querySelector([`[role='listbox']`,`[role='radiogroup']`,`[role='group']`,`fieldset`,`[class*='list-group']`].join(`,`))??n,i=Array.from(r.querySelectorAll([`input[type='radio']:not(:disabled):not([tabindex='-1'])`,`input[type='checkbox']:not(:disabled):not([tabindex='-1'])`,`[role='radio']:not([aria-disabled='true']):not([tabindex='-1'])`,`[role='checkbox']:not([aria-disabled='true']):not([tabindex='-1'])`,`[role='option']:not([aria-disabled='true']):not([tabindex='-1'])`].join(`,`))).filter(e=>{if(e.hidden||e.getAttribute(`aria-hidden`)===`true`)return!1;let t=window.getComputedStyle(e);return t.display!==`none`&&t.visibility!==`hidden`}),a=t>0?i[0]:i[i.length-1];a&&(e.preventDefault(),a.focus())},[]);return(0,l.jsxs)(be,{ref:I,className:u(n?.optionList?.className,M),style:N&&n?.optionList?.style?{...N,...n.optionList.style}:N??n?.optionList?.style,"aria-label":P[`aria-label`]??P.name,dir:P.dir,lang:P.lang,customization:{classNamePrefix:z},searchInput:ue?(0,l.jsx)(L,{className:n?.searchInput?.className,style:n?.searchInput?.style,search:X.searchValue,onSearchChange:e=>X.handleSearchChange(e??``),onKeyDown:Oe,disabled:U,isSearching:X.isSearching,customization:{classNamePrefix:z,placeholder:n?.searchInput?.placeholder,title:n?.searchInput?.title,pendingIndicator:{className:n?.pendingIndicator?.className,style:n?.pendingIndicator?.style,title:n?.pendingIndicator?.title,content:n?.pendingIndicator?.content,component:n?.pendingIndicator?.component}}}):void 0,optionList:(0,l.jsx)(xe,{...ce,...le,ref:ae,id:P.id,name:P.name,multiple:V,disabled:U,required:P.required,form:P.form,autoComplete:P.autoComplete,autoFocus:P.autoFocus,tabIndex:P.tabIndex,title:P.title,options:X.options,value:Z,onValueChange:De,className:n?.optionListInput?.className,style:n?.optionListInput?.style,customization:{classNamePrefix:z,optionItem:n?.optionListInput?.optionItem,groupHeader:n?.optionListInput?.groupHeader},"aria-busy":fe,indicator:Ee}),children:[P.required?(0,l.jsx)(`input`,{type:`checkbox`,checked:Z.length>0,required:!0,disabled:U,form:P.form,tabIndex:-1,"aria-hidden":!0,onChange:()=>void 0,onInvalid:Q,hidden:!0,className:`${B}visually-hidden`}):null,q?null:(0,l.jsx)(re,{form:P.form,onReset:oe})]})}function pe({autoComplete:e,autoFocus:t,className:n,customization:r,disabled:i,form:a,id:o,multiple:s,name:d,onValueToggle:f,options:p,value:m,required:h,style:g,tabIndex:_,title:v,ref:y,...b}){let x=r?.classNamePrefix??`super-select`,S=x.length>0?`${x}__`:``,C=(0,c.useMemo)(()=>new Set(m),[m]),w=(0,c.useMemo)(()=>p.find(e=>e.hidden)?p.filter(e=>!e.hidden):p,[p]),T=(0,c.useMemo)(()=>{if(t)return w.find(e=>!(i||e.disabled))?.value},[t,i,w]),E=(0,c.useMemo)(()=>me(w),[w]),D=b[`aria-label`]??d;return(0,l.jsx)(`fieldset`,{ref:y,...b,id:o,disabled:i,role:s?`group`:`radiogroup`,"aria-disabled":i||void 0,"aria-required":h||void 0,"aria-label":D,className:u(x,`${S}btn-toolbar`,n),style:g,title:v,tabIndex:_,children:E.map(({label:t,options:n})=>(0,l.jsx)(`div`,{className:u(`${S}btn-group`,r?.buttonGroup?.className),style:r?.buttonGroup?.style,children:n.map(t=>{let n=C.has(t.value),o=i||t.disabled,c=s?`checkbox`:`radio`;return(0,l.jsxs)(`label`,{className:u(`${S}btn`,`${S}btn-outline-secondary`,n&&`${S}active`,o&&`${S}disabled`,r?.button?.className),style:r?.button?.style,children:[(0,l.jsx)(`input`,{value:t.value,className:`${S}btn-check`,checked:n,autoComplete:e,autoFocus:t.value===T,disabled:o,form:a,name:d,type:c,onChange:()=>f(t.value),onClick:e=>{s||!n||o||(e.preventDefault(),window.setTimeout(()=>{f(t.value)},0))}}),(0,l.jsx)(`span`,{children:t.children??t.label})]},t.value)})},t))})}function me(e){let t=[],n;for(let r of e){let e=r.groupLabel??``;if(n&&n.label===e){n.options.push(r);continue}if(n=t.find(t=>t.label===e),n){n.options.push(r);continue}n={label:e,options:[r]},t.push(n)}return t}function he({autoComplete:e,autoFocus:t,children:n,className:r,customization:i,defaultValue:a,disabled:o,form:s,id:u,multiple:d,name:f,required:p,style:m,tabIndex:h,title:g,value:_,onChange:y,onInput:b,onValueChange:x,onInvalid:S,ref:C,...w}){let T=(0,c.useMemo)(()=>ie(n),[n]),E=_!==void 0,D=(0,c.useRef)(a),[O,k]=(0,c.useState)(()=>{let e=v(E?_:a);return d?e:e.slice(0,1)}),A=(0,c.useMemo)(()=>E?v(_):O,[O,E,_]),j=(0,c.useId)(),M=d?f:f??`_toggle-button-select-${j}`,N=i?.classNamePrefix??`super-select`,P=N.length>0?`${N}__`:``,F=(0,c.useCallback)(e=>H({id:u,name:f,multiple:d,disabled:o,required:p,value:d?e:e[0]}),[u,f,d,p,o]),I=(0,c.useCallback)(e=>{e.preventDefault(),S&&S(te(F(A)))},[F,S,A]),L=(0,c.useCallback)(()=>{if(!E){let e=v(D.current);k(d?e:e.slice(0,1))}},[E,d]),R=(0,c.useCallback)(e=>{if(o)return;let t;t=d?A.includes(e)?A.filter(t=>t!==e):[...A,e]:A.includes(e)?[]:[e],E||k(t);let n=F(t);b&&b(W(n,{data:``})),y&&y(ee(n)),x&&x(d?t:t[0]??``)},[F,o,E,d,y,b,x,A]),z=!!p,B=i?.component??pe,V={...w,size:void 0},U=V,G=ne(F(A),V);return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(B,{...U,...G,autoComplete:e,autoFocus:t,className:r,customization:i,disabled:o,form:s,id:u,multiple:d,name:M,value:A,onValueToggle:R,options:T,required:p,style:m,tabIndex:h,title:g,ref:C}),z?(0,l.jsx)(`input`,{type:`checkbox`,checked:A.length>0,required:!0,disabled:o,form:s,tabIndex:-1,"aria-hidden":!0,hidden:!0,onChange:()=>void 0,onInvalid:I,className:`${P}visually-hidden`}):null,E?null:(0,l.jsx)(re,{form:s,onReset:L})]})}function ge({"aria-busy":e,"aria-describedby":t,"aria-label":n,"aria-labelledby":r,accessKey:i,children:a,className:o,dir:s,hidden:c,id:d,lang:f,style:p,tabIndex:m,title:h,customization:g}){let _=g?.classNamePrefix??`super-select`,v=_.length>0?`${_}__`:``;return(0,l.jsx)(`div`,{id:d,"aria-busy":e,"aria-describedby":t,"aria-label":n,"aria-labelledby":r,accessKey:i,className:u(`${v}list-group`,o),dir:s,hidden:c,lang:f,style:p,tabIndex:m,title:h,children:(0,l.jsx)(`div`,{className:`${v}list-group-item`,children:a})})}function _e({mode:e,optionSource:t,customization:n,ref:r,children:i,multiple:a,disabled:o,required:s,value:d,defaultValue:f,onChange:p,onInvalid:m,onValueChange:h,className:g,style:_,...y}){Te(t);let b=typeof e==`function`?void 0:e,x=typeof e==`function`?e:void 0,S=!!t&&(!!x||b!==void 0&&!be(b)),[w,T]=(0,c.useState)(0),E=(0,c.useMemo)(()=>({optionSource:t,retryCount:w,shouldLoadOptions:S}),[w,t,S]),[D,O]=(0,c.useState)(()=>S?we(E):Se);(0,c.useEffect)(()=>{if(!t||!S)return;let e=new AbortController,n=!1;return Promise.resolve().then(()=>{if(!(n||e.signal.aborted))return O(we(E)),t.getOptionPage({signal:e.signal})}).then(t=>{!t||n||e.signal.aborted||O({loadKey:E,options:t.options,hasMore:!!t.hasMore,isPending:!1,error:void 0})}).catch(t=>{n||e.signal.aborted||O({loadKey:E,options:[],hasMore:!1,isPending:!1,error:A(t)})}),()=>{n=!0,e.abort()}},[t,E,S]);let k=(0,c.useMemo)(()=>ie(i),[i]),j=Se;S&&(j=D.loadKey===E?D:we(E));let M=(0,c.useMemo)(()=>F(k,j.options),[j.options,k]),N=(0,c.useMemo)(()=>{if(b)return b;if(x){let e=x({options:M,hasMore:j.hasMore,multiple:!!a,disabled:!!o,required:!!s,optionSource:t,error:j.error});if(e)return e}return`modal`},[o,M,x,a,t,b,s,j.error,j.hasMore]),P=d!==void 0,I=(0,c.useRef)(f),[L,R]=(0,c.useState)(void 0),[z,B]=(0,c.useState)(0),V=(0,c.useCallback)(e=>{let t=Array.from(e.currentTarget.selectedOptions).map(e=>e?.value??``),n=[];a&&t.length>0?n=t:e.currentTarget.value&&e.currentTarget.value.length>0&&(n=[e.currentTarget.value]),P||R(a?n:n[0]??``),h&&h(a?n:n[0]??``),p&&p(e)},[P,a,p,h]),U=S&&!j.isPending&&j.error===void 0&&(!be(N)||!j.hasMore),ee=t&&be(N)&&!U?t:void 0,W=U?xe(i,k,j.options):i,G=L===void 0?f:L,K=(0,c.useMemo)(()=>{let e=v(P?d:G);return a?e:e.slice(0,1)},[G,P,a,d]),ne=(0,c.useCallback)(()=>{T(e=>e+1)},[]),q=(0,c.useCallback)(()=>{P||(R(I.current),B(e=>e+1))},[P]),J=n?.classNamePrefix??`super-select`,X=J.length>0?`${J}__`:``,ae=n?.fallback?.component??ge,Z=n?.pendingIndicator?.component??C,oe=n?.errorIndicator?.component??Y,Q=u(g,n?.fallback?.className),se=_&&n?.fallback?.style?{..._,...n.fallback.style}:_??n?.fallback?.style,$;S&&j.isPending?$=(0,l.jsx)(Z,{inline:!0,className:n?.pendingIndicator?.className,style:n?.pendingIndicator?.style,title:n?.pendingIndicator?.title,content:n?.pendingIndicator?.content,customization:{classNamePrefix:J}}):S&&j.error&&($=(0,l.jsx)(oe,{className:n?.errorIndicator?.className,style:n?.errorIndicator?.style,error:j.error,message:j.error.userMessage??n?.errorIndicator?.defaultMessage,onRetry:ne,customization:{classNamePrefix:J,icon:n?.errorIndicator?.icon,retryButton:n?.errorIndicator?.retryButton}}));let ce=y.name&&K.length>0?a?K.map((e,t)=>(0,l.jsx)(`input`,{type:`hidden`,name:y.name,value:e,form:y.form,disabled:o},`super-select-async-hidden-value-${e}-${t}`)):(0,l.jsx)(`input`,{type:`hidden`,name:y.name,value:K[0]??``,form:y.form,disabled:o}):null;return $?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(ae,{id:y.id,"aria-busy":j.isPending||void 0,"aria-describedby":y[`aria-describedby`],"aria-label":y[`aria-label`],"aria-labelledby":y[`aria-labelledby`],accessKey:y.accessKey,className:Q,dir:y.dir,hidden:y.hidden,lang:y.lang,style:se,tabIndex:y.tabIndex,title:y.title,customization:{classNamePrefix:J},children:$}),ce,s?(0,l.jsx)(`select`,{required:!0,disabled:o,form:y.form,multiple:a,value:a?K:K[0]??``,onChange:()=>void 0,onInvalid:e=>{e.preventDefault(),m&&m(te(H({id:y.id,name:y.name,value:a?K:K[0]??``,multiple:a,disabled:o,required:s})))},"aria-hidden":!0,tabIndex:-1,className:`${X}visually-hidden`,children:K.map(e=>(0,l.jsx)(`option`,{value:e,children:e},e))}):null,P?null:(0,l.jsx)(re,{form:y.form,onReset:q})]}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(ve,{ref:r,...y,mode:N,className:g,style:_,multiple:a,disabled:o,required:s,value:d,defaultValue:P?void 0:G,onChange:V,onInvalid:m,optionSource:ee,customization:n,children:W},z),P?null:(0,l.jsx)(re,{form:y.form,onReset:q})]})}function ve({mode:e,onChange:t,optionSource:n,customization:r,children:i,ref:a,...o}){let s=r?.classNamePrefix??`super-select`;if(e===`option-list`)return(0,l.jsx)(fe,{ref:a,...o,onChange:t,optionSource:n,customization:r,children:i});if(e===`toggle-button`)return(0,l.jsx)(he,{ref:a,...o,className:r?.toggleButtonInput?.className??o.className,style:o.style&&r?.toggleButtonInput?.style?{...o.style,...r.toggleButtonInput.style}:o.style??r?.toggleButtonInput?.style,onChange:t,customization:r?{classNamePrefix:s,...r.toggleButtonInput}:void 0,children:i});if(e===`native`){let e=s.length>0?`${s}__`:``,n=r?.selectInput?.component??ye,c=r?.selectInput?.className??o.className;return n===ye&&(c=u(`${e}form-select`,c)),(0,l.jsx)(n,{ref:a,...o,className:c,style:o.style&&r?.selectInput?.style?{...o.style,...r.selectInput.style}:o.style??r?.selectInput?.style,onChange:t,children:i})}return(0,l.jsx)(ce,{ref:a,...o,onChange:t,optionSource:n,customization:r,children:i})}function ye({ref:e,...t}){return(0,l.jsx)(`select`,{ref:e,...t})}function be(e){return e===`modal`||e===`option-list`}function xe(e,t,n){if(n.length===0)return e;let r=[],i=new Set(t.map(e=>e.value));for(let e of n)i.has(e.value)||(i.add(e.value),r.push(e));if(r.length===0)return e;let a=[],o=0,s=0;for(;o<r.length;){let e=r[o],t=e.groupLabel;if(!t){a.push((0,l.jsx)(`option`,{value:e.value,disabled:e.disabled,hidden:e.hidden,label:e.label,children:e.children??e.label},`super-select-async-option-${s}-${e.value}`)),o+=1,s+=1;continue}let n=[];for(;o<r.length&&r[o].groupLabel===t;)n.push(r[o]),o+=1,s+=1;a.push((0,l.jsx)(`optgroup`,{label:t,children:n.map((e,t)=>(0,l.jsx)(`option`,{value:e.value,disabled:e.disabled,hidden:e.hidden,label:e.label,children:e.children??e.label},`super-select-async-group-option-${s}-${t}-${e.value}`))},`super-select-async-group-${s}-${t}`))}if(!e)return a;let u=c.Children.toArray(e);return u.length===0?a:[...u,...a]}var Se={options:[],hasMore:!1,isPending:!1,error:void 0},Ce={options:[],hasMore:!1,isPending:!0,error:void 0};function we(e){return{...Ce,loadKey:e}}function Te(e){let t=(0,c.useRef)(e),n=(0,c.useRef)(0),r=(0,c.useRef)(0);(0,c.useEffect)(()=>{if(typeof process<`u`&&process.env&&process.env.NODE_ENV===`production`)return;let i=t.current;if(t.current=e,!e||!i||e===i)return;let a=Date.now();a-r.current>2e3&&(r.current=a,n.current=0),n.current+=1,n.current===5&&console.warn(`SuperSelect: the optionSource prop changed identity 5 times within 2 seconds. Each new option source discards cached options and fetches again. If the source is created during render, keep one instance across renders with the useOptionSource hook or useMemo.`)})}function Ee(e,t=[]){return(0,c.useMemo)(()=>M(e),t)}exports.CloseButton=d,exports.EmptyIndicator=h,exports.ErrorIndicator=Y,exports.Fallback=ge,exports.Modal=f,exports.ModalSelect=ce,exports.ModalSelectButton=oe,exports.MoreIndicator=_,exports.OkButton=se,exports.OptionList=de,exports.OptionListInput=y,exports.OptionListSelect=fe,exports.OptionSource=j,exports.OptionSourceError=D,exports.PendingIndicator=C,exports.SearchInput=w,exports.SelectedContent=$,exports.SuperSelect=_e,exports.ToggleButtonInput=pe,exports.ToggleButtonSelect=he,exports.convertToOptionSourceError=A,exports.createOptionSource=M,exports.isOptionSourceErrorLike=O,exports.useOptionSource=Ee;
|
|
@@ -1426,4 +1426,10 @@ export declare interface ToggleButtonSelectProps<Multiple extends boolean = bool
|
|
|
1426
1426
|
};
|
|
1427
1427
|
}
|
|
1428
1428
|
|
|
1429
|
+
/**
|
|
1430
|
+
* Creates and memoizes an option source from a fetcher, configuration object, or existing option source.
|
|
1431
|
+
* The option source will only be recreated when one of the optional `deps` has changed.
|
|
1432
|
+
*/
|
|
1433
|
+
export declare function useOptionSource<TData = unknown>(init: OptionSourceLike<TData> | OptionSourceInit<TData> | OptionSourceFetcher<TData>, deps?: default_2.DependencyList): OptionSourceLike<TData>;
|
|
1434
|
+
|
|
1429
1435
|
export { }
|
|
@@ -390,7 +390,9 @@ var D = class {
|
|
|
390
390
|
values: e?.values ? [...e.values] : void 0
|
|
391
391
|
};
|
|
392
392
|
for (let e = 0; e < this.pendingQueryRuns.length; e++) {
|
|
393
|
-
let r = this.pendingQueryRuns[e]
|
|
393
|
+
let r = this.pendingQueryRuns[e];
|
|
394
|
+
if (r.abortController.signal.aborted) continue;
|
|
395
|
+
let i = r.query.values, a = n.values, o = !1;
|
|
394
396
|
if (i === a) o = !0;
|
|
395
397
|
else if (i && a && i.length === a.length) {
|
|
396
398
|
o = !0;
|
|
@@ -2107,6 +2109,7 @@ function ve({ "aria-busy": e, "aria-describedby": t, "aria-label": n, "aria-labe
|
|
|
2107
2109
|
//#endregion
|
|
2108
2110
|
//#region src/SuperSelect.tsx
|
|
2109
2111
|
function ye({ mode: e, optionSource: t, customization: n, ref: a, children: p, multiple: m, disabled: h, required: g, value: _, defaultValue: v, onChange: y, onInvalid: x, onValueChange: S, className: C, style: w, ...E }) {
|
|
2112
|
+
De(t);
|
|
2110
2113
|
let D = typeof e == "function" ? void 0 : e, O = typeof e == "function" ? e : void 0, k = !!t && (!!O || D !== void 0 && !Se(D)), [A, j] = c(0), N = o(() => ({
|
|
2111
2114
|
optionSource: t,
|
|
2112
2115
|
retryCount: A,
|
|
@@ -2406,5 +2409,20 @@ function Ee(e) {
|
|
|
2406
2409
|
loadKey: e
|
|
2407
2410
|
};
|
|
2408
2411
|
}
|
|
2412
|
+
function De(e) {
|
|
2413
|
+
let t = s(e), n = s(0), r = s(0);
|
|
2414
|
+
i(() => {
|
|
2415
|
+
if (typeof process < "u" && process.env && process.env.NODE_ENV === "production") return;
|
|
2416
|
+
let i = t.current;
|
|
2417
|
+
if (t.current = e, !e || !i || e === i) return;
|
|
2418
|
+
let a = Date.now();
|
|
2419
|
+
a - r.current > 2e3 && (r.current = a, n.current = 0), n.current += 1, n.current === 5 && console.warn("SuperSelect: the optionSource prop changed identity 5 times within 2 seconds. Each new option source discards cached options and fetches again. If the source is created during render, keep one instance across renders with the useOptionSource hook or useMemo.");
|
|
2420
|
+
});
|
|
2421
|
+
}
|
|
2422
|
+
//#endregion
|
|
2423
|
+
//#region src/useOptionSource.ts
|
|
2424
|
+
function Oe(e, t = []) {
|
|
2425
|
+
return o(() => P(e), t);
|
|
2426
|
+
}
|
|
2409
2427
|
//#endregion
|
|
2410
|
-
export { p as CloseButton, _ as EmptyIndicator, ae as ErrorIndicator, ve as Fallback, m as Modal, $ as ModalSelect, Q as ModalSelectButton, y as MoreIndicator, le as OkButton, pe as OptionList, x as OptionListInput, me as OptionListSelect, N as OptionSource, k as OptionSourceError, T as PendingIndicator, E as SearchInput, ue as SelectedContent, ye as SuperSelect, he as ToggleButtonInput, _e as ToggleButtonSelect, M as convertToOptionSourceError, P as createOptionSource, A as isOptionSourceErrorLike };
|
|
2428
|
+
export { p as CloseButton, _ as EmptyIndicator, ae as ErrorIndicator, ve as Fallback, m as Modal, $ as ModalSelect, Q as ModalSelectButton, y as MoreIndicator, le as OkButton, pe as OptionList, x as OptionListInput, me as OptionListSelect, N as OptionSource, k as OptionSourceError, T as PendingIndicator, E as SearchInput, ue as SelectedContent, ye as SuperSelect, he as ToggleButtonInput, _e as ToggleButtonSelect, M as convertToOptionSourceError, P as createOptionSource, A as isOptionSourceErrorLike, Oe as useOptionSource };
|
package/package.json
CHANGED