@adamosuiteservices/ui 1.6.6 → 1.6.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/combobox.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("./jsx-runtime-BB_1_6y_.cjs"),oe=require("react"),P=require("./index-DoxiiusW.cjs"),Ie=require("./button-DEQVHMrX.cjs"),Z=require("./index-BFyr34mw.cjs"),D=require("./index-CocSS1YK.cjs"),_=require("./index-WIv2ndLu.cjs"),X=require("./index-_XxjJPRD.cjs"),Ce=require("./createLucideIcon-CAtnV-yz.cjs"),ne=require("./popover-FCKBtFo-.cjs"),Ae=require("./checkbox-YWAnswaW.cjs"),$e=require("./chevron-down-BqEHzml5.cjs"),qe=require("./check-CLxNVljQ.cjs");function Ne(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const p=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,p.get?p:{enumerable:!0,get:()=>e[r]})}}return n.default=e,Object.freeze(n)}const a=Ne(oe);/**
|
|
2
2
|
* @license lucide-react v0.546.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
5
5
|
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const Me=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Ne=Ce.createLucideIcon("search",Me);var he=1,De=.9,Le=.8,Oe=.17,ae=.1,le=.999,ze=.9999,Fe=.99,Ve=/[\\\/_+.#"@\[\(\{&]/,Ke=/[\\\/_+.#"@\[\(\{&]/g,Te=/[\s-]/,be=/[\s-]/g;function ue(e,n,r,d,i,c,m){if(c===n.length)return i===e.length?he:Fe;var f=`${i},${c}`;if(m[f]!==void 0)return m[f];for(var h=d.charAt(c),o=r.indexOf(h,i),b=0,u,R,k,$;o>=0;)u=ue(e,n,r,d,o+1,c+1,m),u>b&&(o===i?u*=he:Ve.test(e.charAt(o-1))?(u*=Le,k=e.slice(i,o-1).match(Ke),k&&i>0&&(u*=Math.pow(le,k.length))):Te.test(e.charAt(o-1))?(u*=De,$=e.slice(i,o-1).match(be),$&&i>0&&(u*=Math.pow(le,$.length))):(u*=Oe,i>0&&(u*=Math.pow(le,o-i))),e.charAt(o)!==n.charAt(c)&&(u*=ze)),(u<ae&&r.charAt(o-1)===d.charAt(c+1)||d.charAt(c+1)===d.charAt(c)&&r.charAt(o-1)!==d.charAt(c))&&(R=ue(e,n,r,d,o+1,c+2,m),R*ae>u&&(u=R*ae)),u>b&&(b=u),o=r.indexOf(h,o+1);return m[f]=b,b}function xe(e){return e.toLowerCase().replace(be," ")}function _e(e,n,r){return e=r&&r.length>0?`${e+" "+r.join(" ")}`:e,ue(e,n,xe(e),xe(n),0,0,{})}var J='[cmdk-group=""]',oe='[cmdk-group-items=""]',Be='[cmdk-group-heading=""]',ye='[cmdk-item=""]',ge=`${ye}:not([aria-disabled="true"])`,ce="cmdk-item-select",K="data-value",Ge=(e,n,r)=>_e(e,n,r),je=a.createContext(void 0),Y=()=>a.useContext(je),Ee=a.createContext(void 0),se=()=>a.useContext(Ee),Re=a.createContext(void 0),ke=a.forwardRef((e,n)=>{let r=T(()=>{var t,s;return{search:"",value:(s=(t=e.value)!=null?t:e.defaultValue)!=null?s:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),d=T(()=>new Set),i=T(()=>new Map),c=T(()=>new Map),m=T(()=>new Set),f=we(e),{label:h,children:o,value:b,onValueChange:u,filter:R,shouldFilter:k,loop:$,disablePointerSelection:G=!1,vimBindings:x=!0,...U}=e,I=_.useId(),H=_.useId(),D=_.useId(),C=a.useRef(null),j=rt();z(()=>{if(b!==void 0){let t=b.trim();r.current.value=t,w.emit()}},[b]),z(()=>{j(6,de)},[]);let w=a.useMemo(()=>({subscribe:t=>(m.current.add(t),()=>m.current.delete(t)),snapshot:()=>r.current,setState:(t,s,v)=>{var l,y,E,A;if(!Object.is(r.current[t],s)){if(r.current[t]=s,t==="search")O(),P(),j(1,L);else if(t==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let S=document.getElementById(D);S?S.focus():(l=document.getElementById(I))==null||l.focus()}if(j(7,()=>{var S;r.current.selectedItemId=(S=V())==null?void 0:S.id,w.emit()}),v||j(5,de),((y=f.current)==null?void 0:y.value)!==void 0){let S=s??"";(A=(E=f.current).onValueChange)==null||A.call(E,S);return}}w.emit()}},emit:()=>{m.current.forEach(t=>t())}}),[]),F=a.useMemo(()=>({value:(t,s,v)=>{var l;s!==((l=c.current.get(t))==null?void 0:l.value)&&(c.current.set(t,{value:s,keywords:v}),r.current.filtered.items.set(t,p(s,v)),j(2,()=>{P(),w.emit()}))},item:(t,s)=>(d.current.add(t),s&&(i.current.has(s)?i.current.get(s).add(t):i.current.set(s,new Set([t]))),j(3,()=>{O(),P(),r.current.value||L(),w.emit()}),()=>{c.current.delete(t),d.current.delete(t),r.current.filtered.items.delete(t);let v=V();j(4,()=>{O(),v?.getAttribute("id")===t&&L(),w.emit()})}),group:t=>(i.current.has(t)||i.current.set(t,new Set),()=>{c.current.delete(t),i.current.delete(t)}),filter:()=>f.current.shouldFilter,label:h||e["aria-label"],getDisablePointerSelection:()=>f.current.disablePointerSelection,listId:I,inputId:D,labelId:H,listInnerRef:C}),[]);function p(t,s){var v,l;let y=(l=(v=f.current)==null?void 0:v.filter)!=null?l:Ge;return t?y(t,r.current.search,s):0}function P(){if(!r.current.search||f.current.shouldFilter===!1)return;let t=r.current.filtered.items,s=[];r.current.filtered.groups.forEach(l=>{let y=i.current.get(l),E=0;y.forEach(A=>{let S=t.get(A);E=Math.max(S,E)}),s.push([l,E])});let v=C.current;W().sort((l,y)=>{var E,A;let S=l.getAttribute("id"),Q=y.getAttribute("id");return((E=t.get(Q))!=null?E:0)-((A=t.get(S))!=null?A:0)}).forEach(l=>{let y=l.closest(oe);y?y.appendChild(l.parentElement===y?l:l.closest(`${oe} > *`)):v.appendChild(l.parentElement===v?l:l.closest(`${oe} > *`))}),s.sort((l,y)=>y[1]-l[1]).forEach(l=>{var y;let E=(y=C.current)==null?void 0:y.querySelector(`${J}[${K}="${encodeURIComponent(l[0])}"]`);E?.parentElement.appendChild(E)})}function L(){let t=W().find(v=>v.getAttribute("aria-disabled")!=="true"),s=t?.getAttribute(K);w.setState("value",s||void 0)}function O(){var t,s,v,l;if(!r.current.search||f.current.shouldFilter===!1){r.current.filtered.count=d.current.size;return}r.current.filtered.groups=new Set;let y=0;for(let E of d.current){let A=(s=(t=c.current.get(E))==null?void 0:t.value)!=null?s:"",S=(l=(v=c.current.get(E))==null?void 0:v.keywords)!=null?l:[],Q=p(A,S);r.current.filtered.items.set(E,Q),Q>0&&y++}for(let[E,A]of i.current)for(let S of A)if(r.current.filtered.items.get(S)>0){r.current.filtered.groups.add(E);break}r.current.filtered.count=y}function de(){var t,s,v;let l=V();l&&(((t=l.parentElement)==null?void 0:t.firstChild)===l&&((v=(s=l.closest(J))==null?void 0:s.querySelector(Be))==null||v.scrollIntoView({block:"nearest"})),l.scrollIntoView({block:"nearest"}))}function V(){var t;return(t=C.current)==null?void 0:t.querySelector(`${ye}[aria-selected="true"]`)}function W(){var t;return Array.from(((t=C.current)==null?void 0:t.querySelectorAll(ge))||[])}function te(t){let s=W()[t];s&&w.setState("value",s.getAttribute(K))}function re(t){var s;let v=V(),l=W(),y=l.findIndex(A=>A===v),E=l[y+t];(s=f.current)!=null&&s.loop&&(E=y+t<0?l[l.length-1]:y+t===l.length?l[0]:l[y+t]),E&&w.setState("value",E.getAttribute(K))}function me(t){let s=V(),v=s?.closest(J),l;for(;v&&!l;)v=t>0?et(v,J):tt(v,J),l=v?.querySelector(ge);l?w.setState("value",l.getAttribute(K)):re(t)}let fe=()=>te(W().length-1),pe=t=>{t.preventDefault(),t.metaKey?fe():t.altKey?me(1):re(1)},ve=t=>{t.preventDefault(),t.metaKey?te(0):t.altKey?me(-1):re(-1)};return a.createElement(N.Primitive.div,{ref:n,tabIndex:-1,...U,"cmdk-root":"",onKeyDown:t=>{var s;(s=U.onKeyDown)==null||s.call(U,t);let v=t.nativeEvent.isComposing||t.keyCode===229;if(!(t.defaultPrevented||v))switch(t.key){case"n":case"j":{x&&t.ctrlKey&&pe(t);break}case"ArrowDown":{pe(t);break}case"p":case"k":{x&&t.ctrlKey&&ve(t);break}case"ArrowUp":{ve(t);break}case"Home":{t.preventDefault(),te(0);break}case"End":{t.preventDefault(),fe();break}case"Enter":{t.preventDefault();let l=V();if(l){let y=new Event(ce);l.dispatchEvent(y)}}}}},a.createElement("label",{"cmdk-label":"",htmlFor:F.inputId,id:F.labelId,style:at},h),ee(e,t=>a.createElement(Ee.Provider,{value:w},a.createElement(je.Provider,{value:F},t))))}),Ue=a.forwardRef((e,n)=>{var r,d;let i=_.useId(),c=a.useRef(null),m=a.useContext(Re),f=Y(),h=we(e),o=(d=(r=h.current)==null?void 0:r.forceMount)!=null?d:m?.forceMount;z(()=>{if(!o)return f.item(i,m?.id)},[o]);let b=Se(i,c,[e.value,e.children,c],e.keywords),u=se(),R=M(j=>j.value&&j.value===b.current),k=M(j=>o||f.filter()===!1?!0:j.search?j.filtered.items.get(i)>0:!0);a.useEffect(()=>{let j=c.current;if(!(!j||e.disabled))return j.addEventListener(ce,$),()=>j.removeEventListener(ce,$)},[k,e.onSelect,e.disabled]);function $(){var j,w;G(),(w=(j=h.current).onSelect)==null||w.call(j,b.current)}function G(){u.setState("value",b.current,!0)}if(!k)return null;let{disabled:x,value:U,onSelect:I,forceMount:H,keywords:D,...C}=e;return a.createElement(N.Primitive.div,{ref:X.composeRefs(c,n),...C,id:i,"cmdk-item":"",role:"option","aria-disabled":!!x,"aria-selected":!!R,"data-disabled":!!x,"data-selected":!!R,onPointerMove:x||f.getDisablePointerSelection()?void 0:G,onClick:x?void 0:$},e.children)}),He=a.forwardRef((e,n)=>{let{heading:r,children:d,forceMount:i,...c}=e,m=_.useId(),f=a.useRef(null),h=a.useRef(null),o=_.useId(),b=Y(),u=M(k=>i||b.filter()===!1?!0:k.search?k.filtered.groups.has(m):!0);z(()=>b.group(m),[]),Se(m,f,[e.value,e.heading,h]);let R=a.useMemo(()=>({id:m,forceMount:i}),[i]);return a.createElement(N.Primitive.div,{ref:X.composeRefs(f,n),...c,"cmdk-group":"",role:"presentation",hidden:u?void 0:!0},r&&a.createElement("div",{ref:h,"cmdk-group-heading":"","aria-hidden":!0,id:o},r),ee(e,k=>a.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":r?o:void 0},a.createElement(Re.Provider,{value:R},k))))}),We=a.forwardRef((e,n)=>{let{alwaysRender:r,...d}=e,i=a.useRef(null),c=M(m=>!m.search);return!r&&!c?null:a.createElement(N.Primitive.div,{ref:X.composeRefs(i,n),...d,"cmdk-separator":"",role:"separator"})}),Je=a.forwardRef((e,n)=>{let{onValueChange:r,...d}=e,i=e.value!=null,c=se(),m=M(o=>o.search),f=M(o=>o.selectedItemId),h=Y();return a.useEffect(()=>{e.value!=null&&c.setState("search",e.value)},[e.value]),a.createElement(N.Primitive.input,{ref:n,...d,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":h.listId,"aria-labelledby":h.labelId,"aria-activedescendant":f,id:h.inputId,type:"text",value:i?e.value:m,onChange:o=>{i||c.setState("search",o.target.value),r?.(o.target.value)}})}),Xe=a.forwardRef((e,n)=>{let{children:r,label:d="Suggestions",...i}=e,c=a.useRef(null),m=a.useRef(null),f=M(o=>o.selectedItemId),h=Y();return a.useEffect(()=>{if(m.current&&c.current){let o=m.current,b=c.current,u,R=new ResizeObserver(()=>{u=requestAnimationFrame(()=>{let k=o.offsetHeight;b.style.setProperty("--cmdk-list-height",k.toFixed(1)+"px")})});return R.observe(o),()=>{cancelAnimationFrame(u),R.unobserve(o)}}},[]),a.createElement(N.Primitive.div,{ref:X.composeRefs(c,n),...i,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":f,"aria-label":d,id:h.listId},ee(e,o=>a.createElement("div",{ref:X.composeRefs(m,h.listInnerRef),"cmdk-list-sizer":""},o)))}),Ye=a.forwardRef((e,n)=>{let{open:r,onOpenChange:d,overlayClassName:i,contentClassName:c,container:m,...f}=e;return a.createElement(Z.Root,{open:r,onOpenChange:d},a.createElement(Z.Portal,{container:m},a.createElement(Z.Overlay,{"cmdk-overlay":"",className:i}),a.createElement(Z.Content,{"aria-label":e.label,"cmdk-dialog":"",className:c},a.createElement(ke,{ref:n,...f}))))}),Qe=a.forwardRef((e,n)=>M(r=>r.filtered.count===0)?a.createElement(N.Primitive.div,{ref:n,...e,"cmdk-empty":"",role:"presentation"}):null),Ze=a.forwardRef((e,n)=>{let{progress:r,children:d,label:i="Loading...",...c}=e;return a.createElement(N.Primitive.div,{ref:n,...c,"cmdk-loading":"",role:"progressbar","aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},ee(e,m=>a.createElement("div",{"aria-hidden":!0},m)))}),B=Object.assign(ke,{List:Xe,Item:Ue,Input:Je,Group:He,Separator:We,Dialog:Ye,Empty:Qe,Loading:Ze});function et(e,n){let r=e.nextElementSibling;for(;r;){if(r.matches(n))return r;r=r.nextElementSibling}}function tt(e,n){let r=e.previousElementSibling;for(;r;){if(r.matches(n))return r;r=r.previousElementSibling}}function we(e){let n=a.useRef(e);return z(()=>{n.current=e}),n}var z=typeof window>"u"?a.useEffect:a.useLayoutEffect;function T(e){let n=a.useRef();return n.current===void 0&&(n.current=e()),n}function M(e){let n=se(),r=()=>e(n.snapshot());return a.useSyncExternalStore(n.subscribe,r,r)}function Se(e,n,r,d=[]){let i=a.useRef(),c=Y();return z(()=>{var m;let f=(()=>{var o;for(let b of r){if(typeof b=="string")return b.trim();if(typeof b=="object"&&"current"in b)return b.current?(o=b.current.textContent)==null?void 0:o.trim():i.current}})(),h=d.map(o=>o.trim());c.value(e,f,h),(m=n.current)==null||m.setAttribute(K,f),i.current=f}),i}var rt=()=>{let[e,n]=a.useState(),r=T(()=>new Map);return z(()=>{r.current.forEach(d=>d()),r.current=new Map},[e]),(d,i)=>{r.current.set(d,i),n({})}};function nt(e){let n=e.type;return typeof n=="function"?n(e.props):"render"in n?n.render(e.props):e}function ee({asChild:e,children:n},r){return e&&a.isValidElement(n)?a.cloneElement(nt(n),{ref:n.ref},r(n.props.children)):r(n)}var at={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};function lt({className:e,...n}){return g.jsxRuntimeExports.jsx(B,{"data-slot":"command",className:q.cn("adm:bg-popover adm:text-popover-foreground adm:flex adm:h-full adm:w-full adm:flex-col adm:overflow-hidden adm:rounded-md",e),...n})}function ot({className:e,...n}){return g.jsxRuntimeExports.jsxs("div",{"data-slot":"command-input-wrapper",className:"adm:flex adm:h-9 adm:items-center adm:gap-2 adm:border-b adm:px-3",children:[g.jsxRuntimeExports.jsx(Ne,{className:"adm:size-4 adm:shrink-0 adm:opacity-50"}),g.jsxRuntimeExports.jsx(B.Input,{"data-slot":"command-input",className:q.cn("adm:placeholder:text-muted-foreground adm:flex adm:h-10 adm:w-full adm:rounded-md adm:bg-transparent adm:py-3 adm:text-sm adm:outline-hidden adm:disabled:cursor-not-allowed adm:disabled:opacity-50",e),...n})]})}function it({className:e,...n}){return g.jsxRuntimeExports.jsx(B.List,{"data-slot":"command-list",className:q.cn("adm:max-h-[300px] adm:scroll-py-1 adm:overflow-x-hidden adm:overflow-y-auto",e),...n})}function ut({className:e,...n}){return g.jsxRuntimeExports.jsx(B.Empty,{"data-slot":"command-empty",className:q.cn("adm:py-6 adm:text-center adm:text-sm",e),...n})}function ct({className:e,...n}){return g.jsxRuntimeExports.jsx(B.Group,{"data-slot":"command-group",className:q.cn("adm:text-foreground adm:overflow-hidden adm:p-1 adm:**:**:**:**:**:**:[&_[cmdk-group-heading]]:text-muted-foreground adm:**:**:**:**:**:**:[&_[cmdk-group-heading]]:px-2 adm:**:**:**:**:**:**:[&_[cmdk-group-heading]]:py-1.5 adm:**:**:**:**:**:**:[&_[cmdk-group-heading]]:text-xs adm:**:**:**:**:**:**:[&_[cmdk-group-heading]]:font-medium",e),...n})}function st({className:e,...n}){return g.jsxRuntimeExports.jsx(B.Item,{"data-slot":"command-item",className:q.cn("adm:data-[selected=true]:bg-accent adm:data-[selected=true]:text-accent-foreground adm:[&_svg:not([class*=text-])]:text-muted-foreground adm:relative adm:flex adm:cursor-default adm:items-center adm:gap-2 adm:rounded-sm adm:px-2 adm:py-1.5 adm:text-sm adm:outline-hidden adm:select-none adm:data-[disabled=true]:pointer-events-none adm:data-[disabled=true]:opacity-50 adm:[&_svg]:pointer-events-none adm:[&_svg]:shrink-0 adm:[&_svg:not([class*=size-])]:size-4",e),...n})}function dt({searchable:e,multiple:n,icon:r,showIcon:d,value:i,onValueChange:c,labels:m,options:f,classNames:h,selectedFeedback:o="checkbox",alwaysShowPlaceholder:b=!1,renders:u}){const[R,k]=ie.useState(!1),[$,G]=ie.useState(n?[]:""),x=i!==void 0?i:$,I={...{placeholder:"Select options...",searchPlaceholder:"Search options...",noItemsFound:"No options found.",multipleSelected:p=>`${p} options selected`},...m},H=p=>{c?c(p):G(p)},D=()=>n&&Array.isArray(x)?x.length===0?null:x.length===1?f.find(p=>p.value===x[0])?.label:I.multipleSelected?.(x.length)||`${x.length} options selected`:!n&&typeof x=="string"&&x?f.find(p=>p.value===x)?.label:null,C=()=>n&&Array.isArray(x)?x.length>0:typeof x=="string"&&x!=="",j=p=>n&&Array.isArray(x)?x.includes(p):x===p,w=p=>{if(n){const P=Array.isArray(x)?x:[],L=P.includes(p)?P.filter(O=>O!==p):[...P,p];H(L)}else H(p===x?"":p),k(!1)},F=p=>{const P=j(p),L=f.find(O=>O.value===p);return u?.selectedFeedback?u.selectedFeedback({option:L,isSelected:P,type:o}):o==="check"?g.jsxRuntimeExports.jsx("span",{className:q.cn("adm:absolute adm:right-2 adm:flex adm:size-3.5 adm:items-center adm:justify-center",h?.check),children:P&&g.jsxRuntimeExports.jsx($e.Check,{className:"adm:size-4"})}):g.jsxRuntimeExports.jsx(Ae.Checkbox,{checked:P,className:h?.checkbox})};return g.jsxRuntimeExports.jsxs(ne.Popover,{open:R,onOpenChange:k,children:[g.jsxRuntimeExports.jsx(ne.PopoverTrigger,{asChild:!0,children:u?.trigger?u.trigger({open:R,value:x,displayText:D()??null,placeholder:I.placeholder||"",hasValue:C(),icon:r,showIcon:d}):g.jsxRuntimeExports.jsxs(Ie.Button,{variant:"outline",role:"combobox","aria-expanded":R,className:q.cn("adm:justify-between adm:font-normal",h?.trigger),children:[g.jsxRuntimeExports.jsxs("span",{className:"adm:flex adm:items-center adm:gap-2",children:[d&&r&&g.jsxRuntimeExports.jsx(r,{className:"adm:opacity-50"}),b&&C()&&(u?.placeholder?u.placeholder({text:I.placeholder||"",hasValue:C()}):g.jsxRuntimeExports.jsx("span",{className:"adm:opacity-70",children:I.placeholder})),C()?u?.displayValue?u.displayValue({text:D()??null,value:x}):g.jsxRuntimeExports.jsx("span",{children:D()}):u?.placeholder?u.placeholder({text:I.placeholder||"",hasValue:C()}):g.jsxRuntimeExports.jsx("span",{children:I.placeholder})]}),u?.triggerIcon?u.triggerIcon({open:R}):g.jsxRuntimeExports.jsx(Pe.ChevronDown,{className:"adm:size-4 adm:opacity-50"})]})}),g.jsxRuntimeExports.jsx(ne.PopoverContent,{align:"start",className:q.cn("adm:p-0",h?.popover),children:g.jsxRuntimeExports.jsxs(lt,{className:h?.command,children:[e&&(u?.searchInput?u.searchInput({placeholder:I.searchPlaceholder||""}):g.jsxRuntimeExports.jsx(ot,{placeholder:I.searchPlaceholder,className:h?.input})),g.jsxRuntimeExports.jsxs(it,{className:h?.list,children:[g.jsxRuntimeExports.jsx(ut,{className:h?.empty,children:u?.empty?u.empty({text:I.noItemsFound||""}):I.noItemsFound}),g.jsxRuntimeExports.jsx(ct,{className:h?.group,children:f.map(p=>u?.option?g.jsxRuntimeExports.jsx("div",{children:u.option({option:p,isSelected:j(p.value),selectedFeedback:o})},p.value):g.jsxRuntimeExports.jsxs(st,{value:p.value,onSelect:w,disabled:p.disabled,className:q.cn(h?.item,o==="check"&&"adm:pr-8"),children:[o==="checkbox"&&F(p.value),u?.optionLabel?u.optionLabel({option:p}):p.label,o==="check"&&F(p.value)]},p.value))})]})]})})]})}exports.Combobox=dt;
|
|
6
|
+
*/const Pe=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Me=Ce.createLucideIcon("search",Pe);var ve=1,De=.9,Le=.8,Oe=.17,ae=.1,le=.999,Ve=.9999,ze=.99,Fe=/[\\\/_+.#"@\[\(\{&]/,Ke=/[\\\/_+.#"@\[\(\{&]/g,Te=/[\s-]/,be=/[\s-]/g;function ue(e,n,r,p,i,c,m){if(c===n.length)return i===e.length?ve:ze;var d=`${i},${c}`;if(m[d]!==void 0)return m[d];for(var b=p.charAt(c),u=r.indexOf(b,i),g=0,o,R,k,N;u>=0;)o=ue(e,n,r,p,u+1,c+1,m),o>g&&(u===i?o*=ve:Fe.test(e.charAt(u-1))?(o*=Le,k=e.slice(i,u-1).match(Ke),k&&i>0&&(o*=Math.pow(le,k.length))):Te.test(e.charAt(u-1))?(o*=De,N=e.slice(i,u-1).match(be),N&&i>0&&(o*=Math.pow(le,N.length))):(o*=Oe,i>0&&(o*=Math.pow(le,u-i))),e.charAt(u)!==n.charAt(c)&&(o*=Ve)),(o<ae&&r.charAt(u-1)===p.charAt(c+1)||p.charAt(c+1)===p.charAt(c)&&r.charAt(u-1)!==p.charAt(c))&&(R=ue(e,n,r,p,u+1,c+2,m),R*ae>o&&(o=R*ae)),o>g&&(g=o),u=r.indexOf(b,u+1);return m[d]=g,g}function xe(e){return e.toLowerCase().replace(be," ")}function _e(e,n,r){return e=r&&r.length>0?`${e+" "+r.join(" ")}`:e,ue(e,n,xe(e),xe(n),0,0,{})}var J='[cmdk-group=""]',ie='[cmdk-group-items=""]',Be='[cmdk-group-heading=""]',ye='[cmdk-item=""]',ge=`${ye}:not([aria-disabled="true"])`,ce="cmdk-item-select",K="data-value",Ge=(e,n,r)=>_e(e,n,r),je=a.createContext(void 0),Y=()=>a.useContext(je),Ee=a.createContext(void 0),se=()=>a.useContext(Ee),Re=a.createContext(void 0),ke=a.forwardRef((e,n)=>{let r=T(()=>{var t,s;return{search:"",value:(s=(t=e.value)!=null?t:e.defaultValue)!=null?s:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),p=T(()=>new Set),i=T(()=>new Map),c=T(()=>new Map),m=T(()=>new Set),d=we(e),{label:b,children:u,value:g,onValueChange:o,filter:R,shouldFilter:k,loop:N,disablePointerSelection:G=!1,vimBindings:v=!0,...U}=e,I=_.useId(),H=_.useId(),q=_.useId(),C=a.useRef(null),j=rt();V(()=>{if(g!==void 0){let t=g.trim();r.current.value=t,w.emit()}},[g]),V(()=>{j(6,de)},[]);let w=a.useMemo(()=>({subscribe:t=>(m.current.add(t),()=>m.current.delete(t)),snapshot:()=>r.current,setState:(t,s,h)=>{var l,y,E,A;if(!Object.is(r.current[t],s)){if(r.current[t]=s,t==="search")O(),$(),j(1,L);else if(t==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let S=document.getElementById(q);S?S.focus():(l=document.getElementById(I))==null||l.focus()}if(j(7,()=>{var S;r.current.selectedItemId=(S=F())==null?void 0:S.id,w.emit()}),h||j(5,de),((y=d.current)==null?void 0:y.value)!==void 0){let S=s??"";(A=(E=d.current).onValueChange)==null||A.call(E,S);return}}w.emit()}},emit:()=>{m.current.forEach(t=>t())}}),[]),z=a.useMemo(()=>({value:(t,s,h)=>{var l;s!==((l=c.current.get(t))==null?void 0:l.value)&&(c.current.set(t,{value:s,keywords:h}),r.current.filtered.items.set(t,f(s,h)),j(2,()=>{$(),w.emit()}))},item:(t,s)=>(p.current.add(t),s&&(i.current.has(s)?i.current.get(s).add(t):i.current.set(s,new Set([t]))),j(3,()=>{O(),$(),r.current.value||L(),w.emit()}),()=>{c.current.delete(t),p.current.delete(t),r.current.filtered.items.delete(t);let h=F();j(4,()=>{O(),h?.getAttribute("id")===t&&L(),w.emit()})}),group:t=>(i.current.has(t)||i.current.set(t,new Set),()=>{c.current.delete(t),i.current.delete(t)}),filter:()=>d.current.shouldFilter,label:b||e["aria-label"],getDisablePointerSelection:()=>d.current.disablePointerSelection,listId:I,inputId:q,labelId:H,listInnerRef:C}),[]);function f(t,s){var h,l;let y=(l=(h=d.current)==null?void 0:h.filter)!=null?l:Ge;return t?y(t,r.current.search,s):0}function $(){if(!r.current.search||d.current.shouldFilter===!1)return;let t=r.current.filtered.items,s=[];r.current.filtered.groups.forEach(l=>{let y=i.current.get(l),E=0;y.forEach(A=>{let S=t.get(A);E=Math.max(S,E)}),s.push([l,E])});let h=C.current;W().sort((l,y)=>{var E,A;let S=l.getAttribute("id"),Q=y.getAttribute("id");return((E=t.get(Q))!=null?E:0)-((A=t.get(S))!=null?A:0)}).forEach(l=>{let y=l.closest(ie);y?y.appendChild(l.parentElement===y?l:l.closest(`${ie} > *`)):h.appendChild(l.parentElement===h?l:l.closest(`${ie} > *`))}),s.sort((l,y)=>y[1]-l[1]).forEach(l=>{var y;let E=(y=C.current)==null?void 0:y.querySelector(`${J}[${K}="${encodeURIComponent(l[0])}"]`);E?.parentElement.appendChild(E)})}function L(){let t=W().find(h=>h.getAttribute("aria-disabled")!=="true"),s=t?.getAttribute(K);w.setState("value",s||void 0)}function O(){var t,s,h,l;if(!r.current.search||d.current.shouldFilter===!1){r.current.filtered.count=p.current.size;return}r.current.filtered.groups=new Set;let y=0;for(let E of p.current){let A=(s=(t=c.current.get(E))==null?void 0:t.value)!=null?s:"",S=(l=(h=c.current.get(E))==null?void 0:h.keywords)!=null?l:[],Q=f(A,S);r.current.filtered.items.set(E,Q),Q>0&&y++}for(let[E,A]of i.current)for(let S of A)if(r.current.filtered.items.get(S)>0){r.current.filtered.groups.add(E);break}r.current.filtered.count=y}function de(){var t,s,h;let l=F();l&&(((t=l.parentElement)==null?void 0:t.firstChild)===l&&((h=(s=l.closest(J))==null?void 0:s.querySelector(Be))==null||h.scrollIntoView({block:"nearest"})),l.scrollIntoView({block:"nearest"}))}function F(){var t;return(t=C.current)==null?void 0:t.querySelector(`${ye}[aria-selected="true"]`)}function W(){var t;return Array.from(((t=C.current)==null?void 0:t.querySelectorAll(ge))||[])}function te(t){let s=W()[t];s&&w.setState("value",s.getAttribute(K))}function re(t){var s;let h=F(),l=W(),y=l.findIndex(A=>A===h),E=l[y+t];(s=d.current)!=null&&s.loop&&(E=y+t<0?l[l.length-1]:y+t===l.length?l[0]:l[y+t]),E&&w.setState("value",E.getAttribute(K))}function me(t){let s=F(),h=s?.closest(J),l;for(;h&&!l;)h=t>0?et(h,J):tt(h,J),l=h?.querySelector(ge);l?w.setState("value",l.getAttribute(K)):re(t)}let pe=()=>te(W().length-1),fe=t=>{t.preventDefault(),t.metaKey?pe():t.altKey?me(1):re(1)},he=t=>{t.preventDefault(),t.metaKey?te(0):t.altKey?me(-1):re(-1)};return a.createElement(D.Primitive.div,{ref:n,tabIndex:-1,...U,"cmdk-root":"",onKeyDown:t=>{var s;(s=U.onKeyDown)==null||s.call(U,t);let h=t.nativeEvent.isComposing||t.keyCode===229;if(!(t.defaultPrevented||h))switch(t.key){case"n":case"j":{v&&t.ctrlKey&&fe(t);break}case"ArrowDown":{fe(t);break}case"p":case"k":{v&&t.ctrlKey&&he(t);break}case"ArrowUp":{he(t);break}case"Home":{t.preventDefault(),te(0);break}case"End":{t.preventDefault(),pe();break}case"Enter":{t.preventDefault();let l=F();if(l){let y=new Event(ce);l.dispatchEvent(y)}}}}},a.createElement("label",{"cmdk-label":"",htmlFor:z.inputId,id:z.labelId,style:at},b),ee(e,t=>a.createElement(Ee.Provider,{value:w},a.createElement(je.Provider,{value:z},t))))}),Ue=a.forwardRef((e,n)=>{var r,p;let i=_.useId(),c=a.useRef(null),m=a.useContext(Re),d=Y(),b=we(e),u=(p=(r=b.current)==null?void 0:r.forceMount)!=null?p:m?.forceMount;V(()=>{if(!u)return d.item(i,m?.id)},[u]);let g=Se(i,c,[e.value,e.children,c],e.keywords),o=se(),R=M(j=>j.value&&j.value===g.current),k=M(j=>u||d.filter()===!1?!0:j.search?j.filtered.items.get(i)>0:!0);a.useEffect(()=>{let j=c.current;if(!(!j||e.disabled))return j.addEventListener(ce,N),()=>j.removeEventListener(ce,N)},[k,e.onSelect,e.disabled]);function N(){var j,w;G(),(w=(j=b.current).onSelect)==null||w.call(j,g.current)}function G(){o.setState("value",g.current,!0)}if(!k)return null;let{disabled:v,value:U,onSelect:I,forceMount:H,keywords:q,...C}=e;return a.createElement(D.Primitive.div,{ref:X.composeRefs(c,n),...C,id:i,"cmdk-item":"",role:"option","aria-disabled":!!v,"aria-selected":!!R,"data-disabled":!!v,"data-selected":!!R,onPointerMove:v||d.getDisablePointerSelection()?void 0:G,onClick:v?void 0:N},e.children)}),He=a.forwardRef((e,n)=>{let{heading:r,children:p,forceMount:i,...c}=e,m=_.useId(),d=a.useRef(null),b=a.useRef(null),u=_.useId(),g=Y(),o=M(k=>i||g.filter()===!1?!0:k.search?k.filtered.groups.has(m):!0);V(()=>g.group(m),[]),Se(m,d,[e.value,e.heading,b]);let R=a.useMemo(()=>({id:m,forceMount:i}),[i]);return a.createElement(D.Primitive.div,{ref:X.composeRefs(d,n),...c,"cmdk-group":"",role:"presentation",hidden:o?void 0:!0},r&&a.createElement("div",{ref:b,"cmdk-group-heading":"","aria-hidden":!0,id:u},r),ee(e,k=>a.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":r?u:void 0},a.createElement(Re.Provider,{value:R},k))))}),We=a.forwardRef((e,n)=>{let{alwaysRender:r,...p}=e,i=a.useRef(null),c=M(m=>!m.search);return!r&&!c?null:a.createElement(D.Primitive.div,{ref:X.composeRefs(i,n),...p,"cmdk-separator":"",role:"separator"})}),Je=a.forwardRef((e,n)=>{let{onValueChange:r,...p}=e,i=e.value!=null,c=se(),m=M(u=>u.search),d=M(u=>u.selectedItemId),b=Y();return a.useEffect(()=>{e.value!=null&&c.setState("search",e.value)},[e.value]),a.createElement(D.Primitive.input,{ref:n,...p,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":b.listId,"aria-labelledby":b.labelId,"aria-activedescendant":d,id:b.inputId,type:"text",value:i?e.value:m,onChange:u=>{i||c.setState("search",u.target.value),r?.(u.target.value)}})}),Xe=a.forwardRef((e,n)=>{let{children:r,label:p="Suggestions",...i}=e,c=a.useRef(null),m=a.useRef(null),d=M(u=>u.selectedItemId),b=Y();return a.useEffect(()=>{if(m.current&&c.current){let u=m.current,g=c.current,o,R=new ResizeObserver(()=>{o=requestAnimationFrame(()=>{let k=u.offsetHeight;g.style.setProperty("--cmdk-list-height",k.toFixed(1)+"px")})});return R.observe(u),()=>{cancelAnimationFrame(o),R.unobserve(u)}}},[]),a.createElement(D.Primitive.div,{ref:X.composeRefs(c,n),...i,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":d,"aria-label":p,id:b.listId},ee(e,u=>a.createElement("div",{ref:X.composeRefs(m,b.listInnerRef),"cmdk-list-sizer":""},u)))}),Ye=a.forwardRef((e,n)=>{let{open:r,onOpenChange:p,overlayClassName:i,contentClassName:c,container:m,...d}=e;return a.createElement(Z.Root,{open:r,onOpenChange:p},a.createElement(Z.Portal,{container:m},a.createElement(Z.Overlay,{"cmdk-overlay":"",className:i}),a.createElement(Z.Content,{"aria-label":e.label,"cmdk-dialog":"",className:c},a.createElement(ke,{ref:n,...d}))))}),Qe=a.forwardRef((e,n)=>M(r=>r.filtered.count===0)?a.createElement(D.Primitive.div,{ref:n,...e,"cmdk-empty":"",role:"presentation"}):null),Ze=a.forwardRef((e,n)=>{let{progress:r,children:p,label:i="Loading...",...c}=e;return a.createElement(D.Primitive.div,{ref:n,...c,"cmdk-loading":"",role:"progressbar","aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},ee(e,m=>a.createElement("div",{"aria-hidden":!0},m)))}),B=Object.assign(ke,{List:Xe,Item:Ue,Input:Je,Group:He,Separator:We,Dialog:Ye,Empty:Qe,Loading:Ze});function et(e,n){let r=e.nextElementSibling;for(;r;){if(r.matches(n))return r;r=r.nextElementSibling}}function tt(e,n){let r=e.previousElementSibling;for(;r;){if(r.matches(n))return r;r=r.previousElementSibling}}function we(e){let n=a.useRef(e);return V(()=>{n.current=e}),n}var V=typeof window>"u"?a.useEffect:a.useLayoutEffect;function T(e){let n=a.useRef();return n.current===void 0&&(n.current=e()),n}function M(e){let n=se(),r=()=>e(n.snapshot());return a.useSyncExternalStore(n.subscribe,r,r)}function Se(e,n,r,p=[]){let i=a.useRef(),c=Y();return V(()=>{var m;let d=(()=>{var u;for(let g of r){if(typeof g=="string")return g.trim();if(typeof g=="object"&&"current"in g)return g.current?(u=g.current.textContent)==null?void 0:u.trim():i.current}})(),b=p.map(u=>u.trim());c.value(e,d,b),(m=n.current)==null||m.setAttribute(K,d),i.current=d}),i}var rt=()=>{let[e,n]=a.useState(),r=T(()=>new Map);return V(()=>{r.current.forEach(p=>p()),r.current=new Map},[e]),(p,i)=>{r.current.set(p,i),n({})}};function nt(e){let n=e.type;return typeof n=="function"?n(e.props):"render"in n?n.render(e.props):e}function ee({asChild:e,children:n},r){return e&&a.isValidElement(n)?a.cloneElement(nt(n),{ref:n.ref},r(n.props.children)):r(n)}var at={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};function lt({className:e,...n}){return x.jsxRuntimeExports.jsx(B,{"data-slot":"command",className:P.cn("adm:bg-popover adm:text-popover-foreground adm:flex adm:h-full adm:w-full adm:flex-col adm:overflow-hidden adm:rounded-md",e),...n})}function it({className:e,...n}){return x.jsxRuntimeExports.jsxs("div",{"data-slot":"command-input-wrapper",className:"adm:flex adm:h-9 adm:items-center adm:gap-2 adm:border-b adm:px-3",children:[x.jsxRuntimeExports.jsx(Me,{className:"adm:size-4 adm:shrink-0 adm:opacity-50"}),x.jsxRuntimeExports.jsx(B.Input,{"data-slot":"command-input",className:P.cn("adm:placeholder:text-muted-foreground adm:flex adm:h-10 adm:w-full adm:rounded-md adm:bg-transparent adm:py-3 adm:text-sm adm:outline-hidden adm:disabled:cursor-not-allowed adm:disabled:opacity-50",e),...n})]})}function ot({className:e,...n}){return x.jsxRuntimeExports.jsx(B.List,{"data-slot":"command-list",className:P.cn("adm:max-h-[300px] adm:scroll-py-1 adm:overflow-x-hidden adm:overflow-y-auto",e),...n})}function ut({className:e,...n}){return x.jsxRuntimeExports.jsx(B.Empty,{"data-slot":"command-empty",className:P.cn("adm:py-6 adm:text-center adm:text-sm",e),...n})}function ct({className:e,...n}){return x.jsxRuntimeExports.jsx(B.Group,{"data-slot":"command-group",className:P.cn("adm:text-foreground adm:overflow-hidden adm:p-1 adm:**:**:**:**:**:**:[&_[cmdk-group-heading]]:text-muted-foreground adm:**:**:**:**:**:**:[&_[cmdk-group-heading]]:px-2 adm:**:**:**:**:**:**:[&_[cmdk-group-heading]]:py-1.5 adm:**:**:**:**:**:**:[&_[cmdk-group-heading]]:text-xs adm:**:**:**:**:**:**:[&_[cmdk-group-heading]]:font-medium",e),...n})}function st({className:e,...n}){return x.jsxRuntimeExports.jsx(B.Item,{"data-slot":"command-item",className:P.cn("adm:data-[selected=true]:bg-accent adm:data-[selected=true]:text-accent-foreground adm:[&_svg:not([class*=text-])]:text-muted-foreground adm:relative adm:flex adm:cursor-default adm:items-center adm:gap-2 adm:rounded-sm adm:px-2 adm:py-1.5 adm:text-sm adm:outline-hidden adm:select-none adm:data-[disabled=true]:pointer-events-none adm:data-[disabled=true]:opacity-50 adm:[&_svg]:pointer-events-none adm:[&_svg]:shrink-0 adm:[&_svg:not([class*=size-])]:size-4",e),...n})}function dt({searchable:e,multiple:n,icon:r,value:p,onValueChange:i,labels:c,options:m,classNames:d,selectedFeedback:b="checkbox",alwaysShowPlaceholder:u=!1,valuePosition:g="right",renders:o}){const[R,k]=oe.useState(!1),[N,G]=oe.useState(n?[]:""),v=p!==void 0?p:N,I={...{placeholder:"Select options...",searchPlaceholder:"Search options...",noItemsFound:"No options found.",multipleSelected:f=>`${f} options selected`},...c},H=f=>{i?i(f):G(f)},q=()=>n&&Array.isArray(v)?v.length===0?null:v.length===1?m.find(f=>f.value===v[0])?.label:I.multipleSelected?.(v.length)||`${v.length} options selected`:!n&&typeof v=="string"&&v?m.find(f=>f.value===v)?.label:null,C=()=>n&&Array.isArray(v)?v.length>0:typeof v=="string"&&v!=="",j=f=>n&&Array.isArray(v)?v.includes(f):v===f,w=f=>{if(n){const $=Array.isArray(v)?v:[],L=$.includes(f)?$.filter(O=>O!==f):[...$,f];H(L)}else H(f===v?"":f),k(!1)},z=f=>{const $=j(f),L=m.find(O=>O.value===f);return o?.selectedFeedback?o.selectedFeedback({option:L,isSelected:$,type:b}):b==="check"?x.jsxRuntimeExports.jsx("span",{className:P.cn("adm:absolute adm:right-2 adm:flex adm:size-3.5 adm:items-center adm:justify-center",d?.check),children:$&&x.jsxRuntimeExports.jsx(qe.Check,{className:"adm:size-4"})}):x.jsxRuntimeExports.jsx(Ae.Checkbox,{checked:$,className:d?.checkbox})};return x.jsxRuntimeExports.jsxs(ne.Popover,{open:R,onOpenChange:k,children:[x.jsxRuntimeExports.jsx(ne.PopoverTrigger,{asChild:!0,children:o?.trigger?o.trigger({open:R,value:v,displayText:q()??null,placeholder:I.placeholder||"",hasValue:C(),icon:r}):x.jsxRuntimeExports.jsxs(Ie.Button,{variant:"outline",role:"combobox","aria-expanded":R,className:P.cn("adm:justify-between adm:font-normal",d?.trigger),children:[x.jsxRuntimeExports.jsxs("span",{className:"adm:flex adm:items-center adm:gap-2",children:[r&&x.jsxRuntimeExports.jsx(r,{className:"adm:opacity-50"}),u?o?.placeholder?o.placeholder({text:I.placeholder||"",hasValue:C()}):x.jsxRuntimeExports.jsx("span",{className:"adm:opacity-70",children:I.placeholder}):C()?o?.displayValue?o.displayValue({text:q()??null,value:v}):x.jsxRuntimeExports.jsx("span",{children:q()}):o?.placeholder?o.placeholder({text:I.placeholder||"",hasValue:C()}):x.jsxRuntimeExports.jsx("span",{children:I.placeholder}),u&&C()&&g==="left"&&(o?.displayValue?o.displayValue({text:q()??null,value:v}):x.jsxRuntimeExports.jsx("span",{children:q()}))]}),x.jsxRuntimeExports.jsxs("span",{className:"adm:flex adm:items-center adm:gap-2",children:[u&&C()&&g==="right"&&(o?.displayValue?o.displayValue({text:q()??null,value:v}):x.jsxRuntimeExports.jsx("span",{children:q()})),o?.triggerIcon?o.triggerIcon({open:R}):x.jsxRuntimeExports.jsx($e.ChevronDown,{className:"adm:size-4 adm:opacity-50"})]})]})}),x.jsxRuntimeExports.jsx(ne.PopoverContent,{align:"start",className:P.cn("adm:p-0",d?.popover),children:x.jsxRuntimeExports.jsxs(lt,{className:d?.command,children:[e&&(o?.searchInput?o.searchInput({placeholder:I.searchPlaceholder||""}):x.jsxRuntimeExports.jsx(it,{placeholder:I.searchPlaceholder,className:d?.input})),x.jsxRuntimeExports.jsxs(ot,{className:d?.list,children:[x.jsxRuntimeExports.jsx(ut,{className:d?.empty,children:o?.empty?o.empty({text:I.noItemsFound||""}):I.noItemsFound}),x.jsxRuntimeExports.jsx(ct,{className:d?.group,children:m.map(f=>o?.option?x.jsxRuntimeExports.jsx("div",{children:o.option({option:f,isSelected:j(f.value),selectedFeedback:b})},f.value):x.jsxRuntimeExports.jsxs(st,{value:f.value,onSelect:w,disabled:f.disabled,className:P.cn(d?.item,b==="check"&&"adm:pr-8"),children:[b==="checkbox"&&z(f.value),o?.optionLabel?o.optionLabel({option:f}):f.label,b==="check"&&z(f.value)]},f.value))})]})]})})]})}exports.Combobox=dt;
|
package/dist/combobox.js
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import { j as
|
|
1
|
+
import { j as g } from "./jsx-runtime-BzflLqGi.js";
|
|
2
2
|
import * as n from "react";
|
|
3
3
|
import { useState as fe } from "react";
|
|
4
|
-
import { c as
|
|
4
|
+
import { c as D } from "./index-CRiPKpXj.js";
|
|
5
5
|
import { B as Ce } from "./button-2GdKenQI.js";
|
|
6
|
-
import { R as
|
|
7
|
-
import { P as
|
|
6
|
+
import { R as je, P as Ie, O as Re, a as Ae } from "./index-DniCthJA.js";
|
|
7
|
+
import { P as V } from "./index-BMWt1NBG.js";
|
|
8
8
|
import { u as T } from "./index-Cv867SGx.js";
|
|
9
9
|
import { c as X } from "./index-DLcqcWxM.js";
|
|
10
10
|
import { c as Ne } from "./createLucideIcon-B_8CJpcQ.js";
|
|
11
|
-
import { P as $e, a as Me, b as
|
|
12
|
-
import { C as
|
|
13
|
-
import { C as
|
|
14
|
-
import { C as
|
|
11
|
+
import { P as $e, a as Me, b as De } from "./popover-3rIoNCXs.js";
|
|
12
|
+
import { C as Le } from "./checkbox-Dr487kAg.js";
|
|
13
|
+
import { C as Ve } from "./chevron-down-CpVS2Z7w.js";
|
|
14
|
+
import { C as Pe } from "./check-Ci0GjV-B.js";
|
|
15
15
|
/**
|
|
16
16
|
* @license lucide-react v0.546.0 - ISC
|
|
17
17
|
*
|
|
18
18
|
* This source code is licensed under the ISC license.
|
|
19
19
|
* See the LICENSE file in the root directory of this source tree.
|
|
20
20
|
*/
|
|
21
|
-
const
|
|
21
|
+
const Fe = [
|
|
22
22
|
["path", { d: "m21 21-4.34-4.34", key: "14j7rj" }],
|
|
23
23
|
["circle", { cx: "11", cy: "11", r: "8", key: "4ej97u" }]
|
|
24
|
-
], ze = Ne("search",
|
|
24
|
+
], ze = Ne("search", Fe);
|
|
25
25
|
var pe = 1, Ke = 0.9, Oe = 0.8, qe = 0.17, re = 0.1, ae = 0.999, Be = 0.9999, Te = 0.99, _e = /[\\\/_+.#"@\[\(\{&]/, Ge = /[\\\/_+.#"@\[\(\{&]/g, Ue = /[\s-]/, ge = /[\s-]/g;
|
|
26
|
-
function le(e, a, r,
|
|
27
|
-
if (u === a.length) return
|
|
28
|
-
var
|
|
29
|
-
if (s
|
|
30
|
-
for (var
|
|
31
|
-
return s
|
|
26
|
+
function le(e, a, r, f, o, u, m) {
|
|
27
|
+
if (u === a.length) return o === e.length ? pe : Te;
|
|
28
|
+
var s = `${o},${u}`;
|
|
29
|
+
if (m[s] !== void 0) return m[s];
|
|
30
|
+
for (var b = f.charAt(u), d = r.indexOf(b, o), x = 0, i, E, S, M; d >= 0; ) i = le(e, a, r, f, d + 1, u + 1, m), i > x && (d === o ? i *= pe : _e.test(e.charAt(d - 1)) ? (i *= Oe, S = e.slice(o, d - 1).match(Ge), S && o > 0 && (i *= Math.pow(ae, S.length))) : Ue.test(e.charAt(d - 1)) ? (i *= Ke, M = e.slice(o, d - 1).match(ge), M && o > 0 && (i *= Math.pow(ae, M.length))) : (i *= qe, o > 0 && (i *= Math.pow(ae, d - o))), e.charAt(d) !== a.charAt(u) && (i *= Be)), (i < re && r.charAt(d - 1) === f.charAt(u + 1) || f.charAt(u + 1) === f.charAt(u) && r.charAt(d - 1) !== f.charAt(u)) && (E = le(e, a, r, f, d + 1, u + 2, m), E * re > i && (i = E * re)), i > x && (x = i), d = r.indexOf(b, d + 1);
|
|
31
|
+
return m[s] = x, x;
|
|
32
32
|
}
|
|
33
33
|
function he(e) {
|
|
34
34
|
return e.toLowerCase().replace(ge, " ");
|
|
@@ -36,11 +36,11 @@ function he(e) {
|
|
|
36
36
|
function He(e, a, r) {
|
|
37
37
|
return e = r && r.length > 0 ? `${e + " " + r.join(" ")}` : e, le(e, a, he(e), he(a), 0, 0, {});
|
|
38
38
|
}
|
|
39
|
-
var J = '[cmdk-group=""]', ne = '[cmdk-group-items=""]', We = '[cmdk-group-heading=""]',
|
|
39
|
+
var J = '[cmdk-group=""]', ne = '[cmdk-group-items=""]', We = '[cmdk-group-heading=""]', xe = '[cmdk-item=""]', ve = `${xe}:not([aria-disabled="true"])`, oe = "cmdk-item-select", q = "data-value", Je = (e, a, r) => He(e, a, r), be = n.createContext(void 0), Y = () => n.useContext(be), ye = n.createContext(void 0), ie = () => n.useContext(ye), ke = n.createContext(void 0), we = n.forwardRef((e, a) => {
|
|
40
40
|
let r = B(() => {
|
|
41
41
|
var t, c;
|
|
42
42
|
return { search: "", value: (c = (t = e.value) != null ? t : e.defaultValue) != null ? c : "", selectedItemId: void 0, filtered: { count: 0, items: /* @__PURE__ */ new Map(), groups: /* @__PURE__ */ new Set() } };
|
|
43
|
-
}),
|
|
43
|
+
}), f = B(() => /* @__PURE__ */ new Set()), o = B(() => /* @__PURE__ */ new Map()), u = B(() => /* @__PURE__ */ new Map()), m = B(() => /* @__PURE__ */ new Set()), s = Ee(e), { label: b, children: d, value: x, onValueChange: i, filter: E, shouldFilter: S, loop: M, disablePointerSelection: G = !1, vimBindings: v = !0, ...U } = e, I = T(), H = T(), $ = T(), R = n.useRef(null), k = ot();
|
|
44
44
|
z(() => {
|
|
45
45
|
if (x !== void 0) {
|
|
46
46
|
let t = x.trim();
|
|
@@ -49,64 +49,64 @@ var J = '[cmdk-group=""]', ne = '[cmdk-group-items=""]', We = '[cmdk-group-headi
|
|
|
49
49
|
}, [x]), z(() => {
|
|
50
50
|
k(6, de);
|
|
51
51
|
}, []);
|
|
52
|
-
let C = n.useMemo(() => ({ subscribe: (t) => (
|
|
52
|
+
let C = n.useMemo(() => ({ subscribe: (t) => (m.current.add(t), () => m.current.delete(t)), snapshot: () => r.current, setState: (t, c, h) => {
|
|
53
53
|
var l, y, w, A;
|
|
54
54
|
if (!Object.is(r.current[t], c)) {
|
|
55
|
-
if (r.current[t] = c, t === "search")
|
|
55
|
+
if (r.current[t] = c, t === "search") F(), N(), k(1, P);
|
|
56
56
|
else if (t === "value") {
|
|
57
57
|
if (document.activeElement.hasAttribute("cmdk-input") || document.activeElement.hasAttribute("cmdk-root")) {
|
|
58
|
-
let
|
|
59
|
-
|
|
58
|
+
let j = document.getElementById($);
|
|
59
|
+
j ? j.focus() : (l = document.getElementById(I)) == null || l.focus();
|
|
60
60
|
}
|
|
61
61
|
if (k(7, () => {
|
|
62
|
-
var
|
|
63
|
-
r.current.selectedItemId = (
|
|
64
|
-
}), h || k(5, de), ((y =
|
|
65
|
-
let
|
|
66
|
-
(A = (w =
|
|
62
|
+
var j;
|
|
63
|
+
r.current.selectedItemId = (j = O()) == null ? void 0 : j.id, C.emit();
|
|
64
|
+
}), h || k(5, de), ((y = s.current) == null ? void 0 : y.value) !== void 0) {
|
|
65
|
+
let j = c ?? "";
|
|
66
|
+
(A = (w = s.current).onValueChange) == null || A.call(w, j);
|
|
67
67
|
return;
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
C.emit();
|
|
71
71
|
}
|
|
72
72
|
}, emit: () => {
|
|
73
|
-
|
|
73
|
+
m.current.forEach((t) => t());
|
|
74
74
|
} }), []), K = n.useMemo(() => ({ value: (t, c, h) => {
|
|
75
75
|
var l;
|
|
76
76
|
c !== ((l = u.current.get(t)) == null ? void 0 : l.value) && (u.current.set(t, { value: c, keywords: h }), r.current.filtered.items.set(t, p(c, h)), k(2, () => {
|
|
77
77
|
N(), C.emit();
|
|
78
78
|
}));
|
|
79
|
-
}, item: (t, c) => (
|
|
80
|
-
|
|
79
|
+
}, item: (t, c) => (f.current.add(t), c && (o.current.has(c) ? o.current.get(c).add(t) : o.current.set(c, /* @__PURE__ */ new Set([t]))), k(3, () => {
|
|
80
|
+
F(), N(), r.current.value || P(), C.emit();
|
|
81
81
|
}), () => {
|
|
82
|
-
u.current.delete(t),
|
|
82
|
+
u.current.delete(t), f.current.delete(t), r.current.filtered.items.delete(t);
|
|
83
83
|
let h = O();
|
|
84
84
|
k(4, () => {
|
|
85
|
-
|
|
85
|
+
F(), h?.getAttribute("id") === t && P(), C.emit();
|
|
86
86
|
});
|
|
87
|
-
}), group: (t) => (
|
|
88
|
-
u.current.delete(t),
|
|
89
|
-
}), filter: () =>
|
|
87
|
+
}), group: (t) => (o.current.has(t) || o.current.set(t, /* @__PURE__ */ new Set()), () => {
|
|
88
|
+
u.current.delete(t), o.current.delete(t);
|
|
89
|
+
}), filter: () => s.current.shouldFilter, label: b || e["aria-label"], getDisablePointerSelection: () => s.current.disablePointerSelection, listId: I, inputId: $, labelId: H, listInnerRef: R }), []);
|
|
90
90
|
function p(t, c) {
|
|
91
91
|
var h, l;
|
|
92
|
-
let y = (l = (h =
|
|
92
|
+
let y = (l = (h = s.current) == null ? void 0 : h.filter) != null ? l : Je;
|
|
93
93
|
return t ? y(t, r.current.search, c) : 0;
|
|
94
94
|
}
|
|
95
95
|
function N() {
|
|
96
|
-
if (!r.current.search ||
|
|
96
|
+
if (!r.current.search || s.current.shouldFilter === !1) return;
|
|
97
97
|
let t = r.current.filtered.items, c = [];
|
|
98
98
|
r.current.filtered.groups.forEach((l) => {
|
|
99
|
-
let y =
|
|
99
|
+
let y = o.current.get(l), w = 0;
|
|
100
100
|
y.forEach((A) => {
|
|
101
|
-
let
|
|
102
|
-
w = Math.max(
|
|
101
|
+
let j = t.get(A);
|
|
102
|
+
w = Math.max(j, w);
|
|
103
103
|
}), c.push([l, w]);
|
|
104
104
|
});
|
|
105
105
|
let h = R.current;
|
|
106
106
|
W().sort((l, y) => {
|
|
107
107
|
var w, A;
|
|
108
|
-
let
|
|
109
|
-
return ((w = t.get(Q)) != null ? w : 0) - ((A = t.get(
|
|
108
|
+
let j = l.getAttribute("id"), Q = y.getAttribute("id");
|
|
109
|
+
return ((w = t.get(Q)) != null ? w : 0) - ((A = t.get(j)) != null ? A : 0);
|
|
110
110
|
}).forEach((l) => {
|
|
111
111
|
let y = l.closest(ne);
|
|
112
112
|
y ? y.appendChild(l.parentElement === y ? l : l.closest(`${ne} > *`)) : h.appendChild(l.parentElement === h ? l : l.closest(`${ne} > *`));
|
|
@@ -116,23 +116,23 @@ var J = '[cmdk-group=""]', ne = '[cmdk-group-items=""]', We = '[cmdk-group-headi
|
|
|
116
116
|
w?.parentElement.appendChild(w);
|
|
117
117
|
});
|
|
118
118
|
}
|
|
119
|
-
function
|
|
119
|
+
function P() {
|
|
120
120
|
let t = W().find((h) => h.getAttribute("aria-disabled") !== "true"), c = t?.getAttribute(q);
|
|
121
121
|
C.setState("value", c || void 0);
|
|
122
122
|
}
|
|
123
|
-
function
|
|
123
|
+
function F() {
|
|
124
124
|
var t, c, h, l;
|
|
125
|
-
if (!r.current.search ||
|
|
126
|
-
r.current.filtered.count =
|
|
125
|
+
if (!r.current.search || s.current.shouldFilter === !1) {
|
|
126
|
+
r.current.filtered.count = f.current.size;
|
|
127
127
|
return;
|
|
128
128
|
}
|
|
129
129
|
r.current.filtered.groups = /* @__PURE__ */ new Set();
|
|
130
130
|
let y = 0;
|
|
131
|
-
for (let w of
|
|
132
|
-
let A = (c = (t = u.current.get(w)) == null ? void 0 : t.value) != null ? c : "",
|
|
131
|
+
for (let w of f.current) {
|
|
132
|
+
let A = (c = (t = u.current.get(w)) == null ? void 0 : t.value) != null ? c : "", j = (l = (h = u.current.get(w)) == null ? void 0 : h.keywords) != null ? l : [], Q = p(A, j);
|
|
133
133
|
r.current.filtered.items.set(w, Q), Q > 0 && y++;
|
|
134
134
|
}
|
|
135
|
-
for (let [w, A] of
|
|
135
|
+
for (let [w, A] of o.current) for (let j of A) if (r.current.filtered.items.get(j) > 0) {
|
|
136
136
|
r.current.filtered.groups.add(w);
|
|
137
137
|
break;
|
|
138
138
|
}
|
|
@@ -145,7 +145,7 @@ var J = '[cmdk-group=""]', ne = '[cmdk-group-items=""]', We = '[cmdk-group-headi
|
|
|
145
145
|
}
|
|
146
146
|
function O() {
|
|
147
147
|
var t;
|
|
148
|
-
return (t = R.current) == null ? void 0 : t.querySelector(`${
|
|
148
|
+
return (t = R.current) == null ? void 0 : t.querySelector(`${xe}[aria-selected="true"]`);
|
|
149
149
|
}
|
|
150
150
|
function W() {
|
|
151
151
|
var t;
|
|
@@ -158,7 +158,7 @@ var J = '[cmdk-group=""]', ne = '[cmdk-group-items=""]', We = '[cmdk-group-headi
|
|
|
158
158
|
function te(t) {
|
|
159
159
|
var c;
|
|
160
160
|
let h = O(), l = W(), y = l.findIndex((A) => A === h), w = l[y + t];
|
|
161
|
-
(c =
|
|
161
|
+
(c = s.current) != null && c.loop && (w = y + t < 0 ? l[l.length - 1] : y + t === l.length ? l[0] : l[y + t]), w && C.setState("value", w.getAttribute(q));
|
|
162
162
|
}
|
|
163
163
|
function ue(t) {
|
|
164
164
|
let c = O(), h = c?.closest(J), l;
|
|
@@ -170,14 +170,14 @@ var J = '[cmdk-group=""]', ne = '[cmdk-group-items=""]', We = '[cmdk-group-headi
|
|
|
170
170
|
}, me = (t) => {
|
|
171
171
|
t.preventDefault(), t.metaKey ? ee(0) : t.altKey ? ue(-1) : te(-1);
|
|
172
172
|
};
|
|
173
|
-
return n.createElement(
|
|
173
|
+
return n.createElement(V.div, { ref: a, tabIndex: -1, ...U, "cmdk-root": "", onKeyDown: (t) => {
|
|
174
174
|
var c;
|
|
175
175
|
(c = U.onKeyDown) == null || c.call(U, t);
|
|
176
176
|
let h = t.nativeEvent.isComposing || t.keyCode === 229;
|
|
177
177
|
if (!(t.defaultPrevented || h)) switch (t.key) {
|
|
178
178
|
case "n":
|
|
179
179
|
case "j": {
|
|
180
|
-
|
|
180
|
+
v && t.ctrlKey && se(t);
|
|
181
181
|
break;
|
|
182
182
|
}
|
|
183
183
|
case "ArrowDown": {
|
|
@@ -186,7 +186,7 @@ var J = '[cmdk-group=""]', ne = '[cmdk-group-items=""]', We = '[cmdk-group-headi
|
|
|
186
186
|
}
|
|
187
187
|
case "p":
|
|
188
188
|
case "k": {
|
|
189
|
-
|
|
189
|
+
v && t.ctrlKey && me(t);
|
|
190
190
|
break;
|
|
191
191
|
}
|
|
192
192
|
case "ArrowUp": {
|
|
@@ -210,64 +210,64 @@ var J = '[cmdk-group=""]', ne = '[cmdk-group-items=""]', We = '[cmdk-group-headi
|
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
212
|
}
|
|
213
|
-
} }, n.createElement("label", { "cmdk-label": "", htmlFor: K.inputId, id: K.labelId, style: dt },
|
|
213
|
+
} }, n.createElement("label", { "cmdk-label": "", htmlFor: K.inputId, id: K.labelId, style: dt }, b), Z(e, (t) => n.createElement(ye.Provider, { value: C }, n.createElement(be.Provider, { value: K }, t))));
|
|
214
214
|
}), Xe = n.forwardRef((e, a) => {
|
|
215
|
-
var r,
|
|
216
|
-
let
|
|
215
|
+
var r, f;
|
|
216
|
+
let o = T(), u = n.useRef(null), m = n.useContext(ke), s = Y(), b = Ee(e), d = (f = (r = b.current) == null ? void 0 : r.forceMount) != null ? f : m?.forceMount;
|
|
217
217
|
z(() => {
|
|
218
|
-
if (!
|
|
219
|
-
}, [
|
|
220
|
-
let x =
|
|
218
|
+
if (!d) return s.item(o, m?.id);
|
|
219
|
+
}, [d]);
|
|
220
|
+
let x = Se(o, u, [e.value, e.children, u], e.keywords), i = ie(), E = L((k) => k.value && k.value === x.current), S = L((k) => d || s.filter() === !1 ? !0 : k.search ? k.filtered.items.get(o) > 0 : !0);
|
|
221
221
|
n.useEffect(() => {
|
|
222
222
|
let k = u.current;
|
|
223
|
-
if (!(!k || e.disabled)) return k.addEventListener(oe,
|
|
224
|
-
}, [
|
|
225
|
-
function
|
|
223
|
+
if (!(!k || e.disabled)) return k.addEventListener(oe, M), () => k.removeEventListener(oe, M);
|
|
224
|
+
}, [S, e.onSelect, e.disabled]);
|
|
225
|
+
function M() {
|
|
226
226
|
var k, C;
|
|
227
|
-
G(), (C = (k =
|
|
227
|
+
G(), (C = (k = b.current).onSelect) == null || C.call(k, x.current);
|
|
228
228
|
}
|
|
229
229
|
function G() {
|
|
230
|
-
|
|
230
|
+
i.setState("value", x.current, !0);
|
|
231
231
|
}
|
|
232
|
-
if (!
|
|
233
|
-
let { disabled:
|
|
234
|
-
return n.createElement(
|
|
232
|
+
if (!S) return null;
|
|
233
|
+
let { disabled: v, value: U, onSelect: I, forceMount: H, keywords: $, ...R } = e;
|
|
234
|
+
return n.createElement(V.div, { ref: X(u, a), ...R, id: o, "cmdk-item": "", role: "option", "aria-disabled": !!v, "aria-selected": !!E, "data-disabled": !!v, "data-selected": !!E, onPointerMove: v || s.getDisablePointerSelection() ? void 0 : G, onClick: v ? void 0 : M }, e.children);
|
|
235
235
|
}), Ye = n.forwardRef((e, a) => {
|
|
236
|
-
let { heading: r, children:
|
|
237
|
-
z(() => x.group(
|
|
238
|
-
let
|
|
239
|
-
return n.createElement(
|
|
236
|
+
let { heading: r, children: f, forceMount: o, ...u } = e, m = T(), s = n.useRef(null), b = n.useRef(null), d = T(), x = Y(), i = L((S) => o || x.filter() === !1 ? !0 : S.search ? S.filtered.groups.has(m) : !0);
|
|
237
|
+
z(() => x.group(m), []), Se(m, s, [e.value, e.heading, b]);
|
|
238
|
+
let E = n.useMemo(() => ({ id: m, forceMount: o }), [o]);
|
|
239
|
+
return n.createElement(V.div, { ref: X(s, a), ...u, "cmdk-group": "", role: "presentation", hidden: i ? void 0 : !0 }, r && n.createElement("div", { ref: b, "cmdk-group-heading": "", "aria-hidden": !0, id: d }, r), Z(e, (S) => n.createElement("div", { "cmdk-group-items": "", role: "group", "aria-labelledby": r ? d : void 0 }, n.createElement(ke.Provider, { value: E }, S))));
|
|
240
240
|
}), Qe = n.forwardRef((e, a) => {
|
|
241
|
-
let { alwaysRender: r, ...
|
|
242
|
-
return !r && !u ? null : n.createElement(
|
|
241
|
+
let { alwaysRender: r, ...f } = e, o = n.useRef(null), u = L((m) => !m.search);
|
|
242
|
+
return !r && !u ? null : n.createElement(V.div, { ref: X(o, a), ...f, "cmdk-separator": "", role: "separator" });
|
|
243
243
|
}), Ze = n.forwardRef((e, a) => {
|
|
244
|
-
let { onValueChange: r, ...
|
|
244
|
+
let { onValueChange: r, ...f } = e, o = e.value != null, u = ie(), m = L((d) => d.search), s = L((d) => d.selectedItemId), b = Y();
|
|
245
245
|
return n.useEffect(() => {
|
|
246
246
|
e.value != null && u.setState("search", e.value);
|
|
247
|
-
}, [e.value]), n.createElement(
|
|
248
|
-
|
|
247
|
+
}, [e.value]), n.createElement(V.input, { ref: a, ...f, "cmdk-input": "", autoComplete: "off", autoCorrect: "off", spellCheck: !1, "aria-autocomplete": "list", role: "combobox", "aria-expanded": !0, "aria-controls": b.listId, "aria-labelledby": b.labelId, "aria-activedescendant": s, id: b.inputId, type: "text", value: o ? e.value : m, onChange: (d) => {
|
|
248
|
+
o || u.setState("search", d.target.value), r?.(d.target.value);
|
|
249
249
|
} });
|
|
250
250
|
}), et = n.forwardRef((e, a) => {
|
|
251
|
-
let { children: r, label:
|
|
251
|
+
let { children: r, label: f = "Suggestions", ...o } = e, u = n.useRef(null), m = n.useRef(null), s = L((d) => d.selectedItemId), b = Y();
|
|
252
252
|
return n.useEffect(() => {
|
|
253
|
-
if (
|
|
254
|
-
let
|
|
255
|
-
|
|
256
|
-
let
|
|
257
|
-
x.style.setProperty("--cmdk-list-height",
|
|
253
|
+
if (m.current && u.current) {
|
|
254
|
+
let d = m.current, x = u.current, i, E = new ResizeObserver(() => {
|
|
255
|
+
i = requestAnimationFrame(() => {
|
|
256
|
+
let S = d.offsetHeight;
|
|
257
|
+
x.style.setProperty("--cmdk-list-height", S.toFixed(1) + "px");
|
|
258
258
|
});
|
|
259
259
|
});
|
|
260
|
-
return
|
|
261
|
-
cancelAnimationFrame(
|
|
260
|
+
return E.observe(d), () => {
|
|
261
|
+
cancelAnimationFrame(i), E.unobserve(d);
|
|
262
262
|
};
|
|
263
263
|
}
|
|
264
|
-
}, []), n.createElement(
|
|
264
|
+
}, []), n.createElement(V.div, { ref: X(u, a), ...o, "cmdk-list": "", role: "listbox", tabIndex: -1, "aria-activedescendant": s, "aria-label": f, id: b.listId }, Z(e, (d) => n.createElement("div", { ref: X(m, b.listInnerRef), "cmdk-list-sizer": "" }, d)));
|
|
265
265
|
}), tt = n.forwardRef((e, a) => {
|
|
266
|
-
let { open: r, onOpenChange:
|
|
267
|
-
return n.createElement(
|
|
268
|
-
}), rt = n.forwardRef((e, a) =>
|
|
269
|
-
let { progress: r, children:
|
|
270
|
-
return n.createElement(
|
|
266
|
+
let { open: r, onOpenChange: f, overlayClassName: o, contentClassName: u, container: m, ...s } = e;
|
|
267
|
+
return n.createElement(je, { open: r, onOpenChange: f }, n.createElement(Ie, { container: m }, n.createElement(Re, { "cmdk-overlay": "", className: o }), n.createElement(Ae, { "aria-label": e.label, "cmdk-dialog": "", className: u }, n.createElement(we, { ref: a, ...s }))));
|
|
268
|
+
}), rt = n.forwardRef((e, a) => L((r) => r.filtered.count === 0) ? n.createElement(V.div, { ref: a, ...e, "cmdk-empty": "", role: "presentation" }) : null), at = n.forwardRef((e, a) => {
|
|
269
|
+
let { progress: r, children: f, label: o = "Loading...", ...u } = e;
|
|
270
|
+
return n.createElement(V.div, { ref: a, ...u, "cmdk-loading": "", role: "progressbar", "aria-valuenow": r, "aria-valuemin": 0, "aria-valuemax": 100, "aria-label": o }, Z(e, (m) => n.createElement("div", { "aria-hidden": !0 }, m)));
|
|
271
271
|
}), _ = Object.assign(we, { List: et, Item: Xe, Input: Ze, Group: Ye, Separator: Qe, Dialog: tt, Empty: rt, Loading: at });
|
|
272
272
|
function nt(e, a) {
|
|
273
273
|
let r = e.nextElementSibling;
|
|
@@ -283,7 +283,7 @@ function lt(e, a) {
|
|
|
283
283
|
r = r.previousElementSibling;
|
|
284
284
|
}
|
|
285
285
|
}
|
|
286
|
-
function
|
|
286
|
+
function Ee(e) {
|
|
287
287
|
let a = n.useRef(e);
|
|
288
288
|
return z(() => {
|
|
289
289
|
a.current = e;
|
|
@@ -294,30 +294,30 @@ function B(e) {
|
|
|
294
294
|
let a = n.useRef();
|
|
295
295
|
return a.current === void 0 && (a.current = e()), a;
|
|
296
296
|
}
|
|
297
|
-
function
|
|
297
|
+
function L(e) {
|
|
298
298
|
let a = ie(), r = () => e(a.snapshot());
|
|
299
299
|
return n.useSyncExternalStore(a.subscribe, r, r);
|
|
300
300
|
}
|
|
301
|
-
function
|
|
302
|
-
let
|
|
301
|
+
function Se(e, a, r, f = []) {
|
|
302
|
+
let o = n.useRef(), u = Y();
|
|
303
303
|
return z(() => {
|
|
304
|
-
var
|
|
305
|
-
let
|
|
306
|
-
var
|
|
304
|
+
var m;
|
|
305
|
+
let s = (() => {
|
|
306
|
+
var d;
|
|
307
307
|
for (let x of r) {
|
|
308
308
|
if (typeof x == "string") return x.trim();
|
|
309
|
-
if (typeof x == "object" && "current" in x) return x.current ? (
|
|
309
|
+
if (typeof x == "object" && "current" in x) return x.current ? (d = x.current.textContent) == null ? void 0 : d.trim() : o.current;
|
|
310
310
|
}
|
|
311
|
-
})(),
|
|
312
|
-
u.value(e,
|
|
313
|
-
}),
|
|
311
|
+
})(), b = f.map((d) => d.trim());
|
|
312
|
+
u.value(e, s, b), (m = a.current) == null || m.setAttribute(q, s), o.current = s;
|
|
313
|
+
}), o;
|
|
314
314
|
}
|
|
315
315
|
var ot = () => {
|
|
316
316
|
let [e, a] = n.useState(), r = B(() => /* @__PURE__ */ new Map());
|
|
317
317
|
return z(() => {
|
|
318
|
-
r.current.forEach((
|
|
319
|
-
}, [e]), (
|
|
320
|
-
r.current.set(
|
|
318
|
+
r.current.forEach((f) => f()), r.current = /* @__PURE__ */ new Map();
|
|
319
|
+
}, [e]), (f, o) => {
|
|
320
|
+
r.current.set(f, o), a({});
|
|
321
321
|
};
|
|
322
322
|
};
|
|
323
323
|
function it(e) {
|
|
@@ -332,11 +332,11 @@ function ut({
|
|
|
332
332
|
className: e,
|
|
333
333
|
...a
|
|
334
334
|
}) {
|
|
335
|
-
return /* @__PURE__ */
|
|
335
|
+
return /* @__PURE__ */ g.jsx(
|
|
336
336
|
_,
|
|
337
337
|
{
|
|
338
338
|
"data-slot": "command",
|
|
339
|
-
className:
|
|
339
|
+
className: D(
|
|
340
340
|
"adm:bg-popover adm:text-popover-foreground adm:flex adm:h-full adm:w-full adm:flex-col adm:overflow-hidden adm:rounded-md",
|
|
341
341
|
e
|
|
342
342
|
),
|
|
@@ -348,18 +348,18 @@ function ct({
|
|
|
348
348
|
className: e,
|
|
349
349
|
...a
|
|
350
350
|
}) {
|
|
351
|
-
return /* @__PURE__ */
|
|
351
|
+
return /* @__PURE__ */ g.jsxs(
|
|
352
352
|
"div",
|
|
353
353
|
{
|
|
354
354
|
"data-slot": "command-input-wrapper",
|
|
355
355
|
className: "adm:flex adm:h-9 adm:items-center adm:gap-2 adm:border-b adm:px-3",
|
|
356
356
|
children: [
|
|
357
|
-
/* @__PURE__ */
|
|
358
|
-
/* @__PURE__ */
|
|
357
|
+
/* @__PURE__ */ g.jsx(ze, { className: "adm:size-4 adm:shrink-0 adm:opacity-50" }),
|
|
358
|
+
/* @__PURE__ */ g.jsx(
|
|
359
359
|
_.Input,
|
|
360
360
|
{
|
|
361
361
|
"data-slot": "command-input",
|
|
362
|
-
className:
|
|
362
|
+
className: D(
|
|
363
363
|
"adm:placeholder:text-muted-foreground adm:flex adm:h-10 adm:w-full adm:rounded-md adm:bg-transparent adm:py-3 adm:text-sm adm:outline-hidden adm:disabled:cursor-not-allowed adm:disabled:opacity-50",
|
|
364
364
|
e
|
|
365
365
|
),
|
|
@@ -374,11 +374,11 @@ function st({
|
|
|
374
374
|
className: e,
|
|
375
375
|
...a
|
|
376
376
|
}) {
|
|
377
|
-
return /* @__PURE__ */
|
|
377
|
+
return /* @__PURE__ */ g.jsx(
|
|
378
378
|
_.List,
|
|
379
379
|
{
|
|
380
380
|
"data-slot": "command-list",
|
|
381
|
-
className:
|
|
381
|
+
className: D(
|
|
382
382
|
"adm:max-h-[300px] adm:scroll-py-1 adm:overflow-x-hidden adm:overflow-y-auto",
|
|
383
383
|
e
|
|
384
384
|
),
|
|
@@ -390,11 +390,11 @@ function mt({
|
|
|
390
390
|
className: e,
|
|
391
391
|
...a
|
|
392
392
|
}) {
|
|
393
|
-
return /* @__PURE__ */
|
|
393
|
+
return /* @__PURE__ */ g.jsx(
|
|
394
394
|
_.Empty,
|
|
395
395
|
{
|
|
396
396
|
"data-slot": "command-empty",
|
|
397
|
-
className:
|
|
397
|
+
className: D("adm:py-6 adm:text-center adm:text-sm", e),
|
|
398
398
|
...a
|
|
399
399
|
}
|
|
400
400
|
);
|
|
@@ -403,11 +403,11 @@ function ft({
|
|
|
403
403
|
className: e,
|
|
404
404
|
...a
|
|
405
405
|
}) {
|
|
406
|
-
return /* @__PURE__ */
|
|
406
|
+
return /* @__PURE__ */ g.jsx(
|
|
407
407
|
_.Group,
|
|
408
408
|
{
|
|
409
409
|
"data-slot": "command-group",
|
|
410
|
-
className:
|
|
410
|
+
className: D(
|
|
411
411
|
"adm:text-foreground adm:overflow-hidden adm:p-1 adm:**:**:**:**:**:**:[&_[cmdk-group-heading]]:text-muted-foreground adm:**:**:**:**:**:**:[&_[cmdk-group-heading]]:px-2 adm:**:**:**:**:**:**:[&_[cmdk-group-heading]]:py-1.5 adm:**:**:**:**:**:**:[&_[cmdk-group-heading]]:text-xs adm:**:**:**:**:**:**:[&_[cmdk-group-heading]]:font-medium",
|
|
412
412
|
e
|
|
413
413
|
),
|
|
@@ -419,11 +419,11 @@ function pt({
|
|
|
419
419
|
className: e,
|
|
420
420
|
...a
|
|
421
421
|
}) {
|
|
422
|
-
return /* @__PURE__ */
|
|
422
|
+
return /* @__PURE__ */ g.jsx(
|
|
423
423
|
_.Item,
|
|
424
424
|
{
|
|
425
425
|
"data-slot": "command-item",
|
|
426
|
-
className:
|
|
426
|
+
className: D(
|
|
427
427
|
"adm:data-[selected=true]:bg-accent adm:data-[selected=true]:text-accent-foreground adm:[&_svg:not([class*=text-])]:text-muted-foreground adm:relative adm:flex adm:cursor-default adm:items-center adm:gap-2 adm:rounded-sm adm:px-2 adm:py-1.5 adm:text-sm adm:outline-hidden adm:select-none adm:data-[disabled=true]:pointer-events-none adm:data-[disabled=true]:opacity-50 adm:[&_svg]:pointer-events-none adm:[&_svg]:shrink-0 adm:[&_svg:not([class*=size-])]:size-4",
|
|
428
428
|
e
|
|
429
429
|
),
|
|
@@ -435,110 +435,118 @@ function Rt({
|
|
|
435
435
|
searchable: e,
|
|
436
436
|
multiple: a,
|
|
437
437
|
icon: r,
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
renders:
|
|
438
|
+
value: f,
|
|
439
|
+
onValueChange: o,
|
|
440
|
+
labels: u,
|
|
441
|
+
options: m,
|
|
442
|
+
classNames: s,
|
|
443
|
+
selectedFeedback: b = "checkbox",
|
|
444
|
+
alwaysShowPlaceholder: d = !1,
|
|
445
|
+
valuePosition: x = "right",
|
|
446
|
+
renders: i
|
|
447
447
|
}) {
|
|
448
|
-
const [
|
|
448
|
+
const [E, S] = fe(!1), [M, G] = fe(a ? [] : ""), v = f !== void 0 ? f : M, I = { ...{
|
|
449
449
|
placeholder: "Select options...",
|
|
450
450
|
searchPlaceholder: "Search options...",
|
|
451
451
|
noItemsFound: "No options found.",
|
|
452
452
|
multipleSelected: (p) => `${p} options selected`
|
|
453
|
-
}, ...
|
|
454
|
-
|
|
455
|
-
},
|
|
453
|
+
}, ...u }, H = (p) => {
|
|
454
|
+
o ? o(p) : G(p);
|
|
455
|
+
}, $ = () => a && Array.isArray(v) ? v.length === 0 ? null : v.length === 1 ? m.find((p) => p.value === v[0])?.label : I.multipleSelected?.(v.length) || `${v.length} options selected` : !a && typeof v == "string" && v ? m.find((p) => p.value === v)?.label : null, R = () => a && Array.isArray(v) ? v.length > 0 : typeof v == "string" && v !== "", k = (p) => a && Array.isArray(v) ? v.includes(p) : v === p, C = (p) => {
|
|
456
456
|
if (a) {
|
|
457
|
-
const N = Array.isArray(
|
|
458
|
-
H(
|
|
457
|
+
const N = Array.isArray(v) ? v : [], P = N.includes(p) ? N.filter((F) => F !== p) : [...N, p];
|
|
458
|
+
H(P);
|
|
459
459
|
} else
|
|
460
|
-
H(p ===
|
|
460
|
+
H(p === v ? "" : p), S(!1);
|
|
461
461
|
}, K = (p) => {
|
|
462
|
-
const N = k(p),
|
|
463
|
-
return
|
|
464
|
-
option:
|
|
462
|
+
const N = k(p), P = m.find((F) => F.value === p);
|
|
463
|
+
return i?.selectedFeedback ? i.selectedFeedback({
|
|
464
|
+
option: P,
|
|
465
465
|
isSelected: N,
|
|
466
|
-
type:
|
|
467
|
-
}) :
|
|
468
|
-
|
|
466
|
+
type: b
|
|
467
|
+
}) : b === "check" ? /* @__PURE__ */ g.jsx("span", { className: D("adm:absolute adm:right-2 adm:flex adm:size-3.5 adm:items-center adm:justify-center", s?.check), children: N && /* @__PURE__ */ g.jsx(Pe, { className: "adm:size-4" }) }) : /* @__PURE__ */ g.jsx(
|
|
468
|
+
Le,
|
|
469
469
|
{
|
|
470
470
|
checked: N,
|
|
471
|
-
className:
|
|
471
|
+
className: s?.checkbox
|
|
472
472
|
}
|
|
473
473
|
);
|
|
474
474
|
};
|
|
475
|
-
return /* @__PURE__ */
|
|
476
|
-
/* @__PURE__ */
|
|
477
|
-
open:
|
|
478
|
-
value:
|
|
479
|
-
displayText:
|
|
480
|
-
placeholder:
|
|
475
|
+
return /* @__PURE__ */ g.jsxs($e, { open: E, onOpenChange: S, children: [
|
|
476
|
+
/* @__PURE__ */ g.jsx(Me, { asChild: !0, children: i?.trigger ? i.trigger({
|
|
477
|
+
open: E,
|
|
478
|
+
value: v,
|
|
479
|
+
displayText: $() ?? null,
|
|
480
|
+
placeholder: I.placeholder || "",
|
|
481
481
|
hasValue: R(),
|
|
482
|
-
icon: r
|
|
483
|
-
|
|
484
|
-
}) : /* @__PURE__ */ b.jsxs(
|
|
482
|
+
icon: r
|
|
483
|
+
}) : /* @__PURE__ */ g.jsxs(
|
|
485
484
|
Ce,
|
|
486
485
|
{
|
|
487
486
|
variant: "outline",
|
|
488
487
|
role: "combobox",
|
|
489
|
-
"aria-expanded":
|
|
490
|
-
className:
|
|
488
|
+
"aria-expanded": E,
|
|
489
|
+
className: D("adm:justify-between adm:font-normal", s?.trigger),
|
|
491
490
|
children: [
|
|
492
|
-
/* @__PURE__ */
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
text:
|
|
491
|
+
/* @__PURE__ */ g.jsxs("span", { className: "adm:flex adm:items-center adm:gap-2", children: [
|
|
492
|
+
r && /* @__PURE__ */ g.jsx(r, { className: "adm:opacity-50" }),
|
|
493
|
+
d ? i?.placeholder ? i.placeholder({
|
|
494
|
+
text: I.placeholder || "",
|
|
496
495
|
hasValue: R()
|
|
497
|
-
}) : /* @__PURE__ */
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
text: j.placeholder || "",
|
|
496
|
+
}) : /* @__PURE__ */ g.jsx("span", { className: "adm:opacity-70", children: I.placeholder }) : R() ? i?.displayValue ? i.displayValue({
|
|
497
|
+
text: $() ?? null,
|
|
498
|
+
value: v
|
|
499
|
+
}) : /* @__PURE__ */ g.jsx("span", { children: $() }) : i?.placeholder ? i.placeholder({
|
|
500
|
+
text: I.placeholder || "",
|
|
503
501
|
hasValue: R()
|
|
504
|
-
}) : /* @__PURE__ */
|
|
502
|
+
}) : /* @__PURE__ */ g.jsx("span", { children: I.placeholder }),
|
|
503
|
+
d && R() && x === "left" && (i?.displayValue ? i.displayValue({
|
|
504
|
+
text: $() ?? null,
|
|
505
|
+
value: v
|
|
506
|
+
}) : /* @__PURE__ */ g.jsx("span", { children: $() }))
|
|
505
507
|
] }),
|
|
506
|
-
|
|
508
|
+
/* @__PURE__ */ g.jsxs("span", { className: "adm:flex adm:items-center adm:gap-2", children: [
|
|
509
|
+
d && R() && x === "right" && (i?.displayValue ? i.displayValue({
|
|
510
|
+
text: $() ?? null,
|
|
511
|
+
value: v
|
|
512
|
+
}) : /* @__PURE__ */ g.jsx("span", { children: $() })),
|
|
513
|
+
i?.triggerIcon ? i.triggerIcon({ open: E }) : /* @__PURE__ */ g.jsx(Ve, { className: "adm:size-4 adm:opacity-50" })
|
|
514
|
+
] })
|
|
507
515
|
]
|
|
508
516
|
}
|
|
509
517
|
) }),
|
|
510
|
-
/* @__PURE__ */
|
|
511
|
-
e && (
|
|
512
|
-
placeholder:
|
|
513
|
-
}) : /* @__PURE__ */
|
|
518
|
+
/* @__PURE__ */ g.jsx(De, { align: "start", className: D("adm:p-0", s?.popover), children: /* @__PURE__ */ g.jsxs(ut, { className: s?.command, children: [
|
|
519
|
+
e && (i?.searchInput ? i.searchInput({
|
|
520
|
+
placeholder: I.searchPlaceholder || ""
|
|
521
|
+
}) : /* @__PURE__ */ g.jsx(
|
|
514
522
|
ct,
|
|
515
523
|
{
|
|
516
|
-
placeholder:
|
|
517
|
-
className:
|
|
524
|
+
placeholder: I.searchPlaceholder,
|
|
525
|
+
className: s?.input
|
|
518
526
|
}
|
|
519
527
|
)),
|
|
520
|
-
/* @__PURE__ */
|
|
521
|
-
/* @__PURE__ */
|
|
522
|
-
text:
|
|
523
|
-
}) :
|
|
524
|
-
/* @__PURE__ */
|
|
528
|
+
/* @__PURE__ */ g.jsxs(st, { className: s?.list, children: [
|
|
529
|
+
/* @__PURE__ */ g.jsx(mt, { className: s?.empty, children: i?.empty ? i.empty({
|
|
530
|
+
text: I.noItemsFound || ""
|
|
531
|
+
}) : I.noItemsFound }),
|
|
532
|
+
/* @__PURE__ */ g.jsx(ft, { className: s?.group, children: m.map((p) => i?.option ? /* @__PURE__ */ g.jsx("div", { children: i.option({
|
|
525
533
|
option: p,
|
|
526
534
|
isSelected: k(p.value),
|
|
527
|
-
selectedFeedback:
|
|
528
|
-
}) }, p.value) : /* @__PURE__ */
|
|
535
|
+
selectedFeedback: b
|
|
536
|
+
}) }, p.value) : /* @__PURE__ */ g.jsxs(
|
|
529
537
|
pt,
|
|
530
538
|
{
|
|
531
539
|
value: p.value,
|
|
532
540
|
onSelect: C,
|
|
533
541
|
disabled: p.disabled,
|
|
534
|
-
className:
|
|
535
|
-
|
|
536
|
-
|
|
542
|
+
className: D(
|
|
543
|
+
s?.item,
|
|
544
|
+
b === "check" && "adm:pr-8"
|
|
537
545
|
),
|
|
538
546
|
children: [
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
547
|
+
b === "checkbox" && K(p.value),
|
|
548
|
+
i?.optionLabel ? i.optionLabel({ option: p }) : p.label,
|
|
549
|
+
b === "check" && K(p.value)
|
|
542
550
|
]
|
|
543
551
|
},
|
|
544
552
|
p.value
|
|
@@ -72,7 +72,6 @@ type ComboboxRenderProps = {
|
|
|
72
72
|
icon?: ComponentType<{
|
|
73
73
|
className?: string;
|
|
74
74
|
}>;
|
|
75
|
-
showIcon?: boolean;
|
|
76
75
|
}) => ReactNode;
|
|
77
76
|
/**
|
|
78
77
|
* Custom renderer for the trigger dropdown icon.
|
|
@@ -155,8 +154,6 @@ type ComboboxProps = Readonly<{
|
|
|
155
154
|
icon?: ComponentType<{
|
|
156
155
|
className?: string;
|
|
157
156
|
}>;
|
|
158
|
-
/** Whether to show the icon in the trigger */
|
|
159
|
-
showIcon?: boolean;
|
|
160
157
|
/** Controlled value for the combobox. Can be a single value or array of values for multiple selection. */
|
|
161
158
|
value?: string | string[];
|
|
162
159
|
/** Callback fired when the selected value changes */
|
|
@@ -171,6 +168,8 @@ type ComboboxProps = Readonly<{
|
|
|
171
168
|
selectedFeedback?: "checkbox" | "check";
|
|
172
169
|
/** Always show the placeholder text even when a value is selected. When enabled, both placeholder and value are displayed. */
|
|
173
170
|
alwaysShowPlaceholder?: boolean;
|
|
171
|
+
/** Position where the selected value is displayed when alwaysShowPlaceholder is true ("left" next to placeholder or "right" next to trigger icon) */
|
|
172
|
+
valuePosition?: "left" | "right";
|
|
174
173
|
/** Render prop functions for customizing component rendering */
|
|
175
174
|
renders?: ComboboxRenderProps;
|
|
176
175
|
}>;
|
|
@@ -227,5 +226,5 @@ type ComboboxProps = Readonly<{
|
|
|
227
226
|
* />
|
|
228
227
|
* ```
|
|
229
228
|
*/
|
|
230
|
-
declare function Combobox({ searchable, multiple, icon: Icon,
|
|
229
|
+
declare function Combobox({ searchable, multiple, icon: Icon, value: controlledValue, onValueChange, labels, options, classNames, selectedFeedback, alwaysShowPlaceholder, valuePosition, renders, }: ComboboxProps): import("react/jsx-runtime").JSX.Element;
|
|
231
230
|
export { Combobox };
|
|
@@ -34,8 +34,8 @@ import { Combobox } from "@adamosuiteservices/ui/combobox";
|
|
|
34
34
|
| `multiple` | `boolean` | `false` | Permite selección múltiple |
|
|
35
35
|
| `selectedFeedback` | `"checkbox" \| "check"` | `"checkbox"` | Tipo de indicador visual |
|
|
36
36
|
| `icon` | `ComponentType<{ className?: string }>` | - | Componente de icono opcional para mostrar en el trigger |
|
|
37
|
-
| `showIcon` | `boolean` | `false` | Muestra el icono en el trigger |
|
|
38
37
|
| `alwaysShowPlaceholder` | `boolean` | `false` | Mantiene el placeholder visible junto al valor seleccionado |
|
|
38
|
+
| `valuePosition` | `"left" \| "right"` | `"right"` | Posición del valor cuando alwaysShowPlaceholder es true |
|
|
39
39
|
| `labels` | `ComboboxLabels` | - | Textos personalizables (ver tabla abajo) |
|
|
40
40
|
| `classNames` | `ComboboxClassNames` | - | Clases CSS por sección (ver tabla abajo) |
|
|
41
41
|
| `renders` | `ComboboxRenderProps` | - | Funciones de renderizado personalizadas (ver tabla abajo) |
|
|
@@ -68,17 +68,17 @@ import { Combobox } from "@adamosuiteservices/ui/combobox";
|
|
|
68
68
|
|
|
69
69
|
Funciones de renderizado personalizadas para control total sobre la UI. Todas son opcionales y reciben props relevantes.
|
|
70
70
|
|
|
71
|
-
| Prop | Parámetros
|
|
72
|
-
| ------------------ |
|
|
73
|
-
| `trigger` | `{ open, value, displayText, placeholder, hasValue, icon
|
|
74
|
-
| `triggerIcon` | `{ open }`
|
|
75
|
-
| `placeholder` | `{ text, hasValue }`
|
|
76
|
-
| `displayValue` | `{ text, value }`
|
|
77
|
-
| `option` | `{ option, isSelected, selectedFeedback }`
|
|
78
|
-
| `optionLabel` | `{ option }`
|
|
79
|
-
| `selectedFeedback` | `{ option, isSelected, type }`
|
|
80
|
-
| `empty` | `{ text }`
|
|
81
|
-
| `searchInput` | `{ placeholder }`
|
|
71
|
+
| Prop | Parámetros | Descripción |
|
|
72
|
+
| ------------------ | ----------------------------------------------------------- | --------------------------------------- |
|
|
73
|
+
| `trigger` | `{ open, value, displayText, placeholder, hasValue, icon }` | Renderiza el botón trigger completo |
|
|
74
|
+
| `triggerIcon` | `{ open }` | Renderiza el icono del dropdown |
|
|
75
|
+
| `placeholder` | `{ text, hasValue }` | Renderiza el texto del placeholder |
|
|
76
|
+
| `displayValue` | `{ text, value }` | Renderiza el valor seleccionado |
|
|
77
|
+
| `option` | `{ option, isSelected, selectedFeedback }` | Renderiza una opción completa |
|
|
78
|
+
| `optionLabel` | `{ option }` | Renderiza solo la etiqueta de la opción |
|
|
79
|
+
| `selectedFeedback` | `{ option, isSelected, type }` | Renderiza el indicador de selección |
|
|
80
|
+
| `empty` | `{ text }` | Renderiza el estado vacío |
|
|
81
|
+
| `searchInput` | `{ placeholder }` | Renderiza el input de búsqueda |
|
|
82
82
|
|
|
83
83
|
## Patrones de Uso
|
|
84
84
|
|
|
@@ -104,7 +104,6 @@ import { CalendarIcon } from "lucide-react";
|
|
|
104
104
|
|
|
105
105
|
<Combobox
|
|
106
106
|
searchable
|
|
107
|
-
showIcon
|
|
108
107
|
icon={CalendarIcon}
|
|
109
108
|
options={frameworks}
|
|
110
109
|
labels={{ placeholder: "Select framework..." }}
|
|
@@ -119,6 +118,7 @@ import { CalendarIcon } from "lucide-react";
|
|
|
119
118
|
<Combobox
|
|
120
119
|
searchable
|
|
121
120
|
alwaysShowPlaceholder
|
|
121
|
+
valuePosition="right"
|
|
122
122
|
options={frameworks}
|
|
123
123
|
value={value}
|
|
124
124
|
onValueChange={setValue}
|
|
@@ -129,14 +129,39 @@ import { CalendarIcon } from "lucide-react";
|
|
|
129
129
|
**Comportamiento**:
|
|
130
130
|
|
|
131
131
|
- Sin valor: Muestra solo "Framework"
|
|
132
|
-
- Con valor
|
|
132
|
+
- Con valor y `valuePosition="right"`: Muestra "Framework" a la izquierda y el valor a la derecha
|
|
133
|
+
- Con valor y `valuePosition="left"`: Muestra "Framework" y el valor ambos a la izquierda
|
|
134
|
+
|
|
135
|
+
### Posición del Valor
|
|
136
|
+
|
|
137
|
+
Cuando `alwaysShowPlaceholder` es true, puedes controlar dónde aparece el valor seleccionado:
|
|
138
|
+
|
|
139
|
+
```tsx
|
|
140
|
+
// Valor a la derecha (default)
|
|
141
|
+
<Combobox
|
|
142
|
+
alwaysShowPlaceholder
|
|
143
|
+
valuePosition="right"
|
|
144
|
+
options={frameworks}
|
|
145
|
+
/>
|
|
146
|
+
|
|
147
|
+
// Valor a la izquierda junto al placeholder
|
|
148
|
+
<Combobox
|
|
149
|
+
alwaysShowPlaceholder
|
|
150
|
+
valuePosition="left"
|
|
151
|
+
options={frameworks}
|
|
152
|
+
/>
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
**Layouts resultantes**:
|
|
156
|
+
|
|
157
|
+
- `valuePosition="right"`: `[Icon] [Placeholder]` ... `[Value] [Chevron]`
|
|
158
|
+
- `valuePosition="left"`: `[Icon] [Placeholder] [Value]` ... `[Chevron]`
|
|
133
159
|
|
|
134
160
|
### Icono + Placeholder Persistente
|
|
135
161
|
|
|
136
162
|
```tsx
|
|
137
163
|
<Combobox
|
|
138
164
|
searchable
|
|
139
|
-
showIcon
|
|
140
165
|
alwaysShowPlaceholder
|
|
141
166
|
icon={CalendarIcon}
|
|
142
167
|
options={frameworks}
|
|
@@ -580,7 +605,8 @@ El prop `renders` permite personalizar completamente la UI usando el patrón ren
|
|
|
580
605
|
- **ChevronDownIcon**: Se muestra en trigger con `opacity-50` (puede sobrescribirse con `renders.triggerIcon`)
|
|
581
606
|
- **No animation**: Selección instantánea, sin delays
|
|
582
607
|
- **alwaysShowPlaceholder**: Renderiza placeholder y valor como elementos separados con gap
|
|
583
|
-
- **
|
|
608
|
+
- **valuePosition**: Controla donde aparece el valor cuando `alwaysShowPlaceholder` es true ("left" o "right", default "right")
|
|
609
|
+
- **icon**: Se muestra con `opacity-50` por defecto cuando se proporciona el prop `icon`
|
|
584
610
|
- **Render props**: Tienen prioridad sobre renderizado por defecto, permiten personalización completa
|
|
585
611
|
- **Composición de renders**: Puedes combinar múltiples render props para personalización granular
|
|
586
612
|
|
|
@@ -593,7 +619,7 @@ El prop `renders` permite personalizar completamente la UI usando el patrón ren
|
|
|
593
619
|
**Tipo de value incorrecto**: Single usa `string`, Multiple usa `string[]`
|
|
594
620
|
**Checkboxes no aparecen**: Solo aparecen cuando `selectedFeedback="checkbox"` (default)
|
|
595
621
|
**Check icon no visible**: Solo aparece cuando `selectedFeedback="check"`
|
|
596
|
-
**Icon no se muestra**: Asegúrate de pasar
|
|
622
|
+
**Icon no se muestra**: Asegúrate de pasar el prop `icon` con un componente válido
|
|
597
623
|
**Placeholder desaparece al seleccionar**: Si quieres mantenerlo visible, usa `alwaysShowPlaceholder={true}`
|
|
598
624
|
**Render prop no funciona**: Verifica que el render prop retorne un `ReactNode` válido
|
|
599
625
|
**Custom trigger pierde funcionalidad**: Cuando usas `renders.trigger`, debes manejar el click manualmente o envolver en `PopoverTrigger`
|