@kapiuara/ui 0.10.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -5
- package/dist/components/data/KapiBarChart.d.ts +84 -0
- package/dist/components/data/KapiBarChart.js +87 -0
- package/dist/components/data/KapiEventCalendar.d.ts +70 -0
- package/dist/components/data/KapiEventCalendar.js +225 -0
- package/dist/components/data/KapiHeatmap.d.ts +62 -0
- package/dist/components/data/KapiHeatmap.js +120 -0
- package/dist/components/data/KapiLineChart.d.ts +50 -0
- package/dist/components/data/KapiLineChart.js +105 -0
- package/dist/components/data/KapiPaginationFooter.js +1 -0
- package/dist/components/data/KapiSparkline.d.ts +41 -0
- package/dist/components/data/KapiSparkline.js +55 -0
- package/dist/components/data/KapiTable.js +371 -359
- package/dist/components/data/barChartLogic.d.ts +59 -0
- package/dist/components/data/barChartLogic.js +53 -0
- package/dist/components/data/chartFrame.d.ts +96 -0
- package/dist/components/data/chartFrame.js +89 -0
- package/dist/components/data/eventCalendarLogic.d.ts +70 -0
- package/dist/components/data/eventCalendarLogic.js +45 -0
- package/dist/components/data/heatmapLogic.d.ts +15 -0
- package/dist/components/data/heatmapLogic.js +15 -0
- package/dist/components/data/index.d.ts +19 -0
- package/dist/components/data/lineChartLogic.d.ts +30 -0
- package/dist/components/data/lineChartLogic.js +21 -0
- package/dist/components/data/sparklineLogic.d.ts +28 -0
- package/dist/components/data/sparklineLogic.js +18 -0
- package/dist/components/display/KapiStat.d.ts +1 -1
- package/dist/components/inputs/KapiDatePicker.d.ts +8 -2
- package/dist/components/inputs/KapiDatePicker.js +120 -106
- package/dist/components/inputs/KapiDateRangePicker.d.ts +26 -5
- package/dist/components/inputs/KapiDateRangePicker.js +146 -111
- package/dist/components/inputs/datePickerLogic.d.ts +9 -0
- package/dist/components/inputs/datePickerLogic.js +25 -25
- package/dist/components/inputs/dateRangeLogic.d.ts +23 -4
- package/dist/components/inputs/dateRangeLogic.js +48 -22
- package/dist/components/inputs/facetedSearchLogic.d.ts +1 -1
- package/dist/components/layout/KapiContextSlot.js +108 -88
- package/dist/components/layout/KapiMasonry.d.ts +30 -0
- package/dist/components/layout/KapiMasonry.js +33 -0
- package/dist/components/layout/KapiPageHeader.js +89 -71
- package/dist/components/layout/KapiRail.d.ts +8 -2
- package/dist/components/layout/KapiRail.js +118 -67
- package/dist/components/layout/KapiShell.js +67 -37
- package/dist/components/layout/index.d.ts +2 -0
- package/dist/components/layout/masonryLogic.d.ts +40 -0
- package/dist/components/layout/masonryLogic.js +8 -0
- package/dist/components/layout/railLogic.d.ts +41 -1
- package/dist/components/layout/railLogic.js +36 -4
- package/dist/components/layout/reopenBus.d.ts +53 -0
- package/dist/components/layout/reopenBus.js +6 -0
- package/dist/components/layout/useMasonrySpans.d.ts +32 -0
- package/dist/components/layout/useMasonrySpans.js +44 -0
- package/dist/components/layout/useRailOverflow.d.ts +17 -0
- package/dist/components/layout/useRailOverflow.js +41 -0
- package/dist/components/locale/labelRegistry.d.ts +10 -1
- package/dist/components/navigation/KapiFilterChips.js +1 -1
- package/dist/components/navigation/filterChipsLogic.d.ts +7 -1
- package/dist/components/navigation/filterChipsLogic.js +3 -3
- package/dist/components/overlays/KapiContextMenu.d.ts +3 -0
- package/dist/components/overlays/KapiContextMenu.js +2 -1
- package/dist/components/overlays/KapiDropdown.d.ts +3 -1
- package/dist/components/overlays/KapiDropdown.js +29 -26
- package/dist/components/overlays/KapiMenuButton.js +1 -0
- package/dist/components/overlays/KapiOffcanvasStack.d.ts +2 -2
- package/dist/hooks/breakpointOpenLogic.d.ts +20 -5
- package/dist/hooks/breakpointOpenLogic.js +2 -2
- package/dist/hooks/dataColorLogic.d.ts +23 -0
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/numberFormatLogic.d.ts +7 -0
- package/dist/hooks/numberFormatLogic.js +5 -2
- package/dist/hooks/seriesPaletteLogic.d.ts +24 -0
- package/dist/hooks/themeContrastLogic.js +1 -0
- package/dist/hooks/themeDeriveLogic.d.ts +8 -0
- package/dist/hooks/themeDeriveLogic.js +4 -2
- package/dist/hooks/useKapiTheme.js +27 -27
- package/dist/hooks/useMediaQuery.d.ts +7 -0
- package/dist/hooks/useMediaQuery.js +4 -4
- package/dist/index.js +125 -114
- package/dist/kapi.css +1 -1
- package/dist/kapi.layered.css +1 -1
- package/package.json +2 -6
|
@@ -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,7 @@ 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
14
|
export { useWheelZoom } from "./useWheelZoom";
|
|
15
15
|
export type { UseWheelZoomOptions } from "./useWheelZoom";
|
|
16
16
|
export { useHotkey } from "./useHotkey";
|
|
@@ -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 = {}) => {
|
|
@@ -41,7 +41,15 @@ export type KapiCustomTheme = {
|
|
|
41
41
|
colors: KapiThemeColors;
|
|
42
42
|
/** The radius knobs; an unset or invalid one leaves its whole tier at the base theme's values. */
|
|
43
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;
|
|
44
50
|
};
|
|
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;
|
|
45
53
|
/** A px length such as `10px` or `999px`: what the `control`, `box` and `surface` knobs accept. */
|
|
46
54
|
export declare const RADIUS_PX_PATTERN: RegExp;
|
|
47
55
|
/** A px length or a percentage such as `32%`: what the `squircle` knob accepts. */
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { contrastRatio as e, formatHex as t, mixColors as n, parseColor as r, readableForeground as i } from "./colorLogic.js";
|
|
2
|
-
//#region src/hooks/themeDeriveLogic.ts
|
|
3
2
|
var a = /^\d+(\.\d+)?px$/, o = /^\d+(\.\d+)?(px|%)$/, s = {
|
|
4
3
|
"--kapi-radius-xs": .6,
|
|
5
4
|
"--kapi-radius-inner": .7,
|
|
@@ -126,7 +125,10 @@ var a = /^\d+(\.\d+)?px$/, o = /^\d+(\.\d+)?(px|%)$/, s = {
|
|
|
126
125
|
strong: .6,
|
|
127
126
|
edge: .06
|
|
128
127
|
};
|
|
129
|
-
return l.has("ink") && !o && (s["--kapi-scrim"] = S(F, I.base), s["--kapi-scrim-soft"] = S(F, I.soft), s["--kapi-scrim-tour"] = S(F, I.tour), s["--kapi-scrim-drawer"] = S(F, I.drawer), s["--kapi-scrim-cmdk"] = S(F, I.cmdk), s["--kapi-scrim-strong"] = S(F, I.strong), s["--kapi-edge-shade"] = S(F, I.edge)),
|
|
128
|
+
return l.has("ink") && !o && (s["--kapi-scrim"] = S(F, I.base), s["--kapi-scrim-soft"] = S(F, I.soft), s["--kapi-scrim-tour"] = S(F, I.tour), s["--kapi-scrim-drawer"] = S(F, I.drawer), s["--kapi-scrim-cmdk"] = S(F, I.cmdk), s["--kapi-scrim-strong"] = S(F, I.strong), s["--kapi-edge-shade"] = S(F, I.edge)), e.series?.slice(0, 8).forEach((e, n) => {
|
|
129
|
+
let i = r(e);
|
|
130
|
+
i && (s[`--kapi-series-${n + 1}`] = t(i));
|
|
131
|
+
}), s;
|
|
130
132
|
};
|
|
131
133
|
//#endregion
|
|
132
134
|
export { a as RADIUS_PX_PATTERN, o as RADIUS_SHAPE_PATTERN, C as deriveTheme };
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import { parseColor as e } from "./colorLogic.js";
|
|
3
|
+
import { deriveTheme as t } from "./themeDeriveLogic.js";
|
|
4
|
+
import { defaultStorage as n, readWithLegacy as r, storageKey as i } from "./storageLogic.js";
|
|
5
|
+
import { useMediaQuery as a } from "./useMediaQuery.js";
|
|
6
6
|
import { NO_THEME_COLORS as o, mergeThemeColors as s, parseStoredThemeColors as c, sanitizeThemeColors as l, serializeThemeColors as u } from "./themeColorsLogic.js";
|
|
7
7
|
import { NO_THEME_RADII as d, mergeThemeRadii as f, parseStoredThemeRadii as p, sanitizeThemeRadii as m, serializeThemeRadii as h } from "./themeRadiiLogic.js";
|
|
8
8
|
import { createContext as g, useCallback as _, useContext as v, useEffect as y, useMemo as b, useState as x } from "react";
|
|
9
9
|
//#region src/hooks/useKapiTheme.ts
|
|
10
10
|
var S = "(prefers-color-scheme: dark)", C = (e) => ({
|
|
11
|
-
theme:
|
|
12
|
-
accent:
|
|
13
|
-
font:
|
|
14
|
-
motion:
|
|
15
|
-
customTheme:
|
|
16
|
-
radii:
|
|
11
|
+
theme: i(e, "theme"),
|
|
12
|
+
accent: i(e, "accent"),
|
|
13
|
+
font: i(e, "font"),
|
|
14
|
+
motion: i(e, "motion"),
|
|
15
|
+
customTheme: i(e, "customTheme"),
|
|
16
|
+
radii: i(e, "radii")
|
|
17
17
|
}), w = {
|
|
18
18
|
theme: "v2_theme",
|
|
19
19
|
accent: "v2_accent",
|
|
@@ -25,24 +25,24 @@ var T = {
|
|
|
25
25
|
nunito: "'Nunito Variable', 'Nunito', system-ui, sans-serif",
|
|
26
26
|
roboto: "'Roboto', system-ui, sans-serif",
|
|
27
27
|
system: "system-ui, -apple-system, 'Segoe UI', sans-serif"
|
|
28
|
-
}, E = (
|
|
28
|
+
}, E = (e, t, i) => r(n(), C(e)[t], w[t]) || i, D = (e, t) => {
|
|
29
29
|
try {
|
|
30
30
|
localStorage.setItem(e, t);
|
|
31
31
|
} catch {}
|
|
32
32
|
}, O = (e) => e === "light" || e === "dark", k = (e) => O(e) || e === "system", A = (e, t) => e === "system" ? t ? "dark" : "light" : e, j = (e) => {
|
|
33
33
|
let t = E(e, "theme", "light");
|
|
34
34
|
return k(t) ? t : "light";
|
|
35
|
-
}, M = (e) => e === "dark" ? "light" : "dark", N = (e) => e in T, P = (e) => e === "auto" || e === "reduced", F = (
|
|
36
|
-
let
|
|
37
|
-
...
|
|
35
|
+
}, M = (e) => e === "dark" ? "light" : "dark", N = (e) => e in T, P = (e) => e === "auto" || e === "reduced", F = (n, r) => {
|
|
36
|
+
let i = n.fontChosen && r ? {
|
|
37
|
+
...r,
|
|
38
38
|
font: void 0
|
|
39
|
-
} :
|
|
40
|
-
return o && delete
|
|
41
|
-
"--kapi-font": T[
|
|
42
|
-
...
|
|
43
|
-
base:
|
|
44
|
-
colors:
|
|
45
|
-
radii: f(
|
|
39
|
+
} : r, a = s(i, n.accent ? { primary: n.accent } : null, n.customTheme), o = a.primary && !e(a.primary) ? a.primary : void 0;
|
|
40
|
+
return o && delete a.primary, {
|
|
41
|
+
"--kapi-font": T[n.font] ?? T.nunito,
|
|
42
|
+
...t({
|
|
43
|
+
base: n.theme ?? "light",
|
|
44
|
+
colors: a,
|
|
45
|
+
radii: f(n.radii)
|
|
46
46
|
}),
|
|
47
47
|
...o ? { "--kapi-primary": o } : {}
|
|
48
48
|
};
|
|
@@ -65,7 +65,7 @@ var T = {
|
|
|
65
65
|
setMotion: () => {},
|
|
66
66
|
toggleMotion: () => {}
|
|
67
67
|
}), L = ({ namespace: e } = {}) => {
|
|
68
|
-
let t = b(() => C(e), [e]), [n,
|
|
68
|
+
let t = b(() => C(e), [e]), [n, r] = x(() => j(e)), i = A(n, a(S)), [o, s] = x(() => E(e, "accent", "")), [d, f] = x(() => c(E(e, "customTheme", ""))), [g, v] = x(() => p(E(e, "radii", ""))), [w, T] = x(() => N(E(e, "font", ""))), [O, k] = x(() => {
|
|
69
69
|
let t = E(e, "font", "nunito");
|
|
70
70
|
return N(t) ? t : "nunito";
|
|
71
71
|
}), [F, I] = x(() => {
|
|
@@ -73,7 +73,7 @@ var T = {
|
|
|
73
73
|
return P(t) ? t : "auto";
|
|
74
74
|
}), [L, R] = x(e);
|
|
75
75
|
if (L !== e) {
|
|
76
|
-
R(e),
|
|
76
|
+
R(e), r(j(e)), s(E(e, "accent", "")), f(c(E(e, "customTheme", ""))), v(p(E(e, "radii", "")));
|
|
77
77
|
let t = E(e, "font", "nunito");
|
|
78
78
|
k(N(t) ? t : "nunito"), T(N(E(e, "font", "")));
|
|
79
79
|
let n = E(e, "motion", "auto");
|
|
@@ -86,11 +86,11 @@ var T = {
|
|
|
86
86
|
O,
|
|
87
87
|
w
|
|
88
88
|
]), y(() => D(t.motion, F), [t, F]);
|
|
89
|
-
let z = _(() =>
|
|
89
|
+
let z = _(() => r(M(i)), [i]), B = _((e) => r(e), []), V = _((e) => s(e || ""), []), H = _((e) => f(l(e)), []), U = _((e) => v(m(e)), []), W = _((e) => {
|
|
90
90
|
k(e), T(!0);
|
|
91
91
|
}, []), G = _(() => I((e) => e === "reduced" ? "auto" : "reduced"), []);
|
|
92
92
|
return b(() => ({
|
|
93
|
-
theme:
|
|
93
|
+
theme: i,
|
|
94
94
|
preference: n,
|
|
95
95
|
accent: o,
|
|
96
96
|
customTheme: d,
|
|
@@ -99,7 +99,7 @@ var T = {
|
|
|
99
99
|
fontChosen: w,
|
|
100
100
|
motion: F,
|
|
101
101
|
setTheme: B,
|
|
102
|
-
setPreference:
|
|
102
|
+
setPreference: r,
|
|
103
103
|
toggle: z,
|
|
104
104
|
setAccent: V,
|
|
105
105
|
setCustomTheme: H,
|
|
@@ -108,7 +108,7 @@ var T = {
|
|
|
108
108
|
setMotion: I,
|
|
109
109
|
toggleMotion: G
|
|
110
110
|
}), [
|
|
111
|
-
|
|
111
|
+
i,
|
|
112
112
|
n,
|
|
113
113
|
o,
|
|
114
114
|
d,
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
/** Breakpoint móvil del shell (mantener sincronizado con shell.css). */
|
|
2
2
|
export declare const SHELL_MOBILE_QUERY = "(max-width: 768px)";
|
|
3
|
+
/**
|
|
4
|
+
* Escritorio angosto: el rail sigue vertical pero el panel ya no entra cómodo. 1024 no es un
|
|
5
|
+
* número nuevo, es el breakpoint que la cáscara ya usa para su padding (`shell.css`). Medido con
|
|
6
|
+
* rail y panel abiertos, el contenido queda en 674px a 1024 contra 930 a 1280; plegando el panel
|
|
7
|
+
* a su riel de 44px recupera 214.
|
|
8
|
+
*/
|
|
9
|
+
export declare const SHELL_NARROW_QUERY = "(max-width: 1024px)";
|
|
3
10
|
/** `matchMedia` seguro (SSR / jsdom sin matchMedia → false). */
|
|
4
11
|
export declare const matchesQuery: (query: string) => boolean;
|
|
5
12
|
/** true mientras el viewport cumple la media query. */
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useEffect as e, useState as t } from "react";
|
|
3
3
|
//#region src/hooks/useMediaQuery.ts
|
|
4
|
-
var n = "(max-width: 768px)", r = (e) => typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia(e).matches,
|
|
5
|
-
let [
|
|
4
|
+
var n = "(max-width: 768px)", r = "(max-width: 1024px)", i = (e) => typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia(e).matches, a = (n) => {
|
|
5
|
+
let [r, a] = t(() => i(n));
|
|
6
6
|
return e(() => {
|
|
7
7
|
if (typeof window.matchMedia != "function") return;
|
|
8
8
|
let e = window.matchMedia(n), t = () => a(e.matches);
|
|
9
9
|
return t(), e.addEventListener("change", t), () => e.removeEventListener("change", t);
|
|
10
|
-
}, [n]),
|
|
10
|
+
}, [n]), r;
|
|
11
11
|
};
|
|
12
12
|
//#endregion
|
|
13
|
-
export { n as SHELL_MOBILE_QUERY, r as
|
|
13
|
+
export { n as SHELL_MOBILE_QUERY, r as SHELL_NARROW_QUERY, i as matchesQuery, a as useMediaQuery };
|