@nivaro/react 0.2.53 → 0.2.54
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/full.css +1 -1
- package/dist/hooks/useSessionRecorder.js +1 -1
- package/dist/index.d.ts +113 -2
- package/dist/layout-editor.d.ts +248 -2
- package/dist/shared/components/FormWhatsNew.js +60 -0
- package/dist/shared/components/ItemEditForm.js +4058 -3942
- package/dist/shared/components/RecordReadView.js +219 -211
- package/dist/shared/components/TipLayer.js +27 -27
- package/dist/shared/components/help-videos/api.js +51 -41
- package/dist/shared/components/help-videos/editor/DetailsTab.js +147 -130
- package/dist/shared/components/item-edit/FieldAffordances.js +7 -6
- package/dist/shared/components/item-edit/FieldRow.js +353 -304
- package/dist/shared/components/item-edit/FormHelpVideoButton.js +59 -0
- package/dist/shared/components/item-edit/GroupSection.js +419 -396
- package/dist/shared/components/item-edit/HeaderTools.js +59 -56
- package/dist/shared/components/item-edit/LayoutContentBlock.js +47 -24
- package/dist/shared/components/item-edit/lock-why.js +87 -0
- package/dist/shared/components/item-edit/useFormUsageBeacon.js +59 -0
- package/dist/shared/components/layout-editor/AddPanel.js +204 -146
- package/dist/shared/components/layout-editor/ArrangeButton.js +34 -0
- package/dist/shared/components/layout-editor/AutoArrange.js +86 -0
- package/dist/shared/components/layout-editor/CanvasCompare.js +79 -0
- package/dist/shared/components/layout-editor/ChangeNote.js +146 -0
- package/dist/shared/components/layout-editor/CollabParts.js +170 -0
- package/dist/shared/components/layout-editor/DesignNode.js +304 -115
- package/dist/shared/components/layout-editor/EditorCanvas.js +21 -20
- package/dist/shared/components/layout-editor/EditorTopBar.js +452 -175
- package/dist/shared/components/layout-editor/FindReplace.js +188 -0
- package/dist/shared/components/layout-editor/FormMapButton.js +141 -0
- package/dist/shared/components/layout-editor/HistoryPanel.js +234 -109
- package/dist/shared/components/layout-editor/LayoutEditor.js +1101 -307
- package/dist/shared/components/layout-editor/LayoutsRail.js +94 -67
- package/dist/shared/components/layout-editor/NoteMarker.js +38 -0
- package/dist/shared/components/layout-editor/PlacementsTable.js +187 -0
- package/dist/shared/components/layout-editor/ScheduleChange.js +106 -0
- package/dist/shared/components/layout-editor/SessionHistory.js +84 -0
- package/dist/shared/components/layout-editor/StructureMenu.js +413 -0
- package/dist/shared/components/layout-editor/UnsavedConfirm.js +103 -0
- package/dist/shared/components/layout-editor/ai/AiToolsButton.js +625 -0
- package/dist/shared/components/layout-editor/ai/ChangeCheck.js +153 -0
- package/dist/shared/components/layout-editor/ai/ai-tools-api.js +80 -0
- package/dist/shared/components/layout-editor/ai/assist-ops.js +38 -0
- package/dist/shared/components/layout-editor/ai/autofill-ops.js +73 -0
- package/dist/shared/components/layout-editor/ai/canvas-capture.js +41 -0
- package/dist/shared/components/layout-editor/ai-forms/AiComposer.js +271 -0
- package/dist/shared/components/layout-editor/ai-forms/AiFormsButton.js +182 -0
- package/dist/shared/components/layout-editor/ai-forms/MeaningSuggestions.js +109 -0
- package/dist/shared/components/layout-editor/ai-forms/SlimPanel.js +170 -0
- package/dist/shared/components/layout-editor/ai-forms/ai-forms-api.js +40 -0
- package/dist/shared/components/layout-editor/ai-forms/pending.js +25 -0
- package/dist/shared/components/layout-editor/ai-forms/plan.js +263 -0
- package/dist/shared/components/layout-editor/ai-rules/AiAskPopover.js +160 -0
- package/dist/shared/components/layout-editor/ai-rules/CascadeWriter.js +175 -0
- package/dist/shared/components/layout-editor/ai-rules/FieldRuleWriter.js +97 -0
- package/dist/shared/components/layout-editor/ai-rules/RuleWriter.js +94 -0
- package/dist/shared/components/layout-editor/ai-rules/ValidationSuggest.js +153 -0
- package/dist/shared/components/layout-editor/ai-rules/api.js +6 -0
- package/dist/shared/components/layout-editor/ai-text/AiTextTools.js +383 -0
- package/dist/shared/components/layout-editor/ai-text/text-ops.js +125 -0
- package/dist/shared/components/layout-editor/assist/AskPanel.js +278 -0
- package/dist/shared/components/layout-editor/assist/ExplainDiff.js +93 -0
- package/dist/shared/components/layout-editor/assist/ProposalsButton.js +150 -0
- package/dist/shared/components/layout-editor/assist/assist-api.js +63 -0
- package/dist/shared/components/layout-editor/assist/jump.js +142 -0
- package/dist/shared/components/layout-editor/assist/settings-index.js +118 -0
- package/dist/shared/components/layout-editor/auto-arrange.js +101 -0
- package/dist/shared/components/layout-editor/bulk/BulkChangesButton.js +221 -0
- package/dist/shared/components/layout-editor/bulk/BulkRun.js +237 -0
- package/dist/shared/components/layout-editor/bulk/MacrosPanel.js +230 -0
- package/dist/shared/components/layout-editor/bulk/bulk-api.js +65 -0
- package/dist/shared/components/layout-editor/bulk/field-labels.js +22 -0
- package/dist/shared/components/layout-editor/bulk/macro-record.js +142 -0
- package/dist/shared/components/layout-editor/bulk/useMacroRecorder.js +65 -0
- package/dist/shared/components/layout-editor/bundle-to-active.js +1 -0
- package/dist/shared/components/layout-editor/canvas-diff.js +157 -0
- package/dist/shared/components/layout-editor/collab/FormFollowShare.js +342 -0
- package/dist/shared/components/layout-editor/collab/collab-api.js +77 -0
- package/dist/shared/components/layout-editor/commands/CommandPalette.js +221 -0
- package/dist/shared/components/layout-editor/commands/intents.js +214 -0
- package/dist/shared/components/layout-editor/commands/parse.js +242 -0
- package/dist/shared/components/layout-editor/design-context.js +26 -6
- package/dist/shared/components/layout-editor/dnd/LayoutDndProvider.js +179 -163
- package/dist/shared/components/layout-editor/dnd/collision.js +25 -23
- package/dist/shared/components/layout-editor/dnd/rail-drop.js +56 -0
- package/dist/shared/components/layout-editor/draft-recovery.js +61 -0
- package/dist/shared/components/layout-editor/editor-notes.js +78 -0
- package/dist/shared/components/layout-editor/editors/swap-config.js +1 -0
- package/dist/shared/components/layout-editor/explain/CanvasRules.js +142 -0
- package/dist/shared/components/layout-editor/explain/default-ghosts.js +81 -0
- package/dist/shared/components/layout-editor/explain/driver-hover.js +62 -0
- package/dist/shared/components/layout-editor/explain/field-sources.js +246 -0
- package/dist/shared/components/layout-editor/explain/rule-graph.js +215 -0
- package/dist/shared/components/layout-editor/explain/use-explain.js +132 -0
- package/dist/shared/components/layout-editor/field-zones.js +116 -0
- package/dist/shared/components/layout-editor/form-map.js +138 -0
- package/dist/shared/components/layout-editor/history-api.js +87 -0
- package/dist/shared/components/layout-editor/inheritance.js +55 -0
- package/dist/shared/components/layout-editor/inspect/inspect-api.js +66 -0
- package/dist/shared/components/layout-editor/inspect/picker-preview.js +48 -0
- package/dist/shared/components/layout-editor/inspect/width-fit.js +87 -0
- package/dist/shared/components/layout-editor/inspector/AiFillSetting.js +85 -0
- package/dist/shared/components/layout-editor/inspector/Breadcrumb.js +36 -0
- package/dist/shared/components/layout-editor/inspector/BulkInspector.js +175 -0
- package/dist/shared/components/layout-editor/inspector/ColumnFit.js +112 -0
- package/dist/shared/components/layout-editor/inspector/GroupInspector.js +146 -92
- package/dist/shared/components/layout-editor/inspector/HelpTab.js +174 -0
- package/dist/shared/components/layout-editor/inspector/Inspector.js +256 -175
- package/dist/shared/components/layout-editor/inspector/LookTab.js +46 -40
- package/dist/shared/components/layout-editor/inspector/OverrideNotice.js +61 -0
- package/dist/shared/components/layout-editor/inspector/PickerPreview.js +134 -0
- package/dist/shared/components/layout-editor/inspector/PickerTab.js +167 -141
- package/dist/shared/components/layout-editor/inspector/RulesTab.js +175 -128
- package/dist/shared/components/layout-editor/inspector/Translations.js +156 -0
- package/dist/shared/components/layout-editor/inspector/kit.js +3 -3
- package/dist/shared/components/layout-editor/inspector/tab-request.js +21 -0
- package/dist/shared/components/layout-editor/is-typing.js +9 -0
- package/dist/shared/components/layout-editor/keyboard-move.js +66 -0
- package/dist/shared/components/layout-editor/lint/LintPanel.js +190 -0
- package/dist/shared/components/layout-editor/lint/lint-api.js +52 -0
- package/dist/shared/components/layout-editor/load-error.js +37 -0
- package/dist/shared/components/layout-editor/matrix/FieldStateMatrix.js +305 -0
- package/dist/shared/components/layout-editor/matrix/MatrixGrid.js +181 -0
- package/dist/shared/components/layout-editor/matrix/RoleSectionMatrix.js +147 -0
- package/dist/shared/components/layout-editor/matrix/matrix-api.js +48 -0
- package/dist/shared/components/layout-editor/matrix/role-matrix.js +36 -0
- package/dist/shared/components/layout-editor/matrix/state-matrix.js +145 -0
- package/dist/shared/components/layout-editor/nav/FindPanel.js +109 -0
- package/dist/shared/components/layout-editor/nav/NavTools.js +114 -0
- package/dist/shared/components/layout-editor/nav/OutlinePanel.js +228 -0
- package/dist/shared/components/layout-editor/nav/ShortcutSheet.js +31 -0
- package/dist/shared/components/layout-editor/nav/find.js +20 -0
- package/dist/shared/components/layout-editor/nav/tree.js +142 -0
- package/dist/shared/components/layout-editor/nav/useEditorNav.js +101 -0
- package/dist/shared/components/layout-editor/nav/view-prefs.js +34 -0
- package/dist/shared/components/layout-editor/ops/ChangeRequestsPanel.js +143 -0
- package/dist/shared/components/layout-editor/ops/DependencyDiagram.js +179 -0
- package/dist/shared/components/layout-editor/ops/LayoutOpsBlocks.js +92 -0
- package/dist/shared/components/layout-editor/ops/PromotePanel.js +287 -0
- package/dist/shared/components/layout-editor/ops/ops-api.js +122 -0
- package/dist/shared/components/layout-editor/overview/OverviewActions.js +15 -3
- package/dist/shared/components/layout-editor/overview/describe-conditions.js +18 -14
- package/dist/shared/components/layout-editor/overview/overview-api.js +105 -88
- package/dist/shared/components/layout-editor/panel-style.js +8 -7
- package/dist/shared/components/layout-editor/parity-keys.json.js +4 -0
- package/dist/shared/components/layout-editor/pin.js +25 -0
- package/dist/shared/components/layout-editor/presence.js +111 -0
- package/dist/shared/components/layout-editor/preview/PreviewModes.js +224 -0
- package/dist/shared/components/layout-editor/preview/PreviewPanes.js +262 -0
- package/dist/shared/components/layout-editor/preview/preview-api.js +57 -0
- package/dist/shared/components/layout-editor/preview/preview-model.js +157 -0
- package/dist/shared/components/layout-editor/reuse/FieldMapStep.js +70 -0
- package/dist/shared/components/layout-editor/reuse/FormMoreMenu.js +127 -0
- package/dist/shared/components/layout-editor/reuse/LibraryRows.js +150 -0
- package/dist/shared/components/layout-editor/reuse/NewFormStart.js +20 -0
- package/dist/shared/components/layout-editor/reuse/SectionReuseActions.js +291 -0
- package/dist/shared/components/layout-editor/reuse/field-match.js +77 -0
- package/dist/shared/components/layout-editor/reuse/reuse-api.js +73 -0
- package/dist/shared/components/layout-editor/reuse/seed.js +13 -0
- package/dist/shared/components/layout-editor/reuse/useFormFromRecord.js +43 -0
- package/dist/shared/components/layout-editor/reuse/useRailCopy.js +34 -0
- package/dist/shared/components/layout-editor/settings/FormSettings.js +123 -103
- package/dist/shared/components/layout-editor/settings/InheritanceSection.js +1 -1
- package/dist/shared/components/layout-editor/settings/ToolsSection.js +174 -100
- package/dist/shared/components/layout-editor/settings/WhoSection.js +136 -100
- package/dist/shared/components/layout-editor/settings/controls.js +8 -8
- package/dist/shared/components/layout-editor/settings/settings-registry.js +35 -11
- package/dist/shared/components/layout-editor/shortcuts.js +88 -0
- package/dist/shared/components/layout-editor/show-when.js +35 -0
- package/dist/shared/components/layout-editor/slot-names.js +4 -3
- package/dist/shared/components/layout-editor/structure-ops.js +399 -0
- package/dist/shared/components/layout-editor/testing/CostLimitSetting.js +42 -0
- package/dist/shared/components/layout-editor/testing/TestingPanels.js +551 -0
- package/dist/shared/components/layout-editor/testing/testing-api.js +67 -0
- package/dist/shared/components/layout-editor/testing/testing-model.js +393 -0
- package/dist/shared/components/layout-editor/testing/use-record-check.js +44 -0
- package/dist/shared/components/layout-editor/toolbar-kit.js +242 -0
- package/dist/shared/components/layout-editor/unsaved-marks.js +72 -0
- package/dist/shared/components/layout-editor/usage/FillChip.js +27 -0
- package/dist/shared/components/layout-editor/usage/UsagePanel.js +158 -0
- package/dist/shared/components/layout-editor/usage/suggest-sections.js +55 -0
- package/dist/shared/components/layout-editor/usage/usage-api.js +104 -0
- package/dist/shared/components/layout-editor/useLayoutDraft.js +573 -307
- package/dist/shared/components/support/SuggestFormChange.js +143 -0
- package/dist/shared/lib/ai-fill.js +37 -0
- package/dist/shared/lib/form-usage-beacon.js +84 -0
- package/dist/shared/lib/layout-i18n.js +66 -0
- package/dist/shared/lib/layout-lint.js +490 -0
- package/dist/shared/lib/layout-ops.js +110 -106
- package/dist/shared/lib/screenshot.js +54 -28
- package/dist/shared/lib/visible-when.js +34 -0
- package/package.json +1 -1
|
@@ -1,43 +1,53 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useQueryClient as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { jsxs as s, jsx as a, Fragment as X } from "react/jsx-runtime";
|
|
2
|
+
import { useQueryClient as Z, useQuery as M, useMutation as U } from "@tanstack/react-query";
|
|
3
|
+
import { Bookmark as Q } from "lucide-react";
|
|
4
|
+
import { useState as h } from "react";
|
|
5
|
+
import { toast as G } from "sonner";
|
|
6
|
+
import { useNivaroClient as I } from "../../context.js";
|
|
7
|
+
import { get as P, post as ee } from "../../lib/commands.js";
|
|
8
|
+
import { ExplainDiffButton as te } from "./assist/ExplainDiff.js";
|
|
9
|
+
import { useVersionNaming as ae, fetchVersionBundle as ne } from "./history-api.js";
|
|
10
|
+
import { SessionHistory as re } from "./SessionHistory.js";
|
|
11
|
+
import { slotName as se } from "./slot-names.js";
|
|
12
|
+
import { layoutDraftKeys as A, parseSaveFailure as R } from "./useLayoutDraft.js";
|
|
13
|
+
function oe(t) {
|
|
14
|
+
return /^before\b/i.test(t) ? t : `Before: ${t}`;
|
|
9
15
|
}
|
|
10
|
-
const
|
|
11
|
-
function
|
|
12
|
-
if (
|
|
13
|
-
if (typeof
|
|
14
|
-
const
|
|
15
|
-
return
|
|
16
|
+
const V = A.versions, ie = A.bundle;
|
|
17
|
+
function N(t) {
|
|
18
|
+
if (t == null || t === "") return "empty";
|
|
19
|
+
if (typeof t == "object") {
|
|
20
|
+
const r = JSON.stringify(t);
|
|
21
|
+
return r.length > 60 ? `${r.slice(0, 57)}…` : r;
|
|
16
22
|
}
|
|
17
|
-
return String(
|
|
23
|
+
return String(t);
|
|
18
24
|
}
|
|
19
|
-
const
|
|
20
|
-
function
|
|
21
|
-
const
|
|
22
|
-
for (const
|
|
23
|
-
|
|
24
|
-
for (const
|
|
25
|
-
for (const
|
|
26
|
-
for (const
|
|
27
|
-
|
|
28
|
-
for (const
|
|
29
|
-
for (const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
25
|
+
const D = (t) => t.map((r) => `${r.field} ${N(r.from)} → ${N(r.to)}`), F = (t) => t.startsWith("__") ? se(t) : t;
|
|
26
|
+
function le(t) {
|
|
27
|
+
const r = [];
|
|
28
|
+
for (const n of t.layout)
|
|
29
|
+
r.push({ kind: "Form", text: `${n.field}: ${N(n.from)} → ${N(n.to)}` });
|
|
30
|
+
for (const n of t.groups.added) r.push({ kind: "Group added", text: n });
|
|
31
|
+
for (const n of t.groups.removed) r.push({ kind: "Group removed", text: n });
|
|
32
|
+
for (const n of t.groups.changed)
|
|
33
|
+
r.push({ kind: "Group", text: `${n.label}: ${D(n.changes).join(" · ")}` });
|
|
34
|
+
for (const n of t.assignments.added) r.push({ kind: "Field added", text: F(n) });
|
|
35
|
+
for (const n of t.assignments.removed)
|
|
36
|
+
r.push({ kind: "Field removed", text: F(n) });
|
|
37
|
+
for (const n of t.assignments.changed)
|
|
38
|
+
r.push({
|
|
39
|
+
kind: "Field",
|
|
40
|
+
text: `${F(n.label)}: ${D(n.changes).join(" · ")}`
|
|
41
|
+
});
|
|
42
|
+
return r;
|
|
33
43
|
}
|
|
34
|
-
function
|
|
35
|
-
const [
|
|
36
|
-
if (
|
|
37
|
-
return /* @__PURE__ */
|
|
38
|
-
const
|
|
39
|
-
return /* @__PURE__ */
|
|
40
|
-
|
|
44
|
+
function de({ diff: t }) {
|
|
45
|
+
const [r, n] = h(!1);
|
|
46
|
+
if (t.total === 0)
|
|
47
|
+
return /* @__PURE__ */ a("p", { className: "mt-1 text-[12px] text-slate-500 dark:text-slate-400", children: "Nothing differs from that version. The form is exactly as it was saved." });
|
|
48
|
+
const l = le(t), x = r ? l : l.slice(0, 12);
|
|
49
|
+
return /* @__PURE__ */ s("div", { className: "mt-1", children: [
|
|
50
|
+
t.warnings.map((o) => /* @__PURE__ */ a(
|
|
41
51
|
"p",
|
|
42
52
|
{
|
|
43
53
|
"data-layout-diff-warning": !0,
|
|
@@ -46,134 +56,249 @@ function Q({ diff: e }) {
|
|
|
46
56
|
},
|
|
47
57
|
o
|
|
48
58
|
)),
|
|
49
|
-
/* @__PURE__ */
|
|
50
|
-
|
|
59
|
+
/* @__PURE__ */ s("p", { className: "text-[12px] text-slate-500 dark:text-slate-400", children: [
|
|
60
|
+
t.total,
|
|
51
61
|
" change",
|
|
52
|
-
|
|
53
|
-
|
|
62
|
+
t.total === 1 ? "" : "s",
|
|
63
|
+
t.from.created_at ? ` since ${new Date(t.from.created_at).toLocaleString()}` : ""
|
|
54
64
|
] }),
|
|
55
|
-
/* @__PURE__ */
|
|
65
|
+
/* @__PURE__ */ a("ul", { className: "mt-1 space-y-0.5", children: x.map((o, d) => (
|
|
56
66
|
// biome-ignore lint/suspicious/noArrayIndexKey: ordered diff rows
|
|
57
|
-
/* @__PURE__ */
|
|
58
|
-
/* @__PURE__ */
|
|
59
|
-
/* @__PURE__ */
|
|
60
|
-
] },
|
|
67
|
+
/* @__PURE__ */ s("li", { className: "flex gap-2 text-[12px]", children: [
|
|
68
|
+
/* @__PURE__ */ a("span", { className: "w-24 shrink-0 text-[11px] text-slate-500 dark:text-slate-400", children: o.kind }),
|
|
69
|
+
/* @__PURE__ */ a("span", { className: "min-w-0 break-words text-slate-700 dark:text-slate-200", children: o.text })
|
|
70
|
+
] }, d)
|
|
61
71
|
)) }),
|
|
62
|
-
|
|
72
|
+
l.length > 12 && /* @__PURE__ */ a(
|
|
63
73
|
"button",
|
|
64
74
|
{
|
|
65
75
|
type: "button",
|
|
66
|
-
onClick: () =>
|
|
76
|
+
onClick: () => n((o) => !o),
|
|
67
77
|
className: "mt-1 text-[11px] text-slate-500 underline dark:text-slate-400",
|
|
68
|
-
children:
|
|
78
|
+
children: r ? "Show fewer" : `Show all ${l.length}`
|
|
69
79
|
}
|
|
70
80
|
)
|
|
71
81
|
] });
|
|
72
82
|
}
|
|
73
|
-
function
|
|
74
|
-
layoutId:
|
|
75
|
-
onRestored:
|
|
83
|
+
function ve({
|
|
84
|
+
layoutId: t,
|
|
85
|
+
onRestored: r,
|
|
86
|
+
unsavedCount: n = 0,
|
|
87
|
+
onDiscardUnsaved: l,
|
|
88
|
+
session: x,
|
|
89
|
+
onJump: o,
|
|
90
|
+
onShowOnCanvas: d
|
|
76
91
|
}) {
|
|
77
|
-
const
|
|
78
|
-
queryKey:
|
|
79
|
-
queryFn: () =>
|
|
92
|
+
const g = I(), k = Z(), [f, _] = h(null), [H, v] = h(null), { data: c = [], isLoading: O } = M({
|
|
93
|
+
queryKey: V(t),
|
|
94
|
+
queryFn: () => g.request(P(`/collection-layouts/${t}/versions`)).then((e) => e.data ?? []),
|
|
80
95
|
staleTime: 0,
|
|
81
96
|
refetchOnMount: "always"
|
|
82
|
-
}),
|
|
83
|
-
queryKey: ["layout-editor", "version-diff",
|
|
84
|
-
queryFn: () =>
|
|
85
|
-
|
|
86
|
-
).then((
|
|
87
|
-
enabled:
|
|
97
|
+
}), m = f ?? (c.length > 0 ? "newest" : null), { data: u, isLoading: W } = M({
|
|
98
|
+
queryKey: ["layout-editor", "version-diff", t, m],
|
|
99
|
+
queryFn: () => g.request(
|
|
100
|
+
P(`/collection-layouts/${t}/versions/${m}/diff`, { against: "current" })
|
|
101
|
+
).then((e) => e.data),
|
|
102
|
+
enabled: m != null,
|
|
88
103
|
staleTime: 0,
|
|
89
104
|
refetchOnMount: "always"
|
|
90
|
-
}),
|
|
91
|
-
mutationFn: (
|
|
105
|
+
}), b = U({
|
|
106
|
+
mutationFn: (e) => g.request(ee(`/collection-layouts/${t}/versions/${e}/restore`)),
|
|
92
107
|
onSuccess: () => {
|
|
93
|
-
|
|
108
|
+
v(null), l == null || l(), k.invalidateQueries({ queryKey: ie(t) }), k.invalidateQueries({ queryKey: V(t) }), k.invalidateQueries({ queryKey: ["layout-editor", "version-diff", t] }), r == null || r();
|
|
94
109
|
}
|
|
95
|
-
}),
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
110
|
+
}), y = c.find((e) => e.id === f), { nameVersion: Y, nameCurrent: z } = ae(t), [w, $] = h(null), [S, q] = h(""), [C, K] = h(null), L = (e, i = "") => {
|
|
111
|
+
$(e), q(i);
|
|
112
|
+
}, j = () => {
|
|
113
|
+
const e = w, i = S.trim();
|
|
114
|
+
if ($(null), e == null) return;
|
|
115
|
+
const E = { onError: (J) => G.error(R(J, "Not named").message) };
|
|
116
|
+
e === "current" ? i && z.mutate(i, E) : Y.mutate({ versionId: e, name: i || null }, E);
|
|
117
|
+
}, T = async (e) => {
|
|
118
|
+
if (d) {
|
|
119
|
+
K(e.id);
|
|
120
|
+
try {
|
|
121
|
+
const i = await ne(g, t, e.id);
|
|
122
|
+
d(i, e.name ? `“${e.name}” (v${e.version})` : `version ${e.version}`);
|
|
123
|
+
} catch (i) {
|
|
124
|
+
G.error(R(i, "That version could not be read").message);
|
|
125
|
+
} finally {
|
|
126
|
+
K(null);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}, B = /* @__PURE__ */ a(
|
|
130
|
+
"input",
|
|
131
|
+
{
|
|
132
|
+
autoFocus: !0,
|
|
133
|
+
"aria-label": "Version name",
|
|
134
|
+
value: S,
|
|
135
|
+
maxLength: 120,
|
|
136
|
+
placeholder: "e.g. Go-live baseline",
|
|
137
|
+
onChange: (e) => q(e.target.value),
|
|
138
|
+
onKeyDown: (e) => {
|
|
139
|
+
e.key === "Enter" && j(), e.key === "Escape" && (e.stopPropagation(), $(null));
|
|
140
|
+
},
|
|
141
|
+
onBlur: j,
|
|
142
|
+
className: "h-6 w-full min-w-0 rounded border border-nvr-cyan bg-white px-1.5 text-[12px] outline-none dark:bg-background dark:text-foreground"
|
|
143
|
+
}
|
|
144
|
+
), p = "rounded border border-slate-200 px-1.5 py-0.5 text-[11px] hover:bg-slate-50 dark:border-border dark:hover:bg-muted";
|
|
145
|
+
return /* @__PURE__ */ s("div", { className: "flex flex-col gap-2 text-[12px]", "data-layout-history": !0, children: [
|
|
146
|
+
x && o && /* @__PURE__ */ a(re, { session: x, onJump: o }),
|
|
147
|
+
c.length > 0 && /* @__PURE__ */ s("div", { className: "rounded-lg border border-slate-200 bg-slate-50 p-2 dark:border-border dark:bg-muted/40", children: [
|
|
148
|
+
/* @__PURE__ */ s("div", { className: "flex items-center justify-between gap-2", children: [
|
|
149
|
+
/* @__PURE__ */ a("p", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: f == null ? "What the last save changed" : `Version ${(y == null ? void 0 : y.version) ?? "?"} compared with now` }),
|
|
150
|
+
/* @__PURE__ */ s("span", { className: "flex items-center gap-2", children: [
|
|
151
|
+
d && u && u.total > 0 && /* @__PURE__ */ a(
|
|
152
|
+
"button",
|
|
153
|
+
{
|
|
154
|
+
type: "button",
|
|
155
|
+
"data-show-on-canvas": "",
|
|
156
|
+
disabled: C != null,
|
|
157
|
+
onClick: () => {
|
|
158
|
+
const e = y ?? c[0];
|
|
159
|
+
e && T(e);
|
|
160
|
+
},
|
|
161
|
+
"data-tip": "Mark what differs on the form itself: added, moved, changed, removed",
|
|
162
|
+
className: "text-[11px] text-slate-600 underline dark:text-slate-300",
|
|
163
|
+
children: "Show on canvas"
|
|
164
|
+
}
|
|
165
|
+
),
|
|
166
|
+
f != null && /* @__PURE__ */ a(
|
|
167
|
+
"button",
|
|
168
|
+
{
|
|
169
|
+
type: "button",
|
|
170
|
+
onClick: () => _(null),
|
|
171
|
+
className: "text-[11px] text-slate-500 underline dark:text-slate-400",
|
|
172
|
+
children: "Show last save"
|
|
173
|
+
}
|
|
174
|
+
)
|
|
175
|
+
] })
|
|
109
176
|
] }),
|
|
110
|
-
|
|
111
|
-
|
|
177
|
+
W && /* @__PURE__ */ a("p", { className: "mt-1 text-slate-500", children: "Comparing…" }),
|
|
178
|
+
u && /* @__PURE__ */ a(de, { diff: u }),
|
|
179
|
+
u && u.total > 0 && m != null && /* @__PURE__ */ a(
|
|
180
|
+
te,
|
|
181
|
+
{
|
|
182
|
+
className: "mt-2",
|
|
183
|
+
a: { layout_id: t, version: m },
|
|
184
|
+
b: { layout_id: t, version: "current" }
|
|
185
|
+
},
|
|
186
|
+
String(m)
|
|
187
|
+
)
|
|
112
188
|
] }),
|
|
113
|
-
|
|
114
|
-
|
|
189
|
+
b.isError && /* @__PURE__ */ a("p", { className: "text-[12px] text-[#9c2f47] dark:text-[#f08aa1]", children: "Restore failed. Nothing was changed." }),
|
|
190
|
+
/* @__PURE__ */ a("div", { className: "flex items-center gap-2", "data-name-current": "", children: w === "current" ? B : /* @__PURE__ */ s(
|
|
191
|
+
"button",
|
|
192
|
+
{
|
|
193
|
+
type: "button",
|
|
194
|
+
onClick: () => L("current"),
|
|
195
|
+
"data-tip": "Keep the form as it is saved now, under a name, beyond the rolling 30 versions",
|
|
196
|
+
className: `${p} inline-flex items-center gap-1`,
|
|
197
|
+
children: [
|
|
198
|
+
/* @__PURE__ */ a(Q, { className: "h-3 w-3" }),
|
|
199
|
+
"Name the saved form…"
|
|
200
|
+
]
|
|
201
|
+
}
|
|
202
|
+
) }),
|
|
203
|
+
O ? /* @__PURE__ */ a("p", { className: "text-slate-500", children: "Loading history…" }) : c.length === 0 ? /* @__PURE__ */ a("p", { className: "text-slate-500 dark:text-slate-400", children: "No versions yet. One is saved before every change." }) : /* @__PURE__ */ a("ul", { className: "max-h-64 space-y-1 overflow-y-auto", children: c.map((e) => /* @__PURE__ */ s(
|
|
115
204
|
"li",
|
|
116
205
|
{
|
|
117
206
|
className: "flex items-center justify-between gap-2 rounded border border-slate-100 px-2 py-1 dark:border-border/60",
|
|
118
207
|
children: [
|
|
119
|
-
/* @__PURE__ */
|
|
120
|
-
|
|
208
|
+
/* @__PURE__ */ s("span", { className: "min-w-0 flex-1", children: [
|
|
209
|
+
w === e.id ? B : e.name && /* @__PURE__ */ s(
|
|
210
|
+
"span",
|
|
211
|
+
{
|
|
212
|
+
"data-version-name": e.name,
|
|
213
|
+
"data-tip": "Named: kept beyond the rolling 30 versions",
|
|
214
|
+
className: "mr-1 inline-flex max-w-full items-center gap-0.5 rounded bg-slate-100 px-1 text-[11px] font-medium text-slate-700 dark:bg-muted dark:text-slate-200",
|
|
215
|
+
children: [
|
|
216
|
+
/* @__PURE__ */ a(Q, { className: "h-3 w-3 shrink-0" }),
|
|
217
|
+
/* @__PURE__ */ a("span", { className: "truncate", children: e.name })
|
|
218
|
+
]
|
|
219
|
+
}
|
|
220
|
+
),
|
|
221
|
+
/* @__PURE__ */ s("span", { className: "font-medium", children: [
|
|
121
222
|
"v",
|
|
122
|
-
|
|
223
|
+
e.version
|
|
123
224
|
] }),
|
|
124
225
|
" ",
|
|
125
|
-
/* @__PURE__ */
|
|
126
|
-
|
|
127
|
-
new Date(
|
|
128
|
-
|
|
226
|
+
/* @__PURE__ */ s("span", { className: "text-slate-500 dark:text-slate-400", children: [
|
|
227
|
+
e.note ? `${oe(e.note)} · ` : "",
|
|
228
|
+
new Date(e.created_at).toLocaleString(),
|
|
229
|
+
e.created_by_name ? ` · ${e.created_by_name}` : ""
|
|
129
230
|
] })
|
|
130
231
|
] }),
|
|
131
|
-
/* @__PURE__ */
|
|
132
|
-
/* @__PURE__ */
|
|
232
|
+
/* @__PURE__ */ s("span", { className: "flex shrink-0 items-center gap-1", children: [
|
|
233
|
+
/* @__PURE__ */ a(
|
|
234
|
+
"button",
|
|
235
|
+
{
|
|
236
|
+
type: "button",
|
|
237
|
+
"data-version-name-edit": e.version,
|
|
238
|
+
onClick: () => L(e.id, e.name ?? ""),
|
|
239
|
+
"data-tip": e.name ? "Rename, or clear the name to let it be pruned again" : "Name this version so it is kept beyond the rolling 30",
|
|
240
|
+
className: p,
|
|
241
|
+
children: e.name ? "Rename" : "Name"
|
|
242
|
+
}
|
|
243
|
+
),
|
|
244
|
+
/* @__PURE__ */ a(
|
|
133
245
|
"button",
|
|
134
246
|
{
|
|
135
247
|
type: "button",
|
|
136
|
-
"data-tip": "See what differs from the
|
|
137
|
-
"data-version-diff":
|
|
248
|
+
"data-tip": "See what differs from the form now",
|
|
249
|
+
"data-version-diff": e.version,
|
|
138
250
|
"data-setting": "tool.version_diff",
|
|
139
|
-
onClick: () =>
|
|
140
|
-
className: `${
|
|
251
|
+
onClick: () => _(e.id),
|
|
252
|
+
className: `${p} ${f === e.id ? "border-nvr-cyan text-nvr-navy dark:text-nvr-cyan" : ""}`,
|
|
141
253
|
children: "Compare"
|
|
142
254
|
}
|
|
143
255
|
),
|
|
144
|
-
|
|
145
|
-
|
|
256
|
+
d && /* @__PURE__ */ a(
|
|
257
|
+
"button",
|
|
258
|
+
{
|
|
259
|
+
type: "button",
|
|
260
|
+
"data-version-canvas": e.version,
|
|
261
|
+
disabled: C != null,
|
|
262
|
+
onClick: () => void T(e),
|
|
263
|
+
"data-tip": "Mark on the form what differs from this version",
|
|
264
|
+
className: p,
|
|
265
|
+
children: C === e.id ? "…" : "Canvas"
|
|
266
|
+
}
|
|
267
|
+
),
|
|
268
|
+
H === e.id ? /* @__PURE__ */ s(X, { children: [
|
|
269
|
+
/* @__PURE__ */ a(
|
|
146
270
|
"button",
|
|
147
271
|
{
|
|
148
272
|
type: "button",
|
|
149
|
-
"data-restore-confirm":
|
|
150
|
-
disabled:
|
|
151
|
-
onClick: () =>
|
|
273
|
+
"data-restore-confirm": e.id,
|
|
274
|
+
disabled: b.isPending,
|
|
275
|
+
onClick: () => b.mutate(e.id),
|
|
276
|
+
"data-tip": n > 0 ? `Your ${n} unsaved ${n === 1 ? "change is" : "changes are"} dropped` : void 0,
|
|
152
277
|
className: "rounded bg-nvr-cyan px-1.5 py-0.5 text-[11px] text-white disabled:opacity-60",
|
|
153
|
-
children:
|
|
278
|
+
children: b.isPending ? "Restoring…" : n > 0 ? "Restore, drop unsaved" : "Yes, restore"
|
|
154
279
|
}
|
|
155
280
|
),
|
|
156
|
-
/* @__PURE__ */
|
|
157
|
-
] }) : /* @__PURE__ */
|
|
281
|
+
/* @__PURE__ */ a("button", { type: "button", onClick: () => v(null), className: p, children: "Cancel" })
|
|
282
|
+
] }) : /* @__PURE__ */ a(
|
|
158
283
|
"button",
|
|
159
284
|
{
|
|
160
285
|
type: "button",
|
|
161
|
-
"data-restore":
|
|
286
|
+
"data-restore": e.id,
|
|
162
287
|
"data-setting": "tool.version_restore",
|
|
163
|
-
"data-tip": "Replace the
|
|
164
|
-
onClick: () =>
|
|
165
|
-
className:
|
|
288
|
+
"data-tip": "Replace the form with this version. The current one is kept as a version first.",
|
|
289
|
+
onClick: () => v(e.id),
|
|
290
|
+
className: p,
|
|
166
291
|
children: "Restore"
|
|
167
292
|
}
|
|
168
293
|
)
|
|
169
294
|
] })
|
|
170
295
|
]
|
|
171
296
|
},
|
|
172
|
-
|
|
297
|
+
e.id
|
|
173
298
|
)) })
|
|
174
299
|
] });
|
|
175
300
|
}
|
|
176
301
|
export {
|
|
177
|
-
|
|
178
|
-
|
|
302
|
+
ve as HistoryPanel,
|
|
303
|
+
oe as versionNoteLabel
|
|
179
304
|
};
|