visits-style 2.1.0 → 2.1.1
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 +1 -1
- package/dist/index.es.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("clsx"),ie=require("tailwind-merge"),s=require("react/jsx-runtime"),n=require("react"),d=require("@floating-ui/react"),le=require("react-dom");function N(e,t){return t?ie.twMerge(e,t):e}function Y({className:e,...t}){const o=n.useMemo(()=>g("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:p,...f}){const m=n.useMemo(()=>g("font-medium",o?'after:content-["*"] after:text-danger after:text-sm after:pl-0.5':""),[o]),x=n.useMemo(()=>N("flex flex-col space-y-2",c),[c]);return s.jsxs("div",{className:x,...f,children:[e?s.jsx(Y,{className:m,htmlFor:r,children:e}):null,i&&a?s.jsx("p",{className:"text-xs text-muted pb-2",children:i}):null,s.jsx("div",{className:p,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:N(g("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:N(g("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:N(g("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,...p}){const f=n.useMemo(()=>N(g("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]),m=()=>{p.disabled||i?.(!e)};return s.jsxs("button",{type:"button",role:"checkbox",id:r||l,className:f,onClick:m,"aria-checked":e,...p,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:m,disabled:p.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:p=me,unstyled:f,zIndex:m=9996,role:x,...h},C)=>{const[y,u]=n.useState(!1),M=d.useId(),j=n.useRef(i),w=n.useRef(a),{refs:v,floatingStyles:S,context:T}=d.useFloating({nodeId:M,placement:e,middleware:[d.shift(),d.flip({fallbackAxisSideDirection:"end"}),d.offset({mainAxis:l.y,crossAxis:l.x})],open:y,onOpenChange:R=>{R?j.current?.(v.reference.current,v.floating.current):w.current?.(v.reference.current,v.floating.current),u(R)},whileElementsMounted:d.autoUpdate}),{isMounted:P,styles:O}=d.useTransitionStyles(T,{duration:p,initial({side:R}){let I="";return R==="top"?I="translateY(5%) scale(0.95)":R==="bottom"?I="translateY(-5%) scale(0.95)":R==="left"?I="translateX(5%) scale(0.95)":I="translateX(-5%) scale(0.95)",{opacity:0,transform:I}}}),A=n.useCallback(R=>{if($(R),c)return c();u(!1),w.current?.(v.reference.current,v.floating.current)},[c]);n.useEffect(()=>{if(r&&y)return u(!1)},[r,y]),n.useImperativeHandle(C,()=>({open:()=>{u(!0),j.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 j.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":y,disabled:r,onClick:$})),s.jsx(E,{disabled:r||!P,children:s.jsx(d.FloatingOverlay,{"data-testid":"vs-popover-shadow",onClick:A,style:{zIndex:m},autoFocus:!0,children:s.jsx("div",{role:x||"region",ref:v.setFloating,style:S,children:s.jsx(G,{unstyled:f,styles:O,...D({...h,onClick:$}),children:o})})})})]})});H.displayName="Popover";const G=n.forwardRef(({className:e,unstyled:t,styles:o,style:r={},...l},i)=>{const a=n.useMemo(()=>g("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:p,closeIcon:f,checkIcon:m,onChange:x,onClear:h,renderItem:C,sectionLabelStyle:y,buttonAreaStyle:u,clearLabelText:M,optionStyle:j,...w}){const v=n.useRef(null),[S,T]=n.useState(0),P=n.useMemo(()=>l?e:N(g("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=>{x?.(b),O||v.current?.close()},[x,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]),R=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=R===t,re=n.useMemo(()=>g("overflow-hidden overflow-ellipsis whitespace-nowrap",I?"text-muted":"text-text"),[I]),oe=n.useCallback((b,F)=>C?typeof b=="string"?C(b,{index:F,selected:!1,onChange:()=>{}}):C(b,{index:F,selected:D(b.value),onChange:()=>A(b.value)}):typeof b=="string"?s.jsx("h5",{className:g("font-normal py-1 px-2 text-muted",y),children:b},`optionheader-${F}`):s.jsx(ge,{selected:D(b.value),onChange:A,checkIcon:m,className:j,...b},b.label),[C,A,D,y,j,m]),se=n.useMemo(()=>g("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:R}),s.jsxs("div",{className:se,children:[h&&!I?s.jsx("div",{tabIndex:-1,role:"button",className:"size-6 p-1.5 rounded hover:bg-accent cursor-pointer","aria-label":M,onKeyDown:b=>{b.key!=="Enter"&&b.key!=="Space"||h()},onClick:b=>{b.stopPropagation(),h()},children:f}):null,p]})]}),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(()=>g("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(()=>g("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]),p=()=>{a.disabled||l?.(!e)};return s.jsxs("button",{type:"button",role:"radio",id:o||r,className:c,onClick:p,"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:p,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 p=n.useMemo(()=>N(g("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(()=>N("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform",e),[e]),m=()=>{a.disabled||o?.(!t)};return s.jsxs("button",{type:"button",role:"switch",id:l||i,className:p,onClick:m,"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:m,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),p=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",p.current){p.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 m;const x=()=>{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?x():m=window.setTimeout(x,c.current),()=>{f.forEach(window.cancelAnimationFrame),m&&window.clearTimeout(m)}},[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},p)=>{const[f,m]=n.useState(!1),x=d.useId(),{refs:h,floatingStyles:C,context:y}=d.useFloating({nodeId:x,open:f,placement:t,middleware:[d.shift(),d.flip(),d.offset({mainAxis:i.y,crossAxis:i.x})],whileElementsMounted:c?void 0:d.autoUpdate,onOpenChange:m}),{getReferenceProps:u,getFloatingProps:M}=d.useInteractions([d.useHover(y,{enabled:!c}),d.useClientPoint(y,{enabled:a})]),{isMounted:j,styles:w}=d.useTransitionStyles(y,{duration:l,initial:{opacity:0,transform:"scale(0.8)"}});n.useImperativeHandle(p,()=>({floating:h.floating,reference:h.reference,open:()=>m(!0),close:()=>m(!1)})),n.useEffect(()=>{c&&m(!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:h.setReference,...u()}),s.jsx(E,{disabled:c||!j,children:s.jsx("div",{role:"tooltip",className:"z-[9999]",ref:h.setFloating,...M({style:C}),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(()=>g("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 g("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(()=>g(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:p,onOpenChange:f,size:m,...x}){const h=n.useRef(c),C=n.useRef(!1),y=d.useId(),{refs:u,context:M}=d.useFloating({open:e,onOpenChange:f,nodeId:y}),{getFloatingProps:j}=d.useInteractions([d.useDismiss(M,{enabled:a,escapeKey:a,outsidePress:!1})]),{isMounted:w,styles:v}=d.useTransitionStyles(M,{duration:o,initial:{opacity:0,transform:"scale(0.8)"}});n.useEffect(()=>{C.current!==w&&(C.current=w,!w&&h.current?.())},[w]);const S=n.useCallback(()=>{i&&f?.(!1)},[f,i]);h.current=c;const T=n.useMemo(()=>g("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(()=>N("transition ease-in-out",p),[p]);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:m,style:v,onClick:$,...j({...x}),children:t})})})}const V=n.forwardRef(({size:e,className:t,...o},r)=>{const l=n.useMemo(()=>g(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,...a}){const c=d.useId(),p=n.useRef(!1),f=n.useRef(i),{refs:m,context:x}=d.useFloating({open:e,onOpenChange:o,nodeId:c}),{isMounted:h,styles:C}=d.useTransitionStyles(x,{duration:t,initial(){let u="translateX(75%)";return r==="left"?u="translateX(-75%)":r==="top"?u="translateY(-75%)":r==="bottom"&&(u="translateY(75%)"),{opacity:0,transform:u}}});n.useEffect(()=>{p.current!==h&&(p.current=h,!h&&f.current?.())},[h]);const y=n.useMemo(()=>g("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 f.current=i,s.jsxs(E,{disabled:!h,children:[l?s.jsx(d.FloatingOverlay,{className:"bg-backdrop",style:{opacity:C.opacity},onClick:()=>o?.(!1)}):null,s.jsx("div",{ref:m.setFloating,className:y,role:"dialog",style:C,children:s.jsx(Ce,{...a})})]})}function Ce({className:e,unstyled:t,...o}){const r=n.useMemo(()=>t?e:N(g("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}=Re();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 Ne({id:e,type:t,index:o,duration:r,className:l,children:i,inverted:a,timeout:c=250,max:p=3}){const f=n.useRef(!1),[m,x]=n.useState(!1),{context:h,refs:C}=d.useFloating({open:m,onOpenChange:x,nodeId:e}),{isMounted:y,styles:u}=d.useTransitionStyles(h,{duration:c,initial:{opacity:0,transform:`translateY(${a?"":"-"}50%)`}});n.useLayoutEffect(()=>{x(o<=p)},[o,p]),n.useEffect(()=>{f.current!==y&&(y||L.remove(e),f.current=y)},[y,e]),n.useEffect(()=>{if(!r)return;const w=window.setTimeout(()=>x(!1),r);return()=>window.clearTimeout(w)},[r,e]);const M=n.useCallback(()=>{t!=="loading"&&x(!1)},[t]),j=n.useMemo(()=>g("relative flex w-fit transition-transform ease-in-out cursor-pointer",l),[l]);return y?s.jsx("li",{role:"log",tabIndex:-1,ref:C.setFloating,className:j,style:u,onClick:M,children:i}):null}const ne=n.createContext({});function Re(){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(()=>g("flex flex-col z-40 overflow-hidden",e),[e]),p=n.useMemo(()=>o?.startsWith("bottom")||!1,[o]),f=n.useRef(new Map),[m,x]=n.useState([]),h=n.useState(0)[1];q(()=>L.subscribe(u=>{n.startTransition(()=>{if(u.type==="add")f.current.set(u.id,u.config),x(M=>[...M,u.id]);else if(u.type==="remove"){if(!f.current.delete(u.id))return;x(j=>{const w=new Set(j);return w.has(u.id)?(w.delete(u.id),Array.from(w)):j})}else if(u.type==="update"){const M=f.current.get(u.id);if(!M)return;f.current.set(u.id,{...M,...u.config}),h(j=>j+1)}})}),[]);const C=n.useMemo(()=>({icons:i}),[i]),y=m.length;return s.jsx(E,{children:s.jsx("ol",{className:c,style:a,"aria-live":"polite",children:s.jsx(ne.Provider,{value:C,children:m.map((u,M)=>{const j=f.current.get(u);if(!j)return null;const{className:w,duration:v,...S}=j;return s.jsx(Ne,{id:u,index:y-M,className:w,duration:v,inverted:p,max:r,children:n.createElement(l,S)},u)})})})})}function Ie({className:e,...t}){const o=n.useMemo(()=>N("inline-block animate-pulse rounded-md bg-accent",e),[e]);return s.jsx("span",{className:o,...t})}function Fe({className:e,...t}){const o=n.useMemo(()=>g("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(()=>N("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(()=>N(g("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=g;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.Placeholder=Ie;exports.Popover=H;exports.Portal=E;exports.Progress=Se;exports.Radio=xe;exports.Select=be;exports.Sheet=je;exports.Spinner=ee;exports.Switch=K;exports.Textarea=Z;exports.Toast=ke;exports.ToastItem=te;exports.Tooltip=U;exports.merge=N;exports.toast=L;exports.varientButton=Q;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("clsx"),ie=require("tailwind-merge"),s=require("react/jsx-runtime"),n=require("react"),d=require("@floating-ui/react"),le=require("react-dom");function N(e,t){return t?ie.twMerge(e,t):e}function Y({className:e,...t}){const o=n.useMemo(()=>g("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:p,...f}){const m=n.useMemo(()=>g("font-medium",o?'after:content-["*"] after:text-danger after:text-sm after:pl-0.5':""),[o]),x=n.useMemo(()=>N("flex flex-col space-y-2",c),[c]);return s.jsxs("div",{className:x,...f,children:[e?s.jsx(Y,{className:m,htmlFor:r,children:e}):null,i&&a?s.jsx("p",{className:"text-xs text-muted pb-2",children:i}):null,s.jsx("div",{className:p,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:N(g("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:N(g("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:N(g("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,...p}){const f=n.useMemo(()=>N(g("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]),m=()=>{p.disabled||i?.(!e)};return s.jsxs("button",{type:"button",role:"checkbox",id:r||l,className:f,onClick:m,"aria-checked":e,...p,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:m,disabled:p.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:p=me,unstyled:f,zIndex:m=9996,role:x,...h},C)=>{const[y,u]=n.useState(!1),M=d.useId(),j=n.useRef(i),w=n.useRef(a),{refs:v,floatingStyles:S,context:T}=d.useFloating({nodeId:M,placement:e,middleware:[d.shift(),d.flip({fallbackAxisSideDirection:"end"}),d.offset({mainAxis:l.y,crossAxis:l.x})],open:y,onOpenChange:R=>{R?j.current?.(v.reference.current,v.floating.current):w.current?.(v.reference.current,v.floating.current),u(R)},whileElementsMounted:d.autoUpdate}),{isMounted:P,styles:O}=d.useTransitionStyles(T,{duration:p,initial({side:R}){let I="";return R==="top"?I="translateY(5%) scale(0.95)":R==="bottom"?I="translateY(-5%) scale(0.95)":R==="left"?I="translateX(5%) scale(0.95)":I="translateX(-5%) scale(0.95)",{opacity:0,transform:I}}}),A=n.useCallback(R=>{if($(R),c)return c();u(!1),w.current?.(v.reference.current,v.floating.current)},[c]);n.useEffect(()=>{if(r&&y)return u(!1)},[r,y]),n.useImperativeHandle(C,()=>({open:()=>{u(!0),j.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 j.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":y,disabled:r,onClick:$})),s.jsx(E,{disabled:r||!P,children:s.jsx(d.FloatingOverlay,{"data-testid":"vs-popover-shadow",onClick:A,style:{zIndex:m},autoFocus:!0,children:s.jsx("div",{role:x||"region",ref:v.setFloating,style:S,children:s.jsx(G,{unstyled:f,styles:O,...D({...h,onClick:$}),children:o})})})})]})});H.displayName="Popover";const G=n.forwardRef(({className:e,unstyled:t,styles:o,style:r={},...l},i)=>{const a=n.useMemo(()=>g("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:p,closeIcon:f,checkIcon:m,onChange:x,onClear:h,renderItem:C,sectionLabelStyle:y,buttonAreaStyle:u,clearLabelText:M,optionStyle:j,...w}){const v=n.useRef(null),[S,T]=n.useState(0),P=n.useMemo(()=>l?e:N(g("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=>{x?.(b),O||v.current?.close()},[x,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]),R=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=R===t,re=n.useMemo(()=>g("overflow-hidden overflow-ellipsis whitespace-nowrap",I?"text-muted":"text-text"),[I]),oe=n.useCallback((b,F)=>C?typeof b=="string"?C(b,{index:F,selected:!1,onChange:()=>{}}):C(b,{index:F,selected:D(b.value),onChange:()=>A(b.value)}):typeof b=="string"?s.jsx("h5",{className:g("font-normal py-1 px-2 text-muted",y),children:b},`optionheader-${F}`):s.jsx(ge,{selected:D(b.value),onChange:A,checkIcon:m,className:j,...b},b.label),[C,A,D,y,j,m]),se=n.useMemo(()=>g("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:R}),s.jsxs("div",{className:se,children:[h&&!I?s.jsx("div",{tabIndex:-1,role:"button",className:"size-6 p-1.5 rounded hover:bg-accent cursor-pointer","aria-label":M,onKeyDown:b=>{b.key!=="Enter"&&b.key!=="Space"||h()},onClick:b=>{b.stopPropagation(),h()},children:f}):null,p]})]}),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(()=>g("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(()=>g("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]),p=()=>{a.disabled||l?.(!e)};return s.jsxs("button",{type:"button",role:"radio",id:o||r,className:c,onClick:p,"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:p,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 p=n.useMemo(()=>N(g("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(()=>N("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform",e),[e]),m=()=>{a.disabled||o?.(!t)};return s.jsxs("button",{type:"button",role:"switch",id:l||i,className:p,onClick:m,"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:m,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),p=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",p.current){p.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 m;const x=()=>{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?x():m=window.setTimeout(x,c.current),()=>{f.forEach(window.cancelAnimationFrame),m&&window.clearTimeout(m)}},[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},p)=>{const[f,m]=n.useState(!1),x=d.useId(),{refs:h,floatingStyles:C,context:y}=d.useFloating({nodeId:x,open:f,placement:t,middleware:[d.shift(),d.flip(),d.offset({mainAxis:i.y,crossAxis:i.x})],whileElementsMounted:c?void 0:d.autoUpdate,onOpenChange:m}),{getReferenceProps:u,getFloatingProps:M}=d.useInteractions([d.useHover(y,{enabled:!c}),d.useClientPoint(y,{enabled:a})]),{isMounted:j,styles:w}=d.useTransitionStyles(y,{duration:l,initial:{opacity:0,transform:"scale(0.8)"}});n.useImperativeHandle(p,()=>({floating:h.floating,reference:h.reference,open:()=>m(!0),close:()=>m(!1)})),n.useEffect(()=>{c&&m(!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:h.setReference,...u()}),s.jsx(E,{disabled:c||!j,children:s.jsx("div",{role:"tooltip",className:"z-[9999]",ref:h.setFloating,...M({style:C}),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(()=>g("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 g("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(()=>g(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:p,onOpenChange:f,size:m,...x}){const h=n.useRef(c),C=n.useRef(!1),y=d.useId(),{refs:u,context:M}=d.useFloating({open:e,onOpenChange:f,nodeId:y}),{getFloatingProps:j}=d.useInteractions([d.useDismiss(M,{enabled:a,escapeKey:a,outsidePress:!1})]),{isMounted:w,styles:v}=d.useTransitionStyles(M,{duration:o,initial:{opacity:0,transform:"scale(0.8)"}});n.useEffect(()=>{C.current!==w&&(C.current=w,!w&&h.current?.())},[w]);const S=n.useCallback(()=>{i&&f?.(!1)},[f,i]);h.current=c;const T=n.useMemo(()=>g("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(()=>N("transition ease-in-out",p),[p]);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:m,style:v,onClick:$,...j({...x}),children:t})})})}const V=n.forwardRef(({size:e,className:t,...o},r)=>{const l=n.useMemo(()=>g(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,...a}){const c=d.useId(),p=n.useRef(!1),f=n.useRef(i),{refs:m,context:x}=d.useFloating({open:e,onOpenChange:o,nodeId:c}),{isMounted:h,styles:C}=d.useTransitionStyles(x,{duration:t,initial(){let u="translateX(75%)";return r==="left"?u="translateX(-75%)":r==="top"?u="translateY(-75%)":r==="bottom"&&(u="translateY(75%)"),{opacity:0,transform:u}}});n.useEffect(()=>{p.current!==h&&(p.current=h,!h&&f.current?.())},[h]);const y=n.useMemo(()=>g("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 f.current=i,s.jsxs(E,{disabled:!h,children:[l?s.jsx(d.FloatingOverlay,{className:"bg-backdrop",style:{opacity:C.opacity},onClick:()=>o?.(!1)}):null,s.jsx("div",{ref:m.setFloating,className:y,role:"dialog",style:C,children:s.jsx(Ce,{...a})})]})}function Ce({className:e,unstyled:t,...o}){const r=n.useMemo(()=>t?e:N(g("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}=Re();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 Ne({id:e,type:t,index:o,duration:r=5e3,className:l,children:i,inverted:a,timeout:c=250,max:p=3}){const f=n.useRef(!1),[m,x]=n.useState(!1),{context:h,refs:C}=d.useFloating({open:m,onOpenChange:x,nodeId:e}),{isMounted:y,styles:u}=d.useTransitionStyles(h,{duration:c,initial:{opacity:0,transform:`translateY(${a?"":"-"}50%)`}});n.useLayoutEffect(()=>{x(o<=p)},[o,p]),n.useEffect(()=>{f.current!==y&&(y||L.remove(e),f.current=y)},[y,e]),n.useEffect(()=>{if(!r)return;const w=window.setTimeout(()=>x(!1),r);return()=>window.clearTimeout(w)},[r,e]);const M=n.useCallback(()=>{t!=="loading"&&x(!1)},[t]),j=n.useMemo(()=>g("relative flex w-fit transition-transform ease-in-out cursor-pointer",l),[l]);return y?s.jsx("li",{role:"log",tabIndex:-1,ref:C.setFloating,className:j,style:u,onClick:M,children:i}):null}const ne=n.createContext({});function Re(){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(()=>g("flex flex-col z-40 overflow-hidden",e),[e]),p=n.useMemo(()=>o?.startsWith("bottom")||!1,[o]),f=n.useRef(new Map),[m,x]=n.useState([]),h=n.useState(0)[1];q(()=>L.subscribe(u=>{n.startTransition(()=>{if(u.type==="add")f.current.set(u.id,u.config),x(M=>[...M,u.id]);else if(u.type==="remove"){if(!f.current.delete(u.id))return;x(j=>{const w=new Set(j);return w.has(u.id)?(w.delete(u.id),Array.from(w)):j})}else if(u.type==="update"){const M=f.current.get(u.id);if(!M)return;f.current.set(u.id,{...M,...u.config}),h(j=>j+1)}})}),[]);const C=n.useMemo(()=>({icons:i}),[i]),y=m.length;return s.jsx(E,{children:s.jsx("ol",{className:c,style:a,"aria-live":"polite",children:s.jsx(ne.Provider,{value:C,children:m.map((u,M)=>{const j=f.current.get(u);if(!j)return null;const{className:w,duration:v,...S}=j;return s.jsx(Ne,{id:u,index:y-M,className:w,duration:v,inverted:p,max:r,children:n.createElement(l,S)},u)})})})})}function Ie({className:e,...t}){const o=n.useMemo(()=>N("inline-block animate-pulse rounded-md bg-accent",e),[e]);return s.jsx("span",{className:o,...t})}function Fe({className:e,...t}){const o=n.useMemo(()=>g("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(()=>N("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(()=>N(g("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=g;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.Placeholder=Ie;exports.Popover=H;exports.Portal=E;exports.Progress=Se;exports.Radio=xe;exports.Select=be;exports.Sheet=je;exports.Spinner=ee;exports.Switch=K;exports.Textarea=Z;exports.Toast=ke;exports.ToastItem=te;exports.Tooltip=U;exports.merge=N;exports.toast=L;exports.varientButton=Q;
|
package/dist/index.es.js
CHANGED
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "visits-style",
|
|
3
3
|
"repository": "https://github.com/visits-works/visits-style",
|
|
4
4
|
"homepage": "https://github.com/visits-works/visits-style",
|
|
5
|
-
"version": "2.1.
|
|
5
|
+
"version": "2.1.1",
|
|
6
6
|
"description": "VISITS Technologiesのreactデザインコンポーネント",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "./dist/index.cjs.js",
|