@pixldocs/canvas-renderer 0.5.220 → 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 = {
@@ -17562,10 +17568,11 @@ async function resolveTemplateData(options) {
17562
17568
  async function resolveFromForm(options) {
17563
17569
  var _a, _b, _c;
17564
17570
  const { templateId, formSchemaId, sectionState, flatFormData: directFlatFormData, themeId, supabaseUrl, supabaseAnonKey, prefetched } = options;
17565
- if (!formSchemaId) {
17571
+ const hasSectionStateInput = !!sectionState && Object.keys(sectionState).length > 0;
17572
+ if (!formSchemaId && !hasSectionStateInput) {
17566
17573
  return resolveTemplateData({
17567
17574
  templateId,
17568
- formData: directFlatFormData ?? sectionState ?? {},
17575
+ formData: directFlatFormData ?? {},
17569
17576
  supabaseUrl,
17570
17577
  supabaseAnonKey,
17571
17578
  prefetched: (prefetched == null ? void 0 : prefetched.templateRow) ? { templateRow: prefetched.templateRow } : void 0
@@ -17573,12 +17580,12 @@ async function resolveFromForm(options) {
17573
17580
  }
17574
17581
  const [templateRow, formSchemaRow, defaultForm] = await Promise.all([
17575
17582
  (prefetched == null ? void 0 : prefetched.templateRow) ? Promise.resolve(prefetched.templateRow) : fetchRow(supabaseUrl, supabaseAnonKey, "templates", templateId),
17576
- (prefetched == null ? void 0 : prefetched.formSchemaRow) !== void 0 ? Promise.resolve(prefetched.formSchemaRow) : fetchRow(supabaseUrl, supabaseAnonKey, "form_schemas", formSchemaId),
17577
- (prefetched == null ? void 0 : prefetched.defaultForm) !== void 0 ? Promise.resolve(prefetched.defaultForm) : fetchDefaultForm(supabaseUrl, supabaseAnonKey, formSchemaId)
17583
+ (prefetched == null ? void 0 : prefetched.formSchemaRow) !== void 0 ? Promise.resolve(prefetched.formSchemaRow) : formSchemaId ? fetchRow(supabaseUrl, supabaseAnonKey, "form_schemas", formSchemaId).catch(() => null) : Promise.resolve(null),
17584
+ (prefetched == null ? void 0 : prefetched.defaultForm) !== void 0 ? Promise.resolve(prefetched.defaultForm) : formSchemaId ? fetchDefaultForm(supabaseUrl, supabaseAnonKey, formSchemaId) : Promise.resolve(null)
17578
17585
  ]);
17579
17586
  const templateConfig = templateRow.config;
17580
17587
  const templateFormSchema = templateRow.form_schema;
17581
- const formSchema = formSchemaRow.schema;
17588
+ const formSchema = (formSchemaRow == null ? void 0 : formSchemaRow.schema) ?? void 0;
17582
17589
  if (templateFormSchema) {
17583
17590
  if (!Array.isArray(templateConfig.dynamicFields) && Array.isArray(templateFormSchema.dynamicFields)) {
17584
17591
  templateConfig.dynamicFields = templateFormSchema.dynamicFields;
@@ -17590,7 +17597,7 @@ async function resolveFromForm(options) {
17590
17597
  normalizeLayoutModes(templateConfig);
17591
17598
  const repeatableFromSchema = templateFormSchema == null ? void 0 : templateFormSchema.repeatableSections;
17592
17599
  if ((repeatableFromSchema == null ? void 0 : repeatableFromSchema.length) && templateConfig.pages) {
17593
- paintRepeatableSections(templateConfig, repeatableFromSchema);
17600
+ paintRepeatableSections(templateConfig, repeatableFromSchema, templateFormSchema);
17594
17601
  }
17595
17602
  const schemaSections = getRenderableFormSections(formSchema);
17596
17603
  const repeatableNodeMap = /* @__PURE__ */ new Map();
@@ -17893,8 +17900,11 @@ function normalizeLayoutModes(config) {
17893
17900
  }
17894
17901
  }
17895
17902
  }
17896
- function paintRepeatableSections(config, repeatableSections) {
17903
+ function paintRepeatableSections(config, repeatableSections, formSchema) {
17904
+ var _a, _b;
17897
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)));
17898
17908
  function stripFlags(nodes) {
17899
17909
  for (const node of nodes) {
17900
17910
  delete node.repeatableSection;
@@ -17904,32 +17914,53 @@ function paintRepeatableSections(config, repeatableSections) {
17904
17914
  for (const page of pages) {
17905
17915
  if (page.children) stripFlags(page.children);
17906
17916
  }
17907
- function setRepeatable(nodes, nodeId, payload) {
17917
+ function setRepeatableAll(nodes, nodeId, payload) {
17918
+ let painted = 0;
17908
17919
  for (const node of nodes) {
17909
17920
  const id = node.id;
17910
- if (node.repeatableSection) {
17911
- if (Array.isArray(node.children) && setRepeatable(node.children, nodeId, payload)) {
17912
- return true;
17913
- }
17914
- continue;
17915
- }
17916
17921
  if (id && (id === nodeId || baseId(id) === baseId(nodeId))) {
17917
17922
  node.repeatableSection = payload;
17918
- return true;
17923
+ painted++;
17919
17924
  }
17920
- if (Array.isArray(node.children) && setRepeatable(node.children, nodeId, payload)) {
17921
- return true;
17925
+ if (Array.isArray(node.children)) {
17926
+ painted += setRepeatableAll(node.children, nodeId, payload);
17922
17927
  }
17923
17928
  }
17924
- return false;
17929
+ return painted;
17925
17930
  }
17926
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));
17927
17934
  const payload = { label: section.label };
17928
17935
  if (section.minEntries !== void 0) payload.minEntries = section.minEntries;
17929
17936
  if (section.maxEntries !== void 0) payload.maxEntries = section.maxEntries;
17930
- if (section.entryFilter !== void 0) payload.entryFilter = section.entryFilter;
17937
+ if (shouldUseInlineFilter) payload.entryFilter = { mode: "range", range: inlineRange };
17931
17938
  for (const page of pages) {
17932
- 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
+ }
17933
17964
  }
17934
17965
  }
17935
17966
  }
@@ -19074,9 +19105,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
19074
19105
  }
19075
19106
  return svgString;
19076
19107
  }
19077
- const resolvedPackageVersion = "0.5.220";
19108
+ const resolvedPackageVersion = "0.5.222";
19078
19109
  const PACKAGE_VERSION = resolvedPackageVersion;
19079
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.220";
19110
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.222";
19080
19111
  const roundParityValue = (value) => {
19081
19112
  if (typeof value !== "number") return value;
19082
19113
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -19820,7 +19851,7 @@ class PixldocsRenderer {
19820
19851
  await this.waitForCanvasScene(container, cloned, i);
19821
19852
  }
19822
19853
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
19823
- const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-D5bhT-57.js");
19854
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-CTPOHXtQ.js");
19824
19855
  const prepared = preparePagesForExport(
19825
19856
  cloned.pages,
19826
19857
  canvasWidth,
@@ -22010,7 +22041,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
22010
22041
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
22011
22042
  sanitizeSvgTreeForPdf(svgToDraw);
22012
22043
  try {
22013
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-D5bhT-57.js");
22044
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-CTPOHXtQ.js");
22014
22045
  try {
22015
22046
  await logTextMeasurementDiagnostic(svgToDraw);
22016
22047
  } catch {
@@ -22410,4 +22441,4 @@ export {
22410
22441
  buildTeaserBlurFlatKeys as y,
22411
22442
  collectFontDescriptorsFromConfig as z
22412
22443
  };
22413
- //# sourceMappingURL=index-KtRZhEPi.js.map
22444
+ //# sourceMappingURL=index-DxL--cfL.js.map