@undp/design-system-react
Version:
React based design system for UNDP
2 lines • 7.44 kB
JavaScript
const e=require("./rolldown-runtime-mLOUI7ql.cjs"),t=require("./dist--OhUIyHO.cjs"),n=require("./dist-VI-VV5wq.cjs"),r=require("./dist-DluBSGxD.cjs"),i=require("./dist-Cepu74FS.cjs"),a=require("./dist-BMAVZmE9.cjs"),o=require("./floating-ui.dom-Ca2FrYDD.cjs");let s=require("react");s=e.r(s,1);let c=require("react/jsx-runtime"),l=require("react-dom");l=e.r(l,1);var u=typeof document<`u`?s.useLayoutEffect:function(){};function d(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!d(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!d(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function f(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function p(e,t){let n=f(e);return Math.round(t*n)/n}function m(e){let t=s.useRef(e);return u(()=>{t.current=e}),t}function h(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:c}={},transform:h=!0,whileElementsMounted:g,open:_}=e,[v,y]=s.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[b,x]=s.useState(r);d(b,r)||x(r);let[S,C]=s.useState(null),[w,T]=s.useState(null),E=s.useCallback(e=>{e!==A.current&&(A.current=e,C(e))},[]),D=s.useCallback(e=>{e!==j.current&&(j.current=e,T(e))},[]),O=a||S,k=c||w,A=s.useRef(null),j=s.useRef(null),M=s.useRef(v),N=g!=null,P=m(g),F=m(i),I=m(_),L=s.useCallback(()=>{if(!A.current||!j.current)return;let e={placement:t,strategy:n,middleware:b};F.current&&(e.platform=F.current),o.r(A.current,j.current,e).then(e=>{let t={...e,isPositioned:I.current!==!1};R.current&&!d(M.current,t)&&(M.current=t,l.flushSync(()=>{y(t)}))})},[b,t,n,F,I]);u(()=>{_===!1&&M.current.isPositioned&&(M.current.isPositioned=!1,y(e=>({...e,isPositioned:!1})))},[_]);let R=s.useRef(!1);u(()=>(R.current=!0,()=>{R.current=!1}),[]),u(()=>{if(O&&(A.current=O),k&&(j.current=k),O&&k){if(P.current)return P.current(O,k,L);L()}},[O,k,L,P,N]);let z=s.useMemo(()=>({reference:A,floating:j,setReference:E,setFloating:D}),[E,D]),B=s.useMemo(()=>({reference:O,floating:k}),[O,k]),V=s.useMemo(()=>{let e={position:n,left:0,top:0};if(!B.floating)return e;let t=p(B.floating,v.x),r=p(B.floating,v.y);return h?{...e,transform:`translate(`+t+`px, `+r+`px)`,...f(B.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,h,B.floating,v.x,v.y]);return s.useMemo(()=>({...v,update:L,refs:z,elements:B,floatingStyles:V}),[v,L,z,B,V])}var g=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:o.t({element:r.current,padding:i}).fn(n):r?o.t({element:r,padding:i}).fn(n):{}}}},_=(e,t)=>({...o.s(e),options:[e,t]}),v=(e,t)=>({...o.c(e),options:[e,t]}),y=(e,t)=>({...o.o(e),options:[e,t]}),b=(e,t)=>({...o.i(e),options:[e,t]}),x=(e,t)=>({...o.l(e),options:[e,t]}),S=(e,t)=>({...o.a(e),options:[e,t]}),C=(e,t)=>({...g(e),options:[e,t]}),w=Object.defineProperty,T=(e,t)=>w(e,`name`,{value:t,configurable:!0}),E=`Popper`,[D,O]=r.n(E),[k,A]=D(E),j=T(e=>{let{__scopePopper:t,children:n}=e,[r,i]=s.useState(null),[a,o]=s.useState(void 0);return(0,c.jsx)(k,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})},`Popper`),M=`PopperAnchor`,N=s.forwardRef(T(function(e,r){let{__scopePopper:i,virtualRef:a,...o}=e,l=A(M,i),u=s.useRef(null),d=l.onAnchorChange,f=t.i(r,s.useCallback(e=>{u.current=e,e&&d(e)},[d])),p=s.useRef(null);s.useEffect(()=>{if(!a)return;let e=p.current;p.current=a.current,e!==p.current&&d(p.current)});let m=l.placementState&&B(l.placementState),h=m?.[0],g=m?.[1];return a?null:(0,c.jsx)(n.t.div,{"data-radix-popper-side":h,"data-radix-popper-align":g,...o,ref:f})},`PopperAnchor`)),P=`PopperContent`,[F,I]=D(P),L=s.forwardRef(T(function(e,l){let{__scopePopper:u,side:d=`bottom`,sideOffset:f=0,align:p=`center`,alignOffset:m=0,arrowPadding:g=0,avoidCollisions:w=!0,collisionBoundary:E=[],collisionPadding:D=0,sticky:O=`partial`,hideWhenDetached:k=!1,updatePositionStrategy:j=`optimized`,onPlaced:M,...N}=e,I=A(P,u),[L,V]=s.useState(null),H=t.i(l,V),[U,ee]=s.useState(null),te=a.t(U),ne=te?.width??0,W=te?.height??0,re=d+(p===`center`?``:`-`+p),ie=typeof D==`number`?D:{top:0,right:0,bottom:0,left:0,...D},G=Array.isArray(E)?E:[E],K=G.length>0,q={padding:ie,boundary:G.filter(R),altBoundary:K},{refs:ae,floatingStyles:J,placement:Y,isPositioned:X,middlewareData:Z}=h({strategy:`fixed`,placement:re,whileElementsMounted:T((...e)=>o.n(...e,{animationFrame:j===`always`}),`whileElementsMounted`),elements:{reference:I.anchor},middleware:[_({mainAxis:f+W,alignmentAxis:m}),w&&v({mainAxis:!0,crossAxis:!1,limiter:O===`partial`?y():void 0,...q}),w&&b({...q}),x({...q,apply:T(({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)},`apply`)}),U&&C({element:U,padding:g}),z({arrowWidth:ne,arrowHeight:W}),k&&S({strategy:`referenceHidden`,...q,boundary:K?q.boundary:void 0})]}),Q=I.setPlacementState;r.t(()=>(Q(Y),()=>{Q(void 0)}),[Y,Q]);let[oe,se]=B(Y),$=i.t(M);r.t(()=>{X&&$?.()},[X,$]);let ce=Z.arrow?.x,le=Z.arrow?.y,ue=Z.arrow?.centerOffset!==0,[de,fe]=s.useState();return r.t(()=>{L&&fe(window.getComputedStyle(L).zIndex)},[L]),(0,c.jsx)(`div`,{ref:ae.setFloating,"data-radix-popper-content-wrapper":``,style:{...J,transform:X?J.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:de,"--radix-popper-transform-origin":[Z.transformOrigin?.x,Z.transformOrigin?.y].join(` `),...Z.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,c.jsx)(F,{scope:u,placedSide:oe,placedAlign:se,onArrowChange:ee,arrowX:ce,arrowY:le,shouldHideArrow:ue,children:(0,c.jsx)(n.t.div,{"data-side":oe,"data-align":se,...N,ref:H,style:{...N.style,animation:X?N.style?.animation:`none`}})})})},`PopperContent`));function R(e){return e!==null}T(R,`isNotNull`);var z=T(e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=B(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}}),`transformOrigin`);function B(e){let[t,n=`center`]=e.split(`-`);return[t,n]}T(B,`getSideAndAlignFromPlacement`);var V=j,H=N,U=L;Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return U}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return V}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return H}});
//# sourceMappingURL=dist-ImWxW4aL.cjs.map