@kapiuara/ui 0.6.0 → 0.8.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 +115 -5
- package/dist/components/chat/KapiComposer.d.ts +2 -2
- package/dist/components/chat/KapiComposer.js +47 -45
- package/dist/components/data/KapiTable.d.ts +58 -1
- package/dist/components/data/KapiTable.js +399 -358
- package/dist/components/data/datasetSelectionLogic.d.ts +22 -0
- package/dist/components/data/datasetSelectionLogic.js +5 -0
- package/dist/components/data/index.d.ts +2 -1
- package/dist/components/data/tableLogic.d.ts +7 -0
- package/dist/components/data/tableLogic.js +21 -16
- package/dist/components/display/KapiTruncate.d.ts +32 -0
- package/dist/components/display/KapiTruncate.js +43 -0
- package/dist/components/display/index.d.ts +3 -0
- package/dist/components/display/truncateLogic.d.ts +6 -0
- package/dist/components/display/truncateLogic.js +4 -0
- package/dist/components/inputs/KapiButton.d.ts +9 -2
- package/dist/components/inputs/KapiButton.js +25 -15
- package/dist/components/inputs/KapiFacetedSearch.d.ts +29 -5
- package/dist/components/inputs/KapiFacetedSearch.js +161 -119
- package/dist/components/inputs/KapiSegmented.d.ts +9 -2
- package/dist/components/inputs/KapiSegmented.js +46 -44
- package/dist/components/inputs/facetedSearchLogic.d.ts +40 -9
- package/dist/components/inputs/facetedSearchLogic.js +38 -20
- package/dist/components/inputs/index.d.ts +2 -2
- package/dist/components/layout/KapiRail.d.ts +1 -1
- package/dist/components/layout/KapiRail.js +57 -50
- package/dist/components/layout/KapiShell.d.ts +27 -4
- package/dist/components/layout/KapiShell.js +23 -22
- package/dist/components/navigation/KapiTabs.d.ts +3 -1
- package/dist/components/navigation/KapiTabs.js +47 -46
- package/dist/components/overlays/KapiCanvasForm.js +2 -6
- package/dist/components/overlays/KapiConfirm.js +1 -6
- package/dist/hooks/colorLogic.d.ts +26 -0
- package/dist/hooks/colorLogic.js +53 -0
- package/dist/hooks/index.d.ts +6 -0
- package/dist/hooks/numberFormatLogic.d.ts +6 -0
- package/dist/hooks/numberFormatLogic.js +7 -0
- package/dist/hooks/rightClick.d.ts +10 -0
- package/dist/hooks/rightClick.js +10 -4
- package/dist/hooks/themeColorsLogic.d.ts +11 -0
- package/dist/hooks/themeColorsLogic.js +37 -0
- package/dist/hooks/themeContrastLogic.d.ts +23 -0
- package/dist/hooks/themeContrastLogic.js +46 -0
- package/dist/hooks/themeDeriveLogic.d.ts +52 -0
- package/dist/hooks/themeDeriveLogic.js +103 -0
- package/dist/hooks/useDragScroll.js +26 -23
- package/dist/hooks/useGlobalRightClick.js +28 -25
- package/dist/hooks/useKapiTheme.d.ts +28 -4
- package/dist/hooks/useKapiTheme.js +82 -50
- package/dist/index.js +132 -126
- package/dist/kapi.css +1 -1
- package/dist/kapi.layered.css +1 -1
- package/package.json +3 -3
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `list` abre sus opciones; `date` pide una fecha; `dateRange`
|
|
3
|
-
* calendario; `flag` se aplica directo.
|
|
2
|
+
* `list` abre sus opciones; `text` recibe texto libre sobre ese campo; `date` pide una fecha; `dateRange`
|
|
3
|
+
* pide un rango (desde/hasta) en un solo calendario; `flag` se aplica directo.
|
|
4
4
|
*/
|
|
5
|
-
export type KapiFacetKind = "list" | "date" | "dateRange" | "flag";
|
|
5
|
+
export type KapiFacetKind = "list" | "text" | "date" | "dateRange" | "flag";
|
|
6
|
+
/** Comparación que se aplica al valor de una faceta. `eq` es la de siempre. */
|
|
7
|
+
export type KapiFacetOperator = "eq" | "ne" | "contains" | "startsWith" | "endsWith" | "gt" | "gte" | "lt" | "lte";
|
|
6
8
|
export type KapiFacetOption = {
|
|
7
9
|
value: string;
|
|
8
10
|
label: string;
|
|
@@ -24,17 +26,37 @@ export type KapiFacet = {
|
|
|
24
26
|
signal: AbortSignal;
|
|
25
27
|
}) => Promise<ReadonlyArray<KapiFacetOption>>) | undefined;
|
|
26
28
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
+
* Comparaciones que el usuario puede elegir antes del valor. Ausente o vacío equivale a `["eq"]`:
|
|
30
|
+
* no hay paso extra. Con una sola no se pregunta; con dos o más, el menú ofrece el paso.
|
|
29
31
|
*/
|
|
30
|
-
|
|
32
|
+
operators?: ReadonlyArray<KapiFacetOperator> | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* Recibe el valor elegido (el `value` de la opción, el texto tipeado en una faceta `text`, la fecha como `yyyy-mm-dd`, el rango como
|
|
35
|
+
* `yyyy-mm-dd/yyyy-mm-dd` (ver `parseDateRangeValue`) o `"true"` (flag)) y la comparación elegida
|
|
36
|
+
* (`"eq"` si la faceta no declara `operators`).
|
|
37
|
+
*/
|
|
38
|
+
apply: (value: string, operator: KapiFacetOperator) => void;
|
|
31
39
|
};
|
|
40
|
+
/** Operadores de la faceta: los declarados si hay al menos uno, si no `["eq"]`. */
|
|
41
|
+
export declare const facetOperators: (facet: Pick<KapiFacet, "operators">) => ReadonlyArray<KapiFacetOperator>;
|
|
32
42
|
/** Filtro activo que la barra muestra como chip removible. */
|
|
33
43
|
export type KapiFacetChip = {
|
|
34
44
|
key: string;
|
|
35
45
|
label: string;
|
|
46
|
+
/** Valor elegido de la faceta: el chip dice `label: value`. Sin valor (o vacío) dice sólo `label`. */
|
|
47
|
+
value?: string | undefined;
|
|
48
|
+
/** Comparación del filtro: el chip la dice ("Fecha mayor que: …"). Sin ella, o con `eq`, no dice nada. */
|
|
49
|
+
operator?: KapiFacetOperator | undefined;
|
|
36
50
|
onRemove: () => void;
|
|
37
51
|
};
|
|
52
|
+
/**
|
|
53
|
+
* Texto del chip: `label: value` cuando hay valor, `label` solo cuando no. Un valor vacío o de puros
|
|
54
|
+
* espacios cuenta como ausente, para no dibujar un "Carrera: " colgado. Con un operador que no es `eq`
|
|
55
|
+
* suma su texto: `label operatorText: value`. La función es pura: recibe el texto del operador ya
|
|
56
|
+
* resuelto (traducido), no lo traduce. Lo usan el texto visible y el nombre accesible del botón de
|
|
57
|
+
* quitar, así dos chips de la misma faceta no suenan idénticos.
|
|
58
|
+
*/
|
|
59
|
+
export declare const facetChipText: (chip: Pick<KapiFacetChip, "label" | "value" | "operator">, operatorText?: string | undefined) => string;
|
|
38
60
|
export type KapiFacetMenuItem = {
|
|
39
61
|
type: "text";
|
|
40
62
|
text: string;
|
|
@@ -44,15 +66,22 @@ export type KapiFacetMenuItem = {
|
|
|
44
66
|
} | {
|
|
45
67
|
type: "option";
|
|
46
68
|
option: KapiFacetOption;
|
|
69
|
+
} | {
|
|
70
|
+
type: "operator";
|
|
71
|
+
operator: KapiFacetOperator;
|
|
72
|
+
facet: KapiFacet;
|
|
47
73
|
};
|
|
48
74
|
/**
|
|
49
75
|
* Ítems del desplegable. Sin faceta pendiente: "buscar el texto" (si hay) y las facetas que coinciden.
|
|
50
|
-
* Con una faceta `list` pendiente: sus opciones que coinciden. Con una `
|
|
51
|
-
* el calendario).
|
|
76
|
+
* Con una faceta `list` pendiente: sus opciones que coinciden. Con una `text`: "buscar el texto" (si hay),
|
|
77
|
+
* que se aplica a esa faceta. Con una `date` o `dateRange`: nada (decide el calendario). Con una faceta pendiente de dos o más operadores y ninguno elegido (`operator` ausente o
|
|
78
|
+
* `null`): los operadores a elegir, antes que cualquier valor.
|
|
52
79
|
*/
|
|
53
80
|
export declare function facetMenuItems(facets: ReadonlyArray<KapiFacet>, pending: KapiFacet | null, input: string,
|
|
54
81
|
/** Opciones ya cargadas para la faceta pendiente. Si vienen, NO se filtran de nuevo: filtró el servidor. */
|
|
55
|
-
loaded?: ReadonlyArray<KapiFacetOption> | undefined
|
|
82
|
+
loaded?: ReadonlyArray<KapiFacetOption> | undefined,
|
|
83
|
+
/** Operador ya elegido para la faceta pendiente; sin él, y con 2 o más, el menú pide elegirlo. */
|
|
84
|
+
operator?: KapiFacetOperator | null | undefined): KapiFacetMenuItem[];
|
|
56
85
|
/** Mueve el ítem activo con vuelta; desde `-1` entra por el extremo según la dirección. */
|
|
57
86
|
export declare const moveActive: (index: number, count: number, delta: 1 | -1) => number;
|
|
58
87
|
export type KapiFacetKeyAction = "next" | "prev" | "select" | "text" | "cancel" | "close" | "dropPending" | "removeLast";
|
|
@@ -60,6 +89,8 @@ export type KapiFacetKeyAction = "next" | "prev" | "select" | "text" | "cancel"
|
|
|
60
89
|
export declare function facetKeyAction(key: string, s: {
|
|
61
90
|
input: string;
|
|
62
91
|
pending: boolean;
|
|
92
|
+
/** La faceta pendiente es de texto y ya tiene su operador: Enter aplica el texto en vez de ignorarlo. */
|
|
93
|
+
pendingText?: boolean | undefined;
|
|
63
94
|
active: number;
|
|
64
95
|
open: boolean;
|
|
65
96
|
chips: number;
|
|
@@ -1,42 +1,60 @@
|
|
|
1
1
|
import { normalizeFilterText as e } from "../data/tableLogic.js";
|
|
2
2
|
//#region src/components/inputs/facetedSearchLogic.ts
|
|
3
|
-
var t = (
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
3
|
+
var t = (e) => e.operators && e.operators.length > 0 ? e.operators : ["eq"], n = (e, t) => {
|
|
4
|
+
let n = e.operator && e.operator !== "eq" && t ? `${e.label} ${t}` : e.label;
|
|
5
|
+
return e.value !== void 0 && e.value.trim() !== "" ? `${n}: ${e.value}` : n;
|
|
6
|
+
}, r = (t, n) => !n || e(t).includes(n);
|
|
7
|
+
function i(n, i, a, o, s) {
|
|
8
|
+
let c = e(a);
|
|
9
|
+
if (i) {
|
|
10
|
+
let e = t(i);
|
|
11
|
+
if (e.length >= 2 && !s) return e.map((e) => ({
|
|
12
|
+
type: "operator",
|
|
13
|
+
operator: e,
|
|
14
|
+
facet: i
|
|
15
|
+
}));
|
|
16
|
+
if (i.kind === "text") {
|
|
17
|
+
let e = a.trim();
|
|
18
|
+
return e ? [{
|
|
19
|
+
type: "text",
|
|
20
|
+
text: e
|
|
21
|
+
}] : [];
|
|
22
|
+
}
|
|
23
|
+
return i.kind === "list" ? o ? o.map((e) => ({
|
|
24
|
+
type: "option",
|
|
25
|
+
option: e
|
|
26
|
+
})) : (i.options ?? []).filter((e) => r(e.label, c)).map((e) => ({
|
|
27
|
+
type: "option",
|
|
28
|
+
option: e
|
|
29
|
+
})) : [];
|
|
30
|
+
}
|
|
31
|
+
let l = a.trim(), u = l ? [{
|
|
14
32
|
type: "text",
|
|
15
|
-
text:
|
|
33
|
+
text: l
|
|
16
34
|
}] : [];
|
|
17
|
-
for (let e of n)
|
|
35
|
+
for (let e of n) r(e.label, c) && u.push({
|
|
18
36
|
type: "facet",
|
|
19
37
|
facet: e
|
|
20
38
|
});
|
|
21
|
-
return
|
|
39
|
+
return u;
|
|
22
40
|
}
|
|
23
|
-
var
|
|
24
|
-
function
|
|
41
|
+
var a = (e, t, n) => t === 0 ? -1 : e < 0 ? n > 0 ? 0 : t - 1 : (e + n + t) % t;
|
|
42
|
+
function o(e, t) {
|
|
25
43
|
switch (e) {
|
|
26
44
|
case "ArrowDown": return "next";
|
|
27
45
|
case "ArrowUp": return "prev";
|
|
28
|
-
case "Enter": return t.open && t.active >= 0 ? "select" : !t.pending && t.input.trim() ? "text" : null;
|
|
46
|
+
case "Enter": return t.open && t.active >= 0 ? "select" : (!t.pending || t.pendingText) && t.input.trim() ? "text" : null;
|
|
29
47
|
case "Escape": return t.pending ? "cancel" : t.open ? "close" : null;
|
|
30
48
|
case "Backspace": return t.input === "" ? t.pending ? "dropPending" : t.chips > 0 ? "removeLast" : null : null;
|
|
31
49
|
default: return null;
|
|
32
50
|
}
|
|
33
51
|
}
|
|
34
|
-
var
|
|
52
|
+
var s = (e) => `${e.getFullYear()}-${String(e.getMonth() + 1).padStart(2, "0")}-${String(e.getDate()).padStart(2, "0")}`, c = (e, t) => `${s(e)}/${s(t)}`, l = (e) => {
|
|
35
53
|
let t = /^(\d{4}-\d{2}-\d{2})\/(\d{4}-\d{2}-\d{2})$/.exec(e);
|
|
36
54
|
return t ? {
|
|
37
55
|
from: t[1],
|
|
38
56
|
to: t[2]
|
|
39
57
|
} : null;
|
|
40
|
-
},
|
|
58
|
+
}, u = (e) => e.count === void 0 ? e.label : `${e.label}, ${e.count}`, d = (e) => e?.kind === "date" || e?.kind === "dateRange";
|
|
41
59
|
//#endregion
|
|
42
|
-
export {
|
|
60
|
+
export { n as facetChipText, o as facetKeyAction, i as facetMenuItems, t as facetOperators, u as facetOptionName, d as isDateFacet, a as moveActive, l as parseDateRangeValue, c as toDateRangeValue, s as toDateValue };
|
|
@@ -51,5 +51,5 @@ export { KapiAutocomplete, DEFAULT_AUTOCOMPLETE_LABELS } from "./KapiAutocomplet
|
|
|
51
51
|
export type { KapiAutocompleteLabels, KapiAutocompleteProps, KapiAutocompleteRenderContext } from "./KapiAutocomplete";
|
|
52
52
|
export { KapiFacetedSearch, DEFAULT_FACETED_SEARCH_LABELS } from "./KapiFacetedSearch";
|
|
53
53
|
export type { KapiFacetedSearchLabels, KapiFacetedSearchProps } from "./KapiFacetedSearch";
|
|
54
|
-
export { facetKeyAction, facetMenuItems, parseDateRangeValue, toDateRangeValue, toDateValue } from "./facetedSearchLogic";
|
|
55
|
-
export type { KapiFacet, KapiFacetChip, KapiFacetKind, KapiFacetOption, KapiFacetKeyAction, KapiFacetMenuItem } from "./facetedSearchLogic";
|
|
54
|
+
export { facetKeyAction, facetMenuItems, facetOperators, parseDateRangeValue, toDateRangeValue, toDateValue } from "./facetedSearchLogic";
|
|
55
|
+
export type { KapiFacet, KapiFacetChip, KapiFacetKind, KapiFacetOption, KapiFacetKeyAction, KapiFacetMenuItem, KapiFacetOperator } from "./facetedSearchLogic";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type HTMLAttributes, type ReactNode } from "react";
|
|
2
2
|
import { type KapiRailEntry, type KapiRailItem, type KapiRailPinned, type KapiRailSeparator, type KapiRailZone, type KapiRailVariant } from "./railLogic";
|
|
3
3
|
import "./KapiRail.css";
|
|
4
4
|
import { type KapiLinkLabels } from "../locale/linkLabels";
|
|
@@ -5,98 +5,105 @@ import { useSlidingIndicator as n } from "../../hooks/useSlidingIndicator.js";
|
|
|
5
5
|
import { KapiTooltip as r } from "../overlays/KapiTooltip.js";
|
|
6
6
|
import { navBadgeA11yText as i } from "../navigation/navBadgeLogic.js";
|
|
7
7
|
import { KapiNavBadge as a } from "../navigation/KapiNavBadge.js";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { useScrollEdges as o } from "../../hooks/useScrollEdges.js";
|
|
9
|
+
import { DEFAULT_LINK_LABELS as s } from "../locale/linkLabels.js";
|
|
10
|
+
import { useMediaQuery as c } from "../../hooks/useMediaQuery.js";
|
|
11
|
+
import { isRailSeparator as l, railClasses as u, railItemClasses as d, railShowsTooltip as f, splitRailEntries as p } from "./railLogic.js";
|
|
10
12
|
/* empty css */
|
|
11
|
-
import { jsx as
|
|
12
|
-
import {
|
|
13
|
+
import { jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
14
|
+
import { useCallback as g } from "react";
|
|
15
|
+
import { ExternalLink as _ } from "lucide-react";
|
|
13
16
|
//#region src/components/layout/KapiRail.tsx
|
|
14
|
-
var
|
|
15
|
-
let
|
|
16
|
-
active:
|
|
17
|
-
deps: [
|
|
17
|
+
var v = { navigation: "Navegación principal" }, y = ({ items: y, activeId: b, onSelect: x, brand: S, footer: C, variant: w = "labeled", "aria-label": T, labels: E, className: D, ...O }) => {
|
|
18
|
+
let k = e("rail", v, E), A = e("link", s, E), j = w === "compact", M = f(w), N = p(y), { containerRef: P, indicatorRef: F } = n({
|
|
19
|
+
active: b ?? null,
|
|
20
|
+
deps: [y, w],
|
|
18
21
|
findActive: (e) => e.querySelector(".kapi-rail__item[aria-current=\"page\"]")
|
|
19
|
-
}),
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
}), I = c("(max-width: 768px)") ? "x" : "y", { ref: L, edges: R } = o({ axis: I }), z = g((e) => {
|
|
23
|
+
P.current = e, L.current = e;
|
|
24
|
+
}, [P, L]), B = ({ id: e, label: t, icon: n, href: o, external: s, newTab: c, badge: l, badgeTone: u, badgeLabel: f }) => {
|
|
25
|
+
let p = b === e, g = p ? "page" : void 0, v = i(l, f), y = v === null ? t : `${t} ${v}`, S = j ? y : void 0, C = /* @__PURE__ */ m(a, {
|
|
26
|
+
value: l,
|
|
27
|
+
tone: u,
|
|
28
|
+
label: f,
|
|
24
29
|
placement: "corner",
|
|
25
|
-
announce: !
|
|
26
|
-
}), w = o === void 0 ? /* @__PURE__ */
|
|
30
|
+
announce: !j
|
|
31
|
+
}), w = o === void 0 ? /* @__PURE__ */ h("button", {
|
|
27
32
|
type: "button",
|
|
28
|
-
className:
|
|
29
|
-
onClick: () =>
|
|
30
|
-
"aria-current":
|
|
33
|
+
className: d({ active: p }),
|
|
34
|
+
onClick: () => x?.(e),
|
|
35
|
+
"aria-current": g,
|
|
31
36
|
"aria-label": S,
|
|
32
37
|
children: [
|
|
33
38
|
n,
|
|
34
|
-
!
|
|
39
|
+
!j && t,
|
|
35
40
|
C
|
|
36
41
|
]
|
|
37
|
-
},
|
|
38
|
-
className:
|
|
39
|
-
active:
|
|
42
|
+
}, M ? void 0 : e) : /* @__PURE__ */ h("a", {
|
|
43
|
+
className: d({
|
|
44
|
+
active: p,
|
|
40
45
|
link: !0
|
|
41
46
|
}),
|
|
42
47
|
href: o,
|
|
43
48
|
rel: "noopener noreferrer",
|
|
44
49
|
target: c ? "_blank" : void 0,
|
|
45
|
-
"aria-current":
|
|
50
|
+
"aria-current": g,
|
|
46
51
|
"aria-label": S,
|
|
47
52
|
children: [
|
|
48
53
|
n,
|
|
49
|
-
!
|
|
54
|
+
!j && t,
|
|
50
55
|
C,
|
|
51
|
-
s && /* @__PURE__ */
|
|
56
|
+
s && /* @__PURE__ */ m(_, {
|
|
52
57
|
className: "kapi-rail__ext",
|
|
53
58
|
size: 12,
|
|
54
59
|
"aria-hidden": "true"
|
|
55
60
|
}),
|
|
56
|
-
c && /* @__PURE__ */
|
|
61
|
+
c && /* @__PURE__ */ m("span", {
|
|
57
62
|
className: "kapi-rail__sr",
|
|
58
|
-
children:
|
|
63
|
+
children: A.newTab
|
|
59
64
|
})
|
|
60
65
|
]
|
|
61
|
-
},
|
|
62
|
-
return
|
|
63
|
-
label:
|
|
66
|
+
}, M ? void 0 : e);
|
|
67
|
+
return M ? /* @__PURE__ */ m(r, {
|
|
68
|
+
label: y,
|
|
64
69
|
children: w
|
|
65
70
|
}, e) : w;
|
|
66
|
-
},
|
|
71
|
+
}, V = (e) => e.map((e, t) => l(e) ? /* @__PURE__ */ m("div", {
|
|
67
72
|
className: "kapi-rail__sep",
|
|
68
73
|
role: "separator",
|
|
69
74
|
"aria-orientation": "horizontal"
|
|
70
|
-
}, e.id ?? `sep-${t}`) :
|
|
71
|
-
return /* @__PURE__ */
|
|
72
|
-
...
|
|
73
|
-
className: t(
|
|
74
|
-
"aria-label":
|
|
75
|
+
}, e.id ?? `sep-${t}`) : B(e));
|
|
76
|
+
return /* @__PURE__ */ h("nav", {
|
|
77
|
+
...O,
|
|
78
|
+
className: t(u({ variant: w }), D),
|
|
79
|
+
"aria-label": T ?? k.navigation,
|
|
75
80
|
children: [
|
|
76
|
-
|
|
81
|
+
S !== void 0 && /* @__PURE__ */ m("div", {
|
|
77
82
|
className: "kapi-rail__brand",
|
|
78
|
-
children:
|
|
83
|
+
children: S
|
|
79
84
|
}),
|
|
80
|
-
|
|
85
|
+
N.start.length > 0 && /* @__PURE__ */ m("div", {
|
|
81
86
|
className: "kapi-rail__start",
|
|
82
|
-
children:
|
|
87
|
+
children: V(N.start)
|
|
83
88
|
}),
|
|
84
|
-
/* @__PURE__ */
|
|
85
|
-
ref:
|
|
86
|
-
className:
|
|
87
|
-
|
|
88
|
-
|
|
89
|
+
/* @__PURE__ */ h("div", {
|
|
90
|
+
ref: z,
|
|
91
|
+
className: `kapi-rail__scroll kapi-fade-${I}`,
|
|
92
|
+
"data-edge-start": R.start ? "" : void 0,
|
|
93
|
+
"data-edge-end": R.end ? "" : void 0,
|
|
94
|
+
children: [/* @__PURE__ */ m("span", {
|
|
95
|
+
ref: F,
|
|
89
96
|
className: "kapi-rail__indicator",
|
|
90
97
|
"aria-hidden": "true"
|
|
91
|
-
}),
|
|
98
|
+
}), V(N.scroll)]
|
|
92
99
|
}),
|
|
93
|
-
|
|
100
|
+
N.end.length > 0 && /* @__PURE__ */ m("div", {
|
|
94
101
|
className: "kapi-rail__end",
|
|
95
|
-
children:
|
|
102
|
+
children: V(N.end)
|
|
96
103
|
}),
|
|
97
|
-
|
|
104
|
+
C
|
|
98
105
|
]
|
|
99
106
|
});
|
|
100
107
|
};
|
|
101
108
|
//#endregion
|
|
102
|
-
export {
|
|
109
|
+
export { v as DEFAULT_RAIL_LABELS, y as KapiRail };
|
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
import { type HTMLAttributes, type ReactNode } from "react";
|
|
2
|
+
import type { KapiThemeColors } from "../../hooks/themeDeriveLogic";
|
|
2
3
|
import { type KapiMenuItem } from "../overlays/KapiContextMenu";
|
|
3
4
|
/**
|
|
4
5
|
* Atributos nativos (`id`, `style`, `data-*`…) van a la raíz `.kapi`. `data-theme`/`data-motion`
|
|
5
|
-
* son propios y las variables del tema (`--kapi-font`, `--kapi-primary
|
|
6
|
+
* son propios y las variables del tema (`--kapi-font`, `--kapi-primary`…) ganan sobre `style`.
|
|
6
7
|
*/
|
|
7
8
|
export type KapiShellProps = Omit<HTMLAttributes<HTMLDivElement>, "children"> & {
|
|
8
9
|
/** Navegación principal (típicamente `<KapiRail />`). OPCIONAL. */
|
|
9
10
|
rail?: ReactNode;
|
|
10
11
|
/** Panel contextual (típicamente `<KapiContextSlot />`). OPCIONAL. */
|
|
11
12
|
panel?: ReactNode;
|
|
13
|
+
/**
|
|
14
|
+
* Panel contextual derecho (típicamente `<KapiContextSlot side="right" aria-label="…" />`). OPCIONAL. Pásale
|
|
15
|
+
* `side="right"` al slot (la cáscara no puede, es tu componente) y un nombre accesible distinto del panel izquierdo.
|
|
16
|
+
*/
|
|
17
|
+
panelRight?: ReactNode;
|
|
12
18
|
/** Contenido de la página; va dentro de `<main class="kapi-content">` (el que scrollea). */
|
|
13
19
|
children?: ReactNode;
|
|
14
20
|
/** Ítems del menú del sistema (doble click derecho). Sin ítems no se abre menú. */
|
|
@@ -24,17 +30,34 @@ export type KapiShellProps = Omit<HTMLAttributes<HTMLDivElement>, "children"> &
|
|
|
24
30
|
* (`kapi:theme`…). Dos apps del design system en el mismo origen pasan uno distinto para no pisarse.
|
|
25
31
|
*/
|
|
26
32
|
storageNamespace?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Tema de marca: los colores de la identidad del producto (`primary`, `bg`, `ink`…). Es la base;
|
|
35
|
+
* el acento y lo que la persona personalizó se aplican encima, color por color. Se deriva sobre
|
|
36
|
+
* el tema claro u oscuro que se ve.
|
|
37
|
+
*/
|
|
38
|
+
brandTheme?: KapiThemeColors | undefined;
|
|
27
39
|
};
|
|
28
40
|
/**
|
|
29
41
|
* Marco de la app. Es la raíz `.kapi` (tokens, tema, fuente) y compone:
|
|
30
42
|
*
|
|
31
|
-
* [rail?] [panel?] <main.kapi-content>
|
|
43
|
+
* [rail?] [panel?] <main.kapi-content> [panelRight?]
|
|
44
|
+
*
|
|
45
|
+
* Rail y paneles son opcionales e independientes: el contenido no depende de ninguno.
|
|
32
46
|
*
|
|
33
|
-
*
|
|
47
|
+
* Con `panelRight`, el `KapiContextSlot` que va ahí necesita `side="right"`: la cáscara no puede
|
|
48
|
+
* ponérselo (es un componente tuyo) y sin eso el borde, los íconos de plegar y el drawer móvil
|
|
49
|
+
* apuntan al lado equivocado. Con dos paneles, cada `<aside>` necesita un nombre accesible distinto
|
|
50
|
+
* (`aria-label` o `labels.region`): los dos usan por defecto «Panel contextual», y dos landmarks con
|
|
51
|
+
* el mismo nombre no se distinguen con un lector de pantalla.
|
|
34
52
|
*
|
|
35
53
|
* // con rail + panel
|
|
36
54
|
* <KapiShell rail={<KapiRail items={…} />} panel={<KapiContextSlot title="Módulo">…</KapiContextSlot>}>…</KapiShell>
|
|
55
|
+
* // con panel a cada lado
|
|
56
|
+
* <KapiShell
|
|
57
|
+
* panel={<KapiContextSlot aria-label="Secciones" title="Módulo">…</KapiContextSlot>}
|
|
58
|
+
* panelRight={<KapiContextSlot side="right" aria-label="Detalle" title="Detalle">…</KapiContextSlot>}
|
|
59
|
+
* >…</KapiShell>
|
|
37
60
|
* // sin rail (otra navegación, p. ej. tabs arriba o router propio)
|
|
38
61
|
* <KapiShell><MiTopNav /><Pagina /></KapiShell>
|
|
39
62
|
*/
|
|
40
|
-
export declare const KapiShell: ({ rail, panel, children, contextMenuItems, rightClick, overlays, className, contentClassName, storageNamespace, style, ...rest }: KapiShellProps) => import("react").JSX.Element;
|
|
63
|
+
export declare const KapiShell: ({ rail, panel, panelRight, children, contextMenuItems, rightClick, overlays, className, contentClassName, storageNamespace, brandTheme, style, ...rest }: KapiShellProps) => import("react").JSX.Element;
|
|
@@ -4,46 +4,47 @@ import { KapiContextMenu as t } from "../overlays/KapiContextMenu.js";
|
|
|
4
4
|
import { useGlobalRightClick as n } from "../../hooks/useGlobalRightClick.js";
|
|
5
5
|
import { KapiThemeContext as r, themeRootStyle as i, useKapiThemeState as a } from "../../hooks/useKapiTheme.js";
|
|
6
6
|
import { jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
7
|
-
import {
|
|
7
|
+
import { useMemo as c, useState as l } from "react";
|
|
8
8
|
//#region src/components/layout/KapiShell.tsx
|
|
9
|
-
var
|
|
10
|
-
let
|
|
9
|
+
var u = ({ rail: u, panel: d, panelRight: f, children: p, contextMenuItems: m, rightClick: h = !0, overlays: g, className: _, contentClassName: v = "", storageNamespace: y, brandTheme: b, style: x, ...S }) => {
|
|
10
|
+
let C = a({ namespace: y }), w = c(() => i(C, b), [C, b]), [T, E] = l(null);
|
|
11
11
|
return n({
|
|
12
|
-
enabled:
|
|
13
|
-
onMenu:
|
|
12
|
+
enabled: h,
|
|
13
|
+
onMenu: m?.length ? (e, t) => E({
|
|
14
14
|
x: e,
|
|
15
15
|
y: t
|
|
16
16
|
}) : void 0
|
|
17
17
|
}), /* @__PURE__ */ o(r.Provider, {
|
|
18
|
-
value:
|
|
18
|
+
value: C,
|
|
19
19
|
children: /* @__PURE__ */ s("div", {
|
|
20
|
-
...
|
|
21
|
-
className: e("kapi",
|
|
22
|
-
"data-theme":
|
|
23
|
-
"data-motion":
|
|
20
|
+
...S,
|
|
21
|
+
className: e("kapi", _),
|
|
22
|
+
"data-theme": C.theme,
|
|
23
|
+
"data-motion": C.motion === "reduced" ? "reduced" : void 0,
|
|
24
24
|
style: {
|
|
25
|
-
...
|
|
26
|
-
...
|
|
25
|
+
...x,
|
|
26
|
+
...w
|
|
27
27
|
},
|
|
28
28
|
children: [
|
|
29
|
-
l,
|
|
30
29
|
u,
|
|
30
|
+
d,
|
|
31
31
|
/* @__PURE__ */ o("main", {
|
|
32
|
-
className: `kapi-content${
|
|
32
|
+
className: `kapi-content${v ? ` ${v}` : ""}`,
|
|
33
33
|
tabIndex: 0,
|
|
34
|
-
children:
|
|
34
|
+
children: p
|
|
35
35
|
}),
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
f,
|
|
37
|
+
g,
|
|
38
|
+
T && m && /* @__PURE__ */ o(t, {
|
|
38
39
|
open: !0,
|
|
39
|
-
x:
|
|
40
|
-
y:
|
|
41
|
-
items:
|
|
42
|
-
onClose: () =>
|
|
40
|
+
x: T.x,
|
|
41
|
+
y: T.y,
|
|
42
|
+
items: m,
|
|
43
|
+
onClose: () => E(null)
|
|
43
44
|
})
|
|
44
45
|
]
|
|
45
46
|
})
|
|
46
47
|
});
|
|
47
48
|
};
|
|
48
49
|
//#endregion
|
|
49
|
-
export {
|
|
50
|
+
export { u as KapiShell };
|
|
@@ -8,7 +8,9 @@ export type KapiTabItem<Id extends string = string> = {
|
|
|
8
8
|
label: ReactNode;
|
|
9
9
|
/** Ícono (lucide-react) antes del label. */
|
|
10
10
|
icon?: ReactNode | undefined;
|
|
11
|
-
/** Contador en una píldora tras el label (p. ej. documentos adjuntos); `0` también se muestra.
|
|
11
|
+
/** Contador en una píldora tras el label (p. ej. documentos adjuntos); `0` también se muestra. Se
|
|
12
|
+
* formatea con los separadores de miles del español, que agrupa desde cinco cifras
|
|
13
|
+
* (`14760` → «14.760»; `4760` queda «4760»). */
|
|
12
14
|
count?: number | undefined;
|
|
13
15
|
};
|
|
14
16
|
/**
|
|
@@ -1,81 +1,82 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { joinClasses as e } from "../rootProps.js";
|
|
3
3
|
import { useSlidingIndicator as t } from "../../hooks/useSlidingIndicator.js";
|
|
4
|
-
import {
|
|
4
|
+
import { formatCount as n } from "../../hooks/numberFormatLogic.js";
|
|
5
|
+
import { useScrollEdges as r } from "../../hooks/useScrollEdges.js";
|
|
5
6
|
/* empty css */
|
|
6
|
-
import { nextTabId as
|
|
7
|
-
import { Fragment as
|
|
8
|
-
import { useCallback as
|
|
7
|
+
import { nextTabId as i, tabClasses as a, tabId as o, tabPanelId as s } from "./tabsLogic.js";
|
|
8
|
+
import { Fragment as c, jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
9
|
+
import { useCallback as d, useId as f, useLayoutEffect as p, useRef as m } from "react";
|
|
9
10
|
//#region src/components/navigation/KapiTabs.tsx
|
|
10
|
-
function
|
|
11
|
-
let
|
|
12
|
-
active:
|
|
13
|
-
deps: [
|
|
11
|
+
function h({ tabs: h, value: g, onChange: _, className: v, idBase: y, onKeyDown: b, ...x }) {
|
|
12
|
+
let S = f(), C = y ?? S, w = m({}), { containerRef: T, indicatorRef: E } = t({
|
|
13
|
+
active: g,
|
|
14
|
+
deps: [h],
|
|
14
15
|
findActive: (e) => e.querySelector("[role=\"tab\"][aria-selected=\"true\"]")
|
|
15
|
-
}), { ref:
|
|
16
|
-
|
|
17
|
-
}, [
|
|
18
|
-
|
|
19
|
-
let e =
|
|
20
|
-
e &&
|
|
16
|
+
}), { ref: D, edges: O, reveal: k } = r({ axis: "x" }), A = d((e) => {
|
|
17
|
+
T.current = e, D.current = e;
|
|
18
|
+
}, [T, D]), j = m(!1);
|
|
19
|
+
p(() => {
|
|
20
|
+
let e = T.current?.querySelector("[role=\"tab\"][aria-selected=\"true\"]");
|
|
21
|
+
e && k(e, { instant: !j.current }), j.current = !0;
|
|
21
22
|
}, [
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
g,
|
|
24
|
+
T,
|
|
25
|
+
k
|
|
25
26
|
]);
|
|
26
|
-
let
|
|
27
|
-
if (
|
|
28
|
-
let t =
|
|
29
|
-
t !== void 0 && (e.preventDefault(),
|
|
27
|
+
let M = (e) => {
|
|
28
|
+
if (b?.(e), e.defaultPrevented) return;
|
|
29
|
+
let t = i(h.map((e) => e.id), g, e.key);
|
|
30
|
+
t !== void 0 && (e.preventDefault(), _(t), w.current[t]?.focus());
|
|
30
31
|
};
|
|
31
|
-
return /* @__PURE__ */
|
|
32
|
-
...
|
|
33
|
-
ref:
|
|
34
|
-
className: e("kapi-tabs", "kapi-fade-x",
|
|
35
|
-
"data-edge-start":
|
|
36
|
-
"data-edge-end":
|
|
32
|
+
return /* @__PURE__ */ u("div", {
|
|
33
|
+
...x,
|
|
34
|
+
ref: A,
|
|
35
|
+
className: e("kapi-tabs", "kapi-fade-x", v),
|
|
36
|
+
"data-edge-start": O.start ? "" : void 0,
|
|
37
|
+
"data-edge-end": O.end ? "" : void 0,
|
|
37
38
|
role: "tablist",
|
|
38
|
-
onKeyDown:
|
|
39
|
-
children: [/* @__PURE__ */
|
|
40
|
-
ref:
|
|
39
|
+
onKeyDown: M,
|
|
40
|
+
children: [/* @__PURE__ */ l("span", {
|
|
41
|
+
ref: E,
|
|
41
42
|
className: "kapi-tabs__indicator",
|
|
42
43
|
"aria-hidden": "true"
|
|
43
|
-
}),
|
|
44
|
-
let t = e.id ===
|
|
45
|
-
return /* @__PURE__ */
|
|
44
|
+
}), h.map((e) => {
|
|
45
|
+
let t = e.id === g;
|
|
46
|
+
return /* @__PURE__ */ u("button", {
|
|
46
47
|
ref: (t) => {
|
|
47
|
-
|
|
48
|
+
w.current[e.id] = t;
|
|
48
49
|
},
|
|
49
50
|
type: "button",
|
|
50
|
-
id:
|
|
51
|
+
id: o(C, e.id),
|
|
51
52
|
role: "tab",
|
|
52
|
-
"aria-controls":
|
|
53
|
+
"aria-controls": y ? s(y, e.id) : void 0,
|
|
53
54
|
"aria-selected": t,
|
|
54
55
|
tabIndex: t ? 0 : -1,
|
|
55
|
-
className:
|
|
56
|
-
onClick: () =>
|
|
56
|
+
className: a(t),
|
|
57
|
+
onClick: () => _(e.id),
|
|
57
58
|
children: [
|
|
58
59
|
e.icon,
|
|
59
60
|
e.label,
|
|
60
|
-
e.count !== void 0 && /* @__PURE__ */
|
|
61
|
+
e.count !== void 0 && /* @__PURE__ */ u(c, { children: [" ", /* @__PURE__ */ l("span", {
|
|
61
62
|
className: "kapi-tabs__count",
|
|
62
|
-
children: e.count
|
|
63
|
+
children: n(e.count)
|
|
63
64
|
})] })
|
|
64
65
|
]
|
|
65
66
|
}, e.id);
|
|
66
67
|
})]
|
|
67
68
|
});
|
|
68
69
|
}
|
|
69
|
-
function
|
|
70
|
-
return /* @__PURE__ */
|
|
71
|
-
id:
|
|
70
|
+
function g({ idBase: e, tabId: t, active: n, keepMounted: r = !1, className: i, children: a }) {
|
|
71
|
+
return /* @__PURE__ */ l("div", {
|
|
72
|
+
id: s(e, t),
|
|
72
73
|
role: "tabpanel",
|
|
73
|
-
"aria-labelledby":
|
|
74
|
+
"aria-labelledby": o(e, t),
|
|
74
75
|
tabIndex: 0,
|
|
75
76
|
hidden: !n,
|
|
76
77
|
className: i,
|
|
77
|
-
children: n || r ?
|
|
78
|
+
children: n || r ? a : null
|
|
78
79
|
});
|
|
79
80
|
}
|
|
80
81
|
//#endregion
|
|
81
|
-
export {
|
|
82
|
+
export { g as KapiTabPanel, h as KapiTabs };
|
|
@@ -34,12 +34,8 @@ var f = {
|
|
|
34
34
|
variant: "primary",
|
|
35
35
|
type: "submit",
|
|
36
36
|
form: E,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
icon: D ? /* @__PURE__ */ a("span", {
|
|
40
|
-
className: "kapi-spinner kapi-spinner--sm",
|
|
41
|
-
"aria-hidden": "true"
|
|
42
|
-
}) : void 0,
|
|
37
|
+
loading: D,
|
|
38
|
+
disabled: y,
|
|
43
39
|
children: _ ?? w.submit
|
|
44
40
|
})] });
|
|
45
41
|
return /* @__PURE__ */ a(n, {
|