@pixldocs/canvas-renderer 0.5.87 → 0.5.89
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 +49 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +49 -20
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -10745,36 +10745,53 @@ const NESTED_REPEATABLE_KEY_REGEX = /^field_(.+)_(\d+)_field_(.+)_(\d+)_(.+)$/;
|
|
|
10745
10745
|
const FORMDEF_CANONICAL_KEY_REGEX = /^field_.+_N_.+$/;
|
|
10746
10746
|
function parseEntryRange(range, max, entryMeta) {
|
|
10747
10747
|
if (!range || !range.trim()) return null;
|
|
10748
|
-
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;
|
|
10749
10763
|
for (const partRaw of range.split(",")) {
|
|
10750
10764
|
const part = partRaw.trim();
|
|
10751
10765
|
if (!part) continue;
|
|
10752
10766
|
if (part.startsWith("#")) {
|
|
10753
|
-
|
|
10754
|
-
|
|
10767
|
+
sawSelector = true;
|
|
10768
|
+
const tokens = normalizeToken(part.slice(1));
|
|
10769
|
+
if (!tokens.length || !(entryMeta == null ? void 0 : entryMeta.length)) continue;
|
|
10755
10770
|
for (let i = 0; i < entryMeta.length; i++) {
|
|
10756
10771
|
const m2 = entryMeta[i];
|
|
10757
10772
|
if (!m2) continue;
|
|
10758
|
-
|
|
10759
|
-
|
|
10760
|
-
|
|
10773
|
+
const candidates = [...normalizeToken(m2.id), ...normalizeToken(m2.name)];
|
|
10774
|
+
if (candidates.some((candidate) => tokens.includes(candidate))) {
|
|
10775
|
+
addIndex(i + 1);
|
|
10761
10776
|
}
|
|
10762
10777
|
}
|
|
10763
10778
|
continue;
|
|
10764
10779
|
}
|
|
10765
10780
|
if (/^\d+$/.test(part)) {
|
|
10781
|
+
sawSelector = true;
|
|
10766
10782
|
const n = parseInt(part, 10);
|
|
10767
|
-
|
|
10783
|
+
addIndex(n);
|
|
10768
10784
|
continue;
|
|
10769
10785
|
}
|
|
10770
10786
|
const m = /^(\d*)\s*-\s*(\d*)$/.exec(part);
|
|
10771
10787
|
if (!m) continue;
|
|
10788
|
+
sawSelector = true;
|
|
10772
10789
|
const start = m[1] === "" ? 1 : Math.max(1, parseInt(m[1], 10));
|
|
10773
10790
|
const end = m[2] === "" ? max : Math.min(max, parseInt(m[2], 10));
|
|
10774
|
-
for (let i = start; i <= end; i++)
|
|
10791
|
+
for (let i = start; i <= end; i++) addIndex(i);
|
|
10775
10792
|
}
|
|
10776
|
-
if (out.
|
|
10777
|
-
return
|
|
10793
|
+
if (out.length === 0) return sawSelector ? [] : null;
|
|
10794
|
+
return out;
|
|
10778
10795
|
}
|
|
10779
10796
|
function applyTextCase(text, textCase) {
|
|
10780
10797
|
if (!textCase || textCase === "none") return text;
|
|
@@ -11180,6 +11197,15 @@ function applyFormDataToConfig(config, mappings, formValues, repeatableSectionsF
|
|
|
11180
11197
|
const item = repeatableList.find((r) => baseId(r.nodeId) === baseNodeId || r.nodeId === baseNodeId);
|
|
11181
11198
|
return item == null ? void 0 : item.entryMeta;
|
|
11182
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
|
+
};
|
|
11183
11209
|
const resolvedIdMap = /* @__PURE__ */ new Map();
|
|
11184
11210
|
const addResolved = (key, id) => {
|
|
11185
11211
|
const arr = resolvedIdMap.get(key);
|
|
@@ -11267,7 +11293,7 @@ function applyFormDataToConfig(config, mappings, formValues, repeatableSectionsF
|
|
|
11267
11293
|
let entryIndices;
|
|
11268
11294
|
if (entryFilter && entryFilter.mode === "range" && entryFilter.range) {
|
|
11269
11295
|
const parsed = parseEntryRange(entryFilter.range, N, entryMetaFromList(baseNodeId));
|
|
11270
|
-
entryIndices = parsed
|
|
11296
|
+
entryIndices = parsed ?? Array.from({ length: N }, (_, k) => k + 1);
|
|
11271
11297
|
} else {
|
|
11272
11298
|
entryIndices = Array.from({ length: N }, (_, k) => k + 1);
|
|
11273
11299
|
}
|
|
@@ -11311,8 +11337,8 @@ function applyFormDataToConfig(config, mappings, formValues, repeatableSectionsF
|
|
|
11311
11337
|
const nestedEntryFilter = ((_a2 = node.repeatableSection) == null ? void 0 : _a2.entryFilter) ?? entryFilterFromList(baseNodeId);
|
|
11312
11338
|
let nestedEntryIndices;
|
|
11313
11339
|
if (nestedEntryFilter && nestedEntryFilter.mode === "range" && nestedEntryFilter.range) {
|
|
11314
|
-
const parsed = parseEntryRange(nestedEntryFilter.range, N,
|
|
11315
|
-
nestedEntryIndices = parsed
|
|
11340
|
+
const parsed = parseEntryRange(nestedEntryFilter.range, N, nestedEntryMetaFromList(parentBaseNodeId, parentIndex1Based, baseNodeId));
|
|
11341
|
+
nestedEntryIndices = parsed ?? Array.from({ length: N }, (_, k) => k + 1);
|
|
11316
11342
|
} else {
|
|
11317
11343
|
nestedEntryIndices = Array.from({ length: N }, (_, k) => k + 1);
|
|
11318
11344
|
}
|
|
@@ -12504,18 +12530,21 @@ async function resolveFromForm(options) {
|
|
|
12504
12530
|
const nodeId = s.treeNodeId ?? s.id;
|
|
12505
12531
|
const schemaRepeatable = repeatableFromSchemaByBase.get(baseId(nodeId));
|
|
12506
12532
|
const parentId = s.parentId;
|
|
12533
|
+
const parentSection = inferredSections.find((ps) => ps.id === parentId);
|
|
12534
|
+
const parentNodeId = parentSection ? parentSection.treeNodeId ?? parentSection.id : parentId;
|
|
12507
12535
|
const parentEntries = mergedSectionState[parentId] ?? [];
|
|
12536
|
+
const nestedEntryMeta = {};
|
|
12508
12537
|
const merged = [];
|
|
12509
12538
|
for (let pi = 0; pi < parentEntries.length; pi++) {
|
|
12510
12539
|
const childEntries = mergedSectionState[`${parentId}_${pi}_${s.id}`] ?? [];
|
|
12511
|
-
|
|
12512
|
-
|
|
12513
|
-
|
|
12514
|
-
|
|
12515
|
-
|
|
12516
|
-
|
|
12540
|
+
const meta = childEntries.map((e) => ({
|
|
12541
|
+
id: typeof (e == null ? void 0 : e.__entryId) === "string" ? e.__entryId : void 0,
|
|
12542
|
+
name: typeof (e == null ? void 0 : e.__entryName) === "string" ? e.__entryName : void 0
|
|
12543
|
+
}));
|
|
12544
|
+
nestedEntryMeta[`${baseId(parentNodeId)}_${pi + 1}_${baseId(nodeId)}`] = meta;
|
|
12545
|
+
merged.push(...meta);
|
|
12517
12546
|
}
|
|
12518
|
-
return { nodeId, label: s.label, entryFilter: schemaRepeatable == null ? void 0 : schemaRepeatable.entryFilter, entryMeta: merged };
|
|
12547
|
+
return { nodeId, label: s.label, entryFilter: schemaRepeatable == null ? void 0 : schemaRepeatable.entryFilter, entryMeta: merged, nestedEntryMeta };
|
|
12519
12548
|
});
|
|
12520
12549
|
const inferredRepeatableList = [...topLevelRepeatables, ...nestedRepeatables];
|
|
12521
12550
|
const entryCountForLabel = (label) => {
|