@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,61 @@
|
|
|
1
|
+
import { useState as y, useRef as b, useEffect as R, useCallback as w } from "react";
|
|
2
|
+
const k = "nvr:layout-draft:", u = (e, n) => `${k}${n.toLowerCase()}:${e}`;
|
|
3
|
+
function D(e) {
|
|
4
|
+
const n = e;
|
|
5
|
+
return !!n && typeof n.label == "string" && Array.isArray(n.ops);
|
|
6
|
+
}
|
|
7
|
+
function $(e, n) {
|
|
8
|
+
try {
|
|
9
|
+
const r = window.localStorage.getItem(u(e, n));
|
|
10
|
+
if (!r) return null;
|
|
11
|
+
const t = JSON.parse(r);
|
|
12
|
+
return (t == null ? void 0 : t.v) !== 1 || t.layoutId !== e || typeof t.baseRev != "string" || !Array.isArray(t.steps) || t.steps.length === 0 || !t.steps.every(D) ? null : t;
|
|
13
|
+
} catch {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function A(e) {
|
|
18
|
+
try {
|
|
19
|
+
window.localStorage.setItem(u(e.layoutId, e.userId), JSON.stringify(e));
|
|
20
|
+
} catch {
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function f(e, n) {
|
|
24
|
+
try {
|
|
25
|
+
window.localStorage.removeItem(u(e, n));
|
|
26
|
+
} catch {
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function C(e, n, r) {
|
|
30
|
+
var S;
|
|
31
|
+
const [t, c] = y(null), a = b(null), l = b(!1), s = r ? `${r}:${n}` : null, p = ((S = e.bundle) == null ? void 0 : S.rev) ?? null;
|
|
32
|
+
R(() => {
|
|
33
|
+
if (!s || !r || !p || a.current === s || (a.current = s, l.current = !1, c(null), e.unsavedSteps.length > 0)) return;
|
|
34
|
+
const o = $(n, r);
|
|
35
|
+
o && (o.baseRev === e.baseRev ? (l.current = !0, c({ kind: "offer", draft: o })) : (f(n, r), c({ kind: "dropped", draft: o })));
|
|
36
|
+
}, [s, r, p, n, e.unsavedSteps.length, e.baseRev]);
|
|
37
|
+
const i = e.unsavedSteps, v = e.status === "saving";
|
|
38
|
+
R(() => {
|
|
39
|
+
!s || !r || a.current !== s || l.current || v || (i.length > 0 && e.baseRev ? A({
|
|
40
|
+
v: 1,
|
|
41
|
+
layoutId: n,
|
|
42
|
+
userId: r,
|
|
43
|
+
baseRev: e.baseRev,
|
|
44
|
+
steps: i.map((o) => ({ label: o.label, ops: o.ops })),
|
|
45
|
+
at: Date.now()
|
|
46
|
+
}) : i.length === 0 && f(n, r));
|
|
47
|
+
}, [s, r, n, i, v, e.baseRev, t]);
|
|
48
|
+
const g = e.restore, h = w(() => {
|
|
49
|
+
(t == null ? void 0 : t.kind) === "offer" && (l.current = !1, c(null), g(t.draft.steps));
|
|
50
|
+
}, [t, g]), m = w(() => {
|
|
51
|
+
(t == null ? void 0 : t.kind) === "offer" && r && f(n, r), l.current = !1, c(null);
|
|
52
|
+
}, [t, r, n]);
|
|
53
|
+
return { state: t, recover: h, dismiss: m };
|
|
54
|
+
}
|
|
55
|
+
export {
|
|
56
|
+
f as clearStoredDraft,
|
|
57
|
+
$ as readStoredDraft,
|
|
58
|
+
u as storedDraftKey,
|
|
59
|
+
C as useDraftRecovery,
|
|
60
|
+
A as writeStoredDraft
|
|
61
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { HEADER_GROUP_KEY as p, EDITOR_NOTE_MAX as y } from "../../lib/layout-ops.js";
|
|
2
|
+
import { asObject as s, findPlacement as c, withOverride as d } from "./inspector/model.js";
|
|
3
|
+
const _ = 1e3, g = "__subtitle__";
|
|
4
|
+
function f(t) {
|
|
5
|
+
switch (t.kind) {
|
|
6
|
+
case "field":
|
|
7
|
+
case "slot":
|
|
8
|
+
return { field: t.field, group_key: t.group_key };
|
|
9
|
+
case "header":
|
|
10
|
+
return { field: t.field, group_key: t.field === g ? null : p };
|
|
11
|
+
default:
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function u(t) {
|
|
16
|
+
const e = s(t), n = typeof e.text == "string" ? e.text.trim() : "";
|
|
17
|
+
return n ? {
|
|
18
|
+
text: n,
|
|
19
|
+
by: typeof e.by == "string" ? e.by : null,
|
|
20
|
+
by_name: typeof e.by_name == "string" ? e.by_name : null,
|
|
21
|
+
at: typeof e.at == "string" ? e.at : ""
|
|
22
|
+
} : null;
|
|
23
|
+
}
|
|
24
|
+
function h(t, e) {
|
|
25
|
+
if (e.kind === "group") {
|
|
26
|
+
const r = t.groups.find((i) => i.key === e.key);
|
|
27
|
+
return r ? u(r.editor_note) : null;
|
|
28
|
+
}
|
|
29
|
+
const n = f(e), o = n ? c(t, n.field, n.group_key) : null;
|
|
30
|
+
return o ? u(s(o.overrides).editor_note) : null;
|
|
31
|
+
}
|
|
32
|
+
function E(t) {
|
|
33
|
+
const e = /* @__PURE__ */ new Map();
|
|
34
|
+
for (const n of t.groups) {
|
|
35
|
+
const o = u(n.editor_note);
|
|
36
|
+
o && e.set(`group:${n.key}`, o);
|
|
37
|
+
}
|
|
38
|
+
for (const n of t.placements) {
|
|
39
|
+
const o = u(s(n.overrides).editor_note);
|
|
40
|
+
o && e.set(`${n.field}|${n.group_key ?? ""}`, o);
|
|
41
|
+
}
|
|
42
|
+
return e;
|
|
43
|
+
}
|
|
44
|
+
function T(t) {
|
|
45
|
+
if (t.kind === "group") return `group:${t.key}`;
|
|
46
|
+
const e = f(t);
|
|
47
|
+
return e ? `${e.field}|${e.group_key ?? ""}` : null;
|
|
48
|
+
}
|
|
49
|
+
function m(t, e, n) {
|
|
50
|
+
const o = n ? { ...n, text: n.text.trim().slice(0, _) } : null;
|
|
51
|
+
if (o && !o.text) return m(t, e, null);
|
|
52
|
+
if (e.kind === "group") {
|
|
53
|
+
if (!t.groups.some((a) => a.key === e.key)) return [];
|
|
54
|
+
const l = o ? JSON.stringify(o) : null;
|
|
55
|
+
return l && l.length > y ? [] : [{ op: "group_update", key: e.key, patch: { editor_note: l } }];
|
|
56
|
+
}
|
|
57
|
+
const r = f(e), i = r ? c(t, r.field, r.group_key) : null;
|
|
58
|
+
return !i || !r ? [] : [
|
|
59
|
+
{
|
|
60
|
+
op: "update_placement",
|
|
61
|
+
at: r,
|
|
62
|
+
patch: { overrides: d(i, "editor_note", o ?? void 0) }
|
|
63
|
+
}
|
|
64
|
+
];
|
|
65
|
+
}
|
|
66
|
+
function v(t) {
|
|
67
|
+
const e = t.at ? new Date(t.at) : null, n = e && !Number.isNaN(e.getTime()) ? e.toLocaleDateString(void 0, { day: "numeric", month: "short", year: "numeric" }) : null;
|
|
68
|
+
return [t.by_name || "An admin", n].filter(Boolean).join(" · ");
|
|
69
|
+
}
|
|
70
|
+
export {
|
|
71
|
+
_ as NOTE_TEXT_MAX,
|
|
72
|
+
v as noteByline,
|
|
73
|
+
T as noteKey,
|
|
74
|
+
h as noteOf,
|
|
75
|
+
m as noteOps,
|
|
76
|
+
E as notesOf,
|
|
77
|
+
u as parseNote
|
|
78
|
+
};
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { jsxs as u, jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import { GitBranch as b, AlertTriangle as w } from "lucide-react";
|
|
3
|
+
import { useState as p, useCallback as x } from "react";
|
|
4
|
+
import { cn as m } from "../../../lib/utils.js";
|
|
5
|
+
import { amberStrip as k } from "../panel-style.js";
|
|
6
|
+
import { loopSentence as g } from "./field-sources.js";
|
|
7
|
+
const y = {
|
|
8
|
+
required: "amber",
|
|
9
|
+
readonly: "slate",
|
|
10
|
+
hidden: "slate",
|
|
11
|
+
filled: "violet"
|
|
12
|
+
}, h = "nvr:layout-editor:rules-view";
|
|
13
|
+
function z() {
|
|
14
|
+
const [e, n] = p(() => {
|
|
15
|
+
try {
|
|
16
|
+
return window.localStorage.getItem(h) !== "off";
|
|
17
|
+
} catch {
|
|
18
|
+
return !0;
|
|
19
|
+
}
|
|
20
|
+
}), r = x((a) => {
|
|
21
|
+
n(a);
|
|
22
|
+
try {
|
|
23
|
+
window.localStorage.setItem(h, a ? "on" : "off");
|
|
24
|
+
} catch {
|
|
25
|
+
}
|
|
26
|
+
}, []);
|
|
27
|
+
return [e, r];
|
|
28
|
+
}
|
|
29
|
+
function j({ on: e, onChange: n }) {
|
|
30
|
+
return /* @__PURE__ */ u(
|
|
31
|
+
"button",
|
|
32
|
+
{
|
|
33
|
+
type: "button",
|
|
34
|
+
"aria-pressed": e,
|
|
35
|
+
"aria-label": "Rules",
|
|
36
|
+
"data-rules-view": e ? "on" : "off",
|
|
37
|
+
"data-tip": e ? "Hide the rule tags and default values on the canvas" : "Show why fields are required, read-only or hidden, section rules and default values",
|
|
38
|
+
onClick: () => n(!e),
|
|
39
|
+
className: m(
|
|
40
|
+
"inline-flex h-8 items-center gap-1 rounded-md px-2 text-[12px] font-medium transition-colors",
|
|
41
|
+
e ? "bg-accent text-slate-900 dark:text-foreground" : "text-slate-500 hover:bg-muted hover:text-slate-800 dark:text-muted-foreground dark:hover:text-foreground"
|
|
42
|
+
),
|
|
43
|
+
children: [
|
|
44
|
+
/* @__PURE__ */ l(b, { className: "h-3.5 w-3.5" }),
|
|
45
|
+
/* @__PURE__ */ l("span", { "data-tb-wide": "", children: "Rules" })
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
function E(e, n) {
|
|
51
|
+
var i;
|
|
52
|
+
const r = /* @__PURE__ */ new Map();
|
|
53
|
+
for (const o of e.loops) {
|
|
54
|
+
const t = g(o, e.describe, e.groupLabel);
|
|
55
|
+
for (const d of o.fields) r.set(d, [...r.get(d) ?? [], t]);
|
|
56
|
+
}
|
|
57
|
+
if (r.size > 0 || (((i = n.ghostTags) == null ? void 0 : i.size) ?? 0) > 0 || n.chips && (e.fieldChips.size > 0 || e.groupChips.size > 0))
|
|
58
|
+
return (o) => {
|
|
59
|
+
var f;
|
|
60
|
+
const t = [];
|
|
61
|
+
if (o.kind === "group") {
|
|
62
|
+
if (n.chips)
|
|
63
|
+
for (const s of e.groupChips.get(o.key) ?? [])
|
|
64
|
+
t.push({ text: s.text, tone: "slate", tip: s.tip, onClick: () => n.open(s.open, o) });
|
|
65
|
+
return t;
|
|
66
|
+
}
|
|
67
|
+
if (o.kind !== "field" && o.kind !== "header") return t;
|
|
68
|
+
const d = r.get(o.field);
|
|
69
|
+
if (d && t.push({
|
|
70
|
+
text: "Rule loop",
|
|
71
|
+
tone: "amber",
|
|
72
|
+
tip: d.join(" · "),
|
|
73
|
+
highlight: !0,
|
|
74
|
+
kind: "loop"
|
|
75
|
+
}), n.chips)
|
|
76
|
+
for (const s of e.fieldChips.get(o.field) ?? [])
|
|
77
|
+
t.push({
|
|
78
|
+
text: s.text,
|
|
79
|
+
tone: y[s.state],
|
|
80
|
+
tip: s.tip,
|
|
81
|
+
onClick: () => n.open(s.open, o)
|
|
82
|
+
});
|
|
83
|
+
const c = (f = n.ghostTags) == null ? void 0 : f.get(o.field);
|
|
84
|
+
return c && t.push({ text: c, tone: "slate", tip: "What a new record starts with" }), t;
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
function L({
|
|
88
|
+
explain: e,
|
|
89
|
+
onShow: n
|
|
90
|
+
}) {
|
|
91
|
+
const [r, a] = p(!1);
|
|
92
|
+
if (e.loops.length === 0) return null;
|
|
93
|
+
const i = e.loops.map((t) => ({
|
|
94
|
+
field: t.fields[0],
|
|
95
|
+
text: g(t, e.describe, e.groupLabel)
|
|
96
|
+
})), o = r ? i : i.slice(0, 1);
|
|
97
|
+
return /* @__PURE__ */ u(
|
|
98
|
+
"div",
|
|
99
|
+
{
|
|
100
|
+
role: "note",
|
|
101
|
+
"data-rule-loops": "",
|
|
102
|
+
className: m(
|
|
103
|
+
"flex shrink-0 items-start gap-2 border-b px-4 py-1.5 text-[12.5px]",
|
|
104
|
+
k
|
|
105
|
+
),
|
|
106
|
+
children: [
|
|
107
|
+
/* @__PURE__ */ l(w, { className: "mt-0.5 h-3.5 w-3.5 shrink-0" }),
|
|
108
|
+
/* @__PURE__ */ l("ul", { className: "m-0 min-w-0 flex-1 list-none space-y-0.5 p-0", children: o.map((t) => /* @__PURE__ */ u("li", { className: "flex min-w-0 items-baseline gap-2", children: [
|
|
109
|
+
/* @__PURE__ */ u("span", { className: "min-w-0", children: [
|
|
110
|
+
"Rule loop: ",
|
|
111
|
+
t.text,
|
|
112
|
+
"."
|
|
113
|
+
] }),
|
|
114
|
+
/* @__PURE__ */ l(
|
|
115
|
+
"button",
|
|
116
|
+
{
|
|
117
|
+
type: "button",
|
|
118
|
+
onClick: () => n(t.field),
|
|
119
|
+
className: "shrink-0 font-medium underline underline-offset-2 hover:no-underline",
|
|
120
|
+
children: "Show"
|
|
121
|
+
}
|
|
122
|
+
)
|
|
123
|
+
] }, t.text)) }),
|
|
124
|
+
i.length > 1 && /* @__PURE__ */ l(
|
|
125
|
+
"button",
|
|
126
|
+
{
|
|
127
|
+
type: "button",
|
|
128
|
+
onClick: () => a(!r),
|
|
129
|
+
className: "shrink-0 font-medium underline underline-offset-2 hover:no-underline",
|
|
130
|
+
children: r ? "Fewer" : `${i.length - 1} more`
|
|
131
|
+
}
|
|
132
|
+
)
|
|
133
|
+
]
|
|
134
|
+
}
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
export {
|
|
138
|
+
L as RuleLoopsBanner,
|
|
139
|
+
j as RulesToggle,
|
|
140
|
+
E as explainMarks,
|
|
141
|
+
z as useRulesView
|
|
142
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { fieldLabel as u } from "./field-sources.js";
|
|
2
|
+
import { asObj as i } from "./rule-graph.js";
|
|
3
|
+
function d(s) {
|
|
4
|
+
const t = {};
|
|
5
|
+
for (const [f, e] of Object.entries(i(s))) e !== void 0 && (t[f] = e);
|
|
6
|
+
return t;
|
|
7
|
+
}
|
|
8
|
+
function g(s, t) {
|
|
9
|
+
const f = [];
|
|
10
|
+
for (const [e, n] of Object.entries(s)) {
|
|
11
|
+
if (n == null || n === "") continue;
|
|
12
|
+
const o = t.filter(
|
|
13
|
+
(r) => r.trigger_field === e && (r.is_active === !0 || r.is_active === 1 || r.is_active == null)
|
|
14
|
+
).map((r) => r.target_field);
|
|
15
|
+
o.length > 0 && f.push({ field: e, value: n, targets: [...new Set(o)] });
|
|
16
|
+
}
|
|
17
|
+
return f;
|
|
18
|
+
}
|
|
19
|
+
function m(s) {
|
|
20
|
+
const t = [];
|
|
21
|
+
for (const f of s) {
|
|
22
|
+
const e = i(f.cross_record_defaults), n = typeof e.source_collection == "string" ? e.source_collection : "", o = i(e.field_map);
|
|
23
|
+
if (!n || Object.keys(o).length === 0) continue;
|
|
24
|
+
const r = typeof e.source_fk_field == "string" && e.source_fk_field ? e.source_fk_field : f.field;
|
|
25
|
+
t.push({
|
|
26
|
+
field: f.field,
|
|
27
|
+
source_collection: n,
|
|
28
|
+
fk: r,
|
|
29
|
+
field_map: Object.fromEntries(Object.entries(o).map(([c, l]) => [c, String(l)]))
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
return t;
|
|
33
|
+
}
|
|
34
|
+
function b(s, t) {
|
|
35
|
+
const f = {};
|
|
36
|
+
for (const [e, n] of Object.entries(s.field_map))
|
|
37
|
+
for (const o of n.split("||").map((r) => r.trim())) {
|
|
38
|
+
const r = t[o];
|
|
39
|
+
if (!(r == null || r === "" || typeof r == "object")) {
|
|
40
|
+
f[e] = r;
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return f;
|
|
45
|
+
}
|
|
46
|
+
function j(s, t, f) {
|
|
47
|
+
const e = /* @__PURE__ */ new Map();
|
|
48
|
+
for (const [n, o] of Object.entries(s)) e.set(n, { value: o, via: "layout" });
|
|
49
|
+
for (const n of t)
|
|
50
|
+
for (const [o, r] of Object.entries(n))
|
|
51
|
+
r == null || r === "" ? e.delete(o) : e.set(o, { value: r, via: "rule" });
|
|
52
|
+
for (const n of f)
|
|
53
|
+
for (const [o, r] of Object.entries(n.values))
|
|
54
|
+
e.set(o, { value: r, via: "cross", from: n.from });
|
|
55
|
+
return e;
|
|
56
|
+
}
|
|
57
|
+
function a(s, t, f, e) {
|
|
58
|
+
var o;
|
|
59
|
+
if (t == null || t === "") return null;
|
|
60
|
+
if (Array.isArray(t)) return t.length === 0 ? null : `${t.length} linked`;
|
|
61
|
+
if (typeof t == "boolean" || f === "boolean") {
|
|
62
|
+
if (t === !0 || t === "true" || t === 1 || t === "1") return "Yes";
|
|
63
|
+
if (t === !1 || t === "false" || t === 0 || t === "0") return "No";
|
|
64
|
+
}
|
|
65
|
+
if (typeof t == "object") return null;
|
|
66
|
+
const n = String(t);
|
|
67
|
+
return ((o = e[s]) == null ? void 0 : o[n]) ?? n;
|
|
68
|
+
}
|
|
69
|
+
function y(s, t, f, e, n) {
|
|
70
|
+
const o = a(s, t.value, n, e);
|
|
71
|
+
return o == null ? null : t.via === "rule" ? `By rule: ${o}` : t.via === "cross" ? `From ${u(t.from ?? "", f)}: ${o}` : `Default: ${o}`;
|
|
72
|
+
}
|
|
73
|
+
export {
|
|
74
|
+
m as crossConfigs,
|
|
75
|
+
b as crossValues,
|
|
76
|
+
y as ghostText,
|
|
77
|
+
a as ghostValueText,
|
|
78
|
+
d as layoutDefaults,
|
|
79
|
+
j as mergeGhosts,
|
|
80
|
+
g as ruleTriggers
|
|
81
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { useRef as b, useEffect as A } from "react";
|
|
2
|
+
import { dependentsOf as k } from "./rule-graph.js";
|
|
3
|
+
function E(t) {
|
|
4
|
+
const r = /^(?:field|header):([^:]+)/.exec(t);
|
|
5
|
+
return r ? r[1] : null;
|
|
6
|
+
}
|
|
7
|
+
const c = (t) => `"${t.replace(/["\\]/g, "\\$&")}"`;
|
|
8
|
+
function O(t) {
|
|
9
|
+
if (t.target.kind === "group")
|
|
10
|
+
return [`[data-design-target=${c(`group:${t.target.key}`)}]`];
|
|
11
|
+
const r = t.target.field;
|
|
12
|
+
return [
|
|
13
|
+
`[data-design-target^=${c(`field:${r}:`)}]`,
|
|
14
|
+
`[data-design-target=${c(`header:${r}`)}]`
|
|
15
|
+
];
|
|
16
|
+
}
|
|
17
|
+
const w = {
|
|
18
|
+
visibility: "shows",
|
|
19
|
+
skip: "skips",
|
|
20
|
+
cascade: "filters",
|
|
21
|
+
field_rule: "fills",
|
|
22
|
+
parent_cascade: "fills lines",
|
|
23
|
+
row_rule: "row rules"
|
|
24
|
+
};
|
|
25
|
+
function _(t) {
|
|
26
|
+
const r = b(null), f = b(t);
|
|
27
|
+
return f.current = t, A(() => {
|
|
28
|
+
const n = r.current;
|
|
29
|
+
if (!n) return;
|
|
30
|
+
let l = null;
|
|
31
|
+
const i = [], a = () => {
|
|
32
|
+
for (const o of i)
|
|
33
|
+
o.removeAttribute("data-rule-dependent"), o.removeAttribute("data-rule-drives");
|
|
34
|
+
i.length = 0, l = null;
|
|
35
|
+
}, g = (o) => {
|
|
36
|
+
var u, m;
|
|
37
|
+
const e = ((m = (u = o.target) == null ? void 0 : u.closest) == null ? void 0 : m.call(u, "[data-design-target]")) ?? null;
|
|
38
|
+
if (e === l || (a(), !e || !n.contains(e))) return;
|
|
39
|
+
const v = E(e.getAttribute("data-design-target") ?? "");
|
|
40
|
+
if (!v) return;
|
|
41
|
+
const d = k(f.current, v);
|
|
42
|
+
if (d.length === 0) return;
|
|
43
|
+
l = e;
|
|
44
|
+
const h = /* @__PURE__ */ new Set();
|
|
45
|
+
for (const $ of d)
|
|
46
|
+
for (const s of n.querySelectorAll(O($).join(",")))
|
|
47
|
+
s === e || h.has(s) || (h.add(s), s.setAttribute("data-rule-dependent", w[$.kind]), i.push(s));
|
|
48
|
+
e.setAttribute("data-rule-drives", `Controls ${d.length}`), i.push(e);
|
|
49
|
+
}, p = (o) => {
|
|
50
|
+
const e = o.relatedTarget;
|
|
51
|
+
(!e || !n.contains(e)) && a();
|
|
52
|
+
};
|
|
53
|
+
return n.addEventListener("pointerover", g), n.addEventListener("pointerout", p), () => {
|
|
54
|
+
n.removeEventListener("pointerover", g), n.removeEventListener("pointerout", p), a();
|
|
55
|
+
};
|
|
56
|
+
}, []), r;
|
|
57
|
+
}
|
|
58
|
+
export {
|
|
59
|
+
O as dependentSelectors,
|
|
60
|
+
E as fieldOfTargetKey,
|
|
61
|
+
_ as useDriverHover
|
|
62
|
+
};
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import { titleCase as R } from "../../../lib/utils.js";
|
|
2
|
+
import { parseVisibleWhen as N } from "../../../lib/visible-when.js";
|
|
3
|
+
import { segmentsText as k, describeConditions as v } from "../overview/describe-conditions.js";
|
|
4
|
+
import { asObj as C, asList as b } from "./rule-graph.js";
|
|
5
|
+
const _ = (e) => e === !0 || e === 1 || e === "1" || e === "true";
|
|
6
|
+
function y(e, o) {
|
|
7
|
+
var r;
|
|
8
|
+
const n = (r = o.find((i) => i.field === e)) == null ? void 0 : r.label;
|
|
9
|
+
return n != null && n.trim() ? n.trim() : R(e.split(".").pop() ?? e);
|
|
10
|
+
}
|
|
11
|
+
const h = (e, o = "and") => e.length <= 1 ? e[0] ?? "" : `${e.slice(0, -1).join(", ")} ${o} ${e[e.length - 1]}`;
|
|
12
|
+
function S(e, o, n) {
|
|
13
|
+
const r = [];
|
|
14
|
+
for (const i of e) {
|
|
15
|
+
if (!(i != null && i.field)) continue;
|
|
16
|
+
const f = i.op ?? "eq";
|
|
17
|
+
if (f === "in") {
|
|
18
|
+
const p = String(i.value ?? "").split(",").map((l) => l.trim()).filter(Boolean), a = p.map(
|
|
19
|
+
(l) => k(
|
|
20
|
+
v([{ field: i.field, op: "eq", value: l }], o, n)
|
|
21
|
+
)
|
|
22
|
+
), c = y(i.field, o), t = a.map((l) => l.replace(`${c} is `, ""));
|
|
23
|
+
r.push(p.length ? `${c} is ${h(t, "or")}` : `${c} is set`);
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
r.push(
|
|
27
|
+
k(
|
|
28
|
+
v(
|
|
29
|
+
[{ field: i.field, op: f, value: i.value }],
|
|
30
|
+
o,
|
|
31
|
+
n
|
|
32
|
+
)
|
|
33
|
+
)
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
return r.join(" and ");
|
|
37
|
+
}
|
|
38
|
+
function w(e, o) {
|
|
39
|
+
return b(e).map((n) => o.get(String(n).toUpperCase()) ?? null).filter((n) => !!n);
|
|
40
|
+
}
|
|
41
|
+
function F(e, o, n) {
|
|
42
|
+
const r = o.filter((i) => !n || i.id === String(n));
|
|
43
|
+
return e.map((i) => {
|
|
44
|
+
for (const f of r) {
|
|
45
|
+
const p = f.states.find((a) => a.key === i);
|
|
46
|
+
if (p) return p.label;
|
|
47
|
+
}
|
|
48
|
+
return R(i.replace(/_/g, " "));
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
function L(e) {
|
|
52
|
+
const o = /* @__PURE__ */ new Map();
|
|
53
|
+
for (const n of e.placements)
|
|
54
|
+
!n.field || n.field.startsWith("__") || o.set(n.field, [...o.get(n.field) ?? [], n]);
|
|
55
|
+
return o;
|
|
56
|
+
}
|
|
57
|
+
function W(e, o, n) {
|
|
58
|
+
const r = e.target_type ?? "set";
|
|
59
|
+
return r === "clear" ? "empties it" : r === "set_lookup" || r === "set_from_trigger" ? "looks its value up" : e.target_value == null || e.target_value === "" ? "sets it" : `sets it to ${k(
|
|
60
|
+
v(
|
|
61
|
+
[{ field: e.target_field, op: "eq", value: e.target_value }],
|
|
62
|
+
o,
|
|
63
|
+
n
|
|
64
|
+
)
|
|
65
|
+
).replace(`${y(e.target_field, o)} is `, "")}`;
|
|
66
|
+
}
|
|
67
|
+
function M(e, o, n) {
|
|
68
|
+
const r = e.trigger_op ?? "eq";
|
|
69
|
+
return `When ${S(
|
|
70
|
+
[{ field: e.trigger_field, op: r, value: e.trigger_value }],
|
|
71
|
+
o,
|
|
72
|
+
n
|
|
73
|
+
)}, a rule ${W(e, o, n)}`;
|
|
74
|
+
}
|
|
75
|
+
function T(e) {
|
|
76
|
+
const { layout: o, describe: n, choices: r } = e, i = new Map(e.fields.map((a) => [a.field, a])), f = /* @__PURE__ */ new Map(), p = /* @__PURE__ */ new Map();
|
|
77
|
+
for (const a of e.pipelines)
|
|
78
|
+
for (const c of a.transitions)
|
|
79
|
+
for (const t of c.requirements ?? []) {
|
|
80
|
+
const l = typeof (t == null ? void 0 : t.collection) == "string" && t.collection ? t.collection : null;
|
|
81
|
+
if (!(l && l !== e.collection))
|
|
82
|
+
for (const d of Array.isArray(t == null ? void 0 : t.fields) ? t.fields.map(String) : [])
|
|
83
|
+
p.set(d, [...p.get(d) ?? [], { label: c.label, pipeline: a.id }]);
|
|
84
|
+
}
|
|
85
|
+
for (const [a, c] of L(o)) {
|
|
86
|
+
const t = i.get(a), l = y(a, n), d = [], u = C(c[0].overrides);
|
|
87
|
+
u.required === !0 ? d.push({
|
|
88
|
+
state: "required",
|
|
89
|
+
origin: "placement",
|
|
90
|
+
text: "Required here",
|
|
91
|
+
tip: `${l} is required on this form (Rules tab)`,
|
|
92
|
+
open: { kind: "tab", tab: "rules" }
|
|
93
|
+
}) : u.required === void 0 && _(t == null ? void 0 : t.required) && d.push({
|
|
94
|
+
state: "required",
|
|
95
|
+
origin: "field",
|
|
96
|
+
text: "Required field",
|
|
97
|
+
tip: `${l} is required on every form (the field's own setting)`,
|
|
98
|
+
open: { kind: "tab", tab: "advanced" }
|
|
99
|
+
});
|
|
100
|
+
const m = p.get(a) ?? [];
|
|
101
|
+
if (m.length > 0) {
|
|
102
|
+
const s = [...new Set(m.map((g) => g.label))];
|
|
103
|
+
d.push({
|
|
104
|
+
state: "required",
|
|
105
|
+
origin: "transition",
|
|
106
|
+
text: s.length === 1 ? `Needed to ${s[0]}` : "Needed to move on",
|
|
107
|
+
tip: `${h(s)} ${s.length === 1 ? "needs" : "need"} ${l} first (the pipeline's transition requirements)`,
|
|
108
|
+
open: { kind: "pipeline", id: m[0].pipeline }
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
const x = (t == null ? void 0 : t.computed_type) === "rollup" || (t == null ? void 0 : t.computed_type) === "write";
|
|
112
|
+
u.readonly === !0 && !x ? d.push({
|
|
113
|
+
state: "readonly",
|
|
114
|
+
origin: "placement",
|
|
115
|
+
text: "Read-only here",
|
|
116
|
+
tip: `${l} is read-only on this form (Rules tab)`,
|
|
117
|
+
open: { kind: "tab", tab: "rules" }
|
|
118
|
+
}) : x && u.editable_computed !== !0 ? d.push({
|
|
119
|
+
state: "readonly",
|
|
120
|
+
origin: "field",
|
|
121
|
+
text: "Calculated",
|
|
122
|
+
tip: `${l} is calculated (${(t == null ? void 0 : t.computed_type) === "rollup" ? "from related rows" : "on save"}), so nobody types into it`,
|
|
123
|
+
open: { kind: "tab", tab: "advanced" }
|
|
124
|
+
}) : _(t == null ? void 0 : t.readonly) ? d.push({
|
|
125
|
+
state: "readonly",
|
|
126
|
+
origin: "field",
|
|
127
|
+
text: "Read-only field",
|
|
128
|
+
tip: `${l} is read-only on every form (the field's own setting)`,
|
|
129
|
+
open: { kind: "tab", tab: "advanced" }
|
|
130
|
+
}) : (a.includes(".") || (t == null ? void 0 : t.interface) === "relation-path") && d.push({
|
|
131
|
+
state: "readonly",
|
|
132
|
+
origin: "field",
|
|
133
|
+
text: "From a related record",
|
|
134
|
+
tip: `${l} shows a value of a related record; edit it there`,
|
|
135
|
+
open: { kind: "tab", tab: "advanced" }
|
|
136
|
+
});
|
|
137
|
+
for (const s of b(c[0].lock_conditions))
|
|
138
|
+
if ((s == null ? void 0 : s.type) === "role") {
|
|
139
|
+
const g = w(s.role_ids, e.roleNames);
|
|
140
|
+
if (g.length === 0) continue;
|
|
141
|
+
d.push({
|
|
142
|
+
state: "readonly",
|
|
143
|
+
origin: "role",
|
|
144
|
+
text: `Locked for ${h(g)}`,
|
|
145
|
+
tip: `${l} is read-only for ${h(g)} on this form (Rules tab, Read-only when)`,
|
|
146
|
+
open: { kind: "tab", tab: "rules" }
|
|
147
|
+
});
|
|
148
|
+
} else if ((s == null ? void 0 : s.type) === "pipeline_state") {
|
|
149
|
+
const g = b(s.state_keys).map(String);
|
|
150
|
+
if (g.length === 0) continue;
|
|
151
|
+
const q = F(g, e.pipelines, s.pipeline_id);
|
|
152
|
+
d.push({
|
|
153
|
+
state: "readonly",
|
|
154
|
+
origin: "placement",
|
|
155
|
+
text: `Locked in ${h(q, "or")}`,
|
|
156
|
+
tip: `${l} locks while the record is in ${h(q, "or")} (Rules tab, Read-only when)`,
|
|
157
|
+
open: { kind: "tab", tab: "rules" }
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
const j = c.every((s) => s.is_visible === !1 || s.is_visible === 0);
|
|
161
|
+
u.hidden === !0 || j ? d.push({
|
|
162
|
+
state: "hidden",
|
|
163
|
+
origin: "placement",
|
|
164
|
+
text: "Hidden here",
|
|
165
|
+
tip: `${l} is hidden on this form (Look tab)`,
|
|
166
|
+
open: { kind: "tab", tab: "look" }
|
|
167
|
+
}) : u.hidden === void 0 && _(t == null ? void 0 : t.hidden) && d.push({
|
|
168
|
+
state: "hidden",
|
|
169
|
+
origin: "field",
|
|
170
|
+
text: "Hidden field",
|
|
171
|
+
tip: `${l} is hidden on every form (the field's own setting)`,
|
|
172
|
+
open: { kind: "tab", tab: "advanced" }
|
|
173
|
+
});
|
|
174
|
+
const $ = e.fieldRules.filter(
|
|
175
|
+
(s) => s.target_field === a && s.trigger_field !== a && (s.is_active === !0 || s.is_active === 1 || s.is_active == null)
|
|
176
|
+
);
|
|
177
|
+
$.length > 0 && d.push({
|
|
178
|
+
state: "filled",
|
|
179
|
+
origin: "field_rule",
|
|
180
|
+
text: $.length === 1 ? "Filled by a rule" : `Filled by ${$.length} rules`,
|
|
181
|
+
tip: $.map((s) => M(s, n, r)).join(". "),
|
|
182
|
+
open: { kind: "field_rules" }
|
|
183
|
+
}), d.length > 0 && f.set(a, d);
|
|
184
|
+
}
|
|
185
|
+
return f;
|
|
186
|
+
}
|
|
187
|
+
function E(e) {
|
|
188
|
+
const { describe: o, choices: n } = e, r = /* @__PURE__ */ new Map();
|
|
189
|
+
for (const i of e.layout.groups) {
|
|
190
|
+
const f = [], p = { kind: "group", key: i.key }, a = i.label || i.key, c = N(i.visible_when);
|
|
191
|
+
if (c.length > 0) {
|
|
192
|
+
const u = S(c, o, n);
|
|
193
|
+
u && f.push({
|
|
194
|
+
kind: "shows_when",
|
|
195
|
+
text: `Shows when ${u}`,
|
|
196
|
+
tip: `${a} shows only when ${u} (section settings)`,
|
|
197
|
+
open: p
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
const t = b(i.skip_if_filled).map(String).filter(Boolean);
|
|
201
|
+
if (t.length > 0) {
|
|
202
|
+
const u = t.map((m) => y(m, o));
|
|
203
|
+
f.push({
|
|
204
|
+
kind: "skip",
|
|
205
|
+
text: `Skipped when ${h(u)} ${t.length === 1 ? "is" : "are"} filled`,
|
|
206
|
+
tip: `A new record starts past ${a} when ${h(u)} ${t.length === 1 ? "is" : "are"} already filled`,
|
|
207
|
+
open: p
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
const l = w(i.hidden_for_roles, e.roleNames);
|
|
211
|
+
l.length > 0 && f.push({
|
|
212
|
+
kind: "hidden_for",
|
|
213
|
+
text: `Hidden for ${h(l)}`,
|
|
214
|
+
tip: `${h(l)} never see ${a} or its fields (section settings)`,
|
|
215
|
+
open: p
|
|
216
|
+
});
|
|
217
|
+
const d = w(i.locked_for_roles, e.roleNames);
|
|
218
|
+
d.length > 0 && f.push({
|
|
219
|
+
kind: "locked_for",
|
|
220
|
+
text: `Read-only for ${h(d)}`,
|
|
221
|
+
tip: `Every field in ${a} is read-only for ${h(d)} (section settings)`,
|
|
222
|
+
open: p
|
|
223
|
+
}), f.length > 0 && r.set(i.key, f);
|
|
224
|
+
}
|
|
225
|
+
return r;
|
|
226
|
+
}
|
|
227
|
+
const H = {
|
|
228
|
+
visibility: "shows a section",
|
|
229
|
+
skip: "skips a step",
|
|
230
|
+
cascade: "filters a picker",
|
|
231
|
+
field_rule: "fills a field",
|
|
232
|
+
parent_cascade: "fills grid lines",
|
|
233
|
+
row_rule: "drives grid row rules"
|
|
234
|
+
};
|
|
235
|
+
function K(e, o, n) {
|
|
236
|
+
const r = e.fields.map((i) => y(i, o));
|
|
237
|
+
return e.kind === "self" ? `${r[0]} is inside ${n(e.group ?? "")}, which shows only by its value — once hidden, nobody can change it back` : `${[...r, r[0]].join(" → ")} depend on each other in a loop (${e.kinds.map((i) => H[i] ?? i).join(", ")})`;
|
|
238
|
+
}
|
|
239
|
+
export {
|
|
240
|
+
y as fieldLabel,
|
|
241
|
+
M as fieldRuleSentence,
|
|
242
|
+
T as fieldStateChips,
|
|
243
|
+
E as groupRuleChips,
|
|
244
|
+
K as loopSentence,
|
|
245
|
+
S as ruleSentence
|
|
246
|
+
};
|