@re-venue/ui-core-react 0.1.3 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +409 -0
- package/dist/ui-core-react.css +1 -1
- package/dist/ui-core-react.js +10046 -216
- package/dist/ui-core-react.umd.cjs +47 -1
- package/package.json +26 -1
- package/src/components/AppShell.tsx +3 -0
- package/src/components/common/ConfirmationModal.tsx +65 -0
- package/src/components/common/Container.tsx +15 -0
- package/src/components/common/DangerZoneSection.tsx +62 -0
- package/src/components/common/DetailPanel.tsx +115 -0
- package/src/components/common/DetailSheet.tsx +98 -0
- package/src/components/common/EditableTitle.tsx +119 -0
- package/src/components/common/EmptyState.tsx +36 -0
- package/src/components/common/FormModal.tsx +64 -0
- package/src/components/common/NavigationListItem.tsx +24 -0
- package/src/components/common/PanelEmptyState.tsx +17 -0
- package/src/components/ui/alert-dialog.tsx +104 -0
- package/src/components/ui/avatar.tsx +38 -0
- package/src/components/ui/badge.tsx +31 -0
- package/src/components/ui/button.tsx +47 -0
- package/src/components/ui/card.tsx +43 -0
- package/src/components/ui/checkbox.tsx +26 -0
- package/src/components/ui/dialog.tsx +95 -0
- package/src/components/ui/input.tsx +22 -0
- package/src/components/ui/label.tsx +17 -0
- package/src/components/ui/multi-select.tsx +109 -0
- package/src/components/ui/popover.tsx +29 -0
- package/src/components/ui/progress.tsx +23 -0
- package/src/components/ui/scroll-area.tsx +38 -0
- package/src/components/ui/select.tsx +143 -0
- package/src/components/ui/separator.tsx +20 -0
- package/src/components/ui/sheet.tsx +107 -0
- package/src/components/ui/skeleton.tsx +7 -0
- package/src/components/ui/sonner.tsx +27 -0
- package/src/components/ui/switch.tsx +27 -0
- package/src/components/ui/table.tsx +72 -0
- package/src/components/ui/toast.tsx +111 -0
- package/src/components/ui/toaster.tsx +24 -0
- package/src/components/ui/tooltip.tsx +28 -0
- package/src/components/ui/use-toast.ts +3 -0
- package/src/hooks/use-toast.ts +186 -0
- package/src/hooks/useDetailPanel.ts +21 -0
- package/src/hooks/useDetailSheetControls.ts +16 -0
- package/src/index.ts +48 -0
- package/src/lib/utils.ts +6 -0
- package/src/styles/utilities.css +1 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as SelectPrimitive from "@radix-ui/react-select";
|
|
3
|
+
import { Check, ChevronDown, ChevronUp } from "lucide-react";
|
|
4
|
+
|
|
5
|
+
import { cn } from "../../lib/utils";
|
|
6
|
+
|
|
7
|
+
const Select = SelectPrimitive.Root;
|
|
8
|
+
|
|
9
|
+
const SelectGroup = SelectPrimitive.Group;
|
|
10
|
+
|
|
11
|
+
const SelectValue = SelectPrimitive.Value;
|
|
12
|
+
|
|
13
|
+
const SelectTrigger = React.forwardRef<
|
|
14
|
+
React.ElementRef<typeof SelectPrimitive.Trigger>,
|
|
15
|
+
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger>
|
|
16
|
+
>(({ className, children, ...props }, ref) => (
|
|
17
|
+
<SelectPrimitive.Trigger
|
|
18
|
+
ref={ref}
|
|
19
|
+
className={cn(
|
|
20
|
+
"flex h-10 w-full items-center justify-between rounded-md border border-input bg-white px-3 py-2 text-sm ring-offset-background transition-all duration-200 placeholder:text-muted-foreground hover:border-primary/50 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:border-primary disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",
|
|
21
|
+
className,
|
|
22
|
+
)}
|
|
23
|
+
{...props}
|
|
24
|
+
>
|
|
25
|
+
{children}
|
|
26
|
+
<SelectPrimitive.Icon asChild>
|
|
27
|
+
<ChevronDown className="h-4 w-4 opacity-50" />
|
|
28
|
+
</SelectPrimitive.Icon>
|
|
29
|
+
</SelectPrimitive.Trigger>
|
|
30
|
+
));
|
|
31
|
+
SelectTrigger.displayName = SelectPrimitive.Trigger.displayName;
|
|
32
|
+
|
|
33
|
+
const SelectScrollUpButton = React.forwardRef<
|
|
34
|
+
React.ElementRef<typeof SelectPrimitive.ScrollUpButton>,
|
|
35
|
+
React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollUpButton>
|
|
36
|
+
>(({ className, ...props }, ref) => (
|
|
37
|
+
<SelectPrimitive.ScrollUpButton
|
|
38
|
+
ref={ref}
|
|
39
|
+
className={cn("flex cursor-default items-center justify-center py-1", className)}
|
|
40
|
+
{...props}
|
|
41
|
+
>
|
|
42
|
+
<ChevronUp className="h-4 w-4" />
|
|
43
|
+
</SelectPrimitive.ScrollUpButton>
|
|
44
|
+
));
|
|
45
|
+
SelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName;
|
|
46
|
+
|
|
47
|
+
const SelectScrollDownButton = React.forwardRef<
|
|
48
|
+
React.ElementRef<typeof SelectPrimitive.ScrollDownButton>,
|
|
49
|
+
React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollDownButton>
|
|
50
|
+
>(({ className, ...props }, ref) => (
|
|
51
|
+
<SelectPrimitive.ScrollDownButton
|
|
52
|
+
ref={ref}
|
|
53
|
+
className={cn("flex cursor-default items-center justify-center py-1", className)}
|
|
54
|
+
{...props}
|
|
55
|
+
>
|
|
56
|
+
<ChevronDown className="h-4 w-4" />
|
|
57
|
+
</SelectPrimitive.ScrollDownButton>
|
|
58
|
+
));
|
|
59
|
+
SelectScrollDownButton.displayName = SelectPrimitive.ScrollDownButton.displayName;
|
|
60
|
+
|
|
61
|
+
const SelectContent = React.forwardRef<
|
|
62
|
+
React.ElementRef<typeof SelectPrimitive.Content>,
|
|
63
|
+
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content>
|
|
64
|
+
>(({ className, children, position = "popper", ...props }, ref) => (
|
|
65
|
+
<SelectPrimitive.Portal>
|
|
66
|
+
<SelectPrimitive.Content
|
|
67
|
+
ref={ref}
|
|
68
|
+
className={cn(
|
|
69
|
+
"relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-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",
|
|
70
|
+
position === "popper" &&
|
|
71
|
+
"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
|
|
72
|
+
className,
|
|
73
|
+
)}
|
|
74
|
+
position={position}
|
|
75
|
+
{...props}
|
|
76
|
+
>
|
|
77
|
+
<SelectScrollUpButton />
|
|
78
|
+
<SelectPrimitive.Viewport
|
|
79
|
+
className={cn(
|
|
80
|
+
"p-1",
|
|
81
|
+
position === "popper" &&
|
|
82
|
+
"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]",
|
|
83
|
+
)}
|
|
84
|
+
>
|
|
85
|
+
{children}
|
|
86
|
+
</SelectPrimitive.Viewport>
|
|
87
|
+
<SelectScrollDownButton />
|
|
88
|
+
</SelectPrimitive.Content>
|
|
89
|
+
</SelectPrimitive.Portal>
|
|
90
|
+
));
|
|
91
|
+
SelectContent.displayName = SelectPrimitive.Content.displayName;
|
|
92
|
+
|
|
93
|
+
const SelectLabel = React.forwardRef<
|
|
94
|
+
React.ElementRef<typeof SelectPrimitive.Label>,
|
|
95
|
+
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Label>
|
|
96
|
+
>(({ className, ...props }, ref) => (
|
|
97
|
+
<SelectPrimitive.Label ref={ref} className={cn("py-1.5 pl-8 pr-2 text-sm font-semibold", className)} {...props} />
|
|
98
|
+
));
|
|
99
|
+
SelectLabel.displayName = SelectPrimitive.Label.displayName;
|
|
100
|
+
|
|
101
|
+
const SelectItem = React.forwardRef<
|
|
102
|
+
React.ElementRef<typeof SelectPrimitive.Item>,
|
|
103
|
+
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Item>
|
|
104
|
+
>(({ className, children, ...props }, ref) => (
|
|
105
|
+
<SelectPrimitive.Item
|
|
106
|
+
ref={ref}
|
|
107
|
+
className={cn(
|
|
108
|
+
"relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-all duration-150 data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground hover:bg-accent/50",
|
|
109
|
+
className,
|
|
110
|
+
)}
|
|
111
|
+
{...props}
|
|
112
|
+
>
|
|
113
|
+
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
|
114
|
+
<SelectPrimitive.ItemIndicator>
|
|
115
|
+
<Check className="h-4 w-4" />
|
|
116
|
+
</SelectPrimitive.ItemIndicator>
|
|
117
|
+
</span>
|
|
118
|
+
|
|
119
|
+
<SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>
|
|
120
|
+
</SelectPrimitive.Item>
|
|
121
|
+
));
|
|
122
|
+
SelectItem.displayName = SelectPrimitive.Item.displayName;
|
|
123
|
+
|
|
124
|
+
const SelectSeparator = React.forwardRef<
|
|
125
|
+
React.ElementRef<typeof SelectPrimitive.Separator>,
|
|
126
|
+
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Separator>
|
|
127
|
+
>(({ className, ...props }, ref) => (
|
|
128
|
+
<SelectPrimitive.Separator ref={ref} className={cn("-mx-1 my-1 h-px bg-muted", className)} {...props} />
|
|
129
|
+
));
|
|
130
|
+
SelectSeparator.displayName = SelectPrimitive.Separator.displayName;
|
|
131
|
+
|
|
132
|
+
export {
|
|
133
|
+
Select,
|
|
134
|
+
SelectGroup,
|
|
135
|
+
SelectValue,
|
|
136
|
+
SelectTrigger,
|
|
137
|
+
SelectContent,
|
|
138
|
+
SelectLabel,
|
|
139
|
+
SelectItem,
|
|
140
|
+
SelectSeparator,
|
|
141
|
+
SelectScrollUpButton,
|
|
142
|
+
SelectScrollDownButton,
|
|
143
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as SeparatorPrimitive from "@radix-ui/react-separator";
|
|
3
|
+
|
|
4
|
+
import { cn } from "../../lib/utils";
|
|
5
|
+
|
|
6
|
+
const Separator = React.forwardRef<
|
|
7
|
+
React.ElementRef<typeof SeparatorPrimitive.Root>,
|
|
8
|
+
React.ComponentPropsWithoutRef<typeof SeparatorPrimitive.Root>
|
|
9
|
+
>(({ className, orientation = "horizontal", decorative = true, ...props }, ref) => (
|
|
10
|
+
<SeparatorPrimitive.Root
|
|
11
|
+
ref={ref}
|
|
12
|
+
decorative={decorative}
|
|
13
|
+
orientation={orientation}
|
|
14
|
+
className={cn("shrink-0 bg-border", orientation === "horizontal" ? "h-[1px] w-full" : "h-full w-[1px]", className)}
|
|
15
|
+
{...props}
|
|
16
|
+
/>
|
|
17
|
+
));
|
|
18
|
+
Separator.displayName = SeparatorPrimitive.Root.displayName;
|
|
19
|
+
|
|
20
|
+
export { Separator };
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import * as SheetPrimitive from "@radix-ui/react-dialog";
|
|
2
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
3
|
+
import { X } from "lucide-react";
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
|
|
6
|
+
import { cn } from "../../lib/utils";
|
|
7
|
+
|
|
8
|
+
const Sheet = SheetPrimitive.Root;
|
|
9
|
+
|
|
10
|
+
const SheetTrigger = SheetPrimitive.Trigger;
|
|
11
|
+
|
|
12
|
+
const SheetClose = SheetPrimitive.Close;
|
|
13
|
+
|
|
14
|
+
const SheetPortal = SheetPrimitive.Portal;
|
|
15
|
+
|
|
16
|
+
const SheetOverlay = React.forwardRef<
|
|
17
|
+
React.ElementRef<typeof SheetPrimitive.Overlay>,
|
|
18
|
+
React.ComponentPropsWithoutRef<typeof SheetPrimitive.Overlay>
|
|
19
|
+
>(({ className, ...props }, ref) => (
|
|
20
|
+
<SheetPrimitive.Overlay
|
|
21
|
+
className={cn(
|
|
22
|
+
"fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
|
23
|
+
className,
|
|
24
|
+
)}
|
|
25
|
+
{...props}
|
|
26
|
+
ref={ref}
|
|
27
|
+
/>
|
|
28
|
+
));
|
|
29
|
+
SheetOverlay.displayName = SheetPrimitive.Overlay.displayName;
|
|
30
|
+
|
|
31
|
+
const sheetVariants = cva(
|
|
32
|
+
"fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",
|
|
33
|
+
{
|
|
34
|
+
variants: {
|
|
35
|
+
side: {
|
|
36
|
+
top: "inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",
|
|
37
|
+
bottom:
|
|
38
|
+
"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",
|
|
39
|
+
left: "inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",
|
|
40
|
+
right:
|
|
41
|
+
"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm",
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
defaultVariants: {
|
|
45
|
+
side: "right",
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
interface SheetContentProps
|
|
51
|
+
extends React.ComponentPropsWithoutRef<typeof SheetPrimitive.Content>,
|
|
52
|
+
VariantProps<typeof sheetVariants> {}
|
|
53
|
+
|
|
54
|
+
const SheetContent = React.forwardRef<React.ElementRef<typeof SheetPrimitive.Content>, SheetContentProps>(
|
|
55
|
+
({ side = "right", className, children, ...props }, ref) => (
|
|
56
|
+
<SheetPortal>
|
|
57
|
+
<SheetOverlay />
|
|
58
|
+
<SheetPrimitive.Content ref={ref} className={cn(sheetVariants({ side }), className)} {...props}>
|
|
59
|
+
{children}
|
|
60
|
+
<SheetPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity data-[state=open]:bg-secondary hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none">
|
|
61
|
+
<X className="h-4 w-4" />
|
|
62
|
+
<span className="sr-only">Close</span>
|
|
63
|
+
</SheetPrimitive.Close>
|
|
64
|
+
</SheetPrimitive.Content>
|
|
65
|
+
</SheetPortal>
|
|
66
|
+
),
|
|
67
|
+
);
|
|
68
|
+
SheetContent.displayName = SheetPrimitive.Content.displayName;
|
|
69
|
+
|
|
70
|
+
const SheetHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
|
|
71
|
+
<div className={cn("flex flex-col space-y-2 text-center sm:text-left", className)} {...props} />
|
|
72
|
+
);
|
|
73
|
+
SheetHeader.displayName = "SheetHeader";
|
|
74
|
+
|
|
75
|
+
const SheetFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
|
|
76
|
+
<div className={cn("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2", className)} {...props} />
|
|
77
|
+
);
|
|
78
|
+
SheetFooter.displayName = "SheetFooter";
|
|
79
|
+
|
|
80
|
+
const SheetTitle = React.forwardRef<
|
|
81
|
+
React.ElementRef<typeof SheetPrimitive.Title>,
|
|
82
|
+
React.ComponentPropsWithoutRef<typeof SheetPrimitive.Title>
|
|
83
|
+
>(({ className, ...props }, ref) => (
|
|
84
|
+
<SheetPrimitive.Title ref={ref} className={cn("text-lg font-semibold text-foreground", className)} {...props} />
|
|
85
|
+
));
|
|
86
|
+
SheetTitle.displayName = SheetPrimitive.Title.displayName;
|
|
87
|
+
|
|
88
|
+
const SheetDescription = React.forwardRef<
|
|
89
|
+
React.ElementRef<typeof SheetPrimitive.Description>,
|
|
90
|
+
React.ComponentPropsWithoutRef<typeof SheetPrimitive.Description>
|
|
91
|
+
>(({ className, ...props }, ref) => (
|
|
92
|
+
<SheetPrimitive.Description ref={ref} className={cn("text-sm text-muted-foreground", className)} {...props} />
|
|
93
|
+
));
|
|
94
|
+
SheetDescription.displayName = SheetPrimitive.Description.displayName;
|
|
95
|
+
|
|
96
|
+
export {
|
|
97
|
+
Sheet,
|
|
98
|
+
SheetClose,
|
|
99
|
+
SheetContent,
|
|
100
|
+
SheetDescription,
|
|
101
|
+
SheetFooter,
|
|
102
|
+
SheetHeader,
|
|
103
|
+
SheetOverlay,
|
|
104
|
+
SheetPortal,
|
|
105
|
+
SheetTitle,
|
|
106
|
+
SheetTrigger,
|
|
107
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { useTheme } from "../../hooks/useTheme";
|
|
2
|
+
import { Toaster as Sonner, toast } from "sonner";
|
|
3
|
+
|
|
4
|
+
type ToasterProps = React.ComponentProps<typeof Sonner>;
|
|
5
|
+
|
|
6
|
+
const Toaster = ({ ...props }: ToasterProps) => {
|
|
7
|
+
const { theme = "system" } = useTheme();
|
|
8
|
+
|
|
9
|
+
return (
|
|
10
|
+
<Sonner
|
|
11
|
+
theme={theme as ToasterProps["theme"]}
|
|
12
|
+
className="toaster group"
|
|
13
|
+
toastOptions={{
|
|
14
|
+
classNames: {
|
|
15
|
+
toast:
|
|
16
|
+
"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",
|
|
17
|
+
description: "group-[.toast]:text-muted-foreground",
|
|
18
|
+
actionButton: "group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",
|
|
19
|
+
cancelButton: "group-[.toast]:bg-muted group-[.toast]:text-muted-foreground",
|
|
20
|
+
},
|
|
21
|
+
}}
|
|
22
|
+
{...props}
|
|
23
|
+
/>
|
|
24
|
+
);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export { Toaster, toast };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as SwitchPrimitives from "@radix-ui/react-switch";
|
|
3
|
+
|
|
4
|
+
import { cn } from "../../lib/utils";
|
|
5
|
+
|
|
6
|
+
const Switch = React.forwardRef<
|
|
7
|
+
React.ElementRef<typeof SwitchPrimitives.Root>,
|
|
8
|
+
React.ComponentPropsWithoutRef<typeof SwitchPrimitives.Root>
|
|
9
|
+
>(({ className, ...props }, ref) => (
|
|
10
|
+
<SwitchPrimitives.Root
|
|
11
|
+
className={cn(
|
|
12
|
+
"peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50",
|
|
13
|
+
className,
|
|
14
|
+
)}
|
|
15
|
+
{...props}
|
|
16
|
+
ref={ref}
|
|
17
|
+
>
|
|
18
|
+
<SwitchPrimitives.Thumb
|
|
19
|
+
className={cn(
|
|
20
|
+
"pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0",
|
|
21
|
+
)}
|
|
22
|
+
/>
|
|
23
|
+
</SwitchPrimitives.Root>
|
|
24
|
+
));
|
|
25
|
+
Switch.displayName = SwitchPrimitives.Root.displayName;
|
|
26
|
+
|
|
27
|
+
export { Switch };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
import { cn } from "../../lib/utils";
|
|
4
|
+
|
|
5
|
+
const Table = React.forwardRef<HTMLTableElement, React.HTMLAttributes<HTMLTableElement>>(
|
|
6
|
+
({ className, ...props }, ref) => (
|
|
7
|
+
<div className="relative w-full overflow-auto rounded-lg border border-border">
|
|
8
|
+
<table ref={ref} className={cn("w-full caption-bottom text-sm", className)} {...props} />
|
|
9
|
+
</div>
|
|
10
|
+
),
|
|
11
|
+
);
|
|
12
|
+
Table.displayName = "Table";
|
|
13
|
+
|
|
14
|
+
const TableHeader = React.forwardRef<HTMLTableSectionElement, React.HTMLAttributes<HTMLTableSectionElement>>(
|
|
15
|
+
({ className, ...props }, ref) => <thead ref={ref} className={cn("bg-muted [&_tr]:border-b", className)} {...props} />,
|
|
16
|
+
);
|
|
17
|
+
TableHeader.displayName = "TableHeader";
|
|
18
|
+
|
|
19
|
+
const TableBody = React.forwardRef<HTMLTableSectionElement, React.HTMLAttributes<HTMLTableSectionElement>>(
|
|
20
|
+
({ className, ...props }, ref) => (
|
|
21
|
+
<tbody ref={ref} className={cn("[&_tr:last-child]:border-0", className)} {...props} />
|
|
22
|
+
),
|
|
23
|
+
);
|
|
24
|
+
TableBody.displayName = "TableBody";
|
|
25
|
+
|
|
26
|
+
const TableFooter = React.forwardRef<HTMLTableSectionElement, React.HTMLAttributes<HTMLTableSectionElement>>(
|
|
27
|
+
({ className, ...props }, ref) => (
|
|
28
|
+
<tfoot ref={ref} className={cn("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0", className)} {...props} />
|
|
29
|
+
),
|
|
30
|
+
);
|
|
31
|
+
TableFooter.displayName = "TableFooter";
|
|
32
|
+
|
|
33
|
+
const TableRow = React.forwardRef<HTMLTableRowElement, React.HTMLAttributes<HTMLTableRowElement>>(
|
|
34
|
+
({ className, ...props }, ref) => (
|
|
35
|
+
<tr
|
|
36
|
+
ref={ref}
|
|
37
|
+
className={cn("border-b bg-white transition-colors data-[state=selected]:bg-muted hover:bg-muted/50", className)}
|
|
38
|
+
{...props}
|
|
39
|
+
/>
|
|
40
|
+
),
|
|
41
|
+
);
|
|
42
|
+
TableRow.displayName = "TableRow";
|
|
43
|
+
|
|
44
|
+
const TableHead = React.forwardRef<HTMLTableCellElement, React.ThHTMLAttributes<HTMLTableCellElement>>(
|
|
45
|
+
({ className, ...props }, ref) => (
|
|
46
|
+
<th
|
|
47
|
+
ref={ref}
|
|
48
|
+
className={cn(
|
|
49
|
+
"h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",
|
|
50
|
+
className,
|
|
51
|
+
)}
|
|
52
|
+
{...props}
|
|
53
|
+
/>
|
|
54
|
+
),
|
|
55
|
+
);
|
|
56
|
+
TableHead.displayName = "TableHead";
|
|
57
|
+
|
|
58
|
+
const TableCell = React.forwardRef<HTMLTableCellElement, React.TdHTMLAttributes<HTMLTableCellElement>>(
|
|
59
|
+
({ className, ...props }, ref) => (
|
|
60
|
+
<td ref={ref} className={cn("p-4 align-middle [&:has([role=checkbox])]:pr-0", className)} {...props} />
|
|
61
|
+
),
|
|
62
|
+
);
|
|
63
|
+
TableCell.displayName = "TableCell";
|
|
64
|
+
|
|
65
|
+
const TableCaption = React.forwardRef<HTMLTableCaptionElement, React.HTMLAttributes<HTMLTableCaptionElement>>(
|
|
66
|
+
({ className, ...props }, ref) => (
|
|
67
|
+
<caption ref={ref} className={cn("mt-4 text-sm text-muted-foreground", className)} {...props} />
|
|
68
|
+
),
|
|
69
|
+
);
|
|
70
|
+
TableCaption.displayName = "TableCaption";
|
|
71
|
+
|
|
72
|
+
export { Table, TableHeader, TableBody, TableFooter, TableHead, TableRow, TableCell, TableCaption };
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as ToastPrimitives from "@radix-ui/react-toast";
|
|
3
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
4
|
+
import { X } from "lucide-react";
|
|
5
|
+
|
|
6
|
+
import { cn } from "../../lib/utils";
|
|
7
|
+
|
|
8
|
+
const ToastProvider = ToastPrimitives.Provider;
|
|
9
|
+
|
|
10
|
+
const ToastViewport = React.forwardRef<
|
|
11
|
+
React.ElementRef<typeof ToastPrimitives.Viewport>,
|
|
12
|
+
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Viewport>
|
|
13
|
+
>(({ className, ...props }, ref) => (
|
|
14
|
+
<ToastPrimitives.Viewport
|
|
15
|
+
ref={ref}
|
|
16
|
+
className={cn(
|
|
17
|
+
"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]",
|
|
18
|
+
className,
|
|
19
|
+
)}
|
|
20
|
+
{...props}
|
|
21
|
+
/>
|
|
22
|
+
));
|
|
23
|
+
ToastViewport.displayName = ToastPrimitives.Viewport.displayName;
|
|
24
|
+
|
|
25
|
+
const toastVariants = cva(
|
|
26
|
+
"group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 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",
|
|
27
|
+
{
|
|
28
|
+
variants: {
|
|
29
|
+
variant: {
|
|
30
|
+
default: "border bg-background text-foreground",
|
|
31
|
+
destructive: "destructive group border-destructive bg-destructive text-destructive-foreground",
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
defaultVariants: {
|
|
35
|
+
variant: "default",
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
const Toast = React.forwardRef<
|
|
41
|
+
React.ElementRef<typeof ToastPrimitives.Root>,
|
|
42
|
+
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Root> & VariantProps<typeof toastVariants>
|
|
43
|
+
>(({ className, variant, ...props }, ref) => {
|
|
44
|
+
return <ToastPrimitives.Root ref={ref} className={cn(toastVariants({ variant }), className)} {...props} />;
|
|
45
|
+
});
|
|
46
|
+
Toast.displayName = ToastPrimitives.Root.displayName;
|
|
47
|
+
|
|
48
|
+
const ToastAction = React.forwardRef<
|
|
49
|
+
React.ElementRef<typeof ToastPrimitives.Action>,
|
|
50
|
+
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Action>
|
|
51
|
+
>(({ className, ...props }, ref) => (
|
|
52
|
+
<ToastPrimitives.Action
|
|
53
|
+
ref={ref}
|
|
54
|
+
className={cn(
|
|
55
|
+
"inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors group-[.destructive]:border-muted/40 hover:bg-secondary group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 group-[.destructive]:focus:ring-destructive disabled:pointer-events-none disabled:opacity-50",
|
|
56
|
+
className,
|
|
57
|
+
)}
|
|
58
|
+
{...props}
|
|
59
|
+
/>
|
|
60
|
+
));
|
|
61
|
+
ToastAction.displayName = ToastPrimitives.Action.displayName;
|
|
62
|
+
|
|
63
|
+
const ToastClose = React.forwardRef<
|
|
64
|
+
React.ElementRef<typeof ToastPrimitives.Close>,
|
|
65
|
+
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Close>
|
|
66
|
+
>(({ className, ...props }, ref) => (
|
|
67
|
+
<ToastPrimitives.Close
|
|
68
|
+
ref={ref}
|
|
69
|
+
className={cn(
|
|
70
|
+
"absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity group-hover:opacity-100 group-[.destructive]:text-red-300 hover:text-foreground group-[.destructive]:hover:text-red-50 focus:opacity-100 focus:outline-none focus:ring-2 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",
|
|
71
|
+
className,
|
|
72
|
+
)}
|
|
73
|
+
toast-close=""
|
|
74
|
+
{...props}
|
|
75
|
+
>
|
|
76
|
+
<X className="h-4 w-4" />
|
|
77
|
+
</ToastPrimitives.Close>
|
|
78
|
+
));
|
|
79
|
+
ToastClose.displayName = ToastPrimitives.Close.displayName;
|
|
80
|
+
|
|
81
|
+
const ToastTitle = React.forwardRef<
|
|
82
|
+
React.ElementRef<typeof ToastPrimitives.Title>,
|
|
83
|
+
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Title>
|
|
84
|
+
>(({ className, ...props }, ref) => (
|
|
85
|
+
<ToastPrimitives.Title ref={ref} className={cn("text-sm font-semibold", className)} {...props} />
|
|
86
|
+
));
|
|
87
|
+
ToastTitle.displayName = ToastPrimitives.Title.displayName;
|
|
88
|
+
|
|
89
|
+
const ToastDescription = React.forwardRef<
|
|
90
|
+
React.ElementRef<typeof ToastPrimitives.Description>,
|
|
91
|
+
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Description>
|
|
92
|
+
>(({ className, ...props }, ref) => (
|
|
93
|
+
<ToastPrimitives.Description ref={ref} className={cn("text-sm opacity-90", className)} {...props} />
|
|
94
|
+
));
|
|
95
|
+
ToastDescription.displayName = ToastPrimitives.Description.displayName;
|
|
96
|
+
|
|
97
|
+
type ToastProps = React.ComponentPropsWithoutRef<typeof Toast>;
|
|
98
|
+
|
|
99
|
+
type ToastActionElement = React.ReactElement<typeof ToastAction>;
|
|
100
|
+
|
|
101
|
+
export {
|
|
102
|
+
type ToastProps,
|
|
103
|
+
type ToastActionElement,
|
|
104
|
+
ToastProvider,
|
|
105
|
+
ToastViewport,
|
|
106
|
+
Toast,
|
|
107
|
+
ToastTitle,
|
|
108
|
+
ToastDescription,
|
|
109
|
+
ToastClose,
|
|
110
|
+
ToastAction,
|
|
111
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { useToast } from "../../hooks/use-toast";
|
|
2
|
+
import { Toast, ToastClose, ToastDescription, ToastProvider, ToastTitle, ToastViewport } from "./toast";
|
|
3
|
+
|
|
4
|
+
export function Toaster() {
|
|
5
|
+
const { toasts } = useToast();
|
|
6
|
+
|
|
7
|
+
return (
|
|
8
|
+
<ToastProvider>
|
|
9
|
+
{toasts.map(function ({ id, title, description, action, ...props }) {
|
|
10
|
+
return (
|
|
11
|
+
<Toast key={id} {...props}>
|
|
12
|
+
<div className="grid gap-1">
|
|
13
|
+
{title && <ToastTitle>{title}</ToastTitle>}
|
|
14
|
+
{description && <ToastDescription>{description}</ToastDescription>}
|
|
15
|
+
</div>
|
|
16
|
+
{action}
|
|
17
|
+
<ToastClose />
|
|
18
|
+
</Toast>
|
|
19
|
+
);
|
|
20
|
+
})}
|
|
21
|
+
<ToastViewport />
|
|
22
|
+
</ToastProvider>
|
|
23
|
+
);
|
|
24
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
|
3
|
+
|
|
4
|
+
import { cn } from "../../lib/utils";
|
|
5
|
+
|
|
6
|
+
const TooltipProvider = TooltipPrimitive.Provider;
|
|
7
|
+
|
|
8
|
+
const Tooltip = TooltipPrimitive.Root;
|
|
9
|
+
|
|
10
|
+
const TooltipTrigger = TooltipPrimitive.Trigger;
|
|
11
|
+
|
|
12
|
+
const TooltipContent = React.forwardRef<
|
|
13
|
+
React.ElementRef<typeof TooltipPrimitive.Content>,
|
|
14
|
+
React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content>
|
|
15
|
+
>(({ className, sideOffset = 4, ...props }, ref) => (
|
|
16
|
+
<TooltipPrimitive.Content
|
|
17
|
+
ref={ref}
|
|
18
|
+
sideOffset={sideOffset}
|
|
19
|
+
className={cn(
|
|
20
|
+
"z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md 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",
|
|
21
|
+
className,
|
|
22
|
+
)}
|
|
23
|
+
{...props}
|
|
24
|
+
/>
|
|
25
|
+
));
|
|
26
|
+
TooltipContent.displayName = TooltipPrimitive.Content.displayName;
|
|
27
|
+
|
|
28
|
+
export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider };
|