@nivaro/react 0.3.19 → 0.3.21

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,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.21",
4
4
  "description": "React hooks and components for Nivaro CMS forms",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",