@kapiuara/ui 0.10.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.
- package/README.md +10 -5
- package/dist/components/data/KapiBarChart.d.ts +93 -0
- package/dist/components/data/KapiBarChart.js +88 -0
- package/dist/components/data/KapiEventCalendar.d.ts +70 -0
- package/dist/components/data/KapiEventCalendar.js +225 -0
- package/dist/components/data/KapiHeatmap.d.ts +62 -0
- package/dist/components/data/KapiHeatmap.js +120 -0
- package/dist/components/data/KapiLineChart.d.ts +59 -0
- package/dist/components/data/KapiLineChart.js +106 -0
- package/dist/components/data/KapiPaginationFooter.js +1 -0
- package/dist/components/data/KapiSparkline.d.ts +41 -0
- package/dist/components/data/KapiSparkline.js +55 -0
- package/dist/components/data/KapiTable.d.ts +25 -2
- package/dist/components/data/KapiTable.js +371 -359
- package/dist/components/data/barChartLogic.d.ts +59 -0
- package/dist/components/data/barChartLogic.js +53 -0
- package/dist/components/data/chartFrame.d.ts +112 -0
- package/dist/components/data/chartFrame.js +89 -0
- package/dist/components/data/eventCalendarLogic.d.ts +70 -0
- package/dist/components/data/eventCalendarLogic.js +45 -0
- package/dist/components/data/heatmapLogic.d.ts +15 -0
- package/dist/components/data/heatmapLogic.js +15 -0
- package/dist/components/data/index.d.ts +20 -1
- package/dist/components/data/lineChartLogic.d.ts +30 -0
- package/dist/components/data/lineChartLogic.js +21 -0
- package/dist/components/data/sparklineLogic.d.ts +28 -0
- package/dist/components/data/sparklineLogic.js +18 -0
- package/dist/components/display/KapiStat.d.ts +1 -1
- package/dist/components/inputs/KapiDatePicker.d.ts +8 -2
- package/dist/components/inputs/KapiDatePicker.js +120 -106
- package/dist/components/inputs/KapiDateRangePicker.d.ts +26 -5
- package/dist/components/inputs/KapiDateRangePicker.js +146 -111
- package/dist/components/inputs/KapiFacetedSearch.d.ts +9 -2
- package/dist/components/inputs/KapiFacetedSearch.js +3 -3
- package/dist/components/inputs/KapiSearchChip.d.ts +79 -0
- package/dist/components/inputs/KapiSearchChip.js +73 -0
- package/dist/components/inputs/datePickerLogic.d.ts +9 -0
- package/dist/components/inputs/datePickerLogic.js +25 -25
- package/dist/components/inputs/dateRangeLogic.d.ts +23 -4
- package/dist/components/inputs/dateRangeLogic.js +48 -22
- package/dist/components/inputs/facetedSearchLogic.d.ts +1 -1
- package/dist/components/inputs/index.d.ts +2 -0
- package/dist/components/inputs/searchChipLogic.d.ts +33 -0
- package/dist/components/inputs/searchChipLogic.js +13 -0
- package/dist/components/labelsLogic.d.ts +11 -1
- package/dist/components/layout/KapiContextSlot.js +108 -88
- package/dist/components/layout/KapiMasonry.d.ts +30 -0
- package/dist/components/layout/KapiMasonry.js +33 -0
- package/dist/components/layout/KapiPageHeader.js +89 -71
- package/dist/components/layout/KapiRail.d.ts +8 -2
- package/dist/components/layout/KapiRail.js +118 -67
- package/dist/components/layout/KapiShell.js +67 -37
- package/dist/components/layout/index.d.ts +2 -0
- package/dist/components/layout/masonryLogic.d.ts +40 -0
- package/dist/components/layout/masonryLogic.js +8 -0
- package/dist/components/layout/railLogic.d.ts +41 -1
- package/dist/components/layout/railLogic.js +36 -4
- package/dist/components/layout/reopenBus.d.ts +53 -0
- package/dist/components/layout/reopenBus.js +6 -0
- package/dist/components/layout/useMasonrySpans.d.ts +32 -0
- package/dist/components/layout/useMasonrySpans.js +44 -0
- package/dist/components/layout/useRailOverflow.d.ts +17 -0
- package/dist/components/layout/useRailOverflow.js +41 -0
- package/dist/components/locale/labelRegistry.d.ts +12 -1
- package/dist/components/navigation/KapiFilterChips.js +1 -1
- package/dist/components/navigation/filterChipsLogic.d.ts +7 -1
- package/dist/components/navigation/filterChipsLogic.js +3 -3
- package/dist/components/overlays/KapiConfirm.d.ts +14 -2
- package/dist/components/overlays/KapiConfirm.js +2 -2
- package/dist/components/overlays/KapiContextMenu.d.ts +3 -0
- package/dist/components/overlays/KapiContextMenu.js +2 -1
- package/dist/components/overlays/KapiDropdown.d.ts +3 -1
- package/dist/components/overlays/KapiDropdown.js +29 -26
- package/dist/components/overlays/KapiMenuButton.js +1 -0
- package/dist/components/overlays/KapiOffcanvasStack.d.ts +2 -2
- package/dist/hooks/breakpointOpenLogic.d.ts +20 -5
- package/dist/hooks/breakpointOpenLogic.js +2 -2
- package/dist/hooks/dataColorLogic.d.ts +23 -0
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/numberFormatLogic.d.ts +7 -0
- package/dist/hooks/numberFormatLogic.js +5 -2
- package/dist/hooks/seriesPaletteLogic.d.ts +24 -0
- package/dist/hooks/themeContrastLogic.js +1 -0
- package/dist/hooks/themeDeriveLogic.d.ts +8 -0
- package/dist/hooks/themeDeriveLogic.js +4 -2
- package/dist/hooks/useKapiTheme.js +27 -27
- package/dist/hooks/useMediaQuery.d.ts +7 -0
- package/dist/hooks/useMediaQuery.js +4 -4
- package/dist/index.js +149 -137
- package/dist/kapi.css +1 -1
- package/dist/kapi.layered.css +1 -1
- package/package.json +2 -6
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useLabels as e } from "../locale/KapiLocaleProvider.js";
|
|
3
|
+
import { formatDataValue as t } from "../../hooks/numberFormatLogic.js";
|
|
4
|
+
import { KapiTooltip as n } from "../overlays/KapiTooltip.js";
|
|
5
|
+
import { KapiSegmented as r } from "../inputs/KapiSegmented.js";
|
|
6
|
+
import { useChartTitleId as i, useChartView as a } from "./chartFrame.js";
|
|
7
|
+
import { heatLegendRanges as o, heatMax as s, heatStep as c } from "./heatmapLogic.js";
|
|
8
|
+
/* empty css */
|
|
9
|
+
import { Fragment as l, jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
10
|
+
import { Fragment as f } from "react";
|
|
11
|
+
//#region src/components/data/KapiHeatmap.tsx
|
|
12
|
+
var p = {
|
|
13
|
+
chartView: "Mapa",
|
|
14
|
+
tableView: "Tabla",
|
|
15
|
+
view: "Vista de los datos",
|
|
16
|
+
rowHeader: "Fila",
|
|
17
|
+
empty: "Sin datos para mostrar",
|
|
18
|
+
noData: "sin dato",
|
|
19
|
+
legend: "Intensidad",
|
|
20
|
+
summary: "Mapa de calor de {rows} filas por {columns} columnas. Cambiá a la vista de tabla para leer los valores."
|
|
21
|
+
}, m = (e) => ({ "--kapi-chart-slot": e > 0 ? `var(--kapi-seq-${e})` : "transparent" });
|
|
22
|
+
function h({ rows: h, columns: g, values: _, title: v, max: y, view: b, defaultView: x = "chart", onViewChange: S, labels: C, className: w, ref: T, ...E }) {
|
|
23
|
+
let D = e("heatmap", p, C), O = i(), { current: k, setView: A } = a(b, x, S), j = y !== void 0 && y > 0 ? y : s(_), M = h.length === 0 || g.length === 0, N = (e, t) => _[e]?.[t], P = D.summary.replace("{rows}", String(h.length)).replace("{columns}", String(g.length));
|
|
24
|
+
return /* @__PURE__ */ d("div", {
|
|
25
|
+
...E,
|
|
26
|
+
ref: T,
|
|
27
|
+
className: ["kapi-heatmap", w].filter(Boolean).join(" "),
|
|
28
|
+
role: "group",
|
|
29
|
+
...v ? { "aria-labelledby": O } : {},
|
|
30
|
+
children: [/* @__PURE__ */ d("div", {
|
|
31
|
+
className: "kapi-heatmap__head",
|
|
32
|
+
children: [v ? /* @__PURE__ */ u("div", {
|
|
33
|
+
className: "kapi-heatmap__title",
|
|
34
|
+
id: O,
|
|
35
|
+
children: v
|
|
36
|
+
}) : null, /* @__PURE__ */ u(r, {
|
|
37
|
+
"aria-label": D.view,
|
|
38
|
+
items: [{
|
|
39
|
+
id: "chart",
|
|
40
|
+
label: D.chartView
|
|
41
|
+
}, {
|
|
42
|
+
id: "table",
|
|
43
|
+
label: D.tableView
|
|
44
|
+
}],
|
|
45
|
+
value: k,
|
|
46
|
+
onChange: A
|
|
47
|
+
})]
|
|
48
|
+
}), M ? /* @__PURE__ */ u("p", {
|
|
49
|
+
className: "kapi-heatmap__empty kapi-muted",
|
|
50
|
+
children: D.empty
|
|
51
|
+
}) : k === "table" ? /* @__PURE__ */ u("div", {
|
|
52
|
+
className: "kapi-heatmap__tablewrap",
|
|
53
|
+
children: /* @__PURE__ */ d("table", {
|
|
54
|
+
className: "kapi-heatmap__table",
|
|
55
|
+
children: [/* @__PURE__ */ u("thead", { children: /* @__PURE__ */ d("tr", { children: [/* @__PURE__ */ u("th", {
|
|
56
|
+
scope: "col",
|
|
57
|
+
children: D.rowHeader
|
|
58
|
+
}), g.map((e, t) => /* @__PURE__ */ u("th", {
|
|
59
|
+
scope: "col",
|
|
60
|
+
children: e
|
|
61
|
+
}, `${e}-${t}`))] }) }), /* @__PURE__ */ u("tbody", { children: h.map((e, n) => /* @__PURE__ */ d("tr", { children: [/* @__PURE__ */ u("th", {
|
|
62
|
+
scope: "row",
|
|
63
|
+
children: e
|
|
64
|
+
}), g.map((e, r) => {
|
|
65
|
+
let i = N(n, r);
|
|
66
|
+
return /* @__PURE__ */ u("td", { children: i === void 0 || !Number.isFinite(i) ? /* @__PURE__ */ u("span", {
|
|
67
|
+
className: "kapi-muted",
|
|
68
|
+
children: D.noData
|
|
69
|
+
}) : t(i) }, `${e}-${r}`);
|
|
70
|
+
})] }, `${e}-${n}`)) })]
|
|
71
|
+
})
|
|
72
|
+
}) : /* @__PURE__ */ d(l, { children: [/* @__PURE__ */ u("div", {
|
|
73
|
+
className: "kapi-heatmap__plot",
|
|
74
|
+
role: "img",
|
|
75
|
+
"aria-label": P,
|
|
76
|
+
children: /* @__PURE__ */ d("div", {
|
|
77
|
+
className: "kapi-heatmap__grid",
|
|
78
|
+
style: { "--kapi-heatmap-cols": g.length },
|
|
79
|
+
children: [
|
|
80
|
+
/* @__PURE__ */ u("span", { className: "kapi-heatmap__corner" }),
|
|
81
|
+
g.map((e, t) => /* @__PURE__ */ u("span", {
|
|
82
|
+
className: "kapi-heatmap__colhead",
|
|
83
|
+
children: e
|
|
84
|
+
}, `col-${e}-${t}`)),
|
|
85
|
+
h.map((e, r) => /* @__PURE__ */ d(f, { children: [/* @__PURE__ */ u("span", {
|
|
86
|
+
className: "kapi-heatmap__rowhead",
|
|
87
|
+
children: e
|
|
88
|
+
}), g.map((i, a) => {
|
|
89
|
+
let o = N(r, a), s = o === void 0 ? 0 : c(o, j), l = o === void 0 || !Number.isFinite(o) ? D.noData : t(o);
|
|
90
|
+
return /* @__PURE__ */ u(n, {
|
|
91
|
+
label: `${e} · ${i}: ${l}`,
|
|
92
|
+
className: "kapi-heatmap__cellwrap",
|
|
93
|
+
children: /* @__PURE__ */ u("span", {
|
|
94
|
+
className: `kapi-heatmap__cell${s === 0 ? " kapi-heatmap__cell--empty" : ""}`,
|
|
95
|
+
style: m(s)
|
|
96
|
+
})
|
|
97
|
+
}, `cell-${i}-${a}`);
|
|
98
|
+
})] }, `row-${e}-${r}`))
|
|
99
|
+
]
|
|
100
|
+
})
|
|
101
|
+
}), /* @__PURE__ */ u("ul", {
|
|
102
|
+
className: "kapi-heatmap__legend",
|
|
103
|
+
"aria-label": D.legend,
|
|
104
|
+
children: o(j).map(([e, n], r) => /* @__PURE__ */ d("li", {
|
|
105
|
+
className: "kapi-heatmap__legenditem",
|
|
106
|
+
children: [
|
|
107
|
+
/* @__PURE__ */ u("span", {
|
|
108
|
+
className: "kapi-heatmap__swatch",
|
|
109
|
+
style: m(r + 1)
|
|
110
|
+
}),
|
|
111
|
+
t(Math.round(e)),
|
|
112
|
+
"–",
|
|
113
|
+
t(Math.round(n))
|
|
114
|
+
]
|
|
115
|
+
}, e))
|
|
116
|
+
})] })]
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
//#endregion
|
|
120
|
+
export { p as DEFAULT_HEATMAP_LABELS, h as KapiHeatmap };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { type HTMLAttributes, type ReactNode, type Ref } from "react";
|
|
2
|
+
import type { KapiLabelsOverride } from "../labelsLogic";
|
|
3
|
+
import { type KapiChartLabels, type KapiChartUnit, type KapiChartView } from "./chartFrame";
|
|
4
|
+
import "./KapiLineChart.css";
|
|
5
|
+
/** Una serie de la línea: un valor por categoría, en el mismo orden que `categories`. */
|
|
6
|
+
export type KapiLineChartSeries = {
|
|
7
|
+
/** Id estable de la serie; clave de React y de la fila en la tabla. */
|
|
8
|
+
id: string;
|
|
9
|
+
/** Nombre en la leyenda, en la tabla y en la etiqueta del extremo. */
|
|
10
|
+
label: string;
|
|
11
|
+
/** Un valor por categoría. Lo que falte queda en cero; lo que sobre se ignora. */
|
|
12
|
+
values: readonly number[];
|
|
13
|
+
};
|
|
14
|
+
export type KapiLineChartProps = Omit<HTMLAttributes<HTMLDivElement>, "title" | "children"> & {
|
|
15
|
+
/** Etiquetas del eje horizontal, en orden. Normalmente tiempo. */
|
|
16
|
+
categories: readonly string[];
|
|
17
|
+
/** Series a dibujar. El color sale del slot N de la paleta de datos, en orden y sin ciclar. */
|
|
18
|
+
series: readonly KapiLineChartSeries[];
|
|
19
|
+
/** Título visible. Sin título hay que pasar `aria-label`. */
|
|
20
|
+
title?: ReactNode;
|
|
21
|
+
/** Pasos del eje vertical sobre el cero. @default 4 */
|
|
22
|
+
tickCount?: number;
|
|
23
|
+
/**
|
|
24
|
+
* Rellena el área bajo la línea. **Sólo con una serie**: dos áreas superpuestas se tapan y
|
|
25
|
+
* dejan de poder compararse, así que con más de una se ignora y quedan las líneas.
|
|
26
|
+
* @default false
|
|
27
|
+
*/
|
|
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;
|
|
38
|
+
/** Vista mostrada, si la controla el consumidor. */
|
|
39
|
+
view?: KapiChartView;
|
|
40
|
+
/** Vista inicial cuando el componente la maneja solo. @default "chart" */
|
|
41
|
+
defaultView?: KapiChartView;
|
|
42
|
+
/** Avisa que se cambió de vista. */
|
|
43
|
+
onViewChange?: (view: KapiChartView) => void;
|
|
44
|
+
/** Textos propios; pisan al provider y a los defaults. */
|
|
45
|
+
labels?: KapiLabelsOverride<KapiChartLabels>;
|
|
46
|
+
/** Ref al contenedor. */
|
|
47
|
+
ref?: Ref<HTMLDivElement>;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Gráfico de líneas, para tendencia en el tiempo.
|
|
51
|
+
*
|
|
52
|
+
* Los trazos van en un SVG con `viewBox` de 0 a 100 y `preserveAspectRatio="none"`, así se
|
|
53
|
+
* estiran a cualquier caja sin medirla; el ancho del trazo lo salva `vector-effect`. Todo lo que
|
|
54
|
+
* tiene forma propia —los puntos y cada texto— es HTML posicionado en porcentajes, porque dentro
|
|
55
|
+
* de ese SVG un círculo saldría ovalado y la tipografía deformada.
|
|
56
|
+
*
|
|
57
|
+
* Igual que las barras: la vista de tabla no es opcional, y el plot es `role="img"`.
|
|
58
|
+
*/
|
|
59
|
+
export declare function KapiLineChart({ categories, series, title, tickCount, area, unit, view, defaultView, onViewChange, labels, className, ref, ...rest }: KapiLineChartProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { formatDataValue as e } from "../../hooks/numberFormatLogic.js";
|
|
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, 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
|
+
/* empty css */
|
|
8
|
+
import { jsx as g, jsxs as _ } from "react/jsx-runtime";
|
|
9
|
+
import "react";
|
|
10
|
+
//#region src/components/data/KapiLineChart.tsx
|
|
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
|
+
className: [
|
|
20
|
+
"kapi-linechart",
|
|
21
|
+
U && "kapi-linechart--endlabels",
|
|
22
|
+
k
|
|
23
|
+
].filter(Boolean).join(" "),
|
|
24
|
+
role: "group",
|
|
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,
|
|
36
|
+
block: "kapi-linechart",
|
|
37
|
+
children: /* @__PURE__ */ _("div", {
|
|
38
|
+
className: "kapi-linechart__plot",
|
|
39
|
+
role: "img",
|
|
40
|
+
"aria-label": W,
|
|
41
|
+
children: [
|
|
42
|
+
/* @__PURE__ */ g("div", {
|
|
43
|
+
className: "kapi-linechart__axis",
|
|
44
|
+
children: B.map((e) => /* @__PURE__ */ g("div", {
|
|
45
|
+
className: "kapi-linechart__tick",
|
|
46
|
+
style: i({ y: l(e, z) }),
|
|
47
|
+
children: /* @__PURE__ */ g("span", {
|
|
48
|
+
className: "kapi-linechart__ticklabel",
|
|
49
|
+
children: c(d(e), w)
|
|
50
|
+
})
|
|
51
|
+
}, e))
|
|
52
|
+
}),
|
|
53
|
+
/* @__PURE__ */ _("div", {
|
|
54
|
+
className: "kapi-linechart__canvas",
|
|
55
|
+
children: [
|
|
56
|
+
/* @__PURE__ */ _("svg", {
|
|
57
|
+
className: "kapi-linechart__svg",
|
|
58
|
+
viewBox: "0 0 100 100",
|
|
59
|
+
preserveAspectRatio: "none",
|
|
60
|
+
"aria-hidden": "true",
|
|
61
|
+
focusable: "false",
|
|
62
|
+
children: [I.map((e, t) => H ? /* @__PURE__ */ g("path", {
|
|
63
|
+
className: "kapi-linechart__area",
|
|
64
|
+
d: f(V[t]),
|
|
65
|
+
style: i({ slot: t })
|
|
66
|
+
}, `${e.id}-area`) : null), I.map((e, t) => /* @__PURE__ */ g("path", {
|
|
67
|
+
className: "kapi-linechart__line",
|
|
68
|
+
d: m(V[t]),
|
|
69
|
+
style: i({ slot: t }),
|
|
70
|
+
vectorEffect: "non-scaling-stroke"
|
|
71
|
+
}, e.id))]
|
|
72
|
+
}),
|
|
73
|
+
I.map((n, r) => V[r].map((a, o) => /* @__PURE__ */ g(t, {
|
|
74
|
+
label: `${n.label} · ${y[o] ?? ""}: ${c(e(a.value), w)}`,
|
|
75
|
+
className: "kapi-linechart__dotwrap",
|
|
76
|
+
style: i({
|
|
77
|
+
slot: r,
|
|
78
|
+
x: a.x,
|
|
79
|
+
y: a.y
|
|
80
|
+
}),
|
|
81
|
+
children: /* @__PURE__ */ g("span", { className: "kapi-linechart__dot" })
|
|
82
|
+
}, `${n.id}-${o}`))),
|
|
83
|
+
U ? I.map((e, t) => {
|
|
84
|
+
let n = p(V[t]);
|
|
85
|
+
return n ? /* @__PURE__ */ g("span", {
|
|
86
|
+
className: "kapi-linechart__endlabel",
|
|
87
|
+
style: i({ y: n.y }),
|
|
88
|
+
children: e.label
|
|
89
|
+
}, `${e.id}-end`) : null;
|
|
90
|
+
}) : null
|
|
91
|
+
]
|
|
92
|
+
}),
|
|
93
|
+
/* @__PURE__ */ g("div", {
|
|
94
|
+
className: "kapi-linechart__cats",
|
|
95
|
+
children: y.map((e, t) => /* @__PURE__ */ g("span", {
|
|
96
|
+
className: "kapi-linechart__cat",
|
|
97
|
+
children: e
|
|
98
|
+
}, `${e}-${t}`))
|
|
99
|
+
})
|
|
100
|
+
]
|
|
101
|
+
})
|
|
102
|
+
})
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
//#endregion
|
|
106
|
+
export { y as KapiLineChart };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type HTMLAttributes, type Ref } from "react";
|
|
2
|
+
import type { KapiLabelsOverride } from "../labelsLogic";
|
|
3
|
+
import { type KapiSparklineLabelParts } from "./sparklineLogic";
|
|
4
|
+
import "./KapiSparkline.css";
|
|
5
|
+
/** Textos del sparkline: sólo su nombre accesible. */
|
|
6
|
+
export type KapiSparklineLabels = KapiSparklineLabelParts;
|
|
7
|
+
export declare const DEFAULT_SPARKLINE_LABELS: KapiSparklineLabels;
|
|
8
|
+
export type KapiSparklineProps = Omit<HTMLAttributes<HTMLSpanElement>, "children" | "slot"> & {
|
|
9
|
+
/** Los valores, en orden. Lo no finito se lee como cero. */
|
|
10
|
+
values: readonly number[];
|
|
11
|
+
/**
|
|
12
|
+
* Slot de la paleta de datos, 1-based, igual que en los otros gráficos. Con `tone` el color
|
|
13
|
+
* sale de un color de estado en vez de la paleta. @default 1
|
|
14
|
+
*/
|
|
15
|
+
slot?: number;
|
|
16
|
+
/**
|
|
17
|
+
* Usa un color de estado en vez de la paleta. Es para cuando la línea **significa** algo —una
|
|
18
|
+
* métrica que empeoró—, no para distinguirla de otra: para eso está `slot`.
|
|
19
|
+
*/
|
|
20
|
+
tone?: "success" | "warning" | "danger" | "info";
|
|
21
|
+
/** Rellena el área bajo la línea. @default false */
|
|
22
|
+
area?: boolean;
|
|
23
|
+
/** Marca el último punto, que es donde se lee «dónde quedó». @default true */
|
|
24
|
+
last?: boolean;
|
|
25
|
+
/** Textos propios; pisan al provider y a los defaults. */
|
|
26
|
+
labels?: KapiLabelsOverride<KapiSparklineLabels>;
|
|
27
|
+
/** Ref al contenedor. */
|
|
28
|
+
ref?: Ref<HTMLSpanElement>;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Línea de tendencia en miniatura, sin ejes ni leyenda, para meter al lado de un número.
|
|
32
|
+
*
|
|
33
|
+
* **Se nombra solo.** Un sparkline no tiene eje ni leyenda, así que su nombre accesible es lo
|
|
34
|
+
* único que un lector de pantalla recibe: se arma del dato («Tendencia: sube, de 820 a 1380») en
|
|
35
|
+
* vez de obligar al consumidor a escribirlo, que es el camino seguro a que quede sin nombre. Se
|
|
36
|
+
* pisa con `aria-label`, o se silencia con `aria-hidden` cuando el texto de al lado ya lo dice.
|
|
37
|
+
*
|
|
38
|
+
* **El eje llega hasta el máximo, sin redondear**: un sparkline no tiene ticks que alinear, y
|
|
39
|
+
* estirar hasta un número redondo sólo achataría la forma, que es lo único que tiene para decir.
|
|
40
|
+
*/
|
|
41
|
+
export declare function KapiSparkline({ values, slot, tone, area, last, labels, className, ref, ...rest }: KapiSparklineProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useLabels as e } from "../locale/KapiLocaleProvider.js";
|
|
3
|
+
import { formatDataValue as t } from "../../hooks/numberFormatLogic.js";
|
|
4
|
+
import { chartVars as n } from "./chartFrame.js";
|
|
5
|
+
import { areaPath as r, linePath as i, linePoints as a } from "./lineChartLogic.js";
|
|
6
|
+
import { sparklineLabel as o, sparklineMax as s } from "./sparklineLogic.js";
|
|
7
|
+
/* empty css */
|
|
8
|
+
import { jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
9
|
+
import "react";
|
|
10
|
+
//#region src/components/data/KapiSparkline.tsx
|
|
11
|
+
var u = {
|
|
12
|
+
trend: "Tendencia",
|
|
13
|
+
up: "sube",
|
|
14
|
+
down: "baja",
|
|
15
|
+
flat: "estable",
|
|
16
|
+
from: "de",
|
|
17
|
+
to: "a"
|
|
18
|
+
};
|
|
19
|
+
function d({ values: d, slot: f = 1, tone: p, area: m = !1, last: h = !0, labels: g, className: _, ref: v, ...y }) {
|
|
20
|
+
let b = e("sparkline", u, g), x = s(d), S = a(d, x), C = S[S.length - 1], w = n({ slot: Math.max(1, Math.floor(f)) - 1 }), T = p ? `var(--kapi-${p})` : w["--kapi-chart-slot"];
|
|
21
|
+
return /* @__PURE__ */ l("span", {
|
|
22
|
+
...y,
|
|
23
|
+
ref: v,
|
|
24
|
+
className: ["kapi-sparkline", _].filter(Boolean).join(" "),
|
|
25
|
+
role: "img",
|
|
26
|
+
"aria-label": y["aria-label"] ?? o(d, b, t),
|
|
27
|
+
style: {
|
|
28
|
+
"--kapi-chart-slot": T,
|
|
29
|
+
...y.style
|
|
30
|
+
},
|
|
31
|
+
children: [/* @__PURE__ */ l("svg", {
|
|
32
|
+
className: "kapi-sparkline__svg",
|
|
33
|
+
viewBox: "0 0 100 100",
|
|
34
|
+
preserveAspectRatio: "none",
|
|
35
|
+
"aria-hidden": "true",
|
|
36
|
+
focusable: "false",
|
|
37
|
+
children: [m ? /* @__PURE__ */ c("path", {
|
|
38
|
+
className: "kapi-sparkline__area",
|
|
39
|
+
d: r(S)
|
|
40
|
+
}) : null, /* @__PURE__ */ c("path", {
|
|
41
|
+
className: "kapi-sparkline__line",
|
|
42
|
+
d: i(S),
|
|
43
|
+
vectorEffect: "non-scaling-stroke"
|
|
44
|
+
})]
|
|
45
|
+
}), h && C ? /* @__PURE__ */ c("span", {
|
|
46
|
+
className: "kapi-sparkline__last",
|
|
47
|
+
style: n({
|
|
48
|
+
x: C.x,
|
|
49
|
+
y: C.y
|
|
50
|
+
})
|
|
51
|
+
}) : null]
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
55
|
+
export { u as DEFAULT_SPARKLINE_LABELS, d as KapiSparkline };
|
|
@@ -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
|
-
|
|
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
|
|
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;
|