@pixldocs/canvas-renderer 0.5.468 → 0.5.470

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.
@@ -12281,7 +12281,7 @@ const PageCanvas = forwardRef(
12281
12281
  if (id && id !== "__background__") {
12282
12282
  const width = (obj.width ?? 0) * (obj.scaleX ?? 1);
12283
12283
  const height = (obj.height ?? 0) * (obj.scaleY ?? 1);
12284
- const angle = obj.angle ?? 0;
12284
+ const angle = typeof obj.getTotalAngle === "function" ? obj.getTotalAngle() ?? 0 : obj.angle ?? 0;
12285
12285
  let left;
12286
12286
  let top;
12287
12287
  const centerFn = obj.getCenterPoint;
@@ -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;
@@ -20447,7 +20456,7 @@ function PreviewCanvas({
20447
20456
  return /* @__PURE__ */ jsx(
20448
20457
  "div",
20449
20458
  {
20450
- className: "absolute cursor-pointer transition-all duration-150",
20459
+ className: "absolute cursor-pointer",
20451
20460
  style: {
20452
20461
  left,
20453
20462
  top,
@@ -20457,23 +20466,27 @@ function PreviewCanvas({
20457
20466
  backgroundColor: isHovered ? "rgba(59, 130, 246, 0.1)" : "transparent",
20458
20467
  borderRadius: 4,
20459
20468
  pointerEvents: "auto",
20460
- transform: (bounds == null ? void 0 : bounds.angle) ? `rotate(${bounds.angle}deg)` : void 0,
20461
- transformOrigin: "center center"
20469
+ transform: `rotate(${(bounds == null ? void 0 : bounds.angle) ?? 0}deg)`,
20470
+ transformOrigin: `${width / 2}px ${height / 2}px`,
20471
+ willChange: "transform"
20462
20472
  },
20463
20473
  onMouseEnter: () => setHoveredFieldId(element.id),
20464
20474
  onMouseLeave: () => setHoveredFieldId(null),
20465
20475
  onClick: () => {
20466
- const fieldInfo = elementToFieldMap.get(element.id);
20467
- if (fieldInfo && onDynamicFieldClick) {
20468
- onDynamicFieldClick(element.id, fieldInfo.fieldId);
20476
+ const infos = elementToFieldMap.get(element.id);
20477
+ if (infos && infos.length && onDynamicFieldClick) {
20478
+ onDynamicFieldClick(element.id, infos.map((i) => i.fieldId));
20469
20479
  }
20470
20480
  },
20471
- children: isHovered && /* @__PURE__ */ jsx(
20481
+ children: isHovered && /* @__PURE__ */ jsxs(
20472
20482
  "div",
20473
20483
  {
20474
20484
  className: "absolute -top-6 left-0 bg-primary text-primary-foreground text-xs px-2 py-0.5 rounded shadow-sm whitespace-nowrap",
20475
20485
  style: { fontSize: 10 },
20476
- children: label
20486
+ children: [
20487
+ label,
20488
+ extraCount > 0 ? ` +${extraCount} more` : ""
20489
+ ]
20477
20490
  }
20478
20491
  )
20479
20492
  },
@@ -26295,9 +26308,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
26295
26308
  }
26296
26309
  return svgString;
26297
26310
  }
26298
- const resolvedPackageVersion = "0.5.468";
26311
+ const resolvedPackageVersion = "0.5.470";
26299
26312
  const PACKAGE_VERSION = resolvedPackageVersion;
26300
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.468";
26313
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.470";
26301
26314
  const roundParityValue = (value) => {
26302
26315
  if (typeof value !== "number") return value;
26303
26316
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -27111,7 +27124,7 @@ class PixldocsRenderer {
27111
27124
  await this.waitForCanvasScene(container, cloned, i);
27112
27125
  }
27113
27126
  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");
27127
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-CV7d-_nM.js");
27115
27128
  const prepared = preparePagesForExport(
27116
27129
  cloned.pages,
27117
27130
  canvasWidth,
@@ -29431,7 +29444,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
29431
29444
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
29432
29445
  sanitizeSvgTreeForPdf(svgToDraw);
29433
29446
  try {
29434
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-C7FmPpVD.js");
29447
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-CV7d-_nM.js");
29435
29448
  try {
29436
29449
  await logTextMeasurementDiagnostic(svgToDraw);
29437
29450
  } catch {
@@ -29748,4 +29761,4 @@ export {
29748
29761
  buildTeaserBlurFlatKeys as y,
29749
29762
  collectFontDescriptorsFromConfig as z
29750
29763
  };
29751
- //# sourceMappingURL=index-CGFOtPDx.js.map
29764
+ //# sourceMappingURL=index-DqhyGc11.js.map