@nivaro/react 0.3.8 → 0.3.9

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.
@@ -52,17 +52,17 @@ const Be = /^[-+−]?\$?0(?:\.0+)?%?$/, fe = (i) => i === "—" ? /* @__PURE__ *
52
52
  ];
53
53
  function Ve(i, r, x, M = "month") {
54
54
  const k = /* @__PURE__ */ new Map(), I = /* @__PURE__ */ new Set();
55
- for (const b of i) {
56
- const W = r.key_fields.map((_) => String(b[_] ?? "")).join("|");
55
+ for (const m of i) {
56
+ const W = r.key_fields.map((_) => String(m[_] ?? "")).join("|");
57
57
  let u = k.get(W);
58
58
  if (!u) {
59
59
  u = {};
60
- for (const _ of r.key_fields) u[_] = b[_];
60
+ for (const _ of r.key_fields) u[_] = m[_];
61
61
  k.set(W, u);
62
62
  }
63
- const oe = String(b[r.date_field] ?? ""), w = /^(\d{4})-(\d{2})/.exec(oe);
63
+ const oe = String(m[r.date_field] ?? ""), w = /^(\d{4})-(\d{2})/.exec(oe);
64
64
  if (!w) continue;
65
- const G = Number(b[r.value_field]) || 0;
65
+ const G = Number(m[r.value_field]) || 0;
66
66
  if (Number(w[1]) === x) {
67
67
  const _ = Number(w[2]) - 1, q = M === "quarter" ? `q${Math.floor(_ / 3) + 1}` : ze[_];
68
68
  q && (u[q] = (Number(u[q]) || 0) + G);
@@ -70,28 +70,28 @@ function Ve(i, r, x, M = "month") {
70
70
  I.add(w[1]), u[`y${w[1]}`] = (Number(u[`y${w[1]}`]) || 0) + G;
71
71
  r.total !== !1 && (u.total = (Number(u.total) || 0) + G);
72
72
  }
73
- const le = [...I].filter((b) => Number(b) < x).sort(), R = [...I].filter((b) => Number(b) > x).sort(), P = M === "quarter" ? [1, 2, 3, 4].map((b) => ({
74
- field: `q${b}`,
75
- label: `Q${b}`,
73
+ const le = [...I].filter((m) => Number(m) < x).sort(), R = [...I].filter((m) => Number(m) > x).sort(), P = M === "quarter" ? [1, 2, 3, 4].map((m) => ({
74
+ field: `q${m}`,
75
+ label: `Q${m}`,
76
76
  format: "currency",
77
77
  sum: !0
78
- })) : ze.map((b, W) => ({
79
- field: b,
78
+ })) : ze.map((m, W) => ({
79
+ field: m,
80
80
  label: Qe[W],
81
81
  format: "currency",
82
82
  sum: !0
83
83
  })), L = r.color ? { color: r.color, color_negative: r.color_negative } : {}, se = [
84
- ...le.map((b) => ({
85
- field: `y${b}`,
86
- label: b,
84
+ ...le.map((m) => ({
85
+ field: `y${m}`,
86
+ label: m,
87
87
  format: "currency",
88
88
  sum: !0,
89
89
  ...L
90
90
  })),
91
- ...P.map((b) => ({ ...b, ...L })),
92
- ...R.map((b) => ({
93
- field: `y${b}`,
94
- label: b,
91
+ ...P.map((m) => ({ ...m, ...L })),
92
+ ...R.map((m) => ({
93
+ field: `y${m}`,
94
+ label: m,
95
95
  format: "currency",
96
96
  sum: !0,
97
97
  ...L
@@ -146,7 +146,7 @@ function Xe({
146
146
  emptyText: le
147
147
  }) {
148
148
  var we, _e, Se, qe, Ce, Fe, Me;
149
- const [R, P] = A(() => /* @__PURE__ */ new Set()), [L, se] = A("month"), [b, W] = A(
149
+ const [R, P] = A(() => /* @__PURE__ */ new Set()), [L, se] = A("month"), [m, W] = A(
150
150
  () => new Set(((r == null ? void 0 : r.toggles) ?? []).filter((e) => e.default_on === !1).map((e) => e.label))
151
151
  ), [u, oe] = A(null), [w, G] = A({
152
152
  overflows: !1,
@@ -156,9 +156,9 @@ function Xe({
156
156
  if (Ue(() => {
157
157
  if (!u) return;
158
158
  const e = () => {
159
- const a = u.scrollWidth > u.clientWidth + 1, n = u.scrollWidth > u.clientWidth + u.scrollLeft + 1, l = u.querySelector("[data-qt-actions-head]"), s = r != null && r.sticky && l ? l.offsetWidth : 0, m = u.offsetWidth - u.clientWidth + s, y = u.offsetHeight - u.clientHeight;
159
+ const a = u.scrollWidth > u.clientWidth + 1, n = u.scrollWidth > u.clientWidth + u.scrollLeft + 1, l = u.querySelector("[data-qt-actions-head]"), s = r != null && r.sticky && l ? l.offsetWidth : 0, b = u.offsetWidth - u.clientWidth + s, y = u.offsetHeight - u.clientHeight;
160
160
  G(
161
- (F) => F.overflows === a && F.canScrollRight === n && F.cueInset.right === m && F.cueInset.bottom === y ? F : { overflows: a, canScrollRight: n, cueInset: { right: m, bottom: y } }
161
+ (F) => F.overflows === a && F.canScrollRight === n && F.cueInset.right === b && F.cueInset.bottom === y ? F : { overflows: a, canScrollRight: n, cueInset: { right: b, bottom: y } }
162
162
  );
163
163
  };
164
164
  e();
@@ -182,10 +182,10 @@ function Xe({
182
182
  t.set(n, { ...a, [e]: n });
183
183
  continue;
184
184
  }
185
- for (const [s, m] of Object.entries(a)) {
185
+ for (const [s, b] of Object.entries(a)) {
186
186
  if (s === e) continue;
187
- const y = Number(m);
188
- Number.isFinite(y) && typeof m != "boolean" && (l[s] = (Number(l[s]) || 0) + y);
187
+ const y = Number(b);
188
+ Number.isFinite(y) && typeof b != "boolean" && (l[s] = (Number(l[s]) || 0) + y);
189
189
  }
190
190
  }
191
191
  q = [...t.entries()].sort(([a], [n]) => a.localeCompare(n)).map(([, a]) => a);
@@ -201,7 +201,7 @@ function Xe({
201
201
  for (const t of ke)
202
202
  t.field && e.push(t.field), t.stack && e.push(t.stack);
203
203
  for (const t of (r == null ? void 0 : r.toggles) ?? []) {
204
- const a = !b.has(t.label);
204
+ const a = !m.has(t.label);
205
205
  if (t.hide_when_on ? a : !a)
206
206
  for (const l of e)
207
207
  ((Se = t.fields) != null && Se.includes(l) || t.suffix && l.endsWith(t.suffix)) && K.add(l);
@@ -280,8 +280,8 @@ function Xe({
280
280
  }, T = (e, t) => r != null && r.zero_dash && Number(e) === 0 ? "—" : ae(e, t), Z = (e, t) => {
281
281
  var n;
282
282
  if ((n = t.sparkline_fields) != null && n.length) {
283
- const l = t.sparkline_fields.map((d) => Number(e[d]) || 0), s = Math.max(...l, 1), m = Math.min(...l, 0), y = Math.max(s - m, 1), F = l.map(
284
- (d, h) => `${h / Math.max(l.length - 1, 1) * 60},${17 - (d - m) / y * 15}`
283
+ const l = t.sparkline_fields.map((d) => Number(e[d]) || 0), s = Math.max(...l, 1), b = Math.min(...l, 0), y = Math.max(s - b, 1), F = l.map(
284
+ (d, h) => `${h / Math.max(l.length - 1, 1) * 60},${17 - (d - b) / y * 15}`
285
285
  ).join(" ");
286
286
  return /* @__PURE__ */ o(
287
287
  "svg",
@@ -303,11 +303,11 @@ function Xe({
303
303
  );
304
304
  }
305
305
  if (t.percent_of_total && t.field) {
306
- const l = Number(E(e, t)), s = Ie.get(t.field) ?? 0, m = s > 0 && Number.isFinite(l) ? l / s * 100 : null;
306
+ const l = Number(E(e, t)), s = Ie.get(t.field) ?? 0, b = s > 0 && Number.isFinite(l) ? l / s * 100 : null;
307
307
  return /* @__PURE__ */ f("span", { className: "inline-flex items-baseline gap-1", children: [
308
308
  T(E(e, t), t.format),
309
- m != null && /* @__PURE__ */ f("span", { className: "text-[9.5px] text-slate-400", children: [
310
- m.toLocaleString("en-US", { maximumFractionDigits: 1 }),
309
+ b != null && /* @__PURE__ */ f("span", { className: "text-[9.5px] text-slate-400", children: [
310
+ b.toLocaleString("en-US", { maximumFractionDigits: 1 }),
311
311
  "%"
312
312
  ] })
313
313
  ] });
@@ -332,7 +332,7 @@ function Xe({
332
332
  for (const a of p)
333
333
  a.group && a.group !== t && e++, ue.push(a.group ? e : -1), t = a.group;
334
334
  }
335
- const me = (e) => Ne && ue[e] >= 0 && ue[e] % 2 === 1 ? "bg-slate-50/70 dark:bg-muted/20" : "", g = !!(r != null && r.sticky), Q = "border-r border-slate-200 dark:border-border", We = (e, t) => g && e === 0 ? `sticky left-0 z-[1] ${Q} ${t}` : "", $e = (e) => g ? e === 0 ? `sticky left-0 top-0 z-[3] ${Q} bg-slate-50 dark:bg-muted` : "sticky top-0 z-[2] bg-white dark:bg-card" : "", U = (e) => g && (e === 0 || e === 1) ? "pl-3" : "", j = w.overflows ? "border-l border-slate-200 dark:border-border" : "", be = (e) => g ? `sticky right-0 z-[2] ${j} ${e}` : "", V = (e, t, a = 0, n) => {
335
+ const be = (e) => Ne && ue[e] >= 0 && ue[e] % 2 === 1 ? "bg-slate-50/70 dark:bg-muted/20" : "", g = !!(r != null && r.sticky), Q = "border-r border-slate-200 dark:border-border", We = (e, t) => g && e === 0 ? `sticky left-0 z-[1] ${Q} ${t}` : "", $e = (e) => g ? e === 0 ? `sticky left-0 top-0 z-[3] ${Q} bg-slate-50 dark:bg-muted` : "sticky top-0 z-[2] bg-white dark:bg-card" : "", U = (e) => g && (e === 0 || e === 1) ? "pl-3" : "", j = w.overflows ? "border-l border-slate-200 dark:border-border" : "", me = (e) => g ? `sticky right-0 z-[2] ${j} ${e}` : "", V = (e, t, a = 0, n) => {
336
336
  const l = a === !0 ? 1 : a === !1 ? 0 : a;
337
337
  return /* @__PURE__ */ f(
338
338
  "tr",
@@ -340,32 +340,32 @@ function Xe({
340
340
  onClick: x ? () => x(e) : void 0,
341
341
  className: `group/qtr border-b border-slate-100 dark:border-border/50 ${x ? "cursor-pointer" : ""} ${l >= 2 ? "bg-sky-50/70 hover:bg-sky-100/60 dark:bg-sky-500/10 dark:hover:bg-sky-500/15" : "hover:bg-slate-50 dark:hover:bg-muted/40"}`,
342
342
  children: [
343
- p.map((s, m) => /* @__PURE__ */ o(
343
+ p.map((s, b) => /* @__PURE__ */ o(
344
344
  "td",
345
345
  {
346
- className: `whitespace-nowrap py-1.5 pr-3 ${s.max_width ? "overflow-hidden text-ellipsis" : ""} ${U(m)} ${ne(s, "text-slate-700 dark:text-slate-200")} ${C(s) ? "text-right tabular-nums" : ""} ${s.group ? "min-w-[58px]" : ""} ${X(s) || me(m)} ${We(m, "bg-slate-50 group-hover/qtr:bg-slate-100 dark:bg-muted dark:group-hover/qtr:bg-muted")}`,
346
+ className: `whitespace-nowrap py-1.5 pr-3 ${s.max_width ? "overflow-hidden text-ellipsis" : ""} ${U(b)} ${ne(s, "text-slate-700 dark:text-slate-200")} ${C(s) ? "text-right tabular-nums" : ""} ${s.group ? "min-w-[58px]" : ""} ${X(s) || be(b)} ${We(b, "bg-slate-50 group-hover/qtr:bg-slate-100 dark:bg-muted dark:group-hover/qtr:bg-muted")}`,
347
347
  style: {
348
- ...l > 0 && m === 0 ? { paddingLeft: 2 + l * 16 } : {},
348
+ ...l > 0 && b === 0 ? { paddingLeft: 2 + l * 16 } : {},
349
349
  ...s.max_width ? { maxWidth: s.max_width } : {},
350
350
  ...B(s, Number(E(e, s))) ?? {}
351
351
  },
352
352
  title: s.max_width ? String(E(e, s) ?? "") : void 0,
353
- children: m === 0 && n !== void 0 ? n : Z(e, s)
353
+ children: b === 0 && n !== void 0 ? n : Z(e, s)
354
354
  },
355
- s.field ?? s.label ?? m
355
+ s.field ?? s.label ?? b
356
356
  )),
357
357
  k && /* @__PURE__ */ o(
358
358
  "td",
359
359
  {
360
- className: `py-1 pl-2 pr-3 text-right ${be(
360
+ className: `py-1 pl-2 pr-3 text-right ${me(
361
361
  l >= 2 ? "bg-[#f3f9fe] group-hover/qtr:bg-[#e7f3fd] dark:bg-card dark:group-hover/qtr:bg-muted" : "bg-white group-hover/qtr:bg-slate-50 dark:bg-card dark:group-hover/qtr:bg-muted"
362
362
  )}`,
363
363
  children: /* @__PURE__ */ o("span", { className: "inline-flex flex-nowrap gap-1", children: k.map((s) => /* @__PURE__ */ o(
364
364
  "button",
365
365
  {
366
366
  type: "button",
367
- onClick: (m) => {
368
- m.stopPropagation(), s.onClick(e);
367
+ onClick: (b) => {
368
+ b.stopPropagation(), s.onClick(e);
369
369
  },
370
370
  className: "whitespace-nowrap rounded border border-nvr-cyan/40 bg-nvr-cyan/10 px-1.5 py-0.5 text-[11px] text-slate-700 hover:brightness-105 dark:text-slate-200",
371
371
  children: s.label
@@ -385,11 +385,11 @@ function Xe({
385
385
  for (const l of q) {
386
386
  const s = String(l[e] ?? "").trim();
387
387
  if (!s) continue;
388
- const m = a.get(s) ?? [];
389
- m.push(l), a.set(s, m);
388
+ const b = a.get(s) ?? [];
389
+ b.push(l), a.set(s, b);
390
390
  }
391
391
  const n = [...a.entries()].sort(([l], [s]) => l.localeCompare(s)).map(([l, s]) => {
392
- const m = r.tree_collapsed ? !R.has(l) : R.has(l), y = { [e]: l }, F = (d) => {
392
+ const b = r.tree_collapsed ? !R.has(l) : R.has(l), y = { [e]: l }, F = (d) => {
393
393
  y[d] = s.reduce((h, ee) => {
394
394
  const J = Number(ee[d]);
395
395
  return Number.isFinite(J) ? h + J : h;
@@ -417,15 +417,15 @@ function Xe({
417
417
  d,
418
418
  Number(d.formula ? D(d.formula, y) : y[d.field ?? ""])
419
419
  ),
420
- children: h === 0 ? `${m ? "▸" : "▾"} ${l}` : d.formula ? T(D(d.formula, y), d.format) : d.field && d.field !== e && C(d) ? Z(y, d) : ""
420
+ children: h === 0 ? `${b ? "▸" : "▾"} ${l}` : d.formula ? T(D(d.formula, y), d.format) : d.field && d.field !== e && C(d) ? Z(y, d) : ""
421
421
  },
422
422
  d.field ?? d.label ?? h
423
423
  )),
424
- k && /* @__PURE__ */ o("td", { className: be("bg-slate-100 dark:bg-muted") })
424
+ k && /* @__PURE__ */ o("td", { className: me("bg-slate-100 dark:bg-muted") })
425
425
  ]
426
426
  }
427
427
  ),
428
- children: !m && (() => {
428
+ children: !b && (() => {
429
429
  const d = r.tree_sub_split;
430
430
  if (!d)
431
431
  return s.map((N, S) => {
@@ -479,7 +479,7 @@ function Xe({
479
479
  },
480
480
  c.field ?? c.label ?? v
481
481
  )),
482
- k && /* @__PURE__ */ o("td", { className: be("bg-slate-100 dark:bg-muted") })
482
+ k && /* @__PURE__ */ o("td", { className: me("bg-slate-100 dark:bg-muted") })
483
483
  ]
484
484
  }
485
485
  ),
@@ -504,7 +504,7 @@ function Xe({
504
504
  return /* @__PURE__ */ f("div", { className: g ? "flex min-h-0 flex-1 flex-col" : void 0, children: [
505
505
  (((qe = r == null ? void 0 : r.pivot) == null ? void 0 : qe.quarter_toggle) || (((Ce = r == null ? void 0 : r.toggles) == null ? void 0 : Ce.length) ?? 0) > 0) && /* @__PURE__ */ f("div", { className: "flex shrink-0 items-center justify-between gap-2 pb-2", children: [
506
506
  (((Fe = r == null ? void 0 : r.toggles) == null ? void 0 : Fe.length) ?? 0) > 0 ? /* @__PURE__ */ o("div", { className: "inline-flex gap-0.5 rounded-md border border-slate-200 bg-slate-50 p-0.5 dark:border-border dark:bg-muted/40", children: r.toggles.map((e) => {
507
- const t = !b.has(e.label);
507
+ const t = !m.has(e.label);
508
508
  return /* @__PURE__ */ o(
509
509
  "button",
510
510
  {
@@ -537,7 +537,7 @@ function Xe({
537
537
  {
538
538
  ref: oe,
539
539
  className: g ? "min-h-0 flex-1 overflow-auto" : "overflow-x-auto",
540
- children: /* @__PURE__ */ f("table", { className: "w-full text-[12px]", children: [
540
+ children: /* @__PURE__ */ f("table", { className: "w-full border-separate border-spacing-0 text-[12px] [&>tbody>tr.border-b>td]:border-b [&>tbody>tr.border-b>td]:[border-bottom-color:inherit] [&>tbody:has(+tfoot)>tr:last-child>td]:border-b-0 [&>tfoot>tr.border-t>td]:border-t [&>tfoot>tr.border-t>td]:[border-top-color:inherit]", children: [
541
541
  /* @__PURE__ */ o("thead", { children: Ne ? /* @__PURE__ */ f(Te, { children: [
542
542
  /* @__PURE__ */ f("tr", { children: [
543
543
  (() => {
@@ -567,7 +567,7 @@ function Xe({
567
567
  "th",
568
568
  {
569
569
  colSpan: n,
570
- className: `whitespace-nowrap border-b border-slate-100 py-1 pr-3 text-center text-[11px] font-semibold dark:border-border/60 ${a.group === Y ? "border-t-2 border-t-[#6366f1] bg-[#6366f10f] text-[#4f46e5] dark:border-t-[#a5b4fc] dark:bg-[#a5b4fc12] dark:text-[#a5b4fc]" : `text-slate-600 dark:text-slate-300 ${me(t)}`} ${g ? "sticky top-0 z-[2] bg-white dark:bg-card" : ""}`.trim(),
570
+ className: `whitespace-nowrap border-b border-slate-100 py-1 pr-3 text-center text-[11px] font-semibold dark:border-border/60 ${a.group === Y ? "border-t-2 border-t-[#6366f1] bg-[#6366f10f] text-[#4f46e5] dark:border-t-[#a5b4fc] dark:bg-[#a5b4fc12] dark:text-[#a5b4fc]" : `text-slate-600 dark:text-slate-300 ${be(t)}`} ${g ? "sticky top-0 z-[2] bg-white dark:bg-card" : ""}`.trim(),
571
571
  children: a.group
572
572
  },
573
573
  `g-${a.group}-${t}`
@@ -590,7 +590,7 @@ function Xe({
590
590
  (e, t) => e.group ? /* @__PURE__ */ o(
591
591
  "th",
592
592
  {
593
- className: `min-w-[58px] whitespace-nowrap border-b border-slate-200 py-1 pr-3 ${U(t)} text-[11px] font-medium text-slate-500 dark:border-border dark:text-slate-400 ${C(e) ? "text-right" : "text-left"} ${X(e) || me(t)} ${g ? "sticky top-[26px] z-[2] bg-white dark:bg-card" : ""}`,
593
+ className: `min-w-[58px] whitespace-nowrap border-b border-slate-200 py-1 pr-3 ${U(t)} text-[11px] font-medium text-slate-500 dark:border-border dark:text-slate-400 ${C(e) ? "text-right" : "text-left"} ${X(e) || be(t)} ${g ? "sticky top-[26px] z-[2] bg-white dark:bg-card" : ""}`,
594
594
  children: e.label ?? xe(e.field ?? "")
595
595
  },
596
596
  e.field ?? e.label ?? t