UNPKG

@accounter/client

Version:
1 lines • 8.41 kB
import{s as e}from"./dist-BmACi7k_.js";import{i as t,o as n,t as r}from"./utils-BxkqV8PM.js";import{$ as i,G as a,J as o,K as s,Q as c,R as l,W as u,Z as d,at as f,et as p,q as m,rt as h,tt as g,z as ee}from"./select-BbuF1w16.js";import{i as te,n as _,o as v}from"./button-BBCCSbHv.js";var y=e(n(),1),b=t(),x=Object.defineProperty,S=(e,t)=>x(e,`name`,{value:t,configurable:!0}),C=`Dialog`,[w,T]=h(C),[ne,E]=w(C),D=S(e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=y.useRef(null),l=y.useRef(null),[u,f]=i({prop:r,defaultProp:a??!1,onChange:o,caller:C}),[p,m]=y.useState(0),[h,g]=y.useState(0);return(0,b.jsx)(ne,{scope:t,triggerRef:c,contentRef:l,contentId:d(),titleId:d(),descriptionId:d(),titlePresent:p>0,descriptionPresent:h>0,setTitleCount:m,setDescriptionCount:g,open:u,onOpenChange:f,onOpenToggle:y.useCallback(()=>f(e=>!e),[f]),modal:s,children:n})},`Dialog`),re=`DialogTrigger`,ie=y.forwardRef(S(function(e,t){let{__scopeDialog:n,...r}=e,i=E(re,n),a=v(t,i.triggerRef);return(0,b.jsx)(f.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":F(i.open),...r,ref:a,onClick:g(e.onClick,i.onOpenToggle)})},`DialogTrigger`)),O=`DialogPortal`,[k,A]=w(O,{forceMount:void 0}),ae=S(e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,o=E(O,t);return(0,b.jsx)(k,{scope:t,forceMount:n,children:y.Children.map(r,e=>(0,b.jsx)(c,{present:n||o.open,children:(0,b.jsx)(a,{asChild:!0,container:i,children:e})}))})},`DialogPortal`),j=`DialogOverlay`,oe=y.forwardRef(S(function(e,t){let n=A(j,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=E(j,e.__scopeDialog);return a.modal?(0,b.jsx)(c,{present:r||a.open,children:(0,b.jsx)(ce,{...i,ref:t})}):null},`DialogOverlay`)),se=te(`DialogOverlay.RemoveScroll`),ce=y.forwardRef(S(function(e,t){let{__scopeDialog:n,...r}=e,i=E(j,n),a=v(t,o());return(0,b.jsx)(ee,{as:se,allowPinchZoom:!0,shards:[i.contentRef],children:(0,b.jsx)(f.div,{"data-state":F(i.open),...r,ref:a,style:{pointerEvents:`auto`,...r.style}})})},`DialogOverlayImpl`)),M=`DialogContent`,le=y.forwardRef(S(function(e,t){let n=A(M,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=E(M,e.__scopeDialog);return(0,b.jsx)(c,{present:r||a.open,children:a.modal?(0,b.jsx)(ue,{...i,ref:t}):(0,b.jsx)(de,{...i,ref:t})})},`DialogContent`)),ue=y.forwardRef(S(function(e,t){let n=E(M,e.__scopeDialog),r=y.useRef(null),i=v(t,n.contentRef,r);return y.useEffect(()=>{let e=r.current;if(e)return l(e)},[]),(0,b.jsx)(N,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:g(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:g(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:g(e.onFocusOutside,e=>e.preventDefault())})},`DialogContentModal`)),de=y.forwardRef(S(function(e,t){let n=E(M,e.__scopeDialog),r=y.useRef(!1),i=y.useRef(!1);return(0,b.jsx)(N,{...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`)),N=y.forwardRef(S(function(e,t){let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,c=E(M,n);return u(),(0,b.jsx)(b.Fragment,{children:(0,b.jsx)(s,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,b.jsx)(m,{role:`dialog`,id:c.contentId,"aria-describedby":c.descriptionPresent?c.descriptionId:void 0,"aria-labelledby":c.titlePresent?c.titleId:void 0,"data-state":F(c.open),...o,ref:t,deferPointerDownOutside:!0,onDismiss:()=>c.onOpenChange(!1)})})})},`DialogContentImpl`)),fe=`DialogTitle`,pe=y.forwardRef(S(function(e,t){let{__scopeDialog:n,...r}=e,i=E(fe,n),{setTitleCount:a}=i;return p(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,b.jsx)(f.h2,{id:i.titleId,...r,ref:t})},`DialogTitle`)),me=`DialogDescription`,he=y.forwardRef(S(function(e,t){let{__scopeDialog:n,...r}=e,i=E(me,n),{setDescriptionCount:a}=i;return p(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,b.jsx)(f.p,{id:i.descriptionId,...r,ref:t})},`DialogDescription`)),ge=`DialogClose`,P=y.forwardRef(S(function(e,t){let{__scopeDialog:n,...r}=e,i=E(ge,n);return(0,b.jsx)(f.button,{type:`button`,...r,ref:t,onClick:g(e.onClick,()=>i.onOpenChange(!1))})},`DialogClose`));function F(e){return e?`open`:`closed`}S(F,`getState`);var I=Object.defineProperty,L=(e,t)=>I(e,`name`,{value:t,configurable:!0}),[_e,ve]=h(`AlertDialog`,[T]),R=T(),ye=L(e=>{let{__scopeAlertDialog:t,...n}=e,r=R(t);return(0,b.jsx)(D,{...r,...n,modal:!0})},`AlertDialog`),be=y.forwardRef(L(function(e,t){let{__scopeAlertDialog:n,...r}=e,i=R(n);return(0,b.jsx)(ie,{...i,...r,ref:t})},`AlertDialogTrigger`)),xe=L(e=>{let{__scopeAlertDialog:t,...n}=e,r=R(t);return(0,b.jsx)(ae,{...r,...n})},`AlertDialogPortal`),Se=y.forwardRef(L(function(e,t){let{__scopeAlertDialog:n,...r}=e,i=R(n);return(0,b.jsx)(oe,{...i,...r,ref:t})},`AlertDialogOverlay`)),[Ce,we]=_e(`AlertDialogContent`),Te=y.forwardRef(L(function(e,t){let{__scopeAlertDialog:n,children:r,...i}=e,a=R(n),o=v(t,y.useRef(null)),s=y.useRef(null);return(0,b.jsx)(Ce,{scope:n,cancelRef:s,children:(0,b.jsx)(le,{role:`alertdialog`,...a,...i,ref:o,onOpenAutoFocus:g(i.onOpenAutoFocus,e=>{e.preventDefault(),s.current?.focus({preventScroll:!0})}),onPointerDownOutside:e=>e.preventDefault(),onInteractOutside:e=>e.preventDefault(),children:r})})},`AlertDialogContent`)),Ee=y.forwardRef(L(function(e,t){let{__scopeAlertDialog:n,...r}=e,i=R(n);return(0,b.jsx)(pe,{...i,...r,ref:t})},`AlertDialogTitle`)),De=y.forwardRef(L(function(e,t){let{__scopeAlertDialog:n,...r}=e,i=R(n);return(0,b.jsx)(he,{...i,...r,ref:t})},`AlertDialogDescription`)),Oe=y.forwardRef(L(function(e,t){let{__scopeAlertDialog:n,...r}=e,i=R(n);return(0,b.jsx)(P,{...i,...r,ref:t})},`AlertDialogAction`)),ke=`AlertDialogCancel`,z=y.forwardRef(L(function(e,t){let{__scopeAlertDialog:n,...r}=e,{cancelRef:i}=we(ke,n),a=R(n),o=v(t,i);return(0,b.jsx)(P,{...a,...r,ref:o})},`AlertDialogCancel`)),Ae=ye,je=be,Me=xe,B=Se,V=Te,H=Oe,U=z,W=Ee,G=De,Ne=Ae,Pe=je,Fe=Me,K=y.forwardRef(({className:e,...t},n)=>(0,b.jsx)(B,{className:r(`fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0`,e),...t,ref:n}));K.displayName=B.displayName;var q=y.forwardRef(({className:e,...t},n)=>(0,b.jsxs)(Fe,{children:[(0,b.jsx)(K,{}),(0,b.jsx)(V,{ref:n,className:r(`fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border border-gray-200 bg-white p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg dark:border-gray-800 dark:bg-gray-950`,e),...t})]}));q.displayName=V.displayName;var J=({className:e,...t})=>(0,b.jsx)(`div`,{className:r(`flex flex-col space-y-2 text-center sm:text-left`,e),...t});J.displayName=`AlertDialogHeader`;var Y=({className:e,...t})=>(0,b.jsx)(`div`,{className:r(`flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2`,e),...t});Y.displayName=`AlertDialogFooter`;var X=y.forwardRef(({className:e,...t},n)=>(0,b.jsx)(W,{ref:n,className:r(`text-lg font-semibold`,e),...t}));X.displayName=W.displayName;var Z=y.forwardRef(({className:e,...t},n)=>(0,b.jsx)(G,{ref:n,className:r(`text-sm text-gray-500 dark:text-gray-400`,e),...t}));Z.displayName=G.displayName;var Q=y.forwardRef(({className:e,...t},n)=>(0,b.jsx)(H,{ref:n,className:r(_(),e),...t}));Q.displayName=H.displayName;var $=y.forwardRef(({className:e,...t},n)=>(0,b.jsx)(U,{ref:n,className:r(_({variant:`outline`}),`mt-2 sm:mt-0`,e),...t}));$.displayName=U.displayName;export{Z as a,X as c,q as i,Pe as l,Q as n,Y as o,$ as r,J as s,Ne as t};