@nivaro/react 0.3.35 → 0.3.37
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.
- package/dist/components/slots/CommentsSlot.js +44 -36
- package/dist/full.css +1 -1
- package/dist/hooks/useSessionRecorder.js +1 -1
- package/dist/index.d.ts +13 -4
- package/dist/shared/components/AgentBadge.js +26 -0
- package/dist/shared/components/AgentQuestionsCard.js +198 -0
- package/dist/shared/components/ItemEditForm.js +3329 -3263
- package/dist/shared/components/McpConnectionScope.js +480 -0
- package/dist/shared/components/MyWorkView.js +223 -208
- package/dist/shared/components/RecordReadView.js +620 -572
- package/dist/shared/components/chat/ChatPanel.js +683 -671
- package/dist/shared/components/imports/DownloadSampleButton.js +69 -0
- package/dist/shared/components/imports/ImportConsole.js +106 -104
- package/dist/shared/components/imports/RunDetailSheet.js +11 -10
- package/dist/shared/components/item-edit/FieldAffordances.js +32 -32
- package/dist/shared/components/item-edit/FormTour.js +279 -0
- package/dist/shared/components/item-edit/GroupSection.js +377 -360
- package/dist/shared/components/item-edit/PersonalDefaultControl.js +80 -63
- package/dist/shared/components/item-edit/entry/EntryStrip.js +30 -26
- package/dist/shared/components/item-edit/form-density.js +36 -0
- package/dist/shared/components/item-edit/useFormUsageBeacon.js +59 -46
- package/dist/shared/components/item-edit/usePersonalDefaults.js +312 -296
- package/dist/shared/components/layout-editor/AddPanel.js +349 -192
- package/dist/shared/components/layout-editor/DesignNode.js +146 -131
- package/dist/shared/components/layout-editor/EditorCanvas.js +25 -17
- package/dist/shared/components/layout-editor/EditorTopBar.js +268 -206
- package/dist/shared/components/layout-editor/LayoutEditor.js +810 -731
- package/dist/shared/components/layout-editor/PlaceTools.js +334 -0
- package/dist/shared/components/layout-editor/SlashInsert.js +252 -0
- package/dist/shared/components/layout-editor/StructureMenu.js +285 -242
- package/dist/shared/components/layout-editor/add-target.js +54 -43
- package/dist/shared/components/layout-editor/ai-forms/AiComposer.js +238 -155
- package/dist/shared/components/layout-editor/ai-forms/AiFormsButton.js +1 -1
- package/dist/shared/components/layout-editor/ai-forms/ai-forms-api.js +15 -12
- package/dist/shared/components/layout-editor/dnd/LayoutDndProvider.js +379 -185
- package/dist/shared/components/layout-editor/dnd/TrashZone.js +96 -0
- package/dist/shared/components/layout-editor/dnd/UndoChip.js +76 -0
- package/dist/shared/components/layout-editor/dnd/merge-drop.js +33 -0
- package/dist/shared/components/layout-editor/dnd/multi-drop.js +87 -0
- package/dist/shared/components/layout-editor/dnd/node.js +115 -105
- package/dist/shared/components/layout-editor/dnd/rail-drop.js +4 -4
- package/dist/shared/components/layout-editor/dnd/sensors.js +23 -0
- package/dist/shared/components/layout-editor/dnd/trash-drop.js +58 -0
- package/dist/shared/components/layout-editor/dnd/trash-links.js +97 -0
- package/dist/shared/components/layout-editor/even-row.js +86 -0
- package/dist/shared/components/layout-editor/field-list.js +99 -0
- package/dist/shared/components/layout-editor/format-painter.js +102 -0
- package/dist/shared/components/layout-editor/grid-guides.js +15 -13
- package/dist/shared/components/layout-editor/inspector/BehaviourSettings.js +150 -132
- package/dist/shared/components/layout-editor/inspector/BulkInspector.js +57 -53
- package/dist/shared/components/layout-editor/inspector/EvenRowAction.js +31 -0
- package/dist/shared/components/layout-editor/inspector/GroupInspector.js +154 -141
- package/dist/shared/components/layout-editor/inspector/Inspector.js +209 -178
- package/dist/shared/components/layout-editor/inspector/LookTab.js +106 -98
- package/dist/shared/components/layout-editor/inspector/RulesTab.js +38 -37
- package/dist/shared/components/layout-editor/inspector/kit.js +280 -223
- package/dist/shared/components/layout-editor/keyboard-move.js +15 -15
- package/dist/shared/components/layout-editor/lint/LabelStyle.js +201 -0
- package/dist/shared/components/layout-editor/lint/LintPanel.js +132 -84
- package/dist/shared/components/layout-editor/lint/lint-api.js +65 -28
- package/dist/shared/components/layout-editor/nav/NavTools.js +14 -12
- package/dist/shared/components/layout-editor/nav/ZoomControls.js +145 -0
- package/dist/shared/components/layout-editor/nav/useEditorNav.js +34 -32
- package/dist/shared/components/layout-editor/nav/view-prefs.js +100 -15
- package/dist/shared/components/layout-editor/outputs/LayoutFile.js +89 -0
- package/dist/shared/components/layout-editor/outputs/OutputsButton.js +272 -195
- package/dist/shared/components/layout-editor/outputs/layout-file-plan.js +176 -0
- package/dist/shared/components/layout-editor/outputs/output-api.js +71 -37
- package/dist/shared/components/layout-editor/overview/describe-conditions.js +16 -11
- package/dist/shared/components/layout-editor/overview/purpose.js +5 -5
- package/dist/shared/components/layout-editor/panel-frame.js +1 -1
- package/dist/shared/components/layout-editor/parity-keys.json.js +1 -1
- package/dist/shared/components/layout-editor/personal-default-marks.js +40 -0
- package/dist/shared/components/layout-editor/pin.js +37 -19
- package/dist/shared/components/layout-editor/place-clip.js +257 -0
- package/dist/shared/components/layout-editor/preview/PreviewModes.js +27 -26
- package/dist/shared/components/layout-editor/preview/PreviewPanes.js +149 -118
- package/dist/shared/components/layout-editor/preview/SampleRecord.js +113 -0
- package/dist/shared/components/layout-editor/preview/preview-model.js +79 -60
- package/dist/shared/components/layout-editor/preview/sample-record.js +105 -0
- package/dist/shared/components/layout-editor/removed-log.js +151 -0
- package/dist/shared/components/layout-editor/reuse/LibraryRows.js +109 -78
- package/dist/shared/components/layout-editor/reuse/linked-sections.js +373 -0
- package/dist/shared/components/layout-editor/revert-element.js +140 -0
- package/dist/shared/components/layout-editor/section-structure.js +193 -170
- package/dist/shared/components/layout-editor/settings/EntrySection.js +63 -45
- package/dist/shared/components/layout-editor/settings/LayoutSection.js +63 -32
- package/dist/shared/components/layout-editor/settings/ResolveSettings.js +179 -137
- package/dist/shared/components/layout-editor/settings/WhoSection.js +18 -17
- package/dist/shared/components/layout-editor/settings/settings-registry.js +24 -0
- package/dist/shared/components/layout-editor/shortcuts.js +21 -16
- package/dist/shared/components/layout-editor/structure-ops.js +221 -195
- package/dist/shared/components/layout-editor/usage/UsagePanel.js +133 -85
- package/dist/shared/components/layout-editor/usage/refusal-lens.js +130 -0
- package/dist/shared/components/layout-editor/usage/usage-api.js +12 -11
- package/dist/shared/components/panels/CommentPanel.js +47 -45
- package/dist/shared/components/panels/RevisionsPanel.js +66 -64
- package/dist/shared/components/panels/TaskPanel.js +395 -332
- package/dist/shared/components/profile/AgentsPanel.js +196 -147
- package/dist/shared/components/profile/ConnectionRollback.js +329 -0
- package/dist/shared/components/profile/MyDefaultsCard.js +526 -520
- package/dist/shared/lib/entry-config.js +22 -22
- package/dist/shared/lib/form-usage-beacon.js +91 -55
- package/dist/shared/lib/layout-lint.js +530 -284
- package/dist/shared/lib/layout-resolve.js +58 -44
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { jsx as s, jsxs as h, Fragment as
|
|
2
|
-
import { Copy as Q, History as
|
|
1
|
+
import { jsx as s, jsxs as h, Fragment as me } from "react/jsx-runtime";
|
|
2
|
+
import { Copy as Q, History as fe, Eye as be, Sigma as pe, ExternalLink as xe, UserRound as ye, UserRoundPen as he, UserRoundX as ge, Lock as ke, X as ne } from "lucide-react";
|
|
3
3
|
import { useContext as we, createContext as ve, useState as C, useCallback as N, useRef as M, useEffect as B, useLayoutEffect as Ne } from "react";
|
|
4
4
|
import { createPortal as Ce } from "react-dom";
|
|
5
5
|
import { toast as v } from "sonner";
|
|
@@ -131,16 +131,16 @@ function qe({
|
|
|
131
131
|
field: t,
|
|
132
132
|
value: o,
|
|
133
133
|
relations: l,
|
|
134
|
-
collection:
|
|
134
|
+
collection: f,
|
|
135
135
|
itemId: x,
|
|
136
136
|
openRelated: w,
|
|
137
137
|
editable: R = !1
|
|
138
138
|
}) {
|
|
139
139
|
var J, z;
|
|
140
|
-
const [g, T] = C(null), r = Fe(), [k, S] = C(!1), [y, O] = C(null), [U, A] = C(null), [$, j] = C(!1), b = N((e, c) => T({ x: e, y: c }), []), [D, a] = C(null),
|
|
140
|
+
const [g, T] = C(null), r = Fe(), [k, S] = C(!1), [y, O] = C(null), [U, A] = C(null), [$, j] = C(!1), b = N((e, c) => T({ x: e, y: c }), []), [D, a] = C(null), m = M(null), L = M(null), i = N(() => {
|
|
141
141
|
T(null), a(null), S(!1), O(null), A(null), j(!1);
|
|
142
|
-
const e =
|
|
143
|
-
|
|
142
|
+
const e = m.current, c = L.current;
|
|
143
|
+
m.current = null, L.current = null, (e || c) && window.setTimeout(() => {
|
|
144
144
|
var u;
|
|
145
145
|
document.activeElement && document.activeElement !== document.body || (e != null && e.isConnected ? e.focus() : (u = c == null ? void 0 : c()) == null || u.focus());
|
|
146
146
|
}, 0);
|
|
@@ -151,7 +151,7 @@ function qe({
|
|
|
151
151
|
return;
|
|
152
152
|
}
|
|
153
153
|
const c = e.getBoundingClientRect();
|
|
154
|
-
_.current = null,
|
|
154
|
+
_.current = null, m.current = e, a("menu"), b(c.left, c.bottom + 4);
|
|
155
155
|
},
|
|
156
156
|
[p, i, b]
|
|
157
157
|
), E = N(() => {
|
|
@@ -171,7 +171,7 @@ function qe({
|
|
|
171
171
|
return;
|
|
172
172
|
}
|
|
173
173
|
const F = e.getBoundingClientRect();
|
|
174
|
-
_.current = null,
|
|
174
|
+
_.current = null, m.current = e, L.current = c ?? null, a(u), u === "update" ? P() : E(), b(F.right - ae, F.bottom + 4);
|
|
175
175
|
},
|
|
176
176
|
[p, D, i, b, E, P]
|
|
177
177
|
), _ = M(null), oe = N(
|
|
@@ -192,12 +192,12 @@ function qe({
|
|
|
192
192
|
},
|
|
193
193
|
[b, n]
|
|
194
194
|
), I = l.find(
|
|
195
|
-
(e) => e.many_collection ===
|
|
195
|
+
(e) => e.many_collection === f && e.many_field === t.field && e.one_collection
|
|
196
196
|
), K = x && x !== "new", W = (e) => {
|
|
197
197
|
var u;
|
|
198
198
|
const c = (u = n.current) == null ? void 0 : u.querySelector(e);
|
|
199
199
|
return c ? (c.click(), !0) : !1;
|
|
200
|
-
}, V = !!(r != null && r.allowed(t.field)), X = V && R && !!(r != null && r.hasValue(t.field)), G = V ? (r == null ? void 0 : r.defaultFor(t.field)) ?? null : null, se = X && !G, ie = X && !!G && !(r != null && r.isDefault(t.field)), Y = [
|
|
200
|
+
}, V = !!(r != null && r.allowed(t.field)) && r.manageable(t.field), X = V && R && !!(r != null && r.hasValue(t.field)), G = V ? (r == null ? void 0 : r.defaultFor(t.field)) ?? null : null, se = X && !G, ie = X && !!G && !(r != null && r.isDefault(t.field)), Y = [
|
|
201
201
|
{
|
|
202
202
|
key: "copy",
|
|
203
203
|
label: "Copy value",
|
|
@@ -229,7 +229,7 @@ function qe({
|
|
|
229
229
|
{
|
|
230
230
|
key: "history",
|
|
231
231
|
label: "Value history",
|
|
232
|
-
icon: /* @__PURE__ */ s(
|
|
232
|
+
icon: /* @__PURE__ */ s(fe, { className: "h-3.5 w-3.5" }),
|
|
233
233
|
disabled: !K,
|
|
234
234
|
run: () => {
|
|
235
235
|
W("[data-field-history]") || v.info("No history for this field yet");
|
|
@@ -364,7 +364,7 @@ function Oe({
|
|
|
364
364
|
items: t,
|
|
365
365
|
onClose: o,
|
|
366
366
|
confirm: l,
|
|
367
|
-
anchor:
|
|
367
|
+
anchor: f
|
|
368
368
|
}) {
|
|
369
369
|
Ue();
|
|
370
370
|
const x = M(null), [w, R] = C(0), g = t.filter((a) => !a.disabled);
|
|
@@ -373,8 +373,8 @@ function Oe({
|
|
|
373
373
|
const a = (i) => {
|
|
374
374
|
var d, E;
|
|
375
375
|
const p = i.target;
|
|
376
|
-
(d = x.current) != null && d.contains(p) || (E = p == null ? void 0 : p.closest) != null && E.call(p, $e) && (
|
|
377
|
-
},
|
|
376
|
+
(d = x.current) != null && d.contains(p) || (E = p == null ? void 0 : p.closest) != null && E.call(p, $e) && (f != null && f.contains(p)) || o();
|
|
377
|
+
}, m = (i) => {
|
|
378
378
|
var p;
|
|
379
379
|
if (i.key === "Escape")
|
|
380
380
|
i.preventDefault(), o();
|
|
@@ -399,27 +399,27 @@ function Oe({
|
|
|
399
399
|
d && (d.run(), d.stay || o());
|
|
400
400
|
}
|
|
401
401
|
};
|
|
402
|
-
return window.addEventListener("mousedown", a, !0), window.addEventListener("keydown",
|
|
403
|
-
window.removeEventListener("mousedown", a, !0), window.removeEventListener("keydown",
|
|
402
|
+
return window.addEventListener("mousedown", a, !0), window.addEventListener("keydown", m, !0), (L = x.current) == null || L.focus(), () => {
|
|
403
|
+
window.removeEventListener("mousedown", a, !0), window.removeEventListener("keydown", m, !0);
|
|
404
404
|
};
|
|
405
|
-
}, [o, g, w, l,
|
|
405
|
+
}, [o, g, w, l, f]);
|
|
406
406
|
const T = M(null), r = M(null), k = !!l, S = !!(l != null && l.ready);
|
|
407
407
|
B(() => {
|
|
408
408
|
var a;
|
|
409
409
|
k && ((a = r.current) == null || a.focus());
|
|
410
410
|
}, [k]), B(() => {
|
|
411
|
-
var
|
|
411
|
+
var m;
|
|
412
412
|
if (!S) return;
|
|
413
413
|
const a = document.activeElement;
|
|
414
|
-
(a === r.current || a === x.current || a === document.body) && ((
|
|
414
|
+
(a === r.current || a === x.current || a === document.body) && ((m = T.current) == null || m.focus());
|
|
415
415
|
}, [S]);
|
|
416
416
|
const y = Math.min(ae, window.innerWidth - 16), O = Ee(l == null ? void 0 : l.text), [U, A] = C(() => l ? 96 : t.length * 30 + 12);
|
|
417
417
|
Ne(() => {
|
|
418
|
-
var
|
|
419
|
-
const a = (
|
|
418
|
+
var m;
|
|
419
|
+
const a = (m = x.current) == null ? void 0 : m.offsetHeight;
|
|
420
420
|
a && a !== U && A(a);
|
|
421
421
|
});
|
|
422
|
-
const $ = Math.max(8, Math.min(n.x, window.innerWidth - y - 8)), j = Math.max(8, Math.min(n.y, window.innerHeight - U - 8)), b = (
|
|
422
|
+
const $ = Math.max(8, Math.min(n.x, window.innerWidth - y - 8)), j = Math.max(8, Math.min(n.y, window.innerHeight - U - 8)), b = (f == null ? void 0 : f.closest('[role="dialog"]')) ?? document.body, D = b === document.body ? { position: "fixed", left: $, top: j } : (() => {
|
|
423
423
|
const a = b.getBoundingClientRect();
|
|
424
424
|
return {
|
|
425
425
|
position: "absolute",
|
|
@@ -476,14 +476,14 @@ function Oe({
|
|
|
476
476
|
] })
|
|
477
477
|
] }) : null,
|
|
478
478
|
l ? null : t.map((a) => {
|
|
479
|
-
const
|
|
479
|
+
const m = g.indexOf(a), L = m === w && !a.disabled;
|
|
480
480
|
return /* @__PURE__ */ h(
|
|
481
481
|
"button",
|
|
482
482
|
{
|
|
483
483
|
type: "button",
|
|
484
484
|
role: "menuitem",
|
|
485
485
|
disabled: a.disabled,
|
|
486
|
-
onMouseEnter: () =>
|
|
486
|
+
onMouseEnter: () => m >= 0 && R(m),
|
|
487
487
|
onClick: () => {
|
|
488
488
|
a.run(), a.stay || o();
|
|
489
489
|
},
|
|
@@ -508,7 +508,7 @@ function Oe({
|
|
|
508
508
|
);
|
|
509
509
|
}
|
|
510
510
|
function Je(n) {
|
|
511
|
-
const [t, o] = C(null), [l,
|
|
511
|
+
const [t, o] = C(null), [l, f] = C(!1), x = M(!1), w = M(null);
|
|
512
512
|
B(() => {
|
|
513
513
|
const r = n.current;
|
|
514
514
|
if (!r) return;
|
|
@@ -517,7 +517,7 @@ function Je(n) {
|
|
|
517
517
|
const S = new MutationObserver(k);
|
|
518
518
|
return S.observe(r, { attributes: !0, attributeFilter: ["data-remote-editor"] }), () => S.disconnect();
|
|
519
519
|
}, [n]), B(() => {
|
|
520
|
-
t || (
|
|
520
|
+
t || (f(!1), x.current = !1);
|
|
521
521
|
}, [t]);
|
|
522
522
|
const R = N(
|
|
523
523
|
(r) => {
|
|
@@ -525,15 +525,15 @@ function Je(n) {
|
|
|
525
525
|
const k = r.target;
|
|
526
526
|
k.matches('input, textarea, select, [contenteditable="true"], [role="combobox"]') && (w.current = k, setTimeout(() => {
|
|
527
527
|
x.current || k.blur();
|
|
528
|
-
}, 0),
|
|
528
|
+
}, 0), f(!0));
|
|
529
529
|
},
|
|
530
530
|
[t]
|
|
531
531
|
), g = N(() => {
|
|
532
|
-
x.current = !0,
|
|
532
|
+
x.current = !0, f(!1);
|
|
533
533
|
const r = w.current;
|
|
534
534
|
w.current = null, r && setTimeout(() => r.focus(), 0);
|
|
535
535
|
}, []), T = N(() => {
|
|
536
|
-
|
|
536
|
+
f(!1), w.current = null;
|
|
537
537
|
}, []);
|
|
538
538
|
return { editor: t, confirming: l, onFocusCapture: R, confirm: g, cancel: T };
|
|
539
539
|
}
|
|
@@ -543,7 +543,7 @@ function ze({
|
|
|
543
543
|
onConfirm: o,
|
|
544
544
|
onCancel: l
|
|
545
545
|
}) {
|
|
546
|
-
const
|
|
546
|
+
const f = n.split(/\s+/).map((x) => x[0]).filter(Boolean).slice(0, 2).join("").toUpperCase();
|
|
547
547
|
return /* @__PURE__ */ h(
|
|
548
548
|
"div",
|
|
549
549
|
{
|
|
@@ -553,9 +553,9 @@ function ze({
|
|
|
553
553
|
t ? "border border-amber-300 bg-amber-50 text-amber-900 dark:border-amber-500/40 dark:bg-amber-500/10 dark:text-amber-100" : "text-amber-700 dark:text-amber-300"
|
|
554
554
|
),
|
|
555
555
|
children: [
|
|
556
|
-
/* @__PURE__ */ s("span", { className: "inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-amber-200 text-[9px] font-semibold text-amber-900 dark:bg-amber-500/40 dark:text-amber-50", children:
|
|
556
|
+
/* @__PURE__ */ s("span", { className: "inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-amber-200 text-[9px] font-semibold text-amber-900 dark:bg-amber-500/40 dark:text-amber-50", children: f || "?" }),
|
|
557
557
|
/* @__PURE__ */ s("span", { className: "min-w-0 flex-1", children: t ? `${n} is typing here — edit anyway?` : `${n} is editing this field` }),
|
|
558
|
-
t && /* @__PURE__ */ h(
|
|
558
|
+
t && /* @__PURE__ */ h(me, { children: [
|
|
559
559
|
/* @__PURE__ */ s(
|
|
560
560
|
"button",
|
|
561
561
|
{
|
|
@@ -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
|
+
};
|