@pixldocs/canvas-renderer 0.3.8 → 0.3.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +62 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +62 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -10045,8 +10045,20 @@ async function resolveFromForm(options) {
|
|
|
10045
10045
|
]);
|
|
10046
10046
|
const templateConfig = templateRow.config;
|
|
10047
10047
|
const templateFormSchema = templateRow.form_schema;
|
|
10048
|
-
|
|
10048
|
+
if (templateFormSchema) {
|
|
10049
|
+
if (!Array.isArray(templateConfig.dynamicFields) && Array.isArray(templateFormSchema.dynamicFields)) {
|
|
10050
|
+
templateConfig.dynamicFields = templateFormSchema.dynamicFields;
|
|
10051
|
+
}
|
|
10052
|
+
if (!Array.isArray(templateConfig.fieldGroups) && Array.isArray(templateFormSchema.fieldGroups)) {
|
|
10053
|
+
templateConfig.fieldGroups = templateFormSchema.fieldGroups;
|
|
10054
|
+
}
|
|
10055
|
+
}
|
|
10056
|
+
normalizeLayoutModes(templateConfig);
|
|
10049
10057
|
const repeatableFromSchema = templateFormSchema == null ? void 0 : templateFormSchema.repeatableSections;
|
|
10058
|
+
if ((repeatableFromSchema == null ? void 0 : repeatableFromSchema.length) && templateConfig.pages) {
|
|
10059
|
+
paintRepeatableSections(templateConfig, repeatableFromSchema);
|
|
10060
|
+
}
|
|
10061
|
+
const schemaSections = (_a = formSchemaRow.schema) == null ? void 0 : _a.sections;
|
|
10050
10062
|
const repeatableNodeMap = /* @__PURE__ */ new Map();
|
|
10051
10063
|
if (repeatableFromSchema) {
|
|
10052
10064
|
for (const r of repeatableFromSchema) {
|
|
@@ -10078,9 +10090,7 @@ async function resolveFromForm(options) {
|
|
|
10078
10090
|
}
|
|
10079
10091
|
}
|
|
10080
10092
|
const flatFormData = flattenSectionStateToFormData(mergedSectionState, inferredSections);
|
|
10081
|
-
const
|
|
10082
|
-
const formSchemaDynamicFields = templateFormSchema == null ? void 0 : templateFormSchema.dynamicFields;
|
|
10083
|
-
const dynamicFields = ((configDynamicFields == null ? void 0 : configDynamicFields.length) ? configDynamicFields : formSchemaDynamicFields) || [];
|
|
10093
|
+
const dynamicFields = templateConfig.dynamicFields || [];
|
|
10084
10094
|
const mappings = [];
|
|
10085
10095
|
for (const field of dynamicFields) {
|
|
10086
10096
|
if (field.mappings) {
|
|
@@ -10196,6 +10206,54 @@ function flattenAll(nodes) {
|
|
|
10196
10206
|
}
|
|
10197
10207
|
return result;
|
|
10198
10208
|
}
|
|
10209
|
+
function normalizeLayoutModes(config) {
|
|
10210
|
+
function walk(node) {
|
|
10211
|
+
if (node.layoutMode === "stack" || node.layoutMode === "stacked") {
|
|
10212
|
+
node.layoutMode = "vertical-stack";
|
|
10213
|
+
}
|
|
10214
|
+
if (Array.isArray(node.children)) {
|
|
10215
|
+
for (const child of node.children) walk(child);
|
|
10216
|
+
}
|
|
10217
|
+
}
|
|
10218
|
+
for (const page of config.pages ?? []) {
|
|
10219
|
+
if (page.children) {
|
|
10220
|
+
for (const child of page.children) walk(child);
|
|
10221
|
+
}
|
|
10222
|
+
}
|
|
10223
|
+
}
|
|
10224
|
+
function paintRepeatableSections(config, repeatableSections) {
|
|
10225
|
+
const pages = config.pages ?? [];
|
|
10226
|
+
function stripFlags(nodes) {
|
|
10227
|
+
for (const node of nodes) {
|
|
10228
|
+
delete node.repeatableSection;
|
|
10229
|
+
if (Array.isArray(node.children)) stripFlags(node.children);
|
|
10230
|
+
}
|
|
10231
|
+
}
|
|
10232
|
+
for (const page of pages) {
|
|
10233
|
+
if (page.children) stripFlags(page.children);
|
|
10234
|
+
}
|
|
10235
|
+
function setRepeatable(nodes, nodeId, payload) {
|
|
10236
|
+
for (const node of nodes) {
|
|
10237
|
+
const id = node.id;
|
|
10238
|
+
if (id && (id === nodeId || baseId(id) === baseId(nodeId))) {
|
|
10239
|
+
node.repeatableSection = payload;
|
|
10240
|
+
return true;
|
|
10241
|
+
}
|
|
10242
|
+
if (Array.isArray(node.children) && setRepeatable(node.children, nodeId, payload)) {
|
|
10243
|
+
return true;
|
|
10244
|
+
}
|
|
10245
|
+
}
|
|
10246
|
+
return false;
|
|
10247
|
+
}
|
|
10248
|
+
for (const section of repeatableSections) {
|
|
10249
|
+
const payload = { label: section.label };
|
|
10250
|
+
if (section.minEntries !== void 0) payload.minEntries = section.minEntries;
|
|
10251
|
+
if (section.maxEntries !== void 0) payload.maxEntries = section.maxEntries;
|
|
10252
|
+
for (const page of pages) {
|
|
10253
|
+
if (setRepeatable(page.children ?? [], section.nodeId, payload)) break;
|
|
10254
|
+
}
|
|
10255
|
+
}
|
|
10256
|
+
}
|
|
10199
10257
|
function PixldocsPreview(props) {
|
|
10200
10258
|
const {
|
|
10201
10259
|
pageIndex = 0,
|