@kapiuara/ui 0.11.0 → 0.12.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.
@@ -1,6 +1,6 @@
1
1
  import { type HTMLAttributes, type ReactNode, type Ref } from "react";
2
2
  import type { KapiLabelsOverride } from "../labelsLogic";
3
- import { type KapiChartLabels, type KapiChartView } from "./chartFrame";
3
+ import { type KapiChartLabels, type KapiChartUnit, type KapiChartView } from "./chartFrame";
4
4
  import { type KapiBarSort, type KapiBarValueLabels } from "./barChartLogic";
5
5
  import "./KapiBarChart.css";
6
6
  /** Una serie del gráfico: un valor por categoría, en el mismo orden que `categories`. */
@@ -59,6 +59,15 @@ export type KapiBarChartProps = Omit<HTMLAttributes<HTMLDivElement>, "title" | "
59
59
  * porque una etiqueta al lado de cada marca deja de leerse. @default "auto"
60
60
  */
61
61
  values?: KapiBarValueLabels;
62
+ /**
63
+ * La unidad del valor: `(n) => `$ ${n}`` para una moneda, `(n) => `${n} %`` para un porcentaje.
64
+ *
65
+ * Se aplica en los CUATRO lugares donde el gráfico escribe un número —eje, etiqueta sobre la
66
+ * marca, tooltip y tabla— para que digan todos lo mismo. Recibe el texto ya formateado y no el
67
+ * número, porque el eje abrevia y la tabla no, y esa diferencia es del gráfico: ver
68
+ * `KapiChartUnit`. Sin esta prop el número sale pelado, que es lo correcto para una cantidad.
69
+ */
70
+ unit?: KapiChartUnit | undefined;
62
71
  /** Vista mostrada, si la controla el consumidor. */
63
72
  view?: KapiChartView;
64
73
  /** Vista inicial cuando el componente la maneja solo. @default "chart" */
@@ -81,4 +90,4 @@ export type KapiBarChartProps = Omit<HTMLAttributes<HTMLDivElement>, "title" | "
81
90
  * que es lo que un lector de pantalla recorre. El tooltip de cada barra es para quien ve el
82
91
  * gráfico y usa el mouse.
83
92
  */
84
- export declare function KapiBarChart({ categories, series, title, tickCount, horizontal, sort, stacked, values, view, defaultView, onViewChange, labels, className, ref, ...rest }: KapiBarChartProps): import("react").JSX.Element;
93
+ export declare function KapiBarChart({ categories, series, title, tickCount, horizontal, sort, stacked, values, unit, view, defaultView, onViewChange, labels, className, ref, ...rest }: KapiBarChartProps): import("react").JSX.Element;
@@ -1,78 +1,79 @@
1
1
  "use client";
2
2
  import { formatDataValue as e } from "../../hooks/numberFormatLogic.js";
3
3
  import { KapiTooltip as t } from "../overlays/KapiTooltip.js";
4
- import { KapiChartFrame as n, chartSummary as r, chartVars as i, useChartLabels as a, useChartTitleId as o, useChartView as s } from "./chartFrame.js";
5
- import { barCategoryOrder as c, barHeight as l, barScale as u, barStackTotals as d, barTickLabel as f, barValueLabelPredicate as p } from "./barChartLogic.js";
4
+ import { KapiChartFrame as n, chartSummary as r, chartVars as i, useChartLabels as a, useChartTitleId as o, useChartView as s, withChartUnit as c } from "./chartFrame.js";
5
+ import { barCategoryOrder as l, barHeight as u, barScale as d, barStackTotals as f, barTickLabel as p, barValueLabelPredicate as m } from "./barChartLogic.js";
6
6
  /* empty css */
7
- import { jsx as m, jsxs as h } from "react/jsx-runtime";
7
+ import { jsx as h, jsxs as g } from "react/jsx-runtime";
8
8
  import "react";
9
9
  //#region src/components/data/KapiBarChart.tsx
10
- var g = (e, t) => e.values[t] ?? 0;
11
- function _({ categories: _, series: v, title: y, tickCount: b = 4, horizontal: x = !1, sort: S = "none", stacked: C = !1, values: w, view: T, defaultView: E = "chart", onViewChange: D, labels: O, className: k, ref: A, ...j }) {
12
- let M = a(O), N = o(), { current: P, setView: F } = s(T, E, D), I = v.slice(0, 8);
13
- v.length > 8 && process.env.NODE_ENV !== "production" && console.warn(`KapiBarChart: ${v.length} series y la paleta tiene 8 slots. Se dibujan las primeras 8; agrupá el resto en vez de perderlo.`);
14
- let L = I.map((e) => _.map((t, n) => g(e, n))), R = c(L, _.length, S), z = I.flatMap((e) => _.map((t, n) => g(e, n))), B = C ? d(L, _.length) : z, { max: V, ticks: H } = u(B, b), U = p(z, w ?? (C ? "none" : "auto")), W = r(C ? M.kindStackedBars : M.kindBars, M, I.length, _.length);
15
- return /* @__PURE__ */ m("div", {
16
- ...j,
17
- ref: A,
10
+ var _ = (e, t) => e.values[t] ?? 0;
11
+ function v({ categories: v, series: y, title: b, tickCount: x = 4, horizontal: S = !1, sort: C = "none", stacked: w = !1, values: T, unit: E, view: D, defaultView: O = "chart", onViewChange: k, labels: A, className: j, ref: M, ...N }) {
12
+ let P = a(A), F = o(), { current: I, setView: L } = s(D, O, k), R = y.slice(0, 8);
13
+ y.length > 8 && process.env.NODE_ENV !== "production" && console.warn(`KapiBarChart: ${y.length} series y la paleta tiene 8 slots. Se dibujan las primeras 8; agrupá el resto en vez de perderlo.`);
14
+ let z = R.map((e) => v.map((t, n) => _(e, n))), B = l(z, v.length, C), V = R.flatMap((e) => v.map((t, n) => _(e, n))), H = w ? f(z, v.length) : V, { max: U, ticks: W } = d(H, x), G = m(V, T ?? (w ? "none" : "auto")), K = r(w ? P.kindStackedBars : P.kindBars, P, R.length, v.length);
15
+ return /* @__PURE__ */ h("div", {
16
+ ...N,
17
+ ref: M,
18
18
  className: [
19
19
  "kapi-barchart",
20
- x && "kapi-barchart--horizontal",
21
- k
20
+ S && "kapi-barchart--horizontal",
21
+ j
22
22
  ].filter(Boolean).join(" "),
23
23
  role: "group",
24
- ...y ? { "aria-labelledby": N } : {},
25
- children: /* @__PURE__ */ m(n, {
26
- title: y,
27
- titleId: N,
28
- series: I,
29
- categories: _,
30
- valueAt: (e, t) => g(I[e], t),
31
- view: P,
32
- onViewChange: F,
33
- text: M,
24
+ ...b ? { "aria-labelledby": F } : {},
25
+ children: /* @__PURE__ */ h(n, {
26
+ title: b,
27
+ titleId: F,
28
+ series: R,
29
+ categories: v,
30
+ valueAt: (e, t) => _(R[e], t),
31
+ unit: E,
32
+ view: I,
33
+ onViewChange: L,
34
+ text: P,
34
35
  block: "kapi-barchart",
35
- children: /* @__PURE__ */ h("div", {
36
+ children: /* @__PURE__ */ g("div", {
36
37
  className: "kapi-barchart__plot",
37
38
  role: "img",
38
- "aria-label": W,
39
- children: [/* @__PURE__ */ m("div", {
39
+ "aria-label": K,
40
+ children: [/* @__PURE__ */ h("div", {
40
41
  className: "kapi-barchart__axis",
41
- children: H.map((e) => /* @__PURE__ */ m("div", {
42
+ children: W.map((e) => /* @__PURE__ */ h("div", {
42
43
  className: "kapi-barchart__tick",
43
- style: i({ y: l(e, V) }),
44
- children: /* @__PURE__ */ m("span", {
44
+ style: i({ y: u(e, U) }),
45
+ children: /* @__PURE__ */ h("span", {
45
46
  className: "kapi-barchart__ticklabel",
46
- children: f(e)
47
+ children: c(p(e), E)
47
48
  })
48
49
  }, e))
49
- }), /* @__PURE__ */ m("div", {
50
+ }), /* @__PURE__ */ h("div", {
50
51
  className: "kapi-barchart__groups",
51
- children: R.map((n) => {
52
- let r = _[n];
53
- return /* @__PURE__ */ h("div", {
52
+ children: B.map((n) => {
53
+ let r = v[n];
54
+ return /* @__PURE__ */ g("div", {
54
55
  className: "kapi-barchart__group",
55
- children: [/* @__PURE__ */ m("div", {
56
- className: `kapi-barchart__bars${C ? " kapi-barchart__bars--stacked" : ""}`,
57
- children: I.map((a, o) => {
58
- let s = g(a, n);
59
- return /* @__PURE__ */ m(t, {
60
- label: `${a.label} · ${r}: ${e(s)}`,
56
+ children: [/* @__PURE__ */ h("div", {
57
+ className: `kapi-barchart__bars${w ? " kapi-barchart__bars--stacked" : ""}`,
58
+ children: R.map((a, o) => {
59
+ let s = _(a, n);
60
+ return /* @__PURE__ */ h(t, {
61
+ label: `${a.label} · ${r}: ${c(e(s), E)}`,
61
62
  className: "kapi-barchart__slot",
62
63
  style: i({
63
64
  slot: o,
64
- y: l(s, V)
65
+ y: u(s, U)
65
66
  }),
66
- children: /* @__PURE__ */ m("div", {
67
+ children: /* @__PURE__ */ h("div", {
67
68
  className: "kapi-barchart__bar",
68
- children: U(o * _.length + n) ? /* @__PURE__ */ m("span", {
69
+ children: G(o * v.length + n) ? /* @__PURE__ */ h("span", {
69
70
  className: "kapi-barchart__value",
70
- children: f(s)
71
+ children: c(p(s), E)
71
72
  }) : null
72
73
  })
73
74
  }, a.id);
74
75
  })
75
- }), /* @__PURE__ */ m("div", {
76
+ }), /* @__PURE__ */ h("div", {
76
77
  className: "kapi-barchart__cat",
77
78
  children: r
78
79
  })]
@@ -84,4 +85,4 @@ function _({ categories: _, series: v, title: y, tickCount: b = 4, horizontal: x
84
85
  });
85
86
  }
86
87
  //#endregion
87
- export { _ as KapiBarChart };
88
+ export { v as KapiBarChart };
@@ -1,6 +1,6 @@
1
1
  import { type HTMLAttributes, type ReactNode, type Ref } from "react";
2
2
  import type { KapiLabelsOverride } from "../labelsLogic";
3
- import { type KapiChartLabels, type KapiChartView } from "./chartFrame";
3
+ import { type KapiChartLabels, type KapiChartUnit, type KapiChartView } from "./chartFrame";
4
4
  import "./KapiLineChart.css";
5
5
  /** Una serie de la línea: un valor por categoría, en el mismo orden que `categories`. */
6
6
  export type KapiLineChartSeries = {
@@ -26,6 +26,15 @@ export type KapiLineChartProps = Omit<HTMLAttributes<HTMLDivElement>, "title" |
26
26
  * @default false
27
27
  */
28
28
  area?: boolean;
29
+ /**
30
+ * La unidad del valor: `(n) => `$ ${n}`` para una moneda, `(n) => `${n} %`` para un porcentaje.
31
+ *
32
+ * Se aplica en los CUATRO lugares donde el gráfico escribe un número —eje, etiqueta sobre la
33
+ * marca, tooltip y tabla— para que digan todos lo mismo. Recibe el texto ya formateado y no el
34
+ * número, porque el eje abrevia y la tabla no, y esa diferencia es del gráfico: ver
35
+ * `KapiChartUnit`. Sin esta prop el número sale pelado, que es lo correcto para una cantidad.
36
+ */
37
+ unit?: KapiChartUnit | undefined;
29
38
  /** Vista mostrada, si la controla el consumidor. */
30
39
  view?: KapiChartView;
31
40
  /** Vista inicial cuando el componente la maneja solo. @default "chart" */
@@ -47,4 +56,4 @@ export type KapiLineChartProps = Omit<HTMLAttributes<HTMLDivElement>, "title" |
47
56
  *
48
57
  * Igual que las barras: la vista de tabla no es opcional, y el plot es `role="img"`.
49
58
  */
50
- export declare function KapiLineChart({ categories, series, title, tickCount, area, view, defaultView, onViewChange, labels, className, ref, ...rest }: KapiLineChartProps): import("react").JSX.Element;
59
+ export declare function KapiLineChart({ categories, series, title, tickCount, area, unit, view, defaultView, onViewChange, labels, className, ref, ...rest }: KapiLineChartProps): import("react").JSX.Element;
@@ -1,87 +1,88 @@
1
1
  "use client";
2
2
  import { formatDataValue as e } from "../../hooks/numberFormatLogic.js";
3
3
  import { KapiTooltip as t } from "../overlays/KapiTooltip.js";
4
- import { KapiChartFrame as n, chartSummary as r, chartVars as i, useChartLabels as a, useChartTitleId as o, useChartView as s } from "./chartFrame.js";
5
- import { barHeight as c, barScale as l, barTickLabel as u } from "./barChartLogic.js";
6
- import { areaPath as d, lineEndpoint as f, linePath as p, linePoints as m } from "./lineChartLogic.js";
4
+ import { KapiChartFrame as n, chartSummary as r, chartVars as i, useChartLabels as a, useChartTitleId as o, useChartView as s, withChartUnit as c } from "./chartFrame.js";
5
+ import { barHeight as l, barScale as u, barTickLabel as d } from "./barChartLogic.js";
6
+ import { areaPath as f, lineEndpoint as p, linePath as m, linePoints as h } from "./lineChartLogic.js";
7
7
  /* empty css */
8
- import { jsx as h, jsxs as g } from "react/jsx-runtime";
8
+ import { jsx as g, jsxs as _ } from "react/jsx-runtime";
9
9
  import "react";
10
10
  //#region src/components/data/KapiLineChart.tsx
11
- var _ = 4;
12
- function v({ categories: v, series: y, title: b, tickCount: x = 4, area: S = !1, view: C, defaultView: w = "chart", onViewChange: T, labels: E, className: D, ref: O, ...k }) {
13
- let A = a(E), j = o(), { current: M, setView: N } = s(C, w, T), P = y.slice(0, 8);
14
- y.length > 8 && process.env.NODE_ENV !== "production" && console.warn(`KapiLineChart: ${y.length} series y la paleta tiene 8 slots. Se dibujan las primeras 8; agrupá el resto en vez de perderlo.`);
15
- let F = (e, t) => P[e]?.values[t] ?? 0, I = P.flatMap((e) => v.map((t, n) => e.values[n] ?? 0)), { max: L, ticks: R } = l(I, x), z = P.map((e) => m(e.values, L, v.length)), B = S && P.length === 1, V = P.length > 1 && P.length <= _, H = r(A.kindLine, A, P.length, v.length);
16
- return /* @__PURE__ */ h("div", {
17
- ...k,
18
- ref: O,
11
+ var v = 4;
12
+ function y({ categories: y, series: b, title: x, tickCount: S = 4, area: C = !1, unit: w, view: T, defaultView: E = "chart", onViewChange: D, labels: O, className: k, ref: A, ...j }) {
13
+ let M = a(O), N = o(), { current: P, setView: F } = s(T, E, D), I = b.slice(0, 8);
14
+ b.length > 8 && process.env.NODE_ENV !== "production" && console.warn(`KapiLineChart: ${b.length} series y la paleta tiene 8 slots. Se dibujan las primeras 8; agrupá el resto en vez de perderlo.`);
15
+ let L = (e, t) => I[e]?.values[t] ?? 0, R = I.flatMap((e) => y.map((t, n) => e.values[n] ?? 0)), { max: z, ticks: B } = u(R, S), V = I.map((e) => h(e.values, z, y.length)), H = C && I.length === 1, U = I.length > 1 && I.length <= v, W = r(M.kindLine, M, I.length, y.length);
16
+ return /* @__PURE__ */ g("div", {
17
+ ...j,
18
+ ref: A,
19
19
  className: [
20
20
  "kapi-linechart",
21
- V && "kapi-linechart--endlabels",
22
- D
21
+ U && "kapi-linechart--endlabels",
22
+ k
23
23
  ].filter(Boolean).join(" "),
24
24
  role: "group",
25
- ...b ? { "aria-labelledby": j } : {},
26
- children: /* @__PURE__ */ h(n, {
27
- title: b,
28
- titleId: j,
29
- series: P,
30
- categories: v,
31
- valueAt: F,
32
- view: M,
33
- onViewChange: N,
34
- text: A,
25
+ ...x ? { "aria-labelledby": N } : {},
26
+ children: /* @__PURE__ */ g(n, {
27
+ title: x,
28
+ titleId: N,
29
+ series: I,
30
+ categories: y,
31
+ valueAt: L,
32
+ unit: w,
33
+ view: P,
34
+ onViewChange: F,
35
+ text: M,
35
36
  block: "kapi-linechart",
36
- children: /* @__PURE__ */ g("div", {
37
+ children: /* @__PURE__ */ _("div", {
37
38
  className: "kapi-linechart__plot",
38
39
  role: "img",
39
- "aria-label": H,
40
+ "aria-label": W,
40
41
  children: [
41
- /* @__PURE__ */ h("div", {
42
+ /* @__PURE__ */ g("div", {
42
43
  className: "kapi-linechart__axis",
43
- children: R.map((e) => /* @__PURE__ */ h("div", {
44
+ children: B.map((e) => /* @__PURE__ */ g("div", {
44
45
  className: "kapi-linechart__tick",
45
- style: i({ y: c(e, L) }),
46
- children: /* @__PURE__ */ h("span", {
46
+ style: i({ y: l(e, z) }),
47
+ children: /* @__PURE__ */ g("span", {
47
48
  className: "kapi-linechart__ticklabel",
48
- children: u(e)
49
+ children: c(d(e), w)
49
50
  })
50
51
  }, e))
51
52
  }),
52
- /* @__PURE__ */ g("div", {
53
+ /* @__PURE__ */ _("div", {
53
54
  className: "kapi-linechart__canvas",
54
55
  children: [
55
- /* @__PURE__ */ g("svg", {
56
+ /* @__PURE__ */ _("svg", {
56
57
  className: "kapi-linechart__svg",
57
58
  viewBox: "0 0 100 100",
58
59
  preserveAspectRatio: "none",
59
60
  "aria-hidden": "true",
60
61
  focusable: "false",
61
- children: [P.map((e, t) => B ? /* @__PURE__ */ h("path", {
62
+ children: [I.map((e, t) => H ? /* @__PURE__ */ g("path", {
62
63
  className: "kapi-linechart__area",
63
- d: d(z[t]),
64
+ d: f(V[t]),
64
65
  style: i({ slot: t })
65
- }, `${e.id}-area`) : null), P.map((e, t) => /* @__PURE__ */ h("path", {
66
+ }, `${e.id}-area`) : null), I.map((e, t) => /* @__PURE__ */ g("path", {
66
67
  className: "kapi-linechart__line",
67
- d: p(z[t]),
68
+ d: m(V[t]),
68
69
  style: i({ slot: t }),
69
70
  vectorEffect: "non-scaling-stroke"
70
71
  }, e.id))]
71
72
  }),
72
- P.map((n, r) => z[r].map((a, o) => /* @__PURE__ */ h(t, {
73
- label: `${n.label} · ${v[o] ?? ""}: ${e(a.value)}`,
73
+ I.map((n, r) => V[r].map((a, o) => /* @__PURE__ */ g(t, {
74
+ label: `${n.label} · ${y[o] ?? ""}: ${c(e(a.value), w)}`,
74
75
  className: "kapi-linechart__dotwrap",
75
76
  style: i({
76
77
  slot: r,
77
78
  x: a.x,
78
79
  y: a.y
79
80
  }),
80
- children: /* @__PURE__ */ h("span", { className: "kapi-linechart__dot" })
81
+ children: /* @__PURE__ */ g("span", { className: "kapi-linechart__dot" })
81
82
  }, `${n.id}-${o}`))),
82
- V ? P.map((e, t) => {
83
- let n = f(z[t]);
84
- return n ? /* @__PURE__ */ h("span", {
83
+ U ? I.map((e, t) => {
84
+ let n = p(V[t]);
85
+ return n ? /* @__PURE__ */ g("span", {
85
86
  className: "kapi-linechart__endlabel",
86
87
  style: i({ y: n.y }),
87
88
  children: e.label
@@ -89,9 +90,9 @@ function v({ categories: v, series: y, title: b, tickCount: x = 4, area: S = !1,
89
90
  }) : null
90
91
  ]
91
92
  }),
92
- /* @__PURE__ */ h("div", {
93
+ /* @__PURE__ */ g("div", {
93
94
  className: "kapi-linechart__cats",
94
- children: v.map((e, t) => /* @__PURE__ */ h("span", {
95
+ children: y.map((e, t) => /* @__PURE__ */ g("span", {
95
96
  className: "kapi-linechart__cat",
96
97
  children: e
97
98
  }, `${e}-${t}`))
@@ -102,4 +103,4 @@ function v({ categories: v, series: y, title: b, tickCount: x = 4, area: S = !1,
102
103
  });
103
104
  }
104
105
  //#endregion
105
- export { v as KapiLineChart };
106
+ export { y as KapiLineChart };
@@ -187,7 +187,30 @@ export type KapiTablePagination = {
187
187
  showEdges?: boolean | undefined;
188
188
  };
189
189
  /** `className`/`style`/`id` (`KapiRootProps`) van a la carcasa `.kapi-table-shell` (herramientas + tabla + pie). */
190
- export type KapiTableProps<T, K extends keyof T = keyof T> = KapiRootProps & {
190
+ /**
191
+ * Lo que puede ser el valor de una fila que la identifica. Es `string | number` y no `unknown` a
192
+ * propósito: un id viaja a la URL, entra en un `Set` y se compara por identidad, y una fecha o un
193
+ * objeto fallan las tres cosas en silencio.
194
+ */
195
+ export type KapiTableKey = string | number;
196
+ /**
197
+ * Las claves de `T` que SIRVEN como identificador: las que valen `string | number`.
198
+ *
199
+ * Es el default de `K`, y ése es el punto. `KapiTable` infiere `K` de `keyField`… pero sólo si el
200
+ * consumidor no escribe ningún argumento de tipo: TypeScript no infiere «el resto», así que al
201
+ * escribir uno —que es lo natural, porque `columns` ya pide el tipo de la fila— los demás caen a
202
+ * su default. Con el default viejo, `keyof T`, `selectedIds` pasaba a ser la unión de TODOS los
203
+ * campos de la fila: con una fila que tiene un `Date`, los ids quedaban `string | number | Date` y
204
+ * un estado `number[]` dejaba de tipar sin que se entendiera por qué.
205
+ *
206
+ * Acotando el default a las claves identificables, el peor caso es `string | number` —que es lo
207
+ * que un id puede ser— en vez de la fila entera. De paso, `keyField` deja de aceptar una columna
208
+ * que nunca pudo ser clave.
209
+ */
210
+ export type KapiTableKeyField<T> = {
211
+ [P in keyof T]-?: T[P] extends KapiTableKey ? P : never;
212
+ }[keyof T];
213
+ export type KapiTableProps<T, K extends KapiTableKeyField<T> = KapiTableKeyField<T>> = KapiRootProps & {
191
214
  /** Definición de columnas (clave, encabezado, render, orden, filtro, ancho…). */
192
215
  columns: ReadonlyArray<KapiTableColumn<T>>;
193
216
  /** Filas a mostrar. */
@@ -339,4 +362,4 @@ export type KapiTableProps<T, K extends keyof T = keyof T> = KapiRootProps & {
339
362
  * por header, columna de acciones fija, copiar por celda, virtualización de altura fija,
340
363
  * drag-scroll con click derecho y menú contextual con doble click derecho.
341
364
  */
342
- export declare function KapiTable<T, K extends keyof T = keyof T>({ columns, rows, keyField, maxHeight, fill, bulkActionsPlacement, className, style, id, labels, actions, rowMenu, contextMenu, onCopy, selectable, rowSelect, rowLabel, selectedIds, onSelectedIdsChange, bulkActions, rangeSelect, selectionPresets, virtual, rowHeight, sort, defaultSort, onSortChange, manualSort, pagination, dataset, loading, loadingRows, card, emptyMessage, loadingMessage, isRowSelectable, renderSubComponent, expandedIds, onExpandedIdsChange, density, rowHover, columnToggle, columnVisibility, defaultColumnVisibility, onColumnVisibilityChange, resizableColumns, columnWidths, defaultColumnWidths, onColumnWidthsChange, filterable, filter, defaultFilter, onFilterChange, manualFilter, filterDebounce, exportCsv, toolbar, mobileCards }: KapiTableProps<T, K>): import("react").JSX.Element;
365
+ export declare function KapiTable<T, K extends KapiTableKeyField<T> = KapiTableKeyField<T>>({ columns, rows, keyField, maxHeight, fill, bulkActionsPlacement, className, style, id, labels, actions, rowMenu, contextMenu, onCopy, selectable, rowSelect, rowLabel, selectedIds, onSelectedIdsChange, bulkActions, rangeSelect, selectionPresets, virtual, rowHeight, sort, defaultSort, onSortChange, manualSort, pagination, dataset, loading, loadingRows, card, emptyMessage, loadingMessage, isRowSelectable, renderSubComponent, expandedIds, onExpandedIdsChange, density, rowHover, columnToggle, columnVisibility, defaultColumnVisibility, onColumnVisibilityChange, resizableColumns, columnWidths, defaultColumnWidths, onColumnWidthsChange, filterable, filter, defaultFilter, onFilterChange, manualFilter, filterDebounce, exportCsv, toolbar, mobileCards }: KapiTableProps<T, K>): import("react").JSX.Element;
@@ -26,6 +26,20 @@ export declare const DEFAULT_CHART_LABELS: KapiChartLabels;
26
26
  * sistema de locales, y quien traduzca con `KapiLocaleProvider` se queda con una frase a medias.
27
27
  */
28
28
  export declare const chartSummary: (kind: string, text: KapiChartLabels, series: number, categories: number) => string;
29
+ /**
30
+ * Cómo se nombra la unidad de un valor: `(n) => `$ ${n}`` o `(n) => `${n} %``.
31
+ *
32
+ * RECIBE TEXTO, NO EL NÚMERO, y ésa es la decisión. El gráfico formatea distinto según dónde
33
+ * escribe: el eje abrevia (`740,1 k`) porque una etiqueta compite por lugar, y la tabla no
34
+ * (`740.100,5`) porque es donde el número se lee exacto. La unidad, en cambio, es la misma en los
35
+ * dos. Si esta función recibiera el número, el consumidor tendría que decidir el formato y
36
+ * replicar esa diferencia —o perderla—, y un eje con el importe completo deja de leerse.
37
+ *
38
+ * Así cada uno hace lo suyo: el gráfico sabe de números, el consumidor sabe de qué son.
39
+ */
40
+ export type KapiChartUnit = (formatted: string) => string;
41
+ /** El valor con su unidad, si el consumidor dio una; sin ella el texto queda igual. */
42
+ export declare const withChartUnit: (formatted: string, unit?: KapiChartUnit) => string;
29
43
  /** Cuál de las dos vistas se está mostrando. */
30
44
  export type KapiChartView = "chart" | "table";
31
45
  /**
@@ -51,6 +65,8 @@ export type KapiChartFrameProps = {
51
65
  categories: readonly string[];
52
66
  /** El valor de una celda, por índice de serie y de categoría. */
53
67
  valueAt: (seriesIndex: number, categoryIndex: number) => number;
68
+ /** La unidad del valor, aplicada a las celdas de la tabla. Ver `KapiChartUnit`. */
69
+ unit?: KapiChartUnit | undefined;
54
70
  /** Vista mostrada. */
55
71
  view: KapiChartView;
56
72
  /** Cambiar de vista. */
@@ -91,6 +107,6 @@ export declare const ChartSwatch: ({ block, slot }: {
91
107
  block: KapiChartBlock;
92
108
  slot: number;
93
109
  }) => import("react").JSX.Element;
94
- export declare const KapiChartFrame: ({ title, titleId, series, categories, valueAt, view, onViewChange, text, block, children }: KapiChartFrameProps) => import("react").JSX.Element;
110
+ export declare const KapiChartFrame: ({ title, titleId, series, categories, valueAt, unit, view, onViewChange, text, block, children }: KapiChartFrameProps) => import("react").JSX.Element;
95
111
  /** El `useId` de la cáscara, para que el gráfico ate su título sin repetir el hook. */
96
112
  export declare const useChartTitleId: () => string;
@@ -15,7 +15,7 @@ var c = {
15
15
  kindBars: "Gráfico de barras",
16
16
  kindStackedBars: "Gráfico de barras apiladas",
17
17
  kindLine: "Gráfico de líneas"
18
- }, l = (e, t, n, r) => `${e}. ${t.summary.replace("{series}", String(n)).replace("{categories}", String(r))}`, u = (t) => e("chart", c, t), d = (e, t, n) => {
18
+ }, l = (e, t, n, r) => `${e}. ${t.summary.replace("{series}", String(n)).replace("{categories}", String(r))}`, u = (e, t) => t ? t(e) : e, d = (t) => e("chart", c, t), f = (e, t, n) => {
19
19
  let [r, i] = s(t);
20
20
  return {
21
21
  current: e ?? r,
@@ -23,67 +23,67 @@ var c = {
23
23
  e === void 0 && i(t), n?.(t);
24
24
  }
25
25
  };
26
- }, f = ({ slot: e, x: t, y: n }) => ({
26
+ }, p = ({ slot: e, x: t, y: n }) => ({
27
27
  ...e === void 0 ? {} : { "--kapi-chart-slot": `var(--kapi-series-${e + 1})` },
28
28
  ...t === void 0 ? {} : { "--kapi-chart-x": `${t}%` },
29
29
  ...n === void 0 ? {} : { "--kapi-chart-y": `${n}%` }
30
- }), p = ({ block: e, slot: t }) => /* @__PURE__ */ i("span", {
30
+ }), m = ({ block: e, slot: t }) => /* @__PURE__ */ i("span", {
31
31
  className: `${e}__swatch`,
32
- style: f({ slot: t })
33
- }), m = ({ title: e, titleId: o, series: s, categories: c, valueAt: l, view: u, onViewChange: d, text: f, block: m, children: h }) => {
34
- let g = s.length === 0 || c.length === 0;
32
+ style: p({ slot: t })
33
+ }), h = ({ title: e, titleId: o, series: s, categories: c, valueAt: l, unit: d, view: f, onViewChange: p, text: h, block: g, children: _ }) => {
34
+ let v = s.length === 0 || c.length === 0;
35
35
  return /* @__PURE__ */ a(r, { children: [/* @__PURE__ */ a("div", {
36
- className: `${m}__head`,
36
+ className: `${g}__head`,
37
37
  children: [e ? /* @__PURE__ */ i("div", {
38
- className: `${m}__title`,
38
+ className: `${g}__title`,
39
39
  id: o,
40
40
  children: e
41
41
  }) : null, /* @__PURE__ */ i(n, {
42
- "aria-label": f.view,
42
+ "aria-label": h.view,
43
43
  items: [{
44
44
  id: "chart",
45
- label: f.chartView
45
+ label: h.chartView
46
46
  }, {
47
47
  id: "table",
48
- label: f.tableView
48
+ label: h.tableView
49
49
  }],
50
- value: u,
51
- onChange: d
50
+ value: f,
51
+ onChange: p
52
52
  })]
53
- }), g ? /* @__PURE__ */ i("p", {
54
- className: `${m}__empty kapi-muted`,
55
- children: f.empty
56
- }) : u === "table" ? /* @__PURE__ */ i("div", {
57
- className: `${m}__tablewrap`,
53
+ }), v ? /* @__PURE__ */ i("p", {
54
+ className: `${g}__empty kapi-muted`,
55
+ children: h.empty
56
+ }) : f === "table" ? /* @__PURE__ */ i("div", {
57
+ className: `${g}__tablewrap`,
58
58
  children: /* @__PURE__ */ a("table", {
59
- className: `${m}__table`,
59
+ className: `${g}__table`,
60
60
  children: [/* @__PURE__ */ i("thead", { children: /* @__PURE__ */ a("tr", { children: [/* @__PURE__ */ i("th", {
61
61
  scope: "col",
62
- children: f.series
62
+ children: h.series
63
63
  }), c.map((e, t) => /* @__PURE__ */ i("th", {
64
64
  scope: "col",
65
65
  children: e
66
66
  }, `${e}-${t}`))] }) }), /* @__PURE__ */ i("tbody", { children: s.map((e, n) => /* @__PURE__ */ a("tr", { children: [/* @__PURE__ */ i("th", {
67
67
  scope: "row",
68
68
  children: /* @__PURE__ */ a("span", {
69
- className: `${m}__serie`,
70
- children: [/* @__PURE__ */ i(p, {
71
- block: m,
69
+ className: `${g}__serie`,
70
+ children: [/* @__PURE__ */ i(m, {
71
+ block: g,
72
72
  slot: n
73
73
  }), e.label]
74
74
  })
75
- }), c.map((e, r) => /* @__PURE__ */ i("td", { children: t(l(n, r)) }, `${e}-${r}`))] }, e.id)) })]
75
+ }), c.map((e, r) => /* @__PURE__ */ i("td", { children: u(t(l(n, r)), d) }, `${e}-${r}`))] }, e.id)) })]
76
76
  })
77
77
  }) : /* @__PURE__ */ a(r, { children: [s.length > 1 ? /* @__PURE__ */ i("ul", {
78
- className: `${m}__legend`,
78
+ className: `${g}__legend`,
79
79
  children: s.map((e, t) => /* @__PURE__ */ a("li", {
80
- className: `${m}__legenditem`,
81
- children: [/* @__PURE__ */ i(p, {
82
- block: m,
80
+ className: `${g}__legenditem`,
81
+ children: [/* @__PURE__ */ i(m, {
82
+ block: g,
83
83
  slot: t
84
84
  }), e.label]
85
85
  }, e.id))
86
- }) : null, h] })] });
87
- }, h = () => o();
86
+ }) : null, _] })] });
87
+ }, g = () => o();
88
88
  //#endregion
89
- export { p as ChartSwatch, c as DEFAULT_CHART_LABELS, m as KapiChartFrame, l as chartSummary, f as chartVars, u as useChartLabels, h as useChartTitleId, d as useChartView };
89
+ export { m as ChartSwatch, c as DEFAULT_CHART_LABELS, h as KapiChartFrame, l as chartSummary, p as chartVars, d as useChartLabels, g as useChartTitleId, f as useChartView, u as withChartUnit };
@@ -14,11 +14,11 @@ export type { KapiLinePoint } from "./lineChartLogic";
14
14
  export { KapiBarChart } from "./KapiBarChart";
15
15
  export type { KapiBarChartProps, KapiBarChartSeries } from "./KapiBarChart";
16
16
  export { DEFAULT_CHART_LABELS } from "./chartFrame";
17
- export type { KapiChartLabels, KapiChartView } from "./chartFrame";
17
+ export type { KapiChartLabels, KapiChartUnit, KapiChartView } from "./chartFrame";
18
18
  export { barScale, barHeight, barTickLabel, barValueLabelPredicate, barCategoryOrder, barStackTotals, DIRECT_LABEL_MAX_BARS } from "./barChartLogic";
19
19
  export type { KapiBarScale, KapiBarSort, KapiBarValueLabels } from "./barChartLogic";
20
20
  export { KapiTable, DEFAULT_TABLE_LABELS } from "./KapiTable";
21
- export type { KapiTableColumn, KapiTableCellValue, KapiTableSortDirection, KapiTableSortState, KapiTableSortValue, KapiTableCsvOptions, KapiTableDataset, KapiTableLabels, KapiTableProps, KapiTableSelectionPreset } from "./KapiTable";
21
+ export type { KapiTableCellValue, KapiTableColumn, KapiTableCsvOptions, KapiTableDataset, KapiTableKey, KapiTableKeyField, KapiTableLabels, KapiTableProps, KapiTableSelectionPreset, KapiTableSortDirection, KapiTableSortState, KapiTableSortValue } from "./KapiTable";
22
22
  export { datasetNoticeState, datasetHintLabel, datasetActionLabel, datasetSelectedLabel } from "./datasetSelectionLogic";
23
23
  export { KapiTableFilter, DEFAULT_TABLE_FILTER_LABELS } from "./KapiTableFilter";
24
24
  export type { KapiTableFilterProps, KapiTableFilterLabels } from "./KapiTableFilter";
@@ -18,8 +18,15 @@ export type KapiFacetedSearchLabels = {
18
18
  empty: string;
19
19
  /** Prefijo del botón × de cada chip ("Quitar Estado: Pendiente"). */
20
20
  remove: string;
21
- /** Prefijo del nombre accesible del campo de fecha ("Valor de Fecha desde"). */
22
- valueOf: string;
21
+ /**
22
+ * Prefijo del nombre accesible del campo de fecha ("Valor de Fecha desde").
23
+ * Se llamaba `valueOf`, y ese nombre rompía la prop entera: `Object.prototype` le presta un
24
+ * `valueOf` a todo objeto literal, así que TypeScript lo veía en el tipo aparente de cualquier
25
+ * override parcial, comparaba `() => Object` contra `string` y rechazaba `labels` completo
26
+ * (TS2322 nombrando una clave que el consumidor nunca escribió). Ninguna clave de labels puede
27
+ * llamarse como un miembro de `Object.prototype`; lo fija `components/labels.types.test.tsx`.
28
+ */
29
+ valuePrefix: string;
23
30
  /** Botón que quita todos los filtros (con `onClearAll`). */
24
31
  clearAll: string;
25
32
  /** Mientras `loadOptions` de la faceta está resolviendo. */
@@ -21,7 +21,7 @@ var f = {
21
21
  typeValue: "escribir texto…",
22
22
  empty: "Sin opciones",
23
23
  remove: "Quitar",
24
- valueOf: "Valor de",
24
+ valuePrefix: "Valor de",
25
25
  clearAll: "Limpiar todo",
26
26
  loading: "Buscando…",
27
27
  loadError: "No se pudieron cargar los valores",
@@ -188,13 +188,13 @@ function p({ facets: p, chips: m, onText: fe, onClearAll: h, loadDelay: g = 300,
188
188
  onKeyDown: Ce,
189
189
  children: E.kind === "dateRange" ? /* @__PURE__ */ s(ee, {
190
190
  ref: C,
191
- "aria-label": `${v.valueOf} ${E.label}`,
191
+ "aria-label": `${v.valuePrefix} ${E.label}`,
192
192
  onChange: ({ from: e, to: t }) => {
193
193
  e && t && (E.apply(se(e, t), O ?? "eq"), Z());
194
194
  }
195
195
  }) : /* @__PURE__ */ s(r, {
196
196
  ref: C,
197
- "aria-label": `${v.valueOf} ${E.label}`,
197
+ "aria-label": `${v.valuePrefix} ${E.label}`,
198
198
  onChange: (e) => {
199
199
  e && (E.apply(ce(e), O ?? "eq"), Z());
200
200
  }