@nivaro/react 0.3.53 → 0.3.55
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.
- package/dist/hooks/useSessionRecorder.js +1 -1
- package/dist/shared/components/ItemEditForm.js +3350 -3347
- package/dist/shared/components/PageRenderer.js +397 -396
- package/dist/shared/components/item-edit/DraftRecoveryBanner.js +52 -54
- package/dist/shared/components/item-edit/PersonalDefaultControl.js +12 -11
- package/dist/shared/components/item-edit/RelationCombobox.js +23 -20
- package/dist/shared/components/item-edit/SummaryPanel.js +358 -318
- package/dist/shared/components/item-edit/save-outcome.js +48 -0
- package/dist/shared/components/item-edit/stale-banner.js +13 -0
- package/dist/shared/components/item-edit/usePersonalDefaults.js +116 -114
- package/dist/shared/lib/draft-store.js +35 -29
- package/dist/shared/lib/error-hints.js +1 -0
- package/dist/shared/lib/page-widget-access.js +11 -0
- package/package.json +1 -1
|
@@ -1,16 +1,21 @@
|
|
|
1
|
-
const f = "nivaro-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
|
-
(
|
|
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
|
|
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
|
|
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(
|
|
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((
|
|
40
|
+
return n ? new Promise((i) => {
|
|
36
41
|
try {
|
|
37
|
-
const r = n.transaction(
|
|
38
|
-
|
|
39
|
-
n.close(),
|
|
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(),
|
|
47
|
+
n.close(), i(null);
|
|
43
48
|
}
|
|
44
49
|
}) : null;
|
|
45
50
|
}
|
|
46
|
-
async function
|
|
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
|
|
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
|
-
|
|
65
|
+
a + e,
|
|
61
66
|
JSON.stringify({ id: t, at: n.toISOString() })
|
|
62
67
|
);
|
|
63
68
|
} catch {
|
|
64
69
|
}
|
|
65
70
|
}
|
|
66
|
-
function
|
|
71
|
+
function k(e, t, n = /* @__PURE__ */ new Date()) {
|
|
67
72
|
try {
|
|
68
|
-
const
|
|
69
|
-
if (!
|
|
70
|
-
const r = JSON.parse(
|
|
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
|
|
73
|
-
if (!Number.isFinite(
|
|
74
|
-
return localStorage.removeItem(
|
|
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 >
|
|
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
|
|
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
|
|
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
|
-
|
|
100
|
-
|
|
104
|
+
k as draftCreatedAs,
|
|
105
|
+
m as draftFilledBack,
|
|
106
|
+
p as draftHasContent,
|
|
101
107
|
b as draftKey,
|
|
102
|
-
|
|
103
|
-
|
|
108
|
+
S as draftMatchesPrefill,
|
|
109
|
+
j as keepDraftSavedAt,
|
|
104
110
|
_ as loadDraft,
|
|
105
111
|
h as markDraftCreated,
|
|
106
|
-
|
|
107
|
-
|
|
112
|
+
y as prefillSignature,
|
|
113
|
+
w as saveDraft
|
|
108
114
|
};
|
|
@@ -11,6 +11,7 @@ const h = {
|
|
|
11
11
|
ADMIN_ONLY: "Only administrators can do this. Ask one to do it for you.",
|
|
12
12
|
FIELD_FORBIDDEN: "Leave that field out, or ask an administrator for access to it.",
|
|
13
13
|
FIELD_NOT_READABLE: "Leave that field out, or ask an administrator for access to it.",
|
|
14
|
+
QUERY_NOT_SCOPED: "This report is not limited to the data you may see yet. Ask an administrator to set it up for your access.",
|
|
14
15
|
FILE_NOT_READABLE: "Ask the person who shared it to share it with you, or attach your own copy.",
|
|
15
16
|
NOT_WHILE_MASQUERADING: "Stop viewing as someone else first, then try again.",
|
|
16
17
|
API_KEY_SCOPE_MISSING: "Use a key that has this scope, or ask an administrator to add it.",
|