@questpie/admin 3.2.4 → 3.2.6

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