@nivaro/react 0.2.52 → 0.2.54

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (191) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +116 -2
  4. package/dist/layout-editor.d.ts +248 -2
  5. package/dist/shared/components/FormWhatsNew.js +60 -0
  6. package/dist/shared/components/ItemEditForm.js +3994 -3876
  7. package/dist/shared/components/RecordReadView.js +219 -211
  8. package/dist/shared/components/TipLayer.js +27 -27
  9. package/dist/shared/components/help-videos/api.js +51 -41
  10. package/dist/shared/components/help-videos/editor/DetailsTab.js +147 -130
  11. package/dist/shared/components/item-edit/FieldAffordances.js +7 -6
  12. package/dist/shared/components/item-edit/FieldRow.js +353 -304
  13. package/dist/shared/components/item-edit/FormHelpVideoButton.js +59 -0
  14. package/dist/shared/components/item-edit/GroupSection.js +419 -396
  15. package/dist/shared/components/item-edit/HeaderTools.js +59 -56
  16. package/dist/shared/components/item-edit/LayoutContentBlock.js +47 -24
  17. package/dist/shared/components/item-edit/lock-why.js +87 -0
  18. package/dist/shared/components/item-edit/useFormUsageBeacon.js +59 -0
  19. package/dist/shared/components/layout-editor/AddPanel.js +204 -146
  20. package/dist/shared/components/layout-editor/ArrangeButton.js +34 -0
  21. package/dist/shared/components/layout-editor/AutoArrange.js +86 -0
  22. package/dist/shared/components/layout-editor/CanvasCompare.js +79 -0
  23. package/dist/shared/components/layout-editor/ChangeNote.js +146 -0
  24. package/dist/shared/components/layout-editor/CollabParts.js +170 -0
  25. package/dist/shared/components/layout-editor/DesignNode.js +304 -115
  26. package/dist/shared/components/layout-editor/EditorCanvas.js +21 -20
  27. package/dist/shared/components/layout-editor/EditorTopBar.js +452 -175
  28. package/dist/shared/components/layout-editor/FindReplace.js +188 -0
  29. package/dist/shared/components/layout-editor/FormMapButton.js +141 -0
  30. package/dist/shared/components/layout-editor/HistoryPanel.js +234 -109
  31. package/dist/shared/components/layout-editor/LayoutEditor.js +1101 -307
  32. package/dist/shared/components/layout-editor/LayoutsRail.js +94 -67
  33. package/dist/shared/components/layout-editor/NoteMarker.js +38 -0
  34. package/dist/shared/components/layout-editor/PlacementsTable.js +187 -0
  35. package/dist/shared/components/layout-editor/ScheduleChange.js +106 -0
  36. package/dist/shared/components/layout-editor/SessionHistory.js +84 -0
  37. package/dist/shared/components/layout-editor/StructureMenu.js +413 -0
  38. package/dist/shared/components/layout-editor/UnsavedConfirm.js +103 -0
  39. package/dist/shared/components/layout-editor/ai/AiToolsButton.js +625 -0
  40. package/dist/shared/components/layout-editor/ai/ChangeCheck.js +153 -0
  41. package/dist/shared/components/layout-editor/ai/ai-tools-api.js +80 -0
  42. package/dist/shared/components/layout-editor/ai/assist-ops.js +38 -0
  43. package/dist/shared/components/layout-editor/ai/autofill-ops.js +73 -0
  44. package/dist/shared/components/layout-editor/ai/canvas-capture.js +41 -0
  45. package/dist/shared/components/layout-editor/ai-forms/AiComposer.js +271 -0
  46. package/dist/shared/components/layout-editor/ai-forms/AiFormsButton.js +182 -0
  47. package/dist/shared/components/layout-editor/ai-forms/MeaningSuggestions.js +109 -0
  48. package/dist/shared/components/layout-editor/ai-forms/SlimPanel.js +170 -0
  49. package/dist/shared/components/layout-editor/ai-forms/ai-forms-api.js +40 -0
  50. package/dist/shared/components/layout-editor/ai-forms/pending.js +25 -0
  51. package/dist/shared/components/layout-editor/ai-forms/plan.js +263 -0
  52. package/dist/shared/components/layout-editor/ai-rules/AiAskPopover.js +160 -0
  53. package/dist/shared/components/layout-editor/ai-rules/CascadeWriter.js +175 -0
  54. package/dist/shared/components/layout-editor/ai-rules/FieldRuleWriter.js +97 -0
  55. package/dist/shared/components/layout-editor/ai-rules/RuleWriter.js +94 -0
  56. package/dist/shared/components/layout-editor/ai-rules/ValidationSuggest.js +153 -0
  57. package/dist/shared/components/layout-editor/ai-rules/api.js +6 -0
  58. package/dist/shared/components/layout-editor/ai-text/AiTextTools.js +383 -0
  59. package/dist/shared/components/layout-editor/ai-text/text-ops.js +125 -0
  60. package/dist/shared/components/layout-editor/assist/AskPanel.js +278 -0
  61. package/dist/shared/components/layout-editor/assist/ExplainDiff.js +93 -0
  62. package/dist/shared/components/layout-editor/assist/ProposalsButton.js +150 -0
  63. package/dist/shared/components/layout-editor/assist/assist-api.js +63 -0
  64. package/dist/shared/components/layout-editor/assist/jump.js +142 -0
  65. package/dist/shared/components/layout-editor/assist/settings-index.js +118 -0
  66. package/dist/shared/components/layout-editor/auto-arrange.js +101 -0
  67. package/dist/shared/components/layout-editor/bulk/BulkChangesButton.js +221 -0
  68. package/dist/shared/components/layout-editor/bulk/BulkRun.js +237 -0
  69. package/dist/shared/components/layout-editor/bulk/MacrosPanel.js +230 -0
  70. package/dist/shared/components/layout-editor/bulk/bulk-api.js +65 -0
  71. package/dist/shared/components/layout-editor/bulk/field-labels.js +22 -0
  72. package/dist/shared/components/layout-editor/bulk/macro-record.js +142 -0
  73. package/dist/shared/components/layout-editor/bulk/useMacroRecorder.js +65 -0
  74. package/dist/shared/components/layout-editor/bundle-to-active.js +1 -0
  75. package/dist/shared/components/layout-editor/canvas-diff.js +157 -0
  76. package/dist/shared/components/layout-editor/collab/FormFollowShare.js +342 -0
  77. package/dist/shared/components/layout-editor/collab/collab-api.js +77 -0
  78. package/dist/shared/components/layout-editor/commands/CommandPalette.js +221 -0
  79. package/dist/shared/components/layout-editor/commands/intents.js +214 -0
  80. package/dist/shared/components/layout-editor/commands/parse.js +242 -0
  81. package/dist/shared/components/layout-editor/design-context.js +26 -6
  82. package/dist/shared/components/layout-editor/dnd/LayoutDndProvider.js +179 -163
  83. package/dist/shared/components/layout-editor/dnd/collision.js +25 -23
  84. package/dist/shared/components/layout-editor/dnd/rail-drop.js +56 -0
  85. package/dist/shared/components/layout-editor/draft-recovery.js +61 -0
  86. package/dist/shared/components/layout-editor/editor-notes.js +78 -0
  87. package/dist/shared/components/layout-editor/editors/swap-config.js +1 -0
  88. package/dist/shared/components/layout-editor/explain/CanvasRules.js +142 -0
  89. package/dist/shared/components/layout-editor/explain/default-ghosts.js +81 -0
  90. package/dist/shared/components/layout-editor/explain/driver-hover.js +62 -0
  91. package/dist/shared/components/layout-editor/explain/field-sources.js +246 -0
  92. package/dist/shared/components/layout-editor/explain/rule-graph.js +215 -0
  93. package/dist/shared/components/layout-editor/explain/use-explain.js +132 -0
  94. package/dist/shared/components/layout-editor/field-zones.js +116 -0
  95. package/dist/shared/components/layout-editor/form-map.js +138 -0
  96. package/dist/shared/components/layout-editor/history-api.js +87 -0
  97. package/dist/shared/components/layout-editor/inheritance.js +55 -0
  98. package/dist/shared/components/layout-editor/inspect/inspect-api.js +66 -0
  99. package/dist/shared/components/layout-editor/inspect/picker-preview.js +48 -0
  100. package/dist/shared/components/layout-editor/inspect/width-fit.js +87 -0
  101. package/dist/shared/components/layout-editor/inspector/AiFillSetting.js +85 -0
  102. package/dist/shared/components/layout-editor/inspector/Breadcrumb.js +36 -0
  103. package/dist/shared/components/layout-editor/inspector/BulkInspector.js +175 -0
  104. package/dist/shared/components/layout-editor/inspector/ColumnFit.js +112 -0
  105. package/dist/shared/components/layout-editor/inspector/GroupInspector.js +146 -92
  106. package/dist/shared/components/layout-editor/inspector/HelpTab.js +174 -0
  107. package/dist/shared/components/layout-editor/inspector/Inspector.js +256 -175
  108. package/dist/shared/components/layout-editor/inspector/LookTab.js +46 -40
  109. package/dist/shared/components/layout-editor/inspector/OverrideNotice.js +61 -0
  110. package/dist/shared/components/layout-editor/inspector/PickerPreview.js +134 -0
  111. package/dist/shared/components/layout-editor/inspector/PickerTab.js +167 -141
  112. package/dist/shared/components/layout-editor/inspector/RulesTab.js +175 -128
  113. package/dist/shared/components/layout-editor/inspector/Translations.js +156 -0
  114. package/dist/shared/components/layout-editor/inspector/kit.js +3 -3
  115. package/dist/shared/components/layout-editor/inspector/tab-request.js +21 -0
  116. package/dist/shared/components/layout-editor/is-typing.js +9 -0
  117. package/dist/shared/components/layout-editor/keyboard-move.js +66 -0
  118. package/dist/shared/components/layout-editor/lint/LintPanel.js +190 -0
  119. package/dist/shared/components/layout-editor/lint/lint-api.js +52 -0
  120. package/dist/shared/components/layout-editor/load-error.js +37 -0
  121. package/dist/shared/components/layout-editor/matrix/FieldStateMatrix.js +305 -0
  122. package/dist/shared/components/layout-editor/matrix/MatrixGrid.js +181 -0
  123. package/dist/shared/components/layout-editor/matrix/RoleSectionMatrix.js +147 -0
  124. package/dist/shared/components/layout-editor/matrix/matrix-api.js +48 -0
  125. package/dist/shared/components/layout-editor/matrix/role-matrix.js +36 -0
  126. package/dist/shared/components/layout-editor/matrix/state-matrix.js +145 -0
  127. package/dist/shared/components/layout-editor/nav/FindPanel.js +109 -0
  128. package/dist/shared/components/layout-editor/nav/NavTools.js +114 -0
  129. package/dist/shared/components/layout-editor/nav/OutlinePanel.js +228 -0
  130. package/dist/shared/components/layout-editor/nav/ShortcutSheet.js +31 -0
  131. package/dist/shared/components/layout-editor/nav/find.js +20 -0
  132. package/dist/shared/components/layout-editor/nav/tree.js +142 -0
  133. package/dist/shared/components/layout-editor/nav/useEditorNav.js +101 -0
  134. package/dist/shared/components/layout-editor/nav/view-prefs.js +34 -0
  135. package/dist/shared/components/layout-editor/ops/ChangeRequestsPanel.js +143 -0
  136. package/dist/shared/components/layout-editor/ops/DependencyDiagram.js +179 -0
  137. package/dist/shared/components/layout-editor/ops/LayoutOpsBlocks.js +92 -0
  138. package/dist/shared/components/layout-editor/ops/PromotePanel.js +287 -0
  139. package/dist/shared/components/layout-editor/ops/ops-api.js +122 -0
  140. package/dist/shared/components/layout-editor/overview/OverviewActions.js +15 -3
  141. package/dist/shared/components/layout-editor/overview/describe-conditions.js +18 -14
  142. package/dist/shared/components/layout-editor/overview/overview-api.js +105 -88
  143. package/dist/shared/components/layout-editor/panel-style.js +8 -7
  144. package/dist/shared/components/layout-editor/parity-keys.json.js +4 -0
  145. package/dist/shared/components/layout-editor/pin.js +25 -0
  146. package/dist/shared/components/layout-editor/presence.js +111 -0
  147. package/dist/shared/components/layout-editor/preview/PreviewModes.js +224 -0
  148. package/dist/shared/components/layout-editor/preview/PreviewPanes.js +262 -0
  149. package/dist/shared/components/layout-editor/preview/preview-api.js +57 -0
  150. package/dist/shared/components/layout-editor/preview/preview-model.js +157 -0
  151. package/dist/shared/components/layout-editor/reuse/FieldMapStep.js +70 -0
  152. package/dist/shared/components/layout-editor/reuse/FormMoreMenu.js +127 -0
  153. package/dist/shared/components/layout-editor/reuse/LibraryRows.js +150 -0
  154. package/dist/shared/components/layout-editor/reuse/NewFormStart.js +20 -0
  155. package/dist/shared/components/layout-editor/reuse/SectionReuseActions.js +291 -0
  156. package/dist/shared/components/layout-editor/reuse/field-match.js +77 -0
  157. package/dist/shared/components/layout-editor/reuse/reuse-api.js +73 -0
  158. package/dist/shared/components/layout-editor/reuse/seed.js +13 -0
  159. package/dist/shared/components/layout-editor/reuse/useFormFromRecord.js +43 -0
  160. package/dist/shared/components/layout-editor/reuse/useRailCopy.js +34 -0
  161. package/dist/shared/components/layout-editor/settings/FormSettings.js +123 -103
  162. package/dist/shared/components/layout-editor/settings/InheritanceSection.js +1 -1
  163. package/dist/shared/components/layout-editor/settings/ToolsSection.js +174 -100
  164. package/dist/shared/components/layout-editor/settings/WhoSection.js +136 -100
  165. package/dist/shared/components/layout-editor/settings/controls.js +8 -8
  166. package/dist/shared/components/layout-editor/settings/settings-registry.js +35 -11
  167. package/dist/shared/components/layout-editor/shortcuts.js +88 -0
  168. package/dist/shared/components/layout-editor/show-when.js +35 -0
  169. package/dist/shared/components/layout-editor/slot-names.js +4 -3
  170. package/dist/shared/components/layout-editor/structure-ops.js +399 -0
  171. package/dist/shared/components/layout-editor/testing/CostLimitSetting.js +42 -0
  172. package/dist/shared/components/layout-editor/testing/TestingPanels.js +551 -0
  173. package/dist/shared/components/layout-editor/testing/testing-api.js +67 -0
  174. package/dist/shared/components/layout-editor/testing/testing-model.js +393 -0
  175. package/dist/shared/components/layout-editor/testing/use-record-check.js +44 -0
  176. package/dist/shared/components/layout-editor/toolbar-kit.js +242 -0
  177. package/dist/shared/components/layout-editor/unsaved-marks.js +72 -0
  178. package/dist/shared/components/layout-editor/usage/FillChip.js +27 -0
  179. package/dist/shared/components/layout-editor/usage/UsagePanel.js +158 -0
  180. package/dist/shared/components/layout-editor/usage/suggest-sections.js +55 -0
  181. package/dist/shared/components/layout-editor/usage/usage-api.js +104 -0
  182. package/dist/shared/components/layout-editor/useLayoutDraft.js +573 -307
  183. package/dist/shared/components/support/SuggestFormChange.js +143 -0
  184. package/dist/shared/lib/ai-fill.js +37 -0
  185. package/dist/shared/lib/form-usage-beacon.js +84 -0
  186. package/dist/shared/lib/layout-i18n.js +66 -0
  187. package/dist/shared/lib/layout-lint.js +490 -0
  188. package/dist/shared/lib/layout-ops.js +110 -106
  189. package/dist/shared/lib/screenshot.js +54 -28
  190. package/dist/shared/lib/visible-when.js +34 -0
  191. package/package.json +1 -1
@@ -1,171 +1,332 @@
1
- import { jsxs as f, jsx as s, Fragment as V } from "react/jsx-runtime";
2
- import { useQueryClient as de, useQuery as ie } from "@tanstack/react-query";
3
- import { AlertTriangle as ue, Plus as ce } from "lucide-react";
4
- import { useState as g, useEffect as v, useCallback as L, useRef as A, useMemo as P } from "react";
5
- import { createPortal as me } from "react-dom";
6
- import { useNivaroClient as fe } from "../../context.js";
7
- import { get as pe } from "../../lib/commands.js";
8
- import { UNGROUPED_KEY as ye, HEADER_GROUP_KEY as he } from "../../lib/layout-ops.js";
9
- import { cn as J } from "../../lib/utils.js";
10
- import { modalHostOf as be } from "../ui/popover.js";
11
- import { Skeleton as j } from "../ui/skeleton.js";
12
- import { AddPanel as ge } from "./AddPanel.js";
13
- import { bundleToActiveLayout as xe, previewForRole as ve, roleMarker as ke } from "./bundle-to-active.js";
14
- import { targetKey as we } from "./design-context.js";
15
- import { LayoutDndProvider as Le, useLayoutDnd as Ne } from "./dnd/LayoutDndProvider.js";
16
- import { EditorCanvas as Ee } from "./EditorCanvas.js";
17
- import { EditorTopBar as Ie } from "./EditorTopBar.js";
18
- import { useLayoutEditorHost as Se } from "./host.js";
19
- import { LayoutsRail as Pe } from "./LayoutsRail.js";
20
- import { useLayoutOverview as Re, useOverviewFields as Ke, useInvalidateLayouts as W, useRuleChoiceLabels as Ce, useApproxRecordCount as De } from "./overview/overview-api.js";
21
- import { purposeSegments as _e, Sentence as Oe } from "./overview/purpose.js";
22
- import { useRolePreview as Ae } from "./settings/settings-api.js";
23
- import { useLayoutDraft as Fe, useLayoutBundle as Te, layoutDraftKeys as qe, touchesOverview as Ue } from "./useLayoutDraft.js";
24
- import { FormSettings as $e } from "./settings/FormSettings.js";
25
- import { Inspector as ze } from "./inspector/Inspector.js";
26
- const X = (e) => {
27
- const r = e;
28
- return r != null && r.closest ? r.isContentEditable || !!r.closest(
29
- 'input, textarea, select, [role="textbox"], [contenteditable]:not([contenteditable="false"])'
30
- ) : !1;
31
- };
32
- function Be(e) {
33
- v(() => {
34
- const r = (t) => {
35
- if (!(t.metaKey || t.ctrlKey) || t.altKey) return;
36
- const n = t.key.toLowerCase(), l = n === "z" && t.shiftKey || n === "y" && !t.shiftKey;
37
- n !== "z" && !l || X(t.target) || (t.preventDefault(), l ? e.redo() : e.undo());
1
+ import { jsxs as v, jsx as n, Fragment as ue } from "react/jsx-runtime";
2
+ import { useQueryClient as Bt, useQuery as _t } from "@tanstack/react-query";
3
+ import { Percent as qt, AlertTriangle as at, Plus as Ut, BarChart3 as $t, LayoutGrid as Vt, Table2 as jt, Grid3x3 as zt, Users as Gt } from "lucide-react";
4
+ import { useState as P, useEffect as B, useMemo as N, useRef as z, useCallback as b } from "react";
5
+ import { createPortal as Ht } from "react-dom";
6
+ import { toast as st } from "sonner";
7
+ import { useNivaroClient as Wt } from "../../context.js";
8
+ import { get as Qt } from "../../lib/commands.js";
9
+ import { HEADER_GROUP_KEY as mt, UNGROUPED_KEY as Jt } from "../../lib/layout-ops.js";
10
+ import { useMyUserId as Yt } from "../../lib/presence-signals.js";
11
+ import { cn as re } from "../../lib/utils.js";
12
+ import { modalHostOf as Zt } from "../ui/popover.js";
13
+ import { Skeleton as it } from "../ui/skeleton.js";
14
+ import { AddPanel as Xt } from "./AddPanel.js";
15
+ import { AutoArrangeButton as er } from "./AutoArrange.js";
16
+ import { AiToolsButton as tr } from "./ai/AiToolsButton.js";
17
+ import { pinsToMarks as rr, mergeMarks as lt } from "./ai/ai-tools-api.js";
18
+ import { AiFormsButton as or } from "./ai-forms/AiFormsButton.js";
19
+ import { AskButton as nr, AskPanel as ar } from "./assist/AskPanel.js";
20
+ import { useAskThread as sr } from "./assist/assist-api.js";
21
+ import { jumpToSetting as ir } from "./assist/jump.js";
22
+ import { ProposalsButton as lr } from "./assist/ProposalsButton.js";
23
+ import { BulkChangesButton as dr } from "./bulk/BulkChangesButton.js";
24
+ import { useMacroRecorder as ur } from "./bulk/useMacroRecorder.js";
25
+ import { bundleToActiveLayout as ft, previewForRole as cr, roleMarker as pr } from "./bundle-to-active.js";
26
+ import { useCanvasCompare as mr, CompareBanner as fr } from "./CanvasCompare.js";
27
+ import { changeNotePolicyOf as dt, changeNoteMeta as yr, changeNoteReady as hr, ChangeNoteFields as vr, ChangeNoteSave as gr } from "./ChangeNote.js";
28
+ import { PresenceAvatars as kr, DroppedBanner as wr, RecoveryBanner as br, UnsavedList as xr } from "./CollabParts.js";
29
+ import { CommandPalette as Sr } from "./commands/CommandPalette.js";
30
+ import { nextSelection as Cr, targetKey as U } from "./design-context.js";
31
+ import { LayoutDndProvider as Rr, useLayoutDnd as Ar } from "./dnd/LayoutDndProvider.js";
32
+ import { NO_DND as Nr } from "./dnd/node.js";
33
+ import { useDraftRecovery as Lr } from "./draft-recovery.js";
34
+ import { canvasRenderer as Pr, EditorCanvas as Tr } from "./EditorCanvas.js";
35
+ import { EditorTopBar as Or } from "./EditorTopBar.js";
36
+ import { notesOf as Er, noteKey as Kr } from "./editor-notes.js";
37
+ import { useRulesView as Ir, explainMarks as Fr, RulesToggle as Mr, RuleLoopsBanner as Dr } from "./explain/CanvasRules.js";
38
+ import { useDriverHover as Br } from "./explain/driver-hover.js";
39
+ import { useCanvasExplain as _r, useDefaultGhosts as qr } from "./explain/use-explain.js";
40
+ import { FindReplaceButton as Ur } from "./FindReplace.js";
41
+ import { FormMapButton as $r } from "./FormMapButton.js";
42
+ import { useSectionChanges as Vr } from "./history-api.js";
43
+ import { useLayoutEditorHost as jr } from "./host.js";
44
+ import { overriddenTargets as zr, overrideMark as Gr } from "./inheritance.js";
45
+ import { BulkInspector as Hr } from "./inspector/BulkInspector.js";
46
+ import { requestInspectorTab as Wr } from "./inspector/tab-request.js";
47
+ import { isTyping as Ke } from "./is-typing.js";
48
+ import { ARROW_DIRS as Qr, altArrowMove as Jr } from "./keyboard-move.js";
49
+ import { LayoutsRail as Yr } from "./LayoutsRail.js";
50
+ import { LintButton as Zr, LintPanel as Xr } from "./lint/LintPanel.js";
51
+ import { useLayoutLint as eo } from "./lint/lint-api.js";
52
+ import { FieldStateMatrix as to } from "./matrix/FieldStateMatrix.js";
53
+ import { RoleSectionMatrix as ro } from "./matrix/RoleSectionMatrix.js";
54
+ import { FindTool as oo, OutlineTool as no, ViewTools as ao, ShortcutsTool as so } from "./nav/NavTools.js";
55
+ import { OutlinePanel as io } from "./nav/OutlinePanel.js";
56
+ import { useEditorNav as lo } from "./nav/useEditorNav.js";
57
+ import { COMPACT_ZOOM as uo } from "./nav/view-prefs.js";
58
+ import { useLayoutOverview as co, useOverviewFields as po, useInvalidateLayouts as yt, useRuleChoiceLabels as mo, useApproxRecordCount as fo } from "./overview/overview-api.js";
59
+ import { purposeSegments as yo, Sentence as ho } from "./overview/purpose.js";
60
+ import { PlacementsTable as vo } from "./PlacementsTable.js";
61
+ import { segTrack as go, amberStrip as ut, segOption as ko } from "./panel-style.js";
62
+ import { useLayoutPresence as wo, peersByTarget as bo } from "./presence.js";
63
+ import { PreviewModes as xo } from "./preview/PreviewModes.js";
64
+ import { PreviewPanes as So } from "./preview/PreviewPanes.js";
65
+ import { FormMoreMenu as Co } from "./reuse/FormMoreMenu.js";
66
+ import { useRailCopy as Ro } from "./reuse/useRailCopy.js";
67
+ import { StructureActions as Ao, usePinMarks as No } from "./StructureMenu.js";
68
+ import { useRolePreview as Lo } from "./settings/settings-api.js";
69
+ import { layoutKindOf as Po } from "./settings/settings-registry.js";
70
+ import { ImpactButton as To, TestingButton as Oo } from "./testing/TestingPanels.js";
71
+ import { MenuSeparator as ge, ToolButton as Eo } from "./toolbar-kit.js";
72
+ import { unsavedText as Ko, UnsavedConfirm as Io } from "./UnsavedConfirm.js";
73
+ import { unsavedKeys as Fo, targetFromKey as ct, describeTarget as pt } from "./unsaved-marks.js";
74
+ import { UsagePanel as Mo } from "./usage/UsagePanel.js";
75
+ import { useShowFillRates as Do, useFieldFillRates as Bo, usageTodayText as _o, useLayoutUsageToday as qo } from "./usage/usage-api.js";
76
+ import { useLayoutDraft as Uo, useLayoutBundle as Te, layoutDraftKeys as $o, touchesOverview as Vo } from "./useLayoutDraft.js";
77
+ import { FormSettings as jo } from "./settings/FormSettings.js";
78
+ import { Inspector as zo } from "./inspector/Inspector.js";
79
+ function Go(r) {
80
+ B(() => {
81
+ const l = (s) => {
82
+ if (!(s.metaKey || s.ctrlKey) || s.altKey) return;
83
+ const i = s.key.toLowerCase();
84
+ if (i === "s" && !s.shiftKey) {
85
+ s.preventDefault(), r.autosave ? r.flush() : r.save();
86
+ return;
87
+ }
88
+ const m = i === "z" && s.shiftKey || i === "y" && !s.shiftKey;
89
+ i !== "z" && !m || Ke(s.target) || (s.preventDefault(), m ? r.redo() : r.undo());
38
90
  };
39
- return window.addEventListener("keydown", r), () => window.removeEventListener("keydown", r);
40
- }, [e.undo, e.redo]);
91
+ return window.addEventListener("keydown", l), () => window.removeEventListener("keydown", l);
92
+ }, [r.undo, r.redo, r.autosave, r.flush, r.save]);
41
93
  }
42
- function He(e) {
43
- const r = e.status === "saving";
44
- v(() => {
45
- if (!r) return;
46
- const t = (n) => {
47
- e.flush(), n.preventDefault(), n.returnValue = "";
94
+ function Ho(r, l, s, i, m) {
95
+ B(() => {
96
+ const d = (u) => {
97
+ const h = Qr[u.key];
98
+ if (!h || !u.altKey || u.metaKey || u.ctrlKey || u.shiftKey || u.defaultPrevented || !r || l.length !== 1 || i.current || Ke(u.target) || document.querySelector('[data-radix-popper-content-wrapper], [role="menu"]')) return;
99
+ u.preventDefault();
100
+ const p = Jr(r, l[0], h);
101
+ if (!p) return;
102
+ s(p.ops, { label: p.label }), m(p.next);
103
+ const c = U(p.next);
104
+ requestAnimationFrame(() => {
105
+ var G;
106
+ const g = document.querySelector(
107
+ `[data-layout-editor] [data-design-target="${CSS.escape(c)}"]`
108
+ );
109
+ g == null || g.focus({ preventScroll: !0 }), (G = g == null ? void 0 : g.scrollIntoView) == null || G.call(g, { block: "nearest" });
110
+ });
111
+ };
112
+ return window.addEventListener("keydown", d), () => window.removeEventListener("keydown", d);
113
+ }, [r, l, s, i, m]);
114
+ }
115
+ function Wo(r) {
116
+ const l = r.status === "saving" || r.dirty;
117
+ B(() => {
118
+ if (!l) return;
119
+ const s = (i) => {
120
+ r.flush(), i.preventDefault(), i.returnValue = "";
48
121
  };
49
- return window.addEventListener("beforeunload", t), () => window.removeEventListener("beforeunload", t);
50
- }, [r, e.flush]), v(() => {
51
- const t = () => e.flush();
52
- return window.addEventListener("pagehide", t), () => window.removeEventListener("pagehide", t);
53
- }, [e.flush]);
122
+ return window.addEventListener("beforeunload", s), () => window.removeEventListener("beforeunload", s);
123
+ }, [l, r.flush]), B(() => {
124
+ const s = () => r.flush();
125
+ return window.addEventListener("pagehide", s), () => window.removeEventListener("pagehide", s);
126
+ }, [r.flush]);
54
127
  }
55
- function Me(e) {
56
- const r = de(), t = W(e);
57
- return L(
58
- (n, l) => {
59
- const d = Number(n.layout.id);
60
- Number.isFinite(d) && r.invalidateQueries({ queryKey: qe.versions(d) }), t({ lazy: !Ue(l) });
128
+ function Qo(r) {
129
+ const l = Bt(), s = yt(r);
130
+ return b(
131
+ (i, m) => {
132
+ const d = Number(i.layout.id);
133
+ Number.isFinite(d) && l.invalidateQueries({ queryKey: $o.versions(d) }), s({ lazy: !Vo(m) });
61
134
  },
62
- [r, t]
135
+ [l, s]
63
136
  );
64
137
  }
65
- function Ge(e, r) {
66
- const t = fe();
67
- return ie({
68
- queryKey: ["layout-editor", "preview-record", e, r],
69
- queryFn: () => t.request(
70
- pe(`/items/${encodeURIComponent(e)}/${encodeURIComponent(String(r))}`)
71
- ).then((n) => n.data ?? null),
72
- enabled: r != null,
138
+ function Jo(r, l) {
139
+ const s = Wt();
140
+ return _t({
141
+ queryKey: ["layout-editor", "preview-record", r, l],
142
+ queryFn: () => s.request(
143
+ Qt(`/items/${encodeURIComponent(r)}/${encodeURIComponent(String(l))}`)
144
+ ).then((i) => i.data ?? null),
145
+ enabled: l != null,
73
146
  staleTime: 3e4
74
147
  });
75
148
  }
76
- function Qe(e, r, t = null) {
77
- const n = (l) => {
78
- if (e.kind === "group") return e.key === ye || l.groups.some((c) => c.key === e.key);
79
- const d = e.kind === "header" ? he : e.group_key;
80
- return l.placements.some((c) => c.field === e.field && c.group_key === d);
149
+ function Yo(r, l) {
150
+ const s = z(l);
151
+ s.current = l, B(() => {
152
+ if (!r) return;
153
+ let i = !1;
154
+ const m = (d) => {
155
+ var p, c;
156
+ if (i || d.defaultPrevented || d.button !== 0 || d.metaKey || d.ctrlKey || d.shiftKey || d.altKey) return;
157
+ const u = (c = (p = d.target) == null ? void 0 : p.closest) == null ? void 0 : c.call(p, "a[href]");
158
+ if (!u || u.target && u.target !== "_self" || u.hasAttribute("download")) return;
159
+ let h;
160
+ try {
161
+ h = new URL(u.href, window.location.href);
162
+ } catch {
163
+ return;
164
+ }
165
+ h.origin === window.location.origin && h.pathname + h.search !== window.location.pathname + window.location.search && (d.preventDefault(), d.stopPropagation(), s.current(() => {
166
+ i = !0;
167
+ try {
168
+ u.click();
169
+ } finally {
170
+ i = !1;
171
+ }
172
+ }, u));
173
+ };
174
+ return document.addEventListener("click", m, !0), () => document.removeEventListener("click", m, !0);
175
+ }, [r]);
176
+ }
177
+ function Oe(r, l, s = null) {
178
+ const i = (m) => {
179
+ if (r.kind === "group") return r.key === Jt || m.groups.some((u) => u.key === r.key);
180
+ const d = r.kind === "header" ? mt : r.group_key;
181
+ return m.placements.some((u) => u.field === r.field && u.group_key === d);
81
182
  };
82
- return n(r) || t != null && n(t);
183
+ return i(l) || s != null && i(s);
83
184
  }
84
- function je(e, r, t) {
85
- const n = A(null), l = A(r);
86
- return l.current = r, v(() => {
87
- var m;
88
- if (!e) return;
185
+ function Zo(r, l, s) {
186
+ const i = z(null), m = z(l);
187
+ return m.current = l, B(() => {
188
+ var h;
189
+ if (!r) return;
89
190
  const d = document.activeElement;
90
- (m = n.current) == null || m.focus();
91
- const c = (i) => {
92
- i.key !== "Escape" || i.defaultPrevented || t.current || X(i.target) || document.querySelector('[data-radix-popper-content-wrapper], [role="menu"]') || (i.preventDefault(), l.current());
191
+ (h = i.current) == null || h.focus();
192
+ const u = (p) => {
193
+ p.key !== "Escape" || p.defaultPrevented || s.current || Ke(p.target) || document.querySelector('[data-radix-popper-content-wrapper], [role="menu"]') || (p.preventDefault(), m.current());
93
194
  };
94
- return document.addEventListener("keydown", c), () => {
95
- document.removeEventListener("keydown", c), d != null && d.isConnected && d.focus();
195
+ return document.addEventListener("keydown", u), () => {
196
+ document.removeEventListener("keydown", u), d != null && d.isConnected && d.focus();
96
197
  };
97
- }, [e, t]), n;
198
+ }, [r, s]), i;
98
199
  }
99
- function Ye({
100
- collection: e,
101
- bundle: r,
102
- parent: t,
103
- preview: n,
104
- record: l,
105
- selected: d,
106
- onSelect: c,
107
- showHidden: m,
108
- apply: i,
109
- whenIdle: N
200
+ function Xo({
201
+ collection: r,
202
+ bundle: l,
203
+ parent: s,
204
+ roleId: i,
205
+ stateKey: m = null,
206
+ marks: d,
207
+ overlay: u,
208
+ ruleMarks: h,
209
+ ghost: p,
210
+ deps: c,
211
+ noDnd: g = !1,
212
+ record: G,
213
+ selected: o,
214
+ selection: ce,
215
+ onSelect: t,
216
+ showHidden: T,
217
+ fold: J = null,
218
+ reveal: $ = null,
219
+ apply: O,
220
+ whenIdle: ke,
221
+ fillRate: pe,
222
+ unsaved: me,
223
+ peers: ne,
224
+ compare: y,
225
+ lastChanges: L
110
226
  }) {
111
- const E = Ne(), a = P(() => xe(r, t), [r, t]), o = P(
112
- () => ve(a.active, n.roleId, m),
113
- [a.active, n.roleId, m]
114
- ), { data: y = null } = Ae(e, n.roleId), k = P(
115
- () => n.roleId ? ke(y) : void 0,
116
- [n.roleId, y]
117
- ), I = P(
227
+ const Y = Ar(), _ = g ? Nr : Y, ae = Pr(String(l.layout.layout_type ?? "grouped")), oe = (ae === "item-edit-form" || ae === "read-view") && (y == null ? void 0 : y.diff.bundle) || l, M = N(() => ft(oe, s), [oe, s]), H = N(
228
+ () => s ? zr(l, s) : null,
229
+ [l, s]
230
+ ), V = N(() => H != null && H.size ? (S) => {
231
+ const j = H.get(U(S)), Z = (d == null ? void 0 : d(S)) ?? [];
232
+ return j ? [...Z, Gr(j)] : Z;
233
+ } : d, [H, d]), we = N(
234
+ () => cr(M.active, i, T),
235
+ [M.active, i, T]
236
+ ), { data: I = null } = Lo(r, i), W = N(
237
+ () => i ? pr(I) : void 0,
238
+ [i, I]
239
+ ), C = N(() => Er(l), [l]), F = N(
240
+ () => V && h ? (S) => [...V(S), ...h(S)] : V ?? h,
241
+ [V, h]
242
+ ), D = No(l, F), be = N(
118
243
  () => ({
119
- selected: d,
120
- onSelect: c,
121
- showHidden: m,
122
- inheritedFrom: (w) => a.inherited.get(we(w)) ?? null,
123
- dnd: E,
124
- roleMark: k
244
+ selected: o,
245
+ selection: ce,
246
+ onSelect: t,
247
+ showHidden: T,
248
+ inheritedFrom: (S) => M.inherited.get(U(S)) ?? null,
249
+ dnd: _,
250
+ roleMark: W,
251
+ marks: D,
252
+ overlay: u,
253
+ fillRate: pe,
254
+ note: (S) => {
255
+ const j = Kr(S);
256
+ return j ? C.get(j) ?? null : null;
257
+ },
258
+ fold: J,
259
+ reveal: $,
260
+ unsaved: me,
261
+ peers: ne,
262
+ diffMark: y ? (S) => y.diff.marks.get(U(S)) ?? null : void 0,
263
+ lastChange: L ? (S) => S.kind === "group" ? L[S.key] ?? null : null : void 0,
264
+ ghost: p
125
265
  }),
126
- [d, c, m, a.inherited, E, k]
127
- );
128
- return /* @__PURE__ */ s(
129
- Ee,
266
+ [
267
+ o,
268
+ ce,
269
+ t,
270
+ T,
271
+ M.inherited,
272
+ _,
273
+ W,
274
+ D,
275
+ u,
276
+ pe,
277
+ C,
278
+ J,
279
+ $,
280
+ me,
281
+ ne,
282
+ y,
283
+ L,
284
+ p
285
+ ]
286
+ ), x = Br(c);
287
+ return /* @__PURE__ */ n("div", { ref: x, className: "flex min-h-full flex-col", children: /* @__PURE__ */ n(
288
+ Tr,
130
289
  {
131
- collection: e,
132
- bundle: r,
133
- layout: o,
134
- record: l,
135
- design: I,
136
- apply: i,
137
- whenIdle: N
290
+ collection: r,
291
+ bundle: oe,
292
+ layout: we,
293
+ record: G,
294
+ stateKey: m,
295
+ design: be,
296
+ apply: O,
297
+ whenIdle: ke
138
298
  }
139
- );
299
+ ) });
140
300
  }
141
- function Ve({
142
- collection: e,
143
- name: r,
144
- row: t,
145
- rows: n,
146
- fields: l,
147
- onDone: d
301
+ function en({
302
+ collection: r,
303
+ name: l,
304
+ row: s,
305
+ layoutId: i,
306
+ rows: m,
307
+ fields: d,
308
+ onDone: u
148
309
  }) {
149
- const c = Ce(e, l, n), { data: m } = De(e, t, n), i = t ? t.section === "forms" && (t.reason.kind === "default" || t.reason.kind === "fallback") ? [{ text: "used by every record no rule catches" }] : _e(t, l, c) : [];
150
- return i.length > 0 && typeof m == "number" && i.push({ text: ` (≈ ${m.toLocaleString()} ${m === 1 ? "record" : "records"})` }), /* @__PURE__ */ f(
310
+ const h = mo(r, d, m), { data: p } = fo(r, s, m), c = _o(qo(i).data), g = s ? s.section === "forms" && (s.reason.kind === "default" || s.reason.kind === "fallback") ? [{ text: "used by every record no rule catches" }] : yo(s, d, h) : [];
311
+ return g.length > 0 && typeof p == "number" && g.push({ text: ` (≈ ${p.toLocaleString()} ${p === 1 ? "record" : "records"})` }), c && g.push({ text: g.length > 0 ? `; ${c}` : c }), /* @__PURE__ */ v(
151
312
  "div",
152
313
  {
153
314
  "data-editing-banner": "",
154
315
  className: "flex shrink-0 items-center gap-3 border-b border-nvr-cyan/30 bg-nvr-cyan/10 px-4 py-1.5 text-[12.5px] text-slate-700 dark:text-slate-200",
155
316
  children: [
156
- /* @__PURE__ */ f("p", { className: "m-0 min-w-0 flex-1 truncate", children: [
317
+ /* @__PURE__ */ v("p", { className: "m-0 min-w-0 flex-1 truncate", children: [
157
318
  "Editing ",
158
- /* @__PURE__ */ s("b", { className: "font-semibold text-slate-900 dark:text-foreground", children: r }),
159
- i.length > 0 && /* @__PURE__ */ f(V, { children: [
319
+ /* @__PURE__ */ n("b", { className: "font-semibold text-slate-900 dark:text-foreground", children: l }),
320
+ g.length > 0 && /* @__PURE__ */ v(ue, { children: [
160
321
  " — ",
161
- /* @__PURE__ */ s(Oe, { segs: i, muted: !0 })
322
+ /* @__PURE__ */ n(ho, { segs: g, muted: !0 })
162
323
  ] })
163
324
  ] }),
164
- /* @__PURE__ */ s(
325
+ /* @__PURE__ */ n(
165
326
  "button",
166
327
  {
167
328
  type: "button",
168
- onClick: d,
329
+ onClick: (G) => u(G.currentTarget),
169
330
  className: "inline-flex h-7 shrink-0 items-center rounded-md bg-nvr-cyan px-3 text-[12px] font-medium text-white transition-opacity hover:opacity-90",
170
331
  children: "Done"
171
332
  }
@@ -174,220 +335,853 @@ function Ve({
174
335
  }
175
336
  );
176
337
  }
177
- const Y = (e) => J(
338
+ function tn({ view: r, onView: l }) {
339
+ const s = (i, m, d, u) => /* @__PURE__ */ v(
340
+ "button",
341
+ {
342
+ type: "button",
343
+ "aria-pressed": r === i,
344
+ "aria-label": m,
345
+ "data-editor-view": i,
346
+ "data-tip": u,
347
+ onClick: () => l(i),
348
+ className: re(ko(r === i), "inline-flex items-center justify-center gap-1"),
349
+ children: [
350
+ /* @__PURE__ */ n(d, { className: "h-3.5 w-3.5 shrink-0" }),
351
+ /* @__PURE__ */ n("span", { "data-tb-xwide": "", children: m })
352
+ ]
353
+ }
354
+ );
355
+ return /* @__PURE__ */ v(
356
+ "fieldset",
357
+ {
358
+ "aria-label": "Show the form as",
359
+ className: re("m-0 min-w-0 shrink-0 border-0", go(4)),
360
+ children: [
361
+ s("canvas", "Canvas", Vt, "The form as people see it"),
362
+ s("table", "Table", jt, "Every field as a row: label, section, width, rules"),
363
+ s(
364
+ "states",
365
+ "States",
366
+ zt,
367
+ "Every field by workflow state: editable, read-only, required"
368
+ ),
369
+ s("roles", "Roles", Gt, "Every section by role: can edit, read-only, hidden")
370
+ ]
371
+ }
372
+ );
373
+ }
374
+ const Ee = (r) => re(
178
375
  "inline-flex h-7 items-center gap-1 rounded-md px-2.5 text-[12px] font-medium transition-colors",
179
- 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"
376
+ r ? "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"
180
377
  );
181
- function kt({
182
- collection: e,
183
- layoutId: r,
184
- onBack: t,
185
- mode: n,
186
- onLayoutChange: l,
378
+ function Na({
379
+ collection: r,
380
+ layoutId: l,
381
+ onBack: s,
382
+ mode: i,
383
+ onLayoutChange: m,
187
384
  previewRecordId: d = null,
188
- portalContainer: c
385
+ portalContainer: u,
386
+ onDirtyChange: h
189
387
  }) {
190
- var Q;
191
- const m = Se(), [i, N] = g(r);
192
- v(() => N(r), [r]);
193
- const E = Me(e), a = Fe(i, { onSaved: E }), o = a.bundle, [y, k] = g("layouts"), [I, w] = g("inspector"), [x, R] = g(null), [F, Z] = g(!1), [S, T] = g({
388
+ var rt, ot, nt;
389
+ const p = jr(), [c, g] = P(l);
390
+ B(() => g(l), [l]);
391
+ const G = Qo(r), { draft: o, recorder: ce } = ur(Uo(c, { onSaved: G })), t = o.bundle, [T, J] = P("layouts"), [$, O] = P("inspector"), [ke, pe] = sr(), [me, ne] = P(null), [y, L] = P([]), Y = y.length > 0 ? y[y.length - 1] : null, [_, ae] = P("canvas"), [fe, oe] = P(!1), [M, H] = Do(), { data: V } = Bo(r, M), we = N(
392
+ () => M && V && V.total > 0 ? (e) => V.pct.get(e) ?? null : void 0,
393
+ [M, V]
394
+ ), [I, W] = P({
194
395
  record: d ? { id: d, label: `#${d}` } : null,
195
396
  roleId: null
196
- }), { data: p } = Re(e), { data: q = [] } = Ke(e), h = p == null ? void 0 : p.rows.find((u) => u.layout_id === i), ee = (o == null ? void 0 : o.layout.parent_layout_id) != null ? Number(o.layout.parent_layout_id) : null, { data: K = null } = Te(ee), { data: te = null } = Ge(e, ((Q = S.record) == null ? void 0 : Q.id) ?? null);
197
- Be(a), He(a);
198
- const U = W(e), C = L(() => {
199
- const u = a.whenIdle();
200
- u.then(() => U()), t(u);
201
- }, [a.whenIdle, U, t]);
202
- v(() => {
203
- x && o && !Qe(x, o, K) && R(null);
204
- }, [x, o, K]);
205
- const b = n === "overlay", [D, re] = g(null), $ = A(!1), ne = L((u) => {
206
- $.current = u;
207
- }, []), oe = je(b && D != null, C, $), z = L((u) => {
208
- R(u), w("inspector");
209
- }, []), ae = L(
210
- (u) => T((O) => O.roleId === u ? O : { ...O, roleId: u }),
397
+ }), { data: C } = co(r), { data: F = [] } = po(r), D = C == null ? void 0 : C.rows.find((e) => e.layout_id === c), be = (t == null ? void 0 : t.layout.parent_layout_id) != null ? Number(t.layout.parent_layout_id) : null, { data: x = null } = Te(be), { data: S = null } = Jo(r, ((rt = I.record) == null ? void 0 : rt.id) ?? null), j = N(
398
+ () => t ? ft(t, x).active : null,
399
+ [t, x]
400
+ ), Z = eo(r, t, x), { data: ht } = Te(c), Q = mr(t, ht ?? null, o.unsavedCount, c), { data: vt } = Vr(c, t != null), [Ie, gt] = P([]), kt = N(() => {
401
+ const e = rr(Ie), a = /* @__PURE__ */ new WeakMap();
402
+ return (f) => {
403
+ if (!f || !e) return lt(f, e);
404
+ const k = a.get(f);
405
+ if (k) return k;
406
+ const K = lt(f, e);
407
+ return a.set(f, K), K;
408
+ };
409
+ }, [Ie]), [se, wt] = Ir(), ye = _r(r, j, se), ie = qr(r, j, se && !I.record), { data: xe } = Te(c), E = dt(xe == null ? void 0 : xe.layout) ?? dt(t == null ? void 0 : t.layout), [le, Se] = P({ reason: "", ticket: "" }), [Fe, Me] = P(null), De = z(le);
410
+ De.current = le;
411
+ const Be = b(async () => {
412
+ const e = E ? yr(De.current) : void 0;
413
+ await o.save(e);
414
+ const a = o.unsavedOps().length === 0;
415
+ return a && e && Se((f) => ({ ...f, reason: "" })), a;
416
+ }, [o.save, o.unsavedOps, E]), _e = b(() => {
417
+ var e, a;
418
+ return E ? (o.unsavedOps().length > 0 && Me(
419
+ ((e = q.current) == null ? void 0 : e.querySelector("[data-editor-save]")) ?? ((a = q.current) == null ? void 0 : a.querySelector("[data-editor-topbar]")) ?? null
420
+ ), Promise.resolve()) : o.save();
421
+ }, [E, o.save, o.unsavedOps]);
422
+ B(() => {
423
+ E && o.autosave && o.setAutosave(!1);
424
+ }, [E, o.autosave, o.setAutosave]);
425
+ const bt = E ? { ...o, save: _e, setAutosave: void 0 } : o;
426
+ Go(E ? { ...o, save: _e } : o), Wo(o);
427
+ const q = z(null), [xt, qe] = P(null), Ue = z(o.dirty);
428
+ Ue.current = o.dirty;
429
+ const X = b((e, a, f) => {
430
+ var K, de;
431
+ if (!Ue.current) return a();
432
+ const k = ((K = q.current) == null ? void 0 : K.querySelector("[data-editor-save]")) ?? ((de = q.current) == null ? void 0 : de.querySelector("[data-editor-topbar]")) ?? null;
433
+ qe({ what: e, go: a, anchor: f ?? k });
434
+ }, []), St = Be;
435
+ Yo(o.dirty, (e, a) => X("leave this page", e, a)), B(() => {
436
+ h == null || h(o.dirty);
437
+ }, [o.dirty, h]);
438
+ const $e = z(o.unsavedOps);
439
+ $e.current = o.unsavedOps, B(
440
+ () => () => {
441
+ $e.current().length > 0 && st.warning("Unsaved form changes kept — open the form again to save or discard them");
442
+ },
211
443
  []
212
- ), B = (u) => {
213
- w("inspector"), u !== i && (a.flush(), R(null), N(u), l == null || l(u));
214
- }, _ = String((o == null ? void 0 : o.layout.name) ?? (h == null ? void 0 : h.name) ?? ""), se = String((o == null ? void 0 : o.layout.layout_type) ?? (h == null ? void 0 : h.layout_type) ?? "grouped"), H = m.warning ?? (p == null ? void 0 : p.warning) ?? null, le = b ? {
444
+ );
445
+ const Ve = yt(r), je = b(() => {
446
+ const e = o.whenIdle();
447
+ e.then(() => Ve()), s(e);
448
+ }, [o.whenIdle, Ve, s]), Ce = b(
449
+ (e) => X(i === "overlay" ? "go back to the record" : "leave this form", je, e),
450
+ [X, je, i]
451
+ );
452
+ B(() => {
453
+ if (!t || y.length === 0) return;
454
+ const e = y.filter((a) => Oe(a, t, x));
455
+ e.length !== y.length && L(e);
456
+ }, [y, t, x]);
457
+ const ee = i === "overlay", [Re, Ct] = P(null), Ae = z(!1), Rt = b((e) => {
458
+ Ae.current = e;
459
+ }, []), At = Zo(ee && Re != null, () => Ce(), Ae), R = b((e, a) => {
460
+ L((f) => Cr(f, e, a)), O("inspector");
461
+ }, []), ze = b((e) => L([e]), []), Ge = b(
462
+ (e, a) => {
463
+ if (e.kind === "group") return R({ kind: "group", key: e.key });
464
+ if (e.kind === "tab") {
465
+ R(a), (a.kind === "field" || a.kind === "header") && Wr(a.field, e.tab);
466
+ return;
467
+ }
468
+ if (e.kind === "pipeline")
469
+ return X(
470
+ "open the pipeline",
471
+ () => p.navigate(`/pipelines/${encodeURIComponent(e.id)}`)
472
+ );
473
+ X(
474
+ "open the field rules",
475
+ () => p.navigate(`/data-model/${encodeURIComponent(r)}?tab=rules`)
476
+ );
477
+ },
478
+ [R, X, p, r]
479
+ ), Nt = N(() => {
480
+ const e = /* @__PURE__ */ new Map();
481
+ for (const [a, f] of ie)
482
+ (f.type === "boolean" || f.text.endsWith(" linked")) && e.set(a, f.text);
483
+ return Fr(ye, { chips: se, ghostTags: e, open: Ge });
484
+ }, [ye, se, ie, Ge]), Lt = N(
485
+ () => ie.size > 0 ? (e) => {
486
+ var a;
487
+ return ((a = ie.get(e)) == null ? void 0 : a.text) ?? null;
488
+ } : void 0,
489
+ [ie]
490
+ ), Pt = b(
491
+ (e) => {
492
+ const a = t == null ? void 0 : t.placements.find((k) => k.field === e);
493
+ if (!a) return;
494
+ const f = a.group_key === mt ? { kind: "header", field: e } : { kind: "field", field: e, group_key: a.group_key };
495
+ R(f), requestAnimationFrame(
496
+ () => {
497
+ var k, K;
498
+ return (K = (k = document.querySelector(`[data-layout-editor] [data-design-target="${CSS.escape(U(f))}"]`)) == null ? void 0 : k.scrollIntoView) == null ? void 0 : K.call(k, { block: "center" });
499
+ }
500
+ );
501
+ },
502
+ [t, R]
503
+ );
504
+ Ho(t, y, o.apply, Ae, ze);
505
+ const Ne = wo(c, Y ? U(Y) : null), He = N(() => bo(Ne), [Ne]), Tt = b(
506
+ (e) => (He.get(U(e)) ?? []).map((a) => ({
507
+ id: a.id,
508
+ name: a.name,
509
+ outline: a.tone.outline,
510
+ chip: a.tone.chip
511
+ })),
512
+ [He]
513
+ ), We = N(() => Fo(o.unsavedSteps), [o.unsavedSteps]), Ot = b((e) => We.has(U(e)), [We]), [Qe, he] = P(null), Je = b((e) => {
514
+ ae("canvas"), L([e]), O("inspector"), requestAnimationFrame(() => {
515
+ var f;
516
+ const a = document.querySelector(
517
+ `[data-layout-editor] [data-design-target="${CSS.escape(U(e))}"]`
518
+ );
519
+ (f = a == null ? void 0 : a.scrollIntoView) == null || f.call(a, { block: "center" }), a == null || a.focus({ preventScroll: !0 });
520
+ });
521
+ }, []), Et = Yt(), Le = Lr(o, c, Et), Kt = b(
522
+ (e) => W((a) => a.roleId === e ? a : { ...a, roleId: e }),
523
+ []
524
+ ), te = (e) => {
525
+ var k;
526
+ if (O("inspector"), e === c) return;
527
+ const a = document.activeElement, f = a instanceof HTMLElement && ((k = q.current) != null && k.contains(a)) ? a : null;
528
+ X(
529
+ "open another form",
530
+ () => {
531
+ o.flush(), L([]), g(e), m == null || m(e);
532
+ },
533
+ f
534
+ );
535
+ }, It = Ro(r, t, (C == null ? void 0 : C.rows) ?? [], te), Ft = b(
536
+ (e) => t ? ir(e, {
537
+ bundle: t,
538
+ selection: y,
539
+ select: (a) => {
540
+ L([a]), O("inspector");
541
+ },
542
+ openSettings: () => O("settings"),
543
+ openAddPanel: () => J("add"),
544
+ root: q.current
545
+ }) : Promise.resolve({ ok: !1, message: "The form is still loading" }),
546
+ [t, y]
547
+ ), Ye = z(te);
548
+ Ye.current = te;
549
+ const Mt = b(
550
+ (e) => {
551
+ if (e.kind === "record")
552
+ W((a) => ({ ...a, record: { id: e.id, label: `#${e.id}` } }));
553
+ else if (e.kind === "layout") Ye.current(e.id);
554
+ else {
555
+ const a = t == null ? void 0 : t.placements.find((k) => k.field === e.field);
556
+ if (!a) return st.info(`${e.label} is not on this form`);
557
+ const f = { kind: "field", field: a.field, group_key: a.group_key };
558
+ R(f), requestAnimationFrame(
559
+ () => {
560
+ var k, K, de;
561
+ return (de = (K = (k = q.current) == null ? void 0 : k.querySelector(`[data-design-target="${CSS.escape(U(f))}"]`)) == null ? void 0 : K.scrollIntoView) == null ? void 0 : de.call(K, { block: "center" });
562
+ }
563
+ );
564
+ }
565
+ },
566
+ [t, R]
567
+ ), ve = String((t == null ? void 0 : t.layout.name) ?? (D == null ? void 0 : D.name) ?? ""), Pe = String((t == null ? void 0 : t.layout.layout_type) ?? (D == null ? void 0 : D.layout_type) ?? "grouped"), A = Pe !== "table" && Pe !== "file", w = lo({
568
+ bodyRef: q,
569
+ bundle: t,
570
+ parent: x,
571
+ fields: F,
572
+ onSelect: R,
573
+ showHidden: fe,
574
+ setShowHidden: oe,
575
+ canvasShown: !(A && _ === "table")
576
+ }), Ze = w.outlineOpen && !!t && A, Xe = p.warning ?? (C == null ? void 0 : C.warning) ?? null, Dt = ee ? {
215
577
  role: "dialog",
216
578
  "aria-modal": !0,
217
- "aria-label": `Edit layout ${_}`,
579
+ "aria-label": `Edit form ${ve}`,
218
580
  tabIndex: -1
219
- } : {}, M = /* @__PURE__ */ f(
581
+ } : {}, et = /* @__PURE__ */ v(
220
582
  "div",
221
583
  {
222
- ref: b ? oe : void 0,
584
+ ref: (e) => {
585
+ q.current = e, ee && (At.current = e);
586
+ },
223
587
  "data-layout-editor": "",
224
- "data-mode": n,
225
- ...le,
226
- className: J(
588
+ "data-mode": i,
589
+ ...Dt,
590
+ className: re(
227
591
  "flex min-h-0 flex-col bg-slate-50 outline-none dark:bg-background",
228
- b ? "fixed inset-0 z-[90]" : "flex-1"
592
+ ee ? "fixed inset-0 z-[90]" : "flex-1"
229
593
  ),
230
594
  children: [
231
- /* @__PURE__ */ s(
232
- Ie,
595
+ /* @__PURE__ */ n(
596
+ Or,
233
597
  {
234
- collection: e,
235
- layoutId: i,
236
- layoutName: _,
237
- layoutType: se,
238
- row: h,
239
- fields: q,
240
- draft: a,
241
- preview: S,
242
- onPreview: T,
243
- showHidden: F,
244
- onShowHidden: Z,
245
- onBack: C,
246
- backLabel: b ? "Back to record" : "Layouts"
598
+ collection: r,
599
+ layoutId: c,
600
+ layoutName: ve,
601
+ layoutType: Pe,
602
+ row: D,
603
+ fields: F,
604
+ draft: bt,
605
+ preview: I,
606
+ onPreview: W,
607
+ showHidden: fe,
608
+ onShowHidden: oe,
609
+ onBack: Ce,
610
+ backLabel: ee ? "Back to record" : "Forms",
611
+ onShowOnCanvas: Q.showVersion,
612
+ onReviewChanges: Q.toggleReview,
613
+ reviewing: ((ot = Q.compare) == null ? void 0 : ot.kind) === "unsaved",
614
+ onOpenUnsaved: he,
615
+ presence: /* @__PURE__ */ n(
616
+ kr,
617
+ {
618
+ peers: Ne,
619
+ describe: (e) => {
620
+ const a = ct(e);
621
+ return a && t && Oe(a, t, x) ? pt(a, t, F) : null;
622
+ },
623
+ onJump: (e) => {
624
+ const a = ct(e);
625
+ a && Je(a);
626
+ }
627
+ }
628
+ ),
629
+ onSelectField: (e) => {
630
+ var a;
631
+ return R({
632
+ kind: "field",
633
+ field: e,
634
+ group_key: ((a = t == null ? void 0 : t.placements.find((f) => f.field === e)) == null ? void 0 : a.group_key) ?? null
635
+ });
636
+ },
637
+ view: t && A ? /* @__PURE__ */ v(ue, { children: [
638
+ /* @__PURE__ */ n(tn, { view: _, onView: ae }),
639
+ /* @__PURE__ */ n(Mr, { on: se, onChange: wt })
640
+ ] }) : null,
641
+ tools: /* @__PURE__ */ v(ue, { children: [
642
+ t && A && /* @__PURE__ */ n(er, { bundle: t, apply: o.apply }),
643
+ t && /* @__PURE__ */ n(oo, { find: w.find }),
644
+ t && A && /* @__PURE__ */ n(Ur, { bundle: t, apply: o.apply, collection: r }),
645
+ /* @__PURE__ */ n(ge, {}),
646
+ t && /* @__PURE__ */ n(
647
+ no,
648
+ {
649
+ outline: A ? {
650
+ open: w.outlineOpen,
651
+ onToggle: () => w.setOutlineOpen(!w.outlineOpen)
652
+ } : null
653
+ }
654
+ ),
655
+ t && /* @__PURE__ */ n(
656
+ ao,
657
+ {
658
+ view: A && _ === "canvas" ? {
659
+ compact: w.compact,
660
+ onCompact: w.setCompact,
661
+ onExpandAll: w.expandAll,
662
+ onCollapseAll: w.collapseAll
663
+ } : null
664
+ }
665
+ ),
666
+ t && A && /* @__PURE__ */ n(
667
+ Eo,
668
+ {
669
+ label: "Show how full each field is",
670
+ icon: /* @__PURE__ */ n(qt, { className: "h-3.5 w-3.5" }),
671
+ hint: "The share of records with a value, on each field",
672
+ checked: M,
673
+ onClick: () => H(!M),
674
+ data: { "data-editor-fill-toggle": "" }
675
+ }
676
+ ),
677
+ /* @__PURE__ */ n(ge, {}),
678
+ /* @__PURE__ */ n(
679
+ dr,
680
+ {
681
+ collection: r,
682
+ layoutId: c,
683
+ dirty: o.dirty,
684
+ recorder: ce
685
+ }
686
+ ),
687
+ /* @__PURE__ */ n($r, { bundle: t, collection: r }),
688
+ /* @__PURE__ */ n(ge, {}),
689
+ t && /* @__PURE__ */ n(so, { shortcuts: w.shortcuts })
690
+ ] }),
691
+ ai: /* @__PURE__ */ v(ue, { children: [
692
+ t && A && /* @__PURE__ */ n(
693
+ or,
694
+ {
695
+ collection: r,
696
+ layoutId: c,
697
+ draft: o,
698
+ onOpenLayout: te
699
+ }
700
+ ),
701
+ t && /* @__PURE__ */ n(
702
+ tr,
703
+ {
704
+ collection: r,
705
+ layoutId: c,
706
+ bundle: t,
707
+ apply: o.apply,
708
+ previewRecordShown: I.record != null,
709
+ onPins: gt,
710
+ onSelect: R
711
+ }
712
+ ),
713
+ /* @__PURE__ */ n(ge, {}),
714
+ t && p.isAdmin && /* @__PURE__ */ n(
715
+ nr,
716
+ {
717
+ active: $ === "ask",
718
+ onClick: () => O((e) => e === "ask" ? "inspector" : "ask")
719
+ }
720
+ ),
721
+ /* @__PURE__ */ n(Sr, { collection: r, layoutId: c, draft: o }),
722
+ t && /* @__PURE__ */ n(lr, { layoutId: c, draft: o })
723
+ ] }),
724
+ testing: t ? /* @__PURE__ */ n(
725
+ Oo,
726
+ {
727
+ collection: r,
728
+ layoutId: c,
729
+ bundle: t,
730
+ parent: x,
731
+ apply: o.apply,
732
+ dirty: o.dirty,
733
+ fields: F
734
+ }
735
+ ) : null,
736
+ beforeSave: t ? /* @__PURE__ */ n(
737
+ To,
738
+ {
739
+ collection: r,
740
+ layoutId: c,
741
+ bundle: t,
742
+ parent: x,
743
+ apply: o.apply,
744
+ dirty: o.dirty,
745
+ fields: F
746
+ }
747
+ ) : null,
748
+ previewExtra: /* @__PURE__ */ n(
749
+ xo,
750
+ {
751
+ collection: r,
752
+ value: I,
753
+ onChange: W,
754
+ layout: j,
755
+ fields: F
756
+ }
757
+ ),
758
+ problems: t && /* @__PURE__ */ n(
759
+ Zr,
760
+ {
761
+ findings: Z.findings,
762
+ active: $ === "checks",
763
+ onClick: () => O((e) => e === "checks" ? "inspector" : "checks")
764
+ }
765
+ ),
766
+ more: /* @__PURE__ */ n(
767
+ Co,
768
+ {
769
+ collection: r,
770
+ bundle: t,
771
+ previewRecord: I.record,
772
+ onOpenLayout: te
773
+ }
774
+ )
775
+ }
776
+ ),
777
+ ee && /* @__PURE__ */ n(
778
+ en,
779
+ {
780
+ collection: r,
781
+ layoutId: c,
782
+ name: ve,
783
+ row: D,
784
+ rows: (C == null ? void 0 : C.rows) ?? [],
785
+ fields: F,
786
+ onDone: Ce
787
+ }
788
+ ),
789
+ o.status === "conflict" && o.dirty && /* @__PURE__ */ v(
790
+ "div",
791
+ {
792
+ role: "alert",
793
+ "data-unsaved-conflict": "",
794
+ className: re(
795
+ "flex shrink-0 items-center gap-3 border-b px-4 py-1.5 text-[12.5px]",
796
+ ut
797
+ ),
798
+ children: [
799
+ /* @__PURE__ */ n(at, { className: "h-3.5 w-3.5 shrink-0" }),
800
+ /* @__PURE__ */ v("p", { className: "m-0 min-w-0 flex-1", children: [
801
+ o.error ?? "Someone else saved this form",
802
+ ". Save again to try once more, or reload their version."
803
+ ] }),
804
+ /* @__PURE__ */ v(
805
+ "button",
806
+ {
807
+ type: "button",
808
+ "data-unsaved-reload": "",
809
+ onClick: o.discard,
810
+ className: "inline-flex h-7 shrink-0 items-center rounded-md border border-amber-300 px-2.5 text-[12px] font-medium hover:bg-amber-100 dark:border-amber-500/40 dark:hover:bg-amber-500/15",
811
+ children: [
812
+ "Reload (discard my ",
813
+ Ko(o.unsavedCount),
814
+ ")"
815
+ ]
816
+ }
817
+ )
818
+ ]
247
819
  }
248
820
  ),
249
- b && /* @__PURE__ */ s(
250
- Ve,
821
+ /* @__PURE__ */ n(wr, { labels: o.dropped, onDismiss: o.clearDropped }),
822
+ /* @__PURE__ */ n(
823
+ br,
251
824
  {
252
- collection: e,
253
- name: _,
254
- row: h,
255
- rows: (p == null ? void 0 : p.rows) ?? [],
256
- fields: q,
257
- onDone: C
825
+ state: Le.state,
826
+ onRecover: Le.recover,
827
+ onDismiss: Le.dismiss
258
828
  }
259
829
  ),
260
- H && /* @__PURE__ */ f(
830
+ Xe && /* @__PURE__ */ v(
261
831
  "div",
262
832
  {
263
833
  role: "note",
264
- className: "flex shrink-0 items-center gap-2 border-b border-amber-200 bg-amber-50 px-4 py-1.5 text-[12.5px] text-amber-800 dark:border-amber-500/30 dark:bg-amber-500/10 dark:text-amber-200",
834
+ className: re(
835
+ "flex shrink-0 items-center gap-2 border-b px-4 py-1.5 text-[12.5px]",
836
+ ut
837
+ ),
265
838
  children: [
266
- /* @__PURE__ */ s(ue, { className: "h-3.5 w-3.5 shrink-0" }),
267
- H
839
+ /* @__PURE__ */ n(at, { className: "h-3.5 w-3.5 shrink-0" }),
840
+ Xe
268
841
  ]
269
842
  }
270
843
  ),
271
- /* @__PURE__ */ s(Le, { bundle: o, apply: a.apply, onDragActive: ne, children: /* @__PURE__ */ f("div", { className: "flex min-h-0 flex-1 overflow-hidden", children: [
272
- /* @__PURE__ */ f("aside", { className: "flex w-[260px] shrink-0 flex-col border-r border-slate-200 bg-white dark:border-border dark:bg-card", children: [
273
- /* @__PURE__ */ f(
274
- "div",
275
- {
276
- role: "tablist",
277
- "aria-label": "Left panel",
278
- className: "flex shrink-0 items-center gap-1 border-b border-slate-200 px-2 py-1.5 dark:border-border",
279
- children: [
280
- /* @__PURE__ */ s(
281
- "button",
282
- {
283
- type: "button",
284
- role: "tab",
285
- "aria-selected": y === "layouts",
286
- "data-editor-tab": "layouts",
287
- className: Y(y === "layouts"),
288
- onClick: () => k("layouts"),
289
- children: "Layouts"
290
- }
844
+ /* @__PURE__ */ n(Dr, { explain: ye, onShow: Pt }),
845
+ /* @__PURE__ */ n(
846
+ Rr,
847
+ {
848
+ bundle: t,
849
+ apply: o.apply,
850
+ onDragActive: Rt,
851
+ onDropOnLayout: It,
852
+ children: /* @__PURE__ */ v("div", { className: "flex min-h-0 flex-1 overflow-hidden", children: [
853
+ /* @__PURE__ */ v(
854
+ "aside",
855
+ {
856
+ className: re(
857
+ "flex w-[260px] shrink-0 flex-col border-r border-slate-200 bg-white dark:border-border dark:bg-card",
858
+ Ze && "hidden"
291
859
  ),
292
- /* @__PURE__ */ f(
293
- "button",
860
+ children: [
861
+ /* @__PURE__ */ v(
862
+ "div",
863
+ {
864
+ role: "tablist",
865
+ "aria-label": "Left panel",
866
+ className: "flex shrink-0 items-center gap-1 border-b border-slate-200 px-2 py-1.5 dark:border-border",
867
+ children: [
868
+ /* @__PURE__ */ n(
869
+ "button",
870
+ {
871
+ type: "button",
872
+ role: "tab",
873
+ "aria-selected": T === "layouts",
874
+ "data-editor-tab": "layouts",
875
+ className: Ee(T === "layouts"),
876
+ onClick: () => J("layouts"),
877
+ children: "Forms"
878
+ }
879
+ ),
880
+ /* @__PURE__ */ v(
881
+ "button",
882
+ {
883
+ type: "button",
884
+ role: "tab",
885
+ "aria-selected": T === "add",
886
+ "data-editor-tab": "add",
887
+ className: Ee(T === "add"),
888
+ onClick: () => J("add"),
889
+ disabled: !t,
890
+ "data-tip": "Add a field, section, panel or widget after the selection",
891
+ children: [
892
+ /* @__PURE__ */ n(Ut, { className: "h-3.5 w-3.5" }),
893
+ "Add"
894
+ ]
895
+ }
896
+ ),
897
+ /* @__PURE__ */ v(
898
+ "button",
899
+ {
900
+ type: "button",
901
+ role: "tab",
902
+ "aria-selected": T === "usage",
903
+ "data-editor-tab": "usage",
904
+ className: Ee(T === "usage"),
905
+ onClick: () => J("usage"),
906
+ disabled: !t,
907
+ "data-tip": "How this form is used and where it slows people down",
908
+ children: [
909
+ /* @__PURE__ */ n($t, { className: "h-3.5 w-3.5" }),
910
+ "Usage"
911
+ ]
912
+ }
913
+ )
914
+ ]
915
+ }
916
+ ),
917
+ /* @__PURE__ */ n("div", { className: "min-h-0 flex-1 overflow-y-auto", children: T === "add" && t ? /* @__PURE__ */ n(
918
+ Xt,
919
+ {
920
+ bundle: t,
921
+ collection: r,
922
+ selected: Y,
923
+ apply: o.apply,
924
+ onSelect: R
925
+ }
926
+ ) : T === "usage" && t ? /* @__PURE__ */ n(
927
+ Mo,
928
+ {
929
+ bundle: t,
930
+ collection: r,
931
+ fields: F,
932
+ apply: o.apply,
933
+ showFill: M,
934
+ onShowFill: H
935
+ }
936
+ ) : /* @__PURE__ */ n(
937
+ Yr,
938
+ {
939
+ collection: r,
940
+ currentId: c,
941
+ onOpen: te,
942
+ settingsOpen: $ === "settings",
943
+ onSettings: () => O("settings"),
944
+ dropTargets: !0
945
+ }
946
+ ) })
947
+ ]
948
+ }
949
+ ),
950
+ Ze && t && /* @__PURE__ */ n(
951
+ "aside",
952
+ {
953
+ "data-editor-outline-panel": "",
954
+ className: "flex w-[260px] shrink-0 flex-col border-r border-slate-200 bg-white dark:border-border dark:bg-card",
955
+ children: /* @__PURE__ */ n(
956
+ io,
294
957
  {
295
- type: "button",
296
- role: "tab",
297
- "aria-selected": y === "add",
298
- "data-editor-tab": "add",
299
- className: Y(y === "add"),
300
- onClick: () => k("add"),
301
- disabled: !o,
302
- "data-tip": "Add a field, section, panel or widget after the selection",
303
- children: [
304
- /* @__PURE__ */ s(ce, { className: "h-3.5 w-3.5" }),
305
- "Add"
306
- ]
958
+ bundle: t,
959
+ nodes: w.nodes,
960
+ selection: y,
961
+ onPick: w.selectAndReveal,
962
+ onMoved: ze,
963
+ apply: o.apply,
964
+ onClose: () => w.setOutlineOpen(!1)
307
965
  }
308
966
  )
309
- ]
310
- }
311
- ),
312
- /* @__PURE__ */ s("div", { className: "min-h-0 flex-1 overflow-y-auto", children: y === "add" && o ? /* @__PURE__ */ s(
313
- ge,
314
- {
315
- bundle: o,
316
- collection: e,
317
- selected: x,
318
- apply: a.apply,
319
- onSelect: z
320
- }
321
- ) : /* @__PURE__ */ s(
322
- Pe,
323
- {
324
- collection: e,
325
- currentId: i,
326
- onOpen: B,
327
- settingsOpen: I === "settings",
328
- onSettings: () => w("settings")
329
- }
330
- ) })
331
- ] }),
332
- /* @__PURE__ */ s("main", { className: "min-w-0 flex-1 overflow-y-auto", children: o ? /* @__PURE__ */ s(
333
- Ye,
334
- {
335
- collection: e,
336
- bundle: o,
337
- parent: K,
338
- preview: S,
339
- record: te,
340
- selected: x,
341
- onSelect: z,
342
- showHidden: F,
343
- apply: a.apply,
344
- whenIdle: a.whenIdle
345
- }
346
- ) : a.error ? /* @__PURE__ */ s("p", { className: "p-6 text-[13px] text-red-700 dark:text-red-300", children: a.error }) : /* @__PURE__ */ f("div", { className: "flex flex-col gap-3 p-6", children: [
347
- /* @__PURE__ */ s(j, { className: "h-10 w-full rounded-lg" }),
348
- /* @__PURE__ */ s(j, { className: "h-48 w-full rounded-lg" })
349
- ] }) }),
350
- /* @__PURE__ */ s(
351
- "aside",
352
- {
353
- "data-editor-inspector": "",
354
- className: "flex w-[344px] shrink-0 flex-col overflow-hidden border-l border-slate-200 bg-white dark:border-border dark:bg-card",
355
- children: o && (I === "settings" ? /* @__PURE__ */ s(
356
- $e,
357
- {
358
- bundle: o,
359
- apply: a.apply,
360
- flush: a.flush,
361
- collection: e,
362
- previewRoleId: S.roleId,
363
- onPreviewRoleChange: ae
364
967
  }
365
- ) : /* @__PURE__ */ s(
366
- ze,
968
+ ),
969
+ /* @__PURE__ */ v("main", { className: "min-w-0 flex-1 overflow-y-auto", children: [
970
+ Q.compare && (_ === "canvas" || !A) && /* @__PURE__ */ n(fr, { compare: Q.compare, onClose: Q.close }),
971
+ t && A && _ === "states" ? /* @__PURE__ */ n(
972
+ to,
973
+ {
974
+ bundle: t,
975
+ parent: x,
976
+ collection: r,
977
+ apply: o.apply,
978
+ onSelect: R
979
+ }
980
+ ) : t && A && _ === "roles" ? /* @__PURE__ */ n(
981
+ ro,
982
+ {
983
+ bundle: t,
984
+ parent: x,
985
+ apply: o.apply,
986
+ onSelect: R
987
+ }
988
+ ) : t && A && _ === "table" ? /* @__PURE__ */ n(
989
+ vo,
990
+ {
991
+ bundle: t,
992
+ collection: r,
993
+ apply: o.apply,
994
+ flush: o.flush,
995
+ selection: y,
996
+ onSelect: R,
997
+ onSelection: L
998
+ }
999
+ ) : t ? /* @__PURE__ */ n(
1000
+ "div",
1001
+ {
1002
+ "data-canvas-density": w.compact && A ? "compact" : "normal",
1003
+ style: w.compact && A ? { zoom: uo } : void 0,
1004
+ className: "min-h-full",
1005
+ children: /* @__PURE__ */ n(
1006
+ So,
1007
+ {
1008
+ collection: r,
1009
+ bundle: t,
1010
+ parent: x,
1011
+ preview: I,
1012
+ onPreview: W,
1013
+ record: S,
1014
+ fields: F,
1015
+ renderPane: (e) => /* @__PURE__ */ n(
1016
+ Xo,
1017
+ {
1018
+ collection: r,
1019
+ bundle: t,
1020
+ parent: x,
1021
+ roleId: e.roleId,
1022
+ stateKey: e.stateKey,
1023
+ marks: kt(e.marks),
1024
+ overlay: e.overlay,
1025
+ ruleMarks: Nt,
1026
+ ghost: Lt,
1027
+ deps: ye.deps,
1028
+ noDnd: e.noDnd,
1029
+ record: e.record,
1030
+ selected: Y,
1031
+ selection: y,
1032
+ onSelect: R,
1033
+ showHidden: fe,
1034
+ fold: w.fold,
1035
+ reveal: w.reveal,
1036
+ apply: o.apply,
1037
+ whenIdle: o.whenIdle,
1038
+ fillRate: we,
1039
+ unsaved: Ot,
1040
+ peers: Tt,
1041
+ compare: Q.compare,
1042
+ lastChanges: Q.compare ? void 0 : vt
1043
+ }
1044
+ )
1045
+ }
1046
+ )
1047
+ }
1048
+ ) : o.error ? /* @__PURE__ */ n("p", { className: "p-6 text-[13px] text-red-700 dark:text-red-300", children: o.error }) : /* @__PURE__ */ v("div", { className: "flex flex-col gap-3 p-6", children: [
1049
+ /* @__PURE__ */ n(it, { className: "h-10 w-full rounded-lg" }),
1050
+ /* @__PURE__ */ n(it, { className: "h-48 w-full rounded-lg" })
1051
+ ] })
1052
+ ] }),
1053
+ /* @__PURE__ */ n(
1054
+ "aside",
367
1055
  {
368
- bundle: o,
369
- target: x,
370
- apply: a.apply,
371
- flush: a.flush,
372
- collection: e,
373
- openLayout: B
1056
+ "data-editor-inspector": "",
1057
+ className: "flex w-[344px] shrink-0 flex-col overflow-hidden border-l border-slate-200 bg-white dark:border-border dark:bg-card",
1058
+ children: t && ($ === "ask" ? /* @__PURE__ */ n(
1059
+ ar,
1060
+ {
1061
+ layoutId: c,
1062
+ layoutName: ve,
1063
+ kind: Po(t.layout),
1064
+ bundle: t,
1065
+ thread: ke,
1066
+ setThread: pe,
1067
+ pending: me,
1068
+ onPendingTaken: () => ne(null),
1069
+ jump: Ft,
1070
+ onCite: Mt,
1071
+ recordId: ((nt = I.record) == null ? void 0 : nt.id) ?? null
1072
+ }
1073
+ ) : $ === "checks" ? /* @__PURE__ */ n(
1074
+ Xr,
1075
+ {
1076
+ findings: Z.findings,
1077
+ health: Z.health,
1078
+ ready: Z.ready,
1079
+ onSelect: (e) => L([e]),
1080
+ apply: o.apply,
1081
+ onOpenAiReview: p.aiReviewSlot ? () => O("settings") : void 0
1082
+ }
1083
+ ) : $ === "settings" ? /* @__PURE__ */ n(
1084
+ jo,
1085
+ {
1086
+ bundle: t,
1087
+ apply: o.apply,
1088
+ flush: o.flush,
1089
+ collection: r,
1090
+ previewRoleId: I.roleId,
1091
+ onPreviewRoleChange: Kt,
1092
+ onAskWhere: p.isAdmin ? (e) => {
1093
+ ne(e), O("ask");
1094
+ } : void 0
1095
+ }
1096
+ ) : y.length > 1 ? /* @__PURE__ */ n(
1097
+ Hr,
1098
+ {
1099
+ bundle: t,
1100
+ selection: y,
1101
+ apply: o.apply,
1102
+ collection: r,
1103
+ onSelection: L
1104
+ }
1105
+ ) : /* @__PURE__ */ n(
1106
+ zo,
1107
+ {
1108
+ bundle: t,
1109
+ target: Y,
1110
+ apply: o.apply,
1111
+ flush: o.flush,
1112
+ collection: r,
1113
+ openLayout: te,
1114
+ onSelect: w.selectAndReveal
1115
+ }
1116
+ ))
374
1117
  }
375
- ))
376
- }
377
- )
378
- ] }) })
1118
+ )
1119
+ ] })
1120
+ }
1121
+ ),
1122
+ /* @__PURE__ */ n(
1123
+ Ao,
1124
+ {
1125
+ bundle: t,
1126
+ selection: y,
1127
+ apply: o.apply,
1128
+ onSelection: L,
1129
+ rootRef: q
1130
+ }
1131
+ ),
1132
+ /* @__PURE__ */ n(
1133
+ Io,
1134
+ {
1135
+ request: xt,
1136
+ count: o.unsavedCount,
1137
+ onSave: St,
1138
+ onDiscard: o.discard,
1139
+ onKeep: () => qe(null),
1140
+ note: E ? /* @__PURE__ */ n(vr, { policy: E, value: le, onChange: Se }) : void 0,
1141
+ canSave: hr(E, le)
1142
+ }
1143
+ ),
1144
+ E && Fe && /* @__PURE__ */ n(
1145
+ gr,
1146
+ {
1147
+ open: !0,
1148
+ anchor: Fe,
1149
+ policy: E,
1150
+ count: o.unsavedCount,
1151
+ value: le,
1152
+ onChange: Se,
1153
+ onSave: Be,
1154
+ onClose: () => Me(null)
1155
+ }
1156
+ ),
1157
+ Qe && /* @__PURE__ */ n(
1158
+ xr,
1159
+ {
1160
+ anchor: Qe,
1161
+ steps: o.unsavedSteps,
1162
+ exists: (e) => !!t && Oe(e, t, x),
1163
+ describe: (e) => pt(e, t, F),
1164
+ onJump: (e) => {
1165
+ he(null), Je(e);
1166
+ },
1167
+ onSettings: () => {
1168
+ he(null), O("settings");
1169
+ },
1170
+ onClose: () => he(null)
1171
+ }
1172
+ )
379
1173
  ]
380
1174
  }
381
1175
  );
382
- if (!b) return M;
383
- const G = c ?? (D ? be(D) ?? document.body : null);
384
- return /* @__PURE__ */ f(V, { children: [
385
- /* @__PURE__ */ s("span", { ref: re, hidden: !0, "data-layout-editor-marker": "" }),
386
- G && me(M, G)
1176
+ if (!ee) return et;
1177
+ const tt = u ?? (Re ? Zt(Re) ?? document.body : null);
1178
+ return /* @__PURE__ */ v(ue, { children: [
1179
+ /* @__PURE__ */ n("span", { ref: Ct, hidden: !0, "data-layout-editor-marker": "" }),
1180
+ tt && Ht(et, tt)
387
1181
  ] });
388
1182
  }
389
1183
  export {
390
- kt as LayoutEditor,
391
- X as isTyping,
392
- Qe as targetExists
1184
+ Na as LayoutEditor,
1185
+ Ke as isTyping,
1186
+ Oe as targetExists
393
1187
  };