create-ej-app 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +5 -0
- package/cli.js +68 -0
- package/package.json +36 -0
- package/template/.env.example +12 -0
- package/template/.eslintrc.cjs +24 -0
- package/template/components.json +16 -0
- package/template/next.config.mjs +18 -0
- package/template/package.json +68 -0
- package/template/postcss.config.cjs +6 -0
- package/template/prettier.config.ts +11 -0
- package/template/prisma/schema.prisma +136 -0
- package/template/public/next.svg +1 -0
- package/template/src/app/(app)/dashboard/page.tsx +19 -0
- package/template/src/app/(app)/layout.tsx +117 -0
- package/template/src/app/(app)/roles/[id]/actions.ts +100 -0
- package/template/src/app/(app)/roles/[id]/page.tsx +36 -0
- package/template/src/app/(app)/roles/[id]/render.tsx +266 -0
- package/template/src/app/(app)/roles/actions.ts +67 -0
- package/template/src/app/(app)/roles/page.tsx +51 -0
- package/template/src/app/(app)/roles/render.tsx +70 -0
- package/template/src/app/(app)/settings/actions.ts +18 -0
- package/template/src/app/(app)/settings/loading.tsx +28 -0
- package/template/src/app/(app)/settings/page.tsx +28 -0
- package/template/src/app/(app)/settings/render.tsx +113 -0
- package/template/src/app/(app)/tasks/[id]/actions.ts +107 -0
- package/template/src/app/(app)/tasks/[id]/page.tsx +55 -0
- package/template/src/app/(app)/tasks/[id]/render.tsx +307 -0
- package/template/src/app/(app)/tasks/actions.ts +75 -0
- package/template/src/app/(app)/tasks/page.tsx +66 -0
- package/template/src/app/(app)/tasks/render.tsx +124 -0
- package/template/src/app/(app)/users/[id]/actions.ts +104 -0
- package/template/src/app/(app)/users/[id]/page.tsx +39 -0
- package/template/src/app/(app)/users/[id]/render.tsx +320 -0
- package/template/src/app/(app)/users/actions.ts +67 -0
- package/template/src/app/(app)/users/page.tsx +61 -0
- package/template/src/app/(app)/users/render.tsx +108 -0
- package/template/src/app/(auth)/layout.tsx +20 -0
- package/template/src/app/(auth)/login/page.tsx +49 -0
- package/template/src/app/(auth)/login/user-auth-form.tsx +152 -0
- package/template/src/app/(marketing)/layout.tsx +42 -0
- package/template/src/app/(marketing)/page.tsx +96 -0
- package/template/src/app/api/auth/[...nextauth]/route.ts +7 -0
- package/template/src/app/favicon.ico +0 -0
- package/template/src/app/globals.css +76 -0
- package/template/src/app/layout.tsx +32 -0
- package/template/src/components/app-nav-command.tsx +160 -0
- package/template/src/components/dark-mode-toggle.tsx +43 -0
- package/template/src/components/data-table/data-table-column-header.tsx +91 -0
- package/template/src/components/data-table/data-table-faceted-filter.tsx +149 -0
- package/template/src/components/data-table/data-table-loading.tsx +77 -0
- package/template/src/components/data-table/data-table-pagination.tsx +94 -0
- package/template/src/components/data-table/data-table-toolbar.tsx +78 -0
- package/template/src/components/data-table/data-table-types.ts +17 -0
- package/template/src/components/data-table/data-table-view-options.tsx +59 -0
- package/template/src/components/data-table/data-table.tsx +301 -0
- package/template/src/components/data-table/simple-data-table.tsx +109 -0
- package/template/src/components/empty-placeholder.tsx +78 -0
- package/template/src/components/heading.tsx +17 -0
- package/template/src/components/icons.tsx +83 -0
- package/template/src/components/main-nav.tsx +64 -0
- package/template/src/components/mobile-nav.tsx +50 -0
- package/template/src/components/shell.tsx +13 -0
- package/template/src/components/side-nav.tsx +51 -0
- package/template/src/components/site-footer.tsx +31 -0
- package/template/src/components/system-info.tsx +36 -0
- package/template/src/components/theme-provider.tsx +13 -0
- package/template/src/components/ui/alert-dialog.tsx +145 -0
- package/template/src/components/ui/avatar.tsx +50 -0
- package/template/src/components/ui/badge.tsx +36 -0
- package/template/src/components/ui/button.tsx +56 -0
- package/template/src/components/ui/card.tsx +79 -0
- package/template/src/components/ui/checkbox.tsx +30 -0
- package/template/src/components/ui/command.tsx +155 -0
- package/template/src/components/ui/dialog.tsx +123 -0
- package/template/src/components/ui/dropdown-menu.tsx +200 -0
- package/template/src/components/ui/form.tsx +176 -0
- package/template/src/components/ui/input.tsx +25 -0
- package/template/src/components/ui/label.tsx +26 -0
- package/template/src/components/ui/popover.tsx +31 -0
- package/template/src/components/ui/select.tsx +121 -0
- package/template/src/components/ui/separator.tsx +31 -0
- package/template/src/components/ui/skeleton.tsx +15 -0
- package/template/src/components/ui/table.tsx +114 -0
- package/template/src/components/ui/textarea.tsx +24 -0
- package/template/src/components/ui/toast.tsx +127 -0
- package/template/src/components/ui/toaster.tsx +35 -0
- package/template/src/components/ui/use-toast.ts +189 -0
- package/template/src/components/user-account-nav.tsx +60 -0
- package/template/src/components/user-avatar.tsx +25 -0
- package/template/src/env.mjs +67 -0
- package/template/src/hooks/use-debounce.ts +17 -0
- package/template/src/hooks/use-lock-body.tsx +12 -0
- package/template/src/lib/auth.ts +183 -0
- package/template/src/lib/cn.ts +4 -0
- package/template/src/lib/db.ts +20 -0
- package/template/src/lib/delay.ts +2 -0
- package/template/src/lib/formatDate.ts +11 -0
- package/template/src/lib/generateLabel.ts +5 -0
- package/template/src/lib/siteConfig.ts +4 -0
- package/template/src/types/UnwrapPromise.ts +1 -0
- package/template/tailwind.config.ts +79 -0
- package/template/tsconfig.json +46 -0
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { DialogProps } from '@radix-ui/react-dialog'
|
|
4
|
+
import { Command as CommandPrimitive } from 'cmdk'
|
|
5
|
+
import { Search } from 'lucide-react'
|
|
6
|
+
import * as React from 'react'
|
|
7
|
+
|
|
8
|
+
import { Dialog, DialogContent } from '@/components/ui/dialog'
|
|
9
|
+
import { cn } from '@/lib/cn'
|
|
10
|
+
|
|
11
|
+
const Command = React.forwardRef<
|
|
12
|
+
React.ElementRef<typeof CommandPrimitive>,
|
|
13
|
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive>
|
|
14
|
+
>(({ className, ...props }, ref) => (
|
|
15
|
+
<CommandPrimitive
|
|
16
|
+
ref={ref}
|
|
17
|
+
className={cn(
|
|
18
|
+
'flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground',
|
|
19
|
+
className
|
|
20
|
+
)}
|
|
21
|
+
{...props}
|
|
22
|
+
/>
|
|
23
|
+
))
|
|
24
|
+
Command.displayName = CommandPrimitive.displayName
|
|
25
|
+
|
|
26
|
+
interface CommandDialogProps extends DialogProps {}
|
|
27
|
+
|
|
28
|
+
const CommandDialog = ({ children, ...props }: CommandDialogProps) => {
|
|
29
|
+
return (
|
|
30
|
+
<Dialog {...props}>
|
|
31
|
+
<DialogContent className="overflow-hidden p-0 shadow-lg">
|
|
32
|
+
<Command className="[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5">
|
|
33
|
+
{children}
|
|
34
|
+
</Command>
|
|
35
|
+
</DialogContent>
|
|
36
|
+
</Dialog>
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const CommandInput = React.forwardRef<
|
|
41
|
+
React.ElementRef<typeof CommandPrimitive.Input>,
|
|
42
|
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Input>
|
|
43
|
+
>(({ className, ...props }, ref) => (
|
|
44
|
+
<div className="flex items-center border-b px-3" cmdk-input-wrapper="">
|
|
45
|
+
<Search className="mr-2 h-4 w-4 shrink-0 opacity-50" />
|
|
46
|
+
<CommandPrimitive.Input
|
|
47
|
+
ref={ref}
|
|
48
|
+
className={cn(
|
|
49
|
+
'flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50',
|
|
50
|
+
className
|
|
51
|
+
)}
|
|
52
|
+
{...props}
|
|
53
|
+
/>
|
|
54
|
+
</div>
|
|
55
|
+
))
|
|
56
|
+
|
|
57
|
+
CommandInput.displayName = CommandPrimitive.Input.displayName
|
|
58
|
+
|
|
59
|
+
const CommandList = React.forwardRef<
|
|
60
|
+
React.ElementRef<typeof CommandPrimitive.List>,
|
|
61
|
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive.List>
|
|
62
|
+
>(({ className, ...props }, ref) => (
|
|
63
|
+
<CommandPrimitive.List
|
|
64
|
+
ref={ref}
|
|
65
|
+
className={cn('max-h-[300px] overflow-y-auto overflow-x-hidden', className)}
|
|
66
|
+
{...props}
|
|
67
|
+
/>
|
|
68
|
+
))
|
|
69
|
+
|
|
70
|
+
CommandList.displayName = CommandPrimitive.List.displayName
|
|
71
|
+
|
|
72
|
+
const CommandEmpty = React.forwardRef<
|
|
73
|
+
React.ElementRef<typeof CommandPrimitive.Empty>,
|
|
74
|
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Empty>
|
|
75
|
+
>((props, ref) => (
|
|
76
|
+
<CommandPrimitive.Empty
|
|
77
|
+
ref={ref}
|
|
78
|
+
className="py-6 text-center text-sm"
|
|
79
|
+
{...props}
|
|
80
|
+
/>
|
|
81
|
+
))
|
|
82
|
+
|
|
83
|
+
CommandEmpty.displayName = CommandPrimitive.Empty.displayName
|
|
84
|
+
|
|
85
|
+
const CommandGroup = React.forwardRef<
|
|
86
|
+
React.ElementRef<typeof CommandPrimitive.Group>,
|
|
87
|
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Group>
|
|
88
|
+
>(({ className, ...props }, ref) => (
|
|
89
|
+
<CommandPrimitive.Group
|
|
90
|
+
ref={ref}
|
|
91
|
+
className={cn(
|
|
92
|
+
'overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground',
|
|
93
|
+
className
|
|
94
|
+
)}
|
|
95
|
+
{...props}
|
|
96
|
+
/>
|
|
97
|
+
))
|
|
98
|
+
|
|
99
|
+
CommandGroup.displayName = CommandPrimitive.Group.displayName
|
|
100
|
+
|
|
101
|
+
const CommandSeparator = React.forwardRef<
|
|
102
|
+
React.ElementRef<typeof CommandPrimitive.Separator>,
|
|
103
|
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Separator>
|
|
104
|
+
>(({ className, ...props }, ref) => (
|
|
105
|
+
<CommandPrimitive.Separator
|
|
106
|
+
ref={ref}
|
|
107
|
+
className={cn('-mx-1 h-px bg-border', className)}
|
|
108
|
+
{...props}
|
|
109
|
+
/>
|
|
110
|
+
))
|
|
111
|
+
CommandSeparator.displayName = CommandPrimitive.Separator.displayName
|
|
112
|
+
|
|
113
|
+
const CommandItem = React.forwardRef<
|
|
114
|
+
React.ElementRef<typeof CommandPrimitive.Item>,
|
|
115
|
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Item>
|
|
116
|
+
>(({ className, ...props }, ref) => (
|
|
117
|
+
<CommandPrimitive.Item
|
|
118
|
+
ref={ref}
|
|
119
|
+
className={cn(
|
|
120
|
+
'relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none aria-selected:bg-accent aria-selected:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',
|
|
121
|
+
className
|
|
122
|
+
)}
|
|
123
|
+
{...props}
|
|
124
|
+
/>
|
|
125
|
+
))
|
|
126
|
+
|
|
127
|
+
CommandItem.displayName = CommandPrimitive.Item.displayName
|
|
128
|
+
|
|
129
|
+
const CommandShortcut = ({
|
|
130
|
+
className,
|
|
131
|
+
...props
|
|
132
|
+
}: React.HTMLAttributes<HTMLSpanElement>) => {
|
|
133
|
+
return (
|
|
134
|
+
<span
|
|
135
|
+
className={cn(
|
|
136
|
+
'ml-auto text-xs tracking-widest text-muted-foreground',
|
|
137
|
+
className
|
|
138
|
+
)}
|
|
139
|
+
{...props}
|
|
140
|
+
/>
|
|
141
|
+
)
|
|
142
|
+
}
|
|
143
|
+
CommandShortcut.displayName = 'CommandShortcut'
|
|
144
|
+
|
|
145
|
+
export {
|
|
146
|
+
Command,
|
|
147
|
+
CommandDialog,
|
|
148
|
+
CommandEmpty,
|
|
149
|
+
CommandGroup,
|
|
150
|
+
CommandInput,
|
|
151
|
+
CommandItem,
|
|
152
|
+
CommandList,
|
|
153
|
+
CommandSeparator,
|
|
154
|
+
CommandShortcut
|
|
155
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import * as DialogPrimitive from '@radix-ui/react-dialog'
|
|
4
|
+
import { X } from 'lucide-react'
|
|
5
|
+
import * as React from 'react'
|
|
6
|
+
|
|
7
|
+
import { cn } from '@/lib/cn'
|
|
8
|
+
|
|
9
|
+
const Dialog = DialogPrimitive.Root
|
|
10
|
+
|
|
11
|
+
const DialogTrigger = DialogPrimitive.Trigger
|
|
12
|
+
|
|
13
|
+
const DialogPortal = ({
|
|
14
|
+
className,
|
|
15
|
+
...props
|
|
16
|
+
}: DialogPrimitive.DialogPortalProps) => (
|
|
17
|
+
<DialogPrimitive.Portal className={cn(className)} {...props} />
|
|
18
|
+
)
|
|
19
|
+
DialogPortal.displayName = DialogPrimitive.Portal.displayName
|
|
20
|
+
|
|
21
|
+
const DialogOverlay = React.forwardRef<
|
|
22
|
+
React.ElementRef<typeof DialogPrimitive.Overlay>,
|
|
23
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
|
|
24
|
+
>(({ className, ...props }, ref) => (
|
|
25
|
+
<DialogPrimitive.Overlay
|
|
26
|
+
ref={ref}
|
|
27
|
+
className={cn(
|
|
28
|
+
'fixed inset-0 z-50 bg-background/80 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',
|
|
29
|
+
className
|
|
30
|
+
)}
|
|
31
|
+
{...props}
|
|
32
|
+
/>
|
|
33
|
+
))
|
|
34
|
+
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName
|
|
35
|
+
|
|
36
|
+
const DialogContent = React.forwardRef<
|
|
37
|
+
React.ElementRef<typeof DialogPrimitive.Content>,
|
|
38
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>
|
|
39
|
+
>(({ className, children, ...props }, ref) => (
|
|
40
|
+
<DialogPortal>
|
|
41
|
+
<DialogOverlay />
|
|
42
|
+
<DialogPrimitive.Content
|
|
43
|
+
ref={ref}
|
|
44
|
+
className={cn(
|
|
45
|
+
'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 md:w-full',
|
|
46
|
+
className
|
|
47
|
+
)}
|
|
48
|
+
{...props}
|
|
49
|
+
>
|
|
50
|
+
{children}
|
|
51
|
+
<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">
|
|
52
|
+
<X className="h-4 w-4" />
|
|
53
|
+
<span className="sr-only">Close</span>
|
|
54
|
+
</DialogPrimitive.Close>
|
|
55
|
+
</DialogPrimitive.Content>
|
|
56
|
+
</DialogPortal>
|
|
57
|
+
))
|
|
58
|
+
DialogContent.displayName = DialogPrimitive.Content.displayName
|
|
59
|
+
|
|
60
|
+
const DialogHeader = ({
|
|
61
|
+
className,
|
|
62
|
+
...props
|
|
63
|
+
}: React.HTMLAttributes<HTMLDivElement>) => (
|
|
64
|
+
<div
|
|
65
|
+
className={cn(
|
|
66
|
+
'flex flex-col space-y-1.5 text-center sm:text-left',
|
|
67
|
+
className
|
|
68
|
+
)}
|
|
69
|
+
{...props}
|
|
70
|
+
/>
|
|
71
|
+
)
|
|
72
|
+
DialogHeader.displayName = 'DialogHeader'
|
|
73
|
+
|
|
74
|
+
const DialogFooter = ({
|
|
75
|
+
className,
|
|
76
|
+
...props
|
|
77
|
+
}: React.HTMLAttributes<HTMLDivElement>) => (
|
|
78
|
+
<div
|
|
79
|
+
className={cn(
|
|
80
|
+
'flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2',
|
|
81
|
+
className
|
|
82
|
+
)}
|
|
83
|
+
{...props}
|
|
84
|
+
/>
|
|
85
|
+
)
|
|
86
|
+
DialogFooter.displayName = 'DialogFooter'
|
|
87
|
+
|
|
88
|
+
const DialogTitle = React.forwardRef<
|
|
89
|
+
React.ElementRef<typeof DialogPrimitive.Title>,
|
|
90
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
|
|
91
|
+
>(({ className, ...props }, ref) => (
|
|
92
|
+
<DialogPrimitive.Title
|
|
93
|
+
ref={ref}
|
|
94
|
+
className={cn(
|
|
95
|
+
'text-lg font-semibold leading-none tracking-tight',
|
|
96
|
+
className
|
|
97
|
+
)}
|
|
98
|
+
{...props}
|
|
99
|
+
/>
|
|
100
|
+
))
|
|
101
|
+
DialogTitle.displayName = DialogPrimitive.Title.displayName
|
|
102
|
+
|
|
103
|
+
const DialogDescription = React.forwardRef<
|
|
104
|
+
React.ElementRef<typeof DialogPrimitive.Description>,
|
|
105
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
|
|
106
|
+
>(({ className, ...props }, ref) => (
|
|
107
|
+
<DialogPrimitive.Description
|
|
108
|
+
ref={ref}
|
|
109
|
+
className={cn('text-sm text-muted-foreground', className)}
|
|
110
|
+
{...props}
|
|
111
|
+
/>
|
|
112
|
+
))
|
|
113
|
+
DialogDescription.displayName = DialogPrimitive.Description.displayName
|
|
114
|
+
|
|
115
|
+
export {
|
|
116
|
+
Dialog,
|
|
117
|
+
DialogContent,
|
|
118
|
+
DialogDescription,
|
|
119
|
+
DialogFooter,
|
|
120
|
+
DialogHeader,
|
|
121
|
+
DialogTitle,
|
|
122
|
+
DialogTrigger
|
|
123
|
+
}
|
|
@@ -0,0 +1,200 @@
|
|
|
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 { cn } from '@/lib/cn'
|
|
8
|
+
|
|
9
|
+
const DropdownMenu = DropdownMenuPrimitive.Root
|
|
10
|
+
|
|
11
|
+
const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger
|
|
12
|
+
|
|
13
|
+
const DropdownMenuGroup = DropdownMenuPrimitive.Group
|
|
14
|
+
|
|
15
|
+
const DropdownMenuPortal = DropdownMenuPrimitive.Portal
|
|
16
|
+
|
|
17
|
+
const DropdownMenuSub = DropdownMenuPrimitive.Sub
|
|
18
|
+
|
|
19
|
+
const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup
|
|
20
|
+
|
|
21
|
+
const DropdownMenuSubTrigger = React.forwardRef<
|
|
22
|
+
React.ElementRef<typeof DropdownMenuPrimitive.SubTrigger>,
|
|
23
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubTrigger> & {
|
|
24
|
+
inset?: boolean
|
|
25
|
+
}
|
|
26
|
+
>(({ className, inset, children, ...props }, ref) => (
|
|
27
|
+
<DropdownMenuPrimitive.SubTrigger
|
|
28
|
+
ref={ref}
|
|
29
|
+
className={cn(
|
|
30
|
+
'flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent',
|
|
31
|
+
inset && 'pl-8',
|
|
32
|
+
className
|
|
33
|
+
)}
|
|
34
|
+
{...props}
|
|
35
|
+
>
|
|
36
|
+
{children}
|
|
37
|
+
<ChevronRight className="ml-auto h-4 w-4" />
|
|
38
|
+
</DropdownMenuPrimitive.SubTrigger>
|
|
39
|
+
))
|
|
40
|
+
DropdownMenuSubTrigger.displayName =
|
|
41
|
+
DropdownMenuPrimitive.SubTrigger.displayName
|
|
42
|
+
|
|
43
|
+
const DropdownMenuSubContent = React.forwardRef<
|
|
44
|
+
React.ElementRef<typeof DropdownMenuPrimitive.SubContent>,
|
|
45
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubContent>
|
|
46
|
+
>(({ className, ...props }, ref) => (
|
|
47
|
+
<DropdownMenuPrimitive.SubContent
|
|
48
|
+
ref={ref}
|
|
49
|
+
className={cn(
|
|
50
|
+
'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',
|
|
51
|
+
className
|
|
52
|
+
)}
|
|
53
|
+
{...props}
|
|
54
|
+
/>
|
|
55
|
+
))
|
|
56
|
+
DropdownMenuSubContent.displayName =
|
|
57
|
+
DropdownMenuPrimitive.SubContent.displayName
|
|
58
|
+
|
|
59
|
+
const DropdownMenuContent = React.forwardRef<
|
|
60
|
+
React.ElementRef<typeof DropdownMenuPrimitive.Content>,
|
|
61
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content>
|
|
62
|
+
>(({ className, sideOffset = 4, ...props }, ref) => (
|
|
63
|
+
<DropdownMenuPrimitive.Portal>
|
|
64
|
+
<DropdownMenuPrimitive.Content
|
|
65
|
+
ref={ref}
|
|
66
|
+
sideOffset={sideOffset}
|
|
67
|
+
className={cn(
|
|
68
|
+
'z-50 min-w-[8rem] overflow-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',
|
|
69
|
+
className
|
|
70
|
+
)}
|
|
71
|
+
{...props}
|
|
72
|
+
/>
|
|
73
|
+
</DropdownMenuPrimitive.Portal>
|
|
74
|
+
))
|
|
75
|
+
DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName
|
|
76
|
+
|
|
77
|
+
const DropdownMenuItem = React.forwardRef<
|
|
78
|
+
React.ElementRef<typeof DropdownMenuPrimitive.Item>,
|
|
79
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item> & {
|
|
80
|
+
inset?: boolean
|
|
81
|
+
}
|
|
82
|
+
>(({ className, inset, ...props }, ref) => (
|
|
83
|
+
<DropdownMenuPrimitive.Item
|
|
84
|
+
ref={ref}
|
|
85
|
+
className={cn(
|
|
86
|
+
'relative flex cursor-default select-none items-center 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',
|
|
87
|
+
inset && 'pl-8',
|
|
88
|
+
className
|
|
89
|
+
)}
|
|
90
|
+
{...props}
|
|
91
|
+
/>
|
|
92
|
+
))
|
|
93
|
+
DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName
|
|
94
|
+
|
|
95
|
+
const DropdownMenuCheckboxItem = React.forwardRef<
|
|
96
|
+
React.ElementRef<typeof DropdownMenuPrimitive.CheckboxItem>,
|
|
97
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.CheckboxItem>
|
|
98
|
+
>(({ className, children, checked, ...props }, ref) => (
|
|
99
|
+
<DropdownMenuPrimitive.CheckboxItem
|
|
100
|
+
ref={ref}
|
|
101
|
+
className={cn(
|
|
102
|
+
'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',
|
|
103
|
+
className
|
|
104
|
+
)}
|
|
105
|
+
checked={checked}
|
|
106
|
+
{...props}
|
|
107
|
+
>
|
|
108
|
+
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
|
109
|
+
<DropdownMenuPrimitive.ItemIndicator>
|
|
110
|
+
<Check className="h-4 w-4" />
|
|
111
|
+
</DropdownMenuPrimitive.ItemIndicator>
|
|
112
|
+
</span>
|
|
113
|
+
{children}
|
|
114
|
+
</DropdownMenuPrimitive.CheckboxItem>
|
|
115
|
+
))
|
|
116
|
+
DropdownMenuCheckboxItem.displayName =
|
|
117
|
+
DropdownMenuPrimitive.CheckboxItem.displayName
|
|
118
|
+
|
|
119
|
+
const DropdownMenuRadioItem = React.forwardRef<
|
|
120
|
+
React.ElementRef<typeof DropdownMenuPrimitive.RadioItem>,
|
|
121
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.RadioItem>
|
|
122
|
+
>(({ className, children, ...props }, ref) => (
|
|
123
|
+
<DropdownMenuPrimitive.RadioItem
|
|
124
|
+
ref={ref}
|
|
125
|
+
className={cn(
|
|
126
|
+
'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',
|
|
127
|
+
className
|
|
128
|
+
)}
|
|
129
|
+
{...props}
|
|
130
|
+
>
|
|
131
|
+
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
|
132
|
+
<DropdownMenuPrimitive.ItemIndicator>
|
|
133
|
+
<Circle className="h-2 w-2 fill-current" />
|
|
134
|
+
</DropdownMenuPrimitive.ItemIndicator>
|
|
135
|
+
</span>
|
|
136
|
+
{children}
|
|
137
|
+
</DropdownMenuPrimitive.RadioItem>
|
|
138
|
+
))
|
|
139
|
+
DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName
|
|
140
|
+
|
|
141
|
+
const DropdownMenuLabel = React.forwardRef<
|
|
142
|
+
React.ElementRef<typeof DropdownMenuPrimitive.Label>,
|
|
143
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Label> & {
|
|
144
|
+
inset?: boolean
|
|
145
|
+
}
|
|
146
|
+
>(({ className, inset, ...props }, ref) => (
|
|
147
|
+
<DropdownMenuPrimitive.Label
|
|
148
|
+
ref={ref}
|
|
149
|
+
className={cn(
|
|
150
|
+
'px-2 py-1.5 text-sm font-semibold',
|
|
151
|
+
inset && 'pl-8',
|
|
152
|
+
className
|
|
153
|
+
)}
|
|
154
|
+
{...props}
|
|
155
|
+
/>
|
|
156
|
+
))
|
|
157
|
+
DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName
|
|
158
|
+
|
|
159
|
+
const DropdownMenuSeparator = React.forwardRef<
|
|
160
|
+
React.ElementRef<typeof DropdownMenuPrimitive.Separator>,
|
|
161
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Separator>
|
|
162
|
+
>(({ className, ...props }, ref) => (
|
|
163
|
+
<DropdownMenuPrimitive.Separator
|
|
164
|
+
ref={ref}
|
|
165
|
+
className={cn('-mx-1 my-1 h-px bg-muted', className)}
|
|
166
|
+
{...props}
|
|
167
|
+
/>
|
|
168
|
+
))
|
|
169
|
+
DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName
|
|
170
|
+
|
|
171
|
+
const DropdownMenuShortcut = ({
|
|
172
|
+
className,
|
|
173
|
+
...props
|
|
174
|
+
}: React.HTMLAttributes<HTMLSpanElement>) => {
|
|
175
|
+
return (
|
|
176
|
+
<span
|
|
177
|
+
className={cn('ml-auto text-xs tracking-widest opacity-60', className)}
|
|
178
|
+
{...props}
|
|
179
|
+
/>
|
|
180
|
+
)
|
|
181
|
+
}
|
|
182
|
+
DropdownMenuShortcut.displayName = 'DropdownMenuShortcut'
|
|
183
|
+
|
|
184
|
+
export {
|
|
185
|
+
DropdownMenu,
|
|
186
|
+
DropdownMenuCheckboxItem,
|
|
187
|
+
DropdownMenuContent,
|
|
188
|
+
DropdownMenuGroup,
|
|
189
|
+
DropdownMenuItem,
|
|
190
|
+
DropdownMenuLabel,
|
|
191
|
+
DropdownMenuPortal,
|
|
192
|
+
DropdownMenuRadioGroup,
|
|
193
|
+
DropdownMenuRadioItem,
|
|
194
|
+
DropdownMenuSeparator,
|
|
195
|
+
DropdownMenuShortcut,
|
|
196
|
+
DropdownMenuSub,
|
|
197
|
+
DropdownMenuSubContent,
|
|
198
|
+
DropdownMenuSubTrigger,
|
|
199
|
+
DropdownMenuTrigger
|
|
200
|
+
}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import * as LabelPrimitive from '@radix-ui/react-label'
|
|
2
|
+
import { Slot } from '@radix-ui/react-slot'
|
|
3
|
+
import * as React from 'react'
|
|
4
|
+
import {
|
|
5
|
+
Controller,
|
|
6
|
+
ControllerProps,
|
|
7
|
+
FieldPath,
|
|
8
|
+
FieldValues,
|
|
9
|
+
FormProvider,
|
|
10
|
+
useFormContext
|
|
11
|
+
} from 'react-hook-form'
|
|
12
|
+
|
|
13
|
+
import { Label } from '@/components/ui/label'
|
|
14
|
+
import { cn } from '@/lib/cn'
|
|
15
|
+
|
|
16
|
+
const Form = FormProvider
|
|
17
|
+
|
|
18
|
+
type FormFieldContextValue<
|
|
19
|
+
TFieldValues extends FieldValues = FieldValues,
|
|
20
|
+
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>
|
|
21
|
+
> = {
|
|
22
|
+
name: TName
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const FormFieldContext = React.createContext<FormFieldContextValue>(
|
|
26
|
+
{} as FormFieldContextValue
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
const FormField = <
|
|
30
|
+
TFieldValues extends FieldValues = FieldValues,
|
|
31
|
+
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>
|
|
32
|
+
>({
|
|
33
|
+
...props
|
|
34
|
+
}: ControllerProps<TFieldValues, TName>) => {
|
|
35
|
+
return (
|
|
36
|
+
<FormFieldContext.Provider value={{ name: props.name }}>
|
|
37
|
+
<Controller {...props} />
|
|
38
|
+
</FormFieldContext.Provider>
|
|
39
|
+
)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const useFormField = () => {
|
|
43
|
+
const fieldContext = React.useContext(FormFieldContext)
|
|
44
|
+
const itemContext = React.useContext(FormItemContext)
|
|
45
|
+
const { getFieldState, formState } = useFormContext()
|
|
46
|
+
|
|
47
|
+
const fieldState = getFieldState(fieldContext.name, formState)
|
|
48
|
+
|
|
49
|
+
if (!fieldContext) {
|
|
50
|
+
throw new Error('useFormField should be used within <FormField>')
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const { id } = itemContext
|
|
54
|
+
|
|
55
|
+
return {
|
|
56
|
+
id,
|
|
57
|
+
name: fieldContext.name,
|
|
58
|
+
formItemId: `${id}-form-item`,
|
|
59
|
+
formDescriptionId: `${id}-form-item-description`,
|
|
60
|
+
formMessageId: `${id}-form-item-message`,
|
|
61
|
+
...fieldState
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
type FormItemContextValue = {
|
|
66
|
+
id: string
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const FormItemContext = React.createContext<FormItemContextValue>(
|
|
70
|
+
{} as FormItemContextValue
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
const FormItem = React.forwardRef<
|
|
74
|
+
HTMLDivElement,
|
|
75
|
+
React.HTMLAttributes<HTMLDivElement>
|
|
76
|
+
>(({ className, ...props }, ref) => {
|
|
77
|
+
const id = React.useId()
|
|
78
|
+
|
|
79
|
+
return (
|
|
80
|
+
<FormItemContext.Provider value={{ id }}>
|
|
81
|
+
<div ref={ref} className={cn('space-y-2', className)} {...props} />
|
|
82
|
+
</FormItemContext.Provider>
|
|
83
|
+
)
|
|
84
|
+
})
|
|
85
|
+
FormItem.displayName = 'FormItem'
|
|
86
|
+
|
|
87
|
+
const FormLabel = React.forwardRef<
|
|
88
|
+
React.ElementRef<typeof LabelPrimitive.Root>,
|
|
89
|
+
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root>
|
|
90
|
+
>(({ className, ...props }, ref) => {
|
|
91
|
+
const { error, formItemId } = useFormField()
|
|
92
|
+
|
|
93
|
+
return (
|
|
94
|
+
<Label
|
|
95
|
+
ref={ref}
|
|
96
|
+
className={cn(error && 'text-destructive', className)}
|
|
97
|
+
htmlFor={formItemId}
|
|
98
|
+
{...props}
|
|
99
|
+
/>
|
|
100
|
+
)
|
|
101
|
+
})
|
|
102
|
+
FormLabel.displayName = 'FormLabel'
|
|
103
|
+
|
|
104
|
+
const FormControl = React.forwardRef<
|
|
105
|
+
React.ElementRef<typeof Slot>,
|
|
106
|
+
React.ComponentPropsWithoutRef<typeof Slot>
|
|
107
|
+
>(({ ...props }, ref) => {
|
|
108
|
+
const { error, formItemId, formDescriptionId, formMessageId } = useFormField()
|
|
109
|
+
|
|
110
|
+
return (
|
|
111
|
+
<Slot
|
|
112
|
+
ref={ref}
|
|
113
|
+
id={formItemId}
|
|
114
|
+
aria-describedby={
|
|
115
|
+
!error
|
|
116
|
+
? `${formDescriptionId}`
|
|
117
|
+
: `${formDescriptionId} ${formMessageId}`
|
|
118
|
+
}
|
|
119
|
+
aria-invalid={!!error}
|
|
120
|
+
{...props}
|
|
121
|
+
/>
|
|
122
|
+
)
|
|
123
|
+
})
|
|
124
|
+
FormControl.displayName = 'FormControl'
|
|
125
|
+
|
|
126
|
+
const FormDescription = React.forwardRef<
|
|
127
|
+
HTMLParagraphElement,
|
|
128
|
+
React.HTMLAttributes<HTMLParagraphElement>
|
|
129
|
+
>(({ className, ...props }, ref) => {
|
|
130
|
+
const { formDescriptionId } = useFormField()
|
|
131
|
+
|
|
132
|
+
return (
|
|
133
|
+
<p
|
|
134
|
+
ref={ref}
|
|
135
|
+
id={formDescriptionId}
|
|
136
|
+
className={cn('text-sm text-muted-foreground', className)}
|
|
137
|
+
{...props}
|
|
138
|
+
/>
|
|
139
|
+
)
|
|
140
|
+
})
|
|
141
|
+
FormDescription.displayName = 'FormDescription'
|
|
142
|
+
|
|
143
|
+
const FormMessage = React.forwardRef<
|
|
144
|
+
HTMLParagraphElement,
|
|
145
|
+
React.HTMLAttributes<HTMLParagraphElement>
|
|
146
|
+
>(({ className, children, ...props }, ref) => {
|
|
147
|
+
const { error, formMessageId } = useFormField()
|
|
148
|
+
const body = error ? String(error?.message) : children
|
|
149
|
+
|
|
150
|
+
if (!body) {
|
|
151
|
+
return null
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return (
|
|
155
|
+
<p
|
|
156
|
+
ref={ref}
|
|
157
|
+
id={formMessageId}
|
|
158
|
+
className={cn('text-sm font-medium text-destructive', className)}
|
|
159
|
+
{...props}
|
|
160
|
+
>
|
|
161
|
+
{body}
|
|
162
|
+
</p>
|
|
163
|
+
)
|
|
164
|
+
})
|
|
165
|
+
FormMessage.displayName = 'FormMessage'
|
|
166
|
+
|
|
167
|
+
export {
|
|
168
|
+
Form,
|
|
169
|
+
FormControl,
|
|
170
|
+
FormDescription,
|
|
171
|
+
FormField,
|
|
172
|
+
FormItem,
|
|
173
|
+
FormLabel,
|
|
174
|
+
FormMessage,
|
|
175
|
+
useFormField
|
|
176
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
|
|
3
|
+
import { cn } from '@/lib/cn'
|
|
4
|
+
|
|
5
|
+
export interface InputProps
|
|
6
|
+
extends React.InputHTMLAttributes<HTMLInputElement> {}
|
|
7
|
+
|
|
8
|
+
const Input = React.forwardRef<HTMLInputElement, InputProps>(
|
|
9
|
+
({ className, type, ...props }, ref) => {
|
|
10
|
+
return (
|
|
11
|
+
<input
|
|
12
|
+
type={type}
|
|
13
|
+
className={cn(
|
|
14
|
+
'flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50',
|
|
15
|
+
className
|
|
16
|
+
)}
|
|
17
|
+
ref={ref}
|
|
18
|
+
{...props}
|
|
19
|
+
/>
|
|
20
|
+
)
|
|
21
|
+
}
|
|
22
|
+
)
|
|
23
|
+
Input.displayName = 'Input'
|
|
24
|
+
|
|
25
|
+
export { Input }
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import * as LabelPrimitive from '@radix-ui/react-label'
|
|
4
|
+
import { cva, type VariantProps } from 'class-variance-authority'
|
|
5
|
+
import * as React from 'react'
|
|
6
|
+
|
|
7
|
+
import { cn } from '@/lib/cn'
|
|
8
|
+
|
|
9
|
+
const labelVariants = cva(
|
|
10
|
+
'text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70'
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
const Label = React.forwardRef<
|
|
14
|
+
React.ElementRef<typeof LabelPrimitive.Root>,
|
|
15
|
+
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> &
|
|
16
|
+
VariantProps<typeof labelVariants>
|
|
17
|
+
>(({ className, ...props }, ref) => (
|
|
18
|
+
<LabelPrimitive.Root
|
|
19
|
+
ref={ref}
|
|
20
|
+
className={cn(labelVariants(), className)}
|
|
21
|
+
{...props}
|
|
22
|
+
/>
|
|
23
|
+
))
|
|
24
|
+
Label.displayName = LabelPrimitive.Root.displayName
|
|
25
|
+
|
|
26
|
+
export { Label }
|