@nivaro/react 0.3.23 → 0.3.25

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 (28) hide show
  1. package/dist/hooks/useSessionRecorder.js +1 -1
  2. package/dist/index.d.ts +50 -26
  3. package/dist/shared/components/FilePreviewLightbox.js +56 -35
  4. package/dist/shared/components/ItemEditForm.js +4309 -4263
  5. package/dist/shared/components/PageRenderer.js +63 -62
  6. package/dist/shared/components/ProfileView.js +555 -520
  7. package/dist/shared/components/RecordReadView.js +229 -229
  8. package/dist/shared/components/ReportView.js +123 -120
  9. package/dist/shared/components/ai/AiMarkdown.js +168 -148
  10. package/dist/shared/components/chat/RoomParts.js +120 -119
  11. package/dist/shared/components/chat/chat-core.js +228 -224
  12. package/dist/shared/components/item-edit/FieldRenderer.js +333 -333
  13. package/dist/shared/components/item-edit/FieldRow.js +413 -394
  14. package/dist/shared/components/item-edit/GroupSection.js +637 -635
  15. package/dist/shared/components/item-edit/InlineGridField.js +89 -90
  16. package/dist/shared/components/item-edit/QuickPicker.js +9 -9
  17. package/dist/shared/components/item-edit/RawEditSheet.js +80 -79
  18. package/dist/shared/components/item-edit/RowMatchPanel.js +1 -1
  19. package/dist/shared/components/item-edit/m2m-invalidate.js +19 -0
  20. package/dist/shared/components/item-edit/record-lookups.js +15 -0
  21. package/dist/shared/components/item-edit/render-stability.js +147 -0
  22. package/dist/shared/components/layout-editor/FormMapButton.js +5 -4
  23. package/dist/shared/components/notifications/DeliveryChips.js +27 -17
  24. package/dist/shared/components/profile/TeamsConnect.js +71 -0
  25. package/dist/shared/components/profile/primitives.js +4 -4
  26. package/dist/shared/lib/safe-href.js +10 -0
  27. package/dist/shared/lib/socket-realtime.js +107 -78
  28. package/package.json +6 -6
@@ -1,51 +1,52 @@
1
- import { jsx as l, jsxs as u } from "react/jsx-runtime";
2
- import { useQueryClient as V, useQuery as K } from "@tanstack/react-query";
3
- import { Wrench as X, ShieldAlert as Y, Loader2 as Q } from "lucide-react";
4
- import { useState as w, useMemo as U } from "react";
5
- import { toast as T } from "sonner";
1
+ import { jsx as l, jsxs as f } from "react/jsx-runtime";
2
+ import { useQueryClient as V, useQuery as U } from "@tanstack/react-query";
3
+ import { Wrench as X, ShieldAlert as Y, Loader2 as F } from "lucide-react";
4
+ import { useState as w, useMemo as K } from "react";
5
+ import { toast as Q } from "sonner";
6
6
  import { useNivaroClient as Z } from "../../context.js";
7
7
  import { get as C, patch as I, del as ee, post as te } from "../../lib/commands.js";
8
- import { titleCase as W } from "../../lib/utils.js";
9
- import { Button as A } from "../ui/button.js";
10
- import { Sheet as ne, SheetContent as ae, SheetHeader as se, SheetTitle as re } from "../ui/sheet.js";
8
+ import { titleCase as T } from "../../lib/utils.js";
9
+ import { Button as W } from "../ui/button.js";
10
+ import { Sheet as ne, SheetContent as ae, SheetHeader as re, SheetTitle as se } from "../ui/sheet.js";
11
11
  import { ChangeReasonDialog as ie, changeReasonChallenge as le } from "./ChangeReasonDialog.js";
12
12
  import { FieldRenderer as oe } from "./FieldRenderer.js";
13
13
  import { M2MCombobox as ce, m2aWriteMeta as de } from "./M2MCombobox.js";
14
14
  import { M2MStagingContext as me } from "./M2MStagingContext.js";
15
- function E(a, i) {
16
- const f = (p) => p == null || p === "";
17
- return f(a) && f(i) ? !0 : typeof a == "number" || typeof i == "number" ? Number(a) === Number(i) : typeof a == "boolean" || typeof i == "boolean" ? String(a) === String(i) : typeof a == "object" || typeof i == "object" ? JSON.stringify(a) === JSON.stringify(i) : String(a) === String(i);
15
+ import { invalidateM2MFor as fe } from "./m2m-invalidate.js";
16
+ function A(a, i) {
17
+ const u = (p) => p == null || p === "";
18
+ return u(a) && u(i) ? !0 : typeof a == "number" || typeof i == "number" ? Number(a) === Number(i) : typeof a == "boolean" || typeof i == "boolean" ? String(a) === String(i) : typeof a == "object" || typeof i == "object" ? JSON.stringify(a) === JSON.stringify(i) : String(a) === String(i);
18
19
  }
19
- function F(a) {
20
+ function E(a) {
20
21
  if (a == null || a === "") return "∅";
21
22
  const i = typeof a == "object" ? JSON.stringify(a) : String(a);
22
23
  return i.length > 60 ? `${i.slice(0, 57)}…` : i;
23
24
  }
24
- function Me({
25
+ function qe({
25
26
  collection: a,
26
27
  itemId: i,
27
- open: f,
28
+ open: u,
28
29
  onClose: p,
29
30
  onSaved: S
30
31
  }) {
31
- const h = Z(), _ = V(), [m, M] = w({}), [g, v] = w(/* @__PURE__ */ new Map()), [y, N] = w(/* @__PURE__ */ new Map()), [k, L] = w(!1), [J, j] = w(null), { data: c } = K({
32
+ const h = Z(), M = V(), [m, _] = w({}), [g, v] = w(/* @__PURE__ */ new Map()), [x, N] = w(/* @__PURE__ */ new Map()), [k, L] = w(!1), [J, j] = w(null), { data: c } = U({
32
33
  queryKey: ["raw-edit-config", a],
33
34
  queryFn: async () => {
34
- const [e, s] = await Promise.all([
35
- h.request(C(`/field-config/${a}`)).then((r) => r.data ?? []),
36
- h.request(C(`/collections/${a}`)).then((r) => r.data)
35
+ const [e, r] = await Promise.all([
36
+ h.request(C(`/field-config/${a}`)).then((s) => s.data ?? []),
37
+ h.request(C(`/collections/${a}`)).then((s) => s.data)
37
38
  ]);
38
- return { fields: e, relations: s.relations ?? [] };
39
+ return { fields: e, relations: r.relations ?? [] };
39
40
  },
40
- enabled: f,
41
+ enabled: u,
41
42
  staleTime: 6e4
42
- }), { data: o, isLoading: P } = K({
43
+ }), { data: o, isLoading: P } = U({
43
44
  queryKey: ["raw-edit-record", a, i],
44
45
  queryFn: () => h.request(C(`/items/${a}/${i}`)).then((e) => e.data),
45
- enabled: f,
46
+ enabled: u,
46
47
  staleTime: 0
47
- }), D = U(() => {
48
- const e = (c == null ? void 0 : c.fields) ?? [], s = (c == null ? void 0 : c.relations) ?? [], r = (t) => s.some((n) => n.one_collection === a && n.one_field === t.field);
48
+ }), D = K(() => {
49
+ const e = (c == null ? void 0 : c.fields) ?? [], r = (c == null ? void 0 : c.relations) ?? [], s = (t) => r.some((n) => n.one_collection === a && n.one_field === t.field);
49
50
  return e.filter((t) => !t.field.startsWith("__")).map((t) => ({
50
51
  // Strip every conditional/curation config — raw mode ignores them all
51
52
  field: {
@@ -56,64 +57,64 @@ function Me({
56
57
  lock_condition: null,
57
58
  dependency_config: null
58
59
  },
59
- alias: r(t),
60
- m2mRel: s.find(
60
+ alias: s(t),
61
+ m2mRel: r.find(
61
62
  (n) => n.one_collection === a && n.one_field === t.field && n.junction_field != null
62
63
  )
63
64
  })).sort((t, n) => (t.field.sort ?? 0) - (n.field.sort ?? 0));
64
65
  }, [c, a]), q = (c == null ? void 0 : c.relations) ?? [], O = (e) => q.find(
65
- (s) => s.one_collection === a && s.one_field === e && s.junction_field != null
66
- ), B = U(
66
+ (r) => r.one_collection === a && r.one_field === e && r.junction_field != null
67
+ ), B = K(
67
68
  () => ({
68
69
  getStagedLinks: (e) => g.get(e) ?? [],
69
- getStagedUnlinks: (e) => y.get(e) ?? /* @__PURE__ */ new Set(),
70
- stageLink: (e, s) => v((r) => {
71
- const t = new Map(r);
72
- return t.set(e, [...t.get(e) ?? [], s]), t;
70
+ getStagedUnlinks: (e) => x.get(e) ?? /* @__PURE__ */ new Set(),
71
+ stageLink: (e, r) => v((s) => {
72
+ const t = new Map(s);
73
+ return t.set(e, [...t.get(e) ?? [], r]), t;
73
74
  }),
74
- unstageLink: (e, s) => v((r) => {
75
- const t = new Map(r);
75
+ unstageLink: (e, r) => v((s) => {
76
+ const t = new Map(s);
76
77
  return t.set(
77
78
  e,
78
- (t.get(e) ?? []).filter((n) => String(n) !== String(s))
79
+ (t.get(e) ?? []).filter((n) => String(n) !== String(r))
79
80
  ), t;
80
81
  }),
81
- stageUnlink: (e, s) => N((r) => {
82
- const t = new Map(r), n = new Set(t.get(e) ?? []);
83
- return n.add(s), t.set(e, n), t;
82
+ stageUnlink: (e, r) => N((s) => {
83
+ const t = new Map(s), n = new Set(t.get(e) ?? []);
84
+ return n.add(r), t.set(e, n), t;
84
85
  }),
85
- unstageUnlink: (e, s) => N((r) => {
86
- const t = new Map(r), n = new Set(t.get(e) ?? []);
87
- return n.delete(s), t.set(e, n), t;
86
+ unstageUnlink: (e, r) => N((s) => {
87
+ const t = new Map(s), n = new Set(t.get(e) ?? []);
88
+ return n.delete(r), t.set(e, n), t;
88
89
  })
89
90
  }),
90
- [g, y]
91
- ), H = [...g.values()].some((e) => e.length > 0) || [...y.values()].some((e) => e.size > 0), R = Object.keys(m).length > 0 || H, z = async (e) => {
92
- var s;
91
+ [g, x]
92
+ ), H = [...g.values()].some((e) => e.length > 0) || [...x.values()].some((e) => e.size > 0), R = Object.keys(m).length > 0 || H, z = async (e) => {
93
+ var r;
93
94
  L(!0);
94
95
  try {
95
96
  if (Object.keys(m).length > 0) {
96
97
  const t = { ...m };
97
98
  e && (t._change_reason = e), await h.request(I(`/items/${a}/${i}`, t));
98
99
  }
99
- const r = [];
100
- for (const [t, n] of y.entries()) {
100
+ const s = [];
101
+ for (const [t, n] of x.entries()) {
101
102
  if (!n.size) continue;
102
103
  const d = O(t);
103
104
  if (d)
104
- for (const x of n)
105
- r.push(h.request(ee(`/items/${d.many_collection}/${x}`)).catch(() => {
105
+ for (const y of n)
106
+ s.push(h.request(ee(`/items/${d.many_collection}/${y}`)).catch(() => {
106
107
  }));
107
108
  }
108
109
  for (const [t, n] of g.entries()) {
109
110
  if (!n.length) continue;
110
111
  const d = O(t);
111
112
  if (!d) continue;
112
- const x = q.find(
113
+ const y = q.find(
113
114
  (b) => b.many_collection === d.many_collection && b.many_field === d.junction_field && b.id !== d.id
114
- ), $ = de(x), G = $ ? { [$.field]: $.value } : {};
115
+ ), $ = de(y), G = $ ? { [$.field]: $.value } : {};
115
116
  for (const b of n)
116
- r.push(
117
+ s.push(
117
118
  h.request(
118
119
  te(`/items/${d.many_collection}`, {
119
120
  [d.many_field ?? ""]: i,
@@ -124,15 +125,15 @@ function Me({
124
125
  })
125
126
  );
126
127
  }
127
- await Promise.all(r), T.success("Raw changes saved"), M({}), v(/* @__PURE__ */ new Map()), N(/* @__PURE__ */ new Map()), _.invalidateQueries({ queryKey: ["item", a, String(i)] }), _.invalidateQueries({ queryKey: ["raw-edit-record", a, i] }), _.invalidateQueries({ queryKey: ["m2m-items"] }), S == null || S(), p();
128
- } catch (r) {
129
- const t = le(r);
128
+ await Promise.all(s), Q.success("Raw changes saved"), _({}), v(/* @__PURE__ */ new Map()), N(/* @__PURE__ */ new Map()), M.invalidateQueries({ queryKey: ["item", a, String(i)] }), M.invalidateQueries({ queryKey: ["raw-edit-record", a, i] }), fe(M, [i]), S == null || S(), p();
129
+ } catch (s) {
130
+ const t = le(s);
130
131
  if (t) {
131
132
  j(t);
132
133
  return;
133
134
  }
134
- const n = r == null ? void 0 : r.response;
135
- T.error(((s = n == null ? void 0 : n.data) == null ? void 0 : s.error) ?? (n == null ? void 0 : n.error) ?? "Save failed");
135
+ const n = s == null ? void 0 : s.response;
136
+ Q.error(((r = n == null ? void 0 : n.data) == null ? void 0 : r.error) ?? (n == null ? void 0 : n.error) ?? "Save failed");
136
137
  } finally {
137
138
  L(!1);
138
139
  }
@@ -140,60 +141,60 @@ function Me({
140
141
  return /* @__PURE__ */ l(
141
142
  ne,
142
143
  {
143
- open: f,
144
+ open: u,
144
145
  onOpenChange: (e) => {
145
- e || k || (M({}), v(/* @__PURE__ */ new Map()), N(/* @__PURE__ */ new Map()), p());
146
+ e || k || (_({}), v(/* @__PURE__ */ new Map()), N(/* @__PURE__ */ new Map()), p());
146
147
  },
147
- children: /* @__PURE__ */ u(
148
+ children: /* @__PURE__ */ f(
148
149
  ae,
149
150
  {
150
151
  side: "right",
151
152
  className: "flex w-[1040px] max-w-[94vw] flex-col p-0 sm:max-w-[94vw]",
152
153
  children: [
153
- /* @__PURE__ */ l(se, { className: "shrink-0 border-b border-slate-200 px-5 py-3 dark:border-border", children: /* @__PURE__ */ u(re, { className: "flex items-center gap-2 text-[14px]", children: [
154
+ /* @__PURE__ */ l(re, { className: "shrink-0 border-b border-slate-200 px-5 py-3 dark:border-border", children: /* @__PURE__ */ f(se, { className: "flex items-center gap-2 text-[14px]", children: [
154
155
  /* @__PURE__ */ l(X, { className: "h-4 w-4 text-nvr-cyan" }),
155
156
  "Raw edit — ",
156
- W(a),
157
+ T(a),
157
158
  " #",
158
159
  i
159
160
  ] }) }),
160
- /* @__PURE__ */ u("p", { className: "flex shrink-0 items-center gap-2 border-b border-amber-200 bg-amber-50 px-5 py-2 text-[12px] text-amber-800 dark:border-amber-500/20 dark:bg-amber-500/10 dark:text-amber-300", children: [
161
+ /* @__PURE__ */ f("p", { className: "flex shrink-0 items-center gap-2 border-b border-amber-200 bg-amber-50 px-5 py-2 text-[12px] text-amber-800 dark:border-amber-500/20 dark:bg-amber-500/10 dark:text-amber-300", children: [
161
162
  /* @__PURE__ */ l(Y, { className: "h-3.5 w-3.5 shrink-0" }),
162
163
  "Admin raw mode — visibility rules, locks, cascades and layout restrictions are bypassed. Server-side validation still applies. Every change is recorded in the revision history."
163
164
  ] }),
164
- /* @__PURE__ */ l("div", { className: "min-h-0 flex-1 overflow-y-auto px-5 py-4", children: P || !c ? /* @__PURE__ */ l("div", { className: "flex justify-center py-10", children: /* @__PURE__ */ l(Q, { className: "h-5 w-5 animate-spin text-slate-400" }) }) : /* @__PURE__ */ l("div", { className: "space-y-3", children: D.map(({ field: e, alias: s, m2mRel: r }) => {
165
- const t = e.field in m ? m[e.field] : o == null ? void 0 : o[e.field], n = e.field in m && !E(m[e.field], o == null ? void 0 : o[e.field]);
166
- return /* @__PURE__ */ u(
165
+ /* @__PURE__ */ l("div", { className: "min-h-0 flex-1 overflow-y-auto px-5 py-4", children: P || !c ? /* @__PURE__ */ l("div", { className: "flex justify-center py-10", children: /* @__PURE__ */ l(F, { className: "h-5 w-5 animate-spin text-slate-400" }) }) : /* @__PURE__ */ l("div", { className: "space-y-3", children: D.map(({ field: e, alias: r, m2mRel: s }) => {
166
+ const t = e.field in m ? m[e.field] : o == null ? void 0 : o[e.field], n = e.field in m && !A(m[e.field], o == null ? void 0 : o[e.field]);
167
+ return /* @__PURE__ */ f(
167
168
  "div",
168
169
  {
169
170
  className: `grid grid-cols-[220px_1fr] items-start gap-3 rounded-md ${n ? "-mx-2 bg-amber-50 px-2 py-1 ring-1 ring-amber-200 dark:bg-amber-400/10 dark:ring-amber-500/30" : ""}`,
170
171
  "data-raw-changed": n ? e.field : void 0,
171
172
  "data-raw-field": e.field,
172
173
  children: [
173
- /* @__PURE__ */ u("div", { className: "pt-1.5", children: [
174
- /* @__PURE__ */ u("p", { className: "text-[12px] font-medium text-slate-700 dark:text-slate-200", children: [
175
- e.label || W(e.field),
174
+ /* @__PURE__ */ f("div", { className: "pt-1.5", children: [
175
+ /* @__PURE__ */ f("p", { className: "text-[12px] font-medium text-slate-700 dark:text-slate-200", children: [
176
+ e.label || T(e.field),
176
177
  n && /* @__PURE__ */ l("span", { className: "ml-1.5 rounded bg-amber-200/70 px-1 text-[9px] font-semibold uppercase tracking-wide text-amber-900 dark:bg-amber-500/20 dark:text-amber-200", children: "changed" })
177
178
  ] }),
178
179
  /* @__PURE__ */ l("p", { className: "font-mono text-[10.5px] text-slate-400", children: e.field }),
179
- n && /* @__PURE__ */ u(
180
+ n && /* @__PURE__ */ f(
180
181
  "p",
181
182
  {
182
183
  className: "mt-0.5 truncate text-[10.5px] text-slate-400",
183
- "data-tip": `Was: ${F(o == null ? void 0 : o[e.field])}`,
184
+ "data-tip": `Was: ${E(o == null ? void 0 : o[e.field])}`,
184
185
  children: [
185
186
  "was ",
186
- F(o == null ? void 0 : o[e.field])
187
+ E(o == null ? void 0 : o[e.field])
187
188
  ]
188
189
  }
189
190
  )
190
191
  ] }),
191
- e.field === "id" ? /* @__PURE__ */ l("p", { className: "pt-1.5 font-mono text-[12px] text-slate-500", children: String(t ?? "") }) : s && r ? /* @__PURE__ */ l(me.Provider, { value: B, children: /* @__PURE__ */ l(ce, { relation: r, parentId: i, allRelations: q }) }) : s ? /* @__PURE__ */ l("p", { className: "pt-1.5 text-[11.5px] italic text-slate-400", children: "Child rows (one-to-many) — edit through the normal form" }) : /* @__PURE__ */ l(
192
+ e.field === "id" ? /* @__PURE__ */ l("p", { className: "pt-1.5 font-mono text-[12px] text-slate-500", children: String(t ?? "") }) : r && s ? /* @__PURE__ */ l(me.Provider, { value: B, children: /* @__PURE__ */ l(ce, { relation: s, parentId: i, allRelations: q }) }) : r ? /* @__PURE__ */ l("p", { className: "pt-1.5 text-[11.5px] italic text-slate-400", children: "Child rows (one-to-many) — edit through the normal form" }) : /* @__PURE__ */ l(
192
193
  oe,
193
194
  {
194
195
  field: e,
195
196
  value: t,
196
- onChange: (d) => M((x) => ({ ...x, [e.field]: d })),
197
+ onChange: (d) => _((y) => ({ ...y, [e.field]: d })),
197
198
  relations: c.relations,
198
199
  collection: a,
199
200
  itemId: i
@@ -204,15 +205,15 @@ function Me({
204
205
  e.field
205
206
  );
206
207
  }) }) }),
207
- /* @__PURE__ */ u("div", { className: "flex shrink-0 items-center justify-between gap-3 border-t border-slate-200 px-5 py-3 dark:border-border", children: [
208
+ /* @__PURE__ */ f("div", { className: "flex shrink-0 items-center justify-between gap-3 border-t border-slate-200 px-5 py-3 dark:border-border", children: [
208
209
  /* @__PURE__ */ l("span", { className: "text-[11.5px] text-slate-400", children: (() => {
209
210
  if (!R) return "No changes yet";
210
- const e = Object.keys(m).filter((s) => !E(m[s], o == null ? void 0 : o[s])).length + [...g.values()].filter((s) => s.length > 0).length + [...y.values()].filter((s) => s.size > 0).length;
211
+ const e = Object.keys(m).filter((r) => !A(m[r], o == null ? void 0 : o[r])).length + [...g.values()].filter((r) => r.length > 0).length + [...x.values()].filter((r) => r.size > 0).length;
211
212
  return e === 0 ? "No changes yet" : `${e} field${e !== 1 ? "s" : ""} changed`;
212
213
  })() }),
213
- /* @__PURE__ */ u("div", { className: "flex gap-2", children: [
214
- /* @__PURE__ */ l(A, { variant: "outline", size: "sm", onClick: p, disabled: k, children: "Cancel" }),
215
- /* @__PURE__ */ l(A, { size: "sm", onClick: () => void z(), disabled: !R || k, children: k ? /* @__PURE__ */ l(Q, { className: "h-3.5 w-3.5 animate-spin" }) : "Save raw changes" })
214
+ /* @__PURE__ */ f("div", { className: "flex gap-2", children: [
215
+ /* @__PURE__ */ l(W, { variant: "outline", size: "sm", onClick: p, disabled: k, children: "Cancel" }),
216
+ /* @__PURE__ */ l(W, { size: "sm", onClick: () => void z(), disabled: !R || k, children: k ? /* @__PURE__ */ l(F, { className: "h-3.5 w-3.5 animate-spin" }) : "Save raw changes" })
216
217
  ] })
217
218
  ] }),
218
219
  /* @__PURE__ */ l(
@@ -232,5 +233,5 @@ function Me({
232
233
  );
233
234
  }
234
235
  export {
235
- Me as RawEditSheet
236
+ qe as RawEditSheet
236
237
  };
@@ -5,7 +5,7 @@ import { useMemo as O } from "react";
5
5
  import { get as V } from "../../lib/commands.js";
6
6
  import { evaluateNumeric as ee } from "../../lib/expression.js";
7
7
  import { cn as W } from "../../lib/utils.js";
8
- import "../../lib/field-interfaces.js";
8
+ import "./FieldRenderer.js";
9
9
  import { resolveOptionFilterTokens as te } from "../../lib/option-filter-tokens.js";
10
10
  const U = (t, e) => e.split(".").reduce(
11
11
  (a, s) => a && typeof a == "object" ? a[s] : void 0,
@@ -0,0 +1,19 @@
1
+ function r(t, i) {
2
+ const o = /* @__PURE__ */ new Set();
3
+ for (const e of i) o.add(String(e));
4
+ const n = (e) => e.length > 3 && o.has(String(e[3]));
5
+ t.invalidateQueries({ queryKey: ["m2m-items"], predicate: (e) => n(e.queryKey) }), t.invalidateQueries({
6
+ queryKey: ["m2m-items"],
7
+ predicate: (e) => !n(e.queryKey),
8
+ refetchType: "none"
9
+ });
10
+ }
11
+ function s(t) {
12
+ const i = [];
13
+ for (const o of t.values()) for (const n of o.keys()) i.push(String(n));
14
+ return i;
15
+ }
16
+ export {
17
+ s as editedRowIds,
18
+ r as invalidateM2MFor
19
+ };
@@ -0,0 +1,15 @@
1
+ const t = /* @__PURE__ */ new Map();
2
+ function r(o, e) {
3
+ if (t.delete(o), t.set(o, { role: e.role, state: e.state }), t.size > 200) {
4
+ const s = t.keys().next().value;
5
+ s !== void 0 && t.delete(s);
6
+ }
7
+ }
8
+ function n(o) {
9
+ const e = t.get(o);
10
+ return e && (e.role || e.state) ? e : null;
11
+ }
12
+ export {
13
+ n as recordLookupsFor,
14
+ r as rememberRecordLookups
15
+ };
@@ -0,0 +1,147 @@
1
+ import { useRef as S, useLayoutEffect as v, useMemo as a } from "react";
2
+ function C(e, t) {
3
+ if (Object.is(e, t)) return !0;
4
+ if (e == null || t == null || typeof e != "object" || typeof t != "object") return !1;
5
+ try {
6
+ return JSON.stringify(e) === JSON.stringify(t);
7
+ } catch {
8
+ return !1;
9
+ }
10
+ }
11
+ function E(e, t) {
12
+ if (Object.is(e, t)) return !0;
13
+ if (!e || !t) return !1;
14
+ const n = Object.keys(e);
15
+ if (n.length !== Object.keys(t).length) return !1;
16
+ for (const o of n) if (!Object.hasOwn(t, o) || !Object.is(e[o], t[o])) return !1;
17
+ return !0;
18
+ }
19
+ function b(e, t, n) {
20
+ const o = e.current;
21
+ return o !== void 0 && n(o, t) ? o : (e.current = t, t);
22
+ }
23
+ function j(e, t) {
24
+ const n = S(void 0);
25
+ return b(n, e, t);
26
+ }
27
+ function L(e, t) {
28
+ const n = Object.keys(e);
29
+ if (n.length !== Object.keys(t).length) return !1;
30
+ for (const o of n) {
31
+ const s = e[o], r = t[o];
32
+ if (!r || s.label !== r.label || s.count !== r.count) return !1;
33
+ }
34
+ return !0;
35
+ }
36
+ function T(e) {
37
+ const t = S(e);
38
+ v(() => {
39
+ t.current = e;
40
+ });
41
+ const n = a(
42
+ () => ({
43
+ dismissRemoteChange: (c) => t.current.dismissRemoteChange(c),
44
+ takeRemoteChange: (c) => {
45
+ var u, f;
46
+ return (f = (u = t.current).takeRemoteChange) == null ? void 0 : f.call(u, c);
47
+ },
48
+ onLockHover: () => {
49
+ var c, u;
50
+ return (u = (c = t.current).onLockHover) == null ? void 0 : u.call(c);
51
+ },
52
+ openRelated: (c, u) => {
53
+ var f, i;
54
+ return (i = (f = t.current).openRelated) == null ? void 0 : i.call(f, c, u);
55
+ }
56
+ }),
57
+ []
58
+ ), o = j(e.lockReasons, E), s = j(e.applyToLines, L), r = a(() => {
59
+ const c = {};
60
+ for (const [u, f] of Object.entries(s))
61
+ c[u] = {
62
+ ...f,
63
+ onApply: (i) => {
64
+ var d;
65
+ return (d = t.current.applyToLines[u]) == null ? void 0 : d.onApply(i);
66
+ }
67
+ };
68
+ return c;
69
+ }, [s]), l = !!e.takeRemoteChange, p = !!e.onLockHover, y = !!e.openRelated, { remoteChanges: h, layoutId: g, pickerMisses: k, fromAutofill: O, glossaryHelp: R, placementText: m } = e;
70
+ return a(
71
+ () => ({
72
+ remoteChanges: h,
73
+ dismissRemoteChange: n.dismissRemoteChange,
74
+ takeRemoteChange: l ? n.takeRemoteChange : void 0,
75
+ lockReasons: o,
76
+ onLockHover: p ? n.onLockHover : void 0,
77
+ applyToLines: r,
78
+ openRelated: y ? n.openRelated : void 0,
79
+ layoutId: g,
80
+ pickerMisses: k,
81
+ fromAutofill: O,
82
+ glossaryHelp: R,
83
+ placementText: m
84
+ }),
85
+ [
86
+ h,
87
+ n,
88
+ l,
89
+ o,
90
+ p,
91
+ r,
92
+ y,
93
+ g,
94
+ k,
95
+ O,
96
+ R,
97
+ m
98
+ ]
99
+ );
100
+ }
101
+ function q(e, t) {
102
+ if (e.size !== t.size) return !1;
103
+ for (const n of e) if (!t.has(n)) return !1;
104
+ return !0;
105
+ }
106
+ function A(e, t) {
107
+ if (e.length !== t.length) return !1;
108
+ for (let n = 0; n < e.length; n++) if (!Object.is(e[n], t[n])) return !1;
109
+ return !0;
110
+ }
111
+ const P = /* @__PURE__ */ new Set(["summaryFields", "swapConfig", "alternateWidths"]), w = /* @__PURE__ */ new Set(["onToggle", "onSwapToggle"]);
112
+ function N(e, t) {
113
+ const n = Object.keys(e);
114
+ if (n.length !== Object.keys(t).length) return !1;
115
+ for (const o of n) {
116
+ if (!Object.hasOwn(t, o)) return !1;
117
+ const s = e[o], r = t[o];
118
+ if (!Object.is(s, r)) {
119
+ if (w.has(o)) {
120
+ if (typeof s == "function" && typeof r == "function") continue;
121
+ return !1;
122
+ }
123
+ if (P.has(o)) {
124
+ if (C(s, r)) continue;
125
+ return !1;
126
+ }
127
+ if (s instanceof Set && r instanceof Set) {
128
+ if (q(s, r)) continue;
129
+ return !1;
130
+ }
131
+ if (Array.isArray(s) && Array.isArray(r)) {
132
+ if (A(s, r)) continue;
133
+ return !1;
134
+ }
135
+ return !1;
136
+ }
137
+ }
138
+ return !0;
139
+ }
140
+ export {
141
+ N as groupSectionPropsEqual,
142
+ C as jsonEqual,
143
+ b as keepIfEqual,
144
+ E as shallowRecordEqual,
145
+ j as useKeepIfEqual,
146
+ T as useStableFieldAffordances
147
+ };
@@ -55,9 +55,9 @@ function H({
55
55
  collection: i,
56
56
  onClose: c
57
57
  }) {
58
- const a = L(i), l = j(i), d = B(!0), t = a.data, n = l.data ?? [], s = d.data ?? [], p = a.isError || l.isError || d.isError, k = () => {
58
+ const a = L(i), l = j(i), d = B(!0), t = a.data, n = l.data ?? [], s = d.data ?? [], p = a.isError || l.isError || d.isError, w = () => {
59
59
  a.isError && a.refetch(), l.isError && l.refetch(), d.isError && d.refetch();
60
- }, u = f(null), h = f(null), w = F(() => {
60
+ }, u = f(null), h = f(null), k = F(() => {
61
61
  const r = D({
62
62
  bundle: o,
63
63
  collectionLabel: (t == null ? void 0 : t.label) || i,
@@ -119,14 +119,15 @@ function H({
119
119
  }
120
120
  )
121
121
  ] }),
122
- /* @__PURE__ */ e("div", { className: "min-h-0 flex-1 overflow-hidden p-4 sm:p-6", children: p ? /* @__PURE__ */ e("div", { className: "mx-auto max-w-[900px] rounded-md border border-slate-200 bg-white p-4 dark:border-border dark:bg-card", children: /* @__PURE__ */ e(R, { what: "the field labels and roles for the map", onRetry: k }) }) : (
122
+ /* @__PURE__ */ e("div", { className: "min-h-0 flex-1 overflow-hidden p-4 sm:p-6", children: p ? /* @__PURE__ */ e("div", { className: "mx-auto max-w-[900px] rounded-md border border-slate-200 bg-white p-4 dark:border-border dark:bg-card", children: /* @__PURE__ */ e(R, { what: "the field labels and roles for the map", onRetry: w }) }) : (
123
123
  // The page itself is always light: it is paper.
124
124
  /* @__PURE__ */ e(
125
125
  "iframe",
126
126
  {
127
127
  ref: u,
128
128
  title: "Form map preview",
129
- srcDoc: w,
129
+ srcDoc: k,
130
+ sandbox: "allow-same-origin allow-modals",
130
131
  "data-form-map-frame": "",
131
132
  className: "mx-auto block h-full w-full max-w-[900px] rounded-md border border-slate-300 bg-white shadow-lg dark:border-border"
132
133
  }
@@ -1,17 +1,17 @@
1
1
  import { jsx as m, jsxs as f, Fragment as h } from "react/jsx-runtime";
2
- import { Inbox as b, Bell as u, Mail as k, MessageSquare as x } from "lucide-react";
3
- const y = {
2
+ import { Inbox as b, Bell as u, Mail as k, Users as x, MessageSquare as y } from "lucide-react";
3
+ const g = {
4
4
  ok: "text-emerald-700 dark:text-emerald-400",
5
5
  muted: "text-slate-400 dark:text-slate-500",
6
6
  warn: "text-amber-700 dark:text-amber-400",
7
7
  bad: "text-red-600 dark:text-red-400"
8
8
  };
9
- function $(i) {
10
- return c(i);
9
+ function S(n) {
10
+ return c(n);
11
11
  }
12
- function c(i) {
13
- var o, a, r, n;
14
- const e = i ?? { inapp: { status: "delivered" } }, s = [], l = ((o = e.inapp) == null ? void 0 : o.status) ?? "delivered";
12
+ function c(n) {
13
+ var o, a, r, i;
14
+ const e = n ?? { inapp: { status: "delivered" } }, s = [], l = ((o = e.inapp) == null ? void 0 : o.status) ?? "delivered";
15
15
  if (s.push({
16
16
  key: "inapp",
17
17
  icon: b,
@@ -39,41 +39,51 @@ function c(i) {
39
39
  mailLogId: e.email.mail_log_id ?? null
40
40
  });
41
41
  }
42
- return ((r = e.escalation) != null && r.email_at || (n = e.escalation) != null && n.push_at) && s.push({
42
+ if (((r = e.escalation) != null && r.email_at || (i = e.escalation) != null && i.push_at) && s.push({
43
43
  key: "escalation",
44
44
  icon: u,
45
45
  label: e.escalation.email_at ? "Escalated · email" : "Escalated · push",
46
46
  tone: "warn",
47
47
  tip: `Still unread, so it climbed channels${e.escalation.push_at ? ` · pushed ${new Date(e.escalation.push_at).toLocaleString()}` : ""}${e.escalation.email_at ? ` · emailed ${new Date(e.escalation.email_at).toLocaleString()}` : ""}`,
48
48
  mailLogId: e.escalation.email_log_id ?? null
49
- }), e.sms && e.sms.status !== "not_requested" && s.push({
49
+ }), e.teams) {
50
+ const t = e.teams.status;
51
+ s.push({
52
+ key: "teams",
53
+ icon: x,
54
+ label: t === "sent" ? "Teams" : `Teams · ${t.replace(/_/g, " ")}`,
55
+ tone: t === "sent" ? "ok" : t === "failed" ? "bad" : "muted",
56
+ tip: t === "sent" ? "Sent in Microsoft Teams" : t === "not_connected" ? "Teams not connected" : e.teams.reason ?? `Teams ${t}`
57
+ });
58
+ }
59
+ return e.sms && e.sms.status !== "not_requested" && s.push({
50
60
  key: "sms",
51
- icon: x,
61
+ icon: y,
52
62
  label: "SMS",
53
63
  tone: e.sms.status === "sent" ? "ok" : e.sms.status === "failed" ? "bad" : "muted",
54
64
  tip: e.sms.status === "sent" ? "Text sent" : e.sms.reason ?? `SMS ${e.sms.status}`
55
65
  }), s;
56
66
  }
57
- function w({ delivery: i, mailLogUrl: e, onNavigate: s, className: l }) {
58
- const o = c(i);
67
+ function w({ delivery: n, mailLogUrl: e, onNavigate: s, className: l }) {
68
+ const o = c(n);
59
69
  return /* @__PURE__ */ m(
60
70
  "span",
61
71
  {
62
72
  className: `inline-flex flex-wrap items-center gap-1 ${l ?? ""}`,
63
73
  "data-nvr-delivery": !0,
64
74
  children: o.map((a) => {
65
- const r = a.icon, n = a.mailLogId != null && e ? e(a.mailLogId) : null, t = /* @__PURE__ */ f(h, { children: [
75
+ const r = a.icon, i = a.mailLogId != null && e ? e(a.mailLogId) : null, t = /* @__PURE__ */ f(h, { children: [
66
76
  /* @__PURE__ */ m(r, { className: "h-2.5 w-2.5", strokeWidth: 2 }),
67
77
  a.label
68
- ] }), d = `inline-flex items-center gap-0.5 rounded border border-slate-200/70 px-1 py-px text-[9.5px] font-medium leading-none dark:border-border ${y[a.tone]}`;
69
- return n ? /* @__PURE__ */ m(
78
+ ] }), d = `inline-flex items-center gap-0.5 rounded border border-slate-200/70 px-1 py-px text-[9.5px] font-medium leading-none dark:border-border ${g[a.tone]}`;
79
+ return i ? /* @__PURE__ */ m(
70
80
  "button",
71
81
  {
72
82
  type: "button",
73
83
  "data-tip": `${a.tip} · open mail log`,
74
84
  title: a.tip,
75
85
  onClick: (p) => {
76
- p.stopPropagation(), s == null || s(n);
86
+ p.stopPropagation(), s == null || s(i);
77
87
  },
78
88
  className: `${d} underline decoration-dotted underline-offset-2`,
79
89
  children: t
@@ -86,5 +96,5 @@ function w({ delivery: i, mailLogUrl: e, onNavigate: s, className: l }) {
86
96
  }
87
97
  export {
88
98
  w as DeliveryChips,
89
- $ as describeDelivery
99
+ S as describeDelivery
90
100
  };