@gv-tech/ui-web 2.6.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/package.json +88 -0
- package/src/accordion.tsx +58 -0
- package/src/alert-dialog.tsx +121 -0
- package/src/alert.tsx +49 -0
- package/src/aspect-ratio.tsx +7 -0
- package/src/avatar.tsx +40 -0
- package/src/badge.tsx +34 -0
- package/src/breadcrumb.tsx +105 -0
- package/src/button.tsx +47 -0
- package/src/calendar.tsx +163 -0
- package/src/card.tsx +46 -0
- package/src/carousel.tsx +234 -0
- package/src/chart.tsx +296 -0
- package/src/checkbox.tsx +31 -0
- package/src/collapsible.tsx +15 -0
- package/src/command.tsx +154 -0
- package/src/context-menu.tsx +208 -0
- package/src/dialog.tsx +95 -0
- package/src/drawer.tsx +110 -0
- package/src/dropdown-menu.tsx +212 -0
- package/src/form.tsx +160 -0
- package/src/hooks/use-theme.ts +15 -0
- package/src/hooks/use-toast.ts +189 -0
- package/src/hover-card.tsx +35 -0
- package/src/index.ts +474 -0
- package/src/input.tsx +23 -0
- package/src/label.tsx +21 -0
- package/src/lib/utils.ts +6 -0
- package/src/menubar.tsx +244 -0
- package/src/navigation-menu.tsx +143 -0
- package/src/pagination.tsx +107 -0
- package/src/popover.tsx +45 -0
- package/src/progress.tsx +28 -0
- package/src/radio-group.tsx +41 -0
- package/src/resizable.tsx +59 -0
- package/src/scroll-area.tsx +42 -0
- package/src/search.tsx +87 -0
- package/src/select.tsx +169 -0
- package/src/separator.tsx +24 -0
- package/src/setupTests.ts +114 -0
- package/src/sheet.tsx +136 -0
- package/src/skeleton.tsx +10 -0
- package/src/slider.tsx +27 -0
- package/src/sonner.tsx +32 -0
- package/src/switch.tsx +31 -0
- package/src/table.tsx +104 -0
- package/src/tabs.tsx +62 -0
- package/src/text.tsx +55 -0
- package/src/textarea.tsx +25 -0
- package/src/theme-provider.tsx +15 -0
- package/src/theme-toggle.tsx +92 -0
- package/src/toast.tsx +111 -0
- package/src/toaster.tsx +27 -0
- package/src/toggle-group.tsx +55 -0
- package/src/toggle.tsx +24 -0
- package/src/tooltip.tsx +51 -0
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import * as ContextMenuPrimitive from '@radix-ui/react-context-menu';
|
|
2
|
+
import { Check, ChevronRight, Circle } from 'lucide-react';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
ContextMenuBaseProps,
|
|
7
|
+
ContextMenuCheckboxItemBaseProps,
|
|
8
|
+
ContextMenuContentBaseProps,
|
|
9
|
+
ContextMenuGroupBaseProps,
|
|
10
|
+
ContextMenuItemBaseProps,
|
|
11
|
+
ContextMenuLabelBaseProps,
|
|
12
|
+
ContextMenuRadioGroupBaseProps,
|
|
13
|
+
ContextMenuRadioItemBaseProps,
|
|
14
|
+
ContextMenuSeparatorBaseProps,
|
|
15
|
+
ContextMenuShortcutBaseProps,
|
|
16
|
+
ContextMenuSubBaseProps,
|
|
17
|
+
ContextMenuSubContentBaseProps,
|
|
18
|
+
ContextMenuSubTriggerBaseProps,
|
|
19
|
+
ContextMenuTriggerBaseProps,
|
|
20
|
+
} from '@gv-tech/ui-core';
|
|
21
|
+
import { cn } from './lib/utils';
|
|
22
|
+
|
|
23
|
+
const ContextMenu = ContextMenuPrimitive.Root;
|
|
24
|
+
|
|
25
|
+
const ContextMenuTrigger = ContextMenuPrimitive.Trigger;
|
|
26
|
+
|
|
27
|
+
const ContextMenuGroup = ContextMenuPrimitive.Group;
|
|
28
|
+
|
|
29
|
+
const ContextMenuPortal = ContextMenuPrimitive.Portal;
|
|
30
|
+
|
|
31
|
+
const ContextMenuSub = ContextMenuPrimitive.Sub;
|
|
32
|
+
|
|
33
|
+
const ContextMenuRadioGroup = ContextMenuPrimitive.RadioGroup;
|
|
34
|
+
|
|
35
|
+
const ContextMenuSubTrigger = React.forwardRef<
|
|
36
|
+
React.ElementRef<typeof ContextMenuPrimitive.SubTrigger>,
|
|
37
|
+
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.SubTrigger> & ContextMenuSubTriggerBaseProps
|
|
38
|
+
>(({ className, inset, children, ...props }, ref) => (
|
|
39
|
+
<ContextMenuPrimitive.SubTrigger
|
|
40
|
+
ref={ref}
|
|
41
|
+
className={cn(
|
|
42
|
+
'flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground',
|
|
43
|
+
inset && 'pl-8',
|
|
44
|
+
className,
|
|
45
|
+
)}
|
|
46
|
+
{...props}
|
|
47
|
+
>
|
|
48
|
+
{children}
|
|
49
|
+
<ChevronRight className="ml-auto h-4 w-4" />
|
|
50
|
+
</ContextMenuPrimitive.SubTrigger>
|
|
51
|
+
));
|
|
52
|
+
ContextMenuSubTrigger.displayName = ContextMenuPrimitive.SubTrigger.displayName;
|
|
53
|
+
|
|
54
|
+
const ContextMenuSubContent = React.forwardRef<
|
|
55
|
+
React.ElementRef<typeof ContextMenuPrimitive.SubContent>,
|
|
56
|
+
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.SubContent> & ContextMenuSubContentBaseProps
|
|
57
|
+
>(({ className, ...props }, ref) => (
|
|
58
|
+
<ContextMenuPrimitive.SubContent
|
|
59
|
+
ref={ref}
|
|
60
|
+
className={cn(
|
|
61
|
+
'z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg 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 origin-[--radix-context-menu-content-transform-origin]',
|
|
62
|
+
className,
|
|
63
|
+
)}
|
|
64
|
+
{...props}
|
|
65
|
+
/>
|
|
66
|
+
));
|
|
67
|
+
ContextMenuSubContent.displayName = ContextMenuPrimitive.SubContent.displayName;
|
|
68
|
+
|
|
69
|
+
const ContextMenuContent = React.forwardRef<
|
|
70
|
+
React.ElementRef<typeof ContextMenuPrimitive.Content>,
|
|
71
|
+
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Content> & ContextMenuContentBaseProps
|
|
72
|
+
>(({ className, ...props }, ref) => (
|
|
73
|
+
<ContextMenuPrimitive.Portal>
|
|
74
|
+
<ContextMenuPrimitive.Content
|
|
75
|
+
ref={ref}
|
|
76
|
+
className={cn(
|
|
77
|
+
'z-50 max-h-[--radix-context-menu-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover p-1 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 origin-[--radix-context-menu-content-transform-origin]',
|
|
78
|
+
className,
|
|
79
|
+
)}
|
|
80
|
+
{...props}
|
|
81
|
+
/>
|
|
82
|
+
</ContextMenuPrimitive.Portal>
|
|
83
|
+
));
|
|
84
|
+
ContextMenuContent.displayName = ContextMenuPrimitive.Content.displayName;
|
|
85
|
+
|
|
86
|
+
const ContextMenuItem = React.forwardRef<
|
|
87
|
+
React.ElementRef<typeof ContextMenuPrimitive.Item>,
|
|
88
|
+
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Item> & ContextMenuItemBaseProps
|
|
89
|
+
>(({ className, inset, ...props }, ref) => (
|
|
90
|
+
<ContextMenuPrimitive.Item
|
|
91
|
+
ref={ref}
|
|
92
|
+
className={cn(
|
|
93
|
+
'relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',
|
|
94
|
+
inset && 'pl-8',
|
|
95
|
+
className,
|
|
96
|
+
)}
|
|
97
|
+
{...props}
|
|
98
|
+
/>
|
|
99
|
+
));
|
|
100
|
+
ContextMenuItem.displayName = ContextMenuPrimitive.Item.displayName;
|
|
101
|
+
|
|
102
|
+
const ContextMenuCheckboxItem = React.forwardRef<
|
|
103
|
+
React.ElementRef<typeof ContextMenuPrimitive.CheckboxItem>,
|
|
104
|
+
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.CheckboxItem> & ContextMenuCheckboxItemBaseProps
|
|
105
|
+
>(({ className, children, checked, ...props }, ref) => (
|
|
106
|
+
<ContextMenuPrimitive.CheckboxItem
|
|
107
|
+
ref={ref}
|
|
108
|
+
className={cn(
|
|
109
|
+
'relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',
|
|
110
|
+
className,
|
|
111
|
+
)}
|
|
112
|
+
checked={checked}
|
|
113
|
+
{...props}
|
|
114
|
+
>
|
|
115
|
+
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
|
116
|
+
<ContextMenuPrimitive.ItemIndicator>
|
|
117
|
+
<Check className="h-4 w-4" />
|
|
118
|
+
</ContextMenuPrimitive.ItemIndicator>
|
|
119
|
+
</span>
|
|
120
|
+
{children}
|
|
121
|
+
</ContextMenuPrimitive.CheckboxItem>
|
|
122
|
+
));
|
|
123
|
+
ContextMenuCheckboxItem.displayName = ContextMenuPrimitive.CheckboxItem.displayName;
|
|
124
|
+
|
|
125
|
+
const ContextMenuRadioItem = React.forwardRef<
|
|
126
|
+
React.ElementRef<typeof ContextMenuPrimitive.RadioItem>,
|
|
127
|
+
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.RadioItem> & ContextMenuRadioItemBaseProps
|
|
128
|
+
>(({ className, children, ...props }, ref) => (
|
|
129
|
+
<ContextMenuPrimitive.RadioItem
|
|
130
|
+
ref={ref}
|
|
131
|
+
className={cn(
|
|
132
|
+
'relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',
|
|
133
|
+
className,
|
|
134
|
+
)}
|
|
135
|
+
{...props}
|
|
136
|
+
>
|
|
137
|
+
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
|
138
|
+
<ContextMenuPrimitive.ItemIndicator>
|
|
139
|
+
<Circle className="h-4 w-4 fill-current" />
|
|
140
|
+
</ContextMenuPrimitive.ItemIndicator>
|
|
141
|
+
</span>
|
|
142
|
+
{children}
|
|
143
|
+
</ContextMenuPrimitive.RadioItem>
|
|
144
|
+
));
|
|
145
|
+
ContextMenuRadioItem.displayName = ContextMenuPrimitive.RadioItem.displayName;
|
|
146
|
+
|
|
147
|
+
const ContextMenuLabel = React.forwardRef<
|
|
148
|
+
React.ElementRef<typeof ContextMenuPrimitive.Label>,
|
|
149
|
+
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Label> & ContextMenuLabelBaseProps
|
|
150
|
+
>(({ className, inset, ...props }, ref) => (
|
|
151
|
+
<ContextMenuPrimitive.Label
|
|
152
|
+
ref={ref}
|
|
153
|
+
className={cn('px-2 py-1.5 text-sm font-semibold text-foreground', inset && 'pl-8', className)}
|
|
154
|
+
{...props}
|
|
155
|
+
/>
|
|
156
|
+
));
|
|
157
|
+
ContextMenuLabel.displayName = ContextMenuPrimitive.Label.displayName;
|
|
158
|
+
|
|
159
|
+
const ContextMenuSeparator = React.forwardRef<
|
|
160
|
+
React.ElementRef<typeof ContextMenuPrimitive.Separator>,
|
|
161
|
+
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Separator> & ContextMenuSeparatorBaseProps
|
|
162
|
+
>(({ className, ...props }, ref) => (
|
|
163
|
+
<ContextMenuPrimitive.Separator ref={ref} className={cn('-mx-1 my-1 h-px bg-border', className)} {...props} />
|
|
164
|
+
));
|
|
165
|
+
ContextMenuSeparator.displayName = ContextMenuPrimitive.Separator.displayName;
|
|
166
|
+
|
|
167
|
+
const ContextMenuShortcut = ({
|
|
168
|
+
className,
|
|
169
|
+
...props
|
|
170
|
+
}: React.HTMLAttributes<HTMLSpanElement> & ContextMenuShortcutBaseProps) => {
|
|
171
|
+
return <span className={cn('ml-auto text-xs tracking-widest text-muted-foreground', className)} {...props} />;
|
|
172
|
+
};
|
|
173
|
+
ContextMenuShortcut.displayName = 'ContextMenuShortcut';
|
|
174
|
+
|
|
175
|
+
export {
|
|
176
|
+
ContextMenu,
|
|
177
|
+
ContextMenuCheckboxItem,
|
|
178
|
+
ContextMenuContent,
|
|
179
|
+
ContextMenuGroup,
|
|
180
|
+
ContextMenuItem,
|
|
181
|
+
ContextMenuLabel,
|
|
182
|
+
ContextMenuPortal,
|
|
183
|
+
ContextMenuRadioGroup,
|
|
184
|
+
ContextMenuRadioItem,
|
|
185
|
+
ContextMenuSeparator,
|
|
186
|
+
ContextMenuShortcut,
|
|
187
|
+
ContextMenuSub,
|
|
188
|
+
ContextMenuSubContent,
|
|
189
|
+
ContextMenuSubTrigger,
|
|
190
|
+
ContextMenuTrigger,
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
export type {
|
|
194
|
+
ContextMenuCheckboxItemBaseProps as ContextMenuCheckboxItemProps,
|
|
195
|
+
ContextMenuContentBaseProps as ContextMenuContentProps,
|
|
196
|
+
ContextMenuGroupBaseProps as ContextMenuGroupProps,
|
|
197
|
+
ContextMenuItemBaseProps as ContextMenuItemProps,
|
|
198
|
+
ContextMenuLabelBaseProps as ContextMenuLabelProps,
|
|
199
|
+
ContextMenuBaseProps as ContextMenuProps,
|
|
200
|
+
ContextMenuRadioGroupBaseProps as ContextMenuRadioGroupProps,
|
|
201
|
+
ContextMenuRadioItemBaseProps as ContextMenuRadioItemProps,
|
|
202
|
+
ContextMenuSeparatorBaseProps as ContextMenuSeparatorProps,
|
|
203
|
+
ContextMenuShortcutBaseProps as ContextMenuShortcutProps,
|
|
204
|
+
ContextMenuSubContentBaseProps as ContextMenuSubContentProps,
|
|
205
|
+
ContextMenuSubBaseProps as ContextMenuSubProps,
|
|
206
|
+
ContextMenuSubTriggerBaseProps as ContextMenuSubTriggerProps,
|
|
207
|
+
ContextMenuTriggerBaseProps as ContextMenuTriggerProps,
|
|
208
|
+
};
|
package/src/dialog.tsx
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
2
|
+
import { X } from 'lucide-react';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
|
|
5
|
+
import { cn } from './lib/utils';
|
|
6
|
+
|
|
7
|
+
const Dialog = DialogPrimitive.Root;
|
|
8
|
+
|
|
9
|
+
const DialogTrigger = DialogPrimitive.Trigger;
|
|
10
|
+
|
|
11
|
+
const DialogPortal = DialogPrimitive.Portal;
|
|
12
|
+
|
|
13
|
+
const DialogClose = DialogPrimitive.Close;
|
|
14
|
+
|
|
15
|
+
const DialogOverlay = React.forwardRef<
|
|
16
|
+
React.ElementRef<typeof DialogPrimitive.Overlay>,
|
|
17
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
|
|
18
|
+
>(({ className, ...props }, ref) => (
|
|
19
|
+
<DialogPrimitive.Overlay
|
|
20
|
+
ref={ref}
|
|
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
|
+
/>
|
|
27
|
+
));
|
|
28
|
+
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
|
|
29
|
+
|
|
30
|
+
const DialogContent = React.forwardRef<
|
|
31
|
+
React.ElementRef<typeof DialogPrimitive.Content>,
|
|
32
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>
|
|
33
|
+
>(({ className, children, ...props }, ref) => (
|
|
34
|
+
<DialogPortal>
|
|
35
|
+
<DialogOverlay />
|
|
36
|
+
<DialogPrimitive.Content
|
|
37
|
+
ref={ref}
|
|
38
|
+
className={cn(
|
|
39
|
+
'fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 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-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg',
|
|
40
|
+
className,
|
|
41
|
+
)}
|
|
42
|
+
{...props}
|
|
43
|
+
>
|
|
44
|
+
{children}
|
|
45
|
+
<DialogPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground">
|
|
46
|
+
<X className="h-4 w-4" />
|
|
47
|
+
<span className="sr-only">Close</span>
|
|
48
|
+
</DialogPrimitive.Close>
|
|
49
|
+
</DialogPrimitive.Content>
|
|
50
|
+
</DialogPortal>
|
|
51
|
+
));
|
|
52
|
+
DialogContent.displayName = DialogPrimitive.Content.displayName;
|
|
53
|
+
|
|
54
|
+
const DialogHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
|
|
55
|
+
<div className={cn('flex flex-col space-y-1.5 text-center sm:text-left', className)} {...props} />
|
|
56
|
+
);
|
|
57
|
+
DialogHeader.displayName = 'DialogHeader';
|
|
58
|
+
|
|
59
|
+
const DialogFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
|
|
60
|
+
<div className={cn('flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2', className)} {...props} />
|
|
61
|
+
);
|
|
62
|
+
DialogFooter.displayName = 'DialogFooter';
|
|
63
|
+
|
|
64
|
+
const DialogTitle = React.forwardRef<
|
|
65
|
+
React.ElementRef<typeof DialogPrimitive.Title>,
|
|
66
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
|
|
67
|
+
>(({ className, ...props }, ref) => (
|
|
68
|
+
<DialogPrimitive.Title
|
|
69
|
+
ref={ref}
|
|
70
|
+
className={cn('text-lg font-semibold leading-none tracking-tight', className)}
|
|
71
|
+
{...props}
|
|
72
|
+
/>
|
|
73
|
+
));
|
|
74
|
+
DialogTitle.displayName = DialogPrimitive.Title.displayName;
|
|
75
|
+
|
|
76
|
+
const DialogDescription = React.forwardRef<
|
|
77
|
+
React.ElementRef<typeof DialogPrimitive.Description>,
|
|
78
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
|
|
79
|
+
>(({ className, ...props }, ref) => (
|
|
80
|
+
<DialogPrimitive.Description ref={ref} className={cn('text-sm text-muted-foreground', className)} {...props} />
|
|
81
|
+
));
|
|
82
|
+
DialogDescription.displayName = DialogPrimitive.Description.displayName;
|
|
83
|
+
|
|
84
|
+
export {
|
|
85
|
+
Dialog,
|
|
86
|
+
DialogClose,
|
|
87
|
+
DialogContent,
|
|
88
|
+
DialogDescription,
|
|
89
|
+
DialogFooter,
|
|
90
|
+
DialogHeader,
|
|
91
|
+
DialogOverlay,
|
|
92
|
+
DialogPortal,
|
|
93
|
+
DialogTitle,
|
|
94
|
+
DialogTrigger,
|
|
95
|
+
};
|
package/src/drawer.tsx
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { Drawer as DrawerPrimitive } from 'vaul';
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
DrawerBaseProps,
|
|
8
|
+
DrawerCloseBaseProps,
|
|
9
|
+
DrawerContentBaseProps,
|
|
10
|
+
DrawerDescriptionBaseProps,
|
|
11
|
+
DrawerFooterBaseProps,
|
|
12
|
+
DrawerHeaderBaseProps,
|
|
13
|
+
DrawerTitleBaseProps,
|
|
14
|
+
DrawerTriggerBaseProps,
|
|
15
|
+
} from '@gv-tech/ui-core';
|
|
16
|
+
import { cn } from './lib/utils';
|
|
17
|
+
|
|
18
|
+
const Drawer = ({ shouldScaleBackground = true, ...props }: React.ComponentProps<typeof DrawerPrimitive.Root>) => (
|
|
19
|
+
<DrawerPrimitive.Root shouldScaleBackground={shouldScaleBackground} {...props} />
|
|
20
|
+
);
|
|
21
|
+
Drawer.displayName = 'Drawer';
|
|
22
|
+
|
|
23
|
+
const DrawerTrigger = DrawerPrimitive.Trigger;
|
|
24
|
+
|
|
25
|
+
const DrawerPortal = DrawerPrimitive.Portal;
|
|
26
|
+
|
|
27
|
+
const DrawerClose = DrawerPrimitive.Close;
|
|
28
|
+
|
|
29
|
+
const DrawerOverlay = React.forwardRef<
|
|
30
|
+
React.ElementRef<typeof DrawerPrimitive.Overlay>,
|
|
31
|
+
React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Overlay>
|
|
32
|
+
>(({ className, ...props }, ref) => (
|
|
33
|
+
<DrawerPrimitive.Overlay ref={ref} className={cn('fixed inset-0 z-50 bg-black/80', className)} {...props} />
|
|
34
|
+
));
|
|
35
|
+
DrawerOverlay.displayName = DrawerPrimitive.Overlay.displayName;
|
|
36
|
+
|
|
37
|
+
const DrawerContent = React.forwardRef<
|
|
38
|
+
React.ElementRef<typeof DrawerPrimitive.Content>,
|
|
39
|
+
React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Content> & DrawerContentBaseProps
|
|
40
|
+
>(({ className, children, ...props }, ref) => (
|
|
41
|
+
<DrawerPortal>
|
|
42
|
+
<DrawerOverlay />
|
|
43
|
+
<DrawerPrimitive.Content
|
|
44
|
+
ref={ref}
|
|
45
|
+
className={cn(
|
|
46
|
+
'fixed inset-x-0 bottom-0 z-50 mt-24 flex h-auto flex-col rounded-t-[10px] border bg-background',
|
|
47
|
+
className,
|
|
48
|
+
)}
|
|
49
|
+
{...props}
|
|
50
|
+
>
|
|
51
|
+
<div className="mx-auto mt-4 h-2 w-[100px] rounded-full bg-muted" />
|
|
52
|
+
{children}
|
|
53
|
+
</DrawerPrimitive.Content>
|
|
54
|
+
</DrawerPortal>
|
|
55
|
+
));
|
|
56
|
+
DrawerContent.displayName = 'DrawerContent';
|
|
57
|
+
|
|
58
|
+
const DrawerHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement> & DrawerHeaderBaseProps) => (
|
|
59
|
+
<div className={cn('grid gap-1.5 p-4 text-center sm:text-left', className)} {...props} />
|
|
60
|
+
);
|
|
61
|
+
DrawerHeader.displayName = 'DrawerHeader';
|
|
62
|
+
|
|
63
|
+
const DrawerFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement> & DrawerFooterBaseProps) => (
|
|
64
|
+
<div className={cn('mt-auto flex flex-col gap-2 p-4', className)} {...props} />
|
|
65
|
+
);
|
|
66
|
+
DrawerFooter.displayName = 'DrawerFooter';
|
|
67
|
+
|
|
68
|
+
const DrawerTitle = React.forwardRef<
|
|
69
|
+
React.ElementRef<typeof DrawerPrimitive.Title>,
|
|
70
|
+
React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Title> & DrawerTitleBaseProps
|
|
71
|
+
>(({ className, ...props }, ref) => (
|
|
72
|
+
<DrawerPrimitive.Title
|
|
73
|
+
ref={ref}
|
|
74
|
+
className={cn('text-lg font-semibold leading-none tracking-tight', className)}
|
|
75
|
+
{...props}
|
|
76
|
+
/>
|
|
77
|
+
));
|
|
78
|
+
DrawerTitle.displayName = DrawerPrimitive.Title.displayName;
|
|
79
|
+
|
|
80
|
+
const DrawerDescription = React.forwardRef<
|
|
81
|
+
React.ElementRef<typeof DrawerPrimitive.Description>,
|
|
82
|
+
React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Description> & DrawerDescriptionBaseProps
|
|
83
|
+
>(({ className, ...props }, ref) => (
|
|
84
|
+
<DrawerPrimitive.Description ref={ref} className={cn('text-sm text-muted-foreground', className)} {...props} />
|
|
85
|
+
));
|
|
86
|
+
DrawerDescription.displayName = DrawerPrimitive.Description.displayName;
|
|
87
|
+
|
|
88
|
+
export {
|
|
89
|
+
Drawer,
|
|
90
|
+
DrawerClose,
|
|
91
|
+
DrawerContent,
|
|
92
|
+
DrawerDescription,
|
|
93
|
+
DrawerFooter,
|
|
94
|
+
DrawerHeader,
|
|
95
|
+
DrawerOverlay,
|
|
96
|
+
DrawerPortal,
|
|
97
|
+
DrawerTitle,
|
|
98
|
+
DrawerTrigger,
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export type {
|
|
102
|
+
DrawerCloseBaseProps as DrawerCloseProps,
|
|
103
|
+
DrawerContentBaseProps as DrawerContentProps,
|
|
104
|
+
DrawerDescriptionBaseProps as DrawerDescriptionProps,
|
|
105
|
+
DrawerFooterBaseProps as DrawerFooterProps,
|
|
106
|
+
DrawerHeaderBaseProps as DrawerHeaderProps,
|
|
107
|
+
DrawerBaseProps as DrawerProps,
|
|
108
|
+
DrawerTitleBaseProps as DrawerTitleProps,
|
|
109
|
+
DrawerTriggerBaseProps as DrawerTriggerProps,
|
|
110
|
+
};
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
|
|
4
|
+
import { Check, ChevronRight, Circle } from 'lucide-react';
|
|
5
|
+
import * as React from 'react';
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
DropdownMenuBaseProps,
|
|
9
|
+
DropdownMenuCheckboxItemBaseProps,
|
|
10
|
+
DropdownMenuContentBaseProps,
|
|
11
|
+
DropdownMenuGroupBaseProps,
|
|
12
|
+
DropdownMenuItemBaseProps,
|
|
13
|
+
DropdownMenuLabelBaseProps,
|
|
14
|
+
DropdownMenuRadioGroupBaseProps,
|
|
15
|
+
DropdownMenuRadioItemBaseProps,
|
|
16
|
+
DropdownMenuSeparatorBaseProps,
|
|
17
|
+
DropdownMenuShortcutBaseProps,
|
|
18
|
+
DropdownMenuSubBaseProps,
|
|
19
|
+
DropdownMenuSubContentBaseProps,
|
|
20
|
+
DropdownMenuSubTriggerBaseProps,
|
|
21
|
+
DropdownMenuTriggerBaseProps,
|
|
22
|
+
} from '@gv-tech/ui-core';
|
|
23
|
+
import { cn } from './lib/utils';
|
|
24
|
+
|
|
25
|
+
const DropdownMenu = DropdownMenuPrimitive.Root;
|
|
26
|
+
|
|
27
|
+
const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
|
|
28
|
+
|
|
29
|
+
const DropdownMenuGroup = DropdownMenuPrimitive.Group;
|
|
30
|
+
|
|
31
|
+
const DropdownMenuPortal = DropdownMenuPrimitive.Portal;
|
|
32
|
+
|
|
33
|
+
const DropdownMenuSub = DropdownMenuPrimitive.Sub;
|
|
34
|
+
|
|
35
|
+
const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;
|
|
36
|
+
|
|
37
|
+
const DropdownMenuSubTrigger = React.forwardRef<
|
|
38
|
+
React.ElementRef<typeof DropdownMenuPrimitive.SubTrigger>,
|
|
39
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubTrigger> & DropdownMenuSubTriggerBaseProps
|
|
40
|
+
>(({ className, inset, children, ...props }, ref) => (
|
|
41
|
+
<DropdownMenuPrimitive.SubTrigger
|
|
42
|
+
ref={ref}
|
|
43
|
+
className={cn(
|
|
44
|
+
'flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0',
|
|
45
|
+
inset && 'pl-8',
|
|
46
|
+
className,
|
|
47
|
+
)}
|
|
48
|
+
{...props}
|
|
49
|
+
>
|
|
50
|
+
{children}
|
|
51
|
+
<ChevronRight className="ml-auto" />
|
|
52
|
+
</DropdownMenuPrimitive.SubTrigger>
|
|
53
|
+
));
|
|
54
|
+
DropdownMenuSubTrigger.displayName = DropdownMenuPrimitive.SubTrigger.displayName;
|
|
55
|
+
|
|
56
|
+
const DropdownMenuSubContent = React.forwardRef<
|
|
57
|
+
React.ElementRef<typeof DropdownMenuPrimitive.SubContent>,
|
|
58
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubContent> & DropdownMenuSubContentBaseProps
|
|
59
|
+
>(({ className, ...props }, ref) => (
|
|
60
|
+
<DropdownMenuPrimitive.SubContent
|
|
61
|
+
ref={ref}
|
|
62
|
+
className={cn(
|
|
63
|
+
'z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg 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 origin-[--radix-dropdown-menu-content-transform-origin]',
|
|
64
|
+
className,
|
|
65
|
+
)}
|
|
66
|
+
{...props}
|
|
67
|
+
/>
|
|
68
|
+
));
|
|
69
|
+
DropdownMenuSubContent.displayName = DropdownMenuPrimitive.SubContent.displayName;
|
|
70
|
+
|
|
71
|
+
const DropdownMenuContent = React.forwardRef<
|
|
72
|
+
React.ElementRef<typeof DropdownMenuPrimitive.Content>,
|
|
73
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content> & DropdownMenuContentBaseProps
|
|
74
|
+
>(({ className, sideOffset = 4, ...props }, ref) => (
|
|
75
|
+
<DropdownMenuPrimitive.Portal>
|
|
76
|
+
<DropdownMenuPrimitive.Content
|
|
77
|
+
ref={ref}
|
|
78
|
+
sideOffset={sideOffset}
|
|
79
|
+
className={cn(
|
|
80
|
+
'z-50 max-h-[var(--radix-dropdown-menu-content-available-height)] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md',
|
|
81
|
+
'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 origin-[--radix-dropdown-menu-content-transform-origin]',
|
|
82
|
+
className,
|
|
83
|
+
)}
|
|
84
|
+
{...props}
|
|
85
|
+
/>
|
|
86
|
+
</DropdownMenuPrimitive.Portal>
|
|
87
|
+
));
|
|
88
|
+
DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName;
|
|
89
|
+
|
|
90
|
+
const DropdownMenuItem = React.forwardRef<
|
|
91
|
+
React.ElementRef<typeof DropdownMenuPrimitive.Item>,
|
|
92
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item> & DropdownMenuItemBaseProps
|
|
93
|
+
>(({ className, inset, ...props }, ref) => (
|
|
94
|
+
<DropdownMenuPrimitive.Item
|
|
95
|
+
ref={ref}
|
|
96
|
+
className={cn(
|
|
97
|
+
'relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>svg]:size-4 [&>svg]:shrink-0',
|
|
98
|
+
inset && 'pl-8',
|
|
99
|
+
className,
|
|
100
|
+
)}
|
|
101
|
+
{...props}
|
|
102
|
+
/>
|
|
103
|
+
));
|
|
104
|
+
DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName;
|
|
105
|
+
|
|
106
|
+
const DropdownMenuCheckboxItem = React.forwardRef<
|
|
107
|
+
React.ElementRef<typeof DropdownMenuPrimitive.CheckboxItem>,
|
|
108
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.CheckboxItem> & DropdownMenuCheckboxItemBaseProps
|
|
109
|
+
>(({ className, children, checked, ...props }, ref) => (
|
|
110
|
+
<DropdownMenuPrimitive.CheckboxItem
|
|
111
|
+
ref={ref}
|
|
112
|
+
className={cn(
|
|
113
|
+
'relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',
|
|
114
|
+
className,
|
|
115
|
+
)}
|
|
116
|
+
checked={checked}
|
|
117
|
+
{...props}
|
|
118
|
+
>
|
|
119
|
+
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
|
120
|
+
<DropdownMenuPrimitive.ItemIndicator>
|
|
121
|
+
<Check className="h-4 w-4" />
|
|
122
|
+
</DropdownMenuPrimitive.ItemIndicator>
|
|
123
|
+
</span>
|
|
124
|
+
{children}
|
|
125
|
+
</DropdownMenuPrimitive.CheckboxItem>
|
|
126
|
+
));
|
|
127
|
+
DropdownMenuCheckboxItem.displayName = DropdownMenuPrimitive.CheckboxItem.displayName;
|
|
128
|
+
|
|
129
|
+
const DropdownMenuRadioItem = React.forwardRef<
|
|
130
|
+
React.ElementRef<typeof DropdownMenuPrimitive.RadioItem>,
|
|
131
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.RadioItem> & DropdownMenuRadioItemBaseProps
|
|
132
|
+
>(({ className, children, ...props }, ref) => (
|
|
133
|
+
<DropdownMenuPrimitive.RadioItem
|
|
134
|
+
ref={ref}
|
|
135
|
+
className={cn(
|
|
136
|
+
'relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',
|
|
137
|
+
className,
|
|
138
|
+
)}
|
|
139
|
+
{...props}
|
|
140
|
+
>
|
|
141
|
+
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
|
142
|
+
<DropdownMenuPrimitive.ItemIndicator>
|
|
143
|
+
<Circle className="h-2 w-2 fill-current" />
|
|
144
|
+
</DropdownMenuPrimitive.ItemIndicator>
|
|
145
|
+
</span>
|
|
146
|
+
{children}
|
|
147
|
+
</DropdownMenuPrimitive.RadioItem>
|
|
148
|
+
));
|
|
149
|
+
DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName;
|
|
150
|
+
|
|
151
|
+
const DropdownMenuLabel = React.forwardRef<
|
|
152
|
+
React.ElementRef<typeof DropdownMenuPrimitive.Label>,
|
|
153
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Label> & DropdownMenuLabelBaseProps
|
|
154
|
+
>(({ className, inset, ...props }, ref) => (
|
|
155
|
+
<DropdownMenuPrimitive.Label
|
|
156
|
+
ref={ref}
|
|
157
|
+
className={cn('px-2 py-1.5 text-sm font-semibold', inset && 'pl-8', className)}
|
|
158
|
+
{...props}
|
|
159
|
+
/>
|
|
160
|
+
));
|
|
161
|
+
DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName;
|
|
162
|
+
|
|
163
|
+
const DropdownMenuSeparator = React.forwardRef<
|
|
164
|
+
React.ElementRef<typeof DropdownMenuPrimitive.Separator>,
|
|
165
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Separator> & DropdownMenuSeparatorBaseProps
|
|
166
|
+
>(({ className, ...props }, ref) => (
|
|
167
|
+
<DropdownMenuPrimitive.Separator ref={ref} className={cn('-mx-1 my-1 h-px bg-muted', className)} {...props} />
|
|
168
|
+
));
|
|
169
|
+
DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName;
|
|
170
|
+
|
|
171
|
+
const DropdownMenuShortcut = ({
|
|
172
|
+
className,
|
|
173
|
+
...props
|
|
174
|
+
}: React.HTMLAttributes<HTMLSpanElement> & DropdownMenuShortcutBaseProps) => {
|
|
175
|
+
return <span className={cn('ml-auto text-xs tracking-widest opacity-60', className)} {...props} />;
|
|
176
|
+
};
|
|
177
|
+
DropdownMenuShortcut.displayName = 'DropdownMenuShortcut';
|
|
178
|
+
|
|
179
|
+
export {
|
|
180
|
+
DropdownMenu,
|
|
181
|
+
DropdownMenuCheckboxItem,
|
|
182
|
+
DropdownMenuContent,
|
|
183
|
+
DropdownMenuGroup,
|
|
184
|
+
DropdownMenuItem,
|
|
185
|
+
DropdownMenuLabel,
|
|
186
|
+
DropdownMenuPortal,
|
|
187
|
+
DropdownMenuRadioGroup,
|
|
188
|
+
DropdownMenuRadioItem,
|
|
189
|
+
DropdownMenuSeparator,
|
|
190
|
+
DropdownMenuShortcut,
|
|
191
|
+
DropdownMenuSub,
|
|
192
|
+
DropdownMenuSubContent,
|
|
193
|
+
DropdownMenuSubTrigger,
|
|
194
|
+
DropdownMenuTrigger,
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
export type {
|
|
198
|
+
DropdownMenuCheckboxItemBaseProps as DropdownMenuCheckboxItemProps,
|
|
199
|
+
DropdownMenuContentBaseProps as DropdownMenuContentProps,
|
|
200
|
+
DropdownMenuGroupBaseProps as DropdownMenuGroupProps,
|
|
201
|
+
DropdownMenuItemBaseProps as DropdownMenuItemProps,
|
|
202
|
+
DropdownMenuLabelBaseProps as DropdownMenuLabelProps,
|
|
203
|
+
DropdownMenuBaseProps as DropdownMenuProps,
|
|
204
|
+
DropdownMenuRadioGroupBaseProps as DropdownMenuRadioGroupProps,
|
|
205
|
+
DropdownMenuRadioItemBaseProps as DropdownMenuRadioItemProps,
|
|
206
|
+
DropdownMenuSeparatorBaseProps as DropdownMenuSeparatorProps,
|
|
207
|
+
DropdownMenuShortcutBaseProps as DropdownMenuShortcutProps,
|
|
208
|
+
DropdownMenuSubContentBaseProps as DropdownMenuSubContentProps,
|
|
209
|
+
DropdownMenuSubBaseProps as DropdownMenuSubProps,
|
|
210
|
+
DropdownMenuSubTriggerBaseProps as DropdownMenuSubTriggerProps,
|
|
211
|
+
DropdownMenuTriggerBaseProps as DropdownMenuTriggerProps,
|
|
212
|
+
};
|