@traky-app/ui 1.0.0 → 1.2.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/README.md +12 -19
- package/package.json +50 -3
- package/registry/traky/json/command.json +1 -1
- package/registry/traky/json/icon.json +17 -0
- package/registry/traky/json/logo.json +17 -0
- package/registry/traky/registry.json +20 -0
- package/registry/traky/ui/command.tsx +2 -0
- package/registry/traky/ui/icon.tsx +71 -0
- package/registry/traky/ui/logo.tsx +77 -0
- package/src/hooks/use-document-theme.ts +25 -0
- package/src/hooks/use-mobile.ts +19 -0
- package/src/lib/disable-input-autofill.ts +23 -0
- package/src/lib/sidebar-persistence.ts +76 -0
- package/src/lib/utils.ts +30 -0
- package/src/ui/accordion.tsx +65 -0
- package/src/ui/alert-dialog.tsx +163 -0
- package/src/ui/alert.tsx +66 -0
- package/src/ui/animated-beam.tsx +185 -0
- package/src/ui/animated-list.tsx +71 -0
- package/src/ui/avatar.tsx +53 -0
- package/src/ui/badge.tsx +46 -0
- package/src/ui/bento-grid.tsx +109 -0
- package/src/ui/breadcrumb.tsx +108 -0
- package/src/ui/bubble.tsx +125 -0
- package/src/ui/button-group.tsx +83 -0
- package/src/ui/button.tsx +64 -0
- package/src/ui/calendar.tsx +213 -0
- package/src/ui/card.tsx +92 -0
- package/src/ui/carousel.tsx +240 -0
- package/src/ui/chart.tsx +380 -0
- package/src/ui/checkbox.tsx +31 -0
- package/src/ui/checkpoint.tsx +94 -0
- package/src/ui/code-block.tsx +232 -0
- package/src/ui/collapsible.tsx +33 -0
- package/src/ui/command.tsx +192 -0
- package/src/ui/context-menu.tsx +251 -0
- package/src/ui/dialog.tsx +142 -0
- package/src/ui/drawer.tsx +135 -0
- package/src/ui/dropdown-menu.tsx +256 -0
- package/src/ui/empty.tsx +104 -0
- package/src/ui/field.tsx +248 -0
- package/src/ui/globe.tsx +234 -0
- package/src/ui/hover-card.tsx +44 -0
- package/src/ui/icon.tsx +71 -0
- package/src/ui/input-group.tsx +170 -0
- package/src/ui/input-otp.tsx +77 -0
- package/src/ui/input.tsx +24 -0
- package/src/ui/item.tsx +193 -0
- package/src/ui/kbd.tsx +28 -0
- package/src/ui/label.tsx +24 -0
- package/src/ui/logo.tsx +77 -0
- package/src/ui/map.tsx +2226 -0
- package/src/ui/marker.tsx +69 -0
- package/src/ui/marquee.tsx +74 -0
- package/src/ui/message.tsx +92 -0
- package/src/ui/navigation-menu.tsx +169 -0
- package/src/ui/number-ticker.tsx +90 -0
- package/src/ui/pagination.tsx +122 -0
- package/src/ui/popover.tsx +48 -0
- package/src/ui/progress.tsx +31 -0
- package/src/ui/select.tsx +193 -0
- package/src/ui/separator.tsx +28 -0
- package/src/ui/sheet.tsx +143 -0
- package/src/ui/sidebar.tsx +764 -0
- package/src/ui/skeleton.tsx +13 -0
- package/src/ui/sonner.tsx +71 -0
- package/src/ui/spinner.tsx +15 -0
- package/src/ui/switch.tsx +41 -0
- package/src/ui/table.tsx +116 -0
- package/src/ui/tabs.tsx +66 -0
- package/src/ui/textarea.tsx +20 -0
- package/src/ui/toggle-group.tsx +83 -0
- package/src/ui/toggle.tsx +47 -0
- package/src/ui/tooltip.tsx +61 -0
- package/src/ui/trace.tsx +165 -0
package/README.md
CHANGED
|
@@ -1,31 +1,24 @@
|
|
|
1
1
|
# @traky-app/ui
|
|
2
2
|
|
|
3
|
-
Registro
|
|
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
|
-
##
|
|
5
|
+
## Layout
|
|
6
6
|
|
|
7
7
|
```
|
|
8
|
-
|
|
9
|
-
├──
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
##
|
|
20
|
-
|
|
21
|
-
Tras editar fuentes en `registry/traky/ui/`:
|
|
16
|
+
## Build del registro
|
|
22
17
|
|
|
23
18
|
```bash
|
|
24
|
-
pnpm
|
|
19
|
+
pnpm registry:build
|
|
25
20
|
```
|
|
26
21
|
|
|
27
|
-
|
|
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
|
-
|
|
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.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.2.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,50 @@
|
|
|
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
|
+
"@types/react": "^19.3.0",
|
|
59
|
+
"@types/react-dom": "^19.3.0",
|
|
60
|
+
"class-variance-authority": "^0.7.1",
|
|
61
|
+
"clsx": "^2.1.1",
|
|
62
|
+
"cmdk": "^1.1.1",
|
|
63
|
+
"cobe": "^0.6.5",
|
|
64
|
+
"embla-carousel-react": "^8.6.0",
|
|
65
|
+
"input-otp": "^1.5.0",
|
|
66
|
+
"maplibre-gl": "^6.9.1",
|
|
67
|
+
"motion": "^13.3.0",
|
|
68
|
+
"radix-ui": "^1.6.7",
|
|
69
|
+
"react-day-picker": "^10.0.2",
|
|
70
|
+
"recharts": "^3.10.1",
|
|
71
|
+
"sonner": "^2.0.8",
|
|
72
|
+
"tailwind-merge": "^3.7.0",
|
|
73
|
+
"vaul": "^1.1.2"
|
|
27
74
|
}
|
|
28
75
|
}
|
|
@@ -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 // cmdk omite `type` de sus props, pero el input sí lo recibe.\n {...({ type: \"search\" } as React.ComponentProps<typeof CommandPrimitive.Input>)}\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
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "icon",
|
|
4
|
+
"type": "registry:ui",
|
|
5
|
+
"author": "Traky (https://traky.app)",
|
|
6
|
+
"dependencies": [
|
|
7
|
+
"class-variance-authority"
|
|
8
|
+
],
|
|
9
|
+
"files": [
|
|
10
|
+
{
|
|
11
|
+
"path": "ui/icon.tsx",
|
|
12
|
+
"content": "import * as React from \"react\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\n\nimport { cn } from \"@/lib/utils\"\n\nconst iconVariants = cva(\"inline-flex items-start\", {\n variants: {\n variant: {\n green: \"text-[#a5dd64]\",\n blue: \"text-[#000b27]\",\n white: \"text-white\",\n },\n size: {\n xs: \"[&_svg]:h-6\",\n sm: \"[&_svg]:h-10\",\n md: \"[&_svg]:h-14\",\n lg: \"[&_svg]:h-20\",\n },\n },\n defaultVariants: {\n variant: \"green\",\n size: \"md\",\n },\n})\n\nconst ICON_PATH =\n \"M137.5,137.32c32.32-32.32,31.39-85.48-2.79-116.6-30.34-27.63-78.03-27.63-108.37,0C-2.4,46.89-7.62,88.67,10.67,120.51c7.17,12.47,18.17,22.28,31.67,27.27,11.56,4.27,23.9,5.5,33.94,3.23l-20.23,19.95,23.62,23.62s55.88-55.31,57.83-57.26ZM55.69,105.19c-13.7-13.7-13.7-35.99,0-49.69,13.7-13.7,35.99-13.7,49.69,0,13.7,13.7,13.7,35.99,0,49.69-13.7,13.7-35.99,13.7-49.69,0Z\"\n\ntype IconProps = React.ComponentProps<\"span\"> &\n VariantProps<typeof iconVariants> & {\n /** Muestra ® junto al isotipo. */\n registered?: boolean\n }\n\nfunction Icon({\n className,\n variant = \"green\",\n size = \"md\",\n registered = false,\n ...props\n}: IconProps) {\n return (\n <span\n data-slot=\"icon\"\n data-variant={variant}\n data-size={size}\n className={cn(iconVariants({ variant, size }), className)}\n {...props}\n >\n <svg\n viewBox=\"0 0 161.06 194.58\"\n role=\"img\"\n aria-label=\"Traky\"\n className=\"block w-auto fill-current\"\n >\n <path d={ICON_PATH} />\n </svg>\n {registered ? (\n <sup\n className=\"ml-0.5 text-[0.55em] leading-none font-semibold select-none opacity-80\"\n aria-hidden\n >\n ®\n </sup>\n ) : null}\n </span>\n )\n}\n\nexport { Icon, iconVariants }\nexport type { IconProps }\n",
|
|
13
|
+
"type": "registry:ui",
|
|
14
|
+
"target": ""
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "logo",
|
|
4
|
+
"type": "registry:ui",
|
|
5
|
+
"author": "Traky (https://traky.app)",
|
|
6
|
+
"dependencies": [
|
|
7
|
+
"class-variance-authority"
|
|
8
|
+
],
|
|
9
|
+
"files": [
|
|
10
|
+
{
|
|
11
|
+
"path": "ui/logo.tsx",
|
|
12
|
+
"content": "import * as React from \"react\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\n\nimport { cn } from \"@/lib/utils\"\n\nconst logoVariants = cva(\"inline-flex items-start\", {\n variants: {\n variant: {\n green: \"text-[#a5dd64]\",\n blue: \"text-[#000b27]\",\n white: \"text-white\",\n },\n size: {\n xs: \"[&_svg]:h-6\",\n sm: \"[&_svg]:h-10\",\n md: \"[&_svg]:h-14\",\n lg: \"[&_svg]:h-20\",\n },\n },\n defaultVariants: {\n variant: \"green\",\n size: \"md\",\n },\n})\n\nconst LOGO_PATHS = [\n \"M259.89,30.16l-12,44.79h-5.2c-14.45,0-17.26-8.8-14.36-19.61l6.76-25.24h-14.21l-6.76,25.24c-5,18.65,6.11,33.82,24.76,33.82h5.2l-1.84,6.08c-2.9,10.81-14.06,19.61-24.87,19.61h-16.38l-3.81,14.21h16.38c18.65,0,37.89-15.17,42.88-33.82l17.65-65.08h-14.21Z\",\n \"M15.4,55.45l2.72-10.15h28.64l4-14.91h-28.64L30.26,0h-14.21L1.2,55.45c-5,18.65,6.11,33.82,24.76,33.82h9.02l3.81-14.21h-9.02c-10.82,0-17.26-8.8-14.36-19.62Z\",\n \"M186.36,56.58l25.6-16.04,2.71-10.11h-10.01l-38.7,24.32,6.53-24.38h-13.6l-15.77,58.85h13.6l5.47-20.43h10.6c10.56,0,16.85,8.59,14.02,19.15l-.33,1.23h13.87l.33-1.23c3.91-14.61-2.31-27.01-14.32-31.35Z\",\n \"M122.83,28.78c-11.62,0-23.48,6.65-31.07,16.33l3.78-14.1h-4.37c-7.07,0-14.34,2.25-20.93,6.04l1.78-6.64h-15.15l-4.06,15.15h6.4c-5.58,5.6-9.85,12.4-11.81,19.68l-6.52,24.33h14.98s6.63-24.74,6.63-24.74c2.9-10.81,14.06-19.61,24.87-19.61h4.32c-3.18,4.09-5.62,8.7-6.93,13.6-4.44,16.56,5.43,30.03,21.99,30.03,6.5,0,13.07-2.1,18.94-5.62l-1.59,5.92h12.45s8-29.31,8.28-30.33c4.44-16.56-5.43-30.03-21.99-30.03ZM110.45,74.99c-8.91,0-14.22-7.25-11.84-16.17,2.39-8.91,11.59-16.17,20.5-16.17s14.22,7.25,11.84,16.17c-2.39,8.91-11.59,16.17-20.5,16.17Z\",\n] as const\n\ntype LogoProps = React.ComponentProps<\"span\"> &\n VariantProps<typeof logoVariants> & {\n /** Muestra ® junto al wordmark. */\n registered?: boolean\n }\n\nfunction Logo({\n className,\n variant = \"green\",\n size = \"md\",\n registered = false,\n ...props\n}: LogoProps) {\n return (\n <span\n data-slot=\"logo\"\n data-variant={variant}\n data-size={size}\n className={cn(logoVariants({ variant, size }), className)}\n {...props}\n >\n <svg\n viewBox=\"0 0 274.1 129.06\"\n role=\"img\"\n aria-label=\"Traky\"\n className=\"block w-auto fill-current\"\n >\n {LOGO_PATHS.map((d) => (\n <path key={d.slice(0, 12)} d={d} />\n ))}\n </svg>\n {registered ? (\n <sup\n className=\"ml-0.5 text-[0.55em] leading-none font-semibold select-none opacity-80\"\n aria-hidden\n >\n ®\n </sup>\n ) : null}\n </span>\n )\n}\n\nexport { Logo, logoVariants }\nexport type { LogoProps }\n",
|
|
13
|
+
"type": "registry:ui",
|
|
14
|
+
"target": ""
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
@@ -293,6 +293,16 @@
|
|
|
293
293
|
}
|
|
294
294
|
]
|
|
295
295
|
},
|
|
296
|
+
{
|
|
297
|
+
"name": "icon",
|
|
298
|
+
"type": "registry:ui",
|
|
299
|
+
"files": [
|
|
300
|
+
{
|
|
301
|
+
"path": "json/icon.json",
|
|
302
|
+
"type": "registry:file"
|
|
303
|
+
}
|
|
304
|
+
]
|
|
305
|
+
},
|
|
296
306
|
{
|
|
297
307
|
"name": "input-group",
|
|
298
308
|
"type": "registry:ui",
|
|
@@ -353,6 +363,16 @@
|
|
|
353
363
|
}
|
|
354
364
|
]
|
|
355
365
|
},
|
|
366
|
+
{
|
|
367
|
+
"name": "logo",
|
|
368
|
+
"type": "registry:ui",
|
|
369
|
+
"files": [
|
|
370
|
+
{
|
|
371
|
+
"path": "json/logo.json",
|
|
372
|
+
"type": "registry:file"
|
|
373
|
+
}
|
|
374
|
+
]
|
|
375
|
+
},
|
|
356
376
|
{
|
|
357
377
|
"name": "map",
|
|
358
378
|
"type": "registry:ui",
|
|
@@ -76,6 +76,8 @@ 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
|
+
// cmdk omite `type` de sus props, pero el input sí lo recibe.
|
|
80
|
+
{...({ type: "search" } as React.ComponentProps<typeof CommandPrimitive.Input>)}
|
|
79
81
|
enterKeyHint="search"
|
|
80
82
|
name={name ?? "traky-command-search"}
|
|
81
83
|
className={cn(
|
|
@@ -0,0 +1,71 @@
|
|
|
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 iconVariants = cva("inline-flex items-start", {
|
|
7
|
+
variants: {
|
|
8
|
+
variant: {
|
|
9
|
+
green: "text-[#a5dd64]",
|
|
10
|
+
blue: "text-[#000b27]",
|
|
11
|
+
white: "text-white",
|
|
12
|
+
},
|
|
13
|
+
size: {
|
|
14
|
+
xs: "[&_svg]:h-6",
|
|
15
|
+
sm: "[&_svg]:h-10",
|
|
16
|
+
md: "[&_svg]:h-14",
|
|
17
|
+
lg: "[&_svg]:h-20",
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
defaultVariants: {
|
|
21
|
+
variant: "green",
|
|
22
|
+
size: "md",
|
|
23
|
+
},
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
const ICON_PATH =
|
|
27
|
+
"M137.5,137.32c32.32-32.32,31.39-85.48-2.79-116.6-30.34-27.63-78.03-27.63-108.37,0C-2.4,46.89-7.62,88.67,10.67,120.51c7.17,12.47,18.17,22.28,31.67,27.27,11.56,4.27,23.9,5.5,33.94,3.23l-20.23,19.95,23.62,23.62s55.88-55.31,57.83-57.26ZM55.69,105.19c-13.7-13.7-13.7-35.99,0-49.69,13.7-13.7,35.99-13.7,49.69,0,13.7,13.7,13.7,35.99,0,49.69-13.7,13.7-35.99,13.7-49.69,0Z"
|
|
28
|
+
|
|
29
|
+
type IconProps = React.ComponentProps<"span"> &
|
|
30
|
+
VariantProps<typeof iconVariants> & {
|
|
31
|
+
/** Muestra ® junto al isotipo. */
|
|
32
|
+
registered?: boolean
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function Icon({
|
|
36
|
+
className,
|
|
37
|
+
variant = "green",
|
|
38
|
+
size = "md",
|
|
39
|
+
registered = false,
|
|
40
|
+
...props
|
|
41
|
+
}: IconProps) {
|
|
42
|
+
return (
|
|
43
|
+
<span
|
|
44
|
+
data-slot="icon"
|
|
45
|
+
data-variant={variant}
|
|
46
|
+
data-size={size}
|
|
47
|
+
className={cn(iconVariants({ variant, size }), className)}
|
|
48
|
+
{...props}
|
|
49
|
+
>
|
|
50
|
+
<svg
|
|
51
|
+
viewBox="0 0 161.06 194.58"
|
|
52
|
+
role="img"
|
|
53
|
+
aria-label="Traky"
|
|
54
|
+
className="block w-auto fill-current"
|
|
55
|
+
>
|
|
56
|
+
<path d={ICON_PATH} />
|
|
57
|
+
</svg>
|
|
58
|
+
{registered ? (
|
|
59
|
+
<sup
|
|
60
|
+
className="ml-0.5 text-[0.55em] leading-none font-semibold select-none opacity-80"
|
|
61
|
+
aria-hidden
|
|
62
|
+
>
|
|
63
|
+
®
|
|
64
|
+
</sup>
|
|
65
|
+
) : null}
|
|
66
|
+
</span>
|
|
67
|
+
)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export { Icon, iconVariants }
|
|
71
|
+
export type { IconProps }
|
|
@@ -0,0 +1,77 @@
|
|
|
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 logoVariants = cva("inline-flex items-start", {
|
|
7
|
+
variants: {
|
|
8
|
+
variant: {
|
|
9
|
+
green: "text-[#a5dd64]",
|
|
10
|
+
blue: "text-[#000b27]",
|
|
11
|
+
white: "text-white",
|
|
12
|
+
},
|
|
13
|
+
size: {
|
|
14
|
+
xs: "[&_svg]:h-6",
|
|
15
|
+
sm: "[&_svg]:h-10",
|
|
16
|
+
md: "[&_svg]:h-14",
|
|
17
|
+
lg: "[&_svg]:h-20",
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
defaultVariants: {
|
|
21
|
+
variant: "green",
|
|
22
|
+
size: "md",
|
|
23
|
+
},
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
const LOGO_PATHS = [
|
|
27
|
+
"M259.89,30.16l-12,44.79h-5.2c-14.45,0-17.26-8.8-14.36-19.61l6.76-25.24h-14.21l-6.76,25.24c-5,18.65,6.11,33.82,24.76,33.82h5.2l-1.84,6.08c-2.9,10.81-14.06,19.61-24.87,19.61h-16.38l-3.81,14.21h16.38c18.65,0,37.89-15.17,42.88-33.82l17.65-65.08h-14.21Z",
|
|
28
|
+
"M15.4,55.45l2.72-10.15h28.64l4-14.91h-28.64L30.26,0h-14.21L1.2,55.45c-5,18.65,6.11,33.82,24.76,33.82h9.02l3.81-14.21h-9.02c-10.82,0-17.26-8.8-14.36-19.62Z",
|
|
29
|
+
"M186.36,56.58l25.6-16.04,2.71-10.11h-10.01l-38.7,24.32,6.53-24.38h-13.6l-15.77,58.85h13.6l5.47-20.43h10.6c10.56,0,16.85,8.59,14.02,19.15l-.33,1.23h13.87l.33-1.23c3.91-14.61-2.31-27.01-14.32-31.35Z",
|
|
30
|
+
"M122.83,28.78c-11.62,0-23.48,6.65-31.07,16.33l3.78-14.1h-4.37c-7.07,0-14.34,2.25-20.93,6.04l1.78-6.64h-15.15l-4.06,15.15h6.4c-5.58,5.6-9.85,12.4-11.81,19.68l-6.52,24.33h14.98s6.63-24.74,6.63-24.74c2.9-10.81,14.06-19.61,24.87-19.61h4.32c-3.18,4.09-5.62,8.7-6.93,13.6-4.44,16.56,5.43,30.03,21.99,30.03,6.5,0,13.07-2.1,18.94-5.62l-1.59,5.92h12.45s8-29.31,8.28-30.33c4.44-16.56-5.43-30.03-21.99-30.03ZM110.45,74.99c-8.91,0-14.22-7.25-11.84-16.17,2.39-8.91,11.59-16.17,20.5-16.17s14.22,7.25,11.84,16.17c-2.39,8.91-11.59,16.17-20.5,16.17Z",
|
|
31
|
+
] as const
|
|
32
|
+
|
|
33
|
+
type LogoProps = React.ComponentProps<"span"> &
|
|
34
|
+
VariantProps<typeof logoVariants> & {
|
|
35
|
+
/** Muestra ® junto al wordmark. */
|
|
36
|
+
registered?: boolean
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function Logo({
|
|
40
|
+
className,
|
|
41
|
+
variant = "green",
|
|
42
|
+
size = "md",
|
|
43
|
+
registered = false,
|
|
44
|
+
...props
|
|
45
|
+
}: LogoProps) {
|
|
46
|
+
return (
|
|
47
|
+
<span
|
|
48
|
+
data-slot="logo"
|
|
49
|
+
data-variant={variant}
|
|
50
|
+
data-size={size}
|
|
51
|
+
className={cn(logoVariants({ variant, size }), className)}
|
|
52
|
+
{...props}
|
|
53
|
+
>
|
|
54
|
+
<svg
|
|
55
|
+
viewBox="0 0 274.1 129.06"
|
|
56
|
+
role="img"
|
|
57
|
+
aria-label="Traky"
|
|
58
|
+
className="block w-auto fill-current"
|
|
59
|
+
>
|
|
60
|
+
{LOGO_PATHS.map((d) => (
|
|
61
|
+
<path key={d.slice(0, 12)} d={d} />
|
|
62
|
+
))}
|
|
63
|
+
</svg>
|
|
64
|
+
{registered ? (
|
|
65
|
+
<sup
|
|
66
|
+
className="ml-0.5 text-[0.55em] leading-none font-semibold select-none opacity-80"
|
|
67
|
+
aria-hidden
|
|
68
|
+
>
|
|
69
|
+
®
|
|
70
|
+
</sup>
|
|
71
|
+
) : null}
|
|
72
|
+
</span>
|
|
73
|
+
)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export { Logo, logoVariants }
|
|
77
|
+
export type { LogoProps }
|
|
@@ -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
|
+
}
|
package/src/lib/utils.ts
ADDED
|
@@ -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 }
|