@vielzeug/orbit 2.0.2 → 2.1.0

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/core.cjs CHANGED
@@ -1,2 +1,2 @@
1
- const e=require("./utils.cjs");require("./_dev.cjs");const t=require("./errors.cjs");function n(t,n){return{floating:e.toRect(n.getBoundingClientRect()),reference:e.toRect(t.getBoundingClientRect())}}function r(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 i=8;function a(e,t,n){return Promise.resolve().then(()=>s(e,t,n))}function o(e,t,n){return new Promise((r,i)=>{requestAnimationFrame(()=>{try{r(s(e,t,n))}catch(e){i(e)}})})}function s(a,o,{boundary:s,containingBlock:c,middleware:l=[],padding:u,placement:d=`bottom`}={}){let f=l,p=d,m={},h=n(a,o);for(let t=0;t<i;t+=1){let t={...e.baseCoords(p,h.reference,h.floating),boundary:s,elements:{floating:o,reference:a},initialPlacement:d,middlewareData:m,padding:u,placement:p,rects:h},i;for(let e of f){let n=e(t);if(t=r(t,n),m=t.middlewareData,i=n?.reset,i)break}if(!i){let e={middlewareData:t.middlewareData,placement:t.placement,x:t.x,y:t.y};if(c){let t=c.getBoundingClientRect();return{...e,x:e.x-t.x,y:e.y-t.y}}return e}i.remeasure?h=n(a,o):i.rects!=null&&(h=i.rects),p=i.placement??t.placement}throw new t.OrbitConfigError(`Middleware triggered too many resets in a single compute cycle.`)}exports.computePosition=s,exports.computePositionAsync=a,exports.computePositionRaf=o,exports.getRects=n;
1
+ const e=require("./utils.cjs");require("./_dev.cjs");const t=require("./errors.cjs");function n(t,n){return{floating:e.toRect(n.getBoundingClientRect()),reference:e.toRect(t.getBoundingClientRect())}}function r(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 i=8;function a(a,o,{boundary:s,containingBlock:c,middleware:l=[],padding:u,placement:d=`bottom`}={}){let f=l,p=d,m={},h=n(a,o);for(let t=0;t<i;t+=1){let t={...e.baseCoords(p,h.reference,h.floating),boundary:s,elements:{floating:o,reference:a},initialPlacement:d,middlewareData:m,padding:u,placement:p,rects:h},i;for(let e of f){let n=e(t);if(t=r(t,n),m=t.middlewareData,i=n?.reset,i)break}if(!i){let e={middlewareData:t.middlewareData,placement:t.placement,x:t.x,y:t.y};if(c){let t=c.getBoundingClientRect();return{...e,x:e.x-t.x,y:e.y-t.y}}return e}i.remeasure?h=n(a,o):i.rects!=null&&(h=i.rects),p=i.placement??t.placement}throw new t.OrbitConfigError(`Middleware triggered too many resets in a single compute cycle.`)}exports.computePosition=a;
2
2
  //# sourceMappingURL=core.cjs.map
package/dist/core.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"core.cjs","names":[],"sources":["../src/core.ts"],"sourcesContent":["import { devOnly, warn } from './_dev';\nimport { OrbitConfigError } from './errors';\nimport type {\n ComputePositionOptions,\n ComputePositionResult,\n MiddlewareData,\n MiddlewareReset,\n MiddlewareResult,\n MiddlewareState,\n ReferenceElement,\n} from './types';\nimport { baseCoords, toRect } from './utils';\n\n// ── DOM helpers ────────────────────────────────────────────────────────────────────────────────\n\n/** Reads the bounding rects of the reference and floating elements from the DOM. */\nexport function getRects(reference: ReferenceElement, floating: HTMLElement): MiddlewareState['rects'] {\n return {\n floating: toRect(floating.getBoundingClientRect()),\n reference: toRect(reference.getBoundingClientRect()),\n };\n}\n\n// ── Internal state helpers ───────────────────────────────────────────────────────────\n\nfunction mergeState(state: MiddlewareState, result: MiddlewareResult | undefined): MiddlewareState {\n if (!result) return state;\n\n return {\n ...state,\n middlewareData: result.data\n ? (Object.assign(Object.create(null), state.middlewareData, result.data) as MiddlewareData)\n : state.middlewareData,\n placement: result.placement ?? state.placement,\n x: result.x ?? state.x,\n y: result.y ?? state.y,\n };\n}\n\n// ── Constants ─────────────────────────────────────────────────────────────────────────────────\n\n/** Maximum number of pipeline restarts allowed per `computePosition` call before throwing. */\nconst MAX_RESETS = 8;\n\n// ── Public API ────────────────────────────────────────────────────────────────────────────────\n\n/**\n * Deferred position computation. Runs `computePosition` in the next **microtask** and\n * returns a `Promise<ComputePositionResult>`.\n *\n * Useful for async component lifecycles (e.g. `await nextTick()` in Vue/React) where the\n * synchronous `computePosition` would read stale DOM measurements because layout has not been\n * committed yet. Note: this defers to the microtask queue, not the next animation frame — if you\n * need post-layout measurements use `requestAnimationFrame` instead.\n *\n * @example\n * ```ts\n * const result = await computePositionAsync(reference, floating, { placement: 'top' });\n * floating.style.left = `${result.x}px`;\n * floating.style.top = `${result.y}px`;\n * ```\n */\nexport function computePositionAsync(\n reference: ReferenceElement,\n floating: HTMLElement,\n options?: ComputePositionOptions,\n): Promise<ComputePositionResult> {\n return Promise.resolve().then(() => computePosition(reference, floating, options));\n}\n\n/**\n * Deferred position computation. Runs `computePosition` in the next **animation frame** and\n * returns a `Promise<ComputePositionResult>`.\n *\n * Useful when the layout has not yet committed (e.g. immediately after DOM insertion). Unlike\n * `computePositionAsync` which defers to the microtask queue, this waits for the next\n * `requestAnimationFrame` tick — guaranteeing post-layout DOM measurements.\n *\n * @example\n * ```ts\n * const result = await computePositionRaf(reference, floating, { placement: 'top' });\n * floating.style.left = `${result.x}px`;\n * floating.style.top = `${result.y}px`;\n * ```\n */\nexport function computePositionRaf(\n reference: ReferenceElement,\n floating: HTMLElement,\n options?: ComputePositionOptions,\n): Promise<ComputePositionResult> {\n return new Promise((resolve, reject) => {\n requestAnimationFrame(() => {\n try {\n resolve(computePosition(reference, floating, options));\n } catch (err) {\n reject(err);\n }\n });\n });\n}\n\n/**\n * Runs the middleware pipeline and returns the final position.\n *\n * Position is computed in viewport-relative coordinates assuming `position: fixed`.\n */\nexport function computePosition(\n reference: ReferenceElement,\n floating: HTMLElement,\n { boundary, containingBlock, middleware = [], padding, placement = 'bottom' }: ComputePositionOptions = {},\n): ComputePositionResult {\n const mws = middleware;\n\n if (reference === floating) {\n warn('computePosition: reference and floating are the same element.');\n }\n\n let currentPlacement = placement;\n let middlewareData: MiddlewareData = {};\n let rects = getRects(reference, floating);\n\n devOnly(() => {\n if (rects.floating.width === 0 && rects.floating.height === 0) {\n warn('computePosition: floating element has zero dimensions — is it hidden or detached from the DOM?');\n }\n\n const pos = getComputedStyle(floating).position;\n\n if (pos !== 'fixed' && pos !== 'absolute') {\n warn(\n `computePosition: floating element has \\`position: ${pos}\\`. ` +\n 'Orbit computes viewport-relative coordinates and expects position: fixed ' +\n '(or absolute for scoped stacking contexts).',\n );\n }\n });\n\n for (let resets = 0; resets < MAX_RESETS; resets += 1) {\n let state: MiddlewareState = {\n ...baseCoords(currentPlacement, rects.reference, rects.floating),\n boundary,\n elements: { floating, reference },\n initialPlacement: placement,\n middlewareData,\n padding,\n placement: currentPlacement,\n rects,\n };\n\n let reset: MiddlewareReset | undefined;\n\n for (const mw of mws) {\n const result = mw(state);\n\n state = mergeState(state, result);\n middlewareData = state.middlewareData;\n reset = result?.reset;\n\n if (reset) break;\n }\n\n if (!reset) {\n const result: ComputePositionResult = {\n middlewareData: state.middlewareData,\n placement: state.placement,\n x: state.x,\n y: state.y,\n };\n\n if (containingBlock) {\n const cb = containingBlock.getBoundingClientRect();\n\n return { ...result, x: result.x - cb.x, y: result.y - cb.y };\n }\n\n return result;\n }\n\n if (reset.remeasure) {\n rects = getRects(reference, floating);\n } else if (reset.rects != null) {\n rects = reset.rects;\n }\n\n currentPlacement = reset.placement ?? state.placement;\n }\n\n throw new OrbitConfigError('Middleware triggered too many resets in a single compute cycle.');\n}\n"],"mappings":"qFAgBA,SAAgB,EAAS,EAA6B,EAAiD,CACrG,MAAO,CACL,SAAU,EAAA,OAAO,EAAS,sBAAsB,CAAC,EACjD,UAAW,EAAA,OAAO,EAAU,sBAAsB,CAAC,CACrD,CACF,CAIA,SAAS,EAAW,EAAwB,EAAuD,CAGjG,OAFK,EA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AAG,EAAM,CACX,EAEA,GAAI,EAAiB,CACnB,IAAM,EAAK,EAAgB,sBAAsB,EAEjD,MAAO,CAAE,GAAG,EAAQ,EAAG,EAAO,EAAI,EAAG,EAAG,EAAG,EAAO,EAAI,EAAG,CAAE,CAC7D,CAEA,OAAO,CACT,CAEI,EAAM,UACR,EAAQ,EAAS,EAAW,CAAQ,EAC3B,EAAM,OAAS,OACxB,EAAQ,EAAM,OAGhB,EAAmB,EAAM,WAAa,EAAM,SAC9C,CAEA,MAAM,IAAI,EAAA,iBAAiB,iEAAiE,CAC9F"}
1
+ {"version":3,"file":"core.cjs","names":[],"sources":["../src/core.ts"],"sourcesContent":["import { devOnly, warn } from './_dev';\nimport { OrbitConfigError } from './errors';\nimport type {\n ComputePositionOptions,\n ComputePositionResult,\n MiddlewareData,\n MiddlewareReset,\n MiddlewareResult,\n MiddlewareState,\n ReferenceElement,\n} from './types';\nimport { baseCoords, toRect } from './utils';\n\n// ── DOM helpers ────────────────────────────────────────────────────────────────────────────────\n\n/** Reads the bounding rects of the reference and floating elements from the DOM. */\nfunction getRects(reference: ReferenceElement, floating: HTMLElement): MiddlewareState['rects'] {\n return {\n floating: toRect(floating.getBoundingClientRect()),\n reference: toRect(reference.getBoundingClientRect()),\n };\n}\n\n// ── Internal state helpers ───────────────────────────────────────────────────────────\n\nfunction mergeState(state: MiddlewareState, result: MiddlewareResult | undefined): MiddlewareState {\n if (!result) return state;\n\n return {\n ...state,\n middlewareData: result.data\n ? (Object.assign(Object.create(null), state.middlewareData, result.data) as MiddlewareData)\n : state.middlewareData,\n placement: result.placement ?? state.placement,\n x: result.x ?? state.x,\n y: result.y ?? state.y,\n };\n}\n\n// ── Constants ─────────────────────────────────────────────────────────────────────────────────\n\n/** Maximum number of pipeline restarts allowed per `computePosition` call before throwing. */\nconst MAX_RESETS = 8;\n\n// ── Public API ────────────────────────────────────────────────────────────────────────────────\n\n/**\n * Runs the middleware pipeline and returns the final position.\n *\n * Position is computed in viewport-relative coordinates assuming `position: fixed`.\n */\nexport function computePosition(\n reference: ReferenceElement,\n floating: HTMLElement,\n { boundary, containingBlock, middleware = [], padding, placement = 'bottom' }: ComputePositionOptions = {},\n): ComputePositionResult {\n const mws = middleware;\n\n if (reference === floating) {\n warn('computePosition: reference and floating are the same element.');\n }\n\n let currentPlacement = placement;\n let middlewareData: MiddlewareData = {};\n let rects = getRects(reference, floating);\n\n devOnly(() => {\n if (rects.floating.width === 0 && rects.floating.height === 0) {\n warn('computePosition: floating element has zero dimensions — is it hidden or detached from the DOM?');\n }\n\n const pos = getComputedStyle(floating).position;\n\n if (pos !== 'fixed' && pos !== 'absolute') {\n warn(\n `computePosition: floating element has \\`position: ${pos}\\`. ` +\n 'Orbit computes viewport-relative coordinates and expects position: fixed ' +\n '(or absolute for scoped stacking contexts).',\n );\n }\n });\n\n for (let resets = 0; resets < MAX_RESETS; resets += 1) {\n let state: MiddlewareState = {\n ...baseCoords(currentPlacement, rects.reference, rects.floating),\n boundary,\n elements: { floating, reference },\n initialPlacement: placement,\n middlewareData,\n padding,\n placement: currentPlacement,\n rects,\n };\n\n let reset: MiddlewareReset | undefined;\n\n for (const mw of mws) {\n const result = mw(state);\n\n state = mergeState(state, result);\n middlewareData = state.middlewareData;\n reset = result?.reset;\n\n if (reset) break;\n }\n\n if (!reset) {\n const result: ComputePositionResult = {\n middlewareData: state.middlewareData,\n placement: state.placement,\n x: state.x,\n y: state.y,\n };\n\n if (containingBlock) {\n const cb = containingBlock.getBoundingClientRect();\n\n return { ...result, x: result.x - cb.x, y: result.y - cb.y };\n }\n\n return result;\n }\n\n if (reset.remeasure) {\n rects = getRects(reference, floating);\n } else if (reset.rects != null) {\n rects = reset.rects;\n }\n\n currentPlacement = reset.placement ?? state.placement;\n }\n\n throw new OrbitConfigError('Middleware triggered too many resets in a single compute cycle.');\n}\n"],"mappings":"qFAgBA,SAAS,EAAS,EAA6B,EAAiD,CAC9F,MAAO,CACL,SAAU,EAAA,OAAO,EAAS,sBAAsB,CA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CAAQ,EAC3B,EAAM,OAAS,OACxB,EAAQ,EAAM,OAGhB,EAAmB,EAAM,WAAa,EAAM,SAC9C,CAEA,MAAM,IAAI,EAAA,iBAAiB,iEAAiE,CAC9F"}
package/dist/core.d.ts CHANGED
@@ -1,39 +1,4 @@
1
- import type { ComputePositionOptions, ComputePositionResult, MiddlewareState, ReferenceElement } from './types';
2
- /** Reads the bounding rects of the reference and floating elements from the DOM. */
3
- export declare function getRects(reference: ReferenceElement, floating: HTMLElement): MiddlewareState['rects'];
4
- /**
5
- * Deferred position computation. Runs `computePosition` in the next **microtask** and
6
- * returns a `Promise<ComputePositionResult>`.
7
- *
8
- * Useful for async component lifecycles (e.g. `await nextTick()` in Vue/React) where the
9
- * synchronous `computePosition` would read stale DOM measurements because layout has not been
10
- * committed yet. Note: this defers to the microtask queue, not the next animation frame — if you
11
- * need post-layout measurements use `requestAnimationFrame` instead.
12
- *
13
- * @example
14
- * ```ts
15
- * const result = await computePositionAsync(reference, floating, { placement: 'top' });
16
- * floating.style.left = `${result.x}px`;
17
- * floating.style.top = `${result.y}px`;
18
- * ```
19
- */
20
- export declare function computePositionAsync(reference: ReferenceElement, floating: HTMLElement, options?: ComputePositionOptions): Promise<ComputePositionResult>;
21
- /**
22
- * Deferred position computation. Runs `computePosition` in the next **animation frame** and
23
- * returns a `Promise<ComputePositionResult>`.
24
- *
25
- * Useful when the layout has not yet committed (e.g. immediately after DOM insertion). Unlike
26
- * `computePositionAsync` which defers to the microtask queue, this waits for the next
27
- * `requestAnimationFrame` tick — guaranteeing post-layout DOM measurements.
28
- *
29
- * @example
30
- * ```ts
31
- * const result = await computePositionRaf(reference, floating, { placement: 'top' });
32
- * floating.style.left = `${result.x}px`;
33
- * floating.style.top = `${result.y}px`;
34
- * ```
35
- */
36
- export declare function computePositionRaf(reference: ReferenceElement, floating: HTMLElement, options?: ComputePositionOptions): Promise<ComputePositionResult>;
1
+ import type { ComputePositionOptions, ComputePositionResult, ReferenceElement } from './types';
37
2
  /**
38
3
  * Runs the middleware pipeline and returns the final position.
39
4
  *
@@ -1 +1 @@
1
- {"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,sBAAsB,EACtB,qBAAqB,EAIrB,eAAe,EACf,gBAAgB,EACjB,MAAM,SAAS,CAAC;AAKjB,oFAAoF;AACpF,wBAAgB,QAAQ,CAAC,SAAS,EAAE,gBAAgB,EAAE,QAAQ,EAAE,WAAW,GAAG,eAAe,CAAC,OAAO,CAAC,CAKrG;AAyBD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,gBAAgB,EAC3B,QAAQ,EAAE,WAAW,EACrB,OAAO,CAAC,EAAE,sBAAsB,GAC/B,OAAO,CAAC,qBAAqB,CAAC,CAEhC;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,gBAAgB,EAC3B,QAAQ,EAAE,WAAW,EACrB,OAAO,CAAC,EAAE,sBAAsB,GAC/B,OAAO,CAAC,qBAAqB,CAAC,CAUhC;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,SAAS,EAAE,gBAAgB,EAC3B,QAAQ,EAAE,WAAW,EACrB,EAAE,QAAQ,EAAE,eAAe,EAAE,UAAe,EAAE,OAAO,EAAE,SAAoB,EAAE,GAAE,sBAA2B,GACzG,qBAAqB,CA8EvB"}
1
+ {"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,sBAAsB,EACtB,qBAAqB,EAKrB,gBAAgB,EACjB,MAAM,SAAS,CAAC;AAoCjB;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,SAAS,EAAE,gBAAgB,EAC3B,QAAQ,EAAE,WAAW,EACrB,EAAE,QAAQ,EAAE,eAAe,EAAE,UAAe,EAAE,OAAO,EAAE,SAAoB,EAAE,GAAE,sBAA2B,GACzG,qBAAqB,CA8EvB"}
package/dist/core.js CHANGED
@@ -1,2 +1,2 @@
1
- import{baseCoords as e,toRect as t}from"./utils.js";import"./_dev.js";import{OrbitConfigError as n}from"./errors.js";function r(e,n){return{floating:t(n.getBoundingClientRect()),reference:t(e.getBoundingClientRect())}}function i(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 a=8;function o(e,t,n){return Promise.resolve().then(()=>c(e,t,n))}function s(e,t,n){return new Promise((r,i)=>{requestAnimationFrame(()=>{try{r(c(e,t,n))}catch(e){i(e)}})})}function c(t,o,{boundary:s,containingBlock:c,middleware:l=[],padding:u,placement:d=`bottom`}={}){let f=l,p=d,m={},h=r(t,o);for(let n=0;n<a;n+=1){let n={...e(p,h.reference,h.floating),boundary:s,elements:{floating:o,reference:t},initialPlacement:d,middlewareData:m,padding:u,placement:p,rects:h},a;for(let e of f){let t=e(n);if(n=i(n,t),m=n.middlewareData,a=t?.reset,a)break}if(!a){let e={middlewareData:n.middlewareData,placement:n.placement,x:n.x,y:n.y};if(c){let t=c.getBoundingClientRect();return{...e,x:e.x-t.x,y:e.y-t.y}}return e}a.remeasure?h=r(t,o):a.rects!=null&&(h=a.rects),p=a.placement??n.placement}throw new n(`Middleware triggered too many resets in a single compute cycle.`)}export{c as computePosition,o as computePositionAsync,s as computePositionRaf,r as getRects};
1
+ import{baseCoords as e,toRect as t}from"./utils.js";import"./_dev.js";import{OrbitConfigError as n}from"./errors.js";function r(e,n){return{floating:t(n.getBoundingClientRect()),reference:t(e.getBoundingClientRect())}}function i(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 a=8;function o(t,o,{boundary:s,containingBlock:c,middleware:l=[],padding:u,placement:d=`bottom`}={}){let f=l,p=d,m={},h=r(t,o);for(let n=0;n<a;n+=1){let n={...e(p,h.reference,h.floating),boundary:s,elements:{floating:o,reference:t},initialPlacement:d,middlewareData:m,padding:u,placement:p,rects:h},a;for(let e of f){let t=e(n);if(n=i(n,t),m=n.middlewareData,a=t?.reset,a)break}if(!a){let e={middlewareData:n.middlewareData,placement:n.placement,x:n.x,y:n.y};if(c){let t=c.getBoundingClientRect();return{...e,x:e.x-t.x,y:e.y-t.y}}return e}a.remeasure?h=r(t,o):a.rects!=null&&(h=a.rects),p=a.placement??n.placement}throw new n(`Middleware triggered too many resets in a single compute cycle.`)}export{o as computePosition};
2
2
  //# sourceMappingURL=core.js.map
package/dist/core.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"core.js","names":[],"sources":["../src/core.ts"],"sourcesContent":["import { devOnly, warn } from './_dev';\nimport { OrbitConfigError } from './errors';\nimport type {\n ComputePositionOptions,\n ComputePositionResult,\n MiddlewareData,\n MiddlewareReset,\n MiddlewareResult,\n MiddlewareState,\n ReferenceElement,\n} from './types';\nimport { baseCoords, toRect } from './utils';\n\n// ── DOM helpers ────────────────────────────────────────────────────────────────────────────────\n\n/** Reads the bounding rects of the reference and floating elements from the DOM. */\nexport function getRects(reference: ReferenceElement, floating: HTMLElement): MiddlewareState['rects'] {\n return {\n floating: toRect(floating.getBoundingClientRect()),\n reference: toRect(reference.getBoundingClientRect()),\n };\n}\n\n// ── Internal state helpers ───────────────────────────────────────────────────────────\n\nfunction mergeState(state: MiddlewareState, result: MiddlewareResult | undefined): MiddlewareState {\n if (!result) return state;\n\n return {\n ...state,\n middlewareData: result.data\n ? (Object.assign(Object.create(null), state.middlewareData, result.data) as MiddlewareData)\n : state.middlewareData,\n placement: result.placement ?? state.placement,\n x: result.x ?? state.x,\n y: result.y ?? state.y,\n };\n}\n\n// ── Constants ─────────────────────────────────────────────────────────────────────────────────\n\n/** Maximum number of pipeline restarts allowed per `computePosition` call before throwing. */\nconst MAX_RESETS = 8;\n\n// ── Public API ────────────────────────────────────────────────────────────────────────────────\n\n/**\n * Deferred position computation. Runs `computePosition` in the next **microtask** and\n * returns a `Promise<ComputePositionResult>`.\n *\n * Useful for async component lifecycles (e.g. `await nextTick()` in Vue/React) where the\n * synchronous `computePosition` would read stale DOM measurements because layout has not been\n * committed yet. Note: this defers to the microtask queue, not the next animation frame — if you\n * need post-layout measurements use `requestAnimationFrame` instead.\n *\n * @example\n * ```ts\n * const result = await computePositionAsync(reference, floating, { placement: 'top' });\n * floating.style.left = `${result.x}px`;\n * floating.style.top = `${result.y}px`;\n * ```\n */\nexport function computePositionAsync(\n reference: ReferenceElement,\n floating: HTMLElement,\n options?: ComputePositionOptions,\n): Promise<ComputePositionResult> {\n return Promise.resolve().then(() => computePosition(reference, floating, options));\n}\n\n/**\n * Deferred position computation. Runs `computePosition` in the next **animation frame** and\n * returns a `Promise<ComputePositionResult>`.\n *\n * Useful when the layout has not yet committed (e.g. immediately after DOM insertion). Unlike\n * `computePositionAsync` which defers to the microtask queue, this waits for the next\n * `requestAnimationFrame` tick — guaranteeing post-layout DOM measurements.\n *\n * @example\n * ```ts\n * const result = await computePositionRaf(reference, floating, { placement: 'top' });\n * floating.style.left = `${result.x}px`;\n * floating.style.top = `${result.y}px`;\n * ```\n */\nexport function computePositionRaf(\n reference: ReferenceElement,\n floating: HTMLElement,\n options?: ComputePositionOptions,\n): Promise<ComputePositionResult> {\n return new Promise((resolve, reject) => {\n requestAnimationFrame(() => {\n try {\n resolve(computePosition(reference, floating, options));\n } catch (err) {\n reject(err);\n }\n });\n });\n}\n\n/**\n * Runs the middleware pipeline and returns the final position.\n *\n * Position is computed in viewport-relative coordinates assuming `position: fixed`.\n */\nexport function computePosition(\n reference: ReferenceElement,\n floating: HTMLElement,\n { boundary, containingBlock, middleware = [], padding, placement = 'bottom' }: ComputePositionOptions = {},\n): ComputePositionResult {\n const mws = middleware;\n\n if (reference === floating) {\n warn('computePosition: reference and floating are the same element.');\n }\n\n let currentPlacement = placement;\n let middlewareData: MiddlewareData = {};\n let rects = getRects(reference, floating);\n\n devOnly(() => {\n if (rects.floating.width === 0 && rects.floating.height === 0) {\n warn('computePosition: floating element has zero dimensions — is it hidden or detached from the DOM?');\n }\n\n const pos = getComputedStyle(floating).position;\n\n if (pos !== 'fixed' && pos !== 'absolute') {\n warn(\n `computePosition: floating element has \\`position: ${pos}\\`. ` +\n 'Orbit computes viewport-relative coordinates and expects position: fixed ' +\n '(or absolute for scoped stacking contexts).',\n );\n }\n });\n\n for (let resets = 0; resets < MAX_RESETS; resets += 1) {\n let state: MiddlewareState = {\n ...baseCoords(currentPlacement, rects.reference, rects.floating),\n boundary,\n elements: { floating, reference },\n initialPlacement: placement,\n middlewareData,\n padding,\n placement: currentPlacement,\n rects,\n };\n\n let reset: MiddlewareReset | undefined;\n\n for (const mw of mws) {\n const result = mw(state);\n\n state = mergeState(state, result);\n middlewareData = state.middlewareData;\n reset = result?.reset;\n\n if (reset) break;\n }\n\n if (!reset) {\n const result: ComputePositionResult = {\n middlewareData: state.middlewareData,\n placement: state.placement,\n x: state.x,\n y: state.y,\n };\n\n if (containingBlock) {\n const cb = containingBlock.getBoundingClientRect();\n\n return { ...result, x: result.x - cb.x, y: result.y - cb.y };\n }\n\n return result;\n }\n\n if (reset.remeasure) {\n rects = getRects(reference, floating);\n } else if (reset.rects != null) {\n rects = reset.rects;\n }\n\n currentPlacement = reset.placement ?? state.placement;\n }\n\n throw new OrbitConfigError('Middleware triggered too many resets in a single compute cycle.');\n}\n"],"mappings":"qHAgBA,SAAgB,EAAS,EAA6B,EAAiD,CACrG,MAAO,CACL,SAAU,EAAO,EAAS,sBAAsB,CAAC,EACjD,UAAW,EAAO,EAAU,sBAAsB,CAAC,CACrD,CACF,CAIA,SAAS,EAAW,EAAwB,EAAuD,CAGjG,OAFK,EAEE,CACL,GAAG,EACH,eAAgB,EAAO,KAClB,OAAO,OAAO,OAAO,OAAO,IAAI,EAAG,EAAM,eAAgB,EAAO,IAAI,EACrE,EAAM,eACV,UAAW,EAAO,WAAa,EAAM,U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,EAAG,CAAE,CAC7D,CAEA,OAAO,CACT,CAEI,EAAM,UACR,EAAQ,EAAS,EAAW,CAAQ,EAC3B,EAAM,OAAS,OACxB,EAAQ,EAAM,OAGhB,EAAmB,EAAM,WAAa,EAAM,SAC9C,CAEA,MAAM,IAAI,EAAiB,iEAAiE,CAC9F"}
1
+ {"version":3,"file":"core.js","names":[],"sources":["../src/core.ts"],"sourcesContent":["import { devOnly, warn } from './_dev';\nimport { OrbitConfigError } from './errors';\nimport type {\n ComputePositionOptions,\n ComputePositionResult,\n MiddlewareData,\n MiddlewareReset,\n MiddlewareResult,\n MiddlewareState,\n ReferenceElement,\n} from './types';\nimport { baseCoords, toRect } from './utils';\n\n// ── DOM helpers ────────────────────────────────────────────────────────────────────────────────\n\n/** Reads the bounding rects of the reference and floating elements from the DOM. */\nfunction getRects(reference: ReferenceElement, floating: HTMLElement): MiddlewareState['rects'] {\n return {\n floating: toRect(floating.getBoundingClientRect()),\n reference: toRect(reference.getBoundingClientRect()),\n };\n}\n\n// ── Internal state helpers ───────────────────────────────────────────────────────────\n\nfunction mergeState(state: MiddlewareState, result: MiddlewareResult | undefined): MiddlewareState {\n if (!result) return state;\n\n return {\n ...state,\n middlewareData: result.data\n ? (Object.assign(Object.create(null), state.middlewareData, result.data) as MiddlewareData)\n : state.middlewareData,\n placement: result.placement ?? state.placement,\n x: result.x ?? state.x,\n y: result.y ?? state.y,\n };\n}\n\n// ── Constants ─────────────────────────────────────────────────────────────────────────────────\n\n/** Maximum number of pipeline restarts allowed per `computePosition` call before throwing. */\nconst MAX_RESETS = 8;\n\n// ── Public API ────────────────────────────────────────────────────────────────────────────────\n\n/**\n * Runs the middleware pipeline and returns the final position.\n *\n * Position is computed in viewport-relative coordinates assuming `position: fixed`.\n */\nexport function computePosition(\n reference: ReferenceElement,\n floating: HTMLElement,\n { boundary, containingBlock, middleware = [], padding, placement = 'bottom' }: ComputePositionOptions = {},\n): ComputePositionResult {\n const mws = middleware;\n\n if (reference === floating) {\n warn('computePosition: reference and floating are the same element.');\n }\n\n let currentPlacement = placement;\n let middlewareData: MiddlewareData = {};\n let rects = getRects(reference, floating);\n\n devOnly(() => {\n if (rects.floating.width === 0 && rects.floating.height === 0) {\n warn('computePosition: floating element has zero dimensions — is it hidden or detached from the DOM?');\n }\n\n const pos = getComputedStyle(floating).position;\n\n if (pos !== 'fixed' && pos !== 'absolute') {\n warn(\n `computePosition: floating element has \\`position: ${pos}\\`. ` +\n 'Orbit computes viewport-relative coordinates and expects position: fixed ' +\n '(or absolute for scoped stacking contexts).',\n );\n }\n });\n\n for (let resets = 0; resets < MAX_RESETS; resets += 1) {\n let state: MiddlewareState = {\n ...baseCoords(currentPlacement, rects.reference, rects.floating),\n boundary,\n elements: { floating, reference },\n initialPlacement: placement,\n middlewareData,\n padding,\n placement: currentPlacement,\n rects,\n };\n\n let reset: MiddlewareReset | undefined;\n\n for (const mw of mws) {\n const result = mw(state);\n\n state = mergeState(state, result);\n middlewareData = state.middlewareData;\n reset = result?.reset;\n\n if (reset) break;\n }\n\n if (!reset) {\n const result: ComputePositionResult = {\n middlewareData: state.middlewareData,\n placement: state.placement,\n x: state.x,\n y: state.y,\n };\n\n if (containingBlock) {\n const cb = containingBlock.getBoundingClientRect();\n\n return { ...result, x: result.x - cb.x, y: result.y - cb.y };\n }\n\n return result;\n }\n\n if (reset.remeasure) {\n rects = getRects(reference, floating);\n } else if (reset.rects != null) {\n rects = reset.rects;\n }\n\n currentPlacement = reset.placement ?? state.placement;\n }\n\n throw new OrbitConfigError('Middleware triggered too many resets in a single compute cycle.');\n}\n"],"mappings":"qHAgBA,SAAS,EAAS,EAA6B,EAAiD,CAC9F,MAAO,CACL,SAAU,EAAO,EAAS,sBAAsB,CAAC,EACjD,UAAW,EAAO,EAAU,sBAAsB,CAAC,CACrD,CACF,CAIA,SAAS,EAAW,EAAwB,EAAuD,CAGjG,OAFK,EAEE,CACL,GAAG,EACH,eAAgB,EAAO,KAClB,OAAO,OAAO,OAAO,OAAO,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.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./float.cjs");function t(e,t){for(let[n,r]of Object.entries(t))e.style.setProperty(n,r)}function n(){let e=document.createElement(`div`);return e.dataset.orbitDebug=``,t(e,{"font-family":`monospace`,"font-size":`11px`,left:`0`,"pointer-events":`none`,position:`fixed`,top:`0`,"z-index":`2147483647`}),e}function r(e,n,r){let i=document.createElement(`div`);return i.textContent=e,t(i,{background:`rgba(0,100,255,0.85)`,"border-radius":`3px`,color:`#fff`,left:`${n}px`,padding:`1px 6px`,position:`fixed`,top:`${Math.max(0,r)}px`,"white-space":`nowrap`}),i}function i(e,n,r,i,a){let o=document.createElement(`div`);return t(o,{border:`1.5px dashed ${a}`,height:`${i}px`,left:`${e}px`,position:`fixed`,top:`${n}px`,width:`${r}px`}),o}function a(t,a,o={}){let s=n();document.body.appendChild(s);function c(e){if(s.innerHTML=``,s.appendChild(i(1,1,window.innerWidth-2,window.innerHeight-2,`rgba(0,100,255,0.3)`)),t instanceof Element){let e=t.getBoundingClientRect();s.appendChild(i(e.left,e.top,e.width,e.height,`rgba(255,120,0,0.7)`))}let n=a.getBoundingClientRect();s.appendChild(r(e.placement,n.left,n.top-22))}let l=o.apply;function u(e){l?l(e):(a.style.left=`${e.x}px`,a.style.top=`${e.y}px`),c(e)}let d=e.createPositioner(t,a,{...o,apply:u}),f=d.dispose.bind(d);return d.start(),Object.assign(d,{dispose(){f(),s.remove()}})}exports.debugPositioner=a;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./float.cjs");function t(e,t){for(let[n,r]of Object.entries(t))e.style.setProperty(n,r)}function n(){let e=document.createElement(`div`);return e.dataset.orbitDebug=``,t(e,{"font-family":`monospace`,"font-size":`11px`,left:`0`,"pointer-events":`none`,position:`fixed`,top:`0`,"z-index":`2147483647`}),e}function r(e,n,r){let i=document.createElement(`div`);return i.textContent=e,t(i,{background:`rgba(0,100,255,0.85)`,"border-radius":`3px`,color:`#fff`,left:`${n}px`,padding:`1px 6px`,position:`fixed`,top:`${Math.max(0,r)}px`,"white-space":`nowrap`}),i}function i(e,n,r,i,a){let o=document.createElement(`div`);return t(o,{border:`1.5px dashed ${a}`,height:`${i}px`,left:`${e}px`,position:`fixed`,top:`${n}px`,width:`${r}px`}),o}function a(t,a,o={}){let s=n();document.body.appendChild(s);function c(e){if(s.innerHTML=``,s.appendChild(i(1,1,window.innerWidth-2,window.innerHeight-2,`rgba(0,100,255,0.3)`)),t instanceof Element){let e=t.getBoundingClientRect();s.appendChild(i(e.left,e.top,e.width,e.height,`rgba(255,120,0,0.7)`))}let n=a.getBoundingClientRect();s.appendChild(r(e.placement,n.left,n.top-22))}let l=o.apply;function u(t){l?l(t):e.applyDefault(t,a,o.strategy??`fixed`),c(t)}let d=e.createPositioner(t,a,{...o,apply:u}),f=d.dispose.bind(d);return d.start(),Object.assign(d,{dispose(){f(),s.remove()}})}exports.debugPositioner=a;
2
2
  //# sourceMappingURL=devtools.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"devtools.cjs","names":[],"sources":["../src/devtools.ts"],"sourcesContent":["/**\n * @vielzeug/orbit — debug overlay for positioning visualisation.\n *\n * Import from the dedicated sub-path so it is tree-shaken from production bundles:\n * ```ts\n * import { debugPositioner } from '@vielzeug/orbit/devtools';\n * ```\n */\n\nimport type { Positioner, PositionerOptions } from './float';\nimport { createPositioner } from './float';\nimport type { ComputePositionResult, ReferenceElement } from './types';\n\n// ── Overlay helpers ───────────────────────────────────────────────────────────\n\nfunction setStyles(el: HTMLElement, styles: Record<string, string>): void {\n for (const [key, val] of Object.entries(styles)) {\n el.style.setProperty(key, val);\n }\n}\n\nfunction createOverlay(): HTMLElement {\n const el = document.createElement('div');\n\n el.dataset.orbitDebug = '';\n setStyles(el, {\n 'font-family': 'monospace',\n 'font-size': '11px',\n left: '0',\n 'pointer-events': 'none',\n position: 'fixed',\n top: '0',\n 'z-index': '2147483647',\n });\n\n return el;\n}\n\nfunction createPlacementBadge(text: string, x: number, y: number): HTMLElement {\n const el = document.createElement('div');\n\n el.textContent = text;\n setStyles(el, {\n background: 'rgba(0,100,255,0.85)',\n 'border-radius': '3px',\n color: '#fff',\n left: `${x}px`,\n padding: '1px 6px',\n position: 'fixed',\n top: `${Math.max(0, y)}px`,\n 'white-space': 'nowrap',\n });\n\n return el;\n}\n\nfunction createOutlineBox(x: number, y: number, width: number, height: number, color: string): HTMLElement {\n const el = document.createElement('div');\n\n setStyles(el, {\n border: `1.5px dashed ${color}`,\n height: `${height}px`,\n left: `${x}px`,\n position: 'fixed',\n top: `${y}px`,\n width: `${width}px`,\n });\n\n return el;\n}\n\n// ── Public API ────────────────────────────────────────────────────────────────\n\n/**\n * Wraps `createPositioner()` and attaches a persistent visual debug overlay to the document.\n *\n * The overlay renders on every position update:\n * - **Blue dashed outline** — the viewport boundary used by overflow detection.\n * - **Orange dashed outline** — the reference element's bounding rect.\n * - **Blue label** — the active placement string (e.g. `\"top-start\"`).\n *\n * The overlay is automatically removed when `handle.dispose()` is called.\n *\n * Use only in development. Tree-shaken from production bundles via the sub-path import.\n *\n * @example\n * ```ts\n * import { debugPositioner } from '@vielzeug/orbit/devtools';\n *\n * const handle = debugPositioner(reference, tooltip, {\n * placement: 'top',\n * middleware: [offset(8), flip(), shift({ padding: 6 })],\n * });\n * // on teardown:\n * handle.dispose();\n * ```\n */\nexport function debugPositioner(\n reference: ReferenceElement,\n floating: HTMLElement,\n options: PositionerOptions = {},\n): Positioner {\n const overlay = createOverlay();\n\n document.body.appendChild(overlay);\n\n function renderOverlay(result: ComputePositionResult): void {\n overlay.innerHTML = '';\n\n // Viewport boundary.\n overlay.appendChild(createOutlineBox(1, 1, window.innerWidth - 2, window.innerHeight - 2, 'rgba(0,100,255,0.3)'));\n\n // Reference element.\n if (reference instanceof Element) {\n const r = reference.getBoundingClientRect();\n\n overlay.appendChild(createOutlineBox(r.left, r.top, r.width, r.height, 'rgba(255,120,0,0.7)'));\n }\n\n // Placement label — positioned just above the floating element.\n const fr = floating.getBoundingClientRect();\n\n overlay.appendChild(createPlacementBadge(result.placement, fr.left, fr.top - 22));\n }\n\n const userApply = options.apply;\n\n function wrappedApply(result: ComputePositionResult): void {\n if (userApply) {\n userApply(result);\n } else {\n floating.style.left = `${result.x}px`;\n floating.style.top = `${result.y}px`;\n }\n\n renderOverlay(result);\n }\n\n const positioner = createPositioner(reference, floating, { ...options, apply: wrappedApply });\n const dispose = positioner.dispose.bind(positioner);\n\n positioner.start();\n\n return Object.assign(positioner, {\n dispose(): void {\n dispose();\n overlay.remove();\n },\n });\n}\n"],"mappings":"kGAeA,SAAS,EAAU,EAAiB,EAAsC,CACxE,IAAK,GAAM,CAAC,EAAK,KAAQ,OAAO,QAAQ,CAAM,EAC5C,EAAG,MAAM,YAAY,EAAK,CAAG,CAEjC,CAEA,SAAS,GAA6B,CACpC,IAAM,EAAK,SAAS,cAAc,KAAK,EAavC,MAXA,GAAG,QAAQ,WAAa,GACxB,EAAU,EAAI,CACZ,cAAe,YACf,YAAa,OACb,KAAM,IACN,iBAAkB,OAClB,SAAU,QACV,IAAK,IACL,UAAW,YACb,CAAC,EAEM,CACT,CAEA,SAAS,EAAqB,EAAc,EAAW,EAAwB,CAC7E,IAAM,EAAK,SAAS,cAAc,KAAK,EAcvC,MAZA,GAAG,YAAc,EACjB,EAAU,EAAI,CACZ,WAAY,uBACZ,gBAAiB,MACjB,MAAO,OACP,KAAM,GAAG,EAAE,IACX,QAAS,UACT,SAAU,QACV,IAAK,GAAG,KAAK,IAAI,EAAG,CAAC,EAAE,IACvB,cAAe,QACjB,CAAC,EAEM,CACT,CAEA,SAAS,EAAiB,EAAW,EAAW,EAAe,EAAgB,EAA4B,CACzG,IAAM,EAAK,SAAS,cAAc,KAAK,EAWvC,OATA,EAAU,EAAI,CACZ,OAAQ,gBAAgB,IACxB,OAAQ,GAAG,EAAO,IAClB,KAAM,GAAG,EAAE,IACX,SAAU,QACV,IAAK,GAAG,EAAE,IACV,MAAO,GAAG,EAAM,GAClB,CAAC,EAEM,CACT,CA4BA,SAAgB,EACd,EACA,EACA,EAA6B,CAAC,EAClB,CACZ,IAAM,EAAU,EAAc,EAE9B,SAAS,KAAK,YAAY,CAAO,EAEjC,SAAS,EAAc,EAAqC,CAO1D,GANA,EAAQ,UAAY,GAGpB,EAAQ,YAAY,EAAiB,EAAG,EAAG,OAAO,WAAa,EAAG,OAAO,YAAc,EAAG,qBAAqB,CAAC,EAG5G,aAAqB,QAAS,CAChC,IAAM,EAAI,EAAU,sBAAsB,EAE1C,EAAQ,YAAY,EAAiB,EAAE,KAAM,EAAE,IAAK,EAAE,MAAO,EAAE,OAAQ,qBAAqB,CAAC,CAC/F,CAGA,IAAM,EAAK,EAAS,sBAAsB,EAE1C,EAAQ,YAAY,EAAqB,EAAO,UAAW,EAAG,KAAM,EAAG,IAAM,EAAE,CAAC,CAClF,CAEA,IAAM,EAAY,EAAQ,MAE1B,SAAS,EAAa,EAAqC,CACrD,EACF,EAAU,CAAM,GAEhB,EAAS,MAAM,KAAO,GAAG,EAAO,EAAE,IAClC,EAAS,MAAM,IAAM,GAAG,EAAO,EAAE,KAGnC,EAAc,CAAM,CACtB,CAEA,IAAM,EAAa,EAAA,iBAAiB,EAAW,EAAU,CAAE,GAAG,EAAS,MAAO,CAAa,CAAC,EACtF,EAAU,EAAW,QAAQ,KAAK,CAAU,EAIlD,OAFA,EAAW,MAAM,EAEV,OAAO,OAAO,EAAY,CAC/B,SAAgB,CACd,EAAQ,EACR,EAAQ,OAAO,CACjB,CACF,CAAC,CACH"}
1
+ {"version":3,"file":"devtools.cjs","names":[],"sources":["../src/devtools.ts"],"sourcesContent":["/**\n * @vielzeug/orbit — debug overlay for positioning visualisation.\n *\n * Import from the dedicated sub-path so it is tree-shaken from production bundles:\n * ```ts\n * import { debugPositioner } from '@vielzeug/orbit/devtools';\n * ```\n */\n\nimport type { Positioner, PositionerOptions } from './float';\nimport { applyDefault, createPositioner } from './float';\nimport type { ComputePositionResult, ReferenceElement } from './types';\n\n// ── Overlay helpers ───────────────────────────────────────────────────────────\n\nfunction setStyles(el: HTMLElement, styles: Record<string, string>): void {\n for (const [key, val] of Object.entries(styles)) {\n el.style.setProperty(key, val);\n }\n}\n\nfunction createOverlay(): HTMLElement {\n const el = document.createElement('div');\n\n el.dataset.orbitDebug = '';\n setStyles(el, {\n 'font-family': 'monospace',\n 'font-size': '11px',\n left: '0',\n 'pointer-events': 'none',\n position: 'fixed',\n top: '0',\n 'z-index': '2147483647',\n });\n\n return el;\n}\n\nfunction createPlacementBadge(text: string, x: number, y: number): HTMLElement {\n const el = document.createElement('div');\n\n el.textContent = text;\n setStyles(el, {\n background: 'rgba(0,100,255,0.85)',\n 'border-radius': '3px',\n color: '#fff',\n left: `${x}px`,\n padding: '1px 6px',\n position: 'fixed',\n top: `${Math.max(0, y)}px`,\n 'white-space': 'nowrap',\n });\n\n return el;\n}\n\nfunction createOutlineBox(x: number, y: number, width: number, height: number, color: string): HTMLElement {\n const el = document.createElement('div');\n\n setStyles(el, {\n border: `1.5px dashed ${color}`,\n height: `${height}px`,\n left: `${x}px`,\n position: 'fixed',\n top: `${y}px`,\n width: `${width}px`,\n });\n\n return el;\n}\n\n// ── Public API ────────────────────────────────────────────────────────────────\n\n/**\n * Wraps `createPositioner()` and attaches a persistent visual debug overlay to the document.\n *\n * The overlay renders on every position update:\n * - **Blue dashed outline** — the viewport boundary used by overflow detection.\n * - **Orange dashed outline** — the reference element's bounding rect.\n * - **Blue label** — the active placement string (e.g. `\"top-start\"`).\n *\n * The overlay is automatically removed when `handle.dispose()` is called.\n *\n * Use only in development. Tree-shaken from production bundles via the sub-path import.\n *\n * @example\n * ```ts\n * import { debugPositioner } from '@vielzeug/orbit/devtools';\n *\n * const handle = debugPositioner(reference, tooltip, {\n * placement: 'top',\n * middleware: [offset(8), flip(), shift({ padding: 6 })],\n * });\n * // on teardown:\n * handle.dispose();\n * ```\n */\nexport function debugPositioner(\n reference: ReferenceElement,\n floating: HTMLElement,\n options: PositionerOptions = {},\n): Positioner {\n const overlay = createOverlay();\n\n document.body.appendChild(overlay);\n\n function renderOverlay(result: ComputePositionResult): void {\n overlay.innerHTML = '';\n\n // Viewport boundary.\n overlay.appendChild(createOutlineBox(1, 1, window.innerWidth - 2, window.innerHeight - 2, 'rgba(0,100,255,0.3)'));\n\n // Reference element.\n if (reference instanceof Element) {\n const r = reference.getBoundingClientRect();\n\n overlay.appendChild(createOutlineBox(r.left, r.top, r.width, r.height, 'rgba(255,120,0,0.7)'));\n }\n\n // Placement label — positioned just above the floating element.\n const fr = floating.getBoundingClientRect();\n\n overlay.appendChild(createPlacementBadge(result.placement, fr.left, fr.top - 22));\n }\n\n const userApply = options.apply;\n\n function wrappedApply(result: ComputePositionResult): void {\n if (userApply) {\n userApply(result);\n } else {\n applyDefault(result, floating, options.strategy ?? 'fixed');\n }\n\n renderOverlay(result);\n }\n\n const positioner = createPositioner(reference, floating, { ...options, apply: wrappedApply });\n const dispose = positioner.dispose.bind(positioner);\n\n positioner.start();\n\n return Object.assign(positioner, {\n dispose(): void {\n dispose();\n overlay.remove();\n },\n });\n}\n"],"mappings":"kGAeA,SAAS,EAAU,EAAiB,EAAsC,CACxE,IAAK,GAAM,CAAC,EAAK,KAAQ,OAAO,QAAQ,CAAM,EAC5C,EAAG,MAAM,YAAY,EAAK,CAAG,CAEjC,CAEA,SAAS,GAA6B,CACpC,IAAM,EAAK,SAAS,cAAc,KAAK,EAavC,MAXA,GAAG,QAAQ,WAAa,GACxB,EAAU,EAAI,CACZ,cAAe,YACf,YAAa,OACb,KAAM,IACN,iBAAkB,OAClB,SAAU,QACV,IAAK,IACL,UAAW,YACb,CAAC,EAEM,CACT,CAEA,SAAS,EAAqB,EAAc,EAAW,EAAwB,CAC7E,IAAM,EAAK,SAAS,cAAc,KAAK,EAcvC,MAZA,GAAG,YAAc,EACjB,EAAU,EAAI,CACZ,WAAY,uBACZ,gBAAiB,MACjB,MAAO,OACP,KAAM,GAAG,EAAE,IACX,QAAS,UACT,SAAU,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AC,CACH"}
@@ -1 +1 @@
1
- {"version":3,"file":"devtools.d.ts","sourceRoot":"","sources":["../src/devtools.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE7D,OAAO,KAAK,EAAyB,gBAAgB,EAAE,MAAM,SAAS,CAAC;AA8DvE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,eAAe,CAC7B,SAAS,EAAE,gBAAgB,EAC3B,QAAQ,EAAE,WAAW,EACrB,OAAO,GAAE,iBAAsB,GAC9B,UAAU,CAgDZ"}
1
+ {"version":3,"file":"devtools.d.ts","sourceRoot":"","sources":["../src/devtools.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE7D,OAAO,KAAK,EAAyB,gBAAgB,EAAE,MAAM,SAAS,CAAC;AA8DvE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,eAAe,CAC7B,SAAS,EAAE,gBAAgB,EAC3B,QAAQ,EAAE,WAAW,EACrB,OAAO,GAAE,iBAAsB,GAC9B,UAAU,CA+CZ"}
package/dist/devtools.js CHANGED
@@ -1,2 +1,2 @@
1
- import{createPositioner as e}from"./float.js";function t(e,t){for(let[n,r]of Object.entries(t))e.style.setProperty(n,r)}function n(){let e=document.createElement(`div`);return e.dataset.orbitDebug=``,t(e,{"font-family":`monospace`,"font-size":`11px`,left:`0`,"pointer-events":`none`,position:`fixed`,top:`0`,"z-index":`2147483647`}),e}function r(e,n,r){let i=document.createElement(`div`);return i.textContent=e,t(i,{background:`rgba(0,100,255,0.85)`,"border-radius":`3px`,color:`#fff`,left:`${n}px`,padding:`1px 6px`,position:`fixed`,top:`${Math.max(0,r)}px`,"white-space":`nowrap`}),i}function i(e,n,r,i,a){let o=document.createElement(`div`);return t(o,{border:`1.5px dashed ${a}`,height:`${i}px`,left:`${e}px`,position:`fixed`,top:`${n}px`,width:`${r}px`}),o}function a(t,a,o={}){let s=n();document.body.appendChild(s);function c(e){if(s.innerHTML=``,s.appendChild(i(1,1,window.innerWidth-2,window.innerHeight-2,`rgba(0,100,255,0.3)`)),t instanceof Element){let e=t.getBoundingClientRect();s.appendChild(i(e.left,e.top,e.width,e.height,`rgba(255,120,0,0.7)`))}let n=a.getBoundingClientRect();s.appendChild(r(e.placement,n.left,n.top-22))}let l=o.apply;function u(e){l?l(e):(a.style.left=`${e.x}px`,a.style.top=`${e.y}px`),c(e)}let d=e(t,a,{...o,apply:u}),f=d.dispose.bind(d);return d.start(),Object.assign(d,{dispose(){f(),s.remove()}})}export{a as debugPositioner};
1
+ import{applyDefault as e,createPositioner as t}from"./float.js";function n(e,t){for(let[n,r]of Object.entries(t))e.style.setProperty(n,r)}function r(){let e=document.createElement(`div`);return e.dataset.orbitDebug=``,n(e,{"font-family":`monospace`,"font-size":`11px`,left:`0`,"pointer-events":`none`,position:`fixed`,top:`0`,"z-index":`2147483647`}),e}function i(e,t,r){let i=document.createElement(`div`);return i.textContent=e,n(i,{background:`rgba(0,100,255,0.85)`,"border-radius":`3px`,color:`#fff`,left:`${t}px`,padding:`1px 6px`,position:`fixed`,top:`${Math.max(0,r)}px`,"white-space":`nowrap`}),i}function a(e,t,r,i,a){let o=document.createElement(`div`);return n(o,{border:`1.5px dashed ${a}`,height:`${i}px`,left:`${e}px`,position:`fixed`,top:`${t}px`,width:`${r}px`}),o}function o(n,o,s={}){let c=r();document.body.appendChild(c);function l(e){if(c.innerHTML=``,c.appendChild(a(1,1,window.innerWidth-2,window.innerHeight-2,`rgba(0,100,255,0.3)`)),n instanceof Element){let e=n.getBoundingClientRect();c.appendChild(a(e.left,e.top,e.width,e.height,`rgba(255,120,0,0.7)`))}let t=o.getBoundingClientRect();c.appendChild(i(e.placement,t.left,t.top-22))}let u=s.apply;function d(t){u?u(t):e(t,o,s.strategy??`fixed`),l(t)}let f=t(n,o,{...s,apply:d}),p=f.dispose.bind(f);return f.start(),Object.assign(f,{dispose(){p(),c.remove()}})}export{o as debugPositioner};
2
2
  //# sourceMappingURL=devtools.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"devtools.js","names":[],"sources":["../src/devtools.ts"],"sourcesContent":["/**\n * @vielzeug/orbit — debug overlay for positioning visualisation.\n *\n * Import from the dedicated sub-path so it is tree-shaken from production bundles:\n * ```ts\n * import { debugPositioner } from '@vielzeug/orbit/devtools';\n * ```\n */\n\nimport type { Positioner, PositionerOptions } from './float';\nimport { createPositioner } from './float';\nimport type { ComputePositionResult, ReferenceElement } from './types';\n\n// ── Overlay helpers ───────────────────────────────────────────────────────────\n\nfunction setStyles(el: HTMLElement, styles: Record<string, string>): void {\n for (const [key, val] of Object.entries(styles)) {\n el.style.setProperty(key, val);\n }\n}\n\nfunction createOverlay(): HTMLElement {\n const el = document.createElement('div');\n\n el.dataset.orbitDebug = '';\n setStyles(el, {\n 'font-family': 'monospace',\n 'font-size': '11px',\n left: '0',\n 'pointer-events': 'none',\n position: 'fixed',\n top: '0',\n 'z-index': '2147483647',\n });\n\n return el;\n}\n\nfunction createPlacementBadge(text: string, x: number, y: number): HTMLElement {\n const el = document.createElement('div');\n\n el.textContent = text;\n setStyles(el, {\n background: 'rgba(0,100,255,0.85)',\n 'border-radius': '3px',\n color: '#fff',\n left: `${x}px`,\n padding: '1px 6px',\n position: 'fixed',\n top: `${Math.max(0, y)}px`,\n 'white-space': 'nowrap',\n });\n\n return el;\n}\n\nfunction createOutlineBox(x: number, y: number, width: number, height: number, color: string): HTMLElement {\n const el = document.createElement('div');\n\n setStyles(el, {\n border: `1.5px dashed ${color}`,\n height: `${height}px`,\n left: `${x}px`,\n position: 'fixed',\n top: `${y}px`,\n width: `${width}px`,\n });\n\n return el;\n}\n\n// ── Public API ────────────────────────────────────────────────────────────────\n\n/**\n * Wraps `createPositioner()` and attaches a persistent visual debug overlay to the document.\n *\n * The overlay renders on every position update:\n * - **Blue dashed outline** — the viewport boundary used by overflow detection.\n * - **Orange dashed outline** — the reference element's bounding rect.\n * - **Blue label** — the active placement string (e.g. `\"top-start\"`).\n *\n * The overlay is automatically removed when `handle.dispose()` is called.\n *\n * Use only in development. Tree-shaken from production bundles via the sub-path import.\n *\n * @example\n * ```ts\n * import { debugPositioner } from '@vielzeug/orbit/devtools';\n *\n * const handle = debugPositioner(reference, tooltip, {\n * placement: 'top',\n * middleware: [offset(8), flip(), shift({ padding: 6 })],\n * });\n * // on teardown:\n * handle.dispose();\n * ```\n */\nexport function debugPositioner(\n reference: ReferenceElement,\n floating: HTMLElement,\n options: PositionerOptions = {},\n): Positioner {\n const overlay = createOverlay();\n\n document.body.appendChild(overlay);\n\n function renderOverlay(result: ComputePositionResult): void {\n overlay.innerHTML = '';\n\n // Viewport boundary.\n overlay.appendChild(createOutlineBox(1, 1, window.innerWidth - 2, window.innerHeight - 2, 'rgba(0,100,255,0.3)'));\n\n // Reference element.\n if (reference instanceof Element) {\n const r = reference.getBoundingClientRect();\n\n overlay.appendChild(createOutlineBox(r.left, r.top, r.width, r.height, 'rgba(255,120,0,0.7)'));\n }\n\n // Placement label — positioned just above the floating element.\n const fr = floating.getBoundingClientRect();\n\n overlay.appendChild(createPlacementBadge(result.placement, fr.left, fr.top - 22));\n }\n\n const userApply = options.apply;\n\n function wrappedApply(result: ComputePositionResult): void {\n if (userApply) {\n userApply(result);\n } else {\n floating.style.left = `${result.x}px`;\n floating.style.top = `${result.y}px`;\n }\n\n renderOverlay(result);\n }\n\n const positioner = createPositioner(reference, floating, { ...options, apply: wrappedApply });\n const dispose = positioner.dispose.bind(positioner);\n\n positioner.start();\n\n return Object.assign(positioner, {\n dispose(): void {\n dispose();\n overlay.remove();\n },\n });\n}\n"],"mappings":"8CAeA,SAAS,EAAU,EAAiB,EAAsC,CACxE,IAAK,GAAM,CAAC,EAAK,KAAQ,OAAO,QAAQ,CAAM,EAC5C,EAAG,MAAM,YAAY,EAAK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UAAW,EAAG,KAAM,EAAG,IAAM,EAAE,CAAC,CAClF,CAEA,IAAM,EAAY,EAAQ,MAE1B,SAAS,EAAa,EAAqC,CACrD,EACF,EAAU,CAAM,GAEhB,EAAS,MAAM,KAAO,GAAG,EAAO,EAAE,IAClC,EAAS,MAAM,IAAM,GAAG,EAAO,EAAE,KAGnC,EAAc,CAAM,CACtB,CAEA,IAAM,EAAa,EAAiB,EAAW,EAAU,CAAE,GAAG,EAAS,MAAO,CAAa,CAAC,EACtF,EAAU,EAAW,QAAQ,KAAK,CAAU,EAIlD,OAFA,EAAW,MAAM,EAEV,OAAO,OAAO,EAAY,CAC/B,SAAgB,CACd,EAAQ,EACR,EAAQ,OAAO,CACjB,CACF,CAAC,CACH"}
1
+ {"version":3,"file":"devtools.js","names":[],"sources":["../src/devtools.ts"],"sourcesContent":["/**\n * @vielzeug/orbit — debug overlay for positioning visualisation.\n *\n * Import from the dedicated sub-path so it is tree-shaken from production bundles:\n * ```ts\n * import { debugPositioner } from '@vielzeug/orbit/devtools';\n * ```\n */\n\nimport type { Positioner, PositionerOptions } from './float';\nimport { applyDefault, createPositioner } from './float';\nimport type { ComputePositionResult, ReferenceElement } from './types';\n\n// ── Overlay helpers ───────────────────────────────────────────────────────────\n\nfunction setStyles(el: HTMLElement, styles: Record<string, string>): void {\n for (const [key, val] of Object.entries(styles)) {\n el.style.setProperty(key, val);\n }\n}\n\nfunction createOverlay(): HTMLElement {\n const el = document.createElement('div');\n\n el.dataset.orbitDebug = '';\n setStyles(el, {\n 'font-family': 'monospace',\n 'font-size': '11px',\n left: '0',\n 'pointer-events': 'none',\n position: 'fixed',\n top: '0',\n 'z-index': '2147483647',\n });\n\n return el;\n}\n\nfunction createPlacementBadge(text: string, x: number, y: number): HTMLElement {\n const el = document.createElement('div');\n\n el.textContent = text;\n setStyles(el, {\n background: 'rgba(0,100,255,0.85)',\n 'border-radius': '3px',\n color: '#fff',\n left: `${x}px`,\n padding: '1px 6px',\n position: 'fixed',\n top: `${Math.max(0, y)}px`,\n 'white-space': 'nowrap',\n });\n\n return el;\n}\n\nfunction createOutlineBox(x: number, y: number, width: number, height: number, color: string): HTMLElement {\n const el = document.createElement('div');\n\n setStyles(el, {\n border: `1.5px dashed ${color}`,\n height: `${height}px`,\n left: `${x}px`,\n position: 'fixed',\n top: `${y}px`,\n width: `${width}px`,\n });\n\n return el;\n}\n\n// ── Public API ────────────────────────────────────────────────────────────────\n\n/**\n * Wraps `createPositioner()` and attaches a persistent visual debug overlay to the document.\n *\n * The overlay renders on every position update:\n * - **Blue dashed outline** — the viewport boundary used by overflow detection.\n * - **Orange dashed outline** — the reference element's bounding rect.\n * - **Blue label** — the active placement string (e.g. `\"top-start\"`).\n *\n * The overlay is automatically removed when `handle.dispose()` is called.\n *\n * Use only in development. Tree-shaken from production bundles via the sub-path import.\n *\n * @example\n * ```ts\n * import { debugPositioner } from '@vielzeug/orbit/devtools';\n *\n * const handle = debugPositioner(reference, tooltip, {\n * placement: 'top',\n * middleware: [offset(8), flip(), shift({ padding: 6 })],\n * });\n * // on teardown:\n * handle.dispose();\n * ```\n */\nexport function debugPositioner(\n reference: ReferenceElement,\n floating: HTMLElement,\n options: PositionerOptions = {},\n): Positioner {\n const overlay = createOverlay();\n\n document.body.appendChild(overlay);\n\n function renderOverlay(result: ComputePositionResult): void {\n overlay.innerHTML = '';\n\n // Viewport boundary.\n overlay.appendChild(createOutlineBox(1, 1, window.innerWidth - 2, window.innerHeight - 2, 'rgba(0,100,255,0.3)'));\n\n // Reference element.\n if (reference instanceof Element) {\n const r = reference.getBoundingClientRect();\n\n overlay.appendChild(createOutlineBox(r.left, r.top, r.width, r.height, 'rgba(255,120,0,0.7)'));\n }\n\n // Placement label — positioned just above the floating element.\n const fr = floating.getBoundingClientRect();\n\n overlay.appendChild(createPlacementBadge(result.placement, fr.left, fr.top - 22));\n }\n\n const userApply = options.apply;\n\n function wrappedApply(result: ComputePositionResult): void {\n if (userApply) {\n userApply(result);\n } else {\n applyDefault(result, floating, options.strategy ?? 'fixed');\n }\n\n renderOverlay(result);\n }\n\n const positioner = createPositioner(reference, floating, { ...options, apply: wrappedApply });\n const dispose = positioner.dispose.bind(positioner);\n\n positioner.start();\n\n return Object.assign(positioner, {\n dispose(): void {\n dispose();\n overlay.remove();\n },\n });\n}\n"],"mappings":"gEAeA,SAAS,EAAU,EAAiB,EAAsC,CACxE,IAAK,GAAM,CAAC,EAAK,KAAQ,OAAO,QAAQ,CAAM,EAC5C,EAAG,MAAM,YAAY,EAAK,CAAG,CAEjC,CAEA,SAAS,GAA6B,CACpC,IAAM,EAAK,SAAS,cAAc,KAAK,EAavC,MAXA,GAAG,QAAQ,WAAa,GACxB,EAAU,EAAI,CACZ,cAAe,YACf,YAAa,OACb,KAAM,IACN,iBAAkB,OAClB,SAAU,QACV,IAAK,IACL,UAAW,YACb,CAAC,EAEM,CACT,CAEA,SAAS,EAAqB,EAAc,EAAW,EAAwB,CAC7E,IAAM,EAAK,SAAS,cAAc,KAAK,EAcvC,MAZA,GAAG,YAAc,EACjB,EAAU,EAAI,CACZ,WAAY,uBACZ,gBAAiB,MACjB,MAAO,OACP,KAAM,GAAG,EAAE,IACX,QAAS,UACT,SAAU,QACV,IAAK,GAAG,KAAK,IAAI,EAAG,CAAC,EAAE,IACvB,cAAe,QACjB,CAAC,EAEM,CACT,CAEA,SAAS,EAAiB,EAAW,EAAW,EAAe,EAAgB,EAA4B,CACzG,IAAM,EAAK,SAAS,cAAc,KAAK,EAWvC,OATA,EAAU,EAAI,CACZ,OAAQ,gBAAgB,IACxB,OAAQ,GAAG,EAAO,IAClB,KAAM,GAAG,EAAE,IACX,SAAU,QACV,IAAK,GAAG,EAAE,IACV,MAAO,GAAG,EAAM,GAClB,CAAC,EAEM,CACT,CA4BA,SAAgB,EACd,EACA,EACA,EAA6B,CAAC,EAClB,CACZ,IAAM,EAAU,EAAc,EAE9B,SAAS,KAAK,YAAY,CAAO,EAEjC,SAAS,EAAc,EAAqC,CAO1D,GANA,EAAQ,UAAY,GAGpB,EAAQ,YAAY,EAAiB,EAAG,EAAG,OAAO,WAAa,EAAG,OAAO,YAAc,EAAG,qBAAqB,CAAC,EAG5G,aAAqB,QAAS,CAChC,IAAM,EAAI,EAAU,sBAAsB,EAE1C,EAAQ,YAAY,EAAiB,EAAE,KAAM,EAAE,IAAK,EAAE,MAAO,EAAE,OAAQ,qBAAqB,CAAC,CAC/F,CAGA,IAAM,EAAK,EAAS,sBAAsB,EAE1C,EAAQ,YAAY,EAAqB,EAAO,UAAW,EAAG,KAAM,EAAG,IAAM,EAAE,CAAC,CAClF,CAEA,IAAM,EAAY,EAAQ,MAE1B,SAAS,EAAa,EAAqC,CACrD,EACF,EAAU,CAAM,EAEhB,EAAa,EAAQ,EAAU,EAAQ,UAAY,OAAO,EAG5D,EAAc,CAAM,CACtB,CAEA,IAAM,EAAa,EAAiB,EAAW,EAAU,CAAE,GAAG,EAAS,MAAO,CAAa,CAAC,EACtF,EAAU,EAAW,QAAQ,KAAK,CAAU,EAIlD,OAFA,EAAW,MAAM,EAEV,OAAO,OAAO,EAAY,CAC/B,SAAgB,CACd,EAAQ,EACR,EAAQ,OAAO,CACjB,CACF,CAAC,CACH"}
package/dist/errors.cjs CHANGED
@@ -1,2 +1,2 @@
1
- var e=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}},t=class extends e{};exports.OrbitConfigError=t,exports.OrbitError=e;
1
+ var e=class extends Error{constructor(e,t){super(e,t),this.name=new.target.name,Object.setPrototypeOf(this,new.target.prototype)}},t=class extends e{};exports.OrbitConfigError=t,exports.OrbitError=e;
2
2
  //# sourceMappingURL=errors.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.cjs","names":[],"sources":["../src/errors.ts"],"sourcesContent":["/** Base class for all orbit errors. Use `instanceof OrbitError` to catch any orbit-originated error. */\nexport class OrbitError extends Error {\n constructor(message: string, opts?: ErrorOptions) {\n super(message, opts);\n this.name = new.target.name;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n\n static is(err: unknown): err is OrbitError {\n return err instanceof OrbitError;\n }\n}\n\n/** Thrown when a middleware pipeline is configured incorrectly. */\nexport class OrbitConfigError extends OrbitError {}\n"],"mappings":"AACA,IAAa,EAAb,MAAa,UAAmB,KAAM,CACpC,YAAY,EAAiB,EAAqB,CAChD,MAAM,EAAS,CAAI,EACnB,KAAK,KAAO,WAAW,KACvB,OAAO,eAAe,KAAM,WAAW,SAAS,CAClD,CAEA,OAAO,GAAG,EAAiC,CACzC,OAAO,aAAe,CACxB,CACF,EAGa,EAAb,cAAsC,CAAW,CAAC"}
1
+ {"version":3,"file":"errors.cjs","names":[],"sources":["../src/errors.ts"],"sourcesContent":["/** Base class for all orbit errors. Use `instanceof OrbitError` to catch any orbit-originated error. */\nexport class OrbitError extends Error {\n constructor(message: string, opts?: ErrorOptions) {\n super(message, opts);\n this.name = new.target.name;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/** Thrown when a middleware pipeline is configured incorrectly. */\nexport class OrbitConfigError extends OrbitError {}\n"],"mappings":"AACA,IAAa,EAAb,cAAgC,KAAM,CACpC,YAAY,EAAiB,EAAqB,CAChD,MAAM,EAAS,CAAI,EACnB,KAAK,KAAO,WAAW,KACvB,OAAO,eAAe,KAAM,WAAW,SAAS,CAClD,CACF,EAGa,EAAb,cAAsC,CAAW,CAAC"}
package/dist/errors.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  /** Base class for all orbit errors. Use `instanceof OrbitError` to catch any orbit-originated error. */
2
2
  export declare class OrbitError extends Error {
3
3
  constructor(message: string, opts?: ErrorOptions);
4
- static is(err: unknown): err is OrbitError;
5
4
  }
6
5
  /** Thrown when a middleware pipeline is configured incorrectly. */
7
6
  export declare class OrbitConfigError extends OrbitError {
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,wGAAwG;AACxG,qBAAa,UAAW,SAAQ,KAAK;gBACvB,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,YAAY;IAMhD,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,UAAU;CAG3C;AAED,mEAAmE;AACnE,qBAAa,gBAAiB,SAAQ,UAAU;CAAG"}
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,wGAAwG;AACxG,qBAAa,UAAW,SAAQ,KAAK;gBACvB,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,YAAY;CAKjD;AAED,mEAAmE;AACnE,qBAAa,gBAAiB,SAAQ,UAAU;CAAG"}
package/dist/errors.js CHANGED
@@ -1,2 +1,2 @@
1
- var e=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}},t=class extends e{};export{t as OrbitConfigError,e as OrbitError};
1
+ var e=class extends Error{constructor(e,t){super(e,t),this.name=new.target.name,Object.setPrototypeOf(this,new.target.prototype)}},t=class extends e{};export{t as OrbitConfigError,e as OrbitError};
2
2
  //# sourceMappingURL=errors.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","names":[],"sources":["../src/errors.ts"],"sourcesContent":["/** Base class for all orbit errors. Use `instanceof OrbitError` to catch any orbit-originated error. */\nexport class OrbitError extends Error {\n constructor(message: string, opts?: ErrorOptions) {\n super(message, opts);\n this.name = new.target.name;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n\n static is(err: unknown): err is OrbitError {\n return err instanceof OrbitError;\n }\n}\n\n/** Thrown when a middleware pipeline is configured incorrectly. */\nexport class OrbitConfigError extends OrbitError {}\n"],"mappings":"AACA,IAAa,EAAb,MAAa,UAAmB,KAAM,CACpC,YAAY,EAAiB,EAAqB,CAChD,MAAM,EAAS,CAAI,EACnB,KAAK,KAAO,WAAW,KACvB,OAAO,eAAe,KAAM,WAAW,SAAS,CAClD,CAEA,OAAO,GAAG,EAAiC,CACzC,OAAO,aAAe,CACxB,CACF,EAGa,EAAb,cAAsC,CAAW,CAAC"}
1
+ {"version":3,"file":"errors.js","names":[],"sources":["../src/errors.ts"],"sourcesContent":["/** Base class for all orbit errors. Use `instanceof OrbitError` to catch any orbit-originated error. */\nexport class OrbitError extends Error {\n constructor(message: string, opts?: ErrorOptions) {\n super(message, opts);\n this.name = new.target.name;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/** Thrown when a middleware pipeline is configured incorrectly. */\nexport class OrbitConfigError extends OrbitError {}\n"],"mappings":"AACA,IAAa,EAAb,cAAgC,KAAM,CACpC,YAAY,EAAiB,EAAqB,CAChD,MAAM,EAAS,CAAI,EACnB,KAAK,KAAO,WAAW,KACvB,OAAO,eAAe,KAAM,WAAW,SAAS,CAClD,CACF,EAGa,EAAb,cAAsC,CAAW,CAAC"}
package/dist/float.cjs CHANGED
@@ -1,2 +1,2 @@
1
- const e=require("./auto-update.cjs"),t=require("./containing-block.cjs"),n=require("./core.cjs"),r=require("./overflow.cjs");function i(e,t,n,r){let i=new AbortController,a=!1;return{get disposalSignal(){return i.signal},dispose(){a||(a=!0,i.abort(),e())},get disposed(){return a},getPosition:t,start(){a||n()},[Symbol.dispose](){this.dispose()},update(){a||r()}}}function a(e,n){return n===`absolute`?e.offsetParent instanceof Element?e.offsetParent:null:t.getContainingBlock(e)}function o(e,t,n){t.style.position=n,t.style.left=`${e.x}px`,t.style.top=`${e.y}px`}function s(t,s,{apply:c,autoUpdate:l={},boundary:u=`clippingAncestors`,middleware:d,padding:f,placement:p=`bottom`,strategy:m=`fixed`}={}){let h=!0,g,_=null,v=!1;function y(){if(!h)return;let e=a(s,m),i=u===`clippingAncestors`?r.getClippingAncestorRect(s):u,l=n.computePosition(t,s,{boundary:i,containingBlock:e,middleware:d,padding:f,placement:p});_=l,(c??(e=>o(e,s,m)))(l)}function b(){v||(v=!0,l===!1?y():g=e.autoUpdate(t,s,y,l))}return i(()=>{h=!1,g?.()},()=>_,b,y)}exports.createPositioner=s;
1
+ const e=require("./auto-update.cjs"),t=require("./containing-block.cjs"),n=require("./core.cjs"),r=require("./overflow.cjs");function i(e,n){return n===`absolute`?e.offsetParent instanceof Element?e.offsetParent:null:t.getContainingBlock(e)}function a(e,t,n){t.style.position=n,t.style.left=`${e.x}px`,t.style.top=`${e.y}px`}function o(t,o,{apply:s,autoUpdate:c={},boundary:l=`clippingAncestors`,middleware:u,padding:d,placement:f=`bottom`,strategy:p=`fixed`}={}){let m=new AbortController,h=!0,g=!1,_,v=null,y=!1;function b(){if(!h)return;let e=i(o,p),c=l===`clippingAncestors`?r.getClippingAncestorRect(o):l,m=n.computePosition(t,o,{boundary:c,containingBlock:e,middleware:u,padding:d,placement:f});v=m,(s??(e=>a(e,o,p)))(m)}function x(){y||g||(y=!0,c===!1?b():_=e.autoUpdate(t,o,b,c))}return{get disposalSignal(){return m.signal},dispose(){g||(g=!0,h=!1,m.abort(),_?.())},get disposed(){return g},getPosition:()=>v,start:x,[Symbol.dispose](){this.dispose()},update(){g||b()}}}exports.applyDefault=a,exports.createPositioner=o;
2
2
  //# sourceMappingURL=float.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"float.cjs","names":[],"sources":["../src/float.ts"],"sourcesContent":["import { type AutoUpdateOptions, autoUpdate } from './auto-update';\nimport { getContainingBlock } from './containing-block';\nimport { computePosition } from './core';\nimport { getClippingAncestorRect } from './overflow';\nimport type { ComputePositionOptions, ComputePositionResult, ReferenceElement } from './types';\n\nexport type PositionStrategy = 'absolute' | 'fixed';\n\nexport interface PositionerOptions extends Omit<ComputePositionOptions, 'boundary' | 'containingBlock'> {\n apply?: (result: ComputePositionResult) => void;\n autoUpdate?: AutoUpdateOptions | false;\n boundary?: ComputePositionOptions['boundary'] | 'clippingAncestors';\n strategy?: PositionStrategy;\n}\n\nexport interface Positioner {\n readonly disposalSignal: AbortSignal;\n dispose(): void;\n readonly disposed: boolean;\n getPosition(): ComputePositionResult | null;\n start(): void;\n update(): void;\n [Symbol.dispose](): void;\n}\n\nfunction makePositioner(\n rawDispose: () => void,\n getPosition: () => ComputePositionResult | null,\n start: () => void,\n update: () => void,\n): Positioner {\n const controller = new AbortController();\n let disposed = false;\n\n return {\n get disposalSignal() {\n return controller.signal;\n },\n dispose() {\n if (disposed) return;\n\n disposed = true;\n controller.abort();\n rawDispose();\n },\n get disposed() {\n return disposed;\n },\n getPosition,\n start(): void {\n if (!disposed) start();\n },\n [Symbol.dispose](): void {\n this.dispose();\n },\n update(): void {\n if (!disposed) update();\n },\n };\n}\n\nfunction resolveContainingBlock(floating: HTMLElement, strategy: PositionStrategy): Element | null {\n if (strategy === 'absolute') return floating.offsetParent instanceof Element ? floating.offsetParent : null;\n\n return getContainingBlock(floating);\n}\n\nfunction applyDefault(result: ComputePositionResult, floating: HTMLElement, strategy: PositionStrategy): void {\n floating.style.position = strategy;\n floating.style.left = `${result.x}px`;\n floating.style.top = `${result.y}px`;\n}\n\n/**\n * Creates a lifecycle-owned floating positioner.\n *\n * The positioner owns coordinate strategy, clipping-boundary resolution, updates, and cleanup.\n * Call `start()` once the elements are mounted, then call `dispose()` when their owner ends.\n */\nexport function createPositioner(\n reference: ReferenceElement,\n floating: HTMLElement,\n {\n apply,\n autoUpdate: autoUpdateOptions = {},\n boundary: boundaryOption = 'clippingAncestors',\n middleware,\n padding,\n placement = 'bottom',\n strategy = 'fixed',\n }: PositionerOptions = {},\n): Positioner {\n let active = true;\n let cleanup: (() => void) | undefined;\n let lastPosition: ComputePositionResult | null = null;\n let started = false;\n\n function update(): void {\n if (!active) return;\n\n const containingBlock = resolveContainingBlock(floating, strategy);\n const boundary = boundaryOption === 'clippingAncestors' ? getClippingAncestorRect(floating) : boundaryOption;\n const result = computePosition(reference, floating, { boundary, containingBlock, middleware, padding, placement });\n\n lastPosition = result;\n (apply ?? ((position) => applyDefault(position, floating, strategy)))(result);\n }\n\n function start(): void {\n if (started) return;\n\n started = true;\n\n if (autoUpdateOptions === false) update();\n else cleanup = autoUpdate(reference, floating, update, autoUpdateOptions);\n }\n\n return makePositioner(\n () => {\n active = false;\n cleanup?.();\n },\n () => lastPosition,\n start,\n update,\n );\n}\n"],"mappings":"6HAyBA,SAAS,EACP,EACA,EACA,EACA,EACY,CACZ,IAAM,EAAa,IAAI,gBACnB,EAAW,GAEf,MAAO,CACL,IAAI,gBAAiB,CACnB,OAAO,EAAW,MACpB,EACA,SAAU,CACJ,IAEJ,EAAW,GACX,EAAW,MAAM,EACjB,EAAW,EACb,EACA,IAAI,UAAW,CACb,OAAO,CACT,EACA,cACA,OAAc,CACP,GAAU,EAAM,CACvB,EACA,CAAC,OAAO,UAAiB,CACvB,KAAK,QAAQ,CACf,EACA,QAAe,CACR,GAAU,EAAO,CACxB,CACF,CACF,CAEA,SAAS,EAAuB,EAAuB,EAA4C,CAGjG,OAFI,IAAa,WAAmB,EAAS,wBAAwB,QAAU,EAAS,aAAe,KAEhG,EAAA,mBAAmB,CAAQ,CACpC,CAEA,SAAS,EAAa,EAA+B,EAAuB,EAAkC,CAC5G,EAAS,MAAM,SAAW,EAC1B,EAAS,MAAM,KAAO,GAAG,EAAO,EAAE,IAClC,EAAS,MAAM,IAAM,GAAG,EAAO,EAAE,GACnC,CAQA,SAAgB,EACd,EACA,EACA,CACE,QACA,WAAY,EAAoB,CAAC,EACjC,SAAU,EAAiB,oBAC3B,aACA,UACA,YAAY,SACZ,WAAW,SACU,CAAC,EACZ,CACZ,IAAI,EAAS,GACT,EACA,EAA6C,KAC7C,EAAU,GAEd,SAAS,GAAe,CACtB,GAAI,CAAC,EAAQ,OAEb,IAAM,EAAkB,EAAuB,EAAU,CAAQ,EAC3D,EAAW,IAAmB,oBAAsB,EAAA,wBAAwB,CAAQ,EAAI,EACxF,EAAS,EAAA,gBAAgB,EAAW,EAAU,CAAE,WAAU,kBAAiB,aAAY,UAAS,WAAU,CAAC,EAEjH,EAAe,GACd,IAAW,GAAa,EAAa,EAAU,EAAU,CAAQ,GAAA,CAAI,CAAM,CAC9E,CAEA,SAAS,GAAc,CACjB,IAEJ,EAAU,GAEN,IAAsB,GAAO,EAAO,EACnC,EAAU,EAAA,WAAW,EAAW,EAAU,EAAQ,CAAiB,EAC1E,CAEA,OAAO,MACC,CACJ,EAAS,GACT,IAAU,CACZ,MACM,EACN,EACA,CACF,CACF"}
1
+ {"version":3,"file":"float.cjs","names":[],"sources":["../src/float.ts"],"sourcesContent":["import { type AutoUpdateOptions, autoUpdate } from './auto-update';\nimport { getContainingBlock } from './containing-block';\nimport { computePosition } from './core';\nimport { getClippingAncestorRect } from './overflow';\nimport type { ComputePositionOptions, ComputePositionResult, ReferenceElement } from './types';\n\nexport type PositionStrategy = 'absolute' | 'fixed';\n\nexport interface PositionerOptions extends Omit<ComputePositionOptions, 'boundary' | 'containingBlock'> {\n apply?: (result: ComputePositionResult) => void;\n autoUpdate?: AutoUpdateOptions | false;\n boundary?: ComputePositionOptions['boundary'] | 'clippingAncestors';\n strategy?: PositionStrategy;\n}\n\nexport interface Positioner {\n readonly disposalSignal: AbortSignal;\n dispose(): void;\n readonly disposed: boolean;\n getPosition(): ComputePositionResult | null;\n start(): void;\n update(): void;\n [Symbol.dispose](): void;\n}\n\nfunction resolveContainingBlock(floating: HTMLElement, strategy: PositionStrategy): Element | null {\n if (strategy === 'absolute') return floating.offsetParent instanceof Element ? floating.offsetParent : null;\n\n return getContainingBlock(floating);\n}\n\n/** @internal — default apply: sets position, left, top on the floating element. */\nexport function applyDefault(result: ComputePositionResult, floating: HTMLElement, strategy: PositionStrategy): void {\n floating.style.position = strategy;\n floating.style.left = `${result.x}px`;\n floating.style.top = `${result.y}px`;\n}\n\n/**\n * Creates a lifecycle-owned floating positioner.\n *\n * The positioner owns coordinate strategy, clipping-boundary resolution, updates, and cleanup.\n * Call `start()` once the elements are mounted, then call `dispose()` when their owner ends.\n */\nexport function createPositioner(\n reference: ReferenceElement,\n floating: HTMLElement,\n {\n apply,\n autoUpdate: autoUpdateOptions = {},\n boundary: boundaryOption = 'clippingAncestors',\n middleware,\n padding,\n placement = 'bottom',\n strategy = 'fixed',\n }: PositionerOptions = {},\n): Positioner {\n const controller = new AbortController();\n let active = true;\n let disposed = false;\n let cleanup: (() => void) | undefined;\n let lastPosition: ComputePositionResult | null = null;\n let started = false;\n\n function update(): void {\n if (!active) return;\n\n const containingBlock = resolveContainingBlock(floating, strategy);\n const boundary = boundaryOption === 'clippingAncestors' ? getClippingAncestorRect(floating) : boundaryOption;\n const result = computePosition(reference, floating, { boundary, containingBlock, middleware, padding, placement });\n\n lastPosition = result;\n (apply ?? ((position) => applyDefault(position, floating, strategy)))(result);\n }\n\n function start(): void {\n if (started || disposed) return;\n\n started = true;\n\n if (autoUpdateOptions === false) update();\n else cleanup = autoUpdate(reference, floating, update, autoUpdateOptions);\n }\n\n return {\n get disposalSignal() {\n return controller.signal;\n },\n dispose() {\n if (disposed) return;\n\n disposed = true;\n active = false;\n controller.abort();\n cleanup?.();\n },\n get disposed() {\n return disposed;\n },\n getPosition: () => lastPosition,\n start,\n [Symbol.dispose]() {\n this.dispose();\n },\n update() {\n if (!disposed) update();\n },\n };\n}\n"],"mappings":"6HAyBA,SAAS,EAAuB,EAAuB,EAA4C,CAGjG,OAFI,IAAa,WAAmB,EAAS,wBAAwB,QAAU,EAAS,aAAe,KAEhG,EAAA,mBAAmB,CAAQ,CACpC,CAGA,SAAgB,EAAa,EAA+B,EAAuB,EAAkC,CACnH,EAAS,MAAM,SAAW,EAC1B,EAAS,MAAM,KAAO,GAAG,EAAO,EAAE,IAClC,EAAS,MAAM,IAAM,GAAG,EAAO,EAAE,GACnC,CAQA,SAAgB,EACd,EACA,EACA,CACE,QACA,WAAY,EAAoB,CAAC,EACjC,SAAU,EAAiB,oBAC3B,aACA,UACA,YAAY,SACZ,WAAW,SACU,CAAC,EACZ,CACZ,IAAM,EAAa,IAAI,gBACnB,EAAS,GACT,EAAW,GACX,EACA,EAA6C,KAC7C,EAAU,GAE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AM,WAAW,UAAU;IACzB,QAAQ,CAAC,cAAc,EAAE,WAAW,CAAC;IACrC,OAAO,IAAI,IAAI,CAAC;IAChB,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,WAAW,IAAI,qBAAqB,GAAG,IAAI,CAAC;IAC5C,KAAK,IAAI,IAAI,CAAC;IACd,MAAM,IAAI,IAAI,CAAC;IACf,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC;CAC1B;AAeD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,gBAAgB,EAC3B,QAAQ,EAAE,WAAW,EACrB,EACE,KAAK,EACL,UAAU,EAAE,iBAAsB,EAClC,QAAQ,EAAE,cAAoC,EAC9C,UAAU,EACV,OAAO,EACP,SAAoB,EACpB,QAAkB,GACnB,GAAE,iBAAsB,GACxB,UAAU,CAoDZ"}
package/dist/float.js CHANGED
@@ -1,2 +1,2 @@
1
- import{autoUpdate as e}from"./auto-update.js";import{getContainingBlock as t}from"./containing-block.js";import{computePosition as n}from"./core.js";import{getClippingAncestorRect as r}from"./overflow.js";function i(e,t,n,r){let i=new AbortController,a=!1;return{get disposalSignal(){return i.signal},dispose(){a||(a=!0,i.abort(),e())},get disposed(){return a},getPosition:t,start(){a||n()},[Symbol.dispose](){this.dispose()},update(){a||r()}}}function a(e,n){return n===`absolute`?e.offsetParent instanceof Element?e.offsetParent:null:t(e)}function o(e,t,n){t.style.position=n,t.style.left=`${e.x}px`,t.style.top=`${e.y}px`}function s(t,s,{apply:c,autoUpdate:l={},boundary:u=`clippingAncestors`,middleware:d,padding:f,placement:p=`bottom`,strategy:m=`fixed`}={}){let h=!0,g,_=null,v=!1;function y(){if(!h)return;let e=a(s,m),i=u===`clippingAncestors`?r(s):u,l=n(t,s,{boundary:i,containingBlock:e,middleware:d,padding:f,placement:p});_=l,(c??(e=>o(e,s,m)))(l)}function b(){v||(v=!0,l===!1?y():g=e(t,s,y,l))}return i(()=>{h=!1,g?.()},()=>_,b,y)}export{s as createPositioner};
1
+ import{autoUpdate as e}from"./auto-update.js";import{getContainingBlock as t}from"./containing-block.js";import{computePosition as n}from"./core.js";import{getClippingAncestorRect as r}from"./overflow.js";function i(e,n){return n===`absolute`?e.offsetParent instanceof Element?e.offsetParent:null:t(e)}function a(e,t,n){t.style.position=n,t.style.left=`${e.x}px`,t.style.top=`${e.y}px`}function o(t,o,{apply:s,autoUpdate:c={},boundary:l=`clippingAncestors`,middleware:u,padding:d,placement:f=`bottom`,strategy:p=`fixed`}={}){let m=new AbortController,h=!0,g=!1,_,v=null,y=!1;function b(){if(!h)return;let e=i(o,p),c=l===`clippingAncestors`?r(o):l,m=n(t,o,{boundary:c,containingBlock:e,middleware:u,padding:d,placement:f});v=m,(s??(e=>a(e,o,p)))(m)}function x(){y||g||(y=!0,c===!1?b():_=e(t,o,b,c))}return{get disposalSignal(){return m.signal},dispose(){g||(g=!0,h=!1,m.abort(),_?.())},get disposed(){return g},getPosition:()=>v,start:x,[Symbol.dispose](){this.dispose()},update(){g||b()}}}export{a as applyDefault,o as createPositioner};
2
2
  //# sourceMappingURL=float.js.map
package/dist/float.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"float.js","names":[],"sources":["../src/float.ts"],"sourcesContent":["import { type AutoUpdateOptions, autoUpdate } from './auto-update';\nimport { getContainingBlock } from './containing-block';\nimport { computePosition } from './core';\nimport { getClippingAncestorRect } from './overflow';\nimport type { ComputePositionOptions, ComputePositionResult, ReferenceElement } from './types';\n\nexport type PositionStrategy = 'absolute' | 'fixed';\n\nexport interface PositionerOptions extends Omit<ComputePositionOptions, 'boundary' | 'containingBlock'> {\n apply?: (result: ComputePositionResult) => void;\n autoUpdate?: AutoUpdateOptions | false;\n boundary?: ComputePositionOptions['boundary'] | 'clippingAncestors';\n strategy?: PositionStrategy;\n}\n\nexport interface Positioner {\n readonly disposalSignal: AbortSignal;\n dispose(): void;\n readonly disposed: boolean;\n getPosition(): ComputePositionResult | null;\n start(): void;\n update(): void;\n [Symbol.dispose](): void;\n}\n\nfunction makePositioner(\n rawDispose: () => void,\n getPosition: () => ComputePositionResult | null,\n start: () => void,\n update: () => void,\n): Positioner {\n const controller = new AbortController();\n let disposed = false;\n\n return {\n get disposalSignal() {\n return controller.signal;\n },\n dispose() {\n if (disposed) return;\n\n disposed = true;\n controller.abort();\n rawDispose();\n },\n get disposed() {\n return disposed;\n },\n getPosition,\n start(): void {\n if (!disposed) start();\n },\n [Symbol.dispose](): void {\n this.dispose();\n },\n update(): void {\n if (!disposed) update();\n },\n };\n}\n\nfunction resolveContainingBlock(floating: HTMLElement, strategy: PositionStrategy): Element | null {\n if (strategy === 'absolute') return floating.offsetParent instanceof Element ? floating.offsetParent : null;\n\n return getContainingBlock(floating);\n}\n\nfunction applyDefault(result: ComputePositionResult, floating: HTMLElement, strategy: PositionStrategy): void {\n floating.style.position = strategy;\n floating.style.left = `${result.x}px`;\n floating.style.top = `${result.y}px`;\n}\n\n/**\n * Creates a lifecycle-owned floating positioner.\n *\n * The positioner owns coordinate strategy, clipping-boundary resolution, updates, and cleanup.\n * Call `start()` once the elements are mounted, then call `dispose()` when their owner ends.\n */\nexport function createPositioner(\n reference: ReferenceElement,\n floating: HTMLElement,\n {\n apply,\n autoUpdate: autoUpdateOptions = {},\n boundary: boundaryOption = 'clippingAncestors',\n middleware,\n padding,\n placement = 'bottom',\n strategy = 'fixed',\n }: PositionerOptions = {},\n): Positioner {\n let active = true;\n let cleanup: (() => void) | undefined;\n let lastPosition: ComputePositionResult | null = null;\n let started = false;\n\n function update(): void {\n if (!active) return;\n\n const containingBlock = resolveContainingBlock(floating, strategy);\n const boundary = boundaryOption === 'clippingAncestors' ? getClippingAncestorRect(floating) : boundaryOption;\n const result = computePosition(reference, floating, { boundary, containingBlock, middleware, padding, placement });\n\n lastPosition = result;\n (apply ?? ((position) => applyDefault(position, floating, strategy)))(result);\n }\n\n function start(): void {\n if (started) return;\n\n started = true;\n\n if (autoUpdateOptions === false) update();\n else cleanup = autoUpdate(reference, floating, update, autoUpdateOptions);\n }\n\n return makePositioner(\n () => {\n active = false;\n cleanup?.();\n },\n () => lastPosition,\n start,\n update,\n );\n}\n"],"mappings":"6MAyBA,SAAS,EACP,EACA,EACA,EACA,EACY,CACZ,IAAM,EAAa,IAAI,gBACnB,EAAW,GAEf,MAAO,CACL,IAAI,gBAAiB,CACnB,OAAO,EAAW,MACpB,EACA,SAAU,CACJ,IAEJ,EAAW,GACX,EAAW,MAAM,EACjB,EAAW,EACb,EACA,IAAI,UAAW,CACb,OAAO,CACT,EACA,cACA,OAAc,CACP,GAAU,EAAM,CACvB,EACA,CAAC,OAAO,UAAiB,CACvB,KAAK,QAAQ,CACf,EACA,QAAe,CACR,GAAU,EAAO,CACxB,CACF,CACF,CAEA,SAAS,EAAuB,EAAuB,EAA4C,CAGjG,OAFI,IAAa,WAAmB,EAAS,wBAAwB,QAAU,EAAS,aAAe,KAEhG,EAAmB,CAAQ,CACpC,CAEA,SAAS,EAAa,EAA+B,EAAuB,EAAkC,CAC5G,EAAS,MAAM,SAAW,EAC1B,EAAS,MAAM,KAAO,GAAG,EAAO,EAAE,IAClC,EAAS,MAAM,IAAM,GAAG,EAAO,EAAE,GACnC,CAQA,SAAgB,EACd,EACA,EACA,CACE,QACA,WAAY,EAAoB,CAAC,EACjC,SAAU,EAAiB,oBAC3B,aACA,UACA,YAAY,SACZ,WAAW,SACU,CAAC,EACZ,CACZ,IAAI,EAAS,GACT,EACA,EAA6C,KAC7C,EAAU,GAEd,SAAS,GAAe,CACtB,GAAI,CAAC,EAAQ,OAEb,IAAM,EAAkB,EAAuB,EAAU,CAAQ,EAC3D,EAAW,IAAmB,oBAAsB,EAAwB,CAAQ,EAAI,EACxF,EAAS,EAAgB,EAAW,EAAU,CAAE,WAAU,kBAAiB,aAAY,UAAS,WAAU,CAAC,EAEjH,EAAe,GACd,IAAW,GAAa,EAAa,EAAU,EAAU,CAAQ,GAAA,CAAI,CAAM,CAC9E,CAEA,SAAS,GAAc,CACjB,IAEJ,EAAU,GAEN,IAAsB,GAAO,EAAO,EACnC,EAAU,EAAW,EAAW,EAAU,EAAQ,CAAiB,EAC1E,CAEA,OAAO,MACC,CACJ,EAAS,GACT,IAAU,CACZ,MACM,EACN,EACA,CACF,CACF"}
1
+ {"version":3,"file":"float.js","names":[],"sources":["../src/float.ts"],"sourcesContent":["import { type AutoUpdateOptions, autoUpdate } from './auto-update';\nimport { getContainingBlock } from './containing-block';\nimport { computePosition } from './core';\nimport { getClippingAncestorRect } from './overflow';\nimport type { ComputePositionOptions, ComputePositionResult, ReferenceElement } from './types';\n\nexport type PositionStrategy = 'absolute' | 'fixed';\n\nexport interface PositionerOptions extends Omit<ComputePositionOptions, 'boundary' | 'containingBlock'> {\n apply?: (result: ComputePositionResult) => void;\n autoUpdate?: AutoUpdateOptions | false;\n boundary?: ComputePositionOptions['boundary'] | 'clippingAncestors';\n strategy?: PositionStrategy;\n}\n\nexport interface Positioner {\n readonly disposalSignal: AbortSignal;\n dispose(): void;\n readonly disposed: boolean;\n getPosition(): ComputePositionResult | null;\n start(): void;\n update(): void;\n [Symbol.dispose](): void;\n}\n\nfunction resolveContainingBlock(floating: HTMLElement, strategy: PositionStrategy): Element | null {\n if (strategy === 'absolute') return floating.offsetParent instanceof Element ? floating.offsetParent : null;\n\n return getContainingBlock(floating);\n}\n\n/** @internal — default apply: sets position, left, top on the floating element. */\nexport function applyDefault(result: ComputePositionResult, floating: HTMLElement, strategy: PositionStrategy): void {\n floating.style.position = strategy;\n floating.style.left = `${result.x}px`;\n floating.style.top = `${result.y}px`;\n}\n\n/**\n * Creates a lifecycle-owned floating positioner.\n *\n * The positioner owns coordinate strategy, clipping-boundary resolution, updates, and cleanup.\n * Call `start()` once the elements are mounted, then call `dispose()` when their owner ends.\n */\nexport function createPositioner(\n reference: ReferenceElement,\n floating: HTMLElement,\n {\n apply,\n autoUpdate: autoUpdateOptions = {},\n boundary: boundaryOption = 'clippingAncestors',\n middleware,\n padding,\n placement = 'bottom',\n strategy = 'fixed',\n }: PositionerOptions = {},\n): Positioner {\n const controller = new AbortController();\n let active = true;\n let disposed = false;\n let cleanup: (() => void) | undefined;\n let lastPosition: ComputePositionResult | null = null;\n let started = false;\n\n function update(): void {\n if (!active) return;\n\n const containingBlock = resolveContainingBlock(floating, strategy);\n const boundary = boundaryOption === 'clippingAncestors' ? getClippingAncestorRect(floating) : boundaryOption;\n const result = computePosition(reference, floating, { boundary, containingBlock, middleware, padding, placement });\n\n lastPosition = result;\n (apply ?? ((position) => applyDefault(position, floating, strategy)))(result);\n }\n\n function start(): void {\n if (started || disposed) return;\n\n started = true;\n\n if (autoUpdateOptions === false) update();\n else cleanup = autoUpdate(reference, floating, update, autoUpdateOptions);\n }\n\n return {\n get disposalSignal() {\n return controller.signal;\n },\n dispose() {\n if (disposed) return;\n\n disposed = true;\n active = false;\n controller.abort();\n cleanup?.();\n },\n get disposed() {\n return disposed;\n },\n getPosition: () => lastPosition,\n start,\n [Symbol.dispose]() {\n this.dispose();\n },\n update() {\n if (!disposed) update();\n },\n };\n}\n"],"mappings":"6MAyBA,SAAS,EAAuB,EAAuB,EAA4C,CAGjG,OAFI,IAAa,WAAmB,EAAS,wBAAwB,QAAU,EAAS,aAAe,KAEhG,EAAmB,CAAQ,CACpC,CAGA,SAAgB,EAAa,EAA+B,EAAuB,EAAkC,CACnH,EAAS,MAAM,SAAW,EAC1B,EAAS,MAAM,KAAO,GAAG,EAAO,EAAE,IAClC,EAAS,MAAM,IAAM,GAAG,EAAO,EAAE,GACnC,CAQA,SAAgB,EACd,EACA,EACA,CACE,QACA,WAAY,EAAoB,CAAC,EACjC,SAAU,EAAiB,oBAC3B,aACA,UACA,YAAY,SACZ,WAAW,SACU,CAAC,EACZ,CACZ,IAAM,EAAa,IAAI,gBACnB,EAAS,GACT,EAAW,GACX,EACA,EAA6C,KAC7C,EAAU,GAEd,SAAS,GAAe,CACtB,GAAI,CAAC,EAAQ,OAEb,IAAM,EAAkB,EAAuB,EAAU,CAAQ,EAC3D,EAAW,IAAmB,oBAAsB,EAAwB,CAAQ,EAAI,EACxF,EAAS,EAAgB,EAAW,EAAU,CAAE,WAAU,kBAAiB,aAAY,UAAS,WAAU,CAAC,EAEjH,EAAe,GACd,IAAW,GAAa,EAAa,EAAU,EAAU,CAAQ,GAAA,CAAI,CAAM,CAC9E,CAEA,SAAS,GAAc,CACjB,GAAW,IAEf,EAAU,GAEN,IAAsB,GAAO,EAAO,EACnC,EAAU,EAAW,EAAW,EAAU,EAAQ,CAAiB,EAC1E,CAEA,MAAO,CACL,IAAI,gBAAiB,CACnB,OAAO,EAAW,MACpB,EACA,SAAU,CACJ,IAEJ,EAAW,GACX,EAAS,GACT,EAAW,MAAM,EACjB,IAAU,EACZ,EACA,IAAI,UAAW,CACb,OAAO,CACT,EACA,gBAAmB,EACnB,QACA,CAAC,OAAO,UAAW,CACjB,KAAK,QAAQ,CACf,EACA,QAAS,CACF,GAAU,EAAO,CACxB,CACF,CACF"}
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./utils.cjs"),t=require("./auto-update.cjs"),n=require("./errors.cjs"),r=require("./core.cjs"),i=require("./overflow.cjs"),a=require("./float.cjs"),o=require("./inline.cjs"),s=require("./middleware/arrow.cjs"),c=require("./middleware/auto-placement.cjs"),l=require("./middleware/flip.cjs"),u=require("./middleware/hide.cjs"),d=require("./middleware/offset.cjs"),f=require("./middleware/shift.cjs"),p=require("./middleware/size.cjs");exports.OrbitConfigError=n.OrbitConfigError,exports.OrbitError=n.OrbitError,exports.arrow=s.arrow,exports.autoPlacement=c.autoPlacement,exports.autoUpdate=t.autoUpdate,exports.computePosition=r.computePosition,exports.computePositionAsync=r.computePositionAsync,exports.computePositionRaf=r.computePositionRaf,exports.createPositioner=a.createPositioner,exports.detectOverflow=i.detectOverflow,exports.flip=l.flip,exports.getAlignment=e.getAlignment,exports.getClippingAncestorRect=i.getClippingAncestorRect,exports.getRects=r.getRects,exports.getSide=e.getSide,exports.hide=u.hide,exports.inline=o.inline,exports.limitShift=f.limitShift,exports.offset=d.offset,exports.shift=f.shift,exports.size=p.size;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./utils.cjs"),t=require("./auto-update.cjs"),n=require("./errors.cjs"),r=require("./core.cjs"),i=require("./overflow.cjs"),a=require("./float.cjs"),o=require("./inline.cjs"),s=require("./middleware/arrow.cjs"),c=require("./middleware/auto-placement.cjs"),l=require("./middleware/flip.cjs"),u=require("./middleware/hide.cjs"),d=require("./middleware/offset.cjs"),f=require("./middleware/shift.cjs"),p=require("./middleware/size.cjs");exports.OrbitConfigError=n.OrbitConfigError,exports.OrbitError=n.OrbitError,exports.arrow=s.arrow,exports.autoPlacement=c.autoPlacement,exports.autoUpdate=t.autoUpdate,exports.computePosition=r.computePosition,exports.createPositioner=a.createPositioner,exports.detectOverflow=i.detectOverflow,exports.flip=l.flip,exports.getAlignment=e.getAlignment,exports.getClippingAncestorRect=i.getClippingAncestorRect,exports.getSide=e.getSide,exports.hide=u.hide,exports.inline=o.inline,exports.limitShift=f.limitShift,exports.offset=d.offset,exports.shift=f.shift,exports.size=p.size;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export type { AutoUpdateOptions } from './auto-update';
2
2
  export { autoUpdate } from './auto-update';
3
- export { computePosition, computePositionAsync, computePositionRaf, getRects } from './core';
3
+ export { computePosition } from './core';
4
4
  export { OrbitConfigError, OrbitError } from './errors';
5
5
  export type { Positioner, PositionerOptions, PositionStrategy } from './float';
6
6
  export { createPositioner } from './float';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,YAAY,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEvD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,eAAe,EAAE,oBAAoB,EA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AE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,YAAY,EAAE,iBAAiB,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACxF,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AACvD,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEzC,OAAO,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAErE,YAAY,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAElE,YAAY,EACV,SAAS,EACT,SAAS,EACT,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,EACrB,QAAQ,EACR,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,gBAAgB,GACjB,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC"}
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{getAlignment as e,getSide as t}from"./utils.js";import{autoUpdate as n}from"./auto-update.js";import{OrbitConfigError as r,OrbitError as i}from"./errors.js";import{computePosition as a,computePositionAsync as o,computePositionRaf as s,getRects as c}from"./core.js";import{detectOverflow as l,getClippingAncestorRect as u}from"./overflow.js";import{createPositioner as d}from"./float.js";import{inline as f}from"./inline.js";import{arrow as p}from"./middleware/arrow.js";import{autoPlacement as m}from"./middleware/auto-placement.js";import{flip as h}from"./middleware/flip.js";import{hide as g}from"./middleware/hide.js";import{offset as _}from"./middleware/offset.js";import{limitShift as v,shift as y}from"./middleware/shift.js";import{size as b}from"./middleware/size.js";export{r as OrbitConfigError,i as OrbitError,p as arrow,m as autoPlacement,n as autoUpdate,a as computePosition,o as computePositionAsync,s as computePositionRaf,d as createPositioner,l as detectOverflow,h as flip,e as getAlignment,u as getClippingAncestorRect,c as getRects,t as getSide,g as hide,f as inline,v as limitShift,_ as offset,y as shift,b as size};
1
+ import{getAlignment as e,getSide as t}from"./utils.js";import{autoUpdate as n}from"./auto-update.js";import{OrbitConfigError as r,OrbitError as i}from"./errors.js";import{computePosition as a}from"./core.js";import{detectOverflow as o,getClippingAncestorRect as s}from"./overflow.js";import{createPositioner as c}from"./float.js";import{inline as l}from"./inline.js";import{arrow as u}from"./middleware/arrow.js";import{autoPlacement as d}from"./middleware/auto-placement.js";import{flip as f}from"./middleware/flip.js";import{hide as p}from"./middleware/hide.js";import{offset as m}from"./middleware/offset.js";import{limitShift as h,shift as g}from"./middleware/shift.js";import{size as _}from"./middleware/size.js";export{r as OrbitConfigError,i as OrbitError,u as arrow,d as autoPlacement,n as autoUpdate,a as computePosition,c as createPositioner,o as detectOverflow,f as flip,e as getAlignment,s as getClippingAncestorRect,t as getSide,p as hide,l as inline,h as limitShift,m as offset,g as shift,_ as size};
package/dist/orbit.cjs CHANGED
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});function e(e,t,n){return Math.min(Math.max(e,t),n)}var t={bottom:`top`,left:`right`,right:`left`,top:`bottom`};function n(e){return e.split(`-`)[0]}function r(e){return e.split(`-`)[1]??null}function i(e,t){return t?`${e}-${t}`:e}function a({height:e,width:t,x:n,y:r}){return{height:e,width:t,x:n,y:r}}function o(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 s(e){return typeof Element<`u`&&e instanceof Element}function c(e){return e.assignedSlot?e.assignedSlot:e.parentElement??(e.getRootNode()instanceof ShadowRoot?e.getRootNode().host:null)}function l(e,t,n,r){return e===`start`?t:e===`end`?t+n-r:t+(n-r)/2}function u(e,t,i){let a=n(e),o=r(e);switch(a){case`bottom`:return{x:l(o,t.x,t.width,i.width),y:t.y+t.height};case`left`:return{x:t.x-i.width,y:l(o,t.y,t.height,i.height)};case`right`:return{x:t.x+t.width,y:l(o,t.y,t.height,i.height)};case`top`:return{x:l(o,t.x,t.width,i.width),y:t.y-i.height}}}function d(e,t){let n,r=0,i=(()=>{let i=Date.now(),a=t-(i-r);if(a<=0){n!==void 0&&clearTimeout(n),n=void 0,r=i,e();return}n===void 0&&(n=setTimeout(()=>{n=void 0,r=Date.now(),e()},a))});return i.cancel=()=>{n!==void 0&&clearTimeout(n),n=void 0},i}function f(e){let t=[],n=c(e);for(;n;){let e=getComputedStyle(n),r=e.overflow+e.overflowX+e.overflowY;/auto|scroll|overlay/.test(r)&&t.push(n),n=c(n)}return t}function p(e,t,n,{animationFrame:r=!1,observeAncestors:i=!0,observeFloating:a=!0,observeVisualViewport:o=!0,pauseWhenHidden:c=!0,throttle:l=0}={}){let u=l>0?d(n,l):null,p=u??n,m=!0,h=()=>{m&&p()};p();let g=[];if(c&&s(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(s(e)&&i){let t=f(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(t)||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 _=o?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);s(e)&&v.observe(e),a&&v.observe(t),g.push(()=>v.disconnect());let y=0;if(r){let e=()=>{h(),y=window.requestAnimationFrame(e)};y=window.requestAnimationFrame(e),g.push(()=>window.cancelAnimationFrame(y))}return()=>{u?.cancel();for(let e of g)e()}}var m=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}},h=class extends m{};function g(e,t){return{floating:a(t.getBoundingClientRect()),reference:a(e.getBoundingClientRect())}}function _(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 v=8;function y(e,t,n){return Promise.resolve().then(()=>x(e,t,n))}function b(e,t,n){return new Promise((r,i)=>{requestAnimationFrame(()=>{try{r(x(e,t,n))}catch(e){i(e)}})})}function x(e,t,{boundary:n,containingBlock:r,middleware:i=[],padding:a,placement:o=`bottom`}={}){let s=i,c=o,l={},d=g(e,t);for(let i=0;i<v;i+=1){let i={...u(c,d.reference,d.floating),boundary:n,elements:{floating:t,reference:e},initialPlacement:o,middlewareData:l,padding:a,placement:c,rects:d},f;for(let e of s){let t=e(i);if(i=_(i,t),l=i.middlewareData,f=t?.reset,f)break}if(!f){let e={middlewareData:i.middlewareData,placement:i.placement,x:i.x,y:i.y};if(r){let t=r.getBoundingClientRect();return{...e,x:e.x-t.x,y:e.y-t.y}}return e}f.remeasure?d=g(e,t):f.rects!=null&&(d=f.rects),c=f.placement??i.placement}throw new h(`Middleware triggered too many resets in a single compute cycle.`)}var S=[`transform`,`perspective`,`filter`],C=[`layout`,`paint`,`strict`,`content`];function w(e){return e.transform!==`none`||e.perspective!==`none`||e.filter!==`none`||e.backdropFilter&&e.backdropFilter!==`none`||e.willChange!==`auto`&&S.some(t=>e.willChange.includes(t))?!0:e.contain!==`none`&&C.some(t=>e.contain.includes(t))}function T(e){let t=c(e);for(;t;){if(w(getComputedStyle(t)))return t;t=c(t)}return null}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 D(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 O=/(hidden|clip|scroll|auto|overlay)/;function k(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 A(e){let t=c(e),n=E();for(;t;){let e=getComputedStyle(t);if(O.test(`${e.overflow}${e.overflowX}${e.overflowY}`)){let e=t.getBoundingClientRect();n=k(n,{height:e.height,width:e.width,x:e.x,y:e.y})}t=c(t)}return n}function j(e,t){return{boundary:D(e.boundary??t.boundary),padding:o(e.padding??t.padding)}}function M(e){return{...e.rects.floating,x:e.x,y:e.y}}function N(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 P(e){return Math.max(e.top,0)+Math.max(e.right,0)+Math.max(e.bottom,0)+Math.max(e.left,0)}function F(e){return e.top>0||e.right>0||e.bottom>0||e.left>0}function I(e,t){return t.top>=e.height||t.right>=e.width||t.bottom>=e.height||t.left>=e.width}function L(e,t,r,i){let a=e.rects.reference;switch(n(t)){case`bottom`:return r.y+r.height-i.bottom-(a.y+a.height);case`left`:return a.x-(r.x+i.left);case`right`:return r.x+r.width-i.right-(a.x+a.width);case`top`:return a.y-(r.y+i.top)}}function R(e,t,n={}){let{x:r,y:i}=u(t,e.rects.reference,e.rects.floating),{boundary:a,padding:o}=j(n,e);return N({...e.rects.floating,x:r,y:i},a,o)}function z(e,t={}){let{boundary:n,padding:r}=j(t,e);return N(M(e),n,r)}function B(e,t,n,r){let i=new AbortController,a=!1;return{get disposalSignal(){return i.signal},dispose(){a||(a=!0,i.abort(),e())},get disposed(){return a},getPosition:t,start(){a||n()},[Symbol.dispose](){this.dispose()},update(){a||r()}}}function V(e,t){return t===`absolute`?e.offsetParent instanceof Element?e.offsetParent:null:T(e)}function H(e,t,n){t.style.position=n,t.style.left=`${e.x}px`,t.style.top=`${e.y}px`}function U(e,t,{apply:n,autoUpdate:r={},boundary:i=`clippingAncestors`,middleware:a,padding:o,placement:s=`bottom`,strategy:c=`fixed`}={}){let l=!0,u,d=null,f=!1;function m(){if(!l)return;let r=V(t,c),u=x(e,t,{boundary:i===`clippingAncestors`?A(t):i,containingBlock:r,middleware:a,padding:o,placement:s});d=u,(n??(e=>H(e,t,c)))(u)}function h(){f||(f=!0,r===!1?m():u=p(e,t,m,r))}return B(()=>{l=!1,u?.()},()=>d,h,m)}function W(e){return!(`getClientRects`in e)||typeof e.getClientRects!=`function`?[]:Array.from(e.getClientRects()).map(a).filter(e=>e.width>0||e.height>0)}function G(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 K(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function q(e={}){function t(t){let r=W(t.elements.reference);if(r.length<=1)return;let i=o(e.padding??2),a=n(t.placement),s=r[0];if(e.x!=null&&e.y!=null)s=r.find(t=>G(t,e.x,e.y,i))??s;else if(a===`top`||a===`bottom`){let e=t.x+t.rects.floating.width/2;s=r.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},s)}else{let e=t.y+t.rects.floating.height/2;s=r.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},s)}if(!K(s,t.rects.reference))return{reset:{rects:{...t.rects,reference:s}}}}return t}function J({element:t,padding:r=0}){function i(i){let s=n(i.placement),c=o(r),l=a(t.getBoundingClientRect());if(s===`top`||s===`bottom`){let t=i.rects.reference.x+i.rects.reference.width/2-i.x-l.width/2,n=c.left,r=e(t,n,Math.max(n,i.rects.floating.width-l.width-c.right));return{data:{arrow:{centerOffset:t-r,constrained:r!==t,x:r}}}}let u=i.rects.reference.y+i.rects.reference.height/2-i.y-l.height/2,d=c.top,f=e(u,d,Math.max(d,i.rects.floating.height-l.height-c.bottom));return{data:{arrow:{centerOffset:u-f,constrained:f!==u,y:f}}}}return i}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 function(t){let{boundary:n,padding:r}=j(e,t),i=e.allowedPlacements??X(e.alignment);i.length;let a=t.placement,o=1/0,s=-1/0;for(let c of i){let i=P(R(t,c,e)),l=L(t,c,n,r);(i<o||i===o&&l>s)&&(a=c,o=i,s=l)}if(a!==t.placement)return{reset:{placement:a}}}}function Q(e={}){function a(a){let o=z(a,e);if(!F(o))return;let s=n(a.placement),c=r(a.placement),l=e.fallbackPlacements??[i(t[s],c)],u=[a.placement],d=a.placement,f=P(o);for(let t of l){let n=R(a,t,e),r=P(n);if(!F(n))return{data:{flip:{skippedPlacements:u}},reset:{placement:t}};u.push(t),r<f&&(d=t,f=r)}if(d!==a.placement)return{data:{flip:{skippedPlacements:u}},reset:{placement:d}}}return a}function $(e={}){let t=e.strategy??`both`;function n(n){let{boundary:r,padding:i}=j(e,n),a={};if(t===`escaped`||t===`both`){let e=M(n),t=N(e,r,i);a.escaped=I(e,t),a.escapedOffsets=t}if(t===`referenceHidden`||t===`both`){let e=N(n.rects.reference,r,i);a.referenceHidden=I(n.rects.reference,e),a.referenceHiddenOffsets=e}return{data:{hide:a}}}return n}function ee(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 te(e){return function(t){let r=n(t.placement),{crossAxis:i,mainAxis:a}=ee(e,t);switch(r){case`bottom`:return{x:t.x+i,y:t.y+a};case`left`:return{x:t.x-a,y:t.y+i};case`right`:return{x:t.x+a,y:t.y+i};case`top`:return{x:t.x+i,y:t.y-a}}}}function ne(t={}){return(r,i)=>{let{placement:a,rects:o,x:s,y:c}=r,l=n(a),u=l===`top`||l===`bottom`,d=typeof t.offset==`function`?t.offset(r):t.offset??0;if(u){let t=o.reference.x-d,n=o.reference.x+o.reference.width+d-o.floating.width,[r,a]=t<=n?[t,n]:[n,t],c=e(s+i.crossAxis,r,a);return{...i,crossAxis:c-s}}let f=o.reference.y-d,p=o.reference.y+o.reference.height+d-o.floating.height,[m,h]=f<=p?[f,p]:[p,f],g=e(c+i.crossAxis,m,h);return{...i,crossAxis:g-c}}}function re(e={}){let{crossAxis:t=!0,limiter:r,mainAxis:i=!1}=e;function a(a){let o=z(a,e),s=n(a.placement),c=s===`top`||s===`bottom`,l=Math.max(o.left,0)-Math.max(o.right,0),u=Math.max(o.top,0)-Math.max(o.bottom,0),d=c?t:i,f=c?i:t,p=d?l:0,m=f?u:0;if(r){let e=r(a,{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:a.x+p,y:a.y+m}}return a}function ie(e={}){function t(t){let{boundary:r,padding:i}=j(e,t),a=n(t.placement),o=r.y+i.top,s=r.x+r.width-i.right,c=r.y+r.height-i.bottom,l=r.x+i.left;return{data:{size:{availableHeight:a===`bottom`?Math.max(0,c-t.y):a===`top`?Math.max(0,t.rects.reference.y-o):Math.max(0,c-o),availableWidth:a===`right`?Math.max(0,s-t.x):a===`left`?Math.max(0,t.rects.reference.x-l):Math.max(0,s-l)}}}}return t}exports.OrbitConfigError=h,exports.OrbitError=m,exports.arrow=J,exports.autoPlacement=Z,exports.autoUpdate=p,exports.computePosition=x,exports.computePositionAsync=y,exports.computePositionRaf=b,exports.createPositioner=U,exports.detectOverflow=z,exports.flip=Q,exports.getAlignment=r,exports.getClippingAncestorRect=A,exports.getRects=g,exports.getSide=n,exports.hide=$,exports.inline=q,exports.limitShift=ne,exports.offset=te,exports.shift=re,exports.size=ie;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});function e(e,t,n){return Math.min(Math.max(e,t),n)}var t={bottom:`top`,left:`right`,right:`left`,top:`bottom`};function n(e){return e.split(`-`)[0]}function r(e){return e.split(`-`)[1]??null}function i(e,t){return t?`${e}-${t}`:e}function a({height:e,width:t,x:n,y:r}){return{height:e,width:t,x:n,y:r}}function o(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 s(e){return typeof Element<`u`&&e instanceof Element}function c(e){return e.assignedSlot?e.assignedSlot:e.parentElement??(e.getRootNode()instanceof ShadowRoot?e.getRootNode().host:null)}function l(e,t,n,r){return e===`start`?t:e===`end`?t+n-r:t+(n-r)/2}function u(e,t,i){let a=n(e),o=r(e);switch(a){case`bottom`:return{x:l(o,t.x,t.width,i.width),y:t.y+t.height};case`left`:return{x:t.x-i.width,y:l(o,t.y,t.height,i.height)};case`right`:return{x:t.x+t.width,y:l(o,t.y,t.height,i.height)};case`top`:return{x:l(o,t.x,t.width,i.width),y:t.y-i.height}}}function d(e,t){let n,r=0,i=(()=>{let i=Date.now(),a=t-(i-r);if(a<=0){n!==void 0&&clearTimeout(n),n=void 0,r=i,e();return}n===void 0&&(n=setTimeout(()=>{n=void 0,r=Date.now(),e()},a))});return i.cancel=()=>{n!==void 0&&clearTimeout(n),n=void 0},i}function f(e){let t=[],n=c(e);for(;n;){let e=getComputedStyle(n),r=e.overflow+e.overflowX+e.overflowY;/auto|scroll|overlay/.test(r)&&t.push(n),n=c(n)}return t}function p(e,t,n,{animationFrame:r=!1,observeAncestors:i=!0,observeFloating:a=!0,observeVisualViewport:o=!0,pauseWhenHidden:c=!0,throttle:l=0}={}){let u=l>0?d(n,l):null,p=u??n,m=!0,h=()=>{m&&p()};p();let g=[];if(c&&s(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(s(e)&&i){let t=f(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(t)||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 _=o?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);s(e)&&v.observe(e),a&&v.observe(t),g.push(()=>v.disconnect());let y=0;if(r){let e=()=>{h(),y=window.requestAnimationFrame(e)};y=window.requestAnimationFrame(e),g.push(()=>window.cancelAnimationFrame(y))}return()=>{u?.cancel();for(let e of g)e()}}var m=class extends Error{constructor(e,t){super(e,t),this.name=new.target.name,Object.setPrototypeOf(this,new.target.prototype)}},h=class extends m{};function g(e,t){return{floating:a(t.getBoundingClientRect()),reference:a(e.getBoundingClientRect())}}function _(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 v=8;function y(e,t,{boundary:n,containingBlock:r,middleware:i=[],padding:a,placement:o=`bottom`}={}){let s=i,c=o,l={},d=g(e,t);for(let i=0;i<v;i+=1){let i={...u(c,d.reference,d.floating),boundary:n,elements:{floating:t,reference:e},initialPlacement:o,middlewareData:l,padding:a,placement:c,rects:d},f;for(let e of s){let t=e(i);if(i=_(i,t),l=i.middlewareData,f=t?.reset,f)break}if(!f){let e={middlewareData:i.middlewareData,placement:i.placement,x:i.x,y:i.y};if(r){let t=r.getBoundingClientRect();return{...e,x:e.x-t.x,y:e.y-t.y}}return e}f.remeasure?d=g(e,t):f.rects!=null&&(d=f.rects),c=f.placement??i.placement}throw new h(`Middleware triggered too many resets in a single compute cycle.`)}var b=[`transform`,`perspective`,`filter`],x=[`layout`,`paint`,`strict`,`content`];function S(e){return e.transform!==`none`||e.perspective!==`none`||e.filter!==`none`||e.backdropFilter&&e.backdropFilter!==`none`||e.willChange!==`auto`&&b.some(t=>e.willChange.includes(t))?!0:e.contain!==`none`&&x.some(t=>e.contain.includes(t))}function C(e){let t=c(e);for(;t;){if(S(getComputedStyle(t)))return t;t=c(t)}return null}function w(){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 T(e){if(!e)return w();if(e instanceof Element){let t=e.getBoundingClientRect();return{height:t.height,width:t.width,x:t.x,y:t.y}}return e}var E=/(hidden|clip|scroll|auto|overlay)/;function D(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 O(e){let t=c(e),n=w();for(;t;){let e=getComputedStyle(t);if(E.test(`${e.overflow}${e.overflowX}${e.overflowY}`)){let e=t.getBoundingClientRect();n=D(n,{height:e.height,width:e.width,x:e.x,y:e.y})}t=c(t)}return n}function k(e,t){return{boundary:T(e.boundary??t.boundary),padding:o(e.padding??t.padding)}}function A(e){return{...e.rects.floating,x:e.x,y:e.y}}function j(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 M(e){return Math.max(e.top,0)+Math.max(e.right,0)+Math.max(e.bottom,0)+Math.max(e.left,0)}function N(e){return e.top>0||e.right>0||e.bottom>0||e.left>0}function P(e,t){return t.top>=e.height||t.right>=e.width||t.bottom>=e.height||t.left>=e.width}function F(e,t,r,i){let a=e.rects.reference;switch(n(t)){case`bottom`:return r.y+r.height-i.bottom-(a.y+a.height);case`left`:return a.x-(r.x+i.left);case`right`:return r.x+r.width-i.right-(a.x+a.width);case`top`:return a.y-(r.y+i.top)}}function I(e,t,n={}){let{x:r,y:i}=u(t,e.rects.reference,e.rects.floating),{boundary:a,padding:o}=k(n,e);return j({...e.rects.floating,x:r,y:i},a,o)}function L(e,t={}){let{boundary:n,padding:r}=k(t,e);return j(A(e),n,r)}function R(e,t){return t===`absolute`?e.offsetParent instanceof Element?e.offsetParent:null:C(e)}function z(e,t,n){t.style.position=n,t.style.left=`${e.x}px`,t.style.top=`${e.y}px`}function B(e,t,{apply:n,autoUpdate:r={},boundary:i=`clippingAncestors`,middleware:a,padding:o,placement:s=`bottom`,strategy:c=`fixed`}={}){let l=new AbortController,u=!0,d=!1,f,m=null,h=!1;function g(){if(!u)return;let r=R(t,c),l=y(e,t,{boundary:i===`clippingAncestors`?O(t):i,containingBlock:r,middleware:a,padding:o,placement:s});m=l,(n??(e=>z(e,t,c)))(l)}function _(){h||d||(h=!0,r===!1?g():f=p(e,t,g,r))}return{get disposalSignal(){return l.signal},dispose(){d||(d=!0,u=!1,l.abort(),f?.())},get disposed(){return d},getPosition:()=>m,start:_,[Symbol.dispose](){this.dispose()},update(){d||g()}}}function V(e){return!(`getClientRects`in e)||typeof e.getClientRects!=`function`?[]:Array.from(e.getClientRects()).map(a).filter(e=>e.width>0||e.height>0)}function H(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 U(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function W(e={}){function t(t){let r=V(t.elements.reference);if(r.length<=1)return;let i=o(e.padding??2),a=n(t.placement),s=r[0];if(e.x!=null&&e.y!=null)s=r.find(t=>H(t,e.x,e.y,i))??s;else if(a===`top`||a===`bottom`){let e=t.x+t.rects.floating.width/2;s=r.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},s)}else{let e=t.y+t.rects.floating.height/2;s=r.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},s)}if(!U(s,t.rects.reference))return{reset:{rects:{...t.rects,reference:s}}}}return t}function G({element:t,padding:r=0}){function i(i){let s=n(i.placement),c=o(r),l=a(t.getBoundingClientRect());if(s===`top`||s===`bottom`){let t=i.rects.reference.x+i.rects.reference.width/2-i.x-l.width/2,n=c.left,r=e(t,n,Math.max(n,i.rects.floating.width-l.width-c.right));return{data:{arrow:{centerOffset:t-r,constrained:r!==t,x:r}}}}let u=i.rects.reference.y+i.rects.reference.height/2-i.y-l.height/2,d=c.top,f=e(u,d,Math.max(d,i.rects.floating.height-l.height-c.bottom));return{data:{arrow:{centerOffset:u-f,constrained:f!==u,y:f}}}}return i}var K=[`top`,`right`,`bottom`,`left`];function q(e){return e===void 0?K:e===null?K.flatMap(e=>[e,`${e}-start`,`${e}-end`]):K.map(t=>`${t}-${e}`)}function J(e={}){return function(t){let{boundary:n,padding:r}=k(e,t),i=e.allowedPlacements??q(e.alignment);i.length;let a=t.placement,o=1/0,s=-1/0;for(let c of i){let i=M(I(t,c,e)),l=F(t,c,n,r);(i<o||i===o&&l>s)&&(a=c,o=i,s=l)}if(a!==t.placement)return{reset:{placement:a}}}}function Y(e={}){function a(a){let o=L(a,e);if(!N(o))return;let s=n(a.placement),c=r(a.placement),l=e.fallbackPlacements??[i(t[s],c)],u=[a.placement],d=a.placement,f=M(o);for(let t of l){let n=I(a,t,e),r=M(n);if(!N(n))return{data:{flip:{skippedPlacements:u}},reset:{placement:t}};u.push(t),r<f&&(d=t,f=r)}if(d!==a.placement)return{data:{flip:{skippedPlacements:u}},reset:{placement:d}}}return a}function X(e={}){let t=e.strategy??`both`;function n(n){let{boundary:r,padding:i}=k(e,n),a={};if(t===`escaped`||t===`both`){let e=A(n),t=j(e,r,i);a.escaped=P(e,t),a.escapedOffsets=t}if(t===`referenceHidden`||t===`both`){let e=j(n.rects.reference,r,i);a.referenceHidden=P(n.rects.reference,e),a.referenceHiddenOffsets=e}return{data:{hide:a}}}return n}function Z(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 Q(e){return function(t){let r=n(t.placement),{crossAxis:i,mainAxis:a}=Z(e,t);switch(r){case`bottom`:return{x:t.x+i,y:t.y+a};case`left`:return{x:t.x-a,y:t.y+i};case`right`:return{x:t.x+a,y:t.y+i};case`top`:return{x:t.x+i,y:t.y-a}}}}function $(t={}){return(r,i)=>{let{placement:a,rects:o,x:s,y:c}=r,l=n(a),u=l===`top`||l===`bottom`,d=typeof t.offset==`function`?t.offset(r):t.offset??0;if(u){let t=o.reference.x-d,n=o.reference.x+o.reference.width+d-o.floating.width,[r,a]=t<=n?[t,n]:[n,t],c=e(s+i.crossAxis,r,a);return{...i,crossAxis:c-s}}let f=o.reference.y-d,p=o.reference.y+o.reference.height+d-o.floating.height,[m,h]=f<=p?[f,p]:[p,f],g=e(c+i.crossAxis,m,h);return{...i,crossAxis:g-c}}}function ee(e={}){let{crossAxis:t=!0,limiter:r,mainAxis:i=!1}=e;function a(a){let o=L(a,e),s=n(a.placement),c=s===`top`||s===`bottom`,l=Math.max(o.left,0)-Math.max(o.right,0),u=Math.max(o.top,0)-Math.max(o.bottom,0),d=c?t:i,f=c?i:t,p=d?l:0,m=f?u:0;if(r){let e=r(a,{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:a.x+p,y:a.y+m}}return a}function te(e={}){function t(t){let{boundary:r,padding:i}=k(e,t),a=n(t.placement),o=r.y+i.top,s=r.x+r.width-i.right,c=r.y+r.height-i.bottom,l=r.x+i.left;return{data:{size:{availableHeight:a===`bottom`?Math.max(0,c-t.y):a===`top`?Math.max(0,t.rects.reference.y-o):Math.max(0,c-o),availableWidth:a===`right`?Math.max(0,s-t.x):a===`left`?Math.max(0,t.rects.reference.x-l):Math.max(0,s-l)}}}}return t}exports.OrbitConfigError=h,exports.OrbitError=m,exports.arrow=G,exports.autoPlacement=J,exports.autoUpdate=p,exports.computePosition=y,exports.createPositioner=B,exports.detectOverflow=L,exports.flip=Y,exports.getAlignment=r,exports.getClippingAncestorRect=O,exports.getSide=n,exports.hide=X,exports.inline=W,exports.limitShift=$,exports.offset=Q,exports.shift=ee,exports.size=te;
2
2
  //# sourceMappingURL=orbit.cjs.map