@vielzeug/orbit 1.0.5 → 1.1.1
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/auto-update.cjs +1 -1
- package/dist/auto-update.cjs.map +1 -1
- package/dist/auto-update.d.ts.map +1 -1
- package/dist/auto-update.js +1 -1
- package/dist/auto-update.js.map +1 -1
- package/dist/containing-block.cjs +2 -0
- package/dist/containing-block.cjs.map +1 -0
- package/dist/containing-block.d.ts +28 -0
- package/dist/containing-block.d.ts.map +1 -0
- package/dist/containing-block.js +2 -0
- package/dist/containing-block.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/orbit.cjs +1 -1
- package/dist/orbit.cjs.map +1 -1
- package/dist/orbit.iife.js +1 -1
- package/dist/orbit.iife.js.map +1 -1
- package/dist/orbit.js +1 -1
- package/dist/orbit.js.map +1 -1
- package/dist/overflow.cjs +1 -1
- package/dist/overflow.cjs.map +1 -1
- package/dist/overflow.d.ts +19 -0
- package/dist/overflow.d.ts.map +1 -1
- package/dist/overflow.js +1 -1
- package/dist/overflow.js.map +1 -1
- package/dist/utils.cjs +1 -1
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.js +1 -1
- package/dist/utils.js.map +1 -1
- package/package.json +2 -2
package/dist/auto-update.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("./utils.cjs");let t=require("@vielzeug/arsenal");function n(
|
|
1
|
+
const e=require("./utils.cjs");let t=require("@vielzeug/arsenal");function n(t){let n=[],r=e.flatTreeParent(t);for(;r;){let t=getComputedStyle(r),i=t.overflow+t.overflowX+t.overflowY;/auto|scroll|overlay/.test(i)&&n.push(r),r=e.flatTreeParent(r)}return n}function r(r,i,a,{animationFrame:o=!1,observeAncestors:s=!0,observeFloating:c=!0,observeVisualViewport:l=!0,pauseWhenHidden:u=!0,throttle:d=0}={}){let f=d>0?(0,t.throttle)(a,d,{leading:!0,trailing:!0}):null,p=f??a,m=!0,h=()=>{m&&p()};p();let g=[];if(u&&e.isElement(r)&&typeof IntersectionObserver<`u`){let e=new IntersectionObserver(e=>{m=e.at(-1)?.isIntersecting??!0,m&&p()});e.observe(r),g.push(()=>e.disconnect())}if(e.isElement(r)&&s){let e=n(r);for(let t of e)t.addEventListener(`scroll`,h,{passive:!0}),g.push(()=>t.removeEventListener(`scroll`,h));window.addEventListener(`scroll`,h,{passive:!0}),g.push(()=>window.removeEventListener(`scroll`,h))}else{let e=e=>{e.composedPath().includes(i)||h()};window.addEventListener(`scroll`,e,{capture:!0,passive:!0}),g.push(()=>window.removeEventListener(`scroll`,e,{capture:!0}))}window.addEventListener(`resize`,h,{passive:!0}),g.push(()=>window.removeEventListener(`resize`,h));let _=l?window.visualViewport:null;_&&(_.addEventListener(`resize`,h,{passive:!0}),_.addEventListener(`scroll`,h,{passive:!0}),g.push(()=>{_.removeEventListener(`resize`,h),_.removeEventListener(`scroll`,h)}));let v=new ResizeObserver(h);e.isElement(r)&&v.observe(r),c&&v.observe(i),g.push(()=>v.disconnect());let y=0;if(o){let e=()=>{h(),y=window.requestAnimationFrame(e)};y=window.requestAnimationFrame(e),g.push(()=>window.cancelAnimationFrame(y))}return()=>{f?.cancel();for(let e of g)e()}}exports.autoUpdate=r;
|
|
2
2
|
//# sourceMappingURL=auto-update.cjs.map
|
package/dist/auto-update.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auto-update.cjs","names":[],"sources":["../src/auto-update.ts"],"sourcesContent":["import { throttle } from '@vielzeug/arsenal';\n\nimport type { ReferenceElement } from './types';\n\nimport { isElement } from './utils';\n\nexport interface AutoUpdateOptions {\n /** Watch the floating element for size changes. Default: `true`. */\n observeFloating?: boolean;\n /**\n * Listen to scroll events on ancestor scroll containers of the reference element\n * in addition to the window. More efficient in deeply nested DOMs.\n * Set to `false` to use only a capture-phase window listener.\n * Default: `true`.\n */\n observeAncestors?: boolean;\n /** Track visual viewport scroll and resize (useful for pinch-zoom). Default: `true`. */\n observeVisualViewport?: boolean;\n /** Re-position on every animation frame. Use only when the reference itself animates. Default: `false`. */\n animationFrame?: boolean;\n /**\n * Throttle update calls to at most once every `throttle` milliseconds.\n * Uses a leading + trailing strategy: fires immediately, then once more after the interval.\n * Default: `0` (no throttling).\n */\n throttle?: number;\n /**\n * Pause position updates while the reference element is scrolled out of the viewport.\n * Uses IntersectionObserver to detect visibility. When the reference becomes visible again,\n * one position update is fired immediately.\n * Default: `true`.\n */\n pauseWhenHidden?: boolean;\n}\n\n/**\n * Collects the ancestor scroll containers of an element (up to and including the\n * nearest scrollable ancestor). Used to scope scroll listeners to the minimal\n * set of elements rather than relying on a capture-phase window listener.\n */\nfunction getScrollAncestors(el: Element): Element[] {\n const ancestors: Element[] = [];\n let current: Element | null = el
|
|
1
|
+
{"version":3,"file":"auto-update.cjs","names":[],"sources":["../src/auto-update.ts"],"sourcesContent":["import { throttle } from '@vielzeug/arsenal';\n\nimport type { ReferenceElement } from './types';\n\nimport { flatTreeParent, isElement } from './utils';\n\nexport interface AutoUpdateOptions {\n /** Watch the floating element for size changes. Default: `true`. */\n observeFloating?: boolean;\n /**\n * Listen to scroll events on ancestor scroll containers of the reference element\n * in addition to the window. More efficient in deeply nested DOMs.\n * Set to `false` to use only a capture-phase window listener.\n * Default: `true`.\n */\n observeAncestors?: boolean;\n /** Track visual viewport scroll and resize (useful for pinch-zoom). Default: `true`. */\n observeVisualViewport?: boolean;\n /** Re-position on every animation frame. Use only when the reference itself animates. Default: `false`. */\n animationFrame?: boolean;\n /**\n * Throttle update calls to at most once every `throttle` milliseconds.\n * Uses a leading + trailing strategy: fires immediately, then once more after the interval.\n * Default: `0` (no throttling).\n */\n throttle?: number;\n /**\n * Pause position updates while the reference element is scrolled out of the viewport.\n * Uses IntersectionObserver to detect visibility. When the reference becomes visible again,\n * one position update is fired immediately.\n * Default: `true`.\n */\n pauseWhenHidden?: boolean;\n}\n\n/**\n * Collects the ancestor scroll containers of an element (up to and including the\n * nearest scrollable ancestor). Used to scope scroll listeners to the minimal\n * set of elements rather than relying on a capture-phase window listener.\n *\n * Walks the flat (rendering) tree via `flatTreeParent` — not light-DOM `parentElement` alone —\n * so a scroll container that lives inside the shadow tree a component's light-DOM content is\n * *projected into* (e.g. a dialog's own internal scroll region, reached only by crossing its\n * `<slot>`) is still found, instead of silently skipped.\n */\nfunction getScrollAncestors(el: Element): Element[] {\n const ancestors: Element[] = [];\n let current: Element | null = flatTreeParent(el);\n\n while (current) {\n const style = getComputedStyle(current);\n const overflow = style.overflow + style.overflowX + style.overflowY;\n\n if (/auto|scroll|overlay/.test(overflow)) {\n ancestors.push(current);\n }\n\n current = flatTreeParent(current);\n }\n\n return ancestors;\n}\n\n/**\n * Calls `update` immediately and re-calls it whenever the reference or floating element\n * could have changed position: scroll, resize, ResizeObserver, or animation frames.\n *\n * By default, scroll listeners are attached to both ancestor scroll containers of the reference\n * AND the window (for document scroll). The ancestor listeners fire for nested container scrolls;\n * the window listener fires for page-level scroll. Set `observeAncestors: false` to use only a\n * capture-phase window listener.\n *\n * Returns a cleanup function that removes all listeners.\n *\n * @example\n * ```ts\n * const cleanup = autoUpdate(reference, floating, () => {\n * const { x, y } = computePosition(reference, floating, options);\n * floating.style.left = `${x}px`;\n * floating.style.top = `${y}px`;\n * });\n * // later:\n * cleanup();\n * ```\n */\nexport function autoUpdate(\n reference: ReferenceElement,\n floating: HTMLElement,\n update: () => void,\n {\n animationFrame = false,\n observeAncestors = true,\n observeFloating = true,\n observeVisualViewport = true,\n pauseWhenHidden = true,\n throttle: throttleMs = 0,\n }: AutoUpdateOptions = {},\n): () => void {\n const throttled = throttleMs > 0 ? throttle(update, throttleMs, { leading: true, trailing: true }) : null;\n const notify = throttled ?? update;\n\n // ── Visibility guard ─────────────────────────────────────────────────────────\n let referenceVisible = true;\n const conditionalNotify = (): void => {\n if (referenceVisible) notify();\n };\n\n // Initial call always runs regardless of visibility state.\n notify();\n\n const cleanups: Array<() => void> = [];\n\n // IntersectionObserver: pause updates when reference is off-screen.\n if (pauseWhenHidden && isElement(reference) && typeof IntersectionObserver !== 'undefined') {\n const io = new IntersectionObserver((entries) => {\n referenceVisible = entries.at(-1)?.isIntersecting ?? true;\n\n if (referenceVisible) notify(); // Re-position immediately when becoming visible.\n });\n\n io.observe(reference);\n cleanups.push(() => io.disconnect());\n }\n\n // ── Scroll listeners ────────────────────────────────────────────────────────\n if (isElement(reference) && observeAncestors) {\n // Targeted ancestor listeners for nested container scroll.\n const ancestors = getScrollAncestors(reference);\n\n for (const ancestor of ancestors) {\n ancestor.addEventListener('scroll', conditionalNotify, { passive: true });\n cleanups.push(() => ancestor.removeEventListener('scroll', conditionalNotify));\n }\n\n // Always add window scroll for document-level scroll (non-capture, doesn't fire for nested containers).\n window.addEventListener('scroll', conditionalNotify, { passive: true });\n cleanups.push(() => window.removeEventListener('scroll', conditionalNotify));\n } else {\n // VirtualReference or observeAncestors: false — capture-phase window listener catches all scrolls.\n const scrollHandler = (e: Event): void => {\n if (e.composedPath().includes(floating)) return;\n\n conditionalNotify();\n };\n\n window.addEventListener('scroll', scrollHandler, { capture: true, passive: true });\n cleanups.push(() => window.removeEventListener('scroll', scrollHandler, { capture: true }));\n }\n\n window.addEventListener('resize', conditionalNotify, { passive: true });\n cleanups.push(() => window.removeEventListener('resize', conditionalNotify));\n\n const vv = observeVisualViewport ? window.visualViewport : null;\n\n if (vv) {\n vv.addEventListener('resize', conditionalNotify, { passive: true });\n vv.addEventListener('scroll', conditionalNotify, { passive: true });\n cleanups.push(() => {\n vv.removeEventListener('resize', conditionalNotify);\n vv.removeEventListener('scroll', conditionalNotify);\n });\n }\n\n const ro = new ResizeObserver(conditionalNotify);\n\n if (isElement(reference)) ro.observe(reference);\n\n if (observeFloating) ro.observe(floating);\n\n cleanups.push(() => ro.disconnect());\n\n let frameId = 0;\n\n if (animationFrame) {\n const frameLoop = (): void => {\n conditionalNotify();\n frameId = window.requestAnimationFrame(frameLoop);\n };\n\n frameId = window.requestAnimationFrame(frameLoop);\n cleanups.push(() => window.cancelAnimationFrame(frameId));\n }\n\n return (): void => {\n throttled?.cancel();\n\n for (const fn of cleanups) fn();\n };\n}\n"],"mappings":"kEA6CA,SAAS,EAAmB,EAAwB,CAClD,IAAM,EAAuB,CAAC,EAC1B,EAA0B,EAAA,eAAe,CAAE,EAE/C,KAAO,GAAS,CACd,IAAM,EAAQ,iBAAiB,CAAO,EAChC,EAAW,EAAM,SAAW,EAAM,UAAY,EAAM,UAEtD,sBAAsB,KAAK,CAAQ,GACrC,EAAU,KAAK,CAAO,EAGxB,EAAU,EAAA,eAAe,CAAO,CAClC,CAEA,OAAO,CACT,CAwBA,SAAgB,EACd,EACA,EACA,EACA,CACE,iBAAiB,GACjB,mBAAmB,GACnB,kBAAkB,GAClB,wBAAwB,GACxB,kBAAkB,GAClB,SAAU,EAAa,GACF,CAAC,EACZ,CACZ,IAAM,EAAY,EAAa,GAAA,EAAA,EAAA,SAAA,CAAa,EAAQ,EAAY,CAAE,QAAS,GAAM,SAAU,EAAK,CAAC,EAAI,KAC/F,EAAS,GAAa,EAGxB,EAAmB,GACjB,MAAgC,CAChC,GAAkB,EAAO,CAC/B,EAGA,EAAO,EAEP,IAAM,EAA8B,CAAC,EAGrC,GAAI,GAAmB,EAAA,UAAU,CAAS,GAAK,OAAO,qBAAyB,IAAa,CAC1F,IAAM,EAAK,IAAI,qBAAsB,GAAY,CAC/C,EAAmB,EAAQ,GAAG,EAAE,CAAC,EAAE,gBAAkB,GAEjD,GAAkB,EAAO,CAC/B,CAAC,EAED,EAAG,QAAQ,CAAS,EACpB,EAAS,SAAW,EAAG,WAAW,CAAC,CACrC,CAGA,GAAI,EAAA,UAAU,CAAS,GAAK,EAAkB,CAE5C,IAAM,EAAY,EAAmB,CAAS,EAE9C,IAAK,IAAM,KAAY,EACrB,EAAS,iBAAiB,SAAU,EAAmB,CAAE,QAAS,EAAK,CAAC,EACxE,EAAS,SAAW,EAAS,oBAAoB,SAAU,CAAiB,CAAC,EAI/E,OAAO,iBAAiB,SAAU,EAAmB,CAAE,QAAS,EAAK,CAAC,EACtE,EAAS,SAAW,OAAO,oBAAoB,SAAU,CAAiB,CAAC,CAC7E,KAAO,CAEL,IAAM,EAAiB,GAAmB,CACpC,EAAE,aAAa,CAAC,CAAC,SAAS,CAAQ,GAEtC,EAAkB,CACpB,EAEA,OAAO,iBAAiB,SAAU,EAAe,CAAE,QAAS,GAAM,QAAS,EAAK,CAAC,EACjF,EAAS,SAAW,OAAO,oBAAoB,SAAU,EAAe,CAAE,QAAS,EAAK,CAAC,CAAC,CAC5F,CAEA,OAAO,iBAAiB,SAAU,EAAmB,CAAE,QAAS,EAAK,CAAC,EACtE,EAAS,SAAW,OAAO,oBAAoB,SAAU,CAAiB,CAAC,EAE3E,IAAM,EAAK,EAAwB,OAAO,eAAiB,KAEvD,IACF,EAAG,iBAAiB,SAAU,EAAmB,CAAE,QAAS,EAAK,CAAC,EAClE,EAAG,iBAAiB,SAAU,EAAmB,CAAE,QAAS,EAAK,CAAC,EAClE,EAAS,SAAW,CAClB,EAAG,oBAAoB,SAAU,CAAiB,EAClD,EAAG,oBAAoB,SAAU,CAAiB,CACpD,CAAC,GAGH,IAAM,EAAK,IAAI,eAAe,CAAiB,EAE3C,EAAA,UAAU,CAAS,GAAG,EAAG,QAAQ,CAAS,EAE1C,GAAiB,EAAG,QAAQ,CAAQ,EAExC,EAAS,SAAW,EAAG,WAAW,CAAC,EAEnC,IAAI,EAAU,EAEd,GAAI,EAAgB,CAClB,IAAM,MAAwB,CAC5B,EAAkB,EAClB,EAAU,OAAO,sBAAsB,CAAS,CAClD,EAEA,EAAU,OAAO,sBAAsB,CAAS,EAChD,EAAS,SAAW,OAAO,qBAAqB,CAAO,CAAC,CAC1D,CAEA,UAAmB,CACjB,GAAW,OAAO,EAElB,IAAK,IAAM,KAAM,EAAU,EAAG,CAChC,CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auto-update.d.ts","sourceRoot":"","sources":["../src/auto-update.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAIhD,MAAM,WAAW,iBAAiB;IAChC,oEAAoE;IACpE,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,wFAAwF;IACxF,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,2GAA2G;IAC3G,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;;OAKG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;
|
|
1
|
+
{"version":3,"file":"auto-update.d.ts","sourceRoot":"","sources":["../src/auto-update.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAIhD,MAAM,WAAW,iBAAiB;IAChC,oEAAoE;IACpE,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,wFAAwF;IACxF,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,2GAA2G;IAC3G,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;;OAKG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AA8BD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,UAAU,CACxB,SAAS,EAAE,gBAAgB,EAC3B,QAAQ,EAAE,WAAW,EACrB,MAAM,EAAE,MAAM,IAAI,EAClB,EACE,cAAsB,EACtB,gBAAuB,EACvB,eAAsB,EACtB,qBAA4B,EAC5B,eAAsB,EACtB,QAAQ,EAAE,UAAc,GACzB,GAAE,iBAAsB,GACxB,MAAM,IAAI,CA2FZ"}
|
package/dist/auto-update.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{isElement as
|
|
1
|
+
import{flatTreeParent as e,isElement as t}from"./utils.js";import{throttle as n}from"@vielzeug/arsenal";function r(t){let n=[],r=e(t);for(;r;){let t=getComputedStyle(r),i=t.overflow+t.overflowX+t.overflowY;/auto|scroll|overlay/.test(i)&&n.push(r),r=e(r)}return n}function i(e,i,a,{animationFrame:o=!1,observeAncestors:s=!0,observeFloating:c=!0,observeVisualViewport:l=!0,pauseWhenHidden:u=!0,throttle:d=0}={}){let f=d>0?n(a,d,{leading:!0,trailing:!0}):null,p=f??a,m=!0,h=()=>{m&&p()};p();let g=[];if(u&&t(e)&&typeof IntersectionObserver<`u`){let t=new IntersectionObserver(e=>{m=e.at(-1)?.isIntersecting??!0,m&&p()});t.observe(e),g.push(()=>t.disconnect())}if(t(e)&&s){let t=r(e);for(let e of t)e.addEventListener(`scroll`,h,{passive:!0}),g.push(()=>e.removeEventListener(`scroll`,h));window.addEventListener(`scroll`,h,{passive:!0}),g.push(()=>window.removeEventListener(`scroll`,h))}else{let e=e=>{e.composedPath().includes(i)||h()};window.addEventListener(`scroll`,e,{capture:!0,passive:!0}),g.push(()=>window.removeEventListener(`scroll`,e,{capture:!0}))}window.addEventListener(`resize`,h,{passive:!0}),g.push(()=>window.removeEventListener(`resize`,h));let _=l?window.visualViewport:null;_&&(_.addEventListener(`resize`,h,{passive:!0}),_.addEventListener(`scroll`,h,{passive:!0}),g.push(()=>{_.removeEventListener(`resize`,h),_.removeEventListener(`scroll`,h)}));let v=new ResizeObserver(h);t(e)&&v.observe(e),c&&v.observe(i),g.push(()=>v.disconnect());let y=0;if(o){let e=()=>{h(),y=window.requestAnimationFrame(e)};y=window.requestAnimationFrame(e),g.push(()=>window.cancelAnimationFrame(y))}return()=>{f?.cancel();for(let e of g)e()}}export{i as autoUpdate};
|
|
2
2
|
//# sourceMappingURL=auto-update.js.map
|
package/dist/auto-update.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auto-update.js","names":[],"sources":["../src/auto-update.ts"],"sourcesContent":["import { throttle } from '@vielzeug/arsenal';\n\nimport type { ReferenceElement } from './types';\n\nimport { isElement } from './utils';\n\nexport interface AutoUpdateOptions {\n /** Watch the floating element for size changes. Default: `true`. */\n observeFloating?: boolean;\n /**\n * Listen to scroll events on ancestor scroll containers of the reference element\n * in addition to the window. More efficient in deeply nested DOMs.\n * Set to `false` to use only a capture-phase window listener.\n * Default: `true`.\n */\n observeAncestors?: boolean;\n /** Track visual viewport scroll and resize (useful for pinch-zoom). Default: `true`. */\n observeVisualViewport?: boolean;\n /** Re-position on every animation frame. Use only when the reference itself animates. Default: `false`. */\n animationFrame?: boolean;\n /**\n * Throttle update calls to at most once every `throttle` milliseconds.\n * Uses a leading + trailing strategy: fires immediately, then once more after the interval.\n * Default: `0` (no throttling).\n */\n throttle?: number;\n /**\n * Pause position updates while the reference element is scrolled out of the viewport.\n * Uses IntersectionObserver to detect visibility. When the reference becomes visible again,\n * one position update is fired immediately.\n * Default: `true`.\n */\n pauseWhenHidden?: boolean;\n}\n\n/**\n * Collects the ancestor scroll containers of an element (up to and including the\n * nearest scrollable ancestor). Used to scope scroll listeners to the minimal\n * set of elements rather than relying on a capture-phase window listener.\n */\nfunction getScrollAncestors(el: Element): Element[] {\n const ancestors: Element[] = [];\n let current: Element | null = el
|
|
1
|
+
{"version":3,"file":"auto-update.js","names":[],"sources":["../src/auto-update.ts"],"sourcesContent":["import { throttle } from '@vielzeug/arsenal';\n\nimport type { ReferenceElement } from './types';\n\nimport { flatTreeParent, isElement } from './utils';\n\nexport interface AutoUpdateOptions {\n /** Watch the floating element for size changes. Default: `true`. */\n observeFloating?: boolean;\n /**\n * Listen to scroll events on ancestor scroll containers of the reference element\n * in addition to the window. More efficient in deeply nested DOMs.\n * Set to `false` to use only a capture-phase window listener.\n * Default: `true`.\n */\n observeAncestors?: boolean;\n /** Track visual viewport scroll and resize (useful for pinch-zoom). Default: `true`. */\n observeVisualViewport?: boolean;\n /** Re-position on every animation frame. Use only when the reference itself animates. Default: `false`. */\n animationFrame?: boolean;\n /**\n * Throttle update calls to at most once every `throttle` milliseconds.\n * Uses a leading + trailing strategy: fires immediately, then once more after the interval.\n * Default: `0` (no throttling).\n */\n throttle?: number;\n /**\n * Pause position updates while the reference element is scrolled out of the viewport.\n * Uses IntersectionObserver to detect visibility. When the reference becomes visible again,\n * one position update is fired immediately.\n * Default: `true`.\n */\n pauseWhenHidden?: boolean;\n}\n\n/**\n * Collects the ancestor scroll containers of an element (up to and including the\n * nearest scrollable ancestor). Used to scope scroll listeners to the minimal\n * set of elements rather than relying on a capture-phase window listener.\n *\n * Walks the flat (rendering) tree via `flatTreeParent` — not light-DOM `parentElement` alone —\n * so a scroll container that lives inside the shadow tree a component's light-DOM content is\n * *projected into* (e.g. a dialog's own internal scroll region, reached only by crossing its\n * `<slot>`) is still found, instead of silently skipped.\n */\nfunction getScrollAncestors(el: Element): Element[] {\n const ancestors: Element[] = [];\n let current: Element | null = flatTreeParent(el);\n\n while (current) {\n const style = getComputedStyle(current);\n const overflow = style.overflow + style.overflowX + style.overflowY;\n\n if (/auto|scroll|overlay/.test(overflow)) {\n ancestors.push(current);\n }\n\n current = flatTreeParent(current);\n }\n\n return ancestors;\n}\n\n/**\n * Calls `update` immediately and re-calls it whenever the reference or floating element\n * could have changed position: scroll, resize, ResizeObserver, or animation frames.\n *\n * By default, scroll listeners are attached to both ancestor scroll containers of the reference\n * AND the window (for document scroll). The ancestor listeners fire for nested container scrolls;\n * the window listener fires for page-level scroll. Set `observeAncestors: false` to use only a\n * capture-phase window listener.\n *\n * Returns a cleanup function that removes all listeners.\n *\n * @example\n * ```ts\n * const cleanup = autoUpdate(reference, floating, () => {\n * const { x, y } = computePosition(reference, floating, options);\n * floating.style.left = `${x}px`;\n * floating.style.top = `${y}px`;\n * });\n * // later:\n * cleanup();\n * ```\n */\nexport function autoUpdate(\n reference: ReferenceElement,\n floating: HTMLElement,\n update: () => void,\n {\n animationFrame = false,\n observeAncestors = true,\n observeFloating = true,\n observeVisualViewport = true,\n pauseWhenHidden = true,\n throttle: throttleMs = 0,\n }: AutoUpdateOptions = {},\n): () => void {\n const throttled = throttleMs > 0 ? throttle(update, throttleMs, { leading: true, trailing: true }) : null;\n const notify = throttled ?? update;\n\n // ── Visibility guard ─────────────────────────────────────────────────────────\n let referenceVisible = true;\n const conditionalNotify = (): void => {\n if (referenceVisible) notify();\n };\n\n // Initial call always runs regardless of visibility state.\n notify();\n\n const cleanups: Array<() => void> = [];\n\n // IntersectionObserver: pause updates when reference is off-screen.\n if (pauseWhenHidden && isElement(reference) && typeof IntersectionObserver !== 'undefined') {\n const io = new IntersectionObserver((entries) => {\n referenceVisible = entries.at(-1)?.isIntersecting ?? true;\n\n if (referenceVisible) notify(); // Re-position immediately when becoming visible.\n });\n\n io.observe(reference);\n cleanups.push(() => io.disconnect());\n }\n\n // ── Scroll listeners ────────────────────────────────────────────────────────\n if (isElement(reference) && observeAncestors) {\n // Targeted ancestor listeners for nested container scroll.\n const ancestors = getScrollAncestors(reference);\n\n for (const ancestor of ancestors) {\n ancestor.addEventListener('scroll', conditionalNotify, { passive: true });\n cleanups.push(() => ancestor.removeEventListener('scroll', conditionalNotify));\n }\n\n // Always add window scroll for document-level scroll (non-capture, doesn't fire for nested containers).\n window.addEventListener('scroll', conditionalNotify, { passive: true });\n cleanups.push(() => window.removeEventListener('scroll', conditionalNotify));\n } else {\n // VirtualReference or observeAncestors: false — capture-phase window listener catches all scrolls.\n const scrollHandler = (e: Event): void => {\n if (e.composedPath().includes(floating)) return;\n\n conditionalNotify();\n };\n\n window.addEventListener('scroll', scrollHandler, { capture: true, passive: true });\n cleanups.push(() => window.removeEventListener('scroll', scrollHandler, { capture: true }));\n }\n\n window.addEventListener('resize', conditionalNotify, { passive: true });\n cleanups.push(() => window.removeEventListener('resize', conditionalNotify));\n\n const vv = observeVisualViewport ? window.visualViewport : null;\n\n if (vv) {\n vv.addEventListener('resize', conditionalNotify, { passive: true });\n vv.addEventListener('scroll', conditionalNotify, { passive: true });\n cleanups.push(() => {\n vv.removeEventListener('resize', conditionalNotify);\n vv.removeEventListener('scroll', conditionalNotify);\n });\n }\n\n const ro = new ResizeObserver(conditionalNotify);\n\n if (isElement(reference)) ro.observe(reference);\n\n if (observeFloating) ro.observe(floating);\n\n cleanups.push(() => ro.disconnect());\n\n let frameId = 0;\n\n if (animationFrame) {\n const frameLoop = (): void => {\n conditionalNotify();\n frameId = window.requestAnimationFrame(frameLoop);\n };\n\n frameId = window.requestAnimationFrame(frameLoop);\n cleanups.push(() => window.cancelAnimationFrame(frameId));\n }\n\n return (): void => {\n throttled?.cancel();\n\n for (const fn of cleanups) fn();\n };\n}\n"],"mappings":"wGA6CA,SAAS,EAAmB,EAAwB,CAClD,IAAM,EAAuB,CAAC,EAC1B,EAA0B,EAAe,CAAE,EAE/C,KAAO,GAAS,CACd,IAAM,EAAQ,iBAAiB,CAAO,EAChC,EAAW,EAAM,SAAW,EAAM,UAAY,EAAM,UAEtD,sBAAsB,KAAK,CAAQ,GACrC,EAAU,KAAK,CAAO,EAGxB,EAAU,EAAe,CAAO,CAClC,CAEA,OAAO,CACT,CAwBA,SAAgB,EACd,EACA,EACA,EACA,CACE,iBAAiB,GACjB,mBAAmB,GACnB,kBAAkB,GAClB,wBAAwB,GACxB,kBAAkB,GAClB,SAAU,EAAa,GACF,CAAC,EACZ,CACZ,IAAM,EAAY,EAAa,EAAI,EAAS,EAAQ,EAAY,CAAE,QAAS,GAAM,SAAU,EAAK,CAAC,EAAI,KAC/F,EAAS,GAAa,EAGxB,EAAmB,GACjB,MAAgC,CAChC,GAAkB,EAAO,CAC/B,EAGA,EAAO,EAEP,IAAM,EAA8B,CAAC,EAGrC,GAAI,GAAmB,EAAU,CAAS,GAAK,OAAO,qBAAyB,IAAa,CAC1F,IAAM,EAAK,IAAI,qBAAsB,GAAY,CAC/C,EAAmB,EAAQ,GAAG,EAAE,CAAC,EAAE,gBAAkB,GAEjD,GAAkB,EAAO,CAC/B,CAAC,EAED,EAAG,QAAQ,CAAS,EACpB,EAAS,SAAW,EAAG,WAAW,CAAC,CACrC,CAGA,GAAI,EAAU,CAAS,GAAK,EAAkB,CAE5C,IAAM,EAAY,EAAmB,CAAS,EAE9C,IAAK,IAAM,KAAY,EACrB,EAAS,iBAAiB,SAAU,EAAmB,CAAE,QAAS,EAAK,CAAC,EACxE,EAAS,SAAW,EAAS,oBAAoB,SAAU,CAAiB,CAAC,EAI/E,OAAO,iBAAiB,SAAU,EAAmB,CAAE,QAAS,EAAK,CAAC,EACtE,EAAS,SAAW,OAAO,oBAAoB,SAAU,CAAiB,CAAC,CAC7E,KAAO,CAEL,IAAM,EAAiB,GAAmB,CACpC,EAAE,aAAa,CAAC,CAAC,SAAS,CAAQ,GAEtC,EAAkB,CACpB,EAEA,OAAO,iBAAiB,SAAU,EAAe,CAAE,QAAS,GAAM,QAAS,EAAK,CAAC,EACjF,EAAS,SAAW,OAAO,oBAAoB,SAAU,EAAe,CAAE,QAAS,EAAK,CAAC,CAAC,CAC5F,CAEA,OAAO,iBAAiB,SAAU,EAAmB,CAAE,QAAS,EAAK,CAAC,EACtE,EAAS,SAAW,OAAO,oBAAoB,SAAU,CAAiB,CAAC,EAE3E,IAAM,EAAK,EAAwB,OAAO,eAAiB,KAEvD,IACF,EAAG,iBAAiB,SAAU,EAAmB,CAAE,QAAS,EAAK,CAAC,EAClE,EAAG,iBAAiB,SAAU,EAAmB,CAAE,QAAS,EAAK,CAAC,EAClE,EAAS,SAAW,CAClB,EAAG,oBAAoB,SAAU,CAAiB,EAClD,EAAG,oBAAoB,SAAU,CAAiB,CACpD,CAAC,GAGH,IAAM,EAAK,IAAI,eAAe,CAAiB,EAE3C,EAAU,CAAS,GAAG,EAAG,QAAQ,CAAS,EAE1C,GAAiB,EAAG,QAAQ,CAAQ,EAExC,EAAS,SAAW,EAAG,WAAW,CAAC,EAEnC,IAAI,EAAU,EAEd,GAAI,EAAgB,CAClB,IAAM,MAAwB,CAC5B,EAAkB,EAClB,EAAU,OAAO,sBAAsB,CAAS,CAClD,EAEA,EAAU,OAAO,sBAAsB,CAAS,EAChD,EAAS,SAAW,OAAO,qBAAqB,CAAO,CAAC,CAC1D,CAEA,UAAmB,CACjB,GAAW,OAAO,EAElB,IAAK,IAAM,KAAM,EAAU,EAAG,CAChC,CACF"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("./utils.cjs");var t=[`transform`,`perspective`,`filter`],n=[`layout`,`paint`,`strict`,`content`];function r(e){return e.transform!==`none`||e.perspective!==`none`||e.filter!==`none`||e.backdropFilter&&e.backdropFilter!==`none`||e.willChange!==`auto`&&t.some(t=>e.willChange.includes(t))?!0:e.contain!==`none`&&n.some(t=>e.contain.includes(t))}function i(t){let n=e.flatTreeParent(t);for(;n;){if(r(getComputedStyle(n)))return n;n=e.flatTreeParent(n)}return null}exports.getContainingBlock=i;
|
|
2
|
+
//# sourceMappingURL=containing-block.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"containing-block.cjs","names":[],"sources":["../src/containing-block.ts"],"sourcesContent":["/**\n * @vielzeug/orbit — containing-block detection for `position: fixed` elements.\n */\n\nimport { flatTreeParent } from './utils';\n\nconst WILL_CHANGE_TRAPS = ['transform', 'perspective', 'filter'];\nconst CONTAIN_TRAPS = ['layout', 'paint', 'strict', 'content'];\n\n/**\n * True if `style` makes its element a containing block for `position: fixed` descendants, per\n * the CSS Transforms spec: a non-`none` `transform`, `perspective`, or `filter`; a non-`none`\n * `backdrop-filter`; a `will-change` naming one of those three properties; or a `contain` value\n * that affects layout or paint.\n */\nfunction establishesFixedContainingBlock(style: CSSStyleDeclaration): boolean {\n if (style.transform !== 'none') return true;\n\n if (style.perspective !== 'none') return true;\n\n if (style.filter !== 'none') return true;\n\n if (style.backdropFilter && style.backdropFilter !== 'none') return true;\n\n if (style.willChange !== 'auto' && WILL_CHANGE_TRAPS.some((prop) => style.willChange.includes(prop))) return true;\n\n return style.contain !== 'none' && CONTAIN_TRAPS.some((keyword) => style.contain.includes(keyword));\n}\n\n/**\n * Walks up from `element` (crossing shadow boundaries via the flat tree) to find the nearest\n * ancestor that establishes a containing block for `position: fixed` descendants. Returns `null`\n * when none is found — the common case, meaning the true viewport is the containing block.\n *\n * `Element.offsetParent` can't answer this: browsers report it as `null` unconditionally for\n * `position: fixed` elements, without accounting for a transformed ancestor — even though the\n * CSS Transforms spec says that ancestor *does* become the containing block once it has a\n * non-`none` `transform`/`filter`/`perspective`/`backdrop-filter` (even a visually-identity one,\n * e.g. `transform: scale(1)` left over from an entrance transition that never resets to `none` at\n * rest). A `position: fixed` floating element nested inside such an ancestor — a modal dialog's\n * panel is the classic case — has its `left`/`top` resolved against *that* ancestor's box instead\n * of the viewport, silently mispositioning it even though the coordinates computed for it were\n * correct viewport-relative values.\n *\n * Pass the result as `containingBlock` to `computePosition()` to correct for this.\n *\n * @example\n * ```ts\n * const containingBlock = getContainingBlock(floatingEl);\n * computePosition(reference, floating, { containingBlock, placement: 'bottom-start' });\n * ```\n */\nexport function getContainingBlock(element: Element): Element | null {\n let node = flatTreeParent(element);\n\n while (node) {\n if (establishesFixedContainingBlock(getComputedStyle(node))) return node;\n\n node = flatTreeParent(node);\n }\n\n return null;\n}\n"],"mappings":"+BAMA,IAAM,EAAoB,CAAC,YAAa,cAAe,QAAQ,EACzD,EAAgB,CAAC,SAAU,QAAS,SAAU,SAAS,EAQ7D,SAAS,EAAgC,EAAqC,CAW5E,OAVI,EAAM,YAAc,QAEpB,EAAM,cAAgB,QAEtB,EAAM,SAAW,QAEjB,EAAM,gBAAkB,EAAM,iBAAmB,QAEjD,EAAM,aAAe,QAAU,EAAkB,KAAM,GAAS,EAAM,WAAW,SAAS,CAAI,CAAC,EAAU,GAEtG,EAAM,UAAY,QAAU,EAAc,KAAM,GAAY,EAAM,QAAQ,SAAS,CAAO,CAAC,CACpG,CAyBA,SAAgB,EAAmB,EAAkC,CACnE,IAAI,EAAO,EAAA,eAAe,CAAO,EAEjC,KAAO,GAAM,CACX,GAAI,EAAgC,iBAAiB,CAAI,CAAC,EAAG,OAAO,EAEpE,EAAO,EAAA,eAAe,CAAI,CAC5B,CAEA,OAAO,IACT"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @vielzeug/orbit — containing-block detection for `position: fixed` elements.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Walks up from `element` (crossing shadow boundaries via the flat tree) to find the nearest
|
|
6
|
+
* ancestor that establishes a containing block for `position: fixed` descendants. Returns `null`
|
|
7
|
+
* when none is found — the common case, meaning the true viewport is the containing block.
|
|
8
|
+
*
|
|
9
|
+
* `Element.offsetParent` can't answer this: browsers report it as `null` unconditionally for
|
|
10
|
+
* `position: fixed` elements, without accounting for a transformed ancestor — even though the
|
|
11
|
+
* CSS Transforms spec says that ancestor *does* become the containing block once it has a
|
|
12
|
+
* non-`none` `transform`/`filter`/`perspective`/`backdrop-filter` (even a visually-identity one,
|
|
13
|
+
* e.g. `transform: scale(1)` left over from an entrance transition that never resets to `none` at
|
|
14
|
+
* rest). A `position: fixed` floating element nested inside such an ancestor — a modal dialog's
|
|
15
|
+
* panel is the classic case — has its `left`/`top` resolved against *that* ancestor's box instead
|
|
16
|
+
* of the viewport, silently mispositioning it even though the coordinates computed for it were
|
|
17
|
+
* correct viewport-relative values.
|
|
18
|
+
*
|
|
19
|
+
* Pass the result as `containingBlock` to `computePosition()` to correct for this.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* const containingBlock = getContainingBlock(floatingEl);
|
|
24
|
+
* computePosition(reference, floating, { containingBlock, placement: 'bottom-start' });
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare function getContainingBlock(element: Element): Element | null;
|
|
28
|
+
//# sourceMappingURL=containing-block.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"containing-block.d.ts","sourceRoot":"","sources":["../src/containing-block.ts"],"names":[],"mappings":"AAAA;;GAEG;AA2BH;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,GAAG,IAAI,CAUnE"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{flatTreeParent as e}from"./utils.js";var t=[`transform`,`perspective`,`filter`],n=[`layout`,`paint`,`strict`,`content`];function r(e){return e.transform!==`none`||e.perspective!==`none`||e.filter!==`none`||e.backdropFilter&&e.backdropFilter!==`none`||e.willChange!==`auto`&&t.some(t=>e.willChange.includes(t))?!0:e.contain!==`none`&&n.some(t=>e.contain.includes(t))}function i(t){let n=e(t);for(;n;){if(r(getComputedStyle(n)))return n;n=e(n)}return null}export{i as getContainingBlock};
|
|
2
|
+
//# sourceMappingURL=containing-block.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"containing-block.js","names":[],"sources":["../src/containing-block.ts"],"sourcesContent":["/**\n * @vielzeug/orbit — containing-block detection for `position: fixed` elements.\n */\n\nimport { flatTreeParent } from './utils';\n\nconst WILL_CHANGE_TRAPS = ['transform', 'perspective', 'filter'];\nconst CONTAIN_TRAPS = ['layout', 'paint', 'strict', 'content'];\n\n/**\n * True if `style` makes its element a containing block for `position: fixed` descendants, per\n * the CSS Transforms spec: a non-`none` `transform`, `perspective`, or `filter`; a non-`none`\n * `backdrop-filter`; a `will-change` naming one of those three properties; or a `contain` value\n * that affects layout or paint.\n */\nfunction establishesFixedContainingBlock(style: CSSStyleDeclaration): boolean {\n if (style.transform !== 'none') return true;\n\n if (style.perspective !== 'none') return true;\n\n if (style.filter !== 'none') return true;\n\n if (style.backdropFilter && style.backdropFilter !== 'none') return true;\n\n if (style.willChange !== 'auto' && WILL_CHANGE_TRAPS.some((prop) => style.willChange.includes(prop))) return true;\n\n return style.contain !== 'none' && CONTAIN_TRAPS.some((keyword) => style.contain.includes(keyword));\n}\n\n/**\n * Walks up from `element` (crossing shadow boundaries via the flat tree) to find the nearest\n * ancestor that establishes a containing block for `position: fixed` descendants. Returns `null`\n * when none is found — the common case, meaning the true viewport is the containing block.\n *\n * `Element.offsetParent` can't answer this: browsers report it as `null` unconditionally for\n * `position: fixed` elements, without accounting for a transformed ancestor — even though the\n * CSS Transforms spec says that ancestor *does* become the containing block once it has a\n * non-`none` `transform`/`filter`/`perspective`/`backdrop-filter` (even a visually-identity one,\n * e.g. `transform: scale(1)` left over from an entrance transition that never resets to `none` at\n * rest). A `position: fixed` floating element nested inside such an ancestor — a modal dialog's\n * panel is the classic case — has its `left`/`top` resolved against *that* ancestor's box instead\n * of the viewport, silently mispositioning it even though the coordinates computed for it were\n * correct viewport-relative values.\n *\n * Pass the result as `containingBlock` to `computePosition()` to correct for this.\n *\n * @example\n * ```ts\n * const containingBlock = getContainingBlock(floatingEl);\n * computePosition(reference, floating, { containingBlock, placement: 'bottom-start' });\n * ```\n */\nexport function getContainingBlock(element: Element): Element | null {\n let node = flatTreeParent(element);\n\n while (node) {\n if (establishesFixedContainingBlock(getComputedStyle(node))) return node;\n\n node = flatTreeParent(node);\n }\n\n return null;\n}\n"],"mappings":"4CAMA,IAAM,EAAoB,CAAC,YAAa,cAAe,QAAQ,EACzD,EAAgB,CAAC,SAAU,QAAS,SAAU,SAAS,EAQ7D,SAAS,EAAgC,EAAqC,CAW5E,OAVI,EAAM,YAAc,QAEpB,EAAM,cAAgB,QAEtB,EAAM,SAAW,QAEjB,EAAM,gBAAkB,EAAM,iBAAmB,QAEjD,EAAM,aAAe,QAAU,EAAkB,KAAM,GAAS,EAAM,WAAW,SAAS,CAAI,CAAC,EAAU,GAEtG,EAAM,UAAY,QAAU,EAAc,KAAM,GAAY,EAAM,QAAQ,SAAS,CAAO,CAAC,CACpG,CAyBA,SAAgB,EAAmB,EAAkC,CACnE,IAAI,EAAO,EAAe,CAAO,EAEjC,KAAO,GAAM,CACX,GAAI,EAAgC,iBAAiB,CAAI,CAAC,EAAG,OAAO,EAEpE,EAAO,EAAe,CAAI,CAC5B,CAEA,OAAO,IACT"}
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./errors.cjs"),t=require("./utils.cjs"),n=require("./auto-update.cjs"),r=require("./core.cjs"),i=require("./float.cjs"),a=require("./overflow.cjs"),o=require("./
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./errors.cjs"),t=require("./utils.cjs"),n=require("./auto-update.cjs"),r=require("./core.cjs"),i=require("./float.cjs"),a=require("./overflow.cjs"),o=require("./containing-block.cjs"),s=require("./compose.cjs"),c=require("./middleware/arrow.cjs"),l=require("./middleware/auto-placement.cjs"),u=require("./middleware/flip.cjs"),d=require("./middleware/hide.cjs"),f=require("./inline.cjs"),p=require("./middleware/offset.cjs"),m=require("./middleware/shift.cjs"),h=require("./middleware/size.cjs");exports.OrbitConfigError=e.OrbitConfigError,exports.OrbitError=e.OrbitError,exports.arrow=c.arrow,exports.autoPlacement=l.autoPlacement,exports.autoUpdate=n.autoUpdate,exports.compose=s.compose,exports.computePosition=r.computePosition,exports.computePositionAsync=r.computePositionAsync,exports.computePositionRaf=r.computePositionRaf,exports.detectOverflow=a.detectOverflow,exports.flip=u.flip,exports.float=i.float,exports.floatWithAnchor=i.floatWithAnchor,exports.getAlignment=t.getAlignment,exports.getClippingAncestorRect=a.getClippingAncestorRect,exports.getContainingBlock=o.getContainingBlock,exports.getRects=r.getRects,exports.getSide=t.getSide,exports.hide=d.hide,exports.inline=f.inline,exports.isCssAnchorSupported=i.isCssAnchorSupported,exports.limitShift=m.limitShift,exports.offset=p.offset,exports.shift=m.shift,exports.size=h.size;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { OrbitConfigError, OrbitError } from './errors';
|
|
2
2
|
export { computePosition, computePositionAsync, computePositionRaf, getRects } from './core';
|
|
3
|
-
export { detectOverflow } from './overflow';
|
|
3
|
+
export { detectOverflow, getClippingAncestorRect } from './overflow';
|
|
4
|
+
export { getContainingBlock } from './containing-block';
|
|
4
5
|
export { float, floatWithAnchor, isCssAnchorSupported } from './float';
|
|
5
6
|
export type { CssAnchorHandle, FloatOptions } from './float';
|
|
6
7
|
export { autoUpdate } from './auto-update';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAGxD,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAC7F,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAGxD,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAC7F,OAAO,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAGxD,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AACvE,YAAY,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAG7D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,YAAY,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAGvD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,YAAY,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAExE,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,YAAY,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAErE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AACvD,YAAY,EAAE,iBAAiB,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAExF,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGrD,YAAY,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAGlE,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAGhD,YAAY,EACV,SAAS,EACT,SAAS,EACT,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,EACrB,QAAQ,EACR,WAAW,EACX,QAAQ,EACR,UAAU,EACV,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,OAAO,EACP,SAAS,EACT,IAAI,EACJ,gBAAgB,EAChB,SAAS,EACT,IAAI,EACJ,UAAU,EACV,QAAQ,EACR,eAAe,EACf,gBAAgB,GACjB,MAAM,SAAS,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{OrbitConfigError as e,OrbitError as t}from"./errors.js";import{getAlignment as n,getSide as r}from"./utils.js";import{autoUpdate as i}from"./auto-update.js";import{computePosition as a,computePositionAsync as o,computePositionRaf as s,getRects as c}from"./core.js";import{float as l,floatWithAnchor as u,isCssAnchorSupported as d}from"./float.js";import{detectOverflow as f}from"./overflow.js";import{compose as
|
|
1
|
+
import{OrbitConfigError as e,OrbitError as t}from"./errors.js";import{getAlignment as n,getSide as r}from"./utils.js";import{autoUpdate as i}from"./auto-update.js";import{computePosition as a,computePositionAsync as o,computePositionRaf as s,getRects as c}from"./core.js";import{float as l,floatWithAnchor as u,isCssAnchorSupported as d}from"./float.js";import{detectOverflow as f,getClippingAncestorRect as p}from"./overflow.js";import{getContainingBlock as m}from"./containing-block.js";import{compose as h}from"./compose.js";import{arrow as g}from"./middleware/arrow.js";import{autoPlacement as _}from"./middleware/auto-placement.js";import{flip as v}from"./middleware/flip.js";import{hide as y}from"./middleware/hide.js";import{inline as b}from"./inline.js";import{offset as x}from"./middleware/offset.js";import{limitShift as S,shift as C}from"./middleware/shift.js";import{size as w}from"./middleware/size.js";export{e as OrbitConfigError,t as OrbitError,g as arrow,_ as autoPlacement,i as autoUpdate,h as compose,a as computePosition,o as computePositionAsync,s as computePositionRaf,f as detectOverflow,v as flip,l as float,u as floatWithAnchor,n as getAlignment,p as getClippingAncestorRect,m as getContainingBlock,c as getRects,r as getSide,y as hide,b as inline,d as isCssAnchorSupported,S as limitShift,x as offset,C as shift,w as size};
|
package/dist/orbit.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@vielzeug/arsenal");var t=class e extends Error{constructor(e,t){super(e,t),this.name=new.target.name,Object.setPrototypeOf(this,new.target.prototype)}static is(t){return t instanceof e}},n=class extends t{},r=!globalThis.__ORBIT_PROD__;function i(e){r&&console.warn(`[@vielzeug/orbit] ${e}`)}function a(e){r&&e()}var o={bottom:`top`,left:`right`,right:`left`,top:`bottom`};function s(e){return e.split(`-`)[0]}function c(e){return e.split(`-`)[1]??null}function l(e,t){return t?`${e}-${t}`:e}function u({height:e,width:t,x:n,y:r}){return{height:e,width:t,x:n,y:r}}function d(e=0){return typeof e==`number`?{bottom:e,left:e,right:e,top:e}:{bottom:e.bottom??0,left:e.left??0,right:e.right??0,top:e.top??0}}function f(e){return typeof Element<`u`&&e instanceof Element}var p=[[`arrow`,`flip`],[`arrow`,`shift`],[`arrow`,`autoPlacement`],[`flip`,`inline`],[`shift`,`inline`],[`autoPlacement`,`inline`],[`size`,`flip`],[`size`,`autoPlacement`]];function m(e){for(let[t,r]of p){let i=e.indexOf(t),a=e.indexOf(r);if(i!==-1&&a!==-1&&i<a)throw new n(`"${t}" must come after "${r}" in the middleware pipeline. Recommended order: inline → offset → flip/autoPlacement → shift → size → arrow.`)}if(e.includes(`flip`)&&e.includes(`autoPlacement`))throw new n(`use either flip() or autoPlacement() in the middleware pipeline, not both.`)}var h=Symbol.for(`@vielzeug/orbit/name`);function g(e,t){return e[h]=t,e}function _(e,t,n,r){return e===`start`?t:e===`end`?t+n-r:t+(n-r)/2}function v(e,t,n){let r=s(e),i=c(e);switch(r){case`bottom`:return{x:_(i,t.x,t.width,n.width),y:t.y+t.height};case`left`:return{x:t.x-n.width,y:_(i,t.y,t.height,n.height)};case`right`:return{x:t.x+t.width,y:_(i,t.y,t.height,n.height)};case`top`:return{x:_(i,t.x,t.width,n.width),y:t.y-n.height}}}function y(e,t){return{floating:u(t.getBoundingClientRect()),reference:u(e.getBoundingClientRect())}}function b(e,t){return t?{...e,middlewareData:t.data?Object.assign(Object.create(null),e.middlewareData,t.data):e.middlewareData,placement:t.placement??e.placement,x:t.x??e.x,y:t.y??e.y}:e}var x=8;function S(e,t,n){return Promise.resolve().then(()=>w(e,t,n))}function C(e,t,n){return new Promise((r,i)=>{requestAnimationFrame(()=>{try{r(w(e,t,n))}catch(e){i(e)}})})}function w(e,t,{boundary:r,containingBlock:o,middleware:s=[],padding:c,placement:l=`bottom`}={}){let u=s.filter(Boolean);e===t&&i(`computePosition: reference and floating are the same element.`),m(u.map(e=>{let t=e[h];return typeof t==`string`?t:null}));let d=l,f={},p=y(e,t);a(()=>{p.floating.width===0&&p.floating.height===0&&i(`computePosition: floating element has zero dimensions — is it hidden or detached from the DOM?`);let e=getComputedStyle(t).position;e!==`fixed`&&e!==`absolute`&&i(`computePosition: floating element has \`position: ${e}\`. Orbit computes viewport-relative coordinates and expects position: fixed (or absolute for scoped stacking contexts).`)});for(let n=0;n<x;n+=1){let n={...v(d,p.reference,p.floating),boundary:r,elements:{floating:t,reference:e},initialPlacement:l,middlewareData:f,padding:c,placement:d,rects:p},i;for(let e of u){let t=e(n);if(n=b(n,t),f=n.middlewareData,i=t?.reset,i)break}if(!i){let e={middlewareData:n.middlewareData,placement:n.placement,x:n.x,y:n.y};if(o){let t=o.getBoundingClientRect();return{...e,x:e.x-t.x,y:e.y-t.y}}return e}i.remeasure?p=y(e,t):i.rects!=null&&(p=i.rects),d=i.placement??n.placement}throw new n(`Middleware triggered too many resets in a single compute cycle.`)}function T(){let e=window.visualViewport;return e?{height:e.height,width:e.width,x:e.offsetLeft,y:e.offsetTop}:{height:window.innerHeight,width:window.innerWidth,x:0,y:0}}function E(e){if(!e)return T();if(e instanceof Element){let t=e.getBoundingClientRect();return{height:t.height,width:t.width,x:t.x,y:t.y}}return e}function D(e,t){return{boundary:E(e.boundary??t.boundary),padding:d(e.padding??t.padding)}}function O(e){return{...e.rects.floating,x:e.x,y:e.y}}function k(e,t,n){return{bottom:e.y+e.height-(t.y+t.height-n.bottom),left:t.x+n.left-e.x,right:e.x+e.width-(t.x+t.width-n.right),top:t.y+n.top-e.y}}function A(e){return Math.max(e.top,0)+Math.max(e.right,0)+Math.max(e.bottom,0)+Math.max(e.left,0)}function j(e){return e.top>0||e.right>0||e.bottom>0||e.left>0}function M(e,t){return t.top>=e.height||t.right>=e.width||t.bottom>=e.height||t.left>=e.width}function N(e,t,n,r){let i=e.rects.reference;switch(s(t)){case`bottom`:return n.y+n.height-r.bottom-(i.y+i.height);case`left`:return i.x-(n.x+r.left);case`right`:return n.x+n.width-r.right-(i.x+i.width);case`top`:return i.y-(n.y+r.top)}}function P(e,t,n={}){let{x:r,y:i}=v(t,e.rects.reference,e.rects.floating),{boundary:a,padding:o}=D(n,e);return k({...e.rects.floating,x:r,y:i},a,o)}function F(e,t={}){let{boundary:n,padding:r}=D(t,e);return k(O(e),n,r)}function I(e){let t=[],n=e.parentElement;for(;n;){let e=getComputedStyle(n),r=e.overflow+e.overflowX+e.overflowY;if(/auto|scroll|overlay/.test(r)&&t.push(n),n.parentElement)n=n.parentElement;else{let e=n.getRootNode();n=e instanceof ShadowRoot?e.host:null}}return t}function L(t,n,r,{animationFrame:i=!1,observeAncestors:a=!0,observeFloating:o=!0,observeVisualViewport:s=!0,pauseWhenHidden:c=!0,throttle:l=0}={}){let u=l>0?(0,e.throttle)(r,l,{leading:!0,trailing:!0}):null,d=u??r,p=!0,m=()=>{p&&d()};d();let h=[];if(c&&f(t)&&typeof IntersectionObserver<`u`){let e=new IntersectionObserver(e=>{p=e.at(-1)?.isIntersecting??!0,p&&d()});e.observe(t),h.push(()=>e.disconnect())}if(f(t)&&a){let e=I(t);for(let t of e)t.addEventListener(`scroll`,m,{passive:!0}),h.push(()=>t.removeEventListener(`scroll`,m));window.addEventListener(`scroll`,m,{passive:!0}),h.push(()=>window.removeEventListener(`scroll`,m))}else{let e=e=>{e.composedPath().includes(n)||m()};window.addEventListener(`scroll`,e,{capture:!0,passive:!0}),h.push(()=>window.removeEventListener(`scroll`,e,{capture:!0}))}window.addEventListener(`resize`,m,{passive:!0}),h.push(()=>window.removeEventListener(`resize`,m));let g=s?window.visualViewport:null;g&&(g.addEventListener(`resize`,m,{passive:!0}),g.addEventListener(`scroll`,m,{passive:!0}),h.push(()=>{g.removeEventListener(`resize`,m),g.removeEventListener(`scroll`,m)}));let _=new ResizeObserver(m);f(t)&&_.observe(t),o&&_.observe(n),h.push(()=>_.disconnect());let v=0;if(i){let e=()=>{m(),v=window.requestAnimationFrame(e)};v=window.requestAnimationFrame(e),h.push(()=>window.cancelAnimationFrame(v))}return()=>{u?.cancel();for(let e of h)e()}}function R(e,t,n){let r=new AbortController,i=!1;return{get disposalSignal(){return r.signal},dispose(){i||(i=!0,r.abort(),e())},get disposed(){return i},getPosition:t,[Symbol.dispose](){this.dispose()},update:n}}function z(){return typeof CSS<`u`&&CSS.supports(`anchor-name`,`--orbit`)}var B=0,V={bottom:`block-end center`,"bottom-end":`block-end span-inline-end`,"bottom-start":`block-end span-inline-start`,left:`inline-start center`,"left-end":`inline-start span-block-end`,"left-start":`inline-start span-block-start`,right:`inline-end center`,"right-end":`inline-end span-block-end`,"right-start":`inline-end span-block-start`,top:`block-start center`,"top-end":`block-start span-inline-end`,"top-start":`block-start span-inline-start`};function H(e,t){let n={};for(let r of Object.keys(t)){let i=e.style.getPropertyValue(r);n[r]=i===``?void 0:i,e.style.setProperty(r,t[r])}return()=>{for(let r of Object.keys(t)){let t=n[r];t===void 0?e.style.removeProperty(r):e.style.setProperty(r,t)}}}function U(e,t,n,r){let i=`--orbit-${++B}`,a=H(e,{"anchor-name":i}),o=H(t,{position:`fixed`,"position-anchor":i,"position-area":V[n],"position-try-fallbacks":r});return()=>{a(),o()}}function W(e,t,{fallbacks:n=`flip-block, flip-inline, flip-block flip-inline`,placement:r=`bottom`}={}){let i=U(e,t,r,n),a=R(()=>i(),()=>null,()=>{});return Object.assign(a,{cssAnchor:!0})}function G(e,t){t.style.left=`${e.x}px`,t.style.top=`${e.y}px`}function K(e,t,{apply:n,autoUpdate:r={},boundary:i,containingBlock:a,middleware:o,padding:s,placement:c=`bottom`}={}){let l=null,u=n??(e=>G(e,t));function d(){let n=w(e,t,{boundary:i,containingBlock:a,middleware:o,padding:s,placement:c});l=n,u(n)}if(r===!1)return d(),R(()=>{},()=>l,d);let f=L(e,t,d,r);return R(()=>f(),()=>l,d)}function q(...e){return e.filter(Boolean)}function J({element:t,padding:n=0}){function r(r){let i=s(r.placement),a=d(n),o=u(t.getBoundingClientRect());if(i===`top`||i===`bottom`){let t=r.rects.reference.x+r.rects.reference.width/2-r.x-o.width/2,n=a.left,i=(0,e.clamp)(t,n,Math.max(n,r.rects.floating.width-o.width-a.right));return{data:{arrow:{centerOffset:t-i,constrained:i!==t,x:i}}}}let c=r.rects.reference.y+r.rects.reference.height/2-r.y-o.height/2,l=a.top,f=(0,e.clamp)(c,l,Math.max(l,r.rects.floating.height-o.height-a.bottom));return{data:{arrow:{centerOffset:c-f,constrained:f!==c,y:f}}}}return g(r,`arrow`)}var Y=[`top`,`right`,`bottom`,`left`];function X(e){return e===void 0?Y:e===null?Y.flatMap(e=>[e,`${e}-start`,`${e}-end`]):Y.map(t=>`${t}-${e}`)}function Z(e={}){return g(function(t){let{boundary:n,padding:r}=D(e,t),a=e.allowedPlacements??X(e.alignment);a.length===0&&i(`autoPlacement: allowedPlacements is empty — no placement will be evaluated.`);let o=t.placement,s=1/0,c=-1/0;for(let i of a){let a=A(P(t,i,e)),l=N(t,i,n,r);(a<s||a===s&&l>c)&&(o=i,s=a,c=l)}if(o!==t.placement)return{reset:{placement:o}}},`autoPlacement`)}function Q(e={}){function t(t){let n=F(t,e);if(!j(n))return;let r=s(t.placement),i=c(t.placement),a=e.fallbackPlacements??[l(o[r],i)],u=[t.placement],d=t.placement,f=A(n);for(let n of a){let r=P(t,n,e),i=A(r);if(!j(r))return{data:{flip:{skippedPlacements:u}},reset:{placement:n}};u.push(n),i<f&&(d=n,f=i)}if(d!==t.placement)return{data:{flip:{skippedPlacements:u}},reset:{placement:d}}}return g(t,`flip`)}function $(e={}){let t=e.strategy??`both`;function n(n){let{boundary:r,padding:i}=D(e,n),a={};if(t===`escaped`||t===`both`){let e=O(n),t=k(e,r,i);a.escaped=M(e,t),a.escapedOffsets=t}if(t===`referenceHidden`||t===`both`){let e=k(n.rects.reference,r,i);a.referenceHidden=M(n.rects.reference,e),a.referenceHiddenOffsets=e}return{data:{hide:a}}}return g(n,`hide`)}function ee(e){return!(`getClientRects`in e)||typeof e.getClientRects!=`function`?[]:Array.from(e.getClientRects()).map(u).filter(e=>e.width>0||e.height>0)}function te(e,t,n,r){return t>=e.x-r.left&&t<=e.x+e.width+r.right&&n>=e.y-r.top&&n<=e.y+e.height+r.bottom}function ne(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function re(e={}){function t(t){let n=ee(t.elements.reference);if(n.length<=1)return;let r=d(e.padding??2),i=s(t.placement),a=n[0];if(e.x!=null&&e.y!=null)a=n.find(t=>te(t,e.x,e.y,r))??a;else if(i===`top`||i===`bottom`){let e=t.x+t.rects.floating.width/2;a=n.reduce((t,n)=>{let r=Math.abs(t.x+t.width/2-e);return Math.abs(n.x+n.width/2-e)<r?n:t},a)}else{let e=t.y+t.rects.floating.height/2;a=n.reduce((t,n)=>{let r=Math.abs(t.y+t.height/2-e);return Math.abs(n.y+n.height/2-e)<r?n:t},a)}if(!ne(a,t.rects.reference))return{reset:{rects:{...t.rects,reference:a}}}}return g(t,`inline`)}function ie(e,t){let n=typeof e==`function`?e(t):e;return typeof n==`number`?{crossAxis:0,mainAxis:n}:{crossAxis:n.crossAxis??0,mainAxis:n.mainAxis??0}}function ae(e){return g(function(t){let n=s(t.placement),{crossAxis:r,mainAxis:i}=ie(e,t);switch(n){case`bottom`:return{x:t.x+r,y:t.y+i};case`left`:return{x:t.x-i,y:t.y+r};case`right`:return{x:t.x+i,y:t.y+r};case`top`:return{x:t.x+r,y:t.y-i}}},`offset`)}function oe(t={}){return(n,r)=>{let{placement:i,rects:a,x:o,y:c}=n,l=s(i),u=l===`top`||l===`bottom`,d=typeof t.offset==`function`?t.offset(n):t.offset??0;if(u){let t=a.reference.x-d,n=a.reference.x+a.reference.width+d-a.floating.width,[i,s]=t<=n?[t,n]:[n,t],c=(0,e.clamp)(o+r.crossAxis,i,s);return{...r,crossAxis:c-o}}let f=a.reference.y-d,p=a.reference.y+a.reference.height+d-a.floating.height,[m,h]=f<=p?[f,p]:[p,f],g=(0,e.clamp)(c+r.crossAxis,m,h);return{...r,crossAxis:g-c}}}function se(e={}){let{crossAxis:t=!0,limiter:n,mainAxis:r=!1}=e;function i(i){let a=F(i,e),o=s(i.placement),c=o===`top`||o===`bottom`,l=Math.max(a.left,0)-Math.max(a.right,0),u=Math.max(a.top,0)-Math.max(a.bottom,0),d=c?t:r,f=c?r:t,p=d?l:0,m=f?u:0;if(n){let e=n(i,{crossAxis:c?p:m,mainAxis:c?m:p});p=c?e.crossAxis:e.mainAxis,m=c?e.mainAxis:e.crossAxis}return{data:{shift:{x:p,y:m}},x:i.x+p,y:i.y+m}}return g(i,`shift`)}function ce(e={}){function t(t){let{boundary:n,padding:r}=D(e,t),i=s(t.placement),a=n.y+r.top,o=n.x+n.width-r.right,c=n.y+n.height-r.bottom,l=n.x+r.left;return{data:{size:{availableHeight:i===`bottom`?Math.max(0,c-t.y):i===`top`?Math.max(0,t.rects.reference.y-a):Math.max(0,c-a),availableWidth:i===`right`?Math.max(0,o-t.x):i===`left`?Math.max(0,t.rects.reference.x-l):Math.max(0,o-l)}}}}return g(t,`size`)}exports.OrbitConfigError=n,exports.OrbitError=t,exports.arrow=J,exports.autoPlacement=Z,exports.autoUpdate=L,exports.compose=q,exports.computePosition=w,exports.computePositionAsync=S,exports.computePositionRaf=C,exports.detectOverflow=F,exports.flip=Q,exports.float=K,exports.floatWithAnchor=W,exports.getAlignment=c,exports.getRects=y,exports.getSide=s,exports.hide=$,exports.inline=re,exports.isCssAnchorSupported=z,exports.limitShift=oe,exports.offset=ae,exports.shift=se,exports.size=ce;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@vielzeug/arsenal");var t=class e extends Error{constructor(e,t){super(e,t),this.name=new.target.name,Object.setPrototypeOf(this,new.target.prototype)}static is(t){return t instanceof e}},n=class extends t{},r=!globalThis.__ORBIT_PROD__;function i(e){r&&console.warn(`[@vielzeug/orbit] ${e}`)}function a(e){r&&e()}var o={bottom:`top`,left:`right`,right:`left`,top:`bottom`};function s(e){return e.split(`-`)[0]}function c(e){return e.split(`-`)[1]??null}function l(e,t){return t?`${e}-${t}`:e}function u({height:e,width:t,x:n,y:r}){return{height:e,width:t,x:n,y:r}}function d(e=0){return typeof e==`number`?{bottom:e,left:e,right:e,top:e}:{bottom:e.bottom??0,left:e.left??0,right:e.right??0,top:e.top??0}}function f(e){return typeof Element<`u`&&e instanceof Element}function p(e){return e.assignedSlot?e.assignedSlot:e.parentElement??(e.getRootNode()instanceof ShadowRoot?e.getRootNode().host:null)}var m=[[`arrow`,`flip`],[`arrow`,`shift`],[`arrow`,`autoPlacement`],[`flip`,`inline`],[`shift`,`inline`],[`autoPlacement`,`inline`],[`size`,`flip`],[`size`,`autoPlacement`]];function h(e){for(let[t,r]of m){let i=e.indexOf(t),a=e.indexOf(r);if(i!==-1&&a!==-1&&i<a)throw new n(`"${t}" must come after "${r}" in the middleware pipeline. Recommended order: inline → offset → flip/autoPlacement → shift → size → arrow.`)}if(e.includes(`flip`)&&e.includes(`autoPlacement`))throw new n(`use either flip() or autoPlacement() in the middleware pipeline, not both.`)}var g=Symbol.for(`@vielzeug/orbit/name`);function _(e,t){return e[g]=t,e}function v(e,t,n,r){return e===`start`?t:e===`end`?t+n-r:t+(n-r)/2}function y(e,t,n){let r=s(e),i=c(e);switch(r){case`bottom`:return{x:v(i,t.x,t.width,n.width),y:t.y+t.height};case`left`:return{x:t.x-n.width,y:v(i,t.y,t.height,n.height)};case`right`:return{x:t.x+t.width,y:v(i,t.y,t.height,n.height)};case`top`:return{x:v(i,t.x,t.width,n.width),y:t.y-n.height}}}function b(e,t){return{floating:u(t.getBoundingClientRect()),reference:u(e.getBoundingClientRect())}}function x(e,t){return t?{...e,middlewareData:t.data?Object.assign(Object.create(null),e.middlewareData,t.data):e.middlewareData,placement:t.placement??e.placement,x:t.x??e.x,y:t.y??e.y}:e}var S=8;function C(e,t,n){return Promise.resolve().then(()=>T(e,t,n))}function w(e,t,n){return new Promise((r,i)=>{requestAnimationFrame(()=>{try{r(T(e,t,n))}catch(e){i(e)}})})}function T(e,t,{boundary:r,containingBlock:o,middleware:s=[],padding:c,placement:l=`bottom`}={}){let u=s.filter(Boolean);e===t&&i(`computePosition: reference and floating are the same element.`),h(u.map(e=>{let t=e[g];return typeof t==`string`?t:null}));let d=l,f={},p=b(e,t);a(()=>{p.floating.width===0&&p.floating.height===0&&i(`computePosition: floating element has zero dimensions — is it hidden or detached from the DOM?`);let e=getComputedStyle(t).position;e!==`fixed`&&e!==`absolute`&&i(`computePosition: floating element has \`position: ${e}\`. Orbit computes viewport-relative coordinates and expects position: fixed (or absolute for scoped stacking contexts).`)});for(let n=0;n<S;n+=1){let n={...y(d,p.reference,p.floating),boundary:r,elements:{floating:t,reference:e},initialPlacement:l,middlewareData:f,padding:c,placement:d,rects:p},i;for(let e of u){let t=e(n);if(n=x(n,t),f=n.middlewareData,i=t?.reset,i)break}if(!i){let e={middlewareData:n.middlewareData,placement:n.placement,x:n.x,y:n.y};if(o){let t=o.getBoundingClientRect();return{...e,x:e.x-t.x,y:e.y-t.y}}return e}i.remeasure?p=b(e,t):i.rects!=null&&(p=i.rects),d=i.placement??n.placement}throw new n(`Middleware triggered too many resets in a single compute cycle.`)}function E(){let e=window.visualViewport;return e?{height:e.height,width:e.width,x:e.offsetLeft,y:e.offsetTop}:{height:window.innerHeight,width:window.innerWidth,x:0,y:0}}function ee(e){if(!e)return E();if(e instanceof Element){let t=e.getBoundingClientRect();return{height:t.height,width:t.width,x:t.x,y:t.y}}return e}var D=/(hidden|clip|scroll|auto|overlay)/;function O(e,t){let n=Math.max(e.x,t.x),r=Math.max(e.y,t.y),i=Math.min(e.x+e.width,t.x+t.width),a=Math.min(e.y+e.height,t.y+t.height);return{height:Math.max(0,a-r),width:Math.max(0,i-n),x:n,y:r}}function k(e){let t=p(e),n=E();for(;t;){let e=getComputedStyle(t);if(D.test(`${e.overflow}${e.overflowX}${e.overflowY}`)){let e=t.getBoundingClientRect();n=O(n,{height:e.height,width:e.width,x:e.x,y:e.y})}t=p(t)}return n}function A(e,t){return{boundary:ee(e.boundary??t.boundary),padding:d(e.padding??t.padding)}}function j(e){return{...e.rects.floating,x:e.x,y:e.y}}function M(e,t,n){return{bottom:e.y+e.height-(t.y+t.height-n.bottom),left:t.x+n.left-e.x,right:e.x+e.width-(t.x+t.width-n.right),top:t.y+n.top-e.y}}function N(e){return Math.max(e.top,0)+Math.max(e.right,0)+Math.max(e.bottom,0)+Math.max(e.left,0)}function P(e){return e.top>0||e.right>0||e.bottom>0||e.left>0}function F(e,t){return t.top>=e.height||t.right>=e.width||t.bottom>=e.height||t.left>=e.width}function I(e,t,n,r){let i=e.rects.reference;switch(s(t)){case`bottom`:return n.y+n.height-r.bottom-(i.y+i.height);case`left`:return i.x-(n.x+r.left);case`right`:return n.x+n.width-r.right-(i.x+i.width);case`top`:return i.y-(n.y+r.top)}}function L(e,t,n={}){let{x:r,y:i}=y(t,e.rects.reference,e.rects.floating),{boundary:a,padding:o}=A(n,e);return M({...e.rects.floating,x:r,y:i},a,o)}function R(e,t={}){let{boundary:n,padding:r}=A(t,e);return M(j(e),n,r)}var z=[`transform`,`perspective`,`filter`],B=[`layout`,`paint`,`strict`,`content`];function V(e){return e.transform!==`none`||e.perspective!==`none`||e.filter!==`none`||e.backdropFilter&&e.backdropFilter!==`none`||e.willChange!==`auto`&&z.some(t=>e.willChange.includes(t))?!0:e.contain!==`none`&&B.some(t=>e.contain.includes(t))}function H(e){let t=p(e);for(;t;){if(V(getComputedStyle(t)))return t;t=p(t)}return null}function U(e){let t=[],n=p(e);for(;n;){let e=getComputedStyle(n),r=e.overflow+e.overflowX+e.overflowY;/auto|scroll|overlay/.test(r)&&t.push(n),n=p(n)}return t}function W(t,n,r,{animationFrame:i=!1,observeAncestors:a=!0,observeFloating:o=!0,observeVisualViewport:s=!0,pauseWhenHidden:c=!0,throttle:l=0}={}){let u=l>0?(0,e.throttle)(r,l,{leading:!0,trailing:!0}):null,d=u??r,p=!0,m=()=>{p&&d()};d();let h=[];if(c&&f(t)&&typeof IntersectionObserver<`u`){let e=new IntersectionObserver(e=>{p=e.at(-1)?.isIntersecting??!0,p&&d()});e.observe(t),h.push(()=>e.disconnect())}if(f(t)&&a){let e=U(t);for(let t of e)t.addEventListener(`scroll`,m,{passive:!0}),h.push(()=>t.removeEventListener(`scroll`,m));window.addEventListener(`scroll`,m,{passive:!0}),h.push(()=>window.removeEventListener(`scroll`,m))}else{let e=e=>{e.composedPath().includes(n)||m()};window.addEventListener(`scroll`,e,{capture:!0,passive:!0}),h.push(()=>window.removeEventListener(`scroll`,e,{capture:!0}))}window.addEventListener(`resize`,m,{passive:!0}),h.push(()=>window.removeEventListener(`resize`,m));let g=s?window.visualViewport:null;g&&(g.addEventListener(`resize`,m,{passive:!0}),g.addEventListener(`scroll`,m,{passive:!0}),h.push(()=>{g.removeEventListener(`resize`,m),g.removeEventListener(`scroll`,m)}));let _=new ResizeObserver(m);f(t)&&_.observe(t),o&&_.observe(n),h.push(()=>_.disconnect());let v=0;if(i){let e=()=>{m(),v=window.requestAnimationFrame(e)};v=window.requestAnimationFrame(e),h.push(()=>window.cancelAnimationFrame(v))}return()=>{u?.cancel();for(let e of h)e()}}function G(e,t,n){let r=new AbortController,i=!1;return{get disposalSignal(){return r.signal},dispose(){i||(i=!0,r.abort(),e())},get disposed(){return i},getPosition:t,[Symbol.dispose](){this.dispose()},update:n}}function K(){return typeof CSS<`u`&&CSS.supports(`anchor-name`,`--orbit`)}var q=0,J={bottom:`block-end center`,"bottom-end":`block-end span-inline-end`,"bottom-start":`block-end span-inline-start`,left:`inline-start center`,"left-end":`inline-start span-block-end`,"left-start":`inline-start span-block-start`,right:`inline-end center`,"right-end":`inline-end span-block-end`,"right-start":`inline-end span-block-start`,top:`block-start center`,"top-end":`block-start span-inline-end`,"top-start":`block-start span-inline-start`};function Y(e,t){let n={};for(let r of Object.keys(t)){let i=e.style.getPropertyValue(r);n[r]=i===``?void 0:i,e.style.setProperty(r,t[r])}return()=>{for(let r of Object.keys(t)){let t=n[r];t===void 0?e.style.removeProperty(r):e.style.setProperty(r,t)}}}function X(e,t,n,r){let i=`--orbit-${++q}`,a=Y(e,{"anchor-name":i}),o=Y(t,{position:`fixed`,"position-anchor":i,"position-area":J[n],"position-try-fallbacks":r});return()=>{a(),o()}}function te(e,t,{fallbacks:n=`flip-block, flip-inline, flip-block flip-inline`,placement:r=`bottom`}={}){let i=X(e,t,r,n),a=G(()=>i(),()=>null,()=>{});return Object.assign(a,{cssAnchor:!0})}function Z(e,t){t.style.left=`${e.x}px`,t.style.top=`${e.y}px`}function Q(e,t,{apply:n,autoUpdate:r={},boundary:i,containingBlock:a,middleware:o,padding:s,placement:c=`bottom`}={}){let l=null,u=n??(e=>Z(e,t));function d(){let n=T(e,t,{boundary:i,containingBlock:a,middleware:o,padding:s,placement:c});l=n,u(n)}if(r===!1)return d(),G(()=>{},()=>l,d);let f=W(e,t,d,r);return G(()=>f(),()=>l,d)}function ne(...e){return e.filter(Boolean)}function re({element:t,padding:n=0}){function r(r){let i=s(r.placement),a=d(n),o=u(t.getBoundingClientRect());if(i===`top`||i===`bottom`){let t=r.rects.reference.x+r.rects.reference.width/2-r.x-o.width/2,n=a.left,i=(0,e.clamp)(t,n,Math.max(n,r.rects.floating.width-o.width-a.right));return{data:{arrow:{centerOffset:t-i,constrained:i!==t,x:i}}}}let c=r.rects.reference.y+r.rects.reference.height/2-r.y-o.height/2,l=a.top,f=(0,e.clamp)(c,l,Math.max(l,r.rects.floating.height-o.height-a.bottom));return{data:{arrow:{centerOffset:c-f,constrained:f!==c,y:f}}}}return _(r,`arrow`)}var $=[`top`,`right`,`bottom`,`left`];function ie(e){return e===void 0?$:e===null?$.flatMap(e=>[e,`${e}-start`,`${e}-end`]):$.map(t=>`${t}-${e}`)}function ae(e={}){return _(function(t){let{boundary:n,padding:r}=A(e,t),a=e.allowedPlacements??ie(e.alignment);a.length===0&&i(`autoPlacement: allowedPlacements is empty — no placement will be evaluated.`);let o=t.placement,s=1/0,c=-1/0;for(let i of a){let a=N(L(t,i,e)),l=I(t,i,n,r);(a<s||a===s&&l>c)&&(o=i,s=a,c=l)}if(o!==t.placement)return{reset:{placement:o}}},`autoPlacement`)}function oe(e={}){function t(t){let n=R(t,e);if(!P(n))return;let r=s(t.placement),i=c(t.placement),a=e.fallbackPlacements??[l(o[r],i)],u=[t.placement],d=t.placement,f=N(n);for(let n of a){let r=L(t,n,e),i=N(r);if(!P(r))return{data:{flip:{skippedPlacements:u}},reset:{placement:n}};u.push(n),i<f&&(d=n,f=i)}if(d!==t.placement)return{data:{flip:{skippedPlacements:u}},reset:{placement:d}}}return _(t,`flip`)}function se(e={}){let t=e.strategy??`both`;function n(n){let{boundary:r,padding:i}=A(e,n),a={};if(t===`escaped`||t===`both`){let e=j(n),t=M(e,r,i);a.escaped=F(e,t),a.escapedOffsets=t}if(t===`referenceHidden`||t===`both`){let e=M(n.rects.reference,r,i);a.referenceHidden=F(n.rects.reference,e),a.referenceHiddenOffsets=e}return{data:{hide:a}}}return _(n,`hide`)}function ce(e){return!(`getClientRects`in e)||typeof e.getClientRects!=`function`?[]:Array.from(e.getClientRects()).map(u).filter(e=>e.width>0||e.height>0)}function le(e,t,n,r){return t>=e.x-r.left&&t<=e.x+e.width+r.right&&n>=e.y-r.top&&n<=e.y+e.height+r.bottom}function ue(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function de(e={}){function t(t){let n=ce(t.elements.reference);if(n.length<=1)return;let r=d(e.padding??2),i=s(t.placement),a=n[0];if(e.x!=null&&e.y!=null)a=n.find(t=>le(t,e.x,e.y,r))??a;else if(i===`top`||i===`bottom`){let e=t.x+t.rects.floating.width/2;a=n.reduce((t,n)=>{let r=Math.abs(t.x+t.width/2-e);return Math.abs(n.x+n.width/2-e)<r?n:t},a)}else{let e=t.y+t.rects.floating.height/2;a=n.reduce((t,n)=>{let r=Math.abs(t.y+t.height/2-e);return Math.abs(n.y+n.height/2-e)<r?n:t},a)}if(!ue(a,t.rects.reference))return{reset:{rects:{...t.rects,reference:a}}}}return _(t,`inline`)}function fe(e,t){let n=typeof e==`function`?e(t):e;return typeof n==`number`?{crossAxis:0,mainAxis:n}:{crossAxis:n.crossAxis??0,mainAxis:n.mainAxis??0}}function pe(e){return _(function(t){let n=s(t.placement),{crossAxis:r,mainAxis:i}=fe(e,t);switch(n){case`bottom`:return{x:t.x+r,y:t.y+i};case`left`:return{x:t.x-i,y:t.y+r};case`right`:return{x:t.x+i,y:t.y+r};case`top`:return{x:t.x+r,y:t.y-i}}},`offset`)}function me(t={}){return(n,r)=>{let{placement:i,rects:a,x:o,y:c}=n,l=s(i),u=l===`top`||l===`bottom`,d=typeof t.offset==`function`?t.offset(n):t.offset??0;if(u){let t=a.reference.x-d,n=a.reference.x+a.reference.width+d-a.floating.width,[i,s]=t<=n?[t,n]:[n,t],c=(0,e.clamp)(o+r.crossAxis,i,s);return{...r,crossAxis:c-o}}let f=a.reference.y-d,p=a.reference.y+a.reference.height+d-a.floating.height,[m,h]=f<=p?[f,p]:[p,f],g=(0,e.clamp)(c+r.crossAxis,m,h);return{...r,crossAxis:g-c}}}function he(e={}){let{crossAxis:t=!0,limiter:n,mainAxis:r=!1}=e;function i(i){let a=R(i,e),o=s(i.placement),c=o===`top`||o===`bottom`,l=Math.max(a.left,0)-Math.max(a.right,0),u=Math.max(a.top,0)-Math.max(a.bottom,0),d=c?t:r,f=c?r:t,p=d?l:0,m=f?u:0;if(n){let e=n(i,{crossAxis:c?p:m,mainAxis:c?m:p});p=c?e.crossAxis:e.mainAxis,m=c?e.mainAxis:e.crossAxis}return{data:{shift:{x:p,y:m}},x:i.x+p,y:i.y+m}}return _(i,`shift`)}function ge(e={}){function t(t){let{boundary:n,padding:r}=A(e,t),i=s(t.placement),a=n.y+r.top,o=n.x+n.width-r.right,c=n.y+n.height-r.bottom,l=n.x+r.left;return{data:{size:{availableHeight:i===`bottom`?Math.max(0,c-t.y):i===`top`?Math.max(0,t.rects.reference.y-a):Math.max(0,c-a),availableWidth:i===`right`?Math.max(0,o-t.x):i===`left`?Math.max(0,t.rects.reference.x-l):Math.max(0,o-l)}}}}return _(t,`size`)}exports.OrbitConfigError=n,exports.OrbitError=t,exports.arrow=re,exports.autoPlacement=ae,exports.autoUpdate=W,exports.compose=ne,exports.computePosition=T,exports.computePositionAsync=C,exports.computePositionRaf=w,exports.detectOverflow=R,exports.flip=oe,exports.float=Q,exports.floatWithAnchor=te,exports.getAlignment=c,exports.getClippingAncestorRect=k,exports.getContainingBlock=H,exports.getRects=b,exports.getSide=s,exports.hide=se,exports.inline=de,exports.isCssAnchorSupported=K,exports.limitShift=me,exports.offset=pe,exports.shift=he,exports.size=ge;
|
|
2
2
|
//# sourceMappingURL=orbit.cjs.map
|