ta_data_mas 0.0.2

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 (219) hide show
  1. package/README.md +42 -0
  2. package/apps/api/.prettierrc +4 -0
  3. package/apps/api/README.md +98 -0
  4. package/apps/api/drizzle/0000_right_drax.sql +87 -0
  5. package/apps/api/drizzle/meta/0000_snapshot.json +588 -0
  6. package/apps/api/drizzle/meta/_journal.json +13 -0
  7. package/apps/api/drizzle.config.ts +12 -0
  8. package/apps/api/eslint.config.mjs +35 -0
  9. package/apps/api/nest-cli.json +8 -0
  10. package/apps/api/package.json +99 -0
  11. package/apps/api/src/app.controller.spec.ts +25 -0
  12. package/apps/api/src/app.controller.ts +9 -0
  13. package/apps/api/src/app.module.ts +37 -0
  14. package/apps/api/src/app.service.ts +8 -0
  15. package/apps/api/src/auth/auth.controller.ts +113 -0
  16. package/apps/api/src/auth/auth.module.ts +15 -0
  17. package/apps/api/src/auth/auth.service.ts +309 -0
  18. package/apps/api/src/auth/decorators/current-user-decorator.ts +10 -0
  19. package/apps/api/src/auth/decorators/require-org-role-decorator.ts +7 -0
  20. package/apps/api/src/auth/dto/login.dto.ts +10 -0
  21. package/apps/api/src/auth/dto/register.dto.ts +14 -0
  22. package/apps/api/src/auth/guards/jwt-auth-guard.ts +40 -0
  23. package/apps/api/src/auth/guards/org-role.guards.ts +60 -0
  24. package/apps/api/src/db/db.module.ts +9 -0
  25. package/apps/api/src/db/drizzle.service.ts +16 -0
  26. package/apps/api/src/db/schema/index.ts +6 -0
  27. package/apps/api/src/db/schema/organizations.ts +30 -0
  28. package/apps/api/src/db/schema/projects.ts +26 -0
  29. package/apps/api/src/db/schema/query-history.ts +16 -0
  30. package/apps/api/src/db/schema/storage-buckets.ts +17 -0
  31. package/apps/api/src/db/schema/storage-objects.ts +18 -0
  32. package/apps/api/src/db/schema/users.ts +14 -0
  33. package/apps/api/src/main.ts +51 -0
  34. package/apps/api/src/members/dto/invite-member-dto.ts +6 -0
  35. package/apps/api/src/members/dto/update-role.dto.ts +8 -0
  36. package/apps/api/src/members/invite.service.ts +147 -0
  37. package/apps/api/src/members/members.controller.ts +56 -0
  38. package/apps/api/src/members/members.module.ts +13 -0
  39. package/apps/api/src/members/members.service.ts +85 -0
  40. package/apps/api/src/orgs/dto/create-org.dto.ts +8 -0
  41. package/apps/api/src/orgs/orgs.controller.ts +27 -0
  42. package/apps/api/src/orgs/orgs.module.ts +12 -0
  43. package/apps/api/src/orgs/orgs.service.ts +86 -0
  44. package/apps/api/src/project-api/project-api.controller.ts +95 -0
  45. package/apps/api/src/project-api/project-api.module.ts +12 -0
  46. package/apps/api/src/project-api/project-api.service.ts +196 -0
  47. package/apps/api/src/project-api/project-key.guard.ts +45 -0
  48. package/apps/api/src/project-api/query-parser.ts +129 -0
  49. package/apps/api/src/project-auth/dto/magic-link.dto.ts +7 -0
  50. package/apps/api/src/project-auth/dto/signin.dto.ts +10 -0
  51. package/apps/api/src/project-auth/dto/signup.dto.ts +11 -0
  52. package/apps/api/src/project-auth/project-auth-dashboard.controller.ts +35 -0
  53. package/apps/api/src/project-auth/project-auth.controller.ts +111 -0
  54. package/apps/api/src/project-auth/project-auth.module.ts +13 -0
  55. package/apps/api/src/project-auth/project-auth.service.ts +440 -0
  56. package/apps/api/src/projects/dto/create-project.dto.ts +9 -0
  57. package/apps/api/src/projects/projects.controller.ts +34 -0
  58. package/apps/api/src/projects/projects.module.ts +12 -0
  59. package/apps/api/src/projects/projects.service.ts +136 -0
  60. package/apps/api/src/realtime/realtime-socket.type.ts +14 -0
  61. package/apps/api/src/realtime/realtime.controller.ts +63 -0
  62. package/apps/api/src/realtime/realtime.gateway.ts +150 -0
  63. package/apps/api/src/realtime/realtime.module.ts +14 -0
  64. package/apps/api/src/realtime/realtime.service.ts +101 -0
  65. package/apps/api/src/realtime/trigger.service.ts +95 -0
  66. package/apps/api/src/sql-editor/dto/execute-query.dto.ts +7 -0
  67. package/apps/api/src/sql-editor/sql-editor.controller.ts +28 -0
  68. package/apps/api/src/sql-editor/sql-editor.module.ts +12 -0
  69. package/apps/api/src/sql-editor/sql-editor.service.ts +154 -0
  70. package/apps/api/src/storage/project-storage.controller.ts +140 -0
  71. package/apps/api/src/storage/storage.controller.ts +118 -0
  72. package/apps/api/src/storage/storage.module.ts +15 -0
  73. package/apps/api/src/storage/storage.service.ts +191 -0
  74. package/apps/api/src/storage/uploadthing.ts +23 -0
  75. package/apps/api/src/table-editor/dto/alter-table.dto.ts +15 -0
  76. package/apps/api/src/table-editor/dto/create-table.dto.ts +54 -0
  77. package/apps/api/src/table-editor/table-editor.controller.ts +117 -0
  78. package/apps/api/src/table-editor/table-editor.module.ts +12 -0
  79. package/apps/api/src/table-editor/table-editor.service.ts +366 -0
  80. package/apps/api/test/app.e2e-spec.ts +29 -0
  81. package/apps/api/test/jest-e2e.json +9 -0
  82. package/apps/api/tsconfig.build.json +4 -0
  83. package/apps/api/tsconfig.json +25 -0
  84. package/apps/web/.env.example +12 -0
  85. package/apps/web/AGENTS.md +9 -0
  86. package/apps/web/CLAUDE.md +1 -0
  87. package/apps/web/README.md +36 -0
  88. package/apps/web/components.json +25 -0
  89. package/apps/web/eslint.config.mjs +18 -0
  90. package/apps/web/next.config.ts +11 -0
  91. package/apps/web/package.json +48 -0
  92. package/apps/web/postcss.config.mjs +7 -0
  93. package/apps/web/public/file.svg +1 -0
  94. package/apps/web/public/globe.svg +1 -0
  95. package/apps/web/public/logo.svg +4 -0
  96. package/apps/web/public/next.svg +1 -0
  97. package/apps/web/public/vercel.svg +1 -0
  98. package/apps/web/public/window.svg +1 -0
  99. package/apps/web/src/app/(dashboard)/layout.tsx +33 -0
  100. package/apps/web/src/app/(dashboard)/organizations/(list)/layout.tsx +7 -0
  101. package/apps/web/src/app/(dashboard)/organizations/(list)/new/page.tsx +26 -0
  102. package/apps/web/src/app/(dashboard)/organizations/(list)/page.tsx +44 -0
  103. package/apps/web/src/app/(dashboard)/organizations/[slug]/[projectSlug]/api/page.tsx +13 -0
  104. package/apps/web/src/app/(dashboard)/organizations/[slug]/[projectSlug]/auth/layout.tsx +19 -0
  105. package/apps/web/src/app/(dashboard)/organizations/[slug]/[projectSlug]/auth/page.tsx +10 -0
  106. package/apps/web/src/app/(dashboard)/organizations/[slug]/[projectSlug]/auth/providers/page.tsx +19 -0
  107. package/apps/web/src/app/(dashboard)/organizations/[slug]/[projectSlug]/auth/url-configuration/page.tsx +24 -0
  108. package/apps/web/src/app/(dashboard)/organizations/[slug]/[projectSlug]/auth/users/page.tsx +13 -0
  109. package/apps/web/src/app/(dashboard)/organizations/[slug]/[projectSlug]/database/page.tsx +29 -0
  110. package/apps/web/src/app/(dashboard)/organizations/[slug]/[projectSlug]/realtime/page.tsx +28 -0
  111. package/apps/web/src/app/(dashboard)/organizations/[slug]/[projectSlug]/sql/page.tsx +21 -0
  112. package/apps/web/src/app/(dashboard)/organizations/[slug]/[projectSlug]/storage/page.tsx +28 -0
  113. package/apps/web/src/app/(dashboard)/organizations/[slug]/layout.tsx +20 -0
  114. package/apps/web/src/app/(dashboard)/organizations/[slug]/projects/page.tsx +62 -0
  115. package/apps/web/src/app/(dashboard)/organizations/[slug]/settings/members/page.tsx +28 -0
  116. package/apps/web/src/app/(dashboard)/organizations/[slug]/settings/page.tsx +10 -0
  117. package/apps/web/src/app/(dashboard)/settings/page.tsx +12 -0
  118. package/apps/web/src/app/dashboard/page.tsx +14 -0
  119. package/apps/web/src/app/favicon.ico +0 -0
  120. package/apps/web/src/app/globals.css +115 -0
  121. package/apps/web/src/app/layout.tsx +36 -0
  122. package/apps/web/src/app/login/page.tsx +199 -0
  123. package/apps/web/src/app/page.tsx +100 -0
  124. package/apps/web/src/app/register/page.tsx +218 -0
  125. package/apps/web/src/components/app-sidebar.tsx +301 -0
  126. package/apps/web/src/components/navbar.tsx +63 -0
  127. package/apps/web/src/components/topNav.tsx +68 -0
  128. package/apps/web/src/components/ui/avatar.tsx +112 -0
  129. package/apps/web/src/components/ui/badge.tsx +48 -0
  130. package/apps/web/src/components/ui/button.tsx +66 -0
  131. package/apps/web/src/components/ui/card.tsx +102 -0
  132. package/apps/web/src/components/ui/checkbox.tsx +32 -0
  133. package/apps/web/src/components/ui/dialog.tsx +168 -0
  134. package/apps/web/src/components/ui/dropdown-menu.tsx +269 -0
  135. package/apps/web/src/components/ui/field.tsx +238 -0
  136. package/apps/web/src/components/ui/input.tsx +19 -0
  137. package/apps/web/src/components/ui/label.tsx +24 -0
  138. package/apps/web/src/components/ui/resizable.tsx +50 -0
  139. package/apps/web/src/components/ui/scroll-area.tsx +55 -0
  140. package/apps/web/src/components/ui/select.tsx +192 -0
  141. package/apps/web/src/components/ui/separator.tsx +28 -0
  142. package/apps/web/src/components/ui/sheet.tsx +147 -0
  143. package/apps/web/src/components/ui/sidebar.tsx +703 -0
  144. package/apps/web/src/components/ui/skeleton.tsx +13 -0
  145. package/apps/web/src/components/ui/switch.tsx +33 -0
  146. package/apps/web/src/components/ui/table.tsx +116 -0
  147. package/apps/web/src/components/ui/tooltip.tsx +57 -0
  148. package/apps/web/src/features/api-docs/api-docs-client.tsx +227 -0
  149. package/apps/web/src/features/api-docs/api-docs-helpers.server.ts +86 -0
  150. package/apps/web/src/features/auth/action.ts +67 -0
  151. package/apps/web/src/features/auth/client.schema.ts +13 -0
  152. package/apps/web/src/features/auth/constants.ts +6 -0
  153. package/apps/web/src/features/auth/cookies.ts +86 -0
  154. package/apps/web/src/features/auth/server.schema.ts +11 -0
  155. package/apps/web/src/features/auth/sign-out.ts +17 -0
  156. package/apps/web/src/features/members/action.ts +66 -0
  157. package/apps/web/src/features/members/client.schema.ts +11 -0
  158. package/apps/web/src/features/members/constants.ts +8 -0
  159. package/apps/web/src/features/members/members-client.tsx +198 -0
  160. package/apps/web/src/features/members/members-helpers.server.ts +21 -0
  161. package/apps/web/src/features/members/server.schema.ts +19 -0
  162. package/apps/web/src/features/organization/action.ts +45 -0
  163. package/apps/web/src/features/organization/client.schema.ts +5 -0
  164. package/apps/web/src/features/organization/constants.tsx +3 -0
  165. package/apps/web/src/features/organization/create-org-form.tsx +66 -0
  166. package/apps/web/src/features/organization/organization-helpers.server.ts +35 -0
  167. package/apps/web/src/features/organization/server.schema.ts +10 -0
  168. package/apps/web/src/features/project-auth/project-auth-action.ts +78 -0
  169. package/apps/web/src/features/project-auth/project-auth-client.schema.ts +18 -0
  170. package/apps/web/src/features/project-auth/project-auth-constants.ts +8 -0
  171. package/apps/web/src/features/project-auth/project-auth-helpers.server.ts +39 -0
  172. package/apps/web/src/features/project-auth/project-auth-providers.tsx +222 -0
  173. package/apps/web/src/features/project-auth/project-auth-server.schema.ts +22 -0
  174. package/apps/web/src/features/project-auth/project-auth-shell.tsx +106 -0
  175. package/apps/web/src/features/project-auth/project-auth-url-config.tsx +151 -0
  176. package/apps/web/src/features/project-auth/project-auth-users.tsx +138 -0
  177. package/apps/web/src/features/projects/action.ts +46 -0
  178. package/apps/web/src/features/projects/client.schema.ts +9 -0
  179. package/apps/web/src/features/projects/constants.ts +6 -0
  180. package/apps/web/src/features/projects/create-project-modal.tsx +117 -0
  181. package/apps/web/src/features/projects/project-helpers.server.ts +38 -0
  182. package/apps/web/src/features/projects/server.schema.ts +10 -0
  183. package/apps/web/src/features/realtime/realtime-client.tsx +294 -0
  184. package/apps/web/src/features/realtime/realtime-helpers.server.ts +40 -0
  185. package/apps/web/src/features/sql-editor/sql-editor-client.tsx +324 -0
  186. package/apps/web/src/features/sql-editor/sql-editor-helpers.server.ts +22 -0
  187. package/apps/web/src/features/storage/storage-client.tsx +500 -0
  188. package/apps/web/src/features/storage/storage-helpers.server.ts +36 -0
  189. package/apps/web/src/features/table-editor/action.ts +97 -0
  190. package/apps/web/src/features/table-editor/add-column-dialog.tsx +184 -0
  191. package/apps/web/src/features/table-editor/client.schema.ts +36 -0
  192. package/apps/web/src/features/table-editor/create-table-drawer.tsx +542 -0
  193. package/apps/web/src/features/table-editor/server.schema.ts +41 -0
  194. package/apps/web/src/features/table-editor/table-editor-client.tsx +737 -0
  195. package/apps/web/src/features/table-editor/table-editor-helpers.server.ts +39 -0
  196. package/apps/web/src/hooks/use-mobile.ts +19 -0
  197. package/apps/web/src/lib/axios.ts +8 -0
  198. package/apps/web/src/lib/utils.ts +6 -0
  199. package/apps/web/src/proxy.ts +72 -0
  200. package/apps/web/src/server-utils/utils.ts +10 -0
  201. package/apps/web/tsconfig.json +34 -0
  202. package/package.json +22 -0
  203. package/packages/apiDatabase-js/package.json +39 -0
  204. package/packages/apiDatabase-js/src/auth/index.ts +121 -0
  205. package/packages/apiDatabase-js/src/client.ts +25 -0
  206. package/packages/apiDatabase-js/src/db/index.ts +15 -0
  207. package/packages/apiDatabase-js/src/db/query-builder.ts +194 -0
  208. package/packages/apiDatabase-js/src/index.ts +16 -0
  209. package/packages/apiDatabase-js/src/realtime/index.ts +84 -0
  210. package/packages/apiDatabase-js/src/storage/index.ts +130 -0
  211. package/packages/apiDatabase-js/tsconfig.json +13 -0
  212. package/packages/apiDatabase-js/tsdown.config.ts +20 -0
  213. package/packages/constants/package.json +6 -0
  214. package/packages/constants/src/index.ts +76 -0
  215. package/packages/tsconfig.json +13 -0
  216. package/packages/tsdown.config.ts +20 -0
  217. package/packages/types/package.json +6 -0
  218. package/packages/types/src/index.ts +254 -0
  219. package/pnpm-workspace.yaml +10 -0
@@ -0,0 +1,703 @@
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+ import { cva, type VariantProps } from "class-variance-authority";
5
+ import { Slot } from "radix-ui";
6
+
7
+ import { useIsMobile } from "@/hooks/use-mobile";
8
+ import { cn } from "@/lib/utils";
9
+ import { Button } from "@/components/ui/button";
10
+ import { Input } from "@/components/ui/input";
11
+ import { Separator } from "@/components/ui/separator";
12
+ import {
13
+ Sheet,
14
+ SheetContent,
15
+ SheetDescription,
16
+ SheetHeader,
17
+ SheetTitle,
18
+ } from "@/components/ui/sheet";
19
+ import { Skeleton } from "@/components/ui/skeleton";
20
+ import {
21
+ Tooltip,
22
+ TooltipContent,
23
+ TooltipTrigger,
24
+ } from "@/components/ui/tooltip";
25
+ import { PanelLeftIcon } from "lucide-react";
26
+
27
+ const SIDEBAR_COOKIE_NAME = "sidebar_state";
28
+ const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
29
+ const SIDEBAR_WIDTH = "16rem";
30
+ const SIDEBAR_WIDTH_MOBILE = "18rem";
31
+ const SIDEBAR_WIDTH_ICON = "3rem";
32
+ const SIDEBAR_KEYBOARD_SHORTCUT = "b";
33
+
34
+ type SidebarContextProps = {
35
+ state: "expanded" | "collapsed";
36
+ open: boolean;
37
+ setOpen: (open: boolean) => void;
38
+ openMobile: boolean;
39
+ setOpenMobile: (open: boolean) => void;
40
+ isMobile: boolean;
41
+ toggleSidebar: () => void;
42
+ };
43
+
44
+ const SidebarContext = React.createContext<SidebarContextProps | null>(null);
45
+
46
+ function useSidebar() {
47
+ const context = React.useContext(SidebarContext);
48
+ if (!context) {
49
+ throw new Error("useSidebar must be used within a SidebarProvider.");
50
+ }
51
+
52
+ return context;
53
+ }
54
+
55
+ function SidebarProvider({
56
+ defaultOpen = true,
57
+ open: openProp,
58
+ onOpenChange: setOpenProp,
59
+ className,
60
+ style,
61
+ children,
62
+ ...props
63
+ }: React.ComponentProps<"div"> & {
64
+ defaultOpen?: boolean;
65
+ open?: boolean;
66
+ onOpenChange?: (open: boolean) => void;
67
+ }) {
68
+ const isMobile = useIsMobile();
69
+ const [openMobile, setOpenMobile] = React.useState(false);
70
+
71
+ // This is the internal state of the sidebar.
72
+ // We use openProp and setOpenProp for control from outside the component.
73
+ const [_open, _setOpen] = React.useState(defaultOpen);
74
+ const open = openProp ?? _open;
75
+ const setOpen = React.useCallback(
76
+ (value: boolean | ((value: boolean) => boolean)) => {
77
+ const openState = typeof value === "function" ? value(open) : value;
78
+ if (setOpenProp) {
79
+ setOpenProp(openState);
80
+ } else {
81
+ _setOpen(openState);
82
+ }
83
+
84
+ // This sets the cookie to keep the sidebar state.
85
+ document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`;
86
+ },
87
+ [setOpenProp, open],
88
+ );
89
+
90
+ // Helper to toggle the sidebar.
91
+ const toggleSidebar = React.useCallback(() => {
92
+ return isMobile ? setOpenMobile((open) => !open) : setOpen((open) => !open);
93
+ }, [isMobile, setOpen, setOpenMobile]);
94
+
95
+ // Adds a keyboard shortcut to toggle the sidebar.
96
+ React.useEffect(() => {
97
+ const handleKeyDown = (event: KeyboardEvent) => {
98
+ if (
99
+ event.key === SIDEBAR_KEYBOARD_SHORTCUT &&
100
+ (event.metaKey || event.ctrlKey)
101
+ ) {
102
+ event.preventDefault();
103
+ toggleSidebar();
104
+ }
105
+ };
106
+
107
+ window.addEventListener("keydown", handleKeyDown);
108
+ return () => window.removeEventListener("keydown", handleKeyDown);
109
+ }, [toggleSidebar]);
110
+
111
+ // We add a state so that we can do data-state="expanded" or "collapsed".
112
+ // This makes it easier to style the sidebar with Tailwind classes.
113
+ const state = open ? "expanded" : "collapsed";
114
+
115
+ const contextValue = React.useMemo<SidebarContextProps>(
116
+ () => ({
117
+ state,
118
+ open,
119
+ setOpen,
120
+ isMobile,
121
+ openMobile,
122
+ setOpenMobile,
123
+ toggleSidebar,
124
+ }),
125
+ [state, open, setOpen, isMobile, openMobile, setOpenMobile, toggleSidebar],
126
+ );
127
+
128
+ return (
129
+ <SidebarContext.Provider value={contextValue}>
130
+ <div
131
+ data-slot="sidebar-wrapper"
132
+ style={
133
+ {
134
+ "--sidebar-width": SIDEBAR_WIDTH,
135
+ "--sidebar-width-icon": SIDEBAR_WIDTH_ICON,
136
+ ...style,
137
+ } as React.CSSProperties
138
+ }
139
+ className={cn(
140
+ "group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar",
141
+ className,
142
+ )}
143
+ {...props}
144
+ >
145
+ {children}
146
+ </div>
147
+ </SidebarContext.Provider>
148
+ );
149
+ }
150
+
151
+ function Sidebar({
152
+ side = "left",
153
+ variant = "sidebar",
154
+ collapsible = "offcanvas",
155
+ className,
156
+ children,
157
+ dir,
158
+ ...props
159
+ }: React.ComponentProps<"div"> & {
160
+ side?: "left" | "right";
161
+ variant?: "sidebar" | "floating" | "inset";
162
+ collapsible?: "offcanvas" | "icon" | "none";
163
+ }) {
164
+ const { isMobile, state, openMobile, setOpenMobile } = useSidebar();
165
+
166
+ if (collapsible === "none") {
167
+ return (
168
+ <div
169
+ data-slot="sidebar"
170
+ className={cn(
171
+ "flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground",
172
+ className,
173
+ )}
174
+ {...props}
175
+ >
176
+ {children}
177
+ </div>
178
+ );
179
+ }
180
+
181
+ if (isMobile) {
182
+ return (
183
+ <Sheet open={openMobile} onOpenChange={setOpenMobile} {...props}>
184
+ <SheetContent
185
+ dir={dir}
186
+ data-sidebar="sidebar"
187
+ data-slot="sidebar"
188
+ data-mobile="true"
189
+ className="w-(--sidebar-width) bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden"
190
+ style={
191
+ {
192
+ "--sidebar-width": SIDEBAR_WIDTH_MOBILE,
193
+ } as React.CSSProperties
194
+ }
195
+ side={side}
196
+ >
197
+ <SheetHeader className="sr-only">
198
+ <SheetTitle>Sidebar</SheetTitle>
199
+ <SheetDescription>Displays the mobile sidebar.</SheetDescription>
200
+ </SheetHeader>
201
+ <div className="flex h-full w-full flex-col">{children}</div>
202
+ </SheetContent>
203
+ </Sheet>
204
+ );
205
+ }
206
+
207
+ return (
208
+ <div
209
+ className="group peer hidden text-sidebar-foreground md:block"
210
+ data-state={state}
211
+ data-collapsible={state === "collapsed" ? collapsible : ""}
212
+ data-variant={variant}
213
+ data-side={side}
214
+ data-slot="sidebar"
215
+ >
216
+ {/* This is what handles the sidebar gap on desktop */}
217
+ <div
218
+ data-slot="sidebar-gap"
219
+ className={cn(
220
+ "relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear",
221
+ "group-data-[collapsible=offcanvas]:w-0",
222
+ "group-data-[side=right]:rotate-180",
223
+ variant === "floating" || variant === "inset"
224
+ ? "group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]"
225
+ : "group-data-[collapsible=icon]:w-(--sidebar-width-icon)",
226
+ )}
227
+ />
228
+ <div
229
+ data-slot="sidebar-container"
230
+ data-side={side}
231
+ className={cn(
232
+ "fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear data-[side=left]:left-0 data-[side=left]:group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)] data-[side=right]:right-0 data-[side=right]:group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)] md:flex",
233
+ // Adjust the padding for floating and inset variants.
234
+ variant === "floating" || variant === "inset"
235
+ ? "p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]"
236
+ : "group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l",
237
+ className,
238
+ )}
239
+ {...props}
240
+ >
241
+ <div
242
+ data-sidebar="sidebar"
243
+ data-slot="sidebar-inner"
244
+ className="flex size-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:shadow-sm group-data-[variant=floating]:ring-1 group-data-[variant=floating]:ring-sidebar-border"
245
+ >
246
+ {children}
247
+ </div>
248
+ </div>
249
+ </div>
250
+ );
251
+ }
252
+
253
+ function SidebarTrigger({
254
+ className,
255
+ onClick,
256
+ ...props
257
+ }: React.ComponentProps<typeof Button>) {
258
+ const { toggleSidebar } = useSidebar();
259
+
260
+ return (
261
+ <Button
262
+ data-sidebar="trigger"
263
+ data-slot="sidebar-trigger"
264
+ variant="ghost"
265
+ size="icon-sm"
266
+ className={cn(className)}
267
+ onClick={(event) => {
268
+ onClick?.(event);
269
+ toggleSidebar();
270
+ }}
271
+ {...props}
272
+ >
273
+ <PanelLeftIcon />
274
+ <span className="sr-only">Toggle Sidebar</span>
275
+ </Button>
276
+ );
277
+ }
278
+
279
+ function SidebarRail({ className, ...props }: React.ComponentProps<"button">) {
280
+ const { toggleSidebar } = useSidebar();
281
+
282
+ return (
283
+ <button
284
+ data-sidebar="rail"
285
+ data-slot="sidebar-rail"
286
+ aria-label="Toggle Sidebar"
287
+ tabIndex={-1}
288
+ onClick={toggleSidebar}
289
+ title="Toggle Sidebar"
290
+ className={cn(
291
+ "absolute inset-y-0 z-20 hidden w-4 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:start-1/2 after:w-[2px] hover:after:bg-sidebar-border sm:flex ltr:-translate-x-1/2 rtl:-translate-x-1/2",
292
+ "in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize",
293
+ "[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize",
294
+ "group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full hover:group-data-[collapsible=offcanvas]:bg-sidebar",
295
+ "[[data-side=left][data-collapsible=offcanvas]_&]:-right-2",
296
+ "[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",
297
+ className,
298
+ )}
299
+ {...props}
300
+ />
301
+ );
302
+ }
303
+
304
+ function SidebarInset({ className, ...props }: React.ComponentProps<"main">) {
305
+ return (
306
+ <main
307
+ data-slot="sidebar-inset"
308
+ className={cn(
309
+ "relative flex w-full flex-1 flex-col bg-background md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2",
310
+ className,
311
+ )}
312
+ {...props}
313
+ />
314
+ );
315
+ }
316
+
317
+ function SidebarInput({
318
+ className,
319
+ ...props
320
+ }: React.ComponentProps<typeof Input>) {
321
+ return (
322
+ <Input
323
+ data-slot="sidebar-input"
324
+ data-sidebar="input"
325
+ className={cn("h-8 w-full bg-background shadow-none", className)}
326
+ {...props}
327
+ />
328
+ );
329
+ }
330
+
331
+ function SidebarHeader({ className, ...props }: React.ComponentProps<"div">) {
332
+ return (
333
+ <div
334
+ data-slot="sidebar-header"
335
+ data-sidebar="header"
336
+ className={cn("flex flex-col gap-2 p-2", className)}
337
+ {...props}
338
+ />
339
+ );
340
+ }
341
+
342
+ function SidebarFooter({ className, ...props }: React.ComponentProps<"div">) {
343
+ return (
344
+ <div
345
+ data-slot="sidebar-footer"
346
+ data-sidebar="footer"
347
+ className={cn("flex flex-col gap-2 p-2", className)}
348
+ {...props}
349
+ />
350
+ );
351
+ }
352
+
353
+ function SidebarSeparator({
354
+ className,
355
+ ...props
356
+ }: React.ComponentProps<typeof Separator>) {
357
+ return (
358
+ <Separator
359
+ data-slot="sidebar-separator"
360
+ data-sidebar="separator"
361
+ className={cn("mx-2 w-auto bg-sidebar-border", className)}
362
+ {...props}
363
+ />
364
+ );
365
+ }
366
+
367
+ function SidebarContent({ className, ...props }: React.ComponentProps<"div">) {
368
+ return (
369
+ <div
370
+ data-slot="sidebar-content"
371
+ data-sidebar="content"
372
+ className={cn(
373
+ "no-scrollbar flex min-h-0 flex-1 flex-col gap-0 overflow-auto group-data-[collapsible=icon]:overflow-hidden",
374
+ className,
375
+ )}
376
+ {...props}
377
+ />
378
+ );
379
+ }
380
+
381
+ function SidebarGroup({ className, ...props }: React.ComponentProps<"div">) {
382
+ return (
383
+ <div
384
+ data-slot="sidebar-group"
385
+ data-sidebar="group"
386
+ className={cn("relative flex w-full min-w-0 flex-col p-2", className)}
387
+ {...props}
388
+ />
389
+ );
390
+ }
391
+
392
+ function SidebarGroupLabel({
393
+ className,
394
+ asChild = false,
395
+ ...props
396
+ }: React.ComponentProps<"div"> & { asChild?: boolean }) {
397
+ const Comp = asChild ? Slot.Root : "div";
398
+
399
+ return (
400
+ <Comp
401
+ data-slot="sidebar-group-label"
402
+ data-sidebar="group-label"
403
+ className={cn(
404
+ "flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 ring-sidebar-ring outline-hidden transition-[margin,opacity] duration-200 ease-linear group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0 focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",
405
+ className,
406
+ )}
407
+ {...props}
408
+ />
409
+ );
410
+ }
411
+
412
+ function SidebarGroupAction({
413
+ className,
414
+ asChild = false,
415
+ ...props
416
+ }: React.ComponentProps<"button"> & { asChild?: boolean }) {
417
+ const Comp = asChild ? Slot.Root : "button";
418
+
419
+ return (
420
+ <Comp
421
+ data-slot="sidebar-group-action"
422
+ data-sidebar="group-action"
423
+ className={cn(
424
+ "absolute top-3.5 right-3 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform group-data-[collapsible=icon]:hidden after:absolute after:-inset-2 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 md:after:hidden [&>svg]:size-4 [&>svg]:shrink-0",
425
+ className,
426
+ )}
427
+ {...props}
428
+ />
429
+ );
430
+ }
431
+
432
+ function SidebarGroupContent({
433
+ className,
434
+ ...props
435
+ }: React.ComponentProps<"div">) {
436
+ return (
437
+ <div
438
+ data-slot="sidebar-group-content"
439
+ data-sidebar="group-content"
440
+ className={cn("w-full text-sm", className)}
441
+ {...props}
442
+ />
443
+ );
444
+ }
445
+
446
+ function SidebarMenu({ className, ...props }: React.ComponentProps<"ul">) {
447
+ return (
448
+ <ul
449
+ data-slot="sidebar-menu"
450
+ data-sidebar="menu"
451
+ className={cn("flex w-full min-w-0 flex-col gap-0", className)}
452
+ {...props}
453
+ />
454
+ );
455
+ }
456
+
457
+ function SidebarMenuItem({ className, ...props }: React.ComponentProps<"li">) {
458
+ return (
459
+ <li
460
+ data-slot="sidebar-menu-item"
461
+ data-sidebar="menu-item"
462
+ className={cn("group/menu-item relative", className)}
463
+ {...props}
464
+ />
465
+ );
466
+ }
467
+
468
+ const sidebarMenuButtonVariants = cva(
469
+ "peer/menu-button group/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm ring-sidebar-ring outline-hidden transition-[width,height,padding] group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-open:hover:bg-sidebar-accent data-open:hover:text-sidebar-accent-foreground data-active:bg-sidebar-accent data-active:font-medium data-active:text-sidebar-accent-foreground [&_svg]:size-4 [&_svg]:shrink-0 [&>span:last-child]:truncate",
470
+ {
471
+ variants: {
472
+ variant: {
473
+ default: "hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",
474
+ outline:
475
+ "bg-background shadow-[0_0_0_1px_var(--sidebar-border)] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_var(--sidebar-accent)]",
476
+ },
477
+ size: {
478
+ default: "h-8 text-sm",
479
+ sm: "h-7 text-xs",
480
+ lg: "h-12 text-sm group-data-[collapsible=icon]:p-0!",
481
+ },
482
+ },
483
+ defaultVariants: {
484
+ variant: "default",
485
+ size: "default",
486
+ },
487
+ },
488
+ );
489
+
490
+ function SidebarMenuButton({
491
+ asChild = false,
492
+ isActive = false,
493
+ variant = "default",
494
+ size = "default",
495
+ tooltip,
496
+ className,
497
+ ...props
498
+ }: React.ComponentProps<"button"> & {
499
+ asChild?: boolean;
500
+ isActive?: boolean;
501
+ tooltip?: string | React.ComponentProps<typeof TooltipContent>;
502
+ } & VariantProps<typeof sidebarMenuButtonVariants>) {
503
+ const Comp = asChild ? Slot.Root : "button";
504
+ const { isMobile, state } = useSidebar();
505
+
506
+ const button = (
507
+ <Comp
508
+ data-slot="sidebar-menu-button"
509
+ data-sidebar="menu-button"
510
+ data-size={size}
511
+ // data-active={isActive? }
512
+ {...(isActive ? { "data-active": true } : {})}
513
+ className={cn(sidebarMenuButtonVariants({ variant, size }), className)}
514
+ {...props}
515
+ />
516
+ );
517
+
518
+ if (!tooltip) {
519
+ return button;
520
+ }
521
+
522
+ if (typeof tooltip === "string") {
523
+ tooltip = {
524
+ children: tooltip,
525
+ };
526
+ }
527
+
528
+ return (
529
+ <Tooltip>
530
+ <TooltipTrigger asChild>{button}</TooltipTrigger>
531
+ <TooltipContent
532
+ side="right"
533
+ align="center"
534
+ hidden={state !== "collapsed" || isMobile}
535
+ {...tooltip}
536
+ />
537
+ </Tooltip>
538
+ );
539
+ }
540
+
541
+ function SidebarMenuAction({
542
+ className,
543
+ asChild = false,
544
+ showOnHover = false,
545
+ ...props
546
+ }: React.ComponentProps<"button"> & {
547
+ asChild?: boolean;
548
+ showOnHover?: boolean;
549
+ }) {
550
+ const Comp = asChild ? Slot.Root : "button";
551
+
552
+ return (
553
+ <Comp
554
+ data-slot="sidebar-menu-action"
555
+ data-sidebar="menu-action"
556
+ className={cn(
557
+ "absolute top-1.5 right-1 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform group-data-[collapsible=icon]:hidden peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[size=default]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5 peer-data-[size=sm]/menu-button:top-1 after:absolute after:-inset-2 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 md:after:hidden [&>svg]:size-4 [&>svg]:shrink-0",
558
+ showOnHover &&
559
+ "group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 peer-data-active/menu-button:text-sidebar-accent-foreground aria-expanded:opacity-100 md:opacity-0",
560
+ className,
561
+ )}
562
+ {...props}
563
+ />
564
+ );
565
+ }
566
+
567
+ function SidebarMenuBadge({
568
+ className,
569
+ ...props
570
+ }: React.ComponentProps<"div">) {
571
+ return (
572
+ <div
573
+ data-slot="sidebar-menu-badge"
574
+ data-sidebar="menu-badge"
575
+ className={cn(
576
+ "pointer-events-none absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium text-sidebar-foreground tabular-nums select-none group-data-[collapsible=icon]:hidden peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[size=default]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5 peer-data-[size=sm]/menu-button:top-1 peer-data-active/menu-button:text-sidebar-accent-foreground",
577
+ className,
578
+ )}
579
+ {...props}
580
+ />
581
+ );
582
+ }
583
+
584
+ function SidebarMenuSkeleton({
585
+ className,
586
+ showIcon = false,
587
+ ...props
588
+ }: React.ComponentProps<"div"> & {
589
+ showIcon?: boolean;
590
+ }) {
591
+ // Random width between 50 to 90%.
592
+ const [width] = React.useState(() => {
593
+ return `${Math.floor(Math.random() * 40) + 50}%`;
594
+ });
595
+
596
+ return (
597
+ <div
598
+ data-slot="sidebar-menu-skeleton"
599
+ data-sidebar="menu-skeleton"
600
+ className={cn("flex h-8 items-center gap-2 rounded-md px-2", className)}
601
+ {...props}
602
+ >
603
+ {showIcon && (
604
+ <Skeleton
605
+ className="size-4 rounded-md"
606
+ data-sidebar="menu-skeleton-icon"
607
+ />
608
+ )}
609
+ <Skeleton
610
+ className="h-4 max-w-(--skeleton-width) flex-1"
611
+ data-sidebar="menu-skeleton-text"
612
+ style={
613
+ {
614
+ "--skeleton-width": width,
615
+ } as React.CSSProperties
616
+ }
617
+ />
618
+ </div>
619
+ );
620
+ }
621
+
622
+ function SidebarMenuSub({ className, ...props }: React.ComponentProps<"ul">) {
623
+ return (
624
+ <ul
625
+ data-slot="sidebar-menu-sub"
626
+ data-sidebar="menu-sub"
627
+ className={cn(
628
+ "mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5 group-data-[collapsible=icon]:hidden",
629
+ className,
630
+ )}
631
+ {...props}
632
+ />
633
+ );
634
+ }
635
+
636
+ function SidebarMenuSubItem({
637
+ className,
638
+ ...props
639
+ }: React.ComponentProps<"li">) {
640
+ return (
641
+ <li
642
+ data-slot="sidebar-menu-sub-item"
643
+ data-sidebar="menu-sub-item"
644
+ className={cn("group/menu-sub-item relative", className)}
645
+ {...props}
646
+ />
647
+ );
648
+ }
649
+
650
+ function SidebarMenuSubButton({
651
+ asChild = false,
652
+ size = "md",
653
+ isActive = false,
654
+ className,
655
+ ...props
656
+ }: React.ComponentProps<"a"> & {
657
+ asChild?: boolean;
658
+ size?: "sm" | "md";
659
+ isActive?: boolean;
660
+ }) {
661
+ const Comp = asChild ? Slot.Root : "a";
662
+
663
+ return (
664
+ <Comp
665
+ data-slot="sidebar-menu-sub-button"
666
+ data-sidebar="menu-sub-button"
667
+ data-size={size}
668
+ data-active={isActive}
669
+ className={cn(
670
+ "flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground ring-sidebar-ring outline-hidden group-data-[collapsible=icon]:hidden hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[size=md]:text-sm data-[size=sm]:text-xs data-active:bg-sidebar-accent data-active:text-sidebar-accent-foreground [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground",
671
+ className,
672
+ )}
673
+ {...props}
674
+ />
675
+ );
676
+ }
677
+
678
+ export {
679
+ Sidebar,
680
+ SidebarContent,
681
+ SidebarFooter,
682
+ SidebarGroup,
683
+ SidebarGroupAction,
684
+ SidebarGroupContent,
685
+ SidebarGroupLabel,
686
+ SidebarHeader,
687
+ SidebarInput,
688
+ SidebarInset,
689
+ SidebarMenu,
690
+ SidebarMenuAction,
691
+ SidebarMenuBadge,
692
+ SidebarMenuButton,
693
+ SidebarMenuItem,
694
+ SidebarMenuSkeleton,
695
+ SidebarMenuSub,
696
+ SidebarMenuSubButton,
697
+ SidebarMenuSubItem,
698
+ SidebarProvider,
699
+ SidebarRail,
700
+ SidebarSeparator,
701
+ SidebarTrigger,
702
+ useSidebar,
703
+ };
@@ -0,0 +1,13 @@
1
+ import { cn } from "@/lib/utils"
2
+
3
+ function Skeleton({ className, ...props }: React.ComponentProps<"div">) {
4
+ return (
5
+ <div
6
+ data-slot="skeleton"
7
+ className={cn("animate-pulse rounded-md bg-muted", className)}
8
+ {...props}
9
+ />
10
+ )
11
+ }
12
+
13
+ export { Skeleton }