@nivaro/react 0.3.112 → 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.
@@ -0,0 +1,92 @@
1
+ import { combineTerms as d, totalTip as m, TOTAL_FNS as h, linearSumTerms as v } from "../cbv/column-totals.js";
2
+ const b = (e) => `nvr_queue_totals_${e}`;
3
+ function y(e) {
4
+ return /^(extra|formula)\.[A-Za-z_][\w.]*$/.test(e);
5
+ }
6
+ const T = "Worked out in the list from a formula that does more than add and subtract number columns, so it has no total.";
7
+ function s(e, r) {
8
+ var t, u;
9
+ const n = (t = r.meta) == null ? void 0 : t.find((o) => o.path === e);
10
+ return n != null && n.multi_value && !n.aggregate ? null : n != null && n.no_total ? { kind: "none", why: n.no_total } : n != null && n.number || (u = r.numberFormatPaths) != null && u.has(e) ? { kind: "server", path: e } : null;
11
+ }
12
+ function _(e, r) {
13
+ var n;
14
+ if (e.startsWith("extra.")) return s(e.slice(6), r);
15
+ if (e.startsWith("formula.")) {
16
+ const t = (n = r.formulas) == null ? void 0 : n.find((i) => `formula.${i.key}` === e);
17
+ if (!t) return null;
18
+ const u = v(t.formula), o = u == null ? void 0 : u.map(
19
+ (i) => i.field.startsWith("extra.") ? i.field.slice(6) : null
20
+ );
21
+ return u && (o != null && o.every((i) => {
22
+ var l;
23
+ return i != null && ((l = s(i, r)) == null ? void 0 : l.kind) === "server";
24
+ })) ? {
25
+ kind: "derived",
26
+ terms: u.map((i, l) => ({ field: o[l], sign: i.sign }))
27
+ } : { kind: "none", why: T };
28
+ }
29
+ return null;
30
+ }
31
+ function g(e, r) {
32
+ return Object.keys(e).filter((n) => {
33
+ const t = r(n);
34
+ return (t == null ? void 0 : t.kind) === "server" || (t == null ? void 0 : t.kind) === "derived" && e[n] === "sum";
35
+ });
36
+ }
37
+ function x(e, r) {
38
+ const n = [];
39
+ for (const t of e) {
40
+ const u = r(t), o = (u == null ? void 0 : u.kind) === "server" ? [u.path] : (u == null ? void 0 : u.kind) === "derived" ? u.terms.map((i) => i.field) : [];
41
+ for (const i of o) n.includes(i) || n.push(i);
42
+ }
43
+ return n.sort().slice(0, 12);
44
+ }
45
+ function c(e, r) {
46
+ return r === "count" ? e.count : e.count <= 0 ? null : r === "sum" ? e.sum : r === "min" ? e.min : r === "max" ? e.max : e.avg ?? (e.count > 0 ? e.sum / e.count : null);
47
+ }
48
+ function $(e, r, n) {
49
+ if (e) {
50
+ if (r.kind === "server") {
51
+ const t = e[r.path];
52
+ return t ? c(t, n) : void 0;
53
+ }
54
+ return r.kind === "derived" ? r.terms.some((t) => !e[t.field]) ? void 0 : r.terms.every((t) => {
55
+ var u;
56
+ return (((u = e[t.field]) == null ? void 0 : u.count) ?? 0) === 0;
57
+ }) ? null : d(r.terms, (t) => {
58
+ var u;
59
+ return ((u = e[t]) == null ? void 0 : u.sum) ?? 0;
60
+ }) : null;
61
+ }
62
+ }
63
+ function q(e) {
64
+ var t;
65
+ let r = m(e.fn, e.label, e.rows);
66
+ e.derivedText && (r += `, worked out as ${e.derivedText}`);
67
+ const n = Object.entries(e.byCollection ?? {});
68
+ if (n.length > 1) {
69
+ const u = ((t = h.find((i) => i.fn === e.fn)) == null ? void 0 : t.short) ?? e.fn, o = n.map(([i, l]) => {
70
+ var f;
71
+ const a = c(l, e.fn);
72
+ return `${((f = e.collectionLabel) == null ? void 0 : f.call(e, i)) ?? i} ${a == null ? "—" : e.format(a)}`;
73
+ }).join(" · ");
74
+ r += `. ${u} by source: ${o}`;
75
+ }
76
+ return e.partial && (r += ". This worklist is past its read limit, so the figure covers the rows it read, not every record."), r;
77
+ }
78
+ function O(e) {
79
+ return e === "currency" ? { type: "number", decimals: 2, thousands: !0, prefix: "$" } : null;
80
+ }
81
+ export {
82
+ T as FORMULA_NO_TOTAL,
83
+ O as formulaTotalFormat,
84
+ c as pickTotal,
85
+ g as queueTotalColumns,
86
+ x as queueTotalPaths,
87
+ q as queueTotalTip,
88
+ $ as queueTotalValue,
89
+ y as queueTotalsEligibleKey,
90
+ b as queueTotalsStoreKey,
91
+ _ as queueTotalsSupport
92
+ };
@@ -1,20 +1,24 @@
1
- import { choiceLabel as i } from "../../lib/utils.js";
2
- function c(e, t) {
1
+ import { choiceLabel as u } from "../../lib/utils.js";
2
+ function l(t, e) {
3
3
  var n;
4
- const r = (n = e == null ? void 0 : e.choices) == null ? void 0 : n.find((o) => o.value === t);
5
- return r ? i(r.text) : t;
4
+ const r = (n = t == null ? void 0 : t.choices) == null ? void 0 : n.find((o) => o.value === e);
5
+ return r ? u(r.text) : e;
6
6
  }
7
- function f(e) {
8
- const t = Object.entries(e ?? {}).filter(([, r]) => r > 0).sort((r, n) => n[1] - r[1] || r[0].localeCompare(n[0]));
9
- return t.length === 0 ? null : t.map(([r, n]) => `${r} ${n.toLocaleString("en-US")}`).join(" · ");
7
+ function a(t) {
8
+ const e = Object.entries(t ?? {}).filter(([, r]) => r > 0).sort((r, n) => n[1] - r[1] || r[0].localeCompare(n[0]));
9
+ return e.length === 0 ? null : e.map(([r, n]) => `${r} ${n.toLocaleString("en-US")}`).join(" · ");
10
10
  }
11
- function l(e) {
12
- if (!e || typeof e.tagName != "string") return !0;
13
- const t = e;
14
- return !!(t === document.body || t === document.documentElement || t.tagName === "TR" && t.hasAttribute("data-row-key"));
11
+ function c(t) {
12
+ if (!t || typeof t.tagName != "string") return !0;
13
+ const e = t;
14
+ return !!(e === document.body || e === document.documentElement || e.tagName === "TR" && e.hasAttribute("data-row-key"));
15
+ }
16
+ function s(t) {
17
+ return (t ?? []).filter((e) => (e == null ? void 0 : e.key) && e.formula).map((e) => `formula.${e.key}`);
15
18
  }
16
19
  export {
17
- f as atRiskBreakdown,
18
- c as extraChoiceText,
19
- l as worklistKeyTarget
20
+ a as atRiskBreakdown,
21
+ l as extraChoiceText,
22
+ s as formulaColumnKeys,
23
+ c as worklistKeyTarget
20
24
  };
@@ -1,5 +1,5 @@
1
- import { noteTrailAddress as L } from "./nav-trail.js";
2
- const u = "lv", m = "nvr:list-address", A = 1, v = 7e3;
1
+ import { noteTrailAddress as m } from "./nav-trail.js";
2
+ const u = "lv", L = "nvr:list-address", A = 1, v = 7e3;
3
3
  function k(t) {
4
4
  const e = new TextEncoder().encode(t);
5
5
  let o = "";
@@ -8,7 +8,7 @@ function k(t) {
8
8
  }
9
9
  function S(t) {
10
10
  try {
11
- const e = t.replace(/-/g, "+").replace(/_/g, "/"), o = atob(e + "=".repeat((4 - e.length % 4) % 4)), i = Uint8Array.from(o, (r) => r.charCodeAt(0));
11
+ const e = t.replace(/-/g, "+").replace(/_/g, "/"), o = atob(e + "=".repeat((4 - e.length % 4) % 4)), i = Uint8Array.from(o, (c) => c.charCodeAt(0));
12
12
  return new TextDecoder().decode(i);
13
13
  } catch {
14
14
  return null;
@@ -38,10 +38,10 @@ function $(t, e, o) {
38
38
  const i = new URL(t);
39
39
  return i.searchParams.set(u, b(e, o)), i.toString();
40
40
  }
41
- function N(t) {
41
+ function O(t) {
42
42
  return typeof window > "u" ? null : _(new URLSearchParams(window.location.search).get(u), t);
43
43
  }
44
- function j() {
44
+ function T() {
45
45
  if (typeof window > "u") return;
46
46
  const t = new URLSearchParams(window.location.search);
47
47
  if (!t.has(u)) return;
@@ -53,24 +53,24 @@ function j() {
53
53
  `${window.location.pathname}${e ? `?${e}` : ""}${window.location.hash}`
54
54
  );
55
55
  }
56
- function I(t, e) {
56
+ function N(t, e) {
57
57
  if (typeof window > "u" || !window.history) return;
58
58
  const o = new URLSearchParams(window.location.search), i = e ? b(t, e) : null;
59
59
  if ((o.get(u) ?? null) === i) return;
60
60
  i ? o.set(u, i) : o.delete(u);
61
- const r = o.toString(), l = `${window.location.pathname}${r ? `?${r}` : ""}${window.location.hash}`;
61
+ const c = o.toString(), a = `${window.location.pathname}${c ? `?${c}` : ""}${window.location.hash}`;
62
62
  try {
63
- window.history.replaceState(window.history.state, "", l);
63
+ window.history.replaceState(window.history.state, "", a);
64
64
  } catch {
65
65
  return;
66
66
  }
67
- L(l);
67
+ m(a);
68
68
  try {
69
- window.dispatchEvent(new CustomEvent(m, { detail: { path: l } }));
69
+ window.dispatchEvent(new CustomEvent(L, { detail: { path: a } }));
70
70
  } catch {
71
71
  }
72
72
  }
73
- async function O(t, e) {
73
+ async function I(t, e) {
74
74
  if (typeof window > "u") return "failed";
75
75
  const o = $(window.location.href, t, e);
76
76
  if (o.length > v) return "too-long";
@@ -80,7 +80,7 @@ async function O(t, e) {
80
80
  return "failed";
81
81
  }
82
82
  }
83
- const a = (t) => !!t && typeof t == "object" && !Array.isArray(t), y = (t) => typeof t == "string" ? t : void 0, g = (t) => Array.isArray(t) ? t.filter((e) => typeof e == "string") : void 0, E = (t) => Array.isArray(t) ? t.filter((e) => typeof e == "string" || typeof e == "number") : [], d = (t, e) => {
83
+ const l = (t) => !!t && typeof t == "object" && !Array.isArray(t), y = (t) => typeof t == "string" ? t : void 0, g = (t) => Array.isArray(t) ? t.filter((e) => typeof e == "string") : void 0, j = (t) => Array.isArray(t) ? t.filter((e) => typeof e == "string" || typeof e == "number") : [], d = (t, e) => {
84
84
  const o = Number(t);
85
85
  return Number.isInteger(o) && o > 0 ? Math.min(o, e) : void 0;
86
86
  };
@@ -88,83 +88,89 @@ function R(t) {
88
88
  if (!t) return null;
89
89
  const e = {}, o = y(t.q);
90
90
  o && (e.q = o.slice(0, 500)), Array.isArray(t.f) && (e.f = t.f.filter(
91
- (n) => a(n) && Array.isArray(n.path) && typeof n.op == "string"
92
- ).slice(0, 50).map((n, s) => ({
91
+ (n) => l(n) && Array.isArray(n.path) && typeof n.op == "string"
92
+ ).slice(0, 50).map((n, r) => ({
93
93
  ...n,
94
- id: typeof n.id == "string" && n.id ? n.id : `lv-${s}`,
94
+ id: typeof n.id == "string" && n.id ? n.id : `lv-${r}`,
95
95
  pathLabels: Array.isArray(n.pathLabels) ? n.pathLabels : n.path,
96
96
  fieldType: typeof n.fieldType == "string" ? n.fieldType : "string",
97
97
  value: n.value ?? ""
98
98
  })));
99
99
  const i = y(t.s);
100
100
  if (i && /^-?[\w.$]+$/.test(i) && (e.s = i), Array.isArray(t.c) && (e.c = t.c.filter(
101
- (n) => typeof n == "string" || a(n) && typeof n.key == "string"
102
- ).slice(0, 100)), a(t.qf)) {
101
+ (n) => typeof n == "string" || l(n) && typeof n.key == "string"
102
+ ).slice(0, 100)), l(t.qf)) {
103
103
  const n = {};
104
- for (const [s, f] of Object.entries(t.qf)) {
105
- const h = E(f);
106
- h.length && (n[s] = h.slice(0, 500));
104
+ for (const [r, f] of Object.entries(t.qf)) {
105
+ const h = j(f);
106
+ h.length && (n[r] = h.slice(0, 500));
107
107
  }
108
108
  e.qf = n;
109
109
  }
110
- if (a(t.cf)) {
110
+ if (l(t.cf)) {
111
111
  const n = {};
112
- for (const [s, f] of Object.entries(t.cf))
113
- a(f) && typeof f.kind == "string" && (n[s] = f);
112
+ for (const [r, f] of Object.entries(t.cf))
113
+ l(f) && typeof f.kind == "string" && (n[r] = f);
114
114
  e.cf = n;
115
115
  }
116
116
  Array.isArray(t.lc) && (e.lc = t.lc.filter(
117
- (n) => a(n) && Array.isArray(n.path) && typeof n.op == "string"
118
- ).slice(0, 50)), Array.isArray(t.ex) && (e.ex = t.ex.filter((n) => a(n) && Array.isArray(n.path)).slice(0, 50));
119
- const r = y(t.g);
120
- r && /^[\w.$]+$/.test(r) && (e.g = r);
121
- const l = d(t.ps, 200);
122
- l && (e.ps = l);
117
+ (n) => l(n) && Array.isArray(n.path) && typeof n.op == "string"
118
+ ).slice(0, 50)), Array.isArray(t.ex) && (e.ex = t.ex.filter((n) => l(n) && Array.isArray(n.path)).slice(0, 50));
119
+ const c = y(t.g);
120
+ c && /^[\w.$]+$/.test(c) && (e.g = c);
121
+ const a = d(t.ps, 200);
122
+ a && (e.ps = a);
123
123
  const p = d(t.p, 1e5);
124
124
  p && (e.p = p), t.a === !0 && (e.a = !0);
125
- const c = d(t.v, Number.MAX_SAFE_INTEGER);
126
- return c && (e.v = c), e;
125
+ const s = d(t.v, Number.MAX_SAFE_INTEGER);
126
+ return s && (e.v = s), e;
127
127
  }
128
128
  function q(t) {
129
129
  if (!t) return null;
130
130
  const e = {};
131
- if ((t.scope === "mine" || t.scope === "unowned" || t.scope === "all" || t.scope === "claimed") && (e.scope = t.scope), a(t.filters)) {
132
- const c = {};
133
- for (const [n, s] of Object.entries(t.filters))
134
- if (typeof s == "string") c[n] = s.slice(0, 500);
131
+ if ((t.scope === "mine" || t.scope === "unowned" || t.scope === "all" || t.scope === "claimed") && (e.scope = t.scope), l(t.filters)) {
132
+ const s = {};
133
+ for (const [n, r] of Object.entries(t.filters))
134
+ if (typeof r == "string") s[n] = r.slice(0, 500);
135
135
  else {
136
- const f = g(s);
137
- f != null && f.length && (c[n] = f.slice(0, 500));
136
+ const f = g(r);
137
+ f != null && f.length && (s[n] = f.slice(0, 500));
138
138
  }
139
- e.filters = c;
139
+ e.filters = s;
140
140
  }
141
141
  const o = y(t.sort);
142
142
  o && /^-?[\w.$]+$/.test(o) && (e.sort = o);
143
143
  const i = y(t.group_by);
144
144
  i && (e.group_by = i), (t.view === "table" || t.view === "kanban" || t.view === "workload") && (e.view = t.view);
145
- const r = g(t.columns);
146
- if (r != null && r.length && (e.columns = r.slice(0, 100)), a(t.pins)) {
147
- const c = {};
148
- for (const [n, s] of Object.entries(t.pins)) (s === "left" || s === "right") && (c[n] = s);
149
- Object.keys(c).length && (e.pins = c);
145
+ const c = g(t.columns);
146
+ if (c != null && c.length && (e.columns = c.slice(0, 100)), l(t.pins)) {
147
+ const s = {};
148
+ for (const [n, r] of Object.entries(t.pins)) (r === "left" || r === "right") && (s[n] = r);
149
+ Object.keys(s).length && (e.pins = s);
150
150
  }
151
- const l = d(t.page, 1e5);
152
- l && (e.page = l);
151
+ if (l(t.totals)) {
152
+ const s = {};
153
+ for (const [n, r] of Object.entries(t.totals))
154
+ /^(extra|formula)\.[A-Za-z_][\w.]*$/.test(n) && (r === "sum" || r === "avg" || r === "min" || r === "max" || r === "count") && (s[n] = r);
155
+ Object.keys(s).length && (e.totals = s);
156
+ }
157
+ const a = d(t.page, 1e5);
158
+ a && (e.page = a);
153
159
  const p = d(t.view_id, Number.MAX_SAFE_INTEGER);
154
160
  return p && (e.view_id = p), e;
155
161
  }
156
162
  export {
157
- m as LIST_ADDRESS_EVENT,
163
+ L as LIST_ADDRESS_EVENT,
158
164
  v as LIST_LINK_MAX_CHARS,
159
165
  u as LIST_LINK_PARAM,
160
- O as copyListLink,
166
+ I as copyListLink,
161
167
  _ as decodeListLink,
162
- j as dropListLinkParam,
168
+ T as dropListLinkParam,
163
169
  b as encodeListLink,
164
170
  $ as listLinkUrl,
165
171
  w as pruneListLinkState,
166
- N as readListLinkFromLocation,
167
- I as replaceListLinkParam,
172
+ O as readListLinkFromLocation,
173
+ N as replaceListLinkParam,
168
174
  R as sanitizeCbvLinkState,
169
175
  q as sanitizeQueueLinkState
170
176
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nivaro/react",
3
- "version": "0.3.112",
3
+ "version": "0.3.114",
4
4
  "description": "React hooks and components for Nivaro CMS forms",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",