@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
@@ -3,88 +3,90 @@ import { MoreHorizontal as R } from "lucide-react";
3
3
  import { useRef as v, useState as k, useEffect as _ } from "react";
4
4
  import { createPortal as C } from "react-dom";
5
5
  import { cn as w } from "../../lib/utils.js";
6
- function B({ children: b }) {
6
+ function B({ children: m }) {
7
7
  var f, p;
8
- const d = v(null), h = v(null), [l, r] = k(!1), u = v(!1);
8
+ const r = v(null), h = v(null), [l, o] = k(!1), u = v(!1);
9
9
  u.current = l;
10
- const o = v(0), [n, m] = k(!1);
10
+ const a = v(0), [t, b] = k(!1);
11
11
  if (_(() => {
12
- var a;
13
- const e = (a = d.current) == null ? void 0 : a.closest("[data-nvr-header-row]");
12
+ var d;
13
+ const e = (d = r.current) == null ? void 0 : d.closest("[data-nvr-header-row]");
14
14
  if (!e) return;
15
15
  const i = () => {
16
- u.current ? o.current > 0 && e.clientWidth > o.current + 32 && r(!1) : e.scrollWidth > e.clientWidth + 2 && (o.current = e.scrollWidth, r(!0), m(!1));
16
+ u.current ? a.current > 0 && e.clientWidth > a.current + 32 && o(!1) : e.scrollWidth > e.clientWidth + 2 && (a.current = e.scrollWidth, o(!0), b(!1));
17
17
  };
18
18
  i();
19
19
  const g = new ResizeObserver(i);
20
20
  return g.observe(e), () => g.disconnect();
21
21
  }), _(() => {
22
- if (!n) return;
22
+ if (!t) return;
23
23
  const e = (g) => {
24
- const a = g.target;
25
- if (a.closest("[data-nvr-header-tools-panel]") || a.closest("[data-nvr-header-tools-btn]") || a.closest("[data-nvr-header-menu-panel]") || a.closest("[data-radix-popper-content-wrapper]"))
24
+ const d = g.target;
25
+ if (d.closest("[data-nvr-header-tools-panel]") || d.closest("[data-nvr-header-tools-btn]") || d.closest("[data-nvr-header-menu-panel]") || d.closest("[data-radix-popper-content-wrapper]"))
26
26
  return;
27
- const y = a.closest('[role="dialog"]');
28
- y && !y.contains(d.current) || m(!1);
27
+ const y = d.closest('[role="dialog"]');
28
+ y && !y.contains(r.current) || b(!1);
29
29
  }, i = (g) => {
30
- g.target.closest("[data-nvr-header-menu-panel] [data-nvr-menu-close]") && m(!1);
30
+ g.target.closest("[data-nvr-header-menu-panel] [data-nvr-menu-close]") && b(!1);
31
31
  };
32
32
  return window.addEventListener("mousedown", e, !0), window.addEventListener("click", i), () => {
33
33
  window.removeEventListener("mousedown", e, !0), window.removeEventListener("click", i);
34
34
  };
35
- }, [n]), !l)
36
- return /* @__PURE__ */ c("div", { ref: d, className: "contents", children: b });
37
- const s = n ? (f = h.current) == null ? void 0 : f.getBoundingClientRect() : void 0, t = ((p = h.current) == null ? void 0 : p.closest('[role="dialog"]')) ?? document.body;
38
- return /* @__PURE__ */ x("div", { ref: d, className: "flex shrink-0 items-center", children: [
35
+ }, [t]), !l)
36
+ return /* @__PURE__ */ c("div", { ref: r, className: "contents", children: m });
37
+ const s = t ? (f = h.current) == null ? void 0 : f.getBoundingClientRect() : void 0, n = ((p = h.current) == null ? void 0 : p.closest('[role="dialog"]')) ?? document.body;
38
+ return /* @__PURE__ */ x("div", { ref: r, className: "flex shrink-0 items-center", children: [
39
39
  /* @__PURE__ */ c(
40
40
  "button",
41
41
  {
42
42
  ref: h,
43
43
  type: "button",
44
44
  "data-nvr-header-tools-btn": !0,
45
- title: "More tools",
46
- onClick: () => m((e) => !e),
45
+ "aria-expanded": t,
46
+ "aria-label": "More tools",
47
+ "data-tip": "More tools",
48
+ onClick: () => b((e) => !e),
47
49
  className: w(
48
- "inline-flex h-9 items-center gap-1.5 rounded-md border border-input bg-background px-3 text-sm font-medium shadow-sm transition-colors hover:bg-accent hover:text-accent-foreground",
49
- n && "bg-accent text-accent-foreground"
50
+ "inline-flex h-9 items-center gap-1.5 rounded-md border border-input bg-background px-3 text-sm font-medium shadow-sm transition-colors hover:bg-accent hover:text-accent-foreground dark:bg-transparent dark:hover:bg-accent",
51
+ t && "bg-accent text-accent-foreground dark:bg-accent"
50
52
  ),
51
53
  children: /* @__PURE__ */ c(R, { className: "h-4 w-4" })
52
54
  }
53
55
  ),
54
- n && s && C(
56
+ t && s && C(
55
57
  /* @__PURE__ */ c(
56
58
  "div",
57
59
  {
58
60
  "data-nvr-header-tools-panel": !0,
59
- style: t === document.body ? {
61
+ style: n === document.body ? {
60
62
  position: "fixed",
61
63
  top: s.bottom + 6,
62
64
  right: Math.max(8, window.innerWidth - s.right),
63
65
  zIndex: 110
64
66
  } : {
65
67
  position: "absolute",
66
- top: s.bottom - t.getBoundingClientRect().top + 6,
67
- right: Math.max(8, t.getBoundingClientRect().right - s.right),
68
+ top: s.bottom - n.getBoundingClientRect().top + 6,
69
+ right: Math.max(8, n.getBoundingClientRect().right - s.right),
68
70
  zIndex: 110
69
71
  },
70
72
  className: "flex max-w-[440px] flex-wrap items-center justify-end gap-1.5 rounded-lg border border-slate-200 bg-white p-2 shadow-xl dark:border-border dark:bg-card",
71
- children: b
73
+ children: m
72
74
  }
73
75
  ),
74
- t
76
+ n
75
77
  )
76
78
  ] });
77
79
  }
78
80
  function W({
79
- children: b,
80
- label: d = "More",
81
+ children: m,
82
+ label: r = "More",
81
83
  className: h
82
84
  }) {
83
- var m, s;
84
- const l = v(null), [r, u] = k(!1);
85
+ var b, s;
86
+ const l = v(null), [o, u] = k(!1);
85
87
  _(() => {
86
- if (!r) return;
87
- const t = (p) => {
88
+ if (!o) return;
89
+ const n = (p) => {
88
90
  var i;
89
91
  const e = p.target;
90
92
  e.closest("[data-nvr-header-menu-panel]") || e.closest("[data-nvr-header-menu-btn]") || e.closest("[data-radix-popper-content-wrapper]") || // A dialog opened from a menu row, not one hosting the form.
@@ -92,11 +94,11 @@ function W({
92
94
  }, f = (p) => {
93
95
  p.key === "Escape" && u(!1);
94
96
  };
95
- return window.addEventListener("mousedown", t, !0), window.addEventListener("keydown", f), () => {
96
- window.removeEventListener("mousedown", t, !0), window.removeEventListener("keydown", f);
97
+ return window.addEventListener("mousedown", n, !0), window.addEventListener("keydown", f), () => {
98
+ window.removeEventListener("mousedown", n, !0), window.removeEventListener("keydown", f);
97
99
  };
98
- }, [r]);
99
- const o = r ? (m = l.current) == null ? void 0 : m.getBoundingClientRect() : void 0, n = ((s = l.current) == null ? void 0 : s.closest('[role="dialog"]')) ?? document.body;
100
+ }, [o]);
101
+ const a = o ? (b = l.current) == null ? void 0 : b.getBoundingClientRect() : void 0, t = ((s = l.current) == null ? void 0 : s.closest('[role="dialog"]')) ?? document.body;
100
102
  return /* @__PURE__ */ x("div", { className: w("relative shrink-0", h), children: [
101
103
  /* @__PURE__ */ x(
102
104
  "button",
@@ -105,37 +107,38 @@ function W({
105
107
  type: "button",
106
108
  "data-nvr-header-menu-btn": !0,
107
109
  "aria-haspopup": "menu",
108
- "aria-expanded": r,
109
- title: "More actions",
110
- onClick: () => u((t) => !t),
110
+ "aria-expanded": o,
111
+ "aria-label": r,
112
+ "data-tip": "More actions",
113
+ onClick: () => u((n) => !n),
111
114
  className: w(
112
- "inline-flex h-9 items-center gap-1 rounded-md border border-input bg-background px-2.5 text-sm font-medium shadow-sm transition-colors hover:bg-accent hover:text-accent-foreground",
113
- r && "bg-accent text-accent-foreground"
115
+ "inline-flex h-9 items-center gap-1 rounded-md border border-input bg-background px-2.5 text-sm font-medium shadow-sm transition-colors hover:bg-accent hover:text-accent-foreground dark:bg-transparent dark:hover:bg-accent",
116
+ o && "bg-accent text-accent-foreground dark:bg-accent"
114
117
  ),
115
118
  children: [
116
119
  /* @__PURE__ */ c(R, { className: "h-4 w-4" }),
117
- /* @__PURE__ */ c("span", { className: "hidden lg:inline", children: d })
120
+ /* @__PURE__ */ c("span", { className: "hidden lg:inline", children: r })
118
121
  ]
119
122
  }
120
123
  ),
121
- r && o && C(
124
+ o && a && C(
122
125
  /* @__PURE__ */ c(
123
126
  "div",
124
127
  {
125
128
  "data-nvr-header-menu-panel": !0,
126
129
  role: "menu",
127
- onClick: (t) => {
128
- t.target.closest("[data-nvr-menu-close]") && u(!1);
130
+ onClick: (n) => {
131
+ n.target.closest("[data-nvr-menu-close]") && u(!1);
129
132
  },
130
- style: n === document.body ? {
133
+ style: t === document.body ? {
131
134
  position: "fixed",
132
- top: o.bottom + 6,
133
- right: Math.max(8, window.innerWidth - o.right),
135
+ top: a.bottom + 6,
136
+ right: Math.max(8, window.innerWidth - a.right),
134
137
  zIndex: 110
135
138
  } : {
136
139
  position: "absolute",
137
- top: o.bottom - n.getBoundingClientRect().top + 6,
138
- right: Math.max(8, n.getBoundingClientRect().right - o.right),
140
+ top: a.bottom - t.getBoundingClientRect().top + 6,
141
+ right: Math.max(8, t.getBoundingClientRect().right - a.right),
139
142
  zIndex: 110
140
143
  },
141
144
  className: w(
@@ -144,16 +147,16 @@ function W({
144
147
  "[&_button:hover]:bg-accent [&_button:hover]:text-accent-foreground [&_button_svg]:h-3.5 [&_button_svg]:w-3.5 [&_button_svg]:shrink-0 [&_button_svg]:text-slate-500",
145
148
  "[&>[data-nvr-menu-divider]]:my-1 [&>[data-nvr-menu-divider]]:h-px [&>[data-nvr-menu-divider]]:bg-slate-100 dark:[&>[data-nvr-menu-divider]]:bg-border"
146
149
  ),
147
- children: b
150
+ children: m
148
151
  }
149
152
  ),
150
- n
153
+ t
151
154
  )
152
155
  ] });
153
156
  }
154
157
  function j({
155
- children: b,
156
- className: d
158
+ children: m,
159
+ className: r
157
160
  }) {
158
161
  return /* @__PURE__ */ c(
159
162
  "div",
@@ -161,9 +164,9 @@ function j({
161
164
  "data-nvr-header-tool-group": !0,
162
165
  className: w(
163
166
  "inline-flex h-9 shrink-0 items-center rounded-md border border-input bg-background px-0.5 shadow-sm [&>*+*]:border-l [&>*+*]:border-input/70",
164
- d
167
+ r
165
168
  ),
166
- children: b
169
+ children: m
167
170
  }
168
171
  );
169
172
  }
@@ -1,58 +1,58 @@
1
1
  import { jsxs as c, jsx as t } from "react/jsx-runtime";
2
2
  import { AlertTriangle as i, Info as o } from "lucide-react";
3
3
  function m(e) {
4
- const r = [], s = /\*\*([^*]+)\*\*|\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/g;
5
- let l = 0, a = 0;
6
- for (const n of e.matchAll(s)) {
7
- const d = n.index ?? 0;
8
- d > l && r.push(/* @__PURE__ */ t("span", { children: e.slice(l, d) }, a++)), n[1] !== void 0 ? r.push(
9
- /* @__PURE__ */ t("strong", { className: "font-semibold", children: n[1] }, a++)
10
- ) : r.push(
4
+ const a = [], n = /\*\*([^*]+)\*\*|\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/g;
5
+ let r = 0, l = 0;
6
+ for (const s of e.matchAll(n)) {
7
+ const d = s.index ?? 0;
8
+ d > r && a.push(/* @__PURE__ */ t("span", { children: e.slice(r, d) }, l++)), s[1] !== void 0 ? a.push(
9
+ /* @__PURE__ */ t("strong", { className: "font-semibold", children: s[1] }, l++)
10
+ ) : a.push(
11
11
  /* @__PURE__ */ t(
12
12
  "a",
13
13
  {
14
- href: n[3],
14
+ href: s[3],
15
15
  target: "_blank",
16
16
  rel: "noreferrer",
17
17
  className: "text-nvr-navy underline underline-offset-2 dark:text-nvr-cyan",
18
- children: n[2]
18
+ children: s[2]
19
19
  },
20
- a++
20
+ l++
21
21
  )
22
- ), l = d + n[0].length;
22
+ ), r = d + s[0].length;
23
23
  }
24
- return l < e.length && r.push(/* @__PURE__ */ t("span", { children: e.slice(l) }, a++)), r;
24
+ return r < e.length && a.push(/* @__PURE__ */ t("span", { children: e.slice(r) }, l++)), a;
25
25
  }
26
26
  function h({ group: e }) {
27
- const r = e.content_tone ?? "info", s = (e.content ?? "").trim();
28
- if (r === "divider")
27
+ const a = e.content_tone ?? "info", n = (e.content ?? "").trim();
28
+ if (a === "divider")
29
29
  return /* @__PURE__ */ c("div", { className: "flex items-center gap-3 py-1", "data-content-block": e.key, children: [
30
30
  /* @__PURE__ */ t("span", { className: "h-px flex-1 bg-slate-200 dark:bg-border" }),
31
- (s || e.label) && /* @__PURE__ */ t("span", { className: "text-[11px] font-medium uppercase tracking-wide text-slate-400", children: s || e.label }),
31
+ (n || e.label) && /* @__PURE__ */ t("span", { className: "text-[11px] font-medium uppercase tracking-wide text-slate-400", children: n || e.label }),
32
32
  /* @__PURE__ */ t("span", { className: "h-px flex-1 bg-slate-200 dark:bg-border" })
33
33
  ] });
34
- if (!s) return null;
35
- const l = s.split(/\n{2,}/), a = r === "warn";
34
+ if (!n) return null;
35
+ const r = n.split(/\n{2,}/), l = a === "warn";
36
36
  return /* @__PURE__ */ c(
37
37
  "div",
38
38
  {
39
39
  "data-content-block": e.key,
40
- className: `flex gap-2.5 rounded-lg border px-3.5 py-2.5 ${a ? "border-amber-200 bg-amber-50/70 dark:border-amber-500/30 dark:bg-amber-500/10" : "border-slate-200 bg-slate-50/70 dark:border-border dark:bg-muted/40"}`,
40
+ className: `flex gap-2.5 rounded-lg border px-3.5 py-2.5 ${l ? "border-amber-200 bg-amber-50/70 dark:border-amber-500/30 dark:bg-amber-500/10" : "border-slate-200 bg-slate-50/70 dark:border-border dark:bg-muted/40"}`,
41
41
  children: [
42
- a ? /* @__PURE__ */ t(i, { className: "mt-0.5 h-3.5 w-3.5 shrink-0 text-amber-500" }) : /* @__PURE__ */ t(o, { className: "mt-0.5 h-3.5 w-3.5 shrink-0 text-slate-400" }),
42
+ l ? /* @__PURE__ */ t(i, { className: "mt-0.5 h-3.5 w-3.5 shrink-0 text-amber-500" }) : /* @__PURE__ */ t(o, { className: "mt-0.5 h-3.5 w-3.5 shrink-0 text-slate-400" }),
43
43
  /* @__PURE__ */ c("div", { className: "min-w-0 space-y-1.5", children: [
44
44
  e.label && e.label !== e.key && /* @__PURE__ */ t(
45
45
  "p",
46
46
  {
47
- className: `text-[12.5px] font-semibold ${a ? "text-amber-800 dark:text-amber-300" : "text-slate-800 dark:text-foreground"}`,
47
+ className: `text-[12.5px] font-semibold ${l ? "text-amber-800 dark:text-amber-300" : "text-slate-800 dark:text-foreground"}`,
48
48
  children: e.label
49
49
  }
50
50
  ),
51
- l.map((n, d) => /* @__PURE__ */ t(
51
+ r.map((s, d) => /* @__PURE__ */ t(
52
52
  "p",
53
53
  {
54
- className: `whitespace-pre-wrap text-[12.5px] leading-relaxed ${a ? "text-amber-700 dark:text-amber-300/90" : "text-slate-600 dark:text-muted-foreground"}`,
55
- children: m(n)
54
+ className: `whitespace-pre-wrap text-[12.5px] leading-relaxed ${l ? "text-amber-700 dark:text-amber-300/90" : "text-slate-600 dark:text-muted-foreground"}`,
55
+ children: m(s)
56
56
  },
57
57
  d
58
58
  ))
@@ -61,6 +61,29 @@ function h({ group: e }) {
61
61
  }
62
62
  );
63
63
  }
64
+ function k({ group: e, className: a }) {
65
+ const n = (e.content ?? "").trim();
66
+ if (!n || e.type === "content" || e.content_tone === "divider") return null;
67
+ const r = e.content_tone === "warn";
68
+ return /* @__PURE__ */ c(
69
+ "div",
70
+ {
71
+ "data-section-intro": e.key,
72
+ className: `flex gap-2 rounded-lg border px-3 py-2 ${r ? "border-amber-200 bg-amber-50/70 dark:border-amber-500/30 dark:bg-amber-500/10" : "border-slate-200 bg-slate-50/70 dark:border-border dark:bg-muted/40"} ${a ?? ""}`,
73
+ children: [
74
+ r ? /* @__PURE__ */ t(i, { className: "mt-0.5 h-3.5 w-3.5 shrink-0 text-amber-500" }) : /* @__PURE__ */ t(o, { className: "mt-0.5 h-3.5 w-3.5 shrink-0 text-slate-400" }),
75
+ /* @__PURE__ */ t(
76
+ "p",
77
+ {
78
+ className: `min-w-0 whitespace-pre-wrap text-[12.5px] leading-relaxed ${r ? "text-amber-700 dark:text-amber-300/90" : "text-slate-600 dark:text-muted-foreground"}`,
79
+ children: m(n)
80
+ }
81
+ )
82
+ ]
83
+ }
84
+ );
85
+ }
64
86
  export {
65
- h as LayoutContentBlock
87
+ h as LayoutContentBlock,
88
+ k as SectionIntro
66
89
  };
@@ -0,0 +1,87 @@
1
+ import { jsxs as u, jsx as i } from "react/jsx-runtime";
2
+ import { useQuery as p } from "@tanstack/react-query";
3
+ import { EyeOff as h } from "lucide-react";
4
+ import { useState as m, useCallback as x, useMemo as c } from "react";
5
+ import { useNivaroClient as b } from "../../context.js";
6
+ import { get as y } from "../../lib/commands.js";
7
+ import { describeShowWhen as g } from "../layout-editor/show-when.js";
8
+ import { Popover as k, PopoverTrigger as w, PopoverContent as N } from "../ui/popover.js";
9
+ function T(t, r, l) {
10
+ const d = b(), [s, a] = m(!1), o = r == null || r === "" ? null : String(r), e = p({
11
+ queryKey: ["layout-why", t, o],
12
+ enabled: l.enabled && !!o && (l.eager || s),
13
+ staleTime: 6e4,
14
+ retry: !1,
15
+ queryFn: () => d.request(y("/collection-layouts/why", { collection: t, item: o })).then((f) => f.data ?? null)
16
+ }), n = x(() => a(!0), []);
17
+ return { data: e.data ?? null, want: n };
18
+ }
19
+ const v = /^(Locked for your role|Locked while the record is in |Locked by the record’s current state|The ".*" section is locked for your role|Read-only field)/;
20
+ function j(t, r) {
21
+ var d;
22
+ if (!r) return t;
23
+ const l = { ...t };
24
+ for (const [s, a] of Object.entries(t)) {
25
+ if (!v.test(a)) continue;
26
+ const o = ((d = r.locks[s]) == null ? void 0 : d.text) ?? (a === "Read-only field" ? r.record_lock : null);
27
+ o && (l[s] = o);
28
+ }
29
+ return l;
30
+ }
31
+ function E({
32
+ why: t,
33
+ fields: r,
34
+ stepVisible: l
35
+ }) {
36
+ const [d, s] = m(!1), a = c(() => {
37
+ const e = new Map(r.map((n) => [n.field, n.label || n.field]));
38
+ return (n) => e.get(n) ?? n;
39
+ }, [r]), o = c(
40
+ () => (t.hidden ?? []).filter(
41
+ (e) => e.kind !== "step_rule" || !l({ visible_when: JSON.stringify(e.rules ?? []) })
42
+ ).map((e) => {
43
+ const n = e.kind === "step_rule" ? g(e.rules, r) : null;
44
+ return {
45
+ ...e,
46
+ words: e.kind === "step_rule" ? `“${e.section_label ?? e.section}” shows only when ${n ?? "its rule matches"}` : e.text
47
+ };
48
+ }),
49
+ [t.hidden, l, r]
50
+ );
51
+ return o.length ? /* @__PURE__ */ u(k, { open: d, onOpenChange: s, children: [
52
+ /* @__PURE__ */ i(w, { asChild: !0, children: /* @__PURE__ */ u(
53
+ "button",
54
+ {
55
+ type: "button",
56
+ "data-hidden-by-rules": o.length,
57
+ className: "inline-flex items-center gap-1.5 self-start rounded-md border border-slate-200 bg-white px-2 py-1 text-[12px] text-slate-600 transition-colors hover:bg-muted dark:border-border dark:bg-card dark:text-muted-foreground",
58
+ children: [
59
+ /* @__PURE__ */ i(h, { "aria-hidden": !0, className: "h-3.5 w-3.5" }),
60
+ o.length,
61
+ " ",
62
+ o.length === 1 ? "field" : "fields",
63
+ " hidden by rules"
64
+ ]
65
+ }
66
+ ) }),
67
+ /* @__PURE__ */ u(N, { align: "start", className: "w-[360px] p-0", children: [
68
+ /* @__PURE__ */ u("div", { className: "border-b border-slate-200 px-3 py-2 text-[12px] text-slate-500 dark:border-border dark:text-muted-foreground", children: [
69
+ "This record opens with the",
70
+ " ",
71
+ /* @__PURE__ */ i("b", { className: "font-medium text-slate-800 dark:text-foreground", children: t.layout.name }),
72
+ " form",
73
+ t.layout.why ? ` because ${t.layout.why}` : "",
74
+ ". Only admins see this list."
75
+ ] }),
76
+ /* @__PURE__ */ i("ul", { className: "max-h-[320px] divide-y divide-slate-100 overflow-y-auto overscroll-contain dark:divide-border", children: o.map((e) => /* @__PURE__ */ u("li", { className: "px-3 py-2 text-[12.5px]", children: [
77
+ /* @__PURE__ */ i("span", { className: "font-medium text-slate-800 dark:text-foreground", children: a(e.field) }),
78
+ /* @__PURE__ */ i("p", { className: "m-0 text-[12px] text-slate-500 dark:text-muted-foreground", children: e.words })
79
+ ] }, `${e.kind}:${e.field}`)) })
80
+ ] })
81
+ ] }) : null;
82
+ }
83
+ export {
84
+ E as HiddenByRulesNote,
85
+ j as refineLockReasons,
86
+ T as useLockWhy
87
+ };
@@ -0,0 +1,59 @@
1
+ import { useRef as i, useEffect as g, useCallback as C } from "react";
2
+ import { useApiFetchConfig as L } from "../../context.js";
3
+ import { StepClock as y, sessionEvent as F, queueFormUsage as R } from "../../lib/form-usage-beacon.js";
4
+ function x({
5
+ enabled: w,
6
+ layoutId: t,
7
+ collection: o,
8
+ itemId: a,
9
+ step: s
10
+ }) {
11
+ const u = L(), d = i(u);
12
+ d.current = u;
13
+ const l = i(s);
14
+ l.current = s;
15
+ const n = i(null), f = w && t != null && !!o;
16
+ return g(() => {
17
+ if (!f || t == null) return;
18
+ const r = () => typeof document > "u" || document.visibilityState !== "hidden", e = {
19
+ clock: new y(l.current, Date.now(), r()),
20
+ openSent: !1,
21
+ saved: !1,
22
+ elapsed: 0
23
+ };
24
+ n.current = e;
25
+ const c = (S) => {
26
+ const { steps: h, total: m } = e.clock.take(Date.now());
27
+ e.elapsed += m;
28
+ const k = F({
29
+ layoutId: t,
30
+ collection: o,
31
+ item: a,
32
+ openSent: e.openSent,
33
+ saved: e.saved,
34
+ step: e.clock.currentStep,
35
+ steps: h,
36
+ total: m,
37
+ elapsed: e.elapsed,
38
+ final: S
39
+ });
40
+ if (!k) return;
41
+ e.openSent = !0, e.saved = !1;
42
+ const { apiBase: b, authHeaders: E, credentials: D } = d.current;
43
+ R(k, { apiBase: b, authHeaders: E, credentials: D });
44
+ }, p = () => {
45
+ document.visibilityState === "hidden" ? (c(!1), e.clock.pause(Date.now())) : e.clock.resume(Date.now());
46
+ }, v = () => c(!0);
47
+ return document.addEventListener("visibilitychange", p), window.addEventListener("pagehide", v), () => {
48
+ document.removeEventListener("visibilitychange", p), window.removeEventListener("pagehide", v), c(!0), n.current === e && (n.current = null);
49
+ };
50
+ }, [f, t, o, a]), g(() => {
51
+ var r;
52
+ (r = n.current) == null || r.clock.step(s, Date.now());
53
+ }, [s]), { markSaved: C(() => {
54
+ n.current && (n.current.saved = !0);
55
+ }, []) };
56
+ }
57
+ export {
58
+ x as useFormUsageBeacon
59
+ };