@hexclave/ui 1.0.2 → 1.0.5
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/copy-button.d.ts +1 -1
- package/dist/components/simple-tooltip.js +2 -2
- package/dist/components/simple-tooltip.js.map +1 -1
- package/dist/components/ui/badge.d.ts +2 -2
- package/dist/components/ui/button.d.ts +2 -2
- package/dist/components/ui/form.d.ts +1 -1
- package/dist/components/ui/form.d.ts.map +1 -1
- package/dist/components/ui/resizable.d.ts +1 -1
- package/dist/components/ui/resizable.d.ts.map +1 -1
- package/dist/components/ui/typography.d.ts +1 -1
- package/dist/esm/components/copy-button.d.ts +1 -1
- package/dist/esm/components/simple-tooltip.js +3 -3
- package/dist/esm/components/simple-tooltip.js.map +1 -1
- package/dist/esm/components/ui/badge.d.ts +2 -2
- package/dist/esm/components/ui/button.d.ts +2 -2
- package/dist/esm/components/ui/form.d.ts +1 -1
- package/dist/esm/components/ui/form.d.ts.map +1 -1
- package/dist/esm/components/ui/resizable.d.ts +1 -1
- package/dist/esm/components/ui/resizable.d.ts.map +1 -1
- package/dist/esm/components/ui/typography.d.ts +1 -1
- package/package.json +3 -2
- package/src/components/action-dialog.tsx +135 -0
- package/src/components/brand-icons.tsx +276 -0
- package/src/components/browser-frame/LICENSE +3 -0
- package/src/components/browser-frame/index.tsx +51 -0
- package/src/components/copy-button.tsx +36 -0
- package/src/components/copy-field.tsx +52 -0
- package/src/components/data-table/cells.tsx +133 -0
- package/src/components/data-table/column-header.tsx +52 -0
- package/src/components/data-table/data-table.tsx +318 -0
- package/src/components/data-table/faceted-filter.tsx +138 -0
- package/src/components/data-table/index.tsx +9 -0
- package/src/components/data-table/pagination.tsx +76 -0
- package/src/components/data-table/toolbar-items.tsx +13 -0
- package/src/components/data-table/toolbar.tsx +100 -0
- package/src/components/data-table/utils.tsx +7 -0
- package/src/components/data-table/view-options.tsx +64 -0
- package/src/components/simple-tooltip.tsx +48 -0
- package/src/components/ui/accordion.tsx +58 -0
- package/src/components/ui/alert.tsx +60 -0
- package/src/components/ui/aspect-ratio.tsx +7 -0
- package/src/components/ui/avatar.tsx +51 -0
- package/src/components/ui/badge.tsx +36 -0
- package/src/components/ui/breadcrumb.tsx +116 -0
- package/src/components/ui/button.tsx +95 -0
- package/src/components/ui/calendar.tsx +77 -0
- package/src/components/ui/card.tsx +88 -0
- package/src/components/ui/checkbox.tsx +31 -0
- package/src/components/ui/collapsible.tsx +11 -0
- package/src/components/ui/command.tsx +159 -0
- package/src/components/ui/context-menu.tsx +205 -0
- package/src/components/ui/dialog.tsx +135 -0
- package/src/components/ui/dropdown-menu.tsx +245 -0
- package/src/components/ui/form.tsx +173 -0
- package/src/components/ui/hover-card.tsx +30 -0
- package/src/components/ui/inline-code.tsx +40 -0
- package/src/components/ui/input-otp.tsx +73 -0
- package/src/components/ui/input.tsx +68 -0
- package/src/components/ui/label.tsx +40 -0
- package/src/components/ui/menubar.tsx +241 -0
- package/src/components/ui/navigation-menu.tsx +131 -0
- package/src/components/ui/password-input.tsx +50 -0
- package/src/components/ui/popover.tsx +34 -0
- package/src/components/ui/progress.tsx +29 -0
- package/src/components/ui/radio-group.tsx +45 -0
- package/src/components/ui/resizable.tsx +45 -0
- package/src/components/ui/scroll-area.tsx +49 -0
- package/src/components/ui/select.tsx +162 -0
- package/src/components/ui/separator.tsx +32 -0
- package/src/components/ui/sheet.tsx +139 -0
- package/src/components/ui/skeleton.tsx +23 -0
- package/src/components/ui/slider.tsx +29 -0
- package/src/components/ui/spinner.tsx +18 -0
- package/src/components/ui/switch.tsx +75 -0
- package/src/components/ui/table.tsx +117 -0
- package/src/components/ui/tabs.tsx +56 -0
- package/src/components/ui/textarea.tsx +24 -0
- package/src/components/ui/toast.tsx +135 -0
- package/src/components/ui/toaster.tsx +35 -0
- package/src/components/ui/toggle-group.tsx +62 -0
- package/src/components/ui/toggle.tsx +46 -0
- package/src/components/ui/tooltip.tsx +40 -0
- package/src/components/ui/typography.tsx +47 -0
- package/src/components/ui/use-toast.tsx +195 -0
- package/src/index.ts +54 -0
- package/src/lib/utils.tsx +6 -0
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { forwardRefIfNeeded } from "@hexclave/shared/dist/utils/react";
|
|
5
|
+
import { Cross2Icon } from "@radix-ui/react-icons";
|
|
6
|
+
import * as ToastPrimitives from "@radix-ui/react-toast";
|
|
7
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
8
|
+
|
|
9
|
+
import { cn } from "../../lib/utils";
|
|
10
|
+
|
|
11
|
+
const ToastProvider = ToastPrimitives.Provider;
|
|
12
|
+
|
|
13
|
+
const ToastViewport = forwardRefIfNeeded<
|
|
14
|
+
React.ElementRef<typeof ToastPrimitives.Viewport>,
|
|
15
|
+
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Viewport>
|
|
16
|
+
>(({ className, ...props }, ref) => (
|
|
17
|
+
<ToastPrimitives.Viewport
|
|
18
|
+
ref={ref}
|
|
19
|
+
className={cn(
|
|
20
|
+
"stack-scope fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",
|
|
21
|
+
className
|
|
22
|
+
)}
|
|
23
|
+
{...props}
|
|
24
|
+
/>
|
|
25
|
+
));
|
|
26
|
+
ToastViewport.displayName = ToastPrimitives.Viewport.displayName;
|
|
27
|
+
|
|
28
|
+
const toastVariants = cva(
|
|
29
|
+
"stack-scope group pointer-events-auto relative flex w-full items-center justify-between space-x-2 overflow-hidden rounded-md border p-4 pr-6 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",
|
|
30
|
+
{
|
|
31
|
+
variants: {
|
|
32
|
+
variant: {
|
|
33
|
+
default:
|
|
34
|
+
"border border-border bg-background text-foreground shadow-lg dark:border-gray-600 dark:bg-gray-800 dark:text-foreground",
|
|
35
|
+
destructive:
|
|
36
|
+
'destructive group border-destructive bg-destructive text-destructive-foreground',
|
|
37
|
+
success:
|
|
38
|
+
'success group border-success bg-success text-success-foreground',
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
defaultVariants: {
|
|
42
|
+
variant: "default",
|
|
43
|
+
},
|
|
44
|
+
}
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
const Toast = forwardRefIfNeeded<
|
|
48
|
+
React.ElementRef<typeof ToastPrimitives.Root>,
|
|
49
|
+
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Root> &
|
|
50
|
+
VariantProps<typeof toastVariants>
|
|
51
|
+
>(({ className, variant, ...props }, ref) => {
|
|
52
|
+
return (
|
|
53
|
+
<ToastPrimitives.Root
|
|
54
|
+
ref={ref}
|
|
55
|
+
className={cn(toastVariants({ variant }), className)}
|
|
56
|
+
{...props}
|
|
57
|
+
/>
|
|
58
|
+
);
|
|
59
|
+
});
|
|
60
|
+
Toast.displayName = ToastPrimitives.Root.displayName;
|
|
61
|
+
|
|
62
|
+
const ToastAction = forwardRefIfNeeded<
|
|
63
|
+
React.ElementRef<typeof ToastPrimitives.Action>,
|
|
64
|
+
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Action>
|
|
65
|
+
>(({ className, ...props }, ref) => (
|
|
66
|
+
<ToastPrimitives.Action
|
|
67
|
+
ref={ref}
|
|
68
|
+
className={cn(
|
|
69
|
+
"inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium transition-colors hover:bg-secondary focus:outline-none focus:ring-1 focus:ring-ring disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",
|
|
70
|
+
className
|
|
71
|
+
)}
|
|
72
|
+
{...props}
|
|
73
|
+
/>
|
|
74
|
+
));
|
|
75
|
+
ToastAction.displayName = ToastPrimitives.Action.displayName;
|
|
76
|
+
|
|
77
|
+
const ToastClose = forwardRefIfNeeded<
|
|
78
|
+
React.ElementRef<typeof ToastPrimitives.Close>,
|
|
79
|
+
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Close>
|
|
80
|
+
>(({ className, ...props }, ref) => (
|
|
81
|
+
<ToastPrimitives.Close
|
|
82
|
+
ref={ref}
|
|
83
|
+
className={cn(
|
|
84
|
+
'absolute right-1 top-1 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-1 group-hover:opacity-100',
|
|
85
|
+
'group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600',
|
|
86
|
+
'group-[.success]:text-green-300 group-[.success]:hover:text-green-50 group-[.success]:focus:ring-green-400 group-[.success]:focus:ring-offset-green-600',
|
|
87
|
+
className
|
|
88
|
+
)}
|
|
89
|
+
toast-close=''
|
|
90
|
+
{...props}
|
|
91
|
+
>
|
|
92
|
+
<Cross2Icon className="h-4 w-4" />
|
|
93
|
+
</ToastPrimitives.Close>
|
|
94
|
+
));
|
|
95
|
+
ToastClose.displayName = ToastPrimitives.Close.displayName;
|
|
96
|
+
|
|
97
|
+
const ToastTitle = forwardRefIfNeeded<
|
|
98
|
+
React.ElementRef<typeof ToastPrimitives.Title>,
|
|
99
|
+
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Title>
|
|
100
|
+
>(({ className, ...props }, ref) => (
|
|
101
|
+
<ToastPrimitives.Title
|
|
102
|
+
ref={ref}
|
|
103
|
+
className={cn("text-sm font-semibold [&+div]:text-xs", className)}
|
|
104
|
+
{...props}
|
|
105
|
+
/>
|
|
106
|
+
));
|
|
107
|
+
ToastTitle.displayName = ToastPrimitives.Title.displayName;
|
|
108
|
+
|
|
109
|
+
const ToastDescription = forwardRefIfNeeded<
|
|
110
|
+
React.ElementRef<typeof ToastPrimitives.Description>,
|
|
111
|
+
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Description>
|
|
112
|
+
>(({ className, ...props }, ref) => (
|
|
113
|
+
<ToastPrimitives.Description
|
|
114
|
+
ref={ref}
|
|
115
|
+
className={cn("text-sm opacity-90", className)}
|
|
116
|
+
{...props}
|
|
117
|
+
/>
|
|
118
|
+
));
|
|
119
|
+
ToastDescription.displayName = ToastPrimitives.Description.displayName;
|
|
120
|
+
|
|
121
|
+
type ToastProps = React.ComponentPropsWithoutRef<typeof Toast>;
|
|
122
|
+
|
|
123
|
+
type ToastActionElement = React.ReactElement<typeof ToastAction>;
|
|
124
|
+
|
|
125
|
+
export {
|
|
126
|
+
type ToastProps,
|
|
127
|
+
type ToastActionElement,
|
|
128
|
+
ToastProvider,
|
|
129
|
+
ToastViewport,
|
|
130
|
+
Toast,
|
|
131
|
+
ToastTitle,
|
|
132
|
+
ToastDescription,
|
|
133
|
+
ToastClose,
|
|
134
|
+
ToastAction,
|
|
135
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
Toast,
|
|
5
|
+
ToastClose,
|
|
6
|
+
ToastDescription,
|
|
7
|
+
ToastProvider,
|
|
8
|
+
ToastTitle,
|
|
9
|
+
ToastViewport,
|
|
10
|
+
} from "./toast";
|
|
11
|
+
import { useToast } from "./use-toast";
|
|
12
|
+
|
|
13
|
+
export function Toaster() {
|
|
14
|
+
const { toasts } = useToast();
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<ToastProvider>
|
|
18
|
+
{toasts.map(function ({ id, title, description, action, ...props }) {
|
|
19
|
+
return (
|
|
20
|
+
<Toast key={id} {...props}>
|
|
21
|
+
<div className="stack-scope grid gap-1">
|
|
22
|
+
{title && <ToastTitle>{title}</ToastTitle>}
|
|
23
|
+
{description && (
|
|
24
|
+
<ToastDescription>{description}</ToastDescription>
|
|
25
|
+
)}
|
|
26
|
+
</div>
|
|
27
|
+
{action}
|
|
28
|
+
<ToastClose />
|
|
29
|
+
</Toast>
|
|
30
|
+
);
|
|
31
|
+
})}
|
|
32
|
+
<ToastViewport />
|
|
33
|
+
</ToastProvider>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { forwardRefIfNeeded } from "@hexclave/shared/dist/utils/react";
|
|
5
|
+
import * as ToggleGroupPrimitive from "@radix-ui/react-toggle-group";
|
|
6
|
+
import { VariantProps } from "class-variance-authority";
|
|
7
|
+
|
|
8
|
+
import { cn } from "../../lib/utils";
|
|
9
|
+
import { toggleVariants } from "./toggle";
|
|
10
|
+
|
|
11
|
+
const ToggleGroupContext = React.createContext<
|
|
12
|
+
VariantProps<typeof toggleVariants>
|
|
13
|
+
>({
|
|
14
|
+
size: "default",
|
|
15
|
+
variant: "default",
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const ToggleGroup = forwardRefIfNeeded<
|
|
19
|
+
React.ElementRef<typeof ToggleGroupPrimitive.Root>,
|
|
20
|
+
React.ComponentPropsWithoutRef<typeof ToggleGroupPrimitive.Root> &
|
|
21
|
+
VariantProps<typeof toggleVariants>
|
|
22
|
+
>(({ className, variant, size, children, ...props }, ref) => (
|
|
23
|
+
<ToggleGroupPrimitive.Root
|
|
24
|
+
ref={ref}
|
|
25
|
+
className={cn("flex items-center justify-center gap-1", className)}
|
|
26
|
+
{...props}
|
|
27
|
+
>
|
|
28
|
+
<ToggleGroupContext.Provider value={{ variant, size }}>
|
|
29
|
+
{children}
|
|
30
|
+
</ToggleGroupContext.Provider>
|
|
31
|
+
</ToggleGroupPrimitive.Root>
|
|
32
|
+
));
|
|
33
|
+
|
|
34
|
+
ToggleGroup.displayName = ToggleGroupPrimitive.Root.displayName;
|
|
35
|
+
|
|
36
|
+
const ToggleGroupItem = forwardRefIfNeeded<
|
|
37
|
+
React.ElementRef<typeof ToggleGroupPrimitive.Item>,
|
|
38
|
+
React.ComponentPropsWithoutRef<typeof ToggleGroupPrimitive.Item> &
|
|
39
|
+
VariantProps<typeof toggleVariants>
|
|
40
|
+
>(({ className, children, variant, size, ...props }, ref) => {
|
|
41
|
+
const context = React.useContext(ToggleGroupContext);
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<ToggleGroupPrimitive.Item
|
|
45
|
+
ref={ref}
|
|
46
|
+
className={cn(
|
|
47
|
+
toggleVariants({
|
|
48
|
+
variant: context.variant || variant,
|
|
49
|
+
size: context.size || size,
|
|
50
|
+
}),
|
|
51
|
+
className
|
|
52
|
+
)}
|
|
53
|
+
{...props}
|
|
54
|
+
>
|
|
55
|
+
{children}
|
|
56
|
+
</ToggleGroupPrimitive.Item>
|
|
57
|
+
);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
ToggleGroupItem.displayName = ToggleGroupPrimitive.Item.displayName;
|
|
61
|
+
|
|
62
|
+
export { ToggleGroup, ToggleGroupItem };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { forwardRefIfNeeded } from "@hexclave/shared/dist/utils/react";
|
|
5
|
+
import * as TogglePrimitive from "@radix-ui/react-toggle";
|
|
6
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
7
|
+
|
|
8
|
+
import { cn } from "../../lib/utils";
|
|
9
|
+
|
|
10
|
+
const toggleVariants = cva(
|
|
11
|
+
"stack-scope inline-flex items-center justify-center rounded-md text-sm font-medium hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground",
|
|
12
|
+
{
|
|
13
|
+
variants: {
|
|
14
|
+
variant: {
|
|
15
|
+
default: "bg-transparent",
|
|
16
|
+
outline:
|
|
17
|
+
"border border-input bg-transparent shadow-sm hover:bg-accent hover:text-accent-foreground",
|
|
18
|
+
},
|
|
19
|
+
size: {
|
|
20
|
+
default: "h-9 px-3",
|
|
21
|
+
sm: "h-8 px-2",
|
|
22
|
+
lg: "h-10 px-3",
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
defaultVariants: {
|
|
26
|
+
variant: "default",
|
|
27
|
+
size: "default",
|
|
28
|
+
},
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
const Toggle = forwardRefIfNeeded<
|
|
33
|
+
React.ElementRef<typeof TogglePrimitive.Root>,
|
|
34
|
+
React.ComponentPropsWithoutRef<typeof TogglePrimitive.Root> &
|
|
35
|
+
VariantProps<typeof toggleVariants>
|
|
36
|
+
>(({ className, variant, size, ...props }, ref) => (
|
|
37
|
+
<TogglePrimitive.Root
|
|
38
|
+
ref={ref}
|
|
39
|
+
className={cn(toggleVariants({ variant, size, className }))}
|
|
40
|
+
{...props}
|
|
41
|
+
/>
|
|
42
|
+
));
|
|
43
|
+
|
|
44
|
+
Toggle.displayName = TogglePrimitive.Root.displayName;
|
|
45
|
+
|
|
46
|
+
export { Toggle, toggleVariants };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { forwardRefIfNeeded } from "@hexclave/shared/dist/utils/react";
|
|
5
|
+
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
|
6
|
+
|
|
7
|
+
import { cn } from "../../lib/utils";
|
|
8
|
+
|
|
9
|
+
const TooltipProvider = forwardRefIfNeeded<
|
|
10
|
+
void,
|
|
11
|
+
React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Provider>
|
|
12
|
+
>((props, ref) => (
|
|
13
|
+
<TooltipPrimitive.Provider
|
|
14
|
+
delayDuration={0}
|
|
15
|
+
{...props}
|
|
16
|
+
/>
|
|
17
|
+
));
|
|
18
|
+
TooltipProvider.displayName = TooltipPrimitive.Provider.displayName;
|
|
19
|
+
|
|
20
|
+
const Tooltip = TooltipPrimitive.Root;
|
|
21
|
+
|
|
22
|
+
const TooltipTrigger = TooltipPrimitive.Trigger;
|
|
23
|
+
|
|
24
|
+
const TooltipContent = forwardRefIfNeeded<
|
|
25
|
+
React.ElementRef<typeof TooltipPrimitive.Content>,
|
|
26
|
+
React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content>
|
|
27
|
+
>(({ className, sideOffset = 4, ...props }, ref) => (
|
|
28
|
+
<TooltipPrimitive.Content
|
|
29
|
+
ref={ref}
|
|
30
|
+
sideOffset={sideOffset}
|
|
31
|
+
className={cn(
|
|
32
|
+
"stack-scope z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
|
33
|
+
className
|
|
34
|
+
)}
|
|
35
|
+
{...props}
|
|
36
|
+
/>
|
|
37
|
+
));
|
|
38
|
+
TooltipContent.displayName = TooltipPrimitive.Content.displayName;
|
|
39
|
+
|
|
40
|
+
export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { forwardRefIfNeeded } from "@hexclave/shared/dist/utils/react";
|
|
2
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { cn } from "../../lib/utils";
|
|
5
|
+
|
|
6
|
+
const typographyVariants = cva("stack-scope text-md", {
|
|
7
|
+
variants: {
|
|
8
|
+
type: {
|
|
9
|
+
h1: "text-3xl font-bold",
|
|
10
|
+
h2: "text-2xl font-semibold",
|
|
11
|
+
h3: "text-xl font-medium",
|
|
12
|
+
h4: "text-lg font-medium",
|
|
13
|
+
p: "text-md",
|
|
14
|
+
label: "text-sm",
|
|
15
|
+
footnote: "text-xs",
|
|
16
|
+
div: "text-md",
|
|
17
|
+
},
|
|
18
|
+
variant: {
|
|
19
|
+
primary: "text-black dark:text-white",
|
|
20
|
+
secondary: "text-zinc-600 dark:text-zinc-400",
|
|
21
|
+
destructive: "text-destructive",
|
|
22
|
+
success: "text-green-500",
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
defaultVariants: {
|
|
26
|
+
type: "p",
|
|
27
|
+
variant: "primary",
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
type TypographyProps = {} & React.HTMLAttributes<HTMLHeadingElement> & VariantProps<typeof typographyVariants>
|
|
32
|
+
|
|
33
|
+
const Typography = forwardRefIfNeeded<HTMLHeadingElement, TypographyProps>(
|
|
34
|
+
({ className, type, variant, ...props }, ref) => {
|
|
35
|
+
const Comp = (type === 'footnote' || type === 'label' ? 'p' : type) || 'p';
|
|
36
|
+
return (
|
|
37
|
+
<Comp
|
|
38
|
+
className={cn(typographyVariants({ type, variant, className }))}
|
|
39
|
+
ref={ref}
|
|
40
|
+
{...props}
|
|
41
|
+
/>
|
|
42
|
+
);
|
|
43
|
+
},
|
|
44
|
+
);
|
|
45
|
+
Typography.displayName = "Typography";
|
|
46
|
+
|
|
47
|
+
export { Typography };
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// Inspired by react-hot-toast library
|
|
4
|
+
import React from "react";
|
|
5
|
+
|
|
6
|
+
import type {
|
|
7
|
+
ToastActionElement,
|
|
8
|
+
ToastProps,
|
|
9
|
+
} from "./toast";
|
|
10
|
+
|
|
11
|
+
const TOAST_LIMIT = 1;
|
|
12
|
+
const TOAST_REMOVE_DELAY = 1000000;
|
|
13
|
+
|
|
14
|
+
type ToasterToast = ToastProps & {
|
|
15
|
+
id: string,
|
|
16
|
+
title?: React.ReactNode,
|
|
17
|
+
description?: React.ReactNode,
|
|
18
|
+
action?: ToastActionElement,
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const actionTypes = {
|
|
22
|
+
ADD_TOAST: "ADD_TOAST",
|
|
23
|
+
UPDATE_TOAST: "UPDATE_TOAST",
|
|
24
|
+
DISMISS_TOAST: "DISMISS_TOAST",
|
|
25
|
+
REMOVE_TOAST: "REMOVE_TOAST",
|
|
26
|
+
} as const;
|
|
27
|
+
|
|
28
|
+
let count = 0;
|
|
29
|
+
|
|
30
|
+
function genId() {
|
|
31
|
+
count = (count + 1) % Number.MAX_SAFE_INTEGER;
|
|
32
|
+
return count.toString();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
type ActionType = typeof actionTypes
|
|
36
|
+
|
|
37
|
+
type Action =
|
|
38
|
+
| {
|
|
39
|
+
type: ActionType["ADD_TOAST"],
|
|
40
|
+
toast: ToasterToast,
|
|
41
|
+
}
|
|
42
|
+
| {
|
|
43
|
+
type: ActionType["UPDATE_TOAST"],
|
|
44
|
+
toast: Partial<ToasterToast>,
|
|
45
|
+
}
|
|
46
|
+
| {
|
|
47
|
+
type: ActionType["DISMISS_TOAST"],
|
|
48
|
+
toastId?: ToasterToast["id"],
|
|
49
|
+
}
|
|
50
|
+
| {
|
|
51
|
+
type: ActionType["REMOVE_TOAST"],
|
|
52
|
+
toastId?: ToasterToast["id"],
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
type State = {
|
|
56
|
+
toasts: ToasterToast[],
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const toastTimeouts = new Map<string, ReturnType<typeof setTimeout>>();
|
|
60
|
+
|
|
61
|
+
const addToRemoveQueue = (toastId: string) => {
|
|
62
|
+
if (toastTimeouts.has(toastId)) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const timeout = setTimeout(() => {
|
|
67
|
+
toastTimeouts.delete(toastId);
|
|
68
|
+
dispatch({
|
|
69
|
+
type: "REMOVE_TOAST",
|
|
70
|
+
toastId: toastId,
|
|
71
|
+
});
|
|
72
|
+
}, TOAST_REMOVE_DELAY);
|
|
73
|
+
|
|
74
|
+
toastTimeouts.set(toastId, timeout);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export const reducer = (state: State, action: Action): State => {
|
|
78
|
+
switch (action.type) {
|
|
79
|
+
case "ADD_TOAST": {
|
|
80
|
+
return {
|
|
81
|
+
...state,
|
|
82
|
+
toasts: [action.toast, ...state.toasts].slice(0, TOAST_LIMIT),
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
case "UPDATE_TOAST": {
|
|
86
|
+
return {
|
|
87
|
+
...state,
|
|
88
|
+
toasts: state.toasts.map((t) =>
|
|
89
|
+
t.id === action.toast.id ? { ...t, ...action.toast } : t
|
|
90
|
+
),
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
case "DISMISS_TOAST": {
|
|
94
|
+
const { toastId } = action;
|
|
95
|
+
|
|
96
|
+
// ! Side effects ! - This could be extracted into a dismissToast() action,
|
|
97
|
+
// but I'll keep it here for simplicity
|
|
98
|
+
if (toastId) {
|
|
99
|
+
addToRemoveQueue(toastId);
|
|
100
|
+
} else {
|
|
101
|
+
state.toasts.forEach((toast) => {
|
|
102
|
+
addToRemoveQueue(toast.id);
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return {
|
|
107
|
+
...state,
|
|
108
|
+
toasts: state.toasts.map((t) =>
|
|
109
|
+
t.id === toastId || toastId === undefined
|
|
110
|
+
? {
|
|
111
|
+
...t,
|
|
112
|
+
open: false,
|
|
113
|
+
}
|
|
114
|
+
: t
|
|
115
|
+
),
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
case "REMOVE_TOAST": {
|
|
119
|
+
if (action.toastId === undefined) {
|
|
120
|
+
return {
|
|
121
|
+
...state,
|
|
122
|
+
toasts: [],
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
return {
|
|
126
|
+
...state,
|
|
127
|
+
toasts: state.toasts.filter((t) => t.id !== action.toastId),
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
const listeners: Array<(state: State) => void> = [];
|
|
134
|
+
|
|
135
|
+
let memoryState: State = { toasts: [] };
|
|
136
|
+
|
|
137
|
+
function dispatch(action: Action) {
|
|
138
|
+
memoryState = reducer(memoryState, action);
|
|
139
|
+
listeners.forEach((listener) => {
|
|
140
|
+
listener(memoryState);
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
type Toast = Omit<ToasterToast, "id">
|
|
145
|
+
|
|
146
|
+
function toast({ ...props }: Toast) {
|
|
147
|
+
const id = genId();
|
|
148
|
+
|
|
149
|
+
const update = (props: ToasterToast) =>
|
|
150
|
+
dispatch({
|
|
151
|
+
type: "UPDATE_TOAST",
|
|
152
|
+
toast: { ...props, id },
|
|
153
|
+
});
|
|
154
|
+
const dismiss = () => dispatch({ type: "DISMISS_TOAST", toastId: id });
|
|
155
|
+
|
|
156
|
+
dispatch({
|
|
157
|
+
type: "ADD_TOAST",
|
|
158
|
+
toast: {
|
|
159
|
+
...props,
|
|
160
|
+
id,
|
|
161
|
+
open: true,
|
|
162
|
+
onOpenChange: (open) => {
|
|
163
|
+
if (!open) dismiss();
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
return {
|
|
169
|
+
id: id,
|
|
170
|
+
dismiss,
|
|
171
|
+
update,
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function useToast() {
|
|
176
|
+
const [state, setState] = React.useState<State>(memoryState);
|
|
177
|
+
|
|
178
|
+
React.useEffect(() => {
|
|
179
|
+
listeners.push(setState);
|
|
180
|
+
return () => {
|
|
181
|
+
const index = listeners.indexOf(setState);
|
|
182
|
+
if (index > -1) {
|
|
183
|
+
listeners.splice(index, 1);
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
}, [state]);
|
|
187
|
+
|
|
188
|
+
return {
|
|
189
|
+
...state,
|
|
190
|
+
toast,
|
|
191
|
+
dismiss: (toastId?: string) => dispatch({ type: "DISMISS_TOAST", toastId }),
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export { useToast, toast };
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export * from "./components/action-dialog";
|
|
2
|
+
export * as BrandIcons from "./components/brand-icons";
|
|
3
|
+
export * from "./components/browser-frame";
|
|
4
|
+
export * from "./components/copy-button";
|
|
5
|
+
export * from "./components/copy-field";
|
|
6
|
+
export * from "./components/data-table";
|
|
7
|
+
export * from "./components/simple-tooltip";
|
|
8
|
+
export * from "./components/ui/accordion";
|
|
9
|
+
export * from "./components/ui/alert";
|
|
10
|
+
export * from "./components/ui/aspect-ratio";
|
|
11
|
+
export * from "./components/ui/avatar";
|
|
12
|
+
export * from "./components/ui/badge";
|
|
13
|
+
export * from "./components/ui/breadcrumb";
|
|
14
|
+
export * from "./components/ui/button";
|
|
15
|
+
export * from "./components/ui/calendar";
|
|
16
|
+
export * from "./components/ui/card";
|
|
17
|
+
export * from "./components/ui/checkbox";
|
|
18
|
+
export * from "./components/ui/collapsible";
|
|
19
|
+
export * from "./components/ui/command";
|
|
20
|
+
export * from "./components/ui/context-menu";
|
|
21
|
+
export * from "./components/ui/dialog";
|
|
22
|
+
export * from "./components/ui/dropdown-menu";
|
|
23
|
+
export * from "./components/ui/form";
|
|
24
|
+
export * from "./components/ui/hover-card";
|
|
25
|
+
export * from "./components/ui/inline-code";
|
|
26
|
+
export * from "./components/ui/input";
|
|
27
|
+
export * from "./components/ui/input-otp";
|
|
28
|
+
export * from "./components/ui/label";
|
|
29
|
+
export * from "./components/ui/menubar";
|
|
30
|
+
export * from "./components/ui/navigation-menu";
|
|
31
|
+
export * from "./components/ui/password-input";
|
|
32
|
+
export * from "./components/ui/popover";
|
|
33
|
+
export * from "./components/ui/progress";
|
|
34
|
+
export * from "./components/ui/radio-group";
|
|
35
|
+
export * from "./components/ui/scroll-area";
|
|
36
|
+
export * from "./components/ui/select";
|
|
37
|
+
export * from "./components/ui/separator";
|
|
38
|
+
export * from "./components/ui/sheet";
|
|
39
|
+
export * from "./components/ui/skeleton";
|
|
40
|
+
export * from "./components/ui/slider";
|
|
41
|
+
export * from "./components/ui/spinner";
|
|
42
|
+
export * from "./components/ui/switch";
|
|
43
|
+
export * from "./components/ui/table";
|
|
44
|
+
export * from "./components/ui/tabs";
|
|
45
|
+
export * from "./components/ui/textarea";
|
|
46
|
+
export * from "./components/ui/toast";
|
|
47
|
+
export * from "./components/ui/toaster";
|
|
48
|
+
export * from "./components/ui/toggle-group";
|
|
49
|
+
export * from "./components/ui/tooltip";
|
|
50
|
+
export * from "./components/ui/typography";
|
|
51
|
+
export * from "./components/ui/use-toast";
|
|
52
|
+
export * from "./components/ui/resizable";
|
|
53
|
+
export { cn } from "./lib/utils";
|
|
54
|
+
|