dgz-ui-shared
Version:
Custom ui library using React.js, Shadcn/ui, TailwindCSS, Typescript, dgz-ui library
6 lines (3 loc) • 5.64 kB
JavaScript
"use strict";const T=require("react"),t=require("./index-BL59b1Bz-COeLljOH.cjs"),p=require("./createLucideIcon-B950nf2d-DrrWmvZU.cjs");function B(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const o in e)if(o!=="default"){const a=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(n,o,a.get?a:{enumerable:!0,get:()=>e[o]})}}return n.default=e,Object.freeze(n)}const i=B(T);var D="Dialog",[_,q]=t.j(D),[W,u]=_(D),b=e=>{const{__scopeDialog:n,children:o,open:a,defaultOpen:s,onOpenChange:r,modal:l=!0}=e,c=i.useRef(null),f=i.useRef(null),[m,v]=t.y({prop:a,defaultProp:s??!1,onChange:r,caller:D});return t.ae.jsx(W,{scope:n,triggerRef:c,contentRef:f,contentId:t.g(),titleId:t.g(),descriptionId:t.g(),open:m,onOpenChange:v,onOpenToggle:i.useCallback(()=>v(k=>!k),[v]),modal:l,children:o})};b.displayName=D;var j="DialogTrigger",x=i.forwardRef((e,n)=>{const{__scopeDialog:o,...a}=e,s=u(j,o),r=t.i(n,s.triggerRef);return t.ae.jsx(t.h.button,{type:"button","aria-haspopup":"dialog","aria-expanded":s.open,"aria-controls":s.contentId,"data-state":R(s.open),...a,ref:r,onClick:t.y$1(e.onClick,s.onOpenToggle)})});x.displayName=j;var y="DialogPortal",[L,O]=_(y,{forceMount:void 0}),C=e=>{const{__scopeDialog:n,forceMount:o,children:a,container:s}=e,r=u(y,n);return t.ae.jsx(L,{scope:n,forceMount:o,children:i.Children.map(a,l=>t.ae.jsx(t.R,{present:o||r.open,children:t.ae.jsx(p.Me,{asChild:!0,container:s,children:l})}))})};C.displayName=y;var g="DialogOverlay",I=i.forwardRef((e,n)=>{const o=O(g,e.__scopeDialog),{forceMount:a=o.forceMount,...s}=e,r=u(g,e.__scopeDialog);return r.modal?t.ae.jsx(t.R,{present:a||r.open,children:t.ae.jsx(G,{...s,ref:n})}):null});I.displayName=g;var z=t.S("DialogOverlay.RemoveScroll"),G=i.forwardRef((e,n)=>{const{__scopeDialog:o,...a}=e,s=u(g,o);return t.ae.jsx(p.dt,{as:z,allowPinchZoom:!0,shards:[s.contentRef],children:t.ae.jsx(t.h.div,{"data-state":R(s.open),...a,ref:n,style:{pointerEvents:"auto",...a.style}})})}),d="DialogContent",w=i.forwardRef((e,n)=>{const o=O(d,e.__scopeDialog),{forceMount:a=o.forceMount,...s}=e,r=u(d,e.__scopeDialog);return t.ae.jsx(t.R,{present:a||r.open,children:r.modal?t.ae.jsx(H,{...s,ref:n}):t.ae.jsx(K,{...s,ref:n})})});w.displayName=d;var H=i.forwardRef((e,n)=>{const o=u(d,e.__scopeDialog),a=i.useRef(null),s=t.i(n,o.contentRef,a);return i.useEffect(()=>{const r=a.current;if(r)return p.Rt(r)},[]),t.ae.jsx(F,{...e,ref:s,trapFocus:o.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:t.y$1(e.onCloseAutoFocus,r=>{var l;r.preventDefault(),(l=o.triggerRef.current)==null||l.focus()}),onPointerDownOutside:t.y$1(e.onPointerDownOutside,r=>{const l=r.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0;(l.button===2||c)&&r.preventDefault()}),onFocusOutside:t.y$1(e.onFocusOutside,r=>r.preventDefault())})}),K=i.forwardRef((e,n)=>{const o=u(d,e.__scopeDialog),a=i.useRef(!1),s=i.useRef(!1);return t.ae.jsx(F,{...e,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:r=>{var l,c;(l=e.onCloseAutoFocus)==null||l.call(e,r),r.defaultPrevented||(a.current||(c=o.triggerRef.current)==null||c.focus(),r.preventDefault()),a.current=!1,s.current=!1},onInteractOutside:r=>{var l,c;(l=e.onInteractOutside)==null||l.call(e,r),r.defaultPrevented||(a.current=!0,r.detail.originalEvent.type==="pointerdown"&&(s.current=!0));const f=r.target;(c=o.triggerRef.current)!=null&&c.contains(f)&&r.preventDefault(),r.detail.originalEvent.type==="focusin"&&s.current&&r.preventDefault()}})}),F=i.forwardRef((e,n)=>{const{__scopeDialog:o,trapFocus:a,onOpenAutoFocus:s,onCloseAutoFocus:r,...l}=e,c=u(d,o),f=i.useRef(null),m=t.i(n,f);return p.Ct(),t.ae.jsxs(t.ae.Fragment,{children:[t.ae.jsx(p.Se,{asChild:!0,loop:!0,trapped:a,onMountAutoFocus:s,onUnmountAutoFocus:r,children:t.ae.jsx(t.M,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":R(c.open),...l,ref:m,onDismiss:()=>c.onOpenChange(!1)})}),t.ae.jsxs(t.ae.Fragment,{children:[t.ae.jsx(U,{titleId:c.titleId}),t.ae.jsx(X,{contentRef:f,descriptionId:c.descriptionId})]})]})}),h="DialogTitle",N=i.forwardRef((e,n)=>{const{__scopeDialog:o,...a}=e,s=u(h,o);return t.ae.jsx(t.h.h2,{id:s.titleId,...a,ref:n})});N.displayName=h;var E="DialogDescription",P=i.forwardRef((e,n)=>{const{__scopeDialog:o,...a}=e,s=u(E,o);return t.ae.jsx(t.h.p,{id:s.descriptionId,...a,ref:n})});P.displayName=E;var M="DialogClose",A=i.forwardRef((e,n)=>{const{__scopeDialog:o,...a}=e,s=u(M,o);return t.ae.jsx(t.h.button,{type:"button",...a,ref:n,onClick:t.y$1(e.onClick,()=>s.onOpenChange(!1))})});A.displayName=M;function R(e){return e?"open":"closed"}var $="DialogTitleWarning",[Q,S]=t.b($,{contentName:d,titleName:h,docsSlug:"dialog"}),U=({titleId:e})=>{const n=S($),o=`\`${n.contentName}\` requires a \`${n.titleName}\` for the component to be accessible for screen reader users.
If you want to hide the \`${n.titleName}\`, you can wrap it with our VisuallyHidden component.
For more information, see https://radix-ui.com/primitives/docs/components/${n.docsSlug}`;return i.useEffect(()=>{e&&(document.getElementById(e)||console.error(o))},[o,e]),null},V="DialogDescriptionWarning",X=({contentRef:e,descriptionId:n})=>{const o=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${S(V).contentName}}.`;return i.useEffect(()=>{var a;const s=(a=e.current)==null?void 0:a.getAttribute("aria-describedby");n&&s&&(document.getElementById(n)||console.warn(o))},[o,e,n]),null},Z=b,J=x,Y=C,ee=I,te=w,ne=N,oe=P,re=A;exports.Ce=J;exports.De=q;exports.Ee=ne;exports.Pe=oe;exports.Re=Y;exports._e=ee;exports.he=te;exports.ve=Q;exports.xe=Z;exports.ye=re;