@pago-sh/ui 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.
Files changed (229) hide show
  1. package/.turbo/turbo-build.log +195 -0
  2. package/CHANGELOG.md +47 -0
  3. package/README.md +22 -0
  4. package/components.json +17 -0
  5. package/dist/chunk-2RCGDEGJ.mjs +1 -0
  6. package/dist/chunk-3GDNSYGJ.mjs +1 -0
  7. package/dist/chunk-4TCUGB6E.mjs +1 -0
  8. package/dist/chunk-6XCXQA5L.mjs +1 -0
  9. package/dist/chunk-BBYR3CIF.mjs +1 -0
  10. package/dist/chunk-CFBUY7KY.mjs +1 -0
  11. package/dist/chunk-CHG2VB73.mjs +1 -0
  12. package/dist/chunk-GCVBVZU7.mjs +1 -0
  13. package/dist/chunk-HRGUR4R2.mjs +1 -0
  14. package/dist/chunk-IVU4SSCD.mjs +1 -0
  15. package/dist/chunk-N6WI5TGM.mjs +1 -0
  16. package/dist/chunk-OTKGECM3.mjs +1 -0
  17. package/dist/chunk-SRZFZUN4.mjs +1 -0
  18. package/dist/chunk-VPECET7P.mjs +1 -0
  19. package/dist/chunk-WQPSZXQS.mjs +1 -0
  20. package/dist/chunk-YXNT3UEO.mjs +1 -0
  21. package/dist/components/atoms/Accordion.d.mts +20 -0
  22. package/dist/components/atoms/Accordion.d.ts +20 -0
  23. package/dist/components/atoms/Accordion.js +1 -0
  24. package/dist/components/atoms/Accordion.mjs +1 -0
  25. package/dist/components/atoms/Card.d.mts +18 -0
  26. package/dist/components/atoms/Card.d.ts +18 -0
  27. package/dist/components/atoms/Card.js +1 -0
  28. package/dist/components/atoms/Card.mjs +1 -0
  29. package/dist/components/atoms/Combobox.d.mts +24 -0
  30. package/dist/components/atoms/Combobox.d.ts +24 -0
  31. package/dist/components/atoms/Combobox.js +1 -0
  32. package/dist/components/atoms/Combobox.mjs +1 -0
  33. package/dist/components/atoms/CopyToClipboardInput.d.mts +12 -0
  34. package/dist/components/atoms/CopyToClipboardInput.d.ts +12 -0
  35. package/dist/components/atoms/CopyToClipboardInput.js +1 -0
  36. package/dist/components/atoms/CopyToClipboardInput.mjs +1 -0
  37. package/dist/components/atoms/CountryPicker.d.mts +16 -0
  38. package/dist/components/atoms/CountryPicker.d.ts +16 -0
  39. package/dist/components/atoms/CountryPicker.js +1 -0
  40. package/dist/components/atoms/CountryPicker.mjs +1 -0
  41. package/dist/components/atoms/CountryStatePicker.d.mts +18 -0
  42. package/dist/components/atoms/CountryStatePicker.d.ts +18 -0
  43. package/dist/components/atoms/CountryStatePicker.js +1 -0
  44. package/dist/components/atoms/CountryStatePicker.mjs +1 -0
  45. package/dist/components/atoms/DateTimePicker.d.mts +10 -0
  46. package/dist/components/atoms/DateTimePicker.d.ts +10 -0
  47. package/dist/components/atoms/DateTimePicker.js +1 -0
  48. package/dist/components/atoms/DateTimePicker.mjs +1 -0
  49. package/dist/components/atoms/DropdownMenu.d.mts +22 -0
  50. package/dist/components/atoms/DropdownMenu.d.ts +22 -0
  51. package/dist/components/atoms/DropdownMenu.js +1 -0
  52. package/dist/components/atoms/DropdownMenu.mjs +1 -0
  53. package/dist/components/atoms/FormattedDateTime.d.mts +10 -0
  54. package/dist/components/atoms/FormattedDateTime.d.ts +10 -0
  55. package/dist/components/atoms/FormattedDateTime.js +1 -0
  56. package/dist/components/atoms/FormattedDateTime.mjs +1 -0
  57. package/dist/components/atoms/FormattedInterval.d.mts +9 -0
  58. package/dist/components/atoms/FormattedInterval.d.ts +9 -0
  59. package/dist/components/atoms/FormattedInterval.js +1 -0
  60. package/dist/components/atoms/FormattedInterval.mjs +1 -0
  61. package/dist/components/atoms/InputOTP.d.mts +4 -0
  62. package/dist/components/atoms/InputOTP.d.ts +4 -0
  63. package/dist/components/atoms/InputOTP.js +1 -0
  64. package/dist/components/atoms/InputOTP.mjs +1 -0
  65. package/dist/components/atoms/MoneyInput.d.mts +21 -0
  66. package/dist/components/atoms/MoneyInput.d.ts +21 -0
  67. package/dist/components/atoms/MoneyInput.js +1 -0
  68. package/dist/components/atoms/MoneyInput.mjs +1 -0
  69. package/dist/components/atoms/Paginator.d.mts +21 -0
  70. package/dist/components/atoms/Paginator.d.ts +21 -0
  71. package/dist/components/atoms/Paginator.js +1 -0
  72. package/dist/components/atoms/Paginator.mjs +1 -0
  73. package/dist/components/atoms/PagoTimeAgo.d.mts +8 -0
  74. package/dist/components/atoms/PagoTimeAgo.d.ts +8 -0
  75. package/dist/components/atoms/PagoTimeAgo.js +1 -0
  76. package/dist/components/atoms/PagoTimeAgo.mjs +1 -0
  77. package/dist/components/atoms/PercentageInput.d.mts +19 -0
  78. package/dist/components/atoms/PercentageInput.d.ts +19 -0
  79. package/dist/components/atoms/PercentageInput.js +1 -0
  80. package/dist/components/atoms/PercentageInput.mjs +1 -0
  81. package/dist/components/atoms/ShadowBox.d.mts +14 -0
  82. package/dist/components/atoms/ShadowBox.d.ts +14 -0
  83. package/dist/components/atoms/ShadowBox.js +1 -0
  84. package/dist/components/atoms/ShadowBox.mjs +1 -0
  85. package/dist/components/atoms/ShadowBoxOnMd.d.mts +6 -0
  86. package/dist/components/atoms/ShadowBoxOnMd.d.ts +6 -0
  87. package/dist/components/atoms/ShadowBoxOnMd.js +1 -0
  88. package/dist/components/atoms/ShadowBoxOnMd.mjs +1 -0
  89. package/dist/components/atoms/Sidebar.d.mts +11 -0
  90. package/dist/components/atoms/Sidebar.d.ts +11 -0
  91. package/dist/components/atoms/Sidebar.js +1 -0
  92. package/dist/components/atoms/Sidebar.mjs +1 -0
  93. package/dist/components/molecules/Banner.d.mts +11 -0
  94. package/dist/components/molecules/Banner.d.ts +11 -0
  95. package/dist/components/molecules/Banner.js +1 -0
  96. package/dist/components/molecules/Banner.mjs +1 -0
  97. package/dist/components/ui/accordion.d.mts +19 -0
  98. package/dist/components/ui/accordion.d.ts +19 -0
  99. package/dist/components/ui/accordion.js +1 -0
  100. package/dist/components/ui/accordion.mjs +1 -0
  101. package/dist/components/ui/alert-dialog.d.mts +41 -0
  102. package/dist/components/ui/alert-dialog.d.ts +41 -0
  103. package/dist/components/ui/alert-dialog.js +1 -0
  104. package/dist/components/ui/alert-dialog.mjs +1 -0
  105. package/dist/components/ui/calendar.d.mts +12 -0
  106. package/dist/components/ui/calendar.d.ts +12 -0
  107. package/dist/components/ui/calendar.js +1 -0
  108. package/dist/components/ui/calendar.mjs +1 -0
  109. package/dist/components/ui/card.d.mts +23 -0
  110. package/dist/components/ui/card.d.ts +23 -0
  111. package/dist/components/ui/card.js +1 -0
  112. package/dist/components/ui/card.mjs +1 -0
  113. package/dist/components/ui/chart.d.mts +55 -0
  114. package/dist/components/ui/chart.d.ts +55 -0
  115. package/dist/components/ui/chart.js +7 -0
  116. package/dist/components/ui/chart.mjs +7 -0
  117. package/dist/components/ui/checkbox.d.mts +2 -0
  118. package/dist/components/ui/checkbox.d.ts +2 -0
  119. package/dist/components/ui/checkbox.js +1 -0
  120. package/dist/components/ui/checkbox.mjs +1 -0
  121. package/dist/components/ui/command.d.mts +36 -0
  122. package/dist/components/ui/command.d.ts +36 -0
  123. package/dist/components/ui/command.js +1 -0
  124. package/dist/components/ui/command.mjs +1 -0
  125. package/dist/components/ui/dialog.d.mts +34 -0
  126. package/dist/components/ui/dialog.d.ts +34 -0
  127. package/dist/components/ui/dialog.js +1 -0
  128. package/dist/components/ui/dialog.mjs +1 -0
  129. package/dist/components/ui/dropdown-menu.d.mts +23 -0
  130. package/dist/components/ui/dropdown-menu.d.ts +23 -0
  131. package/dist/components/ui/dropdown-menu.js +1 -0
  132. package/dist/components/ui/dropdown-menu.mjs +1 -0
  133. package/dist/components/ui/form.d.mts +43 -0
  134. package/dist/components/ui/form.d.ts +43 -0
  135. package/dist/components/ui/form.js +1 -0
  136. package/dist/components/ui/form.mjs +1 -0
  137. package/dist/components/ui/input-otp.d.mts +21 -0
  138. package/dist/components/ui/input-otp.d.ts +21 -0
  139. package/dist/components/ui/input-otp.js +1 -0
  140. package/dist/components/ui/input-otp.mjs +1 -0
  141. package/dist/components/ui/label.d.mts +9 -0
  142. package/dist/components/ui/label.d.ts +9 -0
  143. package/dist/components/ui/label.js +1 -0
  144. package/dist/components/ui/label.mjs +1 -0
  145. package/dist/components/ui/popover.d.mts +12 -0
  146. package/dist/components/ui/popover.d.ts +12 -0
  147. package/dist/components/ui/popover.js +1 -0
  148. package/dist/components/ui/popover.mjs +1 -0
  149. package/dist/components/ui/radio-group.d.mts +14 -0
  150. package/dist/components/ui/radio-group.d.ts +14 -0
  151. package/dist/components/ui/radio-group.js +1 -0
  152. package/dist/components/ui/radio-group.mjs +1 -0
  153. package/dist/components/ui/separator.d.mts +10 -0
  154. package/dist/components/ui/separator.d.ts +10 -0
  155. package/dist/components/ui/separator.js +1 -0
  156. package/dist/components/ui/separator.mjs +1 -0
  157. package/dist/components/ui/sheet.d.mts +43 -0
  158. package/dist/components/ui/sheet.d.ts +43 -0
  159. package/dist/components/ui/sheet.js +1 -0
  160. package/dist/components/ui/sheet.mjs +1 -0
  161. package/dist/components/ui/sidebar.d.mts +149 -0
  162. package/dist/components/ui/sidebar.d.ts +149 -0
  163. package/dist/components/ui/sidebar.js +1 -0
  164. package/dist/components/ui/sidebar.mjs +1 -0
  165. package/dist/components/ui/tooltip.d.mts +1 -0
  166. package/dist/components/ui/tooltip.d.ts +1 -0
  167. package/dist/components/ui/tooltip.js +1 -0
  168. package/dist/components/ui/tooltip.mjs +1 -0
  169. package/dist/hooks/theming.d.mts +76 -0
  170. package/dist/hooks/theming.d.ts +76 -0
  171. package/dist/hooks/theming.js +1 -0
  172. package/dist/hooks/theming.mjs +1 -0
  173. package/dist/hooks/use-mobile.d.mts +3 -0
  174. package/dist/hooks/use-mobile.d.ts +3 -0
  175. package/dist/hooks/use-mobile.js +1 -0
  176. package/dist/hooks/use-mobile.mjs +1 -0
  177. package/dist/lib/meterUnit.d.mts +34 -0
  178. package/dist/lib/meterUnit.d.ts +34 -0
  179. package/dist/lib/meterUnit.js +1 -0
  180. package/dist/lib/meterUnit.mjs +1 -0
  181. package/dist/lib/utils.d.mts +5 -0
  182. package/dist/lib/utils.d.ts +5 -0
  183. package/dist/lib/utils.js +1 -0
  184. package/dist/lib/utils.mjs +1 -0
  185. package/eslint.config.mjs +18 -0
  186. package/package.json +74 -0
  187. package/src/components/atoms/Accordion.tsx +56 -0
  188. package/src/components/atoms/Card.tsx +52 -0
  189. package/src/components/atoms/Combobox.tsx +166 -0
  190. package/src/components/atoms/CopyToClipboardInput.tsx +72 -0
  191. package/src/components/atoms/CountryPicker.tsx +81 -0
  192. package/src/components/atoms/CountryStatePicker.tsx +155 -0
  193. package/src/components/atoms/DateTimePicker.tsx +69 -0
  194. package/src/components/atoms/DropdownMenu.tsx +68 -0
  195. package/src/components/atoms/FormattedDateTime.tsx +58 -0
  196. package/src/components/atoms/FormattedInterval.tsx +81 -0
  197. package/src/components/atoms/InputOTP.tsx +7 -0
  198. package/src/components/atoms/MoneyInput.tsx +297 -0
  199. package/src/components/atoms/Paginator.tsx +227 -0
  200. package/src/components/atoms/PagoTimeAgo.tsx +19 -0
  201. package/src/components/atoms/PercentageInput.tsx +97 -0
  202. package/src/components/atoms/ShadowBox.tsx +26 -0
  203. package/src/components/atoms/ShadowBoxOnMd.tsx +20 -0
  204. package/src/components/atoms/Sidebar.tsx +1 -0
  205. package/src/components/molecules/Banner.tsx +42 -0
  206. package/src/components/ui/accordion.tsx +63 -0
  207. package/src/components/ui/alert-dialog.tsx +147 -0
  208. package/src/components/ui/calendar.tsx +81 -0
  209. package/src/components/ui/card.tsx +47 -0
  210. package/src/components/ui/chart.tsx +372 -0
  211. package/src/components/ui/checkbox.tsx +3 -0
  212. package/src/components/ui/command.tsx +133 -0
  213. package/src/components/ui/dialog.tsx +127 -0
  214. package/src/components/ui/dropdown-menu.tsx +74 -0
  215. package/src/components/ui/form.tsx +180 -0
  216. package/src/components/ui/input-otp.tsx +68 -0
  217. package/src/components/ui/label.tsx +25 -0
  218. package/src/components/ui/popover.tsx +34 -0
  219. package/src/components/ui/radio-group.tsx +46 -0
  220. package/src/components/ui/separator.tsx +29 -0
  221. package/src/components/ui/sheet.tsx +149 -0
  222. package/src/components/ui/sidebar.tsx +742 -0
  223. package/src/components/ui/tooltip.tsx +8 -0
  224. package/src/hooks/theming.ts +87 -0
  225. package/src/hooks/use-mobile.ts +19 -0
  226. package/src/lib/meterUnit.ts +52 -0
  227. package/src/lib/utils.ts +6 -0
  228. package/tsconfig.json +15 -0
  229. package/tsup.config.ts +11 -0
@@ -0,0 +1,127 @@
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/utils'
8
+
9
+ const Dialog = DialogPrimitive.Root
10
+
11
+ const DialogTrigger = DialogPrimitive.Trigger
12
+
13
+ const DialogPortal = DialogPrimitive.Portal
14
+
15
+ const DialogClose = DialogPrimitive.Close
16
+
17
+ const DialogOverlay = ({
18
+ ref,
19
+ className,
20
+ ...props
21
+ }: React.ComponentProps<typeof DialogPrimitive.Overlay>) => (
22
+ <DialogPrimitive.Overlay
23
+ ref={ref}
24
+ className={cn(
25
+ 'data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/80',
26
+ className,
27
+ )}
28
+ {...props}
29
+ />
30
+ )
31
+ DialogOverlay.displayName = DialogPrimitive.Overlay.displayName
32
+
33
+ const DialogContent = ({
34
+ ref,
35
+ className,
36
+ children,
37
+ ...props
38
+ }: React.ComponentProps<typeof DialogPrimitive.Content>) => (
39
+ <DialogPortal>
40
+ <DialogOverlay />
41
+ <DialogPrimitive.Content
42
+ ref={ref}
43
+ className={cn(
44
+ 'bg-background 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%] fixed top-[50%] left-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border p-6 shadow-lg duration-200 sm:rounded-lg',
45
+ className,
46
+ )}
47
+ {...props}
48
+ >
49
+ {children}
50
+ <DialogPrimitive.Close className="ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-none disabled:pointer-events-none">
51
+ <X className="h-4 w-4" />
52
+ <span className="sr-only">Close</span>
53
+ </DialogPrimitive.Close>
54
+ </DialogPrimitive.Content>
55
+ </DialogPortal>
56
+ )
57
+ DialogContent.displayName = DialogPrimitive.Content.displayName
58
+
59
+ const DialogHeader = ({
60
+ className,
61
+ ...props
62
+ }: React.HTMLAttributes<HTMLDivElement>) => (
63
+ <div
64
+ className={cn(
65
+ 'flex flex-col space-y-1.5 text-center sm:text-left',
66
+ className,
67
+ )}
68
+ {...props}
69
+ />
70
+ )
71
+ DialogHeader.displayName = 'DialogHeader'
72
+
73
+ const DialogFooter = ({
74
+ className,
75
+ ...props
76
+ }: React.HTMLAttributes<HTMLDivElement>) => (
77
+ <div
78
+ className={cn(
79
+ 'flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2',
80
+ className,
81
+ )}
82
+ {...props}
83
+ />
84
+ )
85
+ DialogFooter.displayName = 'DialogFooter'
86
+
87
+ const DialogTitle = ({
88
+ ref,
89
+ className,
90
+ ...props
91
+ }: React.ComponentProps<typeof DialogPrimitive.Title>) => (
92
+ <DialogPrimitive.Title
93
+ ref={ref}
94
+ className={cn(
95
+ 'text-lg leading-none font-semibold tracking-tight',
96
+ className,
97
+ )}
98
+ {...props}
99
+ />
100
+ )
101
+ DialogTitle.displayName = DialogPrimitive.Title.displayName
102
+
103
+ const DialogDescription = ({
104
+ ref,
105
+ className,
106
+ ...props
107
+ }: React.ComponentProps<typeof DialogPrimitive.Description>) => (
108
+ <DialogPrimitive.Description
109
+ ref={ref}
110
+ className={cn('text-muted-foreground text-sm', className)}
111
+ {...props}
112
+ />
113
+ )
114
+ DialogDescription.displayName = DialogPrimitive.Description.displayName
115
+
116
+ export {
117
+ Dialog,
118
+ DialogClose,
119
+ DialogContent,
120
+ DialogDescription,
121
+ DialogFooter,
122
+ DialogHeader,
123
+ DialogOverlay,
124
+ DialogPortal,
125
+ DialogTitle,
126
+ DialogTrigger,
127
+ }
@@ -0,0 +1,74 @@
1
+ 'use client'
2
+
3
+ import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu'
4
+ import * as React from 'react'
5
+
6
+ import { cn } from '@/lib/utils'
7
+
8
+ const DropdownMenu = DropdownMenuPrimitive.Root
9
+
10
+ const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger
11
+
12
+ const DropdownMenuPortal = DropdownMenuPrimitive.Portal
13
+
14
+ const DropdownMenuContent = ({
15
+ ref,
16
+ className,
17
+ sideOffset = 4,
18
+ ...props
19
+ }: React.ComponentProps<typeof DropdownMenuPrimitive.Content>) => (
20
+ <DropdownMenuPrimitive.Portal>
21
+ <DropdownMenuPrimitive.Content
22
+ ref={ref}
23
+ sideOffset={sideOffset}
24
+ className={cn(
25
+ 'bg-popover text-popover-foreground 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 z-50 min-w-32 overflow-hidden rounded-md border p-1 shadow-md',
26
+ className,
27
+ )}
28
+ {...props}
29
+ />
30
+ </DropdownMenuPrimitive.Portal>
31
+ )
32
+ DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName
33
+
34
+ const DropdownMenuItem = ({
35
+ ref,
36
+ className,
37
+ destructive,
38
+ ...props
39
+ }: React.ComponentProps<typeof DropdownMenuPrimitive.Item> & {
40
+ destructive?: boolean
41
+ }) => (
42
+ <DropdownMenuPrimitive.Item
43
+ ref={ref}
44
+ className={cn(
45
+ 'focus:bg-accent focus:text-accent-foreground relative flex cursor-pointer items-center gap-2 rounded-xs px-2 py-1.5 text-sm transition-colors outline-none select-none data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4! [&_svg]:shrink-0',
46
+ destructive && 'text-destructive focus:text-white',
47
+ className,
48
+ )}
49
+ {...props}
50
+ />
51
+ )
52
+ DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName
53
+
54
+ const DropdownMenuSeparator = ({
55
+ ref,
56
+ className,
57
+ ...props
58
+ }: React.ComponentProps<typeof DropdownMenuPrimitive.Separator>) => (
59
+ <DropdownMenuPrimitive.Separator
60
+ ref={ref}
61
+ className={cn('bg-muted -mx-1 my-1 h-px', className)}
62
+ {...props}
63
+ />
64
+ )
65
+ DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName
66
+
67
+ export {
68
+ DropdownMenu,
69
+ DropdownMenuContent,
70
+ DropdownMenuItem,
71
+ DropdownMenuPortal,
72
+ DropdownMenuSeparator,
73
+ DropdownMenuTrigger,
74
+ }
@@ -0,0 +1,180 @@
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 {
7
+ Controller,
8
+ ControllerProps,
9
+ FieldPath,
10
+ FieldValues,
11
+ FormProvider,
12
+ useFormContext,
13
+ } from 'react-hook-form'
14
+
15
+ import { Label } from '@/components/ui/label'
16
+ import { cn } from '@/lib/utils'
17
+
18
+ const Form = FormProvider
19
+
20
+ type FormFieldContextValue<
21
+ TFieldValues extends FieldValues = FieldValues,
22
+ TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
23
+ > = {
24
+ name: TName
25
+ }
26
+
27
+ const FormFieldContext = React.createContext<FormFieldContextValue>(
28
+ {} as FormFieldContextValue,
29
+ )
30
+
31
+ const FormField = <
32
+ TFieldValues extends FieldValues = FieldValues,
33
+ TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
34
+ >({
35
+ ...props
36
+ }: ControllerProps<TFieldValues, TName>) => {
37
+ return (
38
+ <FormFieldContext.Provider value={{ name: props.name }}>
39
+ <Controller {...props} />
40
+ </FormFieldContext.Provider>
41
+ )
42
+ }
43
+
44
+ const useFormField = () => {
45
+ const fieldContext = React.useContext(FormFieldContext)
46
+ const itemContext = React.useContext(FormItemContext)
47
+ const { getFieldState, formState } = useFormContext()
48
+
49
+ const fieldState = getFieldState(fieldContext.name, formState)
50
+
51
+ if (!fieldContext) {
52
+ throw new Error('useFormField should be used within <FormField>')
53
+ }
54
+
55
+ const { id } = itemContext
56
+
57
+ return {
58
+ id,
59
+ name: fieldContext.name,
60
+ formItemId: `${id}-form-item`,
61
+ formDescriptionId: `${id}-form-item-description`,
62
+ formMessageId: `${id}-form-item-message`,
63
+ ...fieldState,
64
+ }
65
+ }
66
+
67
+ type FormItemContextValue = {
68
+ id: string
69
+ }
70
+
71
+ const FormItemContext = React.createContext<FormItemContextValue>(
72
+ {} as FormItemContextValue,
73
+ )
74
+
75
+ const FormItem = ({
76
+ ref,
77
+ className,
78
+ ...props
79
+ }: React.ComponentProps<'div'>) => {
80
+ const id = React.useId()
81
+
82
+ return (
83
+ <FormItemContext.Provider value={{ id }}>
84
+ <div ref={ref} className={cn('space-y-2', className)} {...props} />
85
+ </FormItemContext.Provider>
86
+ )
87
+ }
88
+ FormItem.displayName = 'FormItem'
89
+
90
+ const FormLabel = ({
91
+ ref,
92
+ className,
93
+ ...props
94
+ }: React.ComponentProps<typeof LabelPrimitive.Root>) => {
95
+ const { error, formItemId } = useFormField()
96
+
97
+ return (
98
+ <Label
99
+ ref={ref}
100
+ className={cn(error && 'text-destructive', className)}
101
+ htmlFor={formItemId}
102
+ {...props}
103
+ />
104
+ )
105
+ }
106
+ FormLabel.displayName = 'FormLabel'
107
+
108
+ const FormControl = ({ ref, ...props }: React.ComponentProps<typeof Slot>) => {
109
+ const { error, formItemId, formDescriptionId, formMessageId } = useFormField()
110
+
111
+ return (
112
+ <Slot
113
+ ref={ref}
114
+ id={formItemId}
115
+ aria-describedby={
116
+ !error
117
+ ? `${formDescriptionId}`
118
+ : `${formDescriptionId} ${formMessageId}`
119
+ }
120
+ aria-invalid={!!error}
121
+ {...props}
122
+ />
123
+ )
124
+ }
125
+ FormControl.displayName = 'FormControl'
126
+
127
+ const FormDescription = ({
128
+ ref,
129
+ className,
130
+ ...props
131
+ }: React.ComponentProps<'p'>) => {
132
+ const { formDescriptionId } = useFormField()
133
+
134
+ return (
135
+ <p
136
+ ref={ref}
137
+ id={formDescriptionId}
138
+ className={cn('text-muted-foreground text-sm', className)}
139
+ {...props}
140
+ />
141
+ )
142
+ }
143
+ FormDescription.displayName = 'FormDescription'
144
+
145
+ const FormMessage = ({
146
+ ref,
147
+ className,
148
+ children,
149
+ ...props
150
+ }: React.ComponentProps<'p'>) => {
151
+ const { error, formMessageId } = useFormField()
152
+ const body = error ? String(error?.message) : children
153
+
154
+ if (!body) {
155
+ return null
156
+ }
157
+
158
+ return (
159
+ <p
160
+ ref={ref}
161
+ id={formMessageId}
162
+ className={cn('text-destructive text-sm font-medium', className)}
163
+ {...props}
164
+ >
165
+ {body}
166
+ </p>
167
+ )
168
+ }
169
+ FormMessage.displayName = 'FormMessage'
170
+
171
+ export {
172
+ Form,
173
+ FormControl,
174
+ FormDescription,
175
+ FormField,
176
+ FormItem,
177
+ FormLabel,
178
+ FormMessage,
179
+ useFormField,
180
+ }
@@ -0,0 +1,68 @@
1
+ 'use client'
2
+
3
+ import { OTPInput, OTPInputContext, RenderProps } from 'input-otp'
4
+ import * as React from 'react'
5
+
6
+ import { cn } from '@/lib/utils'
7
+
8
+ const InputOTP = ({
9
+ ref,
10
+ className,
11
+ containerClassName,
12
+ ...props
13
+ }: React.ComponentProps<typeof OTPInput>) => (
14
+ <OTPInput
15
+ ref={ref}
16
+ containerClassName={cn(
17
+ 'flex items-center gap-2 has-disabled:opacity-50',
18
+ containerClassName,
19
+ )}
20
+ className={cn('disabled:cursor-not-allowed', className)}
21
+ {...props}
22
+ />
23
+ )
24
+ InputOTP.displayName = 'InputOTP'
25
+
26
+ const InputOTPGroup = ({
27
+ ref,
28
+ className,
29
+ ...props
30
+ }: React.ComponentProps<'div'>) => (
31
+ <div ref={ref} className={cn('flex items-center', className)} {...props} />
32
+ )
33
+ InputOTPGroup.displayName = 'InputOTPGroup'
34
+
35
+ const InputOTPSlot = ({
36
+ ref,
37
+ index,
38
+ className,
39
+ ...props
40
+ }: {
41
+ index: number
42
+ className?: string
43
+ } & React.ComponentProps<'div'>) => {
44
+ const inputOTPContext = React.useContext<RenderProps>(OTPInputContext)
45
+ const { char, hasFakeCaret, isActive } = inputOTPContext.slots[index]
46
+
47
+ return (
48
+ <div
49
+ ref={ref}
50
+ className={cn(
51
+ 'border-input dark:bg-pago-900 relative flex h-10 w-10 items-center justify-center border-y border-r bg-white text-sm transition-all first:rounded-l-md first:border-l last:rounded-r-md',
52
+ isActive && 'ring-ring ring-offset-background z-10 ring-2',
53
+ className,
54
+ )}
55
+ {...props}
56
+ >
57
+ {char}
58
+ {hasFakeCaret && (
59
+ <div className="pointer-events-none absolute inset-0 flex items-center justify-center">
60
+ <div className="animate-caret-blink bg-foreground h-4 w-px duration-1000" />
61
+ </div>
62
+ )}
63
+ </div>
64
+ )
65
+ }
66
+ InputOTPSlot.displayName = 'InputOTPSlot'
67
+
68
+ export { InputOTP, InputOTPGroup, InputOTPSlot }
@@ -0,0 +1,25 @@
1
+ 'use client'
2
+
3
+ import * as LabelPrimitive from '@radix-ui/react-label'
4
+ import { cva } from 'class-variance-authority'
5
+
6
+ import { cn } from '@/lib/utils'
7
+
8
+ const labelVariants = cva(
9
+ 'block text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70',
10
+ )
11
+
12
+ const Label = ({
13
+ ref,
14
+ className,
15
+ ...props
16
+ }: React.ComponentProps<typeof LabelPrimitive.Root>) => (
17
+ <LabelPrimitive.Root
18
+ ref={ref}
19
+ className={cn(labelVariants(), className)}
20
+ {...props}
21
+ />
22
+ )
23
+ Label.displayName = LabelPrimitive.Root.displayName
24
+
25
+ export { Label }
@@ -0,0 +1,34 @@
1
+ 'use client'
2
+
3
+ import * as PopoverPrimitive from '@radix-ui/react-popover'
4
+ import * as React from 'react'
5
+
6
+ import { cn } from '@/lib/utils'
7
+
8
+ const Popover = PopoverPrimitive.Root
9
+
10
+ const PopoverTrigger = PopoverPrimitive.Trigger
11
+
12
+ const PopoverContent = ({
13
+ ref,
14
+ className,
15
+ align = 'center',
16
+ sideOffset = 4,
17
+ ...props
18
+ }: React.ComponentProps<typeof PopoverPrimitive.Content>) => (
19
+ <PopoverPrimitive.Portal>
20
+ <PopoverPrimitive.Content
21
+ ref={ref}
22
+ align={align}
23
+ sideOffset={sideOffset}
24
+ className={cn(
25
+ 'bg-popover text-popover-foreground 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 z-50 w-72 rounded-md border p-4 shadow-md outline-none',
26
+ className,
27
+ )}
28
+ {...props}
29
+ />
30
+ </PopoverPrimitive.Portal>
31
+ )
32
+ PopoverContent.displayName = PopoverPrimitive.Content.displayName
33
+
34
+ export { Popover, PopoverContent, PopoverTrigger }
@@ -0,0 +1,46 @@
1
+ 'use client'
2
+
3
+ import * as RadioGroupPrimitive from '@radix-ui/react-radio-group'
4
+ import { Circle } from 'lucide-react'
5
+ import * as React from 'react'
6
+
7
+ import { cn } from '@/lib/utils'
8
+
9
+ const RadioGroup = ({
10
+ ref,
11
+ className,
12
+ ...props
13
+ }: React.ComponentProps<typeof RadioGroupPrimitive.Root>) => {
14
+ return (
15
+ <RadioGroupPrimitive.Root
16
+ className={cn('grid gap-2', className)}
17
+ {...props}
18
+ ref={ref}
19
+ />
20
+ )
21
+ }
22
+ RadioGroup.displayName = RadioGroupPrimitive.Root.displayName
23
+
24
+ const RadioGroupItem = ({
25
+ ref,
26
+ className,
27
+ ...props
28
+ }: React.ComponentProps<typeof RadioGroupPrimitive.Item>) => {
29
+ return (
30
+ <RadioGroupPrimitive.Item
31
+ ref={ref}
32
+ className={cn(
33
+ 'border-primary text-primary ring-offset-background focus-visible:ring-ring aspect-square h-4 w-4 rounded-full border focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50',
34
+ className,
35
+ )}
36
+ {...props}
37
+ >
38
+ <RadioGroupPrimitive.Indicator className="flex items-center justify-center">
39
+ <Circle className="h-2.5 w-2.5 fill-current text-current" />
40
+ </RadioGroupPrimitive.Indicator>
41
+ </RadioGroupPrimitive.Item>
42
+ )
43
+ }
44
+ RadioGroupItem.displayName = RadioGroupPrimitive.Item.displayName
45
+
46
+ export { RadioGroup, RadioGroupItem }
@@ -0,0 +1,29 @@
1
+ 'use client'
2
+
3
+ import * as SeparatorPrimitive from '@radix-ui/react-separator'
4
+ import * as React from 'react'
5
+
6
+ import { cn } from '@/lib/utils'
7
+
8
+ const Separator = ({
9
+ ref,
10
+ className,
11
+ orientation = 'horizontal',
12
+ decorative = true,
13
+ ...props
14
+ }: React.ComponentProps<typeof SeparatorPrimitive.Root>) => (
15
+ <SeparatorPrimitive.Root
16
+ ref={ref}
17
+ decorative={decorative}
18
+ orientation={orientation}
19
+ className={cn(
20
+ 'bg-border shrink-0',
21
+ orientation === 'horizontal' ? 'h-px w-full' : 'h-full w-px',
22
+ className,
23
+ )}
24
+ {...props}
25
+ />
26
+ )
27
+ Separator.displayName = SeparatorPrimitive.Root.displayName
28
+
29
+ export { Separator }