@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
package/src/index.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// @j3ehcmz/ui — sistema de diseño de los módulos del Portal HCMZ.
|
|
2
|
+
// Estilos: @import "@j3ehcmz/ui/estilos.css" en el globals.css del módulo.
|
|
3
|
+
|
|
4
|
+
export { Shell, Monograma, type Modulo } from "./shell/Shell";
|
|
5
|
+
export { BotonPortal, DivisorCabecera, URL_PORTAL } from "./shell/BotonPortal";
|
|
6
|
+
export { BotonTema } from "./shell/BotonTema";
|
|
7
|
+
|
|
8
|
+
export { Boton, BotonIcono, Pista, FilaInterruptor, Segmentado, Interruptor } from "./ui/controles";
|
|
9
|
+
export {
|
|
10
|
+
ChipEstado,
|
|
11
|
+
Avatar,
|
|
12
|
+
EtiquetaSeccion,
|
|
13
|
+
Titulo,
|
|
14
|
+
Tarjeta,
|
|
15
|
+
TarjetaFilas,
|
|
16
|
+
FilaDato,
|
|
17
|
+
Nota,
|
|
18
|
+
Vacio,
|
|
19
|
+
CLASES_TONO,
|
|
20
|
+
COLOR_TONO,
|
|
21
|
+
GLIFO_TONO,
|
|
22
|
+
type Tono,
|
|
23
|
+
} from "./ui/contenido";
|
|
24
|
+
export { Dialogo, Modal } from "./ui/Dialogo";
|
|
25
|
+
export * from "./ui/clases";
|
|
26
|
+
|
|
27
|
+
// 0.2.0 — piezas que estaban copiadas en 3+ módulos.
|
|
28
|
+
export { NavModulo, type EnlaceModulo } from "./ui/NavModulo";
|
|
29
|
+
export { EncabezadoPagina, Panel, Kpi, Aviso, Esqueleto, FilaEsqueleto } from "./ui/pagina";
|
|
30
|
+
export { Tabla, TH, TD, TR, type Columna } from "./ui/Tabla";
|
|
31
|
+
export { CampoBusqueda, BotonCopiar, ToastProvider, useToast } from "./ui/interactivos";
|
|
32
|
+
export { Hace, Frescura, useAhora } from "./tiempo/Hace";
|
|
33
|
+
export { hace, duracion, aMs, fechaCorta, fechaHora, type OpcionesHace } from "./tiempo/relativo";
|
|
34
|
+
export { GLIFOS_BASE, type IconoProp, type NombreIconoBase } from "./iconos/glifos";
|
|
35
|
+
|
|
36
|
+
export { ScriptsCabecera, TEMA_INICIAL } from "./navegador/ScriptsCabecera";
|
|
37
|
+
export { TRANSICION_PORTAL } from "./navegador/transicion-portal";
|
|
38
|
+
export { ReportarErrores, reportarErrorNavegador } from "./navegador/reportar-errores";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { TRANSICION_PORTAL } from "./transicion-portal";
|
|
2
|
+
|
|
3
|
+
/* Tema compartido con el portal: la fuente es la cookie portal-tema de .hcmz.online (el localStorage es de cada
|
|
4
|
+
subdominio). Sin cookie = el del sistema, y lo sigue en vivo; al volver a la pestaña se relee. Si el botón de
|
|
5
|
+
un módulo cambia data-tema, se guarda en la cookie y lo heredan todos. */
|
|
6
|
+
export const TEMA_INICIAL = `(function(){try{var h=document.documentElement,q=matchMedia('(prefers-color-scheme: dark)'),propio=null;function aplicar(){var m=document.cookie.match(/(?:^|; )portal-tema=(claro|oscuro)/);var t=m?m[1]:(q.matches?'oscuro':'claro');propio=t;if(h.dataset.tema!==t)h.dataset.tema=t}aplicar();q.addEventListener('change',aplicar);document.addEventListener('visibilitychange',function(){if(!document.hidden)aplicar()});new MutationObserver(function(){var t=h.dataset.tema==='oscuro'?'oscuro':'claro';if(t===propio)return;propio=t;var d=location.hostname.endsWith('.hcmz.online')?'; domain=.hcmz.online':'',s=location.protocol==='https:'?'; secure':'';document.cookie='portal-tema='+t+'; path=/; max-age=31536000; samesite=lax'+d+s}).observe(h,{attributes:true,attributeFilter:['data-tema']})}catch(e){}})()`;
|
|
7
|
+
|
|
8
|
+
/** Va dentro de <head> del layout raíz: «el ícono viaja» (entrada/regreso del portal) + tema antes de pintar. */
|
|
9
|
+
export function ScriptsCabecera({ transicion = true }: { transicion?: boolean }) {
|
|
10
|
+
return (
|
|
11
|
+
<>
|
|
12
|
+
{transicion && <script dangerouslySetInnerHTML={{ __html: TRANSICION_PORTAL }} />}
|
|
13
|
+
<script dangerouslySetInnerHTML={{ __html: TEMA_INICIAL }} />
|
|
14
|
+
</>
|
|
15
|
+
);
|
|
16
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useEffect } from "react";
|
|
4
|
+
|
|
5
|
+
/* Errores del navegador → POST /api/errores (→ GlitchTip). Sin dependencias: ~1 KB. Máximo 10 por página y sin
|
|
6
|
+
repetir el mismo mensaje. Se ignora el ruido que no es del módulo (extensiones, «Script error.», ResizeObserver).
|
|
7
|
+
Además mide el rendimiento real de esta carga de página (Web Vitals) y lo manda UNA vez, al ocultar o cerrar la
|
|
8
|
+
pestaña, por la misma ruta (→ pestaña Rendimiento del Monitor). Solo ruta genérica y tiempos: nada de quién.
|
|
9
|
+
Vive SOLO en @j3ehcmz/ui: los módulos lo importan, no lo copian. */
|
|
10
|
+
|
|
11
|
+
function enviar(cuerpo: string) {
|
|
12
|
+
if (!navigator.sendBeacon?.("/api/errores", new Blob([cuerpo], { type: "application/json" }))) {
|
|
13
|
+
void fetch("/api/errores", { method: "POST", body: cuerpo, headers: { "Content-Type": "application/json" }, keepalive: true }).catch(() => {});
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** Segmentos con números o muy largos (ids, fechas, códigos) → «:id», para no mandar datos de nadie. */
|
|
18
|
+
const rutaGenerica = (p: string) =>
|
|
19
|
+
p
|
|
20
|
+
.split("/")
|
|
21
|
+
.map((s) => (s.length > 24 || (/\d/.test(s) && s.length > 2) ? ":id" : s.replace(/[^\w\-.]/g, "")))
|
|
22
|
+
.join("/")
|
|
23
|
+
.slice(0, 200) || "/";
|
|
24
|
+
|
|
25
|
+
let vitalesIniciadas = false;
|
|
26
|
+
|
|
27
|
+
function medirVitales() {
|
|
28
|
+
if (vitalesIniciadas || typeof PerformanceObserver === "undefined") return;
|
|
29
|
+
vitalesIniciadas = true;
|
|
30
|
+
const v: { lcp?: number; fcp?: number; cls?: number } = {};
|
|
31
|
+
const interacciones = new Map<number, number>();
|
|
32
|
+
let cls = 0;
|
|
33
|
+
let ventana = 0;
|
|
34
|
+
let primero = 0;
|
|
35
|
+
let ultimo = 0;
|
|
36
|
+
const observar = (type: string, cb: (e: PerformanceEntry) => void, extra: Record<string, unknown> = {}) => {
|
|
37
|
+
try {
|
|
38
|
+
new PerformanceObserver((l) => l.getEntries().forEach(cb)).observe({ type, buffered: true, ...extra } as PerformanceObserverInit);
|
|
39
|
+
} catch {
|
|
40
|
+
/* navegador viejo: esa métrica no se mide */
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
observar("largest-contentful-paint", (e) => (v.lcp = e.startTime));
|
|
44
|
+
observar("paint", (e) => {
|
|
45
|
+
if (e.name === "first-contentful-paint") v.fcp = e.startTime;
|
|
46
|
+
});
|
|
47
|
+
observar("layout-shift", (e) => {
|
|
48
|
+
const s = e as PerformanceEntry & { value: number; hadRecentInput: boolean };
|
|
49
|
+
if (s.hadRecentInput) return;
|
|
50
|
+
if (ventana && s.startTime - ultimo < 1000 && s.startTime - primero < 5000) ventana += s.value;
|
|
51
|
+
else {
|
|
52
|
+
ventana = s.value;
|
|
53
|
+
primero = s.startTime;
|
|
54
|
+
}
|
|
55
|
+
ultimo = s.startTime;
|
|
56
|
+
cls = Math.max(cls, ventana);
|
|
57
|
+
v.cls = cls;
|
|
58
|
+
});
|
|
59
|
+
observar(
|
|
60
|
+
"event",
|
|
61
|
+
(e) => {
|
|
62
|
+
const id = (e as PerformanceEntry & { interactionId?: number }).interactionId;
|
|
63
|
+
if (id) interacciones.set(id, Math.max(interacciones.get(id) ?? 0, e.duration));
|
|
64
|
+
},
|
|
65
|
+
{ durationThreshold: 16 },
|
|
66
|
+
);
|
|
67
|
+
let mandado = false;
|
|
68
|
+
const mandar = () => {
|
|
69
|
+
if (mandado || (v.fcp === undefined && v.lcp === undefined)) return;
|
|
70
|
+
mandado = true;
|
|
71
|
+
const n = performance.getEntriesByType("navigation")[0] as PerformanceNavigationTiming | undefined;
|
|
72
|
+
const d = [...interacciones.values()].sort((a, b) => b - a);
|
|
73
|
+
const red = (navigator as Navigator & { connection?: { effectiveType?: string } }).connection?.effectiveType;
|
|
74
|
+
enviar(
|
|
75
|
+
JSON.stringify({
|
|
76
|
+
tipo: "vitales",
|
|
77
|
+
ruta: rutaGenerica(location.pathname),
|
|
78
|
+
lcp: v.lcp,
|
|
79
|
+
fcp: v.fcp,
|
|
80
|
+
cls: v.cls ?? 0,
|
|
81
|
+
inp: d.length ? d[Math.min(Math.floor(d.length / 50), d.length - 1)] : undefined,
|
|
82
|
+
ttfb: n && n.responseStart > 0 ? n.responseStart : undefined,
|
|
83
|
+
carga: n && n.loadEventEnd > 0 ? n.loadEventEnd : undefined,
|
|
84
|
+
ancho: innerWidth,
|
|
85
|
+
red,
|
|
86
|
+
nav: n?.type,
|
|
87
|
+
}),
|
|
88
|
+
);
|
|
89
|
+
};
|
|
90
|
+
addEventListener("visibilitychange", () => {
|
|
91
|
+
if (document.visibilityState === "hidden") mandar();
|
|
92
|
+
});
|
|
93
|
+
addEventListener("pagehide", mandar);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const vistos = new Set<string>();
|
|
97
|
+
|
|
98
|
+
export function reportarErrorNavegador(error: unknown, donde?: string) {
|
|
99
|
+
try {
|
|
100
|
+
const e = error instanceof Error ? error : new Error(typeof error === "string" ? error : JSON.stringify(error) ?? String(error));
|
|
101
|
+
const mensaje = (e.message || String(error)).slice(0, 2000);
|
|
102
|
+
const pila = e.stack ?? "";
|
|
103
|
+
if (/^Script error\.?$|ResizeObserver loop|^AbortError|signal is aborted/i.test(mensaje)) return;
|
|
104
|
+
if (/chrome-extension:|moz-extension:|safari-extension:/.test(pila)) return;
|
|
105
|
+
const clave = `${e.name}:${mensaje}`;
|
|
106
|
+
if (vistos.has(clave) || vistos.size >= 10) return;
|
|
107
|
+
vistos.add(clave);
|
|
108
|
+
enviar(JSON.stringify({ mensaje, tipo: e.name, pila: pila.slice(0, 8000), url: location.href, donde }));
|
|
109
|
+
} catch {
|
|
110
|
+
/* reportar nunca rompe la página */
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export function ReportarErrores() {
|
|
115
|
+
useEffect(() => {
|
|
116
|
+
const alError = (ev: ErrorEvent) => reportarErrorNavegador(ev.error ?? ev.message, "window.onerror");
|
|
117
|
+
const alRechazo = (ev: PromiseRejectionEvent) => reportarErrorNavegador(ev.reason, "promesa sin capturar");
|
|
118
|
+
addEventListener("error", alError);
|
|
119
|
+
addEventListener("unhandledrejection", alRechazo);
|
|
120
|
+
medirVitales();
|
|
121
|
+
return () => {
|
|
122
|
+
removeEventListener("error", alError);
|
|
123
|
+
removeEventListener("unhandledrejection", alRechazo);
|
|
124
|
+
};
|
|
125
|
+
}, []);
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/* «El ícono viaja» — mitad del MÓDULO (handoff «Transiciones entre módulos», partes 1b y 1c).
|
|
2
|
+
El mismo archivo vive en cada módulo, al lado de su layout raíz (copiar tal cual; el original está
|
|
3
|
+
en portal-hcmz/docs/transicion-portal.ts). Se pone en <head>, antes de pintar:
|
|
4
|
+
<script dangerouslySetInnerHTML={{ __html: TRANSICION_PORTAL }} />
|
|
5
|
+
- Entrada (1b): si se llegó desde el portal (Referrer-Policy del portal = strict-origin-when-cross-origin,
|
|
6
|
+
llega el origen), el <main> funde 220 ms desde 6 px abajo. La barra NO se anima: queda fija desde el
|
|
7
|
+
primer cuadro donde terminó la réplica del portal. La marca se quita al terminar ese fundido (no con un
|
|
8
|
+
temporizador: si el módulo pinta tarde, el fundido igual corre y no hay brinco). Por eso la barra tiene que estar FUERA del <main>.
|
|
9
|
+
- Regreso (1c): un clic en cualquier enlace a la portada del portal (el botón «Portal») funde el <main>
|
|
10
|
+
160 ms y navega en el mismo clic (la red corre en paralelo; esperar el fundido solo sumaba espera). El portal, al ver que venís de acá, baja ícono y nombre a la tarjeta.
|
|
11
|
+
- Precarga: al dejar el puntero ~200 ms sobre el botón «Portal», Chrome/Edge ya piden la portada (regla de
|
|
12
|
+
precarga, mismo sitio: va con la cookie de Access) y el regreso no espera al servidor.
|
|
13
|
+
- NADA de este script agrega nodos al HTML antes de que React hidrate: un <style>/<script> metido en <head> mientras
|
|
14
|
+
se lee la página hacía que React no reconociera su <head>, tirara el error #418 y volviera a pintar TODA la página
|
|
15
|
+
en cada carga (~0,6-1,2 s de congelamiento, medido el 26-oct). Por eso el estilo va como hoja adoptada (no es un
|
|
16
|
+
nodo) y la regla de precarga se agrega al terminar de cargar.
|
|
17
|
+
Con movimiento reducido, teclas modificadoras, botón del medio o target=_blank: navegación normal. */
|
|
18
|
+
export const TRANSICION_PORTAL = `(function(){try{
|
|
19
|
+
var P="https://portal.hcmz.online",h=document.documentElement,C="cubic-bezier(.2,0,.2,1)";
|
|
20
|
+
var quieto=matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
21
|
+
var r=document.referrer&&new URL(document.referrer);
|
|
22
|
+
if(r&&r.origin===P&&!quieto){h.dataset.desdePortal="1";var fin=function(){delete h.dataset.desdePortal};addEventListener("animationend",function(e){if(e.animationName==="entra-modulo")fin()});setTimeout(fin,4000)}
|
|
23
|
+
var css="html[data-desde-portal] main{animation:entra-modulo 220ms "+C+" backwards}@keyframes entra-modulo{from{opacity:0;transform:translateY(6px)}}";
|
|
24
|
+
try{var hoja=new CSSStyleSheet();hoja.replaceSync(css);document.adoptedStyleSheets=document.adoptedStyleSheets.concat(hoja)}catch(_){addEventListener("DOMContentLoaded",function(){var s=document.createElement("style");s.textContent=css;document.head.appendChild(s)})}
|
|
25
|
+
if(HTMLScriptElement.supports&&HTMLScriptElement.supports("speculationrules"))addEventListener("load",function(){var sr=document.createElement("script");sr.type="speculationrules";sr.textContent=JSON.stringify({prefetch:[{where:{href_matches:P+"/"},eagerness:"moderate"}]});document.head.appendChild(sr)});
|
|
26
|
+
document.addEventListener("click",function(e){
|
|
27
|
+
if(quieto||e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return;
|
|
28
|
+
var a=e.target&&e.target.closest&&e.target.closest("a[href]");
|
|
29
|
+
if(!a||(a.target&&a.target!=="_self")||a.hasAttribute("download"))return;
|
|
30
|
+
var u=new URL(a.href,location.href);
|
|
31
|
+
if(u.origin!==P||u.pathname!=="/"||u.search||u.hash)return;
|
|
32
|
+
var m=document.querySelector("main");
|
|
33
|
+
if(!m||!m.animate)return;
|
|
34
|
+
e.preventDefault();
|
|
35
|
+
var an=m.animate([{opacity:1},{opacity:0}],{duration:160,easing:C,fill:"forwards"});
|
|
36
|
+
requestAnimationFrame(function(){location.href=P+"/"});
|
|
37
|
+
addEventListener("pageshow",function(ev){if(ev.persisted)an.cancel()},{once:true});
|
|
38
|
+
});
|
|
39
|
+
}catch(e){}})()`;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { LayoutGrid } from "lucide-react";
|
|
2
|
+
import type { MouseEvent } from "react";
|
|
3
|
+
|
|
4
|
+
export const URL_PORTAL = "https://portal.hcmz.online";
|
|
5
|
+
|
|
6
|
+
type Props = {
|
|
7
|
+
/** A dónde lleva (por omisión, la portada del portal). */
|
|
8
|
+
href?: string;
|
|
9
|
+
/** Solo ícono, 44×44 (cabecera móvil). */
|
|
10
|
+
compacto?: boolean;
|
|
11
|
+
/** Si se pasa, se usa en vez de navegar con href. */
|
|
12
|
+
onClick?: () => void;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/* Botón «Portal»: el último de la barra de todo módulo (regla barra-de-modulo.md).
|
|
16
|
+
Alto 34, padding 0 13, gap 7, radio 8, borde fuerte, glifo layout-grid 15 + «Portal» 13/500.
|
|
17
|
+
Nunca «Inicio», «Volver» ni «Salir». La transición del portal lo detecta por su href. */
|
|
18
|
+
export function BotonPortal({ href = URL_PORTAL, compacto = false, onClick }: Props) {
|
|
19
|
+
const manejar = onClick
|
|
20
|
+
? (e: MouseEvent) => {
|
|
21
|
+
e.preventDefault();
|
|
22
|
+
onClick();
|
|
23
|
+
}
|
|
24
|
+
: undefined;
|
|
25
|
+
|
|
26
|
+
if (compacto) {
|
|
27
|
+
return (
|
|
28
|
+
<a href={href} onClick={manejar} aria-label="Portal" title="Portal" className="inline-flex size-11 items-center justify-center rounded-[8px] text-tinta-2">
|
|
29
|
+
<LayoutGrid width={17} height={17} strokeWidth={1.75} aria-hidden="true" style={{ flex: "none" }} />
|
|
30
|
+
</a>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<a
|
|
36
|
+
href={href}
|
|
37
|
+
onClick={manejar}
|
|
38
|
+
className="inline-flex h-[34px] cursor-pointer items-center gap-[7px] whitespace-nowrap rounded-[8px] border border-borde-fuerte bg-tarjeta px-[13px] font-sans text-ui font-medium text-tinta hover:bg-sutil"
|
|
39
|
+
>
|
|
40
|
+
<LayoutGrid width={15} height={15} strokeWidth={1.75} aria-hidden="true" style={{ flex: "none" }} />
|
|
41
|
+
Portal
|
|
42
|
+
</a>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Divisor vertical que va antes del botón «Portal» en la cabecera de escritorio. */
|
|
47
|
+
export function DivisorCabecera({ alto = 26 }: { alto?: 24 | 26 }) {
|
|
48
|
+
return <span aria-hidden="true" className={`w-px flex-none bg-borde-sutil ${alto === 24 ? "h-6" : "h-[26px]"}`} />;
|
|
49
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { Moon, Sun } from "lucide-react";
|
|
4
|
+
import { useSyncExternalStore } from "react";
|
|
5
|
+
|
|
6
|
+
type Tema = "claro" | "oscuro";
|
|
7
|
+
|
|
8
|
+
function leer(): Tema {
|
|
9
|
+
return document.documentElement.dataset.tema === "oscuro" ? "oscuro" : "claro";
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function suscribir(cb: () => void) {
|
|
13
|
+
const obs = new MutationObserver(cb);
|
|
14
|
+
obs.observe(document.documentElement, { attributes: true, attributeFilter: ["data-tema"] });
|
|
15
|
+
return () => obs.disconnect();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/* Cambia data-tema en <html>; el script TEMA_INICIAL lo guarda en la cookie portal-tema y lo heredan todos los módulos. */
|
|
19
|
+
export function BotonTema({ grande = false }: { grande?: boolean }) {
|
|
20
|
+
const tema = useSyncExternalStore(suscribir, leer, () => "claro" as Tema);
|
|
21
|
+
const Glifo = tema === "oscuro" ? Sun : Moon;
|
|
22
|
+
|
|
23
|
+
function alternar() {
|
|
24
|
+
document.documentElement.dataset.tema = leer() === "oscuro" ? "claro" : "oscuro";
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<button
|
|
29
|
+
type="button"
|
|
30
|
+
onClick={alternar}
|
|
31
|
+
aria-label={tema === "oscuro" ? "Cambiar a modo claro" : "Cambiar a modo oscuro"}
|
|
32
|
+
className={
|
|
33
|
+
grande
|
|
34
|
+
? "inline-flex size-11 cursor-pointer items-center justify-center border-0 bg-transparent text-tinta-2"
|
|
35
|
+
: "inline-flex size-[34px] cursor-pointer items-center justify-center rounded-[8px] border border-borde-fuerte bg-control text-tinta transition-colors duration-[120ms] ease-estandar hover:bg-sutil"
|
|
36
|
+
}
|
|
37
|
+
>
|
|
38
|
+
<Glifo width={grande ? 18 : 16} height={grande ? 18 : 16} strokeWidth={1.85} aria-hidden="true" />
|
|
39
|
+
</button>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import Image from "next/image";
|
|
2
|
+
import { Circle, type LucideIcon } from "lucide-react";
|
|
3
|
+
import type { ReactNode } from "react";
|
|
4
|
+
import { BotonPortal, DivisorCabecera, URL_PORTAL } from "./BotonPortal";
|
|
5
|
+
import { BotonTema } from "./BotonTema";
|
|
6
|
+
|
|
7
|
+
export type Modulo = {
|
|
8
|
+
/** = PORTAL_MODULE_ID (para «Pedir permiso para editar»). */
|
|
9
|
+
id: string;
|
|
10
|
+
/** El de la tarjeta del portal; una sola línea. */
|
|
11
|
+
nombre: string;
|
|
12
|
+
/** Para la barra móvil. */
|
|
13
|
+
nombreCorto?: string;
|
|
14
|
+
/** El MISMO glifo de la tarjeta del portal (import por nombre de lucide-react). */
|
|
15
|
+
icono: LucideIcon;
|
|
16
|
+
/** Caja del ícono sin acento (fondo hundida, tinta-2), como el Monitor. Por omisión lleva el acento del módulo. */
|
|
17
|
+
sinAcento?: boolean;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
type Props = {
|
|
21
|
+
modulo: Modulo;
|
|
22
|
+
/** Quién mira; null = sin sesión (no se muestra «quién»). */
|
|
23
|
+
persona: { nombre: string; nivel?: string; puedeEditar: boolean } | null;
|
|
24
|
+
/** Extras del grupo derecho (frescura, avisos), alto ≤ 34. Van ANTES del tema. */
|
|
25
|
+
extras?: ReactNode;
|
|
26
|
+
/** Franja propia DEBAJO de la barra (pestañas / navegación del módulo). */
|
|
27
|
+
navegacion?: ReactNode;
|
|
28
|
+
/** Barra pegada arriba al hacer scroll. */
|
|
29
|
+
fija?: boolean;
|
|
30
|
+
/** Ancho máximo del contenido; "completo" = sin límite (bandejas, tableros). */
|
|
31
|
+
ancho?: "normal" | "completo";
|
|
32
|
+
urlPortal?: string;
|
|
33
|
+
/** Debajo de la barra móvil (p. ej. la frescura de los datos). */
|
|
34
|
+
extrasMovil?: ReactNode;
|
|
35
|
+
/** Acciones DENTRO de la barra móvil (≤ 760 px), antes del tema: botones de ícono 44×44 (BotonIcono), máximo 1–2
|
|
36
|
+
* para que el nombre quepa en los 56 px. Por omisión la barra móvil no lleva extras. */
|
|
37
|
+
accionesMovil?: ReactNode;
|
|
38
|
+
/** true = repetir `extras` dentro de la barra móvil (cuando los extras ya son BotonIcono de 44, p. ej. un engrane de ajustes).
|
|
39
|
+
* Si se pasa `accionesMovil`, gana `accionesMovil`. */
|
|
40
|
+
extrasEnMovil?: boolean;
|
|
41
|
+
/** false = no mostrar el aviso «Solo lectura» (módulos que son de solo lectura para todos). */
|
|
42
|
+
avisoSoloLectura?: boolean;
|
|
43
|
+
/** Clases extra del <main> (p. ej. "flex flex-col gap-[18px]"). */
|
|
44
|
+
claseContenido?: string;
|
|
45
|
+
/** Texto del aviso de solo lectura, después de «Solo lectura.». */
|
|
46
|
+
textoSoloLectura?: ReactNode;
|
|
47
|
+
children: ReactNode;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/* Barra de módulo (Sistema-de-diseno-Portal-HCMZ/reglas/barra-de-modulo.md). NO cambiar medidas ni orden: la
|
|
51
|
+
transición «el ícono viaja» del portal cuenta con ellas (ícono en 88,29; nombre en 130,29). La barra va FUERA
|
|
52
|
+
del <main>. La sesión se maneja en el Portal: aquí solo se regresa a él. */
|
|
53
|
+
export function Shell({ modulo, persona, extras, navegacion, fija, ancho = "normal", urlPortal = URL_PORTAL, textoSoloLectura = "Tu cuenta puede ver pero no cambiar nada.", extrasMovil, accionesMovil, extrasEnMovil, avisoSoloLectura = true, claseContenido = "", children }: Props) {
|
|
54
|
+
const Glifo = modulo.icono ?? Circle;
|
|
55
|
+
const accionMovil = accionesMovil ?? (extrasEnMovil ? extras : null);
|
|
56
|
+
const nivel = persona?.nivel ?? (persona?.puedeEditar ? "Puede editar" : "Solo lectura");
|
|
57
|
+
const pedirEditar = `${urlPortal}/solicitar?modulo=${encodeURIComponent(modulo.id)}&nivel=editar`;
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<div className="min-h-screen bg-pagina">
|
|
61
|
+
<a
|
|
62
|
+
href="#contenido"
|
|
63
|
+
className="sr-only focus:not-sr-only focus:absolute focus:left-3 focus:top-3 focus:z-50 focus:rounded-control focus:bg-tarjeta focus:px-3 focus:py-2 focus:text-ui"
|
|
64
|
+
>
|
|
65
|
+
Saltar al contenido
|
|
66
|
+
</a>
|
|
67
|
+
|
|
68
|
+
<div className={`noprint ${fija ? "sticky top-0 z-30" : ""}`}>
|
|
69
|
+
{/* Escritorio */}
|
|
70
|
+
<header className="flex h-14 items-center gap-[14px] border-b border-borde-sutil bg-tarjeta px-6 max-[760px]:hidden">
|
|
71
|
+
<Monograma alto={30} />
|
|
72
|
+
<DivisorCabecera alto={24} />
|
|
73
|
+
<span className={`flex size-7 flex-none items-center justify-center rounded-[8px] ${modulo.sinAcento ? "bg-hundida text-tinta-2" : "bg-acento-bg text-acento-tinta"}`}>
|
|
74
|
+
<Glifo width={16} height={16} strokeWidth={1.75} aria-hidden="true" />
|
|
75
|
+
</span>
|
|
76
|
+
<span className="whitespace-nowrap font-display text-[15px] font-medium tracking-[-0.01em] text-tinta">{modulo.nombre}</span>
|
|
77
|
+
<div className="ml-auto flex items-center gap-[14px]">
|
|
78
|
+
{extras}
|
|
79
|
+
<BotonTema />
|
|
80
|
+
{persona && (
|
|
81
|
+
<div className="flex flex-col items-end gap-0.5 max-[1000px]:hidden">
|
|
82
|
+
<span className="whitespace-nowrap text-ui-lg font-medium text-tinta">{persona.nombre}</span>
|
|
83
|
+
<span className="font-mono text-etiqueta uppercase tracking-[0.08em] text-tinta-3">{nivel}</span>
|
|
84
|
+
</div>
|
|
85
|
+
)}
|
|
86
|
+
<DivisorCabecera />
|
|
87
|
+
<BotonPortal href={urlPortal} />
|
|
88
|
+
</div>
|
|
89
|
+
</header>
|
|
90
|
+
|
|
91
|
+
{/* Móvil */}
|
|
92
|
+
<header className="hidden border-b border-borde-sutil bg-tarjeta max-[760px]:block">
|
|
93
|
+
<div className="flex h-14 items-center gap-2.5 pl-4 pr-1.5">
|
|
94
|
+
<Monograma alto={28} />
|
|
95
|
+
<span className={`whitespace-nowrap font-display text-[14.5px] font-medium text-tinta ${accionMovil ? "min-w-0 truncate" : ""}`}>{modulo.nombreCorto ?? modulo.nombre}</span>
|
|
96
|
+
<span className="ml-auto flex">
|
|
97
|
+
{accionMovil && <span className="flex items-center">{accionMovil}</span>}
|
|
98
|
+
<BotonTema grande />
|
|
99
|
+
<BotonPortal href={urlPortal} compacto />
|
|
100
|
+
</span>
|
|
101
|
+
</div>
|
|
102
|
+
{extrasMovil && <div className="px-4 pb-2.5">{extrasMovil}</div>}
|
|
103
|
+
</header>
|
|
104
|
+
|
|
105
|
+
{navegacion}
|
|
106
|
+
</div>
|
|
107
|
+
|
|
108
|
+
<main
|
|
109
|
+
id="contenido"
|
|
110
|
+
className={`mx-auto w-full px-7 pb-9 pt-7 max-[620px]:px-4 max-[620px]:pb-6 max-[620px]:pt-5 ${ancho === "completo" ? "" : "max-w-[1240px]"} ${claseContenido}`}
|
|
111
|
+
>
|
|
112
|
+
{avisoSoloLectura && persona && !persona.puedeEditar && (
|
|
113
|
+
<div className="noprint mb-5 flex flex-wrap items-center gap-x-2 gap-y-1 rounded-panel border border-borde-sutil bg-sindatos-bg px-4 py-3 text-ui text-tinta-2">
|
|
114
|
+
<Circle width={14} height={14} strokeWidth={1.75} aria-hidden="true" className="text-sindatos" />
|
|
115
|
+
<span>
|
|
116
|
+
<b className="font-medium text-tinta">Solo lectura.</b> {textoSoloLectura}
|
|
117
|
+
</span>
|
|
118
|
+
<a className="font-medium text-tinta underline underline-offset-2" href={pedirEditar}>
|
|
119
|
+
Pedir permiso para editar
|
|
120
|
+
</a>
|
|
121
|
+
</div>
|
|
122
|
+
)}
|
|
123
|
+
{children}
|
|
124
|
+
</main>
|
|
125
|
+
</div>
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** Monograma «M» del hospital (alt según la regla de marca). Lee /marca/monograma-m.png del public/ del módulo (todos lo tienen). */
|
|
130
|
+
export function Monograma({ alto = 30 }: { alto?: number }) {
|
|
131
|
+
return <Image src="/marca/monograma-m.png" alt="Hospital Centro Médico Zacapa" width={200} height={170} priority style={{ height: alto, width: "auto", display: "block" }} />;
|
|
132
|
+
}
|
package/src/texto.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// @j3ehcmz/ui/texto — utilidades de texto puras (sirven en servidor y navegador, sin React).
|
|
2
|
+
|
|
3
|
+
/** Quita tildes y diéresis para comparar o buscar: «Josué Peña Ñuñez» → «Josue Pena Nunez». No cambia mayúsculas.
|
|
4
|
+
* Ojo: la ñ también pasa a n (lo que se quiere al buscar: «pena» encuentra «Peña»). */
|
|
5
|
+
export function sinAcentos(texto: string): string {
|
|
6
|
+
return texto.normalize("NFD").replace(/[̀-ͯ]/g, "").normalize("NFC");
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/** Para buscar: sin tildes, minúsculas y espacios colapsados. */
|
|
10
|
+
export function normalizar(texto: string): string {
|
|
11
|
+
return sinAcentos(texto).toLowerCase().replace(/\s+/g, " ").trim();
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const TITULOS = /^(dr|dra|lic|licda|ing|inga|sr|sra|srta|msc|mba|pem|arq)\.?$/i;
|
|
15
|
+
|
|
16
|
+
/** Iniciales de una persona: primera letra del primer nombre y de la ÚLTIMA palabra (el apellido que queda), en mayúsculas.
|
|
17
|
+
* Salta títulos (Dr., Licda., Ing.…) y lo que no empieza con letra («(correo)», números). Una sola palabra → sus dos
|
|
18
|
+
* primeras letras. Vacío → «?». «Dra. María José García López» → «ML»; «admin@» → «AD». */
|
|
19
|
+
export function iniciales(nombre: string, max: 1 | 2 = 2): string {
|
|
20
|
+
const palabras = nombre
|
|
21
|
+
.trim()
|
|
22
|
+
.split(/\s+/)
|
|
23
|
+
.filter((p) => p && !TITULOS.test(p) && /^\p{L}/u.test(p));
|
|
24
|
+
if (palabras.length === 0) return "?";
|
|
25
|
+
const primera = palabras[0]!;
|
|
26
|
+
if (max === 1) return primera[0]!.toLocaleUpperCase("es");
|
|
27
|
+
if (palabras.length === 1) {
|
|
28
|
+
const letras = [...primera].filter((c) => /\p{L}/u.test(c));
|
|
29
|
+
return letras.slice(0, 2).join("").toLocaleUpperCase("es");
|
|
30
|
+
}
|
|
31
|
+
return (primera[0]! + palabras[palabras.length - 1]![0]!).toLocaleUpperCase("es");
|
|
32
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
4
|
+
import { ChipEstado, type Tono } from "../ui/contenido";
|
|
5
|
+
import { aMs, fechaCorta, fechaHora, hace, type OpcionesHace } from "./relativo";
|
|
6
|
+
|
|
7
|
+
type Fecha = string | number | Date | null | undefined;
|
|
8
|
+
|
|
9
|
+
/** Reloj que se actualiza solo. `null` en el servidor y en el primer render (no desfasa la hidratación).
|
|
10
|
+
* Se pausa con la pestaña oculta y se pone al día al volver (regla de rendimiento: nada corre de fondo). */
|
|
11
|
+
export function useAhora(cadaMs = 1000): number | null {
|
|
12
|
+
const [ahora, setAhora] = useState<number | null>(null);
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
let t: ReturnType<typeof setInterval> | undefined;
|
|
15
|
+
const tic = () => setAhora(Date.now());
|
|
16
|
+
const arrancar = () => {
|
|
17
|
+
clearInterval(t);
|
|
18
|
+
tic();
|
|
19
|
+
t = setInterval(tic, cadaMs);
|
|
20
|
+
};
|
|
21
|
+
const visibilidad = () => (document.hidden ? clearInterval(t) : arrancar());
|
|
22
|
+
const t0 = setTimeout(arrancar, 0);
|
|
23
|
+
document.addEventListener("visibilitychange", visibilidad);
|
|
24
|
+
return () => {
|
|
25
|
+
clearTimeout(t0);
|
|
26
|
+
clearInterval(t);
|
|
27
|
+
document.removeEventListener("visibilitychange", visibilidad);
|
|
28
|
+
};
|
|
29
|
+
}, [cadaMs]);
|
|
30
|
+
return ahora;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** «hace 4 min» que se actualiza solo (cada 15 s). Antes de montar muestra la fecha (igual en servidor y navegador).
|
|
34
|
+
* El `title` lleva la fecha y hora exactas de Guatemala. */
|
|
35
|
+
export function Hace({ fecha, prefijo, corte, nunca = "nunca", className }: { fecha: Fecha; prefijo?: string; corte?: OpcionesHace["corte"]; nunca?: string; className?: string }) {
|
|
36
|
+
const ahora = useAhora(15_000);
|
|
37
|
+
const ms = aMs(fecha);
|
|
38
|
+
if (ms === null) return <span className={className}>{nunca}</span>;
|
|
39
|
+
const texto = ahora === null ? fechaCorta(ms) : hace(ms, ahora, { corte });
|
|
40
|
+
return (
|
|
41
|
+
<time dateTime={new Date(ms).toISOString()} title={fechaHora(ms)} className={className}>
|
|
42
|
+
{prefijo ? `${prefijo} ${texto}` : texto}
|
|
43
|
+
</time>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Frescura de los datos de una fuente: «Actualizado hace 2 min» en verde; ámbar pasados `avisoMin`; rojo pasados `criticoMin`;
|
|
48
|
+
* gris si nunca llegó nada. Va en `extras` del Shell o junto al título. */
|
|
49
|
+
export function Frescura({ fecha, avisoMin = 3, criticoMin = 5, sinDatos = "Sin datos todavía", className }: { fecha: Fecha; avisoMin?: number; criticoMin?: number; sinDatos?: string; className?: string }) {
|
|
50
|
+
const ahora = useAhora(1000);
|
|
51
|
+
const ms = aMs(fecha);
|
|
52
|
+
let tono: Tono = "sindatos";
|
|
53
|
+
let texto = sinDatos;
|
|
54
|
+
if (ms !== null) {
|
|
55
|
+
if (ahora === null) {
|
|
56
|
+
texto = `Actualizado ${fechaCorta(ms)}`;
|
|
57
|
+
} else {
|
|
58
|
+
const min = (ahora - ms) / 60_000;
|
|
59
|
+
const rel = hace(ms, ahora);
|
|
60
|
+
tono = min >= criticoMin ? "suspendido" : min >= avisoMin ? "porvencer" : "aldia";
|
|
61
|
+
texto = tono === "suspendido" ? `Última actualización ${rel}` : `Actualizado ${rel}`;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return (
|
|
65
|
+
<span role="status" aria-live="off" title={ms !== null ? fechaHora(ms) : undefined} className={`inline-flex ${className ?? ""}`}>
|
|
66
|
+
<ChipEstado tono={tono}>{texto}</ChipEstado>
|
|
67
|
+
</span>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/* Tiempo relativo en español de Guatemala. Puro (sin React ni Date.now): sirve en servidor, navegador y pruebas.
|
|
2
|
+
Zona: America/Guatemala (UTC−6 fijo, sin horario de verano). */
|
|
3
|
+
|
|
4
|
+
const ZONA = "America/Guatemala";
|
|
5
|
+
const DESFASE_MS = -6 * 3600_000;
|
|
6
|
+
const MIN = 60_000;
|
|
7
|
+
const HORA = 3600_000;
|
|
8
|
+
const DIA = 86400_000;
|
|
9
|
+
|
|
10
|
+
/** Número de día calendario en Guatemala (para «ayer»). */
|
|
11
|
+
function diaGT(ms: number): number {
|
|
12
|
+
return Math.floor((ms + DESFASE_MS) / DIA);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const fmtFecha = new Intl.DateTimeFormat("es-GT", { timeZone: ZONA, day: "numeric", month: "short" });
|
|
16
|
+
const fmtFechaAnio = new Intl.DateTimeFormat("es-GT", { timeZone: ZONA, day: "numeric", month: "short", year: "numeric" });
|
|
17
|
+
const fmtCompleta = new Intl.DateTimeFormat("es-GT", { timeZone: ZONA, day: "numeric", month: "short", year: "numeric", hour: "2-digit", minute: "2-digit", hour12: false });
|
|
18
|
+
|
|
19
|
+
/** «3 nov» (o «3 nov 2025» si es de otro año que `ahora`). */
|
|
20
|
+
export function fechaCorta(ms: number, ahora: number = ms): string {
|
|
21
|
+
const anio = (x: number) => new Date(x + DESFASE_MS).getUTCFullYear();
|
|
22
|
+
return (anio(ms) === anio(ahora) ? fmtFecha : fmtFechaAnio).format(ms);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** «3 nov 2026, 14:05» (hora de Guatemala). Para el `title` de un «hace…». */
|
|
26
|
+
export function fechaHora(ms: number): string {
|
|
27
|
+
return fmtCompleta.format(ms);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export type OpcionesHace = {
|
|
31
|
+
/** "fecha" (por omisión): después de «ayer» se muestra la fecha. "dias": «hace 3 días» hasta 30 días y luego la fecha. */
|
|
32
|
+
corte?: "dias" | "fecha";
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Cuánto hace de `ms` (epoch en milisegundos) visto desde `ahora`:
|
|
37
|
+
* «hace un momento» (< 1 min) → «hace 4 min» → «hace 2 h» (mismo día, o menos de 6 h) → «ayer» → «3 nov».
|
|
38
|
+
* Un futuro de hasta 1 min (relojes desfasados) cuenta como «hace un momento»; más allá se muestra la fecha.
|
|
39
|
+
*/
|
|
40
|
+
export function hace(ms: number, ahora: number, { corte = "fecha" }: OpcionesHace = {}): string {
|
|
41
|
+
if (!Number.isFinite(ms) || !Number.isFinite(ahora)) return "—";
|
|
42
|
+
const d = ahora - ms;
|
|
43
|
+
if (d < -MIN) return fechaCorta(ms, ahora);
|
|
44
|
+
if (d < MIN) return "hace un momento";
|
|
45
|
+
if (d < HORA) return `hace ${Math.floor(d / MIN)} min`;
|
|
46
|
+
const dias = diaGT(ahora) - diaGT(ms);
|
|
47
|
+
if (d < 6 * HORA || dias === 0) return `hace ${Math.floor(d / HORA)} h`;
|
|
48
|
+
if (dias === 1) return "ayer";
|
|
49
|
+
if (corte === "dias" && dias < 30) return `hace ${dias} días`;
|
|
50
|
+
return fechaCorta(ms, ahora);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Convierte lo que suelen traer los datos (ISO, epoch ms, Date) a epoch ms; null si no se puede. */
|
|
54
|
+
export function aMs(fecha: string | number | Date | null | undefined): number | null {
|
|
55
|
+
if (fecha === null || fecha === undefined || fecha === "") return null;
|
|
56
|
+
const ms = fecha instanceof Date ? fecha.getTime() : typeof fecha === "number" ? fecha : Date.parse(fecha);
|
|
57
|
+
return Number.isFinite(ms) ? ms : null;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Duración corta: 45 → «45 s»; 82 → «1 min 22 s»; 3700 → «1 h 1 min»; 200000 → «2 d 7 h». */
|
|
61
|
+
export function duracion(seg: number | null | undefined): string {
|
|
62
|
+
if (seg === null || seg === undefined || !Number.isFinite(seg)) return "—";
|
|
63
|
+
const s = Math.max(0, Math.round(seg));
|
|
64
|
+
if (s < 60) return `${s} s`;
|
|
65
|
+
const m = Math.floor(s / 60);
|
|
66
|
+
if (m < 60) return `${m} min${s % 60 ? ` ${s % 60} s` : ""}`;
|
|
67
|
+
const h = Math.floor(m / 60);
|
|
68
|
+
if (h < 48) return `${h} h${m % 60 ? ` ${m % 60} min` : ""}`;
|
|
69
|
+
return `${Math.floor(h / 24)} d${h % 24 ? ` ${h % 24} h` : ""}`;
|
|
70
|
+
}
|