@pixldocs/canvas-renderer 0.5.203 → 0.5.205

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.
@@ -13143,22 +13143,35 @@ function applyFormDataToConfig(config, mappings, formValues, repeatableSectionsF
13143
13143
  }
13144
13144
  return false;
13145
13145
  };
13146
- const getFieldForRepeatableKey = (fieldId, fullKey) => {
13147
- if (!(dynamicFields == null ? void 0 : dynamicFields.length)) return void 0;
13146
+ const getFieldsForRepeatableKey = (fieldId, fullKey) => {
13147
+ if (!(dynamicFields == null ? void 0 : dynamicFields.length)) return [];
13148
+ const matches = [];
13149
+ const add = (field) => {
13150
+ if (field && !matches.some((existing) => existing.id === field.id)) matches.push(field);
13151
+ };
13148
13152
  if (fullKey) {
13149
- const byFullId = dynamicFields.find((f) => f.id === fullKey);
13150
- if (byFullId) return byFullId;
13151
- }
13152
- const byId = dynamicFields.find((f) => f.id === fieldId);
13153
- if (byId) return byId;
13154
- const byElementId = dynamicFields.find((f) => (f.mappings ?? []).some((m) => (m == null ? void 0 : m.elementId) === fieldId));
13155
- if (byElementId) return byElementId;
13156
- const suffixMatch = dynamicFields.find((f) => {
13157
- if (f.id.endsWith(`_N_${fieldId}`)) return true;
13158
- if (f.id.endsWith(`_${fieldId}`) && f.id.includes("_N_")) return true;
13159
- return false;
13160
- });
13161
- return suffixMatch;
13153
+ add(dynamicFields.find((f) => f.id === fullKey));
13154
+ const nestedMatch = fullKey.match(NESTED_REPEATABLE_KEY_REGEX);
13155
+ if (nestedMatch) {
13156
+ const [, parentId, , childId, , suffix] = nestedMatch;
13157
+ add(dynamicFields.find((f) => f.id === `field_${parentId}_N_field_${childId}_N_${suffix}`));
13158
+ } else {
13159
+ const match = fullKey.match(REPEATABLE_KEY_REGEX);
13160
+ if (match) {
13161
+ const [, nodeId, , suffix] = match;
13162
+ add(dynamicFields.find((f) => f.id === `field_${nodeId}_N_${suffix}`));
13163
+ }
13164
+ }
13165
+ }
13166
+ add(dynamicFields.find((f) => f.id === fieldId));
13167
+ for (const f of dynamicFields) {
13168
+ if ((f.mappings ?? []).some((m) => (m == null ? void 0 : m.elementId) === fieldId)) add(f);
13169
+ }
13170
+ for (const f of dynamicFields) {
13171
+ if (f.id.endsWith(`_N_${fieldId}`)) add(f);
13172
+ else if (f.id.endsWith(`_${fieldId}`) && f.id.includes("_N_")) add(f);
13173
+ }
13174
+ return matches;
13162
13175
  };
13163
13176
  if (dynamicFields == null ? void 0 : dynamicFields.length) {
13164
13177
  for (const key of Object.keys(formValues)) {
@@ -13166,8 +13179,8 @@ function applyFormDataToConfig(config, mappings, formValues, repeatableSectionsF
13166
13179
  if (nestedMatch) {
13167
13180
  const [, parentId, parentIndexStr, childId, childIndexStr, fieldId] = nestedMatch;
13168
13181
  const value = formValues[key];
13169
- const field = getFieldForRepeatableKey(fieldId, key);
13170
- for (const mapping of (field == null ? void 0 : field.mappings) ?? []) {
13182
+ const fields = getFieldsForRepeatableKey(fieldId, key);
13183
+ for (const field of fields) for (const mapping of field.mappings ?? []) {
13171
13184
  const oldElementId = mapping.elementId;
13172
13185
  const mapKeyByElement = `${baseId(parentId)}_${parentIndexStr}_${baseId(childId)}_${childIndexStr}_${oldElementId}`;
13173
13186
  let elementIds = resolvedIdMap.get(mapKeyByElement);
@@ -13218,8 +13231,8 @@ function applyFormDataToConfig(config, mappings, formValues, repeatableSectionsF
13218
13231
  if (!match) continue;
13219
13232
  const [, nodeId, indexStr, fieldId] = match;
13220
13233
  const value = formValues[key];
13221
- const field = getFieldForRepeatableKey(fieldId);
13222
- for (const mapping of (field == null ? void 0 : field.mappings) ?? []) {
13234
+ const fields = getFieldsForRepeatableKey(fieldId, key);
13235
+ for (const field of fields) for (const mapping of field.mappings ?? []) {
13223
13236
  const oldElementId = mapping.elementId;
13224
13237
  const elementIds = /* @__PURE__ */ new Set();
13225
13238
  for (const candidateBaseId of getRepeatableBaseIdsForToken(nodeId)) {
@@ -15705,7 +15718,7 @@ async function resolveTemplateData(options) {
15705
15718
  }
15706
15719
  }
15707
15720
  if (repeatableSectionsInput.length > 0) {
15708
- paintRepeatableSections(config, repeatableSectionsInput);
15721
+ paintRepeatableSections(config, repeatableSectionsInput, inlineFormSchema == null ? void 0 : inlineFormSchema.entryFilters);
15709
15722
  }
15710
15723
  }
15711
15724
  const mergedFormData = {
@@ -15776,7 +15789,7 @@ async function resolveFromForm(options) {
15776
15789
  normalizeLayoutModes(templateConfig);
15777
15790
  const repeatableFromSchema = templateFormSchema == null ? void 0 : templateFormSchema.repeatableSections;
15778
15791
  if ((repeatableFromSchema == null ? void 0 : repeatableFromSchema.length) && templateConfig.pages) {
15779
- paintRepeatableSections(templateConfig, repeatableFromSchema);
15792
+ paintRepeatableSections(templateConfig, repeatableFromSchema, templateFormSchema == null ? void 0 : templateFormSchema.entryFilters);
15780
15793
  }
15781
15794
  const schemaSections = getRenderableFormSections(formSchema);
15782
15795
  const repeatableNodeMap = /* @__PURE__ */ new Map();
@@ -15800,6 +15813,7 @@ async function resolveFromForm(options) {
15800
15813
  } else {
15801
15814
  inferredSections = [];
15802
15815
  }
15816
+ const templateDefaultMetaSectionState = templateRow.default_data && isDefaultDataV2(templateRow.default_data) ? templateRow.default_data.sectionState : extractSectionStateCandidate(templateRow.default_data, inferredSections);
15803
15817
  const defaultFormMetaSectionState = extractSectionStateCandidate(defaultForm == null ? void 0 : defaultForm.values, inferredSections) ?? extractSectionStateCandidate(defaultForm == null ? void 0 : defaultForm.saved_data, inferredSections);
15804
15818
  let mergedSectionState = { ...sectionState };
15805
15819
  const templateDefaultData = templateRow.default_data;
@@ -15811,6 +15825,7 @@ async function resolveFromForm(options) {
15811
15825
  }
15812
15826
  }
15813
15827
  }
15828
+ mergedSectionState = mergeRepeatableEntryMeta(mergedSectionState, templateDefaultMetaSectionState, inferredSections);
15814
15829
  mergedSectionState = mergeRepeatableEntryMeta(mergedSectionState, defaultFormMetaSectionState, inferredSections);
15815
15830
  const flatFormData = flattenSectionStateToFormData(mergedSectionState, inferredSections);
15816
15831
  const dynamicFields = templateConfig.dynamicFields || [];
@@ -15863,11 +15878,17 @@ async function resolveFromForm(options) {
15863
15878
  }
15864
15879
  return void 0;
15865
15880
  };
15881
+ const entryMetaForLabel = (label) => {
15882
+ const normalized = label.trim().toLowerCase();
15883
+ const item = inferredRepeatableList.find((candidate) => candidate.label.trim().toLowerCase() === normalized);
15884
+ return { entryMeta: item == null ? void 0 : item.entryMeta, nestedEntryMeta: item == null ? void 0 : item.nestedEntryMeta };
15885
+ };
15866
15886
  const fallbackRepeatableList = (repeatableFromSchema ?? []).map((r) => ({
15867
15887
  nodeId: r.nodeId,
15868
15888
  label: r.label,
15869
15889
  entryFilter: r.entryFilter,
15870
- entryCount: entryCountForLabel(r.label)
15890
+ entryCount: entryCountForLabel(r.label),
15891
+ ...entryMetaForLabel(r.label)
15871
15892
  }));
15872
15893
  const repeatableList = inferredRepeatableList.length > 0 ? [
15873
15894
  ...inferredRepeatableList,
@@ -16931,9 +16952,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
16931
16952
  }
16932
16953
  return svgString;
16933
16954
  }
16934
- const resolvedPackageVersion = "0.5.203";
16955
+ const resolvedPackageVersion = "0.5.205";
16935
16956
  const PACKAGE_VERSION = resolvedPackageVersion;
16936
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.203";
16957
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.205";
16937
16958
  const roundParityValue = (value) => {
16938
16959
  if (typeof value !== "number") return value;
16939
16960
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -17612,7 +17633,7 @@ class PixldocsRenderer {
17612
17633
  await this.waitForCanvasScene(container, cloned, i);
17613
17634
  }
17614
17635
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
17615
- const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-B8tazQjy.js");
17636
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-CZyBCnFF.js");
17616
17637
  const prepared = preparePagesForExport(
17617
17638
  cloned.pages,
17618
17639
  canvasWidth,
@@ -19796,7 +19817,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
19796
19817
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
19797
19818
  sanitizeSvgTreeForPdf(svgToDraw);
19798
19819
  try {
19799
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-B8tazQjy.js");
19820
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-CZyBCnFF.js");
19800
19821
  try {
19801
19822
  await logTextMeasurementDiagnostic(svgToDraw);
19802
19823
  } catch {
@@ -20196,4 +20217,4 @@ export {
20196
20217
  buildTeaserBlurFlatKeys as y,
20197
20218
  collectFontDescriptorsFromConfig as z
20198
20219
  };
20199
- //# sourceMappingURL=index-C2gJ23dU.js.map
20220
+ //# sourceMappingURL=index-DBuMPh9u.js.map