@texturehq/edges 1.29.0 → 1.30.0

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.
@@ -1,2 +1,2 @@
1
- import*as ro from'react';import ro__default,{memo,useRef,useCallback,useState,useEffect,Component}from'react';import {Modal,Dialog,Form,Link,Button,ModalOverlay,composeRenderProps}from'react-aria-components';import {twMerge}from'tailwind-merge';import*as ft from'@phosphor-icons/react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';var dt=Object.defineProperty;var ct=(e,o,t)=>o in e?dt(e,o,{enumerable:true,configurable:true,writable:true,value:t}):e[o]=t;var ge=(e,o,t)=>ct(e,typeof o!="symbol"?o+"":o,t);function Se(e,o=false){let[t,r]=useState(o);return useEffect(()=>{if(typeof window>"u")return;let n=window.matchMedia(e);r(n.matches);let a=s=>{r(s.matches);};return n.addEventListener("change",a),()=>{n.removeEventListener("change",a);}},[e]),t}function Be(e=false){return `${e?"outline outline-1 outline-border-input data-[focus-visible]:outline-2 data-[focus-visible]:outline-action-default data-[focus-visible]:outline-offset-0 invalid:outline-2 invalid:outline-feedback-error-border group-invalid:outline-2 group-invalid:outline-feedback-error-border forced-colors:focus:outline-[Highlight] forced-colors:focus:outline-2 forced-colors:focus:outline-offset-2":"outline-none data-[focus-visible]:outline data-[focus-visible]:outline-2 data-[focus-visible]:outline-action-default data-[focus-visible]:outline-offset-0 invalid:outline-2 invalid:outline-feedback-error-border group-invalid:outline-2 group-invalid:outline-feedback-error-border forced-colors:focus:outline-[Highlight] forced-colors:focus:outline-2 forced-colors:focus:outline-offset-2"}`}var j={sm:{text:"text-[length:var(--control-text-sm)]",height:"h-[var(--control-sm-height)]",padding:"px-[var(--control-padding-sm)]",paddingY:"py-[var(--control-gap-sm)]",gap:"gap-[var(--control-gap-sm)]"},md:{text:"text-[length:var(--control-text-md)]",height:"h-[var(--control-md-height)]",padding:"px-[var(--control-padding-md)]",paddingY:"py-[var(--control-gap-md)]",gap:"gap-[var(--control-gap-md)]"},lg:{text:"text-[length:var(--control-text-lg)]",height:"h-[var(--control-lg-height)]",padding:"px-[var(--control-padding-lg)]",paddingY:"py-[var(--control-gap-lg)]",gap:"gap-[var(--control-gap-lg)]"},xl:{text:"text-[length:var(--control-text-xl)]",height:"h-[var(--control-xl-height)]",padding:"px-[var(--control-padding-xl)]",paddingY:"py-[var(--control-gap-xl)]",gap:"gap-[var(--control-gap-xl)]"}};var q={xs:16,sm:20,md:24,lg:32,xl:40,"2xl":48},k=memo(({name:e,size:o="md",color:t,weight:r="regular",className:n,ariaLabel:a,...s})=>{let i=ft[e];if(!i)return process.env.NODE_ENV==="development"&&console.error(`Icon "${e}" not found in @phosphor-icons/react`),null;let l=typeof o=="string"&&o in q?q[o]:o,d=twMerge("inline-block flex-shrink-0",!t&&"text-current",n);return jsx(i,{...s,size:l,color:t,weight:r,className:d,"aria-label":a||`${e} icon`,"data-testid":`icon-${e}`})});k.displayName="Icon";var Me=memo(({variant:e="subtle",shape:o="square",containerSize:t,containerClassName:r,size:n="md",className:a,name:s,color:i,weight:l,ariaLabel:d,ref:p,...c})=>{let f=typeof n=="string"&&n in q?q[n]:n,x=t?typeof t=="string"&&t in q?q[t]:t:f*1.75,v=twMerge("inline-flex items-center justify-center flex-shrink-0",o==="circle"?"rounded-full":"rounded-lg",e==="subtle"&&"bg-gray-100 dark:bg-gray-800",e==="solid"&&"bg-brand text-white",e==="outline"&&"border-2 border-current",r);return jsx("div",{className:v,style:{width:x,height:x},children:jsx(k,{...c,name:s,size:n,color:i,weight:l,className:a,ariaLabel:d})})});Me.displayName="IconWithContainer";var bt="flex font-medium justify-center items-center gap-2 text-center transition rounded-[var(--control-border-radius)] whitespace-nowrap box-border",xt={default:"bg-action-default text-[color:var(--color-action-default-text)] hover:bg-action-default-hover forced-colors:bg-[ButtonText] forced-colors:text-[ButtonFace] border-2 border-transparent",brand:"bg-action-brand text-[color:var(--color-action-brand-text)] hover:bg-action-brand-hover forced-colors:bg-[ButtonText] forced-colors:text-[ButtonFace] border-2 border-transparent",secondary:"bg-transparent text-text-body border-2 border-border-muted hover:bg-text-body/5 forced-colors:border-[ButtonBorder] forced-colors:bg-[ButtonFace] forced-colors:text-[ButtonText]",ghost:"border-none text-text-body hover:bg-text-body/5 forced-colors:text-[ButtonText] forced-colors:hover:bg-[ButtonFace]",destructive:"bg-transparent text-feedback-error-text border-2 border-border-muted hover:bg-feedback-error-background/50 forced-colors:border-[ButtonBorder] forced-colors:bg-[ButtonFace] forced-colors:text-[Mark]",link:"!text-action-brand hover:text-action-brand/90 hover:underline hover:decoration-2 hover:underline-offset-4",icon:"border-none text-text-body hover:bg-background-hover hover:text-text-heading forced-colors:text-[ButtonText] forced-colors:hover:bg-[ButtonFace] p-1 flex-shrink-0 rounded-[var(--control-border-radius)]",unstyled:"bg-transparent"},Te={full:"w-full",default:"w-fit"},ht="opacity-50 cursor-not-allowed pointer-events-none",vt="opacity-100 cursor-pointer",yt={"top-right":"-right-2 -top-2","top-left":"-left-2 -top-2","bottom-right":"-right-2 -bottom-2","bottom-left":"-left-2 -bottom-2"},Pt={primary:"bg-action-brand text-white",destructive:"bg-action-destructive text-white"};function wt(e){return e?e==="primary"?"brand":e:"default"}function Nt(e){let{variant:o="default",size:t="md",isDisabled:r,fullWidth:n=false,isLoading:a=false}=e,s=wt(o),i=s==="unstyled"?"":`${bt} ${xt[s]}`;s!=="unstyled"&&(i+=` ${j[t].text} ${j[t].height} ${j[t].padding} ${j[t].gap}`),r||a?i+=` ${ht}`:i+=` ${vt}`,n?i+=` ${Te.full}`:i+=` ${Te.default}`;let l=s==="brand"?"focus-visible:outline-action-brand":void 0;return [i,Be(),l].filter(Boolean).join(" ")}function A(e){let{icon:o,children:t,isLoading:r=false,loadingText:n,loadingIndicator:a,size:s="md",iconPosition:i="left",iconWeight:l,href:d,className:p,badgeNumber:c,badgeVariant:f="primary",badgePosition:x="top-right",style:v,target:N,rel:B,...P}=e,m=o?jsx(k,{name:o,size:s,weight:l}):null,y=jsxs(Fragment,{children:[i==="left"&&m,typeof t=="function"?null:t,i==="right"&&m]}),C=jsxs("div",{className:"relative inline-flex items-center justify-center",children:[jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:a||jsx(k,{name:"CircleNotch",size:s,className:"animate-spin","aria-hidden":"true"})}),jsx("div",{className:"invisible","aria-hidden":"true",children:y}),n&&jsx("span",{className:"sr-only",role:"status","aria-live":"polite",children:n})]}),g=(c??0)>0,D=twMerge(Nt(e),p),I=d?{href:d,target:N,rel:B,...P}:{};if(d){let{onPress:R,onPressStart:V,onPressEnd:U,onPressChange:E,onPressUp:L,onAuxClick:te,onContextMenu:ke,onDoubleClick:le,...de}=P;Object.assign(I,de);}let T=d?jsx(Link,{...I,...r&&{"aria-busy":true},style:g?void 0:v,className:D,children:r?C:typeof t=="function"?(function(R){return jsxs(Fragment,{children:[i==="left"&&m,t(R),i==="right"&&m]})}):y}):jsx(Button,{...P,...r&&{"aria-busy":true},style:g?void 0:v,className:D,children:r?C:typeof t=="function"?(function(R){return jsxs(Fragment,{children:[i==="left"&&m,t(R),i==="right"&&m]})}):y});return g?jsxs("div",{className:twMerge("relative flex",p),style:v,children:[T,jsx("span",{className:`absolute ${yt[x]} flex h-5 w-5 items-center justify-center rounded-full ${Pt[f]} text-xs font-medium`,"aria-label":`${c} items`,children:c})]}):T}function he({action:e,defaultVariant:o,defaultSize:t="lg"}){let r=!!e.formId;return jsx(A,{type:r?"submit":"button",form:r?e.formId:void 0,size:e.size||t,variant:e.variant||o,onPress:r?void 0:e.onPress,isLoading:e.isLoading,isDisabled:e.isDisabled,children:e.label})}function W({primaryAction:e,secondaryAction:o,tertiaryAction:t,footerContent:r}){let n=e||o||t;return !n&&!r?null:jsxs("div",{className:`flex w-full flex-col items-center justify-center border-t p-4 ${r?"h-28":""}`,children:[r&&jsx("div",{className:"flex h-10 justify-center",children:r}),n&&jsxs("div",{className:"flex w-full items-center justify-between gap-3",children:[jsx("div",{children:t&&jsx(he,{action:t,defaultVariant:"destructive"})}),jsxs("div",{className:"flex items-center gap-3",children:[o&&jsx(he,{action:o,defaultVariant:"secondary"}),e&&jsx(he,{action:e,defaultVariant:"default"})]})]})]})}var Dt={xs:"text-base md:text-lg font-semibold",sm:"text-lg md:text-xl font-semibold",md:"text-xl md:text-2xl font-semibold",lg:"text-2xl md:text-3xl font-semibold",xl:"text-3xl md:text-4xl font-semibold"},Rt={page:"h-16 leading-[62px]"};function Y({tag:e="h1",size:o="lg",height:t,className:r="",children:n}){let a=Dt[o],s=t?Rt[t]:"";return jsx(e,{className:twMerge(a,s,r),children:n})}var w=({title:e,onClose:o,hideCloseIcon:t=false,titleAlign:r="left",hasBackArrow:n=false,onBack:a,headerContent:s})=>jsxs("div",{className:twMerge("relative flex h-16 w-full flex-shrink-0 items-center justify-between border-b px-6",e&&"border-b",r==="center"?"justify-center":""),children:[n&&jsx(A,{variant:"icon",onPress:a,className:"absolute left-6","aria-label":"Go back",children:jsx(k,{name:"CaretLeft","data-testid":"back-arrow"})}),s||jsxs(Fragment,{children:[e&&jsx(Y,{size:"xs",children:e}),o&&!t&&jsx(A,{variant:"icon",onPress:o,"aria-label":"Close dialog",children:jsx(k,{name:"X","data-testid":"close-button"})})]})]});var S=({width:e,height:o,variant:t="rect",animation:r="pulse",gradient:n=false,flex:a=false,stack:s,responsive:i,delay:l=0,adjustAnimationSpeedBasedOnWidth:d=false,ariaLabel:p,className:c,"data-testid":f})=>{let[x,v]=useState(l===0);if(useEffect(()=>{if(l>0){let g=setTimeout(()=>v(true),l);return ()=>clearTimeout(g)}},[l]),!x)return null;let N=n?"bg-gradient-to-r from-[var(--color-skeleton-base)] via-[var(--color-skeleton-highlight)] to-[var(--color-skeleton-base)]":"bg-[var(--color-skeleton-base)]",B=d&&e?(()=>{let g=typeof e=="number"?e:parseFloat(String(e));return isNaN(g)?"":`animation-duration-[${Math.max(.8,g/100)}s]`})():"",P=r==="pulse"?`animate-pulse ${B}`:r==="wave"?`relative overflow-hidden before:absolute before:inset-0 before:bg-gradient-to-r before:from-transparent before:via-[var(--color-skeleton-wave)] before:to-transparent before:animate-wave ${B}`:"",m="rounded-sm";t==="circle"&&(m="rounded-full"),t==="text"&&(m="h-4 w-full rounded-sm");let y=a?"flex-1 min-w-0":"",C=i?Object.entries(i).map(([g,D])=>`${g}:w-[${D}]`).join(" "):"";return s?jsx("div",{className:"space-y-2","data-testid":f,children:s.map((g,D)=>jsx("div",{className:twMerge(N,P,m,y,C,c),style:{width:g,height:o}},D))}):jsx("div",{className:twMerge(N,P,m,y,C,c),style:{width:e,height:o},role:"presentation","aria-hidden":!p,"aria-label":p??void 0,"data-testid":f})};var Mt={outlined:"bg-background-surface border border-border-default",elevated:"bg-background-surface border-0 shadow-md",filled:"bg-background-muted border-0",ghost:"bg-transparent border-0 shadow-none"},Ht="rounded-lg",Pe={square:"aspect-square",video:"aspect-video",wide:"aspect-[2/1]",auto:""},Tt={start:"justify-start",end:"justify-end",center:"justify-center",between:"justify-between"};function z({variant:e="outlined",className:o,children:t,isLoading:r=false,layout:n="default"}){return jsx("div",{className:twMerge("w-full overflow-hidden",Mt[e],Ht,n==="flex"&&"flex flex-col",o),"data-testid":"card",children:r?jsx(S,{width:"100%",height:"100%",className:"rounded-none"}):t})}function Ae({title:e,subtitle:o,actions:t,className:r,isLoading:n=false}){return n?jsxs("div",{className:twMerge("p-6 pb-4",r),children:[jsxs("div",{className:"flex justify-between items-start mb-1",children:[jsx(S,{width:120,height:20}),jsx(S,{width:24,height:24})]}),o&&jsx(S,{width:200,height:16})]}):!e&&!o&&!t?null:jsx("div",{className:twMerge("p-6 pb-4",r),children:jsxs("div",{className:"flex justify-between items-start gap-4",children:[jsxs("div",{className:"min-w-0 flex-1",children:[e&&jsx("div",{className:"mb-1",children:typeof e=="string"?jsx(Y,{tag:"h3",size:"sm",className:"text-text-heading",children:e}):e}),o&&jsx("div",{className:"text-sm text-text-muted",children:o})]}),t&&jsx("div",{className:"flex-shrink-0",children:t})]})})}function ze({src:e,alt:o,aspectRatio:t="auto",className:r,children:n,isLoading:a=false}){return a?jsx("div",{className:twMerge("bg-background-muted",Pe[t],r),children:jsx(S,{width:"100%",height:"100%"})}):n?jsx("div",{className:twMerge("overflow-hidden",Pe[t],r),children:n}):e?jsx("div",{className:twMerge("overflow-hidden",Pe[t],r),children:jsx("img",{src:e,alt:o||"",className:"w-full h-full object-cover",loading:"lazy"})}):null}function _e({className:e,children:o,isLoading:t=false,fill:r=false}){let a=e?.match(/p(?:t|b|l|r|x|y)?-(?:\d+(?:\.\d+)?|px|\[.+?\])/)?"":"px-6 py-4";return t?jsx("div",{className:twMerge(a,r&&"flex-1 flex flex-col min-h-0",e),children:jsxs("div",{className:"space-y-2",children:[jsx(S,{width:"100%",height:16}),jsx(S,{width:"80%",height:16}),jsx(S,{width:"60%",height:16})]})}):o?jsx("div",{className:twMerge("px-6 py-4 text-text-body",r&&"flex-1 flex flex-col min-h-0",e),children:o}):null}function $e({className:e,children:o,align:t="end",isLoading:r=false}){return r?jsxs("div",{className:twMerge("px-6 py-4 flex gap-2 justify-end",e),children:[jsx(S,{width:80,height:32}),jsx(S,{width:60,height:32})]}):o?jsx("div",{className:twMerge("px-6 py-4 flex items-center gap-2",Tt[t],e),children:o}):null}z.Header=Ae;z.Media=ze;z.Content=_e;z.Footer=$e;var M=class extends Component{constructor(){super(...arguments);ge(this,"state",{hasError:false});ge(this,"handleRetry",()=>{this.setState({hasError:false,error:void 0}),typeof window<"u"&&window.location.reload();});}static getDerivedStateFromError(t){return {hasError:true,error:t}}componentDidCatch(t,r){console.error("Error Boundary caught an error:",t,r);}render(){return this.state.hasError?this.props.fallback?this.props.fallback:jsxs(z,{children:[this.props.title&&jsx(z.Header,{title:this.props.title}),jsx(z.Content,{children:jsxs("div",{className:"flex flex-col items-center justify-center gap-4","data-testid":"error-boundary",children:[jsx("p",{className:"text-red-500",children:this.state.error?.message||"Something went wrong"}),jsx("button",{className:"rounded bg-blue-500 px-4 py-2 text-white hover:bg-blue-600",onClick:this.handleRetry,children:"Retry"})]})})]}):this.props.children}};function O({transparent:e=false,className:o,children:t,...r}){return jsx(ModalOverlay,{...r,className:composeRenderProps(o,(n,a)=>twMerge("fixed inset-0 z-50","outline-none focus:outline-none focus-visible:outline-none ring-0 focus:ring-0 focus-visible:ring-0",e?"bg-transparent":["bg-gradient-to-br from-black/20 via-black/15 to-black/20","backdrop-blur-[2px]","supports-[backdrop-filter]:bg-black/15"].join(" "),a.isEntering&&["animate-in fade-in","duration-300 ease-out"].join(" "),a.isExiting&&["animate-out fade-out","duration-200 ease-in"].join(" "),n)),children:t})}var Ot=.3,Vt=.5;function ne({children:e,title:o,headerContent:t,titleAlign:r="left",hideCloseIcon:n=false,hasBackArrow:a=false,onBack:s,isOpen:i,onClose:l,isDismissable:d=true,transparentOverlay:p=false,primaryAction:c,secondaryAction:f,footerContent:x,maxHeight:v="80vh",height:N,maxWidth:B="640px",contentPadding:P=true,showHandle:m=true,animationVariant:y="scale",className:C}){let[g,D]=useState(false),[I,T]=useState(0),[R,V]=useState(false),U=useRef(null),E=useRef(null),L=useRef({isDragging:false,startY:0,startTime:0,pointerId:null});useEffect(()=>{if(i){let h=setTimeout(()=>{D(true),setTimeout(()=>D(false),600);},400);return ()=>clearTimeout(h)}},[i]),useEffect(()=>{i||(T(0),V(false),L.current={isDragging:false,startY:0,startTime:0,pointerId:null});},[i]);let te=useCallback(h=>{d&&(h.pointerType!=="touch"&&h.pointerType!=="pen"||(E.current&&(clearTimeout(E.current),E.current=null),L.current={isDragging:true,startY:h.clientY,startTime:Date.now(),pointerId:h.pointerId},V(false),h.currentTarget.setPointerCapture(h.pointerId)));},[d]),ke=useCallback(h=>{let{isDragging:ce,startY:ue,pointerId:pe}=L.current;if(!ce||h.pointerId!==pe)return;let fe=h.clientY-ue;T(Math.max(0,fe));},[]),le=useCallback(h=>{let{isDragging:ce,startY:ue,startTime:pe,pointerId:fe}=L.current;if(!ce||h.pointerId!==fe)return;let me=h.clientY-ue,it=Date.now()-pe,st=me/it;L.current={isDragging:false,startY:0,startTime:0,pointerId:null};let lt=(U.current?.getBoundingClientRect().height??0)*Ot;(me>lt||st>Vt&&me>50)&&d?(l?.(),T(0)):(V(true),T(0),E.current=setTimeout(()=>{V(false),E.current=null;},200));},[d,l]);if(!i)return null;let de=o||t,at=c||f||x;return jsx(M,{children:jsx(O,{isOpen:i,onOpenChange:h=>{h||l?.();},isDismissable:d,transparent:p,className:"flex items-end justify-center p-0 sm:p-4",children:jsx(Modal,{className:"w-full max-w-full p-0 sm:p-2 outline-none focus:outline-none focus-visible:outline-none ring-0 focus:ring-0 focus-visible:ring-0",isDismissable:d,children:jsx("div",{ref:U,className:twMerge("w-full",R&&"transition-transform duration-200"),style:{transform:I>0?`translateY(${I}px)`:void 0},children:jsxs(Dialog,{className:twMerge("relative flex w-full flex-col overflow-hidden","bg-background-surface","shadow-2xl shadow-black/30 dark:shadow-black/60","border-t border-x border-border-default/40","outline-none focus:outline-none focus-visible:outline-none ring-0 focus:ring-0 focus-visible:ring-0 focus:shadow-none","origin-bottom",y==="scale"?"animate-[tray-enter-scale_400ms_cubic-bezier(0.32,0.72,0,1)]":"animate-[tray-enter_400ms_cubic-bezier(0.32,0.72,0,1)]",y==="scale"?"data-[exiting]:animate-[tray-exit-scale_250ms_cubic-bezier(0.32,0,0.67,0)]":"data-[exiting]:animate-[tray-exit_250ms_cubic-bezier(0.32,0,0.67,0)]",C),style:{maxWidth:B,...N?{height:N}:{maxHeight:v}},children:[m&&jsx("div",{className:"absolute top-0 left-0 right-0 h-8 z-10 flex justify-center items-start pt-2 touch-none cursor-grab active:cursor-grabbing",onPointerDown:te,onPointerMove:ke,onPointerUp:le,onPointerCancel:le,children:jsx("div",{className:twMerge("h-1 w-12 rounded-full bg-border-muted transition-all duration-300","hover:bg-border-default hover:w-16",g&&"animate-[handle-wiggle_0.6s_ease-in-out]")})}),de&&(a?jsx(w,{title:o,headerContent:t,titleAlign:r,hideCloseIcon:n||!l,hasBackArrow:true,onBack:s??(()=>{}),onClose:l||(()=>{})}):jsx(w,{title:o,headerContent:t,titleAlign:r,hideCloseIcon:n||!l,onClose:l||(()=>{})})),jsx("div",{className:twMerge("flex-1 min-h-0 overflow-y-auto overscroll-contain",P?"p-4":"p-0"),children:e}),at&&jsx(W,{primaryAction:c,secondaryAction:f,footerContent:x})]})})})})})}ne.displayName="Tray";function De({isOpen:e,onClose:o,title:t,headerContent:r,titleAlign:n="left",hideCloseIcon:a=false,hasBackArrow:s=false,onBack:i,children:l,primaryAction:d,secondaryAction:p,tertiaryAction:c,footerContent:f,transparentOverlay:x=false,maxWidth:v="600px",minWidth:N="400px",maxHeight:B="85vh",height:P,mobileMaxHeight:m="90vh",mobileHeight:y,contentPadding:C=true,className:g}){let D=Se("(max-width: 767px)"),I=useRef(null),T=useCallback(()=>{I.current&&I.current.scrollTop!==0&&(I.current.scrollTop=0);},[]),R=useRef(null),V=useCallback(()=>{R.current&&R.current.scrollTop!==0&&(R.current.scrollTop=0);},[]);if(e===false)return null;let U=t||r,E=d||p||c||f,L=e!==void 0;return D?L?jsx(ne,{isOpen:e,onClose:o,title:t,headerContent:r,titleAlign:n,hideCloseIcon:a,hasBackArrow:s,onBack:i,primaryAction:d,secondaryAction:p,footerContent:f,transparentOverlay:x,maxHeight:m,height:y,maxWidth:v,contentPadding:C,showHandle:true,animationVariant:"scale",className:g,children:l}):jsx(M,{children:jsx(O,{isDismissable:true,transparent:x,className:"flex items-end justify-center",children:jsx(Modal,{className:"w-full p-0 outline-none focus:outline-none focus-visible:outline-none ring-0 focus:ring-0 focus-visible:ring-0",children:jsxs(Dialog,{ref:I,onScroll:T,className:twMerge("relative flex w-full flex-col","bg-background-surface","shadow-2xl shadow-black/20","border-t border-x border-border-default/40","max-h-[90vh]","rounded-t-xl","overflow-hidden","animate-in slide-in-from-bottom","duration-300 ease-out","data-[exiting]:animate-out data-[exiting]:slide-out-to-bottom","data-[exiting]:duration-200 data-[exiting]:ease-in",g),style:{...y?{height:y}:{maxHeight:m}},children:[jsx("div",{className:"flex justify-center pt-2",children:jsx("div",{className:"h-1.5 w-12 rounded-full bg-border-muted"})}),U&&(s?jsx(w,{title:t,headerContent:r,titleAlign:n,hideCloseIcon:a||!o,hasBackArrow:true,onBack:i,onClose:o||(()=>{})}):jsx(w,{title:t,headerContent:r,titleAlign:n,hideCloseIcon:a||!o,onClose:o||(()=>{})})),jsx("div",{className:twMerge("flex-1 min-h-0 overflow-y-auto overscroll-contain",C?"px-6 py-6":"p-0"),children:l}),E&&jsx(W,{primaryAction:d,secondaryAction:p,tertiaryAction:c,footerContent:f})]})})})}):jsx(M,{children:jsx(O,{...L?{isOpen:e,onOpenChange:te=>{!te&&o&&o();}}:{},isDismissable:true,transparent:x,className:"flex items-center justify-center",children:jsx(Modal,{className:"w-full p-4 outline-none focus:outline-none focus-visible:outline-none ring-0 focus:ring-0 focus-visible:ring-0",style:{maxWidth:v},children:jsxs(Dialog,{ref:R,onScroll:V,className:twMerge("relative flex w-full flex-col","bg-background-surface","shadow-2xl shadow-black/20","border border-border-default/50","rounded-md","overflow-hidden","outline-none focus:outline-none focus-visible:outline-none ring-0 focus:ring-0","animate-in fade-in zoom-in-96 slide-in-from-bottom-2","duration-300 ease-out","data-[exiting]:animate-out data-[exiting]:fade-out data-[exiting]:zoom-out-95","data-[exiting]:duration-200 data-[exiting]:ease-in",g),style:{minWidth:N,...P?{height:P}:{maxHeight:B}},children:[U&&(s?jsx(w,{title:t,headerContent:r,titleAlign:n,hideCloseIcon:a||!o,hasBackArrow:true,onBack:i,onClose:o||(()=>{})}):jsx(w,{title:t,headerContent:r,titleAlign:n,hideCloseIcon:a||!o,onClose:o||(()=>{})})),jsx("div",{className:twMerge("flex-1 min-h-0 overflow-y-auto",C?"px-6 py-6":"p-0"),children:l}),E&&jsx(W,{primaryAction:d,secondaryAction:p,tertiaryAction:c,footerContent:f})]})})})})}function Z(e){return jsx(Form,{validationBehavior:"aria",...e,className:twMerge("flex flex-col gap-6",e.className)})}function mn({formId:e="dialog-form",onSubmit:o,primaryLabel:t="Save",secondaryLabel:r="Cancel",onCancel:n,primaryVariant:a,secondaryVariant:s="secondary",children:i,title:l,...d}){return jsx(De,{title:l,primaryAction:{label:t,onPress:()=>{let c=document.getElementById(e);c&&c.requestSubmit();},variant:a},secondaryAction:n?{label:r,onPress:n,variant:s}:void 0,...d,children:jsx(Z,{id:e,onSubmit:o,children:i})})}function ie({children:e,title:o,headerContent:t,titleAlign:r="left",hideCloseIcon:n=false,hasBackArrow:a=false,onBack:s,isOpen:i,slideInFrom:l="right",transparentOverlay:d=false,onClose:p,className:c,primaryAction:f,secondaryAction:x,footerContent:v,contentPadding:N=true,maxWidth:B="400px"}){if(!i)return null;let P=o||t,m=f||x||v;return jsx(M,{children:jsx(O,{isOpen:i,onOpenChange:y=>!y&&p?.(),isDismissable:true,transparent:d,children:jsx(Modal,{className:"outline-none focus:outline-none focus-visible:outline-none ring-0 focus:ring-0 focus-visible:ring-0",children:jsxs(Dialog,{className:twMerge("fixed top-0 bottom-0 flex flex-col bg-background-surface shadow-xl overflow-hidden",l==="right"?"right-0":"left-0",l==="right"?"animate-in slide-in-from-right duration-300 ease-out":"animate-in slide-in-from-left duration-300 ease-out","data-[exiting]:animate-out",l==="right"?"data-[exiting]:slide-out-to-right":"data-[exiting]:slide-out-to-left","data-[exiting]:duration-200 data-[exiting]:ease-in","outline-none focus-visible:outline focus-visible:outline-2 focus-visible:outline-action-default focus-visible:outline-offset-0",c),style:{maxWidth:B,width:"100%"},children:[P&&(a&&s?jsx(w,{title:o,headerContent:t,titleAlign:r,hideCloseIcon:n,hasBackArrow:true,onBack:s,onClose:p}):jsx(w,{title:o,headerContent:t,titleAlign:r,hideCloseIcon:n,onClose:p})),jsx("div",{className:twMerge("flex-1 overflow-y-auto overscroll-contain",N?"px-6 py-6":"p-0"),children:e}),m&&jsx(W,{primaryAction:f,secondaryAction:x,footerContent:v})]})})})})}ie.displayName="Drawer";function Bn({formId:e="drawer-form",onSubmit:o,primaryLabel:t="Save",secondaryLabel:r="Cancel",onCancel:n,primaryVariant:a,secondaryVariant:s="secondary",children:i,...l}){return jsx(ie,{primaryAction:{label:t,onPress:()=>{let p=document.getElementById(e);p&&p.requestSubmit();},variant:a},secondaryAction:n?{label:r,onPress:n,variant:s}:void 0,...l,children:jsx(Z,{id:e,onSubmit:o,className:"mt-2",children:i})})}function Hn({align:e="end",className:o,...t}){return jsx("div",{...t,className:twMerge("flex gap-2",e==="start"?"justify-start":e==="between"?"justify-between":"justify-end",o)})}var eo={sm:"gap-2",md:"gap-4",lg:"gap-6"};function to(e){if(!e)return "";let o=e.base?`grid-cols-${e.base}`:"",t=e.md?`md:grid-cols-${e.md}`:"",r=e.lg?`lg:grid-cols-${e.lg}`:"";return [o,t,r].filter(Boolean).join(" ")}function An({cols:e={base:1},gap:o="lg",className:t,...r}){return jsx("div",{...r,className:twMerge("grid",to(e),eo[o],t)})}var no=ro__default.forwardRef(({children:e,className:o},t)=>jsx("div",{ref:t,className:twMerge("relative w-full",o),children:e}));no.displayName="InputWrapper";function Ke({size:e="md",className:o,children:t,...r}){return jsx("div",{...r,className:twMerge("leading-[2.25] text-text-caption",j[e].text,o),children:t})}function Qn({title:e,description:o,showDivider:t,className:r,children:n,...a}){return jsxs("section",{...a,className:twMerge("flex flex-col",r),children:[(e||o)&&jsxs("div",{className:"flex flex-col gap-1 mb-6",children:[typeof e=="string"?jsx(Y,{tag:"h3",size:"sm",children:e}):e,o?jsx(Ke,{size:"lg",children:o}):null]}),jsx("div",{className:"flex flex-col gap-6",children:n}),t&&jsx("hr",{className:"mt-2 border-border-muted"})]})}function Xn(){return jsx("hr",{className:"border-border-muted"})}function ta({steps:e,currentStepId:o,onStepClick:t,className:r}){let n=e.findIndex(a=>a.id===o);return jsx("nav",{"aria-label":"Progress",className:twMerge("w-full",r),children:jsx("div",{className:"relative mb-12",children:jsx("ol",{className:"relative flex items-start justify-between",children:e.map((a,s)=>{let i=a.id===o,l=s<n,d=t&&(l||i);return jsxs("li",{className:"relative flex flex-col items-center",style:{flex:`1 1 ${100/e.length}%`},children:[jsx("button",{type:"button",disabled:!d,onClick:()=>d&&t?.(a.id),className:twMerge("relative z-10 flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-full border-2 transition-colors bg-background-body",l&&"border-action-default bg-action-default text-text-onPrimary hover:bg-action-default/90",i&&"border-action-default bg-background-body text-action-default",!l&&!i&&"border-border-default bg-background-body text-text-muted",d&&"cursor-pointer",!d&&"cursor-default"),"aria-current":i?"step":void 0,children:l?jsx(k,{name:"Check",size:20,weight:"bold"}):jsx("span",{className:"text-sm font-semibold",children:s+1})}),s<e.length-1&&jsx("div",{className:"absolute top-5 h-0.5 transition-colors",style:{left:"50%",width:"100%",marginLeft:"20px",backgroundColor:s<n?"var(--color-action-default)":"var(--color-border-default)"}}),jsxs("div",{className:"mt-3 flex flex-col items-center text-center w-32",children:[jsx("span",{className:twMerge("text-sm font-medium",i&&"text-text-default",l&&"text-text-body",!i&&!l&&"text-text-muted"),children:a.title}),a.description&&jsx("span",{className:"mt-1 text-xs text-text-caption",children:a.description})]})]},a.id)})})})})}function ia({formId:e,show:o,isSubmitting:t,onCancel:r,primaryLabel:n="Save changes",secondaryLabel:a="Cancel",className:s}){return o?jsx("div",{className:twMerge("fixed inset-x-0 bottom-0 z-40 border-t border-border-muted bg-background-surface/95 backdrop-blur supports-[backdrop-filter]:bg-background-surface/70",s),children:jsxs("div",{className:"mx-auto flex max-w-screen-lg items-center justify-between gap-3 p-3",children:[jsx("div",{className:"text-sm text-text-muted",children:"You have unsaved changes"}),jsxs("div",{className:"flex gap-2",children:[jsx(A,{variant:"secondary",onPress:r,children:a}),jsx(A,{type:"submit",form:e,isDisabled:!!t,children:t?"Saving...":n})]})]})}):null}function da({when:e,message:o="You have unsaved changes. Leave anyway?"}){return ro.useEffect(()=>{if(!e)return;let t=r=>(r.preventDefault(),r.returnValue=o,o);return window.addEventListener("beforeunload",t),()=>window.removeEventListener("beforeunload",t)},[e,o]),null}function ua({steps:e,initialStepId:o,canNavigate:t}){if(e.length===0)throw new Error("useWizard: steps array cannot be empty");let[r,n]=ro.useState(o||e[0].id),a=e.findIndex(c=>c.id===r),s=a>0,i=a<e.length-1,l=async c=>c===r?true:t&&!await t(r,c)?false:(n(c),true);return {steps:e,currentStepId:r,setCurrentStepId:l,next:async()=>!i||a===-1?false:l(e[a+1].id),prev:async()=>!s||a===-1?false:l(e[a-1].id),hasNext:i,hasPrev:s,stepIndex:a}}export{mn as DialogForm,Bn as DrawerForm,Hn as FormActions,Xn as FormDivider,An as FormGrid,Qn as FormSection,ta as FormStepper,ia as SaveBar,da as UnsavedChangesPrompt,ua as useWizard};//# sourceMappingURL=index.js.map
1
+ import*as fo from'react';import fo__default,{memo,useRef,useCallback,useEffect,useState,Component}from'react';import {Modal,Dialog,Form,Link,Button,ModalOverlay,composeRenderProps}from'react-aria-components';import {twMerge}from'tailwind-merge';import*as yt from'@phosphor-icons/react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';var mt=Object.defineProperty;var gt=(e,o,t)=>o in e?mt(e,o,{enumerable:true,configurable:true,writable:true,value:t}):e[o]=t;var Ne=(e,o,t)=>gt(e,typeof o!="symbol"?o+"":o,t);function Le(e,o=false){let[t,r]=useState(o);return useEffect(()=>{if(typeof window>"u")return;let n=window.matchMedia(e);r(n.matches);let a=s=>{r(s.matches);};return n.addEventListener("change",a),()=>{n.removeEventListener("change",a);}},[e]),t}function pe(e=true){let[o,t]=useState(null);return useEffect(()=>{if(!e){t(null);return}let r=typeof window<"u"?window.visualViewport:null;if(!r)return;let n=()=>{let a=Math.max(0,window.innerHeight-r.height-(r.offsetTop??0));t({height:r.height,keyboardOffset:a});};return n(),r.addEventListener("resize",n),r.addEventListener("scroll",n),()=>{r.removeEventListener("resize",n),r.removeEventListener("scroll",n);}},[e]),o}function Ae(e=false){return `${e?"outline outline-1 outline-border-input data-[focus-visible]:outline-2 data-[focus-visible]:outline-action-default data-[focus-visible]:outline-offset-0 invalid:outline-2 invalid:outline-feedback-error-border group-invalid:outline-2 group-invalid:outline-feedback-error-border forced-colors:focus:outline-[Highlight] forced-colors:focus:outline-2 forced-colors:focus:outline-offset-2":"outline-none data-[focus-visible]:outline data-[focus-visible]:outline-2 data-[focus-visible]:outline-action-default data-[focus-visible]:outline-offset-0 invalid:outline-2 invalid:outline-feedback-error-border group-invalid:outline-2 group-invalid:outline-feedback-error-border forced-colors:focus:outline-[Highlight] forced-colors:focus:outline-2 forced-colors:focus:outline-offset-2"}`}var Q={sm:{text:"text-[length:var(--control-text-sm)]",height:"h-[var(--control-sm-height)]",padding:"px-[var(--control-padding-sm)]",paddingY:"py-[var(--control-gap-sm)]",gap:"gap-[var(--control-gap-sm)]"},md:{text:"text-[length:var(--control-text-md)]",height:"h-[var(--control-md-height)]",padding:"px-[var(--control-padding-md)]",paddingY:"py-[var(--control-gap-md)]",gap:"gap-[var(--control-gap-md)]"},lg:{text:"text-[length:var(--control-text-lg)]",height:"h-[var(--control-lg-height)]",padding:"px-[var(--control-padding-lg)]",paddingY:"py-[var(--control-gap-lg)]",gap:"gap-[var(--control-gap-lg)]"},xl:{text:"text-[length:var(--control-text-xl)]",height:"h-[var(--control-xl-height)]",padding:"px-[var(--control-padding-xl)]",paddingY:"py-[var(--control-gap-xl)]",gap:"gap-[var(--control-gap-xl)]"}};var te={xs:16,sm:20,md:24,lg:32,xl:40,"2xl":48},D=memo(({name:e,size:o="md",color:t,weight:r="regular",className:n,ariaLabel:a,...s})=>{let i=yt[e];if(!i)return process.env.NODE_ENV==="development"&&console.error(`Icon "${e}" not found in @phosphor-icons/react`),null;let l=typeof o=="string"&&o in te?te[o]:o,d=twMerge("inline-block flex-shrink-0",!t&&"text-current",n);return jsx(i,{...s,size:l,color:t,weight:r,className:d,"aria-label":a||`${e} icon`,"data-testid":`icon-${e}`})});D.displayName="Icon";var $e=memo(({variant:e="subtle",shape:o="square",containerSize:t,containerClassName:r,size:n="md",className:a,name:s,color:i,weight:l,ariaLabel:d,ref:f,...c})=>{let g=typeof n=="string"&&n in te?te[n]:n,v=t?typeof t=="string"&&t in te?te[t]:t:g*1.75,b=twMerge("inline-flex items-center justify-center flex-shrink-0",o==="circle"?"rounded-full":"rounded-lg",e==="subtle"&&"bg-gray-100 dark:bg-gray-800",e==="solid"&&"bg-brand text-white",e==="outline"&&"border-2 border-current",r);return jsx("div",{className:b,style:{width:v,height:v},children:jsx(D,{...c,name:s,size:n,color:i,weight:l,className:a,ariaLabel:d})})});$e.displayName="IconWithContainer";var Nt="flex font-medium justify-center items-center gap-2 text-center transition rounded-[var(--control-border-radius)] whitespace-nowrap box-border",Ct={default:"bg-action-default text-[color:var(--color-action-default-text)] hover:bg-action-default-hover forced-colors:bg-[ButtonText] forced-colors:text-[ButtonFace] border-2 border-transparent",brand:"bg-action-brand text-[color:var(--color-action-brand-text)] hover:bg-action-brand-hover forced-colors:bg-[ButtonText] forced-colors:text-[ButtonFace] border-2 border-transparent",secondary:"bg-transparent text-text-body border-2 border-border-muted hover:bg-text-body/5 forced-colors:border-[ButtonBorder] forced-colors:bg-[ButtonFace] forced-colors:text-[ButtonText]",ghost:"border-none text-text-body hover:bg-text-body/5 forced-colors:text-[ButtonText] forced-colors:hover:bg-[ButtonFace]",destructive:"bg-transparent text-feedback-error-text border-2 border-border-muted hover:bg-feedback-error-background/50 forced-colors:border-[ButtonBorder] forced-colors:bg-[ButtonFace] forced-colors:text-[Mark]",link:"!text-action-brand hover:text-action-brand/90 hover:underline hover:decoration-2 hover:underline-offset-4",icon:"border-none text-text-body hover:bg-background-hover hover:text-text-heading forced-colors:text-[ButtonText] forced-colors:hover:bg-[ButtonFace] p-1 flex-shrink-0 rounded-[var(--control-border-radius)]",unstyled:"bg-transparent"},_e={full:"w-full",default:"w-fit"},Rt="opacity-50 cursor-not-allowed pointer-events-none",Dt="opacity-100 cursor-pointer",kt={"top-right":"-right-2 -top-2","top-left":"-left-2 -top-2","bottom-right":"-right-2 -bottom-2","bottom-left":"-left-2 -bottom-2"},St={primary:"bg-action-brand text-white",destructive:"bg-action-destructive text-white"};function Bt(e){return e?e==="primary"?"brand":e:"default"}function It(e){let{variant:o="default",size:t="md",isDisabled:r,fullWidth:n=false,isLoading:a=false}=e,s=Bt(o),i=s==="unstyled"?"":`${Nt} ${Ct[s]}`;s!=="unstyled"&&(i+=` ${Q[t].text} ${Q[t].height} ${Q[t].padding} ${Q[t].gap}`),r||a?i+=` ${Rt}`:i+=` ${Dt}`,n?i+=` ${_e.full}`:i+=` ${_e.default}`;let l=s==="brand"?"focus-visible:outline-action-brand":void 0;return [i,Ae(),l].filter(Boolean).join(" ")}function z(e){let{icon:o,children:t,isLoading:r=false,loadingText:n,loadingIndicator:a,size:s="md",iconPosition:i="left",iconWeight:l,href:d,className:f,badgeNumber:c,badgeVariant:g="primary",badgePosition:v="top-right",style:b,target:C,rel:S,...w}=e,p=o?jsx(D,{name:o,size:s,weight:l}):null,y=jsxs(Fragment,{children:[i==="left"&&p,typeof t=="function"?null:t,i==="right"&&p]}),R=jsxs("div",{className:"relative inline-flex items-center justify-center",children:[jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:a||jsx(D,{name:"CircleNotch",size:s,className:"animate-spin","aria-hidden":"true"})}),jsx("div",{className:"invisible","aria-hidden":"true",children:y}),n&&jsx("span",{className:"sr-only",role:"status","aria-live":"polite",children:n})]}),h=(c??0)>0,P=twMerge(It(e),f),O=d?{href:d,target:C,rel:S,...w}:{};if(d){let{onPress:M,onPressStart:I,onPressEnd:ne,onPressChange:_,onPressUp:K,onAuxClick:ae,onContextMenu:Z,onDoubleClick:L,...F}=w;Object.assign(O,F);}let B=d?jsx(Link,{...O,...r&&{"aria-busy":true},style:h?void 0:b,className:P,children:r?R:typeof t=="function"?(function(M){return jsxs(Fragment,{children:[i==="left"&&p,t(M),i==="right"&&p]})}):y}):jsx(Button,{...w,...r&&{"aria-busy":true},style:h?void 0:b,className:P,children:r?R:typeof t=="function"?(function(M){return jsxs(Fragment,{children:[i==="left"&&p,t(M),i==="right"&&p]})}):y});return h?jsxs("div",{className:twMerge("relative flex",f),style:b,children:[B,jsx("span",{className:`absolute ${kt[v]} flex h-5 w-5 items-center justify-center rounded-full ${St[g]} text-xs font-medium`,"aria-label":`${c} items`,children:c})]}):B}function De({action:e,defaultVariant:o,defaultSize:t="lg"}){let r=!!e.formId;return jsx(z,{type:r?"submit":"button",form:r?e.formId:void 0,size:e.size||t,variant:e.variant||o,onPress:r?void 0:e.onPress,isLoading:e.isLoading,isDisabled:e.isDisabled,children:e.label})}function j({primaryAction:e,secondaryAction:o,tertiaryAction:t,footerContent:r}){let n=e||o||t;return !n&&!r?null:jsxs("div",{className:`flex w-full flex-col items-center justify-center border-t p-4 ${r?"h-28":""}`,children:[r&&jsx("div",{className:"flex h-10 justify-center",children:r}),n&&jsxs("div",{className:"flex w-full items-center justify-between gap-3",children:[jsx("div",{children:t&&jsx(De,{action:t,defaultVariant:"destructive"})}),jsxs("div",{className:"flex items-center gap-3",children:[o&&jsx(De,{action:o,defaultVariant:"secondary"}),e&&jsx(De,{action:e,defaultVariant:"default"})]})]})]})}var Tt={xs:"text-base md:text-lg font-semibold",sm:"text-lg md:text-xl font-semibold",md:"text-xl md:text-2xl font-semibold",lg:"text-2xl md:text-3xl font-semibold",xl:"text-3xl md:text-4xl font-semibold"},Et={page:"h-16 leading-[62px]"};function X({tag:e="h1",size:o="lg",height:t,className:r="",children:n}){let a=Tt[o],s=t?Et[t]:"";return jsx(e,{className:twMerge(a,s,r),children:n})}var N=({title:e,onClose:o,hideCloseIcon:t=false,titleAlign:r="left",hasBackArrow:n=false,onBack:a,headerContent:s})=>jsxs("div",{className:twMerge("relative flex h-16 w-full flex-shrink-0 items-center justify-between border-b px-6",e&&"border-b",r==="center"?"justify-center":""),children:[n&&jsx(z,{variant:"icon",onPress:a,className:"absolute left-6","aria-label":"Go back",children:jsx(D,{name:"CaretLeft","data-testid":"back-arrow"})}),s||jsxs(Fragment,{children:[e&&jsx(X,{size:"xs",children:e}),o&&!t&&jsx(z,{variant:"icon",onPress:o,"aria-label":"Close dialog",children:jsx(D,{name:"X","data-testid":"close-button"})})]})]});var k=({width:e,height:o,variant:t="rect",animation:r="pulse",gradient:n=false,flex:a=false,stack:s,responsive:i,delay:l=0,adjustAnimationSpeedBasedOnWidth:d=false,ariaLabel:f,className:c,"data-testid":g})=>{let[v,b]=useState(l===0);if(useEffect(()=>{if(l>0){let h=setTimeout(()=>b(true),l);return ()=>clearTimeout(h)}},[l]),!v)return null;let C=n?"bg-gradient-to-r from-[var(--color-skeleton-base)] via-[var(--color-skeleton-highlight)] to-[var(--color-skeleton-base)]":"bg-[var(--color-skeleton-base)]",S=d&&e?(()=>{let h=typeof e=="number"?e:parseFloat(String(e));return isNaN(h)?"":`animation-duration-[${Math.max(.8,h/100)}s]`})():"",w=r==="pulse"?`animate-pulse ${S}`:r==="wave"?`relative overflow-hidden before:absolute before:inset-0 before:bg-gradient-to-r before:from-transparent before:via-[var(--color-skeleton-wave)] before:to-transparent before:animate-wave ${S}`:"",p="rounded-sm";t==="circle"&&(p="rounded-full"),t==="text"&&(p="h-4 w-full rounded-sm");let y=a?"flex-1 min-w-0":"",R=i?Object.entries(i).map(([h,P])=>`${h}:w-[${P}]`).join(" "):"";return s?jsx("div",{className:"space-y-2","data-testid":g,children:s.map((h,P)=>jsx("div",{className:twMerge(C,w,p,y,R,c),style:{width:h,height:o}},P))}):jsx("div",{className:twMerge(C,w,p,y,R,c),style:{width:e,height:o},role:"presentation","aria-hidden":!f,"aria-label":f??void 0,"data-testid":g})};var Vt={outlined:"bg-background-surface border border-border-default",elevated:"bg-background-surface border-0 shadow-md",filled:"bg-background-muted border-0",ghost:"bg-transparent border-0 shadow-none"},$t="rounded-lg",Be={square:"aspect-square",video:"aspect-video",wide:"aspect-[2/1]",auto:""},Ot={start:"justify-start",end:"justify-end",center:"justify-center",between:"justify-between"};function V({variant:e="outlined",className:o,children:t,isLoading:r=false,layout:n="default"}){return jsx("div",{className:twMerge("w-full overflow-hidden",Vt[e],$t,n==="flex"&&"flex flex-col",o),"data-testid":"card",children:r?jsx(k,{width:"100%",height:"100%",className:"rounded-none"}):t})}function Ye({title:e,subtitle:o,actions:t,className:r,isLoading:n=false}){return n?jsxs("div",{className:twMerge("p-6 pb-4",r),children:[jsxs("div",{className:"flex justify-between items-start mb-1",children:[jsx(k,{width:120,height:20}),jsx(k,{width:24,height:24})]}),o&&jsx(k,{width:200,height:16})]}):!e&&!o&&!t?null:jsx("div",{className:twMerge("p-6 pb-4",r),children:jsxs("div",{className:"flex justify-between items-start gap-4",children:[jsxs("div",{className:"min-w-0 flex-1",children:[e&&jsx("div",{className:"mb-1",children:typeof e=="string"?jsx(X,{tag:"h3",size:"sm",className:"text-text-heading",children:e}):e}),o&&jsx("div",{className:"text-sm text-text-muted",children:o})]}),t&&jsx("div",{className:"flex-shrink-0",children:t})]})})}function Ge({src:e,alt:o,aspectRatio:t="auto",className:r,children:n,isLoading:a=false}){return a?jsx("div",{className:twMerge("bg-background-muted",Be[t],r),children:jsx(k,{width:"100%",height:"100%"})}):n?jsx("div",{className:twMerge("overflow-hidden",Be[t],r),children:n}):e?jsx("div",{className:twMerge("overflow-hidden",Be[t],r),children:jsx("img",{src:e,alt:o||"",className:"w-full h-full object-cover",loading:"lazy"})}):null}function Ue({className:e,children:o,isLoading:t=false,fill:r=false}){let a=e?.match(/p(?:t|b|l|r|x|y)?-(?:\d+(?:\.\d+)?|px|\[.+?\])/)?"":"px-6 py-4";return t?jsx("div",{className:twMerge(a,r&&"flex-1 flex flex-col min-h-0",e),children:jsxs("div",{className:"space-y-2",children:[jsx(k,{width:"100%",height:16}),jsx(k,{width:"80%",height:16}),jsx(k,{width:"60%",height:16})]})}):o?jsx("div",{className:twMerge("px-6 py-4 text-text-body",r&&"flex-1 flex flex-col min-h-0",e),children:o}):null}function qe({className:e,children:o,align:t="end",isLoading:r=false}){return r?jsxs("div",{className:twMerge("px-6 py-4 flex gap-2 justify-end",e),children:[jsx(k,{width:80,height:32}),jsx(k,{width:60,height:32})]}):o?jsx("div",{className:twMerge("px-6 py-4 flex items-center gap-2",Ot[t],e),children:o}):null}V.Header=Ye;V.Media=Ge;V.Content=Ue;V.Footer=qe;var E=class extends Component{constructor(){super(...arguments);Ne(this,"state",{hasError:false});Ne(this,"handleRetry",()=>{this.setState({hasError:false,error:void 0}),typeof window<"u"&&window.location.reload();});}static getDerivedStateFromError(t){return {hasError:true,error:t}}componentDidCatch(t,r){console.error("Error Boundary caught an error:",t,r);}render(){return this.state.hasError?this.props.fallback?this.props.fallback:jsxs(V,{children:[this.props.title&&jsx(V.Header,{title:this.props.title}),jsx(V.Content,{children:jsxs("div",{className:"flex flex-col items-center justify-center gap-4","data-testid":"error-boundary",children:[jsx("p",{className:"text-red-500",children:this.state.error?.message||"Something went wrong"}),jsx("button",{className:"rounded bg-blue-500 px-4 py-2 text-white hover:bg-blue-600",onClick:this.handleRetry,children:"Retry"})]})})]}):this.props.children}};function Y({transparent:e=false,className:o,children:t,...r}){return jsx(ModalOverlay,{...r,className:composeRenderProps(o,(n,a)=>twMerge("fixed inset-0 z-50","outline-none focus:outline-none focus-visible:outline-none ring-0 focus:ring-0 focus-visible:ring-0",e?"bg-transparent":["bg-gradient-to-br from-black/20 via-black/15 to-black/20","backdrop-blur-[2px]","supports-[backdrop-filter]:bg-black/15"].join(" "),a.isEntering&&["animate-in fade-in","duration-300 ease-out"].join(" "),a.isExiting&&["animate-out fade-out","duration-200 ease-in"].join(" "),n)),children:t})}var Qt=.3,Xt=.5;function he({children:e,title:o,headerContent:t,titleAlign:r="left",hideCloseIcon:n=false,hasBackArrow:a=false,onBack:s,isOpen:i,onClose:l,isDismissable:d=true,transparentOverlay:f=false,primaryAction:c,secondaryAction:g,footerContent:v,maxHeight:b="80vh",height:C,maxWidth:S="640px",contentPadding:w=true,showHandle:p=true,animationVariant:y="scale",className:R}){let[h,P]=useState(false),[O,B]=useState(0),[M,I]=useState(false),ne=pe(i),_=ne?.height??null,K=ne?.keyboardOffset??0,ae=useRef(null),Z=useRef(null),L=useRef(null),F=useRef({isDragging:false,startY:0,startTime:0,pointerId:null});useEffect(()=>{if(i){let m=setTimeout(()=>{P(true),setTimeout(()=>P(false),600);},400);return ()=>clearTimeout(m)}},[i]),useEffect(()=>{i||(B(0),I(false),F.current={isDragging:false,startY:0,startTime:0,pointerId:null});},[i]),useEffect(()=>{let m=Z.current;if(!m||!i)return;let A=null,ee=le=>{let q=le.target;q&&["INPUT","TEXTAREA","SELECT"].includes(q.tagName)&&(A&&clearTimeout(A),A=setTimeout(()=>{q.scrollIntoView({block:"nearest",behavior:"smooth"});},320));};return m.addEventListener("focusin",ee),()=>{m.removeEventListener("focusin",ee),A&&clearTimeout(A);}},[i]);let G=useCallback(m=>{d&&(m.pointerType!=="touch"&&m.pointerType!=="pen"||(L.current&&(clearTimeout(L.current),L.current=null),F.current={isDragging:true,startY:m.clientY,startTime:Date.now(),pointerId:m.pointerId},I(false),m.currentTarget.setPointerCapture(m.pointerId)));},[d]),U=useCallback(m=>{let{isDragging:A,startY:ee,pointerId:le}=F.current;if(!A||m.pointerId!==le)return;let q=m.clientY-ee;B(Math.max(0,q));},[]),ie=useCallback(m=>{let{isDragging:A,startY:ee,startTime:le,pointerId:q}=F.current;if(!A||m.pointerId!==q)return;let we=m.clientY-ee,ut=Date.now()-le,ft=we/ut;F.current={isDragging:false,startY:0,startTime:0,pointerId:null};let pt=(ae.current?.getBoundingClientRect().height??0)*Qt;(we>pt||ft>Xt&&we>50)&&d?(l?.(),B(0)):(I(true),B(0),L.current=setTimeout(()=>{I(false),L.current=null;},200));},[d,l]);if(!i)return null;let Pe=o||t,se=c||g||v;return jsx(E,{children:jsx(Y,{isOpen:i,onOpenChange:m=>{m||l?.();},isDismissable:d,transparent:f,style:{paddingBottom:K>0?`${K}px`:void 0,transition:"padding-bottom 0.25s ease-out"},className:"flex items-end justify-center p-0 sm:p-4",children:jsx(Modal,{className:"w-full max-w-full p-0 sm:p-2 outline-none focus:outline-none focus-visible:outline-none ring-0 focus:ring-0 focus-visible:ring-0",isDismissable:d,children:jsx("div",{ref:ae,className:twMerge("w-full",M&&"transition-transform duration-200"),style:{transform:O>0?`translateY(${O}px)`:void 0},children:jsxs(Dialog,{className:twMerge("relative flex w-full flex-col overflow-hidden","bg-background-surface","shadow-2xl shadow-black/30 dark:shadow-black/60","border-t border-x border-border-default/40","outline-none focus:outline-none focus-visible:outline-none ring-0 focus:ring-0 focus-visible:ring-0 focus:shadow-none","origin-bottom",y==="scale"?"animate-[tray-enter-scale_400ms_cubic-bezier(0.32,0.72,0,1)]":"animate-[tray-enter_400ms_cubic-bezier(0.32,0.72,0,1)]",y==="scale"?"data-[exiting]:animate-[tray-exit-scale_250ms_cubic-bezier(0.32,0,0.67,0)]":"data-[exiting]:animate-[tray-exit_250ms_cubic-bezier(0.32,0,0.67,0)]",R),style:{maxWidth:S,...C?{height:C}:{maxHeight:/\d/.test(b)?_!==null?`min(${b}, ${Math.max(_-8,0)}px, 100dvh)`:`min(${b}, 100dvh)`:b}},children:[p&&jsx("div",{className:"absolute top-0 left-0 right-0 h-8 z-10 flex justify-center items-start pt-2 touch-none cursor-grab active:cursor-grabbing",onPointerDown:G,onPointerMove:U,onPointerUp:ie,onPointerCancel:ie,children:jsx("div",{className:twMerge("h-1 w-12 rounded-full bg-border-muted transition-all duration-300","hover:bg-border-default hover:w-16",h&&"animate-[handle-wiggle_0.6s_ease-in-out]")})}),Pe&&(a?jsx(N,{title:o,headerContent:t,titleAlign:r,hideCloseIcon:n||!l,hasBackArrow:true,onBack:s??(()=>{}),onClose:l||(()=>{})}):jsx(N,{title:o,headerContent:t,titleAlign:r,hideCloseIcon:n||!l,onClose:l||(()=>{})})),jsx("div",{ref:Z,className:twMerge("flex-1 min-h-0 overflow-y-auto overscroll-contain",w?"p-4":"p-0"),children:e}),se&&jsx(j,{primaryAction:c,secondaryAction:g,footerContent:v})]})})})})})}he.displayName="Tray";function He({isOpen:e,onClose:o,title:t,headerContent:r,titleAlign:n="left",hideCloseIcon:a=false,hasBackArrow:s=false,onBack:i,children:l,primaryAction:d,secondaryAction:f,tertiaryAction:c,footerContent:g,transparentOverlay:v=false,maxWidth:b="600px",minWidth:C="400px",maxHeight:S="85vh",height:w,mobileMaxHeight:p="90vh",mobileHeight:y,contentPadding:R=true,className:h}){let P=Le("(max-width: 767px)"),O=pe(P&&e===void 0),B=O?.height??null,M=O?.keyboardOffset??0,I=useRef(null),ne=useCallback(()=>{I.current&&I.current.scrollTop!==0&&(I.current.scrollTop=0);},[]),_=useRef(null),K=useRef(null);useEffect(()=>{let G=K.current;if(!G||!P)return;let U=null,ie=Pe=>{let se=Pe.target;se&&["INPUT","TEXTAREA","SELECT"].includes(se.tagName)&&(U&&clearTimeout(U),U=setTimeout(()=>{se.scrollIntoView({block:"nearest",behavior:"smooth"});},320));};return G.addEventListener("focusin",ie),()=>{G.removeEventListener("focusin",ie),U&&clearTimeout(U);}},[P]);let ae=useCallback(()=>{_.current&&_.current.scrollTop!==0&&(_.current.scrollTop=0);},[]);if(e===false)return null;let Z=t||r,L=d||f||c||g,F=e!==void 0;return P?F?jsx(he,{isOpen:e,onClose:o,title:t,headerContent:r,titleAlign:n,hideCloseIcon:a,hasBackArrow:s,onBack:i,primaryAction:d,secondaryAction:f,footerContent:g,transparentOverlay:v,maxHeight:p,height:y,maxWidth:b,contentPadding:R,showHandle:true,animationVariant:"scale",className:h,children:l}):jsx(E,{children:jsx(Y,{isDismissable:true,transparent:v,style:{paddingBottom:M>0?`${M}px`:void 0,transition:"padding-bottom 0.25s ease-out"},className:"flex items-end justify-center",children:jsx(Modal,{className:"w-full p-0 outline-none focus:outline-none focus-visible:outline-none ring-0 focus:ring-0 focus-visible:ring-0",children:jsxs(Dialog,{ref:I,onScroll:ne,className:twMerge("relative flex w-full flex-col","bg-background-surface","shadow-2xl shadow-black/20","border-t border-x border-border-default/40","rounded-t-xl","overflow-hidden","animate-in slide-in-from-bottom","duration-300 ease-out","data-[exiting]:animate-out data-[exiting]:slide-out-to-bottom","data-[exiting]:duration-200 data-[exiting]:ease-in",h),style:{...y?{height:y}:{maxHeight:/\d/.test(p)?B!==null?`min(${p}, ${Math.max(B-8,0)}px, 100dvh)`:`min(${p}, 100dvh)`:p}},children:[jsx("div",{className:"flex justify-center pt-2",children:jsx("div",{className:"h-1.5 w-12 rounded-full bg-border-muted"})}),Z&&(s?jsx(N,{title:t,headerContent:r,titleAlign:n,hideCloseIcon:a||!o,hasBackArrow:true,onBack:i,onClose:o||(()=>{})}):jsx(N,{title:t,headerContent:r,titleAlign:n,hideCloseIcon:a||!o,onClose:o||(()=>{})})),jsx("div",{ref:K,className:twMerge("flex-1 min-h-0 overflow-y-auto overscroll-contain",R?"px-6 py-6":"p-0"),children:l}),L&&jsx(j,{primaryAction:d,secondaryAction:f,tertiaryAction:c,footerContent:g})]})})})}):jsx(E,{children:jsx(Y,{...F?{isOpen:e,onOpenChange:G=>{!G&&o&&o();}}:{},isDismissable:true,transparent:v,className:"flex items-center justify-center",children:jsx(Modal,{className:"w-full p-4 outline-none focus:outline-none focus-visible:outline-none ring-0 focus:ring-0 focus-visible:ring-0",style:{maxWidth:b},children:jsxs(Dialog,{ref:_,onScroll:ae,className:twMerge("relative flex w-full flex-col","bg-background-surface","shadow-2xl shadow-black/20","border border-border-default/50","rounded-md","overflow-hidden","outline-none focus:outline-none focus-visible:outline-none ring-0 focus:ring-0","animate-in fade-in zoom-in-96 slide-in-from-bottom-2","duration-300 ease-out","data-[exiting]:animate-out data-[exiting]:fade-out data-[exiting]:zoom-out-95","data-[exiting]:duration-200 data-[exiting]:ease-in",h),style:{minWidth:C,...w?{height:w}:{maxHeight:S}},children:[Z&&(s?jsx(N,{title:t,headerContent:r,titleAlign:n,hideCloseIcon:a||!o,hasBackArrow:true,onBack:i,onClose:o||(()=>{})}):jsx(N,{title:t,headerContent:r,titleAlign:n,hideCloseIcon:a||!o,onClose:o||(()=>{})})),jsx("div",{className:twMerge("flex-1 min-h-0 overflow-y-auto",R?"px-6 py-6":"p-0"),children:l}),L&&jsx(j,{primaryAction:d,secondaryAction:f,tertiaryAction:c,footerContent:g})]})})})})}function ue(e){return jsx(Form,{validationBehavior:"aria",...e,className:twMerge("flex flex-col gap-6",e.className)})}function Dn({formId:e="dialog-form",onSubmit:o,primaryLabel:t="Save",secondaryLabel:r="Cancel",onCancel:n,primaryVariant:a,secondaryVariant:s="secondary",children:i,title:l,...d}){return jsx(He,{title:l,primaryAction:{label:t,onPress:()=>{let c=document.getElementById(e);c&&c.requestSubmit();},variant:a},secondaryAction:n?{label:r,onPress:n,variant:s}:void 0,...d,children:jsx(ue,{id:e,onSubmit:o,children:i})})}function ve({children:e,title:o,headerContent:t,titleAlign:r="left",hideCloseIcon:n=false,hasBackArrow:a=false,onBack:s,isOpen:i,slideInFrom:l="right",transparentOverlay:d=false,onClose:f,className:c,primaryAction:g,secondaryAction:v,footerContent:b,contentPadding:C=true,maxWidth:S="400px"}){if(!i)return null;let w=o||t,p=g||v||b;return jsx(E,{children:jsx(Y,{isOpen:i,onOpenChange:y=>!y&&f?.(),isDismissable:true,transparent:d,children:jsx(Modal,{className:"outline-none focus:outline-none focus-visible:outline-none ring-0 focus:ring-0 focus-visible:ring-0",children:jsxs(Dialog,{className:twMerge("fixed top-0 bottom-0 flex flex-col bg-background-surface shadow-xl overflow-hidden",l==="right"?"right-0":"left-0",l==="right"?"animate-in slide-in-from-right duration-300 ease-out":"animate-in slide-in-from-left duration-300 ease-out","data-[exiting]:animate-out",l==="right"?"data-[exiting]:slide-out-to-right":"data-[exiting]:slide-out-to-left","data-[exiting]:duration-200 data-[exiting]:ease-in","outline-none focus-visible:outline focus-visible:outline-2 focus-visible:outline-action-default focus-visible:outline-offset-0",c),style:{maxWidth:S,width:"100%"},children:[w&&(a&&s?jsx(N,{title:o,headerContent:t,titleAlign:r,hideCloseIcon:n,hasBackArrow:true,onBack:s,onClose:f}):jsx(N,{title:o,headerContent:t,titleAlign:r,hideCloseIcon:n,onClose:f})),jsx("div",{className:twMerge("flex-1 overflow-y-auto overscroll-contain",C?"px-6 py-6":"p-0"),children:e}),p&&jsx(j,{primaryAction:g,secondaryAction:v,footerContent:b})]})})})})}ve.displayName="Drawer";function On({formId:e="drawer-form",onSubmit:o,primaryLabel:t="Save",secondaryLabel:r="Cancel",onCancel:n,primaryVariant:a,secondaryVariant:s="secondary",children:i,...l}){return jsx(ve,{primaryAction:{label:t,onPress:()=>{let f=document.getElementById(e);f&&f.requestSubmit();},variant:a},secondaryAction:n?{label:r,onPress:n,variant:s}:void 0,...l,children:jsx(ue,{id:e,onSubmit:o,className:"mt-2",children:i})})}function Yn({align:e="end",className:o,...t}){return jsx("div",{...t,className:twMerge("flex gap-2",e==="start"?"justify-start":e==="between"?"justify-between":"justify-end",o)})}var lo={sm:"gap-2",md:"gap-4",lg:"gap-6"};function co(e){if(!e)return "";let o=e.base?`grid-cols-${e.base}`:"",t=e.md?`md:grid-cols-${e.md}`:"",r=e.lg?`lg:grid-cols-${e.lg}`:"";return [o,t,r].filter(Boolean).join(" ")}function Qn({cols:e={base:1},gap:o="lg",className:t,...r}){return jsx("div",{...r,className:twMerge("grid",co(e),lo[o],t)})}var po=fo__default.forwardRef(({children:e,className:o},t)=>jsx("div",{ref:t,className:twMerge("relative w-full",o),children:e}));po.displayName="InputWrapper";function nt({size:e="md",className:o,children:t,...r}){return jsx("div",{...r,className:twMerge("leading-[2.25] text-text-caption",Q[e].text,o),children:t})}function sa({title:e,description:o,showDivider:t,className:r,children:n,...a}){return jsxs("section",{...a,className:twMerge("flex flex-col",r),children:[(e||o)&&jsxs("div",{className:"flex flex-col gap-1 mb-6",children:[typeof e=="string"?jsx(X,{tag:"h3",size:"sm",children:e}):e,o?jsx(nt,{size:"lg",children:o}):null]}),jsx("div",{className:"flex flex-col gap-6",children:n}),t&&jsx("hr",{className:"mt-2 border-border-muted"})]})}function la(){return jsx("hr",{className:"border-border-muted"})}function pa({steps:e,currentStepId:o,onStepClick:t,className:r}){let n=e.findIndex(a=>a.id===o);return jsx("nav",{"aria-label":"Progress",className:twMerge("w-full",r),children:jsx("div",{className:"relative mb-12",children:jsx("ol",{className:"relative flex items-start justify-between",children:e.map((a,s)=>{let i=a.id===o,l=s<n,d=t&&(l||i);return jsxs("li",{className:"relative flex flex-col items-center",style:{flex:`1 1 ${100/e.length}%`},children:[jsx("button",{type:"button",disabled:!d,onClick:()=>d&&t?.(a.id),className:twMerge("relative z-10 flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-full border-2 transition-colors bg-background-body",l&&"border-action-default bg-action-default text-text-onPrimary hover:bg-action-default/90",i&&"border-action-default bg-background-body text-action-default",!l&&!i&&"border-border-default bg-background-body text-text-muted",d&&"cursor-pointer",!d&&"cursor-default"),"aria-current":i?"step":void 0,children:l?jsx(D,{name:"Check",size:20,weight:"bold"}):jsx("span",{className:"text-sm font-semibold",children:s+1})}),s<e.length-1&&jsx("div",{className:"absolute top-5 h-0.5 transition-colors",style:{left:"50%",width:"100%",marginLeft:"20px",backgroundColor:s<n?"var(--color-action-default)":"var(--color-border-default)"}}),jsxs("div",{className:"mt-3 flex flex-col items-center text-center w-32",children:[jsx("span",{className:twMerge("text-sm font-medium",i&&"text-text-default",l&&"text-text-body",!i&&!l&&"text-text-muted"),children:a.title}),a.description&&jsx("span",{className:"mt-1 text-xs text-text-caption",children:a.description})]})]},a.id)})})})})}function xa({formId:e,show:o,isSubmitting:t,onCancel:r,primaryLabel:n="Save changes",secondaryLabel:a="Cancel",className:s}){return o?jsx("div",{className:twMerge("fixed inset-x-0 bottom-0 z-40 border-t border-border-muted bg-background-surface/95 backdrop-blur supports-[backdrop-filter]:bg-background-surface/70",s),children:jsxs("div",{className:"mx-auto flex max-w-screen-lg items-center justify-between gap-3 p-3",children:[jsx("div",{className:"text-sm text-text-muted",children:"You have unsaved changes"}),jsxs("div",{className:"flex gap-2",children:[jsx(z,{variant:"secondary",onPress:r,children:a}),jsx(z,{type:"submit",form:e,isDisabled:!!t,children:t?"Saving...":n})]})]})}):null}function Pa({when:e,message:o="You have unsaved changes. Leave anyway?"}){return fo.useEffect(()=>{if(!e)return;let t=r=>(r.preventDefault(),r.returnValue=o,o);return window.addEventListener("beforeunload",t),()=>window.removeEventListener("beforeunload",t)},[e,o]),null}function Na({steps:e,initialStepId:o,canNavigate:t}){if(e.length===0)throw new Error("useWizard: steps array cannot be empty");let[r,n]=fo.useState(o||e[0].id),a=e.findIndex(c=>c.id===r),s=a>0,i=a<e.length-1,l=async c=>c===r?true:t&&!await t(r,c)?false:(n(c),true);return {steps:e,currentStepId:r,setCurrentStepId:l,next:async()=>!i||a===-1?false:l(e[a+1].id),prev:async()=>!s||a===-1?false:l(e[a-1].id),hasNext:i,hasPrev:s,stepIndex:a}}export{Dn as DialogForm,On as DrawerForm,Yn as FormActions,la as FormDivider,Qn as FormGrid,sa as FormSection,pa as FormStepper,xa as SaveBar,Pa as UnsavedChangesPrompt,Na as useWizard};//# sourceMappingURL=index.js.map
2
2
  //# sourceMappingURL=index.js.map