@questpie/admin 3.1.0 → 3.2.1
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 +12 -2
- package/dist/client/blocks/block-renderer.mjs +357 -49
- package/dist/client/builder/page/page.d.mts +29 -1
- package/dist/client/components/blocks/block-editor-context.mjs +11 -1
- package/dist/client/components/blocks/block-editor-provider.mjs +68 -26
- package/dist/client/components/blocks/block-item.mjs +181 -170
- package/dist/client/components/blocks/utils/tree-utils.mjs +13 -1
- package/dist/client/components/fields/array-field.mjs +177 -118
- package/dist/client/components/filter-builder/filter-builder-sheet.mjs +305 -310
- package/dist/client/components/filter-builder/filters-tab.mjs +1 -1
- package/dist/client/components/history-sidebar.mjs +121 -114
- package/dist/client/components/preview/live-preview-mode.mjs +140 -114
- package/dist/client/components/preview/preview-pane.mjs +288 -333
- package/dist/client/components/primitives/option-label.mjs +44 -0
- package/dist/client/components/primitives/select-multi.mjs +408 -383
- package/dist/client/components/primitives/select-single.mjs +387 -357
- package/dist/client/components/widgets/chart-widget.mjs +168 -143
- package/dist/client/contexts/focus-context.d.mts +11 -0
- package/dist/client/contexts/focus-context.mjs +51 -34
- package/dist/client/hooks/use-audit-history.mjs +10 -17
- package/dist/client/hooks/use-brand.mjs +2 -1
- package/dist/client/hooks/use-transition-stage.mjs +34 -41
- package/dist/client/preview/block-scope-context.d.mts +2 -2
- package/dist/client/preview/block-scope-context.mjs +10 -20
- package/dist/client/preview/index.d.mts +1 -1
- package/dist/client/preview/patch.mjs +100 -0
- package/dist/client/preview/preview-banner.d.mts +2 -2
- package/dist/client/preview/preview-field.d.mts +38 -9
- package/dist/client/preview/preview-field.mjs +385 -118
- package/dist/client/preview/types.d.mts +82 -3
- package/dist/client/preview/types.mjs +85 -6
- package/dist/client/preview/use-collection-preview.d.mts +19 -1
- package/dist/client/preview/use-collection-preview.mjs +182 -58
- package/dist/client/runtime/index.d.mts +2 -2
- package/dist/client/runtime/index.mjs +2 -2
- package/dist/client/runtime/provider.d.mts +5 -5
- package/dist/client/scope/picker.d.mts +2 -2
- package/dist/client/scope/provider.d.mts +2 -2
- package/dist/client/utils/build-field-definitions-from-schema.mjs +8 -3
- package/dist/client/views/auth/login-form.d.mts +2 -2
- package/dist/client/views/auth/reset-password-form.d.mts +2 -2
- package/dist/client/views/collection/bulk-action-toolbar.mjs +23 -25
- package/dist/client/views/collection/cells/primitive-cells.mjs +63 -13
- package/dist/client/views/collection/columns/build-columns.mjs +1 -0
- package/dist/client/views/collection/form-view.mjs +262 -33
- package/dist/client/views/collection/table-view.mjs +16 -11
- package/dist/client/views/layout/admin-layout-provider.d.mts +5 -5
- package/dist/client/views/layout/admin-layout-provider.mjs +107 -16
- package/dist/client/views/pages/accept-invite-page.d.mts +2 -2
- package/dist/client/views/pages/dashboard-page.d.mts +2 -2
- package/dist/client/views/pages/forgot-password-page.d.mts +2 -2
- package/dist/client/views/pages/reset-password-page.d.mts +2 -2
- package/dist/client/views/pages/setup-page.d.mts +2 -2
- package/dist/client.d.mts +3 -2
- package/dist/client.mjs +3 -2
- package/dist/components/rich-text/rich-text-renderer.d.mts +2 -2
- package/dist/index.d.mts +3 -2
- package/dist/index.mjs +3 -2
- package/dist/server/augmentation/common.d.mts +8 -4
- package/dist/server/augmentation/form-layout.d.mts +1 -1
- package/dist/server/i18n/messages/cs.mjs +11 -0
- package/dist/server/i18n/messages/de.mjs +11 -0
- package/dist/server/i18n/messages/en.mjs +11 -0
- package/dist/server/i18n/messages/es.mjs +11 -0
- package/dist/server/i18n/messages/fr.mjs +11 -0
- package/dist/server/i18n/messages/pl.mjs +11 -0
- package/dist/server/i18n/messages/pt.mjs +11 -0
- package/dist/server/i18n/messages/sk.mjs +11 -0
- package/dist/server/modules/admin/block/block-builder.d.mts +7 -10
- package/dist/server/modules/admin/block/block-builder.mjs +7 -10
- package/dist/server/modules/admin/collections/account.d.mts +50 -50
- package/dist/server/modules/admin/collections/admin-locks.d.mts +49 -49
- 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 +64 -64
- package/dist/server/modules/admin/collections/assets.d.mts +57 -20
- package/dist/server/modules/admin/collections/session.d.mts +42 -42
- package/dist/server/modules/admin/collections/user.d.mts +100 -34
- package/dist/server/modules/admin/collections/user.mjs +4 -4
- package/dist/server/modules/admin/collections/verification.d.mts +32 -32
- package/dist/server/modules/admin/index.d.mts +3 -3
- package/dist/server/modules/admin/routes/admin-config.d.mts +2 -2
- package/dist/server/modules/admin/routes/admin-config.mjs +9 -12
- 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/translations.mjs +1 -1
- package/dist/server/modules/admin/routes/widget-data.d.mts +5 -5
- package/dist/server/modules/admin-preferences/collections/admin-preferences.mjs +4 -6
- package/dist/server/modules/admin-preferences/collections/saved-views.d.mts +27 -29
- package/dist/server/modules/admin-preferences/collections/saved-views.mjs +4 -6
- package/package.json +4 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { selectBasePath, useAdminStore } from "../runtime/provider.mjs";
|
|
2
2
|
import { c } from "react/compiler-runtime";
|
|
3
3
|
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
4
4
|
|
|
@@ -9,8 +9,8 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
|
9
9
|
* Provides a mutation for transitioning collection/global records between
|
|
10
10
|
* workflow stages. Supports optional scheduled transitions via `scheduledAt`.
|
|
11
11
|
*
|
|
12
|
-
* Uses direct fetch
|
|
13
|
-
* client SDK
|
|
12
|
+
* Uses direct fetch because the hook accepts runtime collection/global names
|
|
13
|
+
* from admin metadata, while the generated client SDK is keyed by app types.
|
|
14
14
|
*
|
|
15
15
|
* @example
|
|
16
16
|
* ```tsx
|
|
@@ -40,22 +40,15 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
|
40
40
|
* @param options - Optional configuration (mode, mutationOptions)
|
|
41
41
|
*/
|
|
42
42
|
function useTransitionStage(resourceName, options) {
|
|
43
|
-
const $ = c(
|
|
43
|
+
const $ = c(12);
|
|
44
44
|
const mode = options?.mode ?? "collection";
|
|
45
|
-
const
|
|
45
|
+
const basePath = useAdminStore(selectBasePath);
|
|
46
46
|
const queryClient = useQueryClient();
|
|
47
47
|
let t0;
|
|
48
|
-
if ($[0] !==
|
|
49
|
-
t0 =
|
|
50
|
-
$[0] = client;
|
|
51
|
-
$[1] = t0;
|
|
52
|
-
} else t0 = $[1];
|
|
53
|
-
const basePath = t0;
|
|
54
|
-
let t1;
|
|
55
|
-
if ($[2] !== basePath || $[3] !== mode || $[4] !== resourceName) {
|
|
56
|
-
t1 = async (params) => {
|
|
48
|
+
if ($[0] !== basePath || $[1] !== mode || $[2] !== resourceName) {
|
|
49
|
+
t0 = async (params) => {
|
|
57
50
|
const body = { stage: params.stage };
|
|
58
|
-
if (params.scheduledAt) body.scheduledAt = params.scheduledAt instanceof Date ? params.scheduledAt.toISOString() : params.scheduledAt;
|
|
51
|
+
if (params.scheduledAt !== void 0) body.scheduledAt = params.scheduledAt instanceof Date ? params.scheduledAt.toISOString() : params.scheduledAt;
|
|
59
52
|
const url = mode === "global" ? `${basePath}/globals/${resourceName}/transition` : `${basePath}/${resourceName}/${params.id}/transition`;
|
|
60
53
|
const response = await fetch(url, {
|
|
61
54
|
method: "POST",
|
|
@@ -72,14 +65,14 @@ function useTransitionStage(resourceName, options) {
|
|
|
72
65
|
}
|
|
73
66
|
return response.json();
|
|
74
67
|
};
|
|
75
|
-
$[
|
|
76
|
-
$[
|
|
77
|
-
$[
|
|
78
|
-
$[
|
|
79
|
-
} else
|
|
80
|
-
let
|
|
81
|
-
if ($[
|
|
82
|
-
|
|
68
|
+
$[0] = basePath;
|
|
69
|
+
$[1] = mode;
|
|
70
|
+
$[2] = resourceName;
|
|
71
|
+
$[3] = t0;
|
|
72
|
+
} else t0 = $[3];
|
|
73
|
+
let t1;
|
|
74
|
+
if ($[4] !== mode || $[5] !== queryClient || $[6] !== resourceName) {
|
|
75
|
+
t1 = () => {
|
|
83
76
|
if (mode === "collection") queryClient.invalidateQueries({ queryKey: ["questpie", "collections"] });
|
|
84
77
|
else queryClient.invalidateQueries({ queryKey: ["questpie", "globals"] });
|
|
85
78
|
queryClient.invalidateQueries({ queryKey: [
|
|
@@ -89,25 +82,25 @@ function useTransitionStage(resourceName, options) {
|
|
|
89
82
|
resourceName
|
|
90
83
|
] });
|
|
91
84
|
};
|
|
92
|
-
$[
|
|
93
|
-
$[
|
|
94
|
-
$[
|
|
95
|
-
$[
|
|
96
|
-
} else
|
|
97
|
-
const
|
|
98
|
-
let
|
|
99
|
-
if ($[
|
|
100
|
-
|
|
101
|
-
mutationFn:
|
|
102
|
-
onSuccess:
|
|
103
|
-
...
|
|
85
|
+
$[4] = mode;
|
|
86
|
+
$[5] = queryClient;
|
|
87
|
+
$[6] = resourceName;
|
|
88
|
+
$[7] = t1;
|
|
89
|
+
} else t1 = $[7];
|
|
90
|
+
const t2 = options?.mutationOptions;
|
|
91
|
+
let t3;
|
|
92
|
+
if ($[8] !== t0 || $[9] !== t1 || $[10] !== t2) {
|
|
93
|
+
t3 = {
|
|
94
|
+
mutationFn: t0,
|
|
95
|
+
onSuccess: t1,
|
|
96
|
+
...t2
|
|
104
97
|
};
|
|
105
|
-
$[
|
|
106
|
-
$[
|
|
107
|
-
$[
|
|
108
|
-
$[
|
|
109
|
-
} else
|
|
110
|
-
return useMutation(
|
|
98
|
+
$[8] = t0;
|
|
99
|
+
$[9] = t1;
|
|
100
|
+
$[10] = t2;
|
|
101
|
+
$[11] = t3;
|
|
102
|
+
} else t3 = $[11];
|
|
103
|
+
return useMutation(t3);
|
|
111
104
|
}
|
|
112
105
|
function _temp() {
|
|
113
106
|
return {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime21 from "react/jsx-runtime";
|
|
3
3
|
|
|
4
4
|
//#region src/client/preview/block-scope-context.d.ts
|
|
5
5
|
|
|
@@ -35,7 +35,7 @@ declare function BlockScopeProvider({
|
|
|
35
35
|
blockId,
|
|
36
36
|
basePath,
|
|
37
37
|
children
|
|
38
|
-
}: BlockScopeProviderProps):
|
|
38
|
+
}: BlockScopeProviderProps): react_jsx_runtime21.JSX.Element;
|
|
39
39
|
/**
|
|
40
40
|
* Get current block scope context.
|
|
41
41
|
*
|
|
@@ -31,39 +31,29 @@ const BlockScopeContext = React.createContext(null);
|
|
|
31
31
|
function BlockScopeProvider(t0) {
|
|
32
32
|
const $ = c(6);
|
|
33
33
|
const { blockId, basePath: t1, children } = t0;
|
|
34
|
-
const
|
|
35
|
-
const parentScope = React.useContext(BlockScopeContext);
|
|
34
|
+
const fieldPrefix = `${t1 === void 0 ? "content._values" : t1}.${blockId}`;
|
|
36
35
|
let t2;
|
|
37
|
-
bb0: {
|
|
38
|
-
if (parentScope) {
|
|
39
|
-
t2 = `${parentScope.fieldPrefix}.${blockId}`;
|
|
40
|
-
break bb0;
|
|
41
|
-
}
|
|
42
|
-
t2 = `${basePath}.${blockId}`;
|
|
43
|
-
}
|
|
44
|
-
const fieldPrefix = t2;
|
|
45
|
-
let t3;
|
|
46
36
|
if ($[0] !== blockId || $[1] !== fieldPrefix) {
|
|
47
|
-
|
|
37
|
+
t2 = {
|
|
48
38
|
blockId,
|
|
49
39
|
fieldPrefix
|
|
50
40
|
};
|
|
51
41
|
$[0] = blockId;
|
|
52
42
|
$[1] = fieldPrefix;
|
|
53
|
-
$[2] =
|
|
54
|
-
} else
|
|
55
|
-
const value =
|
|
56
|
-
let
|
|
43
|
+
$[2] = t2;
|
|
44
|
+
} else t2 = $[2];
|
|
45
|
+
const value = t2;
|
|
46
|
+
let t3;
|
|
57
47
|
if ($[3] !== children || $[4] !== value) {
|
|
58
|
-
|
|
48
|
+
t3 = /* @__PURE__ */ jsx(BlockScopeContext.Provider, {
|
|
59
49
|
value,
|
|
60
50
|
children
|
|
61
51
|
});
|
|
62
52
|
$[3] = children;
|
|
63
53
|
$[4] = value;
|
|
64
|
-
$[5] =
|
|
65
|
-
} else
|
|
66
|
-
return
|
|
54
|
+
$[5] = t3;
|
|
55
|
+
} else t3 = $[5];
|
|
56
|
+
return t3;
|
|
67
57
|
}
|
|
68
58
|
/**
|
|
69
59
|
* Get current block scope context.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BlockScopeContextValue, BlockScopeProvider, BlockScopeProviderProps, useBlockScope, useResolveFieldPath } from "./block-scope-context.mjs";
|
|
2
2
|
import { PreviewBanner, PreviewBannerProps } from "./preview-banner.mjs";
|
|
3
3
|
import { PreviewField, PreviewFieldProps, PreviewProvider, StandalonePreviewField, usePreviewContext } from "./preview-field.mjs";
|
|
4
|
-
import { AdminToPreviewMessage, BlockClickedMessage, FieldClickedMessage, FocusFieldMessage, PreviewConfig, PreviewReadyMessage, PreviewRefreshMessage, PreviewToAdminMessage, RefreshCompleteMessage, SelectBlockMessage, isAdminToPreviewMessage, isPreviewToAdminMessage } from "./types.mjs";
|
|
4
|
+
import { AdminToPreviewMessage, BlockClickedMessage, CommitMessage, FieldClickedMessage, FieldValueEditedMessage, FocusFieldMessage, FullResyncMessage, InitSnapshotMessage, PatchAppliedMessage, PatchBatchMessage, PreviewConfig, PreviewPatchOp, PreviewReadyMessage, PreviewRefreshMessage, PreviewToAdminMessage, RefreshCompleteMessage, ResyncRequestMessage, SelectBlockMessage, isAdminToPreviewMessage, isPreviewToAdminMessage } from "./types.mjs";
|
|
5
5
|
import { UseCollectionPreviewOptions, UseCollectionPreviewResult, useCollectionPreview } from "./use-collection-preview.mjs";
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
//#region src/client/preview/patch.ts
|
|
2
|
+
function cloneSnapshot(value) {
|
|
3
|
+
if (typeof globalThis.structuredClone === "function") return globalThis.structuredClone(value);
|
|
4
|
+
if (value === void 0) return value;
|
|
5
|
+
return JSON.parse(JSON.stringify(value));
|
|
6
|
+
}
|
|
7
|
+
function shouldApplyPatchBatch(lastAppliedSeq, nextSeq) {
|
|
8
|
+
return lastAppliedSeq == null || nextSeq > lastAppliedSeq;
|
|
9
|
+
}
|
|
10
|
+
function applyPatchBatchImmutable(data, ops) {
|
|
11
|
+
return ops.reduce((current, op) => {
|
|
12
|
+
if (op.op === "set") return setAtPath(current, op.path, op.value);
|
|
13
|
+
if (op.op === "remove") return removeAtPath(current, op.path);
|
|
14
|
+
throw new Error(`Unsupported preview patch operation: ${op.op}`);
|
|
15
|
+
}, data);
|
|
16
|
+
}
|
|
17
|
+
function splitPath(path) {
|
|
18
|
+
if (path === "") return [];
|
|
19
|
+
return path.split(".");
|
|
20
|
+
}
|
|
21
|
+
function isObjectRecord(value) {
|
|
22
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
23
|
+
}
|
|
24
|
+
function isArrayIndex(segment) {
|
|
25
|
+
return /^(0|[1-9]\d*)$/.test(segment);
|
|
26
|
+
}
|
|
27
|
+
function createContainer(nextSegment) {
|
|
28
|
+
return nextSegment !== void 0 && isArrayIndex(nextSegment) ? [] : {};
|
|
29
|
+
}
|
|
30
|
+
function cloneContainer(value, nextSegment) {
|
|
31
|
+
if (Array.isArray(value)) return [...value];
|
|
32
|
+
if (isObjectRecord(value)) return { ...value };
|
|
33
|
+
return createContainer(nextSegment);
|
|
34
|
+
}
|
|
35
|
+
function readChild(container, segment) {
|
|
36
|
+
if (Array.isArray(container) && isArrayIndex(segment)) return container[Number(segment)];
|
|
37
|
+
if (isObjectRecord(container)) return container[segment];
|
|
38
|
+
}
|
|
39
|
+
function writeChild(container, segment, value) {
|
|
40
|
+
if (Array.isArray(container) && isArrayIndex(segment)) {
|
|
41
|
+
container[Number(segment)] = value;
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
container[segment] = value;
|
|
45
|
+
}
|
|
46
|
+
function hasChild(container, segment) {
|
|
47
|
+
if (Array.isArray(container) && isArrayIndex(segment)) {
|
|
48
|
+
const index = Number(segment);
|
|
49
|
+
return index >= 0 && index < container.length;
|
|
50
|
+
}
|
|
51
|
+
if (isObjectRecord(container)) return Object.prototype.hasOwnProperty.call(container, segment);
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
function deleteChild(container, segment) {
|
|
55
|
+
if (Array.isArray(container) && isArrayIndex(segment)) {
|
|
56
|
+
container.splice(Number(segment), 1);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
delete container[segment];
|
|
60
|
+
}
|
|
61
|
+
function setAtPath(data, path, value) {
|
|
62
|
+
const segments = splitPath(path);
|
|
63
|
+
if (segments.length === 0) return cloneSnapshot(value);
|
|
64
|
+
const root = cloneContainer(data, segments[0]);
|
|
65
|
+
let cursor = root;
|
|
66
|
+
for (let index = 0; index < segments.length - 1; index += 1) {
|
|
67
|
+
const segment = segments[index];
|
|
68
|
+
const nextSegment = segments[index + 1];
|
|
69
|
+
const nextChild = cloneContainer(readChild(cursor, segment), nextSegment);
|
|
70
|
+
writeChild(cursor, segment, nextChild);
|
|
71
|
+
cursor = nextChild;
|
|
72
|
+
}
|
|
73
|
+
writeChild(cursor, segments[segments.length - 1], cloneSnapshot(value));
|
|
74
|
+
return root;
|
|
75
|
+
}
|
|
76
|
+
function removeAtPath(data, path) {
|
|
77
|
+
const segments = splitPath(path);
|
|
78
|
+
if (segments.length === 0) return;
|
|
79
|
+
if (!Array.isArray(data) && !isObjectRecord(data)) return data;
|
|
80
|
+
const root = cloneContainer(data, segments[0]);
|
|
81
|
+
let sourceCursor = data;
|
|
82
|
+
let cursor = root;
|
|
83
|
+
for (let index = 0; index < segments.length - 1; index += 1) {
|
|
84
|
+
const segment = segments[index];
|
|
85
|
+
if (!hasChild(sourceCursor, segment)) return data;
|
|
86
|
+
const sourceChild = readChild(sourceCursor, segment);
|
|
87
|
+
if (!Array.isArray(sourceChild) && !isObjectRecord(sourceChild)) return data;
|
|
88
|
+
const nextChild = cloneContainer(sourceChild, segments[index + 1]);
|
|
89
|
+
writeChild(cursor, segment, nextChild);
|
|
90
|
+
sourceCursor = sourceChild;
|
|
91
|
+
cursor = nextChild;
|
|
92
|
+
}
|
|
93
|
+
const finalSegment = segments[segments.length - 1];
|
|
94
|
+
if (!hasChild(sourceCursor, finalSegment)) return data;
|
|
95
|
+
deleteChild(cursor, finalSegment);
|
|
96
|
+
return root;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
//#endregion
|
|
100
|
+
export { applyPatchBatchImmutable, cloneSnapshot, shouldApplyPatchBatch };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime22 from "react/jsx-runtime";
|
|
2
2
|
|
|
3
3
|
//#region src/client/preview/preview-banner.d.ts
|
|
4
4
|
|
|
@@ -40,6 +40,6 @@ declare function PreviewBanner({
|
|
|
40
40
|
isPreviewMode,
|
|
41
41
|
className,
|
|
42
42
|
exitPreviewUrl
|
|
43
|
-
}: PreviewBannerProps):
|
|
43
|
+
}: PreviewBannerProps): react_jsx_runtime22.JSX.Element | null;
|
|
44
44
|
//#endregion
|
|
45
45
|
export { PreviewBanner, PreviewBannerProps };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime23 from "react/jsx-runtime";
|
|
3
3
|
|
|
4
4
|
//#region src/client/preview/preview-field.d.ts
|
|
5
5
|
|
|
@@ -8,17 +8,30 @@ type PreviewFieldProps = {
|
|
|
8
8
|
field: string;
|
|
9
9
|
/** Field type for routing (regular, block, or relation) */
|
|
10
10
|
fieldType?: "regular" | "block" | "relation";
|
|
11
|
+
/** Enable inline scalar editing in preview mode */
|
|
12
|
+
editable?: "text" | "textarea";
|
|
11
13
|
/** Content to render */
|
|
12
14
|
children: React.ReactNode;
|
|
13
15
|
/** HTML element type */
|
|
14
16
|
as?: React.ElementType;
|
|
15
17
|
/** Additional class names */
|
|
16
18
|
className?: string;
|
|
19
|
+
/** Inline styles for the rendered element */
|
|
20
|
+
style?: React.CSSProperties;
|
|
17
21
|
/** Click handler (uses context by default) */
|
|
18
22
|
onClick?: (fieldPath: string, context?: {
|
|
19
23
|
blockId?: string;
|
|
20
24
|
fieldType?: "regular" | "block" | "relation";
|
|
21
25
|
}) => void;
|
|
26
|
+
/** Inline edit commit handler (uses context/default postMessage by default) */
|
|
27
|
+
onValueCommit?: (payload: PreviewFieldValueEditedPayload) => void;
|
|
28
|
+
};
|
|
29
|
+
type PreviewFieldValueEditedPayload = {
|
|
30
|
+
path: string;
|
|
31
|
+
value: unknown;
|
|
32
|
+
inputKind: "text" | "textarea" | "number" | "boolean";
|
|
33
|
+
blockId?: string;
|
|
34
|
+
fieldType?: "regular" | "block" | "relation";
|
|
22
35
|
};
|
|
23
36
|
type PreviewContextValue = {
|
|
24
37
|
isPreviewMode: boolean;
|
|
@@ -26,6 +39,7 @@ type PreviewContextValue = {
|
|
|
26
39
|
blockId?: string;
|
|
27
40
|
fieldType?: "regular" | "block" | "relation";
|
|
28
41
|
}) => void;
|
|
42
|
+
handleFieldValueEdited?: (payload: PreviewFieldValueEditedPayload) => void;
|
|
29
43
|
focusedField: string | null;
|
|
30
44
|
};
|
|
31
45
|
/**
|
|
@@ -33,19 +47,28 @@ type PreviewContextValue = {
|
|
|
33
47
|
* Use this at the root of your preview page.
|
|
34
48
|
*/
|
|
35
49
|
declare function PreviewProvider({
|
|
50
|
+
preview,
|
|
36
51
|
isPreviewMode,
|
|
37
52
|
focusedField,
|
|
38
53
|
onFieldClick,
|
|
54
|
+
onFieldValueEdited,
|
|
39
55
|
children
|
|
40
56
|
}: {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
57
|
+
preview?: {
|
|
58
|
+
isPreviewMode: boolean;
|
|
59
|
+
focusedField: string | null;
|
|
60
|
+
handleFieldClick: PreviewContextValue["handleFieldClick"];
|
|
61
|
+
handleFieldValueEdited?: PreviewContextValue["handleFieldValueEdited"];
|
|
62
|
+
};
|
|
63
|
+
isPreviewMode?: boolean;
|
|
64
|
+
focusedField?: string | null;
|
|
65
|
+
onFieldClick?: (fieldPath: string, context?: {
|
|
44
66
|
blockId?: string;
|
|
45
67
|
fieldType?: "regular" | "block" | "relation";
|
|
46
68
|
}) => void;
|
|
69
|
+
onFieldValueEdited?: (payload: PreviewFieldValueEditedPayload) => void;
|
|
47
70
|
children: React.ReactNode;
|
|
48
|
-
}):
|
|
71
|
+
}): react_jsx_runtime23.JSX.Element;
|
|
49
72
|
/**
|
|
50
73
|
* Hook to access preview context.
|
|
51
74
|
*/
|
|
@@ -77,11 +100,14 @@ declare function usePreviewContext(): PreviewContextValue | null;
|
|
|
77
100
|
declare function PreviewField({
|
|
78
101
|
field,
|
|
79
102
|
fieldType,
|
|
103
|
+
editable,
|
|
80
104
|
children,
|
|
81
105
|
as: Component,
|
|
82
106
|
className,
|
|
83
|
-
|
|
84
|
-
|
|
107
|
+
style,
|
|
108
|
+
onClick,
|
|
109
|
+
onValueCommit
|
|
110
|
+
}: PreviewFieldProps): react_jsx_runtime23.JSX.Element;
|
|
85
111
|
/**
|
|
86
112
|
* Standalone PreviewField that works without context.
|
|
87
113
|
* Useful when you can't use PreviewProvider.
|
|
@@ -89,12 +115,15 @@ declare function PreviewField({
|
|
|
89
115
|
declare function StandalonePreviewField({
|
|
90
116
|
field,
|
|
91
117
|
fieldType,
|
|
118
|
+
editable,
|
|
92
119
|
children,
|
|
93
120
|
as: Component,
|
|
94
121
|
className,
|
|
122
|
+
style,
|
|
95
123
|
isPreviewMode,
|
|
96
124
|
isFocused,
|
|
97
|
-
onFieldClick
|
|
125
|
+
onFieldClick,
|
|
126
|
+
onValueCommit
|
|
98
127
|
}: PreviewFieldProps & {
|
|
99
128
|
isPreviewMode: boolean;
|
|
100
129
|
isFocused?: boolean;
|
|
@@ -102,6 +131,6 @@ declare function StandalonePreviewField({
|
|
|
102
131
|
blockId?: string;
|
|
103
132
|
fieldType?: "regular" | "block" | "relation";
|
|
104
133
|
}) => void;
|
|
105
|
-
}):
|
|
134
|
+
}): react_jsx_runtime23.JSX.Element;
|
|
106
135
|
//#endregion
|
|
107
136
|
export { PreviewField, PreviewFieldProps, PreviewProvider, StandalonePreviewField, usePreviewContext };
|