@manago/admin 0.1.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.
package/dist/index.mjs ADDED
@@ -0,0 +1,1465 @@
1
+ import { create } from 'zustand';
2
+ import { persist } from 'zustand/middleware';
3
+ import * as React9 from 'react';
4
+ import { createContext, useContext, useState, useEffect, useMemo } from 'react';
5
+ import { QueryClient, useQuery, QueryClientProvider } from '@tanstack/react-query';
6
+ import { jsx, jsxs } from 'react/jsx-runtime';
7
+ import { createRootRoute, Outlet, createRoute, useRouterState, Link, createBrowserHistory, createRouter, RouterProvider } from '@tanstack/react-router';
8
+ import { Slot } from '@radix-ui/react-slot';
9
+ import { cva } from 'class-variance-authority';
10
+ import { clsx } from 'clsx';
11
+ import { twMerge } from 'tailwind-merge';
12
+ import * as LabelPrimitive from '@radix-ui/react-label';
13
+ import { X, PanelLeft, ChevronRight, Check, Circle, Package, ShoppingCart, Users, DollarSign, LayoutDashboard, CreditCard, UserCog, Settings } from 'lucide-react';
14
+ import * as SeparatorPrimitive from '@radix-ui/react-separator';
15
+ import * as SheetPrimitive from '@radix-ui/react-dialog';
16
+ import * as TooltipPrimitive from '@radix-ui/react-tooltip';
17
+ import * as AvatarPrimitive from '@radix-ui/react-avatar';
18
+ import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
19
+
20
+ var __defProp = Object.defineProperty;
21
+ var __getOwnPropNames = Object.getOwnPropertyNames;
22
+ var __esm = (fn, res) => function __init() {
23
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
24
+ };
25
+ var __export = (target, all) => {
26
+ for (var name in all)
27
+ __defProp(target, name, { get: all[name], enumerable: true });
28
+ };
29
+
30
+ // src/lib/stores/auth-store.ts
31
+ var auth_store_exports = {};
32
+ __export(auth_store_exports, {
33
+ useAuthStore: () => useAuthStore,
34
+ useHasHydrated: () => useHasHydrated
35
+ });
36
+ var useAuthStore, useHasHydrated;
37
+ var init_auth_store = __esm({
38
+ "src/lib/stores/auth-store.ts"() {
39
+ "use client";
40
+ useAuthStore = create()(
41
+ persist(
42
+ (set) => ({
43
+ user: null,
44
+ token: null,
45
+ isAuthenticated: false,
46
+ login: (user, token) => set({ user, token, isAuthenticated: true }),
47
+ logout: () => set({ user: null, token: null, isAuthenticated: false })
48
+ }),
49
+ {
50
+ name: "manago-auth",
51
+ skipHydration: true
52
+ }
53
+ )
54
+ );
55
+ useHasHydrated = () => {
56
+ const [hasHydrated, setHasHydrated] = useState(false);
57
+ useEffect(() => {
58
+ useAuthStore.persist.rehydrate();
59
+ setHasHydrated(true);
60
+ }, []);
61
+ return hasHydrated;
62
+ };
63
+ }
64
+ });
65
+
66
+ // src/lib/api-client.ts
67
+ var ManagoAPIClient = class {
68
+ constructor(config) {
69
+ this.apiKey = config.apiKey;
70
+ this.baseURL = config.baseURL || "http://localhost:3001/api";
71
+ }
72
+ async request(endpoint, options) {
73
+ let token = null;
74
+ if (typeof window !== "undefined") {
75
+ try {
76
+ const { useAuthStore: useAuthStore2 } = await Promise.resolve().then(() => (init_auth_store(), auth_store_exports));
77
+ token = useAuthStore2.getState().token;
78
+ } catch (e) {
79
+ }
80
+ }
81
+ const headers = {
82
+ "Content-Type": "application/json",
83
+ "x-api-key": this.apiKey,
84
+ ...token && { Authorization: `Bearer ${token}` },
85
+ ...options?.headers
86
+ };
87
+ const response = await fetch(`${this.baseURL}${endpoint}`, {
88
+ ...options,
89
+ headers
90
+ });
91
+ if (!response.ok) {
92
+ const error = await response.json().catch(() => ({}));
93
+ throw new Error(error.message || `API Error: ${response.statusText}`);
94
+ }
95
+ return response.json();
96
+ }
97
+ // Auth
98
+ async login(email, password) {
99
+ return this.request("/auth/login", {
100
+ method: "POST",
101
+ body: JSON.stringify({ email, password })
102
+ });
103
+ }
104
+ // Products
105
+ async getProducts(params) {
106
+ const query = new URLSearchParams(params).toString();
107
+ return this.request(`/products${query ? `?${query}` : ""}`);
108
+ }
109
+ async getProduct(id) {
110
+ return this.request(`/products/${id}`);
111
+ }
112
+ async createProduct(data) {
113
+ return this.request("/products", {
114
+ method: "POST",
115
+ body: JSON.stringify(data)
116
+ });
117
+ }
118
+ async updateProduct(id, data) {
119
+ return this.request(`/products/${id}`, {
120
+ method: "PUT",
121
+ body: JSON.stringify(data)
122
+ });
123
+ }
124
+ async deleteProduct(id) {
125
+ return this.request(`/products/${id}`, {
126
+ method: "DELETE"
127
+ });
128
+ }
129
+ // Orders
130
+ async getOrders(params) {
131
+ const query = new URLSearchParams(params).toString();
132
+ return this.request(`/orders${query ? `?${query}` : ""}`);
133
+ }
134
+ // Customers
135
+ async getCustomers(params) {
136
+ const query = new URLSearchParams(params).toString();
137
+ return this.request(`/customers${query ? `?${query}` : ""}`);
138
+ }
139
+ // Settings
140
+ async getSettings() {
141
+ return this.request("/settings");
142
+ }
143
+ async updateSettings(data) {
144
+ return this.request("/settings", {
145
+ method: "PUT",
146
+ body: JSON.stringify(data)
147
+ });
148
+ }
149
+ };
150
+
151
+ // src/lib/default-config.ts
152
+ var defaultConfig = {
153
+ appName: "Manago",
154
+ menu: {
155
+ dashboard: true,
156
+ products: true,
157
+ orders: true,
158
+ customers: true,
159
+ payments: true,
160
+ users: true,
161
+ settings: true
162
+ },
163
+ features: {
164
+ multiUser: true,
165
+ analytics: true,
166
+ exports: true
167
+ },
168
+ theme: {
169
+ primaryColor: "#3B82F6",
170
+ sidebarBg: "#FFFFFF"
171
+ }
172
+ };
173
+ var ConfigContext = createContext(defaultConfig);
174
+ function ConfigProvider({
175
+ config,
176
+ children
177
+ }) {
178
+ const mergedConfig = {
179
+ ...defaultConfig,
180
+ ...config,
181
+ menu: {
182
+ ...defaultConfig.menu,
183
+ ...config?.menu
184
+ },
185
+ features: {
186
+ ...defaultConfig.features,
187
+ ...config?.features
188
+ },
189
+ theme: {
190
+ ...defaultConfig.theme,
191
+ ...config?.theme
192
+ }
193
+ };
194
+ return /* @__PURE__ */ jsx(ConfigContext.Provider, { value: mergedConfig, children });
195
+ }
196
+ function useAdminConfig() {
197
+ return useContext(ConfigContext);
198
+ }
199
+ var queryClient = new QueryClient();
200
+ var ManagoContext = createContext(null);
201
+ function ManagoProvider({
202
+ apiKey,
203
+ config,
204
+ children
205
+ }) {
206
+ const api = new ManagoAPIClient({ apiKey });
207
+ return /* @__PURE__ */ jsx(ManagoContext.Provider, { value: { api }, children: /* @__PURE__ */ jsx(QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ jsx(ConfigProvider, { config: config || {}, children }) }) });
208
+ }
209
+ function useManagoAPI() {
210
+ const context = useContext(ManagoContext);
211
+ if (!context) {
212
+ throw new Error("useManagoAPI must be used within ManagoProvider");
213
+ }
214
+ return context.api;
215
+ }
216
+
217
+ // src/manago-admin.tsx
218
+ init_auth_store();
219
+
220
+ // src/pages/login.tsx
221
+ init_auth_store();
222
+ function cn(...inputs) {
223
+ return twMerge(clsx(inputs));
224
+ }
225
+ var buttonVariants = cva(
226
+ "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
227
+ {
228
+ variants: {
229
+ variant: {
230
+ default: "bg-primary text-primary-foreground hover:bg-primary/90",
231
+ destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
232
+ outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
233
+ secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
234
+ ghost: "hover:bg-accent hover:text-accent-foreground",
235
+ link: "text-primary underline-offset-4 hover:underline"
236
+ },
237
+ size: {
238
+ default: "h-10 px-4 py-2",
239
+ sm: "h-9 rounded-md px-3",
240
+ lg: "h-11 rounded-md px-8",
241
+ icon: "h-10 w-10"
242
+ }
243
+ },
244
+ defaultVariants: {
245
+ variant: "default",
246
+ size: "default"
247
+ }
248
+ }
249
+ );
250
+ var Button = React9.forwardRef(
251
+ ({ className, variant, size, asChild = false, ...props }, ref) => {
252
+ const Comp = asChild ? Slot : "button";
253
+ return /* @__PURE__ */ jsx(
254
+ Comp,
255
+ {
256
+ className: cn(buttonVariants({ variant, size, className })),
257
+ ref,
258
+ ...props
259
+ }
260
+ );
261
+ }
262
+ );
263
+ Button.displayName = "Button";
264
+ var Input = React9.forwardRef(
265
+ ({ className, type, ...props }, ref) => {
266
+ return /* @__PURE__ */ jsx(
267
+ "input",
268
+ {
269
+ type,
270
+ className: cn(
271
+ "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
272
+ className
273
+ ),
274
+ ref,
275
+ ...props
276
+ }
277
+ );
278
+ }
279
+ );
280
+ Input.displayName = "Input";
281
+ var labelVariants = cva(
282
+ "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
283
+ );
284
+ var Label = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
285
+ LabelPrimitive.Root,
286
+ {
287
+ ref,
288
+ className: cn(labelVariants(), className),
289
+ ...props
290
+ }
291
+ ));
292
+ Label.displayName = LabelPrimitive.Root.displayName;
293
+ var Card = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
294
+ "div",
295
+ {
296
+ ref,
297
+ className: cn(
298
+ "rounded-lg border bg-card text-card-foreground shadow-sm",
299
+ className
300
+ ),
301
+ ...props
302
+ }
303
+ ));
304
+ Card.displayName = "Card";
305
+ var CardHeader = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
306
+ "div",
307
+ {
308
+ ref,
309
+ className: cn("flex flex-col space-y-1.5 p-6", className),
310
+ ...props
311
+ }
312
+ ));
313
+ CardHeader.displayName = "CardHeader";
314
+ var CardTitle = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
315
+ "div",
316
+ {
317
+ ref,
318
+ className: cn(
319
+ "text-2xl font-semibold leading-none tracking-tight",
320
+ className
321
+ ),
322
+ ...props
323
+ }
324
+ ));
325
+ CardTitle.displayName = "CardTitle";
326
+ var CardDescription = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
327
+ "div",
328
+ {
329
+ ref,
330
+ className: cn("text-sm text-muted-foreground", className),
331
+ ...props
332
+ }
333
+ ));
334
+ CardDescription.displayName = "CardDescription";
335
+ var CardContent = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: cn("p-6 pt-0", className), ...props }));
336
+ CardContent.displayName = "CardContent";
337
+ var CardFooter = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
338
+ "div",
339
+ {
340
+ ref,
341
+ className: cn("flex items-center p-6 pt-0", className),
342
+ ...props
343
+ }
344
+ ));
345
+ CardFooter.displayName = "CardFooter";
346
+ function LoginPage() {
347
+ const [email, setEmail] = useState("");
348
+ const [password, setPassword] = useState("");
349
+ const [error, setError] = useState("");
350
+ const [loading, setLoading] = useState(false);
351
+ const api = useManagoAPI();
352
+ const { login } = useAuthStore();
353
+ const handleSubmit = async (e) => {
354
+ e.preventDefault();
355
+ setError("");
356
+ setLoading(true);
357
+ try {
358
+ const response = await api.login(email, password);
359
+ login(response.user, response.token);
360
+ } catch (err) {
361
+ setError(err.message || "Invalid credentials");
362
+ } finally {
363
+ setLoading(false);
364
+ }
365
+ };
366
+ return /* @__PURE__ */ jsx("div", { className: "min-h-screen flex items-center justify-center bg-muted/40", children: /* @__PURE__ */ jsxs(Card, { className: "w-full max-w-md", children: [
367
+ /* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsx(CardTitle, { className: "text-2xl text-center", children: "Admin Login" }) }),
368
+ /* @__PURE__ */ jsx(CardContent, { children: /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, className: "space-y-4", children: [
369
+ /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
370
+ /* @__PURE__ */ jsx(Label, { htmlFor: "email", children: "Email" }),
371
+ /* @__PURE__ */ jsx(
372
+ Input,
373
+ {
374
+ id: "email",
375
+ type: "email",
376
+ value: email,
377
+ onChange: (e) => setEmail(e.target.value),
378
+ placeholder: "admin@example.com",
379
+ required: true
380
+ }
381
+ )
382
+ ] }),
383
+ /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
384
+ /* @__PURE__ */ jsx(Label, { htmlFor: "password", children: "Password" }),
385
+ /* @__PURE__ */ jsx(
386
+ Input,
387
+ {
388
+ id: "password",
389
+ type: "password",
390
+ value: password,
391
+ onChange: (e) => setPassword(e.target.value),
392
+ placeholder: "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022",
393
+ required: true
394
+ }
395
+ )
396
+ ] }),
397
+ error && /* @__PURE__ */ jsx("p", { className: "text-sm text-destructive", children: error }),
398
+ /* @__PURE__ */ jsx(Button, { type: "submit", className: "w-full", disabled: loading, children: loading ? "Logging in..." : "Login" })
399
+ ] }) })
400
+ ] }) });
401
+ }
402
+ var MOBILE_BREAKPOINT = 768;
403
+ function useIsMobile() {
404
+ const [isMobile, setIsMobile] = React9.useState(void 0);
405
+ React9.useEffect(() => {
406
+ const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
407
+ const onChange = () => {
408
+ setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
409
+ };
410
+ mql.addEventListener("change", onChange);
411
+ setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
412
+ return () => mql.removeEventListener("change", onChange);
413
+ }, []);
414
+ return !!isMobile;
415
+ }
416
+ var Separator = React9.forwardRef(
417
+ ({ className, orientation = "horizontal", decorative = true, ...props }, ref) => /* @__PURE__ */ jsx(
418
+ SeparatorPrimitive.Root,
419
+ {
420
+ ref,
421
+ decorative,
422
+ orientation,
423
+ className: cn(
424
+ "shrink-0 bg-border",
425
+ orientation === "horizontal" ? "h-[1px] w-full" : "h-full w-[1px]",
426
+ className
427
+ ),
428
+ ...props
429
+ }
430
+ )
431
+ );
432
+ Separator.displayName = SeparatorPrimitive.Root.displayName;
433
+ var Sheet = SheetPrimitive.Root;
434
+ var SheetPortal = SheetPrimitive.Portal;
435
+ var SheetOverlay = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
436
+ SheetPrimitive.Overlay,
437
+ {
438
+ className: cn(
439
+ "fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
440
+ className
441
+ ),
442
+ ...props,
443
+ ref
444
+ }
445
+ ));
446
+ SheetOverlay.displayName = SheetPrimitive.Overlay.displayName;
447
+ var sheetVariants = cva(
448
+ "fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",
449
+ {
450
+ variants: {
451
+ side: {
452
+ top: "inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",
453
+ bottom: "inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",
454
+ left: "inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",
455
+ right: "inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"
456
+ }
457
+ },
458
+ defaultVariants: {
459
+ side: "right"
460
+ }
461
+ }
462
+ );
463
+ var SheetContent = React9.forwardRef(({ side = "right", className, children, ...props }, ref) => /* @__PURE__ */ jsxs(SheetPortal, { children: [
464
+ /* @__PURE__ */ jsx(SheetOverlay, {}),
465
+ /* @__PURE__ */ jsxs(
466
+ SheetPrimitive.Content,
467
+ {
468
+ ref,
469
+ className: cn(sheetVariants({ side }), className),
470
+ ...props,
471
+ children: [
472
+ children,
473
+ /* @__PURE__ */ jsxs(SheetPrimitive.Close, { className: "absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary", children: [
474
+ /* @__PURE__ */ jsx(X, { className: "h-4 w-4" }),
475
+ /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Close" })
476
+ ] })
477
+ ]
478
+ }
479
+ )
480
+ ] }));
481
+ SheetContent.displayName = SheetPrimitive.Content.displayName;
482
+ var SheetHeader = ({
483
+ className,
484
+ ...props
485
+ }) => /* @__PURE__ */ jsx(
486
+ "div",
487
+ {
488
+ className: cn(
489
+ "flex flex-col space-y-2 text-center sm:text-left",
490
+ className
491
+ ),
492
+ ...props
493
+ }
494
+ );
495
+ SheetHeader.displayName = "SheetHeader";
496
+ var SheetTitle = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
497
+ SheetPrimitive.Title,
498
+ {
499
+ ref,
500
+ className: cn("text-lg font-semibold text-foreground", className),
501
+ ...props
502
+ }
503
+ ));
504
+ SheetTitle.displayName = SheetPrimitive.Title.displayName;
505
+ var SheetDescription = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
506
+ SheetPrimitive.Description,
507
+ {
508
+ ref,
509
+ className: cn("text-sm text-muted-foreground", className),
510
+ ...props
511
+ }
512
+ ));
513
+ SheetDescription.displayName = SheetPrimitive.Description.displayName;
514
+ function Skeleton({
515
+ className,
516
+ ...props
517
+ }) {
518
+ return /* @__PURE__ */ jsx(
519
+ "div",
520
+ {
521
+ className: cn("animate-pulse rounded-md bg-muted", className),
522
+ ...props
523
+ }
524
+ );
525
+ }
526
+ var TooltipProvider = TooltipPrimitive.Provider;
527
+ var Tooltip = TooltipPrimitive.Root;
528
+ var TooltipTrigger = TooltipPrimitive.Trigger;
529
+ var TooltipContent = React9.forwardRef(({ className, sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsx(
530
+ TooltipPrimitive.Content,
531
+ {
532
+ ref,
533
+ sideOffset,
534
+ className: cn(
535
+ "z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md 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 origin-[--radix-tooltip-content-transform-origin]",
536
+ className
537
+ ),
538
+ ...props
539
+ }
540
+ ));
541
+ TooltipContent.displayName = TooltipPrimitive.Content.displayName;
542
+ var SIDEBAR_COOKIE_NAME = "sidebar_state";
543
+ var SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
544
+ var SIDEBAR_WIDTH = "16rem";
545
+ var SIDEBAR_WIDTH_MOBILE = "18rem";
546
+ var SIDEBAR_WIDTH_ICON = "3rem";
547
+ var SIDEBAR_KEYBOARD_SHORTCUT = "b";
548
+ var SidebarContext = React9.createContext(null);
549
+ function useSidebar() {
550
+ const context = React9.useContext(SidebarContext);
551
+ if (!context) {
552
+ throw new Error("useSidebar must be used within a SidebarProvider.");
553
+ }
554
+ return context;
555
+ }
556
+ var SidebarProvider = React9.forwardRef(
557
+ ({
558
+ defaultOpen = true,
559
+ open: openProp,
560
+ onOpenChange: setOpenProp,
561
+ className,
562
+ style,
563
+ children,
564
+ ...props
565
+ }, ref) => {
566
+ const isMobile = useIsMobile();
567
+ const [openMobile, setOpenMobile] = React9.useState(false);
568
+ const [_open, _setOpen] = React9.useState(defaultOpen);
569
+ const open = openProp ?? _open;
570
+ const setOpen = React9.useCallback(
571
+ (value) => {
572
+ const openState = typeof value === "function" ? value(open) : value;
573
+ if (setOpenProp) {
574
+ setOpenProp(openState);
575
+ } else {
576
+ _setOpen(openState);
577
+ }
578
+ document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`;
579
+ },
580
+ [setOpenProp, open]
581
+ );
582
+ const toggleSidebar = React9.useCallback(() => {
583
+ return isMobile ? setOpenMobile((open2) => !open2) : setOpen((open2) => !open2);
584
+ }, [isMobile, setOpen, setOpenMobile]);
585
+ React9.useEffect(() => {
586
+ const handleKeyDown = (event) => {
587
+ if (event.key === SIDEBAR_KEYBOARD_SHORTCUT && (event.metaKey || event.ctrlKey)) {
588
+ event.preventDefault();
589
+ toggleSidebar();
590
+ }
591
+ };
592
+ window.addEventListener("keydown", handleKeyDown);
593
+ return () => window.removeEventListener("keydown", handleKeyDown);
594
+ }, [toggleSidebar]);
595
+ const state = open ? "expanded" : "collapsed";
596
+ const contextValue = React9.useMemo(
597
+ () => ({
598
+ state,
599
+ open,
600
+ setOpen,
601
+ isMobile,
602
+ openMobile,
603
+ setOpenMobile,
604
+ toggleSidebar
605
+ }),
606
+ [state, open, setOpen, isMobile, openMobile, setOpenMobile, toggleSidebar]
607
+ );
608
+ return /* @__PURE__ */ jsx(SidebarContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx(TooltipProvider, { delayDuration: 0, children: /* @__PURE__ */ jsx(
609
+ "div",
610
+ {
611
+ style: {
612
+ "--sidebar-width": SIDEBAR_WIDTH,
613
+ "--sidebar-width-icon": SIDEBAR_WIDTH_ICON,
614
+ ...style
615
+ },
616
+ className: cn(
617
+ "group/sidebar-wrapper flex min-h-svh w-full has-[[data-variant=inset]]:bg-sidebar",
618
+ className
619
+ ),
620
+ ref,
621
+ ...props,
622
+ children
623
+ }
624
+ ) }) });
625
+ }
626
+ );
627
+ SidebarProvider.displayName = "SidebarProvider";
628
+ var Sidebar = React9.forwardRef(
629
+ ({
630
+ side = "left",
631
+ variant = "sidebar",
632
+ collapsible = "offcanvas",
633
+ className,
634
+ children,
635
+ ...props
636
+ }, ref) => {
637
+ const { isMobile, state, openMobile, setOpenMobile } = useSidebar();
638
+ if (collapsible === "none") {
639
+ return /* @__PURE__ */ jsx(
640
+ "div",
641
+ {
642
+ className: cn(
643
+ "flex h-full w-[--sidebar-width] flex-col bg-sidebar text-sidebar-foreground",
644
+ className
645
+ ),
646
+ ref,
647
+ ...props,
648
+ children
649
+ }
650
+ );
651
+ }
652
+ if (isMobile) {
653
+ return /* @__PURE__ */ jsx(Sheet, { open: openMobile, onOpenChange: setOpenMobile, ...props, children: /* @__PURE__ */ jsxs(
654
+ SheetContent,
655
+ {
656
+ "data-sidebar": "sidebar",
657
+ "data-mobile": "true",
658
+ className: "w-[--sidebar-width] bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden",
659
+ style: {
660
+ "--sidebar-width": SIDEBAR_WIDTH_MOBILE
661
+ },
662
+ side,
663
+ children: [
664
+ /* @__PURE__ */ jsxs(SheetHeader, { className: "sr-only", children: [
665
+ /* @__PURE__ */ jsx(SheetTitle, { children: "Sidebar" }),
666
+ /* @__PURE__ */ jsx(SheetDescription, { children: "Displays the mobile sidebar." })
667
+ ] }),
668
+ /* @__PURE__ */ jsx("div", { className: "flex h-full w-full flex-col", children })
669
+ ]
670
+ }
671
+ ) });
672
+ }
673
+ return /* @__PURE__ */ jsxs(
674
+ "div",
675
+ {
676
+ ref,
677
+ className: "group peer hidden text-sidebar-foreground md:block",
678
+ "data-state": state,
679
+ "data-collapsible": state === "collapsed" ? collapsible : "",
680
+ "data-variant": variant,
681
+ "data-side": side,
682
+ children: [
683
+ /* @__PURE__ */ jsx(
684
+ "div",
685
+ {
686
+ className: cn(
687
+ "relative w-[--sidebar-width] bg-transparent transition-[width] duration-200 ease-linear",
688
+ "group-data-[collapsible=offcanvas]:w-0",
689
+ "group-data-[side=right]:rotate-180",
690
+ variant === "floating" || variant === "inset" ? "group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]" : "group-data-[collapsible=icon]:w-[--sidebar-width-icon]"
691
+ )
692
+ }
693
+ ),
694
+ /* @__PURE__ */ jsx(
695
+ "div",
696
+ {
697
+ className: cn(
698
+ "fixed inset-y-0 z-10 hidden h-svh w-[--sidebar-width] transition-[left,right,width] duration-200 ease-linear md:flex",
699
+ side === "left" ? "left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]" : "right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",
700
+ // Adjust the padding for floating and inset variants.
701
+ variant === "floating" || variant === "inset" ? "p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4)_+2px)]" : "group-data-[collapsible=icon]:w-[--sidebar-width-icon] group-data-[side=left]:border-r group-data-[side=right]:border-l",
702
+ className
703
+ ),
704
+ ...props,
705
+ children: /* @__PURE__ */ jsx(
706
+ "div",
707
+ {
708
+ "data-sidebar": "sidebar",
709
+ className: "flex h-full w-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:border-sidebar-border group-data-[variant=floating]:shadow",
710
+ children
711
+ }
712
+ )
713
+ }
714
+ )
715
+ ]
716
+ }
717
+ );
718
+ }
719
+ );
720
+ Sidebar.displayName = "Sidebar";
721
+ var SidebarTrigger = React9.forwardRef(({ className, onClick, ...props }, ref) => {
722
+ const { toggleSidebar } = useSidebar();
723
+ return /* @__PURE__ */ jsxs(
724
+ Button,
725
+ {
726
+ ref,
727
+ "data-sidebar": "trigger",
728
+ variant: "ghost",
729
+ size: "icon",
730
+ className: cn("h-7 w-7", className),
731
+ onClick: (event) => {
732
+ onClick?.(event);
733
+ toggleSidebar();
734
+ },
735
+ ...props,
736
+ children: [
737
+ /* @__PURE__ */ jsx(PanelLeft, {}),
738
+ /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Toggle Sidebar" })
739
+ ]
740
+ }
741
+ );
742
+ });
743
+ SidebarTrigger.displayName = "SidebarTrigger";
744
+ var SidebarRail = React9.forwardRef(({ className, ...props }, ref) => {
745
+ const { toggleSidebar } = useSidebar();
746
+ return /* @__PURE__ */ jsx(
747
+ "button",
748
+ {
749
+ ref,
750
+ "data-sidebar": "rail",
751
+ "aria-label": "Toggle Sidebar",
752
+ tabIndex: -1,
753
+ onClick: toggleSidebar,
754
+ title: "Toggle Sidebar",
755
+ className: cn(
756
+ "absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] hover:after:bg-sidebar-border group-data-[side=left]:-right-4 group-data-[side=right]:left-0 sm:flex",
757
+ "[[data-side=left]_&]:cursor-w-resize [[data-side=right]_&]:cursor-e-resize",
758
+ "[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize",
759
+ "group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full group-data-[collapsible=offcanvas]:hover:bg-sidebar",
760
+ "[[data-side=left][data-collapsible=offcanvas]_&]:-right-2",
761
+ "[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",
762
+ className
763
+ ),
764
+ ...props
765
+ }
766
+ );
767
+ });
768
+ SidebarRail.displayName = "SidebarRail";
769
+ var SidebarInset = React9.forwardRef(({ className, ...props }, ref) => {
770
+ return /* @__PURE__ */ jsx(
771
+ "main",
772
+ {
773
+ ref,
774
+ className: cn(
775
+ "relative flex w-full flex-1 flex-col bg-background",
776
+ "md:peer-data-[variant=inset]:m-2 md:peer-data-[state=collapsed]:peer-data-[variant=inset]:ml-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow",
777
+ className
778
+ ),
779
+ ...props
780
+ }
781
+ );
782
+ });
783
+ SidebarInset.displayName = "SidebarInset";
784
+ var SidebarInput = React9.forwardRef(({ className, ...props }, ref) => {
785
+ return /* @__PURE__ */ jsx(
786
+ Input,
787
+ {
788
+ ref,
789
+ "data-sidebar": "input",
790
+ className: cn(
791
+ "h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",
792
+ className
793
+ ),
794
+ ...props
795
+ }
796
+ );
797
+ });
798
+ SidebarInput.displayName = "SidebarInput";
799
+ var SidebarHeader = React9.forwardRef(({ className, ...props }, ref) => {
800
+ return /* @__PURE__ */ jsx(
801
+ "div",
802
+ {
803
+ ref,
804
+ "data-sidebar": "header",
805
+ className: cn("flex flex-col gap-2 p-2", className),
806
+ ...props
807
+ }
808
+ );
809
+ });
810
+ SidebarHeader.displayName = "SidebarHeader";
811
+ var SidebarFooter = React9.forwardRef(({ className, ...props }, ref) => {
812
+ return /* @__PURE__ */ jsx(
813
+ "div",
814
+ {
815
+ ref,
816
+ "data-sidebar": "footer",
817
+ className: cn("flex flex-col gap-2 p-2", className),
818
+ ...props
819
+ }
820
+ );
821
+ });
822
+ SidebarFooter.displayName = "SidebarFooter";
823
+ var SidebarSeparator = React9.forwardRef(({ className, ...props }, ref) => {
824
+ return /* @__PURE__ */ jsx(
825
+ Separator,
826
+ {
827
+ ref,
828
+ "data-sidebar": "separator",
829
+ className: cn("mx-2 w-auto bg-sidebar-border", className),
830
+ ...props
831
+ }
832
+ );
833
+ });
834
+ SidebarSeparator.displayName = "SidebarSeparator";
835
+ var SidebarContent = React9.forwardRef(({ className, ...props }, ref) => {
836
+ return /* @__PURE__ */ jsx(
837
+ "div",
838
+ {
839
+ ref,
840
+ "data-sidebar": "content",
841
+ className: cn(
842
+ "flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",
843
+ className
844
+ ),
845
+ ...props
846
+ }
847
+ );
848
+ });
849
+ SidebarContent.displayName = "SidebarContent";
850
+ var SidebarGroup = React9.forwardRef(({ className, ...props }, ref) => {
851
+ return /* @__PURE__ */ jsx(
852
+ "div",
853
+ {
854
+ ref,
855
+ "data-sidebar": "group",
856
+ className: cn("relative flex w-full min-w-0 flex-col p-2", className),
857
+ ...props
858
+ }
859
+ );
860
+ });
861
+ SidebarGroup.displayName = "SidebarGroup";
862
+ var SidebarGroupLabel = React9.forwardRef(({ className, asChild = false, ...props }, ref) => {
863
+ const Comp = asChild ? Slot : "div";
864
+ return /* @__PURE__ */ jsx(
865
+ Comp,
866
+ {
867
+ ref,
868
+ "data-sidebar": "group-label",
869
+ className: cn(
870
+ "flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 outline-none ring-sidebar-ring transition-[margin,opacity] duration-200 ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",
871
+ "group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",
872
+ className
873
+ ),
874
+ ...props
875
+ }
876
+ );
877
+ });
878
+ SidebarGroupLabel.displayName = "SidebarGroupLabel";
879
+ var SidebarGroupAction = React9.forwardRef(({ className, asChild = false, ...props }, ref) => {
880
+ const Comp = asChild ? Slot : "button";
881
+ return /* @__PURE__ */ jsx(
882
+ Comp,
883
+ {
884
+ ref,
885
+ "data-sidebar": "group-action",
886
+ className: cn(
887
+ "absolute right-3 top-3.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",
888
+ // Increases the hit area of the button on mobile.
889
+ "after:absolute after:-inset-2 after:md:hidden",
890
+ "group-data-[collapsible=icon]:hidden",
891
+ className
892
+ ),
893
+ ...props
894
+ }
895
+ );
896
+ });
897
+ SidebarGroupAction.displayName = "SidebarGroupAction";
898
+ var SidebarGroupContent = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
899
+ "div",
900
+ {
901
+ ref,
902
+ "data-sidebar": "group-content",
903
+ className: cn("w-full text-sm", className),
904
+ ...props
905
+ }
906
+ ));
907
+ SidebarGroupContent.displayName = "SidebarGroupContent";
908
+ var SidebarMenu = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
909
+ "ul",
910
+ {
911
+ ref,
912
+ "data-sidebar": "menu",
913
+ className: cn("flex w-full min-w-0 flex-col gap-1", className),
914
+ ...props
915
+ }
916
+ ));
917
+ SidebarMenu.displayName = "SidebarMenu";
918
+ var SidebarMenuItem = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
919
+ "li",
920
+ {
921
+ ref,
922
+ "data-sidebar": "menu-item",
923
+ className: cn("group/menu-item relative", className),
924
+ ...props
925
+ }
926
+ ));
927
+ SidebarMenuItem.displayName = "SidebarMenuItem";
928
+ var sidebarMenuButtonVariants = cva(
929
+ "peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-none ring-sidebar-ring transition-[width,height,padding] 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 group-has-[[data-sidebar=menu-action]]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:!size-8 group-data-[collapsible=icon]:!p-2 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",
930
+ {
931
+ variants: {
932
+ variant: {
933
+ default: "hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",
934
+ outline: "bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"
935
+ },
936
+ size: {
937
+ default: "h-8 text-sm",
938
+ sm: "h-7 text-xs",
939
+ lg: "h-12 text-sm group-data-[collapsible=icon]:!p-0"
940
+ }
941
+ },
942
+ defaultVariants: {
943
+ variant: "default",
944
+ size: "default"
945
+ }
946
+ }
947
+ );
948
+ var SidebarMenuButton = React9.forwardRef(
949
+ ({
950
+ asChild = false,
951
+ isActive = false,
952
+ variant = "default",
953
+ size = "default",
954
+ tooltip,
955
+ className,
956
+ ...props
957
+ }, ref) => {
958
+ const Comp = asChild ? Slot : "button";
959
+ const { isMobile, state } = useSidebar();
960
+ const button = /* @__PURE__ */ jsx(
961
+ Comp,
962
+ {
963
+ ref,
964
+ "data-sidebar": "menu-button",
965
+ "data-size": size,
966
+ "data-active": isActive,
967
+ className: cn(sidebarMenuButtonVariants({ variant, size }), className),
968
+ ...props
969
+ }
970
+ );
971
+ if (!tooltip) {
972
+ return button;
973
+ }
974
+ if (typeof tooltip === "string") {
975
+ tooltip = {
976
+ children: tooltip
977
+ };
978
+ }
979
+ return /* @__PURE__ */ jsxs(Tooltip, { children: [
980
+ /* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: button }),
981
+ /* @__PURE__ */ jsx(
982
+ TooltipContent,
983
+ {
984
+ side: "right",
985
+ align: "center",
986
+ hidden: state !== "collapsed" || isMobile,
987
+ ...tooltip
988
+ }
989
+ )
990
+ ] });
991
+ }
992
+ );
993
+ SidebarMenuButton.displayName = "SidebarMenuButton";
994
+ var SidebarMenuAction = React9.forwardRef(({ className, asChild = false, showOnHover = false, ...props }, ref) => {
995
+ const Comp = asChild ? Slot : "button";
996
+ return /* @__PURE__ */ jsx(
997
+ Comp,
998
+ {
999
+ ref,
1000
+ "data-sidebar": "menu-action",
1001
+ className: cn(
1002
+ "absolute right-1 top-1.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 peer-hover/menu-button:text-sidebar-accent-foreground [&>svg]:size-4 [&>svg]:shrink-0",
1003
+ // Increases the hit area of the button on mobile.
1004
+ "after:absolute after:-inset-2 after:md:hidden",
1005
+ "peer-data-[size=sm]/menu-button:top-1",
1006
+ "peer-data-[size=default]/menu-button:top-1.5",
1007
+ "peer-data-[size=lg]/menu-button:top-2.5",
1008
+ "group-data-[collapsible=icon]:hidden",
1009
+ showOnHover && "group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 peer-data-[active=true]/menu-button:text-sidebar-accent-foreground md:opacity-0",
1010
+ className
1011
+ ),
1012
+ ...props
1013
+ }
1014
+ );
1015
+ });
1016
+ SidebarMenuAction.displayName = "SidebarMenuAction";
1017
+ var SidebarMenuBadge = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
1018
+ "div",
1019
+ {
1020
+ ref,
1021
+ "data-sidebar": "menu-badge",
1022
+ className: cn(
1023
+ "pointer-events-none absolute right-1 flex h-5 min-w-5 select-none items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums text-sidebar-foreground",
1024
+ "peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground",
1025
+ "peer-data-[size=sm]/menu-button:top-1",
1026
+ "peer-data-[size=default]/menu-button:top-1.5",
1027
+ "peer-data-[size=lg]/menu-button:top-2.5",
1028
+ "group-data-[collapsible=icon]:hidden",
1029
+ className
1030
+ ),
1031
+ ...props
1032
+ }
1033
+ ));
1034
+ SidebarMenuBadge.displayName = "SidebarMenuBadge";
1035
+ var SidebarMenuSkeleton = React9.forwardRef(({ className, showIcon = false, ...props }, ref) => {
1036
+ const width = React9.useMemo(() => {
1037
+ return `${Math.floor(Math.random() * 40) + 50}%`;
1038
+ }, []);
1039
+ return /* @__PURE__ */ jsxs(
1040
+ "div",
1041
+ {
1042
+ ref,
1043
+ "data-sidebar": "menu-skeleton",
1044
+ className: cn("flex h-8 items-center gap-2 rounded-md px-2", className),
1045
+ ...props,
1046
+ children: [
1047
+ showIcon && /* @__PURE__ */ jsx(
1048
+ Skeleton,
1049
+ {
1050
+ className: "size-4 rounded-md",
1051
+ "data-sidebar": "menu-skeleton-icon"
1052
+ }
1053
+ ),
1054
+ /* @__PURE__ */ jsx(
1055
+ Skeleton,
1056
+ {
1057
+ className: "h-4 max-w-[--skeleton-width] flex-1",
1058
+ "data-sidebar": "menu-skeleton-text",
1059
+ style: {
1060
+ "--skeleton-width": width
1061
+ }
1062
+ }
1063
+ )
1064
+ ]
1065
+ }
1066
+ );
1067
+ });
1068
+ SidebarMenuSkeleton.displayName = "SidebarMenuSkeleton";
1069
+ var SidebarMenuSub = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
1070
+ "ul",
1071
+ {
1072
+ ref,
1073
+ "data-sidebar": "menu-sub",
1074
+ className: cn(
1075
+ "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",
1076
+ "group-data-[collapsible=icon]:hidden",
1077
+ className
1078
+ ),
1079
+ ...props
1080
+ }
1081
+ ));
1082
+ SidebarMenuSub.displayName = "SidebarMenuSub";
1083
+ var SidebarMenuSubItem = React9.forwardRef(({ ...props }, ref) => /* @__PURE__ */ jsx("li", { ref, ...props }));
1084
+ SidebarMenuSubItem.displayName = "SidebarMenuSubItem";
1085
+ var SidebarMenuSubButton = React9.forwardRef(({ asChild = false, size = "md", isActive, className, ...props }, ref) => {
1086
+ const Comp = asChild ? Slot : "a";
1087
+ return /* @__PURE__ */ jsx(
1088
+ Comp,
1089
+ {
1090
+ ref,
1091
+ "data-sidebar": "menu-sub-button",
1092
+ "data-size": size,
1093
+ "data-active": isActive,
1094
+ className: cn(
1095
+ "flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground outline-none ring-sidebar-ring 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 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground",
1096
+ "data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground",
1097
+ size === "sm" && "text-xs",
1098
+ size === "md" && "text-sm",
1099
+ "group-data-[collapsible=icon]:hidden",
1100
+ className
1101
+ ),
1102
+ ...props
1103
+ }
1104
+ );
1105
+ });
1106
+ SidebarMenuSubButton.displayName = "SidebarMenuSubButton";
1107
+ var menuItemsConfig = [
1108
+ { key: "dashboard", href: "/", label: "Dashboard", icon: LayoutDashboard },
1109
+ { key: "products", href: "/products", label: "Products", icon: Package },
1110
+ { key: "orders", href: "/orders", label: "Orders", icon: ShoppingCart },
1111
+ { key: "customers", href: "/customers", label: "Customers", icon: Users },
1112
+ { key: "payments", href: "/payments", label: "Payments", icon: CreditCard },
1113
+ { key: "users", href: "/users", label: "Team", icon: UserCog },
1114
+ { key: "settings", href: "/settings", label: "Settings", icon: Settings }
1115
+ ];
1116
+ function AppSidebar() {
1117
+ const routerState = useRouterState();
1118
+ const pathname = routerState.location.pathname;
1119
+ const config = useAdminConfig();
1120
+ const menuItems = menuItemsConfig.filter(
1121
+ (item) => config.menu?.[item.key] !== false
1122
+ );
1123
+ const customItems = (config.customMenuItems || []).map((item) => ({
1124
+ key: item.href,
1125
+ href: item.href,
1126
+ label: item.label,
1127
+ icon: () => /* @__PURE__ */ jsx("span", { className: "text-xl", children: item.icon })
1128
+ }));
1129
+ const allMenuItems = [...menuItems, ...customItems];
1130
+ return /* @__PURE__ */ jsxs(Sidebar, { collapsible: "icon", children: [
1131
+ /* @__PURE__ */ jsx(SidebarHeader, { className: "border-b px-6 py-4", children: typeof config.logo === "string" ? /* @__PURE__ */ jsx("img", { src: config.logo, alt: "Logo", className: "h-8" }) : config.logo ? config.logo : /* @__PURE__ */ jsx("h1", { className: "text-xl font-bold", children: config.appName }) }),
1132
+ /* @__PURE__ */ jsx(SidebarContent, { children: /* @__PURE__ */ jsx(SidebarGroup, { children: /* @__PURE__ */ jsx(SidebarGroupContent, { children: /* @__PURE__ */ jsx(SidebarMenu, { children: allMenuItems.map((item) => {
1133
+ const Icon = item.icon;
1134
+ const isActive = pathname === item.href;
1135
+ return /* @__PURE__ */ jsx(SidebarMenuItem, { children: /* @__PURE__ */ jsx(SidebarMenuButton, { asChild: true, isActive, children: /* @__PURE__ */ jsxs(Link, { to: item.href, children: [
1136
+ /* @__PURE__ */ jsx(Icon, { className: "h-4 w-4" }),
1137
+ /* @__PURE__ */ jsx("span", { children: item.label })
1138
+ ] }) }) }, item.href);
1139
+ }) }) }) }) })
1140
+ ] });
1141
+ }
1142
+
1143
+ // src/components/layout/header.tsx
1144
+ init_auth_store();
1145
+ var Avatar = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
1146
+ AvatarPrimitive.Root,
1147
+ {
1148
+ ref,
1149
+ className: cn(
1150
+ "relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",
1151
+ className
1152
+ ),
1153
+ ...props
1154
+ }
1155
+ ));
1156
+ Avatar.displayName = AvatarPrimitive.Root.displayName;
1157
+ var AvatarImage = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
1158
+ AvatarPrimitive.Image,
1159
+ {
1160
+ ref,
1161
+ className: cn("aspect-square h-full w-full", className),
1162
+ ...props
1163
+ }
1164
+ ));
1165
+ AvatarImage.displayName = AvatarPrimitive.Image.displayName;
1166
+ var AvatarFallback = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
1167
+ AvatarPrimitive.Fallback,
1168
+ {
1169
+ ref,
1170
+ className: cn(
1171
+ "flex h-full w-full items-center justify-center rounded-full bg-muted",
1172
+ className
1173
+ ),
1174
+ ...props
1175
+ }
1176
+ ));
1177
+ AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName;
1178
+ var DropdownMenu = DropdownMenuPrimitive.Root;
1179
+ var DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
1180
+ var DropdownMenuSubTrigger = React9.forwardRef(({ className, inset, children, ...props }, ref) => /* @__PURE__ */ jsxs(
1181
+ DropdownMenuPrimitive.SubTrigger,
1182
+ {
1183
+ ref,
1184
+ className: cn(
1185
+ "flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
1186
+ inset && "pl-8",
1187
+ className
1188
+ ),
1189
+ ...props,
1190
+ children: [
1191
+ children,
1192
+ /* @__PURE__ */ jsx(ChevronRight, { className: "ml-auto" })
1193
+ ]
1194
+ }
1195
+ ));
1196
+ DropdownMenuSubTrigger.displayName = DropdownMenuPrimitive.SubTrigger.displayName;
1197
+ var DropdownMenuSubContent = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
1198
+ DropdownMenuPrimitive.SubContent,
1199
+ {
1200
+ ref,
1201
+ className: cn(
1202
+ "z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-dropdown-menu-content-transform-origin]",
1203
+ className
1204
+ ),
1205
+ ...props
1206
+ }
1207
+ ));
1208
+ DropdownMenuSubContent.displayName = DropdownMenuPrimitive.SubContent.displayName;
1209
+ var DropdownMenuContent = React9.forwardRef(({ className, sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsx(DropdownMenuPrimitive.Portal, { children: /* @__PURE__ */ jsx(
1210
+ DropdownMenuPrimitive.Content,
1211
+ {
1212
+ ref,
1213
+ sideOffset,
1214
+ className: cn(
1215
+ "z-50 max-h-[var(--radix-dropdown-menu-content-available-height)] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-dropdown-menu-content-transform-origin]",
1216
+ className
1217
+ ),
1218
+ ...props
1219
+ }
1220
+ ) }));
1221
+ DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName;
1222
+ var DropdownMenuItem = React9.forwardRef(({ className, inset, ...props }, ref) => /* @__PURE__ */ jsx(
1223
+ DropdownMenuPrimitive.Item,
1224
+ {
1225
+ ref,
1226
+ className: cn(
1227
+ "relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
1228
+ inset && "pl-8",
1229
+ className
1230
+ ),
1231
+ ...props
1232
+ }
1233
+ ));
1234
+ DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName;
1235
+ var DropdownMenuCheckboxItem = React9.forwardRef(({ className, children, checked, ...props }, ref) => /* @__PURE__ */ jsxs(
1236
+ DropdownMenuPrimitive.CheckboxItem,
1237
+ {
1238
+ ref,
1239
+ className: cn(
1240
+ "relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
1241
+ className
1242
+ ),
1243
+ checked,
1244
+ ...props,
1245
+ children: [
1246
+ /* @__PURE__ */ jsx("span", { className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ jsx(DropdownMenuPrimitive.ItemIndicator, { children: /* @__PURE__ */ jsx(Check, { className: "h-4 w-4" }) }) }),
1247
+ children
1248
+ ]
1249
+ }
1250
+ ));
1251
+ DropdownMenuCheckboxItem.displayName = DropdownMenuPrimitive.CheckboxItem.displayName;
1252
+ var DropdownMenuRadioItem = React9.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(
1253
+ DropdownMenuPrimitive.RadioItem,
1254
+ {
1255
+ ref,
1256
+ className: cn(
1257
+ "relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
1258
+ className
1259
+ ),
1260
+ ...props,
1261
+ children: [
1262
+ /* @__PURE__ */ jsx("span", { className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ jsx(DropdownMenuPrimitive.ItemIndicator, { children: /* @__PURE__ */ jsx(Circle, { className: "h-2 w-2 fill-current" }) }) }),
1263
+ children
1264
+ ]
1265
+ }
1266
+ ));
1267
+ DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName;
1268
+ var DropdownMenuLabel = React9.forwardRef(({ className, inset, ...props }, ref) => /* @__PURE__ */ jsx(
1269
+ DropdownMenuPrimitive.Label,
1270
+ {
1271
+ ref,
1272
+ className: cn(
1273
+ "px-2 py-1.5 text-sm font-semibold",
1274
+ inset && "pl-8",
1275
+ className
1276
+ ),
1277
+ ...props
1278
+ }
1279
+ ));
1280
+ DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName;
1281
+ var DropdownMenuSeparator = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
1282
+ DropdownMenuPrimitive.Separator,
1283
+ {
1284
+ ref,
1285
+ className: cn("-mx-1 my-1 h-px bg-muted", className),
1286
+ ...props
1287
+ }
1288
+ ));
1289
+ DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName;
1290
+ function Header() {
1291
+ const { user, logout } = useAuthStore();
1292
+ const initials = user?.name.split(" ").map((n) => n[0]).join("").toUpperCase() || "??";
1293
+ return /* @__PURE__ */ jsxs("header", { className: "flex h-16 shrink-0 items-center gap-2 border-b px-4", children: [
1294
+ /* @__PURE__ */ jsx(SidebarTrigger, { className: "-ml-1" }),
1295
+ /* @__PURE__ */ jsx("div", { className: "flex flex-1" }),
1296
+ /* @__PURE__ */ jsxs(DropdownMenu, { children: [
1297
+ /* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsx(Button, { variant: "ghost", className: "relative h-10 w-10 rounded-full", children: /* @__PURE__ */ jsx(Avatar, { children: /* @__PURE__ */ jsx(AvatarFallback, { children: initials }) }) }) }),
1298
+ /* @__PURE__ */ jsxs(DropdownMenuContent, { align: "end", children: [
1299
+ /* @__PURE__ */ jsx(DropdownMenuLabel, { children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col space-y-1", children: [
1300
+ /* @__PURE__ */ jsx("p", { className: "text-sm font-medium", children: user?.name }),
1301
+ /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: user?.email })
1302
+ ] }) }),
1303
+ /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
1304
+ /* @__PURE__ */ jsx(DropdownMenuItem, { onClick: logout, children: "Log out" })
1305
+ ] })
1306
+ ] })
1307
+ ] });
1308
+ }
1309
+ function AdminLayout({ children }) {
1310
+ return /* @__PURE__ */ jsxs(SidebarProvider, { defaultOpen: true, children: [
1311
+ /* @__PURE__ */ jsx(AppSidebar, {}),
1312
+ /* @__PURE__ */ jsxs(SidebarInset, { className: "flex flex-col", children: [
1313
+ /* @__PURE__ */ jsx(Header, {}),
1314
+ /* @__PURE__ */ jsx("div", { className: "flex flex-1 flex-col gap-4 p-6", children })
1315
+ ] })
1316
+ ] });
1317
+ }
1318
+ var Route = createRootRoute({
1319
+ component: RootComponent
1320
+ });
1321
+ function RootComponent() {
1322
+ return /* @__PURE__ */ jsx(AdminLayout, { children: /* @__PURE__ */ jsx(Outlet, {}) });
1323
+ }
1324
+ function DashboardPage() {
1325
+ const api = useManagoAPI();
1326
+ const { data: products } = useQuery({
1327
+ queryKey: ["products"],
1328
+ queryFn: () => api.getProducts({ limit: 5 })
1329
+ });
1330
+ const { data: orders } = useQuery({
1331
+ queryKey: ["orders"],
1332
+ queryFn: () => api.getOrders({ limit: 5 })
1333
+ });
1334
+ const { data: customers } = useQuery({
1335
+ queryKey: ["customers"],
1336
+ queryFn: () => api.getCustomers({ limit: 5 })
1337
+ });
1338
+ const stats = [
1339
+ {
1340
+ title: "Total Products",
1341
+ value: products?.total || 0,
1342
+ icon: Package,
1343
+ trend: "+12%"
1344
+ },
1345
+ {
1346
+ title: "Total Orders",
1347
+ value: orders?.total || 0,
1348
+ icon: ShoppingCart,
1349
+ trend: "+8%"
1350
+ },
1351
+ {
1352
+ title: "Total Customers",
1353
+ value: customers?.total || 0,
1354
+ icon: Users,
1355
+ trend: "+5%"
1356
+ },
1357
+ {
1358
+ title: "Revenue",
1359
+ value: "$12,456",
1360
+ icon: DollarSign,
1361
+ trend: "+15%"
1362
+ }
1363
+ ];
1364
+ return /* @__PURE__ */ jsxs("div", { className: "space-y-6", children: [
1365
+ /* @__PURE__ */ jsx("h1", { className: "text-3xl font-bold", children: "Dashboard" }),
1366
+ /* @__PURE__ */ jsx("div", { className: "grid gap-4 md:grid-cols-2 lg:grid-cols-4", children: stats.map((stat) => {
1367
+ const Icon = stat.icon;
1368
+ return /* @__PURE__ */ jsxs(Card, { children: [
1369
+ /* @__PURE__ */ jsxs(CardHeader, { className: "flex flex-row items-center justify-between pb-2", children: [
1370
+ /* @__PURE__ */ jsx(CardTitle, { className: "text-sm font-medium text-muted-foreground", children: stat.title }),
1371
+ /* @__PURE__ */ jsx(Icon, { className: "h-4 w-4 text-muted-foreground" })
1372
+ ] }),
1373
+ /* @__PURE__ */ jsxs(CardContent, { children: [
1374
+ /* @__PURE__ */ jsx("div", { className: "text-2xl font-bold", children: stat.value }),
1375
+ /* @__PURE__ */ jsxs("p", { className: "text-xs text-muted-foreground", children: [
1376
+ /* @__PURE__ */ jsx("span", { className: "text-green-600", children: stat.trend }),
1377
+ " from last month"
1378
+ ] })
1379
+ ] })
1380
+ ] }, stat.title);
1381
+ }) }),
1382
+ /* @__PURE__ */ jsxs("div", { className: "grid gap-4 md:grid-cols-2", children: [
1383
+ /* @__PURE__ */ jsxs(Card, { children: [
1384
+ /* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsx(CardTitle, { children: "Recent Orders" }) }),
1385
+ /* @__PURE__ */ jsx(CardContent, { children: /* @__PURE__ */ jsx("div", { className: "space-y-4", children: orders?.data?.slice(0, 5).map((order) => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between border-b pb-2 last:border-0", children: [
1386
+ /* @__PURE__ */ jsxs("div", { children: [
1387
+ /* @__PURE__ */ jsxs("p", { className: "font-medium", children: [
1388
+ "#",
1389
+ order.orderNumber
1390
+ ] }),
1391
+ /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: order.customerEmail })
1392
+ ] }),
1393
+ /* @__PURE__ */ jsxs("div", { className: "text-right", children: [
1394
+ /* @__PURE__ */ jsxs("p", { className: "font-semibold", children: [
1395
+ "$",
1396
+ (order.total / 100).toFixed(2)
1397
+ ] }),
1398
+ /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground capitalize", children: order.paymentStatus })
1399
+ ] })
1400
+ ] }, order.id)) }) })
1401
+ ] }),
1402
+ /* @__PURE__ */ jsxs(Card, { children: [
1403
+ /* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsx(CardTitle, { children: "Top Products" }) }),
1404
+ /* @__PURE__ */ jsx(CardContent, { children: /* @__PURE__ */ jsx("div", { className: "space-y-4", children: products?.data?.slice(0, 5).map((product) => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between border-b pb-2 last:border-0", children: [
1405
+ /* @__PURE__ */ jsxs("div", { children: [
1406
+ /* @__PURE__ */ jsx("p", { className: "font-medium", children: product.name }),
1407
+ /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: product.sku })
1408
+ ] }),
1409
+ /* @__PURE__ */ jsxs("div", { className: "text-right", children: [
1410
+ /* @__PURE__ */ jsxs("p", { className: "font-semibold", children: [
1411
+ "$",
1412
+ (product.price / 100).toFixed(2)
1413
+ ] }),
1414
+ /* @__PURE__ */ jsxs("p", { className: "text-xs text-muted-foreground", children: [
1415
+ product.stock,
1416
+ " in stock"
1417
+ ] })
1418
+ ] })
1419
+ ] }, product.id)) }) })
1420
+ ] })
1421
+ ] })
1422
+ ] });
1423
+ }
1424
+
1425
+ // src/routes/index.tsx
1426
+ var Route2 = createRoute({
1427
+ getParentRoute: () => Route,
1428
+ path: "/",
1429
+ component: DashboardPage
1430
+ });
1431
+
1432
+ // src/routeTree.gen.ts
1433
+ var routeTree = Route.addChildren([
1434
+ Route2
1435
+ // ProductsRoute,
1436
+ // OrdersRoute,
1437
+ // CustomersRoute,
1438
+ // PaymentsRoute,
1439
+ // SettingsRoute,
1440
+ // UsersRoute,
1441
+ ]);
1442
+ function ManagoAdmin() {
1443
+ const { isAuthenticated } = useAuthStore();
1444
+ const hasHydrated = useHasHydrated();
1445
+ const router = useMemo(() => {
1446
+ if (typeof window === "undefined") return null;
1447
+ const browserHistory = createBrowserHistory();
1448
+ return createRouter({
1449
+ routeTree,
1450
+ history: browserHistory,
1451
+ basepath: "/admin"
1452
+ });
1453
+ }, []);
1454
+ if (!hasHydrated || !router) {
1455
+ return null;
1456
+ }
1457
+ if (!isAuthenticated) {
1458
+ return /* @__PURE__ */ jsx(LoginPage, {});
1459
+ }
1460
+ return /* @__PURE__ */ jsx(RouterProvider, { router });
1461
+ }
1462
+
1463
+ export { ManagoAdmin, ManagoProvider, useManagoAPI };
1464
+ //# sourceMappingURL=index.mjs.map
1465
+ //# sourceMappingURL=index.mjs.map