labellife-design-tool 2.4.1 → 2.4.3

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.
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var react = require('react');
5
+ var React = require('react');
6
6
  var reactKonva = require('react-konva');
7
7
  var mobxReactLite = require('mobx-react-lite');
8
8
  var material = require('@mui/material');
@@ -519,9 +519,9 @@ var VIEWPORT_PAD = 400; // page units of dim area rendered around the crop rect
519
519
  var CropEditor = mobxReactLite.observer(function (_ref) {
520
520
  var element = _ref.element,
521
521
  image = _ref.image;
522
- var rectRef = react.useRef(null);
523
- var transformerRef = react.useRef(null);
524
- react.useEffect(function () {
522
+ var rectRef = React.useRef(null);
523
+ var transformerRef = React.useRef(null);
524
+ React.useEffect(function () {
525
525
  if (transformerRef.current && rectRef.current) {
526
526
  var _transformerRef$curre;
527
527
  transformerRef.current.nodes([rectRef.current]);
@@ -694,19 +694,19 @@ var ImageElementComponent = mobxReactLite.observer(function (_ref) {
694
694
  onDragEnd = _ref.onDragEnd,
695
695
  groupChild = _ref.groupChild,
696
696
  store = _ref.store;
697
- var imageRef = react.useRef(null);
698
- var groupRef = react.useRef(null);
699
- var _useState = react.useState(null),
697
+ var imageRef = React.useRef(null);
698
+ var groupRef = React.useRef(null);
699
+ var _useState = React.useState(null),
700
700
  _useState2 = _slicedToArray(_useState, 2),
701
701
  image = _useState2[0],
702
702
  setImage = _useState2[1];
703
703
 
704
704
  // Persistent auto-crop state: tracks the visible portion of the source image.
705
705
  // Initialized on image load (cover-fit centered), then updated directionally on resize.
706
- var autoCropRef = react.useRef(null);
707
- var autoCropSrcRef = react.useRef(null); // tracks which image the crop was computed for
706
+ var autoCropRef = React.useRef(null);
707
+ var autoCropSrcRef = React.useRef(null); // tracks which image the crop was computed for
708
708
 
709
- react.useEffect(function () {
709
+ React.useEffect(function () {
710
710
  if (!element.src) {
711
711
  setImage(null);
712
712
  return;
@@ -736,7 +736,7 @@ var ImageElementComponent = mobxReactLite.observer(function (_ref) {
736
736
  var needsCache = hasFilters || element.cornerRadius > 0 || element.shadowEnabled;
737
737
 
738
738
  // Cache the image node whenever filters, cornerRadius, or shadow change so they take effect
739
- react.useEffect(function () {
739
+ React.useEffect(function () {
740
740
  var node = imageRef.current;
741
741
  if (!node || !image) return;
742
742
  if (needsCache) {
@@ -1020,6 +1020,203 @@ var ImageElementComponent = mobxReactLite.observer(function (_ref) {
1020
1020
  });
1021
1021
  ImageElementComponent.displayName = 'ImageElement';
1022
1022
 
1023
+ // Composes a canvas/Konva font-style string (e.g. "italic bold") from the
1024
+ // element model's separate fontStyle/fontWeight fields. Shared by
1025
+ // text-element.js (KonvaText) and curved-text.js (custom Shape), which
1026
+ // both need to build a canvas `ctx.font` / Konva fontStyle string the same
1027
+ // way.
1028
+ function composeFontStyle(fontStyle, fontWeight) {
1029
+ var parts = [];
1030
+ var style = String(fontStyle || '').trim();
1031
+ var weight = String(fontWeight || '').trim();
1032
+ if (style === 'italic' || style.includes('italic')) parts.push('italic');
1033
+ if (weight && weight !== 'normal') parts.push(weight);
1034
+ return parts.length > 0 ? parts.join(' ') : 'normal';
1035
+ }
1036
+
1037
+ // src/canvas/curved-text-geometry.js
1038
+ //
1039
+ // Pure, framework-free geometry math for the curved-text effect.
1040
+ // Deliberately authored as CommonJS (not ESM like the rest of src/canvas)
1041
+ // so this one file can be unit-tested with plain `node`, no jest/babel
1042
+ // required — this repo has no test framework installed. Rollup's
1043
+ // commonjs() plugin (already in rollup.config.mjs) interops this into the
1044
+ // ESM build correctly when curved-text.js imports it with `import`.
1045
+
1046
+ // At curvePower = 100 (max), the radius is this many multiples of
1047
+ // fontSize. Tuned empirically: 3x let realistic multi-word labels wrap
1048
+ // into a nearly-closed loop well before the slider reached 100 (e.g. a
1049
+ // ~500px-wide line swept ~341° — individual glyphs rotate past horizontal
1050
+ // once a line wraps past ~180°, which read as "letters rotating wrong").
1051
+ // 6x keeps the same line under ~170° at max curvePower, a clearly-open arc.
1052
+ // Adjust this constant (and re-run curved-text-geometry.test.js, which
1053
+ // exercises it) if the on-screen result needs to be tighter/looser.
1054
+ var MAX_RADIUS_FONT_MULTIPLIER = 6;
1055
+
1056
+ // Maps curvePower (-100..100) to a positive radius magnitude in px.
1057
+ // Direction (smile vs frown) is NOT encoded here — callers apply
1058
+ // Math.sign(curvePower) separately (see curved-text.js). curvePower = 0
1059
+ // returns Infinity (a "straight line" radius) for defensiveness, though
1060
+ // callers should treat curvePower === 0 as "don't curve at all" before
1061
+ // reaching here (falls back to plain KonvaText).
1062
+ function computeArcRadius(curvePower, fontSize) {
1063
+ var power = Math.abs(curvePower);
1064
+ if (power === 0) return Infinity;
1065
+ return fontSize * MAX_RADIUS_FONT_MULTIPLIER / (power / 100);
1066
+ }
1067
+
1068
+ // Computes the radius for line `lineIndex` (0-based, top to bottom) of a
1069
+ // multi-line curved text block, so all lines share one arc center
1070
+ // (concentric) and stack in normal reading order.
1071
+ //
1072
+ // For curvePower > 0 ("smile", center below the text), later lines move
1073
+ // closer to the center (smaller radius). For curvePower < 0 ("frown",
1074
+ // center above the text), later lines move away from the center (larger
1075
+ // radius).
1076
+ function computeLineRadius(baseRadius, lineIndex, lineHeight, curvePower) {
1077
+ var direction = curvePower > 0 ? -1 : 1;
1078
+ return baseRadius + lineIndex * lineHeight * direction;
1079
+ }
1080
+
1081
+ // Distributes characters of one line along an arc of the given radius,
1082
+ // centered so the line's midpoint sits at angle 0 — i.e. center-aligned.
1083
+ //
1084
+ // charWidths: array of per-glyph advance widths (px), in reading order.
1085
+ // radius: positive, finite radius magnitude (px) for this line.
1086
+ //
1087
+ // Returns an array, one entry per character, each: { angle } — the angle
1088
+ // (radians) from the arc's center-line, in reading order. Callers convert
1089
+ // `angle` + `radius` into an (x, y) position and a tangent rotation for
1090
+ // drawing (see curved-text.js).
1091
+ function layoutCharsOnArc(charWidths, radius) {
1092
+ if (!Number.isFinite(radius) || radius <= 0) {
1093
+ throw new Error('layoutCharsOnArc requires a finite, positive radius');
1094
+ }
1095
+ var totalWidth = charWidths.reduce(function (sum, w) {
1096
+ return sum + w;
1097
+ }, 0);
1098
+ var totalAngle = totalWidth / radius;
1099
+ var cumBefore = 0;
1100
+ return charWidths.map(function (w) {
1101
+ var cumMid = cumBefore + w / 2;
1102
+ cumBefore += w;
1103
+ var angleFromStart = cumMid / radius;
1104
+ return {
1105
+ angle: angleFromStart - totalAngle / 2
1106
+ };
1107
+ });
1108
+ }
1109
+ var curvedTextGeometry = {
1110
+ computeArcRadius: computeArcRadius,
1111
+ computeLineRadius: computeLineRadius,
1112
+ layoutCharsOnArc: layoutCharsOnArc
1113
+ };
1114
+
1115
+ var CurvedText = mobxReactLite.observer(/*#__PURE__*/React.forwardRef(function (_ref, ref) {
1116
+ var element = _ref.element,
1117
+ displayText = _ref.displayText,
1118
+ width = _ref.width;
1119
+ var fontStyleStr = composeFontStyle(element.fontStyle, element.fontWeight);
1120
+ var lineHeightMultiplier = typeof element.lineHeight === 'number' ? element.lineHeight : parseFloat(element.lineHeight) || 1.2;
1121
+ var lineHeightPx = element.fontSize * lineHeightMultiplier;
1122
+ var letterSpacing = element.letterSpacing || 0;
1123
+ var curvePower = element.curvePower;
1124
+
1125
+ // Precondition: caller must not mount this component with curvePower === 0.
1126
+ // Defensive guard to avoid passing Infinity to layoutCharsOnArc.
1127
+ if (curvePower === 0) return null;
1128
+ var direction = curvePower > 0 ? 1 : -1;
1129
+ var baseRadius = curvedTextGeometry.computeArcRadius(curvePower, element.fontSize);
1130
+ var lines = (displayText || '').split('\n');
1131
+
1132
+ // Shared per-character geometry: walks every line/character and invokes
1133
+ // `draw(ctx, ch, x, y, angle)` inside the same save/translate/rotate/
1134
+ // restore frame. Used by both sceneFunc (real glyph fill/stroke) and
1135
+ // hitFunc (hit-region rects) so the clickable area always matches what's
1136
+ // actually painted — duplicating this math between the two would risk
1137
+ // them drifting apart.
1138
+ var forEachChar = function forEachChar(ctx, draw) {
1139
+ var centerX = width / 2;
1140
+ lines.forEach(function (lineText, lineIndex) {
1141
+ var chars = Array.from(lineText);
1142
+ if (chars.length === 0) return;
1143
+ var charWidths = chars.map(function (ch) {
1144
+ return ctx.measureText(ch).width + letterSpacing;
1145
+ });
1146
+ var lineRadius = curvedTextGeometry.computeLineRadius(baseRadius, lineIndex, lineHeightPx, curvePower);
1147
+ var signedRadius = direction * lineRadius;
1148
+ var baselineY = lineIndex * lineHeightPx + element.fontSize;
1149
+ var centerY = baselineY + signedRadius;
1150
+ var layout = curvedTextGeometry.layoutCharsOnArc(charWidths, lineRadius);
1151
+ chars.forEach(function (ch, idx) {
1152
+ var angle = layout[idx].angle;
1153
+ var x = centerX + lineRadius * Math.sin(angle);
1154
+ var y = centerY - signedRadius * Math.cos(angle);
1155
+ draw(ctx, ch, x, y, angle, charWidths[idx]);
1156
+ });
1157
+ });
1158
+ };
1159
+ return /*#__PURE__*/jsxRuntime.jsx(reactKonva.Shape, {
1160
+ ref: ref,
1161
+ width: width,
1162
+ height: lines.length * lineHeightPx,
1163
+ sceneFunc: function sceneFunc(ctx) {
1164
+ ctx.font = "".concat(fontStyleStr, " ").concat(element.fontSize, "px \"").concat(element.fontFamily, "\"");
1165
+ ctx.textAlign = 'center';
1166
+ ctx.textBaseline = 'alphabetic';
1167
+ forEachChar(ctx, function (c, ch, x, y, angle) {
1168
+ c.save();
1169
+ c.translate(x, y);
1170
+ c.rotate(direction * angle);
1171
+ if (element.strokeWidth > 0) {
1172
+ c.strokeStyle = element.stroke || '#000000';
1173
+ c.lineWidth = element.strokeWidth;
1174
+ c.strokeText(ch, 0, 0);
1175
+ }
1176
+ c.fillStyle = element.fill;
1177
+ c.fillText(ch, 0, 0);
1178
+ c.restore();
1179
+ });
1180
+ },
1181
+ hitFunc: function hitFunc(ctx, shape) {
1182
+ ctx.font = "".concat(fontStyleStr, " ").concat(element.fontSize, "px \"").concat(element.fontFamily, "\"");
1183
+ ctx.textAlign = 'center';
1184
+ ctx.textBaseline = 'alphabetic';
1185
+ ctx.beginPath();
1186
+ forEachChar(ctx, function (c, ch, x, y, angle, charWidth) {
1187
+ c.save();
1188
+ c.translate(x, y);
1189
+ c.rotate(direction * angle);
1190
+ c.rect(-charWidth / 2, -element.fontSize * 0.8, charWidth, element.fontSize * 1.1);
1191
+ c.restore();
1192
+ });
1193
+ ctx.fillStrokeShape(shape);
1194
+ }
1195
+ });
1196
+ }));
1197
+ CurvedText.displayName = 'CurvedText';
1198
+
1199
+ function computeCurvedCacheBounds(element) {
1200
+ var lineCount = (element.text || element.placeholder || '').split('\n').length;
1201
+ var lineHeightMultiplier = typeof element.lineHeight === 'number' ? element.lineHeight : parseFloat(element.lineHeight) || 1.2;
1202
+ var lineHeightPx = element.fontSize * lineHeightMultiplier;
1203
+ var baseRadius = curvedTextGeometry.computeArcRadius(element.curvePower, element.fontSize);
1204
+ var halfChord = element.width / 2;
1205
+ var maxSagitta = 0;
1206
+ for (var lineIndex = 0; lineIndex < lineCount; lineIndex++) {
1207
+ var lineRadius = curvedTextGeometry.computeLineRadius(baseRadius, lineIndex, lineHeightPx, element.curvePower);
1208
+ var sagitta = halfChord >= lineRadius ? lineRadius : lineRadius - Math.sqrt(lineRadius * lineRadius - halfChord * halfChord);
1209
+ if (sagitta > maxSagitta) maxSagitta = sagitta;
1210
+ }
1211
+ var declaredHeight = lineCount * lineHeightPx;
1212
+ var xPad = maxSagitta / 2;
1213
+ return {
1214
+ x: -xPad,
1215
+ y: -maxSagitta,
1216
+ width: element.width + xPad * 2,
1217
+ height: declaredHeight + maxSagitta * 2
1218
+ };
1219
+ }
1023
1220
  var TextElementComponent = mobxReactLite.observer(function (_ref) {
1024
1221
  var _element$backgroundOp;
1025
1222
  var element = _ref.element;
@@ -1028,19 +1225,30 @@ var TextElementComponent = mobxReactLite.observer(function (_ref) {
1028
1225
  onTransformEnd = _ref.onTransformEnd,
1029
1226
  onDragEnd = _ref.onDragEnd,
1030
1227
  groupChild = _ref.groupChild;
1031
- var groupRef = react.useRef(null);
1032
- var textRef = react.useRef(null);
1033
- var _useState = react.useState(element.height || 50),
1228
+ var groupRef = React.useRef(null);
1229
+ var textRef = React.useRef(null);
1230
+ var _useState = React.useState(element.height || 50),
1034
1231
  _useState2 = _slicedToArray(_useState, 2),
1035
1232
  textHeight = _useState2[0],
1036
1233
  setTextHeight = _useState2[1];
1234
+ var isCurved = element.curveEnabled && element.curvePower !== 0;
1037
1235
 
1038
1236
  // Force Konva to recalculate text layout when fonts finish loading.
1039
- react.useEffect(function () {
1237
+ React.useEffect(function () {
1040
1238
  var onFontLoaded = function onFontLoaded() {
1041
- var _node$getLayer;
1239
+ var _node$getLayer2;
1042
1240
  var node = textRef.current;
1043
1241
  if (!node) return;
1242
+
1243
+ // CurvedText's sceneFunc re-measures glyphs via ctx.measureText on
1244
+ // every draw (no internal cached layout like Konva.Text has), so
1245
+ // there's no stale-layout workaround needed — just repaint.
1246
+ if (element.curveEnabled && element.curvePower !== 0) {
1247
+ var _node$getLayer;
1248
+ if (element.blurEnabled) node.cache(computeCurvedCacheBounds(element));
1249
+ (_node$getLayer = node.getLayer()) === null || _node$getLayer === void 0 || _node$getLayer.batchDraw();
1250
+ return;
1251
+ }
1044
1252
  var f = node.fontFamily();
1045
1253
  node.fontFamily('serif');
1046
1254
  node.fontFamily(f);
@@ -1055,7 +1263,7 @@ var TextElementComponent = mobxReactLite.observer(function (_ref) {
1055
1263
  if (element.blurEnabled && node) {
1056
1264
  node.cache();
1057
1265
  }
1058
- (_node$getLayer = node.getLayer()) === null || _node$getLayer === void 0 || _node$getLayer.batchDraw();
1266
+ (_node$getLayer2 = node.getLayer()) === null || _node$getLayer2 === void 0 || _node$getLayer2.batchDraw();
1059
1267
  };
1060
1268
  document.fonts.addEventListener('loadingdone', onFontLoaded);
1061
1269
  return function () {
@@ -1064,7 +1272,10 @@ var TextElementComponent = mobxReactLite.observer(function (_ref) {
1064
1272
  }, []);
1065
1273
 
1066
1274
  // Sync Konva auto-sized height back to element model after text reflows
1067
- react.useEffect(function () {
1275
+ // (straight text only — curved text's height is computed synchronously
1276
+ // below, since it doesn't width-wrap and doesn't need a measured node).
1277
+ React.useEffect(function () {
1278
+ if (element.curveEnabled && element.curvePower !== 0) return;
1068
1279
  var node = textRef.current;
1069
1280
  if (!node) return;
1070
1281
  var frame = requestAnimationFrame(function () {
@@ -1079,23 +1290,40 @@ var TextElementComponent = mobxReactLite.observer(function (_ref) {
1079
1290
  return function () {
1080
1291
  return cancelAnimationFrame(frame);
1081
1292
  };
1082
- }, [element.text, element.fontSize, element.fontFamily, element.fontWeight, element.width]);
1293
+ }, [element.text, element.fontSize, element.fontFamily, element.fontWeight, element.width, element.curveEnabled, element.curvePower]);
1294
+
1295
+ // Curved text: height is deterministic from line count (no width-based
1296
+ // wrapping), so sync it directly without waiting on Konva measurement.
1297
+ React.useEffect(function () {
1298
+ if (!(element.curveEnabled && element.curvePower !== 0)) return;
1299
+ var lineCount = (element.text || element.placeholder || '').split('\n').length;
1300
+ var lineHeightMultiplier = typeof element.lineHeight === 'number' ? element.lineHeight : parseFloat(element.lineHeight) || 1.2;
1301
+ var h = lineCount * element.fontSize * lineHeightMultiplier;
1302
+ setTextHeight(h);
1303
+ if (Math.abs(h - element.height) > 1) element.set({
1304
+ height: h
1305
+ });
1306
+ }, [element.text, element.placeholder, element.fontSize, element.lineHeight, element.curveEnabled, element.curvePower]);
1083
1307
 
1084
1308
  // Apply blur filter: cache the text node when blur is enabled
1085
- react.useEffect(function () {
1086
- var _node$getLayer2;
1309
+ React.useEffect(function () {
1310
+ var _node$getLayer3;
1087
1311
  var node = textRef.current;
1088
1312
  if (!node) return;
1089
1313
  if (element.blurEnabled) {
1090
1314
  node.filters([Konva.Filters.Blur]);
1091
1315
  node.blurRadius(element.blurRadius);
1092
- node.cache();
1316
+ if (isCurved) {
1317
+ node.cache(computeCurvedCacheBounds(element));
1318
+ } else {
1319
+ node.cache();
1320
+ }
1093
1321
  } else {
1094
1322
  node.filters([]);
1095
1323
  node.clearCache();
1096
1324
  }
1097
- (_node$getLayer2 = node.getLayer()) === null || _node$getLayer2 === void 0 || _node$getLayer2.batchDraw();
1098
- }, [element.blurEnabled, element.blurRadius, element.text, element.fontSize, element.width]);
1325
+ (_node$getLayer3 = node.getLayer()) === null || _node$getLayer3 === void 0 || _node$getLayer3.batchDraw();
1326
+ }, [element.blurEnabled, element.blurRadius, element.text, element.fontSize, element.width, isCurved, element.curvePower, element.lineHeight]);
1099
1327
  if (!element.visible) return null;
1100
1328
  var handleDragEnd = function handleDragEnd(e) {
1101
1329
  element.set({
@@ -1120,7 +1348,9 @@ var TextElementComponent = mobxReactLite.observer(function (_ref) {
1120
1348
  var tNode = textRef.current;
1121
1349
  if (tNode) {
1122
1350
  tNode.width(newWidth);
1123
- tNode.fontSize(newFontSize);
1351
+ if (typeof tNode.fontSize === 'function') {
1352
+ tNode.fontSize(newFontSize);
1353
+ }
1124
1354
  }
1125
1355
  node.scaleX(1);
1126
1356
  node.scaleY(1);
@@ -1155,8 +1385,10 @@ var TextElementComponent = mobxReactLite.observer(function (_ref) {
1155
1385
  var cssFontWeight = String(element.fontWeight || 'normal');
1156
1386
  var originalText = element.text;
1157
1387
  var textarea = document.createElement('textarea');
1158
- textarea.value = '';
1159
- textarea.placeholder = originalText;
1388
+ textarea.value = originalText;
1389
+ // Only show the dimmed placeholder hint when there's no real text yet
1390
+ // (e.g. a freshly-added text element) — not when editing existing text.
1391
+ textarea.placeholder = originalText ? '' : element.placeholder;
1160
1392
  textarea.style.position = 'absolute';
1161
1393
  textarea.style.top = "".concat(textPosition.y, "px");
1162
1394
  textarea.style.left = "".concat(textPosition.x, "px");
@@ -1196,12 +1428,14 @@ var TextElementComponent = mobxReactLite.observer(function (_ref) {
1196
1428
  stageContainer.appendChild(placeholderStyle);
1197
1429
  stageContainer.appendChild(textarea);
1198
1430
  textarea.focus();
1431
+ var caretPos = textarea.value.length;
1432
+ textarea.setSelectionRange(caretPos, caretPos);
1199
1433
  var removed = false;
1200
1434
  var removeTextarea = function removeTextarea() {
1201
1435
  var cancel = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
1202
1436
  if (removed) return;
1203
1437
  removed = true;
1204
- var newText = !cancel && textarea.value.length > 0 ? textarea.value : originalText;
1438
+ var newText = cancel ? originalText : textarea.value;
1205
1439
  element.set({
1206
1440
  text: newText
1207
1441
  });
@@ -1234,14 +1468,7 @@ var TextElementComponent = mobxReactLite.observer(function (_ref) {
1234
1468
  return c.toUpperCase();
1235
1469
  });
1236
1470
  }
1237
- var fontStyleStr = function () {
1238
- var parts = [];
1239
- var style = String(element.fontStyle || '').trim();
1240
- var weight = String(element.fontWeight || '').trim();
1241
- if (style === 'italic' || style.includes('italic')) parts.push('italic');
1242
- if (weight && weight !== 'normal') parts.push(weight);
1243
- return parts.length > 0 ? parts.join(' ') : 'normal';
1244
- }();
1471
+ var fontStyleStr = composeFontStyle(element.fontStyle, element.fontWeight);
1245
1472
  var pad = element.backgroundEnabled ? element.backgroundPadding || 0 : 0;
1246
1473
  return /*#__PURE__*/jsxRuntime.jsxs(reactKonva.Group, {
1247
1474
  ref: groupRef,
@@ -1275,7 +1502,12 @@ var TextElementComponent = mobxReactLite.observer(function (_ref) {
1275
1502
  opacity: (_element$backgroundOp = element.backgroundOpacity) !== null && _element$backgroundOp !== void 0 ? _element$backgroundOp : 1,
1276
1503
  cornerRadius: element.backgroundCornerRadius || 0,
1277
1504
  listening: false
1278
- }), /*#__PURE__*/jsxRuntime.jsx(reactKonva.Text, {
1505
+ }), isCurved ? /*#__PURE__*/jsxRuntime.jsx(CurvedText, {
1506
+ ref: textRef,
1507
+ element: element,
1508
+ displayText: displayText,
1509
+ width: element.width
1510
+ }) : /*#__PURE__*/jsxRuntime.jsx(reactKonva.Text, {
1279
1511
  ref: textRef,
1280
1512
  text: displayText,
1281
1513
  width: element.width,
@@ -1310,12 +1542,12 @@ var SVGElementComponent = mobxReactLite.observer(function (_ref) {
1310
1542
  onTransformEnd = _ref.onTransformEnd,
1311
1543
  onDragEnd = _ref.onDragEnd,
1312
1544
  groupChild = _ref.groupChild;
1313
- var imageRef = react.useRef(null);
1314
- var _useState = react.useState(null),
1545
+ var imageRef = React.useRef(null);
1546
+ var _useState = React.useState(null),
1315
1547
  _useState2 = _slicedToArray(_useState, 2),
1316
1548
  image = _useState2[0],
1317
1549
  setImage = _useState2[1];
1318
- react.useEffect(function () {
1550
+ React.useEffect(function () {
1319
1551
  if (!element.src) {
1320
1552
  setImage(null);
1321
1553
  return;
@@ -1419,7 +1651,7 @@ var FigureElementComponent = mobxReactLite.observer(function (_ref) {
1419
1651
  onTransformEnd = _ref.onTransformEnd,
1420
1652
  onDragEnd = _ref.onDragEnd,
1421
1653
  groupChild = _ref.groupChild;
1422
- var shapeRef = react.useRef(null);
1654
+ var shapeRef = React.useRef(null);
1423
1655
  if (!element.visible) return null;
1424
1656
  var handleDragEnd = function handleDragEnd(e) {
1425
1657
  element.set({
@@ -1686,8 +1918,8 @@ var LineElementComponent = mobxReactLite.observer(function (_ref) {
1686
1918
  shadowOpacity: element.shadowOpacity,
1687
1919
  onDragEnd: handleLineDragEnd
1688
1920
  });
1689
- return /*#__PURE__*/jsxRuntime.jsxs(react.Fragment, {
1690
- children: [lineNode, isSelected && /*#__PURE__*/jsxRuntime.jsxs(react.Fragment, {
1921
+ return /*#__PURE__*/jsxRuntime.jsxs(React.Fragment, {
1922
+ children: [lineNode, isSelected && /*#__PURE__*/jsxRuntime.jsxs(React.Fragment, {
1691
1923
  children: [/*#__PURE__*/jsxRuntime.jsx(reactKonva.Rect, {
1692
1924
  x: startX - HANDLE_SIZE / 2,
1693
1925
  y: startY - HANDLE_SIZE / 2,
@@ -1722,8 +1954,8 @@ var GroupElementComponent = mobxReactLite.observer(function (_ref) {
1722
1954
  var onTransformEnd = _ref.onTransformEnd,
1723
1955
  onDragEnd = _ref.onDragEnd,
1724
1956
  _ElementRenderer = _ref._ElementRenderer;
1725
- var groupRef = react.useRef(null);
1726
- var handleDragEnd = react.useCallback(function (e) {
1957
+ var groupRef = React.useRef(null);
1958
+ var handleDragEnd = React.useCallback(function (e) {
1727
1959
  var node = e.target;
1728
1960
  element.set({
1729
1961
  x: node.x(),
@@ -1731,7 +1963,7 @@ var GroupElementComponent = mobxReactLite.observer(function (_ref) {
1731
1963
  });
1732
1964
  if (onDragEnd) onDragEnd(e);
1733
1965
  }, [element, onDragEnd]);
1734
- var handleTransformEnd = react.useCallback(function (e) {
1966
+ var handleTransformEnd = React.useCallback(function (e) {
1735
1967
  var node = groupRef.current;
1736
1968
  if (!node) return;
1737
1969
  var scaleX = node.scaleX();
@@ -1861,29 +2093,39 @@ function parseDateFromFormat(dateStr, format) {
1861
2093
  return new Date();
1862
2094
  }
1863
2095
 
2096
+ // Shared sizing for the popup's action row (Back / Continue / Do it later),
2097
+ // exported so a custom `PopupActions` component can visually match them.
2098
+ var popupActionButtonSx = {
2099
+ textTransform: 'none',
2100
+ fontSize: 21,
2101
+ py: 1.65,
2102
+ borderRadius: '10px'
2103
+ };
2104
+
1864
2105
  // ── Default single-field dialog (full-page overlay) ──────────────────
1865
2106
  var SingleFieldDialog = function SingleFieldDialog(_ref) {
1866
2107
  var field = _ref.field,
2108
+ store = _ref.store,
1867
2109
  onSubmit = _ref.onSubmit,
1868
2110
  onSkip = _ref.onSkip,
1869
2111
  onBack = _ref.onBack,
1870
2112
  canGoBack = _ref.canGoBack,
1871
2113
  currentIndex = _ref.currentIndex,
1872
2114
  totalCount = _ref.totalCount;
1873
- var _useState = react.useState(''),
2115
+ var _useState = React.useState(''),
1874
2116
  _useState2 = _slicedToArray(_useState, 2),
1875
2117
  value = _useState2[0],
1876
2118
  setValue = _useState2[1];
1877
- var _useState3 = react.useState(null),
2119
+ var _useState3 = React.useState(null),
1878
2120
  _useState4 = _slicedToArray(_useState3, 2),
1879
2121
  imagePreview = _useState4[0],
1880
2122
  setImagePreview = _useState4[1];
1881
- var fileInputRef = react.useRef(null);
1882
- var _useState5 = react.useState([]),
2123
+ var fileInputRef = React.useRef(null);
2124
+ var _useState5 = React.useState([]),
1883
2125
  _useState6 = _slicedToArray(_useState5, 2),
1884
2126
  selectedItems = _useState6[0],
1885
2127
  setSelectedItems = _useState6[1];
1886
- var _useState7 = react.useState(''),
2128
+ var _useState7 = React.useState(''),
1887
2129
  _useState8 = _slicedToArray(_useState7, 2),
1888
2130
  customRadioValue = _useState8[0],
1889
2131
  setCustomRadioValue = _useState8[1];
@@ -1901,7 +2143,7 @@ var SingleFieldDialog = function SingleFieldDialog(_ref) {
1901
2143
  var headerText = config.headerText || null;
1902
2144
  var accentColor = config.accentColor || '#0d83cd';
1903
2145
  var progressPct = Math.round((currentIndex + 1) / totalCount * 100);
1904
- react.useEffect(function () {
2146
+ React.useEffect(function () {
1905
2147
  setValue('');
1906
2148
  setImagePreview(null);
1907
2149
  setSelectedItems([]);
@@ -2424,36 +2666,30 @@ var SingleFieldDialog = function SingleFieldDialog(_ref) {
2424
2666
  mt: 4.5,
2425
2667
  flexShrink: 0
2426
2668
  },
2427
- children: [canGoBack && /*#__PURE__*/jsxRuntime.jsx(material.Button, {
2669
+ children: [config.PopupActions && /*#__PURE__*/jsxRuntime.jsx(config.PopupActions, {
2670
+ store: store
2671
+ }), canGoBack && /*#__PURE__*/jsxRuntime.jsx(material.Button, {
2428
2672
  variant: "outlined",
2429
2673
  onClick: onBack,
2430
2674
  startIcon: /*#__PURE__*/jsxRuntime.jsx(ArrowBackIcon, {}),
2431
- sx: {
2432
- textTransform: 'none',
2675
+ sx: _objectSpread2(_objectSpread2({}, popupActionButtonSx), {}, {
2433
2676
  fontWeight: 500,
2434
- fontSize: 21,
2435
2677
  px: 3,
2436
- py: 1.65,
2437
- borderRadius: '10px',
2438
2678
  color: '#555',
2439
2679
  borderColor: '#d0d5dd',
2440
2680
  '&:hover': {
2441
2681
  borderColor: '#aaa',
2442
2682
  backgroundColor: 'rgba(0,0,0,0.02)'
2443
2683
  }
2444
- },
2684
+ }),
2445
2685
  children: t('inputFieldsDialog.back', 'Back')
2446
2686
  }), /*#__PURE__*/jsxRuntime.jsx(material.Button, {
2447
2687
  variant: "contained",
2448
2688
  onClick: handleSubmit,
2449
2689
  disabled: isSubmitDisabled,
2450
- sx: _objectSpread2({
2451
- textTransform: 'none',
2690
+ sx: _objectSpread2(_objectSpread2({}, popupActionButtonSx), {}, {
2452
2691
  fontWeight: 600,
2453
- fontSize: 21,
2454
2692
  px: 5,
2455
- py: 1.65,
2456
- borderRadius: '10px',
2457
2693
  backgroundColor: accentColor,
2458
2694
  boxShadow: 'none',
2459
2695
  '&:hover': {
@@ -2467,13 +2703,9 @@ var SingleFieldDialog = function SingleFieldDialog(_ref) {
2467
2703
  onClick: function onClick() {
2468
2704
  return onSkip(field.id);
2469
2705
  },
2470
- sx: _objectSpread2({
2471
- textTransform: 'none',
2706
+ sx: _objectSpread2(_objectSpread2({}, popupActionButtonSx), {}, {
2472
2707
  fontWeight: 500,
2473
- fontSize: 21,
2474
2708
  px: 4.5,
2475
- py: 1.65,
2476
- borderRadius: '10px',
2477
2709
  color: '#555',
2478
2710
  borderColor: '#d0d5dd',
2479
2711
  '&:hover': {
@@ -2499,20 +2731,20 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
2499
2731
  backTrigger = _ref2$backTrigger === void 0 ? 0 : _ref2$backTrigger;
2500
2732
  // displayIndex counts how many fields have been answered (for step indicator only).
2501
2733
  // Navigation always uses fields[0] — the first remaining pending field.
2502
- var _useState9 = react.useState(0),
2734
+ var _useState9 = React.useState(0),
2503
2735
  _useState0 = _slicedToArray(_useState9, 2),
2504
2736
  displayIndex = _useState0[0],
2505
2737
  setDisplayIndex = _useState0[1];
2506
- var initialTotalRef = react.useRef(0);
2507
- var completedHistoryRef = react.useRef([]);
2508
- var removedDueToSkipRef = react.useRef([]);
2509
- var isGoingBackRef = react.useRef(false);
2510
- var prevBackTriggerRef = react.useRef(backTrigger);
2738
+ var initialTotalRef = React.useRef(0);
2739
+ var completedHistoryRef = React.useRef([]);
2740
+ var removedDueToSkipRef = React.useRef([]);
2741
+ var isGoingBackRef = React.useRef(false);
2742
+ var prevBackTriggerRef = React.useRef(backTrigger);
2511
2743
  var config = getInputFieldsConfig();
2512
2744
  var pendingFields = store._pendingInputFields || [];
2513
2745
 
2514
2746
  // When disabled, clear any pending fields so they are treated as skipped
2515
- react.useEffect(function () {
2747
+ React.useEffect(function () {
2516
2748
  if (!enabled && pendingFields.length > 0) {
2517
2749
  store.clearPendingInputFields();
2518
2750
  }
@@ -2522,7 +2754,7 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
2522
2754
  });
2523
2755
 
2524
2756
  // Capture total and reset display counter when a fresh batch appears
2525
- react.useEffect(function () {
2757
+ React.useEffect(function () {
2526
2758
  if (fields.length > 0 && initialTotalRef.current === 0) {
2527
2759
  if (isGoingBackRef.current) {
2528
2760
  // Back-from-summary restored a field — recover total from history + pending
@@ -2571,7 +2803,7 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
2571
2803
  }
2572
2804
  // displayIndex stays unchanged — it already points to the last step (N-1)
2573
2805
  };
2574
- react.useEffect(function () {
2806
+ React.useEffect(function () {
2575
2807
  if (backTrigger !== prevBackTriggerRef.current) {
2576
2808
  prevBackTriggerRef.current = backTrigger;
2577
2809
  handleBackFromSummary();
@@ -2716,6 +2948,7 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
2716
2948
  }
2717
2949
  return /*#__PURE__*/jsxRuntime.jsx(SingleFieldDialog, {
2718
2950
  field: currentField,
2951
+ store: store,
2719
2952
  onSubmit: handleSubmit,
2720
2953
  onSkip: handleSkip,
2721
2954
  onBack: handleBack,
@@ -2752,12 +2985,12 @@ var getCheckerboardImage = function getCheckerboardImage() {
2752
2985
  var CheckerboardBackground = function CheckerboardBackground(_ref) {
2753
2986
  var w = _ref.w,
2754
2987
  h = _ref.h;
2755
- var _useState = react.useState(false),
2988
+ var _useState = React.useState(false),
2756
2989
  _useState2 = _slicedToArray(_useState, 2),
2757
2990
  ready = _useState2[0],
2758
2991
  setReady = _useState2[1];
2759
- var imgRef = react.useRef(getCheckerboardImage());
2760
- react.useEffect(function () {
2992
+ var imgRef = React.useRef(getCheckerboardImage());
2993
+ React.useEffect(function () {
2761
2994
  var img = imgRef.current;
2762
2995
  if (img.complete) {
2763
2996
  setReady(true);
@@ -2794,11 +3027,11 @@ var ImageBackground = function ImageBackground(_ref2) {
2794
3027
  var url = _ref2.url,
2795
3028
  w = _ref2.w,
2796
3029
  h = _ref2.h;
2797
- var _useState3 = react.useState(null),
3030
+ var _useState3 = React.useState(null),
2798
3031
  _useState4 = _slicedToArray(_useState3, 2),
2799
3032
  image = _useState4[0],
2800
3033
  setImage = _useState4[1];
2801
- react.useEffect(function () {
3034
+ React.useEffect(function () {
2802
3035
  if (!url) {
2803
3036
  setImage(null);
2804
3037
  return;
@@ -2990,7 +3223,7 @@ var CORNER_ANCHORS = ['top-left', 'top-right', 'bottom-left', 'bottom-right'];
2990
3223
  var SelectionTransformer = mobxReactLite.observer(function (_ref5) {
2991
3224
  var store = _ref5.store,
2992
3225
  stageRef = _ref5.stageRef;
2993
- var transformerRef = react.useRef(null);
3226
+ var transformerRef = React.useRef(null);
2994
3227
  var selectedIds = _toConsumableArray(store.selectedElementsIds);
2995
3228
 
2996
3229
  // Filter out line elements (custom endpoint handles) and elements mid-crop
@@ -3008,7 +3241,7 @@ var SelectionTransformer = mobxReactLite.observer(function (_ref5) {
3008
3241
  return el && el.type === 'group';
3009
3242
  }();
3010
3243
  var targetAnchors = useCorners ? CORNER_ANCHORS : allText ? TEXT_ANCHORS : ALL_ANCHORS;
3011
- react.useEffect(function () {
3244
+ React.useEffect(function () {
3012
3245
  var frame = requestAnimationFrame(function () {
3013
3246
  var _transformerRef$curre;
3014
3247
  if (!transformerRef.current || !stageRef.current) return;
@@ -3054,9 +3287,9 @@ var Workspace = mobxReactLite.observer(function (_ref6) {
3054
3287
  onInputFieldsComplete = _ref6.onInputFieldsComplete,
3055
3288
  _ref6$backTrigger = _ref6.backTrigger,
3056
3289
  backTrigger = _ref6$backTrigger === void 0 ? 0 : _ref6$backTrigger;
3057
- var stageRef = react.useRef(null);
3058
- var containerRef = react.useRef(null);
3059
- var _useState5 = react.useState({
3290
+ var stageRef = React.useRef(null);
3291
+ var containerRef = React.useRef(null);
3292
+ var _useState5 = React.useState({
3060
3293
  width: 800,
3061
3294
  height: 600
3062
3295
  }),
@@ -3066,7 +3299,7 @@ var Workspace = mobxReactLite.observer(function (_ref6) {
3066
3299
  var PageControls = components.PageControls;
3067
3300
 
3068
3301
  // Resize observer
3069
- react.useEffect(function () {
3302
+ React.useEffect(function () {
3070
3303
  var container = containerRef.current;
3071
3304
  if (!container) return;
3072
3305
  var updateSize = function updateSize() {
@@ -3105,12 +3338,12 @@ var Workspace = mobxReactLite.observer(function (_ref6) {
3105
3338
  }, [store.width, store.height]);
3106
3339
 
3107
3340
  // Set stage ref on store for export
3108
- react.useEffect(function () {
3341
+ React.useEffect(function () {
3109
3342
  if (stageRef.current) {
3110
3343
  store._setStageRef(stageRef.current);
3111
3344
  }
3112
3345
  }, [stageRef.current]);
3113
- var handleStageMouseDown = react.useCallback(function (e) {
3346
+ var handleStageMouseDown = React.useCallback(function (e) {
3114
3347
  var _store$_toolbarPanel, _target$attrs, _e$evt, _e$evt2;
3115
3348
  // Clicking anywhere outside the crop rect / pannable image / resize
3116
3349
  // handles while cropping finishes the crop (like Polotno), then falls
@@ -3166,17 +3399,17 @@ var Workspace = mobxReactLite.observer(function (_ref6) {
3166
3399
  store.selectElements([targetId]);
3167
3400
  }
3168
3401
  }, [store]);
3169
- var handleTransformEnd = react.useCallback(function () {
3402
+ var handleTransformEnd = React.useCallback(function () {
3170
3403
  // Save to history after transform
3171
3404
  store.history.addUndoState();
3172
3405
  }, [store]);
3173
- var handleDragEnd = react.useCallback(function () {
3406
+ var handleDragEnd = React.useCallback(function () {
3174
3407
  // Save to history after drag
3175
3408
  store.history.addUndoState();
3176
3409
  }, [store]);
3177
3410
 
3178
3411
  // Keyboard shortcuts
3179
- react.useEffect(function () {
3412
+ React.useEffect(function () {
3180
3413
  var handleKeyDown = function handleKeyDown(e) {
3181
3414
  var _store$_toolbarPanel2;
3182
3415
  // Only handle if stage container or body is focused
@@ -3297,7 +3530,7 @@ var Workspace = mobxReactLite.observer(function (_ref6) {
3297
3530
  }, [store]);
3298
3531
 
3299
3532
  // Zoom with mouse wheel
3300
- var handleWheel = react.useCallback(function (e) {
3533
+ var handleWheel = React.useCallback(function (e) {
3301
3534
  e.evt.preventDefault();
3302
3535
  var stage = stageRef.current;
3303
3536
  if (!stage) return;