@data-slot/select 0.2.31 → 0.2.33
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/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require(`@data-slot/core`);const t=[`top`,`bottom`],n=[`start`,`center`,`end`],r=[`item-aligned`,`popper`];function i(i,o={}){let s=(0,e.getPart)(i,`select-trigger`),c=(0,e.getPart)(i,`select-content`),l=(0,e.getPart)(i,`select-value`);if(!s||!c)throw Error(`Select requires trigger and content slots`);let u=o.defaultValue??(0,e.getDataString)(i,`defaultValue`)??null,ee=o.defaultOpen??(0,e.getDataBool)(i,`defaultOpen`)??!1,d=o.placeholder??(0,e.getDataString)(i,`placeholder`)??(l?(0,e.getDataString)(l,`placeholder`):void 0)??``,f=o.disabled??(0,e.getDataBool)(i,`disabled`)??!1,p=o.required??(0,e.getDataBool)(i,`required`)??!1,m=o.name??(0,e.getDataString)(i,`name`)??null,h=o.onValueChange,g=o.onOpenChange,_=o.position??(0,e.getDataEnum)(i,`position`,r)??`item-aligned`,v=o.side??(0,e.getDataEnum)(c,`side`,t)??(0,e.getDataEnum)(i,`side`,t)??`bottom`,y=o.align??(0,e.getDataEnum)(c,`align`,n)??(0,e.getDataEnum)(i,`align`,n)??`start`,te=o.sideOffset??(0,e.getDataNumber)(c,`sideOffset`)??(0,e.getDataNumber)(i,`sideOffset`)??4,b=o.alignOffset??(0,e.getDataNumber)(c,`alignOffset`)??(0,e.getDataNumber)(i,`alignOffset`)??0,x=o.avoidCollisions??(0,e.getDataBool)(c,`avoidCollisions`)??(0,e.getDataBool)(i,`avoidCollisions`)??!0,S=o.collisionPadding??(0,e.getDataNumber)(c,`collisionPadding`)??(0,e.getDataNumber)(i,`collisionPadding`)??8,C=o.lockScroll??(0,e.getDataBool)(i,`lockScroll`)??!0,w=!1,T=u,E=null,D=-1,O=``,k=null,A=!1,j=0,M=0,N=[],P=[],F=[],I=new Map,L=null,R=!1,z=(0,e.createPortalLifecycle)({content:c,root:i}),B=e=>e.hasAttribute(`disabled`)||e.hasAttribute(`data-disabled`)||e.getAttribute(`aria-disabled`)===`true`,V=(0,e.ensureId)(s,`select-trigger`),H=(0,e.ensureId)(c,`select-content`);s.setAttribute(`role`,`combobox`),s.setAttribute(`aria-haspopup`,`listbox`),s.setAttribute(`aria-controls`,H),s.hasAttribute(`type`)||s.setAttribute(`type`,`button`),c.setAttribute(`role`,`listbox`),c.setAttribute(`aria-labelledby`,V),c.tabIndex=-1;let U=document.querySelector(`label[for="${CSS.escape(V)}"]`);if(U){let t=(0,e.ensureId)(U,`select-label`),n=s.getAttribute(`aria-labelledby`);s.setAttribute(`aria-labelledby`,n?`${n} ${t}`:t),N.push((0,e.on)(U,`click`,e=>{e.preventDefault(),f||Z(!w)}))}f&&(s.setAttribute(`aria-disabled`,`true`),s.setAttribute(`data-disabled`,``)),p&&s.setAttribute(`aria-required`,`true`),m&&(L=document.createElement(`input`),L.type=`hidden`,L.name=m,L.value=T??``,i.appendChild(L));let W=()=>{P=(0,e.getParts)(c,`select-item`);for(let t of P)t.setAttribute(`role`,`option`),t.hasAttribute(`data-disabled`)||t.hasAttribute(`disabled`)?t.setAttribute(`aria-disabled`,`true`):t.removeAttribute(`aria-disabled`),t.tabIndex=-1,t.dataset.value===T?((0,e.setAria)(t,`selected`,!0),t.setAttribute(`data-selected`,``)):((0,e.setAria)(t,`selected`,!1),t.removeAttribute(`data-selected`));F=P.filter(e=>!B(e)),I=new Map(F.map((e,t)=>[e,t]));let t=(0,e.getParts)(c,`select-group`);for(let n of t){n.setAttribute(`role`,`group`);let t=(0,e.getPart)(n,`select-label`);if(t){let r=(0,e.ensureId)(t,`select-label`);n.setAttribute(`aria-labelledby`,r)}}},G=(e,t)=>{let n=P.find(e=>e.dataset.value===T)??F[0],r=e.left,i,a=0,o=e.height;if(n){let r=n.getBoundingClientRect();a=r.top-t.top+c.scrollTop,o=r.height||n.offsetHeight||e.height,i=e.top+e.height/2-o/2-a}else i=e.top;return{x:r,y:i,alignItem:n,itemTopInContent:a,itemHeight:o}},K=()=>{let n=i.ownerDocument.defaultView??window,r=s.getBoundingClientRect();c.style.minWidth=`${r.width}px`;let a=c.getBoundingClientRect(),o,l=`bottom`;if(_===`item-aligned`){let e=G(r,a);o={x:e.x,y:e.y};let t=r.top+r.height/2,n=S,i=window.innerHeight-a.height-S,s=e=>x?i<n?n:Math.min(Math.max(e,n),i):e;if(x){let e=window.innerWidth,t=window.innerHeight;o.y<S?o.y=S:o.y+a.height>t-S&&(o.y=t-a.height-S),o.x<S?o.x=S:o.x+a.width>e-S&&(o.x=e-a.width-S)}if(e.alignItem){let n=Math.max(0,c.scrollHeight-c.clientHeight);if(n>0){let r=n=>e.itemTopInContent+e.itemHeight/2-(t-n);o.y=s(t-a.height/2);let i=Math.min(Math.max(r(o.y),0),n);c.scrollTop=i,o.y=s(t-(e.itemTopInContent-i+e.itemHeight/2)),i=Math.min(Math.max(r(o.y),0),n),c.scrollTop=i}}else c.scrollTop=0;l=o.y<r.top?`top`:`bottom`}else{let n=(0,e.computeFloatingPosition)({anchorRect:r,contentRect:a,side:v,align:y,sideOffset:te,alignOffset:b,avoidCollisions:x,collisionPadding:S,allowedSides:t});o={x:n.x,y:n.y},l=n.side}C?(c.style.position=`fixed`,c.style.top=`${o.y}px`,c.style.left=`${o.x}px`):(c.style.position=`absolute`,c.style.top=`${o.y+n.scrollY}px`,c.style.left=`${o.x+n.scrollX}px`),c.style.margin=`0`,c.setAttribute(`data-side`,l),c.setAttribute(`data-align`,_===`item-aligned`?`center`:y)},q=(0,e.createPositionSync)({observedElements:[s,c],isActive:()=>w,ancestorScroll:C,onUpdate:K,ignoreScrollTarget:e=>e instanceof Node&&c.contains(e)}),J=(t,n=!0,r=!0)=>{for(let i=0;i<F.length;i++){let a=F[i];i===t?(a.setAttribute(`data-highlighted`,``),r&&(0,e.ensureItemVisibleInContainer)(a,c),n&&a.focus()):a.removeAttribute(`data-highlighted`)}D=t},Y=()=>{for(let e of P)e.removeAttribute(`data-highlighted`);D=-1},X=e=>{i.setAttribute(`data-state`,e),s.setAttribute(`data-state`,e),c.setAttribute(`data-state`,e)},ne=()=>{if(l)if(T===null)l.textContent=d,s.setAttribute(`data-placeholder`,``);else{let e=P.find(e=>e.dataset.value===T);l.textContent=e?.dataset.label??e?.textContent?.trim()??T,s.removeAttribute(`data-placeholder`)}},Z=(t,n=!1)=>{if(w!==t&&!(f&&t)){if(t){E=document.activeElement,w=!0,(0,e.setAria)(s,`expanded`,!0),z.mount(),c.hidden=!1,X(`open`),C&&!R&&((0,e.lockScroll)(),R=!0),W(),A=!1;let t=F.findIndex(e=>e.dataset.value===T);t>=0?J(t,!1,!1):Y(),q.start(),K(),q.update(),requestAnimationFrame(()=>{if(w&&(q.update(),j!==0||M!==0)){let e=document.elementFromPoint(j,M)?.closest?.(`[data-slot="select-item"]`);if(e&&!B(e)&&c.contains(e)){let t=I.get(e);t!==void 0&&J(t,!1)}}}),c.focus()}else w=!1,(0,e.setAria)(s,`expanded`,!1),z.restore(),c.hidden=!0,X(`closed`),Y(),O=``,A=!1,R&&=((0,e.unlockScroll)(),!1),q.stop(),n?E=null:requestAnimationFrame(()=>{E&&document.contains(E)?E.focus():s&&document.contains(s)&&s.focus(),E=null});(0,e.emit)(i,`select:open-change`,{open:w}),g?.(w)}},Q=(t,n=!1)=>{if(T===t&&!n)return;let r=T;T=t,L&&(L.value=t??``),t===null?i.removeAttribute(`data-value`):i.setAttribute(`data-value`,t);for(let n of P)n.dataset.value===t?((0,e.setAria)(n,`selected`,!0),n.setAttribute(`data-selected`,``)):((0,e.setAria)(n,`selected`,!1),n.removeAttribute(`data-selected`));ne(),!n&&r!==t&&((0,e.emit)(i,`select:change`,{value:t}),h?.(t))},$=e=>{if(B(e))return;let t=e.dataset.value;t!==void 0&&(Q(t),Z(!1))},re=e=>{let t=F.length;if(t!==0)switch(e.key){case`ArrowDown`:e.preventDefault(),A=!0,J(D===-1?0:Math.min(D+1,t-1));break;case`ArrowUp`:e.preventDefault(),A=!0,J(D===-1?t-1:Math.max(D-1,0));break;case`Home`:e.preventDefault(),A=!0,J(0);break;case`End`:e.preventDefault(),A=!0,J(t-1);break;case`Enter`:case` `:e.preventDefault(),D>=0&&$(F[D]);break;case`Tab`:Z(!1,!0);break;case`Escape`:e.preventDefault(),Z(!1);break;default:e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&(e.preventDefault(),ie(e.key.toLowerCase()))}},ie=e=>{k&&clearTimeout(k),k=setTimeout(()=>{O=``},500),O+=e;let t=F.findIndex(e=>(e.textContent?.trim().toLowerCase()||``).startsWith(O));if(t===-1&&O.length===1){let n=D+1;for(let r=0;r<F.length;r++){let i=(n+r)%F.length;if((F[i].textContent?.trim().toLowerCase()||``).startsWith(e)){t=i;break}}}t!==-1&&(A=!0,J(t))};return(0,e.setAria)(s,`expanded`,!1),c.hidden=!0,X(`closed`),W(),Q(T,!0),N.push((0,e.on)(s,`pointerdown`,e=>{j=e.clientX,M=e.clientY}),(0,e.on)(s,`click`,()=>{f||Z(!w)}),(0,e.on)(s,`keydown`,e=>{if(!f)switch(e.key){case`Enter`:case` `:case`ArrowDown`:case`ArrowUp`:e.preventDefault(),Z(!0);break}})),N.push((0,e.on)(c,`keydown`,re),(0,e.on)(c,`click`,e=>{let t=e.target.closest?.(`[data-slot="select-item"]`);t&&$(t)}),(0,e.on)(c,`pointermove`,e=>{let t=e.target.closest?.(`[data-slot="select-item"]`);if(!(A&&(A=!1,t&&I.get(t)===D)))if(t&&!B(t)){let e=I.get(t);e!==void 0&&e!==D&&J(e,!1)}else Y()}),(0,e.on)(c,`pointerleave`,()=>{A||Y()})),N.push((0,e.createDismissLayer)({root:i,isOpen:()=>w,onDismiss:()=>Z(!1),closeOnClickOutside:!0,closeOnEscape:!1})),N.push((0,e.on)(i,`select:set`,e=>{let t=e.detail;t?.value!==void 0&&Q(t.value),t?.open!==void 0&&Z(t.open)})),ee&&Z(!0),{get value(){return T},get isOpen(){return w},select:e=>Q(e),open:()=>Z(!0),close:()=>Z(!1),destroy:()=>{k&&clearTimeout(k),q.stop(),z.cleanup(),R&&=((0,e.unlockScroll)(),!1),N.forEach(e=>e()),N.length=0,L&&L.parentNode&&L.parentNode.removeChild(L),a.delete(i)}}}const a=new WeakSet;function o(t=document){let n=[];for(let r of(0,e.getRoots)(t,`select`))a.has(r)||(a.add(r),n.push(i(r)));return n}exports.create=o,exports.createSelect=i;
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{computeFloatingPosition as e,createDismissLayer as t,createPortalLifecycle as n,createPositionSync as r,emit as i,ensureId as a,ensureItemVisibleInContainer as o,getDataBool as s,getDataEnum as c,getDataNumber as l,getDataString as u,getPart as d,getParts as f,getRoots as p,lockScroll as ee,on as m,setAria as h,unlockScroll as g}from"@data-slot/core";const _=[`top`,`bottom`],v=[`start`,`center`,`end`],te=[`item-aligned`,`popper`];function y(p,y={}){let x=d(p,`select-trigger`),S=d(p,`select-content`),C=d(p,`select-value`);if(!x||!S)throw Error(`Select requires trigger and content slots`);let ne=y.defaultValue??u(p,`defaultValue`)??null,re=y.defaultOpen??s(p,`defaultOpen`)??!1,ie=y.placeholder??u(p,`placeholder`)??(C?u(C,`placeholder`):void 0)??``,w=y.disabled??s(p,`disabled`)??!1,ae=y.required??s(p,`required`)??!1,
|
|
1
|
+
import{computeFloatingPosition as e,createDismissLayer as t,createPortalLifecycle as n,createPositionSync as r,emit as i,ensureId as a,ensureItemVisibleInContainer as o,getDataBool as s,getDataEnum as c,getDataNumber as l,getDataString as u,getPart as d,getParts as f,getRoots as p,lockScroll as ee,on as m,setAria as h,unlockScroll as g}from"@data-slot/core";const _=[`top`,`bottom`],v=[`start`,`center`,`end`],te=[`item-aligned`,`popper`];function y(p,y={}){let x=d(p,`select-trigger`),S=d(p,`select-content`),C=d(p,`select-value`);if(!x||!S)throw Error(`Select requires trigger and content slots`);let ne=y.defaultValue??u(p,`defaultValue`)??null,re=y.defaultOpen??s(p,`defaultOpen`)??!1,ie=y.placeholder??u(p,`placeholder`)??(C?u(C,`placeholder`):void 0)??``,w=y.disabled??s(p,`disabled`)??!1,ae=y.required??s(p,`required`)??!1,T=y.name??u(p,`name`)??null,oe=y.onValueChange,se=y.onOpenChange,E=y.position??c(p,`position`,te)??`item-aligned`,ce=y.side??c(S,`side`,_)??c(p,`side`,_)??`bottom`,le=y.align??c(S,`align`,v)??c(p,`align`,v)??`start`,ue=y.sideOffset??l(S,`sideOffset`)??l(p,`sideOffset`)??4,de=y.alignOffset??l(S,`alignOffset`)??l(p,`alignOffset`)??0,D=y.avoidCollisions??s(S,`avoidCollisions`)??s(p,`avoidCollisions`)??!0,O=y.collisionPadding??l(S,`collisionPadding`)??l(p,`collisionPadding`)??8,k=y.lockScroll??s(p,`lockScroll`)??!0,A=!1,j=ne,M=null,N=-1,P=``,F=null,I=!1,L=0,R=0,z=[],B=[],V=[],H=new Map,U=null,W=!1,G=n({content:S,root:p}),K=e=>e.hasAttribute(`disabled`)||e.hasAttribute(`data-disabled`)||e.getAttribute(`aria-disabled`)===`true`,fe=a(x,`select-trigger`),pe=a(S,`select-content`);x.setAttribute(`role`,`combobox`),x.setAttribute(`aria-haspopup`,`listbox`),x.setAttribute(`aria-controls`,pe),x.hasAttribute(`type`)||x.setAttribute(`type`,`button`),S.setAttribute(`role`,`listbox`),S.setAttribute(`aria-labelledby`,fe),S.tabIndex=-1;let q=document.querySelector(`label[for="${CSS.escape(fe)}"]`);if(q){let e=a(q,`select-label`),t=x.getAttribute(`aria-labelledby`);x.setAttribute(`aria-labelledby`,t?`${t} ${e}`:e),z.push(m(q,`click`,e=>{e.preventDefault(),w||Q(!A)}))}w&&(x.setAttribute(`aria-disabled`,`true`),x.setAttribute(`data-disabled`,``)),ae&&x.setAttribute(`aria-required`,`true`),T&&(U=document.createElement(`input`),U.type=`hidden`,U.name=T,U.value=j??``,p.appendChild(U));let me=()=>{B=f(S,`select-item`);for(let e of B)e.setAttribute(`role`,`option`),e.hasAttribute(`data-disabled`)||e.hasAttribute(`disabled`)?e.setAttribute(`aria-disabled`,`true`):e.removeAttribute(`aria-disabled`),e.tabIndex=-1,e.dataset.value===j?(h(e,`selected`,!0),e.setAttribute(`data-selected`,``)):(h(e,`selected`,!1),e.removeAttribute(`data-selected`));V=B.filter(e=>!K(e)),H=new Map(V.map((e,t)=>[e,t]));let e=f(S,`select-group`);for(let t of e){t.setAttribute(`role`,`group`);let e=d(t,`select-label`);if(e){let n=a(e,`select-label`);t.setAttribute(`aria-labelledby`,n)}}},he=(e,t)=>{let n=B.find(e=>e.dataset.value===j)??V[0],r=e.left,i,a=0,o=e.height;if(n){let r=n.getBoundingClientRect();a=r.top-t.top+S.scrollTop,o=r.height||n.offsetHeight||e.height,i=e.top+e.height/2-o/2-a}else i=e.top;return{x:r,y:i,alignItem:n,itemTopInContent:a,itemHeight:o}},ge=()=>{let t=p.ownerDocument.defaultView??window,n=x.getBoundingClientRect();S.style.minWidth=`${n.width}px`;let r=S.getBoundingClientRect(),i,a=`bottom`;if(E===`item-aligned`){let e=he(n,r);i={x:e.x,y:e.y};let t=n.top+n.height/2,o=O,s=window.innerHeight-r.height-O,c=e=>D?s<o?o:Math.min(Math.max(e,o),s):e;if(D){let e=window.innerWidth,t=window.innerHeight;i.y<O?i.y=O:i.y+r.height>t-O&&(i.y=t-r.height-O),i.x<O?i.x=O:i.x+r.width>e-O&&(i.x=e-r.width-O)}if(e.alignItem){let n=Math.max(0,S.scrollHeight-S.clientHeight);if(n>0){let a=n=>e.itemTopInContent+e.itemHeight/2-(t-n);i.y=c(t-r.height/2);let o=Math.min(Math.max(a(i.y),0),n);S.scrollTop=o,i.y=c(t-(e.itemTopInContent-o+e.itemHeight/2)),o=Math.min(Math.max(a(i.y),0),n),S.scrollTop=o}}else S.scrollTop=0;a=i.y<n.top?`top`:`bottom`}else{let t=e({anchorRect:n,contentRect:r,side:ce,align:le,sideOffset:ue,alignOffset:de,avoidCollisions:D,collisionPadding:O,allowedSides:_});i={x:t.x,y:t.y},a=t.side}k?(S.style.position=`fixed`,S.style.top=`${i.y}px`,S.style.left=`${i.x}px`):(S.style.position=`absolute`,S.style.top=`${i.y+t.scrollY}px`,S.style.left=`${i.x+t.scrollX}px`),S.style.margin=`0`,S.setAttribute(`data-side`,a),S.setAttribute(`data-align`,E===`item-aligned`?`center`:le)},J=r({observedElements:[x,S],isActive:()=>A,ancestorScroll:k,onUpdate:ge,ignoreScrollTarget:e=>e instanceof Node&&S.contains(e)}),Y=(e,t=!0,n=!0)=>{for(let r=0;r<V.length;r++){let i=V[r];r===e?(i.setAttribute(`data-highlighted`,``),n&&o(i,S),t&&i.focus()):i.removeAttribute(`data-highlighted`)}N=e},X=()=>{for(let e of B)e.removeAttribute(`data-highlighted`);N=-1},Z=e=>{p.setAttribute(`data-state`,e),x.setAttribute(`data-state`,e),S.setAttribute(`data-state`,e)},_e=()=>{if(C)if(j===null)C.textContent=ie,x.setAttribute(`data-placeholder`,``);else{let e=B.find(e=>e.dataset.value===j);C.textContent=e?.dataset.label??e?.textContent?.trim()??j,x.removeAttribute(`data-placeholder`)}},Q=(e,t=!1)=>{if(A!==e&&!(w&&e)){if(e){M=document.activeElement,A=!0,h(x,`expanded`,!0),G.mount(),S.hidden=!1,Z(`open`),k&&!W&&(ee(),W=!0),me(),I=!1;let e=V.findIndex(e=>e.dataset.value===j);e>=0?Y(e,!1,!1):X(),J.start(),ge(),J.update(),requestAnimationFrame(()=>{if(A&&(J.update(),L!==0||R!==0)){let e=document.elementFromPoint(L,R)?.closest?.(`[data-slot="select-item"]`);if(e&&!K(e)&&S.contains(e)){let t=H.get(e);t!==void 0&&Y(t,!1)}}}),S.focus()}else A=!1,h(x,`expanded`,!1),G.restore(),S.hidden=!0,Z(`closed`),X(),P=``,I=!1,W&&=(g(),!1),J.stop(),t?M=null:requestAnimationFrame(()=>{M&&document.contains(M)?M.focus():x&&document.contains(x)&&x.focus(),M=null});i(p,`select:open-change`,{open:A}),se?.(A)}},$=(e,t=!1)=>{if(j===e&&!t)return;let n=j;j=e,U&&(U.value=e??``),e===null?p.removeAttribute(`data-value`):p.setAttribute(`data-value`,e);for(let t of B)t.dataset.value===e?(h(t,`selected`,!0),t.setAttribute(`data-selected`,``)):(h(t,`selected`,!1),t.removeAttribute(`data-selected`));_e(),!t&&n!==e&&(i(p,`select:change`,{value:e}),oe?.(e))},ve=e=>{if(K(e))return;let t=e.dataset.value;t!==void 0&&($(t),Q(!1))},ye=e=>{let t=V.length;if(t!==0)switch(e.key){case`ArrowDown`:e.preventDefault(),I=!0,Y(N===-1?0:Math.min(N+1,t-1));break;case`ArrowUp`:e.preventDefault(),I=!0,Y(N===-1?t-1:Math.max(N-1,0));break;case`Home`:e.preventDefault(),I=!0,Y(0);break;case`End`:e.preventDefault(),I=!0,Y(t-1);break;case`Enter`:case` `:e.preventDefault(),N>=0&&ve(V[N]);break;case`Tab`:Q(!1,!0);break;case`Escape`:e.preventDefault(),Q(!1);break;default:e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&(e.preventDefault(),be(e.key.toLowerCase()))}},be=e=>{F&&clearTimeout(F),F=setTimeout(()=>{P=``},500),P+=e;let t=V.findIndex(e=>(e.textContent?.trim().toLowerCase()||``).startsWith(P));if(t===-1&&P.length===1){let n=N+1;for(let r=0;r<V.length;r++){let i=(n+r)%V.length;if((V[i].textContent?.trim().toLowerCase()||``).startsWith(e)){t=i;break}}}t!==-1&&(I=!0,Y(t))};return h(x,`expanded`,!1),S.hidden=!0,Z(`closed`),me(),$(j,!0),z.push(m(x,`pointerdown`,e=>{L=e.clientX,R=e.clientY}),m(x,`click`,()=>{w||Q(!A)}),m(x,`keydown`,e=>{if(!w)switch(e.key){case`Enter`:case` `:case`ArrowDown`:case`ArrowUp`:e.preventDefault(),Q(!0);break}})),z.push(m(S,`keydown`,ye),m(S,`click`,e=>{let t=e.target.closest?.(`[data-slot="select-item"]`);t&&ve(t)}),m(S,`pointermove`,e=>{let t=e.target.closest?.(`[data-slot="select-item"]`);if(!(I&&(I=!1,t&&H.get(t)===N)))if(t&&!K(t)){let e=H.get(t);e!==void 0&&e!==N&&Y(e,!1)}else X()}),m(S,`pointerleave`,()=>{I||X()})),z.push(t({root:p,isOpen:()=>A,onDismiss:()=>Q(!1),closeOnClickOutside:!0,closeOnEscape:!1})),z.push(m(p,`select:set`,e=>{let t=e.detail;t?.value!==void 0&&$(t.value),t?.open!==void 0&&Q(t.open)})),re&&Q(!0),{get value(){return j},get isOpen(){return A},select:e=>$(e),open:()=>Q(!0),close:()=>Q(!1),destroy:()=>{F&&clearTimeout(F),J.stop(),G.cleanup(),W&&=(g(),!1),z.forEach(e=>e()),z.length=0,U&&U.parentNode&&U.parentNode.removeChild(U),b.delete(p)}}}const b=new WeakSet;function x(e=document){let t=[];for(let n of p(e,`select`))b.has(n)||(b.add(n),t.push(y(n)));return t}export{x as create,y as createSelect};
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|