@vielzeug/orbit 26.11.27 → 26.11.29

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/devtools.cjs CHANGED
@@ -1,2 +1,2 @@
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 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.replaceChildren(),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 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":["createPositioner","require_float","setStyles","key","val","styles","el","createOverlay","createPlacementBadge","text","x","y","createOutlineBox","color","height","width","debugPositioner","overlay","renderOverlay","reference","r","fr","floating","result","userApply","options","wrappedApply","positioner","dispose"],"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 return Object.assign(positioner, {\n dispose(): void {\n dispose();\n overlay.remove();\n },\n });\n}\n"],"mappings":"A,kGAeA,SAASE,EAAU,EAAiB,EAAsC,CACxE,IAAK,GAAM,CAACC,EAAKC,KAAQ,OAAO,QAAQC,CAAM,EAC5CC,EAAG,MAAM,YAAYH,EAAKC,CAAG,CAEjC,CAEA,SAASG,GAA6B,CACpC,IAAMD,EAAK,SAAS,cAAc,KAAK,EAavC,MAXA,GAAG,QAAQ,WAAa,GACxBJ,EAAUI,EAAI,CACZ,cAAe,YACf,YAAa,OACb,KAAM,IACN,iBAAkB,OAClB,SAAU,QACV,IAAK,IACL,UAAW,YACb,CAAC,EAEMA,CACT,CAEA,SAASE,EAAqB,EAAc,EAAW,EAAwB,CAC7E,IAAMF,EAAK,SAAS,cAAc,KAAK,EAcvC,MAZA,GAAG,YAAcG,EACjBP,EAAUI,EAAI,CACZ,WAAY,uBACZ,gBAAiB,MACjB,MAAO,OACP,KAAM,GAAGI,EAAE,IACX,QAAS,UACT,SAAU,QACV,IAAK,GAAG,KAAK,IAAI,EAAGC,CAAC,EAAE,IAC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CAAC,CACH,C"}
1
+ {"version":3,"file":"devtools.cjs","names":["createPositioner","require_float","setStyles","key","val","styles","el","createOverlay","createPlacementBadge","text","x","y","createOutlineBox","color","height","width","debugPositioner","overlay","renderOverlay","reference","r","fr","floating","result","userApply","options","wrappedApply","positioner","dispose"],"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.replaceChildren();\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 return Object.assign(positioner, {\n dispose(): void {\n dispose();\n overlay.remove();\n },\n });\n}\n"],"mappings":"A,kGAeA,SAASE,EAAU,EAAiB,EAAsC,CACxE,IAAK,GAAM,CAACC,EAAKC,KAAQ,OAAO,QAAQC,CAAM,EAC5CC,EAAG,MAAM,YAAYH,EAAK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KC,EAAS,sBAAsB,EAE1CL,EAAQ,YAAYT,EAAqBe,EAAO,UAAWF,EAAG,KAAMA,EAAG,IAAM,EAAE,CAAC,CAClF,CAEA,IAAMG,EAAYC,EAAQ,MAE1B,SAASC,EAAa,EAAqC,CACrDF,EACFA,EAAUD,CAAM,EAEhBtB,EAAA,aAAasB,EAAQD,EAAUG,EAAQ,UAAY,OAAO,EAG5DP,EAAcK,CAAM,CACtB,CAEA,IAAMI,EAAa3B,EAAAA,iBAAiBmB,EAAWG,EAAU,CAAE,GAAGG,EAAS,MAAOC,CAAa,CAAC,EACtFE,EAAUD,EAAW,QAAQ,KAAKA,CAAU,EAElD,OAAO,OAAO,OAAOA,EAAY,CAC/B,SAAgB,CACdC,EAAQ,EACRX,EAAQ,OAAO,CACjB,CACF,CAAC,CACH,C"}
package/dist/devtools.js CHANGED
@@ -1,2 +1,2 @@
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 Object.assign(f,{dispose(){p(),c.remove()}})}export{o 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.replaceChildren(),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 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":["setStyles","key","val","styles","el","createOverlay","createPlacementBadge","text","x","y","createOutlineBox","color","height","width","debugPositioner","overlay","renderOverlay","reference","r","fr","floating","result","userApply","options","wrappedApply","applyDefault","positioner","createPositioner","dispose"],"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 return Object.assign(positioner, {\n dispose(): void {\n dispose();\n overlay.remove();\n },\n });\n}\n"],"mappings":"A,gEAeA,SAASA,EAAU,EAAiB,EAAsC,CACxE,IAAK,GAAM,CAACC,EAAKC,KAAQ,OAAO,QAAQC,CAAM,EAC5CC,EAAG,MAAM,YAAYH,EAAKC,CAAG,CAEjC,CAEA,SAASG,GAA6B,CACpC,IAAMD,EAAK,SAAS,cAAc,KAAK,EAavC,MAXA,GAAG,QAAQ,WAAa,GACxBJ,EAAUI,EAAI,CACZ,cAAe,YACf,YAAa,OACb,KAAM,IACN,iBAAkB,O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UD,CAAM,EAEhBI,EAAaJ,EAAQD,EAAUG,EAAQ,UAAY,OAAO,EAG5DP,EAAcK,CAAM,CACtB,CAEA,IAAMK,EAAaC,EAAiBV,EAAWG,EAAU,CAAE,GAAGG,EAAS,MAAOC,CAAa,CAAC,EACtFI,EAAUF,EAAW,QAAQ,KAAKA,CAAU,EAElD,OAAO,OAAO,OAAOA,EAAY,CAC/B,SAAgB,CACdE,EAAQ,EACRb,EAAQ,OAAO,CACjB,CACF,CAAC,CACH,C"}
1
+ {"version":3,"file":"devtools.js","names":["setStyles","key","val","styles","el","createOverlay","createPlacementBadge","text","x","y","createOutlineBox","color","height","width","debugPositioner","overlay","renderOverlay","reference","r","fr","floating","result","userApply","options","wrappedApply","applyDefault","positioner","createPositioner","dispose"],"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.replaceChildren();\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 return Object.assign(positioner, {\n dispose(): void {\n dispose();\n overlay.remove();\n },\n });\n}\n"],"mappings":"A,gEAeA,SAASA,EAAU,EAAiB,EAAsC,CACxE,IAAK,GAAM,CAACC,EAAKC,KAAQ,OAAO,QAAQC,CAAM,EAC5CC,EAAG,MAAM,YAAYH,EAAKC,CAAG,CAEjC,CAEA,SAASG,GAA6B,CACpC,IAAMD,EAAK,SAAS,cAAc,KAAK,EAavC,MAXA,GAAG,QAAQ,WAAa,GACxBJ,EAAUI,EAAI,CACZ,cAAe,YACf,YAAa,OACb,KAAM,IACN,iBAAkB,OAClB,SAAU,QACV,IAAK,IACL,UAAW,YACb,CAAC,EAEMA,CACT,CAEA,SAASE,EAAqB,EAAc,EAAW,EAAwB,CAC7E,IAAMF,EAAK,SAAS,cAAc,KAAK,EAcvC,MAZA,GAAG,YAAcG,EACjBP,EAAUI,EAAI,CACZ,WAAY,uBACZ,gBAAiB,MACjB,MAAO,OACP,KAAM,GAAGI,EAAE,IACX,QAAS,UACT,SAAU,QACV,IAAK,GAAG,KAAK,IAAI,EAAGC,CAAC,EAAE,IACvB,cAAe,QACjB,CAAC,EAEML,CACT,CAEA,SAASM,EAAiB,EAAW,EAAW,EAAe,EAAgB,EAA4B,CACzG,IAAMN,EAAK,SAAS,cAAc,KAAK,EAWvC,OATAJ,EAAUI,EAAI,CACZ,OAAQ,gBAAgBO,IACxB,OAAQ,GAAGC,EAAO,IAClB,KAAM,GAAGJ,EAAE,IACX,SAAU,QACV,IAAK,GAAGC,EAAE,IACV,MAAO,GAAGI,EAAM,GAClB,CAAC,EAEMT,CACT,CA4BA,SAAgBU,EACd,EACA,EACA,EAA6B,CAAC,EAClB,CACZ,IAAMC,EAAUV,EAAc,EAE9B,SAAS,KAAK,YAAYU,CAAO,EAEjC,SAASC,EAAc,EAAqC,CAO1D,GANAD,EAAQ,gBAAgB,EAGxBA,EAAQ,YAAYL,EAAiB,EAAG,EAAG,OAAO,WAAa,EAAG,OAAO,YAAc,EAAG,qBAAqB,CAAC,EAG5GO,aAAqB,QAAS,CAChC,IAAMC,EAAID,EAAU,sBAAsB,EAE1CF,EAAQ,YAAYL,EAAiBQ,EAAE,KAAMA,EAAE,IAAKA,EAAE,MAAOA,EAAE,OAAQ,qBAAqB,CAAC,CAC/F,CAGA,IAAMC,EAAKC,EAAS,sBAAsB,EAE1CL,EAAQ,YAAYT,EAAqBe,EAAO,UAAWF,EAAG,KAAMA,EAAG,IAAM,EAAE,CAAC,CAClF,CAEA,IAAMG,EAAYC,EAAQ,MAE1B,SAASC,EAAa,EAAqC,CACrDF,EACFA,EAAUD,CAAM,EAEhBI,EAAaJ,EAAQD,EAAUG,EAAQ,UAAY,OAAO,EAG5DP,EAAcK,CAAM,CACtB,CAEA,IAAMK,EAAaC,EAAiBV,EAAWG,EAAU,CAAE,GAAGG,EAAS,MAAOC,CAAa,CAAC,EACtFI,EAAUF,EAAW,QAAQ,KAAKA,CAAU,EAElD,OAAO,OAAO,OAAOA,EAAY,CAC/B,SAAgB,CACdE,EAAQ,EACRb,EAAQ,OAAO,CACjB,CACF,CAAC,CACH,C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vielzeug/orbit",
3
- "version": "26.11.27",
3
+ "version": "26.11.29",
4
4
  "description": "Floating UI positioning with lifecycle-owned geometry and middleware",
5
5
  "repository": {
6
6
  "type": "git",
@@ -68,10 +68,10 @@
68
68
  "test": "vitest"
69
69
  },
70
70
  "dependencies": {
71
- "@vielzeug/arsenal": "26.11.27"
71
+ "@vielzeug/arsenal": "26.11.29"
72
72
  },
73
73
  "peerDependencies": {
74
- "@vielzeug/ripple": "^26.11.27"
74
+ "@vielzeug/ripple": "^26.11.29"
75
75
  },
76
76
  "peerDependenciesMeta": {
77
77
  "@vielzeug/ripple": {
@@ -80,7 +80,7 @@
80
80
  },
81
81
  "devDependencies": {
82
82
  "@types/node": "^26.6.6",
83
- "@vielzeug/ripple": "26.11.27",
83
+ "@vielzeug/ripple": "26.11.29",
84
84
  "typescript": "^6.0.3",
85
85
  "vite": "^8.3.8",
86
86
  "vitest": "^5.1.0"