@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
|
@@ -1,136 +1,156 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useLabels as e } from "../locale/KapiLocaleProvider.js";
|
|
3
3
|
import { joinClasses as t } from "../rootProps.js";
|
|
4
|
-
import { clampCtxPanelWidth as n, ctxPanelWidthFromDrag as
|
|
4
|
+
import { clampCtxPanelWidth as n, ctxPanelWidthFromDrag as ee, stepCtxPanelWidth as te } from "../navigation/contextPanelLogic.js";
|
|
5
5
|
/* empty css */
|
|
6
|
-
import { KapiPanelMiniContext as
|
|
7
|
-
import { resolveGone as
|
|
8
|
-
import { SHELL_MOBILE_QUERY as
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
6
|
+
import { KapiPanelMiniContext as ne } from "../navigation/panelMini.js";
|
|
7
|
+
import { resolveGone as re, resolveMini as ie } from "../navigation/panelMiniLogic.js";
|
|
8
|
+
import { SHELL_MOBILE_QUERY as ae, SHELL_NARROW_QUERY as oe, matchesQuery as se, useMediaQuery as r } from "../../hooks/useMediaQuery.js";
|
|
9
|
+
import { useReopenBus as i } from "./reopenBus.js";
|
|
10
|
+
import { openOnZoneCross as a, shellZone as ce } from "../../hooks/breakpointOpenLogic.js";
|
|
11
|
+
import { Fragment as le, jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
12
|
+
import { useCallback as c, useEffect as l, useMemo as ue, useRef as u, useState as d } from "react";
|
|
13
|
+
import { ChevronsLeft as f, ChevronsRight as p } from "lucide-react";
|
|
13
14
|
//#region src/components/layout/KapiContextSlot.tsx
|
|
14
|
-
var
|
|
15
|
+
var m = {
|
|
15
16
|
collapse: "Plegar panel",
|
|
16
17
|
expand: "Desplegar panel",
|
|
17
18
|
region: "Panel contextual",
|
|
18
19
|
resize: "Redimensionar panel"
|
|
19
|
-
},
|
|
20
|
-
let
|
|
21
|
-
|
|
22
|
-
}, [
|
|
23
|
-
|
|
24
|
-
let e =
|
|
25
|
-
|
|
20
|
+
}, h = ({ title: h, actions: g, children: _, open: v, defaultOpen: y, onOpenChange: b, side: x = "left", collapsedMode: S = "hidden", resizable: de = !1, width: C, defaultWidth: fe, onWidthChange: pe, minWidth: w = 200, maxWidth: T = 420, "aria-label": me, labels: he, className: ge, style: E, id: D }) => {
|
|
21
|
+
let O = e("contextSlot", m, he), k = me ?? O.region, A = x === "right", j = A ? p : f, M = A ? f : p, [N, P] = d(() => y ?? !se("(max-width: 1024px)")), F = v ?? N, I = c((e) => {
|
|
22
|
+
v === void 0 && P(e), b?.(e);
|
|
23
|
+
}, [v, b]), L = r(ae), _e = r(oe), R = ce(L, _e), z = u(R), B = u(R === "wide" ? F : y ?? !0);
|
|
24
|
+
l(() => {
|
|
25
|
+
let e = a(z.current, R, B.current);
|
|
26
|
+
z.current = R, e !== null && e !== F && I(e);
|
|
26
27
|
}, [
|
|
27
|
-
B,
|
|
28
28
|
R,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
29
|
+
F,
|
|
30
|
+
I
|
|
31
|
+
]), l(() => {
|
|
32
|
+
R === "wide" && (B.current = F);
|
|
33
|
+
}, [R, F]);
|
|
34
|
+
let [ve, ye] = d(fe ?? null), [be, V] = d(!1), H = u(null), U = u(null), W = C ?? ve, G = W === null ? null : n(W, w, T), K = () => G ?? H.current?.offsetWidth ?? 258, q = (e) => {
|
|
35
|
+
e !== G && (C === void 0 && ye(e), pe?.(e));
|
|
36
|
+
}, xe = (e) => {
|
|
37
|
+
e.button === 0 && (U.current = {
|
|
37
38
|
startX: e.clientX,
|
|
38
|
-
startWidth:
|
|
39
|
-
}, e.currentTarget.setPointerCapture(e.pointerId),
|
|
40
|
-
},
|
|
41
|
-
let t =
|
|
42
|
-
t &&
|
|
43
|
-
},
|
|
44
|
-
|
|
45
|
-
},
|
|
46
|
-
let t =
|
|
47
|
-
t !== null && (e.preventDefault(),
|
|
48
|
-
},
|
|
49
|
-
...
|
|
50
|
-
"--kapi-ctxslot-w": `${
|
|
51
|
-
},
|
|
52
|
-
collapsedMode:
|
|
53
|
-
open:
|
|
54
|
-
mobile:
|
|
55
|
-
}),
|
|
56
|
-
collapsedMode:
|
|
57
|
-
open:
|
|
58
|
-
mobile:
|
|
59
|
-
}),
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
39
|
+
startWidth: K()
|
|
40
|
+
}, e.currentTarget.setPointerCapture(e.pointerId), V(!0), e.preventDefault());
|
|
41
|
+
}, Se = (e) => {
|
|
42
|
+
let t = U.current;
|
|
43
|
+
t && q(ee(x, t.startWidth, t.startX, e.clientX, w, T));
|
|
44
|
+
}, J = (e) => {
|
|
45
|
+
U.current = null, e.currentTarget.hasPointerCapture(e.pointerId) && e.currentTarget.releasePointerCapture(e.pointerId), V(!1);
|
|
46
|
+
}, Ce = (e) => {
|
|
47
|
+
let t = te(x, K(), e.key, w, T);
|
|
48
|
+
t !== null && (e.preventDefault(), q(t));
|
|
49
|
+
}, we = G === null ? E : {
|
|
50
|
+
...E,
|
|
51
|
+
"--kapi-ctxslot-w": `${G}px`
|
|
52
|
+
}, Y = ie({
|
|
53
|
+
collapsedMode: S,
|
|
54
|
+
open: F,
|
|
55
|
+
mobile: L
|
|
56
|
+
}), X = re({
|
|
57
|
+
collapsedMode: S,
|
|
58
|
+
open: F,
|
|
59
|
+
mobile: L
|
|
60
|
+
}), Z = i(), Q = Z?.publish, Te = !!Z && L, $ = c(() => I(!0), [I]);
|
|
61
|
+
l(() => {
|
|
62
|
+
if (Q) {
|
|
63
|
+
if (!L || F || X) Q(null);
|
|
64
|
+
else return Q({
|
|
65
|
+
expand: $,
|
|
66
|
+
label: O.expand,
|
|
67
|
+
side: A ? "right" : "left"
|
|
68
|
+
}), () => Q(null);
|
|
69
|
+
}
|
|
70
|
+
}, [
|
|
64
71
|
Q,
|
|
65
|
-
|
|
66
|
-
|
|
72
|
+
L,
|
|
73
|
+
F,
|
|
74
|
+
X,
|
|
75
|
+
$,
|
|
76
|
+
O.expand,
|
|
77
|
+
A
|
|
78
|
+
]);
|
|
79
|
+
let Ee = ue(() => ({
|
|
80
|
+
mini: Y,
|
|
81
|
+
expand: () => I(!0),
|
|
82
|
+
tooltipSide: A ? "left" : "right"
|
|
83
|
+
}), [
|
|
84
|
+
Y,
|
|
85
|
+
I,
|
|
86
|
+
A
|
|
67
87
|
]);
|
|
68
|
-
return /* @__PURE__ */
|
|
69
|
-
ref:
|
|
70
|
-
id:
|
|
71
|
-
className: t("kapi-ctxslot",
|
|
72
|
-
style:
|
|
88
|
+
return /* @__PURE__ */ s(le, { children: [/* @__PURE__ */ s("div", {
|
|
89
|
+
ref: H,
|
|
90
|
+
id: D,
|
|
91
|
+
className: t("kapi-ctxslot", A && "kapi-ctxslot--right", !F && "is-collapsed", be && "is-resizing", Y && "is-mini kapi-navmini", X && "is-gone", ge),
|
|
92
|
+
style: we,
|
|
73
93
|
children: [
|
|
74
|
-
|
|
94
|
+
de && F && !L && /* @__PURE__ */ o("div", {
|
|
75
95
|
className: "kapi-ctxslot__resize",
|
|
76
96
|
role: "separator",
|
|
77
97
|
"aria-orientation": "vertical",
|
|
78
|
-
"aria-label":
|
|
79
|
-
"aria-valuemin":
|
|
80
|
-
"aria-valuemax":
|
|
81
|
-
"aria-valuenow": n(
|
|
98
|
+
"aria-label": O.resize,
|
|
99
|
+
"aria-valuemin": w,
|
|
100
|
+
"aria-valuemax": T,
|
|
101
|
+
"aria-valuenow": n(G ?? 258, w, T),
|
|
82
102
|
tabIndex: 0,
|
|
83
|
-
onPointerDown:
|
|
84
|
-
onPointerMove:
|
|
85
|
-
onPointerUp:
|
|
86
|
-
onPointerCancel:
|
|
87
|
-
onKeyDown:
|
|
103
|
+
onPointerDown: xe,
|
|
104
|
+
onPointerMove: Se,
|
|
105
|
+
onPointerUp: J,
|
|
106
|
+
onPointerCancel: J,
|
|
107
|
+
onKeyDown: Ce
|
|
88
108
|
}),
|
|
89
|
-
/* @__PURE__ */
|
|
109
|
+
/* @__PURE__ */ o("div", {
|
|
90
110
|
className: "kapi-ctxslot__inner",
|
|
91
|
-
inert: !
|
|
92
|
-
children: /* @__PURE__ */
|
|
111
|
+
inert: !F && !Y,
|
|
112
|
+
children: /* @__PURE__ */ s("aside", {
|
|
93
113
|
className: "kapi-ctxpanel",
|
|
94
|
-
"aria-label":
|
|
95
|
-
children: [/* @__PURE__ */
|
|
114
|
+
"aria-label": k,
|
|
115
|
+
children: [/* @__PURE__ */ s("div", {
|
|
96
116
|
className: "kapi-ctxpanel__head",
|
|
97
|
-
children: [/* @__PURE__ */
|
|
117
|
+
children: [/* @__PURE__ */ o("span", { children: h }), /* @__PURE__ */ s("div", {
|
|
98
118
|
className: "kapi-ctxpanel__actions",
|
|
99
|
-
children: [
|
|
119
|
+
children: [g, /* @__PURE__ */ o("button", {
|
|
100
120
|
type: "button",
|
|
101
121
|
className: "kapi-paneltoggle",
|
|
102
|
-
onClick: () =>
|
|
103
|
-
"aria-label":
|
|
104
|
-
children: /* @__PURE__ */
|
|
122
|
+
onClick: () => I(!1),
|
|
123
|
+
"aria-label": O.collapse,
|
|
124
|
+
children: /* @__PURE__ */ o(j, {
|
|
105
125
|
size: 16,
|
|
106
126
|
strokeWidth: 2,
|
|
107
127
|
"aria-hidden": "true"
|
|
108
128
|
})
|
|
109
129
|
})]
|
|
110
130
|
})]
|
|
111
|
-
}), /* @__PURE__ */
|
|
112
|
-
value:
|
|
113
|
-
children:
|
|
131
|
+
}), /* @__PURE__ */ o(ne.Provider, {
|
|
132
|
+
value: Ee,
|
|
133
|
+
children: _
|
|
114
134
|
})]
|
|
115
135
|
})
|
|
116
136
|
}),
|
|
117
|
-
|
|
137
|
+
!X && !Te && /* @__PURE__ */ o("button", {
|
|
118
138
|
type: "button",
|
|
119
139
|
className: "kapi-paneltoggle kapi-ctxslot__reopen",
|
|
120
|
-
onClick:
|
|
121
|
-
"aria-label":
|
|
122
|
-
children: /* @__PURE__ */
|
|
140
|
+
onClick: $,
|
|
141
|
+
"aria-label": O.expand,
|
|
142
|
+
children: /* @__PURE__ */ o(M, {
|
|
123
143
|
size: 16,
|
|
124
144
|
strokeWidth: 2,
|
|
125
145
|
"aria-hidden": "true"
|
|
126
146
|
})
|
|
127
147
|
})
|
|
128
148
|
]
|
|
129
|
-
}), /* @__PURE__ */
|
|
149
|
+
}), /* @__PURE__ */ o("div", {
|
|
130
150
|
className: "kapi-ctxslot__backdrop",
|
|
131
|
-
onClick: () =>
|
|
151
|
+
onClick: () => I(!1),
|
|
132
152
|
"aria-hidden": "true"
|
|
133
153
|
})] });
|
|
134
154
|
};
|
|
135
155
|
//#endregion
|
|
136
|
-
export {
|
|
156
|
+
export { m as DEFAULT_CONTEXT_SLOT_LABELS, h as KapiContextSlot };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type HTMLAttributes, type Ref } from "react";
|
|
2
|
+
import { type KapiGap } from "./layoutPrimitives";
|
|
3
|
+
import "./KapiMasonry.css";
|
|
4
|
+
export type KapiMasonryProps = HTMLAttributes<HTMLDivElement> & {
|
|
5
|
+
/** Separación entre ítems, en los dos ejes: número = px, string = largo CSS. Default 12px. */
|
|
6
|
+
gap?: KapiGap | undefined;
|
|
7
|
+
/** Ancho mínimo de columna (número = px, string = largo CSS): `auto-fit` + `minmax`. Default 220px. */
|
|
8
|
+
min?: number | string | undefined;
|
|
9
|
+
/** Cantidad fija de columnas. Si se pasan `cols` y `min`, gana `cols`. */
|
|
10
|
+
cols?: number | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Alto (px) de una fila de la grilla: el grano con el que se empaqueta. Más chico acomoda más
|
|
13
|
+
* justo pero obliga al navegador a resolver más filas por ítem. Default `8`.
|
|
14
|
+
*/
|
|
15
|
+
rowUnit?: number | undefined;
|
|
16
|
+
/** Ref al contenedor de la grilla. */
|
|
17
|
+
ref?: Ref<HTMLDivElement> | undefined;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Masonry: tarjetas de alto distinto que se acomodan en columnas sin dejar huecos verticales, con
|
|
21
|
+
* el orden del DOM igual al orden visual por filas (1, 2, 3 / 4, 5, 6).
|
|
22
|
+
*
|
|
23
|
+
* Es UNA grilla CSS con los ítems en orden como hijos directos; el alto de cada ítem se mide y se
|
|
24
|
+
* traduce en `grid-row-end: span N`. No hay contenedores de columna ni `columns` de CSS (que
|
|
25
|
+
* ordenan por columna), así que el orden de tabulación y lo que anuncia un lector de pantalla
|
|
26
|
+
* coinciden con el visual. Cada hijo de `children` queda envuelto en un `div` que es el ítem de la
|
|
27
|
+
* grilla (un `Fragment` cuenta como un solo hijo). Antes de medir, o sin `ResizeObserver`, es una
|
|
28
|
+
* grilla normal.
|
|
29
|
+
*/
|
|
30
|
+
export declare function KapiMasonry({ gap, min, cols, rowUnit, className, style, children, ref, ...rest }: KapiMasonryProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { joinClasses as e } from "../rootProps.js";
|
|
3
|
+
import { gapValue as t, gridColumns as n } from "./layoutPrimitives.js";
|
|
4
|
+
import { useMasonrySpans as r } from "./useMasonrySpans.js";
|
|
5
|
+
/* empty css */
|
|
6
|
+
import { jsx as i } from "react/jsx-runtime";
|
|
7
|
+
import { Children as a, isValidElement as o } from "react";
|
|
8
|
+
//#region src/components/layout/KapiMasonry.tsx
|
|
9
|
+
function s({ gap: s, min: c, cols: l, rowUnit: u = 8, className: d, style: f, children: p, ref: m, ...h }) {
|
|
10
|
+
let g = a.toArray(p), { spans: _, measured: v, register: y } = r({
|
|
11
|
+
rowUnit: u,
|
|
12
|
+
watch: [s, g.length]
|
|
13
|
+
}), b = t(s), x = n(l, c), S = {
|
|
14
|
+
...b !== void 0 && { "--kapi-masonry-gap": b },
|
|
15
|
+
...Number.isFinite(u) && u > 0 && { "--kapi-masonry-row": `${u}px` },
|
|
16
|
+
...x !== void 0 && { gridTemplateColumns: x },
|
|
17
|
+
...f
|
|
18
|
+
};
|
|
19
|
+
return /* @__PURE__ */ i("div", {
|
|
20
|
+
...h,
|
|
21
|
+
ref: m,
|
|
22
|
+
className: e("kapi-masonry", v && "is-measured", d),
|
|
23
|
+
style: S,
|
|
24
|
+
children: g.map((e, t) => /* @__PURE__ */ i("div", {
|
|
25
|
+
ref: y(t),
|
|
26
|
+
className: "kapi-masonry__item",
|
|
27
|
+
style: { gridRowEnd: `span ${_[t] ?? 1}` },
|
|
28
|
+
children: e
|
|
29
|
+
}, o(e) && e.key !== null ? e.key : t))
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
export { s as KapiMasonry };
|
|
@@ -1,72 +1,150 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { prefersReducedMotion as e } from "../../hooks/reducedMotion.js";
|
|
3
|
+
import { maxTransitionMs as t } from "../overlays/dialogUtils.js";
|
|
4
|
+
import { useReopenBus as n } from "./reopenBus.js";
|
|
5
|
+
import { useScrollCollapse as r } from "../../hooks/useScrollCollapse.js";
|
|
6
|
+
import { pageHeaderBox as i } from "./pageHeaderLogic.js";
|
|
4
7
|
/* empty css */
|
|
5
|
-
import { Fragment as
|
|
6
|
-
import { useLayoutEffect as
|
|
8
|
+
import { Fragment as a, jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
9
|
+
import { useEffect as c, useLayoutEffect as l, useRef as u } from "react";
|
|
10
|
+
import { ChevronsLeft as d, ChevronsRight as f } from "lucide-react";
|
|
7
11
|
//#region src/components/layout/KapiPageHeader.tsx
|
|
8
|
-
|
|
9
|
-
let
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
var p = "kapi-pageheader--collapsed", m = "kapi-pageheader--animating", h = "kapi-pageheader--measuring", g = 80, _ = (e, t) => {
|
|
13
|
+
let n = e.style.height;
|
|
14
|
+
e.classList.add(h), e.style.height = "", e.classList.toggle(p, !1);
|
|
15
|
+
let r = e.getBoundingClientRect().height;
|
|
16
|
+
e.classList.toggle(p, !0);
|
|
17
|
+
let i = e.getBoundingClientRect().height;
|
|
18
|
+
return e.classList.toggle(p, t), e.style.height = n, e.getBoundingClientRect(), e.classList.remove(h), {
|
|
19
|
+
expanded: r,
|
|
20
|
+
collapsed: i
|
|
21
|
+
};
|
|
22
|
+
}, v = (e, t) => {
|
|
23
|
+
let n = i(e, t);
|
|
24
|
+
return t ? n : {
|
|
25
|
+
height: null,
|
|
26
|
+
reserve: n.reserve
|
|
27
|
+
};
|
|
28
|
+
}, y = (e, t, n) => {
|
|
29
|
+
let r = () => {
|
|
30
|
+
t.height === null ? e.style.removeProperty("height") : e.style.height = `${t.height}px`, e.style.setProperty("--kapi-pageheader-reserve", `${t.reserve}px`);
|
|
31
|
+
};
|
|
32
|
+
n ? r() : (e.style.transition = "none", r(), e.getBoundingClientRect(), e.style.transition = "");
|
|
33
|
+
};
|
|
34
|
+
function b({ title: p, subtitle: h, meta: b, actions: x, chip: S, collapseOnScroll: C = !0, sticky: w = !0, scrollRoot: T = null, responsive: E = !0, className: D, ...O }) {
|
|
35
|
+
let { collapsed: k, sentinelRef: A } = r({ root: T }), j = C && k, M = u(null), N = u({
|
|
36
|
+
expanded: 0,
|
|
37
|
+
collapsed: 0
|
|
38
|
+
}), P = u(j);
|
|
39
|
+
P.current = j;
|
|
40
|
+
let F = u(!1), I = u(!1);
|
|
41
|
+
l(() => {
|
|
42
|
+
let e = M.current;
|
|
12
43
|
if (!e) return;
|
|
13
|
-
let
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
44
|
+
let t = () => {
|
|
45
|
+
I.current || (N.current = _(e, P.current), y(e, v(N.current, P.current), !1));
|
|
46
|
+
};
|
|
47
|
+
t();
|
|
48
|
+
let n = !0;
|
|
49
|
+
if (document.fonts?.ready.then(() => {
|
|
50
|
+
n && t();
|
|
51
|
+
}), typeof ResizeObserver > "u") return () => {
|
|
52
|
+
n = !1;
|
|
53
|
+
};
|
|
54
|
+
let r = e.getBoundingClientRect().width, i = new ResizeObserver((e) => {
|
|
55
|
+
let n = e[e.length - 1];
|
|
56
|
+
if (!n) return;
|
|
57
|
+
let i = n.borderBoxSize?.[0]?.inlineSize ?? n.contentRect.width;
|
|
58
|
+
i !== r && (r = i, t());
|
|
59
|
+
});
|
|
60
|
+
return i.observe(e), () => {
|
|
61
|
+
n = !1, i.disconnect();
|
|
18
62
|
};
|
|
19
|
-
if (n(), typeof ResizeObserver > "u") return;
|
|
20
|
-
let r = new ResizeObserver(n);
|
|
21
|
-
return r.observe(e), () => r.disconnect();
|
|
22
63
|
}, [
|
|
64
|
+
p,
|
|
65
|
+
h,
|
|
23
66
|
b,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
67
|
+
x,
|
|
68
|
+
S,
|
|
69
|
+
C,
|
|
70
|
+
E
|
|
71
|
+
]), l(() => {
|
|
72
|
+
let n = M.current;
|
|
73
|
+
if (!n) return;
|
|
74
|
+
let { expanded: r } = N.current, a = i(N.current, j), o = F.current && !e(n);
|
|
75
|
+
F.current = !0;
|
|
76
|
+
let s = () => {
|
|
77
|
+
I.current = !1, n.classList.remove(m), j || n.style.removeProperty("height");
|
|
78
|
+
};
|
|
79
|
+
if (!o) {
|
|
80
|
+
y(n, v(N.current, j), !1);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
n.style.height === "" && r > 0 && (n.style.height = `${r}px`, n.getBoundingClientRect()), I.current = !0, n.classList.add(m), y(n, a, !0);
|
|
84
|
+
let c = (e) => {
|
|
85
|
+
e.target === n && e.propertyName === "height" && s();
|
|
86
|
+
};
|
|
87
|
+
n.addEventListener("transitionend", c);
|
|
88
|
+
let l = getComputedStyle(n), u = window.setTimeout(s, t(l.transitionDuration, l.transitionDelay) + g);
|
|
89
|
+
return () => {
|
|
90
|
+
n.removeEventListener("transitionend", c), window.clearTimeout(u);
|
|
91
|
+
};
|
|
92
|
+
}, [j]);
|
|
93
|
+
let L = [
|
|
32
94
|
"kapi-pageheader",
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
].filter(Boolean).join(" ");
|
|
38
|
-
|
|
39
|
-
|
|
95
|
+
w && "kapi-pageheader--sticky",
|
|
96
|
+
E && "kapi-pageheader--cq",
|
|
97
|
+
j && "kapi-pageheader--collapsed",
|
|
98
|
+
D
|
|
99
|
+
].filter(Boolean).join(" "), R = n(), z = R?.addHost;
|
|
100
|
+
c(() => z?.(), [z]);
|
|
101
|
+
let B = R?.info ?? null, V = B?.side === "right" ? d : f;
|
|
102
|
+
return /* @__PURE__ */ s(a, { children: [/* @__PURE__ */ o("div", {
|
|
103
|
+
ref: A,
|
|
40
104
|
className: "kapi-pageheader__sentinel",
|
|
41
105
|
"aria-hidden": !0
|
|
42
|
-
}), /* @__PURE__ */
|
|
43
|
-
...
|
|
44
|
-
ref:
|
|
45
|
-
className:
|
|
46
|
-
children: [
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
c && /* @__PURE__ */ r("div", {
|
|
57
|
-
className: "kapi-pageheader__subtitle",
|
|
58
|
-
children: c
|
|
59
|
-
}),
|
|
60
|
-
l && /* @__PURE__ */ r("div", {
|
|
61
|
-
className: "kapi-pageheader__meta",
|
|
62
|
-
children: l
|
|
106
|
+
}), /* @__PURE__ */ s("header", {
|
|
107
|
+
...O,
|
|
108
|
+
ref: M,
|
|
109
|
+
className: L,
|
|
110
|
+
children: [
|
|
111
|
+
B && /* @__PURE__ */ o("button", {
|
|
112
|
+
type: "button",
|
|
113
|
+
className: "kapi-paneltoggle kapi-pageheader__reopen",
|
|
114
|
+
onClick: B.expand,
|
|
115
|
+
"aria-label": B.label,
|
|
116
|
+
children: /* @__PURE__ */ o(V, {
|
|
117
|
+
size: 16,
|
|
118
|
+
strokeWidth: 2,
|
|
119
|
+
"aria-hidden": "true"
|
|
63
120
|
})
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
121
|
+
}),
|
|
122
|
+
/* @__PURE__ */ s("div", {
|
|
123
|
+
className: "kapi-pageheader__main",
|
|
124
|
+
children: [
|
|
125
|
+
/* @__PURE__ */ s("div", {
|
|
126
|
+
className: "kapi-pageheader__titlerow",
|
|
127
|
+
children: [/* @__PURE__ */ o("h1", {
|
|
128
|
+
className: "kapi-pageheader__title",
|
|
129
|
+
children: p
|
|
130
|
+
}), S]
|
|
131
|
+
}),
|
|
132
|
+
h && /* @__PURE__ */ o("div", {
|
|
133
|
+
className: "kapi-pageheader__subtitle",
|
|
134
|
+
children: h
|
|
135
|
+
}),
|
|
136
|
+
b && /* @__PURE__ */ o("div", {
|
|
137
|
+
className: "kapi-pageheader__meta",
|
|
138
|
+
children: b
|
|
139
|
+
})
|
|
140
|
+
]
|
|
141
|
+
}),
|
|
142
|
+
x && /* @__PURE__ */ o("div", {
|
|
143
|
+
className: "kapi-pageheader__actions",
|
|
144
|
+
children: x
|
|
145
|
+
})
|
|
146
|
+
]
|
|
69
147
|
})] });
|
|
70
148
|
}
|
|
71
149
|
//#endregion
|
|
72
|
-
export {
|
|
150
|
+
export { b as KapiPageHeader };
|
|
@@ -7,13 +7,18 @@ export type { KapiRailEntry, KapiRailItem, KapiRailPinned, KapiRailSeparator, Ka
|
|
|
7
7
|
export type KapiRailLabels = {
|
|
8
8
|
/** Nombre accesible del `<nav>` (sin `aria-label`). */
|
|
9
9
|
navigation: string;
|
|
10
|
+
/** Texto del ítem que, en la barra inferior del celular, guarda los destinos que no entran. */
|
|
11
|
+
more: string;
|
|
12
|
+
/** Se suma al nombre accesible del «Más» cuando el destino activo quedó guardado adentro. */
|
|
13
|
+
moreCurrent: string;
|
|
10
14
|
};
|
|
11
15
|
export declare const DEFAULT_RAIL_LABELS: KapiRailLabels;
|
|
12
16
|
/** Atributos nativos (`id`, `style`, `data-*`…) van al `<nav>`. `Id` se infiere de `items`. */
|
|
13
17
|
export type KapiRailProps<Id extends string = string> = Omit<HTMLAttributes<HTMLElement>, "children" | "onSelect"> & {
|
|
14
18
|
/**
|
|
15
19
|
* Ítems del rail. Intercala `{ separator: true }` para dibujar un divisor entre grupos. Con `pinned: "start"`
|
|
16
|
-
* o `"end"` el ítem queda fijo arriba o abajo; el resto va en la zona del medio, la única que scrollea
|
|
20
|
+
* o `"end"` el ítem queda fijo arriba o abajo; el resto va en la zona del medio, la única que scrollea
|
|
21
|
+
* (en vertical) y la única que, en la barra inferior del celular, esconde en «Más» lo que no entra.
|
|
17
22
|
*/
|
|
18
23
|
items: KapiRailEntry<Id>[];
|
|
19
24
|
/** id del ítem activo (controlado por la app: derívalo de tu router). */
|
|
@@ -35,6 +40,7 @@ export type KapiRailProps<Id extends string = string> = Omit<HTMLAttributes<HTML
|
|
|
35
40
|
/**
|
|
36
41
|
* Rail de navegación (Nav A): ícono + nombre debajo. OPCIONAL en el shell.
|
|
37
42
|
* Es presentacional: no conoce el router; la app pasa `activeId` y `onSelect`.
|
|
38
|
-
* En móvil se convierte en barra inferior (shell.css)
|
|
43
|
+
* En móvil se convierte en barra inferior (shell.css): muestra los ítems del medio que entran y manda el
|
|
44
|
+
* resto a un ítem «Más» que abre un menú hacia arriba. Los ítems fijos y el footer no se tocan.
|
|
39
45
|
*/
|
|
40
46
|
export declare const KapiRail: <Id extends string = string>({ items, activeId, onSelect, brand, footer, variant, "aria-label": ariaLabel, labels, className, ...rest }: KapiRailProps<Id>) => import("react").JSX.Element;
|