@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.
Files changed (92) hide show
  1. package/README.md +10 -5
  2. package/dist/components/data/KapiBarChart.d.ts +93 -0
  3. package/dist/components/data/KapiBarChart.js +88 -0
  4. package/dist/components/data/KapiEventCalendar.d.ts +70 -0
  5. package/dist/components/data/KapiEventCalendar.js +225 -0
  6. package/dist/components/data/KapiHeatmap.d.ts +62 -0
  7. package/dist/components/data/KapiHeatmap.js +120 -0
  8. package/dist/components/data/KapiLineChart.d.ts +59 -0
  9. package/dist/components/data/KapiLineChart.js +106 -0
  10. package/dist/components/data/KapiPaginationFooter.js +1 -0
  11. package/dist/components/data/KapiSparkline.d.ts +41 -0
  12. package/dist/components/data/KapiSparkline.js +55 -0
  13. package/dist/components/data/KapiTable.d.ts +25 -2
  14. package/dist/components/data/KapiTable.js +371 -359
  15. package/dist/components/data/barChartLogic.d.ts +59 -0
  16. package/dist/components/data/barChartLogic.js +53 -0
  17. package/dist/components/data/chartFrame.d.ts +112 -0
  18. package/dist/components/data/chartFrame.js +89 -0
  19. package/dist/components/data/eventCalendarLogic.d.ts +70 -0
  20. package/dist/components/data/eventCalendarLogic.js +45 -0
  21. package/dist/components/data/heatmapLogic.d.ts +15 -0
  22. package/dist/components/data/heatmapLogic.js +15 -0
  23. package/dist/components/data/index.d.ts +20 -1
  24. package/dist/components/data/lineChartLogic.d.ts +30 -0
  25. package/dist/components/data/lineChartLogic.js +21 -0
  26. package/dist/components/data/sparklineLogic.d.ts +28 -0
  27. package/dist/components/data/sparklineLogic.js +18 -0
  28. package/dist/components/display/KapiStat.d.ts +1 -1
  29. package/dist/components/inputs/KapiDatePicker.d.ts +8 -2
  30. package/dist/components/inputs/KapiDatePicker.js +120 -106
  31. package/dist/components/inputs/KapiDateRangePicker.d.ts +26 -5
  32. package/dist/components/inputs/KapiDateRangePicker.js +146 -111
  33. package/dist/components/inputs/KapiFacetedSearch.d.ts +9 -2
  34. package/dist/components/inputs/KapiFacetedSearch.js +3 -3
  35. package/dist/components/inputs/KapiSearchChip.d.ts +79 -0
  36. package/dist/components/inputs/KapiSearchChip.js +73 -0
  37. package/dist/components/inputs/datePickerLogic.d.ts +9 -0
  38. package/dist/components/inputs/datePickerLogic.js +25 -25
  39. package/dist/components/inputs/dateRangeLogic.d.ts +23 -4
  40. package/dist/components/inputs/dateRangeLogic.js +48 -22
  41. package/dist/components/inputs/facetedSearchLogic.d.ts +1 -1
  42. package/dist/components/inputs/index.d.ts +2 -0
  43. package/dist/components/inputs/searchChipLogic.d.ts +33 -0
  44. package/dist/components/inputs/searchChipLogic.js +13 -0
  45. package/dist/components/labelsLogic.d.ts +11 -1
  46. package/dist/components/layout/KapiContextSlot.js +108 -88
  47. package/dist/components/layout/KapiMasonry.d.ts +30 -0
  48. package/dist/components/layout/KapiMasonry.js +33 -0
  49. package/dist/components/layout/KapiPageHeader.js +89 -71
  50. package/dist/components/layout/KapiRail.d.ts +8 -2
  51. package/dist/components/layout/KapiRail.js +118 -67
  52. package/dist/components/layout/KapiShell.js +67 -37
  53. package/dist/components/layout/index.d.ts +2 -0
  54. package/dist/components/layout/masonryLogic.d.ts +40 -0
  55. package/dist/components/layout/masonryLogic.js +8 -0
  56. package/dist/components/layout/railLogic.d.ts +41 -1
  57. package/dist/components/layout/railLogic.js +36 -4
  58. package/dist/components/layout/reopenBus.d.ts +53 -0
  59. package/dist/components/layout/reopenBus.js +6 -0
  60. package/dist/components/layout/useMasonrySpans.d.ts +32 -0
  61. package/dist/components/layout/useMasonrySpans.js +44 -0
  62. package/dist/components/layout/useRailOverflow.d.ts +17 -0
  63. package/dist/components/layout/useRailOverflow.js +41 -0
  64. package/dist/components/locale/labelRegistry.d.ts +12 -1
  65. package/dist/components/navigation/KapiFilterChips.js +1 -1
  66. package/dist/components/navigation/filterChipsLogic.d.ts +7 -1
  67. package/dist/components/navigation/filterChipsLogic.js +3 -3
  68. package/dist/components/overlays/KapiConfirm.d.ts +14 -2
  69. package/dist/components/overlays/KapiConfirm.js +2 -2
  70. package/dist/components/overlays/KapiContextMenu.d.ts +3 -0
  71. package/dist/components/overlays/KapiContextMenu.js +2 -1
  72. package/dist/components/overlays/KapiDropdown.d.ts +3 -1
  73. package/dist/components/overlays/KapiDropdown.js +29 -26
  74. package/dist/components/overlays/KapiMenuButton.js +1 -0
  75. package/dist/components/overlays/KapiOffcanvasStack.d.ts +2 -2
  76. package/dist/hooks/breakpointOpenLogic.d.ts +20 -5
  77. package/dist/hooks/breakpointOpenLogic.js +2 -2
  78. package/dist/hooks/dataColorLogic.d.ts +23 -0
  79. package/dist/hooks/index.d.ts +1 -1
  80. package/dist/hooks/numberFormatLogic.d.ts +7 -0
  81. package/dist/hooks/numberFormatLogic.js +5 -2
  82. package/dist/hooks/seriesPaletteLogic.d.ts +24 -0
  83. package/dist/hooks/themeContrastLogic.js +1 -0
  84. package/dist/hooks/themeDeriveLogic.d.ts +8 -0
  85. package/dist/hooks/themeDeriveLogic.js +4 -2
  86. package/dist/hooks/useKapiTheme.js +27 -27
  87. package/dist/hooks/useMediaQuery.d.ts +7 -0
  88. package/dist/hooks/useMediaQuery.js +4 -4
  89. package/dist/index.js +149 -137
  90. package/dist/kapi.css +1 -1
  91. package/dist/kapi.layered.css +1 -1
  92. package/package.json +2 -6
@@ -1,46 +1,48 @@
1
1
  "use client";
2
2
  import { prefersReducedMotion as e } from "../../hooks/reducedMotion.js";
3
3
  import { maxTransitionMs as t } from "../overlays/dialogUtils.js";
4
- import { useScrollCollapse as n } from "../../hooks/useScrollCollapse.js";
5
- import { pageHeaderBox as r } from "./pageHeaderLogic.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";
6
7
  /* empty css */
7
- import { Fragment as i, jsx as a, jsxs as o } from "react/jsx-runtime";
8
- import { useLayoutEffect as s, useRef as c } from "react";
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";
9
11
  //#region src/components/layout/KapiPageHeader.tsx
10
- var l = "kapi-pageheader--collapsed", u = "kapi-pageheader--animating", d = "kapi-pageheader--measuring", f = 80, p = (e, t) => {
12
+ var p = "kapi-pageheader--collapsed", m = "kapi-pageheader--animating", h = "kapi-pageheader--measuring", g = 80, _ = (e, t) => {
11
13
  let n = e.style.height;
12
- e.classList.add(d), e.style.height = "", e.classList.toggle(l, !1);
14
+ e.classList.add(h), e.style.height = "", e.classList.toggle(p, !1);
13
15
  let r = e.getBoundingClientRect().height;
14
- e.classList.toggle(l, !0);
16
+ e.classList.toggle(p, !0);
15
17
  let i = e.getBoundingClientRect().height;
16
- return e.classList.toggle(l, t), e.style.height = n, e.getBoundingClientRect(), e.classList.remove(d), {
18
+ return e.classList.toggle(p, t), e.style.height = n, e.getBoundingClientRect(), e.classList.remove(h), {
17
19
  expanded: r,
18
20
  collapsed: i
19
21
  };
20
- }, m = (e, t) => {
21
- let n = r(e, t);
22
+ }, v = (e, t) => {
23
+ let n = i(e, t);
22
24
  return t ? n : {
23
25
  height: null,
24
26
  reserve: n.reserve
25
27
  };
26
- }, h = (e, t, n) => {
28
+ }, y = (e, t, n) => {
27
29
  let r = () => {
28
30
  t.height === null ? e.style.removeProperty("height") : e.style.height = `${t.height}px`, e.style.setProperty("--kapi-pageheader-reserve", `${t.reserve}px`);
29
31
  };
30
32
  n ? r() : (e.style.transition = "none", r(), e.getBoundingClientRect(), e.style.transition = "");
31
33
  };
32
- function g({ title: l, subtitle: d, meta: g, actions: _, chip: v, collapseOnScroll: y = !0, sticky: b = !0, scrollRoot: x = null, responsive: S = !0, className: C, ...w }) {
33
- let { collapsed: T, sentinelRef: E } = n({ root: x }), D = y && T, O = c(null), k = c({
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({
34
36
  expanded: 0,
35
37
  collapsed: 0
36
- }), A = c(D);
37
- A.current = D;
38
- let j = c(!1), M = c(!1);
39
- s(() => {
40
- let e = O.current;
38
+ }), P = u(j);
39
+ P.current = j;
40
+ let F = u(!1), I = u(!1);
41
+ l(() => {
42
+ let e = M.current;
41
43
  if (!e) return;
42
44
  let t = () => {
43
- M.current || (k.current = p(e, A.current), h(e, m(k.current, A.current), !1));
45
+ I.current || (N.current = _(e, P.current), y(e, v(N.current, P.current), !1));
44
46
  };
45
47
  t();
46
48
  let n = !0;
@@ -59,74 +61,90 @@ function g({ title: l, subtitle: d, meta: g, actions: _, chip: v, collapseOnScro
59
61
  n = !1, i.disconnect();
60
62
  };
61
63
  }, [
62
- l,
63
- d,
64
- g,
65
- _,
66
- v,
67
- y,
68
- S
69
- ]), s(() => {
70
- let n = O.current;
64
+ p,
65
+ h,
66
+ b,
67
+ x,
68
+ S,
69
+ C,
70
+ E
71
+ ]), l(() => {
72
+ let n = M.current;
71
73
  if (!n) return;
72
- let { expanded: i } = k.current, a = r(k.current, D), o = j.current && !e(n);
73
- j.current = !0;
74
+ let { expanded: r } = N.current, a = i(N.current, j), o = F.current && !e(n);
75
+ F.current = !0;
74
76
  let s = () => {
75
- M.current = !1, n.classList.remove(u), D || n.style.removeProperty("height");
77
+ I.current = !1, n.classList.remove(m), j || n.style.removeProperty("height");
76
78
  };
77
79
  if (!o) {
78
- h(n, m(k.current, D), !1);
80
+ y(n, v(N.current, j), !1);
79
81
  return;
80
82
  }
81
- n.style.height === "" && i > 0 && (n.style.height = `${i}px`, n.getBoundingClientRect()), M.current = !0, n.classList.add(u), h(n, a, !0);
83
+ n.style.height === "" && r > 0 && (n.style.height = `${r}px`, n.getBoundingClientRect()), I.current = !0, n.classList.add(m), y(n, a, !0);
82
84
  let c = (e) => {
83
85
  e.target === n && e.propertyName === "height" && s();
84
86
  };
85
87
  n.addEventListener("transitionend", c);
86
- let l = getComputedStyle(n), d = window.setTimeout(s, t(l.transitionDuration, l.transitionDelay) + f);
88
+ let l = getComputedStyle(n), u = window.setTimeout(s, t(l.transitionDuration, l.transitionDelay) + g);
87
89
  return () => {
88
- n.removeEventListener("transitionend", c), window.clearTimeout(d);
90
+ n.removeEventListener("transitionend", c), window.clearTimeout(u);
89
91
  };
90
- }, [D]);
91
- let N = [
92
+ }, [j]);
93
+ let L = [
92
94
  "kapi-pageheader",
93
- b && "kapi-pageheader--sticky",
94
- S && "kapi-pageheader--cq",
95
- D && "kapi-pageheader--collapsed",
96
- C
97
- ].filter(Boolean).join(" ");
98
- return /* @__PURE__ */ o(i, { children: [/* @__PURE__ */ a("div", {
99
- ref: E,
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,
100
104
  className: "kapi-pageheader__sentinel",
101
105
  "aria-hidden": !0
102
- }), /* @__PURE__ */ o("header", {
103
- ...w,
104
- ref: O,
105
- className: N,
106
- children: [/* @__PURE__ */ o("div", {
107
- className: "kapi-pageheader__main",
108
- children: [
109
- /* @__PURE__ */ o("div", {
110
- className: "kapi-pageheader__titlerow",
111
- children: [/* @__PURE__ */ a("h1", {
112
- className: "kapi-pageheader__title",
113
- children: l
114
- }), v]
115
- }),
116
- d && /* @__PURE__ */ a("div", {
117
- className: "kapi-pageheader__subtitle",
118
- children: d
119
- }),
120
- g && /* @__PURE__ */ a("div", {
121
- className: "kapi-pageheader__meta",
122
- children: g
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"
123
120
  })
124
- ]
125
- }), _ && /* @__PURE__ */ a("div", {
126
- className: "kapi-pageheader__actions",
127
- children: _
128
- })]
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
+ ]
129
147
  })] });
130
148
  }
131
149
  //#endregion
132
- export { g as KapiPageHeader };
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;
@@ -3,107 +3,158 @@ import { useLabels as e } from "../locale/KapiLocaleProvider.js";
3
3
  import { joinClasses as t } from "../rootProps.js";
4
4
  import { useSlidingIndicator as n } from "../../hooks/useSlidingIndicator.js";
5
5
  import { KapiTooltip as r } from "../overlays/KapiTooltip.js";
6
- import { navBadgeA11yText as i } from "../navigation/navBadgeLogic.js";
7
- import { KapiNavBadge as a } from "../navigation/KapiNavBadge.js";
8
- import { useScrollEdges as o } from "../../hooks/useScrollEdges.js";
9
- import { DEFAULT_LINK_LABELS as s } from "../locale/linkLabels.js";
10
- import { useMediaQuery as c } from "../../hooks/useMediaQuery.js";
11
- import { isRailSeparator as l, railClasses as u, railItemClasses as d, railShowsTooltip as f, splitRailEntries as p } from "./railLogic.js";
6
+ import { KapiMenuButton as i } from "../overlays/KapiMenuButton.js";
7
+ import { navBadgeA11yText as a } from "../navigation/navBadgeLogic.js";
8
+ import { KapiNavBadge as o } from "../navigation/KapiNavBadge.js";
9
+ import { useScrollEdges as s } from "../../hooks/useScrollEdges.js";
10
+ import { DEFAULT_LINK_LABELS as c } from "../locale/linkLabels.js";
11
+ import { SHELL_MOBILE_QUERY as l, useMediaQuery as u } from "../../hooks/useMediaQuery.js";
12
+ import { isRailSeparator as d, railClasses as f, railItemClasses as p, railOverflowState as m, railShowsTooltip as h, splitRailEntries as g, splitRailOverflow as _ } from "./railLogic.js";
13
+ import { useRailOverflow as v } from "./useRailOverflow.js";
12
14
  /* empty css */
13
- import { jsx as m, jsxs as h } from "react/jsx-runtime";
14
- import { useCallback as g } from "react";
15
- import { ExternalLink as _ } from "lucide-react";
15
+ import { Fragment as y, jsx as b, jsxs as x } from "react/jsx-runtime";
16
+ import { useCallback as S } from "react";
17
+ import { ExternalLink as C, MoreHorizontal as w } from "lucide-react";
16
18
  //#region src/components/layout/KapiRail.tsx
17
- var v = { navigation: "Navegación principal" }, y = ({ items: y, activeId: b, onSelect: x, brand: S, footer: C, variant: w = "labeled", "aria-label": T, labels: E, className: D, ...O }) => {
18
- let k = e("rail", v, E), A = e("link", s, E), j = w === "compact", M = f(w), N = p(y), { containerRef: P, indicatorRef: F } = n({
19
- active: b ?? null,
20
- deps: [y, w],
21
- findActive: (e) => e.querySelector(".kapi-rail__item[aria-current=\"page\"]")
22
- }), I = c("(max-width: 768px)") ? "x" : "y", { ref: L, edges: R } = o({ axis: I }), z = g((e) => {
23
- P.current = e, L.current = e;
24
- }, [P, L]), B = ({ id: e, label: t, icon: n, href: o, external: s, newTab: c, badge: l, badgeTone: u, badgeLabel: f }) => {
25
- let p = b === e, g = p ? "page" : void 0, v = i(l, f), y = v === null ? t : `${t} ${v}`, S = j ? y : void 0, C = /* @__PURE__ */ m(a, {
19
+ var T = {
20
+ navigation: "Navegación principal",
21
+ more: "Más",
22
+ moreCurrent: "sección actual"
23
+ }, E = ({ items: E, activeId: D, onSelect: O, brand: k, footer: A, variant: j = "labeled", "aria-label": M, labels: N, className: P, ...F }) => {
24
+ let I = e("rail", T, N), L = e("link", c, N), R = j === "compact", z = h(j), B = g(E), V = u(l), { ref: H, edges: U } = s({ axis: "y" }), W = B.scroll, G = W.filter((e) => !d(e)).length, K = v(H, {
25
+ enabled: V,
26
+ count: G,
27
+ separators: W.length - G
28
+ }), { shown: q, hidden: J } = _(W, K ?? G), Y = m(J, D), { containerRef: X, indicatorRef: Z } = n({
29
+ active: D ?? null,
30
+ deps: [
31
+ E,
32
+ j,
33
+ J.length
34
+ ],
35
+ findActive: (e) => e.querySelector(".kapi-rail__item[aria-current=\"page\"], .kapi-rail__more--on")
36
+ }), Q = S((e) => {
37
+ X.current = e, H.current = e;
38
+ }, [X, H]), ee = ({ id: e, label: t, icon: n, href: i, external: s, newTab: c, badge: l, badgeTone: u, badgeLabel: d }) => {
39
+ let f = D === e, m = f ? "page" : void 0, h = a(l, d), g = h === null ? t : `${t} ${h}`, _ = R ? g : void 0, v = /* @__PURE__ */ b(o, {
26
40
  value: l,
27
41
  tone: u,
28
- label: f,
42
+ label: d,
29
43
  placement: "corner",
30
- announce: !j
31
- }), w = o === void 0 ? /* @__PURE__ */ h("button", {
44
+ announce: !R
45
+ }), y = i === void 0 ? /* @__PURE__ */ x("button", {
32
46
  type: "button",
33
- className: d({ active: p }),
34
- onClick: () => x?.(e),
35
- "aria-current": g,
36
- "aria-label": S,
47
+ className: p({ active: f }),
48
+ onClick: () => O?.(e),
49
+ "aria-current": m,
50
+ "aria-label": _,
37
51
  children: [
38
52
  n,
39
- !j && t,
40
- C
53
+ !R && /* @__PURE__ */ b("span", {
54
+ className: "kapi-rail__label",
55
+ children: t
56
+ }),
57
+ v
41
58
  ]
42
- }, M ? void 0 : e) : /* @__PURE__ */ h("a", {
43
- className: d({
44
- active: p,
59
+ }, z ? void 0 : e) : /* @__PURE__ */ x("a", {
60
+ className: p({
61
+ active: f,
45
62
  link: !0
46
63
  }),
47
- href: o,
64
+ href: i,
48
65
  rel: "noopener noreferrer",
49
66
  target: c ? "_blank" : void 0,
50
- "aria-current": g,
51
- "aria-label": S,
67
+ "aria-current": m,
68
+ "aria-label": _,
52
69
  children: [
53
70
  n,
54
- !j && t,
55
- C,
56
- s && /* @__PURE__ */ m(_, {
71
+ !R && /* @__PURE__ */ b("span", {
72
+ className: "kapi-rail__label",
73
+ children: t
74
+ }),
75
+ v,
76
+ s && /* @__PURE__ */ b(C, {
57
77
  className: "kapi-rail__ext",
58
78
  size: 12,
59
79
  "aria-hidden": "true"
60
80
  }),
61
- c && /* @__PURE__ */ m("span", {
81
+ c && /* @__PURE__ */ b("span", {
62
82
  className: "kapi-rail__sr",
63
- children: A.newTab
83
+ children: L.newTab
64
84
  })
65
85
  ]
66
- }, M ? void 0 : e);
67
- return M ? /* @__PURE__ */ m(r, {
68
- label: y,
69
- children: w
70
- }, e) : w;
71
- }, V = (e) => e.map((e, t) => l(e) ? /* @__PURE__ */ m("div", {
86
+ }, z ? void 0 : e);
87
+ return z ? /* @__PURE__ */ b(r, {
88
+ label: g,
89
+ children: y
90
+ }, e) : y;
91
+ }, $ = (e) => e.map((e, t) => d(e) ? /* @__PURE__ */ b("div", {
72
92
  className: "kapi-rail__sep",
73
93
  role: "separator",
74
94
  "aria-orientation": "horizontal"
75
- }, e.id ?? `sep-${t}`) : B(e));
76
- return /* @__PURE__ */ h("nav", {
77
- ...O,
78
- className: t(u({ variant: w }), D),
79
- "aria-label": T ?? k.navigation,
95
+ }, e.id ?? `sep-${t}`) : ee(e)), te = J.map(({ id: e, label: t, href: n, newTab: r, badge: i, badgeLabel: o }) => {
96
+ let s = a(i, o);
97
+ return {
98
+ label: s === null ? t : `${t} ${s}`,
99
+ current: D === e,
100
+ onClick: () => {
101
+ n === void 0 ? O?.(e) : r ? window.open(n, "_blank", "noopener,noreferrer") : window.location.assign(n);
102
+ }
103
+ };
104
+ });
105
+ return /* @__PURE__ */ x("nav", {
106
+ ...F,
107
+ className: t(f({ variant: j }), P),
108
+ "aria-label": M ?? I.navigation,
80
109
  children: [
81
- S !== void 0 && /* @__PURE__ */ m("div", {
110
+ k !== void 0 && /* @__PURE__ */ b("div", {
82
111
  className: "kapi-rail__brand",
83
- children: S
112
+ children: k
84
113
  }),
85
- N.start.length > 0 && /* @__PURE__ */ m("div", {
114
+ B.start.length > 0 && /* @__PURE__ */ b("div", {
86
115
  className: "kapi-rail__start",
87
- children: V(N.start)
116
+ children: $(B.start)
88
117
  }),
89
- /* @__PURE__ */ h("div", {
90
- ref: z,
91
- className: `kapi-rail__scroll kapi-fade-${I}`,
92
- "data-edge-start": R.start ? "" : void 0,
93
- "data-edge-end": R.end ? "" : void 0,
94
- children: [/* @__PURE__ */ m("span", {
95
- ref: F,
96
- className: "kapi-rail__indicator",
97
- "aria-hidden": "true"
98
- }), V(N.scroll)]
118
+ /* @__PURE__ */ x("div", {
119
+ ref: Q,
120
+ className: t("kapi-rail__scroll", !V && "kapi-fade-y"),
121
+ "data-edge-start": !V && U.start ? "" : void 0,
122
+ "data-edge-end": !V && U.end ? "" : void 0,
123
+ children: [
124
+ /* @__PURE__ */ b("span", {
125
+ ref: Z,
126
+ className: "kapi-rail__indicator",
127
+ "aria-hidden": "true"
128
+ }),
129
+ $(q),
130
+ J.length > 0 && /* @__PURE__ */ b(i, {
131
+ className: t("kapi-rail__more", Y.current && "kapi-rail__more--on"),
132
+ variant: "ghost",
133
+ drop: "up",
134
+ icon: /* @__PURE__ */ b(w, {
135
+ size: 21,
136
+ strokeWidth: 1.8
137
+ }),
138
+ ...R || Y.current ? { "aria-label": Y.current ? `${I.more} · ${I.moreCurrent}: ${Y.current.label}` : I.more } : {},
139
+ label: /* @__PURE__ */ x(y, { children: [!R && /* @__PURE__ */ b("span", {
140
+ className: "kapi-rail__label",
141
+ children: I.more
142
+ }), Y.notice && /* @__PURE__ */ b(o, {
143
+ value: "dot",
144
+ tone: Y.notice.badgeTone,
145
+ placement: "corner"
146
+ })] }),
147
+ items: te
148
+ })
149
+ ]
99
150
  }),
100
- N.end.length > 0 && /* @__PURE__ */ m("div", {
151
+ B.end.length > 0 && /* @__PURE__ */ b("div", {
101
152
  className: "kapi-rail__end",
102
- children: V(N.end)
153
+ children: $(B.end)
103
154
  }),
104
- C
155
+ A
105
156
  ]
106
157
  });
107
158
  };
108
159
  //#endregion
109
- export { v as DEFAULT_RAIL_LABELS, y as KapiRail };
160
+ export { T as DEFAULT_RAIL_LABELS, E as KapiRail };
@@ -3,48 +3,78 @@ import { joinClasses as e } from "../rootProps.js";
3
3
  import { KapiContextMenu as t } from "../overlays/KapiContextMenu.js";
4
4
  import { useGlobalRightClick as n } from "../../hooks/useGlobalRightClick.js";
5
5
  import { KapiThemeContext as r, themeRootStyle as i, useKapiThemeState as a } from "../../hooks/useKapiTheme.js";
6
- import { jsx as o, jsxs as s } from "react/jsx-runtime";
7
- import { useMemo as c, useState as l } from "react";
6
+ import { KapiReopenContext as o } from "./reopenBus.js";
7
+ import { jsx as s, jsxs as c } from "react/jsx-runtime";
8
+ import { useCallback as l, useMemo as u, useState as d } from "react";
9
+ import { ChevronsLeft as f, ChevronsRight as p } from "lucide-react";
8
10
  //#region src/components/layout/KapiShell.tsx
9
- var u = ({ rail: u, panel: d, panelRight: f, children: p, contextMenuItems: m, rightClick: h = !0, overlays: g, className: _, contentClassName: v = "", storageNamespace: y, brandTheme: b, style: x, ...S }) => {
10
- let C = a({ namespace: y }), w = c(() => i(C, b), [C, b]), [T, E] = l(null);
11
- return n({
12
- enabled: h,
13
- onMenu: m?.length ? (e, t) => E({
11
+ var m = ({ rail: m, panel: h, panelRight: g, children: _, contextMenuItems: v, rightClick: y = !0, overlays: b, className: x, contentClassName: S = "", storageNamespace: C, brandTheme: w, style: T, ...E }) => {
12
+ let D = a({ namespace: C }), O = u(() => i(D, w), [D, w]), [k, A] = d(null);
13
+ n({
14
+ enabled: y,
15
+ onMenu: v?.length ? (e, t) => A({
14
16
  x: e,
15
17
  y: t
16
18
  }) : void 0
17
- }), /* @__PURE__ */ o(r.Provider, {
18
- value: C,
19
- children: /* @__PURE__ */ s("div", {
20
- ...S,
21
- className: e("kapi", _),
22
- "data-theme": C.theme,
23
- "data-motion": C.motion === "reduced" ? "reduced" : void 0,
24
- style: {
25
- ...x,
26
- ...w
27
- },
28
- children: [
29
- u,
30
- d,
31
- /* @__PURE__ */ o("main", {
32
- className: `kapi-content${v ? ` ${v}` : ""}`,
33
- tabIndex: 0,
34
- children: p
35
- }),
36
- f,
37
- g,
38
- T && m && /* @__PURE__ */ o(t, {
39
- open: !0,
40
- x: T.x,
41
- y: T.y,
42
- items: m,
43
- onClose: () => E(null)
44
- })
45
- ]
19
+ });
20
+ let [j, M] = d(null), [N, P] = d(0), F = l(() => (P((e) => e + 1), () => P((e) => e - 1)), []), I = u(() => ({
21
+ info: j,
22
+ publish: M,
23
+ hosts: N,
24
+ addHost: F
25
+ }), [
26
+ j,
27
+ N,
28
+ F
29
+ ]);
30
+ return /* @__PURE__ */ s(r.Provider, {
31
+ value: D,
32
+ children: /* @__PURE__ */ s(o.Provider, {
33
+ value: I,
34
+ children: /* @__PURE__ */ c("div", {
35
+ ...E,
36
+ className: e("kapi", x),
37
+ "data-theme": D.theme,
38
+ "data-motion": D.motion === "reduced" ? "reduced" : void 0,
39
+ style: {
40
+ ...T,
41
+ ...O
42
+ },
43
+ children: [
44
+ m,
45
+ h,
46
+ /* @__PURE__ */ c("main", {
47
+ className: `kapi-content${S ? ` ${S}` : ""}`,
48
+ tabIndex: 0,
49
+ children: [j && N === 0 && /* @__PURE__ */ s("button", {
50
+ type: "button",
51
+ className: "kapi-paneltoggle kapi-content__reopen",
52
+ onClick: j.expand,
53
+ "aria-label": j.label,
54
+ children: j.side === "right" ? /* @__PURE__ */ s(f, {
55
+ size: 16,
56
+ strokeWidth: 2,
57
+ "aria-hidden": "true"
58
+ }) : /* @__PURE__ */ s(p, {
59
+ size: 16,
60
+ strokeWidth: 2,
61
+ "aria-hidden": "true"
62
+ })
63
+ }), _]
64
+ }),
65
+ g,
66
+ b,
67
+ k && v && /* @__PURE__ */ s(t, {
68
+ open: !0,
69
+ x: k.x,
70
+ y: k.y,
71
+ items: v,
72
+ onClose: () => A(null)
73
+ })
74
+ ]
75
+ })
46
76
  })
47
77
  });
48
78
  };
49
79
  //#endregion
50
- export { u as KapiShell };
80
+ export { m as KapiShell };
@@ -26,6 +26,8 @@ export { KapiCluster } from "./KapiCluster";
26
26
  export type { KapiClusterProps } from "./KapiCluster";
27
27
  export { KapiGrid } from "./KapiGrid";
28
28
  export type { KapiGridProps } from "./KapiGrid";
29
+ export { KapiMasonry } from "./KapiMasonry";
30
+ export type { KapiMasonryProps } from "./KapiMasonry";
29
31
  export type { KapiGap, KapiAlign, KapiClusterAlign, KapiClusterJustify } from "./layoutPrimitives";
30
32
  export { KapiPageHeader } from "./KapiPageHeader";
31
33
  export type { KapiPageHeaderProps } from "./KapiPageHeader";
@@ -0,0 +1,40 @@
1
+ /** Medidas (px) con las que se decide cuántas filas de la grilla ocupa un ítem del masonry. */
2
+ export type MasonryFit = {
3
+ /** Alto del contenido del ítem, medido en el DOM, SIN la separación de abajo. */
4
+ height: number;
5
+ /** Alto de una fila de la grilla (`grid-auto-rows`). Es el grano del empaque. */
6
+ rowUnit: number;
7
+ /** Separación vertical entre ítems. La lleva el ítem abajo, no `row-gap` (ver abajo por qué). */
8
+ gap: number;
9
+ };
10
+ /**
11
+ * Cuántas filas de la grilla ocupa un ítem de alto `height`.
12
+ *
13
+ * N = ceil((height + gap) / rowUnit)
14
+ *
15
+ * **La grilla tiene que llevar `row-gap: 0`, y la separación vertical la pone cada ítem abajo.**
16
+ * No es un detalle de estilo: es lo que hace que `rowUnit` sirva para algo. Si `row-gap` no es
17
+ * cero, cada una de las N filas que el ítem abarca suma su propia separación, el alto que recibe
18
+ * pasa a ser `N·rowUnit + (N−1)·gap`, y el grano del empaque se vuelve `rowUnit + gap` en vez de
19
+ * `rowUnit`. Con `rowUnit` 8 y `gap` 12 eso es un grano de 20px: el gap domina y achicar `rowUnit`
20
+ * deja de mejorar nada. Con `row-gap: 0` el grano es `rowUnit` y el hueco máximo bajo un ítem es
21
+ * `rowUnit − 1` px.
22
+ *
23
+ * Una medida que todavía no existe o no es un número válido devuelve **1**, no 0 ni `NaN`: con
24
+ * `span 1` el ítem se ve como en una grilla normal, que es exactamente lo que tiene que pasar
25
+ * antes de medir, sin `ResizeObserver`, o si alguien renderiza esto en un entorno sin layout. Un
26
+ * `span 0` es inválido en CSS y un `NaN` tira el layout entero.
27
+ */
28
+ export declare const masonrySpan: ({ height, rowUnit, gap }: MasonryFit) => number;
29
+ /**
30
+ * El alto de fila que se usa cuando el consumidor no fija uno.
31
+ *
32
+ * Es un compromiso entre dos extremos malos: una fila de 1px empaqueta perfecto pero obliga al
33
+ * motor de grilla a resolver cientos de filas por ítem, y una fila grande deja huecos visibles
34
+ * porque el alto de cada ítem se redondea para arriba hasta el múltiplo siguiente. Con 8 el hueco
35
+ * máximo es 7px, por debajo del espaciado más chico del sistema.
36
+ *
37
+ * No es un token `--kapi-*` a propósito: no es una decisión de diseño visible, es el grano de una
38
+ * cuenta interna. Lo que sí sale de tokens es el `gap`.
39
+ */
40
+ export declare const MASONRY_ROW_UNIT = 8;
@@ -0,0 +1,8 @@
1
+ //#region src/components/layout/masonryLogic.ts
2
+ var e = ({ height: e, rowUnit: t, gap: n }) => [
3
+ e,
4
+ t,
5
+ n
6
+ ].every(Number.isFinite) && e > 0 && t > 0 && n >= 0 ? Math.max(1, Math.ceil((e + n) / t)) : 1;
7
+ //#endregion
8
+ export { e as masonrySpan };