@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,7 +1,7 @@
1
1
  var j = Object.defineProperty;
2
- var L = (t, e, o) => e in t ? j(t, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[e] = o;
3
- var x = (t, e, o) => L(t, typeof e != "symbol" ? e + "" : e, o);
4
- const P = [
2
+ var I = (t, e, r) => e in t ? j(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
3
+ var x = (t, e, r) => I(t, typeof e != "symbol" ? e + "" : e, r);
4
+ const R = [
5
5
  "label_override",
6
6
  "is_visible",
7
7
  "default_expanded",
@@ -13,7 +13,7 @@ const P = [
13
13
  "input_bindings",
14
14
  "widget_id",
15
15
  "show_approval_chain"
16
- ], Y = [
16
+ ], W = 4e3, L = [
17
17
  "label",
18
18
  "type",
19
19
  "icon",
@@ -30,8 +30,10 @@ const P = [
30
30
  "visible_when",
31
31
  "hidden_for_roles",
32
32
  "locked_for_roles",
33
- "read_width"
34
- ], z = [
33
+ "read_width",
34
+ "editor_note",
35
+ "i18n"
36
+ ], Y = [
35
37
  "name",
36
38
  "slug",
37
39
  "create_label",
@@ -79,18 +81,19 @@ const P = [
79
81
  "quick_picker",
80
82
  "sheet_width",
81
83
  "header_fields",
82
- "hide_empty"
83
- ], m = ["section", "tab", "metadata", "container", "content"], d = "__ungrouped__", C = "__header__", F = [
84
+ "hide_empty",
85
+ "change_note"
86
+ ], m = ["section", "tab", "metadata", "container", "content"], d = "__ungrouped__", z = "__header__", C = [
84
87
  "__apply_values__",
85
88
  "__create_with_defaults__"
86
- ], I = [
89
+ ], D = [
87
90
  "__pipeline__",
88
91
  "__tasks__",
89
92
  "__comments__",
90
93
  "__addendums__",
91
94
  "__referenced_by__",
92
95
  "__related_records__"
93
- ], U = /^__ext_[a-z][a-z0-9-]{1,60}__$/, G = ["__ungrouped_pos__"], D = /* @__PURE__ */ new Map([
96
+ ], G = /^__ext_[a-z][a-z0-9-]{1,60}__$/, M = ["__ungrouped_pos__"], F = /* @__PURE__ */ new Map([
94
97
  [d, 1],
95
98
  ["__pipeline__", 2],
96
99
  ["__tasks__", 3],
@@ -100,18 +103,18 @@ const P = [
100
103
  ["__addendums__", 7],
101
104
  ["__referenced_by__", 8],
102
105
  ["__related_records__", 9]
103
- ]), R = (t) => D.get(t) ?? (U.test(t) ? 8 : 0);
104
- class M extends Error {
105
- constructor(o, s) {
106
- super(o);
106
+ ]), P = (t) => F.get(t) ?? (G.test(t) ? 8 : 0);
107
+ class N extends Error {
108
+ constructor(r, s) {
109
+ super(r);
107
110
  x(this, "op_index");
108
111
  this.name = "LayoutOpError", this.op_index = s;
109
112
  }
110
113
  }
111
114
  function f(t) {
112
- return t.group_key !== null ? !1 : I.includes(t.field) || t.field === "__owners__" || t.field === "__pdf__" || U.test(t.field);
115
+ return t.group_key !== null ? !1 : D.includes(t.field) || t.field === "__owners__" || t.field === "__pdf__" || G.test(t.field);
113
116
  }
114
- function H(t, e) {
117
+ function X(t, e) {
115
118
  return {
116
119
  field: t,
117
120
  group_key: e,
@@ -129,11 +132,11 @@ function H(t, e) {
129
132
  show_approval_chain: !1
130
133
  };
131
134
  }
132
- function K(t, e, o, s) {
135
+ function H(t, e, r, s) {
133
136
  return {
134
137
  key: t,
135
138
  label: e,
136
- type: o,
139
+ type: r,
137
140
  parent_key: s,
138
141
  sort: 0,
139
142
  icon: null,
@@ -154,151 +157,151 @@ function K(t, e, o, s) {
154
157
  };
155
158
  }
156
159
  const g = (t, e) => t < e ? -1 : t > e ? 1 : 0, h = (t, e) => (t.id ?? Number.MAX_SAFE_INTEGER) - (e.id ?? Number.MAX_SAFE_INTEGER);
157
- function V(t) {
160
+ function K(t) {
158
161
  return {
159
162
  ...t,
160
163
  groups: [...t.groups].sort(
161
- (e, o) => g(e.parent_key ?? "", o.parent_key ?? "") || e.sort - o.sort || h(e, o) || g(e.key, o.key)
164
+ (e, r) => g(e.parent_key ?? "", r.parent_key ?? "") || e.sort - r.sort || h(e, r) || g(e.key, r.key)
162
165
  ),
163
166
  placements: [...t.placements].sort(
164
- (e, o) => g(e.group_key ?? "", o.group_key ?? "") || e.sort - o.sort || h(e, o) || g(e.field, o.field)
167
+ (e, r) => g(e.group_key ?? "", r.group_key ?? "") || e.sort - r.sort || h(e, r) || g(e.field, r.field)
165
168
  )
166
169
  };
167
170
  }
168
171
  function p(t, e) {
169
- return t.placements.map((o, s) => ({ p: o, i: s })).filter(({ p: o }) => o.group_key === e && !f(o)).sort((o, s) => o.p.sort - s.p.sort || h(o.p, s.p) || o.i - s.i).map(({ p: o }) => o);
172
+ return t.placements.map((r, s) => ({ p: r, i: s })).filter(({ p: r }) => r.group_key === e && !f(r)).sort((r, s) => r.p.sort - s.p.sort || h(r.p, s.p) || r.i - s.i).map(({ p: r }) => r);
170
173
  }
171
174
  function u(t, e) {
172
- const o = [];
173
- return t.groups.forEach((s, _) => {
174
- s.parent_key === e && o.push({ m: s, tie: R(s.key), i: _ });
175
- }), e === null && t.placements.forEach((s, _) => {
176
- f(s) && o.push({ m: s, tie: R(s.field), i: t.groups.length + _ });
177
- }), o.sort((s, _) => s.m.sort - _.m.sort || s.tie - _.tie || h(s.m, _.m) || s.i - _.i).map((s) => s.m);
175
+ const r = [];
176
+ return t.groups.forEach((s, l) => {
177
+ s.parent_key === e && r.push({ m: s, tie: P(s.key), i: l });
178
+ }), e === null && t.placements.forEach((s, l) => {
179
+ f(s) && r.push({ m: s, tie: P(s.field), i: t.groups.length + l });
180
+ }), r.sort((s, l) => s.m.sort - l.m.sort || s.tie - l.tie || h(s.m, l.m) || s.i - l.i).map((s) => s.m);
178
181
  }
179
182
  function c(t) {
180
- t.forEach((e, o) => {
181
- e.sort = o;
183
+ t.forEach((e, r) => {
184
+ e.sort = r;
182
185
  });
183
186
  }
184
- function X(t) {
187
+ function V(t) {
185
188
  const e = /* @__PURE__ */ new Set();
186
189
  for (const s of t.placements) f(s) || e.add(s.group_key);
187
190
  for (const s of e) c(p(t, s));
188
- const o = /* @__PURE__ */ new Set([null]);
189
- for (const s of t.groups) o.add(s.parent_key);
190
- for (const s of o) c(u(t, s));
191
+ const r = /* @__PURE__ */ new Set([null]);
192
+ for (const s of t.groups) r.add(s.parent_key);
193
+ for (const s of r) c(u(t, s));
191
194
  }
192
- function W(t, e) {
193
- const o = {
195
+ function J(t, e) {
196
+ const r = {
194
197
  layout: { ...t.layout },
195
198
  groups: t.groups.map((s) => ({ ...s })),
196
199
  placements: t.placements.map((s) => ({ ...s }))
197
200
  };
198
- if (!Array.isArray(e)) throw new M("ops must be an array", 0);
199
- return e.forEach((s, _) => {
200
- B(o, s, _), X(o);
201
- }), V({ ...o, rev: t.rev });
201
+ if (!Array.isArray(e)) throw new N("ops must be an array", 0);
202
+ return e.forEach((s, l) => {
203
+ B(r, s, l), V(r);
204
+ }), K({ ...r, rev: t.rev });
202
205
  }
203
- function B(t, e, o) {
206
+ function B(t, e, r) {
204
207
  const s = (n) => {
205
- throw new M(n, o);
208
+ throw new N(n, r);
206
209
  };
207
210
  (!e || typeof e != "object") && s("Each op must be an object");
208
- const _ = (n, r, i) => {
211
+ const l = (n, o, i) => {
209
212
  (typeof i != "number" || !Number.isFinite(i)) && s("index must be a number");
210
- const l = Math.max(0, Math.min(n.length, Math.floor(i)));
211
- return [...n.slice(0, l), r, ...n.slice(l)];
212
- }, y = (n, r) => {
213
+ const _ = Math.max(0, Math.min(n.length, Math.floor(i)));
214
+ return [...n.slice(0, _), o, ...n.slice(_)];
215
+ }, y = (n, o) => {
213
216
  if (n == null) return {};
214
217
  (typeof n != "object" || Array.isArray(n)) && s("patch must be an object");
215
218
  for (const i of Object.keys(n))
216
- r.includes(i) || s(`Unknown setting "${i}"`);
219
+ o.includes(i) || s(`Unknown setting "${i}"`);
217
220
  return n;
218
221
  }, A = (n) => {
219
- const r = y(n, Y);
220
- return r.type !== void 0 && !m.includes(r.type) && s(`Group type must be one of ${m.join(", ")}`), r.read_width != null && !["full", "half", "third"].includes(r.read_width) && s("read_width must be 'full', 'half', 'third' or null"), r;
222
+ const o = y(n, L);
223
+ return o.type !== void 0 && !m.includes(o.type) && s(`Group type must be one of ${m.join(", ")}`), o.read_width != null && !["full", "half", "third"].includes(o.read_width) && s("read_width must be 'full', 'half', 'third' or null"), o.editor_note != null && (typeof o.editor_note != "string" || o.editor_note.length > 4e3) && s("A note must be text of at most 4000 characters"), o;
221
224
  }, k = (n) => {
222
225
  (!n || typeof n.field != "string") && s("A placement needs a field");
223
- const r = n;
224
- G.includes(r.field) && s(`"${r.field}" is a reserved name`);
226
+ const o = n;
227
+ M.includes(o.field) && s(`"${o.field}" is a reserved name`);
225
228
  const i = t.placements.find(
226
- (l) => l.field === r.field && l.group_key === (r.group_key ?? null)
229
+ (_) => _.field === o.field && _.group_key === (o.group_key ?? null)
227
230
  );
228
- return i || s(`"${r.field}" is not placed in ${r.group_key ?? "Ungrouped"}`), i;
231
+ return i || s(`"${o.field}" is not placed in ${o.group_key ?? "Ungrouped"}`), i;
229
232
  }, b = (n) => {
230
233
  n === d && s("The Ungrouped zone can only be moved");
231
- const r = t.groups.find((i) => i.key === n);
232
- return r || s(`No group "${String(n)}"`), r;
234
+ const o = t.groups.find((i) => i.key === n);
235
+ return o || s(`No group "${String(n)}"`), o;
233
236
  }, O = (n) => {
234
- if (n === null || n === C || t.layout.layout_type === "table" && F.includes(n)) return;
235
- const r = t.groups.find((i) => i.key === n);
236
- (!r || r.key === d) && s(`No group "${n}"`), r.type === "container" && s("Fields go in the tabs of a container"), r.type === "content" && s("A text block holds text, not fields");
237
- }, S = (n, r) => {
237
+ if (n === null || n === z || t.layout.layout_type === "table" && C.includes(n)) return;
238
+ const o = t.groups.find((i) => i.key === n);
239
+ (!o || o.key === d) && s(`No group "${n}"`), o.type === "container" && s("Fields go in the tabs of a container"), o.type === "content" && s("A text block holds text, not fields");
240
+ }, T = (n, o) => {
238
241
  if (n === null) return;
239
- const i = t.groups.find((l) => l.key === n);
240
- (i == null ? void 0 : i.type) !== "container" && s(`"${n}" is not a container`), r !== "tab" && s("Only tabs go inside a container");
241
- }, $ = (n, r) => {
242
- const i = f(n) ? u(t, null).filter((l) => l !== n) : p(t, n.group_key).filter((l) => l !== n);
243
- c(_(i, n, r));
242
+ const i = t.groups.find((_) => _.key === n);
243
+ (i == null ? void 0 : i.type) !== "container" && s(`"${n}" is not a container`), o !== "tab" && s("Only tabs go inside a container");
244
+ }, S = (n, o) => {
245
+ const i = f(n) ? u(t, null).filter((_) => _ !== n) : p(t, n.group_key).filter((_) => _ !== n);
246
+ c(l(i, n, o));
244
247
  };
245
248
  switch (e.op) {
246
249
  case "place": {
247
- (typeof e.field != "string" || !e.field) && s("place needs a field"), G.includes(e.field) && s(`"${e.field}" is a reserved name`);
250
+ (typeof e.field != "string" || !e.field) && s("place needs a field"), M.includes(e.field) && s(`"${e.field}" is a reserved name`);
248
251
  const n = e.group_key ?? null;
249
252
  O(n), t.placements.some((i) => i.field === e.field && i.group_key === n) && s(`"${e.field}" is already in ${n ?? "Ungrouped"}`);
250
- const r = {
251
- ...H(e.field, n),
252
- ...y(e.patch, P)
253
+ const o = {
254
+ ...X(e.field, n),
255
+ ...y(e.patch, R)
253
256
  };
254
- t.placements.push(r), $(r, e.index);
257
+ t.placements.push(o), S(o, e.index);
255
258
  return;
256
259
  }
257
260
  case "move": {
258
- const n = k(e.from), r = e.to_group_key ?? null;
259
- r !== n.group_key && (O(r), t.placements.some((i) => i.field === n.field && i.group_key === r) && s(`"${n.field}" is already in ${r ?? "Ungrouped"}`), n.group_key = r), $(n, e.index);
261
+ const n = k(e.from), o = e.to_group_key ?? null;
262
+ o !== n.group_key && (O(o), t.placements.some((i) => i.field === n.field && i.group_key === o) && s(`"${n.field}" is already in ${o ?? "Ungrouped"}`), n.group_key = o), S(n, e.index);
260
263
  return;
261
264
  }
262
265
  case "update_placement": {
263
266
  const n = k(e.at);
264
- Object.assign(n, y(e.patch, P));
267
+ Object.assign(n, y(e.patch, R));
265
268
  return;
266
269
  }
267
270
  case "remove": {
268
271
  const n = k(e.at);
269
- t.placements = t.placements.filter((r) => r !== n);
272
+ t.placements = t.placements.filter((o) => o !== n);
270
273
  return;
271
274
  }
272
275
  case "group_create": {
273
276
  (typeof e.key != "string" || !e.key.trim()) && s("A group needs a key"), e.key.startsWith("__") && s("Group keys starting with __ are reserved"), t.groups.some((v) => v.key === e.key) && s(`A group "${e.key}" already exists`), typeof e.label != "string" && s("A group needs a label");
274
- const n = A(e.patch), r = n.type ?? e.group_type;
275
- m.includes(r) || s(`Group type must be one of ${m.join(", ")}`);
277
+ const n = A(e.patch), o = n.type ?? e.group_type;
278
+ m.includes(o) || s(`Group type must be one of ${m.join(", ")}`);
276
279
  const i = e.parent_key ?? null;
277
- S(i, r);
278
- const l = { ...K(e.key, e.label, r, i), ...n }, w = u(t, i);
279
- t.groups.push(l), c(_(w, l, e.index));
280
+ T(i, o);
281
+ const _ = { ...H(e.key, e.label, o, i), ...n }, w = u(t, i);
282
+ t.groups.push(_), c(l(w, _, e.index));
280
283
  return;
281
284
  }
282
285
  case "group_update": {
283
- const n = b(e.key), r = A(e.patch);
284
- r.type !== void 0 && r.type !== n.type && (n.parent_key !== null && r.type !== "tab" && s("Only tabs go inside a container"), n.type === "container" && t.groups.some((i) => i.parent_key === n.key) && s("Move the tabs out of this container first"), (r.type === "container" || r.type === "content") && p(t, n.key).length && s("Move the fields out of this section first")), Object.assign(n, r);
286
+ const n = b(e.key), o = A(e.patch);
287
+ o.type !== void 0 && o.type !== n.type && (n.parent_key !== null && o.type !== "tab" && s("Only tabs go inside a container"), n.type === "container" && t.groups.some((i) => i.parent_key === n.key) && s("Move the tabs out of this container first"), (o.type === "container" || o.type === "content") && p(t, n.key).length && s("Move the fields out of this section first")), Object.assign(n, o);
285
288
  return;
286
289
  }
287
290
  case "group_move": {
288
291
  const n = e.parent_key ?? null;
289
- let r;
292
+ let o;
290
293
  if (e.key === d || f({ field: e.key, group_key: null })) {
291
294
  n !== null && s("This stays at the top level of the form");
292
- const i = e.key === d ? t.groups.find((l) => l.key === d) : t.placements.find((l) => l.field === e.key && l.group_key === null);
293
- i || s(`"${e.key}" is not on this form`), r = i;
295
+ const i = e.key === d ? t.groups.find((_) => _.key === d) : t.placements.find((_) => _.field === e.key && _.group_key === null);
296
+ i || s(`"${e.key}" is not on this form`), o = i;
294
297
  } else {
295
298
  const i = b(e.key);
296
- S(n, i.type), i.parent_key = n, r = i;
299
+ T(n, i.type), i.parent_key = n, o = i;
297
300
  }
298
301
  c(
299
- _(
300
- u(t, n).filter((i) => i !== r),
301
- r,
302
+ l(
303
+ u(t, n).filter((i) => i !== o),
304
+ o,
302
305
  e.index
303
306
  )
304
307
  );
@@ -307,22 +310,22 @@ function B(t, e, o) {
307
310
  case "group_remove": {
308
311
  const n = b(e.key);
309
312
  e.placements !== "ungroup" && e.placements !== "delete" && s("placements must be 'ungroup' or 'delete'");
310
- const r = u(t, n.parent_key), i = u(t, n.key);
313
+ const o = u(t, n.parent_key), i = u(t, n.key);
311
314
  for (const a of i) a.parent_key = n.parent_key;
312
- const l = r.indexOf(n);
313
- c([...r.slice(0, l), ...i, ...r.slice(l + 1)]), t.groups = t.groups.filter((a) => a !== n);
315
+ const _ = o.indexOf(n);
316
+ c([...o.slice(0, _), ...i, ...o.slice(_ + 1)]), t.groups = t.groups.filter((a) => a !== n);
314
317
  const w = p(t, n.key);
315
318
  if (t.placements = t.placements.filter((a) => a.group_key !== n.key), e.placements === "delete") return;
316
- const v = p(t, null), N = u(t, null), E = w.filter(
317
- (a) => !t.placements.some((T) => T.field === a.field && T.group_key === null)
319
+ const v = p(t, null), U = u(t, null), E = w.filter(
320
+ (a) => !t.placements.some(($) => $.field === a.field && $.group_key === null)
318
321
  );
319
322
  for (const a of E)
320
323
  a.group_key = null, t.placements.push(a);
321
- c([...v, ...E.filter((a) => !f(a))]), c([...N, ...E.filter((a) => f(a))]);
324
+ c([...v, ...E.filter((a) => !f(a))]), c([...U, ...E.filter((a) => f(a))]);
322
325
  return;
323
326
  }
324
327
  case "layout_update": {
325
- Object.assign(t.layout, y(e.patch, z));
328
+ Object.assign(t.layout, y(e.patch, Y));
326
329
  return;
327
330
  }
328
331
  default:
@@ -330,19 +333,20 @@ function B(t, e, o) {
330
333
  }
331
334
  }
332
335
  export {
333
- I as CANVAS_SLOT_KEYS,
334
- Y as GROUP_PATCH_KEYS,
336
+ D as CANVAS_SLOT_KEYS,
337
+ W as EDITOR_NOTE_MAX,
338
+ L as GROUP_PATCH_KEYS,
335
339
  m as GROUP_TYPES,
336
- C as HEADER_GROUP_KEY,
337
- z as LAYOUT_PATCH_KEYS,
338
- M as LayoutOpError,
339
- P as PLACEMENT_PATCH_KEYS,
340
- G as RESERVED_FIELDS,
341
- F as TABLE_FORM_GROUP_KEYS,
340
+ z as HEADER_GROUP_KEY,
341
+ Y as LAYOUT_PATCH_KEYS,
342
+ N as LayoutOpError,
343
+ R as PLACEMENT_PATCH_KEYS,
344
+ M as RESERVED_FIELDS,
345
+ C as TABLE_FORM_GROUP_KEYS,
342
346
  d as UNGROUPED_KEY,
343
- W as applyLayoutOps,
347
+ J as applyLayoutOps,
344
348
  f as isCanvasSlot,
345
- K as newGroup,
346
- H as newPlacement,
347
- V as sortBundleRows
349
+ H as newGroup,
350
+ X as newPlacement,
351
+ K as sortBundleRows
348
352
  };
@@ -1,4 +1,4 @@
1
- const r = "••••••", c = /* @__PURE__ */ new Set([
1
+ const a = "••••••", f = /* @__PURE__ */ new Set([
2
2
  "button",
3
3
  "submit",
4
4
  "reset",
@@ -9,54 +9,80 @@ const r = "••••••", c = /* @__PURE__ */ new Set([
9
9
  "image",
10
10
  "hidden"
11
11
  ]);
12
- function i(n) {
13
- for (const t of Array.from(n.querySelectorAll("input"))) {
14
- const e = t;
15
- if (c.has((e.type || "text").toLowerCase())) continue;
16
- const o = e.value !== "";
17
- e.value = o ? r : "", e.setAttribute("value", o ? r : "");
12
+ function u(e) {
13
+ for (const t of Array.from(e.querySelectorAll("input"))) {
14
+ const n = t;
15
+ if (f.has((n.type || "text").toLowerCase())) continue;
16
+ const r = n.value !== "";
17
+ n.value = r ? a : "", n.setAttribute("value", r ? a : "");
18
18
  }
19
- for (const t of Array.from(n.querySelectorAll("textarea"))) {
20
- const e = t, o = e.value !== "";
21
- e.value = o ? r : "", e.textContent = o ? r : "";
19
+ for (const t of Array.from(e.querySelectorAll("textarea"))) {
20
+ const n = t, r = n.value !== "";
21
+ n.value = r ? a : "", n.textContent = r ? a : "";
22
22
  }
23
- for (const t of Array.from(n.querySelectorAll("select"))) {
24
- const e = t;
25
- for (const o of Array.from(e.options)) o.textContent = r;
23
+ for (const t of Array.from(e.querySelectorAll("select"))) {
24
+ const n = t;
25
+ for (const r of Array.from(n.options)) r.textContent = a;
26
26
  }
27
27
  for (const t of Array.from(
28
- n.querySelectorAll('[contenteditable=""], [contenteditable="true"]')
28
+ e.querySelectorAll('[contenteditable=""], [contenteditable="true"]')
29
29
  ))
30
- t.textContent = t.textContent ? r : "";
31
- for (const t of Array.from(n.querySelectorAll(".nvr-no-record")))
30
+ t.textContent = t.textContent ? a : "";
31
+ for (const t of Array.from(e.querySelectorAll(".nvr-no-record")))
32
32
  t.style.visibility = "hidden";
33
33
  }
34
34
  async function s() {
35
35
  try {
36
- const n = await import("html2canvas");
37
- return n.default ?? n;
36
+ const e = await import("html2canvas");
37
+ return e.default ?? e;
38
38
  } catch {
39
39
  return null;
40
40
  }
41
41
  }
42
- async function u(n = {}) {
42
+ async function m(e = {}) {
43
43
  if (typeof document > "u") return null;
44
44
  const t = await s();
45
45
  if (!t) return null;
46
- const e = n.ignoreAttr ?? "data-report-problem";
46
+ const n = e.ignoreAttr ?? "data-report-problem";
47
47
  try {
48
- const o = await t(document.body, {
48
+ const r = await t(document.body, {
49
49
  logging: !1,
50
- scale: Math.min(1, (n.maxWidth ?? 1280) / Math.max(1, window.innerWidth)),
51
- ignoreElements: (a) => a.hasAttribute(e),
52
- onclone: (a) => i(a)
53
- }), l = o.toDataURL("image/jpeg", 0.7);
54
- return l.length > 24e5 ? o.toDataURL("image/jpeg", 0.4) : l;
50
+ scale: Math.min(1, (e.maxWidth ?? 1280) / Math.max(1, window.innerWidth)),
51
+ ignoreElements: (l) => l.hasAttribute(n),
52
+ onclone: (l) => u(l)
53
+ }), i = r.toDataURL("image/jpeg", 0.7);
54
+ return i.length > 24e5 ? r.toDataURL("image/jpeg", 0.4) : i;
55
+ } catch {
56
+ return null;
57
+ }
58
+ }
59
+ async function d(e, t = {}) {
60
+ if (typeof document > "u") return null;
61
+ const n = await s();
62
+ if (!n) return null;
63
+ const r = Math.max(1, e.scrollWidth || e.clientWidth);
64
+ try {
65
+ const i = await n(e, {
66
+ logging: !1,
67
+ backgroundColor: null,
68
+ scale: Math.min(1, (t.maxWidth ?? 1200) / r),
69
+ ignoreElements: (o) => {
70
+ var c;
71
+ return !!t.ignoreSelector && ((c = o.matches) == null ? void 0 : c.call(o, t.ignoreSelector));
72
+ },
73
+ onclone: (o) => u(o)
74
+ }), l = t.maxChars ?? 19e5;
75
+ for (const o of [0.7, 0.5, 0.35]) {
76
+ const c = i.toDataURL("image/jpeg", o);
77
+ if (c.length <= l) return c;
78
+ }
79
+ return null;
55
80
  } catch {
56
81
  return null;
57
82
  }
58
83
  }
59
84
  export {
60
- u as captureMaskedScreenshot,
61
- i as maskInputsIn
85
+ d as captureElementImage,
86
+ m as captureMaskedScreenshot,
87
+ u as maskInputsIn
62
88
  };
@@ -0,0 +1,34 @@
1
+ function s(e) {
2
+ if (e == null || e === "") return [];
3
+ try {
4
+ const u = typeof e == "string" ? JSON.parse(e) : e;
5
+ return Array.isArray(u) ? u.filter((r) => r && typeof r == "object") : [];
6
+ } catch {
7
+ return [];
8
+ }
9
+ }
10
+ function c(e, u) {
11
+ const r = s(e);
12
+ return r.length === 0 ? !0 : r.every((n) => {
13
+ if (!(n != null && n.field)) return !0;
14
+ const t = u[n.field], i = n.value;
15
+ switch (n.op ?? "eq") {
16
+ case "eq":
17
+ return String(t ?? "") === String(i ?? "");
18
+ case "neq":
19
+ return String(t ?? "") !== String(i ?? "");
20
+ case "null":
21
+ return t == null || t === "";
22
+ case "nnull":
23
+ return t != null && t !== "";
24
+ case "in":
25
+ return String(i ?? "").split(",").map((l) => l.trim()).includes(String(t ?? ""));
26
+ default:
27
+ return !0;
28
+ }
29
+ });
30
+ }
31
+ export {
32
+ c as matchesVisibleWhen,
33
+ s as parseVisibleWhen
34
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nivaro/react",
3
- "version": "0.2.52",
3
+ "version": "0.2.54",
4
4
  "description": "React hooks and components for Nivaro CMS forms",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",