@nivaro/react 0.3.113 → 0.3.114

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,5 +1,5 @@
1
1
  import { formatValue as S } from "../../lib/format-value.js";
2
- const p = [
2
+ const g = [
3
3
  { fn: "sum", label: "Sum", short: "Sum" },
4
4
  { fn: "avg", label: "Average", short: "Avg" },
5
5
  { fn: "min", label: "Minimum", short: "Min" },
@@ -7,66 +7,72 @@ const p = [
7
7
  { fn: "count", label: "Count (filled in)", short: "Count" }
8
8
  ];
9
9
  function b(e) {
10
- return typeof e == "string" && p.some((n) => n.fn === e);
10
+ return typeof e == "string" && g.some((n) => n.fn === e);
11
11
  }
12
12
  function v(e) {
13
13
  return /^[A-Za-z_][A-Za-z0-9_]*$/.test(e);
14
14
  }
15
- function O(e, n, t) {
15
+ function w(e, n, t) {
16
16
  return {
17
17
  [n]: e,
18
18
  ...t.search ? { search: t.search } : {},
19
19
  ...t.conditions ? { conditions: t.conditions } : {}
20
20
  };
21
21
  }
22
- function x(e, n, t) {
23
- var s, l, a;
24
- const r = (a = (l = (s = e == null ? void 0 : e.data) == null ? void 0 : s[0]) == null ? void 0 : l[t]) == null ? void 0 : a[n];
22
+ function M(e, n, t) {
23
+ var i, l, c;
24
+ const r = (c = (l = (i = e == null ? void 0 : e.data) == null ? void 0 : i[0]) == null ? void 0 : l[t]) == null ? void 0 : c[n];
25
25
  if (r == null || r === "") return null;
26
26
  const o = Number(r);
27
27
  return Number.isFinite(o) ? o : null;
28
28
  }
29
- function k(e, n, t) {
29
+ function $(e, n, t) {
30
30
  return n === "count" ? Math.round(e).toLocaleString("en-US") : (t == null ? void 0 : t.type) === "number" ? S(String(e), t) : (Math.round(e * 100) / 100).toLocaleString("en-US", { maximumFractionDigits: 2 });
31
31
  }
32
- const d = (e) => `nvr_cbv_totals_${e}`, _ = (e) => e === "off" || b(e);
33
- function w(e) {
32
+ const p = (e) => `nvr_cbv_totals_${e}`, _ = (e) => e === "off" || b(e);
33
+ function k(e) {
34
+ return y(p(e), v);
35
+ }
36
+ function z(e, n) {
37
+ T(p(e), n);
38
+ }
39
+ function y(e, n) {
34
40
  try {
35
- const n = localStorage.getItem(d(e)), t = n ? JSON.parse(n) : null;
36
- if (!t || typeof t != "object") return {};
37
- const r = t.v === 2 && t.o && typeof t.o == "object" ? t.o : t, o = {};
38
- for (const [s, l] of Object.entries(r)) v(s) && _(l) && (o[s] = l);
39
- return o;
41
+ const t = localStorage.getItem(e), r = t ? JSON.parse(t) : null;
42
+ if (!r || typeof r != "object") return {};
43
+ const o = r.v === 2 && r.o && typeof r.o == "object" ? r.o : r, i = {};
44
+ for (const [l, c] of Object.entries(o)) n(l) && _(c) && (i[l] = c);
45
+ return i;
40
46
  } catch {
41
47
  return {};
42
48
  }
43
49
  }
44
- function M(e, n) {
50
+ function T(e, n) {
45
51
  try {
46
- Object.keys(n).length === 0 ? localStorage.removeItem(d(e)) : localStorage.setItem(d(e), JSON.stringify({ v: 2, o: n }));
52
+ Object.keys(n).length === 0 ? localStorage.removeItem(e) : localStorage.setItem(e, JSON.stringify({ v: 2, o: n }));
47
53
  } catch {
48
54
  }
49
55
  }
50
- function $(e, n) {
56
+ function j(e, n) {
51
57
  const t = { ...e };
52
58
  for (const [r, o] of Object.entries(n))
53
59
  o === "off" ? delete t[r] : t[r] = o;
54
60
  return t;
55
61
  }
56
- function z(e, n, t) {
62
+ function N(e, n, t) {
57
63
  return { ...e, [n]: t ?? "off" };
58
64
  }
59
- function j(e, n) {
65
+ function Z(e, n) {
60
66
  const t = {};
61
67
  for (const [r, o] of Object.entries(e))
62
68
  (o === "off" ? !n[r] : n[r] === o) || (t[r] = o);
63
69
  return t;
64
70
  }
65
- function g(e) {
71
+ function h(e) {
66
72
  return !e.computed_formula || !!e.computed_store;
67
73
  }
68
- const y = /* @__PURE__ */ new Set(["integer", "bigInteger", "biginteger", "decimal", "float"]);
69
- function T(e) {
74
+ const A = /* @__PURE__ */ new Set(["integer", "bigInteger", "biginteger", "decimal", "float"]);
75
+ function O(e) {
70
76
  const n = String(e ?? "").trim();
71
77
  if (!n) return null;
72
78
  let t = 0;
@@ -74,53 +80,53 @@ function T(e) {
74
80
  for (; t < n.length && /\s/.test(n[t]); ) t++;
75
81
  }, o = () => {
76
82
  r();
77
- const u = n.slice(t), i = /^item\.([A-Za-z_][A-Za-z0-9_]*)/.exec(u);
78
- if (i)
79
- return t += i[0].length, i[1];
80
- const c = /^\{\{\s*([A-Za-z_][A-Za-z0-9_]*)\s*\}\}/.exec(u);
81
- if (c)
82
- return t += c[0].length, c[1];
83
- const f = /^coalesce\s*\(/i.exec(u);
83
+ const a = n.slice(t), s = /^item\.([A-Za-z_][A-Za-z0-9_]*)/.exec(a);
84
+ if (s)
85
+ return t += s[0].length, s[1];
86
+ const u = /^\{\{\s*([A-Za-z_][A-Za-z0-9_.]*)\s*\}\}/.exec(a);
87
+ if (u)
88
+ return t += u[0].length, u[1];
89
+ const f = /^coalesce\s*\(/i.exec(a);
84
90
  if (f) {
85
91
  t += f[0].length;
86
- const m = o(), h = /^\s*,\s*0(?:\.0+)?\s*\)/.exec(n.slice(t));
87
- return !m || !h ? null : (t += h[0].length, m);
92
+ const d = o(), m = /^\s*,\s*0(?:\.0+)?\s*\)/.exec(n.slice(t));
93
+ return !d || !m ? null : (t += m[0].length, d);
88
94
  }
89
95
  return null;
90
- }, s = /* @__PURE__ */ new Map(), l = (u) => {
91
- let i = !0;
96
+ }, i = /* @__PURE__ */ new Map(), l = (a) => {
97
+ let s = !0;
92
98
  for (; ; ) {
93
99
  r();
94
- let c = u;
100
+ let u = a;
95
101
  if (n[t] === "+" || n[t] === "-")
96
- n[t] === "-" && (c = c === 1 ? -1 : 1), t++, r();
97
- else if (!i) return !1;
98
- if (i = !1, n[t] === "(") {
99
- if (t++, !l(c) || (r(), n[t] !== ")")) return !1;
102
+ n[t] === "-" && (u = u === 1 ? -1 : 1), t++, r();
103
+ else if (!s) return !1;
104
+ if (s = !1, n[t] === "(") {
105
+ if (t++, !l(u) || (r(), n[t] !== ")")) return !1;
100
106
  t++;
101
107
  } else {
102
108
  const f = o();
103
109
  if (!f) return !1;
104
- s.set(f, (s.get(f) ?? 0) + c);
110
+ i.set(f, (i.get(f) ?? 0) + u);
105
111
  }
106
112
  if (r(), t >= n.length || n[t] === ")") return !0;
107
113
  if (n[t] !== "+" && n[t] !== "-") return !1;
108
114
  }
109
115
  };
110
116
  if (!l(1) || (r(), t !== n.length)) return null;
111
- const a = [];
112
- for (const [u, i] of s)
113
- if (i === 1 || i === -1) a.push({ field: u, sign: i });
114
- else if (i !== 0) return null;
115
- return a.length ? a : null;
116
- }
117
- function N(e, n) {
118
- if (g(e)) return { kind: "server" };
117
+ const c = [];
118
+ for (const [a, s] of i)
119
+ if (s === 1 || s === -1) c.push({ field: a, sign: s });
120
+ else if (s !== 0) return null;
121
+ return c.length ? c : null;
122
+ }
123
+ function C(e, n) {
124
+ if (h(e)) return { kind: "server" };
119
125
  if (e.computed_type !== "rollup") {
120
- const t = T(e.computed_formula ?? "");
126
+ const t = O(e.computed_formula ?? "");
121
127
  if (t != null && t.every((r) => {
122
128
  const o = n(r.field);
123
- return !!o && g(o) && y.has(String(o.type ?? ""));
129
+ return !!o && h(o) && A.has(String(o.type ?? ""));
124
130
  }))
125
131
  return { kind: "derived", terms: t };
126
132
  }
@@ -129,7 +135,7 @@ function N(e, n) {
129
135
  why: e.computed_type === "rollup" ? "Worked out from linked records each time the list is read, so it has no total." : "Calculated each time the list is read from a formula that does more than add and subtract stored columns, so it has no total."
130
136
  };
131
137
  }
132
- function Z(e, n) {
138
+ function F(e, n) {
133
139
  let t = 0;
134
140
  for (const r of e) {
135
141
  const o = n(r.field);
@@ -138,26 +144,28 @@ function Z(e, n) {
138
144
  }
139
145
  return Math.round(t * 1e6) / 1e6;
140
146
  }
141
- function C(e, n, t) {
142
- var s;
143
- const r = ((s = p.find((l) => l.fn === e)) == null ? void 0 : s.label.toLowerCase()) ?? e, o = t == null ? "all matching records" : `all ${t.toLocaleString("en-US")} matching records`;
147
+ function L(e, n, t) {
148
+ var i;
149
+ const r = ((i = g.find((l) => l.fn === e)) == null ? void 0 : i.label.toLowerCase()) ?? e, o = t == null ? "all matching records" : `all ${t.toLocaleString("en-US")} matching records`;
144
150
  return e === "count" ? `Records with ${n} filled in, across ${o}` : `${r.charAt(0).toUpperCase()}${r.slice(1)} of ${n} across ${o}`;
145
151
  }
146
152
  export {
147
- p as TOTAL_FNS,
148
- Z as combineTerms,
149
- k as formatTotal,
150
- g as isStoredField,
153
+ g as TOTAL_FNS,
154
+ F as combineTerms,
155
+ $ as formatTotal,
156
+ h as isStoredField,
151
157
  b as isTotalFn,
152
- T as linearSumTerms,
153
- w as loadTotalOverrides,
154
- j as overridesAfterSave,
155
- x as readTotal,
156
- M as rememberTotalOverrides,
157
- z as setOverride,
158
- $ as shownTotals,
159
- C as totalTip,
158
+ O as linearSumTerms,
159
+ k as loadTotalOverrides,
160
+ y as loadTotalOverridesAt,
161
+ Z as overridesAfterSave,
162
+ M as readTotal,
163
+ z as rememberTotalOverrides,
164
+ T as rememberTotalOverridesAt,
165
+ N as setOverride,
166
+ j as shownTotals,
167
+ L as totalTip,
160
168
  v as totalsEligibleKey,
161
- O as totalsParams,
162
- N as totalsSupport
169
+ w as totalsParams,
170
+ C as totalsSupport
163
171
  };