@pixldocs/canvas-renderer 0.3.7 → 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 +75 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +75 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9001,8 +9001,19 @@ function flattenSectionStateToFormData(sectionState, sections) {
|
|
|
9001
9001
|
for (const child of children) {
|
|
9002
9002
|
const childToken = child.templateKeyPrefix.startsWith("field_") ? child.templateKeyPrefix.slice(6) : child.templateKeyPrefix;
|
|
9003
9003
|
const childStateKey = `${sectionStateKey}_${i}_${child.id}`;
|
|
9004
|
-
const
|
|
9005
|
-
emitRepeatable(child, childStateKey,
|
|
9004
|
+
const compactPrefix = `${sectionPrefix}_${oneBased}_${childToken}`;
|
|
9005
|
+
emitRepeatable(child, childStateKey, compactPrefix);
|
|
9006
|
+
const aliasPrefix = `${sectionPrefix}_${oneBased}_field_${childToken}`;
|
|
9007
|
+
if (aliasPrefix !== compactPrefix) {
|
|
9008
|
+
emitRepeatable(child, childStateKey, aliasPrefix);
|
|
9009
|
+
}
|
|
9010
|
+
const childIdToken = child.id;
|
|
9011
|
+
if (childIdToken !== childToken) {
|
|
9012
|
+
const idPrefix2 = `${sectionPrefix}_${oneBased}_${childIdToken}`;
|
|
9013
|
+
emitRepeatable(child, childStateKey, idPrefix2);
|
|
9014
|
+
const idAliasPrefix = `${sectionPrefix}_${oneBased}_field_${childIdToken}`;
|
|
9015
|
+
emitRepeatable(child, childStateKey, idAliasPrefix);
|
|
9016
|
+
}
|
|
9006
9017
|
}
|
|
9007
9018
|
}
|
|
9008
9019
|
};
|
|
@@ -10034,8 +10045,20 @@ async function resolveFromForm(options) {
|
|
|
10034
10045
|
]);
|
|
10035
10046
|
const templateConfig = templateRow.config;
|
|
10036
10047
|
const templateFormSchema = templateRow.form_schema;
|
|
10037
|
-
|
|
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);
|
|
10038
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;
|
|
10039
10062
|
const repeatableNodeMap = /* @__PURE__ */ new Map();
|
|
10040
10063
|
if (repeatableFromSchema) {
|
|
10041
10064
|
for (const r of repeatableFromSchema) {
|
|
@@ -10067,9 +10090,7 @@ async function resolveFromForm(options) {
|
|
|
10067
10090
|
}
|
|
10068
10091
|
}
|
|
10069
10092
|
const flatFormData = flattenSectionStateToFormData(mergedSectionState, inferredSections);
|
|
10070
|
-
const
|
|
10071
|
-
const formSchemaDynamicFields = templateFormSchema == null ? void 0 : templateFormSchema.dynamicFields;
|
|
10072
|
-
const dynamicFields = ((configDynamicFields == null ? void 0 : configDynamicFields.length) ? configDynamicFields : formSchemaDynamicFields) || [];
|
|
10093
|
+
const dynamicFields = templateConfig.dynamicFields || [];
|
|
10073
10094
|
const mappings = [];
|
|
10074
10095
|
for (const field of dynamicFields) {
|
|
10075
10096
|
if (field.mappings) {
|
|
@@ -10185,6 +10206,54 @@ function flattenAll(nodes) {
|
|
|
10185
10206
|
}
|
|
10186
10207
|
return result;
|
|
10187
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
|
+
}
|
|
10188
10257
|
function PixldocsPreview(props) {
|
|
10189
10258
|
const {
|
|
10190
10259
|
pageIndex = 0,
|