@nivaro/react 0.2.54 → 0.2.56

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 (151) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +99 -98
  3. package/dist/index.d.ts +367 -2
  4. package/dist/index.js +645 -616
  5. package/dist/layout-editor.d.ts +4 -0
  6. package/dist/shared/components/BackgroundRunOffer.js +117 -0
  7. package/dist/shared/components/BroadcastView.js +214 -213
  8. package/dist/shared/components/CollectionBrowserView.js +2592 -2695
  9. package/dist/shared/components/ItemEditForm.js +4066 -3832
  10. package/dist/shared/components/JobsTray.js +100 -55
  11. package/dist/shared/components/MyWorkView.js +91 -89
  12. package/dist/shared/components/NotificationBell.js +80 -79
  13. package/dist/shared/components/ProfileView.js +568 -520
  14. package/dist/shared/components/RecordCompare.js +254 -0
  15. package/dist/shared/components/RecordReadView.js +599 -552
  16. package/dist/shared/components/ReportView.js +578 -543
  17. package/dist/shared/components/RowPresence.js +91 -0
  18. package/dist/shared/components/WidgetSlot.js +474 -458
  19. package/dist/shared/components/ai/AiAnalyticsView.js +16 -6
  20. package/dist/shared/components/ai/AskPanel.js +139 -119
  21. package/dist/shared/components/ai/FirstWeekCard.js +126 -0
  22. package/dist/shared/components/bulk/BulkFieldUpdate.js +289 -0
  23. package/dist/shared/components/bulk/bulk-field-options.js +45 -0
  24. package/dist/shared/components/charts/CumulativeFlowChart.js +176 -0
  25. package/dist/shared/components/chat/ChannelArchive.js +326 -0
  26. package/dist/shared/components/chat/ChannelExtras.js +141 -121
  27. package/dist/shared/components/chat/ChatAnalyticsView.js +112 -110
  28. package/dist/shared/components/chat/ChatPanel.js +1695 -1733
  29. package/dist/shared/components/chat/Composer.js +357 -303
  30. package/dist/shared/components/chat/MessageActions.js +92 -0
  31. package/dist/shared/components/chat/MessageFormat.js +290 -264
  32. package/dist/shared/components/chat/OutboxBubbles.js +146 -0
  33. package/dist/shared/components/chat/RequestIdCard.js +135 -0
  34. package/dist/shared/components/chat/RoomHeaderMenu.js +202 -0
  35. package/dist/shared/components/chat/RoomParts.js +213 -274
  36. package/dist/shared/components/chat/ScreenClip.js +184 -0
  37. package/dist/shared/components/chat/chat-core.js +402 -483
  38. package/dist/shared/components/chat/chat-drafts.js +59 -0
  39. package/dist/shared/components/chat/chat-emoji.js +348 -0
  40. package/dist/shared/components/chat/chat-local-time.js +41 -0
  41. package/dist/shared/components/chat/chat-outbox.js +303 -0
  42. package/dist/shared/components/chat/chat-window.js +163 -0
  43. package/dist/shared/components/chat/huddle/HuddleControls.js +143 -0
  44. package/dist/shared/components/chat/huddle/HuddleStage.js +164 -0
  45. package/dist/shared/components/chat/huddle/huddle-store.js +342 -0
  46. package/dist/shared/components/chat/huddle/useHuddle.js +58 -0
  47. package/dist/shared/components/help-videos/api.js +76 -73
  48. package/dist/shared/components/item-edit/CatalogPickerField.js +113 -112
  49. package/dist/shared/components/item-edit/ChangeReasonDialog.js +13 -13
  50. package/dist/shared/components/item-edit/FieldAffordances.js +2 -2
  51. package/dist/shared/components/item-edit/FieldRenderer.js +248 -245
  52. package/dist/shared/components/item-edit/FieldRow.js +292 -279
  53. package/dist/shared/components/item-edit/GroupSection.js +698 -574
  54. package/dist/shared/components/item-edit/InlineTableField.js +3 -1
  55. package/dist/shared/components/item-edit/RelationCombobox.js +186 -176
  56. package/dist/shared/components/item-edit/entry/EntryStrip.js +54 -0
  57. package/dist/shared/components/item-edit/entry/entry-keys.js +27 -0
  58. package/dist/shared/components/item-edit/entry/useEntryKeyboard.js +70 -0
  59. package/dist/shared/components/item-edit/entry/useEntryMode.js +59 -0
  60. package/dist/shared/components/item-edit/form-structure-ui.js +105 -0
  61. package/dist/shared/components/item-edit/lazy-sections.js +36 -0
  62. package/dist/shared/components/item-edit/lock-why.js +39 -32
  63. package/dist/shared/components/item-edit/picker-miss.js +26 -0
  64. package/dist/shared/components/item-edit/placement-behaviour.js +196 -0
  65. package/dist/shared/components/item-edit/useFormUsageBeacon.js +51 -45
  66. package/dist/shared/components/layout-editor/AddPanel.js +134 -117
  67. package/dist/shared/components/layout-editor/ChangeNote.js +25 -24
  68. package/dist/shared/components/layout-editor/CollabParts.js +80 -75
  69. package/dist/shared/components/layout-editor/DesignNode.js +126 -120
  70. package/dist/shared/components/layout-editor/EditorCanvas.js +30 -27
  71. package/dist/shared/components/layout-editor/EditorTopBar.js +203 -192
  72. package/dist/shared/components/layout-editor/HistoryPanel.js +120 -104
  73. package/dist/shared/components/layout-editor/LayoutEditor.js +768 -671
  74. package/dist/shared/components/layout-editor/RestorePiece.js +143 -0
  75. package/dist/shared/components/layout-editor/StagedChip.js +22 -0
  76. package/dist/shared/components/layout-editor/StructureMenu.js +237 -186
  77. package/dist/shared/components/layout-editor/collab/FormFollowShare.js +149 -103
  78. package/dist/shared/components/layout-editor/collab/collab-api.js +29 -26
  79. package/dist/shared/components/layout-editor/dnd/LayoutDndProvider.js +81 -80
  80. package/dist/shared/components/layout-editor/dnd/node.js +69 -57
  81. package/dist/shared/components/layout-editor/draft-recovery.js +113 -43
  82. package/dist/shared/components/layout-editor/entry/PlacementPresets.js +149 -0
  83. package/dist/shared/components/layout-editor/entry/entry-editor-context.js +10 -0
  84. package/dist/shared/components/layout-editor/entry/presets.js +71 -0
  85. package/dist/shared/components/layout-editor/entry/tab-order.js +110 -0
  86. package/dist/shared/components/layout-editor/entry/theme-preview.js +37 -0
  87. package/dist/shared/components/layout-editor/grid-guides.js +142 -0
  88. package/dist/shared/components/layout-editor/inspector/BehaviourSettings.js +402 -0
  89. package/dist/shared/components/layout-editor/inspector/BulkInspector.js +61 -57
  90. package/dist/shared/components/layout-editor/inspector/GroupInspector.js +247 -151
  91. package/dist/shared/components/layout-editor/inspector/Inspector.js +176 -155
  92. package/dist/shared/components/layout-editor/inspector/LookTab.js +167 -116
  93. package/dist/shared/components/layout-editor/inspector/PickerMisses.js +129 -0
  94. package/dist/shared/components/layout-editor/inspector/PickerTab.js +84 -82
  95. package/dist/shared/components/layout-editor/inspector/RulesTab.js +66 -62
  96. package/dist/shared/components/layout-editor/inspector/kit.js +69 -68
  97. package/dist/shared/components/layout-editor/outputs/OutputsButton.js +254 -0
  98. package/dist/shared/components/layout-editor/outputs/help-sheet.js +154 -0
  99. package/dist/shared/components/layout-editor/outputs/output-api.js +61 -0
  100. package/dist/shared/components/layout-editor/overview/describe-conditions.js +6 -0
  101. package/dist/shared/components/layout-editor/overview/purpose.js +15 -13
  102. package/dist/shared/components/layout-editor/parity-keys.json.js +1 -1
  103. package/dist/shared/components/layout-editor/restore-piece.js +192 -0
  104. package/dist/shared/components/layout-editor/section-structure.js +241 -0
  105. package/dist/shared/components/layout-editor/settings/EntrySection.js +296 -0
  106. package/dist/shared/components/layout-editor/settings/FormSettings.js +41 -39
  107. package/dist/shared/components/layout-editor/settings/ResolveSettings.js +255 -0
  108. package/dist/shared/components/layout-editor/settings/ToolsSection.js +147 -111
  109. package/dist/shared/components/layout-editor/settings/WhoSection.js +29 -26
  110. package/dist/shared/components/layout-editor/settings/settings-registry.js +114 -17
  111. package/dist/shared/components/layout-editor/staged-api.js +64 -0
  112. package/dist/shared/components/layout-editor/structure-ops.js +81 -77
  113. package/dist/shared/components/layout-editor/testing/TestingPanels.js +65 -60
  114. package/dist/shared/components/layout-editor/testing/testing-model.js +198 -185
  115. package/dist/shared/components/layout-editor/toolbar-kit.js +11 -11
  116. package/dist/shared/components/layout-editor/usage/AbTestSection.js +355 -0
  117. package/dist/shared/components/layout-editor/usage/UsagePanel.js +144 -70
  118. package/dist/shared/components/layout-editor/usage/ab-api.js +86 -0
  119. package/dist/shared/components/layout-editor/usage/suggest-collapse.js +32 -0
  120. package/dist/shared/components/layout-editor/useLayoutDraft.js +25 -24
  121. package/dist/shared/components/notifications/NotificationAnalyticsView.js +148 -77
  122. package/dist/shared/components/panels/ErpFailureBanner.js +18 -17
  123. package/dist/shared/components/panels/ExternalRequestsChip.js +63 -62
  124. package/dist/shared/components/pipeline/PipelineEditorView.js +106 -104
  125. package/dist/shared/components/profile/AgentsPanel.js +479 -0
  126. package/dist/shared/components/queue/QueueWorklist.js +1026 -1040
  127. package/dist/shared/components/support/SupportAnalytics.js +171 -0
  128. package/dist/shared/components/support/SupportView.js +75 -73
  129. package/dist/shared/lib/background-runs.js +150 -0
  130. package/dist/shared/lib/delivery-ack.js +9 -0
  131. package/dist/shared/lib/entry-badge-style.js +13 -0
  132. package/dist/shared/lib/entry-config.js +71 -0
  133. package/dist/shared/lib/form-sections.js +64 -0
  134. package/dist/shared/lib/form-structure.js +99 -0
  135. package/dist/shared/lib/form-usage-beacon.js +101 -52
  136. package/dist/shared/lib/jobs-tray.js +25 -23
  137. package/dist/shared/lib/keyset-pager.js +37 -0
  138. package/dist/shared/lib/layout-ops.js +84 -82
  139. package/dist/shared/lib/layout-resolve.js +113 -0
  140. package/dist/shared/lib/placement-behaviour.js +144 -0
  141. package/dist/shared/lib/prefetch.js +149 -0
  142. package/dist/shared/lib/presence-hooks.js +199 -0
  143. package/dist/shared/lib/record-outbox.js +82 -81
  144. package/dist/shared/lib/replay-socket.js +93 -0
  145. package/dist/shared/lib/request-gate.js +51 -50
  146. package/dist/shared/lib/room-gaps.js +96 -0
  147. package/dist/shared/lib/search-log.js +27 -0
  148. package/dist/shared/lib/socket-realtime.js +101 -80
  149. package/dist/shared/lib/stale-chunk.js +60 -0
  150. package/dist/shared/lib/worker-socket.js +200 -0
  151. package/package.json +1 -1
@@ -0,0 +1,254 @@
1
+ import { jsx as l, jsxs as i } from "react/jsx-runtime";
2
+ import { useQueries as E, useQuery as K } from "@tanstack/react-query";
3
+ import { X as j } from "lucide-react";
4
+ import { useRef as z, useEffect as F, useState as D } from "react";
5
+ import { createPortal as R } from "react-dom";
6
+ import { useNivaroClient as A } from "../context.js";
7
+ import { get as $ } from "../lib/commands.js";
8
+ import { formSections as O } from "../lib/form-sections.js";
9
+ import { cn as L, titleCase as Q } from "../lib/utils.js";
10
+ import { Skeleton as M } from "./ui/skeleton.js";
11
+ function X(n) {
12
+ if (n == null || n === "") return "";
13
+ if (typeof n == "boolean") return n ? "true" : "false";
14
+ if (typeof n == "object")
15
+ try {
16
+ return JSON.stringify(n);
17
+ } catch {
18
+ return String(n);
19
+ }
20
+ const d = String(n).trim(), u = Number(d);
21
+ return d !== "" && Number.isFinite(u) ? String(Math.round(u * 100) / 100) : d;
22
+ }
23
+ function B(n) {
24
+ const { records: d, forms: u, labels: q } = n, p = {
25
+ key: "__fields__",
26
+ label: "Fields",
27
+ fields: n.fallback.map((a) => ({ field: a, label: null }))
28
+ }, b = u.map((a) => a ?? [p]), y = [], N = /* @__PURE__ */ new Map(), k = /* @__PURE__ */ new Set(), g = /* @__PURE__ */ new Map();
29
+ for (const a of b)
30
+ for (const r of a) {
31
+ for (const o of r.fields)
32
+ o.label && !g.has(o.field) && g.set(o.field, o.label);
33
+ const c = r.fields.map((o) => o.field).filter((o) => !k.has(o));
34
+ if (!c.length) continue;
35
+ for (const o of c) k.add(o);
36
+ const m = N.get(r.label);
37
+ if (m) m.fields.push(...c);
38
+ else {
39
+ const o = { key: r.key, label: r.label, fields: c };
40
+ N.set(r.label, o), y.push(o);
41
+ }
42
+ }
43
+ const w = b.map((a) => new Set(a.flatMap((r) => r.fields.map((c) => c.field))));
44
+ return y.map((a) => ({
45
+ key: a.key,
46
+ label: a.label,
47
+ rows: a.fields.flatMap((r) => {
48
+ const c = d.map((f, h) => {
49
+ const v = f ? w[h].has(r) ? r in f ? null : "hidden" : "form" : "record";
50
+ return { absent: v, value: v || !f ? null : f[r] };
51
+ }), m = c.filter((f) => !f.absent);
52
+ if (m.length === 0) return [];
53
+ const o = m.length > 1 && new Set(m.map((f) => X(f.value))).size > 1;
54
+ return [
55
+ {
56
+ field: r,
57
+ label: g.get(r) || q[r] || Q(r),
58
+ cells: c,
59
+ differs: o
60
+ }
61
+ ];
62
+ })
63
+ })).filter((a) => a.rows.length > 0);
64
+ }
65
+ const I = {
66
+ record: "Not available",
67
+ form: "Not on this form",
68
+ hidden: "Not visible to you"
69
+ };
70
+ function te({
71
+ collection: n,
72
+ ids: d,
73
+ fields: u,
74
+ renderValue: q,
75
+ onClose: p
76
+ }) {
77
+ const b = A(), y = E({
78
+ queries: d.map((e) => ({
79
+ queryKey: ["cbv-compare", n, String(e)],
80
+ queryFn: () => b.request($(`/items/${n}/${e}`)).then((t) => t.data ?? null).catch(() => null),
81
+ staleTime: 3e4
82
+ }))
83
+ }), N = E({
84
+ queries: d.map((e) => ({
85
+ queryKey: ["compare-form", n, String(e)],
86
+ queryFn: () => b.request(
87
+ $("/collection-layouts/active", { collection: n, item: String(e) })
88
+ ).then((t) => t.data ?? null).catch(() => null),
89
+ staleTime: 3e4
90
+ }))
91
+ }), k = K({
92
+ queryKey: ["bulk-fields-config", n],
93
+ queryFn: () => b.request(
94
+ $(`/field-config/${n}`)
95
+ ).then((e) => Array.isArray(e.data) ? e.data : []),
96
+ staleTime: 6e4
97
+ }), g = z(null);
98
+ F(() => {
99
+ var t;
100
+ const e = document.activeElement;
101
+ return (t = g.current) == null || t.focus(), () => {
102
+ var s;
103
+ return (s = e == null ? void 0 : e.focus) == null ? void 0 : s.call(e);
104
+ };
105
+ }, []), F(() => {
106
+ const e = (t) => {
107
+ t.key === "Escape" && p();
108
+ };
109
+ return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
110
+ }, [p]);
111
+ const w = y.some((e) => e.isLoading) || N.some((e) => e.isLoading), a = y.map((e) => e.data ?? null), r = N.map((e) => e.data ?? null), c = {};
112
+ for (const e of k.data ?? []) c[e.field] = e.label;
113
+ const m = w ? [] : B({
114
+ records: a,
115
+ forms: r.map(
116
+ (e) => e ? O(e.groups ?? [], e.assignments ?? [], {
117
+ ungroupedSort: e.ungrouped_sort
118
+ }) : null
119
+ ),
120
+ labels: c,
121
+ fallback: u.filter((e) => !e.hidden && e.field !== "id").map((e) => e.field)
122
+ }), [o, f] = D(!1), h = m.reduce((e, t) => e + t.rows.filter((s) => s.differs).length, 0), v = o ? m.map((e) => ({ ...e, rows: e.rows.filter((t) => t.differs) })).filter((e) => e.rows.length > 0) : m, S = r.map((e) => {
123
+ var t;
124
+ return ((t = e == null ? void 0 : e.layout) == null ? void 0 : t.name) ?? null;
125
+ }), C = new Set(r.map((e) => {
126
+ var t;
127
+ return ((t = e == null ? void 0 : e.layout) == null ? void 0 : t.id) ?? null;
128
+ })).size === 1, T = { gridTemplateColumns: `minmax(160px, 220px) repeat(${d.length}, minmax(0, 1fr))` };
129
+ return R(
130
+ // biome-ignore lint/a11y/noStaticElementInteractions: backdrop click closes; Escape is the keyboard path
131
+ /* @__PURE__ */ l(
132
+ "div",
133
+ {
134
+ className: "fixed inset-0 z-[130] flex items-center justify-center bg-black/40 p-4 sm:p-6",
135
+ onMouseDown: (e) => e.target === e.currentTarget && p(),
136
+ "data-record-compare": !0,
137
+ children: /* @__PURE__ */ i(
138
+ "div",
139
+ {
140
+ ref: g,
141
+ role: "dialog",
142
+ "aria-modal": "true",
143
+ "aria-label": `Compare ${d.length} records`,
144
+ tabIndex: -1,
145
+ className: "nvr-pop-in flex outline-none max-h-[88vh] w-full max-w-[1100px] flex-col overflow-hidden rounded-lg border border-border bg-card shadow-xl",
146
+ children: [
147
+ /* @__PURE__ */ i("div", { className: "flex shrink-0 flex-wrap items-center gap-x-3 gap-y-1 border-b border-border px-4 py-2.5", children: [
148
+ /* @__PURE__ */ i("span", { className: "text-[14px] font-semibold text-foreground", children: [
149
+ "Compare ",
150
+ d.length,
151
+ " records"
152
+ ] }),
153
+ !w && /* @__PURE__ */ i("span", { className: "text-[12px] text-muted-foreground", "data-compare-diff-count": h, children: [
154
+ h === 0 ? "No differences" : `${h} field${h === 1 ? "" : "s"} differ`,
155
+ C && S[0] ? ` · ${S[0]} form` : ""
156
+ ] }),
157
+ /* @__PURE__ */ i("label", { className: "ml-auto flex cursor-pointer items-center gap-1.5 text-[12px] text-muted-foreground", children: [
158
+ /* @__PURE__ */ l(
159
+ "input",
160
+ {
161
+ type: "checkbox",
162
+ checked: o,
163
+ onChange: (e) => f(e.target.checked),
164
+ className: "h-3.5 w-3.5 accent-[hsl(var(--primary))]"
165
+ }
166
+ ),
167
+ "Differences only"
168
+ ] }),
169
+ /* @__PURE__ */ l(
170
+ "button",
171
+ {
172
+ type: "button",
173
+ onClick: p,
174
+ "aria-label": "Close",
175
+ className: "rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan",
176
+ children: /* @__PURE__ */ l(j, { className: "h-4 w-4" })
177
+ }
178
+ )
179
+ ] }),
180
+ /* @__PURE__ */ i("div", { className: "min-h-0 flex-1 overflow-auto", children: [
181
+ /* @__PURE__ */ i(
182
+ "div",
183
+ {
184
+ className: "sticky top-0 z-[1] grid border-b border-border bg-slate-50 dark:bg-background",
185
+ style: T,
186
+ children: [
187
+ /* @__PURE__ */ l("span", { className: "px-3 py-2 text-[11.5px] font-medium text-muted-foreground", children: "Field" }),
188
+ d.map((e, t) => /* @__PURE__ */ i("span", { className: "min-w-0 px-3 py-2", children: [
189
+ /* @__PURE__ */ i("span", { className: "block truncate font-mono text-[12px] font-medium text-foreground", children: [
190
+ "#",
191
+ String(e)
192
+ ] }),
193
+ !C && /* @__PURE__ */ l("span", { className: "block truncate text-[11px] text-muted-foreground", children: S[t] ? `${S[t]} form` : "No form" })
194
+ ] }, String(e)))
195
+ ]
196
+ }
197
+ ),
198
+ w ? /* @__PURE__ */ l("div", { className: "space-y-2 p-4", "aria-busy": "true", children: [0, 1, 2, 3, 4].map((e) => /* @__PURE__ */ i("div", { className: "grid gap-3", style: T, children: [
199
+ /* @__PURE__ */ l(M, { className: "h-4 w-28" }),
200
+ d.map((t) => /* @__PURE__ */ l(M, { className: "h-4 w-full" }, String(t)))
201
+ ] }, e)) }) : a.every((e) => e == null) ? /* @__PURE__ */ l("p", { className: "px-4 py-8 text-center text-[12.5px] text-muted-foreground", children: "These records could not be opened. They may have been deleted, or you may no longer have access." }) : v.length === 0 ? /* @__PURE__ */ l("p", { className: "px-4 py-8 text-center text-[12.5px] text-muted-foreground", children: o ? "Every field you can see holds the same value." : "Nothing to compare." }) : v.map((e) => {
202
+ const t = e.rows.filter((s) => s.differs).length;
203
+ return /* @__PURE__ */ i("section", { "data-compare-section": e.key, children: [
204
+ /* @__PURE__ */ i("h3", { className: "flex items-baseline gap-2 border-b border-border bg-card px-3 pb-1.5 pt-4 text-[12.5px] font-semibold text-foreground", children: [
205
+ e.label,
206
+ t > 0 && /* @__PURE__ */ i("span", { className: "text-[11.5px] font-normal text-muted-foreground", children: [
207
+ t,
208
+ " differ",
209
+ t === 1 ? "s" : ""
210
+ ] })
211
+ ] }),
212
+ e.rows.map((s) => /* @__PURE__ */ i(
213
+ "div",
214
+ {
215
+ "data-compare-row": s.field,
216
+ "data-differs": s.differs ? "" : void 0,
217
+ className: L(
218
+ "grid border-b border-slate-100 text-[12.5px] dark:border-border/60",
219
+ s.differs && "bg-amber-50 dark:bg-amber-400/10"
220
+ ),
221
+ style: T,
222
+ children: [
223
+ /* @__PURE__ */ l("span", { className: "min-w-0 px-3 py-1.5 text-muted-foreground", children: s.label }),
224
+ s.cells.map((x, _) => /* @__PURE__ */ l(
225
+ "span",
226
+ {
227
+ className: L(
228
+ "min-w-0 break-words px-3 py-1.5 tabular-nums",
229
+ x.absent ? "text-[11.5px] italic text-muted-foreground" : s.differs ? "font-medium text-foreground" : "text-slate-600 dark:text-slate-300"
230
+ ),
231
+ children: x.absent ? I[x.absent] : x.value == null || x.value === "" ? /* @__PURE__ */ l("span", { className: "text-muted-foreground", children: "—" }) : q(s.field, x.value)
232
+ },
233
+ _
234
+ ))
235
+ ]
236
+ },
237
+ s.field
238
+ ))
239
+ ] }, e.key);
240
+ })
241
+ ] })
242
+ ]
243
+ }
244
+ )
245
+ }
246
+ ),
247
+ document.body
248
+ );
249
+ }
250
+ export {
251
+ te as RecordCompareDialog,
252
+ B as buildCompare,
253
+ X as compareKey
254
+ };