@viasat/beam-shared 2.10.1 → 2.10.2
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const et=["top","right","bottom","left"],K=["start","end"],N=et.reduce((t,e)=>t.concat(e,e+"-"+K[0],e+"-"+K[1]),[]),W=Math.min,ft=Math.max,ut={left:"right",right:"left",bottom:"top",top:"bottom"},dt={start:"end",end:"start"};function Y(t,e,s){return ft(t,W(e,s))}function H(t,e){return typeof t=="function"?t(e):t}function C(t){return t.split("-")[0]}function M(t){return t.split("-")[1]}function q(t){return t==="x"?"y":"x"}function nt(t){return t==="y"?"height":"width"}function V(t){return["top","bottom"].includes(C(t))?"y":"x"}function ot(t){return q(V(t))}function it(t,e,s){s===void 0&&(s=!1);const r=M(t),i=ot(t),n=nt(i);let o=i==="x"?r===(s?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[n]>e.floating[n]&&(o=_(o)),[o,_(o)]}function mt(t){const e=_(t);return[X(t),e,X(e)]}function X(t){return t.replace(/start|end/g,e=>dt[e])}function gt(t,e,s){const r=["left","right"],i=["right","left"],n=["top","bottom"],o=["bottom","top"];switch(t){case"top":case"bottom":return s?e?i:r:e?r:i;case"left":case"right":return e?n:o;default:return[]}}function pt(t,e,s,r){const i=M(t);let n=gt(C(t),s==="start",r);return i&&(n=n.map(o=>o+"-"+i),e&&(n=n.concat(n.map(X)))),n}function _(t){return t.replace(/left|right|bottom|top/g,e=>ut[e])}function xt(t){return{top:0,right:0,bottom:0,left:0,...t}}function st(t){return typeof t!="number"?xt(t):{top:t,right:t,bottom:t,left:t}}function Q(t){const{x:e,y:s,width:r,height:i}=t;return{width:r,height:i,top:s,left:e,right:e+r,bottom:s+i,x:e,y:s}}async function I(t,e){var s;e===void 0&&(e={});const{x:r,y:i,platform:n,rects:o,elements:c,strategy:u}=t,{boundary:w="clippingAncestors",rootBoundary:p="viewport",elementContext:l="floating",altBoundary:d=!1,padding:a=0}=H(e,t),m=st(a),f=c[d?l==="floating"?"reference":"floating":l],g=Q(await n.getClippingRect({element:(s=await(n.isElement==null?void 0:n.isElement(f)))==null||s?f:f.contextElement||await(n.getDocumentElement==null?void 0:n.getDocumentElement(c.floating)),boundary:w,rootBoundary:p,strategy:u})),h=l==="floating"?{x:r,y:i,width:o.floating.width,height:o.floating.height}:o.reference,y=await(n.getOffsetParent==null?void 0:n.getOffsetParent(c.floating)),A=await(n.isElement==null?void 0:n.isElement(y))?await(n.getScale==null?void 0:n.getScale(y))||{x:1,y:1}:{x:1,y:1},b=Q(n.convertOffsetParentRelativeRectToViewportRelativeRect?await n.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:h,offsetParent:y,strategy:u}):h);return{top:(g.top-b.top+m.top)/A.y,bottom:(b.bottom-g.bottom+m.bottom)/A.y,left:(g.left-b.left+m.left)/A.x,right:(b.right-g.right+m.right)/A.x}}function ht(t,e,s){return(t?[...s.filter(i=>M(i)===t),...s.filter(i=>M(i)!==t)]:s.filter(i=>C(i)===i)).filter(i=>t?M(i)===t||(e?X(i)!==i:!1):!0)}const wt=function(t){return t===void 0&&(t={}),{name:"autoPlacement",options:t,async fn(e){var s,r,i;const{rects:n,middlewareData:o,placement:c,platform:u,elements:w}=e,{crossAxis:p=!1,alignment:l,allowedPlacements:d=N,autoAlignment:a=!0,...m}=H(t,e),v=l!==void 0||d===N?ht(l||null,a,d):d,f=await I(e,m),g=((s=o.autoPlacement)==null?void 0:s.index)||0,h=v[g];if(h==null)return{};const y=it(h,n,await(u.isRTL==null?void 0:u.isRTL(w.floating)));if(c!==h)return{reset:{placement:v[0]}};const A=[f[C(h)],f[y[0]],f[y[1]]],b=[...((r=o.autoPlacement)==null?void 0:r.overflows)||[],{placement:h,overflows:A}],j=v[g+1];if(j)return{data:{index:g+1,overflows:b},reset:{placement:j}};const F=b.map(x=>{const P=M(x.placement);return[x.placement,P&&p?x.overflows.slice(0,2).reduce((B,T)=>B+T,0):x.overflows[0],x.overflows]}).sort((x,P)=>x[1]-P[1]),D=((i=F.filter(x=>x[2].slice(0,M(x[0])?2:3).every(P=>P<=0))[0])==null?void 0:i[0])||F[0][0];return D!==c?{data:{index:g+1,overflows:b},reset:{placement:D}}:{}}}},vt=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var s,r;const{placement:i,middlewareData:n,rects:o,initialPlacement:c,platform:u,elements:w}=e,{mainAxis:p=!0,crossAxis:l=!0,fallbackPlacements:d,fallbackStrategy:a="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:v=!0,...f}=H(t,e);if((s=n.arrow)!=null&&s.alignmentOffset)return{};const g=C(i),h=V(c),y=C(c)===c,A=await(u.isRTL==null?void 0:u.isRTL(w.floating)),b=d||(y||!v?[_(c)]:mt(c)),j=m!=="none";!d&&j&&b.push(...pt(c,v,m,A));const F=[c,...b],S=await I(e,f),D=[];let x=((r=n.flip)==null?void 0:r.overflows)||[];if(p&&D.push(S[g]),l){const R=it(i,o,A);D.push(S[R[0]],S[R[1]])}if(x=[...x,{placement:i,overflows:D}],!D.every(R=>R<=0)){var P,B;const R=(((P=n.flip)==null?void 0:P.index)||0)+1,E=F[R];if(E)return{data:{index:R,overflows:x},reset:{placement:E}};let L=(B=x.filter(k=>k.overflows[0]<=0).sort((k,$)=>k.overflows[1]-$.overflows[1])[0])==null?void 0:B.placement;if(!L)switch(a){case"bestFit":{var T;const k=(T=x.filter($=>{if(j){const O=V($.placement);return O===h||O==="y"}return!0}).map($=>[$.placement,$.overflows.filter(O=>O>0).reduce((O,z)=>O+z,0)]).sort(($,O)=>$[1]-O[1])[0])==null?void 0:T[0];k&&(L=k);break}case"initialPlacement":L=c;break}if(i!==L)return{reset:{placement:L}}}return{}}}};function Z(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function tt(t){return et.some(e=>t[e]>=0)}const yt=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:s}=e,{strategy:r="referenceHidden",...i}=H(t,e);switch(r){case"referenceHidden":{const n=await I(e,{...i,elementContext:"reference"}),o=Z(n,s.reference);return{data:{referenceHiddenOffsets:o,referenceHidden:tt(o)}}}case"escaped":{const n=await I(e,{...i,altBoundary:!0}),o=Z(n,s.floating);return{data:{escapedOffsets:o,escaped:tt(o)}}}default:return{}}}}};async function bt(t,e){const{placement:s,platform:r,elements:i}=t,n=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=C(s),c=M(s),u=V(s)==="y",w=["left","top"].includes(o)?-1:1,p=n&&u?-1:1,l=H(e,t);let{mainAxis:d,crossAxis:a,alignmentAxis:m}=typeof l=="number"?{mainAxis:l,crossAxis:0,alignmentAxis:null}:{mainAxis:l.mainAxis||0,crossAxis:l.crossAxis||0,alignmentAxis:l.alignmentAxis};return c&&typeof m=="number"&&(a=c==="end"?m*-1:m),u?{x:a*p,y:d*w}:{x:d*w,y:a*p}}const At=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var s,r;const{x:i,y:n,placement:o,middlewareData:c}=e,u=await bt(e,t);return o===((s=c.offset)==null?void 0:s.placement)&&(r=c.arrow)!=null&&r.alignmentOffset?{}:{x:i+u.x,y:n+u.y,data:{...u,placement:o}}}}},Pt=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:s,y:r,placement:i}=e,{mainAxis:n=!0,crossAxis:o=!1,limiter:c={fn:f=>{let{x:g,y:h}=f;return{x:g,y:h}}},...u}=H(t,e),w={x:s,y:r},p=await I(e,u),l=V(C(i)),d=q(l);let a=w[d],m=w[l];if(n){const f=d==="y"?"top":"left",g=d==="y"?"bottom":"right",h=a+p[f],y=a-p[g];a=Y(h,a,y)}if(o){const f=l==="y"?"top":"left",g=l==="y"?"bottom":"right",h=m+p[f],y=m-p[g];m=Y(h,m,y)}const v=c.fn({...e,[d]:a,[l]:m});return{...v,data:{x:v.x-s,y:v.y-r,enabled:{[d]:n,[l]:o}}}}}},Ot=At,St=wt,Rt=Pt,$t=vt,Ct=yt,Dt=t=>{var e;return{visibility:(e=t.hide)!=null&&e.referenceHidden?"hidden":"visible"}},rt=t=>({name:"arrowStyles",options:t,async fn(e){var G,J;const{x:s,y:r,placement:i,rects:n,platform:o,elements:c,middlewareData:u}=e,{element:w,padding:p=0}=H(t,e)||{};if(w==null)return{};const l=st(p),d={x:s,y:r},a=ot(i),m=q(a),v=nt(a),f=await o.getDimensions(w),g=a==="y",h=g?"top":"left",y=g?"bottom":"right",A=g?"clientHeight":"clientWidth",b=n.reference[v]+n.reference[a]-d[a]-n.floating[v],j=d[a]-n.reference[a],F=await((G=o.getOffsetParent)==null?void 0:G.call(o,w));let S=F?F[A]:0;(!S||!await((J=o.isElement)==null?void 0:J.call(o,F)))&&(S=c.floating[A]||n.floating[v]);const D=b/2-j/2,x=S/2-f.width/2-1,P=W(l[h],x),B=W(l[y],x),T=P,R=S-f.width-B,E=S/2-f.width/2+D,L=Y(T,E,R),k=!u.arrow&&M(i)!=null&&E!==L&&n.reference[v]/2-(E<T?P:B)-f.width/2<0,$=k?E<T?E-T:E-R:0,O=C(i),z=["top","left"].includes(O)?-1:1,lt=f.height*z,at=ct({placement:O,arrowHeight:f.height,arrowWidth:f.width,[a]:L});return{[a]:d[a]+$,[m]:d[m]+lt,data:at,reset:k}}}),U=(t,e,s,r)=>{if(r){const i=r===!0?s():s(r);t[e](i)}},Tt=({baseConfig:t,middleware:e,offset:s,arrow:r,placement:i="top"})=>{const n={...t,placement:i};let o=[];if(typeof e.overrides!="object"){o.push(Ot(s));let c=e.flip??!0;e.autoPlacement&&(c=!1),U(o,"unshift",St,e.autoPlacement),U(o,"push",Rt,e.shift??!0),U(o,"unshift",$t,c),U(o,"push",Ct,e.hide??!0)}else o.push(...e.overrides);return r.hide||o.push(rt(r.options)),typeof e.overrides=="function"&&(o=e.overrides(o)),n.middleware=o,n},ct=({placement:t,arrowHeight:e,arrowWidth:s,x:r,y:i})=>{const n=C(t),o=s/2-e,c={top:"rotate(0deg)",bottom:"rotate(180deg)",left:`rotate(-90deg) translateX(${-o}px)`,right:`rotate(90deg) translateX(${o}px)`}[n],u=-s/2-e,w={top:`${-e}px`,bottom:`${-e*2}px`,left:`${u}px`,right:`${u}px`}[n],p={transform:c};p.left=r!=null?`${r}px`:"",p.top=i!=null?`${i}px`:"";const l=_(n);return p[l]=w,p};exports.arrowMiddleware=rt;exports.arrowStyles=ct;exports.buildFloatingUIConfig=Tt;exports.visibilityHandler=Dt;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const nt=["top","right","bottom","left"],K=["start","end"],Q=nt.reduce((t,e)=>t.concat(e,e+"-"+K[0],e+"-"+K[1]),[]),I=Math.min,B=Math.max,dt={left:"right",right:"left",bottom:"top",top:"bottom"},ut={start:"end",end:"start"};function G(t,e,s){return B(t,I(e,s))}function z(t,e){return typeof t=="function"?t(e):t}function C(t){return t.split("-")[0]}function k(t){return t.split("-")[1]}function N(t){return t==="x"?"y":"x"}function it(t){return t==="y"?"height":"width"}function _(t){return["top","bottom"].includes(C(t))?"y":"x"}function ot(t){return N(_(t))}function st(t,e,s){s===void 0&&(s=!1);const r=k(t),o=ot(t),n=it(o);let i=o==="x"?r===(s?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[n]>e.floating[n]&&(i=W(i)),[i,W(i)]}function mt(t){const e=W(t);return[X(t),e,X(e)]}function X(t){return t.replace(/start|end/g,e=>ut[e])}function gt(t,e,s){const r=["left","right"],o=["right","left"],n=["top","bottom"],i=["bottom","top"];switch(t){case"top":case"bottom":return s?e?o:r:e?r:o;case"left":case"right":return e?n:i;default:return[]}}function pt(t,e,s,r){const o=k(t);let n=gt(C(t),s==="start",r);return o&&(n=n.map(i=>i+"-"+o),e&&(n=n.concat(n.map(X)))),n}function W(t){return t.replace(/left|right|bottom|top/g,e=>dt[e])}function ht(t){return{top:0,right:0,bottom:0,left:0,...t}}function rt(t){return typeof t!="number"?ht(t):{top:t,right:t,bottom:t,left:t}}function Z(t){const{x:e,y:s,width:r,height:o}=t;return{width:r,height:o,top:s,left:e,right:e+r,bottom:s+o,x:e,y:s}}async function V(t,e){var s;e===void 0&&(e={});const{x:r,y:o,platform:n,rects:i,elements:l,strategy:m}=t,{boundary:x="clippingAncestors",rootBoundary:c="viewport",elementContext:a="floating",altBoundary:g=!1,padding:f=0}=z(e,t),d=rt(f),u=l[g?a==="floating"?"reference":"floating":a],p=Z(await n.getClippingRect({element:(s=await(n.isElement==null?void 0:n.isElement(u)))==null||s?u:u.contextElement||await(n.getDocumentElement==null?void 0:n.getDocumentElement(l.floating)),boundary:x,rootBoundary:c,strategy:m})),v=a==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,y=await(n.getOffsetParent==null?void 0:n.getOffsetParent(l.floating)),A=await(n.isElement==null?void 0:n.isElement(y))?await(n.getScale==null?void 0:n.getScale(y))||{x:1,y:1}:{x:1,y:1},b=Z(n.convertOffsetParentRelativeRectToViewportRelativeRect?await n.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:v,offsetParent:y,strategy:m}):v);return{top:(p.top-b.top+d.top)/A.y,bottom:(b.bottom-p.bottom+d.bottom)/A.y,left:(p.left-b.left+d.left)/A.x,right:(b.right-p.right+d.right)/A.x}}function xt(t,e,s){return(t?[...s.filter(o=>k(o)===t),...s.filter(o=>k(o)!==t)]:s.filter(o=>C(o)===o)).filter(o=>t?k(o)===t||(e?X(o)!==o:!1):!0)}const wt=function(t){return t===void 0&&(t={}),{name:"autoPlacement",options:t,async fn(e){var s,r,o;const{rects:n,middlewareData:i,placement:l,platform:m,elements:x}=e,{crossAxis:c=!1,alignment:a,allowedPlacements:g=Q,autoAlignment:f=!0,...d}=z(t,e),w=a!==void 0||g===Q?xt(a||null,f,g):g,u=await V(e,d),p=((s=i.autoPlacement)==null?void 0:s.index)||0,v=w[p];if(v==null)return{};const y=st(v,n,await(m.isRTL==null?void 0:m.isRTL(x.floating)));if(l!==v)return{reset:{placement:w[0]}};const A=[u[C(v)],u[y[0]],u[y[1]]],b=[...((r=i.autoPlacement)==null?void 0:r.overflows)||[],{placement:v,overflows:A}],L=w[p+1];if(L)return{data:{index:p+1,overflows:b},reset:{placement:L}};const S=b.map(h=>{const O=k(h.placement);return[h.placement,O&&c?h.overflows.slice(0,2).reduce((T,$)=>T+$,0):h.overflows[0],h.overflows]}).sort((h,O)=>h[1]-O[1]),D=((o=S.filter(h=>h[2].slice(0,k(h[0])?2:3).every(O=>O<=0))[0])==null?void 0:o[0])||S[0][0];return D!==l?{data:{index:p+1,overflows:b},reset:{placement:D}}:{}}}},vt=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var s,r;const{placement:o,middlewareData:n,rects:i,initialPlacement:l,platform:m,elements:x}=e,{mainAxis:c=!0,crossAxis:a=!0,fallbackPlacements:g,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:d="none",flipAlignment:w=!0,...u}=z(t,e);if((s=n.arrow)!=null&&s.alignmentOffset)return{};const p=C(o),v=_(l),y=C(l)===l,A=await(m.isRTL==null?void 0:m.isRTL(x.floating)),b=g||(y||!w?[W(l)]:mt(l)),L=d!=="none";!g&&L&&b.push(...pt(l,w,d,A));const S=[l,...b],P=await V(e,u),D=[];let h=((r=n.flip)==null?void 0:r.overflows)||[];if(c&&D.push(P[p]),a){const M=st(o,i,A);D.push(P[M[0]],P[M[1]])}if(h=[...h,{placement:o,overflows:D}],!D.every(M=>M<=0)){var O,T;const M=(((O=n.flip)==null?void 0:O.index)||0)+1,F=S[M];if(F)return{data:{index:M,overflows:h},reset:{placement:F}};let j=(T=h.filter(H=>H.overflows[0]<=0).sort((H,E)=>H.overflows[1]-E.overflows[1])[0])==null?void 0:T.placement;if(!j)switch(f){case"bestFit":{var $;const H=($=h.filter(E=>{if(L){const R=_(E.placement);return R===v||R==="y"}return!0}).map(E=>[E.placement,E.overflows.filter(R=>R>0).reduce((R,Y)=>R+Y,0)]).sort((E,R)=>E[1]-R[1])[0])==null?void 0:$[0];H&&(j=H);break}case"initialPlacement":j=l;break}if(o!==j)return{reset:{placement:j}}}return{}}}};function tt(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function et(t){return nt.some(e=>t[e]>=0)}const yt=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:s}=e,{strategy:r="referenceHidden",...o}=z(t,e);switch(r){case"referenceHidden":{const n=await V(e,{...o,elementContext:"reference"}),i=tt(n,s.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:et(i)}}}case"escaped":{const n=await V(e,{...o,altBoundary:!0}),i=tt(n,s.floating);return{data:{escapedOffsets:i,escaped:et(i)}}}default:return{}}}}};async function bt(t,e){const{placement:s,platform:r,elements:o}=t,n=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=C(s),l=k(s),m=_(s)==="y",x=["left","top"].includes(i)?-1:1,c=n&&m?-1:1,a=z(e,t);let{mainAxis:g,crossAxis:f,alignmentAxis:d}=typeof a=="number"?{mainAxis:a,crossAxis:0,alignmentAxis:null}:{mainAxis:a.mainAxis||0,crossAxis:a.crossAxis||0,alignmentAxis:a.alignmentAxis};return l&&typeof d=="number"&&(f=l==="end"?d*-1:d),m?{x:f*c,y:g*x}:{x:g*x,y:f*c}}const At=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var s,r;const{x:o,y:n,placement:i,middlewareData:l}=e,m=await bt(e,t);return i===((s=l.offset)==null?void 0:s.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:o+m.x,y:n+m.y,data:{...m,placement:i}}}}},Pt=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:s,y:r,placement:o}=e,{mainAxis:n=!0,crossAxis:i=!1,limiter:l={fn:u=>{let{x:p,y:v}=u;return{x:p,y:v}}},...m}=z(t,e),x={x:s,y:r},c=await V(e,m),a=_(C(o)),g=N(a);let f=x[g],d=x[a];if(n){const u=g==="y"?"top":"left",p=g==="y"?"bottom":"right",v=f+c[u],y=f-c[p];f=G(v,f,y)}if(i){const u=a==="y"?"top":"left",p=a==="y"?"bottom":"right",v=d+c[u],y=d-c[p];d=G(v,d,y)}const w=l.fn({...e,[g]:f,[a]:d});return{...w,data:{x:w.x-s,y:w.y-r,enabled:{[g]:n,[a]:i}}}}}},Ot=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){var s,r;const{placement:o,rects:n,platform:i,elements:l}=e,{apply:m=()=>{},...x}=z(t,e),c=await V(e,x),a=C(o),g=k(o),f=_(o)==="y",{width:d,height:w}=n.floating;let u,p;a==="top"||a==="bottom"?(u=a,p=g===(await(i.isRTL==null?void 0:i.isRTL(l.floating))?"start":"end")?"left":"right"):(p=a,u=g==="end"?"top":"bottom");const v=w-c.top-c.bottom,y=d-c.left-c.right,A=I(w-c[u],v),b=I(d-c[p],y),L=!e.middlewareData.shift;let S=A,P=b;if((s=e.middlewareData.shift)!=null&&s.enabled.x&&(P=y),(r=e.middlewareData.shift)!=null&&r.enabled.y&&(S=v),L&&!g){const h=B(c.left,0),O=B(c.right,0),T=B(c.top,0),$=B(c.bottom,0);f?P=d-2*(h!==0||O!==0?h+O:B(c.left,c.right)):S=w-2*(T!==0||$!==0?T+$:B(c.top,c.bottom))}await m({...e,availableWidth:P,availableHeight:S});const D=await i.getDimensions(l.floating);return d!==D.width||w!==D.height?{reset:{rects:!0}}:{}}}},St=At,Dt=wt,$t=Pt,Rt=vt,Ct=Ot,Tt=yt,Mt=16,Et=t=>{var e;return{visibility:(e=t.hide)!=null&&e.referenceHidden?"hidden":"visible"}},ct=t=>({name:"arrowStyles",options:t,async fn(e){var q,J;const{x:s,y:r,placement:o,rects:n,platform:i,elements:l,middlewareData:m}=e,{element:x,padding:c=0}=z(t,e)||{};if(x==null)return{};const a=rt(c),g={x:s,y:r},f=ot(o),d=N(f),w=it(f),u=await i.getDimensions(x),p=f==="y",v=p?"top":"left",y=p?"bottom":"right",A=p?"clientHeight":"clientWidth",b=n.reference[w]+n.reference[f]-g[f]-n.floating[w],L=g[f]-n.reference[f],S=await((q=i.getOffsetParent)==null?void 0:q.call(i,x));let P=S?S[A]:0;(!P||!await((J=i.isElement)==null?void 0:J.call(i,S)))&&(P=l.floating[A]||n.floating[w]);const D=b/2-L/2,h=P/2-u.width/2-1,O=I(a[v],h),T=I(a[y],h),$=O,M=P-u.width-T,F=P/2-u.width/2+D,j=G($,F,M),H=!m.arrow&&k(o)!=null&&F!==j&&n.reference[w]/2-(F<$?O:T)-u.width/2<0,E=H?F<$?F-$:F-M:0,R=C(o),Y=["top","left"].includes(R)?-1:1,at=u.height*Y,ft=lt({placement:R,arrowHeight:u.height,arrowWidth:u.width,[f]:j});return{[f]:g[f]+E,[d]:g[d]+at,data:ft,reset:H}}}),U=(t,e,s,r)=>{if(r){const o=r===!0?s():s(r);t[e](o)}},kt=({baseConfig:t,middleware:e,offset:s,arrow:r,placement:o="top"})=>{const n={...t,placement:o};let i=[];if(typeof e.overrides!="object"){i.push(St(s));let l=e.flip??!0;if(e.autoPlacement&&(l=!1),U(i,"unshift",Dt,e.autoPlacement),U(i,"unshift",Rt,l),e.size){const m=e.size===!0?{padding:Mt,apply({availableHeight:x,elements:c}){Object.assign(c.floating.style,{maxHeight:`${x}px`})}}:e.size;i.push(Ct(m))}U(i,"push",$t,e.shift??!0),U(i,"push",Tt,e.hide??!0)}else i.push(...e.overrides);return r.hide||i.push(ct(r.options)),typeof e.overrides=="function"&&(i=e.overrides(i)),n.middleware=i,n},lt=({placement:t,arrowHeight:e,arrowWidth:s,x:r,y:o})=>{const n=C(t),i=s/2-e,l={top:"rotate(0deg)",bottom:"rotate(180deg)",left:`rotate(-90deg) translateX(${-i}px)`,right:`rotate(90deg) translateX(${i}px)`}[n],m=-s/2-e,x={top:`${-e}px`,bottom:`${-e*2}px`,left:`${m}px`,right:`${m}px`}[n],c={transform:l};c.left=r!=null?`${r}px`:"",c.top=o!=null?`${o}px`:"";const a=W(n);return c[a]=x,c};exports.arrowMiddleware=ct;exports.arrowStyles=lt;exports.buildFloatingUIConfig=kt;exports.visibilityHandler=Et;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MiddlewareData, ArrowOptions, AutoPlacementOptions, ComputePositionConfig, FlipOptions, HideOptions, Middleware, MiddlewareState, OffsetOptions, Placement, ShiftOptions } from '@floating-ui/dom';
|
|
1
|
+
import { MiddlewareData, ArrowOptions, AutoPlacementOptions, ComputePositionConfig, FlipOptions, HideOptions, Middleware, MiddlewareState, OffsetOptions, Placement, ShiftOptions, SizeOptions } from '@floating-ui/dom';
|
|
2
2
|
import { CSSObject } from '../utils/types';
|
|
3
3
|
/**
|
|
4
4
|
* Function option to derive middleware options from state.
|
|
@@ -26,6 +26,7 @@ export interface FloatingUIConfigArgs {
|
|
|
26
26
|
flip?: boolean | FlipOptions;
|
|
27
27
|
hide?: boolean | HideOptions;
|
|
28
28
|
shift?: boolean | ShiftOptions;
|
|
29
|
+
size?: boolean | SizeOptions;
|
|
29
30
|
};
|
|
30
31
|
arrow: {
|
|
31
32
|
options: ArrowOptions;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const nt = ["top", "right", "bottom", "left"], K = ["start", "end"], Q = /* @__PURE__ */ nt.reduce((t, e) => t.concat(e, e + "-" + K[0], e + "-" + K[1]), []), I = Math.min, B = Math.max, at = {
|
|
2
2
|
left: "right",
|
|
3
3
|
right: "left",
|
|
4
4
|
bottom: "top",
|
|
@@ -7,62 +7,62 @@ const et = ["top", "right", "bottom", "left"], K = ["start", "end"], N = /* @__P
|
|
|
7
7
|
start: "end",
|
|
8
8
|
end: "start"
|
|
9
9
|
};
|
|
10
|
-
function
|
|
11
|
-
return
|
|
10
|
+
function N(t, e, s) {
|
|
11
|
+
return B(t, I(e, s));
|
|
12
12
|
}
|
|
13
|
-
function
|
|
13
|
+
function z(t, e) {
|
|
14
14
|
return typeof t == "function" ? t(e) : t;
|
|
15
15
|
}
|
|
16
16
|
function C(t) {
|
|
17
17
|
return t.split("-")[0];
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function k(t) {
|
|
20
20
|
return t.split("-")[1];
|
|
21
21
|
}
|
|
22
|
-
function
|
|
22
|
+
function U(t) {
|
|
23
23
|
return t === "x" ? "y" : "x";
|
|
24
24
|
}
|
|
25
|
-
function
|
|
25
|
+
function it(t) {
|
|
26
26
|
return t === "y" ? "height" : "width";
|
|
27
27
|
}
|
|
28
|
-
function
|
|
28
|
+
function _(t) {
|
|
29
29
|
return ["top", "bottom"].includes(C(t)) ? "y" : "x";
|
|
30
30
|
}
|
|
31
31
|
function ot(t) {
|
|
32
|
-
return
|
|
32
|
+
return U(_(t));
|
|
33
33
|
}
|
|
34
|
-
function
|
|
34
|
+
function st(t, e, s) {
|
|
35
35
|
s === void 0 && (s = !1);
|
|
36
|
-
const r =
|
|
37
|
-
let
|
|
38
|
-
return e.reference[n] > e.floating[n] && (
|
|
36
|
+
const r = k(t), o = ot(t), n = it(o);
|
|
37
|
+
let i = o === "x" ? r === (s ? "end" : "start") ? "right" : "left" : r === "start" ? "bottom" : "top";
|
|
38
|
+
return e.reference[n] > e.floating[n] && (i = W(i)), [i, W(i)];
|
|
39
39
|
}
|
|
40
|
-
function
|
|
41
|
-
const e =
|
|
42
|
-
return [
|
|
40
|
+
function dt(t) {
|
|
41
|
+
const e = W(t);
|
|
42
|
+
return [Y(t), e, Y(e)];
|
|
43
43
|
}
|
|
44
|
-
function
|
|
44
|
+
function Y(t) {
|
|
45
45
|
return t.replace(/start|end/g, (e) => ft[e]);
|
|
46
46
|
}
|
|
47
|
-
function
|
|
48
|
-
const r = ["left", "right"],
|
|
47
|
+
function mt(t, e, s) {
|
|
48
|
+
const r = ["left", "right"], o = ["right", "left"], n = ["top", "bottom"], i = ["bottom", "top"];
|
|
49
49
|
switch (t) {
|
|
50
50
|
case "top":
|
|
51
51
|
case "bottom":
|
|
52
|
-
return s ? e ?
|
|
52
|
+
return s ? e ? o : r : e ? r : o;
|
|
53
53
|
case "left":
|
|
54
54
|
case "right":
|
|
55
|
-
return e ? n :
|
|
55
|
+
return e ? n : i;
|
|
56
56
|
default:
|
|
57
57
|
return [];
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
|
-
function
|
|
61
|
-
const
|
|
62
|
-
let n =
|
|
63
|
-
return
|
|
60
|
+
function ut(t, e, s, r) {
|
|
61
|
+
const o = k(t);
|
|
62
|
+
let n = mt(C(t), s === "start", r);
|
|
63
|
+
return o && (n = n.map((i) => i + "-" + o), e && (n = n.concat(n.map(Y)))), n;
|
|
64
64
|
}
|
|
65
|
-
function
|
|
65
|
+
function W(t) {
|
|
66
66
|
return t.replace(/left|right|bottom|top/g, (e) => at[e]);
|
|
67
67
|
}
|
|
68
68
|
function gt(t) {
|
|
@@ -74,7 +74,7 @@ function gt(t) {
|
|
|
74
74
|
...t
|
|
75
75
|
};
|
|
76
76
|
}
|
|
77
|
-
function
|
|
77
|
+
function rt(t) {
|
|
78
78
|
return typeof t != "number" ? gt(t) : {
|
|
79
79
|
top: t,
|
|
80
80
|
right: t,
|
|
@@ -82,133 +82,133 @@ function st(t) {
|
|
|
82
82
|
left: t
|
|
83
83
|
};
|
|
84
84
|
}
|
|
85
|
-
function
|
|
85
|
+
function Z(t) {
|
|
86
86
|
const {
|
|
87
87
|
x: e,
|
|
88
88
|
y: s,
|
|
89
89
|
width: r,
|
|
90
|
-
height:
|
|
90
|
+
height: o
|
|
91
91
|
} = t;
|
|
92
92
|
return {
|
|
93
93
|
width: r,
|
|
94
|
-
height:
|
|
94
|
+
height: o,
|
|
95
95
|
top: s,
|
|
96
96
|
left: e,
|
|
97
97
|
right: e + r,
|
|
98
|
-
bottom: s +
|
|
98
|
+
bottom: s + o,
|
|
99
99
|
x: e,
|
|
100
100
|
y: s
|
|
101
101
|
};
|
|
102
102
|
}
|
|
103
|
-
async function
|
|
103
|
+
async function V(t, e) {
|
|
104
104
|
var s;
|
|
105
105
|
e === void 0 && (e = {});
|
|
106
106
|
const {
|
|
107
107
|
x: r,
|
|
108
|
-
y:
|
|
108
|
+
y: o,
|
|
109
109
|
platform: n,
|
|
110
|
-
rects:
|
|
111
|
-
elements:
|
|
110
|
+
rects: i,
|
|
111
|
+
elements: l,
|
|
112
112
|
strategy: u
|
|
113
113
|
} = t, {
|
|
114
|
-
boundary:
|
|
115
|
-
rootBoundary:
|
|
116
|
-
elementContext:
|
|
117
|
-
altBoundary:
|
|
118
|
-
padding:
|
|
119
|
-
} =
|
|
120
|
-
element: (s = await (n.isElement == null ? void 0 : n.isElement(
|
|
121
|
-
boundary:
|
|
122
|
-
rootBoundary:
|
|
114
|
+
boundary: x = "clippingAncestors",
|
|
115
|
+
rootBoundary: c = "viewport",
|
|
116
|
+
elementContext: a = "floating",
|
|
117
|
+
altBoundary: g = !1,
|
|
118
|
+
padding: f = 0
|
|
119
|
+
} = z(e, t), d = rt(f), m = l[g ? a === "floating" ? "reference" : "floating" : a], p = Z(await n.getClippingRect({
|
|
120
|
+
element: (s = await (n.isElement == null ? void 0 : n.isElement(m))) == null || s ? m : m.contextElement || await (n.getDocumentElement == null ? void 0 : n.getDocumentElement(l.floating)),
|
|
121
|
+
boundary: x,
|
|
122
|
+
rootBoundary: c,
|
|
123
123
|
strategy: u
|
|
124
|
-
})),
|
|
124
|
+
})), v = a === "floating" ? {
|
|
125
125
|
x: r,
|
|
126
|
-
y:
|
|
127
|
-
width:
|
|
128
|
-
height:
|
|
129
|
-
} :
|
|
126
|
+
y: o,
|
|
127
|
+
width: i.floating.width,
|
|
128
|
+
height: i.floating.height
|
|
129
|
+
} : i.reference, y = await (n.getOffsetParent == null ? void 0 : n.getOffsetParent(l.floating)), A = await (n.isElement == null ? void 0 : n.isElement(y)) ? await (n.getScale == null ? void 0 : n.getScale(y)) || {
|
|
130
130
|
x: 1,
|
|
131
131
|
y: 1
|
|
132
132
|
} : {
|
|
133
133
|
x: 1,
|
|
134
134
|
y: 1
|
|
135
|
-
},
|
|
136
|
-
elements:
|
|
137
|
-
rect:
|
|
135
|
+
}, b = Z(n.convertOffsetParentRelativeRectToViewportRelativeRect ? await n.convertOffsetParentRelativeRectToViewportRelativeRect({
|
|
136
|
+
elements: l,
|
|
137
|
+
rect: v,
|
|
138
138
|
offsetParent: y,
|
|
139
139
|
strategy: u
|
|
140
|
-
}) :
|
|
140
|
+
}) : v);
|
|
141
141
|
return {
|
|
142
|
-
top: (
|
|
143
|
-
bottom: (
|
|
144
|
-
left: (
|
|
145
|
-
right: (
|
|
142
|
+
top: (p.top - b.top + d.top) / A.y,
|
|
143
|
+
bottom: (b.bottom - p.bottom + d.bottom) / A.y,
|
|
144
|
+
left: (p.left - b.left + d.left) / A.x,
|
|
145
|
+
right: (b.right - p.right + d.right) / A.x
|
|
146
146
|
};
|
|
147
147
|
}
|
|
148
148
|
function pt(t, e, s) {
|
|
149
|
-
return (t ? [...s.filter((
|
|
149
|
+
return (t ? [...s.filter((o) => k(o) === t), ...s.filter((o) => k(o) !== t)] : s.filter((o) => C(o) === o)).filter((o) => t ? k(o) === t || (e ? Y(o) !== o : !1) : !0);
|
|
150
150
|
}
|
|
151
|
-
const
|
|
151
|
+
const ht = function(t) {
|
|
152
152
|
return t === void 0 && (t = {}), {
|
|
153
153
|
name: "autoPlacement",
|
|
154
154
|
options: t,
|
|
155
155
|
async fn(e) {
|
|
156
|
-
var s, r,
|
|
156
|
+
var s, r, o;
|
|
157
157
|
const {
|
|
158
158
|
rects: n,
|
|
159
|
-
middlewareData:
|
|
160
|
-
placement:
|
|
159
|
+
middlewareData: i,
|
|
160
|
+
placement: l,
|
|
161
161
|
platform: u,
|
|
162
|
-
elements:
|
|
162
|
+
elements: x
|
|
163
163
|
} = e, {
|
|
164
|
-
crossAxis:
|
|
165
|
-
alignment:
|
|
166
|
-
allowedPlacements:
|
|
167
|
-
autoAlignment:
|
|
168
|
-
...
|
|
169
|
-
} =
|
|
170
|
-
if (
|
|
164
|
+
crossAxis: c = !1,
|
|
165
|
+
alignment: a,
|
|
166
|
+
allowedPlacements: g = Q,
|
|
167
|
+
autoAlignment: f = !0,
|
|
168
|
+
...d
|
|
169
|
+
} = z(t, e), w = a !== void 0 || g === Q ? pt(a || null, f, g) : g, m = await V(e, d), p = ((s = i.autoPlacement) == null ? void 0 : s.index) || 0, v = w[p];
|
|
170
|
+
if (v == null)
|
|
171
171
|
return {};
|
|
172
|
-
const y =
|
|
173
|
-
if (
|
|
172
|
+
const y = st(v, n, await (u.isRTL == null ? void 0 : u.isRTL(x.floating)));
|
|
173
|
+
if (l !== v)
|
|
174
174
|
return {
|
|
175
175
|
reset: {
|
|
176
|
-
placement:
|
|
176
|
+
placement: w[0]
|
|
177
177
|
}
|
|
178
178
|
};
|
|
179
|
-
const
|
|
180
|
-
placement:
|
|
181
|
-
overflows:
|
|
182
|
-
}],
|
|
183
|
-
if (
|
|
179
|
+
const A = [m[C(v)], m[y[0]], m[y[1]]], b = [...((r = i.autoPlacement) == null ? void 0 : r.overflows) || [], {
|
|
180
|
+
placement: v,
|
|
181
|
+
overflows: A
|
|
182
|
+
}], L = w[p + 1];
|
|
183
|
+
if (L)
|
|
184
184
|
return {
|
|
185
185
|
data: {
|
|
186
|
-
index:
|
|
187
|
-
overflows:
|
|
186
|
+
index: p + 1,
|
|
187
|
+
overflows: b
|
|
188
188
|
},
|
|
189
189
|
reset: {
|
|
190
|
-
placement:
|
|
190
|
+
placement: L
|
|
191
191
|
}
|
|
192
192
|
};
|
|
193
|
-
const
|
|
194
|
-
const
|
|
195
|
-
return [
|
|
193
|
+
const S = b.map((h) => {
|
|
194
|
+
const O = k(h.placement);
|
|
195
|
+
return [h.placement, O && c ? (
|
|
196
196
|
// Check along the mainAxis and main crossAxis side.
|
|
197
|
-
|
|
197
|
+
h.overflows.slice(0, 2).reduce((T, $) => T + $, 0)
|
|
198
198
|
) : (
|
|
199
199
|
// Check only the mainAxis.
|
|
200
|
-
|
|
201
|
-
),
|
|
202
|
-
}).sort((
|
|
200
|
+
h.overflows[0]
|
|
201
|
+
), h.overflows];
|
|
202
|
+
}).sort((h, O) => h[1] - O[1]), D = ((o = S.filter((h) => h[2].slice(
|
|
203
203
|
0,
|
|
204
204
|
// Aligned placements should not check their opposite crossAxis
|
|
205
205
|
// side.
|
|
206
|
-
|
|
207
|
-
).every((
|
|
208
|
-
return D !==
|
|
206
|
+
k(h[0]) ? 2 : 3
|
|
207
|
+
).every((O) => O <= 0))[0]) == null ? void 0 : o[0]) || S[0][0];
|
|
208
|
+
return D !== l ? {
|
|
209
209
|
data: {
|
|
210
|
-
index:
|
|
211
|
-
overflows:
|
|
210
|
+
index: p + 1,
|
|
211
|
+
overflows: b
|
|
212
212
|
},
|
|
213
213
|
reset: {
|
|
214
214
|
placement: D
|
|
@@ -216,79 +216,79 @@ const xt = function(t) {
|
|
|
216
216
|
} : {};
|
|
217
217
|
}
|
|
218
218
|
};
|
|
219
|
-
},
|
|
219
|
+
}, xt = function(t) {
|
|
220
220
|
return t === void 0 && (t = {}), {
|
|
221
221
|
name: "flip",
|
|
222
222
|
options: t,
|
|
223
223
|
async fn(e) {
|
|
224
224
|
var s, r;
|
|
225
225
|
const {
|
|
226
|
-
placement:
|
|
226
|
+
placement: o,
|
|
227
227
|
middlewareData: n,
|
|
228
|
-
rects:
|
|
229
|
-
initialPlacement:
|
|
228
|
+
rects: i,
|
|
229
|
+
initialPlacement: l,
|
|
230
230
|
platform: u,
|
|
231
|
-
elements:
|
|
231
|
+
elements: x
|
|
232
232
|
} = e, {
|
|
233
|
-
mainAxis:
|
|
234
|
-
crossAxis:
|
|
235
|
-
fallbackPlacements:
|
|
236
|
-
fallbackStrategy:
|
|
237
|
-
fallbackAxisSideDirection:
|
|
238
|
-
flipAlignment:
|
|
239
|
-
...
|
|
240
|
-
} =
|
|
233
|
+
mainAxis: c = !0,
|
|
234
|
+
crossAxis: a = !0,
|
|
235
|
+
fallbackPlacements: g,
|
|
236
|
+
fallbackStrategy: f = "bestFit",
|
|
237
|
+
fallbackAxisSideDirection: d = "none",
|
|
238
|
+
flipAlignment: w = !0,
|
|
239
|
+
...m
|
|
240
|
+
} = z(t, e);
|
|
241
241
|
if ((s = n.arrow) != null && s.alignmentOffset)
|
|
242
242
|
return {};
|
|
243
|
-
const
|
|
244
|
-
!
|
|
245
|
-
const
|
|
246
|
-
let
|
|
247
|
-
if (
|
|
248
|
-
const
|
|
249
|
-
D.push(
|
|
243
|
+
const p = C(o), v = _(l), y = C(l) === l, A = await (u.isRTL == null ? void 0 : u.isRTL(x.floating)), b = g || (y || !w ? [W(l)] : dt(l)), L = d !== "none";
|
|
244
|
+
!g && L && b.push(...ut(l, w, d, A));
|
|
245
|
+
const S = [l, ...b], P = await V(e, m), D = [];
|
|
246
|
+
let h = ((r = n.flip) == null ? void 0 : r.overflows) || [];
|
|
247
|
+
if (c && D.push(P[p]), a) {
|
|
248
|
+
const E = st(o, i, A);
|
|
249
|
+
D.push(P[E[0]], P[E[1]]);
|
|
250
250
|
}
|
|
251
|
-
if (
|
|
252
|
-
placement:
|
|
251
|
+
if (h = [...h, {
|
|
252
|
+
placement: o,
|
|
253
253
|
overflows: D
|
|
254
|
-
}], !D.every((
|
|
255
|
-
var
|
|
256
|
-
const
|
|
257
|
-
if (
|
|
254
|
+
}], !D.every((E) => E <= 0)) {
|
|
255
|
+
var O, T;
|
|
256
|
+
const E = (((O = n.flip) == null ? void 0 : O.index) || 0) + 1, F = S[E];
|
|
257
|
+
if (F)
|
|
258
258
|
return {
|
|
259
259
|
data: {
|
|
260
|
-
index:
|
|
261
|
-
overflows:
|
|
260
|
+
index: E,
|
|
261
|
+
overflows: h
|
|
262
262
|
},
|
|
263
263
|
reset: {
|
|
264
|
-
placement:
|
|
264
|
+
placement: F
|
|
265
265
|
}
|
|
266
266
|
};
|
|
267
|
-
let
|
|
268
|
-
if (!
|
|
269
|
-
switch (
|
|
267
|
+
let j = (T = h.filter((H) => H.overflows[0] <= 0).sort((H, M) => H.overflows[1] - M.overflows[1])[0]) == null ? void 0 : T.placement;
|
|
268
|
+
if (!j)
|
|
269
|
+
switch (f) {
|
|
270
270
|
case "bestFit": {
|
|
271
|
-
var
|
|
272
|
-
const
|
|
273
|
-
if (
|
|
274
|
-
const
|
|
275
|
-
return
|
|
271
|
+
var $;
|
|
272
|
+
const H = ($ = h.filter((M) => {
|
|
273
|
+
if (L) {
|
|
274
|
+
const R = _(M.placement);
|
|
275
|
+
return R === v || // Create a bias to the `y` side axis due to horizontal
|
|
276
276
|
// reading directions favoring greater width.
|
|
277
|
-
|
|
277
|
+
R === "y";
|
|
278
278
|
}
|
|
279
279
|
return !0;
|
|
280
|
-
}).map((
|
|
281
|
-
|
|
280
|
+
}).map((M) => [M.placement, M.overflows.filter((R) => R > 0).reduce((R, G) => R + G, 0)]).sort((M, R) => M[1] - R[1])[0]) == null ? void 0 : $[0];
|
|
281
|
+
H && (j = H);
|
|
282
282
|
break;
|
|
283
283
|
}
|
|
284
284
|
case "initialPlacement":
|
|
285
|
-
|
|
285
|
+
j = l;
|
|
286
286
|
break;
|
|
287
287
|
}
|
|
288
|
-
if (
|
|
288
|
+
if (o !== j)
|
|
289
289
|
return {
|
|
290
290
|
reset: {
|
|
291
|
-
placement:
|
|
291
|
+
placement: j
|
|
292
292
|
}
|
|
293
293
|
};
|
|
294
294
|
}
|
|
@@ -296,7 +296,7 @@ const xt = function(t) {
|
|
|
296
296
|
}
|
|
297
297
|
};
|
|
298
298
|
};
|
|
299
|
-
function
|
|
299
|
+
function tt(t, e) {
|
|
300
300
|
return {
|
|
301
301
|
top: t.top - e.height,
|
|
302
302
|
right: t.right - e.width,
|
|
@@ -304,8 +304,8 @@ function Z(t, e) {
|
|
|
304
304
|
left: t.left - e.width
|
|
305
305
|
};
|
|
306
306
|
}
|
|
307
|
-
function
|
|
308
|
-
return
|
|
307
|
+
function et(t) {
|
|
308
|
+
return nt.some((e) => t[e] >= 0);
|
|
309
309
|
}
|
|
310
310
|
const wt = function(t) {
|
|
311
311
|
return t === void 0 && (t = {}), {
|
|
@@ -316,30 +316,30 @@ const wt = function(t) {
|
|
|
316
316
|
rects: s
|
|
317
317
|
} = e, {
|
|
318
318
|
strategy: r = "referenceHidden",
|
|
319
|
-
...
|
|
320
|
-
} =
|
|
319
|
+
...o
|
|
320
|
+
} = z(t, e);
|
|
321
321
|
switch (r) {
|
|
322
322
|
case "referenceHidden": {
|
|
323
|
-
const n = await
|
|
324
|
-
...
|
|
323
|
+
const n = await V(e, {
|
|
324
|
+
...o,
|
|
325
325
|
elementContext: "reference"
|
|
326
|
-
}),
|
|
326
|
+
}), i = tt(n, s.reference);
|
|
327
327
|
return {
|
|
328
328
|
data: {
|
|
329
|
-
referenceHiddenOffsets:
|
|
330
|
-
referenceHidden:
|
|
329
|
+
referenceHiddenOffsets: i,
|
|
330
|
+
referenceHidden: et(i)
|
|
331
331
|
}
|
|
332
332
|
};
|
|
333
333
|
}
|
|
334
334
|
case "escaped": {
|
|
335
|
-
const n = await
|
|
336
|
-
...
|
|
335
|
+
const n = await V(e, {
|
|
336
|
+
...o,
|
|
337
337
|
altBoundary: !0
|
|
338
|
-
}),
|
|
338
|
+
}), i = tt(n, s.floating);
|
|
339
339
|
return {
|
|
340
340
|
data: {
|
|
341
|
-
escapedOffsets:
|
|
342
|
-
escaped:
|
|
341
|
+
escapedOffsets: i,
|
|
342
|
+
escaped: et(i)
|
|
343
343
|
}
|
|
344
344
|
};
|
|
345
345
|
}
|
|
@@ -353,27 +353,27 @@ async function vt(t, e) {
|
|
|
353
353
|
const {
|
|
354
354
|
placement: s,
|
|
355
355
|
platform: r,
|
|
356
|
-
elements:
|
|
357
|
-
} = t, n = await (r.isRTL == null ? void 0 : r.isRTL(
|
|
356
|
+
elements: o
|
|
357
|
+
} = t, n = await (r.isRTL == null ? void 0 : r.isRTL(o.floating)), i = C(s), l = k(s), u = _(s) === "y", x = ["left", "top"].includes(i) ? -1 : 1, c = n && u ? -1 : 1, a = z(e, t);
|
|
358
358
|
let {
|
|
359
|
-
mainAxis:
|
|
360
|
-
crossAxis:
|
|
361
|
-
alignmentAxis:
|
|
362
|
-
} = typeof
|
|
363
|
-
mainAxis:
|
|
359
|
+
mainAxis: g,
|
|
360
|
+
crossAxis: f,
|
|
361
|
+
alignmentAxis: d
|
|
362
|
+
} = typeof a == "number" ? {
|
|
363
|
+
mainAxis: a,
|
|
364
364
|
crossAxis: 0,
|
|
365
365
|
alignmentAxis: null
|
|
366
366
|
} : {
|
|
367
|
-
mainAxis:
|
|
368
|
-
crossAxis:
|
|
369
|
-
alignmentAxis:
|
|
367
|
+
mainAxis: a.mainAxis || 0,
|
|
368
|
+
crossAxis: a.crossAxis || 0,
|
|
369
|
+
alignmentAxis: a.alignmentAxis
|
|
370
370
|
};
|
|
371
|
-
return
|
|
372
|
-
x:
|
|
373
|
-
y:
|
|
371
|
+
return l && typeof d == "number" && (f = l === "end" ? d * -1 : d), u ? {
|
|
372
|
+
x: f * c,
|
|
373
|
+
y: g * x
|
|
374
374
|
} : {
|
|
375
|
-
x:
|
|
376
|
-
y:
|
|
375
|
+
x: g * x,
|
|
376
|
+
y: f * c
|
|
377
377
|
};
|
|
378
378
|
}
|
|
379
379
|
const yt = function(t) {
|
|
@@ -383,22 +383,22 @@ const yt = function(t) {
|
|
|
383
383
|
async fn(e) {
|
|
384
384
|
var s, r;
|
|
385
385
|
const {
|
|
386
|
-
x:
|
|
386
|
+
x: o,
|
|
387
387
|
y: n,
|
|
388
|
-
placement:
|
|
389
|
-
middlewareData:
|
|
388
|
+
placement: i,
|
|
389
|
+
middlewareData: l
|
|
390
390
|
} = e, u = await vt(e, t);
|
|
391
|
-
return
|
|
392
|
-
x:
|
|
391
|
+
return i === ((s = l.offset) == null ? void 0 : s.placement) && (r = l.arrow) != null && r.alignmentOffset ? {} : {
|
|
392
|
+
x: o + u.x,
|
|
393
393
|
y: n + u.y,
|
|
394
394
|
data: {
|
|
395
395
|
...u,
|
|
396
|
-
placement:
|
|
396
|
+
placement: i
|
|
397
397
|
}
|
|
398
398
|
};
|
|
399
399
|
}
|
|
400
400
|
};
|
|
401
|
-
},
|
|
401
|
+
}, bt = function(t) {
|
|
402
402
|
return t === void 0 && (t = {}), {
|
|
403
403
|
name: "shift",
|
|
404
404
|
options: t,
|
|
@@ -406,121 +406,172 @@ const yt = function(t) {
|
|
|
406
406
|
const {
|
|
407
407
|
x: s,
|
|
408
408
|
y: r,
|
|
409
|
-
placement:
|
|
409
|
+
placement: o
|
|
410
410
|
} = e, {
|
|
411
411
|
mainAxis: n = !0,
|
|
412
|
-
crossAxis:
|
|
413
|
-
limiter:
|
|
414
|
-
fn: (
|
|
412
|
+
crossAxis: i = !1,
|
|
413
|
+
limiter: l = {
|
|
414
|
+
fn: (m) => {
|
|
415
415
|
let {
|
|
416
|
-
x:
|
|
417
|
-
y:
|
|
418
|
-
} =
|
|
416
|
+
x: p,
|
|
417
|
+
y: v
|
|
418
|
+
} = m;
|
|
419
419
|
return {
|
|
420
|
-
x:
|
|
421
|
-
y:
|
|
420
|
+
x: p,
|
|
421
|
+
y: v
|
|
422
422
|
};
|
|
423
423
|
}
|
|
424
424
|
},
|
|
425
425
|
...u
|
|
426
|
-
} =
|
|
426
|
+
} = z(t, e), x = {
|
|
427
427
|
x: s,
|
|
428
428
|
y: r
|
|
429
|
-
},
|
|
430
|
-
let
|
|
429
|
+
}, c = await V(e, u), a = _(C(o)), g = U(a);
|
|
430
|
+
let f = x[g], d = x[a];
|
|
431
431
|
if (n) {
|
|
432
|
-
const
|
|
433
|
-
|
|
432
|
+
const m = g === "y" ? "top" : "left", p = g === "y" ? "bottom" : "right", v = f + c[m], y = f - c[p];
|
|
433
|
+
f = N(v, f, y);
|
|
434
434
|
}
|
|
435
|
-
if (
|
|
436
|
-
const
|
|
437
|
-
|
|
435
|
+
if (i) {
|
|
436
|
+
const m = a === "y" ? "top" : "left", p = a === "y" ? "bottom" : "right", v = d + c[m], y = d - c[p];
|
|
437
|
+
d = N(v, d, y);
|
|
438
438
|
}
|
|
439
|
-
const
|
|
439
|
+
const w = l.fn({
|
|
440
440
|
...e,
|
|
441
|
-
[
|
|
442
|
-
[
|
|
441
|
+
[g]: f,
|
|
442
|
+
[a]: d
|
|
443
443
|
});
|
|
444
444
|
return {
|
|
445
|
-
...
|
|
445
|
+
...w,
|
|
446
446
|
data: {
|
|
447
|
-
x:
|
|
448
|
-
y:
|
|
447
|
+
x: w.x - s,
|
|
448
|
+
y: w.y - r,
|
|
449
449
|
enabled: {
|
|
450
|
-
[
|
|
451
|
-
[
|
|
450
|
+
[g]: n,
|
|
451
|
+
[a]: i
|
|
452
452
|
}
|
|
453
453
|
}
|
|
454
454
|
};
|
|
455
455
|
}
|
|
456
456
|
};
|
|
457
|
-
},
|
|
457
|
+
}, At = function(t) {
|
|
458
|
+
return t === void 0 && (t = {}), {
|
|
459
|
+
name: "size",
|
|
460
|
+
options: t,
|
|
461
|
+
async fn(e) {
|
|
462
|
+
var s, r;
|
|
463
|
+
const {
|
|
464
|
+
placement: o,
|
|
465
|
+
rects: n,
|
|
466
|
+
platform: i,
|
|
467
|
+
elements: l
|
|
468
|
+
} = e, {
|
|
469
|
+
apply: u = () => {
|
|
470
|
+
},
|
|
471
|
+
...x
|
|
472
|
+
} = z(t, e), c = await V(e, x), a = C(o), g = k(o), f = _(o) === "y", {
|
|
473
|
+
width: d,
|
|
474
|
+
height: w
|
|
475
|
+
} = n.floating;
|
|
476
|
+
let m, p;
|
|
477
|
+
a === "top" || a === "bottom" ? (m = a, p = g === (await (i.isRTL == null ? void 0 : i.isRTL(l.floating)) ? "start" : "end") ? "left" : "right") : (p = a, m = g === "end" ? "top" : "bottom");
|
|
478
|
+
const v = w - c.top - c.bottom, y = d - c.left - c.right, A = I(w - c[m], v), b = I(d - c[p], y), L = !e.middlewareData.shift;
|
|
479
|
+
let S = A, P = b;
|
|
480
|
+
if ((s = e.middlewareData.shift) != null && s.enabled.x && (P = y), (r = e.middlewareData.shift) != null && r.enabled.y && (S = v), L && !g) {
|
|
481
|
+
const h = B(c.left, 0), O = B(c.right, 0), T = B(c.top, 0), $ = B(c.bottom, 0);
|
|
482
|
+
f ? P = d - 2 * (h !== 0 || O !== 0 ? h + O : B(c.left, c.right)) : S = w - 2 * (T !== 0 || $ !== 0 ? T + $ : B(c.top, c.bottom));
|
|
483
|
+
}
|
|
484
|
+
await u({
|
|
485
|
+
...e,
|
|
486
|
+
availableWidth: P,
|
|
487
|
+
availableHeight: S
|
|
488
|
+
});
|
|
489
|
+
const D = await i.getDimensions(l.floating);
|
|
490
|
+
return d !== D.width || w !== D.height ? {
|
|
491
|
+
reset: {
|
|
492
|
+
rects: !0
|
|
493
|
+
}
|
|
494
|
+
} : {};
|
|
495
|
+
}
|
|
496
|
+
};
|
|
497
|
+
}, Pt = yt, Ot = ht, St = bt, Dt = xt, $t = At, Rt = wt, Ct = 16, Mt = (t) => {
|
|
458
498
|
var e;
|
|
459
499
|
return {
|
|
460
500
|
visibility: (e = t.hide) != null && e.referenceHidden ? "hidden" : "visible"
|
|
461
501
|
};
|
|
462
|
-
},
|
|
502
|
+
}, Tt = (t) => ({
|
|
463
503
|
name: "arrowStyles",
|
|
464
504
|
options: t,
|
|
465
505
|
async fn(e) {
|
|
466
|
-
var
|
|
467
|
-
const { x: s, y: r, placement:
|
|
468
|
-
if (
|
|
506
|
+
var q, J;
|
|
507
|
+
const { x: s, y: r, placement: o, rects: n, platform: i, elements: l, middlewareData: u } = e, { element: x, padding: c = 0 } = z(t, e) || {};
|
|
508
|
+
if (x == null)
|
|
469
509
|
return {};
|
|
470
|
-
const
|
|
471
|
-
let
|
|
472
|
-
(!
|
|
473
|
-
const D =
|
|
474
|
-
placement:
|
|
475
|
-
arrowHeight:
|
|
476
|
-
arrowWidth:
|
|
510
|
+
const a = rt(c), g = { x: s, y: r }, f = ot(o), d = U(f), w = it(f), m = await i.getDimensions(x), p = f === "y", v = p ? "top" : "left", y = p ? "bottom" : "right", A = p ? "clientHeight" : "clientWidth", b = n.reference[w] + n.reference[f] - g[f] - n.floating[w], L = g[f] - n.reference[f], S = await ((q = i.getOffsetParent) == null ? void 0 : q.call(i, x));
|
|
511
|
+
let P = S ? S[A] : 0;
|
|
512
|
+
(!P || !await ((J = i.isElement) == null ? void 0 : J.call(i, S))) && (P = l.floating[A] || n.floating[w]);
|
|
513
|
+
const D = b / 2 - L / 2, h = P / 2 - m.width / 2 - 1, O = I(a[v], h), T = I(a[y], h), $ = O, E = P - m.width - T, F = P / 2 - m.width / 2 + D, j = N($, F, E), H = !u.arrow && k(o) != null && F !== j && n.reference[w] / 2 - (F < $ ? O : T) - m.width / 2 < 0, M = H ? F < $ ? F - $ : F - E : 0, R = C(o), G = ["top", "left"].includes(R) ? -1 : 1, ct = m.height * G, lt = Et({
|
|
514
|
+
placement: R,
|
|
515
|
+
arrowHeight: m.height,
|
|
516
|
+
arrowWidth: m.width,
|
|
477
517
|
// pass arrow middleware
|
|
478
|
-
[
|
|
518
|
+
[f]: j
|
|
479
519
|
// for posterity, this is what the floating-ui arrow middleware returns
|
|
480
520
|
// centerOffset: center - offset - alignmentOffset,
|
|
481
521
|
// ...(shouldAddOffset && { alignmentOffset }),
|
|
482
522
|
});
|
|
483
523
|
return {
|
|
484
|
-
[
|
|
485
|
-
[
|
|
486
|
-
data:
|
|
487
|
-
reset:
|
|
524
|
+
[f]: g[f] + M,
|
|
525
|
+
[d]: g[d] + ct,
|
|
526
|
+
data: lt,
|
|
527
|
+
reset: H
|
|
488
528
|
};
|
|
489
529
|
}
|
|
490
530
|
}), X = (t, e, s, r) => {
|
|
491
531
|
if (r) {
|
|
492
|
-
const
|
|
493
|
-
t[e](
|
|
532
|
+
const o = r === !0 ? s() : s(r);
|
|
533
|
+
t[e](o);
|
|
494
534
|
}
|
|
495
|
-
},
|
|
535
|
+
}, kt = ({
|
|
496
536
|
baseConfig: t,
|
|
497
537
|
middleware: e,
|
|
498
538
|
offset: s,
|
|
499
539
|
arrow: r,
|
|
500
|
-
placement:
|
|
540
|
+
placement: o = "top"
|
|
501
541
|
}) => {
|
|
502
|
-
const n = { ...t, placement:
|
|
503
|
-
let
|
|
542
|
+
const n = { ...t, placement: o };
|
|
543
|
+
let i = [];
|
|
504
544
|
if (typeof e.overrides != "object") {
|
|
505
|
-
|
|
506
|
-
let
|
|
507
|
-
e.autoPlacement && (
|
|
508
|
-
|
|
545
|
+
i.push(Pt(s));
|
|
546
|
+
let l = e.flip ?? !0;
|
|
547
|
+
if (e.autoPlacement && (l = !1), X(
|
|
548
|
+
i,
|
|
509
549
|
"unshift",
|
|
510
|
-
|
|
550
|
+
Ot,
|
|
511
551
|
e.autoPlacement
|
|
512
|
-
), X(
|
|
552
|
+
), X(i, "unshift", Dt, l), e.size) {
|
|
553
|
+
const u = e.size === !0 ? {
|
|
554
|
+
padding: Ct,
|
|
555
|
+
apply({ availableHeight: x, elements: c }) {
|
|
556
|
+
Object.assign(c.floating.style, {
|
|
557
|
+
maxHeight: `${x}px`
|
|
558
|
+
});
|
|
559
|
+
}
|
|
560
|
+
} : e.size;
|
|
561
|
+
i.push($t(u));
|
|
562
|
+
}
|
|
563
|
+
X(i, "push", St, e.shift ?? !0), X(i, "push", Rt, e.hide ?? !0);
|
|
513
564
|
} else
|
|
514
|
-
|
|
515
|
-
return r.hide ||
|
|
516
|
-
},
|
|
565
|
+
i.push(...e.overrides);
|
|
566
|
+
return r.hide || i.push(Tt(r.options)), typeof e.overrides == "function" && (i = e.overrides(i)), n.middleware = i, n;
|
|
567
|
+
}, Et = ({
|
|
517
568
|
placement: t,
|
|
518
569
|
arrowHeight: e,
|
|
519
570
|
arrowWidth: s,
|
|
520
571
|
x: r,
|
|
521
|
-
y:
|
|
572
|
+
y: o
|
|
522
573
|
}) => {
|
|
523
|
-
const n = C(t),
|
|
574
|
+
const n = C(t), i = s / 2 - e, l = {
|
|
524
575
|
/* since the default orientation is pointing down, we don't need to rotate the arrow
|
|
525
576
|
if the tooltip is on top of the reference element
|
|
526
577
|
*/
|
|
@@ -546,9 +597,9 @@ const yt = function(t) {
|
|
|
546
597
|
rotation transformations. In both situations, the overall effect is sliding the
|
|
547
598
|
arrow downwards.
|
|
548
599
|
*/
|
|
549
|
-
left: `rotate(-90deg) translateX(${-
|
|
550
|
-
right: `rotate(90deg) translateX(${
|
|
551
|
-
}[n], u = -s / 2 - e,
|
|
600
|
+
left: `rotate(-90deg) translateX(${-i}px)`,
|
|
601
|
+
right: `rotate(90deg) translateX(${i}px)`
|
|
602
|
+
}[n], u = -s / 2 - e, x = {
|
|
552
603
|
/*
|
|
553
604
|
* If the tooltip is at the top of the anchor, place the arrow at the bottom of
|
|
554
605
|
* the tooltip with bottom: 0. The bottom of the arrow will be flush with the bottom
|
|
@@ -593,16 +644,16 @@ const yt = function(t) {
|
|
|
593
644
|
left: `${u}px`,
|
|
594
645
|
// similarly for the right side
|
|
595
646
|
right: `${u}px`
|
|
596
|
-
}[n],
|
|
597
|
-
transform:
|
|
647
|
+
}[n], c = {
|
|
648
|
+
transform: l
|
|
598
649
|
};
|
|
599
|
-
|
|
600
|
-
const
|
|
601
|
-
return
|
|
650
|
+
c.left = r != null ? `${r}px` : "", c.top = o != null ? `${o}px` : "";
|
|
651
|
+
const a = W(n);
|
|
652
|
+
return c[a] = x, c;
|
|
602
653
|
};
|
|
603
654
|
export {
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
655
|
+
Tt as arrowMiddleware,
|
|
656
|
+
Et as arrowStyles,
|
|
657
|
+
kt as buildFloatingUIConfig,
|
|
658
|
+
Mt as visibilityHandler
|
|
608
659
|
};
|