@pixldocs/canvas-renderer 0.5.202 → 0.5.204

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)) {
@@ -15881,11 +15894,17 @@ async function resolveFromForm(options) {
15881
15894
  }
15882
15895
  return void 0;
15883
15896
  };
15897
+ const entryMetaForLabel = (label) => {
15898
+ const normalized = label.trim().toLowerCase();
15899
+ const item = inferredRepeatableList.find((candidate) => candidate.label.trim().toLowerCase() === normalized);
15900
+ return { entryMeta: item == null ? void 0 : item.entryMeta, nestedEntryMeta: item == null ? void 0 : item.nestedEntryMeta };
15901
+ };
15884
15902
  const fallbackRepeatableList = (repeatableFromSchema ?? []).map((r) => ({
15885
15903
  nodeId: r.nodeId,
15886
15904
  label: r.label,
15887
15905
  entryFilter: r.entryFilter,
15888
- entryCount: entryCountForLabel(r.label)
15906
+ entryCount: entryCountForLabel(r.label),
15907
+ ...entryMetaForLabel(r.label)
15889
15908
  }));
15890
15909
  const repeatableList = inferredRepeatableList.length > 0 ? [
15891
15910
  ...inferredRepeatableList,
@@ -16096,6 +16115,12 @@ function paintRepeatableSections(config, repeatableSections) {
16096
16115
  function setRepeatable(nodes, nodeId, payload) {
16097
16116
  for (const node of nodes) {
16098
16117
  const id = node.id;
16118
+ if (node.repeatableSection) {
16119
+ if (Array.isArray(node.children) && setRepeatable(node.children, nodeId, payload)) {
16120
+ return true;
16121
+ }
16122
+ continue;
16123
+ }
16099
16124
  if (id && (id === nodeId || baseId(id) === baseId(nodeId))) {
16100
16125
  node.repeatableSection = payload;
16101
16126
  return true;
@@ -16943,9 +16968,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
16943
16968
  }
16944
16969
  return svgString;
16945
16970
  }
16946
- const resolvedPackageVersion = "0.5.202";
16971
+ const resolvedPackageVersion = "0.5.204";
16947
16972
  const PACKAGE_VERSION = resolvedPackageVersion;
16948
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.202";
16973
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.204";
16949
16974
  const roundParityValue = (value) => {
16950
16975
  if (typeof value !== "number") return value;
16951
16976
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -17624,7 +17649,7 @@ class PixldocsRenderer {
17624
17649
  await this.waitForCanvasScene(container, cloned, i);
17625
17650
  }
17626
17651
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
17627
- const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-DCyVRj7e.cjs"));
17652
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-BzQh8tO6.cjs"));
17628
17653
  const prepared = preparePagesForExport(
17629
17654
  cloned.pages,
17630
17655
  canvasWidth,
@@ -19808,7 +19833,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
19808
19833
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
19809
19834
  sanitizeSvgTreeForPdf(svgToDraw);
19810
19835
  try {
19811
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-DCyVRj7e.cjs"));
19836
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-BzQh8tO6.cjs"));
19812
19837
  try {
19813
19838
  await logTextMeasurementDiagnostic(svgToDraw);
19814
19839
  } catch {
@@ -20205,4 +20230,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
20205
20230
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
20206
20231
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
20207
20232
  exports.warmTemplateFromForm = warmTemplateFromForm;
20208
- //# sourceMappingURL=index-BfMO-VrX.cjs.map
20233
+ //# sourceMappingURL=index-pfkM2NbI.cjs.map