forge-admin 0.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.
Files changed (131) hide show
  1. package/README.md +73 -0
  2. package/app.db +0 -0
  3. package/components.json +20 -0
  4. package/dist/assets/index-BPVmexx_.css +1 -0
  5. package/dist/assets/index-BtNewH3n.js +258 -0
  6. package/dist/favicon.ico +0 -0
  7. package/dist/index.html +27 -0
  8. package/dist/placeholder.svg +1 -0
  9. package/dist/robots.txt +14 -0
  10. package/eslint.config.js +26 -0
  11. package/index.html +26 -0
  12. package/package.json +107 -0
  13. package/postcss.config.js +6 -0
  14. package/public/favicon.ico +0 -0
  15. package/public/placeholder.svg +1 -0
  16. package/public/robots.txt +14 -0
  17. package/src/App.css +42 -0
  18. package/src/App.tsx +32 -0
  19. package/src/admin/convertSchema.ts +83 -0
  20. package/src/admin/factory.ts +12 -0
  21. package/src/admin/introspecter.ts +6 -0
  22. package/src/admin/router.ts +38 -0
  23. package/src/admin/schema.ts +17 -0
  24. package/src/admin/sqlite.ts +73 -0
  25. package/src/admin/types.ts +35 -0
  26. package/src/components/AdminLayout.tsx +19 -0
  27. package/src/components/AdminSidebar.tsx +102 -0
  28. package/src/components/DataTable.tsx +166 -0
  29. package/src/components/ModelForm.tsx +221 -0
  30. package/src/components/NavLink.tsx +28 -0
  31. package/src/components/StatCard.tsx +32 -0
  32. package/src/components/ui/accordion.tsx +52 -0
  33. package/src/components/ui/alert-dialog.tsx +104 -0
  34. package/src/components/ui/alert.tsx +43 -0
  35. package/src/components/ui/aspect-ratio.tsx +5 -0
  36. package/src/components/ui/avatar.tsx +38 -0
  37. package/src/components/ui/badge.tsx +29 -0
  38. package/src/components/ui/breadcrumb.tsx +90 -0
  39. package/src/components/ui/button.tsx +47 -0
  40. package/src/components/ui/calendar.tsx +54 -0
  41. package/src/components/ui/card.tsx +43 -0
  42. package/src/components/ui/carousel.tsx +224 -0
  43. package/src/components/ui/chart.tsx +303 -0
  44. package/src/components/ui/checkbox.tsx +26 -0
  45. package/src/components/ui/collapsible.tsx +9 -0
  46. package/src/components/ui/command.tsx +132 -0
  47. package/src/components/ui/context-menu.tsx +178 -0
  48. package/src/components/ui/dialog.tsx +95 -0
  49. package/src/components/ui/drawer.tsx +87 -0
  50. package/src/components/ui/dropdown-menu.tsx +179 -0
  51. package/src/components/ui/form.tsx +129 -0
  52. package/src/components/ui/hover-card.tsx +27 -0
  53. package/src/components/ui/input-otp.tsx +61 -0
  54. package/src/components/ui/input.tsx +22 -0
  55. package/src/components/ui/label.tsx +17 -0
  56. package/src/components/ui/menubar.tsx +207 -0
  57. package/src/components/ui/navigation-menu.tsx +120 -0
  58. package/src/components/ui/pagination.tsx +81 -0
  59. package/src/components/ui/popover.tsx +29 -0
  60. package/src/components/ui/progress.tsx +23 -0
  61. package/src/components/ui/radio-group.tsx +36 -0
  62. package/src/components/ui/resizable.tsx +37 -0
  63. package/src/components/ui/scroll-area.tsx +38 -0
  64. package/src/components/ui/select.tsx +143 -0
  65. package/src/components/ui/separator.tsx +20 -0
  66. package/src/components/ui/sheet.tsx +107 -0
  67. package/src/components/ui/sidebar.tsx +637 -0
  68. package/src/components/ui/skeleton.tsx +7 -0
  69. package/src/components/ui/slider.tsx +23 -0
  70. package/src/components/ui/sonner.tsx +27 -0
  71. package/src/components/ui/switch.tsx +27 -0
  72. package/src/components/ui/table.tsx +72 -0
  73. package/src/components/ui/tabs.tsx +53 -0
  74. package/src/components/ui/textarea.tsx +21 -0
  75. package/src/components/ui/toast.tsx +111 -0
  76. package/src/components/ui/toaster.tsx +24 -0
  77. package/src/components/ui/toggle-group.tsx +49 -0
  78. package/src/components/ui/toggle.tsx +37 -0
  79. package/src/components/ui/tooltip.tsx +28 -0
  80. package/src/components/ui/use-toast.ts +3 -0
  81. package/src/config/define.ts +6 -0
  82. package/src/config/index.ts +0 -0
  83. package/src/config/load.ts +45 -0
  84. package/src/config/types.ts +5 -0
  85. package/src/hooks/use-mobile.tsx +19 -0
  86. package/src/hooks/use-toast.ts +186 -0
  87. package/src/index.css +142 -0
  88. package/src/lib/models.ts +138 -0
  89. package/src/lib/utils.ts +6 -0
  90. package/src/main.tsx +5 -0
  91. package/src/orm/cli/makemigrations.ts +63 -0
  92. package/src/orm/cli/migrate.ts +127 -0
  93. package/src/orm/cli.ts +30 -0
  94. package/src/orm/core/base-model.ts +6 -0
  95. package/src/orm/core/manager.ts +27 -0
  96. package/src/orm/core/query-builder.ts +74 -0
  97. package/src/orm/db/connection.ts +0 -0
  98. package/src/orm/db/sql-types.ts +72 -0
  99. package/src/orm/db/sqlite.ts +4 -0
  100. package/src/orm/decorators/field.ts +80 -0
  101. package/src/orm/decorators/model.ts +36 -0
  102. package/src/orm/decorators/relations.ts +0 -0
  103. package/src/orm/metadata/field-metadata.ts +0 -0
  104. package/src/orm/metadata/field-types.ts +12 -0
  105. package/src/orm/metadata/get-meta.ts +9 -0
  106. package/src/orm/metadata/index.ts +15 -0
  107. package/src/orm/metadata/keys.ts +2 -0
  108. package/src/orm/metadata/model-registry.ts +53 -0
  109. package/src/orm/metadata/modifiers.ts +26 -0
  110. package/src/orm/metadata/types.ts +45 -0
  111. package/src/orm/migration-engine/diff.ts +243 -0
  112. package/src/orm/migration-engine/operations.ts +186 -0
  113. package/src/orm/schema/build.ts +138 -0
  114. package/src/orm/schema/state.ts +23 -0
  115. package/src/orm/schema/writeMigrations.ts +21 -0
  116. package/src/orm/syncdb.ts +25 -0
  117. package/src/pages/Dashboard.tsx +127 -0
  118. package/src/pages/Index.tsx +18 -0
  119. package/src/pages/ModelPage.tsx +177 -0
  120. package/src/pages/NotFound.tsx +24 -0
  121. package/src/pages/SchemaEditor.tsx +170 -0
  122. package/src/pages/Settings.tsx +166 -0
  123. package/src/server.ts +69 -0
  124. package/src/vite-env.d.ts +1 -0
  125. package/tailwind.config.js +112 -0
  126. package/tailwind.config.ts +114 -0
  127. package/tsconfig.app.json +30 -0
  128. package/tsconfig.json +16 -0
  129. package/tsconfig.node.json +22 -0
  130. package/vite.config.js +23 -0
  131. package/vite.config.ts +18 -0
@@ -0,0 +1,95 @@
1
+ import * as React from "react";
2
+ import * as DialogPrimitive from "@radix-ui/react-dialog";
3
+ import { X } from "lucide-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 data-[state=open]:bg-accent data-[state=open]:text-muted-foreground hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none">
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
+ DialogPortal,
87
+ DialogOverlay,
88
+ DialogClose,
89
+ DialogTrigger,
90
+ DialogContent,
91
+ DialogHeader,
92
+ DialogFooter,
93
+ DialogTitle,
94
+ DialogDescription,
95
+ };
@@ -0,0 +1,87 @@
1
+ import * as React from "react";
2
+ import { Drawer as DrawerPrimitive } from "vaul";
3
+
4
+ import { cn } from "@/lib/utils";
5
+
6
+ const Drawer = ({ shouldScaleBackground = true, ...props }: React.ComponentProps<typeof DrawerPrimitive.Root>) => (
7
+ <DrawerPrimitive.Root shouldScaleBackground={shouldScaleBackground} {...props} />
8
+ );
9
+ Drawer.displayName = "Drawer";
10
+
11
+ const DrawerTrigger = DrawerPrimitive.Trigger;
12
+
13
+ const DrawerPortal = DrawerPrimitive.Portal;
14
+
15
+ const DrawerClose = DrawerPrimitive.Close;
16
+
17
+ const DrawerOverlay = React.forwardRef<
18
+ React.ElementRef<typeof DrawerPrimitive.Overlay>,
19
+ React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Overlay>
20
+ >(({ className, ...props }, ref) => (
21
+ <DrawerPrimitive.Overlay ref={ref} className={cn("fixed inset-0 z-50 bg-black/80", className)} {...props} />
22
+ ));
23
+ DrawerOverlay.displayName = DrawerPrimitive.Overlay.displayName;
24
+
25
+ const DrawerContent = React.forwardRef<
26
+ React.ElementRef<typeof DrawerPrimitive.Content>,
27
+ React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Content>
28
+ >(({ className, children, ...props }, ref) => (
29
+ <DrawerPortal>
30
+ <DrawerOverlay />
31
+ <DrawerPrimitive.Content
32
+ ref={ref}
33
+ className={cn(
34
+ "fixed inset-x-0 bottom-0 z-50 mt-24 flex h-auto flex-col rounded-t-[10px] border bg-background",
35
+ className,
36
+ )}
37
+ {...props}
38
+ >
39
+ <div className="mx-auto mt-4 h-2 w-[100px] rounded-full bg-muted" />
40
+ {children}
41
+ </DrawerPrimitive.Content>
42
+ </DrawerPortal>
43
+ ));
44
+ DrawerContent.displayName = "DrawerContent";
45
+
46
+ const DrawerHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
47
+ <div className={cn("grid gap-1.5 p-4 text-center sm:text-left", className)} {...props} />
48
+ );
49
+ DrawerHeader.displayName = "DrawerHeader";
50
+
51
+ const DrawerFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
52
+ <div className={cn("mt-auto flex flex-col gap-2 p-4", className)} {...props} />
53
+ );
54
+ DrawerFooter.displayName = "DrawerFooter";
55
+
56
+ const DrawerTitle = React.forwardRef<
57
+ React.ElementRef<typeof DrawerPrimitive.Title>,
58
+ React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Title>
59
+ >(({ className, ...props }, ref) => (
60
+ <DrawerPrimitive.Title
61
+ ref={ref}
62
+ className={cn("text-lg font-semibold leading-none tracking-tight", className)}
63
+ {...props}
64
+ />
65
+ ));
66
+ DrawerTitle.displayName = DrawerPrimitive.Title.displayName;
67
+
68
+ const DrawerDescription = React.forwardRef<
69
+ React.ElementRef<typeof DrawerPrimitive.Description>,
70
+ React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Description>
71
+ >(({ className, ...props }, ref) => (
72
+ <DrawerPrimitive.Description ref={ref} className={cn("text-sm text-muted-foreground", className)} {...props} />
73
+ ));
74
+ DrawerDescription.displayName = DrawerPrimitive.Description.displayName;
75
+
76
+ export {
77
+ Drawer,
78
+ DrawerPortal,
79
+ DrawerOverlay,
80
+ DrawerTrigger,
81
+ DrawerClose,
82
+ DrawerContent,
83
+ DrawerHeader,
84
+ DrawerFooter,
85
+ DrawerTitle,
86
+ DrawerDescription,
87
+ };
@@ -0,0 +1,179 @@
1
+ import * as React from "react";
2
+ import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
3
+ import { Check, ChevronRight, Circle } from "lucide-react";
4
+
5
+ import { cn } from "@/lib/utils";
6
+
7
+ const DropdownMenu = DropdownMenuPrimitive.Root;
8
+
9
+ const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
10
+
11
+ const DropdownMenuGroup = DropdownMenuPrimitive.Group;
12
+
13
+ const DropdownMenuPortal = DropdownMenuPrimitive.Portal;
14
+
15
+ const DropdownMenuSub = DropdownMenuPrimitive.Sub;
16
+
17
+ const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;
18
+
19
+ const DropdownMenuSubTrigger = React.forwardRef<
20
+ React.ElementRef<typeof DropdownMenuPrimitive.SubTrigger>,
21
+ React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubTrigger> & {
22
+ inset?: boolean;
23
+ }
24
+ >(({ className, inset, children, ...props }, ref) => (
25
+ <DropdownMenuPrimitive.SubTrigger
26
+ ref={ref}
27
+ className={cn(
28
+ "flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[state=open]:bg-accent focus:bg-accent",
29
+ inset && "pl-8",
30
+ className,
31
+ )}
32
+ {...props}
33
+ >
34
+ {children}
35
+ <ChevronRight className="ml-auto h-4 w-4" />
36
+ </DropdownMenuPrimitive.SubTrigger>
37
+ ));
38
+ DropdownMenuSubTrigger.displayName = DropdownMenuPrimitive.SubTrigger.displayName;
39
+
40
+ const DropdownMenuSubContent = React.forwardRef<
41
+ React.ElementRef<typeof DropdownMenuPrimitive.SubContent>,
42
+ React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubContent>
43
+ >(({ className, ...props }, ref) => (
44
+ <DropdownMenuPrimitive.SubContent
45
+ ref={ref}
46
+ className={cn(
47
+ "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",
48
+ className,
49
+ )}
50
+ {...props}
51
+ />
52
+ ));
53
+ DropdownMenuSubContent.displayName = DropdownMenuPrimitive.SubContent.displayName;
54
+
55
+ const DropdownMenuContent = React.forwardRef<
56
+ React.ElementRef<typeof DropdownMenuPrimitive.Content>,
57
+ React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content>
58
+ >(({ className, sideOffset = 4, ...props }, ref) => (
59
+ <DropdownMenuPrimitive.Portal>
60
+ <DropdownMenuPrimitive.Content
61
+ ref={ref}
62
+ sideOffset={sideOffset}
63
+ className={cn(
64
+ "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",
65
+ className,
66
+ )}
67
+ {...props}
68
+ />
69
+ </DropdownMenuPrimitive.Portal>
70
+ ));
71
+ DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName;
72
+
73
+ const DropdownMenuItem = React.forwardRef<
74
+ React.ElementRef<typeof DropdownMenuPrimitive.Item>,
75
+ React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item> & {
76
+ inset?: boolean;
77
+ }
78
+ >(({ className, inset, ...props }, ref) => (
79
+ <DropdownMenuPrimitive.Item
80
+ ref={ref}
81
+ className={cn(
82
+ "relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",
83
+ inset && "pl-8",
84
+ className,
85
+ )}
86
+ {...props}
87
+ />
88
+ ));
89
+ DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName;
90
+
91
+ const DropdownMenuCheckboxItem = React.forwardRef<
92
+ React.ElementRef<typeof DropdownMenuPrimitive.CheckboxItem>,
93
+ React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.CheckboxItem>
94
+ >(({ className, children, checked, ...props }, ref) => (
95
+ <DropdownMenuPrimitive.CheckboxItem
96
+ ref={ref}
97
+ className={cn(
98
+ "relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",
99
+ className,
100
+ )}
101
+ checked={checked}
102
+ {...props}
103
+ >
104
+ <span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
105
+ <DropdownMenuPrimitive.ItemIndicator>
106
+ <Check className="h-4 w-4" />
107
+ </DropdownMenuPrimitive.ItemIndicator>
108
+ </span>
109
+ {children}
110
+ </DropdownMenuPrimitive.CheckboxItem>
111
+ ));
112
+ DropdownMenuCheckboxItem.displayName = DropdownMenuPrimitive.CheckboxItem.displayName;
113
+
114
+ const DropdownMenuRadioItem = React.forwardRef<
115
+ React.ElementRef<typeof DropdownMenuPrimitive.RadioItem>,
116
+ React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.RadioItem>
117
+ >(({ className, children, ...props }, ref) => (
118
+ <DropdownMenuPrimitive.RadioItem
119
+ ref={ref}
120
+ className={cn(
121
+ "relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",
122
+ className,
123
+ )}
124
+ {...props}
125
+ >
126
+ <span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
127
+ <DropdownMenuPrimitive.ItemIndicator>
128
+ <Circle className="h-2 w-2 fill-current" />
129
+ </DropdownMenuPrimitive.ItemIndicator>
130
+ </span>
131
+ {children}
132
+ </DropdownMenuPrimitive.RadioItem>
133
+ ));
134
+ DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName;
135
+
136
+ const DropdownMenuLabel = React.forwardRef<
137
+ React.ElementRef<typeof DropdownMenuPrimitive.Label>,
138
+ React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Label> & {
139
+ inset?: boolean;
140
+ }
141
+ >(({ className, inset, ...props }, ref) => (
142
+ <DropdownMenuPrimitive.Label
143
+ ref={ref}
144
+ className={cn("px-2 py-1.5 text-sm font-semibold", inset && "pl-8", className)}
145
+ {...props}
146
+ />
147
+ ));
148
+ DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName;
149
+
150
+ const DropdownMenuSeparator = React.forwardRef<
151
+ React.ElementRef<typeof DropdownMenuPrimitive.Separator>,
152
+ React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Separator>
153
+ >(({ className, ...props }, ref) => (
154
+ <DropdownMenuPrimitive.Separator ref={ref} className={cn("-mx-1 my-1 h-px bg-muted", className)} {...props} />
155
+ ));
156
+ DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName;
157
+
158
+ const DropdownMenuShortcut = ({ className, ...props }: React.HTMLAttributes<HTMLSpanElement>) => {
159
+ return <span className={cn("ml-auto text-xs tracking-widest opacity-60", className)} {...props} />;
160
+ };
161
+ DropdownMenuShortcut.displayName = "DropdownMenuShortcut";
162
+
163
+ export {
164
+ DropdownMenu,
165
+ DropdownMenuTrigger,
166
+ DropdownMenuContent,
167
+ DropdownMenuItem,
168
+ DropdownMenuCheckboxItem,
169
+ DropdownMenuRadioItem,
170
+ DropdownMenuLabel,
171
+ DropdownMenuSeparator,
172
+ DropdownMenuShortcut,
173
+ DropdownMenuGroup,
174
+ DropdownMenuPortal,
175
+ DropdownMenuSub,
176
+ DropdownMenuSubContent,
177
+ DropdownMenuSubTrigger,
178
+ DropdownMenuRadioGroup,
179
+ };
@@ -0,0 +1,129 @@
1
+ import * as React from "react";
2
+ import * as LabelPrimitive from "@radix-ui/react-label";
3
+ import { Slot } from "@radix-ui/react-slot";
4
+ import { Controller, ControllerProps, FieldPath, FieldValues, FormProvider, useFormContext } from "react-hook-form";
5
+
6
+ import { cn } from "@/lib/utils";
7
+ import { Label } from "@/components/ui/label";
8
+
9
+ const Form = FormProvider;
10
+
11
+ type FormFieldContextValue<
12
+ TFieldValues extends FieldValues = FieldValues,
13
+ TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
14
+ > = {
15
+ name: TName;
16
+ };
17
+
18
+ const FormFieldContext = React.createContext<FormFieldContextValue>({} as FormFieldContextValue);
19
+
20
+ const FormField = <
21
+ TFieldValues extends FieldValues = FieldValues,
22
+ TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
23
+ >({
24
+ ...props
25
+ }: ControllerProps<TFieldValues, TName>) => {
26
+ return (
27
+ <FormFieldContext.Provider value={{ name: props.name }}>
28
+ <Controller {...props} />
29
+ </FormFieldContext.Provider>
30
+ );
31
+ };
32
+
33
+ const useFormField = () => {
34
+ const fieldContext = React.useContext(FormFieldContext);
35
+ const itemContext = React.useContext(FormItemContext);
36
+ const { getFieldState, formState } = useFormContext();
37
+
38
+ const fieldState = getFieldState(fieldContext.name, formState);
39
+
40
+ if (!fieldContext) {
41
+ throw new Error("useFormField should be used within <FormField>");
42
+ }
43
+
44
+ const { id } = itemContext;
45
+
46
+ return {
47
+ id,
48
+ name: fieldContext.name,
49
+ formItemId: `${id}-form-item`,
50
+ formDescriptionId: `${id}-form-item-description`,
51
+ formMessageId: `${id}-form-item-message`,
52
+ ...fieldState,
53
+ };
54
+ };
55
+
56
+ type FormItemContextValue = {
57
+ id: string;
58
+ };
59
+
60
+ const FormItemContext = React.createContext<FormItemContextValue>({} as FormItemContextValue);
61
+
62
+ const FormItem = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
63
+ ({ className, ...props }, ref) => {
64
+ const id = React.useId();
65
+
66
+ return (
67
+ <FormItemContext.Provider value={{ id }}>
68
+ <div ref={ref} className={cn("space-y-2", className)} {...props} />
69
+ </FormItemContext.Provider>
70
+ );
71
+ },
72
+ );
73
+ FormItem.displayName = "FormItem";
74
+
75
+ const FormLabel = React.forwardRef<
76
+ React.ElementRef<typeof LabelPrimitive.Root>,
77
+ React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root>
78
+ >(({ className, ...props }, ref) => {
79
+ const { error, formItemId } = useFormField();
80
+
81
+ return <Label ref={ref} className={cn(error && "text-destructive", className)} htmlFor={formItemId} {...props} />;
82
+ });
83
+ FormLabel.displayName = "FormLabel";
84
+
85
+ const FormControl = React.forwardRef<React.ElementRef<typeof Slot>, React.ComponentPropsWithoutRef<typeof Slot>>(
86
+ ({ ...props }, ref) => {
87
+ const { error, formItemId, formDescriptionId, formMessageId } = useFormField();
88
+
89
+ return (
90
+ <Slot
91
+ ref={ref}
92
+ id={formItemId}
93
+ aria-describedby={!error ? `${formDescriptionId}` : `${formDescriptionId} ${formMessageId}`}
94
+ aria-invalid={!!error}
95
+ {...props}
96
+ />
97
+ );
98
+ },
99
+ );
100
+ FormControl.displayName = "FormControl";
101
+
102
+ const FormDescription = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLParagraphElement>>(
103
+ ({ className, ...props }, ref) => {
104
+ const { formDescriptionId } = useFormField();
105
+
106
+ return <p ref={ref} id={formDescriptionId} className={cn("text-sm text-muted-foreground", className)} {...props} />;
107
+ },
108
+ );
109
+ FormDescription.displayName = "FormDescription";
110
+
111
+ const FormMessage = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLParagraphElement>>(
112
+ ({ className, children, ...props }, ref) => {
113
+ const { error, formMessageId } = useFormField();
114
+ const body = error ? String(error?.message) : children;
115
+
116
+ if (!body) {
117
+ return null;
118
+ }
119
+
120
+ return (
121
+ <p ref={ref} id={formMessageId} className={cn("text-sm font-medium text-destructive", className)} {...props}>
122
+ {body}
123
+ </p>
124
+ );
125
+ },
126
+ );
127
+ FormMessage.displayName = "FormMessage";
128
+
129
+ export { useFormField, Form, FormItem, FormLabel, FormControl, FormDescription, FormMessage, FormField };
@@ -0,0 +1,27 @@
1
+ import * as React from "react";
2
+ import * as HoverCardPrimitive from "@radix-ui/react-hover-card";
3
+
4
+ import { cn } from "@/lib/utils";
5
+
6
+ const HoverCard = HoverCardPrimitive.Root;
7
+
8
+ const HoverCardTrigger = HoverCardPrimitive.Trigger;
9
+
10
+ const HoverCardContent = React.forwardRef<
11
+ React.ElementRef<typeof HoverCardPrimitive.Content>,
12
+ React.ComponentPropsWithoutRef<typeof HoverCardPrimitive.Content>
13
+ >(({ className, align = "center", sideOffset = 4, ...props }, ref) => (
14
+ <HoverCardPrimitive.Content
15
+ ref={ref}
16
+ align={align}
17
+ sideOffset={sideOffset}
18
+ className={cn(
19
+ "z-50 w-64 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none 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",
20
+ className,
21
+ )}
22
+ {...props}
23
+ />
24
+ ));
25
+ HoverCardContent.displayName = HoverCardPrimitive.Content.displayName;
26
+
27
+ export { HoverCard, HoverCardTrigger, HoverCardContent };
@@ -0,0 +1,61 @@
1
+ import * as React from "react";
2
+ import { OTPInput, OTPInputContext } from "input-otp";
3
+ import { Dot } from "lucide-react";
4
+
5
+ import { cn } from "@/lib/utils";
6
+
7
+ const InputOTP = React.forwardRef<React.ElementRef<typeof OTPInput>, React.ComponentPropsWithoutRef<typeof OTPInput>>(
8
+ ({ className, containerClassName, ...props }, ref) => (
9
+ <OTPInput
10
+ ref={ref}
11
+ containerClassName={cn("flex items-center gap-2 has-[:disabled]:opacity-50", containerClassName)}
12
+ className={cn("disabled:cursor-not-allowed", className)}
13
+ {...props}
14
+ />
15
+ ),
16
+ );
17
+ InputOTP.displayName = "InputOTP";
18
+
19
+ const InputOTPGroup = React.forwardRef<React.ElementRef<"div">, React.ComponentPropsWithoutRef<"div">>(
20
+ ({ className, ...props }, ref) => <div ref={ref} className={cn("flex items-center", className)} {...props} />,
21
+ );
22
+ InputOTPGroup.displayName = "InputOTPGroup";
23
+
24
+ const InputOTPSlot = React.forwardRef<
25
+ React.ElementRef<"div">,
26
+ React.ComponentPropsWithoutRef<"div"> & { index: number }
27
+ >(({ index, className, ...props }, ref) => {
28
+ const inputOTPContext = React.useContext(OTPInputContext);
29
+ const { char, hasFakeCaret, isActive } = inputOTPContext.slots[index];
30
+
31
+ return (
32
+ <div
33
+ ref={ref}
34
+ className={cn(
35
+ "relative flex h-10 w-10 items-center justify-center border-y border-r border-input text-sm transition-all first:rounded-l-md first:border-l last:rounded-r-md",
36
+ isActive && "z-10 ring-2 ring-ring ring-offset-background",
37
+ className,
38
+ )}
39
+ {...props}
40
+ >
41
+ {char}
42
+ {hasFakeCaret && (
43
+ <div className="pointer-events-none absolute inset-0 flex items-center justify-center">
44
+ <div className="animate-caret-blink h-4 w-px bg-foreground duration-1000" />
45
+ </div>
46
+ )}
47
+ </div>
48
+ );
49
+ });
50
+ InputOTPSlot.displayName = "InputOTPSlot";
51
+
52
+ const InputOTPSeparator = React.forwardRef<React.ElementRef<"div">, React.ComponentPropsWithoutRef<"div">>(
53
+ ({ ...props }, ref) => (
54
+ <div ref={ref} role="separator" {...props}>
55
+ <Dot />
56
+ </div>
57
+ ),
58
+ );
59
+ InputOTPSeparator.displayName = "InputOTPSeparator";
60
+
61
+ export { InputOTP, InputOTPGroup, InputOTPSlot, InputOTPSeparator };
@@ -0,0 +1,22 @@
1
+ import * as React from "react";
2
+
3
+ import { cn } from "@/lib/utils";
4
+
5
+ const Input = React.forwardRef<HTMLInputElement, React.ComponentProps<"input">>(
6
+ ({ className, type, ...props }, ref) => {
7
+ return (
8
+ <input
9
+ type={type}
10
+ className={cn(
11
+ "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground 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 md:text-sm",
12
+ className,
13
+ )}
14
+ ref={ref}
15
+ {...props}
16
+ />
17
+ );
18
+ },
19
+ );
20
+ Input.displayName = "Input";
21
+
22
+ export { Input };
@@ -0,0 +1,17 @@
1
+ import * as React from "react";
2
+ import * as LabelPrimitive from "@radix-ui/react-label";
3
+ import { cva, type VariantProps } from "class-variance-authority";
4
+
5
+ import { cn } from "@/lib/utils";
6
+
7
+ const labelVariants = cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70");
8
+
9
+ const Label = React.forwardRef<
10
+ React.ElementRef<typeof LabelPrimitive.Root>,
11
+ React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> & VariantProps<typeof labelVariants>
12
+ >(({ className, ...props }, ref) => (
13
+ <LabelPrimitive.Root ref={ref} className={cn(labelVariants(), className)} {...props} />
14
+ ));
15
+ Label.displayName = LabelPrimitive.Root.displayName;
16
+
17
+ export { Label };