@kapiuara/ui 0.10.0 → 0.12.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 +93 -0
- package/dist/components/data/KapiBarChart.js +88 -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 +59 -0
- package/dist/components/data/KapiLineChart.js +106 -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.d.ts +25 -2
- 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 +112 -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 +20 -1
- 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/KapiFacetedSearch.d.ts +9 -2
- package/dist/components/inputs/KapiFacetedSearch.js +3 -3
- package/dist/components/inputs/KapiSearchChip.d.ts +79 -0
- package/dist/components/inputs/KapiSearchChip.js +73 -0
- 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/inputs/index.d.ts +2 -0
- package/dist/components/inputs/searchChipLogic.d.ts +33 -0
- package/dist/components/inputs/searchChipLogic.js +13 -0
- package/dist/components/labelsLogic.d.ts +11 -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 +12 -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/KapiConfirm.d.ts +14 -2
- package/dist/components/overlays/KapiConfirm.js +2 -2
- 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 +149 -137
- package/dist/kapi.css +1 -1
- package/dist/kapi.layered.css +1 -1
- package/package.json +2 -6
|
@@ -11,21 +11,40 @@ export declare const isCompleteRange: (range: KapiDateRange) => boolean;
|
|
|
11
11
|
export declare const sameRange: (a: KapiDateRange, b: KapiDateRange) => boolean;
|
|
12
12
|
/**
|
|
13
13
|
* Click en un día del calendario: el primero arranca el rango, el segundo lo cierra (ordenando las
|
|
14
|
-
* puntas). Con un rango ya completo, el click empieza uno nuevo.
|
|
14
|
+
* puntas). Con un rango ya completo, el click empieza uno nuevo. Con un `hasta` abierto vigente, en
|
|
15
|
+
* cambio, el click completa el `desde` en vez de empezar de cero: descartarlo perdería la punta que
|
|
16
|
+
* el usuario ya había elegido.
|
|
15
17
|
*/
|
|
16
18
|
export declare const pickRangeDay: (range: KapiDateRange, day: Date) => KapiDateRange;
|
|
19
|
+
/**
|
|
20
|
+
* El único día elegido del borrador: la punta que se puede confirmar dejando la otra abierta.
|
|
21
|
+
* `null` con las dos puntas o con ninguna, que es cuando no hay nada que dejar abierto.
|
|
22
|
+
*/
|
|
23
|
+
export declare const openEndedDay: (range: KapiDateRange) => Date | null;
|
|
17
24
|
export type RangeDayState = "start" | "end" | "in" | "single" | null;
|
|
18
25
|
/**
|
|
19
26
|
* Cómo se pinta un día: extremo inicial/final, intermedio, rango de un día o nada. Con sólo el inicio
|
|
20
27
|
* elegido, `hover` previsualiza el rango hacia el día bajo el puntero (en cualquier dirección).
|
|
21
28
|
*/
|
|
22
29
|
export declare const rangeDayState: (day: Date, range: KapiDateRange, hover?: Date | null) => RangeDayState;
|
|
23
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* `dd/mm/aaaa – dd/mm/aaaa`; vacío sin nada. Una punta sola se muestra CON el separador
|
|
32
|
+
* (`10/03/2026 –`, `– 10/03/2026`): deja ver que la otra está abierta a propósito, en vez de
|
|
33
|
+
* parecer un rango a medio llenar.
|
|
34
|
+
*/
|
|
24
35
|
export declare const formatRange: (range: KapiDateRange) => string;
|
|
25
|
-
/**
|
|
36
|
+
/**
|
|
37
|
+
* Máscara de teclado: 16 dígitos repartidos en `dd/mm/aaaa – dd/mm/aaaa`. El guion es DATO y no
|
|
38
|
+
* ruido —de qué lado está dice qué punta se está escribiendo—, así que cada lado se enmascara por
|
|
39
|
+
* separado; sin guion se reparten los 16 dígitos como siempre, así tipear derecho sigue armando el
|
|
40
|
+
* rango completo sin tocar una tecla nueva.
|
|
41
|
+
*/
|
|
26
42
|
export declare const maskRangeInput: (raw: string) => string;
|
|
27
43
|
/**
|
|
28
44
|
* Parsea el texto tipeado. `null`: vacío (borrar). `undefined`: incompleto o inválido (el caller
|
|
29
|
-
* restaura el último rango válido). Si las fechas vienen invertidas, las ordena.
|
|
45
|
+
* restaura el último rango válido). Si las fechas vienen invertidas, las ordena. Acepta una sola
|
|
46
|
+
* punta, pero sólo con el separador escrito: `10/03/2026 –` es "sólo desde" y `– 10/03/2026` es
|
|
47
|
+
* "sólo hasta". Una fecha sin separador sigue siendo borrador, porque sola no dice qué punta es; el
|
|
48
|
+
* separador solo también, porque vaciar el campo es la forma de no filtrar.
|
|
30
49
|
*/
|
|
31
50
|
export declare const parseRangeText: (text: string) => KapiDateRange | null | undefined;
|
|
@@ -3,42 +3,68 @@ import { formatValue as e, maskInput as t, parseText as n, sameDay as r } from "
|
|
|
3
3
|
var i = {
|
|
4
4
|
from: null,
|
|
5
5
|
to: null
|
|
6
|
-
}, a = " – ", o = (e) => new Date(e.getFullYear(), e.getMonth(), e.getDate()),
|
|
7
|
-
let n =
|
|
6
|
+
}, a = " – ", o = a.trimEnd(), s = a.trimStart(), c = a.trim(), l = (e) => e.replace(/\D/g, ""), u = (e) => new Date(e.getFullYear(), e.getMonth(), e.getDate()), d = (e, t) => u(e) <= u(t) ? [e, t] : [t, e], f = (e) => !!e.from && !!e.to, p = (e, t) => (e.from ? r(e.from, t.from) : !t.from) && (e.to ? r(e.to, t.to) : !t.to), m = (e, t) => {
|
|
7
|
+
let n = u(t);
|
|
8
|
+
if (!e.from && e.to) {
|
|
9
|
+
let [t, r] = d(n, e.to);
|
|
10
|
+
return {
|
|
11
|
+
from: u(t),
|
|
12
|
+
to: u(r)
|
|
13
|
+
};
|
|
14
|
+
}
|
|
8
15
|
if (!e.from || e.to) return {
|
|
9
16
|
from: n,
|
|
10
17
|
to: null
|
|
11
18
|
};
|
|
12
|
-
let [r, i] =
|
|
19
|
+
let [r, i] = d(e.from, n);
|
|
13
20
|
return {
|
|
14
|
-
from:
|
|
15
|
-
to:
|
|
21
|
+
from: u(r),
|
|
22
|
+
to: u(i)
|
|
16
23
|
};
|
|
17
|
-
},
|
|
24
|
+
}, h = (e) => !!e.from == !!e.to ? null : e.from ?? e.to ?? null, g = (e, t, n) => {
|
|
18
25
|
if (!t.from) return null;
|
|
19
26
|
let i = t.to ?? n ?? null;
|
|
20
27
|
if (!i) return r(e, t.from) ? "single" : null;
|
|
21
|
-
let [a,
|
|
22
|
-
if (r(a,
|
|
28
|
+
let [a, o] = d(t.from, i);
|
|
29
|
+
if (r(a, o)) return r(e, a) ? "single" : null;
|
|
23
30
|
if (r(e, a)) return "start";
|
|
24
|
-
if (r(e,
|
|
25
|
-
let
|
|
26
|
-
return
|
|
27
|
-
},
|
|
28
|
-
let n =
|
|
29
|
-
return
|
|
30
|
-
},
|
|
31
|
+
if (r(e, o)) return "end";
|
|
32
|
+
let s = u(e).getTime();
|
|
33
|
+
return s > u(a).getTime() && s < u(o).getTime() ? "in" : null;
|
|
34
|
+
}, _ = (t) => {
|
|
35
|
+
let n = e(t.from, "date"), r = e(t.to, "date");
|
|
36
|
+
return n && r ? `${n}${a}${r}` : n ? `${n}${o}` : r ? `${s}${r}` : "";
|
|
37
|
+
}, v = (e) => {
|
|
38
|
+
let n = e || "", r = n.search(/[–-]/);
|
|
39
|
+
if (r >= 0) {
|
|
40
|
+
let e = t(l(n.slice(0, r)).slice(0, 8), "date"), i = t(l(n.slice(r + 1)).slice(0, 8), "date");
|
|
41
|
+
return e && i ? `${e}${a}${i}` : e ? `${e}${o}` : i ? `${s}${i}` : c;
|
|
42
|
+
}
|
|
43
|
+
let i = l(n).slice(0, 16), u = t(i.slice(0, 8), "date"), d = t(i.slice(8), "date");
|
|
44
|
+
return d ? `${u}${a}${d}` : u;
|
|
45
|
+
}, y = (e) => {
|
|
31
46
|
let t = (e || "").trim();
|
|
32
47
|
if (!t) return null;
|
|
33
48
|
let r = t.split(/\s*[–-]\s*/);
|
|
34
49
|
if (r.length !== 2) return;
|
|
35
50
|
let i = n(r[0], "date"), a = n(r[1], "date");
|
|
36
|
-
if (
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
51
|
+
if (i && a) {
|
|
52
|
+
let [e, t] = d(i, a);
|
|
53
|
+
return {
|
|
54
|
+
from: e,
|
|
55
|
+
to: t
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
if (i !== void 0 && a !== void 0) {
|
|
59
|
+
if (i) return {
|
|
60
|
+
from: i,
|
|
61
|
+
to: null
|
|
62
|
+
};
|
|
63
|
+
if (a) return {
|
|
64
|
+
from: null,
|
|
65
|
+
to: a
|
|
66
|
+
};
|
|
67
|
+
}
|
|
42
68
|
};
|
|
43
69
|
//#endregion
|
|
44
|
-
export { i as EMPTY_RANGE, a as RANGE_SEPARATOR,
|
|
70
|
+
export { i as EMPTY_RANGE, a as RANGE_SEPARATOR, _ as formatRange, f as isCompleteRange, v as maskRangeInput, h as openEndedDay, y as parseRangeText, m as pickRangeDay, g as rangeDayState, p as sameRange };
|
|
@@ -51,7 +51,7 @@ export type KapiFacetChip = {
|
|
|
51
51
|
};
|
|
52
52
|
/**
|
|
53
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 "
|
|
54
|
+
* espacios cuenta como ausente, para no dibujar un "Estado: " colgado. Con un operador que no es `eq`
|
|
55
55
|
* suma su texto: `label operatorText: value`. La función es pura: recibe el texto del operador ya
|
|
56
56
|
* resuelto (traducido), no lo traduce. Lo usan el texto visible y el nombre accesible del botón de
|
|
57
57
|
* quitar, así dos chips de la misma faceta no suenan idénticos.
|
|
@@ -49,6 +49,8 @@ export { KapiRating, DEFAULT_RATING_LABELS, ratingClasses } from "./KapiRating";
|
|
|
49
49
|
export type { KapiRatingLabels, KapiRatingProps, KapiRatingSize } from "./KapiRating";
|
|
50
50
|
export { KapiAutocomplete, DEFAULT_AUTOCOMPLETE_LABELS } from "./KapiAutocomplete";
|
|
51
51
|
export type { KapiAutocompleteLabels, KapiAutocompleteProps, KapiAutocompleteRenderContext } from "./KapiAutocomplete";
|
|
52
|
+
export { KapiSearchChip, DEFAULT_SEARCH_CHIP_LABELS } from "./KapiSearchChip";
|
|
53
|
+
export type { KapiSearchChipLabels, KapiSearchChipProps } from "./KapiSearchChip";
|
|
52
54
|
export { KapiFacetedSearch, DEFAULT_FACETED_SEARCH_LABELS } from "./KapiFacetedSearch";
|
|
53
55
|
export type { KapiFacetedSearchLabels, KapiFacetedSearchProps } from "./KapiFacetedSearch";
|
|
54
56
|
export { facetKeyAction, facetMenuItems, facetOperators, parseDateRangeValue, toDateRangeValue, toDateValue } from "./facetedSearchLogic";
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Nombre accesible del campo. Precedencia: `aria-label` del consumidor > el placeholder sin su
|
|
3
|
+
* puntuación de cierre > `fallback` (el texto `search` de los labels).
|
|
4
|
+
*
|
|
5
|
+
* Por qué se deriva del placeholder en vez de pedir siempre un `aria-label`: el marcado a mano que
|
|
6
|
+
* este componente reemplaza escribía las dos cosas, y eran la MISMA frase dos veces
|
|
7
|
+
* (`placeholder="Buscar por mesa, materia o fecha…"` + `aria-label="Buscar por mesa, materia o
|
|
8
|
+
* fecha"`). Dos strings que dicen lo mismo se desincronizan en cuanto alguien edita uno: la frase
|
|
9
|
+
* visible cambia y el nombre que lee el lector de pantalla se queda viejo, sin que nada falle.
|
|
10
|
+
* Derivarlo deja una sola frase para mantener.
|
|
11
|
+
*
|
|
12
|
+
* Y el nombre NO depende de que el placeholder esté a la vista: lo que se deriva es el texto, que
|
|
13
|
+
* queda fijo en el `aria-label`. Cuando el placeholder desaparece porque hay valor tipeado —el
|
|
14
|
+
* motivo real por el que un placeholder no alcanza como etiqueta— el nombre sigue ahí.
|
|
15
|
+
*
|
|
16
|
+
* Se recorta la puntuación de cierre (`…`, `...`, puntos y espacios) porque la elipsis es una pista
|
|
17
|
+
* visual de «sigue escribiendo», no parte del nombre, y un lector de pantalla la pronunciaría.
|
|
18
|
+
*/
|
|
19
|
+
export declare const searchChipName: ({ ariaLabel, placeholder, fallback }: {
|
|
20
|
+
ariaLabel?: string | undefined;
|
|
21
|
+
placeholder?: string | undefined;
|
|
22
|
+
fallback: string;
|
|
23
|
+
}) => string;
|
|
24
|
+
/**
|
|
25
|
+
* Clases de la caja del chip. `kapi-filterchip` es la caja del disparador de `KapiDropdown` y la
|
|
26
|
+
* trae tal cual: es lo que hace que los dos chips de una misma fila de filtros tengan la misma
|
|
27
|
+
* caja, el mismo alto y el mismo borde sin que nadie los mantenga iguales a mano.
|
|
28
|
+
* `is-disabled` es la misma clase de estado que usa la caja de `KapiInput` (`inputBoxClasses`).
|
|
29
|
+
*/
|
|
30
|
+
export declare const searchChipClasses: ({ disabled, className }?: {
|
|
31
|
+
disabled?: boolean | undefined;
|
|
32
|
+
className?: string | undefined;
|
|
33
|
+
}) => string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region src/components/inputs/searchChipLogic.ts
|
|
2
|
+
var e = ({ ariaLabel: e, placeholder: t, fallback: n }) => {
|
|
3
|
+
if (e !== void 0 && e.trim() !== "") return e;
|
|
4
|
+
let r = (t ?? "").replace(/[\s.…]+$/u, "").trim();
|
|
5
|
+
return r === "" ? n : r;
|
|
6
|
+
}, t = ({ disabled: e = !1, className: t = "" } = {}) => [
|
|
7
|
+
"kapi-filterchip",
|
|
8
|
+
"kapi-searchchip",
|
|
9
|
+
e && "is-disabled",
|
|
10
|
+
t
|
|
11
|
+
].filter(Boolean).join(" ");
|
|
12
|
+
//#endregion
|
|
13
|
+
export { t as searchChipClasses, e as searchChipName };
|
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* Overrides de textos por clave (prop `labels`): cada clave puede faltar o venir en `undefined`.
|
|
3
|
+
*
|
|
4
|
+
* Ninguna clave de labels puede llamarse como un miembro de `Object.prototype` (`valueOf`,
|
|
5
|
+
* `toString`, `constructor`, `hasOwnProperty`, `isPrototypeOf`, `propertyIsEnumerable`,
|
|
6
|
+
* `toLocaleString`): TypeScript ve el miembro heredado en el tipo aparente de todo objeto literal,
|
|
7
|
+
* compara su firma contra `string` y rechaza la prop ENTERA, no sólo esa clave. El consumidor ve un
|
|
8
|
+
* TS2322 que nombra una clave que nunca escribió, y el contrato de arriba deja de valer para ese
|
|
9
|
+
* tipo completo. Pasó con `valueOf` en `KapiFacetedSearchLabels` (hoy `valuePrefix`). Lo barre
|
|
10
|
+
* `labels.types.test.tsx` sobre todo `KapiLabelRegistry`, en `pnpm typecheck`.
|
|
11
|
+
*/
|
|
2
12
|
export type KapiLabelsOverride<L> = {
|
|
3
13
|
[K in keyof L]?: L[K] | undefined;
|
|
4
14
|
};
|
|
@@ -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 };
|