@radui/ui 0.6.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Accordion.d.ts +1 -1
- package/dist/components/Accordion.js +1 -1
- package/dist/components/AlertDialog.d.ts +44 -1
- package/dist/components/AlertDialog.js +1 -1
- package/dist/components/AspectRatio.js +1 -1
- package/dist/components/Avatar.d.ts +4 -1
- package/dist/components/Avatar.js +1 -1
- package/dist/components/AvatarGroup.d.ts +9 -1
- package/dist/components/AvatarGroup.js +1 -1
- package/dist/components/AvatarPrimitiveFallback-C1siRii4.js +1 -0
- package/dist/components/Badge.d.ts +3 -3
- package/dist/components/Badge.js +1 -1
- package/dist/components/BlockQuote.js +1 -1
- package/dist/components/Breadcrumb.js +1 -1
- package/dist/components/Button.js +1 -1
- package/dist/components/Callout.d.ts +4 -1
- package/dist/components/Callout.js +1 -1
- package/dist/components/Card.d.ts +1 -1
- package/dist/components/Card.js +1 -1
- package/dist/components/Checkbox.d.ts +29 -3
- package/dist/components/Checkbox.js +8 -1
- package/dist/components/CheckboxCards.d.ts +31 -4
- package/dist/components/CheckboxCards.js +1 -1
- package/dist/components/CheckboxGroup.d.ts +29 -2
- package/dist/components/CheckboxGroup.js +1 -1
- package/dist/components/CheckboxGroupPrimitive-DfHQYkep.js +1 -0
- package/dist/components/Code.js +1 -1
- package/dist/components/Collapsible.d.ts +10 -1
- package/dist/components/Collapsible.js +1 -1
- package/dist/components/Combobox.d.ts +1 -1
- package/dist/components/Combobox.js +1 -1
- package/dist/components/ComboboxPrimitive-DQcJ8pzQ.js +1 -0
- package/dist/components/Command.d.ts +6 -1
- package/dist/components/Command.js +1 -1
- package/dist/components/ContextMenu.d.ts +19 -19
- package/dist/components/ContextMenu.js +1 -1
- package/dist/components/DataList.d.ts +10 -4
- package/dist/components/DataList.js +1 -1
- package/dist/components/Dialog.d.ts +6 -1
- package/dist/components/Dialog.js +1 -1
- package/dist/components/Disclosure.d.ts +15 -7
- package/dist/components/Disclosure.js +1 -1
- package/dist/components/Drawer.d.ts +1 -1
- package/dist/components/Drawer.js +1 -1
- package/dist/components/DropdownMenu.d.ts +19 -19
- package/dist/components/DropdownMenu.js +1 -1
- package/dist/components/Em.js +1 -1
- package/dist/components/Fieldset.d.ts +1 -1
- package/dist/components/Fieldset.js +1 -1
- package/dist/components/Heading.js +1 -1
- package/dist/components/HoverCard.d.ts +3 -1
- package/dist/components/HoverCard.js +1 -1
- package/dist/components/Kbd.js +1 -1
- package/dist/components/Link.js +1 -1
- package/dist/components/LiveRegion.js +1 -1
- package/dist/components/MenuPrimitive-D9VMz2TZ.js +1 -0
- package/dist/components/Menubar.d.ts +113 -23
- package/dist/components/Menubar.js +1 -1
- package/dist/components/Minimap.d.ts +16 -12
- package/dist/components/Minimap.js +1 -1
- package/dist/components/NavigationMenu.d.ts +8 -3
- package/dist/components/NavigationMenu.js +1 -1
- package/dist/components/NumberField.d.ts +23 -2
- package/dist/components/NumberField.js +1 -1
- package/dist/components/Popover.d.ts +17 -2
- package/dist/components/Popover.js +1 -1
- package/dist/components/Progress.d.ts +5 -4
- package/dist/components/Progress.js +1 -1
- package/dist/components/Quote.js +1 -1
- package/dist/components/Radio.js +1 -1
- package/dist/components/RadioCards.d.ts +1 -1
- package/dist/components/RadioCards.js +1 -1
- package/dist/components/RadioGroup.d.ts +1 -1
- package/dist/components/RadioGroup.js +1 -1
- package/dist/components/RadioGroupPrimitive-D1PP4y2M.js +1 -0
- package/dist/components/ScrollArea.d.ts +1 -9
- package/dist/components/ScrollArea.js +1 -1
- package/dist/components/Select.d.ts +1 -1
- package/dist/components/Select.js +1 -1
- package/dist/components/Separator.js +1 -1
- package/dist/components/Skeleton.d.ts +12 -6
- package/dist/components/Skeleton.js +1 -1
- package/dist/components/Slider.d.ts +1 -1
- package/dist/components/Slider.js +1 -1
- package/dist/components/Spinner.js +1 -1
- package/dist/components/Splitter.d.ts +7 -1
- package/dist/components/Splitter.js +1 -1
- package/dist/components/Steps.d.ts +25 -10
- package/dist/components/Steps.js +1 -1
- package/dist/components/Strong.js +1 -1
- package/dist/components/Switch.d.ts +23 -1
- package/dist/components/Switch.js +1 -1
- package/dist/components/TabNav.d.ts +34 -9
- package/dist/components/TabNav.js +1 -1
- package/dist/components/Table.d.ts +2 -1
- package/dist/components/Table.js +1 -1
- package/dist/components/Tabs.d.ts +1 -1
- package/dist/components/Tabs.js +1 -1
- package/dist/components/Text.d.ts +2 -2
- package/dist/components/Text.js +1 -1
- package/dist/components/TextArea.d.ts +4 -4
- package/dist/components/TextArea.js +1 -1
- package/dist/components/TextField.d.ts +1 -1
- package/dist/components/TextField.js +1 -1
- package/dist/components/Toast.d.ts +7 -4
- package/dist/components/Toast.js +1 -1
- package/dist/components/Toggle.d.ts +1 -1
- package/dist/components/Toggle.js +1 -1
- package/dist/components/ToggleGroup.d.ts +1 -1
- package/dist/components/ToggleGroup.js +1 -1
- package/dist/components/Toolbar.d.ts +1 -1
- package/dist/components/Toolbar.js +1 -1
- package/dist/components/Tooltip.d.ts +12 -1
- package/dist/components/Tooltip.js +1 -1
- package/dist/components/Tree.d.ts +1 -1
- package/dist/components/Tree.js +1 -1
- package/dist/components/VisuallyHidden.js +1 -1
- package/dist/components/{check-DujVUWP-.js → check-ctUdF4Q3.js} +4 -4
- package/dist/components/{floating-ui.react-Byzse64h.js → floating-ui.react-2kiGB4sW.js} +1 -1
- package/dist/components/index-C7dBo_Ry.js +1 -0
- package/dist/components/index-CBcSLg6O.js +1 -0
- package/dist/components/index-CbNq68zs.js +1 -0
- package/dist/components/index-D8I-rMwz.js +1 -0
- package/dist/components/index-DMX7gpdp.js +1 -0
- package/dist/components/index-FITGoHty.js +1 -0
- package/dist/components/{index-C09ZQH_q.js → index-nYRBURkR.js} +1 -1
- package/dist/components/index-xlB--dex.js +1 -0
- package/dist/components/useComponentClass-C0isGl1z.js +1 -0
- package/dist/themes/baremetal.css +1 -1
- package/dist/themes/default.css +1 -1
- package/package.json +1 -1
- package/dist/components/AvatarPrimitiveFallback-B1u295x6.js +0 -1
- package/dist/components/CheckboxGroupPrimitive-BWGRST9p.js +0 -1
- package/dist/components/ComboboxPrimitive-C2sksm48.js +0 -1
- package/dist/components/MenuPrimitive-COEgTo6S.js +0 -1
- package/dist/components/RadioGroupPrimitive-BWUU-0Qh.js +0 -1
- package/dist/components/clsx-BaVHROc5.js +0 -1
- package/dist/components/index-CD_nZA9X.js +0 -1
- package/dist/components/index-CfC8-kd8.js +0 -1
- package/dist/components/index-Db-tduwt.js +0 -1
- package/dist/components/index-UODM4mVT.js +0 -1
- package/dist/components/index-YhJvxumL.js +0 -1
- package/dist/components/index-m8Mhi26u.js +0 -1
- package/dist/components/useComponentClass-QwNivz0h.js +0 -1
|
@@ -5,13 +5,13 @@ type TextProps = {
|
|
|
5
5
|
customRootClass?: string;
|
|
6
6
|
className?: string;
|
|
7
7
|
as?: string;
|
|
8
|
-
} & ComponentPropsWithoutRef<'p'>;
|
|
8
|
+
} & ComponentPropsWithoutRef<'p'> & Pick<ComponentPropsWithoutRef<'label'>, 'htmlFor'>;
|
|
9
9
|
declare const Text: React.ForwardRefExoticComponent<{
|
|
10
10
|
children: React.ReactNode;
|
|
11
11
|
customRootClass?: string;
|
|
12
12
|
className?: string;
|
|
13
13
|
as?: string;
|
|
14
|
-
} & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, "ref"> & React.RefAttributes<HTMLParagraphElement>>;
|
|
14
|
+
} & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, "ref"> & Pick<Omit<React.DetailedHTMLProps<React.LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, "ref">, "htmlFor"> & React.RefAttributes<HTMLParagraphElement>>;
|
|
15
15
|
|
|
16
16
|
export { Text as default };
|
|
17
17
|
export type { TextProps };
|
package/dist/components/Text.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use client';import
|
|
1
|
+
'use client';import e,{forwardRef as s}from"react";import{u as a,c as t}from"./useComponentClass-C0isGl1z.js";import"./ThemeContext-Sm-iNANd.js";const o="Text",m=["div","span","p","label"],r=s((({children:s,customRootClass:r="",className:l="",as:c="p",...n},p)=>{const i=a(r,o);return m.includes(c)||(c="p"),e.createElement(c,{ref:p,className:t(i,l),...n},s)}));r.displayName=o;export{r as default};
|
|
@@ -20,10 +20,10 @@ declare const TextAreaRoot: React.ForwardRefExoticComponent<Omit<React.DetailedH
|
|
|
20
20
|
type TextAreaInputProps = React.ComponentPropsWithoutRef<'textarea'>;
|
|
21
21
|
declare const TextAreaInput: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement>, "ref"> & React.RefAttributes<HTMLTextAreaElement>>;
|
|
22
22
|
|
|
23
|
-
type
|
|
24
|
-
|
|
23
|
+
type RootOnlyProps = Pick<TextAreaRootProps, 'customRootClass' | 'variant' | 'size' | 'resize' | 'color' | 'radius' | 'className' | 'style'>;
|
|
24
|
+
type TextAreaProps = RootOnlyProps & Omit<TextAreaInputProps, 'className' | 'style' | 'color'> & {
|
|
25
|
+
/** @deprecated Use `readOnly`. */
|
|
25
26
|
readonly?: boolean;
|
|
26
|
-
disabled?: boolean;
|
|
27
27
|
};
|
|
28
28
|
type TextAreaComponent = React.ForwardRefExoticComponent<TextAreaProps & React.RefAttributes<React.ElementRef<'div'>>> & {
|
|
29
29
|
Input: typeof TextAreaInput;
|
|
@@ -31,5 +31,5 @@ type TextAreaComponent = React.ForwardRefExoticComponent<TextAreaProps & React.R
|
|
|
31
31
|
};
|
|
32
32
|
declare const TextArea: TextAreaComponent;
|
|
33
33
|
|
|
34
|
-
export { TextArea as default };
|
|
34
|
+
export { TextAreaInput as Input, TextAreaRoot as Root, TextArea as default };
|
|
35
35
|
export type { TextAreaInputProps, TextAreaProps, TextAreaRootProps };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
'use client';import{jsx as e
|
|
1
|
+
'use client';import{jsx as e}from"react/jsx-runtime";import a from"react";import{u as r,c as s}from"./useComponentClass-C0isGl1z.js";import{c as t,a as o,b as i}from"./index-eAZUMNef.js";import"./ThemeContext-Sm-iNANd.js";const l="TextArea",d=a.forwardRef((({children:a,customRootClass:d="",className:c="",variant:n="",size:m="",resize:u="both",color:f="",radius:p="",...h},v)=>{const x=r(d,l),y=t("textarea",{variant:n,size:m,resize:u,radius:p}),z=i(f),R=o(y,z);return e("div",{ref:v,className:s(x,c),...h,...R,children:a})}));d.displayName=l;const c=a.forwardRef((({children:a,placeholder:r="",value:s,defaultValue:t,...o},i)=>e("textarea",{ref:i,placeholder:r,value:s,defaultValue:t??(void 0===s&&void 0===t&&"string"==typeof a?a:void 0),...o})));c.displayName="TextAreaInput";const n=a.forwardRef((({customRootClass:a="",className:r="",style:t,variant:o,size:i,resize:l,color:n,radius:m,readonly:u=!1,readOnly:f,disabled:p=!1,placeholder:h="",children:v,...x},y)=>{const z={},R={};return Object.entries(x).forEach((([e,a])=>{e.startsWith("data-")?z[e]=a:R[e]=a})),e(d,{ref:y,customRootClass:a,className:s(r),style:t,variant:o,size:i,resize:l,color:n,radius:m,"data-disabled":p?"":void 0,...z,children:e(c,{placeholder:h,disabled:p,readOnly:f??u,...R,children:v})})}));n.displayName="TextArea",n.Input=c,n.Root=d;export{c as Input,d as Root,n as default};
|
|
@@ -37,5 +37,5 @@ type TextFieldComponent = React.ForwardRefExoticComponent<TextFieldProps & React
|
|
|
37
37
|
};
|
|
38
38
|
declare const TextField: TextFieldComponent;
|
|
39
39
|
|
|
40
|
-
export { TextField as default };
|
|
40
|
+
export { TextFieldInput as Input, TextFieldReset as Reset, TextFieldRoot as Root, TextFieldSlot as Slot, TextField as default };
|
|
41
41
|
export type { TextFieldInputProps, TextFieldProps, TextFieldResetProps, TextFieldRootProps, TextFieldSlotProps };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
'use client';import{jsx as e,jsxs as t}from"react/jsx-runtime";import s from"react";import{
|
|
1
|
+
'use client';import{jsx as e,jsxs as t}from"react/jsx-runtime";import s from"react";import{u as a,c as l}from"./useComponentClass-C0isGl1z.js";import{c as o}from"./mergeProps-0RucjqeH.js";import"./ThemeContext-Sm-iNANd.js";const n=s.createContext({rootClass:"",inputRef:{current:null},clearInput:()=>{},hasValue:!1,setHasValue:()=>!1,isLocked:!1,setIsLocked:()=>!1}),r="TextField",u=s.forwardRef((({className:t="",customRootClass:o="",children:u,...c},d)=>{const i=a(o,r),p=s.useRef(null),[f,m]=s.useState(!1),[h,C]=s.useState(!1),x=s.useCallback((()=>{const e=p.current;if(!e)return;const t=Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,"value")?.set;t?.call(e,""),e.dispatchEvent(new Event("input",{bubbles:!0})),m(!1),e.focus()}),[]);return e(n.Provider,{value:{rootClass:i,inputRef:p,clearInput:x,hasValue:f,setHasValue:m,isLocked:h,setIsLocked:C},children:e("div",{ref:d,className:l(i,t),"data-slot":"text-field-root",...c,children:u})})}));u.displayName=r;const c=s.forwardRef((({className:t="",type:a="text",onChange:r,onInput:u,value:c,defaultValue:d,...i},p)=>{const{rootClass:f,inputRef:m,setHasValue:h,setIsLocked:C}=s.useContext(n),x=Boolean(i.disabled||i.readOnly);s.useEffect((()=>{C(x)}),[x,C]),s.useEffect((()=>{void 0===c?void 0!==d&&h(String(d).length>0):h(String(c).length>0)}),[d,h,c]);return e("input",{ref:o(p,m),type:a,className:l(f&&`${f}-input`,t),"data-slot":"text-field-input",value:c,defaultValue:d,onInput:e=>{h(e.currentTarget.value.length>0),u?.(e)},onChange:e=>{h(e.currentTarget.value.length>0),r?.(e)},...i})}));c.displayName="TextFieldInput";const d=s.forwardRef((({children:t,className:a="",side:o,...r},u)=>{const{rootClass:c,inputRef:d}=s.useContext(n);return e("div",{ref:u,role:"presentation",className:l(c&&`${c}-slot`,a),"data-slot":"text-field-slot","data-text-field-slot":o,...r,onMouseDown:e=>{r.onMouseDown?.(e),e.defaultPrevented||(e.preventDefault(),d.current?.focus())},children:t})}));d.displayName="TextFieldSlot";const i=s.forwardRef((({className:t="",type:a="button",onClick:o,children:r,...u},c)=>{const{rootClass:d,clearInput:i,inputRef:p,hasValue:f,isLocked:m}=s.useContext(n);return!f||m?null:e("button",{ref:c,type:a,className:l(d&&`${d}-reset`,t),"data-slot":"text-field-reset",onClick:e=>{o?.(e),e.defaultPrevented||p.current?.disabled||p.current?.readOnly||i()},...u,children:r})}));i.displayName="TextFieldReset";const p=s.forwardRef((({className:s="",customRootClass:a="",inputClassName:o="",startSlot:n,endSlot:r,type:i="text",...p},f)=>t(u,{customRootClass:a,className:l(s),children:[n?e(d,{side:"start",children:n}):null,e(c,{ref:f,type:i,className:l(o),...p}),r?e(d,{side:"end",children:r}):null]})));p.displayName="TextField",p.Root=u,p.Input=c,p.Slot=d,p.Reset=i;export{c as Input,i as Reset,u as Root,d as Slot,p as default};
|
|
@@ -205,9 +205,12 @@ declare const ToastRoot: React$1.FC<ToastRootProps>;
|
|
|
205
205
|
type ToastContentProps = React$1.HTMLAttributes<HTMLDivElement>;
|
|
206
206
|
declare const ToastContent: React$1.ForwardRefExoticComponent<ToastContentProps & React$1.RefAttributes<HTMLDivElement>>;
|
|
207
207
|
|
|
208
|
-
type ToastTitleProps = React$1.HTMLAttributes<
|
|
209
|
-
/**
|
|
210
|
-
|
|
208
|
+
type ToastTitleProps = React$1.HTMLAttributes<HTMLElement>;
|
|
209
|
+
/**
|
|
210
|
+
* Rendered as a plain element, not a heading: toasts are transient live-region
|
|
211
|
+
* announcements, and headings inside them pollute the page outline.
|
|
212
|
+
*/
|
|
213
|
+
declare const ToastTitle: React$1.ForwardRefExoticComponent<ToastTitleProps & React$1.RefAttributes<HTMLElement>>;
|
|
211
214
|
|
|
212
215
|
type ToastDescriptionProps = React$1.HTMLAttributes<HTMLParagraphElement>;
|
|
213
216
|
declare const ToastDescription: React$1.ForwardRefExoticComponent<ToastDescriptionProps & React$1.RefAttributes<HTMLParagraphElement>>;
|
|
@@ -318,5 +321,5 @@ interface ToastNamespace {
|
|
|
318
321
|
}
|
|
319
322
|
declare const Toast: ToastNamespace;
|
|
320
323
|
|
|
321
|
-
export { ToastManager, ToastState, Toaster, createToastManager, Toast as default, promiseToast, toast, useToastManager };
|
|
324
|
+
export { ToastAction as Action, ToastClose as Close, ToastContent as Content, ToastDescription as Description, ToastPortal as Portal, ToastProvider as Provider, ToastRoot as Root, ToastTitle as Title, ToastManager, ToastState, Toaster, ToastViewport as Viewport, createToastManager, Toast as default, promiseToast, toast, useToastManager };
|
|
322
325
|
export type { CreateToastInput, IToastManager, ToastActionProps, ToastCloseProps, ToastContentProps, ToastData, ToastDescriptionProps, ToastManagerReturn, ToastManagerUpdateOptions, ToastPortalProps, ToastPosition, ToastPromiseMessages, ToastPromiseState, ToastProviderProps, ToastRootProps, ToastTitleProps, ToastViewportProps };
|
package/dist/components/Toast.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use client';import{jsx as e,Fragment as t,jsxs as s}from"react/jsx-runtime";import i,{createContext as o,useMemo as r,useEffect as n,useState as a,useCallback as d,useContext as c,useRef as l}from"react";import{u}from"./useComponentClass-QwNivz0h.js";import{createPortal as m}from"react-dom";import{T as p}from"./ThemeContext-Sm-iNANd.js";import{c as f}from"./clsx-BaVHROc5.js";const h=o({rootClass:"",position:"bottom-right",expand:!1,gap:14,maxToasts:3,defaultToastTimeout:4e3,toastManager:void 0,isHovered:!1,setIsHovered:()=>{},heights:new Map,updateHeight:()=>{},unlinkStackHeight:()=>{},removeToast:()=>{},toasts:[],visibleToasts:[],viewportClassName:void 0,viewportStyle:void 0,containerAriaLabel:"Notifications",offset:void 0,mobileOffset:void 0,theme:void 0,dir:void 0,richColors:!1,invert:!1,pauseWhenPageIsHidden:!0,closeButton:!1,icons:void 0,loadingIcon:void 0,swipeDirections:void 0,dragThreshold:void 0}),v=o(null);let b=0;class g{constructor(){this.defaultTimeout=4e3,this.subscribers=new Set,this.dismissSubscribers=new Set,this.updateSubscribers=new Set}subscribe(e){return this.subscribers.add(e),()=>this.subscribers.delete(e)}subscribeDismiss(e){return this.dismissSubscribers.add(e),()=>this.dismissSubscribers.delete(e)}subscribeUpdate(e){return this.updateSubscribers.add(e),()=>this.updateSubscribers.delete(e)}create(e){const{id:t,timeout:s,duration:i,...o}=e,r=t??`toast-${++b}-${Math.random().toString(36).slice(2,7)}`,n={...o,id:r,duration:i??s??this.defaultTimeout};return this.subscribers.forEach((e=>e(n))),r}update(e,t){const s=function(e){const{timeout:t,...s}=e;return void 0!==t?{...s,duration:t,timeout:t}:s}(t);this.updateSubscribers.forEach((t=>t(e,s)))}dismiss(e){this.dismissSubscribers.forEach((t=>t(e)))}dismissAll(){this.dismissSubscribers.forEach((e=>e("__all__")))}close(e){void 0===e?this.dismissAll():this.dismiss(e)}}const y=new g;function w(e){const t=new g;return void 0!==e?.timeout&&(t.defaultTimeout=e.timeout),t}function T(e){return"string"==typeof e?{title:e}:e}function x(e,t,s,i=y){const o=T(t.loading),r=i.create({persistent:!0,variant:"default",...s,...o});return e.then((e=>{i.dismiss(r);const o=function(e,t){return T("function"==typeof e?e(t):e)}(t.success,e);i.create({variant:"success",...s,...o})})).catch((e=>{i.dismiss(r);const o=function(e,t){return T("function"==typeof e?e(t):e)}(t.error,e);i.create({variant:"error",...s,...o})})),e}function N(e,t){return"string"==typeof e?y.create({title:e,...t}):y.create(e)}function C(e){return(t,s)=>"string"==typeof t?y.create({title:t,variant:e,...s}):y.create({variant:e,...t})}const A=Object.assign(N,{success:C("success"),error:C("error"),warning:C("warning"),info:C("info"),loading:C("loading"),dismiss:e=>void 0===e?y.dismissAll():y.dismiss(e),dismissAll:()=>y.dismissAll(),close:e=>y.close(e),promise:x,message:N,custom:(e,t)=>y.create({...t,render:({id:t})=>e(t)})}),M=({children:t,customRootClass:s="",position:i="bottom-right",expand:o=!1,gap:c=14,maxToasts:l,limit:m,timeout:p,duration:f,toastManager:v,className:b,style:g,richColors:w,closeButton:T,offset:x,mobileOffset:N,theme:C,dir:A,swipeDirections:M,visibleToasts:S,toastOptions:H,invert:P,pauseWhenPageIsHidden:D=!0,icons:$,loadingIcon:I,rtl:k,hotkey:R,containerAriaLabel:_,dragThreshold:j})=>{const E=m??l??S??3,K=r((()=>v??y),[v]),B=p??f??4e3;n((()=>{K.defaultTimeout=B}),[K,B]);const L=u(s,"Toast"),[O,F]=a([]),[W,U]=a(!1),[q,z]=a(new Map);n((()=>{const e=K.subscribe((e=>{F((t=>{const s={...H,...e},i=t.findIndex((t=>t.id===e.id));if(-1!==i){const e=t[i],o=[...t];return o[i]={...s,updateKey:(e.updateKey??0)+1},o}return[{...s,updateKey:0},...t].slice(0,2*E)}))})),t=K.subscribeDismiss((e=>{"__all__"===e&&F([])})),s=K.subscribeUpdate(((e,t)=>{F((s=>s.map((s=>s.id===e?{...s,...t}:s))))}));return()=>{e(),t(),s()}}),[K,E,H]);const V=d((e=>{F((t=>{const s=t.find((t=>t.id===e));return s?.onRemove?.(),t.filter((t=>t.id!==e))})),z((t=>{const s=new Map(t);return s.delete(e),s}))}),[]),Y=d(((e,t)=>{z((s=>{if(s.get(e)===t)return s;const i=new Map(s);return i.set(e,t),i}))}),[]),G=d((e=>{z((t=>{if(!t.has(e))return t;const s=new Map(t);return s.delete(e),s}))}),[]),J=O.slice(0,E);return e(h.Provider,{value:{rootClass:L,position:i,expand:o,gap:c,maxToasts:E,defaultToastTimeout:B,toastManager:K,isHovered:W,setIsHovered:U,heights:q,updateHeight:Y,unlinkStackHeight:G,removeToast:V,toasts:O,visibleToasts:J,viewportClassName:b,viewportStyle:g,containerAriaLabel:_??"Notifications",offset:x,mobileOffset:N,theme:C,dir:k?"rtl":A,richColors:w??!1,invert:P??!1,pauseWhenPageIsHidden:D,closeButton:T??!1,icons:$,loadingIcon:I,swipeDirections:M,dragThreshold:j},children:t})};M.displayName="ToastProvider";const S=({children:e,container:t})=>{const s=c(p),[i,o]=a(!1);if(n((()=>{o(!0)}),[]),!i)return null;const r=t??s?.portalRootRef.current??document.body;return m(e,r)};function H(e){if(void 0!==e)return"number"==typeof e?`${e}px`:e}S.displayName="ToastPortal";const P=({children:t,className:s,style:i})=>{const{rootClass:o,position:r,expand:n,isHovered:a,setIsHovered:d,heights:u,gap:m,visibleToasts:p,viewportClassName:v,viewportStyle:b,containerAriaLabel:g,offset:y,mobileOffset:w,theme:T,dir:x,richColors:N,invert:C}=c(h),A=l(null),M=n||a,S=u.get(p[0]?.id)??0,P=p[1]?u.get(p[1].id)??0:0,D=S>0?S:P,$=M?p.reduce(((e,t)=>e+(u.get(t.id)??0)),0)+Math.max(0,p.length-1)*m:D+m*Math.max(0,p.length-1);return e("ol",{ref:A,role:"region","aria-label":g,tabIndex:-1,"data-position":r,"data-expanded":M?"":void 0,"data-theme":T,"data-rich-colors":N?"":void 0,"data-invert":C?"":void 0,dir:x,className:f(o&&`${o}-viewport`,v,s),style:{...b,"--viewport-height":`${$}px`,"--toast-frontmost-height":`${D}px`,"--toast-offset":H(y),"--toast-mobile-offset":H("object"==typeof w?void 0:w),"--toast-mobile-offset-top":H("object"==typeof w?w.top:void 0),"--toast-mobile-offset-bottom":H("object"==typeof w?w.bottom:void 0),"--toast-mobile-offset-left":H("object"==typeof w?w.left:void 0),"--toast-mobile-offset-right":H("object"==typeof w?w.right:void 0),...i},onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),onFocusCapture:()=>d(!0),onBlurCapture:e=>{A.current?.contains(e.relatedTarget)||d(!1)},children:t})};P.displayName="ToastViewport";const D=({toast:t,className:s,children:i})=>{const{rootClass:o,position:r,expand:u,isHovered:m,heights:p,gap:b,toasts:g,visibleToasts:y,updateHeight:w,unlinkStackHeight:T,removeToast:x,defaultToastTimeout:N,toastManager:C,pauseWhenPageIsHidden:A,swipeDirections:M,dragThreshold:S}=c(h),H=l(null),P=l(null),D=t.duration??t.timeout??N,$=l(D),I=l(null),[k,R]=a(!1),[_,j]=a(!0),[E,K]=a(!1),[B,L]=a(!1),O=l(-1),F=l(-1),W=l(!1),U=l({y:0,time:0}),q=l(0),z=r.startsWith("top"),V=u||m,Y=y.findIndex((e=>e.id===t.id)),G=0===Y,J=!G&&!V,Q=g.length>0&&t.id===g[g.length-1]?.id,X=p.get(t.id)??0,Z=p.get(y[0]?.id)??0,ee=y[1]?p.get(y[1].id)??0:0,te=Z>0?Z:ee>0?ee:X;let se=0;for(let e=0;e<Y;e++)se+=(p.get(y[e]?.id)??0)+b;n((()=>{if(E)return;if(!H.current)return;const e=H.current,s=()=>{const s=e.offsetHeight;s>0&&w(t.id,s)};s();const i=new ResizeObserver(s);return i.observe(e),()=>i.disconnect()}),[t.id,w,E]),n((()=>{const e=requestAnimationFrame((()=>{R(!0);const e=setTimeout((()=>j(!1)),420);return()=>clearTimeout(e)}));return()=>cancelAnimationFrame(e)}),[]),n((()=>{const e=O.current,t=F.current,s=y.length,i=-1!==e&&Y>e&&-1!==Y&&!E,o=t>s&&-1!==Y&&!E&&Y===e,r=t>s&&-1!==Y&&!E&&-1!==e&&e>Y;if(O.current=Y,F.current=s,i||o||r){L(!0);const e=requestAnimationFrame((()=>L(!1)));return()=>cancelAnimationFrame(e)}}),[Y,E,y.length]);const[ie,oe]=a((()=>"undefined"!=typeof document&&document.hidden));n((()=>{const e=()=>oe(document.hidden);return document.addEventListener("visibilitychange",e),()=>document.removeEventListener("visibilitychange",e)}),[]);const re=d((()=>{if(!E){if(-1===Y)return t.onClose?.(),t.onDismiss?.(),T(t.id),void x(t.id);T(t.id),K(!0),t.onClose?.(),t.onDismiss?.()}}),[Y,E,t,T,x]),ne=l(re);n((()=>{ne.current=re}),[re]),n((()=>{if(!C)return;return C.subscribeDismiss((e=>{"__all__"!==e&&e===t.id&&ne.current()}))}),[t.id,C]);const ae=d((()=>{P.current&&(clearTimeout(P.current),P.current=null),null!==I.current&&($.current-=Date.now()-I.current,I.current=null)}),[]),de=d((()=>{t.persistent||$.current<=0||(I.current=Date.now(),P.current=setTimeout((()=>ne.current()),$.current))}),[t.persistent]);n((()=>{$.current=t.duration??t.timeout??N,ae()}),[t.updateKey,t.duration,t.timeout,N,ae]),n((()=>((!A||!ie)&&(Q||V)&&!E?de():ae(),ae)),[V,ie,Q,E,A,de,ae,t.updateKey]),n((()=>{if(!E)return;const e=window.setTimeout((()=>x(t.id)),200);return()=>clearTimeout(e)}),[E,x,t.id]);const ce=d((e=>{W.current=!0,U.current={y:e.clientY,time:Date.now()},H.current?.setPointerCapture(e.pointerId),ae()}),[ae]),le=d((e=>{if(!W.current||!H.current)return;const t=e.clientY-U.current.y,s=t*(z?-1:1)<0?.2*t:t;q.current=s,H.current.style.setProperty("--swipe-y",`${s}px`),H.current.setAttribute("data-swiping","")}),[z]),ue=d((e=>{if(!W.current||!H.current)return;W.current=!1,H.current.removeAttribute("data-swiping");const t=q.current,s=Date.now()-U.current.time,i=Math.abs(t)/s,o=z?-1:1,r=z?"up":"down",n=!M?.length||M.includes(r),a=S??40;n&&t*o>0&&(Math.abs(t)>=a||i>.11)?re():(q.current=0,H.current.style.setProperty("--swipe-y","0px"),de())}),[S,z,re,de,M]);if(-1===Y&&!E)return null;const me=t.updateKey&&t.updateKey>0?t.updateKey%2==0?"even":"odd":void 0,pe=V?1:Math.max(.82,1-.05*Y);let fe;if(E)fe=0;else if(V)fe=z?se:-se;else{fe=(z?1:-1)*(14*Y+(1-pe)*(te>0?te:X))}const he={"--swipe-y":"0px","--toast-swipe-movement-x":"0px","--toast-swipe-movement-y":"var(--swipe-y, 0px)","--toast-height":`${X}px`,"--scale":pe,"--y":`${fe}px`,"--toast-lift":z?1:-1,"--front-height":`${Z>0?Z:ee>0?ee:X}px`,"--toast-index":Y,"--toast-offset-y":`${z?se:-se}px`,zIndex:10-Y};return e(v.Provider,{value:{toast:t,index:Y,isExpanded:V,isFront:G,isBehind:J,dismiss:re},children:e("li",{ref:H,role:"status","aria-live":"high"===t.priority?"assertive":"polite","aria-atomic":"true","data-variant":t.variant??void 0,"data-type":t.type??void 0,"data-limited":t.limited?"":void 0,"data-mounted":k?"":void 0,"data-entering":_&&G?"":void 0,"data-restack-skip":B?"":void 0,"data-leaving":E?"":void 0,"data-expanded":V?"":void 0,"data-front":G?"":void 0,"data-behind":J?"":void 0,"data-pulse":me,"data-update-key":t.updateKey??0,"data-toast-id":t.id,className:f(o&&`${o}-item`,t.className,s),style:{...he,...t.style},onPointerDown:ce,onPointerMove:le,onPointerUp:ue,children:t.render?t.render({id:t.id,toast:t,onDismiss:re}):i})})};D.displayName="ToastRoot";const $=i.forwardRef((({className:t,children:s,...i},o)=>{const{rootClass:r}=c(h),n=c(v);return e("div",{ref:o,className:f(r&&`${r}-content`,t),"data-behind":n?.isBehind?"":void 0,"data-expanded":n?.isExpanded?"":void 0,...i,children:s})}));$.displayName="ToastContent";const I=i.forwardRef((({className:t,children:s,...i},o)=>{const{rootClass:r}=c(h);return e("h2",{ref:o,className:f(r&&`${r}-title`,t),...i,children:s})}));I.displayName="ToastTitle";const k=i.forwardRef((({className:t,children:s,...i},o)=>{const{rootClass:r}=c(h);return e("p",{ref:o,className:f(r&&`${r}-description`,t),...i,children:s})}));k.displayName="ToastDescription";const R=i.forwardRef((({className:t,children:s,onClick:i,...o},r)=>{const{rootClass:n}=c(h),a=c(v);return e("button",{ref:r,type:"button","aria-label":"Close notification",className:f(n&&`${n}-close`,t),onClick:e=>{i?.(e),a?.dismiss()},...o,children:s??"×"})}));R.displayName="ToastClose";const _=i.forwardRef((({className:t,children:s,type:i="button",...o},r)=>{const{rootClass:n}=c(h),a=c(v),d=a?.toast.actionProps;return e("button",{ref:r,type:i,className:f(n&&`${n}-action`,t),...d,...o,children:s??d?.children})}));function j(){const e=c(h),t=e.toastManager??y,s=e=>(s,i)=>"string"==typeof s?t.create({title:s,variant:e,...i}):t.create({variant:e,...s});return{toasts:[...e.toasts].reverse(),add:(e,s)=>"string"==typeof e?t.create({title:e,...s}):t.create(e),close:e=>t.close(e),update:(e,s)=>t.update(e,s),promise:(e,s,i)=>x(e,s,i,t),dismiss:e=>void 0===e?t.dismissAll():t.dismiss(e),dismissAll:()=>t.dismissAll(),success:s("success"),error:s("error"),warning:s("warning"),info:s("info"),loading:s("loading")}}function E(){const{toasts:o}=j(),{closeButton:r,icons:n,loadingIcon:a}=i.useContext(h);return e(t,{children:o.map((t=>e(D,{toast:t,children:s($,{children:[t.icon??("loading"===t.type?a:void 0)??n?.[t.variant??t.type??""],e(I,{children:t.title}),t.description&&e(k,{children:t.description}),t.actionProps&&e(_,{}),r&&e(R,{})]})},t.id)))})}function K({children:t,className:s,style:i,containerClassName:o,containerStyle:r,...n}){return e(M,{...n,children:e(S,{children:e("div",{className:o,style:r,children:e(P,{className:s,style:i,children:t??e(E,{})})})})})}_.displayName="ToastAction",K.displayName="Toaster";const B={Provider:M,Portal:S,Viewport:P,Root:D,Content:$,Title:I,Description:k,Action:_,Close:R,useToastManager:j,Toaster:K};export{g as ToastManager,y as ToastState,K as Toaster,w as createToastManager,B as default,x as promiseToast,A as toast,j as useToastManager};
|
|
1
|
+
'use client';import{jsx as e,Fragment as t,jsxs as s}from"react/jsx-runtime";import i,{createContext as o,useMemo as r,useEffect as n,useState as a,useCallback as d,useContext as c,useRef as l}from"react";import{u,c as m}from"./useComponentClass-C0isGl1z.js";import{createPortal as p}from"react-dom";import{T as f}from"./ThemeContext-Sm-iNANd.js";const h=o({rootClass:"",position:"bottom-right",expand:!1,gap:14,maxToasts:3,defaultToastTimeout:4e3,toastManager:void 0,isHovered:!1,setIsHovered:()=>{},heights:new Map,updateHeight:()=>{},unlinkStackHeight:()=>{},removeToast:()=>{},toasts:[],visibleToasts:[],viewportClassName:void 0,viewportStyle:void 0,containerAriaLabel:"Notifications",offset:void 0,mobileOffset:void 0,theme:void 0,dir:void 0,richColors:!1,invert:!1,pauseWhenPageIsHidden:!0,closeButton:!1,icons:void 0,loadingIcon:void 0,swipeDirections:void 0,dragThreshold:void 0}),v=o(null);let b=0;class g{constructor(){this.defaultTimeout=4e3,this.subscribers=new Set,this.dismissSubscribers=new Set,this.updateSubscribers=new Set}subscribe(e){return this.subscribers.add(e),()=>this.subscribers.delete(e)}subscribeDismiss(e){return this.dismissSubscribers.add(e),()=>this.dismissSubscribers.delete(e)}subscribeUpdate(e){return this.updateSubscribers.add(e),()=>this.updateSubscribers.delete(e)}create(e){const{id:t,timeout:s,duration:i,...o}=e,r=t??`toast-${++b}-${Math.random().toString(36).slice(2,7)}`,n={...o,id:r,duration:i??s??this.defaultTimeout};return this.subscribers.forEach((e=>e(n))),r}update(e,t){const s=function(e){const{timeout:t,...s}=e;return void 0!==t?{...s,duration:t,timeout:t}:s}(t);this.updateSubscribers.forEach((t=>t(e,s)))}dismiss(e){this.dismissSubscribers.forEach((t=>t(e)))}dismissAll(){this.dismissSubscribers.forEach((e=>e("__all__")))}close(e){void 0===e?this.dismissAll():this.dismiss(e)}}const y=new g;function w(e){const t=new g;return void 0!==e?.timeout&&(t.defaultTimeout=e.timeout),t}function T(e){return"string"==typeof e?{title:e}:e}function x(e,t,s,i=y){const o=T(t.loading),r=i.create({persistent:!0,variant:"default",...s,...o});return e.then((e=>{i.dismiss(r);const o=function(e,t){return T("function"==typeof e?e(t):e)}(t.success,e);i.create({variant:"success",...s,...o})})).catch((e=>{i.dismiss(r);const o=function(e,t){return T("function"==typeof e?e(t):e)}(t.error,e);i.create({variant:"error",...s,...o})})),e}function C(e,t){return"string"==typeof e?y.create({title:e,...t}):y.create(e)}function N(e){return(t,s)=>"string"==typeof t?y.create({title:t,variant:e,...s}):y.create({variant:e,...t})}const A=Object.assign(C,{success:N("success"),error:N("error"),warning:N("warning"),info:N("info"),loading:N("loading"),dismiss:e=>void 0===e?y.dismissAll():y.dismiss(e),dismissAll:()=>y.dismissAll(),close:e=>y.close(e),promise:x,message:C,custom:(e,t)=>y.create({...t,render:({id:t})=>e(t)})}),M=({children:t,customRootClass:s="",position:i="bottom-right",expand:o=!1,gap:c=14,maxToasts:l,limit:m,timeout:p,duration:f,toastManager:v,className:b,style:g,richColors:w,closeButton:T,offset:x,mobileOffset:C,theme:N,dir:A,swipeDirections:M,visibleToasts:P,toastOptions:S,invert:D,pauseWhenPageIsHidden:H=!0,icons:$,loadingIcon:I,rtl:R,hotkey:k,containerAriaLabel:_,dragThreshold:j})=>{const E=m??l??P??3,K=r((()=>v??y),[v]),B=p??f??4e3;n((()=>{K.defaultTimeout=B}),[K,B]);const L=u(s,"Toast"),[O,F]=a([]),[W,U]=a(!1),[V,q]=a(new Map);n((()=>{const e=K.subscribe((e=>{F((t=>{const s={...S,...e},i=t.findIndex((t=>t.id===e.id));if(-1!==i){const e=t[i],o=[...t];return o[i]={...s,updateKey:(e.updateKey??0)+1},o}return[{...s,updateKey:0},...t].slice(0,2*E)}))})),t=K.subscribeDismiss((e=>{"__all__"===e&&F([])})),s=K.subscribeUpdate(((e,t)=>{F((s=>s.map((s=>s.id===e?{...s,...t}:s))))}));return()=>{e(),t(),s()}}),[K,E,S]);const z=d((e=>{F((t=>{const s=t.find((t=>t.id===e));return s?.onRemove?.(),t.filter((t=>t.id!==e))})),q((t=>{const s=new Map(t);return s.delete(e),s}))}),[]),Y=d(((e,t)=>{q((s=>{if(s.get(e)===t)return s;const i=new Map(s);return i.set(e,t),i}))}),[]),G=d((e=>{q((t=>{if(!t.has(e))return t;const s=new Map(t);return s.delete(e),s}))}),[]),J=O.slice(0,E);return e(h.Provider,{value:{rootClass:L,position:i,expand:o,gap:c,maxToasts:E,defaultToastTimeout:B,toastManager:K,isHovered:W,setIsHovered:U,heights:V,updateHeight:Y,unlinkStackHeight:G,removeToast:z,toasts:O,visibleToasts:J,viewportClassName:b,viewportStyle:g,containerAriaLabel:_??"Notifications",offset:x,mobileOffset:C,theme:N,dir:R?"rtl":A,richColors:w??!1,invert:D??!1,pauseWhenPageIsHidden:H,closeButton:T??!1,icons:$,loadingIcon:I,swipeDirections:M,dragThreshold:j},children:t})};M.displayName="ToastProvider";const P=({children:e,container:t})=>{const s=c(f),[i,o]=a(!1);if(n((()=>{o(!0)}),[]),!i)return null;const r=t??s?.portalRootRef.current??document.body;return p(e,r)};function S(e){if(void 0!==e)return"number"==typeof e?`${e}px`:e}P.displayName="ToastPortal";const D=({children:t,className:s,style:i})=>{const{rootClass:o,position:r,expand:n,isHovered:a,setIsHovered:d,heights:u,gap:p,visibleToasts:f,viewportClassName:v,viewportStyle:b,containerAriaLabel:g,offset:y,mobileOffset:w,theme:T,dir:x,richColors:C,invert:N}=c(h),A=l(null),M=n||a,P=u.get(f[0]?.id)??0,D=f[1]?u.get(f[1].id)??0:0,H=P>0?P:D,$=M?f.reduce(((e,t)=>e+(u.get(t.id)??0)),0)+Math.max(0,f.length-1)*p:H+p*Math.max(0,f.length-1);return e("section",{ref:A,role:"region","aria-label":g,tabIndex:-1,"data-position":r,"data-expanded":M?"":void 0,"data-theme":T,"data-rich-colors":C?"":void 0,"data-invert":N?"":void 0,dir:x,className:m(o&&`${o}-viewport`,v,s),style:{...b,"--viewport-height":`${$}px`,"--toast-frontmost-height":`${H}px`,"--toast-offset":S(y),"--toast-mobile-offset":S("object"==typeof w?void 0:w),"--toast-mobile-offset-top":S("object"==typeof w?w.top:void 0),"--toast-mobile-offset-bottom":S("object"==typeof w?w.bottom:void 0),"--toast-mobile-offset-left":S("object"==typeof w?w.left:void 0),"--toast-mobile-offset-right":S("object"==typeof w?w.right:void 0),...i},onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),onFocusCapture:()=>d(!0),onBlurCapture:e=>{A.current?.contains(e.relatedTarget)||d(!1)},children:t})};D.displayName="ToastViewport";const H=({toast:t,className:s,children:i})=>{const{rootClass:o,position:r,expand:u,isHovered:p,heights:f,gap:b,toasts:g,visibleToasts:y,updateHeight:w,unlinkStackHeight:T,removeToast:x,defaultToastTimeout:C,toastManager:N,pauseWhenPageIsHidden:A,swipeDirections:M,dragThreshold:P}=c(h),S=l(null),D=l(null),H=t.duration??t.timeout??C,$=l(H),I=l(null),[R,k]=a(!1),[_,j]=a(!0),[E,K]=a(!1),[B,L]=a(!1),O=l(-1),F=l(-1),W=l(!1),U=l({y:0,time:0}),V=l(0),q=r.startsWith("top"),z=u||p,Y=y.findIndex((e=>e.id===t.id)),G=0===Y,J=!G&&!z,Q=g.length>0&&t.id===g[g.length-1]?.id,X=f.get(t.id)??0,Z=f.get(y[0]?.id)??0,ee=y[1]?f.get(y[1].id)??0:0,te=Z>0?Z:ee>0?ee:X;let se=0;for(let e=0;e<Y;e++)se+=(f.get(y[e]?.id)??0)+b;n((()=>{if(E)return;if(!S.current)return;const e=S.current,s=()=>{const s=e.offsetHeight;s>0&&w(t.id,s)};s();const i=new ResizeObserver(s);return i.observe(e),()=>i.disconnect()}),[t.id,w,E]),n((()=>{const e=requestAnimationFrame((()=>{k(!0);const e=setTimeout((()=>j(!1)),420);return()=>clearTimeout(e)}));return()=>cancelAnimationFrame(e)}),[]),n((()=>{const e=O.current,t=F.current,s=y.length,i=-1!==e&&Y>e&&-1!==Y&&!E,o=t>s&&-1!==Y&&!E&&Y===e,r=t>s&&-1!==Y&&!E&&-1!==e&&e>Y;if(O.current=Y,F.current=s,i||o||r){L(!0);const e=requestAnimationFrame((()=>L(!1)));return()=>cancelAnimationFrame(e)}}),[Y,E,y.length]);const[ie,oe]=a((()=>"undefined"!=typeof document&&document.hidden));n((()=>{const e=()=>oe(document.hidden);return document.addEventListener("visibilitychange",e),()=>document.removeEventListener("visibilitychange",e)}),[]);const re=d((()=>{if(!E){if(-1===Y)return t.onClose?.(),t.onDismiss?.(),T(t.id),void x(t.id);T(t.id),K(!0),t.onClose?.(),t.onDismiss?.()}}),[Y,E,t,T,x]),ne=l(re);n((()=>{ne.current=re}),[re]),n((()=>{if(!N)return;return N.subscribeDismiss((e=>{"__all__"!==e&&e===t.id&&ne.current()}))}),[t.id,N]);const ae=d((()=>{D.current&&(clearTimeout(D.current),D.current=null),null!==I.current&&($.current-=Date.now()-I.current,I.current=null)}),[]),de=d((()=>{t.persistent||$.current<=0||(I.current=Date.now(),D.current=setTimeout((()=>ne.current()),$.current))}),[t.persistent]);n((()=>{$.current=t.duration??t.timeout??C,ae()}),[t.updateKey,t.duration,t.timeout,C,ae]),n((()=>((!A||!ie)&&(Q||z)&&!E?de():ae(),ae)),[z,ie,Q,E,A,de,ae,t.updateKey]),n((()=>{if(!E)return;const e=window.setTimeout((()=>x(t.id)),200);return()=>clearTimeout(e)}),[E,x,t.id]);const ce=d((e=>{W.current=!0,U.current={y:e.clientY,time:Date.now()},S.current?.setPointerCapture(e.pointerId),ae()}),[ae]),le=d((e=>{if(!W.current||!S.current)return;const t=e.clientY-U.current.y,s=t*(q?-1:1)<0?.2*t:t;V.current=s,S.current.style.setProperty("--swipe-y",`${s}px`),S.current.setAttribute("data-swiping","")}),[q]),ue=d((e=>{if(!W.current||!S.current)return;W.current=!1,S.current.removeAttribute("data-swiping");const t=V.current,s=Date.now()-U.current.time,i=Math.abs(t)/s,o=q?-1:1,r=q?"up":"down",n=!M?.length||M.includes(r),a=P??40;n&&t*o>0&&(Math.abs(t)>=a||i>.11)?re():(V.current=0,S.current.style.setProperty("--swipe-y","0px"),de())}),[P,q,re,de,M]);if(-1===Y&&!E)return null;const me=t.updateKey&&t.updateKey>0?t.updateKey%2==0?"even":"odd":void 0,pe=z?1:Math.max(.82,1-.05*Y);let fe;if(E)fe=0;else if(z)fe=q?se:-se;else{fe=(q?1:-1)*(14*Y+(1-pe)*(te>0?te:X))}const he={"--swipe-y":"0px","--toast-swipe-movement-x":"0px","--toast-swipe-movement-y":"var(--swipe-y, 0px)","--toast-height":`${X}px`,"--scale":pe,"--y":`${fe}px`,"--toast-lift":q?1:-1,"--front-height":`${Z>0?Z:ee>0?ee:X}px`,"--toast-index":Y,"--toast-offset-y":`${q?se:-se}px`,zIndex:10-Y};return e(v.Provider,{value:{toast:t,index:Y,isExpanded:z,isFront:G,isBehind:J,dismiss:re},children:e("div",{ref:S,role:"status","aria-live":"high"===t.priority?"assertive":"polite","aria-atomic":"true","data-variant":t.variant??void 0,"data-type":t.type??void 0,"data-limited":t.limited?"":void 0,"data-mounted":R?"":void 0,"data-entering":_&&G?"":void 0,"data-restack-skip":B?"":void 0,"data-leaving":E?"":void 0,"data-expanded":z?"":void 0,"data-front":G?"":void 0,"data-behind":J?"":void 0,"data-pulse":me,"data-update-key":t.updateKey??0,"data-toast-id":t.id,className:m(o&&`${o}-item`,t.className,s),style:{...he,...t.style},onPointerDown:ce,onPointerMove:le,onPointerUp:ue,children:t.render?t.render({id:t.id,toast:t,onDismiss:re}):i})})};H.displayName="ToastRoot";const $=i.forwardRef((({className:t,children:s,...i},o)=>{const{rootClass:r}=c(h),n=c(v);return e("div",{ref:o,className:m(r&&`${r}-content`,t),"data-behind":n?.isBehind?"":void 0,"data-expanded":n?.isExpanded?"":void 0,...i,children:s})}));$.displayName="ToastContent";const I=i.forwardRef((({className:t,children:s,...i},o)=>{const{rootClass:r}=c(h);return e("div",{ref:o,className:m(r&&`${r}-title`,t),...i,children:s})}));I.displayName="ToastTitle";const R=i.forwardRef((({className:t,children:s,...i},o)=>{const{rootClass:r}=c(h);return e("p",{ref:o,className:m(r&&`${r}-description`,t),...i,children:s})}));R.displayName="ToastDescription";const k=i.forwardRef((({className:t,children:s,onClick:i,...o},r)=>{const{rootClass:n}=c(h),a=c(v);return e("button",{ref:r,type:"button","aria-label":"Close notification",className:m(n&&`${n}-close`,t),onClick:e=>{i?.(e),a?.dismiss()},...o,children:s??"×"})}));k.displayName="ToastClose";const _=i.forwardRef((({className:t,children:s,type:i="button",...o},r)=>{const{rootClass:n}=c(h),a=c(v),d=a?.toast.actionProps;return e("button",{ref:r,type:i,className:m(n&&`${n}-action`,t),...d,...o,children:s??d?.children})}));function j(){const e=c(h),t=e.toastManager??y,s=e=>(s,i)=>"string"==typeof s?t.create({title:s,variant:e,...i}):t.create({variant:e,...s});return{toasts:[...e.toasts].reverse(),add:(e,s)=>"string"==typeof e?t.create({title:e,...s}):t.create(e),close:e=>t.close(e),update:(e,s)=>t.update(e,s),promise:(e,s,i)=>x(e,s,i,t),dismiss:e=>void 0===e?t.dismissAll():t.dismiss(e),dismissAll:()=>t.dismissAll(),success:s("success"),error:s("error"),warning:s("warning"),info:s("info"),loading:s("loading")}}function E(){const{toasts:o}=j(),{closeButton:r,icons:n,loadingIcon:a}=i.useContext(h);return e(t,{children:o.map((t=>e(H,{toast:t,children:s($,{children:[t.icon??("loading"===t.type?a:void 0)??n?.[t.variant??t.type??""],e(I,{children:t.title}),t.description&&e(R,{children:t.description}),t.actionProps&&e(_,{}),r&&e(k,{})]})},t.id)))})}function K({children:t,className:s,style:i,containerClassName:o,containerStyle:r,...n}){return e(M,{...n,children:e(P,{children:e("div",{className:o,style:r,children:e(D,{className:s,style:i,children:t??e(E,{})})})})})}_.displayName="ToastAction",K.displayName="Toaster";const B={Provider:M,Portal:P,Viewport:D,Root:H,Content:$,Title:I,Description:R,Action:_,Close:k,useToastManager:j,Toaster:K};export{_ as Action,k as Close,$ as Content,R as Description,P as Portal,M as Provider,H as Root,I as Title,g as ToastManager,y as ToastState,K as Toaster,D as Viewport,w as createToastManager,B as default,x as promiseToast,A as toast,j as useToastManager};
|
|
@@ -11,7 +11,7 @@ interface ToggleProps extends Omit<React.ComponentPropsWithoutRef<typeof ToggleP
|
|
|
11
11
|
/** Accent color for the toggle */
|
|
12
12
|
color?: string;
|
|
13
13
|
/** Callback fired when toggle state changes */
|
|
14
|
-
onPressedChange
|
|
14
|
+
onPressedChange?: (isPressed: boolean) => void;
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
17
|
* Toggle component that can be used in either controlled or uncontrolled mode.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
'use client';import{jsx as s}from"react/jsx-runtime";import{forwardRef as e}from"react";import{
|
|
1
|
+
'use client';import{jsx as s}from"react/jsx-runtime";import{forwardRef as e}from"react";import{u as o,c as r}from"./useComponentClass-C0isGl1z.js";import{u as a}from"./index-wRElCyvx.js";import{T as t}from"./index-nYRBURkR.js";import"./ThemeContext-Sm-iNANd.js";import"./index-FITGoHty.js";import"./index-XF8itt-H.js";import"./mergeProps-0RucjqeH.js";import"./index-CXzybYmm.js";import"./keyboard-BKF7hXqL.js";const d="Toggle",i=e((({defaultPressed:e=!1,customRootClass:i="",children:m,className:n="",color:p="",pressed:l,onPressedChange:c,asChild:j=!1,...f},u)=>{const[x,C]=a(l,e,c),h=o(i,d),g={};return p&&(g["data-color"]=p),s(t,{ref:u,className:r(h,n),pressed:x,onPressedChange:C,"data-state":x?"on":"off","data-disabled":f.disabled?"":void 0,asChild:j,...f,...g,children:m})}));i.displayName=d;export{i as default};
|
|
@@ -92,5 +92,5 @@ type ToggleGroupComponent = React.ForwardRefExoticComponent<ToggleGroupProps & R
|
|
|
92
92
|
};
|
|
93
93
|
declare const ToggleGroup: ToggleGroupComponent;
|
|
94
94
|
|
|
95
|
-
export { ToggleGroup as default };
|
|
95
|
+
export { ToggleItem as Item, ToggleGroupRoot as Root, ToggleGroup as default };
|
|
96
96
|
export type { ToggleGroupRootProps, ToggleItemProps };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
'use client';import e,{createContext as o,useContext as
|
|
1
|
+
'use client';import e,{createContext as o,useContext as a}from"react";import{jsx as s}from"react/jsx-runtime";import{u as r,c as i}from"./useComponentClass-C0isGl1z.js";import{u as t}from"./index-wRElCyvx.js";import{R as l}from"./index-C7dBo_Ry.js";import{P as d}from"./index-XF8itt-H.js";import{T as n}from"./index-nYRBURkR.js";import{c}from"./index-CXzybYmm.js";import"./ThemeContext-Sm-iNANd.js";import"./index-FITGoHty.js";import"./keyboard-BKF7hXqL.js";import"./mergeRefs-B8eZ_q-T.js";import"./mergeProps-0RucjqeH.js";const m=o({type:"single",activeToggles:[],setActiveToggles:()=>{},rootClass:"",disabled:!1,orientation:"horizontal"}),p="ToggleGroup",u=e.forwardRef((({type:e="single",className:o="",loop:a=!0,orientation:n="horizontal",customRootClass:c="",value:u,defaultValue:g=[],onValueChange:f,color:h="",disabled:v=!1,dir:C="ltr",rovingFocus:T=!0,asChild:j=!1,children:y,...b},R)=>{const x=r(c,p),[N,G]=t(u,g,f),A={activeToggles:N,setActiveToggles:G,type:e,rootClass:x,disabled:v,orientation:n},I={};return h&&(I["data-color"]=h),v&&(I["data-disabled"]=""),I["data-orientation"]=n,s(m.Provider,T?{value:A,children:s(l.Root,{loop:a,orientation:n,dir:C,children:s(l.Group,{...I,...b,children:s(d.div,{ref:R,className:i(x,o),asChild:j,children:y})})})}:{value:A,children:s(d.div,{ref:R,className:i(x,o),...I,dir:C,asChild:j,...b,children:y})})}));u.displayName=p;const g=e.forwardRef((({children:e,className:o="",value:r=null,disabled:t=!1,asChild:d=!1,iconOnly:p=!1,onClick:u,...g},f)=>{const{type:h,activeToggles:v,setActiveToggles:C,rootClass:T,disabled:j}=a(m),y=Array.isArray(v)?v:null==v||""===v?[]:[v],b=y.includes(r),R=t||j,x={},N={};return b?(x["aria-pressed"]="true",N["data-state"]="on"):(x["aria-pressed"]="false",N["data-state"]="off"),R&&(N["data-disabled"]=""),s(l.Item,{children:s(n,{ref:f,onClick:c(u,(()=>{if(R)return;let e=y;if("single"===h)return b?void C([]):void C([r]);"multiple"===h&&(e=b?e.filter((e=>e!==r)):[...e,r]),C(e)})),"aria-selected":void 0,className:i(T&&`${T}-item`,o),disabled:R,asChild:d,...p?{"data-icon-only":""}:{},...x,...N,...g,children:e})})}));g.displayName="ToggleItem";const f=e.forwardRef(((e,o)=>(console.warn("Direct usage of ToggleGroup is not supported. Please use ToggleGroup.Root, ToggleGroup.Item, etc. instead."),null)));f.displayName="ToggleGroup",f.Root=u,f.Item=g;export{g as Item,u as Root,f as default};
|
|
@@ -79,5 +79,5 @@ type ToolbarComponent = React.ForwardRefExoticComponent<ToolbarProps & React.Ref
|
|
|
79
79
|
};
|
|
80
80
|
declare const Toolbar: ToolbarComponent;
|
|
81
81
|
|
|
82
|
-
export { Toolbar as default };
|
|
82
|
+
export { ToolbarButton as Button, ToolbarLink as Link, ToolbarRoot as Root, ToolbarSeparator as Separator, ToolbarToggleGroup as ToggleGroup, ToolbarToggleItem as ToggleItem, Toolbar as default };
|
|
83
83
|
export type { ToolbarButtonProps, ToolbarLinkProps, ToolbarRootProps, ToolbarSeparatorProps, ToolbarToggleGroupProps, ToolbarToggleItemProps };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
'use client';import o,{createContext as e}from"react";import{jsx as r}from"react/jsx-runtime";import{
|
|
1
|
+
'use client';import o,{createContext as e}from"react";import{jsx as r}from"react/jsx-runtime";import{u as a,c as t}from"./useComponentClass-C0isGl1z.js";import{P as s}from"./index-XF8itt-H.js";import{R as l}from"./index-C7dBo_Ry.js";import{B as i}from"./index-FITGoHty.js";import n from"./Separator.js";import d from"./Link.js";import{u}from"./index-wRElCyvx.js";import{T as m}from"./index-nYRBURkR.js";import"./ThemeContext-Sm-iNANd.js";import"./mergeProps-0RucjqeH.js";import"./keyboard-BKF7hXqL.js";import"./mergeRefs-B8eZ_q-T.js";import"./index-eAZUMNef.js";import"./index-CXzybYmm.js";const c=e(null),p="Toolbar",f=o.forwardRef((({orientation:e="horizontal",loop:i=!1,dir:n="ltr",className:d="",customRootClass:u="",asChild:m=!1,children:f,...h},b)=>{const g=a(u,p),T=o.useMemo((()=>({rootClass:g,orientation:e,dir:n})),[g,e,n]),C={"data-orientation":e};return r(c.Provider,{value:T,children:r(l.Root,{orientation:e,loop:i,dir:n,children:r(l.Group,{children:r(s.div,{asChild:m,ref:b,role:"toolbar","aria-orientation":"vertical"===e?"vertical":void 0,dir:n,className:t(g,d),...C,...h,children:f})})})})}));f.displayName=p;const h=o.forwardRef((({className:e="",asChild:a=!1,type:s="button",...n},d)=>{const u=o.useContext(c);if(!u)throw new Error("Toolbar.Button must be used within Toolbar.Root");const{rootClass:m}=u;return r(l.Item,{children:r(i,{ref:d,className:t(m&&`${m}-button`,e),asChild:a,type:a?void 0:s,...n})})}));h.displayName="ToolbarButton";const b=o.forwardRef((({className:e="",orientation:a,...s},l)=>{const i=o.useContext(c);if(!i)throw new Error("Toolbar.Separator must be used within Toolbar.Root");const{rootClass:d,orientation:u}=i;return r(n,{ref:l,...s,decorative:!0,orientation:a??("horizontal"===u?"vertical":"horizontal"),className:t(d&&`${d}-separator`,e)})}));b.displayName="ToolbarSeparator";const g=o.forwardRef((({className:e="",asChild:a=!1,href:s="#",...i},n)=>{const u=o.useContext(c);if(!u)throw new Error("Toolbar.Link must be used within Toolbar.Root");const{rootClass:m}=u;return r(l.Item,{role:"link",children:r(d,{ref:n,asChild:a,href:s,className:t(m&&`${m}-link`,e),...i})})}));g.displayName="ToolbarLink";const T=e(null),C=o.forwardRef((({type:e="single",value:a,defaultValue:s=[],onValueChange:l,disabled:i=!1,className:n="",children:d,...m},p)=>{const f=o.useContext(c);if(!f)throw new Error("Toolbar.ToggleGroup must be used within Toolbar.Root");const[h,b]=u(a,s,l),g=o.useMemo((()=>Array.isArray(h)?h:h?[h]:[]),[h]),C=o.useMemo((()=>({type:e,value:g,setValue:b,rootClass:f.rootClass,disabled:i})),[e,g,b,f.rootClass,i]);return r(T.Provider,{value:C,children:r("div",{ref:p,...m,role:"single"===e?"radiogroup":"group",className:t(f.rootClass&&`${f.rootClass}-toggle-group`,n),children:d})})}));C.displayName="ToolbarToggleGroup";const w=o.forwardRef((({value:e,disabled:a=!1,className:s="",...i},n)=>{const d=o.useContext(T);if(!d)throw new Error("Toolbar.ToggleItem must be used within Toolbar.ToggleGroup");const u=d.value.includes(e),c=a||d.disabled,p="single"===d.type?{role:"radio","aria-checked":u,"aria-pressed":void 0}:{};return r(l.Item,{children:r(m,{ref:n,pressed:u,disabled:c,onPressedChange:o=>{c||("single"!==d.type?o?d.setValue([...d.value,e]):d.setValue(d.value.filter((o=>o!==e))):d.setValue(o?[e]:[]))},className:t(d.rootClass&&`${d.rootClass}-toggle-item`,s),...p,...i})})}));w.displayName="ToolbarToggleItem";const N=o.forwardRef(((o,e)=>("production"!==process.env.NODE_ENV&&console.warn("Direct usage of Toolbar is not supported. Please use Toolbar.Root, Toolbar.Button, etc. instead."),null)));N.displayName="Toolbar",N.Root=f,N.Button=h,N.Separator=b,N.Link=g,N.ToggleGroup=C,N.ToggleItem=w;export{h as Button,g as Link,f as Root,b as Separator,C as ToggleGroup,w as ToggleItem,N as default};
|
|
@@ -8,6 +8,17 @@ interface TooltipRootProps extends React.ComponentPropsWithoutRef<'div'> {
|
|
|
8
8
|
placement?: Placement;
|
|
9
9
|
collisionBoundary?: Element | null | Array<Element | null>;
|
|
10
10
|
collisionPadding?: number;
|
|
11
|
+
/** Controlled open state. */
|
|
12
|
+
open?: boolean;
|
|
13
|
+
/** Initial open state when uncontrolled. */
|
|
14
|
+
defaultOpen?: boolean;
|
|
15
|
+
/** Called with the next open state whenever it changes. */
|
|
16
|
+
onOpenChange?: (open: boolean) => void;
|
|
17
|
+
/** Delay in ms before the tooltip opens on hover. Focus opens immediately. */
|
|
18
|
+
openDelay?: number;
|
|
19
|
+
/** Delay in ms before the tooltip closes after the pointer leaves. */
|
|
20
|
+
closeDelay?: number;
|
|
21
|
+
customRootClass?: string;
|
|
11
22
|
}
|
|
12
23
|
declare const TooltipRoot: React.ForwardRefExoticComponent<TooltipRootProps & React.RefAttributes<HTMLDivElement>>;
|
|
13
24
|
|
|
@@ -40,5 +51,5 @@ interface TooltipComponent extends React.ForwardRefExoticComponent<React.Compone
|
|
|
40
51
|
}
|
|
41
52
|
declare const Tooltip: TooltipComponent;
|
|
42
53
|
|
|
43
|
-
export { Tooltip as default };
|
|
54
|
+
export { TooltipContent as Content, TooltipRoot as Root, TooltipTrigger as Trigger, Tooltip as default };
|
|
44
55
|
export type { TooltipContentProps, TooltipRootProps, TooltipTriggerProps };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
'use client';import o,{createContext as
|
|
1
|
+
'use client';import o,{createContext as e,useRef as t,useContext as r}from"react";import{jsx as a,jsxs as n}from"react/jsx-runtime";import{E as s,D as i,p as l,o as d,f as c,e as p,i as m,v as f,m as u,j as g,n as h,k as w,u as T,I as R,w as y}from"./floating-ui.react-2kiGB4sW.js";import{u as C}from"./index-wRElCyvx.js";import{u as x,c as j}from"./useComponentClass-C0isGl1z.js";import{B as v}from"./index-FITGoHty.js";import{g as N}from"./mergeProps-0RucjqeH.js";import{P as O}from"./index-XF8itt-H.js";import{T as P}from"./ThemeContext-Sm-iNANd.js";import"react-dom";const A=e(null),D="Tooltip",b=o.forwardRef((({children:o,placement:e="top",collisionBoundary:r=null,collisionPadding:n=5,open:T,defaultOpen:R=!1,onOpenChange:y,openDelay:j=0,closeDelay:v=0,customRootClass:N="",...O},P)=>{const b=t(null),E=x(N,D),[B,S]=C(T,R,y),$=(Array.isArray(r)?r:[r]).filter((o=>null!=o)),k={padding:n,boundary:$,altBoundary:$.length>0},F=s({open:B,placement:e,strategy:"fixed",onOpenChange:S,middleware:[l({element:b,padding:4}),d(5),c({crossAxis:!0,fallbackAxisSideDirection:"start",...k}),p(k)],whileElementsMounted:i}),I=F.context,M=m(I,{move:!1,delay:{open:j,close:v},handleClose:f()}),q=u(I),z=g(I),G=h(I,{role:"tooltip"}),H=w([M,q,z,G]);return a(A.Provider,{value:{isOpen:B,setIsOpen:S,data:F,interactions:H,context:I,arrowRef:b,rootClass:E},children:a("div",{ref:P,"data-slot":"tooltip-root",...O,children:o})})}));b.displayName=D;const E=o.forwardRef((({children:o,asChild:e,...t},n)=>{const s=r(A);if(!s)throw new Error("TooltipTrigger must be used within a TooltipRoot component");const{isOpen:i,interactions:l,context:d}=s,{getReferenceProps:c}=l,p=N(o),m=T([d.refs.setReference,n,p]);return a(v,{asChild:e,ref:m,"data-slot":"tooltip-trigger","data-state":i?"open":"closed",...c(t),children:o})}));E.displayName="TooltipTrigger";const B=o.forwardRef((({children:o,showArrow:e=!0,container:t,className:s,style:i,...l},d)=>{const c=r(A),p=r(P);if(!c)throw new Error("TooltipContent must be used within a TooltipRoot component");const{isOpen:m,data:f,interactions:u,context:g,rootClass:h}=c,w=c.arrowRef,C=T([g.refs.setFloating,d]);if(!m)return null;const{getFloatingProps:x}=u,v=t??p?.portalRootRef.current??p?.containerRef.current??void 0;return a(R,{root:v,children:a(O.div,{ref:C,"data-slot":"tooltip-content","data-state":m?"open":"closed","data-side":String(f.placement??"").split("-")[0]||void 0,...x(l),className:j(h&&`${h}-floating-element`,s),style:{...i,...f.floatingStyles},children:n("div",{className:j(h&&`${h}-content-inner`),children:[e&&a(y,{className:j(h&&`${h}-arrow`),ref:w,context:g,"data-slot":"tooltip-arrow"}),o]})})})}));B.displayName="TooltipContent";const S=o.forwardRef(((o,e)=>(console.warn("Direct usage of Tooltip is not supported. Please use Tooltip.Root, Tooltip.Trigger, etc. instead."),null)));S.displayName="Tooltip",S.Root=b,S.Trigger=E,S.Content=B;export{B as Content,b as Root,E as Trigger,S as default};
|
|
@@ -45,5 +45,5 @@ type TreeComponent = React.ForwardRefExoticComponent<TreeProps & React.RefAttrib
|
|
|
45
45
|
};
|
|
46
46
|
declare const Tree: TreeComponent;
|
|
47
47
|
|
|
48
|
-
export { Tree as default };
|
|
48
|
+
export { TreeItem as Item, TreeRoot as Root, Tree as default };
|
|
49
49
|
export type { TreeElement, TreeItemProps, TreeProps, TreeRootProps };
|
package/dist/components/Tree.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use client';import{jsx as e,jsxs as
|
|
1
|
+
'use client';import{jsx as e,jsxs as t,Fragment as r}from"react/jsx-runtime";import{createContext as o,forwardRef as a,useRef as n,useImperativeHandle as l,useCallback as i,useId as s,useState as d,useContext as c,useEffect as m}from"react";import{R as u}from"./index-C7dBo_Ry.js";import{P as f}from"./index-XF8itt-H.js";import{u as p,c as h}from"./useComponentClass-C0isGl1z.js";import{B as g}from"./index-FITGoHty.js";import{K as v}from"./keyboard-BKF7hXqL.js";import"./mergeRefs-B8eZ_q-T.js";import"./mergeProps-0RucjqeH.js";import"./ThemeContext-Sm-iNANd.js";const R=o({rootClass:"",treeRef:{current:null},itemRefs:new Map,registerItemRef:()=>{},unregisterItemRef:()=>{}}),y="Tree",I=a((({children:t,className:r="",customRootClass:o="","aria-label":a,"aria-labelledby":s,loop:d=!0,onKeyDown:c,...m},g)=>{const v=n(null);l(g,(()=>v.current));const I=p(o,y),C=n(new Map),w=i(((e,t)=>{C.current.set(e,t)}),[]),b=i((e=>{C.current.delete(e)}),[]),N={rootClass:I,treeRef:v,itemRefs:C.current,registerItemRef:w,unregisterItemRef:b};return e(R.Provider,{value:N,children:e(u.Root,{orientation:"vertical",mode:"tree",loop:d,asChild:!0,children:e(u.Group,{children:e(f.div,{className:h(I,r),ref:v,role:"tree","aria-orientation":"vertical","aria-label":a,"aria-labelledby":s,onKeyDown:e=>{if(c?.(e),e.defaultPrevented||!(e=>1===e.key.length&&" "!==e.key&&!e.ctrlKey&&!e.metaKey&&!e.altKey)(e))return;const t=Array.from(C.current.values()).map((e=>e.current)).filter((e=>Boolean(e&&e.isConnected&&!e.disabled))).sort(((e,t)=>e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1));if(0===t.length)return;const r=e.key.toLowerCase(),o=t.findIndex((t=>t===e.target)),a=[...t.slice(o+1),...t.slice(0,o+1)].find((e=>(e.textContent??"").trim().toLowerCase().startsWith(r)));a&&a!==e.target&&(e.preventDefault(),a.focus())},...m,children:t})})})})}));I.displayName=y;const C=a((({children:o,item:a,level:i=0,className:f="",parentId:p=null,isSelected:y=!1,onToggleSelect:I,getIsSelected:w,onChildRefReady:b,...N},x)=>{const T=s(),j=n(null);l(x,(()=>j.current));const k=Boolean(a?.items?.length),[D,K]=d((()=>Boolean(a?.expanded))),{rootClass:L,itemRefs:P,registerItemRef:S,unregisterItemRef:$}=c(R),B=n(null);m((()=>(S(T,j),()=>{$(T)})),[T,S,$]),m((()=>{b&&j.current&&b(j)}),[b]);const O=e=>{B.current=e.current};return t(r,{children:[e(u.Item,{handleRightKeyDown:()=>{k&&(D?B.current?.focus():K(!0))},handleLeftKeyDown:()=>{if(D)return void K(!1);if(!p)return;const e=P.get(p);e?.current&&e.current.focus(),K(!1)},role:"treeitem",children:t(g,{ref:j,className:h(L&&`${L}-item`,f),onClick:()=>{I&&I(T,a),k&&K((e=>!e))},onKeyDownCapture:e=>{e.key===v.ENTER&&(I&&I(T,a),e.preventDefault(),e.stopPropagation())},type:"button","data-selected":y,"aria-selected":y,"aria-expanded":k?D:void 0,"data-toggled":D,"data-has-children":k,"data-id":T,"data-parent-id":p,"data-level":i,"aria-level":i+1,...N,children:[e("span",{className:L?`${L}-item-chevron`:void 0,"aria-hidden":!0,children:k?e("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",focusable:"false",children:e("path",{d:"M4.5 2.5L7.5 6L4.5 9.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}):null}),e("span",{className:L?`${L}-item-label`:void 0,children:o})]})}),D&&k&&e("div",{className:L?`${L}-branch`:void 0,role:"group",children:a.items.map(((t,r)=>{const o=i+1,n=!!w&&w(t);return e(C,{parentId:T,level:o,item:t,isSelected:n,onToggleSelect:I,getIsSelected:w,onChildRefReady:0===r?O:void 0,"aria-posinset":r+1,"aria-setsize":a.items.length,children:t.label},t?.id??t?.value??`${r}-${t?.label}`)}))})]})}));C.displayName="TreeItem";const w=a((({children:t,...r},o)=>(console.warn("Direct usage of Tree is not supported. Please use Tree.Root and Tree.Item instead."),e("div",{ref:o,...r,children:t}))));w.displayName="Tree",w.Root=I,w.Item=C;export{C as Item,I as Root,w as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
'use client';import{jsx as e}from"react/jsx-runtime";import{forwardRef as
|
|
1
|
+
'use client';import{jsx as e}from"react/jsx-runtime";import{forwardRef as t}from"react";import{P as s}from"./index-XF8itt-H.js";import{u as o,c as r}from"./useComponentClass-C0isGl1z.js";import"./mergeProps-0RucjqeH.js";import"./ThemeContext-Sm-iNANd.js";const i="VisuallyHidden",a={position:"absolute",width:"1px",height:"1px",margin:"-1px",border:"0",padding:"0",whiteSpace:"nowrap",clip:"rect(0 0 0 0)",clipPath:"inset(50%)",overflow:"hidden",pointerEvents:"none",userSelect:"none"},n=t((({children:t,customRootClass:n,className:p,style:m={},...l},c)=>{const d=o(n,i);return e(s.div,{ref:c,className:r(d,p),style:{...a,...m},...l,children:t})}));n.displayName=i;export{n as default};
|
|
@@ -23,22 +23,22 @@
|
|
|
23
23
|
* This source code is licensed under the ISC license.
|
|
24
24
|
* See the LICENSE file in the root directory of this source tree.
|
|
25
25
|
*/
|
|
26
|
-
var
|
|
26
|
+
var s={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};
|
|
27
27
|
/**
|
|
28
28
|
* @license lucide-react v0.575.0 - ISC
|
|
29
29
|
*
|
|
30
30
|
* This source code is licensed under the ISC license.
|
|
31
31
|
* See the LICENSE file in the root directory of this source tree.
|
|
32
|
-
*/const
|
|
32
|
+
*/const i=e=>{for(const r in e)if(r.startsWith("aria-")||"role"===r||"title"===r)return!0;return!1},a=e((({color:e="currentColor",size:o=24,strokeWidth:a=2,absoluteStrokeWidth:c,className:n="",children:l,iconNode:d,...h},u)=>r("svg",{ref:u,...s,width:o,height:o,stroke:e,strokeWidth:c?24*Number(a)/Number(o):a,className:t("lucide",n),...!l&&!i(h)&&{"aria-hidden":"true"},...h},[...d.map((([e,t])=>r(e,t))),...Array.isArray(l)?l:[l]]))),c=(s,i)=>{const c=e((({className:e,...c},n)=>{return r(a,{ref:n,iconNode:i,className:t(`lucide-${l=o(s),l.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`,`lucide-${s}`,e),...c});var l;
|
|
33
33
|
/**
|
|
34
34
|
* @license lucide-react v0.575.0 - ISC
|
|
35
35
|
*
|
|
36
36
|
* This source code is licensed under the ISC license.
|
|
37
37
|
* See the LICENSE file in the root directory of this source tree.
|
|
38
|
-
*/}));return
|
|
38
|
+
*/}));return c.displayName=o(s),c},n=c("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);
|
|
39
39
|
/**
|
|
40
40
|
* @license lucide-react v0.575.0 - ISC
|
|
41
41
|
*
|
|
42
42
|
* This source code is licensed under the ISC license.
|
|
43
43
|
* See the LICENSE file in the root directory of this source tree.
|
|
44
|
-
*/export{n as C};
|
|
44
|
+
*/export{n as C,c};
|