@pixldocs/canvas-renderer 0.5.85 → 0.5.87
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 +73 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +73 -8
- 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,12 +10743,25 @@ 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
10748
|
const out = /* @__PURE__ */ new Set();
|
|
10748
10749
|
for (const partRaw of range.split(",")) {
|
|
10749
10750
|
const part = partRaw.trim();
|
|
10750
10751
|
if (!part) continue;
|
|
10752
|
+
if (part.startsWith("#")) {
|
|
10753
|
+
const token = part.slice(1).trim().toLowerCase();
|
|
10754
|
+
if (!token || !(entryMeta == null ? void 0 : entryMeta.length)) continue;
|
|
10755
|
+
for (let i = 0; i < entryMeta.length; i++) {
|
|
10756
|
+
const m2 = entryMeta[i];
|
|
10757
|
+
if (!m2) continue;
|
|
10758
|
+
if (m2.id && m2.id.toLowerCase() === token || m2.name && m2.name.toLowerCase() === token) {
|
|
10759
|
+
const idx = i + 1;
|
|
10760
|
+
if (idx >= 1 && idx <= max) out.add(idx);
|
|
10761
|
+
}
|
|
10762
|
+
}
|
|
10763
|
+
continue;
|
|
10764
|
+
}
|
|
10751
10765
|
if (/^\d+$/.test(part)) {
|
|
10752
10766
|
const n = parseInt(part, 10);
|
|
10753
10767
|
if (n >= 1 && n <= max) out.add(n);
|
|
@@ -11162,6 +11176,10 @@ function applyFormDataToConfig(config, mappings, formValues, repeatableSectionsF
|
|
|
11162
11176
|
const filter = item == null ? void 0 : item.entryFilter;
|
|
11163
11177
|
return (filter == null ? void 0 : filter.mode) === "range" && ((_a2 = filter.range) == null ? void 0 : _a2.trim()) ? filter : void 0;
|
|
11164
11178
|
};
|
|
11179
|
+
const entryMetaFromList = (baseNodeId) => {
|
|
11180
|
+
const item = repeatableList.find((r) => baseId(r.nodeId) === baseNodeId || r.nodeId === baseNodeId);
|
|
11181
|
+
return item == null ? void 0 : item.entryMeta;
|
|
11182
|
+
};
|
|
11165
11183
|
const resolvedIdMap = /* @__PURE__ */ new Map();
|
|
11166
11184
|
const addResolved = (key, id) => {
|
|
11167
11185
|
const arr = resolvedIdMap.get(key);
|
|
@@ -11248,7 +11266,7 @@ function applyFormDataToConfig(config, mappings, formValues, repeatableSectionsF
|
|
|
11248
11266
|
const entryFilter = ((_b = node.repeatableSection) == null ? void 0 : _b.entryFilter) ?? entryFilterFromList(baseNodeId);
|
|
11249
11267
|
let entryIndices;
|
|
11250
11268
|
if (entryFilter && entryFilter.mode === "range" && entryFilter.range) {
|
|
11251
|
-
const parsed = parseEntryRange(entryFilter.range, N);
|
|
11269
|
+
const parsed = parseEntryRange(entryFilter.range, N, entryMetaFromList(baseNodeId));
|
|
11252
11270
|
entryIndices = parsed && parsed.length ? parsed : Array.from({ length: N }, (_, k) => k + 1);
|
|
11253
11271
|
} else {
|
|
11254
11272
|
entryIndices = Array.from({ length: N }, (_, k) => k + 1);
|
|
@@ -11293,7 +11311,7 @@ function applyFormDataToConfig(config, mappings, formValues, repeatableSectionsF
|
|
|
11293
11311
|
const nestedEntryFilter = ((_a2 = node.repeatableSection) == null ? void 0 : _a2.entryFilter) ?? entryFilterFromList(baseNodeId);
|
|
11294
11312
|
let nestedEntryIndices;
|
|
11295
11313
|
if (nestedEntryFilter && nestedEntryFilter.mode === "range" && nestedEntryFilter.range) {
|
|
11296
|
-
const parsed = parseEntryRange(nestedEntryFilter.range, N);
|
|
11314
|
+
const parsed = parseEntryRange(nestedEntryFilter.range, N, entryMetaFromList(baseNodeId));
|
|
11297
11315
|
nestedEntryIndices = parsed && parsed.length ? parsed : Array.from({ length: N }, (_, k) => k + 1);
|
|
11298
11316
|
} else {
|
|
11299
11317
|
nestedEntryIndices = Array.from({ length: N }, (_, k) => k + 1);
|
|
@@ -12345,7 +12363,8 @@ async function resolveTemplateData(options) {
|
|
|
12345
12363
|
nodeId: r.nodeId,
|
|
12346
12364
|
label: r.label,
|
|
12347
12365
|
minEntries: r.minEntries,
|
|
12348
|
-
maxEntries: r.maxEntries
|
|
12366
|
+
maxEntries: r.maxEntries,
|
|
12367
|
+
entryFilter: r.entryFilter
|
|
12349
12368
|
});
|
|
12350
12369
|
}
|
|
12351
12370
|
}
|
|
@@ -12468,13 +12487,58 @@ async function resolveFromForm(options) {
|
|
|
12468
12487
|
}
|
|
12469
12488
|
}
|
|
12470
12489
|
}
|
|
12490
|
+
const repeatableFromSchemaByBase = new Map(
|
|
12491
|
+
(repeatableFromSchema ?? []).map((r) => [baseId(r.nodeId), r])
|
|
12492
|
+
);
|
|
12471
12493
|
const topLevelRepeatables = inferredSections.filter((s) => s.type === "repeatable" && !s.parentId).map((s) => {
|
|
12472
12494
|
const entries = mergedSectionState[s.id] ?? [];
|
|
12473
12495
|
const nodeId = s.treeNodeId ?? s.id;
|
|
12474
|
-
|
|
12496
|
+
const schemaRepeatable = repeatableFromSchemaByBase.get(baseId(nodeId));
|
|
12497
|
+
const entryMeta = entries.map((e) => ({
|
|
12498
|
+
id: typeof (e == null ? void 0 : e.__entryId) === "string" ? e.__entryId : void 0,
|
|
12499
|
+
name: typeof (e == null ? void 0 : e.__entryName) === "string" ? e.__entryName : void 0
|
|
12500
|
+
}));
|
|
12501
|
+
return { nodeId, label: s.label, entryCount: Math.max(1, entries.length), entryFilter: schemaRepeatable == null ? void 0 : schemaRepeatable.entryFilter, entryMeta };
|
|
12502
|
+
});
|
|
12503
|
+
const nestedRepeatables = inferredSections.filter((s) => s.type === "repeatable" && s.parentId != null).map((s) => {
|
|
12504
|
+
const nodeId = s.treeNodeId ?? s.id;
|
|
12505
|
+
const schemaRepeatable = repeatableFromSchemaByBase.get(baseId(nodeId));
|
|
12506
|
+
const parentId = s.parentId;
|
|
12507
|
+
const parentEntries = mergedSectionState[parentId] ?? [];
|
|
12508
|
+
const merged = [];
|
|
12509
|
+
for (let pi = 0; pi < parentEntries.length; pi++) {
|
|
12510
|
+
const childEntries = mergedSectionState[`${parentId}_${pi}_${s.id}`] ?? [];
|
|
12511
|
+
for (const e of childEntries) {
|
|
12512
|
+
merged.push({
|
|
12513
|
+
id: typeof (e == null ? void 0 : e.__entryId) === "string" ? e.__entryId : void 0,
|
|
12514
|
+
name: typeof (e == null ? void 0 : e.__entryName) === "string" ? e.__entryName : void 0
|
|
12515
|
+
});
|
|
12516
|
+
}
|
|
12517
|
+
}
|
|
12518
|
+
return { nodeId, label: s.label, entryFilter: schemaRepeatable == null ? void 0 : schemaRepeatable.entryFilter, entryMeta: merged };
|
|
12475
12519
|
});
|
|
12476
|
-
const
|
|
12477
|
-
const
|
|
12520
|
+
const inferredRepeatableList = [...topLevelRepeatables, ...nestedRepeatables];
|
|
12521
|
+
const entryCountForLabel = (label) => {
|
|
12522
|
+
const normalized = label.trim().toLowerCase();
|
|
12523
|
+
for (const item of inferredRepeatableList) {
|
|
12524
|
+
if (item.label.trim().toLowerCase() !== normalized) continue;
|
|
12525
|
+
const count = item.entryCount;
|
|
12526
|
+
if (typeof count === "number") return count;
|
|
12527
|
+
}
|
|
12528
|
+
return void 0;
|
|
12529
|
+
};
|
|
12530
|
+
const fallbackRepeatableList = (repeatableFromSchema ?? []).map((r) => ({
|
|
12531
|
+
nodeId: r.nodeId,
|
|
12532
|
+
label: r.label,
|
|
12533
|
+
entryFilter: r.entryFilter,
|
|
12534
|
+
entryCount: entryCountForLabel(r.label)
|
|
12535
|
+
}));
|
|
12536
|
+
const repeatableList = inferredRepeatableList.length > 0 ? [
|
|
12537
|
+
...inferredRepeatableList,
|
|
12538
|
+
...fallbackRepeatableList.filter(
|
|
12539
|
+
(fallback) => !inferredRepeatableList.some((r) => baseId(r.nodeId) === baseId(fallback.nodeId))
|
|
12540
|
+
)
|
|
12541
|
+
] : fallbackRepeatableList;
|
|
12478
12542
|
const repeatableNestedEntryCounts = {};
|
|
12479
12543
|
for (const s of inferredSections) {
|
|
12480
12544
|
if (s.type !== "repeatable") continue;
|
|
@@ -12692,6 +12756,7 @@ function paintRepeatableSections(config, repeatableSections) {
|
|
|
12692
12756
|
const payload = { label: section.label };
|
|
12693
12757
|
if (section.minEntries !== void 0) payload.minEntries = section.minEntries;
|
|
12694
12758
|
if (section.maxEntries !== void 0) payload.maxEntries = section.maxEntries;
|
|
12759
|
+
if (section.entryFilter !== void 0) payload.entryFilter = section.entryFilter;
|
|
12695
12760
|
for (const page of pages) {
|
|
12696
12761
|
if (setRepeatable(page.children ?? [], section.nodeId, payload)) break;
|
|
12697
12762
|
}
|
|
@@ -12887,7 +12952,7 @@ function PixldocsPreview(props) {
|
|
|
12887
12952
|
!canvasSettled && /* @__PURE__ */ jsxRuntime.jsx("div", { style: { position: "absolute", inset: 0, display: "flex", alignItems: "center", justifyContent: "center", minHeight: 200 }, children: /* @__PURE__ */ jsxRuntime.jsx("div", { style: { color: "#888", fontSize: 14 }, children: "Loading preview..." }) })
|
|
12888
12953
|
] });
|
|
12889
12954
|
}
|
|
12890
|
-
const PACKAGE_VERSION = "0.5.
|
|
12955
|
+
const PACKAGE_VERSION = "0.5.86";
|
|
12891
12956
|
const roundParityValue = (value) => {
|
|
12892
12957
|
if (typeof value !== "number") return value;
|
|
12893
12958
|
return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
|