@nivaro/react 0.2.52 → 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 +116 -2
- package/dist/layout-editor.d.ts +248 -2
- package/dist/shared/components/FormWhatsNew.js +60 -0
- package/dist/shared/components/ItemEditForm.js +3994 -3876
- 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,383 @@
|
|
|
1
|
+
import { jsxs as l, jsx as t, Fragment as V } from "react/jsx-runtime";
|
|
2
|
+
import { useQueryClient as Z, useQuery as ee } from "@tanstack/react-query";
|
|
3
|
+
import { Sparkles as te } from "lucide-react";
|
|
4
|
+
import { useState as p, useMemo as ae } from "react";
|
|
5
|
+
import { useNivaroClient as le } from "../../../context.js";
|
|
6
|
+
import { get as se, post as I } from "../../../lib/commands.js";
|
|
7
|
+
import { cn as v } from "../../../lib/utils.js";
|
|
8
|
+
import { Checkbox as ne } from "../../ui/checkbox.js";
|
|
9
|
+
import { collectionMetaKey as re } from "../collection-meta.js";
|
|
10
|
+
import { tintCard as z } from "../panel-style.js";
|
|
11
|
+
import { smallBtn as P, quietText as y, PickList as oe, Segmented as ie } from "../settings/controls.js";
|
|
12
|
+
import { parseSaveFailure as H } from "../useLayoutDraft.js";
|
|
13
|
+
import { draftTranslations as ce, approveDraftOps as U, staleReason as F, planTextOps as de, planLabel as he } from "./text-ops.js";
|
|
14
|
+
const J = [
|
|
15
|
+
{
|
|
16
|
+
id: "glossary",
|
|
17
|
+
label: "Glossary terms",
|
|
18
|
+
effect: "Labels and help that use another word for a glossary term, rewritten to the term.",
|
|
19
|
+
needsAi: !1
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
id: "intros",
|
|
23
|
+
label: "Section intros",
|
|
24
|
+
effect: "A short note at the top of each step or section: what to fill in and why.",
|
|
25
|
+
needsAi: !0
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
id: "placeholders",
|
|
29
|
+
label: "Placeholders",
|
|
30
|
+
effect: "Example text from the shape of stored values — never a real value.",
|
|
31
|
+
needsAi: !1
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
id: "choices",
|
|
35
|
+
label: "Choice labels",
|
|
36
|
+
effect: "Readable words for coded dropdown choices such as $t:pending_approval.",
|
|
37
|
+
needsAi: !1
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
id: "reading",
|
|
41
|
+
label: "Plain language",
|
|
42
|
+
effect: "Scores every label and help text, worst first, with simpler rewrites.",
|
|
43
|
+
needsAi: !1
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
id: "translate",
|
|
47
|
+
label: "Translations",
|
|
48
|
+
effect: "Draft labels and help in another language; drafts wait for your approval.",
|
|
49
|
+
needsAi: !0
|
|
50
|
+
}
|
|
51
|
+
];
|
|
52
|
+
function Ce({
|
|
53
|
+
layoutId: a,
|
|
54
|
+
bundle: n,
|
|
55
|
+
collection: k,
|
|
56
|
+
apply: m
|
|
57
|
+
}) {
|
|
58
|
+
var G;
|
|
59
|
+
const h = le(), S = Z(), [f, w] = p(null), [$, X] = p(null), [A, R] = p(!1), [M, T] = p(null), [D, O] = p(null), [s, L] = p(null), [B, q] = p(/* @__PURE__ */ new Set()), [K, Q] = p(/* @__PURE__ */ new Map()), { data: x } = ee({
|
|
60
|
+
queryKey: ["layout-editor", "ai-text", "locales", a],
|
|
61
|
+
queryFn: () => h.request(se(`/ai-design/layouts/${a}/text/locales`)).then((e) => (e == null ? void 0 : e.data) ?? null),
|
|
62
|
+
staleTime: 6e4
|
|
63
|
+
}), Y = (x == null ? void 0 : x.ai_configured) ?? !1, u = ae(() => ce(n), [n]), W = async (e, c = $) => {
|
|
64
|
+
if (w(e), L(null), T(null), O(null), !(e === "translate" && !c)) {
|
|
65
|
+
R(!0);
|
|
66
|
+
try {
|
|
67
|
+
const r = await h.request(
|
|
68
|
+
I(`/ai-design/layouts/${a}/text/${e}`, e === "translate" ? { locale: c } : {})
|
|
69
|
+
), o = (r == null ? void 0 : r.data) ?? null;
|
|
70
|
+
L(o), q(
|
|
71
|
+
new Set(((o == null ? void 0 : o.proposals) ?? []).filter((b) => !F(n, b)).map((b) => b.id))
|
|
72
|
+
), Q(/* @__PURE__ */ new Map());
|
|
73
|
+
} catch (r) {
|
|
74
|
+
const o = H(r, "The tool could not run");
|
|
75
|
+
T(
|
|
76
|
+
o.status === 503 ? "AI is not set up here. Glossary terms, placeholders, choice labels and plain language still work from rules." : o.message
|
|
77
|
+
);
|
|
78
|
+
} finally {
|
|
79
|
+
R(!1);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}, _ = async (e) => {
|
|
83
|
+
if (!s || e.length === 0) return;
|
|
84
|
+
T(null);
|
|
85
|
+
const c = e.filter(
|
|
86
|
+
(i) => {
|
|
87
|
+
var d;
|
|
88
|
+
return i.key === "choices" && ((d = i.choices) == null ? void 0 : d.from) === "field" && K.get(i.id) === "field";
|
|
89
|
+
}
|
|
90
|
+
), r = de(n, e, new Set(c.map((i) => i.id)));
|
|
91
|
+
r.ops.length && m(r.ops, { label: he(s.tool, r.applied.length) });
|
|
92
|
+
const o = [];
|
|
93
|
+
for (const i of c)
|
|
94
|
+
if (!(i.target.kind !== "placement" || !i.choices))
|
|
95
|
+
try {
|
|
96
|
+
await h.request(
|
|
97
|
+
I(`/ai-design/layouts/${a}/text/choices/field`, {
|
|
98
|
+
field: i.target.field,
|
|
99
|
+
choices: i.choices.changed.map((d) => ({ value: d.value, text: d.after }))
|
|
100
|
+
})
|
|
101
|
+
), o.push(i.id);
|
|
102
|
+
} catch (d) {
|
|
103
|
+
T(H(d, "The field could not be changed").message);
|
|
104
|
+
}
|
|
105
|
+
o.length && S.invalidateQueries({ queryKey: re(k) });
|
|
106
|
+
const b = /* @__PURE__ */ new Set([...r.applied, ...o]), C = [];
|
|
107
|
+
r.applied.length && C.push(
|
|
108
|
+
`${r.applied.length} change${r.applied.length === 1 ? "" : "s"} on this form (Undo reverts them)`
|
|
109
|
+
), o.length && C.push(
|
|
110
|
+
`${o.length} field${o.length === 1 ? "" : "s"} relabelled on every form`
|
|
111
|
+
), r.skipped.length && C.push(`${r.skipped.length} skipped: ${r.skipped[0].why}`), O(C.join(" · ") || "Nothing changed"), L({ ...s, proposals: s.proposals.filter((i) => !b.has(i.id)) }), q((i) => new Set([...i].filter((d) => !b.has(d))));
|
|
112
|
+
}, g = (s == null ? void 0 : s.proposals) ?? [], N = g.filter((e) => B.has(e.id)), E = J.find((e) => e.id === f);
|
|
113
|
+
return /* @__PURE__ */ l("div", { "data-ai-text-tools": "", className: "space-y-2.5", children: [
|
|
114
|
+
/* @__PURE__ */ t("div", { className: "flex flex-wrap gap-1.5", children: J.map((e) => {
|
|
115
|
+
const c = e.needsAi && !Y;
|
|
116
|
+
return /* @__PURE__ */ t(
|
|
117
|
+
"button",
|
|
118
|
+
{
|
|
119
|
+
type: "button",
|
|
120
|
+
"data-ai-text-tool": e.id,
|
|
121
|
+
disabled: A || c,
|
|
122
|
+
"data-tip": c ? "Needs AI — set it up under Settings → AI Features" : e.effect,
|
|
123
|
+
onClick: () => void W(e.id),
|
|
124
|
+
className: v(
|
|
125
|
+
P,
|
|
126
|
+
f === e.id && "border-nvr-cyan/50 bg-nvr-cyan/10 text-slate-900 dark:border-nvr-cyan/40 dark:text-foreground"
|
|
127
|
+
),
|
|
128
|
+
children: e.label
|
|
129
|
+
},
|
|
130
|
+
e.id
|
|
131
|
+
);
|
|
132
|
+
}) }),
|
|
133
|
+
E && /* @__PURE__ */ t("p", { className: y, children: E.effect }),
|
|
134
|
+
f === "translate" && /* @__PURE__ */ t(
|
|
135
|
+
pe,
|
|
136
|
+
{
|
|
137
|
+
locales: (x == null ? void 0 : x.locales) ?? [],
|
|
138
|
+
locale: $,
|
|
139
|
+
busy: A,
|
|
140
|
+
onPick: (e) => {
|
|
141
|
+
X(e), e && W("translate", e);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
),
|
|
145
|
+
f === "translate" && u.length > 0 && /* @__PURE__ */ l("div", { "data-ai-text-drafts": "", className: v(z, "space-y-1.5 p-2.5 text-[12px]"), children: [
|
|
146
|
+
/* @__PURE__ */ l("div", { className: "flex items-center justify-between gap-2", children: [
|
|
147
|
+
/* @__PURE__ */ l("span", { className: "font-medium text-slate-700 dark:text-foreground", children: [
|
|
148
|
+
u.length,
|
|
149
|
+
" translation draft",
|
|
150
|
+
u.length === 1 ? "" : "s",
|
|
151
|
+
" waiting for approval"
|
|
152
|
+
] }),
|
|
153
|
+
/* @__PURE__ */ t(
|
|
154
|
+
"button",
|
|
155
|
+
{
|
|
156
|
+
type: "button",
|
|
157
|
+
className: P,
|
|
158
|
+
onClick: () => m(U(n, u), {
|
|
159
|
+
label: `Approve ${u.length} translation${u.length === 1 ? "" : "s"}`
|
|
160
|
+
}),
|
|
161
|
+
children: "Approve all"
|
|
162
|
+
}
|
|
163
|
+
)
|
|
164
|
+
] }),
|
|
165
|
+
/* @__PURE__ */ t("ul", { className: "space-y-1", children: u.slice(0, 12).map((e) => /* @__PURE__ */ l("li", { className: "flex items-center gap-2", children: [
|
|
166
|
+
/* @__PURE__ */ l("span", { className: "min-w-0 flex-1 truncate text-slate-600 dark:text-muted-foreground", children: [
|
|
167
|
+
/* @__PURE__ */ t("span", { className: "font-mono text-[11px]", children: e.locale }),
|
|
168
|
+
" ",
|
|
169
|
+
e.field,
|
|
170
|
+
": “",
|
|
171
|
+
e.label,
|
|
172
|
+
"”"
|
|
173
|
+
] }),
|
|
174
|
+
/* @__PURE__ */ t(
|
|
175
|
+
"button",
|
|
176
|
+
{
|
|
177
|
+
type: "button",
|
|
178
|
+
className: "text-[12px] font-medium text-nvr-navy hover:underline dark:text-nvr-cyan",
|
|
179
|
+
onClick: () => m(U(n, [e]), {
|
|
180
|
+
label: `Approve the ${e.locale} translation of ${e.field}`
|
|
181
|
+
}),
|
|
182
|
+
children: "Approve"
|
|
183
|
+
}
|
|
184
|
+
)
|
|
185
|
+
] }, `${e.locale}:${e.group_key}:${e.field}`)) })
|
|
186
|
+
] }),
|
|
187
|
+
A && /* @__PURE__ */ l("p", { className: v(y, "flex items-center gap-1.5"), children: [
|
|
188
|
+
/* @__PURE__ */ t(te, { className: "h-3.5 w-3.5 animate-pulse text-nvr-cyan" }),
|
|
189
|
+
"Reading the form…"
|
|
190
|
+
] }),
|
|
191
|
+
M && /* @__PURE__ */ t("p", { className: "text-[12px] text-[#9c2f47] dark:text-[#f08aa1]", children: M }),
|
|
192
|
+
D && /* @__PURE__ */ t("p", { "data-ai-text-done": "", className: "text-[12px] text-slate-700 dark:text-foreground", children: D }),
|
|
193
|
+
s && !A && /* @__PURE__ */ l("div", { "data-ai-text-result": s.tool, className: "space-y-2", children: [
|
|
194
|
+
s.terms && s.terms.length > 0 && /* @__PURE__ */ l("div", { className: v(z, "p-2.5 text-[12px]"), children: [
|
|
195
|
+
/* @__PURE__ */ t("p", { className: "mb-1 font-medium text-slate-700 dark:text-foreground", children: "Words that are not the glossary term" }),
|
|
196
|
+
/* @__PURE__ */ t("ul", { className: "space-y-0.5 text-slate-600 dark:text-muted-foreground", children: s.terms.map((e) => /* @__PURE__ */ l("li", { children: [
|
|
197
|
+
"“",
|
|
198
|
+
e.found,
|
|
199
|
+
"” should be “",
|
|
200
|
+
e.term,
|
|
201
|
+
"” — ",
|
|
202
|
+
e.places.length,
|
|
203
|
+
" place",
|
|
204
|
+
e.places.length === 1 ? "" : "s"
|
|
205
|
+
] }, `${e.found}:${e.term}`)) })
|
|
206
|
+
] }),
|
|
207
|
+
s.note && /* @__PURE__ */ t("p", { className: y, children: s.note }),
|
|
208
|
+
g.length > 0 && /* @__PURE__ */ l(V, { children: [
|
|
209
|
+
/* @__PURE__ */ t("ul", { className: "space-y-1", children: g.map((e) => /* @__PURE__ */ t(
|
|
210
|
+
me,
|
|
211
|
+
{
|
|
212
|
+
p: e,
|
|
213
|
+
stale: F(n, e),
|
|
214
|
+
checked: B.has(e.id),
|
|
215
|
+
onCheck: (c) => q((r) => {
|
|
216
|
+
const o = new Set(r);
|
|
217
|
+
return c ? o.add(e.id) : o.delete(e.id), o;
|
|
218
|
+
}),
|
|
219
|
+
target: K.get(e.id) ?? "layout",
|
|
220
|
+
onTarget: (c) => Q((r) => new Map(r).set(e.id, c))
|
|
221
|
+
},
|
|
222
|
+
e.id
|
|
223
|
+
)) }),
|
|
224
|
+
/* @__PURE__ */ l("div", { className: "flex flex-wrap items-center gap-1.5", children: [
|
|
225
|
+
/* @__PURE__ */ l(
|
|
226
|
+
"button",
|
|
227
|
+
{
|
|
228
|
+
type: "button",
|
|
229
|
+
"data-ai-text-apply": "",
|
|
230
|
+
disabled: N.length === 0,
|
|
231
|
+
onClick: () => void _(N),
|
|
232
|
+
className: "inline-flex h-7 items-center rounded-md bg-nvr-cyan px-2.5 text-[12px] font-medium text-white transition-colors hover:bg-nvr-cyan-dark disabled:opacity-50",
|
|
233
|
+
children: [
|
|
234
|
+
"Apply ",
|
|
235
|
+
N.length === g.length ? "all" : `${N.length} selected`
|
|
236
|
+
]
|
|
237
|
+
}
|
|
238
|
+
),
|
|
239
|
+
N.length !== g.length && /* @__PURE__ */ t(
|
|
240
|
+
"button",
|
|
241
|
+
{
|
|
242
|
+
type: "button",
|
|
243
|
+
className: P,
|
|
244
|
+
onClick: () => void _(g.filter((e) => !F(n, e))),
|
|
245
|
+
children: "Apply all"
|
|
246
|
+
}
|
|
247
|
+
)
|
|
248
|
+
] })
|
|
249
|
+
] }),
|
|
250
|
+
s.flagged && s.flagged.length > 0 && /* @__PURE__ */ l("div", { className: "space-y-1", children: [
|
|
251
|
+
/* @__PURE__ */ t("p", { className: "text-[12px] font-medium text-slate-700 dark:text-foreground", children: "Hard to read, no plainer wording found" }),
|
|
252
|
+
/* @__PURE__ */ t("ul", { className: "space-y-1", children: s.flagged.map((e) => /* @__PURE__ */ l("li", { className: "flex items-start gap-2 text-[12px]", children: [
|
|
253
|
+
/* @__PURE__ */ t(j, { score: e.score }),
|
|
254
|
+
/* @__PURE__ */ l("span", { className: "min-w-0 text-slate-600 dark:text-muted-foreground", children: [
|
|
255
|
+
e.place,
|
|
256
|
+
": “",
|
|
257
|
+
e.text,
|
|
258
|
+
"”",
|
|
259
|
+
e.reasons.length > 0 && ` — ${e.reasons.join("; ")}`
|
|
260
|
+
] })
|
|
261
|
+
] }, `${e.place}:${e.text}`)) })
|
|
262
|
+
] }),
|
|
263
|
+
s.dropped > 0 && /* @__PURE__ */ l("p", { className: y, children: [
|
|
264
|
+
s.dropped,
|
|
265
|
+
" AI suggestion",
|
|
266
|
+
s.dropped === 1 ? "" : "s",
|
|
267
|
+
" left out: named something not on this form or failed a check."
|
|
268
|
+
] }),
|
|
269
|
+
g.length === 0 && !s.note && !((G = s.flagged) != null && G.length) && /* @__PURE__ */ t("p", { className: y, children: "Nothing to change." })
|
|
270
|
+
] })
|
|
271
|
+
] });
|
|
272
|
+
}
|
|
273
|
+
function pe({
|
|
274
|
+
locales: a,
|
|
275
|
+
locale: n,
|
|
276
|
+
busy: k,
|
|
277
|
+
onPick: m
|
|
278
|
+
}) {
|
|
279
|
+
return a.length === 0 ? /* @__PURE__ */ t("p", { className: y, children: "No other languages are set up. Add them under Settings → Localization." }) : /* @__PURE__ */ t(
|
|
280
|
+
oe,
|
|
281
|
+
{
|
|
282
|
+
ariaLabel: "Language",
|
|
283
|
+
value: n,
|
|
284
|
+
disabled: k,
|
|
285
|
+
placeholder: "Pick a language…",
|
|
286
|
+
options: a.map((h) => ({ value: h, label: h })),
|
|
287
|
+
onChange: m
|
|
288
|
+
}
|
|
289
|
+
);
|
|
290
|
+
}
|
|
291
|
+
function j({ score: a }) {
|
|
292
|
+
const n = a >= 70 ? "plain" : a >= 50 ? "fair" : "hard";
|
|
293
|
+
return /* @__PURE__ */ t(
|
|
294
|
+
"span",
|
|
295
|
+
{
|
|
296
|
+
"data-tip": `Plain-language score ${a} of 100`,
|
|
297
|
+
className: v(
|
|
298
|
+
"inline-flex h-5 shrink-0 items-center rounded px-1.5 font-mono text-[11px] tabular-nums",
|
|
299
|
+
n === "plain" && "bg-emerald-50 text-emerald-700 dark:bg-emerald-500/10 dark:text-emerald-300",
|
|
300
|
+
n === "fair" && "bg-amber-50 text-amber-700 dark:bg-amber-500/10 dark:text-amber-300",
|
|
301
|
+
n === "hard" && "bg-[#fae6eb] text-[#9c2f47] dark:bg-[#3d1621] dark:text-[#f08aa1]"
|
|
302
|
+
),
|
|
303
|
+
children: a
|
|
304
|
+
}
|
|
305
|
+
);
|
|
306
|
+
}
|
|
307
|
+
function me({
|
|
308
|
+
p: a,
|
|
309
|
+
stale: n,
|
|
310
|
+
checked: k,
|
|
311
|
+
onCheck: m,
|
|
312
|
+
target: h,
|
|
313
|
+
onTarget: S
|
|
314
|
+
}) {
|
|
315
|
+
var w;
|
|
316
|
+
const f = `ai-text-${a.id}`;
|
|
317
|
+
return /* @__PURE__ */ l(
|
|
318
|
+
"li",
|
|
319
|
+
{
|
|
320
|
+
"data-ai-text-proposal": a.id,
|
|
321
|
+
className: v(
|
|
322
|
+
"flex items-start gap-2 rounded-md px-1.5 py-1 hover:bg-muted",
|
|
323
|
+
n && "opacity-60"
|
|
324
|
+
),
|
|
325
|
+
children: [
|
|
326
|
+
/* @__PURE__ */ t(
|
|
327
|
+
ne,
|
|
328
|
+
{
|
|
329
|
+
id: f,
|
|
330
|
+
className: "mt-0.5",
|
|
331
|
+
checked: k && !n,
|
|
332
|
+
disabled: !!n,
|
|
333
|
+
onCheckedChange: ($) => m($ === !0)
|
|
334
|
+
}
|
|
335
|
+
),
|
|
336
|
+
/* @__PURE__ */ l("div", { className: "min-w-0 flex-1 space-y-1", children: [
|
|
337
|
+
/* @__PURE__ */ t(
|
|
338
|
+
"label",
|
|
339
|
+
{
|
|
340
|
+
htmlFor: f,
|
|
341
|
+
className: "block text-[12.5px] leading-snug text-slate-800 dark:text-foreground",
|
|
342
|
+
children: a.sentence
|
|
343
|
+
}
|
|
344
|
+
),
|
|
345
|
+
/* @__PURE__ */ l("div", { className: "flex flex-wrap items-center gap-1.5 text-[11.5px] text-slate-500 dark:text-muted-foreground", children: [
|
|
346
|
+
a.score && /* @__PURE__ */ l("span", { className: "inline-flex items-center gap-1", children: [
|
|
347
|
+
/* @__PURE__ */ t(j, { score: a.score.before }),
|
|
348
|
+
a.score.after != null && /* @__PURE__ */ l(V, { children: [
|
|
349
|
+
"→",
|
|
350
|
+
/* @__PURE__ */ t(j, { score: a.score.after })
|
|
351
|
+
] })
|
|
352
|
+
] }),
|
|
353
|
+
/* @__PURE__ */ t("span", { children: a.source === "ai" ? "Written by AI" : "From rules" }),
|
|
354
|
+
(w = a.score) != null && w.reasons.length ? /* @__PURE__ */ l("span", { children: [
|
|
355
|
+
"· ",
|
|
356
|
+
a.score.reasons.join("; ")
|
|
357
|
+
] }) : null,
|
|
358
|
+
a.tone === "warn" && /* @__PURE__ */ t("span", { children: "· shown as a warning" }),
|
|
359
|
+
n && /* @__PURE__ */ l("span", { className: "text-[#9c2f47] dark:text-[#f08aa1]", children: [
|
|
360
|
+
"· ",
|
|
361
|
+
n
|
|
362
|
+
] })
|
|
363
|
+
] }),
|
|
364
|
+
a.key === "choices" && a.choices && /* @__PURE__ */ t("div", { className: "flex items-center gap-2", children: a.choices.from === "field" ? /* @__PURE__ */ t(
|
|
365
|
+
ie,
|
|
366
|
+
{
|
|
367
|
+
ariaLabel: "Where the labels go",
|
|
368
|
+
value: h,
|
|
369
|
+
options: [
|
|
370
|
+
{ value: "layout", label: "This form" },
|
|
371
|
+
{ value: "field", label: "The field (every form)" }
|
|
372
|
+
],
|
|
373
|
+
onChange: S
|
|
374
|
+
}
|
|
375
|
+
) : /* @__PURE__ */ t("span", { className: "text-[11.5px] text-slate-500 dark:text-muted-foreground", children: "This form keeps its own choice list, so the labels go on this form." }) })
|
|
376
|
+
] })
|
|
377
|
+
]
|
|
378
|
+
}
|
|
379
|
+
);
|
|
380
|
+
}
|
|
381
|
+
export {
|
|
382
|
+
Ce as AiTextTools
|
|
383
|
+
};
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { applyLayoutOps as k } from "../../../lib/layout-ops.js";
|
|
2
|
+
import { asObject as a, readOverrides as p, findPlacement as h, withKey as f } from "../inspector/model.js";
|
|
3
|
+
const g = (i) => JSON.stringify(i ?? null);
|
|
4
|
+
function y(i, e) {
|
|
5
|
+
return e.target.kind === "placement" ? h(i, e.target.field, e.target.group_key) : null;
|
|
6
|
+
}
|
|
7
|
+
function w(i, e) {
|
|
8
|
+
if (e.target.kind === "group") {
|
|
9
|
+
const r = e.target.key, t = i.groups.find((s) => s.key === r);
|
|
10
|
+
return t ? e.key === "label" ? t.label : t.content ?? null : void 0;
|
|
11
|
+
}
|
|
12
|
+
const n = y(i, e);
|
|
13
|
+
if (!n) return;
|
|
14
|
+
const o = p(n);
|
|
15
|
+
return e.key === "choices" ? a(o.options).choices ?? null : e.key === "i18n" ? e.i18n ? a(o.i18n)[e.i18n.locale] ?? null : null : o[e.key] ?? null;
|
|
16
|
+
}
|
|
17
|
+
function _(i, e) {
|
|
18
|
+
const n = w(i, e);
|
|
19
|
+
return n === void 0 ? e.target.kind === "group" ? "The section is gone" : "The field is no longer here" : g(n) === g(e.base) ? null : "Changed since you asked";
|
|
20
|
+
}
|
|
21
|
+
function b(i, e) {
|
|
22
|
+
if (e.target.kind === "group") {
|
|
23
|
+
const t = e.key === "label" ? { label: e.after } : { content: e.after, content_tone: e.tone ?? "info" };
|
|
24
|
+
return { op: "group_update", key: e.target.key, patch: t };
|
|
25
|
+
}
|
|
26
|
+
const n = y(i, e);
|
|
27
|
+
if (!n) return null;
|
|
28
|
+
const o = p(n);
|
|
29
|
+
let r;
|
|
30
|
+
if (e.key === "choices") {
|
|
31
|
+
if (!e.choices) return null;
|
|
32
|
+
r = f(o, "options", f(a(o.options), "choices", e.choices.all));
|
|
33
|
+
} else if (e.key === "i18n") {
|
|
34
|
+
if (!e.i18n) return null;
|
|
35
|
+
const { locale: t, label: s, help: l } = e.i18n, c = { label: s, draft: !0 };
|
|
36
|
+
l && (c.help = l), r = f(o, "i18n", { ...a(o.i18n), [t]: c });
|
|
37
|
+
} else
|
|
38
|
+
r = f(o, e.key, e.after);
|
|
39
|
+
return {
|
|
40
|
+
op: "update_placement",
|
|
41
|
+
at: { field: n.field, group_key: n.group_key },
|
|
42
|
+
patch: { overrides: r }
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function O(i, e, n = /* @__PURE__ */ new Set()) {
|
|
46
|
+
let o = i;
|
|
47
|
+
const r = [], t = [], s = [];
|
|
48
|
+
for (const l of e) {
|
|
49
|
+
if (l.key === "choices" && n.has(l.id)) continue;
|
|
50
|
+
const c = _(o, l);
|
|
51
|
+
if (c) {
|
|
52
|
+
s.push({ id: l.id, why: c });
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
const d = b(o, l);
|
|
56
|
+
if (!d) {
|
|
57
|
+
s.push({ id: l.id, why: "Nothing to change" });
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
try {
|
|
61
|
+
o = k(o, [d]), r.push(d), t.push(l.id);
|
|
62
|
+
} catch (u) {
|
|
63
|
+
s.push({ id: l.id, why: u instanceof Error ? u.message : String(u) });
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return { ops: r, applied: t, skipped: s };
|
|
67
|
+
}
|
|
68
|
+
function $(i, e) {
|
|
69
|
+
return `AI ${{
|
|
70
|
+
glossary: "glossary wording",
|
|
71
|
+
intros: "section intros",
|
|
72
|
+
placeholders: "placeholders",
|
|
73
|
+
choices: "choice labels",
|
|
74
|
+
reading: "plainer wording",
|
|
75
|
+
translate: "translation drafts"
|
|
76
|
+
}[i] ?? "wording"}: ${e} change${e === 1 ? "" : "s"}`;
|
|
77
|
+
}
|
|
78
|
+
function T(i) {
|
|
79
|
+
const e = [];
|
|
80
|
+
for (const n of i.placements) {
|
|
81
|
+
const o = a(p(n).i18n);
|
|
82
|
+
for (const [r, t] of Object.entries(o)) {
|
|
83
|
+
const s = a(t);
|
|
84
|
+
s.draft === !0 && e.push({
|
|
85
|
+
field: n.field,
|
|
86
|
+
group_key: n.group_key,
|
|
87
|
+
locale: r,
|
|
88
|
+
label: typeof s.label == "string" ? s.label : "",
|
|
89
|
+
help: typeof s.help == "string" ? s.help : null
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return e;
|
|
94
|
+
}
|
|
95
|
+
function S(i, e) {
|
|
96
|
+
const n = /* @__PURE__ */ new Map();
|
|
97
|
+
for (const r of e) {
|
|
98
|
+
const t = `${r.group_key ?? ""}\0${r.field}`;
|
|
99
|
+
n.set(t, [...n.get(t) ?? [], r]);
|
|
100
|
+
}
|
|
101
|
+
const o = [];
|
|
102
|
+
for (const r of n.values()) {
|
|
103
|
+
const t = h(i, r[0].field, r[0].group_key);
|
|
104
|
+
if (!t) continue;
|
|
105
|
+
const s = p(t), l = { ...a(s.i18n) };
|
|
106
|
+
for (const c of r) {
|
|
107
|
+
const { draft: d, ...u } = a(l[c.locale]);
|
|
108
|
+
l[c.locale] = u;
|
|
109
|
+
}
|
|
110
|
+
o.push({
|
|
111
|
+
op: "update_placement",
|
|
112
|
+
at: { field: t.field, group_key: t.group_key },
|
|
113
|
+
patch: { overrides: f(s, "i18n", l) }
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
return o;
|
|
117
|
+
}
|
|
118
|
+
export {
|
|
119
|
+
S as approveDraftOps,
|
|
120
|
+
w as currentBase,
|
|
121
|
+
T as draftTranslations,
|
|
122
|
+
$ as planLabel,
|
|
123
|
+
O as planTextOps,
|
|
124
|
+
_ as staleReason
|
|
125
|
+
};
|