visits-style 2.2.8 → 2.2.10
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/forms/Select/index.d.ts +7 -8
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +9 -9
- package/package.json +1 -1
|
@@ -3,7 +3,7 @@ import { PopoverRef, Props as PopoverProps } from '../../components/Popover';
|
|
|
3
3
|
type OptionType<T> = {
|
|
4
4
|
value: T;
|
|
5
5
|
label: string;
|
|
6
|
-
}
|
|
6
|
+
};
|
|
7
7
|
interface OptionRenderConfig {
|
|
8
8
|
index: number;
|
|
9
9
|
selected: boolean;
|
|
@@ -13,10 +13,10 @@ export interface Props<T> extends Omit<ButtonHTMLAttributes<HTMLButtonElement>,
|
|
|
13
13
|
ref?: Ref<PopoverRef>;
|
|
14
14
|
/** 配列の値の入力の場合、複数選択モードに切り替えます */
|
|
15
15
|
value: T | T[] | null;
|
|
16
|
-
options: OptionType<T>
|
|
17
|
-
onChange?: (value: T) => void;
|
|
16
|
+
options: Array<OptionType<T> | string>;
|
|
17
|
+
onChange?: (value: T, item: OptionType<T>) => void;
|
|
18
18
|
onClear?: () => void;
|
|
19
|
-
renderItem?: (item: OptionType<T
|
|
19
|
+
renderItem?: (item: OptionType<T> | string, config: OptionRenderConfig) => ReactElement;
|
|
20
20
|
placeholder?: string;
|
|
21
21
|
arrowIcon?: ReactNode;
|
|
22
22
|
closeIcon?: ReactNode;
|
|
@@ -47,11 +47,10 @@ export interface Props<T> extends Omit<ButtonHTMLAttributes<HTMLButtonElement>,
|
|
|
47
47
|
export default function Select<T = unknown>({ ref, className, placeholder, options, error, disabled, value, maxHeight, arrowIcon, closeIcon, checkIcon, onChange, onClear, renderItem, sectionLabelStyle, buttonAreaStyle, clearLabelText, optionStyle, popoverStyle, popoverPosition, labelStyle, ...rest }: Props<T>): import("react").JSX.Element;
|
|
48
48
|
interface SelectItemProps<T> {
|
|
49
49
|
className?: string;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
onChange?: (value: T) => void;
|
|
50
|
+
data: OptionType<T>;
|
|
51
|
+
onChange?: (value: T, data: OptionType<T>) => void;
|
|
53
52
|
checkIcon?: ReactNode;
|
|
54
53
|
selected?: boolean;
|
|
55
54
|
}
|
|
56
|
-
export declare function SelectItem<T>({ className,
|
|
55
|
+
export declare function SelectItem<T>({ className, data, selected, checkIcon, onChange, }: SelectItemProps<T>): import("react").JSX.Element;
|
|
57
56
|
export {};
|
package/dist/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,s)=>(s=n==null?{}:e(i(n)),o(r||!n||!n.__esModule||!a.call(n,`default`)?t(s,`default`,{value:n,enumerable:!0}):s,n));let c=require("clsx");c=s(c,1);let l=require("tailwind-merge"),u=require("react"),d=require("react/jsx-runtime"),f=require("@floating-ui/react"),p=require("react-dom");var m=c.default;function h(e,t){return t?(0,l.twMerge)(e,t):e}function g({as:e,classList:t=[],className:n,override:r,...i}){let a=(0,u.useMemo)(()=>r?n:h(m(t),n),[t,n,r]);return(0,u.createElement)(e||`div`,{className:a,...i})}function _(e,t,n={}){let r=({className:r,...i})=>{let a=(0,u.useMemo)(()=>h(t,r),[r]);return(0,u.createElement)(e,{className:a,...n,...i})};return r.displayName=`Styled${typeof e==`string`?e:`Component`}`,r}function v(e){return(0,d.jsx)(g,{as:`label`,classList:[`leading-none peer-disabled:opacity-70`],...e})}function y({label:e,children:t,required:n,htmlFor:r,error:i,help:a,helpBefore:o,innerClass:s,...c}){let l=(0,u.useMemo)(()=>m(`font-medium`,n?`after:content-["*"] after:text-danger after:text-sm after:pl-0.5`:``),[n]);return(0,d.jsxs)(g,{classList:`flex flex-col space-y-2`,...c,children:[e?(0,d.jsx)(v,{className:l,htmlFor:r,children:e}):null,a&&o?(0,d.jsx)(`p`,{className:`text-xs text-muted pb-2`,children:a}):null,(0,d.jsx)(`div`,{className:s,children:b(t,!!i)}),a&&!o&&!i?(0,d.jsx)(`p`,{className:`text-xs text-muted`,children:a}):null,i?(0,d.jsx)(`p`,{className:`text-xs text-danger`,children:i}):null]})}function b(e,t){let n=u.Children.count(e);if(!n)return null;if(n===1)return(0,u.cloneElement)(e,{error:t});let r=u.Children.toArray(e);return r[0]=(0,u.cloneElement)(r[0],{error:t}),r}function x({error:e,...t}){return(0,d.jsx)(g,{as:`fieldset`,classList:[`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`],...t})}function S({type:e,error:t,...n}){return(0,d.jsx)(g,{as:`input`,type:e,classList:[`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],...n})}function C({error:e,...t}){return(0,d.jsx)(g,{as:`textarea`,classList:[`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`],...t})}function w(){return(0,d.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`30`,height:`30`,viewBox:`0 0 30 30`,children:(0,d.jsx)(`rect`,{width:`20`,height:`3`,y:`13.5`,x:`4.5`,fill:`currentColor`,stroke:`none`,rx:`2`})})}function T({checked:e,indeterminate:t,id:n,name:r,onChange:i,value:a,checkIcon:o,error:s,...c}){let l=()=>{c.disabled||i?.(!e)};return(0,d.jsxs)(g,{as:`button`,type:`button`,role:`checkbox`,id:n||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":s,"bg-primary text-inverted disabled:text-text disabled:bg-input disabled:border-input":!s&&e,"border-input not-disabled:hover:border-input-fore":!s&&!e}],onClick:l,"aria-checked":e,...c,children:[e?o:null,t&&!e?(0,d.jsx)(w,{}):null,(0,d.jsx)(`input`,{type:`checkbox`,"aria-hidden":`true`,name:r,checked:e,value:a,onChange:l,disabled:c.disabled,style:{position:`absolute`,pointerEvents:`none`,top:0,left:0,width:1,height:1,opacity:0}})]})}var E=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0?u.useLayoutEffect:u.useEffect;function D({children:e,container:t,disabled:n}){let[r,i]=(0,u.useState)(null);return E(()=>{if(!t){let e=document.getElementById(`visits-style-portals`);return e||(e=document.createElement(`div`),e.id=`visits-style-portals`,document.body.appendChild(e)),i(e)}i(t)},[t]),n||!r?null:(0,p.createPortal)(e,r)}function O(e){e&&(e.stopPropagation(),e.preventDefault())}var k={open:150,close:75};function A({ref:e,position:t,label:n,children:r,disabled:i,offset:a={x:0,y:6},onOpen:o,onClose:s,onManualClose:c,timeout:l=k,override:p,zIndex:m=9996,role:h,...g}){let[_,v]=(0,u.useState)(!1),y=(0,f.useId)(),b=(0,u.useRef)(o),x=(0,u.useRef)(s),{refs:S,floatingStyles:C,context:w}=(0,f.useFloating)({nodeId:y,placement:t,middleware:[(0,f.shift)(),(0,f.flip)({fallbackAxisSideDirection:`end`}),(0,f.offset)({mainAxis:a.y,crossAxis:a.x})],open:_,onOpenChange:e=>{e?b.current?.(S.reference.current,S.floating.current):x.current?.(S.reference.current,S.floating.current),v(e)},whileElementsMounted:f.autoUpdate}),{isMounted:T,styles:E}=(0,f.useTransitionStyles)(w,{duration:l,initial({side:e}){let t=``;return t=e===`top`?`translateY(5%) scale(0.95)`:e===`bottom`?`translateY(-5%) scale(0.95)`:e===`left`?`translateX(5%) scale(0.95)`:`translateX(-5%) scale(0.95)`,{opacity:0,transform:t}}}),A=(0,u.useCallback)(e=>{if(O(e),c)return c();v(!1),x.current?.(S.reference.current,S.floating.current)},[c]);(0,u.useEffect)(()=>{if(i&&_)return v(!1)},[i,_]),(0,u.useImperativeHandle)(e,()=>({open:()=>{v(!0),b.current?.(S.reference.current,S.floating.current)},close:()=>{v(!1),x.current?.(S.reference.current,S.floating.current)}}),[]);let{getFloatingProps:M,getReferenceProps:N}=(0,f.useInteractions)([(0,f.useClick)(w,{enabled:!i})]);return b.current=o,x.current=s,(0,d.jsxs)(d.Fragment,{children:[(0,u.cloneElement)(u.Children.only(n),N({ref:S.setReference,tabIndex:0,role:`button`,"aria-expanded":_,disabled:i,onClick:O})),(0,d.jsx)(D,{disabled:i||!T,children:(0,d.jsx)(f.FloatingOverlay,{"data-testid":`vs-popover-shadow`,onClick:A,style:{zIndex:m},autoFocus:!0,children:(0,d.jsx)(`div`,{role:h||`region`,ref:S.setFloating,style:C,children:(0,d.jsx)(j,{override:p,styles:E,...M({...g,onClick:O}),children:r})})})})]})}function j({override:e,styles:t,style:n={},...r}){return(0,d.jsx)(g,{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,...n},...r})}function M({ref:e,className:t,placeholder:n=``,options:r=[],error:i,disabled:a,value:o,maxHeight:s=408,arrowIcon:c,closeIcon:l,checkIcon:f,onChange:p,onClear:m,renderItem:h,sectionLabelStyle:_,buttonAreaStyle:v,clearLabelText:y,optionStyle:b,popoverStyle:x,popoverPosition:S,labelStyle:C,...w}){let T=(0,u.useRef)(null),[E,D]=(0,u.useState)(0),O=(0,u.useMemo)(()=>Array.isArray(o),[]),k=(0,u.useCallback)(e=>{p?.(e),O||T.current?.close()},[p,O]),j=(0,u.useCallback)(e=>Array.isArray(o)?o.indexOf(e)>-1:o===e,[o]),M=(0,u.useMemo)(()=>{let e={},t=r.filter(e=>typeof e!=`string`);for(let n=0,r=t.length;n<r;n+=1){let r=t[n];e[`${r.value}`]=r.label}return e},[r]),P=(0,u.useMemo)(()=>{if(!o)return n;if(Array.isArray(o)){if(!o.length)return n;let e=[...o].sort(),t=[];for(let n=0,r=e.length;n<r;n+=1)t[n]=M[`${e[n]}`]||``;return t.filter(Boolean).join(`,`)||n}return M[`${o}`]||n},[n,o,M]),F=(0,u.useMemo)(()=>o==null?!0:Array.isArray(o)?!o.length:!1,[o]),I=(0,u.useCallback)((e,t)=>h?typeof e==`string`?h(e,{index:t,selected:!1,onChange:()=>{}}):h(e,{index:t,selected:j(e.value),onChange:()=>k(e.value)}):typeof e==`string`?(0,d.jsx)(g,{as:`h5`,classList:[`font-normal py-1 px-2 text-muted`],className:_,children:e},`optionheader-${t}`):(0,d.jsx)(N,{selected:j(e.value),onChange:k,checkIcon:f,className:b,...e},e.label),[h,k,j,_,b,f]);return(0,u.useImperativeHandle)(e,()=>T.current,[]),(0,d.jsx)(A,{label:(0,d.jsxs)(g,{as:`button`,type:`button`,classList:[`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`,i?`border-danger hover:border-danger-fore`:`border-input not-disabled:hover:border-input-fore`],className:t,disabled:a,...w,children:[(0,d.jsx)(g,{as:`span`,classList:[`overflow-hidden text-ellipsis whitespace-nowrap`,F?`text-muted`:`text-text`],className:C,children:P}),(0,d.jsxs)(g,{classList:`relative flex items-center space-x-2`,className:v,children:[m&&!F?(0,d.jsx)(`div`,{tabIndex:-1,role:`button`,className:`size-6 p-1.5 rounded hover:bg-accent cursor-pointer`,"aria-label":y,onKeyDown:e=>{(e.key===`Enter`||e.key===`Space`)&&m()},onClick:e=>{e.stopPropagation(),m()},children:l}):null,c]})]}),ref:T,onOpen:e=>D(e?.getBoundingClientRect().width||0),className:x,position:S,disabled:a,children:(0,d.jsx)(`div`,{className:`overflow-y-auto flex flex-col`,role:`listbox`,style:{minWidth:E,maxWidth:`calc(100vw - 3rem)`,maxHeight:s},children:r.map(I)})})}function N({className:e,value:t,label:n,selected:r,checkIcon:i,onChange:a}){return(0,d.jsxs)(g,{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:()=>a?.(t),children:[i===null||r&&i?i:(0,d.jsx)(`div`,{className:`w-5 h-1 mr-1`}),n]})}function P({checked:e,className:t,id:n,name:r,onChange:i,value:a,error:o,...s}){let c=()=>{s.disabled||i?.(!e)};return(0,d.jsxs)(g,{as:`button`,type:`button`,role:`radio`,id:n||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`,o?`border-danger`:`border-input`,e?`[&_i]:bg-primary disabled:[&_i]:bg-text disabled:border-input`:``],className:t,onClick:c,"aria-checked":e,...s,children:[(0,d.jsx)(`i`,{className:`block w-2.5 h-2.5 rounded-full transition-transform`,style:{transform:e?``:`scale(0.8)`,opacity:+!!e}}),(0,d.jsx)(`input`,{type:`radio`,"aria-hidden":`true`,name:r,checked:e,value:a,onChange:c,disabled:s.disabled,style:{position:`absolute`,pointerEvents:`none`,top:0,left:0,width:1,height:1,opacity:0}})]})}function F({checked:e,onChange:t,value:n,id:r,name:i,error:a,ref:o,...s}){let c=()=>{s.disabled||t?.(!e)};return(0,d.jsxs)(g,{as:`button`,type:`button`,role:`switch`,id:r||i,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:c,"aria-checked":e,"aria-invalid":a,...s,children:[(0,d.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%)`:``}}),(0,d.jsx)(`input`,{ref:o,type:`checkbox`,"aria-hidden":`true`,name:i,checked:e,value:n,onChange:c,disabled:s.disabled,style:{position:`absolute`,pointerEvents:`none`,top:0,left:0,width:1,height:1,opacity:0}})]})}function I({header:e,show:t,children:n,timeout:r=300,...i}){let a=(0,u.useRef)(null),o=(0,u.useRef)(0),s=(0,u.useRef)(0),c=(0,u.useRef)(!0);return(0,u.useEffect)(()=>{s.current=r},[r]),E(()=>{if(!a.current)return;if(a.current.style.overflow=`hidden`,a.current.style.opacity=`1`,c.current){c.current=!1,a.current.style.height=t?`auto`:`0px`,t?window.requestAnimationFrame(()=>{a.current&&(o.current=a.current.offsetHeight)}):(window.requestAnimationFrame(()=>{a.current&&(a.current.style.height=`auto`,o.current=a.current.offsetHeight,a.current.style.height=`0px`)}),a.current.style.opacity=`0`);return}t||(a.current.style.height=`${o.current}px`);let e=[];e[0]=window.requestAnimationFrame(()=>{e[1]=window.requestAnimationFrame(()=>{a.current&&(a.current.style.height=`${t?o.current:0}px`,a.current.style.opacity=t?`1`:`0`)})});let n,r=()=>{a.current&&(t?(a.current.style.height=`auto`,a.current.style.overflow=``,a.current.style.opacity=``,window.requestAnimationFrame(()=>{a.current&&(o.current=a.current.offsetHeight)})):a.current.style.height=`0px`)};return s.current===0?r():n=window.setTimeout(r,s.current),()=>{e.forEach(window.cancelAnimationFrame),n&&window.clearTimeout(n)}},[t]),(0,d.jsxs)(`div`,{...i,children:[e,(0,d.jsx)(`div`,{className:`transition-all ease-in-out overflow-hidden`,role:`region`,"aria-hidden":!t,ref:a,style:{transitionDuration:`${r}ms`},children:n})]})}var L=(0,u.forwardRef)(({children:e,position:t=`bottom`,label:n,className:r,timeout:i=150,offset:a={x:0,y:6},clientPoint:o=!1,disabled:s},c)=>{let[l,p]=(0,u.useState)(!1),m=(0,f.useId)(),{refs:h,floatingStyles:g,context:_}=(0,f.useFloating)({nodeId:m,open:l,placement:t,middleware:[(0,f.shift)(),(0,f.flip)(),(0,f.offset)({mainAxis:a.y,crossAxis:a.x})],whileElementsMounted:s?void 0:f.autoUpdate,onOpenChange:p}),{getReferenceProps:v,getFloatingProps:y}=(0,f.useInteractions)([(0,f.useHover)(_,{enabled:!s}),(0,f.useClientPoint)(_,{enabled:o})]),{isMounted:b,styles:x}=(0,f.useTransitionStyles)(_,{duration:i,initial:{opacity:0,transform:`scale(0.8)`}});(0,u.useImperativeHandle)(c,()=>({floating:h.floating,reference:h.reference,open:()=>p(!0),close:()=>p(!1)})),(0,u.useEffect)(()=>{s&&p(!1)},[s]);let S=typeof e==`string`?(0,d.jsx)(`span`,{children:e}):e;return(0,d.jsxs)(d.Fragment,{children:[(0,u.cloneElement)(u.Children.only(S),{ref:h.setReference,...v()}),(0,d.jsx)(D,{disabled:s||!b,children:(0,d.jsx)(`div`,{role:`tooltip`,className:`z-9999`,ref:h.setFloating,...y({style:g}),children:(0,d.jsx)(R,{className:r,style:x,children:n})})})]})});L.displayName=`Tooltip`;var R=(0,u.forwardRef)(({className:e,custom:t,...n},r)=>{let i=(0,u.useMemo)(()=>h(m(`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(0,d.jsx)(`div`,{ref:r,className:i,...n})});R.displayName=`TooltipContent`;function z({variant:e,size:t}){return m(`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!==`icon`,"p-1.5":t===`icon`})}function B({size:e,variant:t,className:n,...r}){let i=(0,u.useMemo)(()=>h(z({size:e,variant:t}),n),[e,t,n]);return(0,d.jsx)(`button`,{className:i,type:`button`,...r})}var V={open:150,close:75};function H({open:e,children:t,timeout:n=V,padding:r=`0.85rem`,verticalAlign:i=`center`,closeOnOverlay:a,closeOnEsc:o,onExited:s,className:c,onOpenChange:l,size:p,...h}){let g=(0,u.useRef)(s),_=(0,u.useRef)(!1),v=(0,f.useId)(),{refs:y,context:b}=(0,f.useFloating)({open:e,onOpenChange:l,nodeId:v}),{getFloatingProps:x}=(0,f.useInteractions)([(0,f.useDismiss)(b,{enabled:o,escapeKey:o,outsidePress:!1})]),{isMounted:S,styles:C}=(0,f.useTransitionStyles)(b,{duration:n,initial:{opacity:0,transform:`scale(0.8)`}});(0,u.useEffect)(()=>{_.current!==S&&(_.current=S,!S&&g.current?.())},[S]);let w=(0,u.useCallback)(()=>{a&&l?.(!1)},[l,a]);g.current=s;let T=(0,u.useMemo)(()=>m(`grid bg-backdrop z-40 justify-items-center transition ease-in-out`,{"place-items-start items-start":i===`start`,"place-items-end":i===`end`,"place-items-center":i===`center`||!i}),[i]);return(0,d.jsx)(D,{disabled:!S,children:(0,d.jsx)(f.FloatingOverlay,{className:T,"data-testid":`vs-dialog-overlay`,onClick:w,style:{padding:r,opacity:C.opacity},lockScroll:!0,children:(0,d.jsx)(U,{ref:y.setFloating,className:c,role:`dialog`,size:p,...x({...h,style:C,onClick:e=>e?.stopPropagation()}),children:t})})})}function U({size:e,...t}){return(0,d.jsx)(g,{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})}function W(e){return(0,d.jsx)(g,{classList:`inline-block animate-pulse rounded-md bg-accent`,...e})}function G(e){return(0,d.jsx)(g,{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 K({label:e=`Loading...`,...t}){return(0,d.jsxs)(g,{as:`svg`,classList:`fill-accent animate-spin text-primary`,"aria-label":e,"aria-hidden":`true`,width:`32`,height:`32`,viewBox:`0 0 100 101`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,...t,children:[(0,d.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:`currentFill`}),(0,d.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:`currentColor`})]})}function q({value:e,max:t,...n}){let r=(0,u.useMemo)(()=>e?Math.min(100,Math.round(e/t*100)):0,[e,t]);return(0,d.jsx)(g,{role:`progressbar`,classList:`relative overflow-hidden rounded-full bg-primary`,"aria-valuemax":t,"aria-valuemin":0,...n,children:(0,d.jsx)(g,{className:`h-full w-full flex-1 bg-input transition-all origin-right`,style:{transform:`translateX(${r}%)`}})})}function J({orientation:e=`horizontal`,...t}){return(0,d.jsx)(g,{as:`hr`,role:`none`,classList:[`border-0 p-0 shrink-0 bg-input`,e===`horizontal`?`h-px w-full`:`w-px h-full`],...t})}var Y={open:250,close:150};function ee({open:e,timeout:t=Y,onOpenChange:n,position:r=`right`,overlay:i,onExited:a,onOpen:o,...s}){let c=(0,f.useId)(),l=(0,u.useRef)(!1),p=(0,u.useRef)(o),m=(0,u.useRef)(a),{refs:h,context:_}=(0,f.useFloating)({open:e,onOpenChange:n,nodeId:c}),{isMounted:v,styles:y}=(0,f.useTransitionStyles)(_,{duration:t,initial(){let e=`translateX(75%)`;return r===`left`?e=`translateX(-75%)`:r===`top`?e=`translateY(-75%)`:r===`bottom`&&(e=`translateY(75%)`),{opacity:0,transform:e}}});return(0,u.useEffect)(()=>{if(l.current!==v){if(l.current=v,v){p.current?.();return}m.current?.()}},[v]),m.current=a,p.current=o,(0,d.jsxs)(D,{disabled:!v,children:[i?(0,d.jsx)(f.FloatingOverlay,{className:i===`transparent`?``:`bg-backdrop`,style:{opacity:y.opacity},onClick:()=>n?.(!1)}):null,(0,d.jsx)(g,{ref:h.setFloating,role:`dialog`,classList:[`fixed transition-transform z-1`,{"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`}],style:y,children:(0,d.jsx)(te,{...s})})]})}function te(e){return(0,d.jsx)(g,{classList:`relative bg-background min-w-full min-h-full border border-input shadow-lg`,...e})}function X({type:e,label:t,message:n}){let{icons:r}=re();return(0,d.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?(0,d.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`?r?.loading:null]}):null,(0,d.jsxs)(`div`,{className:`space-y-2`,children:[(0,d.jsx)(`p`,{className:`font-medium leading-none`,children:t}),n?(0,d.jsx)(`p`,{children:n}):null]})]})}function Z(){}var Q=new class{notify=Z;lastId=0;subscribe=e=>(this.notify=e,()=>{this.notify=Z});add=(e,t={})=>{this.lastId+=1;let n=`${this.lastId}`;return this.notify({id:n,type:`add`,config:{id:n,label:e,...t}}),n};update=(e,t)=>{this.notify({id:e,type:`update`,config:t})};remove=e=>{this.notify({id:e,type:`remove`})};clear=()=>{this.lastId=0}};function ne({id:e,type:t,index:n,duration:r=5e3,className:i,children:a,inverted:o,timeout:s=250,max:l=3}){let p=(0,u.useRef)(!1),[m,h]=(0,u.useState)(!1),{context:g,refs:_}=(0,f.useFloating)({open:m,onOpenChange:h,nodeId:e}),{isMounted:v,styles:y}=(0,f.useTransitionStyles)(g,{duration:s,initial:{opacity:0,transform:`translateY(${o?``:`-`}50%)`}});(0,u.useLayoutEffect)(()=>{h(n<=l)},[n,l]),(0,u.useEffect)(()=>{p.current!==v&&(v||Q.remove(e),p.current=v)},[v,e]),(0,u.useEffect)(()=>{if(!r)return;let e=window.setTimeout(()=>h(!1),r);return()=>window.clearTimeout(e)},[r,e]);let b=(0,u.useCallback)(()=>{t!==`loading`&&h(!1)},[t]),x=(0,u.useMemo)(()=>(0,c.default)(`relative flex w-fit transition-transform ease-in-out cursor-pointer`,i),[i]);return v?(0,d.jsx)(`li`,{role:`log`,tabIndex:-1,ref:_.setFloating,className:x,style:y,onClick:b,children:a}):null}var $=(0,u.createContext)({});function re(){return(0,u.useContext)($)}function ie({className:e,offset:t={},position:n=`top-left`,max:r,ListItem:i=X,icons:a}){let o=(0,u.useMemo)(()=>{let e={position:`fixed`,...t};return Object.keys(t).length||(n.indexOf(`top`)>-1?e.top=`16px`:n.indexOf(`bottom`)>-1&&(e.bottom=`16px`),n.indexOf(`left`)>-1?e.left=`16px`:n.indexOf(`right`)>-1&&(e.right=`16px`)),n.indexOf(`left`)>-1?e.alignItems=`flex-start`:n.indexOf(`right`)>-1?e.alignItems=`flex-end`:(e.left=`50%`,e.alignItems=`center`,e.transform=`translateX(-50%)`),e},[t,n]),s=(0,u.useMemo)(()=>(0,c.default)(`flex flex-col z-40 overflow-hidden`,e),[e]),l=(0,u.useMemo)(()=>n?.startsWith(`bottom`)||!1,[n]),f=(0,u.useRef)(new Map),[p,m]=(0,u.useState)([]),h=(0,u.useState)(0)[1];E(()=>Q.subscribe(e=>{(0,u.startTransition)(()=>{if(e.type===`add`)f.current.set(e.id,e.config),m(t=>[...t,e.id]);else if(e.type===`remove`){if(!f.current.delete(e.id))return;m(t=>{let n=new Set(t);return n.has(e.id)?(n.delete(e.id),Array.from(n)):t})}else if(e.type===`update`){let t=f.current.get(e.id);if(!t)return;f.current.set(e.id,{...t,...e.config}),h(e=>e+1)}})}),[]);let g=(0,u.useMemo)(()=>({icons:a}),[a]),_=p.length;return(0,d.jsx)(D,{children:(0,d.jsx)(`ol`,{className:s,style:o,"aria-live":`polite`,children:(0,d.jsx)($.Provider,{value:g,children:p.map((e,t)=>{let n=f.current.get(e);if(!n)return null;let{className:a,duration:o,...s}=n;return(0,d.jsx)(ne,{id:e,index:_-t,className:a,duration:o,inverted:l,max:r,children:(0,u.createElement)(i,s)},e)})})})})}exports.Accordion=I,exports.Base=g,exports.Button=B,exports.ButtonGroup=G,exports.Checkbox=T,exports.Dialog=H,exports.Divider=J,exports.FormField=y,exports.FormLabel=v,exports.Input=S,exports.InputField=x,exports.Popover=A,exports.Portal=D,exports.Progress=q,exports.Radio=P,exports.Select=M,exports.Sheet=ee,exports.Skeleton=W,exports.Spinner=K,exports.Switch=F,exports.Textarea=C,exports.Toast=ie,exports.ToastItem=X,exports.Tooltip=L,exports.cn=m,exports.element=_,exports.merge=h,exports.toast=Q,exports.varientButton=z;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,s)=>(s=n==null?{}:e(i(n)),o(r||!n||!n.__esModule||!a.call(n,`default`)?t(s,`default`,{value:n,enumerable:!0}):s,n));let c=require("clsx");c=s(c,1);let l=require("tailwind-merge"),u=require("react"),d=require("react/jsx-runtime"),f=require("@floating-ui/react"),p=require("react-dom");var m=c.default;function h(e,t){return t?(0,l.twMerge)(e,t):e}function g({as:e,classList:t=[],className:n,override:r,...i}){let a=(0,u.useMemo)(()=>r?n:h(m(t),n),[t,n,r]);return(0,u.createElement)(e||`div`,{className:a,...i})}function _(e,t,n={}){let r=({className:r,...i})=>{let a=(0,u.useMemo)(()=>h(t,r),[r]);return(0,u.createElement)(e,{className:a,...n,...i})};return r.displayName=`Styled${typeof e==`string`?e:`Component`}`,r}function v(e){return(0,d.jsx)(g,{as:`label`,classList:[`leading-none peer-disabled:opacity-70`],...e})}function y({label:e,children:t,required:n,htmlFor:r,error:i,help:a,helpBefore:o,innerClass:s,...c}){let l=(0,u.useMemo)(()=>m(`font-medium`,n?`after:content-["*"] after:text-danger after:text-sm after:pl-0.5`:``),[n]);return(0,d.jsxs)(g,{classList:`flex flex-col space-y-2`,...c,children:[e?(0,d.jsx)(v,{className:l,htmlFor:r,children:e}):null,a&&o?(0,d.jsx)(`p`,{className:`text-xs text-muted pb-2`,children:a}):null,(0,d.jsx)(`div`,{className:s,children:b(t,!!i)}),a&&!o&&!i?(0,d.jsx)(`p`,{className:`text-xs text-muted`,children:a}):null,i?(0,d.jsx)(`p`,{className:`text-xs text-danger`,children:i}):null]})}function b(e,t){let n=u.Children.count(e);if(!n)return null;if(n===1)return(0,u.cloneElement)(e,{error:t});let r=u.Children.toArray(e);return r[0]=(0,u.cloneElement)(r[0],{error:t}),r}function x({error:e,...t}){return(0,d.jsx)(g,{as:`fieldset`,classList:[`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`],...t})}function S({type:e,error:t,...n}){return(0,d.jsx)(g,{as:`input`,type:e,classList:[`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],...n})}function C({error:e,...t}){return(0,d.jsx)(g,{as:`textarea`,classList:[`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`],...t})}function w(){return(0,d.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`30`,height:`30`,viewBox:`0 0 30 30`,children:(0,d.jsx)(`rect`,{width:`20`,height:`3`,y:`13.5`,x:`4.5`,fill:`currentColor`,stroke:`none`,rx:`2`})})}function T({checked:e,indeterminate:t,id:n,name:r,onChange:i,value:a,checkIcon:o,error:s,...c}){let l=()=>{c.disabled||i?.(!e)};return(0,d.jsxs)(g,{as:`button`,type:`button`,role:`checkbox`,id:n||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":s,"bg-primary text-inverted disabled:text-text disabled:bg-input disabled:border-input":!s&&e,"border-input not-disabled:hover:border-input-fore":!s&&!e}],onClick:l,"aria-checked":e,...c,children:[e?o:null,t&&!e?(0,d.jsx)(w,{}):null,(0,d.jsx)(`input`,{type:`checkbox`,"aria-hidden":`true`,name:r,checked:e,value:a,onChange:l,disabled:c.disabled,style:{position:`absolute`,pointerEvents:`none`,top:0,left:0,width:1,height:1,opacity:0}})]})}var E=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0?u.useLayoutEffect:u.useEffect;function D({children:e,container:t,disabled:n}){let[r,i]=(0,u.useState)(null);return E(()=>{if(!t){let e=document.getElementById(`visits-style-portals`);return e||(e=document.createElement(`div`),e.id=`visits-style-portals`,document.body.appendChild(e)),i(e)}i(t)},[t]),n||!r?null:(0,p.createPortal)(e,r)}function O(e){e&&(e.stopPropagation(),e.preventDefault())}var k={open:150,close:75};function A({ref:e,position:t,label:n,children:r,disabled:i,offset:a={x:0,y:6},onOpen:o,onClose:s,onManualClose:c,timeout:l=k,override:p,zIndex:m=9996,role:h,...g}){let[_,v]=(0,u.useState)(!1),y=(0,f.useId)(),b=(0,u.useRef)(o),x=(0,u.useRef)(s),{refs:S,floatingStyles:C,context:w}=(0,f.useFloating)({nodeId:y,placement:t,middleware:[(0,f.shift)(),(0,f.flip)({fallbackAxisSideDirection:`end`}),(0,f.offset)({mainAxis:a.y,crossAxis:a.x})],open:_,onOpenChange:e=>{e?b.current?.(S.reference.current,S.floating.current):x.current?.(S.reference.current,S.floating.current),v(e)},whileElementsMounted:f.autoUpdate}),{isMounted:T,styles:E}=(0,f.useTransitionStyles)(w,{duration:l,initial({side:e}){let t=``;return t=e===`top`?`translateY(5%) scale(0.95)`:e===`bottom`?`translateY(-5%) scale(0.95)`:e===`left`?`translateX(5%) scale(0.95)`:`translateX(-5%) scale(0.95)`,{opacity:0,transform:t}}}),A=(0,u.useCallback)(e=>{if(O(e),c)return c();v(!1),x.current?.(S.reference.current,S.floating.current)},[c]);(0,u.useEffect)(()=>{if(i&&_)return v(!1)},[i,_]),(0,u.useImperativeHandle)(e,()=>({open:()=>{v(!0),b.current?.(S.reference.current,S.floating.current)},close:()=>{v(!1),x.current?.(S.reference.current,S.floating.current)}}),[]);let{getFloatingProps:M,getReferenceProps:N}=(0,f.useInteractions)([(0,f.useClick)(w,{enabled:!i})]);return b.current=o,x.current=s,(0,d.jsxs)(d.Fragment,{children:[(0,u.cloneElement)(u.Children.only(n),N({ref:S.setReference,tabIndex:0,role:`button`,"aria-expanded":_,disabled:i,onClick:O})),(0,d.jsx)(D,{disabled:i||!T,children:(0,d.jsx)(f.FloatingOverlay,{"data-testid":`vs-popover-shadow`,onClick:A,style:{zIndex:m},autoFocus:!0,children:(0,d.jsx)(`div`,{role:h||`region`,ref:S.setFloating,style:C,children:(0,d.jsx)(j,{override:p,styles:E,...M({...g,onClick:O}),children:r})})})})]})}function j({override:e,styles:t,style:n={},...r}){return(0,d.jsx)(g,{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,...n},...r})}function M({ref:e,className:t,placeholder:n=``,options:r=[],error:i,disabled:a,value:o,maxHeight:s=408,arrowIcon:c,closeIcon:l,checkIcon:f,onChange:p,onClear:m,renderItem:h,sectionLabelStyle:_,buttonAreaStyle:v,clearLabelText:y,optionStyle:b,popoverStyle:x,popoverPosition:S,labelStyle:C,...w}){let T=(0,u.useRef)(null),[E,D]=(0,u.useState)(0),O=(0,u.useMemo)(()=>Array.isArray(o),[]),k=(0,u.useCallback)((e,t)=>{p?.(e,t),O||T.current?.close()},[p,O]),j=(0,u.useCallback)(e=>Array.isArray(o)?o.indexOf(e)>-1:o===e,[o]),M=(0,u.useMemo)(()=>{let e={},t=r.filter(e=>typeof e!=`string`);for(let n=0,r=t.length;n<r;n+=1){let r=t[n];e[`${r.value}`]=r.label}return e},[r]),P=(0,u.useMemo)(()=>{if(!o)return n;if(Array.isArray(o)){if(!o.length)return n;let e=[...o].sort(),t=[];for(let n=0,r=e.length;n<r;n+=1)t[n]=M[`${e[n]}`]||``;return t.filter(Boolean).join(`,`)||n}return M[`${o}`]||n},[n,o,M]),F=(0,u.useMemo)(()=>o==null?!0:Array.isArray(o)?!o.length:!1,[o]),I=(0,u.useCallback)((e,t)=>h?typeof e==`string`?h(e,{index:t,selected:!1,onChange:()=>{}}):h(e,{index:t,selected:j(e.value),onChange:()=>k(e.value,e)}):typeof e==`string`?(0,d.jsx)(g,{as:`h5`,classList:[`font-normal py-1 px-2 text-muted`],className:_,children:e},`optionheader-${t}`):(0,d.jsx)(N,{selected:j(e.value),onChange:k,checkIcon:f,className:b,data:e},e.label),[h,k,j,_,b,f]);return(0,u.useImperativeHandle)(e,()=>T.current,[]),(0,d.jsx)(A,{label:(0,d.jsxs)(g,{as:`button`,type:`button`,classList:[`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`,i?`border-danger hover:border-danger-fore`:`border-input not-disabled:hover:border-input-fore`],className:t,disabled:a,...w,children:[(0,d.jsx)(g,{as:`span`,classList:[`overflow-hidden text-ellipsis whitespace-nowrap`,F?`text-muted`:`text-text`],className:C,children:P}),(0,d.jsxs)(g,{classList:`relative flex items-center space-x-2`,className:v,children:[m&&!F?(0,d.jsx)(`div`,{tabIndex:-1,role:`button`,className:`size-6 p-1.5 rounded hover:bg-accent cursor-pointer`,"aria-label":y,onKeyDown:e=>{(e.key===`Enter`||e.key===`Space`)&&m()},onClick:e=>{e.stopPropagation(),m()},children:l}):null,c]})]}),ref:T,onOpen:e=>D(e?.getBoundingClientRect().width||0),className:x,position:S,disabled:a,children:(0,d.jsx)(`div`,{className:`overflow-y-auto flex flex-col`,role:`listbox`,style:{minWidth:E,maxWidth:`calc(100vw - 3rem)`,maxHeight:s},children:r.map(I)})})}function N({className:e,data:t,selected:n,checkIcon:r,onChange:i}){return(0,d.jsxs)(g,{as:`button`,type:`button`,role:`option`,classList:`flex items-center w-full hover:bg-accent rounded p-1 cursor-pointer`,className:e,"aria-selected":n,onClick:()=>i?.(t.value,t),children:[r===null||n&&r?r:(0,d.jsx)(`div`,{className:`w-5 h-1 mr-1`}),t.label]})}function P({checked:e,className:t,id:n,name:r,onChange:i,value:a,error:o,...s}){let c=()=>{s.disabled||i?.(!e)};return(0,d.jsxs)(g,{as:`button`,type:`button`,role:`radio`,id:n||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`,o?`border-danger`:`border-input`,e?`[&_i]:bg-primary disabled:[&_i]:bg-text disabled:border-input`:``],className:t,onClick:c,"aria-checked":e,...s,children:[(0,d.jsx)(`i`,{className:`block w-2.5 h-2.5 rounded-full transition-transform`,style:{transform:e?``:`scale(0.8)`,opacity:+!!e}}),(0,d.jsx)(`input`,{type:`radio`,"aria-hidden":`true`,name:r,checked:e,value:a,onChange:c,disabled:s.disabled,style:{position:`absolute`,pointerEvents:`none`,top:0,left:0,width:1,height:1,opacity:0}})]})}function F({checked:e,onChange:t,value:n,id:r,name:i,error:a,ref:o,...s}){let c=()=>{s.disabled||t?.(!e)};return(0,d.jsxs)(g,{as:`button`,type:`button`,role:`switch`,id:r||i,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:c,"aria-checked":e,"aria-invalid":a,...s,children:[(0,d.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%)`:``}}),(0,d.jsx)(`input`,{ref:o,type:`checkbox`,"aria-hidden":`true`,name:i,checked:e,value:n,onChange:c,disabled:s.disabled,style:{position:`absolute`,pointerEvents:`none`,top:0,left:0,width:1,height:1,opacity:0}})]})}function I({header:e,show:t,children:n,timeout:r=300,...i}){let a=(0,u.useRef)(null),o=(0,u.useRef)(0),s=(0,u.useRef)(0),c=(0,u.useRef)(!0);return(0,u.useEffect)(()=>{s.current=r},[r]),E(()=>{if(!a.current)return;if(a.current.style.overflow=`hidden`,a.current.style.opacity=`1`,c.current){c.current=!1,a.current.style.height=t?`auto`:`0px`,t?window.requestAnimationFrame(()=>{a.current&&(o.current=a.current.offsetHeight)}):(window.requestAnimationFrame(()=>{a.current&&(a.current.style.height=`auto`,o.current=a.current.offsetHeight,a.current.style.height=`0px`)}),a.current.style.opacity=`0`);return}t||(a.current.style.height=`${o.current}px`);let e=[];e[0]=window.requestAnimationFrame(()=>{e[1]=window.requestAnimationFrame(()=>{a.current&&(a.current.style.height=`${t?o.current:0}px`,a.current.style.opacity=t?`1`:`0`)})});let n,r=()=>{a.current&&(t?(a.current.style.height=`auto`,a.current.style.overflow=``,a.current.style.opacity=``,window.requestAnimationFrame(()=>{a.current&&(o.current=a.current.offsetHeight)})):a.current.style.height=`0px`)};return s.current===0?r():n=window.setTimeout(r,s.current),()=>{e.forEach(window.cancelAnimationFrame),n&&window.clearTimeout(n)}},[t]),(0,d.jsxs)(`div`,{...i,children:[e,(0,d.jsx)(`div`,{className:`transition-all ease-in-out overflow-hidden`,role:`region`,"aria-hidden":!t,ref:a,style:{transitionDuration:`${r}ms`},children:n})]})}var L=(0,u.forwardRef)(({children:e,position:t=`bottom`,label:n,className:r,timeout:i=150,offset:a={x:0,y:6},clientPoint:o=!1,disabled:s},c)=>{let[l,p]=(0,u.useState)(!1),m=(0,f.useId)(),{refs:h,floatingStyles:g,context:_}=(0,f.useFloating)({nodeId:m,open:l,placement:t,middleware:[(0,f.shift)(),(0,f.flip)(),(0,f.offset)({mainAxis:a.y,crossAxis:a.x})],whileElementsMounted:s?void 0:f.autoUpdate,onOpenChange:p}),{getReferenceProps:v,getFloatingProps:y}=(0,f.useInteractions)([(0,f.useHover)(_,{enabled:!s}),(0,f.useClientPoint)(_,{enabled:o})]),{isMounted:b,styles:x}=(0,f.useTransitionStyles)(_,{duration:i,initial:{opacity:0,transform:`scale(0.8)`}});(0,u.useImperativeHandle)(c,()=>({floating:h.floating,reference:h.reference,open:()=>p(!0),close:()=>p(!1)})),(0,u.useEffect)(()=>{s&&p(!1)},[s]);let S=typeof e==`string`?(0,d.jsx)(`span`,{children:e}):e;return(0,d.jsxs)(d.Fragment,{children:[(0,u.cloneElement)(u.Children.only(S),{ref:h.setReference,...v()}),(0,d.jsx)(D,{disabled:s||!b,children:(0,d.jsx)(`div`,{role:`tooltip`,className:`z-9999`,ref:h.setFloating,...y({style:g}),children:(0,d.jsx)(R,{className:r,style:x,children:n})})})]})});L.displayName=`Tooltip`;var R=(0,u.forwardRef)(({className:e,custom:t,...n},r)=>{let i=(0,u.useMemo)(()=>h(m(`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(0,d.jsx)(`div`,{ref:r,className:i,...n})});R.displayName=`TooltipContent`;function z({variant:e,size:t}){return m(`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!==`icon`,"p-1.5":t===`icon`})}function B({size:e,variant:t,className:n,...r}){let i=(0,u.useMemo)(()=>h(z({size:e,variant:t}),n),[e,t,n]);return(0,d.jsx)(`button`,{className:i,type:`button`,...r})}var V={open:150,close:75};function H({open:e,children:t,timeout:n=V,padding:r=`0.85rem`,verticalAlign:i=`center`,closeOnOverlay:a,closeOnEsc:o,onExited:s,className:c,onOpenChange:l,size:p,...h}){let g=(0,u.useRef)(s),_=(0,u.useRef)(!1),v=(0,f.useId)(),{refs:y,context:b}=(0,f.useFloating)({open:e,onOpenChange:l,nodeId:v}),{getFloatingProps:x}=(0,f.useInteractions)([(0,f.useDismiss)(b,{enabled:o,escapeKey:o,outsidePress:!1})]),{isMounted:S,styles:C}=(0,f.useTransitionStyles)(b,{duration:n,initial:{opacity:0,transform:`scale(0.8)`}});(0,u.useEffect)(()=>{_.current!==S&&(_.current=S,!S&&g.current?.())},[S]);let w=(0,u.useCallback)(()=>{a&&l?.(!1)},[l,a]);g.current=s;let T=(0,u.useMemo)(()=>m(`grid bg-backdrop z-40 justify-items-center transition ease-in-out`,{"place-items-start items-start":i===`start`,"place-items-end":i===`end`,"place-items-center":i===`center`||!i}),[i]);return(0,d.jsx)(D,{disabled:!S,children:(0,d.jsx)(f.FloatingOverlay,{className:T,"data-testid":`vs-dialog-overlay`,onClick:w,style:{padding:r,opacity:C.opacity},lockScroll:!0,children:(0,d.jsx)(U,{ref:y.setFloating,className:c,role:`dialog`,size:p,...x({...h,style:C,onClick:e=>e?.stopPropagation()}),children:t})})})}function U({size:e,...t}){return(0,d.jsx)(g,{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})}function W(e){return(0,d.jsx)(g,{classList:`inline-block animate-pulse rounded-md bg-accent`,...e})}function G(e){return(0,d.jsx)(g,{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 K({label:e=`Loading...`,...t}){return(0,d.jsxs)(g,{as:`svg`,classList:`fill-accent animate-spin text-primary`,"aria-label":e,"aria-hidden":`true`,width:`32`,height:`32`,viewBox:`0 0 100 101`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,...t,children:[(0,d.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:`currentFill`}),(0,d.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:`currentColor`})]})}function q({value:e,max:t,...n}){let r=(0,u.useMemo)(()=>e?Math.min(100,Math.round(e/t*100)):0,[e,t]);return(0,d.jsx)(g,{role:`progressbar`,classList:`relative overflow-hidden rounded-full bg-primary`,"aria-valuemax":t,"aria-valuemin":0,...n,children:(0,d.jsx)(g,{className:`h-full w-full flex-1 bg-input transition-all origin-right`,style:{transform:`translateX(${r}%)`}})})}function J({orientation:e=`horizontal`,...t}){return(0,d.jsx)(g,{as:`hr`,role:`none`,classList:[`border-0 p-0 shrink-0 bg-input`,e===`horizontal`?`h-px w-full`:`w-px h-full`],...t})}var Y={open:250,close:150};function ee({open:e,timeout:t=Y,onOpenChange:n,position:r=`right`,overlay:i,onExited:a,onOpen:o,...s}){let c=(0,f.useId)(),l=(0,u.useRef)(!1),p=(0,u.useRef)(o),m=(0,u.useRef)(a),{refs:h,context:_}=(0,f.useFloating)({open:e,onOpenChange:n,nodeId:c}),{isMounted:v,styles:y}=(0,f.useTransitionStyles)(_,{duration:t,initial(){let e=`translateX(75%)`;return r===`left`?e=`translateX(-75%)`:r===`top`?e=`translateY(-75%)`:r===`bottom`&&(e=`translateY(75%)`),{opacity:0,transform:e}}});return(0,u.useEffect)(()=>{if(l.current!==v){if(l.current=v,v){p.current?.();return}m.current?.()}},[v]),m.current=a,p.current=o,(0,d.jsxs)(D,{disabled:!v,children:[i?(0,d.jsx)(f.FloatingOverlay,{className:i===`transparent`?``:`bg-backdrop`,style:{opacity:y.opacity},onClick:()=>n?.(!1)}):null,(0,d.jsx)(g,{ref:h.setFloating,role:`complementary`,classList:[`fixed transition-transform z-1`,{"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`}],style:y,children:(0,d.jsx)(te,{...s})})]})}function te(e){return(0,d.jsx)(g,{classList:`relative bg-background min-w-full min-h-full border border-input shadow-lg`,...e})}function X({type:e,label:t,message:n}){let{icons:r}=re();return(0,d.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?(0,d.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`?r?.loading:null]}):null,(0,d.jsxs)(`div`,{className:`space-y-2`,children:[(0,d.jsx)(`p`,{className:`font-medium leading-none`,children:t}),n?(0,d.jsx)(`p`,{children:n}):null]})]})}function Z(){}var Q=new class{notify=Z;lastId=0;subscribe=e=>(this.notify=e,()=>{this.notify=Z});add=(e,t={})=>{this.lastId+=1;let n=`${this.lastId}`;return this.notify({id:n,type:`add`,config:{id:n,label:e,...t}}),n};update=(e,t)=>{this.notify({id:e,type:`update`,config:t})};remove=e=>{this.notify({id:e,type:`remove`})};clear=()=>{this.lastId=0}};function ne({id:e,type:t,index:n,duration:r=5e3,className:i,children:a,inverted:o,timeout:s=250,max:l=3}){let p=(0,u.useRef)(!1),[m,h]=(0,u.useState)(!1),{context:g,refs:_}=(0,f.useFloating)({open:m,onOpenChange:h,nodeId:e}),{isMounted:v,styles:y}=(0,f.useTransitionStyles)(g,{duration:s,initial:{opacity:0,transform:`translateY(${o?``:`-`}50%)`}});(0,u.useLayoutEffect)(()=>{h(n<=l)},[n,l]),(0,u.useEffect)(()=>{p.current!==v&&(v||Q.remove(e),p.current=v)},[v,e]),(0,u.useEffect)(()=>{if(!r)return;let e=window.setTimeout(()=>h(!1),r);return()=>window.clearTimeout(e)},[r,e]);let b=(0,u.useCallback)(()=>{t!==`loading`&&h(!1)},[t]),x=(0,u.useMemo)(()=>(0,c.default)(`relative flex w-fit transition-transform ease-in-out cursor-pointer`,i),[i]);return v?(0,d.jsx)(`li`,{role:`log`,tabIndex:-1,ref:_.setFloating,className:x,style:y,onClick:b,children:a}):null}var $=(0,u.createContext)({});function re(){return(0,u.useContext)($)}function ie({className:e,offset:t={},position:n=`top-left`,max:r,ListItem:i=X,icons:a}){let o=(0,u.useMemo)(()=>{let e={position:`fixed`,...t};return Object.keys(t).length||(n.indexOf(`top`)>-1?e.top=`16px`:n.indexOf(`bottom`)>-1&&(e.bottom=`16px`),n.indexOf(`left`)>-1?e.left=`16px`:n.indexOf(`right`)>-1&&(e.right=`16px`)),n.indexOf(`left`)>-1?e.alignItems=`flex-start`:n.indexOf(`right`)>-1?e.alignItems=`flex-end`:(e.left=`50%`,e.alignItems=`center`,e.transform=`translateX(-50%)`),e},[t,n]),s=(0,u.useMemo)(()=>(0,c.default)(`flex flex-col z-40 overflow-hidden`,e),[e]),l=(0,u.useMemo)(()=>n?.startsWith(`bottom`)||!1,[n]),f=(0,u.useRef)(new Map),[p,m]=(0,u.useState)([]),h=(0,u.useState)(0)[1];E(()=>Q.subscribe(e=>{(0,u.startTransition)(()=>{if(e.type===`add`)f.current.set(e.id,e.config),m(t=>[...t,e.id]);else if(e.type===`remove`){if(!f.current.delete(e.id))return;m(t=>{let n=new Set(t);return n.has(e.id)?(n.delete(e.id),Array.from(n)):t})}else if(e.type===`update`){let t=f.current.get(e.id);if(!t)return;f.current.set(e.id,{...t,...e.config}),h(e=>e+1)}})}),[]);let g=(0,u.useMemo)(()=>({icons:a}),[a]),_=p.length;return(0,d.jsx)(D,{children:(0,d.jsx)(`ol`,{className:s,style:o,"aria-live":`polite`,children:(0,d.jsx)($.Provider,{value:g,children:p.map((e,t)=>{let n=f.current.get(e);if(!n)return null;let{className:a,duration:o,...s}=n;return(0,d.jsx)(ne,{id:e,index:_-t,className:a,duration:o,inverted:l,max:r,children:(0,u.createElement)(i,s)},e)})})})})}exports.Accordion=I,exports.Base=g,exports.Button=B,exports.ButtonGroup=G,exports.Checkbox=T,exports.Dialog=H,exports.Divider=J,exports.FormField=y,exports.FormLabel=v,exports.Input=S,exports.InputField=x,exports.Popover=A,exports.Portal=D,exports.Progress=q,exports.Radio=P,exports.Select=M,exports.Sheet=ee,exports.Skeleton=W,exports.Spinner=K,exports.Switch=F,exports.Textarea=C,exports.Toast=ie,exports.ToastItem=X,exports.Tooltip=L,exports.cn=m,exports.element=_,exports.merge=h,exports.toast=Q,exports.varientButton=z;
|
package/dist/index.es.js
CHANGED
|
@@ -300,8 +300,8 @@ function ne({ override: e, styles: t, style: n = {}, ...r }) {
|
|
|
300
300
|
//#endregion
|
|
301
301
|
//#region src/forms/Select/index.tsx
|
|
302
302
|
function re({ ref: e, className: t, placeholder: n = "", options: r = [], error: i, disabled: a, value: o, maxHeight: s = 408, arrowIcon: l, closeIcon: u, checkIcon: f, onChange: g, onClear: y, renderItem: b, sectionLabelStyle: x, buttonAreaStyle: S, clearLabelText: C, optionStyle: w, popoverStyle: T, popoverPosition: E, labelStyle: D, ...O }) {
|
|
303
|
-
let k = m(null), [A, j] = h(0), M = p(() => Array.isArray(o), []), N = c((e) => {
|
|
304
|
-
g?.(e), M || k.current?.close();
|
|
303
|
+
let k = m(null), [A, j] = h(0), M = p(() => Array.isArray(o), []), N = c((e, t) => {
|
|
304
|
+
g?.(e, t), M || k.current?.close();
|
|
305
305
|
}, [g, M]), P = c((e) => Array.isArray(o) ? o.indexOf(e) > -1 : o === e, [o]), I = p(() => {
|
|
306
306
|
let e = {}, t = r.filter((e) => typeof e != "string");
|
|
307
307
|
for (let n = 0, r = t.length; n < r; n += 1) {
|
|
@@ -329,7 +329,7 @@ function re({ ref: e, className: t, placeholder: n = "", options: r = [], error:
|
|
|
329
329
|
}) : b(e, {
|
|
330
330
|
index: t,
|
|
331
331
|
selected: P(e.value),
|
|
332
|
-
onChange: () => N(e.value)
|
|
332
|
+
onChange: () => N(e.value, e)
|
|
333
333
|
}) : typeof e == "string" ? /* @__PURE__ */ _(F, {
|
|
334
334
|
as: "h5",
|
|
335
335
|
classList: ["font-normal py-1 px-2 text-muted"],
|
|
@@ -340,7 +340,7 @@ function re({ ref: e, className: t, placeholder: n = "", options: r = [], error:
|
|
|
340
340
|
onChange: N,
|
|
341
341
|
checkIcon: f,
|
|
342
342
|
className: w,
|
|
343
|
-
|
|
343
|
+
data: e
|
|
344
344
|
}, e.label), [
|
|
345
345
|
b,
|
|
346
346
|
N,
|
|
@@ -401,16 +401,16 @@ function re({ ref: e, className: t, placeholder: n = "", options: r = [], error:
|
|
|
401
401
|
})
|
|
402
402
|
});
|
|
403
403
|
}
|
|
404
|
-
function ie({ className: e,
|
|
404
|
+
function ie({ className: e, data: t, selected: n, checkIcon: r, onChange: i }) {
|
|
405
405
|
return /* @__PURE__ */ v(F, {
|
|
406
406
|
as: "button",
|
|
407
407
|
type: "button",
|
|
408
408
|
role: "option",
|
|
409
409
|
classList: "flex items-center w-full hover:bg-accent rounded p-1 cursor-pointer",
|
|
410
410
|
className: e,
|
|
411
|
-
"aria-selected":
|
|
412
|
-
onClick: () =>
|
|
413
|
-
children: [
|
|
411
|
+
"aria-selected": n,
|
|
412
|
+
onClick: () => i?.(t.value, t),
|
|
413
|
+
children: [r === null || n && r ? r : /* @__PURE__ */ _("div", { className: "w-5 h-1 mr-1" }), t.label]
|
|
414
414
|
});
|
|
415
415
|
}
|
|
416
416
|
//#endregion
|
|
@@ -820,7 +820,7 @@ function ve({ open: e, timeout: t = _e, onOpenChange: n, position: r = "right",
|
|
|
820
820
|
onClick: () => n?.(!1)
|
|
821
821
|
}) : null, /* @__PURE__ */ _(F, {
|
|
822
822
|
ref: p.setFloating,
|
|
823
|
-
role: "
|
|
823
|
+
role: "complementary",
|
|
824
824
|
classList: ["fixed transition-transform z-1", {
|
|
825
825
|
"top-0 right-0 h-full max-h-screen": r === "right",
|
|
826
826
|
"top-0 left-0 h-full max-h-screen": r === "left",
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"url": "git+https://github.com/visits-works/visits-style.git"
|
|
6
6
|
},
|
|
7
7
|
"homepage": "https://github.com/visits-works/visits-style",
|
|
8
|
-
"version": "2.2.
|
|
8
|
+
"version": "2.2.10",
|
|
9
9
|
"description": "VISITS Technologiesのreactデザインコンポーネント",
|
|
10
10
|
"type": "module",
|
|
11
11
|
"main": "./dist/index.cjs.js",
|