standards wip
This commit is contained in:
1 parent
4f865b52a6
commit
7eaa8c0da2
32 files changed
+326
-98
No files matched your search
@@ -1 +1 @@
|
||||
var tt=Math.min,$=Math.max,et=Math.round;var k=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 $(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 B(s){return Zt.has(z(s))?"y":"x"}function yt(s){return gt(B(s))}function Ot(s,t,e){e===void 0&&(e=!1);let i=st(s),n=yt(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 vt=["left","right"],Lt=["right","left"],te=["top","bottom"],ee=["bottom","top"];function ie(s,t,e){switch(s){case"top":case"bottom":return e?t?Lt:vt:t?vt:Lt;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=B(t),r=yt(t),l=bt(r),a=z(t),c=o==="y",h=i.x+i.width/2-n.width/2,d=i.y+i.height/2-n.height/2,u=i[l]/2-n[l]/2,f;switch(a){case"top":f={x:h,y:i.y-n.height};break;case"bottom":f={x:h,y:i.y+i.height};break;case"right":f={x:i.x+i.width,y:d};break;case"left":f={x:i.x-n.width,y:d};break;default:f={x:i.x,y:i.y}}switch(st(t)){case"start":f[r]-=u*(e&&c?-1:1);break;case"end":f[r]+=u*(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:h,y:d}=Dt(c,i,a),u=i,f={},p=0;for(let m=0;m<l.length;m++){let{name:g,fn:w}=l[m],{x:b,y:v,data:O,reset:x}=await w({x:h,y:d,initialPlacement:i,placement:u,strategy:n,middlewareData:f,rects:c,platform:r,elements:{reference:s,floating:t}});h=b??h,d=v??d,f={...f,[g]:{...f[g],...O}},x&&p<=50&&(p++,typeof x=="object"&&(x.placement&&(u=x.placement),x.rects&&(c=x.rects===!0?await r.getElementRects({reference:s,floating:t,strategy:n}):x.rects),{x:h,y:d}=Dt(c,u,a)),m=-1)}return{x:h,y:d,placement:u,strategy:n,middlewareData:f}};async function wt(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:h="viewport",elementContext:d="floating",altBoundary:u=!1,padding:f=0}=it(t,s),p=Ct(f),g=l[u?d==="floating"?"reference":"floating":d],w=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:h,strategy:a})),b=d==="floating"?{x:i,y:n,width:r.floating.width,height:r.floating.height}:r.reference,v=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l.floating)),O=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:(w.top-x.top+p.top)/O.y,bottom:(x.bottom-w.bottom+p.bottom)/O.y,left:(w.left-x.left+p.left)/O.x,right:(x.right-w.right+p.right)/O.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:h=!0,crossAxis:d=!0,fallbackPlacements:u,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:m=!0,...g}=it(s,t);if((e=o.arrow)!=null&&e.alignmentOffset)return{};let w=z(n),b=B(l),v=z(l)===l,O=await(a.isRTL==null?void 0:a.isRTL(c.floating)),x=u||(v||!m?[Z(l)]:At(l)),q=p!=="none";!u&&q&&x.push(...St(l,m,p,O));let Y=[l,...x],W=await wt(t,g),L=[],S=((i=o.flip)==null?void 0:i.overflows)||[];if(h&&L.push(W[w]),d){let E=Ot(n,r,O);L.push(W[E[0]],W[E[1]])}if(S=[...S,{placement:n,overflows:L}],!L.every(E=>E<=0)){var V,G;let E=(((V=o.flip)==null?void 0:V.index)||0)+1,J=Y[E];if(J&&(!(d==="alignment"?b!==B(J):!1)||S.every(I=>B(I.placement)===b?I.overflows[0]>0:!0)))return{data:{index:E,overflows:S},reset:{placement:J}};let R=(G=S.filter(M=>M.overflows[0]<=0).sort((M,I)=>M.overflows[1]-I.overflows[1])[0])==null?void 0:G.placement;if(!R)switch(f){case"bestFit":{var Q;let M=(Q=S.filter(I=>{if(q){let H=B(I.placement);return H===b||H==="y"}return!0}).map(I=>[I.placement,I.overflows.filter(H=>H>0).reduce((H,Yt)=>H+Yt,0)]).sort((I,H)=>I[Line truncated
|
||||
var tt=Math.min,$=Math.max,et=Math.round;var k=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 $(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 B(s){return Zt.has(z(s))?"y":"x"}function yt(s){return gt(B(s))}function Ot(s,t,e){e===void 0&&(e=!1);let i=st(s),n=yt(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 vt=["left","right"],Lt=["right","left"],te=["top","bottom"],ee=["bottom","top"];function ie(s,t,e){switch(s){case"top":case"bottom":return e?t?Lt:vt:t?vt:Lt;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=B(t),r=yt(t),l=bt(r),a=z(t),c=o==="y",h=i.x+i.width/2-n.width/2,d=i.y+i.height/2-n.height/2,u=i[l]/2-n[l]/2,f;switch(a){case"top":f={x:h,y:i.y-n.height};break;case"bottom":f={x:h,y:i.y+i.height};break;case"right":f={x:i.x+i.width,y:d};break;case"left":f={x:i.x-n.width,y:d};break;default:f={x:i.x,y:i.y}}switch(st(t)){case"start":f[r]-=u*(e&&c?-1:1);break;case"end":f[r]+=u*(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:h,y:d}=Dt(c,i,a),u=i,f={},p=0;for(let m=0;m<l.length;m++){let{name:g,fn:w}=l[m],{x:b,y:v,data:O,reset:x}=await w({x:h,y:d,initialPlacement:i,placement:u,strategy:n,middlewareData:f,rects:c,platform:r,elements:{reference:s,floating:t}});h=b??h,d=v??d,f={...f,[g]:{...f[g],...O}},x&&p<=50&&(p++,typeof x=="object"&&(x.placement&&(u=x.placement),x.rects&&(c=x.rects===!0?await r.getElementRects({reference:s,floating:t,strategy:n}):x.rects),{x:h,y:d}=Dt(c,u,a)),m=-1)}return{x:h,y:d,placement:u,strategy:n,middlewareData:f}};async function wt(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:h="viewport",elementContext:d="floating",altBoundary:u=!1,padding:f=0}=it(t,s),p=Ct(f),g=l[u?d==="floating"?"reference":"floating":d],w=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:h,strategy:a})),b=d==="floating"?{x:i,y:n,width:r.floating.width,height:r.floating.height}:r.reference,v=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l.floating)),O=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:(w.top-x.top+p.top)/O.y,bottom:(x.bottom-w.bottom+p.bottom)/O.y,left:(w.left-x.left+p.left)/O.x,right:(x.right-w.right+p.right)/O.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:h=!0,crossAxis:d=!0,fallbackPlacements:u,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:m=!0,...g}=it(s,t);if((e=o.arrow)!=null&&e.alignmentOffset)return{};let w=z(n),b=B(l),v=z(l)===l,O=await(a.isRTL==null?void 0:a.isRTL(c.floating)),x=u||(v||!m?[Z(l)]:At(l)),q=p!=="none";!u&&q&&x.push(...St(l,m,p,O));let Y=[l,...x],W=await wt(t,g),L=[],S=((i=o.flip)==null?void 0:i.overflows)||[];if(h&&L.push(W[w]),d){let E=Ot(n,r,O);L.push(W[E[0]],W[E[1]])}if(S=[...S,{placement:n,overflows:L}],!L.every(E=>E<=0)){var V,G;let E=(((V=o.flip)==null?void 0:V.index)||0)+1,J=Y[E];if(J&&(!(d==="alignment"?b!==B(J):!1)||S.every(I=>B(I.placement)===b?I.overflows[0]>0:!0)))return{data:{index:E,overflows:S},reset:{placement:J}};let R=(G=S.filter(M=>M.overflows[0]<=0).sort((M,I)=>M.overflows[1]-I.overflows[1])[0])==null?void 0:G.placement;if(!R)switch(f){case"bestFit":{var Q;let M=(Q=S.filter(I=>{if(q){let H=B(I.placement);return H===b||H==="y"}return!0}).map(I=>[I.placement,I.overflows.filter(H=>H>0).reduce((H,Yt)=>H+Yt,0)]).sort((I,H)=>I[Line truncated
|
||||
Reference in new issue
Block a user