UNPKG

@undp/design-system-react

Version:

React based design system for UNDP

2 lines 5.58 kB
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-CTSEb5uk.cjs"),a=require("./dist-odcXV7N3.cjs"),o=require("./dist-DnbpoIgp.cjs"),s=require("./dist-B7GyuuzQ.cjs"),c=require("./es2015-_DRMRzCt.cjs"),l=require("./dist-DkrZhx1H.cjs");let u=require("react");u=e.r(u,1);let d=require("react/jsx-runtime");var f=Object.defineProperty,p=(e,t)=>f(e,`name`,{value:t,configurable:!0}),m=`Dialog`,[h,g]=r.n(m),[_,v]=h(m),y=p(e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:a,onOpenChange:s,modal:c=!0}=e,l=u.useRef(null),f=u.useRef(null),[p,h]=i.t({prop:r,defaultProp:a??!1,onChange:s,caller:m}),[g,v]=u.useState(0),[y,b]=u.useState(0);return(0,d.jsx)(_,{scope:t,triggerRef:l,contentRef:f,contentId:o.t(),titleId:o.t(),descriptionId:o.t(),titlePresent:g>0,descriptionPresent:y>0,setTitleCount:v,setDescriptionCount:b,open:p,onOpenChange:h,onOpenToggle:u.useCallback(()=>h(e=>!e),[h]),modal:c,children:n})},`Dialog`),b=`DialogTrigger`,x=u.forwardRef(p(function(e,r){let{__scopeDialog:a,...o}=e,s=v(b,a),c=t.i(r,s.triggerRef);return(0,d.jsx)(n.t.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":V(s.open),...o,ref:c,onClick:i.n(e.onClick,s.onOpenToggle)})},`DialogTrigger`)),S=`DialogPortal`,[C,w]=h(S,{forceMount:void 0}),T=p(e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,o=v(S,t);return(0,d.jsx)(C,{scope:t,forceMount:n,children:u.Children.map(r,e=>(0,d.jsx)(a.t,{present:n||o.open,children:(0,d.jsx)(l.t,{asChild:!0,container:i,children:e})}))})},`DialogPortal`),E=`DialogOverlay`,D=u.forwardRef(p(function(e,t){let n=w(E,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,o=v(E,e.__scopeDialog);return o.modal?(0,d.jsx)(a.t,{present:r||o.open,children:(0,d.jsx)(k,{...i,ref:t})}):null},`DialogOverlay`)),O=t.n(`DialogOverlay.RemoveScroll`),k=u.forwardRef(p(function(e,r){let{__scopeDialog:i,...a}=e,o=v(E,i),l=t.i(r,s.i());return(0,d.jsx)(c.n,{as:O,allowPinchZoom:!0,shards:[o.contentRef],children:(0,d.jsx)(n.t.div,{"data-state":V(o.open),...a,ref:l,style:{pointerEvents:`auto`,...a.style}})})},`DialogOverlayImpl`)),A=`DialogContent`,j=u.forwardRef(p(function(e,t){let n=w(A,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,o=v(A,e.__scopeDialog);return(0,d.jsx)(a.t,{present:r||o.open,children:o.modal?(0,d.jsx)(M,{...i,ref:t}):(0,d.jsx)(N,{...i,ref:t})})},`DialogContent`)),M=u.forwardRef(p(function(e,n){let r=v(A,e.__scopeDialog),a=u.useRef(null),o=t.i(n,r.contentRef,a);return u.useEffect(()=>{let e=a.current;if(e)return c.t(e)},[]),(0,d.jsx)(P,{...e,ref:o,trapFocus:r.open,disableOutsidePointerEvents:r.open,onCloseAutoFocus:i.n(e.onCloseAutoFocus,e=>{e.preventDefault(),r.triggerRef.current?.focus()}),onPointerDownOutside:i.n(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:i.n(e.onFocusOutside,e=>e.preventDefault())})},`DialogContentModal`)),N=u.forwardRef(p(function(e,t){let n=v(A,e.__scopeDialog),r=u.useRef(!1),i=u.useRef(!1);return(0,d.jsx)(P,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})},`DialogContentNonModal`)),P=u.forwardRef(p(function(e,t){let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,l=v(A,n);return c.r(),(0,d.jsx)(d.Fragment,{children:(0,d.jsx)(c.i,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,d.jsx)(s.n,{role:`dialog`,id:l.contentId,"aria-describedby":l.descriptionPresent?l.descriptionId:void 0,"aria-labelledby":l.titlePresent?l.titleId:void 0,"data-state":V(l.open),...o,ref:t,deferPointerDownOutside:!0,onDismiss:()=>l.onOpenChange(!1)})})})},`DialogContentImpl`)),F=`DialogTitle`,I=u.forwardRef(p(function(e,t){let{__scopeDialog:i,...a}=e,o=v(F,i),{setTitleCount:s}=o;return r.t(()=>(s(e=>e+1),()=>s(e=>e-1)),[s]),(0,d.jsx)(n.t.h2,{id:o.titleId,...a,ref:t})},`DialogTitle`)),L=`DialogDescription`,R=u.forwardRef(p(function(e,t){let{__scopeDialog:i,...a}=e,o=v(L,i),{setDescriptionCount:s}=o;return r.t(()=>(s(e=>e+1),()=>s(e=>e-1)),[s]),(0,d.jsx)(n.t.p,{id:o.descriptionId,...a,ref:t})},`DialogDescription`)),z=`DialogClose`,B=u.forwardRef(p(function(e,t){let{__scopeDialog:r,...a}=e,o=v(z,r);return(0,d.jsx)(n.t.button,{type:`button`,...a,ref:t,onClick:i.n(e.onClick,()=>o.onOpenChange(!1))})},`DialogClose`));function V(e){return e?`open`:`closed`}p(V,`getState`),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return R}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return B}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return j}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return I}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return y}}); //# sourceMappingURL=dist-BTkvAJGr.cjs.map