@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,551 @@
|
|
|
1
|
+
import { jsxs as a, jsx as e, Fragment as ne } from "react/jsx-runtime";
|
|
2
|
+
import { Target as le, Loader2 as L, FlaskConical as oe, AlertTriangle as K, X as U, RefreshCw as de, Pin as ie, Check as j, EyeOff as ce, CircleDashed as me } from "lucide-react";
|
|
3
|
+
import { useState as T, useMemo as P, useCallback as he } from "react";
|
|
4
|
+
import { useNivaroClient as ue } from "../../../context.js";
|
|
5
|
+
import { useDebounced as pe } from "../../../hooks/useDebounced.js";
|
|
6
|
+
import { useRelationOptions as xe } from "../../../hooks/useRelationOptions.js";
|
|
7
|
+
import { cn as b } from "../../../lib/utils.js";
|
|
8
|
+
import { Popover as Y, PopoverContent as G } from "../../ui/popover.js";
|
|
9
|
+
import { SimpleSelect as F } from "../../ui/SimpleSelect.js";
|
|
10
|
+
import { bundleToActiveLayout as H } from "../bundle-to-active.js";
|
|
11
|
+
import { btnOutline as fe, btnPrimary as ge } from "../overview/OverviewActions.js";
|
|
12
|
+
import { useRoleNames as E, useDisplayTemplate as be } from "../overview/overview-api.js";
|
|
13
|
+
import { segOption as Ne, segTrack as ke } from "../panel-style.js";
|
|
14
|
+
import { fieldName as D } from "../preview/PreviewModes.js";
|
|
15
|
+
import { drivingFields as ve } from "../preview/preview-model.js";
|
|
16
|
+
import { useSettingsRelations as we } from "../settings/settings-api.js";
|
|
17
|
+
import { ToolButton as J } from "../toolbar-kit.js";
|
|
18
|
+
import { usePinnedLabels as Q, useFormRows as Z, draftResolution as ye, useWalkAccess as Ce } from "./testing-api.js";
|
|
19
|
+
import { readTesting as q, DEFAULT_COST_LIMIT as ee, formCost as Te, MAX_PINNED as W, samePin as M, walkthrough as $e, testingPatch as Ie } from "./testing-model.js";
|
|
20
|
+
import { useRecordCheck as te } from "./use-record-check.js";
|
|
21
|
+
const O = "mb-1 block text-[11.5px] font-semibold text-slate-600 dark:text-muted-foreground", g = "text-[11.5px] leading-snug text-slate-500 dark:text-muted-foreground", Se = "h-8 w-full rounded-md border border-slate-200 bg-white px-2.5 text-[12.5px] 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", _ = "", z = /^(\d{1,20}|[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$/i;
|
|
22
|
+
function V(t) {
|
|
23
|
+
return he((o) => D(t, o), [t]);
|
|
24
|
+
}
|
|
25
|
+
function Re({
|
|
26
|
+
collection: t,
|
|
27
|
+
pins: o,
|
|
28
|
+
onPin: r
|
|
29
|
+
}) {
|
|
30
|
+
const l = ue(), [n, m] = T(""), s = pe(n, 250), [i, c] = T(null), [x, d] = T(_), { data: C } = be(t, !0), { data: $ = [] } = E(!0), { options: N, loading: u } = xe(l, t, {
|
|
31
|
+
search: s,
|
|
32
|
+
limit: 6,
|
|
33
|
+
displayTemplate: C ?? null,
|
|
34
|
+
enabled: !i && C !== void 0
|
|
35
|
+
}), v = i ? { item: i.id, role_id: x || null } : null, y = !!v && o.some((p) => M(p, v));
|
|
36
|
+
return /* @__PURE__ */ a(
|
|
37
|
+
"div",
|
|
38
|
+
{
|
|
39
|
+
"data-test-records-add": "",
|
|
40
|
+
className: "mt-3 border-t border-slate-100 pt-3 dark:border-border",
|
|
41
|
+
children: [
|
|
42
|
+
/* @__PURE__ */ e("p", { className: O, children: "Pin a record" }),
|
|
43
|
+
i ? /* @__PURE__ */ a("span", { className: "inline-flex max-w-full items-center gap-1.5 rounded-full bg-nvr-cyan/10 px-2.5 py-1 text-[12px] font-medium text-slate-800 dark:text-foreground", children: [
|
|
44
|
+
/* @__PURE__ */ e("span", { className: "truncate", children: i.label }),
|
|
45
|
+
/* @__PURE__ */ e(
|
|
46
|
+
"button",
|
|
47
|
+
{
|
|
48
|
+
type: "button",
|
|
49
|
+
"aria-label": "Pick another record",
|
|
50
|
+
onClick: () => {
|
|
51
|
+
c(null), m("");
|
|
52
|
+
},
|
|
53
|
+
className: "text-slate-500 hover:text-slate-800 dark:text-muted-foreground dark:hover:text-foreground",
|
|
54
|
+
children: /* @__PURE__ */ e(U, { className: "h-3 w-3" })
|
|
55
|
+
}
|
|
56
|
+
)
|
|
57
|
+
] }) : /* @__PURE__ */ a(ne, { children: [
|
|
58
|
+
/* @__PURE__ */ e(
|
|
59
|
+
"input",
|
|
60
|
+
{
|
|
61
|
+
value: n,
|
|
62
|
+
onChange: (p) => m(p.target.value),
|
|
63
|
+
placeholder: "Search records…",
|
|
64
|
+
"aria-label": "Search records to pin",
|
|
65
|
+
className: Se
|
|
66
|
+
}
|
|
67
|
+
),
|
|
68
|
+
/* @__PURE__ */ a("div", { className: "mt-1 max-h-[160px] overflow-y-auto overscroll-contain", children: [
|
|
69
|
+
z.test(n.trim()) && !N.some((p) => String(p.id) === n.trim()) && /* @__PURE__ */ a(
|
|
70
|
+
"button",
|
|
71
|
+
{
|
|
72
|
+
type: "button",
|
|
73
|
+
"data-pin-by-id": "",
|
|
74
|
+
onClick: () => c({ id: n.trim(), label: `#${n.trim()}` }),
|
|
75
|
+
className: "block w-full truncate rounded px-2 py-1.5 text-left text-[12.5px] text-slate-700 hover:bg-muted dark:text-foreground",
|
|
76
|
+
children: [
|
|
77
|
+
"Record ",
|
|
78
|
+
/* @__PURE__ */ a("span", { className: "font-mono", children: [
|
|
79
|
+
"#",
|
|
80
|
+
n.trim()
|
|
81
|
+
] })
|
|
82
|
+
]
|
|
83
|
+
}
|
|
84
|
+
),
|
|
85
|
+
N.map((p) => /* @__PURE__ */ e(
|
|
86
|
+
"button",
|
|
87
|
+
{
|
|
88
|
+
type: "button",
|
|
89
|
+
"data-option-id": String(p.id),
|
|
90
|
+
onClick: () => c({ id: String(p.id), label: p.label }),
|
|
91
|
+
className: "block w-full truncate rounded px-2 py-1.5 text-left text-[12.5px] text-slate-700 hover:bg-muted dark:text-foreground",
|
|
92
|
+
children: p.label
|
|
93
|
+
},
|
|
94
|
+
String(p.id)
|
|
95
|
+
)),
|
|
96
|
+
!u && N.length === 0 && !z.test(n.trim()) && /* @__PURE__ */ e("p", { className: b(g, "px-2 py-1.5"), children: "No records match." })
|
|
97
|
+
] })
|
|
98
|
+
] }),
|
|
99
|
+
/* @__PURE__ */ a("div", { className: "mt-2 flex items-center gap-1.5", children: [
|
|
100
|
+
/* @__PURE__ */ e("div", { className: "min-w-0 flex-1", children: /* @__PURE__ */ e(
|
|
101
|
+
F,
|
|
102
|
+
{
|
|
103
|
+
value: x,
|
|
104
|
+
onChange: d,
|
|
105
|
+
ariaLabel: "Test as role",
|
|
106
|
+
className: "h-8 text-[12.5px]",
|
|
107
|
+
options: [
|
|
108
|
+
{ value: _, label: "As an administrator" },
|
|
109
|
+
...$.map((p) => ({ value: p.id, label: `As ${p.name}` }))
|
|
110
|
+
]
|
|
111
|
+
}
|
|
112
|
+
) }),
|
|
113
|
+
/* @__PURE__ */ a(
|
|
114
|
+
"button",
|
|
115
|
+
{
|
|
116
|
+
type: "button",
|
|
117
|
+
className: ge,
|
|
118
|
+
disabled: !v || y || o.length >= W,
|
|
119
|
+
"data-tip": y ? "Already pinned as this role" : void 0,
|
|
120
|
+
onClick: () => {
|
|
121
|
+
v && (r(v), c(null), m(""));
|
|
122
|
+
},
|
|
123
|
+
children: [
|
|
124
|
+
/* @__PURE__ */ e(ie, { className: "h-3.5 w-3.5" }),
|
|
125
|
+
"Pin"
|
|
126
|
+
]
|
|
127
|
+
}
|
|
128
|
+
)
|
|
129
|
+
] })
|
|
130
|
+
]
|
|
131
|
+
}
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
const ae = (t) => t === "gained" || t === "editable" ? "text-emerald-700 dark:text-emerald-300" : "text-amber-700 dark:text-amber-300";
|
|
135
|
+
function Pe(t, o) {
|
|
136
|
+
const r = t.result;
|
|
137
|
+
if (r.role_missing) return "Its role no longer exists";
|
|
138
|
+
if (!r.found) return "Record not found";
|
|
139
|
+
const l = t.after.form;
|
|
140
|
+
if (!l) return "Opens on no form";
|
|
141
|
+
if (l.layout_id !== o) return `Opens on “${l.name}”, not this form`;
|
|
142
|
+
const n = t.after.view ?? /* @__PURE__ */ new Map(), m = [...n.values()].filter((s) => s === "readonly").length;
|
|
143
|
+
return `This form · sees ${n.size} ${n.size === 1 ? "field" : "fields"}${m ? ` (${m} read-only)` : ""}`;
|
|
144
|
+
}
|
|
145
|
+
function Ae(t) {
|
|
146
|
+
const { collection: o, layoutId: r, bundle: l, parent: n, apply: m, dirty: s, fields: i, open: c } = t, x = q(l.layout.conditions), d = x.records, C = Q(o, d, c), { data: $ = [] } = E(!0), N = V(i), { run: u, running: v, error: y, check: p } = te({
|
|
147
|
+
layoutId: r,
|
|
148
|
+
bundle: l,
|
|
149
|
+
parent: n,
|
|
150
|
+
pins: d,
|
|
151
|
+
dirty: s,
|
|
152
|
+
label: N
|
|
153
|
+
}), I = (f, k) => m(
|
|
154
|
+
[
|
|
155
|
+
{
|
|
156
|
+
op: "layout_update",
|
|
157
|
+
patch: Ie(l.layout.conditions, { ...x, records: f })
|
|
158
|
+
}
|
|
159
|
+
],
|
|
160
|
+
{ label: k }
|
|
161
|
+
), S = (f) => {
|
|
162
|
+
var k;
|
|
163
|
+
return f ? ((k = $.find((A) => A.id.toUpperCase() === f.toUpperCase())) == null ? void 0 : k.name) ?? "a removed role" : null;
|
|
164
|
+
}, h = (f) => (u == null ? void 0 : u.checks.find((k) => M(k.pin, f))) ?? null, w = (u == null ? void 0 : u.against) === "saved" ? "Compared with the last save." : (u == null ? void 0 : u.against) === "previous" ? "Compared with your previous check." : u ? "First check: the next one shows what changed." : null;
|
|
165
|
+
return /* @__PURE__ */ a("div", { "data-test-records": "", children: [
|
|
166
|
+
/* @__PURE__ */ a("p", { className: g, children: [
|
|
167
|
+
"Pin up to ",
|
|
168
|
+
W,
|
|
169
|
+
" records that cover this form’s important cases. After an edit, Re-check shows which form each one gets and what it can see."
|
|
170
|
+
] }),
|
|
171
|
+
d.length === 0 ? /* @__PURE__ */ e("p", { className: b(g, "mt-3"), children: "No test records yet." }) : /* @__PURE__ */ e("ul", { className: "mt-2 flex flex-col gap-1.5", children: d.map((f) => {
|
|
172
|
+
const k = h(f), A = C.get(f.item) ?? `#${f.item}`, B = S(f.role_id);
|
|
173
|
+
return /* @__PURE__ */ a(
|
|
174
|
+
"li",
|
|
175
|
+
{
|
|
176
|
+
"data-test-record": f.item,
|
|
177
|
+
className: "rounded-md border border-slate-200 px-2.5 py-2 dark:border-border",
|
|
178
|
+
children: [
|
|
179
|
+
/* @__PURE__ */ a("div", { className: "flex items-center gap-2", children: [
|
|
180
|
+
/* @__PURE__ */ e("span", { className: "min-w-0 flex-1 truncate text-[12.5px] font-medium text-slate-800 dark:text-foreground", children: A }),
|
|
181
|
+
/* @__PURE__ */ e("span", { className: "shrink-0 text-[11.5px] text-slate-500 dark:text-muted-foreground", children: B ? `as ${B}` : "as admin" }),
|
|
182
|
+
/* @__PURE__ */ e(
|
|
183
|
+
"button",
|
|
184
|
+
{
|
|
185
|
+
type: "button",
|
|
186
|
+
"aria-label": `Unpin ${A}`,
|
|
187
|
+
onClick: () => I(
|
|
188
|
+
d.filter((R) => !M(R, f)),
|
|
189
|
+
"Unpin a test record"
|
|
190
|
+
),
|
|
191
|
+
className: "shrink-0 text-slate-400 hover:text-slate-700 dark:text-muted-foreground dark:hover:text-foreground",
|
|
192
|
+
children: /* @__PURE__ */ e(U, { className: "h-3.5 w-3.5" })
|
|
193
|
+
}
|
|
194
|
+
)
|
|
195
|
+
] }),
|
|
196
|
+
k && /* @__PURE__ */ a("div", { className: "mt-1", children: [
|
|
197
|
+
/* @__PURE__ */ e("p", { className: g, children: Pe(k, r) }),
|
|
198
|
+
k.changes.length > 0 ? /* @__PURE__ */ e("ul", { className: "mt-0.5", children: k.changes.map((R) => /* @__PURE__ */ e(
|
|
199
|
+
"li",
|
|
200
|
+
{
|
|
201
|
+
className: b("text-[12px] leading-snug", ae(R.kind)),
|
|
202
|
+
children: R.text[0].toUpperCase() + R.text.slice(1)
|
|
203
|
+
},
|
|
204
|
+
R.kind
|
|
205
|
+
)) }) : (u == null ? void 0 : u.against) !== "none" ? /* @__PURE__ */ e("p", { className: "text-[12px] text-slate-500 dark:text-muted-foreground", children: "No change" }) : null
|
|
206
|
+
] })
|
|
207
|
+
]
|
|
208
|
+
},
|
|
209
|
+
`${f.item}\0${f.role_id ?? ""}`
|
|
210
|
+
);
|
|
211
|
+
}) }),
|
|
212
|
+
d.length > 0 && /* @__PURE__ */ a("div", { className: "mt-2.5 flex items-center gap-2", children: [
|
|
213
|
+
/* @__PURE__ */ a(
|
|
214
|
+
"button",
|
|
215
|
+
{
|
|
216
|
+
type: "button",
|
|
217
|
+
"data-test-records-check": "",
|
|
218
|
+
className: fe,
|
|
219
|
+
disabled: v,
|
|
220
|
+
onClick: () => void p(),
|
|
221
|
+
children: [
|
|
222
|
+
v ? /* @__PURE__ */ e(L, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ e(de, { className: "h-3.5 w-3.5" }),
|
|
223
|
+
"Re-check"
|
|
224
|
+
]
|
|
225
|
+
}
|
|
226
|
+
),
|
|
227
|
+
/* @__PURE__ */ e("span", { className: b(g, "min-w-0"), children: y ?? w })
|
|
228
|
+
] }),
|
|
229
|
+
d.length < W && /* @__PURE__ */ e(
|
|
230
|
+
Re,
|
|
231
|
+
{
|
|
232
|
+
collection: o,
|
|
233
|
+
pins: d,
|
|
234
|
+
onPin: (f) => I([...d, f], "Pin a test record")
|
|
235
|
+
}
|
|
236
|
+
)
|
|
237
|
+
] });
|
|
238
|
+
}
|
|
239
|
+
const Oe = {
|
|
240
|
+
fill: "fills it in",
|
|
241
|
+
prefilled: "filled in already",
|
|
242
|
+
blocked: "cannot be filled",
|
|
243
|
+
skipped: "not asked"
|
|
244
|
+
};
|
|
245
|
+
function _e(t) {
|
|
246
|
+
const { collection: o, layoutId: r, bundle: l, fields: n, open: m, active: s } = t, [i, c] = T(_), [x, d] = T({}), { data: C = [] } = E(!0), $ = P(() => ye(l.layout), [l.layout]), N = Ce(r, i || null, $, m), u = Z(o, s, m), v = P(() => ve(s), [s]), y = V(n), p = P(
|
|
247
|
+
() => N.data && u.data ? $e({
|
|
248
|
+
layout: s,
|
|
249
|
+
rows: u.data,
|
|
250
|
+
access: N.data,
|
|
251
|
+
values: x,
|
|
252
|
+
thisLayoutId: r,
|
|
253
|
+
label: y
|
|
254
|
+
}) : null,
|
|
255
|
+
[N.data, u.data, s, x, r, y]
|
|
256
|
+
), I = N.isLoading || u.isLoading, S = N.error || u.error;
|
|
257
|
+
return /* @__PURE__ */ a("div", { "data-walkthrough": "", children: [
|
|
258
|
+
/* @__PURE__ */ e("p", { className: g, children: "Acts out creating a record on this form, step by step, and stops where it could not be finished. Nothing is saved." }),
|
|
259
|
+
/* @__PURE__ */ e("p", { className: b(O, "mt-3"), children: "Create as" }),
|
|
260
|
+
/* @__PURE__ */ e(
|
|
261
|
+
F,
|
|
262
|
+
{
|
|
263
|
+
value: i,
|
|
264
|
+
onChange: c,
|
|
265
|
+
ariaLabel: "Create as role",
|
|
266
|
+
className: "h-8 text-[12.5px]",
|
|
267
|
+
options: [
|
|
268
|
+
{ value: _, label: "An administrator" },
|
|
269
|
+
...C.map((h) => ({ value: h.id, label: h.name }))
|
|
270
|
+
]
|
|
271
|
+
}
|
|
272
|
+
),
|
|
273
|
+
v.length > 0 && /* @__PURE__ */ a("div", { className: "mt-2.5", children: [
|
|
274
|
+
/* @__PURE__ */ e("p", { className: O, children: "Values they enter" }),
|
|
275
|
+
/* @__PURE__ */ e("div", { className: "flex flex-col gap-1.5", children: v.map((h) => /* @__PURE__ */ a("div", { className: "flex items-center gap-2", children: [
|
|
276
|
+
/* @__PURE__ */ e("span", { className: "w-[110px] shrink-0 truncate text-[12px] text-slate-600 dark:text-muted-foreground", children: D(n, h.field) }),
|
|
277
|
+
/* @__PURE__ */ e("div", { className: "min-w-0 flex-1", children: /* @__PURE__ */ e(
|
|
278
|
+
F,
|
|
279
|
+
{
|
|
280
|
+
value: x[h.field] == null ? "" : String(x[h.field]),
|
|
281
|
+
onChange: (w) => d((f) => {
|
|
282
|
+
const k = { ...f };
|
|
283
|
+
return w === "" ? delete k[h.field] : k[h.field] = w, k;
|
|
284
|
+
}),
|
|
285
|
+
ariaLabel: `Value of ${D(n, h.field)}`,
|
|
286
|
+
className: "h-7 text-[12px]",
|
|
287
|
+
options: [
|
|
288
|
+
{ value: "", label: "Left empty" },
|
|
289
|
+
...h.values.map((w) => ({ value: w, label: w }))
|
|
290
|
+
]
|
|
291
|
+
}
|
|
292
|
+
) })
|
|
293
|
+
] }, h.field)) })
|
|
294
|
+
] }),
|
|
295
|
+
/* @__PURE__ */ e("div", { className: "mt-3 border-t border-slate-100 pt-3 dark:border-border", children: I ? /* @__PURE__ */ a("p", { className: b(g, "flex items-center gap-1.5"), children: [
|
|
296
|
+
/* @__PURE__ */ e(L, { className: "h-3.5 w-3.5 animate-spin" }),
|
|
297
|
+
"Walking through…"
|
|
298
|
+
] }) : S || !p ? /* @__PURE__ */ e("p", { className: "text-[12px] text-red-700 dark:text-red-300", children: "The walkthrough could not run." }) : /* @__PURE__ */ e(Le, { result: p }) })
|
|
299
|
+
] });
|
|
300
|
+
}
|
|
301
|
+
function Le({ result: t }) {
|
|
302
|
+
const { steps: o, blocker: r, skipped: l, notes: n } = t, m = (r == null ? void 0 : r.step) ?? Number.POSITIVE_INFINITY;
|
|
303
|
+
return /* @__PURE__ */ a("div", { "data-walk-result": r ? "blocked" : "ok", children: [
|
|
304
|
+
/* @__PURE__ */ a(
|
|
305
|
+
"p",
|
|
306
|
+
{
|
|
307
|
+
role: "status",
|
|
308
|
+
className: b(
|
|
309
|
+
"flex items-start gap-1.5 rounded-md px-2.5 py-1.5 text-[12.5px] font-medium",
|
|
310
|
+
r ? "bg-red-50 text-red-800 dark:bg-red-500/10 dark:text-red-200" : "bg-emerald-50 text-emerald-800 dark:bg-emerald-500/10 dark:text-emerald-200"
|
|
311
|
+
),
|
|
312
|
+
children: [
|
|
313
|
+
r ? /* @__PURE__ */ e(K, { className: "mt-0.5 h-3.5 w-3.5 shrink-0" }) : /* @__PURE__ */ e(j, { className: "mt-0.5 h-3.5 w-3.5 shrink-0" }),
|
|
314
|
+
/* @__PURE__ */ e("span", { children: r ? `Stops at ${r.where}: ${r.reason}` : "The record can be finished and saved." })
|
|
315
|
+
]
|
|
316
|
+
}
|
|
317
|
+
),
|
|
318
|
+
(r == null ? void 0 : r.step) !== -1 && /* @__PURE__ */ e("ol", { className: "mt-2 flex flex-col gap-1", children: o.map((s, i) => {
|
|
319
|
+
const c = s.hidden ? "hidden" : i === m ? "stop" : i > m ? "unreached" : "ok", x = s.fields;
|
|
320
|
+
return /* @__PURE__ */ a("li", { "data-walk-step": s.key, "data-walk-state": c, children: [
|
|
321
|
+
/* @__PURE__ */ a("div", { className: "flex items-center gap-1.5 text-[12.5px]", children: [
|
|
322
|
+
c === "ok" ? /* @__PURE__ */ e(j, { className: "h-3.5 w-3.5 shrink-0 text-emerald-600 dark:text-emerald-400" }) : c === "stop" ? /* @__PURE__ */ e(U, { className: "h-3.5 w-3.5 shrink-0 text-red-600 dark:text-red-400" }) : c === "hidden" ? /* @__PURE__ */ e(ce, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" }) : /* @__PURE__ */ e(me, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" }),
|
|
323
|
+
/* @__PURE__ */ a(
|
|
324
|
+
"span",
|
|
325
|
+
{
|
|
326
|
+
className: b(
|
|
327
|
+
"min-w-0 flex-1 truncate font-medium",
|
|
328
|
+
c === "unreached" || c === "hidden" ? "text-slate-400 dark:text-muted-foreground" : "text-slate-800 dark:text-foreground"
|
|
329
|
+
),
|
|
330
|
+
children: [
|
|
331
|
+
i + 1,
|
|
332
|
+
". ",
|
|
333
|
+
s.label
|
|
334
|
+
]
|
|
335
|
+
}
|
|
336
|
+
),
|
|
337
|
+
/* @__PURE__ */ e("span", { className: g, children: s.hidden ? "hidden for these values" : x.length === 0 ? "nothing required" : `${x.length} required` })
|
|
338
|
+
] }),
|
|
339
|
+
x.length > 0 && c !== "unreached" && /* @__PURE__ */ e("ul", { className: "ml-5 mt-0.5", children: x.map((d) => /* @__PURE__ */ a(
|
|
340
|
+
"li",
|
|
341
|
+
{
|
|
342
|
+
className: b(
|
|
343
|
+
"text-[12px] leading-snug",
|
|
344
|
+
d.status === "blocked" ? "text-red-700 dark:text-red-300" : "text-slate-600 dark:text-muted-foreground"
|
|
345
|
+
),
|
|
346
|
+
children: [
|
|
347
|
+
d.label,
|
|
348
|
+
" — ",
|
|
349
|
+
d.status === "blocked" ? d.reason : Oe[d.status]
|
|
350
|
+
]
|
|
351
|
+
},
|
|
352
|
+
d.field
|
|
353
|
+
)) })
|
|
354
|
+
] }, s.key);
|
|
355
|
+
}) }),
|
|
356
|
+
l.length > 0 && /* @__PURE__ */ a("div", { className: "mt-2.5", children: [
|
|
357
|
+
/* @__PURE__ */ e("p", { className: O, children: "Saves without" }),
|
|
358
|
+
/* @__PURE__ */ e("ul", { children: l.map((s) => /* @__PURE__ */ a("li", { className: "text-[12px] text-amber-700 dark:text-amber-300", children: [
|
|
359
|
+
s.label,
|
|
360
|
+
" (required) — ",
|
|
361
|
+
s.reason
|
|
362
|
+
] }, s.field)) })
|
|
363
|
+
] }),
|
|
364
|
+
n.map((s) => /* @__PURE__ */ e("p", { className: b(g, "mt-2"), children: s }, s))
|
|
365
|
+
] });
|
|
366
|
+
}
|
|
367
|
+
const qe = [
|
|
368
|
+
["picker", "picker", "pickers"],
|
|
369
|
+
["grid", "inline grid", "inline grids"],
|
|
370
|
+
["widget", "widget", "widgets"],
|
|
371
|
+
["panel", "panel", "panels"],
|
|
372
|
+
["query", "query", "queries"]
|
|
373
|
+
];
|
|
374
|
+
function re(t, o, r) {
|
|
375
|
+
const l = Z(t, o, r), n = we(t);
|
|
376
|
+
return P(
|
|
377
|
+
() => l.data ? Te({ layout: o, rows: l.data, relations: n, collection: t }) : null,
|
|
378
|
+
[l.data, o, n, t]
|
|
379
|
+
);
|
|
380
|
+
}
|
|
381
|
+
function se({ cost: t, limit: o }) {
|
|
382
|
+
const r = t.total > o, l = qe.filter(([n]) => t.counts[n] > 0).map(
|
|
383
|
+
([n, m, s]) => `${t.counts[n]} ${t.counts[n] === 1 ? m : s}`
|
|
384
|
+
);
|
|
385
|
+
return /* @__PURE__ */ a("div", { "data-form-cost": t.total, "data-form-cost-over": r ? "" : void 0, children: [
|
|
386
|
+
/* @__PURE__ */ a(
|
|
387
|
+
"p",
|
|
388
|
+
{
|
|
389
|
+
className: b(
|
|
390
|
+
"flex items-center gap-1.5 text-[12.5px] font-medium",
|
|
391
|
+
r ? "text-amber-700 dark:text-amber-300" : "text-slate-800 dark:text-foreground"
|
|
392
|
+
),
|
|
393
|
+
children: [
|
|
394
|
+
r && /* @__PURE__ */ e(K, { className: "h-3.5 w-3.5 shrink-0" }),
|
|
395
|
+
"≈ ",
|
|
396
|
+
t.total,
|
|
397
|
+
" requests when it opens ",
|
|
398
|
+
r ? `— above the limit of ${o}` : `(limit ${o})`
|
|
399
|
+
]
|
|
400
|
+
}
|
|
401
|
+
),
|
|
402
|
+
l.length > 0 && /* @__PURE__ */ e("p", { className: g, children: l.join(" · ") })
|
|
403
|
+
] });
|
|
404
|
+
}
|
|
405
|
+
function Fe(t) {
|
|
406
|
+
const { collection: o, bundle: r, open: l, active: n } = t, m = re(o, n, l), s = q(r.layout.conditions).cost_limit ?? ee, i = m ? m.items.filter((c) => c.kind !== "base").sort((c, x) => x.requests - c.requests).slice(0, 8) : [];
|
|
407
|
+
return /* @__PURE__ */ a("div", { "data-cost-tab": "", children: [
|
|
408
|
+
/* @__PURE__ */ e("p", { className: g, children: "Counts what the form asks the server for when someone opens a record on it: pickers, inline grids, widgets, panels and queries. An estimate to compare forms by." }),
|
|
409
|
+
/* @__PURE__ */ e("div", { className: "mt-3", children: m ? /* @__PURE__ */ e(se, { cost: m, limit: s }) : /* @__PURE__ */ a("p", { className: b(g, "flex items-center gap-1.5"), children: [
|
|
410
|
+
/* @__PURE__ */ e(L, { className: "h-3.5 w-3.5 animate-spin" }),
|
|
411
|
+
"Counting…"
|
|
412
|
+
] }) }),
|
|
413
|
+
i.length > 0 && /* @__PURE__ */ e("ul", { className: "mt-2.5 flex flex-col", children: i.map((c) => /* @__PURE__ */ a(
|
|
414
|
+
"li",
|
|
415
|
+
{
|
|
416
|
+
className: "flex items-center gap-2 border-t border-slate-100 py-1 text-[12px] dark:border-border",
|
|
417
|
+
children: [
|
|
418
|
+
/* @__PURE__ */ e("span", { className: "min-w-0 flex-1 truncate text-slate-700 dark:text-foreground", children: c.label }),
|
|
419
|
+
/* @__PURE__ */ e("span", { className: "shrink-0 text-slate-500 dark:text-muted-foreground", children: c.kind }),
|
|
420
|
+
/* @__PURE__ */ e("span", { className: "w-6 shrink-0 text-right font-mono text-slate-600 dark:text-muted-foreground", children: c.requests })
|
|
421
|
+
]
|
|
422
|
+
},
|
|
423
|
+
c.key
|
|
424
|
+
)) }),
|
|
425
|
+
/* @__PURE__ */ e("p", { className: b(g, "mt-2.5"), children: "The limit is in Form settings → Form cost limit." })
|
|
426
|
+
] });
|
|
427
|
+
}
|
|
428
|
+
const X = [
|
|
429
|
+
{ value: "records", label: "Test records" },
|
|
430
|
+
{ value: "walk", label: "New record" },
|
|
431
|
+
{ value: "cost", label: "Cost" }
|
|
432
|
+
];
|
|
433
|
+
function rt(t) {
|
|
434
|
+
const [o, r] = T(!1), [l, n] = T("records"), m = P(
|
|
435
|
+
() => H(t.bundle, t.parent).active,
|
|
436
|
+
[t.bundle, t.parent]
|
|
437
|
+
), s = q(t.bundle.layout.conditions).records.length;
|
|
438
|
+
return /* @__PURE__ */ a(Y, { open: o, onOpenChange: r, children: [
|
|
439
|
+
/* @__PURE__ */ e(
|
|
440
|
+
J,
|
|
441
|
+
{
|
|
442
|
+
popover: !0,
|
|
443
|
+
onOpen: () => r(!0),
|
|
444
|
+
label: "Test",
|
|
445
|
+
icon: /* @__PURE__ */ e(oe, { className: "h-4 w-4" }),
|
|
446
|
+
tip: "Test: pinned records, a new record as a role, and what the form costs to open",
|
|
447
|
+
hint: s > 0 ? `${s} pinned test ${s === 1 ? "record" : "records"}, new record, cost` : "Pinned records, a new record as a role, cost",
|
|
448
|
+
data: { "data-editor-testing": "" },
|
|
449
|
+
trailing: s > 0 && /* @__PURE__ */ e("span", { className: "rounded-full bg-slate-100 px-1.5 text-[11px] font-semibold text-slate-600 dark:bg-muted dark:text-muted-foreground", children: s })
|
|
450
|
+
}
|
|
451
|
+
),
|
|
452
|
+
/* @__PURE__ */ a(
|
|
453
|
+
G,
|
|
454
|
+
{
|
|
455
|
+
align: "end",
|
|
456
|
+
className: "max-h-[min(80vh,640px)] w-[380px] overflow-y-auto overscroll-contain p-3",
|
|
457
|
+
children: [
|
|
458
|
+
/* @__PURE__ */ e("div", { role: "tablist", "aria-label": "Test", className: ke(X.length), children: X.map((i) => /* @__PURE__ */ e(
|
|
459
|
+
"button",
|
|
460
|
+
{
|
|
461
|
+
type: "button",
|
|
462
|
+
role: "tab",
|
|
463
|
+
"aria-selected": l === i.value,
|
|
464
|
+
"data-testing-tab": i.value,
|
|
465
|
+
className: Ne(l === i.value),
|
|
466
|
+
onClick: () => n(i.value),
|
|
467
|
+
children: i.label
|
|
468
|
+
},
|
|
469
|
+
i.value
|
|
470
|
+
)) }),
|
|
471
|
+
/* @__PURE__ */ e("div", { className: "mt-3", children: l === "records" ? /* @__PURE__ */ e(Ae, { ...t, open: o }) : l === "walk" ? /* @__PURE__ */ e(_e, { ...t, open: o, active: m }) : /* @__PURE__ */ e(Fe, { ...t, open: o, active: m }) })
|
|
472
|
+
]
|
|
473
|
+
}
|
|
474
|
+
)
|
|
475
|
+
] });
|
|
476
|
+
}
|
|
477
|
+
function st(t) {
|
|
478
|
+
const { collection: o, layoutId: r, bundle: l, parent: n, dirty: m, fields: s } = t, [i, c] = T(!1), x = P(() => H(l, n).active, [l, n]), d = q(l.layout.conditions), C = Q(o, d.records, i), $ = V(s), { run: N, running: u, error: v, check: y } = te({
|
|
479
|
+
layoutId: r,
|
|
480
|
+
bundle: l,
|
|
481
|
+
parent: n,
|
|
482
|
+
pins: d.records,
|
|
483
|
+
dirty: m,
|
|
484
|
+
label: $
|
|
485
|
+
}), p = re(o, x, i), I = d.cost_limit ?? ee, S = ((N == null ? void 0 : N.checks) ?? []).filter((h) => h.changes.length > 0);
|
|
486
|
+
return /* @__PURE__ */ a(
|
|
487
|
+
Y,
|
|
488
|
+
{
|
|
489
|
+
open: i,
|
|
490
|
+
onOpenChange: (h) => {
|
|
491
|
+
c(h), h && d.records.length > 0 && y();
|
|
492
|
+
},
|
|
493
|
+
children: [
|
|
494
|
+
/* @__PURE__ */ e(
|
|
495
|
+
J,
|
|
496
|
+
{
|
|
497
|
+
popover: !0,
|
|
498
|
+
onOpen: () => {
|
|
499
|
+
c(!0), d.records.length > 0 && y();
|
|
500
|
+
},
|
|
501
|
+
label: "What changes",
|
|
502
|
+
icon: /* @__PURE__ */ e(le, { className: "h-4 w-4" }),
|
|
503
|
+
tip: "What this save changes for the pinned test records, and what the form costs to open",
|
|
504
|
+
hint: "For the pinned test records, and the form’s cost",
|
|
505
|
+
data: { "data-editor-impact": "" }
|
|
506
|
+
}
|
|
507
|
+
),
|
|
508
|
+
/* @__PURE__ */ a(G, { align: "end", className: "w-[360px] p-3", children: [
|
|
509
|
+
/* @__PURE__ */ e("p", { className: "text-[13px] font-semibold text-slate-900 dark:text-foreground", children: "What this save changes" }),
|
|
510
|
+
/* @__PURE__ */ e("div", { className: "mt-2", "data-impact-records": "", children: d.records.length === 0 ? /* @__PURE__ */ e("p", { className: g, children: "Pin test records (More → Test → Test records) to see what a save changes for them." }) : u ? /* @__PURE__ */ a("p", { className: b(g, "flex items-center gap-1.5"), children: [
|
|
511
|
+
/* @__PURE__ */ e(L, { className: "h-3.5 w-3.5 animate-spin" }),
|
|
512
|
+
"Checking ",
|
|
513
|
+
d.records.length,
|
|
514
|
+
" test ",
|
|
515
|
+
d.records.length === 1 ? "record" : "records",
|
|
516
|
+
"…"
|
|
517
|
+
] }) : v ? /* @__PURE__ */ e("p", { className: "text-[12px] text-red-700 dark:text-red-300", children: v }) : S.length === 0 ? /* @__PURE__ */ a("p", { className: "text-[12px] text-emerald-700 dark:text-emerald-300", children: [
|
|
518
|
+
"No change for the ",
|
|
519
|
+
d.records.length,
|
|
520
|
+
" pinned test",
|
|
521
|
+
" ",
|
|
522
|
+
d.records.length === 1 ? "record" : "records",
|
|
523
|
+
"."
|
|
524
|
+
] }) : /* @__PURE__ */ e("ul", { className: "flex flex-col gap-0.5", children: S.flatMap(
|
|
525
|
+
(h) => h.changes.map((w) => /* @__PURE__ */ a(
|
|
526
|
+
"li",
|
|
527
|
+
{
|
|
528
|
+
className: b("text-[12px] leading-snug", ae(w.kind)),
|
|
529
|
+
children: [
|
|
530
|
+
"Record ",
|
|
531
|
+
C.get(h.pin.item) ?? h.pin.item,
|
|
532
|
+
" ",
|
|
533
|
+
w.text
|
|
534
|
+
]
|
|
535
|
+
},
|
|
536
|
+
`${h.pin.item}\0${h.pin.role_id ?? ""}\0${w.kind}`
|
|
537
|
+
))
|
|
538
|
+
) }) }),
|
|
539
|
+
/* @__PURE__ */ e("div", { className: "mt-3 border-t border-slate-100 pt-2.5 dark:border-border", children: p ? /* @__PURE__ */ e(se, { cost: p, limit: I }) : /* @__PURE__ */ e("p", { className: g, children: "Counting what the form opens with…" }) }),
|
|
540
|
+
/* @__PURE__ */ e("p", { className: b(g, "mt-2"), children: "Nothing is saved until you press Save." })
|
|
541
|
+
] })
|
|
542
|
+
]
|
|
543
|
+
}
|
|
544
|
+
);
|
|
545
|
+
}
|
|
546
|
+
export {
|
|
547
|
+
se as CostLine,
|
|
548
|
+
st as ImpactButton,
|
|
549
|
+
rt as TestingButton,
|
|
550
|
+
re as useFormCost
|
|
551
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { useQuery as p } from "@tanstack/react-query";
|
|
2
|
+
import { useMemo as l } from "react";
|
|
3
|
+
import { useNivaroClient as c } from "../../../context.js";
|
|
4
|
+
import { useRelationOptions as y } from "../../../hooks/useRelationOptions.js";
|
|
5
|
+
import { post as u } from "../../../lib/commands.js";
|
|
6
|
+
import { useDisplayTemplate as h } from "../overview/overview-api.js";
|
|
7
|
+
function v(e) {
|
|
8
|
+
if (!e) return null;
|
|
9
|
+
const t = e;
|
|
10
|
+
return {
|
|
11
|
+
record_conditions: t.record_conditions ?? null,
|
|
12
|
+
conditions: t.conditions ?? null,
|
|
13
|
+
is_active: !!t.is_active,
|
|
14
|
+
sort: t.sort ?? 0,
|
|
15
|
+
layout_type: t.layout_type ?? null
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
async function R(e, t, s) {
|
|
19
|
+
var n;
|
|
20
|
+
const i = await e.request(
|
|
21
|
+
u(`/collection-layouts/${t}/test-records`, s)
|
|
22
|
+
);
|
|
23
|
+
return ((n = i == null ? void 0 : i.data) == null ? void 0 : n.results) ?? [];
|
|
24
|
+
}
|
|
25
|
+
function F(e, t, s, i) {
|
|
26
|
+
const n = c();
|
|
27
|
+
return p({
|
|
28
|
+
queryKey: ["layout-editor", "walkthrough-access", e, t ?? "", s],
|
|
29
|
+
queryFn: () => n.request(
|
|
30
|
+
u(`/collection-layouts/${e}/walkthrough-access`, { role_id: t, draft: s })
|
|
31
|
+
).then((o) => o.data),
|
|
32
|
+
enabled: i,
|
|
33
|
+
staleTime: 3e4
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
function M(e, t, s) {
|
|
37
|
+
const i = c(), n = (t == null ? void 0 : t.assignments) ?? null;
|
|
38
|
+
return p({
|
|
39
|
+
queryKey: ["layout-editor", "field-config", e, n],
|
|
40
|
+
queryFn: () => i.request(
|
|
41
|
+
u(`/field-config/${e}/project`, { assignments: n })
|
|
42
|
+
).then((o) => o.data ?? []),
|
|
43
|
+
enabled: s && n != null,
|
|
44
|
+
staleTime: 6e4,
|
|
45
|
+
placeholderData: (o) => o
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
function $(e, t, s) {
|
|
49
|
+
const i = c(), n = [...new Set(t.map((r) => r.item))].sort().join("\0"), o = l(() => n ? n.split("\0") : [], [n]), f = l(() => ({ id: { _in: o } }), [o]), { data: a } = h(e, s && o.length > 0), { options: m } = y(s ? i : null, e, {
|
|
50
|
+
limit: Math.max(o.length, 1),
|
|
51
|
+
displayTemplate: a ?? null,
|
|
52
|
+
filter: f,
|
|
53
|
+
enabled: s && o.length > 0 && a !== void 0
|
|
54
|
+
});
|
|
55
|
+
return l(() => {
|
|
56
|
+
const r = /* @__PURE__ */ new Map();
|
|
57
|
+
for (const d of m) r.set(String(d.id), d.label);
|
|
58
|
+
return r;
|
|
59
|
+
}, [m]);
|
|
60
|
+
}
|
|
61
|
+
export {
|
|
62
|
+
R as checkTestRecords,
|
|
63
|
+
v as draftResolution,
|
|
64
|
+
M as useFormRows,
|
|
65
|
+
$ as usePinnedLabels,
|
|
66
|
+
F as useWalkAccess
|
|
67
|
+
};
|