@nivaro/react 0.3.52 → 0.3.54

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 (41) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +47 -3
  4. package/dist/shared/components/ItemEditForm.js +4196 -4163
  5. package/dist/shared/components/NotificationBell.js +163 -150
  6. package/dist/shared/components/PageRenderer.js +645 -593
  7. package/dist/shared/components/ProfileView.js +36 -34
  8. package/dist/shared/components/QueryStatStrip.js +96 -89
  9. package/dist/shared/components/QueryTable.js +214 -215
  10. package/dist/shared/components/ReportView.js +548 -529
  11. package/dist/shared/components/alerts/AlertManagerView.js +346 -320
  12. package/dist/shared/components/item-edit/CatalogPickerField.js +1300 -1219
  13. package/dist/shared/components/item-edit/DraftRecoveryBanner.js +52 -54
  14. package/dist/shared/components/item-edit/FieldAffordances.js +145 -136
  15. package/dist/shared/components/item-edit/FieldRenderer.js +366 -326
  16. package/dist/shared/components/item-edit/InlineTableField.js +3047 -2932
  17. package/dist/shared/components/item-edit/NestedRelationEditor.js +149 -143
  18. package/dist/shared/components/item-edit/PersonalDefaultControl.js +12 -11
  19. package/dist/shared/components/item-edit/PlanGrid.js +718 -705
  20. package/dist/shared/components/item-edit/RelationCombobox.js +23 -20
  21. package/dist/shared/components/item-edit/SummaryPanel.js +415 -361
  22. package/dist/shared/components/item-edit/line-qty.js +115 -53
  23. package/dist/shared/components/item-edit/save-outcome.js +48 -0
  24. package/dist/shared/components/item-edit/save-refusal.js +18 -18
  25. package/dist/shared/components/item-edit/stale-banner.js +13 -0
  26. package/dist/shared/components/item-edit/usePersonalDefaults.js +225 -220
  27. package/dist/shared/components/panels/CommentPanel.js +204 -197
  28. package/dist/shared/components/panels/ItemLockBanner.js +318 -291
  29. package/dist/shared/components/panels/PipelinePanel.js +1388 -1218
  30. package/dist/shared/components/panels/RecordIntegrityBanner.js +201 -172
  31. package/dist/shared/components/panels/RevisionsPanel.js +101 -106
  32. package/dist/shared/components/panels/TransitionRequirementsDialog.js +564 -534
  33. package/dist/shared/components/panels/requirement-side-effects.js +46 -29
  34. package/dist/shared/components/queue/QueueItemSheet.js +219 -146
  35. package/dist/shared/components/queue/QueueWorklist.js +738 -730
  36. package/dist/shared/components/widgets/ReviewListWidget.js +236 -201
  37. package/dist/shared/lib/activity-sentence.js +236 -227
  38. package/dist/shared/lib/draft-store.js +35 -29
  39. package/dist/shared/lib/page-widget-access.js +11 -0
  40. package/dist/shared/lib/record-ref.js +43 -34
  41. package/package.json +1 -1
@@ -1,16 +1,21 @@
1
- const f = "nivaro-drafts", i = "drafts";
1
+ const f = "nivaro-drafts", l = "drafts";
2
2
  function m(e) {
3
+ if (e.item_id !== "new") return /* @__PURE__ */ new Set();
4
+ const t = Object.keys(e.fields ?? {}), n = new Set((e.filled ?? []).filter((i) => t.includes(i)));
5
+ return n.size === t.length ? /* @__PURE__ */ new Set() : n;
6
+ }
7
+ function y(e) {
3
8
  if (e == null) return null;
4
9
  const t = JSON.stringify(
5
10
  e,
6
- (o, r) => r && typeof r == "object" && !Array.isArray(r) ? Object.fromEntries(Object.entries(r).sort(([a], [s]) => a < s ? -1 : a > s ? 1 : 0)) : r
11
+ (i, r) => r && typeof r == "object" && !Array.isArray(r) ? Object.fromEntries(Object.entries(r).sort(([o], [s]) => o < s ? -1 : o > s ? 1 : 0)) : r
7
12
  );
8
13
  if (!t || t === "{}" || t === "[]") return null;
9
14
  let n = 5381;
10
- for (let o = 0; o < t.length; o++) n = (n << 5) + n + t.charCodeAt(o) | 0;
15
+ for (let i = 0; i < t.length; i++) n = (n << 5) + n + t.charCodeAt(i) | 0;
11
16
  return `p${(n >>> 0).toString(36)}:${t.length}`;
12
17
  }
13
- function y(e, t) {
18
+ function S(e, t) {
14
19
  return (e.prefill_sig ?? null) === t;
15
20
  }
16
21
  function b(e, t, n) {
@@ -23,7 +28,7 @@ function d() {
23
28
  const t = indexedDB.open(f, 1);
24
29
  t.onupgradeneeded = () => {
25
30
  const n = t.result;
26
- n.objectStoreNames.contains(i) || n.createObjectStore(i, { keyPath: "key" });
31
+ n.objectStoreNames.contains(l) || n.createObjectStore(l, { keyPath: "key" });
27
32
  }, t.onsuccess = () => e(t.result), t.onerror = () => e(null), t.onblocked = () => e(null);
28
33
  } catch {
29
34
  e(null);
@@ -32,18 +37,18 @@ function d() {
32
37
  }
33
38
  async function c(e, t) {
34
39
  const n = await d();
35
- return n ? new Promise((o) => {
40
+ return n ? new Promise((i) => {
36
41
  try {
37
- const r = n.transaction(i, e), a = t(r.objectStore(i));
38
- a.onsuccess = () => o(a.result), a.onerror = () => o(null), r.oncomplete = () => n.close(), r.onerror = () => {
39
- n.close(), o(null);
42
+ const r = n.transaction(l, e), o = t(r.objectStore(l));
43
+ o.onsuccess = () => i(o.result), o.onerror = () => i(null), r.oncomplete = () => n.close(), r.onerror = () => {
44
+ n.close(), i(null);
40
45
  };
41
46
  } catch {
42
- n.close(), o(null);
47
+ n.close(), i(null);
43
48
  }
44
49
  }) : null;
45
50
  }
46
- async function S(e) {
51
+ async function w(e) {
47
52
  return await c("readwrite", (n) => n.put(e)) != null;
48
53
  }
49
54
  async function _(e) {
@@ -53,32 +58,32 @@ async function _(e) {
53
58
  async function O(e) {
54
59
  await c("readwrite", (t) => t.delete(e));
55
60
  }
56
- const l = "nvr:draft-created:", g = 7 * 864e5;
61
+ const a = "nvr:draft-created:", g = 7 * 864e5;
57
62
  function h(e, t, n = /* @__PURE__ */ new Date()) {
58
63
  try {
59
64
  localStorage.setItem(
60
- l + e,
65
+ a + e,
61
66
  JSON.stringify({ id: t, at: n.toISOString() })
62
67
  );
63
68
  } catch {
64
69
  }
65
70
  }
66
- function p(e, t, n = /* @__PURE__ */ new Date()) {
71
+ function k(e, t, n = /* @__PURE__ */ new Date()) {
67
72
  try {
68
- const o = localStorage.getItem(l + e);
69
- if (!o) return null;
70
- const r = JSON.parse(o);
73
+ const i = localStorage.getItem(a + e);
74
+ if (!i) return null;
75
+ const r = JSON.parse(i);
71
76
  if (!r || typeof r.id != "string" || typeof r.at != "string") return null;
72
- const a = Date.parse(r.at);
73
- if (!Number.isFinite(a) || n.getTime() - a > g)
74
- return localStorage.removeItem(l + e), null;
77
+ const o = Date.parse(r.at);
78
+ if (!Number.isFinite(o) || n.getTime() - o > g)
79
+ return localStorage.removeItem(a + e), null;
75
80
  const s = t ? Date.parse(t) : Number.NaN;
76
- return !Number.isFinite(s) || s > a ? null : { id: r.id, at: r.at };
81
+ return !Number.isFinite(s) || s > o ? null : { id: r.id, at: r.at };
77
82
  } catch {
78
83
  return null;
79
84
  }
80
85
  }
81
- function w(e) {
86
+ function p(e) {
82
87
  return Object.keys(e.fields ?? {}).length > 0 || Object.values(e.pending_rows ?? {}).some((t) => t.length > 0) || Object.values(e.pending_edits ?? {}).some((t) => Object.keys(t).length > 0) || Object.values(e.pending_deletes ?? {}).some((t) => t.length > 0) || Object.values(e.m2m_links ?? {}).some((t) => t.length > 0) || Object.values(e.m2m_unlinks ?? {}).some((t) => t.length > 0);
83
88
  }
84
89
  function u(e) {
@@ -91,18 +96,19 @@ function u(e) {
91
96
  e.m2m_unlinks ?? {}
92
97
  ]);
93
98
  }
94
- function D(e, t) {
99
+ function j(e, t) {
95
100
  return !(t != null && t.saved_at) || t.key !== e.key ? e : u(t) === u(e) ? { ...e, saved_at: t.saved_at } : e;
96
101
  }
97
102
  export {
98
103
  O as deleteDraft,
99
- p as draftCreatedAs,
100
- w as draftHasContent,
104
+ k as draftCreatedAs,
105
+ m as draftFilledBack,
106
+ p as draftHasContent,
101
107
  b as draftKey,
102
- y as draftMatchesPrefill,
103
- D as keepDraftSavedAt,
108
+ S as draftMatchesPrefill,
109
+ j as keepDraftSavedAt,
104
110
  _ as loadDraft,
105
111
  h as markDraftCreated,
106
- m as prefillSignature,
107
- S as saveDraft
112
+ y as prefillSignature,
113
+ w as saveDraft
108
114
  };
@@ -0,0 +1,11 @@
1
+ function t(n) {
2
+ var i;
3
+ return ((i = n.config) == null ? void 0 : i.admin_only) === !0;
4
+ }
5
+ function r(n, i) {
6
+ return i ? [...n] : n.filter((e) => !t(e));
7
+ }
8
+ export {
9
+ t as isAdminOnlyWidget,
10
+ r as visiblePageWidgets
11
+ };
@@ -1,72 +1,81 @@
1
- import { get as a } from "./commands.js";
2
- const s = /^[A-Za-z_][A-Za-z0-9_]*$/;
3
- function c(n) {
1
+ import { get as c } from "./commands.js";
2
+ const o = /^[A-Za-z_][A-Za-z0-9_]*$/;
3
+ function a(n) {
4
4
  const t = n == null ? void 0 : n.friendly_id_field;
5
- return typeof t == "string" && t !== "id" && s.test(t) ? t : null;
5
+ return typeof t == "string" && t !== "id" && o.test(t) ? t : null;
6
6
  }
7
- function o(n) {
7
+ function s(n) {
8
8
  if (n == null || typeof n == "object") return null;
9
9
  const t = String(n).trim();
10
10
  return t === "" ? null : t;
11
11
  }
12
12
  function d(n, t) {
13
- const e = c(n);
14
- return e && t ? o(t[e]) : null;
13
+ const r = a(n);
14
+ return r && t ? s(t[r]) : null;
15
15
  }
16
16
  function y(n) {
17
17
  const t = n == null ? void 0 : n.url_alias_fields;
18
- let e = t;
18
+ let r = t;
19
19
  if (typeof t == "string")
20
20
  try {
21
- e = JSON.parse(t);
21
+ r = JSON.parse(t);
22
22
  } catch {
23
- e = [];
23
+ r = [];
24
24
  }
25
- return Array.isArray(e) ? e.filter((i) => typeof i == "string" && s.test(i)) : [];
25
+ return Array.isArray(r) ? r.filter((e) => typeof e == "string" && o.test(e)) : [];
26
26
  }
27
- function p(n, t) {
27
+ function g(n, t) {
28
28
  if (!t) return null;
29
- const e = y(n);
30
- let i;
31
- if (e.length > 0) {
32
- const r = e.map((l) => o(t[l]));
33
- if (r.some((l) => l == null)) return null;
34
- i = r.join("-");
29
+ const r = y(n);
30
+ let e;
31
+ if (r.length > 0) {
32
+ const i = r.map((l) => s(t[l]));
33
+ if (i.some((l) => l == null)) return null;
34
+ e = i.join("-");
35
35
  } else
36
- i = d(n, t);
37
- return !i || /^\d+$/.test(i) || /^[0-9a-f]{8}-[0-9a-f]{4}-/i.test(i) || i === "new" || i.includes("/") ? null : i;
36
+ e = d(n, t);
37
+ return !e || /^\d+$/.test(e) || /^[0-9a-f]{8}-[0-9a-f]{4}-/i.test(e) || e === "new" || e.includes("/") ? null : e;
38
38
  }
39
- async function h(n, t, e, i, r) {
40
- var u;
41
- const l = p(e, i);
42
- if (!l) return String(r);
39
+ async function S(n, t, r, e, i) {
40
+ var f;
41
+ const l = g(r, e);
42
+ if (!l) return String(i);
43
43
  try {
44
- const f = await n.request(
45
- a(`/items/${t}/by-slug/${encodeURIComponent(l)}`, { fields: "id" })
44
+ const u = await n.request(
45
+ c(`/items/${t}/by-slug/${encodeURIComponent(l)}`, { fields: "id" })
46
46
  );
47
- return String(((u = f == null ? void 0 : f.data) == null ? void 0 : u.id) ?? "") === String(r) ? l : String(r);
47
+ return String(((f = u == null ? void 0 : u.data) == null ? void 0 : f.id) ?? "") === String(i) ? l : String(i);
48
48
  } catch {
49
- return String(r);
49
+ return String(i);
50
50
  }
51
51
  }
52
52
  async function w(n) {
53
53
  const t = typeof navigator < "u" ? navigator.clipboard : void 0;
54
54
  if (!t) return;
55
- const e = globalThis.ClipboardItem;
56
- if (e && typeof t.write == "function")
55
+ const r = globalThis.ClipboardItem;
56
+ if (r && typeof t.write == "function")
57
57
  try {
58
58
  await t.write([
59
- new e({ "text/plain": n.then((i) => new Blob([i], { type: "text/plain" })) })
59
+ new r({ "text/plain": n.then((e) => new Blob([e], { type: "text/plain" })) })
60
60
  ]);
61
61
  return;
62
62
  } catch {
63
63
  }
64
64
  await t.writeText(await n);
65
65
  }
66
+ function p(n) {
67
+ return /^No [\w ]+ number( · |$)/.test(String(n ?? ""));
68
+ }
69
+ function h(n) {
70
+ const t = String(n.label ?? "").trim();
71
+ return !t || p(t) ? null : t;
72
+ }
66
73
  export {
67
- p as aliasSegmentOf,
74
+ g as aliasSegmentOf,
75
+ h as copyIdText,
68
76
  w as copyWhenReady,
69
- c as friendlyIdFieldOf,
77
+ a as friendlyIdFieldOf,
70
78
  d as friendlyIdOf,
71
- h as shareableRecordId
79
+ p as isNoNumberLabel,
80
+ S as shareableRecordId
72
81
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nivaro/react",
3
- "version": "0.3.52",
3
+ "version": "0.3.54",
4
4
  "description": "React hooks and components for Nivaro CMS forms",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",