@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.js
CHANGED
|
@@ -10726,36 +10726,53 @@ const NESTED_REPEATABLE_KEY_REGEX = /^field_(.+)_(\d+)_field_(.+)_(\d+)_(.+)$/;
|
|
|
10726
10726
|
const FORMDEF_CANONICAL_KEY_REGEX = /^field_.+_N_.+$/;
|
|
10727
10727
|
function parseEntryRange(range, max, entryMeta) {
|
|
10728
10728
|
if (!range || !range.trim()) return null;
|
|
10729
|
-
const
|
|
10729
|
+
const normalizeToken = (value) => {
|
|
10730
|
+
const raw = String(value ?? "").trim().toLowerCase();
|
|
10731
|
+
if (!raw) return [];
|
|
10732
|
+
const slug = raw.replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "");
|
|
10733
|
+
const withoutTrailingS = slug.endsWith("s") ? slug.slice(0, -1) : "";
|
|
10734
|
+
return Array.from(new Set([raw, slug, withoutTrailingS].filter(Boolean)));
|
|
10735
|
+
};
|
|
10736
|
+
const out = [];
|
|
10737
|
+
const seen = /* @__PURE__ */ new Set();
|
|
10738
|
+
const addIndex = (idx) => {
|
|
10739
|
+
if (idx < 1 || idx > max || seen.has(idx)) return;
|
|
10740
|
+
seen.add(idx);
|
|
10741
|
+
out.push(idx);
|
|
10742
|
+
};
|
|
10743
|
+
let sawSelector = false;
|
|
10730
10744
|
for (const partRaw of range.split(",")) {
|
|
10731
10745
|
const part = partRaw.trim();
|
|
10732
10746
|
if (!part) continue;
|
|
10733
10747
|
if (part.startsWith("#")) {
|
|
10734
|
-
|
|
10735
|
-
|
|
10748
|
+
sawSelector = true;
|
|
10749
|
+
const tokens = normalizeToken(part.slice(1));
|
|
10750
|
+
if (!tokens.length || !(entryMeta == null ? void 0 : entryMeta.length)) continue;
|
|
10736
10751
|
for (let i = 0; i < entryMeta.length; i++) {
|
|
10737
10752
|
const m2 = entryMeta[i];
|
|
10738
10753
|
if (!m2) continue;
|
|
10739
|
-
|
|
10740
|
-
|
|
10741
|
-
|
|
10754
|
+
const candidates = [...normalizeToken(m2.id), ...normalizeToken(m2.name)];
|
|
10755
|
+
if (candidates.some((candidate) => tokens.includes(candidate))) {
|
|
10756
|
+
addIndex(i + 1);
|
|
10742
10757
|
}
|
|
10743
10758
|
}
|
|
10744
10759
|
continue;
|
|
10745
10760
|
}
|
|
10746
10761
|
if (/^\d+$/.test(part)) {
|
|
10762
|
+
sawSelector = true;
|
|
10747
10763
|
const n = parseInt(part, 10);
|
|
10748
|
-
|
|
10764
|
+
addIndex(n);
|
|
10749
10765
|
continue;
|
|
10750
10766
|
}
|
|
10751
10767
|
const m = /^(\d*)\s*-\s*(\d*)$/.exec(part);
|
|
10752
10768
|
if (!m) continue;
|
|
10769
|
+
sawSelector = true;
|
|
10753
10770
|
const start = m[1] === "" ? 1 : Math.max(1, parseInt(m[1], 10));
|
|
10754
10771
|
const end = m[2] === "" ? max : Math.min(max, parseInt(m[2], 10));
|
|
10755
|
-
for (let i = start; i <= end; i++)
|
|
10772
|
+
for (let i = start; i <= end; i++) addIndex(i);
|
|
10756
10773
|
}
|
|
10757
|
-
if (out.
|
|
10758
|
-
return
|
|
10774
|
+
if (out.length === 0) return sawSelector ? [] : null;
|
|
10775
|
+
return out;
|
|
10759
10776
|
}
|
|
10760
10777
|
function applyTextCase(text, textCase) {
|
|
10761
10778
|
if (!textCase || textCase === "none") return text;
|
|
@@ -11161,6 +11178,15 @@ function applyFormDataToConfig(config, mappings, formValues, repeatableSectionsF
|
|
|
11161
11178
|
const item = repeatableList.find((r) => baseId(r.nodeId) === baseNodeId || r.nodeId === baseNodeId);
|
|
11162
11179
|
return item == null ? void 0 : item.entryMeta;
|
|
11163
11180
|
};
|
|
11181
|
+
const nestedEntryMetaFromList = (parentBaseNodeId, parentIndex1Based, childBaseNodeId) => {
|
|
11182
|
+
var _a2;
|
|
11183
|
+
for (const { parentBaseId, childBaseId } of getNestedBasePairs(parentBaseNodeId, childBaseNodeId)) {
|
|
11184
|
+
const item = repeatableList.find((r) => baseId(r.nodeId) === childBaseId || r.nodeId === childBaseId);
|
|
11185
|
+
const meta = (_a2 = item == null ? void 0 : item.nestedEntryMeta) == null ? void 0 : _a2[`${parentBaseId}_${parentIndex1Based}_${childBaseId}`];
|
|
11186
|
+
if (meta == null ? void 0 : meta.length) return meta;
|
|
11187
|
+
}
|
|
11188
|
+
return entryMetaFromList(childBaseNodeId);
|
|
11189
|
+
};
|
|
11164
11190
|
const resolvedIdMap = /* @__PURE__ */ new Map();
|
|
11165
11191
|
const addResolved = (key, id) => {
|
|
11166
11192
|
const arr = resolvedIdMap.get(key);
|
|
@@ -11248,7 +11274,7 @@ function applyFormDataToConfig(config, mappings, formValues, repeatableSectionsF
|
|
|
11248
11274
|
let entryIndices;
|
|
11249
11275
|
if (entryFilter && entryFilter.mode === "range" && entryFilter.range) {
|
|
11250
11276
|
const parsed = parseEntryRange(entryFilter.range, N, entryMetaFromList(baseNodeId));
|
|
11251
|
-
entryIndices = parsed
|
|
11277
|
+
entryIndices = parsed ?? Array.from({ length: N }, (_, k) => k + 1);
|
|
11252
11278
|
} else {
|
|
11253
11279
|
entryIndices = Array.from({ length: N }, (_, k) => k + 1);
|
|
11254
11280
|
}
|
|
@@ -11292,8 +11318,8 @@ function applyFormDataToConfig(config, mappings, formValues, repeatableSectionsF
|
|
|
11292
11318
|
const nestedEntryFilter = ((_a2 = node.repeatableSection) == null ? void 0 : _a2.entryFilter) ?? entryFilterFromList(baseNodeId);
|
|
11293
11319
|
let nestedEntryIndices;
|
|
11294
11320
|
if (nestedEntryFilter && nestedEntryFilter.mode === "range" && nestedEntryFilter.range) {
|
|
11295
|
-
const parsed = parseEntryRange(nestedEntryFilter.range, N,
|
|
11296
|
-
nestedEntryIndices = parsed
|
|
11321
|
+
const parsed = parseEntryRange(nestedEntryFilter.range, N, nestedEntryMetaFromList(parentBaseNodeId, parentIndex1Based, baseNodeId));
|
|
11322
|
+
nestedEntryIndices = parsed ?? Array.from({ length: N }, (_, k) => k + 1);
|
|
11297
11323
|
} else {
|
|
11298
11324
|
nestedEntryIndices = Array.from({ length: N }, (_, k) => k + 1);
|
|
11299
11325
|
}
|
|
@@ -12485,18 +12511,21 @@ async function resolveFromForm(options) {
|
|
|
12485
12511
|
const nodeId = s.treeNodeId ?? s.id;
|
|
12486
12512
|
const schemaRepeatable = repeatableFromSchemaByBase.get(baseId(nodeId));
|
|
12487
12513
|
const parentId = s.parentId;
|
|
12514
|
+
const parentSection = inferredSections.find((ps) => ps.id === parentId);
|
|
12515
|
+
const parentNodeId = parentSection ? parentSection.treeNodeId ?? parentSection.id : parentId;
|
|
12488
12516
|
const parentEntries = mergedSectionState[parentId] ?? [];
|
|
12517
|
+
const nestedEntryMeta = {};
|
|
12489
12518
|
const merged = [];
|
|
12490
12519
|
for (let pi = 0; pi < parentEntries.length; pi++) {
|
|
12491
12520
|
const childEntries = mergedSectionState[`${parentId}_${pi}_${s.id}`] ?? [];
|
|
12492
|
-
|
|
12493
|
-
|
|
12494
|
-
|
|
12495
|
-
|
|
12496
|
-
|
|
12497
|
-
|
|
12521
|
+
const meta = childEntries.map((e) => ({
|
|
12522
|
+
id: typeof (e == null ? void 0 : e.__entryId) === "string" ? e.__entryId : void 0,
|
|
12523
|
+
name: typeof (e == null ? void 0 : e.__entryName) === "string" ? e.__entryName : void 0
|
|
12524
|
+
}));
|
|
12525
|
+
nestedEntryMeta[`${baseId(parentNodeId)}_${pi + 1}_${baseId(nodeId)}`] = meta;
|
|
12526
|
+
merged.push(...meta);
|
|
12498
12527
|
}
|
|
12499
|
-
return { nodeId, label: s.label, entryFilter: schemaRepeatable == null ? void 0 : schemaRepeatable.entryFilter, entryMeta: merged };
|
|
12528
|
+
return { nodeId, label: s.label, entryFilter: schemaRepeatable == null ? void 0 : schemaRepeatable.entryFilter, entryMeta: merged, nestedEntryMeta };
|
|
12500
12529
|
});
|
|
12501
12530
|
const inferredRepeatableList = [...topLevelRepeatables, ...nestedRepeatables];
|
|
12502
12531
|
const entryCountForLabel = (label) => {
|