@inkeep/cxkit-primitives 0.5.36 → 0.5.38
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/atoms/cmdk/index.cjs +1 -1
- package/dist/atoms/cmdk/index.js +328 -320
- package/dist/components/embedded-chat/use-inkeep-chat.cjs +3 -3
- package/dist/components/embedded-chat/use-inkeep-chat.js +138 -143
- package/dist/components/embedded-chat.cjs +2 -2
- package/dist/components/embedded-chat.js +306 -306
- package/dist/components/embedded-search/search-provider.cjs +1 -1
- package/dist/components/embedded-search/search-provider.js +19 -12
- package/dist/components/embedded-search/transform-results.cjs +1 -1
- package/dist/components/embedded-search/transform-results.js +56 -72
- package/dist/components/embedded-search/url-query.cjs +1 -0
- package/dist/components/embedded-search/url-query.js +12 -0
- package/dist/components/embedded-search/use-inkeep-search.cjs +1 -1
- package/dist/components/embedded-search/use-inkeep-search.js +27 -149
- package/dist/components/embedded-search/use-search-filter.cjs +1 -0
- package/dist/components/embedded-search/use-search-filter.js +91 -0
- package/dist/components/embedded-search.cjs +1 -1
- package/dist/components/embedded-search.js +372 -365
- package/dist/components/intelligent-form/actions/escalation-schema.cjs +1 -1
- package/dist/components/intelligent-form/actions/escalation-schema.js +1 -2
- package/dist/constants/search.cjs +1 -0
- package/dist/constants/search.js +5 -0
- package/dist/index.d.cts +17 -122
- package/dist/index.d.ts +17 -122
- package/dist/providers/base-events-provider.cjs +1 -1
- package/dist/providers/base-events-provider.js +1 -1
- package/dist/providers/config-provider.cjs +1 -1
- package/dist/providers/config-provider.js +15 -15
- package/dist/utils/component-ids.cjs +1 -1
- package/dist/utils/component-ids.js +1 -1
- package/dist/utils/default-settings.cjs +1 -1
- package/dist/utils/default-settings.js +7 -21
- package/dist/utils/tools/{links-schema.cjs → links-tool.cjs} +1 -1
- package/dist/utils/tools/{links-schema.js → links-tool.js} +13 -4
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("react/jsx-runtime"),Re=require("@radix-ui/react-dialog"),ke=require("react"),je=require("./command-score.cjs"),y=require("@radix-ui/react-primitive"),D=require("@radix-ui/react-id"),_e=require("../../node_modules/.pnpm/use-sync-external-store@1.4.0_react@19.0.0/node_modules/use-sync-external-store/shim/index.cjs"),Pe=require("../../components/embedded-search.cjs"),Ae=require("../shadow/context.cjs");function le(t){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const r in t)if(r!=="default"){const u=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(n,r,u.get?u:{enumerable:!0,get:()=>t[r]})}}return n.default=t,Object.freeze(n)}const q=le(Re),c=le(ke),O='[cmdk-group=""]',Q='[cmdk-group-items=""]',Le='[cmdk-group-heading=""]',ue='[cmdk-item=""]',ie=`${ue}:not([aria-disabled="true"])`,X="cmdk-item-select",A="data-value",ae=(t,n,r)=>je.commandScore(t,n,r??[]),de=c.createContext(void 0),V=()=>c.useContext(de),fe=c.createContext(void 0),Y=()=>c.useContext(fe),me=c.createContext(void 0),Z=c.forwardRef((t,n)=>{const r=L(()=>({search:"",value:t.value??t.defaultValue??"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),u=L(()=>new Set),s=L(()=>new Map),d=L(()=>new Map),f=L(()=>new Set),m=Ee(t),{label:a,children:I,value:p,onValueChange:E,filter:R,shouldFilter:x,loop:P,disablePointerSelection:Ce=!1,vimBindings:G=!0,...K}=t,ee=D.useId(),N=D.useId(),b=D.useId(),w=c.useRef(null),C=Ve();j(()=>{if(p!==void 0){const e=p.trim();r.current.value=e,S.emit()}},[p]),j(()=>{C(6,re)},[]);const ye=Ae.useShadow(),S=c.useMemo(()=>({subscribe:e=>(f.current.add(e),()=>f.current.delete(e)),snapshot:()=>r.current,setState:(e,i,o)=>{if(!Object.is(r.current[e],i)){if(r.current[e]=i,e==="search")z(),$(),C(1,U);else if(e==="value"&&(ye?.shadowHost?.shadowRoot?.activeElement?.hasAttribute("cmdk-input")||C(1,()=>{k()?.focus()}),C(7,()=>{r.current.selectedItemId=k()?.id,S.emit()}),o||C(5,re),m.current?.value!==void 0)){const g=i??"";m.current.onValueChange?.(g);return}S.emit()}},emit:()=>{f.current.forEach(e=>e())}}),[]),B=c.useMemo(()=>({value:(e,i,o)=>{i!==d.current.get(e)?.value&&(d.current.set(e,{value:i,keywords:o}),r.current.filtered.items.set(e,te(i,o)),C(2,()=>{$(),S.emit()}))},item:(e,i)=>(u.current.add(e),i&&(s.current.has(i)?s.current?.get(i)?.add(e):s.current.set(i,new Set([e]))),C(3,()=>{z(),$(),r.current.value||U(),S.emit()}),()=>{d.current.delete(e),u.current.delete(e),r.current.filtered.items.delete(e);const o=k();C(4,()=>{z(),o?.getAttribute("id")===e&&U(),S.emit()})}),group:e=>(s.current.has(e)||s.current.set(e,new Set),()=>{d.current.delete(e),s.current.delete(e)}),filter:()=>!!m.current.shouldFilter,label:a||t["aria-label"]||"",getDisablePointerSelection:()=>!!m.current.disablePointerSelection,listId:ee,inputId:b,labelId:N,listInnerRef:w}),[]);function te(e,i){const o=m.current?.filter??ae;return e?o?.(e,r.current.search,i):0}function $(){if(!r.current.search||m.current.shouldFilter===!1)return;const e=r.current.filtered.items,i=[];r.current.filtered.groups.forEach(l=>{const v=s.current.get(l);let g=0;v.forEach(J=>{const Ie=e.get(J);g=Math.max(Ie,g)}),i.push([l,g])});const o=w.current;M().sort((l,v)=>{const g=l.getAttribute("id"),J=v.getAttribute("id");return(e.get(J)??0)-(e.get(g)??0)}).forEach(l=>{const v=l.closest(Q);if(v){const g=l.parentElement===v?l:l.closest(`${Q} > *`);g&&v.appendChild(g)}else{const g=l.parentElement===o?l:l.closest(`${Q} > *`);g&&o?.appendChild(g)}}),i.sort((l,v)=>v[1]-l[1]).forEach(l=>{const v=w.current?.querySelector(`${O}[${A}="${encodeURIComponent(l[0])}"]`);v?.parentElement?.appendChild(v)})}function U(){const i=M().find(o=>o.getAttribute("aria-disabled")!=="true"&&o.getAttribute("data-value")!==Pe.ASK_AI_TRIGGER_VALUE)?.getAttribute(A);S.setState("value",i||void 0)}function z(){if(!r.current.search||m.current.shouldFilter===!1){r.current.filtered.count=u.current.size;return}r.current.filtered.groups=new Set;let e=0;for(const i of u.current){const o=d.current.get(i)?.value??"",l=d.current.get(i)?.keywords??[],v=te(o,l);r.current.filtered.items.set(i,v),v>0&&e++}for(const[i,o]of s.current)for(const l of o){const v=r.current.filtered.items.get(l);if(v&&v>0){r.current.filtered.groups.add(i);break}}r.current.filtered.count=e}function re(){const e=k();e&&(e.parentElement?.firstChild===e&&e.closest(O)?.querySelector(Le)?.scrollIntoView({block:"nearest"}),e.scrollIntoView({block:"nearest"}))}function k(){return w.current?.querySelector(`${ue}[aria-selected="true"]`)}function M(){return Array.from(w.current?.querySelectorAll(ie)||[])}function H(e){const o=M()[e];o&&S.setState("value",o.getAttribute(A))}function W(e){const i=k(),o=M(),l=o.findIndex(g=>g===i);let v=o[l+e];m.current?.loop&&(v=l+e<0?o[o.length-1]:l+e===o.length?o[0]:o[l+e]),v&&S.setState("value",v.getAttribute(A))}function ne(e){let o=k()?.closest(O),l;for(;o&&!l;)o=e>0?De(o,O):Te(o,O),l=o?.querySelector(ie);l?S.setState("value",l.getAttribute(A)):W(e)}const oe=()=>H(M().length-1),ce=e=>{e.preventDefault(),e.metaKey?oe():e.altKey?ne(1):W(1)},se=e=>{e.preventDefault(),e.metaKey?H(0):e.altKey?ne(-1):W(-1)};return h.jsxs(y.Primitive.div,{ref:n,tabIndex:-1,...K,"cmdk-root":"",onKeyDown:e=>{if(K.onKeyDown?.(e),!e.defaultPrevented)switch(e.key){case"n":case"j":{G&&e.ctrlKey&&ce(e);break}case"ArrowDown":{ce(e);break}case"p":case"k":{G&&e.ctrlKey&&se(e);break}case"ArrowUp":{se(e);break}case"Home":{e.preventDefault(),H(0);break}case"End":{e.preventDefault(),oe();break}case"Enter":if(!e.nativeEvent.isComposing&&e.keyCode!==229){e.preventDefault();const i=k();if(i){const o=new Event(X);i.dispatchEvent(o)}}}},children:[h.jsx("label",{"cmdk-label":"",htmlFor:B.inputId,id:B.labelId,style:Fe,children:a}),F(t,e=>h.jsx(fe.Provider,{value:S,children:h.jsx(de.Provider,{value:B,children:e})}))]})}),ve=c.forwardRef((t,n)=>{const{id:r}=t,u=c.useRef(null),s=c.useContext(me),d=V(),f=Ee(t),m=f.current?.forceMount??s?.forceMount;j(()=>{if(!m)return d.item(r,s?.id)},[m]);const a=we(r,u,[t.value,t.children,u],t.keywords),I=Y(),p=_(b=>b.value&&b.value===a.current),E=_(b=>m||d.filter()===!1?!0:b.search?b.filtered.items.get(r)>0:!0);c.useEffect(()=>{const b=u.current;if(!b||t.disabled)return;const w=()=>R("keyboard");return b.addEventListener(X,w),()=>b.removeEventListener(X,w)},[E,t.onSelect,t.disabled]);function R(b="click"){x(),f.current.onSelect?.({value:a.current,trigger:b})}function x(){I.setState("value",a.current,!0)}if(!E)return null;const{disabled:P,value:Ce,onSelect:G,forceMount:K,keywords:ee,...N}=t;return h.jsx(y.Primitive.div,{ref:T([u,n]),...N,id:r,"cmdk-item":"",role:"option","aria-disabled":!!P,"aria-selected":!!p,"data-disabled":!!P,"data-selected":!!p,onPointerMove:P||d.getDisablePointerSelection()?void 0:x,onClick:P?void 0:()=>R(),onFocus:P?void 0:x,children:t.children})}),Me=c.forwardRef((t,n)=>{const{heading:r,children:u,forceMount:s,...d}=t,f=D.useId(),m=c.useRef(null),a=c.useRef(null),I=D.useId(),p=V(),E=_(x=>s||p.filter()===!1?!0:x.search?x.filtered.groups.has(f):!0);j(()=>p.group(f),[]),we(f,m,[t.value,t.heading,a]);const R=c.useMemo(()=>({id:f,forceMount:s}),[s]);return h.jsxs(y.Primitive.div,{ref:T([m,n]),...d,"cmdk-group":"",role:"presentation",hidden:E?void 0:!0,children:[r&&h.jsx("div",{ref:a,"cmdk-group-heading":"","aria-hidden":!0,id:I,children:r}),F(t,x=>h.jsx("div",{"cmdk-group-items":"",role:"group","aria-labelledby":r?I:void 0,children:h.jsx(me.Provider,{value:R,children:x})}))]})}),he=c.forwardRef((t,n)=>{const{alwaysRender:r,...u}=t,s=c.useRef(null),d=_(f=>!f.search);return!r&&!d?null:h.jsx(y.Primitive.div,{ref:T([s,n]),...u,"cmdk-separator":"",role:"separator"})}),ge=c.forwardRef((t,n)=>{const{onValueChange:r,...u}=t,s=t.value!=null,d=Y(),f=_(a=>a.search),m=V();return c.useEffect(()=>{t.value!=null&&d.setState("search",t.value)},[t.value]),h.jsx(y.Primitive.input,{ref:n,...u,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":m.listId,"aria-labelledby":m.labelId,id:m.inputId,type:"text",value:s?t.value:f,onChange:a=>{s||d.setState("search",a.target.value),r?.(a.target.value)}})}),be=c.forwardRef((t,n)=>{const{children:r,label:u="Suggestions",...s}=t,d=c.useRef(null),f=c.useRef(null),m=V();return c.useEffect(()=>{if(f.current&&d.current){const a=f.current,I=d.current;let p;const E=new ResizeObserver(()=>{p=requestAnimationFrame(()=>{const R=a.offsetHeight;I.style.setProperty("--cmdk-list-height",R.toFixed(1)+"px")})});return E.observe(a),()=>{cancelAnimationFrame(p),E.unobserve(a)}}},[]),h.jsx(y.Primitive.div,{ref:T([d,n]),...s,"cmdk-list":"",tabIndex:-1,"aria-label":u,id:m.listId,children:F(t,a=>h.jsx("div",{ref:T([f,m.listInnerRef]),"cmdk-list-sizer":"",children:a}))})}),pe=c.forwardRef((t,n)=>{const{open:r,onOpenChange:u,overlayClassName:s,contentClassName:d,container:f,...m}=t;return h.jsx(q.Root,{open:r,onOpenChange:u,children:h.jsxs(q.Portal,{container:f,children:[h.jsx(q.Overlay,{"cmdk-overlay":"",className:s}),h.jsx(q.Content,{"aria-label":t.label,"cmdk-dialog":"",className:d,children:h.jsx(Z,{ref:n,...m})})]})})}),Se=c.forwardRef((t,n)=>_(u=>u.filtered.count===0)?h.jsx(y.Primitive.div,{ref:n,...t,"cmdk-empty":"",role:"presentation"}):null),xe=c.forwardRef((t,n)=>{const{progress:r,children:u,label:s="Loading...",...d}=t;return h.jsx(y.Primitive.div,{ref:n,...d,"cmdk-loading":"",role:"progressbar","aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":100,"aria-label":s,children:F(t,f=>h.jsx("div",{"aria-hidden":!0,children:f}))})}),Oe=Object.assign(Z,{List:be,Item:ve,Input:ge,Group:Me,Separator:he,Dialog:pe,Empty:Se,Loading:xe});function De(t,n){let r=t.nextElementSibling;for(;r;){if(r.matches(n))return r;r=r.nextElementSibling}}function Te(t,n){let r=t.previousElementSibling;for(;r;){if(r.matches(n))return r;r=r.previousElementSibling}}function Ee(t){const n=c.useRef(t);return j(()=>{n.current=t}),n}const j=typeof window>"u"?c.useEffect:c.useLayoutEffect;function L(t){const n=c.useRef(void 0);return n.current===void 0&&(n.current=t()),n}function T(t){return n=>{t.forEach(r=>{typeof r=="function"?r(n):r!=null&&(r.current=n)})}}function _(t){const n=Y(),r=()=>t(n.snapshot());return _e.shimExports.useSyncExternalStore(n.subscribe,r,r)}function we(t,n,r,u=[]){const s=c.useRef(void 0),d=V();return j(()=>{const f=(()=>{for(const a of r){if(typeof a=="string")return a.trim();if(typeof a=="object"&&"current"in a)return a.current?a.current.textContent?.trim():s.current}})(),m=u.map(a=>a.trim());d.value(t,f,m),n.current?.setAttribute(A,f),s.current=f}),s}const Ve=()=>{const[t,n]=c.useState(),r=L(()=>new Map);return j(()=>{r.current.forEach(u=>u()),r.current=new Map},[t]),(u,s)=>{r.current.set(u,s),n({})}};function qe(t){const n=t.type;return typeof n=="function"?n(t.props):"render"in n?n.render(t.props):t}function F({asChild:t,children:n},r){return t&&c.isValidElement(n)?c.cloneElement(qe(n),{ref:n.ref},r(n.props.children)):r(n)}const Fe={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};exports.Command=Oe;exports.CommandDialog=pe;exports.CommandEmpty=Se;exports.CommandInput=ge;exports.CommandItem=ve;exports.CommandList=be;exports.CommandLoading=xe;exports.CommandRoot=Z;exports.CommandSeparator=he;exports.defaultFilter=ae;exports.useCommandState=_;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("react/jsx-runtime"),je=require("@radix-ui/react-dialog"),G=require("react"),_e=require("./command-score.cjs"),k=require("@radix-ui/react-primitive"),T=require("@radix-ui/react-id"),Pe=require("../../node_modules/.pnpm/use-sync-external-store@1.4.0_react@19.0.0/node_modules/use-sync-external-store/shim/index.cjs"),Ae=require("../../constants/search.cjs"),Me=require("../shadow/context.cjs");function de(t){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const r in t)if(r!=="default"){const s=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(n,r,s.get?s:{enumerable:!0,get:()=>t[r]})}}return n.default=t,Object.freeze(n)}const F=de(je),c=de(G),D='[cmdk-group=""]',ee='[cmdk-group-items=""]',Le='[cmdk-group-heading=""]',fe='[cmdk-item=""]',ae=`${fe}:not([aria-disabled="true"])`,te="cmdk-item-select",M="data-value",me=(t,n,r)=>_e.commandScore(t,n,r??[]),ve=c.createContext(void 0),q=()=>c.useContext(ve),he=c.createContext(void 0),K=()=>c.useContext(he),ge=c.createContext(void 0),re=c.forwardRef((t,n)=>{const r=L(()=>new Set),s=L(()=>new Map),a=L(()=>new Map),f=L(()=>new Set),i=we(t),{label:h,children:d,value:S,onValueChange:E,filter:y,shouldFilter:C,loop:w,disablePointerSelection:A=!1,vimBindings:B=!0,defaultSearch:ne,...$}=t,g=L(()=>({search:ne??"",value:t.value??t.defaultValue??"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),U=T.useId(),z=T.useId(),p=T.useId(),I=c.useRef(null),R=qe();_(()=>{if(S!==void 0){const e=S.trim();g.current.value=e,x.emit()}},[S]),_(()=>{R(6,ce)},[]);const Re=Me.useShadow(),x=c.useMemo(()=>({subscribe:e=>(f.current.add(e),()=>f.current.delete(e)),snapshot:()=>g.current,setState:(e,l,o)=>{if(!Object.is(g.current[e],l)){if(g.current[e]=l,e==="search")Q(),W(),R(1,J);else if(e==="value"&&(Re?.shadowHost?.shadowRoot?.activeElement?.hasAttribute("cmdk-input")||R(1,()=>{j()?.focus()}),R(7,()=>{g.current.selectedItemId=j()?.id,x.emit()}),o||R(5,ce),i.current?.value!==void 0)){const b=l??"";i.current.onValueChange?.(b);return}x.emit()}},emit:()=>{f.current.forEach(e=>e())}}),[]),H=c.useMemo(()=>({value:(e,l,o)=>{l!==a.current.get(e)?.value&&(a.current.set(e,{value:l,keywords:o}),g.current.filtered.items.set(e,oe(l,o)),R(2,()=>{W(),x.emit()}))},item:(e,l)=>(r.current.add(e),l&&(s.current.has(l)?s.current?.get(l)?.add(e):s.current.set(l,new Set([e]))),R(3,()=>{Q(),W(),g.current.value||J(),x.emit()}),()=>{a.current.delete(e),r.current.delete(e),g.current.filtered.items.delete(e);const o=j();R(4,()=>{Q(),o?.getAttribute("id")===e&&J(),x.emit()})}),group:e=>(s.current.has(e)||s.current.set(e,new Set),()=>{a.current.delete(e),s.current.delete(e)}),filter:()=>!!i.current.shouldFilter,label:h||t["aria-label"]||"",getDisablePointerSelection:()=>!!i.current.disablePointerSelection,listId:U,inputId:p,labelId:z,listInnerRef:I}),[]);function oe(e,l){const o=i.current?.filter??me;return e?o?.(e,g.current.search,l):0}function W(){if(!g.current.search||i.current.shouldFilter===!1)return;const e=g.current.filtered.items,l=[];g.current.filtered.groups.forEach(u=>{const m=s.current.get(u);let b=0;m.forEach(Z=>{const ke=e.get(Z);b=Math.max(ke,b)}),l.push([u,b])});const o=I.current;O().sort((u,m)=>{const b=u.getAttribute("id"),Z=m.getAttribute("id");return(e.get(Z)??0)-(e.get(b)??0)}).forEach(u=>{const m=u.closest(ee);if(m){const b=u.parentElement===m?u:u.closest(`${ee} > *`);b&&m.appendChild(b)}else{const b=u.parentElement===o?u:u.closest(`${ee} > *`);b&&o?.appendChild(b)}}),l.sort((u,m)=>m[1]-u[1]).forEach(u=>{const m=I.current?.querySelector(`${D}[${M}="${encodeURIComponent(u[0])}"]`);m?.parentElement?.appendChild(m)})}function J(){const l=O().find(o=>o.getAttribute("aria-disabled")!=="true"&&o.getAttribute("data-value")!==Ae.ASK_AI_TRIGGER_VALUE)?.getAttribute(M);x.setState("value",l||void 0)}function Q(){if(!g.current.search||i.current.shouldFilter===!1){g.current.filtered.count=r.current.size;return}g.current.filtered.groups=new Set;let e=0;for(const l of r.current){const o=a.current.get(l)?.value??"",u=a.current.get(l)?.keywords??[],m=oe(o,u);g.current.filtered.items.set(l,m),m>0&&e++}for(const[l,o]of s.current)for(const u of o){const m=g.current.filtered.items.get(u);if(m&&m>0){g.current.filtered.groups.add(l);break}}g.current.filtered.count=e}function ce(){const e=j();e&&(e.parentElement?.firstChild===e&&e.closest(D)?.querySelector(Le)?.scrollIntoView({block:"nearest"}),e.scrollIntoView({block:"nearest"}))}function j(){return I.current?.querySelector(`${fe}[aria-selected="true"]`)}function O(){return Array.from(I.current?.querySelectorAll(ae)||[])}function X(e){const o=O()[e];o&&x.setState("value",o.getAttribute(M))}function Y(e){const l=j(),o=O(),u=o.findIndex(b=>b===l);let m=o[u+e];i.current?.loop&&(m=u+e<0?o[o.length-1]:u+e===o.length?o[0]:o[u+e]),m&&x.setState("value",m.getAttribute(M))}function se(e){let o=j()?.closest(D),u;for(;o&&!u;)o=e>0?Te(o,D):Ve(o,D),u=o?.querySelector(ae);u?x.setState("value",u.getAttribute(M)):Y(e)}const ie=()=>X(O().length-1),le=e=>{e.preventDefault(),e.metaKey?ie():e.altKey?se(1):Y(1)},ue=e=>{e.preventDefault(),e.metaKey?X(0):e.altKey?se(-1):Y(-1)};return v.jsxs(k.Primitive.div,{ref:n,tabIndex:-1,...$,"cmdk-root":"",onKeyDown:e=>{if($.onKeyDown?.(e),!e.defaultPrevented)switch(e.key){case"n":case"j":{B&&e.ctrlKey&&le(e);break}case"ArrowDown":{le(e);break}case"p":case"k":{B&&e.ctrlKey&&ue(e);break}case"ArrowUp":{ue(e);break}case"Home":{e.preventDefault(),X(0);break}case"End":{e.preventDefault(),ie();break}case"Enter":if(!e.nativeEvent.isComposing&&e.keyCode!==229){e.preventDefault();const l=j();if(l){const o=new Event(te);l.dispatchEvent(o)}}}},style:{display:"contents"},children:[v.jsx("label",{"cmdk-label":"",htmlFor:H.inputId,id:H.labelId,style:Ge,children:h}),N(t,e=>v.jsx(he.Provider,{value:x,children:v.jsx(ve.Provider,{value:H,children:e})}))]})}),be=c.forwardRef((t,n)=>{const{id:r}=t,s=c.useRef(null),a=c.useContext(ge),f=q(),i=we(t),h=i.current?.forceMount??a?.forceMount;_(()=>{if(!h)return f.item(r,a?.id)},[h]);const d=Ie(r,s,[t.value,t.children,s],t.keywords),S=K(),E=P(p=>p.value&&p.value===d.current),y=P(p=>h||f.filter()===!1?!0:p.search?p.filtered.items.get(r)>0:!0);c.useEffect(()=>{const p=s.current;if(!p||t.disabled)return;const I=()=>w("keyboard");return p.addEventListener(te,I),()=>p.removeEventListener(te,I)},[y,t.onSelect,t.disabled]);const C=G.useCallback(()=>{S.setState("value",d.current,!0)},[S,d]),w=G.useCallback((p="click")=>{C(),i.current.onSelect?.({value:d.current,trigger:p})},[C,i,d]);if(!y)return null;const{disabled:A,value:B,onSelect:ne,forceMount:$,keywords:g,...U}=t,z=G.useMemo(()=>V([s,n]),[s,n]);return v.jsx(k.Primitive.div,{ref:z,...U,id:r,"cmdk-item":"",role:"option","aria-disabled":!!A,"aria-selected":!!E,"data-disabled":!!A,"data-selected":!!E,onPointerMove:A||f.getDisablePointerSelection()?void 0:C,onClick:A?void 0:w,onFocus:A?void 0:C,children:t.children})}),Oe=c.forwardRef((t,n)=>{const{heading:r,children:s,forceMount:a,...f}=t,i=T.useId(),h=c.useRef(null),d=c.useRef(null),S=T.useId(),E=q(),y=P(w=>a||E.filter()===!1?!0:w.search?w.filtered.groups.has(i):!0);_(()=>E.group(i),[]),Ie(i,h,[t.value,t.heading,d]);const C=c.useMemo(()=>({id:i,forceMount:a}),[a]);return v.jsxs(k.Primitive.div,{ref:V([h,n]),...f,"cmdk-group":"",role:"presentation",hidden:y?void 0:!0,children:[r&&v.jsx("div",{ref:d,"cmdk-group-heading":"","aria-hidden":!0,id:S,children:r}),N(t,w=>v.jsx("div",{"cmdk-group-items":"",role:"group","aria-labelledby":r?S:void 0,children:v.jsx(ge.Provider,{value:C,children:w})}))]})}),pe=c.forwardRef((t,n)=>{const{alwaysRender:r,...s}=t,a=c.useRef(null),f=P(i=>!i.search);return!r&&!f?null:v.jsx(k.Primitive.div,{ref:V([a,n]),...s,"cmdk-separator":"",role:"separator"})}),Se=c.forwardRef((t,n)=>{const{onValueChange:r,...s}=t,a=t.value!=null,f=K(),i=P(d=>d.search),h=q();return c.useEffect(()=>{t.value!=null&&f.setState("search",t.value)},[t.value]),v.jsx(k.Primitive.input,{ref:n,...s,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":h.listId,"aria-labelledby":h.labelId,id:h.inputId,type:"text",value:a?t.value:i,onChange:d=>{a||f.setState("search",d.target.value),r?.(d.target.value)}})}),xe=c.forwardRef((t,n)=>{const{children:r,label:s="Suggestions",...a}=t,f=c.useRef(null),i=c.useRef(null),h=q();return c.useEffect(()=>{if(i.current&&f.current){const d=i.current,S=f.current;let E;const y=new ResizeObserver(()=>{E=requestAnimationFrame(()=>{const C=d.offsetHeight;S.style.setProperty("--cmdk-list-height",C.toFixed(1)+"px")})});return y.observe(d),()=>{cancelAnimationFrame(E),y.unobserve(d)}}},[]),v.jsx(k.Primitive.div,{ref:V([f,n]),...a,"cmdk-list":"",tabIndex:-1,"aria-label":s,id:h.listId,children:N(t,d=>v.jsx("div",{ref:V([i,h.listInnerRef]),"cmdk-list-sizer":"",children:d}))})}),Ee=c.forwardRef((t,n)=>{const{open:r,onOpenChange:s,overlayClassName:a,contentClassName:f,container:i,...h}=t;return v.jsx(F.Root,{open:r,onOpenChange:s,children:v.jsxs(F.Portal,{container:i,children:[v.jsx(F.Overlay,{"cmdk-overlay":"",className:a}),v.jsx(F.Content,{"aria-label":t.label,"cmdk-dialog":"",className:f,children:v.jsx(re,{ref:n,...h})})]})})}),Ce=c.forwardRef((t,n)=>P(s=>s.filtered.count===0)?v.jsx(k.Primitive.div,{ref:n,...t,"cmdk-empty":"",role:"presentation"}):null),ye=c.forwardRef((t,n)=>{const{progress:r,children:s,label:a="Loading...",...f}=t;return v.jsx(k.Primitive.div,{ref:n,...f,"cmdk-loading":"",role:"progressbar","aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":100,"aria-label":a,children:N(t,i=>v.jsx("div",{"aria-hidden":!0,children:i}))})}),De=Object.assign(re,{List:xe,Item:be,Input:Se,Group:Oe,Separator:pe,Dialog:Ee,Empty:Ce,Loading:ye});function Te(t,n){let r=t.nextElementSibling;for(;r;){if(r.matches(n))return r;r=r.nextElementSibling}}function Ve(t,n){let r=t.previousElementSibling;for(;r;){if(r.matches(n))return r;r=r.previousElementSibling}}function we(t){const n=c.useRef(t);return _(()=>{n.current=t}),n}const _=typeof window>"u"?c.useEffect:c.useLayoutEffect;function L(t){const n=c.useRef(void 0);return n.current===void 0&&(n.current=t()),n}function V(t){return n=>{t.forEach(r=>{typeof r=="function"?r(n):r!=null&&(r.current=n)})}}function P(t){const n=K(),r=()=>t(n.snapshot());return Pe.shimExports.useSyncExternalStore(n.subscribe,r,r)}function Ie(t,n,r,s=[]){const a=c.useRef(void 0),f=q();return _(()=>{const i=(()=>{for(const d of r){if(typeof d=="string")return d.trim();if(typeof d=="object"&&"current"in d)return d.current?d.current.textContent?.trim():a.current}})(),h=s.map(d=>d.trim());f.value(t,i,h),n.current?.setAttribute(M,i),a.current=i}),a}const qe=()=>{const[t,n]=c.useState(),r=L(()=>new Map);return _(()=>{r.current.forEach(s=>s()),r.current=new Map},[t]),(s,a)=>{r.current.set(s,a),n({})}};function Fe(t){const n=t.type;return typeof n=="function"?n(t.props):"render"in n?n.render(t.props):t}function N({asChild:t,children:n},r){return t&&c.isValidElement(n)?c.cloneElement(Fe(n),{ref:n.ref},r(n.props.children)):r(n)}const Ge={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};exports.Command=De;exports.CommandDialog=Ee;exports.CommandEmpty=Ce;exports.CommandInput=Se;exports.CommandItem=be;exports.CommandList=xe;exports.CommandLoading=ye;exports.CommandRoot=re;exports.CommandSeparator=pe;exports.defaultFilter=me;exports.useCommandState=P;exports.useCommandStore=K;
|