@nivaro/react 0.3.35 → 0.3.37

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 (106) hide show
  1. package/dist/components/slots/CommentsSlot.js +44 -36
  2. package/dist/full.css +1 -1
  3. package/dist/hooks/useSessionRecorder.js +1 -1
  4. package/dist/index.d.ts +13 -4
  5. package/dist/shared/components/AgentBadge.js +26 -0
  6. package/dist/shared/components/AgentQuestionsCard.js +198 -0
  7. package/dist/shared/components/ItemEditForm.js +3329 -3263
  8. package/dist/shared/components/McpConnectionScope.js +480 -0
  9. package/dist/shared/components/MyWorkView.js +223 -208
  10. package/dist/shared/components/RecordReadView.js +620 -572
  11. package/dist/shared/components/chat/ChatPanel.js +683 -671
  12. package/dist/shared/components/imports/DownloadSampleButton.js +69 -0
  13. package/dist/shared/components/imports/ImportConsole.js +106 -104
  14. package/dist/shared/components/imports/RunDetailSheet.js +11 -10
  15. package/dist/shared/components/item-edit/FieldAffordances.js +32 -32
  16. package/dist/shared/components/item-edit/FormTour.js +279 -0
  17. package/dist/shared/components/item-edit/GroupSection.js +377 -360
  18. package/dist/shared/components/item-edit/PersonalDefaultControl.js +80 -63
  19. package/dist/shared/components/item-edit/entry/EntryStrip.js +30 -26
  20. package/dist/shared/components/item-edit/form-density.js +36 -0
  21. package/dist/shared/components/item-edit/useFormUsageBeacon.js +59 -46
  22. package/dist/shared/components/item-edit/usePersonalDefaults.js +312 -296
  23. package/dist/shared/components/layout-editor/AddPanel.js +349 -192
  24. package/dist/shared/components/layout-editor/DesignNode.js +146 -131
  25. package/dist/shared/components/layout-editor/EditorCanvas.js +25 -17
  26. package/dist/shared/components/layout-editor/EditorTopBar.js +268 -206
  27. package/dist/shared/components/layout-editor/LayoutEditor.js +810 -731
  28. package/dist/shared/components/layout-editor/PlaceTools.js +334 -0
  29. package/dist/shared/components/layout-editor/SlashInsert.js +252 -0
  30. package/dist/shared/components/layout-editor/StructureMenu.js +285 -242
  31. package/dist/shared/components/layout-editor/add-target.js +54 -43
  32. package/dist/shared/components/layout-editor/ai-forms/AiComposer.js +238 -155
  33. package/dist/shared/components/layout-editor/ai-forms/AiFormsButton.js +1 -1
  34. package/dist/shared/components/layout-editor/ai-forms/ai-forms-api.js +15 -12
  35. package/dist/shared/components/layout-editor/dnd/LayoutDndProvider.js +379 -185
  36. package/dist/shared/components/layout-editor/dnd/TrashZone.js +96 -0
  37. package/dist/shared/components/layout-editor/dnd/UndoChip.js +76 -0
  38. package/dist/shared/components/layout-editor/dnd/merge-drop.js +33 -0
  39. package/dist/shared/components/layout-editor/dnd/multi-drop.js +87 -0
  40. package/dist/shared/components/layout-editor/dnd/node.js +115 -105
  41. package/dist/shared/components/layout-editor/dnd/rail-drop.js +4 -4
  42. package/dist/shared/components/layout-editor/dnd/sensors.js +23 -0
  43. package/dist/shared/components/layout-editor/dnd/trash-drop.js +58 -0
  44. package/dist/shared/components/layout-editor/dnd/trash-links.js +97 -0
  45. package/dist/shared/components/layout-editor/even-row.js +86 -0
  46. package/dist/shared/components/layout-editor/field-list.js +99 -0
  47. package/dist/shared/components/layout-editor/format-painter.js +102 -0
  48. package/dist/shared/components/layout-editor/grid-guides.js +15 -13
  49. package/dist/shared/components/layout-editor/inspector/BehaviourSettings.js +150 -132
  50. package/dist/shared/components/layout-editor/inspector/BulkInspector.js +57 -53
  51. package/dist/shared/components/layout-editor/inspector/EvenRowAction.js +31 -0
  52. package/dist/shared/components/layout-editor/inspector/GroupInspector.js +154 -141
  53. package/dist/shared/components/layout-editor/inspector/Inspector.js +209 -178
  54. package/dist/shared/components/layout-editor/inspector/LookTab.js +106 -98
  55. package/dist/shared/components/layout-editor/inspector/RulesTab.js +38 -37
  56. package/dist/shared/components/layout-editor/inspector/kit.js +280 -223
  57. package/dist/shared/components/layout-editor/keyboard-move.js +15 -15
  58. package/dist/shared/components/layout-editor/lint/LabelStyle.js +201 -0
  59. package/dist/shared/components/layout-editor/lint/LintPanel.js +132 -84
  60. package/dist/shared/components/layout-editor/lint/lint-api.js +65 -28
  61. package/dist/shared/components/layout-editor/nav/NavTools.js +14 -12
  62. package/dist/shared/components/layout-editor/nav/ZoomControls.js +145 -0
  63. package/dist/shared/components/layout-editor/nav/useEditorNav.js +34 -32
  64. package/dist/shared/components/layout-editor/nav/view-prefs.js +100 -15
  65. package/dist/shared/components/layout-editor/outputs/LayoutFile.js +89 -0
  66. package/dist/shared/components/layout-editor/outputs/OutputsButton.js +272 -195
  67. package/dist/shared/components/layout-editor/outputs/layout-file-plan.js +176 -0
  68. package/dist/shared/components/layout-editor/outputs/output-api.js +71 -37
  69. package/dist/shared/components/layout-editor/overview/describe-conditions.js +16 -11
  70. package/dist/shared/components/layout-editor/overview/purpose.js +5 -5
  71. package/dist/shared/components/layout-editor/panel-frame.js +1 -1
  72. package/dist/shared/components/layout-editor/parity-keys.json.js +1 -1
  73. package/dist/shared/components/layout-editor/personal-default-marks.js +40 -0
  74. package/dist/shared/components/layout-editor/pin.js +37 -19
  75. package/dist/shared/components/layout-editor/place-clip.js +257 -0
  76. package/dist/shared/components/layout-editor/preview/PreviewModes.js +27 -26
  77. package/dist/shared/components/layout-editor/preview/PreviewPanes.js +149 -118
  78. package/dist/shared/components/layout-editor/preview/SampleRecord.js +113 -0
  79. package/dist/shared/components/layout-editor/preview/preview-model.js +79 -60
  80. package/dist/shared/components/layout-editor/preview/sample-record.js +105 -0
  81. package/dist/shared/components/layout-editor/removed-log.js +151 -0
  82. package/dist/shared/components/layout-editor/reuse/LibraryRows.js +109 -78
  83. package/dist/shared/components/layout-editor/reuse/linked-sections.js +373 -0
  84. package/dist/shared/components/layout-editor/revert-element.js +140 -0
  85. package/dist/shared/components/layout-editor/section-structure.js +193 -170
  86. package/dist/shared/components/layout-editor/settings/EntrySection.js +63 -45
  87. package/dist/shared/components/layout-editor/settings/LayoutSection.js +63 -32
  88. package/dist/shared/components/layout-editor/settings/ResolveSettings.js +179 -137
  89. package/dist/shared/components/layout-editor/settings/WhoSection.js +18 -17
  90. package/dist/shared/components/layout-editor/settings/settings-registry.js +24 -0
  91. package/dist/shared/components/layout-editor/shortcuts.js +21 -16
  92. package/dist/shared/components/layout-editor/structure-ops.js +221 -195
  93. package/dist/shared/components/layout-editor/usage/UsagePanel.js +133 -85
  94. package/dist/shared/components/layout-editor/usage/refusal-lens.js +130 -0
  95. package/dist/shared/components/layout-editor/usage/usage-api.js +12 -11
  96. package/dist/shared/components/panels/CommentPanel.js +47 -45
  97. package/dist/shared/components/panels/RevisionsPanel.js +66 -64
  98. package/dist/shared/components/panels/TaskPanel.js +395 -332
  99. package/dist/shared/components/profile/AgentsPanel.js +196 -147
  100. package/dist/shared/components/profile/ConnectionRollback.js +329 -0
  101. package/dist/shared/components/profile/MyDefaultsCard.js +526 -520
  102. package/dist/shared/lib/entry-config.js +22 -22
  103. package/dist/shared/lib/form-usage-beacon.js +91 -55
  104. package/dist/shared/lib/layout-lint.js +530 -284
  105. package/dist/shared/lib/layout-resolve.js +58 -44
  106. package/package.json +1 -1
@@ -1,30 +1,32 @@
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 _ = {
1
+ import { useQuery as y, useQueryClient as g, useMutation as m } from "@tanstack/react-query";
2
+ import { useMemo as p } from "react";
3
+ import { useNivaroClient as i } from "../../../context.js";
4
+ import { get as f, patch as h } from "../../../lib/commands.js";
5
+ import { mergeInherited as k, lintLayout as q, layoutHealth as T, EMPTY_LINT_CONTEXT as x } from "../../../lib/layout-lint.js";
6
+ const o = {
7
7
  context: (t) => ["layout-editor", "lint-context", t],
8
8
  health: (t) => ["layout-editor", "health", t],
9
- coverage: (t) => ["layout-editor", "coverage", t]
9
+ coverage: (t) => ["layout-editor", "coverage", t],
10
+ style: ["layout-editor", "lint-style"]
10
11
  };
11
- function k(t) {
12
+ function l(t) {
12
13
  if (!t || typeof t != "object") return null;
13
14
  const e = t.data;
14
15
  return e && typeof e == "object" ? e : t;
15
16
  }
16
- function h(t, e = !0) {
17
- const n = c();
18
- return f({
19
- queryKey: _.context(t),
17
+ function L(t, e = !0) {
18
+ const r = i();
19
+ return y({
20
+ queryKey: o.context(t),
20
21
  queryFn: async () => {
21
- const r = k(
22
- await n.request(d("/collection-layouts/lint-context", { collection: t }))
22
+ const n = l(
23
+ await r.request(f("/collection-layouts/lint-context", { collection: t }))
23
24
  );
24
25
  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) ?? []
26
+ fields: (n == null ? void 0 : n.fields) ?? [],
27
+ roles: (n == null ? void 0 : n.roles) ?? [],
28
+ requirements: (n == null ? void 0 : n.requirements) ?? [],
29
+ style: (n == null ? void 0 : n.style) ?? null
28
30
  };
29
31
  },
30
32
  enabled: e,
@@ -32,21 +34,56 @@ function h(t, e = !0) {
32
34
  retry: !1
33
35
  });
34
36
  }
35
- function C(t, e, n = null) {
36
- const { data: r, isSuccess: i, isError: o } = h(t, !!e);
37
- return s(() => {
37
+ function Q(t, e, r = null) {
38
+ const { data: n, isSuccess: u, isError: s } = L(t, !!e);
39
+ return p(() => {
38
40
  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]);
41
+ const _ = n ?? x, a = k(e, r), c = q(a, _);
42
+ return { findings: c, health: T(a, c), ready: u || s };
43
+ }, [e, r, n, u, s]);
42
44
  }
43
- function E(t) {
45
+ function C(t) {
44
46
  const e = t.target;
45
47
  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
48
  }
49
+ const d = {
50
+ off: [],
51
+ max_label_length: null,
52
+ jargon: [],
53
+ allow_words: []
54
+ };
55
+ function M(t = !0) {
56
+ const e = i();
57
+ return y({
58
+ queryKey: o.style,
59
+ queryFn: async () => ({
60
+ ...d,
61
+ ...l(
62
+ await e.request(f("/collection-layouts/lint-style"))
63
+ ) ?? {}
64
+ }),
65
+ enabled: t,
66
+ staleTime: 6e4,
67
+ retry: !1
68
+ });
69
+ }
70
+ function N() {
71
+ const t = i(), e = g();
72
+ return m({
73
+ mutationFn: async (r) => l(
74
+ await t.request(h("/collection-layouts/lint-style", r))
75
+ ) ?? d,
76
+ onSuccess: (r) => {
77
+ e.setQueryData(o.style, r), e.invalidateQueries({ queryKey: ["layout-editor", "lint-context"] }), e.invalidateQueries({ queryKey: ["layout-editor", "health"] });
78
+ }
79
+ });
80
+ }
47
81
  export {
48
- E as findingDesignTarget,
49
- _ as lintKeys,
50
- C as useLayoutLint,
51
- h as useLintContext
82
+ d as EMPTY_LINT_STYLE,
83
+ C as findingDesignTarget,
84
+ o as lintKeys,
85
+ Q as useLayoutLint,
86
+ L as useLintContext,
87
+ M as useLintStyle,
88
+ N as useSaveLintStyle
52
89
  };
@@ -1,12 +1,13 @@
1
1
  import { jsxs as a, jsx as e, Fragment as p } from "react/jsx-runtime";
2
- import { Search as s, ListTree as i, ZoomOut as d, ChevronsUpDown as h, ChevronsDownUp as m, Keyboard as u } from "lucide-react";
2
+ import { Search as s, ListTree as i, ZoomOut as m, ChevronsUpDown as d, ChevronsDownUp as h, Keyboard as u } from "lucide-react";
3
3
  import { Popover as l, PopoverContent as r } from "../../ui/popover.js";
4
4
  import { keyLabels as b } from "../shortcuts.js";
5
5
  import { ToolButton as n } from "../toolbar-kit.js";
6
6
  import { FindPanel as C } from "./FindPanel.js";
7
7
  import { ShortcutSheet as f } from "./ShortcutSheet.js";
8
+ import { ZoomRow as g } from "./ZoomControls.js";
8
9
  const t = (o) => b(o).join("");
9
- function F({ find: o }) {
10
+ function S({ find: o }) {
10
11
  return /* @__PURE__ */ a(l, { open: o.open, onOpenChange: o.onOpenChange, children: [
11
12
  /* @__PURE__ */ e(
12
13
  n,
@@ -33,7 +34,7 @@ function F({ find: o }) {
33
34
  )
34
35
  ] });
35
36
  }
36
- function N({ outline: o }) {
37
+ function T({ outline: o }) {
37
38
  return o ? /* @__PURE__ */ e(
38
39
  n,
39
40
  {
@@ -47,13 +48,14 @@ function N({ outline: o }) {
47
48
  }
48
49
  ) : null;
49
50
  }
50
- function S({ view: o }) {
51
+ function A({ view: o }) {
51
52
  return o ? /* @__PURE__ */ a(p, { children: [
53
+ o.zoom && /* @__PURE__ */ e(g, { zoom: o.zoom }),
52
54
  /* @__PURE__ */ e(
53
55
  n,
54
56
  {
55
57
  label: "Compact canvas",
56
- icon: /* @__PURE__ */ e(d, { className: "h-4 w-4" }),
58
+ icon: /* @__PURE__ */ e(m, { className: "h-4 w-4" }),
57
59
  hint: "Smaller spacing and inputs, here only",
58
60
  checked: o.compact,
59
61
  onClick: () => o.onCompact(!o.compact),
@@ -64,7 +66,7 @@ function S({ view: o }) {
64
66
  n,
65
67
  {
66
68
  label: "Expand all",
67
- icon: /* @__PURE__ */ e(h, { className: "h-4 w-4" }),
69
+ icon: /* @__PURE__ */ e(d, { className: "h-4 w-4" }),
68
70
  hint: "Every step and tab shown",
69
71
  onClick: o.onExpandAll,
70
72
  data: { "data-editor-expand-all": "" }
@@ -74,14 +76,14 @@ function S({ view: o }) {
74
76
  n,
75
77
  {
76
78
  label: "Collapse all",
77
- icon: /* @__PURE__ */ e(m, { className: "h-4 w-4" }),
79
+ icon: /* @__PURE__ */ e(h, { className: "h-4 w-4" }),
78
80
  onClick: o.onCollapseAll,
79
81
  data: { "data-editor-collapse-all": "" }
80
82
  }
81
83
  )
82
84
  ] }) : null;
83
85
  }
84
- function T({ shortcuts: o }) {
86
+ function P({ shortcuts: o }) {
85
87
  return /* @__PURE__ */ a(l, { open: o.open, onOpenChange: o.onOpenChange, children: [
86
88
  /* @__PURE__ */ e(
87
89
  n,
@@ -107,8 +109,8 @@ function T({ shortcuts: o }) {
107
109
  ] });
108
110
  }
109
111
  export {
110
- F as FindTool,
111
- N as OutlineTool,
112
- T as ShortcutsTool,
113
- S as ViewTools
112
+ S as FindTool,
113
+ T as OutlineTool,
114
+ P as ShortcutsTool,
115
+ A as ViewTools
114
116
  };
@@ -0,0 +1,145 @@
1
+ import { jsxs as a, jsx as t, Fragment as h } from "react/jsx-runtime";
2
+ import { Maximize2 as d, Minus as x, Plus as b } from "lucide-react";
3
+ import { createPortal as f } from "react-dom";
4
+ import { cn as v } from "../../../lib/utils.js";
5
+ import { useBarMenu as g } from "../toolbar-kit.js";
6
+ import { ZOOM_STEP as r, ZOOM_MAX as c, ZOOM_MIN as u } from "./view-prefs.js";
7
+ const o = (e) => `${Math.round(e * 100)}%`, i = "inline-flex h-6 w-6 shrink-0 items-center justify-center rounded text-slate-600 transition-colors hover:bg-muted hover:text-slate-900 disabled:pointer-events-none disabled:opacity-40 dark:text-muted-foreground dark:hover:text-foreground", s = "inline-flex h-6 shrink-0 items-center gap-1 rounded px-1.5 text-[12px] font-medium text-slate-700 transition-colors hover:bg-muted dark:text-foreground";
8
+ function m({ zoom: e }) {
9
+ return /* @__PURE__ */ a(h, { children: [
10
+ /* @__PURE__ */ t(
11
+ "button",
12
+ {
13
+ type: "button",
14
+ "aria-label": "Zoom out",
15
+ "data-tip": "Zoom out",
16
+ "data-zoom-out": "",
17
+ disabled: e.value <= u,
18
+ onClick: () => e.onChange(e.value - r * 2),
19
+ className: i,
20
+ children: /* @__PURE__ */ t(x, { className: "h-3.5 w-3.5" })
21
+ }
22
+ ),
23
+ /* @__PURE__ */ t(
24
+ "button",
25
+ {
26
+ type: "button",
27
+ "aria-label": "Zoom in",
28
+ "data-tip": "Zoom in",
29
+ "data-zoom-in": "",
30
+ disabled: e.value >= c,
31
+ onClick: () => e.onChange(e.value + r * 2),
32
+ className: i,
33
+ children: /* @__PURE__ */ t(b, { className: "h-3.5 w-3.5" })
34
+ }
35
+ )
36
+ ] });
37
+ }
38
+ function M({ zoom: e }) {
39
+ const n = g(), l = /* @__PURE__ */ a(
40
+ "div",
41
+ {
42
+ "data-editor-zoom": "",
43
+ className: "flex shrink-0 flex-col gap-1.5 rounded-md px-2 py-1.5 text-[12.5px] text-slate-700 dark:text-foreground",
44
+ children: [
45
+ /* @__PURE__ */ a("div", { className: "flex items-center justify-between gap-2", children: [
46
+ /* @__PURE__ */ t("span", { className: "font-medium text-slate-900 dark:text-foreground", children: "Zoom" }),
47
+ /* @__PURE__ */ t(
48
+ "span",
49
+ {
50
+ "data-zoom-value": "",
51
+ className: "tabular-nums text-[12px] text-slate-500 dark:text-muted-foreground",
52
+ children: o(e.value)
53
+ }
54
+ )
55
+ ] }),
56
+ /* @__PURE__ */ a("div", { className: "flex items-center gap-1", children: [
57
+ /* @__PURE__ */ t(m, { zoom: e }),
58
+ /* @__PURE__ */ t(
59
+ "input",
60
+ {
61
+ type: "range",
62
+ "aria-label": "Canvas zoom",
63
+ "aria-valuetext": o(e.value),
64
+ "data-zoom-slider": "",
65
+ min: u,
66
+ max: c,
67
+ step: r,
68
+ value: e.value,
69
+ onChange: (p) => e.onChange(Number(p.target.value)),
70
+ className: "h-1.5 min-w-0 flex-1 cursor-pointer accent-nvr-cyan"
71
+ }
72
+ )
73
+ ] }),
74
+ /* @__PURE__ */ a("div", { className: "flex items-center gap-1", children: [
75
+ /* @__PURE__ */ a(
76
+ "button",
77
+ {
78
+ type: "button",
79
+ "data-zoom-fit": "",
80
+ "data-tip": "Fit the form’s width to the canvas",
81
+ onClick: e.onFit,
82
+ className: s,
83
+ children: [
84
+ /* @__PURE__ */ t(d, { className: "h-3 w-3" }),
85
+ "Fit to screen"
86
+ ]
87
+ }
88
+ ),
89
+ /* @__PURE__ */ t(
90
+ "button",
91
+ {
92
+ type: "button",
93
+ "data-zoom-reset": "",
94
+ disabled: e.value === 1,
95
+ onClick: () => e.onChange(1),
96
+ className: v(s, "disabled:pointer-events-none disabled:opacity-40"),
97
+ children: "100%"
98
+ }
99
+ )
100
+ ] })
101
+ ]
102
+ }
103
+ );
104
+ return n ? !n.open || !n.list ? null : f(l, n.list) : l;
105
+ }
106
+ function F({ zoom: e }) {
107
+ return e.value === 1 ? null : /* @__PURE__ */ a(
108
+ "fieldset",
109
+ {
110
+ "data-zoom-chip": "",
111
+ "aria-label": "Canvas zoom",
112
+ className: "sticky bottom-3 z-30 -mt-10 mb-3 mr-3 flex h-7 min-w-0 items-center gap-0.5 self-end rounded-md border border-slate-200 bg-white px-1 shadow-sm dark:border-border dark:bg-card",
113
+ children: [
114
+ /* @__PURE__ */ t(m, { zoom: e }),
115
+ /* @__PURE__ */ t("span", { className: "min-w-[3ch] px-1 text-center text-[12px] tabular-nums text-slate-700 dark:text-foreground", children: o(e.value) }),
116
+ /* @__PURE__ */ t(
117
+ "button",
118
+ {
119
+ type: "button",
120
+ "aria-label": "Fit to screen",
121
+ "data-tip": "Fit the form’s width to the canvas",
122
+ onClick: e.onFit,
123
+ className: i,
124
+ children: /* @__PURE__ */ t(d, { className: "h-3 w-3" })
125
+ }
126
+ ),
127
+ /* @__PURE__ */ t(
128
+ "button",
129
+ {
130
+ type: "button",
131
+ "data-zoom-chip-reset": "",
132
+ "data-tip": "Back to 100%",
133
+ onClick: () => e.onChange(1),
134
+ className: s,
135
+ children: "100%"
136
+ }
137
+ )
138
+ ]
139
+ }
140
+ );
141
+ }
142
+ export {
143
+ F as ZoomChip,
144
+ M as ZoomRow
145
+ };
@@ -1,89 +1,89 @@
1
- import { useState as l, useRef as h, useMemo as S, useCallback as y, useEffect as j } from "react";
2
- import { toast as z } from "sonner";
3
- import { targetKey as B } from "../design-context.js";
4
- import { isTyping as G } from "../is-typing.js";
5
- import { buildOutline as J } from "./tree.js";
6
- import { useViewPref as A } from "./view-prefs.js";
7
- function Q(a, s, f, d) {
1
+ import { useState as a, useRef as C, useMemo as S, useCallback as y, useEffect as j } from "react";
2
+ import { toast as B } from "sonner";
3
+ import { targetKey as G } from "../design-context.js";
4
+ import { isTyping as J } from "../is-typing.js";
5
+ import { buildOutline as Q } from "./tree.js";
6
+ import { useViewPref as A, useCanvasZoom as U } from "./view-prefs.js";
7
+ function W(l, s, f, d) {
8
8
  let r = 0;
9
9
  const c = () => {
10
10
  const i = document.querySelector(
11
- `[data-layout-editor] [data-editor-canvas] [data-design-target="${CSS.escape(a)}"]`
11
+ `[data-layout-editor] [data-editor-canvas] [data-design-target="${CSS.escape(l)}"]`
12
12
  );
13
13
  if (i) return f(i);
14
14
  r++, d(r), r < s && window.setTimeout(c, 120);
15
15
  };
16
16
  requestAnimationFrame(c);
17
17
  }
18
- function te({
19
- bodyRef: a,
18
+ function re({
19
+ bodyRef: l,
20
20
  bundle: s,
21
21
  parent: f,
22
22
  fields: d,
23
23
  onSelect: r,
24
24
  showHidden: c,
25
25
  setShowHidden: i,
26
- canvasShown: C
26
+ canvasShown: h
27
27
  }) {
28
- const [_, b] = l(null), [L, x] = l(null), [D, p] = l(!1), [H, M] = l(0), [P, k] = l(!1), [R, T] = A("outline"), [V, I] = A("compact"), m = h(0), K = h(c);
28
+ const [_, b] = a(null), [L, x] = a(null), [D, m] = a(!1), [H, M] = a(0), [P, k] = a(!1), [R, T] = A("outline"), [V, Z] = A("compact"), [z, I] = U(), p = C(0), K = C(c);
29
29
  K.current = c;
30
30
  const q = S(() => {
31
31
  const t = new Map(d.map((e) => [e.field, e.label ?? null]));
32
32
  return (e) => t.get(e);
33
33
  }, [d]), E = S(
34
- () => s ? J(s, f, q) : [],
34
+ () => s ? Q(s, f, q) : [],
35
35
  [s, f, q]
36
- ), w = y(
36
+ ), v = y(
37
37
  (t, e) => {
38
- if (r(t, e), m.current += 1, x({ target: t, seq: m.current }), !C) return;
38
+ if (r(t, e), p.current += 1, x({ target: t, seq: p.current }), !h) return;
39
39
  const n = (t.kind === "field" || t.kind === "slot" && t.group_key !== null) && t.field !== "__subtitle__";
40
40
  let g = !1;
41
- Q(
42
- B(t),
41
+ W(
42
+ G(t),
43
43
  14,
44
44
  (o) => {
45
45
  var u;
46
46
  (u = o.scrollIntoView) == null || u.call(o, { block: "center" }), e != null && e.focus && o.focus({ preventScroll: !0 });
47
47
  },
48
48
  (o) => {
49
- o === 4 && n && !K.current && !g && (g = !0, i(!0), z.info("Show hidden is on: what you picked is hidden on this form"));
49
+ o === 4 && n && !K.current && !g && (g = !0, i(!0), B.info("Show hidden is on: what you picked is hidden on this form"));
50
50
  }
51
51
  );
52
52
  },
53
- [r, i, C]
54
- ), v = h(!1), N = y((t) => {
55
- v.current && (v.current = !1, t.preventDefault());
53
+ [r, i, h]
54
+ ), w = C(!1), N = y((t) => {
55
+ w.current && (w.current = !1, t.preventDefault());
56
56
  }, []), $ = y(
57
57
  (t) => {
58
- t.node.target && (v.current = !0, p(!1), w(t.node.target, { focus: !0 }));
58
+ t.node.target && (w.current = !0, m(!1), v(t.node.target, { focus: !0 }));
59
59
  },
60
- [w]
60
+ [v]
61
61
  ), F = y((t) => {
62
- m.current += 1, b({ open: t, seq: m.current });
62
+ p.current += 1, b({ open: t, seq: p.current });
63
63
  }, []);
64
64
  return j(() => {
65
65
  const t = (e) => {
66
66
  var o, u;
67
67
  const n = e.target instanceof HTMLElement ? e.target : null;
68
- if (!(!(!n || n === document.body || n === document.documentElement || (o = a.current) != null && o.contains(n) || (u = n.closest) != null && u.call(n, "[data-radix-popper-content-wrapper]")) || e.defaultPrevented)) {
68
+ if (!(!(!n || n === document.body || n === document.documentElement || (o = l.current) != null && o.contains(n) || (u = n.closest) != null && u.call(n, "[data-radix-popper-content-wrapper]")) || e.defaultPrevented)) {
69
69
  if ((e.metaKey || e.ctrlKey) && !e.altKey && !e.shiftKey && e.key.toLowerCase() === "f") {
70
- e.preventDefault(), k(!1), p(!0), M((O) => O + 1);
70
+ e.preventDefault(), k(!1), m(!0), M((O) => O + 1);
71
71
  return;
72
72
  }
73
- e.key === "?" && !e.metaKey && !e.ctrlKey && !e.altKey && !G(n) && (e.preventDefault(), p(!1), k((O) => !O));
73
+ e.key === "?" && !e.metaKey && !e.ctrlKey && !e.altKey && !J(n) && (e.preventDefault(), m(!1), k((O) => !O));
74
74
  }
75
75
  };
76
76
  return window.addEventListener("keydown", t), () => window.removeEventListener("keydown", t);
77
- }, [a]), {
77
+ }, [l]), {
78
78
  nodes: E,
79
79
  fold: _,
80
80
  reveal: L,
81
- selectAndReveal: w,
81
+ selectAndReveal: v,
82
82
  expandAll: () => F(!0),
83
83
  collapseAll: () => F(!1),
84
84
  find: {
85
85
  open: D,
86
- onOpenChange: p,
86
+ onOpenChange: m,
87
87
  nodes: E,
88
88
  onPick: $,
89
89
  focusSeq: H,
@@ -93,9 +93,11 @@ function te({
93
93
  outlineOpen: R,
94
94
  setOutlineOpen: T,
95
95
  compact: V,
96
- setCompact: I
96
+ setCompact: Z,
97
+ zoom: z,
98
+ setZoom: I
97
99
  };
98
100
  }
99
101
  export {
100
- te as useEditorNav
102
+ re as useEditorNav
101
103
  };
@@ -1,34 +1,119 @@
1
- import { useState as a, useCallback as l } from "react";
2
- const o = {
1
+ import { useState as m, useCallback as S, useSyncExternalStore as y } from "react";
2
+ const a = {
3
3
  compact: "nvr_layout_editor_compact",
4
4
  outline: "nvr_layout_editor_outline"
5
5
  };
6
- function i(t) {
6
+ function M(t) {
7
7
  try {
8
- return localStorage.getItem(o[t]) === "1";
8
+ return localStorage.getItem(a[t]) === "1";
9
9
  } catch {
10
10
  return !1;
11
11
  }
12
12
  }
13
- function u(t, e) {
13
+ function h(t, e) {
14
14
  try {
15
- e ? localStorage.setItem(o[t], "1") : localStorage.removeItem(o[t]);
15
+ e ? localStorage.setItem(a[t], "1") : localStorage.removeItem(a[t]);
16
16
  } catch {
17
17
  }
18
18
  }
19
- function f(t) {
20
- const [e, c] = a(() => i(t)), n = l(
19
+ function N(t) {
20
+ const [e, n] = m(() => M(t)), o = S(
21
21
  (r) => {
22
- c(r), u(t, r);
22
+ n(r), h(t, r);
23
23
  },
24
24
  [t]
25
25
  );
26
- return [e, n];
26
+ return [e, o];
27
+ }
28
+ const g = 0.8, u = "nvr_layout_editor_zoom", O = 0.3, w = 1.5, i = 0.05;
29
+ function f(t) {
30
+ if (!Number.isFinite(t) || t <= 0) return 1;
31
+ const e = Math.round(t / i) * i;
32
+ return Math.round(Math.min(w, Math.max(O, e)) * 100) / 100;
33
+ }
34
+ function v() {
35
+ try {
36
+ const t = localStorage.getItem(u);
37
+ return t == null ? 1 : f(Number(t));
38
+ } catch {
39
+ return 1;
40
+ }
41
+ }
42
+ function E() {
43
+ const [t, e] = m(v), n = S((o) => {
44
+ const r = f(o);
45
+ e(r);
46
+ try {
47
+ r === 1 ? localStorage.removeItem(u) : localStorage.setItem(u, String(r));
48
+ } catch {
49
+ }
50
+ }, []);
51
+ return [t, n];
52
+ }
53
+ function b(t, e) {
54
+ return Math.round(t * (e ? g : 1) * 1e3) / 1e3;
55
+ }
56
+ function A(t, e, n) {
57
+ if (!e || e <= 0 || !t || t <= 0) return 1;
58
+ const o = n ? g : 1, r = Math.floor(t / e / o * 1e3 / (i * 1e3)) * i;
59
+ return f(Math.min(1, r));
60
+ }
61
+ const s = "nvr_layout_editor_pinned_settings", d = 60;
62
+ let c = null;
63
+ const l = /* @__PURE__ */ new Set();
64
+ function _() {
65
+ if (c) return c;
66
+ let t = [];
67
+ try {
68
+ const e = localStorage.getItem(s), n = e ? JSON.parse(e) : [];
69
+ Array.isArray(n) && (t = [...new Set(n.filter((o) => typeof o == "string" && !!o))].slice(
70
+ 0,
71
+ d
72
+ ));
73
+ } catch {
74
+ t = [];
75
+ }
76
+ return c = t, t;
77
+ }
78
+ function I(t) {
79
+ c = t.slice(0, d);
80
+ try {
81
+ c.length ? localStorage.setItem(s, JSON.stringify(c)) : localStorage.removeItem(s);
82
+ } catch {
83
+ }
84
+ for (const e of l) e();
85
+ }
86
+ function C(t) {
87
+ const e = _();
88
+ I(e.includes(t) ? e.filter((n) => n !== t) : [...e, t]);
89
+ }
90
+ function P(t) {
91
+ l.add(t);
92
+ const e = (n) => {
93
+ n.key === s && (c = null, t());
94
+ };
95
+ return window.addEventListener("storage", e), () => {
96
+ l.delete(t), window.removeEventListener("storage", e);
97
+ };
98
+ }
99
+ const Z = [];
100
+ function x() {
101
+ return y(P, _, () => Z);
27
102
  }
28
- const m = 0.8;
29
103
  export {
30
- m as COMPACT_ZOOM,
31
- i as readViewPref,
32
- f as useViewPref,
33
- u as writeViewPref
104
+ g as COMPACT_ZOOM,
105
+ d as PINS_MAX,
106
+ w as ZOOM_MAX,
107
+ O as ZOOM_MIN,
108
+ i as ZOOM_STEP,
109
+ f as clampZoom,
110
+ b as effectiveZoom,
111
+ A as fitZoom,
112
+ M as readViewPref,
113
+ v as readZoom,
114
+ C as togglePinnedSetting,
115
+ E as useCanvasZoom,
116
+ x as usePinnedSettings,
117
+ N as useViewPref,
118
+ h as writeViewPref
34
119
  };