@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.
@@ -17372,7 +17372,13 @@ function sanitizeSectionStateAgainstSchema(state, schema) {
17372
17372
  if (!state) return {};
17373
17373
  if (!schema) return { ...state };
17374
17374
  const known = /* @__PURE__ */ new Set();
17375
- for (const s of schema.sections ?? []) known.add(s.id);
17375
+ const collectSectionIds = (sections) => {
17376
+ for (const s of sections ?? []) {
17377
+ known.add(s.id);
17378
+ collectSectionIds(s.children);
17379
+ }
17380
+ };
17381
+ collectSectionIds(schema.sections);
17376
17382
  for (const p of schema.repeatablePages ?? []) known.add(p.id);
17377
17383
  const out = {};
17378
17384
  for (const [key, value] of Object.entries(state)) {
@@ -17519,7 +17525,7 @@ async function resolveTemplateData(options) {
17519
17525
  }
17520
17526
  }
17521
17527
  if (repeatableSectionsInput.length > 0) {
17522
- paintRepeatableSections(config, repeatableSectionsInput);
17528
+ paintRepeatableSections(config, repeatableSectionsInput, inlineFormSchema);
17523
17529
  }
17524
17530
  }
17525
17531
  const mergedFormData = {
@@ -17591,7 +17597,7 @@ async function resolveFromForm(options) {
17591
17597
  normalizeLayoutModes(templateConfig);
17592
17598
  const repeatableFromSchema = templateFormSchema == null ? void 0 : templateFormSchema.repeatableSections;
17593
17599
  if ((repeatableFromSchema == null ? void 0 : repeatableFromSchema.length) && templateConfig.pages) {
17594
- paintRepeatableSections(templateConfig, repeatableFromSchema);
17600
+ paintRepeatableSections(templateConfig, repeatableFromSchema, templateFormSchema);
17595
17601
  }
17596
17602
  const schemaSections = getRenderableFormSections(formSchema);
17597
17603
  const repeatableNodeMap = /* @__PURE__ */ new Map();
@@ -17894,8 +17900,11 @@ function normalizeLayoutModes(config) {
17894
17900
  }
17895
17901
  }
17896
17902
  }
17897
- function paintRepeatableSections(config, repeatableSections) {
17903
+ function paintRepeatableSections(config, repeatableSections, formSchema) {
17904
+ var _a, _b;
17898
17905
  const pages = config.pages ?? [];
17906
+ const entryFilters = (formSchema == null ? void 0 : formSchema.entryFilters) ?? [];
17907
+ const entryFilterBases = new Set(entryFilters.map((f) => baseId(f.nodeId)));
17899
17908
  function stripFlags(nodes) {
17900
17909
  for (const node of nodes) {
17901
17910
  delete node.repeatableSection;
@@ -17905,32 +17914,53 @@ function paintRepeatableSections(config, repeatableSections) {
17905
17914
  for (const page of pages) {
17906
17915
  if (page.children) stripFlags(page.children);
17907
17916
  }
17908
- function setRepeatable(nodes, nodeId, payload) {
17917
+ function setRepeatableAll(nodes, nodeId, payload) {
17918
+ let painted = 0;
17909
17919
  for (const node of nodes) {
17910
17920
  const id = node.id;
17911
- if (node.repeatableSection) {
17912
- if (Array.isArray(node.children) && setRepeatable(node.children, nodeId, payload)) {
17913
- return true;
17914
- }
17915
- continue;
17916
- }
17917
17921
  if (id && (id === nodeId || baseId(id) === baseId(nodeId))) {
17918
17922
  node.repeatableSection = payload;
17919
- return true;
17923
+ painted++;
17920
17924
  }
17921
- if (Array.isArray(node.children) && setRepeatable(node.children, nodeId, payload)) {
17922
- return true;
17925
+ if (Array.isArray(node.children)) {
17926
+ painted += setRepeatableAll(node.children, nodeId, payload);
17923
17927
  }
17924
17928
  }
17925
- return false;
17929
+ return painted;
17926
17930
  }
17927
17931
  for (const section of repeatableSections) {
17932
+ const inlineRange = ((_a = section.entryFilter) == null ? void 0 : _a.mode) === "range" ? (_b = section.entryFilter.range) == null ? void 0 : _b.trim() : void 0;
17933
+ const shouldUseInlineFilter = !!inlineRange && !entryFilterBases.has(baseId(section.nodeId));
17928
17934
  const payload = { label: section.label };
17929
17935
  if (section.minEntries !== void 0) payload.minEntries = section.minEntries;
17930
17936
  if (section.maxEntries !== void 0) payload.maxEntries = section.maxEntries;
17931
- if (section.entryFilter !== void 0) payload.entryFilter = section.entryFilter;
17937
+ if (shouldUseInlineFilter) payload.entryFilter = { mode: "range", range: inlineRange };
17932
17938
  for (const page of pages) {
17933
- if (setRepeatable(page.children ?? [], section.nodeId, payload)) break;
17939
+ setRepeatableAll(page.children ?? [], section.nodeId, payload);
17940
+ }
17941
+ }
17942
+ if (entryFilters.length) {
17943
+ const occurrencesByBase = /* @__PURE__ */ new Map();
17944
+ const collect = (nodes) => {
17945
+ var _a2;
17946
+ for (const node of nodes ?? []) {
17947
+ if ((_a2 = node.repeatableSection) == null ? void 0 : _a2.label) {
17948
+ const base = baseId(node.id);
17949
+ if (!occurrencesByBase.has(base)) occurrencesByBase.set(base, []);
17950
+ occurrencesByBase.get(base).push(node);
17951
+ }
17952
+ if (Array.isArray(node.children)) collect(node.children);
17953
+ }
17954
+ };
17955
+ for (const page of pages) collect(page.children ?? []);
17956
+ for (const filter of entryFilters) {
17957
+ const base = baseId(filter.nodeId);
17958
+ const occurrences = occurrencesByBase.get(base);
17959
+ if (!(occurrences == null ? void 0 : occurrences.length)) continue;
17960
+ const target = filter.occurrenceIndex && filter.occurrenceIndex >= 1 ? occurrences[filter.occurrenceIndex - 1] : occurrences.find((node) => node.id === filter.nodeId) ?? occurrences[0];
17961
+ if (target == null ? void 0 : target.repeatableSection) {
17962
+ target.repeatableSection.entryFilter = { mode: filter.mode, ...filter.range ? { range: filter.range } : {} };
17963
+ }
17934
17964
  }
17935
17965
  }
17936
17966
  }
@@ -19075,9 +19105,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
19075
19105
  }
19076
19106
  return svgString;
19077
19107
  }
19078
- const resolvedPackageVersion = "0.5.221";
19108
+ const resolvedPackageVersion = "0.5.222";
19079
19109
  const PACKAGE_VERSION = resolvedPackageVersion;
19080
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.221";
19110
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.222";
19081
19111
  const roundParityValue = (value) => {
19082
19112
  if (typeof value !== "number") return value;
19083
19113
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -19821,7 +19851,7 @@ class PixldocsRenderer {
19821
19851
  await this.waitForCanvasScene(container, cloned, i);
19822
19852
  }
19823
19853
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
19824
- const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-BR2dJuvJ.js");
19854
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-CTPOHXtQ.js");
19825
19855
  const prepared = preparePagesForExport(
19826
19856
  cloned.pages,
19827
19857
  canvasWidth,
@@ -22011,7 +22041,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
22011
22041
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
22012
22042
  sanitizeSvgTreeForPdf(svgToDraw);
22013
22043
  try {
22014
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-BR2dJuvJ.js");
22044
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-CTPOHXtQ.js");
22015
22045
  try {
22016
22046
  await logTextMeasurementDiagnostic(svgToDraw);
22017
22047
  } catch {
@@ -22411,4 +22441,4 @@ export {
22411
22441
  buildTeaserBlurFlatKeys as y,
22412
22442
  collectFontDescriptorsFromConfig as z
22413
22443
  };
22414
- //# sourceMappingURL=index-mmjF0tPc.js.map
22444
+ //# sourceMappingURL=index-DxL--cfL.js.map