@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.
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 +113 -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 +4058 -3942
  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
@@ -0,0 +1,413 @@
1
+ import { jsxs as p, jsx as t, Fragment as I } from "react/jsx-runtime";
2
+ import { CopyPlus as X, Group as J, Ungroup as z, Shuffle as Q, ClipboardCopy as Z, PinOff as ee, Pin as te, ArrowLeft as ne } from "lucide-react";
3
+ import { useState as O, useRef as re, useCallback as oe, useEffect as L, useMemo as w } from "react";
4
+ import { toast as A } from "sonner";
5
+ import { UNGROUPED_KEY as se, isCanvasSlot as ae } from "../../lib/layout-ops.js";
6
+ import { cn as $ } from "../../lib/utils.js";
7
+ import { Checkbox as _ } from "../ui/checkbox.js";
8
+ import { Popover as ie, PopoverAnchor as le, PopoverContent as ce } from "../ui/popover.js";
9
+ import { STRUCTURE_MENU_EVENT as U, duplicateKeys as de } from "./ArrangeButton.js";
10
+ import { ArrangeButton as Ge, openStructureMenu as Ie } from "./ArrangeButton.js";
11
+ import { isTyping as ue } from "./is-typing.js";
12
+ import { tintCard as pe, effectText as P } from "./panel-style.js";
13
+ import { duplicatePlan as B, convertChoices as K, groupName as E, rulesOf as j, ruleSet as V, ruleTargets as me, copyRulesPlan as fe, RULE_LABELS as he, kindWord as T, wrapPlan as ge, duplicateBlocked as xe, unwrapPlan as ke, unwrapBlocked as ye, pinPlan as ve } from "./structure-ops.js";
14
+ import { isPinned as C } from "./pin.js";
15
+ function we(e) {
16
+ if (!e) return null;
17
+ const r = e.indexOf(":"), o = e.slice(0, r), i = e.slice(r + 1);
18
+ if (o === "group") return { kind: "group", key: i };
19
+ if (o === "header") return { kind: "header", field: i };
20
+ if (o !== "field" && o !== "slot") return null;
21
+ const s = i.lastIndexOf(":"), n = i.slice(s + 1);
22
+ return { kind: o, field: i.slice(0, s), group_key: n === "" ? null : n };
23
+ }
24
+ const Ne = (e, r) => ({
25
+ getBoundingClientRect: () => new DOMRect(e, r, 0, 0)
26
+ });
27
+ function qe(e, r) {
28
+ return w(() => {
29
+ const o = new Set(e.groups.filter((i) => C(i)).map((i) => i.key));
30
+ return (i) => {
31
+ const s = (r == null ? void 0 : r(i)) ?? [];
32
+ return i.kind !== "group" || !o.has(i.key) ? s : [
33
+ ...s,
34
+ {
35
+ text: "Pinned",
36
+ tone: "slate",
37
+ icon: "pin",
38
+ tip: "Pinned in the editor: it does not drag and takes no drops. The form people see is unchanged."
39
+ }
40
+ ];
41
+ };
42
+ }, [e.groups, r]);
43
+ }
44
+ function He({
45
+ bundle: e,
46
+ selection: r,
47
+ apply: o,
48
+ onSelection: i,
49
+ rootRef: s
50
+ }) {
51
+ var g, k;
52
+ const [n, l] = O(null), m = re({ bundle: e, selection: r, apply: o, onSelection: i });
53
+ m.current = { bundle: e, selection: r, apply: o, onSelection: i };
54
+ const h = oe((d, u = {}) => d.ok ? (m.current.apply(d.ops, { label: d.label }), d.select && m.current.onSelection([d.select]), u.toastNotes && d.notes.length && A.success(d.label, { description: d.notes.join(". ") }), l(null), !0) : (A(d.reason), !1), []);
55
+ L(() => {
56
+ const d = (u) => {
57
+ if (!(u.metaKey || u.ctrlKey) || u.altKey || u.shiftKey || u.key.toLowerCase() !== "d") return;
58
+ const { bundle: a, selection: c } = m.current;
59
+ if (!(!a || c.length === 0 || ue(u.target) || u.defaultPrevented) && !document.querySelector('[data-radix-popper-content-wrapper], [role="menu"]')) {
60
+ if (u.preventDefault(), c.length > 1) {
61
+ A("Duplicate works on one section at a time");
62
+ return;
63
+ }
64
+ h(B(a, c[0]), { toastNotes: !0 });
65
+ }
66
+ };
67
+ return window.addEventListener("keydown", d), () => window.removeEventListener("keydown", d);
68
+ }, [h]), L(() => {
69
+ const d = (c) => {
70
+ var f;
71
+ return !!c && !!((f = s.current) != null && f.contains(c));
72
+ }, u = (c) => {
73
+ var b, R;
74
+ const f = ((R = (b = c.target) == null ? void 0 : b.closest) == null ? void 0 : R.call(b, "[data-design-target]")) ?? null;
75
+ if (!d(f) || !(f != null && f.closest("[data-design-canvas]")) || !m.current.bundle) return;
76
+ const y = we(f.getAttribute("data-design-target"));
77
+ if (!y) return;
78
+ c.preventDefault();
79
+ const N = m.current.selection, H = f.getAttribute("data-design-target"), D = N.some((G) => be(G) === H), Y = D && N.length > 1 ? N : [y];
80
+ (!D || N.length <= 1) && m.current.onSelection([y]);
81
+ const F = c.button !== 2 && c.clientX === 0 && c.clientY === 0;
82
+ l({
83
+ targets: Y,
84
+ anchor: F ? f : Ne(c.clientX, c.clientY),
85
+ view: "menu"
86
+ });
87
+ }, a = (c) => {
88
+ const f = c.target;
89
+ if (!d(f)) return;
90
+ const y = c.detail;
91
+ l({ targets: y.targets, anchor: f, view: y.view ?? "menu" });
92
+ };
93
+ return document.addEventListener("contextmenu", u, !0), document.addEventListener(U, a), () => {
94
+ document.removeEventListener("contextmenu", u, !0), document.removeEventListener(U, a);
95
+ };
96
+ }, [s]);
97
+ const x = w(() => ({ current: (n == null ? void 0 : n.anchor) ?? null }), [n]);
98
+ return !n || !e ? null : /* @__PURE__ */ p(ie, { open: !0, onOpenChange: (d) => !d && l(null), children: [
99
+ /* @__PURE__ */ t(le, { virtualRef: x }),
100
+ /* @__PURE__ */ t(
101
+ ce,
102
+ {
103
+ align: "start",
104
+ className: "w-[300px] p-1.5",
105
+ "data-structure-menu": n.view,
106
+ onOpenAutoFocus: (d) => {
107
+ var u, a;
108
+ d.preventDefault(), (a = (u = d.currentTarget) == null ? void 0 : u.querySelector(
109
+ '[role="menuitem"]:not([aria-disabled="true"]), input, button'
110
+ )) == null || a.focus();
111
+ },
112
+ children: n.view === "convert" && ((g = n.targets[0]) == null ? void 0 : g.kind) === "group" ? /* @__PURE__ */ t(
113
+ Se,
114
+ {
115
+ bundle: e,
116
+ groupKey: n.targets[0].key,
117
+ onBack: () => l({ ...n, view: "menu" }),
118
+ run: h
119
+ }
120
+ ) : n.view === "rules" && ((k = n.targets[0]) == null ? void 0 : k.kind) === "group" ? /* @__PURE__ */ t(
121
+ Oe,
122
+ {
123
+ bundle: e,
124
+ groupKey: n.targets[0].key,
125
+ onBack: () => l({ ...n, view: "menu" }),
126
+ run: h
127
+ }
128
+ ) : /* @__PURE__ */ t(
129
+ Ee,
130
+ {
131
+ bundle: e,
132
+ targets: n.targets,
133
+ run: h,
134
+ onView: (d) => l({ ...n, view: d })
135
+ }
136
+ )
137
+ }
138
+ )
139
+ ] });
140
+ }
141
+ function be(e) {
142
+ return e.kind === "group" ? `group:${e.key}` : e.kind === "header" ? `header:${e.field}` : `${e.kind}:${e.field}:${e.group_key ?? ""}`;
143
+ }
144
+ const Ce = "flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-[12.5px] text-slate-700 outline-none transition-colors hover:bg-muted focus-visible:bg-muted dark:text-foreground aria-disabled:cursor-not-allowed aria-disabled:opacity-45 aria-disabled:hover:bg-transparent";
145
+ function v({
146
+ icon: e,
147
+ children: r,
148
+ hint: o,
149
+ blocked: i,
150
+ onPick: s,
151
+ ...n
152
+ }) {
153
+ return /* @__PURE__ */ p(
154
+ "button",
155
+ {
156
+ type: "button",
157
+ role: "menuitem",
158
+ "aria-disabled": i ? !0 : void 0,
159
+ "data-tip": i ?? void 0,
160
+ onClick: () => {
161
+ i || s();
162
+ },
163
+ className: Ce,
164
+ ...n,
165
+ children: [
166
+ /* @__PURE__ */ t("span", { className: "flex h-4 w-4 shrink-0 items-center justify-center text-slate-500 dark:text-muted-foreground [&_svg]:h-3.5 [&_svg]:w-3.5", children: e }),
167
+ /* @__PURE__ */ t("span", { className: "min-w-0 flex-1 truncate", children: r }),
168
+ o && /* @__PURE__ */ t("kbd", { className: "shrink-0 font-sans text-[11px] text-slate-400 dark:text-muted-foreground", children: o })
169
+ ]
170
+ }
171
+ );
172
+ }
173
+ function Pe(e) {
174
+ var n;
175
+ if (!["ArrowDown", "ArrowUp", "Home", "End"].includes(e.key)) return;
176
+ const o = Array.from(e.currentTarget.querySelectorAll('[role="menuitem"]'));
177
+ if (o.length === 0) return;
178
+ e.preventDefault();
179
+ const i = o.indexOf(document.activeElement), s = e.key === "Home" ? 0 : e.key === "End" ? o.length - 1 : (i + (e.key === "ArrowDown" ? 1 : -1) + o.length) % o.length;
180
+ (n = o[s]) == null || n.focus();
181
+ }
182
+ function Ee({
183
+ bundle: e,
184
+ targets: r,
185
+ run: o,
186
+ onView: i
187
+ }) {
188
+ const s = r.length === 1 ? r[0] : null, n = (s == null ? void 0 : s.kind) === "group" && s.key !== se ? e.groups.find((g) => g.key === s.key) ?? null : null, l = r.filter(
189
+ (g) => (g.kind === "field" || g.kind === "slot") && !ae(g)
190
+ ), m = l.length ? ge(e, l) : null, h = s ? xe(e, s) : "Duplicate works on one section at a time", x = n ? `${E(n)} · ${T(e, n)}` : l.length > 1 ? `${l.length} selected` : null;
191
+ return /* @__PURE__ */ p("div", { role: "menu", "aria-label": "Arrange", onKeyDown: Pe, className: "flex flex-col", children: [
192
+ x && /* @__PURE__ */ t("p", { className: $(P, "truncate px-2 pb-1 pt-0.5"), children: x }),
193
+ /* @__PURE__ */ t(
194
+ v,
195
+ {
196
+ icon: /* @__PURE__ */ t(X, {}),
197
+ hint: de(),
198
+ blocked: h,
199
+ "data-structure-action": "duplicate",
200
+ onPick: () => o(B(e, s), { toastNotes: !0 }),
201
+ children: "Duplicate"
202
+ }
203
+ ),
204
+ m && /* @__PURE__ */ t(
205
+ v,
206
+ {
207
+ icon: /* @__PURE__ */ t(J, {}),
208
+ blocked: m.ok ? null : m.reason,
209
+ "data-structure-action": "wrap",
210
+ onPick: () => o(m),
211
+ children: m.ok ? m.label.replace(/^Wrap \d+ fields?/, "Wrap") : "Wrap in a new section"
212
+ }
213
+ ),
214
+ n && /* @__PURE__ */ p(I, { children: [
215
+ /* @__PURE__ */ p(
216
+ v,
217
+ {
218
+ icon: /* @__PURE__ */ t(z, {}),
219
+ blocked: ye(e, n.key),
220
+ "data-structure-action": "unwrap",
221
+ onPick: () => o(ke(e, n.key), { toastNotes: !0 }),
222
+ children: [
223
+ "Unwrap: keep its fields, drop the ",
224
+ T(e, n)
225
+ ]
226
+ }
227
+ ),
228
+ /* @__PURE__ */ t(
229
+ v,
230
+ {
231
+ icon: /* @__PURE__ */ t(Q, {}),
232
+ blocked: K(e, n.key).length ? null : "Only sections, tabs, steps and their holders convert",
233
+ "data-structure-action": "convert",
234
+ onPick: () => i("convert"),
235
+ children: "Convert to…"
236
+ }
237
+ ),
238
+ /* @__PURE__ */ t(
239
+ v,
240
+ {
241
+ icon: /* @__PURE__ */ t(Z, {}),
242
+ blocked: j(n).length ? null : "Only sections, tabs and steps have these rules",
243
+ "data-structure-action": "rules",
244
+ onPick: () => i("rules"),
245
+ children: "Copy rules to other sections…"
246
+ }
247
+ ),
248
+ /* @__PURE__ */ t(
249
+ v,
250
+ {
251
+ icon: C(n) ? /* @__PURE__ */ t(ee, {}) : /* @__PURE__ */ t(te, {}),
252
+ "data-structure-action": "pin",
253
+ onPick: () => o(ve(e, n.key, !C(n))),
254
+ children: C(n) ? "Unpin" : "Pin in the editor (no dragging)"
255
+ }
256
+ )
257
+ ] }),
258
+ !n && l.length === 0 && /* @__PURE__ */ t("p", { className: $(P, "px-2 py-1"), children: "Select a section or fields to duplicate, wrap or convert." })
259
+ ] });
260
+ }
261
+ function S({ title: e, onBack: r }) {
262
+ return /* @__PURE__ */ p("div", { className: "flex items-center gap-1.5 px-1 pb-1.5", children: [
263
+ /* @__PURE__ */ t(
264
+ "button",
265
+ {
266
+ type: "button",
267
+ "aria-label": "Back",
268
+ onClick: r,
269
+ className: "inline-flex h-6 w-6 items-center justify-center rounded text-slate-500 hover:bg-muted hover:text-slate-900 dark:text-muted-foreground dark:hover:text-foreground",
270
+ children: /* @__PURE__ */ t(ne, { className: "h-3.5 w-3.5" })
271
+ }
272
+ ),
273
+ /* @__PURE__ */ t("p", { className: "min-w-0 flex-1 truncate text-[13px] font-semibold text-slate-900 dark:text-foreground", children: e })
274
+ ] });
275
+ }
276
+ const W = "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 disabled:pointer-events-none disabled:opacity-40";
277
+ function q({ notes: e }) {
278
+ return e.length === 0 ? null : /* @__PURE__ */ t("ul", { className: "mt-1 list-disc space-y-0.5 pl-4 text-[12px] leading-snug text-slate-600 dark:text-muted-foreground", children: e.map((r) => /* @__PURE__ */ t("li", { children: r }, r)) });
279
+ }
280
+ function Se({
281
+ bundle: e,
282
+ groupKey: r,
283
+ onBack: o,
284
+ run: i
285
+ }) {
286
+ const s = e.groups.find((l) => l.key === r), n = w(() => K(e, r), [e, r]);
287
+ return s ? /* @__PURE__ */ p("div", { "data-structure-convert": "", className: "flex flex-col", children: [
288
+ /* @__PURE__ */ t(S, { title: `Convert ${E(s)}`, onBack: o }),
289
+ /* @__PURE__ */ t("div", { className: "space-y-1.5", children: n.map((l) => /* @__PURE__ */ p("div", { "data-convert-choice": l.to, className: $(pe, "p-2.5"), children: [
290
+ /* @__PURE__ */ p("div", { className: "flex items-center gap-2", children: [
291
+ /* @__PURE__ */ t("p", { className: "min-w-0 flex-1 text-[12.5px] font-medium text-slate-900 dark:text-foreground", children: l.title }),
292
+ /* @__PURE__ */ t(
293
+ "button",
294
+ {
295
+ type: "button",
296
+ disabled: !l.plan.ok,
297
+ onClick: () => i(l.plan),
298
+ className: W,
299
+ children: "Convert"
300
+ }
301
+ )
302
+ ] }),
303
+ l.plan.ok ? /* @__PURE__ */ t(q, { notes: l.plan.notes }) : /* @__PURE__ */ t("p", { className: "mt-1 text-[12px] leading-snug text-amber-700 dark:text-amber-300", children: l.plan.reason })
304
+ ] }, l.to)) })
305
+ ] }) : /* @__PURE__ */ t(S, { title: "That section is no longer here", onBack: o });
306
+ }
307
+ const Ae = (e, r) => {
308
+ if (!V(e, r)) return "none: clears it";
309
+ try {
310
+ const o = JSON.parse(String(e[r])).length;
311
+ return r === "visible_when" ? `${o} condition${o === 1 ? "" : "s"}` : `${o} role${o === 1 ? "" : "s"}`;
312
+ } catch {
313
+ return "set";
314
+ }
315
+ }, M = "h-4 w-4 rounded border-slate-300 data-[state=checked]:border-nvr-cyan data-[state=checked]:bg-nvr-cyan data-[state=checked]:text-white dark:border-slate-600 [&_svg]:h-3 [&_svg]:w-3";
316
+ function Oe({
317
+ bundle: e,
318
+ groupKey: r,
319
+ onBack: o,
320
+ run: i
321
+ }) {
322
+ const s = e.groups.find((a) => a.key === r), n = s ? j(s) : [], [l, m] = O(() => {
323
+ const a = s ? n.filter((c) => V(s, c)) : [];
324
+ return a.length ? a : n;
325
+ }), h = w(() => me(e, r), [e, r]), [x, g] = O([]), k = w(
326
+ () => fe(e, r, x, l),
327
+ [e, r, x, l]
328
+ );
329
+ if (!s) return /* @__PURE__ */ t(S, { title: "That section is no longer here", onBack: o });
330
+ const d = (a, c) => a.includes(c) ? a.filter((f) => f !== c) : [...a, c], u = x.length === h.length && h.length > 0;
331
+ return /* @__PURE__ */ p("div", { "data-structure-rules": "", className: "flex flex-col", children: [
332
+ /* @__PURE__ */ t(S, { title: `Copy the rules of ${E(s)}`, onBack: o }),
333
+ /* @__PURE__ */ p("fieldset", { className: "m-0 min-w-0 border-0 p-0 px-1", children: [
334
+ /* @__PURE__ */ t("legend", { className: "pb-1 text-[12px] font-medium text-slate-700 dark:text-foreground", children: "Rules" }),
335
+ n.map((a) => (
336
+ // biome-ignore lint/a11y/noLabelWithoutControl: the Radix checkbox is the control
337
+ /* @__PURE__ */ p("label", { className: "flex items-center gap-2 py-0.5 text-[12.5px]", children: [
338
+ /* @__PURE__ */ t(
339
+ _,
340
+ {
341
+ checked: l.includes(a),
342
+ onCheckedChange: () => m((c) => d(c, a)),
343
+ className: M
344
+ }
345
+ ),
346
+ /* @__PURE__ */ t("span", { className: "min-w-0 flex-1 truncate text-slate-800 dark:text-foreground", children: he[a] }),
347
+ /* @__PURE__ */ t("span", { className: "shrink-0 text-[11.5px] text-slate-500 dark:text-muted-foreground", children: Ae(s, a) })
348
+ ] }, a)
349
+ ))
350
+ ] }),
351
+ /* @__PURE__ */ p("fieldset", { className: "m-0 mt-2 min-w-0 border-0 p-0 px-1", children: [
352
+ /* @__PURE__ */ p("div", { className: "flex items-center pb-1", children: [
353
+ /* @__PURE__ */ t("legend", { className: "flex-1 text-[12px] font-medium text-slate-700 dark:text-foreground", children: "Onto" }),
354
+ /* @__PURE__ */ t(
355
+ "button",
356
+ {
357
+ type: "button",
358
+ onClick: () => g(u ? [] : h.map((a) => a.key)),
359
+ className: "text-[12px] font-medium text-sky-700 hover:underline dark:text-nvr-cyan",
360
+ children: u ? "None" : "All"
361
+ }
362
+ )
363
+ ] }),
364
+ /* @__PURE__ */ p("div", { className: "max-h-[200px] overflow-y-auto", children: [
365
+ h.length === 0 && /* @__PURE__ */ t("p", { className: P, children: "No other sections on this form." }),
366
+ h.map((a) => (
367
+ // biome-ignore lint/a11y/noLabelWithoutControl: the Radix checkbox is the control
368
+ /* @__PURE__ */ p(
369
+ "label",
370
+ {
371
+ "data-rules-target": a.key,
372
+ className: "flex items-center gap-2 py-0.5 text-[12.5px]",
373
+ children: [
374
+ /* @__PURE__ */ t(
375
+ _,
376
+ {
377
+ checked: x.includes(a.key),
378
+ onCheckedChange: () => g((c) => d(c, a.key)),
379
+ className: M
380
+ }
381
+ ),
382
+ /* @__PURE__ */ t("span", { className: "min-w-0 flex-1 truncate text-slate-800 dark:text-foreground", children: E(a) }),
383
+ /* @__PURE__ */ t("span", { className: "shrink-0 text-[11.5px] text-slate-500 dark:text-muted-foreground", children: T(e, a) })
384
+ ]
385
+ },
386
+ a.key
387
+ )
388
+ ))
389
+ ] })
390
+ ] }),
391
+ /* @__PURE__ */ p("div", { className: "mt-2 border-t border-slate-100 px-1 pt-2 dark:border-border", children: [
392
+ k.ok ? /* @__PURE__ */ t(q, { notes: k.notes }) : x.length > 0 && /* @__PURE__ */ t("p", { className: P, children: k.reason }),
393
+ /* @__PURE__ */ t("div", { className: "mt-2 flex justify-end", children: /* @__PURE__ */ t(
394
+ "button",
395
+ {
396
+ type: "button",
397
+ disabled: !k.ok,
398
+ "data-rules-apply": "",
399
+ onClick: () => i(k),
400
+ className: W,
401
+ children: k.ok ? `Copy to ${k.ops.length}` : "Copy"
402
+ }
403
+ ) })
404
+ ] })
405
+ ] });
406
+ }
407
+ export {
408
+ Ge as ArrangeButton,
409
+ He as StructureActions,
410
+ Ie as openStructureMenu,
411
+ we as parseTargetKey,
412
+ qe as usePinMarks
413
+ };
@@ -0,0 +1,103 @@
1
+ import { jsxs as r, jsx as n } from "react/jsx-runtime";
2
+ import { useState as f, useMemo as h } from "react";
3
+ import { Popover as b, PopoverAnchor as g, PopoverContent as y } from "../ui/popover.js";
4
+ const k = (e) => `${e} unsaved ${e === 1 ? "change" : "changes"}`;
5
+ function w({
6
+ request: e,
7
+ count: l,
8
+ onSave: u,
9
+ onDiscard: m,
10
+ onKeep: d,
11
+ note: i,
12
+ canSave: p = !0
13
+ }) {
14
+ const [a, s] = f(!1), v = h(
15
+ () => ({ current: (e == null ? void 0 : e.anchor) ?? document.body }),
16
+ [e]
17
+ );
18
+ if (!e) return null;
19
+ const x = async () => {
20
+ s(!0);
21
+ try {
22
+ await u() ? e.go() : d();
23
+ } finally {
24
+ s(!1);
25
+ }
26
+ };
27
+ return /* @__PURE__ */ r(
28
+ b,
29
+ {
30
+ open: !0,
31
+ onOpenChange: (o) => {
32
+ !o && !a && d();
33
+ },
34
+ children: [
35
+ /* @__PURE__ */ n(g, { virtualRef: v }),
36
+ /* @__PURE__ */ r(
37
+ y,
38
+ {
39
+ align: "start",
40
+ className: "w-[300px] p-3",
41
+ "data-unsaved-confirm": "",
42
+ onOpenAutoFocus: (o) => {
43
+ var c;
44
+ o.preventDefault();
45
+ const t = o.currentTarget;
46
+ (c = (t == null ? void 0 : t.querySelector("[data-change-note-reason]")) ?? (t == null ? void 0 : t.querySelector('[data-unsaved-action="save"]'))) == null || c.focus();
47
+ },
48
+ children: [
49
+ /* @__PURE__ */ n("p", { className: "text-[13px] font-semibold text-slate-900 dark:text-foreground", children: k(l) }),
50
+ /* @__PURE__ */ r("p", { className: "mt-1 text-[12px] leading-snug text-slate-600 dark:text-muted-foreground", children: [
51
+ "Save them before you ",
52
+ e.what,
53
+ "? Discarded changes cannot be brought back."
54
+ ] }),
55
+ i && /* @__PURE__ */ n("div", { className: "mt-2", children: i }),
56
+ /* @__PURE__ */ r("div", { className: "mt-3 flex items-center justify-end gap-1.5", children: [
57
+ /* @__PURE__ */ n(
58
+ "button",
59
+ {
60
+ type: "button",
61
+ "data-unsaved-action": "keep",
62
+ onClick: d,
63
+ disabled: a,
64
+ className: "inline-flex h-7 items-center rounded-md px-2.5 text-[12px] font-medium text-slate-600 transition-colors hover:bg-muted hover:text-slate-900 disabled:pointer-events-none disabled:opacity-40 dark:text-muted-foreground dark:hover:text-foreground",
65
+ children: "Keep editing"
66
+ }
67
+ ),
68
+ /* @__PURE__ */ n(
69
+ "button",
70
+ {
71
+ type: "button",
72
+ "data-unsaved-action": "discard",
73
+ onClick: () => {
74
+ m(), e.go();
75
+ },
76
+ disabled: a,
77
+ className: "inline-flex h-7 items-center rounded-md border border-slate-200 px-2.5 text-[12px] font-medium text-red-700 transition-colors hover:bg-red-50 disabled:pointer-events-none disabled:opacity-40 dark:border-border dark:text-red-300 dark:hover:bg-red-500/10",
78
+ children: "Discard"
79
+ }
80
+ ),
81
+ /* @__PURE__ */ n(
82
+ "button",
83
+ {
84
+ type: "button",
85
+ "data-unsaved-action": "save",
86
+ onClick: () => void x(),
87
+ disabled: a || !p,
88
+ className: "inline-flex h-7 items-center rounded-md bg-nvr-cyan px-3 text-[12px] font-medium text-white transition-opacity hover:opacity-90 disabled:pointer-events-none disabled:opacity-60",
89
+ children: a ? "Saving…" : "Save"
90
+ }
91
+ )
92
+ ] })
93
+ ]
94
+ }
95
+ )
96
+ ]
97
+ }
98
+ );
99
+ }
100
+ export {
101
+ w as UnsavedConfirm,
102
+ k as unsavedText
103
+ };