@sruim/nexus-design 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +195 -0
- package/dist/assets/grid.webp.js +3 -0
- package/dist/components/credits-button/index.d.ts +8 -0
- package/dist/components/credits-button/index.js +40 -0
- package/dist/components/icon/index.d.ts +7 -0
- package/dist/components/icon/index.js +32 -0
- package/dist/components/icon-button/index.d.ts +9 -0
- package/dist/components/icon-button/index.js +36 -0
- package/dist/components/img-uploader/index.d.ts +19 -0
- package/dist/components/img-uploader/index.js +107 -0
- package/dist/components/img-viewer/index.d.ts +16 -0
- package/dist/components/img-viewer/index.js +80 -0
- package/dist/components/index.d.ts +9 -0
- package/dist/components/loadable/index.d.ts +8 -0
- package/dist/components/loadable/index.js +67 -0
- package/dist/components/loading/assets/loading.webp.js +3 -0
- package/dist/components/loading/index.d.ts +16 -0
- package/dist/components/loading/index.js +85 -0
- package/dist/components/model-uploader/index.d.ts +17 -0
- package/dist/components/model-uploader/index.js +93 -0
- package/dist/components/tree/index.d.ts +14 -0
- package/dist/components/tree/index.js +50 -0
- package/dist/components/tree/node.d.ts +23 -0
- package/dist/components/tree/node.js +185 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +43 -0
- package/dist/style.css +1193 -0
- package/dist/theme.d.ts +2 -0
- package/dist/theme.js +96 -0
- package/dist/tokens/materials.d.ts +4 -0
- package/dist/tokens/materials.js +4 -0
- package/dist/tokens/nexus.d.ts +51 -0
- package/dist/tokens/nexus.js +42 -0
- package/dist/ui/avatar/index.d.ts +11 -0
- package/dist/ui/avatar/index.js +55 -0
- package/dist/ui/badge/index.d.ts +2 -0
- package/dist/ui/badge/index.js +45 -0
- package/dist/ui/button.d.ts +8 -0
- package/dist/ui/button.js +61 -0
- package/dist/ui/carousel/index.d.ts +43 -0
- package/dist/ui/carousel/index.js +186 -0
- package/dist/ui/checkbox/index.d.ts +4 -0
- package/dist/ui/checkbox/index.js +34 -0
- package/dist/ui/collapsible/index.d.ts +9 -0
- package/dist/ui/collapsible/index.js +7 -0
- package/dist/ui/dialog/confirm.d.ts +20 -0
- package/dist/ui/dialog/confirm.js +80 -0
- package/dist/ui/dialog/dialog.d.ts +26 -0
- package/dist/ui/dialog/dialog.js +97 -0
- package/dist/ui/dialog/index.d.ts +2 -0
- package/dist/ui/drawer.d.ts +22 -0
- package/dist/ui/drawer.js +98 -0
- package/dist/ui/form.d.ts +33 -0
- package/dist/ui/form.js +138 -0
- package/dist/ui/index.d.ts +24 -0
- package/dist/ui/input-otp.d.ts +14 -0
- package/dist/ui/input-otp.js +73 -0
- package/dist/ui/label.d.ts +4 -0
- package/dist/ui/label.js +32 -0
- package/dist/ui/masonry/index.d.ts +13 -0
- package/dist/ui/masonry/index.js +45 -0
- package/dist/ui/popover/index.d.ts +15 -0
- package/dist/ui/popover/index.js +78 -0
- package/dist/ui/progress.d.ts +6 -0
- package/dist/ui/progress.js +48 -0
- package/dist/ui/select/index.d.ts +21 -0
- package/dist/ui/select/index.js +127 -0
- package/dist/ui/slider/index.d.ts +9 -0
- package/dist/ui/slider/index.js +87 -0
- package/dist/ui/snap-input.d.ts +7 -0
- package/dist/ui/snap-input.js +38 -0
- package/dist/ui/sonner.d.ts +5 -0
- package/dist/ui/sonner.js +50 -0
- package/dist/ui/switch.d.ts +4 -0
- package/dist/ui/switch.js +33 -0
- package/dist/ui/table/index.d.ts +22 -0
- package/dist/ui/table/index.js +70 -0
- package/dist/ui/tabs/index.d.ts +12 -0
- package/dist/ui/tabs/index.js +60 -0
- package/dist/ui/toggle/index.d.ts +2 -0
- package/dist/ui/toggle/toggle-group.d.ts +9 -0
- package/dist/ui/toggle/toggle-group.js +54 -0
- package/dist/ui/toggle/toggle.d.ts +11 -0
- package/dist/ui/toggle/toggle.js +45 -0
- package/dist/ui/tooltip/index.d.ts +17 -0
- package/dist/ui/tooltip/index.js +68 -0
- package/dist/utils/config.d.ts +2 -0
- package/dist/utils/config.js +48 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/utils.d.ts +8 -0
- package/dist/utils/utils.js +91 -0
- package/package.json +148 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
interface Params {
|
|
3
|
+
className?: string;
|
|
4
|
+
title?: React.ReactNode;
|
|
5
|
+
description?: React.ReactNode;
|
|
6
|
+
cancel?: React.ReactNode;
|
|
7
|
+
confirm?: React.ReactNode;
|
|
8
|
+
cancelText?: string;
|
|
9
|
+
confirmText?: string;
|
|
10
|
+
onCancel?: () => void;
|
|
11
|
+
onConfirm?: () => void;
|
|
12
|
+
}
|
|
13
|
+
interface Props extends Params {
|
|
14
|
+
onClose: () => void;
|
|
15
|
+
}
|
|
16
|
+
interface IConfirm extends React.FC<Props> {
|
|
17
|
+
show: (params?: Params) => void;
|
|
18
|
+
}
|
|
19
|
+
declare const Confirm: IConfirm;
|
|
20
|
+
export { Confirm };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import '@radix-ui/react-portal';
|
|
3
|
+
import '../avatar/index.js';
|
|
4
|
+
import { cn } from '../../utils/config.js';
|
|
5
|
+
import { Button } from '../button.js';
|
|
6
|
+
import '../carousel/index.js';
|
|
7
|
+
import '../checkbox/index.js';
|
|
8
|
+
import '../collapsible/index.js';
|
|
9
|
+
import { Dialog } from './dialog.js';
|
|
10
|
+
import '../drawer.js';
|
|
11
|
+
import '../form.js';
|
|
12
|
+
import '../input-otp.js';
|
|
13
|
+
import '../label.js';
|
|
14
|
+
import 'react';
|
|
15
|
+
import '../popover/index.js';
|
|
16
|
+
import '../progress.js';
|
|
17
|
+
import '../select/index.js';
|
|
18
|
+
import '../slider/index.js';
|
|
19
|
+
import '../sonner.js';
|
|
20
|
+
import '../switch.js';
|
|
21
|
+
import '../table/index.js';
|
|
22
|
+
import '../tabs/index.js';
|
|
23
|
+
import '../toggle/toggle.js';
|
|
24
|
+
import '../toggle/toggle-group.js';
|
|
25
|
+
import '../tooltip/index.js';
|
|
26
|
+
import { Icon } from '../../components/icon/index.js';
|
|
27
|
+
import '../../components/img-uploader/index.js';
|
|
28
|
+
import '../../components/img-viewer/index.js';
|
|
29
|
+
import '../../components/loading/index.js';
|
|
30
|
+
import '../../components/model-uploader/index.js';
|
|
31
|
+
import { FrostGlass } from '../../tokens/materials.js';
|
|
32
|
+
|
|
33
|
+
const Confirm = ({
|
|
34
|
+
className,
|
|
35
|
+
title,
|
|
36
|
+
description,
|
|
37
|
+
cancel,
|
|
38
|
+
confirm,
|
|
39
|
+
cancelText,
|
|
40
|
+
confirmText,
|
|
41
|
+
onCancel,
|
|
42
|
+
onConfirm,
|
|
43
|
+
onClose
|
|
44
|
+
}) => {
|
|
45
|
+
const handleCancel = async () => {
|
|
46
|
+
try {
|
|
47
|
+
await onCancel?.();
|
|
48
|
+
} finally {
|
|
49
|
+
onClose();
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
const handleConfirm = async () => {
|
|
53
|
+
try {
|
|
54
|
+
await onConfirm?.();
|
|
55
|
+
} finally {
|
|
56
|
+
onClose();
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("w-95 p-4 rounded-6 relative", FrostGlass, className), children: [
|
|
60
|
+
/* @__PURE__ */ jsx(
|
|
61
|
+
Icon,
|
|
62
|
+
{
|
|
63
|
+
icon: "i-nexus-close-monotone",
|
|
64
|
+
className: "absolute right-4 top-4 size-5 cursor-pointer text-text-secondary",
|
|
65
|
+
onClick: handleCancel
|
|
66
|
+
}
|
|
67
|
+
),
|
|
68
|
+
/* @__PURE__ */ jsx("h3", { className: "mb-4 mt-6 text-center text-4.5 text-text-primary", children: title }),
|
|
69
|
+
/* @__PURE__ */ jsx("div", { className: "text-center text-4 text-text-secondary", children: description }),
|
|
70
|
+
/* @__PURE__ */ jsxs("div", { className: "mt-6 flex gap-4", children: [
|
|
71
|
+
cancel ? cancel : /* @__PURE__ */ jsx(Button, { variant: "plain", className: "flex-1 font-bold", onClick: handleCancel, children: cancelText }),
|
|
72
|
+
confirm ? confirm : /* @__PURE__ */ jsx(Button, { variant: "solid", className: "flex-1 font-bold", onClick: handleConfirm, children: confirmText })
|
|
73
|
+
] })
|
|
74
|
+
] });
|
|
75
|
+
};
|
|
76
|
+
Confirm.show = (params) => {
|
|
77
|
+
const close = Dialog.show(/* @__PURE__ */ jsx(Confirm, { ...params, onClose: () => close() }));
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export { Confirm };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as D from '@radix-ui/react-dialog';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
declare const Overlay: React.ForwardRefExoticComponent<D.DialogOverlayProps & React.RefAttributes<HTMLDivElement>>;
|
|
4
|
+
declare const Content: React.ForwardRefExoticComponent<D.DialogContentProps & React.RefAttributes<HTMLDivElement>>;
|
|
5
|
+
interface Props {
|
|
6
|
+
overlayClassName?: string;
|
|
7
|
+
}
|
|
8
|
+
interface TDialog extends React.FC<D.DialogContentProps & D.DialogProps & Props> {
|
|
9
|
+
Root: typeof D.Root;
|
|
10
|
+
Portal: typeof D.Portal;
|
|
11
|
+
Trigger: typeof D.Trigger;
|
|
12
|
+
Overlay: typeof Overlay;
|
|
13
|
+
Content: typeof Content;
|
|
14
|
+
show: (dialog: React.ReactNode, params?: Omit<D.DialogContentProps & D.DialogProps, 'open' | 'defaultOpen'> & Props) => () => void;
|
|
15
|
+
}
|
|
16
|
+
declare const Dialog: TDialog;
|
|
17
|
+
declare const open: unique symbol;
|
|
18
|
+
declare const close: unique symbol;
|
|
19
|
+
declare global {
|
|
20
|
+
interface Window {
|
|
21
|
+
[open]: (key: number, dialog: React.ReactNode) => void;
|
|
22
|
+
[close]: (key: number) => void;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export declare const Dialoger: React.FC;
|
|
26
|
+
export { Dialog };
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import { DeepGlass } from '../../tokens/materials.js';
|
|
3
|
+
import { cn } from '../../utils/config.js';
|
|
4
|
+
import { sleep } from '../../utils/utils.js';
|
|
5
|
+
import * as D from '@radix-ui/react-dialog';
|
|
6
|
+
import { VisuallyHidden } from '@radix-ui/react-visually-hidden';
|
|
7
|
+
import * as React from 'react';
|
|
8
|
+
|
|
9
|
+
const AnimationBaseStyle = "duration-slow ease-smooth data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=closed]:animate-out data-[state=closed]:fade-out-0";
|
|
10
|
+
const AnimationInStyle = "data-[state=open]:zoom-in-95 data-[state=open]:slide-in-l-1/2 data-[state=open]:slide-in-t-2";
|
|
11
|
+
const AnimationOutStyle = "data-[state=closed]:zoom-out-95 data-[state=closed]:slide-out-l-1/2 data-[state=closed]:slide-out-t-2";
|
|
12
|
+
const Overlay = React.forwardRef(
|
|
13
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
14
|
+
D.Overlay,
|
|
15
|
+
{
|
|
16
|
+
ref,
|
|
17
|
+
className: cn("fixed inset-0 z-50", DeepGlass, AnimationBaseStyle, className),
|
|
18
|
+
...props
|
|
19
|
+
}
|
|
20
|
+
)
|
|
21
|
+
);
|
|
22
|
+
Overlay.displayName = D.Overlay.displayName;
|
|
23
|
+
const BaseStyle = "outline-none z-50 fixed left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 h-full flex flex-col justify-center";
|
|
24
|
+
const Content = React.forwardRef(
|
|
25
|
+
({ className, children, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
26
|
+
D.Content,
|
|
27
|
+
{
|
|
28
|
+
"aria-describedby": void 0,
|
|
29
|
+
ref,
|
|
30
|
+
className: cn(BaseStyle, AnimationBaseStyle, AnimationInStyle, AnimationOutStyle, className),
|
|
31
|
+
...props,
|
|
32
|
+
children
|
|
33
|
+
}
|
|
34
|
+
)
|
|
35
|
+
);
|
|
36
|
+
Content.displayName = D.Content.displayName;
|
|
37
|
+
const Dialog = ({
|
|
38
|
+
open: open2 = true,
|
|
39
|
+
defaultOpen,
|
|
40
|
+
onOpenChange,
|
|
41
|
+
modal,
|
|
42
|
+
overlayClassName,
|
|
43
|
+
...props
|
|
44
|
+
}) => {
|
|
45
|
+
return /* @__PURE__ */ jsx(D.Root, { open: open2, defaultOpen, onOpenChange, modal, children: /* @__PURE__ */ jsxs(D.Portal, { children: [
|
|
46
|
+
/* @__PURE__ */ jsx(Overlay, { className: overlayClassName }),
|
|
47
|
+
/* @__PURE__ */ jsx(VisuallyHidden, { children: /* @__PURE__ */ jsx(D.Title, {}) }),
|
|
48
|
+
/* @__PURE__ */ jsx(Content, { ...props })
|
|
49
|
+
] }) });
|
|
50
|
+
};
|
|
51
|
+
Dialog.Root = D.Root;
|
|
52
|
+
Dialog.Portal = D.Portal;
|
|
53
|
+
Dialog.Overlay = Overlay;
|
|
54
|
+
Dialog.Content = Content;
|
|
55
|
+
Dialog.Trigger = D.Trigger;
|
|
56
|
+
const open = Symbol.for("open");
|
|
57
|
+
const close = Symbol.for("close");
|
|
58
|
+
const Dialoger = () => {
|
|
59
|
+
const [data, setData] = React.useState({});
|
|
60
|
+
const openDialog = (key, dialog) => {
|
|
61
|
+
if (!dialog) return;
|
|
62
|
+
setData({ ...data, [key]: dialog });
|
|
63
|
+
};
|
|
64
|
+
const closeDialog = (key) => {
|
|
65
|
+
if (data[key]) {
|
|
66
|
+
delete data[key];
|
|
67
|
+
setData({ ...data });
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
if (globalThis.window) {
|
|
71
|
+
globalThis.window[open] = openDialog;
|
|
72
|
+
globalThis.window[close] = closeDialog;
|
|
73
|
+
}
|
|
74
|
+
return /* @__PURE__ */ jsx(Fragment, { children: Object.values(data) });
|
|
75
|
+
};
|
|
76
|
+
Dialog.show = (dialog, params) => {
|
|
77
|
+
if (window === void 0) {
|
|
78
|
+
console.warn("Dialog.show is not supported in Server Side");
|
|
79
|
+
return () => Promise.resolve();
|
|
80
|
+
}
|
|
81
|
+
const key = Date.now();
|
|
82
|
+
window[open](
|
|
83
|
+
key,
|
|
84
|
+
/* @__PURE__ */ jsx(Dialog, { ...params, open: true, children: dialog }, key)
|
|
85
|
+
);
|
|
86
|
+
return () => {
|
|
87
|
+
window[open](
|
|
88
|
+
key,
|
|
89
|
+
/* @__PURE__ */ jsx(Dialog, { ...params, open: false, children: dialog }, key)
|
|
90
|
+
);
|
|
91
|
+
sleep(150).then(() => {
|
|
92
|
+
window[close](key);
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export { Dialog, Dialoger };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Drawer as DrawerPrimitive } from 'vaul';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
declare const Drawer: {
|
|
4
|
+
({ shouldScaleBackground, ...props }: React.ComponentProps<typeof DrawerPrimitive.Root>): import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
displayName: string;
|
|
6
|
+
Content: React.ForwardRefExoticComponent<Omit<Omit<import('@radix-ui/react-dialog').DialogContentProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
7
|
+
Title: React.ForwardRefExoticComponent<Omit<import('@radix-ui/react-dialog').DialogTitleProps & React.RefAttributes<HTMLHeadingElement>, "ref"> & React.RefAttributes<HTMLHeadingElement>>;
|
|
8
|
+
Description: React.ForwardRefExoticComponent<Omit<import('@radix-ui/react-dialog').DialogDescriptionProps & React.RefAttributes<HTMLParagraphElement>, "ref"> & React.RefAttributes<HTMLParagraphElement>>;
|
|
9
|
+
Footer: {
|
|
10
|
+
({ className, ...props }: React.HTMLAttributes<HTMLDivElement>): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
displayName: string;
|
|
12
|
+
};
|
|
13
|
+
Header: {
|
|
14
|
+
({ className, ...props }: React.HTMLAttributes<HTMLDivElement>): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
displayName: string;
|
|
16
|
+
};
|
|
17
|
+
Overlay: React.ForwardRefExoticComponent<Omit<Omit<import('@radix-ui/react-dialog').DialogOverlayProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
18
|
+
Portal: typeof import('vaul').Portal;
|
|
19
|
+
Trigger: React.ForwardRefExoticComponent<import('@radix-ui/react-dialog').DialogTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
20
|
+
Close: React.ForwardRefExoticComponent<import('@radix-ui/react-dialog').DialogCloseProps & React.RefAttributes<HTMLButtonElement>>;
|
|
21
|
+
};
|
|
22
|
+
export { Drawer };
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import { DeepGlass, FrostGlass } from '../tokens/materials.js';
|
|
3
|
+
import { cn } from '../utils/config.js';
|
|
4
|
+
import '@radix-ui/react-portal';
|
|
5
|
+
import './avatar/index.js';
|
|
6
|
+
import './button.js';
|
|
7
|
+
import './carousel/index.js';
|
|
8
|
+
import './checkbox/index.js';
|
|
9
|
+
import './collapsible/index.js';
|
|
10
|
+
import './dialog/confirm.js';
|
|
11
|
+
import './dialog/dialog.js';
|
|
12
|
+
import './form.js';
|
|
13
|
+
import './input-otp.js';
|
|
14
|
+
import './label.js';
|
|
15
|
+
import * as React from 'react';
|
|
16
|
+
import './popover/index.js';
|
|
17
|
+
import './progress.js';
|
|
18
|
+
import './select/index.js';
|
|
19
|
+
import './slider/index.js';
|
|
20
|
+
import './sonner.js';
|
|
21
|
+
import './switch.js';
|
|
22
|
+
import './table/index.js';
|
|
23
|
+
import './tabs/index.js';
|
|
24
|
+
import './toggle/toggle.js';
|
|
25
|
+
import './toggle/toggle-group.js';
|
|
26
|
+
import './tooltip/index.js';
|
|
27
|
+
import { Drawer as Drawer$1 } from 'vaul';
|
|
28
|
+
|
|
29
|
+
const Drawer = ({
|
|
30
|
+
shouldScaleBackground = true,
|
|
31
|
+
...props
|
|
32
|
+
}) => /* @__PURE__ */ jsx(Drawer$1.Root, { shouldScaleBackground, ...props });
|
|
33
|
+
Drawer.displayName = "Drawer";
|
|
34
|
+
const DrawerTrigger = Drawer$1.Trigger;
|
|
35
|
+
const DrawerPortal = Drawer$1.Portal;
|
|
36
|
+
const DrawerClose = Drawer$1.Close;
|
|
37
|
+
const DrawerOverlay = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
38
|
+
Drawer$1.Overlay,
|
|
39
|
+
{
|
|
40
|
+
ref,
|
|
41
|
+
className: cn("fixed inset-0 z-50 duration-slow ease-smooth", DeepGlass, className),
|
|
42
|
+
...props
|
|
43
|
+
}
|
|
44
|
+
));
|
|
45
|
+
DrawerOverlay.displayName = Drawer$1.Overlay.displayName;
|
|
46
|
+
const DrawerContent = React.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(DrawerPortal, { children: [
|
|
47
|
+
/* @__PURE__ */ jsx(DrawerOverlay, {}),
|
|
48
|
+
/* @__PURE__ */ jsxs(
|
|
49
|
+
Drawer$1.Content,
|
|
50
|
+
{
|
|
51
|
+
ref,
|
|
52
|
+
className: cn(
|
|
53
|
+
"fixed inset-x-0 bottom-0 z-50 mt-24 flex h-auto flex-col rounded-t-[10px] border border-border-subtle duration-slow ease-smooth",
|
|
54
|
+
FrostGlass,
|
|
55
|
+
className
|
|
56
|
+
),
|
|
57
|
+
...props,
|
|
58
|
+
children: [
|
|
59
|
+
/* @__PURE__ */ jsx("div", { className: "mx-auto mt-4 h-2 w-[100px] rounded-full bg-surface-dim" }),
|
|
60
|
+
children
|
|
61
|
+
]
|
|
62
|
+
}
|
|
63
|
+
)
|
|
64
|
+
] }));
|
|
65
|
+
DrawerContent.displayName = "DrawerContent";
|
|
66
|
+
const DrawerHeader = ({ className, ...props }) => /* @__PURE__ */ jsx("div", { className: cn("grid gap-1.5 p-4 text-center sm:text-left", className), ...props });
|
|
67
|
+
DrawerHeader.displayName = "DrawerHeader";
|
|
68
|
+
const DrawerFooter = ({ className, ...props }) => /* @__PURE__ */ jsx("div", { className: cn("mt-auto flex flex-col gap-2 p-4", className), ...props });
|
|
69
|
+
DrawerFooter.displayName = "DrawerFooter";
|
|
70
|
+
const DrawerTitle = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
71
|
+
Drawer$1.Title,
|
|
72
|
+
{
|
|
73
|
+
ref,
|
|
74
|
+
className: cn("text-lg font-semibold leading-none tracking-tight", className),
|
|
75
|
+
...props
|
|
76
|
+
}
|
|
77
|
+
));
|
|
78
|
+
DrawerTitle.displayName = Drawer$1.Title.displayName;
|
|
79
|
+
const DrawerDescription = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
80
|
+
Drawer$1.Description,
|
|
81
|
+
{
|
|
82
|
+
ref,
|
|
83
|
+
className: cn("text-sm text-muted-foreground", className),
|
|
84
|
+
...props
|
|
85
|
+
}
|
|
86
|
+
));
|
|
87
|
+
DrawerDescription.displayName = Drawer$1.Description.displayName;
|
|
88
|
+
Drawer.Content = DrawerContent;
|
|
89
|
+
Drawer.Title = DrawerTitle;
|
|
90
|
+
Drawer.Description = DrawerDescription;
|
|
91
|
+
Drawer.Footer = DrawerFooter;
|
|
92
|
+
Drawer.Header = DrawerHeader;
|
|
93
|
+
Drawer.Overlay = DrawerOverlay;
|
|
94
|
+
Drawer.Portal = DrawerPortal;
|
|
95
|
+
Drawer.Trigger = DrawerTrigger;
|
|
96
|
+
Drawer.Close = DrawerClose;
|
|
97
|
+
|
|
98
|
+
export { Drawer };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useFormContext, ControllerProps, FieldPath, FieldValues, UseFormProps, UseFormReturn } from 'react-hook-form';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import type * as LabelPrimitive from '@radix-ui/react-label';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
declare const useFormField: () => {
|
|
6
|
+
invalid: boolean;
|
|
7
|
+
isDirty: boolean;
|
|
8
|
+
isTouched: boolean;
|
|
9
|
+
isValidating: boolean;
|
|
10
|
+
error?: import('react-hook-form').FieldError;
|
|
11
|
+
id: string;
|
|
12
|
+
name: string;
|
|
13
|
+
formItemId: string;
|
|
14
|
+
formDescriptionId: string;
|
|
15
|
+
formMessageId: string;
|
|
16
|
+
};
|
|
17
|
+
interface FormProps<T extends FieldValues> extends React.FormHTMLAttributes<HTMLFormElement> {
|
|
18
|
+
form: UseFormReturn<T>;
|
|
19
|
+
}
|
|
20
|
+
declare const Form: {
|
|
21
|
+
<T extends FieldValues>({ form, children, ...props }: FormProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
Item: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
23
|
+
Field: <TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ ...props }: ControllerProps<TFieldValues, TName>) => import("react/jsx-runtime").JSX.Element;
|
|
24
|
+
Label: React.ForwardRefExoticComponent<Omit<LabelPrimitive.LabelProps & React.RefAttributes<HTMLLabelElement>, "ref"> & React.RefAttributes<HTMLLabelElement>>;
|
|
25
|
+
Control: React.ForwardRefExoticComponent<Omit<import('@radix-ui/react-slot').SlotProps & React.RefAttributes<HTMLElement>, "ref"> & React.RefAttributes<HTMLElement>>;
|
|
26
|
+
Description: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLParagraphElement> & React.RefAttributes<HTMLParagraphElement>>;
|
|
27
|
+
Message: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLParagraphElement> & React.RefAttributes<HTMLParagraphElement>>;
|
|
28
|
+
};
|
|
29
|
+
declare const useForm: <T extends FieldValues>(fn: (_z: typeof z) => Omit<UseFormProps<T>, "resolver"> & {
|
|
30
|
+
resolver: z.ZodSchema<T>;
|
|
31
|
+
}, deps?: React.DependencyList) => UseFormReturn<T, any, T>;
|
|
32
|
+
export { Form, useForm, useFormContext, useFormField };
|
|
33
|
+
export type { UseFormReturn };
|
package/dist/ui/form.js
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { Label } from './label.js';
|
|
3
|
+
import { cn } from '../utils/config.js';
|
|
4
|
+
import '@radix-ui/react-portal';
|
|
5
|
+
import './avatar/index.js';
|
|
6
|
+
import './button.js';
|
|
7
|
+
import './carousel/index.js';
|
|
8
|
+
import './checkbox/index.js';
|
|
9
|
+
import './collapsible/index.js';
|
|
10
|
+
import './dialog/confirm.js';
|
|
11
|
+
import './dialog/dialog.js';
|
|
12
|
+
import './drawer.js';
|
|
13
|
+
import './input-otp.js';
|
|
14
|
+
import * as React from 'react';
|
|
15
|
+
import './popover/index.js';
|
|
16
|
+
import './progress.js';
|
|
17
|
+
import './select/index.js';
|
|
18
|
+
import './slider/index.js';
|
|
19
|
+
import './sonner.js';
|
|
20
|
+
import './switch.js';
|
|
21
|
+
import './table/index.js';
|
|
22
|
+
import './tabs/index.js';
|
|
23
|
+
import './toggle/toggle.js';
|
|
24
|
+
import './toggle/toggle-group.js';
|
|
25
|
+
import './tooltip/index.js';
|
|
26
|
+
import { zodResolver } from '@hookform/resolvers/zod';
|
|
27
|
+
import { Slot } from '@radix-ui/react-slot';
|
|
28
|
+
import { useFormContext, FormProvider, useForm as useForm$1, Controller } from 'react-hook-form';
|
|
29
|
+
export { useFormContext } from 'react-hook-form';
|
|
30
|
+
import { z } from 'zod';
|
|
31
|
+
|
|
32
|
+
const FormFieldContext = React.createContext({});
|
|
33
|
+
const FormField = ({
|
|
34
|
+
...props
|
|
35
|
+
}) => {
|
|
36
|
+
return /* @__PURE__ */ jsx(FormFieldContext.Provider, { value: { name: props.name }, children: /* @__PURE__ */ jsx(Controller, { ...props }) });
|
|
37
|
+
};
|
|
38
|
+
const FormItemContext = React.createContext({});
|
|
39
|
+
const useFormField = () => {
|
|
40
|
+
const fieldContext = React.useContext(FormFieldContext);
|
|
41
|
+
const itemContext = React.useContext(FormItemContext);
|
|
42
|
+
const { getFieldState, formState } = useFormContext();
|
|
43
|
+
const fieldState = getFieldState(fieldContext.name, formState);
|
|
44
|
+
if (!fieldContext) {
|
|
45
|
+
throw new Error("useFormField should be used within <FormField>");
|
|
46
|
+
}
|
|
47
|
+
const { id } = itemContext;
|
|
48
|
+
return {
|
|
49
|
+
id,
|
|
50
|
+
name: fieldContext.name,
|
|
51
|
+
formItemId: `${id}-form-item`,
|
|
52
|
+
formDescriptionId: `${id}-form-item-description`,
|
|
53
|
+
formMessageId: `${id}-form-item-message`,
|
|
54
|
+
...fieldState
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
const FormItem = React.forwardRef(
|
|
58
|
+
({ className, ...props }, ref) => {
|
|
59
|
+
const id = React.useId();
|
|
60
|
+
return /* @__PURE__ */ jsx(FormItemContext.Provider, { value: { id }, children: /* @__PURE__ */ jsx("div", { ref, className: cn("space-y-2", className), ...props }) });
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
FormItem.displayName = "FormItem";
|
|
64
|
+
const FormLabel = React.forwardRef(({ className, ...props }, ref) => {
|
|
65
|
+
const { error, formItemId } = useFormField();
|
|
66
|
+
return /* @__PURE__ */ jsx(
|
|
67
|
+
Label,
|
|
68
|
+
{
|
|
69
|
+
ref,
|
|
70
|
+
className: cn(error && "text-status-error", className),
|
|
71
|
+
htmlFor: formItemId,
|
|
72
|
+
...props
|
|
73
|
+
}
|
|
74
|
+
);
|
|
75
|
+
});
|
|
76
|
+
FormLabel.displayName = "FormLabel";
|
|
77
|
+
const FormControl = React.forwardRef(({ ...props }, ref) => {
|
|
78
|
+
const { error, formItemId, formDescriptionId, formMessageId } = useFormField();
|
|
79
|
+
return /* @__PURE__ */ jsx(
|
|
80
|
+
Slot,
|
|
81
|
+
{
|
|
82
|
+
ref,
|
|
83
|
+
id: formItemId,
|
|
84
|
+
"aria-describedby": !error ? `${formDescriptionId}` : `${formDescriptionId} ${formMessageId}`,
|
|
85
|
+
"aria-invalid": !!error,
|
|
86
|
+
...props
|
|
87
|
+
}
|
|
88
|
+
);
|
|
89
|
+
});
|
|
90
|
+
FormControl.displayName = "FormControl";
|
|
91
|
+
const FormDescription = React.forwardRef(({ className, ...props }, ref) => {
|
|
92
|
+
const { formDescriptionId } = useFormField();
|
|
93
|
+
return /* @__PURE__ */ jsx(
|
|
94
|
+
"p",
|
|
95
|
+
{
|
|
96
|
+
ref,
|
|
97
|
+
id: formDescriptionId,
|
|
98
|
+
className: cn("text-sm text-text-secondary", className),
|
|
99
|
+
...props
|
|
100
|
+
}
|
|
101
|
+
);
|
|
102
|
+
});
|
|
103
|
+
FormDescription.displayName = "FormDescription";
|
|
104
|
+
const FormMessage = React.forwardRef(({ className, children, ...props }, ref) => {
|
|
105
|
+
const { error, formMessageId } = useFormField();
|
|
106
|
+
const body = error ? String(error?.message ?? "") : children;
|
|
107
|
+
if (!body) return null;
|
|
108
|
+
return /* @__PURE__ */ jsx(
|
|
109
|
+
"p",
|
|
110
|
+
{
|
|
111
|
+
ref,
|
|
112
|
+
id: formMessageId,
|
|
113
|
+
className: cn("text-status-error text-2.5", className),
|
|
114
|
+
...props,
|
|
115
|
+
children: body
|
|
116
|
+
}
|
|
117
|
+
);
|
|
118
|
+
});
|
|
119
|
+
FormMessage.displayName = "FormMessage";
|
|
120
|
+
const Form = ({ form, children, ...props }) => /* @__PURE__ */ jsx(FormProvider, { ...form, children: /* @__PURE__ */ jsx("form", { ...props, children }) });
|
|
121
|
+
Form.Item = FormItem;
|
|
122
|
+
Form.Field = FormField;
|
|
123
|
+
Form.Label = FormLabel;
|
|
124
|
+
Form.Control = FormControl;
|
|
125
|
+
Form.Description = FormDescription;
|
|
126
|
+
Form.Message = FormMessage;
|
|
127
|
+
const useForm = (fn, deps = []) => {
|
|
128
|
+
const formSchema = React.useMemo(() => {
|
|
129
|
+
const params = fn(z);
|
|
130
|
+
return {
|
|
131
|
+
...params,
|
|
132
|
+
resolver: zodResolver(params.resolver)
|
|
133
|
+
};
|
|
134
|
+
}, deps);
|
|
135
|
+
return useForm$1(formSchema);
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
export { Form, useForm, useFormField };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export * from '@radix-ui/react-portal';
|
|
2
|
+
export * from './avatar';
|
|
3
|
+
export * from './badge';
|
|
4
|
+
export * from './button';
|
|
5
|
+
export * from './carousel';
|
|
6
|
+
export * from './checkbox';
|
|
7
|
+
export * from './collapsible';
|
|
8
|
+
export * from './dialog';
|
|
9
|
+
export * from './drawer';
|
|
10
|
+
export * from './form';
|
|
11
|
+
export * from './input-otp';
|
|
12
|
+
export * from './label';
|
|
13
|
+
export * from './masonry';
|
|
14
|
+
export * from './popover';
|
|
15
|
+
export * from './progress';
|
|
16
|
+
export * from './select';
|
|
17
|
+
export * from './slider';
|
|
18
|
+
export * from './snap-input';
|
|
19
|
+
export * from './sonner';
|
|
20
|
+
export * from './switch';
|
|
21
|
+
export * from './table';
|
|
22
|
+
export * from './tabs';
|
|
23
|
+
export * from './toggle';
|
|
24
|
+
export * from './tooltip';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { OTPInput } from 'input-otp';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
interface InputOTPComponent extends React.FC<React.ComponentPropsWithoutRef<typeof OTPInput>> {
|
|
4
|
+
Group: typeof InputOTPGroup;
|
|
5
|
+
Slot: typeof InputOTPSlot;
|
|
6
|
+
Separator: typeof InputOTPSeparator;
|
|
7
|
+
}
|
|
8
|
+
declare const InputOTP: InputOTPComponent & typeof OTPInput;
|
|
9
|
+
declare const InputOTPGroup: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
10
|
+
declare const InputOTPSlot: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & {
|
|
11
|
+
index: number;
|
|
12
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
13
|
+
declare const InputOTPSeparator: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
14
|
+
export { InputOTP };
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import { OTPInput, OTPInputContext } from 'input-otp';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { cn } from '../utils/config.js';
|
|
5
|
+
import '@radix-ui/react-portal';
|
|
6
|
+
import './avatar/index.js';
|
|
7
|
+
import './button.js';
|
|
8
|
+
import './carousel/index.js';
|
|
9
|
+
import './checkbox/index.js';
|
|
10
|
+
import './collapsible/index.js';
|
|
11
|
+
import './dialog/confirm.js';
|
|
12
|
+
import './dialog/dialog.js';
|
|
13
|
+
import './drawer.js';
|
|
14
|
+
import './form.js';
|
|
15
|
+
import './label.js';
|
|
16
|
+
import './popover/index.js';
|
|
17
|
+
import './progress.js';
|
|
18
|
+
import './select/index.js';
|
|
19
|
+
import './slider/index.js';
|
|
20
|
+
import './sonner.js';
|
|
21
|
+
import './switch.js';
|
|
22
|
+
import './table/index.js';
|
|
23
|
+
import './tabs/index.js';
|
|
24
|
+
import './toggle/toggle.js';
|
|
25
|
+
import './toggle/toggle-group.js';
|
|
26
|
+
import './tooltip/index.js';
|
|
27
|
+
|
|
28
|
+
const InputOTP = React.forwardRef(({ containerClassName, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
29
|
+
OTPInput,
|
|
30
|
+
{
|
|
31
|
+
ref,
|
|
32
|
+
containerClassName: cn(
|
|
33
|
+
"flex items-center gap-2 has-[:disabled]:opacity-50",
|
|
34
|
+
containerClassName
|
|
35
|
+
),
|
|
36
|
+
...props
|
|
37
|
+
}
|
|
38
|
+
));
|
|
39
|
+
InputOTP.displayName = "InputOTP";
|
|
40
|
+
const InputOTPGroup = React.forwardRef(
|
|
41
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: cn("flex items-center", className), ...props })
|
|
42
|
+
);
|
|
43
|
+
InputOTPGroup.displayName = "InputOTPGroup";
|
|
44
|
+
const InputOTPSlot = React.forwardRef(({ index, className, ...props }, ref) => {
|
|
45
|
+
const inputOTPContext = React.useContext(OTPInputContext);
|
|
46
|
+
const { char, hasFakeCaret, isActive } = inputOTPContext.slots[index];
|
|
47
|
+
return /* @__PURE__ */ jsxs(
|
|
48
|
+
"div",
|
|
49
|
+
{
|
|
50
|
+
ref,
|
|
51
|
+
className: cn(
|
|
52
|
+
"relative mr-4 flex size-10 items-center justify-center border border-border-subtle rounded-3 text-3 transition-all duration-fast ease-smooth last:mr-0",
|
|
53
|
+
isActive && "z-10 ring-2 ring-border-focus ring-offset-background",
|
|
54
|
+
className
|
|
55
|
+
),
|
|
56
|
+
...props,
|
|
57
|
+
children: [
|
|
58
|
+
char,
|
|
59
|
+
hasFakeCaret && /* @__PURE__ */ jsx("div", { className: "pointer-events-none absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ jsx("div", { className: "h-4 w-px bg-text-primary duration-1000" }) })
|
|
60
|
+
]
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
});
|
|
64
|
+
InputOTPSlot.displayName = "InputOTPSlot";
|
|
65
|
+
const InputOTPSeparator = React.forwardRef(
|
|
66
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, role: "separator", ...props, children: /* @__PURE__ */ jsx("div", { className: cn("size-2 rounded-1/2 bg-surface-dim", className) }) })
|
|
67
|
+
);
|
|
68
|
+
InputOTPSeparator.displayName = "InputOTPSeparator";
|
|
69
|
+
InputOTP.Group = InputOTPGroup;
|
|
70
|
+
InputOTP.Slot = InputOTPSlot;
|
|
71
|
+
InputOTP.Separator = InputOTPSeparator;
|
|
72
|
+
|
|
73
|
+
export { InputOTP };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import * as LabelPrimitive from '@radix-ui/react-label';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
declare const Label: React.ForwardRefExoticComponent<Omit<LabelPrimitive.LabelProps & React.RefAttributes<HTMLLabelElement>, "ref"> & React.RefAttributes<HTMLLabelElement>>;
|
|
4
|
+
export { Label };
|