@greatapps/common 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 (205) hide show
  1. package/dist/components/handlers/SearchParamsHandler.mjs +23 -0
  2. package/dist/components/handlers/SearchParamsHandler.mjs.map +1 -0
  3. package/dist/components/layouts/MainLayout.mjs +60 -0
  4. package/dist/components/layouts/MainLayout.mjs.map +1 -0
  5. package/dist/components/layouts/MdSideBarNavigation.mjs +36 -0
  6. package/dist/components/layouts/MdSideBarNavigation.mjs.map +1 -0
  7. package/dist/components/layouts/NavBar.mjs +45 -0
  8. package/dist/components/layouts/NavBar.mjs.map +1 -0
  9. package/dist/components/layouts/NotificationItem.mjs +7 -0
  10. package/dist/components/layouts/NotificationItem.mjs.map +1 -0
  11. package/dist/components/layouts/SideBarNavigation.mjs +22 -0
  12. package/dist/components/layouts/SideBarNavigation.mjs.map +1 -0
  13. package/dist/components/ui/buttons/Button.mjs +51 -0
  14. package/dist/components/ui/buttons/Button.mjs.map +1 -0
  15. package/dist/components/ui/buttons/CancelButton.mjs +16 -0
  16. package/dist/components/ui/buttons/CancelButton.mjs.map +1 -0
  17. package/dist/components/ui/buttons/CopyButton.mjs +34 -0
  18. package/dist/components/ui/buttons/CopyButton.mjs.map +1 -0
  19. package/dist/components/ui/data-display/Accordion.mjs +73 -0
  20. package/dist/components/ui/data-display/Accordion.mjs.map +1 -0
  21. package/dist/components/ui/data-display/Badge.mjs +41 -0
  22. package/dist/components/ui/data-display/Badge.mjs.map +1 -0
  23. package/dist/components/ui/data-display/Card.mjs +91 -0
  24. package/dist/components/ui/data-display/Card.mjs.map +1 -0
  25. package/dist/components/ui/data-display/Pagination.mjs +115 -0
  26. package/dist/components/ui/data-display/Pagination.mjs.map +1 -0
  27. package/dist/components/ui/data-display/ScrollArea.mjs +60 -0
  28. package/dist/components/ui/data-display/ScrollArea.mjs.map +1 -0
  29. package/dist/components/ui/data-display/Separator.mjs +28 -0
  30. package/dist/components/ui/data-display/Separator.mjs.map +1 -0
  31. package/dist/components/ui/data-display/Table.mjs +116 -0
  32. package/dist/components/ui/data-display/Table.mjs.map +1 -0
  33. package/dist/components/ui/data-display/Tabs.mjs +69 -0
  34. package/dist/components/ui/data-display/Tabs.mjs.map +1 -0
  35. package/dist/components/ui/feedback/CircularProgress.mjs +61 -0
  36. package/dist/components/ui/feedback/CircularProgress.mjs.map +1 -0
  37. package/dist/components/ui/feedback/DefaultCircularProgress.mjs +49 -0
  38. package/dist/components/ui/feedback/DefaultCircularProgress.mjs.map +1 -0
  39. package/dist/components/ui/feedback/Progress.mjs +37 -0
  40. package/dist/components/ui/feedback/Progress.mjs.map +1 -0
  41. package/dist/components/ui/feedback/Toast.mjs +73 -0
  42. package/dist/components/ui/feedback/Toast.mjs.map +1 -0
  43. package/dist/components/ui/form/Calendar.mjs +203 -0
  44. package/dist/components/ui/form/Calendar.mjs.map +1 -0
  45. package/dist/components/ui/form/Checkbox.mjs +33 -0
  46. package/dist/components/ui/form/Checkbox.mjs.map +1 -0
  47. package/dist/components/ui/form/DatePicker.mjs +78 -0
  48. package/dist/components/ui/form/DatePicker.mjs.map +1 -0
  49. package/dist/components/ui/form/DateRangePicker.mjs +86 -0
  50. package/dist/components/ui/form/DateRangePicker.mjs.map +1 -0
  51. package/dist/components/ui/form/Input.mjs +20 -0
  52. package/dist/components/ui/form/Input.mjs.map +1 -0
  53. package/dist/components/ui/form/InputOtp.mjs +67 -0
  54. package/dist/components/ui/form/InputOtp.mjs.map +1 -0
  55. package/dist/components/ui/form/RadioGroup.mjs +36 -0
  56. package/dist/components/ui/form/RadioGroup.mjs.map +1 -0
  57. package/dist/components/ui/form/Select.mjs +172 -0
  58. package/dist/components/ui/form/Select.mjs.map +1 -0
  59. package/dist/components/ui/form/Switch.mjs +33 -0
  60. package/dist/components/ui/form/Switch.mjs.map +1 -0
  61. package/dist/components/ui/form/Textarea.mjs +19 -0
  62. package/dist/components/ui/form/Textarea.mjs.map +1 -0
  63. package/dist/components/ui/overlay/Command.mjs +170 -0
  64. package/dist/components/ui/overlay/Command.mjs.map +1 -0
  65. package/dist/components/ui/overlay/Dialog.mjs +131 -0
  66. package/dist/components/ui/overlay/Dialog.mjs.map +1 -0
  67. package/dist/components/ui/overlay/Popover.mjs +46 -0
  68. package/dist/components/ui/overlay/Popover.mjs.map +1 -0
  69. package/dist/components/ui/overlay/Sheet.mjs +129 -0
  70. package/dist/components/ui/overlay/Sheet.mjs.map +1 -0
  71. package/dist/components/ui/overlay/Tooltip.mjs +55 -0
  72. package/dist/components/ui/overlay/Tooltip.mjs.map +1 -0
  73. package/dist/hooks/copy-to-clipboard.hook.mjs +39 -0
  74. package/dist/hooks/copy-to-clipboard.hook.mjs.map +1 -0
  75. package/dist/index.mjs +57 -0
  76. package/dist/index.mjs.map +1 -0
  77. package/dist/infra/api/client.mjs +115 -0
  78. package/dist/infra/api/client.mjs.map +1 -0
  79. package/dist/infra/api/types.mjs +31 -0
  80. package/dist/infra/api/types.mjs.map +1 -0
  81. package/dist/infra/utils/client-info.mjs +27 -0
  82. package/dist/infra/utils/client-info.mjs.map +1 -0
  83. package/dist/infra/utils/clsx.mjs +9 -0
  84. package/dist/infra/utils/clsx.mjs.map +1 -0
  85. package/dist/infra/utils/params.mjs +21 -0
  86. package/dist/infra/utils/params.mjs.map +1 -0
  87. package/dist/infra/utils/percentage.mjs +20 -0
  88. package/dist/infra/utils/percentage.mjs.map +1 -0
  89. package/dist/middlewares/chain.mjs +37 -0
  90. package/dist/middlewares/chain.mjs.map +1 -0
  91. package/dist/middlewares/create-auth-middleware.mjs +28 -0
  92. package/dist/middlewares/create-auth-middleware.mjs.map +1 -0
  93. package/dist/middlewares/types.mjs +11 -0
  94. package/dist/middlewares/types.mjs.map +1 -0
  95. package/dist/middlewares/validate-session.mjs +92 -0
  96. package/dist/middlewares/validate-session.mjs.map +1 -0
  97. package/dist/modules/auth/actions/login.action.mjs +11 -0
  98. package/dist/modules/auth/actions/login.action.mjs.map +1 -0
  99. package/dist/modules/auth/actions/logout.action.mjs +11 -0
  100. package/dist/modules/auth/actions/logout.action.mjs.map +1 -0
  101. package/dist/modules/auth/actions/register.action.mjs +9 -0
  102. package/dist/modules/auth/actions/register.action.mjs.map +1 -0
  103. package/dist/modules/auth/actions/validate-session.action.mjs +44 -0
  104. package/dist/modules/auth/actions/validate-session.action.mjs.map +1 -0
  105. package/dist/modules/auth/hooks/login.hook.mjs +12 -0
  106. package/dist/modules/auth/hooks/login.hook.mjs.map +1 -0
  107. package/dist/modules/auth/hooks/logout.hook.mjs +12 -0
  108. package/dist/modules/auth/hooks/logout.hook.mjs.map +1 -0
  109. package/dist/modules/auth/hooks/register.hook.mjs +12 -0
  110. package/dist/modules/auth/hooks/register.hook.mjs.map +1 -0
  111. package/dist/modules/auth/hooks/useUserQuery.mjs +48 -0
  112. package/dist/modules/auth/hooks/useUserQuery.mjs.map +1 -0
  113. package/dist/modules/auth/schema.mjs +1 -0
  114. package/dist/modules/auth/schema.mjs.map +1 -0
  115. package/dist/modules/auth/services/auth.service.mjs +163 -0
  116. package/dist/modules/auth/services/auth.service.mjs.map +1 -0
  117. package/dist/modules/users/action/find-user-by-id.action.mjs +21 -0
  118. package/dist/modules/users/action/find-user-by-id.action.mjs.map +1 -0
  119. package/dist/modules/users/schema.mjs +11 -0
  120. package/dist/modules/users/schema.mjs.map +1 -0
  121. package/dist/modules/users/services/user.service.mjs +50 -0
  122. package/dist/modules/users/services/user.service.mjs.map +1 -0
  123. package/dist/modules/whitelabel/actions/find-whitelabel.action.mjs +19 -0
  124. package/dist/modules/whitelabel/actions/find-whitelabel.action.mjs.map +1 -0
  125. package/dist/modules/whitelabel/schema.mjs +1 -0
  126. package/dist/modules/whitelabel/schema.mjs.map +1 -0
  127. package/dist/modules/whitelabel/services/whitelabel.service.mjs +62 -0
  128. package/dist/modules/whitelabel/services/whitelabel.service.mjs.map +1 -0
  129. package/dist/providers/auth.provider.mjs +84 -0
  130. package/dist/providers/auth.provider.mjs.map +1 -0
  131. package/dist/providers/query.provider.mjs +37 -0
  132. package/dist/providers/query.provider.mjs.map +1 -0
  133. package/dist/providers/whitelabel.provider.mjs +33 -0
  134. package/dist/providers/whitelabel.provider.mjs.map +1 -0
  135. package/dist/store/useMdSidebarStore.mjs +11 -0
  136. package/dist/store/useMdSidebarStore.mjs.map +1 -0
  137. package/package.json +68 -0
  138. package/src/components/handlers/SearchParamsHandler.tsx +61 -0
  139. package/src/components/layouts/MainLayout.tsx +59 -0
  140. package/src/components/layouts/MdSideBarNavigation.tsx +39 -0
  141. package/src/components/layouts/NavBar.tsx +79 -0
  142. package/src/components/layouts/NotificationItem.tsx +26 -0
  143. package/src/components/layouts/SideBarNavigation.tsx +22 -0
  144. package/src/components/ui/buttons/Button.tsx +55 -0
  145. package/src/components/ui/buttons/CancelButton.tsx +12 -0
  146. package/src/components/ui/buttons/CopyButton.tsx +47 -0
  147. package/src/components/ui/data-display/Accordion.tsx +79 -0
  148. package/src/components/ui/data-display/Badge.tsx +45 -0
  149. package/src/components/ui/data-display/Card.tsx +91 -0
  150. package/src/components/ui/data-display/Pagination.tsx +124 -0
  151. package/src/components/ui/data-display/ScrollArea.tsx +57 -0
  152. package/src/components/ui/data-display/Separator.tsx +27 -0
  153. package/src/components/ui/data-display/Table.tsx +115 -0
  154. package/src/components/ui/data-display/Tabs.tsx +65 -0
  155. package/src/components/ui/feedback/CircularProgress.tsx +75 -0
  156. package/src/components/ui/feedback/DefaultCircularProgress.tsx +53 -0
  157. package/src/components/ui/feedback/Progress.tsx +38 -0
  158. package/src/components/ui/feedback/Toast.tsx +99 -0
  159. package/src/components/ui/form/Calendar.tsx +226 -0
  160. package/src/components/ui/form/Checkbox.tsx +31 -0
  161. package/src/components/ui/form/DatePicker.tsx +97 -0
  162. package/src/components/ui/form/DateRangePicker.tsx +108 -0
  163. package/src/components/ui/form/Input.tsx +18 -0
  164. package/src/components/ui/form/InputOtp.tsx +78 -0
  165. package/src/components/ui/form/RadioGroup.tsx +43 -0
  166. package/src/components/ui/form/Select.tsx +195 -0
  167. package/src/components/ui/form/Switch.tsx +30 -0
  168. package/src/components/ui/form/Textarea.tsx +17 -0
  169. package/src/components/ui/overlay/Command.tsx +183 -0
  170. package/src/components/ui/overlay/Dialog.tsx +146 -0
  171. package/src/components/ui/overlay/Popover.tsx +47 -0
  172. package/src/components/ui/overlay/Sheet.tsx +145 -0
  173. package/src/components/ui/overlay/Tooltip.tsx +60 -0
  174. package/src/hooks/copy-to-clipboard.hook.tsx +52 -0
  175. package/src/index.ts +50 -0
  176. package/src/infra/api/client.ts +142 -0
  177. package/src/infra/api/types.ts +79 -0
  178. package/src/infra/utils/client-info.ts +35 -0
  179. package/src/infra/utils/clsx.ts +6 -0
  180. package/src/infra/utils/params.ts +27 -0
  181. package/src/infra/utils/percentage.ts +42 -0
  182. package/src/middlewares/chain.ts +45 -0
  183. package/src/middlewares/create-auth-middleware.ts +38 -0
  184. package/src/middlewares/types.ts +24 -0
  185. package/src/middlewares/validate-session.ts +116 -0
  186. package/src/modules/auth/actions/login.action.ts +11 -0
  187. package/src/modules/auth/actions/logout.action.ts +11 -0
  188. package/src/modules/auth/actions/register.action.ts +8 -0
  189. package/src/modules/auth/actions/validate-session.action.ts +51 -0
  190. package/src/modules/auth/hooks/login.hook.tsx +10 -0
  191. package/src/modules/auth/hooks/logout.hook.tsx +10 -0
  192. package/src/modules/auth/hooks/register.hook.tsx +10 -0
  193. package/src/modules/auth/hooks/useUserQuery.ts +49 -0
  194. package/src/modules/auth/schema.ts +220 -0
  195. package/src/modules/auth/services/auth.service.ts +225 -0
  196. package/src/modules/users/action/find-user-by-id.action.ts +25 -0
  197. package/src/modules/users/schema.ts +79 -0
  198. package/src/modules/users/services/user.service.ts +63 -0
  199. package/src/modules/whitelabel/actions/find-whitelabel.action.ts +20 -0
  200. package/src/modules/whitelabel/schema.ts +49 -0
  201. package/src/modules/whitelabel/services/whitelabel.service.ts +77 -0
  202. package/src/providers/auth.provider.tsx +113 -0
  203. package/src/providers/query.provider.tsx +52 -0
  204. package/src/providers/whitelabel.provider.tsx +44 -0
  205. package/src/store/useMdSidebarStore.ts +15 -0
@@ -0,0 +1,183 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import { Command as CommandPrimitive } from "cmdk"
5
+ import { SearchIcon } from "lucide-react";
6
+ import {
7
+ Dialog,
8
+ DialogContent,
9
+ DialogDescription,
10
+ DialogHeader,
11
+ DialogTitle,
12
+ } from "./Dialog"
13
+ import { cn } from "../../../infra/utils/clsx"
14
+
15
+ function Command({
16
+ className,
17
+ ...props
18
+ }: React.ComponentProps<typeof CommandPrimitive>) {
19
+ return (
20
+ <CommandPrimitive
21
+ data-slot="command"
22
+ className={cn(
23
+ "bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md",
24
+ className
25
+ )}
26
+ {...props}
27
+ />
28
+ )
29
+ }
30
+
31
+ function CommandDialog({
32
+ title = "Command Palette",
33
+ description = "Search for a command to run...",
34
+ children,
35
+ className,
36
+ showCloseButton = true,
37
+ ...props
38
+ }: React.ComponentProps<typeof Dialog> & {
39
+ title?: string
40
+ description?: string
41
+ className?: string
42
+ showCloseButton?: boolean
43
+ }) {
44
+ return (
45
+ <Dialog {...props}>
46
+ <DialogHeader className="sr-only">
47
+ <DialogTitle>{title}</DialogTitle>
48
+ <DialogDescription>{description}</DialogDescription>
49
+ </DialogHeader>
50
+ <DialogContent
51
+ className={cn("overflow-hidden p-0", className)}
52
+ showCloseButton={showCloseButton}
53
+ >
54
+ <Command className="[&_[cmdk-group-heading]]:text-muted-foreground **:data-[slot=command-input-wrapper]:h-12 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5">
55
+ {children}
56
+ </Command>
57
+ </DialogContent>
58
+ </Dialog>
59
+ )
60
+ }
61
+
62
+ function CommandInput({
63
+ className,
64
+ ...props
65
+ }: React.ComponentProps<typeof CommandPrimitive.Input>) {
66
+ return (
67
+ <div
68
+ data-slot="command-input-wrapper"
69
+ className="flex h-9 items-center gap-2 border-b px-3"
70
+ >
71
+ <SearchIcon className="size-5 shrink-0 opacity-50" />
72
+ <CommandPrimitive.Input
73
+ data-slot="command-input"
74
+ className={cn(
75
+ "placeholder:text-muted-foreground flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50",
76
+ className
77
+ )}
78
+ {...props}
79
+ />
80
+ </div>
81
+ )
82
+ }
83
+
84
+ function CommandList({
85
+ className,
86
+ ...props
87
+ }: React.ComponentProps<typeof CommandPrimitive.List>) {
88
+ return (
89
+ <CommandPrimitive.List
90
+ data-slot="command-list"
91
+ className={cn(
92
+ "max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",
93
+ className
94
+ )}
95
+ {...props}
96
+ />
97
+ )
98
+ }
99
+
100
+ function CommandEmpty({
101
+ ...props
102
+ }: React.ComponentProps<typeof CommandPrimitive.Empty>) {
103
+ return (
104
+ <CommandPrimitive.Empty
105
+ data-slot="command-empty"
106
+ className="py-6 text-center text-sm"
107
+ {...props}
108
+ />
109
+ )
110
+ }
111
+
112
+ function CommandGroup({
113
+ className,
114
+ ...props
115
+ }: React.ComponentProps<typeof CommandPrimitive.Group>) {
116
+ return (
117
+ <CommandPrimitive.Group
118
+ data-slot="command-group"
119
+ className={cn(
120
+ "text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium",
121
+ className
122
+ )}
123
+ {...props}
124
+ />
125
+ )
126
+ }
127
+
128
+ function CommandSeparator({
129
+ className,
130
+ ...props
131
+ }: React.ComponentProps<typeof CommandPrimitive.Separator>) {
132
+ return (
133
+ <CommandPrimitive.Separator
134
+ data-slot="command-separator"
135
+ className={cn("bg-border -mx-1 h-px", className)}
136
+ {...props}
137
+ />
138
+ )
139
+ }
140
+
141
+ function CommandItem({
142
+ className,
143
+ ...props
144
+ }: React.ComponentProps<typeof CommandPrimitive.Item>) {
145
+ return (
146
+ <CommandPrimitive.Item
147
+ data-slot="command-item"
148
+ className={cn(
149
+ "data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
150
+ className
151
+ )}
152
+ {...props}
153
+ />
154
+ )
155
+ }
156
+
157
+ function CommandShortcut({
158
+ className,
159
+ ...props
160
+ }: React.ComponentProps<"span">) {
161
+ return (
162
+ <span
163
+ data-slot="command-shortcut"
164
+ className={cn(
165
+ "text-muted-foreground ml-auto text-xs tracking-widest",
166
+ className
167
+ )}
168
+ {...props}
169
+ />
170
+ )
171
+ }
172
+
173
+ export {
174
+ Command,
175
+ CommandDialog,
176
+ CommandInput,
177
+ CommandList,
178
+ CommandEmpty,
179
+ CommandGroup,
180
+ CommandItem,
181
+ CommandShortcut,
182
+ CommandSeparator,
183
+ }
@@ -0,0 +1,146 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import * as DialogPrimitive from "@radix-ui/react-dialog"
5
+ import { XIcon } from "lucide-react"
6
+ import { cn } from "../../../infra/utils/clsx"
7
+
8
+ function Dialog({
9
+ ...props
10
+ }: React.ComponentProps<typeof DialogPrimitive.Root>) {
11
+ return <DialogPrimitive.Root data-slot="dialog" {...props} />
12
+ }
13
+
14
+ function DialogTrigger({
15
+ ...props
16
+ }: React.ComponentProps<typeof DialogPrimitive.Trigger>) {
17
+ return <DialogPrimitive.Trigger data-slot="dialog-trigger" {...props} />
18
+ }
19
+
20
+ function DialogPortal({
21
+ ...props
22
+ }: React.ComponentProps<typeof DialogPrimitive.Portal>) {
23
+ return <DialogPrimitive.Portal data-slot="dialog-portal" {...props} />
24
+ }
25
+
26
+ function DialogClose({
27
+ ...props
28
+ }: React.ComponentProps<typeof DialogPrimitive.Close>) {
29
+ return <DialogPrimitive.Close data-slot="dialog-close" {...props} />
30
+ }
31
+
32
+ function DialogOverlay({
33
+ className,
34
+ ...props
35
+ }: React.ComponentProps<typeof DialogPrimitive.Overlay>) {
36
+ return (
37
+ <DialogPrimitive.Overlay
38
+ data-slot="dialog-overlay"
39
+ className={cn(
40
+ "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-[1000] bg-black/50",
41
+ className
42
+ )}
43
+ {...props}
44
+ />
45
+ )
46
+ }
47
+
48
+ function DialogContent({
49
+ className,
50
+ children,
51
+ showCloseButton = true,
52
+ ...props
53
+ }: React.ComponentProps<typeof DialogPrimitive.Content> & {
54
+ showCloseButton?: boolean
55
+ }) {
56
+ return (
57
+ <DialogPortal data-slot="dialog-portal">
58
+ <DialogOverlay />
59
+ <DialogPrimitive.Content
60
+ data-slot="dialog-content"
61
+ className={cn(
62
+ "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 fixed top-[50%] left-[50%] z-[1000] grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",
63
+ className
64
+ )}
65
+ {...props}
66
+ >
67
+ {children}
68
+ {showCloseButton && (
69
+ <div className="absolute top-0.5 right-0">
70
+ <div className="p-4">
71
+ <DialogPrimitive.Close
72
+ data-slot="dialog-close"
73
+ className="hover:cursor-pointer flex size-8 items-center justify-center rounded-lg p-2 text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-950 focus:outline-none"
74
+ >
75
+ <XIcon className="size-[18px]" />
76
+ <span className="sr-only">Close</span>
77
+ </DialogPrimitive.Close>
78
+ </div>
79
+ </div>
80
+ )}
81
+ </DialogPrimitive.Content>
82
+ </DialogPortal>
83
+ )
84
+ }
85
+
86
+ function DialogHeader({ className, ...props }: React.ComponentProps<"div">) {
87
+ return (
88
+ <div
89
+ data-slot="dialog-header"
90
+ className={cn("p-5 flex flex-col gap-2 text-center sm:text-left", className)}
91
+ {...props}
92
+ />
93
+ )
94
+ }
95
+
96
+ function DialogFooter({ className, ...props }: React.ComponentProps<"div">) {
97
+ return (
98
+ <div
99
+ data-slot="dialog-footer"
100
+ className={cn(
101
+ "flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",
102
+ className
103
+ )}
104
+ {...props}
105
+ />
106
+ )
107
+ }
108
+
109
+ function DialogTitle({
110
+ className,
111
+ ...props
112
+ }: React.ComponentProps<typeof DialogPrimitive.Title>) {
113
+ return (
114
+ <DialogPrimitive.Title
115
+ data-slot="dialog-title"
116
+ className={cn("text-lg leading-none font-semibold", className)}
117
+ {...props}
118
+ />
119
+ )
120
+ }
121
+
122
+ function DialogDescription({
123
+ className,
124
+ ...props
125
+ }: React.ComponentProps<typeof DialogPrimitive.Description>) {
126
+ return (
127
+ <DialogPrimitive.Description
128
+ data-slot="dialog-description"
129
+ className={cn("text-muted-foreground text-sm", className)}
130
+ {...props}
131
+ />
132
+ )
133
+ }
134
+
135
+ export {
136
+ Dialog,
137
+ DialogClose,
138
+ DialogContent,
139
+ DialogDescription,
140
+ DialogFooter,
141
+ DialogHeader,
142
+ DialogOverlay,
143
+ DialogPortal,
144
+ DialogTitle,
145
+ DialogTrigger,
146
+ }
@@ -0,0 +1,47 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import * as PopoverPrimitive from "@radix-ui/react-popover"
5
+ import { cn } from "../../../infra/utils/clsx"
6
+
7
+ function Popover({
8
+ ...props
9
+ }: React.ComponentProps<typeof PopoverPrimitive.Root>) {
10
+ return <PopoverPrimitive.Root data-slot="popover" {...props} />
11
+ }
12
+
13
+ function PopoverTrigger({
14
+ ...props
15
+ }: React.ComponentProps<typeof PopoverPrimitive.Trigger>) {
16
+ return <PopoverPrimitive.Trigger data-slot="popover-trigger" {...props} />
17
+ }
18
+
19
+ function PopoverContent({
20
+ className,
21
+ align = "center",
22
+ sideOffset = 4,
23
+ ...props
24
+ }: React.ComponentProps<typeof PopoverPrimitive.Content>) {
25
+ return (
26
+ <PopoverPrimitive.Portal>
27
+ <PopoverPrimitive.Content
28
+ data-slot="popover-content"
29
+ align={align}
30
+ sideOffset={sideOffset}
31
+ className={cn(
32
+ "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-[1001] w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",
33
+ className
34
+ )}
35
+ {...props}
36
+ />
37
+ </PopoverPrimitive.Portal>
38
+ )
39
+ }
40
+
41
+ function PopoverAnchor({
42
+ ...props
43
+ }: React.ComponentProps<typeof PopoverPrimitive.Anchor>) {
44
+ return <PopoverPrimitive.Anchor data-slot="popover-anchor" {...props} />
45
+ }
46
+
47
+ export { Popover, PopoverTrigger, PopoverContent, PopoverAnchor }
@@ -0,0 +1,145 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import * as SheetPrimitive from "@radix-ui/react-dialog"
5
+ import { XIcon } from "lucide-react"
6
+ import { cn } from "../../../infra/utils/clsx"
7
+
8
+ function Sheet({ ...props }: React.ComponentProps<typeof SheetPrimitive.Root>) {
9
+ return <SheetPrimitive.Root data-slot="sheet" {...props} />
10
+ }
11
+
12
+ function SheetTrigger({
13
+ ...props
14
+ }: React.ComponentProps<typeof SheetPrimitive.Trigger>) {
15
+ return <SheetPrimitive.Trigger data-slot="sheet-trigger" {...props} />
16
+ }
17
+
18
+ function SheetClose({
19
+ ...props
20
+ }: React.ComponentProps<typeof SheetPrimitive.Close>) {
21
+ return <SheetPrimitive.Close data-slot="sheet-close" {...props} />
22
+ }
23
+
24
+ function SheetPortal({
25
+ ...props
26
+ }: React.ComponentProps<typeof SheetPrimitive.Portal>) {
27
+ return <SheetPrimitive.Portal data-slot="sheet-portal" {...props} />
28
+ }
29
+
30
+ function SheetOverlay({
31
+ className,
32
+ ...props
33
+ }: React.ComponentProps<typeof SheetPrimitive.Overlay>) {
34
+ return (
35
+ <SheetPrimitive.Overlay
36
+ data-slot="sheet-overlay"
37
+ className={cn(
38
+ "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-[1000] bg-black/50",
39
+ className
40
+ )}
41
+ {...props}
42
+ />
43
+ )
44
+ }
45
+
46
+ function SheetContent({
47
+ className,
48
+ children,
49
+ side = "right",
50
+ showCloseButton = true,
51
+ ...props
52
+ }: React.ComponentProps<typeof SheetPrimitive.Content> & {
53
+ side?: "top" | "right" | "bottom" | "left"
54
+ showCloseButton?: boolean
55
+ }) {
56
+ return (
57
+ <SheetPortal>
58
+ <SheetOverlay />
59
+ <SheetPrimitive.Content
60
+ data-slot="sheet-content"
61
+ className={cn(
62
+ "bg-background data-[state=open]:animate-in data-[state=closed]:animate-out fixed z-[1000] flex flex-col gap-4 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500",
63
+ side === "right" &&
64
+ "data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right inset-y-0 right-0 h-full w-3/4 border-l sm:max-w-sm",
65
+ side === "left" &&
66
+ "data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left inset-y-0 left-0 h-full w-3/4 border-r sm:max-w-sm",
67
+ side === "top" &&
68
+ "data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top inset-x-0 top-0 h-auto border-b",
69
+ side === "bottom" &&
70
+ "data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom inset-x-0 bottom-0 h-auto border-t",
71
+ className
72
+ )}
73
+ {...props}
74
+ >
75
+ {children}
76
+ {showCloseButton && (
77
+ <SheetPrimitive.Close
78
+ data-slot="sheet-close"
79
+ className="absolute top-3 right-3 hover:cursor-pointer flex size-8 items-center justify-center rounded-lg p-2 text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-950 focus:outline-none"
80
+ >
81
+ <XIcon className="size-[18px]" />
82
+ <span className="sr-only">Close</span>
83
+ </SheetPrimitive.Close>
84
+ )}
85
+ </SheetPrimitive.Content>
86
+ </SheetPortal>
87
+ )
88
+ }
89
+
90
+ function SheetHeader({ className, ...props }: React.ComponentProps<"div">) {
91
+ return (
92
+ <div
93
+ data-slot="sheet-header"
94
+ className={cn("flex flex-col gap-1.5 p-4", className)}
95
+ {...props}
96
+ />
97
+ )
98
+ }
99
+
100
+ function SheetFooter({ className, ...props }: React.ComponentProps<"div">) {
101
+ return (
102
+ <div
103
+ data-slot="sheet-footer"
104
+ className={cn("mt-auto flex flex-col gap-2 p-4", className)}
105
+ {...props}
106
+ />
107
+ )
108
+ }
109
+
110
+ function SheetTitle({
111
+ className,
112
+ ...props
113
+ }: React.ComponentProps<typeof SheetPrimitive.Title>) {
114
+ return (
115
+ <SheetPrimitive.Title
116
+ data-slot="sheet-title"
117
+ className={cn("text-foreground font-semibold", className)}
118
+ {...props}
119
+ />
120
+ )
121
+ }
122
+
123
+ function SheetDescription({
124
+ className,
125
+ ...props
126
+ }: React.ComponentProps<typeof SheetPrimitive.Description>) {
127
+ return (
128
+ <SheetPrimitive.Description
129
+ data-slot="sheet-description"
130
+ className={cn("text-muted-foreground text-sm", className)}
131
+ {...props}
132
+ />
133
+ )
134
+ }
135
+
136
+ export {
137
+ Sheet,
138
+ SheetTrigger,
139
+ SheetClose,
140
+ SheetContent,
141
+ SheetHeader,
142
+ SheetFooter,
143
+ SheetTitle,
144
+ SheetDescription,
145
+ }
@@ -0,0 +1,60 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import * as TooltipPrimitive from "@radix-ui/react-tooltip"
5
+ import { cn } from "../../../infra/utils/clsx"
6
+
7
+ function TooltipProvider({
8
+ delayDuration = 0,
9
+ ...props
10
+ }: React.ComponentProps<typeof TooltipPrimitive.Provider>) {
11
+ return (
12
+ <TooltipPrimitive.Provider
13
+ data-slot="tooltip-provider"
14
+ delayDuration={delayDuration}
15
+ {...props}
16
+ />
17
+ )
18
+ }
19
+
20
+ function Tooltip({
21
+ ...props
22
+ }: React.ComponentProps<typeof TooltipPrimitive.Root>) {
23
+ return (
24
+ <TooltipProvider>
25
+ <TooltipPrimitive.Root data-slot="tooltip" {...props} />
26
+ </TooltipProvider>
27
+ )
28
+ }
29
+
30
+ function TooltipTrigger({
31
+ ...props
32
+ }: React.ComponentProps<typeof TooltipPrimitive.Trigger>) {
33
+ return <TooltipPrimitive.Trigger data-slot="tooltip-trigger" {...props} />
34
+ }
35
+
36
+ function TooltipContent({
37
+ className,
38
+ sideOffset = 0,
39
+ children,
40
+ ...props
41
+ }: React.ComponentProps<typeof TooltipPrimitive.Content>) {
42
+ return (
43
+ <TooltipPrimitive.Portal>
44
+ <TooltipPrimitive.Content
45
+ data-slot="tooltip-content"
46
+ sideOffset={sideOffset}
47
+ className={cn(
48
+ "bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-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-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",
49
+ className
50
+ )}
51
+ {...props}
52
+ >
53
+ {children}
54
+ <TooltipPrimitive.Arrow className="bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%-2px)] rotate-45 rounded-[2px]" />
55
+ </TooltipPrimitive.Content>
56
+ </TooltipPrimitive.Portal>
57
+ )
58
+ }
59
+
60
+ export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider }
@@ -0,0 +1,52 @@
1
+ import { useState, useCallback, useRef, useEffect } from "react";
2
+
3
+ interface UseCopyToClipboardOptions {
4
+ feedbackDuration?: number;
5
+ onSuccess?: () => void;
6
+ onError?: (error: Error) => void;
7
+ }
8
+
9
+ interface UseCopyToClipboardReturn {
10
+ isCopied: boolean;
11
+ copy: (text: string) => Promise<void>;
12
+ }
13
+
14
+ export default function useCopyToClipboard({
15
+ feedbackDuration = 2000,
16
+ onSuccess,
17
+ onError,
18
+ }: UseCopyToClipboardOptions = {}): UseCopyToClipboardReturn {
19
+ const [isCopied, setIsCopied] = useState(false);
20
+ const timeoutRef = useRef<NodeJS.Timeout | null>(null);
21
+
22
+ useEffect(() => {
23
+ return () => {
24
+ if (timeoutRef.current) {
25
+ clearTimeout(timeoutRef.current);
26
+ }
27
+ };
28
+ }, []);
29
+
30
+ const copy = useCallback(
31
+ async (text: string) => {
32
+ if (timeoutRef.current) {
33
+ clearTimeout(timeoutRef.current);
34
+ }
35
+
36
+ try {
37
+ await navigator.clipboard.writeText(text);
38
+ setIsCopied(true);
39
+ onSuccess?.();
40
+
41
+ timeoutRef.current = setTimeout(() => {
42
+ setIsCopied(false);
43
+ }, feedbackDuration);
44
+ } catch (error) {
45
+ onError?.(error instanceof Error ? error : new Error("Failed to copy"));
46
+ }
47
+ },
48
+ [feedbackDuration, onSuccess, onError],
49
+ );
50
+
51
+ return { isCopied, copy };
52
+ }
package/src/index.ts ADDED
@@ -0,0 +1,50 @@
1
+ // Types
2
+ export * from './modules/auth/schema';
3
+ export * from './modules/users/schema';
4
+ export * from './modules/whitelabel/schema';
5
+ export * from './infra/api/types';
6
+
7
+ // Contexts
8
+ export * from './providers/query.provider';
9
+ export * from './providers/auth.provider';
10
+ export * from './providers/whitelabel.provider';
11
+
12
+ // Hooks
13
+ export { useUserQuery, useUserValidateSession, useInvalidateUser, useSetUserData, USER_QUERY_KEY } from './modules/auth/hooks/useUserQuery';
14
+
15
+ // Providers
16
+ export { QueryProvider } from './providers/query.provider';
17
+
18
+ // API Client
19
+ export { apiClient, ApiClient } from './infra/api/client';
20
+
21
+ // Services
22
+ export { authService } from './modules/auth/services/auth.service';
23
+ export { whitelabelService } from './modules/whitelabel/services/whitelabel.service';
24
+
25
+ // Actions
26
+ export { findWhitelabel } from './modules/whitelabel/actions/find-whitelabel.action';
27
+
28
+ // Middleware
29
+ export { createAuthMiddleware } from './middlewares/create-auth-middleware';
30
+ export { createMiddlewareChain } from './middlewares/chain';
31
+ export { continueChain, stopChain } from './middlewares/types';
32
+ export type { MiddlewareFunction, MiddlewareConfig, MiddlewareResult } from './middlewares/types';
33
+ export { validateSessionAction } from './modules/auth/actions/validate-session.action';
34
+
35
+ // Utils
36
+ export { cn } from './infra/utils/clsx';
37
+ export { getClientInfoFromRequest } from './infra/utils/client-info';
38
+ export { buildQueryParams } from './infra/utils/params';
39
+
40
+ // Layout
41
+ export { MainLayout, MainLayoutContent, MainLayoutSpacer, MainLayoutMain } from './components/layouts/MainLayout';
42
+ export { NavBar } from './components/layouts/NavBar';
43
+ export type { NavBarProps } from './components/layouts/NavBar';
44
+ export { SideBarNavigation } from './components/layouts/SideBarNavigation';
45
+ export { MdSideBarNavigation } from './components/layouts/MdSideBarNavigation';
46
+ export { NotificationItem } from './components/layouts/NotificationItem';
47
+ export type { NotificationItemProps } from './components/layouts/NotificationItem';
48
+
49
+ // Store
50
+ export { useMdSidebarStore } from './store/useMdSidebarStore';