@kapiuara/ui 0.9.0 → 0.11.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 (91) hide show
  1. package/README.md +29 -11
  2. package/dist/components/data/KapiBarChart.d.ts +84 -0
  3. package/dist/components/data/KapiBarChart.js +87 -0
  4. package/dist/components/data/KapiEventCalendar.d.ts +70 -0
  5. package/dist/components/data/KapiEventCalendar.js +225 -0
  6. package/dist/components/data/KapiHeatmap.d.ts +62 -0
  7. package/dist/components/data/KapiHeatmap.js +120 -0
  8. package/dist/components/data/KapiLineChart.d.ts +50 -0
  9. package/dist/components/data/KapiLineChart.js +105 -0
  10. package/dist/components/data/KapiPaginationFooter.js +6 -5
  11. package/dist/components/data/KapiSparkline.d.ts +41 -0
  12. package/dist/components/data/KapiSparkline.js +55 -0
  13. package/dist/components/data/KapiTable.d.ts +1 -1
  14. package/dist/components/data/KapiTable.js +371 -359
  15. package/dist/components/data/barChartLogic.d.ts +59 -0
  16. package/dist/components/data/barChartLogic.js +53 -0
  17. package/dist/components/data/chartFrame.d.ts +96 -0
  18. package/dist/components/data/chartFrame.js +89 -0
  19. package/dist/components/data/eventCalendarLogic.d.ts +70 -0
  20. package/dist/components/data/eventCalendarLogic.js +45 -0
  21. package/dist/components/data/heatmapLogic.d.ts +15 -0
  22. package/dist/components/data/heatmapLogic.js +15 -0
  23. package/dist/components/data/index.d.ts +19 -0
  24. package/dist/components/data/lineChartLogic.d.ts +30 -0
  25. package/dist/components/data/lineChartLogic.js +21 -0
  26. package/dist/components/data/sparklineLogic.d.ts +28 -0
  27. package/dist/components/data/sparklineLogic.js +18 -0
  28. package/dist/components/display/KapiStat.d.ts +1 -1
  29. package/dist/components/feedback/KapiBulkBar.d.ts +1 -1
  30. package/dist/components/inputs/KapiDatePicker.d.ts +8 -2
  31. package/dist/components/inputs/KapiDatePicker.js +120 -106
  32. package/dist/components/inputs/KapiDateRangePicker.d.ts +26 -5
  33. package/dist/components/inputs/KapiDateRangePicker.js +146 -111
  34. package/dist/components/inputs/datePickerLogic.d.ts +9 -0
  35. package/dist/components/inputs/datePickerLogic.js +25 -25
  36. package/dist/components/inputs/dateRangeLogic.d.ts +23 -4
  37. package/dist/components/inputs/dateRangeLogic.js +48 -22
  38. package/dist/components/inputs/facetedSearchLogic.d.ts +1 -1
  39. package/dist/components/layout/KapiContextSlot.js +108 -88
  40. package/dist/components/layout/KapiMasonry.d.ts +30 -0
  41. package/dist/components/layout/KapiMasonry.js +33 -0
  42. package/dist/components/layout/KapiPageHeader.js +136 -58
  43. package/dist/components/layout/KapiRail.d.ts +8 -2
  44. package/dist/components/layout/KapiRail.js +118 -67
  45. package/dist/components/layout/KapiShell.js +67 -37
  46. package/dist/components/layout/index.d.ts +2 -0
  47. package/dist/components/layout/masonryLogic.d.ts +40 -0
  48. package/dist/components/layout/masonryLogic.js +8 -0
  49. package/dist/components/layout/pageHeaderLogic.d.ts +25 -0
  50. package/dist/components/layout/pageHeaderLogic.js +16 -2
  51. package/dist/components/layout/railLogic.d.ts +41 -1
  52. package/dist/components/layout/railLogic.js +36 -4
  53. package/dist/components/layout/reopenBus.d.ts +53 -0
  54. package/dist/components/layout/reopenBus.js +6 -0
  55. package/dist/components/layout/useMasonrySpans.d.ts +32 -0
  56. package/dist/components/layout/useMasonrySpans.js +44 -0
  57. package/dist/components/layout/useRailOverflow.d.ts +17 -0
  58. package/dist/components/layout/useRailOverflow.js +41 -0
  59. package/dist/components/locale/labelRegistry.d.ts +10 -1
  60. package/dist/components/navigation/KapiFilterChips.js +1 -1
  61. package/dist/components/navigation/filterChipsLogic.d.ts +7 -1
  62. package/dist/components/navigation/filterChipsLogic.js +3 -3
  63. package/dist/components/overlays/KapiContextMenu.d.ts +3 -0
  64. package/dist/components/overlays/KapiContextMenu.js +2 -1
  65. package/dist/components/overlays/KapiDropdown.d.ts +3 -1
  66. package/dist/components/overlays/KapiDropdown.js +29 -26
  67. package/dist/components/overlays/KapiMenuButton.js +1 -0
  68. package/dist/components/overlays/KapiOffcanvasStack.d.ts +2 -2
  69. package/dist/hooks/breakpointOpenLogic.d.ts +20 -5
  70. package/dist/hooks/breakpointOpenLogic.js +2 -2
  71. package/dist/hooks/dataColorLogic.d.ts +23 -0
  72. package/dist/hooks/index.d.ts +3 -1
  73. package/dist/hooks/numberFormatLogic.d.ts +7 -0
  74. package/dist/hooks/numberFormatLogic.js +5 -2
  75. package/dist/hooks/seriesPaletteLogic.d.ts +24 -0
  76. package/dist/hooks/themeContrastLogic.js +1 -0
  77. package/dist/hooks/themeDeriveLogic.d.ts +11 -1
  78. package/dist/hooks/themeDeriveLogic.js +40 -31
  79. package/dist/hooks/themeRadiiLogic.d.ts +1 -1
  80. package/dist/hooks/themeRadiiLogic.js +1 -0
  81. package/dist/hooks/useKapiTheme.js +27 -27
  82. package/dist/hooks/useMediaQuery.d.ts +7 -0
  83. package/dist/hooks/useMediaQuery.js +4 -4
  84. package/dist/hooks/useWheelZoom.d.ts +30 -0
  85. package/dist/hooks/useWheelZoom.js +27 -0
  86. package/dist/hooks/wheelZoomLogic.d.ts +18 -0
  87. package/dist/hooks/wheelZoomLogic.js +9 -0
  88. package/dist/index.js +125 -113
  89. package/dist/kapi.css +1 -1
  90. package/dist/kapi.layered.css +1 -1
  91. package/package.json +3 -7
@@ -0,0 +1,59 @@
1
+ /** The top of the axis and the ticks under it, both in data units. */
2
+ export type KapiBarScale = {
3
+ /** The value the top of the plot stands for; always a round number, never the raw maximum. */
4
+ max: number;
5
+ /** Tick values from zero up to `max`, inclusive. */
6
+ ticks: readonly number[];
7
+ };
8
+ /**
9
+ * A rounded axis that covers `values`, with at most `tickCount` steps above zero.
10
+ *
11
+ * Negatives do not get their own direction: this chart anchors at zero, so a negative value is
12
+ * floored there and the bar reads as empty. A dataset that needs both directions needs a
13
+ * different form, not a taller axis.
14
+ */
15
+ export declare const barScale: (values: readonly number[], tickCount?: number) => KapiBarScale;
16
+ /** How tall a bar is, as a percentage of the plot (0-100). Clamped: no bar escapes its box. */
17
+ export declare const barHeight: (value: number, max: number) => number;
18
+ /**
19
+ * A number for an axis label. Thousands become `1,2 k` and millions `3,4 M`, because an axis with
20
+ * `1200000` on it pushes the plot sideways for no information. The decimal comma is the one the
21
+ * UI of this design system writes in.
22
+ */
23
+ export declare const barTickLabel: (value: number) => string;
24
+ /** Cuándo se escribe el valor sobre la barra. */
25
+ export type KapiBarValueLabels = "auto" | "all" | "max" | "none";
26
+ /**
27
+ * Cuántas barras como mucho llevan su valor escrito en `auto`. El método de dataviz es explícito:
28
+ * una etiqueta al lado de cada marca es ruido y no se lee, y las etiquetas directas funcionan
29
+ * **porque** son escasas. Seis es el techo donde todavía se leen de un vistazo; pasando eso el
30
+ * valor queda en el eje, el tooltip y la tabla, que es donde se busca un número exacto.
31
+ */
32
+ export declare const DIRECT_LABEL_MAX_BARS = 6;
33
+ /**
34
+ * Qué barras llevan su valor escrito, como un predicado por índice plano (serie × categoría).
35
+ * `auto` las escribe todas mientras entren pocas, y arriba de ahí sólo la más alta, que es la que
36
+ * cuenta la historia. Devuelve una función y no un array para no armar una lista por render.
37
+ */
38
+ export declare const barValueLabelPredicate: (values: readonly number[], mode?: KapiBarValueLabels) => ((index: number) => boolean);
39
+ /**
40
+ * El total de cada categoría, para el eje de un gráfico apilado. Apilado el eje NO llega al mayor
41
+ * valor suelto sino a la suma más alta: si llegara al valor suelto, la pila más alta se saldría
42
+ * del plot.
43
+ *
44
+ * `rows` es serie por serie, cada una con un valor por categoría.
45
+ */
46
+ export declare const barStackTotals: (rows: readonly (readonly number[])[], categories: number) => number[];
47
+ /** Cómo se ordenan las categorías antes de dibujarlas. */
48
+ export type KapiBarSort = "none" | "desc" | "asc";
49
+ /**
50
+ * El orden en que van las categorías, como una lista de índices.
51
+ *
52
+ * Ordenar de mayor a menor es lo que hace legible una comparación de partes: con las barras
53
+ * apoyadas en la misma base y ordenadas, el ojo lee el ranking sin contar. El criterio es el
54
+ * TOTAL de la categoría sumando las series, que es lo que se compara cuando hay más de una.
55
+ *
56
+ * `none` deja el orden que vino, que es lo correcto cuando el eje significa algo —meses, pasos de
57
+ * un proceso—: ahí reordenar destruye la información.
58
+ */
59
+ export declare const barCategoryOrder: (rows: readonly (readonly number[])[], categories: number, sort?: KapiBarSort) => number[];
@@ -0,0 +1,53 @@
1
+ //#region src/components/data/barChartLogic.ts
2
+ var e = [
3
+ 1,
4
+ 2,
5
+ 2.5,
6
+ 5,
7
+ 10
8
+ ], t = (e) => Number.isFinite(e) ? e : 0, n = (n, r = 4) => {
9
+ let i = Math.max(1, Math.floor(t(r))), a = n.reduce((e, n) => Math.max(e, t(n)), 0);
10
+ if (a <= 0) return {
11
+ max: 1,
12
+ ticks: [0, 1]
13
+ };
14
+ let o = a / i, s = 10 ** Math.floor(Math.log10(o)), c = (e.find((e) => e * s >= o) ?? 10) * s, l = Math.ceil(a / c) * c;
15
+ if (!(c > 0) || !Number.isFinite(c) || !Number.isFinite(l)) return {
16
+ max: 1,
17
+ ticks: [0, 1]
18
+ };
19
+ let u = [];
20
+ for (let e = 0; e * c <= l + c / 1e6; e += 1) u.push(Number((e * c).toPrecision(12)));
21
+ return {
22
+ max: l,
23
+ ticks: u
24
+ };
25
+ }, r = (e, n) => n > 0 ? Math.min(100, Math.max(0, t(e) / n * 100)) : 0, i = (e) => {
26
+ if (!Number.isFinite(e)) return "";
27
+ let t = Math.abs(e), n = (t, n) => {
28
+ let r = e / t;
29
+ return `${Number.isInteger(r) ? String(r) : r.toFixed(1).replace(".", ",")} ${n}`;
30
+ };
31
+ return t >= 1e6 ? n(1e6, "M") : t >= 1e3 ? n(1e3, "k") : Number.isInteger(e) ? String(e) : String(e).replace(".", ",");
32
+ }, a = 6, o = (e, t = "auto") => {
33
+ if (t === "none") return () => !1;
34
+ if (t === "all" || t === "auto" && e.length <= 6) return () => !0;
35
+ let n = -1, r = -Infinity;
36
+ return e.forEach((e, t) => {
37
+ let i = Number.isFinite(e) ? e : -Infinity;
38
+ i > r && (r = i, n = t);
39
+ }), (e) => e === n && r > -Infinity;
40
+ }, s = (e, t) => Array.from({ length: Math.max(0, Math.floor(t)) }, (t, n) => e.reduce((e, t) => {
41
+ let r = t[n];
42
+ return e + (Number.isFinite(r) && r > 0 ? r : 0);
43
+ }, 0)), c = (e, t, n = "none") => {
44
+ let r = Math.max(0, Math.floor(t)), i = Array.from({ length: r }, (e, t) => t);
45
+ if (n === "none") return i;
46
+ let a = s(e, r);
47
+ return i.sort((e, t) => {
48
+ let r = a[t] - a[e];
49
+ return r === 0 ? e - t : n === "desc" ? r : -r;
50
+ });
51
+ };
52
+ //#endregion
53
+ export { a as DIRECT_LABEL_MAX_BARS, c as barCategoryOrder, r as barHeight, n as barScale, s as barStackTotals, i as barTickLabel, o as barValueLabelPredicate };
@@ -0,0 +1,96 @@
1
+ import { type CSSProperties, type ReactNode } from "react";
2
+ import type { KapiLabelsOverride } from "../labelsLogic";
3
+ /** Textos que comparten los gráficos. */
4
+ export type KapiChartLabels = {
5
+ /** Opción que muestra el gráfico. */
6
+ chartView: string;
7
+ /** Opción que muestra la tabla con los mismos datos. */
8
+ tableView: string;
9
+ /** Nombre del selector de vista. */
10
+ view: string;
11
+ /** Encabezado de la primera columna de la tabla. */
12
+ series: string;
13
+ /** Qué se dice cuando no hay nada que dibujar. */
14
+ empty: string;
15
+ /** Cómo se describe el gráfico para quien no lo ve; `{series}` y `{categories}` se reemplazan. */
16
+ summary: string;
17
+ /** Cómo se nombra cada forma al empezar ese resumen. */
18
+ kindBars: string;
19
+ kindStackedBars: string;
20
+ kindLine: string;
21
+ };
22
+ export declare const DEFAULT_CHART_LABELS: KapiChartLabels;
23
+ /**
24
+ * El nombre accesible del plot: la forma, y después el resumen con sus números. Vive acá y no en
25
+ * cada gráfico porque armarlo concatenando un literal suelto deja la mitad de la frase fuera del
26
+ * sistema de locales, y quien traduzca con `KapiLocaleProvider` se queda con una frase a medias.
27
+ */
28
+ export declare const chartSummary: (kind: string, text: KapiChartLabels, series: number, categories: number) => string;
29
+ /** Cuál de las dos vistas se está mostrando. */
30
+ export type KapiChartView = "chart" | "table";
31
+ /**
32
+ * El prefijo de clases del gráfico concreto. Es una unión y no un `string` porque un typo acá
33
+ * produce marcado sin estilo que nada detecta: el CSS simplemente no engancha.
34
+ */
35
+ export type KapiChartBlock = "kapi-barchart" | "kapi-linechart";
36
+ /** Lo mínimo que la cáscara necesita saber de una serie para la leyenda y la tabla. */
37
+ export type KapiChartSeriesInfo = {
38
+ /** Id estable; clave de React y de la fila. */
39
+ id: string;
40
+ /** Nombre en la leyenda y en la tabla. */
41
+ label: string;
42
+ };
43
+ export type KapiChartFrameProps = {
44
+ /** Título visible; sin él hace falta `aria-label` en la raíz. */
45
+ title?: ReactNode | undefined;
46
+ /** Id del título, para que la raíz lo referencie. */
47
+ titleId: string;
48
+ /** Series ya recortadas a los slots de la paleta, en orden. */
49
+ series: readonly KapiChartSeriesInfo[];
50
+ /** Etiquetas del eje de categorías. */
51
+ categories: readonly string[];
52
+ /** El valor de una celda, por índice de serie y de categoría. */
53
+ valueAt: (seriesIndex: number, categoryIndex: number) => number;
54
+ /** Vista mostrada. */
55
+ view: KapiChartView;
56
+ /** Cambiar de vista. */
57
+ onViewChange: (view: KapiChartView) => void;
58
+ /** Textos ya resueltos. */
59
+ text: KapiChartLabels;
60
+ /** Prefijo de las clases CSS del gráfico concreto. */
61
+ block: KapiChartBlock;
62
+ /** El plot. Sólo se dibuja en la vista de gráfico. */
63
+ children: ReactNode;
64
+ };
65
+ /** Resuelve los textos del gráfico: defaults < provider < prop. */
66
+ export declare const useChartLabels: (labels: KapiLabelsOverride<KapiChartLabels> | undefined) => KapiChartLabels;
67
+ /** El estado de vista, controlado o propio, con la misma convención que el resto del sistema. */
68
+ export declare const useChartView: (view: KapiChartView | undefined, defaultView: KapiChartView, onViewChange: ((view: KapiChartView) => void) | undefined) => {
69
+ current: KapiChartView;
70
+ setView: (next: KapiChartView) => void;
71
+ };
72
+ /**
73
+ * El dato, como custom properties. El componente dice CUÁNTO y de qué serie; el CSS decide qué
74
+ * hacer con el número: si `y` es un alto, un `bottom` o un `translateY` es decisión de la hoja de
75
+ * estilos, y cambiarla no toca el `.tsx`. Es el patrón de `--kapi-slider-pct`.
76
+ *
77
+ * Va inline y está bien que vaya: esto es **dato**, no diseño. El problema conocido del inline es
78
+ * que le gana a una media query, y por eso las props de layout de las primitivas no pueden ir así;
79
+ * pero una posición que sale del dato no cambia con el ancho — 37,5% del eje es 37,5% siempre.
80
+ */
81
+ export declare const chartVars: ({ slot, x, y }: {
82
+ /** Índice de la serie, 0-based: elige el slot de la paleta. */
83
+ slot?: number | undefined;
84
+ /** Posición horizontal, en porcentaje del lienzo. */
85
+ x?: number | undefined;
86
+ /** Magnitud o posición vertical, en porcentaje del eje. */
87
+ y?: number | undefined;
88
+ }) => CSSProperties;
89
+ /** El cuadrito de color de una serie. El texto va con tinta, nunca con el color del dato. */
90
+ export declare const ChartSwatch: ({ block, slot }: {
91
+ block: KapiChartBlock;
92
+ slot: number;
93
+ }) => import("react").JSX.Element;
94
+ export declare const KapiChartFrame: ({ title, titleId, series, categories, valueAt, view, onViewChange, text, block, children }: KapiChartFrameProps) => import("react").JSX.Element;
95
+ /** El `useId` de la cáscara, para que el gráfico ate su título sin repetir el hook. */
96
+ export declare const useChartTitleId: () => string;
@@ -0,0 +1,89 @@
1
+ "use client";
2
+ import { useLabels as e } from "../locale/KapiLocaleProvider.js";
3
+ import { formatDataValue as t } from "../../hooks/numberFormatLogic.js";
4
+ import { KapiSegmented as n } from "../inputs/KapiSegmented.js";
5
+ import { Fragment as r, jsx as i, jsxs as a } from "react/jsx-runtime";
6
+ import { useId as o, useState as s } from "react";
7
+ //#region src/components/data/chartFrame.tsx
8
+ var c = {
9
+ chartView: "Gráfico",
10
+ tableView: "Tabla",
11
+ view: "Vista de los datos",
12
+ series: "Serie",
13
+ empty: "Sin datos para mostrar",
14
+ summary: "{series} series en {categories} categorías. Cambiá a la vista de tabla para leer los valores.",
15
+ kindBars: "Gráfico de barras",
16
+ kindStackedBars: "Gráfico de barras apiladas",
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) => {
19
+ let [r, i] = s(t);
20
+ return {
21
+ current: e ?? r,
22
+ setView: (t) => {
23
+ e === void 0 && i(t), n?.(t);
24
+ }
25
+ };
26
+ }, f = ({ slot: e, x: t, y: n }) => ({
27
+ ...e === void 0 ? {} : { "--kapi-chart-slot": `var(--kapi-series-${e + 1})` },
28
+ ...t === void 0 ? {} : { "--kapi-chart-x": `${t}%` },
29
+ ...n === void 0 ? {} : { "--kapi-chart-y": `${n}%` }
30
+ }), p = ({ block: e, slot: t }) => /* @__PURE__ */ i("span", {
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;
35
+ return /* @__PURE__ */ a(r, { children: [/* @__PURE__ */ a("div", {
36
+ className: `${m}__head`,
37
+ children: [e ? /* @__PURE__ */ i("div", {
38
+ className: `${m}__title`,
39
+ id: o,
40
+ children: e
41
+ }) : null, /* @__PURE__ */ i(n, {
42
+ "aria-label": f.view,
43
+ items: [{
44
+ id: "chart",
45
+ label: f.chartView
46
+ }, {
47
+ id: "table",
48
+ label: f.tableView
49
+ }],
50
+ value: u,
51
+ onChange: d
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`,
58
+ children: /* @__PURE__ */ a("table", {
59
+ className: `${m}__table`,
60
+ children: [/* @__PURE__ */ i("thead", { children: /* @__PURE__ */ a("tr", { children: [/* @__PURE__ */ i("th", {
61
+ scope: "col",
62
+ children: f.series
63
+ }), c.map((e, t) => /* @__PURE__ */ i("th", {
64
+ scope: "col",
65
+ children: e
66
+ }, `${e}-${t}`))] }) }), /* @__PURE__ */ i("tbody", { children: s.map((e, n) => /* @__PURE__ */ a("tr", { children: [/* @__PURE__ */ i("th", {
67
+ scope: "row",
68
+ children: /* @__PURE__ */ a("span", {
69
+ className: `${m}__serie`,
70
+ children: [/* @__PURE__ */ i(p, {
71
+ block: m,
72
+ slot: n
73
+ }), e.label]
74
+ })
75
+ }), c.map((e, r) => /* @__PURE__ */ i("td", { children: t(l(n, r)) }, `${e}-${r}`))] }, e.id)) })]
76
+ })
77
+ }) : /* @__PURE__ */ a(r, { children: [s.length > 1 ? /* @__PURE__ */ i("ul", {
78
+ className: `${m}__legend`,
79
+ children: s.map((e, t) => /* @__PURE__ */ a("li", {
80
+ className: `${m}__legenditem`,
81
+ children: [/* @__PURE__ */ i(p, {
82
+ block: m,
83
+ slot: t
84
+ }), e.label]
85
+ }, e.id))
86
+ }) : null, h] })] });
87
+ }, h = () => o();
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 };
@@ -0,0 +1,70 @@
1
+ import { type CalendarCell } from "../inputs/datePickerLogic";
2
+ /**
3
+ * Un evento del calendario. `fin` es INCLUSIVO: el último día que el evento ocupa.
4
+ *
5
+ * Esa decisión no es cosmética. La convención de la mayoría de las librerías de calendario es que
6
+ * el fin sea EXCLUSIVO, y el precio se paga en cada llamador: el código que motivó este componente
7
+ * hacía `end.setDate(end.getDate() + 1)` y después `setUTCHours(23, 59, 59, 999)` sobre las dos
8
+ * puntas para que los días se pintaran bien, con un comentario en mayúsculas explicando el ritual.
9
+ * Un evento que «va del 3 al 5» ocupa el 3, el 4 y el 5; pedir que el llamador escriba 6 es
10
+ * trasladarle un detalle de implementación.
11
+ */
12
+ export type KapiCalendarEvent = {
13
+ id: string;
14
+ title: string;
15
+ /** Primer día que ocupa. La hora se ignora: este calendario es de días completos. */
16
+ start: Date;
17
+ /** Último día que ocupa, inclusive. Si falta, dura un día. */
18
+ end?: Date | undefined;
19
+ /** Slot de la paleta de datos (1..8). Mismo orden fijo que los gráficos. */
20
+ slot?: number | undefined;
21
+ /** Texto secundario: se muestra en la vista de lista y en el popover de «+N». */
22
+ detail?: string | undefined;
23
+ };
24
+ /** Medianoche local. Comparar fechas con hora adentro es la fuente de los errores de un día. */
25
+ export declare const aDia: (d: Date) => number;
26
+ /** ¿El evento ocupa ese día? Compara por día, no por instante. */
27
+ export declare const ocupaElDia: (evento: KapiCalendarEvent, dia: Date) => boolean;
28
+ /** Cuántos días ocupa (mínimo 1). */
29
+ export declare const duracionEnDias: (evento: KapiCalendarEvent) => number;
30
+ /**
31
+ * Los eventos de un día, ordenados para que la grilla no salte.
32
+ *
33
+ * Primero los más largos y después por fecha de inicio: así un evento de varios días mantiene la
34
+ * misma altura en todas las celdas que cruza, en vez de aparecer arriba un día y abajo el
35
+ * siguiente. El desempate por título hace el orden determinista, que es lo que permite
36
+ * fotografiarlo en una baseline.
37
+ */
38
+ export declare const eventosDelDia: (eventos: readonly KapiCalendarEvent[], dia: Date) => KapiCalendarEvent[];
39
+ /**
40
+ * Lo que entra en la celda y cuántos quedan afuera.
41
+ *
42
+ * Con `max` eventos y uno más que no entra, se muestran `max - 1` y el cartel dice «+2»: mostrar
43
+ * `max` y decir «+1» obliga a abrir el popover para ver UN evento que podría haber entrado. El
44
+ * cartel ocupa el mismo lugar que una fila de evento.
45
+ */
46
+ export declare const visiblesYResto: (eventos: readonly KapiCalendarEvent[], max: number) => {
47
+ visibles: KapiCalendarEvent[];
48
+ resto: number;
49
+ };
50
+ /** Las 6 semanas del mes, sin los días de los meses vecinos marcados aparte. */
51
+ export declare const semanasDelMes: (view: Date) => CalendarCell[][];
52
+ /** Los eventos que tocan el mes visible, ordenados por inicio: es la vista de lista. */
53
+ export declare const eventosDelMes: (eventos: readonly KapiCalendarEvent[], view: Date) => KapiCalendarEvent[];
54
+ /** Mes anterior o siguiente, sin arrastrar el día (el 31 no puede saltar a marzo). */
55
+ export declare const correrMes: (view: Date, delta: number) => Date;
56
+ /**
57
+ * Qué días del año tienen algo, para la vista de año.
58
+ *
59
+ * Devuelve un mapa de día (medianoche local, en milisegundos) a la cantidad y al slot del primer
60
+ * evento —el más largo, por el orden de `eventosDelDia`—. El slot sirve para pintar el punto con
61
+ * el color del tipo, que es lo que permite leer el año de un vistazo en vez de contar puntos
62
+ * grises.
63
+ *
64
+ * Recorre los eventos y no los días: un año son 365 iteraciones por evento si se hace al revés,
65
+ * y la mayoría de los eventos duran uno o dos días.
66
+ */
67
+ export declare const diasConEventos: (eventos: readonly KapiCalendarEvent[], year: number) => Map<number, {
68
+ total: number;
69
+ slot: number;
70
+ }>;
@@ -0,0 +1,45 @@
1
+ import { buildDays as e } from "../inputs/datePickerLogic.js";
2
+ //#region src/components/data/eventCalendarLogic.ts
3
+ var t = (e) => new Date(e.getFullYear(), e.getMonth(), e.getDate()).getTime(), n = (e, n) => {
4
+ let r = t(n), i = t(e.start), a = t(e.end ?? e.start);
5
+ return a < i ? r === i : r >= i && r <= a;
6
+ }, r = (e) => {
7
+ let n = t(e.start), r = t(e.end ?? e.start);
8
+ return r < n ? 1 : Math.round((r - n) / 864e5) + 1;
9
+ }, i = (e, i) => e.filter((e) => n(e, i)).sort((e, n) => r(n) - r(e) || t(e.start) - t(n.start) || e.title.localeCompare(n.title)), a = (e, t) => t <= 0 ? {
10
+ visibles: [],
11
+ resto: e.length
12
+ } : e.length <= t ? {
13
+ visibles: [...e],
14
+ resto: 0
15
+ } : {
16
+ visibles: e.slice(0, t - 1),
17
+ resto: e.length - (t - 1)
18
+ }, o = (t) => {
19
+ let n = e(t.getFullYear(), t.getMonth()), r = [];
20
+ for (let e = 0; e < n.length; e += 7) r.push(n.slice(e, e + 7));
21
+ return r;
22
+ }, s = (e, n) => {
23
+ let r = t(new Date(n.getFullYear(), n.getMonth(), 1)), i = t(new Date(n.getFullYear(), n.getMonth() + 1, 0));
24
+ return e.filter((e) => {
25
+ let n = t(e.start);
26
+ return Math.max(n, t(e.end ?? e.start)) >= r && n <= i;
27
+ }).sort((e, n) => t(e.start) - t(n.start) || e.title.localeCompare(n.title));
28
+ }, c = (e, t) => new Date(e.getFullYear(), e.getMonth() + t, 1), l = (e, n) => {
29
+ let r = /* @__PURE__ */ new Map();
30
+ for (let i of e) {
31
+ let e = t(i.start), a = Math.max(e, t(i.end ?? i.start));
32
+ for (let o = e; o <= a; o += 864e5) {
33
+ let e = new Date(o);
34
+ if (e.getFullYear() !== n) continue;
35
+ let a = t(e), s = r.get(a);
36
+ r.set(a, {
37
+ total: (s?.total ?? 0) + 1,
38
+ slot: s?.slot ?? i.slot ?? 1
39
+ });
40
+ }
41
+ }
42
+ return r;
43
+ };
44
+ //#endregion
45
+ export { t as aDia, c as correrMes, l as diasConEventos, r as duracionEnDias, i as eventosDelDia, s as eventosDelMes, n as ocupaElDia, o as semanasDelMes, a as visiblesYResto };
@@ -0,0 +1,15 @@
1
+ /** Cuántos pasos tiene la rampa secuencial (`--kapi-seq-1..5`). */
2
+ export declare const SEQ_STEPS = 5;
3
+ /**
4
+ * En qué paso de la rampa cae un valor, 1-based. El rango va de 0 a `max` y se parte en tramos
5
+ * iguales; un valor en el borde cae en el tramo de ARRIBA, así el máximo no se queda solo en un
6
+ * paso propio.
7
+ *
8
+ * Un valor no finito, o un `max` que no es positivo, devuelve 0: "sin dato", que el componente
9
+ * dibuja distinto de un cero real. Un cero real sí es el paso 1.
10
+ */
11
+ export declare const heatStep: (value: number, max: number, steps?: number) => number;
12
+ /** El valor máximo de una grilla, ignorando lo no finito. Cero o vacía devuelve 0. */
13
+ export declare const heatMax: (rows: readonly (readonly number[])[]) => number;
14
+ /** Los cortes de cada paso, para la leyenda: `[desde, hasta]` por paso, de menor a mayor. */
15
+ export declare const heatLegendRanges: (max: number, steps?: number) => Array<[number, number]>;
@@ -0,0 +1,15 @@
1
+ //#region src/components/data/heatmapLogic.ts
2
+ var e = 5, t = (e, t, n = 5) => {
3
+ let r = Math.max(1, Math.floor(n));
4
+ if (!Number.isFinite(e) || !(t > 0)) return 0;
5
+ if (e <= 0) return 1;
6
+ let i = Math.min(1, e / t);
7
+ return Math.min(r, Math.ceil(i * r));
8
+ }, n = (e) => e.reduce((e, t) => t.reduce((e, t) => Number.isFinite(t) && t > e ? t : e, e), 0), r = (e, t = 5) => {
9
+ let n = Math.max(1, Math.floor(t));
10
+ if (!(e > 0)) return [];
11
+ let r = e / n;
12
+ return Array.from({ length: n }, (e, t) => [t * r, (t + 1) * r]);
13
+ };
14
+ //#endregion
15
+ export { e as SEQ_STEPS, r as heatLegendRanges, n as heatMax, t as heatStep };
@@ -1,3 +1,22 @@
1
+ export { KapiEventCalendar, DEFAULT_EVENT_CALENDAR_LABELS } from "./KapiEventCalendar";
2
+ export type { KapiEventCalendarProps, KapiEventCalendarLabels, KapiEventCalendarView, KapiCalendarEvent } from "./KapiEventCalendar";
3
+ export { KapiHeatmap, DEFAULT_HEATMAP_LABELS } from "./KapiHeatmap";
4
+ export type { KapiHeatmapProps, KapiHeatmapLabels } from "./KapiHeatmap";
5
+ export { heatStep, heatMax, heatLegendRanges, SEQ_STEPS } from "./heatmapLogic";
6
+ export { KapiSparkline, DEFAULT_SPARKLINE_LABELS } from "./KapiSparkline";
7
+ export type { KapiSparklineProps, KapiSparklineLabels } from "./KapiSparkline";
8
+ export { sparklineTrend, sparklineMax, sparklineLabel } from "./sparklineLogic";
9
+ export type { KapiSparklineTrend, KapiSparklineLabelParts } from "./sparklineLogic";
10
+ export { KapiLineChart } from "./KapiLineChart";
11
+ export type { KapiLineChartProps, KapiLineChartSeries } from "./KapiLineChart";
12
+ export { linePoints, linePath, areaPath, lineEndpoint, svgY } from "./lineChartLogic";
13
+ export type { KapiLinePoint } from "./lineChartLogic";
14
+ export { KapiBarChart } from "./KapiBarChart";
15
+ export type { KapiBarChartProps, KapiBarChartSeries } from "./KapiBarChart";
16
+ export { DEFAULT_CHART_LABELS } from "./chartFrame";
17
+ export type { KapiChartLabels, KapiChartView } from "./chartFrame";
18
+ export { barScale, barHeight, barTickLabel, barValueLabelPredicate, barCategoryOrder, barStackTotals, DIRECT_LABEL_MAX_BARS } from "./barChartLogic";
19
+ export type { KapiBarScale, KapiBarSort, KapiBarValueLabels } from "./barChartLogic";
1
20
  export { KapiTable, DEFAULT_TABLE_LABELS } from "./KapiTable";
2
21
  export type { KapiTableColumn, KapiTableCellValue, KapiTableSortDirection, KapiTableSortState, KapiTableSortValue, KapiTableCsvOptions, KapiTableDataset, KapiTableLabels, KapiTableProps, KapiTableSelectionPreset } from "./KapiTable";
3
22
  export { datasetNoticeState, datasetHintLabel, datasetActionLabel, datasetSelectedLabel } from "./datasetSelectionLogic";
@@ -0,0 +1,30 @@
1
+ /** A point of the line, in percentages: `x` from the left, `y` from the BOTTOM. */
2
+ export type KapiLinePoint = {
3
+ /** 0 at the first category, 100 at the last. */
4
+ x: number;
5
+ /** 0 at the baseline, 100 at the top of the axis. */
6
+ y: number;
7
+ /** The value this point stands for, already defaulted to 0 where the series was short. */
8
+ value: number;
9
+ };
10
+ /**
11
+ * Where each value sits. A single point goes to the middle: a line of one point is a dot, and
12
+ * pinning it to the left edge would read as "it starts here and stops", which is not what one
13
+ * value means.
14
+ */
15
+ export declare const linePoints: (values: readonly number[], max: number, count?: number) => KapiLinePoint[];
16
+ /** SVG's y axis grows downward; the points are measured from the bottom. One flip, here. */
17
+ export declare const svgY: (y: number) => number;
18
+ /** The `d` of the line through the points. Empty string with nothing to draw. */
19
+ export declare const linePath: (points: readonly KapiLinePoint[]) => string;
20
+ /**
21
+ * The `d` of the area under the line, closed against the baseline. Needs two points: an area of
22
+ * one point is a vertical line with no surface, which says nothing.
23
+ */
24
+ export declare const areaPath: (points: readonly KapiLinePoint[]) => string;
25
+ /**
26
+ * Which point of a series carries its name, for direct labelling: the last one. The method says
27
+ * to label the endpoint — on a line it is where the eye lands and where the series is identified
28
+ * without matching colors against a legend.
29
+ */
30
+ export declare const lineEndpoint: (points: readonly KapiLinePoint[]) => KapiLinePoint | null;
@@ -0,0 +1,21 @@
1
+ import { barHeight as e } from "./barChartLogic.js";
2
+ //#region src/components/data/lineChartLogic.ts
3
+ var t = (t, n, r = t.length) => {
4
+ let i = Math.max(0, Math.floor(r));
5
+ if (i === 0) return [];
6
+ let a = i === 1 ? 0 : 100 / (i - 1);
7
+ return Array.from({ length: i }, (r, o) => {
8
+ let s = t[o], c = Number.isFinite(s) ? s : 0;
9
+ return {
10
+ x: i === 1 ? 50 : o * a,
11
+ y: e(c, n),
12
+ value: c
13
+ };
14
+ });
15
+ }, n = (e) => 100 - e, r = (e) => e.length === 0 ? "" : e.map((e, t) => `${t === 0 ? "M" : "L"}${e.x} ${n(e.y)}`).join(" "), i = (e) => {
16
+ if (e.length < 2) return "";
17
+ let t = e[0], i = e[e.length - 1];
18
+ return `${r(e)} L${i.x} ${n(0)} L${t.x} ${n(0)} Z`;
19
+ }, a = (e) => e.length === 0 ? null : e[e.length - 1];
20
+ //#endregion
21
+ export { i as areaPath, a as lineEndpoint, r as linePath, t as linePoints, n as svgY };
@@ -0,0 +1,28 @@
1
+ /** Hacia dónde fue la serie, comparando el primer valor finito con el último. */
2
+ export type KapiSparklineTrend = "up" | "down" | "flat";
3
+ /** La tendencia de una serie. Sin datos, o con uno solo, no hay tendencia que contar. */
4
+ export declare const sparklineTrend: (values: readonly number[]) => KapiSparklineTrend;
5
+ /**
6
+ * El techo del eje de un sparkline. A diferencia de un gráfico con eje visible, acá no hay ticks
7
+ * que redondear, así que el techo es el máximo: estirar hasta un número redondo sólo achataría la
8
+ * forma, que es lo único que un sparkline tiene para decir.
9
+ */
10
+ export declare const sparklineMax: (values: readonly number[]) => number;
11
+ /** Textos del nombre accesible, para poder traducirlos. */
12
+ export type KapiSparklineLabelParts = {
13
+ /** Cómo empieza la frase. */
14
+ trend: string;
15
+ /** Qué palabra usa cada dirección. */
16
+ up: string;
17
+ down: string;
18
+ flat: string;
19
+ /** Conector del rango: "de 3 a 9". */
20
+ from: string;
21
+ to: string;
22
+ };
23
+ /**
24
+ * El nombre accesible: "Tendencia: sube, de 820 a 1380". Es lo único que un lector de pantalla
25
+ * tiene de un sparkline, así que se arma solo y el consumidor lo pisa con `aria-label` si su
26
+ * contexto ya lo dice mejor.
27
+ */
28
+ export declare const sparklineLabel: (values: readonly number[], parts: KapiSparklineLabelParts, format: (value: number) => string) => string;
@@ -0,0 +1,18 @@
1
+ import { barScale as e } from "./barChartLogic.js";
2
+ //#region src/components/data/sparklineLogic.ts
3
+ var t = (e) => e.filter((e) => Number.isFinite(e)), n = (e) => {
4
+ let n = t(e);
5
+ if (n.length < 2) return "flat";
6
+ let r = n[0], i = n[n.length - 1];
7
+ return i > r ? "up" : i < r ? "down" : "flat";
8
+ }, r = (n) => {
9
+ let r = t(n).reduce((e, t) => Math.max(e, t), 0);
10
+ return r > 0 ? r : e([]).max;
11
+ }, i = (e, r, i) => {
12
+ let a = t(e);
13
+ if (a.length === 0) return r.trend;
14
+ let o = n(e), s = o === "up" ? r.up : o === "down" ? r.down : r.flat, c = i(a[0]), l = i(a[a.length - 1]);
15
+ return a.length === 1 ? `${r.trend}: ${c}` : `${r.trend}: ${s}, ${r.from} ${c} ${r.to} ${l}`;
16
+ };
17
+ //#endregion
18
+ export { i as sparklineLabel, r as sparklineMax, n as sparklineTrend };
@@ -3,7 +3,7 @@ import { type KapiIconTileSize, type KapiIconTileTone } from "./KapiIconTile";
3
3
  import { type KapiStatTone } from "./statLogic";
4
4
  import "./display.css";
5
5
  export type KapiStatProps = Omit<HTMLAttributes<HTMLDivElement>, "children"> & {
6
- /** Rótulo en versalitas (ej. "Matriculados"). */
6
+ /** Rótulo en versalitas (ej. "Inscriptos"). */
7
7
  label: ReactNode;
8
8
  /** Valor principal, en grande (número, monto…). */
9
9
  value: ReactNode;
@@ -7,7 +7,7 @@ export type KapiBulkBarProps = Omit<HTMLAttributes<HTMLDivElement>, "children" |
7
7
  count: number;
8
8
  /** Vacía la selección. */
9
9
  onClear: () => void;
10
- /** Botones de acción masiva. */
10
+ /** Botones de acción masiva. La barra es una superficie densa: su propio "Limpiar" es `size="sm"`, así que las acciones van en `sm` para quedar a la misma altura (32px). */
11
11
  children?: ReactNode;
12
12
  /** Texto del botón de limpiar. Gana sobre `labels.clear` ("Limpiar"). */
13
13
  clearLabel?: string;
@@ -1,4 +1,4 @@
1
- import { type CSSProperties, type FocusEvent, type Ref } from "react";
1
+ import { type CSSProperties, type FocusEvent, type ReactNode, type Ref } from "react";
2
2
  import { type KapiDatePickerMode, type KapiCalendarLabels } from "./datePickerLogic";
3
3
  import "./KapiDatePicker.css";
4
4
  import type { KapiLabelsOverride } from "../labelsLogic";
@@ -12,6 +12,10 @@ export type KapiDatePickerProps = {
12
12
  onChange?: (value: Date | null) => void;
13
13
  /** Texto de ejemplo del campo; por defecto depende de `mode` (`dd/mm/aaaa`, `hh:mm`…). */
14
14
  placeholder?: string;
15
+ /** Ícono (lucide-react) a la izquierda del chip; con `icon` o `label` el campo se dibuja como chip de filtro. */
16
+ icon?: ReactNode;
17
+ /** Prefijo del chip ("Fecha: 19/10/2026"); también nombra al campo si no hay `aria-label` ni `KapiField`. */
18
+ label?: string;
15
19
  /** Deshabilita el campo y el botón del calendario. */
16
20
  disabled?: boolean;
17
21
  /** `id` del campo de texto (para asociarlo a un `<label>`). */
@@ -42,5 +46,7 @@ export type KapiDatePickerProps = {
42
46
  * Controlado: si `value` cambia desde afuera, el texto, la selección y el mes visible se sincronizan.
43
47
  * Teclado: abrir con el botón (o Flecha abajo en el campo) enfoca el día elegido (u hoy) en la grilla;
44
48
  * Escape cierra y devuelve el foco al campo.
49
+ * Con `label` o `icon` el campo se dibuja como el chip de `KapiDropdown` (la misma clase
50
+ * `.kapi-filterchip`), para una fila de filtros que mezcle los dos.
45
51
  */
46
- export declare const KapiDatePicker: ({ mode, value, onChange, placeholder, disabled, id, name, className, style, "aria-label": ariaLabel, labels, minuteStep, ref, onBlur: onBlurProp }: KapiDatePickerProps) => import("react").JSX.Element;
52
+ export declare const KapiDatePicker: ({ mode, value, onChange, placeholder, icon, label, disabled, id, name, className, style, "aria-label": ariaLabel, labels, minuteStep, ref, onBlur: onBlurProp }: KapiDatePickerProps) => import("react").JSX.Element;