@nild/components 0.0.5 → 0.0.7

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.
@@ -0,0 +1 @@
1
+ import{evaluate as H,getSideAxis as B,getSide as W,clamp as q,getOppositePlacement as Z,getExpandedPlacements as _,getOppositeAxisPlacements as $,getAlignmentSides as J,getPaddingObject as K,getAlignmentAxis as N,getAlignment as z,rectToClientRect as G,getOppositeAxis as M,getAxisLength as Q,min as U}from"./floating-ui.utils.js";function X(l,i,m){let{reference:n,floating:c}=l;const t=B(i),r=N(i),s=Q(r),p=W(i),d=t==="y",g=n.x+n.width/2-c.width/2,a=n.y+n.height/2-c.height/2,f=n[s]/2-c[s]/2;let e;switch(p){case"top":e={x:g,y:n.y-c.height};break;case"bottom":e={x:g,y:n.y+n.height};break;case"right":e={x:n.x+n.width,y:a};break;case"left":e={x:n.x-c.width,y:a};break;default:e={x:n.x,y:n.y}}switch(z(i)){case"start":e[r]-=f*(m&&d?-1:1);break;case"end":e[r]+=f*(m&&d?-1:1);break}return e}const ee=async(l,i,m)=>{const{placement:n="bottom",strategy:c="absolute",middleware:t=[],platform:r}=m,s=t.filter(Boolean),p=await(r.isRTL==null?void 0:r.isRTL(i));let d=await r.getElementRects({reference:l,floating:i,strategy:c}),{x:g,y:a}=X(d,n,p),f=n,e={},o=0;for(let y=0;y<s.length;y++){const{name:u,fn:h}=s[y],{x,y:w,data:R,reset:A}=await h({x:g,y:a,initialPlacement:n,placement:f,strategy:c,middlewareData:e,rects:d,platform:r,elements:{reference:l,floating:i}});g=x??g,a=w??a,e={...e,[u]:{...e[u],...R}},A&&o<=50&&(o++,typeof A=="object"&&(A.placement&&(f=A.placement),A.rects&&(d=A.rects===!0?await r.getElementRects({reference:l,floating:i,strategy:c}):A.rects),{x:g,y:a}=X(d,f,p)),y=-1)}return{x:g,y:a,placement:f,strategy:c,middlewareData:e}};async function I(l,i){var m;i===void 0&&(i={});const{x:n,y:c,platform:t,rects:r,elements:s,strategy:p}=l,{boundary:d="clippingAncestors",rootBoundary:g="viewport",elementContext:a="floating",altBoundary:f=!1,padding:e=0}=H(i,l),o=K(e),y=s[f?a==="floating"?"reference":"floating":a],u=G(await t.getClippingRect({element:(m=await(t.isElement==null?void 0:t.isElement(y)))==null||m?y:y.contextElement||await(t.getDocumentElement==null?void 0:t.getDocumentElement(s.floating)),boundary:d,rootBoundary:g,strategy:p})),h=a==="floating"?{x:n,y:c,width:r.floating.width,height:r.floating.height}:r.reference,x=await(t.getOffsetParent==null?void 0:t.getOffsetParent(s.floating)),w=await(t.isElement==null?void 0:t.isElement(x))?await(t.getScale==null?void 0:t.getScale(x))||{x:1,y:1}:{x:1,y:1},R=G(t.convertOffsetParentRelativeRectToViewportRelativeRect?await t.convertOffsetParentRelativeRectToViewportRelativeRect({elements:s,rect:h,offsetParent:x,strategy:p}):h);return{top:(u.top-R.top+o.top)/w.y,bottom:(R.bottom-u.bottom+o.bottom)/w.y,left:(u.left-R.left+o.left)/w.x,right:(R.right-u.right+o.right)/w.x}}const te=l=>({name:"arrow",options:l,async fn(i){const{x:m,y:n,placement:c,rects:t,platform:r,elements:s,middlewareData:p}=i,{element:d,padding:g=0}=H(l,i)||{};if(d==null)return{};const a=K(g),f={x:m,y:n},e=N(c),o=Q(e),y=await r.getDimensions(d),u=e==="y",h=u?"top":"left",x=u?"bottom":"right",w=u?"clientHeight":"clientWidth",R=t.reference[o]+t.reference[e]-f[e]-t.floating[o],A=f[e]-t.reference[e],C=await(r.getOffsetParent==null?void 0:r.getOffsetParent(d));let T=C?C[w]:0;(!T||!await(r.isElement==null?void 0:r.isElement(C)))&&(T=s.floating[w]||t.floating[o]);const F=R/2-A/2,D=T/2-y[o]/2-1,P=U(a[h],D),V=U(a[x],D),S=P,j=T-y[o]-V,v=T/2-y[o]/2+F,L=q(S,v,j),k=!p.arrow&&z(c)!=null&&v!==L&&t.reference[o]/2-(v<S?P:V)-y[o]/2<0,b=k?v<S?v-S:v-j:0;return{[e]:f[e]+b,data:{[e]:L,centerOffset:v-L-b,...k&&{alignmentOffset:b}},reset:k}}}),ne=function(l){return l===void 0&&(l={}),{name:"flip",options:l,async fn(i){var m,n;const{placement:c,middlewareData:t,rects:r,initialPlacement:s,platform:p,elements:d}=i,{mainAxis:g=!0,crossAxis:a=!0,fallbackPlacements:f,fallbackStrategy:e="bestFit",fallbackAxisSideDirection:o="none",flipAlignment:y=!0,...u}=H(l,i);if((m=t.arrow)!=null&&m.alignmentOffset)return{};const h=W(c),x=B(s),w=W(s)===s,R=await(p.isRTL==null?void 0:p.isRTL(d.floating)),A=f||(w||!y?[Z(s)]:_(s)),C=o!=="none";!f&&C&&A.push(...$(s,y,o,R));const T=[s,...A],F=await I(i,u),D=[];let P=((n=t.flip)==null?void 0:n.overflows)||[];if(g&&D.push(F[h]),a){const v=J(c,r,R);D.push(F[v[0]],F[v[1]])}if(P=[...P,{placement:c,overflows:D}],!D.every(v=>v<=0)){var V,S;const v=(((V=t.flip)==null?void 0:V.index)||0)+1,L=T[v];if(L&&(!(a==="alignment"&&x!==B(L))||P.every(b=>b.overflows[0]>0&&B(b.placement)===x)))return{data:{index:v,overflows:P},reset:{placement:L}};let k=(S=P.filter(b=>b.overflows[0]<=0).sort((b,O)=>b.overflows[1]-O.overflows[1])[0])==null?void 0:S.placement;if(!k)switch(e){case"bestFit":{var j;const b=(j=P.filter(O=>{if(C){const E=B(O.placement);return E===x||E==="y"}return!0}).map(O=>[O.placement,O.overflows.filter(E=>E>0).reduce((E,Y)=>E+Y,0)]).sort((O,E)=>O[1]-E[1])[0])==null?void 0:j[0];b&&(k=b);break}case"initialPlacement":k=s;break}if(c!==k)return{reset:{placement:k}}}return{}}}};async function ae(l,i){const{placement:m,platform:n,elements:c}=l,t=await(n.isRTL==null?void 0:n.isRTL(c.floating)),r=W(m),s=z(m),p=B(m)==="y",d=["left","top"].includes(r)?-1:1,g=t&&p?-1:1,a=H(i,l);let{mainAxis:f,crossAxis:e,alignmentAxis:o}=typeof a=="number"?{mainAxis:a,crossAxis:0,alignmentAxis:null}:{mainAxis:a.mainAxis||0,crossAxis:a.crossAxis||0,alignmentAxis:a.alignmentAxis};return s&&typeof o=="number"&&(e=s==="end"?o*-1:o),p?{x:e*g,y:f*d}:{x:f*d,y:e*g}}const ie=function(l){return l===void 0&&(l=0),{name:"offset",options:l,async fn(i){var m,n;const{x:c,y:t,placement:r,middlewareData:s}=i,p=await ae(i,l);return r===((m=s.offset)==null?void 0:m.placement)&&(n=s.arrow)!=null&&n.alignmentOffset?{}:{x:c+p.x,y:t+p.y,data:{...p,placement:r}}}}},le=function(l){return l===void 0&&(l={}),{name:"shift",options:l,async fn(i){const{x:m,y:n,placement:c}=i,{mainAxis:t=!0,crossAxis:r=!1,limiter:s={fn:u=>{let{x:h,y:x}=u;return{x:h,y:x}}},...p}=H(l,i),d={x:m,y:n},g=await I(i,p),a=B(W(c)),f=M(a);let e=d[f],o=d[a];if(t){const u=f==="y"?"top":"left",h=f==="y"?"bottom":"right",x=e+g[u],w=e-g[h];e=q(x,e,w)}if(r){const u=a==="y"?"top":"left",h=a==="y"?"bottom":"right",x=o+g[u],w=o-g[h];o=q(x,o,w)}const y=s.fn({...i,[f]:e,[a]:o});return{...y,data:{x:y.x-m,y:y.y-n,enabled:{[f]:t,[a]:r}}}}}};export{te as arrow,ee as computePosition,I as detectOverflow,ne as flip,ie as offset,G as rectToClientRect,le as shift};
@@ -0,0 +1 @@
1
+ import{offset as it,shift as rt,flip as st,arrow as lt,computePosition as ct}from"./floating-ui.core.js";import{createCoords as x,round as A,max as W,min as S,rectToClientRect as $,floor as D}from"./floating-ui.utils.js";import{isElement as v,getDocumentElement as b,getOverflowAncestors as N,getComputedStyle as L,isHTMLElement as R,getWindow as C,isTopLayer as V,getParentNode as O,isLastTraversableNode as P,isTableElement as ft,isContainingBlock as K,getContainingBlock as at,getNodeName as I,isOverflowElement as M,getNodeScroll as z,getFrameElement as j,isWebKit as G}from"./floating-ui.utils.dom.js";function J(t){const e=L(t);let n=parseFloat(e.width)||0,o=parseFloat(e.height)||0;const i=R(t),s=i?t.offsetWidth:n,r=i?t.offsetHeight:o,l=A(n)!==s||A(o)!==r;return l&&(n=s,o=r),{width:n,height:o,$:l}}function k(t){return v(t)?t:t.contextElement}function F(t){const e=k(t);if(!R(e))return x(1);const n=e.getBoundingClientRect(),{width:o,height:i,$:s}=J(e);let r=(s?A(n.width):n.width)/o,l=(s?A(n.height):n.height)/i;return(!r||!Number.isFinite(r))&&(r=1),(!l||!Number.isFinite(l))&&(l=1),{x:r,y:l}}const ut=x(0);function Q(t){const e=C(t);return!G()||!e.visualViewport?ut:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function ht(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==C(t)?!1:e}function E(t,e,n,o){e===void 0&&(e=!1),n===void 0&&(n=!1);const i=t.getBoundingClientRect(),s=k(t);let r=x(1);e&&(o?v(o)&&(r=F(o)):r=F(t));const l=ht(s,n,o)?Q(s):x(0);let c=(i.left+l.x)/r.x,f=(i.top+l.y)/r.y,a=i.width/r.x,d=i.height/r.y;if(s){const p=C(s),u=o&&v(o)?C(o):o;let w=p,g=j(w);for(;g&&o&&u!==w;){const m=F(g),h=g.getBoundingClientRect(),y=L(g),T=h.left+(g.clientLeft+parseFloat(y.paddingLeft))*m.x,B=h.top+(g.clientTop+parseFloat(y.paddingTop))*m.y;c*=m.x,f*=m.y,a*=m.x,d*=m.y,c+=T,f+=B,w=C(g),g=j(w)}}return $({width:a,height:d,x:c,y:f})}function q(t,e){const n=z(t).scrollLeft;return e?e.left+n:E(b(t)).left+n}function U(t,e,n){n===void 0&&(n=!1);const o=t.getBoundingClientRect(),i=o.left+e.scrollLeft-(n?0:q(t,o)),s=o.top+e.scrollTop;return{x:i,y:s}}function dt(t){let{elements:e,rect:n,offsetParent:o,strategy:i}=t;const s=i==="fixed",r=b(o),l=e?V(e.floating):!1;if(o===r||l&&s)return n;let c={scrollLeft:0,scrollTop:0},f=x(1);const a=x(0),d=R(o);if((d||!d&&!s)&&((I(o)!=="body"||M(r))&&(c=z(o)),R(o))){const u=E(o);f=F(o),a.x=u.x+o.clientLeft,a.y=u.y+o.clientTop}const p=r&&!d&&!s?U(r,c,!0):x(0);return{width:n.width*f.x,height:n.height*f.y,x:n.x*f.x-c.scrollLeft*f.x+a.x+p.x,y:n.y*f.y-c.scrollTop*f.y+a.y+p.y}}function gt(t){return Array.from(t.getClientRects())}function pt(t){const e=b(t),n=z(t),o=t.ownerDocument.body,i=W(e.scrollWidth,e.clientWidth,o.scrollWidth,o.clientWidth),s=W(e.scrollHeight,e.clientHeight,o.scrollHeight,o.clientHeight);let r=-n.scrollLeft+q(t);const l=-n.scrollTop;return L(o).direction==="rtl"&&(r+=W(e.clientWidth,o.clientWidth)-i),{width:i,height:s,x:r,y:l}}function mt(t,e){const n=C(t),o=b(t),i=n.visualViewport;let s=o.clientWidth,r=o.clientHeight,l=0,c=0;if(i){s=i.width,r=i.height;const f=G();(!f||f&&e==="fixed")&&(l=i.offsetLeft,c=i.offsetTop)}return{width:s,height:r,x:l,y:c}}function yt(t,e){const n=E(t,!0,e==="fixed"),o=n.top+t.clientTop,i=n.left+t.clientLeft,s=R(t)?F(t):x(1),r=t.clientWidth*s.x,l=t.clientHeight*s.y,c=i*s.x,f=o*s.y;return{width:r,height:l,x:c,y:f}}function X(t,e,n){let o;if(e==="viewport")o=mt(t,n);else if(e==="document")o=pt(b(t));else if(v(e))o=yt(e,n);else{const i=Q(t);o={x:e.x-i.x,y:e.y-i.y,width:e.width,height:e.height}}return $(o)}function Y(t,e){const n=O(t);return n===e||!v(n)||P(n)?!1:L(n).position==="fixed"||Y(n,e)}function xt(t,e){const n=e.get(t);if(n)return n;let o=N(t,[],!1).filter(l=>v(l)&&I(l)!=="body"),i=null;const s=L(t).position==="fixed";let r=s?O(t):t;for(;v(r)&&!P(r);){const l=L(r),c=K(r);!c&&l.position==="fixed"&&(i=null),(s?!c&&!i:!c&&l.position==="static"&&i&&["absolute","fixed"].includes(i.position)||M(r)&&!c&&Y(t,r))?o=o.filter(f=>f!==r):i=l,r=O(r)}return e.set(t,o),o}function wt(t){let{element:e,boundary:n,rootBoundary:o,strategy:i}=t;const s=[...n==="clippingAncestors"?V(e)?[]:xt(e,this._c):[].concat(n),o],r=s[0],l=s.reduce((c,f)=>{const a=X(e,f,i);return c.top=W(a.top,c.top),c.right=S(a.right,c.right),c.bottom=S(a.bottom,c.bottom),c.left=W(a.left,c.left),c},X(e,r,i));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function vt(t){const{width:e,height:n}=J(t);return{width:e,height:n}}function bt(t,e,n){const o=R(e),i=b(e),s=n==="fixed",r=E(t,!0,s,e);let l={scrollLeft:0,scrollTop:0};const c=x(0);function f(){c.x=q(i)}if(o||!o&&!s)if((I(e)!=="body"||M(i))&&(l=z(e)),o){const u=E(e,!0,s,e);c.x=u.x+e.clientLeft,c.y=u.y+e.clientTop}else i&&f();s&&!o&&i&&f();const a=i&&!o&&!s?U(i,l):x(0),d=r.left+l.scrollLeft-c.x-a.x,p=r.top+l.scrollTop-c.y-a.y;return{x:d,y:p,width:r.width,height:r.height}}function _(t){return L(t).position==="static"}function Z(t,e){if(!R(t)||L(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return b(t)===n&&(n=n.ownerDocument.body),n}function tt(t,e){const n=C(t);if(V(t))return n;if(!R(t)){let i=O(t);for(;i&&!P(i);){if(v(i)&&!_(i))return i;i=O(i)}return n}let o=Z(t,e);for(;o&&ft(o)&&_(o);)o=Z(o,e);return o&&P(o)&&_(o)&&!K(o)?n:o||at(t)||n}const Lt=async function(t){const e=this.getOffsetParent||tt,n=this.getDimensions,o=await n(t.floating);return{reference:bt(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function Rt(t){return L(t).direction==="rtl"}const et={convertOffsetParentRelativeRectToViewportRelativeRect:dt,getDocumentElement:b,getClippingRect:wt,getOffsetParent:tt,getElementRects:Lt,getClientRects:gt,getDimensions:vt,getScale:F,isElement:v,isRTL:Rt};function nt(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function Tt(t,e){let n=null,o;const i=b(t);function s(){var l;clearTimeout(o),(l=n)==null||l.disconnect(),n=null}function r(l,c){l===void 0&&(l=!1),c===void 0&&(c=1),s();const f=t.getBoundingClientRect(),{left:a,top:d,width:p,height:u}=f;if(l||e(),!p||!u)return;const w=D(d),g=D(i.clientWidth-(a+p)),m=D(i.clientHeight-(d+u)),h=D(a),y={rootMargin:-w+"px "+-g+"px "+-m+"px "+-h+"px",threshold:W(0,S(1,c))||1};let T=!0;function B(ot){const H=ot[0].intersectionRatio;if(H!==c){if(!T)return r();H?r(!1,H):o=setTimeout(()=>{r(!1,1e-7)},1e3)}H===1&&!nt(f,t.getBoundingClientRect())&&r(),T=!1}try{n=new IntersectionObserver(B,{...y,root:i.ownerDocument})}catch{n=new IntersectionObserver(B,y)}n.observe(t)}return r(!0),s}function Ct(t,e,n,o){o===void 0&&(o={});const{ancestorScroll:i=!0,ancestorResize:s=!0,elementResize:r=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:c=!1}=o,f=k(t),a=i||s?[...f?N(f):[],...N(e)]:[];a.forEach(h=>{i&&h.addEventListener("scroll",n,{passive:!0}),s&&h.addEventListener("resize",n)});const d=f&&l?Tt(f,n):null;let p=-1,u=null;r&&(u=new ResizeObserver(h=>{let[y]=h;y&&y.target===f&&u&&(u.unobserve(e),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var T;(T=u)==null||T.observe(e)})),n()}),f&&!c&&u.observe(f),u.observe(e));let w,g=c?E(t):null;c&&m();function m(){const h=E(t);g&&!nt(g,h)&&n(),g=h,w=requestAnimationFrame(m)}return n(),()=>{var h;a.forEach(y=>{i&&y.removeEventListener("scroll",n),s&&y.removeEventListener("resize",n)}),d?.(),(h=u)==null||h.disconnect(),u=null,c&&cancelAnimationFrame(w)}}const Et=it,Wt=rt,Ft=st,Ot=lt,Bt=(t,e,n)=>{const o=new Map,i={platform:et,...n},s={...i.platform,_c:o};return ct(t,e,{...i,platform:s})};export{Ot as arrow,Ct as autoUpdate,Bt as computePosition,Ft as flip,N as getOverflowAncestors,Et as offset,et as platform,Wt as shift};
@@ -1 +1 @@
1
- import{jsx as O}from"react/jsx-runtime";import{computePosition as F,offset as G,shift as H,flip as J,arrow as K,autoUpdate as M}from"../../node_modules/.pnpm/@floating-ui_dom@1.7.1/node_modules/@floating-ui/dom/dist/floating-ui.dom.js";import{useControllableState as N,useStableCallback as x,useIsomorphicLayoutEffect as P}from"@nild/hooks";import{getDPR as Q,roundByDPR as u}from"@nild/shared/utils";import{useRef as b,useState as f,useMemo as W,Children as X,isValidElement as g,cloneElement as j}from"react";import"../../portal/Arrow.js";import k from"../../portal/Portal.js";import Y from"../../transition/Transition.js";import h from"../../trigger/Trigger.js";const Z=(I,{placement:m="bottom",strategy:w="absolute",offset:C=12,open:L,defaultOpen:E=!1}={})=>{const t=b(null),a=b(null),c=b(null),[n,R]=f(E),[r,S]=N(L,E),[s,T]=f({x:0,y:0}),[l,U]=f({x:0,y:0}),[o,V]=f(m.split("-")[0]),$=W(()=>{const e=o==="top"||o==="bottom";return{[o==="left"?"right":"left"]:e?l.x:l.x-s.x,[o==="top"?"bottom":"top"]:e?l.y-s.y:l.y}},[o,l,s]),q={top:"down",bottom:"up",left:"right",right:"left"}[o];let y,d,i;X.forEach(I,e=>{g(e)&&e.type!==h&&e.type!==k&&(y=e),g(e)&&e.type===h&&(d=e),g(e)&&e.type===k&&(i=e)});const z=x(e=>{if(d)return j(d,{...e,ref:t});if(y)return O(h,{...e,ref:t,children:y})}),A=x(e=>{if(i)return O(Y,{visible:r,children:n&&j(i,{...i.props,...e,style:{transform:`translate(${s.x}px, ${s.y}px)`,...Q()>=1.5&&{willChange:"transform"}},ref:a,arrow:{ref:c,style:$,orientation:q}})})}),v=x(()=>{!t.current||!a.current||F(t.current,a.current,{placement:m,strategy:w,middleware:[G(C),H(),J(),c.current&&K({element:c.current})]}).then(({x:e,y:D,placement:B,middlewareData:{arrow:p}})=>{T({x:u(e),y:u(D)}),V(B.split("-")[0]),U({x:u(p?.x??e),y:u(p?.y??D)})})});return P(()=>{r&&!n?R(!0):r&&n&&v()},[r,n]),P(()=>{if(!(!t.current||!a.current||!r))return M(t.current,a.current,v)},[m,w,C,r]),[r,{setOpen:S,renderTrigger:z,renderPortal:A}]};export{Z as default};
1
+ import{jsx as O}from"react/jsx-runtime";import{computePosition as F,offset as G,shift as H,flip as J,arrow as K,autoUpdate as M}from"../../_lib/floating-ui.dom.js";import{useControllableState as N,useStableCallback as x,useIsomorphicLayoutEffect as P}from"@nild/hooks";import{getDPR as Q,roundByDPR as u}from"@nild/shared/utils";import{useRef as b,useState as f,useMemo as W,Children as X,isValidElement as g,cloneElement as j}from"react";import"../../portal/Arrow.js";import k from"../../portal/Portal.js";import Y from"../../transition/Transition.js";import h from"../../trigger/Trigger.js";const Z=(I,{placement:m="bottom",strategy:w="absolute",offset:C=12,open:L,defaultOpen:E=!1}={})=>{const t=b(null),a=b(null),c=b(null),[n,R]=f(E),[r,S]=N(L,E),[s,T]=f({x:0,y:0}),[l,U]=f({x:0,y:0}),[o,V]=f(m.split("-")[0]),$=W(()=>{const e=o==="top"||o==="bottom";return{[o==="left"?"right":"left"]:e?l.x:l.x-s.x,[o==="top"?"bottom":"top"]:e?l.y-s.y:l.y}},[o,l,s]),q={top:"down",bottom:"up",left:"right",right:"left"}[o];let y,d,i;X.forEach(I,e=>{g(e)&&e.type!==h&&e.type!==k&&(y=e),g(e)&&e.type===h&&(d=e),g(e)&&e.type===k&&(i=e)});const z=x(e=>{if(d)return j(d,{...e,ref:t});if(y)return O(h,{...e,ref:t,children:y})}),A=x(e=>{if(i)return O(Y,{visible:r,children:n&&j(i,{...i.props,...e,style:{transform:`translate(${s.x}px, ${s.y}px)`,...Q()>=1.5&&{willChange:"transform"}},ref:a,arrow:{ref:c,style:$,orientation:q}})})}),v=x(()=>{!t.current||!a.current||F(t.current,a.current,{placement:m,strategy:w,middleware:[G(C),H(),J(),c.current&&K({element:c.current})]}).then(({x:e,y:D,placement:B,middlewareData:{arrow:p}})=>{T({x:u(e),y:u(D)}),V(B.split("-")[0]),U({x:u(p?.x??e),y:u(p?.y??D)})})});return P(()=>{r&&!n?R(!0):r&&n&&v()},[r,n]),P(()=>{if(!(!t.current||!a.current||!r))return M(t.current,a.current,v)},[m,w,C,r]),[r,{setOpen:S,renderTrigger:z,renderPortal:A}]};export{Z as default};
@@ -1,7 +1,8 @@
1
- import { ButtonHTMLAttributes } from 'react';
1
+ import { ForwardRefExoticComponent, ButtonHTMLAttributes, HTMLAttributes, ReactNode, RefAttributes } from 'react';
2
2
  import { SwitchVariant, SwitchSize, SwitchShape } from './style';
3
3
  export interface SwitchProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'value' | 'defaultValue' | 'onChange'> {
4
4
  className?: string;
5
+ children?: ReactNode;
5
6
  variant?: SwitchVariant;
6
7
  size?: SwitchSize;
7
8
  shape?: SwitchShape;
@@ -10,10 +11,14 @@ export interface SwitchProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement
10
11
  value?: boolean;
11
12
  defaultValue?: boolean;
12
13
  disabled?: boolean;
13
- checkedContent?: React.ReactNode;
14
- uncheckedContent?: React.ReactNode;
15
- thumbContent?: React.ReactNode;
16
14
  onChange?: (checked: boolean) => void;
17
15
  }
18
- declare const Switch: import('react').ForwardRefExoticComponent<SwitchProps & import('react').RefAttributes<HTMLButtonElement>>;
16
+ declare const Switch: ForwardRefExoticComponent<SwitchProps & RefAttributes<HTMLButtonElement>> & {
17
+ Checked: typeof Checked;
18
+ Unchecked: typeof Unchecked;
19
+ Thumb: typeof Thumb;
20
+ };
21
+ declare const Checked: ForwardRefExoticComponent<HTMLAttributes<HTMLDivElement> & RefAttributes<HTMLDivElement>>;
22
+ declare const Unchecked: ForwardRefExoticComponent<HTMLAttributes<HTMLDivElement> & RefAttributes<HTMLDivElement>>;
23
+ declare const Thumb: ForwardRefExoticComponent<HTMLAttributes<HTMLDivElement> & RefAttributes<HTMLDivElement>>;
19
24
  export default Switch;
@@ -1 +1 @@
1
- import{jsxs as N,jsx as s}from"react/jsx-runtime";import{useControllableState as M}from"@nild/hooks";import{cnMerge as a}from"@nild/shared/utils";import{forwardRef as y}from"react";import{DISABLED_CLS as L}from"../_shared/style/index.js";import{SIZE_VAR_MAP as P,VARIANT_TRACK_CLS_MAP as h,VARIANT_THUMB_CLS_MAP as I,SHAPE_CLS_MAP as o,VARIANT_CLS_MAP as R,SIZE_CLS_MAP as j}from"./style/index.js";const l=y(({className:d,variant:e="solid",size:c="medium",shape:i="round",checked:m,defaultChecked:f,value:u,defaultValue:g,disabled:v,checkedContent:p,uncheckedContent:w,thumbContent:A,onChange:n,style:C,..._},x)=>{const S={"--nd-switch-height":P[c]},[t,b]=M(m??u,f??g??!1),k=()=>{b(r=>(n?.(!r),!r))};return N("button",{..._,type:"button",role:"switch","aria-checked":t,disabled:v,className:a("nd-switch",["relative","inline-block","font-sans","overflow-hidden","cursor-pointer"],["h-[var(--nd-switch-height)]"],L,R[e],j[c],o[i],d),style:{...S,...C},ref:x,onClick:k,children:[s("div",{className:a("h-[var(--nd-switch-height)] flex justify-center items-center","text-center text-contrast","ps-[calc(var(--nd-switch-height)/3)] pe-[calc(var(--nd-switch-height)*1.1)]","transition-[margin-inline,background-color]",h[e][`${t}`].concat(t?["ms-0 me-0"]:["-ms-[100%] me-[100%]"])),children:p}),s("div",{className:a("h-[var(--nd-switch-height)] flex justify-center items-center","text-center text-contrast","-mt-[var(--nd-switch-height)]","ps-[calc(var(--nd-switch-height)*1.1)] pe-[calc(var(--nd-switch-height)/3)]","transition-[margin-inline,background-color]",h[e][`${t}`].concat(t?["ms-[100%] -me-[100%]"]:["ms-0 me-0"])),children:w}),s("div",{className:a("flex justify-center items-center","h-[var(--nd-switch-height)] absolute aspect-square scale-80","text-contrast transition-[left]",I[e],o[i],t?"left-[calc(100%-var(--nd-switch-height))]":"left-0"),children:A})]})});l.displayName="Switch";export{l as default};
1
+ import{jsxs as j,jsx as r}from"react/jsx-runtime";import{useControllableState as U}from"@nild/hooks";import{cnJoin as n,cnMerge as d}from"@nild/shared/utils";import{forwardRef as p,Children as B,isValidElement as D,cloneElement as g}from"react";import{DISABLED_CLS as H}from"../_shared/style/index.js";import{VARIANT_TRACK_CLS_MAP as y,VARIANT_THUMB_CLS_MAP as Z,SHAPE_CLS_MAP as k,SIZE_VAR_MAP as $,VARIANT_CLS_MAP as q,SIZE_CLS_MAP as J}from"./style/index.js";const m=p(({className:t,children:c,variant:e="solid",size:a="medium",shape:w="round",checked:C,defaultChecked:b,value:x,defaultValue:M,disabled:E,onChange:v,style:I,...L},P)=>{let l,h,o;B.forEach(c,s=>{D(s)&&(s.type===f?l=s:s.type===u?h=s:s.type===N&&(o=s))});const R={"--nd-switch-height":$[a]},[i,T]=U(C??x,b??M??!1),A=n("h-[var(--nd-switch-height)]","ps-[calc(var(--nd-switch-height)/3)] pe-[calc(var(--nd-switch-height)*1.1)]",y[e][`${i}`].concat(i?"ms-0 me-0":"-ms-[100%] me-[100%]")),S=n("h-[var(--nd-switch-height)]","-mt-[var(--nd-switch-height)]","ps-[calc(var(--nd-switch-height)*1.1)] pe-[calc(var(--nd-switch-height)/3)]",y[e][`${i}`].concat(i?"ms-[100%] -me-[100%]":"ms-0 me-0")),_=n("h-[var(--nd-switch-height)]",Z[e],k[w],i?"left-[calc(100%-var(--nd-switch-height))]":"left-0"),V=()=>{T(s=>(v?.(!s),!s))};return j("button",{...L,type:"button",role:"switch","aria-checked":i,disabled:E,className:d("nd-switch","h-[var(--nd-switch-height)]","group","relative inline-block font-sans overflow-hidden cursor-pointer",H,q[e],J[a],k[w],t),style:{...R,...I},ref:P,onClick:V,children:[l?g(l,{...l.props,className:n(A,l.props.className)}):r(f,{className:A}),h?g(h,{...h.props,className:n(S,h.props.className)}):r(u,{className:S}),o?g(o,{...o.props,className:n(_,o.props.className)}):r(N,{className:_})]})});m.displayName="Switch";const f=p(({className:t,children:c,...e},a)=>r("div",{...e,className:d("flex justify-center items-center","text-center text-contrast","transition-[margin-inline,background-color]",t),ref:a,children:c}));f.displayName="Switch.Checked";const u=p(({className:t,children:c,...e},a)=>r("div",{...e,className:d("flex justify-center items-center","text-center text-contrast","transition-[margin-inline,background-color]",t),ref:a,children:c}));u.displayName="Switch.Unchecked";const N=p(({className:t,children:c,...e},a)=>r("div",{...e,className:d("flex justify-center items-center","absolute aspect-square scale-80","text-contrast transition-[left,background-color]",t),ref:a,children:c}));N.displayName="Switch.Thumb",m.Checked=f,m.Unchecked=u,m.Thumb=N;export{m as default};
@@ -1 +1 @@
1
- const a={solid:[""],outlined:["border-solid border border-primary"]},r={solid:{true:["bg-primary"],false:["bg-[--alpha(var(--color-primary)/45%)]"]},outlined:{true:["bg-transparent"],false:["bg-transparent"]}},e={solid:["bg-contrast","top-0"],outlined:["bg-primary","-top-[1px]"]},l={small:"calc(var(--spacing) * 4)",medium:"calc(var(--spacing) * 6)",large:"calc(var(--spacing) * 8)"},s={small:["min-w-8","text-sm"],medium:["min-w-10","text-md"],large:["min-w-12","text-lg"]},t={round:["rounded-full"],square:["rounded-md"]};export{t as SHAPE_CLS_MAP,s as SIZE_CLS_MAP,l as SIZE_VAR_MAP,a as VARIANT_CLS_MAP,e as VARIANT_THUMB_CLS_MAP,r as VARIANT_TRACK_CLS_MAP};
1
+ const r={solid:[""],outlined:["border-solid border border-primary"]},a={solid:{true:["bg-primary","group-enabled:group-hover:bg-primary-hover"],false:["bg-[--alpha(var(--color-primary)/40%)]","group-enabled:group-hover:bg-[--alpha(var(--color-primary)/50%)]"]},outlined:{true:["bg-transparent"],false:["bg-transparent"]}},e={solid:["bg-contrast","top-0"],outlined:["bg-primary","group-enabled:group-hover:bg-primary-hover","-top-[1px]"]},o={small:"calc(var(--spacing) * 4)",medium:"calc(var(--spacing) * 6)",large:"calc(var(--spacing) * 8)"},l={small:["min-w-8","text-sm"],medium:["min-w-10","text-md"],large:["min-w-12","text-lg"]},p={round:["rounded-full"],square:["rounded-md"]};export{p as SHAPE_CLS_MAP,l as SIZE_CLS_MAP,o as SIZE_VAR_MAP,r as VARIANT_CLS_MAP,e as VARIANT_THUMB_CLS_MAP,a as VARIANT_TRACK_CLS_MAP};
package/dist/tailwind.css CHANGED
@@ -1 +1 @@
1
- @theme static{ --nd-color-primary-0: light-dark(#fafafa, #171717); --nd-color-primary-5: light-dark(#f7f7f7, #1e1e1e); --nd-color-primary-10: light-dark(#f4f4f4, #242424); --nd-color-primary-15: light-dark(#ededed, #2c2c2c); --nd-color-primary-20: light-dark(#e5e5e5, #333333); --nd-color-primary-30: light-dark(#cecece, #434343); --nd-color-primary-40: light-dark(#aeaeae, #575757); --nd-color-primary-50: light-dark(#888888, #888888); --nd-color-primary-60: light-dark(#626262, #b9b9b9); --nd-color-primary-70: light-dark(#424242, #cdcdcd); --nd-color-primary-80: light-dark(#2b2b2b, #dedede); --nd-color-primary-90: light-dark(#1d1d1d, #ececec); --nd-color-primary-100: light-dark(#171717, #fafafa); }@theme{ --color-primary: var(--nd-color-primary-80); --color-primary-hover: var(--nd-color-primary-70); --color-primary-active: var(--nd-color-primary-90); --color-secondary: var(--nd-color-primary-20); --color-secondary-hover: var(--nd-color-primary-30); --color-secondary-active: var(--nd-color-primary-40); --color-tertiary: var(--nd-color-primary-15); --color-tertiary-hover: var(--nd-color-primary-20); --color-tertiary-active: var(--nd-color-primary-30); --color-contrast: var(--nd-color-primary-0); --color-split: var(--nd-color-primary-20); --text-color-primary: var(--nd-color-primary-100); --text-color-secondary: var(--nd-color-primary-60); --text-color-link: var(--color-primary); --text-color-link-hover: var(--color-primary-hover); --text-color-link-active: var(--color-primary-active); --background-color-container: light-dark(var(--nd-color-primary-0), var(--nd-color-primary-5)); --text-sm: .75rem; --text-sm--line-height: 1.25rem; --text-md: .875rem; --text-md--line-height: 1.375rem; --text-lg: 1rem; --text-lg--line-height: 1.5rem; --text-xl: 1.25rem; --text-xl--line-height: 1.75rem; --text-2xl: 1.5rem; --text-2xl--line-height: 2rem; --text-3xl: 1.875rem; --text-3xl--line-height: 2.375rem; --text-4xl: 2.375rem; --text-4xl--line-height: 2.875rem; --text-5xl: 2.875rem; --text-5xl--line-height: 3.375rem; --radius-sm: .125rem; --radius-md: .25rem; --radius-lg: .375rem; }@utility underline{text-decoration: underline; text-underline-offset: .125rem;}@custom-variant disabled{&.disabled,&:disabled {@slot;}}
1
+ @theme static{ --nd-color-primary-0: light-dark(#fafafa, #171717); --nd-color-primary-5: light-dark(#f7f7f7, #1e1e1e); --nd-color-primary-10: light-dark(#f4f4f4, #242424); --nd-color-primary-15: light-dark(#ededed, #2c2c2c); --nd-color-primary-20: light-dark(#e5e5e5, #333333); --nd-color-primary-30: light-dark(#cecece, #434343); --nd-color-primary-40: light-dark(#aeaeae, #575757); --nd-color-primary-50: light-dark(#888888, #888888); --nd-color-primary-60: light-dark(#626262, #b9b9b9); --nd-color-primary-70: light-dark(#424242, #cdcdcd); --nd-color-primary-80: light-dark(#2b2b2b, #dedede); --nd-color-primary-90: light-dark(#1d1d1d, #ececec); --nd-color-primary-100: light-dark(#171717, #fafafa); }@theme{ --color-primary: var(--nd-color-primary-80); --color-primary-hover: var(--nd-color-primary-70); --color-primary-active: var(--nd-color-primary-90); --color-secondary: var(--nd-color-primary-20); --color-secondary-hover: var(--nd-color-primary-30); --color-secondary-active: var(--nd-color-primary-40); --color-tertiary: var(--nd-color-primary-15); --color-tertiary-hover: var(--nd-color-primary-20); --color-tertiary-active: var(--nd-color-primary-30); --color-contrast: var(--nd-color-primary-0); --color-split: var(--nd-color-primary-20); --text-color-primary: var(--nd-color-primary-100); --text-color-secondary: var(--nd-color-primary-60); --text-color-link: var(--color-primary); --text-color-link-hover: var(--color-primary-hover); --text-color-link-active: var(--color-primary-active); --background-color-container: light-dark(var(--nd-color-primary-0), var(--nd-color-primary-5)); --text-sm: .75rem; --text-sm--line-height: 1.25rem; --text-md: .875rem; --text-md--line-height: 1.375rem; --text-lg: 1rem; --text-lg--line-height: 1.5rem; --text-xl: 1.25rem; --text-xl--line-height: 1.75rem; --text-2xl: 1.5rem; --text-2xl--line-height: 2rem; --text-3xl: 1.875rem; --text-3xl--line-height: 2.375rem; --text-4xl: 2.375rem; --text-4xl--line-height: 2.875rem; --text-5xl: 2.875rem; --text-5xl--line-height: 3.375rem; --radius-sm: .125rem; --radius-md: .25rem; --radius-lg: .375rem; --default-transition-duration: .2s; }@utility underline{text-decoration: underline; text-underline-offset: .125rem;}@custom-variant disabled{&.disabled,&:disabled {@slot;}}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nild/components",
3
3
  "private": false,
4
- "version": "0.0.5",
4
+ "version": "0.0.7",
5
5
  "type": "module",
6
6
  "module": "./dist/index.js",
7
7
  "exports": {
@@ -31,8 +31,8 @@
31
31
  "peerDependencies": {
32
32
  "react": ">=18.2.0",
33
33
  "react-dom": ">=18.2.0",
34
- "@nild/shared": "0.0.4",
35
- "@nild/hooks": "0.0.5"
34
+ "@nild/hooks": "0.0.6",
35
+ "@nild/shared": "0.0.5"
36
36
  },
37
37
  "scripts": {
38
38
  "build": "vite build --mode PROD",
@@ -1 +0,0 @@
1
- import{evaluate as H,getSideAxis as B,getSide as W,clamp as q,getOppositePlacement as Z,getExpandedPlacements as _,getOppositeAxisPlacements as $,getAlignmentSides as J,getPaddingObject as K,getAlignmentAxis as N,getAlignment as z,rectToClientRect as G,getOppositeAxis as M,getAxisLength as Q,min as U}from"../../../../../@floating-ui_utils@0.2.9/node_modules/@floating-ui/utils/dist/floating-ui.utils.js";function X(l,i,m){let{reference:n,floating:c}=l;const t=B(i),r=N(i),s=Q(r),p=W(i),d=t==="y",g=n.x+n.width/2-c.width/2,a=n.y+n.height/2-c.height/2,f=n[s]/2-c[s]/2;let e;switch(p){case"top":e={x:g,y:n.y-c.height};break;case"bottom":e={x:g,y:n.y+n.height};break;case"right":e={x:n.x+n.width,y:a};break;case"left":e={x:n.x-c.width,y:a};break;default:e={x:n.x,y:n.y}}switch(z(i)){case"start":e[r]-=f*(m&&d?-1:1);break;case"end":e[r]+=f*(m&&d?-1:1);break}return e}const ee=async(l,i,m)=>{const{placement:n="bottom",strategy:c="absolute",middleware:t=[],platform:r}=m,s=t.filter(Boolean),p=await(r.isRTL==null?void 0:r.isRTL(i));let d=await r.getElementRects({reference:l,floating:i,strategy:c}),{x:g,y:a}=X(d,n,p),f=n,e={},o=0;for(let y=0;y<s.length;y++){const{name:u,fn:h}=s[y],{x,y:w,data:R,reset:A}=await h({x:g,y:a,initialPlacement:n,placement:f,strategy:c,middlewareData:e,rects:d,platform:r,elements:{reference:l,floating:i}});g=x??g,a=w??a,e={...e,[u]:{...e[u],...R}},A&&o<=50&&(o++,typeof A=="object"&&(A.placement&&(f=A.placement),A.rects&&(d=A.rects===!0?await r.getElementRects({reference:l,floating:i,strategy:c}):A.rects),{x:g,y:a}=X(d,f,p)),y=-1)}return{x:g,y:a,placement:f,strategy:c,middlewareData:e}};async function I(l,i){var m;i===void 0&&(i={});const{x:n,y:c,platform:t,rects:r,elements:s,strategy:p}=l,{boundary:d="clippingAncestors",rootBoundary:g="viewport",elementContext:a="floating",altBoundary:f=!1,padding:e=0}=H(i,l),o=K(e),y=s[f?a==="floating"?"reference":"floating":a],u=G(await t.getClippingRect({element:(m=await(t.isElement==null?void 0:t.isElement(y)))==null||m?y:y.contextElement||await(t.getDocumentElement==null?void 0:t.getDocumentElement(s.floating)),boundary:d,rootBoundary:g,strategy:p})),h=a==="floating"?{x:n,y:c,width:r.floating.width,height:r.floating.height}:r.reference,x=await(t.getOffsetParent==null?void 0:t.getOffsetParent(s.floating)),w=await(t.isElement==null?void 0:t.isElement(x))?await(t.getScale==null?void 0:t.getScale(x))||{x:1,y:1}:{x:1,y:1},R=G(t.convertOffsetParentRelativeRectToViewportRelativeRect?await t.convertOffsetParentRelativeRectToViewportRelativeRect({elements:s,rect:h,offsetParent:x,strategy:p}):h);return{top:(u.top-R.top+o.top)/w.y,bottom:(R.bottom-u.bottom+o.bottom)/w.y,left:(u.left-R.left+o.left)/w.x,right:(R.right-u.right+o.right)/w.x}}const te=l=>({name:"arrow",options:l,async fn(i){const{x:m,y:n,placement:c,rects:t,platform:r,elements:s,middlewareData:p}=i,{element:d,padding:g=0}=H(l,i)||{};if(d==null)return{};const a=K(g),f={x:m,y:n},e=N(c),o=Q(e),y=await r.getDimensions(d),u=e==="y",h=u?"top":"left",x=u?"bottom":"right",w=u?"clientHeight":"clientWidth",R=t.reference[o]+t.reference[e]-f[e]-t.floating[o],A=f[e]-t.reference[e],C=await(r.getOffsetParent==null?void 0:r.getOffsetParent(d));let T=C?C[w]:0;(!T||!await(r.isElement==null?void 0:r.isElement(C)))&&(T=s.floating[w]||t.floating[o]);const F=R/2-A/2,D=T/2-y[o]/2-1,P=U(a[h],D),V=U(a[x],D),S=P,j=T-y[o]-V,v=T/2-y[o]/2+F,L=q(S,v,j),k=!p.arrow&&z(c)!=null&&v!==L&&t.reference[o]/2-(v<S?P:V)-y[o]/2<0,b=k?v<S?v-S:v-j:0;return{[e]:f[e]+b,data:{[e]:L,centerOffset:v-L-b,...k&&{alignmentOffset:b}},reset:k}}}),ne=function(l){return l===void 0&&(l={}),{name:"flip",options:l,async fn(i){var m,n;const{placement:c,middlewareData:t,rects:r,initialPlacement:s,platform:p,elements:d}=i,{mainAxis:g=!0,crossAxis:a=!0,fallbackPlacements:f,fallbackStrategy:e="bestFit",fallbackAxisSideDirection:o="none",flipAlignment:y=!0,...u}=H(l,i);if((m=t.arrow)!=null&&m.alignmentOffset)return{};const h=W(c),x=B(s),w=W(s)===s,R=await(p.isRTL==null?void 0:p.isRTL(d.floating)),A=f||(w||!y?[Z(s)]:_(s)),C=o!=="none";!f&&C&&A.push(...$(s,y,o,R));const T=[s,...A],F=await I(i,u),D=[];let P=((n=t.flip)==null?void 0:n.overflows)||[];if(g&&D.push(F[h]),a){const v=J(c,r,R);D.push(F[v[0]],F[v[1]])}if(P=[...P,{placement:c,overflows:D}],!D.every(v=>v<=0)){var V,S;const v=(((V=t.flip)==null?void 0:V.index)||0)+1,L=T[v];if(L&&(!(a==="alignment"&&x!==B(L))||P.every(b=>b.overflows[0]>0&&B(b.placement)===x)))return{data:{index:v,overflows:P},reset:{placement:L}};let k=(S=P.filter(b=>b.overflows[0]<=0).sort((b,O)=>b.overflows[1]-O.overflows[1])[0])==null?void 0:S.placement;if(!k)switch(e){case"bestFit":{var j;const b=(j=P.filter(O=>{if(C){const E=B(O.placement);return E===x||E==="y"}return!0}).map(O=>[O.placement,O.overflows.filter(E=>E>0).reduce((E,Y)=>E+Y,0)]).sort((O,E)=>O[1]-E[1])[0])==null?void 0:j[0];b&&(k=b);break}case"initialPlacement":k=s;break}if(c!==k)return{reset:{placement:k}}}return{}}}};async function ae(l,i){const{placement:m,platform:n,elements:c}=l,t=await(n.isRTL==null?void 0:n.isRTL(c.floating)),r=W(m),s=z(m),p=B(m)==="y",d=["left","top"].includes(r)?-1:1,g=t&&p?-1:1,a=H(i,l);let{mainAxis:f,crossAxis:e,alignmentAxis:o}=typeof a=="number"?{mainAxis:a,crossAxis:0,alignmentAxis:null}:{mainAxis:a.mainAxis||0,crossAxis:a.crossAxis||0,alignmentAxis:a.alignmentAxis};return s&&typeof o=="number"&&(e=s==="end"?o*-1:o),p?{x:e*g,y:f*d}:{x:f*d,y:e*g}}const ie=function(l){return l===void 0&&(l=0),{name:"offset",options:l,async fn(i){var m,n;const{x:c,y:t,placement:r,middlewareData:s}=i,p=await ae(i,l);return r===((m=s.offset)==null?void 0:m.placement)&&(n=s.arrow)!=null&&n.alignmentOffset?{}:{x:c+p.x,y:t+p.y,data:{...p,placement:r}}}}},le=function(l){return l===void 0&&(l={}),{name:"shift",options:l,async fn(i){const{x:m,y:n,placement:c}=i,{mainAxis:t=!0,crossAxis:r=!1,limiter:s={fn:u=>{let{x:h,y:x}=u;return{x:h,y:x}}},...p}=H(l,i),d={x:m,y:n},g=await I(i,p),a=B(W(c)),f=M(a);let e=d[f],o=d[a];if(t){const u=f==="y"?"top":"left",h=f==="y"?"bottom":"right",x=e+g[u],w=e-g[h];e=q(x,e,w)}if(r){const u=a==="y"?"top":"left",h=a==="y"?"bottom":"right",x=o+g[u],w=o-g[h];o=q(x,o,w)}const y=s.fn({...i,[f]:e,[a]:o});return{...y,data:{x:y.x-m,y:y.y-n,enabled:{[f]:t,[a]:r}}}}}};export{te as arrow,ee as computePosition,I as detectOverflow,ne as flip,ie as offset,G as rectToClientRect,le as shift};
@@ -1 +0,0 @@
1
- import{offset as it,shift as rt,flip as st,arrow as lt,computePosition as ct}from"../../../../../@floating-ui_core@1.7.1/node_modules/@floating-ui/core/dist/floating-ui.core.js";import{createCoords as x,round as A,max as W,min as S,rectToClientRect as $,floor as D}from"../../../../../@floating-ui_utils@0.2.9/node_modules/@floating-ui/utils/dist/floating-ui.utils.js";import{isElement as v,getDocumentElement as b,getOverflowAncestors as N,getComputedStyle as L,isHTMLElement as R,getWindow as C,isTopLayer as V,getParentNode as O,isLastTraversableNode as P,isTableElement as ft,isContainingBlock as K,getContainingBlock as at,getNodeName as I,isOverflowElement as M,getNodeScroll as z,getFrameElement as j,isWebKit as G}from"../../../../../@floating-ui_utils@0.2.9/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.js";function J(t){const e=L(t);let n=parseFloat(e.width)||0,o=parseFloat(e.height)||0;const i=R(t),s=i?t.offsetWidth:n,r=i?t.offsetHeight:o,l=A(n)!==s||A(o)!==r;return l&&(n=s,o=r),{width:n,height:o,$:l}}function k(t){return v(t)?t:t.contextElement}function F(t){const e=k(t);if(!R(e))return x(1);const n=e.getBoundingClientRect(),{width:o,height:i,$:s}=J(e);let r=(s?A(n.width):n.width)/o,l=(s?A(n.height):n.height)/i;return(!r||!Number.isFinite(r))&&(r=1),(!l||!Number.isFinite(l))&&(l=1),{x:r,y:l}}const ut=x(0);function Q(t){const e=C(t);return!G()||!e.visualViewport?ut:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function ht(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==C(t)?!1:e}function E(t,e,n,o){e===void 0&&(e=!1),n===void 0&&(n=!1);const i=t.getBoundingClientRect(),s=k(t);let r=x(1);e&&(o?v(o)&&(r=F(o)):r=F(t));const l=ht(s,n,o)?Q(s):x(0);let c=(i.left+l.x)/r.x,f=(i.top+l.y)/r.y,a=i.width/r.x,d=i.height/r.y;if(s){const p=C(s),u=o&&v(o)?C(o):o;let w=p,g=j(w);for(;g&&o&&u!==w;){const m=F(g),h=g.getBoundingClientRect(),y=L(g),T=h.left+(g.clientLeft+parseFloat(y.paddingLeft))*m.x,B=h.top+(g.clientTop+parseFloat(y.paddingTop))*m.y;c*=m.x,f*=m.y,a*=m.x,d*=m.y,c+=T,f+=B,w=C(g),g=j(w)}}return $({width:a,height:d,x:c,y:f})}function q(t,e){const n=z(t).scrollLeft;return e?e.left+n:E(b(t)).left+n}function U(t,e,n){n===void 0&&(n=!1);const o=t.getBoundingClientRect(),i=o.left+e.scrollLeft-(n?0:q(t,o)),s=o.top+e.scrollTop;return{x:i,y:s}}function dt(t){let{elements:e,rect:n,offsetParent:o,strategy:i}=t;const s=i==="fixed",r=b(o),l=e?V(e.floating):!1;if(o===r||l&&s)return n;let c={scrollLeft:0,scrollTop:0},f=x(1);const a=x(0),d=R(o);if((d||!d&&!s)&&((I(o)!=="body"||M(r))&&(c=z(o)),R(o))){const u=E(o);f=F(o),a.x=u.x+o.clientLeft,a.y=u.y+o.clientTop}const p=r&&!d&&!s?U(r,c,!0):x(0);return{width:n.width*f.x,height:n.height*f.y,x:n.x*f.x-c.scrollLeft*f.x+a.x+p.x,y:n.y*f.y-c.scrollTop*f.y+a.y+p.y}}function gt(t){return Array.from(t.getClientRects())}function pt(t){const e=b(t),n=z(t),o=t.ownerDocument.body,i=W(e.scrollWidth,e.clientWidth,o.scrollWidth,o.clientWidth),s=W(e.scrollHeight,e.clientHeight,o.scrollHeight,o.clientHeight);let r=-n.scrollLeft+q(t);const l=-n.scrollTop;return L(o).direction==="rtl"&&(r+=W(e.clientWidth,o.clientWidth)-i),{width:i,height:s,x:r,y:l}}function mt(t,e){const n=C(t),o=b(t),i=n.visualViewport;let s=o.clientWidth,r=o.clientHeight,l=0,c=0;if(i){s=i.width,r=i.height;const f=G();(!f||f&&e==="fixed")&&(l=i.offsetLeft,c=i.offsetTop)}return{width:s,height:r,x:l,y:c}}function yt(t,e){const n=E(t,!0,e==="fixed"),o=n.top+t.clientTop,i=n.left+t.clientLeft,s=R(t)?F(t):x(1),r=t.clientWidth*s.x,l=t.clientHeight*s.y,c=i*s.x,f=o*s.y;return{width:r,height:l,x:c,y:f}}function X(t,e,n){let o;if(e==="viewport")o=mt(t,n);else if(e==="document")o=pt(b(t));else if(v(e))o=yt(e,n);else{const i=Q(t);o={x:e.x-i.x,y:e.y-i.y,width:e.width,height:e.height}}return $(o)}function Y(t,e){const n=O(t);return n===e||!v(n)||P(n)?!1:L(n).position==="fixed"||Y(n,e)}function xt(t,e){const n=e.get(t);if(n)return n;let o=N(t,[],!1).filter(l=>v(l)&&I(l)!=="body"),i=null;const s=L(t).position==="fixed";let r=s?O(t):t;for(;v(r)&&!P(r);){const l=L(r),c=K(r);!c&&l.position==="fixed"&&(i=null),(s?!c&&!i:!c&&l.position==="static"&&i&&["absolute","fixed"].includes(i.position)||M(r)&&!c&&Y(t,r))?o=o.filter(f=>f!==r):i=l,r=O(r)}return e.set(t,o),o}function wt(t){let{element:e,boundary:n,rootBoundary:o,strategy:i}=t;const s=[...n==="clippingAncestors"?V(e)?[]:xt(e,this._c):[].concat(n),o],r=s[0],l=s.reduce((c,f)=>{const a=X(e,f,i);return c.top=W(a.top,c.top),c.right=S(a.right,c.right),c.bottom=S(a.bottom,c.bottom),c.left=W(a.left,c.left),c},X(e,r,i));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function vt(t){const{width:e,height:n}=J(t);return{width:e,height:n}}function bt(t,e,n){const o=R(e),i=b(e),s=n==="fixed",r=E(t,!0,s,e);let l={scrollLeft:0,scrollTop:0};const c=x(0);function f(){c.x=q(i)}if(o||!o&&!s)if((I(e)!=="body"||M(i))&&(l=z(e)),o){const u=E(e,!0,s,e);c.x=u.x+e.clientLeft,c.y=u.y+e.clientTop}else i&&f();s&&!o&&i&&f();const a=i&&!o&&!s?U(i,l):x(0),d=r.left+l.scrollLeft-c.x-a.x,p=r.top+l.scrollTop-c.y-a.y;return{x:d,y:p,width:r.width,height:r.height}}function _(t){return L(t).position==="static"}function Z(t,e){if(!R(t)||L(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return b(t)===n&&(n=n.ownerDocument.body),n}function tt(t,e){const n=C(t);if(V(t))return n;if(!R(t)){let i=O(t);for(;i&&!P(i);){if(v(i)&&!_(i))return i;i=O(i)}return n}let o=Z(t,e);for(;o&&ft(o)&&_(o);)o=Z(o,e);return o&&P(o)&&_(o)&&!K(o)?n:o||at(t)||n}const Lt=async function(t){const e=this.getOffsetParent||tt,n=this.getDimensions,o=await n(t.floating);return{reference:bt(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function Rt(t){return L(t).direction==="rtl"}const et={convertOffsetParentRelativeRectToViewportRelativeRect:dt,getDocumentElement:b,getClippingRect:wt,getOffsetParent:tt,getElementRects:Lt,getClientRects:gt,getDimensions:vt,getScale:F,isElement:v,isRTL:Rt};function nt(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function Tt(t,e){let n=null,o;const i=b(t);function s(){var l;clearTimeout(o),(l=n)==null||l.disconnect(),n=null}function r(l,c){l===void 0&&(l=!1),c===void 0&&(c=1),s();const f=t.getBoundingClientRect(),{left:a,top:d,width:p,height:u}=f;if(l||e(),!p||!u)return;const w=D(d),g=D(i.clientWidth-(a+p)),m=D(i.clientHeight-(d+u)),h=D(a),y={rootMargin:-w+"px "+-g+"px "+-m+"px "+-h+"px",threshold:W(0,S(1,c))||1};let T=!0;function B(ot){const H=ot[0].intersectionRatio;if(H!==c){if(!T)return r();H?r(!1,H):o=setTimeout(()=>{r(!1,1e-7)},1e3)}H===1&&!nt(f,t.getBoundingClientRect())&&r(),T=!1}try{n=new IntersectionObserver(B,{...y,root:i.ownerDocument})}catch{n=new IntersectionObserver(B,y)}n.observe(t)}return r(!0),s}function Ct(t,e,n,o){o===void 0&&(o={});const{ancestorScroll:i=!0,ancestorResize:s=!0,elementResize:r=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:c=!1}=o,f=k(t),a=i||s?[...f?N(f):[],...N(e)]:[];a.forEach(h=>{i&&h.addEventListener("scroll",n,{passive:!0}),s&&h.addEventListener("resize",n)});const d=f&&l?Tt(f,n):null;let p=-1,u=null;r&&(u=new ResizeObserver(h=>{let[y]=h;y&&y.target===f&&u&&(u.unobserve(e),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var T;(T=u)==null||T.observe(e)})),n()}),f&&!c&&u.observe(f),u.observe(e));let w,g=c?E(t):null;c&&m();function m(){const h=E(t);g&&!nt(g,h)&&n(),g=h,w=requestAnimationFrame(m)}return n(),()=>{var h;a.forEach(y=>{i&&y.removeEventListener("scroll",n),s&&y.removeEventListener("resize",n)}),d?.(),(h=u)==null||h.disconnect(),u=null,c&&cancelAnimationFrame(w)}}const Et=it,Wt=rt,Ft=st,Ot=lt,Bt=(t,e,n)=>{const o=new Map,i={platform:et,...n},s={...i.platform,_c:o};return ct(t,e,{...i,platform:s})};export{Ot as arrow,Ct as autoUpdate,Bt as computePosition,Ft as flip,N as getOverflowAncestors,Et as offset,et as platform,Wt as shift};