@data-slot/select 0.2.31 → 0.2.32

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