@nivaro/react 0.3.56 → 0.3.58

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 (55) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +9 -2
  4. package/dist/shared/components/CollectionBrowserView.js +2827 -2750
  5. package/dist/shared/components/DataTable.js +247 -236
  6. package/dist/shared/components/ItemEditForm.js +1693 -1668
  7. package/dist/shared/components/ProfileView.js +716 -715
  8. package/dist/shared/components/RecordReadView.js +367 -364
  9. package/dist/shared/components/ReportView.js +64 -39
  10. package/dist/shared/components/alerts/AlertManagerView.js +284 -271
  11. package/dist/shared/components/cbv/row-focus.js +19 -0
  12. package/dist/shared/components/help-videos/HelpVideoPlayer.js +152 -147
  13. package/dist/shared/components/integrations/console/SignalCard.js +59 -59
  14. package/dist/shared/components/integrations/console/tone.js +52 -30
  15. package/dist/shared/components/item-edit/CatalogPickerField.js +525 -505
  16. package/dist/shared/components/item-edit/FieldRow.js +175 -173
  17. package/dist/shared/components/item-edit/InlineTableField.js +407 -402
  18. package/dist/shared/components/item-edit/M2MCombobox.js +313 -291
  19. package/dist/shared/components/item-edit/MidairCollisionDialog.js +1 -1
  20. package/dist/shared/components/item-edit/PlanGrid.js +826 -803
  21. package/dist/shared/components/item-edit/QuickCreateButton.js +115 -79
  22. package/dist/shared/components/item-edit/RecordLiveSync.js +77 -75
  23. package/dist/shared/components/item-edit/RelationCombobox.js +412 -328
  24. package/dist/shared/components/item-edit/RelationGroupedCombobox.js +147 -125
  25. package/dist/shared/components/item-edit/SummaryPanel.js +406 -392
  26. package/dist/shared/components/item-edit/option-disambiguate.js +44 -32
  27. package/dist/shared/components/item-edit/related-missing.js +45 -0
  28. package/dist/shared/components/item-edit/save-outcome.js +5 -5
  29. package/dist/shared/components/notifications/NotificationRulesEditor.js +130 -123
  30. package/dist/shared/components/panels/AccessDeniedPanel.js +52 -48
  31. package/dist/shared/components/panels/ItemLockBanner.js +2 -3
  32. package/dist/shared/components/panels/PipelinePanel.js +1027 -978
  33. package/dist/shared/components/panels/RevisionsPanel.js +4 -1
  34. package/dist/shared/components/panels/TaskPanel.js +265 -249
  35. package/dist/shared/components/panels/landing-state.js +27 -0
  36. package/dist/shared/components/pipeline/PipelineEditorView.js +86 -78
  37. package/dist/shared/components/profile/AiMemoryCard.js +12 -10
  38. package/dist/shared/components/queue/OwnerAvatars.js +80 -41
  39. package/dist/shared/components/queue/QueueItemSheet.js +111 -111
  40. package/dist/shared/components/queue/QueueQuickFilters.js +48 -48
  41. package/dist/shared/components/queue/QueueWorklist.js +975 -964
  42. package/dist/shared/components/queue/group-sums.js +27 -0
  43. package/dist/shared/components/queue/live-state-aspect.js +7 -3
  44. package/dist/shared/components/queue/path-label.js +14 -0
  45. package/dist/shared/components/widgets/ReviewListWidget.js +186 -168
  46. package/dist/shared/lib/back-closes.js +25 -0
  47. package/dist/shared/lib/cbv-page-warm.js +36 -0
  48. package/dist/shared/lib/form-usage-beacon.js +7 -7
  49. package/dist/shared/lib/list-page-memory.js +41 -0
  50. package/dist/shared/lib/live.js +44 -44
  51. package/dist/shared/lib/own-writes.js +76 -28
  52. package/dist/shared/lib/record-ref.js +78 -53
  53. package/dist/shared/lib/request-gate.js +110 -109
  54. package/dist/shared/lib/validation-rules.js +34 -19
  55. package/package.json +1 -1
@@ -1,20 +1,20 @@
1
- import { noteOwnWriteFromCommand as b } from "./own-writes.js";
2
- import { noteCredentialChanged as z, isIdentityRead as M, claimIdentityCall as $, signedOutError as Z, noteSignedIn as H, isSignedOutError as U, noteUnauthorized as x } from "./signed-out.js";
3
- function G(t) {
1
+ import { isRehearsalCommand as M, noteOwnWriteFromCommand as R } from "./own-writes.js";
2
+ import { noteCredentialChanged as $, isIdentityRead as Z, claimIdentityCall as H, signedOutError as U, noteSignedIn as x, isSignedOutError as B, noteUnauthorized as F } from "./signed-out.js";
3
+ function I(t) {
4
4
  if (!t || typeof t != "object") return "";
5
- const s = Object.entries(t).filter(([, o]) => o != null).map(([o, a]) => [o, String(a)]).sort(([o], [a]) => o < a ? -1 : o > a ? 1 : 0);
5
+ const s = Object.entries(t).filter(([, o]) => o != null).map(([o, i]) => [o, String(i)]).sort(([o], [i]) => o < i ? -1 : o > i ? 1 : 0);
6
6
  return s.length ? new URLSearchParams(s).toString() : "";
7
7
  }
8
- function I(t) {
8
+ function P(t) {
9
9
  const s = (t._method ?? "GET").toUpperCase(), o = s === "GET" || t._body === void 0 ? "" : JSON.stringify(t._body);
10
- return `${s} ${t._path ?? ""} ${G(t._params)} ${o}`;
10
+ return `${s} ${t._path ?? ""} ${I(t._params)} ${o}`;
11
11
  }
12
12
  function S(t) {
13
13
  return (t._method ?? "GET").toUpperCase() === "GET";
14
14
  }
15
- const P = /^\/(widgets-internal\/[^/]+\/render|items\/[^/]+\/[^/]+\/child-summary|items\/[^/]+\/auto-id-preview|config-conformance\/record\/.+\/check|pipelines\/instance\/[^/]+\/owners\/batch|addendums\/summary|at-risk\/evaluate|record-views\/.+\/touch)$/;
16
- function B(t) {
17
- return S(t) ? !0 : (t._method ?? "GET").toUpperCase() !== "POST" ? !1 : P.test((t._path ?? "").split("?")[0]);
15
+ const N = /^\/(widgets-internal\/[^/]+\/render|items\/[^/]+\/[^/]+\/child-summary|items\/[^/]+\/auto-id-preview|config-conformance\/record\/.+\/check|pipelines\/instance\/[^/]+\/owners\/batch|addendums\/summary|at-risk\/evaluate|record-views\/.+\/touch)$/;
16
+ function W(t) {
17
+ return S(t) ? !0 : (t._method ?? "GET").toUpperCase() !== "POST" ? !1 : N.test((t._path ?? "").split("?")[0]);
18
18
  }
19
19
  function T(t) {
20
20
  if (t == null || typeof t != "object") return t;
@@ -24,11 +24,11 @@ function T(t) {
24
24
  return t;
25
25
  }
26
26
  }
27
- const N = Symbol("nivaro.coalesced");
28
- function F(t) {
29
- return t[N] === !0;
27
+ const j = Symbol("nivaro.coalesced");
28
+ function K(t) {
29
+ return t[j] === !0;
30
30
  }
31
- const R = 20, W = /^\/items\/([A-Za-z_][A-Za-z0-9_]*)(?:\/([^/?#]+))?$/, K = /* @__PURE__ */ new Set(["aggregate", "export", "distinct", "resolve-paths", "batch-read"]), J = /* @__PURE__ */ new Set([
31
+ const k = 20, J = /^\/items\/([A-Za-z_][A-Za-z0-9_]*)(?:\/([^/?#]+))?$/, Y = /* @__PURE__ */ new Set(["aggregate", "export", "distinct", "resolve-paths", "batch-read"]), Q = /* @__PURE__ */ new Set([
32
32
  "fields",
33
33
  "filter",
34
34
  "sort",
@@ -41,25 +41,25 @@ const R = 20, W = /^\/items\/([A-Za-z_][A-Za-z0-9_]*)(?:\/([^/?#]+))?$/, K = /*
41
41
  "conditions",
42
42
  "labels"
43
43
  ]);
44
- function Y(t) {
44
+ function V(t) {
45
45
  const s = t;
46
46
  if ((s._method ?? "GET").toUpperCase() !== "GET") return null;
47
- const o = W.exec(s._path ?? "");
47
+ const o = J.exec(s._path ?? "");
48
48
  if (!o) return null;
49
- const [, a, d] = o;
50
- if (d !== void 0 && K.has(d)) return null;
49
+ const [, i, d] = o;
50
+ if (d !== void 0 && Y.has(d)) return null;
51
51
  const m = s._params ?? {}, c = {};
52
52
  for (const [r, u] of Object.entries(m))
53
53
  if (u !== void 0) {
54
- if (!J.has(r)) return null;
54
+ if (!Q.has(r)) return null;
55
55
  c[r] = u;
56
56
  }
57
- return d === void 0 ? { collection: a, query: c } : { collection: a, id: d, query: c };
57
+ return d === void 0 ? { collection: i, query: c } : { collection: i, id: d, query: c };
58
58
  }
59
- function Q(t) {
59
+ function X(t) {
60
60
  let s = [], o;
61
- const a = (c) => t.request(c.command).then(c.resolve, c.reject), d = async (c) => {
62
- if (c.length === 1) return a(c[0]);
61
+ const i = (c) => t.request(c.command).then(c.resolve, c.reject), d = async (c) => {
62
+ if (c.length === 1) return i(c[0]);
63
63
  let r;
64
64
  try {
65
65
  const u = await t.request({
@@ -81,7 +81,7 @@ function Q(t) {
81
81
  c.forEach((u, n) => {
82
82
  const e = r == null ? void 0 : r[n];
83
83
  if ((e == null ? void 0 : e.status) !== 200 || e === void 0) {
84
- a(u);
84
+ i(u);
85
85
  return;
86
86
  }
87
87
  u.resolve(u.read.id !== void 0 ? { data: e.data } : { data: e.data, ...e.meta ?? {} });
@@ -90,8 +90,8 @@ function Q(t) {
90
90
  o = void 0;
91
91
  const c = s;
92
92
  s = [];
93
- for (let r = 0; r < c.length; r += R)
94
- d(c.slice(r, r + R));
93
+ for (let r = 0; r < c.length; r += k)
94
+ d(c.slice(r, r + k));
95
95
  };
96
96
  return (c, r) => new Promise((u, n) => {
97
97
  s.push({
@@ -102,22 +102,22 @@ function Q(t) {
102
102
  }), o === void 0 && (o = setTimeout(m, 0));
103
103
  });
104
104
  }
105
- const k = 50, V = 10, X = /^\/collections\/([A-Za-z_][A-Za-z0-9_-]{0,127})$/;
106
- function ee(t) {
105
+ const q = 50, ee = 10, te = /^\/collections\/([A-Za-z_][A-Za-z0-9_-]{0,127})$/;
106
+ function ne(t) {
107
107
  const s = t;
108
- if ((s._method ?? "GET").toUpperCase() !== "GET" || G(s._params) !== "") return null;
109
- const o = X.exec(s._path ?? "");
108
+ if ((s._method ?? "GET").toUpperCase() !== "GET" || I(s._params) !== "") return null;
109
+ const o = te.exec(s._path ?? "");
110
110
  return o ? o[1] : null;
111
111
  }
112
- function te() {
112
+ function se() {
113
113
  return Object.assign(new Error("Not found"), { status: 404, response: { error: "Not found" } });
114
114
  }
115
- function ne(t) {
116
- let s = !0, o = [], a;
115
+ function oe(t) {
116
+ let s = !0, o = [], i;
117
117
  const d = (r) => t.request(r.command).then(r.resolve, r.reject), m = async (r) => {
118
- const u = [...new Set(r.map((i) => i.name))];
118
+ const u = [...new Set(r.map((a) => a.name))];
119
119
  if (u.length === 1 || !s) {
120
- for (const i of r) d(i);
120
+ for (const a of r) d(a);
121
121
  return;
122
122
  }
123
123
  let n;
@@ -127,11 +127,11 @@ function ne(t) {
127
127
  _path: "/collections",
128
128
  _params: { names: u.join(",") }
129
129
  });
130
- } catch (i) {
131
- const h = i == null ? void 0 : i.status;
130
+ } catch (a) {
131
+ const h = a == null ? void 0 : a.status;
132
132
  if (h === 400 || h === 404 || h === 405) s = !1;
133
133
  else if (h === 429 || h !== void 0 && h >= 500) {
134
- for (const p of r) p.reject(i);
134
+ for (const p of r) p.reject(a);
135
135
  return;
136
136
  }
137
137
  n = void 0;
@@ -139,22 +139,22 @@ function ne(t) {
139
139
  const e = n == null ? void 0 : n.data;
140
140
  if (!e || typeof e != "object" || Array.isArray(e)) {
141
141
  Array.isArray(e) && (s = !1);
142
- for (const i of r) d(i);
142
+ for (const a of r) d(a);
143
143
  return;
144
144
  }
145
145
  const l = e, f = new Set(Array.isArray(n == null ? void 0 : n.missing) ? n.missing : []);
146
- for (const i of r)
147
- Object.hasOwn(l, i.name) ? i.resolve({ data: T(l[i.name]) }) : f.has(i.name) ? i.reject(te()) : d(i);
146
+ for (const a of r)
147
+ Object.hasOwn(l, a.name) ? a.resolve({ data: T(l[a.name]) }) : f.has(a.name) ? a.reject(se()) : d(a);
148
148
  }, c = () => {
149
- a = void 0;
149
+ i = void 0;
150
150
  const r = o;
151
151
  o = [];
152
152
  const u = [], n = /* @__PURE__ */ new Map();
153
153
  for (const e of r) {
154
154
  let l = n.get(e.name);
155
155
  if (!l) {
156
- const f = u[u.length - 1], i = f ? new Set(f.map((h) => h.name)).size : k;
157
- l = f && i < k ? f : [], l !== f && u.push(l), n.set(e.name, l);
156
+ const f = u[u.length - 1], a = f ? new Set(f.map((h) => h.name)).size : q;
157
+ l = f && a < q ? f : [], l !== f && u.push(l), n.set(e.name, l);
158
158
  }
159
159
  l.push(e);
160
160
  }
@@ -166,77 +166,78 @@ function ne(t) {
166
166
  command: r,
167
167
  resolve: n,
168
168
  reject: e
169
- }), a === void 0 && (a = setTimeout(c, V));
169
+ }), i === void 0 && (i = setTimeout(c, ee));
170
170
  });
171
171
  }
172
- const q = 3e3, se = /^\/(collections\/[A-Za-z_][A-Za-z0-9_-]*|field-config\/[A-Za-z_][A-Za-z0-9_-]*|collection-layouts(\/active|\/summary\/[A-Za-z_][A-Za-z0-9_-]*)?|chat\/room-types|users\/me)$/, oe = /^\/(record-views|item-locks|drafts|presence|rum|comments|notifications|tasks|field-rules\/evaluate|chat\/(?!room-types)|field-config\/[^/]+\/(evaluate-visibility|evaluate-defaults|evaluate-lock|cascade|project)$|items\/(?!nivaro_|directus_)[^/]+|users\/cards$|files\/verify$)/;
173
- function re(t) {
172
+ const D = 3e3, re = /^\/(collections\/[A-Za-z_][A-Za-z0-9_-]*|field-config\/[A-Za-z_][A-Za-z0-9_-]*|collection-layouts(\/active|\/summary\/[A-Za-z_][A-Za-z0-9_-]*)?|chat\/room-types|users\/me)$/, ae = /^\/(record-views|item-locks|drafts|presence|rum|comments|notifications|tasks|field-rules\/evaluate|chat\/(?!room-types)|field-config\/[^/]+\/(evaluate-visibility|evaluate-defaults|evaluate-lock|cascade|project)$|items\/(?!nivaro_|directus_)[^/]+|users\/cards$|files\/verify$)/;
173
+ function ie(t) {
174
174
  const s = (t._path ?? "").split("?")[0];
175
- return (t._method ?? "GET").toUpperCase() === "POST" && P.test(s) ? !0 : oe.test(s);
175
+ return (t._method ?? "GET").toUpperCase() === "POST" && N.test(s) ? !0 : ae.test(s);
176
176
  }
177
- function ie(t) {
177
+ function ce(t) {
178
178
  const s = t;
179
- if (!S(s) || !se.test(s._path ?? "")) return !1;
179
+ if (!S(s) || !re.test(s._path ?? "")) return !1;
180
180
  const o = s._params;
181
181
  return !(o && o.item != null && /^\/collection-layouts\/active$/.test(s._path ?? ""));
182
182
  }
183
183
  let y = 0;
184
- function D() {
184
+ function G() {
185
185
  y++;
186
186
  }
187
187
  let g = 0;
188
- const ae = 50, ce = /^\/items\//;
189
- function ue(t, s, o, a) {
190
- if (s.epoch !== a) return !1;
188
+ const ue = 50, le = /^\/items\//;
189
+ function fe(t, s, o, i) {
190
+ if (s.epoch !== i) return !1;
191
191
  const d = t._path ?? "";
192
- return !ce.test(d) || o - s.at < ae;
192
+ return !le.test(d) || o - s.at < ue;
193
193
  }
194
194
  function w(t, s) {
195
195
  return t.then(
196
- (o) => (s && H(), o),
196
+ (o) => (s && x(), o),
197
197
  (o) => {
198
- throw U(o, s) && x(s), o;
198
+ throw B(o, s) && F(s), o;
199
199
  }
200
200
  );
201
201
  }
202
- function me(t, s = {}) {
203
- if (F(t)) return t;
204
- const o = /* @__PURE__ */ new Map(), a = s.batchReads ? Q(t) : null, d = s.batchCollections === !1 ? null : ne(t), m = /* @__PURE__ */ new Map();
202
+ function pe(t, s = {}) {
203
+ if (K(t)) return t;
204
+ const o = /* @__PURE__ */ new Map(), i = s.batchReads ? X(t) : null, d = s.batchCollections === !1 ? null : oe(t), m = /* @__PURE__ */ new Map();
205
205
  let c = y;
206
206
  const r = (n, e, l) => {
207
207
  if (e !== y) return;
208
208
  c !== y && (m.clear(), c = y);
209
209
  const f = Date.now();
210
- for (const [i, h] of m) f - h.at >= q && m.delete(i);
210
+ for (const [a, h] of m) f - h.at >= D && m.delete(a);
211
211
  m.set(n, { at: f, epoch: e, value: l });
212
212
  }, u = (n) => {
213
213
  const e = n;
214
214
  if (!S(e)) {
215
- b(e._method, e._path, e._body);
216
- const _ = !re(e);
217
- _ && D(), g++;
218
- const C = w(t.request(n), !1).finally(() => {
215
+ const _ = M(e._path, e._params);
216
+ _ || R(e._method, e._path, e._body);
217
+ const C = !ie(e);
218
+ C && G(), g++;
219
+ const O = w(t.request(n), !1).finally(() => {
219
220
  g++;
220
221
  });
221
- return (_ ? C.finally(D) : C).then((O) => (b(e._method, e._path, e._body, O), O));
222
+ return (C ? O.finally(G) : O).then((b) => (_ || R(e._method, e._path, e._body, b), b));
222
223
  }
223
224
  if (n._signal)
224
225
  return w(t.request(n), !1);
225
- const l = I(e), f = ie(e);
226
+ const l = P(e), f = ce(e);
226
227
  if (f) {
227
228
  const _ = m.get(l);
228
- if (_ && _.epoch === y && Date.now() - _.at < q)
229
+ if (_ && _.epoch === y && Date.now() - _.at < D)
229
230
  return Promise.resolve(T(_.value));
230
231
  }
231
- const i = o.get(l);
232
- if (i && ue(e, i, Date.now(), g))
233
- return i.p.then(T);
234
- const h = M(e._method, e._path, e._params);
235
- if (h && !$()) return Promise.reject(Z());
236
- const p = a ? Y(e) : null, E = !p && d ? ee(e) : null, j = w(
237
- p && a ? a(n, p) : E && d ? d(n, E) : t.request(n),
232
+ const a = o.get(l);
233
+ if (a && fe(e, a, Date.now(), g))
234
+ return a.p.then(T);
235
+ const h = Z(e._method, e._path, e._params);
236
+ if (h && !H()) return Promise.reject(U());
237
+ const p = i ? V(e) : null, E = !p && d ? ne(e) : null, L = w(
238
+ p && i ? i(n, p) : E && d ? d(n, E) : t.request(n),
238
239
  h
239
- ), L = y, A = j.then((_) => (f && r(l, L, T(_)), _)).finally(() => {
240
+ ), z = y, A = L.then((_) => (f && r(l, z, T(_)), _)).finally(() => {
240
241
  var _;
241
242
  ((_ = o.get(l)) == null ? void 0 : _.p) === A && o.delete(l);
242
243
  });
@@ -245,27 +246,27 @@ function me(t, s = {}) {
245
246
  return new Proxy(t, {
246
247
  get(n, e, l) {
247
248
  if (e === "request") return u;
248
- if (e === N) return !0;
249
+ if (e === j) return !0;
249
250
  if (e === "setToken" && typeof n.setToken == "function")
250
- return (i) => {
251
- n.setToken(i), z();
251
+ return (a) => {
252
+ n.setToken(a), $();
252
253
  };
253
254
  const f = Reflect.get(n, e, l);
254
255
  return typeof f == "function" ? f.bind(n) : f;
255
256
  }
256
257
  });
257
258
  }
258
- const le = /^\/(item-locks|drafts|auth)\b/, v = /* @__PURE__ */ new Set();
259
- function fe() {
259
+ const de = /^\/(item-locks|drafts|auth)\b/, v = /* @__PURE__ */ new Set();
260
+ function he() {
260
261
  for (const t of [...v]) t();
261
262
  }
262
- function _e(t) {
263
+ function ye(t) {
263
264
  return t.subscribe((s) => {
264
- s.type === "observerAdded" && s.query.state.fetchStatus === "fetching" && v.size !== 0 && fe();
265
+ s.type === "observerAdded" && s.query.state.fetchStatus === "fetching" && v.size !== 0 && he();
265
266
  });
266
267
  }
267
- function pe(t, s = {}) {
268
- let o = s.open ?? !0, a;
268
+ function ve(t, s = {}) {
269
+ let o = s.open ?? !0, i;
269
270
  const d = /* @__PURE__ */ new Map(), m = () => {
270
271
  const n = [...d.values()];
271
272
  d.clear();
@@ -274,30 +275,30 @@ function pe(t, s = {}) {
274
275
  v.delete(c), m();
275
276
  }, r = (n) => {
276
277
  const e = n;
277
- if (o || !B(e) || le.test(e._path ?? "")) return t.request(n);
278
- const l = I(e), f = d.get(l);
278
+ if (o || !W(e) || de.test(e._path ?? "")) return t.request(n);
279
+ const l = P(e), f = d.get(l);
279
280
  if (f) return f.promise.then(T);
280
- let i = () => {
281
+ let a = () => {
281
282
  };
282
283
  const p = new Promise((E) => {
283
- i = E;
284
+ a = E;
284
285
  }).then(() => t.request(n));
285
- return d.set(l, { promise: p, release: i }), v.add(c), p;
286
+ return d.set(l, { promise: p, release: a }), v.add(c), p;
286
287
  };
287
288
  return new Proxy(t, {
288
289
  get(n, e, l) {
289
290
  if (e === "request") return r;
290
291
  if (e === "open") return o;
291
292
  if (e === "setOpen")
292
- return (i) => {
293
- a !== void 0 && (clearTimeout(a), a = void 0);
293
+ return (a) => {
294
+ i !== void 0 && (clearTimeout(i), i = void 0);
294
295
  const h = o;
295
- o = i, i && !h && (v.delete(c), m());
296
+ o = a, a && !h && (v.delete(c), m());
296
297
  };
297
298
  if (e === "dispose")
298
299
  return () => {
299
- a === void 0 && (a = setTimeout(() => {
300
- a = void 0, o = !0, v.delete(c), m();
300
+ i === void 0 && (i = setTimeout(() => {
301
+ i = void 0, o = !0, v.delete(c), m();
301
302
  }, 0));
302
303
  };
303
304
  const f = Reflect.get(n, e, l);
@@ -306,19 +307,19 @@ function pe(t, s = {}) {
306
307
  });
307
308
  }
308
309
  export {
309
- R as BATCH_READ_LIMIT,
310
- k as COLLECTION_BATCH_LIMIT,
311
- V as COLLECTION_BATCH_WINDOW_MS,
312
- ae as RECORD_JOIN_MS,
313
- q as SETTLED_READ_MS,
314
- ee as batchableCollectionMeta,
315
- Y as batchableRead,
316
- pe as createGatedClient,
317
- D as forgetSettledReads,
318
- F as isCoalesced,
319
- ie as isSettledRead,
320
- ue as mayJoinInflight,
321
- fe as releaseGatedReads,
322
- _e as releaseGatedReadsOnSharedFetch,
323
- me as withGetCoalescing
310
+ k as BATCH_READ_LIMIT,
311
+ q as COLLECTION_BATCH_LIMIT,
312
+ ee as COLLECTION_BATCH_WINDOW_MS,
313
+ ue as RECORD_JOIN_MS,
314
+ D as SETTLED_READ_MS,
315
+ ne as batchableCollectionMeta,
316
+ V as batchableRead,
317
+ ve as createGatedClient,
318
+ G as forgetSettledReads,
319
+ K as isCoalesced,
320
+ ce as isSettledRead,
321
+ fe as mayJoinInflight,
322
+ he as releaseGatedReads,
323
+ ye as releaseGatedReadsOnSharedFetch,
324
+ pe as withGetCoalescing
324
325
  };
@@ -1,7 +1,7 @@
1
- function o(t) {
1
+ function l(t) {
2
2
  return t == null || t === "" || Array.isArray(t) && t.length === 0;
3
3
  }
4
- function d(t) {
4
+ function f(t) {
5
5
  if (t == null || t === "") return null;
6
6
  const e = /* @__PURE__ */ new Date(), r = Date.UTC(e.getFullYear(), e.getMonth(), e.getDate()), s = String(t).match(
7
7
  /^(\d{4})-(\d{2})-(\d{2})(?:[T ]00:00:00(?:\.0+)?(?:Z|[+-]00:?00)?)?$/
@@ -12,7 +12,7 @@ function d(t) {
12
12
  const i = Date.UTC(n.getFullYear(), n.getMonth(), n.getDate());
13
13
  return Math.round((i - r) / 864e5);
14
14
  }
15
- function c(t) {
15
+ function d(t) {
16
16
  const e = String(t ?? "").trim();
17
17
  if (!e) return { stored: null, display: "", valid: !0 };
18
18
  const r = e.startsWith("+"), s = e.replace(/\D/g, "");
@@ -25,15 +25,29 @@ function c(t) {
25
25
  } : r && s.length >= 8 && s.length <= 15 ? { stored: `+${s}`, display: `+${s}`, valid: !0 } : { stored: r ? `+${s}` : s, display: e, valid: !1 };
26
26
  }
27
27
  function y(t) {
28
- const e = c(t);
28
+ const e = d(t);
29
29
  return e.valid && e.stored ? e.display : String(t ?? "");
30
30
  }
31
- function f(t, e, r) {
31
+ function p(t, e) {
32
+ let r = t;
33
+ if (typeof r == "string")
34
+ try {
35
+ r = JSON.parse(r);
36
+ } catch {
37
+ return !1;
38
+ }
39
+ return Array.isArray(r) ? r.some((s) => {
40
+ if (!s || typeof s != "object") return !1;
41
+ const n = s;
42
+ return n.soft ? !1 : n.type === "required" ? !0 : n.type === "required_if" && n.field ? c(e[n.field], String(n.op ?? "eq"), n.value) : !1;
43
+ }) : !1;
44
+ }
45
+ function c(t, e, r) {
32
46
  switch (e) {
33
47
  case "null":
34
- return o(t);
48
+ return l(t);
35
49
  case "nnull":
36
- return !o(t);
50
+ return !l(t);
37
51
  case "neq":
38
52
  return String(t ?? "") !== String(r ?? "");
39
53
  case "in":
@@ -45,14 +59,14 @@ function f(t, e, r) {
45
59
  function m(t, e) {
46
60
  const r = (u) => typeof u == "number" ? u : typeof u == "string" && /^\s*-?(\d+\.?\d*|\.\d+)\s*$/.test(u) ? Number(u) : null, s = r(t), n = r(e);
47
61
  if (s !== null && n !== null && Number.isFinite(s) && Number.isFinite(n)) return s - n;
48
- const i = (u) => u instanceof Date ? Number.isNaN(u.getTime()) ? null : u.toISOString().slice(0, 10) : typeof u == "string" && /^\d{4}-\d{2}-\d{2}/.test(u) ? u.slice(0, 10) : null, l = i(t), a = i(e);
49
- return l === null || a === null ? null : l < a ? -1 : l > a ? 1 : 0;
62
+ const i = (u) => u instanceof Date ? Number.isNaN(u.getTime()) ? null : u.toISOString().slice(0, 10) : typeof u == "string" && /^\d{4}-\d{2}-\d{2}/.test(u) ? u.slice(0, 10) : null, o = i(t), a = i(e);
63
+ return o === null || a === null ? null : o < a ? -1 : o > a ? 1 : 0;
50
64
  }
51
65
  function g(t, e, r, s, n, i) {
52
66
  if (!r || !s) return null;
53
- const l = s[r];
54
- if (o(e) || o(l)) return null;
55
- const a = m(e, l);
67
+ const o = s[r];
68
+ if (l(e) || l(o)) return null;
69
+ const a = m(e, o);
56
70
  if (a === null) return null;
57
71
  const u = r.replace(/_/g, " ");
58
72
  return t === "gte_field" && a < 0 ? i ?? `${n} must be on or after ${u}` : t === "lte_field" && a > 0 ? i ?? `${n} must be on or before ${u}` : null;
@@ -60,7 +74,7 @@ function g(t, e, r, s, n, i) {
60
74
  function $(t, e, r, s) {
61
75
  if (t.type === "required_if") {
62
76
  const n = t.field;
63
- return !n || !s || !f(s[n], String(t.op ?? "eq"), t.value) ? null : o(e) ? t.message ?? `${r} is required when ${n} matches this condition` : null;
77
+ return !n || !s || !c(s[n], String(t.op ?? "eq"), t.value) ? null : l(e) ? t.message ?? `${r} is required when ${n} matches this condition` : null;
64
78
  }
65
79
  if (t.type === "gte_field" || t.type === "lte_field")
66
80
  return g(
@@ -71,10 +85,10 @@ function $(t, e, r, s) {
71
85
  r,
72
86
  t.message
73
87
  );
74
- if (o(e) && t.type !== "required") return null;
88
+ if (l(e) && t.type !== "required") return null;
75
89
  switch (t.type) {
76
90
  case "required":
77
- return o(e) ? t.message ?? `${r} is required` : null;
91
+ return l(e) ? t.message ?? `${r} is required` : null;
78
92
  case "min": {
79
93
  const n = Number(t.value);
80
94
  return typeof e == "number" && e < n ? t.message ?? `${r} must be at least ${n}` : typeof e == "string" && e.length < n ? t.message ?? `${r} must be at least ${n} characters` : null;
@@ -92,7 +106,7 @@ function $(t, e, r, s) {
92
106
  case "email":
93
107
  return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(String(e)) ? null : t.message ?? `${r} must be a valid email`;
94
108
  case "phone":
95
- return c(e).valid ? null : t.message ?? `${r} must be a valid phone number`;
109
+ return d(e).valid ? null : t.message ?? `${r} must be a valid phone number`;
96
110
  case "url":
97
111
  try {
98
112
  return new URL(String(e)), null;
@@ -102,11 +116,11 @@ function $(t, e, r, s) {
102
116
  // Date must be at least N calendar days from today (e.g. delivery-date
103
117
  // minimums). max_days_from_today caps how far out a date may be.
104
118
  case "min_days_from_today": {
105
- const n = d(e), i = Number(t.value);
119
+ const n = f(e), i = Number(t.value);
106
120
  return n === null || Number.isNaN(i) || n >= i ? null : t.message ?? `${r} must be at least ${i} days from today`;
107
121
  }
108
122
  case "max_days_from_today": {
109
- const n = d(e), i = Number(t.value);
123
+ const n = f(e), i = Number(t.value);
110
124
  return n === null || Number.isNaN(i) || n <= i ? null : t.message ?? `${r} must be within ${i} days of today`;
111
125
  }
112
126
  default:
@@ -116,5 +130,6 @@ function $(t, e, r, s) {
116
130
  export {
117
131
  $ as applyValidationRule,
118
132
  y as formatPhone,
119
- c as normalizePhone
133
+ d as normalizePhone,
134
+ p as requiredByRules
120
135
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nivaro/react",
3
- "version": "0.3.56",
3
+ "version": "0.3.58",
4
4
  "description": "React hooks and components for Nivaro CMS forms",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",