@nivaro/react 0.3.36 → 0.3.38

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 (102) hide show
  1. package/dist/components/slots/CommentsSlot.js +44 -36
  2. package/dist/full.css +1 -1
  3. package/dist/hooks/useSessionRecorder.js +1 -1
  4. package/dist/index.d.ts +9 -1
  5. package/dist/shared/components/AgentBadge.js +26 -0
  6. package/dist/shared/components/AgentQuestionsCard.js +198 -0
  7. package/dist/shared/components/ItemEditForm.js +3329 -3263
  8. package/dist/shared/components/McpConnectionScope.js +480 -0
  9. package/dist/shared/components/MyWorkView.js +223 -208
  10. package/dist/shared/components/RecordReadView.js +620 -575
  11. package/dist/shared/components/chat/ChatPanel.js +683 -671
  12. package/dist/shared/components/imports/DownloadSampleButton.js +69 -0
  13. package/dist/shared/components/imports/ImportConsole.js +106 -104
  14. package/dist/shared/components/imports/RunDetailSheet.js +34 -32
  15. package/dist/shared/components/item-edit/FieldAffordances.js +32 -32
  16. package/dist/shared/components/item-edit/FormTour.js +279 -0
  17. package/dist/shared/components/item-edit/GroupSection.js +377 -360
  18. package/dist/shared/components/item-edit/PersonalDefaultControl.js +28 -28
  19. package/dist/shared/components/item-edit/entry/EntryStrip.js +30 -26
  20. package/dist/shared/components/item-edit/form-density.js +36 -0
  21. package/dist/shared/components/item-edit/useFormUsageBeacon.js +59 -46
  22. package/dist/shared/components/item-edit/usePersonalDefaults.js +312 -296
  23. package/dist/shared/components/layout-editor/AddPanel.js +349 -192
  24. package/dist/shared/components/layout-editor/DesignNode.js +126 -112
  25. package/dist/shared/components/layout-editor/EditorTopBar.js +123 -103
  26. package/dist/shared/components/layout-editor/LayoutEditor.js +829 -751
  27. package/dist/shared/components/layout-editor/PlaceTools.js +334 -0
  28. package/dist/shared/components/layout-editor/SlashInsert.js +252 -0
  29. package/dist/shared/components/layout-editor/StructureMenu.js +285 -242
  30. package/dist/shared/components/layout-editor/add-target.js +54 -43
  31. package/dist/shared/components/layout-editor/ai-forms/AiComposer.js +238 -155
  32. package/dist/shared/components/layout-editor/ai-forms/AiFormsButton.js +1 -1
  33. package/dist/shared/components/layout-editor/ai-forms/ai-forms-api.js +15 -12
  34. package/dist/shared/components/layout-editor/dnd/LayoutDndProvider.js +347 -189
  35. package/dist/shared/components/layout-editor/dnd/TrashZone.js +60 -32
  36. package/dist/shared/components/layout-editor/dnd/UndoChip.js +76 -0
  37. package/dist/shared/components/layout-editor/dnd/merge-drop.js +33 -0
  38. package/dist/shared/components/layout-editor/dnd/multi-drop.js +87 -0
  39. package/dist/shared/components/layout-editor/dnd/node.js +115 -105
  40. package/dist/shared/components/layout-editor/dnd/sensors.js +23 -0
  41. package/dist/shared/components/layout-editor/dnd/trash-drop.js +34 -28
  42. package/dist/shared/components/layout-editor/dnd/trash-links.js +97 -0
  43. package/dist/shared/components/layout-editor/even-row.js +86 -0
  44. package/dist/shared/components/layout-editor/field-list.js +99 -0
  45. package/dist/shared/components/layout-editor/format-painter.js +102 -0
  46. package/dist/shared/components/layout-editor/grid-guides.js +15 -13
  47. package/dist/shared/components/layout-editor/inspector/BehaviourSettings.js +150 -132
  48. package/dist/shared/components/layout-editor/inspector/BulkInspector.js +57 -53
  49. package/dist/shared/components/layout-editor/inspector/EvenRowAction.js +31 -0
  50. package/dist/shared/components/layout-editor/inspector/GroupInspector.js +154 -141
  51. package/dist/shared/components/layout-editor/inspector/Inspector.js +209 -178
  52. package/dist/shared/components/layout-editor/inspector/LookTab.js +106 -98
  53. package/dist/shared/components/layout-editor/inspector/RulesTab.js +38 -37
  54. package/dist/shared/components/layout-editor/inspector/kit.js +280 -223
  55. package/dist/shared/components/layout-editor/keyboard-move.js +15 -15
  56. package/dist/shared/components/layout-editor/lint/LabelStyle.js +201 -0
  57. package/dist/shared/components/layout-editor/lint/LintPanel.js +132 -84
  58. package/dist/shared/components/layout-editor/lint/lint-api.js +65 -28
  59. package/dist/shared/components/layout-editor/nav/NavTools.js +14 -12
  60. package/dist/shared/components/layout-editor/nav/ZoomControls.js +145 -0
  61. package/dist/shared/components/layout-editor/nav/useEditorNav.js +34 -32
  62. package/dist/shared/components/layout-editor/nav/view-prefs.js +100 -15
  63. package/dist/shared/components/layout-editor/outputs/LayoutFile.js +89 -0
  64. package/dist/shared/components/layout-editor/outputs/OutputsButton.js +272 -195
  65. package/dist/shared/components/layout-editor/outputs/layout-file-plan.js +176 -0
  66. package/dist/shared/components/layout-editor/outputs/output-api.js +71 -37
  67. package/dist/shared/components/layout-editor/overview/describe-conditions.js +16 -11
  68. package/dist/shared/components/layout-editor/overview/purpose.js +5 -5
  69. package/dist/shared/components/layout-editor/parity-keys.json.js +1 -1
  70. package/dist/shared/components/layout-editor/pin.js +37 -19
  71. package/dist/shared/components/layout-editor/place-clip.js +257 -0
  72. package/dist/shared/components/layout-editor/preview/PreviewModes.js +27 -26
  73. package/dist/shared/components/layout-editor/preview/PreviewPanes.js +148 -117
  74. package/dist/shared/components/layout-editor/preview/SampleRecord.js +113 -0
  75. package/dist/shared/components/layout-editor/preview/preview-model.js +79 -60
  76. package/dist/shared/components/layout-editor/preview/sample-record.js +105 -0
  77. package/dist/shared/components/layout-editor/removed-log.js +151 -0
  78. package/dist/shared/components/layout-editor/reuse/LibraryRows.js +109 -78
  79. package/dist/shared/components/layout-editor/reuse/linked-sections.js +373 -0
  80. package/dist/shared/components/layout-editor/revert-element.js +140 -0
  81. package/dist/shared/components/layout-editor/section-structure.js +193 -170
  82. package/dist/shared/components/layout-editor/settings/EntrySection.js +63 -45
  83. package/dist/shared/components/layout-editor/settings/LayoutSection.js +63 -32
  84. package/dist/shared/components/layout-editor/settings/ResolveSettings.js +179 -137
  85. package/dist/shared/components/layout-editor/settings/WhoSection.js +18 -17
  86. package/dist/shared/components/layout-editor/settings/settings-registry.js +24 -0
  87. package/dist/shared/components/layout-editor/shortcuts.js +21 -16
  88. package/dist/shared/components/layout-editor/structure-ops.js +221 -195
  89. package/dist/shared/components/layout-editor/usage/UsagePanel.js +133 -85
  90. package/dist/shared/components/layout-editor/usage/refusal-lens.js +130 -0
  91. package/dist/shared/components/layout-editor/usage/usage-api.js +12 -11
  92. package/dist/shared/components/panels/CommentPanel.js +47 -45
  93. package/dist/shared/components/panels/RevisionsPanel.js +66 -64
  94. package/dist/shared/components/panels/TaskPanel.js +395 -332
  95. package/dist/shared/components/profile/AgentsPanel.js +196 -147
  96. package/dist/shared/components/profile/ConnectionRollback.js +329 -0
  97. package/dist/shared/components/profile/MyDefaultsCard.js +526 -520
  98. package/dist/shared/lib/entry-config.js +22 -22
  99. package/dist/shared/lib/form-usage-beacon.js +91 -55
  100. package/dist/shared/lib/layout-lint.js +530 -284
  101. package/dist/shared/lib/layout-resolve.js +58 -44
  102. package/package.json +1 -1
@@ -0,0 +1,279 @@
1
+ import { jsxs as b, jsx as p, Fragment as B } from "react/jsx-runtime";
2
+ import { useQueryClient as O, useQuery as T } from "@tanstack/react-query";
3
+ import { Compass as W, X as D } from "lucide-react";
4
+ import { useState as v, useEffect as k, useCallback as F, useId as j, useRef as z, useLayoutEffect as H, useMemo as R } from "react";
5
+ import { createPortal as Q } from "react-dom";
6
+ import { useNivaroClient as P } from "../../context.js";
7
+ import { get as X, patch as G } from "../../lib/commands.js";
8
+ import { cn as V } from "../../lib/utils.js";
9
+ const I = 280, Y = 4;
10
+ function J(e) {
11
+ return e.length <= 1 ? e[0] ?? "" : `${e.slice(0, -1).join(", ")} and ${e[e.length - 1]}`;
12
+ }
13
+ function ce(e, t) {
14
+ const i = /* @__PURE__ */ new Map();
15
+ for (const n of e) {
16
+ if (n.type !== "section" && n.type !== "tab" && n.type !== "metadata") continue;
17
+ const x = (t[n.key] ?? []).filter((r) => !r.hidden), c = x.map((r) => (r.label || r.field).trim()).filter(Boolean), u = x.filter((r) => r.required).length, g = n.content_tone === "divider" ? "" : (n.content ?? "").trim();
18
+ let f;
19
+ if (g) f = g.length > I ? `${g.slice(0, I - 1).trimEnd()}…` : g;
20
+ else if (n.type === "metadata") f = "Facts about the record itself: who made it and when.";
21
+ else if (c.length === 0) f = "Nothing to fill in here yet.";
22
+ else {
23
+ const r = c.slice(0, Y), w = c.length - r.length;
24
+ f = c.length === 1 ? `One field: ${r[0]}.` : `${c.length} fields: ${w > 0 ? `${r.join(", ")} and ${w} more` : J(r)}.`;
25
+ }
26
+ i.set(n.key, { key: n.key, title: n.label || "Section", body: f, required: u });
27
+ }
28
+ return i;
29
+ }
30
+ function U(e) {
31
+ if (!e) return [];
32
+ const t = [];
33
+ for (const i of e.querySelectorAll("[data-section-key], [data-read-section]")) {
34
+ if (i.hidden || i.closest("[hidden]") || i.classList.contains("hidden")) continue;
35
+ const n = i.getAttribute("data-section-key") ?? i.getAttribute("data-read-section");
36
+ n && !t.includes(n) && t.push(n);
37
+ }
38
+ return t;
39
+ }
40
+ function Z(e, t) {
41
+ if (!e) return null;
42
+ const i = typeof CSS < "u" && CSS.escape ? CSS.escape(t) : t.replace(/["\\]/g, "\\$&");
43
+ return e.querySelector(`[data-section-key="${i}"], [data-read-section="${i}"]`);
44
+ }
45
+ const K = (e, t) => `nvr:form-tour:${e}:${t}`;
46
+ function _(e) {
47
+ try {
48
+ return localStorage.getItem(e) === "1";
49
+ } catch {
50
+ return !1;
51
+ }
52
+ }
53
+ const ee = () => {
54
+ try {
55
+ return window.matchMedia("(prefers-reduced-motion: reduce)").matches;
56
+ } catch {
57
+ return !1;
58
+ }
59
+ };
60
+ function ue(e) {
61
+ const { layoutId: t, userId: i, enabled: n } = e, x = P(), c = O(), u = t != null ? K(i, t) : "", [g, f] = v(() => u ? _(u) : !1);
62
+ k(() => f(u ? _(u) : !1), [u]);
63
+ const { data: r, isSuccess: w } = T({
64
+ queryKey: ["form-tours-done", i],
65
+ queryFn: () => x.request(X("/auth/me")).then((l) => {
66
+ var y, m;
67
+ const N = (m = (y = l == null ? void 0 : l.data) == null ? void 0 : y.preferences) == null ? void 0 : m.form_tours_done;
68
+ return Array.isArray(N) ? N.filter((S) => Number.isInteger(S)) : [];
69
+ }),
70
+ enabled: n && t != null && !g,
71
+ staleTime: 5 * 6e4
72
+ }), a = g || t != null && !!(r != null && r.includes(t)), $ = F(() => {
73
+ if (t != null) {
74
+ f(!0);
75
+ try {
76
+ localStorage.setItem(K(i, t), "1");
77
+ } catch {
78
+ }
79
+ c.setQueryData(
80
+ ["form-tours-done", i],
81
+ (l) => l != null && l.includes(t) ? l : [...l ?? [], t]
82
+ ), x.request(G("/users/me/preferences", { form_tour_done: t })).catch(() => {
83
+ });
84
+ }
85
+ }, [x, c, t, i]);
86
+ return { seen: a, known: g || w, markSeen: $ };
87
+ }
88
+ function fe({ onClick: e }) {
89
+ return /* @__PURE__ */ b(
90
+ "button",
91
+ {
92
+ type: "button",
93
+ "data-form-tour-button": "",
94
+ "data-tip": "A short walk through this form",
95
+ onClick: e,
96
+ className: "inline-flex h-6 items-center gap-1 rounded px-2 text-[11.5px] font-medium text-slate-500 transition-colors hover:bg-muted hover:text-slate-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-sky-600 dark:text-muted-foreground dark:hover:text-foreground dark:focus-visible:ring-sky-300",
97
+ children: [
98
+ /* @__PURE__ */ p(W, { className: "h-3.5 w-3.5", "aria-hidden": "true" }),
99
+ "Tour"
100
+ ]
101
+ }
102
+ );
103
+ }
104
+ const te = 320, M = 10;
105
+ function me({
106
+ rootRef: e,
107
+ steps: t,
108
+ formName: i,
109
+ onClose: n
110
+ }) {
111
+ const x = j(), c = z(null), [u, g] = v(null);
112
+ k(() => {
113
+ g(U(e.current).filter((o) => t.has(o)));
114
+ }, []);
115
+ const f = u ?? [], [r, w] = v(0), [a, $] = v(null), [l, N] = v(
116
+ () => typeof window < "u" && window.innerWidth < 640
117
+ ), y = f[r], m = y ? t.get(y) : void 0;
118
+ k(() => {
119
+ u && u.length === 0 && n(!1);
120
+ }, [u, n]), H(() => {
121
+ if (!y) return;
122
+ const o = Z(e.current, y);
123
+ if (!o) return;
124
+ const s = o.getBoundingClientRect().height > window.innerHeight * 0.6;
125
+ o.scrollIntoView({
126
+ block: s ? "start" : "center",
127
+ behavior: ee() ? "auto" : "smooth"
128
+ });
129
+ let d = 0;
130
+ const h = () => {
131
+ cancelAnimationFrame(d), d = requestAnimationFrame(() => {
132
+ const A = o.getBoundingClientRect();
133
+ $({ top: A.top, left: A.left, width: A.width, height: A.height }), N(window.innerWidth < 640);
134
+ });
135
+ };
136
+ return h(), window.addEventListener("scroll", h, !0), window.addEventListener("resize", h), () => {
137
+ cancelAnimationFrame(d), window.removeEventListener("scroll", h, !0), window.removeEventListener("resize", h);
138
+ };
139
+ }, [y, e]);
140
+ const S = !!m;
141
+ k(() => {
142
+ var s;
143
+ if (!S) return;
144
+ const o = document.activeElement;
145
+ return (s = c.current) == null || s.focus({ preventScroll: !0 }), () => {
146
+ var d;
147
+ return (d = o == null ? void 0 : o.focus) == null ? void 0 : d.call(o, { preventScroll: !0 });
148
+ };
149
+ }, [S]);
150
+ const q = r >= f.length - 1, E = F(() => {
151
+ q ? n(!0) : w((o) => o + 1);
152
+ }, [q, n]), L = F(() => w((o) => Math.max(0, o - 1)), []);
153
+ k(() => {
154
+ const o = (s) => {
155
+ var h;
156
+ const d = document.activeElement;
157
+ d && d !== document.body && !((h = c.current) != null && h.contains(d)) || (s.key === "Escape" ? (s.preventDefault(), n(!1)) : s.key === "ArrowRight" && !s.altKey && !s.metaKey && !s.ctrlKey ? E() : s.key === "ArrowLeft" && !s.altKey && !s.metaKey && !s.ctrlKey && L());
158
+ };
159
+ return window.addEventListener("keydown", o), () => window.removeEventListener("keydown", o);
160
+ }, [E, L, n]);
161
+ const C = R(() => {
162
+ if (!a || l || typeof window > "u") return null;
163
+ const o = window.innerWidth, s = window.innerHeight, d = Math.min(Math.max(12, a.left + 16), o - te - 12), h = a.top + Math.min(a.height, 52) + M;
164
+ return h + 200 < s ? { top: Math.max(12, h), left: d } : a.top - M - 200 > 0 ? { bottom: s - a.top + M, left: d } : { top: 12, left: d };
165
+ }, [a, l]);
166
+ return !m || typeof document > "u" ? null : Q(
167
+ /* @__PURE__ */ b(B, { children: [
168
+ a && /* @__PURE__ */ p(
169
+ "div",
170
+ {
171
+ "aria-hidden": "true",
172
+ "data-form-tour-ring": "",
173
+ className: "pointer-events-none fixed z-[70] rounded-xl ring-2 ring-nvr-cyan ring-offset-2 ring-offset-white transition-[top,left,width,height] duration-200 motion-reduce:transition-none dark:ring-offset-background",
174
+ style: {
175
+ top: a.top,
176
+ left: a.left,
177
+ width: a.width,
178
+ height: Math.min(a.height, window.innerHeight - Math.max(0, a.top) + 8)
179
+ }
180
+ }
181
+ ),
182
+ /* @__PURE__ */ b(
183
+ "div",
184
+ {
185
+ ref: c,
186
+ role: "dialog",
187
+ "aria-modal": "false",
188
+ "aria-labelledby": x,
189
+ tabIndex: -1,
190
+ "data-form-tour": "",
191
+ "data-form-tour-step": m.key,
192
+ className: V(
193
+ "fixed z-[71] rounded-xl border border-slate-200 bg-white p-4 shadow-lg outline-none dark:border-border dark:bg-card",
194
+ l ? "inset-x-3 bottom-3" : "w-[320px]"
195
+ ),
196
+ style: l || !C ? void 0 : C,
197
+ children: [
198
+ /* @__PURE__ */ b("div", { className: "flex items-start gap-2", children: [
199
+ /* @__PURE__ */ b("div", { className: "min-w-0 flex-1", children: [
200
+ /* @__PURE__ */ b("p", { className: "text-[11px] font-medium text-slate-500 dark:text-muted-foreground", children: [
201
+ r === 0 && i ? `${i} · ` : "",
202
+ r + 1,
203
+ " of ",
204
+ f.length
205
+ ] }),
206
+ /* @__PURE__ */ p(
207
+ "h2",
208
+ {
209
+ id: x,
210
+ className: "mt-0.5 text-[14px] font-semibold text-slate-900 dark:text-foreground",
211
+ children: m.title
212
+ }
213
+ )
214
+ ] }),
215
+ /* @__PURE__ */ p(
216
+ "button",
217
+ {
218
+ type: "button",
219
+ "aria-label": "Close the tour",
220
+ "data-form-tour-close": "",
221
+ onClick: () => n(!1),
222
+ className: "-mr-1 -mt-1 rounded p-1 text-slate-400 transition-colors hover:bg-muted hover:text-slate-700 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-sky-600 dark:hover:text-foreground dark:focus-visible:ring-sky-300",
223
+ children: /* @__PURE__ */ p(D, { className: "h-4 w-4" })
224
+ }
225
+ )
226
+ ] }),
227
+ /* @__PURE__ */ p("p", { className: "mt-2 whitespace-pre-wrap text-[12.5px] leading-relaxed text-slate-600 dark:text-muted-foreground", children: m.body }),
228
+ m.required > 0 && /* @__PURE__ */ b("p", { className: "mt-1.5 text-[12px] text-slate-500 dark:text-muted-foreground", children: [
229
+ m.required === 1 ? "One field here is" : `${m.required} fields here are`,
230
+ " ",
231
+ "required ",
232
+ /* @__PURE__ */ p("span", { className: "text-destructive", children: "*" })
233
+ ] }),
234
+ /* @__PURE__ */ b("div", { className: "mt-3 flex items-center gap-2", children: [
235
+ r === 0 ? /* @__PURE__ */ p(
236
+ "button",
237
+ {
238
+ type: "button",
239
+ "data-form-tour-skip": "",
240
+ onClick: () => n(!1),
241
+ className: "h-8 rounded-md px-2.5 text-[12.5px] font-medium text-slate-500 transition-colors hover:bg-muted hover:text-slate-800 dark:text-muted-foreground dark:hover:text-foreground",
242
+ children: "Skip tour"
243
+ }
244
+ ) : /* @__PURE__ */ p(
245
+ "button",
246
+ {
247
+ type: "button",
248
+ "data-form-tour-back": "",
249
+ onClick: L,
250
+ className: "h-8 rounded-md px-2.5 text-[12.5px] font-medium text-slate-600 transition-colors hover:bg-muted hover:text-slate-900 dark:text-muted-foreground dark:hover:text-foreground",
251
+ children: "Back"
252
+ }
253
+ ),
254
+ /* @__PURE__ */ p("span", { className: "flex-1" }),
255
+ /* @__PURE__ */ p(
256
+ "button",
257
+ {
258
+ type: "button",
259
+ "data-form-tour-next": "",
260
+ onClick: E,
261
+ className: "h-8 rounded-md bg-nvr-cyan px-3 text-[12.5px] font-medium text-white transition-opacity hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-sky-600 focus-visible:ring-offset-2 dark:focus-visible:ring-sky-300 dark:focus-visible:ring-offset-card",
262
+ children: q ? "Done" : "Next"
263
+ }
264
+ )
265
+ ] })
266
+ ]
267
+ }
268
+ )
269
+ ] }),
270
+ document.body
271
+ );
272
+ }
273
+ export {
274
+ me as FormTour,
275
+ fe as FormTourButton,
276
+ ce as buildTourSteps,
277
+ U as sectionKeysOnScreen,
278
+ ue as useFormTourSeen
279
+ };