@nivaro/react 0.2.54 → 0.2.55

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 (150) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +99 -98
  3. package/dist/index.d.ts +339 -2
  4. package/dist/index.js +644 -618
  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/worker-socket.js +200 -0
  150. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  import { jsxs as d, jsx as t, Fragment as J } from "react/jsx-runtime";
2
2
  import { useQuery as R } from "@tanstack/react-query";
3
3
  import { Globe2 as j, ChevronRight as _, ChevronDown as $, Check as G, X as U } from "lucide-react";
4
- import { useContext as f, createContext as P, useState as g, useRef as I, useEffect as E } from "react";
4
+ import { useContext as h, createContext as P, useState as g, useRef as I, useEffect as E } from "react";
5
5
  import { useNivaroClient as K } from "../../../context.js";
6
6
  import { get as M } from "../../../lib/commands.js";
7
7
  import { cn as m } from "../../../lib/utils.js";
@@ -13,18 +13,18 @@ import { useFocusBuffer as x } from "../focus-buffer.js";
13
13
  import { labelText as ae, effectText as q, segOption as re, segTrack as le, inputBase as v, groupTitle as L } from "../panel-style.js";
14
14
  const N = P(null);
15
15
  function se() {
16
- const e = f(N);
16
+ const e = h(N);
17
17
  if (!e) throw new Error("Inspector parts render inside <Inspector>");
18
18
  return e;
19
19
  }
20
20
  const C = P(null);
21
21
  function Oe(e, o) {
22
22
  var n;
23
- const i = f(C), r = (n = i == null ? void 0 : i.pending) == null ? void 0 : n.values;
24
- return r && e in r ? r[e] : o;
23
+ const i = h(C), l = (n = i == null ? void 0 : i.pending) == null ? void 0 : n.values;
24
+ return l && e in l ? l[e] : o;
25
25
  }
26
26
  function oe() {
27
- const e = f(C), o = K(), i = e == null ? void 0 : e.pending, { data: r, isLoading: n } = R({
27
+ const e = h(C), o = K(), i = e == null ? void 0 : e.pending, { data: l, isLoading: n } = R({
28
28
  queryKey: ["layout-editor", "field-impact", e == null ? void 0 : e.collection, e == null ? void 0 : e.field],
29
29
  queryFn: () => o.request(
30
30
  M(`/data-model/${e == null ? void 0 : e.collection}/fields/${encodeURIComponent((e == null ? void 0 : e.field) ?? "")}/impact`)
@@ -34,10 +34,10 @@ function oe() {
34
34
  });
35
35
  if (!e || !i) return null;
36
36
  const a = [
37
- ...new Set((r ?? []).filter((s) => s.source === "layout").map((s) => s.label))
37
+ ...new Set((l ?? []).filter((s) => s.source === "layout").map((s) => s.label))
38
38
  ], c = [
39
- ...new Set((r ?? []).filter((s) => s.source !== "layout").map((s) => s.label))
40
- ], l = a.slice(0, 8);
39
+ ...new Set((l ?? []).filter((s) => s.source !== "layout").map((s) => s.label))
40
+ ], r = a.slice(0, 8);
41
41
  return /* @__PURE__ */ d(
42
42
  "div",
43
43
  {
@@ -56,12 +56,12 @@ function oe() {
56
56
  e.fieldLabel,
57
57
  " is used…"
58
58
  ] }) : /* @__PURE__ */ d("div", { className: "space-y-1 text-[11px]", children: [
59
- l.length > 0 && /* @__PURE__ */ d("p", { children: [
59
+ r.length > 0 && /* @__PURE__ */ d("p", { children: [
60
60
  "Forms of ",
61
61
  e.collectionLabel,
62
62
  ": ",
63
- l.join(", "),
64
- a.length > l.length && ` and ${a.length - l.length} more`
63
+ r.join(", "),
64
+ a.length > r.length && ` and ${a.length - r.length} more`
65
65
  ] }),
66
66
  /* @__PURE__ */ d("p", { children: [
67
67
  "Also the ",
@@ -145,38 +145,38 @@ function ue({
145
145
  k: e,
146
146
  label: o,
147
147
  effect: i,
148
- scope: r = "form",
148
+ scope: l = "form",
149
149
  enforced: n,
150
150
  inline: a,
151
151
  confirmAt: c,
152
- children: l,
152
+ children: r,
153
153
  className: s
154
154
  }) {
155
155
  var p;
156
- const u = f(C);
156
+ const u = h(C);
157
157
  return /* @__PURE__ */ d("div", { "data-setting": e, "data-setting-row": "", className: m("space-y-1.5", s), children: [
158
158
  /* @__PURE__ */ d("div", { className: "flex min-h-5 items-center justify-between gap-3", children: [
159
159
  /* @__PURE__ */ d("span", { className: "flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5", children: [
160
160
  /* @__PURE__ */ t("span", { className: ae, children: o }),
161
- /* @__PURE__ */ t(ie, { scope: r })
161
+ /* @__PURE__ */ t(ie, { scope: l })
162
162
  ] }),
163
- a && /* @__PURE__ */ t("span", { className: "flex shrink-0 items-center", children: l })
163
+ a && /* @__PURE__ */ t("span", { className: "flex shrink-0 items-center", children: r })
164
164
  ] }),
165
- !a && l,
165
+ !a && r,
166
166
  /* @__PURE__ */ t("p", { "data-effect": "", className: q, children: i }),
167
167
  n && /* @__PURE__ */ t(de, {}),
168
- r === "field" && ((p = u == null ? void 0 : u.pending) == null ? void 0 : p.key) === (c ?? e) && /* @__PURE__ */ t(oe, {})
168
+ l === "field" && ((p = u == null ? void 0 : u.pending) == null ? void 0 : p.key) === (c ?? e) && /* @__PURE__ */ t(oe, {})
169
169
  ] });
170
170
  }
171
171
  function Ie({
172
172
  k: e,
173
173
  label: o,
174
174
  effect: i,
175
- scope: r,
175
+ scope: l,
176
176
  enforced: n,
177
177
  checked: a,
178
178
  onChange: c,
179
- disabled: l,
179
+ disabled: r,
180
180
  confirmAt: s
181
181
  }) {
182
182
  return /* @__PURE__ */ t(
@@ -185,7 +185,7 @@ function Ie({
185
185
  k: e,
186
186
  label: o,
187
187
  effect: i,
188
- scope: r,
188
+ scope: l,
189
189
  enforced: n,
190
190
  confirmAt: s,
191
191
  inline: !0,
@@ -193,7 +193,7 @@ function Ie({
193
193
  ne,
194
194
  {
195
195
  checked: a,
196
- disabled: l,
196
+ disabled: r,
197
197
  onCheckedChange: c,
198
198
  "aria-label": typeof o == "string" ? o : void 0,
199
199
  className: "h-[18px] w-8 border-0 data-[state=checked]:bg-nvr-cyan data-[state=unchecked]:bg-slate-300 dark:data-[state=unchecked]:bg-slate-600 [&>span]:mx-0.5 [&>span]:h-3.5 [&>span]:w-3.5 [&>span]:bg-white [&>span]:shadow-sm [&>span]:data-[state=checked]:translate-x-3.5"
@@ -207,12 +207,12 @@ function me({
207
207
  value: e,
208
208
  onChange: o,
209
209
  placeholder: i,
210
- mono: r,
210
+ mono: l,
211
211
  disabled: n,
212
212
  type: a = "text",
213
213
  ariaLabel: c
214
214
  }) {
215
- const l = f(N), s = x(e, () => l == null ? void 0 : l.flush());
215
+ const r = h(N), s = x(e, () => r == null ? void 0 : r.flush());
216
216
  return /* @__PURE__ */ t(
217
217
  "input",
218
218
  {
@@ -225,10 +225,10 @@ function me({
225
225
  s.set(u.target.value), o(u.target.value);
226
226
  },
227
227
  onKeyDown: (u) => {
228
- u.key === "Enter" && (l == null || l.flush());
228
+ u.key === "Enter" && (r == null || r.flush());
229
229
  },
230
230
  ...s.props,
231
- className: m(A, r && "font-mono")
231
+ className: m(A, l && "font-mono")
232
232
  }
233
233
  );
234
234
  }
@@ -236,20 +236,21 @@ function Ee({
236
236
  value: e,
237
237
  onChange: o,
238
238
  ariaLabel: i,
239
- rows: r = 4
239
+ rows: l = 4,
240
+ mono: n
240
241
  }) {
241
- const n = f(N), a = x(e, () => n == null ? void 0 : n.flush());
242
+ const a = h(N), c = x(e, () => a == null ? void 0 : a.flush());
242
243
  return /* @__PURE__ */ t(
243
244
  "textarea",
244
245
  {
245
246
  "aria-label": i,
246
- rows: r,
247
- value: a.value,
248
- onChange: (c) => {
249
- a.set(c.target.value), o(c.target.value);
247
+ rows: l,
248
+ value: c.value,
249
+ onChange: (r) => {
250
+ c.set(r.target.value), o(r.target.value);
250
251
  },
251
- ...a.props,
252
- className: m(v, "h-auto py-1.5 leading-snug")
252
+ ...c.props,
253
+ className: m(v, "h-auto py-1.5 leading-snug", n && "font-mono text-[12px]")
253
254
  }
254
255
  );
255
256
  }
@@ -258,14 +259,14 @@ function Le({
258
259
  children: o,
259
260
  className: i
260
261
  }) {
261
- const r = f(N), n = x(e, () => r == null ? void 0 : r.flush());
262
+ const l = h(N), n = x(e, () => l == null ? void 0 : l.flush());
262
263
  return /* @__PURE__ */ t(
263
264
  "div",
264
265
  {
265
266
  className: i,
266
267
  ...n.props,
267
268
  onKeyDownCapture: (a) => {
268
- a.key === "Enter" && a.target.tagName === "INPUT" && (r == null || r.flush());
269
+ a.key === "Enter" && a.target.tagName === "INPUT" && (l == null || l.flush());
269
270
  },
270
271
  children: o(n.value, (a) => (n.set(a), a))
271
272
  }
@@ -275,7 +276,7 @@ function Fe({
275
276
  value: e,
276
277
  onCommit: o,
277
278
  placeholder: i,
278
- mono: r,
279
+ mono: l,
279
280
  ariaLabel: n
280
281
  }) {
281
282
  const a = x(e);
@@ -289,7 +290,7 @@ function Fe({
289
290
  a.set(c.target.value), o(c.target.value);
290
291
  },
291
292
  ...a.props,
292
- className: m(A, r && "font-mono")
293
+ className: m(A, l && "font-mono")
293
294
  }
294
295
  );
295
296
  }
@@ -297,14 +298,14 @@ function je({
297
298
  value: e,
298
299
  options: o,
299
300
  onChange: i,
300
- disabled: r
301
+ disabled: l
301
302
  }) {
302
303
  return /* @__PURE__ */ t("div", { className: le(o.length), children: o.map((n) => /* @__PURE__ */ t(
303
304
  "button",
304
305
  {
305
306
  type: "button",
306
307
  "aria-pressed": n.value === e,
307
- disabled: r,
308
+ disabled: l,
308
309
  "data-tip": n.tip,
309
310
  onClick: () => i(n.value),
310
311
  className: re(n.value === e),
@@ -317,18 +318,18 @@ function F({
317
318
  value: e,
318
319
  options: o,
319
320
  onChange: i,
320
- ariaLabel: r,
321
+ ariaLabel: l,
321
322
  disabled: n,
322
323
  unknownLabel: a = (c) => c
323
324
  }) {
324
- const c = e && !o.some((l) => l.value === e) ? [...o, { value: e, label: a(e) }] : o;
325
+ const c = e && !o.some((r) => r.value === e) ? [...o, { value: e, label: a(e) }] : o;
325
326
  return /* @__PURE__ */ t(
326
327
  te,
327
328
  {
328
329
  value: e,
329
330
  onChange: i,
330
331
  options: c,
331
- ariaLabel: r,
332
+ ariaLabel: l,
332
333
  disabled: n,
333
334
  className: m(v, "focus:ring-0 focus:ring-offset-0")
334
335
  }
@@ -338,16 +339,16 @@ function Pe({
338
339
  value: e,
339
340
  onCommit: o,
340
341
  placeholder: i,
341
- rows: r = 4,
342
+ rows: l = 4,
342
343
  validate: n,
343
344
  ariaLabel: a
344
345
  }) {
345
- const c = e == null ? "" : JSON.stringify(e, null, 2), [l, s] = g(c), [u, p] = g(null), b = I(!1);
346
+ const c = e == null ? "" : JSON.stringify(e, null, 2), [r, s] = g(c), [u, p] = g(null), b = I(!1);
346
347
  E(() => {
347
348
  b.current || (s(c), p(null));
348
349
  }, [c]);
349
- const w = (h) => {
350
- const O = h.trim();
350
+ const w = (f) => {
351
+ const O = f.trim();
351
352
  if (!O) return e != null ? { send: void 0 } : { error: null };
352
353
  try {
353
354
  const y = JSON.parse(O), T = (n == null ? void 0 : n(y)) ?? null;
@@ -356,24 +357,24 @@ function Pe({
356
357
  return { error: "Not valid JSON — nothing saved" };
357
358
  }
358
359
  }, D = () => {
359
- const h = w(l);
360
- "send" in h ? (p(null), o(h.send)) : p(h.error);
360
+ const f = w(r);
361
+ "send" in f ? (p(null), o(f.send)) : p(f.error);
361
362
  }, S = I(() => {
362
363
  });
363
364
  return S.current = () => {
364
365
  if (!b.current) return;
365
- const h = w(l);
366
- "send" in h && o(h.send);
366
+ const f = w(r);
367
+ "send" in f && o(f.send);
367
368
  }, E(() => () => S.current(), []), /* @__PURE__ */ d("div", { className: "space-y-1", children: [
368
369
  /* @__PURE__ */ t(
369
370
  "textarea",
370
371
  {
371
- value: l,
372
- rows: r,
372
+ value: r,
373
+ rows: l,
373
374
  "aria-label": a,
374
375
  spellCheck: !1,
375
376
  placeholder: i,
376
- onChange: (h) => s(h.target.value),
377
+ onChange: (f) => s(f.target.value),
377
378
  onFocus: () => {
378
379
  b.current = !0;
379
380
  },
@@ -393,26 +394,26 @@ function qe({
393
394
  title: e,
394
395
  children: o,
395
396
  className: i,
396
- collapsible: r,
397
+ collapsible: l,
397
398
  defaultOpen: n = !1
398
399
  }) {
399
- const [a, c] = g(!r || n);
400
+ const [a, c] = g(!l || n);
400
401
  return /* @__PURE__ */ d(
401
402
  "section",
402
403
  {
403
404
  className: m(
404
405
  "space-y-4 border-t border-slate-100 pt-5 dark:border-border/60",
405
- r && !a && "space-y-0",
406
+ l && !a && "space-y-0",
406
407
  i
407
408
  ),
408
409
  children: [
409
- r ? /* @__PURE__ */ d(
410
+ l ? /* @__PURE__ */ d(
410
411
  "button",
411
412
  {
412
413
  type: "button",
413
414
  "aria-expanded": a,
414
415
  "data-section-toggle": "",
415
- onClick: () => c((l) => !l),
416
+ onClick: () => c((r) => !r),
416
417
  className: m(
417
418
  L,
418
419
  "-mx-1 flex w-[calc(100%+0.5rem)] items-center gap-1.5 rounded px-1 text-left hover:bg-slate-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan/50 dark:hover:bg-muted/60"
@@ -440,10 +441,10 @@ function Ae({
440
441
  value: e,
441
442
  options: o,
442
443
  onChange: i,
443
- placeholder: r = "None selected",
444
+ placeholder: l = "None selected",
444
445
  ariaLabel: n
445
446
  }) {
446
- const [a, c] = g(!1), l = (s) => {
447
+ const [a, c] = g(!1), r = (s) => {
447
448
  var u;
448
449
  return ((u = o.find((p) => p.value === s)) == null ? void 0 : u.label) ?? s;
449
450
  };
@@ -458,7 +459,7 @@ function Ae({
458
459
  "flex items-center justify-between text-left hover:border-slate-300"
459
460
  ),
460
461
  children: [
461
- /* @__PURE__ */ t("span", { className: m("truncate", !e.length && "text-slate-400"), children: e.length ? e.map(l).join(", ") : r }),
462
+ /* @__PURE__ */ t("span", { className: m("truncate", !e.length && "text-slate-400"), children: e.length ? e.map(r).join(", ") : l }),
462
463
  /* @__PURE__ */ t($, { className: "ml-1 h-3.5 w-3.5 shrink-0 text-slate-400" })
463
464
  ]
464
465
  }
@@ -503,10 +504,10 @@ function Be({
503
504
  fields: o,
504
505
  onChange: i
505
506
  }) {
506
- const r = (n, a) => i(e.map((c, l) => l === n ? { ...c, ...a } : c));
507
+ const l = (n, a) => i(e.map((c, r) => r === n ? { ...c, ...a } : c));
507
508
  return /* @__PURE__ */ d("div", { className: "space-y-1.5", children: [
508
509
  e.map((n, a) => {
509
- const c = k.some((l) => l.value === n.op) ? k : [...k, { value: n.op, label: n.op }];
510
+ const c = k.some((r) => r.value === n.op) ? k : [...k, { value: n.op, label: n.op }];
510
511
  return (
511
512
  // biome-ignore lint/suspicious/noArrayIndexKey: conditions are positional
512
513
  /* @__PURE__ */ d("div", { className: "flex items-center gap-1", "data-condition-row": "", children: [
@@ -516,7 +517,7 @@ function Be({
516
517
  value: n.field,
517
518
  ariaLabel: "Field",
518
519
  options: [{ value: "", label: "Field…" }, ...o],
519
- onChange: (l) => r(a, { field: l })
520
+ onChange: (r) => l(a, { field: r })
520
521
  }
521
522
  ) }),
522
523
  /* @__PURE__ */ t("div", { className: "min-w-0 flex-[2]", children: /* @__PURE__ */ t(
@@ -525,7 +526,7 @@ function Be({
525
526
  value: n.op,
526
527
  ariaLabel: "Condition",
527
528
  options: c,
528
- onChange: (l) => r(a, l === "nnull" ? { op: l, value: void 0 } : { op: l })
529
+ onChange: (r) => l(a, r === "nnull" ? { op: r, value: void 0 } : { op: r })
529
530
  }
530
531
  ) }),
531
532
  n.op !== "nnull" && n.op !== "null" && /* @__PURE__ */ t("div", { className: "min-w-0 flex-[2]", children: /* @__PURE__ */ t(
@@ -534,7 +535,7 @@ function Be({
534
535
  value: n.value == null ? "" : String(n.value),
535
536
  ariaLabel: "Value",
536
537
  placeholder: "value",
537
- onChange: (l) => r(a, { value: l })
538
+ onChange: (r) => l(a, { value: r })
538
539
  }
539
540
  ) }),
540
541
  /* @__PURE__ */ t(
@@ -543,7 +544,7 @@ function Be({
543
544
  type: "button",
544
545
  "aria-label": "Remove condition",
545
546
  "data-tip": "Remove condition",
546
- onClick: () => i(e.filter((l, s) => s !== a)),
547
+ onClick: () => i(e.filter((r, s) => s !== a)),
547
548
  className: "inline-flex h-7 w-7 shrink-0 items-center justify-center rounded text-slate-500 transition-colors hover:bg-slate-100 hover:text-red-600 dark:hover:bg-muted dark:hover:text-red-400",
548
549
  children: /* @__PURE__ */ t(U, { className: "h-3.5 w-3.5" })
549
550
  }
@@ -0,0 +1,254 @@
1
+ import { jsxs as o, jsx as e, Fragment as R } from "react/jsx-runtime";
2
+ import { FileOutput as T, ArrowLeft as H, FileSpreadsheet as M, Download as U, Printer as _, Upload as q, Loader2 as I } from "lucide-react";
3
+ import { useState as u, useRef as W, useMemo as j } from "react";
4
+ import { useApiFetchConfig as Y } from "../../../context.js";
5
+ import { cn as x } from "../../../lib/utils.js";
6
+ import { Checkbox as z } from "../../ui/checkbox.js";
7
+ import { Popover as G, PopoverContent as J } from "../../ui/popover.js";
8
+ import { useCollectionMeta as K } from "../inspector/field-context.js";
9
+ import { effectText as g } from "../panel-style.js";
10
+ import { ToolButton as Q } from "../toolbar-kit.js";
11
+ import { helpSheetPlan as V, propWord as X, diffHelpSheet as Z, helpSheetRows as ee } from "./help-sheet.js";
12
+ import { parseHelpSheetFile as te, saveFile as k, downloadTemplate as ae, downloadRecords as ne, downloadBlankForm as oe, downloadHelpSheet as se } from "./output-api.js";
13
+ const re = "mt-0.5 h-4 w-4 shrink-0 rounded border-slate-300 data-[state=checked]:border-nvr-cyan data-[state=checked]:bg-nvr-cyan data-[state=checked]:text-white dark:border-slate-600 [&_svg]:h-3 [&_svg]:w-3", le = "group flex w-full items-start gap-2.5 rounded-md px-2 py-1.5 text-left transition-colors hover:bg-muted focus-visible:bg-muted focus-visible:outline-none disabled:pointer-events-none disabled:opacity-60";
14
+ function f({
15
+ icon: s,
16
+ title: d,
17
+ effect: i,
18
+ busy: n,
19
+ onClick: c,
20
+ data: w
21
+ }) {
22
+ return /* @__PURE__ */ o("button", { type: "button", className: le, disabled: n, onClick: c, "data-output": w, children: [
23
+ /* @__PURE__ */ e("span", { className: "mt-0.5 text-slate-500 dark:text-muted-foreground", children: n ? /* @__PURE__ */ e(I, { className: "h-4 w-4 animate-spin" }) : s }),
24
+ /* @__PURE__ */ o("span", { className: "min-w-0 flex-1", children: [
25
+ /* @__PURE__ */ e("span", { className: "block text-[13px] font-medium text-slate-900 dark:text-foreground", children: d }),
26
+ /* @__PURE__ */ e("span", { className: x(g, "block"), children: i })
27
+ ] })
28
+ ] });
29
+ }
30
+ function de({
31
+ diff: s,
32
+ skip: d,
33
+ toggle: i
34
+ }) {
35
+ return /* @__PURE__ */ e(
36
+ "div",
37
+ {
38
+ "data-help-changes": "",
39
+ className: "mt-2 max-h-[320px] overflow-y-auto border-t border-slate-100 pt-1 dark:border-border",
40
+ children: s.changes.map((n) => (
41
+ // biome-ignore lint/a11y/noLabelWithoutControl: the Radix checkbox is the control
42
+ /* @__PURE__ */ o(
43
+ "label",
44
+ {
45
+ "data-help-change": n.prop,
46
+ className: "flex cursor-pointer items-start gap-2 rounded px-1 py-1.5 hover:bg-muted",
47
+ children: [
48
+ /* @__PURE__ */ e(
49
+ z,
50
+ {
51
+ checked: !d.has(n.id),
52
+ onCheckedChange: () => i(n.id),
53
+ className: re
54
+ }
55
+ ),
56
+ /* @__PURE__ */ o("span", { className: "min-w-0 flex-1 text-[12.5px] leading-snug", children: [
57
+ /* @__PURE__ */ o("span", { className: "block truncate text-[11.5px] text-slate-500 dark:text-muted-foreground", children: [
58
+ X(n.prop),
59
+ " · ",
60
+ n.where
61
+ ] }),
62
+ /* @__PURE__ */ e("span", { className: "block whitespace-pre-wrap break-words text-slate-500 line-through decoration-slate-300 dark:text-muted-foreground", children: n.before || "Empty" }),
63
+ /* @__PURE__ */ e("span", { className: "block whitespace-pre-wrap break-words text-slate-900 dark:text-foreground", children: n.after || "Removed (the field’s own text shows)" })
64
+ ] })
65
+ ]
66
+ },
67
+ n.id
68
+ )
69
+ ))
70
+ }
71
+ );
72
+ }
73
+ function ye({
74
+ bundle: s,
75
+ apply: d,
76
+ collection: i
77
+ }) {
78
+ const n = Y(), c = Number(s.layout.id), w = String(s.layout.name ?? "form"), [S, F] = u(!1), [p, B] = u(null), [E, y] = u(null), [a, N] = u(null), [v, O] = u(/* @__PURE__ */ new Set()), $ = W(null), { data: C } = K(S ? i : null), A = C == null ? void 0 : C.fields, h = j(() => ((a == null ? void 0 : a.changes) ?? []).filter((t) => !v.has(t.id)), [a, v]), b = j(() => V(s, h), [s, h]), m = async (t, r) => {
79
+ B(t), y(null);
80
+ try {
81
+ await r();
82
+ } catch (l) {
83
+ y(l.message || "Something went wrong");
84
+ } finally {
85
+ B(null);
86
+ }
87
+ }, D = (t) => {
88
+ t && m("upload", async () => {
89
+ const r = await te(n, t), l = Z(s, A ?? [], r);
90
+ O(/* @__PURE__ */ new Set()), N(l);
91
+ });
92
+ }, L = (t) => O((r) => {
93
+ const l = new Set(r);
94
+ return l.has(t) ? l.delete(t) : l.add(t), l;
95
+ }), P = (t) => {
96
+ F(t), t || (N(null), y(null));
97
+ };
98
+ return /* @__PURE__ */ o(G, { open: S, onOpenChange: P, children: [
99
+ /* @__PURE__ */ e(
100
+ Q,
101
+ {
102
+ popover: !0,
103
+ onOpen: () => F(!0),
104
+ label: "Outputs",
105
+ icon: /* @__PURE__ */ e(T, { className: "h-3.5 w-3.5 shrink-0" }),
106
+ tip: "Excel template and export, blank printable form, help text sheet",
107
+ hint: "Spreadsheet, print and help text",
108
+ data: { "data-outputs-open": "" }
109
+ }
110
+ ),
111
+ /* @__PURE__ */ e(J, { align: "end", className: "w-[420px] p-3", "data-outputs": "", children: a ? /* @__PURE__ */ o(R, { children: [
112
+ /* @__PURE__ */ o(
113
+ "button",
114
+ {
115
+ type: "button",
116
+ onClick: () => N(null),
117
+ className: "mb-1 inline-flex items-center gap-1 text-[12px] font-medium text-sky-700 hover:underline dark:text-nvr-cyan",
118
+ children: [
119
+ /* @__PURE__ */ e(H, { className: "h-3 w-3" }),
120
+ " Back"
121
+ ]
122
+ }
123
+ ),
124
+ /* @__PURE__ */ e("p", { className: "text-[13px] font-semibold text-slate-900 dark:text-foreground", children: a.changes.length === 0 ? "Nothing differs from the form" : `${a.changes.length} ${a.changes.length === 1 ? "change" : "changes"} in the sheet` }),
125
+ /* @__PURE__ */ e("p", { className: x(g, "mt-0.5"), children: "Untick any you do not want. Applying is one step; Undo puts every one back." }),
126
+ /* @__PURE__ */ e(de, { diff: a, skip: v, toggle: L }),
127
+ (a.unknown > 0 || a.skipped.length > 0) && /* @__PURE__ */ o("p", { className: x(g, "mt-2"), children: [
128
+ a.unknown > 0 && `${a.unknown} ${a.unknown === 1 ? "row" : "rows"} match nothing on this form and ${a.unknown === 1 ? "is" : "are"} left out. `,
129
+ a.skipped.join(". ")
130
+ ] }),
131
+ /* @__PURE__ */ o("div", { className: "mt-2 flex items-center justify-end gap-2 border-t border-slate-100 pt-2.5 dark:border-border", children: [
132
+ /* @__PURE__ */ e("span", { className: x(g, "mr-auto"), children: a.changes.length > 0 && `${h.length} of ${a.changes.length} ticked` }),
133
+ /* @__PURE__ */ o(
134
+ "button",
135
+ {
136
+ type: "button",
137
+ "data-help-apply": "",
138
+ disabled: !b.ok,
139
+ onClick: () => {
140
+ b.ok && (d(b.ops, { label: b.label }), P(!1));
141
+ },
142
+ className: "inline-flex h-7 items-center rounded-md bg-nvr-cyan px-3 text-[12px] font-medium text-white transition-opacity hover:opacity-90 disabled:pointer-events-none disabled:opacity-40",
143
+ children: [
144
+ "Apply ",
145
+ h.length > 0 ? h.length : ""
146
+ ]
147
+ }
148
+ )
149
+ ] })
150
+ ] }) : /* @__PURE__ */ o(R, { children: [
151
+ /* @__PURE__ */ e("p", { className: "px-2 text-[13px] font-semibold text-slate-900 dark:text-foreground", children: "Outputs" }),
152
+ /* @__PURE__ */ e("p", { className: x(g, "mt-0.5 px-2"), children: "The form as a file. Spreadsheets and print follow the saved form." }),
153
+ /* @__PURE__ */ o("div", { className: "mt-2 space-y-0.5", children: [
154
+ /* @__PURE__ */ e(
155
+ f,
156
+ {
157
+ data: "template",
158
+ icon: /* @__PURE__ */ e(M, { className: "h-4 w-4" }),
159
+ title: "Excel import template",
160
+ effect: "Columns in this form’s order; choices are dropdowns and required columns are amber.",
161
+ busy: p === "template",
162
+ onClick: () => m("template", async () => k(await ae(n, c)))
163
+ }
164
+ ),
165
+ /* @__PURE__ */ e(
166
+ f,
167
+ {
168
+ data: "records",
169
+ icon: /* @__PURE__ */ e(U, { className: "h-4 w-4" }),
170
+ title: "Export records to Excel",
171
+ effect: "Up to 5,000 records in the same columns, limited to what you may read.",
172
+ busy: p === "records",
173
+ onClick: () => m("records", async () => k(await ne(n, c)))
174
+ }
175
+ ),
176
+ /* @__PURE__ */ e(
177
+ f,
178
+ {
179
+ data: "blank",
180
+ icon: /* @__PURE__ */ e(_, { className: "h-4 w-4" }),
181
+ title: "Blank printable form",
182
+ effect: "A PDF with lines and checkboxes for filling in on paper.",
183
+ busy: p === "blank",
184
+ onClick: () => m("blank", async () => k(await oe(n, c)))
185
+ }
186
+ )
187
+ ] }),
188
+ /* @__PURE__ */ o("div", { className: "mt-2 border-t border-slate-100 pt-2 dark:border-border", children: [
189
+ /* @__PURE__ */ e("p", { className: "px-2 text-[12.5px] font-semibold text-slate-900 dark:text-foreground", children: "Labels and help text" }),
190
+ /* @__PURE__ */ o("div", { className: "mt-1 space-y-0.5", children: [
191
+ /* @__PURE__ */ e(
192
+ f,
193
+ {
194
+ data: "help-download",
195
+ icon: /* @__PURE__ */ e(U, { className: "h-4 w-4" }),
196
+ title: "Download as a sheet",
197
+ effect: "Every label, help text and placeholder on this form, including unsaved edits.",
198
+ busy: p === "help",
199
+ onClick: () => m(
200
+ "help",
201
+ async () => k(
202
+ await se(
203
+ n,
204
+ ee(s, A ?? []),
205
+ w
206
+ )
207
+ )
208
+ )
209
+ }
210
+ ),
211
+ /* @__PURE__ */ e(
212
+ f,
213
+ {
214
+ data: "help-upload",
215
+ icon: /* @__PURE__ */ e(q, { className: "h-4 w-4" }),
216
+ title: "Upload the edited sheet",
217
+ effect: "You see every difference before anything changes.",
218
+ busy: p === "upload",
219
+ onClick: () => {
220
+ var t;
221
+ return (t = $.current) == null ? void 0 : t.click();
222
+ }
223
+ }
224
+ ),
225
+ /* @__PURE__ */ e(
226
+ "input",
227
+ {
228
+ ref: $,
229
+ type: "file",
230
+ accept: ".xlsx",
231
+ className: "hidden",
232
+ "data-help-file": "",
233
+ onChange: (t) => {
234
+ var r;
235
+ D((r = t.target.files) == null ? void 0 : r[0]), t.target.value = "";
236
+ }
237
+ }
238
+ )
239
+ ] })
240
+ ] }),
241
+ E && /* @__PURE__ */ e(
242
+ "p",
243
+ {
244
+ role: "alert",
245
+ className: "mt-2 text-[12px] leading-snug text-red-600 dark:text-red-400",
246
+ children: E
247
+ }
248
+ )
249
+ ] }) })
250
+ ] });
251
+ }
252
+ export {
253
+ ye as OutputsButton
254
+ };