@nivaro/react 0.3.58 → 0.3.59

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.
Files changed (43) hide show
  1. package/dist/components/fields/RelationField.js +110 -80
  2. package/dist/full.css +1 -1
  3. package/dist/hooks/useRelationOptions.js +1 -0
  4. package/dist/hooks/useSessionRecorder.js +1 -1
  5. package/dist/index.d.ts +32 -1
  6. package/dist/index.js +523 -520
  7. package/dist/shared/components/CollectionBrowserView.js +2083 -2052
  8. package/dist/shared/components/DataTable.js +497 -465
  9. package/dist/shared/components/ItemEditForm.js +4430 -4282
  10. package/dist/shared/components/PageRenderer.js +537 -508
  11. package/dist/shared/components/QueryTable.js +74 -74
  12. package/dist/shared/components/WidgetSlot.js +543 -520
  13. package/dist/shared/components/alerts/AlertManagerView.js +269 -275
  14. package/dist/shared/components/alerts/types.js +37 -14
  15. package/dist/shared/components/item-edit/FieldRenderer.js +22 -20
  16. package/dist/shared/components/item-edit/GridBulkEditDialog.js +55 -54
  17. package/dist/shared/components/item-edit/InlineTableField.js +2461 -2421
  18. package/dist/shared/components/item-edit/M2MCombobox.js +141 -137
  19. package/dist/shared/components/item-edit/PlanGrid.js +876 -820
  20. package/dist/shared/components/item-edit/QuickCreateButton.js +323 -130
  21. package/dist/shared/components/item-edit/RelationCombobox.js +408 -375
  22. package/dist/shared/components/item-edit/RelationGroupedCombobox.js +255 -156
  23. package/dist/shared/components/item-edit/SummaryPanel.js +356 -343
  24. package/dist/shared/components/item-edit/duplicate-rehearsal.js +47 -0
  25. package/dist/shared/components/item-edit/line-midair.js +82 -75
  26. package/dist/shared/components/item-edit/save-outcome.js +6 -4
  27. package/dist/shared/components/panels/ItemLockBanner.js +212 -209
  28. package/dist/shared/components/panels/PipelinePanel.js +775 -737
  29. package/dist/shared/components/panels/RecordIntegrityBanner.js +114 -86
  30. package/dist/shared/components/panels/RevisionsPanel.js +313 -299
  31. package/dist/shared/components/pipeline/PipelineEditorView.js +26 -16
  32. package/dist/shared/components/queue/QueueQuickFilters.js +13 -13
  33. package/dist/shared/components/queue/QueueWorklist.js +978 -953
  34. package/dist/shared/components/queue/live-state-aspect.js +9 -5
  35. package/dist/shared/components/widgets/ReviewListWidget.js +152 -149
  36. package/dist/shared/lib/display-prefs.js +60 -52
  37. package/dist/shared/lib/draft-store.js +71 -48
  38. package/dist/shared/lib/expression.js +53 -53
  39. package/dist/shared/lib/list-page-memory.js +42 -20
  40. package/dist/shared/lib/money-input.js +45 -0
  41. package/dist/shared/lib/sanitize-html.js +10 -6
  42. package/dist/shared/lib/staged-row-labels.js +18 -0
  43. package/package.json +1 -1
@@ -1,41 +1,63 @@
1
- const c = "nvr:list-page:";
1
+ const s = "nvr:list-page:";
2
2
  function l() {
3
- var t;
3
+ var e;
4
4
  if (typeof window > "u") return null;
5
- const e = (t = window.history) == null ? void 0 : t.state;
6
- return typeof (e == null ? void 0 : e.key) == "string" && e.key ? e.key : null;
5
+ const t = (e = window.history) == null ? void 0 : e.state;
6
+ return typeof (t == null ? void 0 : t.key) == "string" && t.key ? t.key : null;
7
7
  }
8
- function f(e, t) {
9
- return `${c}${e}|${t}`;
8
+ function f() {
9
+ const t = l();
10
+ if (t || typeof window > "u" || !window.history) return t;
11
+ try {
12
+ const e = window.history.state, r = e && typeof e == "object" ? e : {}, n = `nvr${Math.random().toString(36).slice(2, 10)}`;
13
+ return window.history.replaceState({ ...r, key: n }, ""), l();
14
+ } catch {
15
+ return null;
16
+ }
10
17
  }
11
- function a(e, t = l()) {
12
- if (!t) return null;
18
+ function a(t, e) {
19
+ return `${s}${t}|${e}`;
20
+ }
21
+ function h(t, e = l()) {
22
+ if (!e) return null;
13
23
  try {
14
- const r = window.sessionStorage.getItem(f(e, t)), n = r == null ? Number.NaN : Number(r);
24
+ const r = window.sessionStorage.getItem(a(t, e)), n = r == null ? Number.NaN : Number(r);
15
25
  return Number.isInteger(n) && n > 1 && n < 1e5 ? n : null;
16
26
  } catch {
17
27
  return null;
18
28
  }
19
29
  }
20
- function m(e, t, r = l()) {
30
+ function y(t, e, r = e > 1 ? f() : l()) {
21
31
  if (r)
22
32
  try {
23
- const n = window.sessionStorage, u = f(e, r);
24
- if (!(t > 1)) {
25
- n.removeItem(u);
33
+ const n = window.sessionStorage, c = a(t, r);
34
+ if (!(e > 1)) {
35
+ n.removeItem(c);
26
36
  return;
27
37
  }
28
- n.setItem(u, String(Math.floor(t)));
29
- const i = [];
38
+ n.setItem(c, String(Math.floor(e)));
39
+ const u = [];
30
40
  for (let o = 0; o < n.length; o++) {
31
- const s = n.key(o);
32
- s != null && s.startsWith(c) && i.push(s);
41
+ const i = n.key(o);
42
+ i != null && i.startsWith(s) && u.push(i);
33
43
  }
34
- for (const o of i.slice(0, Math.max(0, i.length - 50))) n.removeItem(o);
44
+ for (const o of u.slice(0, Math.max(0, u.length - 50))) n.removeItem(o);
35
45
  } catch {
36
46
  }
37
47
  }
48
+ function g(t, e) {
49
+ return t && t > 1 && e === 1 ? t : e;
50
+ }
51
+ function w(t) {
52
+ if (t.pending == null) return null;
53
+ if (t.failed && !t.fetching) return { close: !0, page: null };
54
+ if (!t.gateOpen || !t.loaded || t.fetching || t.placeholder) return null;
55
+ const e = t.totalUnknown || t.total == null ? null : Math.max(1, Math.ceil(t.total / t.pageSize));
56
+ return { close: !0, page: e != null && t.page > e ? e : null };
57
+ }
38
58
  export {
39
- m as rememberListPage,
40
- a as rememberedListPage
59
+ g as pageWhileSettling,
60
+ y as rememberListPage,
61
+ h as rememberedListPage,
62
+ w as restoreWindowOutcome
41
63
  };
@@ -0,0 +1,45 @@
1
+ const u = 999999999999e-2, a = "Enter an amount of zero or more", f = /[\t\r\n]/, c = /^(\d+(\.\d*)?|\.\d+)$/, d = /^\d{1,3}(,\d{3})+(\.\d*)?$/, m = /^\d{1,3}( \d{3})+(\.\d*)?$/;
2
+ function h(s) {
3
+ const t = +`${s}e2`;
4
+ return Number.isFinite(t) ? Math.round(t) / 100 : Math.round(Number(s) * 100) / 100;
5
+ }
6
+ function N(s) {
7
+ const t = String(s ?? "").trim();
8
+ if (f.test(t)) return { ok: !1, error: "Paste one amount per cell" };
9
+ if (t === "" || t === "—" || t === "-")
10
+ return { ok: !0, value: 0, rounded: !1 };
11
+ let e = t, o = !1;
12
+ /^\(.*\)$/.test(e) && (o = !0, e = e.slice(1, -1).trim());
13
+ let l = !1;
14
+ for (; ; )
15
+ if (e.startsWith("-")) {
16
+ if (o) return { ok: !1, error: a };
17
+ o = !0, e = e.slice(1).trim();
18
+ } else if (e.startsWith("$")) {
19
+ if (l) return { ok: !1, error: a };
20
+ l = !0, e = e.slice(1).trim();
21
+ } else break;
22
+ e = e.replace(/\s+/g, " ");
23
+ let r;
24
+ if (c.test(e)) r = e;
25
+ else if (d.test(e)) r = e.replace(/,/g, "");
26
+ else if (m.test(e)) r = e.replace(/ /g, "");
27
+ else return /^[\d., ]+$/.test(e) && /,/.test(e) ? {
28
+ ok: !1,
29
+ error: `"${t}" is not clear — use a comma only between thousands (1,234) and a point for cents (12.34)`
30
+ } : { ok: !1, error: a };
31
+ const i = Number(r);
32
+ if (!Number.isFinite(i)) return { ok: !1, error: a };
33
+ if (i > u)
34
+ return { ok: !1, error: "That is more than a month can hold ($9,999,999,999.99)" };
35
+ const n = h(r);
36
+ return {
37
+ ok: !0,
38
+ value: o && n !== 0 ? -n : n,
39
+ rounded: Math.abs(i - n) > 1e-9
40
+ };
41
+ }
42
+ export {
43
+ u as MONEY_INPUT_MAX,
44
+ N as parseMoneyInput
45
+ };
@@ -52,20 +52,24 @@ const l = /* @__PURE__ */ new Set([
52
52
  "template",
53
53
  "base",
54
54
  "noscript"
55
- ]), f = /* @__PURE__ */ new Set(["href", "title", "colspan", "rowspan", "start", "type"]), p = /^(https?:|mailto:|tel:)/i, u = (n) => {
55
+ ]), f = /* @__PURE__ */ new Set(["href", "title", "colspan", "rowspan", "start", "type"]), p = /^(https?:|mailto:|tel:)/i, h = (n) => {
56
56
  let e = "";
57
57
  for (const r of n) r.charCodeAt(0) > 32 && (e += r);
58
58
  return e = e.toLowerCase(), !e || p.test(e) ? !0 : !/^[a-z][a-z0-9+.-]*:/.test(e);
59
59
  };
60
- function h(n) {
60
+ function u(n) {
61
61
  if (typeof DOMParser < "u") {
62
62
  const e = new DOMParser().parseFromString(n, "text/html");
63
63
  for (const r of e.body.querySelectorAll("script,style,template,noscript")) r.remove();
64
+ for (const r of e.body.querySelectorAll(
65
+ "br,p,div,li,tr,td,th,h1,h2,h3,h4,h5,h6,blockquote,pre"
66
+ ))
67
+ r.nextSibling && r.after(e.createTextNode(" "));
64
68
  return (e.body.textContent || "").replace(/\s+/g, " ");
65
69
  }
66
70
  return n.replace(/<(script|style|template|noscript)\b[\s\S]*?<\/\1>/gi, " ").replace(/<[^>]+>/g, " ").replace(/&nbsp;/g, " ").replace(/\s+/g, " ");
67
71
  }
68
- function m(n) {
72
+ function d(n) {
69
73
  if (typeof DOMParser > "u") return "";
70
74
  const e = new DOMParser().parseFromString(n, "text/html"), r = (i) => {
71
75
  for (const t of [...i.children]) {
@@ -84,7 +88,7 @@ function m(n) {
84
88
  }
85
89
  for (const o of [...t.attributes]) {
86
90
  const a = o.name.toLowerCase();
87
- (!f.has(a) || a === "href" && !u(o.value)) && t.removeAttribute(o.name);
91
+ (!f.has(a) || a === "href" && !h(o.value)) && t.removeAttribute(o.name);
88
92
  }
89
93
  s === "a" && (t.setAttribute("rel", "noopener noreferrer"), t.setAttribute("target", "_blank")), r(t);
90
94
  }
@@ -92,6 +96,6 @@ function m(n) {
92
96
  return r(e.body), e.body.innerHTML;
93
97
  }
94
98
  export {
95
- h as htmlToText,
96
- m as sanitizeHtml
99
+ u as htmlToText,
100
+ d as sanitizeHtml
97
101
  };
@@ -0,0 +1,18 @@
1
+ const s = /* @__PURE__ */ new Map();
2
+ function o(t, n) {
3
+ const e = s.get(t) ?? /* @__PURE__ */ new Set();
4
+ return e.add(n), s.set(t, e), () => {
5
+ e.delete(n), e.size === 0 && s.delete(t);
6
+ };
7
+ }
8
+ function a(t, n) {
9
+ for (const e of s.get(t) ?? []) {
10
+ const r = e(n);
11
+ if (r != null && r.trim()) return r;
12
+ }
13
+ return null;
14
+ }
15
+ export {
16
+ o as registerStagedRowLabel,
17
+ a as stagedRowLabel
18
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nivaro/react",
3
- "version": "0.3.58",
3
+ "version": "0.3.59",
4
4
  "description": "React hooks and components for Nivaro CMS forms",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",