@questpie/admin 3.2.3 → 3.2.5

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 (244) hide show
  1. package/dist/client/blocks/block-renderer.d.mts +2 -2
  2. package/dist/client/blocks/block-renderer.mjs +164 -339
  3. package/dist/client/components/actions/action-button.mjs +9 -9
  4. package/dist/client/components/actions/action-dialog.mjs +195 -493
  5. package/dist/client/components/actions/confirmation-dialog.mjs +44 -159
  6. package/dist/client/components/actions/header-actions.mjs +73 -165
  7. package/dist/client/components/admin-link.d.mts +2 -2
  8. package/dist/client/components/admin-link.mjs +40 -126
  9. package/dist/client/components/auth/auth-loading.mjs +9 -44
  10. package/dist/client/components/blocks/block-canvas.mjs +31 -95
  11. package/dist/client/components/blocks/block-editor-context.mjs +13 -57
  12. package/dist/client/components/blocks/block-editor-layout.mjs +72 -166
  13. package/dist/client/components/blocks/block-editor-provider.mjs +184 -245
  14. package/dist/client/components/blocks/block-fields-renderer.mjs +54 -229
  15. package/dist/client/components/blocks/block-insert-button.mjs +49 -165
  16. package/dist/client/components/blocks/block-item-menu.mjs +102 -301
  17. package/dist/client/components/blocks/block-item.mjs +136 -370
  18. package/dist/client/components/blocks/block-library-sidebar.mjs +106 -220
  19. package/dist/client/components/blocks/block-tree.mjs +12 -68
  20. package/dist/client/components/blocks/block-type-icon.mjs +14 -56
  21. package/dist/client/components/brand-logo.mjs +35 -149
  22. package/dist/client/components/component-renderer.mjs +42 -118
  23. package/dist/client/components/error-boundary.mjs +14 -58
  24. package/dist/client/components/fields/array-field.mjs +209 -521
  25. package/dist/client/components/fields/asset-preview-field.mjs +41 -141
  26. package/dist/client/components/fields/blocks-field/blocks-field.mjs +60 -156
  27. package/dist/client/components/fields/boolean-field.mjs +29 -59
  28. package/dist/client/components/fields/date-field.mjs +7 -37
  29. package/dist/client/components/fields/datetime-field.mjs +7 -38
  30. package/dist/client/components/fields/email-field.mjs +25 -54
  31. package/dist/client/components/fields/field-wrapper.mjs +30 -105
  32. package/dist/client/components/fields/json-field.mjs +107 -313
  33. package/dist/client/components/fields/locale-badge.mjs +6 -15
  34. package/dist/client/components/fields/number-field.mjs +27 -60
  35. package/dist/client/components/fields/object-array-field.mjs +283 -659
  36. package/dist/client/components/fields/object-field.mjs +165 -633
  37. package/dist/client/components/fields/relation/displays/cards-display.mjs +106 -220
  38. package/dist/client/components/fields/relation/displays/chips-display.mjs +78 -150
  39. package/dist/client/components/fields/relation/displays/grid-display.mjs +92 -186
  40. package/dist/client/components/fields/relation/displays/list-display.mjs +122 -239
  41. package/dist/client/components/fields/relation/displays/table-display.mjs +70 -244
  42. package/dist/client/components/fields/relation/relation-items-display.mjs +30 -126
  43. package/dist/client/components/fields/relation-field.mjs +10 -66
  44. package/dist/client/components/fields/relation-picker.mjs +18 -18
  45. package/dist/client/components/fields/relation-select.mjs +12 -12
  46. package/dist/client/components/fields/rich-text-editor/bubble-menu.mjs +80 -182
  47. package/dist/client/components/fields/rich-text-editor/image-popover.mjs +8 -19
  48. package/dist/client/components/fields/rich-text-editor/image-upload.mjs +13 -29
  49. package/dist/client/components/fields/rich-text-editor/index.mjs +196 -530
  50. package/dist/client/components/fields/rich-text-editor/slash-commands.mjs +61 -111
  51. package/dist/client/components/fields/rich-text-editor/table-controls.mjs +105 -415
  52. package/dist/client/components/fields/rich-text-editor/toolbar.mjs +256 -511
  53. package/dist/client/components/fields/rich-text-field.mjs +14 -53
  54. package/dist/client/components/fields/select-field.mjs +39 -74
  55. package/dist/client/components/fields/text-field.mjs +26 -59
  56. package/dist/client/components/fields/textarea-field.mjs +26 -58
  57. package/dist/client/components/fields/time-field.mjs +7 -35
  58. package/dist/client/components/fields/upload-field.mjs +47 -165
  59. package/dist/client/components/filter-builder/columns-tab.mjs +80 -280
  60. package/dist/client/components/filter-builder/filter-builder-sheet.mjs +197 -540
  61. package/dist/client/components/filter-builder/filters-tab.mjs +96 -386
  62. package/dist/client/components/filter-builder/saved-views-tab.mjs +133 -351
  63. package/dist/client/components/history-sidebar.mjs +306 -611
  64. package/dist/client/components/layout/field-layout-renderer.mjs +106 -254
  65. package/dist/client/components/locale-switcher.mjs +106 -228
  66. package/dist/client/components/media/media-grid.mjs +84 -273
  67. package/dist/client/components/media/media-picker-dialog.mjs +177 -494
  68. package/dist/client/components/preview/live-preview-mode.mjs +240 -438
  69. package/dist/client/components/preview/preview-pane.mjs +22 -22
  70. package/dist/client/components/primitives/asset-preview.mjs +290 -666
  71. package/dist/client/components/primitives/checkbox-input.mjs +9 -35
  72. package/dist/client/components/primitives/date-input.mjs +109 -327
  73. package/dist/client/components/primitives/dropzone.mjs +209 -336
  74. package/dist/client/components/primitives/field-select-control.mjs +12 -80
  75. package/dist/client/components/primitives/number-input.mjs +4 -4
  76. package/dist/client/components/primitives/select-multi.mjs +200 -559
  77. package/dist/client/components/primitives/select-single.mjs +165 -499
  78. package/dist/client/components/primitives/time-input.mjs +43 -117
  79. package/dist/client/components/primitives/toggle-input.mjs +9 -29
  80. package/dist/client/components/sheets/resource-sheet.mjs +61 -70
  81. package/dist/client/components/ui/accordion.mjs +35 -155
  82. package/dist/client/components/ui/alert.mjs +13 -68
  83. package/dist/client/components/ui/badge.mjs +9 -51
  84. package/dist/client/components/ui/button.mjs +8 -54
  85. package/dist/client/components/ui/card.mjs +37 -193
  86. package/dist/client/components/ui/checkbox.mjs +12 -68
  87. package/dist/client/components/ui/command.mjs +48 -219
  88. package/dist/client/components/ui/dialog.mjs +50 -262
  89. package/dist/client/components/ui/drawer.mjs +55 -259
  90. package/dist/client/components/ui/dropdown-menu.mjs +86 -427
  91. package/dist/client/components/ui/empty-state.mjs +28 -98
  92. package/dist/client/components/ui/field.mjs +73 -309
  93. package/dist/client/components/ui/input-group.mjs +42 -167
  94. package/dist/client/components/ui/input.mjs +7 -37
  95. package/dist/client/components/ui/kbd.mjs +6 -36
  96. package/dist/client/components/ui/label.mjs +7 -37
  97. package/dist/client/components/ui/popover.mjs +34 -169
  98. package/dist/client/components/ui/responsive-dialog.mjs +67 -273
  99. package/dist/client/components/ui/scroll-fade.mjs +63 -158
  100. package/dist/client/components/ui/search-input.mjs +33 -100
  101. package/dist/client/components/ui/select.mjs +72 -393
  102. package/dist/client/components/ui/separator.mjs +7 -38
  103. package/dist/client/components/ui/sheet.mjs +49 -269
  104. package/dist/client/components/ui/sidebar.mjs +171 -690
  105. package/dist/client/components/ui/skeleton.mjs +7 -38
  106. package/dist/client/components/ui/sonner.mjs +11 -42
  107. package/dist/client/components/ui/switch.mjs +9 -45
  108. package/dist/client/components/ui/table.mjs +48 -266
  109. package/dist/client/components/ui/tabs.mjs +26 -139
  110. package/dist/client/components/ui/textarea.mjs +6 -32
  111. package/dist/client/components/ui/tooltip.mjs +27 -129
  112. package/dist/client/components/widgets/chart-widget.mjs +174 -522
  113. package/dist/client/components/widgets/progress-widget.mjs +66 -172
  114. package/dist/client/components/widgets/quick-actions-widget.mjs +102 -261
  115. package/dist/client/components/widgets/recent-items-widget.mjs +69 -195
  116. package/dist/client/components/widgets/stats-widget.mjs +41 -175
  117. package/dist/client/components/widgets/table-widget.mjs +9 -9
  118. package/dist/client/components/widgets/timeline-widget.mjs +86 -226
  119. package/dist/client/components/widgets/value-widget.mjs +74 -381
  120. package/dist/client/components/widgets/widget-empty-state.mjs +26 -76
  121. package/dist/client/components/widgets/widget-skeletons.mjs +138 -421
  122. package/dist/client/contexts/focus-context.d.mts +4 -0
  123. package/dist/client/contexts/focus-context.mjs +87 -150
  124. package/dist/client/hooks/typed-hooks.mjs +241 -701
  125. package/dist/client/hooks/use-action.mjs +62 -198
  126. package/dist/client/hooks/use-admin-config.mjs +5 -35
  127. package/dist/client/hooks/use-admin-preferences.mjs +16 -88
  128. package/dist/client/hooks/use-admin-routes.mjs +22 -56
  129. package/dist/client/hooks/use-audit-history.mjs +21 -69
  130. package/dist/client/hooks/use-brand.mjs +1 -9
  131. package/dist/client/hooks/use-collection-fields.mjs +17 -57
  132. package/dist/client/hooks/use-collection-meta.mjs +12 -44
  133. package/dist/client/hooks/use-collection-schema.mjs +10 -33
  134. package/dist/client/hooks/use-collection-validation.mjs +23 -53
  135. package/dist/client/hooks/use-collection.mjs +194 -614
  136. package/dist/client/hooks/use-current-user.mjs +0 -1
  137. package/dist/client/hooks/use-field-hooks.mjs +10 -10
  138. package/dist/client/hooks/use-field-options.mjs +61 -202
  139. package/dist/client/hooks/use-global-fields.mjs +14 -46
  140. package/dist/client/hooks/use-global-meta.mjs +9 -30
  141. package/dist/client/hooks/use-global-schema.mjs +9 -30
  142. package/dist/client/hooks/use-global.mjs +63 -219
  143. package/dist/client/hooks/use-locks.mjs +117 -325
  144. package/dist/client/hooks/use-media-query.mjs +16 -36
  145. package/dist/client/hooks/use-prefill-params.mjs +0 -1
  146. package/dist/client/hooks/use-questpie-query-options.mjs +12 -29
  147. package/dist/client/hooks/use-reactive-fields.mjs +1 -1
  148. package/dist/client/hooks/use-reactive-prop.mjs +65 -223
  149. package/dist/client/hooks/use-realtime-highlight.mjs +51 -114
  150. package/dist/client/hooks/use-saved-views.mjs +22 -103
  151. package/dist/client/hooks/use-search-param-toggle.mjs +28 -79
  152. package/dist/client/hooks/use-search.mjs +31 -143
  153. package/dist/client/hooks/use-server-actions.mjs +18 -50
  154. package/dist/client/hooks/use-server-validation.mjs +72 -166
  155. package/dist/client/hooks/use-server-widget-data.mjs +7 -33
  156. package/dist/client/hooks/use-setup-status.mjs +12 -25
  157. package/dist/client/hooks/use-sidebar-search-param.mjs +33 -78
  158. package/dist/client/hooks/use-transition-stage.mjs +8 -38
  159. package/dist/client/hooks/use-upload.mjs +54 -152
  160. package/dist/client/hooks/use-validation-error-map.mjs +6 -26
  161. package/dist/client/hooks/use-view-state.mjs +187 -437
  162. package/dist/client/i18n/hooks.mjs +65 -197
  163. package/dist/client/lib/render-profiler.mjs +14 -41
  164. package/dist/client/preview/block-scope-context.d.mts +2 -2
  165. package/dist/client/preview/block-scope-context.mjs +14 -36
  166. package/dist/client/preview/diff.mjs +110 -0
  167. package/dist/client/preview/preview-banner.mjs +42 -108
  168. package/dist/client/preview/preview-field.d.mts +4 -4
  169. package/dist/client/preview/preview-field.mjs +166 -409
  170. package/dist/client/preview/use-collection-preview.mjs +135 -201
  171. package/dist/client/runtime/content-locales-provider.mjs +31 -83
  172. package/dist/client/runtime/locale-scope.mjs +22 -63
  173. package/dist/client/runtime/provider.mjs +100 -255
  174. package/dist/client/runtime/translations-provider.mjs +41 -107
  175. package/dist/client/scope/picker.d.mts +2 -2
  176. package/dist/client/scope/picker.mjs +86 -321
  177. package/dist/client/scope/provider.d.mts +2 -2
  178. package/dist/client/scope/provider.mjs +8 -17
  179. package/dist/client/views/auth/accept-invite-form.d.mts +2 -2
  180. package/dist/client/views/auth/accept-invite-form.mjs +121 -412
  181. package/dist/client/views/auth/auth-layout.d.mts +3 -3
  182. package/dist/client/views/auth/auth-layout.mjs +104 -284
  183. package/dist/client/views/auth/forgot-password-form.d.mts +2 -2
  184. package/dist/client/views/auth/forgot-password-form.mjs +94 -325
  185. package/dist/client/views/auth/invite-form.mjs +107 -442
  186. package/dist/client/views/auth/login-form.d.mts +2 -2
  187. package/dist/client/views/auth/login-form.mjs +116 -337
  188. package/dist/client/views/auth/reset-password-form.mjs +128 -453
  189. package/dist/client/views/auth/setup-form.mjs +140 -478
  190. package/dist/client/views/collection/auto-form-fields.mjs +243 -615
  191. package/dist/client/views/collection/bulk-action-toolbar.mjs +212 -400
  192. package/dist/client/views/collection/cells/complex-cells.mjs +183 -611
  193. package/dist/client/views/collection/cells/primitive-cells.mjs +109 -363
  194. package/dist/client/views/collection/cells/relation-cells.mjs +86 -233
  195. package/dist/client/views/collection/cells/shared/asset-thumbnail.mjs +142 -371
  196. package/dist/client/views/collection/cells/shared/relation-chip.mjs +35 -131
  197. package/dist/client/views/collection/cells/upload-cells.mjs +60 -177
  198. package/dist/client/views/collection/columns/build-columns.mjs +8 -48
  199. package/dist/client/views/collection/field-renderer.mjs +11 -24
  200. package/dist/client/views/collection/form-view.mjs +288 -560
  201. package/dist/client/views/collection/table-view.mjs +239 -469
  202. package/dist/client/views/collection/view-skeletons.mjs +112 -237
  203. package/dist/client/views/common/global-search.mjs +241 -543
  204. package/dist/client/views/dashboard/dashboard-grid.mjs +256 -775
  205. package/dist/client/views/dashboard/dashboard-widget.mjs +38 -126
  206. package/dist/client/views/dashboard/widget-card.mjs +61 -269
  207. package/dist/client/views/globals/global-form-view.mjs +478 -1298
  208. package/dist/client/views/layout/admin-layout-provider.mjs +28 -88
  209. package/dist/client/views/layout/admin-layout.mjs +83 -246
  210. package/dist/client/views/layout/admin-router.mjs +457 -1289
  211. package/dist/client/views/layout/admin-sidebar.mjs +510 -1292
  212. package/dist/client/views/layout/admin-theme.mjs +30 -64
  213. package/dist/client/views/layout/admin-view-layout.mjs +40 -144
  214. package/dist/client/views/pages/accept-invite-page.mjs +95 -290
  215. package/dist/client/views/pages/dashboard-page.mjs +11 -57
  216. package/dist/client/views/pages/forgot-password-page.mjs +31 -83
  217. package/dist/client/views/pages/invite-page.mjs +35 -90
  218. package/dist/client/views/pages/login-page.mjs +41 -121
  219. package/dist/client/views/pages/reset-password-page.d.mts +2 -2
  220. package/dist/client/views/pages/reset-password-page.mjs +46 -173
  221. package/dist/client/views/pages/setup-page.d.mts +2 -2
  222. package/dist/client/views/pages/setup-page.mjs +33 -95
  223. package/dist/components/rich-text/rich-text-renderer.d.mts +2 -2
  224. package/dist/components/rich-text/rich-text-renderer.mjs +9 -33
  225. package/dist/server/modules/admin/collections/account.d.mts +50 -50
  226. package/dist/server/modules/admin/collections/admin-locks.d.mts +54 -54
  227. package/dist/server/modules/admin/collections/admin-preferences.d.mts +39 -39
  228. package/dist/server/modules/admin/collections/admin-saved-views.d.mts +47 -47
  229. package/dist/server/modules/admin/collections/apikey.d.mts +68 -68
  230. package/dist/server/modules/admin/collections/assets.d.mts +34 -34
  231. package/dist/server/modules/admin/collections/session.d.mts +42 -42
  232. package/dist/server/modules/admin/collections/user.d.mts +53 -53
  233. package/dist/server/modules/admin/collections/verification.d.mts +36 -36
  234. package/dist/server/modules/admin/index.d.mts +21 -20
  235. package/dist/server/modules/admin/routes/admin-config.d.mts +2 -2
  236. package/dist/server/modules/admin/routes/execute-action.d.mts +9 -9
  237. package/dist/server/modules/admin/routes/locales.d.mts +2 -2
  238. package/dist/server/modules/admin/routes/preview.d.mts +11 -11
  239. package/dist/server/modules/admin/routes/reactive.d.mts +9 -9
  240. package/dist/server/modules/admin/routes/setup.d.mts +7 -7
  241. package/dist/server/modules/admin/routes/translations.d.mts +4 -4
  242. package/dist/server/modules/admin/routes/widget-data.d.mts +5 -5
  243. package/dist/server/modules/admin-preferences/collections/saved-views.d.mts +27 -27
  244. package/package.json +3 -5
@@ -7,7 +7,6 @@ import { Tabs, TabsList, TabsTrigger } from "../ui/tabs.mjs";
7
7
  import { FocusProvider, parsePreviewFieldPath, scheduleScrollFieldIntoView, useFocus } from "../../contexts/focus-context.mjs";
8
8
  import { useIsMobile } from "../../hooks/use-media-query.mjs";
9
9
  import { PreviewPane } from "./preview-pane.mjs";
10
- import { c } from "react/compiler-runtime";
11
10
  import { Icon } from "@iconify/react";
12
11
  import * as React from "react";
13
12
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
@@ -27,260 +26,169 @@ function getFocusStatePath(state) {
27
26
  if (state.type === "block") return state.fieldPath ? `content._values.${state.blockId}.${state.fieldPath}` : `content._values.${state.blockId}`;
28
27
  return null;
29
28
  }
30
- function useResizablePane(t0, t1, t2) {
31
- const $ = c(9);
32
- const defaultSize = t0 === void 0 ? 50 : t0;
33
- const minSize = t1 === void 0 ? 30 : t1;
34
- const enabled = t2 === void 0 ? true : t2;
29
+ function isPreviewIframeFocused() {
30
+ const activeElement = document.activeElement;
31
+ return activeElement instanceof HTMLIFrameElement || activeElement?.tagName === "IFRAME";
32
+ }
33
+ function useResizablePane(defaultSize = 50, minSize = 30, enabled = true) {
35
34
  const [previewPercent, setPreviewPercent] = React.useState(defaultSize);
36
35
  const isDragging = React.useRef(false);
37
36
  const containerRef = React.useRef(null);
38
- let t3;
39
- if ($[0] !== enabled) {
40
- t3 = (e) => {
41
- if (!enabled) return;
42
- e.preventDefault();
43
- isDragging.current = true;
44
- document.body.style.cursor = "col-resize";
45
- document.body.style.userSelect = "none";
37
+ const previousBodyStyleRef = React.useRef({
38
+ cursor: "",
39
+ userSelect: ""
40
+ });
41
+ const restoreBodyStyle = React.useCallback(() => {
42
+ Object.assign(document.body.style, previousBodyStyleRef.current);
43
+ }, []);
44
+ const handleMouseDown = React.useCallback((e) => {
45
+ if (!enabled) return;
46
+ e.preventDefault();
47
+ isDragging.current = true;
48
+ previousBodyStyleRef.current = {
49
+ cursor: document.body.style.cursor,
50
+ userSelect: document.body.style.userSelect
51
+ };
52
+ Object.assign(document.body.style, {
53
+ cursor: "col-resize",
54
+ userSelect: "none"
55
+ });
56
+ }, [enabled]);
57
+ React.useEffect(() => {
58
+ if (!enabled) return;
59
+ const handleMouseMove = (e) => {
60
+ if (!isDragging.current || !containerRef.current) return;
61
+ const rect = containerRef.current.getBoundingClientRect();
62
+ const formPercent = (e.clientX - rect.left) / rect.width * 100;
63
+ setPreviewPercent(Math.min(100 - minSize, Math.max(minSize, 100 - formPercent)));
46
64
  };
47
- $[0] = enabled;
48
- $[1] = t3;
49
- } else t3 = $[1];
50
- const handleMouseDown = t3;
51
- let t4;
52
- let t5;
53
- if ($[2] !== enabled || $[3] !== minSize) {
54
- t4 = () => {
55
- if (!enabled) return;
56
- const handleMouseMove = (e_0) => {
57
- if (!isDragging.current || !containerRef.current) return;
58
- const rect = containerRef.current.getBoundingClientRect();
59
- const formPercent = (e_0.clientX - rect.left) / rect.width * 100;
60
- setPreviewPercent(Math.min(100 - minSize, Math.max(minSize, 100 - formPercent)));
61
- };
62
- const handleMouseUp = () => {
63
- if (isDragging.current) {
64
- isDragging.current = false;
65
- document.body.style.cursor = "";
66
- document.body.style.userSelect = "";
67
- }
68
- };
69
- window.addEventListener("mousemove", handleMouseMove);
70
- window.addEventListener("mouseup", handleMouseUp);
71
- return () => {
72
- window.removeEventListener("mousemove", handleMouseMove);
73
- window.removeEventListener("mouseup", handleMouseUp);
74
- };
65
+ const handleMouseUp = () => {
66
+ if (isDragging.current) {
67
+ isDragging.current = false;
68
+ restoreBodyStyle();
69
+ }
75
70
  };
76
- t5 = [enabled, minSize];
77
- $[2] = enabled;
78
- $[3] = minSize;
79
- $[4] = t4;
80
- $[5] = t5;
81
- } else {
82
- t4 = $[4];
83
- t5 = $[5];
84
- }
85
- React.useEffect(t4, t5);
86
- let t6;
87
- if ($[6] !== handleMouseDown || $[7] !== previewPercent) {
88
- t6 = {
89
- previewPercent,
90
- containerRef,
91
- handleMouseDown
71
+ window.addEventListener("mousemove", handleMouseMove);
72
+ window.addEventListener("mouseup", handleMouseUp);
73
+ return () => {
74
+ window.removeEventListener("mousemove", handleMouseMove);
75
+ window.removeEventListener("mouseup", handleMouseUp);
76
+ if (isDragging.current) {
77
+ isDragging.current = false;
78
+ restoreBodyStyle();
79
+ }
92
80
  };
93
- $[6] = handleMouseDown;
94
- $[7] = previewPercent;
95
- $[8] = t6;
96
- } else t6 = $[8];
97
- return t6;
81
+ }, [
82
+ enabled,
83
+ minSize,
84
+ restoreBodyStyle
85
+ ]);
86
+ return {
87
+ previewPercent,
88
+ containerRef,
89
+ handleMouseDown
90
+ };
98
91
  }
99
- function useLivePreviewRenderTelemetry(t0) {
100
- const $ = c(4);
101
- const { open, isMobile, activeTab } = t0;
92
+ function useLivePreviewRenderTelemetry({ open, isMobile, activeTab }) {
102
93
  const renderCountRef = React.useRef(0);
103
94
  const startAtRef = React.useRef(0);
104
95
  const lastLogAtRef = React.useRef(0);
105
- let t1;
106
- if ($[0] !== activeTab || $[1] !== isMobile || $[2] !== open) {
107
- t1 = () => {
108
- if (!DEV_TELEMETRY) return;
109
- if (!open) {
110
- renderCountRef.current = 0;
111
- startAtRef.current = 0;
112
- lastLogAtRef.current = 0;
113
- return;
114
- }
115
- const now = performance.now();
116
- if (!startAtRef.current) startAtRef.current = now;
117
- renderCountRef.current = renderCountRef.current + 1;
118
- const shouldLogByCount = renderCountRef.current % 25 === 0;
119
- const shouldLogByTime = now - lastLogAtRef.current >= 5e3;
120
- if (!shouldLogByCount && !shouldLogByTime) return;
121
- lastLogAtRef.current = now;
122
- const elapsedMs = Math.max(1, now - startAtRef.current);
123
- const rendersPerSecond = renderCountRef.current * 1e3 / elapsedMs;
124
- console.debug(`[LivePreviewTelemetry] renders=${renderCountRef.current} rps=${rendersPerSecond.toFixed(2)} mobile=${isMobile} tab=${activeTab}`);
125
- };
126
- $[0] = activeTab;
127
- $[1] = isMobile;
128
- $[2] = open;
129
- $[3] = t1;
130
- } else t1 = $[3];
131
- React.useEffect(t1);
96
+ React.useEffect(() => {
97
+ if (!DEV_TELEMETRY) return;
98
+ if (!open) {
99
+ renderCountRef.current = 0;
100
+ startAtRef.current = 0;
101
+ lastLogAtRef.current = 0;
102
+ return;
103
+ }
104
+ const now = performance.now();
105
+ if (!startAtRef.current) startAtRef.current = now;
106
+ renderCountRef.current += 1;
107
+ const shouldLogByCount = renderCountRef.current % 25 === 0;
108
+ const shouldLogByTime = now - lastLogAtRef.current >= 5e3;
109
+ if (!shouldLogByCount && !shouldLogByTime) return;
110
+ lastLogAtRef.current = now;
111
+ const elapsedMs = Math.max(1, now - startAtRef.current);
112
+ const rendersPerSecond = renderCountRef.current * 1e3 / elapsedMs;
113
+ console.debug(`[LivePreviewTelemetry] renders=${renderCountRef.current} rps=${rendersPerSecond.toFixed(2)} mobile=${isMobile} tab=${activeTab}`);
114
+ });
132
115
  }
133
- function LivePreviewContent(t0) {
134
- const $ = c(79);
135
- const { open, children, previewUrl, previewRef, onFieldValueEdited, onPatchApplied, onResyncRequest, defaultSize: t1, minSize: t2 } = t0;
136
- const defaultSize = t1 === void 0 ? 50 : t1;
137
- const minSize = t2 === void 0 ? 30 : t2;
116
+ function LivePreviewContent({ open, children, previewUrl, previewRef, onFieldValueEdited, onPatchApplied, onResyncRequest, defaultSize = 50, minSize = 30 }) {
138
117
  const { t } = useTranslation();
139
118
  const isMobile = useIsMobile();
140
119
  const [activeTab, setActiveTab] = React.useState("form");
141
- let t3;
142
- if ($[0] !== activeTab || $[1] !== isMobile || $[2] !== open) {
143
- t3 = {
144
- open,
145
- isMobile,
146
- activeTab
147
- };
148
- $[0] = activeTab;
149
- $[1] = isMobile;
150
- $[2] = open;
151
- $[3] = t3;
152
- } else t3 = $[3];
153
- useLivePreviewRenderTelemetry(t3);
120
+ useLivePreviewRenderTelemetry({
121
+ open,
122
+ isMobile,
123
+ activeTab
124
+ });
154
125
  const { previewPercent, containerRef, handleMouseDown } = useResizablePane(defaultSize, minSize, open && !isMobile);
155
- const focusContext = useFocus();
156
- const focusState = focusContext.state;
157
- let t4;
158
- if ($[4] !== focusContext) {
159
- t4 = (state) => {
160
- if (state.type === "field") focusContext.focusField(state.fieldPath);
161
- else if (state.type === "block") focusContext.focusBlock(state.blockId, state.fieldPath);
162
- else if (state.type === "relation") focusContext.focusRelation(state.fieldPath, state.targetCollection);
163
- };
164
- $[4] = focusContext;
165
- $[5] = t4;
166
- } else t4 = $[5];
167
- const applyFocusState = t4;
168
- const handleExitPreview = _temp;
169
- let t5;
170
- let t6;
171
- if ($[6] !== open) {
172
- t5 = () => {
173
- if (!open) setActiveTab("form");
174
- };
175
- t6 = [open];
176
- $[6] = open;
177
- $[7] = t5;
178
- $[8] = t6;
179
- } else {
180
- t5 = $[7];
181
- t6 = $[8];
182
- }
183
- React.useEffect(t5, t6);
184
- let t7;
185
- let t8;
186
- if ($[9] !== focusState || $[10] !== open || $[11] !== previewRef) {
187
- t7 = () => {
188
- if (!open) return;
189
- if (!previewRef.current) return;
190
- if (focusState.type === "field" || focusState.type === "relation") previewRef.current.sendFocusToPreview(focusState.fieldPath);
191
- else if (focusState.type === "block") if (focusState.fieldPath) {
192
- const fullPath = `content._values.${focusState.blockId}.${focusState.fieldPath}`;
193
- previewRef.current.sendFocusToPreview(fullPath);
194
- } else {
195
- const fullPath_0 = `content._values.${focusState.blockId}`;
196
- previewRef.current.sendFocusToPreview(fullPath_0);
197
- }
198
- };
199
- t8 = [
200
- focusState,
201
- previewRef,
202
- open
203
- ];
204
- $[9] = focusState;
205
- $[10] = open;
206
- $[11] = previewRef;
207
- $[12] = t7;
208
- $[13] = t8;
209
- } else {
210
- t7 = $[12];
211
- t8 = $[13];
212
- }
213
- React.useEffect(t7, t8);
214
- let t10;
215
- let t9;
216
- if ($[14] !== applyFocusState || $[15] !== focusState || $[16] !== open) {
217
- t9 = () => {
218
- if (!open) return;
219
- const handleKeyDown = (e) => {
220
- if (e.key !== "Tab") return;
221
- const formScope = document.querySelector("[data-preview-form-scope]");
222
- if (!formScope) return;
223
- const fields = Array.from(formScope.querySelectorAll("[data-field-path]"));
224
- if (fields.length === 0) return;
225
- if (!formScope.contains(document.activeElement)) return;
226
- e.preventDefault();
227
- const currentPath = getFocusStatePath(focusState);
228
- const currentIdx = currentPath ? fields.findIndex((el) => el.getAttribute("data-field-path") === currentPath) : -1;
229
- let nextIdx;
230
- if (e.shiftKey) nextIdx = currentIdx <= 0 ? fields.length - 1 : currentIdx - 1;
231
- else nextIdx = currentIdx >= fields.length - 1 ? 0 : currentIdx + 1;
232
- const nextPath = fields[nextIdx]?.getAttribute("data-field-path");
233
- if (nextPath) applyFocusState(parsePreviewFieldPath(nextPath));
234
- };
235
- window.addEventListener("keydown", handleKeyDown);
236
- return () => window.removeEventListener("keydown", handleKeyDown);
237
- };
238
- t10 = [
239
- focusState,
240
- applyFocusState,
241
- open
242
- ];
243
- $[14] = applyFocusState;
244
- $[15] = focusState;
245
- $[16] = open;
246
- $[17] = t10;
247
- $[18] = t9;
248
- } else {
249
- t10 = $[17];
250
- t9 = $[18];
251
- }
252
- React.useEffect(t9, t10);
253
- let t11;
254
- if ($[19] !== applyFocusState) {
255
- t11 = (fieldPath, context) => {
256
- applyFocusState(parsePreviewFieldPath(fieldPath, context));
257
- };
258
- $[19] = applyFocusState;
259
- $[20] = t11;
260
- } else t11 = $[20];
261
- const handlePreviewFieldClick = t11;
262
- let t12;
263
- if ($[21] !== focusContext) {
264
- t12 = (blockId) => {
265
- focusContext.focusBlock(blockId);
266
- };
267
- $[21] = focusContext;
268
- $[22] = t12;
269
- } else t12 = $[22];
270
- const handlePreviewBlockClick = t12;
271
- let t13;
272
- if ($[23] !== focusContext) {
273
- t13 = (message) => {
274
- focusContext.requestBlockInsert(message.position, message.referenceBlockId);
126
+ const { state: focusState, focusField, focusBlock, focusRelation, requestBlockInsert } = useFocus();
127
+ const applyFocusState = React.useCallback((state) => {
128
+ if (state.type === "field") focusField(state.fieldPath);
129
+ else if (state.type === "block") focusBlock(state.blockId, state.fieldPath);
130
+ else if (state.type === "relation") focusRelation(state.fieldPath, state.targetCollection);
131
+ }, [
132
+ focusBlock,
133
+ focusField,
134
+ focusRelation
135
+ ]);
136
+ const handleExitPreview = React.useCallback(() => {
137
+ window.location.href = "/api/preview?disable=true";
138
+ }, []);
139
+ React.useEffect(() => {
140
+ if (!open) return;
141
+ if (!previewRef.current) return;
142
+ if (focusState.type === "field" || focusState.type === "relation") previewRef.current.sendFocusToPreview(focusState.fieldPath);
143
+ else if (focusState.type === "block") if (focusState.fieldPath) {
144
+ const fullPath = `content._values.${focusState.blockId}.${focusState.fieldPath}`;
145
+ previewRef.current.sendFocusToPreview(fullPath);
146
+ } else {
147
+ const fullPath = `content._values.${focusState.blockId}`;
148
+ previewRef.current.sendFocusToPreview(fullPath);
149
+ }
150
+ }, [
151
+ focusState,
152
+ previewRef,
153
+ open
154
+ ]);
155
+ React.useEffect(() => {
156
+ if (!open) return;
157
+ const handleKeyDown = (e) => {
158
+ if (e.key !== "Tab") return;
159
+ const formScope = document.querySelector("[data-preview-form-scope]");
160
+ if (!formScope) return;
161
+ const fields = Array.from(formScope.querySelectorAll("[data-field-path]"));
162
+ if (fields.length === 0) return;
163
+ if (!formScope.contains(document.activeElement)) return;
164
+ e.preventDefault();
165
+ const currentPath = getFocusStatePath(focusState);
166
+ const currentIdx = currentPath ? fields.findIndex((el) => el.getAttribute("data-field-path") === currentPath) : -1;
167
+ let nextIdx;
168
+ if (e.shiftKey) nextIdx = currentIdx <= 0 ? fields.length - 1 : currentIdx - 1;
169
+ else nextIdx = currentIdx >= fields.length - 1 ? 0 : currentIdx + 1;
170
+ const nextPath = fields[nextIdx]?.getAttribute("data-field-path");
171
+ if (nextPath) applyFocusState(parsePreviewFieldPath(nextPath));
275
172
  };
276
- $[23] = focusContext;
277
- $[24] = t13;
278
- } else t13 = $[24];
279
- const handlePreviewBlockInsertRequest = t13;
280
- const t14 = open ? "bg-background fixed inset-0 z-50 flex flex-col" : "w-full";
281
- let t15;
282
- if ($[25] !== activeTab || $[26] !== isMobile || $[27] !== open || $[28] !== t) {
283
- t15 = open && /* @__PURE__ */ jsxs("div", {
173
+ window.addEventListener("keydown", handleKeyDown);
174
+ return () => window.removeEventListener("keydown", handleKeyDown);
175
+ }, [
176
+ focusState,
177
+ applyFocusState,
178
+ open
179
+ ]);
180
+ const handlePreviewFieldClick = React.useCallback((fieldPath, context) => {
181
+ applyFocusState(parsePreviewFieldPath(fieldPath, context));
182
+ }, [applyFocusState]);
183
+ const handlePreviewBlockClick = React.useCallback((blockId) => {
184
+ focusBlock(blockId);
185
+ }, [focusBlock]);
186
+ const handlePreviewBlockInsertRequest = React.useCallback((message) => {
187
+ requestBlockInsert(message.position, message.referenceBlockId);
188
+ }, [requestBlockInsert]);
189
+ return /* @__PURE__ */ jsxs("div", {
190
+ className: open ? "bg-background fixed inset-0 z-50 flex flex-col" : "w-full",
191
+ children: [open && /* @__PURE__ */ jsxs("div", {
284
192
  className: "flex shrink-0 items-center justify-between border-b px-4 py-2",
285
193
  children: [
286
194
  /* @__PURE__ */ jsxs("div", {
@@ -328,210 +236,104 @@ function LivePreviewContent(t0) {
328
236
  })
329
237
  })
330
238
  ]
331
- });
332
- $[25] = activeTab;
333
- $[26] = isMobile;
334
- $[27] = open;
335
- $[28] = t;
336
- $[29] = t15;
337
- } else t15 = $[29];
338
- const t16 = open && !isMobile ? containerRef : void 0;
339
- const t17 = open ? isMobile ? "min-h-0 flex-1" : "flex min-h-0 flex-1" : "w-full";
340
- let t18;
341
- if ($[30] !== activeTab || $[31] !== isMobile || $[32] !== open) {
342
- t18 = open ? isMobile ? cn("h-full overflow-y-auto p-6", activeTab !== "form" && "hidden") : "bg-background h-full overflow-y-auto border-r p-6" : "w-full";
343
- $[30] = activeTab;
344
- $[31] = isMobile;
345
- $[32] = open;
346
- $[33] = t18;
347
- } else t18 = $[33];
348
- let t19;
349
- if ($[34] !== isMobile || $[35] !== open || $[36] !== previewPercent) {
350
- t19 = open && !isMobile ? { width: `${100 - previewPercent}%` } : void 0;
351
- $[34] = isMobile;
352
- $[35] = open;
353
- $[36] = previewPercent;
354
- $[37] = t19;
355
- } else t19 = $[37];
356
- let t20;
357
- if ($[38] !== children || $[39] !== t18 || $[40] !== t19) {
358
- t20 = /* @__PURE__ */ jsx("div", {
359
- "data-preview-form-scope": true,
360
- className: t18,
361
- style: t19,
362
- children
363
- });
364
- $[38] = children;
365
- $[39] = t18;
366
- $[40] = t19;
367
- $[41] = t20;
368
- } else t20 = $[41];
369
- let t21;
370
- if ($[42] !== activeTab || $[43] !== handlePreviewBlockClick || $[44] !== handlePreviewBlockInsertRequest || $[45] !== handlePreviewFieldClick || $[46] !== isMobile || $[47] !== onFieldValueEdited || $[48] !== onPatchApplied || $[49] !== onResyncRequest || $[50] !== open || $[51] !== previewRef || $[52] !== previewUrl || $[53] !== t) {
371
- t21 = open && isMobile && /* @__PURE__ */ jsx("div", {
372
- className: activeTab === "preview" ? "h-full" : "hidden",
373
- children: previewUrl ? /* @__PURE__ */ jsx(PreviewPane, {
374
- ref: previewRef,
375
- url: previewUrl,
376
- onFieldClick: handlePreviewFieldClick,
377
- onBlockClick: handlePreviewBlockClick,
378
- onBlockInsertRequest: handlePreviewBlockInsertRequest,
379
- onFieldValueEdited,
380
- onPatchApplied,
381
- onResyncRequest
382
- }) : /* @__PURE__ */ jsxs("div", {
383
- className: "flex h-full items-center justify-center",
384
- children: [/* @__PURE__ */ jsx(Icon, {
385
- icon: "ph:spinner",
386
- className: "text-muted-foreground h-6 w-6 animate-spin"
387
- }), /* @__PURE__ */ jsx("span", {
388
- className: "text-muted-foreground ml-2 text-sm",
389
- children: t("preview.loadingPreview")
390
- })]
391
- })
392
- });
393
- $[42] = activeTab;
394
- $[43] = handlePreviewBlockClick;
395
- $[44] = handlePreviewBlockInsertRequest;
396
- $[45] = handlePreviewFieldClick;
397
- $[46] = isMobile;
398
- $[47] = onFieldValueEdited;
399
- $[48] = onPatchApplied;
400
- $[49] = onResyncRequest;
401
- $[50] = open;
402
- $[51] = previewRef;
403
- $[52] = previewUrl;
404
- $[53] = t;
405
- $[54] = t21;
406
- } else t21 = $[54];
407
- let t22;
408
- if ($[55] !== handleMouseDown || $[56] !== handlePreviewBlockClick || $[57] !== handlePreviewBlockInsertRequest || $[58] !== handlePreviewFieldClick || $[59] !== isMobile || $[60] !== onFieldValueEdited || $[61] !== onPatchApplied || $[62] !== onResyncRequest || $[63] !== open || $[64] !== previewPercent || $[65] !== previewRef || $[66] !== previewUrl || $[67] !== t) {
409
- t22 = open && !isMobile && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("button", {
410
- type: "button",
411
- "aria-label": "Resize preview pane",
412
- onMouseDown: handleMouseDown,
413
- onClick: _temp2,
414
- className: "bg-border hover:bg-border-strong w-1 shrink-0 cursor-col-resize appearance-none border-0 p-0 transition-colors"
415
- }), /* @__PURE__ */ jsx("div", {
416
- className: "bg-muted min-w-0",
417
- style: { width: `${previewPercent}%` },
418
- children: previewUrl ? /* @__PURE__ */ jsx(PreviewPane, {
419
- ref: previewRef,
420
- url: previewUrl,
421
- onFieldClick: handlePreviewFieldClick,
422
- onBlockClick: handlePreviewBlockClick,
423
- onBlockInsertRequest: handlePreviewBlockInsertRequest,
424
- onFieldValueEdited,
425
- onPatchApplied,
426
- onResyncRequest
427
- }) : /* @__PURE__ */ jsxs("div", {
428
- className: "flex h-full items-center justify-center",
429
- children: [/* @__PURE__ */ jsx(Icon, {
430
- icon: "ph:spinner",
431
- className: "text-muted-foreground h-6 w-6 animate-spin"
432
- }), /* @__PURE__ */ jsx("span", {
433
- className: "text-muted-foreground ml-2 text-sm",
434
- children: t("preview.loadingPreview")
435
- })]
436
- })
437
- })] });
438
- $[55] = handleMouseDown;
439
- $[56] = handlePreviewBlockClick;
440
- $[57] = handlePreviewBlockInsertRequest;
441
- $[58] = handlePreviewFieldClick;
442
- $[59] = isMobile;
443
- $[60] = onFieldValueEdited;
444
- $[61] = onPatchApplied;
445
- $[62] = onResyncRequest;
446
- $[63] = open;
447
- $[64] = previewPercent;
448
- $[65] = previewRef;
449
- $[66] = previewUrl;
450
- $[67] = t;
451
- $[68] = t22;
452
- } else t22 = $[68];
453
- let t23;
454
- if ($[69] !== t16 || $[70] !== t17 || $[71] !== t20 || $[72] !== t21 || $[73] !== t22) {
455
- t23 = /* @__PURE__ */ jsxs("div", {
456
- ref: t16,
457
- className: t17,
239
+ }), /* @__PURE__ */ jsxs("div", {
240
+ ref: open && !isMobile ? containerRef : void 0,
241
+ className: open ? isMobile ? "min-h-0 flex-1" : "flex min-h-0 flex-1" : "w-full",
458
242
  children: [
459
- t20,
460
- t21,
461
- t22
243
+ /* @__PURE__ */ jsx("div", {
244
+ "data-preview-form-scope": true,
245
+ className: open ? isMobile ? cn("h-full overflow-y-auto p-6", activeTab !== "form" && "hidden") : "bg-background h-full overflow-y-auto border-r p-6" : "w-full",
246
+ style: open && !isMobile ? { width: `${100 - previewPercent}%` } : void 0,
247
+ children
248
+ }),
249
+ open && isMobile && /* @__PURE__ */ jsx("div", {
250
+ className: activeTab === "preview" ? "h-full" : "hidden",
251
+ children: previewUrl ? /* @__PURE__ */ jsx(PreviewPane, {
252
+ ref: previewRef,
253
+ url: previewUrl,
254
+ onFieldClick: handlePreviewFieldClick,
255
+ onBlockClick: handlePreviewBlockClick,
256
+ onBlockInsertRequest: handlePreviewBlockInsertRequest,
257
+ onFieldValueEdited,
258
+ onPatchApplied,
259
+ onResyncRequest
260
+ }) : /* @__PURE__ */ jsxs("div", {
261
+ className: "flex h-full items-center justify-center",
262
+ children: [/* @__PURE__ */ jsx(Icon, {
263
+ icon: "ph:spinner",
264
+ className: "text-muted-foreground h-6 w-6 animate-spin"
265
+ }), /* @__PURE__ */ jsx("span", {
266
+ className: "text-muted-foreground ml-2 text-sm",
267
+ children: t("preview.loadingPreview")
268
+ })]
269
+ })
270
+ }),
271
+ open && !isMobile && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("button", {
272
+ type: "button",
273
+ "aria-label": "Resize preview pane",
274
+ onMouseDown: handleMouseDown,
275
+ onClick: (e) => e.preventDefault(),
276
+ className: "bg-border hover:bg-border-strong w-1 shrink-0 cursor-col-resize appearance-none border-0 p-0 transition-colors"
277
+ }), /* @__PURE__ */ jsx("div", {
278
+ className: "bg-muted min-w-0",
279
+ style: { width: `${previewPercent}%` },
280
+ children: previewUrl ? /* @__PURE__ */ jsx(PreviewPane, {
281
+ ref: previewRef,
282
+ url: previewUrl,
283
+ onFieldClick: handlePreviewFieldClick,
284
+ onBlockClick: handlePreviewBlockClick,
285
+ onBlockInsertRequest: handlePreviewBlockInsertRequest,
286
+ onFieldValueEdited,
287
+ onPatchApplied,
288
+ onResyncRequest
289
+ }) : /* @__PURE__ */ jsxs("div", {
290
+ className: "flex h-full items-center justify-center",
291
+ children: [/* @__PURE__ */ jsx(Icon, {
292
+ icon: "ph:spinner",
293
+ className: "text-muted-foreground h-6 w-6 animate-spin"
294
+ }), /* @__PURE__ */ jsx("span", {
295
+ className: "text-muted-foreground ml-2 text-sm",
296
+ children: t("preview.loadingPreview")
297
+ })]
298
+ })
299
+ })] })
462
300
  ]
463
- });
464
- $[69] = t16;
465
- $[70] = t17;
466
- $[71] = t20;
467
- $[72] = t21;
468
- $[73] = t22;
469
- $[74] = t23;
470
- } else t23 = $[74];
471
- let t24;
472
- if ($[75] !== t14 || $[76] !== t15 || $[77] !== t23) {
473
- t24 = /* @__PURE__ */ jsxs("div", {
474
- className: t14,
475
- children: [t15, t23]
476
- });
477
- $[75] = t14;
478
- $[76] = t15;
479
- $[77] = t23;
480
- $[78] = t24;
481
- } else t24 = $[78];
482
- return t24;
301
+ })]
302
+ });
483
303
  }
484
- function _temp2(e_0) {
485
- return e_0.preventDefault();
486
- }
487
- function _temp() {
488
- window.location.href = "/api/preview?disable=true";
489
- }
490
- function LivePreviewMode(t0) {
491
- const $ = c(11);
492
- const { open, onClose, children, previewUrl, previewRef: previewRefProp, onFieldValueEdited, onPatchApplied, onResyncRequest, defaultSize, minSize } = t0;
304
+ function LivePreviewMode({ open, onClose, children, previewUrl, previewRef: previewRefProp, onFieldValueEdited, onPatchApplied, onResyncRequest, defaultSize, minSize }) {
493
305
  const fallbackPreviewRef = React.useRef(null);
494
306
  const previewRef = previewRefProp ?? fallbackPreviewRef;
495
- const handleFocusChange = _temp3;
496
- let t1;
497
- if ($[0] !== children || $[1] !== defaultSize || $[2] !== minSize || $[3] !== onClose || $[4] !== onFieldValueEdited || $[5] !== onPatchApplied || $[6] !== onResyncRequest || $[7] !== open || $[8] !== previewRef || $[9] !== previewUrl) {
498
- t1 = /* @__PURE__ */ jsx(FocusProvider, {
499
- onFocusChange: handleFocusChange,
500
- children: /* @__PURE__ */ jsx(LivePreviewContent, {
501
- open,
502
- onClose,
503
- previewUrl,
504
- previewRef,
505
- onFieldValueEdited,
506
- onPatchApplied,
507
- onResyncRequest,
508
- defaultSize,
509
- minSize,
510
- children
511
- })
512
- });
513
- $[0] = children;
514
- $[1] = defaultSize;
515
- $[2] = minSize;
516
- $[3] = onClose;
517
- $[4] = onFieldValueEdited;
518
- $[5] = onPatchApplied;
519
- $[6] = onResyncRequest;
520
- $[7] = open;
521
- $[8] = previewRef;
522
- $[9] = previewUrl;
523
- $[10] = t1;
524
- } else t1 = $[10];
525
- return t1;
526
- }
527
- function _temp3(state) {
528
- if (state.type === "field" || state.type === "relation") scheduleScrollFieldIntoView(state.fieldPath);
529
- else if (state.type === "block") scheduleScrollFieldIntoView(state.fieldPath ? `content._values.${state.blockId}.${state.fieldPath}` : `content._values.${state.blockId}`, { fallbackToBlock: true });
530
- else if (state.type === "block-insert") {
531
- const targetBlockId = state.referenceBlockId ?? state.position.parentId;
532
- if (!targetBlockId) return;
533
- scheduleScrollFieldIntoView(`content._values.${targetBlockId}`, { fallbackToBlock: true });
534
- }
307
+ return /* @__PURE__ */ jsx(FocusProvider, {
308
+ onFocusChange: React.useCallback((state) => {
309
+ const shouldFocusForm = !isPreviewIframeFocused();
310
+ if (state.type === "field" || state.type === "relation") scheduleScrollFieldIntoView(state.fieldPath, { focus: shouldFocusForm });
311
+ else if (state.type === "block") scheduleScrollFieldIntoView(state.fieldPath ? `content._values.${state.blockId}.${state.fieldPath}` : `content._values.${state.blockId}`, {
312
+ fallbackToBlock: true,
313
+ focus: shouldFocusForm
314
+ });
315
+ else if (state.type === "block-insert") {
316
+ const targetBlockId = state.referenceBlockId ?? state.position.parentId;
317
+ if (!targetBlockId) return;
318
+ scheduleScrollFieldIntoView(`content._values.${targetBlockId}`, {
319
+ fallbackToBlock: true,
320
+ focus: shouldFocusForm
321
+ });
322
+ }
323
+ }, []),
324
+ children: /* @__PURE__ */ jsx(LivePreviewContent, {
325
+ open,
326
+ onClose,
327
+ previewUrl,
328
+ previewRef,
329
+ onFieldValueEdited,
330
+ onPatchApplied,
331
+ onResyncRequest,
332
+ defaultSize,
333
+ minSize,
334
+ children
335
+ })
336
+ });
535
337
  }
536
338
 
537
339
  //#endregion