@traky-app/ui 1.0.0 → 1.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.
Files changed (68) hide show
  1. package/README.md +12 -19
  2. package/package.json +48 -3
  3. package/registry/traky/json/command.json +1 -1
  4. package/registry/traky/ui/command.tsx +1 -0
  5. package/src/hooks/use-document-theme.ts +25 -0
  6. package/src/hooks/use-mobile.ts +19 -0
  7. package/src/lib/disable-input-autofill.ts +23 -0
  8. package/src/lib/sidebar-persistence.ts +76 -0
  9. package/src/lib/utils.ts +30 -0
  10. package/src/ui/accordion.tsx +65 -0
  11. package/src/ui/alert-dialog.tsx +163 -0
  12. package/src/ui/alert.tsx +66 -0
  13. package/src/ui/animated-beam.tsx +185 -0
  14. package/src/ui/animated-list.tsx +71 -0
  15. package/src/ui/avatar.tsx +53 -0
  16. package/src/ui/badge.tsx +46 -0
  17. package/src/ui/bento-grid.tsx +109 -0
  18. package/src/ui/breadcrumb.tsx +108 -0
  19. package/src/ui/bubble.tsx +125 -0
  20. package/src/ui/button-group.tsx +83 -0
  21. package/src/ui/button.tsx +64 -0
  22. package/src/ui/calendar.tsx +213 -0
  23. package/src/ui/card.tsx +92 -0
  24. package/src/ui/carousel.tsx +240 -0
  25. package/src/ui/chart.tsx +380 -0
  26. package/src/ui/checkbox.tsx +31 -0
  27. package/src/ui/checkpoint.tsx +94 -0
  28. package/src/ui/code-block.tsx +232 -0
  29. package/src/ui/collapsible.tsx +33 -0
  30. package/src/ui/command.tsx +191 -0
  31. package/src/ui/context-menu.tsx +251 -0
  32. package/src/ui/dialog.tsx +142 -0
  33. package/src/ui/drawer.tsx +135 -0
  34. package/src/ui/dropdown-menu.tsx +256 -0
  35. package/src/ui/empty.tsx +104 -0
  36. package/src/ui/field.tsx +248 -0
  37. package/src/ui/globe.tsx +234 -0
  38. package/src/ui/hover-card.tsx +44 -0
  39. package/src/ui/input-group.tsx +170 -0
  40. package/src/ui/input-otp.tsx +77 -0
  41. package/src/ui/input.tsx +24 -0
  42. package/src/ui/item.tsx +193 -0
  43. package/src/ui/kbd.tsx +28 -0
  44. package/src/ui/label.tsx +24 -0
  45. package/src/ui/map.tsx +2226 -0
  46. package/src/ui/marker.tsx +69 -0
  47. package/src/ui/marquee.tsx +74 -0
  48. package/src/ui/message.tsx +92 -0
  49. package/src/ui/navigation-menu.tsx +169 -0
  50. package/src/ui/number-ticker.tsx +90 -0
  51. package/src/ui/pagination.tsx +122 -0
  52. package/src/ui/popover.tsx +48 -0
  53. package/src/ui/progress.tsx +31 -0
  54. package/src/ui/select.tsx +193 -0
  55. package/src/ui/separator.tsx +28 -0
  56. package/src/ui/sheet.tsx +143 -0
  57. package/src/ui/sidebar.tsx +764 -0
  58. package/src/ui/skeleton.tsx +13 -0
  59. package/src/ui/sonner.tsx +71 -0
  60. package/src/ui/spinner.tsx +15 -0
  61. package/src/ui/switch.tsx +41 -0
  62. package/src/ui/table.tsx +116 -0
  63. package/src/ui/tabs.tsx +66 -0
  64. package/src/ui/textarea.tsx +20 -0
  65. package/src/ui/toggle-group.tsx +83 -0
  66. package/src/ui/toggle.tsx +47 -0
  67. package/src/ui/tooltip.tsx +61 -0
  68. package/src/ui/trace.tsx +165 -0
package/README.md CHANGED
@@ -1,31 +1,24 @@
1
1
  # @traky-app/ui
2
2
 
3
- Registro oficial de componentes Traky (copy-paste, estilo shadcn, **sin** depender de `ui.shadcn.com`).
3
+ Registro Traky UI: fuentes y manifiestos JSON para instalar componentes en apps Next.js (patrón copy-paste, sin depender de shadcn).
4
4
 
5
- ## Estructura
5
+ ## Layout
6
6
 
7
7
  ```
8
- packages/ui/
9
- ├── registry/traky/
10
- │ ├── ui/ # fuente .tsx (59+ componentes)
11
- │ ├── lib/ # utils, sidebar-persistence, …
12
- │ ├── hooks/ # use-mobile, …
13
- │ ├── json/ # ítems generados (*.json)
14
- │ └── registry.json # índice
15
- ├── schema/components.json # plantilla components.json
16
- └── scripts/build-registry.mjs
8
+ registry/traky/
9
+ ├── ui/ # fuentes .tsx
10
+ ├── lib/ # utils, helpers del registro
11
+ ├── hooks/ # hooks referenciados por componentes
12
+ ├── json/ # ítems generados (*.json)
13
+ └── registry.json
17
14
  ```
18
15
 
19
- ## Generar JSON del registro
20
-
21
- Tras editar fuentes en `registry/traky/ui/`:
16
+ ## Build del registro
22
17
 
23
18
  ```bash
24
- pnpm --filter @traky-app/ui registry:build
19
+ pnpm registry:build
25
20
  ```
26
21
 
27
- Commitea `registry/traky/json/` para que funcione la URL raw de GitHub.
28
-
29
- ## Consumir desde app-traky
22
+ Publicación: release en GitHub (tag `v` + `version` de este `package.json`) → workflow `publish.yml`. Manual: `npm publish --access public` (2FA/token).
30
23
 
31
- Ver `@traky-app/cli` y [REGISTRY.md](../../REGISTRY.md) en la raíz del monorepo.
24
+ Guía completa: [REGISTRY.md](../../REGISTRY.md) en la raíz del monorepo.
package/package.json CHANGED
@@ -1,17 +1,19 @@
1
1
  {
2
2
  "name": "@traky-app/ui",
3
- "version": "1.0.0",
4
- "description": "Registro Traky UI — componentes copy-paste (sin depender del registro shadcn)",
3
+ "version": "1.1.0",
4
+ "description": "Componentes Traky UI para importar desde @traky-app/ui, más el registro copy-paste.",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "files": [
8
+ "src",
8
9
  "registry",
9
10
  "schema",
10
11
  "README.md"
11
12
  ],
12
13
  "exports": {
13
14
  "./registry/*": "./registry/*",
14
- "./schema/components.json": "./schema/components.json"
15
+ "./schema/components.json": "./schema/components.json",
16
+ "./*": "./src/ui/*.tsx"
15
17
  },
16
18
  "scripts": {
17
19
  "registry:build": "node ./scripts/build-registry.mjs",
@@ -24,5 +26,48 @@
24
26
  },
25
27
  "publishConfig": {
26
28
  "access": "public"
29
+ },
30
+ "sideEffects": [
31
+ "**/*.css"
32
+ ],
33
+ "peerDependencies": {
34
+ "react": "^19.0.0",
35
+ "react-dom": "^19.0.0"
36
+ },
37
+ "dependencies": {
38
+ "@radix-ui/react-accordion": "^1.2.20",
39
+ "@radix-ui/react-alert-dialog": "^1.1.23",
40
+ "@radix-ui/react-avatar": "^1.2.6",
41
+ "@radix-ui/react-checkbox": "^1.3.11",
42
+ "@radix-ui/react-collapsible": "^1.1.20",
43
+ "@radix-ui/react-context-menu": "^2.4.1",
44
+ "@radix-ui/react-dialog": "^1.1.23",
45
+ "@radix-ui/react-dropdown-menu": "^2.1.24",
46
+ "@radix-ui/react-hover-card": "^1.1.23",
47
+ "@radix-ui/react-label": "^2.1.15",
48
+ "@radix-ui/react-navigation-menu": "^1.2.22",
49
+ "@radix-ui/react-popover": "^1.1.23",
50
+ "@radix-ui/react-select": "^2.3.7",
51
+ "@radix-ui/react-slot": "^1.3.3",
52
+ "@radix-ui/react-tabs": "^1.1.21",
53
+ "@radix-ui/react-toggle": "^1.1.18",
54
+ "@radix-ui/react-toggle-group": "^1.1.19",
55
+ "@radix-ui/react-tooltip": "^1.2.16",
56
+ "@tabler/icons-react": "^3.46.0",
57
+ "@types/geojson": "^7946.0.16",
58
+ "class-variance-authority": "^0.7.1",
59
+ "clsx": "^2.1.1",
60
+ "cmdk": "^1.1.1",
61
+ "cobe": "^0.6.5",
62
+ "embla-carousel-react": "^8.6.0",
63
+ "input-otp": "^1.5.0",
64
+ "maplibre-gl": "^6.9.1",
65
+ "motion": "^13.3.0",
66
+ "radix-ui": "^1.6.7",
67
+ "react-day-picker": "^10.0.2",
68
+ "recharts": "^3.10.1",
69
+ "sonner": "^2.0.8",
70
+ "tailwind-merge": "^3.7.0",
71
+ "vaul": "^1.1.2"
27
72
  }
28
73
  }
@@ -14,7 +14,7 @@
14
14
  "files": [
15
15
  {
16
16
  "path": "ui/command.tsx",
17
- "content": "\"use client\"\n\nimport { IconSearch } from \"@tabler/icons-react\";\nimport * as React from \"react\"\nimport { Command as CommandPrimitive } from \"cmdk\"\nimport { DISABLE_INPUT_AUTOFILL } from \"@/lib/disable-input-autofill\"\nimport { cn } from \"@/lib/utils\"\nimport {\n Dialog,\n DialogContent,\n DialogDescription,\n DialogHeader,\n DialogTitle,\n} from \"@/components/ui/dialog\"\n\nfunction Command({\n className,\n ...props\n}: React.ComponentProps<typeof CommandPrimitive>) {\n return (\n <CommandPrimitive\n data-slot=\"command\"\n className={cn(\n \"bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction CommandDialog({\n title = \"Command Palette\",\n description = \"Search for a command to run...\",\n children,\n className,\n showCloseButton = true,\n ...props\n}: React.ComponentProps<typeof Dialog> & {\n title?: string\n description?: string\n className?: string\n showCloseButton?: boolean\n}) {\n return (\n <Dialog {...props}>\n <DialogHeader className=\"sr-only\">\n <DialogTitle>{title}</DialogTitle>\n <DialogDescription>{description}</DialogDescription>\n </DialogHeader>\n <DialogContent\n className={cn(\"overflow-hidden p-0\", className)}\n showCloseButton={showCloseButton}\n >\n <Command className=\"[&_[cmdk-group-heading]]:text-muted-foreground **:data-[slot=command-input-wrapper]:h-12 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5\">\n {children}\n </Command>\n </DialogContent>\n </Dialog>\n )\n}\n\nfunction CommandInput({\n className,\n name,\n ...props\n}: React.ComponentProps<typeof CommandPrimitive.Input>) {\n return (\n <div\n data-slot=\"command-input-wrapper\"\n className=\"flex h-9 items-center gap-2 border-b px-3\"\n >\n <IconSearch className=\"size-4 shrink-0 opacity-50\" />\n <CommandPrimitive.Input\n data-slot=\"command-input\"\n // type=search + anti-autofill: evita iCloud Password / gestores\n // en “Buscar usuario”, “Buscar dirección”, etc.\n {...DISABLE_INPUT_AUTOFILL}\n enterKeyHint=\"search\"\n name={name ?? \"traky-command-search\"}\n className={cn(\n \"placeholder:text-muted-foreground flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50\",\n className\n )}\n {...props}\n />\n </div>\n )\n}\n\nfunction CommandList({\n className,\n ...props\n}: React.ComponentProps<typeof CommandPrimitive.List>) {\n return (\n <CommandPrimitive.List\n data-slot=\"command-list\"\n className={cn(\n \"max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction CommandEmpty({\n ...props\n}: React.ComponentProps<typeof CommandPrimitive.Empty>) {\n return (\n <CommandPrimitive.Empty\n data-slot=\"command-empty\"\n className=\"py-6 text-center text-sm\"\n {...props}\n />\n )\n}\n\nfunction CommandGroup({\n className,\n ...props\n}: React.ComponentProps<typeof CommandPrimitive.Group>) {\n return (\n <CommandPrimitive.Group\n data-slot=\"command-group\"\n className={cn(\n \"text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction CommandSeparator({\n className,\n ...props\n}: React.ComponentProps<typeof CommandPrimitive.Separator>) {\n return (\n <CommandPrimitive.Separator\n data-slot=\"command-separator\"\n className={cn(\"bg-border -mx-1 h-px\", className)}\n {...props}\n />\n )\n}\n\nfunction CommandItem({\n className,\n ...props\n}: React.ComponentProps<typeof CommandPrimitive.Item>) {\n return (\n <CommandPrimitive.Item\n data-slot=\"command-item\"\n className={cn(\n \"data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction CommandShortcut({\n className,\n ...props\n}: React.ComponentProps<\"span\">) {\n return (\n <span\n data-slot=\"command-shortcut\"\n className={cn(\n \"text-muted-foreground ml-auto text-xs tracking-widest\",\n className\n )}\n {...props}\n />\n )\n}\n\nexport {\n Command,\n CommandDialog,\n CommandInput,\n CommandList,\n CommandEmpty,\n CommandGroup,\n CommandItem,\n CommandShortcut,\n CommandSeparator,\n}\n",
17
+ "content": "\"use client\"\n\nimport { IconSearch } from \"@tabler/icons-react\";\nimport * as React from \"react\"\nimport { Command as CommandPrimitive } from \"cmdk\"\nimport { DISABLE_INPUT_AUTOFILL } from \"@/lib/disable-input-autofill\"\nimport { cn } from \"@/lib/utils\"\nimport {\n Dialog,\n DialogContent,\n DialogDescription,\n DialogHeader,\n DialogTitle,\n} from \"@/components/ui/dialog\"\n\nfunction Command({\n className,\n ...props\n}: React.ComponentProps<typeof CommandPrimitive>) {\n return (\n <CommandPrimitive\n data-slot=\"command\"\n className={cn(\n \"bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction CommandDialog({\n title = \"Command Palette\",\n description = \"Search for a command to run...\",\n children,\n className,\n showCloseButton = true,\n ...props\n}: React.ComponentProps<typeof Dialog> & {\n title?: string\n description?: string\n className?: string\n showCloseButton?: boolean\n}) {\n return (\n <Dialog {...props}>\n <DialogHeader className=\"sr-only\">\n <DialogTitle>{title}</DialogTitle>\n <DialogDescription>{description}</DialogDescription>\n </DialogHeader>\n <DialogContent\n className={cn(\"overflow-hidden p-0\", className)}\n showCloseButton={showCloseButton}\n >\n <Command className=\"[&_[cmdk-group-heading]]:text-muted-foreground **:data-[slot=command-input-wrapper]:h-12 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5\">\n {children}\n </Command>\n </DialogContent>\n </Dialog>\n )\n}\n\nfunction CommandInput({\n className,\n name,\n ...props\n}: React.ComponentProps<typeof CommandPrimitive.Input>) {\n return (\n <div\n data-slot=\"command-input-wrapper\"\n className=\"flex h-9 items-center gap-2 border-b px-3\"\n >\n <IconSearch className=\"size-4 shrink-0 opacity-50\" />\n <CommandPrimitive.Input\n data-slot=\"command-input\"\n // type=search + anti-autofill: evita iCloud Password / gestores\n // en “Buscar usuario”, “Buscar dirección”, etc.\n {...DISABLE_INPUT_AUTOFILL}\n type=\"search\"\n enterKeyHint=\"search\"\n name={name ?? \"traky-command-search\"}\n className={cn(\n \"placeholder:text-muted-foreground flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50\",\n className\n )}\n {...props}\n />\n </div>\n )\n}\n\nfunction CommandList({\n className,\n ...props\n}: React.ComponentProps<typeof CommandPrimitive.List>) {\n return (\n <CommandPrimitive.List\n data-slot=\"command-list\"\n className={cn(\n \"max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction CommandEmpty({\n ...props\n}: React.ComponentProps<typeof CommandPrimitive.Empty>) {\n return (\n <CommandPrimitive.Empty\n data-slot=\"command-empty\"\n className=\"py-6 text-center text-sm\"\n {...props}\n />\n )\n}\n\nfunction CommandGroup({\n className,\n ...props\n}: React.ComponentProps<typeof CommandPrimitive.Group>) {\n return (\n <CommandPrimitive.Group\n data-slot=\"command-group\"\n className={cn(\n \"text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction CommandSeparator({\n className,\n ...props\n}: React.ComponentProps<typeof CommandPrimitive.Separator>) {\n return (\n <CommandPrimitive.Separator\n data-slot=\"command-separator\"\n className={cn(\"bg-border -mx-1 h-px\", className)}\n {...props}\n />\n )\n}\n\nfunction CommandItem({\n className,\n ...props\n}: React.ComponentProps<typeof CommandPrimitive.Item>) {\n return (\n <CommandPrimitive.Item\n data-slot=\"command-item\"\n className={cn(\n \"data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction CommandShortcut({\n className,\n ...props\n}: React.ComponentProps<\"span\">) {\n return (\n <span\n data-slot=\"command-shortcut\"\n className={cn(\n \"text-muted-foreground ml-auto text-xs tracking-widest\",\n className\n )}\n {...props}\n />\n )\n}\n\nexport {\n Command,\n CommandDialog,\n CommandInput,\n CommandList,\n CommandEmpty,\n CommandGroup,\n CommandItem,\n CommandShortcut,\n CommandSeparator,\n}\n",
18
18
  "type": "registry:ui",
19
19
  "target": ""
20
20
  }
@@ -76,6 +76,7 @@ function CommandInput({
76
76
  // type=search + anti-autofill: evita iCloud Password / gestores
77
77
  // en “Buscar usuario”, “Buscar dirección”, etc.
78
78
  {...DISABLE_INPUT_AUTOFILL}
79
+ type="search"
79
80
  enterKeyHint="search"
80
81
  name={name ?? "traky-command-search"}
81
82
  className={cn(
@@ -0,0 +1,25 @@
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+
5
+ type Theme = "light" | "dark" | "system";
6
+
7
+ /** Lee la clase `light` / `dark` del documento. Sirve con el ThemeProvider de cada app. */
8
+ export function useTheme() {
9
+ const [theme, setTheme] = React.useState<Theme>("system");
10
+
11
+ React.useEffect(() => {
12
+ const root = document.documentElement;
13
+ const read = () => {
14
+ if (root.classList.contains("dark")) setTheme("dark");
15
+ else if (root.classList.contains("light")) setTheme("light");
16
+ else setTheme("system");
17
+ };
18
+ read();
19
+ const observer = new MutationObserver(read);
20
+ observer.observe(root, { attributes: true, attributeFilter: ["class"] });
21
+ return () => observer.disconnect();
22
+ }, []);
23
+
24
+ return { theme };
25
+ }
@@ -0,0 +1,19 @@
1
+ import * as React from "react"
2
+
3
+ const MOBILE_BREAKPOINT = 768
4
+
5
+ export function useIsMobile() {
6
+ const [isMobile, setIsMobile] = React.useState<boolean | undefined>(undefined)
7
+
8
+ React.useEffect(() => {
9
+ const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`)
10
+ const onChange = () => {
11
+ setIsMobile(window.innerWidth < MOBILE_BREAKPOINT)
12
+ }
13
+ mql.addEventListener("change", onChange)
14
+ setIsMobile(window.innerWidth < MOBILE_BREAKPOINT)
15
+ return () => mql.removeEventListener("change", onChange)
16
+ }, [])
17
+
18
+ return !!isMobile
19
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Atributos para evitar autocompletado de Safari/iCloud, Chrome,
3
+ * 1Password, LastPass, Bitwarden, etc. en buscadores y campos de datos.
4
+ *
5
+ * Los formularios de auth deben pasar `autoComplete` explícito
6
+ * (`email`, `current-password`, …) para anular estos defaults.
7
+ */
8
+ export const DISABLE_INPUT_AUTOFILL = {
9
+ autoComplete: "off",
10
+ autoCorrect: "off",
11
+ autoCapitalize: "off",
12
+ spellCheck: false,
13
+ /** 1Password */
14
+ "data-1p-ignore": true,
15
+ /** LastPass */
16
+ "data-lpignore": "true",
17
+ /** Bitwarden */
18
+ "data-bwignore": "true",
19
+ /** Proton Pass */
20
+ "data-protonpass-ignore": "true",
21
+ /** Heurística genérica de gestores */
22
+ "data-form-type": "other",
23
+ } as const;
@@ -0,0 +1,76 @@
1
+ /** Estado abierto/cerrado del panel lateral (desktop). */
2
+ export const SIDEBAR_OPEN_STORAGE_KEY = "traky.sidebar.open";
3
+
4
+ /** Prefijo para grupos colapsables de NavMain por sección (`/enterprise`, `/admin`, …). */
5
+ export const SIDEBAR_NAV_GROUPS_PREFIX = "traky.sidebar.nav-groups:";
6
+
7
+ export function readSidebarOpen(fallback = true): boolean {
8
+ if (typeof window === "undefined") return fallback;
9
+ try {
10
+ const stored = localStorage.getItem(SIDEBAR_OPEN_STORAGE_KEY);
11
+ if (stored === "true") return true;
12
+ if (stored === "false") return false;
13
+ const match = document.cookie.match(/(?:^|;\s*)sidebar_state=([^;]+)/);
14
+ if (match) return match[1] === "true";
15
+ } catch {
16
+ /* storage bloqueado */
17
+ }
18
+ return fallback;
19
+ }
20
+
21
+ export function writeSidebarOpen(open: boolean): void {
22
+ if (typeof window === "undefined") return;
23
+ try {
24
+ localStorage.setItem(SIDEBAR_OPEN_STORAGE_KEY, String(open));
25
+ } catch {
26
+ /* storage bloqueado */
27
+ }
28
+ }
29
+
30
+ export function navGroupsStorageKey(linkPrefix: string): string {
31
+ return `${SIDEBAR_NAV_GROUPS_PREFIX}${linkPrefix}`;
32
+ }
33
+
34
+ type NavGroupItem = {
35
+ title: string;
36
+ isActive?: boolean;
37
+ items?: unknown[];
38
+ };
39
+
40
+ function buildDefaultNavGroups(items: NavGroupItem[]): Record<string, boolean> {
41
+ return Object.fromEntries(
42
+ items
43
+ .filter((item) => item.items && item.items.length > 0)
44
+ .map((item) => [item.title, item.isActive === true]),
45
+ );
46
+ }
47
+
48
+ export function readNavGroupsOpen(
49
+ linkPrefix: string,
50
+ items: NavGroupItem[],
51
+ ): Record<string, boolean> {
52
+ const defaults = buildDefaultNavGroups(items);
53
+ if (typeof window === "undefined") return defaults;
54
+
55
+ try {
56
+ const raw = localStorage.getItem(navGroupsStorageKey(linkPrefix));
57
+ if (!raw) return defaults;
58
+ const parsed = JSON.parse(raw) as Record<string, boolean>;
59
+ if (typeof parsed !== "object" || parsed === null) return defaults;
60
+ return { ...defaults, ...parsed };
61
+ } catch {
62
+ return defaults;
63
+ }
64
+ }
65
+
66
+ export function writeNavGroupsOpen(
67
+ linkPrefix: string,
68
+ state: Record<string, boolean>,
69
+ ): void {
70
+ if (typeof window === "undefined") return;
71
+ try {
72
+ localStorage.setItem(navGroupsStorageKey(linkPrefix), JSON.stringify(state));
73
+ } catch {
74
+ /* storage bloqueado */
75
+ }
76
+ }
@@ -0,0 +1,30 @@
1
+ import { clsx, type ClassValue } from "clsx"
2
+ import { twMerge } from "tailwind-merge"
3
+
4
+ export function cn(...inputs: ClassValue[]) {
5
+ return twMerge(clsx(inputs))
6
+ }
7
+
8
+ /** Quita tildes, apóstrofos, comas y pasa a minúsculas (méx → mex, mexico, → mexico). */
9
+ export function normalizeSearchText(value: string): string {
10
+ return value
11
+ .normalize("NFD")
12
+ .replace(/[\u0300-\u036f]/g, "")
13
+ .replace(/[''`´’]/g, "")
14
+ .replace(/[,.;:¡!¿?()[\]{}«»""„]/g, " ")
15
+ .replace(/\s+/g, " ")
16
+ .toLowerCase()
17
+ .trim()
18
+ }
19
+
20
+ /** Filtro cmdk insensible a acentos y mayúsculas. */
21
+ export function commandFilterAccentInsensitive(
22
+ value: string,
23
+ search: string,
24
+ ): number {
25
+ const normalizedValue = normalizeSearchText(value)
26
+ const normalizedSearch = normalizeSearchText(search)
27
+ if (!normalizedSearch) return 1
28
+ return normalizedValue.includes(normalizedSearch) ? 1 : 0
29
+ }
30
+
@@ -0,0 +1,65 @@
1
+ "use client"
2
+
3
+ import { IconChevronDown } from "@tabler/icons-react";
4
+ import * as React from "react"
5
+ import * as AccordionPrimitive from "@radix-ui/react-accordion"
6
+ import { cn } from "../lib/utils"
7
+
8
+ function Accordion({
9
+ ...props
10
+ }: React.ComponentProps<typeof AccordionPrimitive.Root>) {
11
+ return <AccordionPrimitive.Root data-slot="accordion" {...props} />
12
+ }
13
+
14
+ function AccordionItem({
15
+ className,
16
+ ...props
17
+ }: React.ComponentProps<typeof AccordionPrimitive.Item>) {
18
+ return (
19
+ <AccordionPrimitive.Item
20
+ data-slot="accordion-item"
21
+ className={cn("border-b last:border-b-0", className)}
22
+ {...props}
23
+ />
24
+ )
25
+ }
26
+
27
+ function AccordionTrigger({
28
+ className,
29
+ children,
30
+ ...props
31
+ }: React.ComponentProps<typeof AccordionPrimitive.Trigger>) {
32
+ return (
33
+ <AccordionPrimitive.Header className="flex">
34
+ <AccordionPrimitive.Trigger
35
+ data-slot="accordion-trigger"
36
+ className={cn(
37
+ "focus-visible:border-ring focus-visible:ring-ring/50 flex flex-1 items-start justify-between gap-4 rounded-md py-4 text-left text-sm font-medium transition-all outline-none hover:underline focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 [&[data-state=open]>svg]:rotate-180",
38
+ className
39
+ )}
40
+ {...props}
41
+ >
42
+ {children}
43
+ <IconChevronDown className="text-muted-foreground pointer-events-none size-4 shrink-0 translate-y-0.5 transition-transform duration-200" />
44
+ </AccordionPrimitive.Trigger>
45
+ </AccordionPrimitive.Header>
46
+ )
47
+ }
48
+
49
+ function AccordionContent({
50
+ className,
51
+ children,
52
+ ...props
53
+ }: React.ComponentProps<typeof AccordionPrimitive.Content>) {
54
+ return (
55
+ <AccordionPrimitive.Content
56
+ data-slot="accordion-content"
57
+ className="data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden text-sm"
58
+ {...props}
59
+ >
60
+ <div className={cn("pt-0 pb-4", className)}>{children}</div>
61
+ </AccordionPrimitive.Content>
62
+ )
63
+ }
64
+
65
+ export { Accordion, AccordionItem, AccordionTrigger, AccordionContent }
@@ -0,0 +1,163 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog"
5
+
6
+ import { cn } from "../lib/utils"
7
+ import { buttonVariants } from "./button"
8
+
9
+ function AlertDialog({
10
+ ...props
11
+ }: React.ComponentProps<typeof AlertDialogPrimitive.Root>) {
12
+ return <AlertDialogPrimitive.Root data-slot="alert-dialog" {...props} />
13
+ }
14
+
15
+ function AlertDialogTrigger({
16
+ ...props
17
+ }: React.ComponentProps<typeof AlertDialogPrimitive.Trigger>) {
18
+ return (
19
+ <AlertDialogPrimitive.Trigger data-slot="alert-dialog-trigger" {...props} />
20
+ )
21
+ }
22
+
23
+ function AlertDialogPortal({
24
+ ...props
25
+ }: React.ComponentProps<typeof AlertDialogPrimitive.Portal>) {
26
+ return (
27
+ <AlertDialogPrimitive.Portal data-slot="alert-dialog-portal" {...props} />
28
+ )
29
+ }
30
+
31
+ function AlertDialogOverlay({
32
+ className,
33
+ ...props
34
+ }: React.ComponentProps<typeof AlertDialogPrimitive.Overlay>) {
35
+ return (
36
+ <AlertDialogPrimitive.Overlay
37
+ data-slot="alert-dialog-overlay"
38
+ className={cn(
39
+ "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",
40
+ className
41
+ )}
42
+ {...props}
43
+ />
44
+ )
45
+ }
46
+
47
+ function AlertDialogContent({
48
+ className,
49
+ size = "default",
50
+ ...props
51
+ }: React.ComponentProps<typeof AlertDialogPrimitive.Content> & {
52
+ size?: "default" | "lg"
53
+ }) {
54
+ return (
55
+ <AlertDialogPortal>
56
+ <AlertDialogOverlay />
57
+ <AlertDialogPrimitive.Content
58
+ data-slot="alert-dialog-content"
59
+ className={cn(
60
+ "bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 w-full translate-x-[-50%] translate-y-[-50%] rounded-lg border shadow-lg duration-200",
61
+ size === "lg"
62
+ ? "flex max-h-[92dvh] max-w-[calc(100%-1.25rem)] flex-col gap-0 overflow-hidden p-0 sm:max-w-5xl"
63
+ : "grid max-w-[calc(100%-2rem)] gap-4 p-6 sm:max-w-lg",
64
+ className
65
+ )}
66
+ {...props}
67
+ />
68
+ </AlertDialogPortal>
69
+ )
70
+ }
71
+
72
+ function AlertDialogHeader({
73
+ className,
74
+ ...props
75
+ }: React.ComponentProps<"div">) {
76
+ return (
77
+ <div
78
+ data-slot="alert-dialog-header"
79
+ className={cn("flex flex-col gap-2 text-center sm:text-left", className)}
80
+ {...props}
81
+ />
82
+ )
83
+ }
84
+
85
+ function AlertDialogFooter({
86
+ className,
87
+ ...props
88
+ }: React.ComponentProps<"div">) {
89
+ return (
90
+ <div
91
+ data-slot="alert-dialog-footer"
92
+ className={cn(
93
+ "flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",
94
+ className
95
+ )}
96
+ {...props}
97
+ />
98
+ )
99
+ }
100
+
101
+ function AlertDialogTitle({
102
+ className,
103
+ ...props
104
+ }: React.ComponentProps<typeof AlertDialogPrimitive.Title>) {
105
+ return (
106
+ <AlertDialogPrimitive.Title
107
+ data-slot="alert-dialog-title"
108
+ className={cn("text-lg font-semibold", className)}
109
+ {...props}
110
+ />
111
+ )
112
+ }
113
+
114
+ function AlertDialogDescription({
115
+ className,
116
+ ...props
117
+ }: React.ComponentProps<typeof AlertDialogPrimitive.Description>) {
118
+ return (
119
+ <AlertDialogPrimitive.Description
120
+ data-slot="alert-dialog-description"
121
+ className={cn("text-muted-foreground text-sm", className)}
122
+ {...props}
123
+ />
124
+ )
125
+ }
126
+
127
+ function AlertDialogAction({
128
+ className,
129
+ ...props
130
+ }: React.ComponentProps<typeof AlertDialogPrimitive.Action>) {
131
+ return (
132
+ <AlertDialogPrimitive.Action
133
+ className={cn(buttonVariants(), className)}
134
+ {...props}
135
+ />
136
+ )
137
+ }
138
+
139
+ function AlertDialogCancel({
140
+ className,
141
+ ...props
142
+ }: React.ComponentProps<typeof AlertDialogPrimitive.Cancel>) {
143
+ return (
144
+ <AlertDialogPrimitive.Cancel
145
+ className={cn(buttonVariants({ variant: "outline" }), className)}
146
+ {...props}
147
+ />
148
+ )
149
+ }
150
+
151
+ export {
152
+ AlertDialog,
153
+ AlertDialogPortal,
154
+ AlertDialogOverlay,
155
+ AlertDialogTrigger,
156
+ AlertDialogContent,
157
+ AlertDialogHeader,
158
+ AlertDialogFooter,
159
+ AlertDialogTitle,
160
+ AlertDialogDescription,
161
+ AlertDialogAction,
162
+ AlertDialogCancel,
163
+ }
@@ -0,0 +1,66 @@
1
+ import * as React from "react"
2
+ import { cva, type VariantProps } from "class-variance-authority"
3
+
4
+ import { cn } from "../lib/utils"
5
+
6
+ const alertVariants = cva(
7
+ "relative w-full rounded-lg border px-4 py-3 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current",
8
+ {
9
+ variants: {
10
+ variant: {
11
+ default: "bg-card text-card-foreground",
12
+ destructive:
13
+ "text-destructive bg-card [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90",
14
+ },
15
+ },
16
+ defaultVariants: {
17
+ variant: "default",
18
+ },
19
+ }
20
+ )
21
+
22
+ function Alert({
23
+ className,
24
+ variant,
25
+ ...props
26
+ }: React.ComponentProps<"div"> & VariantProps<typeof alertVariants>) {
27
+ return (
28
+ <div
29
+ data-slot="alert"
30
+ role="alert"
31
+ className={cn(alertVariants({ variant }), className)}
32
+ {...props}
33
+ />
34
+ )
35
+ }
36
+
37
+ function AlertTitle({ className, ...props }: React.ComponentProps<"div">) {
38
+ return (
39
+ <div
40
+ data-slot="alert-title"
41
+ className={cn(
42
+ "col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight",
43
+ className
44
+ )}
45
+ {...props}
46
+ />
47
+ )
48
+ }
49
+
50
+ function AlertDescription({
51
+ className,
52
+ ...props
53
+ }: React.ComponentProps<"div">) {
54
+ return (
55
+ <div
56
+ data-slot="alert-description"
57
+ className={cn(
58
+ "text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed",
59
+ className
60
+ )}
61
+ {...props}
62
+ />
63
+ )
64
+ }
65
+
66
+ export { Alert, AlertTitle, AlertDescription }