@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
|
@@ -19,36 +19,43 @@ const PreviewContext = React.createContext(null);
|
|
|
19
19
|
* Use this at the root of your preview page.
|
|
20
20
|
*/
|
|
21
21
|
function PreviewProvider(t0) {
|
|
22
|
-
const $ = c(
|
|
23
|
-
const { isPreviewMode, focusedField, onFieldClick, children } = t0;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
22
|
+
const $ = c(8);
|
|
23
|
+
const { preview, isPreviewMode, focusedField, onFieldClick, onFieldValueEdited, children } = t0;
|
|
24
|
+
const t1 = preview?.isPreviewMode ?? isPreviewMode ?? false;
|
|
25
|
+
const t2 = preview?.focusedField ?? focusedField ?? null;
|
|
26
|
+
const t3 = preview?.handleFieldClick ?? onFieldClick ?? _temp;
|
|
27
|
+
const t4 = preview?.handleFieldValueEdited ?? onFieldValueEdited;
|
|
28
|
+
let t5;
|
|
29
|
+
if ($[0] !== t1 || $[1] !== t2 || $[2] !== t3 || $[3] !== t4) {
|
|
30
|
+
t5 = {
|
|
31
|
+
isPreviewMode: t1,
|
|
32
|
+
focusedField: t2,
|
|
33
|
+
handleFieldClick: t3,
|
|
34
|
+
handleFieldValueEdited: t4
|
|
30
35
|
};
|
|
31
|
-
$[0] =
|
|
32
|
-
$[1] =
|
|
33
|
-
$[2] =
|
|
34
|
-
$[3] =
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
$[0] = t1;
|
|
37
|
+
$[1] = t2;
|
|
38
|
+
$[2] = t3;
|
|
39
|
+
$[3] = t4;
|
|
40
|
+
$[4] = t5;
|
|
41
|
+
} else t5 = $[4];
|
|
42
|
+
const value = t5;
|
|
43
|
+
let t6;
|
|
44
|
+
if ($[5] !== children || $[6] !== value) {
|
|
45
|
+
t6 = /* @__PURE__ */ jsx(PreviewContext.Provider, {
|
|
40
46
|
value,
|
|
41
47
|
children
|
|
42
48
|
});
|
|
43
|
-
$[
|
|
44
|
-
$[
|
|
45
|
-
$[
|
|
46
|
-
} else
|
|
47
|
-
return
|
|
49
|
+
$[5] = children;
|
|
50
|
+
$[6] = value;
|
|
51
|
+
$[7] = t6;
|
|
52
|
+
} else t6 = $[7];
|
|
53
|
+
return t6;
|
|
48
54
|
}
|
|
49
55
|
/**
|
|
50
56
|
* Hook to access preview context.
|
|
51
57
|
*/
|
|
58
|
+
function _temp() {}
|
|
52
59
|
function usePreviewContext() {
|
|
53
60
|
return React.useContext(PreviewContext);
|
|
54
61
|
}
|
|
@@ -77,8 +84,8 @@ function usePreviewContext() {
|
|
|
77
84
|
* ```
|
|
78
85
|
*/
|
|
79
86
|
function PreviewField(t0) {
|
|
80
|
-
const $ = c(
|
|
81
|
-
const { field, fieldType: t1, children, as: t2, className, onClick } = t0;
|
|
87
|
+
const $ = c(17);
|
|
88
|
+
const { field, fieldType: t1, editable, children, as: t2, className, style, onClick, onValueCommit } = t0;
|
|
82
89
|
const fieldType = t1 === void 0 ? "regular" : t1;
|
|
83
90
|
const Component = t2 === void 0 ? "div" : t2;
|
|
84
91
|
const context = usePreviewContext();
|
|
@@ -86,69 +93,52 @@ function PreviewField(t0) {
|
|
|
86
93
|
const fullPath = useResolveFieldPath(field);
|
|
87
94
|
if (!context?.isPreviewMode) {
|
|
88
95
|
let t3$1;
|
|
89
|
-
if ($[0] !== Component || $[1] !== children || $[2] !== className) {
|
|
96
|
+
if ($[0] !== Component || $[1] !== children || $[2] !== className || $[3] !== style) {
|
|
90
97
|
t3$1 = /* @__PURE__ */ jsx(Component, {
|
|
91
98
|
className,
|
|
99
|
+
style,
|
|
92
100
|
children
|
|
93
101
|
});
|
|
94
102
|
$[0] = Component;
|
|
95
103
|
$[1] = children;
|
|
96
104
|
$[2] = className;
|
|
97
|
-
$[3] =
|
|
98
|
-
|
|
105
|
+
$[3] = style;
|
|
106
|
+
$[4] = t3$1;
|
|
107
|
+
} else t3$1 = $[4];
|
|
99
108
|
return t3$1;
|
|
100
109
|
}
|
|
101
|
-
const
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
t3 = (e) => {
|
|
106
|
-
e.stopPropagation();
|
|
107
|
-
if (onClick) onClick(fullPath, {
|
|
108
|
-
blockId: blockScope?.blockId,
|
|
109
|
-
fieldType
|
|
110
|
-
});
|
|
111
|
-
else handleFieldClick(fullPath, {
|
|
112
|
-
blockId: blockScope?.blockId,
|
|
113
|
-
fieldType
|
|
114
|
-
});
|
|
115
|
-
};
|
|
116
|
-
$[4] = blockScope?.blockId;
|
|
117
|
-
$[5] = fieldType;
|
|
118
|
-
$[6] = fullPath;
|
|
119
|
-
$[7] = handleFieldClick;
|
|
120
|
-
$[8] = onClick;
|
|
121
|
-
$[9] = t3;
|
|
122
|
-
} else t3 = $[9];
|
|
123
|
-
const handleClick = t3;
|
|
124
|
-
const t4 = blockScope?.blockId;
|
|
125
|
-
const t5 = isFocused && "outline-primary outline outline-2 outline-offset-2";
|
|
126
|
-
let t6;
|
|
127
|
-
if ($[10] !== className || $[11] !== t5) {
|
|
128
|
-
t6 = cn(className, "group relative cursor-pointer transition-[outline-color,outline-offset] duration-150", "hover:outline-primary/60 hover:hover:outline hover:outline-2 hover:outline-offset-2 hover:outline-dashed", t5);
|
|
129
|
-
$[10] = className;
|
|
130
|
-
$[11] = t5;
|
|
131
|
-
$[12] = t6;
|
|
132
|
-
} else t6 = $[12];
|
|
110
|
+
const t3 = blockScope?.blockId;
|
|
111
|
+
const t4 = context.focusedField === fullPath;
|
|
112
|
+
const t5 = onClick ?? context.handleFieldClick;
|
|
113
|
+
const t6 = onValueCommit ?? context.handleFieldValueEdited;
|
|
133
114
|
let t7;
|
|
134
|
-
if ($[
|
|
135
|
-
t7 = /* @__PURE__ */ jsx(
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
115
|
+
if ($[5] !== Component || $[6] !== children || $[7] !== className || $[8] !== editable || $[9] !== fieldType || $[10] !== fullPath || $[11] !== style || $[12] !== t3 || $[13] !== t4 || $[14] !== t5 || $[15] !== t6) {
|
|
116
|
+
t7 = /* @__PURE__ */ jsx(PreviewFieldElement, {
|
|
117
|
+
Component,
|
|
118
|
+
blockId: t3,
|
|
119
|
+
className,
|
|
120
|
+
editable,
|
|
121
|
+
fieldType,
|
|
122
|
+
fullPath,
|
|
123
|
+
isFocused: t4,
|
|
124
|
+
onClick: t5,
|
|
125
|
+
onValueCommit: t6,
|
|
126
|
+
style,
|
|
141
127
|
children
|
|
142
128
|
});
|
|
143
|
-
$[
|
|
144
|
-
$[
|
|
145
|
-
$[
|
|
146
|
-
$[
|
|
147
|
-
$[
|
|
148
|
-
$[
|
|
149
|
-
$[
|
|
150
|
-
$[
|
|
151
|
-
|
|
129
|
+
$[5] = Component;
|
|
130
|
+
$[6] = children;
|
|
131
|
+
$[7] = className;
|
|
132
|
+
$[8] = editable;
|
|
133
|
+
$[9] = fieldType;
|
|
134
|
+
$[10] = fullPath;
|
|
135
|
+
$[11] = style;
|
|
136
|
+
$[12] = t3;
|
|
137
|
+
$[13] = t4;
|
|
138
|
+
$[14] = t5;
|
|
139
|
+
$[15] = t6;
|
|
140
|
+
$[16] = t7;
|
|
141
|
+
} else t7 = $[16];
|
|
152
142
|
return t7;
|
|
153
143
|
}
|
|
154
144
|
/**
|
|
@@ -156,71 +146,348 @@ function PreviewField(t0) {
|
|
|
156
146
|
* Useful when you can't use PreviewProvider.
|
|
157
147
|
*/
|
|
158
148
|
function StandalonePreviewField(t0) {
|
|
159
|
-
const $ = c(
|
|
160
|
-
const { field, fieldType: t1, children, as: t2, className, isPreviewMode, isFocused, onFieldClick } = t0;
|
|
149
|
+
const $ = c(17);
|
|
150
|
+
const { field, fieldType: t1, editable, children, as: t2, className, style, isPreviewMode, isFocused, onFieldClick, onValueCommit } = t0;
|
|
161
151
|
const fieldType = t1 === void 0 ? "regular" : t1;
|
|
162
152
|
const Component = t2 === void 0 ? "div" : t2;
|
|
163
153
|
const blockScope = useBlockScope();
|
|
164
154
|
const fullPath = useResolveFieldPath(field);
|
|
165
155
|
if (!isPreviewMode) {
|
|
166
156
|
let t3$1;
|
|
167
|
-
if ($[0] !== Component || $[1] !== children || $[2] !== className) {
|
|
157
|
+
if ($[0] !== Component || $[1] !== children || $[2] !== className || $[3] !== style) {
|
|
168
158
|
t3$1 = /* @__PURE__ */ jsx(Component, {
|
|
169
159
|
className,
|
|
160
|
+
style,
|
|
170
161
|
children
|
|
171
162
|
});
|
|
172
163
|
$[0] = Component;
|
|
173
164
|
$[1] = children;
|
|
174
165
|
$[2] = className;
|
|
175
|
-
$[3] =
|
|
176
|
-
|
|
166
|
+
$[3] = style;
|
|
167
|
+
$[4] = t3$1;
|
|
168
|
+
} else t3$1 = $[4];
|
|
177
169
|
return t3$1;
|
|
178
170
|
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
171
|
+
const t3 = blockScope?.blockId;
|
|
172
|
+
const t4 = !!isFocused;
|
|
173
|
+
let t5;
|
|
174
|
+
if ($[5] !== Component || $[6] !== children || $[7] !== className || $[8] !== editable || $[9] !== fieldType || $[10] !== fullPath || $[11] !== onFieldClick || $[12] !== onValueCommit || $[13] !== style || $[14] !== t3 || $[15] !== t4) {
|
|
175
|
+
t5 = /* @__PURE__ */ jsx(PreviewFieldElement, {
|
|
176
|
+
Component,
|
|
177
|
+
blockId: t3,
|
|
178
|
+
className,
|
|
179
|
+
editable,
|
|
180
|
+
fieldType,
|
|
181
|
+
fullPath,
|
|
182
|
+
isFocused: t4,
|
|
183
|
+
onClick: onFieldClick,
|
|
184
|
+
onValueCommit,
|
|
185
|
+
style,
|
|
186
|
+
children
|
|
187
|
+
});
|
|
188
|
+
$[5] = Component;
|
|
189
|
+
$[6] = children;
|
|
190
|
+
$[7] = className;
|
|
191
|
+
$[8] = editable;
|
|
192
|
+
$[9] = fieldType;
|
|
193
|
+
$[10] = fullPath;
|
|
194
|
+
$[11] = onFieldClick;
|
|
195
|
+
$[12] = onValueCommit;
|
|
196
|
+
$[13] = style;
|
|
197
|
+
$[14] = t3;
|
|
198
|
+
$[15] = t4;
|
|
199
|
+
$[16] = t5;
|
|
200
|
+
} else t5 = $[16];
|
|
201
|
+
return t5;
|
|
202
|
+
}
|
|
203
|
+
function PreviewFieldElement(t0) {
|
|
204
|
+
const $ = c(66);
|
|
205
|
+
const { Component, blockId, children, className, editable, fieldType, fullPath, isFocused, onClick, onValueCommit, style } = t0;
|
|
206
|
+
const [isEditing, setIsEditing] = React.useState(false);
|
|
207
|
+
const [draftValue, setDraftValue] = React.useState("");
|
|
208
|
+
const [isHovered, setIsHovered] = React.useState(false);
|
|
209
|
+
const [hasDomFocus, setHasDomFocus] = React.useState(false);
|
|
210
|
+
const inputRef = React.useRef(null);
|
|
211
|
+
const isEditable = editable === "text" || editable === "textarea";
|
|
212
|
+
const shouldShowAffordance = isHovered || hasDomFocus || isFocused || isEditing;
|
|
213
|
+
const t1 = shouldShowAffordance ? "var(--ring, var(--highlight, #b700ff))" : "transparent";
|
|
214
|
+
const t2 = shouldShowAffordance ? `0 0 0 ${isEditing ? 5 : 4}px color-mix(in srgb, var(--ring, var(--highlight, #b700ff)) ${isEditing ? 24 : 16}%, transparent)` : void 0;
|
|
215
|
+
const t3 = isEditable ? "text" : "pointer";
|
|
216
|
+
let t4;
|
|
217
|
+
if ($[0] !== style || $[1] !== t1 || $[2] !== t2 || $[3] !== t3) {
|
|
218
|
+
t4 = {
|
|
219
|
+
outlineColor: t1,
|
|
220
|
+
outlineOffset: "2px",
|
|
221
|
+
outlineStyle: "solid",
|
|
222
|
+
outlineWidth: "2px",
|
|
223
|
+
boxShadow: t2,
|
|
224
|
+
borderRadius: "2px",
|
|
225
|
+
cursor: t3,
|
|
226
|
+
transition: "outline-color 150ms ease, box-shadow 150ms ease, background-color 150ms ease",
|
|
227
|
+
...style
|
|
187
228
|
};
|
|
188
|
-
$[
|
|
189
|
-
$[
|
|
190
|
-
$[
|
|
191
|
-
$[
|
|
192
|
-
$[
|
|
193
|
-
} else
|
|
194
|
-
const
|
|
195
|
-
|
|
196
|
-
const t5 = isFocused && "outline-primary outline outline-2 outline-offset-2";
|
|
229
|
+
$[0] = style;
|
|
230
|
+
$[1] = t1;
|
|
231
|
+
$[2] = t2;
|
|
232
|
+
$[3] = t3;
|
|
233
|
+
$[4] = t4;
|
|
234
|
+
} else t4 = $[4];
|
|
235
|
+
const previewStyle = t4;
|
|
236
|
+
let t5;
|
|
197
237
|
let t6;
|
|
198
|
-
if ($[
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
238
|
+
if ($[5] !== isEditing) {
|
|
239
|
+
t5 = () => {
|
|
240
|
+
if (isEditing) {
|
|
241
|
+
inputRef.current?.focus();
|
|
242
|
+
inputRef.current?.select();
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
t6 = [isEditing];
|
|
246
|
+
$[5] = isEditing;
|
|
247
|
+
$[6] = t5;
|
|
248
|
+
$[7] = t6;
|
|
249
|
+
} else {
|
|
250
|
+
t5 = $[6];
|
|
251
|
+
t6 = $[7];
|
|
252
|
+
}
|
|
253
|
+
React.useEffect(t5, t6);
|
|
204
254
|
let t7;
|
|
205
|
-
if ($[
|
|
206
|
-
t7 =
|
|
255
|
+
if ($[8] !== children || $[9] !== isEditable) {
|
|
256
|
+
t7 = () => {
|
|
257
|
+
if (!isEditable) return;
|
|
258
|
+
setDraftValue(childrenToEditableValue(children));
|
|
259
|
+
setIsEditing(true);
|
|
260
|
+
};
|
|
261
|
+
$[8] = children;
|
|
262
|
+
$[9] = isEditable;
|
|
263
|
+
$[10] = t7;
|
|
264
|
+
} else t7 = $[10];
|
|
265
|
+
const startEditing = t7;
|
|
266
|
+
let t8;
|
|
267
|
+
if ($[11] !== blockId || $[12] !== fieldType || $[13] !== fullPath || $[14] !== onClick) {
|
|
268
|
+
t8 = () => {
|
|
269
|
+
onClick(fullPath, {
|
|
270
|
+
blockId,
|
|
271
|
+
fieldType
|
|
272
|
+
});
|
|
273
|
+
};
|
|
274
|
+
$[11] = blockId;
|
|
275
|
+
$[12] = fieldType;
|
|
276
|
+
$[13] = fullPath;
|
|
277
|
+
$[14] = onClick;
|
|
278
|
+
$[15] = t8;
|
|
279
|
+
} else t8 = $[15];
|
|
280
|
+
const routeClick = t8;
|
|
281
|
+
let t9;
|
|
282
|
+
if ($[16] !== blockId || $[17] !== draftValue || $[18] !== editable || $[19] !== fieldType || $[20] !== fullPath || $[21] !== isEditing || $[22] !== onValueCommit) {
|
|
283
|
+
t9 = () => {
|
|
284
|
+
if (!isEditing || !editable) return;
|
|
285
|
+
const payload = {
|
|
286
|
+
path: fullPath,
|
|
287
|
+
value: draftValue,
|
|
288
|
+
inputKind: editable,
|
|
289
|
+
blockId,
|
|
290
|
+
fieldType
|
|
291
|
+
};
|
|
292
|
+
if (onValueCommit) onValueCommit(payload);
|
|
293
|
+
else postFieldValueEdited(payload);
|
|
294
|
+
setIsEditing(false);
|
|
295
|
+
};
|
|
296
|
+
$[16] = blockId;
|
|
297
|
+
$[17] = draftValue;
|
|
298
|
+
$[18] = editable;
|
|
299
|
+
$[19] = fieldType;
|
|
300
|
+
$[20] = fullPath;
|
|
301
|
+
$[21] = isEditing;
|
|
302
|
+
$[22] = onValueCommit;
|
|
303
|
+
$[23] = t9;
|
|
304
|
+
} else t9 = $[23];
|
|
305
|
+
const commitEdit = t9;
|
|
306
|
+
let t10;
|
|
307
|
+
if ($[24] !== children) {
|
|
308
|
+
t10 = () => {
|
|
309
|
+
setIsEditing(false);
|
|
310
|
+
setDraftValue(childrenToEditableValue(children));
|
|
311
|
+
};
|
|
312
|
+
$[24] = children;
|
|
313
|
+
$[25] = t10;
|
|
314
|
+
} else t10 = $[25];
|
|
315
|
+
const cancelEdit = t10;
|
|
316
|
+
let t11;
|
|
317
|
+
if ($[26] !== isEditing || $[27] !== routeClick) {
|
|
318
|
+
t11 = (event) => {
|
|
319
|
+
event.preventDefault();
|
|
320
|
+
event.stopPropagation();
|
|
321
|
+
if (!isEditing) routeClick();
|
|
322
|
+
};
|
|
323
|
+
$[26] = isEditing;
|
|
324
|
+
$[27] = routeClick;
|
|
325
|
+
$[28] = t11;
|
|
326
|
+
} else t11 = $[28];
|
|
327
|
+
const handleClick = t11;
|
|
328
|
+
let t12;
|
|
329
|
+
if ($[29] !== startEditing) {
|
|
330
|
+
t12 = (event_0) => {
|
|
331
|
+
event_0.preventDefault();
|
|
332
|
+
event_0.stopPropagation();
|
|
333
|
+
startEditing();
|
|
334
|
+
};
|
|
335
|
+
$[29] = startEditing;
|
|
336
|
+
$[30] = t12;
|
|
337
|
+
} else t12 = $[30];
|
|
338
|
+
const handleDoubleClick = t12;
|
|
339
|
+
let t13;
|
|
340
|
+
if ($[31] !== cancelEdit || $[32] !== commitEdit || $[33] !== editable || $[34] !== isEditable || $[35] !== isEditing || $[36] !== routeClick || $[37] !== startEditing) {
|
|
341
|
+
t13 = (event_1) => {
|
|
342
|
+
event_1.stopPropagation();
|
|
343
|
+
if (!isEditing) {
|
|
344
|
+
if (event_1.key === "Enter" && isEditable) {
|
|
345
|
+
event_1.preventDefault();
|
|
346
|
+
routeClick();
|
|
347
|
+
startEditing();
|
|
348
|
+
}
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
if (event_1.key === "Escape") {
|
|
352
|
+
event_1.preventDefault();
|
|
353
|
+
cancelEdit();
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
356
|
+
if (editable === "text" && event_1.key === "Enter") {
|
|
357
|
+
event_1.preventDefault();
|
|
358
|
+
commitEdit();
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
361
|
+
if (editable === "textarea" && event_1.key === "Enter" && (event_1.metaKey || event_1.ctrlKey)) {
|
|
362
|
+
event_1.preventDefault();
|
|
363
|
+
commitEdit();
|
|
364
|
+
}
|
|
365
|
+
};
|
|
366
|
+
$[31] = cancelEdit;
|
|
367
|
+
$[32] = commitEdit;
|
|
368
|
+
$[33] = editable;
|
|
369
|
+
$[34] = isEditable;
|
|
370
|
+
$[35] = isEditing;
|
|
371
|
+
$[36] = routeClick;
|
|
372
|
+
$[37] = startEditing;
|
|
373
|
+
$[38] = t13;
|
|
374
|
+
} else t13 = $[38];
|
|
375
|
+
const handleKeyDown = t13;
|
|
376
|
+
let t14;
|
|
377
|
+
if ($[39] !== commitEdit || $[40] !== draftValue || $[41] !== editable || $[42] !== handleKeyDown) {
|
|
378
|
+
t14 = editable === "textarea" ? /* @__PURE__ */ jsx("textarea", {
|
|
379
|
+
ref: inputRef,
|
|
380
|
+
value: draftValue,
|
|
381
|
+
onChange: (event_2) => setDraftValue(event_2.target.value),
|
|
382
|
+
onBlur: commitEdit,
|
|
383
|
+
onClick: _temp2,
|
|
384
|
+
onKeyDown: handleKeyDown,
|
|
385
|
+
className: "min-h-[4lh] w-full resize-y bg-transparent p-0 [letter-spacing:inherit] text-inherit outline-none [font:inherit]"
|
|
386
|
+
}) : /* @__PURE__ */ jsx("input", {
|
|
387
|
+
ref: inputRef,
|
|
388
|
+
type: "text",
|
|
389
|
+
value: draftValue,
|
|
390
|
+
onChange: (event_4) => setDraftValue(event_4.target.value),
|
|
391
|
+
onBlur: commitEdit,
|
|
392
|
+
onClick: _temp3,
|
|
393
|
+
onKeyDown: handleKeyDown,
|
|
394
|
+
className: "w-full bg-transparent p-0 [letter-spacing:inherit] text-inherit outline-none [font:inherit]"
|
|
395
|
+
});
|
|
396
|
+
$[39] = commitEdit;
|
|
397
|
+
$[40] = draftValue;
|
|
398
|
+
$[41] = editable;
|
|
399
|
+
$[42] = handleKeyDown;
|
|
400
|
+
$[43] = t14;
|
|
401
|
+
} else t14 = $[43];
|
|
402
|
+
const editor = t14;
|
|
403
|
+
const t15 = isEditing ? "true" : void 0;
|
|
404
|
+
let t16;
|
|
405
|
+
let t17;
|
|
406
|
+
let t18;
|
|
407
|
+
let t19;
|
|
408
|
+
if ($[44] === Symbol.for("react.memo_cache_sentinel")) {
|
|
409
|
+
t16 = () => setIsHovered(true);
|
|
410
|
+
t17 = () => setIsHovered(false);
|
|
411
|
+
t18 = () => setHasDomFocus(true);
|
|
412
|
+
t19 = () => setHasDomFocus(false);
|
|
413
|
+
$[44] = t16;
|
|
414
|
+
$[45] = t17;
|
|
415
|
+
$[46] = t18;
|
|
416
|
+
$[47] = t19;
|
|
417
|
+
} else {
|
|
418
|
+
t16 = $[44];
|
|
419
|
+
t17 = $[45];
|
|
420
|
+
t18 = $[46];
|
|
421
|
+
t19 = $[47];
|
|
422
|
+
}
|
|
423
|
+
const t20 = isEditable && "cursor-text";
|
|
424
|
+
const t21 = isFocused && "outline-primary shadow-[0_0_0_4px_hsl(var(--primary)/0.14)]";
|
|
425
|
+
const t22 = isEditing && "outline-primary bg-background/80 shadow-[0_0_0_4px_hsl(var(--primary)/0.18)]";
|
|
426
|
+
let t23;
|
|
427
|
+
if ($[48] !== className || $[49] !== t20 || $[50] !== t21 || $[51] !== t22) {
|
|
428
|
+
t23 = cn(className, "group/preview-field relative rounded-[2px] transition-[box-shadow,outline-color,outline-offset] duration-150", "cursor-pointer outline outline-2 outline-offset-2 outline-transparent", "hover:outline-primary/50 hover:shadow-[0_0_0_4px_hsl(var(--primary)/0.10)]", "focus-visible:outline-primary/70 focus-visible:shadow-[0_0_0_4px_hsl(var(--primary)/0.12)]", t20, t21, t22);
|
|
429
|
+
$[48] = className;
|
|
430
|
+
$[49] = t20;
|
|
431
|
+
$[50] = t21;
|
|
432
|
+
$[51] = t22;
|
|
433
|
+
$[52] = t23;
|
|
434
|
+
} else t23 = $[52];
|
|
435
|
+
const t24 = isEditing ? editor : children;
|
|
436
|
+
let t25;
|
|
437
|
+
if ($[53] !== Component || $[54] !== blockId || $[55] !== editable || $[56] !== fieldType || $[57] !== fullPath || $[58] !== handleClick || $[59] !== handleDoubleClick || $[60] !== handleKeyDown || $[61] !== previewStyle || $[62] !== t15 || $[63] !== t23 || $[64] !== t24) {
|
|
438
|
+
t25 = /* @__PURE__ */ jsx(Component, {
|
|
207
439
|
"data-preview-field": fullPath,
|
|
208
|
-
"data-block-id":
|
|
440
|
+
"data-block-id": blockId,
|
|
209
441
|
"data-field-type": fieldType,
|
|
442
|
+
"data-preview-editable": editable,
|
|
443
|
+
"data-preview-editing": t15,
|
|
444
|
+
tabIndex: 0,
|
|
210
445
|
onClick: handleClick,
|
|
211
|
-
|
|
212
|
-
|
|
446
|
+
onDoubleClick: handleDoubleClick,
|
|
447
|
+
onKeyDown: handleKeyDown,
|
|
448
|
+
onMouseEnter: t16,
|
|
449
|
+
onMouseLeave: t17,
|
|
450
|
+
onFocus: t18,
|
|
451
|
+
onBlur: t19,
|
|
452
|
+
style: previewStyle,
|
|
453
|
+
className: t23,
|
|
454
|
+
children: t24
|
|
213
455
|
});
|
|
214
|
-
$[
|
|
215
|
-
$[
|
|
216
|
-
$[
|
|
217
|
-
$[
|
|
218
|
-
$[
|
|
219
|
-
$[
|
|
220
|
-
$[
|
|
221
|
-
$[
|
|
222
|
-
|
|
223
|
-
|
|
456
|
+
$[53] = Component;
|
|
457
|
+
$[54] = blockId;
|
|
458
|
+
$[55] = editable;
|
|
459
|
+
$[56] = fieldType;
|
|
460
|
+
$[57] = fullPath;
|
|
461
|
+
$[58] = handleClick;
|
|
462
|
+
$[59] = handleDoubleClick;
|
|
463
|
+
$[60] = handleKeyDown;
|
|
464
|
+
$[61] = previewStyle;
|
|
465
|
+
$[62] = t15;
|
|
466
|
+
$[63] = t23;
|
|
467
|
+
$[64] = t24;
|
|
468
|
+
$[65] = t25;
|
|
469
|
+
} else t25 = $[65];
|
|
470
|
+
return t25;
|
|
471
|
+
}
|
|
472
|
+
function _temp3(event_5) {
|
|
473
|
+
return event_5.stopPropagation();
|
|
474
|
+
}
|
|
475
|
+
function _temp2(event_3) {
|
|
476
|
+
return event_3.stopPropagation();
|
|
477
|
+
}
|
|
478
|
+
function childrenToEditableValue(children) {
|
|
479
|
+
if (children === null || children === void 0 || typeof children === "boolean") return "";
|
|
480
|
+
if (typeof children === "string" || typeof children === "number") return String(children);
|
|
481
|
+
if (Array.isArray(children)) return children.map(childrenToEditableValue).join("");
|
|
482
|
+
if (React.isValidElement(children)) return childrenToEditableValue(children.props.children);
|
|
483
|
+
return "";
|
|
484
|
+
}
|
|
485
|
+
function postFieldValueEdited(payload) {
|
|
486
|
+
if (typeof window === "undefined" || !window.parent) return;
|
|
487
|
+
window.parent.postMessage({
|
|
488
|
+
type: "FIELD_VALUE_EDITED",
|
|
489
|
+
...payload
|
|
490
|
+
}, "*");
|
|
224
491
|
}
|
|
225
492
|
|
|
226
493
|
//#endregion
|
|
@@ -29,10 +29,50 @@ type FocusFieldMessage = {
|
|
|
29
29
|
/** Field path to focus (supports full scoped paths) */
|
|
30
30
|
fieldPath: string;
|
|
31
31
|
};
|
|
32
|
+
/**
|
|
33
|
+
* Single preview draft patch operation.
|
|
34
|
+
*/
|
|
35
|
+
type PreviewPatchOp = {
|
|
36
|
+
op: "set" | "remove";
|
|
37
|
+
path: string;
|
|
38
|
+
value?: unknown;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Seed preview with a full draft snapshot.
|
|
42
|
+
*/
|
|
43
|
+
type InitSnapshotMessage = {
|
|
44
|
+
type: "INIT_SNAPSHOT";
|
|
45
|
+
seq: number;
|
|
46
|
+
data: unknown;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Apply a batch of draft changes.
|
|
50
|
+
*/
|
|
51
|
+
type PatchBatchMessage = {
|
|
52
|
+
type: "PATCH_BATCH";
|
|
53
|
+
seq: number;
|
|
54
|
+
ops: PreviewPatchOp[];
|
|
55
|
+
snapshotVersion?: number;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Replace preview draft after a successful save.
|
|
59
|
+
*/
|
|
60
|
+
type CommitMessage = {
|
|
61
|
+
type: "COMMIT";
|
|
62
|
+
seq: number;
|
|
63
|
+
data: unknown;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Ask preview to discard its draft and reload from the canonical loader.
|
|
67
|
+
*/
|
|
68
|
+
type FullResyncMessage = {
|
|
69
|
+
type: "FULL_RESYNC";
|
|
70
|
+
reason?: string;
|
|
71
|
+
};
|
|
32
72
|
/**
|
|
33
73
|
* All messages from Admin to Preview.
|
|
34
74
|
*/
|
|
35
|
-
type AdminToPreviewMessage = PreviewRefreshMessage | SelectBlockMessage | FocusFieldMessage;
|
|
75
|
+
type AdminToPreviewMessage = PreviewRefreshMessage | SelectBlockMessage | FocusFieldMessage | InitSnapshotMessage | PatchBatchMessage | CommitMessage | FullResyncMessage;
|
|
36
76
|
/**
|
|
37
77
|
* Preview is ready to receive data.
|
|
38
78
|
*/
|
|
@@ -59,6 +99,20 @@ type BlockClickedMessage = {
|
|
|
59
99
|
/** Block ID that was clicked */
|
|
60
100
|
blockId: string;
|
|
61
101
|
};
|
|
102
|
+
type BlockInsertPosition = {
|
|
103
|
+
parentId: string | null;
|
|
104
|
+
index: number;
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* User asked to insert a block from the preview surface.
|
|
108
|
+
*/
|
|
109
|
+
type BlockInsertRequestedMessage = {
|
|
110
|
+
type: "BLOCK_INSERT_REQUESTED";
|
|
111
|
+
/** Insert position in the existing block tree editor */
|
|
112
|
+
position: BlockInsertPosition;
|
|
113
|
+
/** Nearby block used for focus/scroll context */
|
|
114
|
+
referenceBlockId?: string;
|
|
115
|
+
};
|
|
62
116
|
/**
|
|
63
117
|
* Preview refresh completed.
|
|
64
118
|
* Sent after preview successfully re-runs loader.
|
|
@@ -68,10 +122,35 @@ type RefreshCompleteMessage = {
|
|
|
68
122
|
/** Timestamp of completion */
|
|
69
123
|
timestamp: number;
|
|
70
124
|
};
|
|
125
|
+
/**
|
|
126
|
+
* Preview acknowledged a patch batch.
|
|
127
|
+
*/
|
|
128
|
+
type PatchAppliedMessage = {
|
|
129
|
+
type: "PATCH_APPLIED";
|
|
130
|
+
seq: number;
|
|
131
|
+
};
|
|
132
|
+
/**
|
|
133
|
+
* Preview detected a mismatch and requested a full resync.
|
|
134
|
+
*/
|
|
135
|
+
type ResyncRequestMessage = {
|
|
136
|
+
type: "RESYNC_REQUEST";
|
|
137
|
+
reason?: string;
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
140
|
+
* User committed an inline edit inside the preview iframe.
|
|
141
|
+
*/
|
|
142
|
+
type FieldValueEditedMessage = {
|
|
143
|
+
type: "FIELD_VALUE_EDITED";
|
|
144
|
+
path: string;
|
|
145
|
+
value: unknown;
|
|
146
|
+
inputKind: "text" | "textarea" | "number" | "boolean";
|
|
147
|
+
blockId?: string;
|
|
148
|
+
fieldType?: "regular" | "block" | "relation";
|
|
149
|
+
};
|
|
71
150
|
/**
|
|
72
151
|
* All messages from Preview to Admin.
|
|
73
152
|
*/
|
|
74
|
-
type PreviewToAdminMessage = PreviewReadyMessage | FieldClickedMessage | BlockClickedMessage | RefreshCompleteMessage;
|
|
153
|
+
type PreviewToAdminMessage = PreviewReadyMessage | FieldClickedMessage | BlockClickedMessage | BlockInsertRequestedMessage | RefreshCompleteMessage | PatchAppliedMessage | ResyncRequestMessage | FieldValueEditedMessage;
|
|
75
154
|
/**
|
|
76
155
|
* Preview configuration for a collection.
|
|
77
156
|
*/
|
|
@@ -111,4 +190,4 @@ declare function isAdminToPreviewMessage(data: unknown): data is AdminToPreviewM
|
|
|
111
190
|
*/
|
|
112
191
|
declare function isPreviewToAdminMessage(data: unknown): data is PreviewToAdminMessage;
|
|
113
192
|
//#endregion
|
|
114
|
-
export { AdminToPreviewMessage, BlockClickedMessage, FieldClickedMessage, FocusFieldMessage, PreviewConfig, PreviewReadyMessage, PreviewRefreshMessage, PreviewToAdminMessage, RefreshCompleteMessage, SelectBlockMessage, isAdminToPreviewMessage, isPreviewToAdminMessage };
|
|
193
|
+
export { AdminToPreviewMessage, BlockClickedMessage, CommitMessage, FieldClickedMessage, FieldValueEditedMessage, FocusFieldMessage, FullResyncMessage, InitSnapshotMessage, PatchAppliedMessage, PatchBatchMessage, PreviewConfig, PreviewPatchOp, PreviewReadyMessage, PreviewRefreshMessage, PreviewToAdminMessage, RefreshCompleteMessage, ResyncRequestMessage, SelectBlockMessage, isAdminToPreviewMessage, isPreviewToAdminMessage };
|