@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.
@@ -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
  };
@@ -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.",
@@ -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
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nivaro/react",
3
- "version": "0.3.53",
3
+ "version": "0.3.55",
4
4
  "description": "React hooks and components for Nivaro CMS forms",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",