@j3ehcmz/ui 0.0.0-stage → 0.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/package.json CHANGED
@@ -1,6 +1,47 @@
1
1
  {
2
2
  "name": "@j3ehcmz/ui",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.0",
4
+ "description": "Sistema de diseño de los módulos del Portal HCMZ: tokens, tema Tailwind v4, barra de módulo y componentes.",
5
+ "type": "module",
6
+ "sideEffects": [
7
+ "*.css"
8
+ ],
9
+ "exports": {
10
+ ".": "./src/index.ts",
11
+ "./iconos": "./src/iconos/index.ts",
12
+ "./texto": "./src/texto.ts",
13
+ "./estilos.css": "./css/estilos.css"
14
+ },
15
+ "files": [
16
+ "src",
17
+ "css",
18
+ "fuentes",
19
+ "CHANGELOG.md"
20
+ ],
21
+ "scripts": {
22
+ "tipos": "tsc --noEmit -p . && tsc --noEmit -p demo",
23
+ "test": "bun test tests"
24
+ },
25
+ "peerDependencies": {
26
+ "lucide-react": ">=1.38.0",
27
+ "next": ">=16.3.0",
28
+ "react": ">=19.2.0",
29
+ "tailwindcss": ">=4.0.0"
30
+ },
31
+ "devDependencies": {
32
+ "@types/node": "^20",
33
+ "@types/react": "^19",
34
+ "lucide-react": "^1.47.0",
35
+ "next": "16.4.3",
36
+ "react": "19.2.8",
37
+ "typescript": "^5.9.0"
38
+ },
39
+ "publishConfig": {
40
+ "access": "public"
41
+ },
42
+ "repository": {
43
+ "type": "git",
44
+ "url": "git+https://github.com/JosueHCMZ/hcmz-ui.git"
45
+ },
46
+ "license": "UNLICENSED"
47
+ }
@@ -0,0 +1,37 @@
1
+ import { ICONOS, ALIAS, type NombreIcono } from "./registro";
2
+
3
+ type Props = {
4
+ /** Nombre del registro (kebab-case de Lucide) o alias del portal (`starlink`, `bien`…). */
5
+ nombre: NombreIcono | (string & {});
6
+ /** Tamaño en px (12–28 son los del sistema). */
7
+ tamano?: number;
8
+ /** Alias de `tamano` (el nombre que usaban las copias locales de los módulos). */
9
+ size?: number;
10
+ trazo?: number;
11
+ /** Alias de `trazo`. */
12
+ stroke?: number;
13
+ className?: string;
14
+ /** Si el ícono comunica algo por sí solo (sin texto al lado), pasá la etiqueta. */
15
+ etiqueta?: string;
16
+ };
17
+
18
+ export function Icono({ nombre, tamano, size, trazo, stroke, className, etiqueta }: Props) {
19
+ const px = tamano ?? size ?? 16;
20
+ const grosor = trazo ?? stroke ?? 1.75;
21
+ const clave = (nombre in ICONOS ? nombre : ALIAS[nombre]) as NombreIcono | undefined;
22
+ if (!clave && process.env.NODE_ENV !== "production") console.warn(`[Icono] «${nombre}» no está en el registro; se dibuja circle-dashed.`);
23
+ const Comp = ICONOS[clave ?? "circle-dashed"];
24
+ return (
25
+ <Comp
26
+ width={px}
27
+ height={px}
28
+ strokeWidth={grosor}
29
+ absoluteStrokeWidth={false}
30
+ className={className}
31
+ aria-hidden={etiqueta ? undefined : true}
32
+ aria-label={etiqueta}
33
+ role={etiqueta ? "img" : undefined}
34
+ focusable="false"
35
+ />
36
+ );
37
+ }
@@ -0,0 +1,92 @@
1
+ import {
2
+ Ban,
3
+ BellOff,
4
+ Check,
5
+ CircleAlert,
6
+ CircleCheck,
7
+ CircleDashed,
8
+ CircleHelp,
9
+ CircleX,
10
+ Clock,
11
+ CloudOff,
12
+ FilterX,
13
+ History,
14
+ Inbox,
15
+ Info,
16
+ LoaderCircle,
17
+ Lock,
18
+ OctagonAlert,
19
+ Plus,
20
+ RefreshCw,
21
+ Search,
22
+ SearchX,
23
+ TriangleAlert,
24
+ Unplug,
25
+ WifiOff,
26
+ X,
27
+ type LucideIcon,
28
+ } from "lucide-react";
29
+ import { isValidElement, type ReactElement } from "react";
30
+
31
+ /* Íconos por NOMBRE dentro de los componentes del paquete (Vacio, ChipEstado, Panel, Aviso, Kpi…).
32
+ Solo un juego BASE (estados, vacíos, avisos): el registro completo pesa ~32 KB gzip y cargarlo desde
33
+ ChipEstado lo metería en todas las páginas. Para cualquier otro nombre:
34
+ icono={Lightbulb} ← lo normal (import por nombre de lucide-react)
35
+ icono={<Icono nombre="lightbulb" />} ← nombre que viene de datos (@j3ehcmz/ui/iconos) */
36
+ export const GLIFOS_BASE = {
37
+ ban: Ban,
38
+ "bell-off": BellOff,
39
+ check: Check,
40
+ "circle-alert": CircleAlert,
41
+ "circle-check": CircleCheck,
42
+ "circle-dashed": CircleDashed,
43
+ "circle-help": CircleHelp,
44
+ "circle-x": CircleX,
45
+ clock: Clock,
46
+ "cloud-off": CloudOff,
47
+ "filter-x": FilterX,
48
+ history: History,
49
+ inbox: Inbox,
50
+ info: Info,
51
+ "loader-circle": LoaderCircle,
52
+ lock: Lock,
53
+ "octagon-alert": OctagonAlert,
54
+ plus: Plus,
55
+ "refresh-cw": RefreshCw,
56
+ search: Search,
57
+ "search-x": SearchX,
58
+ "triangle-alert": TriangleAlert,
59
+ unplug: Unplug,
60
+ "wifi-off": WifiOff,
61
+ x: X,
62
+ } as const satisfies Record<string, LucideIcon>;
63
+
64
+ /** Alias del registro del portal que caen en el juego base. */
65
+ const ALIAS_BASE: Record<string, keyof typeof GLIFOS_BASE> = {
66
+ alerta: "triangle-alert",
67
+ bien: "circle-check",
68
+ mal: "circle-x",
69
+ reloj: "clock",
70
+ cargando: "loader-circle",
71
+ buscar: "search",
72
+ "octagon-x": "octagon-alert",
73
+ };
74
+
75
+ export type NombreIconoBase = keyof typeof GLIFOS_BASE;
76
+
77
+ /** Lo que aceptan las props `icono` de los componentes: componente de lucide-react, elemento ya dibujado o nombre del juego base. */
78
+ export type IconoProp = LucideIcon | ReactElement | NombreIconoBase | (string & {});
79
+
80
+ function glifoPorNombre(nombre: string): LucideIcon {
81
+ const clave = (nombre in GLIFOS_BASE ? nombre : ALIAS_BASE[nombre]) as NombreIconoBase | undefined;
82
+ if (!clave && process.env.NODE_ENV !== "production")
83
+ console.warn(`[@j3ehcmz/ui] El ícono «${nombre}» no está en el juego base; pasa el componente (icono={X}) o <Icono nombre="${nombre}" />.`);
84
+ return GLIFOS_BASE[clave ?? "circle-dashed"];
85
+ }
86
+
87
+ /** Dibuja una prop `icono` (componente, elemento o nombre). Decorativo: aria-hidden. */
88
+ export function GlifoIcono({ icono, tamano = 16, trazo = 1.75, className }: { icono: IconoProp; tamano?: number; trazo?: number; className?: string }) {
89
+ if (isValidElement(icono)) return icono;
90
+ const Comp = typeof icono === "string" ? glifoPorNombre(icono) : (icono as LucideIcon);
91
+ return <Comp width={tamano} height={tamano} strokeWidth={trazo} aria-hidden="true" focusable="false" className={className} style={{ flex: "none" }} />;
92
+ }
@@ -0,0 +1,5 @@
1
+ // @j3ehcmz/ui/iconos — registro único de íconos del Portal (319 Lucide, trazo 1,75; origen: portal-hcmz/components/ui/iconos.ts).
2
+ // Entrada APARTE a propósito: importa todos los glifos. Úsalo en componentes de SERVIDOR o donde el nombre llega como dato
3
+ // (ICONO_MODULO, catálogo). En componentes de cliente importa el glifo directo de lucide-react para no cargar los 319.
4
+ export { Icono } from "./Icono";
5
+ export { ICONOS, ALIAS, RESERVADOS_ESTADO, ICONO_MODULO, type NombreIcono } from "./registro";