@kapiuara/ui 0.17.0 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/README.md +259 -9
  2. package/dist/components/data/KapiScatterChart.d.ts +56 -0
  3. package/dist/components/data/KapiScatterChart.js +90 -0
  4. package/dist/components/data/chartFrame.d.ts +20 -2
  5. package/dist/components/data/chartFrame.js +33 -24
  6. package/dist/components/data/index.d.ts +4 -0
  7. package/dist/components/data/scatterLogic.d.ts +56 -0
  8. package/dist/components/data/scatterLogic.js +43 -0
  9. package/dist/components/display/KapiAvatarGroup.d.ts +14 -2
  10. package/dist/components/display/KapiAvatarGroup.js +25 -23
  11. package/dist/components/display/KapiTimeline.d.ts +14 -0
  12. package/dist/components/display/KapiTimeline.js +28 -21
  13. package/dist/components/display/avatarGroupSlots.d.ts +6 -0
  14. package/dist/components/display/avatarGroupSlots.js +9 -0
  15. package/dist/components/display/index.d.ts +1 -1
  16. package/dist/components/feedback/KapiAlert.d.ts +6 -1
  17. package/dist/components/feedback/KapiAlert.js +45 -44
  18. package/dist/components/feedback/KapiCountdown.d.ts +12 -1
  19. package/dist/components/feedback/KapiCountdown.js +34 -31
  20. package/dist/components/feedback/KapiEmpty.d.ts +6 -1
  21. package/dist/components/feedback/KapiEmpty.js +20 -18
  22. package/dist/components/feedback/KapiProgress.js +1 -1
  23. package/dist/components/feedback/KapiSpinner.d.ts +48 -0
  24. package/dist/components/feedback/KapiSpinner.js +27 -0
  25. package/dist/components/feedback/KapiToastContainer.js +1 -1
  26. package/dist/components/feedback/KapiTour.js +1 -1
  27. package/dist/components/feedback/alertSlots.d.ts +9 -0
  28. package/dist/components/feedback/alertSlots.js +12 -0
  29. package/dist/components/feedback/countdownSlots.d.ts +6 -0
  30. package/dist/components/feedback/countdownSlots.js +9 -0
  31. package/dist/components/feedback/emptySlots.d.ts +8 -0
  32. package/dist/components/feedback/emptySlots.js +11 -0
  33. package/dist/components/feedback/index.d.ts +5 -3
  34. package/dist/components/inputs/KapiFileUpload.d.ts +14 -1
  35. package/dist/components/inputs/KapiFileUpload.js +80 -67
  36. package/dist/components/inputs/formBridgeLogic.d.ts +104 -0
  37. package/dist/components/inputs/formBridgeLogic.js +25 -0
  38. package/dist/components/inputs/index.d.ts +2 -0
  39. package/dist/components/locale/labelRegistry.d.ts +8 -0
  40. package/dist/components/navigation/KapiSteps.d.ts +26 -5
  41. package/dist/components/navigation/KapiSteps.js +55 -43
  42. package/dist/components/overlays/KapiImageViewer.d.ts +63 -0
  43. package/dist/components/overlays/KapiImageViewer.js +106 -0
  44. package/dist/components/overlays/KapiShortcutsHelp.d.ts +53 -0
  45. package/dist/components/overlays/KapiShortcutsHelp.js +55 -0
  46. package/dist/components/overlays/KapiTooltip.d.ts +49 -10
  47. package/dist/components/overlays/KapiTooltip.js +110 -58
  48. package/dist/components/overlays/KapiViewport.d.ts +63 -0
  49. package/dist/components/overlays/KapiViewport.js +195 -0
  50. package/dist/components/overlays/index.d.ts +8 -0
  51. package/dist/components/overlays/shortcutsHelpSlots.d.ts +9 -0
  52. package/dist/components/overlays/shortcutsHelpSlots.js +12 -0
  53. package/dist/components/overlays/viewportLogic.d.ts +73 -0
  54. package/dist/components/overlays/viewportLogic.js +54 -0
  55. package/dist/components/slotCatalog.d.ts +33 -0
  56. package/dist/components/slotCatalog.js +30 -20
  57. package/dist/css/base.css +1 -1
  58. package/dist/css/components/data/KapiScatterChart.css +1 -0
  59. package/dist/css/components/display/display.css +1 -1
  60. package/dist/css/components/inputs/KapiFileUpload.css +1 -1
  61. package/dist/css/components/navigation/KapiSteps.css +1 -1
  62. package/dist/css/components/overlays/KapiViewport.css +1 -0
  63. package/dist/css/components/overlays/overlays.css +1 -1
  64. package/dist/hooks/elementSizeLogic.d.ts +15 -0
  65. package/dist/hooks/elementSizeLogic.js +7 -0
  66. package/dist/hooks/hotkeyLogic.d.ts +9 -0
  67. package/dist/hooks/hotkeyLogic.js +16 -15
  68. package/dist/hooks/hotkeyRegistry.d.ts +44 -0
  69. package/dist/hooks/hotkeyRegistry.js +32 -0
  70. package/dist/hooks/index.d.ts +10 -0
  71. package/dist/hooks/useDebouncedValue.d.ts +30 -0
  72. package/dist/hooks/useDebouncedValue.js +26 -0
  73. package/dist/hooks/useDisclosure.d.ts +39 -0
  74. package/dist/hooks/useDisclosure.js +35 -0
  75. package/dist/hooks/useElementSize.d.ts +27 -0
  76. package/dist/hooks/useElementSize.js +29 -0
  77. package/dist/hooks/useHotkey.d.ts +8 -0
  78. package/dist/hooks/useHotkey.js +27 -15
  79. package/dist/index.js +201 -188
  80. package/dist/kapi.css +1 -1
  81. package/dist/kapi.layered.css +1 -1
  82. package/dist/logic.d.ts +4 -0
  83. package/dist/logic.js +33 -29
  84. package/package.json +1 -1
@@ -0,0 +1,56 @@
1
+ /** Un punto de dispersión: dos valores numéricos y una etiqueta opcional. */
2
+ export type KapiScatterPoint = {
3
+ /** Valor sobre el eje horizontal. */
4
+ x: number;
5
+ /** Valor sobre el eje vertical. */
6
+ y: number;
7
+ /**
8
+ * Nombre del punto: es la cabecera de su fila en la tabla y abre su descripción accesible. Sin
9
+ * él, la fila se llama con el nombre de la serie y la posición del punto (`Ventas 3`).
10
+ */
11
+ label?: string | undefined;
12
+ };
13
+ /** Eje de dispersión: su ventana y las marcas de adentro, en unidades de dato. */
14
+ export type KapiScatterAxis = {
15
+ /** Valor del borde inferior. */
16
+ min: number;
17
+ /** Valor del borde superior. */
18
+ max: number;
19
+ /** Marcas, de `min` a `max` inclusive. */
20
+ ticks: readonly number[];
21
+ };
22
+ /**
23
+ * Ventana redondeada que cubre `values`, con a lo sumo `tickCount` tramos.
24
+ *
25
+ * **No es `barScale` y no debe serlo.** El eje de un gráfico de barras tiene que arrancar en CERO,
26
+ * porque el largo de la barra ES el valor y truncar el eje miente sobre las proporciones. El de una
27
+ * dispersión es una ventana sobre los datos: forzarlo a cero aplastaría la nube contra una esquina
28
+ * cuando los valores están lejos del origen (sueldos, años, temperaturas). Son dos reglas distintas
29
+ * sobre el mismo problema, no la misma regla escrita dos veces.
30
+ */
31
+ export declare const scatterAxis: (values: readonly number[], tickCount?: number) => KapiScatterAxis;
32
+ /**
33
+ * Posición de un punto en porcentaje de la ventana (0 a 100 en los dos ejes). `cy` se mide **desde
34
+ * arriba**, que es la convención de la que vienen los nombres `cx`/`cy`; el gráfico no usa SVG,
35
+ * posiciona HTML desde abajo y da vuelta el valor al aplicarlo (`y: 100 - cy`).
36
+ *
37
+ * Un eje de ancho cero devuelve el centro en vez de dividir por cero.
38
+ */
39
+ export declare const scatterPosition: (point: KapiScatterPoint, x: KapiScatterAxis, y: KapiScatterAxis) => {
40
+ cx: number;
41
+ cy: number;
42
+ };
43
+ /**
44
+ * ¿El punto cae dentro de la ventana? Sirve para no dibujar un punto pisado contra el borde, donde
45
+ * mentiría sobre su valor.
46
+ *
47
+ * Qué filtra HOY en `KapiScatterChart`, que es lo único que lo usa: sólo los puntos **no finitos**
48
+ * (`NaN`, infinitos), porque toda comparación con ellos es falsa. Un punto finito no puede quedar
49
+ * afuera, porque los dos ejes salen de `scatterAxis` sobre esos mismos puntos y esa función
50
+ * redondea la ventana hacia afuera. El componente no acepta ejes fijos del consumidor; la función
51
+ * es pública y sí sirve para eso, pero esa combinación todavía no existe acá. Ojo con el filtro:
52
+ * un punto no finito desaparece del dibujo y la tabla lo sigue listando.
53
+ */
54
+ export declare const scatterInside: (point: KapiScatterPoint, x: KapiScatterAxis, y: KapiScatterAxis) => boolean;
55
+ /** Texto corto de una marca: entero si lo es, si no con los decimales que haga falta (hasta 2). */
56
+ export declare const scatterTickLabel: (value: number) => string;
@@ -0,0 +1,43 @@
1
+ //#region src/components/data/scatterLogic.ts
2
+ var e = (e, t = 0) => Number.isFinite(e) ? e : t, t = (e, t) => {
3
+ let n = e / Math.max(1, t), r = 10 ** Math.floor(Math.log10(n)), i = n / r;
4
+ return (i <= 1 ? 1 : i <= 2 ? 2 : i <= 5 ? 5 : 10) * r;
5
+ }, n = (n, r = 4) => {
6
+ let i = Math.max(1, Math.floor(e(r, 4))), a = n.filter((e) => Number.isFinite(e));
7
+ if (a.length === 0) return {
8
+ min: 0,
9
+ max: 1,
10
+ ticks: [0, 1]
11
+ };
12
+ let o = a[0], s = o;
13
+ for (let e of a) e < o && (o = e), e > s && (s = e);
14
+ if (o === s) {
15
+ let e = Math.abs(o) > 0 ? Math.abs(o) / 10 : 1;
16
+ o -= e, s += e;
17
+ }
18
+ let c = t(s - o, i);
19
+ if (!(c > 0) || !Number.isFinite(c)) return {
20
+ min: 0,
21
+ max: 1,
22
+ ticks: [0, 1]
23
+ };
24
+ let l = Math.floor(o / c) * c, u = Math.ceil(s / c) * c, d = Math.max(1, Math.round((u - l) / c)), f = [...new Set(Array.from({ length: d + 1 }, (e, t) => Number((l + t * c).toPrecision(12))))];
25
+ return {
26
+ min: Number(l.toPrecision(12)),
27
+ max: Number(u.toPrecision(12)),
28
+ ticks: f
29
+ };
30
+ }, r = (e, t, n) => {
31
+ let r = t.max - t.min, i = n.max - n.min, a = r === 0 ? 50 : (e.x - t.min) / r * 100, o = i === 0 ? 50 : 100 - (e.y - n.min) / i * 100;
32
+ return {
33
+ cx: Number(a.toFixed(3)),
34
+ cy: Number(o.toFixed(3))
35
+ };
36
+ }, i = (e, t, n) => e.x >= t.min && e.x <= t.max && e.y >= n.min && e.y <= n.max, a = (e) => {
37
+ if (!Number.isFinite(e)) return "";
38
+ if (Number.isInteger(e)) return String(e);
39
+ let t = Math.abs(e);
40
+ return e.toFixed(t < 1 ? 2 : 1);
41
+ };
42
+ //#endregion
43
+ export { n as scatterAxis, i as scatterInside, r as scatterPosition, a as scatterTickLabel };
@@ -1,6 +1,9 @@
1
1
  import type { HTMLAttributes, Ref } from "react";
2
2
  import { type KapiAvatarSize, type KapiAvatarTone } from "./KapiAvatar.js";
3
3
  import type { KapiLabelsOverride } from "../labelsLogic.js";
4
+ import type { KapiClassNames } from "../slotCatalog.js";
5
+ /** Partes de `KapiAvatarGroup` que acepta `classNames` (`root`, `item`, `more`). */
6
+ export type KapiAvatarGroupClassNames = KapiClassNames<"avatarGroup">;
4
7
  /** Textos de `KapiAvatarGroup`; se pisan con `labels` o el `KapiLocaleProvider`. */
5
8
  export type KapiAvatarGroupLabels = {
6
9
  /** Nombre accesible del "+N"; `{n}` = personas que no se muestran. */
@@ -19,7 +22,14 @@ export type KapiAvatarGroupItem = {
19
22
  /** Nombre anterior de `tone`, deprecado. @deprecated Usar `tone` (mismos valores). */
20
23
  color?: KapiAvatarTone | undefined;
21
24
  };
22
- export type KapiAvatarGroupProps = Omit<HTMLAttributes<HTMLDivElement>, "children"> & {
25
+ /**
26
+ * `role` se omite porque el componente lo fija: la raíz es siempre `role="group"`. Antes el
27
+ * `{...rest}` iba ÚLTIMO y un `role` del consumidor ganaba; ahora va primero —como pide la
28
+ * convención de passthrough, para que rol, ARIA y handlers propios no se pisen— así que un
29
+ * `role` pasado se descartaría EN SILENCIO. Omitirlo lo convierte en un error de compilación,
30
+ * que es lo que ya hace `KapiAlert` con el suyo.
31
+ */
32
+ export type KapiAvatarGroupProps = Omit<HTMLAttributes<HTMLDivElement>, "children" | "role"> & {
23
33
  /** Ref al `<div>` raíz del grupo. */
24
34
  ref?: Ref<HTMLDivElement> | undefined;
25
35
  /** Personas a mostrar, en orden; las que pasan de `max` se resumen en "+N". */
@@ -30,6 +40,8 @@ export type KapiAvatarGroupProps = Omit<HTMLAttributes<HTMLDivElement>, "childre
30
40
  size?: KapiAvatarSize | undefined;
31
41
  /** Textos propios; pisan los del `KapiLocaleProvider` y los defaults. */
32
42
  labels?: KapiLabelsOverride<KapiAvatarGroupLabels> | undefined;
43
+ /** Clases por parte (`root`, `item`, `more`). Se suman a las propias. */
44
+ classNames?: KapiAvatarGroupClassNames | undefined;
33
45
  };
34
46
  /** Overlapping avatars capped at `max`, with a trailing "+N" tile. Each avatar keeps its name as tooltip. */
35
- export declare function KapiAvatarGroup({ items, max, size, labels, className, style, ...rest }: KapiAvatarGroupProps): import("react").JSX.Element;
47
+ export declare function KapiAvatarGroup({ items, max, size, labels, className, classNames, style, ...rest }: KapiAvatarGroupProps): import("react").JSX.Element;
@@ -1,40 +1,42 @@
1
1
  "use client";
2
2
  import "#kapi-css/components/display/display.css";
3
3
  import { useLabels as e } from "../locale/KapiLocaleProvider.js";
4
+ import { slot as t } from "../slotsLogic.js";
4
5
  /* empty css */
5
- import { KapiAvatar as t } from "./KapiAvatar.js";
6
- import { avatarOverlapPx as n, overflowLabel as r, splitAvatarGroup as i } from "./avatarGroupLogic.js";
7
- import { jsx as a, jsxs as o } from "react/jsx-runtime";
6
+ import { KapiAvatar as n } from "./KapiAvatar.js";
7
+ import { avatarOverlapPx as r, overflowLabel as i, splitAvatarGroup as a } from "./avatarGroupLogic.js";
8
+ import { AVATAR_GROUP_SLOTS as o } from "./avatarGroupSlots.js";
9
+ import { jsx as s, jsxs as c } from "react/jsx-runtime";
8
10
  //#region src/components/display/KapiAvatarGroup.tsx
9
- var s = { overflow: "{n} más" }, c = {
11
+ var l = { overflow: "{n} más" }, u = {
10
12
  sm: 28,
11
13
  md: 36,
12
14
  lg: 48
13
15
  };
14
- function l({ items: l, max: u = 4, size: d = "md", labels: f, className: p, style: m, ...h }) {
15
- let g = e("avatarGroup", s, f), { visible: _, overflow: v } = i(l, u), y = typeof d == "number" ? d : c[d], b = {
16
- "--kapi-avatargroup-overlap": `${n(y)}px`,
17
- ...m
18
- }, x = l.slice(_.length).map((e) => e.name).filter(Boolean).join(", ");
19
- return /* @__PURE__ */ o("div", {
20
- className: ["kapi-avatargroup", p].filter(Boolean).join(" "),
21
- style: b,
16
+ function d({ items: d, max: f = 4, size: p = "md", labels: m, className: h, classNames: g, style: _, ...v }) {
17
+ let y = e("avatarGroup", l, m), { visible: b, overflow: x } = a(d, f), S = typeof p == "number" ? p : u[p], C = {
18
+ "--kapi-avatargroup-overlap": `${r(S)}px`,
19
+ ..._
20
+ }, w = d.slice(b.length).map((e) => e.name).filter(Boolean).join(", ");
21
+ return /* @__PURE__ */ c("div", {
22
+ ...v,
23
+ ...t(o, "root", g, h),
24
+ style: C,
22
25
  role: "group",
23
- ...h,
24
- children: [_.map((e, n) => /* @__PURE__ */ a(t, {
25
- className: "kapi-avatargroup__item",
26
+ children: [b.map((e, r) => /* @__PURE__ */ s(n, {
27
+ ...t(o, "item", g),
26
28
  title: e.name,
27
- size: d,
29
+ size: p,
28
30
  ...e
29
- }, `${e.name ?? e.initials ?? ""}-${n}`)), v > 0 && /* @__PURE__ */ a(t, {
30
- className: "kapi-avatargroup__item kapi-avatargroup__more",
31
+ }, `${e.name ?? e.initials ?? ""}-${r}`)), x > 0 && /* @__PURE__ */ s(n, {
32
+ ...t(o, "more", g, o.parts.item, "kapi-avatargroup__more", g?.item),
31
33
  tone: "neutral",
32
- size: d,
33
- initials: r(v),
34
- title: x || void 0,
35
- "aria-label": g.overflow.replace("{n}", String(v))
34
+ size: p,
35
+ initials: i(x),
36
+ title: w || void 0,
37
+ "aria-label": y.overflow.replace("{n}", String(x))
36
38
  })]
37
39
  });
38
40
  }
39
41
  //#endregion
40
- export { s as DEFAULT_AVATAR_GROUP_LABELS, l as KapiAvatarGroup };
42
+ export { l as DEFAULT_AVATAR_GROUP_LABELS, d as KapiAvatarGroup };
@@ -1,4 +1,5 @@
1
1
  import type { HTMLAttributes, ReactNode, Ref } from "react";
2
+ import type { KapiRender } from "../renderSlot.js";
2
3
  import { type KapiTimelineToneName } from "./timelineLogic.js";
3
4
  export type KapiTimelineItem = {
4
5
  /** Qué pasó. */
@@ -7,6 +8,19 @@ export type KapiTimelineItem = {
7
8
  date?: ReactNode;
8
9
  /** Color del punto: un tono de la línea de tiempo o una familia propia de la app. @default "primary" */
9
10
  tone?: KapiTimelineToneName | undefined;
11
+ /**
12
+ * Convierte el texto en un link al destino. La **fecha queda afuera** a propósito: es contexto,
13
+ * no destino, y adentro haría que el lector anuncie «texto fecha, enlace».
14
+ */
15
+ href?: string | undefined;
16
+ /** Abre el link en una pestaña nueva, con el aviso compartido del locale. Sólo con `href`. */
17
+ newTab?: boolean | undefined;
18
+ /** Dibuja otro elemento con el aspecto del link (el `<Link>` de tu router). Sólo con `href`. */
19
+ render?: KapiRender | undefined;
20
+ /** Ícono adentro del punto. Decorativo: el riel entero es `aria-hidden`, así que el significado va en el texto. */
21
+ icon?: ReactNode;
22
+ /** Reemplaza el punto entero por un nodo propio. Gana sobre `icon` y sobre `tone`. */
23
+ marker?: ReactNode;
10
24
  };
11
25
  /** Atributos nativos (`id`, `style`, `data-*`, `aria-*`…) van al `<ol>`. */
12
26
  export type KapiTimelineProps = Omit<HTMLAttributes<HTMLOListElement>, "children"> & {
@@ -2,38 +2,45 @@
2
2
  import "#kapi-css/components/display/display.css";
3
3
  import { useToneLookResolver as e } from "../../hooks/useToneFamilies.js";
4
4
  /* empty css */
5
- import { isTimelineTone as t, needsToneResolver as n, showConnector as r, timelineDotClass as i } from "./timelineLogic.js";
6
- import { jsx as a, jsxs as o } from "react/jsx-runtime";
5
+ import { KapiAnchor as t } from "./KapiAnchor.js";
6
+ import { isTimelineTone as n, needsToneResolver as r, showConnector as i, timelineDotClass as a } from "./timelineLogic.js";
7
+ import { jsx as o, jsxs as s } from "react/jsx-runtime";
7
8
  //#region src/components/display/KapiTimeline.tsx
8
- function s({ items: s, className: c, ...l }) {
9
- let u = e("KapiTimeline");
10
- return /* @__PURE__ */ a("ol", {
11
- ...l,
12
- className: ["kapi-timeline", c].filter(Boolean).join(" "),
13
- children: s.map((e, c) => {
14
- let l = n(e.tone) ? u(e.tone) : void 0;
15
- return /* @__PURE__ */ o("li", {
9
+ function c({ items: c, className: l, ...u }) {
10
+ let d = e("KapiTimeline");
11
+ return /* @__PURE__ */ o("ol", {
12
+ ...u,
13
+ className: ["kapi-timeline", l].filter(Boolean).join(" "),
14
+ children: c.map((e, l) => {
15
+ let u = r(e.tone) ? d(e.tone) : void 0;
16
+ return /* @__PURE__ */ s("li", {
16
17
  className: "kapi-timeline__item",
17
- children: [/* @__PURE__ */ o("div", {
18
+ children: [/* @__PURE__ */ s("div", {
18
19
  className: "kapi-timeline__rail",
19
20
  "aria-hidden": !0,
20
- children: [/* @__PURE__ */ a("span", {
21
- className: i(t(e.tone) ? e.tone : void 0, l?.style !== void 0),
22
- style: l?.style
23
- }), r(c, s.length) && /* @__PURE__ */ a("span", { className: "kapi-tl-line" })]
24
- }), /* @__PURE__ */ o("div", {
21
+ children: [e.marker ?? /* @__PURE__ */ o("span", {
22
+ className: a(n(e.tone) ? e.tone : void 0, u?.style !== void 0),
23
+ style: u?.style,
24
+ children: e.icon
25
+ }), i(l, c.length) && /* @__PURE__ */ o("span", { className: "kapi-tl-line" })]
26
+ }), /* @__PURE__ */ s("div", {
25
27
  className: "kapi-timeline__body",
26
- children: [/* @__PURE__ */ a("div", {
28
+ children: [/* @__PURE__ */ o("div", {
27
29
  className: "kapi-strong",
28
- children: e.text
29
- }), e.date != null && /* @__PURE__ */ a("div", {
30
+ children: e.href === void 0 ? e.text : /* @__PURE__ */ o(t, {
31
+ href: e.href,
32
+ ...e.newTab ? { newTab: !0 } : {},
33
+ ...e.render ? { render: e.render } : {},
34
+ children: e.text
35
+ })
36
+ }), e.date != null && /* @__PURE__ */ o("div", {
30
37
  className: "kapi-muted",
31
38
  children: e.date
32
39
  })]
33
40
  })]
34
- }, c);
41
+ }, l);
35
42
  })
36
43
  });
37
44
  }
38
45
  //#endregion
39
- export { s as KapiTimeline };
46
+ export { c as KapiTimeline };
@@ -0,0 +1,6 @@
1
+ /** Partes de `avatarGroup` (ver `slotCatalog.ts` para el contrato). Vive junto al componente para que su CSS lo siga. */
2
+ export declare const AVATAR_GROUP_SLOTS: import("../slotsLogic.js").SlotTable<"avatarGroup", {
3
+ readonly root: "kapi-avatargroup";
4
+ readonly item: "kapi-avatargroup__item";
5
+ readonly more: null;
6
+ }>;
@@ -0,0 +1,9 @@
1
+ import { defineSlots as e } from "../slotsLogic.js";
2
+ //#region src/components/display/avatarGroupSlots.ts
3
+ var t = e("avatarGroup", {
4
+ root: "kapi-avatargroup",
5
+ item: "kapi-avatargroup__item",
6
+ more: null
7
+ });
8
+ //#endregion
9
+ export { t as AVATAR_GROUP_SLOTS };
@@ -44,7 +44,7 @@ iconTileSizePx,
44
44
  iconTileRadiusPx } from "./iconTileLogic.js";
45
45
  export type { KapiIconTileSize, KapiIconTileTone } from "./iconTileLogic.js";
46
46
  export { DEFAULT_AVATAR_GROUP_LABELS, KapiAvatarGroup } from "./KapiAvatarGroup.js";
47
- export type { KapiAvatarGroupItem, KapiAvatarGroupLabels, KapiAvatarGroupProps } from "./KapiAvatarGroup.js";
47
+ export type { KapiAvatarGroupClassNames, KapiAvatarGroupItem, KapiAvatarGroupLabels, KapiAvatarGroupProps } from "./KapiAvatarGroup.js";
48
48
  export {
49
49
  /** @deprecated Interno; usa `KapiAvatarGroup` en su lugar. Se quita en 1.0. */
50
50
  splitAvatarGroup,
@@ -2,6 +2,9 @@ import type { HTMLAttributes, ReactNode, Ref } from "react";
2
2
  import type { KapiCloseReason } from "../closeReason.js";
3
3
  import { type KapiFamilyTone, type KapiTone } from "../tone.js";
4
4
  import type { KapiLabelsOverride } from "../labelsLogic.js";
5
+ import type { KapiClassNames } from "../slotCatalog.js";
6
+ /** Partes de `KapiAlert` que acepta `classNames` (`root`, `icon`, `body`, `title`, `message`, `close`). */
7
+ export type KapiAlertClassNames = KapiClassNames<"alert">;
5
8
  export type KapiAlertLabels = {
6
9
  /** Nombre accesible del botón de cierre (con `onClose`). */
7
10
  close: string;
@@ -15,6 +18,8 @@ export type KapiAlertVariant = KapiAlertTone;
15
18
  export type KapiAlertProps = Omit<HTMLAttributes<HTMLDivElement>, "title" | "role" | "children"> & {
16
19
  /** Ref al `<div>` raíz del aviso. */
17
20
  ref?: Ref<HTMLDivElement> | undefined;
21
+ /** Clases por parte (`root`, `icon`, `body`, `title`, `message`, `close`). Se suman a las propias. */
22
+ classNames?: KapiAlertClassNames | undefined;
18
23
  /**
19
24
  * Rol semántico: define color, ícono y si se anuncia como `alert` o `status`. Una familia propia
20
25
  * de la app (`toneFamilies`) pinta el color y usa el ícono y el anuncio de `info`.
@@ -53,4 +58,4 @@ export declare const alertRole: (tone: KapiAlertTone, override?: KapiAlertRole)
53
58
  * Banner inline (info / success / warning / danger) para formularios, modales y pantallas.
54
59
  * `danger` se anuncia como `role="alert"`; el resto como `role="status"` (ver `role`).
55
60
  */
56
- export declare const KapiAlert: ({ tone: toneProp, variant, title, children, action, icon, onClose, labels, className, role, style, ...rest }: KapiAlertProps) => import("react").JSX.Element;
61
+ export declare const KapiAlert: ({ tone: toneProp, variant, title, children, action, icon, onClose, labels, className, classNames, role, style, ...rest }: KapiAlertProps) => import("react").JSX.Element;
@@ -1,82 +1,83 @@
1
1
  "use client";
2
2
  import "#kapi-css/components/feedback/feedback.css";
3
3
  import { useToneLook as e } from "../../hooks/useToneFamilies.js";
4
- import { joinClasses as t } from "../rootProps.js";
5
- import { resolveTone as n } from "../tone.js";
6
- import { KapiButton as r } from "../inputs/KapiButton.js";
7
- import { useLabels as i } from "../locale/KapiLocaleProvider.js";
4
+ import { resolveTone as t } from "../tone.js";
5
+ import { KapiButton as n } from "../inputs/KapiButton.js";
6
+ import { useLabels as r } from "../locale/KapiLocaleProvider.js";
7
+ import { slot as i } from "../slotsLogic.js";
8
8
  /* empty css */
9
- import { jsx as a, jsxs as o } from "react/jsx-runtime";
10
- import { AlertTriangle as s, CheckCircle2 as c, Info as l, X as u, XCircle as d } from "lucide-react";
9
+ import { ALERT_SLOTS as a } from "./alertSlots.js";
10
+ import { jsx as o, jsxs as s } from "react/jsx-runtime";
11
+ import { AlertTriangle as c, CheckCircle2 as l, Info as u, X as d, XCircle as f } from "lucide-react";
11
12
  //#region src/components/feedback/KapiAlert.tsx
12
- var f = { close: "Cerrar aviso" }, p = (e, t) => {
13
+ var p = { close: "Cerrar aviso" }, m = (e, t) => {
13
14
  let n = t ?? (e === "danger" ? "alert" : "status");
14
15
  return n === "none" ? void 0 : n;
15
- }, m = {
16
+ }, h = {
16
17
  info: {
17
- Icon: l,
18
+ Icon: u,
18
19
  color: "var(--kapi-info)"
19
20
  },
20
21
  success: {
21
- Icon: c,
22
+ Icon: l,
22
23
  color: "var(--kapi-success)"
23
24
  },
24
25
  warning: {
25
- Icon: s,
26
+ Icon: c,
26
27
  color: "var(--kapi-warning)"
27
28
  },
28
29
  danger: {
29
- Icon: d,
30
+ Icon: f,
30
31
  color: "var(--kapi-danger)"
31
32
  }
32
- }, h = ({ tone: s, variant: c, title: l, children: d, action: h, icon: g, onClose: _, labels: v, className: y, role: b, style: x, ...S }) => {
33
- let C = i("alert", f, v), w = e("KapiAlert", s), T = n(w.tone, c, "info"), E = T in m ? T : "info", { Icon: D } = m[E], O = w.style ? "var(--kapi-tone)" : m[E].color;
34
- return /* @__PURE__ */ o("div", {
35
- ...S,
36
- style: w.style ? {
37
- ...w.style,
38
- ...x
39
- } : x,
40
- className: t("kapi-alert", w.style ? "kapi-alert--family" : `kapi-alert--${E}`, y),
41
- role: p(E, b),
33
+ }, g = ({ tone: c, variant: l, title: u, children: f, action: g, icon: _, onClose: v, labels: y, className: b, classNames: x, role: S, style: C, ...w }) => {
34
+ let T = r("alert", p, y), E = e("KapiAlert", c), D = t(E.tone, l, "info"), O = D in h ? D : "info", { Icon: k } = h[O], A = E.style ? "var(--kapi-tone)" : h[O].color;
35
+ return /* @__PURE__ */ s("div", {
36
+ ...w,
37
+ style: E.style ? {
38
+ ...E.style,
39
+ ...C
40
+ } : C,
41
+ ...i(a, "root", x, E.style ? "kapi-alert--family" : `kapi-alert--${O}`, b),
42
+ role: m(O, S),
42
43
  children: [
43
- g === void 0 ? /* @__PURE__ */ a(D, {
44
- className: "kapi-alert__ico",
44
+ _ === void 0 ? /* @__PURE__ */ o(k, {
45
+ ...i(a, "icon", x),
45
46
  size: 19,
46
47
  strokeWidth: 2,
47
- color: O
48
- }) : g === !1 || g === null ? null : /* @__PURE__ */ a("span", {
49
- className: "kapi-alert__ico kapi-alert__ico--custom",
50
- style: { color: O },
48
+ color: A
49
+ }) : _ === !1 || _ === null ? null : /* @__PURE__ */ o("span", {
50
+ ...i(a, "icon", x, "kapi-alert__ico--custom"),
51
+ style: { color: A },
51
52
  "aria-hidden": "true",
52
- children: g
53
+ children: _
53
54
  }),
54
- /* @__PURE__ */ o("div", {
55
- className: "kapi-alert__body",
56
- children: [l && /* @__PURE__ */ a("div", {
57
- className: "kapi-alert__title",
58
- children: l
59
- }), d && /* @__PURE__ */ a("div", {
60
- className: "kapi-alert__msg",
61
- children: d
55
+ /* @__PURE__ */ s("div", {
56
+ ...i(a, "body", x),
57
+ children: [u && /* @__PURE__ */ o("div", {
58
+ ...i(a, "title", x),
59
+ children: u
60
+ }), f && /* @__PURE__ */ o("div", {
61
+ ...i(a, "message", x),
62
+ children: f
62
63
  })]
63
64
  }),
64
- h,
65
- _ && /* @__PURE__ */ a(r, {
66
- className: "kapi-alert__close",
65
+ g,
66
+ v && /* @__PURE__ */ o(n, {
67
+ ...i(a, "close", x),
67
68
  variant: "ghost",
68
69
  size: "sm",
69
70
  iconOnly: !0,
70
- icon: /* @__PURE__ */ a(u, {
71
+ icon: /* @__PURE__ */ o(d, {
71
72
  size: 16,
72
73
  strokeWidth: 2.2,
73
74
  "aria-hidden": "true"
74
75
  }),
75
- "aria-label": C.close,
76
- onClick: () => _?.("close-button")
76
+ "aria-label": T.close,
77
+ onClick: () => v?.("close-button")
77
78
  })
78
79
  ]
79
80
  });
80
81
  };
81
82
  //#endregion
82
- export { f as DEFAULT_ALERT_LABELS, h as KapiAlert, p as alertRole };
83
+ export { p as DEFAULT_ALERT_LABELS, g as KapiAlert, m as alertRole };
@@ -2,10 +2,15 @@ import { type HTMLAttributes, type ReactNode, type Ref } from "react";
2
2
  import { type KapiBadgeAppearance, type KapiBadgeSize } from "../display/KapiBadge.js";
3
3
  import { type KapiCountdownLabels, type KapiCountdownTarget, type KapiCountdownToneMap } from "./countdownLogic.js";
4
4
  import type { KapiLabelsOverride } from "../labelsLogic.js";
5
+ import type { KapiClassNames } from "../slotCatalog.js";
6
+ /** Partes de `KapiCountdown` que acepta `classNames` (`root`, `prefix`, `time`). */
7
+ export type KapiCountdownClassNames = KapiClassNames<"countdown">;
5
8
  /** Native attributes (`id`, `style`, `data-*`…) go to the chip; `role="timer"` and its label (from `detail`) are owned. */
6
9
  export type KapiCountdownProps = Omit<HTMLAttributes<HTMLSpanElement>, "prefix" | "children" | "role" | "aria-label"> & {
7
10
  /** Ref al `<span>` raíz de la cuenta regresiva. */
8
11
  ref?: Ref<HTMLSpanElement> | undefined;
12
+ /** Clases por parte (`root`, `prefix`, `time`). Se suman a las propias. */
13
+ classNames?: KapiCountdownClassNames | undefined;
9
14
  /** Deadline: Date, ISO string or epoch milliseconds. */
10
15
  to: KapiCountdownTarget;
11
16
  /** Text before the clock while running (e.g. "Cierra en"). Hidden once overdue. */
@@ -16,6 +21,12 @@ export type KapiCountdownProps = Omit<HTMLAttributes<HTMLSpanElement>, "prefix"
16
21
  nearThresholdMs?: number | undefined;
17
22
  /** Tooltip text. Defaults to a sentence like "Faltan 2 horas". */
18
23
  detail?: string | undefined;
24
+ /**
25
+ * Fija el "ahora" en lugar de leer el reloj, y **apaga el tick**. Es la misma convención que el
26
+ * resto de lo que muestra tiempo relativo en el sistema: sin esto, un test y una captura miden
27
+ * algo distinto en cada corrida y la baseline se mueve sola.
28
+ */
29
+ now?: number | undefined;
19
30
  /** Override the Spanish copy (unit words keyed by `Intl.PluralRules` category). */
20
31
  labels?: KapiLabelsOverride<KapiCountdownLabels> | undefined;
21
32
  /** Tamaño del badge: `sm` · `md`. */
@@ -26,4 +37,4 @@ export type KapiCountdownProps = Omit<HTMLAttributes<HTMLSpanElement>, "prefix"
26
37
  badgeTone?: KapiBadgeAppearance | undefined;
27
38
  };
28
39
  /** Live countdown chip: ticks every second and changes color as the deadline approaches. */
29
- export declare function KapiCountdown({ to, prefix, tones, nearThresholdMs, detail, labels, size, badgeVariant, badgeTone, className, ...rest }: KapiCountdownProps): import("react").JSX.Element | null;
40
+ export declare function KapiCountdown({ to, prefix, tones, nearThresholdMs, detail, now: nowProp, labels, size, badgeVariant, badgeTone, className, classNames, ...rest }: KapiCountdownProps): import("react").JSX.Element | null;
@@ -1,44 +1,47 @@
1
1
  "use client";
2
2
  import "#kapi-css/components/feedback/feedback.css";
3
3
  import { useKapiLocale as e, useLabels as t } from "../locale/KapiLocaleProvider.js";
4
- import { KapiTooltip as n } from "../overlays/KapiTooltip.js";
5
- import { KapiBadge as r } from "../display/KapiBadge.js";
4
+ import { slot as n } from "../slotsLogic.js";
6
5
  /* empty css */
7
- import { DEFAULT_COUNTDOWN_LABELS as i, DEFAULT_NEAR_MS as a, bucketFor as o, chipText as s, describe as c, parseTarget as l, resolveTones as u } from "./countdownLogic.js";
8
- import { useEffect as d, useState as f } from "react";
9
- import { jsx as p, jsxs as m } from "react/jsx-runtime";
6
+ import { KapiTooltip as r } from "../overlays/KapiTooltip.js";
7
+ import { KapiBadge as i } from "../display/KapiBadge.js";
8
+ import { DEFAULT_COUNTDOWN_LABELS as a, DEFAULT_NEAR_MS as o, bucketFor as s, chipText as c, describe as l, parseTarget as u, resolveTones as d } from "./countdownLogic.js";
9
+ import { COUNTDOWN_SLOTS as f } from "./countdownSlots.js";
10
+ import { useEffect as p, useState as m } from "react";
11
+ import { jsx as h, jsxs as g } from "react/jsx-runtime";
10
12
  //#region src/components/feedback/KapiCountdown.tsx
11
- function h({ to: h, prefix: g, tones: _, nearThresholdMs: v = a, detail: y, labels: b, size: x = "md", badgeVariant: S, badgeTone: C, className: w, ...T }) {
12
- let [E, D] = f(() => Date.now()), O = t("countdown", i, b), k = e() ?? "es";
13
- d(() => {
14
- D(Date.now());
15
- let e = setInterval(() => D(Date.now()), 1e3);
13
+ function _({ to: _, prefix: v, tones: y, nearThresholdMs: b = o, detail: x, now: S, labels: C, size: w = "md", badgeVariant: T, badgeTone: E, className: D, classNames: O, ...k }) {
14
+ let [A, j] = m(() => Date.now()), M = S ?? A, N = t("countdown", a, C), P = e() ?? "es";
15
+ p(() => {
16
+ if (S !== void 0) return;
17
+ j(Date.now());
18
+ let e = setInterval(() => j(Date.now()), 1e3);
16
19
  return () => clearInterval(e);
17
- }, [h]);
18
- let A = l(h);
19
- if (!Number.isFinite(A)) return null;
20
- let j = A - E, M = o(j, v), N = u(_)[M], P = y ?? c(j, O, k), F = g && M !== "overdue";
21
- return /* @__PURE__ */ p(n, {
22
- label: P,
23
- children: /* @__PURE__ */ m(r, {
24
- ...T,
25
- tone: N,
26
- variant: S ?? C ?? "subtle",
27
- size: x,
28
- className: ["kapi-countdown", w].filter(Boolean).join(" "),
29
- "data-state": M,
20
+ }, [_, S]);
21
+ let F = u(_);
22
+ if (!Number.isFinite(F)) return null;
23
+ let I = F - M, L = s(I, b), R = d(y)[L], z = x ?? l(I, N, P), B = v && L !== "overdue";
24
+ return /* @__PURE__ */ h(r, {
25
+ label: z,
26
+ children: /* @__PURE__ */ g(i, {
27
+ ...k,
28
+ tone: R,
29
+ variant: T ?? E ?? "subtle",
30
+ size: w,
31
+ ...n(f, "root", O, D),
32
+ "data-state": L,
30
33
  role: "timer",
31
- "aria-label": P,
34
+ "aria-label": z,
32
35
  suppressHydrationWarning: !0,
33
- children: [F && /* @__PURE__ */ p("span", {
34
- className: "kapi-countdown__prefix",
35
- children: g
36
- }), /* @__PURE__ */ p("span", {
37
- className: "kapi-countdown__time",
38
- children: s(j, O)
36
+ children: [B && /* @__PURE__ */ h("span", {
37
+ ...n(f, "prefix", O),
38
+ children: v
39
+ }), /* @__PURE__ */ h("span", {
40
+ ...n(f, "time", O),
41
+ children: c(I, N)
39
42
  })]
40
43
  })
41
44
  });
42
45
  }
43
46
  //#endregion
44
- export { h as KapiCountdown };
47
+ export { _ as KapiCountdown };
@@ -1,4 +1,7 @@
1
1
  import type { HTMLAttributes, ReactNode, Ref } from "react";
2
+ import type { KapiClassNames } from "../slotCatalog.js";
3
+ /** Partes de `KapiEmpty` que acepta `classNames` (`root`, `icon`, `title`, `description`, `action`). */
4
+ export type KapiEmptyClassNames = KapiClassNames<"empty">;
2
5
  export type KapiEmptyProps = Omit<HTMLAttributes<HTMLDivElement>, "title"> & {
3
6
  /** Ref al `<div>` raíz del estado vacío. */
4
7
  ref?: Ref<HTMLDivElement> | undefined;
@@ -10,6 +13,8 @@ export type KapiEmptyProps = Omit<HTMLAttributes<HTMLDivElement>, "title"> & {
10
13
  description?: ReactNode;
11
14
  /** Acción principal (típicamente un `KapiButton`). */
12
15
  action?: ReactNode;
16
+ /** Clases por parte (`root`, `icon`, `title`, `description`, `action`). Se suman a las propias. */
17
+ classNames?: KapiEmptyClassNames | undefined;
13
18
  };
14
19
  /** Estado vacío: ícono, título, descripción y acción opcionales, centrados. */
15
- export declare function KapiEmpty({ icon, title, description, action, className, ...rest }: KapiEmptyProps): import("react").JSX.Element;
20
+ export declare function KapiEmpty({ icon, title, description, action, className, classNames, ...rest }: KapiEmptyProps): import("react").JSX.Element;