visits-style 2.1.4 → 2.2.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.
package/dist/index.cjs.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("clsx"),ie=require("tailwind-merge"),s=require("react/jsx-runtime"),n=require("react"),d=require("@floating-ui/react"),le=require("react-dom");function R(e,t){return t?ie.twMerge(e,t):e}function Y({className:e,...t}){const o=n.useMemo(()=>x("leading-none peer-disabled:opacity-70",e),[e]);return s.jsx("label",{className:o,...t})}function ae({label:e,children:t,required:o,htmlFor:r,error:l,help:i,helpBefore:a,className:c,innerClass:m,...f}){const p=n.useMemo(()=>x("font-medium",o?'after:content-["*"] after:text-danger after:text-sm after:pl-0.5':""),[o]),y=n.useMemo(()=>R("flex flex-col space-y-2",c),[c]);return s.jsxs("div",{className:y,...f,children:[e?s.jsx(Y,{className:p,htmlFor:r,children:e}):null,i&&a?s.jsx("p",{className:"text-xs text-muted pb-2",children:i}):null,s.jsx("div",{className:m,children:ue(t,!!l)}),i&&!a&&!l?s.jsx("p",{className:"text-xs text-muted",children:i}):null,l?s.jsx("p",{className:"text-xs text-danger",children:l}):null]})}function ue(e,t){const o=n.Children.count(e);if(!o)return null;if(o===1)return n.cloneElement(e,{error:t});const r=n.Children.toArray(e);return r[0]=n.cloneElement(r[0],{error:t}),r}function ce({error:e,unstyled:t,className:o,...r}){const l=n.useMemo(()=>t?o:R(x("flex rounded-md border bg-background px-3 py-2 w-full [&_input]:placeholder:text-muted","[&_input]:disabled:opacity-50 [&_input]:focus-visible:outline-none",e?"border-danger hover:border-danger-fore":"border-input"),o),[o,e,t]);return s.jsx("div",{className:l,...r})}const z=n.forwardRef(({className:e,type:t,error:o,unstyled:r,...l},i)=>{const a=n.useMemo(()=>r?e:R(x("flex rounded-md border bg-background px-3 py-2 w-full placeholder:text-muted","disabled:cursor-not-allowed disabled:opacity-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-ring",o?"border-danger hover:border-danger-fore":"border-input not-disabled:hover:border-input-fore",t==="file"?"file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground":null),e),[e,t,o,r]);return s.jsx("input",{ref:i,type:t,className:a,...l})});z.displayName="Input";const Z=n.forwardRef(({className:e,error:t,unstyled:o,...r},l)=>{const i=n.useMemo(()=>o?e:R(x("flex rounded-md border bg-background px-3 py-2 w-full","disabled:cursor-not-allowed disabled:opacity-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-ring",t?"border-danger hover:border-danger-fore":"border-input not-disabled:hover:border-input-fore"),e),[e,t,o]);return s.jsx("textarea",{ref:l,className:i,...r})});Z.displayName="Textarea";function de(){return s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"30",height:"30",viewBox:"0 0 30 30",children:s.jsx("rect",{width:"20",height:"3",y:"13.5",x:"4.5",fill:"currentColor",stroke:"none",rx:"2"})})}function fe({checked:e,indeterminate:t,className:o,id:r,name:l,onChange:i,value:a,checkIcon:c,...m}){const f=n.useMemo(()=>R(x("inline-flex justify-center items-center border w-4.5 h-4.5 rounded","cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed",e||t?"bg-primary text-inverted disabled:text-text disabled:bg-input disabled:border-input":"border-input not-disabled:hover:border-input-fore"),o),[e,t,o]),p=()=>{m.disabled||i?.(!e)};return s.jsxs("button",{type:"button",role:"checkbox",id:r||l,className:f,onClick:p,"aria-checked":e,...m,children:[e?c:null,t&&!e?s.jsx(de,{}):null,s.jsx("input",{type:"checkbox","aria-hidden":"true",name:l,checked:e,value:a,onChange:p,disabled:m.disabled,style:{position:"absolute",pointerEvents:"none",top:0,left:0,width:1,height:1,opacity:0}})]})}const pe=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",q=pe?n.useLayoutEffect:n.useEffect;function E({children:e,container:t,disabled:o}){const[r,l]=n.useState(null);return q(()=>{if(!t){let i=document.getElementById("visits-style-portals");return i||(i=document.createElement("div"),i.id="visits-style-portals",document.body.appendChild(i)),l(i)}l(t)},[t]),o||!r?null:le.createPortal(e,r)}function $(e){e&&(e.stopPropagation(),e.preventDefault())}const me={open:150,close:75},H=n.forwardRef(({position:e,label:t,children:o,disabled:r,offset:l={x:0,y:6},onOpen:i,onClose:a,onManualClose:c,timeout:m=me,unstyled:f,zIndex:p=9996,role:y,...C},M)=>{const[g,u]=n.useState(!1),j=d.useId(),h=n.useRef(i),w=n.useRef(a),{refs:v,floatingStyles:S,context:T}=d.useFloating({nodeId:j,placement:e,middleware:[d.shift(),d.flip({fallbackAxisSideDirection:"end"}),d.offset({mainAxis:l.y,crossAxis:l.x})],open:g,onOpenChange:N=>{N?h.current?.(v.reference.current,v.floating.current):w.current?.(v.reference.current,v.floating.current),u(N)},whileElementsMounted:d.autoUpdate}),{isMounted:P,styles:O}=d.useTransitionStyles(T,{duration:m,initial({side:N}){let I="";return N==="top"?I="translateY(5%) scale(0.95)":N==="bottom"?I="translateY(-5%) scale(0.95)":N==="left"?I="translateX(5%) scale(0.95)":I="translateX(-5%) scale(0.95)",{opacity:0,transform:I}}}),A=n.useCallback(N=>{if($(N),c)return c();u(!1),w.current?.(v.reference.current,v.floating.current)},[c]);n.useEffect(()=>{if(r&&g)return u(!1)},[r,g]),n.useImperativeHandle(M,()=>({open:()=>{u(!0),h.current?.(v.reference.current,v.floating.current)},close:()=>{u(!1),w.current?.(v.reference.current,v.floating.current)}}),[]);const{getFloatingProps:D,getReferenceProps:_}=d.useInteractions([d.useClick(T,{enabled:!r})]);return h.current=i,w.current=a,s.jsxs(s.Fragment,{children:[n.cloneElement(n.Children.only(t),_({ref:v.setReference,tabIndex:0,role:"button","aria-expanded":g,disabled:r,onClick:$})),s.jsx(E,{disabled:r||!P,children:s.jsx(d.FloatingOverlay,{"data-testid":"vs-popover-shadow",onClick:A,style:{zIndex:p},autoFocus:!0,children:s.jsx("div",{role:y||"region",ref:v.setFloating,style:S,children:s.jsx(G,{unstyled:f,styles:O,...D({...C,onClick:$}),children:o})})})})]})});H.displayName="Popover";const G=n.forwardRef(({className:e,unstyled:t,styles:o,style:r={},...l},i)=>{const a=n.useMemo(()=>R(x("z-20 w-auto h-auto outline-none transition-transform ease-in-out",t?null:"border border-accent rounded-md shadow-lg p-1 bg-background"),e),[e,t]);return s.jsx("div",{ref:i,className:a,style:{...o,...r},...l})});G.displayName="PopoverContent";function be({className:e,placeholder:t="",options:o=[],error:r,unstyled:l,disabled:i,value:a,maxHeight:c=408,arrowIcon:m,closeIcon:f,checkIcon:p,onChange:y,onClear:C,renderItem:M,sectionLabelStyle:g,buttonAreaStyle:u,clearLabelText:j,optionStyle:h,...w}){const v=n.useRef(null),[S,T]=n.useState(0),P=n.useMemo(()=>l?e:R(x("flex items-center justify-between rounded-md border bg-background px-3 py-2 w-full overflow-hidden cursor-pointer","disabled:cursor-not-allowed disabled:opacity-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-ring",r?"border-danger hover:border-danger-fore":"border-input not-disabled:hover:border-input-fore"),e),[e,r,l]),O=n.useMemo(()=>Array.isArray(a),[]),A=n.useCallback(b=>{y?.(b),O||v.current?.close()},[y,O]),D=n.useCallback(b=>Array.isArray(a)?a.indexOf(b)>-1:a===b,[a]),_=n.useMemo(()=>{const b={},F=o.filter(k=>typeof k!="string");for(let k=0,B=F.length;k<B;k+=1){const X=F[k];b[`${X.value}`]=X.label}return b},[o]),N=n.useMemo(()=>{if(!a)return t;if(Array.isArray(a)){if(!a.length)return t;const b=[...a].sort(),F=[];for(let k=0,B=b.length;k<B;k+=1)F[k]=_[`${b[k]}`]||"";return F.filter(Boolean).join(",")||t}return _[`${a}`]||t},[t,a,_]),I=N===t,re=n.useMemo(()=>x("overflow-hidden overflow-ellipsis whitespace-nowrap",I?"text-muted":"text-text"),[I]),oe=n.useCallback((b,F)=>M?typeof b=="string"?M(b,{index:F,selected:!1,onChange:()=>{}}):M(b,{index:F,selected:D(b.value),onChange:()=>A(b.value)}):typeof b=="string"?s.jsx("h5",{className:x("font-normal py-1 px-2 text-muted",g),children:b},`optionheader-${F}`):s.jsx(ge,{selected:D(b.value),onChange:A,checkIcon:p,className:h,...b},b.label),[M,A,D,g,h,p]),se=n.useMemo(()=>x("relative flex items-center pr-4 space-x-2",u),[u]);return s.jsx(H,{label:s.jsxs("button",{type:"button",className:P,disabled:i,...w,children:[s.jsx("span",{className:re,children:N}),s.jsxs("div",{className:se,children:[C&&!I?s.jsx("div",{tabIndex:-1,role:"button",className:"size-6 p-1.5 rounded hover:bg-accent cursor-pointer","aria-label":j,onKeyDown:b=>{b.key!=="Enter"&&b.key!=="Space"||C()},onClick:b=>{b.stopPropagation(),C()},children:f}):null,m]})]}),ref:v,onOpen:b=>T(b?.getBoundingClientRect().width||0),disabled:i,children:s.jsx("ul",{className:"overflow-y-auto flex flex-col",role:"listbox",style:{minWidth:S,maxWidth:"calc(100vw - 3rem)",maxHeight:c},children:o.map(oe)})})}function ge({className:e,value:t,label:o,selected:r,checkIcon:l,onChange:i}){const a=n.useMemo(()=>x("flex items-center w-full hover:bg-accent rounded p-1 cursor-pointer",e),[e]);return s.jsxs("button",{type:"button",role:"option",className:a,"aria-selected":r,onClick:()=>i?.(t),children:[r&&l?l:s.jsx("div",{className:"w-5 h-1 mr-1"}),o]})}function xe({checked:e,className:t,id:o,name:r,onChange:l,value:i,...a}){const c=n.useMemo(()=>x("relative inline-flex justify-center items-center border border-input w-4.5 h-4.5 rounded-full","cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed not-disabled:hover:border-input-fore",e?"[&_i]:bg-primary disabled:[&_i]:bg-text disabled:border-input":"",t),[t,e]),m=()=>{a.disabled||l?.(!e)};return s.jsxs("button",{type:"button",role:"radio",id:o||r,className:c,onClick:m,"aria-checked":e,...a,children:[s.jsx("i",{className:"block w-2.5 h-2.5 rounded-full transition-transform",style:{transform:e?"":"scale(0.8)",opacity:e?1:0}}),s.jsx("input",{type:"radio","aria-hidden":"true",name:r,checked:e,value:i,onChange:m,disabled:a.disabled,style:{position:"absolute",pointerEvents:"none",top:0,left:0,width:1,height:1,opacity:0}})]})}const K=n.forwardRef(({className:e,checked:t,onChange:o,value:r,id:l,name:i,...a},c)=>{const m=n.useMemo(()=>R(x("inline-flex shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50","w-11",t?"bg-primary":"bg-input"),e),[e,t]),f=n.useMemo(()=>R("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform",e),[e]),p=()=>{a.disabled||o?.(!t)};return s.jsxs("button",{type:"button",role:"switch",id:l||i,className:m,onClick:p,"aria-checked":t,...a,children:[s.jsx("span",{className:f,style:{transform:t?"translateX(100%)":""}}),s.jsx("input",{ref:c,type:"checkbox","aria-hidden":"true",name:i,checked:t,value:r,onChange:p,disabled:a.disabled,style:{position:"absolute",pointerEvents:"none",top:0,left:0,width:1,height:1,opacity:0}})]})});K.displayName="Switch";function he({header:e,show:t,children:o,timeout:r=300,...l}){const i=n.useRef(null),a=n.useRef(0),c=n.useRef(0),m=n.useRef(!0);return n.useEffect(()=>{c.current=r},[r]),q(()=>{if(!i.current)return;if(i.current.style.overflow="hidden",i.current.style.opacity="1",m.current){m.current=!1,i.current.style.height=t?"auto":"0px",t?window.requestAnimationFrame(()=>{i.current&&(a.current=i.current.offsetHeight)}):(window.requestAnimationFrame(()=>{i.current&&(i.current.style.height="auto",a.current=i.current.offsetHeight,i.current.style.height="0px")}),i.current.style.opacity="0");return}t||(i.current.style.height=`${a.current}px`);const f=[];f[0]=window.requestAnimationFrame(()=>{f[1]=window.requestAnimationFrame(()=>{i.current&&(i.current.style.height=`${t?a.current:0}px`,i.current.style.opacity=t?"1":"0")})});let p;const y=()=>{i.current&&(t?(i.current.style.height="auto",i.current.style.overflow="",i.current.style.opacity="",window.requestAnimationFrame(()=>{i.current&&(a.current=i.current.offsetHeight)})):i.current.style.height="0px")};return c.current===0?y():p=window.setTimeout(y,c.current),()=>{f.forEach(window.cancelAnimationFrame),p&&window.clearTimeout(p)}},[t]),s.jsxs("div",{...l,children:[e,s.jsx("div",{className:"transition-all ease-in-out overflow-hidden",role:"region","aria-hidden":!t,ref:i,style:{transitionDuration:`${r}ms`},children:o})]})}const U=n.forwardRef(({children:e,position:t="bottom",label:o,className:r,timeout:l=150,offset:i={x:0,y:6},clientPoint:a=!1,disabled:c},m)=>{const[f,p]=n.useState(!1),y=d.useId(),{refs:C,floatingStyles:M,context:g}=d.useFloating({nodeId:y,open:f,placement:t,middleware:[d.shift(),d.flip(),d.offset({mainAxis:i.y,crossAxis:i.x})],whileElementsMounted:c?void 0:d.autoUpdate,onOpenChange:p}),{getReferenceProps:u,getFloatingProps:j}=d.useInteractions([d.useHover(g,{enabled:!c}),d.useClientPoint(g,{enabled:a})]),{isMounted:h,styles:w}=d.useTransitionStyles(g,{duration:l,initial:{opacity:0,transform:"scale(0.8)"}});n.useImperativeHandle(m,()=>({floating:C.floating,reference:C.reference,open:()=>p(!0),close:()=>p(!1)})),n.useEffect(()=>{c&&p(!1)},[c]);const v=typeof e=="string"?s.jsx("span",{children:e}):e;return s.jsxs(s.Fragment,{children:[n.cloneElement(n.Children.only(v),{ref:C.setReference,...u()}),s.jsx(E,{disabled:c||!h,children:s.jsx("div",{role:"tooltip",className:"z-[9999]",ref:C.setFloating,...j({style:M}),children:s.jsx(J,{className:r,style:w,children:o})})})]})});U.displayName="Tooltip";const J=n.forwardRef(({className:e,custom:t,...o},r)=>{const l=n.useMemo(()=>R(x("relative w-auto h-auto outline-none transition-transform ease-in-out whitespace-pre",t?null:"border border-accent rounded shadow-md px-3 py-1 bg-background"),e),[e,t]);return s.jsx("div",{ref:r,className:l,...o})});J.displayName="TooltipContent";function Q({variant:e,size:t}){return x("inline-flex items-center justify-center whitespace-nowrap transition-colors rounded-md cursor-pointer","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-auto",{"bg-primary text-inverted hover:bg-primary-fore":!e||e==="primary","bg-info text-inverted hover:bg-info-fore":e==="info","bg-warn text-inverted hover:bg-warn-fore":e==="warn","bg-danger text-inverted hover:bg-danger-fore":e==="danger","hover:bg-accent":e==="ghost","hover:underline":e==="link","border border-input hover:bg-accent":e==="outline"},{"px-2 py-1":!t,"p-1.5":t==="icon"})}function ye({size:e,variant:t,className:o,...r}){const l=n.useMemo(()=>x(Q({size:e,variant:t}),o),[e,t,o]);return s.jsx("button",{className:l,type:"button",...r})}function we({open:e,children:t,timeout:o=150,padding:r="0.85rem",verticalAlign:l="center",closeOnOverlay:i,closeOnEsc:a,onExited:c,className:m,onOpenChange:f,size:p,...y}){const C=n.useRef(c),M=n.useRef(!1),g=d.useId(),{refs:u,context:j}=d.useFloating({open:e,onOpenChange:f,nodeId:g}),{getFloatingProps:h}=d.useInteractions([d.useDismiss(j,{enabled:a,escapeKey:a,outsidePress:!1})]),{isMounted:w,styles:v}=d.useTransitionStyles(j,{duration:o,initial:{opacity:0,transform:"scale(0.8)"}});n.useEffect(()=>{M.current!==w&&(M.current=w,!w&&C.current?.())},[w]);const S=n.useCallback(()=>{i&&f?.(!1)},[f,i]);C.current=c;const T=n.useMemo(()=>x("grid bg-backdrop z-40 justify-items-center",{"place-items-start items-start":l==="start","place-items-end":l==="end","place-items-center":l==="center"||!l}),[l]),P=n.useMemo(()=>R("transition ease-in-out",m),[m]);return s.jsx(E,{disabled:!w,children:s.jsx(d.FloatingOverlay,{className:T,"data-testid":"vs-dialog-overlay",onClick:S,style:{padding:r,opacity:v.opacity},lockScroll:!0,children:s.jsx(V,{ref:u.setFloating,className:P,role:"dialog",size:p,style:v,onClick:$,...h({...y}),children:t})})})}const V=n.forwardRef(({size:e,className:t,...o},r)=>{const l=n.useMemo(()=>x(e?"flex flex-col bg-background shadow-lg p-5 rounded":null,{"w-full max-w-dialog-sm":e==="small","w-full max-w-dialog-md":e==="medium","w-full max-w-dialog-lg":e==="large"},t),[e,t]);return s.jsx("div",{ref:r,className:l,...o})});V.displayName="DialogContent";const ve={open:250,close:150};function je({open:e,timeout:t=ve,onOpenChange:o,position:r="right",overlay:l,onExited:i,onOpen:a,...c}){const m=d.useId(),f=n.useRef(!1),p=n.useRef(a),y=n.useRef(i),{refs:C,context:M}=d.useFloating({open:e,onOpenChange:o,nodeId:m}),{isMounted:g,styles:u}=d.useTransitionStyles(M,{duration:t,initial(){let h="translateX(75%)";return r==="left"?h="translateX(-75%)":r==="top"?h="translateY(-75%)":r==="bottom"&&(h="translateY(75%)"),{opacity:0,transform:h}}});n.useEffect(()=>{if(f.current!==g){if(f.current=g,g){p.current?.();return}y.current?.()}},[g]);const j=n.useMemo(()=>x("fixed transition-transform z-30",{"top-0 right-0 h-full max-h-screen":r==="right","top-0 left-0 h-full max-h-screen":r==="left","top-0 left-0 right-0 w-full max-w-screen":r==="top","bottom-0 left-0 right-0 w-full max-w-screen":r==="bottom"}),[r]);return y.current=i,p.current=a,s.jsxs(E,{disabled:!g,children:[l?s.jsx(d.FloatingOverlay,{className:"bg-backdrop",style:{opacity:u.opacity},onClick:()=>o?.(!1)}):null,s.jsx("div",{ref:C.setFloating,className:j,role:"dialog",style:u,children:s.jsx(Ce,{...c})})]})}function Ce({className:e,unstyled:t,...o}){const r=n.useMemo(()=>t?e:R(x("relative bg-background min-w-full min-h-full border border-input shadow-lg"),e),[t,e]);return s.jsx("div",{className:r,...o})}function ee({size:e=20,label:t="Loading...",...o}){return s.jsxs("div",{role:"status",...o,children:[s.jsxs("svg",{"aria-hidden":"true",className:"text-accent animate-spin fill-primary",width:e,height:e,viewBox:"0 0 100 101",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("path",{d:"M100 50.6a50 50 0 1 1-100 0 50 50 0 0 1 100 0Zm-91 0a41 41 0 1 0 82 0 41 41 0 0 0-82 0Z",fill:"currentColor"}),s.jsx("path",{d:"M94 39a4.2 4.2 0 0 0 3-5.4A50 50 0 0 0 41.7 1.3c-2.4.4-3.9 2.9-3.2 5.3a5 5 0 0 0 5.6 3.5A41 41 0 0 1 88 36 5 5 0 0 0 94 39Z",fill:"currentFill"})]}),s.jsx("span",{className:"sr-only",children:t})]})}function te({type:e,label:t,message:o}){const{icons:r}=Ne();return s.jsxs("div",{className:"flex items-center px-4 py-3 w-80 text-sm bg-background border border-input rounded-lg shadow-md m-2",children:[e?s.jsxs("figure",{className:"mr-2",children:[e==="success"&&r?.success?r.success:null,e==="info"&&r?.info?r.info:null,e==="error"&&r?.error?r.error:null,e==="warn"&&r?.warn?r.warn:null,e==="loading"?s.jsx(ee,{size:20}):null]}):null,s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"font-medium leading-none",children:t}),o?s.jsx("p",{children:o}):null]})]})}function W(){}class Me{notify=W;lastId=0;subscribe=t=>(this.notify=t,()=>{this.notify=W});add=(t,o={})=>{this.lastId+=1;const r=`${this.lastId}`;return this.notify({id:r,type:"add",config:{id:r,label:t,...o}}),r};update=(t,o)=>{this.notify({id:t,type:"update",config:o})};remove=t=>{this.notify({id:t,type:"remove"})};clear=()=>{this.lastId=0}}const L=new Me;function Re({id:e,type:t,index:o,duration:r=5e3,className:l,children:i,inverted:a,timeout:c=250,max:m=3}){const f=n.useRef(!1),[p,y]=n.useState(!1),{context:C,refs:M}=d.useFloating({open:p,onOpenChange:y,nodeId:e}),{isMounted:g,styles:u}=d.useTransitionStyles(C,{duration:c,initial:{opacity:0,transform:`translateY(${a?"":"-"}50%)`}});n.useLayoutEffect(()=>{y(o<=m)},[o,m]),n.useEffect(()=>{f.current!==g&&(g||L.remove(e),f.current=g)},[g,e]),n.useEffect(()=>{if(!r)return;const w=window.setTimeout(()=>y(!1),r);return()=>window.clearTimeout(w)},[r,e]);const j=n.useCallback(()=>{t!=="loading"&&y(!1)},[t]),h=n.useMemo(()=>x("relative flex w-fit transition-transform ease-in-out cursor-pointer",l),[l]);return g?s.jsx("li",{role:"log",tabIndex:-1,ref:M.setFloating,className:h,style:u,onClick:j,children:i}):null}const ne=n.createContext({});function Ne(){return n.useContext(ne)}function ke({className:e,margin:t=16,position:o="top-left",max:r,ListItem:l=te,icons:i}){const a=n.useMemo(()=>{const u={position:"fixed"};return o.indexOf("top")>-1?u.top=t:o.indexOf("bottom")>-1&&(u.bottom=t),o.indexOf("left")>-1?(u.left=t,u.alignItems="flex-start"):o.indexOf("right")>-1?(u.right=t,u.alignItems="flex-end"):(u.left="50%",u.alignItems="center",u.transform="translateX(-50%)"),u},[t,o]),c=n.useMemo(()=>x("flex flex-col z-40 overflow-hidden",e),[e]),m=n.useMemo(()=>o?.startsWith("bottom")||!1,[o]),f=n.useRef(new Map),[p,y]=n.useState([]),C=n.useState(0)[1];q(()=>L.subscribe(u=>{n.startTransition(()=>{if(u.type==="add")f.current.set(u.id,u.config),y(j=>[...j,u.id]);else if(u.type==="remove"){if(!f.current.delete(u.id))return;y(h=>{const w=new Set(h);return w.has(u.id)?(w.delete(u.id),Array.from(w)):h})}else if(u.type==="update"){const j=f.current.get(u.id);if(!j)return;f.current.set(u.id,{...j,...u.config}),C(h=>h+1)}})}),[]);const M=n.useMemo(()=>({icons:i}),[i]),g=p.length;return s.jsx(E,{children:s.jsx("ol",{className:c,style:a,"aria-live":"polite",children:s.jsx(ne.Provider,{value:M,children:p.map((u,j)=>{const h=f.current.get(u);if(!h)return null;const{className:w,duration:v,...S}=h;return s.jsx(Re,{id:u,index:g-j,className:w,duration:v,inverted:m,max:r,children:n.createElement(l,S)},u)})})})})}function Ie({className:e,...t}){const o=n.useMemo(()=>R("inline-block animate-pulse rounded-md bg-accent",e),[e]);return s.jsx("div",{className:o,...t})}function Fe({className:e,...t}){const o=n.useMemo(()=>x("flex items-center justify-center","[&_button]:rounded-none [&_:first-child]:rounded-bl [&_:first-child]:rounded-tl [&_:last-child]:rounded-br [&_:last-child]:rounded-tr","[&_:first-child]:border-r-0 [&_:last-child]:border-l-0",e),[e]);return s.jsx("div",{role:"group",className:o,...t})}function Se({value:e,max:t,className:o,...r}){const l=n.useMemo(()=>e?Math.round(e/t*100):0,[e,t]),i=n.useMemo(()=>R("relative overflow-hidden rounded-full bg-primary",o),[o]);return s.jsx("div",{role:"progressbar",className:i,"aria-valuemax":t,"aria-valuemin":0,...r,children:s.jsx("div",{className:"h-full w-full flex-1 bg-input transition-all origin-right",style:{transform:`translateX(${l>100?100:l}%)`}})})}function Te({className:e,orientation:t="horizontal",...o}){const r=n.useMemo(()=>R(x("border-0 p-0 shrink-0 bg-input",t==="horizontal"?"h-[1px] w-full":"w-[1px] h-full"),e),[e,t]);return s.jsx("hr",{className:r,role:"none",...o})}exports.clsx=x;exports.Accordion=he;exports.Button=ye;exports.ButtonGroup=Fe;exports.Checkbox=fe;exports.Dialog=we;exports.Divider=Te;exports.FormField=ae;exports.FormLabel=Y;exports.Input=z;exports.InputField=ce;exports.Popover=H;exports.Portal=E;exports.Progress=Se;exports.Radio=xe;exports.Select=be;exports.Sheet=je;exports.Skeleton=Ie;exports.Spinner=ee;exports.Switch=K;exports.Textarea=Z;exports.Toast=ke;exports.ToastItem=te;exports.Tooltip=U;exports.merge=R;exports.toast=L;exports.varientButton=Q;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _=require("clsx"),ee=require("tailwind-merge"),n=require("react/jsx-runtime"),o=require("react"),d=require("@floating-ui/react"),te=require("react-dom");function I(...e){return e.length?_(...e):""}function E(e,t){return t?ee.twMerge(e,t):e}function v({as:e,classList:t=[],className:s,...r}){const l=o.useMemo(()=>Array.isArray(t)?t.length?E(I(...t),s):s:E(I(t),s),[t,s]);return o.createElement(e||"div",{className:l,...r})}function W(e){return n.jsx(v,{as:"label",classList:["leading-none peer-disabled:opacity-70"],...e})}function ne({label:e,children:t,required:s,htmlFor:r,error:l,help:i,helpBefore:a,innerClass:c,...f}){const p=o.useMemo(()=>I("font-medium",s?'after:content-["*"] after:text-danger after:text-sm after:pl-0.5':""),[s]);return n.jsxs(v,{classList:"flex flex-col space-y-2",...f,children:[e?n.jsx(W,{className:p,htmlFor:r,children:e}):null,i&&a?n.jsx("p",{className:"text-xs text-muted pb-2",children:i}):null,n.jsx("div",{className:c,children:re(t,!!l)}),i&&!a&&!l?n.jsx("p",{className:"text-xs text-muted",children:i}):null,l?n.jsx("p",{className:"text-xs text-danger",children:l}):null]})}function re(e,t){const s=o.Children.count(e);if(!s)return null;if(s===1)return o.cloneElement(e,{error:t});const r=o.Children.toArray(e);return r[0]=o.cloneElement(r[0],{error:t}),r}function se({error:e,customStyle:t,...s}){return n.jsx(v,{classList:t?void 0:["flex rounded-md border bg-background px-3 py-2 w-full [&_input]:placeholder:text-muted","[&_input]:disabled:opacity-50 [&_input]:focus-visible:outline-none",e?"border-danger hover:border-danger-fore":"border-input"],...s})}function oe({type:e,error:t,customStyle:s,...r}){return n.jsx(v,{as:"input",type:e,classList:s?void 0:["flex rounded-md border bg-background px-3 py-2 w-full placeholder:text-muted","disabled:cursor-not-allowed disabled:opacity-50 focus-visible:outline-none focus-visible:ring-2",t?"border-danger hover:border-danger-fore focus-visible:ring-danger":"border-input not-disabled:hover:border-input-fore focus-visible:ring-ring",e==="file"?"file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground":null],...r})}function ie({error:e,customStyle:t,...s}){return n.jsx(v,{as:"textarea",classList:t?void 0:["flex rounded-md border bg-background px-3 py-2 w-full","disabled:cursor-not-allowed disabled:opacity-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-ring",e?"border-danger hover:border-danger-fore":"border-input not-disabled:hover:border-input-fore"],...s})}function le(){return n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"30",height:"30",viewBox:"0 0 30 30",children:n.jsx("rect",{width:"20",height:"3",y:"13.5",x:"4.5",fill:"currentColor",stroke:"none",rx:"2"})})}function ae({checked:e,indeterminate:t,id:s,name:r,onChange:l,value:i,checkIcon:a,error:c,...f}){const p=()=>{f.disabled||l?.(!e)};return n.jsxs(v,{as:"button",type:"button",role:"checkbox",id:s||r,classList:["inline-flex justify-center items-center border w-4.5 h-4.5 rounded","cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed",{"border-danger hover:border-danger-fore":c,"bg-primary text-inverted disabled:text-text disabled:bg-input disabled:border-input":!c&&e,"border-input not-disabled:hover:border-input-fore":!c&&!e}],onClick:p,"aria-checked":e,...f,children:[e?a:null,t&&!e?n.jsx(le,{}):null,n.jsx("input",{type:"checkbox","aria-hidden":"true",name:r,checked:e,value:i,onChange:p,disabled:f.disabled,style:{position:"absolute",pointerEvents:"none",top:0,left:0,width:1,height:1,opacity:0}})]})}const ue=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",H=ue?o.useLayoutEffect:o.useEffect;function A({children:e,container:t,disabled:s}){const[r,l]=o.useState(null);return H(()=>{if(!t){let i=document.getElementById("visits-style-portals");return i||(i=document.createElement("div"),i.id="visits-style-portals",document.body.appendChild(i)),l(i)}l(t)},[t]),s||!r?null:te.createPortal(e,r)}function $(e){e&&(e.stopPropagation(),e.preventDefault())}const ce={open:150,close:75};function Z({ref:e,position:t,label:s,children:r,disabled:l,offset:i={x:0,y:6},onOpen:a,onClose:c,onManualClose:f,timeout:p=ce,customStyle:x,zIndex:h=9996,role:C,...k}){const[g,u]=o.useState(!1),j=d.useId(),m=o.useRef(a),y=o.useRef(c),{refs:w,floatingStyles:N,context:T}=d.useFloating({nodeId:j,placement:t,middleware:[d.shift(),d.flip({fallbackAxisSideDirection:"end"}),d.offset({mainAxis:i.y,crossAxis:i.x})],open:g,onOpenChange:M=>{M?m.current?.(w.reference.current,w.floating.current):y.current?.(w.reference.current,w.floating.current),u(M)},whileElementsMounted:d.autoUpdate}),{isMounted:D,styles:L}=d.useTransitionStyles(T,{duration:p,initial({side:M}){let S="";return M==="top"?S="translateY(5%) scale(0.95)":M==="bottom"?S="translateY(-5%) scale(0.95)":M==="left"?S="translateX(5%) scale(0.95)":S="translateX(-5%) scale(0.95)",{opacity:0,transform:S}}}),P=o.useCallback(M=>{if($(M),f)return f();u(!1),y.current?.(w.reference.current,w.floating.current)},[f]);o.useEffect(()=>{if(l&&g)return u(!1)},[l,g]),o.useImperativeHandle(e,()=>({open:()=>{u(!0),m.current?.(w.reference.current,w.floating.current)},close:()=>{u(!1),y.current?.(w.reference.current,w.floating.current)}}),[]);const{getFloatingProps:B,getReferenceProps:O}=d.useInteractions([d.useClick(T,{enabled:!l})]);return m.current=a,y.current=c,n.jsxs(n.Fragment,{children:[o.cloneElement(o.Children.only(s),O({ref:w.setReference,tabIndex:0,role:"button","aria-expanded":g,disabled:l,onClick:$})),n.jsx(A,{disabled:l||!D,children:n.jsx(d.FloatingOverlay,{"data-testid":"vs-popover-shadow",onClick:P,style:{zIndex:h},autoFocus:!0,children:n.jsx("div",{role:C||"region",ref:w.setFloating,style:N,children:n.jsx(de,{customStyle:x,styles:L,...B({...k,onClick:$}),children:r})})})})]})}function de({customStyle:e,styles:t,style:s={},...r}){return n.jsx(v,{classList:["z-20 w-auto h-auto outline-none transition-transform ease-in-out",e?null:"border border-accent rounded-md shadow-lg p-1 bg-background"],style:{...t,...s},...r})}function fe({className:e,placeholder:t="",options:s=[],error:r,customStyle:l,disabled:i,value:a,maxHeight:c=408,arrowIcon:f,closeIcon:p,checkIcon:x,onChange:h,onClear:C,renderItem:k,sectionLabelStyle:g,buttonAreaStyle:u,clearLabelText:j,optionStyle:m,...y}){const w=o.useRef(null),[N,T]=o.useState(0),D=o.useMemo(()=>Array.isArray(a),[]),L=o.useCallback(b=>{h?.(b),D||w.current?.close()},[h,D]),P=o.useCallback(b=>Array.isArray(a)?a.indexOf(b)>-1:a===b,[a]),B=o.useMemo(()=>{const b={},F=s.filter(R=>typeof R!="string");for(let R=0,q=F.length;R<q;R+=1){const Y=F[R];b[`${Y.value}`]=Y.label}return b},[s]),O=o.useMemo(()=>{if(!a)return t;if(Array.isArray(a)){if(!a.length)return t;const b=[...a].sort(),F=[];for(let R=0,q=b.length;R<q;R+=1)F[R]=B[`${b[R]}`]||"";return F.filter(Boolean).join(",")||t}return B[`${a}`]||t},[t,a,B]),M=o.useMemo(()=>a==null?!0:Array.isArray(a)?!a.length:!1,[a]),S=o.useCallback((b,F)=>k?typeof b=="string"?k(b,{index:F,selected:!1,onChange:()=>{}}):k(b,{index:F,selected:P(b.value),onChange:()=>L(b.value)}):typeof b=="string"?n.jsx(v,{as:"h5",classList:["font-normal py-1 px-2 text-muted"],className:g,children:b},`optionheader-${F}`):n.jsx(pe,{selected:P(b.value),onChange:L,checkIcon:x,className:m,...b},b.label),[k,L,P,g,m,x]);return n.jsx(Z,{label:n.jsxs(v,{as:"button",type:"button",classList:l?void 0:["flex items-center justify-between rounded-md border bg-background px-3 py-2 w-full overflow-hidden cursor-pointer","disabled:cursor-not-allowed disabled:opacity-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-ring",r?"border-danger hover:border-danger-fore":"border-input not-disabled:hover:border-input-fore"],className:e,disabled:i,...y,children:[n.jsx(v,{as:"span",classList:["overflow-hidden overflow-ellipsis whitespace-nowrap",M?"text-muted":"text-text"],children:O}),n.jsxs(v,{classList:"relative flex items-center space-x-2",className:u,children:[C&&!M?n.jsx("div",{tabIndex:-1,role:"button",className:"size-6 p-1.5 rounded hover:bg-accent cursor-pointer","aria-label":j,onKeyDown:b=>{b.key!=="Enter"&&b.key!=="Space"||C()},onClick:b=>{b.stopPropagation(),C()},children:p}):null,f]})]}),ref:w,onOpen:b=>T(b?.getBoundingClientRect().width||0),disabled:i,children:n.jsx("ul",{className:"overflow-y-auto flex flex-col",role:"listbox",style:{minWidth:N,maxWidth:"calc(100vw - 3rem)",maxHeight:c},children:s.map(S)})})}function pe({className:e,value:t,label:s,selected:r,checkIcon:l,onChange:i}){return n.jsxs(v,{as:"button",type:"button",role:"option",classList:"flex items-center w-full hover:bg-accent rounded p-1 cursor-pointer",className:e,"aria-selected":r,onClick:()=>i?.(t),children:[r&&l?l:n.jsx("div",{className:"w-5 h-1 mr-1"}),s]})}function be({checked:e,className:t,id:s,name:r,onChange:l,value:i,error:a,...c}){const f=()=>{c.disabled||l?.(!e)};return n.jsxs(v,{as:"button",type:"button",role:"radio",id:s||r,classList:["relative inline-flex justify-center items-center border w-4.5 h-4.5 rounded-full","cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed not-disabled:hover:border-input-fore",a?"border-danger":"border-input",e?"[&_i]:bg-primary disabled:[&_i]:bg-text disabled:border-input":""],className:t,onClick:f,"aria-checked":e,...c,children:[n.jsx("i",{className:"block w-2.5 h-2.5 rounded-full transition-transform",style:{transform:e?"":"scale(0.8)",opacity:e?1:0}}),n.jsx("input",{type:"radio","aria-hidden":"true",name:r,checked:e,value:i,onChange:f,disabled:c.disabled,style:{position:"absolute",pointerEvents:"none",top:0,left:0,width:1,height:1,opacity:0}})]})}function ge({checked:e,onChange:t,value:s,id:r,name:l,error:i,ref:a,...c}){const f=()=>{c.disabled||t?.(!e)};return n.jsxs(v,{as:"button",type:"button",role:"switch",id:r||l,classList:["inline-flex shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50","w-11",e?"bg-primary disabled:bg-text":"bg-input"],onClick:f,"aria-checked":e,"aria-invalid":i,...c,children:[n.jsx("span",{className:"pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform",style:{transform:e?"translateX(100%)":""}}),n.jsx("input",{ref:a,type:"checkbox","aria-hidden":"true",name:l,checked:e,value:s,onChange:f,disabled:c.disabled,style:{position:"absolute",pointerEvents:"none",top:0,left:0,width:1,height:1,opacity:0}})]})}function me({header:e,show:t,children:s,timeout:r=300,...l}){const i=o.useRef(null),a=o.useRef(0),c=o.useRef(0),f=o.useRef(!0);return o.useEffect(()=>{c.current=r},[r]),H(()=>{if(!i.current)return;if(i.current.style.overflow="hidden",i.current.style.opacity="1",f.current){f.current=!1,i.current.style.height=t?"auto":"0px",t?window.requestAnimationFrame(()=>{i.current&&(a.current=i.current.offsetHeight)}):(window.requestAnimationFrame(()=>{i.current&&(i.current.style.height="auto",a.current=i.current.offsetHeight,i.current.style.height="0px")}),i.current.style.opacity="0");return}t||(i.current.style.height=`${a.current}px`);const p=[];p[0]=window.requestAnimationFrame(()=>{p[1]=window.requestAnimationFrame(()=>{i.current&&(i.current.style.height=`${t?a.current:0}px`,i.current.style.opacity=t?"1":"0")})});let x;const h=()=>{i.current&&(t?(i.current.style.height="auto",i.current.style.overflow="",i.current.style.opacity="",window.requestAnimationFrame(()=>{i.current&&(a.current=i.current.offsetHeight)})):i.current.style.height="0px")};return c.current===0?h():x=window.setTimeout(h,c.current),()=>{p.forEach(window.cancelAnimationFrame),x&&window.clearTimeout(x)}},[t]),n.jsxs("div",{...l,children:[e,n.jsx("div",{className:"transition-all ease-in-out overflow-hidden",role:"region","aria-hidden":!t,ref:i,style:{transitionDuration:`${r}ms`},children:s})]})}const G=o.forwardRef(({children:e,position:t="bottom",label:s,className:r,timeout:l=150,offset:i={x:0,y:6},clientPoint:a=!1,disabled:c},f)=>{const[p,x]=o.useState(!1),h=d.useId(),{refs:C,floatingStyles:k,context:g}=d.useFloating({nodeId:h,open:p,placement:t,middleware:[d.shift(),d.flip(),d.offset({mainAxis:i.y,crossAxis:i.x})],whileElementsMounted:c?void 0:d.autoUpdate,onOpenChange:x}),{getReferenceProps:u,getFloatingProps:j}=d.useInteractions([d.useHover(g,{enabled:!c}),d.useClientPoint(g,{enabled:a})]),{isMounted:m,styles:y}=d.useTransitionStyles(g,{duration:l,initial:{opacity:0,transform:"scale(0.8)"}});o.useImperativeHandle(f,()=>({floating:C.floating,reference:C.reference,open:()=>x(!0),close:()=>x(!1)})),o.useEffect(()=>{c&&x(!1)},[c]);const w=typeof e=="string"?n.jsx("span",{children:e}):e;return n.jsxs(n.Fragment,{children:[o.cloneElement(o.Children.only(w),{ref:C.setReference,...u()}),n.jsx(A,{disabled:c||!m,children:n.jsx("div",{role:"tooltip",className:"z-9999",ref:C.setFloating,...j({style:k}),children:n.jsx(K,{className:r,style:y,children:s})})})]})});G.displayName="Tooltip";const K=o.forwardRef(({className:e,custom:t,...s},r)=>{const l=o.useMemo(()=>E(I("relative w-auto h-auto outline-none transition-transform ease-in-out whitespace-pre",t?null:"border border-accent rounded shadow-md px-3 py-1 bg-background"),e),[e,t]);return n.jsx("div",{ref:r,className:l,...s})});K.displayName="TooltipContent";function U({variant:e,size:t}){return I("inline-flex items-center justify-center whitespace-nowrap transition-colors rounded-md cursor-pointer","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-auto",{"bg-primary text-inverted hover:bg-primary-fore":!e||e==="primary","bg-info text-inverted hover:bg-info-fore":e==="info","bg-warn text-inverted hover:bg-warn-fore":e==="warn","bg-danger text-inverted hover:bg-danger-fore":e==="danger","hover:bg-accent":e==="ghost","hover:underline":e==="link","border border-input hover:bg-accent":e==="outline"},{"px-2 py-1":!t,"p-1.5":t==="icon"})}function xe({size:e,variant:t,className:s,...r}){const l=o.useMemo(()=>E(U({size:e,variant:t}),s),[e,t,s]);return n.jsx("button",{className:l,type:"button",...r})}const he={open:150,close:75};function ye({open:e,children:t,timeout:s=he,padding:r="0.85rem",verticalAlign:l="center",closeOnOverlay:i,closeOnEsc:a,onExited:c,className:f,onOpenChange:p,size:x,...h}){const C=o.useRef(c),k=o.useRef(!1),g=d.useId(),{refs:u,context:j}=d.useFloating({open:e,onOpenChange:p,nodeId:g}),{getFloatingProps:m}=d.useInteractions([d.useDismiss(j,{enabled:a,escapeKey:a,outsidePress:!1})]),{isMounted:y,styles:w}=d.useTransitionStyles(j,{duration:s,initial:{opacity:0,transform:"scale(0.8)"}});o.useEffect(()=>{k.current!==y&&(k.current=y,!y&&C.current?.())},[y]);const N=o.useCallback(()=>{i&&p?.(!1)},[p,i]);C.current=c;const T=o.useMemo(()=>I("grid bg-backdrop z-40 justify-items-center transition ease-in-out",{"place-items-start items-start":l==="start","place-items-end":l==="end","place-items-center":l==="center"||!l}),[l]);return n.jsx(A,{disabled:!y,children:n.jsx(d.FloatingOverlay,{className:T,"data-testid":"vs-dialog-overlay",onClick:N,style:{padding:r,opacity:w.opacity},lockScroll:!0,children:n.jsx(we,{ref:u.setFloating,className:f,role:"dialog",size:x,onClick:$,...m({...h,style:w}),children:t})})})}function we({size:e,...t}){return n.jsx(v,{classList:[e?"flex flex-col bg-background shadow-lg p-5 rounded":null,{"w-full max-w-dialog-sm":e==="small","w-full max-w-dialog-md":e==="medium","w-full max-w-dialog-lg":e==="large"}],...t})}const ve={open:250,close:150};function je({open:e,timeout:t=ve,onOpenChange:s,position:r="right",overlay:l,onExited:i,onOpen:a,...c}){const f=d.useId(),p=o.useRef(!1),x=o.useRef(a),h=o.useRef(i),{refs:C,context:k}=d.useFloating({open:e,onOpenChange:s,nodeId:f}),{isMounted:g,styles:u}=d.useTransitionStyles(k,{duration:t,initial(){let m="translateX(75%)";return r==="left"?m="translateX(-75%)":r==="top"?m="translateY(-75%)":r==="bottom"&&(m="translateY(75%)"),{opacity:0,transform:m}}});o.useEffect(()=>{if(p.current!==g){if(p.current=g,g){x.current?.();return}h.current?.()}},[g]);const j=o.useMemo(()=>I("fixed transition-transform z-30",{"top-0 right-0 h-full max-h-screen":r==="right","top-0 left-0 h-full max-h-screen":r==="left","top-0 left-0 right-0 w-full max-w-screen":r==="top","bottom-0 left-0 right-0 w-full max-w-screen":r==="bottom"}),[r]);return h.current=i,x.current=a,n.jsxs(A,{disabled:!g,children:[l?n.jsx(d.FloatingOverlay,{className:"bg-backdrop",style:{opacity:u.opacity},onClick:()=>s?.(!1)}):null,n.jsx("div",{ref:C.setFloating,className:j,role:"dialog",style:u,children:n.jsx(Ce,{...c})})]})}function Ce({className:e,customStyle:t,...s}){const r=o.useMemo(()=>t?e:E(I("relative bg-background min-w-full min-h-full border border-input shadow-lg"),e),[t,e]);return n.jsx("div",{className:r,...s})}function J({size:e=20,label:t="Loading...",...s}){return n.jsxs("div",{role:"status",...s,children:[n.jsxs("svg",{"aria-hidden":"true",className:"text-accent animate-spin fill-primary",width:e,height:e,viewBox:"0 0 100 101",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[n.jsx("path",{d:"M100 50.6a50 50 0 1 1-100 0 50 50 0 0 1 100 0Zm-91 0a41 41 0 1 0 82 0 41 41 0 0 0-82 0Z",fill:"currentColor"}),n.jsx("path",{d:"M94 39a4.2 4.2 0 0 0 3-5.4A50 50 0 0 0 41.7 1.3c-2.4.4-3.9 2.9-3.2 5.3a5 5 0 0 0 5.6 3.5A41 41 0 0 1 88 36 5 5 0 0 0 94 39Z",fill:"currentFill"})]}),n.jsx("span",{className:"sr-only",children:t})]})}function Q({type:e,label:t,message:s}){const{icons:r}=Re();return n.jsxs("div",{className:"flex items-center px-4 py-3 w-80 text-sm bg-background border border-input rounded-lg shadow-md m-2",children:[e?n.jsxs("figure",{className:"mr-2",children:[e==="success"&&r?.success?r.success:null,e==="info"&&r?.info?r.info:null,e==="error"&&r?.error?r.error:null,e==="warn"&&r?.warn?r.warn:null,e==="loading"?n.jsx(J,{size:20}):null]}):null,n.jsxs("div",{className:"space-y-2",children:[n.jsx("p",{className:"font-medium leading-none",children:t}),s?n.jsx("p",{children:s}):null]})]})}function z(){}class ke{notify=z;lastId=0;subscribe=t=>(this.notify=t,()=>{this.notify=z});add=(t,s={})=>{this.lastId+=1;const r=`${this.lastId}`;return this.notify({id:r,type:"add",config:{id:r,label:t,...s}}),r};update=(t,s)=>{this.notify({id:t,type:"update",config:s})};remove=t=>{this.notify({id:t,type:"remove"})};clear=()=>{this.lastId=0}}const X=new ke;function Me({id:e,type:t,index:s,duration:r=5e3,className:l,children:i,inverted:a,timeout:c=250,max:f=3}){const p=o.useRef(!1),[x,h]=o.useState(!1),{context:C,refs:k}=d.useFloating({open:x,onOpenChange:h,nodeId:e}),{isMounted:g,styles:u}=d.useTransitionStyles(C,{duration:c,initial:{opacity:0,transform:`translateY(${a?"":"-"}50%)`}});o.useLayoutEffect(()=>{h(s<=f)},[s,f]),o.useEffect(()=>{p.current!==g&&(g||X.remove(e),p.current=g)},[g,e]),o.useEffect(()=>{if(!r)return;const y=window.setTimeout(()=>h(!1),r);return()=>window.clearTimeout(y)},[r,e]);const j=o.useCallback(()=>{t!=="loading"&&h(!1)},[t]),m=o.useMemo(()=>_("relative flex w-fit transition-transform ease-in-out cursor-pointer",l),[l]);return g?n.jsx("li",{role:"log",tabIndex:-1,ref:k.setFloating,className:m,style:u,onClick:j,children:i}):null}const V=o.createContext({});function Re(){return o.useContext(V)}function Fe({className:e,margin:t=16,position:s="top-left",max:r,ListItem:l=Q,icons:i}){const a=o.useMemo(()=>{const u={position:"fixed"};return s.indexOf("top")>-1?u.top=t:s.indexOf("bottom")>-1&&(u.bottom=t),s.indexOf("left")>-1?(u.left=t,u.alignItems="flex-start"):s.indexOf("right")>-1?(u.right=t,u.alignItems="flex-end"):(u.left="50%",u.alignItems="center",u.transform="translateX(-50%)"),u},[t,s]),c=o.useMemo(()=>_("flex flex-col z-40 overflow-hidden",e),[e]),f=o.useMemo(()=>s?.startsWith("bottom")||!1,[s]),p=o.useRef(new Map),[x,h]=o.useState([]),C=o.useState(0)[1];H(()=>X.subscribe(u=>{o.startTransition(()=>{if(u.type==="add")p.current.set(u.id,u.config),h(j=>[...j,u.id]);else if(u.type==="remove"){if(!p.current.delete(u.id))return;h(m=>{const y=new Set(m);return y.has(u.id)?(y.delete(u.id),Array.from(y)):m})}else if(u.type==="update"){const j=p.current.get(u.id);if(!j)return;p.current.set(u.id,{...j,...u.config}),C(m=>m+1)}})}),[]);const k=o.useMemo(()=>({icons:i}),[i]),g=x.length;return n.jsx(A,{children:n.jsx("ol",{className:c,style:a,"aria-live":"polite",children:n.jsx(V.Provider,{value:k,children:x.map((u,j)=>{const m=p.current.get(u);if(!m)return null;const{className:y,duration:w,...N}=m;return n.jsx(Me,{id:u,index:g-j,className:y,duration:w,inverted:f,max:r,children:o.createElement(l,N)},u)})})})})}function Ie(e){return n.jsx(v,{classList:"inline-block animate-pulse rounded-md bg-accent",...e})}function Ne(e){return n.jsx(v,{role:"group",classList:["flex items-center justify-center","[&_button]:rounded-none **:first:rounded-bl **:first:rounded-tl **:last:rounded-br **:last:rounded-tr","**:first:border-r-0 **:last:border-l-0"],...e})}function Se({value:e,max:t,...s}){const r=o.useMemo(()=>e?Math.min(100,Math.round(e/t*100)):0,[e,t]);return n.jsx(v,{role:"progressbar",classList:"relative overflow-hidden rounded-full bg-primary","aria-valuemax":t,"aria-valuemin":0,...s,children:n.jsx(v,{className:"h-full w-full flex-1 bg-input transition-all origin-right",style:{transform:`translateX(${r}%)`}})})}function Te({orientation:e="horizontal",...t}){return n.jsx(v,{as:"hr",role:"none",classList:["border-0 p-0 shrink-0 bg-input",e==="horizontal"?"h-px w-full":"w-px h-full"],...t})}exports.Accordion=me;exports.Base=v;exports.Button=xe;exports.ButtonGroup=Ne;exports.Checkbox=ae;exports.Dialog=ye;exports.Divider=Te;exports.FormField=ne;exports.FormLabel=W;exports.Input=oe;exports.InputField=se;exports.Popover=Z;exports.Portal=A;exports.Progress=Se;exports.Radio=be;exports.Select=fe;exports.Sheet=je;exports.Skeleton=Ie;exports.Spinner=J;exports.Switch=ge;exports.Textarea=ie;exports.Toast=Fe;exports.ToastItem=Q;exports.Tooltip=G;exports.cn=I;exports.merge=E;exports.toast=X;exports.varientButton=U;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import { ButtonHTMLAttributes } from 'react';
2
- import { default as clsx } from 'clsx';
2
+ import { ClassValue as ClassValue_2 } from 'clsx';
3
+ import { ClassValue as ClassValue_3 } from 'utils/merge';
4
+ import { DOMElement } from 'react';
3
5
  import { ForwardRefExoticComponent } from 'react';
4
6
  import { FunctionComponent } from 'react';
5
7
  import { HTMLAttributes } from 'react';
@@ -10,6 +12,7 @@ import { Placement } from '@floating-ui/core';
10
12
  import { ReactElement } from 'react';
11
13
  import { ReactNode } from 'react';
12
14
  import { ReactPortal } from 'react';
15
+ import { Ref } from 'react';
13
16
  import { RefAttributes } from 'react';
14
17
  import { ReferenceElement } from '@floating-ui/core';
15
18
  import { ReferenceType } from '@floating-ui/react';
@@ -34,15 +37,25 @@ export declare interface AccordionProps extends HTMLAttributes<HTMLDivElement> {
34
37
  timeout?: number;
35
38
  }
36
39
 
40
+ export declare function Base<T extends HTMLAttributes<HTMLElement>>({ as, classList, className, ...props }: T & BaseProps): DOMElement< {
41
+ className: string | undefined;
42
+ } & Omit<T & BaseProps, "as" | "classList" | "className">, Element>;
43
+
44
+ declare interface BaseProps {
45
+ as?: string;
46
+ classList?: ClassValue_3 | ClassValue_3[];
47
+ }
48
+
37
49
  export declare function Button({ size, variant, className, ...rest }: ButtonProps): JSX.Element;
38
50
 
39
- export declare function ButtonGroup({ className, ...rest }: HTMLAttributes<HTMLDivElement>): JSX.Element;
51
+ export declare function ButtonGroup(props: HTMLAttributes<HTMLDivElement>): JSX.Element;
40
52
 
41
53
  export declare type ButtonProps = InnerButtonProps & ButtonHTMLAttributes<HTMLButtonElement>;
42
54
 
43
- export declare function Checkbox({ checked, indeterminate, className, id, name, onChange, value, checkIcon, ...rest }: CheckboxProps): JSX.Element;
55
+ export declare function Checkbox({ checked, indeterminate, id, name, onChange, value, checkIcon, error, ...rest }: CheckboxProps): JSX.Element;
44
56
 
45
57
  export declare interface CheckboxProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'onClick' | 'onChange' | 'type' | 'role'> {
58
+ error?: boolean;
46
59
  children?: ReactNode;
47
60
  checked?: boolean;
48
61
  indeterminate?: boolean;
@@ -53,7 +66,9 @@ export declare interface CheckboxProps extends Omit<ButtonHTMLAttributes<HTMLBut
53
66
  onChange?: (checked: boolean) => void;
54
67
  }
55
68
 
56
- export { clsx }
69
+ export declare type ClassValue = ClassValue_2;
70
+
71
+ export declare function cn(...args: ClassValue_2[]): string;
57
72
 
58
73
  export declare function Dialog({ open, children, timeout, padding, verticalAlign, closeOnOverlay, closeOnEsc, onExited, className, onOpenChange, size, ...rest }: DialogProps): JSX.Element;
59
74
 
@@ -95,14 +110,14 @@ export declare interface DialogProps extends HTMLAttributes<HTMLDivElement> {
95
110
  verticalAlign?: 'start' | 'center' | 'end';
96
111
  }
97
112
 
98
- export declare function Divider({ className, orientation, ...props }: DividerProps): JSX.Element;
113
+ export declare function Divider({ orientation, ...props }: DividerProps): JSX.Element;
99
114
 
100
115
  export declare interface DividerProps extends HTMLAttributes<HTMLElement> {
101
116
  /** @default 'horizontal' */
102
117
  orientation?: 'horizontal' | 'vertical';
103
118
  }
104
119
 
105
- export declare function FormField({ label, children, required, htmlFor, error, help, helpBefore, className, innerClass, ...rest }: FormFieldProps): JSX.Element;
120
+ export declare function FormField({ label, children, required, htmlFor, error, help, helpBefore, innerClass, ...rest }: FormFieldProps): JSX.Element;
106
121
 
107
122
  export declare interface FormFieldProps extends HTMLAttributes<HTMLDivElement> {
108
123
  label?: string;
@@ -119,27 +134,27 @@ export declare interface FormFieldProps extends HTMLAttributes<HTMLDivElement> {
119
134
  required?: boolean;
120
135
  }
121
136
 
122
- export declare function FormLabel({ className, ...rest }: LabelHTMLAttributes<HTMLLabelElement>): JSX.Element;
137
+ export declare function FormLabel(props: LabelHTMLAttributes<HTMLLabelElement>): JSX.Element;
123
138
 
124
139
  declare interface InnerButtonProps {
125
140
  variant?: 'primary' | 'info' | 'warn' | 'link' | 'outline' | 'ghost' | 'danger';
126
141
  size?: 'icon' | 'none';
127
142
  }
128
143
 
129
- export declare const Input: ForwardRefExoticComponent<InputProps & RefAttributes<HTMLInputElement>>;
144
+ export declare function Input({ type, error, customStyle, ...rest }: InputProps): JSX.Element;
130
145
 
131
- export declare function InputField({ error, unstyled, className, ...rest }: InputFieldProps): JSX.Element;
146
+ export declare function InputField({ error, customStyle, ...rest }: InputFieldProps): JSX.Element;
132
147
 
133
148
  export declare interface InputFieldProps extends HTMLAttributes<HTMLInputElement> {
134
149
  error?: boolean;
135
150
  /** 基本スタイルを全部外し、完全にclassNameの定義によせます */
136
- unstyled?: boolean;
151
+ customStyle?: boolean;
137
152
  }
138
153
 
139
154
  export declare interface InputProps extends InputHTMLAttributes<HTMLInputElement> {
140
155
  error?: boolean;
141
156
  /** 基本スタイルを全部外し、完全にclassNameの定義によせます */
142
- unstyled?: boolean;
157
+ customStyle?: boolean;
143
158
  }
144
159
 
145
160
  export declare function merge(a: string, b?: string): string;
@@ -155,9 +170,10 @@ declare type OptionType<T> = {
155
170
  label: string;
156
171
  } | string;
157
172
 
158
- export declare const Popover: ForwardRefExoticComponent<PopoverProps & RefAttributes<PopoverRef>>;
173
+ export declare function Popover({ ref, position, label, children, disabled, offset, onOpen, onClose, onManualClose, timeout, customStyle, zIndex, role, ...rest }: PopoverProps): JSX.Element;
159
174
 
160
175
  export declare interface PopoverProps extends HTMLAttributes<HTMLDivElement> {
176
+ ref?: Ref<PopoverRef>;
161
177
  /** ボタンの内容 */
162
178
  label: ReactElement;
163
179
  /** 内容のリスト */
@@ -197,7 +213,7 @@ export declare interface PopoverProps extends HTMLAttributes<HTMLDivElement> {
197
213
  */
198
214
  zIndex?: number;
199
215
  /** デフォルトスタイルを外し、cssクラスを適用します */
200
- unstyled?: boolean;
216
+ customStyle?: boolean;
201
217
  }
202
218
 
203
219
  export declare interface PopoverRef {
@@ -213,7 +229,7 @@ export declare interface PortalProps {
213
229
  disabled?: boolean;
214
230
  }
215
231
 
216
- export declare function Progress({ value, max, className, ...rest }: ProgressProps): JSX.Element;
232
+ export declare function Progress({ value, max, ...rest }: ProgressProps): JSX.Element;
217
233
 
218
234
  export declare interface ProgressProps extends HTMLAttributes<HTMLDivElement> {
219
235
  /** 現状の進捗 */
@@ -225,6 +241,8 @@ export declare interface ProgressProps extends HTMLAttributes<HTMLDivElement> {
225
241
  max: number;
226
242
  }
227
243
 
244
+ declare type Props = HTMLAttributes<HTMLDivElement>;
245
+
228
246
  declare type PublishArgs = ({
229
247
  id: string;
230
248
  type: 'add';
@@ -238,9 +256,10 @@ declare type PublishArgs = ({
238
256
  config: Partial<ToastConfig>;
239
257
  });
240
258
 
241
- export declare function Radio({ checked, className, id, name, onChange, value, ...rest }: RadioProps): JSX.Element;
259
+ export declare function Radio({ checked, className, id, name, onChange, value, error, ...rest }: RadioProps): JSX.Element;
242
260
 
243
261
  export declare interface RadioProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'onClick' | 'onChange' | 'type' | 'role'> {
262
+ error?: boolean;
244
263
  children?: ReactNode;
245
264
  checked?: boolean;
246
265
  /** idが未指定の場合、nameが代わりに使われます */
@@ -248,7 +267,7 @@ export declare interface RadioProps extends Omit<ButtonHTMLAttributes<HTMLButton
248
267
  onChange?: (checked: boolean) => void;
249
268
  }
250
269
 
251
- export declare function Select<T = unknown>({ className, placeholder, options, error, unstyled, disabled, value, maxHeight, arrowIcon, closeIcon, checkIcon, onChange, onClear, renderItem, sectionLabelStyle, buttonAreaStyle, clearLabelText, optionStyle, ...rest }: SelectProps<T>): JSX.Element;
270
+ export declare function Select<T = unknown>({ className, placeholder, options, error, customStyle, disabled, value, maxHeight, arrowIcon, closeIcon, checkIcon, onChange, onClear, renderItem, sectionLabelStyle, buttonAreaStyle, clearLabelText, optionStyle, ...rest }: SelectProps<T>): JSX.Element;
252
271
 
253
272
  export declare interface SelectProps<T> extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'onChange' | 'onClick' | 'type' | 'value' | 'children'> {
254
273
  /** 配列の値の入力の場合、複数選択モードに切り替えます */
@@ -267,7 +286,7 @@ export declare interface SelectProps<T> extends Omit<ButtonHTMLAttributes<HTMLBu
267
286
  */
268
287
  maxHeight?: number;
269
288
  error?: boolean;
270
- unstyled?: boolean;
289
+ customStyle?: boolean;
271
290
  /** クリアボタン、矢印アイコンの領域のdivのスタイルのカスタム指定 */
272
291
  buttonAreaStyle?: string;
273
292
  /** section(stringのみで区域を区切った場合)を使うときのスタイルのカスタム指定 */
@@ -302,7 +321,7 @@ export declare interface SheetProps extends HTMLAttributes<HTMLDivElement> {
302
321
  * @defaut 'right'
303
322
  */
304
323
  position?: 'left' | 'right' | 'top' | 'bottom';
305
- unstyled?: boolean;
324
+ customStyle?: boolean;
306
325
  }
307
326
 
308
327
  export declare interface SinnerProps extends HTMLAttributes<HTMLDivElement> {
@@ -311,22 +330,25 @@ export declare interface SinnerProps extends HTMLAttributes<HTMLDivElement> {
311
330
  label?: string;
312
331
  }
313
332
 
314
- export declare function Skeleton({ className, ...props }: HTMLAttributes<HTMLDivElement>): JSX.Element;
333
+ export declare function Skeleton(props: Props): JSX.Element;
315
334
 
316
335
  export declare function Spinner({ size, label, ...rest }: SinnerProps): JSX.Element;
317
336
 
318
- export declare const Switch: ForwardRefExoticComponent<SwitchProps & RefAttributes<HTMLInputElement>>;
337
+ export declare function Switch({ checked, onChange, value, id, name, error, ref, ...rest }: SwitchProps): JSX.Element;
319
338
 
320
339
  export declare interface SwitchProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'onClick' | 'onChange' | 'type' | 'role'> {
340
+ ref?: Ref<HTMLInputElement>;
341
+ error?: boolean;
321
342
  checked?: boolean;
322
343
  onChange?: (checked: boolean) => void;
323
344
  }
324
345
 
325
- export declare const Textarea: ForwardRefExoticComponent<TextareaProps & RefAttributes<HTMLTextAreaElement>>;
346
+ export declare function Textarea({ error, customStyle, ...rest }: TextareaProps): JSX.Element;
326
347
 
327
348
  export declare interface TextareaProps extends TextareaHTMLAttributes<HTMLTextAreaElement> {
349
+ ref?: Ref<HTMLTextAreaElement>;
328
350
  error?: boolean;
329
- unstyled?: boolean;
351
+ customStyle?: boolean;
330
352
  }
331
353
 
332
354
  export declare function Toast({ className, margin, position, max, ListItem, icons, }: ToasterProps): JSX.Element;