@kapiuara/ui 0.10.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.
- package/README.md +10 -5
- package/dist/components/data/KapiBarChart.d.ts +84 -0
- package/dist/components/data/KapiBarChart.js +87 -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 +50 -0
- package/dist/components/data/KapiLineChart.js +105 -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.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 +96 -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 +19 -0
- 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/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/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 +10 -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/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 +125 -114
- package/dist/kapi.css +1 -1
- package/dist/kapi.layered.css +1 -1
- package/package.json +2 -6
package/README.md
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
# @kapiuara/ui
|
|
2
2
|
|
|
3
|
-
Design system
|
|
3
|
+
Design system para aplicaciones de gestión. React 19 + TypeScript + Vite.
|
|
4
4
|
CSS nativo propio scopeado bajo `.kapi` (tokens como custom properties). Sin Radix / Bootstrap /
|
|
5
5
|
Tailwind / Mantine. Iconos: sólo `lucide-react`. Fuente: Nunito.
|
|
6
6
|
|
|
7
|
-
>
|
|
8
|
-
> `dist`. Ver `BRANDING.md` en la raíz del repo.
|
|
7
|
+
> Paquete público. El tarball lleva sólo `dist`: ni el demo ni el código fuente se publican.
|
|
9
8
|
>
|
|
10
9
|
> ```sh
|
|
11
10
|
> pnpm add @kapiuara/ui react react-dom lucide-react
|
|
@@ -218,8 +217,14 @@ import "@kapiuara/ui/styles.css"; // + importá la fuente: @fontsourc
|
|
|
218
217
|
- `KapiRail` es presentacional: la app le pasa `activeId` + `onSelect` (deriva el activo de su router). `footer` para cuenta/tema.
|
|
219
218
|
- Zonas fijas del rail: `brand` (arriba) y `footer` (abajo) no se mueven nunca. Cada ítem decide con `pinned`:
|
|
220
219
|
`"start"` lo fija arriba bajo la marca, `"end"` abajo sobre el footer, y sin `pinned` va a la zona del medio, la
|
|
221
|
-
única que scrollea cuando no entra en el alto
|
|
222
|
-
|
|
220
|
+
única que scrollea cuando no entra en el alto. Los divisores (`{ separator: true, pinned }`) siguen la misma regla.
|
|
221
|
+
- **En celular el rail es una barra inferior y la zona del medio NO scrollea: los destinos que no entran van a
|
|
222
|
+
un «Más».** Cuántos se ven se **mide** (el ancho de ítem es el piso táctil `--kapi-tap`): a 320px entran 2 y
|
|
223
|
+
el «Más», a 375px 3, a 390px 4, a 430px 5; arriba de 768px el rail vuelve a ser vertical y no esconde nada.
|
|
224
|
+
Es intrínseco, no hay prop para apagarlo: scrollear de costado en 235px no tiene affordance y ninguna barra
|
|
225
|
+
inferior nativa lo hace. Las zonas fijas y el `footer` no se tocan. El «Más» abre hacia arriba, marca el
|
|
226
|
+
destino activo en el menú y, si el activo quedó adentro, lo dice en su nombre accesible; si algún escondido
|
|
227
|
+
tiene aviso, muestra un punto. El texto sale de `labels.more` y `labels.moreCurrent`.
|
|
223
228
|
|
|
224
229
|
```tsx
|
|
225
230
|
<KapiRail
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { type HTMLAttributes, type ReactNode, type Ref } from "react";
|
|
2
|
+
import type { KapiLabelsOverride } from "../labelsLogic";
|
|
3
|
+
import { type KapiChartLabels, type KapiChartView } from "./chartFrame";
|
|
4
|
+
import { type KapiBarSort, type KapiBarValueLabels } from "./barChartLogic";
|
|
5
|
+
import "./KapiBarChart.css";
|
|
6
|
+
/** Una serie del gráfico: un valor por categoría, en el mismo orden que `categories`. */
|
|
7
|
+
export type KapiBarChartSeries = {
|
|
8
|
+
/** Id estable de la serie; es la clave de React y el id de la fila en la tabla. */
|
|
9
|
+
id: string;
|
|
10
|
+
/** Nombre que se muestra en la leyenda y en la tabla. */
|
|
11
|
+
label: string;
|
|
12
|
+
/**
|
|
13
|
+
* Un valor por categoría. Si faltan valores, esas categorías quedan en cero; si sobran, se
|
|
14
|
+
* ignoran. Un negativo se lee como cero: este gráfico ancla en cero y no tiene dirección
|
|
15
|
+
* hacia abajo.
|
|
16
|
+
*/
|
|
17
|
+
values: readonly number[];
|
|
18
|
+
};
|
|
19
|
+
export type KapiBarChartProps = Omit<HTMLAttributes<HTMLDivElement>, "title" | "children"> & {
|
|
20
|
+
/** Etiquetas del eje horizontal: una por grupo de barras. */
|
|
21
|
+
categories: readonly string[];
|
|
22
|
+
/** Series a dibujar. El color sale del slot N de la paleta de datos, en orden y sin ciclar. */
|
|
23
|
+
series: readonly KapiBarChartSeries[];
|
|
24
|
+
/**
|
|
25
|
+
* Título visible. Sin título hay que pasar `aria-label`: un gráfico sin nombre no se puede
|
|
26
|
+
* anunciar ni encontrar.
|
|
27
|
+
*/
|
|
28
|
+
title?: ReactNode;
|
|
29
|
+
/** Pasos del eje vertical sobre el cero. @default 4 */
|
|
30
|
+
tickCount?: number;
|
|
31
|
+
/**
|
|
32
|
+
* Dibuja las barras acostadas, de izquierda a derecha, con las categorías en el eje vertical.
|
|
33
|
+
* Es la forma de comparar partes cuando los nombres son largos o hay muchas: en vertical las
|
|
34
|
+
* etiquetas se amontonan o se rotan, y una etiqueta rotada no se lee. @default false
|
|
35
|
+
*/
|
|
36
|
+
horizontal?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Ordena las categorías por su total antes de dibujarlas. Ordenado de mayor a menor es lo que
|
|
39
|
+
* hace legible una comparación: el ojo lee el ranking sin contar.
|
|
40
|
+
*
|
|
41
|
+
* El default es no tocar el orden, y es a propósito: cuando el eje significa algo —meses, pasos
|
|
42
|
+
* de un proceso— reordenar destruye la información. @default "none"
|
|
43
|
+
*/
|
|
44
|
+
sort?: KapiBarSort;
|
|
45
|
+
/**
|
|
46
|
+
* Apila las series dentro de cada categoría en vez de ponerlas una al lado de la otra. Es para
|
|
47
|
+
* ver cómo se reparte un total; para comparar las series entre sí, agrupadas se comparan mejor,
|
|
48
|
+
* porque todas arrancan de la misma base.
|
|
49
|
+
*
|
|
50
|
+
* Apilado el eje llega a la suma más alta, no al mayor valor suelto, y el valor deja de
|
|
51
|
+
* escribirse por defecto: una etiqueta por segmento se pisa con la de arriba y no hay forma de
|
|
52
|
+
* saber si entra sin medir. El número queda en el tooltip y en la tabla. @default false
|
|
53
|
+
*/
|
|
54
|
+
stacked?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Qué barras llevan su valor escrito encima. `auto` las escribe todas mientras sean pocas y
|
|
57
|
+
* arriba de ahí sólo la más alta; `max` siempre sólo la más alta; `none` ninguna, y el número
|
|
58
|
+
* queda en el eje, el tooltip y la tabla. `all` las escribe todas: úsalo con muy pocas barras,
|
|
59
|
+
* porque una etiqueta al lado de cada marca deja de leerse. @default "auto"
|
|
60
|
+
*/
|
|
61
|
+
values?: KapiBarValueLabels;
|
|
62
|
+
/** Vista mostrada, si la controla el consumidor. */
|
|
63
|
+
view?: KapiChartView;
|
|
64
|
+
/** Vista inicial cuando el componente la maneja solo. @default "chart" */
|
|
65
|
+
defaultView?: KapiChartView;
|
|
66
|
+
/** Avisa que se cambió de vista. */
|
|
67
|
+
onViewChange?: (view: KapiChartView) => void;
|
|
68
|
+
/** Textos propios; pisan al provider y a los defaults. */
|
|
69
|
+
labels?: KapiLabelsOverride<KapiChartLabels>;
|
|
70
|
+
/** Ref al contenedor. */
|
|
71
|
+
ref?: Ref<HTMLDivElement>;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Gráfico de barras agrupadas.
|
|
75
|
+
*
|
|
76
|
+
* Trae la vista de tabla incorporada y **no es decorativa**: tres slots de la paleta clara quedan
|
|
77
|
+
* abajo de 3:1 contra la card, así que el color solo no alcanza para leer el gráfico. La tabla es
|
|
78
|
+
* el canal que lo arregla, y por eso el selector de vista está siempre y no se puede sacar.
|
|
79
|
+
*
|
|
80
|
+
* El plot es `role="img"` con un resumen: sus barras son píxeles y los valores viven en la tabla,
|
|
81
|
+
* que es lo que un lector de pantalla recorre. El tooltip de cada barra es para quien ve el
|
|
82
|
+
* gráfico y usa el mouse.
|
|
83
|
+
*/
|
|
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;
|
|
@@ -0,0 +1,87 @@
|
|
|
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 } 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";
|
|
6
|
+
/* empty css */
|
|
7
|
+
import { jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
8
|
+
import "react";
|
|
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,
|
|
18
|
+
className: [
|
|
19
|
+
"kapi-barchart",
|
|
20
|
+
x && "kapi-barchart--horizontal",
|
|
21
|
+
k
|
|
22
|
+
].filter(Boolean).join(" "),
|
|
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,
|
|
34
|
+
block: "kapi-barchart",
|
|
35
|
+
children: /* @__PURE__ */ h("div", {
|
|
36
|
+
className: "kapi-barchart__plot",
|
|
37
|
+
role: "img",
|
|
38
|
+
"aria-label": W,
|
|
39
|
+
children: [/* @__PURE__ */ m("div", {
|
|
40
|
+
className: "kapi-barchart__axis",
|
|
41
|
+
children: H.map((e) => /* @__PURE__ */ m("div", {
|
|
42
|
+
className: "kapi-barchart__tick",
|
|
43
|
+
style: i({ y: l(e, V) }),
|
|
44
|
+
children: /* @__PURE__ */ m("span", {
|
|
45
|
+
className: "kapi-barchart__ticklabel",
|
|
46
|
+
children: f(e)
|
|
47
|
+
})
|
|
48
|
+
}, e))
|
|
49
|
+
}), /* @__PURE__ */ m("div", {
|
|
50
|
+
className: "kapi-barchart__groups",
|
|
51
|
+
children: R.map((n) => {
|
|
52
|
+
let r = _[n];
|
|
53
|
+
return /* @__PURE__ */ h("div", {
|
|
54
|
+
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)}`,
|
|
61
|
+
className: "kapi-barchart__slot",
|
|
62
|
+
style: i({
|
|
63
|
+
slot: o,
|
|
64
|
+
y: l(s, V)
|
|
65
|
+
}),
|
|
66
|
+
children: /* @__PURE__ */ m("div", {
|
|
67
|
+
className: "kapi-barchart__bar",
|
|
68
|
+
children: U(o * _.length + n) ? /* @__PURE__ */ m("span", {
|
|
69
|
+
className: "kapi-barchart__value",
|
|
70
|
+
children: f(s)
|
|
71
|
+
}) : null
|
|
72
|
+
})
|
|
73
|
+
}, a.id);
|
|
74
|
+
})
|
|
75
|
+
}), /* @__PURE__ */ m("div", {
|
|
76
|
+
className: "kapi-barchart__cat",
|
|
77
|
+
children: r
|
|
78
|
+
})]
|
|
79
|
+
}, `${r}-${n}`);
|
|
80
|
+
})
|
|
81
|
+
})]
|
|
82
|
+
})
|
|
83
|
+
})
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
//#endregion
|
|
87
|
+
export { _ as KapiBarChart };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { type HTMLAttributes, type Ref } from "react";
|
|
2
|
+
import type { KapiLabelsOverride } from "../labelsLogic";
|
|
3
|
+
import { type KapiCalendarEvent } from "./eventCalendarLogic";
|
|
4
|
+
import "./KapiEventCalendar.css";
|
|
5
|
+
export type { KapiCalendarEvent };
|
|
6
|
+
/** Qué se está mirando. */
|
|
7
|
+
export type KapiEventCalendarView = "month" | "list" | "year";
|
|
8
|
+
/** Textos propios del calendario de eventos. */
|
|
9
|
+
export type KapiEventCalendarLabels = {
|
|
10
|
+
monthView: string;
|
|
11
|
+
listView: string;
|
|
12
|
+
yearView: string;
|
|
13
|
+
view: string;
|
|
14
|
+
prev: string;
|
|
15
|
+
next: string;
|
|
16
|
+
today: string;
|
|
17
|
+
empty: string;
|
|
18
|
+
/** Cartel de los que no entran en la celda; `{n}` se reemplaza. */
|
|
19
|
+
more: string;
|
|
20
|
+
/** Nombre accesible del popover de «+N»; `{date}` se reemplaza. */
|
|
21
|
+
moreTitle: string;
|
|
22
|
+
/** Cómo se lee un rango en la lista; `{from}` y `{to}` se reemplazan. */
|
|
23
|
+
range: string;
|
|
24
|
+
};
|
|
25
|
+
export declare const DEFAULT_EVENT_CALENDAR_LABELS: KapiEventCalendarLabels;
|
|
26
|
+
export type KapiEventCalendarProps = Omit<HTMLAttributes<HTMLDivElement>, "onSelect"> & {
|
|
27
|
+
/** Lo que hay agendado. Un evento sin `end` dura un día; `end` es INCLUSIVO. */
|
|
28
|
+
events: readonly KapiCalendarEvent[];
|
|
29
|
+
/** Mes visible (cualquier día del mes sirve). Sin esto el componente lo maneja solo. */
|
|
30
|
+
month?: Date | undefined;
|
|
31
|
+
/** Pide cambiar de mes (flechas). Con `month` controlado, es el único modo de navegar. */
|
|
32
|
+
onMonthChange?: ((month: Date) => void) | undefined;
|
|
33
|
+
/** Vista visible, controlada. Con esto, `defaultView` se ignora. */
|
|
34
|
+
view?: KapiEventCalendarView | undefined;
|
|
35
|
+
/** Vista inicial cuando el componente maneja su propia vista. @default "month" */
|
|
36
|
+
defaultView?: KapiEventCalendarView | undefined;
|
|
37
|
+
/** Avisa el cambio de vista. Sirve para que una app recuerde en cuál la dejó cada persona. */
|
|
38
|
+
onViewChange?: ((view: KapiEventCalendarView) => void) | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* Cuántos eventos entran en una celda antes del cartel «+N». Por encima de 3 la fila del mes
|
|
41
|
+
* crece tanto que el mes deja de verse de un vistazo, que es para lo que existe la vista de mes.
|
|
42
|
+
* @default 2
|
|
43
|
+
*/
|
|
44
|
+
maxPerDay?: number | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* Click en un evento. SIN esto los eventos no son botones: un control que no hace nada igual
|
|
47
|
+
* recibe foco y promete algo que no va a pasar.
|
|
48
|
+
*/
|
|
49
|
+
onEventClick?: ((event: KapiCalendarEvent) => void) | undefined;
|
|
50
|
+
/** Reemplaza textos propios (i18n). */
|
|
51
|
+
labels?: KapiLabelsOverride<KapiEventCalendarLabels> | undefined;
|
|
52
|
+
/** Va al contenedor. */
|
|
53
|
+
ref?: Ref<HTMLDivElement> | undefined;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Calendario de eventos: un mes con lo que pasa cada día, y una lista del mismo mes.
|
|
57
|
+
*
|
|
58
|
+
* NO es `KapiCalendar`, que sirve para elegir o mirar una fecha. Este dibuja lo que ocurre EN los
|
|
59
|
+
* días: eventos de uno o varios días, con su color y su click.
|
|
60
|
+
*
|
|
61
|
+
* El color sale de la paleta de datos (`--kapi-series-1..8`, con `slot`), la misma que los
|
|
62
|
+
* gráficos y con el mismo orden fijo. No es coherencia por coherencia: esa paleta tiene un gate
|
|
63
|
+
* que verifica que los pares adyacentes se distingan bajo daltonismo, y «un color por tipo de
|
|
64
|
+
* evento» es exactamente el caso que ese gate cubre. Un evento sin `slot` usa el primario.
|
|
65
|
+
*
|
|
66
|
+
* La vista de lista no es un extra: en un mes cargado, una celda con «+3 más» esconde más de lo
|
|
67
|
+
* que muestra, y en celular la grilla de siete columnas deja de leerse. La lista es el mismo dato
|
|
68
|
+
* en una forma que siempre entra, y es la que recorre un lector de pantalla.
|
|
69
|
+
*/
|
|
70
|
+
export declare const KapiEventCalendar: ({ events, month, onMonthChange, view, defaultView, onViewChange, maxPerDay, onEventClick, labels, className, ref, ...rest }: KapiEventCalendarProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useLabels as e } from "../locale/KapiLocaleProvider.js";
|
|
3
|
+
import { calendarNames as t, monthTitle as n, sameDay as r } from "../inputs/datePickerLogic.js";
|
|
4
|
+
import { joinClasses as i } from "../rootProps.js";
|
|
5
|
+
import { KapiSegmented as a } from "../inputs/KapiSegmented.js";
|
|
6
|
+
import { KapiPopover as o } from "../overlays/KapiPopover.js";
|
|
7
|
+
import { aDia as s, correrMes as c, diasConEventos as l, duracionEnDias as u, eventosDelDia as d, eventosDelMes as f, semanasDelMes as p, visiblesYResto as m } from "./eventCalendarLogic.js";
|
|
8
|
+
/* empty css */
|
|
9
|
+
import { Fragment as h, jsx as g, jsxs as _ } from "react/jsx-runtime";
|
|
10
|
+
import { useRef as v, useState as y } from "react";
|
|
11
|
+
import { ChevronLeft as b, ChevronRight as x } from "lucide-react";
|
|
12
|
+
//#region src/components/data/KapiEventCalendar.tsx
|
|
13
|
+
var S = {
|
|
14
|
+
monthView: "Mes",
|
|
15
|
+
listView: "Lista",
|
|
16
|
+
yearView: "Año",
|
|
17
|
+
view: "Vista del calendario",
|
|
18
|
+
prev: "Mes anterior",
|
|
19
|
+
next: "Mes siguiente",
|
|
20
|
+
today: "Hoy",
|
|
21
|
+
empty: "No hay nada agendado este mes",
|
|
22
|
+
more: "+{n} más",
|
|
23
|
+
moreTitle: "Eventos del {date}",
|
|
24
|
+
range: "del {from} al {to}"
|
|
25
|
+
}, C = (e) => `${e.getDate()}/${e.getMonth() + 1}`, w = ({ events: w, month: T, onMonthChange: E, view: D, defaultView: O = "month", onViewChange: k, maxPerDay: A = 2, onEventClick: j, labels: M, className: N, ref: P, ...F }) => {
|
|
26
|
+
let I = e("eventCalendar", S, M), L = t(), [R, z] = y(() => T ?? /* @__PURE__ */ new Date()), B = T ?? R, V = (e) => {
|
|
27
|
+
T === void 0 && z(e), E?.(e);
|
|
28
|
+
}, [H, U] = y(O), W = D ?? H, G = (e) => {
|
|
29
|
+
D === void 0 && U(e), k?.(e);
|
|
30
|
+
}, [K, q] = y(null), J = v(null), Y = /* @__PURE__ */ new Date(), X = [
|
|
31
|
+
{
|
|
32
|
+
id: "month",
|
|
33
|
+
label: I.monthView
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
id: "list",
|
|
37
|
+
label: I.listView
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
id: "year",
|
|
41
|
+
label: I.yearView
|
|
42
|
+
}
|
|
43
|
+
], Z = (e) => ({ "--kapi-evcal-color": `var(--kapi-series-${e.slot ?? 1})` }), Q = ({ e, lista: t, sigue: n }) => {
|
|
44
|
+
let r = u(e), a = /* @__PURE__ */ _(h, { children: [
|
|
45
|
+
/* @__PURE__ */ g("span", {
|
|
46
|
+
className: "kapi-evcal__dot",
|
|
47
|
+
"aria-hidden": "true"
|
|
48
|
+
}),
|
|
49
|
+
/* @__PURE__ */ g("span", {
|
|
50
|
+
className: "kapi-evcal__ev-title",
|
|
51
|
+
children: e.title
|
|
52
|
+
}),
|
|
53
|
+
t && r > 1 && /* @__PURE__ */ g("span", {
|
|
54
|
+
className: "kapi-evcal__ev-range",
|
|
55
|
+
children: I.range.replace("{from}", C(e.start)).replace("{to}", C(e.end ?? e.start))
|
|
56
|
+
}),
|
|
57
|
+
t && e.detail && /* @__PURE__ */ g("span", {
|
|
58
|
+
className: "kapi-evcal__ev-detail",
|
|
59
|
+
children: e.detail
|
|
60
|
+
})
|
|
61
|
+
] });
|
|
62
|
+
return j ? /* @__PURE__ */ g("button", {
|
|
63
|
+
type: "button",
|
|
64
|
+
className: i("kapi-evcal__ev", t && "kapi-evcal__ev--list", n && "kapi-evcal__ev--sigue"),
|
|
65
|
+
style: Z(e),
|
|
66
|
+
onClick: () => j(e),
|
|
67
|
+
"aria-label": n ? e.title : void 0,
|
|
68
|
+
children: a
|
|
69
|
+
}) : /* @__PURE__ */ g("span", {
|
|
70
|
+
className: i("kapi-evcal__ev", t && "kapi-evcal__ev--list"),
|
|
71
|
+
style: Z(e),
|
|
72
|
+
children: a
|
|
73
|
+
});
|
|
74
|
+
}, $ = f(w, B), ee = l(w, B.getFullYear());
|
|
75
|
+
return /* @__PURE__ */ _("div", {
|
|
76
|
+
...F,
|
|
77
|
+
ref: P,
|
|
78
|
+
className: i("kapi-evcal", N),
|
|
79
|
+
children: [
|
|
80
|
+
/* @__PURE__ */ _("div", {
|
|
81
|
+
className: "kapi-evcal__head",
|
|
82
|
+
children: [/* @__PURE__ */ _("div", {
|
|
83
|
+
className: "kapi-evcal__nav",
|
|
84
|
+
children: [
|
|
85
|
+
/* @__PURE__ */ g("button", {
|
|
86
|
+
type: "button",
|
|
87
|
+
className: "kapi-btn kapi-btn--icon",
|
|
88
|
+
onClick: () => V(c(B, W === "year" ? -12 : -1)),
|
|
89
|
+
"aria-label": I.prev,
|
|
90
|
+
children: /* @__PURE__ */ g(b, {
|
|
91
|
+
size: 16,
|
|
92
|
+
strokeWidth: 2,
|
|
93
|
+
"aria-hidden": "true"
|
|
94
|
+
})
|
|
95
|
+
}),
|
|
96
|
+
/* @__PURE__ */ g("button", {
|
|
97
|
+
type: "button",
|
|
98
|
+
className: "kapi-btn kapi-btn--icon",
|
|
99
|
+
onClick: () => V(c(B, W === "year" ? 12 : 1)),
|
|
100
|
+
"aria-label": I.next,
|
|
101
|
+
children: /* @__PURE__ */ g(x, {
|
|
102
|
+
size: 16,
|
|
103
|
+
strokeWidth: 2,
|
|
104
|
+
"aria-hidden": "true"
|
|
105
|
+
})
|
|
106
|
+
}),
|
|
107
|
+
/* @__PURE__ */ g("h3", {
|
|
108
|
+
className: "kapi-evcal__title",
|
|
109
|
+
"aria-live": "polite",
|
|
110
|
+
children: W === "year" ? String(B.getFullYear()) : n(B, L.months)
|
|
111
|
+
})
|
|
112
|
+
]
|
|
113
|
+
}), /* @__PURE__ */ g(a, {
|
|
114
|
+
items: X,
|
|
115
|
+
value: W,
|
|
116
|
+
onChange: G,
|
|
117
|
+
"aria-label": I.view
|
|
118
|
+
})]
|
|
119
|
+
}),
|
|
120
|
+
W === "month" ? /* @__PURE__ */ _("div", {
|
|
121
|
+
className: "kapi-evcal__grid",
|
|
122
|
+
role: "table",
|
|
123
|
+
"aria-label": n(B, L.months),
|
|
124
|
+
children: [/* @__PURE__ */ g("div", {
|
|
125
|
+
className: "kapi-evcal__row kapi-evcal__row--head",
|
|
126
|
+
role: "row",
|
|
127
|
+
children: L.weekdays.map((e, t) => /* @__PURE__ */ g("div", {
|
|
128
|
+
className: "kapi-evcal__wd",
|
|
129
|
+
role: "columnheader",
|
|
130
|
+
children: /* @__PURE__ */ g("abbr", {
|
|
131
|
+
title: L.weekdayNames[t],
|
|
132
|
+
children: e
|
|
133
|
+
})
|
|
134
|
+
}, e))
|
|
135
|
+
}), p(B).map((e) => /* @__PURE__ */ g("div", {
|
|
136
|
+
className: "kapi-evcal__row",
|
|
137
|
+
role: "row",
|
|
138
|
+
children: e.map((e) => {
|
|
139
|
+
let t = d(w, e.date), { visibles: n, resto: a } = m(t, A), o = e.date.toISOString();
|
|
140
|
+
return /* @__PURE__ */ _("div", {
|
|
141
|
+
role: "cell",
|
|
142
|
+
className: i("kapi-evcal__day", e.out && "is-out", r(e.date, Y) && "is-today"),
|
|
143
|
+
children: [
|
|
144
|
+
/* @__PURE__ */ g("span", {
|
|
145
|
+
className: "kapi-evcal__daynum",
|
|
146
|
+
children: e.day
|
|
147
|
+
}),
|
|
148
|
+
n.map((t) => /* @__PURE__ */ g(Q, {
|
|
149
|
+
e: t,
|
|
150
|
+
sigue: s(t.start) < s(e.date) && e.date.getDay() !== 1
|
|
151
|
+
}, t.id)),
|
|
152
|
+
a > 0 && /* @__PURE__ */ g("button", {
|
|
153
|
+
type: "button",
|
|
154
|
+
className: "kapi-evcal__more",
|
|
155
|
+
onClick: (t) => {
|
|
156
|
+
J.current = t.currentTarget, q(e.date);
|
|
157
|
+
},
|
|
158
|
+
children: I.more.replace("{n}", String(a))
|
|
159
|
+
})
|
|
160
|
+
]
|
|
161
|
+
}, o);
|
|
162
|
+
})
|
|
163
|
+
}, e[0].date.toISOString()))]
|
|
164
|
+
}) : W === "year" ? /* @__PURE__ */ g("div", {
|
|
165
|
+
className: "kapi-evcal__year",
|
|
166
|
+
children: Array.from({ length: 12 }, (e, t) => {
|
|
167
|
+
let n = new Date(B.getFullYear(), t, 1);
|
|
168
|
+
return /* @__PURE__ */ _("div", {
|
|
169
|
+
className: "kapi-evcal__mini",
|
|
170
|
+
children: [/* @__PURE__ */ g("button", {
|
|
171
|
+
type: "button",
|
|
172
|
+
className: "kapi-evcal__mini-title",
|
|
173
|
+
onClick: () => {
|
|
174
|
+
V(n), G("month");
|
|
175
|
+
},
|
|
176
|
+
children: L.months[t]
|
|
177
|
+
}), /* @__PURE__ */ g("div", {
|
|
178
|
+
className: "kapi-evcal__mini-grid",
|
|
179
|
+
children: p(n).flat().map((e) => {
|
|
180
|
+
let t = e.out ? void 0 : ee.get(s(e.date));
|
|
181
|
+
return /* @__PURE__ */ g("span", {
|
|
182
|
+
className: i("kapi-evcal__mini-day", e.out && "is-out", t && "has-events"),
|
|
183
|
+
style: t ? { "--kapi-evcal-color": `var(--kapi-series-${t.slot})` } : void 0,
|
|
184
|
+
children: e.out ? "" : e.day
|
|
185
|
+
}, e.date.toISOString());
|
|
186
|
+
})
|
|
187
|
+
})]
|
|
188
|
+
}, t);
|
|
189
|
+
})
|
|
190
|
+
}) : $.length === 0 ? /* @__PURE__ */ g("p", {
|
|
191
|
+
className: "kapi-evcal__empty kapi-muted",
|
|
192
|
+
children: I.empty
|
|
193
|
+
}) : /* @__PURE__ */ g("ul", {
|
|
194
|
+
className: "kapi-evcal__list",
|
|
195
|
+
children: $.map((e) => /* @__PURE__ */ _("li", {
|
|
196
|
+
className: "kapi-evcal__li",
|
|
197
|
+
children: [/* @__PURE__ */ g("span", {
|
|
198
|
+
className: "kapi-evcal__li-date",
|
|
199
|
+
children: C(e.start)
|
|
200
|
+
}), /* @__PURE__ */ g(Q, {
|
|
201
|
+
e,
|
|
202
|
+
lista: !0
|
|
203
|
+
})]
|
|
204
|
+
}, e.id))
|
|
205
|
+
}),
|
|
206
|
+
K && /* @__PURE__ */ g(o, {
|
|
207
|
+
open: !0,
|
|
208
|
+
anchorRef: J,
|
|
209
|
+
onClose: () => q(null),
|
|
210
|
+
children: /* @__PURE__ */ _("div", {
|
|
211
|
+
className: "kapi-evcal__pop",
|
|
212
|
+
children: [/* @__PURE__ */ g("p", {
|
|
213
|
+
className: "kapi-evcal__pop-title",
|
|
214
|
+
children: I.moreTitle.replace("{date}", C(K))
|
|
215
|
+
}), d(w, K).map((e) => /* @__PURE__ */ g(Q, {
|
|
216
|
+
e,
|
|
217
|
+
lista: !0
|
|
218
|
+
}, e.id))]
|
|
219
|
+
})
|
|
220
|
+
})
|
|
221
|
+
]
|
|
222
|
+
});
|
|
223
|
+
};
|
|
224
|
+
//#endregion
|
|
225
|
+
export { S as DEFAULT_EVENT_CALENDAR_LABELS, w as KapiEventCalendar };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { type HTMLAttributes, type ReactNode, type Ref } from "react";
|
|
2
|
+
import type { KapiLabelsOverride } from "../labelsLogic";
|
|
3
|
+
import { type KapiChartView } from "./chartFrame";
|
|
4
|
+
import "./KapiHeatmap.css";
|
|
5
|
+
/** Textos propios del heatmap. */
|
|
6
|
+
export type KapiHeatmapLabels = {
|
|
7
|
+
/** Opción que muestra el mapa. */
|
|
8
|
+
chartView: string;
|
|
9
|
+
/** Opción que muestra la tabla. */
|
|
10
|
+
tableView: string;
|
|
11
|
+
/** Nombre del selector de vista. */
|
|
12
|
+
view: string;
|
|
13
|
+
/** Encabezado de la primera columna. */
|
|
14
|
+
rowHeader: string;
|
|
15
|
+
/** Qué se dice cuando no hay nada que dibujar. */
|
|
16
|
+
empty: string;
|
|
17
|
+
/** Qué dice una celda sin dato. */
|
|
18
|
+
noData: string;
|
|
19
|
+
/** Rótulo de la leyenda. */
|
|
20
|
+
legend: string;
|
|
21
|
+
/** Resumen para quien no lo ve; `{rows}` y `{columns}` se reemplazan. */
|
|
22
|
+
summary: string;
|
|
23
|
+
};
|
|
24
|
+
export declare const DEFAULT_HEATMAP_LABELS: KapiHeatmapLabels;
|
|
25
|
+
export type KapiHeatmapProps = Omit<HTMLAttributes<HTMLDivElement>, "title" | "children"> & {
|
|
26
|
+
/** Etiquetas de las filas, en orden. */
|
|
27
|
+
rows: readonly string[];
|
|
28
|
+
/** Etiquetas de las columnas, en orden. */
|
|
29
|
+
columns: readonly string[];
|
|
30
|
+
/**
|
|
31
|
+
* Los valores, fila por fila. Lo que falte queda como **sin dato**, que se dibuja distinto de un
|
|
32
|
+
* cero: un cero es información y un hueco no.
|
|
33
|
+
*/
|
|
34
|
+
values: readonly (readonly number[])[];
|
|
35
|
+
/** Título visible. Sin título hay que pasar `aria-label`. */
|
|
36
|
+
title?: ReactNode;
|
|
37
|
+
/**
|
|
38
|
+
* Techo de la escala. Sin esto sale del mayor valor de la grilla; pasarlo sirve para comparar
|
|
39
|
+
* dos mapas entre sí, que con techos distintos no se pueden comparar.
|
|
40
|
+
*/
|
|
41
|
+
max?: number;
|
|
42
|
+
/** Vista mostrada, si la controla el consumidor. */
|
|
43
|
+
view?: KapiChartView;
|
|
44
|
+
/** Vista inicial cuando el componente la maneja solo. @default "chart" */
|
|
45
|
+
defaultView?: KapiChartView;
|
|
46
|
+
/** Avisa que se cambió de vista. */
|
|
47
|
+
onViewChange?: (view: KapiChartView) => void;
|
|
48
|
+
/** Textos propios; pisan al provider y a los defaults. */
|
|
49
|
+
labels?: KapiLabelsOverride<KapiHeatmapLabels>;
|
|
50
|
+
/** Ref al contenedor. */
|
|
51
|
+
ref?: Ref<HTMLDivElement>;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Mapa de calor: magnitud en una grilla de dos dimensiones.
|
|
55
|
+
*
|
|
56
|
+
* Usa la rampa secuencial en **pasos discretos**, no un degradé. Un degradé se ve más fino pero no
|
|
57
|
+
* se puede leer: nadie distingue el 62% del 67%, y su leyenda sería una barra continua que tampoco
|
|
58
|
+
* se lee. Con pasos, la leyenda son cuadritos con su rango y el ojo compara contra ella.
|
|
59
|
+
*
|
|
60
|
+
* Igual que el resto de la familia, la vista de tabla no es opcional y el mapa es `role="img"`.
|
|
61
|
+
*/
|
|
62
|
+
export declare function KapiHeatmap({ rows, columns, values, title, max, view, defaultView, onViewChange, labels, className, ref, ...rest }: KapiHeatmapProps): import("react").JSX.Element;
|