@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.d.ts
CHANGED
|
@@ -256,7 +256,7 @@ export declare function normalizeFontFamily(fontStack: string): string;
|
|
|
256
256
|
* Package version banner. Bump alongside package.json so we can confirm
|
|
257
257
|
* (via browser:log) that the deployed bundle matches the expected build.
|
|
258
258
|
*/
|
|
259
|
-
export declare const PACKAGE_VERSION = "0.5.
|
|
259
|
+
export declare const PACKAGE_VERSION = "0.5.86";
|
|
260
260
|
|
|
261
261
|
export declare interface PageSettings {
|
|
262
262
|
backgroundColor?: string;
|
|
@@ -584,6 +584,10 @@ export declare interface ResolveFromFormOptions {
|
|
|
584
584
|
label: string;
|
|
585
585
|
minEntries?: number;
|
|
586
586
|
maxEntries?: number;
|
|
587
|
+
entryFilter?: {
|
|
588
|
+
mode: 'all' | 'range';
|
|
589
|
+
range?: string;
|
|
590
|
+
};
|
|
587
591
|
}[];
|
|
588
592
|
repeatablePages?: unknown[];
|
|
589
593
|
dynamicFields?: DynamicField[];
|
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,12 +10724,25 @@ 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
10729
|
const out = /* @__PURE__ */ new Set();
|
|
10729
10730
|
for (const partRaw of range.split(",")) {
|
|
10730
10731
|
const part = partRaw.trim();
|
|
10731
10732
|
if (!part) continue;
|
|
10733
|
+
if (part.startsWith("#")) {
|
|
10734
|
+
const token = part.slice(1).trim().toLowerCase();
|
|
10735
|
+
if (!token || !(entryMeta == null ? void 0 : entryMeta.length)) continue;
|
|
10736
|
+
for (let i = 0; i < entryMeta.length; i++) {
|
|
10737
|
+
const m2 = entryMeta[i];
|
|
10738
|
+
if (!m2) continue;
|
|
10739
|
+
if (m2.id && m2.id.toLowerCase() === token || m2.name && m2.name.toLowerCase() === token) {
|
|
10740
|
+
const idx = i + 1;
|
|
10741
|
+
if (idx >= 1 && idx <= max) out.add(idx);
|
|
10742
|
+
}
|
|
10743
|
+
}
|
|
10744
|
+
continue;
|
|
10745
|
+
}
|
|
10732
10746
|
if (/^\d+$/.test(part)) {
|
|
10733
10747
|
const n = parseInt(part, 10);
|
|
10734
10748
|
if (n >= 1 && n <= max) out.add(n);
|
|
@@ -11143,6 +11157,10 @@ function applyFormDataToConfig(config, mappings, formValues, repeatableSectionsF
|
|
|
11143
11157
|
const filter = item == null ? void 0 : item.entryFilter;
|
|
11144
11158
|
return (filter == null ? void 0 : filter.mode) === "range" && ((_a2 = filter.range) == null ? void 0 : _a2.trim()) ? filter : void 0;
|
|
11145
11159
|
};
|
|
11160
|
+
const entryMetaFromList = (baseNodeId) => {
|
|
11161
|
+
const item = repeatableList.find((r) => baseId(r.nodeId) === baseNodeId || r.nodeId === baseNodeId);
|
|
11162
|
+
return item == null ? void 0 : item.entryMeta;
|
|
11163
|
+
};
|
|
11146
11164
|
const resolvedIdMap = /* @__PURE__ */ new Map();
|
|
11147
11165
|
const addResolved = (key, id) => {
|
|
11148
11166
|
const arr = resolvedIdMap.get(key);
|
|
@@ -11229,7 +11247,7 @@ function applyFormDataToConfig(config, mappings, formValues, repeatableSectionsF
|
|
|
11229
11247
|
const entryFilter = ((_b = node.repeatableSection) == null ? void 0 : _b.entryFilter) ?? entryFilterFromList(baseNodeId);
|
|
11230
11248
|
let entryIndices;
|
|
11231
11249
|
if (entryFilter && entryFilter.mode === "range" && entryFilter.range) {
|
|
11232
|
-
const parsed = parseEntryRange(entryFilter.range, N);
|
|
11250
|
+
const parsed = parseEntryRange(entryFilter.range, N, entryMetaFromList(baseNodeId));
|
|
11233
11251
|
entryIndices = parsed && parsed.length ? parsed : Array.from({ length: N }, (_, k) => k + 1);
|
|
11234
11252
|
} else {
|
|
11235
11253
|
entryIndices = Array.from({ length: N }, (_, k) => k + 1);
|
|
@@ -11274,7 +11292,7 @@ function applyFormDataToConfig(config, mappings, formValues, repeatableSectionsF
|
|
|
11274
11292
|
const nestedEntryFilter = ((_a2 = node.repeatableSection) == null ? void 0 : _a2.entryFilter) ?? entryFilterFromList(baseNodeId);
|
|
11275
11293
|
let nestedEntryIndices;
|
|
11276
11294
|
if (nestedEntryFilter && nestedEntryFilter.mode === "range" && nestedEntryFilter.range) {
|
|
11277
|
-
const parsed = parseEntryRange(nestedEntryFilter.range, N);
|
|
11295
|
+
const parsed = parseEntryRange(nestedEntryFilter.range, N, entryMetaFromList(baseNodeId));
|
|
11278
11296
|
nestedEntryIndices = parsed && parsed.length ? parsed : Array.from({ length: N }, (_, k) => k + 1);
|
|
11279
11297
|
} else {
|
|
11280
11298
|
nestedEntryIndices = Array.from({ length: N }, (_, k) => k + 1);
|
|
@@ -12326,7 +12344,8 @@ async function resolveTemplateData(options) {
|
|
|
12326
12344
|
nodeId: r.nodeId,
|
|
12327
12345
|
label: r.label,
|
|
12328
12346
|
minEntries: r.minEntries,
|
|
12329
|
-
maxEntries: r.maxEntries
|
|
12347
|
+
maxEntries: r.maxEntries,
|
|
12348
|
+
entryFilter: r.entryFilter
|
|
12330
12349
|
});
|
|
12331
12350
|
}
|
|
12332
12351
|
}
|
|
@@ -12449,13 +12468,58 @@ async function resolveFromForm(options) {
|
|
|
12449
12468
|
}
|
|
12450
12469
|
}
|
|
12451
12470
|
}
|
|
12471
|
+
const repeatableFromSchemaByBase = new Map(
|
|
12472
|
+
(repeatableFromSchema ?? []).map((r) => [baseId(r.nodeId), r])
|
|
12473
|
+
);
|
|
12452
12474
|
const topLevelRepeatables = inferredSections.filter((s) => s.type === "repeatable" && !s.parentId).map((s) => {
|
|
12453
12475
|
const entries = mergedSectionState[s.id] ?? [];
|
|
12454
12476
|
const nodeId = s.treeNodeId ?? s.id;
|
|
12455
|
-
|
|
12477
|
+
const schemaRepeatable = repeatableFromSchemaByBase.get(baseId(nodeId));
|
|
12478
|
+
const entryMeta = entries.map((e) => ({
|
|
12479
|
+
id: typeof (e == null ? void 0 : e.__entryId) === "string" ? e.__entryId : void 0,
|
|
12480
|
+
name: typeof (e == null ? void 0 : e.__entryName) === "string" ? e.__entryName : void 0
|
|
12481
|
+
}));
|
|
12482
|
+
return { nodeId, label: s.label, entryCount: Math.max(1, entries.length), entryFilter: schemaRepeatable == null ? void 0 : schemaRepeatable.entryFilter, entryMeta };
|
|
12483
|
+
});
|
|
12484
|
+
const nestedRepeatables = inferredSections.filter((s) => s.type === "repeatable" && s.parentId != null).map((s) => {
|
|
12485
|
+
const nodeId = s.treeNodeId ?? s.id;
|
|
12486
|
+
const schemaRepeatable = repeatableFromSchemaByBase.get(baseId(nodeId));
|
|
12487
|
+
const parentId = s.parentId;
|
|
12488
|
+
const parentEntries = mergedSectionState[parentId] ?? [];
|
|
12489
|
+
const merged = [];
|
|
12490
|
+
for (let pi = 0; pi < parentEntries.length; pi++) {
|
|
12491
|
+
const childEntries = mergedSectionState[`${parentId}_${pi}_${s.id}`] ?? [];
|
|
12492
|
+
for (const e of childEntries) {
|
|
12493
|
+
merged.push({
|
|
12494
|
+
id: typeof (e == null ? void 0 : e.__entryId) === "string" ? e.__entryId : void 0,
|
|
12495
|
+
name: typeof (e == null ? void 0 : e.__entryName) === "string" ? e.__entryName : void 0
|
|
12496
|
+
});
|
|
12497
|
+
}
|
|
12498
|
+
}
|
|
12499
|
+
return { nodeId, label: s.label, entryFilter: schemaRepeatable == null ? void 0 : schemaRepeatable.entryFilter, entryMeta: merged };
|
|
12456
12500
|
});
|
|
12457
|
-
const
|
|
12458
|
-
const
|
|
12501
|
+
const inferredRepeatableList = [...topLevelRepeatables, ...nestedRepeatables];
|
|
12502
|
+
const entryCountForLabel = (label) => {
|
|
12503
|
+
const normalized = label.trim().toLowerCase();
|
|
12504
|
+
for (const item of inferredRepeatableList) {
|
|
12505
|
+
if (item.label.trim().toLowerCase() !== normalized) continue;
|
|
12506
|
+
const count = item.entryCount;
|
|
12507
|
+
if (typeof count === "number") return count;
|
|
12508
|
+
}
|
|
12509
|
+
return void 0;
|
|
12510
|
+
};
|
|
12511
|
+
const fallbackRepeatableList = (repeatableFromSchema ?? []).map((r) => ({
|
|
12512
|
+
nodeId: r.nodeId,
|
|
12513
|
+
label: r.label,
|
|
12514
|
+
entryFilter: r.entryFilter,
|
|
12515
|
+
entryCount: entryCountForLabel(r.label)
|
|
12516
|
+
}));
|
|
12517
|
+
const repeatableList = inferredRepeatableList.length > 0 ? [
|
|
12518
|
+
...inferredRepeatableList,
|
|
12519
|
+
...fallbackRepeatableList.filter(
|
|
12520
|
+
(fallback) => !inferredRepeatableList.some((r) => baseId(r.nodeId) === baseId(fallback.nodeId))
|
|
12521
|
+
)
|
|
12522
|
+
] : fallbackRepeatableList;
|
|
12459
12523
|
const repeatableNestedEntryCounts = {};
|
|
12460
12524
|
for (const s of inferredSections) {
|
|
12461
12525
|
if (s.type !== "repeatable") continue;
|
|
@@ -12673,6 +12737,7 @@ function paintRepeatableSections(config, repeatableSections) {
|
|
|
12673
12737
|
const payload = { label: section.label };
|
|
12674
12738
|
if (section.minEntries !== void 0) payload.minEntries = section.minEntries;
|
|
12675
12739
|
if (section.maxEntries !== void 0) payload.maxEntries = section.maxEntries;
|
|
12740
|
+
if (section.entryFilter !== void 0) payload.entryFilter = section.entryFilter;
|
|
12676
12741
|
for (const page of pages) {
|
|
12677
12742
|
if (setRepeatable(page.children ?? [], section.nodeId, payload)) break;
|
|
12678
12743
|
}
|
|
@@ -12868,7 +12933,7 @@ function PixldocsPreview(props) {
|
|
|
12868
12933
|
!canvasSettled && /* @__PURE__ */ jsx("div", { style: { position: "absolute", inset: 0, display: "flex", alignItems: "center", justifyContent: "center", minHeight: 200 }, children: /* @__PURE__ */ jsx("div", { style: { color: "#888", fontSize: 14 }, children: "Loading preview..." }) })
|
|
12869
12934
|
] });
|
|
12870
12935
|
}
|
|
12871
|
-
const PACKAGE_VERSION = "0.5.
|
|
12936
|
+
const PACKAGE_VERSION = "0.5.86";
|
|
12872
12937
|
const roundParityValue = (value) => {
|
|
12873
12938
|
if (typeof value !== "number") return value;
|
|
12874
12939
|
return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
|