@carlonicora/nextjs-jsonapi 1.0.3 → 1.0.4

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 (261) hide show
  1. package/package.json +2 -1
  2. package/src/atoms/index.ts +1 -0
  3. package/src/atoms/recentPagesAtom.ts +10 -0
  4. package/src/client/context/JsonApiContext.ts +61 -0
  5. package/src/client/context/JsonApiProvider.tsx +27 -0
  6. package/src/client/context/index.ts +2 -0
  7. package/src/client/hooks/index.ts +3 -0
  8. package/src/client/hooks/useJsonApiGet.ts +188 -0
  9. package/src/client/hooks/useJsonApiMutation.ts +193 -0
  10. package/src/client/hooks/useRehydration.ts +47 -0
  11. package/src/client/index.ts +11 -0
  12. package/src/client/request.ts +97 -0
  13. package/src/client/token.ts +10 -0
  14. package/src/components/containers/PageContainer.tsx +15 -0
  15. package/src/components/containers/ReactMarkdownContainer.tsx +119 -0
  16. package/src/components/containers/TabsContainer.tsx +93 -0
  17. package/src/components/containers/index.ts +3 -0
  18. package/src/components/contents/AttributeElement.tsx +20 -0
  19. package/src/components/contents/index.ts +1 -0
  20. package/src/components/details/AllowedUsersDetails.tsx +23 -0
  21. package/src/components/details/index.ts +1 -0
  22. package/src/components/editors/BlockNoteDiffInlineContent.tsx +152 -0
  23. package/src/components/editors/BlockNoteEditor.tsx +404 -0
  24. package/src/components/editors/BlockNoteEditorContainer.tsx +13 -0
  25. package/src/components/editors/BlockNoteEditorFormattingToolbar.tsx +38 -0
  26. package/src/components/editors/index.ts +1 -0
  27. package/src/components/errors/ErrorDetails.tsx +41 -0
  28. package/src/components/errors/errorToast.ts +9 -0
  29. package/src/components/errors/index.ts +2 -0
  30. package/src/components/forms/CommonAssociationForm.tsx +162 -0
  31. package/src/components/forms/CommonDeleter.tsx +94 -0
  32. package/src/components/forms/CommonEditorButtons.tsx +30 -0
  33. package/src/components/forms/CommonEditorHeader.tsx +35 -0
  34. package/src/components/forms/CommonEditorTrigger.tsx +26 -0
  35. package/src/components/forms/DatePickerPopover.tsx +219 -0
  36. package/src/components/forms/DateRangeSelector.tsx +110 -0
  37. package/src/components/forms/FileUploader.tsx +324 -0
  38. package/src/components/forms/FormCheckbox.tsx +66 -0
  39. package/src/components/forms/FormContainerGeneric.tsx +39 -0
  40. package/src/components/forms/FormDate.tsx +247 -0
  41. package/src/components/forms/FormDateTime.tsx +231 -0
  42. package/src/components/forms/FormInput.tsx +110 -0
  43. package/src/components/forms/FormPassword.tsx +54 -0
  44. package/src/components/forms/FormPlaceAutocomplete.tsx +286 -0
  45. package/src/components/forms/FormSelect.tsx +72 -0
  46. package/src/components/forms/FormSlider.tsx +51 -0
  47. package/src/components/forms/FormSwitch.tsx +25 -0
  48. package/src/components/forms/FormTextarea.tsx +44 -0
  49. package/src/components/forms/MultiFileUploader.tsx +107 -0
  50. package/src/components/forms/PasswordInput.tsx +47 -0
  51. package/src/components/forms/index.ts +21 -0
  52. package/src/components/index.ts +11 -0
  53. package/src/components/navigations/Breadcrumb.tsx +83 -0
  54. package/src/components/navigations/ContentTitle.tsx +39 -0
  55. package/src/components/navigations/Header.tsx +27 -0
  56. package/src/components/navigations/ModeToggleSwitch.tsx +25 -0
  57. package/src/components/navigations/PageSection.tsx +64 -0
  58. package/src/components/navigations/RecentPagesNavigator.tsx +52 -0
  59. package/src/components/navigations/index.ts +6 -0
  60. package/src/components/pages/PageContainerContentDetails.tsx +76 -0
  61. package/src/components/pages/PageContentContainer.tsx +31 -0
  62. package/src/components/pages/index.ts +2 -0
  63. package/src/components/tables/ContentListTable.tsx +165 -0
  64. package/src/components/tables/ContentTableSearch.tsx +105 -0
  65. package/src/components/tables/cells/cell.component.tsx +18 -0
  66. package/src/components/tables/cells/cell.date.tsx +16 -0
  67. package/src/components/tables/cells/cell.id.tsx +27 -0
  68. package/src/components/tables/cells/cell.link.tsx +18 -0
  69. package/src/components/tables/cells/cell.text.tsx +12 -0
  70. package/src/components/tables/cells/cell.url.tsx +13 -0
  71. package/src/components/tables/cells/index.ts +5 -0
  72. package/src/components/tables/index.ts +3 -0
  73. package/src/contexts/SharedContext.tsx +35 -0
  74. package/src/contexts/index.ts +2 -0
  75. package/src/core/abstracts/AbstractApiData.ts +138 -0
  76. package/src/core/abstracts/AbstractService.ts +263 -0
  77. package/src/core/abstracts/index.ts +2 -0
  78. package/src/core/endpoint/EndpointCreator.ts +97 -0
  79. package/src/core/endpoint/index.ts +1 -0
  80. package/src/core/factories/JsonApiDataFactory.ts +12 -0
  81. package/src/core/factories/RehydrationFactory.ts +30 -0
  82. package/src/core/factories/index.ts +2 -0
  83. package/src/core/fields/FieldSelector.ts +15 -0
  84. package/src/core/fields/index.ts +1 -0
  85. package/src/core/index.ts +20 -0
  86. package/src/core/interfaces/ApiData.ts +8 -0
  87. package/src/core/interfaces/ApiDataInterface.ts +15 -0
  88. package/src/core/interfaces/ApiRequestDataTypeInterface.ts +14 -0
  89. package/src/core/interfaces/ApiResponseInterface.ts +17 -0
  90. package/src/core/interfaces/JsonApiHydratedDataInterface.ts +5 -0
  91. package/src/core/interfaces/index.ts +5 -0
  92. package/src/core/registry/DataClassRegistry.ts +51 -0
  93. package/src/core/registry/ModuleRegistrar.ts +43 -0
  94. package/src/core/registry/ModuleRegistry.ts +64 -0
  95. package/src/core/registry/index.ts +3 -0
  96. package/src/core/utils/index.ts +2 -0
  97. package/src/core/utils/rehydrate.ts +24 -0
  98. package/src/core/utils/translateResponse.ts +125 -0
  99. package/src/features/auth/auth.module.ts +9 -0
  100. package/src/features/auth/config.ts +57 -0
  101. package/src/features/auth/data/auth.interface.ts +31 -0
  102. package/src/features/auth/data/auth.service.ts +159 -0
  103. package/src/features/auth/data/auth.ts +54 -0
  104. package/src/features/auth/data/index.ts +3 -0
  105. package/src/features/auth/index.ts +3 -0
  106. package/src/features/company/company.module.ts +10 -0
  107. package/src/features/company/data/company.fields.ts +6 -0
  108. package/src/features/company/data/company.interface.ts +28 -0
  109. package/src/features/company/data/company.service.ts +73 -0
  110. package/src/features/company/data/company.ts +104 -0
  111. package/src/features/company/data/index.ts +4 -0
  112. package/src/features/company/index.ts +2 -0
  113. package/src/features/content/content.module.ts +20 -0
  114. package/src/features/content/data/content.fields.ts +13 -0
  115. package/src/features/content/data/content.interface.ts +23 -0
  116. package/src/features/content/data/content.service.ts +75 -0
  117. package/src/features/content/data/content.ts +85 -0
  118. package/src/features/content/data/index.ts +4 -0
  119. package/src/features/content/index.ts +2 -0
  120. package/src/features/feature/components/forms/FormFeatures.tsx +149 -0
  121. package/src/features/feature/components/index.ts +1 -0
  122. package/src/features/feature/data/feature.interface.ts +9 -0
  123. package/src/features/feature/data/feature.service.ts +19 -0
  124. package/src/features/feature/data/feature.ts +33 -0
  125. package/src/features/feature/data/index.ts +3 -0
  126. package/src/features/feature/feature.module.ts +10 -0
  127. package/src/features/feature/index.ts +3 -0
  128. package/src/features/index.ts +12 -0
  129. package/src/features/module/data/index.ts +2 -0
  130. package/src/features/module/data/module.interface.ts +12 -0
  131. package/src/features/module/data/module.ts +42 -0
  132. package/src/features/module/index.ts +2 -0
  133. package/src/features/module/module.module.ts +10 -0
  134. package/src/features/notification/data/index.ts +4 -0
  135. package/src/features/notification/data/notification.fields.ts +8 -0
  136. package/src/features/notification/data/notification.interface.ts +14 -0
  137. package/src/features/notification/data/notification.service.ts +34 -0
  138. package/src/features/notification/data/notification.ts +51 -0
  139. package/src/features/notification/index.ts +2 -0
  140. package/src/features/notification/notification.module.ts +10 -0
  141. package/src/features/push/data/index.ts +3 -0
  142. package/src/features/push/data/push.interface.ts +8 -0
  143. package/src/features/push/data/push.service.ts +17 -0
  144. package/src/features/push/data/push.ts +18 -0
  145. package/src/features/push/index.ts +2 -0
  146. package/src/features/push/push.module.ts +10 -0
  147. package/src/features/role/data/index.ts +4 -0
  148. package/src/features/role/data/role.fields.ts +8 -0
  149. package/src/features/role/data/role.interface.ts +16 -0
  150. package/src/features/role/data/role.service.ts +117 -0
  151. package/src/features/role/data/role.ts +62 -0
  152. package/src/features/role/index.ts +2 -0
  153. package/src/features/role/role.module.ts +10 -0
  154. package/src/features/s3/data/index.ts +3 -0
  155. package/src/features/s3/data/s3.interface.ts +11 -0
  156. package/src/features/s3/data/s3.service.ts +30 -0
  157. package/src/features/s3/data/s3.ts +60 -0
  158. package/src/features/s3/index.ts +2 -0
  159. package/src/features/s3/s3.module.ts +10 -0
  160. package/src/features/search/index.ts +1 -0
  161. package/src/features/search/interfaces/index.ts +1 -0
  162. package/src/features/search/interfaces/search.result.interface.ts +3 -0
  163. package/src/features/user/author.module.ts +10 -0
  164. package/src/features/user/components/index.ts +2 -0
  165. package/src/features/user/components/lists/ContributorsList.tsx +41 -0
  166. package/src/features/user/components/lists/index.ts +1 -0
  167. package/src/features/user/components/widgets/UserAvatar.tsx +86 -0
  168. package/src/features/user/components/widgets/index.ts +1 -0
  169. package/src/features/user/contexts/CurrentUserContext.tsx +156 -0
  170. package/src/features/user/contexts/index.ts +1 -0
  171. package/src/features/user/data/index.ts +4 -0
  172. package/src/features/user/data/user.fields.ts +8 -0
  173. package/src/features/user/data/user.interface.ts +41 -0
  174. package/src/features/user/data/user.service.ts +246 -0
  175. package/src/features/user/data/user.ts +162 -0
  176. package/src/features/user/index.ts +4 -0
  177. package/src/features/user/user.module.ts +21 -0
  178. package/src/hooks/TableGeneratorRegistry.ts +53 -0
  179. package/src/hooks/index.ts +33 -0
  180. package/src/hooks/types.ts +35 -0
  181. package/src/hooks/url.rewriter.ts +22 -0
  182. package/src/hooks/useCustomD3Graph.tsx +705 -0
  183. package/src/hooks/useDataListRetriever.ts +349 -0
  184. package/src/hooks/useDebounce.ts +33 -0
  185. package/src/hooks/usePageUrlGenerator.ts +50 -0
  186. package/src/hooks/useTableGenerator.ts +16 -0
  187. package/src/i18n/config.ts +73 -0
  188. package/src/i18n/index.ts +18 -0
  189. package/src/index.ts +16 -0
  190. package/src/interfaces/breadcrumb.item.data.interface.ts +4 -0
  191. package/src/interfaces/d3.link.interface.ts +7 -0
  192. package/src/interfaces/d3.node.interface.ts +12 -0
  193. package/src/interfaces/index.ts +3 -0
  194. package/src/permissions/check.ts +127 -0
  195. package/src/permissions/index.ts +2 -0
  196. package/src/permissions/types.ts +109 -0
  197. package/src/roles/config.ts +46 -0
  198. package/src/roles/index.ts +1 -0
  199. package/src/server/cache.ts +28 -0
  200. package/src/server/index.ts +3 -0
  201. package/src/server/request.ts +113 -0
  202. package/src/server/token.ts +10 -0
  203. package/src/shadcnui/custom/kanban.tsx +1001 -0
  204. package/src/shadcnui/custom/link.tsx +18 -0
  205. package/src/shadcnui/custom/multi-select.tsx +382 -0
  206. package/src/shadcnui/index.ts +49 -0
  207. package/src/shadcnui/ui/accordion.tsx +52 -0
  208. package/src/shadcnui/ui/alert-dialog.tsx +141 -0
  209. package/src/shadcnui/ui/alert.tsx +43 -0
  210. package/src/shadcnui/ui/avatar.tsx +50 -0
  211. package/src/shadcnui/ui/badge.tsx +40 -0
  212. package/src/shadcnui/ui/breadcrumb.tsx +115 -0
  213. package/src/shadcnui/ui/button.tsx +51 -0
  214. package/src/shadcnui/ui/calendar.tsx +73 -0
  215. package/src/shadcnui/ui/card.tsx +43 -0
  216. package/src/shadcnui/ui/carousel.tsx +225 -0
  217. package/src/shadcnui/ui/chart.tsx +320 -0
  218. package/src/shadcnui/ui/checkbox.tsx +29 -0
  219. package/src/shadcnui/ui/collapsible.tsx +11 -0
  220. package/src/shadcnui/ui/command.tsx +155 -0
  221. package/src/shadcnui/ui/context-menu.tsx +179 -0
  222. package/src/shadcnui/ui/dialog.tsx +96 -0
  223. package/src/shadcnui/ui/drawer.tsx +89 -0
  224. package/src/shadcnui/ui/dropdown-menu.tsx +205 -0
  225. package/src/shadcnui/ui/form.tsx +138 -0
  226. package/src/shadcnui/ui/hover-card.tsx +29 -0
  227. package/src/shadcnui/ui/input.tsx +21 -0
  228. package/src/shadcnui/ui/label.tsx +26 -0
  229. package/src/shadcnui/ui/navigation-menu.tsx +168 -0
  230. package/src/shadcnui/ui/popover.tsx +33 -0
  231. package/src/shadcnui/ui/progress.tsx +25 -0
  232. package/src/shadcnui/ui/radio-group.tsx +37 -0
  233. package/src/shadcnui/ui/resizable.tsx +47 -0
  234. package/src/shadcnui/ui/scroll-area.tsx +40 -0
  235. package/src/shadcnui/ui/select.tsx +164 -0
  236. package/src/shadcnui/ui/separator.tsx +28 -0
  237. package/src/shadcnui/ui/sheet.tsx +139 -0
  238. package/src/shadcnui/ui/sidebar.tsx +677 -0
  239. package/src/shadcnui/ui/skeleton.tsx +13 -0
  240. package/src/shadcnui/ui/slider.tsx +25 -0
  241. package/src/shadcnui/ui/sonner.tsx +25 -0
  242. package/src/shadcnui/ui/switch.tsx +31 -0
  243. package/src/shadcnui/ui/table.tsx +120 -0
  244. package/src/shadcnui/ui/tabs.tsx +55 -0
  245. package/src/shadcnui/ui/textarea.tsx +24 -0
  246. package/src/shadcnui/ui/toggle.tsx +39 -0
  247. package/src/shadcnui/ui/tooltip.tsx +61 -0
  248. package/src/unified/JsonApiRequest.ts +325 -0
  249. package/src/unified/index.ts +1 -0
  250. package/src/utils/blocknote-diff.util.ts +815 -0
  251. package/src/utils/blocknote-word-diff-renderer.util.ts +413 -0
  252. package/src/utils/cn.ts +6 -0
  253. package/src/utils/compose-refs.ts +61 -0
  254. package/src/utils/date-formatter.ts +53 -0
  255. package/src/utils/exists.ts +7 -0
  256. package/src/utils/index.ts +15 -0
  257. package/src/utils/schemas/entity.object.schema.ts +8 -0
  258. package/src/utils/schemas/index.ts +2 -0
  259. package/src/utils/schemas/user.object.schema.ts +9 -0
  260. package/src/utils/table-options.ts +67 -0
  261. package/src/utils/use-mobile.tsx +21 -0
@@ -0,0 +1,96 @@
1
+ "use client";
2
+
3
+ import { cn } from "../../utils/cn";
4
+ import * as DialogPrimitive from "@radix-ui/react-dialog";
5
+ import { Cross2Icon } from "@radix-ui/react-icons";
6
+ import * as React from "react";
7
+
8
+ const Dialog = DialogPrimitive.Root;
9
+
10
+ const DialogTrigger = DialogPrimitive.Trigger;
11
+
12
+ const DialogPortal = DialogPrimitive.Portal;
13
+
14
+ const DialogClose = DialogPrimitive.Close;
15
+
16
+ const DialogOverlay = React.forwardRef<
17
+ React.ElementRef<typeof DialogPrimitive.Overlay>,
18
+ React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
19
+ >(({ className, ...props }, ref) => (
20
+ <DialogPrimitive.Overlay
21
+ ref={ref}
22
+ className={cn(
23
+ "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",
24
+ className,
25
+ )}
26
+ {...props}
27
+ />
28
+ ));
29
+ DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
30
+
31
+ const DialogContent = React.forwardRef<
32
+ React.ElementRef<typeof DialogPrimitive.Content>,
33
+ React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>
34
+ >(({ className, children, ...props }, ref) => (
35
+ <DialogPortal>
36
+ <DialogOverlay />
37
+ <DialogPrimitive.Content
38
+ ref={ref}
39
+ className={cn(
40
+ "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",
41
+ className,
42
+ )}
43
+ {...props}
44
+ >
45
+ {children}
46
+ <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">
47
+ <Cross2Icon className="h-4 w-4" />
48
+ <span className="sr-only">Close</span>
49
+ </DialogPrimitive.Close>
50
+ </DialogPrimitive.Content>
51
+ </DialogPortal>
52
+ ));
53
+ DialogContent.displayName = DialogPrimitive.Content.displayName;
54
+
55
+ const DialogHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
56
+ <div className={cn("flex flex-col space-y-1.5 text-center sm:text-left", className)} {...props} />
57
+ );
58
+ DialogHeader.displayName = "DialogHeader";
59
+
60
+ const DialogFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
61
+ <div className={cn("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2", className)} {...props} />
62
+ );
63
+ DialogFooter.displayName = "DialogFooter";
64
+
65
+ const DialogTitle = React.forwardRef<
66
+ React.ElementRef<typeof DialogPrimitive.Title>,
67
+ React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
68
+ >(({ className, ...props }, ref) => (
69
+ <DialogPrimitive.Title
70
+ ref={ref}
71
+ className={cn("text-lg font-semibold leading-none tracking-tight", className)}
72
+ {...props}
73
+ />
74
+ ));
75
+ DialogTitle.displayName = DialogPrimitive.Title.displayName;
76
+
77
+ const DialogDescription = React.forwardRef<
78
+ React.ElementRef<typeof DialogPrimitive.Description>,
79
+ React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
80
+ >(({ className, ...props }, ref) => (
81
+ <DialogPrimitive.Description ref={ref} className={cn("text-sm text-muted-foreground", className)} {...props} />
82
+ ));
83
+ DialogDescription.displayName = DialogPrimitive.Description.displayName;
84
+
85
+ export {
86
+ Dialog,
87
+ DialogClose,
88
+ DialogContent,
89
+ DialogDescription,
90
+ DialogFooter,
91
+ DialogHeader,
92
+ DialogOverlay,
93
+ DialogPortal,
94
+ DialogTitle,
95
+ DialogTrigger,
96
+ };
@@ -0,0 +1,89 @@
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+ import { Drawer as DrawerPrimitive } from "vaul";
5
+
6
+ import { cn } from "../../utils/cn";
7
+
8
+ const Drawer = ({ shouldScaleBackground = true, ...props }: React.ComponentProps<typeof DrawerPrimitive.Root>) => (
9
+ <DrawerPrimitive.Root shouldScaleBackground={shouldScaleBackground} {...props} />
10
+ );
11
+ Drawer.displayName = "Drawer";
12
+
13
+ const DrawerTrigger = DrawerPrimitive.Trigger;
14
+
15
+ const DrawerPortal = DrawerPrimitive.Portal;
16
+
17
+ const DrawerClose = DrawerPrimitive.Close;
18
+
19
+ const DrawerOverlay = React.forwardRef<
20
+ React.ElementRef<typeof DrawerPrimitive.Overlay>,
21
+ React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Overlay>
22
+ >(({ className, ...props }, ref) => (
23
+ <DrawerPrimitive.Overlay ref={ref} className={cn("fixed inset-0 z-50 bg-black/80", className)} {...props} />
24
+ ));
25
+ DrawerOverlay.displayName = DrawerPrimitive.Overlay.displayName;
26
+
27
+ const DrawerContent = React.forwardRef<
28
+ React.ElementRef<typeof DrawerPrimitive.Content>,
29
+ React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Content>
30
+ >(({ className, children, ...props }, ref) => (
31
+ <DrawerPortal>
32
+ <DrawerOverlay />
33
+ <DrawerPrimitive.Content
34
+ ref={ref}
35
+ className={cn(
36
+ "fixed inset-x-0 bottom-0 z-50 mt-24 flex h-auto flex-col rounded-t-[10px] border bg-background",
37
+ className,
38
+ )}
39
+ {...props}
40
+ >
41
+ <div className="mx-auto mt-4 h-2 w-[100px] rounded-full bg-muted" />
42
+ {children}
43
+ </DrawerPrimitive.Content>
44
+ </DrawerPortal>
45
+ ));
46
+ DrawerContent.displayName = "DrawerContent";
47
+
48
+ const DrawerHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
49
+ <div className={cn("grid gap-1.5 p-4 text-center sm:text-left", className)} {...props} />
50
+ );
51
+ DrawerHeader.displayName = "DrawerHeader";
52
+
53
+ const DrawerFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
54
+ <div className={cn("mt-auto flex flex-col gap-2 p-4", className)} {...props} />
55
+ );
56
+ DrawerFooter.displayName = "DrawerFooter";
57
+
58
+ const DrawerTitle = React.forwardRef<
59
+ React.ElementRef<typeof DrawerPrimitive.Title>,
60
+ React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Title>
61
+ >(({ className, ...props }, ref) => (
62
+ <DrawerPrimitive.Title
63
+ ref={ref}
64
+ className={cn("text-lg font-semibold leading-none tracking-tight", className)}
65
+ {...props}
66
+ />
67
+ ));
68
+ DrawerTitle.displayName = DrawerPrimitive.Title.displayName;
69
+
70
+ const DrawerDescription = React.forwardRef<
71
+ React.ElementRef<typeof DrawerPrimitive.Description>,
72
+ React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Description>
73
+ >(({ className, ...props }, ref) => (
74
+ <DrawerPrimitive.Description ref={ref} className={cn("text-sm text-muted-foreground", className)} {...props} />
75
+ ));
76
+ DrawerDescription.displayName = DrawerPrimitive.Description.displayName;
77
+
78
+ export {
79
+ Drawer,
80
+ DrawerClose,
81
+ DrawerContent,
82
+ DrawerDescription,
83
+ DrawerFooter,
84
+ DrawerHeader,
85
+ DrawerOverlay,
86
+ DrawerPortal,
87
+ DrawerTitle,
88
+ DrawerTrigger,
89
+ };
@@ -0,0 +1,205 @@
1
+ "use client";
2
+
3
+ import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
4
+ import {
5
+ CheckIcon,
6
+ ChevronRightIcon,
7
+ DotFilledIcon,
8
+ } from "@radix-ui/react-icons";
9
+ import * as React from "react";
10
+
11
+ import { cn } from "../../utils/cn";
12
+
13
+ const DropdownMenu = DropdownMenuPrimitive.Root;
14
+
15
+ const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
16
+
17
+ const DropdownMenuGroup = DropdownMenuPrimitive.Group;
18
+
19
+ const DropdownMenuPortal = DropdownMenuPrimitive.Portal;
20
+
21
+ const DropdownMenuSub = DropdownMenuPrimitive.Sub;
22
+
23
+ const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;
24
+
25
+ const DropdownMenuSubTrigger = React.forwardRef<
26
+ React.ElementRef<typeof DropdownMenuPrimitive.SubTrigger>,
27
+ React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubTrigger> & {
28
+ inset?: boolean;
29
+ }
30
+ >(({ className, inset, children, ...props }, ref) => (
31
+ <DropdownMenuPrimitive.SubTrigger
32
+ ref={ref}
33
+ className={cn(
34
+ "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",
35
+ inset && "pl-8",
36
+ className,
37
+ )}
38
+ {...props}
39
+ >
40
+ {children}
41
+ <ChevronRightIcon className="ml-auto h-4 w-4" />
42
+ </DropdownMenuPrimitive.SubTrigger>
43
+ ));
44
+ DropdownMenuSubTrigger.displayName =
45
+ DropdownMenuPrimitive.SubTrigger.displayName;
46
+
47
+ const DropdownMenuSubContent = React.forwardRef<
48
+ React.ElementRef<typeof DropdownMenuPrimitive.SubContent>,
49
+ React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubContent>
50
+ >(({ className, ...props }, ref) => (
51
+ <DropdownMenuPrimitive.SubContent
52
+ ref={ref}
53
+ className={cn(
54
+ "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",
55
+ className,
56
+ )}
57
+ {...props}
58
+ />
59
+ ));
60
+ DropdownMenuSubContent.displayName =
61
+ DropdownMenuPrimitive.SubContent.displayName;
62
+
63
+ const DropdownMenuContent = React.forwardRef<
64
+ React.ElementRef<typeof DropdownMenuPrimitive.Content>,
65
+ React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content>
66
+ >(({ className, sideOffset = 4, ...props }, ref) => (
67
+ <DropdownMenuPrimitive.Portal>
68
+ <DropdownMenuPrimitive.Content
69
+ ref={ref}
70
+ sideOffset={sideOffset}
71
+ className={cn(
72
+ "z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md",
73
+ "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",
74
+ className,
75
+ )}
76
+ {...props}
77
+ />
78
+ </DropdownMenuPrimitive.Portal>
79
+ ));
80
+ DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName;
81
+
82
+ const DropdownMenuItem = React.forwardRef<
83
+ React.ElementRef<typeof DropdownMenuPrimitive.Item>,
84
+ React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item> & {
85
+ inset?: boolean;
86
+ }
87
+ >(({ className, inset, ...props }, ref) => (
88
+ <DropdownMenuPrimitive.Item
89
+ ref={ref}
90
+ className={cn(
91
+ "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",
92
+ inset && "pl-8",
93
+ className,
94
+ )}
95
+ {...props}
96
+ />
97
+ ));
98
+ DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName;
99
+
100
+ const DropdownMenuCheckboxItem = React.forwardRef<
101
+ React.ElementRef<typeof DropdownMenuPrimitive.CheckboxItem>,
102
+ React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.CheckboxItem>
103
+ >(({ className, children, checked, ...props }, ref) => (
104
+ <DropdownMenuPrimitive.CheckboxItem
105
+ ref={ref}
106
+ className={cn(
107
+ "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",
108
+ className,
109
+ )}
110
+ checked={checked}
111
+ {...props}
112
+ >
113
+ <span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
114
+ <DropdownMenuPrimitive.ItemIndicator>
115
+ <CheckIcon className="h-4 w-4" />
116
+ </DropdownMenuPrimitive.ItemIndicator>
117
+ </span>
118
+ {children}
119
+ </DropdownMenuPrimitive.CheckboxItem>
120
+ ));
121
+ DropdownMenuCheckboxItem.displayName =
122
+ DropdownMenuPrimitive.CheckboxItem.displayName;
123
+
124
+ const DropdownMenuRadioItem = React.forwardRef<
125
+ React.ElementRef<typeof DropdownMenuPrimitive.RadioItem>,
126
+ React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.RadioItem>
127
+ >(({ className, children, ...props }, ref) => (
128
+ <DropdownMenuPrimitive.RadioItem
129
+ ref={ref}
130
+ className={cn(
131
+ "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",
132
+ className,
133
+ )}
134
+ {...props}
135
+ >
136
+ <span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
137
+ <DropdownMenuPrimitive.ItemIndicator>
138
+ <DotFilledIcon className="h-4 w-4 fill-current" />
139
+ </DropdownMenuPrimitive.ItemIndicator>
140
+ </span>
141
+ {children}
142
+ </DropdownMenuPrimitive.RadioItem>
143
+ ));
144
+ DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName;
145
+
146
+ const DropdownMenuLabel = React.forwardRef<
147
+ React.ElementRef<typeof DropdownMenuPrimitive.Label>,
148
+ React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Label> & {
149
+ inset?: boolean;
150
+ }
151
+ >(({ className, inset, ...props }, ref) => (
152
+ <DropdownMenuPrimitive.Label
153
+ ref={ref}
154
+ className={cn(
155
+ "px-2 py-1.5 text-sm font-semibold",
156
+ inset && "pl-8",
157
+ className,
158
+ )}
159
+ {...props}
160
+ />
161
+ ));
162
+ DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName;
163
+
164
+ const DropdownMenuSeparator = React.forwardRef<
165
+ React.ElementRef<typeof DropdownMenuPrimitive.Separator>,
166
+ React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Separator>
167
+ >(({ className, ...props }, ref) => (
168
+ <DropdownMenuPrimitive.Separator
169
+ ref={ref}
170
+ className={cn("-mx-1 my-1 h-px bg-muted", className)}
171
+ {...props}
172
+ />
173
+ ));
174
+ DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName;
175
+
176
+ const DropdownMenuShortcut = ({
177
+ className,
178
+ ...props
179
+ }: React.HTMLAttributes<HTMLSpanElement>) => {
180
+ return (
181
+ <span
182
+ className={cn("ml-auto text-xs tracking-widest opacity-60", className)}
183
+ {...props}
184
+ />
185
+ );
186
+ };
187
+ DropdownMenuShortcut.displayName = "DropdownMenuShortcut";
188
+
189
+ export {
190
+ DropdownMenu,
191
+ DropdownMenuCheckboxItem,
192
+ DropdownMenuContent,
193
+ DropdownMenuGroup,
194
+ DropdownMenuItem,
195
+ DropdownMenuLabel,
196
+ DropdownMenuPortal,
197
+ DropdownMenuRadioGroup,
198
+ DropdownMenuRadioItem,
199
+ DropdownMenuSeparator,
200
+ DropdownMenuShortcut,
201
+ DropdownMenuSub,
202
+ DropdownMenuSubContent,
203
+ DropdownMenuSubTrigger,
204
+ DropdownMenuTrigger,
205
+ };
@@ -0,0 +1,138 @@
1
+ "use client";
2
+
3
+ import * as LabelPrimitive from "@radix-ui/react-label";
4
+ import { Slot } from "@radix-ui/react-slot";
5
+ import * as React from "react";
6
+ import { Controller, ControllerProps, FieldPath, FieldValues, FormProvider, useFormContext } from "react-hook-form";
7
+
8
+ import { Label } from "./label";
9
+ import { cn } from "../../utils/cn";
10
+
11
+ const Form = FormProvider;
12
+
13
+ type FormFieldContextValue<
14
+ TFieldValues extends FieldValues = FieldValues,
15
+ TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
16
+ > = {
17
+ name: TName;
18
+ };
19
+
20
+ const FormFieldContext = React.createContext<FormFieldContextValue>({} as FormFieldContextValue);
21
+
22
+ const FormField = <
23
+ TFieldValues extends FieldValues = FieldValues,
24
+ TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
25
+ >({
26
+ ...props
27
+ }: ControllerProps<TFieldValues, TName>) => {
28
+ return (
29
+ <FormFieldContext.Provider value={{ name: props.name }}>
30
+ <Controller {...props} />
31
+ </FormFieldContext.Provider>
32
+ );
33
+ };
34
+
35
+ const useFormField = () => {
36
+ const fieldContext = React.useContext(FormFieldContext);
37
+ const itemContext = React.useContext(FormItemContext);
38
+ const { getFieldState, formState } = useFormContext();
39
+
40
+ const fieldState = getFieldState(fieldContext.name, formState);
41
+
42
+ if (!fieldContext) {
43
+ throw new Error("useFormField should be used within <FormField>");
44
+ }
45
+
46
+ const { id } = itemContext;
47
+
48
+ return {
49
+ id,
50
+ name: fieldContext.name,
51
+ formItemId: `${id}-form-item`,
52
+ formDescriptionId: `${id}-form-item-description`,
53
+ formMessageId: `${id}-form-item-message`,
54
+ ...fieldState,
55
+ };
56
+ };
57
+
58
+ type FormItemContextValue = {
59
+ id: string;
60
+ };
61
+
62
+ const FormItemContext = React.createContext<FormItemContextValue>({} as FormItemContextValue);
63
+
64
+ const FormItem = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
65
+ ({ className, ...props }, ref) => {
66
+ const id = React.useId();
67
+
68
+ return (
69
+ <FormItemContext.Provider value={{ id }}>
70
+ <div ref={ref} className={cn("space-y-2", className)} {...props} />
71
+ </FormItemContext.Provider>
72
+ );
73
+ },
74
+ );
75
+ FormItem.displayName = "FormItem";
76
+
77
+ const FormLabel = React.forwardRef<
78
+ React.ElementRef<typeof LabelPrimitive.Root>,
79
+ React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root>
80
+ >(({ className, ...props }, ref) => {
81
+ const { error, formItemId } = useFormField();
82
+
83
+ return <Label ref={ref} className={cn(error && "text-destructive", className)} htmlFor={formItemId} {...props} />;
84
+ });
85
+ FormLabel.displayName = "FormLabel";
86
+
87
+ const FormControl = React.forwardRef<React.ElementRef<typeof Slot>, React.ComponentPropsWithoutRef<typeof Slot>>(
88
+ ({ ...props }, ref) => {
89
+ const { error, formItemId, formDescriptionId, formMessageId } = useFormField();
90
+
91
+ return (
92
+ <Slot
93
+ ref={ref}
94
+ id={formItemId}
95
+ aria-describedby={!error ? `${formDescriptionId}` : `${formDescriptionId} ${formMessageId}`}
96
+ aria-invalid={!!error}
97
+ {...props}
98
+ />
99
+ );
100
+ },
101
+ );
102
+ FormControl.displayName = "FormControl";
103
+
104
+ const FormDescription = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLParagraphElement>>(
105
+ ({ className, ...props }, ref) => {
106
+ const { formDescriptionId } = useFormField();
107
+
108
+ return (
109
+ <p ref={ref} id={formDescriptionId} className={cn("text-muted-foreground text-[0.8rem]", className)} {...props} />
110
+ );
111
+ },
112
+ );
113
+ FormDescription.displayName = "FormDescription";
114
+
115
+ const FormMessage = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLParagraphElement>>(
116
+ ({ className, children, ...props }, ref) => {
117
+ const { error, formMessageId } = useFormField();
118
+ const body = error ? String(error?.message) : children;
119
+
120
+ if (!body) {
121
+ return null;
122
+ }
123
+
124
+ return (
125
+ <p
126
+ ref={ref}
127
+ id={formMessageId}
128
+ className={cn("text-destructive text-[0.8rem] font-medium", className)}
129
+ {...props}
130
+ >
131
+ {body}
132
+ </p>
133
+ );
134
+ },
135
+ );
136
+ FormMessage.displayName = "FormMessage";
137
+
138
+ export { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, useFormField };
@@ -0,0 +1,29 @@
1
+ "use client";
2
+
3
+ import * as HoverCardPrimitive from "@radix-ui/react-hover-card";
4
+ import * as React from "react";
5
+
6
+ import { cn } from "../../utils/cn";
7
+
8
+ const HoverCard = HoverCardPrimitive.Root;
9
+
10
+ const HoverCardTrigger = HoverCardPrimitive.Trigger;
11
+
12
+ const HoverCardContent = React.forwardRef<
13
+ React.ElementRef<typeof HoverCardPrimitive.Content>,
14
+ React.ComponentPropsWithoutRef<typeof HoverCardPrimitive.Content>
15
+ >(({ className, align = "center", sideOffset = 4, ...props }, ref) => (
16
+ <HoverCardPrimitive.Content
17
+ ref={ref}
18
+ align={align}
19
+ sideOffset={sideOffset}
20
+ className={cn(
21
+ "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",
22
+ className,
23
+ )}
24
+ {...props}
25
+ />
26
+ ));
27
+ HoverCardContent.displayName = HoverCardPrimitive.Content.displayName;
28
+
29
+ export { HoverCard, HoverCardContent, HoverCardTrigger };
@@ -0,0 +1,21 @@
1
+ import * as React from "react"
2
+
3
+ import { cn } from "../../utils/cn"
4
+
5
+ function Input({ className, type, ...props }: React.ComponentProps<"input">) {
6
+ return (
7
+ <input
8
+ type={type}
9
+ data-slot="input"
10
+ className={cn(
11
+ "file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
12
+ "focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",
13
+ "aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
14
+ className
15
+ )}
16
+ {...props}
17
+ />
18
+ )
19
+ }
20
+
21
+ 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 "../../utils/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 };