@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.
- package/README.md +29 -11
- 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 +6 -5
- package/dist/components/data/KapiSparkline.d.ts +41 -0
- package/dist/components/data/KapiSparkline.js +55 -0
- package/dist/components/data/KapiTable.d.ts +1 -1
- 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/feedback/KapiBulkBar.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 +136 -58
- 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/pageHeaderLogic.d.ts +25 -0
- package/dist/components/layout/pageHeaderLogic.js +16 -2
- 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 +3 -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 +11 -1
- package/dist/hooks/themeDeriveLogic.js +40 -31
- package/dist/hooks/themeRadiiLogic.d.ts +1 -1
- package/dist/hooks/themeRadiiLogic.js +1 -0
- package/dist/hooks/useKapiTheme.js +27 -27
- package/dist/hooks/useMediaQuery.d.ts +7 -0
- package/dist/hooks/useMediaQuery.js +4 -4
- package/dist/hooks/useWheelZoom.d.ts +30 -0
- package/dist/hooks/useWheelZoom.js +27 -0
- package/dist/hooks/wheelZoomLogic.d.ts +18 -0
- package/dist/hooks/wheelZoomLogic.js +9 -0
- package/dist/index.js +125 -113
- package/dist/kapi.css +1 -1
- package/dist/kapi.layered.css +1 -1
- package/package.json +3 -7
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
type Options = {
|
|
2
|
+
/** Alto (px) de una fila de la grilla: el grano del empaque. */
|
|
3
|
+
rowUnit: number;
|
|
4
|
+
/** Cosas que no cambian el tamaño de un ítem pero sí su cuenta (la separación, la cantidad): fuerzan a medir de nuevo. */
|
|
5
|
+
watch: readonly unknown[];
|
|
6
|
+
};
|
|
7
|
+
type Result = {
|
|
8
|
+
/** Filas que ocupa cada ítem, por índice. Un índice que todavía no se midió vale 1 (`spans[i] ?? 1`). */
|
|
9
|
+
spans: readonly number[];
|
|
10
|
+
/** Si se midió al menos un ítem con alto real. Antes de eso la grilla se comporta como una normal. */
|
|
11
|
+
measured: boolean;
|
|
12
|
+
/** Ref (estable por índice) que registra el elemento de un ítem para medirlo y observarlo. */
|
|
13
|
+
register: (index: number) => (element: HTMLElement | null) => void;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Cuántas filas de la grilla ocupa cada ítem del masonry, medido en el DOM (la cuenta es
|
|
17
|
+
* `masonrySpan`). Mide en el layout effect, antes de pintar, y de nuevo cuando CUALQUIER ítem cambia
|
|
18
|
+
* de tamaño.
|
|
19
|
+
*
|
|
20
|
+
* Se observa cada ítem y no el contenedor, y no es un detalle: cuando entra la webfont o carga una
|
|
21
|
+
* imagen cambia el alto de ESE ítem, pero el contenedor no cambia de tamaño (su ancho lo fija la
|
|
22
|
+
* columna), así que un observer en el contenedor no se entera y el ítem queda mal empacado para
|
|
23
|
+
* siempre. Es una sola instancia de `ResizeObserver` con todos los ítems adentro.
|
|
24
|
+
*
|
|
25
|
+
* La separación vertical es el `margin-bottom` USADO del ítem (el CSS lo iguala al `gap` de la
|
|
26
|
+
* grilla), leído del DOM: así vale cualquier largo CSS (`"1rem"`, `var(--x)`) sin parsearlo acá.
|
|
27
|
+
*
|
|
28
|
+
* Sin `ResizeObserver` se mide una vez y no se reacciona a cambios; sin layout (alto 0) `measured`
|
|
29
|
+
* queda en `false` y cada ítem en `span 1`.
|
|
30
|
+
*/
|
|
31
|
+
export declare const useMasonrySpans: ({ rowUnit, watch }: Options) => Result;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { masonrySpan as e } from "./masonryLogic.js";
|
|
3
|
+
import { useCallback as t, useLayoutEffect as n, useRef as r, useState as i } from "react";
|
|
4
|
+
//#region src/components/layout/useMasonrySpans.ts
|
|
5
|
+
var a = {
|
|
6
|
+
spans: [],
|
|
7
|
+
measured: !1
|
|
8
|
+
}, o = (e, t) => e.measured === t.measured && e.spans.length === t.spans.length && e.spans.every((e, n) => e === t.spans[n]), s = ({ rowUnit: s, watch: c }) => {
|
|
9
|
+
let [l, u] = i(a), d = r(/* @__PURE__ */ new Map()), f = r(null), p = r(/* @__PURE__ */ new Map()), m = t(() => {
|
|
10
|
+
let t = [...d.current.entries()], n = t[0]?.[1], r = n ? Number.parseFloat(getComputedStyle(n).marginBottom) : NaN, i = [], a = !1;
|
|
11
|
+
for (let [n, o] of t) {
|
|
12
|
+
let t = o.getBoundingClientRect().height;
|
|
13
|
+
t > 0 && (a = !0), i[n] = e({
|
|
14
|
+
height: t,
|
|
15
|
+
rowUnit: s,
|
|
16
|
+
gap: r
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
let c = {
|
|
20
|
+
spans: Array.from(i, (e) => e ?? 1),
|
|
21
|
+
measured: a
|
|
22
|
+
};
|
|
23
|
+
u((e) => o(e, c) ? e : c);
|
|
24
|
+
}, [s]), h = t((e) => {
|
|
25
|
+
let t = p.current.get(e);
|
|
26
|
+
return t || (t = (t) => {
|
|
27
|
+
let n = d.current.get(e);
|
|
28
|
+
n && n !== t && f.current?.unobserve(n), t ? (d.current.set(e, t), f.current?.observe(t)) : d.current.delete(e);
|
|
29
|
+
}, p.current.set(e, t)), t;
|
|
30
|
+
}, []);
|
|
31
|
+
return n(() => {
|
|
32
|
+
if (typeof ResizeObserver > "u") return;
|
|
33
|
+
let e = new ResizeObserver(m);
|
|
34
|
+
return f.current = e, d.current.forEach((t) => e.observe(t)), () => {
|
|
35
|
+
e.disconnect(), f.current = null;
|
|
36
|
+
};
|
|
37
|
+
}, [m]), n(m, [m, ...c]), {
|
|
38
|
+
spans: l.spans,
|
|
39
|
+
measured: l.measured,
|
|
40
|
+
register: h
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
//#endregion
|
|
44
|
+
export { s as useMasonrySpans };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type RefObject } from "react";
|
|
2
|
+
type Options = {
|
|
3
|
+
/** Sólo en la barra inferior móvil; en el rail vertical no se esconde nada. */
|
|
4
|
+
enabled: boolean;
|
|
5
|
+
/** Ítems (sin divisores) de la zona del medio. */
|
|
6
|
+
count: number;
|
|
7
|
+
/** Divisores de la zona del medio. */
|
|
8
|
+
separators: number;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Cuántos ítems de la zona del medio entran en la barra inferior, medido en el DOM (la decisión es
|
|
12
|
+
* `railOverflowCounts`). Mide en el layout effect, antes de pintar, y de nuevo cuando la zona cambia de
|
|
13
|
+
* tamaño. `null`: no se midió (o no aplica) y se muestra todo. El ancho de un ítem es su `min-width` (el
|
|
14
|
+
* piso táctil): su ancho real crece para repartir el sobrante y no sirve de medida.
|
|
15
|
+
*/
|
|
16
|
+
export declare const useRailOverflow: (zoneRef: RefObject<HTMLElement | null>, { enabled, count, separators }: Options) => number | null;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { railOverflowCounts as e } from "./railLogic.js";
|
|
3
|
+
import { useCallback as t, useLayoutEffect as n, useRef as r, useState as i } from "react";
|
|
4
|
+
//#region src/components/layout/useRailOverflow.ts
|
|
5
|
+
var a = (e) => Number.parseFloat(e), o = (o, { enabled: s, count: c, separators: l }) => {
|
|
6
|
+
let [u, d] = i(null), f = r(0), p = t(() => {
|
|
7
|
+
let t = o.current;
|
|
8
|
+
if (!t || !s) return;
|
|
9
|
+
let n = getComputedStyle(t), r = a(n.columnGap), i = Number.isFinite(r) ? r : 0, u = t.querySelector(".kapi-rail__sep");
|
|
10
|
+
if (u) {
|
|
11
|
+
let e = getComputedStyle(u), t = (a(e.marginLeft) || 0) + (a(e.marginRight) || 0);
|
|
12
|
+
f.current = u.offsetWidth + t + i;
|
|
13
|
+
}
|
|
14
|
+
let p = t.querySelector(".kapi-rail__item"), { visible: m } = e({
|
|
15
|
+
available: t.clientWidth - (a(n.paddingLeft) || 0) - (a(n.paddingRight) || 0),
|
|
16
|
+
itemWidth: p ? a(getComputedStyle(p).minWidth) : NaN,
|
|
17
|
+
gap: i,
|
|
18
|
+
count: c,
|
|
19
|
+
reserved: l * f.current
|
|
20
|
+
});
|
|
21
|
+
d((e) => e === m ? e : m);
|
|
22
|
+
}, [
|
|
23
|
+
o,
|
|
24
|
+
s,
|
|
25
|
+
c,
|
|
26
|
+
l
|
|
27
|
+
]);
|
|
28
|
+
return n(() => {
|
|
29
|
+
p();
|
|
30
|
+
let e = o.current;
|
|
31
|
+
if (!s || !e || typeof ResizeObserver > "u") return;
|
|
32
|
+
let t = new ResizeObserver(p);
|
|
33
|
+
return t.observe(e), () => t.disconnect();
|
|
34
|
+
}, [
|
|
35
|
+
p,
|
|
36
|
+
o,
|
|
37
|
+
s
|
|
38
|
+
]), s ? u : null;
|
|
39
|
+
};
|
|
40
|
+
//#endregion
|
|
41
|
+
export { o as useRailOverflow };
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import type { KapiLabelsOverride } from "../labelsLogic";
|
|
2
|
+
import type { KapiChartLabels } from "../data/chartFrame";
|
|
3
|
+
import type { KapiEventCalendarLabels } from "../data/KapiEventCalendar";
|
|
4
|
+
import type { KapiHeatmapLabels } from "../data/KapiHeatmap";
|
|
5
|
+
import type { KapiSparklineLabels } from "../data/KapiSparkline";
|
|
2
6
|
import type { KapiTableLabels } from "../data/KapiTable";
|
|
3
7
|
import type { KapiTableFilterLabels } from "../data/KapiTableFilter";
|
|
4
8
|
import type { KapiPaginationLabels } from "../data/KapiPagination";
|
|
@@ -55,7 +59,8 @@ import type { UnsavedGuardLabels } from "../../hooks/useUnsavedGuard";
|
|
|
55
59
|
* Clave → tipo de los textos de cada componente. Es una `interface` a propósito: una app puede
|
|
56
60
|
* sumar sus propias claves por module augmentation (`declare module "@kapiuara/ui" { interface
|
|
57
61
|
* KapiLabelRegistry { … } }`) y usar `useLabels` en sus componentes.
|
|
58
|
-
* `calendar` lo comparten `KapiDatePicker` y `KapiDateRangePicker` (este suma `pickStart`/`pickEnd`
|
|
62
|
+
* `calendar` lo comparten `KapiDatePicker` y `KapiDateRangePicker` (este suma `pickStart`/`pickEnd`
|
|
63
|
+
* y, para los rangos de una sola punta, `openEnd`/`openStart`).
|
|
59
64
|
* `link` lo comparten los enlaces con `newTab` (`KapiPanelGroup`, `KapiContextPanel`, `KapiRail`,
|
|
60
65
|
* `KapiAccessCard`).
|
|
61
66
|
* `canvasForm` y `unsavedGuard` solo se configuran desde el provider (sin prop `labels` propia).
|
|
@@ -67,6 +72,7 @@ export interface KapiLabelRegistry {
|
|
|
67
72
|
bulkBar: KapiBulkBarLabels;
|
|
68
73
|
calendar: KapiDateRangePickerLabels;
|
|
69
74
|
canvasForm: KapiCanvasFormLabels;
|
|
75
|
+
chart: KapiChartLabels;
|
|
70
76
|
chatList: KapiChatListLabels;
|
|
71
77
|
chatThread: KapiChatThreadLabels;
|
|
72
78
|
collapsiblePanel: KapiCollapsiblePanelLabels;
|
|
@@ -85,6 +91,8 @@ export interface KapiLabelRegistry {
|
|
|
85
91
|
fileUpload: KapiFileUploadLabels;
|
|
86
92
|
fileViewer: KapiFileViewerLabels;
|
|
87
93
|
filterChips: KapiFilterChipsLabels;
|
|
94
|
+
heatmap: KapiHeatmapLabels;
|
|
95
|
+
eventCalendar: KapiEventCalendarLabels;
|
|
88
96
|
input: KapiInputLabels;
|
|
89
97
|
link: KapiLinkLabels;
|
|
90
98
|
messageBubble: KapiMessageBubbleLabels;
|
|
@@ -100,6 +108,7 @@ export interface KapiLabelRegistry {
|
|
|
100
108
|
scrollArea: KapiScrollAreaLabels;
|
|
101
109
|
select: KapiSelectLabels;
|
|
102
110
|
shapeSheet: KapiShapeSheetLabels;
|
|
111
|
+
sparkline: KapiSparklineLabels;
|
|
103
112
|
splitModal: KapiSplitModalLabels;
|
|
104
113
|
steps: KapiStepsLabels;
|
|
105
114
|
table: KapiTableLabels;
|
|
@@ -29,7 +29,7 @@ function u({ items: u, value: d, onChange: f, size: p = "md", labels: m, classNa
|
|
|
29
29
|
onClick: () => f(e.id),
|
|
30
30
|
onKeyDown: (e) => x(e, t),
|
|
31
31
|
children: [/* @__PURE__ */ o("span", { children: e.label }), e.count != null && /* @__PURE__ */ o("span", {
|
|
32
|
-
className: "kapi-
|
|
32
|
+
className: "kapi-filterpill__count",
|
|
33
33
|
"aria-hidden": !0,
|
|
34
34
|
children: e.count
|
|
35
35
|
})]
|
|
@@ -8,7 +8,13 @@ export type KapiFilterChipItem<Id extends string = string> = {
|
|
|
8
8
|
/** Color del contador (y del chip activo si no es neutral/primary). */
|
|
9
9
|
tone?: KapiFilterChipTone;
|
|
10
10
|
};
|
|
11
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* Clases de un chip. Pura: es lo que se testea.
|
|
13
|
+
* Emite `kapi-filterpill*`, no `kapi-filterchip*`: esa otra clase es el control de filtro de
|
|
14
|
+
* styles/kapi.css y la usan el disparador de KapiDropdown, los botones de la barra de KapiTable y
|
|
15
|
+
* el buscador de la demo. Mientras la píldora la compartía, le ganaba por orden del bundle y les
|
|
16
|
+
* borraba el aspecto a los tres. Ver el encabezado de KapiFilterChips.css.
|
|
17
|
+
*/
|
|
12
18
|
export declare const filterChipClasses: (item: Pick<KapiFilterChipItem, "tone">, active: boolean, size?: "sm" | "md") => string;
|
|
13
19
|
/** Índice del chip activo para el roving tabindex (0 si `value` no existe). */
|
|
14
20
|
export declare const activeChipIndex: (items: readonly {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
//#region src/components/navigation/filterChipsLogic.ts
|
|
2
2
|
var e = (e, t, n = "md") => [
|
|
3
|
-
"kapi-
|
|
4
|
-
`kapi-
|
|
5
|
-
n !== "md" && `kapi-
|
|
3
|
+
"kapi-filterpill",
|
|
4
|
+
`kapi-filterpill--${e.tone ?? "neutral"}`,
|
|
5
|
+
n !== "md" && `kapi-filterpill--${n}`,
|
|
6
6
|
t && "is-on"
|
|
7
7
|
].filter(Boolean).join(" "), t = (e, t) => Math.max(0, e.findIndex((e) => e.id === t)), n = (e, t, n) => {
|
|
8
8
|
if (t <= 0) return null;
|
|
@@ -16,6 +16,8 @@ export type KapiMenuItem = {
|
|
|
16
16
|
danger?: boolean | undefined;
|
|
17
17
|
/** Atenuado y no ejecutable: anuncia `aria-disabled`, ignora click/Enter y las flechas lo saltean. */
|
|
18
18
|
disabled?: boolean | undefined;
|
|
19
|
+
/** Marca el ítem como el actual (la página o sección donde estás): `aria-current` y un acento visual. */
|
|
20
|
+
current?: boolean | undefined;
|
|
19
21
|
};
|
|
20
22
|
/** `className`/`style`/`id` van al menú (`role="menu"`); la posición calculada gana sobre `style`. */
|
|
21
23
|
export type KapiContextMenuProps = KapiRootProps & {
|
|
@@ -42,6 +44,7 @@ export declare const DEFAULT_CONTEXT_MENU_LABELS: KapiContextMenuLabels;
|
|
|
42
44
|
export declare const menuItemClass: (item: {
|
|
43
45
|
danger?: boolean | undefined;
|
|
44
46
|
disabled?: boolean | undefined;
|
|
47
|
+
current?: boolean | undefined;
|
|
45
48
|
}) => string;
|
|
46
49
|
/**
|
|
47
50
|
* Menú contextual custom. Se abre con doble click derecho (ver
|
|
@@ -9,7 +9,7 @@ import { actionableIndexes as c, estimateMenuHeight as l } from "./menuButtonLog
|
|
|
9
9
|
import { Fragment as u, jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
10
10
|
import { useEffect as p, useLayoutEffect as m, useRef as h } from "react";
|
|
11
11
|
//#region src/components/overlays/KapiContextMenu.tsx
|
|
12
|
-
var g = { menu: "Menú contextual" }, _ = (e) => n("kapi-ctxmenu__item", e.danger && "is-danger", e.disabled && "is-disabled"), v = 210, y = ({ open: e, ...t }) => e ? /* @__PURE__ */ d(b, { ...t }) : null, b = ({ x: y, y: b, items: x, onClose: S, className: C, style: w, id: T, labels: E, "aria-label": D }) => {
|
|
12
|
+
var g = { menu: "Menú contextual" }, _ = (e) => n("kapi-ctxmenu__item", e.danger && "is-danger", e.disabled && "is-disabled", e.current && "is-current"), v = 210, y = ({ open: e, ...t }) => e ? /* @__PURE__ */ d(b, { ...t }) : null, b = ({ x: y, y: b, items: x, onClose: S, className: C, style: w, id: T, labels: E, "aria-label": D }) => {
|
|
13
13
|
let O = e("contextMenu", g, E), k = h(null), A = c(x), j = (e) => {
|
|
14
14
|
k.current?.querySelector(`[data-menu-index="${e}"]`)?.focus();
|
|
15
15
|
};
|
|
@@ -78,6 +78,7 @@ var g = { menu: "Menú contextual" }, _ = (e) => n("kapi-ctxmenu__item", e.dange
|
|
|
78
78
|
tabIndex: -1,
|
|
79
79
|
"data-menu-index": t,
|
|
80
80
|
"aria-disabled": e.disabled ? "true" : void 0,
|
|
81
|
+
"aria-current": e.current ? "true" : void 0,
|
|
81
82
|
className: _(e),
|
|
82
83
|
onClick: () => {
|
|
83
84
|
e.disabled || (e.onClick?.(), S());
|
|
@@ -18,6 +18,8 @@ export type KapiDropdownProps<T extends KapiDropdownOption = KapiDropdownOption>
|
|
|
18
18
|
drop?: KapiDropdownDrop;
|
|
19
19
|
/** Ancho mínimo del menú en px. */
|
|
20
20
|
minWidth?: number;
|
|
21
|
+
/** Deshabilita el control: el chip queda apagado, fuera del orden de tabulación, y el menú no abre. */
|
|
22
|
+
disabled?: boolean;
|
|
21
23
|
};
|
|
22
24
|
/** Clases del menú según hacia dónde abre. Pura y exportada para testear. */
|
|
23
25
|
export declare const dropdownMenuClass: (drop?: KapiDropdownDrop) => string;
|
|
@@ -27,4 +29,4 @@ export declare const dropdownItemClass: (selected: boolean) => string;
|
|
|
27
29
|
* Select liviano (menú simple con la cara del rediseño), ideal para filtros compactos tipo chip.
|
|
28
30
|
* Para selects ricos (búsqueda/multi) usa KapiSelect.
|
|
29
31
|
*/
|
|
30
|
-
export declare const KapiDropdown: <T extends KapiDropdownOption = KapiDropdownOption>({ value, options, onChange, icon, label, drop, minWidth, className, ...rest }: KapiDropdownProps<T>) => import("react").JSX.Element;
|
|
32
|
+
export declare const KapiDropdown: <T extends KapiDropdownOption = KapiDropdownOption>({ value, options, onChange, icon, label, drop, minWidth, disabled, className, ...rest }: KapiDropdownProps<T>) => import("react").JSX.Element;
|
|
@@ -6,34 +6,37 @@ import { Fragment as a, jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
|
6
6
|
import { useEffect as c, useId as l, useRef as u, useState as d } from "react";
|
|
7
7
|
import { Check as f, ChevronDown as p } from "lucide-react";
|
|
8
8
|
//#region src/components/overlays/KapiDropdown.tsx
|
|
9
|
-
var m = (e = "down") => `kapi-menu kapi-dropdown__menu kapi-dropdown__menu--${e}`, h = (e) => `kapi-menu__item${e ? " kapi-menu__item--on" : ""}`, g = ({ value: g, options: _, onChange: v, icon: y, label: b, drop: x = "down", minWidth: S = 170,
|
|
10
|
-
let [
|
|
11
|
-
|
|
12
|
-
},
|
|
13
|
-
|
|
9
|
+
var m = (e = "down") => `kapi-menu kapi-dropdown__menu kapi-dropdown__menu--${e}`, h = (e) => `kapi-menu__item${e ? " kapi-menu__item--on" : ""}`, g = ({ value: g, options: _, onChange: v, icon: y, label: b, drop: x = "down", minWidth: S = 170, disabled: C = !1, className: w, ...T }) => {
|
|
10
|
+
let [E, D] = d(!1), O = l(), k = `${O}-trigger`, A = `${O}-menu`, j = u(null), M = u(null), N = _.map((e, t) => t), P = E && !C, F = (e) => {
|
|
11
|
+
M.current?.querySelector(`[data-menu-index="${e}"]`)?.focus();
|
|
12
|
+
}, I = (e) => {
|
|
13
|
+
D(!1), e && j.current?.focus();
|
|
14
14
|
};
|
|
15
15
|
c(() => {
|
|
16
|
-
|
|
17
|
-
}, [
|
|
18
|
-
|
|
16
|
+
P && F(n(N, _.indexOf(g)));
|
|
17
|
+
}, [P]), c(() => {
|
|
18
|
+
C && D(!1);
|
|
19
|
+
}, [C]);
|
|
20
|
+
let L = (e) => {
|
|
19
21
|
let n = r(e.key);
|
|
20
|
-
n.kind === "move" ? (e.preventDefault(),
|
|
21
|
-
},
|
|
22
|
-
e.key === "ArrowDown" || e.key === "ArrowUp" ? (e.preventDefault(),
|
|
22
|
+
n.kind === "move" ? (e.preventDefault(), F(i(t(document.activeElement), n.dir, N))) : n.kind === "close" && (n.returnFocus && (e.preventDefault(), e.stopPropagation()), I(n.returnFocus));
|
|
23
|
+
}, R = (e) => {
|
|
24
|
+
e.key === "ArrowDown" || e.key === "ArrowUp" ? (e.preventDefault(), D(!0)) : e.key === "Escape" && P && (e.stopPropagation(), I(!0));
|
|
23
25
|
};
|
|
24
26
|
return /* @__PURE__ */ s("div", {
|
|
25
|
-
...
|
|
26
|
-
className: e("kapi-dropdown",
|
|
27
|
+
...T,
|
|
28
|
+
className: e("kapi-dropdown", w),
|
|
27
29
|
children: [/* @__PURE__ */ s("button", {
|
|
28
|
-
ref:
|
|
29
|
-
id:
|
|
30
|
+
ref: j,
|
|
31
|
+
id: k,
|
|
30
32
|
type: "button",
|
|
31
33
|
className: "kapi-filterchip",
|
|
32
|
-
|
|
33
|
-
|
|
34
|
+
disabled: C,
|
|
35
|
+
onClick: () => D((e) => !e),
|
|
36
|
+
onKeyDown: R,
|
|
34
37
|
"aria-haspopup": "listbox",
|
|
35
|
-
"aria-expanded":
|
|
36
|
-
"aria-controls":
|
|
38
|
+
"aria-expanded": P,
|
|
39
|
+
"aria-controls": P ? A : void 0,
|
|
37
40
|
children: [
|
|
38
41
|
y,
|
|
39
42
|
b && /* @__PURE__ */ s("span", {
|
|
@@ -50,17 +53,17 @@ var m = (e = "down") => `kapi-menu kapi-dropdown__menu kapi-dropdown__menu--${e}
|
|
|
50
53
|
color: "var(--kapi-muted-2)"
|
|
51
54
|
})
|
|
52
55
|
]
|
|
53
|
-
}),
|
|
56
|
+
}), P && /* @__PURE__ */ s(a, { children: [/* @__PURE__ */ o("div", {
|
|
54
57
|
className: "kapi-dropdown__backdrop",
|
|
55
|
-
onClick: () =>
|
|
58
|
+
onClick: () => D(!1)
|
|
56
59
|
}), /* @__PURE__ */ o("div", {
|
|
57
60
|
className: m(x),
|
|
58
61
|
style: { minWidth: S },
|
|
59
62
|
role: "listbox",
|
|
60
|
-
id:
|
|
61
|
-
"aria-labelledby":
|
|
62
|
-
ref:
|
|
63
|
-
onKeyDown:
|
|
63
|
+
id: A,
|
|
64
|
+
"aria-labelledby": k,
|
|
65
|
+
ref: M,
|
|
66
|
+
onKeyDown: L,
|
|
64
67
|
children: _.map((e, t) => /* @__PURE__ */ s("button", {
|
|
65
68
|
type: "button",
|
|
66
69
|
role: "option",
|
|
@@ -69,7 +72,7 @@ var m = (e = "down") => `kapi-menu kapi-dropdown__menu kapi-dropdown__menu--${e}
|
|
|
69
72
|
"data-menu-index": t,
|
|
70
73
|
className: h(e === g),
|
|
71
74
|
onClick: () => {
|
|
72
|
-
v(e),
|
|
75
|
+
v(e), I(!0);
|
|
73
76
|
},
|
|
74
77
|
children: [e, e === g && /* @__PURE__ */ o(f, {
|
|
75
78
|
size: 14,
|
|
@@ -96,6 +96,7 @@ var _ = 6, v = ({ label: v, items: y, icon: b, variant: x = "default", "aria-lab
|
|
|
96
96
|
tabIndex: -1,
|
|
97
97
|
"data-menu-index": t,
|
|
98
98
|
"aria-disabled": e.disabled ? "true" : void 0,
|
|
99
|
+
"aria-current": e.current ? "true" : void 0,
|
|
99
100
|
className: o(e),
|
|
100
101
|
onClick: () => {
|
|
101
102
|
e.disabled || (N(!0), e.onClick?.());
|
|
@@ -41,9 +41,9 @@ export type KapiOffcanvasStackControls = {
|
|
|
41
41
|
*
|
|
42
42
|
* const stack = useKapiOffcanvasStack();
|
|
43
43
|
* stack.push({
|
|
44
|
-
* title: "
|
|
44
|
+
* title: "Ficha",
|
|
45
45
|
* content: ({ push }) => (
|
|
46
|
-
* <KapiButton onClick={() => push({ title: "
|
|
46
|
+
* <KapiButton onClick={() => push({ title: "Detalle", width: 420, content: <Detalle /> })}>Ver detalle</KapiButton>
|
|
47
47
|
* )
|
|
48
48
|
* });
|
|
49
49
|
* ```
|
|
@@ -1,7 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
2
|
+
* En qué franja de ancho está la cáscara. Son TRES y no dos, y el motivo es medible: entre el
|
|
3
|
+
* breakpoint móvil y una ventana cómoda, el panel se come un tercio del ancho útil.
|
|
4
|
+
*
|
|
5
|
+
* Con rail (92px) y panel (258px) abiertos, el contenido queda en 930px a 1280, 674 a 1024, 550
|
|
6
|
+
* a 900 y 484 a 834 —un iPad en vertical—. O sea que abajo de 1024 el panel cuesta más de lo que
|
|
7
|
+
* aporta: plegado a su riel de 44px devuelve 214px, un 31% más de ancho para el contenido.
|
|
6
8
|
*/
|
|
7
|
-
export
|
|
9
|
+
export type KapiShellZone = "mobile" | "narrow" | "wide";
|
|
10
|
+
/** La franja, a partir de las dos media queries de la cáscara. */
|
|
11
|
+
export declare const shellZone: (isMobile: boolean, isNarrow: boolean) => KapiShellZone;
|
|
12
|
+
/**
|
|
13
|
+
* Estado abierto/cerrado de un panel lateral al cruzar de franja (lógica pura). Devuelve el nuevo
|
|
14
|
+
* estado, o `null` si no hubo cruce.
|
|
15
|
+
* - a `mobile`: se cierra, porque ahí el panel es un drawer y abierto taparía todo con su backdrop.
|
|
16
|
+
* - a `narrow`: se pliega a su riel, porque el contenido no entra con los dos abiertos.
|
|
17
|
+
* - a `wide`: vuelve al último estado que el usuario tenía donde sí había lugar.
|
|
18
|
+
*
|
|
19
|
+
* Sólo actúa EN EL CRUCE: si alguien abre el panel estando en `narrow`, no se lo volvemos a
|
|
20
|
+
* cerrar. Una ayuda que pelea contra lo que acabás de hacer deja de ser una ayuda.
|
|
21
|
+
*/
|
|
22
|
+
export declare const openOnZoneCross: (antes: KapiShellZone, ahora: KapiShellZone, ultimoEnWide: boolean) => boolean | null;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
//#region src/hooks/breakpointOpenLogic.ts
|
|
2
|
-
var e = (e, t, n) => e === t ? null :
|
|
2
|
+
var e = (e, t) => e ? "mobile" : t ? "narrow" : "wide", t = (e, t, n) => e === t ? null : t === "wide" && n;
|
|
3
3
|
//#endregion
|
|
4
|
-
export { e as
|
|
4
|
+
export { t as openOnZoneCross, e as shellZone };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { KapiRgbColor } from "./colorLogic";
|
|
2
|
+
/** A color in OKLab: `l` 0-1 on the lightness axis, `a`/`b` the opponent axes around 0. */
|
|
3
|
+
export type KapiOklab = {
|
|
4
|
+
/** Perceptual lightness, 0 (black) to 1 (white). */
|
|
5
|
+
l: number;
|
|
6
|
+
/** Green (negative) to red (positive). */
|
|
7
|
+
a: number;
|
|
8
|
+
/** Blue (negative) to yellow (positive). */
|
|
9
|
+
b: number;
|
|
10
|
+
};
|
|
11
|
+
/** The three dichromacies the palette gate simulates. */
|
|
12
|
+
export type KapiCvdKind = "protan" | "deutan" | "tritan";
|
|
13
|
+
/** Converts an sRGB color to OKLab. Alpha is ignored: flatten it over its background first. */
|
|
14
|
+
export declare const toOklab: (color: KapiRgbColor) => KapiOklab;
|
|
15
|
+
/**
|
|
16
|
+
* How a color is seen with one of the three dichromacies, back in sRGB. For a distance use
|
|
17
|
+
* `cvdDeltaE`, which stays in linear space and does not pay the rounding of this round trip.
|
|
18
|
+
*/
|
|
19
|
+
export declare const simulateCvd: (color: KapiRgbColor, kind: KapiCvdKind) => KapiRgbColor;
|
|
20
|
+
/** Euclidean distance in OKLab, ×100: the scale the palette thresholds are written in. */
|
|
21
|
+
export declare const oklabDeltaE: (a: KapiRgbColor, b: KapiRgbColor) => number;
|
|
22
|
+
/** `oklabDeltaE` as seen with one of the three dichromacies. */
|
|
23
|
+
export declare const cvdDeltaE: (a: KapiRgbColor, b: KapiRgbColor, kind: KapiCvdKind) => number;
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -10,7 +10,9 @@ export { useUnsavedGuard, unsavedGuardHandler, DEFAULT_UNSAVED_GUARD_LABELS } fr
|
|
|
10
10
|
export type { BeforeUnloadLike as KapiBeforeUnloadLike, UnsavedGuard as KapiUnsavedGuard, UnsavedGuardDialogProps as KapiUnsavedGuardDialogProps, UnsavedGuardLabels as KapiUnsavedGuardLabels, UnsavedGuardOptions as KapiUnsavedGuardOptions } from "./useUnsavedGuard";
|
|
11
11
|
export { KAPI_ROOT_SELECTOR, resolveKapiRoot, useKapiRoot } from "./kapiRoot";
|
|
12
12
|
export { REDUCED_MOTION_QUERY, prefersReducedMotion } from "./reducedMotion";
|
|
13
|
-
export { SHELL_MOBILE_QUERY, matchesQuery, useMediaQuery } from "./useMediaQuery";
|
|
13
|
+
export { SHELL_MOBILE_QUERY, SHELL_NARROW_QUERY, matchesQuery, useMediaQuery } from "./useMediaQuery";
|
|
14
|
+
export { useWheelZoom } from "./useWheelZoom";
|
|
15
|
+
export type { UseWheelZoomOptions } from "./useWheelZoom";
|
|
14
16
|
export { useHotkey } from "./useHotkey";
|
|
15
17
|
export type { UseHotkeyOptions } from "./useHotkey";
|
|
16
18
|
export { usePersistentState } from "./usePersistentState";
|
|
@@ -4,3 +4,10 @@
|
|
|
4
4
|
* decimals into a badge. `NaN` or infinite → "" (the caller renders nothing rather than "NaN").
|
|
5
5
|
*/
|
|
6
6
|
export declare const formatCount: (value: number, locale?: string) => string;
|
|
7
|
+
/**
|
|
8
|
+
* A data value shown in full, for a table cell or a readout: `1240` → "1240" and `1240000` →
|
|
9
|
+
* "1.240.000", keeping up to three decimals. It is NOT the axis formatter: an axis abbreviates
|
|
10
|
+
* (`1,2 k`) because a label competes for room, while a table is where the exact number is read.
|
|
11
|
+
* `NaN` or infinite → "" (the caller renders nothing rather than "NaN").
|
|
12
|
+
*/
|
|
13
|
+
export declare const formatDataValue: (value: number, locale?: string) => string;
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
var e = /* @__PURE__ */ new Map(), t = (t) => {
|
|
3
3
|
let n = e.get(t);
|
|
4
4
|
return n || (n = new Intl.NumberFormat(t, { maximumFractionDigits: 0 }), e.set(t, n)), n;
|
|
5
|
-
}, n = (e, n = "es") => Number.isFinite(e) ? t(n).format(Math.round(e)) : ""
|
|
5
|
+
}, n = (e, n = "es") => Number.isFinite(e) ? t(n).format(Math.round(e)) : "", r = /* @__PURE__ */ new Map(), i = (e) => {
|
|
6
|
+
let t = r.get(e);
|
|
7
|
+
return t || (t = new Intl.NumberFormat(e, { maximumFractionDigits: 3 }), r.set(e, t)), t;
|
|
8
|
+
}, a = (e, t = "es") => Number.isFinite(e) ? i(t).format(e) : "";
|
|
6
9
|
//#endregion
|
|
7
|
-
export { n as formatCount };
|
|
10
|
+
export { n as formatCount, a as formatDataValue };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { KapiRgbColor } from "./colorLogic";
|
|
2
|
+
/** Which theme a palette is being judged in: each one has its own lightness band. */
|
|
3
|
+
export type KapiPaletteTheme = "light" | "dark";
|
|
4
|
+
/** One rule a palette broke, named so the message can point at the slot. */
|
|
5
|
+
export type KapiPaletteIssue = {
|
|
6
|
+
/** The rule that failed. */
|
|
7
|
+
check: "cvd" | "normal" | "band" | "chroma" | "duplicate" | "monotone" | "step" | "hue";
|
|
8
|
+
/** Human-readable detail: which slots, and by how much. */
|
|
9
|
+
detail: string;
|
|
10
|
+
};
|
|
11
|
+
export declare const PALETTE_CVD_FLOOR = 8;
|
|
12
|
+
export declare const PALETTE_NORMAL_FLOOR = 15;
|
|
13
|
+
export declare const PALETTE_CHROMA_FLOOR = 0.1;
|
|
14
|
+
export declare const PALETTE_BAND: Record<KapiPaletteTheme, readonly [number, number]>;
|
|
15
|
+
export declare const RAMP_MIN_DELTA_L = 0.06;
|
|
16
|
+
export declare const RAMP_MAX_HUE_SPREAD = 30;
|
|
17
|
+
/** The worst of protanopia and deutanopia for one pair: the number the floor applies to. */
|
|
18
|
+
export declare const enforcedCvdDeltaE: (a: KapiRgbColor, b: KapiRgbColor) => number;
|
|
19
|
+
/** Smallest tritanopia ΔE over the adjacent pairs. Informational: it does not fail a palette. */
|
|
20
|
+
export declare const tritanFloor: (colors: readonly KapiRgbColor[]) => number;
|
|
21
|
+
/** Every rule a categorical palette breaks, in slot order. Empty means it passes. */
|
|
22
|
+
export declare const checkSeriesPalette: (colors: readonly KapiRgbColor[], theme: KapiPaletteTheme) => KapiPaletteIssue[];
|
|
23
|
+
/** Every rule a sequential ramp breaks, in step order. Empty means it passes. */
|
|
24
|
+
export declare const checkSequentialRamp: (colors: readonly KapiRgbColor[]) => KapiPaletteIssue[];
|
|
@@ -25,6 +25,7 @@ var n = 4.5, r = [
|
|
|
25
25
|
...e === "primary" ? [] : [[`--kapi-${e}`, `--kapi-${e}-bg`]]
|
|
26
26
|
]),
|
|
27
27
|
...[...a, "neutral"].map((e) => [`--kapi-${e}-fg`, `--kapi-${e}`]),
|
|
28
|
+
["--kapi-primary-ink", "--kapi-primary-bg"],
|
|
28
29
|
["--kapi-neutral", "--kapi-card"],
|
|
29
30
|
["--kapi-tip-fg", "--kapi-tip-bg"]
|
|
30
31
|
], s = (r, i = {}) => {
|
|
@@ -26,6 +26,8 @@ export type KapiThemeColors = {
|
|
|
26
26
|
export type KapiThemeRadii = {
|
|
27
27
|
/** Anchor of the control tier, a px length (`10px`): xs, inner, sm, ctl-sm, md and group (`--kapi-radius-md`). */
|
|
28
28
|
control?: string | undefined;
|
|
29
|
+
/** Anchor of the box tier, a px length (`10px`): check and box, the shape of checkboxes and textareas (`--kapi-radius-box`). */
|
|
30
|
+
box?: string | undefined;
|
|
29
31
|
/** Anchor of the surface tier, a px length (`18px`): lg, xl, the card radius and surfaces (`--kapi-radius-surface`). */
|
|
30
32
|
surface?: string | undefined;
|
|
31
33
|
/** Corner of square fixed-size controls, a percentage or px length, passed as-is (`--kapi-radius-squircle`). */
|
|
@@ -39,8 +41,16 @@ export type KapiCustomTheme = {
|
|
|
39
41
|
colors: KapiThemeColors;
|
|
40
42
|
/** The radius knobs; an unset or invalid one leaves its whole tier at the base theme's values. */
|
|
41
43
|
radii?: KapiThemeRadii | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* The categorical data palette, slot by slot, at most `SERIES_SLOTS` entries. Leave it out and
|
|
46
|
+
* slot 1 still follows the brand, because the base theme spells it `var(--kapi-primary)`; this
|
|
47
|
+
* is for taking over the rest. Order is meaning here: series N is always slot N.
|
|
48
|
+
*/
|
|
49
|
+
series?: readonly string[] | undefined;
|
|
42
50
|
};
|
|
43
|
-
/**
|
|
51
|
+
/** How many categorical slots the palette has. A ninth series folds into "other", never a new hue. */
|
|
52
|
+
export declare const SERIES_SLOTS = 8;
|
|
53
|
+
/** A px length such as `10px` or `999px`: what the `control`, `box` and `surface` knobs accept. */
|
|
44
54
|
export declare const RADIUS_PX_PATTERN: RegExp;
|
|
45
55
|
/** A px length or a percentage such as `32%`: what the `squircle` knob accepts. */
|
|
46
56
|
export declare const RADIUS_SHAPE_PATTERN: RegExp;
|