@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.js
CHANGED
|
@@ -10675,6 +10675,7 @@ function flattenSectionStateToFormData(sectionState, sections) {
|
|
|
10675
10675
|
flat[`${sectionPrefix}_${oneBased}_sectionLabel`] = sectionLabel;
|
|
10676
10676
|
flat[`${sectionPrefix}_${oneBased}_label`] = sectionLabel;
|
|
10677
10677
|
for (const f of section.entryFields) {
|
|
10678
|
+
if (f.key === "__entryId" || f.key === "__entryName") continue;
|
|
10678
10679
|
const v = entry[f.key];
|
|
10679
10680
|
if (f.templateKey) {
|
|
10680
10681
|
if (f.type === "list" && Array.isArray(v)) {
|
|
@@ -10723,25 +10724,55 @@ function baseId(id) {
|
|
|
10723
10724
|
const REPEATABLE_KEY_REGEX = /^field_(.+)_(\d+)_(.+)$/;
|
|
10724
10725
|
const NESTED_REPEATABLE_KEY_REGEX = /^field_(.+)_(\d+)_field_(.+)_(\d+)_(.+)$/;
|
|
10725
10726
|
const FORMDEF_CANONICAL_KEY_REGEX = /^field_.+_N_.+$/;
|
|
10726
|
-
function parseEntryRange(range, max) {
|
|
10727
|
+
function parseEntryRange(range, max, entryMeta) {
|
|
10727
10728
|
if (!range || !range.trim()) return null;
|
|
10728
|
-
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;
|
|
10729
10744
|
for (const partRaw of range.split(",")) {
|
|
10730
10745
|
const part = partRaw.trim();
|
|
10731
10746
|
if (!part) continue;
|
|
10747
|
+
if (part.startsWith("#")) {
|
|
10748
|
+
sawSelector = true;
|
|
10749
|
+
const tokens = normalizeToken(part.slice(1));
|
|
10750
|
+
if (!tokens.length || !(entryMeta == null ? void 0 : entryMeta.length)) continue;
|
|
10751
|
+
for (let i = 0; i < entryMeta.length; i++) {
|
|
10752
|
+
const m2 = entryMeta[i];
|
|
10753
|
+
if (!m2) continue;
|
|
10754
|
+
const candidates = [...normalizeToken(m2.id), ...normalizeToken(m2.name)];
|
|
10755
|
+
if (candidates.some((candidate) => tokens.includes(candidate))) {
|
|
10756
|
+
addIndex(i + 1);
|
|
10757
|
+
}
|
|
10758
|
+
}
|
|
10759
|
+
continue;
|
|
10760
|
+
}
|
|
10732
10761
|
if (/^\d+$/.test(part)) {
|
|
10762
|
+
sawSelector = true;
|
|
10733
10763
|
const n = parseInt(part, 10);
|
|
10734
|
-
|
|
10764
|
+
addIndex(n);
|
|
10735
10765
|
continue;
|
|
10736
10766
|
}
|
|
10737
10767
|
const m = /^(\d*)\s*-\s*(\d*)$/.exec(part);
|
|
10738
10768
|
if (!m) continue;
|
|
10769
|
+
sawSelector = true;
|
|
10739
10770
|
const start = m[1] === "" ? 1 : Math.max(1, parseInt(m[1], 10));
|
|
10740
10771
|
const end = m[2] === "" ? max : Math.min(max, parseInt(m[2], 10));
|
|
10741
|
-
for (let i = start; i <= end; i++)
|
|
10772
|
+
for (let i = start; i <= end; i++) addIndex(i);
|
|
10742
10773
|
}
|
|
10743
|
-
if (out.
|
|
10744
|
-
return
|
|
10774
|
+
if (out.length === 0) return sawSelector ? [] : null;
|
|
10775
|
+
return out;
|
|
10745
10776
|
}
|
|
10746
10777
|
function applyTextCase(text, textCase) {
|
|
10747
10778
|
if (!textCase || textCase === "none") return text;
|
|
@@ -11143,6 +11174,19 @@ function applyFormDataToConfig(config, mappings, formValues, repeatableSectionsF
|
|
|
11143
11174
|
const filter = item == null ? void 0 : item.entryFilter;
|
|
11144
11175
|
return (filter == null ? void 0 : filter.mode) === "range" && ((_a2 = filter.range) == null ? void 0 : _a2.trim()) ? filter : void 0;
|
|
11145
11176
|
};
|
|
11177
|
+
const entryMetaFromList = (baseNodeId) => {
|
|
11178
|
+
const item = repeatableList.find((r) => baseId(r.nodeId) === baseNodeId || r.nodeId === baseNodeId);
|
|
11179
|
+
return item == null ? void 0 : item.entryMeta;
|
|
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
|
+
};
|
|
11146
11190
|
const resolvedIdMap = /* @__PURE__ */ new Map();
|
|
11147
11191
|
const addResolved = (key, id) => {
|
|
11148
11192
|
const arr = resolvedIdMap.get(key);
|
|
@@ -11229,8 +11273,8 @@ function applyFormDataToConfig(config, mappings, formValues, repeatableSectionsF
|
|
|
11229
11273
|
const entryFilter = ((_b = node.repeatableSection) == null ? void 0 : _b.entryFilter) ?? entryFilterFromList(baseNodeId);
|
|
11230
11274
|
let entryIndices;
|
|
11231
11275
|
if (entryFilter && entryFilter.mode === "range" && entryFilter.range) {
|
|
11232
|
-
const parsed = parseEntryRange(entryFilter.range, N);
|
|
11233
|
-
entryIndices = parsed
|
|
11276
|
+
const parsed = parseEntryRange(entryFilter.range, N, entryMetaFromList(baseNodeId));
|
|
11277
|
+
entryIndices = parsed ?? Array.from({ length: N }, (_, k) => k + 1);
|
|
11234
11278
|
} else {
|
|
11235
11279
|
entryIndices = Array.from({ length: N }, (_, k) => k + 1);
|
|
11236
11280
|
}
|
|
@@ -11274,8 +11318,8 @@ function applyFormDataToConfig(config, mappings, formValues, repeatableSectionsF
|
|
|
11274
11318
|
const nestedEntryFilter = ((_a2 = node.repeatableSection) == null ? void 0 : _a2.entryFilter) ?? entryFilterFromList(baseNodeId);
|
|
11275
11319
|
let nestedEntryIndices;
|
|
11276
11320
|
if (nestedEntryFilter && nestedEntryFilter.mode === "range" && nestedEntryFilter.range) {
|
|
11277
|
-
const parsed = parseEntryRange(nestedEntryFilter.range, N);
|
|
11278
|
-
nestedEntryIndices = parsed
|
|
11321
|
+
const parsed = parseEntryRange(nestedEntryFilter.range, N, nestedEntryMetaFromList(parentBaseNodeId, parentIndex1Based, baseNodeId));
|
|
11322
|
+
nestedEntryIndices = parsed ?? Array.from({ length: N }, (_, k) => k + 1);
|
|
11279
11323
|
} else {
|
|
11280
11324
|
nestedEntryIndices = Array.from({ length: N }, (_, k) => k + 1);
|
|
11281
11325
|
}
|
|
@@ -12457,12 +12501,28 @@ async function resolveFromForm(options) {
|
|
|
12457
12501
|
const entries = mergedSectionState[s.id] ?? [];
|
|
12458
12502
|
const nodeId = s.treeNodeId ?? s.id;
|
|
12459
12503
|
const schemaRepeatable = repeatableFromSchemaByBase.get(baseId(nodeId));
|
|
12460
|
-
|
|
12504
|
+
const entryMeta = entries.map((e) => ({
|
|
12505
|
+
id: typeof (e == null ? void 0 : e.__entryId) === "string" ? e.__entryId : void 0,
|
|
12506
|
+
name: typeof (e == null ? void 0 : e.__entryName) === "string" ? e.__entryName : void 0
|
|
12507
|
+
}));
|
|
12508
|
+
return { nodeId, label: s.label, entryCount: Math.max(1, entries.length), entryFilter: schemaRepeatable == null ? void 0 : schemaRepeatable.entryFilter, entryMeta };
|
|
12461
12509
|
});
|
|
12462
12510
|
const nestedRepeatables = inferredSections.filter((s) => s.type === "repeatable" && s.parentId != null).map((s) => {
|
|
12463
12511
|
const nodeId = s.treeNodeId ?? s.id;
|
|
12464
12512
|
const schemaRepeatable = repeatableFromSchemaByBase.get(baseId(nodeId));
|
|
12465
|
-
|
|
12513
|
+
const parentId = s.parentId;
|
|
12514
|
+
const parentEntries = mergedSectionState[parentId] ?? [];
|
|
12515
|
+
const merged = [];
|
|
12516
|
+
for (let pi = 0; pi < parentEntries.length; pi++) {
|
|
12517
|
+
const childEntries = mergedSectionState[`${parentId}_${pi}_${s.id}`] ?? [];
|
|
12518
|
+
for (const e of childEntries) {
|
|
12519
|
+
merged.push({
|
|
12520
|
+
id: typeof (e == null ? void 0 : e.__entryId) === "string" ? e.__entryId : void 0,
|
|
12521
|
+
name: typeof (e == null ? void 0 : e.__entryName) === "string" ? e.__entryName : void 0
|
|
12522
|
+
});
|
|
12523
|
+
}
|
|
12524
|
+
}
|
|
12525
|
+
return { nodeId, label: s.label, entryFilter: schemaRepeatable == null ? void 0 : schemaRepeatable.entryFilter, entryMeta: merged };
|
|
12466
12526
|
});
|
|
12467
12527
|
const inferredRepeatableList = [...topLevelRepeatables, ...nestedRepeatables];
|
|
12468
12528
|
const entryCountForLabel = (label) => {
|