@nivaro/react 0.3.64 → 0.3.66

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 (74) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +62 -8
  4. package/dist/shared/components/CollectionBrowserView.js +3127 -3204
  5. package/dist/shared/components/ConformanceView.js +235 -221
  6. package/dist/shared/components/DataTable.js +478 -459
  7. package/dist/shared/components/ItemEditForm.js +4842 -4500
  8. package/dist/shared/components/MyWorkView.js +124 -113
  9. package/dist/shared/components/PageRenderer.js +146 -138
  10. package/dist/shared/components/ProfileView.js +483 -472
  11. package/dist/shared/components/RecordDrilldownSheet.js +73 -65
  12. package/dist/shared/components/ReportView.js +1100 -1094
  13. package/dist/shared/components/bulk/BulkActionButtons.js +72 -72
  14. package/dist/shared/components/bulk/BulkCompareButton.js +62 -0
  15. package/dist/shared/components/bulk/BulkFieldUpdate.js +114 -103
  16. package/dist/shared/components/bulk/BulkFieldUpdateButton.js +73 -0
  17. package/dist/shared/components/bulk/MessageStakeholders.js +235 -0
  18. package/dist/shared/components/bulk/bulk-field-options.js +29 -23
  19. package/dist/shared/components/integrations/IntegrationObligationsView.js +191 -173
  20. package/dist/shared/components/integrations/IntegrationStatusLines.js +101 -85
  21. package/dist/shared/components/integrations/RecordIntegrationPreview.js +11 -9
  22. package/dist/shared/components/integrations/SendCurrentData.js +126 -0
  23. package/dist/shared/components/item-edit/CatalogPickerField.js +1535 -1440
  24. package/dist/shared/components/item-edit/FieldRenderer.js +49 -45
  25. package/dist/shared/components/item-edit/FieldRow.js +413 -403
  26. package/dist/shared/components/item-edit/GroupSection.js +555 -538
  27. package/dist/shared/components/item-edit/InlineTableField.js +2903 -2816
  28. package/dist/shared/components/item-edit/M2MCombobox.js +407 -338
  29. package/dist/shared/components/item-edit/MidairCollisionDialog.js +367 -116
  30. package/dist/shared/components/item-edit/NestedRelationEditor.js +171 -163
  31. package/dist/shared/components/item-edit/PlanGrid.js +783 -724
  32. package/dist/shared/components/item-edit/QuickCreateButton.js +291 -224
  33. package/dist/shared/components/item-edit/RecordInsights.js +113 -111
  34. package/dist/shared/components/item-edit/RecordLiveSync.js +4 -1
  35. package/dist/shared/components/item-edit/RelationCombobox.js +398 -364
  36. package/dist/shared/components/item-edit/SummaryPanel.js +146 -144
  37. package/dist/shared/components/item-edit/UserChip.js +264 -229
  38. package/dist/shared/components/item-edit/cascade-clear-notice.js +56 -0
  39. package/dist/shared/components/item-edit/collision-format.js +37 -0
  40. package/dist/shared/components/item-edit/field-a11y.js +25 -0
  41. package/dist/shared/components/item-edit/header-path-preview.js +52 -0
  42. package/dist/shared/components/item-edit/line-merge.js +84 -0
  43. package/dist/shared/components/item-edit/line-midair.js +94 -87
  44. package/dist/shared/components/item-edit/move-guard.js +17 -0
  45. package/dist/shared/components/item-edit/picker-search.js +27 -16
  46. package/dist/shared/components/item-edit/rail-width.js +8 -0
  47. package/dist/shared/components/monitoring/InactiveUserLinksView.js +126 -124
  48. package/dist/shared/components/panels/AccessDeniedPanel.js +96 -55
  49. package/dist/shared/components/panels/CommentPanel.js +142 -136
  50. package/dist/shared/components/panels/ItemLockBanner.js +246 -240
  51. package/dist/shared/components/panels/PipelinePanel.js +1366 -1194
  52. package/dist/shared/components/panels/RevisionsPanel.js +106 -102
  53. package/dist/shared/components/panels/SlaBreachBanner.js +16 -20
  54. package/dist/shared/components/panels/SlaClock.js +90 -68
  55. package/dist/shared/components/queue/QueueItemSheet.js +94 -87
  56. package/dist/shared/components/queue/QueueWorklist.js +1522 -1347
  57. package/dist/shared/components/queue/worklist-csv.js +75 -0
  58. package/dist/shared/components/queue/worklist-helpers.js +20 -0
  59. package/dist/shared/components/widgets/ReviewListWidget.js +226 -207
  60. package/dist/shared/lib/bulk-copy.js +17 -0
  61. package/dist/shared/lib/cbv-export.js +122 -0
  62. package/dist/shared/lib/delete-offer.js +13 -0
  63. package/dist/shared/lib/error-hints.js +1 -0
  64. package/dist/shared/lib/leave-guard.js +41 -26
  65. package/dist/shared/lib/list-link.js +72 -56
  66. package/dist/shared/lib/live-queries.js +32 -30
  67. package/dist/shared/lib/moved-notice.js +25 -0
  68. package/dist/shared/lib/notification-target.js +56 -54
  69. package/dist/shared/lib/obligation-banner.js +11 -8
  70. package/dist/shared/lib/obligation-reason-text.js +6 -6
  71. package/dist/shared/lib/quick-filter-cascade.js +29 -19
  72. package/dist/shared/lib/sort-cycle.js +6 -0
  73. package/dist/shared/lib/summary-mode.js +59 -41
  74. package/package.json +1 -1
@@ -0,0 +1,56 @@
1
+ import { useRef as s, useEffect as f, useCallback as d, createContext as m, useContext as h } from "react";
2
+ import { toast as C } from "sonner";
3
+ const p = m(null), E = () => h(p);
4
+ function w(n) {
5
+ const e = [...new Set(n.filter(Boolean))];
6
+ return e.length <= 1 ? e[0] ?? "" : `${e.slice(0, -1).join(", ")} and ${e[e.length - 1]}`;
7
+ }
8
+ function T(n, e) {
9
+ const r = w(n);
10
+ return e ? `${r} cleared — not available for the ${e} you picked` : `${r} cleared — no longer available for what you picked`;
11
+ }
12
+ function x(n, e) {
13
+ const r = new Set(n.map((t) => t.field)), o = [...new Set(n.flatMap((t) => t.parents))].filter((t) => !r.has(t));
14
+ return o.length === 0 ? null : o.reduce((t, c) => e(c) > e(t) ? c : t, o[0]);
15
+ }
16
+ const S = 4e3, g = 500, R = "nvr-cascade-clear";
17
+ function N(n) {
18
+ const e = s(n);
19
+ e.current = n;
20
+ const r = s([]), o = s(0), t = s(null);
21
+ return f(
22
+ () => () => {
23
+ t.current && clearTimeout(t.current);
24
+ },
25
+ []
26
+ ), d((c) => {
27
+ const l = Date.now();
28
+ l - o.current > S && (r.current = []), o.current = l, r.current.some((a) => a.field === c.field) || r.current.push(c), t.current && clearTimeout(t.current), t.current = setTimeout(() => {
29
+ const a = r.current;
30
+ if (a.length === 0) return;
31
+ const u = x(a, e.current.editSeq);
32
+ C.info(
33
+ T(
34
+ a.map((i) => i.label),
35
+ u ? e.current.labelOf(u) : null
36
+ ),
37
+ {
38
+ id: R,
39
+ description: "Pick them again from the narrowed lists."
40
+ }
41
+ );
42
+ }, g);
43
+ }, []);
44
+ }
45
+ function P(n, e, r) {
46
+ return r.crossFill > 0 || r.notPerson > 0 ? !1 : (n.touched.add(e), n.seq.set(e, n.next()), !0);
47
+ }
48
+ export {
49
+ p as CascadeClearNoticeContext,
50
+ T as cascadeClearText,
51
+ x as cascadeRootParent,
52
+ w as joinLabels,
53
+ P as notePersonLinkEdit,
54
+ N as useCascadeClearNotices,
55
+ E as useCascadeClearNotifier
56
+ };
@@ -0,0 +1,37 @@
1
+ const s = /(^|_)(total|amount|price|cost|subtotal|spend|budget)s?($|_)/i;
2
+ function c(t) {
3
+ return s.test(t);
4
+ }
5
+ function m(t) {
6
+ if (typeof t == "number") return Number.isFinite(t) ? t : null;
7
+ if (typeof t == "string" && /^-?\d+(\.\d+)?(e-?\d+)?$/i.test(t.trim())) {
8
+ const n = Number(t);
9
+ return Number.isFinite(n) ? n : null;
10
+ }
11
+ return null;
12
+ }
13
+ function a(t, n) {
14
+ const r = m(n);
15
+ if (r == null) return null;
16
+ const u = Number(r.toPrecision(12));
17
+ return c(t) ? u.toLocaleString("en-US", {
18
+ style: "currency",
19
+ currency: "USD",
20
+ minimumFractionDigits: 2,
21
+ maximumFractionDigits: 2
22
+ }) : u.toLocaleString("en-US", { maximumFractionDigits: 6 });
23
+ }
24
+ function f(t, n, r = 12, u = 24) {
25
+ let e = 0;
26
+ const l = Math.min(t.length, n.length);
27
+ for (; e < l && t[e] === n[e]; ) e++;
28
+ if (e < u) return { a: t, b: n };
29
+ let i = Math.max(0, e - r);
30
+ const o = t.lastIndexOf(" ", i);
31
+ return o > 0 && i - o <= 8 && (i = o + 1), { a: `…${t.slice(i)}`, b: `…${n.slice(i)}` };
32
+ }
33
+ export {
34
+ a as collisionNumberText,
35
+ f as differingTails,
36
+ c as isMoneyFieldName
37
+ };
@@ -0,0 +1,25 @@
1
+ function o(t, e) {
2
+ const a = (i, u) => {
3
+ u == null ? t.hasAttribute(i) && t.removeAttribute(i) : t.getAttribute(i) !== u && t.setAttribute(i, u);
4
+ }, r = t.tagName !== "BUTTON" || t.getAttribute("role") === "combobox";
5
+ a("aria-required", e.required && r ? "true" : null), e.hasError ? (a("aria-invalid", "true"), t.setAttribute("data-nvr-invalid", "")) : t.hasAttribute("data-nvr-invalid") && (t.removeAttribute("data-nvr-invalid"), a("aria-invalid", null));
6
+ const n = (t.getAttribute("aria-describedby") ?? "").split(/\s+/).filter((i) => i && i !== e.errorId);
7
+ e.hasError && e.describe !== !1 && n.push(e.errorId), a("aria-describedby", n.length ? n.join(" ") : null);
8
+ }
9
+ function b(t) {
10
+ return t ? t.querySelector(
11
+ 'input:not([type=hidden]), textarea, [role="combobox"], [contenteditable="true"]'
12
+ ) ?? t.querySelector("button") : null;
13
+ }
14
+ function d(t, e, a) {
15
+ const r = b(t);
16
+ if (!r || (o(r, a), r.hasAttribute("aria-label"))) return;
17
+ r.id || (r.id = `${e}-control`);
18
+ const n = r.tagName === "BUTTON" ? `${e} ${r.id}` : e;
19
+ r.getAttribute("aria-labelledby") !== n && r.setAttribute("aria-labelledby", n);
20
+ }
21
+ export {
22
+ o as applyFieldA11y,
23
+ d as nameFieldControl,
24
+ b as primaryControl
25
+ };
@@ -0,0 +1,52 @@
1
+ import { useQueries as p } from "@tanstack/react-query";
2
+ import { useMemo as m } from "react";
3
+ import { useNivaroClient as h } from "../../context.js";
4
+ import { get as w } from "../../lib/commands.js";
5
+ function v(n, f, c, a) {
6
+ const d = [];
7
+ for (const l of n) {
8
+ const r = l.split(".");
9
+ if (r.length !== 2 || !r[0] || !r[1]) continue;
10
+ const [t, o] = r, e = f[t], i = e != null && typeof e == "object" ? e.id : e;
11
+ if (i == null || i === "") continue;
12
+ const s = c[t], u = s != null && typeof s == "object" ? s.id : s;
13
+ !a && String(u ?? "") === String(i) || d.push({ path: l, hop: t, rest: o, id: String(i) });
14
+ }
15
+ return d;
16
+ }
17
+ function _(n) {
18
+ const f = h(), c = v(n.paths, n.draft, n.saved, n.isNew).map((t) => {
19
+ const o = n.relations.find(
20
+ (e) => e.many_collection === n.collection && e.many_field === t.hop && !e.junction_field
21
+ );
22
+ return o != null && o.one_collection ? { ...t, target: o.one_collection } : null;
23
+ }).filter((t) => !!t), a = /* @__PURE__ */ new Map();
24
+ for (const t of c) {
25
+ const o = `${t.target}:${t.id}`, e = a.get(o) ?? { target: t.target, id: t.id, fields: /* @__PURE__ */ new Set() };
26
+ e.fields.add(t.rest), a.set(o, e);
27
+ }
28
+ const d = [...a.values()], l = p({
29
+ queries: d.map((t) => ({
30
+ queryKey: ["header-path-preview", t.target, t.id, [...t.fields].sort().join(",")],
31
+ queryFn: () => f.request(
32
+ w(`/items/${t.target}/${encodeURIComponent(t.id)}`, {
33
+ fields: [...t.fields].join(",")
34
+ })
35
+ ).then((o) => o.data ?? null).catch(() => null),
36
+ staleTime: 3e4
37
+ }))
38
+ }), r = l.map((t) => t.dataUpdatedAt).join(",");
39
+ return m(() => {
40
+ var o;
41
+ const t = {};
42
+ for (const e of c) {
43
+ const i = d.findIndex((u) => u.target === e.target && u.id === e.id), s = (o = l[i]) == null ? void 0 : o.data;
44
+ s && (t[e.path] = s[e.rest] ?? null);
45
+ }
46
+ return t;
47
+ }, [r, c.map((t) => `${t.path}=${t.id}`).join("|")]);
48
+ }
49
+ export {
50
+ v as pathsToPreview,
51
+ _ as useHeaderPathPreview
52
+ };
@@ -0,0 +1,84 @@
1
+ import { evaluateNumeric as u } from "../../lib/expression.js";
2
+ import { sameStoredValue as a } from "../../lib/write-formula.js";
3
+ import { lineConflictKey as l } from "./line-midair.js";
4
+ function m(e, n) {
5
+ return e.key != null && e.rowId != null ? l({ key: e.key, rowId: e.rowId }, n) : n;
6
+ }
7
+ function k(e) {
8
+ const n = new Set((e.derived ?? []).map((t) => t.field));
9
+ return e.conflicts.map((t) => {
10
+ const i = e.mine[t.field], c = n.has(t.field) ? "derived" : a(t.current_value, i) ? "same" : "conflict";
11
+ return {
12
+ key: m(e, t.field),
13
+ field: t.field,
14
+ theirs: t.current_value,
15
+ mine: i,
16
+ kind: c
17
+ };
18
+ });
19
+ }
20
+ function b(e, n) {
21
+ return e.every((t) => t.kind !== "conflict" || n.has(t.key));
22
+ }
23
+ function g(e, n) {
24
+ const t = /* @__PURE__ */ new Set();
25
+ for (const i of e) (i.kind !== "conflict" || n.get(i.key) !== "mine") && t.add(i.key);
26
+ return t;
27
+ }
28
+ function y(e, n) {
29
+ if (!(n != null && n.length)) return e;
30
+ const t = { ...e };
31
+ for (const i of n) {
32
+ const c = u(i.formula, t);
33
+ c !== null && Number.isFinite(c) && (t[i.field] = Math.round(c * 1e6) / 1e6);
34
+ }
35
+ return t;
36
+ }
37
+ function w(e, n) {
38
+ const t = k(e), i = new Set(t.map((r) => r.field)), c = new Set((e.derived ?? []).map((r) => r.field)), o = { ...e.current ?? {} };
39
+ for (const [r, d] of Object.entries(e.edit ?? e.mine))
40
+ r.startsWith("_") || r === "id" || i.has(r) || c.has(r) || (o[r] = d);
41
+ for (const r of t)
42
+ r.kind !== "derived" && (o[r.field] = r.kind === "conflict" && n.get(r.key) === "mine" ? r.mine : r.theirs);
43
+ return y(o, e.derived);
44
+ }
45
+ function S(e, n) {
46
+ const t = [], i = e.edit ?? e.mine, c = (o) => {
47
+ if (t.includes(o) || o === "id" || o.startsWith("_") || /_id$/.test(o)) return;
48
+ const r = i[o];
49
+ r !== null && typeof r == "object" || n != null && n(o) || t.push(o);
50
+ };
51
+ for (const o of Object.keys(e.edit ?? e.mine)) c(o);
52
+ for (const o of e.conflicts) c(o.field);
53
+ for (const o of e.derived ?? []) c(o.field);
54
+ return t;
55
+ }
56
+ function O(e) {
57
+ const n = {};
58
+ for (const [t, i] of Object.entries(e ?? {}))
59
+ t !== "id" && !t.startsWith("_") && (n[t] = i);
60
+ return n;
61
+ }
62
+ const v = /^(date_created|date_updated|created|changed|user_created|user_updated|creator|modified_by|modified_on)$/i;
63
+ function j(e, n, t) {
64
+ const i = t.filter((f) => Number(f.id) > n);
65
+ if (i.length === 0) return null;
66
+ const c = i.reduce((f, s) => Number(s.id) > Number(f.id) ? s : f), o = /* @__PURE__ */ new Set();
67
+ for (const f of i)
68
+ for (const s of Object.keys(f.delta ?? {})) v.test(s) || o.add(s);
69
+ const r = c.data ?? null, d = [];
70
+ for (const f of Object.keys(e))
71
+ f === "id" || f.startsWith("_") || !o.has(f) || d.push({ field: f, current_value: r ? r[f] : null });
72
+ return { conflicts: d, latest: Number(c.id), current: r };
73
+ }
74
+ export {
75
+ k as classifyLineConflicts,
76
+ O as mergeEditOf,
77
+ m as mergeKeyOf,
78
+ b as mergeReady,
79
+ g as mergeTheirsKeys,
80
+ w as mergedLinePreview,
81
+ S as previewFields,
82
+ y as recomputeDerived,
83
+ j as restoredLineConflicts
84
+ };
@@ -1,67 +1,70 @@
1
1
  var q = Object.defineProperty;
2
2
  var _ = (s, t, n) => t in s ? q(s, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : s[t] = n;
3
- var w = (s, t, n) => _(s, typeof t != "symbol" ? t + "" : t, n);
4
- import { patch as b, get as h } from "../../lib/commands.js";
5
- import { midairCollisionOf as d } from "../../lib/record-outbox.js";
3
+ var p = (s, t, n) => _(s, typeof t != "symbol" ? t + "" : t, n);
4
+ import { patch as d, get as h } from "../../lib/commands.js";
5
+ import { midairCollisionOf as b } from "../../lib/record-outbox.js";
6
6
  function S(s, t) {
7
7
  return typeof t != "number" || !Number.isFinite(t) || t <= 0 ? s : { ...s, _base_revision: t };
8
8
  }
9
- function A(s, t) {
9
+ function C(s, t) {
10
10
  return `${s.key}\0${s.rowId}\0${t}`;
11
11
  }
12
- function C(s, t) {
12
+ function N(s, t) {
13
13
  const n = {};
14
- for (const [i, e] of Object.entries(s)) t.has(i) || (n[i] = e);
15
- return Object.keys(n).some((i) => i !== "_change_reason" && i !== "__flush_early") ? n : null;
14
+ for (const [r, e] of Object.entries(s)) t.has(r) || (n[r] = e);
15
+ return Object.keys(n).some((r) => r !== "_change_reason" && r !== "__flush_early") ? n : null;
16
16
  }
17
- function N(s, t, n, r) {
18
- const i = s.findIndex((a) => String(a.id) === String(t)), e = i >= 0 ? s[i] : void 0, o = (e == null ? void 0 : e[n || "line_number"]) ?? (e == null ? void 0 : e.line_number);
17
+ function j(s, t, n, i) {
18
+ var u;
19
+ const r = s.findIndex((c) => String(c.id) === String(t)), e = r >= 0 ? s[r] : void 0, o = (e == null ? void 0 : e[n || "line_number"]) ?? (e == null ? void 0 : e.line_number);
19
20
  if (o != null && o !== "") return `Line ${String(o)}`;
20
21
  if (e) {
22
+ const c = (u = i == null ? void 0 : i(e)) == null ? void 0 : u.trim();
23
+ if (c) return c;
21
24
  const a = e.year;
22
25
  if ((typeof a == "number" || typeof a == "string") && /^\d{4}$/.test(String(a)))
23
26
  return `Year ${String(a)}`;
24
27
  }
25
- return i >= 0 ? `Line ${i + 1}` : `Row ${t}`;
28
+ return r >= 0 ? `Line ${r + 1}` : `Row ${t}`;
26
29
  }
27
- const p = 500;
30
+ const m = 500;
28
31
  function k(s) {
29
32
  var n;
30
33
  const t = s;
31
34
  return ((t == null ? void 0 : t.status) ?? ((n = t == null ? void 0 : t.response) == null ? void 0 : n.status)) === 404;
32
35
  }
33
36
  async function $(s, t, n) {
34
- const r = /* @__PURE__ */ new Map(), i = [...new Set(n.map(String))].filter(
37
+ const i = /* @__PURE__ */ new Map(), r = [...new Set(n.map(String))].filter(
35
38
  (e) => e && e !== "new" && !e.startsWith("pending:")
36
39
  );
37
- for (let e = 0; e < i.length; e += p) {
38
- const o = i.slice(e, e + p);
40
+ for (let e = 0; e < r.length; e += m) {
41
+ const o = r.slice(e, e + m);
39
42
  try {
40
- const a = await s.request(
43
+ const u = await s.request(
41
44
  h("/revisions/latest", { collection: t, items: o.join(",") })
42
45
  );
43
- for (const [c, u] of Object.entries((a == null ? void 0 : a.data) ?? {}))
44
- r.set(c, typeof u == "number" && Number.isFinite(u) ? u : null);
45
- } catch (a) {
46
- if (!k(a)) continue;
46
+ for (const [c, a] of Object.entries((u == null ? void 0 : u.data) ?? {}))
47
+ i.set(c, typeof a == "number" && Number.isFinite(a) ? a : null);
48
+ } catch (u) {
49
+ if (!k(u)) continue;
47
50
  let c = 0;
48
- const u = async () => {
49
- var g;
51
+ const a = async () => {
52
+ var l;
50
53
  for (; c < o.length; ) {
51
- const y = o[c++];
54
+ const f = o[c++];
52
55
  try {
53
- const f = await s.request(
54
- h("/revisions", { collection: t, item: y, latest_only: "1" })
55
- ), l = (g = f == null ? void 0 : f.data) == null ? void 0 : g.latest;
56
- r.set(y, typeof l == "number" && Number.isFinite(l) ? l : null);
56
+ const g = await s.request(
57
+ h("/revisions", { collection: t, item: f, latest_only: "1" })
58
+ ), y = (l = g == null ? void 0 : g.data) == null ? void 0 : l.latest;
59
+ i.set(f, typeof y == "number" && Number.isFinite(y) ? y : null);
57
60
  } catch {
58
61
  }
59
62
  }
60
63
  };
61
- await Promise.all(Array.from({ length: Math.min(4, o.length) }, u));
64
+ await Promise.all(Array.from({ length: Math.min(4, o.length) }, a));
62
65
  }
63
66
  }
64
- return r;
67
+ return i;
65
68
  }
66
69
  function M(s) {
67
70
  try {
@@ -72,35 +75,35 @@ function M(s) {
72
75
  }
73
76
  class R {
74
77
  constructor(t) {
75
- w(this, "entries", /* @__PURE__ */ new Map());
78
+ p(this, "entries", /* @__PURE__ */ new Map());
76
79
  this.fetcher = t;
77
80
  }
78
- put(t, n, r) {
79
- const i = {
81
+ put(t, n, i) {
82
+ const r = {
80
83
  sig: n,
81
- base: r
84
+ base: i
82
85
  };
83
- this.entries.set(t, i), r.then((e) => {
84
- i.settled = e;
86
+ this.entries.set(t, r), i.then((e) => {
87
+ r.settled = e;
85
88
  });
86
89
  }
87
90
  /** Record a read of these rows. */
88
91
  noteRows(t) {
89
- var i;
92
+ var r;
90
93
  const n = [];
91
94
  for (const e of t) {
92
95
  const o = (e == null ? void 0 : e.id) == null ? "" : String(e.id);
93
96
  if (!o || o === "new" || o.startsWith("pending:")) continue;
94
- const a = M(e);
95
- ((i = this.entries.get(o)) == null ? void 0 : i.sig) !== a && n.push({ id: o, sig: a });
97
+ const u = M(e);
98
+ ((r = this.entries.get(o)) == null ? void 0 : r.sig) !== u && n.push({ id: o, sig: u });
96
99
  }
97
100
  if (n.length === 0) return;
98
- const r = this.fetcher(n.map((e) => e.id)).catch(() => /* @__PURE__ */ new Map());
101
+ const i = this.fetcher(n.map((e) => e.id)).catch(() => /* @__PURE__ */ new Map());
99
102
  for (const e of n)
100
103
  this.put(
101
104
  e.id,
102
105
  e.sig,
103
- r.then((o) => o.has(e.id) ? o.get(e.id) ?? null : null)
106
+ i.then((o) => o.has(e.id) ? o.get(e.id) ?? null : null)
104
107
  );
105
108
  }
106
109
  /** The base for a write to this row — read-time when known, else fetched
@@ -111,8 +114,8 @@ class R {
111
114
  const e = await n.base;
112
115
  if (e != null) return e;
113
116
  }
114
- const i = (await this.fetcher([t]).catch(() => /* @__PURE__ */ new Map())).get(t) ?? null;
115
- return i != null && this.set(t, i), i;
117
+ const r = (await this.fetcher([t]).catch(() => /* @__PURE__ */ new Map())).get(t) ?? null;
118
+ return r != null && this.set(t, r), r;
116
119
  }
117
120
  /** The read-time base of a row, if a read noted it (undefined = never read). */
118
121
  peek(t) {
@@ -127,88 +130,92 @@ class R {
127
130
  /** After a 409: the person's next write is a choice made against `latest`. */
128
131
  set(t, n) {
129
132
  var e;
130
- const i = { sig: ((e = this.entries.get(t)) == null ? void 0 : e.sig) ?? "", base: Promise.resolve(n), settled: n };
131
- this.entries.set(t, i);
133
+ const r = { sig: ((e = this.entries.get(t)) == null ? void 0 : e.sig) ?? "", base: Promise.resolve(n), settled: n };
134
+ this.entries.set(t, r);
132
135
  }
133
136
  /** After the person's own write: the next read brings the new base. */
134
137
  forget(t) {
135
138
  this.entries.delete(t);
136
139
  }
137
140
  }
138
- const m = /* @__PURE__ */ new WeakMap();
139
- function L(s, t) {
140
- let n = m.get(s);
141
- n || (n = /* @__PURE__ */ new Map(), m.set(s, n));
142
- let r = n.get(t);
143
- return r || (r = new R((i) => $(s, t, i)), n.set(t, r)), r;
141
+ const w = /* @__PURE__ */ new WeakMap();
142
+ function O(s, t) {
143
+ let n = w.get(s);
144
+ n || (n = /* @__PURE__ */ new Map(), w.set(s, n));
145
+ let i = n.get(t);
146
+ return i || (i = new R((r) => $(s, t, r)), n.set(t, i)), i;
144
147
  }
145
- function j(s, t) {
148
+ function x(s, t) {
146
149
  const n = /* @__PURE__ */ new Map();
147
- for (const r of t)
148
- !r || r === "new" || r.startsWith("pending:") || n.set(r, s.baseOf(r));
150
+ for (const i of t)
151
+ !i || i === "new" || i.startsWith("pending:") || n.set(i, s.baseOf(i));
149
152
  return n;
150
153
  }
151
- async function x(s, t, n, r, i, e) {
152
- const o = e.base !== void 0 ? await e.base : null, a = o != null && o > 0 ? o : await t.baseOf(r);
154
+ async function F(s, t, n, i, r, e) {
155
+ const o = e.base !== void 0 ? await e.base : null, u = o != null && o > 0 ? o : await t.baseOf(i);
153
156
  try {
154
- await s.request(b(n, S(i, a)));
157
+ await s.request(d(n, S(r, u)));
155
158
  } catch (c) {
156
- const u = d(c);
157
- if (!u) throw c;
158
- return u.latest > 0 && t.set(r, u.latest), {
159
+ const a = b(c);
160
+ if (!a) throw c;
161
+ a.latest > 0 && t.set(i, a.latest);
162
+ const l = await s.request(h(n.split("?")[0])).then((f) => (f == null ? void 0 : f.data) ?? null).catch(() => null);
163
+ return {
159
164
  ok: !1,
160
165
  conflict: {
161
166
  key: e.key,
162
- rowId: r,
167
+ rowId: i,
163
168
  label: e.label,
164
- conflicts: u.conflicts,
165
- latest: u.latest,
166
- mine: i,
169
+ conflicts: a.conflicts,
170
+ latest: a.latest,
171
+ mine: r,
172
+ edit: r,
173
+ current: l,
167
174
  url: n
168
175
  }
169
176
  };
170
177
  }
171
- return t.forget(r), { ok: !0 };
178
+ return t.forget(i), { ok: !0 };
172
179
  }
173
- async function F(s, t, n, r, i, e = 3) {
180
+ async function K(s, t, n, i, r, e = 3) {
174
181
  for (let o = 0; o < e; o++) {
175
- const a = await $(s, t, [n]), c = await s.request(
176
- h(`/items/${t}/${n}`, { fields: `id,${r}` })
177
- ).then((u) => (u == null ? void 0 : u.data) ?? null);
182
+ const u = await $(s, t, [n]), c = await s.request(
183
+ h(`/items/${t}/${n}`, { fields: `id,${i}` })
184
+ ).then((a) => (a == null ? void 0 : a.data) ?? null);
178
185
  if (!c) return !1;
179
186
  try {
180
187
  return await s.request(
181
- b(
188
+ d(
182
189
  `/items/${t}/${n}`,
183
- S({ [r]: (Number(c[r]) || 0) + i }, a.get(n))
190
+ S({ [i]: (Number(c[i]) || 0) + r }, u.get(n))
184
191
  )
185
192
  ), !0;
186
- } catch (u) {
187
- if (!d(u)) throw u;
193
+ } catch (a) {
194
+ if (!b(a)) throw a;
188
195
  }
189
196
  }
190
197
  return !1;
191
198
  }
192
- function K(s, t, n) {
193
- const r = (e, o) => {
194
- e[0] !== "o2m-rows" || String(e[3]) !== n || typeof e[1] != "string" || Array.isArray(o) && L(t, e[1]).noteRows(o);
195
- }, i = s.getQueryCache();
196
- for (const e of i.findAll({ queryKey: ["o2m-rows"] })) r(e.queryKey, e.state.data);
197
- return i.subscribe((e) => {
198
- e.type !== "updated" || e.action.type !== "success" || r(e.query.queryKey, e.query.state.data);
199
+ function L(s, t, n) {
200
+ const i = (e, o) => {
201
+ e[0] !== "o2m-rows" || String(e[3]) !== n || typeof e[1] != "string" || Array.isArray(o) && O(t, e[1]).noteRows(o);
202
+ }, r = s.getQueryCache();
203
+ for (const e of r.findAll({ queryKey: ["o2m-rows"] })) i(e.queryKey, e.state.data);
204
+ return r.subscribe((e) => {
205
+ e.type !== "updated" || e.action.type !== "success" || i(e.query.queryKey, e.query.state.data);
199
206
  });
200
207
  }
201
208
  export {
202
- p as LATEST_BATCH,
209
+ m as LATEST_BATCH,
203
210
  R as RowBaseBook,
204
211
  $ as fetchLatestRevisions,
205
- F as incrementGuarded,
206
- A as lineConflictKey,
207
- N as lineLabelOf,
208
- K as noteLineReads,
209
- C as resolveLineCollision,
210
- L as rowBaseBookFor,
211
- j as snapshotRowBases,
212
+ K as incrementGuarded,
213
+ C as lineConflictKey,
214
+ j as lineLabelOf,
215
+ L as noteLineReads,
216
+ N as resolveLineCollision,
217
+ O as rowBaseBookFor,
218
+ x as snapshotRowBases,
212
219
  S as withRowBaseRevision,
213
- x as writeLineGuarded
220
+ F as writeLineGuarded
214
221
  };
@@ -0,0 +1,17 @@
1
+ function o(e) {
2
+ var n;
3
+ return e.isDirty || (((n = e.staged) == null ? void 0 : n.total) ?? 0) > 0;
4
+ }
5
+ function i(e) {
6
+ return e.childRefused || (e.lineConflicts ?? 0) > 0 || !!e.reasonWaiting || !!e.chooserOpen;
7
+ }
8
+ function f(e, n) {
9
+ for (const [t, r] of Object.entries(n))
10
+ if (r && e[t] !== r) return { field: t, message: r };
11
+ return null;
12
+ }
13
+ export {
14
+ i as moveBlockedAfterSave,
15
+ f as newFieldError,
16
+ o as unsavedBeforeMove
17
+ };
@@ -1,28 +1,39 @@
1
- import { useState as c, useRef as i, useEffect as s } from "react";
2
- import { matchesAllTokens as a } from "../../lib/utils.js";
3
- function S(t, n, r = 300) {
4
- const [e, o] = c(t), f = i(!1);
1
+ import { useState as i, useRef as l, useEffect as s } from "react";
2
+ import { matchesAllTokens as f } from "../../lib/utils.js";
3
+ function g(t, e, n = 300) {
4
+ const [r, u] = i(t), c = l(!1);
5
5
  return s(() => {
6
- if (t === e) {
7
- f.current = !1;
6
+ if (t === r) {
7
+ c.current = !1;
8
8
  return;
9
9
  }
10
10
  if (!t) {
11
- o("");
11
+ u("");
12
12
  return;
13
13
  }
14
- if (n) {
15
- f.current = !0;
14
+ if (e) {
15
+ c.current = !0;
16
16
  return;
17
17
  }
18
- const u = setTimeout(() => o(t), f.current ? 0 : r);
19
- return () => clearTimeout(u);
20
- }, [t, e, n, r]), e;
18
+ const o = setTimeout(() => u(t), c.current ? 0 : n);
19
+ return () => clearTimeout(o);
20
+ }, [t, r, e, n]), r;
21
21
  }
22
- function T(t, n, r, e) {
23
- return e || !r.trim() ? t : t.filter((o) => a(n(o), r));
22
+ function p(t, e, n, r) {
23
+ return r || !n.trim() ? t : t.filter((u) => f(e(u), n));
24
+ }
25
+ const a = 200;
26
+ function E(t, e, n) {
27
+ const r = n.replace(/[-_/]+/g, " ").trim();
28
+ return !r || t.length >= a ? [] : t.filter((u) => f(e(u), r));
29
+ }
30
+ function S(t) {
31
+ return !!t && t.length > 0 && t.every((e) => e.fuzzy === !0);
24
32
  }
25
33
  export {
26
- T as narrowLocally,
27
- S as useLatestSearch
34
+ a as PICKER_PAGE,
35
+ E as labelOnlyMatches,
36
+ p as narrowLocally,
37
+ S as onlyCloseMatches,
38
+ g as useLatestSearch
28
39
  };
@@ -0,0 +1,8 @@
1
+ const r = 768;
2
+ function o(R) {
3
+ return R > 0 && R < 768;
4
+ }
5
+ export {
6
+ r as NARROW_RECORD_PX,
7
+ o as isNarrowRecordWidth
8
+ };