@pixldocs/canvas-renderer 0.5.221 → 0.5.222

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.
@@ -17390,7 +17390,13 @@ function sanitizeSectionStateAgainstSchema(state, schema) {
17390
17390
  if (!state) return {};
17391
17391
  if (!schema) return { ...state };
17392
17392
  const known = /* @__PURE__ */ new Set();
17393
- for (const s of schema.sections ?? []) known.add(s.id);
17393
+ const collectSectionIds = (sections) => {
17394
+ for (const s of sections ?? []) {
17395
+ known.add(s.id);
17396
+ collectSectionIds(s.children);
17397
+ }
17398
+ };
17399
+ collectSectionIds(schema.sections);
17394
17400
  for (const p of schema.repeatablePages ?? []) known.add(p.id);
17395
17401
  const out = {};
17396
17402
  for (const [key, value] of Object.entries(state)) {
@@ -17537,7 +17543,7 @@ async function resolveTemplateData(options) {
17537
17543
  }
17538
17544
  }
17539
17545
  if (repeatableSectionsInput.length > 0) {
17540
- paintRepeatableSections(config, repeatableSectionsInput);
17546
+ paintRepeatableSections(config, repeatableSectionsInput, inlineFormSchema);
17541
17547
  }
17542
17548
  }
17543
17549
  const mergedFormData = {
@@ -17609,7 +17615,7 @@ async function resolveFromForm(options) {
17609
17615
  normalizeLayoutModes(templateConfig);
17610
17616
  const repeatableFromSchema = templateFormSchema == null ? void 0 : templateFormSchema.repeatableSections;
17611
17617
  if ((repeatableFromSchema == null ? void 0 : repeatableFromSchema.length) && templateConfig.pages) {
17612
- paintRepeatableSections(templateConfig, repeatableFromSchema);
17618
+ paintRepeatableSections(templateConfig, repeatableFromSchema, templateFormSchema);
17613
17619
  }
17614
17620
  const schemaSections = getRenderableFormSections(formSchema);
17615
17621
  const repeatableNodeMap = /* @__PURE__ */ new Map();
@@ -17912,8 +17918,11 @@ function normalizeLayoutModes(config) {
17912
17918
  }
17913
17919
  }
17914
17920
  }
17915
- function paintRepeatableSections(config, repeatableSections) {
17921
+ function paintRepeatableSections(config, repeatableSections, formSchema) {
17922
+ var _a, _b;
17916
17923
  const pages = config.pages ?? [];
17924
+ const entryFilters = (formSchema == null ? void 0 : formSchema.entryFilters) ?? [];
17925
+ const entryFilterBases = new Set(entryFilters.map((f) => baseId(f.nodeId)));
17917
17926
  function stripFlags(nodes) {
17918
17927
  for (const node of nodes) {
17919
17928
  delete node.repeatableSection;
@@ -17923,32 +17932,53 @@ function paintRepeatableSections(config, repeatableSections) {
17923
17932
  for (const page of pages) {
17924
17933
  if (page.children) stripFlags(page.children);
17925
17934
  }
17926
- function setRepeatable(nodes, nodeId, payload) {
17935
+ function setRepeatableAll(nodes, nodeId, payload) {
17936
+ let painted = 0;
17927
17937
  for (const node of nodes) {
17928
17938
  const id = node.id;
17929
- if (node.repeatableSection) {
17930
- if (Array.isArray(node.children) && setRepeatable(node.children, nodeId, payload)) {
17931
- return true;
17932
- }
17933
- continue;
17934
- }
17935
17939
  if (id && (id === nodeId || baseId(id) === baseId(nodeId))) {
17936
17940
  node.repeatableSection = payload;
17937
- return true;
17941
+ painted++;
17938
17942
  }
17939
- if (Array.isArray(node.children) && setRepeatable(node.children, nodeId, payload)) {
17940
- return true;
17943
+ if (Array.isArray(node.children)) {
17944
+ painted += setRepeatableAll(node.children, nodeId, payload);
17941
17945
  }
17942
17946
  }
17943
- return false;
17947
+ return painted;
17944
17948
  }
17945
17949
  for (const section of repeatableSections) {
17950
+ const inlineRange = ((_a = section.entryFilter) == null ? void 0 : _a.mode) === "range" ? (_b = section.entryFilter.range) == null ? void 0 : _b.trim() : void 0;
17951
+ const shouldUseInlineFilter = !!inlineRange && !entryFilterBases.has(baseId(section.nodeId));
17946
17952
  const payload = { label: section.label };
17947
17953
  if (section.minEntries !== void 0) payload.minEntries = section.minEntries;
17948
17954
  if (section.maxEntries !== void 0) payload.maxEntries = section.maxEntries;
17949
- if (section.entryFilter !== void 0) payload.entryFilter = section.entryFilter;
17955
+ if (shouldUseInlineFilter) payload.entryFilter = { mode: "range", range: inlineRange };
17950
17956
  for (const page of pages) {
17951
- if (setRepeatable(page.children ?? [], section.nodeId, payload)) break;
17957
+ setRepeatableAll(page.children ?? [], section.nodeId, payload);
17958
+ }
17959
+ }
17960
+ if (entryFilters.length) {
17961
+ const occurrencesByBase = /* @__PURE__ */ new Map();
17962
+ const collect = (nodes) => {
17963
+ var _a2;
17964
+ for (const node of nodes ?? []) {
17965
+ if ((_a2 = node.repeatableSection) == null ? void 0 : _a2.label) {
17966
+ const base = baseId(node.id);
17967
+ if (!occurrencesByBase.has(base)) occurrencesByBase.set(base, []);
17968
+ occurrencesByBase.get(base).push(node);
17969
+ }
17970
+ if (Array.isArray(node.children)) collect(node.children);
17971
+ }
17972
+ };
17973
+ for (const page of pages) collect(page.children ?? []);
17974
+ for (const filter of entryFilters) {
17975
+ const base = baseId(filter.nodeId);
17976
+ const occurrences = occurrencesByBase.get(base);
17977
+ if (!(occurrences == null ? void 0 : occurrences.length)) continue;
17978
+ const target = filter.occurrenceIndex && filter.occurrenceIndex >= 1 ? occurrences[filter.occurrenceIndex - 1] : occurrences.find((node) => node.id === filter.nodeId) ?? occurrences[0];
17979
+ if (target == null ? void 0 : target.repeatableSection) {
17980
+ target.repeatableSection.entryFilter = { mode: filter.mode, ...filter.range ? { range: filter.range } : {} };
17981
+ }
17952
17982
  }
17953
17983
  }
17954
17984
  }
@@ -19093,9 +19123,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
19093
19123
  }
19094
19124
  return svgString;
19095
19125
  }
19096
- const resolvedPackageVersion = "0.5.221";
19126
+ const resolvedPackageVersion = "0.5.222";
19097
19127
  const PACKAGE_VERSION = resolvedPackageVersion;
19098
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.221";
19128
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.222";
19099
19129
  const roundParityValue = (value) => {
19100
19130
  if (typeof value !== "number") return value;
19101
19131
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -19839,7 +19869,7 @@ class PixldocsRenderer {
19839
19869
  await this.waitForCanvasScene(container, cloned, i);
19840
19870
  }
19841
19871
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
19842
- const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-CZjhPHZh.cjs"));
19872
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-CDMnc_eW.cjs"));
19843
19873
  const prepared = preparePagesForExport(
19844
19874
  cloned.pages,
19845
19875
  canvasWidth,
@@ -22029,7 +22059,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
22029
22059
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
22030
22060
  sanitizeSvgTreeForPdf(svgToDraw);
22031
22061
  try {
22032
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-CZjhPHZh.cjs"));
22062
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-CDMnc_eW.cjs"));
22033
22063
  try {
22034
22064
  await logTextMeasurementDiagnostic(svgToDraw);
22035
22065
  } catch {
@@ -22426,4 +22456,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
22426
22456
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
22427
22457
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
22428
22458
  exports.warmTemplateFromForm = warmTemplateFromForm;
22429
- //# sourceMappingURL=index-DIokvyoP.cjs.map
22459
+ //# sourceMappingURL=index-BKJxI43i.cjs.map