@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,263 @@
|
|
|
1
|
+
var P = Object.defineProperty;
|
|
2
|
+
var R = (s, o, n) => o in s ? P(s, o, { enumerable: !0, configurable: !0, writable: !0, value: n }) : s[o] = n;
|
|
3
|
+
var w = (s, o, n) => R(s, typeof o != "symbol" ? o + "" : o, n);
|
|
4
|
+
import { applyLayoutOps as x, GROUP_PATCH_KEYS as z } from "../../../lib/layout-ops.js";
|
|
5
|
+
import { titleCase as T } from "../../../lib/utils.js";
|
|
6
|
+
import { placementOf as C } from "../commands/intents.js";
|
|
7
|
+
import { asArray as H, lockConditionsColumn as K, readOverrides as W } from "../inspector/model.js";
|
|
8
|
+
import { humanizeOpError as G } from "../useLayoutDraft.js";
|
|
9
|
+
const A = 4;
|
|
10
|
+
function k(s) {
|
|
11
|
+
return s.length <= A ? s.join(", ") : `${s.slice(0, A).join(", ")} and ${s.length - A} more`;
|
|
12
|
+
}
|
|
13
|
+
const L = (s, o) => `${s} ${o}${s === 1 ? "" : "s"}`;
|
|
14
|
+
function _(s, o) {
|
|
15
|
+
var n;
|
|
16
|
+
return ((n = s.fields.find((e) => e.field === o)) == null ? void 0 : n.label) || T(o);
|
|
17
|
+
}
|
|
18
|
+
function U(s, o) {
|
|
19
|
+
const n = s.toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "").slice(0, 40) || "section";
|
|
20
|
+
let e = n;
|
|
21
|
+
for (let t = 2; o.has(e); t++) e = `${n}_${t}`;
|
|
22
|
+
return o.add(e), e;
|
|
23
|
+
}
|
|
24
|
+
class O {
|
|
25
|
+
constructor(o) {
|
|
26
|
+
w(this, "work");
|
|
27
|
+
w(this, "ops", []);
|
|
28
|
+
w(this, "steps", []);
|
|
29
|
+
w(this, "notes", []);
|
|
30
|
+
this.work = x(o, [{ op: "layout_update", patch: {} }]);
|
|
31
|
+
}
|
|
32
|
+
/** True when the op applied. */
|
|
33
|
+
try(o, n) {
|
|
34
|
+
try {
|
|
35
|
+
return this.work = x(this.work, [o]), this.ops.push(o), !0;
|
|
36
|
+
} catch (e) {
|
|
37
|
+
return n && this.notes.push(n(G(e.message))), !1;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
result() {
|
|
41
|
+
return { ops: this.ops, steps: this.steps, notes: this.notes };
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const q = (s) => s.type === "tab" || s.type === "section";
|
|
45
|
+
function Y(s, o, n) {
|
|
46
|
+
var S;
|
|
47
|
+
const e = new O(s), t = o.layout === "steps" ? "tab" : "section", r = t === "tab" ? "step" : "section", p = e.work.groups.filter((i) => !i.key.startsWith("__")), l = t === "tab" ? ((S = p.find((i) => i.type === "tab")) == null ? void 0 : S.parent_key) ?? null : null, u = new Set(e.work.groups.map((i) => i.key)), c = /* @__PURE__ */ new Set(), b = new Set(n.fields.map((i) => i.field));
|
|
48
|
+
o.groups.forEach((i, d) => {
|
|
49
|
+
const f = i.fields.filter((a) => b.has(a)), y = i.fields.filter((a) => !b.has(a));
|
|
50
|
+
if (y.length && e.notes.push(`Left out ${k(y)}: not a field of this collection.`), f.length === 0) return;
|
|
51
|
+
const g = p.find(
|
|
52
|
+
(a) => q(a) && !c.has(a.key) && a.label.trim().toLowerCase() === i.label.trim().toLowerCase() && (a.parent_key === null || a.parent_key === l)
|
|
53
|
+
);
|
|
54
|
+
let h;
|
|
55
|
+
if (g) {
|
|
56
|
+
c.add(g.key), h = g.key;
|
|
57
|
+
const a = () => g.type === t || e.try({ op: "group_update", key: h, patch: { type: t } }, ($) => `"${g.label}": ${$}`), m = t === "tab" ? l : null;
|
|
58
|
+
t === "tab" && a(), e.try({ op: "group_move", key: h, parent_key: m, index: d }), t !== "tab" && a(), e.steps.push(`Use the existing ${r} "${g.label}" as ${r} ${d + 1}`);
|
|
59
|
+
} else {
|
|
60
|
+
if (h = U(i.label, u), !e.try(
|
|
61
|
+
{
|
|
62
|
+
op: "group_create",
|
|
63
|
+
key: h,
|
|
64
|
+
label: i.label,
|
|
65
|
+
group_type: t,
|
|
66
|
+
parent_key: t === "tab" ? l : null,
|
|
67
|
+
index: d
|
|
68
|
+
},
|
|
69
|
+
(m) => `Could not add ${r} "${i.label}": ${m}`
|
|
70
|
+
)) return;
|
|
71
|
+
e.steps.push(`Add ${r} "${i.label}"`);
|
|
72
|
+
}
|
|
73
|
+
const v = [], E = [];
|
|
74
|
+
f.forEach((a, m) => {
|
|
75
|
+
const $ = C(e.work, a);
|
|
76
|
+
if ($) {
|
|
77
|
+
if ($.group_key === h && $.sort === m) return;
|
|
78
|
+
e.try({
|
|
79
|
+
op: "move",
|
|
80
|
+
from: { field: a, group_key: $.group_key },
|
|
81
|
+
to_group_key: h,
|
|
82
|
+
index: m
|
|
83
|
+
}) && v.push(_(n, a));
|
|
84
|
+
} else e.try({ op: "place", field: a, group_key: h, index: m }) && E.push(_(n, a));
|
|
85
|
+
});
|
|
86
|
+
const N = e.steps.length - 1, I = [
|
|
87
|
+
E.length ? `add ${k(E)}` : null,
|
|
88
|
+
v.length ? `move in ${k(v)}` : null
|
|
89
|
+
].filter(Boolean);
|
|
90
|
+
I.length && (e.steps[N] += `: ${I.join("; ")}`);
|
|
91
|
+
});
|
|
92
|
+
for (const i of p) {
|
|
93
|
+
if (!q(i) || c.has(i.key)) continue;
|
|
94
|
+
const d = e.work.placements.filter((y) => y.group_key === i.key), f = e.work.groups.some((y) => y.parent_key === i.key);
|
|
95
|
+
d.length === 0 && !f ? e.try({ op: "group_remove", key: i.key, placements: "ungroup" }) && e.steps.push(`Remove the empty ${i.type === "tab" ? "step" : "section"} "${i.label}"`) : d.length && e.notes.push(
|
|
96
|
+
`"${i.label}" stays: it still holds ${L(d.length, "field")} the AI did not place (${k(d.map((y) => _(n, y.field)))}).`
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
for (const i of e.work.groups.filter((d) => d.type === "container"))
|
|
100
|
+
!e.work.groups.some((f) => f.parent_key === i.key) && !e.work.placements.some((f) => f.group_key === i.key) && e.try({ op: "group_remove", key: i.key, placements: "ungroup" }) && e.steps.push(`Remove the empty tab group "${i.label}"`);
|
|
101
|
+
return t === "tab" && s.layout.tab_mode !== "steps" && o.groups.length > 1 && e.try({ op: "layout_update", patch: { tab_mode: "steps" } }) && e.steps.push("Show the tabs as steps, filled one after another"), o.dropped.length && e.notes.unshift(
|
|
102
|
+
`The AI named ${L(o.dropped.length, "thing")} this collection has no field for: ${k(o.dropped)}. Left out.`
|
|
103
|
+
), e.result();
|
|
104
|
+
}
|
|
105
|
+
const M = (s, o, n) => n.map((e) => {
|
|
106
|
+
var t;
|
|
107
|
+
return ((t = s.find((r) => r.pipeline_id === o && r.key === e)) == null ? void 0 : t.label) ?? e;
|
|
108
|
+
});
|
|
109
|
+
function X(s, o, n) {
|
|
110
|
+
const e = [];
|
|
111
|
+
for (const t of s.locks)
|
|
112
|
+
e.push({
|
|
113
|
+
id: `lock:${t.field}:${t.pipeline_id}`,
|
|
114
|
+
text: `Make ${_(n, t.field)} read-only in ${k(M(o, t.pipeline_id, t.state_keys))}`,
|
|
115
|
+
source: t.source,
|
|
116
|
+
checked: !0,
|
|
117
|
+
note: null
|
|
118
|
+
});
|
|
119
|
+
for (const t of s.requirements)
|
|
120
|
+
e.push({
|
|
121
|
+
id: `require:${t.field}`,
|
|
122
|
+
text: `Make ${_(n, t.field)} required`,
|
|
123
|
+
source: t.source,
|
|
124
|
+
checked: !1,
|
|
125
|
+
note: `The process needs it by ${M(o, t.pipeline_id, [t.state_key])[0]}. Required on a form applies in every state, so it starts unticked.`
|
|
126
|
+
});
|
|
127
|
+
return e;
|
|
128
|
+
}
|
|
129
|
+
function j(s, o, n, e, t) {
|
|
130
|
+
const r = new O(s);
|
|
131
|
+
for (const p of o.locks) {
|
|
132
|
+
if (!n.has(`lock:${p.field}:${p.pipeline_id}`)) continue;
|
|
133
|
+
const l = C(r.work, p.field), u = _(t, p.field);
|
|
134
|
+
if (!l) {
|
|
135
|
+
r.notes.push(`${u} is not on the form, so it gets no lock.`);
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
const c = H(l.lock_conditions), b = c.find((i) => i.type === "pipeline_state" && i.pipeline_id === p.pipeline_id), S = b ? c.map(
|
|
139
|
+
(i) => i === b ? { ...i, state_keys: [.../* @__PURE__ */ new Set([...i.state_keys ?? [], ...p.state_keys])] } : i
|
|
140
|
+
) : [...c, { type: "pipeline_state", pipeline_id: p.pipeline_id, state_keys: p.state_keys }];
|
|
141
|
+
r.try({
|
|
142
|
+
op: "update_placement",
|
|
143
|
+
at: { field: l.field, group_key: l.group_key },
|
|
144
|
+
patch: { lock_conditions: K(S) }
|
|
145
|
+
}) && r.steps.push(
|
|
146
|
+
`Make ${u} read-only in ${k(M(e, p.pipeline_id, p.state_keys))}`
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
for (const p of o.requirements) {
|
|
150
|
+
if (!n.has(`require:${p.field}`)) continue;
|
|
151
|
+
const l = C(r.work, p.field), u = _(t, p.field);
|
|
152
|
+
if (!l) {
|
|
153
|
+
r.notes.push(`${u} is not on the form, so it cannot be required here.`);
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
const c = W(l);
|
|
157
|
+
c.required !== !0 && r.try({
|
|
158
|
+
op: "update_placement",
|
|
159
|
+
at: { field: l.field, group_key: l.group_key },
|
|
160
|
+
patch: { overrides: { ...c, required: !0 } }
|
|
161
|
+
}) && r.steps.push(`Make ${u} required`);
|
|
162
|
+
}
|
|
163
|
+
return r.result();
|
|
164
|
+
}
|
|
165
|
+
function Z(s, o, n, e) {
|
|
166
|
+
const t = Y(s, o, n);
|
|
167
|
+
if (!e || e.chosen.size === 0) return t;
|
|
168
|
+
const r = x(s, t.ops), p = j(r, o, e.chosen, e.states, n);
|
|
169
|
+
return {
|
|
170
|
+
ops: [...t.ops, ...p.ops],
|
|
171
|
+
steps: [...t.steps, ...p.steps],
|
|
172
|
+
notes: [...t.notes, ...p.notes]
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
function ee(s, o, n, e) {
|
|
176
|
+
const t = new O(s);
|
|
177
|
+
t.try({
|
|
178
|
+
op: "layout_update",
|
|
179
|
+
patch: { parent_layout_id: o.id, conditions: { role_ids: [e.id] } }
|
|
180
|
+
}) && t.steps.push(`Inherit everything from the parent form and show this one to ${e.name}`);
|
|
181
|
+
const r = [];
|
|
182
|
+
n.drop.forEach((p, l) => {
|
|
183
|
+
t.try(
|
|
184
|
+
{ op: "place", field: p.field, group_key: null, index: l, patch: { is_visible: !1 } },
|
|
185
|
+
(u) => `${p.label} stays: ${u}`
|
|
186
|
+
) && r.push(p.label);
|
|
187
|
+
}), r.length && t.steps.push(`Hide ${L(r.length, "field")}: ${k(r)}`);
|
|
188
|
+
for (const p of n.hide_groups) {
|
|
189
|
+
const l = o.groups.find((c) => c.key === p.key);
|
|
190
|
+
if (!l || l.parent_key !== null) continue;
|
|
191
|
+
const u = {};
|
|
192
|
+
for (const c of z) u[c] = l[c];
|
|
193
|
+
u.hidden_for_roles = JSON.stringify([e.id]), t.try({
|
|
194
|
+
op: "group_create",
|
|
195
|
+
key: l.key,
|
|
196
|
+
label: l.label,
|
|
197
|
+
group_type: l.type,
|
|
198
|
+
parent_key: null,
|
|
199
|
+
index: l.sort,
|
|
200
|
+
patch: u
|
|
201
|
+
}) && t.steps.push(
|
|
202
|
+
`Hide the ${l.type === "tab" ? "step" : "section"} "${l.label}" for ${e.name}`
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
return t.result();
|
|
206
|
+
}
|
|
207
|
+
function te(s, o) {
|
|
208
|
+
const n = /* @__PURE__ */ new Set([
|
|
209
|
+
"id",
|
|
210
|
+
"date_created",
|
|
211
|
+
"date_updated",
|
|
212
|
+
"user_created",
|
|
213
|
+
"user_updated",
|
|
214
|
+
"created_at",
|
|
215
|
+
"updated_at",
|
|
216
|
+
"created_by",
|
|
217
|
+
"updated_by",
|
|
218
|
+
"sort"
|
|
219
|
+
]), e = new Set(s.placements.map((t) => t.field));
|
|
220
|
+
return o.filter((t) => t.field && !t.field.startsWith("_") && !n.has(t.field)).filter((t) => !t.hidden && !e.has(t.field)).map((t) => t.field);
|
|
221
|
+
}
|
|
222
|
+
function oe(s) {
|
|
223
|
+
return s.groups.filter((o) => q(o) && !o.key.startsWith("__")).map((o) => ({
|
|
224
|
+
key: o.key,
|
|
225
|
+
label: o.label || T(o.key),
|
|
226
|
+
fields: s.placements.filter((n) => n.group_key === o.key).map((n) => n.field)
|
|
227
|
+
}));
|
|
228
|
+
}
|
|
229
|
+
function se(s, o, n) {
|
|
230
|
+
const e = [];
|
|
231
|
+
for (const t of o) {
|
|
232
|
+
const r = s.groups.find((u) => u.key === t.group_key);
|
|
233
|
+
if (!r || !q(r) || C(s, t.field)) continue;
|
|
234
|
+
const p = s.placements.filter((u) => u.group_key === r.key).length, l = { op: "place", field: t.field, group_key: r.key, index: p };
|
|
235
|
+
try {
|
|
236
|
+
x(s, [l]);
|
|
237
|
+
} catch {
|
|
238
|
+
continue;
|
|
239
|
+
}
|
|
240
|
+
e.push({ ...t, label: _(n, t.field), group_label: r.label || T(r.key), op: l });
|
|
241
|
+
}
|
|
242
|
+
return e;
|
|
243
|
+
}
|
|
244
|
+
function ne(s, o) {
|
|
245
|
+
const n = new O(s);
|
|
246
|
+
for (const e of o) {
|
|
247
|
+
const t = n.work.placements.filter((r) => r.group_key === e.group_key).length;
|
|
248
|
+
n.try({ op: "place", field: e.field, group_key: e.group_key, index: t }) && n.steps.push(`Add ${e.label} to "${e.group_label}"`);
|
|
249
|
+
}
|
|
250
|
+
return n.result();
|
|
251
|
+
}
|
|
252
|
+
export {
|
|
253
|
+
X as extraChoices,
|
|
254
|
+
k as listNames,
|
|
255
|
+
se as meaningChoices,
|
|
256
|
+
oe as meaningGroups,
|
|
257
|
+
Z as planComposed,
|
|
258
|
+
j as planExtras,
|
|
259
|
+
ne as planMeaning,
|
|
260
|
+
ee as planSlimOps,
|
|
261
|
+
Y as planStructure,
|
|
262
|
+
te as unplacedFields
|
|
263
|
+
};
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { jsxs as a, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { Sparkles as f } from "lucide-react";
|
|
3
|
+
import { useState as p, useRef as N } from "react";
|
|
4
|
+
import { cn as A } from "../../../lib/utils.js";
|
|
5
|
+
import { Popover as C, PopoverTrigger as D, PopoverContent as P } from "../../ui/popover.js";
|
|
6
|
+
import { parseSaveFailure as S } from "../useLayoutDraft.js";
|
|
7
|
+
const g = "text-[12px] leading-snug text-slate-500 dark:text-muted-foreground", E = "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-40 dark:text-muted-foreground dark:hover:text-foreground", T = "inline-flex h-7 items-center rounded-md bg-nvr-cyan px-3 text-[12px] font-medium text-white transition-opacity hover:opacity-90 disabled:opacity-40", j = "inline-flex h-7 items-center gap-1.5 rounded-md border border-slate-200 bg-white px-2 text-[12px] font-medium text-slate-700 transition-colors hover:bg-slate-50 disabled:opacity-40 dark:border-border dark:bg-card dark:text-foreground dark:hover:bg-muted", B = "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";
|
|
8
|
+
function F(o, n) {
|
|
9
|
+
const s = S(o, n);
|
|
10
|
+
return s.status === 503 ? "AI is not set up here — the settings beside this still work by hand." : s.message;
|
|
11
|
+
}
|
|
12
|
+
function G({ items: o }) {
|
|
13
|
+
return o.length ? /* @__PURE__ */ a("div", { className: B, "data-ai-dropped": "", children: [
|
|
14
|
+
/* @__PURE__ */ a("p", { className: "font-medium", children: [
|
|
15
|
+
"Left out (",
|
|
16
|
+
o.length,
|
|
17
|
+
")"
|
|
18
|
+
] }),
|
|
19
|
+
/* @__PURE__ */ t("ul", { className: "mt-0.5 list-disc space-y-0.5 pl-4", children: o.map((n) => /* @__PURE__ */ t("li", { children: n }, n)) })
|
|
20
|
+
] }) : null;
|
|
21
|
+
}
|
|
22
|
+
function Q({
|
|
23
|
+
label: o,
|
|
24
|
+
title: n,
|
|
25
|
+
placeholder: s,
|
|
26
|
+
examples: b = [],
|
|
27
|
+
ask: k,
|
|
28
|
+
children: v,
|
|
29
|
+
disabled: y,
|
|
30
|
+
testId: m
|
|
31
|
+
}) {
|
|
32
|
+
const [w, x] = p(!1), [l, c] = p(""), [r, d] = p({ kind: "idle" }), u = N(null), h = async () => {
|
|
33
|
+
const e = l.trim();
|
|
34
|
+
if (!(!e || r.kind === "asking")) {
|
|
35
|
+
d({ kind: "asking" });
|
|
36
|
+
try {
|
|
37
|
+
d({ kind: "ok", result: await k(e) });
|
|
38
|
+
} catch (i) {
|
|
39
|
+
d({ kind: "error", error: F(i, "The AI could not write that") });
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
return /* @__PURE__ */ a(C, { open: w, onOpenChange: x, children: [
|
|
44
|
+
/* @__PURE__ */ t(D, { asChild: !0, children: /* @__PURE__ */ a(
|
|
45
|
+
"button",
|
|
46
|
+
{
|
|
47
|
+
type: "button",
|
|
48
|
+
className: j,
|
|
49
|
+
disabled: y,
|
|
50
|
+
"data-tip": n,
|
|
51
|
+
"data-ai-rule-trigger": m,
|
|
52
|
+
children: [
|
|
53
|
+
/* @__PURE__ */ t(f, { className: "h-3.5 w-3.5 text-nvr-cyan" }),
|
|
54
|
+
o
|
|
55
|
+
]
|
|
56
|
+
}
|
|
57
|
+
) }),
|
|
58
|
+
/* @__PURE__ */ a(
|
|
59
|
+
P,
|
|
60
|
+
{
|
|
61
|
+
align: "start",
|
|
62
|
+
className: "w-[420px] max-w-[calc(100vw-32px)] overflow-hidden p-0",
|
|
63
|
+
"data-ai-rule-popover": m,
|
|
64
|
+
onOpenAutoFocus: (e) => {
|
|
65
|
+
var i;
|
|
66
|
+
e.preventDefault(), (i = u.current) == null || i.focus();
|
|
67
|
+
},
|
|
68
|
+
children: [
|
|
69
|
+
/* @__PURE__ */ a(
|
|
70
|
+
"form",
|
|
71
|
+
{
|
|
72
|
+
className: "space-y-2 border-b border-slate-200 px-3 py-2.5 dark:border-border",
|
|
73
|
+
onSubmit: (e) => {
|
|
74
|
+
e.preventDefault(), h();
|
|
75
|
+
},
|
|
76
|
+
children: [
|
|
77
|
+
/* @__PURE__ */ a("p", { className: "flex items-center gap-1.5 text-[12px] font-semibold text-slate-700 dark:text-foreground", children: [
|
|
78
|
+
/* @__PURE__ */ t(f, { className: "h-3.5 w-3.5 text-nvr-cyan" }),
|
|
79
|
+
n
|
|
80
|
+
] }),
|
|
81
|
+
/* @__PURE__ */ t(
|
|
82
|
+
"textarea",
|
|
83
|
+
{
|
|
84
|
+
ref: u,
|
|
85
|
+
value: l,
|
|
86
|
+
rows: 2,
|
|
87
|
+
onChange: (e) => {
|
|
88
|
+
c(e.target.value), r.kind !== "asking" && d({ kind: "idle" });
|
|
89
|
+
},
|
|
90
|
+
onKeyDown: (e) => {
|
|
91
|
+
e.key === "Enter" && !e.shiftKey && (e.preventDefault(), h());
|
|
92
|
+
},
|
|
93
|
+
placeholder: s,
|
|
94
|
+
"aria-label": n,
|
|
95
|
+
"data-ai-rule-input": "",
|
|
96
|
+
className: "w-full resize-none rounded-md border border-slate-200 bg-white px-2.5 py-1.5 text-[13px] text-slate-800 outline-none placeholder:text-slate-400 focus:border-nvr-cyan dark:border-border dark:bg-background dark:text-foreground dark:placeholder:text-muted-foreground"
|
|
97
|
+
}
|
|
98
|
+
),
|
|
99
|
+
/* @__PURE__ */ t("div", { className: "flex items-center justify-end", children: /* @__PURE__ */ t(
|
|
100
|
+
"button",
|
|
101
|
+
{
|
|
102
|
+
type: "submit",
|
|
103
|
+
className: T,
|
|
104
|
+
disabled: !l.trim() || r.kind === "asking",
|
|
105
|
+
"data-ai-rule-ask": "",
|
|
106
|
+
children: r.kind === "asking" ? "Asking…" : "Ask AI"
|
|
107
|
+
}
|
|
108
|
+
) })
|
|
109
|
+
]
|
|
110
|
+
}
|
|
111
|
+
),
|
|
112
|
+
/* @__PURE__ */ a("div", { className: "max-h-[min(60vh,460px)] overflow-y-auto overscroll-contain px-3 py-3", children: [
|
|
113
|
+
r.kind === "idle" && /* @__PURE__ */ a("div", { className: "space-y-1.5", children: [
|
|
114
|
+
/* @__PURE__ */ t("p", { className: g, children: "You see the result and what it does to real records before anything changes." }),
|
|
115
|
+
b.map((e) => /* @__PURE__ */ t(
|
|
116
|
+
"button",
|
|
117
|
+
{
|
|
118
|
+
type: "button",
|
|
119
|
+
className: "block w-full rounded-md px-2 py-1 text-left text-[12.5px] text-slate-700 transition-colors hover:bg-muted dark:text-foreground",
|
|
120
|
+
onClick: () => {
|
|
121
|
+
var i;
|
|
122
|
+
c(e), (i = u.current) == null || i.focus();
|
|
123
|
+
},
|
|
124
|
+
children: e
|
|
125
|
+
},
|
|
126
|
+
e
|
|
127
|
+
))
|
|
128
|
+
] }),
|
|
129
|
+
r.kind === "asking" && /* @__PURE__ */ t("p", { className: g, children: "Asking the AI and testing the answer…" }),
|
|
130
|
+
r.kind === "error" && /* @__PURE__ */ t(
|
|
131
|
+
"p",
|
|
132
|
+
{
|
|
133
|
+
className: "text-[12.5px] leading-snug text-red-700 dark:text-red-300",
|
|
134
|
+
"data-ai-rule-error": "",
|
|
135
|
+
children: r.error
|
|
136
|
+
}
|
|
137
|
+
),
|
|
138
|
+
r.kind === "ok" && /* @__PURE__ */ t("div", { className: A("space-y-2.5"), "data-ai-rule-result": "", children: v(
|
|
139
|
+
r.result,
|
|
140
|
+
() => {
|
|
141
|
+
x(!1), c(""), d({ kind: "idle" });
|
|
142
|
+
},
|
|
143
|
+
() => d({ kind: "idle" })
|
|
144
|
+
) })
|
|
145
|
+
] })
|
|
146
|
+
]
|
|
147
|
+
}
|
|
148
|
+
)
|
|
149
|
+
] });
|
|
150
|
+
}
|
|
151
|
+
export {
|
|
152
|
+
Q as AiAskPopover,
|
|
153
|
+
G as DroppedList,
|
|
154
|
+
F as aiFailure,
|
|
155
|
+
E as aiGhostBtn,
|
|
156
|
+
T as aiPrimaryBtn,
|
|
157
|
+
g as aiQuiet,
|
|
158
|
+
j as aiTriggerBtn,
|
|
159
|
+
B as aiWarn
|
|
160
|
+
};
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { jsx as t, jsxs as m, Fragment as j } from "react/jsx-runtime";
|
|
2
|
+
import { useQuery as v } from "@tanstack/react-query";
|
|
3
|
+
import { useState as q } from "react";
|
|
4
|
+
import { useNivaroClient as g } from "../../../context.js";
|
|
5
|
+
import { post as L, get as C } from "../../../lib/commands.js";
|
|
6
|
+
import { resolveOptionFilterTokens as T } from "../../../lib/option-filter-tokens.js";
|
|
7
|
+
import { buildCascadeFilter as I } from "../../item-edit/helpers.js";
|
|
8
|
+
import { useLayoutEditorHost as P } from "../host.js";
|
|
9
|
+
import { RelationLabel as R } from "../pickers/relation-label.js";
|
|
10
|
+
import { RelationPicker as $ } from "../pickers/relation-picker.js";
|
|
11
|
+
import { AiAskPopover as B, aiQuiet as h, aiWarn as F, DroppedList as O, aiGhostBtn as W, aiPrimaryBtn as z } from "./AiAskPopover.js";
|
|
12
|
+
function A(r, e) {
|
|
13
|
+
const a = new Set(e.map((o) => o.parent_field));
|
|
14
|
+
return [...r.filter((o) => !a.has(o.parent_field)), ...e];
|
|
15
|
+
}
|
|
16
|
+
function N(r, e, a, o) {
|
|
17
|
+
const n = (d) => d && typeof d == "object" && !Array.isArray(d) ? d.id ?? null : d, l = I({
|
|
18
|
+
rules: r,
|
|
19
|
+
parentValue: (d) => {
|
|
20
|
+
const c = a[d];
|
|
21
|
+
return Array.isArray(c) ? c.map(n) : n(c);
|
|
22
|
+
}
|
|
23
|
+
}).filter, s = e ? T(e, a, o) : void 0;
|
|
24
|
+
return s ? l ? { _and: [s, l] } : s : l;
|
|
25
|
+
}
|
|
26
|
+
function k(r, e, a) {
|
|
27
|
+
const o = g();
|
|
28
|
+
return v({
|
|
29
|
+
queryKey: ["layout-editor", "ai-cascade-preview", r, JSON.stringify(e ?? null)],
|
|
30
|
+
queryFn: () => o.request(
|
|
31
|
+
C(`/items/${r}`, {
|
|
32
|
+
fields: "id",
|
|
33
|
+
limit: 6,
|
|
34
|
+
...e ? { filter: JSON.stringify(e) } : {}
|
|
35
|
+
})
|
|
36
|
+
).then((n) => ({
|
|
37
|
+
total: typeof n.total == "number" ? n.total : null,
|
|
38
|
+
ids: (n.data ?? []).map((l) => String(l.id))
|
|
39
|
+
})),
|
|
40
|
+
enabled: a,
|
|
41
|
+
staleTime: 3e4
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
function b({
|
|
45
|
+
title: r,
|
|
46
|
+
related: e,
|
|
47
|
+
q: a
|
|
48
|
+
}) {
|
|
49
|
+
var o, n;
|
|
50
|
+
return /* @__PURE__ */ m("div", { className: "min-w-0 flex-1 space-y-1", children: [
|
|
51
|
+
/* @__PURE__ */ m("p", { className: "text-[11.5px] font-medium text-slate-500 dark:text-muted-foreground", children: [
|
|
52
|
+
r,
|
|
53
|
+
((o = a.data) == null ? void 0 : o.total) != null && /* @__PURE__ */ t("span", { className: "ml-1 tabular-nums text-slate-700 dark:text-foreground", children: a.data.total.toLocaleString() })
|
|
54
|
+
] }),
|
|
55
|
+
a.isLoading ? /* @__PURE__ */ t("p", { className: h, children: "Loading…" }) : a.isError ? /* @__PURE__ */ t("p", { className: "text-[12px] text-red-700 dark:text-red-300", children: "Could not read the options" }) : (n = a.data) != null && n.ids.length ? /* @__PURE__ */ t("ul", { className: "space-y-0.5 text-[12px] text-slate-700 dark:text-foreground", children: a.data.ids.map((l) => /* @__PURE__ */ t("li", { className: "truncate", children: /* @__PURE__ */ t(R, { relatedCollection: e, id: l }) }, l)) }) : /* @__PURE__ */ t("p", { className: h, children: "No options" })
|
|
56
|
+
] });
|
|
57
|
+
}
|
|
58
|
+
function E({
|
|
59
|
+
collection: r,
|
|
60
|
+
answer: e,
|
|
61
|
+
rules: a,
|
|
62
|
+
currentOptionFilter: o,
|
|
63
|
+
parentFields: n
|
|
64
|
+
}) {
|
|
65
|
+
const l = g(), [s, d] = q(null), c = [.../* @__PURE__ */ new Set(["id", ...n, ...J(e.option_filter)])], y = v({
|
|
66
|
+
queryKey: ["layout-editor", "ai-cascade-record", r, s, c.join(",")],
|
|
67
|
+
queryFn: () => l.request(
|
|
68
|
+
C(`/items/${r}/${encodeURIComponent(s ?? "")}`, {
|
|
69
|
+
fields: c.join(",")
|
|
70
|
+
})
|
|
71
|
+
).then((u) => u.data ?? null),
|
|
72
|
+
enabled: !!s,
|
|
73
|
+
staleTime: 3e4
|
|
74
|
+
}), i = y.data ?? null, f = i ? N(a, o, i, s ?? "") : void 0, x = i ? N(
|
|
75
|
+
A(a, e.cascade_filters),
|
|
76
|
+
e.option_filter ?? o,
|
|
77
|
+
i,
|
|
78
|
+
s ?? ""
|
|
79
|
+
) : void 0, p = !!i, _ = k(e.related, f, p), S = k(e.related, x, p);
|
|
80
|
+
return /* @__PURE__ */ m(
|
|
81
|
+
"div",
|
|
82
|
+
{
|
|
83
|
+
className: "space-y-2 rounded-md border border-slate-200 p-2.5 dark:border-border",
|
|
84
|
+
"data-ai-cascade-preview": "",
|
|
85
|
+
children: [
|
|
86
|
+
/* @__PURE__ */ t("p", { className: "text-[12px] font-medium text-slate-700 dark:text-foreground", children: "Try it on a record" }),
|
|
87
|
+
/* @__PURE__ */ t(
|
|
88
|
+
$,
|
|
89
|
+
{
|
|
90
|
+
relatedCollection: r,
|
|
91
|
+
value: s,
|
|
92
|
+
onChange: (u) => d(u == null || u === "" ? null : String(u)),
|
|
93
|
+
placeholder: "Pick a record…"
|
|
94
|
+
}
|
|
95
|
+
),
|
|
96
|
+
s && y.isError && /* @__PURE__ */ t("p", { className: "text-[12px] text-red-700 dark:text-red-300", children: "Could not read that record" }),
|
|
97
|
+
p && /* @__PURE__ */ m("div", { className: "flex gap-3", children: [
|
|
98
|
+
/* @__PURE__ */ t(b, { title: "Today", related: e.related, q: _ }),
|
|
99
|
+
/* @__PURE__ */ t(b, { title: "With this change", related: e.related, q: S })
|
|
100
|
+
] })
|
|
101
|
+
]
|
|
102
|
+
}
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
function J(r) {
|
|
106
|
+
return r ? [...JSON.stringify(r).matchAll(/"\$parent\.([A-Za-z_][A-Za-z0-9_]*)"/g)].map((e) => e[1]).filter((e) => e !== "id") : [];
|
|
107
|
+
}
|
|
108
|
+
function w({
|
|
109
|
+
layoutId: r,
|
|
110
|
+
collection: e,
|
|
111
|
+
field: a,
|
|
112
|
+
rules: o,
|
|
113
|
+
currentOptionFilter: n,
|
|
114
|
+
parentFields: l,
|
|
115
|
+
onApply: s,
|
|
116
|
+
disabled: d
|
|
117
|
+
}) {
|
|
118
|
+
const c = g();
|
|
119
|
+
return P().isAdmin ? /* @__PURE__ */ t(
|
|
120
|
+
B,
|
|
121
|
+
{
|
|
122
|
+
testId: "cascade",
|
|
123
|
+
label: "Write with AI",
|
|
124
|
+
title: "Describe which options this picker offers",
|
|
125
|
+
placeholder: "only regions of the record's zone, active ones first",
|
|
126
|
+
disabled: d,
|
|
127
|
+
ask: async (i) => (await c.request(
|
|
128
|
+
L(`/ai-design/layouts/${r}/cascade`, { field: a, text: i })
|
|
129
|
+
)).data,
|
|
130
|
+
children: (i, f, x) => /* @__PURE__ */ m(j, { children: [
|
|
131
|
+
/* @__PURE__ */ t("ul", { className: "list-disc space-y-1 pl-4 text-[12.5px] leading-snug text-slate-800 dark:text-foreground", children: i.sentences.map((p) => /* @__PURE__ */ t("li", { children: p }, p)) }),
|
|
132
|
+
i.explanation && /* @__PURE__ */ t("p", { className: h, children: i.explanation }),
|
|
133
|
+
i.option_filter && n && /* @__PURE__ */ t("p", { className: F, children: "The option filter replaces the one this field has today." }),
|
|
134
|
+
/* @__PURE__ */ t(O, { items: i.dropped }),
|
|
135
|
+
/* @__PURE__ */ t(
|
|
136
|
+
E,
|
|
137
|
+
{
|
|
138
|
+
collection: e,
|
|
139
|
+
answer: i,
|
|
140
|
+
rules: o,
|
|
141
|
+
currentOptionFilter: n,
|
|
142
|
+
parentFields: l
|
|
143
|
+
}
|
|
144
|
+
),
|
|
145
|
+
/* @__PURE__ */ t("p", { className: h, children: "Saving changes this picker on every form that shows it." }),
|
|
146
|
+
/* @__PURE__ */ m("div", { className: "flex items-center justify-end gap-1.5 pt-1", children: [
|
|
147
|
+
/* @__PURE__ */ t("button", { type: "button", className: W, onClick: x, children: "Back" }),
|
|
148
|
+
/* @__PURE__ */ t(
|
|
149
|
+
"button",
|
|
150
|
+
{
|
|
151
|
+
type: "button",
|
|
152
|
+
className: z,
|
|
153
|
+
"data-ai-cascade-apply": "",
|
|
154
|
+
onClick: () => {
|
|
155
|
+
s(
|
|
156
|
+
{
|
|
157
|
+
rules: A(o, i.cascade_filters),
|
|
158
|
+
optionFilter: i.option_filter ?? n
|
|
159
|
+
},
|
|
160
|
+
i.sentences[0] ?? "Narrow the options"
|
|
161
|
+
), f();
|
|
162
|
+
},
|
|
163
|
+
children: "Use this"
|
|
164
|
+
}
|
|
165
|
+
)
|
|
166
|
+
] })
|
|
167
|
+
] })
|
|
168
|
+
}
|
|
169
|
+
) : null;
|
|
170
|
+
}
|
|
171
|
+
export {
|
|
172
|
+
w as CascadeWriter,
|
|
173
|
+
A as mergeCascadeRules,
|
|
174
|
+
N as previewFilter
|
|
175
|
+
};
|