@vielzeug/orbit 1.1.5 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/README.md +18 -58
  2. package/dist/auto-update.cjs +1 -1
  3. package/dist/auto-update.cjs.map +1 -1
  4. package/dist/auto-update.d.ts.map +1 -1
  5. package/dist/auto-update.js +1 -1
  6. package/dist/auto-update.js.map +1 -1
  7. package/dist/core.cjs +1 -1
  8. package/dist/core.cjs.map +1 -1
  9. package/dist/core.d.ts.map +1 -1
  10. package/dist/core.js +1 -1
  11. package/dist/core.js.map +1 -1
  12. package/dist/devtools.cjs +1 -1
  13. package/dist/devtools.cjs.map +1 -1
  14. package/dist/devtools.d.ts +7 -7
  15. package/dist/devtools.d.ts.map +1 -1
  16. package/dist/devtools.js +1 -1
  17. package/dist/devtools.js.map +1 -1
  18. package/dist/float.cjs +1 -1
  19. package/dist/float.cjs.map +1 -1
  20. package/dist/float.d.ts +18 -65
  21. package/dist/float.d.ts.map +1 -1
  22. package/dist/float.js +1 -1
  23. package/dist/float.js.map +1 -1
  24. package/dist/index.cjs +1 -1
  25. package/dist/index.d.ts +3 -5
  26. package/dist/index.d.ts.map +1 -1
  27. package/dist/index.js +1 -1
  28. package/dist/inline.cjs +1 -1
  29. package/dist/inline.cjs.map +1 -1
  30. package/dist/inline.d.ts +3 -2
  31. package/dist/inline.d.ts.map +1 -1
  32. package/dist/inline.js +1 -1
  33. package/dist/inline.js.map +1 -1
  34. package/dist/middleware/arrow.cjs +1 -1
  35. package/dist/middleware/arrow.cjs.map +1 -1
  36. package/dist/middleware/arrow.d.ts +2 -2
  37. package/dist/middleware/arrow.d.ts.map +1 -1
  38. package/dist/middleware/arrow.js +1 -1
  39. package/dist/middleware/arrow.js.map +1 -1
  40. package/dist/middleware/auto-placement.cjs +1 -1
  41. package/dist/middleware/auto-placement.cjs.map +1 -1
  42. package/dist/middleware/auto-placement.d.ts.map +1 -1
  43. package/dist/middleware/auto-placement.js +1 -1
  44. package/dist/middleware/auto-placement.js.map +1 -1
  45. package/dist/middleware/flip.cjs +1 -1
  46. package/dist/middleware/flip.cjs.map +1 -1
  47. package/dist/middleware/flip.d.ts +2 -2
  48. package/dist/middleware/flip.d.ts.map +1 -1
  49. package/dist/middleware/flip.js +1 -1
  50. package/dist/middleware/flip.js.map +1 -1
  51. package/dist/middleware/hide.cjs +1 -1
  52. package/dist/middleware/hide.cjs.map +1 -1
  53. package/dist/middleware/hide.d.ts +2 -2
  54. package/dist/middleware/hide.d.ts.map +1 -1
  55. package/dist/middleware/hide.js +1 -1
  56. package/dist/middleware/hide.js.map +1 -1
  57. package/dist/middleware/offset.cjs +1 -1
  58. package/dist/middleware/offset.cjs.map +1 -1
  59. package/dist/middleware/offset.js +1 -1
  60. package/dist/middleware/offset.js.map +1 -1
  61. package/dist/middleware/shift.cjs +1 -1
  62. package/dist/middleware/shift.cjs.map +1 -1
  63. package/dist/middleware/shift.d.ts +2 -2
  64. package/dist/middleware/shift.d.ts.map +1 -1
  65. package/dist/middleware/shift.js +1 -1
  66. package/dist/middleware/shift.js.map +1 -1
  67. package/dist/middleware/size.cjs +1 -1
  68. package/dist/middleware/size.cjs.map +1 -1
  69. package/dist/middleware/size.d.ts +6 -5
  70. package/dist/middleware/size.d.ts.map +1 -1
  71. package/dist/middleware/size.js +1 -1
  72. package/dist/middleware/size.js.map +1 -1
  73. package/dist/orbit.cjs +1 -1
  74. package/dist/orbit.cjs.map +1 -1
  75. package/dist/orbit.iife.js +1 -1
  76. package/dist/orbit.iife.js.map +1 -1
  77. package/dist/orbit.js +1 -1
  78. package/dist/orbit.js.map +1 -1
  79. package/dist/presets.cjs.map +1 -1
  80. package/dist/presets.d.ts +9 -5
  81. package/dist/presets.d.ts.map +1 -1
  82. package/dist/presets.js.map +1 -1
  83. package/dist/reactive.cjs +1 -1
  84. package/dist/reactive.cjs.map +1 -1
  85. package/dist/reactive.d.ts +6 -43
  86. package/dist/reactive.d.ts.map +1 -1
  87. package/dist/reactive.js +1 -1
  88. package/dist/reactive.js.map +1 -1
  89. package/dist/types.d.ts +2 -29
  90. package/dist/types.d.ts.map +1 -1
  91. package/dist/utils.cjs +1 -1
  92. package/dist/utils.cjs.map +1 -1
  93. package/dist/utils.d.ts +1 -2
  94. package/dist/utils.d.ts.map +1 -1
  95. package/dist/utils.js +1 -1
  96. package/dist/utils.js.map +1 -1
  97. package/package.json +10 -13
  98. package/dist/compose.cjs +0 -2
  99. package/dist/compose.cjs.map +0 -1
  100. package/dist/compose.d.ts +0 -25
  101. package/dist/compose.d.ts.map +0 -1
  102. package/dist/compose.js +0 -2
  103. package/dist/compose.js.map +0 -1
  104. package/dist/ssr.cjs +0 -2
  105. package/dist/ssr.cjs.map +0 -1
  106. package/dist/ssr.d.ts +0 -41
  107. package/dist/ssr.d.ts.map +0 -1
  108. package/dist/ssr.js +0 -2
  109. package/dist/ssr.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import type { DetectOverflowOptions, HideData, TypedMiddleware } from '../types';
1
+ import type { DetectOverflowOptions, Middleware } from '../types';
2
2
  export interface HideOptions extends DetectOverflowOptions {
3
3
  /**
4
4
  * Which hidden states to compute.
@@ -13,5 +13,5 @@ export interface HideOptions extends DetectOverflowOptions {
13
13
  * Writes `{ referenceHidden, referenceHiddenOffsets, escaped, escapedOffsets }` to
14
14
  * `middlewareData.hide`.
15
15
  */
16
- export declare function hide(options?: HideOptions): TypedMiddleware<'hide', HideData>;
16
+ export declare function hide(options?: HideOptions): Middleware;
17
17
  //# sourceMappingURL=hide.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"hide.d.ts","sourceRoot":"","sources":["../../src/middleware/hide.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,QAAQ,EAAc,eAAe,EAAE,MAAM,UAAU,CAAC;AAK7F,MAAM,WAAW,WAAY,SAAQ,qBAAqB;IACxD;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,iBAAiB,GAAG,SAAS,GAAG,MAAM,CAAC;CACnD;AAED;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,OAAO,GAAE,WAAgB,GAAG,eAAe,CAAC,MAAM,EAAE,QAAQ,CAAC,CA0BjF"}
1
+ {"version":3,"file":"hide.d.ts","sourceRoot":"","sources":["../../src/middleware/hide.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAY,UAAU,EAAE,MAAM,UAAU,CAAC;AAI5E,MAAM,WAAW,WAAY,SAAQ,qBAAqB;IACxD;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,iBAAiB,GAAG,SAAS,GAAG,MAAM,CAAC;CACnD;AAED;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,OAAO,GAAE,WAAgB,GAAG,UAAU,CA0B1D"}
@@ -1,2 +1,2 @@
1
- import{tagMiddleware as e}from"../utils.js";import{detectOverflowAtRect as t,getFloatingRect as n,isFullyClipped as r,resolveBoundary as i}from"../overflow.js";function a(a={}){let o=a.strategy??`both`;function s(e){let{boundary:s,padding:c}=i(a,e),l={};if(o===`escaped`||o===`both`){let i=n(e),a=t(i,s,c);l.escaped=r(i,a),l.escapedOffsets=a}if(o===`referenceHidden`||o===`both`){let n=t(e.rects.reference,s,c);l.referenceHidden=r(e.rects.reference,n),l.referenceHiddenOffsets=n}return{data:{hide:l}}}return e(s,`hide`)}export{a as hide};
1
+ import{detectOverflowAtRect as e,getFloatingRect as t,isFullyClipped as n,resolveBoundary as r}from"../overflow.js";function i(i={}){let a=i.strategy??`both`;function o(o){let{boundary:s,padding:c}=r(i,o),l={};if(a===`escaped`||a===`both`){let r=t(o),i=e(r,s,c);l.escaped=n(r,i),l.escapedOffsets=i}if(a===`referenceHidden`||a===`both`){let t=e(o.rects.reference,s,c);l.referenceHidden=n(o.rects.reference,t),l.referenceHiddenOffsets=t}return{data:{hide:l}}}return o}export{i as hide};
2
2
  //# sourceMappingURL=hide.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"hide.js","names":[],"sources":["../../src/middleware/hide.ts"],"sourcesContent":["import type { DetectOverflowOptions, HideData, Middleware, TypedMiddleware } from '../types';\n\nimport { detectOverflowAtRect, getFloatingRect, isFullyClipped, resolveBoundary } from '../overflow';\nimport { tagMiddleware } from '../utils';\n\nexport interface HideOptions extends DetectOverflowOptions {\n /**\n * Which hidden states to compute.\n * - `'referenceHidden'` — whether the reference itself is off-screen.\n * - `'escaped'` — whether the floating element has fully exited the boundary.\n * - `'both'` (default) — both of the above.\n */\n strategy?: 'referenceHidden' | 'escaped' | 'both';\n}\n\n/**\n * Detects when the reference or floating element is hidden outside the boundary.\n * Writes `{ referenceHidden, referenceHiddenOffsets, escaped, escapedOffsets }` to\n * `middlewareData.hide`.\n */\nexport function hide(options: HideOptions = {}): TypedMiddleware<'hide', HideData> {\n const strategy = options.strategy ?? 'both';\n\n function hideMiddleware(state: Parameters<Middleware>[0]): ReturnType<Middleware> {\n const { boundary, padding } = resolveBoundary(options, state);\n const next: HideData = {};\n\n if (strategy === 'escaped' || strategy === 'both') {\n const floatingRect = getFloatingRect(state);\n const escapedOffsets = detectOverflowAtRect(floatingRect, boundary, padding);\n\n next.escaped = isFullyClipped(floatingRect, escapedOffsets);\n next.escapedOffsets = escapedOffsets;\n }\n\n if (strategy === 'referenceHidden' || strategy === 'both') {\n const referenceHiddenOffsets = detectOverflowAtRect(state.rects.reference, boundary, padding);\n\n next.referenceHidden = isFullyClipped(state.rects.reference, referenceHiddenOffsets);\n next.referenceHiddenOffsets = referenceHiddenOffsets;\n }\n\n return { data: { hide: next } };\n }\n\n return tagMiddleware<'hide', HideData, typeof hideMiddleware>(hideMiddleware, 'hide');\n}\n"],"mappings":"gKAoBA,SAAgB,EAAK,EAAuB,CAAC,EAAsC,CACjF,IAAM,EAAW,EAAQ,UAAY,OAErC,SAAS,EAAe,EAA0D,CAChF,GAAM,CAAE,WAAU,WAAY,EAAgB,EAAS,CAAK,EACtD,EAAiB,CAAC,EAExB,GAAI,IAAa,WAAa,IAAa,OAAQ,CACjD,IAAM,EAAe,EAAgB,CAAK,EACpC,EAAiB,EAAqB,EAAc,EAAU,CAAO,EAE3E,EAAK,QAAU,EAAe,EAAc,CAAc,EAC1D,EAAK,eAAiB,CACxB,CAEA,GAAI,IAAa,mBAAqB,IAAa,OAAQ,CACzD,IAAM,EAAyB,EAAqB,EAAM,MAAM,UAAW,EAAU,CAAO,EAE5F,EAAK,gBAAkB,EAAe,EAAM,MAAM,UAAW,CAAsB,EACnF,EAAK,uBAAyB,CAChC,CAEA,MAAO,CAAE,KAAM,CAAE,KAAM,CAAK,CAAE,CAChC,CAEA,OAAO,EAAuD,EAAgB,MAAM,CACtF"}
1
+ {"version":3,"file":"hide.js","names":[],"sources":["../../src/middleware/hide.ts"],"sourcesContent":["import type { DetectOverflowOptions, HideData, Middleware } from '../types';\n\nimport { detectOverflowAtRect, getFloatingRect, isFullyClipped, resolveBoundary } from '../overflow';\n\nexport interface HideOptions extends DetectOverflowOptions {\n /**\n * Which hidden states to compute.\n * - `'referenceHidden'` — whether the reference itself is off-screen.\n * - `'escaped'` — whether the floating element has fully exited the boundary.\n * - `'both'` (default) — both of the above.\n */\n strategy?: 'referenceHidden' | 'escaped' | 'both';\n}\n\n/**\n * Detects when the reference or floating element is hidden outside the boundary.\n * Writes `{ referenceHidden, referenceHiddenOffsets, escaped, escapedOffsets }` to\n * `middlewareData.hide`.\n */\nexport function hide(options: HideOptions = {}): Middleware {\n const strategy = options.strategy ?? 'both';\n\n function hideMiddleware(state: Parameters<Middleware>[0]): ReturnType<Middleware> {\n const { boundary, padding } = resolveBoundary(options, state);\n const next: HideData = {};\n\n if (strategy === 'escaped' || strategy === 'both') {\n const floatingRect = getFloatingRect(state);\n const escapedOffsets = detectOverflowAtRect(floatingRect, boundary, padding);\n\n next.escaped = isFullyClipped(floatingRect, escapedOffsets);\n next.escapedOffsets = escapedOffsets;\n }\n\n if (strategy === 'referenceHidden' || strategy === 'both') {\n const referenceHiddenOffsets = detectOverflowAtRect(state.rects.reference, boundary, padding);\n\n next.referenceHidden = isFullyClipped(state.rects.reference, referenceHiddenOffsets);\n next.referenceHiddenOffsets = referenceHiddenOffsets;\n }\n\n return { data: { hide: next } };\n }\n\n return hideMiddleware;\n}\n"],"mappings":"oHAmBA,SAAgB,EAAK,EAAuB,CAAC,EAAe,CAC1D,IAAM,EAAW,EAAQ,UAAY,OAErC,SAAS,EAAe,EAA0D,CAChF,GAAM,CAAE,WAAU,WAAY,EAAgB,EAAS,CAAK,EACtD,EAAiB,CAAC,EAExB,GAAI,IAAa,WAAa,IAAa,OAAQ,CACjD,IAAM,EAAe,EAAgB,CAAK,EACpC,EAAiB,EAAqB,EAAc,EAAU,CAAO,EAE3E,EAAK,QAAU,EAAe,EAAc,CAAc,EAC1D,EAAK,eAAiB,CACxB,CAEA,GAAI,IAAa,mBAAqB,IAAa,OAAQ,CACzD,IAAM,EAAyB,EAAqB,EAAM,MAAM,UAAW,EAAU,CAAO,EAE5F,EAAK,gBAAkB,EAAe,EAAM,MAAM,UAAW,CAAsB,EACnF,EAAK,uBAAyB,CAChC,CAEA,MAAO,CAAE,KAAM,CAAE,KAAM,CAAK,CAAE,CAChC,CAEA,OAAO,CACT"}
@@ -1,2 +1,2 @@
1
- const e=require("../utils.cjs");function t(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 n(n){return e.tagMiddleware(function(r){let i=e.getSide(r.placement),{crossAxis:a,mainAxis:o}=t(n,r);switch(i){case`bottom`:return{x:r.x+a,y:r.y+o};case`left`:return{x:r.x-o,y:r.y+a};case`right`:return{x:r.x+o,y:r.y+a};case`top`:return{x:r.x+a,y:r.y-o}}},`offset`)}exports.offset=n;
1
+ const e=require("../utils.cjs");function t(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 n(n){return function(r){let i=e.getSide(r.placement),{crossAxis:a,mainAxis:o}=t(n,r);switch(i){case`bottom`:return{x:r.x+a,y:r.y+o};case`left`:return{x:r.x-o,y:r.y+a};case`right`:return{x:r.x+o,y:r.y+a};case`top`:return{x:r.x+a,y:r.y-o}}}}exports.offset=n;
2
2
  //# sourceMappingURL=offset.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"offset.cjs","names":[],"sources":["../../src/middleware/offset.ts"],"sourcesContent":["import type { Middleware, MiddlewareState } from '../types';\n\nimport { getSide, tagMiddleware } from '../utils';\n\nexport type OffsetConfig = {\n /** Offset perpendicular to the main axis. */\n crossAxis?: number;\n /** Offset along the axis away from the reference. */\n mainAxis?: number;\n};\n\nexport type OffsetValue = number | OffsetConfig | ((state: MiddlewareState) => number | OffsetConfig);\n\nfunction resolveOffsetConfig(value: OffsetValue, state: MiddlewareState): Required<OffsetConfig> {\n const raw = typeof value === 'function' ? value(state) : value;\n\n if (typeof raw === 'number') return { crossAxis: 0, mainAxis: raw };\n\n return { crossAxis: raw.crossAxis ?? 0, mainAxis: raw.mainAxis ?? 0 };\n}\n\n/**\n * Shifts the floating element along the main axis (away from reference) and/or\n * the cross axis. Accepts a number, config object, or a function for dynamic values.\n *\n * Must be the **first** middleware in the pipeline.\n */\nexport function offset(value: OffsetValue): Middleware {\n return tagMiddleware(function offsetMiddleware(state: Parameters<Middleware>[0]): ReturnType<Middleware> {\n const side = getSide(state.placement);\n const { crossAxis, mainAxis } = resolveOffsetConfig(value, state);\n\n switch (side) {\n case 'bottom':\n return { x: state.x + crossAxis, y: state.y + mainAxis };\n case 'left':\n return { x: state.x - mainAxis, y: state.y + crossAxis };\n case 'right':\n return { x: state.x + mainAxis, y: state.y + crossAxis };\n case 'top':\n return { x: state.x + crossAxis, y: state.y - mainAxis };\n }\n }, 'offset');\n}\n"],"mappings":"gCAaA,SAAS,EAAoB,EAAoB,EAAgD,CAC/F,IAAM,EAAM,OAAO,GAAU,WAAa,EAAM,CAAK,EAAI,EAIzD,OAFI,OAAO,GAAQ,SAAiB,CAAE,UAAW,EAAG,SAAU,CAAI,EAE3D,CAAE,UAAW,EAAI,WAAa,EAAG,SAAU,EAAI,UAAY,CAAE,CACtE,CAQA,SAAgB,EAAO,EAAgC,CACrD,OAAO,EAAA,cAAc,SAA0B,EAA0D,CACvG,IAAM,EAAO,EAAA,QAAQ,EAAM,SAAS,EAC9B,CAAE,YAAW,YAAa,EAAoB,EAAO,CAAK,EAEhE,OAAQ,EAAR,CACE,IAAK,SACH,MAAO,CAAE,EAAG,EAAM,EAAI,EAAW,EAAG,EAAM,EAAI,CAAS,EACzD,IAAK,OACH,MAAO,CAAE,EAAG,EAAM,EAAI,EAAU,EAAG,EAAM,EAAI,CAAU,EACzD,IAAK,QACH,MAAO,CAAE,EAAG,EAAM,EAAI,EAAU,EAAG,EAAM,EAAI,CAAU,EACzD,IAAK,MACH,MAAO,CAAE,EAAG,EAAM,EAAI,EAAW,EAAG,EAAM,EAAI,CAAS,CAC3D,CACF,EAAG,QAAQ,CACb"}
1
+ {"version":3,"file":"offset.cjs","names":[],"sources":["../../src/middleware/offset.ts"],"sourcesContent":["import type { Middleware, MiddlewareState } from '../types';\n\nimport { getSide } from '../utils';\n\nexport type OffsetConfig = {\n /** Offset perpendicular to the main axis. */\n crossAxis?: number;\n /** Offset along the axis away from the reference. */\n mainAxis?: number;\n};\n\nexport type OffsetValue = number | OffsetConfig | ((state: MiddlewareState) => number | OffsetConfig);\n\nfunction resolveOffsetConfig(value: OffsetValue, state: MiddlewareState): Required<OffsetConfig> {\n const raw = typeof value === 'function' ? value(state) : value;\n\n if (typeof raw === 'number') return { crossAxis: 0, mainAxis: raw };\n\n return { crossAxis: raw.crossAxis ?? 0, mainAxis: raw.mainAxis ?? 0 };\n}\n\n/**\n * Shifts the floating element along the main axis (away from reference) and/or\n * the cross axis. Accepts a number, config object, or a function for dynamic values.\n *\n * Must be the **first** middleware in the pipeline.\n */\nexport function offset(value: OffsetValue): Middleware {\n return function offsetMiddleware(state: Parameters<Middleware>[0]): ReturnType<Middleware> {\n const side = getSide(state.placement);\n const { crossAxis, mainAxis } = resolveOffsetConfig(value, state);\n\n switch (side) {\n case 'bottom':\n return { x: state.x + crossAxis, y: state.y + mainAxis };\n case 'left':\n return { x: state.x - mainAxis, y: state.y + crossAxis };\n case 'right':\n return { x: state.x + mainAxis, y: state.y + crossAxis };\n case 'top':\n return { x: state.x + crossAxis, y: state.y - mainAxis };\n }\n };\n}\n"],"mappings":"gCAaA,SAAS,EAAoB,EAAoB,EAAgD,CAC/F,IAAM,EAAM,OAAO,GAAU,WAAa,EAAM,CAAK,EAAI,EAIzD,OAFI,OAAO,GAAQ,SAAiB,CAAE,UAAW,EAAG,SAAU,CAAI,EAE3D,CAAE,UAAW,EAAI,WAAa,EAAG,SAAU,EAAI,UAAY,CAAE,CACtE,CAQA,SAAgB,EAAO,EAAgC,CACrD,OAAO,SAA0B,EAA0D,CACzF,IAAM,EAAO,EAAA,QAAQ,EAAM,SAAS,EAC9B,CAAE,YAAW,YAAa,EAAoB,EAAO,CAAK,EAEhE,OAAQ,EAAR,CACE,IAAK,SACH,MAAO,CAAE,EAAG,EAAM,EAAI,EAAW,EAAG,EAAM,EAAI,CAAS,EACzD,IAAK,OACH,MAAO,CAAE,EAAG,EAAM,EAAI,EAAU,EAAG,EAAM,EAAI,CAAU,EACzD,IAAK,QACH,MAAO,CAAE,EAAG,EAAM,EAAI,EAAU,EAAG,EAAM,EAAI,CAAU,EACzD,IAAK,MACH,MAAO,CAAE,EAAG,EAAM,EAAI,EAAW,EAAG,EAAM,EAAI,CAAS,CAC3D,CACF,CACF"}
@@ -1,2 +1,2 @@
1
- import{getSide as e,tagMiddleware as t}from"../utils.js";function n(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 r(r){return t(function(t){let i=e(t.placement),{crossAxis:a,mainAxis:o}=n(r,t);switch(i){case`bottom`:return{x:t.x+a,y:t.y+o};case`left`:return{x:t.x-o,y:t.y+a};case`right`:return{x:t.x+o,y:t.y+a};case`top`:return{x:t.x+a,y:t.y-o}}},`offset`)}export{r as offset};
1
+ import{getSide as e}from"../utils.js";function t(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 n(n){return function(r){let i=e(r.placement),{crossAxis:a,mainAxis:o}=t(n,r);switch(i){case`bottom`:return{x:r.x+a,y:r.y+o};case`left`:return{x:r.x-o,y:r.y+a};case`right`:return{x:r.x+o,y:r.y+a};case`top`:return{x:r.x+a,y:r.y-o}}}}export{n as offset};
2
2
  //# sourceMappingURL=offset.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"offset.js","names":[],"sources":["../../src/middleware/offset.ts"],"sourcesContent":["import type { Middleware, MiddlewareState } from '../types';\n\nimport { getSide, tagMiddleware } from '../utils';\n\nexport type OffsetConfig = {\n /** Offset perpendicular to the main axis. */\n crossAxis?: number;\n /** Offset along the axis away from the reference. */\n mainAxis?: number;\n};\n\nexport type OffsetValue = number | OffsetConfig | ((state: MiddlewareState) => number | OffsetConfig);\n\nfunction resolveOffsetConfig(value: OffsetValue, state: MiddlewareState): Required<OffsetConfig> {\n const raw = typeof value === 'function' ? value(state) : value;\n\n if (typeof raw === 'number') return { crossAxis: 0, mainAxis: raw };\n\n return { crossAxis: raw.crossAxis ?? 0, mainAxis: raw.mainAxis ?? 0 };\n}\n\n/**\n * Shifts the floating element along the main axis (away from reference) and/or\n * the cross axis. Accepts a number, config object, or a function for dynamic values.\n *\n * Must be the **first** middleware in the pipeline.\n */\nexport function offset(value: OffsetValue): Middleware {\n return tagMiddleware(function offsetMiddleware(state: Parameters<Middleware>[0]): ReturnType<Middleware> {\n const side = getSide(state.placement);\n const { crossAxis, mainAxis } = resolveOffsetConfig(value, state);\n\n switch (side) {\n case 'bottom':\n return { x: state.x + crossAxis, y: state.y + mainAxis };\n case 'left':\n return { x: state.x - mainAxis, y: state.y + crossAxis };\n case 'right':\n return { x: state.x + mainAxis, y: state.y + crossAxis };\n case 'top':\n return { x: state.x + crossAxis, y: state.y - mainAxis };\n }\n }, 'offset');\n}\n"],"mappings":"yDAaA,SAAS,EAAoB,EAAoB,EAAgD,CAC/F,IAAM,EAAM,OAAO,GAAU,WAAa,EAAM,CAAK,EAAI,EAIzD,OAFI,OAAO,GAAQ,SAAiB,CAAE,UAAW,EAAG,SAAU,CAAI,EAE3D,CAAE,UAAW,EAAI,WAAa,EAAG,SAAU,EAAI,UAAY,CAAE,CACtE,CAQA,SAAgB,EAAO,EAAgC,CACrD,OAAO,EAAc,SAA0B,EAA0D,CACvG,IAAM,EAAO,EAAQ,EAAM,SAAS,EAC9B,CAAE,YAAW,YAAa,EAAoB,EAAO,CAAK,EAEhE,OAAQ,EAAR,CACE,IAAK,SACH,MAAO,CAAE,EAAG,EAAM,EAAI,EAAW,EAAG,EAAM,EAAI,CAAS,EACzD,IAAK,OACH,MAAO,CAAE,EAAG,EAAM,EAAI,EAAU,EAAG,EAAM,EAAI,CAAU,EACzD,IAAK,QACH,MAAO,CAAE,EAAG,EAAM,EAAI,EAAU,EAAG,EAAM,EAAI,CAAU,EACzD,IAAK,MACH,MAAO,CAAE,EAAG,EAAM,EAAI,EAAW,EAAG,EAAM,EAAI,CAAS,CAC3D,CACF,EAAG,QAAQ,CACb"}
1
+ {"version":3,"file":"offset.js","names":[],"sources":["../../src/middleware/offset.ts"],"sourcesContent":["import type { Middleware, MiddlewareState } from '../types';\n\nimport { getSide } from '../utils';\n\nexport type OffsetConfig = {\n /** Offset perpendicular to the main axis. */\n crossAxis?: number;\n /** Offset along the axis away from the reference. */\n mainAxis?: number;\n};\n\nexport type OffsetValue = number | OffsetConfig | ((state: MiddlewareState) => number | OffsetConfig);\n\nfunction resolveOffsetConfig(value: OffsetValue, state: MiddlewareState): Required<OffsetConfig> {\n const raw = typeof value === 'function' ? value(state) : value;\n\n if (typeof raw === 'number') return { crossAxis: 0, mainAxis: raw };\n\n return { crossAxis: raw.crossAxis ?? 0, mainAxis: raw.mainAxis ?? 0 };\n}\n\n/**\n * Shifts the floating element along the main axis (away from reference) and/or\n * the cross axis. Accepts a number, config object, or a function for dynamic values.\n *\n * Must be the **first** middleware in the pipeline.\n */\nexport function offset(value: OffsetValue): Middleware {\n return function offsetMiddleware(state: Parameters<Middleware>[0]): ReturnType<Middleware> {\n const side = getSide(state.placement);\n const { crossAxis, mainAxis } = resolveOffsetConfig(value, state);\n\n switch (side) {\n case 'bottom':\n return { x: state.x + crossAxis, y: state.y + mainAxis };\n case 'left':\n return { x: state.x - mainAxis, y: state.y + crossAxis };\n case 'right':\n return { x: state.x + mainAxis, y: state.y + crossAxis };\n case 'top':\n return { x: state.x + crossAxis, y: state.y - mainAxis };\n }\n };\n}\n"],"mappings":"sCAaA,SAAS,EAAoB,EAAoB,EAAgD,CAC/F,IAAM,EAAM,OAAO,GAAU,WAAa,EAAM,CAAK,EAAI,EAIzD,OAFI,OAAO,GAAQ,SAAiB,CAAE,UAAW,EAAG,SAAU,CAAI,EAE3D,CAAE,UAAW,EAAI,WAAa,EAAG,SAAU,EAAI,UAAY,CAAE,CACtE,CAQA,SAAgB,EAAO,EAAgC,CACrD,OAAO,SAA0B,EAA0D,CACzF,IAAM,EAAO,EAAQ,EAAM,SAAS,EAC9B,CAAE,YAAW,YAAa,EAAoB,EAAO,CAAK,EAEhE,OAAQ,EAAR,CACE,IAAK,SACH,MAAO,CAAE,EAAG,EAAM,EAAI,EAAW,EAAG,EAAM,EAAI,CAAS,EACzD,IAAK,OACH,MAAO,CAAE,EAAG,EAAM,EAAI,EAAU,EAAG,EAAM,EAAI,CAAU,EACzD,IAAK,QACH,MAAO,CAAE,EAAG,EAAM,EAAI,EAAU,EAAG,EAAM,EAAI,CAAU,EACzD,IAAK,MACH,MAAO,CAAE,EAAG,EAAM,EAAI,EAAW,EAAG,EAAM,EAAI,CAAS,CAC3D,CACF,CACF"}
@@ -1,2 +1,2 @@
1
- const e=require("../utils.cjs"),t=require("../overflow.cjs");let n=require("@vielzeug/arsenal/math");function r(t={}){return(r,i)=>{let{placement:a,rects:o,x:s,y:c}=r,l=e.getSide(a),u=l===`top`||l===`bottom`,d=typeof t.offset==`function`?t.offset(r):t.offset??0;if(u){let e=o.reference.x-d,t=o.reference.x+o.reference.width+d-o.floating.width,[r,a]=e<=t?[e,t]:[t,e],c=(0,n.clamp)(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=(0,n.clamp)(c+i.crossAxis,m,h);return{...i,crossAxis:g-c}}}function i(n={}){let{crossAxis:r=!0,limiter:i,mainAxis:a=!1}=n;function o(o){let s=t.detectOverflow(o,n),c=e.getSide(o.placement),l=c===`top`||c===`bottom`,u=Math.max(s.left,0)-Math.max(s.right,0),d=Math.max(s.top,0)-Math.max(s.bottom,0),f=l?r:a,p=l?a:r,m=f?u:0,h=p?d:0;if(i){let e=i(o,{crossAxis:l?m:h,mainAxis:l?h:m});m=l?e.crossAxis:e.mainAxis,h=l?e.mainAxis:e.crossAxis}return{data:{shift:{x:m,y:h}},x:o.x+m,y:o.y+h}}return e.tagMiddleware(o,`shift`)}exports.limitShift=r,exports.shift=i;
1
+ const e=require("../utils.cjs"),t=require("../overflow.cjs");function n(t={}){return(n,r)=>{let{placement:i,rects:a,x:o,y:s}=n,c=e.getSide(i),l=c===`top`||c===`bottom`,u=typeof t.offset==`function`?t.offset(n):t.offset??0;if(l){let t=a.reference.x-u,n=a.reference.x+a.reference.width+u-a.floating.width,[i,s]=t<=n?[t,n]:[n,t],c=e.clamp(o+r.crossAxis,i,s);return{...r,crossAxis:c-o}}let d=a.reference.y-u,f=a.reference.y+a.reference.height+u-a.floating.height,[p,m]=d<=f?[d,f]:[f,d],h=e.clamp(s+r.crossAxis,p,m);return{...r,crossAxis:h-s}}}function r(n={}){let{crossAxis:r=!0,limiter:i,mainAxis:a=!1}=n;function o(o){let s=t.detectOverflow(o,n),c=e.getSide(o.placement),l=c===`top`||c===`bottom`,u=Math.max(s.left,0)-Math.max(s.right,0),d=Math.max(s.top,0)-Math.max(s.bottom,0),f=l?r:a,p=l?a:r,m=f?u:0,h=p?d:0;if(i){let e=i(o,{crossAxis:l?m:h,mainAxis:l?h:m});m=l?e.crossAxis:e.mainAxis,h=l?e.mainAxis:e.crossAxis}return{data:{shift:{x:m,y:h}},x:o.x+m,y:o.y+h}}return o}exports.limitShift=n,exports.shift=r;
2
2
  //# sourceMappingURL=shift.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"shift.cjs","names":[],"sources":["../../src/middleware/shift.ts"],"sourcesContent":["import type { DetectOverflowOptions, Middleware, MiddlewareState, ShiftData, TypedMiddleware } from '../types';\n\nimport { detectOverflow } from '../overflow';\nimport { clamp, getSide, tagMiddleware } from '../utils';\n\n/**\n * A limiter function passed to `shift()` that constrains the maximum allowed drift.\n * Receives the current middleware state and the proposed shift correction (as deltas),\n * and returns the clamped correction.\n */\nexport type ShiftLimiter = (\n state: MiddlewareState,\n correction: { crossAxis: number; mainAxis: number },\n) => { crossAxis: number; mainAxis: number };\n\nexport interface LimitShiftOptions {\n /**\n * Extra pixels of allowed drift past the reference's cross-axis extent before clamping kicks in.\n * Can be a static number or a function returning a number based on current state.\n * Default: `0`.\n */\n offset?: number | ((state: MiddlewareState) => number);\n}\n\n/**\n * Returns a {@link ShiftLimiter} that constrains `shift()` so the floating element\n * stays visually connected to the reference along the cross axis.\n *\n * Without a limiter, `shift()` will push the float as far as needed to fit in the boundary —\n * potentially sliding it far away from the reference. `limitShift` clamps the drift so the\n * float stays within the reference's cross-axis extent (± `offset` pixels).\n *\n * @example\n * ```ts\n * // Tooltip stays above the button even when viewport clips it.\n * shift({ padding: 6, limiter: limitShift() })\n *\n * // Allow up to 10px of drift beyond the reference's edges.\n * shift({ padding: 6, limiter: limitShift({ offset: 10 }) })\n * ```\n */\nexport function limitShift(options: LimitShiftOptions = {}): ShiftLimiter {\n return (state, correction) => {\n const { placement, rects, x, y } = state;\n const side = getSide(placement);\n const isVertical = side === 'top' || side === 'bottom';\n const extra = typeof options.offset === 'function' ? options.offset(state) : (options.offset ?? 0);\n\n if (isVertical) {\n // Cross axis is x. Clamp float.left to [ref.left-extra, ref.right+extra-float.width].\n const lo = rects.reference.x - extra;\n const hi = rects.reference.x + rects.reference.width + extra - rects.floating.width;\n const [min, max] = lo <= hi ? [lo, hi] : [hi, lo];\n const clamped = clamp(x + correction.crossAxis, min, max);\n\n return { ...correction, crossAxis: clamped - x };\n }\n\n // Cross axis is y. Clamp float.top to [ref.top-extra, ref.bottom+extra-float.height].\n const lo = rects.reference.y - extra;\n const hi = rects.reference.y + rects.reference.height + extra - rects.floating.height;\n const [min, max] = lo <= hi ? [lo, hi] : [hi, lo];\n const clamped = clamp(y + correction.crossAxis, min, max);\n\n return { ...correction, crossAxis: clamped - y };\n };\n}\n\nexport interface ShiftOptions extends DetectOverflowOptions {\n /**\n * Whether to shift along the main axis (the axis away from the reference).\n * Default: `false` — main-axis overflow is better handled by `flip`.\n */\n mainAxis?: boolean;\n /**\n * Whether to shift along the cross axis (perpendicular to the reference direction).\n * Default: `true`.\n */\n crossAxis?: boolean;\n /**\n * Constrains how far `shift()` can move the floating element along the cross axis.\n * Pass `limitShift()` to keep the float within the reference's extent.\n */\n limiter?: ShiftLimiter;\n}\n\n/**\n * Shifts the floating element along the cross axis to keep it inside the boundary.\n *\n * By default only the cross axis is corrected. Enable `mainAxis` to also shift\n * along the main axis (useful when `flip` is not in the pipeline).\n *\n * | Placement | Cross axis | Main axis |\n * |------------------|------------|-----------|\n * | `top` / `bottom` | horizontal | vertical |\n * | `left` / `right` | vertical | horizontal|\n */\nexport function shift(options: ShiftOptions = {}): TypedMiddleware<'shift', ShiftData> {\n const { crossAxis = true, limiter, mainAxis = false } = options;\n\n function shiftMiddleware(state: Parameters<Middleware>[0]): ReturnType<Middleware> {\n const overflow = detectOverflow(state, options);\n const side = getSide(state.placement);\n const isVertical = side === 'top' || side === 'bottom';\n\n const xCorrection = Math.max(overflow.left, 0) - Math.max(overflow.right, 0);\n const yCorrection = Math.max(overflow.top, 0) - Math.max(overflow.bottom, 0);\n const applyX = isVertical ? crossAxis : mainAxis;\n const applyY = isVertical ? mainAxis : crossAxis;\n\n let dx = applyX ? xCorrection : 0;\n let dy = applyY ? yCorrection : 0;\n\n if (limiter) {\n const limited = limiter(state, {\n crossAxis: isVertical ? dx : dy,\n mainAxis: isVertical ? dy : dx,\n });\n\n dx = isVertical ? limited.crossAxis : limited.mainAxis;\n dy = isVertical ? limited.mainAxis : limited.crossAxis;\n }\n\n return { data: { shift: { x: dx, y: dy } }, x: state.x + dx, y: state.y + dy };\n }\n\n return tagMiddleware<'shift', ShiftData, typeof shiftMiddleware>(shiftMiddleware, 'shift');\n}\n"],"mappings":"qGAyCA,SAAgB,EAAW,EAA6B,CAAC,EAAiB,CACxE,OAAQ,EAAO,IAAe,CAC5B,GAAM,CAAE,YAAW,QAAO,IAAG,KAAM,EAC7B,EAAO,EAAA,QAAQ,CAAS,EACxB,EAAa,IAAS,OAAS,IAAS,SACxC,EAAQ,OAAO,EAAQ,QAAW,WAAa,EAAQ,OAAO,CAAK,EAAK,EAAQ,QAAU,EAEhG,GAAI,EAAY,CAEd,IAAM,EAAK,EAAM,UAAU,EAAI,EACzB,EAAK,EAAM,UAAU,EAAI,EAAM,UAAU,MAAQ,EAAQ,EAAM,SAAS,MACxE,CAAC,EAAK,GAAO,GAAM,EAAK,CAAC,EAAI,CAAE,EAAI,CAAC,EAAI,CAAE,EAC1C,GAAA,EAAU,EAAA,MAAA,CAAM,EAAI,EAAW,UAAW,EAAK,CAAG,EAExD,MAAO,CAAE,GAAG,EAAY,UAAW,EAAU,CAAE,CACjD,CAGA,IAAM,EAAK,EAAM,UAAU,EAAI,EACzB,EAAK,EAAM,UAAU,EAAI,EAAM,UAAU,OAAS,EAAQ,EAAM,SAAS,OACzE,CAAC,EAAK,GAAO,GAAM,EAAK,CAAC,EAAI,CAAE,EAAI,CAAC,EAAI,CAAE,EAC1C,GAAA,EAAU,EAAA,MAAA,CAAM,EAAI,EAAW,UAAW,EAAK,CAAG,EAExD,MAAO,CAAE,GAAG,EAAY,UAAW,EAAU,CAAE,CACjD,CACF,CA+BA,SAAgB,EAAM,EAAwB,CAAC,EAAwC,CACrF,GAAM,CAAE,YAAY,GAAM,UAAS,WAAW,IAAU,EAExD,SAAS,EAAgB,EAA0D,CACjF,IAAM,EAAW,EAAA,eAAe,EAAO,CAAO,EACxC,EAAO,EAAA,QAAQ,EAAM,SAAS,EAC9B,EAAa,IAAS,OAAS,IAAS,SAExC,EAAc,KAAK,IAAI,EAAS,KAAM,CAAC,EAAI,KAAK,IAAI,EAAS,MAAO,CAAC,EACrE,EAAc,KAAK,IAAI,EAAS,IAAK,CAAC,EAAI,KAAK,IAAI,EAAS,OAAQ,CAAC,EACrE,EAAS,EAAa,EAAY,EAClC,EAAS,EAAa,EAAW,EAEnC,EAAK,EAAS,EAAc,EAC5B,EAAK,EAAS,EAAc,EAEhC,GAAI,EAAS,CACX,IAAM,EAAU,EAAQ,EAAO,CAC7B,UAAW,EAAa,EAAK,EAC7B,SAAU,EAAa,EAAK,CAC9B,CAAC,EAED,EAAK,EAAa,EAAQ,UAAY,EAAQ,SAC9C,EAAK,EAAa,EAAQ,SAAW,EAAQ,SAC/C,CAEA,MAAO,CAAE,KAAM,CAAE,MAAO,CAAE,EAAG,EAAI,EAAG,CAAG,CAAE,EAAG,EAAG,EAAM,EAAI,EAAI,EAAG,EAAM,EAAI,CAAG,CAC/E,CAEA,OAAO,EAAA,cAA0D,EAAiB,OAAO,CAC3F"}
1
+ {"version":3,"file":"shift.cjs","names":[],"sources":["../../src/middleware/shift.ts"],"sourcesContent":["import type { DetectOverflowOptions, Middleware, MiddlewareState } from '../types';\n\nimport { detectOverflow } from '../overflow';\nimport { clamp, getSide } from '../utils';\n\n/**\n * A limiter function passed to `shift()` that constrains the maximum allowed drift.\n * Receives the current middleware state and the proposed shift correction (as deltas),\n * and returns the clamped correction.\n */\nexport type ShiftLimiter = (\n state: MiddlewareState,\n correction: { crossAxis: number; mainAxis: number },\n) => { crossAxis: number; mainAxis: number };\n\nexport interface LimitShiftOptions {\n /**\n * Extra pixels of allowed drift past the reference's cross-axis extent before clamping kicks in.\n * Can be a static number or a function returning a number based on current state.\n * Default: `0`.\n */\n offset?: number | ((state: MiddlewareState) => number);\n}\n\n/**\n * Returns a {@link ShiftLimiter} that constrains `shift()` so the floating element\n * stays visually connected to the reference along the cross axis.\n *\n * Without a limiter, `shift()` will push the float as far as needed to fit in the boundary —\n * potentially sliding it far away from the reference. `limitShift` clamps the drift so the\n * float stays within the reference's cross-axis extent (± `offset` pixels).\n *\n * @example\n * ```ts\n * // Tooltip stays above the button even when viewport clips it.\n * shift({ padding: 6, limiter: limitShift() })\n *\n * // Allow up to 10px of drift beyond the reference's edges.\n * shift({ padding: 6, limiter: limitShift({ offset: 10 }) })\n * ```\n */\nexport function limitShift(options: LimitShiftOptions = {}): ShiftLimiter {\n return (state, correction) => {\n const { placement, rects, x, y } = state;\n const side = getSide(placement);\n const isVertical = side === 'top' || side === 'bottom';\n const extra = typeof options.offset === 'function' ? options.offset(state) : (options.offset ?? 0);\n\n if (isVertical) {\n // Cross axis is x. Clamp float.left to [ref.left-extra, ref.right+extra-float.width].\n const lo = rects.reference.x - extra;\n const hi = rects.reference.x + rects.reference.width + extra - rects.floating.width;\n const [min, max] = lo <= hi ? [lo, hi] : [hi, lo];\n const clamped = clamp(x + correction.crossAxis, min, max);\n\n return { ...correction, crossAxis: clamped - x };\n }\n\n // Cross axis is y. Clamp float.top to [ref.top-extra, ref.bottom+extra-float.height].\n const lo = rects.reference.y - extra;\n const hi = rects.reference.y + rects.reference.height + extra - rects.floating.height;\n const [min, max] = lo <= hi ? [lo, hi] : [hi, lo];\n const clamped = clamp(y + correction.crossAxis, min, max);\n\n return { ...correction, crossAxis: clamped - y };\n };\n}\n\nexport interface ShiftOptions extends DetectOverflowOptions {\n /**\n * Whether to shift along the main axis (the axis away from the reference).\n * Default: `false` — main-axis overflow is better handled by `flip`.\n */\n mainAxis?: boolean;\n /**\n * Whether to shift along the cross axis (perpendicular to the reference direction).\n * Default: `true`.\n */\n crossAxis?: boolean;\n /**\n * Constrains how far `shift()` can move the floating element along the cross axis.\n * Pass `limitShift()` to keep the float within the reference's extent.\n */\n limiter?: ShiftLimiter;\n}\n\n/**\n * Shifts the floating element along the cross axis to keep it inside the boundary.\n *\n * By default only the cross axis is corrected. Enable `mainAxis` to also shift\n * along the main axis (useful when `flip` is not in the pipeline).\n *\n * | Placement | Cross axis | Main axis |\n * |------------------|------------|-----------|\n * | `top` / `bottom` | horizontal | vertical |\n * | `left` / `right` | vertical | horizontal|\n */\nexport function shift(options: ShiftOptions = {}): Middleware {\n const { crossAxis = true, limiter, mainAxis = false } = options;\n\n function shiftMiddleware(state: Parameters<Middleware>[0]): ReturnType<Middleware> {\n const overflow = detectOverflow(state, options);\n const side = getSide(state.placement);\n const isVertical = side === 'top' || side === 'bottom';\n\n const xCorrection = Math.max(overflow.left, 0) - Math.max(overflow.right, 0);\n const yCorrection = Math.max(overflow.top, 0) - Math.max(overflow.bottom, 0);\n const applyX = isVertical ? crossAxis : mainAxis;\n const applyY = isVertical ? mainAxis : crossAxis;\n\n let dx = applyX ? xCorrection : 0;\n let dy = applyY ? yCorrection : 0;\n\n if (limiter) {\n const limited = limiter(state, {\n crossAxis: isVertical ? dx : dy,\n mainAxis: isVertical ? dy : dx,\n });\n\n dx = isVertical ? limited.crossAxis : limited.mainAxis;\n dy = isVertical ? limited.mainAxis : limited.crossAxis;\n }\n\n return { data: { shift: { x: dx, y: dy } }, x: state.x + dx, y: state.y + dy };\n }\n\n return shiftMiddleware;\n}\n"],"mappings":"6DAyCA,SAAgB,EAAW,EAA6B,CAAC,EAAiB,CACxE,OAAQ,EAAO,IAAe,CAC5B,GAAM,CAAE,YAAW,QAAO,IAAG,KAAM,EAC7B,EAAO,EAAA,QAAQ,CAAS,EACxB,EAAa,IAAS,OAAS,IAAS,SACxC,EAAQ,OAAO,EAAQ,QAAW,WAAa,EAAQ,OAAO,CAAK,EAAK,EAAQ,QAAU,EAEhG,GAAI,EAAY,CAEd,IAAM,EAAK,EAAM,UAAU,EAAI,EACzB,EAAK,EAAM,UAAU,EAAI,EAAM,UAAU,MAAQ,EAAQ,EAAM,SAAS,MACxE,CAAC,EAAK,GAAO,GAAM,EAAK,CAAC,EAAI,CAAE,EAAI,CAAC,EAAI,CAAE,EAC1C,EAAU,EAAA,MAAM,EAAI,EAAW,UAAW,EAAK,CAAG,EAExD,MAAO,CAAE,GAAG,EAAY,UAAW,EAAU,CAAE,CACjD,CAGA,IAAM,EAAK,EAAM,UAAU,EAAI,EACzB,EAAK,EAAM,UAAU,EAAI,EAAM,UAAU,OAAS,EAAQ,EAAM,SAAS,OACzE,CAAC,EAAK,GAAO,GAAM,EAAK,CAAC,EAAI,CAAE,EAAI,CAAC,EAAI,CAAE,EAC1C,EAAU,EAAA,MAAM,EAAI,EAAW,UAAW,EAAK,CAAG,EAExD,MAAO,CAAE,GAAG,EAAY,UAAW,EAAU,CAAE,CACjD,CACF,CA+BA,SAAgB,EAAM,EAAwB,CAAC,EAAe,CAC5D,GAAM,CAAE,YAAY,GAAM,UAAS,WAAW,IAAU,EAExD,SAAS,EAAgB,EAA0D,CACjF,IAAM,EAAW,EAAA,eAAe,EAAO,CAAO,EACxC,EAAO,EAAA,QAAQ,EAAM,SAAS,EAC9B,EAAa,IAAS,OAAS,IAAS,SAExC,EAAc,KAAK,IAAI,EAAS,KAAM,CAAC,EAAI,KAAK,IAAI,EAAS,MAAO,CAAC,EACrE,EAAc,KAAK,IAAI,EAAS,IAAK,CAAC,EAAI,KAAK,IAAI,EAAS,OAAQ,CAAC,EACrE,EAAS,EAAa,EAAY,EAClC,EAAS,EAAa,EAAW,EAEnC,EAAK,EAAS,EAAc,EAC5B,EAAK,EAAS,EAAc,EAEhC,GAAI,EAAS,CACX,IAAM,EAAU,EAAQ,EAAO,CAC7B,UAAW,EAAa,EAAK,EAC7B,SAAU,EAAa,EAAK,CAC9B,CAAC,EAED,EAAK,EAAa,EAAQ,UAAY,EAAQ,SAC9C,EAAK,EAAa,EAAQ,SAAW,EAAQ,SAC/C,CAEA,MAAO,CAAE,KAAM,CAAE,MAAO,CAAE,EAAG,EAAI,EAAG,CAAG,CAAE,EAAG,EAAG,EAAM,EAAI,EAAI,EAAG,EAAM,EAAI,CAAG,CAC/E,CAEA,OAAO,CACT"}
@@ -1,4 +1,4 @@
1
- import type { DetectOverflowOptions, MiddlewareState, ShiftData, TypedMiddleware } from '../types';
1
+ import type { DetectOverflowOptions, Middleware, MiddlewareState } from '../types';
2
2
  /**
3
3
  * A limiter function passed to `shift()` that constrains the maximum allowed drift.
4
4
  * Receives the current middleware state and the proposed shift correction (as deltas),
@@ -65,5 +65,5 @@ export interface ShiftOptions extends DetectOverflowOptions {
65
65
  * | `top` / `bottom` | horizontal | vertical |
66
66
  * | `left` / `right` | vertical | horizontal|
67
67
  */
68
- export declare function shift(options?: ShiftOptions): TypedMiddleware<'shift', ShiftData>;
68
+ export declare function shift(options?: ShiftOptions): Middleware;
69
69
  //# sourceMappingURL=shift.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"shift.d.ts","sourceRoot":"","sources":["../../src/middleware/shift.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAc,eAAe,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAK/G;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG,CACzB,KAAK,EAAE,eAAe,EACtB,UAAU,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,KAChD;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AAE7C,MAAM,WAAW,iBAAiB;IAChC;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,KAAK,EAAE,eAAe,KAAK,MAAM,CAAC,CAAC;CACxD;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,UAAU,CAAC,OAAO,GAAE,iBAAsB,GAAG,YAAY,CAyBxE;AAED,MAAM,WAAW,YAAa,SAAQ,qBAAqB;IACzD;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;OAGG;IACH,OAAO,CAAC,EAAE,YAAY,CAAC;CACxB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,KAAK,CAAC,OAAO,GAAE,YAAiB,GAAG,eAAe,CAAC,OAAO,EAAE,SAAS,CAAC,CA8BrF"}
1
+ {"version":3,"file":"shift.d.ts","sourceRoot":"","sources":["../../src/middleware/shift.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAKnF;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG,CACzB,KAAK,EAAE,eAAe,EACtB,UAAU,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,KAChD;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AAE7C,MAAM,WAAW,iBAAiB;IAChC;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,KAAK,EAAE,eAAe,KAAK,MAAM,CAAC,CAAC;CACxD;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,UAAU,CAAC,OAAO,GAAE,iBAAsB,GAAG,YAAY,CAyBxE;AAED,MAAM,WAAW,YAAa,SAAQ,qBAAqB;IACzD;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;OAGG;IACH,OAAO,CAAC,EAAE,YAAY,CAAC;CACxB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,KAAK,CAAC,OAAO,GAAE,YAAiB,GAAG,UAAU,CA8B5D"}
@@ -1,2 +1,2 @@
1
- import{clamp as e,getSide as t,tagMiddleware as n}from"../utils.js";import{detectOverflow as r}from"../overflow.js";function i(n={}){return(r,i)=>{let{placement:a,rects:o,x:s,y:c}=r,l=t(a),u=l===`top`||l===`bottom`,d=typeof n.offset==`function`?n.offset(r):n.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 a(e={}){let{crossAxis:i=!0,limiter:a,mainAxis:o=!1}=e;function s(n){let s=r(n,e),c=t(n.placement),l=c===`top`||c===`bottom`,u=Math.max(s.left,0)-Math.max(s.right,0),d=Math.max(s.top,0)-Math.max(s.bottom,0),f=l?i:o,p=l?o:i,m=f?u:0,h=p?d:0;if(a){let e=a(n,{crossAxis:l?m:h,mainAxis:l?h:m});m=l?e.crossAxis:e.mainAxis,h=l?e.mainAxis:e.crossAxis}return{data:{shift:{x:m,y:h}},x:n.x+m,y:n.y+h}}return n(s,`shift`)}export{i as limitShift,a as shift};
1
+ import{clamp as e,getSide as t}from"../utils.js";import{detectOverflow as n}from"../overflow.js";function r(n={}){return(r,i)=>{let{placement:a,rects:o,x:s,y:c}=r,l=t(a),u=l===`top`||l===`bottom`,d=typeof n.offset==`function`?n.offset(r):n.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 i(e={}){let{crossAxis:r=!0,limiter:i,mainAxis:a=!1}=e;function o(o){let s=n(o,e),c=t(o.placement),l=c===`top`||c===`bottom`,u=Math.max(s.left,0)-Math.max(s.right,0),d=Math.max(s.top,0)-Math.max(s.bottom,0),f=l?r:a,p=l?a:r,m=f?u:0,h=p?d:0;if(i){let e=i(o,{crossAxis:l?m:h,mainAxis:l?h:m});m=l?e.crossAxis:e.mainAxis,h=l?e.mainAxis:e.crossAxis}return{data:{shift:{x:m,y:h}},x:o.x+m,y:o.y+h}}return o}export{r as limitShift,i as shift};
2
2
  //# sourceMappingURL=shift.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"shift.js","names":[],"sources":["../../src/middleware/shift.ts"],"sourcesContent":["import type { DetectOverflowOptions, Middleware, MiddlewareState, ShiftData, TypedMiddleware } from '../types';\n\nimport { detectOverflow } from '../overflow';\nimport { clamp, getSide, tagMiddleware } from '../utils';\n\n/**\n * A limiter function passed to `shift()` that constrains the maximum allowed drift.\n * Receives the current middleware state and the proposed shift correction (as deltas),\n * and returns the clamped correction.\n */\nexport type ShiftLimiter = (\n state: MiddlewareState,\n correction: { crossAxis: number; mainAxis: number },\n) => { crossAxis: number; mainAxis: number };\n\nexport interface LimitShiftOptions {\n /**\n * Extra pixels of allowed drift past the reference's cross-axis extent before clamping kicks in.\n * Can be a static number or a function returning a number based on current state.\n * Default: `0`.\n */\n offset?: number | ((state: MiddlewareState) => number);\n}\n\n/**\n * Returns a {@link ShiftLimiter} that constrains `shift()` so the floating element\n * stays visually connected to the reference along the cross axis.\n *\n * Without a limiter, `shift()` will push the float as far as needed to fit in the boundary —\n * potentially sliding it far away from the reference. `limitShift` clamps the drift so the\n * float stays within the reference's cross-axis extent (± `offset` pixels).\n *\n * @example\n * ```ts\n * // Tooltip stays above the button even when viewport clips it.\n * shift({ padding: 6, limiter: limitShift() })\n *\n * // Allow up to 10px of drift beyond the reference's edges.\n * shift({ padding: 6, limiter: limitShift({ offset: 10 }) })\n * ```\n */\nexport function limitShift(options: LimitShiftOptions = {}): ShiftLimiter {\n return (state, correction) => {\n const { placement, rects, x, y } = state;\n const side = getSide(placement);\n const isVertical = side === 'top' || side === 'bottom';\n const extra = typeof options.offset === 'function' ? options.offset(state) : (options.offset ?? 0);\n\n if (isVertical) {\n // Cross axis is x. Clamp float.left to [ref.left-extra, ref.right+extra-float.width].\n const lo = rects.reference.x - extra;\n const hi = rects.reference.x + rects.reference.width + extra - rects.floating.width;\n const [min, max] = lo <= hi ? [lo, hi] : [hi, lo];\n const clamped = clamp(x + correction.crossAxis, min, max);\n\n return { ...correction, crossAxis: clamped - x };\n }\n\n // Cross axis is y. Clamp float.top to [ref.top-extra, ref.bottom+extra-float.height].\n const lo = rects.reference.y - extra;\n const hi = rects.reference.y + rects.reference.height + extra - rects.floating.height;\n const [min, max] = lo <= hi ? [lo, hi] : [hi, lo];\n const clamped = clamp(y + correction.crossAxis, min, max);\n\n return { ...correction, crossAxis: clamped - y };\n };\n}\n\nexport interface ShiftOptions extends DetectOverflowOptions {\n /**\n * Whether to shift along the main axis (the axis away from the reference).\n * Default: `false` — main-axis overflow is better handled by `flip`.\n */\n mainAxis?: boolean;\n /**\n * Whether to shift along the cross axis (perpendicular to the reference direction).\n * Default: `true`.\n */\n crossAxis?: boolean;\n /**\n * Constrains how far `shift()` can move the floating element along the cross axis.\n * Pass `limitShift()` to keep the float within the reference's extent.\n */\n limiter?: ShiftLimiter;\n}\n\n/**\n * Shifts the floating element along the cross axis to keep it inside the boundary.\n *\n * By default only the cross axis is corrected. Enable `mainAxis` to also shift\n * along the main axis (useful when `flip` is not in the pipeline).\n *\n * | Placement | Cross axis | Main axis |\n * |------------------|------------|-----------|\n * | `top` / `bottom` | horizontal | vertical |\n * | `left` / `right` | vertical | horizontal|\n */\nexport function shift(options: ShiftOptions = {}): TypedMiddleware<'shift', ShiftData> {\n const { crossAxis = true, limiter, mainAxis = false } = options;\n\n function shiftMiddleware(state: Parameters<Middleware>[0]): ReturnType<Middleware> {\n const overflow = detectOverflow(state, options);\n const side = getSide(state.placement);\n const isVertical = side === 'top' || side === 'bottom';\n\n const xCorrection = Math.max(overflow.left, 0) - Math.max(overflow.right, 0);\n const yCorrection = Math.max(overflow.top, 0) - Math.max(overflow.bottom, 0);\n const applyX = isVertical ? crossAxis : mainAxis;\n const applyY = isVertical ? mainAxis : crossAxis;\n\n let dx = applyX ? xCorrection : 0;\n let dy = applyY ? yCorrection : 0;\n\n if (limiter) {\n const limited = limiter(state, {\n crossAxis: isVertical ? dx : dy,\n mainAxis: isVertical ? dy : dx,\n });\n\n dx = isVertical ? limited.crossAxis : limited.mainAxis;\n dy = isVertical ? limited.mainAxis : limited.crossAxis;\n }\n\n return { data: { shift: { x: dx, y: dy } }, x: state.x + dx, y: state.y + dy };\n }\n\n return tagMiddleware<'shift', ShiftData, typeof shiftMiddleware>(shiftMiddleware, 'shift');\n}\n"],"mappings":"oHAyCA,SAAgB,EAAW,EAA6B,CAAC,EAAiB,CACxE,OAAQ,EAAO,IAAe,CAC5B,GAAM,CAAE,YAAW,QAAO,IAAG,KAAM,EAC7B,EAAO,EAAQ,CAAS,EACxB,EAAa,IAAS,OAAS,IAAS,SACxC,EAAQ,OAAO,EAAQ,QAAW,WAAa,EAAQ,OAAO,CAAK,EAAK,EAAQ,QAAU,EAEhG,GAAI,EAAY,CAEd,IAAM,EAAK,EAAM,UAAU,EAAI,EACzB,EAAK,EAAM,UAAU,EAAI,EAAM,UAAU,MAAQ,EAAQ,EAAM,SAAS,MACxE,CAAC,EAAK,GAAO,GAAM,EAAK,CAAC,EAAI,CAAE,EAAI,CAAC,EAAI,CAAE,EAC1C,EAAU,EAAM,EAAI,EAAW,UAAW,EAAK,CAAG,EAExD,MAAO,CAAE,GAAG,EAAY,UAAW,EAAU,CAAE,CACjD,CAGA,IAAM,EAAK,EAAM,UAAU,EAAI,EACzB,EAAK,EAAM,UAAU,EAAI,EAAM,UAAU,OAAS,EAAQ,EAAM,SAAS,OACzE,CAAC,EAAK,GAAO,GAAM,EAAK,CAAC,EAAI,CAAE,EAAI,CAAC,EAAI,CAAE,EAC1C,EAAU,EAAM,EAAI,EAAW,UAAW,EAAK,CAAG,EAExD,MAAO,CAAE,GAAG,EAAY,UAAW,EAAU,CAAE,CACjD,CACF,CA+BA,SAAgB,EAAM,EAAwB,CAAC,EAAwC,CACrF,GAAM,CAAE,YAAY,GAAM,UAAS,WAAW,IAAU,EAExD,SAAS,EAAgB,EAA0D,CACjF,IAAM,EAAW,EAAe,EAAO,CAAO,EACxC,EAAO,EAAQ,EAAM,SAAS,EAC9B,EAAa,IAAS,OAAS,IAAS,SAExC,EAAc,KAAK,IAAI,EAAS,KAAM,CAAC,EAAI,KAAK,IAAI,EAAS,MAAO,CAAC,EACrE,EAAc,KAAK,IAAI,EAAS,IAAK,CAAC,EAAI,KAAK,IAAI,EAAS,OAAQ,CAAC,EACrE,EAAS,EAAa,EAAY,EAClC,EAAS,EAAa,EAAW,EAEnC,EAAK,EAAS,EAAc,EAC5B,EAAK,EAAS,EAAc,EAEhC,GAAI,EAAS,CACX,IAAM,EAAU,EAAQ,EAAO,CAC7B,UAAW,EAAa,EAAK,EAC7B,SAAU,EAAa,EAAK,CAC9B,CAAC,EAED,EAAK,EAAa,EAAQ,UAAY,EAAQ,SAC9C,EAAK,EAAa,EAAQ,SAAW,EAAQ,SAC/C,CAEA,MAAO,CAAE,KAAM,CAAE,MAAO,CAAE,EAAG,EAAI,EAAG,CAAG,CAAE,EAAG,EAAG,EAAM,EAAI,EAAI,EAAG,EAAM,EAAI,CAAG,CAC/E,CAEA,OAAO,EAA0D,EAAiB,OAAO,CAC3F"}
1
+ {"version":3,"file":"shift.js","names":[],"sources":["../../src/middleware/shift.ts"],"sourcesContent":["import type { DetectOverflowOptions, Middleware, MiddlewareState } from '../types';\n\nimport { detectOverflow } from '../overflow';\nimport { clamp, getSide } from '../utils';\n\n/**\n * A limiter function passed to `shift()` that constrains the maximum allowed drift.\n * Receives the current middleware state and the proposed shift correction (as deltas),\n * and returns the clamped correction.\n */\nexport type ShiftLimiter = (\n state: MiddlewareState,\n correction: { crossAxis: number; mainAxis: number },\n) => { crossAxis: number; mainAxis: number };\n\nexport interface LimitShiftOptions {\n /**\n * Extra pixels of allowed drift past the reference's cross-axis extent before clamping kicks in.\n * Can be a static number or a function returning a number based on current state.\n * Default: `0`.\n */\n offset?: number | ((state: MiddlewareState) => number);\n}\n\n/**\n * Returns a {@link ShiftLimiter} that constrains `shift()` so the floating element\n * stays visually connected to the reference along the cross axis.\n *\n * Without a limiter, `shift()` will push the float as far as needed to fit in the boundary —\n * potentially sliding it far away from the reference. `limitShift` clamps the drift so the\n * float stays within the reference's cross-axis extent (± `offset` pixels).\n *\n * @example\n * ```ts\n * // Tooltip stays above the button even when viewport clips it.\n * shift({ padding: 6, limiter: limitShift() })\n *\n * // Allow up to 10px of drift beyond the reference's edges.\n * shift({ padding: 6, limiter: limitShift({ offset: 10 }) })\n * ```\n */\nexport function limitShift(options: LimitShiftOptions = {}): ShiftLimiter {\n return (state, correction) => {\n const { placement, rects, x, y } = state;\n const side = getSide(placement);\n const isVertical = side === 'top' || side === 'bottom';\n const extra = typeof options.offset === 'function' ? options.offset(state) : (options.offset ?? 0);\n\n if (isVertical) {\n // Cross axis is x. Clamp float.left to [ref.left-extra, ref.right+extra-float.width].\n const lo = rects.reference.x - extra;\n const hi = rects.reference.x + rects.reference.width + extra - rects.floating.width;\n const [min, max] = lo <= hi ? [lo, hi] : [hi, lo];\n const clamped = clamp(x + correction.crossAxis, min, max);\n\n return { ...correction, crossAxis: clamped - x };\n }\n\n // Cross axis is y. Clamp float.top to [ref.top-extra, ref.bottom+extra-float.height].\n const lo = rects.reference.y - extra;\n const hi = rects.reference.y + rects.reference.height + extra - rects.floating.height;\n const [min, max] = lo <= hi ? [lo, hi] : [hi, lo];\n const clamped = clamp(y + correction.crossAxis, min, max);\n\n return { ...correction, crossAxis: clamped - y };\n };\n}\n\nexport interface ShiftOptions extends DetectOverflowOptions {\n /**\n * Whether to shift along the main axis (the axis away from the reference).\n * Default: `false` — main-axis overflow is better handled by `flip`.\n */\n mainAxis?: boolean;\n /**\n * Whether to shift along the cross axis (perpendicular to the reference direction).\n * Default: `true`.\n */\n crossAxis?: boolean;\n /**\n * Constrains how far `shift()` can move the floating element along the cross axis.\n * Pass `limitShift()` to keep the float within the reference's extent.\n */\n limiter?: ShiftLimiter;\n}\n\n/**\n * Shifts the floating element along the cross axis to keep it inside the boundary.\n *\n * By default only the cross axis is corrected. Enable `mainAxis` to also shift\n * along the main axis (useful when `flip` is not in the pipeline).\n *\n * | Placement | Cross axis | Main axis |\n * |------------------|------------|-----------|\n * | `top` / `bottom` | horizontal | vertical |\n * | `left` / `right` | vertical | horizontal|\n */\nexport function shift(options: ShiftOptions = {}): Middleware {\n const { crossAxis = true, limiter, mainAxis = false } = options;\n\n function shiftMiddleware(state: Parameters<Middleware>[0]): ReturnType<Middleware> {\n const overflow = detectOverflow(state, options);\n const side = getSide(state.placement);\n const isVertical = side === 'top' || side === 'bottom';\n\n const xCorrection = Math.max(overflow.left, 0) - Math.max(overflow.right, 0);\n const yCorrection = Math.max(overflow.top, 0) - Math.max(overflow.bottom, 0);\n const applyX = isVertical ? crossAxis : mainAxis;\n const applyY = isVertical ? mainAxis : crossAxis;\n\n let dx = applyX ? xCorrection : 0;\n let dy = applyY ? yCorrection : 0;\n\n if (limiter) {\n const limited = limiter(state, {\n crossAxis: isVertical ? dx : dy,\n mainAxis: isVertical ? dy : dx,\n });\n\n dx = isVertical ? limited.crossAxis : limited.mainAxis;\n dy = isVertical ? limited.mainAxis : limited.crossAxis;\n }\n\n return { data: { shift: { x: dx, y: dy } }, x: state.x + dx, y: state.y + dy };\n }\n\n return shiftMiddleware;\n}\n"],"mappings":"iGAyCA,SAAgB,EAAW,EAA6B,CAAC,EAAiB,CACxE,OAAQ,EAAO,IAAe,CAC5B,GAAM,CAAE,YAAW,QAAO,IAAG,KAAM,EAC7B,EAAO,EAAQ,CAAS,EACxB,EAAa,IAAS,OAAS,IAAS,SACxC,EAAQ,OAAO,EAAQ,QAAW,WAAa,EAAQ,OAAO,CAAK,EAAK,EAAQ,QAAU,EAEhG,GAAI,EAAY,CAEd,IAAM,EAAK,EAAM,UAAU,EAAI,EACzB,EAAK,EAAM,UAAU,EAAI,EAAM,UAAU,MAAQ,EAAQ,EAAM,SAAS,MACxE,CAAC,EAAK,GAAO,GAAM,EAAK,CAAC,EAAI,CAAE,EAAI,CAAC,EAAI,CAAE,EAC1C,EAAU,EAAM,EAAI,EAAW,UAAW,EAAK,CAAG,EAExD,MAAO,CAAE,GAAG,EAAY,UAAW,EAAU,CAAE,CACjD,CAGA,IAAM,EAAK,EAAM,UAAU,EAAI,EACzB,EAAK,EAAM,UAAU,EAAI,EAAM,UAAU,OAAS,EAAQ,EAAM,SAAS,OACzE,CAAC,EAAK,GAAO,GAAM,EAAK,CAAC,EAAI,CAAE,EAAI,CAAC,EAAI,CAAE,EAC1C,EAAU,EAAM,EAAI,EAAW,UAAW,EAAK,CAAG,EAExD,MAAO,CAAE,GAAG,EAAY,UAAW,EAAU,CAAE,CACjD,CACF,CA+BA,SAAgB,EAAM,EAAwB,CAAC,EAAe,CAC5D,GAAM,CAAE,YAAY,GAAM,UAAS,WAAW,IAAU,EAExD,SAAS,EAAgB,EAA0D,CACjF,IAAM,EAAW,EAAe,EAAO,CAAO,EACxC,EAAO,EAAQ,EAAM,SAAS,EAC9B,EAAa,IAAS,OAAS,IAAS,SAExC,EAAc,KAAK,IAAI,EAAS,KAAM,CAAC,EAAI,KAAK,IAAI,EAAS,MAAO,CAAC,EACrE,EAAc,KAAK,IAAI,EAAS,IAAK,CAAC,EAAI,KAAK,IAAI,EAAS,OAAQ,CAAC,EACrE,EAAS,EAAa,EAAY,EAClC,EAAS,EAAa,EAAW,EAEnC,EAAK,EAAS,EAAc,EAC5B,EAAK,EAAS,EAAc,EAEhC,GAAI,EAAS,CACX,IAAM,EAAU,EAAQ,EAAO,CAC7B,UAAW,EAAa,EAAK,EAC7B,SAAU,EAAa,EAAK,CAC9B,CAAC,EAED,EAAK,EAAa,EAAQ,UAAY,EAAQ,SAC9C,EAAK,EAAa,EAAQ,SAAW,EAAQ,SAC/C,CAEA,MAAO,CAAE,KAAM,CAAE,MAAO,CAAE,EAAG,EAAI,EAAG,CAAG,CAAE,EAAG,EAAG,EAAM,EAAI,EAAI,EAAG,EAAM,EAAI,CAAG,CAC/E,CAEA,OAAO,CACT"}
@@ -1,2 +1,2 @@
1
- const e=require("../utils.cjs"),t=require("../overflow.cjs");function n(n={}){function r(r){let{boundary:i,padding:a}=t.resolveBoundary(n,r),o=e.getSide(r.placement),s=i.y+a.top,c=i.x+i.width-a.right,l=i.y+i.height-a.bottom,u=i.x+a.left;return{data:{size:{availableHeight:o===`bottom`?Math.max(0,l-r.y):o===`top`?Math.max(0,r.rects.reference.y-s):Math.max(0,l-s),availableWidth:o===`right`?Math.max(0,c-r.x):o===`left`?Math.max(0,r.rects.reference.x-u):Math.max(0,c-u)}}}}return e.tagMiddleware(r,`size`)}exports.size=n;
1
+ const e=require("../utils.cjs"),t=require("../overflow.cjs");function n(n={}){function r(r){let{boundary:i,padding:a}=t.resolveBoundary(n,r),o=e.getSide(r.placement),s=i.y+a.top,c=i.x+i.width-a.right,l=i.y+i.height-a.bottom,u=i.x+a.left;return{data:{size:{availableHeight:o===`bottom`?Math.max(0,l-r.y):o===`top`?Math.max(0,r.rects.reference.y-s):Math.max(0,l-s),availableWidth:o===`right`?Math.max(0,c-r.x):o===`left`?Math.max(0,r.rects.reference.x-u):Math.max(0,c-u)}}}}return r}exports.size=n;
2
2
  //# sourceMappingURL=size.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"size.cjs","names":[],"sources":["../../src/middleware/size.ts"],"sourcesContent":["import type { DetectOverflowOptions, Middleware, SizeData, TypedMiddleware } from '../types';\n\nimport { resolveBoundary } from '../overflow';\nimport { getSide, tagMiddleware } from '../utils';\n\nexport type SizeOptions = DetectOverflowOptions;\n\n/**\n * Reports the available space between the reference and boundary edges.\n *\n * Available dimensions are written to `middlewareData.size`.\n *\n * Read `result.middlewareData.size` in the `float()` `apply` option or after `computePosition()`\n * to constrain the floating element's dimensions.\n *\n * @example\n * ```ts\n * const cleanup = float(ref, el, {\n * middleware: [offset(8), flip(), shift(), size()],\n * apply(result) {\n * el.style.maxHeight = `${result.middlewareData.size!.availableHeight}px`;\n * },\n * });\n * ```\n */\nexport function size(options: SizeOptions = {}): TypedMiddleware<'size', SizeData> {\n function sizeMiddleware(state: Parameters<Middleware>[0]): ReturnType<Middleware> {\n const { boundary, padding } = resolveBoundary(options, state);\n const side = getSide(state.placement);\n const top = boundary.y + padding.top;\n const right = boundary.x + boundary.width - padding.right;\n const bottom = boundary.y + boundary.height - padding.bottom;\n const left = boundary.x + padding.left;\n\n const availableHeight =\n side === 'bottom'\n ? Math.max(0, bottom - state.y)\n : side === 'top'\n ? Math.max(0, state.rects.reference.y - top)\n : Math.max(0, bottom - top);\n\n const availableWidth =\n side === 'right'\n ? Math.max(0, right - state.x)\n : side === 'left'\n ? Math.max(0, state.rects.reference.x - left)\n : Math.max(0, right - left);\n\n const sizeData: SizeData = { availableHeight, availableWidth };\n\n return { data: { size: sizeData } };\n }\n\n return tagMiddleware<'size', SizeData, typeof sizeMiddleware>(sizeMiddleware, 'size');\n}\n"],"mappings":"6DAyBA,SAAgB,EAAK,EAAuB,CAAC,EAAsC,CACjF,SAAS,EAAe,EAA0D,CAChF,GAAM,CAAE,WAAU,WAAY,EAAA,gBAAgB,EAAS,CAAK,EACtD,EAAO,EAAA,QAAQ,EAAM,SAAS,EAC9B,EAAM,EAAS,EAAI,EAAQ,IAC3B,EAAQ,EAAS,EAAI,EAAS,MAAQ,EAAQ,MAC9C,EAAS,EAAS,EAAI,EAAS,OAAS,EAAQ,OAChD,EAAO,EAAS,EAAI,EAAQ,KAkBlC,MAAO,CAAE,KAAM,CAAE,KAAM,CAFM,gBAb3B,IAAS,SACL,KAAK,IAAI,EAAG,EAAS,EAAM,CAAC,EAC5B,IAAS,MACP,KAAK,IAAI,EAAG,EAAM,MAAM,UAAU,EAAI,CAAG,EACzC,KAAK,IAAI,EAAG,EAAS,CAAG,EASc,eAN5C,IAAS,QACL,KAAK,IAAI,EAAG,EAAQ,EAAM,CAAC,EAC3B,IAAS,OACP,KAAK,IAAI,EAAG,EAAM,MAAM,UAAU,EAAI,CAAI,EAC1C,KAAK,IAAI,EAAG,EAAQ,CAAI,CAIT,CAAS,CAAE,CACpC,CAEA,OAAO,EAAA,cAAuD,EAAgB,MAAM,CACtF"}
1
+ {"version":3,"file":"size.cjs","names":[],"sources":["../../src/middleware/size.ts"],"sourcesContent":["import type { DetectOverflowOptions, Middleware } from '../types';\n\nimport { resolveBoundary } from '../overflow';\nimport { getSide } from '../utils';\n\nexport type SizeOptions = DetectOverflowOptions;\n\n/**\n * Reports the available space between the reference and boundary edges.\n *\n * Available dimensions are written to `middlewareData.size`.\n *\n * Read `result.middlewareData.size` in the positioner `apply` option or after `computePosition()`\n * to constrain the floating element's dimensions.\n *\n * @example\n * ```ts\n * const positioner = createPositioner(ref, el, {\n * middleware: [offset(8), flip(), shift(), size()],\n * apply(result) {\n * el.style.maxHeight = `${(result.middlewareData.size as SizeData).availableHeight}px`;\n * },\n * });\n * positioner.start();\n * ```\n */\nexport function size(options: SizeOptions = {}): Middleware {\n function sizeMiddleware(state: Parameters<Middleware>[0]): ReturnType<Middleware> {\n const { boundary, padding } = resolveBoundary(options, state);\n const side = getSide(state.placement);\n const top = boundary.y + padding.top;\n const right = boundary.x + boundary.width - padding.right;\n const bottom = boundary.y + boundary.height - padding.bottom;\n const left = boundary.x + padding.left;\n\n const availableHeight =\n side === 'bottom'\n ? Math.max(0, bottom - state.y)\n : side === 'top'\n ? Math.max(0, state.rects.reference.y - top)\n : Math.max(0, bottom - top);\n\n const availableWidth =\n side === 'right'\n ? Math.max(0, right - state.x)\n : side === 'left'\n ? Math.max(0, state.rects.reference.x - left)\n : Math.max(0, right - left);\n\n return { data: { size: { availableHeight, availableWidth } } };\n }\n\n return sizeMiddleware;\n}\n"],"mappings":"6DA0BA,SAAgB,EAAK,EAAuB,CAAC,EAAe,CAC1D,SAAS,EAAe,EAA0D,CAChF,GAAM,CAAE,WAAU,WAAY,EAAA,gBAAgB,EAAS,CAAK,EACtD,EAAO,EAAA,QAAQ,EAAM,SAAS,EAC9B,EAAM,EAAS,EAAI,EAAQ,IAC3B,EAAQ,EAAS,EAAI,EAAS,MAAQ,EAAQ,MAC9C,EAAS,EAAS,EAAI,EAAS,OAAS,EAAQ,OAChD,EAAO,EAAS,EAAI,EAAQ,KAgBlC,MAAO,CAAE,KAAM,CAAE,KAAM,CAAE,gBAbvB,IAAS,SACL,KAAK,IAAI,EAAG,EAAS,EAAM,CAAC,EAC5B,IAAS,MACP,KAAK,IAAI,EAAG,EAAM,MAAM,UAAU,EAAI,CAAG,EACzC,KAAK,IAAI,EAAG,EAAS,CAAG,EASU,eANxC,IAAS,QACL,KAAK,IAAI,EAAG,EAAQ,EAAM,CAAC,EAC3B,IAAS,OACP,KAAK,IAAI,EAAG,EAAM,MAAM,UAAU,EAAI,CAAI,EAC1C,KAAK,IAAI,EAAG,EAAQ,CAAI,CAEyB,CAAE,CAAE,CAC/D,CAEA,OAAO,CACT"}
@@ -1,22 +1,23 @@
1
- import type { DetectOverflowOptions, SizeData, TypedMiddleware } from '../types';
1
+ import type { DetectOverflowOptions, Middleware } from '../types';
2
2
  export type SizeOptions = DetectOverflowOptions;
3
3
  /**
4
4
  * Reports the available space between the reference and boundary edges.
5
5
  *
6
6
  * Available dimensions are written to `middlewareData.size`.
7
7
  *
8
- * Read `result.middlewareData.size` in the `float()` `apply` option or after `computePosition()`
8
+ * Read `result.middlewareData.size` in the positioner `apply` option or after `computePosition()`
9
9
  * to constrain the floating element's dimensions.
10
10
  *
11
11
  * @example
12
12
  * ```ts
13
- * const cleanup = float(ref, el, {
13
+ * const positioner = createPositioner(ref, el, {
14
14
  * middleware: [offset(8), flip(), shift(), size()],
15
15
  * apply(result) {
16
- * el.style.maxHeight = `${result.middlewareData.size!.availableHeight}px`;
16
+ * el.style.maxHeight = `${(result.middlewareData.size as SizeData).availableHeight}px`;
17
17
  * },
18
18
  * });
19
+ * positioner.start();
19
20
  * ```
20
21
  */
21
- export declare function size(options?: SizeOptions): TypedMiddleware<'size', SizeData>;
22
+ export declare function size(options?: SizeOptions): Middleware;
22
23
  //# sourceMappingURL=size.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"size.d.ts","sourceRoot":"","sources":["../../src/middleware/size.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAc,QAAQ,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAK7F,MAAM,MAAM,WAAW,GAAG,qBAAqB,CAAC;AAEhD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,IAAI,CAAC,OAAO,GAAE,WAAgB,GAAG,eAAe,CAAC,MAAM,EAAE,QAAQ,CAAC,CA6BjF"}
1
+ {"version":3,"file":"size.d.ts","sourceRoot":"","sources":["../../src/middleware/size.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAKlE,MAAM,MAAM,WAAW,GAAG,qBAAqB,CAAC;AAEhD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,IAAI,CAAC,OAAO,GAAE,WAAgB,GAAG,UAAU,CA2B1D"}
@@ -1,2 +1,2 @@
1
- import{getSide as e,tagMiddleware as t}from"../utils.js";import{resolveBoundary as n}from"../overflow.js";function r(r={}){function i(t){let{boundary:i,padding:a}=n(r,t),o=e(t.placement),s=i.y+a.top,c=i.x+i.width-a.right,l=i.y+i.height-a.bottom,u=i.x+a.left;return{data:{size:{availableHeight:o===`bottom`?Math.max(0,l-t.y):o===`top`?Math.max(0,t.rects.reference.y-s):Math.max(0,l-s),availableWidth:o===`right`?Math.max(0,c-t.x):o===`left`?Math.max(0,t.rects.reference.x-u):Math.max(0,c-u)}}}}return t(i,`size`)}export{r as size};
1
+ import{getSide as e}from"../utils.js";import{resolveBoundary as t}from"../overflow.js";function n(n={}){function r(r){let{boundary:i,padding:a}=t(n,r),o=e(r.placement),s=i.y+a.top,c=i.x+i.width-a.right,l=i.y+i.height-a.bottom,u=i.x+a.left;return{data:{size:{availableHeight:o===`bottom`?Math.max(0,l-r.y):o===`top`?Math.max(0,r.rects.reference.y-s):Math.max(0,l-s),availableWidth:o===`right`?Math.max(0,c-r.x):o===`left`?Math.max(0,r.rects.reference.x-u):Math.max(0,c-u)}}}}return r}export{n as size};
2
2
  //# sourceMappingURL=size.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"size.js","names":[],"sources":["../../src/middleware/size.ts"],"sourcesContent":["import type { DetectOverflowOptions, Middleware, SizeData, TypedMiddleware } from '../types';\n\nimport { resolveBoundary } from '../overflow';\nimport { getSide, tagMiddleware } from '../utils';\n\nexport type SizeOptions = DetectOverflowOptions;\n\n/**\n * Reports the available space between the reference and boundary edges.\n *\n * Available dimensions are written to `middlewareData.size`.\n *\n * Read `result.middlewareData.size` in the `float()` `apply` option or after `computePosition()`\n * to constrain the floating element's dimensions.\n *\n * @example\n * ```ts\n * const cleanup = float(ref, el, {\n * middleware: [offset(8), flip(), shift(), size()],\n * apply(result) {\n * el.style.maxHeight = `${result.middlewareData.size!.availableHeight}px`;\n * },\n * });\n * ```\n */\nexport function size(options: SizeOptions = {}): TypedMiddleware<'size', SizeData> {\n function sizeMiddleware(state: Parameters<Middleware>[0]): ReturnType<Middleware> {\n const { boundary, padding } = resolveBoundary(options, state);\n const side = getSide(state.placement);\n const top = boundary.y + padding.top;\n const right = boundary.x + boundary.width - padding.right;\n const bottom = boundary.y + boundary.height - padding.bottom;\n const left = boundary.x + padding.left;\n\n const availableHeight =\n side === 'bottom'\n ? Math.max(0, bottom - state.y)\n : side === 'top'\n ? Math.max(0, state.rects.reference.y - top)\n : Math.max(0, bottom - top);\n\n const availableWidth =\n side === 'right'\n ? Math.max(0, right - state.x)\n : side === 'left'\n ? Math.max(0, state.rects.reference.x - left)\n : Math.max(0, right - left);\n\n const sizeData: SizeData = { availableHeight, availableWidth };\n\n return { data: { size: sizeData } };\n }\n\n return tagMiddleware<'size', SizeData, typeof sizeMiddleware>(sizeMiddleware, 'size');\n}\n"],"mappings":"0GAyBA,SAAgB,EAAK,EAAuB,CAAC,EAAsC,CACjF,SAAS,EAAe,EAA0D,CAChF,GAAM,CAAE,WAAU,WAAY,EAAgB,EAAS,CAAK,EACtD,EAAO,EAAQ,EAAM,SAAS,EAC9B,EAAM,EAAS,EAAI,EAAQ,IAC3B,EAAQ,EAAS,EAAI,EAAS,MAAQ,EAAQ,MAC9C,EAAS,EAAS,EAAI,EAAS,OAAS,EAAQ,OAChD,EAAO,EAAS,EAAI,EAAQ,KAkBlC,MAAO,CAAE,KAAM,CAAE,KAAM,CAFM,gBAb3B,IAAS,SACL,KAAK,IAAI,EAAG,EAAS,EAAM,CAAC,EAC5B,IAAS,MACP,KAAK,IAAI,EAAG,EAAM,MAAM,UAAU,EAAI,CAAG,EACzC,KAAK,IAAI,EAAG,EAAS,CAAG,EASc,eAN5C,IAAS,QACL,KAAK,IAAI,EAAG,EAAQ,EAAM,CAAC,EAC3B,IAAS,OACP,KAAK,IAAI,EAAG,EAAM,MAAM,UAAU,EAAI,CAAI,EAC1C,KAAK,IAAI,EAAG,EAAQ,CAAI,CAIT,CAAS,CAAE,CACpC,CAEA,OAAO,EAAuD,EAAgB,MAAM,CACtF"}
1
+ {"version":3,"file":"size.js","names":[],"sources":["../../src/middleware/size.ts"],"sourcesContent":["import type { DetectOverflowOptions, Middleware } from '../types';\n\nimport { resolveBoundary } from '../overflow';\nimport { getSide } from '../utils';\n\nexport type SizeOptions = DetectOverflowOptions;\n\n/**\n * Reports the available space between the reference and boundary edges.\n *\n * Available dimensions are written to `middlewareData.size`.\n *\n * Read `result.middlewareData.size` in the positioner `apply` option or after `computePosition()`\n * to constrain the floating element's dimensions.\n *\n * @example\n * ```ts\n * const positioner = createPositioner(ref, el, {\n * middleware: [offset(8), flip(), shift(), size()],\n * apply(result) {\n * el.style.maxHeight = `${(result.middlewareData.size as SizeData).availableHeight}px`;\n * },\n * });\n * positioner.start();\n * ```\n */\nexport function size(options: SizeOptions = {}): Middleware {\n function sizeMiddleware(state: Parameters<Middleware>[0]): ReturnType<Middleware> {\n const { boundary, padding } = resolveBoundary(options, state);\n const side = getSide(state.placement);\n const top = boundary.y + padding.top;\n const right = boundary.x + boundary.width - padding.right;\n const bottom = boundary.y + boundary.height - padding.bottom;\n const left = boundary.x + padding.left;\n\n const availableHeight =\n side === 'bottom'\n ? Math.max(0, bottom - state.y)\n : side === 'top'\n ? Math.max(0, state.rects.reference.y - top)\n : Math.max(0, bottom - top);\n\n const availableWidth =\n side === 'right'\n ? Math.max(0, right - state.x)\n : side === 'left'\n ? Math.max(0, state.rects.reference.x - left)\n : Math.max(0, right - left);\n\n return { data: { size: { availableHeight, availableWidth } } };\n }\n\n return sizeMiddleware;\n}\n"],"mappings":"uFA0BA,SAAgB,EAAK,EAAuB,CAAC,EAAe,CAC1D,SAAS,EAAe,EAA0D,CAChF,GAAM,CAAE,WAAU,WAAY,EAAgB,EAAS,CAAK,EACtD,EAAO,EAAQ,EAAM,SAAS,EAC9B,EAAM,EAAS,EAAI,EAAQ,IAC3B,EAAQ,EAAS,EAAI,EAAS,MAAQ,EAAQ,MAC9C,EAAS,EAAS,EAAI,EAAS,OAAS,EAAQ,OAChD,EAAO,EAAS,EAAI,EAAQ,KAgBlC,MAAO,CAAE,KAAM,CAAE,KAAM,CAAE,gBAbvB,IAAS,SACL,KAAK,IAAI,EAAG,EAAS,EAAM,CAAC,EAC5B,IAAS,MACP,KAAK,IAAI,EAAG,EAAM,MAAM,UAAU,EAAI,CAAG,EACzC,KAAK,IAAI,EAAG,EAAS,CAAG,EASU,eANxC,IAAS,QACL,KAAK,IAAI,EAAG,EAAQ,EAAM,CAAC,EAC3B,IAAS,OACP,KAAK,IAAI,EAAG,EAAM,MAAM,UAAU,EAAI,CAAI,EAC1C,KAAK,IAAI,EAAG,EAAQ,CAAI,CAEyB,CAAE,CAAE,CAC/D,CAEA,OAAO,CACT"}
package/dist/orbit.cjs CHANGED
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});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{};function n(e,t,n){return t!=null&&e<t?t:n!=null&&e>n?n:e}var r={bottom:`top`,left:`right`,right:`left`,top:`bottom`};function i(e){return e.split(`-`)[0]}function a(e){return e.split(`-`)[1]??null}function o(e,t){return t?`${e}-${t}`:e}function s({height:e,width:t,x:n,y:r}){return{height:e,width:t,x:n,y:r}}function c(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 l(e){return typeof Element<`u`&&e instanceof Element}function u(e){return e.assignedSlot?e.assignedSlot:e.parentElement??(e.getRootNode()instanceof ShadowRoot?e.getRootNode().host:null)}var d=[[`arrow`,`flip`],[`arrow`,`shift`],[`arrow`,`autoPlacement`],[`flip`,`inline`],[`shift`,`inline`],[`autoPlacement`,`inline`],[`size`,`flip`],[`size`,`autoPlacement`]];function f(e){for(let[n,r]of d){let i=e.indexOf(n),a=e.indexOf(r);if(i!==-1&&a!==-1&&i<a)throw new t(`"${n}" must come after "${r}" in the middleware pipeline. Recommended order: inline → offset → flip/autoPlacement → shift → size → arrow.`)}if(e.includes(`flip`)&&e.includes(`autoPlacement`))throw new t(`use either flip() or autoPlacement() in the middleware pipeline, not both.`)}var p=Symbol.for(`@vielzeug/orbit/name`);function m(e,t){return e[p]=t,e}function h(e,t,n,r){return e===`start`?t:e===`end`?t+n-r:t+(n-r)/2}function g(e,t,n){let r=i(e),o=a(e);switch(r){case`bottom`:return{x:h(o,t.x,t.width,n.width),y:t.y+t.height};case`left`:return{x:t.x-n.width,y:h(o,t.y,t.height,n.height)};case`right`:return{x:t.x+t.width,y:h(o,t.y,t.height,n.height)};case`top`:return{x:h(o,t.x,t.width,n.width),y:t.y-n.height}}}function _(e,t){return{floating:s(t.getBoundingClientRect()),reference:s(e.getBoundingClientRect())}}function v(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 y=8;function b(e,t,n){return Promise.resolve().then(()=>S(e,t,n))}function x(e,t,n){return new Promise((r,i)=>{requestAnimationFrame(()=>{try{r(S(e,t,n))}catch(e){i(e)}})})}function S(e,n,{boundary:r,containingBlock:i,middleware:a=[],padding:o,placement:s=`bottom`}={}){let c=a.filter(Boolean);f(c.map(e=>{let t=e[p];return typeof t==`string`?t:null}));let l=s,u={},d=_(e,n);for(let t=0;t<y;t+=1){let t={...g(l,d.reference,d.floating),boundary:r,elements:{floating:n,reference:e},initialPlacement:s,middlewareData:u,padding:o,placement:l,rects:d},a;for(let e of c){let n=e(t);if(t=v(t,n),u=t.middlewareData,a=n?.reset,a)break}if(!a){let e={middlewareData:t.middlewareData,placement:t.placement,x:t.x,y:t.y};if(i){let t=i.getBoundingClientRect();return{...e,x:e.x-t.x,y:e.y-t.y}}return e}a.remeasure?d=_(e,n):a.rects!=null&&(d=a.rects),l=a.placement??t.placement}throw new t(`Middleware triggered too many resets in a single compute cycle.`)}function C(){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 w(e){if(!e)return C();if(e instanceof Element){let t=e.getBoundingClientRect();return{height:t.height,width:t.width,x:t.x,y:t.y}}return e}var ee=/(hidden|clip|scroll|auto|overlay)/;function T(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 E(e){let t=u(e),n=C();for(;t;){let e=getComputedStyle(t);if(ee.test(`${e.overflow}${e.overflowX}${e.overflowY}`)){let e=t.getBoundingClientRect();n=T(n,{height:e.height,width:e.width,x:e.x,y:e.y})}t=u(t)}return n}function D(e,t){return{boundary:w(e.boundary??t.boundary),padding:c(e.padding??t.padding)}}function O(e){return{...e.rects.floating,x:e.x,y:e.y}}function k(e,t,n){return{bottom:e.y+e.height-(t.y+t.height-n.bottom),left:t.x+n.left-e.x,right:e.x+e.width-(t.x+t.width-n.right),top:t.y+n.top-e.y}}function A(e){return Math.max(e.top,0)+Math.max(e.right,0)+Math.max(e.bottom,0)+Math.max(e.left,0)}function j(e){return e.top>0||e.right>0||e.bottom>0||e.left>0}function M(e,t){return t.top>=e.height||t.right>=e.width||t.bottom>=e.height||t.left>=e.width}function N(e,t,n,r){let a=e.rects.reference;switch(i(t)){case`bottom`:return n.y+n.height-r.bottom-(a.y+a.height);case`left`:return a.x-(n.x+r.left);case`right`:return n.x+n.width-r.right-(a.x+a.width);case`top`:return a.y-(n.y+r.top)}}function P(e,t,n={}){let{x:r,y:i}=g(t,e.rects.reference,e.rects.floating),{boundary:a,padding:o}=D(n,e);return k({...e.rects.floating,x:r,y:i},a,o)}function F(e,t={}){let{boundary:n,padding:r}=D(t,e);return k(O(e),n,r)}var I=[`transform`,`perspective`,`filter`],L=[`layout`,`paint`,`strict`,`content`];function R(e){return e.transform!==`none`||e.perspective!==`none`||e.filter!==`none`||e.backdropFilter&&e.backdropFilter!==`none`||e.willChange!==`auto`&&I.some(t=>e.willChange.includes(t))?!0:e.contain!==`none`&&L.some(t=>e.contain.includes(t))}function z(e){let t=u(e);for(;t;){if(R(getComputedStyle(t)))return t;t=u(t)}return null}function B(e,t=700,n={leading:!0,trailing:!1}){let r=n.leading??!0,i=n.trailing??!1,a,o=-1/0,s,c,l=()=>{a!==void 0&&(clearTimeout(a),a=void 0)},u=e=>{a=setTimeout(p,e)},d=t=>{if(o=t,l(),!s)return;let n=s;return s=void 0,c=e(...n),c},f=e=>t-(e-o),p=()=>{let e=Date.now();s&&f(e)<=0?d(e):s?u(f(e)):l()};return Object.assign((...e)=>{let t=Date.now();o===-1/0&&!r&&(o=t),s=e;let n=f(t);return n<=0?d(t):(i&&!a&&u(n),c)},{cancel:()=>{l(),s=void 0,o=-1/0},flush:()=>{if(s)return d(Date.now())},pending:()=>s!==void 0||a!==void 0})}function V(e){let t=[],n=u(e);for(;n;){let e=getComputedStyle(n),r=e.overflow+e.overflowX+e.overflowY;/auto|scroll|overlay/.test(r)&&t.push(n),n=u(n)}return t}function H(e,t,n,{animationFrame:r=!1,observeAncestors:i=!0,observeFloating:a=!0,observeVisualViewport:o=!0,pauseWhenHidden:s=!0,throttle:c=0}={}){let u=c>0?B(n,c,{leading:!0,trailing:!0}):null,d=u??n,f=!0,p=()=>{f&&d()};d();let m=[];if(s&&l(e)&&typeof IntersectionObserver<`u`){let t=new IntersectionObserver(e=>{f=e.at(-1)?.isIntersecting??!0,f&&d()});t.observe(e),m.push(()=>t.disconnect())}if(l(e)&&i){let t=V(e);for(let e of t)e.addEventListener(`scroll`,p,{passive:!0}),m.push(()=>e.removeEventListener(`scroll`,p));window.addEventListener(`scroll`,p,{passive:!0}),m.push(()=>window.removeEventListener(`scroll`,p))}else{let e=e=>{e.composedPath().includes(t)||p()};window.addEventListener(`scroll`,e,{capture:!0,passive:!0}),m.push(()=>window.removeEventListener(`scroll`,e,{capture:!0}))}window.addEventListener(`resize`,p,{passive:!0}),m.push(()=>window.removeEventListener(`resize`,p));let h=o?window.visualViewport:null;h&&(h.addEventListener(`resize`,p,{passive:!0}),h.addEventListener(`scroll`,p,{passive:!0}),m.push(()=>{h.removeEventListener(`resize`,p),h.removeEventListener(`scroll`,p)}));let g=new ResizeObserver(p);l(e)&&g.observe(e),a&&g.observe(t),m.push(()=>g.disconnect());let _=0;if(r){let e=()=>{p(),_=window.requestAnimationFrame(e)};_=window.requestAnimationFrame(e),m.push(()=>window.cancelAnimationFrame(_))}return()=>{u?.cancel();for(let e of m)e()}}function U(e,t,n){let r=new AbortController,i=!1;return{get disposalSignal(){return r.signal},dispose(){i||(i=!0,r.abort(),e())},get disposed(){return i},getPosition:t,[Symbol.dispose](){this.dispose()},update:n}}function W(){return typeof CSS<`u`&&CSS.supports(`anchor-name`,`--orbit`)}var G=0,K={bottom:`block-end center`,"bottom-end":`block-end span-inline-end`,"bottom-start":`block-end span-inline-start`,left:`inline-start center`,"left-end":`inline-start span-block-end`,"left-start":`inline-start span-block-start`,right:`inline-end center`,"right-end":`inline-end span-block-end`,"right-start":`inline-end span-block-start`,top:`block-start center`,"top-end":`block-start span-inline-end`,"top-start":`block-start span-inline-start`};function q(e,t){let n={};for(let r of Object.keys(t)){let i=e.style.getPropertyValue(r);n[r]=i===``?void 0:i,e.style.setProperty(r,t[r])}return()=>{for(let r of Object.keys(t)){let t=n[r];t===void 0?e.style.removeProperty(r):e.style.setProperty(r,t)}}}function te(e,t,n,r){let i=`--orbit-${++G}`,a=q(e,{"anchor-name":i}),o=q(t,{position:`fixed`,"position-anchor":i,"position-area":K[n],"position-try-fallbacks":r});return()=>{a(),o()}}function J(e,t,{fallbacks:n=`flip-block, flip-inline, flip-block flip-inline`,placement:r=`bottom`}={}){let i=te(e,t,r,n),a=U(()=>i(),()=>null,()=>{});return Object.assign(a,{cssAnchor:!0})}function Y(e,t){t.style.left=`${e.x}px`,t.style.top=`${e.y}px`}function X(e,t,{apply:n,autoUpdate:r={},boundary:i,containingBlock:a,middleware:o,padding:s,placement:c=`bottom`}={}){let l=null,u=n??(e=>Y(e,t));function d(){let n=S(e,t,{boundary:i,containingBlock:a,middleware:o,padding:s,placement:c});l=n,u(n)}if(r===!1)return d(),U(()=>{},()=>l,d);let f=H(e,t,d,r);return U(()=>f(),()=>l,d)}function Z(...e){return e.filter(Boolean)}function Q({element:e,padding:t=0}){function r(r){let a=i(r.placement),o=c(t),l=s(e.getBoundingClientRect());if(a===`top`||a===`bottom`){let e=r.rects.reference.x+r.rects.reference.width/2-r.x-l.width/2,t=o.left,i=n(e,t,Math.max(t,r.rects.floating.width-l.width-o.right));return{data:{arrow:{centerOffset:e-i,constrained:i!==e,x:i}}}}let u=r.rects.reference.y+r.rects.reference.height/2-r.y-l.height/2,d=o.top,f=n(u,d,Math.max(d,r.rects.floating.height-l.height-o.bottom));return{data:{arrow:{centerOffset:u-f,constrained:f!==u,y:f}}}}return m(r,`arrow`)}var $=[`top`,`right`,`bottom`,`left`];function ne(e){return e===void 0?$:e===null?$.flatMap(e=>[e,`${e}-start`,`${e}-end`]):$.map(t=>`${t}-${e}`)}function re(e={}){return m(function(t){let{boundary:n,padding:r}=D(e,t),i=e.allowedPlacements??ne(e.alignment);i.length;let a=t.placement,o=1/0,s=-1/0;for(let c of i){let i=A(P(t,c,e)),l=N(t,c,n,r);(i<o||i===o&&l>s)&&(a=c,o=i,s=l)}if(a!==t.placement)return{reset:{placement:a}}},`autoPlacement`)}function ie(e={}){function t(t){let n=F(t,e);if(!j(n))return;let s=i(t.placement),c=a(t.placement),l=e.fallbackPlacements??[o(r[s],c)],u=[t.placement],d=t.placement,f=A(n);for(let n of l){let r=P(t,n,e),i=A(r);if(!j(r))return{data:{flip:{skippedPlacements:u}},reset:{placement:n}};u.push(n),i<f&&(d=n,f=i)}if(d!==t.placement)return{data:{flip:{skippedPlacements:u}},reset:{placement:d}}}return m(t,`flip`)}function ae(e={}){let t=e.strategy??`both`;function n(n){let{boundary:r,padding:i}=D(e,n),a={};if(t===`escaped`||t===`both`){let e=O(n),t=k(e,r,i);a.escaped=M(e,t),a.escapedOffsets=t}if(t===`referenceHidden`||t===`both`){let e=k(n.rects.reference,r,i);a.referenceHidden=M(n.rects.reference,e),a.referenceHiddenOffsets=e}return{data:{hide:a}}}return m(n,`hide`)}function oe(e){return!(`getClientRects`in e)||typeof e.getClientRects!=`function`?[]:Array.from(e.getClientRects()).map(s).filter(e=>e.width>0||e.height>0)}function se(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 ce(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function le(e={}){function t(t){let n=oe(t.elements.reference);if(n.length<=1)return;let r=c(e.padding??2),a=i(t.placement),o=n[0];if(e.x!=null&&e.y!=null)o=n.find(t=>se(t,e.x,e.y,r))??o;else if(a===`top`||a===`bottom`){let e=t.x+t.rects.floating.width/2;o=n.reduce((t,n)=>{let r=Math.abs(t.x+t.width/2-e);return Math.abs(n.x+n.width/2-e)<r?n:t},o)}else{let e=t.y+t.rects.floating.height/2;o=n.reduce((t,n)=>{let r=Math.abs(t.y+t.height/2-e);return Math.abs(n.y+n.height/2-e)<r?n:t},o)}if(!ce(o,t.rects.reference))return{reset:{rects:{...t.rects,reference:o}}}}return m(t,`inline`)}function ue(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 de(e){return m(function(t){let n=i(t.placement),{crossAxis:r,mainAxis:a}=ue(e,t);switch(n){case`bottom`:return{x:t.x+r,y:t.y+a};case`left`:return{x:t.x-a,y:t.y+r};case`right`:return{x:t.x+a,y:t.y+r};case`top`:return{x:t.x+r,y:t.y-a}}},`offset`)}function fe(e={}){return(t,r)=>{let{placement:a,rects:o,x:s,y:c}=t,l=i(a),u=l===`top`||l===`bottom`,d=typeof e.offset==`function`?e.offset(t):e.offset??0;if(u){let e=o.reference.x-d,t=o.reference.x+o.reference.width+d-o.floating.width,[i,a]=e<=t?[e,t]:[t,e],c=n(s+r.crossAxis,i,a);return{...r,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=n(c+r.crossAxis,m,h);return{...r,crossAxis:g-c}}}function pe(e={}){let{crossAxis:t=!0,limiter:n,mainAxis:r=!1}=e;function a(a){let o=F(a,e),s=i(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:r,f=c?r:t,p=d?l:0,m=f?u:0;if(n){let e=n(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 m(a,`shift`)}function me(e={}){function t(t){let{boundary:n,padding:r}=D(e,t),a=i(t.placement),o=n.y+r.top,s=n.x+n.width-r.right,c=n.y+n.height-r.bottom,l=n.x+r.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 m(t,`size`)}exports.OrbitConfigError=t,exports.OrbitError=e,exports.arrow=Q,exports.autoPlacement=re,exports.autoUpdate=H,exports.compose=Z,exports.computePosition=S,exports.computePositionAsync=b,exports.computePositionRaf=x,exports.detectOverflow=F,exports.flip=ie,exports.float=X,exports.floatWithAnchor=J,exports.getAlignment=a,exports.getClippingAncestorRect=E,exports.getContainingBlock=z,exports.getRects=_,exports.getSide=i,exports.hide=ae,exports.inline=le,exports.isCssAnchorSupported=W,exports.limitShift=fe,exports.offset=de,exports.shift=pe,exports.size=me;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});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{};function n(e,t,n){return Math.min(Math.max(e,t),n)}var r={bottom:`top`,left:`right`,right:`left`,top:`bottom`};function i(e){return e.split(`-`)[0]}function a(e){return e.split(`-`)[1]??null}function o(e,t){return t?`${e}-${t}`:e}function s({height:e,width:t,x:n,y:r}){return{height:e,width:t,x:n,y:r}}function c(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 l(e){return typeof Element<`u`&&e instanceof Element}function u(e){return e.assignedSlot?e.assignedSlot:e.parentElement??(e.getRootNode()instanceof ShadowRoot?e.getRootNode().host:null)}function d(e,t,n,r){return e===`start`?t:e===`end`?t+n-r:t+(n-r)/2}function f(e,t,n){let r=i(e),o=a(e);switch(r){case`bottom`:return{x:d(o,t.x,t.width,n.width),y:t.y+t.height};case`left`:return{x:t.x-n.width,y:d(o,t.y,t.height,n.height)};case`right`:return{x:t.x+t.width,y:d(o,t.y,t.height,n.height)};case`top`:return{x:d(o,t.x,t.width,n.width),y:t.y-n.height}}}function p(e,t){return{floating:s(t.getBoundingClientRect()),reference:s(e.getBoundingClientRect())}}function m(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 h=8;function g(e,t,n){return Promise.resolve().then(()=>v(e,t,n))}function _(e,t,n){return new Promise((r,i)=>{requestAnimationFrame(()=>{try{r(v(e,t,n))}catch(e){i(e)}})})}function v(e,n,{boundary:r,containingBlock:i,middleware:a=[],padding:o,placement:s=`bottom`}={}){let c=a,l=s,u={},d=p(e,n);for(let t=0;t<h;t+=1){let t={...f(l,d.reference,d.floating),boundary:r,elements:{floating:n,reference:e},initialPlacement:s,middlewareData:u,padding:o,placement:l,rects:d},a;for(let e of c){let n=e(t);if(t=m(t,n),u=t.middlewareData,a=n?.reset,a)break}if(!a){let e={middlewareData:t.middlewareData,placement:t.placement,x:t.x,y:t.y};if(i){let t=i.getBoundingClientRect();return{...e,x:e.x-t.x,y:e.y-t.y}}return e}a.remeasure?d=p(e,n):a.rects!=null&&(d=a.rects),l=a.placement??t.placement}throw new t(`Middleware triggered too many resets in a single compute cycle.`)}function y(){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 b(e){if(!e)return y();if(e instanceof Element){let t=e.getBoundingClientRect();return{height:t.height,width:t.width,x:t.x,y:t.y}}return e}var x=/(hidden|clip|scroll|auto|overlay)/;function S(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 C(e){let t=u(e),n=y();for(;t;){let e=getComputedStyle(t);if(x.test(`${e.overflow}${e.overflowX}${e.overflowY}`)){let e=t.getBoundingClientRect();n=S(n,{height:e.height,width:e.width,x:e.x,y:e.y})}t=u(t)}return n}function w(e,t){return{boundary:b(e.boundary??t.boundary),padding:c(e.padding??t.padding)}}function T(e){return{...e.rects.floating,x:e.x,y:e.y}}function E(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 D(e){return Math.max(e.top,0)+Math.max(e.right,0)+Math.max(e.bottom,0)+Math.max(e.left,0)}function O(e){return e.top>0||e.right>0||e.bottom>0||e.left>0}function k(e,t){return t.top>=e.height||t.right>=e.width||t.bottom>=e.height||t.left>=e.width}function A(e,t,n,r){let a=e.rects.reference;switch(i(t)){case`bottom`:return n.y+n.height-r.bottom-(a.y+a.height);case`left`:return a.x-(n.x+r.left);case`right`:return n.x+n.width-r.right-(a.x+a.width);case`top`:return a.y-(n.y+r.top)}}function j(e,t,n={}){let{x:r,y:i}=f(t,e.rects.reference,e.rects.floating),{boundary:a,padding:o}=w(n,e);return E({...e.rects.floating,x:r,y:i},a,o)}function M(e,t={}){let{boundary:n,padding:r}=w(t,e);return E(T(e),n,r)}function N(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 P(e){let t=[],n=u(e);for(;n;){let e=getComputedStyle(n),r=e.overflow+e.overflowX+e.overflowY;/auto|scroll|overlay/.test(r)&&t.push(n),n=u(n)}return t}function F(e,t,n,{animationFrame:r=!1,observeAncestors:i=!0,observeFloating:a=!0,observeVisualViewport:o=!0,pauseWhenHidden:s=!0,throttle:c=0}={}){let u=c>0?N(n,c):null,d=u??n,f=!0,p=()=>{f&&d()};d();let m=[];if(s&&l(e)&&typeof IntersectionObserver<`u`){let t=new IntersectionObserver(e=>{f=e.at(-1)?.isIntersecting??!0,f&&d()});t.observe(e),m.push(()=>t.disconnect())}if(l(e)&&i){let t=P(e);for(let e of t)e.addEventListener(`scroll`,p,{passive:!0}),m.push(()=>e.removeEventListener(`scroll`,p));window.addEventListener(`scroll`,p,{passive:!0}),m.push(()=>window.removeEventListener(`scroll`,p))}else{let e=e=>{e.composedPath().includes(t)||p()};window.addEventListener(`scroll`,e,{capture:!0,passive:!0}),m.push(()=>window.removeEventListener(`scroll`,e,{capture:!0}))}window.addEventListener(`resize`,p,{passive:!0}),m.push(()=>window.removeEventListener(`resize`,p));let h=o?window.visualViewport:null;h&&(h.addEventListener(`resize`,p,{passive:!0}),h.addEventListener(`scroll`,p,{passive:!0}),m.push(()=>{h.removeEventListener(`resize`,p),h.removeEventListener(`scroll`,p)}));let g=new ResizeObserver(p);l(e)&&g.observe(e),a&&g.observe(t),m.push(()=>g.disconnect());let _=0;if(r){let e=()=>{p(),_=window.requestAnimationFrame(e)};_=window.requestAnimationFrame(e),m.push(()=>window.cancelAnimationFrame(_))}return()=>{u?.cancel();for(let e of m)e()}}var I=[`transform`,`perspective`,`filter`],L=[`layout`,`paint`,`strict`,`content`];function R(e){return e.transform!==`none`||e.perspective!==`none`||e.filter!==`none`||e.backdropFilter&&e.backdropFilter!==`none`||e.willChange!==`auto`&&I.some(t=>e.willChange.includes(t))?!0:e.contain!==`none`&&L.some(t=>e.contain.includes(t))}function z(e){let t=u(e);for(;t;){if(R(getComputedStyle(t)))return t;t=u(t)}return null}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:z(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 p(){if(!l)return;let r=V(t,c),u=v(e,t,{boundary:i===`clippingAncestors`?C(t):i,containingBlock:r,middleware:a,padding:o,placement:s});d=u,(n??(e=>H(e,t,c)))(u)}function m(){f||(f=!0,r===!1?p():u=F(e,t,p,r))}return B(()=>{l=!1,u?.()},()=>d,m,p)}function W({element:e,padding:t=0}){function r(r){let a=i(r.placement),o=c(t),l=s(e.getBoundingClientRect());if(a===`top`||a===`bottom`){let e=r.rects.reference.x+r.rects.reference.width/2-r.x-l.width/2,t=o.left,i=n(e,t,Math.max(t,r.rects.floating.width-l.width-o.right));return{data:{arrow:{centerOffset:e-i,constrained:i!==e,x:i}}}}let u=r.rects.reference.y+r.rects.reference.height/2-r.y-l.height/2,d=o.top,f=n(u,d,Math.max(d,r.rects.floating.height-l.height-o.bottom));return{data:{arrow:{centerOffset:u-f,constrained:f!==u,y:f}}}}return r}var G=[`top`,`right`,`bottom`,`left`];function K(e){return e===void 0?G:e===null?G.flatMap(e=>[e,`${e}-start`,`${e}-end`]):G.map(t=>`${t}-${e}`)}function q(e={}){return function(t){let{boundary:n,padding:r}=w(e,t),i=e.allowedPlacements??K(e.alignment);i.length;let a=t.placement,o=1/0,s=-1/0;for(let c of i){let i=D(j(t,c,e)),l=A(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 J(e={}){function t(t){let n=M(t,e);if(!O(n))return;let s=i(t.placement),c=a(t.placement),l=e.fallbackPlacements??[o(r[s],c)],u=[t.placement],d=t.placement,f=D(n);for(let n of l){let r=j(t,n,e),i=D(r);if(!O(r))return{data:{flip:{skippedPlacements:u}},reset:{placement:n}};u.push(n),i<f&&(d=n,f=i)}if(d!==t.placement)return{data:{flip:{skippedPlacements:u}},reset:{placement:d}}}return t}function Y(e={}){let t=e.strategy??`both`;function n(n){let{boundary:r,padding:i}=w(e,n),a={};if(t===`escaped`||t===`both`){let e=T(n),t=E(e,r,i);a.escaped=k(e,t),a.escapedOffsets=t}if(t===`referenceHidden`||t===`both`){let e=E(n.rects.reference,r,i);a.referenceHidden=k(n.rects.reference,e),a.referenceHiddenOffsets=e}return{data:{hide:a}}}return n}function X(e){return!(`getClientRects`in e)||typeof e.getClientRects!=`function`?[]:Array.from(e.getClientRects()).map(s).filter(e=>e.width>0||e.height>0)}function Z(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 Q(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function $(e={}){function t(t){let n=X(t.elements.reference);if(n.length<=1)return;let r=c(e.padding??2),a=i(t.placement),o=n[0];if(e.x!=null&&e.y!=null)o=n.find(t=>Z(t,e.x,e.y,r))??o;else if(a===`top`||a===`bottom`){let e=t.x+t.rects.floating.width/2;o=n.reduce((t,n)=>{let r=Math.abs(t.x+t.width/2-e);return Math.abs(n.x+n.width/2-e)<r?n:t},o)}else{let e=t.y+t.rects.floating.height/2;o=n.reduce((t,n)=>{let r=Math.abs(t.y+t.height/2-e);return Math.abs(n.y+n.height/2-e)<r?n:t},o)}if(!Q(o,t.rects.reference))return{reset:{rects:{...t.rects,reference:o}}}}return t}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 n=i(t.placement),{crossAxis:r,mainAxis:a}=ee(e,t);switch(n){case`bottom`:return{x:t.x+r,y:t.y+a};case`left`:return{x:t.x-a,y:t.y+r};case`right`:return{x:t.x+a,y:t.y+r};case`top`:return{x:t.x+r,y:t.y-a}}}}function ne(e={}){return(t,r)=>{let{placement:a,rects:o,x:s,y:c}=t,l=i(a),u=l===`top`||l===`bottom`,d=typeof e.offset==`function`?e.offset(t):e.offset??0;if(u){let e=o.reference.x-d,t=o.reference.x+o.reference.width+d-o.floating.width,[i,a]=e<=t?[e,t]:[t,e],c=n(s+r.crossAxis,i,a);return{...r,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=n(c+r.crossAxis,m,h);return{...r,crossAxis:g-c}}}function re(e={}){let{crossAxis:t=!0,limiter:n,mainAxis:r=!1}=e;function a(a){let o=M(a,e),s=i(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:r,f=c?r:t,p=d?l:0,m=f?u:0;if(n){let e=n(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:n,padding:r}=w(e,t),a=i(t.placement),o=n.y+r.top,s=n.x+n.width-r.right,c=n.y+n.height-r.bottom,l=n.x+r.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=t,exports.OrbitError=e,exports.arrow=W,exports.autoPlacement=q,exports.autoUpdate=F,exports.computePosition=v,exports.computePositionAsync=g,exports.computePositionRaf=_,exports.createPositioner=U,exports.detectOverflow=M,exports.flip=J,exports.getAlignment=a,exports.getClippingAncestorRect=C,exports.getRects=p,exports.getSide=i,exports.hide=Y,exports.inline=$,exports.limitShift=ne,exports.offset=te,exports.shift=re,exports.size=ie;
2
2
  //# sourceMappingURL=orbit.cjs.map