@nivaro/react 0.3.19 → 0.3.20

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.
@@ -1,74 +1,84 @@
1
- import { jsxs as D, Fragment as R, jsx as H } from "react/jsx-runtime";
2
- import { useState as S, useRef as m, useCallback as O, cloneElement as k } from "react";
3
- import { headerChangedCells as $, headerNeedsDense as j, headerFoldedCells as x } from "../../lib/header-strip.js";
4
- import { useLayoutDesign as M } from "../layout-editor/design-context.js";
5
- import { HeaderOverflowChip as T } from "./HeaderOverflowChip.js";
6
- function B() {
7
- const [a, i] = S(!1), o = m(!1);
8
- o.current = a;
9
- const [l, d] = S([]), s = m([]);
10
- s.current = l;
11
- const y = m(/* @__PURE__ */ new Map()), u = m(/* @__PURE__ */ new Map()), e = m(null), n = O((r) => {
12
- var v;
13
- if ((v = e.current) == null || v.call(e), e.current = null, !r || typeof ResizeObserver > "u") return;
14
- let f = 0;
15
- const w = () => {
16
- f = 0;
17
- const c = j(r, o.current, u.current);
18
- c !== o.current && i(c);
19
- const h = c ? x(r, o.current, y.current) : [], t = (C) => C.map((F) => `${F.key}${F.empty ? "e" : ""}`).join();
20
- t(h) !== t(s.current) && d(h);
21
- }, b = () => {
22
- f || (f = window.requestAnimationFrame(w));
23
- }, p = new ResizeObserver(b);
24
- p.observe(r);
25
- for (const c of r.children) p.observe(c);
26
- const g = new MutationObserver((c) => {
27
- for (const t of r.children) p.observe(t);
28
- const h = $(r, c);
29
- for (const t of h.shown)
30
- y.current.delete(t), u.current.delete(t);
31
- for (const t of h.folded) u.current.delete(t);
32
- b();
1
+ import { jsxs as C, Fragment as M, jsx as _ } from "react/jsx-runtime";
2
+ import { useState as b, useRef as u, useCallback as $, cloneElement as v } from "react";
3
+ import { headerChangedCells as j, HEADER_MORE_ROW_KEY as x, headerNeedsDense as A, headerFoldPlan as K } from "../../lib/header-strip.js";
4
+ import { useLayoutDesign as T } from "../layout-editor/design-context.js";
5
+ import { HeaderOverflowChip as z } from "./HeaderOverflowChip.js";
6
+ function J() {
7
+ const [i, f] = b(!1), t = u(!1);
8
+ t.current = i;
9
+ const [h, y] = b([]), s = u([]);
10
+ s.current = h;
11
+ const [d, S] = b(null), R = u(null);
12
+ R.current = d;
13
+ const e = u(/* @__PURE__ */ new Map()), r = u(/* @__PURE__ */ new Map()), n = u(null), m = $((c) => {
14
+ var O;
15
+ if ((O = n.current) == null || O.call(n), n.current = null, !c || typeof ResizeObserver > "u") return;
16
+ let p = 0;
17
+ const D = () => {
18
+ p = 0;
19
+ const a = A(c, t.current, r.current);
20
+ a !== t.current && f(a);
21
+ const l = a ? K(c, t.current, e.current) : { folded: [], rows: null }, o = (w) => w.map((k) => `${k.key}${k.empty ? "e" : ""}`).join();
22
+ o(l.folded) !== o(s.current) && y(l.folded);
23
+ const E = (w) => w ? JSON.stringify(w) : "";
24
+ E(l.rows) !== E(R.current) && S(l.rows);
25
+ }, F = () => {
26
+ p || (p = window.requestAnimationFrame(D));
27
+ }, g = new ResizeObserver(F);
28
+ g.observe(c);
29
+ for (const a of c.children) g.observe(a);
30
+ const H = new MutationObserver((a) => {
31
+ for (const o of c.children) g.observe(o);
32
+ const l = j(c, a);
33
+ for (const o of l.shown)
34
+ e.current.delete(o), r.current.delete(o);
35
+ for (const o of l.folded) r.current.delete(o);
36
+ F();
33
37
  });
34
- g.observe(r, { childList: !0, subtree: !0, characterData: !0 }), w(), e.current = () => {
35
- p.disconnect(), g.disconnect(), f && window.cancelAnimationFrame(f);
38
+ H.observe(c, { childList: !0, subtree: !0, characterData: !0 }), D(), n.current = () => {
39
+ g.disconnect(), H.disconnect(), p && window.cancelAnimationFrame(p);
36
40
  };
37
41
  }, []);
38
- return { headerDense: a, headerFolded: l, headerTilesRef: n };
42
+ return { headerDense: i, headerFolded: h, headerRows: d, headerTilesRef: m };
39
43
  }
40
- function K({ tiles: a, folded: i }) {
41
- const o = new Set(i.map((e) => String(e.key))), l = /* @__PURE__ */ new Set(), d = a.map((e, n) => {
42
- let r = String(e.key ?? n);
43
- return l.has(r) && (r = `${r}#${n}`), l.add(r), r;
44
- }), s = a.filter((e, n) => o.has(d[n])), u = M() ? s.map(
45
- (e) => k(e, { "data-design-copy": "" })
46
- ) : s;
47
- return /* @__PURE__ */ D(R, { children: [
48
- a.map(
49
- (e, n) => (
50
- // Folded: marked on the tile itself, which keeps its own key — a
51
- // wrapper changed the key and remounted the tile on every fold, so a
52
- // widget refetched and re-rendered each time. Out of flow but in the
53
- // DOM, in place.
54
- k(
55
- e,
56
- o.has(d[n]) ? { "data-header-cell": d[n], "data-header-folded": "", "aria-hidden": "true" } : { "data-header-cell": d[n] }
57
- )
58
- )
59
- ),
60
- s.length > 0 && /* @__PURE__ */ H(
61
- T,
44
+ function P({
45
+ tiles: i,
46
+ folded: f,
47
+ rows: t = null
48
+ }) {
49
+ const h = new Set(f.map((e) => String(e.key))), y = /* @__PURE__ */ new Set(), s = i.map((e, r) => {
50
+ let n = String(e.key ?? r);
51
+ return y.has(n) && (n = `${n}#${r}`), y.add(n), n;
52
+ }), d = i.filter((e, r) => h.has(s[r])), R = T() ? d.map(
53
+ (e) => v(e, { "data-design-copy": "" })
54
+ ) : d;
55
+ return /* @__PURE__ */ C(M, { children: [
56
+ i.map((e, r) => {
57
+ if (h.has(s[r]))
58
+ return v(e, {
59
+ "data-header-cell": s[r],
60
+ "data-header-folded": "",
61
+ "aria-hidden": "true"
62
+ });
63
+ const n = t == null ? void 0 : t[s[r]], m = e.props.style;
64
+ return v(e, {
65
+ "data-header-cell": s[r],
66
+ ...n != null || m ? { style: n != null ? { ...m, order: n } : m } : {}
67
+ });
68
+ }),
69
+ d.length > 0 && /* @__PURE__ */ _(
70
+ z,
62
71
  {
63
- count: s.length,
64
- allEmpty: i.every((e) => e.empty),
65
- labels: i.map((e) => e.label),
66
- children: u
72
+ count: d.length,
73
+ allEmpty: f.every((e) => e.empty),
74
+ labels: f.map((e) => e.label),
75
+ order: t == null ? void 0 : t[x],
76
+ children: R
67
77
  }
68
78
  )
69
79
  ] });
70
80
  }
71
81
  export {
72
- K as HeaderTiles,
73
- B as useHeaderBand
82
+ P as HeaderTiles,
83
+ J as useHeaderBand
74
84
  };
@@ -1,35 +1,37 @@
1
- import { jsxs as a, jsx as t } from "react/jsx-runtime";
2
- import { ChevronDown as i } from "lucide-react";
3
- import { useState as l } from "react";
4
- import { cn as p } from "../../lib/utils.js";
5
- import { Popover as m, PopoverTrigger as x, PopoverContent as h } from "../ui/popover.js";
6
- function w({
7
- count: o,
1
+ import { jsxs as o, jsx as t } from "react/jsx-runtime";
2
+ import { ChevronDown as l } from "lucide-react";
3
+ import { useState as p } from "react";
4
+ import { cn as m } from "../../lib/utils.js";
5
+ import { Popover as x, PopoverTrigger as h, PopoverContent as c } from "../ui/popover.js";
6
+ function g({
7
+ count: s,
8
8
  allEmpty: r,
9
9
  labels: d,
10
- children: s
10
+ order: a,
11
+ children: n
11
12
  }) {
12
- const [e, n] = l(!1);
13
- return /* @__PURE__ */ a(m, { open: e, onOpenChange: n, children: [
14
- /* @__PURE__ */ t(x, { asChild: !0, children: /* @__PURE__ */ a(
13
+ const [e, i] = p(!1);
14
+ return /* @__PURE__ */ o(x, { open: e, onOpenChange: i, children: [
15
+ /* @__PURE__ */ t(h, { asChild: !0, children: /* @__PURE__ */ o(
15
16
  "button",
16
17
  {
17
18
  type: "button",
18
19
  "data-header-more": !0,
19
20
  "data-copy-skip": !0,
20
21
  "data-open": e ? "true" : void 0,
21
- className: p(
22
+ style: a != null ? { order: a } : void 0,
23
+ className: m(
22
24
  "flex min-h-[34px] flex-none items-center gap-1 self-stretch pr-3 pl-4 text-[11px] font-semibold tabular-nums text-slate-500 shadow-[-1px_1px_0_0_#e2e8f0] transition-colors duration-[120ms] hover:text-slate-900 dark:text-slate-500 dark:shadow-[-1px_1px_0_0_hsl(var(--border))] dark:hover:text-slate-100",
23
25
  e && "text-slate-900 dark:text-slate-100"
24
26
  ),
25
27
  "data-tip": e ? void 0 : `${d.join(" · ")}${r ? " — all empty" : ""}`,
26
28
  children: [
27
29
  "+",
28
- o,
30
+ s,
29
31
  " ",
30
32
  r ? "empty" : "more",
31
33
  /* @__PURE__ */ t(
32
- i,
34
+ l,
33
35
  {
34
36
  className: "h-3 w-3 transition-transform duration-[120ms] data-[open=true]:rotate-180",
35
37
  "data-open": e ? "true" : void 0,
@@ -40,16 +42,16 @@ function w({
40
42
  }
41
43
  ) }),
42
44
  /* @__PURE__ */ t(
43
- h,
45
+ c,
44
46
  {
45
47
  align: "start",
46
48
  sideOffset: 4,
47
49
  className: "w-[320px] max-w-[calc(100vw-32px)] rounded-md border border-slate-200 bg-white p-1 shadow-lg dark:border-border dark:bg-card",
48
- children: /* @__PURE__ */ t("div", { className: "flex flex-col", "data-header-list": !0, children: s })
50
+ children: /* @__PURE__ */ t("div", { className: "flex flex-col", "data-header-list": !0, children: n })
49
51
  }
50
52
  )
51
53
  ] });
52
54
  }
53
55
  export {
54
- w as HeaderOverflowChip
56
+ g as HeaderOverflowChip
55
57
  };
@@ -1,133 +1,151 @@
1
- const W = "shrink-0 border-y border-slate-200/90 bg-white dark:border-border dark:bg-card", q = "flex items-stretch overflow-hidden pr-4 pl-[29px]", B = "flex min-w-0 flex-1 flex-wrap content-start items-stretch overflow-hidden", D = "[[data-header-dense]_&]:min-h-[34px] [[data-header-dense]_&]:flex-row [[data-header-dense]_&]:items-center [[data-header-dense]_&]:gap-x-2 [[data-header-dense]_&]:pr-3 [[data-header-dense]_&]:pl-4 [[data-header-dense]_&]:pt-[7px] [[data-header-dense]_&]:pb-[7px] [[data-header-dense]_&]:max-w-none", C = "[[data-header-list]_&]:h-8 [[data-header-list]_&]:min-h-0 [[data-header-list]_&]:w-full [[data-header-list]_&]:max-w-none [[data-header-list]_&]:flex-row [[data-header-list]_&]:items-center [[data-header-list]_&]:justify-between [[data-header-list]_&]:gap-x-6 [[data-header-list]_&]:rounded-sm [[data-header-list]_&]:px-2 [[data-header-list]_&]:py-0 [[data-header-list]_&]:shadow-none", S = "[&[data-header-folded]]:pointer-events-none [&[data-header-folded]]:invisible [&[data-header-folded]]:absolute", O = `group relative flex min-h-[52px] min-w-[96px] max-w-[264px] flex-none flex-col justify-start gap-1 px-4 pt-[9px] pb-2 shadow-[-1px_1px_0_0_#e2e8f0] data-[empty=true]:min-w-0 data-[empty=true]:px-3 data-[empty=true]:opacity-60 dark:shadow-[-1px_1px_0_0_hsl(var(--border))] ${D} ${C} ${S}`, I = "truncate text-[13px] font-semibold leading-tight tabular-nums tracking-[-0.01em] text-slate-900 dark:text-slate-100", N = "truncate text-[10px] font-semibold uppercase leading-none tracking-[0.07em] text-slate-400 dark:text-slate-500 [[data-header-dense]_&]:shrink-0 [[data-header-list]_&]:shrink-0", $ = "truncate text-[13px] font-semibold leading-tight tabular-nums text-slate-900 dark:text-slate-100", K = "flex shrink-0 items-stretch self-stretch max-lg:[&[data-header-dock]]:hidden shadow-[-1px_0_0_0_#e2e8f0] dark:shadow-[-1px_0_0_0_hsl(var(--border))]", U = "ml-auto hidden items-center self-center py-1 pr-0 pl-4 max-lg:[&[data-header-tail]]:flex", j = "flex min-h-[40px] items-center gap-3 py-2 pr-4 pl-5", F = "text-[11px] font-medium leading-none tabular-nums text-slate-400 dark:text-slate-500 [[data-header-dense]_&]:hidden", M = "flex h-5 items-end gap-x-1.5 [[data-header-dense]_&]:h-auto [[data-header-dense]_&]:items-center [[data-header-list]_&]:h-auto [[data-header-list]_&]:items-baseline [[data-header-list]_&]:justify-end [[data-header-list]_&]:text-right";
2
- function g(t) {
3
- const r = Array.from(t.children).filter(
4
- (a) => !a.hasAttribute("data-header-more") && !a.hasAttribute("data-header-tail")
5
- ), s = r.filter((a) => a.hasAttribute("data-header-cell"));
6
- return s.length > 0 ? s : r;
1
+ const I = "shrink-0 border-y border-slate-200/90 bg-white dark:border-border dark:bg-card", N = "flex items-stretch overflow-hidden pr-4 pl-[29px]", K = "flex min-w-0 flex-1 flex-wrap content-start items-stretch overflow-hidden", S = "[[data-header-dense]_&]:min-h-[34px] [[data-header-dense]_&]:flex-row [[data-header-dense]_&]:items-center [[data-header-dense]_&]:gap-x-2 [[data-header-dense]_&]:pr-3 [[data-header-dense]_&]:pl-4 [[data-header-dense]_&]:pt-[7px] [[data-header-dense]_&]:pb-[7px] [[data-header-dense]_&]:max-w-none", L = "[[data-header-list]_&]:h-8 [[data-header-list]_&]:min-h-0 [[data-header-list]_&]:w-full [[data-header-list]_&]:max-w-none [[data-header-list]_&]:flex-row [[data-header-list]_&]:items-center [[data-header-list]_&]:justify-between [[data-header-list]_&]:gap-x-6 [[data-header-list]_&]:rounded-sm [[data-header-list]_&]:px-2 [[data-header-list]_&]:py-0 [[data-header-list]_&]:shadow-none", H = "[&[data-header-folded]]:pointer-events-none [&[data-header-folded]]:invisible [&[data-header-folded]]:absolute", $ = `group relative flex min-h-[52px] min-w-[96px] max-w-[264px] flex-none flex-col justify-start gap-1 px-4 pt-[9px] pb-2 shadow-[-1px_1px_0_0_#e2e8f0] data-[empty=true]:min-w-0 data-[empty=true]:px-3 data-[empty=true]:opacity-60 dark:shadow-[-1px_1px_0_0_hsl(var(--border))] ${S} ${L} ${H}`, M = "truncate text-[13px] font-semibold leading-tight tabular-nums tracking-[-0.01em] text-slate-900 dark:text-slate-100", U = "truncate text-[10px] font-semibold uppercase leading-none tracking-[0.07em] text-slate-400 dark:text-slate-500 [[data-header-dense]_&]:shrink-0 [[data-header-list]_&]:shrink-0", j = "truncate text-[13px] font-semibold leading-tight tabular-nums text-slate-900 dark:text-slate-100", T = "flex shrink-0 items-stretch self-stretch max-lg:[&[data-header-dock]]:hidden shadow-[-1px_0_0_0_#e2e8f0] dark:shadow-[-1px_0_0_0_hsl(var(--border))]", V = "ml-auto hidden items-center self-center py-1 pr-0 pl-4 max-lg:[&[data-header-tail]]:flex", F = "flex min-h-[40px] items-center gap-3 py-2 pr-4 pl-5", P = "text-[11px] font-medium leading-none tabular-nums text-slate-400 dark:text-slate-500 [[data-header-dense]_&]:hidden", X = "flex h-5 items-end gap-x-1.5 [[data-header-dense]_&]:h-auto [[data-header-dense]_&]:items-center [[data-header-list]_&]:h-auto [[data-header-list]_&]:items-baseline [[data-header-list]_&]:justify-end [[data-header-list]_&]:text-right";
2
+ function A(n) {
3
+ const r = Array.from(n.children).filter(
4
+ (t) => !t.hasAttribute("data-header-more") && !t.hasAttribute("data-header-tail")
5
+ ), o = r.filter((t) => t.hasAttribute("data-header-cell"));
6
+ return o.length > 0 ? o : r;
7
7
  }
8
- function b(t) {
8
+ function b(n) {
9
9
  const r = /* @__PURE__ */ new Set();
10
- return t.map((s, a) => {
11
- let l = s.hasAttribute("data-header-cell") ? s.getAttribute("data-header-cell") ?? a : a;
12
- return r.has(l) && (l = `${l}#${a}`), r.add(l), l;
10
+ return n.map((o, t) => {
11
+ let l = o.hasAttribute("data-header-cell") ? o.getAttribute("data-header-cell") ?? t : t;
12
+ return r.has(l) && (l = `${l}#${t}`), r.add(l), l;
13
13
  });
14
14
  }
15
- function T(t, r) {
16
- const s = g(t), a = b(s), l = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Set();
15
+ function Y(n, r) {
16
+ const o = A(n), t = b(o), l = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set();
17
17
  for (const d of r) {
18
- if (d.target === t) continue;
19
- let n = d.target instanceof Element ? d.target : d.target.parentElement;
20
- if (!n || n.closest("[data-header-more]")) continue;
21
- for (; n && n.parentElement !== t; ) n = n.parentElement;
22
- const c = n ? s.indexOf(n) : -1;
23
- !n || c < 0 || (n.hasAttribute("data-header-folded") ? o : l).add(a[c]);
18
+ if (d.target === n) continue;
19
+ let s = d.target instanceof Element ? d.target : d.target.parentElement;
20
+ if (!s || s.closest("[data-header-more]")) continue;
21
+ for (; s && s.parentElement !== n; ) s = s.parentElement;
22
+ const c = s ? o.indexOf(s) : -1;
23
+ !s || c < 0 || (s.hasAttribute("data-header-folded") ? a : l).add(t[c]);
24
24
  }
25
- return { shown: [...l], folded: [...o] };
25
+ return { shown: [...l], folded: [...a] };
26
26
  }
27
- function V(t, r, s) {
28
- const a = g(t);
29
- if (a.length === 0) return !1;
30
- const l = b(a), o = t.querySelector(":scope > [data-header-tail]");
27
+ function z(n, r, o) {
28
+ const t = A(n);
29
+ if (t.length === 0) return !1;
30
+ const l = b(t), a = n.querySelector(":scope > [data-header-tail]");
31
31
  let d = 0;
32
- a.forEach((c, _) => {
33
- let f;
34
- r ? f = s.get(l[_]) ?? L(c) : (f = c.getBoundingClientRect().width, s.set(l[_], f)), d += f;
32
+ t.forEach((c, _) => {
33
+ let i;
34
+ r ? i = o.get(l[_]) ?? v(c) : (i = c.getBoundingClientRect().width, o.set(l[_], i)), d += i;
35
35
  });
36
- const n = t.clientWidth - ((o == null ? void 0 : o.getBoundingClientRect().width) ?? 0);
37
- return r ? d > n - 24 : d > n;
36
+ const s = n.clientWidth - ((a == null ? void 0 : a.getBoundingClientRect().width) ?? 0);
37
+ return r ? d > s - 24 : d > s;
38
38
  }
39
- function L(t) {
40
- var a;
41
- const r = t.querySelectorAll("[data-header-label]");
42
- if (r.length === 0) return t.getBoundingClientRect().width;
43
- let s = 0;
39
+ function v(n) {
40
+ var t;
41
+ const r = n.querySelectorAll("[data-header-label]");
42
+ if (r.length === 0) return n.getBoundingClientRect().width;
43
+ let o = 0;
44
44
  for (const l of r) {
45
- const o = (a = l.parentElement) == null ? void 0 : a.querySelector(":scope > [data-header-value]"), d = l.closest('[data-empty="true"]') != null, n = Math.max(l.scrollWidth, ((o == null ? void 0 : o.scrollWidth) ?? 0) * 1.16 + 40);
46
- s += Math.max(n + (d ? 24 : 32), d ? 0 : 96);
45
+ const a = (t = l.parentElement) == null ? void 0 : t.querySelector(":scope > [data-header-value]"), d = l.closest('[data-empty="true"]') != null, s = Math.max(l.scrollWidth, ((a == null ? void 0 : a.scrollWidth) ?? 0) * 1.16 + 40);
46
+ o += Math.max(s + (d ? 24 : 32), d ? 0 : 96);
47
47
  }
48
- return s;
48
+ return o;
49
49
  }
50
- const R = 2;
51
- function H(t) {
52
- var o;
53
- const r = t.querySelectorAll("[data-header-label]");
54
- if (r.length === 0) return t.getBoundingClientRect().width;
55
- const s = t.querySelectorAll("[data-header-value]");
56
- let a = 0, l = 0;
50
+ const k = 2;
51
+ function O(n) {
52
+ var a;
53
+ const r = n.querySelectorAll("[data-header-label]");
54
+ if (r.length === 0) return n.getBoundingClientRect().width;
55
+ const o = n.querySelectorAll("[data-header-value]");
56
+ let t = 0, l = 0;
57
57
  for (const d of r) {
58
- const n = ((o = d.parentElement) == null ? void 0 : o.querySelector(":scope > [data-header-value]")) ?? s[l];
59
- a += d.scrollWidth + ((n == null ? void 0 : n.scrollWidth) ?? 0) + 8 + 28, l++;
58
+ const s = ((a = d.parentElement) == null ? void 0 : a.querySelector(":scope > [data-header-value]")) ?? o[l];
59
+ t += d.scrollWidth + ((s == null ? void 0 : s.scrollWidth) ?? 0) + 8 + 28, l++;
60
60
  }
61
- return a;
61
+ return t;
62
+ }
63
+ const W = "__more__";
64
+ function q(n, r, o, t, l) {
65
+ const a = [], d = (i, u) => a[i] === r || u <= a[i] + 0.5, s = (i) => {
66
+ let u = l ? a.findIndex((E, p) => d(p, i)) : a.length - 1;
67
+ return (u < 0 || !d(u, i)) && (a.push(r), u = a.length - 1), a[u] -= i, u;
68
+ }, c = n.map((i) => i == null ? -1 : s(i)), _ = n.some((i) => i == null) ? s(o) : -1;
69
+ return a.length === 0 && a.push(r), t > 0 && !d(a.length - 1, t) && a.push(r - t), { count: a.length, rowOf: c, chipRow: _ };
62
70
  }
63
- function v(t) {
64
- if (t.matches('[data-empty="true"]') || t.querySelector('[data-empty="true"]')) return !0;
65
- const r = t.querySelectorAll("[data-header-value]");
66
- return r.length > 0 && Array.from(r).every((s) => {
67
- var a;
68
- return ((a = s.textContent) == null ? void 0 : a.trim()) === "—";
71
+ function B(n) {
72
+ if (n.matches('[data-empty="true"]') || n.querySelector('[data-empty="true"]')) return !0;
73
+ const r = n.querySelectorAll("[data-header-value]");
74
+ return r.length > 0 && Array.from(r).every((o) => {
75
+ var t;
76
+ return ((t = o.textContent) == null ? void 0 : t.trim()) === "—";
69
77
  });
70
78
  }
71
- function z(t, r, s) {
72
- const a = Array.from(t.children), l = a.find((e) => e.hasAttribute("data-header-more")), o = a.find((e) => e.hasAttribute("data-header-tail")), d = g(t);
73
- if (d.length === 0) return [];
74
- const n = b(d), c = d.map((e, h) => {
75
- const i = n[h];
79
+ function G(n, r, o) {
80
+ const t = Array.from(n.children), l = t.find((e) => e.hasAttribute("data-header-more")), a = t.find((e) => e.hasAttribute("data-header-tail")), d = A(n);
81
+ if (d.length === 0) return { folded: [], rows: null };
82
+ const s = b(d), c = d.map((e, h) => {
83
+ const f = s[h];
76
84
  if (r && !e.hasAttribute("data-header-folded")) {
77
- const m = e.getBoundingClientRect().width;
78
- m > 0 && s.set(i, m);
85
+ const g = e.getBoundingClientRect().width;
86
+ g > 0 && o.set(f, g);
79
87
  }
80
- return s.get(i) ?? H(e);
81
- }), _ = t.clientWidth, f = l ? l.getBoundingClientRect().width : 96, y = (o == null ? void 0 : o.getBoundingClientRect().width) ?? 0, w = (e) => {
82
- let h = 1, i = 0;
83
- const m = (u) => {
84
- i > 0 && i + u > _ + 0.5 && (h++, i = 0), i += u;
85
- };
86
- for (let u = 0; u < c.length; u++) e.has(u) || m(c[u]);
87
- return e.size > 0 && m(f), y > 0 && m(y), h;
88
- }, p = /* @__PURE__ */ new Set();
89
- if (w(p) <= R) return [];
90
- const x = d.map(v), A = d.map(
88
+ return o.get(f) ?? O(e);
89
+ }), _ = n.clientWidth, i = l ? l.getBoundingClientRect().width : 96, u = (a == null ? void 0 : a.getBoundingClientRect().width) ?? 0, E = (e, h) => q(
90
+ c.map((f, g) => e.has(g) ? null : f),
91
+ _,
92
+ i,
93
+ u,
94
+ h
95
+ ), p = /* @__PURE__ */ new Set();
96
+ if (E(p, !1).count <= k) return { folded: [], rows: null };
97
+ const x = d.map(B), R = d.map(
91
98
  (e) => e.hasAttribute("data-header-money") || e.querySelector("[data-header-money]") != null
92
- ), E = (e) => d.map((h, i) => i).filter(e).reverse(), k = [
93
- ...E((e) => x[e]),
94
- ...E((e) => !x[e] && !A[e]),
95
- ...E((e) => !x[e] && A[e])
99
+ ), D = d.map((e) => e.hasAttribute("data-header-pin")), w = (e) => d.map((h, f) => f).filter((h) => !D[h] && e(h)).reverse(), C = [
100
+ ...w((e) => x[e]),
101
+ ...w((e) => !x[e] && !R[e]),
102
+ ...w((e) => !x[e] && R[e])
96
103
  ];
97
- for (const e of k)
98
- if (p.add(e), w(p) <= R) break;
99
- return [...p].sort((e, h) => e - h).map((e) => {
100
- var h, i;
101
- return {
102
- index: e,
103
- key: n[e],
104
- empty: x[e],
105
- label: ((i = (h = d[e].querySelector("[data-header-label]")) == null ? void 0 : h.textContent) == null ? void 0 : i.trim()) ?? ""
106
- };
107
- });
104
+ let m = E(p, !0);
105
+ for (const e of C) {
106
+ if (m.count <= k) break;
107
+ p.add(e), m = E(p, !0);
108
+ }
109
+ const y = {};
110
+ return m.rowOf.forEach((e, h) => {
111
+ e >= 0 && (y[String(s[h])] = e);
112
+ }), m.chipRow >= 0 && (y[W] = m.chipRow), {
113
+ folded: [...p].sort((e, h) => e - h).map((e) => {
114
+ var h, f;
115
+ return {
116
+ index: e,
117
+ key: s[e],
118
+ empty: x[e],
119
+ label: ((f = (h = d[e].querySelector("[data-header-label]")) == null ? void 0 : h.textContent) == null ? void 0 : f.trim()) ?? ""
120
+ };
121
+ }),
122
+ rows: y
123
+ };
108
124
  }
109
125
  export {
110
- W as HEADER_BAND,
111
- D as HEADER_CELL_DENSE,
112
- S as HEADER_CELL_FOLDED,
113
- C as HEADER_CELL_LIST,
114
- K as HEADER_DOCK,
115
- j as HEADER_DOCK_CELL,
116
- U as HEADER_DOCK_INLINE,
117
- N as HEADER_LABEL,
118
- R as HEADER_MAX_ROWS,
119
- q as HEADER_ROW,
120
- F as HEADER_SUB,
121
- O as HEADER_TILE,
122
- B as HEADER_TILES,
123
- $ as HEADER_VALUE,
124
- I as HEADER_VALUE_HERO,
125
- M as HEADER_VALUE_LINE,
126
- v as headerCellIsEmpty,
126
+ I as HEADER_BAND,
127
+ S as HEADER_CELL_DENSE,
128
+ H as HEADER_CELL_FOLDED,
129
+ L as HEADER_CELL_LIST,
130
+ T as HEADER_DOCK,
131
+ F as HEADER_DOCK_CELL,
132
+ V as HEADER_DOCK_INLINE,
133
+ U as HEADER_LABEL,
134
+ k as HEADER_MAX_ROWS,
135
+ W as HEADER_MORE_ROW_KEY,
136
+ N as HEADER_ROW,
137
+ P as HEADER_SUB,
138
+ $ as HEADER_TILE,
139
+ K as HEADER_TILES,
140
+ j as HEADER_VALUE,
141
+ M as HEADER_VALUE_HERO,
142
+ X as HEADER_VALUE_LINE,
143
+ B as headerCellIsEmpty,
127
144
  b as headerCellKeys,
128
- g as headerCells,
129
- T as headerChangedCells,
130
- H as headerEstimateDenseWidth,
131
- z as headerFoldedCells,
132
- V as headerNeedsDense
145
+ A as headerCells,
146
+ Y as headerChangedCells,
147
+ O as headerEstimateDenseWidth,
148
+ G as headerFoldPlan,
149
+ z as headerNeedsDense,
150
+ q as headerPackRows
133
151
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nivaro/react",
3
- "version": "0.3.19",
3
+ "version": "0.3.20",
4
4
  "description": "React hooks and components for Nivaro CMS forms",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",