@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,142 @@
1
+ import { HEADER_GROUP_KEY as k } from "../../../lib/layout-ops.js";
2
+ import { SUBTITLE_FIELD as d } from "../inspector/model.js";
3
+ const p = (e) => /^__[a-z][a-z0-9_-]*__$/.test(e) && e !== d;
4
+ function w(e) {
5
+ return !e.field.startsWith("__") && e.widget_id == null && e.group_key !== k;
6
+ }
7
+ function y(e, n, r) {
8
+ const a = e.key.split(".")[0], o = r.length === 1 ? r[0] : null, i = n.placements;
9
+ switch (a) {
10
+ case "group": {
11
+ if ((o == null ? void 0 : o.kind) === "group" && !o.key.startsWith("__")) return o;
12
+ const t = n.groups.find((s) => !s.key.startsWith("__"));
13
+ return t ? { kind: "group", key: t.key } : { none: "This form has no sections yet" };
14
+ }
15
+ case "slot":
16
+ case "pdf_button": {
17
+ if ((o == null ? void 0 : o.kind) === "slot" && p(o.field)) return o;
18
+ const t = i.find(
19
+ (s) => p(s.field) && (a === "slot" || s.field === "__pdf__")
20
+ );
21
+ return t ? { kind: "slot", field: t.field, group_key: t.group_key } : { none: a === "slot" ? "This form has no panels" : "This form has no PDF button" };
22
+ }
23
+ case "widget": {
24
+ const t = i.find((s) => s.widget_id != null);
25
+ return t ? { kind: "slot", field: t.field, group_key: t.group_key } : { none: "This form has no widgets" };
26
+ }
27
+ case "header": {
28
+ if ((o == null ? void 0 : o.kind) === "header" && o.field !== d) return o;
29
+ const t = i.find(
30
+ (s) => s.group_key === k && s.field !== d
31
+ );
32
+ return t ? { kind: "header", field: t.field } : { none: "This form has no header strip items" };
33
+ }
34
+ case "subtitle":
35
+ return i.some((t) => t.field === d) ? { kind: "header", field: d } : { none: "This form has no subtitle" };
36
+ default: {
37
+ if ((o == null ? void 0 : o.kind) === "field" && !o.field.startsWith("__")) return o;
38
+ const t = new Map(n.groups.map((l, u) => [l.key, u])), s = i.filter(w).sort(
39
+ (l, u) => (t.get(l.group_key ?? "") ?? 1e6) - (t.get(u.group_key ?? "") ?? 1e6) || l.sort - u.sort
40
+ )[0];
41
+ return s ? { kind: "field", field: s.field, group_key: s.group_key } : { none: "This form has no fields yet" };
42
+ }
43
+ }
44
+ }
45
+ const _ = () => new Promise(
46
+ (e) => typeof requestAnimationFrame == "function" ? requestAnimationFrame(() => e()) : setTimeout(e, 16)
47
+ );
48
+ async function f(e, n = 1500) {
49
+ const r = Date.now() + n;
50
+ for (; ; ) {
51
+ const a = e();
52
+ if (a) return a;
53
+ if (Date.now() > r) return null;
54
+ await _();
55
+ }
56
+ }
57
+ function c(e) {
58
+ var a;
59
+ (a = e.scrollIntoView) == null || a.call(e, { block: "center", behavior: "smooth" });
60
+ const n = {
61
+ outline: e.style.outline,
62
+ outlineOffset: e.style.outlineOffset,
63
+ borderRadius: e.style.borderRadius,
64
+ background: e.style.background
65
+ };
66
+ e.setAttribute("data-setting-found", ""), e.style.outline = "2px solid var(--nvr-cyan, #00ceff)", e.style.outlineOffset = "3px", e.style.borderRadius = e.style.borderRadius || "6px", e.style.background = "rgb(var(--nvr-cyan-rgb, 0 206 255) / 0.08)";
67
+ const r = e.matches('input, textarea, button, [role="switch"], [tabindex]') ? e : e.querySelector('input, textarea, [role="switch"], button, [tabindex]');
68
+ r == null || r.focus({ preventScroll: !0 }), setTimeout(() => {
69
+ e.removeAttribute("data-setting-found"), Object.assign(e.style, n);
70
+ }, 2600);
71
+ }
72
+ const m = (e) => `[data-setting="${e.replace(/["\\]/g, "\\$&")}"]`;
73
+ async function v(e, n) {
74
+ const r = n.root;
75
+ if (!r) return { ok: !1, message: "The editor is not open" };
76
+ const a = (i) => r.querySelector(`${i} ${m(e.key)}`);
77
+ if (e.home === "form_settings") {
78
+ n.openSettings();
79
+ let i = await f(() => a("[data-form-settings]"), 800);
80
+ if (!i) {
81
+ const t = r.querySelector(
82
+ '[data-form-settings] [aria-label="Clear search"]'
83
+ );
84
+ t && (t.click(), i = await f(() => a("[data-form-settings]"), 800));
85
+ }
86
+ return i ? (c(i), { ok: !0 }) : {
87
+ ok: !1,
88
+ message: `“${e.label}” is not offered for this kind of layout.`
89
+ };
90
+ }
91
+ if (e.home === "inspector") {
92
+ const i = y(e, n.bundle, n.selection);
93
+ if ("none" in i)
94
+ return {
95
+ ok: !1,
96
+ message: `${i.none}, so there is nothing to show “${e.label}” on.`
97
+ };
98
+ n.select(i), await _();
99
+ const t = "[data-editor-inspector]";
100
+ if (e.place && !S.has(e.place)) {
101
+ const l = await f(() => {
102
+ const u = [...r.querySelectorAll(`${t} [role="tab"]`)];
103
+ return u.length === 0 ? null : u.find((b) => {
104
+ var h;
105
+ const g = (h = b.textContent) == null ? void 0 : h.trim();
106
+ return g === e.place || e.place === "Grid" && g === "Table";
107
+ }) ?? "missing";
108
+ });
109
+ if (l === "missing" || l === null)
110
+ return {
111
+ ok: !1,
112
+ message: `“${e.label}” is on the ${e.place} tab, which only some fields have. Select such a field and open that tab.`
113
+ };
114
+ l.getAttribute("aria-selected") !== "true" && l.click();
115
+ }
116
+ const s = await f(() => a(t));
117
+ return s ? (c(s), { ok: !0 }) : {
118
+ ok: !1,
119
+ message: `“${e.label}” is in ${e.where}, but the selected item does not offer it.`
120
+ };
121
+ }
122
+ e.home === "add_panel" && n.openAddPanel();
123
+ const o = await f(() => r.querySelector(m(e.key)), 600);
124
+ return o ? (c(o), { ok: !0 }) : {
125
+ ok: !1,
126
+ message: e.home === "overview" ? `“${e.label}” is on the Layouts overview (${e.place}). Leave the editor with Layouts to get there.` : `“${e.label}” is in ${e.where}.`
127
+ };
128
+ }
129
+ const S = /* @__PURE__ */ new Set([
130
+ "Group",
131
+ "Slot",
132
+ "Widget",
133
+ "Header item",
134
+ "Subtitle",
135
+ "All tabs"
136
+ ]);
137
+ export {
138
+ c as flashSetting,
139
+ v as jumpToSetting,
140
+ y as targetFor,
141
+ f as waitFor
142
+ };
@@ -0,0 +1,118 @@
1
+ import w from "../parity-keys.json.js";
2
+ import { SECTIONS as b, SETTINGS as S } from "../settings/settings-registry.js";
3
+ const k = {
4
+ Group: "Section inspector",
5
+ Slot: "Panel inspector",
6
+ Widget: "Widget inspector",
7
+ "Header item": "Header strip inspector",
8
+ Subtitle: "Subtitle inspector"
9
+ }, _ = {
10
+ add_panel: "Add panel",
11
+ canvas: "Canvas",
12
+ overview: "Layouts overview"
13
+ };
14
+ function p(n, e) {
15
+ return n === "form_settings" ? `Form settings · ${e}` : n === "inspector" ? k[e] ?? (e === "All tabs" ? "Field inspector" : `Field inspector · ${e} tab`) : `${_[n] ?? n} · ${e}`;
16
+ }
17
+ let h = null;
18
+ function m() {
19
+ if (h) return h;
20
+ const n = new Map(b.map((t) => [t.id, t.title])), e = S.map((t) => {
21
+ const i = n.get(t.section) ?? t.section;
22
+ return {
23
+ key: t.key,
24
+ label: t.label,
25
+ effect: t.effect,
26
+ keywords: t.keywords,
27
+ home: "form_settings",
28
+ place: i,
29
+ where: p("form_settings", i),
30
+ types: t.types
31
+ };
32
+ }), a = new Set(e.map((t) => t.key));
33
+ for (const t of w) {
34
+ if (t.status === "retired" || !t.home || t.home === "form_settings" || a.has(t.key) || /no editor today/i.test(t.label)) continue;
35
+ const i = t.home, o = t.tab_or_section ?? "";
36
+ e.push({
37
+ key: t.key,
38
+ label: t.label,
39
+ home: i,
40
+ place: o,
41
+ where: p(i, o),
42
+ types: t.layout_types ?? []
43
+ }), a.add(t.key);
44
+ }
45
+ return h = e, e;
46
+ }
47
+ const W = new Set(
48
+ "a an and are be can could do does find for form get go have how i in is it its me my of on off or please set setting settings should switch that the there this to toggle turn want way what where which who why will with you your change make put let option options control enable disable".split(
49
+ " "
50
+ )
51
+ ), y = {
52
+ mandatory: "required",
53
+ compulsory: "required",
54
+ obligatory: "required",
55
+ optional: "required",
56
+ invisible: "hide",
57
+ hidden: "hide",
58
+ hiding: "hide",
59
+ readonly: "read",
60
+ editable: "read",
61
+ locked: "lock",
62
+ wide: "width",
63
+ size: "width",
64
+ title: "label",
65
+ name: "label",
66
+ rename: "label",
67
+ remark: "comment",
68
+ note: "comment",
69
+ tabs: "tab",
70
+ steps: "step",
71
+ wizard: "step",
72
+ print: "pdf"
73
+ };
74
+ function v(n) {
75
+ const e = n.toLowerCase().replace(/[^a-z0-9]/g, "");
76
+ return y[e] ? y[e] : e.length > 4 && e.endsWith("ies") ? `${e.slice(0, -3)}y` : e.length > 3 && e.endsWith("s") && !e.endsWith("ss") ? e.slice(0, -1) : e;
77
+ }
78
+ const l = (n) => n.split(/[\s._/:,;()“”"'?!·-]+/).map(v).filter(Boolean);
79
+ function N(n) {
80
+ return [...new Set(l(n).filter((e) => e.length > 1 && !W.has(e)))];
81
+ }
82
+ function H(n, e, a = 5) {
83
+ const t = N(n);
84
+ if (t.length === 0) return [];
85
+ const i = [];
86
+ for (const o of m()) {
87
+ if (e && o.types.length && !o.types.includes(e)) continue;
88
+ const s = l(o.label), g = [
89
+ ...s,
90
+ ...l(o.effect ?? ""),
91
+ ...l(o.keywords ?? ""),
92
+ ...l(o.key)
93
+ ], d = (r, c) => r.some((f) => f === c || c.length >= 4 && f.startsWith(c)), u = t.filter((r) => d(g, r)).length;
94
+ u !== 0 && i.push({
95
+ entry: o,
96
+ score: u / t.length,
97
+ labelHits: t.filter((r) => d(s, r)).length
98
+ });
99
+ }
100
+ return i.sort(
101
+ (o, s) => s.score - o.score || s.labelHits - o.labelHits || +(s.entry.home === "form_settings") - +(o.entry.home === "form_settings") || o.entry.label.length - s.entry.label.length
102
+ ), i.slice(0, a).map(({ entry: o, score: s }) => ({ entry: o, score: s }));
103
+ }
104
+ function q(n) {
105
+ return /^\s*(where|how (do|can) i|how to|is there (a|an) (setting|option|toggle|way))\b/i.test(
106
+ n
107
+ );
108
+ }
109
+ function E(n) {
110
+ return m().find((e) => e.key === n);
111
+ }
112
+ export {
113
+ N as contentWords,
114
+ q as isWhereQuestion,
115
+ H as searchSettings,
116
+ E as settingEntry,
117
+ m as settingsIndex
118
+ };
@@ -0,0 +1,101 @@
1
+ import { normalizedBundle as E, fieldZones as I, zoneItems as S, widthOf as W, keyOf as R, storedWidth as C, flagOn as D, GRID_WIDTHS as M } from "./field-zones.js";
2
+ const g = 12;
3
+ function x(e) {
4
+ const n = [];
5
+ let o = g;
6
+ return e.forEach((f, r) => {
7
+ o + f > g ? (n.push([r]), o = f) : (n[n.length - 1].push(r), o += f);
8
+ }), n;
9
+ }
10
+ function A(e) {
11
+ return x(e).filter((n) => n.reduce((o, f) => o + e[f], 0) < g).length;
12
+ }
13
+ function j(e, n = 3) {
14
+ const o = e.map((r, i) => i), f = [];
15
+ for (; o.length; ) {
16
+ const r = o.shift(), i = [r];
17
+ let s = g - e[r];
18
+ for (; s > 0; ) {
19
+ let u = -1;
20
+ if (o.slice(0, n).forEach((c, d) => {
21
+ e[c] <= s && (u < 0 || e[c] > e[o[u]]) && (u = d);
22
+ }), u < 0) break;
23
+ const [a] = o.splice(u, 1);
24
+ i.push(a), s -= e[a];
25
+ }
26
+ f.push(i);
27
+ }
28
+ return f;
29
+ }
30
+ function G(e) {
31
+ if (e.reduce((f, r) => f + r, 0) >= g) return null;
32
+ let n = null;
33
+ const o = (f, r, i) => {
34
+ if (!(i > g)) {
35
+ if (f === e.length) {
36
+ if (i !== g) return;
37
+ const s = r.reduce((a, c, d) => a + c - e[d], 0), u = Math.max(...r) - Math.min(...r);
38
+ (!n || s < n.grow || s === n.grow && u < n.spread) && (n = { ws: [...r], grow: s, spread: u });
39
+ return;
40
+ }
41
+ for (const s of [...M].reverse())
42
+ s >= e[f] && o(f + 1, [...r, s], i + s);
43
+ }
44
+ };
45
+ return o(0, [], 0), (n == null ? void 0 : n.ws) ?? null;
46
+ }
47
+ const w = (e) => !D(e, "hidden") && e.is_visible !== !1;
48
+ function T(e, n = {}) {
49
+ const o = E(e), f = n.widen ?? !0, r = I(o), i = n.zone === void 0 ? r : r.filter((a) => a.key === n.zone), s = [], u = [];
50
+ for (const a of i) {
51
+ const c = S(o, a.key), d = c.filter(w);
52
+ if (d.length === 0) continue;
53
+ const h = d.map(W), y = j(h, n.lookahead), b = [...h], m = [];
54
+ if (f)
55
+ for (const t of y) {
56
+ const l = G(t.map((p) => h[p]));
57
+ l && t.forEach((p, _) => {
58
+ l[_] !== h[p] && (b[p] = l[_], m.push({ field: d[p].field, from: h[p], to: l[_] }));
59
+ });
60
+ }
61
+ const B = y.flat().map((t) => d[t]), z = c.filter((t) => !w(t) && !H(c, t));
62
+ for (const t of B) {
63
+ z.push(t);
64
+ for (let l = c.indexOf(t) + 1; l < c.length && !w(c[l]); l++)
65
+ z.push(c[l]);
66
+ }
67
+ const k = [...c];
68
+ let O = 0;
69
+ z.forEach((t, l) => {
70
+ k[l] !== t && (k.splice(k.indexOf(t), 1), k.splice(l, 0, t), s.push({ op: "move", from: R(t), to_group_key: a.key, index: l }), O++);
71
+ });
72
+ for (const t of m) {
73
+ const l = d.find((p) => p.field === t.field);
74
+ s.push({ op: "update_placement", at: R(l), patch: { col_span: C(t.to) } });
75
+ }
76
+ if (O === 0 && m.length === 0) continue;
77
+ const v = y.flat().map((t) => b[t]);
78
+ u.push({
79
+ key: a.key,
80
+ label: a.label,
81
+ moved: O,
82
+ widened: m,
83
+ rowsBefore: x(h).length,
84
+ rowsAfter: x(v).length,
85
+ gapsBefore: A(h),
86
+ gapsAfter: A(v)
87
+ });
88
+ }
89
+ return { ops: s, zones: u, checked: i.length };
90
+ }
91
+ function H(e, n) {
92
+ for (let o = e.indexOf(n) - 1; o >= 0; o--) if (w(e[o])) return !0;
93
+ return !1;
94
+ }
95
+ export {
96
+ G as fillRow,
97
+ A as gapCount,
98
+ x as gridRows,
99
+ j as packRows,
100
+ T as planAutoArrange
101
+ };
@@ -0,0 +1,221 @@
1
+ import { jsxs as n, jsx as e } from "react/jsx-runtime";
2
+ import { Layers as q } from "lucide-react";
3
+ import { useState as i } from "react";
4
+ import { formatNumber as C, cn as O } from "../../../lib/utils.js";
5
+ import { Popover as B, PopoverContent as E } from "../../ui/popover.js";
6
+ import { effectText as v, labelText as h, tintCard as H } from "../panel-style.js";
7
+ import { Segmented as g, PickList as f } from "../settings/controls.js";
8
+ import { ToolButton as W } from "../toolbar-kit.js";
9
+ import { BulkRun as L } from "./BulkRun.js";
10
+ import { useFieldLabels as R } from "./field-labels.js";
11
+ import { MacrosPanel as $ } from "./MacrosPanel.js";
12
+ function ee({
13
+ collection: s,
14
+ layoutId: r,
15
+ dirty: d,
16
+ recorder: t
17
+ }) {
18
+ const [u, o] = i(!1), [l, m] = i("retire"), a = !!(t != null && t.recording);
19
+ return /* @__PURE__ */ n(B, { open: u, onOpenChange: o, children: [
20
+ /* @__PURE__ */ e(
21
+ W,
22
+ {
23
+ popover: !0,
24
+ onOpen: () => o(!0),
25
+ label: "Every form",
26
+ icon: /* @__PURE__ */ e(q, { className: "h-3.5 w-3.5" }),
27
+ tip: "Retire a field, make one change on every form, or replay a recorded macro",
28
+ hint: a ? `Recording a macro: ${(t == null ? void 0 : t.steps.length) ?? 0} steps` : "Retire a field, one change everywhere, macros",
29
+ dot: a,
30
+ data: { "data-bulk-button": "" },
31
+ trailing: a && /* @__PURE__ */ n(
32
+ "span",
33
+ {
34
+ "data-recording": "",
35
+ className: "ml-0.5 inline-flex items-center gap-1 rounded-full bg-rose-50 px-1.5 text-[11px] font-semibold text-rose-700 dark:bg-rose-500/15 dark:text-rose-300",
36
+ children: [
37
+ /* @__PURE__ */ e("span", { className: "h-1.5 w-1.5 animate-pulse rounded-full bg-rose-500" }),
38
+ (t == null ? void 0 : t.steps.length) ?? 0
39
+ ]
40
+ }
41
+ )
42
+ }
43
+ ),
44
+ /* @__PURE__ */ e(
45
+ E,
46
+ {
47
+ align: "end",
48
+ "data-bulk-panel": "",
49
+ className: "max-h-[min(78vh,680px)] w-[460px] max-w-[calc(100vw-24px)] overflow-y-auto overscroll-contain p-0",
50
+ children: u && /* @__PURE__ */ n("div", { className: "space-y-3 p-4", children: [
51
+ /* @__PURE__ */ n("div", { children: [
52
+ /* @__PURE__ */ e("h3", { className: "text-[14px] font-semibold text-slate-900 dark:text-foreground", children: "Every form of this collection" }),
53
+ /* @__PURE__ */ e("p", { className: v, children: "Previewed form by form first. Each form saves its own version, so History can put any one back." })
54
+ ] }),
55
+ /* @__PURE__ */ e(
56
+ g,
57
+ {
58
+ ariaLabel: "What to do",
59
+ value: l,
60
+ onChange: m,
61
+ options: [
62
+ { value: "retire", label: "Retire a field" },
63
+ { value: "change", label: "One change" },
64
+ { value: "macros", label: a ? "Macros · recording" : "Macros" }
65
+ ]
66
+ }
67
+ ),
68
+ l === "retire" && /* @__PURE__ */ e(A, { collection: s, layoutId: r, dirty: d }),
69
+ l === "change" && /* @__PURE__ */ e(j, { collection: s, layoutId: r, dirty: d }),
70
+ l === "macros" && /* @__PURE__ */ e(
71
+ $,
72
+ {
73
+ collection: s,
74
+ layoutId: r ?? null,
75
+ dirty: d,
76
+ recorder: t,
77
+ onRecordStart: () => o(!1)
78
+ }
79
+ )
80
+ ] })
81
+ }
82
+ )
83
+ ] });
84
+ }
85
+ function A({
86
+ collection: s,
87
+ layoutId: r,
88
+ dirty: d
89
+ }) {
90
+ const { labels: t, onForms: u } = R(s), [o, l] = i(null);
91
+ return /* @__PURE__ */ n("div", { "data-bulk-tab": "retire", className: "space-y-3", children: [
92
+ /* @__PURE__ */ e("p", { className: v, children: "Takes a field off every form at once: its placements, header, summaries, quick picker and defaults. The values stay in the database." }),
93
+ /* @__PURE__ */ n("div", { className: "space-y-1", children: [
94
+ /* @__PURE__ */ e("span", { className: h, children: "Field" }),
95
+ /* @__PURE__ */ e(
96
+ f,
97
+ {
98
+ ariaLabel: "Field to retire",
99
+ value: o,
100
+ options: u,
101
+ onChange: l,
102
+ placeholder: "Pick a field on the forms…",
103
+ emptyText: "No fields are placed on these forms",
104
+ className: "w-full"
105
+ }
106
+ )
107
+ ] }),
108
+ /* @__PURE__ */ e(
109
+ L,
110
+ {
111
+ collection: s,
112
+ action: o ? { kind: "retire", field: o } : null,
113
+ labels: t,
114
+ dirtyLayoutId: d ? r : null,
115
+ applyLabel: (a) => `Retire from ${a} form${a === 1 ? "" : "s"}`,
116
+ extra: (a) => a.values ? /* @__PURE__ */ e("div", { "data-bulk-values": "", className: O(H, "p-2.5 text-[12.5px]"), children: a.values.populated != null && a.values.total != null ? /* @__PURE__ */ n("span", { className: "text-slate-800 dark:text-foreground", children: [
117
+ /* @__PURE__ */ e("strong", { children: C(a.values.populated) }),
118
+ " of",
119
+ " ",
120
+ C(a.values.total),
121
+ " records still hold a value. Retiring keeps them; nobody sees or edits them on a form any more."
122
+ ] }) : /* @__PURE__ */ e("span", { className: v, children: a.values.note }) }) : null
123
+ }
124
+ )
125
+ ] });
126
+ }
127
+ const I = [
128
+ { value: "place_after", label: "Place it after another field" },
129
+ { value: "place_before", label: "Place it before another field" },
130
+ { value: "set_width", label: "Set its width" },
131
+ { value: "required", label: "Required or optional" },
132
+ { value: "readonly", label: "Read-only or editable" },
133
+ { value: "hidden", label: "Hidden or shown" },
134
+ { value: "remove", label: "Remove it from the forms" }
135
+ ], M = [
136
+ { value: "12", label: "Full" },
137
+ { value: "6", label: "½" },
138
+ { value: "4", label: "⅓" },
139
+ { value: "3", label: "¼" }
140
+ ];
141
+ function j({
142
+ collection: s,
143
+ layoutId: r,
144
+ dirty: d
145
+ }) {
146
+ const { labels: t, all: u, onForms: o } = R(s), [l, m] = i("place_after"), [a, F] = i(null), [p, _] = i(null), [y, P] = i("6"), [N, T] = i("on"), b = l === "place_after" || l === "place_before", x = l === "required" || l === "readonly" || l === "hidden", k = a ? b ? p && p !== a ? { type: l, field: a, anchor: p } : null : l === "set_width" ? { type: "set_width", field: a, width: Number(y) } : x ? { type: "set_flag", field: a, flag: l, on: N === "on" } : { type: "remove", field: a } : null, S = k ? { kind: "change", change: k } : null, w = {
147
+ required: ["Required", "Optional"],
148
+ readonly: ["Read-only", "Editable"],
149
+ hidden: ["Hidden", "Shown"]
150
+ };
151
+ return /* @__PURE__ */ n("div", { "data-bulk-tab": "change", className: "space-y-3", children: [
152
+ /* @__PURE__ */ n("div", { className: "space-y-1", children: [
153
+ /* @__PURE__ */ e("span", { className: h, children: "Change" }),
154
+ /* @__PURE__ */ e(
155
+ f,
156
+ {
157
+ ariaLabel: "Change",
158
+ value: l,
159
+ options: I,
160
+ onChange: (c) => c && m(c),
161
+ className: "w-full"
162
+ }
163
+ )
164
+ ] }),
165
+ /* @__PURE__ */ n("div", { className: "space-y-1", children: [
166
+ /* @__PURE__ */ e("span", { className: h, children: "Field" }),
167
+ /* @__PURE__ */ e(
168
+ f,
169
+ {
170
+ ariaLabel: "Field",
171
+ value: a,
172
+ options: b ? u : o,
173
+ onChange: F,
174
+ placeholder: "Pick a field…",
175
+ className: "w-full"
176
+ }
177
+ )
178
+ ] }),
179
+ b && /* @__PURE__ */ n("div", { className: "space-y-1", children: [
180
+ /* @__PURE__ */ e("span", { className: h, children: l === "place_after" ? "After" : "Before" }),
181
+ /* @__PURE__ */ e(
182
+ f,
183
+ {
184
+ ariaLabel: "Next to field",
185
+ value: p,
186
+ options: o.filter((c) => c.value !== a),
187
+ onChange: _,
188
+ placeholder: "Pick the field it goes next to…",
189
+ className: "w-full"
190
+ }
191
+ ),
192
+ /* @__PURE__ */ e("p", { className: v, children: "Forms without this field are skipped and listed." })
193
+ ] }),
194
+ l === "set_width" && /* @__PURE__ */ e(g, { ariaLabel: "Width", value: y, onChange: P, options: M }),
195
+ x && /* @__PURE__ */ e(
196
+ g,
197
+ {
198
+ ariaLabel: "Set to",
199
+ value: N,
200
+ onChange: T,
201
+ options: [
202
+ { value: "on", label: w[l][0] },
203
+ { value: "off", label: w[l][1] }
204
+ ]
205
+ }
206
+ ),
207
+ /* @__PURE__ */ e(
208
+ L,
209
+ {
210
+ collection: s,
211
+ action: S,
212
+ labels: t,
213
+ dirtyLayoutId: d ? r : null,
214
+ applyLabel: (c) => `Apply to ${c} form${c === 1 ? "" : "s"}`
215
+ }
216
+ )
217
+ ] });
218
+ }
219
+ export {
220
+ ee as BulkChangesButton
221
+ };