@m3e/core 1.0.6 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/a11y.js +1420 -1033
- package/dist/a11y.js.map +1 -1
- package/dist/a11y.min.js +10 -23
- package/dist/a11y.min.js.map +1 -1
- package/dist/anchoring.js +2 -8
- package/dist/anchoring.js.map +1 -1
- package/dist/anchoring.min.js +1 -1
- package/dist/anchoring.min.js.map +1 -1
- package/dist/custom-elements.json +4231 -4024
- package/dist/html-custom-data.json +0 -5
- package/dist/index.js +4007 -3561
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +9 -480
- package/dist/index.min.js.map +1 -1
- package/dist/src/a11y/list-key/ListKeyManager.d.ts +11 -0
- package/dist/src/a11y/list-key/ListKeyManager.d.ts.map +1 -1
- package/dist/src/anchoring/positionAnchor.d.ts +2 -2
- package/dist/src/anchoring/positionAnchor.d.ts.map +1 -1
- package/dist/src/shared/primitives/CollapsibleElement.d.ts.map +1 -1
- package/dist/src/shared/primitives/RippleElement.d.ts +0 -5
- package/dist/src/shared/primitives/RippleElement.d.ts.map +1 -1
- package/dist/src/shared/primitives/SlideElement.d.ts.map +1 -1
- package/dist/src/shared/utils/generateClipPaths.d.ts +8 -0
- package/dist/src/shared/utils/generateClipPaths.d.ts.map +1 -0
- package/dist/src/shared/utils/index.d.ts +1 -0
- package/dist/src/shared/utils/index.d.ts.map +1 -1
- package/package.json +1 -15
package/dist/anchoring.min.js
CHANGED
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
* Copyright (c) 2025 matraic
|
|
4
4
|
* See LICENSE file in the project root for full license text.
|
|
5
5
|
*/
|
|
6
|
-
const t=Math.min,e=Math.max,n=Math.round,o=Math.floor,i=t=>({x:t,y:t}),r={left:"right",right:"left",bottom:"top",top:"bottom"},l={start:"end",end:"start"};function c(n,o,i){return e(n,t(o,i))}function s(t,e){return"function"==typeof t?t(e):t}function a(t){return t.split("-")[0]}function f(t){return t.split("-")[1]}function u(t){return"x"===t?"y":"x"}function h(t){return"y"===t?"height":"width"}const d=new Set(["top","bottom"]);function p(t){return d.has(a(t))?"y":"x"}function m(t){return u(p(t))}function g(t){return t.replace(/start|end/g,t=>l[t])}const y=["left","right"],w=["right","left"],x=["top","bottom"],v=["bottom","top"];function b(t,e,n,o){const i=f(t);let r=function(t,e,n){switch(t){case"top":case"bottom":return n?e?w:y:e?y:w;case"left":case"right":return e?x:v;default:return[]}}(a(t),"start"===n,o);return i&&(r=r.map(t=>t+"-"+i),e&&(r=r.concat(r.map(g)))),r}function R(t){return t.replace(/left|right|bottom|top/g,t=>r[t])}function L(t){return"number"!=typeof t?function(t){return{top:0,right:0,bottom:0,left:0,...t}}(t):{top:t,right:t,bottom:t,left:t}}function S(t){const{x:e,y:n,width:o,height:i}=t;return{width:o,height:i,top:n,left:e,right:e+o,bottom:n+i,x:e,y:n}}function T(t,e,n){let{reference:o,floating:i}=t;const r=p(e),l=m(e),c=h(l),s=a(e),u="y"===r,d=o.x+o.width/2-i.width/2,g=o.y+o.height/2-i.height/2,y=o[c]/2-i[c]/2;let w;switch(s){case"top":w={x:d,y:o.y-i.height};break;case"bottom":w={x:d,y:o.y+o.height};break;case"right":w={x:o.x+o.width,y:g};break;case"left":w={x:o.x-i.width,y:g};break;default:w={x:o.x,y:o.y}}switch(f(e)){case"start":w[l]-=y*(n&&u?-1:1);break;case"end":w[l]+=y*(n&&u?-1:1)}return w}async function E(t,e){var n;void 0===e&&(e={});const{x:o,y:i,platform:r,rects:l,elements:c,strategy:a}=t,{boundary:f="clippingAncestors",rootBoundary:u="viewport",elementContext:h="floating",altBoundary:d=!1,padding:p=0}=s(e,t),m=L(p),g=c[d?"floating"===h?"reference":"floating":h],y=S(await r.getClippingRect({element:null==(n=await(null==r.isElement?void 0:r.isElement(g)))||n?g:g.contextElement||await(null==r.getDocumentElement?void 0:r.getDocumentElement(c.floating)),boundary:f,rootBoundary:u,strategy:a})),w="floating"===h?{x:o,y:i,width:l.floating.width,height:l.floating.height}:l.reference,x=await(null==r.getOffsetParent?void 0:r.getOffsetParent(c.floating)),v=await(null==r.isElement?void 0:r.isElement(x))&&await(null==r.getScale?void 0:r.getScale(x))||{x:1,y:1},b=S(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:w,offsetParent:x,strategy:a}):w);return{top:(y.top-b.top+m.top)/v.y,bottom:(b.bottom-y.bottom+m.bottom)/v.y,left:(y.left-b.left+m.left)/v.x,right:(b.right-y.right+m.right)/v.x}}function A(n){const o=t(...n.map(t=>t.left)),i=t(...n.map(t=>t.top));return{x:o,y:i,width:e(...n.map(t=>t.right))-o,height:e(...n.map(t=>t.bottom))-i}}const C=new Set(["left","top"]);function D(){return"undefined"!=typeof window}function O(t){return k(t)?(t.nodeName||"").toLowerCase():"#document"}function P(t){var e;return(null==t||null==(e=t.ownerDocument)?void 0:e.defaultView)||window}function F(t){var e;return null==(e=(k(t)?t.ownerDocument:t.document)||window.document)?void 0:e.documentElement}function k(t){return!!D()&&(t instanceof Node||t instanceof P(t).Node)}function B(t){return!!D()&&(t instanceof Element||t instanceof P(t).Element)}function N(t){return!!D()&&(t instanceof HTMLElement||t instanceof P(t).HTMLElement)}function W(t){return!(!D()||"undefined"==typeof ShadowRoot)&&(t instanceof ShadowRoot||t instanceof P(t).ShadowRoot)}const H=new Set(["inline","contents"]);function M(t){const{overflow:e,overflowX:n,overflowY:o,display:i}=K(t);return/auto|scroll|overlay|hidden|clip/.test(e+o+n)&&!H.has(i)}const V=new Set(["table","td","th"]);function z(t){return V.has(O(t))}const $=[":popover-open",":modal"];function I(t){return $.some(e=>{try{return t.matches(e)}catch(t){return!1}})}const Y=["transform","translate","scale","rotate","perspective"],j=["transform","translate","scale","rotate","perspective","filter"],q=["paint","layout","strict","content"];function X(t){const e=_(),n=B(t)?K(t):t;return Y.some(t=>!!n[t]&&"none"!==n[t])||!!n.containerType&&"normal"!==n.containerType||!e&&!!n.backdropFilter&&"none"!==n.backdropFilter||!e&&!!n.filter&&"none"!==n.filter||j.some(t=>(n.willChange||"").includes(t))||q.some(t=>(n.contain||"").includes(t))}function _(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}const G=new Set(["html","body","#document"]);function J(t){return G.has(O(t))}function K(t){return P(t).getComputedStyle(t)}function Q(t){return B(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function U(t){if("html"===O(t))return t;const e=t.assignedSlot||t.parentNode||W(t)&&t.host||F(t);return W(e)?e.host:e}function Z(t){const e=U(t);return J(e)?t.ownerDocument?t.ownerDocument.body:t.body:N(e)&&M(e)?e:Z(e)}function tt(t,e,n){var o;void 0===e&&(e=[]),void 0===n&&(n=!0);const i=Z(t),r=i===(null==(o=t.ownerDocument)?void 0:o.body),l=P(i);if(r){const t=et(l);return e.concat(l,l.visualViewport||[],M(i)?i:[],t&&n?tt(t):[])}return e.concat(i,tt(i,[],n))}function et(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function nt(t){const e=K(t);let o=parseFloat(e.width)||0,i=parseFloat(e.height)||0;const r=N(t),l=r?t.offsetWidth:o,c=r?t.offsetHeight:i,s=n(o)!==l||n(i)!==c;return s&&(o=l,i=c),{width:o,height:i,$:s}}function ot(t){return B(t)?t:t.contextElement}function it(t){const e=ot(t);if(!N(e))return i(1);const o=e.getBoundingClientRect(),{width:r,height:l,$:c}=nt(e);let s=(c?n(o.width):o.width)/r,a=(c?n(o.height):o.height)/l;return s&&Number.isFinite(s)||(s=1),a&&Number.isFinite(a)||(a=1),{x:s,y:a}}const rt=i(0);function lt(t){const e=P(t);return _()&&e.visualViewport?{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}:rt}function ct(t,e,n,o){void 0===e&&(e=!1),void 0===n&&(n=!1);const r=t.getBoundingClientRect(),l=ot(t);let c=i(1);e&&(o?B(o)&&(c=it(o)):c=it(t));const s=function(t,e,n){return void 0===e&&(e=!1),!(!n||e&&n!==P(t))&&e}(l,n,o)?lt(l):i(0);let a=(r.left+s.x)/c.x,f=(r.top+s.y)/c.y,u=r.width/c.x,h=r.height/c.y;if(l){const t=P(l),e=o&&B(o)?P(o):o;let n=t,i=et(n);for(;i&&o&&e!==n;){const t=it(i),e=i.getBoundingClientRect(),o=K(i),r=e.left+(i.clientLeft+parseFloat(o.paddingLeft))*t.x,l=e.top+(i.clientTop+parseFloat(o.paddingTop))*t.y;a*=t.x,f*=t.y,u*=t.x,h*=t.y,a+=r,f+=l,n=P(i),i=et(n)}}return S({width:u,height:h,x:a,y:f})}function st(t,e){const n=Q(t).scrollLeft;return e?e.left+n:ct(F(t)).left+n}function at(t,e){const n=t.getBoundingClientRect();return{x:n.left+e.scrollLeft-st(t,n),y:n.top+e.scrollTop}}const ft=new Set(["absolute","fixed"]);function ut(t,n,o){let r;if("viewport"===n)r=function(t,e){const n=P(t),o=F(t),i=n.visualViewport;let r=o.clientWidth,l=o.clientHeight,c=0,s=0;if(i){r=i.width,l=i.height;const t=_();(!t||t&&"fixed"===e)&&(c=i.offsetLeft,s=i.offsetTop)}const a=st(o);if(a<=0){const t=o.ownerDocument,e=t.body,n=getComputedStyle(e),i="CSS1Compat"===t.compatMode&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,l=Math.abs(o.clientWidth-e.clientWidth-i);l<=25&&(r-=l)}else a<=25&&(r+=a);return{width:r,height:l,x:c,y:s}}(t,o);else if("document"===n)r=function(t){const n=F(t),o=Q(t),i=t.ownerDocument.body,r=e(n.scrollWidth,n.clientWidth,i.scrollWidth,i.clientWidth),l=e(n.scrollHeight,n.clientHeight,i.scrollHeight,i.clientHeight);let c=-o.scrollLeft+st(t);const s=-o.scrollTop;return"rtl"===K(i).direction&&(c+=e(n.clientWidth,i.clientWidth)-r),{width:r,height:l,x:c,y:s}}(F(t));else if(B(n))r=function(t,e){const n=ct(t,!0,"fixed"===e),o=n.top+t.clientTop,r=n.left+t.clientLeft,l=N(t)?it(t):i(1);return{width:t.clientWidth*l.x,height:t.clientHeight*l.y,x:r*l.x,y:o*l.y}}(n,o);else{const e=lt(t);r={x:n.x-e.x,y:n.y-e.y,width:n.width,height:n.height}}return S(r)}function ht(t,e){const n=U(t);return!(n===e||!B(n)||J(n))&&("fixed"===K(n).position||ht(n,e))}function dt(t,e,n){const o=N(e),r=F(e),l="fixed"===n,c=ct(t,!0,l,e);let s={scrollLeft:0,scrollTop:0};const a=i(0);function f(){a.x=st(r)}if(o||!o&&!l)if(("body"!==O(e)||M(r))&&(s=Q(e)),o){const t=ct(e,!0,l,e);a.x=t.x+e.clientLeft,a.y=t.y+e.clientTop}else r&&f();l&&!o&&r&&f();const u=!r||o||l?i(0):at(r,s);return{x:c.left+s.scrollLeft-a.x-u.x,y:c.top+s.scrollTop-a.y-u.y,width:c.width,height:c.height}}function pt(t){return"static"===K(t).position}function mt(t,e){if(!N(t)||"fixed"===K(t).position)return null;if(e)return e(t);let n=t.offsetParent;return F(t)===n&&(n=n.ownerDocument.body),n}function gt(t,e){const n=P(t);if(I(t))return n;if(!N(t)){let e=U(t);for(;e&&!J(e);){if(B(e)&&!pt(e))return e;e=U(e)}return n}let o=mt(t,e);for(;o&&z(o)&&pt(o);)o=mt(o,e);return o&&J(o)&&pt(o)&&!X(o)?n:o||function(t){let e=U(t);for(;N(e)&&!J(e);){if(X(e))return e;if(I(e))return null;e=U(e)}return null}(t)||n}const yt={convertOffsetParentRelativeRectToViewportRelativeRect:function(t){let{elements:e,rect:n,offsetParent:o,strategy:r}=t;const l="fixed"===r,c=F(o),s=!!e&&I(e.floating);if(o===c||s&&l)return n;let a={scrollLeft:0,scrollTop:0},f=i(1);const u=i(0),h=N(o);if((h||!h&&!l)&&(("body"!==O(o)||M(c))&&(a=Q(o)),N(o))){const t=ct(o);f=it(o),u.x=t.x+o.clientLeft,u.y=t.y+o.clientTop}const d=!c||h||l?i(0):at(c,a);return{width:n.width*f.x,height:n.height*f.y,x:n.x*f.x-a.scrollLeft*f.x+u.x+d.x,y:n.y*f.y-a.scrollTop*f.y+u.y+d.y}},getDocumentElement:F,getClippingRect:function(n){let{element:o,boundary:i,rootBoundary:r,strategy:l}=n;const c=[..."clippingAncestors"===i?I(o)?[]:function(t,e){const n=e.get(t);if(n)return n;let o=tt(t,[],!1).filter(t=>B(t)&&"body"!==O(t)),i=null;const r="fixed"===K(t).position;let l=r?U(t):t;for(;B(l)&&!J(l);){const e=K(l),n=X(l);n||"fixed"!==e.position||(i=null),(r?!n&&!i:!n&&"static"===e.position&&i&&ft.has(i.position)||M(l)&&!n&&ht(t,l))?o=o.filter(t=>t!==l):i=e,l=U(l)}return e.set(t,o),o}(o,this._c):[].concat(i),r],s=c[0],a=c.reduce((n,i)=>{const r=ut(o,i,l);return n.top=e(r.top,n.top),n.right=t(r.right,n.right),n.bottom=t(r.bottom,n.bottom),n.left=e(r.left,n.left),n},ut(o,s,l));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}},getOffsetParent:gt,getElementRects:async function(t){const e=this.getOffsetParent||gt,n=this.getDimensions,o=await n(t.floating);return{reference:dt(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}},getClientRects:function(t){return Array.from(t.getClientRects())},getDimensions:function(t){const{width:e,height:n}=nt(t);return{width:e,height:n}},getScale:it,isElement:B,isRTL:function(t){return"rtl"===K(t).direction}};function wt(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function xt(n,i,r,l){void 0===l&&(l={});const{ancestorScroll:c=!0,ancestorResize:s=!0,elementResize:a="function"==typeof ResizeObserver,layoutShift:f="function"==typeof IntersectionObserver,animationFrame:u=!1}=l,h=ot(n),d=c||s?[...h?tt(h):[],...tt(i)]:[];d.forEach(t=>{c&&t.addEventListener("scroll",r,{passive:!0}),s&&t.addEventListener("resize",r)});const p=h&&f?function(n,i){let r,l=null;const c=F(n);function s(){var t;clearTimeout(r),null==(t=l)||t.disconnect(),l=null}return function a(f,u){void 0===f&&(f=!1),void 0===u&&(u=1),s();const h=n.getBoundingClientRect(),{left:d,top:p,width:m,height:g}=h;if(f||i(),!m||!g)return;const y={rootMargin:-o(p)+"px "+-o(c.clientWidth-(d+m))+"px "+-o(c.clientHeight-(p+g))+"px "+-o(d)+"px",threshold:e(0,t(1,u))||1};let w=!0;function x(t){const e=t[0].intersectionRatio;if(e!==u){if(!w)return a();e?a(!1,e):r=setTimeout(()=>{a(!1,1e-7)},1e3)}1!==e||wt(h,n.getBoundingClientRect())||a(),w=!1}try{l=new IntersectionObserver(x,{...y,root:c.ownerDocument})}catch(t){l=new IntersectionObserver(x,y)}l.observe(n)}(!0),s}(h,r):null;let m,g=-1,y=null;a&&(y=new ResizeObserver(t=>{let[e]=t;e&&e.target===h&&y&&(y.unobserve(i),cancelAnimationFrame(g),g=requestAnimationFrame(()=>{var t;null==(t=y)||t.observe(i)})),r()}),h&&!u&&y.observe(h),y.observe(i));let w=u?ct(n):null;return u&&function t(){const e=ct(n);w&&!wt(w,e)&&r();w=e,m=requestAnimationFrame(t)}(),r(),()=>{var t;d.forEach(t=>{c&&t.removeEventListener("scroll",r),s&&t.removeEventListener("resize",r)}),null==p||p(),null==(t=y)||t.disconnect(),y=null,u&&cancelAnimationFrame(m)}}const vt=function(t){return void 0===t&&(t=0),{name:"offset",options:t,async fn(e){var n,o;const{x:i,y:r,placement:l,middlewareData:c}=e,u=await async function(t,e){const{placement:n,platform:o,elements:i}=t,r=await(null==o.isRTL?void 0:o.isRTL(i.floating)),l=a(n),c=f(n),u="y"===p(n),h=C.has(l)?-1:1,d=r&&u?-1:1,m=s(e,t);let{mainAxis:g,crossAxis:y,alignmentAxis:w}="number"==typeof m?{mainAxis:m,crossAxis:0,alignmentAxis:null}:{mainAxis:m.mainAxis||0,crossAxis:m.crossAxis||0,alignmentAxis:m.alignmentAxis};return c&&"number"==typeof w&&(y="end"===c?-1*w:w),u?{x:y*d,y:g*h}:{x:g*h,y:y*d}}(e,t);return l===(null==(n=c.offset)?void 0:n.placement)&&null!=(o=c.arrow)&&o.alignmentOffset?{}:{x:i+u.x,y:r+u.y,data:{...u,placement:l}}}}},bt=function(t){return void 0===t&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:o,placement:i}=e,{mainAxis:r=!0,crossAxis:l=!1,limiter:f={fn:t=>{let{x:e,y:n}=t;return{x:e,y:n}}},...h}=s(t,e),d={x:n,y:o},m=await E(e,h),g=p(a(i)),y=u(g);let w=d[y],x=d[g];if(r){const t="y"===y?"bottom":"right";w=c(w+m["y"===y?"top":"left"],w,w-m[t])}if(l){const t="y"===g?"bottom":"right";x=c(x+m["y"===g?"top":"left"],x,x-m[t])}const v=f.fn({...e,[y]:w,[g]:x});return{...v,data:{x:v.x-n,y:v.y-o,enabled:{[y]:r,[g]:l}}}}}},Rt=function(t){return void 0===t&&(t={}),{name:"flip",options:t,async fn(e){var n,o;const{placement:i,middlewareData:r,rects:l,initialPlacement:c,platform:u,elements:d}=e,{mainAxis:y=!0,crossAxis:w=!0,fallbackPlacements:x,fallbackStrategy:v="bestFit",fallbackAxisSideDirection:L="none",flipAlignment:S=!0,...T}=s(t,e);if(null!=(n=r.arrow)&&n.alignmentOffset)return{};const A=a(i),C=p(c),D=a(c)===c,O=await(null==u.isRTL?void 0:u.isRTL(d.floating)),P=x||(D||!S?[R(c)]:function(t){const e=R(t);return[g(t),e,g(e)]}(c)),F="none"!==L;!x&&F&&P.push(...b(c,S,L,O));const k=[c,...P],B=await E(e,T),N=[];let W=(null==(o=r.flip)?void 0:o.overflows)||[];if(y&&N.push(B[A]),w){const t=function(t,e,n){void 0===n&&(n=!1);const o=f(t),i=m(t),r=h(i);let l="x"===i?o===(n?"end":"start")?"right":"left":"start"===o?"bottom":"top";return e.reference[r]>e.floating[r]&&(l=R(l)),[l,R(l)]}(i,l,O);N.push(B[t[0]],B[t[1]])}if(W=[...W,{placement:i,overflows:N}],!N.every(t=>t<=0)){var H,M;const t=((null==(H=r.flip)?void 0:H.index)||0)+1,e=k[t];if(e){if(!("alignment"===w&&C!==p(e))||W.every(t=>p(t.placement)!==C||t.overflows[0]>0))return{data:{index:t,overflows:W},reset:{placement:e}}}let n=null==(M=W.filter(t=>t.overflows[0]<=0).sort((t,e)=>t.overflows[1]-e.overflows[1])[0])?void 0:M.placement;if(!n)switch(v){case"bestFit":{var V;const t=null==(V=W.filter(t=>{if(F){const e=p(t.placement);return e===C||"y"===e}return!0}).map(t=>[t.placement,t.overflows.filter(t=>t>0).reduce((t,e)=>t+e,0)]).sort((t,e)=>t[1]-e[1])[0])?void 0:V[0];t&&(n=t);break}case"initialPlacement":n=c}if(i!==n)return{reset:{placement:n}}}return{}}}},Lt=function(n){return void 0===n&&(n={}),{name:"inline",options:n,async fn(o){const{placement:i,elements:r,rects:l,platform:c,strategy:f}=o,{padding:u=2,x:h,y:d}=s(n,o),m=Array.from(await(null==c.getClientRects?void 0:c.getClientRects(r.reference))||[]),g=function(t){const e=t.slice().sort((t,e)=>t.y-e.y),n=[];let o=null;for(let t=0;t<e.length;t++){const i=e[t];!o||i.y-o.y>o.height/2?n.push([i]):n[n.length-1].push(i),o=i}return n.map(t=>S(A(t)))}(m),y=S(A(m)),w=L(u);const x=await c.getElementRects({reference:{getBoundingClientRect:function(){if(2===g.length&&g[0].left>g[1].right&&null!=h&&null!=d)return g.find(t=>h>t.left-w.left&&h<t.right+w.right&&d>t.top-w.top&&d<t.bottom+w.bottom)||y;if(g.length>=2){if("y"===p(i)){const t=g[0],e=g[g.length-1],n="top"===a(i),o=t.top,r=e.bottom,l=n?t.left:e.left,c=n?t.right:e.right;return{top:o,bottom:r,left:l,right:c,width:c-l,height:r-o,x:l,y:o}}const n="left"===a(i),o=e(...g.map(t=>t.right)),r=t(...g.map(t=>t.left)),l=g.filter(t=>n?t.left===r:t.right===o),c=l[0].top,s=l[l.length-1].bottom;return{top:c,bottom:s,left:r,right:o,width:o-r,height:s-c,x:r,y:c}}return y}},floating:r.floating,strategy:f});return l.reference.x!==x.reference.x||l.reference.y!==x.reference.y||l.reference.width!==x.reference.width||l.reference.height!==x.reference.height?{reset:{rects:x}}:{}}}},St=(t,e,n)=>{const o=new Map,i={platform:yt,...n},r={...i.platform,_c:o};return(async(t,e,n)=>{const{placement:o="bottom",strategy:i="absolute",middleware:r=[],platform:l}=n,c=r.filter(Boolean),s=await(null==l.isRTL?void 0:l.isRTL(e));let a=await l.getElementRects({reference:t,floating:e,strategy:i}),{x:f,y:u}=T(a,o,s),h=o,d={},p=0;for(let n=0;n<c.length;n++){const{name:r,fn:m}=c[n],{x:g,y:y,data:w,reset:x}=await m({x:f,y:u,initialPlacement:o,placement:h,strategy:i,middlewareData:d,rects:a,platform:l,elements:{reference:t,floating:e}});f=null!=g?g:f,u=null!=y?y:u,d={...d,[r]:{...d[r],...w}},x&&p<=50&&(p++,"object"==typeof x&&(x.placement&&(h=x.placement),x.rects&&(a=!0===x.rects?await l.getElementRects({reference:t,floating:e,strategy:i}):x.rects),({x:f,y:u}=T(a,h,s))),n=-1)}return{x:f,y:u,placement:h,strategy:i,middlewareData:d}})(t,e,{...i,platform:r})};function Tt(t){return function(t){for(let e=t;e;e=Et(e))if(e instanceof Element&&"none"===getComputedStyle(e).display)return null;for(let e=Et(t);e;e=Et(e)){if(!(e instanceof Element))continue;const t=getComputedStyle(e);if("contents"!==t.display){if("static"!==t.position||X(t))return e;if("BODY"===e.tagName)return e}}return null}(t)}function Et(t){return t.assignedSlot?t.assignedSlot:t.parentNode instanceof ShadowRoot?t.parentNode.host:t.parentNode}async function At(t,e,n,o){async function i(){const i=new Array;n?.inline&&i.push(Lt()),n.flip&&i.push(!0===n.flip?Rt():Rt({fallbackPlacements:n.flip})),n.shift&&i.push(bt()),n.offset&&!isNaN(n.offset)&&i.push(vt(n.offset));const r=await St(e,t,{placement:n.position,middleware:i,platform:{...yt,getOffsetParent:t=>yt.getOffsetParent(t,Tt)}});o?o(r.x,r.y,r.placement):(t.style.left=`${r.x}px`,t.style.top=`${r.y}px`)}return await i(),xt(e,t,async()=>await i())}export{At as positionAnchor};
|
|
6
|
+
const t=Math.min,e=Math.max,n=Math.round,o=Math.floor,i=t=>({x:t,y:t}),r={left:"right",right:"left",bottom:"top",top:"bottom"},l={start:"end",end:"start"};function c(n,o,i){return e(n,t(o,i))}function s(t,e){return"function"==typeof t?t(e):t}function a(t){return t.split("-")[0]}function f(t){return t.split("-")[1]}function u(t){return"x"===t?"y":"x"}function h(t){return"y"===t?"height":"width"}const d=new Set(["top","bottom"]);function p(t){return d.has(a(t))?"y":"x"}function m(t){return u(p(t))}function g(t){return t.replace(/start|end/g,t=>l[t])}const y=["left","right"],w=["right","left"],x=["top","bottom"],v=["bottom","top"];function b(t,e,n,o){const i=f(t);let r=function(t,e,n){switch(t){case"top":case"bottom":return n?e?w:y:e?y:w;case"left":case"right":return e?x:v;default:return[]}}(a(t),"start"===n,o);return i&&(r=r.map(t=>t+"-"+i),e&&(r=r.concat(r.map(g)))),r}function R(t){return t.replace(/left|right|bottom|top/g,t=>r[t])}function L(t){return"number"!=typeof t?function(t){return{top:0,right:0,bottom:0,left:0,...t}}(t):{top:t,right:t,bottom:t,left:t}}function S(t){const{x:e,y:n,width:o,height:i}=t;return{width:o,height:i,top:n,left:e,right:e+o,bottom:n+i,x:e,y:n}}function T(t,e,n){let{reference:o,floating:i}=t;const r=p(e),l=m(e),c=h(l),s=a(e),u="y"===r,d=o.x+o.width/2-i.width/2,g=o.y+o.height/2-i.height/2,y=o[c]/2-i[c]/2;let w;switch(s){case"top":w={x:d,y:o.y-i.height};break;case"bottom":w={x:d,y:o.y+o.height};break;case"right":w={x:o.x+o.width,y:g};break;case"left":w={x:o.x-i.width,y:g};break;default:w={x:o.x,y:o.y}}switch(f(e)){case"start":w[l]-=y*(n&&u?-1:1);break;case"end":w[l]+=y*(n&&u?-1:1)}return w}async function E(t,e){var n;void 0===e&&(e={});const{x:o,y:i,platform:r,rects:l,elements:c,strategy:a}=t,{boundary:f="clippingAncestors",rootBoundary:u="viewport",elementContext:h="floating",altBoundary:d=!1,padding:p=0}=s(e,t),m=L(p),g=c[d?"floating"===h?"reference":"floating":h],y=S(await r.getClippingRect({element:null==(n=await(null==r.isElement?void 0:r.isElement(g)))||n?g:g.contextElement||await(null==r.getDocumentElement?void 0:r.getDocumentElement(c.floating)),boundary:f,rootBoundary:u,strategy:a})),w="floating"===h?{x:o,y:i,width:l.floating.width,height:l.floating.height}:l.reference,x=await(null==r.getOffsetParent?void 0:r.getOffsetParent(c.floating)),v=await(null==r.isElement?void 0:r.isElement(x))&&await(null==r.getScale?void 0:r.getScale(x))||{x:1,y:1},b=S(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:w,offsetParent:x,strategy:a}):w);return{top:(y.top-b.top+m.top)/v.y,bottom:(b.bottom-y.bottom+m.bottom)/v.y,left:(y.left-b.left+m.left)/v.x,right:(b.right-y.right+m.right)/v.x}}function A(n){const o=t(...n.map(t=>t.left)),i=t(...n.map(t=>t.top));return{x:o,y:i,width:e(...n.map(t=>t.right))-o,height:e(...n.map(t=>t.bottom))-i}}const C=new Set(["left","top"]);function D(){return"undefined"!=typeof window}function O(t){return k(t)?(t.nodeName||"").toLowerCase():"#document"}function P(t){var e;return(null==t||null==(e=t.ownerDocument)?void 0:e.defaultView)||window}function F(t){var e;return null==(e=(k(t)?t.ownerDocument:t.document)||window.document)?void 0:e.documentElement}function k(t){return!!D()&&(t instanceof Node||t instanceof P(t).Node)}function B(t){return!!D()&&(t instanceof Element||t instanceof P(t).Element)}function N(t){return!!D()&&(t instanceof HTMLElement||t instanceof P(t).HTMLElement)}function W(t){return!(!D()||"undefined"==typeof ShadowRoot)&&(t instanceof ShadowRoot||t instanceof P(t).ShadowRoot)}const H=new Set(["inline","contents"]);function M(t){const{overflow:e,overflowX:n,overflowY:o,display:i}=K(t);return/auto|scroll|overlay|hidden|clip/.test(e+o+n)&&!H.has(i)}const V=new Set(["table","td","th"]);function z(t){return V.has(O(t))}const I=[":popover-open",":modal"];function Y(t){return I.some(e=>{try{return t.matches(e)}catch(t){return!1}})}const j=["transform","translate","scale","rotate","perspective"],q=["transform","translate","scale","rotate","perspective","filter"],X=["paint","layout","strict","content"];function $(t){const e=_(),n=B(t)?K(t):t;return j.some(t=>!!n[t]&&"none"!==n[t])||!!n.containerType&&"normal"!==n.containerType||!e&&!!n.backdropFilter&&"none"!==n.backdropFilter||!e&&!!n.filter&&"none"!==n.filter||q.some(t=>(n.willChange||"").includes(t))||X.some(t=>(n.contain||"").includes(t))}function _(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}const G=new Set(["html","body","#document"]);function J(t){return G.has(O(t))}function K(t){return P(t).getComputedStyle(t)}function Q(t){return B(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function U(t){if("html"===O(t))return t;const e=t.assignedSlot||t.parentNode||W(t)&&t.host||F(t);return W(e)?e.host:e}function Z(t){const e=U(t);return J(e)?t.ownerDocument?t.ownerDocument.body:t.body:N(e)&&M(e)?e:Z(e)}function tt(t,e,n){var o;void 0===e&&(e=[]),void 0===n&&(n=!0);const i=Z(t),r=i===(null==(o=t.ownerDocument)?void 0:o.body),l=P(i);if(r){const t=et(l);return e.concat(l,l.visualViewport||[],M(i)?i:[],t&&n?tt(t):[])}return e.concat(i,tt(i,[],n))}function et(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function nt(t){const e=K(t);let o=parseFloat(e.width)||0,i=parseFloat(e.height)||0;const r=N(t),l=r?t.offsetWidth:o,c=r?t.offsetHeight:i,s=n(o)!==l||n(i)!==c;return s&&(o=l,i=c),{width:o,height:i,$:s}}function ot(t){return B(t)?t:t.contextElement}function it(t){const e=ot(t);if(!N(e))return i(1);const o=e.getBoundingClientRect(),{width:r,height:l,$:c}=nt(e);let s=(c?n(o.width):o.width)/r,a=(c?n(o.height):o.height)/l;return s&&Number.isFinite(s)||(s=1),a&&Number.isFinite(a)||(a=1),{x:s,y:a}}const rt=i(0);function lt(t){const e=P(t);return _()&&e.visualViewport?{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}:rt}function ct(t,e,n,o){void 0===e&&(e=!1),void 0===n&&(n=!1);const r=t.getBoundingClientRect(),l=ot(t);let c=i(1);e&&(o?B(o)&&(c=it(o)):c=it(t));const s=function(t,e,n){return void 0===e&&(e=!1),!(!n||e&&n!==P(t))&&e}(l,n,o)?lt(l):i(0);let a=(r.left+s.x)/c.x,f=(r.top+s.y)/c.y,u=r.width/c.x,h=r.height/c.y;if(l){const t=P(l),e=o&&B(o)?P(o):o;let n=t,i=et(n);for(;i&&o&&e!==n;){const t=it(i),e=i.getBoundingClientRect(),o=K(i),r=e.left+(i.clientLeft+parseFloat(o.paddingLeft))*t.x,l=e.top+(i.clientTop+parseFloat(o.paddingTop))*t.y;a*=t.x,f*=t.y,u*=t.x,h*=t.y,a+=r,f+=l,n=P(i),i=et(n)}}return S({width:u,height:h,x:a,y:f})}function st(t,e){const n=Q(t).scrollLeft;return e?e.left+n:ct(F(t)).left+n}function at(t,e){const n=t.getBoundingClientRect();return{x:n.left+e.scrollLeft-st(t,n),y:n.top+e.scrollTop}}const ft=new Set(["absolute","fixed"]);function ut(t,n,o){let r;if("viewport"===n)r=function(t,e){const n=P(t),o=F(t),i=n.visualViewport;let r=o.clientWidth,l=o.clientHeight,c=0,s=0;if(i){r=i.width,l=i.height;const t=_();(!t||t&&"fixed"===e)&&(c=i.offsetLeft,s=i.offsetTop)}const a=st(o);if(a<=0){const t=o.ownerDocument,e=t.body,n=getComputedStyle(e),i="CSS1Compat"===t.compatMode&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,l=Math.abs(o.clientWidth-e.clientWidth-i);l<=25&&(r-=l)}else a<=25&&(r+=a);return{width:r,height:l,x:c,y:s}}(t,o);else if("document"===n)r=function(t){const n=F(t),o=Q(t),i=t.ownerDocument.body,r=e(n.scrollWidth,n.clientWidth,i.scrollWidth,i.clientWidth),l=e(n.scrollHeight,n.clientHeight,i.scrollHeight,i.clientHeight);let c=-o.scrollLeft+st(t);const s=-o.scrollTop;return"rtl"===K(i).direction&&(c+=e(n.clientWidth,i.clientWidth)-r),{width:r,height:l,x:c,y:s}}(F(t));else if(B(n))r=function(t,e){const n=ct(t,!0,"fixed"===e),o=n.top+t.clientTop,r=n.left+t.clientLeft,l=N(t)?it(t):i(1);return{width:t.clientWidth*l.x,height:t.clientHeight*l.y,x:r*l.x,y:o*l.y}}(n,o);else{const e=lt(t);r={x:n.x-e.x,y:n.y-e.y,width:n.width,height:n.height}}return S(r)}function ht(t,e){const n=U(t);return!(n===e||!B(n)||J(n))&&("fixed"===K(n).position||ht(n,e))}function dt(t,e,n){const o=N(e),r=F(e),l="fixed"===n,c=ct(t,!0,l,e);let s={scrollLeft:0,scrollTop:0};const a=i(0);function f(){a.x=st(r)}if(o||!o&&!l)if(("body"!==O(e)||M(r))&&(s=Q(e)),o){const t=ct(e,!0,l,e);a.x=t.x+e.clientLeft,a.y=t.y+e.clientTop}else r&&f();l&&!o&&r&&f();const u=!r||o||l?i(0):at(r,s);return{x:c.left+s.scrollLeft-a.x-u.x,y:c.top+s.scrollTop-a.y-u.y,width:c.width,height:c.height}}function pt(t){return"static"===K(t).position}function mt(t,e){if(!N(t)||"fixed"===K(t).position)return null;if(e)return e(t);let n=t.offsetParent;return F(t)===n&&(n=n.ownerDocument.body),n}function gt(t,e){const n=P(t);if(Y(t))return n;if(!N(t)){let e=U(t);for(;e&&!J(e);){if(B(e)&&!pt(e))return e;e=U(e)}return n}let o=mt(t,e);for(;o&&z(o)&&pt(o);)o=mt(o,e);return o&&J(o)&&pt(o)&&!$(o)?n:o||function(t){let e=U(t);for(;N(e)&&!J(e);){if($(e))return e;if(Y(e))return null;e=U(e)}return null}(t)||n}const yt={convertOffsetParentRelativeRectToViewportRelativeRect:function(t){let{elements:e,rect:n,offsetParent:o,strategy:r}=t;const l="fixed"===r,c=F(o),s=!!e&&Y(e.floating);if(o===c||s&&l)return n;let a={scrollLeft:0,scrollTop:0},f=i(1);const u=i(0),h=N(o);if((h||!h&&!l)&&(("body"!==O(o)||M(c))&&(a=Q(o)),N(o))){const t=ct(o);f=it(o),u.x=t.x+o.clientLeft,u.y=t.y+o.clientTop}const d=!c||h||l?i(0):at(c,a);return{width:n.width*f.x,height:n.height*f.y,x:n.x*f.x-a.scrollLeft*f.x+u.x+d.x,y:n.y*f.y-a.scrollTop*f.y+u.y+d.y}},getDocumentElement:F,getClippingRect:function(n){let{element:o,boundary:i,rootBoundary:r,strategy:l}=n;const c=[..."clippingAncestors"===i?Y(o)?[]:function(t,e){const n=e.get(t);if(n)return n;let o=tt(t,[],!1).filter(t=>B(t)&&"body"!==O(t)),i=null;const r="fixed"===K(t).position;let l=r?U(t):t;for(;B(l)&&!J(l);){const e=K(l),n=$(l);n||"fixed"!==e.position||(i=null),(r?!n&&!i:!n&&"static"===e.position&&i&&ft.has(i.position)||M(l)&&!n&&ht(t,l))?o=o.filter(t=>t!==l):i=e,l=U(l)}return e.set(t,o),o}(o,this._c):[].concat(i),r],s=c[0],a=c.reduce((n,i)=>{const r=ut(o,i,l);return n.top=e(r.top,n.top),n.right=t(r.right,n.right),n.bottom=t(r.bottom,n.bottom),n.left=e(r.left,n.left),n},ut(o,s,l));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}},getOffsetParent:gt,getElementRects:async function(t){const e=this.getOffsetParent||gt,n=this.getDimensions,o=await n(t.floating);return{reference:dt(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}},getClientRects:function(t){return Array.from(t.getClientRects())},getDimensions:function(t){const{width:e,height:n}=nt(t);return{width:e,height:n}},getScale:it,isElement:B,isRTL:function(t){return"rtl"===K(t).direction}};function wt(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function xt(n,i,r,l){void 0===l&&(l={});const{ancestorScroll:c=!0,ancestorResize:s=!0,elementResize:a="function"==typeof ResizeObserver,layoutShift:f="function"==typeof IntersectionObserver,animationFrame:u=!1}=l,h=ot(n),d=c||s?[...h?tt(h):[],...tt(i)]:[];d.forEach(t=>{c&&t.addEventListener("scroll",r,{passive:!0}),s&&t.addEventListener("resize",r)});const p=h&&f?function(n,i){let r,l=null;const c=F(n);function s(){var t;clearTimeout(r),null==(t=l)||t.disconnect(),l=null}return function a(f,u){void 0===f&&(f=!1),void 0===u&&(u=1),s();const h=n.getBoundingClientRect(),{left:d,top:p,width:m,height:g}=h;if(f||i(),!m||!g)return;const y={rootMargin:-o(p)+"px "+-o(c.clientWidth-(d+m))+"px "+-o(c.clientHeight-(p+g))+"px "+-o(d)+"px",threshold:e(0,t(1,u))||1};let w=!0;function x(t){const e=t[0].intersectionRatio;if(e!==u){if(!w)return a();e?a(!1,e):r=setTimeout(()=>{a(!1,1e-7)},1e3)}1!==e||wt(h,n.getBoundingClientRect())||a(),w=!1}try{l=new IntersectionObserver(x,{...y,root:c.ownerDocument})}catch(t){l=new IntersectionObserver(x,y)}l.observe(n)}(!0),s}(h,r):null;let m,g=-1,y=null;a&&(y=new ResizeObserver(t=>{let[e]=t;e&&e.target===h&&y&&(y.unobserve(i),cancelAnimationFrame(g),g=requestAnimationFrame(()=>{var t;null==(t=y)||t.observe(i)})),r()}),h&&!u&&y.observe(h),y.observe(i));let w=u?ct(n):null;return u&&function t(){const e=ct(n);w&&!wt(w,e)&&r();w=e,m=requestAnimationFrame(t)}(),r(),()=>{var t;d.forEach(t=>{c&&t.removeEventListener("scroll",r),s&&t.removeEventListener("resize",r)}),null==p||p(),null==(t=y)||t.disconnect(),y=null,u&&cancelAnimationFrame(m)}}const vt=function(t){return void 0===t&&(t=0),{name:"offset",options:t,async fn(e){var n,o;const{x:i,y:r,placement:l,middlewareData:c}=e,u=await async function(t,e){const{placement:n,platform:o,elements:i}=t,r=await(null==o.isRTL?void 0:o.isRTL(i.floating)),l=a(n),c=f(n),u="y"===p(n),h=C.has(l)?-1:1,d=r&&u?-1:1,m=s(e,t);let{mainAxis:g,crossAxis:y,alignmentAxis:w}="number"==typeof m?{mainAxis:m,crossAxis:0,alignmentAxis:null}:{mainAxis:m.mainAxis||0,crossAxis:m.crossAxis||0,alignmentAxis:m.alignmentAxis};return c&&"number"==typeof w&&(y="end"===c?-1*w:w),u?{x:y*d,y:g*h}:{x:g*h,y:y*d}}(e,t);return l===(null==(n=c.offset)?void 0:n.placement)&&null!=(o=c.arrow)&&o.alignmentOffset?{}:{x:i+u.x,y:r+u.y,data:{...u,placement:l}}}}},bt=function(t){return void 0===t&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:o,placement:i}=e,{mainAxis:r=!0,crossAxis:l=!1,limiter:f={fn:t=>{let{x:e,y:n}=t;return{x:e,y:n}}},...h}=s(t,e),d={x:n,y:o},m=await E(e,h),g=p(a(i)),y=u(g);let w=d[y],x=d[g];if(r){const t="y"===y?"bottom":"right";w=c(w+m["y"===y?"top":"left"],w,w-m[t])}if(l){const t="y"===g?"bottom":"right";x=c(x+m["y"===g?"top":"left"],x,x-m[t])}const v=f.fn({...e,[y]:w,[g]:x});return{...v,data:{x:v.x-n,y:v.y-o,enabled:{[y]:r,[g]:l}}}}}},Rt=function(t){return void 0===t&&(t={}),{name:"flip",options:t,async fn(e){var n,o;const{placement:i,middlewareData:r,rects:l,initialPlacement:c,platform:u,elements:d}=e,{mainAxis:y=!0,crossAxis:w=!0,fallbackPlacements:x,fallbackStrategy:v="bestFit",fallbackAxisSideDirection:L="none",flipAlignment:S=!0,...T}=s(t,e);if(null!=(n=r.arrow)&&n.alignmentOffset)return{};const A=a(i),C=p(c),D=a(c)===c,O=await(null==u.isRTL?void 0:u.isRTL(d.floating)),P=x||(D||!S?[R(c)]:function(t){const e=R(t);return[g(t),e,g(e)]}(c)),F="none"!==L;!x&&F&&P.push(...b(c,S,L,O));const k=[c,...P],B=await E(e,T),N=[];let W=(null==(o=r.flip)?void 0:o.overflows)||[];if(y&&N.push(B[A]),w){const t=function(t,e,n){void 0===n&&(n=!1);const o=f(t),i=m(t),r=h(i);let l="x"===i?o===(n?"end":"start")?"right":"left":"start"===o?"bottom":"top";return e.reference[r]>e.floating[r]&&(l=R(l)),[l,R(l)]}(i,l,O);N.push(B[t[0]],B[t[1]])}if(W=[...W,{placement:i,overflows:N}],!N.every(t=>t<=0)){var H,M;const t=((null==(H=r.flip)?void 0:H.index)||0)+1,e=k[t];if(e){if(!("alignment"===w&&C!==p(e))||W.every(t=>p(t.placement)!==C||t.overflows[0]>0))return{data:{index:t,overflows:W},reset:{placement:e}}}let n=null==(M=W.filter(t=>t.overflows[0]<=0).sort((t,e)=>t.overflows[1]-e.overflows[1])[0])?void 0:M.placement;if(!n)switch(v){case"bestFit":{var V;const t=null==(V=W.filter(t=>{if(F){const e=p(t.placement);return e===C||"y"===e}return!0}).map(t=>[t.placement,t.overflows.filter(t=>t>0).reduce((t,e)=>t+e,0)]).sort((t,e)=>t[1]-e[1])[0])?void 0:V[0];t&&(n=t);break}case"initialPlacement":n=c}if(i!==n)return{reset:{placement:n}}}return{}}}},Lt=function(n){return void 0===n&&(n={}),{name:"inline",options:n,async fn(o){const{placement:i,elements:r,rects:l,platform:c,strategy:f}=o,{padding:u=2,x:h,y:d}=s(n,o),m=Array.from(await(null==c.getClientRects?void 0:c.getClientRects(r.reference))||[]),g=function(t){const e=t.slice().sort((t,e)=>t.y-e.y),n=[];let o=null;for(let t=0;t<e.length;t++){const i=e[t];!o||i.y-o.y>o.height/2?n.push([i]):n[n.length-1].push(i),o=i}return n.map(t=>S(A(t)))}(m),y=S(A(m)),w=L(u);const x=await c.getElementRects({reference:{getBoundingClientRect:function(){if(2===g.length&&g[0].left>g[1].right&&null!=h&&null!=d)return g.find(t=>h>t.left-w.left&&h<t.right+w.right&&d>t.top-w.top&&d<t.bottom+w.bottom)||y;if(g.length>=2){if("y"===p(i)){const t=g[0],e=g[g.length-1],n="top"===a(i),o=t.top,r=e.bottom,l=n?t.left:e.left,c=n?t.right:e.right;return{top:o,bottom:r,left:l,right:c,width:c-l,height:r-o,x:l,y:o}}const n="left"===a(i),o=e(...g.map(t=>t.right)),r=t(...g.map(t=>t.left)),l=g.filter(t=>n?t.left===r:t.right===o),c=l[0].top,s=l[l.length-1].bottom;return{top:c,bottom:s,left:r,right:o,width:o-r,height:s-c,x:r,y:c}}return y}},floating:r.floating,strategy:f});return l.reference.x!==x.reference.x||l.reference.y!==x.reference.y||l.reference.width!==x.reference.width||l.reference.height!==x.reference.height?{reset:{rects:x}}:{}}}},St=(t,e,n)=>{const o=new Map,i={platform:yt,...n},r={...i.platform,_c:o};return(async(t,e,n)=>{const{placement:o="bottom",strategy:i="absolute",middleware:r=[],platform:l}=n,c=r.filter(Boolean),s=await(null==l.isRTL?void 0:l.isRTL(e));let a=await l.getElementRects({reference:t,floating:e,strategy:i}),{x:f,y:u}=T(a,o,s),h=o,d={},p=0;for(let n=0;n<c.length;n++){const{name:r,fn:m}=c[n],{x:g,y:y,data:w,reset:x}=await m({x:f,y:u,initialPlacement:o,placement:h,strategy:i,middlewareData:d,rects:a,platform:l,elements:{reference:t,floating:e}});f=null!=g?g:f,u=null!=y?y:u,d={...d,[r]:{...d[r],...w}},x&&p<=50&&(p++,"object"==typeof x&&(x.placement&&(h=x.placement),x.rects&&(a=!0===x.rects?await l.getElementRects({reference:t,floating:e,strategy:i}):x.rects),({x:f,y:u}=T(a,h,s))),n=-1)}return{x:f,y:u,placement:h,strategy:i,middlewareData:d}})(t,e,{...i,platform:r})};function Tt(t){return function(t){for(let e=t;e;e=Et(e))if(e instanceof Element&&"none"===getComputedStyle(e).display)return null;for(let e=Et(t);e;e=Et(e)){if(!(e instanceof Element))continue;const t=getComputedStyle(e);if("contents"!==t.display){if("static"!==t.position||$(t))return e;if("BODY"===e.tagName)return e}}return null}(t)}function Et(t){return t.assignedSlot?t.assignedSlot:t.parentNode instanceof ShadowRoot?t.parentNode.host:t.parentNode}async function At(t,e,n,o){async function i(){const i=new Array;n?.inline&&i.push(Lt()),n.flip&&i.push(!0===n.flip?Rt():Rt({fallbackPlacements:n.flip})),n.shift&&i.push(bt()),n.offset&&!isNaN(n.offset)&&i.push(vt(n.offset));const r=await St(e,t,{placement:n.position,middleware:i,platform:{...yt,getOffsetParent:t=>yt.getOffsetParent(t,Tt)}});o(r.x,r.y,r.placement)}return await i(),xt(e,t,async()=>await i())}export{At as positionAnchor};
|
|
7
7
|
//# sourceMappingURL=anchoring.min.js.map
|