@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.
- package/dist/client/blocks/block-renderer.d.mts +2 -2
- package/dist/client/blocks/block-renderer.mjs +164 -339
- package/dist/client/components/actions/action-button.mjs +9 -9
- package/dist/client/components/actions/action-dialog.mjs +195 -493
- package/dist/client/components/actions/confirmation-dialog.mjs +44 -159
- package/dist/client/components/actions/header-actions.mjs +73 -165
- package/dist/client/components/admin-link.d.mts +2 -2
- package/dist/client/components/admin-link.mjs +40 -126
- package/dist/client/components/auth/auth-loading.mjs +9 -44
- package/dist/client/components/blocks/block-canvas.mjs +31 -95
- package/dist/client/components/blocks/block-editor-context.mjs +13 -57
- package/dist/client/components/blocks/block-editor-layout.mjs +72 -166
- package/dist/client/components/blocks/block-editor-provider.mjs +184 -245
- package/dist/client/components/blocks/block-fields-renderer.mjs +54 -229
- package/dist/client/components/blocks/block-insert-button.mjs +49 -165
- package/dist/client/components/blocks/block-item-menu.mjs +102 -301
- package/dist/client/components/blocks/block-item.mjs +136 -370
- package/dist/client/components/blocks/block-library-sidebar.mjs +106 -220
- package/dist/client/components/blocks/block-tree.mjs +12 -68
- package/dist/client/components/blocks/block-type-icon.mjs +14 -56
- package/dist/client/components/brand-logo.mjs +35 -149
- package/dist/client/components/component-renderer.mjs +42 -118
- package/dist/client/components/error-boundary.mjs +14 -58
- package/dist/client/components/fields/array-field.mjs +209 -521
- package/dist/client/components/fields/asset-preview-field.mjs +41 -141
- package/dist/client/components/fields/blocks-field/blocks-field.mjs +60 -156
- package/dist/client/components/fields/boolean-field.mjs +29 -59
- package/dist/client/components/fields/date-field.mjs +7 -37
- package/dist/client/components/fields/datetime-field.mjs +7 -38
- package/dist/client/components/fields/email-field.mjs +25 -54
- package/dist/client/components/fields/field-wrapper.mjs +30 -105
- package/dist/client/components/fields/json-field.mjs +107 -313
- package/dist/client/components/fields/locale-badge.mjs +6 -15
- package/dist/client/components/fields/number-field.mjs +27 -60
- package/dist/client/components/fields/object-array-field.mjs +283 -659
- package/dist/client/components/fields/object-field.mjs +165 -633
- package/dist/client/components/fields/relation/displays/cards-display.mjs +106 -220
- package/dist/client/components/fields/relation/displays/chips-display.mjs +78 -150
- package/dist/client/components/fields/relation/displays/grid-display.mjs +92 -186
- package/dist/client/components/fields/relation/displays/list-display.mjs +122 -239
- package/dist/client/components/fields/relation/displays/table-display.mjs +70 -244
- package/dist/client/components/fields/relation/relation-items-display.mjs +30 -126
- package/dist/client/components/fields/relation-field.mjs +10 -66
- package/dist/client/components/fields/relation-picker.mjs +18 -18
- package/dist/client/components/fields/relation-select.mjs +12 -12
- package/dist/client/components/fields/rich-text-editor/bubble-menu.mjs +80 -182
- package/dist/client/components/fields/rich-text-editor/image-popover.mjs +8 -19
- package/dist/client/components/fields/rich-text-editor/image-upload.mjs +13 -29
- package/dist/client/components/fields/rich-text-editor/index.mjs +196 -530
- package/dist/client/components/fields/rich-text-editor/slash-commands.mjs +61 -111
- package/dist/client/components/fields/rich-text-editor/table-controls.mjs +105 -415
- package/dist/client/components/fields/rich-text-editor/toolbar.mjs +256 -511
- package/dist/client/components/fields/rich-text-field.mjs +14 -53
- package/dist/client/components/fields/select-field.mjs +39 -74
- package/dist/client/components/fields/text-field.mjs +26 -59
- package/dist/client/components/fields/textarea-field.mjs +26 -58
- package/dist/client/components/fields/time-field.mjs +7 -35
- package/dist/client/components/fields/upload-field.mjs +47 -165
- package/dist/client/components/filter-builder/columns-tab.mjs +80 -280
- package/dist/client/components/filter-builder/filter-builder-sheet.mjs +197 -540
- package/dist/client/components/filter-builder/filters-tab.mjs +96 -386
- package/dist/client/components/filter-builder/saved-views-tab.mjs +133 -351
- package/dist/client/components/history-sidebar.mjs +306 -611
- package/dist/client/components/layout/field-layout-renderer.mjs +106 -254
- package/dist/client/components/locale-switcher.mjs +106 -228
- package/dist/client/components/media/media-grid.mjs +84 -273
- package/dist/client/components/media/media-picker-dialog.mjs +177 -494
- package/dist/client/components/preview/live-preview-mode.mjs +240 -438
- package/dist/client/components/preview/preview-pane.mjs +22 -22
- package/dist/client/components/primitives/asset-preview.mjs +290 -666
- package/dist/client/components/primitives/checkbox-input.mjs +9 -35
- package/dist/client/components/primitives/date-input.mjs +109 -327
- package/dist/client/components/primitives/dropzone.mjs +209 -336
- package/dist/client/components/primitives/field-select-control.mjs +12 -80
- package/dist/client/components/primitives/number-input.mjs +4 -4
- package/dist/client/components/primitives/select-multi.mjs +200 -559
- package/dist/client/components/primitives/select-single.mjs +165 -499
- package/dist/client/components/primitives/time-input.mjs +43 -117
- package/dist/client/components/primitives/toggle-input.mjs +9 -29
- package/dist/client/components/sheets/resource-sheet.mjs +61 -70
- package/dist/client/components/ui/accordion.mjs +35 -155
- package/dist/client/components/ui/alert.mjs +13 -68
- package/dist/client/components/ui/badge.mjs +9 -51
- package/dist/client/components/ui/button.mjs +8 -54
- package/dist/client/components/ui/card.mjs +37 -193
- package/dist/client/components/ui/checkbox.mjs +12 -68
- package/dist/client/components/ui/command.mjs +48 -219
- package/dist/client/components/ui/dialog.mjs +50 -262
- package/dist/client/components/ui/drawer.mjs +55 -259
- package/dist/client/components/ui/dropdown-menu.mjs +86 -427
- package/dist/client/components/ui/empty-state.mjs +28 -98
- package/dist/client/components/ui/field.mjs +73 -309
- package/dist/client/components/ui/input-group.mjs +42 -167
- package/dist/client/components/ui/input.mjs +7 -37
- package/dist/client/components/ui/kbd.mjs +6 -36
- package/dist/client/components/ui/label.mjs +7 -37
- package/dist/client/components/ui/popover.mjs +34 -169
- package/dist/client/components/ui/responsive-dialog.mjs +67 -273
- package/dist/client/components/ui/scroll-fade.mjs +63 -158
- package/dist/client/components/ui/search-input.mjs +33 -100
- package/dist/client/components/ui/select.mjs +72 -393
- package/dist/client/components/ui/separator.mjs +7 -38
- package/dist/client/components/ui/sheet.mjs +49 -269
- package/dist/client/components/ui/sidebar.mjs +171 -690
- package/dist/client/components/ui/skeleton.mjs +7 -38
- package/dist/client/components/ui/sonner.mjs +11 -42
- package/dist/client/components/ui/switch.mjs +9 -45
- package/dist/client/components/ui/table.mjs +48 -266
- package/dist/client/components/ui/tabs.mjs +26 -139
- package/dist/client/components/ui/textarea.mjs +6 -32
- package/dist/client/components/ui/tooltip.mjs +27 -129
- package/dist/client/components/widgets/chart-widget.mjs +174 -522
- package/dist/client/components/widgets/progress-widget.mjs +66 -172
- package/dist/client/components/widgets/quick-actions-widget.mjs +102 -261
- package/dist/client/components/widgets/recent-items-widget.mjs +69 -195
- package/dist/client/components/widgets/stats-widget.mjs +41 -175
- package/dist/client/components/widgets/table-widget.mjs +9 -9
- package/dist/client/components/widgets/timeline-widget.mjs +86 -226
- package/dist/client/components/widgets/value-widget.mjs +74 -381
- package/dist/client/components/widgets/widget-empty-state.mjs +26 -76
- package/dist/client/components/widgets/widget-skeletons.mjs +138 -421
- package/dist/client/contexts/focus-context.d.mts +4 -0
- package/dist/client/contexts/focus-context.mjs +87 -150
- package/dist/client/hooks/typed-hooks.mjs +241 -701
- package/dist/client/hooks/use-action.mjs +62 -198
- package/dist/client/hooks/use-admin-config.mjs +5 -35
- package/dist/client/hooks/use-admin-preferences.mjs +16 -88
- package/dist/client/hooks/use-admin-routes.mjs +22 -56
- package/dist/client/hooks/use-audit-history.mjs +21 -69
- package/dist/client/hooks/use-brand.mjs +1 -9
- package/dist/client/hooks/use-collection-fields.mjs +17 -57
- package/dist/client/hooks/use-collection-meta.mjs +12 -44
- package/dist/client/hooks/use-collection-schema.mjs +10 -33
- package/dist/client/hooks/use-collection-validation.mjs +23 -53
- package/dist/client/hooks/use-collection.mjs +194 -614
- package/dist/client/hooks/use-current-user.mjs +0 -1
- package/dist/client/hooks/use-field-hooks.mjs +10 -10
- package/dist/client/hooks/use-field-options.mjs +61 -202
- package/dist/client/hooks/use-global-fields.mjs +14 -46
- package/dist/client/hooks/use-global-meta.mjs +9 -30
- package/dist/client/hooks/use-global-schema.mjs +9 -30
- package/dist/client/hooks/use-global.mjs +63 -219
- package/dist/client/hooks/use-locks.mjs +117 -325
- package/dist/client/hooks/use-media-query.mjs +16 -36
- package/dist/client/hooks/use-prefill-params.mjs +0 -1
- package/dist/client/hooks/use-questpie-query-options.mjs +12 -29
- package/dist/client/hooks/use-reactive-fields.mjs +1 -1
- package/dist/client/hooks/use-reactive-prop.mjs +65 -223
- package/dist/client/hooks/use-realtime-highlight.mjs +51 -114
- package/dist/client/hooks/use-saved-views.mjs +22 -103
- package/dist/client/hooks/use-search-param-toggle.mjs +28 -79
- package/dist/client/hooks/use-search.mjs +31 -143
- package/dist/client/hooks/use-server-actions.mjs +18 -50
- package/dist/client/hooks/use-server-validation.mjs +72 -166
- package/dist/client/hooks/use-server-widget-data.mjs +7 -33
- package/dist/client/hooks/use-setup-status.mjs +12 -25
- package/dist/client/hooks/use-sidebar-search-param.mjs +33 -78
- package/dist/client/hooks/use-transition-stage.mjs +8 -38
- package/dist/client/hooks/use-upload.mjs +54 -152
- package/dist/client/hooks/use-validation-error-map.mjs +6 -26
- package/dist/client/hooks/use-view-state.mjs +187 -437
- package/dist/client/i18n/hooks.mjs +65 -197
- package/dist/client/lib/render-profiler.mjs +14 -41
- package/dist/client/preview/block-scope-context.d.mts +2 -2
- package/dist/client/preview/block-scope-context.mjs +14 -36
- package/dist/client/preview/diff.mjs +110 -0
- package/dist/client/preview/preview-banner.mjs +42 -108
- package/dist/client/preview/preview-field.d.mts +4 -4
- package/dist/client/preview/preview-field.mjs +166 -409
- package/dist/client/preview/use-collection-preview.mjs +135 -201
- package/dist/client/runtime/content-locales-provider.mjs +31 -83
- package/dist/client/runtime/locale-scope.mjs +22 -63
- package/dist/client/runtime/provider.mjs +100 -255
- package/dist/client/runtime/translations-provider.mjs +41 -107
- package/dist/client/scope/picker.d.mts +2 -2
- package/dist/client/scope/picker.mjs +86 -321
- package/dist/client/scope/provider.d.mts +2 -2
- package/dist/client/scope/provider.mjs +8 -17
- package/dist/client/views/auth/accept-invite-form.d.mts +2 -2
- package/dist/client/views/auth/accept-invite-form.mjs +121 -412
- package/dist/client/views/auth/auth-layout.d.mts +3 -3
- package/dist/client/views/auth/auth-layout.mjs +104 -284
- package/dist/client/views/auth/forgot-password-form.d.mts +2 -2
- package/dist/client/views/auth/forgot-password-form.mjs +94 -325
- package/dist/client/views/auth/invite-form.mjs +107 -442
- package/dist/client/views/auth/login-form.d.mts +2 -2
- package/dist/client/views/auth/login-form.mjs +116 -337
- package/dist/client/views/auth/reset-password-form.mjs +128 -453
- package/dist/client/views/auth/setup-form.mjs +140 -478
- package/dist/client/views/collection/auto-form-fields.mjs +243 -615
- package/dist/client/views/collection/bulk-action-toolbar.mjs +212 -400
- package/dist/client/views/collection/cells/complex-cells.mjs +183 -611
- package/dist/client/views/collection/cells/primitive-cells.mjs +109 -363
- package/dist/client/views/collection/cells/relation-cells.mjs +86 -233
- package/dist/client/views/collection/cells/shared/asset-thumbnail.mjs +142 -371
- package/dist/client/views/collection/cells/shared/relation-chip.mjs +35 -131
- package/dist/client/views/collection/cells/upload-cells.mjs +60 -177
- package/dist/client/views/collection/columns/build-columns.mjs +8 -48
- package/dist/client/views/collection/field-renderer.mjs +11 -24
- package/dist/client/views/collection/form-view.mjs +288 -560
- package/dist/client/views/collection/table-view.mjs +239 -469
- package/dist/client/views/collection/view-skeletons.mjs +112 -237
- package/dist/client/views/common/global-search.mjs +241 -543
- package/dist/client/views/dashboard/dashboard-grid.mjs +256 -775
- package/dist/client/views/dashboard/dashboard-widget.mjs +38 -126
- package/dist/client/views/dashboard/widget-card.mjs +61 -269
- package/dist/client/views/globals/global-form-view.mjs +478 -1298
- package/dist/client/views/layout/admin-layout-provider.mjs +28 -88
- package/dist/client/views/layout/admin-layout.mjs +83 -246
- package/dist/client/views/layout/admin-router.mjs +457 -1289
- package/dist/client/views/layout/admin-sidebar.mjs +510 -1292
- package/dist/client/views/layout/admin-theme.mjs +30 -64
- package/dist/client/views/layout/admin-view-layout.mjs +40 -144
- package/dist/client/views/pages/accept-invite-page.mjs +95 -290
- package/dist/client/views/pages/dashboard-page.mjs +11 -57
- package/dist/client/views/pages/forgot-password-page.mjs +31 -83
- package/dist/client/views/pages/invite-page.mjs +35 -90
- package/dist/client/views/pages/login-page.mjs +41 -121
- package/dist/client/views/pages/reset-password-page.d.mts +2 -2
- package/dist/client/views/pages/reset-password-page.mjs +46 -173
- package/dist/client/views/pages/setup-page.d.mts +2 -2
- package/dist/client/views/pages/setup-page.mjs +33 -95
- package/dist/components/rich-text/rich-text-renderer.d.mts +2 -2
- package/dist/components/rich-text/rich-text-renderer.mjs +9 -33
- package/dist/server/modules/admin/collections/account.d.mts +50 -50
- package/dist/server/modules/admin/collections/admin-locks.d.mts +54 -54
- package/dist/server/modules/admin/collections/admin-preferences.d.mts +39 -39
- package/dist/server/modules/admin/collections/admin-saved-views.d.mts +47 -47
- package/dist/server/modules/admin/collections/apikey.d.mts +68 -68
- package/dist/server/modules/admin/collections/assets.d.mts +34 -34
- package/dist/server/modules/admin/collections/session.d.mts +42 -42
- package/dist/server/modules/admin/collections/user.d.mts +53 -53
- package/dist/server/modules/admin/collections/verification.d.mts +36 -36
- package/dist/server/modules/admin/index.d.mts +21 -20
- package/dist/server/modules/admin/routes/admin-config.d.mts +2 -2
- package/dist/server/modules/admin/routes/execute-action.d.mts +9 -9
- package/dist/server/modules/admin/routes/locales.d.mts +2 -2
- package/dist/server/modules/admin/routes/preview.d.mts +11 -11
- package/dist/server/modules/admin/routes/reactive.d.mts +9 -9
- package/dist/server/modules/admin/routes/setup.d.mts +7 -7
- package/dist/server/modules/admin/routes/translations.d.mts +4 -4
- package/dist/server/modules/admin/routes/widget-data.d.mts +5 -5
- package/dist/server/modules/admin-preferences/collections/saved-views.d.mts +27 -27
- 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
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
81
|
+
}, [
|
|
82
|
+
enabled,
|
|
83
|
+
minSize,
|
|
84
|
+
restoreBodyStyle
|
|
85
|
+
]);
|
|
86
|
+
return {
|
|
87
|
+
previewPercent,
|
|
88
|
+
containerRef,
|
|
89
|
+
handleMouseDown
|
|
90
|
+
};
|
|
98
91
|
}
|
|
99
|
-
function useLivePreviewRenderTelemetry(
|
|
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
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
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(
|
|
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
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
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
|
|
156
|
-
const
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
if (!
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
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
|
-
|
|
277
|
-
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
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
|
-
|
|
333
|
-
|
|
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
|
-
|
|
460
|
-
|
|
461
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
}
|
|
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
|