UNPKG

@anoki/fse-ui

Version:

FSE UI components library

3 lines (2 loc) 2.13 kB
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=["top","right","bottom","left"],f=Math.min,p=Math.max,O=Math.round,S=Math.floor,y=t=>({x:t,y:t}),M={left:"right",right:"left",bottom:"top",top:"bottom"},j={start:"end",end:"start"};function w(t,e,n){return p(t,f(e,n))}function C(t,e){return typeof t=="function"?t(e):t}function l(t){return t.split("-")[0]}function a(t){return t.split("-")[1]}function d(t){return t==="x"?"y":"x"}function h(t){return t==="y"?"height":"width"}const L=new Set(["top","bottom"]);function x(t){return L.has(l(t))?"y":"x"}function A(t){return d(x(t))}function T(t,e,n){n===void 0&&(n=!1);const r=a(t),i=A(t),o=h(i);let s=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[o]>e.floating[o]&&(s=g(s)),[s,g(s)]}function E(t){const e=g(t);return[c(t),e,c(e)]}function c(t){return t.replace(/start|end/g,e=>j[e])}const m=["left","right"],u=["right","left"],R=["top","bottom"],v=["bottom","top"];function k(t,e,n){switch(t){case"top":case"bottom":return n?e?u:m:e?m:u;case"left":case"right":return e?R:v;default:return[]}}function q(t,e,n,r){const i=a(t);let o=k(l(t),n==="start",r);return i&&(o=o.map(s=>s+"-"+i),e&&(o=o.concat(o.map(c)))),o}function g(t){return t.replace(/left|right|bottom|top/g,e=>M[e])}function b(t){return{top:0,right:0,bottom:0,left:0,...t}}function z(t){return typeof t!="number"?b(t):{top:t,right:t,bottom:t,left:t}}function B(t){const{x:e,y:n,width:r,height:i}=t;return{width:r,height:i,top:n,left:e,right:e+r,bottom:n+i,x:e,y:n}}exports.clamp=w;exports.createCoords=y;exports.evaluate=C;exports.expandPaddingObject=b;exports.floor=S;exports.getAlignment=a;exports.getAlignmentAxis=A;exports.getAlignmentSides=T;exports.getAxisLength=h;exports.getExpandedPlacements=E;exports.getOppositeAlignmentPlacement=c;exports.getOppositeAxis=d;exports.getOppositeAxisPlacements=q;exports.getOppositePlacement=g;exports.getPaddingObject=z;exports.getSide=l;exports.getSideAxis=x;exports.max=p;exports.min=f;exports.rectToClientRect=B;exports.round=O;exports.sides=P; //# sourceMappingURL=index.cjs666.js.map