@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.
@@ -13161,22 +13161,35 @@ function applyFormDataToConfig(config, mappings, formValues, repeatableSectionsF
13161
13161
  }
13162
13162
  return false;
13163
13163
  };
13164
- const getFieldForRepeatableKey = (fieldId, fullKey) => {
13165
- if (!(dynamicFields == null ? void 0 : dynamicFields.length)) return void 0;
13164
+ const getFieldsForRepeatableKey = (fieldId, fullKey) => {
13165
+ if (!(dynamicFields == null ? void 0 : dynamicFields.length)) return [];
13166
+ const matches = [];
13167
+ const add = (field) => {
13168
+ if (field && !matches.some((existing) => existing.id === field.id)) matches.push(field);
13169
+ };
13166
13170
  if (fullKey) {
13167
- const byFullId = dynamicFields.find((f) => f.id === fullKey);
13168
- if (byFullId) return byFullId;
13169
- }
13170
- const byId = dynamicFields.find((f) => f.id === fieldId);
13171
- if (byId) return byId;
13172
- const byElementId = dynamicFields.find((f) => (f.mappings ?? []).some((m) => (m == null ? void 0 : m.elementId) === fieldId));
13173
- if (byElementId) return byElementId;
13174
- const suffixMatch = dynamicFields.find((f) => {
13175
- if (f.id.endsWith(`_N_${fieldId}`)) return true;
13176
- if (f.id.endsWith(`_${fieldId}`) && f.id.includes("_N_")) return true;
13177
- return false;
13178
- });
13179
- return suffixMatch;
13171
+ add(dynamicFields.find((f) => f.id === fullKey));
13172
+ const nestedMatch = fullKey.match(NESTED_REPEATABLE_KEY_REGEX);
13173
+ if (nestedMatch) {
13174
+ const [, parentId, , childId, , suffix] = nestedMatch;
13175
+ add(dynamicFields.find((f) => f.id === `field_${parentId}_N_field_${childId}_N_${suffix}`));
13176
+ } else {
13177
+ const match = fullKey.match(REPEATABLE_KEY_REGEX);
13178
+ if (match) {
13179
+ const [, nodeId, , suffix] = match;
13180
+ add(dynamicFields.find((f) => f.id === `field_${nodeId}_N_${suffix}`));
13181
+ }
13182
+ }
13183
+ }
13184
+ add(dynamicFields.find((f) => f.id === fieldId));
13185
+ for (const f of dynamicFields) {
13186
+ if ((f.mappings ?? []).some((m) => (m == null ? void 0 : m.elementId) === fieldId)) add(f);
13187
+ }
13188
+ for (const f of dynamicFields) {
13189
+ if (f.id.endsWith(`_N_${fieldId}`)) add(f);
13190
+ else if (f.id.endsWith(`_${fieldId}`) && f.id.includes("_N_")) add(f);
13191
+ }
13192
+ return matches;
13180
13193
  };
13181
13194
  if (dynamicFields == null ? void 0 : dynamicFields.length) {
13182
13195
  for (const key of Object.keys(formValues)) {
@@ -13184,8 +13197,8 @@ function applyFormDataToConfig(config, mappings, formValues, repeatableSectionsF
13184
13197
  if (nestedMatch) {
13185
13198
  const [, parentId, parentIndexStr, childId, childIndexStr, fieldId] = nestedMatch;
13186
13199
  const value = formValues[key];
13187
- const field = getFieldForRepeatableKey(fieldId, key);
13188
- for (const mapping of (field == null ? void 0 : field.mappings) ?? []) {
13200
+ const fields = getFieldsForRepeatableKey(fieldId, key);
13201
+ for (const field of fields) for (const mapping of field.mappings ?? []) {
13189
13202
  const oldElementId = mapping.elementId;
13190
13203
  const mapKeyByElement = `${baseId(parentId)}_${parentIndexStr}_${baseId(childId)}_${childIndexStr}_${oldElementId}`;
13191
13204
  let elementIds = resolvedIdMap.get(mapKeyByElement);
@@ -13236,8 +13249,8 @@ function applyFormDataToConfig(config, mappings, formValues, repeatableSectionsF
13236
13249
  if (!match) continue;
13237
13250
  const [, nodeId, indexStr, fieldId] = match;
13238
13251
  const value = formValues[key];
13239
- const field = getFieldForRepeatableKey(fieldId);
13240
- for (const mapping of (field == null ? void 0 : field.mappings) ?? []) {
13252
+ const fields = getFieldsForRepeatableKey(fieldId, key);
13253
+ for (const field of fields) for (const mapping of field.mappings ?? []) {
13241
13254
  const oldElementId = mapping.elementId;
13242
13255
  const elementIds = /* @__PURE__ */ new Set();
13243
13256
  for (const candidateBaseId of getRepeatableBaseIdsForToken(nodeId)) {
@@ -15723,7 +15736,7 @@ async function resolveTemplateData(options) {
15723
15736
  }
15724
15737
  }
15725
15738
  if (repeatableSectionsInput.length > 0) {
15726
- paintRepeatableSections(config, repeatableSectionsInput);
15739
+ paintRepeatableSections(config, repeatableSectionsInput, inlineFormSchema == null ? void 0 : inlineFormSchema.entryFilters);
15727
15740
  }
15728
15741
  }
15729
15742
  const mergedFormData = {
@@ -15794,7 +15807,7 @@ async function resolveFromForm(options) {
15794
15807
  normalizeLayoutModes(templateConfig);
15795
15808
  const repeatableFromSchema = templateFormSchema == null ? void 0 : templateFormSchema.repeatableSections;
15796
15809
  if ((repeatableFromSchema == null ? void 0 : repeatableFromSchema.length) && templateConfig.pages) {
15797
- paintRepeatableSections(templateConfig, repeatableFromSchema);
15810
+ paintRepeatableSections(templateConfig, repeatableFromSchema, templateFormSchema == null ? void 0 : templateFormSchema.entryFilters);
15798
15811
  }
15799
15812
  const schemaSections = getRenderableFormSections(formSchema);
15800
15813
  const repeatableNodeMap = /* @__PURE__ */ new Map();
@@ -15818,6 +15831,7 @@ async function resolveFromForm(options) {
15818
15831
  } else {
15819
15832
  inferredSections = [];
15820
15833
  }
15834
+ const templateDefaultMetaSectionState = templateRow.default_data && isDefaultDataV2(templateRow.default_data) ? templateRow.default_data.sectionState : extractSectionStateCandidate(templateRow.default_data, inferredSections);
15821
15835
  const defaultFormMetaSectionState = extractSectionStateCandidate(defaultForm == null ? void 0 : defaultForm.values, inferredSections) ?? extractSectionStateCandidate(defaultForm == null ? void 0 : defaultForm.saved_data, inferredSections);
15822
15836
  let mergedSectionState = { ...sectionState };
15823
15837
  const templateDefaultData = templateRow.default_data;
@@ -15829,6 +15843,7 @@ async function resolveFromForm(options) {
15829
15843
  }
15830
15844
  }
15831
15845
  }
15846
+ mergedSectionState = mergeRepeatableEntryMeta(mergedSectionState, templateDefaultMetaSectionState, inferredSections);
15832
15847
  mergedSectionState = mergeRepeatableEntryMeta(mergedSectionState, defaultFormMetaSectionState, inferredSections);
15833
15848
  const flatFormData = flattenSectionStateToFormData(mergedSectionState, inferredSections);
15834
15849
  const dynamicFields = templateConfig.dynamicFields || [];
@@ -15881,11 +15896,17 @@ async function resolveFromForm(options) {
15881
15896
  }
15882
15897
  return void 0;
15883
15898
  };
15899
+ const entryMetaForLabel = (label) => {
15900
+ const normalized = label.trim().toLowerCase();
15901
+ const item = inferredRepeatableList.find((candidate) => candidate.label.trim().toLowerCase() === normalized);
15902
+ return { entryMeta: item == null ? void 0 : item.entryMeta, nestedEntryMeta: item == null ? void 0 : item.nestedEntryMeta };
15903
+ };
15884
15904
  const fallbackRepeatableList = (repeatableFromSchema ?? []).map((r) => ({
15885
15905
  nodeId: r.nodeId,
15886
15906
  label: r.label,
15887
15907
  entryFilter: r.entryFilter,
15888
- entryCount: entryCountForLabel(r.label)
15908
+ entryCount: entryCountForLabel(r.label),
15909
+ ...entryMetaForLabel(r.label)
15889
15910
  }));
15890
15911
  const repeatableList = inferredRepeatableList.length > 0 ? [
15891
15912
  ...inferredRepeatableList,
@@ -16949,9 +16970,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
16949
16970
  }
16950
16971
  return svgString;
16951
16972
  }
16952
- const resolvedPackageVersion = "0.5.203";
16973
+ const resolvedPackageVersion = "0.5.205";
16953
16974
  const PACKAGE_VERSION = resolvedPackageVersion;
16954
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.203";
16975
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.205";
16955
16976
  const roundParityValue = (value) => {
16956
16977
  if (typeof value !== "number") return value;
16957
16978
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -17630,7 +17651,7 @@ class PixldocsRenderer {
17630
17651
  await this.waitForCanvasScene(container, cloned, i);
17631
17652
  }
17632
17653
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
17633
- const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-xsu5ahea.cjs"));
17654
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-LmnOwVt3.cjs"));
17634
17655
  const prepared = preparePagesForExport(
17635
17656
  cloned.pages,
17636
17657
  canvasWidth,
@@ -19814,7 +19835,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
19814
19835
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
19815
19836
  sanitizeSvgTreeForPdf(svgToDraw);
19816
19837
  try {
19817
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-xsu5ahea.cjs"));
19838
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-LmnOwVt3.cjs"));
19818
19839
  try {
19819
19840
  await logTextMeasurementDiagnostic(svgToDraw);
19820
19841
  } catch {
@@ -20211,4 +20232,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
20211
20232
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
20212
20233
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
20213
20234
  exports.warmTemplateFromForm = warmTemplateFromForm;
20214
- //# sourceMappingURL=index-CZ28FLrz.cjs.map
20235
+ //# sourceMappingURL=index-CGi2L90_.cjs.map