@data-slot/core 0.2.42 → 0.2.43
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.
|
@@ -165,13 +165,27 @@ interface PortalLifecycleOptions {
|
|
|
165
165
|
root: Element;
|
|
166
166
|
enabled?: boolean;
|
|
167
167
|
state?: PortalState;
|
|
168
|
+
wrapperSlot?: string;
|
|
168
169
|
}
|
|
169
170
|
interface PortalLifecycleController {
|
|
170
171
|
readonly state: PortalState;
|
|
172
|
+
readonly container: Element;
|
|
171
173
|
mount(): void;
|
|
172
174
|
restore(): void;
|
|
173
175
|
cleanup(): void;
|
|
174
176
|
}
|
|
175
177
|
declare function createPortalLifecycle(options: PortalLifecycleOptions): PortalLifecycleController;
|
|
178
|
+
interface PresenceLifecycleOptions {
|
|
179
|
+
element: HTMLElement;
|
|
180
|
+
onExitComplete: () => void;
|
|
181
|
+
win?: Window;
|
|
182
|
+
}
|
|
183
|
+
interface PresenceLifecycleController {
|
|
184
|
+
readonly isExiting: boolean;
|
|
185
|
+
enter(): void;
|
|
186
|
+
exit(): void;
|
|
187
|
+
cleanup(): void;
|
|
188
|
+
}
|
|
189
|
+
declare function createPresenceLifecycle(options: PresenceLifecycleOptions): PresenceLifecycleController;
|
|
176
190
|
//#endregion
|
|
177
|
-
export { type ComputeFloatingPositionInput, type DismissLayerOptions, type FloatingPosition, type PopupAlign, type PopupPlacementOptions, type PopupSide, type PortalLifecycleController, type PortalLifecycleOptions, type PortalState, type PositionSyncController, type PositionSyncOptions, composeHandlers, computeFloatingPosition, containsWithPortals, createDismissLayer, createPortalLifecycle, createPositionSync, emit, ensureId, ensureItemVisibleInContainer, getDataBool, getDataEnum, getDataNumber, getDataString, getPart, getParts, getRoots, linkLabelledBy, lockScroll, on, portalToBody, restorePortal, setAria, unlockScroll };
|
|
191
|
+
export { type ComputeFloatingPositionInput, type DismissLayerOptions, type FloatingPosition, type PopupAlign, type PopupPlacementOptions, type PopupSide, type PortalLifecycleController, type PortalLifecycleOptions, type PortalState, type PositionSyncController, type PositionSyncOptions, type PresenceLifecycleController, type PresenceLifecycleOptions, composeHandlers, computeFloatingPosition, containsWithPortals, createDismissLayer, createPortalLifecycle, createPositionSync, createPresenceLifecycle, emit, ensureId, ensureItemVisibleInContainer, getDataBool, getDataEnum, getDataNumber, getDataString, getPart, getParts, getRoots, linkLabelledBy, lockScroll, on, portalToBody, restorePortal, setAria, unlockScroll };
|
|
@@ -165,13 +165,27 @@ interface PortalLifecycleOptions {
|
|
|
165
165
|
root: Element;
|
|
166
166
|
enabled?: boolean;
|
|
167
167
|
state?: PortalState;
|
|
168
|
+
wrapperSlot?: string;
|
|
168
169
|
}
|
|
169
170
|
interface PortalLifecycleController {
|
|
170
171
|
readonly state: PortalState;
|
|
172
|
+
readonly container: Element;
|
|
171
173
|
mount(): void;
|
|
172
174
|
restore(): void;
|
|
173
175
|
cleanup(): void;
|
|
174
176
|
}
|
|
175
177
|
declare function createPortalLifecycle(options: PortalLifecycleOptions): PortalLifecycleController;
|
|
178
|
+
interface PresenceLifecycleOptions {
|
|
179
|
+
element: HTMLElement;
|
|
180
|
+
onExitComplete: () => void;
|
|
181
|
+
win?: Window;
|
|
182
|
+
}
|
|
183
|
+
interface PresenceLifecycleController {
|
|
184
|
+
readonly isExiting: boolean;
|
|
185
|
+
enter(): void;
|
|
186
|
+
exit(): void;
|
|
187
|
+
cleanup(): void;
|
|
188
|
+
}
|
|
189
|
+
declare function createPresenceLifecycle(options: PresenceLifecycleOptions): PresenceLifecycleController;
|
|
176
190
|
//#endregion
|
|
177
|
-
export { type ComputeFloatingPositionInput, type DismissLayerOptions, type FloatingPosition, type PopupAlign, type PopupPlacementOptions, type PopupSide, type PortalLifecycleController, type PortalLifecycleOptions, type PortalState, type PositionSyncController, type PositionSyncOptions, composeHandlers, computeFloatingPosition, containsWithPortals, createDismissLayer, createPortalLifecycle, createPositionSync, emit, ensureId, ensureItemVisibleInContainer, getDataBool, getDataEnum, getDataNumber, getDataString, getPart, getParts, getRoots, linkLabelledBy, lockScroll, on, portalToBody, restorePortal, setAria, unlockScroll };
|
|
191
|
+
export { type ComputeFloatingPositionInput, type DismissLayerOptions, type FloatingPosition, type PopupAlign, type PopupPlacementOptions, type PopupSide, type PortalLifecycleController, type PortalLifecycleOptions, type PortalState, type PositionSyncController, type PositionSyncOptions, type PresenceLifecycleController, type PresenceLifecycleOptions, composeHandlers, computeFloatingPosition, containsWithPortals, createDismissLayer, createPortalLifecycle, createPositionSync, createPresenceLifecycle, emit, ensureId, ensureItemVisibleInContainer, getDataBool, getDataEnum, getDataNumber, getDataString, getPart, getParts, getRoots, linkLabelledBy, lockScroll, on, portalToBody, restorePortal, setAria, unlockScroll };
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=(e,t)=>e.querySelector(`[data-slot="${t}"]`),t=(e,t)=>[...e.querySelectorAll(`[data-slot="${t}"]`)],n=(e,t)=>[...e.querySelectorAll(`[data-slot="${t}"]`)],r=new WeakMap;function i(e,t,n){if(typeof process<`u`&&process.env?.NODE_ENV===`production`)return;let i=r.get(e);i||(i=new Set,r.set(e,i)),!i.has(t)&&(i.add(t),console.warn(`[@data-slot] ${n}`))}function a(e){let t=`data-${e.replace(/([A-Z])/g,`-$1`).toLowerCase()}`,n=`data-${e}`;return t===n?[t]:[t,n]}function o(e,t){for(let n of a(t))if(e.hasAttribute(n))return e.getAttribute(n);return null}function s(e,t){return a(t).some(t=>e.hasAttribute(t))}const c=new Set([``,`true`,`1`,`yes`]),l=new Set([`false`,`0`,`no`]);function u(e,t){if(!s(e,t))return;let n=o(e,t);if(n===null)return;let r=n.toLowerCase();if(c.has(r))return!0;if(l.has(r))return!1;i(e,t,`Invalid boolean value "${n}" for data-${t}. Expected: true/false/1/0/yes/no or empty.`)}function d(e,t){let n=o(e,t);if(n===null||n===``)return;let r=Number(n);if(Number.isNaN(r)||!Number.isFinite(r)){i(e,t,`Invalid number value "${n}" for data-${t}.`);return}return r}function f(e,t){if(s(e,t))return o(e,t)??void 0}function p(e,t,n){let r=o(e,t);if(r!==null){if(n.includes(r))return r;i(e,t,`Invalid value "${r}" for data-${t}. Expected one of: ${n.join(`, `)}.`)}}const m=new WeakMap,h=Symbol.for(`data-slot.portal-owner`),g=e=>e[h]??m.get(e),_=(e,t)=>{m.set(e,t),e[h]=t},v=e=>{m.delete(e),delete e[h]};function y(e,t){return b(e,t,new Set)}function b(e,t,n){if(!t)return!1;let r=t instanceof Element?t:t.parentElement;if(!r)return!1;if(e.contains(r))return!0;let i=r;for(;i;){let t=g(i);if(t&&!n.has(t)&&(n.add(t),b(e,t,n)))return!0;i=i.parentElement}return!1}function x(e,t,n){if(n.portaled)return;let r=(t.ownerDocument??document)?.body;r&&(n.originalParent=e.parentNode,n.originalNextSibling=e.nextSibling,_(e,t),r.appendChild(e),n.portaled=!0)}function S(e,t){if(!t.portaled)return;v(e);let n=t.originalParent,r=t.originalNextSibling;n&&n.isConnected?r&&r.parentNode===n?n.insertBefore(e,r):n.appendChild(e):e.remove(),t.portaled=!1,t.originalParent=null,t.originalNextSibling=null}let C=0;const w=(e,t)=>e.id||=`${t}-${++C}`,T=(e,t,n)=>{n===null?e.removeAttribute(`aria-${t}`):e.setAttribute(`aria-${t}`,String(n))},E=(e,t,n)=>{t&&e.setAttribute(`aria-labelledby`,w(t,`title`)),n&&e.setAttribute(`aria-describedby`,w(n,`desc`))};function D(e,t,n,r){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}const O=(e,t,n)=>e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:n})),k=(...e)=>t=>{for(let n of e){if(t.defaultPrevented)break;n?.(t)}};let A=0,j=``,M=``;function N(){if(A===0){let e=document.documentElement;j=e.style.overflow,M=e.style.scrollbarGutter,e.style.overflow=`hidden`,e.style.scrollbarGutter=`stable`}A++}function P(){if(A=Math.max(0,A-1),A===0){let e=document.documentElement;e.style.overflow=j,e.style.scrollbarGutter=M}}const F=[`top`,`right`,`bottom`,`left`],I=e=>{let t=window.visualViewport,n=e.viewportWidth??t?.width,r=e.viewportHeight??t?.height;if(n==null||r==null)throw Error(`computeFloatingPosition requires window.visualViewport when viewport dimensions are not provided`);return{x:t?.offsetLeft??0,y:t?.offsetTop??0,width:n,height:r}},L=(e,t,n,r,i,a)=>{let o=0,s=0;return e===`top`?s=n.top-r.height-i:e===`bottom`?s=n.bottom+i:o=e===`left`?n.left-r.width-i:n.right+i,e===`top`||e===`bottom`?o=t===`start`?n.left+a:t===`center`?n.left+n.width/2-r.width/2+a:n.right-r.width-a:s=t===`start`?n.top+a:t===`center`?n.top+n.height/2-r.height/2+a:n.bottom-r.height-a,{x:o,y:s}},R=(e,t,n,r,i)=>{let a=r.x+i,o=r.x+r.width-i,s=r.y+i,c=r.y+r.height-i;return e===`top`?Math.max(0,s-t.y):e===`bottom`?Math.max(0,t.y+n.height-c):e===`left`?Math.max(0,a-t.x):Math.max(0,t.x+n.width-o)},z=(e,t,n)=>n<t?t:Math.min(Math.max(e,t),n);function B(e){let t=I(e),n=e.allowedSides?.length?[...new Set(e.allowedSides)]:[...F],r=n.includes(e.side)?e.side:n[0],i=r,a=L(i,e.align,e.anchorRect,e.contentRect,e.sideOffset,e.alignOffset);if(e.avoidCollisions){let o=[r,...n.filter(e=>e!==r)],s=i,c=a,l=1/0;for(let n of o){let r=L(n,e.align,e.anchorRect,e.contentRect,e.sideOffset,e.alignOffset),i=R(n,r,e.contentRect,t,e.collisionPadding);if(i<=0){s=n,c=r,l=i;break}i<l&&(s=n,c=r,l=i)}i=s,a=c;let u=t.x+e.collisionPadding,d=t.x+t.width-e.contentRect.width-e.collisionPadding,f=t.y+e.collisionPadding,p=t.y+t.height-e.contentRect.height-e.collisionPadding;a.x=z(a.x,u,d),a.y=z(a.y,f,p)}return{x:a.x,y:a.y,side:i,align:e.align}}function V(e,t,n=4){if(t.clientHeight<=0)return;let r=Math.max(0,t.scrollHeight-t.clientHeight);if(r<=0)return;let i=e.getBoundingClientRect(),a=t.getBoundingClientRect(),o=i.top-a.top+t.scrollTop,s=o+i.height,c=t.scrollTop+n,l=t.scrollTop+t.clientHeight-n,u=t.scrollTop;o<c?u=o-n:s>l&&(u=s-t.clientHeight+n),u=Math.min(Math.max(u,0),r),u!==t.scrollTop&&(t.scrollTop=u)}const H=e=>({x:e.x,y:e.y,width:e.width,height:e.height}),U=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,W=e=>{let t=getComputedStyle(e),n=`${t.overflow}${t.overflowX}${t.overflowY}`;return/(auto|scroll|overlay)/.test(n)},G=(e,t)=>{let n=new Set([e]),r=e.parentNode;for(;r;){if(r instanceof Element){W(r)&&n.add(r),r=r.parentNode;continue}if(r instanceof Document){r.scrollingElement&&n.add(r.scrollingElement),n.add(r),r.defaultView&&(n.add(r.defaultView),r.defaultView.visualViewport&&n.add(r.defaultView.visualViewport));break}r=null}return n.add(t),t.visualViewport&&n.add(t.visualViewport),[...n]},K=(e,t,n)=>{let r=null,i=null,a=()=>{i!==null&&(n.clearTimeout(i),i=null),r?.disconnect(),r=null},o=(s=!1,c=1)=>{a();let l=e.getBoundingClientRect();if(s||t(),!l.width||!l.height)return;let u=e.ownerDocument.documentElement,d=Math.floor(l.top),f=Math.floor(u.clientWidth-(l.left+l.width)),p=Math.floor(u.clientHeight-(l.top+l.height)),m=Math.floor(l.left),h=`${-d}px ${-f}px ${-p}px ${-m}px`,g=Math.max(0,Math.min(1,c))||1,_=!0;r=new IntersectionObserver(t=>{let r=t[0]?.intersectionRatio??1;if(r!==g){if(!_){o();return}r?o(!1,r):i=n.setTimeout(()=>{o(!1,1e-7)},1e3)}if(r===1&&!U(H(l),H(e.getBoundingClientRect()))){o();return}_=!1},{rootMargin:h,threshold:g}),r.observe(e)};return o(!0),a};function q(e){let t=e.win??window,n=e.isActive??(()=>!0),r=e.observedElements??[],i=e.ancestorScroll??!0,a=e.ancestorResize??!0,o=e.elementResize??typeof ResizeObserver<`u`,s=e.layoutShift??!1,c=e.animationFrame??!1,l=null,u=null,d=!1,f=null,p=null,m=[],h=()=>{l===null&&(l=t.requestAnimationFrame(()=>{l=null,n()&&e.onUpdate()}))},g=()=>h(),_=t=>{e.ignoreScrollTarget?.(t.target)||h()},v=()=>{let e=new Set,n=r.length?r:[];if(n.length===0)return e.add(t),t.visualViewport&&e.add(t.visualViewport),[...e];for(let r of n)for(let n of G(r,t))e.add(n);return[...e]},y=e=>{let n=new Set([t]);t.visualViewport&&n.add(t.visualViewport);for(let r of e)(r===t||r===t.visualViewport)&&n.add(r);return[...n]};return{start:()=>{if(d)return;d=!0;let e=v(),n=y(e);if(i)for(let t of e)t.addEventListener(`scroll`,_,{passive:!0}),m.push(()=>t.removeEventListener(`scroll`,_));if(a)for(let e of n)e.addEventListener(`resize`,g),m.push(()=>e.removeEventListener(`resize`,g));if(o&&typeof ResizeObserver<`u`){f=new ResizeObserver(g);for(let e of r)f.observe(e)}let l=r[0]??null;if(s&&l&&typeof IntersectionObserver<`u`&&(p=K(l,h,t)),c&&l){let e=H(l.getBoundingClientRect()),n=()=>{if(!d)return;let r=H(l.getBoundingClientRect());U(e,r)||h(),e=r,u=t.requestAnimationFrame(n)};u=t.requestAnimationFrame(n)}},stop:()=>{d&&(d=!1,l!==null&&(t.cancelAnimationFrame(l),l=null),u!==null&&(t.cancelAnimationFrame(u),u=null),m.forEach(e=>e()),m=[],f?.disconnect(),f=null,p?.(),p=null)},update:h}}function J(e){let t=e.root.ownerDocument??document,n=e.isInside??(t=>y(e.root,t)),r=e.closeOnClickOutside??!0,i=e.closeOnEscape??!0,a=e.preventEscapeDefault??!0,o=[];return r&&o.push(D(t,`pointerdown`,t=>{if(!e.isOpen())return;let r=t.target;n(r)||e.onDismiss()})),i&&o.push(D(t,`keydown`,t=>{e.isOpen()&&t.key===`Escape`&&(a&&t.preventDefault(),e.onDismiss())})),()=>{o.forEach(e=>e()),o.length=0}}function Y(e){let t=e.enabled??!0,n=e.state??{originalParent:null,originalNextSibling:null,portaled:!1};return{state:n,mount:()=>{t&&x(e.content,e.root,n)},restore:()=>{t&&S(e.content,n)},cleanup:()=>{t&&S(e.content,n)}}}exports.composeHandlers=k,exports.computeFloatingPosition=B,exports.containsWithPortals=y,exports.createDismissLayer=J,exports.createPortalLifecycle=Y,exports.createPositionSync=q,exports.emit=O,exports.ensureId=w,exports.ensureItemVisibleInContainer=V,exports.getDataBool=u,exports.getDataEnum=p,exports.getDataNumber=d,exports.getDataString=f,exports.getPart=e,exports.getParts=t,exports.getRoots=n,exports.linkLabelledBy=E,exports.lockScroll=N,exports.on=D,exports.portalToBody=x,exports.restorePortal=S,exports.setAria=T,exports.unlockScroll=P;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=(e,t)=>e.querySelector(`[data-slot="${t}"]`),t=(e,t)=>[...e.querySelectorAll(`[data-slot="${t}"]`)],n=(e,t)=>[...e.querySelectorAll(`[data-slot="${t}"]`)],r=new WeakMap;function i(e,t,n){if(typeof process<`u`&&process.env?.NODE_ENV===`production`)return;let i=r.get(e);i||(i=new Set,r.set(e,i)),!i.has(t)&&(i.add(t),console.warn(`[@data-slot] ${n}`))}function a(e){let t=`data-${e.replace(/([A-Z])/g,`-$1`).toLowerCase()}`,n=`data-${e}`;return t===n?[t]:[t,n]}function o(e,t){for(let n of a(t))if(e.hasAttribute(n))return e.getAttribute(n);return null}function s(e,t){return a(t).some(t=>e.hasAttribute(t))}const c=new Set([``,`true`,`1`,`yes`]),l=new Set([`false`,`0`,`no`]);function u(e,t){if(!s(e,t))return;let n=o(e,t);if(n===null)return;let r=n.toLowerCase();if(c.has(r))return!0;if(l.has(r))return!1;i(e,t,`Invalid boolean value "${n}" for data-${t}. Expected: true/false/1/0/yes/no or empty.`)}function d(e,t){let n=o(e,t);if(n===null||n===``)return;let r=Number(n);if(Number.isNaN(r)||!Number.isFinite(r)){i(e,t,`Invalid number value "${n}" for data-${t}.`);return}return r}function f(e,t){if(s(e,t))return o(e,t)??void 0}function p(e,t,n){let r=o(e,t);if(r!==null){if(n.includes(r))return r;i(e,t,`Invalid value "${r}" for data-${t}. Expected one of: ${n.join(`, `)}.`)}}const m=new WeakMap,h=Symbol.for(`data-slot.portal-owner`),g=e=>e[h]??m.get(e),_=(e,t)=>{m.set(e,t),e[h]=t},v=e=>{m.delete(e),delete e[h]};function y(e,t){return b(e,t,new Set)}function b(e,t,n){if(!t)return!1;let r=t instanceof Element?t:t.parentElement;if(!r)return!1;if(e.contains(r))return!0;let i=r;for(;i;){let t=g(i);if(t&&!n.has(t)&&(n.add(t),b(e,t,n)))return!0;i=i.parentElement}return!1}function x(e,t,n){if(n.portaled)return;let r=(t.ownerDocument??document)?.body;r&&(n.originalParent=e.parentNode,n.originalNextSibling=e.nextSibling,_(e,t),r.appendChild(e),n.portaled=!0)}function S(e,t){if(!t.portaled)return;v(e);let n=t.originalParent,r=t.originalNextSibling;n&&n.isConnected?r&&r.parentNode===n?n.insertBefore(e,r):n.appendChild(e):e.remove(),t.portaled=!1,t.originalParent=null,t.originalNextSibling=null}let C=0;const w=(e,t)=>e.id||=`${t}-${++C}`,T=(e,t,n)=>{n===null?e.removeAttribute(`aria-${t}`):e.setAttribute(`aria-${t}`,String(n))},E=(e,t,n)=>{t&&e.setAttribute(`aria-labelledby`,w(t,`title`)),n&&e.setAttribute(`aria-describedby`,w(n,`desc`))};function D(e,t,n,r){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}const O=(e,t,n)=>e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:n})),k=(...e)=>t=>{for(let n of e){if(t.defaultPrevented)break;n?.(t)}};let A=0,j=``,M=``;function N(){if(A===0){let e=document.documentElement;j=e.style.overflow,M=e.style.scrollbarGutter,e.style.overflow=`hidden`,e.style.scrollbarGutter=`stable`}A++}function P(){if(A=Math.max(0,A-1),A===0){let e=document.documentElement;e.style.overflow=j,e.style.scrollbarGutter=M}}const F=[`top`,`right`,`bottom`,`left`],I=e=>{let t=window.visualViewport,n=e.viewportWidth??t?.width,r=e.viewportHeight??t?.height;if(n==null||r==null)throw Error(`computeFloatingPosition requires window.visualViewport when viewport dimensions are not provided`);return{x:t?.offsetLeft??0,y:t?.offsetTop??0,width:n,height:r}},L=(e,t,n,r,i,a)=>{let o=0,s=0;return e===`top`?s=n.top-r.height-i:e===`bottom`?s=n.bottom+i:o=e===`left`?n.left-r.width-i:n.right+i,e===`top`||e===`bottom`?o=t===`start`?n.left+a:t===`center`?n.left+n.width/2-r.width/2+a:n.right-r.width-a:s=t===`start`?n.top+a:t===`center`?n.top+n.height/2-r.height/2+a:n.bottom-r.height-a,{x:o,y:s}},R=(e,t,n,r,i)=>{let a=r.x+i,o=r.x+r.width-i,s=r.y+i,c=r.y+r.height-i;return e===`top`?Math.max(0,s-t.y):e===`bottom`?Math.max(0,t.y+n.height-c):e===`left`?Math.max(0,a-t.x):Math.max(0,t.x+n.width-o)},z=(e,t,n)=>n<t?t:Math.min(Math.max(e,t),n);function B(e){let t=I(e),n=e.allowedSides?.length?[...new Set(e.allowedSides)]:[...F],r=n.includes(e.side)?e.side:n[0],i=r,a=L(i,e.align,e.anchorRect,e.contentRect,e.sideOffset,e.alignOffset);if(e.avoidCollisions){let o=[r,...n.filter(e=>e!==r)],s=i,c=a,l=1/0;for(let n of o){let r=L(n,e.align,e.anchorRect,e.contentRect,e.sideOffset,e.alignOffset),i=R(n,r,e.contentRect,t,e.collisionPadding);if(i<=0){s=n,c=r,l=i;break}i<l&&(s=n,c=r,l=i)}i=s,a=c;let u=t.x+e.collisionPadding,d=t.x+t.width-e.contentRect.width-e.collisionPadding,f=t.y+e.collisionPadding,p=t.y+t.height-e.contentRect.height-e.collisionPadding;a.x=z(a.x,u,d),a.y=z(a.y,f,p)}return{x:a.x,y:a.y,side:i,align:e.align}}function V(e,t,n=4){if(t.clientHeight<=0)return;let r=Math.max(0,t.scrollHeight-t.clientHeight);if(r<=0)return;let i=e.getBoundingClientRect(),a=t.getBoundingClientRect(),o=i.top-a.top+t.scrollTop,s=o+i.height,c=t.scrollTop+n,l=t.scrollTop+t.clientHeight-n,u=t.scrollTop;o<c?u=o-n:s>l&&(u=s-t.clientHeight+n),u=Math.min(Math.max(u,0),r),u!==t.scrollTop&&(t.scrollTop=u)}const H=e=>({x:e.x,y:e.y,width:e.width,height:e.height}),U=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,W=e=>{let t=getComputedStyle(e),n=`${t.overflow}${t.overflowX}${t.overflowY}`;return/(auto|scroll|overlay)/.test(n)},G=(e,t)=>{let n=new Set([e]),r=e.parentNode;for(;r;){if(r instanceof Element){W(r)&&n.add(r),r=r.parentNode;continue}if(r instanceof Document){r.scrollingElement&&n.add(r.scrollingElement),n.add(r),r.defaultView&&(n.add(r.defaultView),r.defaultView.visualViewport&&n.add(r.defaultView.visualViewport));break}r=null}return n.add(t),t.visualViewport&&n.add(t.visualViewport),[...n]},K=(e,t,n)=>{let r=null,i=null,a=()=>{i!==null&&(n.clearTimeout(i),i=null),r?.disconnect(),r=null},o=(s=!1,c=1)=>{a();let l=e.getBoundingClientRect();if(s||t(),!l.width||!l.height)return;let u=e.ownerDocument.documentElement,d=Math.floor(l.top),f=Math.floor(u.clientWidth-(l.left+l.width)),p=Math.floor(u.clientHeight-(l.top+l.height)),m=Math.floor(l.left),h=`${-d}px ${-f}px ${-p}px ${-m}px`,g=Math.max(0,Math.min(1,c))||1,_=!0;r=new IntersectionObserver(t=>{let r=t[0]?.intersectionRatio??1;if(r!==g){if(!_){o();return}r?o(!1,r):i=n.setTimeout(()=>{o(!1,1e-7)},1e3)}if(r===1&&!U(H(l),H(e.getBoundingClientRect()))){o();return}_=!1},{rootMargin:h,threshold:g}),r.observe(e)};return o(!0),a};function q(e){let t=e.win??window,n=e.isActive??(()=>!0),r=e.observedElements??[],i=e.ancestorScroll??!0,a=e.ancestorResize??!0,o=e.elementResize??typeof ResizeObserver<`u`,s=e.layoutShift??!1,c=e.animationFrame??!1,l=null,u=null,d=!1,f=null,p=null,m=[],h=()=>{l===null&&(l=t.requestAnimationFrame(()=>{l=null,n()&&e.onUpdate()}))},g=()=>h(),_=t=>{e.ignoreScrollTarget?.(t.target)||h()},v=()=>{let e=new Set,n=r.length?r:[];if(n.length===0)return e.add(t),t.visualViewport&&e.add(t.visualViewport),[...e];for(let r of n)for(let n of G(r,t))e.add(n);return[...e]},y=e=>{let n=new Set([t]);t.visualViewport&&n.add(t.visualViewport);for(let r of e)(r===t||r===t.visualViewport)&&n.add(r);return[...n]};return{start:()=>{if(d)return;d=!0;let e=v(),n=y(e);if(i)for(let t of e)t.addEventListener(`scroll`,_,{passive:!0}),m.push(()=>t.removeEventListener(`scroll`,_));if(a)for(let e of n)e.addEventListener(`resize`,g),m.push(()=>e.removeEventListener(`resize`,g));if(o&&typeof ResizeObserver<`u`){f=new ResizeObserver(g);for(let e of r)f.observe(e)}let l=r[0]??null;if(s&&l&&typeof IntersectionObserver<`u`&&(p=K(l,h,t)),c&&l){let e=H(l.getBoundingClientRect()),n=()=>{if(!d)return;let r=H(l.getBoundingClientRect());U(e,r)||h(),e=r,u=t.requestAnimationFrame(n)};u=t.requestAnimationFrame(n)}},stop:()=>{d&&(d=!1,l!==null&&(t.cancelAnimationFrame(l),l=null),u!==null&&(t.cancelAnimationFrame(u),u=null),m.forEach(e=>e()),m=[],f?.disconnect(),f=null,p?.(),p=null)},update:h}}function J(e){let t=e.root.ownerDocument??document,n=e.isInside??(t=>y(e.root,t)),r=e.closeOnClickOutside??!0,i=e.closeOnEscape??!0,a=e.preventEscapeDefault??!0,o=[];return r&&o.push(D(t,`pointerdown`,t=>{if(!e.isOpen())return;let r=t.target;n(r)||e.onDismiss()})),i&&o.push(D(t,`keydown`,t=>{e.isOpen()&&t.key===`Escape`&&(a&&t.preventDefault(),e.onDismiss())})),()=>{o.forEach(e=>e()),o.length=0}}function Y(e){let t=e.enabled??!0,n=e.wrapperSlot,r=e.state??{originalParent:null,originalNextSibling:null,portaled:!1},i=e.root.ownerDocument??document,a=null,o=()=>{if(a)return a;let e=i.createElement(`div`);return n&&e.setAttribute(`data-slot`,n),a=e,e},s=()=>{if(r.portaled)return;let t=e.content.parentNode;if(!t)return;let n=o();t.insertBefore(n,e.content),n.appendChild(e.content),x(n,e.root,r)},c=()=>{if(!r.portaled)return;let t=a;if(!t)return;S(t,r);let n=t.parentNode;n&&n.isConnected?(n.insertBefore(e.content,t),t.remove()):e.content.remove()};return{state:r,get container(){return t&&n&&r.portaled&&a?a:e.content},mount:()=>{t&&(n?s():x(e.content,e.root,r))},restore:()=>{t&&(n?c():S(e.content,r))},cleanup:()=>{t&&(n?c():S(e.content,r))}}}const X=e=>{let t=e.trim().toLowerCase();if(!t)return 0;if(t.endsWith(`ms`)){let e=Number(t.slice(0,-2).trim());return Number.isFinite(e)?e:0}if(t.endsWith(`s`)){let e=Number(t.slice(0,-1).trim());return Number.isFinite(e)?e*1e3:0}let n=Number(t);return Number.isFinite(n)?n:0},Z=(e,t)=>{let n=e.split(`,`),r=t.split(`,`),i=Math.max(n.length,r.length),a=0;for(let e=0;e<i;e++){let t=X(n[e]??n[n.length-1]??`0`),i=X(r[e]??r[r.length-1]??`0`);a=Math.max(a,t+i)}return a},Q=e=>{let t=getComputedStyle(e),n=Z(t.transitionDuration,t.transitionDelay),r=Z(t.animationDuration,t.animationDelay);return Math.max(n,r)};function $(e){let t=e.win??window,n=!1,r=null,i=null,a=null,o=[],s=()=>{i!==null&&(t.cancelAnimationFrame(i),i=null),a!==null&&(t.clearTimeout(a),a=null),o.forEach(e=>e()),o=[]},c=()=>{s(),n=!1,e.element.removeAttribute(`data-ending-style`)},l=()=>{r!==null&&(t.cancelAnimationFrame(r),r=null),e.element.removeAttribute(`data-starting-style`)},u=()=>{n&&(s(),n=!1,e.element.removeAttribute(`data-ending-style`),e.onExitComplete())};return{get isExiting(){return n},enter:()=>{c(),l(),e.element.setAttribute(`data-starting-style`,``),r=t.requestAnimationFrame(()=>{r=null,e.element.removeAttribute(`data-starting-style`)})},exit:()=>{c(),l(),n=!0,e.element.setAttribute(`data-ending-style`,``);let r=Q(e.element);if(r>0){let n=t=>{t.target===e.element&&u()};e.element.addEventListener(`transitionend`,n),e.element.addEventListener(`animationend`,n),o.push(()=>e.element.removeEventListener(`transitionend`,n)),o.push(()=>e.element.removeEventListener(`animationend`,n)),a=t.setTimeout(()=>{a=null,u()},Math.ceil(r)+50)}else i=t.requestAnimationFrame(()=>{i=null,u()})},cleanup:()=>{c(),l()}}}exports.composeHandlers=k,exports.computeFloatingPosition=B,exports.containsWithPortals=y,exports.createDismissLayer=J,exports.createPortalLifecycle=Y,exports.createPositionSync=q,exports.createPresenceLifecycle=$,exports.emit=O,exports.ensureId=w,exports.ensureItemVisibleInContainer=V,exports.getDataBool=u,exports.getDataEnum=p,exports.getDataNumber=d,exports.getDataString=f,exports.getPart=e,exports.getParts=t,exports.getRoots=n,exports.linkLabelledBy=E,exports.lockScroll=N,exports.on=D,exports.portalToBody=x,exports.restorePortal=S,exports.setAria=T,exports.unlockScroll=P;
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=(e,t)=>e.querySelector(`[data-slot="${t}"]`),t=(e,t)=>[...e.querySelectorAll(`[data-slot="${t}"]`)],n=(e,t)=>[...e.querySelectorAll(`[data-slot="${t}"]`)],r=new WeakMap;function i(e,t,n){if(typeof process<`u`&&process.env?.NODE_ENV===`production`)return;let i=r.get(e);i||(i=new Set,r.set(e,i)),!i.has(t)&&(i.add(t),console.warn(`[@data-slot] ${n}`))}function a(e){let t=`data-${e.replace(/([A-Z])/g,`-$1`).toLowerCase()}`,n=`data-${e}`;return t===n?[t]:[t,n]}function o(e,t){for(let n of a(t))if(e.hasAttribute(n))return e.getAttribute(n);return null}function s(e,t){return a(t).some(t=>e.hasAttribute(t))}const c=new Set([``,`true`,`1`,`yes`]),l=new Set([`false`,`0`,`no`]);function u(e,t){if(!s(e,t))return;let n=o(e,t);if(n===null)return;let r=n.toLowerCase();if(c.has(r))return!0;if(l.has(r))return!1;i(e,t,`Invalid boolean value "${n}" for data-${t}. Expected: true/false/1/0/yes/no or empty.`)}function d(e,t){let n=o(e,t);if(n===null||n===``)return;let r=Number(n);if(Number.isNaN(r)||!Number.isFinite(r)){i(e,t,`Invalid number value "${n}" for data-${t}.`);return}return r}function f(e,t){if(s(e,t))return o(e,t)??void 0}function p(e,t,n){let r=o(e,t);if(r!==null){if(n.includes(r))return r;i(e,t,`Invalid value "${r}" for data-${t}. Expected one of: ${n.join(`, `)}.`)}}const m=new WeakMap,h=Symbol.for(`data-slot.portal-owner`),g=e=>e[h]??m.get(e),_=(e,t)=>{m.set(e,t),e[h]=t},v=e=>{m.delete(e),delete e[h]};function y(e,t){return b(e,t,new Set)}function b(e,t,n){if(!t)return!1;let r=t instanceof Element?t:t.parentElement;if(!r)return!1;if(e.contains(r))return!0;let i=r;for(;i;){let t=g(i);if(t&&!n.has(t)&&(n.add(t),b(e,t,n)))return!0;i=i.parentElement}return!1}function x(e,t,n){if(n.portaled)return;let r=(t.ownerDocument??document)?.body;r&&(n.originalParent=e.parentNode,n.originalNextSibling=e.nextSibling,_(e,t),r.appendChild(e),n.portaled=!0)}function S(e,t){if(!t.portaled)return;v(e);let n=t.originalParent,r=t.originalNextSibling;n&&n.isConnected?r&&r.parentNode===n?n.insertBefore(e,r):n.appendChild(e):e.remove(),t.portaled=!1,t.originalParent=null,t.originalNextSibling=null}let C=0;const w=(e,t)=>e.id||=`${t}-${++C}`,T=(e,t,n)=>{n===null?e.removeAttribute(`aria-${t}`):e.setAttribute(`aria-${t}`,String(n))},E=(e,t,n)=>{t&&e.setAttribute(`aria-labelledby`,w(t,`title`)),n&&e.setAttribute(`aria-describedby`,w(n,`desc`))};function D(e,t,n,r){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}const O=(e,t,n)=>e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:n})),k=(...e)=>t=>{for(let n of e){if(t.defaultPrevented)break;n?.(t)}};let A=0,j=``,M=``;function N(){if(A===0){let e=document.documentElement;j=e.style.overflow,M=e.style.scrollbarGutter,e.style.overflow=`hidden`,e.style.scrollbarGutter=`stable`}A++}function P(){if(A=Math.max(0,A-1),A===0){let e=document.documentElement;e.style.overflow=j,e.style.scrollbarGutter=M}}const F=[`top`,`right`,`bottom`,`left`],I=e=>{let t=window.visualViewport,n=e.viewportWidth??t?.width,r=e.viewportHeight??t?.height;if(n==null||r==null)throw Error(`computeFloatingPosition requires window.visualViewport when viewport dimensions are not provided`);return{x:t?.offsetLeft??0,y:t?.offsetTop??0,width:n,height:r}},L=(e,t,n,r,i,a)=>{let o=0,s=0;return e===`top`?s=n.top-r.height-i:e===`bottom`?s=n.bottom+i:o=e===`left`?n.left-r.width-i:n.right+i,e===`top`||e===`bottom`?o=t===`start`?n.left+a:t===`center`?n.left+n.width/2-r.width/2+a:n.right-r.width-a:s=t===`start`?n.top+a:t===`center`?n.top+n.height/2-r.height/2+a:n.bottom-r.height-a,{x:o,y:s}},R=(e,t,n,r,i)=>{let a=r.x+i,o=r.x+r.width-i,s=r.y+i,c=r.y+r.height-i;return e===`top`?Math.max(0,s-t.y):e===`bottom`?Math.max(0,t.y+n.height-c):e===`left`?Math.max(0,a-t.x):Math.max(0,t.x+n.width-o)},z=(e,t,n)=>n<t?t:Math.min(Math.max(e,t),n);function B(e){let t=I(e),n=e.allowedSides?.length?[...new Set(e.allowedSides)]:[...F],r=n.includes(e.side)?e.side:n[0],i=r,a=L(i,e.align,e.anchorRect,e.contentRect,e.sideOffset,e.alignOffset);if(e.avoidCollisions){let o=[r,...n.filter(e=>e!==r)],s=i,c=a,l=1/0;for(let n of o){let r=L(n,e.align,e.anchorRect,e.contentRect,e.sideOffset,e.alignOffset),i=R(n,r,e.contentRect,t,e.collisionPadding);if(i<=0){s=n,c=r,l=i;break}i<l&&(s=n,c=r,l=i)}i=s,a=c;let u=t.x+e.collisionPadding,d=t.x+t.width-e.contentRect.width-e.collisionPadding,f=t.y+e.collisionPadding,p=t.y+t.height-e.contentRect.height-e.collisionPadding;a.x=z(a.x,u,d),a.y=z(a.y,f,p)}return{x:a.x,y:a.y,side:i,align:e.align}}function V(e,t,n=4){if(t.clientHeight<=0)return;let r=Math.max(0,t.scrollHeight-t.clientHeight);if(r<=0)return;let i=e.getBoundingClientRect(),a=t.getBoundingClientRect(),o=i.top-a.top+t.scrollTop,s=o+i.height,c=t.scrollTop+n,l=t.scrollTop+t.clientHeight-n,u=t.scrollTop;o<c?u=o-n:s>l&&(u=s-t.clientHeight+n),u=Math.min(Math.max(u,0),r),u!==t.scrollTop&&(t.scrollTop=u)}const H=e=>({x:e.x,y:e.y,width:e.width,height:e.height}),U=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,W=e=>{let t=getComputedStyle(e),n=`${t.overflow}${t.overflowX}${t.overflowY}`;return/(auto|scroll|overlay)/.test(n)},G=(e,t)=>{let n=new Set([e]),r=e.parentNode;for(;r;){if(r instanceof Element){W(r)&&n.add(r),r=r.parentNode;continue}if(r instanceof Document){r.scrollingElement&&n.add(r.scrollingElement),n.add(r),r.defaultView&&(n.add(r.defaultView),r.defaultView.visualViewport&&n.add(r.defaultView.visualViewport));break}r=null}return n.add(t),t.visualViewport&&n.add(t.visualViewport),[...n]},K=(e,t,n)=>{let r=null,i=null,a=()=>{i!==null&&(n.clearTimeout(i),i=null),r?.disconnect(),r=null},o=(s=!1,c=1)=>{a();let l=e.getBoundingClientRect();if(s||t(),!l.width||!l.height)return;let u=e.ownerDocument.documentElement,d=Math.floor(l.top),f=Math.floor(u.clientWidth-(l.left+l.width)),p=Math.floor(u.clientHeight-(l.top+l.height)),m=Math.floor(l.left),h=`${-d}px ${-f}px ${-p}px ${-m}px`,g=Math.max(0,Math.min(1,c))||1,_=!0;r=new IntersectionObserver(t=>{let r=t[0]?.intersectionRatio??1;if(r!==g){if(!_){o();return}r?o(!1,r):i=n.setTimeout(()=>{o(!1,1e-7)},1e3)}if(r===1&&!U(H(l),H(e.getBoundingClientRect()))){o();return}_=!1},{rootMargin:h,threshold:g}),r.observe(e)};return o(!0),a};function q(e){let t=e.win??window,n=e.isActive??(()=>!0),r=e.observedElements??[],i=e.ancestorScroll??!0,a=e.ancestorResize??!0,o=e.elementResize??typeof ResizeObserver<`u`,s=e.layoutShift??!1,c=e.animationFrame??!1,l=null,u=null,d=!1,f=null,p=null,m=[],h=()=>{l===null&&(l=t.requestAnimationFrame(()=>{l=null,n()&&e.onUpdate()}))},g=()=>h(),_=t=>{e.ignoreScrollTarget?.(t.target)||h()},v=()=>{let e=new Set,n=r.length?r:[];if(n.length===0)return e.add(t),t.visualViewport&&e.add(t.visualViewport),[...e];for(let r of n)for(let n of G(r,t))e.add(n);return[...e]},y=e=>{let n=new Set([t]);t.visualViewport&&n.add(t.visualViewport);for(let r of e)(r===t||r===t.visualViewport)&&n.add(r);return[...n]};return{start:()=>{if(d)return;d=!0;let e=v(),n=y(e);if(i)for(let t of e)t.addEventListener(`scroll`,_,{passive:!0}),m.push(()=>t.removeEventListener(`scroll`,_));if(a)for(let e of n)e.addEventListener(`resize`,g),m.push(()=>e.removeEventListener(`resize`,g));if(o&&typeof ResizeObserver<`u`){f=new ResizeObserver(g);for(let e of r)f.observe(e)}let l=r[0]??null;if(s&&l&&typeof IntersectionObserver<`u`&&(p=K(l,h,t)),c&&l){let e=H(l.getBoundingClientRect()),n=()=>{if(!d)return;let r=H(l.getBoundingClientRect());U(e,r)||h(),e=r,u=t.requestAnimationFrame(n)};u=t.requestAnimationFrame(n)}},stop:()=>{d&&(d=!1,l!==null&&(t.cancelAnimationFrame(l),l=null),u!==null&&(t.cancelAnimationFrame(u),u=null),m.forEach(e=>e()),m=[],f?.disconnect(),f=null,p?.(),p=null)},update:h}}function J(e){let t=e.root.ownerDocument??document,n=e.isInside??(t=>y(e.root,t)),r=e.closeOnClickOutside??!0,i=e.closeOnEscape??!0,a=e.preventEscapeDefault??!0,o=[];return r&&o.push(D(t,`pointerdown`,t=>{if(!e.isOpen())return;let r=t.target;n(r)||e.onDismiss()})),i&&o.push(D(t,`keydown`,t=>{e.isOpen()&&t.key===`Escape`&&(a&&t.preventDefault(),e.onDismiss())})),()=>{o.forEach(e=>e()),o.length=0}}function Y(e){let t=e.enabled??!0,n=e.state??{originalParent:null,originalNextSibling:null,portaled:!1};return{state:n,mount:()=>{t&&x(e.content,e.root,n)},restore:()=>{t&&S(e.content,n)},cleanup:()=>{t&&S(e.content,n)}}}export{k as composeHandlers,B as computeFloatingPosition,y as containsWithPortals,J as createDismissLayer,Y as createPortalLifecycle,q as createPositionSync,O as emit,w as ensureId,V as ensureItemVisibleInContainer,u as getDataBool,p as getDataEnum,d as getDataNumber,f as getDataString,e as getPart,t as getParts,n as getRoots,E as linkLabelledBy,N as lockScroll,D as on,x as portalToBody,S as restorePortal,T as setAria,P as unlockScroll};
|
|
1
|
+
const e=(e,t)=>e.querySelector(`[data-slot="${t}"]`),t=(e,t)=>[...e.querySelectorAll(`[data-slot="${t}"]`)],n=(e,t)=>[...e.querySelectorAll(`[data-slot="${t}"]`)],r=new WeakMap;function i(e,t,n){if(typeof process<`u`&&process.env?.NODE_ENV===`production`)return;let i=r.get(e);i||(i=new Set,r.set(e,i)),!i.has(t)&&(i.add(t),console.warn(`[@data-slot] ${n}`))}function a(e){let t=`data-${e.replace(/([A-Z])/g,`-$1`).toLowerCase()}`,n=`data-${e}`;return t===n?[t]:[t,n]}function o(e,t){for(let n of a(t))if(e.hasAttribute(n))return e.getAttribute(n);return null}function s(e,t){return a(t).some(t=>e.hasAttribute(t))}const c=new Set([``,`true`,`1`,`yes`]),l=new Set([`false`,`0`,`no`]);function u(e,t){if(!s(e,t))return;let n=o(e,t);if(n===null)return;let r=n.toLowerCase();if(c.has(r))return!0;if(l.has(r))return!1;i(e,t,`Invalid boolean value "${n}" for data-${t}. Expected: true/false/1/0/yes/no or empty.`)}function d(e,t){let n=o(e,t);if(n===null||n===``)return;let r=Number(n);if(Number.isNaN(r)||!Number.isFinite(r)){i(e,t,`Invalid number value "${n}" for data-${t}.`);return}return r}function f(e,t){if(s(e,t))return o(e,t)??void 0}function p(e,t,n){let r=o(e,t);if(r!==null){if(n.includes(r))return r;i(e,t,`Invalid value "${r}" for data-${t}. Expected one of: ${n.join(`, `)}.`)}}const m=new WeakMap,h=Symbol.for(`data-slot.portal-owner`),g=e=>e[h]??m.get(e),_=(e,t)=>{m.set(e,t),e[h]=t},v=e=>{m.delete(e),delete e[h]};function y(e,t){return b(e,t,new Set)}function b(e,t,n){if(!t)return!1;let r=t instanceof Element?t:t.parentElement;if(!r)return!1;if(e.contains(r))return!0;let i=r;for(;i;){let t=g(i);if(t&&!n.has(t)&&(n.add(t),b(e,t,n)))return!0;i=i.parentElement}return!1}function x(e,t,n){if(n.portaled)return;let r=(t.ownerDocument??document)?.body;r&&(n.originalParent=e.parentNode,n.originalNextSibling=e.nextSibling,_(e,t),r.appendChild(e),n.portaled=!0)}function S(e,t){if(!t.portaled)return;v(e);let n=t.originalParent,r=t.originalNextSibling;n&&n.isConnected?r&&r.parentNode===n?n.insertBefore(e,r):n.appendChild(e):e.remove(),t.portaled=!1,t.originalParent=null,t.originalNextSibling=null}let C=0;const w=(e,t)=>e.id||=`${t}-${++C}`,T=(e,t,n)=>{n===null?e.removeAttribute(`aria-${t}`):e.setAttribute(`aria-${t}`,String(n))},E=(e,t,n)=>{t&&e.setAttribute(`aria-labelledby`,w(t,`title`)),n&&e.setAttribute(`aria-describedby`,w(n,`desc`))};function D(e,t,n,r){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}const O=(e,t,n)=>e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:n})),k=(...e)=>t=>{for(let n of e){if(t.defaultPrevented)break;n?.(t)}};let A=0,j=``,M=``;function N(){if(A===0){let e=document.documentElement;j=e.style.overflow,M=e.style.scrollbarGutter,e.style.overflow=`hidden`,e.style.scrollbarGutter=`stable`}A++}function P(){if(A=Math.max(0,A-1),A===0){let e=document.documentElement;e.style.overflow=j,e.style.scrollbarGutter=M}}const F=[`top`,`right`,`bottom`,`left`],I=e=>{let t=window.visualViewport,n=e.viewportWidth??t?.width,r=e.viewportHeight??t?.height;if(n==null||r==null)throw Error(`computeFloatingPosition requires window.visualViewport when viewport dimensions are not provided`);return{x:t?.offsetLeft??0,y:t?.offsetTop??0,width:n,height:r}},L=(e,t,n,r,i,a)=>{let o=0,s=0;return e===`top`?s=n.top-r.height-i:e===`bottom`?s=n.bottom+i:o=e===`left`?n.left-r.width-i:n.right+i,e===`top`||e===`bottom`?o=t===`start`?n.left+a:t===`center`?n.left+n.width/2-r.width/2+a:n.right-r.width-a:s=t===`start`?n.top+a:t===`center`?n.top+n.height/2-r.height/2+a:n.bottom-r.height-a,{x:o,y:s}},R=(e,t,n,r,i)=>{let a=r.x+i,o=r.x+r.width-i,s=r.y+i,c=r.y+r.height-i;return e===`top`?Math.max(0,s-t.y):e===`bottom`?Math.max(0,t.y+n.height-c):e===`left`?Math.max(0,a-t.x):Math.max(0,t.x+n.width-o)},z=(e,t,n)=>n<t?t:Math.min(Math.max(e,t),n);function B(e){let t=I(e),n=e.allowedSides?.length?[...new Set(e.allowedSides)]:[...F],r=n.includes(e.side)?e.side:n[0],i=r,a=L(i,e.align,e.anchorRect,e.contentRect,e.sideOffset,e.alignOffset);if(e.avoidCollisions){let o=[r,...n.filter(e=>e!==r)],s=i,c=a,l=1/0;for(let n of o){let r=L(n,e.align,e.anchorRect,e.contentRect,e.sideOffset,e.alignOffset),i=R(n,r,e.contentRect,t,e.collisionPadding);if(i<=0){s=n,c=r,l=i;break}i<l&&(s=n,c=r,l=i)}i=s,a=c;let u=t.x+e.collisionPadding,d=t.x+t.width-e.contentRect.width-e.collisionPadding,f=t.y+e.collisionPadding,p=t.y+t.height-e.contentRect.height-e.collisionPadding;a.x=z(a.x,u,d),a.y=z(a.y,f,p)}return{x:a.x,y:a.y,side:i,align:e.align}}function V(e,t,n=4){if(t.clientHeight<=0)return;let r=Math.max(0,t.scrollHeight-t.clientHeight);if(r<=0)return;let i=e.getBoundingClientRect(),a=t.getBoundingClientRect(),o=i.top-a.top+t.scrollTop,s=o+i.height,c=t.scrollTop+n,l=t.scrollTop+t.clientHeight-n,u=t.scrollTop;o<c?u=o-n:s>l&&(u=s-t.clientHeight+n),u=Math.min(Math.max(u,0),r),u!==t.scrollTop&&(t.scrollTop=u)}const H=e=>({x:e.x,y:e.y,width:e.width,height:e.height}),U=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,W=e=>{let t=getComputedStyle(e),n=`${t.overflow}${t.overflowX}${t.overflowY}`;return/(auto|scroll|overlay)/.test(n)},G=(e,t)=>{let n=new Set([e]),r=e.parentNode;for(;r;){if(r instanceof Element){W(r)&&n.add(r),r=r.parentNode;continue}if(r instanceof Document){r.scrollingElement&&n.add(r.scrollingElement),n.add(r),r.defaultView&&(n.add(r.defaultView),r.defaultView.visualViewport&&n.add(r.defaultView.visualViewport));break}r=null}return n.add(t),t.visualViewport&&n.add(t.visualViewport),[...n]},K=(e,t,n)=>{let r=null,i=null,a=()=>{i!==null&&(n.clearTimeout(i),i=null),r?.disconnect(),r=null},o=(s=!1,c=1)=>{a();let l=e.getBoundingClientRect();if(s||t(),!l.width||!l.height)return;let u=e.ownerDocument.documentElement,d=Math.floor(l.top),f=Math.floor(u.clientWidth-(l.left+l.width)),p=Math.floor(u.clientHeight-(l.top+l.height)),m=Math.floor(l.left),h=`${-d}px ${-f}px ${-p}px ${-m}px`,g=Math.max(0,Math.min(1,c))||1,_=!0;r=new IntersectionObserver(t=>{let r=t[0]?.intersectionRatio??1;if(r!==g){if(!_){o();return}r?o(!1,r):i=n.setTimeout(()=>{o(!1,1e-7)},1e3)}if(r===1&&!U(H(l),H(e.getBoundingClientRect()))){o();return}_=!1},{rootMargin:h,threshold:g}),r.observe(e)};return o(!0),a};function q(e){let t=e.win??window,n=e.isActive??(()=>!0),r=e.observedElements??[],i=e.ancestorScroll??!0,a=e.ancestorResize??!0,o=e.elementResize??typeof ResizeObserver<`u`,s=e.layoutShift??!1,c=e.animationFrame??!1,l=null,u=null,d=!1,f=null,p=null,m=[],h=()=>{l===null&&(l=t.requestAnimationFrame(()=>{l=null,n()&&e.onUpdate()}))},g=()=>h(),_=t=>{e.ignoreScrollTarget?.(t.target)||h()},v=()=>{let e=new Set,n=r.length?r:[];if(n.length===0)return e.add(t),t.visualViewport&&e.add(t.visualViewport),[...e];for(let r of n)for(let n of G(r,t))e.add(n);return[...e]},y=e=>{let n=new Set([t]);t.visualViewport&&n.add(t.visualViewport);for(let r of e)(r===t||r===t.visualViewport)&&n.add(r);return[...n]};return{start:()=>{if(d)return;d=!0;let e=v(),n=y(e);if(i)for(let t of e)t.addEventListener(`scroll`,_,{passive:!0}),m.push(()=>t.removeEventListener(`scroll`,_));if(a)for(let e of n)e.addEventListener(`resize`,g),m.push(()=>e.removeEventListener(`resize`,g));if(o&&typeof ResizeObserver<`u`){f=new ResizeObserver(g);for(let e of r)f.observe(e)}let l=r[0]??null;if(s&&l&&typeof IntersectionObserver<`u`&&(p=K(l,h,t)),c&&l){let e=H(l.getBoundingClientRect()),n=()=>{if(!d)return;let r=H(l.getBoundingClientRect());U(e,r)||h(),e=r,u=t.requestAnimationFrame(n)};u=t.requestAnimationFrame(n)}},stop:()=>{d&&(d=!1,l!==null&&(t.cancelAnimationFrame(l),l=null),u!==null&&(t.cancelAnimationFrame(u),u=null),m.forEach(e=>e()),m=[],f?.disconnect(),f=null,p?.(),p=null)},update:h}}function J(e){let t=e.root.ownerDocument??document,n=e.isInside??(t=>y(e.root,t)),r=e.closeOnClickOutside??!0,i=e.closeOnEscape??!0,a=e.preventEscapeDefault??!0,o=[];return r&&o.push(D(t,`pointerdown`,t=>{if(!e.isOpen())return;let r=t.target;n(r)||e.onDismiss()})),i&&o.push(D(t,`keydown`,t=>{e.isOpen()&&t.key===`Escape`&&(a&&t.preventDefault(),e.onDismiss())})),()=>{o.forEach(e=>e()),o.length=0}}function Y(e){let t=e.enabled??!0,n=e.wrapperSlot,r=e.state??{originalParent:null,originalNextSibling:null,portaled:!1},i=e.root.ownerDocument??document,a=null,o=()=>{if(a)return a;let e=i.createElement(`div`);return n&&e.setAttribute(`data-slot`,n),a=e,e},s=()=>{if(r.portaled)return;let t=e.content.parentNode;if(!t)return;let n=o();t.insertBefore(n,e.content),n.appendChild(e.content),x(n,e.root,r)},c=()=>{if(!r.portaled)return;let t=a;if(!t)return;S(t,r);let n=t.parentNode;n&&n.isConnected?(n.insertBefore(e.content,t),t.remove()):e.content.remove()};return{state:r,get container(){return t&&n&&r.portaled&&a?a:e.content},mount:()=>{t&&(n?s():x(e.content,e.root,r))},restore:()=>{t&&(n?c():S(e.content,r))},cleanup:()=>{t&&(n?c():S(e.content,r))}}}const X=e=>{let t=e.trim().toLowerCase();if(!t)return 0;if(t.endsWith(`ms`)){let e=Number(t.slice(0,-2).trim());return Number.isFinite(e)?e:0}if(t.endsWith(`s`)){let e=Number(t.slice(0,-1).trim());return Number.isFinite(e)?e*1e3:0}let n=Number(t);return Number.isFinite(n)?n:0},Z=(e,t)=>{let n=e.split(`,`),r=t.split(`,`),i=Math.max(n.length,r.length),a=0;for(let e=0;e<i;e++){let t=X(n[e]??n[n.length-1]??`0`),i=X(r[e]??r[r.length-1]??`0`);a=Math.max(a,t+i)}return a},Q=e=>{let t=getComputedStyle(e),n=Z(t.transitionDuration,t.transitionDelay),r=Z(t.animationDuration,t.animationDelay);return Math.max(n,r)};function $(e){let t=e.win??window,n=!1,r=null,i=null,a=null,o=[],s=()=>{i!==null&&(t.cancelAnimationFrame(i),i=null),a!==null&&(t.clearTimeout(a),a=null),o.forEach(e=>e()),o=[]},c=()=>{s(),n=!1,e.element.removeAttribute(`data-ending-style`)},l=()=>{r!==null&&(t.cancelAnimationFrame(r),r=null),e.element.removeAttribute(`data-starting-style`)},u=()=>{n&&(s(),n=!1,e.element.removeAttribute(`data-ending-style`),e.onExitComplete())};return{get isExiting(){return n},enter:()=>{c(),l(),e.element.setAttribute(`data-starting-style`,``),r=t.requestAnimationFrame(()=>{r=null,e.element.removeAttribute(`data-starting-style`)})},exit:()=>{c(),l(),n=!0,e.element.setAttribute(`data-ending-style`,``);let r=Q(e.element);if(r>0){let n=t=>{t.target===e.element&&u()};e.element.addEventListener(`transitionend`,n),e.element.addEventListener(`animationend`,n),o.push(()=>e.element.removeEventListener(`transitionend`,n)),o.push(()=>e.element.removeEventListener(`animationend`,n)),a=t.setTimeout(()=>{a=null,u()},Math.ceil(r)+50)}else i=t.requestAnimationFrame(()=>{i=null,u()})},cleanup:()=>{c(),l()}}}export{k as composeHandlers,B as computeFloatingPosition,y as containsWithPortals,J as createDismissLayer,Y as createPortalLifecycle,q as createPositionSync,$ as createPresenceLifecycle,O as emit,w as ensureId,V as ensureItemVisibleInContainer,u as getDataBool,p as getDataEnum,d as getDataNumber,f as getDataString,e as getPart,t as getParts,n as getRoots,E as linkLabelledBy,N as lockScroll,D as on,x as portalToBody,S as restorePortal,T as setAria,P as unlockScroll};
|