@arkcit/engine 0.3.0
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/README.md +68 -0
- package/dist/UIEngine.d.ts +6 -0
- package/dist/UIEngine.js +3235 -0
- package/dist/bindings.d.ts +8 -0
- package/dist/bindings.js +146 -0
- package/dist/components/index.d.ts +17 -0
- package/dist/components/index.js +143 -0
- package/dist/core/index.d.ts +4 -0
- package/dist/core/index.js +9 -0
- package/dist/form/engineFormValidation.d.ts +2 -0
- package/dist/form/engineFormValidation.js +241 -0
- package/dist/form.d.ts +67 -0
- package/dist/form.js +241 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +3336 -0
- package/dist/layout.d.ts +6 -0
- package/dist/layout.js +82 -0
- package/dist/preview/index.d.ts +63 -0
- package/dist/preview/index.js +1514 -0
- package/dist/react-web/index.d.ts +8 -0
- package/dist/react-web/index.js +3246 -0
- package/dist/registry.d.ts +2 -0
- package/dist/registry.js +0 -0
- package/dist/render-layer/index.d.ts +1 -0
- package/dist/render-layer/index.js +13 -0
- package/dist/renderStudioForm-CPQEzvT7.d.ts +75 -0
- package/dist/renderers/index.d.ts +8 -0
- package/dist/renderers/index.js +1570 -0
- package/dist/runtime/index.d.ts +1 -0
- package/dist/runtime/index.js +0 -0
- package/dist/schema/index.d.ts +1 -0
- package/dist/schema/index.js +0 -0
- package/dist/studio-bridge/index.d.ts +501 -0
- package/dist/studio-bridge/index.js +2840 -0
- package/dist/studioProps.d.ts +8 -0
- package/dist/studioProps.js +97 -0
- package/dist/types-9TZ2lQDP.d.ts +60 -0
- package/dist/types-CyAE6ZLH.d.ts +19 -0
- package/dist/types.d.ts +16 -0
- package/dist/types.js +0 -0
- package/dist/wizardEditingHandlers-D50tR-6n.d.ts +163 -0
- package/package.json +160 -0
|
@@ -0,0 +1,2840 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
|
|
21
|
+
// src/studio-bridge/inline/forceFullWidth.ts
|
|
22
|
+
var shouldForceStudioNodeFullWidth = ({
|
|
23
|
+
widthPct,
|
|
24
|
+
nodeType,
|
|
25
|
+
isStudioRendererContext,
|
|
26
|
+
colSpan
|
|
27
|
+
}) => widthPct === null && (nodeType === "Container" || nodeType === "Grid" || colSpan !== void 0 || isStudioRendererContext && (nodeType === "Form" || nodeType === "FormWizard"));
|
|
28
|
+
|
|
29
|
+
// src/studio-bridge/inline/inlineText.ts
|
|
30
|
+
var getEditableTextValue = ({
|
|
31
|
+
node,
|
|
32
|
+
nodeProps,
|
|
33
|
+
propName,
|
|
34
|
+
runtime,
|
|
35
|
+
resolveTranslationValue
|
|
36
|
+
}) => {
|
|
37
|
+
var _a;
|
|
38
|
+
let value = nodeProps[propName];
|
|
39
|
+
if (node.type === "FormField" && (propName === "label" || propName === "name")) {
|
|
40
|
+
const fieldObject = nodeProps.field && typeof nodeProps.field === "object" && !Array.isArray(nodeProps.field) ? nodeProps.field : null;
|
|
41
|
+
if (value === void 0 && fieldObject) {
|
|
42
|
+
value = fieldObject[propName];
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (typeof value === "string") return { value, mode: "primitive" };
|
|
46
|
+
if (typeof value === "number" || typeof value === "boolean") {
|
|
47
|
+
return { value: String(value), mode: "primitive" };
|
|
48
|
+
}
|
|
49
|
+
if (value && typeof value === "object") {
|
|
50
|
+
if ("$t" in value && typeof value.$t === "string") {
|
|
51
|
+
const translationValue = value;
|
|
52
|
+
const resolvedValue = resolveTranslationValue(translationValue, runtime);
|
|
53
|
+
return {
|
|
54
|
+
value: typeof resolvedValue === "string" ? resolvedValue : (_a = translationValue.defaultValue) != null ? _a : translationValue.$t,
|
|
55
|
+
mode: "translation"
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
try {
|
|
59
|
+
return {
|
|
60
|
+
value: JSON.stringify(value, null, 2),
|
|
61
|
+
mode: "json"
|
|
62
|
+
};
|
|
63
|
+
} catch (e) {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return null;
|
|
68
|
+
};
|
|
69
|
+
var selectCandidateInlineProp = ({
|
|
70
|
+
node,
|
|
71
|
+
isWizardStepNode,
|
|
72
|
+
orderedEditableTextProps,
|
|
73
|
+
getTextValue
|
|
74
|
+
}) => {
|
|
75
|
+
var _a, _b;
|
|
76
|
+
if (node.type === "FormField") {
|
|
77
|
+
if (getTextValue("label")) return "label";
|
|
78
|
+
if (getTextValue("name")) return "name";
|
|
79
|
+
}
|
|
80
|
+
if (node.type === "Button") {
|
|
81
|
+
if (getTextValue("children")) return "children";
|
|
82
|
+
}
|
|
83
|
+
if (node.type === "Form") {
|
|
84
|
+
if (getTextValue("title")) return "title";
|
|
85
|
+
}
|
|
86
|
+
if (isWizardStepNode) {
|
|
87
|
+
if (getTextValue("title")) return "title";
|
|
88
|
+
if (getTextValue("description")) return "description";
|
|
89
|
+
}
|
|
90
|
+
const blockedTypes = /* @__PURE__ */ new Set(["Form", "FormWizard", "Accordion", "ExpandablePanel"]);
|
|
91
|
+
if (node.type === "Cover") {
|
|
92
|
+
const coverTextProps = ["eyebrow", "title", "subtitle", "description", "children"];
|
|
93
|
+
return (_a = coverTextProps.find((propName) => getTextValue(propName) !== null)) != null ? _a : null;
|
|
94
|
+
}
|
|
95
|
+
const sourceProps = blockedTypes.has(node.type) ? [] : orderedEditableTextProps;
|
|
96
|
+
return (_b = sourceProps.find((propName) => getTextValue(propName) !== null)) != null ? _b : null;
|
|
97
|
+
};
|
|
98
|
+
var selectEffectiveInlineProp = ({
|
|
99
|
+
node,
|
|
100
|
+
isWizardStepNode,
|
|
101
|
+
hasRenderableChildren,
|
|
102
|
+
childrenInlineEntry,
|
|
103
|
+
candidateInlineProp
|
|
104
|
+
}) => {
|
|
105
|
+
if (isWizardStepNode) return candidateInlineProp;
|
|
106
|
+
if (node.type === "FormField") return candidateInlineProp;
|
|
107
|
+
if (node.type === "ScrollReveal") {
|
|
108
|
+
if (hasRenderableChildren) return null;
|
|
109
|
+
return childrenInlineEntry ? "children" : null;
|
|
110
|
+
}
|
|
111
|
+
if (node.type === "Cover") return candidateInlineProp;
|
|
112
|
+
if (node.type === "Dropdown" || node.type === "Tooltip" || node.type === "Popin" || node.type === "Drawer") {
|
|
113
|
+
return candidateInlineProp;
|
|
114
|
+
}
|
|
115
|
+
if (hasRenderableChildren) {
|
|
116
|
+
return childrenInlineEntry ? "children" : null;
|
|
117
|
+
}
|
|
118
|
+
return candidateInlineProp;
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
// src/studio-bridge/inline/inlineEditing.ts
|
|
122
|
+
var getValueAtPropPath = (source, propPath) => propPath.split(".").filter(Boolean).reduce((current, segment) => {
|
|
123
|
+
if (!current || typeof current !== "object" || Array.isArray(current)) return void 0;
|
|
124
|
+
return current[segment];
|
|
125
|
+
}, source);
|
|
126
|
+
var computeInlineEditorStyle = ({
|
|
127
|
+
wrapperElement,
|
|
128
|
+
targetElementForEditor
|
|
129
|
+
}) => {
|
|
130
|
+
if (!targetElementForEditor) return { inset: 0 };
|
|
131
|
+
const wrapperRect = wrapperElement.getBoundingClientRect();
|
|
132
|
+
const targetRect = targetElementForEditor.getBoundingClientRect();
|
|
133
|
+
return {
|
|
134
|
+
top: Math.max(0, targetRect.top - wrapperRect.top - 2),
|
|
135
|
+
left: Math.max(0, targetRect.left - wrapperRect.left - 2),
|
|
136
|
+
width: Math.max(48, targetRect.width + 4),
|
|
137
|
+
height: Math.max(32, targetRect.height + 4)
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
var shouldUseMultilineInlineEditor = ({
|
|
141
|
+
mode,
|
|
142
|
+
value
|
|
143
|
+
}) => mode === "json" || value.length > 64;
|
|
144
|
+
var applyInlineEditingValue = ({
|
|
145
|
+
editingState,
|
|
146
|
+
rawValue,
|
|
147
|
+
schemaNodes,
|
|
148
|
+
onInlineTextEdit,
|
|
149
|
+
findNodeById: findNodeById2
|
|
150
|
+
}) => {
|
|
151
|
+
var _a;
|
|
152
|
+
if (!onInlineTextEdit) return;
|
|
153
|
+
const isFormFieldLabelOrName = editingState.propName === "label" || editingState.propName === "name";
|
|
154
|
+
const applyFormFieldValue = (nextValue) => {
|
|
155
|
+
var _a2;
|
|
156
|
+
const targetNode2 = findNodeById2(editingState.nodeId, schemaNodes);
|
|
157
|
+
const targetProps2 = (_a2 = targetNode2 == null ? void 0 : targetNode2.props) != null ? _a2 : {};
|
|
158
|
+
const currentField = targetProps2.field && typeof targetProps2.field === "object" && !Array.isArray(targetProps2.field) ? targetProps2.field : {};
|
|
159
|
+
if ((targetNode2 == null ? void 0 : targetNode2.type) === "FormField" && isFormFieldLabelOrName) {
|
|
160
|
+
onInlineTextEdit(editingState.nodeId, "field", __spreadProps(__spreadValues({}, currentField), {
|
|
161
|
+
[editingState.propName]: nextValue
|
|
162
|
+
}));
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
const targetNode = findNodeById2(editingState.nodeId, schemaNodes);
|
|
166
|
+
const targetProps = (_a = targetNode == null ? void 0 : targetNode.props) != null ? _a : {};
|
|
167
|
+
const currentValue = getValueAtPropPath(targetProps, editingState.propName);
|
|
168
|
+
if (editingState.mode === "translation" && currentValue && typeof currentValue === "object" && !Array.isArray(currentValue) && typeof currentValue.$t === "string") {
|
|
169
|
+
onInlineTextEdit(editingState.nodeId, editingState.propName, __spreadProps(__spreadValues({}, currentValue), {
|
|
170
|
+
$t: rawValue,
|
|
171
|
+
defaultValue: rawValue
|
|
172
|
+
}));
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
if (editingState.mode === "json") {
|
|
176
|
+
try {
|
|
177
|
+
const parsed = JSON.parse(rawValue);
|
|
178
|
+
applyFormFieldValue(parsed);
|
|
179
|
+
onInlineTextEdit(editingState.nodeId, editingState.propName, parsed);
|
|
180
|
+
return;
|
|
181
|
+
} catch (e) {
|
|
182
|
+
applyFormFieldValue(rawValue);
|
|
183
|
+
onInlineTextEdit(editingState.nodeId, editingState.propName, rawValue);
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
const trimmed = rawValue.trim();
|
|
188
|
+
if (trimmed.startsWith("{") && trimmed.endsWith("}") || trimmed.startsWith("[") && trimmed.endsWith("]")) {
|
|
189
|
+
try {
|
|
190
|
+
const parsed = JSON.parse(trimmed);
|
|
191
|
+
applyFormFieldValue(parsed);
|
|
192
|
+
onInlineTextEdit(editingState.nodeId, editingState.propName, parsed);
|
|
193
|
+
return;
|
|
194
|
+
} catch (e) {
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
applyFormFieldValue(rawValue);
|
|
198
|
+
onInlineTextEdit(editingState.nodeId, editingState.propName, rawValue);
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
// src/studio-bridge/inline/inlineEditorOpening.ts
|
|
202
|
+
var openInlineEditorFromDoubleClick = ({
|
|
203
|
+
event,
|
|
204
|
+
nodeId,
|
|
205
|
+
nodeType,
|
|
206
|
+
effectiveCandidateInlineProp,
|
|
207
|
+
getTextValue,
|
|
208
|
+
setInlineEditing
|
|
209
|
+
}) => {
|
|
210
|
+
var _a;
|
|
211
|
+
const targetElement = event.target;
|
|
212
|
+
const targetInlineProp = (_a = targetElement == null ? void 0 : targetElement.closest("[data-inline-prop]")) == null ? void 0 : _a.getAttribute("data-inline-prop");
|
|
213
|
+
const chosenProp = nodeType === "Cover" && targetInlineProp ? targetInlineProp : targetInlineProp && targetInlineProp !== "children" ? targetInlineProp : effectiveCandidateInlineProp;
|
|
214
|
+
if (!chosenProp) return false;
|
|
215
|
+
const initialEntry = getTextValue(chosenProp);
|
|
216
|
+
if (initialEntry === null) return false;
|
|
217
|
+
const targetElementForEditor = targetInlineProp ? targetElement == null ? void 0 : targetElement.closest("[data-inline-prop]") : null;
|
|
218
|
+
const wrapperElement = event.currentTarget;
|
|
219
|
+
const editorStyle = computeInlineEditorStyle({
|
|
220
|
+
wrapperElement,
|
|
221
|
+
targetElementForEditor
|
|
222
|
+
});
|
|
223
|
+
event.preventDefault();
|
|
224
|
+
event.stopPropagation();
|
|
225
|
+
setInlineEditing({
|
|
226
|
+
nodeId,
|
|
227
|
+
propName: chosenProp,
|
|
228
|
+
value: initialEntry.value,
|
|
229
|
+
multiline: shouldUseMultilineInlineEditor({
|
|
230
|
+
mode: initialEntry.mode,
|
|
231
|
+
value: initialEntry.value
|
|
232
|
+
}),
|
|
233
|
+
mode: initialEntry.mode,
|
|
234
|
+
editorStyle
|
|
235
|
+
});
|
|
236
|
+
return true;
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
// src/studio-bridge/inline/resolveInlineEditingTarget.ts
|
|
240
|
+
var INLINE_TECHNICAL_TEXT_PROPS = /* @__PURE__ */ new Set(["className", "rootMargin"]);
|
|
241
|
+
var PREFERRED_INLINE_TEXT_PROPS = [
|
|
242
|
+
"children",
|
|
243
|
+
"label",
|
|
244
|
+
"title",
|
|
245
|
+
"description",
|
|
246
|
+
"placeholder",
|
|
247
|
+
"name",
|
|
248
|
+
"text"
|
|
249
|
+
];
|
|
250
|
+
var resolveInlineEditingTarget = ({
|
|
251
|
+
node,
|
|
252
|
+
nodeProps,
|
|
253
|
+
runtime,
|
|
254
|
+
editableTextProps,
|
|
255
|
+
resolveTranslationValue
|
|
256
|
+
}) => {
|
|
257
|
+
var _a, _b, _c, _d, _e;
|
|
258
|
+
const isWizardStepNode = node.type === "Container" && String((_a = nodeProps.cardSection) != null ? _a : "") !== "header" && String((_b = nodeProps.cardSection) != null ? _b : "") !== "body" && String((_c = nodeProps.cardSection) != null ? _c : "") !== "footer" && (nodeProps.layout && typeof nodeProps.layout === "object" && !Array.isArray(nodeProps.layout) ? Boolean(nodeProps.layout.wizardStep) : false);
|
|
259
|
+
const canResolveInlineText = isWizardStepNode || editableTextProps.length > 0;
|
|
260
|
+
const orderedEditableTextProps = canResolveInlineText ? [
|
|
261
|
+
...PREFERRED_INLINE_TEXT_PROPS.filter((prop) => editableTextProps.includes(prop)),
|
|
262
|
+
...editableTextProps.filter(
|
|
263
|
+
(prop) => !PREFERRED_INLINE_TEXT_PROPS.includes(prop) && !INLINE_TECHNICAL_TEXT_PROPS.has(prop)
|
|
264
|
+
)
|
|
265
|
+
] : [];
|
|
266
|
+
const getTextValue = canResolveInlineText ? (propName) => getEditableTextValue({
|
|
267
|
+
node,
|
|
268
|
+
nodeProps,
|
|
269
|
+
propName,
|
|
270
|
+
runtime,
|
|
271
|
+
resolveTranslationValue
|
|
272
|
+
}) : () => null;
|
|
273
|
+
const candidateInlineProp = canResolveInlineText ? selectCandidateInlineProp({
|
|
274
|
+
node,
|
|
275
|
+
isWizardStepNode,
|
|
276
|
+
orderedEditableTextProps,
|
|
277
|
+
getTextValue
|
|
278
|
+
}) : null;
|
|
279
|
+
const effectiveCandidateInlineProp = canResolveInlineText ? selectEffectiveInlineProp({
|
|
280
|
+
node,
|
|
281
|
+
isWizardStepNode,
|
|
282
|
+
hasRenderableChildren: ((_e = (_d = node.children) == null ? void 0 : _d.length) != null ? _e : 0) > 0,
|
|
283
|
+
childrenInlineEntry: getTextValue("children"),
|
|
284
|
+
candidateInlineProp
|
|
285
|
+
}) : null;
|
|
286
|
+
return {
|
|
287
|
+
canResolveInlineText,
|
|
288
|
+
isWizardStepNode,
|
|
289
|
+
orderedEditableTextProps,
|
|
290
|
+
getTextValue,
|
|
291
|
+
effectiveCandidateInlineProp
|
|
292
|
+
};
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
// src/studio-bridge/inline/InlineTextEditor.tsx
|
|
296
|
+
import { jsx } from "react/jsx-runtime";
|
|
297
|
+
var InlineTextEditor = ({
|
|
298
|
+
editing,
|
|
299
|
+
onChange,
|
|
300
|
+
onCancel,
|
|
301
|
+
onCommit
|
|
302
|
+
}) => editing.multiline ? /* @__PURE__ */ jsx(
|
|
303
|
+
"textarea",
|
|
304
|
+
{
|
|
305
|
+
className: "absolute z-[260] h-full w-full resize-none rounded-md border border-primary/70 bg-background/95 px-2 py-1 text-sm text-foreground outline-none ring-0 cursor-text shadow-lg",
|
|
306
|
+
style: editing.editorStyle,
|
|
307
|
+
value: editing.value,
|
|
308
|
+
autoFocus: true,
|
|
309
|
+
"aria-label": "Inline text editor",
|
|
310
|
+
onChange: (event) => onChange(event.target.value),
|
|
311
|
+
onBlur: onCommit,
|
|
312
|
+
onKeyDown: (event) => {
|
|
313
|
+
if (event.key === "Escape") {
|
|
314
|
+
event.preventDefault();
|
|
315
|
+
onCancel();
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
if (event.key === "Enter" && (event.metaKey || event.ctrlKey)) {
|
|
319
|
+
event.preventDefault();
|
|
320
|
+
onCommit();
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
) : /* @__PURE__ */ jsx(
|
|
325
|
+
"input",
|
|
326
|
+
{
|
|
327
|
+
className: "absolute z-[260] h-full w-full rounded-md border border-primary/70 bg-background/95 px-2 text-sm text-foreground outline-none ring-0 cursor-text shadow-lg",
|
|
328
|
+
style: editing.editorStyle,
|
|
329
|
+
value: editing.value,
|
|
330
|
+
autoFocus: true,
|
|
331
|
+
"aria-label": "Inline text editor",
|
|
332
|
+
onChange: (event) => onChange(event.target.value),
|
|
333
|
+
onBlur: onCommit,
|
|
334
|
+
onKeyDown: (event) => {
|
|
335
|
+
if (event.key === "Escape") {
|
|
336
|
+
event.preventDefault();
|
|
337
|
+
onCancel();
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
if (event.key === "Enter") {
|
|
341
|
+
event.preventDefault();
|
|
342
|
+
onCommit();
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
);
|
|
347
|
+
|
|
348
|
+
// src/studio-bridge/interactions/studioClick.ts
|
|
349
|
+
var isInteractiveSelectionTarget = ({
|
|
350
|
+
targetElement,
|
|
351
|
+
nodeType,
|
|
352
|
+
isFormInteractiveTarget
|
|
353
|
+
}) => isFormInteractiveTarget(targetElement) && nodeType !== "Button" && nodeType !== "Link";
|
|
354
|
+
var resolveButtonOverlayTarget = ({
|
|
355
|
+
clickEvent,
|
|
356
|
+
boundTargetNodeId,
|
|
357
|
+
overlayCandidates
|
|
358
|
+
}) => {
|
|
359
|
+
var _a, _b, _c;
|
|
360
|
+
const actionLabel = clickEvent && typeof clickEvent === "object" ? "id" in clickEvent ? String((_a = clickEvent.id) != null ? _a : "") : "type" in clickEvent ? String((_b = clickEvent.type) != null ? _b : "") : "" : "";
|
|
361
|
+
const payload = clickEvent && typeof clickEvent === "object" && "payload" in clickEvent && clickEvent.payload && typeof clickEvent.payload === "object" ? clickEvent.payload : null;
|
|
362
|
+
const requestedTargetNodeId = String((_c = payload == null ? void 0 : payload.targetNodeId) != null ? _c : boundTargetNodeId).trim();
|
|
363
|
+
const targetNodeId = requestedTargetNodeId || (overlayCandidates.length === 1 ? overlayCandidates[0] : "");
|
|
364
|
+
return {
|
|
365
|
+
actionLabel,
|
|
366
|
+
payload,
|
|
367
|
+
targetNodeId
|
|
368
|
+
};
|
|
369
|
+
};
|
|
370
|
+
var buildNormalizedActionRef = ({
|
|
371
|
+
clickEvent,
|
|
372
|
+
payload,
|
|
373
|
+
targetNodeId
|
|
374
|
+
}) => {
|
|
375
|
+
const basePayload = payload && typeof payload === "object" ? payload : {};
|
|
376
|
+
const normalizedPayload = targetNodeId && !("targetNodeId" in basePayload) ? __spreadProps(__spreadValues({}, basePayload), { targetNodeId }) : basePayload;
|
|
377
|
+
return clickEvent && typeof clickEvent === "object" && "id" in clickEvent ? __spreadProps(__spreadValues({}, clickEvent), { payload: normalizedPayload }) : clickEvent && typeof clickEvent === "object" && "type" in clickEvent ? __spreadProps(__spreadValues({}, clickEvent), { payload: normalizedPayload }) : clickEvent;
|
|
378
|
+
};
|
|
379
|
+
var syncOverlayStateFromAction = ({
|
|
380
|
+
targetNodeId,
|
|
381
|
+
actionLabel,
|
|
382
|
+
runtime,
|
|
383
|
+
onInlineTextEdit,
|
|
384
|
+
findNodeById: findNodeById2,
|
|
385
|
+
schemaNodes
|
|
386
|
+
}) => {
|
|
387
|
+
if (!targetNodeId || !onInlineTextEdit) return;
|
|
388
|
+
const targetNode = findNodeById2(targetNodeId, schemaNodes);
|
|
389
|
+
if (!targetNode) return;
|
|
390
|
+
const overlaysRaw = runtime.get("overlays.byNodeId");
|
|
391
|
+
const overlaysByNodeId = overlaysRaw && typeof overlaysRaw === "object" ? overlaysRaw : {};
|
|
392
|
+
if (!actionLabel) {
|
|
393
|
+
if (targetNode.type === "Popin") {
|
|
394
|
+
onInlineTextEdit(targetNodeId, "displayedPopin", true);
|
|
395
|
+
} else if (targetNode.type === "Drawer") {
|
|
396
|
+
onInlineTextEdit(targetNodeId, "open", true);
|
|
397
|
+
}
|
|
398
|
+
runtime.dispatch({
|
|
399
|
+
id: "overlay.open",
|
|
400
|
+
payload: { targetNodeId }
|
|
401
|
+
});
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
404
|
+
if (targetNode.type === "Popin") {
|
|
405
|
+
if (actionLabel === "overlay.open") {
|
|
406
|
+
onInlineTextEdit(targetNodeId, "displayedPopin", true);
|
|
407
|
+
} else if (actionLabel === "overlay.close") {
|
|
408
|
+
onInlineTextEdit(targetNodeId, "displayedPopin", false);
|
|
409
|
+
} else if (actionLabel === "overlay.toggle") {
|
|
410
|
+
const current = Boolean(overlaysByNodeId[targetNodeId]);
|
|
411
|
+
onInlineTextEdit(targetNodeId, "displayedPopin", !current);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
if (targetNode.type === "Drawer") {
|
|
415
|
+
if (actionLabel === "overlay.open") {
|
|
416
|
+
onInlineTextEdit(targetNodeId, "open", true);
|
|
417
|
+
} else if (actionLabel === "overlay.close") {
|
|
418
|
+
onInlineTextEdit(targetNodeId, "open", false);
|
|
419
|
+
} else if (actionLabel === "overlay.toggle") {
|
|
420
|
+
const current = Boolean(overlaysByNodeId[targetNodeId]);
|
|
421
|
+
onInlineTextEdit(targetNodeId, "open", !current);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
};
|
|
425
|
+
var resolveClickedNodeId = ({
|
|
426
|
+
targetElement,
|
|
427
|
+
fallbackNodeId
|
|
428
|
+
}) => {
|
|
429
|
+
var _a;
|
|
430
|
+
const closestNode = targetElement == null ? void 0 : targetElement.closest("[data-node-id]");
|
|
431
|
+
return (_a = closestNode == null ? void 0 : closestNode.dataset.nodeId) != null ? _a : fallbackNodeId;
|
|
432
|
+
};
|
|
433
|
+
|
|
434
|
+
// src/studio-bridge/nodes/studioNodeEditing.ts
|
|
435
|
+
var suppressStudioClickUntil = 0;
|
|
436
|
+
var markSuppressStudioClick = (durationMs = 220) => {
|
|
437
|
+
suppressStudioClickUntil = Date.now() + Math.max(0, durationMs);
|
|
438
|
+
};
|
|
439
|
+
var shouldSuppressStudioClick = () => Date.now() <= suppressStudioClickUntil;
|
|
440
|
+
|
|
441
|
+
// src/utils/schemaTraversal.ts
|
|
442
|
+
var findNodeById = (nodeId, nodes) => {
|
|
443
|
+
var _a;
|
|
444
|
+
for (const candidate of nodes) {
|
|
445
|
+
if (candidate.id === nodeId) return candidate;
|
|
446
|
+
const nested = findNodeById(nodeId, (_a = candidate.children) != null ? _a : []);
|
|
447
|
+
if (nested) return nested;
|
|
448
|
+
}
|
|
449
|
+
return null;
|
|
450
|
+
};
|
|
451
|
+
var collectOverlayNodeIds = (nodes) => {
|
|
452
|
+
const ids = [];
|
|
453
|
+
const walk = (items) => {
|
|
454
|
+
var _a;
|
|
455
|
+
for (const item of items) {
|
|
456
|
+
if (item.type === "Popin" || item.type === "Drawer") ids.push(item.id);
|
|
457
|
+
if ((_a = item.children) == null ? void 0 : _a.length) walk(item.children);
|
|
458
|
+
}
|
|
459
|
+
};
|
|
460
|
+
walk(nodes);
|
|
461
|
+
return ids;
|
|
462
|
+
};
|
|
463
|
+
|
|
464
|
+
// src/studio-bridge/interactions/resizeStudio.ts
|
|
465
|
+
var computeMouseResizeSize = ({
|
|
466
|
+
state,
|
|
467
|
+
clientX,
|
|
468
|
+
clientY,
|
|
469
|
+
minWidthPct,
|
|
470
|
+
minHeightPct,
|
|
471
|
+
minHeightPx
|
|
472
|
+
}) => {
|
|
473
|
+
const deltaX = clientX - state.startX;
|
|
474
|
+
const deltaY = clientY - state.startY;
|
|
475
|
+
const nextWidth = state.startWidthPct + deltaX / state.containerWidth * 100;
|
|
476
|
+
const nextHeight = state.startHeightPct + deltaY / state.containerHeight * 100;
|
|
477
|
+
const nextHeightPx = state.startHeightPx + deltaY;
|
|
478
|
+
return {
|
|
479
|
+
widthPct: Math.max(minWidthPct, Math.min(100, Number(nextWidth.toFixed(2)))),
|
|
480
|
+
heightPct: Math.max(minHeightPct, Math.min(100, Number(nextHeight.toFixed(2)))),
|
|
481
|
+
heightPx: Math.max(minHeightPx, Number(nextHeightPx.toFixed(0)))
|
|
482
|
+
};
|
|
483
|
+
};
|
|
484
|
+
var computePinchResizeSize = ({
|
|
485
|
+
state,
|
|
486
|
+
distance,
|
|
487
|
+
minWidthPct,
|
|
488
|
+
minHeightPct
|
|
489
|
+
}) => {
|
|
490
|
+
if (!state.startDistance) return null;
|
|
491
|
+
const scale = distance / state.startDistance;
|
|
492
|
+
const nextWidth = state.startWidthPct * scale;
|
|
493
|
+
const nextHeight = state.startHeightPct * scale;
|
|
494
|
+
return {
|
|
495
|
+
widthPct: Math.max(minWidthPct, Math.min(100, Number(nextWidth.toFixed(2)))),
|
|
496
|
+
heightPct: Math.max(minHeightPct, Math.min(100, Number(nextHeight.toFixed(2))))
|
|
497
|
+
};
|
|
498
|
+
};
|
|
499
|
+
var createMouseResizeState = ({
|
|
500
|
+
nodeId,
|
|
501
|
+
clientX,
|
|
502
|
+
clientY,
|
|
503
|
+
widthPct,
|
|
504
|
+
heightPct,
|
|
505
|
+
heightPx,
|
|
506
|
+
elementRect,
|
|
507
|
+
parentRect,
|
|
508
|
+
minHeightPx
|
|
509
|
+
}) => ({
|
|
510
|
+
nodeId,
|
|
511
|
+
startX: clientX,
|
|
512
|
+
startY: clientY,
|
|
513
|
+
startWidthPct: widthPct != null ? widthPct : elementRect.width / Math.max(parentRect.width, 1) * 100,
|
|
514
|
+
startHeightPct: heightPct != null ? heightPct : elementRect.height / Math.max(parentRect.height, 1) * 100,
|
|
515
|
+
startHeightPx: heightPx != null ? heightPx : Math.max(minHeightPx, elementRect.height),
|
|
516
|
+
containerWidth: Math.max(parentRect.width, 1),
|
|
517
|
+
containerHeight: Math.max(parentRect.height, 1)
|
|
518
|
+
});
|
|
519
|
+
var createPinchResizeState = ({
|
|
520
|
+
nodeId,
|
|
521
|
+
widthPct,
|
|
522
|
+
heightPct,
|
|
523
|
+
distance
|
|
524
|
+
}) => ({
|
|
525
|
+
nodeId,
|
|
526
|
+
startDistance: distance,
|
|
527
|
+
startWidthPct: widthPct != null ? widthPct : 100,
|
|
528
|
+
startHeightPct: heightPct != null ? heightPct : 100
|
|
529
|
+
});
|
|
530
|
+
|
|
531
|
+
// src/studio-bridge/nodes/nodeWrapperHandlers.ts
|
|
532
|
+
var createTouchResizeHandlers = ({
|
|
533
|
+
node,
|
|
534
|
+
widthPct,
|
|
535
|
+
heightPct,
|
|
536
|
+
onNodeResize,
|
|
537
|
+
onNodeResizeStart,
|
|
538
|
+
onNodeResizeEnd,
|
|
539
|
+
pinchStateRef,
|
|
540
|
+
minWidthPct,
|
|
541
|
+
minHeightPct
|
|
542
|
+
}) => ({
|
|
543
|
+
onTouchStart: (event) => {
|
|
544
|
+
if (!onNodeResize) return;
|
|
545
|
+
if (event.touches.length < 2) return;
|
|
546
|
+
onNodeResizeStart == null ? void 0 : onNodeResizeStart(node.id);
|
|
547
|
+
const [firstTouch, secondTouch] = [event.touches[0], event.touches[1]];
|
|
548
|
+
const dx = secondTouch.clientX - firstTouch.clientX;
|
|
549
|
+
const dy = secondTouch.clientY - firstTouch.clientY;
|
|
550
|
+
const distance = Math.hypot(dx, dy);
|
|
551
|
+
pinchStateRef.current = createPinchResizeState({
|
|
552
|
+
nodeId: node.id,
|
|
553
|
+
widthPct,
|
|
554
|
+
heightPct,
|
|
555
|
+
distance
|
|
556
|
+
});
|
|
557
|
+
},
|
|
558
|
+
onTouchMove: (event) => {
|
|
559
|
+
if (!onNodeResize) return;
|
|
560
|
+
const state = pinchStateRef.current;
|
|
561
|
+
if (!state || state.nodeId !== node.id) return;
|
|
562
|
+
if (event.touches.length < 2) return;
|
|
563
|
+
const [firstTouch, secondTouch] = [event.touches[0], event.touches[1]];
|
|
564
|
+
const dx = secondTouch.clientX - firstTouch.clientX;
|
|
565
|
+
const dy = secondTouch.clientY - firstTouch.clientY;
|
|
566
|
+
const distance = Math.hypot(dx, dy);
|
|
567
|
+
const nextSize = computePinchResizeSize({
|
|
568
|
+
state,
|
|
569
|
+
distance,
|
|
570
|
+
minWidthPct,
|
|
571
|
+
minHeightPct
|
|
572
|
+
});
|
|
573
|
+
if (!nextSize) return;
|
|
574
|
+
pinchStateRef.current = __spreadProps(__spreadValues({}, state), {
|
|
575
|
+
lastSize: nextSize
|
|
576
|
+
});
|
|
577
|
+
onNodeResize(node.id, nextSize);
|
|
578
|
+
},
|
|
579
|
+
onTouchEnd: () => {
|
|
580
|
+
const state = pinchStateRef.current;
|
|
581
|
+
if (state == null ? void 0 : state.lastSize) {
|
|
582
|
+
onNodeResizeEnd == null ? void 0 : onNodeResizeEnd(node.id, state.lastSize);
|
|
583
|
+
}
|
|
584
|
+
pinchStateRef.current = null;
|
|
585
|
+
}
|
|
586
|
+
});
|
|
587
|
+
var createMouseResizeHandler = ({
|
|
588
|
+
node,
|
|
589
|
+
widthPct,
|
|
590
|
+
heightPct,
|
|
591
|
+
heightPx,
|
|
592
|
+
onNodeResize,
|
|
593
|
+
onNodeResizeStart,
|
|
594
|
+
resizeStateRef,
|
|
595
|
+
minHeightPx
|
|
596
|
+
}) => onNodeResize ? (event) => {
|
|
597
|
+
event.preventDefault();
|
|
598
|
+
event.stopPropagation();
|
|
599
|
+
const element = event.currentTarget.closest("[data-node-id]");
|
|
600
|
+
if (!element) return;
|
|
601
|
+
const parent = element.parentElement;
|
|
602
|
+
if (!parent) return;
|
|
603
|
+
const parentRect = parent.getBoundingClientRect();
|
|
604
|
+
const elementRect = element.getBoundingClientRect();
|
|
605
|
+
onNodeResizeStart == null ? void 0 : onNodeResizeStart(node.id);
|
|
606
|
+
resizeStateRef.current = createMouseResizeState({
|
|
607
|
+
nodeId: node.id,
|
|
608
|
+
clientX: event.clientX,
|
|
609
|
+
clientY: event.clientY,
|
|
610
|
+
widthPct,
|
|
611
|
+
heightPct,
|
|
612
|
+
heightPx,
|
|
613
|
+
elementRect,
|
|
614
|
+
parentRect,
|
|
615
|
+
minHeightPx
|
|
616
|
+
});
|
|
617
|
+
} : void 0;
|
|
618
|
+
var createStudioNodeClickHandler = ({
|
|
619
|
+
node,
|
|
620
|
+
nodeProps,
|
|
621
|
+
schemaNodes,
|
|
622
|
+
runtime,
|
|
623
|
+
onNodeClick,
|
|
624
|
+
onInlineTextEdit,
|
|
625
|
+
isInlineEditingNode,
|
|
626
|
+
enableEventOnClick,
|
|
627
|
+
isFormInteractiveTarget
|
|
628
|
+
}) => (event) => {
|
|
629
|
+
var _a, _b;
|
|
630
|
+
if (shouldSuppressStudioClick()) {
|
|
631
|
+
event.preventDefault();
|
|
632
|
+
event.stopPropagation();
|
|
633
|
+
return;
|
|
634
|
+
}
|
|
635
|
+
if (!onNodeClick) return;
|
|
636
|
+
if (isInlineEditingNode) return;
|
|
637
|
+
const targetElement = event.target;
|
|
638
|
+
if (node.type === "Button" && enableEventOnClick && Boolean(targetElement == null ? void 0 : targetElement.closest("button"))) {
|
|
639
|
+
const clickEvent = (_a = node.events) == null ? void 0 : _a.onClick;
|
|
640
|
+
const boundTargetNodeId = String((_b = nodeProps.buttonTargetNodeId) != null ? _b : "").trim();
|
|
641
|
+
const overlayCandidates = collectOverlayNodeIds(schemaNodes);
|
|
642
|
+
const { actionLabel, payload, targetNodeId } = resolveButtonOverlayTarget({
|
|
643
|
+
clickEvent,
|
|
644
|
+
boundTargetNodeId,
|
|
645
|
+
overlayCandidates
|
|
646
|
+
});
|
|
647
|
+
if (clickEvent) {
|
|
648
|
+
const normalizedActionRef = buildNormalizedActionRef({
|
|
649
|
+
clickEvent,
|
|
650
|
+
payload,
|
|
651
|
+
targetNodeId
|
|
652
|
+
});
|
|
653
|
+
runtime.dispatch(normalizedActionRef);
|
|
654
|
+
}
|
|
655
|
+
syncOverlayStateFromAction({
|
|
656
|
+
targetNodeId,
|
|
657
|
+
actionLabel: clickEvent ? actionLabel : "",
|
|
658
|
+
runtime,
|
|
659
|
+
onInlineTextEdit,
|
|
660
|
+
findNodeById,
|
|
661
|
+
schemaNodes
|
|
662
|
+
});
|
|
663
|
+
event.stopPropagation();
|
|
664
|
+
return;
|
|
665
|
+
}
|
|
666
|
+
if (isInteractiveSelectionTarget({
|
|
667
|
+
targetElement,
|
|
668
|
+
nodeType: node.type,
|
|
669
|
+
isFormInteractiveTarget
|
|
670
|
+
})) {
|
|
671
|
+
event.stopPropagation();
|
|
672
|
+
return;
|
|
673
|
+
}
|
|
674
|
+
const clickedNodeId = resolveClickedNodeId({
|
|
675
|
+
targetElement,
|
|
676
|
+
fallbackNodeId: node.id
|
|
677
|
+
});
|
|
678
|
+
if (clickedNodeId && clickedNodeId !== node.id) {
|
|
679
|
+
event.stopPropagation();
|
|
680
|
+
onNodeClick(clickedNodeId);
|
|
681
|
+
return;
|
|
682
|
+
}
|
|
683
|
+
event.stopPropagation();
|
|
684
|
+
onNodeClick(node.id);
|
|
685
|
+
};
|
|
686
|
+
var createStudioNodeDoubleClickHandler = ({
|
|
687
|
+
node,
|
|
688
|
+
onInlineTextEdit,
|
|
689
|
+
effectiveCandidateInlineProp,
|
|
690
|
+
getTextValue,
|
|
691
|
+
setInlineEditing
|
|
692
|
+
}) => (event) => {
|
|
693
|
+
if (!onInlineTextEdit) return;
|
|
694
|
+
openInlineEditorFromDoubleClick({
|
|
695
|
+
event,
|
|
696
|
+
nodeId: node.id,
|
|
697
|
+
nodeType: node.type,
|
|
698
|
+
effectiveCandidateInlineProp,
|
|
699
|
+
getTextValue,
|
|
700
|
+
setInlineEditing
|
|
701
|
+
});
|
|
702
|
+
};
|
|
703
|
+
|
|
704
|
+
// src/studio-bridge/nodes/nodeWrapperStudio.tsx
|
|
705
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
706
|
+
var getNodeWrapperPresentation = ({
|
|
707
|
+
isOpenStudioOverlayNode,
|
|
708
|
+
wrapperClassName,
|
|
709
|
+
widthPct,
|
|
710
|
+
shouldForceFullWidth
|
|
711
|
+
}) => {
|
|
712
|
+
const wrapperStyle = isOpenStudioOverlayNode ? {
|
|
713
|
+
position: "absolute",
|
|
714
|
+
inset: 0,
|
|
715
|
+
width: "100%",
|
|
716
|
+
height: "100%"
|
|
717
|
+
} : widthPct !== null || shouldForceFullWidth ? { width: `${widthPct != null ? widthPct : 100}%` } : void 0;
|
|
718
|
+
const overlayWrapperClassName = isOpenStudioOverlayNode ? [wrapperClassName, "absolute inset-0 h-full w-full"].filter(Boolean).join(" ") : wrapperClassName;
|
|
719
|
+
return {
|
|
720
|
+
wrapperStyle,
|
|
721
|
+
overlayWrapperClassName,
|
|
722
|
+
requiresPlainWrapper: Boolean(overlayWrapperClassName) || Boolean(wrapperStyle)
|
|
723
|
+
};
|
|
724
|
+
};
|
|
725
|
+
var getStudioNodeInteractionState = ({
|
|
726
|
+
node,
|
|
727
|
+
selectedNodeId,
|
|
728
|
+
effectiveCandidateInlineProp,
|
|
729
|
+
isInlineEditingNode,
|
|
730
|
+
isOpenStudioOverlayNode,
|
|
731
|
+
isInsideForm,
|
|
732
|
+
isInsideFormWizard,
|
|
733
|
+
isInsideStepForm,
|
|
734
|
+
inlinePropName
|
|
735
|
+
}) => {
|
|
736
|
+
var _a, _b, _c;
|
|
737
|
+
const nodeLayoutRecord = node.props && typeof node.props === "object" && !Array.isArray(node.props) && node.props.layout && typeof node.props.layout === "object" && !Array.isArray(node.props.layout) ? node.props.layout : {};
|
|
738
|
+
const isSelected = selectedNodeId === node.id;
|
|
739
|
+
const isFormFieldNode = node.type === "FormField" && String((_a = nodeLayoutRecord.formRole) != null ? _a : "field").trim() === "field";
|
|
740
|
+
const isTitleLikeInternalNode = String((_b = nodeLayoutRecord.formRole) != null ? _b : "").trim() === "title" || String((_c = nodeLayoutRecord.wizardStepRole) != null ? _c : "").trim() === "title" || ["H1", "H2", "H3", "H4", "H5", "H6"].includes(node.type);
|
|
741
|
+
const isActionButtonLikeNode = node.type === "Button" && (isInsideForm || isInsideFormWizard || isInsideStepForm);
|
|
742
|
+
const studioFormFieldWrapperClassName = isFormFieldNode ? "rounded-lg border-dashed border-sky-400/70 bg-sky-500/5 p-2 hover:border-sky-500 hover:bg-sky-500/10" : "";
|
|
743
|
+
const allowNodeHandles = (() => {
|
|
744
|
+
if (isInsideForm) return isFormFieldNode;
|
|
745
|
+
if (isInsideFormWizard || isInsideStepForm) {
|
|
746
|
+
if (isTitleLikeInternalNode) return false;
|
|
747
|
+
if (isActionButtonLikeNode) return false;
|
|
748
|
+
return true;
|
|
749
|
+
}
|
|
750
|
+
return true;
|
|
751
|
+
})();
|
|
752
|
+
return {
|
|
753
|
+
isSelected,
|
|
754
|
+
allowNodeHandles,
|
|
755
|
+
studioFormFieldWrapperClassName,
|
|
756
|
+
cursorClassName: effectiveCandidateInlineProp ? "cursor-text" : "cursor-pointer",
|
|
757
|
+
preserveContentWhileInlineEditing: isInlineEditingNode && isOpenStudioOverlayNode && (inlinePropName === "title" || inlinePropName === "closeText")
|
|
758
|
+
};
|
|
759
|
+
};
|
|
760
|
+
var renderPlainWrappedNode = ({
|
|
761
|
+
nodeId,
|
|
762
|
+
overlayWrapperClassName,
|
|
763
|
+
wrapperStyle,
|
|
764
|
+
nodeContent
|
|
765
|
+
}) => /* @__PURE__ */ jsx2(
|
|
766
|
+
"div",
|
|
767
|
+
{
|
|
768
|
+
"data-node-id": nodeId,
|
|
769
|
+
className: ["relative min-w-0 max-w-full flex-none", overlayWrapperClassName].filter(Boolean).join(" "),
|
|
770
|
+
style: wrapperStyle,
|
|
771
|
+
children: nodeContent
|
|
772
|
+
},
|
|
773
|
+
nodeId
|
|
774
|
+
);
|
|
775
|
+
|
|
776
|
+
// src/studio-bridge/nodes/StudioNodeWrapper.tsx
|
|
777
|
+
import { jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
778
|
+
var StudioNodeWrapper = ({
|
|
779
|
+
nodeId,
|
|
780
|
+
wrapperClassName = "",
|
|
781
|
+
cursorClassName = "",
|
|
782
|
+
isSelected,
|
|
783
|
+
allowResizeHandle = true,
|
|
784
|
+
style,
|
|
785
|
+
onClick,
|
|
786
|
+
onDoubleClick,
|
|
787
|
+
onTouchStart,
|
|
788
|
+
onTouchMove,
|
|
789
|
+
onTouchEnd,
|
|
790
|
+
showResizeHandle,
|
|
791
|
+
onResizeMouseDown,
|
|
792
|
+
isInlineEditing,
|
|
793
|
+
preserveContentWhileInlineEditing = false,
|
|
794
|
+
children,
|
|
795
|
+
inlineEditor
|
|
796
|
+
}) => /* @__PURE__ */ jsxs(
|
|
797
|
+
"div",
|
|
798
|
+
{
|
|
799
|
+
"data-node-id": nodeId,
|
|
800
|
+
className: [
|
|
801
|
+
"relative block w-fit min-w-0 max-w-full rounded-md border border-transparent transition-colors",
|
|
802
|
+
wrapperClassName,
|
|
803
|
+
cursorClassName,
|
|
804
|
+
isSelected ? "border-dashed border-primary/60 bg-primary/5" : ""
|
|
805
|
+
].filter(Boolean).join(" "),
|
|
806
|
+
style: __spreadValues({
|
|
807
|
+
position: "relative"
|
|
808
|
+
}, style != null ? style : {}),
|
|
809
|
+
onTouchStart,
|
|
810
|
+
onTouchMove,
|
|
811
|
+
onTouchEnd,
|
|
812
|
+
onClick,
|
|
813
|
+
onDoubleClick,
|
|
814
|
+
children: [
|
|
815
|
+
allowResizeHandle && showResizeHandle && onResizeMouseDown ? /* @__PURE__ */ jsx3(
|
|
816
|
+
"button",
|
|
817
|
+
{
|
|
818
|
+
type: "button",
|
|
819
|
+
className: "absolute -right-2 -top-2 z-20 inline-flex h-7 w-7 cursor-nwse-resize items-center justify-center rounded-md border border-primary bg-primary text-xs text-primary-foreground shadow-sm transition-colors hover:bg-primary-hover hover:border-primary-hover",
|
|
820
|
+
"aria-label": "Resize node",
|
|
821
|
+
onMouseDown: onResizeMouseDown,
|
|
822
|
+
children: "\u2922"
|
|
823
|
+
}
|
|
824
|
+
) : null,
|
|
825
|
+
/* @__PURE__ */ jsx3(
|
|
826
|
+
"div",
|
|
827
|
+
{
|
|
828
|
+
className: isInlineEditing && !preserveContentWhileInlineEditing ? "pointer-events-none opacity-0" : void 0,
|
|
829
|
+
children
|
|
830
|
+
}
|
|
831
|
+
),
|
|
832
|
+
isInlineEditing ? inlineEditor : null
|
|
833
|
+
]
|
|
834
|
+
},
|
|
835
|
+
nodeId
|
|
836
|
+
);
|
|
837
|
+
|
|
838
|
+
// src/render-layer/renderDirectives.ts
|
|
839
|
+
var RENDER_BINDING_PROP_NAMES = /* @__PURE__ */ new Set([
|
|
840
|
+
"bindingEnabled",
|
|
841
|
+
"valueBindingKey",
|
|
842
|
+
"optionsBindingKey",
|
|
843
|
+
"useBindingData",
|
|
844
|
+
"entitiesBindingKey",
|
|
845
|
+
"videoBindingKey",
|
|
846
|
+
"mapBindingKey",
|
|
847
|
+
"productBindingKey",
|
|
848
|
+
"useTranslationKeys",
|
|
849
|
+
"tagContentTranslationKey",
|
|
850
|
+
"tagContentTranslationValue",
|
|
851
|
+
"hrefTranslationKey",
|
|
852
|
+
"hrefTranslationValue",
|
|
853
|
+
"mediaSource",
|
|
854
|
+
"mediaSrc",
|
|
855
|
+
"mediaAlt",
|
|
856
|
+
"rowsBindingKey",
|
|
857
|
+
"columnsBindingKey"
|
|
858
|
+
]);
|
|
859
|
+
var STUDIO_INTERNAL_PROP_NAMES = /* @__PURE__ */ new Set([
|
|
860
|
+
...RENDER_BINDING_PROP_NAMES
|
|
861
|
+
]);
|
|
862
|
+
var getRenderBindingProps = (props) => {
|
|
863
|
+
if (!props || typeof props !== "object" || Array.isArray(props)) {
|
|
864
|
+
return {};
|
|
865
|
+
}
|
|
866
|
+
const source = props;
|
|
867
|
+
const embedded = source.__studio && typeof source.__studio === "object" && !Array.isArray(source.__studio) ? source.__studio : {};
|
|
868
|
+
const legacy = Array.from(RENDER_BINDING_PROP_NAMES).reduce(
|
|
869
|
+
(accumulator, key) => {
|
|
870
|
+
if (source[key] !== void 0) {
|
|
871
|
+
accumulator[key] = source[key];
|
|
872
|
+
}
|
|
873
|
+
return accumulator;
|
|
874
|
+
},
|
|
875
|
+
{}
|
|
876
|
+
);
|
|
877
|
+
return Array.from(RENDER_BINDING_PROP_NAMES).reduce((accumulator, key) => {
|
|
878
|
+
if (legacy[key] !== void 0) {
|
|
879
|
+
accumulator[key] = legacy[key];
|
|
880
|
+
} else if (embedded[key] !== void 0) {
|
|
881
|
+
accumulator[key] = embedded[key];
|
|
882
|
+
}
|
|
883
|
+
return accumulator;
|
|
884
|
+
}, {});
|
|
885
|
+
};
|
|
886
|
+
|
|
887
|
+
// src/utils/renderChildren.tsx
|
|
888
|
+
import { normalizeRenderableChild, toBoolean } from "@arkcit/engine-react";
|
|
889
|
+
|
|
890
|
+
// src/studio-bridge/overlay/overlayStudio.ts
|
|
891
|
+
var toBoolean2 = (value) => {
|
|
892
|
+
if (typeof value === "boolean") return value;
|
|
893
|
+
if (typeof value === "string") return value.toLowerCase() === "true";
|
|
894
|
+
return Boolean(value);
|
|
895
|
+
};
|
|
896
|
+
var readOverlayState = (runtime) => {
|
|
897
|
+
const overlaysRaw = runtime.get("overlays.byNodeId");
|
|
898
|
+
return overlaysRaw && typeof overlaysRaw === "object" ? overlaysRaw : {};
|
|
899
|
+
};
|
|
900
|
+
var applyStudioOverlayComponentProps = ({
|
|
901
|
+
node,
|
|
902
|
+
componentProps,
|
|
903
|
+
runtime,
|
|
904
|
+
overlaysByNodeId,
|
|
905
|
+
renderBindingProps,
|
|
906
|
+
resolvedChildContent,
|
|
907
|
+
onInlineTextEdit,
|
|
908
|
+
isStudioRendererContext,
|
|
909
|
+
dropdownOpenByNodeId,
|
|
910
|
+
setDropdownOpenByNodeId
|
|
911
|
+
}) => {
|
|
912
|
+
if (node.type === "Popin") {
|
|
913
|
+
const bindingEnabled = toBoolean2(renderBindingProps.bindingEnabled);
|
|
914
|
+
const rawOverlayOpen = overlaysByNodeId[node.id];
|
|
915
|
+
const fallbackOpen = Boolean(componentProps.displayedPopin);
|
|
916
|
+
const isOpen = bindingEnabled ? typeof rawOverlayOpen === "boolean" ? rawOverlayOpen : fallbackOpen : fallbackOpen;
|
|
917
|
+
componentProps.displayedPopin = isOpen;
|
|
918
|
+
componentProps.setDisplayedPopin = (next) => {
|
|
919
|
+
const nextOpen = typeof next === "function" ? next(isOpen) : next;
|
|
920
|
+
onInlineTextEdit == null ? void 0 : onInlineTextEdit(node.id, "displayedPopin", nextOpen);
|
|
921
|
+
if (bindingEnabled) {
|
|
922
|
+
runtime.dispatch({
|
|
923
|
+
id: nextOpen ? "overlay.open" : "overlay.close",
|
|
924
|
+
payload: { targetNodeId: node.id }
|
|
925
|
+
});
|
|
926
|
+
}
|
|
927
|
+
};
|
|
928
|
+
componentProps.children = resolvedChildContent !== null ? resolvedChildContent : normalizeRenderableChild(componentProps.children);
|
|
929
|
+
}
|
|
930
|
+
if (node.type === "Drawer") {
|
|
931
|
+
const bindingEnabled = toBoolean2(renderBindingProps.bindingEnabled);
|
|
932
|
+
const rawOverlayOpen = overlaysByNodeId[node.id];
|
|
933
|
+
const fallbackOpen = Boolean(componentProps.open);
|
|
934
|
+
const isOpen = bindingEnabled ? typeof rawOverlayOpen === "boolean" ? rawOverlayOpen : fallbackOpen : fallbackOpen;
|
|
935
|
+
componentProps.open = isOpen;
|
|
936
|
+
componentProps.onClose = () => {
|
|
937
|
+
onInlineTextEdit == null ? void 0 : onInlineTextEdit(node.id, "open", false);
|
|
938
|
+
if (bindingEnabled) {
|
|
939
|
+
runtime.dispatch({
|
|
940
|
+
id: "overlay.close",
|
|
941
|
+
payload: { targetNodeId: node.id }
|
|
942
|
+
});
|
|
943
|
+
}
|
|
944
|
+
};
|
|
945
|
+
componentProps.children = resolvedChildContent !== null ? resolvedChildContent : normalizeRenderableChild(componentProps.children);
|
|
946
|
+
}
|
|
947
|
+
if (node.type === "Dropdown") {
|
|
948
|
+
const fallbackOpen = Boolean(componentProps.open);
|
|
949
|
+
const isOpen = isStudioRendererContext && node.id in dropdownOpenByNodeId ? Boolean(dropdownOpenByNodeId[node.id]) : fallbackOpen;
|
|
950
|
+
componentProps.open = isOpen;
|
|
951
|
+
componentProps.onOpenChange = (nextOpen) => {
|
|
952
|
+
setDropdownOpenByNodeId((previous) => __spreadProps(__spreadValues({}, previous), {
|
|
953
|
+
[node.id]: Boolean(nextOpen)
|
|
954
|
+
}));
|
|
955
|
+
onInlineTextEdit == null ? void 0 : onInlineTextEdit(node.id, "open", Boolean(nextOpen));
|
|
956
|
+
};
|
|
957
|
+
if (resolvedChildContent !== null) {
|
|
958
|
+
componentProps.children = resolvedChildContent;
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
if (node.type === "Tooltip") {
|
|
962
|
+
componentProps.children = resolvedChildContent !== null ? resolvedChildContent : normalizeRenderableChild(componentProps.children);
|
|
963
|
+
}
|
|
964
|
+
};
|
|
965
|
+
var getOpenStudioOverlayState = ({
|
|
966
|
+
node,
|
|
967
|
+
nodeProps,
|
|
968
|
+
overlaysByNodeId
|
|
969
|
+
}) => {
|
|
970
|
+
const renderBindingProps = getRenderBindingProps(nodeProps);
|
|
971
|
+
const bindingEnabled = toBoolean2(renderBindingProps.bindingEnabled);
|
|
972
|
+
return Boolean(
|
|
973
|
+
node.type === "Popin" && Boolean(bindingEnabled ? overlaysByNodeId[node.id] : nodeProps.displayedPopin) || node.type === "Drawer" && Boolean(bindingEnabled ? overlaysByNodeId[node.id] : nodeProps.open)
|
|
974
|
+
);
|
|
975
|
+
};
|
|
976
|
+
|
|
977
|
+
// src/studio-bridge/overlay/renderNodeFrame.tsx
|
|
978
|
+
import { createPortal } from "react-dom";
|
|
979
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
980
|
+
var renderNodeFrame = ({
|
|
981
|
+
node,
|
|
982
|
+
nodeProps,
|
|
983
|
+
nodeContent,
|
|
984
|
+
selectedNodeId,
|
|
985
|
+
onNodeClick,
|
|
986
|
+
onInlineTextEdit,
|
|
987
|
+
onNodeResize,
|
|
988
|
+
onNodeResizeStart,
|
|
989
|
+
onNodeResizeEnd,
|
|
990
|
+
widthPct,
|
|
991
|
+
heightPct,
|
|
992
|
+
heightPx,
|
|
993
|
+
wrapperClassName,
|
|
994
|
+
isOpenStudioOverlayNode,
|
|
995
|
+
shouldForceFullWidth,
|
|
996
|
+
effectiveCandidateInlineProp,
|
|
997
|
+
inlineEditing,
|
|
998
|
+
isInlineEditingNode,
|
|
999
|
+
ancestorTypeMembership,
|
|
1000
|
+
schemaNodes,
|
|
1001
|
+
runtime,
|
|
1002
|
+
enableEventOnClick,
|
|
1003
|
+
isFormInteractiveTarget,
|
|
1004
|
+
getTextValue,
|
|
1005
|
+
setInlineEditing,
|
|
1006
|
+
inlineEditor,
|
|
1007
|
+
NodeWrapper,
|
|
1008
|
+
overlaysByNodeId,
|
|
1009
|
+
getOpenStudioOverlayState: getOpenStudioOverlayState2,
|
|
1010
|
+
resizeStateRef,
|
|
1011
|
+
pinchStateRef,
|
|
1012
|
+
minWidthPct,
|
|
1013
|
+
minHeightPct,
|
|
1014
|
+
minHeightPx,
|
|
1015
|
+
overlayRootId
|
|
1016
|
+
}) => {
|
|
1017
|
+
var _a;
|
|
1018
|
+
const { wrapperStyle, overlayWrapperClassName, requiresPlainWrapper } = getNodeWrapperPresentation({
|
|
1019
|
+
isOpenStudioOverlayNode,
|
|
1020
|
+
wrapperClassName,
|
|
1021
|
+
widthPct,
|
|
1022
|
+
shouldForceFullWidth
|
|
1023
|
+
});
|
|
1024
|
+
if (!onNodeClick && !selectedNodeId) {
|
|
1025
|
+
if (!requiresPlainWrapper) return nodeContent;
|
|
1026
|
+
return renderPlainWrappedNode({
|
|
1027
|
+
nodeId: node.id,
|
|
1028
|
+
overlayWrapperClassName,
|
|
1029
|
+
wrapperStyle,
|
|
1030
|
+
nodeContent
|
|
1031
|
+
});
|
|
1032
|
+
}
|
|
1033
|
+
const {
|
|
1034
|
+
isSelected,
|
|
1035
|
+
allowNodeHandles,
|
|
1036
|
+
studioFormFieldWrapperClassName,
|
|
1037
|
+
cursorClassName,
|
|
1038
|
+
preserveContentWhileInlineEditing
|
|
1039
|
+
} = getStudioNodeInteractionState({
|
|
1040
|
+
node,
|
|
1041
|
+
selectedNodeId,
|
|
1042
|
+
effectiveCandidateInlineProp,
|
|
1043
|
+
isInlineEditingNode,
|
|
1044
|
+
isOpenStudioOverlayNode,
|
|
1045
|
+
isInsideForm: ancestorTypeMembership.Form.has(node.id),
|
|
1046
|
+
isInsideFormWizard: ancestorTypeMembership.FormWizard.has(node.id),
|
|
1047
|
+
isInsideStepForm: ancestorTypeMembership.StepForm.has(node.id),
|
|
1048
|
+
inlinePropName: inlineEditing == null ? void 0 : inlineEditing.propName
|
|
1049
|
+
});
|
|
1050
|
+
const touchResizeHandlers = createTouchResizeHandlers({
|
|
1051
|
+
node,
|
|
1052
|
+
widthPct,
|
|
1053
|
+
heightPct,
|
|
1054
|
+
onNodeResize,
|
|
1055
|
+
onNodeResizeStart,
|
|
1056
|
+
onNodeResizeEnd,
|
|
1057
|
+
pinchStateRef,
|
|
1058
|
+
minWidthPct,
|
|
1059
|
+
minHeightPct
|
|
1060
|
+
});
|
|
1061
|
+
const onResizeMouseDown = createMouseResizeHandler({
|
|
1062
|
+
node,
|
|
1063
|
+
widthPct,
|
|
1064
|
+
heightPct,
|
|
1065
|
+
heightPx,
|
|
1066
|
+
onNodeResize,
|
|
1067
|
+
onNodeResizeStart,
|
|
1068
|
+
resizeStateRef,
|
|
1069
|
+
minHeightPx
|
|
1070
|
+
});
|
|
1071
|
+
const onClick = createStudioNodeClickHandler({
|
|
1072
|
+
node,
|
|
1073
|
+
nodeProps,
|
|
1074
|
+
schemaNodes,
|
|
1075
|
+
runtime,
|
|
1076
|
+
onNodeClick,
|
|
1077
|
+
onInlineTextEdit,
|
|
1078
|
+
isInlineEditingNode,
|
|
1079
|
+
enableEventOnClick,
|
|
1080
|
+
isFormInteractiveTarget
|
|
1081
|
+
});
|
|
1082
|
+
const onDoubleClick = createStudioNodeDoubleClickHandler({
|
|
1083
|
+
node,
|
|
1084
|
+
onInlineTextEdit,
|
|
1085
|
+
effectiveCandidateInlineProp,
|
|
1086
|
+
getTextValue,
|
|
1087
|
+
setInlineEditing
|
|
1088
|
+
});
|
|
1089
|
+
const wrappedNode = /* @__PURE__ */ jsx4(
|
|
1090
|
+
NodeWrapper,
|
|
1091
|
+
{
|
|
1092
|
+
nodeId: node.id,
|
|
1093
|
+
wrapperClassName: [overlayWrapperClassName, studioFormFieldWrapperClassName].filter(Boolean).join(" "),
|
|
1094
|
+
cursorClassName: onNodeClick ? cursorClassName : "",
|
|
1095
|
+
isSelected,
|
|
1096
|
+
allowDragHandle: allowNodeHandles,
|
|
1097
|
+
allowResizeHandle: allowNodeHandles,
|
|
1098
|
+
style: wrapperStyle,
|
|
1099
|
+
onTouchStart: touchResizeHandlers.onTouchStart,
|
|
1100
|
+
onTouchMove: touchResizeHandlers.onTouchMove,
|
|
1101
|
+
onTouchEnd: touchResizeHandlers.onTouchEnd,
|
|
1102
|
+
onClick,
|
|
1103
|
+
onDoubleClick,
|
|
1104
|
+
showResizeHandle: isSelected && Boolean(onNodeResize) && allowNodeHandles,
|
|
1105
|
+
onResizeMouseDown,
|
|
1106
|
+
isInlineEditing: isInlineEditingNode,
|
|
1107
|
+
preserveContentWhileInlineEditing,
|
|
1108
|
+
inlineEditor,
|
|
1109
|
+
children: nodeContent
|
|
1110
|
+
}
|
|
1111
|
+
);
|
|
1112
|
+
if (getOpenStudioOverlayState2({
|
|
1113
|
+
node,
|
|
1114
|
+
nodeProps,
|
|
1115
|
+
overlaysByNodeId
|
|
1116
|
+
})) {
|
|
1117
|
+
const overlayRoot = (_a = globalThis.document) == null ? void 0 : _a.getElementById(overlayRootId);
|
|
1118
|
+
if (overlayRoot) {
|
|
1119
|
+
return createPortal(wrappedNode, overlayRoot);
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
return wrappedNode;
|
|
1123
|
+
};
|
|
1124
|
+
|
|
1125
|
+
// src/react-web/engine/NodeErrorBoundary.tsx
|
|
1126
|
+
import { NodeErrorBoundary } from "@arkcit/engine-react";
|
|
1127
|
+
|
|
1128
|
+
// src/layout/nodeLayout.ts
|
|
1129
|
+
var toPositiveNumber = (value) => {
|
|
1130
|
+
const numeric = Number(value);
|
|
1131
|
+
if (!Number.isFinite(numeric) || numeric <= 0) return void 0;
|
|
1132
|
+
return numeric;
|
|
1133
|
+
};
|
|
1134
|
+
var toColSpan = (value) => {
|
|
1135
|
+
const numeric = Number(value);
|
|
1136
|
+
if (!Number.isInteger(numeric) || numeric < 1 || numeric > 12) return void 0;
|
|
1137
|
+
return numeric;
|
|
1138
|
+
};
|
|
1139
|
+
var toCardSection = (value) => {
|
|
1140
|
+
if (value === "header" || value === "body" || value === "footer") return value;
|
|
1141
|
+
return void 0;
|
|
1142
|
+
};
|
|
1143
|
+
var readNodeLayout = (props) => {
|
|
1144
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
1145
|
+
if (!props) return {};
|
|
1146
|
+
const rawLayout = props.layout && typeof props.layout === "object" && !Array.isArray(props.layout) ? props.layout : {};
|
|
1147
|
+
return {
|
|
1148
|
+
widthPct: toPositiveNumber((_a = rawLayout.widthPct) != null ? _a : props.__studioWidthPct),
|
|
1149
|
+
heightPct: toPositiveNumber((_b = rawLayout.heightPct) != null ? _b : props.__studioHeightPct),
|
|
1150
|
+
heightPx: toPositiveNumber((_c = rawLayout.heightPx) != null ? _c : props.__studioHeightPx),
|
|
1151
|
+
colSpan: toColSpan((_d = rawLayout.colSpan) != null ? _d : props.__studioColSpan),
|
|
1152
|
+
wrapperClassName: String(
|
|
1153
|
+
(_f = (_e = rawLayout.wrapperClassName) != null ? _e : props.__studioWrapperClassName) != null ? _f : ""
|
|
1154
|
+
).trim(),
|
|
1155
|
+
cardSection: toCardSection((_g = rawLayout.cardSection) != null ? _g : props.__studioCardSection)
|
|
1156
|
+
};
|
|
1157
|
+
};
|
|
1158
|
+
|
|
1159
|
+
// src/utils/nodeResetToken.ts
|
|
1160
|
+
import { buildNodeResetToken } from "@arkcit/engine-react";
|
|
1161
|
+
|
|
1162
|
+
// src/runtime/bindings.ts
|
|
1163
|
+
var DANGEROUS_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
1164
|
+
var MISSING_TRANSLATION_FALLBACK = "Lorem ipsum dolor sit amet. (fallback)";
|
|
1165
|
+
var MISSING_REF_FALLBACK = "Lorem ipsum dolor sit amet. (fallback)";
|
|
1166
|
+
var isPlainObject = (value) => {
|
|
1167
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
1168
|
+
const prototype = Object.getPrototypeOf(value);
|
|
1169
|
+
return prototype === Object.prototype || prototype === null;
|
|
1170
|
+
};
|
|
1171
|
+
var isReactElementLike = (value) => isPlainObject(value) && typeof value.$$typeof === "symbol" && "props" in value;
|
|
1172
|
+
var isTranslationValue = (value) => isPlainObject(value) && typeof value.$t === "string";
|
|
1173
|
+
var isRefValue = (value) => isPlainObject(value) && typeof value.$ref === "string";
|
|
1174
|
+
var isExprValue = (value) => isPlainObject(value) && typeof value.$expr === "string";
|
|
1175
|
+
var parseStructuredString = (value) => {
|
|
1176
|
+
if (typeof value !== "string") return value;
|
|
1177
|
+
const trimmed = value.trim();
|
|
1178
|
+
if (!trimmed.startsWith("{") || !trimmed.endsWith("}")) return value;
|
|
1179
|
+
try {
|
|
1180
|
+
const parsed = JSON.parse(trimmed);
|
|
1181
|
+
if (!isPlainObject(parsed)) return value;
|
|
1182
|
+
if ((typeof parsed.$ref === "string" || typeof parsed.$t === "string") && Object.keys(parsed).length >= 1) {
|
|
1183
|
+
return parsed;
|
|
1184
|
+
}
|
|
1185
|
+
return value;
|
|
1186
|
+
} catch (e) {
|
|
1187
|
+
return value;
|
|
1188
|
+
}
|
|
1189
|
+
};
|
|
1190
|
+
var resolveUIValue = (value, runtime) => {
|
|
1191
|
+
const normalizedValue = parseStructuredString(value);
|
|
1192
|
+
if (isTranslationValue(normalizedValue)) {
|
|
1193
|
+
const fallback = typeof normalizedValue.defaultValue === "string" && normalizedValue.defaultValue.trim() ? normalizedValue.defaultValue : normalizedValue.$t;
|
|
1194
|
+
if (!runtime.t) return fallback || MISSING_TRANSLATION_FALLBACK;
|
|
1195
|
+
const translated = runtime.t(normalizedValue.$t, normalizedValue.values);
|
|
1196
|
+
if (typeof translated !== "string") return fallback || MISSING_TRANSLATION_FALLBACK;
|
|
1197
|
+
if (!translated.trim()) return fallback || MISSING_TRANSLATION_FALLBACK;
|
|
1198
|
+
if (translated === normalizedValue.$t) return fallback || MISSING_TRANSLATION_FALLBACK;
|
|
1199
|
+
return translated;
|
|
1200
|
+
}
|
|
1201
|
+
if (isRefValue(normalizedValue)) {
|
|
1202
|
+
const resolved = runtime.get(normalizedValue.$ref);
|
|
1203
|
+
if (resolved == null) return MISSING_REF_FALLBACK;
|
|
1204
|
+
if (typeof resolved === "string" && !resolved.trim()) return MISSING_REF_FALLBACK;
|
|
1205
|
+
return resolved;
|
|
1206
|
+
}
|
|
1207
|
+
if (isExprValue(normalizedValue)) {
|
|
1208
|
+
return void 0;
|
|
1209
|
+
}
|
|
1210
|
+
if (Array.isArray(normalizedValue)) {
|
|
1211
|
+
return normalizedValue.map((item) => resolveUIValue(item, runtime));
|
|
1212
|
+
}
|
|
1213
|
+
if (isReactElementLike(normalizedValue)) {
|
|
1214
|
+
return normalizedValue;
|
|
1215
|
+
}
|
|
1216
|
+
if (isPlainObject(normalizedValue)) {
|
|
1217
|
+
const next = {};
|
|
1218
|
+
Object.entries(normalizedValue).forEach(([key, childValue]) => {
|
|
1219
|
+
if (DANGEROUS_KEYS.has(key)) return;
|
|
1220
|
+
next[key] = resolveUIValue(childValue, runtime);
|
|
1221
|
+
});
|
|
1222
|
+
return next;
|
|
1223
|
+
}
|
|
1224
|
+
return normalizedValue;
|
|
1225
|
+
};
|
|
1226
|
+
|
|
1227
|
+
// src/studio-bridge/overlay/renderSafeNode.tsx
|
|
1228
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
1229
|
+
var FallbackInlineTextEditor = ({
|
|
1230
|
+
editing,
|
|
1231
|
+
onChange,
|
|
1232
|
+
onCancel,
|
|
1233
|
+
onCommit
|
|
1234
|
+
}) => editing.multiline ? /* @__PURE__ */ jsx5(
|
|
1235
|
+
"textarea",
|
|
1236
|
+
{
|
|
1237
|
+
style: editing.editorStyle,
|
|
1238
|
+
value: editing.value,
|
|
1239
|
+
autoFocus: true,
|
|
1240
|
+
"aria-label": "Inline text editor",
|
|
1241
|
+
onChange: (event) => onChange(event.target.value),
|
|
1242
|
+
onBlur: onCommit,
|
|
1243
|
+
onKeyDown: (event) => {
|
|
1244
|
+
if (event.key === "Escape") {
|
|
1245
|
+
event.preventDefault();
|
|
1246
|
+
onCancel();
|
|
1247
|
+
return;
|
|
1248
|
+
}
|
|
1249
|
+
if (event.key === "Enter" && (event.metaKey || event.ctrlKey)) {
|
|
1250
|
+
event.preventDefault();
|
|
1251
|
+
onCommit();
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
}
|
|
1255
|
+
) : /* @__PURE__ */ jsx5(
|
|
1256
|
+
"input",
|
|
1257
|
+
{
|
|
1258
|
+
style: editing.editorStyle,
|
|
1259
|
+
value: editing.value,
|
|
1260
|
+
autoFocus: true,
|
|
1261
|
+
"aria-label": "Inline text editor",
|
|
1262
|
+
onChange: (event) => onChange(event.target.value),
|
|
1263
|
+
onBlur: onCommit,
|
|
1264
|
+
onKeyDown: (event) => {
|
|
1265
|
+
if (event.key === "Escape") {
|
|
1266
|
+
event.preventDefault();
|
|
1267
|
+
onCancel();
|
|
1268
|
+
return;
|
|
1269
|
+
}
|
|
1270
|
+
if (event.key === "Enter") {
|
|
1271
|
+
event.preventDefault();
|
|
1272
|
+
onCommit();
|
|
1273
|
+
}
|
|
1274
|
+
}
|
|
1275
|
+
}
|
|
1276
|
+
);
|
|
1277
|
+
var renderSafeNode = ({
|
|
1278
|
+
node,
|
|
1279
|
+
registry,
|
|
1280
|
+
runtime,
|
|
1281
|
+
schemaNodes,
|
|
1282
|
+
renderNode,
|
|
1283
|
+
isStudioRendererContext,
|
|
1284
|
+
overlaysByNodeId,
|
|
1285
|
+
selectedNodeId,
|
|
1286
|
+
onNodeClick,
|
|
1287
|
+
onInlineTextEdit,
|
|
1288
|
+
onNodeResize,
|
|
1289
|
+
onNodeResizeStart,
|
|
1290
|
+
onNodeResizeEnd,
|
|
1291
|
+
inlineEditing,
|
|
1292
|
+
setInlineEditing,
|
|
1293
|
+
ancestorTypeMembership,
|
|
1294
|
+
resizeStateRef,
|
|
1295
|
+
pinchStateRef,
|
|
1296
|
+
minWidthPct,
|
|
1297
|
+
minHeightPct,
|
|
1298
|
+
minHeightPx,
|
|
1299
|
+
overlayRootId,
|
|
1300
|
+
NodeWrapper,
|
|
1301
|
+
InlineTextEditorComponent,
|
|
1302
|
+
isFormInteractiveTarget
|
|
1303
|
+
}) => {
|
|
1304
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
1305
|
+
const nodeProps = (_a = node.props) != null ? _a : {};
|
|
1306
|
+
const nodeLayout = readNodeLayout(nodeProps);
|
|
1307
|
+
const wrapperClassName = (_b = nodeLayout.wrapperClassName) != null ? _b : "";
|
|
1308
|
+
const resetToken = buildNodeResetToken(node);
|
|
1309
|
+
const widthPct = (_c = nodeLayout.widthPct) != null ? _c : null;
|
|
1310
|
+
const heightPct = (_d = nodeLayout.heightPct) != null ? _d : null;
|
|
1311
|
+
const heightPx = (_e = nodeLayout.heightPx) != null ? _e : null;
|
|
1312
|
+
const isOpenStudioOverlayNode = isStudioRendererContext && getOpenStudioOverlayState({
|
|
1313
|
+
node,
|
|
1314
|
+
nodeProps,
|
|
1315
|
+
overlaysByNodeId
|
|
1316
|
+
});
|
|
1317
|
+
const shouldForceFullWidth = shouldForceStudioNodeFullWidth({
|
|
1318
|
+
widthPct,
|
|
1319
|
+
nodeType: node.type,
|
|
1320
|
+
isStudioRendererContext,
|
|
1321
|
+
colSpan: nodeLayout.colSpan
|
|
1322
|
+
});
|
|
1323
|
+
const enableEventOnClick = toBoolean(nodeProps.buttonEnableEventOnClick);
|
|
1324
|
+
const nodeRegistryMeta = (_f = registry[node.type]) == null ? void 0 : _f.meta;
|
|
1325
|
+
const editableTextProps = ((_g = nodeRegistryMeta == null ? void 0 : nodeRegistryMeta.editableTextProps) != null ? _g : []).filter(
|
|
1326
|
+
(propName) => propName !== "className"
|
|
1327
|
+
);
|
|
1328
|
+
const { getTextValue, effectiveCandidateInlineProp } = resolveInlineEditingTarget({
|
|
1329
|
+
node,
|
|
1330
|
+
nodeProps,
|
|
1331
|
+
runtime,
|
|
1332
|
+
editableTextProps,
|
|
1333
|
+
resolveTranslationValue: resolveUIValue
|
|
1334
|
+
});
|
|
1335
|
+
const isInlineEditingNode = (inlineEditing == null ? void 0 : inlineEditing.nodeId) === node.id;
|
|
1336
|
+
const nodeContent = /* @__PURE__ */ jsx5(NodeErrorBoundary, { nodeId: node.id, nodeType: node.type, resetToken, children: renderNode(node, { widthPct, heightPct, heightPx }) }, node.id);
|
|
1337
|
+
const commitInlineEditing = () => {
|
|
1338
|
+
if (!inlineEditing) return;
|
|
1339
|
+
applyInlineEditingValue({
|
|
1340
|
+
editingState: inlineEditing,
|
|
1341
|
+
rawValue: inlineEditing.value,
|
|
1342
|
+
schemaNodes,
|
|
1343
|
+
onInlineTextEdit,
|
|
1344
|
+
findNodeById
|
|
1345
|
+
});
|
|
1346
|
+
setInlineEditing(null);
|
|
1347
|
+
};
|
|
1348
|
+
const InlineEditorComponent = InlineTextEditorComponent != null ? InlineTextEditorComponent : FallbackInlineTextEditor;
|
|
1349
|
+
const inlineEditor = isInlineEditingNode && inlineEditing ? /* @__PURE__ */ jsx5(
|
|
1350
|
+
InlineEditorComponent,
|
|
1351
|
+
{
|
|
1352
|
+
editing: inlineEditing,
|
|
1353
|
+
onChange: (value) => setInlineEditing((previous) => {
|
|
1354
|
+
if (!previous) return previous;
|
|
1355
|
+
return __spreadProps(__spreadValues({}, previous), {
|
|
1356
|
+
value
|
|
1357
|
+
});
|
|
1358
|
+
}),
|
|
1359
|
+
onCancel: () => setInlineEditing(null),
|
|
1360
|
+
onCommit: commitInlineEditing
|
|
1361
|
+
}
|
|
1362
|
+
) : null;
|
|
1363
|
+
return renderNodeFrame({
|
|
1364
|
+
node,
|
|
1365
|
+
nodeProps,
|
|
1366
|
+
nodeContent,
|
|
1367
|
+
selectedNodeId,
|
|
1368
|
+
onNodeClick,
|
|
1369
|
+
onInlineTextEdit,
|
|
1370
|
+
onNodeResize,
|
|
1371
|
+
onNodeResizeStart,
|
|
1372
|
+
onNodeResizeEnd,
|
|
1373
|
+
widthPct,
|
|
1374
|
+
heightPct,
|
|
1375
|
+
heightPx,
|
|
1376
|
+
wrapperClassName,
|
|
1377
|
+
isOpenStudioOverlayNode,
|
|
1378
|
+
shouldForceFullWidth,
|
|
1379
|
+
effectiveCandidateInlineProp,
|
|
1380
|
+
inlineEditing,
|
|
1381
|
+
isInlineEditingNode,
|
|
1382
|
+
ancestorTypeMembership,
|
|
1383
|
+
schemaNodes,
|
|
1384
|
+
runtime,
|
|
1385
|
+
enableEventOnClick,
|
|
1386
|
+
isFormInteractiveTarget,
|
|
1387
|
+
getTextValue,
|
|
1388
|
+
setInlineEditing,
|
|
1389
|
+
inlineEditor,
|
|
1390
|
+
NodeWrapper,
|
|
1391
|
+
overlaysByNodeId,
|
|
1392
|
+
getOpenStudioOverlayState,
|
|
1393
|
+
resizeStateRef,
|
|
1394
|
+
pinchStateRef,
|
|
1395
|
+
minWidthPct,
|
|
1396
|
+
minHeightPct,
|
|
1397
|
+
minHeightPx,
|
|
1398
|
+
overlayRootId
|
|
1399
|
+
});
|
|
1400
|
+
};
|
|
1401
|
+
|
|
1402
|
+
// src/studio-bridge/preview-form/previewFormRenderer.tsx
|
|
1403
|
+
import React from "react";
|
|
1404
|
+
|
|
1405
|
+
// src/form/engineFormValidation.ts
|
|
1406
|
+
var EMAIL_REGEX = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
1407
|
+
var isEmptyValue = (value) => {
|
|
1408
|
+
if (value == null) return true;
|
|
1409
|
+
if (typeof value === "string") return value.trim().length === 0;
|
|
1410
|
+
if (Array.isArray(value)) return value.length === 0;
|
|
1411
|
+
return false;
|
|
1412
|
+
};
|
|
1413
|
+
var toNumber = (value) => {
|
|
1414
|
+
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
1415
|
+
if (typeof value === "string") {
|
|
1416
|
+
const parsed = Number(value);
|
|
1417
|
+
return Number.isFinite(parsed) ? parsed : null;
|
|
1418
|
+
}
|
|
1419
|
+
return null;
|
|
1420
|
+
};
|
|
1421
|
+
var defaultDeclarativeValidatorRegistry = {
|
|
1422
|
+
required: (value) => isEmptyValue(value) ? { code: "required" } : null,
|
|
1423
|
+
minLength: (value, params) => {
|
|
1424
|
+
var _a;
|
|
1425
|
+
if (isEmptyValue(value)) return null;
|
|
1426
|
+
const min = toNumber((_a = params == null ? void 0 : params.min) != null ? _a : params == null ? void 0 : params.value);
|
|
1427
|
+
if (min == null) return null;
|
|
1428
|
+
return String(value).length < min ? { code: "minLength", params: { min } } : null;
|
|
1429
|
+
},
|
|
1430
|
+
maxLength: (value, params) => {
|
|
1431
|
+
var _a;
|
|
1432
|
+
if (isEmptyValue(value)) return null;
|
|
1433
|
+
const max = toNumber((_a = params == null ? void 0 : params.max) != null ? _a : params == null ? void 0 : params.value);
|
|
1434
|
+
if (max == null) return null;
|
|
1435
|
+
return String(value).length > max ? { code: "maxLength", params: { max } } : null;
|
|
1436
|
+
},
|
|
1437
|
+
email: (value) => {
|
|
1438
|
+
if (isEmptyValue(value)) return null;
|
|
1439
|
+
return EMAIL_REGEX.test(String(value)) ? null : { code: "email" };
|
|
1440
|
+
},
|
|
1441
|
+
pattern: (value, params) => {
|
|
1442
|
+
var _a, _b;
|
|
1443
|
+
if (isEmptyValue(value)) return null;
|
|
1444
|
+
const rawPattern = String((_b = (_a = params == null ? void 0 : params.pattern) != null ? _a : params == null ? void 0 : params.value) != null ? _b : "").trim();
|
|
1445
|
+
if (!rawPattern) return null;
|
|
1446
|
+
try {
|
|
1447
|
+
const regex = new RegExp(rawPattern);
|
|
1448
|
+
return regex.test(String(value)) ? null : { code: "pattern", params: { pattern: rawPattern } };
|
|
1449
|
+
} catch (e) {
|
|
1450
|
+
return { code: "pattern" };
|
|
1451
|
+
}
|
|
1452
|
+
}
|
|
1453
|
+
};
|
|
1454
|
+
var buildLegacyValidators = (field) => {
|
|
1455
|
+
var _a, _b, _c;
|
|
1456
|
+
const validators = [];
|
|
1457
|
+
if (field.required) {
|
|
1458
|
+
validators.push({
|
|
1459
|
+
id: `${String((_a = field.name) != null ? _a : "field")}:required`,
|
|
1460
|
+
type: "required",
|
|
1461
|
+
stopOnFailure: true
|
|
1462
|
+
});
|
|
1463
|
+
}
|
|
1464
|
+
if (String((_b = field.pattern) != null ? _b : "").trim()) {
|
|
1465
|
+
validators.push({
|
|
1466
|
+
id: `${String((_c = field.name) != null ? _c : "field")}:pattern`,
|
|
1467
|
+
type: "pattern",
|
|
1468
|
+
params: { pattern: String(field.pattern) }
|
|
1469
|
+
});
|
|
1470
|
+
}
|
|
1471
|
+
return validators;
|
|
1472
|
+
};
|
|
1473
|
+
var normalizeValidators = (field, options) => {
|
|
1474
|
+
const explicit = Array.isArray(field.validators) ? field.validators : [];
|
|
1475
|
+
if (explicit.length > 0) return explicit;
|
|
1476
|
+
if (!(options == null ? void 0 : options.useLegacyFieldConstraints)) return [];
|
|
1477
|
+
return buildLegacyValidators(field);
|
|
1478
|
+
};
|
|
1479
|
+
var toIssueArray = (issue) => {
|
|
1480
|
+
if (!issue) return [];
|
|
1481
|
+
return Array.isArray(issue) ? issue : [issue];
|
|
1482
|
+
};
|
|
1483
|
+
var validateFieldWithConfig = (field, value, values, config, registry) => {
|
|
1484
|
+
if (config.enabled === false) return [];
|
|
1485
|
+
const validate = registry[config.type];
|
|
1486
|
+
if (!validate) return [];
|
|
1487
|
+
const baseIssues = toIssueArray(
|
|
1488
|
+
validate(value, config.params, {
|
|
1489
|
+
field,
|
|
1490
|
+
values
|
|
1491
|
+
})
|
|
1492
|
+
);
|
|
1493
|
+
return baseIssues.map((baseIssue) => {
|
|
1494
|
+
var _a, _b, _c, _d, _e;
|
|
1495
|
+
return {
|
|
1496
|
+
field: String((_a = field.name) != null ? _a : ""),
|
|
1497
|
+
validatorId: config.id || baseIssue.validatorId,
|
|
1498
|
+
code: baseIssue.code,
|
|
1499
|
+
messageKey: (_b = baseIssue.messageKey) != null ? _b : config.messageKey,
|
|
1500
|
+
message: (_c = baseIssue.message) != null ? _c : config.message,
|
|
1501
|
+
params: __spreadValues(__spreadValues({}, (_d = config.params) != null ? _d : {}), (_e = baseIssue.params) != null ? _e : {})
|
|
1502
|
+
};
|
|
1503
|
+
});
|
|
1504
|
+
};
|
|
1505
|
+
var resolveIssueMessage = (issue, t) => {
|
|
1506
|
+
const defaultMessageByCode = () => {
|
|
1507
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1508
|
+
switch (issue.code) {
|
|
1509
|
+
case "required":
|
|
1510
|
+
return "This field is required";
|
|
1511
|
+
case "email":
|
|
1512
|
+
return "Invalid email address";
|
|
1513
|
+
case "pattern":
|
|
1514
|
+
return "Invalid format";
|
|
1515
|
+
case "minLength": {
|
|
1516
|
+
const min = (_c = (_a = issue.params) == null ? void 0 : _a.min) != null ? _c : (_b = issue.params) == null ? void 0 : _b.value;
|
|
1517
|
+
return min != null ? `Minimum ${String(min)} characters` : "Value is too short";
|
|
1518
|
+
}
|
|
1519
|
+
case "maxLength": {
|
|
1520
|
+
const max = (_f = (_d = issue.params) == null ? void 0 : _d.max) != null ? _f : (_e = issue.params) == null ? void 0 : _e.value;
|
|
1521
|
+
return max != null ? `Maximum ${String(max)} characters` : "Value is too long";
|
|
1522
|
+
}
|
|
1523
|
+
default:
|
|
1524
|
+
return void 0;
|
|
1525
|
+
}
|
|
1526
|
+
};
|
|
1527
|
+
if (issue.messageKey && t) {
|
|
1528
|
+
const translated = t(issue.messageKey, issue.params);
|
|
1529
|
+
if (typeof translated === "string" && translated.trim().length > 0) {
|
|
1530
|
+
return translated;
|
|
1531
|
+
}
|
|
1532
|
+
}
|
|
1533
|
+
if (issue.message && issue.message.trim().length > 0) return issue.message;
|
|
1534
|
+
if (issue.messageKey && issue.messageKey.trim().length > 0) return issue.messageKey;
|
|
1535
|
+
return defaultMessageByCode();
|
|
1536
|
+
};
|
|
1537
|
+
var validateFormValues = (fields, values, options) => {
|
|
1538
|
+
var _a;
|
|
1539
|
+
const mergedRegistry = __spreadValues(__spreadValues({}, defaultDeclarativeValidatorRegistry), (_a = options == null ? void 0 : options.registry) != null ? _a : {});
|
|
1540
|
+
const issues = [];
|
|
1541
|
+
fields.forEach((field) => {
|
|
1542
|
+
var _a2;
|
|
1543
|
+
const fieldName = String((_a2 = field.name) != null ? _a2 : "").trim();
|
|
1544
|
+
if (!fieldName) return;
|
|
1545
|
+
const fieldValue = values[fieldName];
|
|
1546
|
+
const validators = normalizeValidators(field, options);
|
|
1547
|
+
if (validators.length === 0) return;
|
|
1548
|
+
for (const validatorConfig of validators) {
|
|
1549
|
+
const fieldIssues = validateFieldWithConfig(
|
|
1550
|
+
field,
|
|
1551
|
+
fieldValue,
|
|
1552
|
+
values,
|
|
1553
|
+
validatorConfig,
|
|
1554
|
+
mergedRegistry
|
|
1555
|
+
);
|
|
1556
|
+
if (fieldIssues.length > 0) {
|
|
1557
|
+
issues.push(...fieldIssues);
|
|
1558
|
+
if (validatorConfig.stopOnFailure) break;
|
|
1559
|
+
}
|
|
1560
|
+
}
|
|
1561
|
+
});
|
|
1562
|
+
const errors = {};
|
|
1563
|
+
issues.forEach((issue) => {
|
|
1564
|
+
if (errors[issue.field]) return;
|
|
1565
|
+
errors[issue.field] = resolveIssueMessage(issue, options == null ? void 0 : options.t);
|
|
1566
|
+
});
|
|
1567
|
+
return { issues, errors };
|
|
1568
|
+
};
|
|
1569
|
+
|
|
1570
|
+
// src/utils/formStudio.ts
|
|
1571
|
+
var getLayoutRecord = (props) => {
|
|
1572
|
+
if (!props) return {};
|
|
1573
|
+
const layout = props.layout;
|
|
1574
|
+
if (!layout || typeof layout !== "object" || Array.isArray(layout)) {
|
|
1575
|
+
return {};
|
|
1576
|
+
}
|
|
1577
|
+
return layout;
|
|
1578
|
+
};
|
|
1579
|
+
var normalizeStudioFormChild = (child) => {
|
|
1580
|
+
var _a, _b, _c, _d, _e;
|
|
1581
|
+
const childProps = (_a = child.props) != null ? _a : {};
|
|
1582
|
+
const childLayout = getLayoutRecord(childProps);
|
|
1583
|
+
if (child.type === "__studio_form_field") {
|
|
1584
|
+
return __spreadProps(__spreadValues({}, child), {
|
|
1585
|
+
type: "FormField",
|
|
1586
|
+
props: __spreadProps(__spreadValues({}, childProps), {
|
|
1587
|
+
layout: __spreadProps(__spreadValues({}, childLayout), {
|
|
1588
|
+
formRole: "field"
|
|
1589
|
+
})
|
|
1590
|
+
})
|
|
1591
|
+
});
|
|
1592
|
+
}
|
|
1593
|
+
if (child.type === "__studio_form_title") {
|
|
1594
|
+
return __spreadProps(__spreadValues({}, child), {
|
|
1595
|
+
type: "Text",
|
|
1596
|
+
props: __spreadProps(__spreadValues({}, childProps), {
|
|
1597
|
+
layout: __spreadProps(__spreadValues({}, childLayout), {
|
|
1598
|
+
formRole: "title"
|
|
1599
|
+
})
|
|
1600
|
+
})
|
|
1601
|
+
});
|
|
1602
|
+
}
|
|
1603
|
+
if (child.type === "__studio_form_submit") {
|
|
1604
|
+
return __spreadProps(__spreadValues({}, child), {
|
|
1605
|
+
type: "Button",
|
|
1606
|
+
props: __spreadProps(__spreadValues({}, childProps), {
|
|
1607
|
+
intent: String((_b = childProps.intent) != null ? _b : "primary"),
|
|
1608
|
+
variant: String((_c = childProps.variant) != null ? _c : "solid"),
|
|
1609
|
+
layout: __spreadProps(__spreadValues({}, childLayout), {
|
|
1610
|
+
formRole: "submit"
|
|
1611
|
+
})
|
|
1612
|
+
})
|
|
1613
|
+
});
|
|
1614
|
+
}
|
|
1615
|
+
if (child.type === "__studio_form_reset") {
|
|
1616
|
+
return __spreadProps(__spreadValues({}, child), {
|
|
1617
|
+
type: "Button",
|
|
1618
|
+
props: __spreadProps(__spreadValues({}, childProps), {
|
|
1619
|
+
intent: String((_d = childProps.intent) != null ? _d : "neutral"),
|
|
1620
|
+
variant: String((_e = childProps.variant) != null ? _e : "outline"),
|
|
1621
|
+
layout: __spreadProps(__spreadValues({}, childLayout), {
|
|
1622
|
+
formRole: "reset"
|
|
1623
|
+
})
|
|
1624
|
+
})
|
|
1625
|
+
});
|
|
1626
|
+
}
|
|
1627
|
+
return child;
|
|
1628
|
+
};
|
|
1629
|
+
var getStudioFormChildRole = (child) => {
|
|
1630
|
+
var _a, _b;
|
|
1631
|
+
if (child.type === "__studio_form_field") return "field";
|
|
1632
|
+
if (child.type === "__studio_form_title") return "title";
|
|
1633
|
+
if (child.type === "__studio_form_submit") return "submit";
|
|
1634
|
+
if (child.type === "__studio_form_reset") return "reset";
|
|
1635
|
+
const layout = getLayoutRecord(
|
|
1636
|
+
(_a = child.props) != null ? _a : {}
|
|
1637
|
+
);
|
|
1638
|
+
return String((_b = layout.formRole) != null ? _b : "").trim();
|
|
1639
|
+
};
|
|
1640
|
+
var buildFormFieldConfig = (rawProps, nestedField = {}) => {
|
|
1641
|
+
var _a, _b, _c, _d;
|
|
1642
|
+
const fieldName = String((_b = (_a = rawProps.name) != null ? _a : nestedField.name) != null ? _b : "").trim();
|
|
1643
|
+
return __spreadProps(__spreadValues(__spreadValues({}, nestedField), rawProps), {
|
|
1644
|
+
name: fieldName,
|
|
1645
|
+
label: String((_d = (_c = rawProps.label) != null ? _c : nestedField.label) != null ? _d : fieldName)
|
|
1646
|
+
});
|
|
1647
|
+
};
|
|
1648
|
+
var buildWizardFieldConfig = (rawProps, nestedField) => {
|
|
1649
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
1650
|
+
const name = String((_b = (_a = rawProps.name) != null ? _a : nestedField.name) != null ? _b : "").trim();
|
|
1651
|
+
return {
|
|
1652
|
+
name,
|
|
1653
|
+
label: String((_d = (_c = rawProps.label) != null ? _c : nestedField.label) != null ? _d : name || "Field"),
|
|
1654
|
+
type: (_e = rawProps.type) != null ? _e : nestedField.type,
|
|
1655
|
+
required: Boolean((_g = (_f = rawProps.required) != null ? _f : nestedField.required) != null ? _g : false),
|
|
1656
|
+
pattern: rawProps.pattern != null ? String(rawProps.pattern) : nestedField.pattern != null ? String(nestedField.pattern) : void 0,
|
|
1657
|
+
placeholder: (_h = rawProps.placeholder) != null ? _h : nestedField.placeholder,
|
|
1658
|
+
validators: Array.isArray(rawProps.validators) && rawProps.validators.length > 0 ? rawProps.validators : Array.isArray(nestedField.validators) && nestedField.validators.length > 0 ? nestedField.validators : void 0,
|
|
1659
|
+
options: (_i = rawProps.options) != null ? _i : nestedField.options,
|
|
1660
|
+
helperText: (_j = rawProps.helperText) != null ? _j : nestedField.helperText,
|
|
1661
|
+
defaultValue: (_k = rawProps.defaultValue) != null ? _k : nestedField.defaultValue,
|
|
1662
|
+
rows: (_l = rawProps.rows) != null ? _l : nestedField.rows,
|
|
1663
|
+
accept: (_m = rawProps.accept) != null ? _m : nestedField.accept
|
|
1664
|
+
};
|
|
1665
|
+
};
|
|
1666
|
+
|
|
1667
|
+
// src/studio-bridge/preview-form/previewFormState.ts
|
|
1668
|
+
var resolveStudioFormNextValues = ({
|
|
1669
|
+
formValues,
|
|
1670
|
+
fieldName,
|
|
1671
|
+
nextValue
|
|
1672
|
+
}) => __spreadProps(__spreadValues({}, formValues), {
|
|
1673
|
+
[fieldName]: nextValue
|
|
1674
|
+
});
|
|
1675
|
+
var resolveStudioFormResetValues = (normalizedFormFields) => normalizedFormFields.reduce((accumulator, field) => {
|
|
1676
|
+
var _a, _b;
|
|
1677
|
+
const fieldName = String((_a = field.name) != null ? _a : "").trim();
|
|
1678
|
+
if (!fieldName) return accumulator;
|
|
1679
|
+
accumulator[fieldName] = (_b = field.defaultValue) != null ? _b : "";
|
|
1680
|
+
return accumulator;
|
|
1681
|
+
}, {});
|
|
1682
|
+
var patchStudioFormFieldNode = ({
|
|
1683
|
+
child,
|
|
1684
|
+
formValues,
|
|
1685
|
+
formErrors,
|
|
1686
|
+
formDict,
|
|
1687
|
+
formLoaderType,
|
|
1688
|
+
fieldOnChange
|
|
1689
|
+
}) => {
|
|
1690
|
+
var _a, _b, _c;
|
|
1691
|
+
const rawChildProps = (_a = child.props) != null ? _a : {};
|
|
1692
|
+
const childLayout = readNodeLayout(rawChildProps);
|
|
1693
|
+
const rawLayout = rawChildProps.layout && typeof rawChildProps.layout === "object" && !Array.isArray(rawChildProps.layout) ? __spreadValues({}, rawChildProps.layout) : {};
|
|
1694
|
+
const existingWrapperClassName = String((_b = rawLayout.wrapperClassName) != null ? _b : "").trim();
|
|
1695
|
+
rawLayout.wrapperClassName = [existingWrapperClassName, "w-full", "max-w-full"].filter(Boolean).join(" ");
|
|
1696
|
+
delete rawLayout.widthPct;
|
|
1697
|
+
delete rawLayout.heightPct;
|
|
1698
|
+
delete rawLayout.heightPx;
|
|
1699
|
+
const fieldBasis = childLayout.widthPct !== null ? `${childLayout.widthPct}%` : "100%";
|
|
1700
|
+
const nestedField = rawChildProps.field && typeof rawChildProps.field === "object" && !Array.isArray(rawChildProps.field) ? rawChildProps.field : {};
|
|
1701
|
+
const fieldConfig = buildFormFieldConfig(rawChildProps, nestedField);
|
|
1702
|
+
const fieldName = String((_c = fieldConfig.name) != null ? _c : "").trim();
|
|
1703
|
+
const value = fieldName && fieldName in formValues ? formValues[fieldName] : rawChildProps.defaultValue;
|
|
1704
|
+
const patchedFieldNode = __spreadProps(__spreadValues({}, child), {
|
|
1705
|
+
props: __spreadValues(__spreadProps(__spreadValues({}, rawChildProps), {
|
|
1706
|
+
layout: rawLayout,
|
|
1707
|
+
field: fieldConfig,
|
|
1708
|
+
value,
|
|
1709
|
+
error: fieldName ? formErrors[fieldName] : void 0,
|
|
1710
|
+
onChange: fieldOnChange,
|
|
1711
|
+
dict: formDict
|
|
1712
|
+
}), formLoaderType !== void 0 ? { loaderType: formLoaderType } : {})
|
|
1713
|
+
});
|
|
1714
|
+
return {
|
|
1715
|
+
patchedFieldNode,
|
|
1716
|
+
fieldBasis
|
|
1717
|
+
};
|
|
1718
|
+
};
|
|
1719
|
+
|
|
1720
|
+
// src/studio-bridge/preview-form/previewFormStructure.ts
|
|
1721
|
+
var DEFAULT_FORM_DICT = {
|
|
1722
|
+
submit: "Submit",
|
|
1723
|
+
reset: "Reset",
|
|
1724
|
+
loading: "Loading...",
|
|
1725
|
+
success: "Saved",
|
|
1726
|
+
search: "Search...",
|
|
1727
|
+
noResultToShow: "No result"
|
|
1728
|
+
};
|
|
1729
|
+
var resolveStudioFormStructure = ({
|
|
1730
|
+
componentProps,
|
|
1731
|
+
visibleChildren
|
|
1732
|
+
}) => {
|
|
1733
|
+
const normalizedChildren = visibleChildren.map((child) => normalizeStudioFormChild(child));
|
|
1734
|
+
const titleNode = normalizedChildren.find((child) => getStudioFormChildRole(child) === "title");
|
|
1735
|
+
const fieldNodes = normalizedChildren.filter((child) => getStudioFormChildRole(child) === "field");
|
|
1736
|
+
const submitNode = normalizedChildren.find((child) => getStudioFormChildRole(child) === "submit");
|
|
1737
|
+
const resetNode = normalizedChildren.find((child) => getStudioFormChildRole(child) === "reset");
|
|
1738
|
+
const externalChildren = normalizedChildren.filter((child) => {
|
|
1739
|
+
const role = getStudioFormChildRole(child);
|
|
1740
|
+
return role !== "title" && role !== "field" && role !== "submit" && role !== "reset";
|
|
1741
|
+
});
|
|
1742
|
+
const formValues = componentProps.values && typeof componentProps.values === "object" && !Array.isArray(componentProps.values) ? componentProps.values : {};
|
|
1743
|
+
const formErrors = componentProps.errors && typeof componentProps.errors === "object" && !Array.isArray(componentProps.errors) ? componentProps.errors : {};
|
|
1744
|
+
const formDict = componentProps.dict && typeof componentProps.dict === "object" && !Array.isArray(componentProps.dict) ? componentProps.dict : DEFAULT_FORM_DICT;
|
|
1745
|
+
const normalizedFormFields = fieldNodes.map((child) => {
|
|
1746
|
+
var _a;
|
|
1747
|
+
const rawChildProps = (_a = child.props) != null ? _a : {};
|
|
1748
|
+
const nestedField = rawChildProps.field && typeof rawChildProps.field === "object" && !Array.isArray(rawChildProps.field) ? rawChildProps.field : {};
|
|
1749
|
+
return buildFormFieldConfig(rawChildProps, nestedField);
|
|
1750
|
+
}).filter((field) => {
|
|
1751
|
+
var _a;
|
|
1752
|
+
return String((_a = field.name) != null ? _a : "").trim().length > 0;
|
|
1753
|
+
});
|
|
1754
|
+
return {
|
|
1755
|
+
normalizedChildren,
|
|
1756
|
+
titleNode,
|
|
1757
|
+
fieldNodes,
|
|
1758
|
+
submitNode,
|
|
1759
|
+
resetNode,
|
|
1760
|
+
externalChildren,
|
|
1761
|
+
normalizedFormFields,
|
|
1762
|
+
formValues,
|
|
1763
|
+
formErrors,
|
|
1764
|
+
formDict,
|
|
1765
|
+
formLoaderType: componentProps.loaderType
|
|
1766
|
+
};
|
|
1767
|
+
};
|
|
1768
|
+
|
|
1769
|
+
// src/studio-bridge/preview-form/previewFormRenderer.tsx
|
|
1770
|
+
import { jsx as jsx6, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
1771
|
+
var materializePreviewForm = ({
|
|
1772
|
+
node,
|
|
1773
|
+
componentProps,
|
|
1774
|
+
visibleChildren,
|
|
1775
|
+
runtime,
|
|
1776
|
+
onInlineTextEdit,
|
|
1777
|
+
captureFieldFocus,
|
|
1778
|
+
renderSafeNode: renderSafeNode2
|
|
1779
|
+
}) => {
|
|
1780
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
1781
|
+
const {
|
|
1782
|
+
titleNode,
|
|
1783
|
+
fieldNodes,
|
|
1784
|
+
submitNode,
|
|
1785
|
+
resetNode,
|
|
1786
|
+
externalChildren,
|
|
1787
|
+
normalizedFormFields,
|
|
1788
|
+
formValues,
|
|
1789
|
+
formErrors,
|
|
1790
|
+
formDict,
|
|
1791
|
+
formLoaderType
|
|
1792
|
+
} = resolveStudioFormStructure({
|
|
1793
|
+
componentProps,
|
|
1794
|
+
visibleChildren
|
|
1795
|
+
});
|
|
1796
|
+
if (!(fieldNodes.length > 0 || titleNode || submitNode || resetNode)) {
|
|
1797
|
+
return null;
|
|
1798
|
+
}
|
|
1799
|
+
const validateAndSetErrors = (nextValues) => {
|
|
1800
|
+
const validation = validateFormValues(normalizedFormFields, nextValues, {
|
|
1801
|
+
t: runtime.t,
|
|
1802
|
+
useLegacyFieldConstraints: true
|
|
1803
|
+
});
|
|
1804
|
+
onInlineTextEdit == null ? void 0 : onInlineTextEdit(node.id, "errors", validation.errors);
|
|
1805
|
+
return validation;
|
|
1806
|
+
};
|
|
1807
|
+
const fieldOnChange = (event) => {
|
|
1808
|
+
var _a2;
|
|
1809
|
+
captureFieldFocus(event.target);
|
|
1810
|
+
const fieldName = String((_a2 = event.target.name) != null ? _a2 : "").trim();
|
|
1811
|
+
if (!fieldName) return;
|
|
1812
|
+
const target = event.target;
|
|
1813
|
+
const nextValue = target.type === "checkbox" ? Boolean(target.checked) : event.target.value;
|
|
1814
|
+
const nextValues = resolveStudioFormNextValues({
|
|
1815
|
+
formValues,
|
|
1816
|
+
fieldName,
|
|
1817
|
+
nextValue
|
|
1818
|
+
});
|
|
1819
|
+
onInlineTextEdit == null ? void 0 : onInlineTextEdit(node.id, "values", nextValues);
|
|
1820
|
+
validateAndSetErrors(nextValues);
|
|
1821
|
+
};
|
|
1822
|
+
const openInlineEditorForFormDictProp = (propName, fallbackValue) => {
|
|
1823
|
+
onInlineTextEdit == null ? void 0 : onInlineTextEdit(node.id, propName, fallbackValue);
|
|
1824
|
+
};
|
|
1825
|
+
const openInlineEditorForFormNodeProp = (targetNodeId, fallbackValue) => {
|
|
1826
|
+
onInlineTextEdit == null ? void 0 : onInlineTextEdit(targetNodeId, "children", fallbackValue);
|
|
1827
|
+
};
|
|
1828
|
+
return /* @__PURE__ */ jsxs2("div", { className: "mx-auto mt-10 w-full min-w-0 rounded-2xl border border-border bg-background p-6 shadow-sm", children: [
|
|
1829
|
+
titleNode ? /* @__PURE__ */ jsx6("div", { className: "mb-6 text-center", children: renderSafeNode2(__spreadProps(__spreadValues({}, titleNode), {
|
|
1830
|
+
type: "H3",
|
|
1831
|
+
props: __spreadProps(__spreadValues({}, (_a = titleNode.props) != null ? _a : {}), {
|
|
1832
|
+
className: "text-center text-2xl font-semibold text-foreground",
|
|
1833
|
+
layout: __spreadProps(__spreadValues({}, getLayoutRecord(
|
|
1834
|
+
(_b = titleNode.props) != null ? _b : {}
|
|
1835
|
+
)), {
|
|
1836
|
+
formRole: "title"
|
|
1837
|
+
})
|
|
1838
|
+
})
|
|
1839
|
+
})) }) : /* @__PURE__ */ jsx6("h3", { className: "mb-6 text-center text-2xl font-semibold text-foreground", children: String((_c = componentProps.title) != null ? _c : "Form") }),
|
|
1840
|
+
/* @__PURE__ */ jsxs2(
|
|
1841
|
+
"form",
|
|
1842
|
+
{
|
|
1843
|
+
className: "flex flex-wrap items-start gap-x-3 gap-y-3",
|
|
1844
|
+
role: "form",
|
|
1845
|
+
onSubmit: (event) => {
|
|
1846
|
+
event.preventDefault();
|
|
1847
|
+
const validation = validateAndSetErrors(formValues);
|
|
1848
|
+
if (Object.keys(validation.errors).length > 0) return;
|
|
1849
|
+
},
|
|
1850
|
+
children: [
|
|
1851
|
+
fieldNodes.map((child) => {
|
|
1852
|
+
const { patchedFieldNode, fieldBasis } = patchStudioFormFieldNode({
|
|
1853
|
+
child,
|
|
1854
|
+
formValues,
|
|
1855
|
+
formErrors,
|
|
1856
|
+
formDict,
|
|
1857
|
+
formLoaderType,
|
|
1858
|
+
fieldOnChange
|
|
1859
|
+
});
|
|
1860
|
+
return /* @__PURE__ */ jsx6("div", { className: "contents", children: /* @__PURE__ */ jsx6("div", { style: { flex: `0 0 ${fieldBasis}`, maxWidth: fieldBasis }, children: /* @__PURE__ */ jsx6("div", { className: "min-w-0", children: renderSafeNode2(patchedFieldNode) }) }) }, child.id);
|
|
1861
|
+
}),
|
|
1862
|
+
submitNode || resetNode ? /* @__PURE__ */ jsxs2("div", { className: "basis-full flex flex-wrap justify-end gap-3 py-4", children: [
|
|
1863
|
+
submitNode ? renderSafeNode2(__spreadProps(__spreadValues({}, submitNode), {
|
|
1864
|
+
props: __spreadProps(__spreadValues({}, (_d = submitNode.props) != null ? _d : {}), {
|
|
1865
|
+
type: "submit",
|
|
1866
|
+
onDoubleClick: (event) => {
|
|
1867
|
+
var _a2, _b2, _c2;
|
|
1868
|
+
event.preventDefault();
|
|
1869
|
+
event.stopPropagation();
|
|
1870
|
+
openInlineEditorForFormNodeProp(
|
|
1871
|
+
submitNode.id,
|
|
1872
|
+
String(
|
|
1873
|
+
(_c2 = (_b2 = (_a2 = submitNode.props) == null ? void 0 : _a2.children) != null ? _b2 : formDict.submit) != null ? _c2 : "Submit"
|
|
1874
|
+
)
|
|
1875
|
+
);
|
|
1876
|
+
}
|
|
1877
|
+
})
|
|
1878
|
+
})) : null,
|
|
1879
|
+
resetNode ? renderSafeNode2(__spreadProps(__spreadValues({}, resetNode), {
|
|
1880
|
+
props: __spreadProps(__spreadValues({}, (_e = resetNode.props) != null ? _e : {}), {
|
|
1881
|
+
type: "button",
|
|
1882
|
+
onClick: () => {
|
|
1883
|
+
const resetValues = resolveStudioFormResetValues(normalizedFormFields);
|
|
1884
|
+
onInlineTextEdit == null ? void 0 : onInlineTextEdit(node.id, "values", resetValues);
|
|
1885
|
+
onInlineTextEdit == null ? void 0 : onInlineTextEdit(node.id, "errors", {});
|
|
1886
|
+
},
|
|
1887
|
+
onDoubleClick: (event) => {
|
|
1888
|
+
var _a2, _b2, _c2;
|
|
1889
|
+
event.preventDefault();
|
|
1890
|
+
event.stopPropagation();
|
|
1891
|
+
openInlineEditorForFormNodeProp(
|
|
1892
|
+
resetNode.id,
|
|
1893
|
+
String(
|
|
1894
|
+
(_c2 = (_b2 = (_a2 = resetNode.props) == null ? void 0 : _a2.children) != null ? _b2 : formDict.reset) != null ? _c2 : "Reset"
|
|
1895
|
+
)
|
|
1896
|
+
);
|
|
1897
|
+
}
|
|
1898
|
+
})
|
|
1899
|
+
})) : null
|
|
1900
|
+
] }) : componentProps.onSubmit || componentProps.onReset ? /* @__PURE__ */ jsxs2("div", { className: "basis-full flex flex-wrap justify-end gap-3 py-4", children: [
|
|
1901
|
+
componentProps.onSubmit ? /* @__PURE__ */ jsx6(
|
|
1902
|
+
"button",
|
|
1903
|
+
{
|
|
1904
|
+
type: "submit",
|
|
1905
|
+
className: "inline-flex items-center justify-center rounded-md border border-primary bg-primary px-4 py-2 text-sm font-medium text-primary-foreground",
|
|
1906
|
+
onDoubleClick: (event) => {
|
|
1907
|
+
var _a2;
|
|
1908
|
+
event.preventDefault();
|
|
1909
|
+
event.stopPropagation();
|
|
1910
|
+
openInlineEditorForFormDictProp("dict.submit", String((_a2 = formDict.submit) != null ? _a2 : "Submit"));
|
|
1911
|
+
},
|
|
1912
|
+
children: String((_f = formDict.submit) != null ? _f : "Submit")
|
|
1913
|
+
}
|
|
1914
|
+
) : null,
|
|
1915
|
+
componentProps.onReset ? /* @__PURE__ */ jsx6(
|
|
1916
|
+
"button",
|
|
1917
|
+
{
|
|
1918
|
+
type: "button",
|
|
1919
|
+
className: "inline-flex items-center justify-center rounded-md border border-border bg-background px-4 py-2 text-sm font-medium text-foreground",
|
|
1920
|
+
onClick: () => {
|
|
1921
|
+
const resetValues = resolveStudioFormResetValues(normalizedFormFields);
|
|
1922
|
+
onInlineTextEdit == null ? void 0 : onInlineTextEdit(node.id, "values", resetValues);
|
|
1923
|
+
onInlineTextEdit == null ? void 0 : onInlineTextEdit(node.id, "errors", {});
|
|
1924
|
+
},
|
|
1925
|
+
onDoubleClick: (event) => {
|
|
1926
|
+
var _a2;
|
|
1927
|
+
event.preventDefault();
|
|
1928
|
+
event.stopPropagation();
|
|
1929
|
+
openInlineEditorForFormDictProp("dict.reset", String((_a2 = formDict.reset) != null ? _a2 : "Reset"));
|
|
1930
|
+
},
|
|
1931
|
+
children: String((_g = formDict.reset) != null ? _g : "Reset")
|
|
1932
|
+
}
|
|
1933
|
+
) : null
|
|
1934
|
+
] }) : null,
|
|
1935
|
+
externalChildren.map((child) => /* @__PURE__ */ jsx6(React.Fragment, { children: renderSafeNode2(child) }, child.id))
|
|
1936
|
+
]
|
|
1937
|
+
}
|
|
1938
|
+
)
|
|
1939
|
+
] });
|
|
1940
|
+
};
|
|
1941
|
+
|
|
1942
|
+
// src/utils/navigationStudio.tsx
|
|
1943
|
+
import {
|
|
1944
|
+
buildAccordionItems,
|
|
1945
|
+
buildExpandablePanelChildren
|
|
1946
|
+
} from "@arkcit/engine-react";
|
|
1947
|
+
|
|
1948
|
+
// src/studio-bridge/preview-navigation/previewTabs.ts
|
|
1949
|
+
var normalizeStudioTabsProps = (props) => {
|
|
1950
|
+
var _a;
|
|
1951
|
+
const rawTabs = Array.isArray(props.tabs) ? props.tabs : [];
|
|
1952
|
+
const tabs = rawTabs.length ? rawTabs.map((tab, index) => {
|
|
1953
|
+
var _a2, _b, _c;
|
|
1954
|
+
const rawTab = tab && typeof tab === "object" && !Array.isArray(tab) ? tab : {};
|
|
1955
|
+
const id = String((_a2 = rawTab.id) != null ? _a2 : `tab-${index + 1}`);
|
|
1956
|
+
const title = (_c = (_b = rawTab.title) != null ? _b : rawTab.label) != null ? _c : `Tab ${index + 1}`;
|
|
1957
|
+
return __spreadProps(__spreadValues({}, rawTab), {
|
|
1958
|
+
id,
|
|
1959
|
+
title,
|
|
1960
|
+
label: title
|
|
1961
|
+
});
|
|
1962
|
+
}) : [
|
|
1963
|
+
{
|
|
1964
|
+
id: "overview",
|
|
1965
|
+
title: "Overview",
|
|
1966
|
+
label: "Overview",
|
|
1967
|
+
content: "Overview content"
|
|
1968
|
+
}
|
|
1969
|
+
];
|
|
1970
|
+
const rawDict = props.dict && typeof props.dict === "object" && !Array.isArray(props.dict) ? props.dict : {};
|
|
1971
|
+
const rawUrlSync = props.urlSync && typeof props.urlSync === "object" && !Array.isArray(props.urlSync) ? props.urlSync : null;
|
|
1972
|
+
const rawNavigation = (rawUrlSync == null ? void 0 : rawUrlSync.navigation) && typeof rawUrlSync.navigation === "object" && !Array.isArray(rawUrlSync.navigation) ? rawUrlSync.navigation : null;
|
|
1973
|
+
const normalizedUrlSync = rawNavigation && typeof rawNavigation.getSearch === "function" && typeof rawNavigation.replaceSearch === "function" ? __spreadProps(__spreadValues({}, rawUrlSync), {
|
|
1974
|
+
navigation: rawNavigation
|
|
1975
|
+
}) : void 0;
|
|
1976
|
+
return __spreadProps(__spreadValues({}, props), {
|
|
1977
|
+
tabs,
|
|
1978
|
+
dict: __spreadProps(__spreadValues({}, rawDict), {
|
|
1979
|
+
noContentYet: typeof rawDict.noContentYet === "string" && rawDict.noContentYet.trim().length > 0 ? rawDict.noContentYet : "No content yet"
|
|
1980
|
+
}),
|
|
1981
|
+
defaultActive: typeof props.defaultActive === "string" && props.defaultActive.trim().length > 0 ? props.defaultActive : String((_a = tabs[0].id) != null ? _a : "overview"),
|
|
1982
|
+
keepMounted: typeof props.keepMounted === "boolean" ? props.keepMounted : true,
|
|
1983
|
+
urlSync: normalizedUrlSync
|
|
1984
|
+
});
|
|
1985
|
+
};
|
|
1986
|
+
var resolveStudioTabsContent = ({
|
|
1987
|
+
tabItems,
|
|
1988
|
+
rawChildren,
|
|
1989
|
+
runtime,
|
|
1990
|
+
renderChild,
|
|
1991
|
+
normalizeRenderableChild: normalizeRenderableChild2
|
|
1992
|
+
}) => {
|
|
1993
|
+
const childrenByTabId = /* @__PURE__ */ new Map();
|
|
1994
|
+
const unassignedChildren = [];
|
|
1995
|
+
rawChildren.forEach((child) => {
|
|
1996
|
+
var _a, _b, _c;
|
|
1997
|
+
const childProps = (_a = child.props) != null ? _a : {};
|
|
1998
|
+
const rawLayout = childProps.layout && typeof childProps.layout === "object" && !Array.isArray(childProps.layout) ? childProps.layout : {};
|
|
1999
|
+
const tabIdFromLayout = (_b = rawLayout.tabId) != null ? _b : childProps.__studioTabId;
|
|
2000
|
+
const resolvedTabId = resolveUIValue(tabIdFromLayout, runtime);
|
|
2001
|
+
const normalizedTabId = String(resolvedTabId != null ? resolvedTabId : "").trim();
|
|
2002
|
+
if (!normalizedTabId) {
|
|
2003
|
+
unassignedChildren.push(child);
|
|
2004
|
+
return;
|
|
2005
|
+
}
|
|
2006
|
+
const existing = (_c = childrenByTabId.get(normalizedTabId)) != null ? _c : [];
|
|
2007
|
+
existing.push(child);
|
|
2008
|
+
childrenByTabId.set(normalizedTabId, existing);
|
|
2009
|
+
});
|
|
2010
|
+
return tabItems.map((item, index) => {
|
|
2011
|
+
var _a, _b, _c, _d;
|
|
2012
|
+
const rawId = (_a = item.id) != null ? _a : `tab-${index + 1}`;
|
|
2013
|
+
const resolvedId = resolveUIValue(rawId, runtime);
|
|
2014
|
+
const normalizedId = String(
|
|
2015
|
+
resolvedId == null || String(resolvedId).trim().length === 0 ? rawId : resolvedId
|
|
2016
|
+
);
|
|
2017
|
+
const rawTitle = (_b = item.title) != null ? _b : item.label;
|
|
2018
|
+
const resolvedTitle = resolveUIValue(rawTitle, runtime);
|
|
2019
|
+
const normalizedTitle = (_c = resolvedTitle != null ? resolvedTitle : rawTitle) != null ? _c : `Tab ${index + 1}`;
|
|
2020
|
+
const mappedChildren = (_d = childrenByTabId.get(normalizedId)) != null ? _d : [];
|
|
2021
|
+
const fallbackChildren = index === 0 ? unassignedChildren : [];
|
|
2022
|
+
const contentNodes = [...mappedChildren, ...fallbackChildren];
|
|
2023
|
+
const contentFromChildren = contentNodes.length > 0 ? contentNodes.length === 1 ? renderChild(contentNodes[0]) : contentNodes.map((child) => renderChild(child)) : null;
|
|
2024
|
+
return __spreadProps(__spreadValues({}, item), {
|
|
2025
|
+
id: normalizedId,
|
|
2026
|
+
title: normalizedTitle,
|
|
2027
|
+
label: normalizedTitle,
|
|
2028
|
+
content: contentFromChildren != null ? contentFromChildren : normalizeRenderableChild2(item.content)
|
|
2029
|
+
});
|
|
2030
|
+
});
|
|
2031
|
+
};
|
|
2032
|
+
var resolveStudioTabsProps = ({
|
|
2033
|
+
componentProps,
|
|
2034
|
+
tabItems,
|
|
2035
|
+
rawChildren,
|
|
2036
|
+
runtime,
|
|
2037
|
+
renderChild,
|
|
2038
|
+
normalizeRenderableChild: normalizeRenderableChild2
|
|
2039
|
+
}) => {
|
|
2040
|
+
const normalizedProps = normalizeStudioTabsProps(componentProps);
|
|
2041
|
+
const resolvedTabs = resolveStudioTabsContent({
|
|
2042
|
+
tabItems: Array.isArray(normalizedProps.tabs) ? normalizedProps.tabs : tabItems,
|
|
2043
|
+
rawChildren,
|
|
2044
|
+
runtime,
|
|
2045
|
+
renderChild,
|
|
2046
|
+
normalizeRenderableChild: normalizeRenderableChild2
|
|
2047
|
+
});
|
|
2048
|
+
return {
|
|
2049
|
+
normalizedProps,
|
|
2050
|
+
resolvedTabs
|
|
2051
|
+
};
|
|
2052
|
+
};
|
|
2053
|
+
|
|
2054
|
+
// src/studio-bridge/preview-navigation/previewNavigationState.ts
|
|
2055
|
+
var findContainingNodeId = (targetNodeId, candidates, idResolver) => {
|
|
2056
|
+
const containsNode = (candidate) => {
|
|
2057
|
+
var _a;
|
|
2058
|
+
if (candidate.id === targetNodeId) return true;
|
|
2059
|
+
return ((_a = candidate.children) != null ? _a : []).some((nested) => containsNode(nested));
|
|
2060
|
+
};
|
|
2061
|
+
for (const candidate of candidates) {
|
|
2062
|
+
if (containsNode(candidate)) {
|
|
2063
|
+
return idResolver(candidate);
|
|
2064
|
+
}
|
|
2065
|
+
}
|
|
2066
|
+
return null;
|
|
2067
|
+
};
|
|
2068
|
+
var resolveAccordionOpenIds = ({
|
|
2069
|
+
itemIds,
|
|
2070
|
+
persistedOpenIds,
|
|
2071
|
+
selectedItemId,
|
|
2072
|
+
allowMultiple
|
|
2073
|
+
}) => {
|
|
2074
|
+
let effectiveOpenIds = persistedOpenIds.filter((id) => itemIds.includes(id));
|
|
2075
|
+
if (selectedItemId) {
|
|
2076
|
+
effectiveOpenIds = allowMultiple ? Array.from(/* @__PURE__ */ new Set([...effectiveOpenIds, selectedItemId])) : [selectedItemId];
|
|
2077
|
+
} else if (effectiveOpenIds.length === 0 && itemIds[0]) {
|
|
2078
|
+
effectiveOpenIds = [itemIds[0]];
|
|
2079
|
+
}
|
|
2080
|
+
return effectiveOpenIds;
|
|
2081
|
+
};
|
|
2082
|
+
var resolveStudioAccordionState = ({
|
|
2083
|
+
nodeId,
|
|
2084
|
+
accordionChildren,
|
|
2085
|
+
itemIds,
|
|
2086
|
+
selectedNodeId,
|
|
2087
|
+
accordionOpenIdsByNodeId,
|
|
2088
|
+
allowMultiple
|
|
2089
|
+
}) => {
|
|
2090
|
+
var _a;
|
|
2091
|
+
const validItemIds = new Set(itemIds);
|
|
2092
|
+
const persistedOpenIds = ((_a = accordionOpenIdsByNodeId[nodeId]) != null ? _a : []).filter(
|
|
2093
|
+
(id) => validItemIds.has(id)
|
|
2094
|
+
);
|
|
2095
|
+
const selectedItemId = selectedNodeId != null ? findContainingNodeId(
|
|
2096
|
+
selectedNodeId,
|
|
2097
|
+
accordionChildren,
|
|
2098
|
+
(candidate) => {
|
|
2099
|
+
var _a2, _b;
|
|
2100
|
+
return String((_b = ((_a2 = candidate.props) != null ? _a2 : {}).id) != null ? _b : candidate.id);
|
|
2101
|
+
}
|
|
2102
|
+
) : null;
|
|
2103
|
+
const effectiveOpenIds = resolveAccordionOpenIds({
|
|
2104
|
+
itemIds,
|
|
2105
|
+
persistedOpenIds,
|
|
2106
|
+
selectedItemId,
|
|
2107
|
+
allowMultiple
|
|
2108
|
+
});
|
|
2109
|
+
return {
|
|
2110
|
+
validItemIds,
|
|
2111
|
+
effectiveOpenIds
|
|
2112
|
+
};
|
|
2113
|
+
};
|
|
2114
|
+
var resolveStudioExpandablePanelState = ({
|
|
2115
|
+
nodeId,
|
|
2116
|
+
expandablePanelOpenByNodeId
|
|
2117
|
+
}) => {
|
|
2118
|
+
var _a;
|
|
2119
|
+
return {
|
|
2120
|
+
controlledOpen: (_a = expandablePanelOpenByNodeId[nodeId]) != null ? _a : true,
|
|
2121
|
+
defaultOpen: true,
|
|
2122
|
+
disableAnimation: true
|
|
2123
|
+
};
|
|
2124
|
+
};
|
|
2125
|
+
|
|
2126
|
+
// src/studio-bridge/preview-navigation/previewNavigationConfigurators.tsx
|
|
2127
|
+
var configurePreviewAccordion = ({
|
|
2128
|
+
node,
|
|
2129
|
+
componentProps,
|
|
2130
|
+
accordionChildren,
|
|
2131
|
+
selectedNodeId,
|
|
2132
|
+
accordionOpenIdsByNodeId,
|
|
2133
|
+
setAccordionOpenIdsByNodeId,
|
|
2134
|
+
renderSafeNode: renderSafeNode2
|
|
2135
|
+
}) => {
|
|
2136
|
+
const items = buildAccordionItems(accordionChildren, renderSafeNode2);
|
|
2137
|
+
componentProps.items = items;
|
|
2138
|
+
const { validItemIds, effectiveOpenIds } = resolveStudioAccordionState({
|
|
2139
|
+
nodeId: node.id,
|
|
2140
|
+
accordionChildren,
|
|
2141
|
+
itemIds: items.map((item) => item.id),
|
|
2142
|
+
selectedNodeId,
|
|
2143
|
+
accordionOpenIdsByNodeId,
|
|
2144
|
+
allowMultiple: Boolean(componentProps.allowMultiple)
|
|
2145
|
+
});
|
|
2146
|
+
componentProps.openIds = effectiveOpenIds;
|
|
2147
|
+
componentProps.defaultOpenIds = effectiveOpenIds;
|
|
2148
|
+
componentProps.onOpenIdsChange = (nextOpenIds) => {
|
|
2149
|
+
setAccordionOpenIdsByNodeId((previous) => __spreadProps(__spreadValues({}, previous), {
|
|
2150
|
+
[node.id]: nextOpenIds.filter((id) => validItemIds.has(id))
|
|
2151
|
+
}));
|
|
2152
|
+
};
|
|
2153
|
+
};
|
|
2154
|
+
var configurePreviewExpandablePanel = ({
|
|
2155
|
+
node,
|
|
2156
|
+
componentProps,
|
|
2157
|
+
panelChildren,
|
|
2158
|
+
expandablePanelOpenByNodeId,
|
|
2159
|
+
setExpandablePanelOpenByNodeId,
|
|
2160
|
+
renderSafeNode: renderSafeNode2
|
|
2161
|
+
}) => {
|
|
2162
|
+
const { controlledOpen, defaultOpen, disableAnimation } = resolveStudioExpandablePanelState({
|
|
2163
|
+
nodeId: node.id,
|
|
2164
|
+
expandablePanelOpenByNodeId
|
|
2165
|
+
});
|
|
2166
|
+
componentProps.open = controlledOpen;
|
|
2167
|
+
componentProps.defaultOpen = defaultOpen;
|
|
2168
|
+
componentProps.disableAnimation = disableAnimation;
|
|
2169
|
+
componentProps.onOpenChange = (nextOpen) => {
|
|
2170
|
+
setExpandablePanelOpenByNodeId((previous) => __spreadProps(__spreadValues({}, previous), {
|
|
2171
|
+
[node.id]: Boolean(nextOpen)
|
|
2172
|
+
}));
|
|
2173
|
+
};
|
|
2174
|
+
const panelContent = buildExpandablePanelChildren(panelChildren, renderSafeNode2);
|
|
2175
|
+
if (panelContent) {
|
|
2176
|
+
componentProps.children = panelContent;
|
|
2177
|
+
}
|
|
2178
|
+
};
|
|
2179
|
+
var configurePreviewTabs = ({
|
|
2180
|
+
componentProps,
|
|
2181
|
+
tabItems,
|
|
2182
|
+
rawChildren,
|
|
2183
|
+
runtime,
|
|
2184
|
+
renderSafeNode: renderSafeNode2,
|
|
2185
|
+
normalizeRenderableChild: normalizeRenderableChild2
|
|
2186
|
+
}) => {
|
|
2187
|
+
const { normalizedProps, resolvedTabs } = resolveStudioTabsProps({
|
|
2188
|
+
componentProps,
|
|
2189
|
+
tabItems,
|
|
2190
|
+
rawChildren,
|
|
2191
|
+
runtime,
|
|
2192
|
+
renderChild: renderSafeNode2,
|
|
2193
|
+
normalizeRenderableChild: normalizeRenderableChild2
|
|
2194
|
+
});
|
|
2195
|
+
Object.assign(componentProps, normalizedProps);
|
|
2196
|
+
componentProps.tabs = resolvedTabs;
|
|
2197
|
+
delete componentProps.children;
|
|
2198
|
+
};
|
|
2199
|
+
|
|
2200
|
+
// src/studio-bridge/preview-wizard/previewWizardMaterialization.ts
|
|
2201
|
+
import React2 from "react";
|
|
2202
|
+
|
|
2203
|
+
// src/studio-bridge/preview-wizard/previewWizardFormState.ts
|
|
2204
|
+
var resolveStudioWizardNextValues = ({
|
|
2205
|
+
rawWizardValues,
|
|
2206
|
+
fieldName,
|
|
2207
|
+
nextValue
|
|
2208
|
+
}) => __spreadProps(__spreadValues({}, rawWizardValues), {
|
|
2209
|
+
[fieldName]: nextValue
|
|
2210
|
+
});
|
|
2211
|
+
var resolveStudioWizardActiveStepFields = ({
|
|
2212
|
+
stepId,
|
|
2213
|
+
stepIdToNode
|
|
2214
|
+
}) => {
|
|
2215
|
+
var _a;
|
|
2216
|
+
const activeStepNode = stepIdToNode[stepId];
|
|
2217
|
+
return ((_a = activeStepNode == null ? void 0 : activeStepNode.children) != null ? _a : []).filter((child) => child.type === "FormField").map((child) => {
|
|
2218
|
+
var _a2;
|
|
2219
|
+
const childProps = (_a2 = child.props) != null ? _a2 : {};
|
|
2220
|
+
const childFieldObj = childProps.field && typeof childProps.field === "object" && !Array.isArray(childProps.field) ? childProps.field : {};
|
|
2221
|
+
return buildWizardFieldConfig(childProps, childFieldObj);
|
|
2222
|
+
}).filter((field) => {
|
|
2223
|
+
var _a2;
|
|
2224
|
+
return String((_a2 = field.name) != null ? _a2 : "").trim().length > 0;
|
|
2225
|
+
});
|
|
2226
|
+
};
|
|
2227
|
+
var resolveStudioWizardNextErrors = ({
|
|
2228
|
+
currentWizardErrors,
|
|
2229
|
+
activeStepFields,
|
|
2230
|
+
nextValues,
|
|
2231
|
+
runtime
|
|
2232
|
+
}) => {
|
|
2233
|
+
const validation = validateFormValues(activeStepFields, nextValues, {
|
|
2234
|
+
t: runtime.t,
|
|
2235
|
+
useLegacyFieldConstraints: true
|
|
2236
|
+
});
|
|
2237
|
+
const activeStepFieldNames = new Set(
|
|
2238
|
+
activeStepFields.map((field) => {
|
|
2239
|
+
var _a;
|
|
2240
|
+
return String((_a = field.name) != null ? _a : "").trim();
|
|
2241
|
+
}).filter(Boolean)
|
|
2242
|
+
);
|
|
2243
|
+
const nextErrors = Object.entries(currentWizardErrors).reduce(
|
|
2244
|
+
(accumulator, [key, value]) => {
|
|
2245
|
+
if (activeStepFieldNames.has(key)) return accumulator;
|
|
2246
|
+
accumulator[key] = value;
|
|
2247
|
+
return accumulator;
|
|
2248
|
+
},
|
|
2249
|
+
{}
|
|
2250
|
+
);
|
|
2251
|
+
Object.entries(validation.errors).forEach(([key, value]) => {
|
|
2252
|
+
if (!value) return;
|
|
2253
|
+
nextErrors[key] = value;
|
|
2254
|
+
});
|
|
2255
|
+
return nextErrors;
|
|
2256
|
+
};
|
|
2257
|
+
var patchStudioWizardFieldNode = ({
|
|
2258
|
+
nested,
|
|
2259
|
+
rawWizardValues,
|
|
2260
|
+
currentWizardErrors,
|
|
2261
|
+
fieldOnChange
|
|
2262
|
+
}) => {
|
|
2263
|
+
var _a, _b, _c, _d, _e;
|
|
2264
|
+
const nestedProps = (_a = nested.props) != null ? _a : {};
|
|
2265
|
+
const fieldObj = nestedProps.field && typeof nestedProps.field === "object" && !Array.isArray(nestedProps.field) ? nestedProps.field : {};
|
|
2266
|
+
const fieldName = String((_c = (_b = nestedProps.name) != null ? _b : fieldObj.name) != null ? _c : "").trim();
|
|
2267
|
+
const fieldConfig = __spreadProps(__spreadValues(__spreadValues({}, fieldObj), nestedProps), {
|
|
2268
|
+
name: fieldName,
|
|
2269
|
+
label: String((_e = (_d = nestedProps.label) != null ? _d : fieldObj.label) != null ? _e : fieldName || "Field")
|
|
2270
|
+
});
|
|
2271
|
+
const patchedNode = __spreadProps(__spreadValues({}, nested), {
|
|
2272
|
+
props: __spreadProps(__spreadValues({}, nestedProps), {
|
|
2273
|
+
layout: (() => {
|
|
2274
|
+
var _a2;
|
|
2275
|
+
const rawLayout = nestedProps.layout && typeof nestedProps.layout === "object" && !Array.isArray(nestedProps.layout) ? __spreadValues({}, nestedProps.layout) : {};
|
|
2276
|
+
const existingWrapperClassName = String((_a2 = rawLayout.wrapperClassName) != null ? _a2 : "").trim();
|
|
2277
|
+
rawLayout.wrapperClassName = [existingWrapperClassName, "w-full", "max-w-full"].filter(Boolean).join(" ");
|
|
2278
|
+
delete rawLayout.widthPct;
|
|
2279
|
+
delete rawLayout.heightPct;
|
|
2280
|
+
delete rawLayout.heightPx;
|
|
2281
|
+
return rawLayout;
|
|
2282
|
+
})(),
|
|
2283
|
+
field: fieldConfig,
|
|
2284
|
+
value: fieldName ? rawWizardValues[fieldName] : void 0,
|
|
2285
|
+
error: fieldName ? currentWizardErrors[fieldName] : void 0,
|
|
2286
|
+
onChange: fieldOnChange
|
|
2287
|
+
})
|
|
2288
|
+
});
|
|
2289
|
+
const nestedLayout = readNodeLayout(nestedProps);
|
|
2290
|
+
const fieldBasis = nestedLayout.widthPct !== null ? `${nestedLayout.widthPct}%` : "100%";
|
|
2291
|
+
return {
|
|
2292
|
+
patchedNode,
|
|
2293
|
+
fieldBasis
|
|
2294
|
+
};
|
|
2295
|
+
};
|
|
2296
|
+
|
|
2297
|
+
// src/studio-bridge/preview-wizard/previewWizardMaterialization.ts
|
|
2298
|
+
var renderStudioWizardStepContent = ({
|
|
2299
|
+
step,
|
|
2300
|
+
nodeId,
|
|
2301
|
+
existingFormConfig,
|
|
2302
|
+
rawWizardValues,
|
|
2303
|
+
stepIdToNode,
|
|
2304
|
+
runtime,
|
|
2305
|
+
renderSafeNode: renderSafeNode2,
|
|
2306
|
+
captureFieldFocus,
|
|
2307
|
+
onInlineTextEdit
|
|
2308
|
+
}) => {
|
|
2309
|
+
if (step.contentType === "content") {
|
|
2310
|
+
if (step.contentNode) {
|
|
2311
|
+
return renderSafeNode2(step.contentNode);
|
|
2312
|
+
}
|
|
2313
|
+
return step.contentValue;
|
|
2314
|
+
}
|
|
2315
|
+
if (step.stepRenderableContent.length === 0) {
|
|
2316
|
+
return step.contentValue;
|
|
2317
|
+
}
|
|
2318
|
+
return React2.createElement(
|
|
2319
|
+
"div",
|
|
2320
|
+
{ className: "flex flex-wrap items-start gap-x-3 gap-y-3" },
|
|
2321
|
+
step.stepRenderableContent.map((nested) => {
|
|
2322
|
+
if (nested.type !== "FormField") {
|
|
2323
|
+
return React2.createElement(
|
|
2324
|
+
"div",
|
|
2325
|
+
{ key: nested.id, className: "basis-full" },
|
|
2326
|
+
renderSafeNode2(nested)
|
|
2327
|
+
);
|
|
2328
|
+
}
|
|
2329
|
+
const currentWizardErrors = existingFormConfig.errors && typeof existingFormConfig.errors === "object" && !Array.isArray(existingFormConfig.errors) ? existingFormConfig.errors : {};
|
|
2330
|
+
const { patchedNode, fieldBasis } = patchStudioWizardFieldNode({
|
|
2331
|
+
nested,
|
|
2332
|
+
rawWizardValues,
|
|
2333
|
+
currentWizardErrors,
|
|
2334
|
+
fieldOnChange: (event) => {
|
|
2335
|
+
var _a;
|
|
2336
|
+
captureFieldFocus(event.target);
|
|
2337
|
+
const nextFieldName = String((_a = event.target.name) != null ? _a : "").trim();
|
|
2338
|
+
if (!nextFieldName) return;
|
|
2339
|
+
const target = event.target;
|
|
2340
|
+
const nextValue = target.type === "checkbox" ? Boolean(target.checked) : event.target.value;
|
|
2341
|
+
const nextValues = resolveStudioWizardNextValues({
|
|
2342
|
+
rawWizardValues,
|
|
2343
|
+
fieldName: nextFieldName,
|
|
2344
|
+
nextValue
|
|
2345
|
+
});
|
|
2346
|
+
const activeStepFields = resolveStudioWizardActiveStepFields({
|
|
2347
|
+
stepId: step.id,
|
|
2348
|
+
stepIdToNode
|
|
2349
|
+
});
|
|
2350
|
+
const nextErrors = resolveStudioWizardNextErrors({
|
|
2351
|
+
currentWizardErrors,
|
|
2352
|
+
activeStepFields,
|
|
2353
|
+
nextValues,
|
|
2354
|
+
runtime
|
|
2355
|
+
});
|
|
2356
|
+
onInlineTextEdit == null ? void 0 : onInlineTextEdit(nodeId, "form.values", nextValues);
|
|
2357
|
+
onInlineTextEdit == null ? void 0 : onInlineTextEdit(nodeId, "form.errors", nextErrors);
|
|
2358
|
+
}
|
|
2359
|
+
});
|
|
2360
|
+
return React2.createElement(
|
|
2361
|
+
"div",
|
|
2362
|
+
{
|
|
2363
|
+
key: nested.id,
|
|
2364
|
+
className: "min-w-0",
|
|
2365
|
+
style: { flex: `0 0 ${fieldBasis}`, maxWidth: fieldBasis }
|
|
2366
|
+
},
|
|
2367
|
+
renderSafeNode2(patchedNode)
|
|
2368
|
+
);
|
|
2369
|
+
})
|
|
2370
|
+
);
|
|
2371
|
+
};
|
|
2372
|
+
var materializeStudioWizardSteps = ({
|
|
2373
|
+
nodeId,
|
|
2374
|
+
currentSteps,
|
|
2375
|
+
existingFormConfig,
|
|
2376
|
+
rawWizardValues,
|
|
2377
|
+
stepIdToNode,
|
|
2378
|
+
runtime,
|
|
2379
|
+
renderSafeNode: renderSafeNode2,
|
|
2380
|
+
captureFieldFocus,
|
|
2381
|
+
onInlineTextEdit
|
|
2382
|
+
}) => currentSteps.map((step) => ({
|
|
2383
|
+
id: step.id,
|
|
2384
|
+
title: step.title,
|
|
2385
|
+
description: step.description,
|
|
2386
|
+
titleNode: step.titleNode ? renderSafeNode2(step.titleNode) : void 0,
|
|
2387
|
+
descriptionNode: step.descriptionNode ? renderSafeNode2(step.descriptionNode) : void 0,
|
|
2388
|
+
isValid: step.isValid,
|
|
2389
|
+
content: renderStudioWizardStepContent({
|
|
2390
|
+
step,
|
|
2391
|
+
nodeId,
|
|
2392
|
+
currentSteps,
|
|
2393
|
+
existingFormConfig,
|
|
2394
|
+
rawWizardValues,
|
|
2395
|
+
stepIdToNode,
|
|
2396
|
+
runtime,
|
|
2397
|
+
renderSafeNode: renderSafeNode2,
|
|
2398
|
+
captureFieldFocus,
|
|
2399
|
+
onInlineTextEdit
|
|
2400
|
+
})
|
|
2401
|
+
}));
|
|
2402
|
+
|
|
2403
|
+
// src/studio-bridge/preview-wizard/wizardEditingHandlers.ts
|
|
2404
|
+
var findWizardStepRoleNode = (stepNode, role) => {
|
|
2405
|
+
var _a;
|
|
2406
|
+
const nestedChildren = Array.isArray(stepNode.children) ? stepNode.children : [];
|
|
2407
|
+
return (_a = nestedChildren.find((child) => {
|
|
2408
|
+
var _a2, _b;
|
|
2409
|
+
const childProps = (_a2 = child.props) != null ? _a2 : {};
|
|
2410
|
+
return String((_b = getLayoutRecord(childProps).wizardStepRole) != null ? _b : "").trim() === role;
|
|
2411
|
+
})) != null ? _a : null;
|
|
2412
|
+
};
|
|
2413
|
+
var createStudioWizardOnStepChange = ({
|
|
2414
|
+
nodeId,
|
|
2415
|
+
stepIdToNode,
|
|
2416
|
+
setWizardActiveStepByNodeId,
|
|
2417
|
+
existingOnStepChange,
|
|
2418
|
+
onNodeClick
|
|
2419
|
+
}) => {
|
|
2420
|
+
return (stepId) => {
|
|
2421
|
+
setWizardActiveStepByNodeId((previous) => {
|
|
2422
|
+
if (previous[nodeId] === stepId) return previous;
|
|
2423
|
+
return __spreadProps(__spreadValues({}, previous), {
|
|
2424
|
+
[nodeId]: stepId
|
|
2425
|
+
});
|
|
2426
|
+
});
|
|
2427
|
+
if (typeof existingOnStepChange === "function") {
|
|
2428
|
+
existingOnStepChange(stepId);
|
|
2429
|
+
}
|
|
2430
|
+
const stepNode = stepIdToNode[stepId];
|
|
2431
|
+
if (stepNode && onNodeClick) {
|
|
2432
|
+
onNodeClick(stepNode.id);
|
|
2433
|
+
}
|
|
2434
|
+
};
|
|
2435
|
+
};
|
|
2436
|
+
var attachStudioWizardEditingHandlers = ({
|
|
2437
|
+
studioConfig,
|
|
2438
|
+
node,
|
|
2439
|
+
stepIdToNode,
|
|
2440
|
+
openInlineEditorForNodeProp
|
|
2441
|
+
}) => {
|
|
2442
|
+
studioConfig.onStepTitleDoubleClick = (stepId) => {
|
|
2443
|
+
var _a, _b, _c, _d, _e;
|
|
2444
|
+
const stepNode = stepIdToNode[stepId];
|
|
2445
|
+
if (!stepNode) return;
|
|
2446
|
+
const stepProps = (_a = stepNode.props) != null ? _a : {};
|
|
2447
|
+
const titleNode = findWizardStepRoleNode(stepNode, "title");
|
|
2448
|
+
if (titleNode) {
|
|
2449
|
+
const titleNodeProps = (_b = titleNode.props) != null ? _b : {};
|
|
2450
|
+
openInlineEditorForNodeProp(
|
|
2451
|
+
titleNode.id,
|
|
2452
|
+
"children",
|
|
2453
|
+
(_d = (_c = titleNodeProps.children) != null ? _c : stepProps.title) != null ? _d : stepId
|
|
2454
|
+
);
|
|
2455
|
+
return;
|
|
2456
|
+
}
|
|
2457
|
+
openInlineEditorForNodeProp(stepNode.id, "title", (_e = stepProps.title) != null ? _e : stepId);
|
|
2458
|
+
};
|
|
2459
|
+
studioConfig.onStepDescriptionDoubleClick = (stepId) => {
|
|
2460
|
+
var _a, _b, _c, _d, _e;
|
|
2461
|
+
const stepNode = stepIdToNode[stepId];
|
|
2462
|
+
if (!stepNode) return;
|
|
2463
|
+
const stepProps = (_a = stepNode.props) != null ? _a : {};
|
|
2464
|
+
const descriptionNode = findWizardStepRoleNode(stepNode, "description");
|
|
2465
|
+
if (descriptionNode) {
|
|
2466
|
+
const descriptionNodeProps = (_b = descriptionNode.props) != null ? _b : {};
|
|
2467
|
+
openInlineEditorForNodeProp(
|
|
2468
|
+
descriptionNode.id,
|
|
2469
|
+
"children",
|
|
2470
|
+
(_d = (_c = descriptionNodeProps.children) != null ? _c : stepProps.description) != null ? _d : ""
|
|
2471
|
+
);
|
|
2472
|
+
return;
|
|
2473
|
+
}
|
|
2474
|
+
openInlineEditorForNodeProp(stepNode.id, "description", (_e = stepProps.description) != null ? _e : "");
|
|
2475
|
+
};
|
|
2476
|
+
studioConfig.onBackLabelDoubleClick = () => {
|
|
2477
|
+
var _a, _b, _c;
|
|
2478
|
+
return openInlineEditorForNodeProp(
|
|
2479
|
+
node.id,
|
|
2480
|
+
"labels.back",
|
|
2481
|
+
(_c = (_b = (_a = node.props) == null ? void 0 : _a.labels) == null ? void 0 : _b.back) != null ? _c : "Back"
|
|
2482
|
+
);
|
|
2483
|
+
};
|
|
2484
|
+
studioConfig.onNextLabelDoubleClick = () => {
|
|
2485
|
+
var _a, _b, _c;
|
|
2486
|
+
return openInlineEditorForNodeProp(
|
|
2487
|
+
node.id,
|
|
2488
|
+
"labels.next",
|
|
2489
|
+
(_c = (_b = (_a = node.props) == null ? void 0 : _a.labels) == null ? void 0 : _b.next) != null ? _c : "Next"
|
|
2490
|
+
);
|
|
2491
|
+
};
|
|
2492
|
+
studioConfig.onFinishLabelDoubleClick = () => {
|
|
2493
|
+
var _a, _b, _c;
|
|
2494
|
+
return openInlineEditorForNodeProp(
|
|
2495
|
+
node.id,
|
|
2496
|
+
"labels.finish",
|
|
2497
|
+
(_c = (_b = (_a = node.props) == null ? void 0 : _a.labels) == null ? void 0 : _b.finish) != null ? _c : "Finish"
|
|
2498
|
+
);
|
|
2499
|
+
};
|
|
2500
|
+
return studioConfig;
|
|
2501
|
+
};
|
|
2502
|
+
|
|
2503
|
+
// src/utils/wizardStudio.ts
|
|
2504
|
+
var getWizardStepRole = (node) => {
|
|
2505
|
+
var _a, _b;
|
|
2506
|
+
const props = (_a = node.props) != null ? _a : {};
|
|
2507
|
+
const layout = getLayoutRecord(props);
|
|
2508
|
+
return String((_b = layout.wizardStepRole) != null ? _b : "").trim();
|
|
2509
|
+
};
|
|
2510
|
+
var getWizardRenderableChildren = (nodes) => nodes.filter((nested) => {
|
|
2511
|
+
const stepRole = getWizardStepRole(nested);
|
|
2512
|
+
return stepRole !== "title" && stepRole !== "description";
|
|
2513
|
+
});
|
|
2514
|
+
var findSelectedWizardStepId = (stepChildren, selectedNodeId) => {
|
|
2515
|
+
var _a, _b, _c;
|
|
2516
|
+
if (!selectedNodeId) return null;
|
|
2517
|
+
const selectedStep = stepChildren.find((stepChild) => {
|
|
2518
|
+
var _a2;
|
|
2519
|
+
if (stepChild.id === selectedNodeId) return true;
|
|
2520
|
+
return ((_a2 = stepChild.children) != null ? _a2 : []).some((nested) => {
|
|
2521
|
+
const stepRole = getWizardStepRole(nested);
|
|
2522
|
+
return nested.id === selectedNodeId && (stepRole === "title" || stepRole === "description");
|
|
2523
|
+
});
|
|
2524
|
+
});
|
|
2525
|
+
if (!selectedStep) return null;
|
|
2526
|
+
const stepProps = (_a = selectedStep.props) != null ? _a : {};
|
|
2527
|
+
return String((_c = (_b = stepProps.id) != null ? _b : selectedStep.id) != null ? _c : "").trim() || null;
|
|
2528
|
+
};
|
|
2529
|
+
var buildFieldsByStep = (stepIdToNode, currentSteps) => currentSteps.reduce((accumulator, step) => {
|
|
2530
|
+
var _a, _b;
|
|
2531
|
+
const stepId = String((_a = step.id) != null ? _a : "").trim();
|
|
2532
|
+
if (!stepId) return accumulator;
|
|
2533
|
+
const stepNode = stepIdToNode[stepId];
|
|
2534
|
+
const stepRenderableChildren = getWizardRenderableChildren((_b = stepNode == null ? void 0 : stepNode.children) != null ? _b : []);
|
|
2535
|
+
const fields = stepRenderableChildren.filter((nested) => nested.type === "FormField").map((nested) => {
|
|
2536
|
+
var _a2;
|
|
2537
|
+
const nestedProps = (_a2 = nested.props) != null ? _a2 : {};
|
|
2538
|
+
const nestedField = nestedProps.field && typeof nestedProps.field === "object" && !Array.isArray(nestedProps.field) ? nestedProps.field : {};
|
|
2539
|
+
return buildWizardFieldConfig(nestedProps, nestedField);
|
|
2540
|
+
}).filter((field) => {
|
|
2541
|
+
var _a2;
|
|
2542
|
+
return String((_a2 = field.name) != null ? _a2 : "").trim().length > 0;
|
|
2543
|
+
});
|
|
2544
|
+
accumulator[stepId] = fields;
|
|
2545
|
+
return accumulator;
|
|
2546
|
+
}, {});
|
|
2547
|
+
var resolveActiveWizardStepId = ({
|
|
2548
|
+
selectedStepId,
|
|
2549
|
+
stepIds,
|
|
2550
|
+
activeStepFromProps,
|
|
2551
|
+
activeStepFromMemory
|
|
2552
|
+
}) => {
|
|
2553
|
+
var _a;
|
|
2554
|
+
if (selectedStepId && stepIds.includes(selectedStepId)) return selectedStepId;
|
|
2555
|
+
if (activeStepFromProps && stepIds.includes(activeStepFromProps)) {
|
|
2556
|
+
return activeStepFromProps;
|
|
2557
|
+
}
|
|
2558
|
+
if (activeStepFromMemory && stepIds.includes(activeStepFromMemory)) {
|
|
2559
|
+
return activeStepFromMemory;
|
|
2560
|
+
}
|
|
2561
|
+
return (_a = stepIds[0]) != null ? _a : "";
|
|
2562
|
+
};
|
|
2563
|
+
var validateWizardStepFields = ({
|
|
2564
|
+
stepRenderableContent,
|
|
2565
|
+
values,
|
|
2566
|
+
runtime
|
|
2567
|
+
}) => {
|
|
2568
|
+
const normalizedFields = stepRenderableContent.filter((nested) => nested.type === "FormField").map((nested) => {
|
|
2569
|
+
var _a;
|
|
2570
|
+
const nestedProps = (_a = nested.props) != null ? _a : {};
|
|
2571
|
+
const fieldObject = nestedProps.field && typeof nestedProps.field === "object" && !Array.isArray(nestedProps.field) ? nestedProps.field : {};
|
|
2572
|
+
return buildWizardFieldConfig(nestedProps, fieldObject);
|
|
2573
|
+
});
|
|
2574
|
+
const filteredFields = normalizedFields.filter((field) => field.name.length > 0);
|
|
2575
|
+
const validation = validateFormValues(filteredFields, values, {
|
|
2576
|
+
t: runtime.t,
|
|
2577
|
+
useLegacyFieldConstraints: true
|
|
2578
|
+
});
|
|
2579
|
+
return validation.issues.length === 0;
|
|
2580
|
+
};
|
|
2581
|
+
|
|
2582
|
+
// src/studio-bridge/preview-wizard/previewWizardStructure.ts
|
|
2583
|
+
var resolveStudioWizardStructure = ({
|
|
2584
|
+
node,
|
|
2585
|
+
componentProps,
|
|
2586
|
+
selectedNodeId,
|
|
2587
|
+
wizardActiveStepByNodeId,
|
|
2588
|
+
runtime,
|
|
2589
|
+
internalStudioNodeTypes
|
|
2590
|
+
}) => {
|
|
2591
|
+
var _a, _b, _c, _d, _e, _f;
|
|
2592
|
+
const existingFormConfig = componentProps.form && typeof componentProps.form === "object" && !Array.isArray(componentProps.form) ? __spreadValues({}, componentProps.form) : {};
|
|
2593
|
+
const existingStudioConfig = componentProps.studio && typeof componentProps.studio === "object" && !Array.isArray(componentProps.studio) ? __spreadValues({}, componentProps.studio) : {};
|
|
2594
|
+
const stepChildren = ((_a = node.children) != null ? _a : []).filter((child) => {
|
|
2595
|
+
var _a2;
|
|
2596
|
+
const childProps = (_a2 = child.props) != null ? _a2 : {};
|
|
2597
|
+
const layout = getLayoutRecord(childProps);
|
|
2598
|
+
const isWizardStepFlag = layout.wizardStep === true;
|
|
2599
|
+
const isSupportedStepType = child.type === "Container" || child.type === "StepForm";
|
|
2600
|
+
return isSupportedStepType && isWizardStepFlag;
|
|
2601
|
+
});
|
|
2602
|
+
const stepIdToNode = stepChildren.reduce(
|
|
2603
|
+
(accumulator, stepChild) => {
|
|
2604
|
+
var _a2, _b2, _c2;
|
|
2605
|
+
const stepProps = (_a2 = stepChild.props) != null ? _a2 : {};
|
|
2606
|
+
const stepId = String((_b2 = stepProps.id) != null ? _b2 : "").trim();
|
|
2607
|
+
const fallbackId = String((_c2 = stepChild.id) != null ? _c2 : "").trim();
|
|
2608
|
+
if (stepId) accumulator[stepId] = stepChild;
|
|
2609
|
+
if (fallbackId) accumulator[fallbackId] = stepChild;
|
|
2610
|
+
return accumulator;
|
|
2611
|
+
},
|
|
2612
|
+
{}
|
|
2613
|
+
);
|
|
2614
|
+
const selectedStepId = findSelectedWizardStepId(stepChildren, selectedNodeId);
|
|
2615
|
+
const rawWizardValues = existingFormConfig.values && typeof existingFormConfig.values === "object" && !Array.isArray(existingFormConfig.values) ? existingFormConfig.values : {};
|
|
2616
|
+
const currentSteps = stepChildren.map((stepChild) => {
|
|
2617
|
+
var _a2, _b2, _c2, _d2, _e2, _f2, _g, _h, _i, _j, _k;
|
|
2618
|
+
const stepProps = (_a2 = stepChild.props) != null ? _a2 : {};
|
|
2619
|
+
const stepId = String((_b2 = stepProps.id) != null ? _b2 : "").trim() || stepChild.id;
|
|
2620
|
+
const stepContent = ((_c2 = stepChild.children) != null ? _c2 : []).filter(
|
|
2621
|
+
(nested) => !internalStudioNodeTypes.has(nested.type)
|
|
2622
|
+
);
|
|
2623
|
+
const stepTitleNode = stepContent.find(
|
|
2624
|
+
(nested) => {
|
|
2625
|
+
var _a3, _b3;
|
|
2626
|
+
return String(
|
|
2627
|
+
(_b3 = getLayoutRecord((_a3 = nested.props) != null ? _a3 : {}).wizardStepRole) != null ? _b3 : ""
|
|
2628
|
+
).trim() === "title";
|
|
2629
|
+
}
|
|
2630
|
+
);
|
|
2631
|
+
const stepDescriptionNode = stepContent.find(
|
|
2632
|
+
(nested) => {
|
|
2633
|
+
var _a3, _b3;
|
|
2634
|
+
return String(
|
|
2635
|
+
(_b3 = getLayoutRecord((_a3 = nested.props) != null ? _a3 : {}).wizardStepRole) != null ? _b3 : ""
|
|
2636
|
+
).trim() === "description";
|
|
2637
|
+
}
|
|
2638
|
+
);
|
|
2639
|
+
const stepTitleNodeValue = (_d2 = stepTitleNode == null ? void 0 : stepTitleNode.props) == null ? void 0 : _d2.children;
|
|
2640
|
+
const stepDescriptionNodeValue = (_e2 = stepDescriptionNode == null ? void 0 : stepDescriptionNode.props) == null ? void 0 : _e2.children;
|
|
2641
|
+
const title = resolveUIValue((_f2 = stepTitleNodeValue != null ? stepTitleNodeValue : stepProps.title) != null ? _f2 : stepId, runtime);
|
|
2642
|
+
const description = resolveUIValue((_g = stepDescriptionNodeValue != null ? stepDescriptionNodeValue : stepProps.description) != null ? _g : "", runtime);
|
|
2643
|
+
const rawContentType = String((_h = stepProps.contentType) != null ? _h : "content");
|
|
2644
|
+
const stepRenderableContent = getWizardRenderableChildren(stepContent);
|
|
2645
|
+
const hasFieldChildren = stepRenderableContent.some((nested) => {
|
|
2646
|
+
var _a3, _b3;
|
|
2647
|
+
if (nested.type !== "FormField") return false;
|
|
2648
|
+
const nestedProps = (_a3 = nested.props) != null ? _a3 : {};
|
|
2649
|
+
return String((_b3 = getLayoutRecord(nestedProps).formRole) != null ? _b3 : "field").trim() === "field";
|
|
2650
|
+
});
|
|
2651
|
+
const contentType = hasFieldChildren ? "form" : rawContentType;
|
|
2652
|
+
const isValid = !hasFieldChildren ? stepProps.isValid !== false : validateWizardStepFields({
|
|
2653
|
+
stepRenderableContent,
|
|
2654
|
+
values: rawWizardValues,
|
|
2655
|
+
runtime
|
|
2656
|
+
});
|
|
2657
|
+
const explicitContentNode = stepRenderableContent.find(
|
|
2658
|
+
(nested) => {
|
|
2659
|
+
var _a3;
|
|
2660
|
+
return getLayoutRecord((_a3 = nested.props) != null ? _a3 : {}).wizardContent === true;
|
|
2661
|
+
}
|
|
2662
|
+
);
|
|
2663
|
+
const contentNode = explicitContentNode != null ? explicitContentNode : contentType === "content" ? stepRenderableContent[0] : void 0;
|
|
2664
|
+
return {
|
|
2665
|
+
id: stepId,
|
|
2666
|
+
title,
|
|
2667
|
+
description,
|
|
2668
|
+
titleNode: stepTitleNode,
|
|
2669
|
+
descriptionNode: stepDescriptionNode,
|
|
2670
|
+
contentNode,
|
|
2671
|
+
isValid,
|
|
2672
|
+
contentType,
|
|
2673
|
+
stepRenderableContent,
|
|
2674
|
+
contentValue: contentType === "content" ? resolveUIValue(
|
|
2675
|
+
(_k = (_j = (_i = contentNode == null ? void 0 : contentNode.props) == null ? void 0 : _i.children) != null ? _j : stepProps.content) != null ? _k : title,
|
|
2676
|
+
runtime
|
|
2677
|
+
) : null
|
|
2678
|
+
};
|
|
2679
|
+
});
|
|
2680
|
+
const normalizedFieldsByStep = buildFieldsByStep(
|
|
2681
|
+
stepIdToNode,
|
|
2682
|
+
currentSteps
|
|
2683
|
+
);
|
|
2684
|
+
const stepIds = currentSteps.map((step) => step.id).filter(Boolean);
|
|
2685
|
+
const activeStepFromMemory = String((_b = wizardActiveStepByNodeId[node.id]) != null ? _b : "").trim();
|
|
2686
|
+
const activeStepFromProps = String(
|
|
2687
|
+
(_f = (_e = (_c = node.props) == null ? void 0 : _c.activeStepId) != null ? _e : (_d = node.props) == null ? void 0 : _d.initialStepId) != null ? _f : ""
|
|
2688
|
+
).trim();
|
|
2689
|
+
const resolvedActiveStepId = resolveActiveWizardStepId({
|
|
2690
|
+
selectedStepId,
|
|
2691
|
+
stepIds,
|
|
2692
|
+
activeStepFromProps,
|
|
2693
|
+
activeStepFromMemory
|
|
2694
|
+
});
|
|
2695
|
+
return {
|
|
2696
|
+
stepChildren,
|
|
2697
|
+
stepIdToNode,
|
|
2698
|
+
selectedStepId,
|
|
2699
|
+
currentSteps,
|
|
2700
|
+
normalizedFieldsByStep,
|
|
2701
|
+
resolvedActiveStepId,
|
|
2702
|
+
existingFormConfig,
|
|
2703
|
+
existingStudioConfig
|
|
2704
|
+
};
|
|
2705
|
+
};
|
|
2706
|
+
|
|
2707
|
+
// src/studio-bridge/preview-wizard/previewWizardConfigurator.ts
|
|
2708
|
+
var configurePreviewFormWizard = ({
|
|
2709
|
+
node,
|
|
2710
|
+
componentProps,
|
|
2711
|
+
isStudioRendererContext,
|
|
2712
|
+
selectedNodeId,
|
|
2713
|
+
wizardActiveStepByNodeId,
|
|
2714
|
+
runtime,
|
|
2715
|
+
setWizardActiveStepByNodeId,
|
|
2716
|
+
onNodeClick,
|
|
2717
|
+
onInlineTextEdit,
|
|
2718
|
+
renderSafeNode: renderSafeNode2,
|
|
2719
|
+
captureFieldFocus,
|
|
2720
|
+
openInlineEditorForNodeProp,
|
|
2721
|
+
internalStudioNodeTypes
|
|
2722
|
+
}) => {
|
|
2723
|
+
var _a;
|
|
2724
|
+
if (isStudioRendererContext) {
|
|
2725
|
+
const existingClassName = String((_a = componentProps.className) != null ? _a : "").trim();
|
|
2726
|
+
componentProps.className = [
|
|
2727
|
+
existingClassName,
|
|
2728
|
+
"w-full",
|
|
2729
|
+
"[&_[data-step-form-wrapper]>section]:max-w-full",
|
|
2730
|
+
"[&_[data-step-form-wrapper]>section]:mx-0"
|
|
2731
|
+
].filter(Boolean).join(" ");
|
|
2732
|
+
}
|
|
2733
|
+
const {
|
|
2734
|
+
existingFormConfig,
|
|
2735
|
+
existingStudioConfig,
|
|
2736
|
+
currentSteps,
|
|
2737
|
+
normalizedFieldsByStep,
|
|
2738
|
+
resolvedActiveStepId,
|
|
2739
|
+
stepIdToNode
|
|
2740
|
+
} = resolveStudioWizardStructure({
|
|
2741
|
+
node,
|
|
2742
|
+
componentProps,
|
|
2743
|
+
selectedNodeId,
|
|
2744
|
+
wizardActiveStepByNodeId,
|
|
2745
|
+
runtime,
|
|
2746
|
+
internalStudioNodeTypes
|
|
2747
|
+
});
|
|
2748
|
+
const rawWizardValues = existingFormConfig.values && typeof existingFormConfig.values === "object" && !Array.isArray(existingFormConfig.values) ? existingFormConfig.values : {};
|
|
2749
|
+
const materializedSteps = materializeStudioWizardSteps({
|
|
2750
|
+
nodeId: node.id,
|
|
2751
|
+
currentSteps,
|
|
2752
|
+
existingFormConfig,
|
|
2753
|
+
rawWizardValues,
|
|
2754
|
+
stepIdToNode,
|
|
2755
|
+
runtime,
|
|
2756
|
+
renderSafeNode: renderSafeNode2,
|
|
2757
|
+
captureFieldFocus,
|
|
2758
|
+
onInlineTextEdit
|
|
2759
|
+
});
|
|
2760
|
+
if (materializedSteps.length > 0) {
|
|
2761
|
+
componentProps.steps = materializedSteps;
|
|
2762
|
+
}
|
|
2763
|
+
existingFormConfig.fieldsByStep = normalizedFieldsByStep;
|
|
2764
|
+
if (resolvedActiveStepId) {
|
|
2765
|
+
componentProps.activeStepId = resolvedActiveStepId;
|
|
2766
|
+
}
|
|
2767
|
+
componentProps.onStepChange = createStudioWizardOnStepChange({
|
|
2768
|
+
nodeId: node.id,
|
|
2769
|
+
stepIdToNode,
|
|
2770
|
+
setWizardActiveStepByNodeId,
|
|
2771
|
+
existingOnStepChange: componentProps.onStepChange,
|
|
2772
|
+
onNodeClick
|
|
2773
|
+
});
|
|
2774
|
+
attachStudioWizardEditingHandlers({
|
|
2775
|
+
studioConfig: existingStudioConfig,
|
|
2776
|
+
node,
|
|
2777
|
+
stepIdToNode,
|
|
2778
|
+
openInlineEditorForNodeProp
|
|
2779
|
+
});
|
|
2780
|
+
componentProps.form = isStudioRendererContext ? void 0 : existingFormConfig;
|
|
2781
|
+
componentProps.studio = existingStudioConfig;
|
|
2782
|
+
};
|
|
2783
|
+
export {
|
|
2784
|
+
InlineTextEditor,
|
|
2785
|
+
StudioNodeWrapper,
|
|
2786
|
+
applyInlineEditingValue,
|
|
2787
|
+
applyStudioOverlayComponentProps,
|
|
2788
|
+
attachStudioWizardEditingHandlers,
|
|
2789
|
+
buildNormalizedActionRef,
|
|
2790
|
+
computeInlineEditorStyle,
|
|
2791
|
+
computeMouseResizeSize,
|
|
2792
|
+
computePinchResizeSize,
|
|
2793
|
+
configurePreviewAccordion,
|
|
2794
|
+
configurePreviewExpandablePanel,
|
|
2795
|
+
configurePreviewFormWizard,
|
|
2796
|
+
configurePreviewTabs,
|
|
2797
|
+
createMouseResizeHandler,
|
|
2798
|
+
createMouseResizeState,
|
|
2799
|
+
createPinchResizeState,
|
|
2800
|
+
createStudioNodeClickHandler,
|
|
2801
|
+
createStudioNodeDoubleClickHandler,
|
|
2802
|
+
createStudioWizardOnStepChange,
|
|
2803
|
+
createTouchResizeHandlers,
|
|
2804
|
+
getEditableTextValue,
|
|
2805
|
+
getNodeWrapperPresentation,
|
|
2806
|
+
getOpenStudioOverlayState,
|
|
2807
|
+
getStudioNodeInteractionState,
|
|
2808
|
+
isInteractiveSelectionTarget,
|
|
2809
|
+
markSuppressStudioClick,
|
|
2810
|
+
materializePreviewForm,
|
|
2811
|
+
materializeStudioWizardSteps,
|
|
2812
|
+
normalizeStudioTabsProps,
|
|
2813
|
+
openInlineEditorFromDoubleClick,
|
|
2814
|
+
patchStudioFormFieldNode,
|
|
2815
|
+
patchStudioWizardFieldNode,
|
|
2816
|
+
readOverlayState,
|
|
2817
|
+
renderNodeFrame,
|
|
2818
|
+
renderPlainWrappedNode,
|
|
2819
|
+
renderSafeNode,
|
|
2820
|
+
resolveButtonOverlayTarget,
|
|
2821
|
+
resolveClickedNodeId,
|
|
2822
|
+
resolveInlineEditingTarget,
|
|
2823
|
+
resolveStudioAccordionState,
|
|
2824
|
+
resolveStudioExpandablePanelState,
|
|
2825
|
+
resolveStudioFormNextValues,
|
|
2826
|
+
resolveStudioFormResetValues,
|
|
2827
|
+
resolveStudioFormStructure,
|
|
2828
|
+
resolveStudioTabsContent,
|
|
2829
|
+
resolveStudioTabsProps,
|
|
2830
|
+
resolveStudioWizardActiveStepFields,
|
|
2831
|
+
resolveStudioWizardNextErrors,
|
|
2832
|
+
resolveStudioWizardNextValues,
|
|
2833
|
+
resolveStudioWizardStructure,
|
|
2834
|
+
selectCandidateInlineProp,
|
|
2835
|
+
selectEffectiveInlineProp,
|
|
2836
|
+
shouldForceStudioNodeFullWidth,
|
|
2837
|
+
shouldSuppressStudioClick,
|
|
2838
|
+
shouldUseMultilineInlineEditor,
|
|
2839
|
+
syncOverlayStateFromAction
|
|
2840
|
+
};
|