@vielzeug/orbit 26.10.14 → 26.10.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_dev.cjs.map +1 -1
- package/dist/_dev.js.map +1 -1
- package/dist/auto-update.cjs +1 -1
- package/dist/auto-update.cjs.map +1 -1
- package/dist/auto-update.js +1 -1
- package/dist/auto-update.js.map +1 -1
- package/dist/containing-block.cjs.map +1 -1
- package/dist/containing-block.js.map +1 -1
- package/dist/core.cjs.map +1 -1
- package/dist/core.js.map +1 -1
- package/dist/devtools.cjs.map +1 -1
- package/dist/devtools.js.map +1 -1
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.js.map +1 -1
- package/dist/float.cjs.map +1 -1
- package/dist/float.js.map +1 -1
- package/dist/inline.cjs.map +1 -1
- package/dist/inline.js.map +1 -1
- package/dist/middleware/arrow.cjs.map +1 -1
- package/dist/middleware/arrow.js.map +1 -1
- package/dist/middleware/auto-placement.cjs.map +1 -1
- package/dist/middleware/auto-placement.js.map +1 -1
- package/dist/middleware/flip.cjs +1 -1
- package/dist/middleware/flip.cjs.map +1 -1
- package/dist/middleware/flip.d.ts.map +1 -1
- package/dist/middleware/flip.js +1 -1
- package/dist/middleware/flip.js.map +1 -1
- package/dist/middleware/hide.cjs.map +1 -1
- package/dist/middleware/hide.js.map +1 -1
- package/dist/middleware/offset.cjs.map +1 -1
- package/dist/middleware/offset.js.map +1 -1
- package/dist/middleware/shift.cjs.map +1 -1
- package/dist/middleware/shift.js.map +1 -1
- package/dist/middleware/size.cjs.map +1 -1
- package/dist/middleware/size.js.map +1 -1
- package/dist/orbit.cjs +1 -1
- package/dist/orbit.cjs.map +1 -1
- package/dist/orbit.iife.js +1 -1
- package/dist/orbit.iife.js.map +1 -1
- package/dist/orbit.js +586 -1
- package/dist/orbit.js.map +1 -1
- package/dist/overflow.cjs.map +1 -1
- package/dist/overflow.js.map +1 -1
- package/dist/presets.cjs.map +1 -1
- package/dist/presets.js.map +1 -1
- package/dist/reactive.cjs.map +1 -1
- package/dist/reactive.js.map +1 -1
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.js.map +1 -1
- package/package.json +7 -7
package/dist/orbit.js
CHANGED
|
@@ -1,2 +1,587 @@
|
|
|
1
|
-
import{clamp as e}from"@vielzeug/arsenal";var t={bottom:`top`,left:`right`,right:`left`,top:`bottom`};function getSide(e){return e.split(`-`)[0]}function getAlignment(e){return e.split(`-`)[1]??null}function withPlacement(e,t){return t?`${e}-${t}`:e}function toRect({height:e,width:t,x:n,y:r}){return{height:e,width:t,x:n,y:r}}function toSideObject(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 isElement(e){return typeof Element<`u`&&e instanceof Element}function flatTreeParent(e){return e.assignedSlot?e.assignedSlot:e.parentElement??(e.getRootNode()instanceof ShadowRoot?e.getRootNode().host:null)}function alignedOffset(e,t,n,r){return e===`start`?t:e===`end`?t+n-r:t+(n-r)/2}function baseCoords(e,t,n){let r=getSide(e),i=getAlignment(e);switch(r){case`bottom`:return{x:alignedOffset(i,t.x,t.width,n.width),y:t.y+t.height};case`left`:return{x:t.x-n.width,y:alignedOffset(i,t.y,t.height,n.height)};case`right`:return{x:t.x+t.width,y:alignedOffset(i,t.y,t.height,n.height)};case`top`:return{x:alignedOffset(i,t.x,t.width,n.width),y:t.y-n.height}}}function throttle(e,t){let n,r=0,throttled=(()=>{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 throttled.cancel=()=>{n!==void 0&&clearTimeout(n),n=void 0},throttled}function getScrollAncestors(e){let t=[],n=flatTreeParent(e);for(;n;){let e=getComputedStyle(n),r=e.overflow+e.overflowX+e.overflowY;/auto|scroll|overlay/.test(r)&&t.push(n),n=flatTreeParent(n)}return t}function autoUpdate(e,t,n,{animationFrame:r=!1,observeAncestors:i=!0,observeFloating:a=!0,observeVisualViewport:o=!0,pauseWhenHidden:s=!0,throttle:c=0}={}){let l=c>0?throttle(n,c):null,u=l??n,d=!0,conditionalNotify=()=>{d&&u()};u();let f=[];if(s&&isElement(e)&&typeof IntersectionObserver<`u`){let t=new IntersectionObserver(e=>{d=e.at(-1)?.isIntersecting??!0,d&&u()});t.observe(e),f.push(()=>t.disconnect())}if(isElement(e)&&i){let t=getScrollAncestors(e);for(let e of t)e.addEventListener(`scroll`,conditionalNotify,{passive:!0}),f.push(()=>e.removeEventListener(`scroll`,conditionalNotify));window.addEventListener(`scroll`,conditionalNotify,{passive:!0}),f.push(()=>window.removeEventListener(`scroll`,conditionalNotify))}else{let scrollHandler=e=>{e.composedPath().includes(t)||conditionalNotify()};window.addEventListener(`scroll`,scrollHandler,{capture:!0,passive:!0}),f.push(()=>window.removeEventListener(`scroll`,scrollHandler,{capture:!0}))}window.addEventListener(`resize`,conditionalNotify,{passive:!0}),f.push(()=>window.removeEventListener(`resize`,conditionalNotify));let p=o?window.visualViewport:null;p&&(p.addEventListener(`resize`,conditionalNotify,{passive:!0}),p.addEventListener(`scroll`,conditionalNotify,{passive:!0}),f.push(()=>{p.removeEventListener(`resize`,conditionalNotify),p.removeEventListener(`scroll`,conditionalNotify)}));let m=new ResizeObserver(conditionalNotify);isElement(e)&&m.observe(e),a&&m.observe(t),f.push(()=>m.disconnect());let h=0;if(r){let frameLoop=()=>{conditionalNotify(),h=window.requestAnimationFrame(frameLoop)};h=window.requestAnimationFrame(frameLoop),f.push(()=>window.cancelAnimationFrame(h))}return()=>{l?.cancel();for(let e of f)e()}}var OrbitError=class extends Error{constructor(e,t){super(e,t),this.name=new.target.name,Object.setPrototypeOf(this,new.target.prototype)}},OrbitConfigError=class extends OrbitError{};function getRects(e,t){return{floating:toRect(t.getBoundingClientRect()),reference:toRect(e.getBoundingClientRect())}}function mergeState(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 n=8;function computePosition(e,t,{boundary:r,containingBlock:i,middleware:a=[],padding:o,placement:s=`bottom`}={}){let c=a,l=s,u={},d=getRects(e,t);for(let a=0;a<n;a+=1){let n={...baseCoords(l,d.reference,d.floating),boundary:r,elements:{floating:t,reference:e},initialPlacement:s,middlewareData:u,padding:o,placement:l,rects:d},a;for(let e of c){let t=e(n);if(n=mergeState(n,t),u=n.middlewareData,a=t?.reset,a)break}if(!a){let e={middlewareData:n.middlewareData,placement:n.placement,x:n.x,y:n.y};if(i){let t=i.getBoundingClientRect();return{...e,x:e.x-t.x,y:e.y-t.y}}return e}a.remeasure?d=getRects(e,t):a.rects!=null&&(d=a.rects),l=a.placement??n.placement}throw new OrbitConfigError(`Middleware triggered too many resets in a single compute cycle.`)}var r=[`transform`,`perspective`,`filter`],i=[`layout`,`paint`,`strict`,`content`];function establishesFixedContainingBlock(e){return e.transform!==`none`||e.perspective!==`none`||e.filter!==`none`||e.backdropFilter&&e.backdropFilter!==`none`||e.willChange!==`auto`&&r.some(t=>e.willChange.includes(t))?!0:e.contain!==`none`&&i.some(t=>e.contain.includes(t))}function getContainingBlock(e){let t=flatTreeParent(e);for(;t;){if(establishesFixedContainingBlock(getComputedStyle(t)))return t;t=flatTreeParent(t)}return null}function getViewportRect(){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 getBoundaryRect(e){if(!e)return getViewportRect();if(e instanceof Element){let t=e.getBoundingClientRect();return{height:t.height,width:t.width,x:t.x,y:t.y}}return e}var a=/(hidden|clip|scroll|auto|overlay)/;function intersectRect(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 getClippingAncestorRect(e){let t=flatTreeParent(e),n=getViewportRect();for(;t;){let e=getComputedStyle(t);if(a.test(`${e.overflow}${e.overflowX}${e.overflowY}`)){let e=t.getBoundingClientRect();n=intersectRect(n,{height:e.height,width:e.width,x:e.x,y:e.y})}t=flatTreeParent(t)}return n}function resolveBoundary(e,t){return{boundary:getBoundaryRect(e.boundary??t.boundary),padding:toSideObject(e.padding??t.padding)}}function getFloatingRect(e){return{...e.rects.floating,x:e.x,y:e.y}}function detectOverflowAtRect(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 totalOverflow(e){return Math.max(e.top,0)+Math.max(e.right,0)+Math.max(e.bottom,0)+Math.max(e.left,0)}function hasOverflow(e){return e.top>0||e.right>0||e.bottom>0||e.left>0}function isFullyClipped(e,t){return t.top>=e.height||t.right>=e.width||t.bottom>=e.height||t.left>=e.width}function getAvailableSpace(e,t,n,r){let i=e.rects.reference;switch(getSide(t)){case`bottom`:return n.y+n.height-r.bottom-(i.y+i.height);case`left`:return i.x-(n.x+r.left);case`right`:return n.x+n.width-r.right-(i.x+i.width);case`top`:return i.y-(n.y+r.top)}}function getPlacementOverflow(e,t,n={}){let{x:r,y:i}=baseCoords(t,e.rects.reference,e.rects.floating),{boundary:a,padding:o}=resolveBoundary(n,e);return detectOverflowAtRect({...e.rects.floating,x:r,y:i},a,o)}function detectOverflow(e,t={}){let{boundary:n,padding:r}=resolveBoundary(t,e);return detectOverflowAtRect(getFloatingRect(e),n,r)}function resolveContainingBlock(e,t){return t===`absolute`?e.offsetParent instanceof Element?e.offsetParent:null:getContainingBlock(e)}function applyDefault(e,t,n){t.style.position=n,t.style.left=`${e.x}px`,t.style.top=`${e.y}px`}function createPositioner(e,t,{apply:n,autoUpdate:r={},boundary:i=`clippingAncestors`,middleware:a,padding:o,placement:s=`bottom`,strategy:c=`fixed`}={}){let l=new AbortController,u=!0,d=!1,f,p;function update(){if(!u)return;let r=resolveContainingBlock(t,c),l=computePosition(e,t,{boundary:i===`clippingAncestors`?getClippingAncestorRect(t):i,containingBlock:r,middleware:a,padding:o,placement:s});p=l,(n??(e=>applyDefault(e,t,c)))(l)}let m={get disposalSignal(){return l.signal},dispose(){d||(d=!0,u=!1,l.abort(),f?.())},get disposed(){return d},getPosition:()=>p,[Symbol.dispose](){this.dispose()},update(){d||update()}};return r===!1?update():f=autoUpdate(e,t,update,r),m}function getClientRects(e){return!(`getClientRects`in e)||typeof e.getClientRects!=`function`?[]:Array.from(e.getClientRects()).map(toRect).filter(e=>e.width>0||e.height>0)}function rectContainsPoint(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 sameRect(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function inline(e={}){function inlineMiddleware(t){let n=getClientRects(t.elements.reference);if(n.length<=1)return;let r=toSideObject(e.padding??2),i=getSide(t.placement),a=n[0];if(e.x!=null&&e.y!=null)a=n.find(t=>rectContainsPoint(t,e.x,e.y,r))??a;else if(i===`top`||i===`bottom`){let e=t.x+t.rects.floating.width/2;a=n.reduce((t,n)=>{let r=Math.abs(t.x+t.width/2-e);return Math.abs(n.x+n.width/2-e)<r?n:t},a)}else{let e=t.y+t.rects.floating.height/2;a=n.reduce((t,n)=>{let r=Math.abs(t.y+t.height/2-e);return Math.abs(n.y+n.height/2-e)<r?n:t},a)}if(!sameRect(a,t.rects.reference))return{reset:{rects:{...t.rects,reference:a}}}}return inlineMiddleware}function arrow({element:t,padding:n=0}){function arrowMiddleware(r){let i=getSide(r.placement),a=toSideObject(n),o=toRect(t.getBoundingClientRect());if(i===`top`||i===`bottom`){let t=r.rects.reference.x+r.rects.reference.width/2-r.x-o.width/2,n=a.left,i=Math.max(n,r.rects.floating.width-o.width-a.right),s=e(t,n,i);return{data:{arrow:{centerOffset:t-s,constrained:s!==t,x:s}}}}let s=r.rects.reference.y+r.rects.reference.height/2-r.y-o.height/2,c=a.top,l=Math.max(c,r.rects.floating.height-o.height-a.bottom),u=e(s,c,l);return{data:{arrow:{centerOffset:s-u,constrained:u!==s,y:u}}}}return arrowMiddleware}var o=[`top`,`right`,`bottom`,`left`];function getDefaultPlacements(e){return e===void 0?o:e===null?o.flatMap(e=>[e,`${e}-start`,`${e}-end`]):o.map(t=>`${t}-${e}`)}function autoPlacement(e={}){return function autoPlacementMiddleware(t){let{boundary:n,padding:r}=resolveBoundary(e,t),i=e.allowedPlacements??getDefaultPlacements(e.alignment);i.length;let a=t.placement,o=1/0,s=-1/0;for(let c of i){let i=totalOverflow(getPlacementOverflow(t,c,e)),l=getAvailableSpace(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 flip(e={}){function flipMiddleware(n){let r=detectOverflow(n,e);if(!hasOverflow(r))return;let i=getSide(n.placement),a=getAlignment(n.placement),o=e.fallbackPlacements??[withPlacement(t[i],a)],s=[n.placement],c=n.placement,l=totalOverflow(r);for(let t of o){let r=getPlacementOverflow(n,t,e),i=totalOverflow(r);if(!hasOverflow(r))return{data:{flip:{skippedPlacements:s}},reset:{placement:t}};s.push(t),i<l&&(c=t,l=i)}if(c!==n.placement)return{data:{flip:{skippedPlacements:s}},reset:{placement:c}}}return flipMiddleware}function hide(e={}){let t=e.strategy??`both`;function hideMiddleware(n){let{boundary:r,padding:i}=resolveBoundary(e,n),a={};if(t===`escaped`||t===`both`){let e=getFloatingRect(n),t=detectOverflowAtRect(e,r,i);a.escaped=isFullyClipped(e,t),a.escapedOffsets=t}if(t===`referenceHidden`||t===`both`){let e=detectOverflowAtRect(n.rects.reference,r,i);a.referenceHidden=isFullyClipped(n.rects.reference,e),a.referenceHiddenOffsets=e}return{data:{hide:a}}}return hideMiddleware}function resolveOffsetConfig(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 offset(e){return function offsetMiddleware(t){let n=getSide(t.placement),{crossAxis:r,mainAxis:i}=resolveOffsetConfig(e,t);switch(n){case`bottom`:return{x:t.x+r,y:t.y+i};case`left`:return{x:t.x-i,y:t.y+r};case`right`:return{x:t.x+i,y:t.y+r};case`top`:return{x:t.x+r,y:t.y-i}}}}function limitShift(t={}){return(n,r)=>{let{placement:i,rects:a,x:o,y:s}=n,c=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(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(s+r.crossAxis,p,m);return{...r,crossAxis:h-s}}}function shift(e={}){let{crossAxis:t=!0,limiter:n,mainAxis:r=!1}=e;function shiftMiddleware(i){let a=detectOverflow(i,e),o=getSide(i.placement),s=o===`top`||o===`bottom`,c=Math.max(a.left,0)-Math.max(a.right,0),l=Math.max(a.top,0)-Math.max(a.bottom,0),u=s?t:r,d=s?r:t,f=u?c:0,p=d?l:0;if(n){let e=n(i,{crossAxis:s?f:p,mainAxis:s?p:f});f=s?e.crossAxis:e.mainAxis,p=s?e.mainAxis:e.crossAxis}return{data:{shift:{x:f,y:p}},x:i.x+f,y:i.y+p}}return shiftMiddleware}function size(e={}){function sizeMiddleware(t){let{boundary:n,padding:r}=resolveBoundary(e,t),i=getSide(t.placement),a=n.y+r.top,o=n.x+n.width-r.right,s=n.y+n.height-r.bottom,c=n.x+r.left;return{data:{size:{availableHeight:i===`bottom`?Math.max(0,s-t.y):i===`top`?Math.max(0,t.rects.reference.y-a):Math.max(0,s-a),availableWidth:i===`right`?Math.max(0,o-t.x):i===`left`?Math.max(0,t.rects.reference.x-c):Math.max(0,o-c)}}}}return sizeMiddleware}export{OrbitConfigError,OrbitError,arrow,autoPlacement,autoUpdate,computePosition,createPositioner,detectOverflow,flip,getAlignment,getBoundaryRect,getClippingAncestorRect,getSide,hide,inline,limitShift,offset,shift,size};
|
|
1
|
+
import { clamp as e } from "@vielzeug/arsenal";
|
|
2
|
+
//#region src/utils.ts
|
|
3
|
+
var t = {
|
|
4
|
+
bottom: "top",
|
|
5
|
+
left: "right",
|
|
6
|
+
right: "left",
|
|
7
|
+
top: "bottom"
|
|
8
|
+
};
|
|
9
|
+
function getSide(e) {
|
|
10
|
+
return e.split("-")[0];
|
|
11
|
+
}
|
|
12
|
+
function getAlignment(e) {
|
|
13
|
+
return e.split("-")[1] ?? null;
|
|
14
|
+
}
|
|
15
|
+
function withPlacement(e, t) {
|
|
16
|
+
return t ? `${e}-${t}` : e;
|
|
17
|
+
}
|
|
18
|
+
function toRect({ height: e, width: t, x: n, y: r }) {
|
|
19
|
+
return {
|
|
20
|
+
height: e,
|
|
21
|
+
width: t,
|
|
22
|
+
x: n,
|
|
23
|
+
y: r
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function toSideObject(e = 0) {
|
|
27
|
+
return typeof e == "number" ? {
|
|
28
|
+
bottom: e,
|
|
29
|
+
left: e,
|
|
30
|
+
right: e,
|
|
31
|
+
top: e
|
|
32
|
+
} : {
|
|
33
|
+
bottom: e.bottom ?? 0,
|
|
34
|
+
left: e.left ?? 0,
|
|
35
|
+
right: e.right ?? 0,
|
|
36
|
+
top: e.top ?? 0
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function isElement(e) {
|
|
40
|
+
return typeof Element < "u" && e instanceof Element;
|
|
41
|
+
}
|
|
42
|
+
function flatTreeParent(e) {
|
|
43
|
+
return e.assignedSlot ? e.assignedSlot : e.parentElement ?? (e.getRootNode() instanceof ShadowRoot ? e.getRootNode().host : null);
|
|
44
|
+
}
|
|
45
|
+
function alignedOffset(e, t, n, r) {
|
|
46
|
+
return e === "start" ? t : e === "end" ? t + n - r : t + (n - r) / 2;
|
|
47
|
+
}
|
|
48
|
+
function baseCoords(e, t, n) {
|
|
49
|
+
let r = getSide(e), i = getAlignment(e);
|
|
50
|
+
switch (r) {
|
|
51
|
+
case "bottom": return {
|
|
52
|
+
x: alignedOffset(i, t.x, t.width, n.width),
|
|
53
|
+
y: t.y + t.height
|
|
54
|
+
};
|
|
55
|
+
case "left": return {
|
|
56
|
+
x: t.x - n.width,
|
|
57
|
+
y: alignedOffset(i, t.y, t.height, n.height)
|
|
58
|
+
};
|
|
59
|
+
case "right": return {
|
|
60
|
+
x: t.x + t.width,
|
|
61
|
+
y: alignedOffset(i, t.y, t.height, n.height)
|
|
62
|
+
};
|
|
63
|
+
case "top": return {
|
|
64
|
+
x: alignedOffset(i, t.x, t.width, n.width),
|
|
65
|
+
y: t.y - n.height
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
//#endregion
|
|
70
|
+
//#region src/auto-update.ts
|
|
71
|
+
function throttle(e, t) {
|
|
72
|
+
let n, r = 0, throttled = (() => {
|
|
73
|
+
let i = Date.now(), a = t - (i - r);
|
|
74
|
+
a <= 0 ? (n !== void 0 && clearTimeout(n), n = void 0, r = i, e()) : n === void 0 && (n = setTimeout(() => {
|
|
75
|
+
n = void 0, r = Date.now(), e();
|
|
76
|
+
}, a));
|
|
77
|
+
});
|
|
78
|
+
return throttled.cancel = () => {
|
|
79
|
+
n !== void 0 && clearTimeout(n), n = void 0;
|
|
80
|
+
}, throttled;
|
|
81
|
+
}
|
|
82
|
+
function getScrollAncestors(e) {
|
|
83
|
+
let t = [], n = flatTreeParent(e);
|
|
84
|
+
for (; n;) {
|
|
85
|
+
let e = getComputedStyle(n), r = e.overflow + e.overflowX + e.overflowY;
|
|
86
|
+
/auto|scroll|overlay/.test(r) && t.push(n), n = flatTreeParent(n);
|
|
87
|
+
}
|
|
88
|
+
return t;
|
|
89
|
+
}
|
|
90
|
+
function autoUpdate(e, t, n, { animationFrame: r = !1, observeAncestors: i = !0, observeFloating: a = !0, observeVisualViewport: o = !0, pauseWhenHidden: s = !0, throttle: c = 0 } = {}) {
|
|
91
|
+
let l = c > 0 ? throttle(n, c) : null, u = l ?? n, d = !0, conditionalNotify = () => {
|
|
92
|
+
d && u();
|
|
93
|
+
};
|
|
94
|
+
u();
|
|
95
|
+
let f = [];
|
|
96
|
+
if (s && isElement(e) && typeof IntersectionObserver < "u") {
|
|
97
|
+
let t = new IntersectionObserver((e) => {
|
|
98
|
+
d = e.at(-1)?.isIntersecting ?? !0, d && u();
|
|
99
|
+
});
|
|
100
|
+
t.observe(e), f.push(() => t.disconnect());
|
|
101
|
+
}
|
|
102
|
+
if (isElement(e) && i) {
|
|
103
|
+
let t = getScrollAncestors(e);
|
|
104
|
+
for (let e of t) e.addEventListener("scroll", conditionalNotify, { passive: !0 }), f.push(() => e.removeEventListener("scroll", conditionalNotify));
|
|
105
|
+
window.addEventListener("scroll", conditionalNotify, { passive: !0 }), f.push(() => window.removeEventListener("scroll", conditionalNotify));
|
|
106
|
+
} else {
|
|
107
|
+
let scrollHandler = (e) => {
|
|
108
|
+
e.composedPath().includes(t) || conditionalNotify();
|
|
109
|
+
};
|
|
110
|
+
window.addEventListener("scroll", scrollHandler, {
|
|
111
|
+
capture: !0,
|
|
112
|
+
passive: !0
|
|
113
|
+
}), f.push(() => window.removeEventListener("scroll", scrollHandler, { capture: !0 }));
|
|
114
|
+
}
|
|
115
|
+
window.addEventListener("resize", conditionalNotify, { passive: !0 }), f.push(() => window.removeEventListener("resize", conditionalNotify));
|
|
116
|
+
let p = o ? window.visualViewport : null;
|
|
117
|
+
p && (p.addEventListener("resize", conditionalNotify, { passive: !0 }), p.addEventListener("scroll", conditionalNotify, { passive: !0 }), f.push(() => {
|
|
118
|
+
p.removeEventListener("resize", conditionalNotify), p.removeEventListener("scroll", conditionalNotify);
|
|
119
|
+
}));
|
|
120
|
+
let m = new ResizeObserver(conditionalNotify);
|
|
121
|
+
isElement(e) && m.observe(e), a && m.observe(t), f.push(() => m.disconnect());
|
|
122
|
+
let h = 0;
|
|
123
|
+
if (r) {
|
|
124
|
+
let frameLoop = () => {
|
|
125
|
+
conditionalNotify(), h = window.requestAnimationFrame(frameLoop);
|
|
126
|
+
};
|
|
127
|
+
h = window.requestAnimationFrame(frameLoop), f.push(() => window.cancelAnimationFrame(h));
|
|
128
|
+
}
|
|
129
|
+
return () => {
|
|
130
|
+
l?.cancel();
|
|
131
|
+
for (let e of f) e();
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
//#endregion
|
|
135
|
+
//#region src/errors.ts
|
|
136
|
+
var OrbitError = class extends Error {
|
|
137
|
+
constructor(e, t) {
|
|
138
|
+
super(e, t), this.name = new.target.name, Object.setPrototypeOf(this, new.target.prototype);
|
|
139
|
+
}
|
|
140
|
+
}, OrbitConfigError = class extends OrbitError {};
|
|
141
|
+
//#endregion
|
|
142
|
+
//#region src/core.ts
|
|
143
|
+
function getRects(e, t) {
|
|
144
|
+
return {
|
|
145
|
+
floating: toRect(t.getBoundingClientRect()),
|
|
146
|
+
reference: toRect(e.getBoundingClientRect())
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
function mergeState(e, t) {
|
|
150
|
+
return t ? {
|
|
151
|
+
...e,
|
|
152
|
+
middlewareData: t.data ? Object.assign(Object.create(null), e.middlewareData, t.data) : e.middlewareData,
|
|
153
|
+
placement: t.placement ?? e.placement,
|
|
154
|
+
x: t.x ?? e.x,
|
|
155
|
+
y: t.y ?? e.y
|
|
156
|
+
} : e;
|
|
157
|
+
}
|
|
158
|
+
var n = 8;
|
|
159
|
+
function computePosition(e, t, { boundary: r, containingBlock: i, middleware: a = [], padding: o, placement: s = "bottom" } = {}) {
|
|
160
|
+
let c = a, l = s, u = {}, d = getRects(e, t);
|
|
161
|
+
for (let a = 0; a < n; a += 1) {
|
|
162
|
+
let n = {
|
|
163
|
+
...baseCoords(l, d.reference, d.floating),
|
|
164
|
+
boundary: r,
|
|
165
|
+
elements: {
|
|
166
|
+
floating: t,
|
|
167
|
+
reference: e
|
|
168
|
+
},
|
|
169
|
+
initialPlacement: s,
|
|
170
|
+
middlewareData: u,
|
|
171
|
+
padding: o,
|
|
172
|
+
placement: l,
|
|
173
|
+
rects: d
|
|
174
|
+
}, a;
|
|
175
|
+
for (let e of c) {
|
|
176
|
+
let t = e(n);
|
|
177
|
+
if (n = mergeState(n, t), u = n.middlewareData, a = t?.reset, a) break;
|
|
178
|
+
}
|
|
179
|
+
if (!a) {
|
|
180
|
+
let e = {
|
|
181
|
+
middlewareData: n.middlewareData,
|
|
182
|
+
placement: n.placement,
|
|
183
|
+
x: n.x,
|
|
184
|
+
y: n.y
|
|
185
|
+
};
|
|
186
|
+
if (i) {
|
|
187
|
+
let t = i.getBoundingClientRect();
|
|
188
|
+
return {
|
|
189
|
+
...e,
|
|
190
|
+
x: e.x - t.x,
|
|
191
|
+
y: e.y - t.y
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
return e;
|
|
195
|
+
}
|
|
196
|
+
a.remeasure ? d = getRects(e, t) : a.rects != null && (d = a.rects), l = a.placement ?? n.placement;
|
|
197
|
+
}
|
|
198
|
+
throw new OrbitConfigError("Middleware triggered too many resets in a single compute cycle.");
|
|
199
|
+
}
|
|
200
|
+
//#endregion
|
|
201
|
+
//#region src/containing-block.ts
|
|
202
|
+
var r = [
|
|
203
|
+
"transform",
|
|
204
|
+
"perspective",
|
|
205
|
+
"filter"
|
|
206
|
+
], i = [
|
|
207
|
+
"layout",
|
|
208
|
+
"paint",
|
|
209
|
+
"strict",
|
|
210
|
+
"content"
|
|
211
|
+
];
|
|
212
|
+
function establishesFixedContainingBlock(e) {
|
|
213
|
+
return e.transform !== "none" || e.perspective !== "none" || e.filter !== "none" || e.backdropFilter && e.backdropFilter !== "none" || e.willChange !== "auto" && r.some((t) => e.willChange.includes(t)) ? !0 : e.contain !== "none" && i.some((t) => e.contain.includes(t));
|
|
214
|
+
}
|
|
215
|
+
function getContainingBlock(e) {
|
|
216
|
+
let t = flatTreeParent(e);
|
|
217
|
+
for (; t;) {
|
|
218
|
+
if (establishesFixedContainingBlock(getComputedStyle(t))) return t;
|
|
219
|
+
t = flatTreeParent(t);
|
|
220
|
+
}
|
|
221
|
+
return null;
|
|
222
|
+
}
|
|
223
|
+
//#endregion
|
|
224
|
+
//#region src/overflow.ts
|
|
225
|
+
function getViewportRect() {
|
|
226
|
+
let e = window.visualViewport;
|
|
227
|
+
return e ? {
|
|
228
|
+
height: e.height,
|
|
229
|
+
width: e.width,
|
|
230
|
+
x: e.offsetLeft,
|
|
231
|
+
y: e.offsetTop
|
|
232
|
+
} : {
|
|
233
|
+
height: window.innerHeight,
|
|
234
|
+
width: window.innerWidth,
|
|
235
|
+
x: 0,
|
|
236
|
+
y: 0
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
function getBoundaryRect(e) {
|
|
240
|
+
if (!e) return getViewportRect();
|
|
241
|
+
if (e instanceof Element) {
|
|
242
|
+
let t = e.getBoundingClientRect();
|
|
243
|
+
return {
|
|
244
|
+
height: t.height,
|
|
245
|
+
width: t.width,
|
|
246
|
+
x: t.x,
|
|
247
|
+
y: t.y
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
return e;
|
|
251
|
+
}
|
|
252
|
+
var a = /(hidden|clip|scroll|auto|overlay)/;
|
|
253
|
+
function intersectRect(e, t) {
|
|
254
|
+
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);
|
|
255
|
+
return {
|
|
256
|
+
height: Math.max(0, a - r),
|
|
257
|
+
width: Math.max(0, i - n),
|
|
258
|
+
x: n,
|
|
259
|
+
y: r
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
function getClippingAncestorRect(e) {
|
|
263
|
+
let t = flatTreeParent(e), n = getViewportRect();
|
|
264
|
+
for (; t;) {
|
|
265
|
+
let e = getComputedStyle(t);
|
|
266
|
+
if (a.test(`${e.overflow}${e.overflowX}${e.overflowY}`)) {
|
|
267
|
+
let e = t.getBoundingClientRect();
|
|
268
|
+
n = intersectRect(n, {
|
|
269
|
+
height: e.height,
|
|
270
|
+
width: e.width,
|
|
271
|
+
x: e.x,
|
|
272
|
+
y: e.y
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
t = flatTreeParent(t);
|
|
276
|
+
}
|
|
277
|
+
return n;
|
|
278
|
+
}
|
|
279
|
+
function resolveBoundary(e, t) {
|
|
280
|
+
return {
|
|
281
|
+
boundary: getBoundaryRect(e.boundary ?? t.boundary),
|
|
282
|
+
padding: toSideObject(e.padding ?? t.padding)
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
function getFloatingRect(e) {
|
|
286
|
+
return {
|
|
287
|
+
...e.rects.floating,
|
|
288
|
+
x: e.x,
|
|
289
|
+
y: e.y
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
function detectOverflowAtRect(e, t, n) {
|
|
293
|
+
return {
|
|
294
|
+
bottom: e.y + e.height - (t.y + t.height - n.bottom),
|
|
295
|
+
left: t.x + n.left - e.x,
|
|
296
|
+
right: e.x + e.width - (t.x + t.width - n.right),
|
|
297
|
+
top: t.y + n.top - e.y
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
function totalOverflow(e) {
|
|
301
|
+
return Math.max(e.top, 0) + Math.max(e.right, 0) + Math.max(e.bottom, 0) + Math.max(e.left, 0);
|
|
302
|
+
}
|
|
303
|
+
function hasOverflow(e) {
|
|
304
|
+
return e.top > 0 || e.right > 0 || e.bottom > 0 || e.left > 0;
|
|
305
|
+
}
|
|
306
|
+
function isFullyClipped(e, t) {
|
|
307
|
+
return t.top >= e.height || t.right >= e.width || t.bottom >= e.height || t.left >= e.width;
|
|
308
|
+
}
|
|
309
|
+
function getAvailableSpace(e, t, n, r) {
|
|
310
|
+
let i = e.rects.reference;
|
|
311
|
+
switch (getSide(t)) {
|
|
312
|
+
case "bottom": return n.y + n.height - r.bottom - (i.y + i.height);
|
|
313
|
+
case "left": return i.x - (n.x + r.left);
|
|
314
|
+
case "right": return n.x + n.width - r.right - (i.x + i.width);
|
|
315
|
+
case "top": return i.y - (n.y + r.top);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
function getPlacementOverflow(e, t, n = {}) {
|
|
319
|
+
let { x: r, y: i } = baseCoords(t, e.rects.reference, e.rects.floating), { boundary: a, padding: o } = resolveBoundary(n, e);
|
|
320
|
+
return detectOverflowAtRect({
|
|
321
|
+
...e.rects.floating,
|
|
322
|
+
x: r,
|
|
323
|
+
y: i
|
|
324
|
+
}, a, o);
|
|
325
|
+
}
|
|
326
|
+
function detectOverflow(e, t = {}) {
|
|
327
|
+
let { boundary: n, padding: r } = resolveBoundary(t, e);
|
|
328
|
+
return detectOverflowAtRect(getFloatingRect(e), n, r);
|
|
329
|
+
}
|
|
330
|
+
//#endregion
|
|
331
|
+
//#region src/float.ts
|
|
332
|
+
function resolveContainingBlock(e, t) {
|
|
333
|
+
return t === "absolute" ? e.offsetParent instanceof Element ? e.offsetParent : null : getContainingBlock(e);
|
|
334
|
+
}
|
|
335
|
+
function applyDefault(e, t, n) {
|
|
336
|
+
t.style.position = n, t.style.left = `${e.x}px`, t.style.top = `${e.y}px`;
|
|
337
|
+
}
|
|
338
|
+
function createPositioner(e, t, { apply: n, autoUpdate: r = {}, boundary: i = "clippingAncestors", middleware: a, padding: o, placement: s = "bottom", strategy: c = "fixed" } = {}) {
|
|
339
|
+
let l = new AbortController(), u = !0, d = !1, f, p;
|
|
340
|
+
function update() {
|
|
341
|
+
if (!u) return;
|
|
342
|
+
let r = resolveContainingBlock(t, c), l = computePosition(e, t, {
|
|
343
|
+
boundary: i === "clippingAncestors" ? getClippingAncestorRect(t) : i,
|
|
344
|
+
containingBlock: r,
|
|
345
|
+
middleware: a,
|
|
346
|
+
padding: o,
|
|
347
|
+
placement: s
|
|
348
|
+
});
|
|
349
|
+
p = l, (n ?? ((e) => applyDefault(e, t, c)))(l);
|
|
350
|
+
}
|
|
351
|
+
let m = {
|
|
352
|
+
get disposalSignal() {
|
|
353
|
+
return l.signal;
|
|
354
|
+
},
|
|
355
|
+
dispose() {
|
|
356
|
+
d || (d = !0, u = !1, l.abort(), f?.());
|
|
357
|
+
},
|
|
358
|
+
get disposed() {
|
|
359
|
+
return d;
|
|
360
|
+
},
|
|
361
|
+
getPosition: () => p,
|
|
362
|
+
[Symbol.dispose]() {
|
|
363
|
+
this.dispose();
|
|
364
|
+
},
|
|
365
|
+
update() {
|
|
366
|
+
d || update();
|
|
367
|
+
}
|
|
368
|
+
};
|
|
369
|
+
return r === !1 ? update() : f = autoUpdate(e, t, update, r), m;
|
|
370
|
+
}
|
|
371
|
+
//#endregion
|
|
372
|
+
//#region src/inline.ts
|
|
373
|
+
function getClientRects(e) {
|
|
374
|
+
return !("getClientRects" in e) || typeof e.getClientRects != "function" ? [] : Array.from(e.getClientRects()).map(toRect).filter((e) => e.width > 0 || e.height > 0);
|
|
375
|
+
}
|
|
376
|
+
function rectContainsPoint(e, t, n, r) {
|
|
377
|
+
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;
|
|
378
|
+
}
|
|
379
|
+
function sameRect(e, t) {
|
|
380
|
+
return e.x === t.x && e.y === t.y && e.width === t.width && e.height === t.height;
|
|
381
|
+
}
|
|
382
|
+
function inline(e = {}) {
|
|
383
|
+
function inlineMiddleware(t) {
|
|
384
|
+
let n = getClientRects(t.elements.reference);
|
|
385
|
+
if (n.length <= 1) return;
|
|
386
|
+
let r = toSideObject(e.padding ?? 2), i = getSide(t.placement), a = n[0];
|
|
387
|
+
if (e.x != null && e.y != null) a = n.find((t) => rectContainsPoint(t, e.x, e.y, r)) ?? a;
|
|
388
|
+
else if (i === "top" || i === "bottom") {
|
|
389
|
+
let e = t.x + t.rects.floating.width / 2;
|
|
390
|
+
a = n.reduce((t, n) => {
|
|
391
|
+
let r = Math.abs(t.x + t.width / 2 - e);
|
|
392
|
+
return Math.abs(n.x + n.width / 2 - e) < r ? n : t;
|
|
393
|
+
}, a);
|
|
394
|
+
} else {
|
|
395
|
+
let e = t.y + t.rects.floating.height / 2;
|
|
396
|
+
a = n.reduce((t, n) => {
|
|
397
|
+
let r = Math.abs(t.y + t.height / 2 - e);
|
|
398
|
+
return Math.abs(n.y + n.height / 2 - e) < r ? n : t;
|
|
399
|
+
}, a);
|
|
400
|
+
}
|
|
401
|
+
if (!sameRect(a, t.rects.reference)) return { reset: { rects: {
|
|
402
|
+
...t.rects,
|
|
403
|
+
reference: a
|
|
404
|
+
} } };
|
|
405
|
+
}
|
|
406
|
+
return inlineMiddleware;
|
|
407
|
+
}
|
|
408
|
+
//#endregion
|
|
409
|
+
//#region src/middleware/arrow.ts
|
|
410
|
+
function arrow({ element: t, padding: n = 0 }) {
|
|
411
|
+
function arrowMiddleware(r) {
|
|
412
|
+
let i = getSide(r.placement), a = toSideObject(n), o = toRect(t.getBoundingClientRect());
|
|
413
|
+
if (i === "top" || i === "bottom") {
|
|
414
|
+
let t = r.rects.reference.x + r.rects.reference.width / 2 - r.x - o.width / 2, n = a.left, i = Math.max(n, r.rects.floating.width - o.width - a.right), s = e(t, n, i);
|
|
415
|
+
return { data: { arrow: {
|
|
416
|
+
centerOffset: t - s,
|
|
417
|
+
constrained: s !== t,
|
|
418
|
+
x: s
|
|
419
|
+
} } };
|
|
420
|
+
}
|
|
421
|
+
let s = r.rects.reference.y + r.rects.reference.height / 2 - r.y - o.height / 2, c = a.top, l = Math.max(c, r.rects.floating.height - o.height - a.bottom), u = e(s, c, l);
|
|
422
|
+
return { data: { arrow: {
|
|
423
|
+
centerOffset: s - u,
|
|
424
|
+
constrained: u !== s,
|
|
425
|
+
y: u
|
|
426
|
+
} } };
|
|
427
|
+
}
|
|
428
|
+
return arrowMiddleware;
|
|
429
|
+
}
|
|
430
|
+
//#endregion
|
|
431
|
+
//#region src/middleware/auto-placement.ts
|
|
432
|
+
var o = [
|
|
433
|
+
"top",
|
|
434
|
+
"right",
|
|
435
|
+
"bottom",
|
|
436
|
+
"left"
|
|
437
|
+
];
|
|
438
|
+
function getDefaultPlacements(e) {
|
|
439
|
+
return e === void 0 ? o : e === null ? o.flatMap((e) => [
|
|
440
|
+
e,
|
|
441
|
+
`${e}-start`,
|
|
442
|
+
`${e}-end`
|
|
443
|
+
]) : o.map((t) => `${t}-${e}`);
|
|
444
|
+
}
|
|
445
|
+
function autoPlacement(e = {}) {
|
|
446
|
+
return function autoPlacementMiddleware(t) {
|
|
447
|
+
let { boundary: n, padding: r } = resolveBoundary(e, t), i = e.allowedPlacements ?? getDefaultPlacements(e.alignment);
|
|
448
|
+
i.length;
|
|
449
|
+
let a = t.placement, o = Infinity, s = -Infinity;
|
|
450
|
+
for (let c of i) {
|
|
451
|
+
let i = totalOverflow(getPlacementOverflow(t, c, e)), l = getAvailableSpace(t, c, n, r);
|
|
452
|
+
(i < o || i === o && l > s) && (a = c, o = i, s = l);
|
|
453
|
+
}
|
|
454
|
+
if (a !== t.placement) return { reset: { placement: a } };
|
|
455
|
+
};
|
|
456
|
+
}
|
|
457
|
+
//#endregion
|
|
458
|
+
//#region src/middleware/flip.ts
|
|
459
|
+
function flip(e = {}) {
|
|
460
|
+
function flipMiddleware(n) {
|
|
461
|
+
if (!hasOverflow(detectOverflow(n, e))) return;
|
|
462
|
+
let r = getSide(n.placement), i = getAlignment(n.placement), a = e.fallbackPlacements ?? [withPlacement(t[r], i)], o = [n.placement], s = n.placement, c = totalOverflow(getPlacementOverflow(n, n.placement, e));
|
|
463
|
+
for (let t of a) {
|
|
464
|
+
let r = getPlacementOverflow(n, t, e), i = totalOverflow(r);
|
|
465
|
+
if (!hasOverflow(r)) return {
|
|
466
|
+
data: { flip: { skippedPlacements: o } },
|
|
467
|
+
reset: { placement: t }
|
|
468
|
+
};
|
|
469
|
+
o.push(t), i < c && (s = t, c = i);
|
|
470
|
+
}
|
|
471
|
+
if (s !== n.placement) return {
|
|
472
|
+
data: { flip: { skippedPlacements: o } },
|
|
473
|
+
reset: { placement: s }
|
|
474
|
+
};
|
|
475
|
+
}
|
|
476
|
+
return flipMiddleware;
|
|
477
|
+
}
|
|
478
|
+
//#endregion
|
|
479
|
+
//#region src/middleware/hide.ts
|
|
480
|
+
function hide(e = {}) {
|
|
481
|
+
let t = e.strategy ?? "both";
|
|
482
|
+
function hideMiddleware(n) {
|
|
483
|
+
let { boundary: r, padding: i } = resolveBoundary(e, n), a = {};
|
|
484
|
+
if (t === "escaped" || t === "both") {
|
|
485
|
+
let e = getFloatingRect(n), t = detectOverflowAtRect(e, r, i);
|
|
486
|
+
a.escaped = isFullyClipped(e, t), a.escapedOffsets = t;
|
|
487
|
+
}
|
|
488
|
+
if (t === "referenceHidden" || t === "both") {
|
|
489
|
+
let e = detectOverflowAtRect(n.rects.reference, r, i);
|
|
490
|
+
a.referenceHidden = isFullyClipped(n.rects.reference, e), a.referenceHiddenOffsets = e;
|
|
491
|
+
}
|
|
492
|
+
return { data: { hide: a } };
|
|
493
|
+
}
|
|
494
|
+
return hideMiddleware;
|
|
495
|
+
}
|
|
496
|
+
//#endregion
|
|
497
|
+
//#region src/middleware/offset.ts
|
|
498
|
+
function resolveOffsetConfig(e, t) {
|
|
499
|
+
let n = typeof e == "function" ? e(t) : e;
|
|
500
|
+
return typeof n == "number" ? {
|
|
501
|
+
crossAxis: 0,
|
|
502
|
+
mainAxis: n
|
|
503
|
+
} : {
|
|
504
|
+
crossAxis: n.crossAxis ?? 0,
|
|
505
|
+
mainAxis: n.mainAxis ?? 0
|
|
506
|
+
};
|
|
507
|
+
}
|
|
508
|
+
function offset(e) {
|
|
509
|
+
return function offsetMiddleware(t) {
|
|
510
|
+
let n = getSide(t.placement), { crossAxis: r, mainAxis: i } = resolveOffsetConfig(e, t);
|
|
511
|
+
switch (n) {
|
|
512
|
+
case "bottom": return {
|
|
513
|
+
x: t.x + r,
|
|
514
|
+
y: t.y + i
|
|
515
|
+
};
|
|
516
|
+
case "left": return {
|
|
517
|
+
x: t.x - i,
|
|
518
|
+
y: t.y + r
|
|
519
|
+
};
|
|
520
|
+
case "right": return {
|
|
521
|
+
x: t.x + i,
|
|
522
|
+
y: t.y + r
|
|
523
|
+
};
|
|
524
|
+
case "top": return {
|
|
525
|
+
x: t.x + r,
|
|
526
|
+
y: t.y - i
|
|
527
|
+
};
|
|
528
|
+
}
|
|
529
|
+
};
|
|
530
|
+
}
|
|
531
|
+
//#endregion
|
|
532
|
+
//#region src/middleware/shift.ts
|
|
533
|
+
function limitShift(t = {}) {
|
|
534
|
+
return (n, r) => {
|
|
535
|
+
let { placement: i, rects: a, x: o, y: s } = n, c = getSide(i), l = c === "top" || c === "bottom", u = typeof t.offset == "function" ? t.offset(n) : t.offset ?? 0;
|
|
536
|
+
if (l) {
|
|
537
|
+
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(o + r.crossAxis, i, s);
|
|
538
|
+
return {
|
|
539
|
+
...r,
|
|
540
|
+
crossAxis: c - o
|
|
541
|
+
};
|
|
542
|
+
}
|
|
543
|
+
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(s + r.crossAxis, p, m);
|
|
544
|
+
return {
|
|
545
|
+
...r,
|
|
546
|
+
crossAxis: h - s
|
|
547
|
+
};
|
|
548
|
+
};
|
|
549
|
+
}
|
|
550
|
+
function shift(e = {}) {
|
|
551
|
+
let { crossAxis: t = !0, limiter: n, mainAxis: r = !1 } = e;
|
|
552
|
+
function shiftMiddleware(i) {
|
|
553
|
+
let a = detectOverflow(i, e), o = getSide(i.placement), s = o === "top" || o === "bottom", c = Math.max(a.left, 0) - Math.max(a.right, 0), l = Math.max(a.top, 0) - Math.max(a.bottom, 0), u = s ? t : r, d = s ? r : t, f = u ? c : 0, p = d ? l : 0;
|
|
554
|
+
if (n) {
|
|
555
|
+
let e = n(i, {
|
|
556
|
+
crossAxis: s ? f : p,
|
|
557
|
+
mainAxis: s ? p : f
|
|
558
|
+
});
|
|
559
|
+
f = s ? e.crossAxis : e.mainAxis, p = s ? e.mainAxis : e.crossAxis;
|
|
560
|
+
}
|
|
561
|
+
return {
|
|
562
|
+
data: { shift: {
|
|
563
|
+
x: f,
|
|
564
|
+
y: p
|
|
565
|
+
} },
|
|
566
|
+
x: i.x + f,
|
|
567
|
+
y: i.y + p
|
|
568
|
+
};
|
|
569
|
+
}
|
|
570
|
+
return shiftMiddleware;
|
|
571
|
+
}
|
|
572
|
+
//#endregion
|
|
573
|
+
//#region src/middleware/size.ts
|
|
574
|
+
function size(e = {}) {
|
|
575
|
+
function sizeMiddleware(t) {
|
|
576
|
+
let { boundary: n, padding: r } = resolveBoundary(e, t), i = getSide(t.placement), a = n.y + r.top, o = n.x + n.width - r.right, s = n.y + n.height - r.bottom, c = n.x + r.left;
|
|
577
|
+
return { data: { size: {
|
|
578
|
+
availableHeight: i === "bottom" ? Math.max(0, s - t.y) : i === "top" ? Math.max(0, t.rects.reference.y - a) : Math.max(0, s - a),
|
|
579
|
+
availableWidth: i === "right" ? Math.max(0, o - t.x) : i === "left" ? Math.max(0, t.rects.reference.x - c) : Math.max(0, o - c)
|
|
580
|
+
} } };
|
|
581
|
+
}
|
|
582
|
+
return sizeMiddleware;
|
|
583
|
+
}
|
|
584
|
+
//#endregion
|
|
585
|
+
export { OrbitConfigError, OrbitError, arrow, autoPlacement, autoUpdate, computePosition, createPositioner, detectOverflow, flip, getAlignment, getBoundaryRect, getClippingAncestorRect, getSide, hide, inline, limitShift, offset, shift, size };
|
|
586
|
+
|
|
2
587
|
//# sourceMappingURL=orbit.js.map
|