@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/CHANGELOG.md +31 -0
- package/README.md +65 -2
- package/css/estilos.css +375 -0
- package/css/fuentes.css +60 -0
- package/css/tokens.css +95 -0
- package/fuentes/josefin-sans-300.woff2 +0 -0
- package/fuentes/josefin-sans-400.woff2 +0 -0
- package/fuentes/plex-mono-400.woff2 +0 -0
- package/fuentes/plex-mono-500.woff2 +0 -0
- package/fuentes/plex-sans-latin.woff2 +0 -0
- package/fuentes/sora-latin.woff2 +0 -0
- package/package.json +45 -4
- package/src/iconos/Icono.tsx +37 -0
- package/src/iconos/glifos.tsx +92 -0
- package/src/iconos/index.ts +5 -0
- package/src/iconos/registro.ts +787 -0
- package/src/index.ts +38 -0
- package/src/navegador/ScriptsCabecera.tsx +16 -0
- package/src/navegador/reportar-errores.tsx +127 -0
- package/src/navegador/transicion-portal.ts +39 -0
- package/src/shell/BotonPortal.tsx +49 -0
- package/src/shell/BotonTema.tsx +41 -0
- package/src/shell/Shell.tsx +132 -0
- package/src/texto.ts +32 -0
- package/src/tiempo/Hace.tsx +69 -0
- package/src/tiempo/relativo.ts +70 -0
- package/src/ui/Dialogo.tsx +121 -0
- package/src/ui/NavModulo.tsx +129 -0
- package/src/ui/Tabla.tsx +88 -0
- package/src/ui/clases.ts +16 -0
- package/src/ui/contenido.tsx +165 -0
- package/src/ui/controles.tsx +247 -0
- package/src/ui/interactivos.tsx +230 -0
- package/src/ui/pagina.tsx +205 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { X } from "lucide-react";
|
|
4
|
+
import { useEffect, useRef, type ReactNode } from "react";
|
|
5
|
+
import { Boton, BotonIcono } from "./controles";
|
|
6
|
+
|
|
7
|
+
type PropsDialogo = {
|
|
8
|
+
titulo: string;
|
|
9
|
+
descripcion?: ReactNode;
|
|
10
|
+
children?: ReactNode;
|
|
11
|
+
/** Texto del botón principal. Sin `accion` (y sin `pie`) el diálogo funciona como modal genérico: lleva botón Cerrar arriba y no tiene pie. */
|
|
12
|
+
accion?: string;
|
|
13
|
+
onAccion?: () => void;
|
|
14
|
+
onCancelar: () => void;
|
|
15
|
+
ancho?: number;
|
|
16
|
+
ocupado?: boolean;
|
|
17
|
+
error?: string | null;
|
|
18
|
+
destructivo?: boolean;
|
|
19
|
+
deshabilitado?: boolean;
|
|
20
|
+
/** Pie propio (reemplaza Cancelar + acción). */
|
|
21
|
+
pie?: ReactNode;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/** Diálogo: radio 14, sombra de menú, pie sutil con Cancelar + acción. Escape y clic afuera cancelan. */
|
|
25
|
+
export function Dialogo({ titulo, descripcion, children, accion, onAccion, onCancelar, ancho = 420, ocupado, error, destructivo, deshabilitado, pie }: PropsDialogo) {
|
|
26
|
+
const generico = accion === undefined;
|
|
27
|
+
const caja = useRef<HTMLDivElement>(null);
|
|
28
|
+
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
const tecla = (e: KeyboardEvent) => e.key === "Escape" && !ocupado && onCancelar();
|
|
31
|
+
addEventListener("keydown", tecla);
|
|
32
|
+
return () => removeEventListener("keydown", tecla);
|
|
33
|
+
}, [onCancelar, ocupado]);
|
|
34
|
+
|
|
35
|
+
// Modal genérico: el foco entra al abrir y regresa al cerrar (el diálogo con acción conserva su comportamiento de siempre).
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
if (!generico) return;
|
|
38
|
+
const antes = document.activeElement as HTMLElement | null;
|
|
39
|
+
caja.current?.focus();
|
|
40
|
+
return () => antes?.focus?.();
|
|
41
|
+
}, [generico]);
|
|
42
|
+
|
|
43
|
+
const conPie = pie !== undefined || !generico;
|
|
44
|
+
const cabeza = (
|
|
45
|
+
<>
|
|
46
|
+
<span className="block font-display text-[19px] font-normal tracking-[-.01em]">{titulo}</span>
|
|
47
|
+
{descripcion && <p className="m-0 mt-[9px] text-[13.5px] leading-[1.55] text-tinta-2 [text-wrap:pretty]">{descripcion}</p>}
|
|
48
|
+
</>
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<div className="fixed inset-0 z-50 flex items-center justify-center bg-velo-dialogo p-4" onMouseDown={(e) => e.target === e.currentTarget && !ocupado && onCancelar()}>
|
|
53
|
+
<div
|
|
54
|
+
ref={caja}
|
|
55
|
+
role="dialog"
|
|
56
|
+
aria-modal="true"
|
|
57
|
+
aria-label={titulo}
|
|
58
|
+
tabIndex={generico ? -1 : undefined}
|
|
59
|
+
style={{ maxWidth: ancho }}
|
|
60
|
+
className="flex max-h-full w-full flex-col overflow-hidden rounded-[14px] bg-tarjeta text-tinta shadow-menu focus:outline-none"
|
|
61
|
+
>
|
|
62
|
+
<div className={`min-h-0 overflow-y-auto ${conPie ? "" : "pb-6"}`}>
|
|
63
|
+
{generico ? (
|
|
64
|
+
<div className="flex items-start gap-2 pl-6 pr-3 pt-3">
|
|
65
|
+
<div className="min-w-0 flex-1 pt-3">{cabeza}</div>
|
|
66
|
+
<BotonIcono icono={X} titulo="Cerrar" onClick={onCancelar} disabled={ocupado} />
|
|
67
|
+
</div>
|
|
68
|
+
) : (
|
|
69
|
+
<div className="px-6 pt-6">{cabeza}</div>
|
|
70
|
+
)}
|
|
71
|
+
{children && <div className="flex flex-col gap-[10px] px-6 pt-[18px]">{children}</div>}
|
|
72
|
+
{error && (
|
|
73
|
+
<p role="alert" className="m-0 px-6 pt-3 text-[13px] text-suspendido-tinta">
|
|
74
|
+
{error}
|
|
75
|
+
</p>
|
|
76
|
+
)}
|
|
77
|
+
</div>
|
|
78
|
+
{pie !== undefined ? (
|
|
79
|
+
<div className="mt-[22px] flex flex-none flex-wrap justify-end gap-[9px] border-t border-divisor bg-sutil px-6 py-4">{pie}</div>
|
|
80
|
+
) : (
|
|
81
|
+
!generico && (
|
|
82
|
+
<div className="mt-[22px] flex flex-none justify-end gap-[9px] border-t border-divisor bg-sutil px-6 py-4">
|
|
83
|
+
<Boton onClick={onCancelar} disabled={ocupado}>
|
|
84
|
+
Cancelar
|
|
85
|
+
</Boton>
|
|
86
|
+
<Boton variante={destructivo ? "destructivo" : "primario"} onClick={onAccion} disabled={ocupado || deshabilitado}>
|
|
87
|
+
{ocupado ? "Un momento…" : accion}
|
|
88
|
+
</Boton>
|
|
89
|
+
</div>
|
|
90
|
+
)
|
|
91
|
+
)}
|
|
92
|
+
</div>
|
|
93
|
+
</div>
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** Modal genérico (formularios, detalle): Dialogo sin acción fija. `abierto={false}` no dibuja nada. */
|
|
98
|
+
export function Modal({
|
|
99
|
+
titulo,
|
|
100
|
+
abierto = true,
|
|
101
|
+
alCerrar,
|
|
102
|
+
ancho = 440,
|
|
103
|
+
pie,
|
|
104
|
+
descripcion,
|
|
105
|
+
children,
|
|
106
|
+
}: {
|
|
107
|
+
titulo: string;
|
|
108
|
+
abierto?: boolean;
|
|
109
|
+
alCerrar: () => void;
|
|
110
|
+
ancho?: number;
|
|
111
|
+
pie?: ReactNode;
|
|
112
|
+
descripcion?: ReactNode;
|
|
113
|
+
children?: ReactNode;
|
|
114
|
+
}) {
|
|
115
|
+
if (!abierto) return null;
|
|
116
|
+
return (
|
|
117
|
+
<Dialogo titulo={titulo} descripcion={descripcion} onCancelar={alCerrar} ancho={ancho} pie={pie}>
|
|
118
|
+
{children}
|
|
119
|
+
</Dialogo>
|
|
120
|
+
);
|
|
121
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import Link from "next/link";
|
|
4
|
+
import { usePathname } from "next/navigation";
|
|
5
|
+
import type { CSSProperties } from "react";
|
|
6
|
+
import { GlifoIcono, type IconoProp } from "../iconos/glifos";
|
|
7
|
+
|
|
8
|
+
export type EnlaceModulo = {
|
|
9
|
+
href: string;
|
|
10
|
+
texto: string;
|
|
11
|
+
/** Lo normal: componente de lucide-react (icono={Lightbulb}). */
|
|
12
|
+
icono?: IconoProp;
|
|
13
|
+
/** Cuándo está activo. Por omisión: "/" solo en "/", lo demás en la ruta y sus hijas. */
|
|
14
|
+
activo?: (ruta: string) => boolean;
|
|
15
|
+
/** Insignia con un número (sin leer, pendientes). 0 o undefined = sin insignia. */
|
|
16
|
+
cuenta?: number;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
type Props = {
|
|
20
|
+
enlaces: EnlaceModulo[];
|
|
21
|
+
/** Nombre accesible («Secciones de Ideas»). */
|
|
22
|
+
etiqueta: string;
|
|
23
|
+
/**
|
|
24
|
+
* - "barra" (Ideas): franja bajo la barra, pestañas compactas con subrayado de acento.
|
|
25
|
+
* - "banda" (Central de Atención): franja centrada a 1180, borde inferior de acento de punta a punta de la pestaña.
|
|
26
|
+
* - "inferior-movil" (Avisos): pestañas bajo la barra en escritorio; en el teléfono, barra inferior FIJA de 64 px.
|
|
27
|
+
* Con esta variante el módulo deja espacio abajo: `<Shell claseContenido="max-[760px]:pb-24">`.
|
|
28
|
+
*/
|
|
29
|
+
variante?: "barra" | "banda" | "inferior-movil";
|
|
30
|
+
className?: string;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const porOmision = (href: string) => (ruta: string) => (href === "/" ? ruta === "/" : ruta === href || ruta.startsWith(`${href}/`));
|
|
34
|
+
|
|
35
|
+
function Insignia({ n, movil }: { n: number; movil?: boolean }) {
|
|
36
|
+
if (!n || n <= 0) return null;
|
|
37
|
+
return (
|
|
38
|
+
<span
|
|
39
|
+
className={`inline-flex h-[18px] min-w-[18px] items-center justify-center rounded-pildora bg-tinta px-[5px] font-mono text-etiqueta tracking-normal text-sobre-tinta ${
|
|
40
|
+
movil ? "max-[760px]:absolute max-[760px]:left-[calc(50%+6px)] max-[760px]:top-[9px]" : ""
|
|
41
|
+
}`}
|
|
42
|
+
>
|
|
43
|
+
<span className="sr-only">, {n} pendientes</span>
|
|
44
|
+
<span aria-hidden="true">{n > 99 ? "99+" : n}</span>
|
|
45
|
+
</span>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** Navegación del módulo para el slot `navegacion` del Shell (franja propia DEBAJO de la barra). */
|
|
50
|
+
export function NavModulo({ enlaces, etiqueta, variante = "barra", className = "" }: Props) {
|
|
51
|
+
const ruta = usePathname() ?? "/";
|
|
52
|
+
const items = enlaces.map((e) => ({ ...e, on: (e.activo ?? porOmision(e.href))(ruta) }));
|
|
53
|
+
|
|
54
|
+
if (variante === "banda") {
|
|
55
|
+
return (
|
|
56
|
+
<nav aria-label={etiqueta} className={`noprint border-b border-borde-sutil bg-tarjeta ${className}`}>
|
|
57
|
+
<div className="sin-barra mx-auto flex w-full max-w-[1180px] gap-1 overflow-x-auto px-5 max-[620px]:px-2">
|
|
58
|
+
{items.map((e) => (
|
|
59
|
+
<Link
|
|
60
|
+
key={e.href}
|
|
61
|
+
href={e.href}
|
|
62
|
+
aria-current={e.on ? "page" : undefined}
|
|
63
|
+
className={`-mb-px inline-flex h-11 items-center gap-2 whitespace-nowrap border-b-2 px-3 text-ui ${
|
|
64
|
+
e.on ? "border-acento font-medium text-tinta" : "border-transparent text-tinta-3 hover:text-tinta"
|
|
65
|
+
}`}
|
|
66
|
+
>
|
|
67
|
+
{e.icono && <GlifoIcono icono={e.icono} tamano={15} />}
|
|
68
|
+
{e.texto}
|
|
69
|
+
<Insignia n={e.cuenta ?? 0} />
|
|
70
|
+
</Link>
|
|
71
|
+
))}
|
|
72
|
+
</div>
|
|
73
|
+
</nav>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (variante === "inferior-movil") {
|
|
78
|
+
return (
|
|
79
|
+
<nav
|
|
80
|
+
aria-label={etiqueta}
|
|
81
|
+
className={`noprint border-b border-borde-sutil bg-tarjeta pb-[env(safe-area-inset-bottom,0px)] max-[760px]:fixed max-[760px]:inset-x-0 max-[760px]:bottom-0 max-[760px]:z-40 max-[760px]:border-b-0 max-[760px]:border-t ${className}`}
|
|
82
|
+
>
|
|
83
|
+
<ul
|
|
84
|
+
style={{ "--columnas": `repeat(${items.length}, minmax(0, 1fr))` } as CSSProperties}
|
|
85
|
+
className="m-0 flex list-none items-center gap-1 px-7 py-0 max-[760px]:grid max-[760px]:grid-cols-[var(--columnas)] max-[760px]:gap-0 max-[760px]:px-0"
|
|
86
|
+
>
|
|
87
|
+
{items.map((e) => (
|
|
88
|
+
<li key={e.href} className="flex-none">
|
|
89
|
+
<Link
|
|
90
|
+
href={e.href}
|
|
91
|
+
aria-current={e.on ? "page" : undefined}
|
|
92
|
+
className={`relative inline-flex h-11 items-center gap-[7px] whitespace-nowrap px-3 text-ui-lg max-[760px]:h-16 max-[760px]:w-full max-[760px]:flex-col max-[760px]:justify-center max-[760px]:gap-[3px] max-[760px]:px-0 max-[760px]:text-mini ${
|
|
93
|
+
e.on
|
|
94
|
+
? "-mb-px border-b-2 border-tinta font-semibold text-tinta max-[760px]:mb-0 max-[760px]:border-b-0 max-[760px]:shadow-[inset_0_2px_0_var(--tinta)]"
|
|
95
|
+
: "text-tinta-3"
|
|
96
|
+
}`}
|
|
97
|
+
>
|
|
98
|
+
{e.icono && <GlifoIcono icono={e.icono} tamano={19} trazo={e.on ? 2 : 1.75} />}
|
|
99
|
+
{e.texto}
|
|
100
|
+
<Insignia n={e.cuenta ?? 0} movil />
|
|
101
|
+
</Link>
|
|
102
|
+
</li>
|
|
103
|
+
))}
|
|
104
|
+
</ul>
|
|
105
|
+
</nav>
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// "barra"
|
|
110
|
+
return (
|
|
111
|
+
<div className={`noprint sin-barra overflow-x-auto border-b border-borde-sutil bg-tarjeta px-5 max-[760px]:px-3 ${className}`}>
|
|
112
|
+
<nav aria-label={etiqueta} className="flex items-center gap-1">
|
|
113
|
+
{items.map((e) => (
|
|
114
|
+
<Link
|
|
115
|
+
key={e.href}
|
|
116
|
+
href={e.href}
|
|
117
|
+
aria-current={e.on ? "page" : undefined}
|
|
118
|
+
className={`relative inline-flex h-10 items-center gap-1.5 whitespace-nowrap rounded-[8px] px-2.5 text-ui ${e.on ? "font-medium text-tinta" : "text-tinta-3 hover:text-tinta"}`}
|
|
119
|
+
>
|
|
120
|
+
{e.icono && <GlifoIcono icono={e.icono} tamano={15} />}
|
|
121
|
+
{e.texto}
|
|
122
|
+
<Insignia n={e.cuenta ?? 0} />
|
|
123
|
+
{e.on && <span aria-hidden="true" className="absolute inset-x-2.5 -bottom-px h-[2px] rounded-pildora bg-acento" />}
|
|
124
|
+
</Link>
|
|
125
|
+
))}
|
|
126
|
+
</nav>
|
|
127
|
+
</div>
|
|
128
|
+
);
|
|
129
|
+
}
|
package/src/ui/Tabla.tsx
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import Link from "next/link";
|
|
2
|
+
import type { Key, ReactNode } from "react";
|
|
3
|
+
|
|
4
|
+
/* Tabla de datos (modelo: isc-hcmz components/ui/datos.tsx). Sin estado: sirve en componentes de servidor.
|
|
5
|
+
Scroll horizontal PROPIO (nunca ensancha la página), números tabulares, encabezado mono. */
|
|
6
|
+
|
|
7
|
+
/** Clases de celda para tablas armadas a mano (mismas medidas que <Tabla>). */
|
|
8
|
+
export const TH = "whitespace-nowrap px-4 py-2.5 font-mono text-etiqueta font-medium uppercase tracking-[0.06em] text-tinta-3";
|
|
9
|
+
export const TD = "px-4 py-2.5 align-top text-tinta-2";
|
|
10
|
+
/** Fila del cuerpo (divisor + resalte al pasar). */
|
|
11
|
+
export const TR = "border-b border-borde-sutil last:border-0 hover:bg-sutil";
|
|
12
|
+
|
|
13
|
+
export type Columna<T> = {
|
|
14
|
+
titulo: ReactNode;
|
|
15
|
+
celda: (fila: T) => ReactNode;
|
|
16
|
+
/** Alinea a la derecha (cifras, montos). */
|
|
17
|
+
derecha?: boolean;
|
|
18
|
+
/** Ancho CSS de la columna ("120px", "30%"). */
|
|
19
|
+
ancho?: string;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export function Tabla<T>({
|
|
23
|
+
etiqueta,
|
|
24
|
+
columnas,
|
|
25
|
+
filas,
|
|
26
|
+
clave,
|
|
27
|
+
enlace,
|
|
28
|
+
vacio = "No hay resultados.",
|
|
29
|
+
minAncho,
|
|
30
|
+
enTarjeta = true,
|
|
31
|
+
className = "",
|
|
32
|
+
}: {
|
|
33
|
+
/** Nombre accesible de la tabla (y de su región con scroll). */
|
|
34
|
+
etiqueta: string;
|
|
35
|
+
columnas: Columna<T>[];
|
|
36
|
+
filas: T[];
|
|
37
|
+
/** Clave estable de cada fila; por omisión el índice. */
|
|
38
|
+
clave?: (fila: T, i: number) => Key;
|
|
39
|
+
/** Si la fila lleva a un detalle: la primera celda se vuelve enlace. */
|
|
40
|
+
enlace?: (fila: T) => string;
|
|
41
|
+
/** Lo que se ve sin filas (texto o un <Vacio />). */
|
|
42
|
+
vacio?: ReactNode;
|
|
43
|
+
/** Ancho mínimo en px antes de desplazar horizontalmente. */
|
|
44
|
+
minAncho?: number;
|
|
45
|
+
/** false = sin tarjeta alrededor (dentro de un Panel con sinRelleno). */
|
|
46
|
+
enTarjeta?: boolean;
|
|
47
|
+
className?: string;
|
|
48
|
+
}) {
|
|
49
|
+
const marco = enTarjeta ? "rounded-tarjeta border border-borde-sutil bg-tarjeta shadow-plana" : "";
|
|
50
|
+
if (filas.length === 0) {
|
|
51
|
+
return typeof vacio === "string" ? <div className={`${marco} px-5 py-8 text-center text-ui-lg text-tinta-3 ${className}`}>{vacio}</div> : <div className={`${marco} ${className}`}>{vacio}</div>;
|
|
52
|
+
}
|
|
53
|
+
return (
|
|
54
|
+
<div role="region" aria-label={etiqueta} tabIndex={0} className={`${marco} overflow-x-auto ${className}`}>
|
|
55
|
+
<table aria-label={etiqueta} className="w-full border-collapse text-ui tabular-nums" style={minAncho ? { minWidth: minAncho } : undefined}>
|
|
56
|
+
<thead>
|
|
57
|
+
<tr className="border-b border-borde-sutil">
|
|
58
|
+
{columnas.map((c, j) => (
|
|
59
|
+
<th key={j} scope="col" className={`${TH} ${c.derecha ? "text-right" : "text-left"}`} style={c.ancho ? { width: c.ancho } : undefined}>
|
|
60
|
+
{c.titulo}
|
|
61
|
+
</th>
|
|
62
|
+
))}
|
|
63
|
+
</tr>
|
|
64
|
+
</thead>
|
|
65
|
+
<tbody>
|
|
66
|
+
{filas.map((f, i) => {
|
|
67
|
+
const href = enlace?.(f);
|
|
68
|
+
return (
|
|
69
|
+
<tr key={clave ? clave(f, i) : i} className={TR}>
|
|
70
|
+
{columnas.map((c, j) => (
|
|
71
|
+
<td key={j} className={`${TD} ${c.derecha ? "text-right" : ""}`}>
|
|
72
|
+
{href && j === 0 ? (
|
|
73
|
+
<Link href={href} className="font-medium text-tinta underline-offset-2 hover:underline">
|
|
74
|
+
{c.celda(f)}
|
|
75
|
+
</Link>
|
|
76
|
+
) : (
|
|
77
|
+
c.celda(f)
|
|
78
|
+
)}
|
|
79
|
+
</td>
|
|
80
|
+
))}
|
|
81
|
+
</tr>
|
|
82
|
+
);
|
|
83
|
+
})}
|
|
84
|
+
</tbody>
|
|
85
|
+
</table>
|
|
86
|
+
</div>
|
|
87
|
+
);
|
|
88
|
+
}
|
package/src/ui/clases.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/* Clases sueltas para lo que no vale la pena volver componente (inputs nativos, enlaces con forma de botón).
|
|
2
|
+
Mismas medidas que los componentes. Si una pantalla necesita otra medida, primero se agrega aquí. */
|
|
3
|
+
|
|
4
|
+
export const BTN =
|
|
5
|
+
"inline-flex h-[34px] cursor-pointer items-center justify-center gap-[7px] whitespace-nowrap rounded-[8px] border border-borde-fuerte bg-control px-[13px] text-ui text-tinta-2 hover:bg-sutil disabled:cursor-default disabled:opacity-50";
|
|
6
|
+
export const BTN_PRIMARIO =
|
|
7
|
+
"inline-flex h-[34px] cursor-pointer items-center justify-center gap-[7px] whitespace-nowrap rounded-[8px] border border-tinta bg-tinta px-[13px] text-ui font-medium text-sobre-tinta hover:opacity-90 disabled:cursor-default disabled:opacity-50";
|
|
8
|
+
export const BTN_PELIGRO =
|
|
9
|
+
"inline-flex h-[34px] cursor-pointer items-center justify-center gap-[7px] whitespace-nowrap rounded-[8px] border border-suspendido bg-suspendido-bg px-[13px] text-ui font-medium text-suspendido-tinta hover:opacity-90 disabled:cursor-default disabled:opacity-50";
|
|
10
|
+
export const INPUT =
|
|
11
|
+
"h-9 w-full rounded-[8px] border border-borde-fuerte bg-control px-3 text-ui-lg text-tinta placeholder:text-tinta-apoyo focus:outline-2 focus:outline-tinta";
|
|
12
|
+
export const SELECT = `${INPUT} cursor-pointer`;
|
|
13
|
+
export const TEXTAREA = "w-full rounded-[8px] border border-borde-fuerte bg-control px-3 py-2 text-ui-lg text-tinta placeholder:text-tinta-apoyo focus:outline-2 focus:outline-tinta";
|
|
14
|
+
export const ETIQUETA = "mb-1 block text-mini font-medium text-tinta-2";
|
|
15
|
+
export const TARJETA = "rounded-tarjeta border border-borde-sutil bg-tarjeta shadow-plana";
|
|
16
|
+
export const TITULO = "m-0 font-display text-seccion font-medium text-tinta max-[620px]:text-[22px]";
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { CircleAlert, CircleCheck, CircleDashed, CloudOff, Inbox, OctagonAlert, SearchX, TriangleAlert, type LucideIcon } from "lucide-react";
|
|
2
|
+
import type { ReactNode } from "react";
|
|
3
|
+
import { GlifoIcono, type IconoProp } from "../iconos/glifos";
|
|
4
|
+
|
|
5
|
+
export type Tono = "aldia" | "porvencer" | "fallo" | "suspendido" | "sindatos";
|
|
6
|
+
|
|
7
|
+
/* Estados VALIDADOS PARA DALTONISMO: van siempre con texto y ícono, nunca solo color.
|
|
8
|
+
Versión oficial del design system (4-nov): fondo -bg, texto -tinta, ícono en el hex validado. */
|
|
9
|
+
const TONO: Record<Tono, { chip: string; icono: string; glifo: LucideIcon }> = {
|
|
10
|
+
aldia: { chip: "bg-aldia-bg text-aldia-tinta", icono: "text-aldia", glifo: CircleCheck },
|
|
11
|
+
porvencer: { chip: "bg-porvencer-bg text-porvencer-tinta", icono: "text-porvencer", glifo: TriangleAlert },
|
|
12
|
+
fallo: { chip: "bg-fallo-bg text-fallo-tinta", icono: "text-fallo", glifo: CircleAlert },
|
|
13
|
+
suspendido: { chip: "bg-suspendido-bg text-suspendido-tinta", icono: "text-suspendido", glifo: OctagonAlert },
|
|
14
|
+
sindatos: { chip: "bg-sindatos-bg text-sindatos-tinta", icono: "text-sindatos", glifo: CircleDashed },
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/** Fondo + tinta de texto de cada estado (chips, avisos, celdas). Para el ícono del estado, `text-<tono>`. */
|
|
18
|
+
export const CLASES_TONO: Record<Tono, string> = {
|
|
19
|
+
aldia: TONO.aldia.chip,
|
|
20
|
+
porvencer: TONO.porvencer.chip,
|
|
21
|
+
fallo: TONO.fallo.chip,
|
|
22
|
+
suspendido: TONO.suspendido.chip,
|
|
23
|
+
sindatos: TONO.sindatos.chip,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/** Color «hex» validado del estado, para el ícono (`text-aldia`…). */
|
|
27
|
+
export const COLOR_TONO: Record<Tono, string> = {
|
|
28
|
+
aldia: TONO.aldia.icono,
|
|
29
|
+
porvencer: TONO.porvencer.icono,
|
|
30
|
+
fallo: TONO.fallo.icono,
|
|
31
|
+
suspendido: TONO.suspendido.icono,
|
|
32
|
+
sindatos: TONO.sindatos.icono,
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/** Glifo reservado de cada estado. */
|
|
36
|
+
export const GLIFO_TONO: Record<Tono, LucideIcon> = {
|
|
37
|
+
aldia: TONO.aldia.glifo,
|
|
38
|
+
porvencer: TONO.porvencer.glifo,
|
|
39
|
+
fallo: TONO.fallo.glifo,
|
|
40
|
+
suspendido: TONO.suspendido.glifo,
|
|
41
|
+
sindatos: TONO.sindatos.glifo,
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/** `icono` por omisión = el del estado; `icono={null}` lo quita. Acepta componente, elemento o nombre del juego base.
|
|
45
|
+
* `tamano="chica"` = 20 px de alto (dentro de tablas y filas densas). */
|
|
46
|
+
export function ChipEstado({
|
|
47
|
+
tono,
|
|
48
|
+
icono,
|
|
49
|
+
tamano = "normal",
|
|
50
|
+
className = "",
|
|
51
|
+
children,
|
|
52
|
+
}: {
|
|
53
|
+
tono: Tono;
|
|
54
|
+
icono?: IconoProp | null;
|
|
55
|
+
tamano?: "normal" | "chica";
|
|
56
|
+
className?: string;
|
|
57
|
+
children: ReactNode;
|
|
58
|
+
}) {
|
|
59
|
+
const t = TONO[tono];
|
|
60
|
+
const glifo = icono === undefined ? t.glifo : icono;
|
|
61
|
+
const chica = tamano === "chica";
|
|
62
|
+
return (
|
|
63
|
+
<span
|
|
64
|
+
className={`inline-flex items-center whitespace-nowrap rounded-pildora font-medium ${chica ? "h-5 gap-1 px-2 text-mini" : "h-6 gap-[5px] px-[10px] text-[12.5px]"} ${t.chip} ${className}`}
|
|
65
|
+
>
|
|
66
|
+
{glifo && <GlifoIcono icono={glifo} tamano={chica ? 12 : 14} className={t.icono} />}
|
|
67
|
+
{children}
|
|
68
|
+
</span>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** Iniciales en círculo (persona o contacto). */
|
|
73
|
+
export function Avatar({ texto, size = 36, fuente = 14, peso = 500, className = "" }: { texto: string; size?: number; fuente?: number; peso?: 300 | 400 | 500; className?: string }) {
|
|
74
|
+
return (
|
|
75
|
+
<span
|
|
76
|
+
style={{ width: size, height: size, fontSize: fuente, fontWeight: peso }}
|
|
77
|
+
className={`flex flex-none items-center justify-center rounded-full bg-hundida font-display text-tinta-2 ${className}`}
|
|
78
|
+
>
|
|
79
|
+
{texto}
|
|
80
|
+
</span>
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** Etiqueta de sección: mono 11, +.12em, mayúsculas. */
|
|
85
|
+
export function EtiquetaSeccion({ children, className = "" }: { children: ReactNode; className?: string }) {
|
|
86
|
+
return <span className={`font-mono text-[11px] uppercase leading-[1.3] tracking-[.12em] text-tinta-3 ${className}`}>{children}</span>;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** Título de página (Sora 26/500; 22 en teléfono). */
|
|
90
|
+
export function Titulo({ children, className = "" }: { children: ReactNode; className?: string }) {
|
|
91
|
+
return <h1 className={`m-0 font-display text-seccion font-medium text-tinta max-[620px]:text-[22px] ${className}`}>{children}</h1>;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** Tarjeta base del portal (radio 14). */
|
|
95
|
+
export function Tarjeta({ children, className = "" }: { children: ReactNode; className?: string }) {
|
|
96
|
+
return <div className={`rounded-tarjeta border border-borde-sutil bg-tarjeta shadow-plana ${className}`}>{children}</div>;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** Tarjeta radio 16 con filas divididas (Ajustes, Desglose). Usar con FilaDato / FilaInterruptor. */
|
|
100
|
+
export function TarjetaFilas({ children, className = "" }: { children: ReactNode; className?: string }) {
|
|
101
|
+
return <div className={`overflow-hidden rounded-[16px] border border-borde-sutil bg-tarjeta shadow-plana ${className}`}>{children}</div>;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export function FilaDato({ k, children, ultima }: { k: ReactNode; children: ReactNode; ultima?: boolean }) {
|
|
105
|
+
return (
|
|
106
|
+
<div className={`flex items-center justify-between gap-3 px-[18px] py-[14px] text-[14px] ${ultima ? "" : "border-b border-divisor"}`}>
|
|
107
|
+
<span className="text-tinta-3">{k}</span>
|
|
108
|
+
<span className="min-w-0 text-right text-tinta">{children}</span>
|
|
109
|
+
</div>
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export function Nota({ children, className = "" }: { children: ReactNode; className?: string }) {
|
|
114
|
+
return <p className={`m-0 text-[13px] leading-[1.5] text-tinta-3 ${className}`}>{children}</p>;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
type TipoVacio = "vacio" | "sin-datos" | "caido" | "sin-coincidencias";
|
|
118
|
+
|
|
119
|
+
const ICONO_VACIO: Record<TipoVacio, LucideIcon> = {
|
|
120
|
+
vacio: Inbox,
|
|
121
|
+
"sin-datos": CircleDashed,
|
|
122
|
+
caido: CloudOff,
|
|
123
|
+
"sin-coincidencias": SearchX,
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
/** Estado vacío: ícono, una línea de qué pasa y (opcional) qué hacer.
|
|
127
|
+
* - `tipo` pone el ícono por omisión (vacío, sin datos de la fuente, servicio caído, búsqueda sin resultados);
|
|
128
|
+
* «caido» pinta el ícono en rojo y se anuncia (role="alert").
|
|
129
|
+
* - `accion`: botón o enlace de qué hacer («Agregar la primera», «Quitar filtros», «Reintentar»).
|
|
130
|
+
* - `marco`: caja con borde (cuando el vacío va suelto en la página y no dentro de una tarjeta). */
|
|
131
|
+
export function Vacio({
|
|
132
|
+
icono,
|
|
133
|
+
titulo,
|
|
134
|
+
tipo,
|
|
135
|
+
accion,
|
|
136
|
+
marco,
|
|
137
|
+
className = "",
|
|
138
|
+
children,
|
|
139
|
+
}: {
|
|
140
|
+
icono?: IconoProp;
|
|
141
|
+
titulo: string;
|
|
142
|
+
tipo?: TipoVacio;
|
|
143
|
+
accion?: ReactNode;
|
|
144
|
+
marco?: boolean;
|
|
145
|
+
className?: string;
|
|
146
|
+
children?: ReactNode;
|
|
147
|
+
}) {
|
|
148
|
+
const glifo = icono ?? (tipo ? ICONO_VACIO[tipo] : undefined);
|
|
149
|
+
const caido = tipo === "caido";
|
|
150
|
+
return (
|
|
151
|
+
<div
|
|
152
|
+
role={caido ? "alert" : undefined}
|
|
153
|
+
className={`flex flex-col items-center gap-2 px-6 py-12 text-center ${marco ? "rounded-tarjeta border border-borde-sutil bg-tarjeta shadow-plana" : ""} ${className}`}
|
|
154
|
+
>
|
|
155
|
+
{glifo && (
|
|
156
|
+
<span className={`mb-1 flex size-10 items-center justify-center rounded-full ${caido ? "bg-fallo-bg text-fallo" : "bg-hundida text-tinta-3"}`}>
|
|
157
|
+
<GlifoIcono icono={glifo} tamano={18} />
|
|
158
|
+
</span>
|
|
159
|
+
)}
|
|
160
|
+
<span className="font-display text-titulo-tarjeta font-medium text-tinta">{titulo}</span>
|
|
161
|
+
{children && <div className="max-w-[420px] text-ui text-tinta-3">{children}</div>}
|
|
162
|
+
{accion && <div className="mt-2 flex flex-wrap items-center justify-center gap-2">{accion}</div>}
|
|
163
|
+
</div>
|
|
164
|
+
);
|
|
165
|
+
}
|