@nivaro/react 0.3.99 → 0.3.100

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/full.css +1 -1
  2. package/dist/hooks/useFormSchema.js +82 -85
  3. package/dist/hooks/useSessionRecorder.js +206 -175
  4. package/dist/index.d.ts +38 -13
  5. package/dist/index.js +182 -180
  6. package/dist/lib/commands.js +15 -11
  7. package/dist/shared/components/CollectionBrowserView.js +516 -503
  8. package/dist/shared/components/ItemEditForm.js +3021 -3019
  9. package/dist/shared/components/JobsTray.js +20 -16
  10. package/dist/shared/components/MyWorkView.js +133 -126
  11. package/dist/shared/components/NotificationBell.js +314 -288
  12. package/dist/shared/components/RecordCompare.js +38 -40
  13. package/dist/shared/components/RecordReadView.js +119 -119
  14. package/dist/shared/components/cbv/FoundElsewhere.js +61 -0
  15. package/dist/shared/components/item-edit/InlineGridField.js +45 -45
  16. package/dist/shared/components/item-edit/InlineTableField.js +750 -749
  17. package/dist/shared/components/item-edit/QuickPickerDialog.js +44 -44
  18. package/dist/shared/components/item-edit/RawEditSheet.js +122 -114
  19. package/dist/shared/components/item-edit/RelationCombobox.js +454 -378
  20. package/dist/shared/components/item-edit/SummaryPanel.js +56 -48
  21. package/dist/shared/components/item-edit/related-missing.js +75 -19
  22. package/dist/shared/components/notifications/NotificationCenterView.js +249 -226
  23. package/dist/shared/components/panels/AccessDeniedPanel.js +31 -28
  24. package/dist/shared/components/panels/BackgroundMove.js +175 -0
  25. package/dist/shared/components/panels/MoveAdvisory.js +204 -0
  26. package/dist/shared/components/panels/PipelinePanel.js +1450 -1219
  27. package/dist/shared/components/panels/RecordIntegrityBanner.js +113 -112
  28. package/dist/shared/lib/commands.js +18 -14
  29. package/dist/shared/lib/error-hints.js +1 -1
  30. package/dist/shared/lib/job-failure-text.js +12 -0
  31. package/dist/shared/lib/move-failure.js +9 -0
  32. package/dist/shared/lib/obligation-banner.js +15 -14
  33. package/dist/shared/lib/partner-failure.js +71 -0
  34. package/dist/shared/lib/prefetch.js +73 -73
  35. package/dist/shared/lib/replay-checkout.js +18 -13
  36. package/dist/shared/lib/replay-context.js +90 -77
  37. package/dist/shared/lib/replay-idle.js +21 -0
  38. package/dist/shared/lib/replay-socket.js +21 -17
  39. package/dist/shared/lib/rum.js +56 -51
  40. package/dist/shared/lib/safe-error.js +17 -13
  41. package/dist/shared/lib/stale-chunk.js +69 -26
  42. package/dist/shared/lib/system-collections.js +20 -0
  43. package/package.json +1 -1
@@ -0,0 +1,71 @@
1
+ import { isRawErrorText as f } from "./safe-error.js";
2
+ function b(t, e) {
3
+ const r = (t ?? "").trim(), s = (e ?? "").trim(), n = s && r.toLowerCase().startsWith(`${s.toLowerCase()}:`) ? r.slice(s.length + 1).trim() : r;
4
+ return n ? n.charAt(0).toUpperCase() + n.slice(1) : "";
5
+ }
6
+ const m = /\bHTTP \d{3}: /, u = [
7
+ "message",
8
+ "error_description",
9
+ "detail",
10
+ "error",
11
+ "title",
12
+ "reason",
13
+ "description",
14
+ "msg"
15
+ ], T = new RegExp(`"(?:${u.join("|")})"\\s*:\\s*"((?:[^"\\\\]|\\\\.)*)`);
16
+ function a(t) {
17
+ try {
18
+ return JSON.parse(`"${t.replace(/\\$/, "")}"`);
19
+ } catch {
20
+ return t;
21
+ }
22
+ }
23
+ function h(t, e = 0) {
24
+ if (typeof t == "string") return t;
25
+ if (!t || typeof t != "object" || Array.isArray(t) || e > 1) return null;
26
+ const r = t;
27
+ for (const s of u) {
28
+ const n = h(r[s], e + 1);
29
+ if (n != null && n.trim()) return n;
30
+ }
31
+ return null;
32
+ }
33
+ function d(t) {
34
+ const e = m.exec(t);
35
+ if (!e) return null;
36
+ const r = t.slice(e.index + e[0].length).trim();
37
+ let s = null, n = !1;
38
+ try {
39
+ s = h(JSON.parse(r));
40
+ } catch {
41
+ const i = T.exec(r);
42
+ i ? (s = a(i[1]), n = r[i.index + i[0].length] !== '"') : r.startsWith('"') && (s = a(r.slice(1).replace(/"$/, "")), n = r.length < 2 || !r.endsWith('"'));
43
+ }
44
+ const o = (s ?? "").replace(/\s+/g, " ").trim(), c = n || o.length > 300 ? `${o.slice(0, 299).trimEnd()}…` : o;
45
+ if (o.length < 3 || /<[a-z!/]/i.test(o) || f(o)) return null;
46
+ const l = t.slice(0, e.index).replace(/[\s:·—–-]+$/, "").trim();
47
+ return l ? `${l}: ${c}` : c;
48
+ }
49
+ const p = /\bHTTP (\d{3})\b/, g = /\b(?:fetch failed|Timed out after \d+ms|socket hang up|E(?:CONN[A-Z]+|NOTFOUND|AI_AGAIN|TIMEDOUT|HOSTUNREACH))\b/;
50
+ function y(t) {
51
+ var r;
52
+ const e = Number(((r = p.exec(t)) == null ? void 0 : r[1]) ?? 0);
53
+ return e ? e === 401 || e === 403 ? "The other system did not accept this app’s sign-in. An administrator needs to check the connection." : e === 408 || e === 504 ? "The other system took too long to answer." : e === 502 || e === 503 ? "The other system is not answering right now." : e >= 500 ? "The other system ran into a problem of its own." : "The other system refused the request." : g.test(t) ? /Timed out after|ETIMEDOUT/.test(t) ? "The other system took too long to answer." : "The other system could not be reached." : null;
54
+ }
55
+ function A(t) {
56
+ return d(t) ?? y(t);
57
+ }
58
+ const E = /(?:^|: )submission failed\s+[—–-]\s/i;
59
+ function x(t) {
60
+ const e = E.exec(t);
61
+ if (!e) return null;
62
+ const r = t.slice(e.index + (e[0].startsWith(": ") ? 2 : 0));
63
+ return A(r.charAt(0).toUpperCase() + r.slice(1));
64
+ }
65
+ export {
66
+ x as partnerCallText,
67
+ A as partnerFailureText,
68
+ y as partnerOutcome,
69
+ d as partnerWords,
70
+ b as withoutMoveLabel
71
+ };
@@ -1,20 +1,20 @@
1
- import { withSignal as L } from "@nivaro/sdk";
1
+ import { withSignal as p } from "@nivaro/sdk";
2
2
  import { useQueryClient as O } from "@tanstack/react-query";
3
- import { useRef as K, useEffect as k, useMemo as U } from "react";
3
+ import { useRef as $, useEffect as A, useMemo as U } from "react";
4
4
  import { useOptionalNivaroClient as H } from "../context.js";
5
- import { get as T } from "./commands.js";
6
- const x = 30, A = 80, G = 2, z = 6, M = 3e4;
5
+ import { get as K, getActiveLayout as x } from "./commands.js";
6
+ const G = 30, k = 80, z = 2, B = 6, M = 3e4;
7
7
  let v = [];
8
- function B(e = Date.now(), r = x) {
8
+ function J(e = Date.now(), r = G) {
9
9
  return v = v.filter((t) => e - t < 6e4), v.length >= r ? !1 : (v.push(e), !0);
10
10
  }
11
- function J(e) {
11
+ function W(e) {
12
12
  return e ? e.saveData ? !1 : e.effectiveType !== "slow-2g" && e.effectiveType !== "2g" : !0;
13
13
  }
14
- function W() {
15
- return typeof navigator > "u" ? !1 : !J(navigator.connection);
14
+ function X() {
15
+ return typeof navigator > "u" ? !1 : !W(navigator.connection);
16
16
  }
17
- function X(e = G, r = z) {
17
+ function V(e = z, r = B) {
18
18
  const t = [], n = /* @__PURE__ */ new Map(), i = () => {
19
19
  for (; n.size < e && t.length > 0; ) {
20
20
  const u = t.shift();
@@ -51,49 +51,49 @@ function X(e = G, r = z) {
51
51
  }
52
52
  };
53
53
  }
54
- const g = X();
55
- function V(e, r) {
54
+ const g = V();
55
+ function Y(e, r) {
56
56
  setTimeout(() => {
57
57
  const t = e.getQueryCache().find({ queryKey: r, exact: !0 });
58
58
  !t || t.getObserversCount() > 0 || t.state.fetchStatus !== "fetching" || e.cancelQueries({ queryKey: r, exact: !0 });
59
59
  }, 120);
60
60
  }
61
- function Y(e, r) {
61
+ function Z(e, r) {
62
62
  return {
63
63
  item: ["item", e, String(r)],
64
64
  layout: ["active-layout", e, null, String(r)]
65
65
  };
66
66
  }
67
- function F(e, r, t) {
67
+ function b(e, r, t) {
68
68
  const n = e.getQueryState(r);
69
69
  return n ? n.fetchStatus === "fetching" ? !0 : n.dataUpdatedAt > 0 && t - n.dataUpdatedAt < M : !1;
70
70
  }
71
71
  function y(e, r, t, n = Date.now(), i) {
72
- if (W() || F(e, r, n)) return !1;
72
+ if (X() || b(e, r, n)) return !1;
73
73
  const u = JSON.stringify(r);
74
- return g.has(u) || !B(n) ? !1 : g.add({
74
+ return g.has(u) || !J(n) ? !1 : g.add({
75
75
  id: u,
76
76
  group: i ?? null,
77
77
  run: () => (
78
78
  // Fresh by now (the page itself fetched it while this waited) = nothing to do.
79
- F(e, r, Date.now()) ? Promise.resolve() : e.prefetchQuery({
79
+ b(e, r, Date.now()) ? Promise.resolve() : e.prefetchQuery({
80
80
  queryKey: r,
81
81
  queryFn: ({ signal: s }) => t(s),
82
82
  staleTime: M
83
83
  })
84
84
  ),
85
- cancel: () => V(e, r)
85
+ cancel: () => Y(e, r)
86
86
  });
87
87
  }
88
88
  function N(e, r, t, n, i = {}) {
89
89
  if (!t || n == null || n === "" || n === "new") return 0;
90
- const u = Y(t, n), s = i.group ?? `record:${t}:${n}`;
90
+ const u = Z(t, n), s = i.group ?? `record:${t}:${n}`;
91
91
  let c = 0;
92
92
  return y(
93
93
  e,
94
94
  u.item,
95
95
  (l) => r.request(
96
- L(T(`/items/${t}/${n}`), l)
96
+ p(K(`/items/${t}/${n}`), l)
97
97
  ).then((f) => f.data),
98
98
  Date.now(),
99
99
  s
@@ -101,27 +101,27 @@ function N(e, r, t, n, i = {}) {
101
101
  e,
102
102
  u.layout,
103
103
  (l) => r.request(
104
- L(T("/collection-layouts/active", { collection: t, item: String(n) }), l)
104
+ p(x({ collection: t, item: String(n) }), l)
105
105
  ).then((f) => f.data ?? null),
106
106
  Date.now(),
107
107
  s
108
108
  ) && c++, c;
109
109
  }
110
- function Z(e) {
110
+ function j(e) {
111
111
  return { meta: ["cbv-collection-meta", e] };
112
112
  }
113
113
  function Q(e, r, t, n = {}) {
114
114
  if (!t || /^(nivaro|directus)_/i.test(t)) return 0;
115
- const i = Z(t);
115
+ const i = j(t);
116
116
  return y(
117
117
  e,
118
118
  i.meta,
119
- (u) => r.request(L(T(`/collections/${t}`), u)).then((s) => s.data),
119
+ (u) => r.request(p(K(`/collections/${t}`), u)).then((s) => s.data),
120
120
  Date.now(),
121
121
  n.group ?? `list:${t}`
122
122
  ) ? 1 : 0;
123
123
  }
124
- function j(e, r = 2e3) {
124
+ function ee(e, r = 2e3) {
125
125
  if (typeof window > "u") return () => {
126
126
  };
127
127
  const t = window;
@@ -135,19 +135,19 @@ function j(e, r = 2e3) {
135
135
  const n = setTimeout(e, 300);
136
136
  return () => clearTimeout(n);
137
137
  }
138
- function ce(e) {
139
- const r = K(e);
138
+ function se(e) {
139
+ const r = $(e);
140
140
  r.current = e;
141
141
  const t = JSON.stringify(e.queryKey);
142
- k(() => {
142
+ A(() => {
143
143
  if (e.enabled)
144
- return j(() => {
144
+ return ee(() => {
145
145
  const n = r.current;
146
146
  y(n.qc, n.queryKey, n.queryFn);
147
147
  });
148
148
  }, [e.enabled, t]);
149
149
  }
150
- function ee(e, r) {
150
+ function te(e, r) {
151
151
  const t = e.getAttribute("href");
152
152
  if (!t || t.startsWith("#") || e.hasAttribute("download") || e.target && e.target !== "_self") return null;
153
153
  try {
@@ -157,7 +157,7 @@ function ee(e, r) {
157
157
  return null;
158
158
  }
159
159
  }
160
- function te(e) {
160
+ function ne(e) {
161
161
  if (typeof document > "u") return () => {
162
162
  };
163
163
  const r = e.root ?? document, t = window.location.origin;
@@ -167,54 +167,54 @@ function te(e) {
167
167
  }, c = () => {
168
168
  s(), i = null, u && g.cancelGroup(u), u = null;
169
169
  }, l = (a) => {
170
- var C, D, b;
171
- const o = ee(a, t);
170
+ var _, C, D;
171
+ const o = te(a, t);
172
172
  if (!o) return;
173
173
  try {
174
- (C = e.preloadRoute) == null || C.call(e, o);
174
+ (_ = e.preloadRoute) == null || _.call(e, o);
175
175
  } catch {
176
176
  }
177
177
  if (!e.client) return;
178
- const d = o.split("?")[0], m = `link:${d}`, w = (D = e.matchRecord) == null ? void 0 : D.call(e, d);
178
+ const d = o.split("?")[0], m = `link:${d}`, w = (C = e.matchRecord) == null ? void 0 : C.call(e, d);
179
179
  if (w) {
180
180
  N(e.qc, e.client, w.collection, w.id, { group: m }) > 0 && (u = m);
181
181
  return;
182
182
  }
183
- const _ = (b = e.matchList) == null ? void 0 : b.call(e, d);
184
- _ && Q(e.qc, e.client, _, { group: m }) > 0 && (u = m);
183
+ const I = (D = e.matchList) == null ? void 0 : D.call(e, d);
184
+ I && Q(e.qc, e.client, I, { group: m }) > 0 && (u = m);
185
185
  }, f = (a) => {
186
186
  var o, d;
187
187
  return (d = (o = a.target) == null ? void 0 : o.closest) == null ? void 0 : d.call(o, "a[href]");
188
- }, P = (a) => {
188
+ }, T = (a) => {
189
189
  const o = f(a);
190
190
  !o || o === i || (c(), i = o, n = setTimeout(() => {
191
191
  n = null, l(o);
192
- }, A));
193
- }, q = (a) => {
192
+ }, k));
193
+ }, P = (a) => {
194
194
  const o = a.relatedTarget;
195
195
  i && o && i.contains(o) || c();
196
196
  }, E = () => {
197
197
  u = null;
198
- }, R = (a) => {
198
+ }, q = (a) => {
199
199
  const o = a.key;
200
200
  (o === "Enter" || o === " ") && E();
201
- }, S = (a) => {
201
+ }, R = (a) => {
202
202
  const o = f(a);
203
203
  o && (c(), l(o));
204
- }, I = (a) => {
204
+ }, S = (a) => {
205
205
  f(a) && c();
206
206
  };
207
- return r.addEventListener("pointerover", P, { passive: !0 }), r.addEventListener("pointerout", q, { passive: !0 }), r.addEventListener("pointerdown", E, { passive: !0, capture: !0 }), r.addEventListener("keydown", R, { capture: !0 }), r.addEventListener("focusin", S), r.addEventListener("focusout", I), () => {
208
- s(), r.removeEventListener("pointerover", P), r.removeEventListener("pointerout", q), r.removeEventListener("pointerdown", E, { capture: !0 }), r.removeEventListener("keydown", R, { capture: !0 }), r.removeEventListener("focusin", S), r.removeEventListener("focusout", I);
207
+ return r.addEventListener("pointerover", T, { passive: !0 }), r.addEventListener("pointerout", P, { passive: !0 }), r.addEventListener("pointerdown", E, { passive: !0, capture: !0 }), r.addEventListener("keydown", q, { capture: !0 }), r.addEventListener("focusin", R), r.addEventListener("focusout", S), () => {
208
+ s(), r.removeEventListener("pointerover", T), r.removeEventListener("pointerout", P), r.removeEventListener("pointerdown", E, { capture: !0 }), r.removeEventListener("keydown", q, { capture: !0 }), r.removeEventListener("focusin", R), r.removeEventListener("focusout", S);
209
209
  };
210
210
  }
211
- function se(e) {
212
- const r = K(e);
211
+ function ae(e) {
212
+ const r = $(e);
213
213
  r.current = e;
214
214
  const t = e.enabled !== !1;
215
- k(() => {
215
+ A(() => {
216
216
  if (t)
217
- return te({
217
+ return ne({
218
218
  qc: r.current.qc,
219
219
  get client() {
220
220
  return r.current.client;
@@ -235,68 +235,68 @@ function se(e) {
235
235
  });
236
236
  }, [t]);
237
237
  }
238
- const h = /* @__PURE__ */ new Map(), p = /* @__PURE__ */ new Set();
239
- function $(e, r) {
238
+ const h = /* @__PURE__ */ new Map(), L = /* @__PURE__ */ new Set();
239
+ function F(e, r) {
240
240
  const t = () => {
241
241
  const i = h.get(e);
242
242
  i && clearTimeout(i), h.set(
243
243
  e,
244
244
  setTimeout(() => {
245
- h.delete(e), r() && p.add(e);
246
- }, A)
245
+ h.delete(e), r() && L.add(e);
246
+ }, k)
247
247
  );
248
248
  }, n = () => {
249
249
  const i = h.get(e);
250
- i && clearTimeout(i), h.delete(e), p.delete(e) && g.cancelGroup(e);
250
+ i && clearTimeout(i), h.delete(e), L.delete(e) && g.cancelGroup(e);
251
251
  };
252
252
  return {
253
253
  onPointerEnter: t,
254
254
  onPointerLeave: n,
255
255
  onPointerDown: () => {
256
- p.delete(e);
256
+ L.delete(e);
257
257
  },
258
258
  onFocus: t,
259
259
  onBlur: n
260
260
  };
261
261
  }
262
- function ae() {
262
+ function fe() {
263
263
  const e = O(), r = H();
264
264
  return U(
265
265
  () => ({
266
266
  record: (t, n) => {
267
267
  if (!r || !t || n == null || n === "" || n === "new") return {};
268
268
  const i = `record:${t}:${n}`;
269
- return $(i, () => N(e, r, t, n, { group: i }));
269
+ return F(i, () => N(e, r, t, n, { group: i }));
270
270
  },
271
271
  list: (t) => {
272
272
  if (!r || !t) return {};
273
273
  const n = `list:${t}`;
274
- return $(n, () => Q(e, r, t, { group: n }));
274
+ return F(n, () => Q(e, r, t, { group: n }));
275
275
  }
276
276
  }),
277
277
  [e, r]
278
278
  );
279
279
  }
280
280
  export {
281
- A as INTENT_DWELL_MS,
282
- G as MAX_PREFETCH_IN_FLIGHT,
283
- z as MAX_PREFETCH_QUEUED,
284
- x as PREFETCH_PER_MINUTE,
281
+ k as INTENT_DWELL_MS,
282
+ z as MAX_PREFETCH_IN_FLIGHT,
283
+ B as MAX_PREFETCH_QUEUED,
284
+ G as PREFETCH_PER_MINUTE,
285
285
  M as PREFETCH_STALE_MS,
286
- J as connectionAllowsPrefetch,
287
- X as createPrefetchLimiter,
288
- te as installIntentPrefetch,
289
- $ as intentProps,
290
- ee as linkPath,
291
- Z as listQueryKeys,
286
+ W as connectionAllowsPrefetch,
287
+ V as createPrefetchLimiter,
288
+ ne as installIntentPrefetch,
289
+ F as intentProps,
290
+ te as linkPath,
291
+ j as listQueryKeys,
292
292
  Q as prefetchCollectionList,
293
293
  y as prefetchKey,
294
294
  g as prefetchLimiter,
295
295
  N as prefetchRecord,
296
- Y as recordQueryKeys,
297
- B as takePrefetchToken,
298
- ce as useIdleNextPage,
299
- se as useIntentPrefetch,
300
- ae as usePrefetchIntent,
301
- j as whenIdle
296
+ Z as recordQueryKeys,
297
+ J as takePrefetchToken,
298
+ se as useIdleNextPage,
299
+ ae as useIntentPrefetch,
300
+ fe as usePrefetchIntent,
301
+ ee as whenIdle
302
302
  };
@@ -1,20 +1,25 @@
1
1
  const i = 6e4, o = 9e5;
2
- const a = /* @__PURE__ */ new Set([1, 2, 3, 4, 5, 6, 12, 14]);
3
- function u(e = Date.now()) {
4
- return { lastFullAt: e, interacted: !1, pending: !1 };
2
+ const l = /* @__PURE__ */ new Set([1, 2, 3, 4, 5, 6, 12, 14]);
3
+ function u(n) {
4
+ var t;
5
+ const e = n;
6
+ return (e == null ? void 0 : e.type) === 3 && l.has(Number((t = e.data) == null ? void 0 : t.source));
5
7
  }
6
- function _(e, l, t = Date.now()) {
7
- var E;
8
- const n = l;
9
- if ((n == null ? void 0 : n.type) === 2)
10
- return e.lastFullAt = t, e.interacted = !1, e.pending = !1, !1;
11
- if ((n == null ? void 0 : n.type) === 3 && a.has(Number((E = n.data) == null ? void 0 : E.source)) && (e.interacted = !0), e.pending) return !1;
12
- const c = t - e.lastFullAt, r = e.interacted ? c >= 6e4 : c >= 9e5;
13
- return r && (e.pending = !0), r;
8
+ function a(n = Date.now()) {
9
+ return { lastFullAt: n, interacted: !1, pending: !1 };
10
+ }
11
+ function s(n, e, t = Date.now()) {
12
+ const c = e;
13
+ if ((c == null ? void 0 : c.type) === 2)
14
+ return n.lastFullAt = t, n.interacted = !1, n.pending = !1, !1;
15
+ if (u(e) && (n.interacted = !0), n.pending) return !1;
16
+ const r = t - n.lastFullAt, E = n.interacted ? r >= 6e4 : r >= 9e5;
17
+ return E && (n.pending = !0), E;
14
18
  }
15
19
  export {
16
20
  i as REPLAY_CHECKOUT_ACTIVE_MS,
17
21
  o as REPLAY_CHECKOUT_IDLE_MS,
18
- u as createReplayCheckoutState,
19
- _ as noteReplayEvent
22
+ a as createReplayCheckoutState,
23
+ u as isReplayInputEvent,
24
+ s as noteReplayEvent
20
25
  };