@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
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { jsxs as r, jsx as t, Fragment as B } from "react/jsx-runtime";
|
|
2
|
+
import { Loader2 as T, Sparkles as F } from "lucide-react";
|
|
3
|
+
import { useState as j, useRef as h, useCallback as R, useEffect as L } from "react";
|
|
4
|
+
import { useNivaroClient as q } from "../../../context.js";
|
|
5
|
+
import { post as D } from "../../../lib/commands.js";
|
|
6
|
+
import { cn as E } from "../../../lib/utils.js";
|
|
7
|
+
import { Popover as P, PopoverContent as U } from "../../ui/popover.js";
|
|
8
|
+
import { useLayoutEditorHost as H } from "../host.js";
|
|
9
|
+
import { ToolButton as J } from "../toolbar-kit.js";
|
|
10
|
+
import { parseSaveFailure as V } from "../useLayoutDraft.js";
|
|
11
|
+
import { slimBundle as S, savedJustNow as W } from "./assist-ops.js";
|
|
12
|
+
const m = "text-[12px] leading-snug text-slate-500 dark:text-muted-foreground", _ = "inline-flex h-7 items-center rounded-md px-2.5 text-[12px] font-medium text-slate-600 transition-colors hover:bg-muted hover:text-slate-900 dark:text-muted-foreground dark:hover:text-foreground";
|
|
13
|
+
function ae({
|
|
14
|
+
layoutId: y,
|
|
15
|
+
draft: a
|
|
16
|
+
}) {
|
|
17
|
+
const O = H(), A = q(), [e, o] = j({ kind: "idle" }), [k, c] = j(!1), i = a.unsavedCount ?? 0, p = O.isAdmin && !!a.unsavedOps, f = h(null), g = h(null), C = h(i), I = h(!1), b = h(0), x = R(
|
|
18
|
+
async (n, l) => {
|
|
19
|
+
if (n === "save" && I.current) return;
|
|
20
|
+
const $ = ++b.current;
|
|
21
|
+
n === "ask" && o({ kind: "checking", trigger: n });
|
|
22
|
+
try {
|
|
23
|
+
const u = await A.request(
|
|
24
|
+
D(`/ai-design/layouts/${y}/check-changes`, {
|
|
25
|
+
before: l.before ? S(l.before) : null,
|
|
26
|
+
after: S(l.after)
|
|
27
|
+
})
|
|
28
|
+
);
|
|
29
|
+
if ($ !== b.current) return;
|
|
30
|
+
const s = u == null ? void 0 : u.data;
|
|
31
|
+
if (!s || s.status === "skipped" && n === "save") {
|
|
32
|
+
o({ kind: "idle" });
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
o({ kind: "done", trigger: n, answer: s }), n === "save" && s.status === "checked" && s.warnings.length && c(!0);
|
|
36
|
+
} catch (u) {
|
|
37
|
+
if ($ !== b.current) return;
|
|
38
|
+
const s = V(u, "The AI check failed");
|
|
39
|
+
if (s.status === 503 && (I.current = !0), n === "save") {
|
|
40
|
+
o({ kind: "idle" });
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
o({
|
|
44
|
+
kind: "error",
|
|
45
|
+
message: s.status === 503 ? "AI is not set up here, so changes cannot be checked." : s.message
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
[A, y]
|
|
50
|
+
);
|
|
51
|
+
L(() => {
|
|
52
|
+
if (p) {
|
|
53
|
+
if (i > 0 && a.bundle && (g.current = { before: f.current, after: a.bundle }), W(C.current, i, a.status, !!a.autosave)) {
|
|
54
|
+
const n = g.current;
|
|
55
|
+
n && x("save", n);
|
|
56
|
+
}
|
|
57
|
+
i === 0 && (g.current = null, a.bundle && (f.current = a.bundle)), C.current = i;
|
|
58
|
+
}
|
|
59
|
+
}, [p, i, a.status, a.autosave, a.bundle, x]);
|
|
60
|
+
const v = e.kind === "done" && (e.answer.status === "skipped" || e.answer.warnings.length === 0);
|
|
61
|
+
if (L(() => {
|
|
62
|
+
if (!v || k) return;
|
|
63
|
+
const n = setTimeout(() => o({ kind: "idle" }), 8e3);
|
|
64
|
+
return () => clearTimeout(n);
|
|
65
|
+
}, [v, k]), !p || e.kind === "idle" && i === 0) return null;
|
|
66
|
+
const N = () => {
|
|
67
|
+
a.bundle && x("ask", { before: f.current, after: a.bundle });
|
|
68
|
+
}, d = e.kind === "done" && e.answer.status === "checked" ? e.answer.warnings : [], w = e.kind === "checking" ? "Checking…" : d.length ? `${d.length} to look at` : v ? "Looks fine" : null;
|
|
69
|
+
return /* @__PURE__ */ r(P, { open: k, onOpenChange: c, children: [
|
|
70
|
+
/* @__PURE__ */ t(
|
|
71
|
+
J,
|
|
72
|
+
{
|
|
73
|
+
popover: !0,
|
|
74
|
+
onOpen: () => {
|
|
75
|
+
(e.kind === "idle" || e.kind === "error") && N(), c(!0);
|
|
76
|
+
},
|
|
77
|
+
label: "AI review",
|
|
78
|
+
ariaLabel: "AI review of the changes",
|
|
79
|
+
icon: e.kind === "checking" ? /* @__PURE__ */ t(T, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ t(F, { className: "h-3.5 w-3.5 text-nvr-cyan" }),
|
|
80
|
+
tip: "AI reads the change next to the roles and the workflow and warns about likely mistakes. It never blocks Save.",
|
|
81
|
+
hint: w ?? "Likely mistakes, next to the roles and the workflow",
|
|
82
|
+
badge: d.length || void 0,
|
|
83
|
+
data: { "data-ai-change-check": e.kind },
|
|
84
|
+
onClick: (n) => {
|
|
85
|
+
(e.kind === "idle" || e.kind === "error") && (n.preventDefault(), N(), c(!0));
|
|
86
|
+
},
|
|
87
|
+
className: E(
|
|
88
|
+
d.length && "border-amber-300 bg-amber-50 text-amber-900 hover:bg-amber-100 dark:border-amber-800/70 dark:bg-amber-950/40 dark:text-amber-200 dark:hover:bg-amber-950/60"
|
|
89
|
+
),
|
|
90
|
+
trailing: w && /* @__PURE__ */ r("span", { className: "text-slate-500 dark:text-muted-foreground", children: [
|
|
91
|
+
"· ",
|
|
92
|
+
w
|
|
93
|
+
] })
|
|
94
|
+
}
|
|
95
|
+
),
|
|
96
|
+
/* @__PURE__ */ t(U, { align: "end", className: "w-[380px] p-0", "data-ai-change-check-panel": "", children: /* @__PURE__ */ r("div", { className: "space-y-2.5 p-3", children: [
|
|
97
|
+
/* @__PURE__ */ t("p", { className: "text-[13px] font-semibold text-slate-900 dark:text-foreground", children: e.kind !== "idle" && "trigger" in e && e.trigger === "save" ? "AI review of the change you saved" : "AI review of your unsaved changes" }),
|
|
98
|
+
e.kind === "checking" && /* @__PURE__ */ t("p", { className: m, children: "Reading the change…" }),
|
|
99
|
+
e.kind === "error" && /* @__PURE__ */ t("p", { className: "text-[12px] text-[#9c2f47] dark:text-[#f08aa1]", children: e.message }),
|
|
100
|
+
e.kind === "done" && e.answer.status === "skipped" && /* @__PURE__ */ t("p", { className: m, children: e.answer.reason === "empty" ? "Nothing has changed since the last save." : "Only labels, help text or the order inside a section changed: nothing for the AI to judge." }),
|
|
101
|
+
e.kind === "done" && e.answer.status === "checked" && /* @__PURE__ */ r(B, { children: [
|
|
102
|
+
d.length ? /* @__PURE__ */ t("ul", { className: "space-y-1.5", "data-ai-change-warnings": "", children: d.map((n, l) => /* @__PURE__ */ r(
|
|
103
|
+
"li",
|
|
104
|
+
{
|
|
105
|
+
className: "rounded-md bg-amber-50 px-2.5 py-2 text-[12.5px] leading-snug text-amber-950 dark:bg-amber-950/40 dark:text-amber-100",
|
|
106
|
+
children: [
|
|
107
|
+
n.message,
|
|
108
|
+
(n.field_label || n.section_label || n.roles.length > 0) && /* @__PURE__ */ t("span", { className: "mt-1 block text-[11.5px] text-amber-800/80 dark:text-amber-200/70", children: [
|
|
109
|
+
n.field_label && `Field: ${n.field_label}`,
|
|
110
|
+
n.section_label && `Section: ${n.section_label}`,
|
|
111
|
+
n.roles.length > 0 && `Roles: ${n.roles.join(", ")}`
|
|
112
|
+
].filter(Boolean).join(" · ") })
|
|
113
|
+
]
|
|
114
|
+
},
|
|
115
|
+
`${l}:${n.message}`
|
|
116
|
+
)) }) : /* @__PURE__ */ t("p", { className: "text-[12.5px] text-slate-700 dark:text-foreground", children: "Nothing looks off." }),
|
|
117
|
+
e.answer.dropped > 0 && /* @__PURE__ */ r("p", { className: m, children: [
|
|
118
|
+
"Left out ",
|
|
119
|
+
e.answer.dropped,
|
|
120
|
+
" remark",
|
|
121
|
+
e.answer.dropped === 1 ? "" : "s",
|
|
122
|
+
" that named fields, sections or roles this form does not have."
|
|
123
|
+
] }),
|
|
124
|
+
/* @__PURE__ */ r("details", { className: "text-[12px]", children: [
|
|
125
|
+
/* @__PURE__ */ r("summary", { className: "cursor-pointer text-slate-600 dark:text-muted-foreground", children: [
|
|
126
|
+
"What it read (",
|
|
127
|
+
e.answer.changes.length,
|
|
128
|
+
")"
|
|
129
|
+
] }),
|
|
130
|
+
/* @__PURE__ */ t("ul", { className: "mt-1 list-disc space-y-0.5 pl-4 text-slate-600 dark:text-muted-foreground", children: e.answer.changes.map((n, l) => /* @__PURE__ */ t("li", { children: n }, `${l}:${n}`)) })
|
|
131
|
+
] })
|
|
132
|
+
] }),
|
|
133
|
+
/* @__PURE__ */ t("p", { className: m, children: "Advice from AI: it never blocks Save, and Undo reverses a saved change." }),
|
|
134
|
+
/* @__PURE__ */ r("div", { className: "flex justify-end gap-1", children: [
|
|
135
|
+
i > 0 && e.kind !== "checking" && /* @__PURE__ */ t("button", { type: "button", className: _, onClick: N, children: "Check again" }),
|
|
136
|
+
/* @__PURE__ */ t(
|
|
137
|
+
"button",
|
|
138
|
+
{
|
|
139
|
+
type: "button",
|
|
140
|
+
className: _,
|
|
141
|
+
onClick: () => {
|
|
142
|
+
c(!1), o({ kind: "idle" });
|
|
143
|
+
},
|
|
144
|
+
children: "Dismiss"
|
|
145
|
+
}
|
|
146
|
+
)
|
|
147
|
+
] })
|
|
148
|
+
] }) })
|
|
149
|
+
] });
|
|
150
|
+
}
|
|
151
|
+
export {
|
|
152
|
+
ae as AiChangeCheck
|
|
153
|
+
};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { UNGROUPED_KEY as s, HEADER_GROUP_KEY as f } from "../../../lib/layout-ops.js";
|
|
2
|
+
import { targetKey as u } from "../design-context.js";
|
|
3
|
+
const l = "__form__";
|
|
4
|
+
function g(n, o) {
|
|
5
|
+
const e = /^(field|group):(.+)$/.exec(n);
|
|
6
|
+
if (!e) return null;
|
|
7
|
+
if (e[1] === "group")
|
|
8
|
+
return e[2] === s ? { kind: "group", key: s } : o.groups.some((r) => r.key === e[2]) ? { kind: "group", key: e[2] } : null;
|
|
9
|
+
const t = o.placements.find((r) => r.field === e[2] && r.group_key !== f);
|
|
10
|
+
return t ? { kind: "field", field: t.field, group_key: t.group_key } : null;
|
|
11
|
+
}
|
|
12
|
+
function p(n, o) {
|
|
13
|
+
return n === l ? null : g(`group:${n}`, o);
|
|
14
|
+
}
|
|
15
|
+
const m = {
|
|
16
|
+
blocking: "amber",
|
|
17
|
+
confusing: "violet",
|
|
18
|
+
minor: "slate"
|
|
19
|
+
};
|
|
20
|
+
function _(n, o) {
|
|
21
|
+
const e = [];
|
|
22
|
+
for (const t of n.findings) {
|
|
23
|
+
const r = g(t.target, o);
|
|
24
|
+
r && e.push({
|
|
25
|
+
target: r,
|
|
26
|
+
text: t.severity === "blocking" ? `Blocks ${n.role}` : `Confuses ${n.role}`,
|
|
27
|
+
tone: m[t.severity],
|
|
28
|
+
tip: t.suggestion ? `${t.problem} ${t.suggestion}` : t.problem
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
return e;
|
|
32
|
+
}
|
|
33
|
+
function d(n, o) {
|
|
34
|
+
const e = [];
|
|
35
|
+
for (const t of n.comments) {
|
|
36
|
+
const r = p(t.section, o);
|
|
37
|
+
r && e.push({
|
|
38
|
+
target: r,
|
|
39
|
+
text: `Design: ${t.topic}`,
|
|
40
|
+
tone: t.severity === "high" ? "amber" : "violet",
|
|
41
|
+
tip: t.suggestion ? `${t.comment} ${t.suggestion}` : t.comment
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
return e;
|
|
45
|
+
}
|
|
46
|
+
function y(n) {
|
|
47
|
+
if (n.length === 0) return;
|
|
48
|
+
const o = /* @__PURE__ */ new Map();
|
|
49
|
+
for (const e of n) {
|
|
50
|
+
const t = u(e.target);
|
|
51
|
+
o.set(t, [...o.get(t) ?? [], e]);
|
|
52
|
+
}
|
|
53
|
+
return (e) => {
|
|
54
|
+
const t = o.get(u(e));
|
|
55
|
+
if (!t) return [];
|
|
56
|
+
const r = t[0], c = t.some((i) => i.tone === "amber") ? "amber" : r.tone;
|
|
57
|
+
return [
|
|
58
|
+
{
|
|
59
|
+
text: t.length > 1 ? `${r.text} · ${t.length}` : r.text,
|
|
60
|
+
tone: c,
|
|
61
|
+
tip: t.map((i) => i.tip).join(`
|
|
62
|
+
`),
|
|
63
|
+
highlight: !0,
|
|
64
|
+
kind: "ai"
|
|
65
|
+
}
|
|
66
|
+
];
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
function $(n, o) {
|
|
70
|
+
return n ? o ? (e) => [...n(e), ...o(e)] : n : o;
|
|
71
|
+
}
|
|
72
|
+
export {
|
|
73
|
+
l as FORM_TARGET,
|
|
74
|
+
d as critiquePins,
|
|
75
|
+
$ as mergeMarks,
|
|
76
|
+
_ as personaPins,
|
|
77
|
+
y as pinsToMarks,
|
|
78
|
+
p as sectionTarget,
|
|
79
|
+
g as targetFromRef
|
|
80
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
function r(o, e, l, i) {
|
|
2
|
+
return !i && o > 0 && e === 0 && (l === "saving" || l === "saved");
|
|
3
|
+
}
|
|
4
|
+
function s(o) {
|
|
5
|
+
return {
|
|
6
|
+
rev: o.rev,
|
|
7
|
+
layout: {
|
|
8
|
+
conditions: o.layout.conditions ?? null,
|
|
9
|
+
record_conditions: o.layout.record_conditions ?? null,
|
|
10
|
+
default_values: o.layout.default_values ?? null
|
|
11
|
+
},
|
|
12
|
+
groups: o.groups.map((e) => ({
|
|
13
|
+
key: e.key,
|
|
14
|
+
parent_key: e.parent_key,
|
|
15
|
+
sort: e.sort,
|
|
16
|
+
label: e.label,
|
|
17
|
+
type: e.type,
|
|
18
|
+
is_collapsed: e.is_collapsed,
|
|
19
|
+
visible_when: e.visible_when,
|
|
20
|
+
hidden_for_roles: e.hidden_for_roles,
|
|
21
|
+
locked_for_roles: e.locked_for_roles
|
|
22
|
+
})),
|
|
23
|
+
placements: o.placements.map((e) => ({
|
|
24
|
+
field: e.field,
|
|
25
|
+
group_key: e.group_key,
|
|
26
|
+
sort: e.sort,
|
|
27
|
+
label_override: e.label_override,
|
|
28
|
+
is_visible: e.is_visible,
|
|
29
|
+
overrides: e.overrides,
|
|
30
|
+
lock_conditions: e.lock_conditions,
|
|
31
|
+
widget_id: e.widget_id
|
|
32
|
+
}))
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export {
|
|
36
|
+
r as savedJustNow,
|
|
37
|
+
s as slimBundle
|
|
38
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { AUTOFILL_CHECK_KEY as f } from "../../../lib/ai-fill.js";
|
|
2
|
+
import { HEADER_GROUP_KEY as m, applyLayoutOps as y } from "../../../lib/layout-ops.js";
|
|
3
|
+
import { newGroupKey as _ } from "../add-target.js";
|
|
4
|
+
import { readOverrides as d, withOverride as k } from "../inspector/model.js";
|
|
5
|
+
function c(e, o) {
|
|
6
|
+
return e.placements.filter((t) => t.field === o && t.group_key !== m);
|
|
7
|
+
}
|
|
8
|
+
function H(e, o) {
|
|
9
|
+
return c(e, o).some((t) => d(t)[f] === !0);
|
|
10
|
+
}
|
|
11
|
+
function g(e, o) {
|
|
12
|
+
return o.filter((t) => c(e, t).length > 0);
|
|
13
|
+
}
|
|
14
|
+
function K(e, o, t, i = !0) {
|
|
15
|
+
const l = [], r = [];
|
|
16
|
+
for (const p of g(e, o)) {
|
|
17
|
+
let h = !1;
|
|
18
|
+
for (const s of c(e, p))
|
|
19
|
+
d(s)[f] === !0 !== i && (l.push({
|
|
20
|
+
op: "update_placement",
|
|
21
|
+
at: { field: s.field, group_key: s.group_key },
|
|
22
|
+
patch: { overrides: k(s, f, i ? !0 : void 0) }
|
|
23
|
+
}), h = !0);
|
|
24
|
+
h && r.push(
|
|
25
|
+
i ? `Highlight ${t(p)} when the form is filled from a document` : `Stop highlighting ${t(p)}`
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
return l.length === 0 ? null : {
|
|
29
|
+
ops: l,
|
|
30
|
+
steps: r,
|
|
31
|
+
label: i ? "Highlight fields often corrected after autofill" : "Remove autofill highlights"
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function O(e, o, t) {
|
|
35
|
+
const i = g(e, o);
|
|
36
|
+
if (i.length === 0) return null;
|
|
37
|
+
const l = _(e, "check_these"), r = e.groups.filter((n) => n.parent_key == null && n.type === "container").sort((n, u) => n.sort - u.sort)[0], p = ((r == null ? void 0 : r.tab_mode) ?? e.layout.tab_mode) === "steps" ? "step" : "tab", h = [
|
|
38
|
+
{
|
|
39
|
+
op: "group_create",
|
|
40
|
+
key: l,
|
|
41
|
+
label: "Check these",
|
|
42
|
+
group_type: r ? "tab" : "section",
|
|
43
|
+
parent_key: (r == null ? void 0 : r.key) ?? null,
|
|
44
|
+
index: 0
|
|
45
|
+
}
|
|
46
|
+
], s = [
|
|
47
|
+
r ? `Add a first ${p} "Check these"` : 'Add a section "Check these" at the top of the form'
|
|
48
|
+
];
|
|
49
|
+
return i.forEach((n, u) => {
|
|
50
|
+
const a = c(e, n)[0];
|
|
51
|
+
h.push({
|
|
52
|
+
op: "move",
|
|
53
|
+
from: { field: a.field, group_key: a.group_key },
|
|
54
|
+
to_group_key: l,
|
|
55
|
+
index: u
|
|
56
|
+
}), s.push(`Move ${t(n)} into it`);
|
|
57
|
+
}), { ops: h, steps: s, label: 'Add a "Check these" section' };
|
|
58
|
+
}
|
|
59
|
+
function P(e, o) {
|
|
60
|
+
try {
|
|
61
|
+
return y(e, o.ops), null;
|
|
62
|
+
} catch (t) {
|
|
63
|
+
return (t == null ? void 0 : t.message) || "This change does not fit the layout";
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
export {
|
|
67
|
+
f as AUTOFILL_CHECK_KEY,
|
|
68
|
+
O as checkSectionPlan,
|
|
69
|
+
H as hasAutofillCheck,
|
|
70
|
+
K as highlightPlan,
|
|
71
|
+
g as placedFields,
|
|
72
|
+
P as planApplies
|
|
73
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { captureElementImage as f } from "../../../lib/screenshot.js";
|
|
2
|
+
const i = '[data-design-target^="group:"]', h = '[data-design-target^="field:"]';
|
|
3
|
+
function m(t) {
|
|
4
|
+
return (t == null ? void 0 : t.querySelector("main")) ?? null;
|
|
5
|
+
}
|
|
6
|
+
function S(t) {
|
|
7
|
+
var c;
|
|
8
|
+
const e = t.getBoundingClientRect(), d = e.top - t.scrollTop, g = e.left - t.scrollLeft, r = [], a = /* @__PURE__ */ new Set();
|
|
9
|
+
for (const n of Array.from(t.querySelectorAll(i))) {
|
|
10
|
+
const o = (n.getAttribute("data-design-target") ?? "").slice(6);
|
|
11
|
+
if (!o || a.has(o)) continue;
|
|
12
|
+
a.add(o);
|
|
13
|
+
const s = n.getBoundingClientRect(), l = /* @__PURE__ */ new Set();
|
|
14
|
+
for (const u of Array.from(n.querySelectorAll(h)))
|
|
15
|
+
((c = u.parentElement) == null ? void 0 : c.closest(i)) === n && l.add(Math.round(u.getBoundingClientRect().top / 4));
|
|
16
|
+
r.push({
|
|
17
|
+
key: o,
|
|
18
|
+
x: Math.round(s.left - g),
|
|
19
|
+
y: Math.round(s.top - d),
|
|
20
|
+
w: Math.round(s.width),
|
|
21
|
+
h: Math.round(s.height),
|
|
22
|
+
rows: l.size
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
canvas: { w: Math.round(t.scrollWidth), h: Math.round(t.scrollHeight) },
|
|
27
|
+
sections: r
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function y(t) {
|
|
31
|
+
const e = t.firstElementChild ?? t;
|
|
32
|
+
return f(e, {
|
|
33
|
+
maxWidth: 1200,
|
|
34
|
+
ignoreSelector: "[data-design-badges]"
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
export {
|
|
38
|
+
m as canvasRoot,
|
|
39
|
+
y as captureCanvas,
|
|
40
|
+
S as measureSections
|
|
41
|
+
};
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
import { jsx as t, jsxs as s } from "react/jsx-runtime";
|
|
2
|
+
import { FileUp as _, Sparkles as P, Quote as q } from "lucide-react";
|
|
3
|
+
import { useState as y, useRef as K, useMemo as v } from "react";
|
|
4
|
+
import { useNivaroClient as L } from "../../../context.js";
|
|
5
|
+
import { cn as g, formatFileSize as U } from "../../../lib/utils.js";
|
|
6
|
+
import { Checkbox as Q } from "../../ui/checkbox.js";
|
|
7
|
+
import { useOverviewFields as Y, apiFailure as W } from "../overview/overview-api.js";
|
|
8
|
+
import { effectText as X, inputBase as R, tintCard as G } from "../panel-style.js";
|
|
9
|
+
import { COMPOSE_ACCEPT as H, COMPOSE_MAX_BYTES as J, composeFromText as V, composeFromFile as Z } from "./ai-forms-api.js";
|
|
10
|
+
import { extraChoices as E, planComposed as T } from "./plan.js";
|
|
11
|
+
const ee = {
|
|
12
|
+
describe: {
|
|
13
|
+
title: "Describe the form",
|
|
14
|
+
hint: "Built from this collection’s fields. Anything the AI names that is not a field is left out and listed."
|
|
15
|
+
},
|
|
16
|
+
picture: {
|
|
17
|
+
title: "From a picture or PDF",
|
|
18
|
+
hint: "A screenshot, scan, PDF or spreadsheet of the old form. Its labels are matched to fields; labels with no field are listed, never created. Read once, never stored. Up to 10 MB."
|
|
19
|
+
},
|
|
20
|
+
sop: {
|
|
21
|
+
title: "From a process document",
|
|
22
|
+
hint: "One step per stage of the process, with suggested read-only and required fields for the pipeline states. Read once, never stored. Up to 10 MB."
|
|
23
|
+
}
|
|
24
|
+
}, x = X, j = "inline-flex h-7 items-center gap-1 rounded-md px-2.5 text-[12px] font-medium text-slate-600 transition-colors hover:bg-muted hover:text-slate-900 disabled:opacity-50 dark:text-muted-foreground dark:hover:text-foreground", z = "inline-flex h-7 items-center gap-1.5 rounded-md bg-nvr-cyan px-3 text-[12px] font-medium text-white transition-opacity hover:opacity-90 disabled:pointer-events-none disabled:opacity-50", F = "text-[12px] font-semibold text-slate-700 dark:text-foreground", te = "rounded-md border border-amber-200 bg-amber-50 px-2.5 py-1.5 text-[12px] leading-snug text-amber-800 dark:border-amber-500/30 dark:bg-amber-500/10 dark:text-amber-200";
|
|
25
|
+
function he({
|
|
26
|
+
collection: o,
|
|
27
|
+
mode: n,
|
|
28
|
+
bundle: m,
|
|
29
|
+
applyLabel: h,
|
|
30
|
+
onApply: w,
|
|
31
|
+
onBack: b,
|
|
32
|
+
busy: C = !1
|
|
33
|
+
}) {
|
|
34
|
+
const k = L(), { data: N = [] } = Y(o), [r, p] = y(""), [d, A] = y(null), [i, c] = y({ kind: "input" }), [e, u] = y(/* @__PURE__ */ new Set()), f = K(null), S = v(() => ({ fields: N }), [N]), D = ee[n], I = n === "describe" ? r.trim().length >= 6 : !!d, M = async () => {
|
|
35
|
+
if (I) {
|
|
36
|
+
c({ kind: "asking" });
|
|
37
|
+
try {
|
|
38
|
+
const a = n === "describe" ? await V(k, o, r.trim()) : await Z(k, {
|
|
39
|
+
collection: o,
|
|
40
|
+
mode: n,
|
|
41
|
+
file: d,
|
|
42
|
+
note: r
|
|
43
|
+
});
|
|
44
|
+
u(
|
|
45
|
+
new Set(
|
|
46
|
+
E(a.form, a.states ?? [], S).filter((l) => l.checked).map((l) => l.id)
|
|
47
|
+
)
|
|
48
|
+
), c({ kind: "review", result: a });
|
|
49
|
+
} catch (a) {
|
|
50
|
+
const l = W(a, "The AI could not build the form");
|
|
51
|
+
c({
|
|
52
|
+
kind: "input",
|
|
53
|
+
error: l.status === 503 ? "AI is not set up here. Turn it on under Settings → AI." : l.message
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
return i.kind === "review" ? /* @__PURE__ */ t(
|
|
59
|
+
ae,
|
|
60
|
+
{
|
|
61
|
+
result: i.result,
|
|
62
|
+
bundle: m,
|
|
63
|
+
env: S,
|
|
64
|
+
chosen: e,
|
|
65
|
+
onChosen: u,
|
|
66
|
+
applyLabel: h,
|
|
67
|
+
busy: C,
|
|
68
|
+
onBack: () => c({ kind: "input" }),
|
|
69
|
+
onApply: (a) => w(a, i.result)
|
|
70
|
+
}
|
|
71
|
+
) : /* @__PURE__ */ s(
|
|
72
|
+
"form",
|
|
73
|
+
{
|
|
74
|
+
className: "space-y-2.5",
|
|
75
|
+
"data-ai-compose": n,
|
|
76
|
+
onSubmit: (a) => {
|
|
77
|
+
a.preventDefault(), M();
|
|
78
|
+
},
|
|
79
|
+
children: [
|
|
80
|
+
/* @__PURE__ */ t("p", { className: F, children: D.title }),
|
|
81
|
+
/* @__PURE__ */ t("p", { className: x, children: D.hint }),
|
|
82
|
+
n !== "describe" && /* @__PURE__ */ s("div", { className: "flex items-center gap-2", children: [
|
|
83
|
+
/* @__PURE__ */ t(
|
|
84
|
+
"input",
|
|
85
|
+
{
|
|
86
|
+
ref: f,
|
|
87
|
+
type: "file",
|
|
88
|
+
accept: H,
|
|
89
|
+
className: "hidden",
|
|
90
|
+
"data-ai-compose-file": "",
|
|
91
|
+
onChange: (a) => {
|
|
92
|
+
var O;
|
|
93
|
+
const l = ((O = a.target.files) == null ? void 0 : O[0]) ?? null;
|
|
94
|
+
if (a.target.value = "", l && l.size > J) {
|
|
95
|
+
c({ kind: "input", error: `${l.name} is larger than 10 MB` });
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
A(l), c({ kind: "input" });
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
),
|
|
102
|
+
/* @__PURE__ */ s(
|
|
103
|
+
"button",
|
|
104
|
+
{
|
|
105
|
+
type: "button",
|
|
106
|
+
className: g(
|
|
107
|
+
"inline-flex h-8 items-center gap-1.5 rounded-md border border-slate-200 bg-white px-2.5 text-[12.5px] font-medium text-slate-700 transition-colors hover:bg-slate-50 dark:border-border dark:bg-card dark:text-foreground dark:hover:bg-muted"
|
|
108
|
+
),
|
|
109
|
+
onClick: () => {
|
|
110
|
+
var a;
|
|
111
|
+
return (a = f.current) == null ? void 0 : a.click();
|
|
112
|
+
},
|
|
113
|
+
children: [
|
|
114
|
+
/* @__PURE__ */ t(_, { className: "h-3.5 w-3.5" }),
|
|
115
|
+
d ? "Choose another file" : "Choose a file"
|
|
116
|
+
]
|
|
117
|
+
}
|
|
118
|
+
),
|
|
119
|
+
d && /* @__PURE__ */ s("span", { className: "min-w-0 truncate text-[12px] text-slate-600 dark:text-muted-foreground", children: [
|
|
120
|
+
d.name,
|
|
121
|
+
" · ",
|
|
122
|
+
U(d.size)
|
|
123
|
+
] })
|
|
124
|
+
] }),
|
|
125
|
+
n === "describe" ? /* @__PURE__ */ t(
|
|
126
|
+
"textarea",
|
|
127
|
+
{
|
|
128
|
+
value: r,
|
|
129
|
+
onChange: (a) => p(a.target.value),
|
|
130
|
+
rows: 3,
|
|
131
|
+
maxLength: 2e3,
|
|
132
|
+
"aria-label": "Describe the form",
|
|
133
|
+
placeholder: "A returns form with a manager approval step",
|
|
134
|
+
"data-ai-compose-text": "",
|
|
135
|
+
className: g(R, "h-auto resize-y py-1.5 leading-snug"),
|
|
136
|
+
onKeyDown: (a) => {
|
|
137
|
+
a.key === "Enter" && (a.metaKey || a.ctrlKey) && (a.preventDefault(), M());
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
) : /* @__PURE__ */ t(
|
|
141
|
+
"input",
|
|
142
|
+
{
|
|
143
|
+
value: r,
|
|
144
|
+
onChange: (a) => p(a.target.value),
|
|
145
|
+
maxLength: 500,
|
|
146
|
+
"aria-label": "Note for the AI (optional)",
|
|
147
|
+
placeholder: "Note for the AI (optional)",
|
|
148
|
+
className: R
|
|
149
|
+
}
|
|
150
|
+
),
|
|
151
|
+
i.kind === "input" && i.error && /* @__PURE__ */ t(
|
|
152
|
+
"p",
|
|
153
|
+
{
|
|
154
|
+
role: "alert",
|
|
155
|
+
"data-ai-compose-error": "",
|
|
156
|
+
className: "text-[12.5px] leading-snug text-red-700 dark:text-red-300",
|
|
157
|
+
children: i.error
|
|
158
|
+
}
|
|
159
|
+
),
|
|
160
|
+
/* @__PURE__ */ s("div", { className: "flex items-center justify-end gap-1.5 pt-0.5", children: [
|
|
161
|
+
b && /* @__PURE__ */ t("button", { type: "button", className: j, onClick: b, children: "Back" }),
|
|
162
|
+
/* @__PURE__ */ s(
|
|
163
|
+
"button",
|
|
164
|
+
{
|
|
165
|
+
type: "submit",
|
|
166
|
+
className: z,
|
|
167
|
+
disabled: !I || i.kind === "asking",
|
|
168
|
+
"data-ai-compose-run": "",
|
|
169
|
+
children: [
|
|
170
|
+
/* @__PURE__ */ t(P, { className: "h-3.5 w-3.5" }),
|
|
171
|
+
i.kind === "asking" ? n === "describe" ? "Building…" : "Reading…" : n === "describe" ? "Build draft" : "Read it"
|
|
172
|
+
]
|
|
173
|
+
}
|
|
174
|
+
)
|
|
175
|
+
] })
|
|
176
|
+
]
|
|
177
|
+
}
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
function ae({
|
|
181
|
+
result: o,
|
|
182
|
+
bundle: n,
|
|
183
|
+
env: m,
|
|
184
|
+
chosen: h,
|
|
185
|
+
onChosen: w,
|
|
186
|
+
applyLabel: b,
|
|
187
|
+
onApply: C,
|
|
188
|
+
onBack: k,
|
|
189
|
+
busy: N
|
|
190
|
+
}) {
|
|
191
|
+
const { form: r } = o, p = v(() => o.states ?? [], [o]), d = v(() => E(r, p, m), [r, p, m]), A = (e) => T(e, r, m, { chosen: h, states: p }), i = v(
|
|
192
|
+
() => T(n, r, m, { chosen: h, states: p }),
|
|
193
|
+
[n, r, m, h, p]
|
|
194
|
+
), c = r.groups.filter((e) => e.source);
|
|
195
|
+
return /* @__PURE__ */ s("div", { className: "space-y-3", "data-ai-review": "", children: [
|
|
196
|
+
/* @__PURE__ */ s("p", { className: g(F, "flex items-center gap-1.5"), children: [
|
|
197
|
+
/* @__PURE__ */ t(P, { className: "h-3.5 w-3.5 text-nvr-cyan" }),
|
|
198
|
+
"The AI proposes"
|
|
199
|
+
] }),
|
|
200
|
+
r.explanation && /* @__PURE__ */ t("p", { className: x, children: r.explanation }),
|
|
201
|
+
i.steps.length > 0 ? /* @__PURE__ */ t("ol", { className: "list-decimal space-y-1 pl-5 text-[12.5px] leading-snug text-slate-700 dark:text-foreground", children: i.steps.map((e, u) => (
|
|
202
|
+
// biome-ignore lint/suspicious/noArrayIndexKey: two steps may read the same; the list is rebuilt whole
|
|
203
|
+
/* @__PURE__ */ t("li", { children: e }, `${u}:${e}`)
|
|
204
|
+
)) }) : /* @__PURE__ */ t("p", { className: x, children: "Nothing to change: the form already looks like this." }),
|
|
205
|
+
d.length > 0 && /* @__PURE__ */ t(B, { title: "Read-only and required, from the process", children: /* @__PURE__ */ t("ul", { className: "space-y-1.5", children: d.map((e) => /* @__PURE__ */ s("li", { className: "flex items-start gap-2", children: [
|
|
206
|
+
/* @__PURE__ */ t(
|
|
207
|
+
Q,
|
|
208
|
+
{
|
|
209
|
+
id: `ai-extra-${e.id}`,
|
|
210
|
+
className: "mt-0.5 border-slate-300 data-[state=checked]:border-nvr-cyan data-[state=checked]:bg-nvr-cyan data-[state=checked]:text-white dark:border-border",
|
|
211
|
+
checked: h.has(e.id),
|
|
212
|
+
onCheckedChange: (u) => {
|
|
213
|
+
const f = new Set(h);
|
|
214
|
+
u === !0 ? f.add(e.id) : f.delete(e.id), w(f);
|
|
215
|
+
},
|
|
216
|
+
"data-ai-extra": e.id
|
|
217
|
+
}
|
|
218
|
+
),
|
|
219
|
+
/* @__PURE__ */ s("label", { htmlFor: `ai-extra-${e.id}`, className: "min-w-0 flex-1 cursor-pointer", children: [
|
|
220
|
+
/* @__PURE__ */ t("span", { className: "block text-[12.5px] leading-snug text-slate-800 dark:text-foreground", children: e.text }),
|
|
221
|
+
e.note && /* @__PURE__ */ t("span", { className: g(x, "block"), children: e.note }),
|
|
222
|
+
e.source && /* @__PURE__ */ t($, { text: e.source })
|
|
223
|
+
] })
|
|
224
|
+
] }, e.id)) }) }),
|
|
225
|
+
c.length > 0 && /* @__PURE__ */ t(B, { title: "Where each step came from", children: /* @__PURE__ */ t("ul", { className: "space-y-1.5", "data-ai-sources": "", children: c.map((e) => /* @__PURE__ */ s("li", { children: [
|
|
226
|
+
/* @__PURE__ */ t("span", { className: "text-[12px] font-medium text-slate-800 dark:text-foreground", children: e.label }),
|
|
227
|
+
/* @__PURE__ */ t($, { text: e.source })
|
|
228
|
+
] }, e.label)) }) }),
|
|
229
|
+
r.candidates.length > 0 && /* @__PURE__ */ s(B, { title: "Labels with no field", children: [
|
|
230
|
+
/* @__PURE__ */ t("p", { className: x, children: "Not created. Add them as fields in the data model first if the form needs them." }),
|
|
231
|
+
/* @__PURE__ */ t("ul", { className: "mt-1 space-y-0.5", "data-ai-candidates": "", children: r.candidates.map((e) => /* @__PURE__ */ s("li", { className: "text-[12.5px] text-slate-700 dark:text-foreground", children: [
|
|
232
|
+
e.label,
|
|
233
|
+
/* @__PURE__ */ t("span", { className: "text-slate-500 dark:text-muted-foreground", children: [e.type, e.group ? `in ${e.group}` : null].filter(Boolean).length ? ` · ${[e.type, e.group ? `in ${e.group}` : null].filter(Boolean).join(" · ")}` : "" })
|
|
234
|
+
] }, e.label)) })
|
|
235
|
+
] }),
|
|
236
|
+
i.notes.map((e) => /* @__PURE__ */ t("p", { className: te, children: e }, e)),
|
|
237
|
+
/* @__PURE__ */ s("div", { className: "flex items-center justify-end gap-1.5 pt-1", children: [
|
|
238
|
+
/* @__PURE__ */ t("button", { type: "button", className: j, onClick: k, children: "Back" }),
|
|
239
|
+
/* @__PURE__ */ t(
|
|
240
|
+
"button",
|
|
241
|
+
{
|
|
242
|
+
type: "button",
|
|
243
|
+
className: z,
|
|
244
|
+
disabled: i.ops.length === 0 || N,
|
|
245
|
+
onClick: () => C(A),
|
|
246
|
+
"data-ai-apply": "",
|
|
247
|
+
children: b(i)
|
|
248
|
+
}
|
|
249
|
+
)
|
|
250
|
+
] })
|
|
251
|
+
] });
|
|
252
|
+
}
|
|
253
|
+
function B({ title: o, children: n }) {
|
|
254
|
+
return /* @__PURE__ */ s("div", { className: g(G, "space-y-1.5 px-2.5 py-2"), children: [
|
|
255
|
+
/* @__PURE__ */ t("p", { className: F, children: o }),
|
|
256
|
+
n
|
|
257
|
+
] });
|
|
258
|
+
}
|
|
259
|
+
function $({ text: o }) {
|
|
260
|
+
return /* @__PURE__ */ s("span", { className: "mt-0.5 flex items-start gap-1 text-[11.5px] italic leading-snug text-slate-500 dark:text-muted-foreground", children: [
|
|
261
|
+
/* @__PURE__ */ t(q, { className: "mt-0.5 h-3 w-3 shrink-0 not-italic" }),
|
|
262
|
+
o
|
|
263
|
+
] });
|
|
264
|
+
}
|
|
265
|
+
export {
|
|
266
|
+
he as AiComposer,
|
|
267
|
+
ee as MODE_COPY,
|
|
268
|
+
j as ghostBtn,
|
|
269
|
+
z as primaryBtn,
|
|
270
|
+
x as quiet
|
|
271
|
+
};
|