faker
This commit is contained in:
1 parent
11cb9b03f5
commit
5f95289079
25 files changed
+430
-129
No files matched your search
@@ -1 +1 @@
|
||||
var tt=Math.min,V=Math.max,et=Math.round;var E=i=>({x:i,y:i}),Gt={left:"right",right:"left",bottom:"top",top:"bottom"},Qt={start:"end",end:"start"};function mt(i,t,e){return V(i,tt(t,e))}function it(i,t){return typeof i=="function"?i(t):i}function W(i){return i.split("-")[0]}function st(i){return i.split("-")[1]}function gt(i){return i==="x"?"y":"x"}function bt(i){return i==="y"?"height":"width"}var Zt=new Set(["top","bottom"]);function P(i){return Zt.has(W(i))?"y":"x"}function wt(i){return gt(P(i))}function Ot(i,t,e){e===void 0&&(e=!1);let s=st(i),n=wt(i),o=bt(n),r=n==="x"?s===(e?"end":"start")?"right":"left":s==="start"?"bottom":"top";return t.reference[o]>t.floating[o]&&(r=Z(r)),[r,Z(r)]}function At(i){let t=Z(i);return[lt(i),t,lt(t)]}function lt(i){return i.replace(/start|end/g,t=>Qt[t])}var vt=["left","right"],Lt=["right","left"],te=["top","bottom"],ee=["bottom","top"];function ie(i,t,e){switch(i){case"top":case"bottom":return e?t?Lt:vt:t?vt:Lt;case"left":case"right":return t?te:ee;default:return[]}}function St(i,t,e,s){let n=st(i),o=ie(W(i),e==="start",s);return n&&(o=o.map(r=>r+"-"+n),t&&(o=o.concat(o.map(lt)))),o}function Z(i){return i.replace(/left|right|bottom|top/g,t=>Gt[t])}function se(i){return{top:0,right:0,bottom:0,left:0,...i}}function Ct(i){return typeof i!="number"?se(i):{top:i,right:i,bottom:i,left:i}}function U(i){let{x:t,y:e,width:s,height:n}=i;return{width:s,height:n,top:e,left:t,right:t+s,bottom:e+n,x:t,y:e}}function Dt(i,t,e){let{reference:s,floating:n}=i,o=P(t),r=wt(t),l=bt(r),a=W(t),c=o==="y",d=s.x+s.width/2-n.width/2,h=s.y+s.height/2-n.height/2,p=s[l]/2-n[l]/2,f;switch(a){case"top":f={x:d,y:s.y-n.height};break;case"bottom":f={x:d,y:s.y+s.height};break;case"right":f={x:s.x+s.width,y:h};break;case"left":f={x:s.x-n.width,y:h};break;default:f={x:s.x,y:s.y}}switch(st(t)){case"start":f[r]-=p*(e&&c?-1:1);break;case"end":f[r]+=p*(e&&c?-1:1);break}return f}var Et=async(i,t,e)=>{let{placement:s="bottom",strategy:n="absolute",middleware:o=[],platform:r}=e,l=o.filter(Boolean),a=await(r.isRTL==null?void 0:r.isRTL(t)),c=await r.getElementRects({reference:i,floating:t,strategy:n}),{x:d,y:h}=Dt(c,s,a),p=s,f={},u=0;for(let m=0;m<l.length;m++){let{name:g,fn:y}=l[m],{x:b,y:v,data:L,reset:x}=await y({x:d,y:h,initialPlacement:s,placement:p,strategy:n,middlewareData:f,rects:c,platform:r,elements:{reference:i,floating:t}});d=b??d,h=v??h,f={...f,[g]:{...f[g],...L}},x&&u<=50&&(u++,typeof x=="object"&&(x.placement&&(p=x.placement),x.rects&&(c=x.rects===!0?await r.getElementRects({reference:i,floating:t,strategy:n}):x.rects),{x:d,y:h}=Dt(c,p,a)),m=-1)}return{x:d,y:h,placement:p,strategy:n,middlewareData:f}};async function yt(i,t){var e;t===void 0&&(t={});let{x:s,y:n,platform:o,rects:r,elements:l,strategy:a}=i,{boundary:c="clippingAncestors",rootBoundary:d="viewport",elementContext:h="floating",altBoundary:p=!1,padding:f=0}=it(t,i),u=Ct(f),g=l[p?h==="floating"?"reference":"floating":h],y=U(await o.getClippingRect({element:(e=await(o.isElement==null?void 0:o.isElement(g)))==null||e?g:g.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(l.floating)),boundary:c,rootBoundary:d,strategy:a})),b=h==="floating"?{x:s,y:n,width:r.floating.width,height:r.floating.height}:r.reference,v=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l.floating)),L=await(o.isElement==null?void 0:o.isElement(v))?await(o.getScale==null?void 0:o.getScale(v))||{x:1,y:1}:{x:1,y:1},x=U(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:b,offsetParent:v,strategy:a}):b);return{top:(y.top-x.top+u.top)/L.y,bottom:(x.bottom-y.bottom+u.bottom)/L.y,left:(y.left-x.left+u.left)/L.x,right:(x.right-y.right+u.right)/L.x}}var Rt=function(i){return i===void 0&&(i={}),{name:"flip",options:i,async fn(t){var e,s;let{placement:n,middlewareData:o,rects:r,initialPlacement:l,platform:a,elements:c}=t,{mainAxis:d=!0,crossAxis:h=!0,fallbackPlacements:p,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:u="none",flipAlignment:m=!0,...g}=it(i,t);if((e=o.arrow)!=null&&e.alignmentOffset)return{};let y=W(n),b=P(l),v=W(l)===l,L=await(a.isRTL==null?void 0:a.isRTL(c.floating)),x=p||(v||!m?[Z(l)]:At(l)),q=u!=="none";!p&&q&&x.push(...St(l,m,u,L));let Q=[l,...x],$=await yt(t,g),F=[],I=((s=o.flip)==null?void 0:s.overflows)||[];if(d&&F.push($[y]),h){let A=Ot(n,r,L);F.push($[A[0]],$[A[1]])}if(I=[...I,{placement:n,overflows:F}],!F.every(A=>A<=0)){var J,j;let A=(((J=o.flip)==null?void 0:J.index)||0)+1,T=Q[A];if(T&&(!(h==="alignment"?b!==P(T):!1)||I.every(D=>P(D.placement)===b?D.overflows[0]>0:!0)))return{data:{index:A,overflows:I},reset:{placement:T}};let z=(j=I.filter(M=>M.overflows[0]<=0).sort((M,D)=>M.overflows[1]-D.overflows[1])[0])==null?void 0:j.placement;if(!z)switch(f){case"bestFit":{var X;let M=(X=I.filter(D=>{if(q){let H=P(D.placement);return H===b||H==="y"}return!0}).map(D=>[D.placement,D.overflows.filter(H=>H>0).reduce((H,Yt)=>H+Yt,0)]).sort((D,H)=>D[Line truncated
|
||||
var tt=Math.min,V=Math.max,et=Math.round;var E=s=>({x:s,y:s}),Gt={left:"right",right:"left",bottom:"top",top:"bottom"},Qt={start:"end",end:"start"};function mt(s,t,e){return V(s,tt(t,e))}function it(s,t){return typeof s=="function"?s(t):s}function z(s){return s.split("-")[0]}function st(s){return s.split("-")[1]}function gt(s){return s==="x"?"y":"x"}function bt(s){return s==="y"?"height":"width"}var Zt=new Set(["top","bottom"]);function M(s){return Zt.has(z(s))?"y":"x"}function wt(s){return gt(M(s))}function Ot(s,t,e){e===void 0&&(e=!1);let i=st(s),n=wt(s),o=bt(n),r=n==="x"?i===(e?"end":"start")?"right":"left":i==="start"?"bottom":"top";return t.reference[o]>t.floating[o]&&(r=Z(r)),[r,Z(r)]}function At(s){let t=Z(s);return[lt(s),t,lt(t)]}function lt(s){return s.replace(/start|end/g,t=>Qt[t])}var Lt=["left","right"],vt=["right","left"],te=["top","bottom"],ee=["bottom","top"];function ie(s,t,e){switch(s){case"top":case"bottom":return e?t?vt:Lt:t?Lt:vt;case"left":case"right":return t?te:ee;default:return[]}}function St(s,t,e,i){let n=st(s),o=ie(z(s),e==="start",i);return n&&(o=o.map(r=>r+"-"+n),t&&(o=o.concat(o.map(lt)))),o}function Z(s){return s.replace(/left|right|bottom|top/g,t=>Gt[t])}function se(s){return{top:0,right:0,bottom:0,left:0,...s}}function Ct(s){return typeof s!="number"?se(s):{top:s,right:s,bottom:s,left:s}}function U(s){let{x:t,y:e,width:i,height:n}=s;return{width:i,height:n,top:e,left:t,right:t+i,bottom:e+n,x:t,y:e}}function Dt(s,t,e){let{reference:i,floating:n}=s,o=M(t),r=wt(t),l=bt(r),a=z(t),c=o==="y",d=i.x+i.width/2-n.width/2,h=i.y+i.height/2-n.height/2,p=i[l]/2-n[l]/2,f;switch(a){case"top":f={x:d,y:i.y-n.height};break;case"bottom":f={x:d,y:i.y+i.height};break;case"right":f={x:i.x+i.width,y:h};break;case"left":f={x:i.x-n.width,y:h};break;default:f={x:i.x,y:i.y}}switch(st(t)){case"start":f[r]-=p*(e&&c?-1:1);break;case"end":f[r]+=p*(e&&c?-1:1);break}return f}var Et=async(s,t,e)=>{let{placement:i="bottom",strategy:n="absolute",middleware:o=[],platform:r}=e,l=o.filter(Boolean),a=await(r.isRTL==null?void 0:r.isRTL(t)),c=await r.getElementRects({reference:s,floating:t,strategy:n}),{x:d,y:h}=Dt(c,i,a),p=i,f={},u=0;for(let m=0;m<l.length;m++){let{name:g,fn:y}=l[m],{x:b,y:L,data:v,reset:x}=await y({x:d,y:h,initialPlacement:i,placement:p,strategy:n,middlewareData:f,rects:c,platform:r,elements:{reference:s,floating:t}});d=b??d,h=L??h,f={...f,[g]:{...f[g],...v}},x&&u<=50&&(u++,typeof x=="object"&&(x.placement&&(p=x.placement),x.rects&&(c=x.rects===!0?await r.getElementRects({reference:s,floating:t,strategy:n}):x.rects),{x:d,y:h}=Dt(c,p,a)),m=-1)}return{x:d,y:h,placement:p,strategy:n,middlewareData:f}};async function yt(s,t){var e;t===void 0&&(t={});let{x:i,y:n,platform:o,rects:r,elements:l,strategy:a}=s,{boundary:c="clippingAncestors",rootBoundary:d="viewport",elementContext:h="floating",altBoundary:p=!1,padding:f=0}=it(t,s),u=Ct(f),g=l[p?h==="floating"?"reference":"floating":h],y=U(await o.getClippingRect({element:(e=await(o.isElement==null?void 0:o.isElement(g)))==null||e?g:g.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(l.floating)),boundary:c,rootBoundary:d,strategy:a})),b=h==="floating"?{x:i,y:n,width:r.floating.width,height:r.floating.height}:r.reference,L=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l.floating)),v=await(o.isElement==null?void 0:o.isElement(L))?await(o.getScale==null?void 0:o.getScale(L))||{x:1,y:1}:{x:1,y:1},x=U(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:b,offsetParent:L,strategy:a}):b);return{top:(y.top-x.top+u.top)/v.y,bottom:(x.bottom-y.bottom+u.bottom)/v.y,left:(y.left-x.left+u.left)/v.x,right:(x.right-y.right+u.right)/v.x}}var Rt=function(s){return s===void 0&&(s={}),{name:"flip",options:s,async fn(t){var e,i;let{placement:n,middlewareData:o,rects:r,initialPlacement:l,platform:a,elements:c}=t,{mainAxis:d=!0,crossAxis:h=!0,fallbackPlacements:p,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:u="none",flipAlignment:m=!0,...g}=it(s,t);if((e=o.arrow)!=null&&e.alignmentOffset)return{};let y=z(n),b=M(l),L=z(l)===l,v=await(a.isRTL==null?void 0:a.isRTL(c.floating)),x=p||(L||!m?[Z(l)]:At(l)),q=u!=="none";!p&&q&&x.push(...St(l,m,u,v));let Q=[l,...x],W=await yt(t,g),F=[],I=((i=o.flip)==null?void 0:i.overflows)||[];if(d&&F.push(W[y]),h){let A=Ot(n,r,v);F.push(W[A[0]],W[A[1]])}if(I=[...I,{placement:n,overflows:F}],!F.every(A=>A<=0)){var J,j;let A=(((J=o.flip)==null?void 0:J.index)||0)+1,T=Q[A];if(T&&(!(h==="alignment"?b!==M(T):!1)||I.every(D=>M(D.placement)===b?D.overflows[0]>0:!0)))return{data:{index:A,overflows:I},reset:{placement:T}};let $=(j=I.filter(P=>P.overflows[0]<=0).sort((P,D)=>P.overflows[1]-D.overflows[1])[0])==null?void 0:j.placement;if(!$)switch(f){case"bestFit":{var X;let P=(X=I.filter(D=>{if(q){let H=M(D.placement);return H===b||H==="y"}return!0}).map(D=>[D.placement,D.overflows.filter(H=>H>0).reduce((H,Yt)=>H+Yt,0)]).sort((D,H)=>D[Line truncated
|
||||
Reference in new issue
Block a user