@moondreamsdev/dreamer-ui 1.7.7-test.3 → 1.7.7-test.5
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.
- package/dist/{Toast-SgqUNTIy.cjs → Toast-B4zUICg8.cjs} +2 -2
- package/dist/Toast-B4zUICg8.cjs.map +1 -0
- package/dist/{Toast-vensJgtx.js → Toast-C84BREWE.js} +20 -20
- package/dist/Toast-C84BREWE.js.map +1 -0
- package/dist/components.cjs.js +1 -1
- package/dist/components.cjs.js.map +1 -1
- package/dist/components.esm.js +710 -574
- package/dist/components.esm.js.map +1 -1
- package/dist/providers.cjs.js +1 -1
- package/dist/providers.esm.js +1 -1
- package/dist/src/components/accordion/AccordionItem.d.ts +1 -0
- package/dist/src/components/clickable/Clickable.d.ts +1 -0
- package/dist/src/components/index.d.ts +1 -0
- package/dist/src/components/panel/Panel.d.ts +36 -0
- package/dist/src/components/panel/hooks.d.ts +6 -0
- package/dist/src/components/panel/index.d.ts +3 -0
- package/dist/src/components/panel/variants.d.ts +12 -0
- package/dist/src/components/radiogroup/RadioGroupItem.d.ts +1 -0
- package/dist/src/components/separator/Separator.d.ts +2 -3
- package/dist/src/components/separator/variants.d.ts +0 -7
- package/dist/src/components/tooltip/hooks.d.ts +1 -0
- package/dist/src/hooks/useActionModal.d.ts +1 -0
- package/dist/src/hooks/useToast.d.ts +1 -0
- package/dist/src/symbols/index.d.ts +1 -0
- package/dist/theme.css +1 -0
- package/package.json +1 -1
- package/dist/Toast-SgqUNTIy.cjs.map +0 -1
- package/dist/Toast-vensJgtx.js.map +0 -1
package/dist/components.cjs.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),l=require("react"),w=require("./utils.cjs.js"),N=require("./QuestionMarkCircled-D5cHmQp1.cjs"),A=require("./Toast-SgqUNTIy.cjs"),M=require("./X-CgjeP2OI.cjs"),W=require("react-dom");function D({id:o,title:s,content:e,children:n,className:t="",disabled:r=!1,isOpen:a=!1,onToggle:d,triggerClassName:f="",bodyClassName:c=""}){const h=l.useId(),u=o||`accordion-item-${h}`,v=`${u}-header`,m=`${u}-panel`,b=()=>{!r&&d&&d()},p=x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),b())};return i.jsxs("div",{className:w.join("border-b border-gray-200",r&&"opacity-60 cursor-not-allowed",t),children:[i.jsxs("button",{id:v,type:"button",className:w.join("w-full text-left py-3 px-4 flex justify-between items-center focus:outline focus:outline-secondary",r?"cursor-not-allowed":"hover:bg-gray-50/10 cursor-pointer",f),"aria-expanded":a,"aria-controls":m,disabled:r,onClick:b,onKeyDown:p,children:[i.jsx("span",{children:s}),i.jsx("span",{className:w.join("transform transition-transform duration-300 ease-linear",a?"rotate-180":"rotate-0"),"aria-hidden":"true",children:i.jsx(N.ChevronDown,{size:18})})]}),i.jsx("div",{id:m,role:"region","aria-labelledby":v,className:w.join("transition-all duration-300 ease-linear px-4",a?"max-h-96 opacity-100 overflow-auto py-3":"max-h-0 opacity-0 overflow-hidden",c),children:a&&(n||e)})]})}function Z({id:o,items:s=[],children:e,className:n="",itemClassName:t="",allowMultiple:r=!1,defaultOpenItems:a=[],triggersClassName:d="",bodiesClassName:f=""}){const c=l.useId(),h=o||`accordion-group-${c}`,[u,v]=l.useState(new Set(a)),m=x=>{v(y=>{const g=new Set(y);return g.has(x)?g.delete(x):(r||g.clear(),g.add(x)),g})},b=x=>`${c}-item-${x}`,p=x=>u.has(x);return i.jsxs("div",{id:h,className:n,children:[s.length>0&&s.map((x,y)=>{const g=x.id||b(y);return i.jsx(D,{id:g,title:x.title,content:x.content,disabled:x.disabled,isOpen:p(g),onToggle:()=>m(g),className:t,triggerClassName:d,bodyClassName:f},g)}),s.length===0&&e&&l.Children.map(e,(x,y)=>{if(l.isValidElement(x)&&x.type===D){const g=x.props.id||b(y);return l.createElement(D,{...x.props,key:g,id:g,className:w.join(t,x.props.className),isOpen:p(g),onToggle:()=>m(g),triggerClassName:w.join(d,x.props.triggerClassName),bodyClassName:w.join(f,x.props.bodyClassName)})}return null})]})}function U(){const[o,s]=l.useState(0);return l.useEffect(()=>{const e=setInterval(()=>{s(n=>(n+1)%3)},500);return()=>clearInterval(e)},[]),i.jsx("div",{className:"absolute inset-0 inline-flex items-center justify-center gap-x-2 align-middle",children:[0,1,2].map(e=>i.jsx("div",{className:w.join("rounded-full transition-all duration-500 ease-in-out size-[0.35em] bg-current",o===e&&"transform -translate-y-1")},e))})}const J={base:"",primary:"bg-primary text-primary-foreground hover:bg-primary/85 disabled:bg-muted disabled:text-muted-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/85 disabled:bg-muted/80 disabled:text-muted-foreground/80",tertiary:"text-primary hover:text-primary-foreground disabled:text-muted",outline:"border border-primary text-primary hover:border-primary-foreground hover:text-primary-foreground disabled:border-muted disabled:text-muted",link:"underline-offset-4 hover:underline disabled:underline disabled:text-muted",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/85 disabled:bg-muted disabled:text-muted-foreground"},Y={stripped:"",fitted:"size-fit",sm:"px-2 py-1 text-sm",md:"px-4 py-2 text-base",lg:"px-6 py-3 text-lg",icon:"p-1 w-fit aspect-square",full:"p-2 w-full"},O={none:"rounded-none",sm:"rounded-sm",md:"rounded-md",lg:"rounded-lg",full:"rounded-full"},q={variant:"primary",size:"md",rounded:"md"};function _({variant:o=q.variant,size:s,rounded:e=q.rounded,loading:n,linkTo:t,linkProps:r,type:a="button",className:d,...f}){let c;o==="link"&&!s?c="fitted":c=s||q.size;const u=w.join("appearance-none focus:outline-none focus:ring not-disabled:hover:cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed transition-all",J[o],Y[c],O[e],n&&"relative pointer-events-none",t&&"relative",d);return i.jsxs("button",{...f,role:t?"link":f.role,"aria-label":f["aria-label"]||(r==null?void 0:r["aria-label"]),"aria-description":f["aria-description"]||(r==null?void 0:r["aria-description"]),"aria-disabled":f.disabled||n,"aria-busy":n,type:a,className:u,children:[n&&i.jsx(U,{}),i.jsx("span",{className:w.join(n&&"invisible"),children:f.children}),t&&!f.disabled&&i.jsx("a",{...r,"aria-hidden":!0,href:t,rel:(r==null?void 0:r.rel)||"noreferrer",className:"absolute inset-0"})]})}function P(o){const[s,e]=l.useState(""),n=l.useCallback(t=>{let r=t,a="";for(;r&&!a;){const d=window.getComputedStyle(r).backgroundColor;d&&d!=="transparent"&&d!=="rgba(0, 0, 0, 0)"&&(a=d),r=r.parentElement}return a||"transparent"},[]);return l.useEffect(()=>{const t=document.getElementById(o);if(t){const r=n(t.parentElement);e(r)}},[o,n]),s}function ee({ref:o,id:s,size:e=20,color:n,filled:t=!1,rounded:r=!0,checked:a=!1,onCheckedChange:d,disabled:f,className:c="",...h}){const u=l.useId(),v=l.useMemo(()=>s||`checkbox-${u}`,[s,u]),m=P(v),[b,p]=l.useState(a);l.useEffect(()=>{p(a)},[a]);const x=()=>{f||(p(!b),d==null||d(!b))},y=j=>{j.key===" "&&(j.preventDefault(),x())},g=w.join("flex items-center justify-center border outline outline-transparent focus:outline-current focus:outline-offset-2",r&&"rounded",f&&"opacity-40 cursor-not-allowed",!f&&"cursor-pointer",c);return i.jsx("button",{id:v,type:"button",ref:o,tabIndex:0,role:"checkbox",onClick:x,"aria-checked":b,"aria-disabled":f,onKeyDownCapture:y,style:{width:e,height:e,color:n,backgroundColor:b&&t?"currentcolor":"transparent"},className:g,...h,children:b&&i.jsx(N.Check,{size:e,color:t?m:void 0})})}function te({children:o,className:s,linkTo:e,linkProps:n,onButtonClick:t,buttonProps:r,...a}){return e&&t&&console.warn('Clickable: Both "linkTo" and "onButtonClick" props are provided. Only "linkTo" will be used.'),i.jsxs("div",{className:w.join("relative w-fit",s),...a,children:[o,e&&i.jsx("a",{...n,rel:(n==null?void 0:n.rel)||"noreferrer",href:e,className:w.join("absolute inset-0",n==null?void 0:n.className)}),!e&&t&&i.jsx("button",{...r,type:"button",onClick:t,className:w.join("absolute inset-0 cursor-pointer",r==null?void 0:r.className)})]})}function R({elementId:o,type:s,message:e}){return l.useEffect(()=>{const n=document.getElementById(o);if(n){if(!e&&s==="error"){n.removeAttribute("data-error");return}if(!e&&s==="success"){n.removeAttribute("data-success");return}return n.setAttribute("aria-describedby",`${o}-${s}-message`),n.setAttribute("aria-invalid",s==="error"?"true":"false"),s==="error"&&n.setAttribute("data-error","true"),s==="success"&&n.setAttribute("data-success","true"),()=>{n.removeAttribute("aria-describedby"),n.removeAttribute("aria-invalid"),n.removeAttribute("data-error"),n.removeAttribute("data-success")}}},[o,s,e]),e?i.jsxs("small",{className:w.join("mt-0.5 text-sm inline-flex items-center gap-1 w-full justify-start",s==="error"&&"text-destructive",s==="success"&&"text-success"),role:"status",children:[s==="error"?i.jsx(M.ExclamationTriangle,{}):i.jsx(N.CheckCircled,{}),i.jsx("span",{id:`${o}-${s}-message`,children:e})]}):null}const re={base:"",default:"ring ring-transparent focus:ring-primary-foreground not-disabled:data-error:ring-destructive not-disabled:data-success:ring-success",underline:"border-b border-border focus:border-primary-foreground disabled:border-muted/30 not-disabled:data-error:border-destructive not-disabled:data-success:border-success",outline:"border border-border focus:border-primary-foreground disabled:border-muted/30 not-disabled:data-error:border-destructive not-disabled:data-success:border-success"},ne={none:"rounded-none",sm:"rounded-sm",md:"rounded-md",lg:"rounded-lg",full:"px-3 rounded-full"},H={variant:"default",rounded:"none"};function oe({variant:o=H.variant,rounded:s,displayOnlyMode:e=!1,errorMessage:n,successMessage:t,type:r="text",className:a,...d}){const f=l.useId(),[c,h]=l.useState(!1);let u=s;o==="outline"&&!s&&(u="md"),u=u||H.rounded;const b=w.join("appearance-none w-full focus:outline-none disabled:opacity-50 disabled:cursor-not-allowed placeholder:text-muted/70 hide-number-input-arrows transition-all","file:mr-2 file:border-0 file:rounded-md file:px-1.5 file:py-1 file:bg-primary hover:file:bg-primary/85 file:text-sm file:font-medium file:text-foreground file:transition-colors",!e&&re[o],!e&&ne[u],r==="password"&&"pr-10",!e&&"px-2 py-1",e&&"pointer-events-none",a);return i.jsxs("div",{className:w.join(e&&"cursor-text"),style:{height:d.height,width:d.width},children:[i.jsxs("div",{className:w.join(r==="password"&&"relative"),children:[i.jsx("input",{...d,id:f,type:r==="password"&&c?"text":r,"aria-disabled":d.disabled,readOnly:e,"aria-readonly":e||d["aria-readonly"],"data-error":n?!0:void 0,"data-success":t?!0:void 0,className:b}),r==="password"&&i.jsx("button",{onClick:()=>h(!c),className:"absolute inset-y-0 right-0 px-2 hover:cursor-pointer","aria-label":"Toggle password visibility","data-state":c?"visible":"hidden",children:c?i.jsx(N.EyeClosed$1,{size:20}):i.jsx(N.EyeClosed,{size:20})})]}),!e&&i.jsx(R,{elementId:f,type:"error",message:n}),!e&&i.jsx(R,{elementId:f,type:"success",message:t})]})}function se({display:o="inline",width:s="fit-content",className:e="",required:n,helpMessage:t,suffix:r,htmlFor:a,children:d,...f}){const c=l.useId(),h=w.join("font-medium",o,e),u=t?`${a??c}-help`:void 0;return i.jsxs("div",{style:{display:o==="inline"?"inline-flex":"flex",width:s},className:"relative",children:[i.jsxs("label",{className:h,htmlFor:a,...f,children:[d,n&&i.jsx("span",{className:"text-red-500 font-medium ml-1","aria-label":"required",children:"*"})]}),t&&i.jsx("span",{className:"text-gray-500 ml-1 size-fit -translate-y-1/3","aria-describedby":u,"aria-label":"Help information",title:t,children:i.jsx(N.QuestionMarkCircled,{})}),t&&i.jsx("div",{id:u,className:"sr-only",children:t}),r&&i.jsx("span",{className:"ml-1",children:r})]})}function ae(o){const[s,e]=l.useState(!1),[n,t]=l.useState(!1);return l.useEffect(()=>{o?(t(!0),setTimeout(()=>e(!0),10)):(e(!1),setTimeout(()=>t(!1),150))},[o]),{show:s,shouldRender:n}}function ie(o,s){l.useEffect(()=>{const e=n=>{n.key==="Escape"&&o&&s()};return document.addEventListener("keydown",e),o&&(document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",e),document.body.style.overflow="auto"}},[o,s])}function le(o,s){const e=l.useRef(null),n=l.useCallback(()=>{const t=document.getElementById(o);if(!t)return;const r=t.querySelectorAll('[data-modal-action="true"]');if(r.length>0){r[0].focus();return}const a=t.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');if(a.length>0){const d=Array.from(a).filter(f=>!(f instanceof HTMLButtonElement&&f.getAttribute("data-modal-close-button")==="true"));if(d.length>0){d[0].focus();return}a[0].focus();return}t.focus()},[o]);l.useEffect(()=>(s&&(e.current=document.activeElement,n()),()=>{document.body.style.overflow="auto",e.current instanceof HTMLElement&&e.current.focus()}),[s,n])}function ue({id:o,isOpen:s,onClose:e,title:n,children:t,contentOnly:r=!1,className:a,overlayClassName:d,hideCloseButton:f=!1,actions:c=[],disableCloseOnOverlayClick:h=!1,ariaLabelledBy:u,ariaDescribedBy:v}){const m=l.useId(),b=o||`modal-${m}`,p=o?`${o}-title`:`modal-title-${m}`,{show:x,shouldRender:y}=ae(s);if(le(b,y),ie(y,e),!y)return null;const g=()=>n?l.isValidElement(n)?i.jsx("div",{className:"mb-4",children:n}):i.jsx("h2",{className:"mb-4 text-xl font-semibold",id:p,children:n}):null,j=()=>c.length===0?null:i.jsx("div",{className:"mt-6 not-sm:grid gap-y-2 sm:flex sm:justify-start sm:flex-row-reverse sm:gap-x-3",children:c.map((I,E)=>{const{label:L,className:k,...T}=I;return i.jsx(_,{className:k,type:"button",...T,"data-modal-action":"true",children:L},E)})});return i.jsx(i.Fragment,{children:W.createPortal(i.jsx("div",{"aria-labelledby":u??n?p:void 0,"aria-describedby":v,role:"dialog","aria-modal":"true",className:"fixed inset-0 z-[100] overflow-y-auto",children:i.jsxs("div",{className:"flex min-h-screen items-center justify-center p-4",children:[i.jsx("div",{className:A.n("fixed inset-0 bg-black/20 transition-all",d),onClick:()=>{h||e()}}),r&&i.jsx("div",{className:A.n("relative w-fit",a),children:t}),!r&&i.jsxs("div",{id:b,tabIndex:-1,className:A.n("relative w-full max-w-xl transform rounded-lg shadow-xl transition-all p-6 bg-inherit focus:ring ease-in duration-75",x?"opacity-100 scale-100":"opacity-0 scale-90",a),children:[!f&&i.jsx("button",{type:"button",onClick:e,"data-modal-close-button":"true",className:"rounded-md p-0.5 top-2.5 right-2.5 absolute opacity-80 hover:opacity-100 transition-opacity focus:outline-none focus:ring-2 focus:ring-gray-500 leading-0",children:i.jsx(M.X,{size:18})}),g(),t,j()]})]})}),document.body)})}function Q({itemId:o,checked:s,onChange:e,name:n,disabled:t=!1,className:r=""}){const a="relative inline-flex items-center justify-center rounded-full",d=()=>{t||e()},f=w.join(a,!s&&"hover:border-current/60",!t&&"border-current cursor-pointer",t&&"border-muted/60 cursor-not-allowed",r);return i.jsx("div",{id:o,role:"radio",tabIndex:-1,"aria-checked":s,"aria-disabled":t,"aria-description":`Radio button for ${n}`,"aria-labelledby":`${o}-label`,onClick:d,className:f,style:{width:"1em",height:"1em",padding:"0.1em",borderWidth:"0.06em"},children:s&&i.jsx("div",{className:w.join("size-full aspect-square rounded-full",t&&"bg-muted/60",!t&&"bg-current")})})}function z({value:o,children:s,className:e="",isSelected:n=!1,onChange:t,disabled:r=!1,hideInput:a=!1,description:d,name:f}){const h=`radio-${l.useId()}-${o}`,u=()=>{r||t==null||t(o)};return i.jsxs("div",{title:d,className:w.join("relative flex items-center",e,a&&`p-2 border-2 focus-within:border-dashed focus-within:${r?"border-current/50":"border-current/80"}`,a&&!n&&`border-transparent ${r?"":"not-focus-within:hover:border-border/60"}`,a&&n&&"border-border",r&&"opacity-60 cursor-not-allowed"),style:{gap:"0.5em"},children:[!a&&i.jsx(Q,{itemId:h,name:f||"",checked:n,onChange:u,disabled:r,className:w.join(a&&"")}),i.jsx("div",{id:a?h:void 0,tabIndex:a?-1:void 0,role:a?"radio":void 0,onClick:a?u:void 0,"aria-checked":a?n?"true":"false":void 0,"aria-disabled":a?r:void 0,"aria-description":a?d||`Radio button for ${f}`:void 0,"aria-labelledby":a?`${h}-label`:void 0,className:w.join(a&&"size-full",typeof s=="object"&&"grow focus:outline-none"),children:i.jsx("label",{id:`${h}-label`,onClick:a?void 0:u,className:w.join(r&&"cursor-not-allowed",!r&&"cursor-pointer"),children:s})})]})}function ce(o,s){const[e,n]=l.useState(s),[t,r]=l.useState(-1),[a,d]=l.useState(!1),f=l.useCallback((m,b)=>{var y;const p=m[b];p.hasAttribute("disabled")||p.getAttribute("aria-disabled")==="true"||((y=m[b])==null||y.click(),r(b))},[]),c=l.useCallback((m,b)=>{var x;if(m.preventDefault(),a||!b.length)return;const p=s!==-1?s:0;(x=b[p])==null||x.focus(),n(p),s!==-1&&f(b,p)},[s,a,f]),h=l.useCallback(m=>{var y;if(!m.shiftKey)return;m.preventDefault();const b=Array.from(document.querySelectorAll('a, button, input, textarea, select, details, [tabindex]:not([tabindex="-1"])')).filter(g=>!g.hasAttribute("disabled")&&g.tabIndex>=0),p=b.findIndex(g=>g.id===o),x=p>0?p-1:b.length-1;(y=b[x])==null||y.focus()},[o]),u=l.useCallback((m,b)=>{var j;if(!b.length)return;const p=m.target;if(!b.some(I=>I.id===p.id))return;const y=e!==-1?e:0;let g=y;switch(m.key){case"ArrowUp":case"ArrowLeft":m.preventDefault(),g=y>0?y-1:b.length-1;break;case"ArrowDown":case"ArrowRight":m.preventDefault(),g=(y+1)%b.length;break;case" ":m.preventDefault(),f(b,y);return;case"Tab":h(m);return;default:return}(j=b[g])==null||j.focus(),n(g),t!==-1&&f(b,g)},[e,t,h,f]),v=l.useCallback(()=>{const m=document.querySelector(`[id="${o}"][role="radiogroup"]`);return m?Array.from(m.querySelectorAll('[role="radio"]')):[]},[o]);l.useEffect(()=>{const m=document.querySelector(`[id="${o}"][role="radiogroup"]`);if(!m)return;const b=v(),p=j=>c(j,b),x=j=>u(j,b),y=()=>d(!0),g=()=>d(!1);return document.addEventListener("keydown",x),m.addEventListener("focus",p),m.addEventListener("mousedown",y),document.addEventListener("mouseup",g),()=>{document.removeEventListener("keydown",x),m.removeEventListener("focus",p),m.removeEventListener("mousedown",y),document.removeEventListener("mouseup",g)}},[o,v,c,u])}function de({options:o=[],value:s,onChange:e,id:n,children:t,className:r="",childrenClassName:a="",hideInputs:d=!1}){const f=l.useId(),c=n||`radio-group-${f}`;ce(c,o.findIndex(u=>u===s));const h=l.useMemo(()=>o.reduce((u,v)=>(typeof v=="string"?u.some(m=>m.value===v)||u.push({label:v,value:v}):u.push(v),u),[]),[o]);return i.jsxs("div",{id:c,role:"radiogroup",tabIndex:0,className:w.join(r,"focus:outline-none"),children:[h.length>0&&h.map((u,v)=>i.jsx(z,{value:u.value,isSelected:s===u.value,onChange:e,name:c,disabled:u.disabled,description:u.description,hideInput:d,className:a,children:u.label},`${u.value}-${v}`)),h.length===0&&t&&l.Children.map(t,u=>l.isValidElement(u)&&u.type===z?i.jsx(z,{...u.props,className:w.join(a,u.props.className),hideInput:u.props.hideInput||d,isSelected:s===u.props.value,onChange:e,name:c,children:u.props.children}):null)]})}const fe={thin:{horizontal:"h-px",vertical:"w-px"},medium:{horizontal:"h-0.5",vertical:"w-0.5"},thick:{horizontal:"h-1",vertical:"w-1"},"extra-thick":{horizontal:"h-2",vertical:"w-2"}},me={default:"bg-border",muted:"bg-muted",accent:"bg-accent"},be={horizontal:"w-full",vertical:"min-h-4 h-full"};function he({orientation:o="horizontal",decorative:s=!1,thickness:e="thin",variant:n="default",className:t,...r}){const a=w.join("shrink-0",be[o],fe[e][o],me[n],t);return i.jsx("div",{...r,className:a,role:s?"presentation":"separator","aria-orientation":s?void 0:o,"aria-hidden":s,"data-orientation":o,"data-thickness":e,"data-variant":n})}function xe({children:o,ref:s,...e}){if(l.isValidElement(o)){let n={...e};return o.props&&(n={...n,...o.props}),l.cloneElement(o,{...n,ref:t=>{typeof s=="function"?s(t):s&&(s.current=t)}})}return l.createElement("div",{...e,ref:s},o)}function ge({elementId:o,maxLength:s}){const[e,n]=l.useState(0);return l.useEffect(()=>{const t=document.getElementById(o);if(!t)return;const r=()=>{const a=t.value.length;n(a);const d=a>=s;t.setAttribute("aria-describedby",`${o}-character-count`),t.setAttribute("aria-invalid",d?"true":"false"),d?t.setAttribute("data-error","true"):t.removeAttribute("data-error")};return r(),t.addEventListener("input",r),t.setAttribute("maxlength",String(s)),()=>{t.removeEventListener("input",r),t.removeAttribute("maxlength"),t.removeAttribute("aria-describedby"),t.removeAttribute("aria-invalid"),t.removeAttribute("data-error")}},[o,s]),i.jsx("small",{className:w.join("mt-0.5 text-sm inline-flex items-center gap-1 w-full justify-end",e>=s&&"text-destructive",e<s&&"text-current"),role:"status",children:i.jsxs("span",{id:`${o}-character-count`,children:[e," / ",s," characters"]})})}function pe(o,s){l.useEffect(()=>{const e=document.getElementById(o);if(!e)return;if(!s){e.style.height="auto";return}const n=()=>{e.style.height="auto",e.style.height=`${e.scrollHeight}px`};return n(),e.addEventListener("input",n),e.addEventListener("resize",n),window.addEventListener("resize",n),()=>{e.removeEventListener("input",n),e.removeEventListener("resize",n),window.removeEventListener("resize",n)}},[o,s])}const ve={base:"","left-line":"border-l border-border focus:border-primary-foreground disabled:border-muted/30 not-disabled:data-error:border-destructive not-disabled:data-success:border-success",outline:"border border-border focus:border-primary-foreground disabled:border-muted/30 not-disabled:data-error:border-destructive not-disabled:data-success:border-success"},we={none:"rounded-none",sm:"rounded-sm",md:"rounded-md",lg:"rounded-lg",full:"px-3 rounded-full"},K={variant:"outline",rounded:"none"};function ye({variant:o=K.variant,rounded:s,displayOnlyMode:e=!1,errorMessage:n,successMessage:t,hideResizeHandle:r=!1,autoExpand:a=!1,characterLimit:d=0,className:f,...c}){const h=l.useId();pe(h,a||e);let u=s;o==="outline"&&!s&&(u="md"),u=u||K.rounded;let v=r;(e||o==="left-line"&&!r)&&(v=!0);const b=w.join("appearance-none w-full focus:outline-none disabled:opacity-50 disabled:cursor-not-allowed placeholder:text-muted/70 hide-number-input-arrows transition-all",!e&&ve[o],!e&&we[u],!e&&"px-2 py-1",e&&"pointer-events-none",v&&"no-resize-handle",f);return i.jsxs("div",{className:w.join("-space-y-1.5",e&&"cursor-text"),children:[i.jsx("textarea",{...c,id:h,"aria-disabled":c.disabled,readOnly:e,"aria-readonly":e||c["aria-readonly"],style:{resize:a?"none":void 0},className:b}),d>0&&i.jsx(ge,{elementId:h,maxLength:d}),!e&&i.jsx(R,{elementId:h,type:"error",message:n}),!e&&i.jsx(R,{elementId:h,type:"success",message:t})]})}const je={sm:{container:"h-5 min-w-9 w-9",thumb:"h-4 w-4",translate:"translate-x-4"},md:{container:"h-6 min-w-11 w-11",thumb:"h-5 w-5",translate:"translate-x-5"},lg:{container:"h-7 min-w-13 w-13",thumb:"h-6 w-6",translate:"translate-x-6"}},Ee={default:{unchecked:"bg-muted",checked:"bg-primary"},success:{unchecked:"bg-muted",checked:"bg-success"},destructive:{unchecked:"bg-muted",checked:"bg-destructive"}},G={variant:"default",size:"md"};function Ce({ref:o,id:s,size:e=G.size,variant:n=G.variant,checked:t,onCheckedChange:r,disabled:a=!1,className:d,thumbClassName:f,backgroundClassNames:c,...h}){const u=l.useId(),v=l.useMemo(()=>s||`toggle-${u}`,[s,u]),[m,b]=l.useState(t);l.useEffect(()=>{b(t)},[t]);const p=()=>{if(!a){const E=!m;t===void 0&&b(E),r==null||r(E)}},x=E=>{(E.key===" "||E.key==="Enter")&&(E.preventDefault(),p())},y=je[e],g=Ee[n],j=w.join("relative inline-flex items-center rounded-full transition-all duration-200 ease-in-out","focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2",y.container,m?(c==null?void 0:c.checked)||g.checked:(c==null?void 0:c.unchecked)||g.unchecked,a&&"opacity-50 cursor-not-allowed",!a&&"cursor-pointer",d),I=w.join("absolute left-0.5 top-1/2 -translate-y-1/2 rounded-full bg-white shadow-sm transition-transform duration-200 ease-in-out",y.thumb,m&&y.translate,f);return i.jsxs("button",{ref:o,id:v,type:"button",role:"switch",tabIndex:0,"aria-checked":m,"aria-disabled":a,disabled:a,onClick:p,onKeyDown:x,className:j,...h,children:[i.jsx("span",{className:I}),i.jsx("span",{className:"sr-only",children:m?"Enabled":"Disabled"})]})}const S=8,$=4,C=6;function Ie(o){return{calculatePosition:l.useCallback((e,n)=>{const t=e.getBoundingClientRect(),r=n.getBoundingClientRect(),a={width:window.innerWidth,height:window.innerHeight},d=(v,m,b,p)=>v<0||m<0||v+b>a.width||m+p>a.height,f={top:{x:t.left+t.width/2-r.width/2,y:t.top-r.height-$,arrow:{x:r.width/2-C,y:r.height}},bottom:{x:t.left+t.width/2-r.width/2,y:t.bottom+$,arrow:{x:r.width/2-C,y:-6}},left:{x:t.left-r.width-$,y:t.top+t.height/2-r.height/2,arrow:{x:r.width,y:r.height/2-C}},right:{x:t.right+$,y:t.top+t.height/2-r.height/2,arrow:{x:-6,y:r.height/2-C}}};let c=o,h=f[o];if(d(h.x,h.y,r.width,r.height)){const v={top:"bottom",bottom:"top",left:"right",right:"left"},m=f[v[o]];if(!d(m.x,m.y,r.width,r.height))c=v[o],h=m;else{const b=["top","bottom","left","right"].filter(p=>p!==o&&p!==v[o]);for(const p of b){const x=f[p];if(!d(x.x,x.y,r.width,r.height)){c=p,h=x;break}}}}h.x=Math.max(S,Math.min(h.x,a.width-r.width-S)),h.y=Math.max(S,Math.min(h.y,a.height-r.height-S));const u={x:t.left+t.width/2,y:t.top+t.height/2};return c==="top"||c==="bottom"?h.arrow.x=Math.max(C,Math.min(u.x-h.x-C,r.width-C*2)):h.arrow.y=Math.max(C,Math.min(u.y-h.y-C,r.height-C*2)),{...h,placement:c}},[o])}}function Ne(o,s,e){const n=l.useRef(null),t=l.useRef(null),r=l.useCallback(()=>{if(!n.current||!t.current)return;const a=o(n.current,t.current);e(a)},[o,e]);return l.useEffect(()=>{if(!s)return;const a=()=>r();return window.addEventListener("resize",a),()=>{window.removeEventListener("resize",a)}},[s,r]),{triggerRef:n,tooltipRef:t,updatePosition:r}}function Ae(o,s,e,n,t,r,a,d,f){const c=l.useRef(null),h=l.useCallback(()=>{o||(c.current&&clearTimeout(c.current),c.current=window.setTimeout(()=>{e(!0),requestAnimationFrame(()=>{t(),n(!0)})},s))},[o,s,e,t,n]),u=l.useCallback((v=!1)=>{if(c.current&&clearTimeout(c.current),v){n(!1),setTimeout(()=>e(!1),150);return}c.current=window.setTimeout(()=>{n(!1),setTimeout(()=>e(!1),150)},100)},[n,e]);return l.useEffect(()=>{!r&&!a&&!d&&f&&u()},[r,a,d,f,u]),l.useEffect(()=>()=>{c.current&&clearTimeout(c.current)},[]),{showTooltip:h,hideTooltip:u,timeoutRef:c}}function ke({id:o,children:s,message:e,placement:n="top",disabled:t=!1,delay:r=200,className:a}){const[d,f]=l.useState(!1),[c,h]=l.useState(!1),[u,v]=l.useState(null),[m,b]=l.useState(!1),[p,x]=l.useState(!1),[y,g]=l.useState(!1),{calculatePosition:j}=Ie(n),{triggerRef:I,tooltipRef:E,updatePosition:L}=Ne(j,c,v),{showTooltip:k,hideTooltip:T,timeoutRef:F}=Ae(t,r,h,f,L,m,p,y,d),X=l.useId(),V=o??X;return i.jsxs(i.Fragment,{children:[l.cloneElement(s,{ref:B=>{I.current=B},onMouseEnter:()=>{b(!0),k()},onMouseLeave:()=>{b(!1)},onFocus:()=>{g(!0),k()},onBlur:()=>{g(!1),T(!0)},onKeyDown:B=>{B.key==="Escape"&&T(!0)},"aria-describedby":t?void 0:V}),c&&W.createPortal(i.jsx("div",{ref:E,id:V,role:"tooltip",className:w.join("fixed z-50 px-2 py-1 text-sm rounded shadow-lg pointer-events-auto transition-all duration-150 ease-out",d?"opacity-100":"opacity-0",a),style:u?{left:u.x,top:u.y}:{opacity:0},onMouseEnter:()=>{x(!0),F.current&&clearTimeout(F.current)},onMouseLeave:()=>{x(!1)},children:e}),document.body)]})}exports.ActionModal=A.ActionModal;exports.Toast=A.Toast;exports.Accordion=Z;exports.AccordionItem=D;exports.Button=_;exports.ButtonLoadingDots=U;exports.Checkbox=ee;exports.Clickable=te;exports.Input=oe;exports.Label=se;exports.Modal=ue;exports.RadioGroup=de;exports.RadioGroupItem=z;exports.RadioInput=Q;exports.Separator=he;exports.Slot=xe;exports.Textarea=ye;exports.Toggle=Ce;exports.Tooltip=ke;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),l=require("react"),y=require("./utils.cjs.js"),A=require("./QuestionMarkCircled-D5cHmQp1.cjs"),I=require("./Toast-B4zUICg8.cjs"),F=require("./X-CgjeP2OI.cjs"),V=require("react-dom");function D({id:o,title:s,content:t,children:r,className:e="",disabled:n=!1,isOpen:a=!1,onToggle:c,triggerClassName:f="",bodyClassName:d=""}){const h=l.useId(),u=o||`accordion-item-${h}`,v=`${u}-header`,m=`${u}-panel`,b=()=>{!n&&c&&c()},g=x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),b())};return i.jsxs("div",{className:y.join("border-b border-gray-200",n&&"opacity-60 cursor-not-allowed",e),children:[i.jsxs("button",{id:v,type:"button",className:y.join("w-full text-left py-3 px-4 flex justify-between items-center focus:outline focus:outline-secondary",n?"cursor-not-allowed":"hover:bg-gray-50/10 cursor-pointer",f),"aria-expanded":a,"aria-controls":m,disabled:n,onClick:b,onKeyDown:g,children:[i.jsx("span",{children:s}),i.jsx("span",{className:y.join("transform transition-transform duration-300 ease-linear",a?"rotate-180":"rotate-0"),"aria-hidden":"true",children:i.jsx(A.ChevronDown,{size:18})})]}),i.jsx("div",{id:m,role:"region","aria-labelledby":v,className:y.join("transition-all duration-300 ease-linear px-4",a?"max-h-96 opacity-100 overflow-auto py-3":"max-h-0 opacity-0 overflow-hidden",d),children:a&&(r||t)})]})}function Z({id:o,items:s=[],children:t,className:r="",itemClassName:e="",allowMultiple:n=!1,defaultOpenItems:a=[],triggersClassName:c="",bodiesClassName:f=""}){const d=l.useId(),h=o||`accordion-group-${d}`,[u,v]=l.useState(new Set(a)),m=x=>{v(w=>{const p=new Set(w);return p.has(x)?p.delete(x):(n||p.clear(),p.add(x)),p})},b=x=>`${d}-item-${x}`,g=x=>u.has(x);return i.jsxs("div",{id:h,className:r,children:[s.length>0&&s.map((x,w)=>{const p=x.id||b(w);return i.jsx(D,{id:p,title:x.title,content:x.content,disabled:x.disabled,isOpen:g(p),onToggle:()=>m(p),className:e,triggerClassName:c,bodyClassName:f},p)}),s.length===0&&t&&l.Children.map(t,(x,w)=>{if(l.isValidElement(x)&&x.type===D){const p=x.props.id||b(w);return l.createElement(D,{...x.props,key:p,id:p,className:y.join(e,x.props.className),isOpen:g(p),onToggle:()=>m(p),triggerClassName:y.join(c,x.props.triggerClassName),bodyClassName:y.join(f,x.props.bodyClassName)})}return null})]})}function U(){const[o,s]=l.useState(0);return l.useEffect(()=>{const t=setInterval(()=>{s(r=>(r+1)%3)},500);return()=>clearInterval(t)},[]),i.jsx("div",{className:"absolute inset-0 inline-flex items-center justify-center gap-x-2 align-middle",children:[0,1,2].map(t=>i.jsx("div",{className:y.join("rounded-full transition-all duration-500 ease-in-out size-[0.35em] bg-current",o===t&&"transform -translate-y-1")},t))})}const J={base:"",primary:"bg-primary text-primary-foreground hover:bg-primary/85 disabled:bg-muted disabled:text-muted-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/85 disabled:bg-muted/80 disabled:text-muted-foreground/80",tertiary:"text-primary hover:text-primary-foreground disabled:text-muted",outline:"border border-primary text-primary hover:border-primary-foreground hover:text-primary-foreground disabled:border-muted disabled:text-muted",link:"underline-offset-4 hover:underline disabled:underline disabled:text-muted",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/85 disabled:bg-muted disabled:text-muted-foreground"},Y={stripped:"",fitted:"size-fit",sm:"px-2 py-1 text-sm",md:"px-4 py-2 text-base",lg:"px-6 py-3 text-lg",icon:"p-1 w-fit aspect-square",full:"p-2 w-full"},P={none:"rounded-none",sm:"rounded-sm",md:"rounded-md",lg:"rounded-lg",full:"rounded-full"},q={variant:"primary",size:"md",rounded:"md"};function X({variant:o=q.variant,size:s,rounded:t=q.rounded,loading:r,linkTo:e,linkProps:n,type:a="button",className:c,...f}){let d;o==="link"&&!s?d="fitted":d=s||q.size;const u=y.join("appearance-none focus:outline-none focus:ring not-disabled:hover:cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed transition-all",J[o],Y[d],P[t],r&&"relative pointer-events-none",e&&"relative",c);return i.jsxs("button",{...f,role:e?"link":f.role,"aria-label":f["aria-label"]||(n==null?void 0:n["aria-label"]),"aria-description":f["aria-description"]||(n==null?void 0:n["aria-description"]),"aria-disabled":f.disabled||r,"aria-busy":r,type:a,className:u,children:[r&&i.jsx(U,{}),i.jsx("span",{className:y.join(r&&"invisible"),children:f.children}),e&&!f.disabled&&i.jsx("a",{...n,"aria-hidden":!0,href:e,rel:(n==null?void 0:n.rel)||"noreferrer",className:"absolute inset-0"})]})}function O(o){const[s,t]=l.useState(""),r=l.useCallback(e=>{let n=e,a="";for(;n&&!a;){const c=window.getComputedStyle(n).backgroundColor;c&&c!=="transparent"&&c!=="rgba(0, 0, 0, 0)"&&(a=c),n=n.parentElement}return a||"transparent"},[]);return l.useEffect(()=>{const e=document.getElementById(o);if(e){const n=r(e.parentElement);t(n)}},[o,r]),s}function ee({ref:o,id:s,size:t=20,color:r,filled:e=!1,rounded:n=!0,checked:a=!1,onCheckedChange:c,disabled:f,className:d="",...h}){const u=l.useId(),v=l.useMemo(()=>s||`checkbox-${u}`,[s,u]),m=O(v),[b,g]=l.useState(a);l.useEffect(()=>{g(a)},[a]);const x=()=>{f||(g(!b),c==null||c(!b))},w=j=>{j.key===" "&&(j.preventDefault(),x())},p=y.join("flex items-center justify-center border outline outline-transparent focus:outline-current focus:outline-offset-2",n&&"rounded",f&&"opacity-40 cursor-not-allowed",!f&&"cursor-pointer",d);return i.jsx("button",{id:v,type:"button",ref:o,tabIndex:0,role:"checkbox",onClick:x,"aria-checked":b,"aria-disabled":f,onKeyDownCapture:w,style:{width:t,height:t,color:r,backgroundColor:b&&e?"currentcolor":"transparent"},className:p,...h,children:b&&i.jsx(A.Check,{size:t,color:e?m:void 0})})}function te({children:o,className:s,linkTo:t,linkProps:r,onButtonClick:e,buttonProps:n,...a}){return t&&e&&console.warn('Clickable: Both "linkTo" and "onButtonClick" props are provided. Only "linkTo" will be used.'),i.jsxs("div",{className:y.join("relative w-fit",s),...a,children:[o,t&&i.jsx("a",{...r,rel:(r==null?void 0:r.rel)||"noreferrer",href:t,className:y.join("absolute inset-0",r==null?void 0:r.className)}),!t&&e&&i.jsx("button",{...n,type:"button",onClick:e,className:y.join("absolute inset-0 cursor-pointer",n==null?void 0:n.className)})]})}function L({elementId:o,type:s,message:t}){return l.useEffect(()=>{const r=document.getElementById(o);if(r){if(!t&&s==="error"){r.removeAttribute("data-error");return}if(!t&&s==="success"){r.removeAttribute("data-success");return}return r.setAttribute("aria-describedby",`${o}-${s}-message`),r.setAttribute("aria-invalid",s==="error"?"true":"false"),s==="error"&&r.setAttribute("data-error","true"),s==="success"&&r.setAttribute("data-success","true"),()=>{r.removeAttribute("aria-describedby"),r.removeAttribute("aria-invalid"),r.removeAttribute("data-error"),r.removeAttribute("data-success")}}},[o,s,t]),t?i.jsxs("small",{className:y.join("mt-0.5 text-sm inline-flex items-center gap-1 w-full justify-start",s==="error"&&"text-destructive",s==="success"&&"text-success"),role:"status",children:[s==="error"?i.jsx(F.ExclamationTriangle,{}):i.jsx(A.CheckCircled,{}),i.jsx("span",{id:`${o}-${s}-message`,children:t})]}):null}const re={base:"",default:"ring ring-transparent focus:ring-primary-foreground not-disabled:data-error:ring-destructive not-disabled:data-success:ring-success",underline:"border-b border-border focus:border-primary-foreground disabled:border-muted/30 not-disabled:data-error:border-destructive not-disabled:data-success:border-success",outline:"border border-border focus:border-primary-foreground disabled:border-muted/30 not-disabled:data-error:border-destructive not-disabled:data-success:border-success"},ne={none:"rounded-none",sm:"rounded-sm",md:"rounded-md",lg:"rounded-lg",full:"px-3 rounded-full"},G={variant:"default",rounded:"none"};function oe({variant:o=G.variant,rounded:s,displayOnlyMode:t=!1,errorMessage:r,successMessage:e,type:n="text",className:a,...c}){const f=l.useId(),[d,h]=l.useState(!1);let u=s;o==="outline"&&!s&&(u="md"),u=u||G.rounded;const b=y.join("appearance-none w-full focus:outline-none disabled:opacity-50 disabled:cursor-not-allowed placeholder:text-muted/70 hide-number-input-arrows transition-all","file:mr-2 file:border-0 file:rounded-md file:px-1.5 file:py-1 file:bg-primary hover:file:bg-primary/85 file:text-sm file:font-medium file:text-foreground file:transition-colors",!t&&re[o],!t&&ne[u],n==="password"&&"pr-10",!t&&"px-2 py-1",t&&"pointer-events-none",a);return i.jsxs("div",{className:y.join(t&&"cursor-text"),style:{height:c.height,width:c.width},children:[i.jsxs("div",{className:y.join(n==="password"&&"relative"),children:[i.jsx("input",{...c,id:f,type:n==="password"&&d?"text":n,"aria-disabled":c.disabled,readOnly:t,"aria-readonly":t||c["aria-readonly"],"data-error":r?!0:void 0,"data-success":e?!0:void 0,className:b}),n==="password"&&i.jsx("button",{onClick:()=>h(!d),className:"absolute inset-y-0 right-0 px-2 hover:cursor-pointer","aria-label":"Toggle password visibility","data-state":d?"visible":"hidden",children:d?i.jsx(A.EyeClosed$1,{size:20}):i.jsx(A.EyeClosed,{size:20})})]}),!t&&i.jsx(L,{elementId:f,type:"error",message:r}),!t&&i.jsx(L,{elementId:f,type:"success",message:e})]})}function se({display:o="inline",width:s="fit-content",className:t="",required:r,helpMessage:e,suffix:n,htmlFor:a,children:c,...f}){const d=l.useId(),h=y.join("font-medium",o,t),u=e?`${a??d}-help`:void 0;return i.jsxs("div",{style:{display:o==="inline"?"inline-flex":"flex",width:s},className:"relative",children:[i.jsxs("label",{className:h,htmlFor:a,...f,children:[c,r&&i.jsx("span",{className:"text-red-500 font-medium ml-1","aria-label":"required",children:"*"})]}),e&&i.jsx("span",{className:"text-gray-500 ml-1 size-fit -translate-y-1/3","aria-describedby":u,"aria-label":"Help information",title:e,children:i.jsx(A.QuestionMarkCircled,{})}),e&&i.jsx("div",{id:u,className:"sr-only",children:e}),n&&i.jsx("span",{className:"ml-1",children:n})]})}function ae(o){const[s,t]=l.useState(!1),[r,e]=l.useState(!1);return l.useEffect(()=>{o?(e(!0),setTimeout(()=>t(!0),10)):(t(!1),setTimeout(()=>e(!1),150))},[o]),{show:s,shouldRender:r}}function ie(o,s){l.useEffect(()=>{const t=r=>{r.key==="Escape"&&o&&s()};return document.addEventListener("keydown",t),o&&(document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",t),document.body.style.overflow="auto"}},[o,s])}function le(o,s){const t=l.useRef(null),r=l.useCallback(()=>{const e=document.getElementById(o);if(!e)return;const n=e.querySelectorAll('[data-modal-action="true"]');if(n.length>0){n[0].focus();return}const a=e.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');if(a.length>0){const c=Array.from(a).filter(f=>!(f instanceof HTMLButtonElement&&f.getAttribute("data-modal-close-button")==="true"));if(c.length>0){c[0].focus();return}a[0].focus();return}e.focus()},[o]);l.useEffect(()=>(s&&(t.current=document.activeElement,r()),()=>{document.body.style.overflow="auto",t.current instanceof HTMLElement&&t.current.focus()}),[s,r])}function ue({id:o,isOpen:s,onClose:t,title:r,children:e,contentOnly:n=!1,className:a,overlayClassName:c,hideCloseButton:f=!1,actions:d=[],disableCloseOnOverlayClick:h=!1,ariaLabelledBy:u,ariaDescribedBy:v}){const m=l.useId(),b=o||`modal-${m}`,g=o?`${o}-title`:`modal-title-${m}`,{show:x,shouldRender:w}=ae(s);if(le(b,w),ie(w,t),!w)return null;const p=()=>r?l.isValidElement(r)?i.jsx("div",{className:"mb-4",children:r}):i.jsx("h2",{className:"mb-4 text-xl font-semibold",id:g,children:r}):null,j=()=>d.length===0?null:i.jsx("div",{className:"mt-6 not-sm:grid gap-y-2 sm:flex sm:justify-start sm:flex-row-reverse sm:gap-x-3",children:d.map((C,E)=>{const{label:k,className:S,...T}=C;return i.jsx(X,{className:S,type:"button",...T,"data-modal-action":"true",children:k},E)})});return i.jsx(i.Fragment,{children:V.createPortal(i.jsx("div",{"aria-labelledby":u??r?g:void 0,"aria-describedby":v,role:"dialog","aria-modal":"true",className:"fixed inset-0 z-[100] overflow-y-auto",children:i.jsxs("div",{className:"flex min-h-screen items-center justify-center p-4",children:[i.jsx("div",{className:I.n("fixed inset-0 bg-black/20 transition-all",c),onClick:()=>{h||t()}}),n&&i.jsx("div",{className:I.n("relative w-fit",a),children:e}),!n&&i.jsxs("div",{id:b,tabIndex:-1,className:I.n("relative w-full max-w-xl transform rounded-lg shadow-xl bg-popover transition-all p-6 focus:ring ease-in duration-75",x?"opacity-100 scale-100":"opacity-0 scale-90",a),children:[!f&&i.jsx("button",{type:"button",onClick:t,"data-modal-close-button":"true",className:"rounded-md p-0.5 top-2.5 right-2.5 absolute opacity-80 hover:opacity-100 transition-opacity focus:outline-none focus:ring-2 focus:ring-gray-500 leading-0",children:i.jsx(F.X,{size:18})}),p(),e,j()]})]})}),document.body)})}function ce(o){const[s,t]=l.useState(!1),[r,e]=l.useState(!1);return l.useEffect(()=>{o?(e(!0),setTimeout(()=>t(!0),10)):(t(!1),setTimeout(()=>e(!1),300))},[o]),{show:s,shouldRender:r}}function de(o,s){l.useEffect(()=>{const t=r=>{r.key==="Escape"&&o&&s()};return document.addEventListener("keydown",t),o&&(document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",t),document.body.style.overflow="auto"}},[o,s])}function fe(o,s){const t=l.useRef(null),r=l.useCallback(()=>{const e=document.getElementById(o);if(!e)return;const n=e.querySelectorAll('[data-panel-action="true"]');if(n.length>0){n[0].focus();return}const a=e.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');if(a.length>0){const c=Array.from(a).filter(f=>!(f instanceof HTMLButtonElement&&f.getAttribute("data-panel-close-button")==="true"));if(c.length>0){c[0].focus();return}a[0].focus();return}e.focus()},[o]);l.useEffect(()=>(s&&(t.current=document.activeElement,r()),()=>{document.body.style.overflow="auto",t.current instanceof HTMLElement&&t.current.focus()}),[s,r])}const me={size:{sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg",xl:"max-w-xl","2xl":"max-w-2xl",full:"w-full",screen:"w-screen"}};function be({ref:o,id:s,isOpen:t,onClose:r,title:e,children:n,footer:a,size:c="md",className:f,overlayClassName:d,hideCloseButton:h=!1,disableCloseOnOverlayClick:u=!1,ariaLabelledBy:v,ariaDescribedBy:m}){const b=l.useId(),g=s||`panel-${b}`,x=s?`${s}-title`:`panel-title-${b}`,{show:w,shouldRender:p}=ce(t);if(fe(g,p),de(p,r),!p)return null;const j=()=>e?l.isValidElement(e)?i.jsx("div",{children:e}):i.jsx("h2",{className:"text-2xl font-semibold",id:x,children:e}):null,C=()=>{if(!a)return null;if(l.isValidElement(a)){const E=a,k=E.props.className||"";return l.cloneElement(E,{className:I.n("px-6 py-4",k)})}return i.jsx("div",{className:"px-6 py-4",children:a})};return i.jsx(i.Fragment,{children:V.createPortal(i.jsxs("div",{"aria-labelledby":v??e?x:void 0,"aria-describedby":m,role:"dialog","aria-modal":"true",className:"fixed inset-0 z-[100] overflow-hidden","data-panel-open":t,children:[i.jsx("div",{className:I.n("fixed inset-0 bg-black/40 transition-opacity duration-300",w?"opacity-100":"opacity-0",d),onClick:()=>{u||r()}}),i.jsx("div",{className:"fixed inset-y-0 right-0 flex max-w-full",children:i.jsx("div",{id:g,ref:o,tabIndex:-1,className:I.n("relative h-full transform shadow-xl bg-popover transition-transform duration-300 ease-in-out",c!=="screen"&&"border-l border-border",me.size[c],w?"translate-x-0":"translate-x-full",f),"data-panel-size":c,children:i.jsxs("div",{className:"flex h-full flex-col",children:[e&&i.jsx("div",{className:"px-6 pt-6",children:j()}),!h&&i.jsx("button",{type:"button",onClick:r,"data-panel-close-button":"true","aria-label":"Close panel",className:"rounded-md p-0.5 top-3 right-3 absolute opacity-80 hover:opacity-100 transition-opacity focus:outline-none focus:ring-2 focus:ring-gray-500 leading-0",children:i.jsx(F.X,{size:18})}),i.jsx("div",{className:I.n("flex-1 overflow-y-auto px-6 pb-6",e?"pt-6":"pt-10"),children:n}),C()]})})})]}),document.body)})}function _({itemId:o,checked:s,onChange:t,name:r,disabled:e=!1,className:n=""}){const a="relative inline-flex items-center justify-center rounded-full",c=()=>{e||t()},f=y.join(a,!s&&"hover:border-current/60",!e&&"border-current cursor-pointer",e&&"border-muted/60 cursor-not-allowed",n);return i.jsx("div",{id:o,role:"radio",tabIndex:-1,"aria-checked":s,"aria-disabled":e,"aria-description":`Radio button for ${r}`,"aria-labelledby":`${o}-label`,onClick:c,className:f,style:{width:"1em",height:"1em",padding:"0.1em",borderWidth:"0.06em"},children:s&&i.jsx("div",{className:y.join("size-full aspect-square rounded-full",e&&"bg-muted/60",!e&&"bg-current")})})}function z({value:o,children:s,className:t="",isSelected:r=!1,onChange:e,disabled:n=!1,hideInput:a=!1,description:c,name:f}){const h=`radio-${l.useId()}-${o}`,u=()=>{n||e==null||e(o)};return i.jsxs("div",{title:c,className:y.join("relative flex items-center",t,a&&`p-2 border-2 focus-within:border-dashed focus-within:${n?"border-current/50":"border-current/80"}`,a&&!r&&`border-transparent ${n?"":"not-focus-within:hover:border-border/60"}`,a&&r&&"border-border",n&&"opacity-60 cursor-not-allowed"),style:{gap:"0.5em"},children:[!a&&i.jsx(_,{itemId:h,name:f||"",checked:r,onChange:u,disabled:n,className:y.join(a&&"")}),i.jsx("div",{id:a?h:void 0,tabIndex:a?-1:void 0,role:a?"radio":void 0,onClick:a?u:void 0,"aria-checked":a?r?"true":"false":void 0,"aria-disabled":a?n:void 0,"aria-description":a?c||`Radio button for ${f}`:void 0,"aria-labelledby":a?`${h}-label`:void 0,className:y.join(a&&"size-full",typeof s=="object"&&"grow focus:outline-none"),children:i.jsx("label",{id:`${h}-label`,onClick:a?void 0:u,className:y.join(n&&"cursor-not-allowed",!n&&"cursor-pointer"),children:s})})]})}function he(o,s){const[t,r]=l.useState(s),[e,n]=l.useState(-1),[a,c]=l.useState(!1),f=l.useCallback((m,b)=>{var w;const g=m[b];g.hasAttribute("disabled")||g.getAttribute("aria-disabled")==="true"||((w=m[b])==null||w.click(),n(b))},[]),d=l.useCallback((m,b)=>{var x;if(m.preventDefault(),a||!b.length)return;const g=s!==-1?s:0;(x=b[g])==null||x.focus(),r(g),s!==-1&&f(b,g)},[s,a,f]),h=l.useCallback(m=>{var w;if(!m.shiftKey)return;m.preventDefault();const b=Array.from(document.querySelectorAll('a, button, input, textarea, select, details, [tabindex]:not([tabindex="-1"])')).filter(p=>!p.hasAttribute("disabled")&&p.tabIndex>=0),g=b.findIndex(p=>p.id===o),x=g>0?g-1:b.length-1;(w=b[x])==null||w.focus()},[o]),u=l.useCallback((m,b)=>{var j;if(!b.length)return;const g=m.target;if(!b.some(C=>C.id===g.id))return;const w=t!==-1?t:0;let p=w;switch(m.key){case"ArrowUp":case"ArrowLeft":m.preventDefault(),p=w>0?w-1:b.length-1;break;case"ArrowDown":case"ArrowRight":m.preventDefault(),p=(w+1)%b.length;break;case" ":m.preventDefault(),f(b,w);return;case"Tab":h(m);return;default:return}(j=b[p])==null||j.focus(),r(p),e!==-1&&f(b,p)},[t,e,h,f]),v=l.useCallback(()=>{const m=document.querySelector(`[id="${o}"][role="radiogroup"]`);return m?Array.from(m.querySelectorAll('[role="radio"]')):[]},[o]);l.useEffect(()=>{const m=document.querySelector(`[id="${o}"][role="radiogroup"]`);if(!m)return;const b=v(),g=j=>d(j,b),x=j=>u(j,b),w=()=>c(!0),p=()=>c(!1);return document.addEventListener("keydown",x),m.addEventListener("focus",g),m.addEventListener("mousedown",w),document.addEventListener("mouseup",p),()=>{document.removeEventListener("keydown",x),m.removeEventListener("focus",g),m.removeEventListener("mousedown",w),document.removeEventListener("mouseup",p)}},[o,v,d,u])}function xe({options:o=[],value:s,onChange:t,id:r,children:e,className:n="",childrenClassName:a="",hideInputs:c=!1}){const f=l.useId(),d=r||`radio-group-${f}`;he(d,o.findIndex(u=>u===s));const h=l.useMemo(()=>o.reduce((u,v)=>(typeof v=="string"?u.some(m=>m.value===v)||u.push({label:v,value:v}):u.push(v),u),[]),[o]);return i.jsxs("div",{id:d,role:"radiogroup",tabIndex:0,className:y.join(n,"focus:outline-none"),children:[h.length>0&&h.map((u,v)=>i.jsx(z,{value:u.value,isSelected:s===u.value,onChange:t,name:d,disabled:u.disabled,description:u.description,hideInput:c,className:a,children:u.label},`${u.value}-${v}`)),h.length===0&&e&&l.Children.map(e,u=>l.isValidElement(u)&&u.type===z?i.jsx(z,{...u.props,className:y.join(a,u.props.className),hideInput:u.props.hideInput||c,isSelected:s===u.props.value,onChange:t,name:d,children:u.props.children}):null)]})}const pe={thin:{horizontal:"h-px",vertical:"w-px"},medium:{horizontal:"h-0.5",vertical:"w-0.5"},thick:{horizontal:"h-1",vertical:"w-1"},"extra-thick":{horizontal:"h-2",vertical:"w-2"}},ge={horizontal:"w-full",vertical:"min-h-4 h-full"};function ve({orientation:o="horizontal",decorative:s=!1,thickness:t="thin",className:r,...e}){const n=y.join("shrink-0 bg-border",ge[o],pe[t][o],r);return i.jsx("div",{...e,className:n,role:s?"presentation":"separator","aria-orientation":s?void 0:o,"aria-hidden":s,"data-orientation":o,"data-thickness":t})}function we({children:o,ref:s,...t}){if(l.isValidElement(o)){let r={...t};return o.props&&(r={...r,...o.props}),l.cloneElement(o,{...r,ref:e=>{typeof s=="function"?s(e):s&&(s.current=e)}})}return l.createElement("div",{...t,ref:s},o)}function ye({elementId:o,maxLength:s}){const[t,r]=l.useState(0);return l.useEffect(()=>{const e=document.getElementById(o);if(!e)return;const n=()=>{const a=e.value.length;r(a);const c=a>=s;e.setAttribute("aria-describedby",`${o}-character-count`),e.setAttribute("aria-invalid",c?"true":"false"),c?e.setAttribute("data-error","true"):e.removeAttribute("data-error")};return n(),e.addEventListener("input",n),e.setAttribute("maxlength",String(s)),()=>{e.removeEventListener("input",n),e.removeAttribute("maxlength"),e.removeAttribute("aria-describedby"),e.removeAttribute("aria-invalid"),e.removeAttribute("data-error")}},[o,s]),i.jsx("small",{className:y.join("mt-0.5 text-sm inline-flex items-center gap-1 w-full justify-end",t>=s&&"text-destructive",t<s&&"text-current"),role:"status",children:i.jsxs("span",{id:`${o}-character-count`,children:[t," / ",s," characters"]})})}function je(o,s){l.useEffect(()=>{const t=document.getElementById(o);if(!t)return;if(!s){t.style.height="auto";return}const r=()=>{t.style.height="auto",t.style.height=`${t.scrollHeight}px`};return r(),t.addEventListener("input",r),t.addEventListener("resize",r),window.addEventListener("resize",r),()=>{t.removeEventListener("input",r),t.removeEventListener("resize",r),window.removeEventListener("resize",r)}},[o,s])}const Ee={base:"","left-line":"border-l border-border focus:border-primary-foreground disabled:border-muted/30 not-disabled:data-error:border-destructive not-disabled:data-success:border-success",outline:"border border-border focus:border-primary-foreground disabled:border-muted/30 not-disabled:data-error:border-destructive not-disabled:data-success:border-success"},Ne={none:"rounded-none",sm:"rounded-sm",md:"rounded-md",lg:"rounded-lg",full:"px-3 rounded-full"},M={variant:"outline",rounded:"none"};function Ce({variant:o=M.variant,rounded:s,displayOnlyMode:t=!1,errorMessage:r,successMessage:e,hideResizeHandle:n=!1,autoExpand:a=!1,characterLimit:c=0,className:f,...d}){const h=l.useId();je(h,a||t);let u=s;o==="outline"&&!s&&(u="md"),u=u||M.rounded;let v=n;(t||o==="left-line"&&!n)&&(v=!0);const b=y.join("appearance-none w-full focus:outline-none disabled:opacity-50 disabled:cursor-not-allowed placeholder:text-muted/70 hide-number-input-arrows transition-all",!t&&Ee[o],!t&&Ne[u],!t&&"px-2 py-1",t&&"pointer-events-none",v&&"no-resize-handle",f);return i.jsxs("div",{className:y.join("-space-y-1.5",t&&"cursor-text"),children:[i.jsx("textarea",{...d,id:h,"aria-disabled":d.disabled,readOnly:t,"aria-readonly":t||d["aria-readonly"],style:{resize:a?"none":void 0},className:b}),c>0&&i.jsx(ye,{elementId:h,maxLength:c}),!t&&i.jsx(L,{elementId:h,type:"error",message:r}),!t&&i.jsx(L,{elementId:h,type:"success",message:e})]})}const Ie={sm:{container:"h-5 min-w-9 w-9",thumb:"h-4 w-4",translate:"translate-x-4"},md:{container:"h-6 min-w-11 w-11",thumb:"h-5 w-5",translate:"translate-x-5"},lg:{container:"h-7 min-w-13 w-13",thumb:"h-6 w-6",translate:"translate-x-6"}},Ae={default:{unchecked:"bg-muted",checked:"bg-primary"},success:{unchecked:"bg-muted",checked:"bg-success"},destructive:{unchecked:"bg-muted",checked:"bg-destructive"}},W={variant:"default",size:"md"};function ke({ref:o,id:s,size:t=W.size,variant:r=W.variant,checked:e,onCheckedChange:n,disabled:a=!1,className:c,thumbClassName:f,backgroundClassNames:d,...h}){const u=l.useId(),v=l.useMemo(()=>s||`toggle-${u}`,[s,u]),[m,b]=l.useState(e);l.useEffect(()=>{b(e)},[e]);const g=()=>{if(!a){const E=!m;e===void 0&&b(E),n==null||n(E)}},x=E=>{(E.key===" "||E.key==="Enter")&&(E.preventDefault(),g())},w=Ie[t],p=Ae[r],j=y.join("relative inline-flex items-center rounded-full transition-all duration-200 ease-in-out","focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2",w.container,m?(d==null?void 0:d.checked)||p.checked:(d==null?void 0:d.unchecked)||p.unchecked,a&&"opacity-50 cursor-not-allowed",!a&&"cursor-pointer",c),C=y.join("absolute left-0.5 top-1/2 -translate-y-1/2 rounded-full bg-white shadow-sm transition-transform duration-200 ease-in-out",w.thumb,m&&w.translate,f);return i.jsxs("button",{ref:o,id:v,type:"button",role:"switch",tabIndex:0,"aria-checked":m,"aria-disabled":a,disabled:a,onClick:g,onKeyDown:x,className:j,...h,children:[i.jsx("span",{className:C}),i.jsx("span",{className:"sr-only",children:m?"Enabled":"Disabled"})]})}const $=8,R=4,N=6;function Se(o){return{calculatePosition:l.useCallback((t,r)=>{const e=t.getBoundingClientRect(),n=r.getBoundingClientRect(),a={width:window.innerWidth,height:window.innerHeight},c=(v,m,b,g)=>v<0||m<0||v+b>a.width||m+g>a.height,f={top:{x:e.left+e.width/2-n.width/2,y:e.top-n.height-R,arrow:{x:n.width/2-N,y:n.height}},bottom:{x:e.left+e.width/2-n.width/2,y:e.bottom+R,arrow:{x:n.width/2-N,y:-6}},left:{x:e.left-n.width-R,y:e.top+e.height/2-n.height/2,arrow:{x:n.width,y:n.height/2-N}},right:{x:e.right+R,y:e.top+e.height/2-n.height/2,arrow:{x:-6,y:n.height/2-N}}};let d=o,h=f[o];if(c(h.x,h.y,n.width,n.height)){const v={top:"bottom",bottom:"top",left:"right",right:"left"},m=f[v[o]];if(!c(m.x,m.y,n.width,n.height))d=v[o],h=m;else{const b=["top","bottom","left","right"].filter(g=>g!==o&&g!==v[o]);for(const g of b){const x=f[g];if(!c(x.x,x.y,n.width,n.height)){d=g,h=x;break}}}}h.x=Math.max($,Math.min(h.x,a.width-n.width-$)),h.y=Math.max($,Math.min(h.y,a.height-n.height-$));const u={x:e.left+e.width/2,y:e.top+e.height/2};return d==="top"||d==="bottom"?h.arrow.x=Math.max(N,Math.min(u.x-h.x-N,n.width-N*2)):h.arrow.y=Math.max(N,Math.min(u.y-h.y-N,n.height-N*2)),{...h,placement:d}},[o])}}function Te(o,s,t){const r=l.useRef(null),e=l.useRef(null),n=l.useCallback(()=>{if(!r.current||!e.current)return;const a=o(r.current,e.current);t(a)},[o,t]);return l.useEffect(()=>{if(!s)return;const a=()=>n();return window.addEventListener("resize",a),()=>{window.removeEventListener("resize",a)}},[s,n]),{triggerRef:r,tooltipRef:e,updatePosition:n}}function $e(o,s,t,r,e,n,a,c,f){const d=l.useRef(null),h=l.useCallback(()=>{o||(d.current&&clearTimeout(d.current),d.current=window.setTimeout(()=>{t(!0),requestAnimationFrame(()=>{e(),r(!0)})},s))},[o,s,t,e,r]),u=l.useCallback((v=!1)=>{if(d.current&&clearTimeout(d.current),v){r(!1),setTimeout(()=>t(!1),150);return}d.current=window.setTimeout(()=>{r(!1),setTimeout(()=>t(!1),150)},100)},[r,t]);return l.useEffect(()=>{!n&&!a&&!c&&f&&u()},[n,a,c,f,u]),l.useEffect(()=>()=>{d.current&&clearTimeout(d.current)},[]),{showTooltip:h,hideTooltip:u,timeoutRef:d}}function Re({id:o,children:s,message:t,placement:r="top",disabled:e=!1,delay:n=200,className:a}){const[c,f]=l.useState(!1),[d,h]=l.useState(!1),[u,v]=l.useState(null),[m,b]=l.useState(!1),[g,x]=l.useState(!1),[w,p]=l.useState(!1),{calculatePosition:j}=Se(r),{triggerRef:C,tooltipRef:E,updatePosition:k}=Te(j,d,v),{showTooltip:S,hideTooltip:T,timeoutRef:H}=$e(e,n,h,f,k,m,g,w,c),Q=l.useId(),K=o??Q;return i.jsxs(i.Fragment,{children:[l.cloneElement(s,{ref:B=>{C.current=B},onMouseEnter:()=>{b(!0),S()},onMouseLeave:()=>{b(!1)},onFocus:()=>{p(!0),S()},onBlur:()=>{p(!1),T(!0)},onKeyDown:B=>{B.key==="Escape"&&T(!0)},"aria-describedby":e?void 0:K}),d&&V.createPortal(i.jsx("div",{ref:E,id:K,role:"tooltip",className:y.join("fixed z-50 px-2 py-1 text-sm rounded shadow-lg bg-popover pointer-events-auto transition-all duration-150 ease-out",c?"opacity-100":"opacity-0",a),style:u?{left:u.x,top:u.y}:{opacity:0},onMouseEnter:()=>{x(!0),H.current&&clearTimeout(H.current)},onMouseLeave:()=>{x(!1)},children:t}),document.body)]})}exports.ActionModal=I.ActionModal;exports.Toast=I.Toast;exports.Accordion=Z;exports.AccordionItem=D;exports.Button=X;exports.ButtonLoadingDots=U;exports.Checkbox=ee;exports.Clickable=te;exports.Input=oe;exports.Label=se;exports.Modal=ue;exports.Panel=be;exports.RadioGroup=xe;exports.RadioGroupItem=z;exports.RadioInput=_;exports.Separator=ve;exports.Slot=we;exports.Textarea=Ce;exports.Toggle=ke;exports.Tooltip=Re;
|
|
2
2
|
//# sourceMappingURL=components.cjs.js.map
|