@pixldocs/canvas-renderer 0.5.468 → 0.5.469

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.
@@ -20231,27 +20231,32 @@ PageCanvas.displayName = "PageCanvas";
20231
20231
  function buildElementToFieldMap(dynamicFields) {
20232
20232
  const map = /* @__PURE__ */ new Map();
20233
20233
  if (!dynamicFields) return map;
20234
- for (const field of dynamicFields) {
20234
+ const ordered = dynamicFields.map((f, idx) => ({ f, idx })).sort((a, b) => {
20235
+ const ao = a.f.order ?? Number.POSITIVE_INFINITY;
20236
+ const bo = b.f.order ?? Number.POSITIVE_INFINITY;
20237
+ if (ao !== bo) return ao - bo;
20238
+ return a.idx - b.idx;
20239
+ });
20240
+ const push = (elementId, info) => {
20241
+ const list = map.get(elementId);
20242
+ if (list) list.push(info);
20243
+ else map.set(elementId, [info]);
20244
+ };
20245
+ ordered.forEach(({ f: field }, formIndex) => {
20235
20246
  if (field.mappings && Array.isArray(field.mappings)) {
20236
20247
  for (const mapping of field.mappings) {
20237
20248
  if (mapping.elementId) {
20238
- map.set(mapping.elementId, {
20239
- fieldId: field.id,
20240
- label: field.label
20241
- });
20249
+ push(mapping.elementId, { fieldId: field.id, label: field.label, formIndex });
20242
20250
  }
20243
20251
  }
20244
20252
  } else if (field.elementIds && Array.isArray(field.elementIds)) {
20245
20253
  for (const elementId of field.elementIds) {
20246
20254
  if (elementId) {
20247
- map.set(elementId, {
20248
- fieldId: field.id,
20249
- label: field.label
20250
- });
20255
+ push(elementId, { fieldId: field.id, label: field.label, formIndex });
20251
20256
  }
20252
20257
  }
20253
20258
  }
20254
- }
20259
+ });
20255
20260
  return map;
20256
20261
  }
20257
20262
  function PreviewCanvas({
@@ -20342,9 +20347,9 @@ function PreviewCanvas({
20342
20347
  };
20343
20348
  }, [config.themeConfig]);
20344
20349
  const handleDynamicFieldClick = useCallback((elementId) => {
20345
- const fieldInfo = elementToFieldMap.get(elementId);
20346
- if (fieldInfo && onDynamicFieldClick) {
20347
- onDynamicFieldClick(elementId, fieldInfo.fieldId);
20350
+ const infos = elementToFieldMap.get(elementId);
20351
+ if (infos && infos.length && onDynamicFieldClick) {
20352
+ onDynamicFieldClick(elementId, infos.map((i) => i.fieldId));
20348
20353
  }
20349
20354
  }, [elementToFieldMap, onDynamicFieldClick]);
20350
20355
  const dynamicFieldElements = useMemo(() => {
@@ -20352,10 +20357,14 @@ function PreviewCanvas({
20352
20357
  const seenIds = /* @__PURE__ */ new Set();
20353
20358
  for (const element of elements) {
20354
20359
  if (seenIds.has(element.id)) continue;
20355
- const fieldInfo = elementToFieldMap.get(element.id);
20356
- if (fieldInfo) {
20360
+ const infos = elementToFieldMap.get(element.id);
20361
+ if (infos && infos.length) {
20357
20362
  seenIds.add(element.id);
20358
- result.push({ element, label: fieldInfo.label });
20363
+ result.push({
20364
+ element,
20365
+ label: infos[0].label,
20366
+ extraCount: Math.max(0, infos.length - 1)
20367
+ });
20359
20368
  }
20360
20369
  }
20361
20370
  return result;
@@ -20429,7 +20438,7 @@ function PreviewCanvas({
20429
20438
  onReady
20430
20439
  }
20431
20440
  ),
20432
- onDynamicFieldClick && dynamicFieldElements.map(({ element, label }) => {
20441
+ onDynamicFieldClick && dynamicFieldElements.map(({ element, label, extraCount }) => {
20433
20442
  const bounds = actualBounds.get(element.id);
20434
20443
  const isHovered = hoveredFieldId === element.id;
20435
20444
  let left, top, width, height;
@@ -20463,17 +20472,20 @@ function PreviewCanvas({
20463
20472
  onMouseEnter: () => setHoveredFieldId(element.id),
20464
20473
  onMouseLeave: () => setHoveredFieldId(null),
20465
20474
  onClick: () => {
20466
- const fieldInfo = elementToFieldMap.get(element.id);
20467
- if (fieldInfo && onDynamicFieldClick) {
20468
- onDynamicFieldClick(element.id, fieldInfo.fieldId);
20475
+ const infos = elementToFieldMap.get(element.id);
20476
+ if (infos && infos.length && onDynamicFieldClick) {
20477
+ onDynamicFieldClick(element.id, infos.map((i) => i.fieldId));
20469
20478
  }
20470
20479
  },
20471
- children: isHovered && /* @__PURE__ */ jsx(
20480
+ children: isHovered && /* @__PURE__ */ jsxs(
20472
20481
  "div",
20473
20482
  {
20474
20483
  className: "absolute -top-6 left-0 bg-primary text-primary-foreground text-xs px-2 py-0.5 rounded shadow-sm whitespace-nowrap",
20475
20484
  style: { fontSize: 10 },
20476
- children: label
20485
+ children: [
20486
+ label,
20487
+ extraCount > 0 ? ` +${extraCount} more` : ""
20488
+ ]
20477
20489
  }
20478
20490
  )
20479
20491
  },
@@ -26295,9 +26307,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
26295
26307
  }
26296
26308
  return svgString;
26297
26309
  }
26298
- const resolvedPackageVersion = "0.5.468";
26310
+ const resolvedPackageVersion = "0.5.469";
26299
26311
  const PACKAGE_VERSION = resolvedPackageVersion;
26300
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.468";
26312
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.469";
26301
26313
  const roundParityValue = (value) => {
26302
26314
  if (typeof value !== "number") return value;
26303
26315
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -27111,7 +27123,7 @@ class PixldocsRenderer {
27111
27123
  await this.waitForCanvasScene(container, cloned, i);
27112
27124
  }
27113
27125
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
27114
- const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-C7FmPpVD.js");
27126
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-CKIO3hJy.js");
27115
27127
  const prepared = preparePagesForExport(
27116
27128
  cloned.pages,
27117
27129
  canvasWidth,
@@ -29431,7 +29443,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
29431
29443
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
29432
29444
  sanitizeSvgTreeForPdf(svgToDraw);
29433
29445
  try {
29434
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-C7FmPpVD.js");
29446
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-CKIO3hJy.js");
29435
29447
  try {
29436
29448
  await logTextMeasurementDiagnostic(svgToDraw);
29437
29449
  } catch {
@@ -29748,4 +29760,4 @@ export {
29748
29760
  buildTeaserBlurFlatKeys as y,
29749
29761
  collectFontDescriptorsFromConfig as z
29750
29762
  };
29751
- //# sourceMappingURL=index-CGFOtPDx.js.map
29763
+ //# sourceMappingURL=index-P777JY1z.js.map