@pixldocs/canvas-renderer 0.5.86 → 0.5.88
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 +72 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +72 -12
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -10694,6 +10694,7 @@ function flattenSectionStateToFormData(sectionState, sections) {
|
|
|
10694
10694
|
flat[`${sectionPrefix}_${oneBased}_sectionLabel`] = sectionLabel;
|
|
10695
10695
|
flat[`${sectionPrefix}_${oneBased}_label`] = sectionLabel;
|
|
10696
10696
|
for (const f of section.entryFields) {
|
|
10697
|
+
if (f.key === "__entryId" || f.key === "__entryName") continue;
|
|
10697
10698
|
const v = entry[f.key];
|
|
10698
10699
|
if (f.templateKey) {
|
|
10699
10700
|
if (f.type === "list" && Array.isArray(v)) {
|
|
@@ -10742,25 +10743,55 @@ function baseId(id) {
|
|
|
10742
10743
|
const REPEATABLE_KEY_REGEX = /^field_(.+)_(\d+)_(.+)$/;
|
|
10743
10744
|
const NESTED_REPEATABLE_KEY_REGEX = /^field_(.+)_(\d+)_field_(.+)_(\d+)_(.+)$/;
|
|
10744
10745
|
const FORMDEF_CANONICAL_KEY_REGEX = /^field_.+_N_.+$/;
|
|
10745
|
-
function parseEntryRange(range, max) {
|
|
10746
|
+
function parseEntryRange(range, max, entryMeta) {
|
|
10746
10747
|
if (!range || !range.trim()) return null;
|
|
10747
|
-
const
|
|
10748
|
+
const normalizeToken = (value) => {
|
|
10749
|
+
const raw = String(value ?? "").trim().toLowerCase();
|
|
10750
|
+
if (!raw) return [];
|
|
10751
|
+
const slug = raw.replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "");
|
|
10752
|
+
const withoutTrailingS = slug.endsWith("s") ? slug.slice(0, -1) : "";
|
|
10753
|
+
return Array.from(new Set([raw, slug, withoutTrailingS].filter(Boolean)));
|
|
10754
|
+
};
|
|
10755
|
+
const out = [];
|
|
10756
|
+
const seen = /* @__PURE__ */ new Set();
|
|
10757
|
+
const addIndex = (idx) => {
|
|
10758
|
+
if (idx < 1 || idx > max || seen.has(idx)) return;
|
|
10759
|
+
seen.add(idx);
|
|
10760
|
+
out.push(idx);
|
|
10761
|
+
};
|
|
10762
|
+
let sawSelector = false;
|
|
10748
10763
|
for (const partRaw of range.split(",")) {
|
|
10749
10764
|
const part = partRaw.trim();
|
|
10750
10765
|
if (!part) continue;
|
|
10766
|
+
if (part.startsWith("#")) {
|
|
10767
|
+
sawSelector = true;
|
|
10768
|
+
const tokens = normalizeToken(part.slice(1));
|
|
10769
|
+
if (!tokens.length || !(entryMeta == null ? void 0 : entryMeta.length)) continue;
|
|
10770
|
+
for (let i = 0; i < entryMeta.length; i++) {
|
|
10771
|
+
const m2 = entryMeta[i];
|
|
10772
|
+
if (!m2) continue;
|
|
10773
|
+
const candidates = [...normalizeToken(m2.id), ...normalizeToken(m2.name)];
|
|
10774
|
+
if (candidates.some((candidate) => tokens.includes(candidate))) {
|
|
10775
|
+
addIndex(i + 1);
|
|
10776
|
+
}
|
|
10777
|
+
}
|
|
10778
|
+
continue;
|
|
10779
|
+
}
|
|
10751
10780
|
if (/^\d+$/.test(part)) {
|
|
10781
|
+
sawSelector = true;
|
|
10752
10782
|
const n = parseInt(part, 10);
|
|
10753
|
-
|
|
10783
|
+
addIndex(n);
|
|
10754
10784
|
continue;
|
|
10755
10785
|
}
|
|
10756
10786
|
const m = /^(\d*)\s*-\s*(\d*)$/.exec(part);
|
|
10757
10787
|
if (!m) continue;
|
|
10788
|
+
sawSelector = true;
|
|
10758
10789
|
const start = m[1] === "" ? 1 : Math.max(1, parseInt(m[1], 10));
|
|
10759
10790
|
const end = m[2] === "" ? max : Math.min(max, parseInt(m[2], 10));
|
|
10760
|
-
for (let i = start; i <= end; i++)
|
|
10791
|
+
for (let i = start; i <= end; i++) addIndex(i);
|
|
10761
10792
|
}
|
|
10762
|
-
if (out.
|
|
10763
|
-
return
|
|
10793
|
+
if (out.length === 0) return sawSelector ? [] : null;
|
|
10794
|
+
return out;
|
|
10764
10795
|
}
|
|
10765
10796
|
function applyTextCase(text, textCase) {
|
|
10766
10797
|
if (!textCase || textCase === "none") return text;
|
|
@@ -11162,6 +11193,19 @@ function applyFormDataToConfig(config, mappings, formValues, repeatableSectionsF
|
|
|
11162
11193
|
const filter = item == null ? void 0 : item.entryFilter;
|
|
11163
11194
|
return (filter == null ? void 0 : filter.mode) === "range" && ((_a2 = filter.range) == null ? void 0 : _a2.trim()) ? filter : void 0;
|
|
11164
11195
|
};
|
|
11196
|
+
const entryMetaFromList = (baseNodeId) => {
|
|
11197
|
+
const item = repeatableList.find((r) => baseId(r.nodeId) === baseNodeId || r.nodeId === baseNodeId);
|
|
11198
|
+
return item == null ? void 0 : item.entryMeta;
|
|
11199
|
+
};
|
|
11200
|
+
const nestedEntryMetaFromList = (parentBaseNodeId, parentIndex1Based, childBaseNodeId) => {
|
|
11201
|
+
var _a2;
|
|
11202
|
+
for (const { parentBaseId, childBaseId } of getNestedBasePairs(parentBaseNodeId, childBaseNodeId)) {
|
|
11203
|
+
const item = repeatableList.find((r) => baseId(r.nodeId) === childBaseId || r.nodeId === childBaseId);
|
|
11204
|
+
const meta = (_a2 = item == null ? void 0 : item.nestedEntryMeta) == null ? void 0 : _a2[`${parentBaseId}_${parentIndex1Based}_${childBaseId}`];
|
|
11205
|
+
if (meta == null ? void 0 : meta.length) return meta;
|
|
11206
|
+
}
|
|
11207
|
+
return entryMetaFromList(childBaseNodeId);
|
|
11208
|
+
};
|
|
11165
11209
|
const resolvedIdMap = /* @__PURE__ */ new Map();
|
|
11166
11210
|
const addResolved = (key, id) => {
|
|
11167
11211
|
const arr = resolvedIdMap.get(key);
|
|
@@ -11248,8 +11292,8 @@ function applyFormDataToConfig(config, mappings, formValues, repeatableSectionsF
|
|
|
11248
11292
|
const entryFilter = ((_b = node.repeatableSection) == null ? void 0 : _b.entryFilter) ?? entryFilterFromList(baseNodeId);
|
|
11249
11293
|
let entryIndices;
|
|
11250
11294
|
if (entryFilter && entryFilter.mode === "range" && entryFilter.range) {
|
|
11251
|
-
const parsed = parseEntryRange(entryFilter.range, N);
|
|
11252
|
-
entryIndices = parsed
|
|
11295
|
+
const parsed = parseEntryRange(entryFilter.range, N, entryMetaFromList(baseNodeId));
|
|
11296
|
+
entryIndices = parsed ?? Array.from({ length: N }, (_, k) => k + 1);
|
|
11253
11297
|
} else {
|
|
11254
11298
|
entryIndices = Array.from({ length: N }, (_, k) => k + 1);
|
|
11255
11299
|
}
|
|
@@ -11293,8 +11337,8 @@ function applyFormDataToConfig(config, mappings, formValues, repeatableSectionsF
|
|
|
11293
11337
|
const nestedEntryFilter = ((_a2 = node.repeatableSection) == null ? void 0 : _a2.entryFilter) ?? entryFilterFromList(baseNodeId);
|
|
11294
11338
|
let nestedEntryIndices;
|
|
11295
11339
|
if (nestedEntryFilter && nestedEntryFilter.mode === "range" && nestedEntryFilter.range) {
|
|
11296
|
-
const parsed = parseEntryRange(nestedEntryFilter.range, N);
|
|
11297
|
-
nestedEntryIndices = parsed
|
|
11340
|
+
const parsed = parseEntryRange(nestedEntryFilter.range, N, nestedEntryMetaFromList(parentBaseNodeId, parentIndex1Based, baseNodeId));
|
|
11341
|
+
nestedEntryIndices = parsed ?? Array.from({ length: N }, (_, k) => k + 1);
|
|
11298
11342
|
} else {
|
|
11299
11343
|
nestedEntryIndices = Array.from({ length: N }, (_, k) => k + 1);
|
|
11300
11344
|
}
|
|
@@ -12476,12 +12520,28 @@ async function resolveFromForm(options) {
|
|
|
12476
12520
|
const entries = mergedSectionState[s.id] ?? [];
|
|
12477
12521
|
const nodeId = s.treeNodeId ?? s.id;
|
|
12478
12522
|
const schemaRepeatable = repeatableFromSchemaByBase.get(baseId(nodeId));
|
|
12479
|
-
|
|
12523
|
+
const entryMeta = entries.map((e) => ({
|
|
12524
|
+
id: typeof (e == null ? void 0 : e.__entryId) === "string" ? e.__entryId : void 0,
|
|
12525
|
+
name: typeof (e == null ? void 0 : e.__entryName) === "string" ? e.__entryName : void 0
|
|
12526
|
+
}));
|
|
12527
|
+
return { nodeId, label: s.label, entryCount: Math.max(1, entries.length), entryFilter: schemaRepeatable == null ? void 0 : schemaRepeatable.entryFilter, entryMeta };
|
|
12480
12528
|
});
|
|
12481
12529
|
const nestedRepeatables = inferredSections.filter((s) => s.type === "repeatable" && s.parentId != null).map((s) => {
|
|
12482
12530
|
const nodeId = s.treeNodeId ?? s.id;
|
|
12483
12531
|
const schemaRepeatable = repeatableFromSchemaByBase.get(baseId(nodeId));
|
|
12484
|
-
|
|
12532
|
+
const parentId = s.parentId;
|
|
12533
|
+
const parentEntries = mergedSectionState[parentId] ?? [];
|
|
12534
|
+
const merged = [];
|
|
12535
|
+
for (let pi = 0; pi < parentEntries.length; pi++) {
|
|
12536
|
+
const childEntries = mergedSectionState[`${parentId}_${pi}_${s.id}`] ?? [];
|
|
12537
|
+
for (const e of childEntries) {
|
|
12538
|
+
merged.push({
|
|
12539
|
+
id: typeof (e == null ? void 0 : e.__entryId) === "string" ? e.__entryId : void 0,
|
|
12540
|
+
name: typeof (e == null ? void 0 : e.__entryName) === "string" ? e.__entryName : void 0
|
|
12541
|
+
});
|
|
12542
|
+
}
|
|
12543
|
+
}
|
|
12544
|
+
return { nodeId, label: s.label, entryFilter: schemaRepeatable == null ? void 0 : schemaRepeatable.entryFilter, entryMeta: merged };
|
|
12485
12545
|
});
|
|
12486
12546
|
const inferredRepeatableList = [...topLevelRepeatables, ...nestedRepeatables];
|
|
12487
12547
|
const entryCountForLabel = (label) => {
|