@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
- import { jsx as t, jsxs as d, Fragment as J } from "react/jsx-runtime";
1
+ import { jsxs as d, jsx as t, Fragment as J } from "react/jsx-runtime";
2
2
  import { useQuery as R } from "@tanstack/react-query";
3
3
  import { Globe2 as j, ChevronRight as _, ChevronDown as $, Check as G, X as U } from "lucide-react";
4
- import { createContext as P, useContext as f, useState as g, useRef as I, useEffect as E } from "react";
4
+ import { useContext as f, createContext as P, useState as g, useRef as I, useEffect as E } from "react";
5
5
  import { useNivaroClient as K } from "../../../context.js";
6
6
  import { get as M } from "../../../lib/commands.js";
7
7
  import { cn as m } from "../../../lib/utils.js";
@@ -10,7 +10,7 @@ import { Popover as H, PopoverTrigger as Z, PopoverContent as ee } from "../../u
10
10
  import { SimpleSelect as te } from "../../ui/SimpleSelect.js";
11
11
  import { Switch as ne } from "../../ui/switch.js";
12
12
  import { useFocusBuffer as x } from "../focus-buffer.js";
13
- import { effectText as q, labelText as ae, inputBase as v, segOption as re, segTrack as le, groupTitle as L } from "../panel-style.js";
13
+ import { labelText as ae, effectText as q, segOption as re, segTrack as le, inputBase as v, groupTitle as L } from "../panel-style.js";
14
14
  const N = P(null);
15
15
  function se() {
16
16
  const e = f(N);
@@ -0,0 +1,21 @@
1
+ import { useRef as c, useEffect as i } from "react";
2
+ const r = "nvr:layout-inspector-tab";
3
+ let e = null;
4
+ function w(t, n) {
5
+ e = { key: t, tab: n }, typeof window < "u" && window.dispatchEvent(new Event(r));
6
+ }
7
+ function a(t, n) {
8
+ const s = c(n);
9
+ s.current = n, i(() => {
10
+ const o = () => {
11
+ if ((e == null ? void 0 : e.key) !== t) return;
12
+ const { tab: u } = e;
13
+ e = null, s.current(u);
14
+ };
15
+ return o(), window.addEventListener(r, o), () => window.removeEventListener(r, o);
16
+ }, [t]);
17
+ }
18
+ export {
19
+ w as requestInspectorTab,
20
+ a as useInspectorTabRequest
21
+ };
@@ -0,0 +1,9 @@
1
+ const n = (e) => {
2
+ const t = e;
3
+ return t != null && t.closest ? t.isContentEditable || !!t.closest(
4
+ 'input, textarea, select, [role="textbox"], [contenteditable]:not([contenteditable="false"])'
5
+ ) : !1;
6
+ };
7
+ export {
8
+ n as isTyping
9
+ };
@@ -0,0 +1,66 @@
1
+ import { isCanvasSlot as a, UNGROUPED_KEY as x, HEADER_GROUP_KEY as v } from "../../lib/layout-ops.js";
2
+ import { titleCase as b } from "../../lib/utils.js";
3
+ import { normalizedBundle as A, fieldZones as R, zoneItems as w } from "./field-zones.js";
4
+ import { pinLocked as $, pinnedZone as E } from "./pin.js";
5
+ const Z = {
6
+ ArrowUp: "up",
7
+ ArrowDown: "down",
8
+ ArrowLeft: "left",
9
+ ArrowRight: "right"
10
+ }, u = (r) => r === "up" || r === "left" ? -1 : 1;
11
+ function I(r, e) {
12
+ return [
13
+ ...r.groups.filter((n) => n.parent_key === e).map((n) => ({ key: n.key, sort: n.sort })),
14
+ ...e === null ? r.placements.filter((n) => a(n)).map((n) => ({ key: n.field, sort: n.sort })) : []
15
+ ].sort((n, l) => n.sort - l.sort).map((n) => n.key);
16
+ }
17
+ function D(r, e) {
18
+ if (e === x) return "ungrouped fields";
19
+ const o = r.groups.find((n) => n.key === e);
20
+ return o ? `${o.type === "tab" ? "tab" : "section"} "${o.label || b(o.key)}"` : "panel";
21
+ }
22
+ function _(r, e, o, n) {
23
+ const l = w(r, o), p = l.findIndex((d) => d.field === e.field), i = p + u(n);
24
+ return p < 0 || i < 0 || i >= l.length ? null : {
25
+ ops: [{ op: "move", from: { field: e.field, group_key: o }, to_group_key: o, index: i }],
26
+ label: `Move ${e.kind === "header" ? "header tile" : "field"} ${u(n) < 0 ? "up" : "down"}`,
27
+ next: e
28
+ };
29
+ }
30
+ function C(r, e, o) {
31
+ const n = A(r);
32
+ if ($(n, e)) return null;
33
+ if (e.kind === "header") return _(n, e, v, o);
34
+ if ((e.kind === "field" || e.kind === "slot") && !a(e)) {
35
+ const s = e.group_key;
36
+ if (!n.placements.some((t) => t.field === e.field && t.group_key === s)) return null;
37
+ if (o === "up" || o === "down") return _(n, e, s, o);
38
+ const c = R(n), g = c.findIndex((t) => t.key === s);
39
+ if (g < 0) return null;
40
+ for (let t = g + u(o); t >= 0 && t < c.length; t += u(o)) {
41
+ const f = c[t];
42
+ if (n.placements.some((m) => m.field === e.field && m.group_key === f.key) || E(n, f.key) || a({ field: e.field, group_key: f.key })) continue;
43
+ const h = o === "left" ? w(n, f.key).length : 0;
44
+ return {
45
+ ops: [
46
+ { op: "move", from: { field: e.field, group_key: s }, to_group_key: f.key, index: h }
47
+ ],
48
+ label: `Move field to ${f.label}`,
49
+ next: { kind: e.kind, field: e.field, group_key: f.key }
50
+ };
51
+ }
52
+ return null;
53
+ }
54
+ const l = e.kind === "group" ? e.key : e.field, p = n.groups.find((s) => s.key === l), i = p ? p.parent_key : null;
55
+ if ((o === "left" || o === "right") && i === null) return null;
56
+ const d = I(n, i), y = d.indexOf(l), k = y + u(o);
57
+ return y < 0 || k < 0 || k >= d.length ? null : {
58
+ ops: [{ op: "group_move", key: l, parent_key: i, index: k }],
59
+ label: `Move ${e.kind === "group" ? D(n, l) : "panel"} ${i === null ? u(o) < 0 ? "up" : "down" : u(o) < 0 ? "left" : "right"}`,
60
+ next: e
61
+ };
62
+ }
63
+ export {
64
+ Z as ARROW_DIRS,
65
+ C as altArrowMove
66
+ };
@@ -0,0 +1,190 @@
1
+ import { jsxs as a, jsx as r } from "react/jsx-runtime";
2
+ import { CircleAlert as k, CheckCircle2 as h, Sparkles as w, Info as y, AlertTriangle as v, AlertCircle as C } from "lucide-react";
3
+ import { cn as c } from "../../../lib/utils.js";
4
+ import { PanelHeader as T, PanelBody as $ } from "../panel-frame.js";
5
+ import { groupTitle as b, effectText as x } from "../panel-style.js";
6
+ import { barBtnOn as I, barBtn as P } from "../toolbar-kit.js";
7
+ import { findingDesignTarget as B } from "./lint-api.js";
8
+ const j = [
9
+ { severity: "error", title: "Errors" },
10
+ { severity: "warn", title: "Warnings" },
11
+ { severity: "info", title: "Tips" }
12
+ ], A = {
13
+ error: C,
14
+ warn: v,
15
+ info: y
16
+ }, O = {
17
+ error: "text-red-600 dark:text-red-400",
18
+ warn: "text-amber-600 dark:text-amber-400",
19
+ info: "text-slate-500 dark:text-muted-foreground"
20
+ };
21
+ function S(e) {
22
+ return e >= 80 ? "bg-emerald-50 text-emerald-700 dark:bg-emerald-500/15 dark:text-emerald-300" : e >= 60 ? "bg-amber-50 text-amber-700 dark:bg-amber-500/15 dark:text-amber-300" : "bg-red-50 text-red-700 dark:bg-red-500/15 dark:text-red-300";
23
+ }
24
+ function f(e) {
25
+ const t = (n) => e.filter((s) => s.severity === n).length;
26
+ return { error: t("error"), warn: t("warn"), info: t("info") };
27
+ }
28
+ function G({
29
+ findings: e,
30
+ active: t,
31
+ onClick: n
32
+ }) {
33
+ const s = f(e), o = s.error + s.warn;
34
+ return /* @__PURE__ */ a(
35
+ "button",
36
+ {
37
+ type: "button",
38
+ onClick: n,
39
+ "aria-pressed": t,
40
+ "aria-label": `Problems: ${s.error} errors, ${s.warn} warnings`,
41
+ "data-editor-checks": "",
42
+ "data-tip": "Problems this form has: hidden required fields, missing cascade parents, empty steps, unreachable fields and accessibility",
43
+ className: c(P, "gap-1 px-2", t && I),
44
+ children: [
45
+ /* @__PURE__ */ r(
46
+ k,
47
+ {
48
+ className: c(
49
+ "h-3.5 w-3.5",
50
+ s.error > 0 ? "text-red-600 dark:text-red-400" : o > 0 ? "text-amber-600 dark:text-amber-400" : "text-slate-500 dark:text-muted-foreground"
51
+ )
52
+ }
53
+ ),
54
+ o > 0 ? /* @__PURE__ */ r("span", { "data-checks-count": o, className: "tabular-nums", children: o }) : /* @__PURE__ */ r(h, { className: "h-3.5 w-3.5 text-emerald-600 dark:text-emerald-400" })
55
+ ]
56
+ }
57
+ );
58
+ }
59
+ function E({
60
+ finding: e,
61
+ onSelect: t,
62
+ apply: n,
63
+ readOnly: s
64
+ }) {
65
+ const o = A[e.severity], i = B(e);
66
+ return /* @__PURE__ */ a(
67
+ "li",
68
+ {
69
+ "data-lint-finding": e.rule,
70
+ className: "rounded-md border border-slate-200 bg-white dark:border-border dark:bg-card",
71
+ children: [
72
+ /* @__PURE__ */ a(
73
+ "button",
74
+ {
75
+ type: "button",
76
+ disabled: !i,
77
+ onClick: () => i && t(i),
78
+ className: "flex w-full items-start gap-2 rounded-md px-2.5 py-2 text-left transition-colors hover:bg-muted disabled:cursor-default disabled:hover:bg-transparent",
79
+ "data-tip": i ? "Select it on the form" : void 0,
80
+ children: [
81
+ /* @__PURE__ */ r(o, { className: c("mt-0.5 h-3.5 w-3.5 shrink-0", O[e.severity]) }),
82
+ /* @__PURE__ */ r("span", { className: "min-w-0 text-[12.5px] leading-snug text-slate-700 dark:text-foreground", children: e.message })
83
+ ]
84
+ }
85
+ ),
86
+ e.fix && !s && /* @__PURE__ */ r("div", { className: "border-t border-slate-100 px-2.5 py-1.5 dark:border-border", children: /* @__PURE__ */ r(
87
+ "button",
88
+ {
89
+ type: "button",
90
+ "data-lint-fix": "",
91
+ onClick: () => e.fix && n(e.fix.ops, { label: e.fix.label }),
92
+ className: "inline-flex h-6 items-center rounded px-1.5 text-[12px] font-medium text-slate-700 transition-colors hover:bg-muted hover:text-slate-900 dark:text-foreground",
93
+ children: e.fix.label
94
+ }
95
+ ) })
96
+ ]
97
+ }
98
+ );
99
+ }
100
+ function J({
101
+ findings: e,
102
+ health: t,
103
+ ready: n,
104
+ onSelect: s,
105
+ apply: o,
106
+ onOpenAiReview: i,
107
+ readOnly: g = !1
108
+ }) {
109
+ const l = f(e), N = e.length === 0 ? n ? "Nothing to fix" : "Checking…" : [
110
+ l.error && `${l.error} ${l.error === 1 ? "problem" : "problems"}`,
111
+ l.warn && `${l.warn} ${l.warn === 1 ? "warning" : "warnings"}`,
112
+ l.info && `${l.info} ${l.info === 1 ? "suggestion" : "suggestions"}`
113
+ ].filter(Boolean).join(" · ");
114
+ return /* @__PURE__ */ a("div", { "data-lint-panel": "", className: "flex min-h-0 flex-1 flex-col", children: [
115
+ /* @__PURE__ */ r(T, { eyebrow: "Form", title: "Problems", sub: N }),
116
+ /* @__PURE__ */ a($, { children: [
117
+ t && /* @__PURE__ */ a("section", { "aria-label": "Health", className: "space-y-1.5", children: [
118
+ /* @__PURE__ */ a("div", { className: "flex items-center gap-2", children: [
119
+ /* @__PURE__ */ r("h3", { className: b, children: "Health" }),
120
+ /* @__PURE__ */ a(
121
+ "span",
122
+ {
123
+ "data-health-score": t.score,
124
+ className: c(
125
+ "rounded-full px-2 py-px text-[11.5px] font-semibold tabular-nums",
126
+ S(t.score)
127
+ ),
128
+ children: [
129
+ t.score,
130
+ " / 100"
131
+ ]
132
+ }
133
+ )
134
+ ] }),
135
+ t.costs.length > 0 ? /* @__PURE__ */ r("ul", { className: "space-y-0.5", children: t.costs.map((d) => /* @__PURE__ */ a("li", { className: c(x, "flex justify-between gap-2"), children: [
136
+ /* @__PURE__ */ r("span", { children: d.label }),
137
+ /* @__PURE__ */ a("span", { className: "tabular-nums", children: [
138
+ "−",
139
+ d.points
140
+ ] })
141
+ ] }, d.label)) }) : /* @__PURE__ */ r("p", { className: x, children: "Nothing costs this form points." })
142
+ ] }),
143
+ e.length === 0 && n && /* @__PURE__ */ a("p", { className: c(x, "flex items-center gap-1.5"), children: [
144
+ /* @__PURE__ */ r(h, { className: "h-3.5 w-3.5 text-emerald-600 dark:text-emerald-400" }),
145
+ "No problems found on this form."
146
+ ] }),
147
+ j.map(({ severity: d, title: p }) => {
148
+ const u = e.filter((m) => m.severity === d);
149
+ return u.length === 0 ? null : /* @__PURE__ */ a("section", { "aria-label": p, className: "space-y-1.5", children: [
150
+ /* @__PURE__ */ a("h3", { className: b, children: [
151
+ p,
152
+ " ",
153
+ /* @__PURE__ */ r("span", { className: "font-normal text-slate-500 dark:text-muted-foreground", children: u.length })
154
+ ] }),
155
+ /* @__PURE__ */ r("ul", { className: "space-y-1.5", children: u.map((m) => /* @__PURE__ */ r(
156
+ E,
157
+ {
158
+ finding: m,
159
+ onSelect: s,
160
+ apply: o,
161
+ readOnly: g
162
+ },
163
+ m.id
164
+ )) })
165
+ ] }, d);
166
+ }),
167
+ i && /* @__PURE__ */ a("div", { className: "space-y-1", children: [
168
+ /* @__PURE__ */ r("p", { className: x, children: "These checks are counted, not guessed. The AI review also reads labels and help text." }),
169
+ /* @__PURE__ */ a(
170
+ "button",
171
+ {
172
+ type: "button",
173
+ onClick: i,
174
+ className: "inline-flex h-7 items-center gap-1.5 rounded-md px-1.5 text-[12px] font-medium text-slate-700 transition-colors hover:bg-muted hover:text-slate-900 dark:text-foreground",
175
+ children: [
176
+ /* @__PURE__ */ r(w, { className: "h-3.5 w-3.5" }),
177
+ "Open the AI review"
178
+ ]
179
+ }
180
+ )
181
+ ] })
182
+ ] })
183
+ ] });
184
+ }
185
+ export {
186
+ G as LintButton,
187
+ J as LintPanel,
188
+ f as lintCounts,
189
+ S as scoreTone
190
+ };
@@ -0,0 +1,52 @@
1
+ import { useQuery as f } from "@tanstack/react-query";
2
+ import { useMemo as s } from "react";
3
+ import { useNivaroClient as c } from "../../../context.js";
4
+ import { get as d } from "../../../lib/commands.js";
5
+ import { mergeInherited as y, lintLayout as g, layoutHealth as p, EMPTY_LINT_CONTEXT as m } from "../../../lib/layout-lint.js";
6
+ const _ = {
7
+ context: (t) => ["layout-editor", "lint-context", t],
8
+ health: (t) => ["layout-editor", "health", t],
9
+ coverage: (t) => ["layout-editor", "coverage", t]
10
+ };
11
+ function k(t) {
12
+ if (!t || typeof t != "object") return null;
13
+ const e = t.data;
14
+ return e && typeof e == "object" ? e : t;
15
+ }
16
+ function h(t, e = !0) {
17
+ const n = c();
18
+ return f({
19
+ queryKey: _.context(t),
20
+ queryFn: async () => {
21
+ const r = k(
22
+ await n.request(d("/collection-layouts/lint-context", { collection: t }))
23
+ );
24
+ return {
25
+ fields: (r == null ? void 0 : r.fields) ?? [],
26
+ roles: (r == null ? void 0 : r.roles) ?? [],
27
+ requirements: (r == null ? void 0 : r.requirements) ?? []
28
+ };
29
+ },
30
+ enabled: e,
31
+ staleTime: 6e4,
32
+ retry: !1
33
+ });
34
+ }
35
+ function C(t, e, n = null) {
36
+ const { data: r, isSuccess: i, isError: o } = h(t, !!e);
37
+ return s(() => {
38
+ if (!e) return { findings: [], health: null, ready: !1 };
39
+ const a = r ?? m, u = y(e, n), l = g(u, a);
40
+ return { findings: l, health: p(u, l), ready: i || o };
41
+ }, [e, n, r, i, o]);
42
+ }
43
+ function E(t) {
44
+ const e = t.target;
45
+ return e.kind === "group" ? { kind: "group", key: e.key } : e.kind !== "field" ? null : e.group_key === "__header__" ? { kind: "header", field: e.field } : /^__.*__$/.test(e.field) ? { kind: "slot", field: e.field, group_key: e.group_key } : { kind: "field", field: e.field, group_key: e.group_key };
46
+ }
47
+ export {
48
+ E as findingDesignTarget,
49
+ _ as lintKeys,
50
+ C as useLayoutLint,
51
+ h as useLintContext
52
+ };
@@ -0,0 +1,37 @@
1
+ import { jsxs as a, jsx as o } from "react/jsx-runtime";
2
+ import { cn as n } from "../../lib/utils.js";
3
+ function x({
4
+ what: e,
5
+ onRetry: r,
6
+ className: t
7
+ }) {
8
+ return /* @__PURE__ */ a(
9
+ "p",
10
+ {
11
+ role: "alert",
12
+ "data-load-error": "",
13
+ className: n(
14
+ "m-0 flex flex-wrap items-center gap-x-1.5 text-[12px] leading-snug text-red-700 dark:text-red-300",
15
+ t
16
+ ),
17
+ children: [
18
+ "Could not load ",
19
+ e,
20
+ ".",
21
+ /* @__PURE__ */ o(
22
+ "button",
23
+ {
24
+ type: "button",
25
+ "data-load-retry": "",
26
+ onClick: r,
27
+ className: "font-medium text-[#0089ad] hover:underline dark:text-nvr-cyan",
28
+ children: "Retry"
29
+ }
30
+ )
31
+ ]
32
+ }
33
+ );
34
+ }
35
+ export {
36
+ x as LoadError
37
+ };