labellife-design-tool 2.4.0 → 2.4.2

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.
package/dist/esm/index.js CHANGED
@@ -58,10 +58,11 @@ import '@mui/icons-material/AlignVerticalCenter';
58
58
  import '@mui/icons-material/AlignVerticalBottom';
59
59
  import VerticalAlignTopIcon from '@mui/icons-material/VerticalAlignTop';
60
60
  import VerticalAlignBottomIcon from '@mui/icons-material/VerticalAlignBottom';
61
+ import GestureIcon from '@mui/icons-material/Gesture';
61
62
  import ZoomInIcon from '@mui/icons-material/ZoomIn';
62
63
  import ZoomOutIcon from '@mui/icons-material/ZoomOut';
63
64
  import FitScreenIcon from '@mui/icons-material/FitScreen';
64
- import { Group, Image as Image$1, Rect, Transformer, Text, Arrow, Path, RegularPolygon, Star, Circle, Line, Shape as Shape$1, Stage, Layer } from 'react-konva';
65
+ import { Group, Image as Image$1, Rect, Transformer, Shape as Shape$1, Text, Arrow, Path, RegularPolygon, Star, Circle, Line, Stage, Layer } from 'react-konva';
65
66
  import Konva from 'konva';
66
67
  import ArrowBackIcon from '@mui/icons-material/ArrowBack';
67
68
 
@@ -7272,18 +7273,30 @@ var MONTH_NAMES$1 = ['January', 'February', 'March', 'April', 'May', 'June', 'Ju
7272
7273
  var DATE_FORMATS = [{
7273
7274
  key: 'MM-DD-YYYY',
7274
7275
  label: 'MM-DD-YYYY'
7276
+ }, {
7277
+ key: 'DD-MM-YYYY',
7278
+ label: 'DD-MM-YYYY'
7275
7279
  }, {
7276
7280
  key: 'MMMM-DD-YYYY',
7277
7281
  label: 'Month Name-DD-YYYY'
7282
+ }, {
7283
+ key: 'DD-MMMM-YYYY',
7284
+ label: 'DD-Month Name-YYYY'
7278
7285
  }, {
7279
7286
  key: 'MMMM-DD',
7280
7287
  label: 'Month Name-DD'
7288
+ }, {
7289
+ key: 'DD-MMMM',
7290
+ label: 'DD-Month Name'
7281
7291
  }, {
7282
7292
  key: 'YYYY',
7283
7293
  label: 'YYYY'
7284
7294
  }, {
7285
7295
  key: 'MM-DD',
7286
7296
  label: 'MM-DD'
7297
+ }, {
7298
+ key: 'DD-MM',
7299
+ label: 'DD-MM'
7287
7300
  }];
7288
7301
  function formatDate$1(date, format) {
7289
7302
  var mm = String(date.getMonth() + 1).padStart(2, '0');
@@ -7293,14 +7306,22 @@ function formatDate$1(date, format) {
7293
7306
  switch (format) {
7294
7307
  case 'MM-DD-YYYY':
7295
7308
  return "".concat(mm, "-").concat(dd, "-").concat(yyyy);
7309
+ case 'DD-MM-YYYY':
7310
+ return "".concat(dd, "-").concat(mm, "-").concat(yyyy);
7296
7311
  case 'MMMM-DD-YYYY':
7297
7312
  return "".concat(monthName, "-").concat(dd, "-").concat(yyyy);
7313
+ case 'DD-MMMM-YYYY':
7314
+ return "".concat(dd, "-").concat(monthName, "-").concat(yyyy);
7298
7315
  case 'MMMM-DD':
7299
7316
  return "".concat(monthName, "-").concat(dd);
7317
+ case 'DD-MMMM':
7318
+ return "".concat(dd, "-").concat(monthName);
7300
7319
  case 'YYYY':
7301
7320
  return yyyy;
7302
7321
  case 'MM-DD':
7303
7322
  return "".concat(mm, "-").concat(dd);
7323
+ case 'DD-MM':
7324
+ return "".concat(dd, "-").concat(mm);
7304
7325
  default:
7305
7326
  return "".concat(mm, "-").concat(dd, "-").concat(yyyy);
7306
7327
  }
@@ -9814,10 +9835,85 @@ var PositionButton = observer(function (_ref8) {
9814
9835
  });
9815
9836
  });
9816
9837
 
9838
+ // Curve (text-only) slider popover — same button/popover pattern as
9839
+ // PositionButton, holding the same control previously in the Text
9840
+ // Effects panel's Curve section. No separate enable toggle: curvePower
9841
+ // itself is the on/off state (0 = straight, matching how the renderer
9842
+ // already treats curvePower === 0 as "no curve").
9843
+ var CurveButton = observer(function (_ref0) {
9844
+ var element = _ref0.element;
9845
+ var _useState5 = useState(null),
9846
+ _useState6 = _slicedToArray(_useState5, 2),
9847
+ anchorEl = _useState6[0],
9848
+ setAnchorEl = _useState6[1];
9849
+ var open = Boolean(anchorEl);
9850
+ return /*#__PURE__*/jsxs(Fragment, {
9851
+ children: [/*#__PURE__*/jsx(Button, {
9852
+ size: "small",
9853
+ onClick: function onClick(e) {
9854
+ return setAnchorEl(e.currentTarget);
9855
+ },
9856
+ startIcon: /*#__PURE__*/jsx(GestureIcon, {
9857
+ sx: {
9858
+ fontSize: '16px !important'
9859
+ }
9860
+ }),
9861
+ sx: _objectSpread2({
9862
+ textTransform: 'none',
9863
+ fontSize: 12,
9864
+ whiteSpace: 'nowrap',
9865
+ px: 1.5,
9866
+ minWidth: 'auto'
9867
+ }, open ? {
9868
+ backgroundColor: '#e3f2fd',
9869
+ color: '#0d83cd'
9870
+ } : {}),
9871
+ children: t('toolbar.curve', 'Curve')
9872
+ }), /*#__PURE__*/jsx(Popover, {
9873
+ open: open,
9874
+ anchorEl: anchorEl,
9875
+ onClose: function onClose() {
9876
+ return setAnchorEl(null);
9877
+ },
9878
+ anchorOrigin: {
9879
+ vertical: 'bottom',
9880
+ horizontal: 'left'
9881
+ },
9882
+ transformOrigin: {
9883
+ vertical: 'top',
9884
+ horizontal: 'left'
9885
+ },
9886
+ slotProps: {
9887
+ paper: {
9888
+ sx: {
9889
+ mt: 0.5,
9890
+ p: 2,
9891
+ width: 260,
9892
+ borderRadius: '10px',
9893
+ boxShadow: '0 4px 20px rgba(0,0,0,0.12)'
9894
+ }
9895
+ }
9896
+ },
9897
+ children: /*#__PURE__*/jsx(SliderRow, {
9898
+ label: t('toolbar.curve', 'Curve'),
9899
+ value: element.curvePower,
9900
+ onChange: function onChange(v) {
9901
+ return element.set({
9902
+ curveEnabled: true,
9903
+ curvePower: v
9904
+ });
9905
+ },
9906
+ min: -500,
9907
+ max: 500
9908
+ })
9909
+ })]
9910
+ });
9911
+ });
9912
+
9817
9913
  // Common controls for all element types
9818
- var CommonControls = observer(function (_ref0) {
9819
- var element = _ref0.element,
9820
- store = _ref0.store;
9914
+ var CommonControls = observer(function (_ref1) {
9915
+ var element = _ref1.element,
9916
+ store = _ref1.store;
9821
9917
  var isLocked = element.locked;
9822
9918
  var handleDuplicate = function handleDuplicate() {
9823
9919
  if (element.clone) {
@@ -9895,6 +9991,9 @@ var CommonControls = observer(function (_ref0) {
9895
9991
  }), /*#__PURE__*/jsx(PositionButton, {
9896
9992
  element: element,
9897
9993
  store: store
9994
+ }), element.type === 'text' && /*#__PURE__*/jsx(CurveButton, {
9995
+ element: element,
9996
+ store: store
9898
9997
  }), /*#__PURE__*/jsx(Divider, {
9899
9998
  orientation: "vertical",
9900
9999
  flexItem: true,
@@ -9938,26 +10037,26 @@ var CommonControls = observer(function (_ref0) {
9938
10037
  });
9939
10038
 
9940
10039
  // Download button with format/quality popover
9941
- var DefaultDownloadButton = observer(function (_ref1) {
9942
- var store = _ref1.store;
9943
- var _useState5 = useState(null),
9944
- _useState6 = _slicedToArray(_useState5, 2),
9945
- anchorEl = _useState6[0],
9946
- setAnchorEl = _useState6[1];
9947
- var _useState7 = useState('png'),
10040
+ var DefaultDownloadButton = observer(function (_ref10) {
10041
+ var store = _ref10.store;
10042
+ var _useState7 = useState(null),
9948
10043
  _useState8 = _slicedToArray(_useState7, 2),
9949
- fileType = _useState8[0],
9950
- setFileType = _useState8[1];
10044
+ anchorEl = _useState8[0],
10045
+ setAnchorEl = _useState8[1];
10046
+ var _useState9 = useState('png'),
10047
+ _useState0 = _slicedToArray(_useState9, 2),
10048
+ fileType = _useState0[0],
10049
+ setFileType = _useState0[1];
9951
10050
  // Default quality so pixelRatio=1 (output = template's own pixel size).
9952
10051
  // qualityToPixelRatio(q) = q * 3, so q = 1/3 → pixelRatio = 1.
9953
- var _useState9 = useState(1 / 3),
9954
- _useState0 = _slicedToArray(_useState9, 2),
9955
- quality = _useState0[0],
9956
- setQuality = _useState0[1];
9957
- var _useState1 = useState(false),
10052
+ var _useState1 = useState(1 / 3),
9958
10053
  _useState10 = _slicedToArray(_useState1, 2),
9959
- exporting = _useState10[0],
9960
- setExporting = _useState10[1];
10054
+ quality = _useState10[0],
10055
+ setQuality = _useState10[1];
10056
+ var _useState11 = useState(false),
10057
+ _useState12 = _slicedToArray(_useState11, 2),
10058
+ exporting = _useState12[0],
10059
+ setExporting = _useState12[1];
9961
10060
  var open = Boolean(anchorEl);
9962
10061
  var handleClick = function handleClick(e) {
9963
10062
  setAnchorEl(e.currentTarget);
@@ -10190,15 +10289,15 @@ var DefaultDownloadButton = observer(function (_ref1) {
10190
10289
  });
10191
10290
 
10192
10291
  // Import button — loads a JSON template file into the store
10193
- var DefaultImportButton = observer(function (_ref11) {
10194
- var store = _ref11.store;
10195
- var _useState11 = useState(false),
10196
- _useState12 = _slicedToArray(_useState11, 2),
10197
- importing = _useState12[0],
10198
- setImporting = _useState12[1];
10292
+ var DefaultImportButton = observer(function (_ref12) {
10293
+ var store = _ref12.store;
10294
+ var _useState13 = useState(false),
10295
+ _useState14 = _slicedToArray(_useState13, 2),
10296
+ importing = _useState14[0],
10297
+ setImporting = _useState14[1];
10199
10298
  var fileInputRef = React.useRef(null);
10200
10299
  var handleFileChange = useCallback(/*#__PURE__*/function () {
10201
- var _ref12 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(e) {
10300
+ var _ref13 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(e) {
10202
10301
  var _e$target$files;
10203
10302
  var file, text, jsonData, _t3;
10204
10303
  return _regenerator().w(function (_context2) {
@@ -10236,7 +10335,7 @@ var DefaultImportButton = observer(function (_ref11) {
10236
10335
  }, _callee2, null, [[2, 4, 5, 6]]);
10237
10336
  }));
10238
10337
  return function (_x) {
10239
- return _ref12.apply(this, arguments);
10338
+ return _ref13.apply(this, arguments);
10240
10339
  };
10241
10340
  }(), [store]);
10242
10341
  return /*#__PURE__*/jsxs(Fragment, {
@@ -10302,10 +10401,10 @@ var rowSx = {
10302
10401
  display: 'none'
10303
10402
  }
10304
10403
  };
10305
- var Toolbar = observer(function (_ref13) {
10306
- var store = _ref13.store,
10307
- _ref13$components = _ref13.components,
10308
- components = _ref13$components === void 0 ? {} : _ref13$components;
10404
+ var Toolbar = observer(function (_ref14) {
10405
+ var store = _ref14.store,
10406
+ _ref14$components = _ref14.components,
10407
+ components = _ref14$components === void 0 ? {} : _ref14$components;
10309
10408
  var ActionControls = components.ActionControls;
10310
10409
  var ImportButton = 'ImportButton' in components ? components.ImportButton : DefaultImportButton;
10311
10410
  var DownloadButton = 'DownloadButton' in components ? components.DownloadButton : DefaultDownloadButton;
@@ -11025,6 +11124,203 @@ var ImageElementComponent = observer(function (_ref) {
11025
11124
  });
11026
11125
  ImageElementComponent.displayName = 'ImageElement';
11027
11126
 
11127
+ // Composes a canvas/Konva font-style string (e.g. "italic bold") from the
11128
+ // element model's separate fontStyle/fontWeight fields. Shared by
11129
+ // text-element.js (KonvaText) and curved-text.js (custom Shape), which
11130
+ // both need to build a canvas `ctx.font` / Konva fontStyle string the same
11131
+ // way.
11132
+ function composeFontStyle(fontStyle, fontWeight) {
11133
+ var parts = [];
11134
+ var style = String(fontStyle || '').trim();
11135
+ var weight = String(fontWeight || '').trim();
11136
+ if (style === 'italic' || style.includes('italic')) parts.push('italic');
11137
+ if (weight && weight !== 'normal') parts.push(weight);
11138
+ return parts.length > 0 ? parts.join(' ') : 'normal';
11139
+ }
11140
+
11141
+ // src/canvas/curved-text-geometry.js
11142
+ //
11143
+ // Pure, framework-free geometry math for the curved-text effect.
11144
+ // Deliberately authored as CommonJS (not ESM like the rest of src/canvas)
11145
+ // so this one file can be unit-tested with plain `node`, no jest/babel
11146
+ // required — this repo has no test framework installed. Rollup's
11147
+ // commonjs() plugin (already in rollup.config.mjs) interops this into the
11148
+ // ESM build correctly when curved-text.js imports it with `import`.
11149
+
11150
+ // At curvePower = 100 (max), the radius is this many multiples of
11151
+ // fontSize. Tuned empirically: 3x let realistic multi-word labels wrap
11152
+ // into a nearly-closed loop well before the slider reached 100 (e.g. a
11153
+ // ~500px-wide line swept ~341° — individual glyphs rotate past horizontal
11154
+ // once a line wraps past ~180°, which read as "letters rotating wrong").
11155
+ // 6x keeps the same line under ~170° at max curvePower, a clearly-open arc.
11156
+ // Adjust this constant (and re-run curved-text-geometry.test.js, which
11157
+ // exercises it) if the on-screen result needs to be tighter/looser.
11158
+ var MAX_RADIUS_FONT_MULTIPLIER = 6;
11159
+
11160
+ // Maps curvePower (-100..100) to a positive radius magnitude in px.
11161
+ // Direction (smile vs frown) is NOT encoded here — callers apply
11162
+ // Math.sign(curvePower) separately (see curved-text.js). curvePower = 0
11163
+ // returns Infinity (a "straight line" radius) for defensiveness, though
11164
+ // callers should treat curvePower === 0 as "don't curve at all" before
11165
+ // reaching here (falls back to plain KonvaText).
11166
+ function computeArcRadius(curvePower, fontSize) {
11167
+ var power = Math.abs(curvePower);
11168
+ if (power === 0) return Infinity;
11169
+ return fontSize * MAX_RADIUS_FONT_MULTIPLIER / (power / 100);
11170
+ }
11171
+
11172
+ // Computes the radius for line `lineIndex` (0-based, top to bottom) of a
11173
+ // multi-line curved text block, so all lines share one arc center
11174
+ // (concentric) and stack in normal reading order.
11175
+ //
11176
+ // For curvePower > 0 ("smile", center below the text), later lines move
11177
+ // closer to the center (smaller radius). For curvePower < 0 ("frown",
11178
+ // center above the text), later lines move away from the center (larger
11179
+ // radius).
11180
+ function computeLineRadius(baseRadius, lineIndex, lineHeight, curvePower) {
11181
+ var direction = curvePower > 0 ? -1 : 1;
11182
+ return baseRadius + lineIndex * lineHeight * direction;
11183
+ }
11184
+
11185
+ // Distributes characters of one line along an arc of the given radius,
11186
+ // centered so the line's midpoint sits at angle 0 — i.e. center-aligned.
11187
+ //
11188
+ // charWidths: array of per-glyph advance widths (px), in reading order.
11189
+ // radius: positive, finite radius magnitude (px) for this line.
11190
+ //
11191
+ // Returns an array, one entry per character, each: { angle } — the angle
11192
+ // (radians) from the arc's center-line, in reading order. Callers convert
11193
+ // `angle` + `radius` into an (x, y) position and a tangent rotation for
11194
+ // drawing (see curved-text.js).
11195
+ function layoutCharsOnArc(charWidths, radius) {
11196
+ if (!Number.isFinite(radius) || radius <= 0) {
11197
+ throw new Error('layoutCharsOnArc requires a finite, positive radius');
11198
+ }
11199
+ var totalWidth = charWidths.reduce(function (sum, w) {
11200
+ return sum + w;
11201
+ }, 0);
11202
+ var totalAngle = totalWidth / radius;
11203
+ var cumBefore = 0;
11204
+ return charWidths.map(function (w) {
11205
+ var cumMid = cumBefore + w / 2;
11206
+ cumBefore += w;
11207
+ var angleFromStart = cumMid / radius;
11208
+ return {
11209
+ angle: angleFromStart - totalAngle / 2
11210
+ };
11211
+ });
11212
+ }
11213
+ var curvedTextGeometry = {
11214
+ computeArcRadius: computeArcRadius,
11215
+ computeLineRadius: computeLineRadius,
11216
+ layoutCharsOnArc: layoutCharsOnArc
11217
+ };
11218
+
11219
+ var CurvedText = observer(/*#__PURE__*/React.forwardRef(function (_ref, ref) {
11220
+ var element = _ref.element,
11221
+ displayText = _ref.displayText,
11222
+ width = _ref.width;
11223
+ var fontStyleStr = composeFontStyle(element.fontStyle, element.fontWeight);
11224
+ var lineHeightMultiplier = typeof element.lineHeight === 'number' ? element.lineHeight : parseFloat(element.lineHeight) || 1.2;
11225
+ var lineHeightPx = element.fontSize * lineHeightMultiplier;
11226
+ var letterSpacing = element.letterSpacing || 0;
11227
+ var curvePower = element.curvePower;
11228
+
11229
+ // Precondition: caller must not mount this component with curvePower === 0.
11230
+ // Defensive guard to avoid passing Infinity to layoutCharsOnArc.
11231
+ if (curvePower === 0) return null;
11232
+ var direction = curvePower > 0 ? 1 : -1;
11233
+ var baseRadius = curvedTextGeometry.computeArcRadius(curvePower, element.fontSize);
11234
+ var lines = (displayText || '').split('\n');
11235
+
11236
+ // Shared per-character geometry: walks every line/character and invokes
11237
+ // `draw(ctx, ch, x, y, angle)` inside the same save/translate/rotate/
11238
+ // restore frame. Used by both sceneFunc (real glyph fill/stroke) and
11239
+ // hitFunc (hit-region rects) so the clickable area always matches what's
11240
+ // actually painted — duplicating this math between the two would risk
11241
+ // them drifting apart.
11242
+ var forEachChar = function forEachChar(ctx, draw) {
11243
+ var centerX = width / 2;
11244
+ lines.forEach(function (lineText, lineIndex) {
11245
+ var chars = Array.from(lineText);
11246
+ if (chars.length === 0) return;
11247
+ var charWidths = chars.map(function (ch) {
11248
+ return ctx.measureText(ch).width + letterSpacing;
11249
+ });
11250
+ var lineRadius = curvedTextGeometry.computeLineRadius(baseRadius, lineIndex, lineHeightPx, curvePower);
11251
+ var signedRadius = direction * lineRadius;
11252
+ var baselineY = lineIndex * lineHeightPx + element.fontSize;
11253
+ var centerY = baselineY + signedRadius;
11254
+ var layout = curvedTextGeometry.layoutCharsOnArc(charWidths, lineRadius);
11255
+ chars.forEach(function (ch, idx) {
11256
+ var angle = layout[idx].angle;
11257
+ var x = centerX + lineRadius * Math.sin(angle);
11258
+ var y = centerY - signedRadius * Math.cos(angle);
11259
+ draw(ctx, ch, x, y, angle, charWidths[idx]);
11260
+ });
11261
+ });
11262
+ };
11263
+ return /*#__PURE__*/jsx(Shape$1, {
11264
+ ref: ref,
11265
+ width: width,
11266
+ height: lines.length * lineHeightPx,
11267
+ sceneFunc: function sceneFunc(ctx) {
11268
+ ctx.font = "".concat(fontStyleStr, " ").concat(element.fontSize, "px \"").concat(element.fontFamily, "\"");
11269
+ ctx.textAlign = 'center';
11270
+ ctx.textBaseline = 'alphabetic';
11271
+ forEachChar(ctx, function (c, ch, x, y, angle) {
11272
+ c.save();
11273
+ c.translate(x, y);
11274
+ c.rotate(direction * angle);
11275
+ if (element.strokeWidth > 0) {
11276
+ c.strokeStyle = element.stroke || '#000000';
11277
+ c.lineWidth = element.strokeWidth;
11278
+ c.strokeText(ch, 0, 0);
11279
+ }
11280
+ c.fillStyle = element.fill;
11281
+ c.fillText(ch, 0, 0);
11282
+ c.restore();
11283
+ });
11284
+ },
11285
+ hitFunc: function hitFunc(ctx, shape) {
11286
+ ctx.font = "".concat(fontStyleStr, " ").concat(element.fontSize, "px \"").concat(element.fontFamily, "\"");
11287
+ ctx.textAlign = 'center';
11288
+ ctx.textBaseline = 'alphabetic';
11289
+ ctx.beginPath();
11290
+ forEachChar(ctx, function (c, ch, x, y, angle, charWidth) {
11291
+ c.save();
11292
+ c.translate(x, y);
11293
+ c.rotate(direction * angle);
11294
+ c.rect(-charWidth / 2, -element.fontSize * 0.8, charWidth, element.fontSize * 1.1);
11295
+ c.restore();
11296
+ });
11297
+ ctx.fillStrokeShape(shape);
11298
+ }
11299
+ });
11300
+ }));
11301
+ CurvedText.displayName = 'CurvedText';
11302
+
11303
+ function computeCurvedCacheBounds(element) {
11304
+ var lineCount = (element.text || element.placeholder || '').split('\n').length;
11305
+ var lineHeightMultiplier = typeof element.lineHeight === 'number' ? element.lineHeight : parseFloat(element.lineHeight) || 1.2;
11306
+ var lineHeightPx = element.fontSize * lineHeightMultiplier;
11307
+ var baseRadius = curvedTextGeometry.computeArcRadius(element.curvePower, element.fontSize);
11308
+ var halfChord = element.width / 2;
11309
+ var maxSagitta = 0;
11310
+ for (var lineIndex = 0; lineIndex < lineCount; lineIndex++) {
11311
+ var lineRadius = curvedTextGeometry.computeLineRadius(baseRadius, lineIndex, lineHeightPx, element.curvePower);
11312
+ var sagitta = halfChord >= lineRadius ? lineRadius : lineRadius - Math.sqrt(lineRadius * lineRadius - halfChord * halfChord);
11313
+ if (sagitta > maxSagitta) maxSagitta = sagitta;
11314
+ }
11315
+ var declaredHeight = lineCount * lineHeightPx;
11316
+ var xPad = maxSagitta / 2;
11317
+ return {
11318
+ x: -xPad,
11319
+ y: -maxSagitta,
11320
+ width: element.width + xPad * 2,
11321
+ height: declaredHeight + maxSagitta * 2
11322
+ };
11323
+ }
11028
11324
  var TextElementComponent = observer(function (_ref) {
11029
11325
  var _element$backgroundOp;
11030
11326
  var element = _ref.element;
@@ -11039,13 +11335,24 @@ var TextElementComponent = observer(function (_ref) {
11039
11335
  _useState2 = _slicedToArray(_useState, 2),
11040
11336
  textHeight = _useState2[0],
11041
11337
  setTextHeight = _useState2[1];
11338
+ var isCurved = element.curveEnabled && element.curvePower !== 0;
11042
11339
 
11043
11340
  // Force Konva to recalculate text layout when fonts finish loading.
11044
11341
  useEffect(function () {
11045
11342
  var onFontLoaded = function onFontLoaded() {
11046
- var _node$getLayer;
11343
+ var _node$getLayer2;
11047
11344
  var node = textRef.current;
11048
11345
  if (!node) return;
11346
+
11347
+ // CurvedText's sceneFunc re-measures glyphs via ctx.measureText on
11348
+ // every draw (no internal cached layout like Konva.Text has), so
11349
+ // there's no stale-layout workaround needed — just repaint.
11350
+ if (element.curveEnabled && element.curvePower !== 0) {
11351
+ var _node$getLayer;
11352
+ if (element.blurEnabled) node.cache(computeCurvedCacheBounds(element));
11353
+ (_node$getLayer = node.getLayer()) === null || _node$getLayer === void 0 || _node$getLayer.batchDraw();
11354
+ return;
11355
+ }
11049
11356
  var f = node.fontFamily();
11050
11357
  node.fontFamily('serif');
11051
11358
  node.fontFamily(f);
@@ -11060,7 +11367,7 @@ var TextElementComponent = observer(function (_ref) {
11060
11367
  if (element.blurEnabled && node) {
11061
11368
  node.cache();
11062
11369
  }
11063
- (_node$getLayer = node.getLayer()) === null || _node$getLayer === void 0 || _node$getLayer.batchDraw();
11370
+ (_node$getLayer2 = node.getLayer()) === null || _node$getLayer2 === void 0 || _node$getLayer2.batchDraw();
11064
11371
  };
11065
11372
  document.fonts.addEventListener('loadingdone', onFontLoaded);
11066
11373
  return function () {
@@ -11069,7 +11376,10 @@ var TextElementComponent = observer(function (_ref) {
11069
11376
  }, []);
11070
11377
 
11071
11378
  // Sync Konva auto-sized height back to element model after text reflows
11379
+ // (straight text only — curved text's height is computed synchronously
11380
+ // below, since it doesn't width-wrap and doesn't need a measured node).
11072
11381
  useEffect(function () {
11382
+ if (element.curveEnabled && element.curvePower !== 0) return;
11073
11383
  var node = textRef.current;
11074
11384
  if (!node) return;
11075
11385
  var frame = requestAnimationFrame(function () {
@@ -11084,23 +11394,40 @@ var TextElementComponent = observer(function (_ref) {
11084
11394
  return function () {
11085
11395
  return cancelAnimationFrame(frame);
11086
11396
  };
11087
- }, [element.text, element.fontSize, element.fontFamily, element.fontWeight, element.width]);
11397
+ }, [element.text, element.fontSize, element.fontFamily, element.fontWeight, element.width, element.curveEnabled, element.curvePower]);
11398
+
11399
+ // Curved text: height is deterministic from line count (no width-based
11400
+ // wrapping), so sync it directly without waiting on Konva measurement.
11401
+ useEffect(function () {
11402
+ if (!(element.curveEnabled && element.curvePower !== 0)) return;
11403
+ var lineCount = (element.text || element.placeholder || '').split('\n').length;
11404
+ var lineHeightMultiplier = typeof element.lineHeight === 'number' ? element.lineHeight : parseFloat(element.lineHeight) || 1.2;
11405
+ var h = lineCount * element.fontSize * lineHeightMultiplier;
11406
+ setTextHeight(h);
11407
+ if (Math.abs(h - element.height) > 1) element.set({
11408
+ height: h
11409
+ });
11410
+ }, [element.text, element.placeholder, element.fontSize, element.lineHeight, element.curveEnabled, element.curvePower]);
11088
11411
 
11089
11412
  // Apply blur filter: cache the text node when blur is enabled
11090
11413
  useEffect(function () {
11091
- var _node$getLayer2;
11414
+ var _node$getLayer3;
11092
11415
  var node = textRef.current;
11093
11416
  if (!node) return;
11094
11417
  if (element.blurEnabled) {
11095
11418
  node.filters([Konva.Filters.Blur]);
11096
11419
  node.blurRadius(element.blurRadius);
11097
- node.cache();
11420
+ if (isCurved) {
11421
+ node.cache(computeCurvedCacheBounds(element));
11422
+ } else {
11423
+ node.cache();
11424
+ }
11098
11425
  } else {
11099
11426
  node.filters([]);
11100
11427
  node.clearCache();
11101
11428
  }
11102
- (_node$getLayer2 = node.getLayer()) === null || _node$getLayer2 === void 0 || _node$getLayer2.batchDraw();
11103
- }, [element.blurEnabled, element.blurRadius, element.text, element.fontSize, element.width]);
11429
+ (_node$getLayer3 = node.getLayer()) === null || _node$getLayer3 === void 0 || _node$getLayer3.batchDraw();
11430
+ }, [element.blurEnabled, element.blurRadius, element.text, element.fontSize, element.width, isCurved, element.curvePower, element.lineHeight]);
11104
11431
  if (!element.visible) return null;
11105
11432
  var handleDragEnd = function handleDragEnd(e) {
11106
11433
  element.set({
@@ -11125,7 +11452,9 @@ var TextElementComponent = observer(function (_ref) {
11125
11452
  var tNode = textRef.current;
11126
11453
  if (tNode) {
11127
11454
  tNode.width(newWidth);
11128
- tNode.fontSize(newFontSize);
11455
+ if (typeof tNode.fontSize === 'function') {
11456
+ tNode.fontSize(newFontSize);
11457
+ }
11129
11458
  }
11130
11459
  node.scaleX(1);
11131
11460
  node.scaleY(1);
@@ -11239,14 +11568,7 @@ var TextElementComponent = observer(function (_ref) {
11239
11568
  return c.toUpperCase();
11240
11569
  });
11241
11570
  }
11242
- var fontStyleStr = function () {
11243
- var parts = [];
11244
- var style = String(element.fontStyle || '').trim();
11245
- var weight = String(element.fontWeight || '').trim();
11246
- if (style === 'italic' || style.includes('italic')) parts.push('italic');
11247
- if (weight && weight !== 'normal') parts.push(weight);
11248
- return parts.length > 0 ? parts.join(' ') : 'normal';
11249
- }();
11571
+ var fontStyleStr = composeFontStyle(element.fontStyle, element.fontWeight);
11250
11572
  var pad = element.backgroundEnabled ? element.backgroundPadding || 0 : 0;
11251
11573
  return /*#__PURE__*/jsxs(Group, {
11252
11574
  ref: groupRef,
@@ -11280,7 +11602,12 @@ var TextElementComponent = observer(function (_ref) {
11280
11602
  opacity: (_element$backgroundOp = element.backgroundOpacity) !== null && _element$backgroundOp !== void 0 ? _element$backgroundOp : 1,
11281
11603
  cornerRadius: element.backgroundCornerRadius || 0,
11282
11604
  listening: false
11283
- }), /*#__PURE__*/jsx(Text, {
11605
+ }), isCurved ? /*#__PURE__*/jsx(CurvedText, {
11606
+ ref: textRef,
11607
+ element: element,
11608
+ displayText: displayText,
11609
+ width: element.width
11610
+ }) : /*#__PURE__*/jsx(Text, {
11284
11611
  ref: textRef,
11285
11612
  text: displayText,
11286
11613
  width: element.width,
@@ -11866,9 +12193,19 @@ function parseDateFromFormat(dateStr, format) {
11866
12193
  return new Date();
11867
12194
  }
11868
12195
 
12196
+ // Shared sizing for the popup's action row (Back / Continue / Do it later),
12197
+ // exported so a custom `PopupActions` component can visually match them.
12198
+ var popupActionButtonSx = {
12199
+ textTransform: 'none',
12200
+ fontSize: 21,
12201
+ py: 1.65,
12202
+ borderRadius: '10px'
12203
+ };
12204
+
11869
12205
  // ── Default single-field dialog (full-page overlay) ──────────────────
11870
12206
  var SingleFieldDialog = function SingleFieldDialog(_ref) {
11871
12207
  var field = _ref.field,
12208
+ store = _ref.store,
11872
12209
  onSubmit = _ref.onSubmit,
11873
12210
  onSkip = _ref.onSkip,
11874
12211
  onBack = _ref.onBack,
@@ -12429,36 +12766,30 @@ var SingleFieldDialog = function SingleFieldDialog(_ref) {
12429
12766
  mt: 4.5,
12430
12767
  flexShrink: 0
12431
12768
  },
12432
- children: [canGoBack && /*#__PURE__*/jsx(Button, {
12769
+ children: [config.PopupActions && /*#__PURE__*/jsx(config.PopupActions, {
12770
+ store: store
12771
+ }), canGoBack && /*#__PURE__*/jsx(Button, {
12433
12772
  variant: "outlined",
12434
12773
  onClick: onBack,
12435
12774
  startIcon: /*#__PURE__*/jsx(ArrowBackIcon, {}),
12436
- sx: {
12437
- textTransform: 'none',
12775
+ sx: _objectSpread2(_objectSpread2({}, popupActionButtonSx), {}, {
12438
12776
  fontWeight: 500,
12439
- fontSize: 21,
12440
12777
  px: 3,
12441
- py: 1.65,
12442
- borderRadius: '10px',
12443
12778
  color: '#555',
12444
12779
  borderColor: '#d0d5dd',
12445
12780
  '&:hover': {
12446
12781
  borderColor: '#aaa',
12447
12782
  backgroundColor: 'rgba(0,0,0,0.02)'
12448
12783
  }
12449
- },
12784
+ }),
12450
12785
  children: t('inputFieldsDialog.back', 'Back')
12451
12786
  }), /*#__PURE__*/jsx(Button, {
12452
12787
  variant: "contained",
12453
12788
  onClick: handleSubmit,
12454
12789
  disabled: isSubmitDisabled,
12455
- sx: _objectSpread2({
12456
- textTransform: 'none',
12790
+ sx: _objectSpread2(_objectSpread2({}, popupActionButtonSx), {}, {
12457
12791
  fontWeight: 600,
12458
- fontSize: 21,
12459
12792
  px: 5,
12460
- py: 1.65,
12461
- borderRadius: '10px',
12462
12793
  backgroundColor: accentColor,
12463
12794
  boxShadow: 'none',
12464
12795
  '&:hover': {
@@ -12472,13 +12803,9 @@ var SingleFieldDialog = function SingleFieldDialog(_ref) {
12472
12803
  onClick: function onClick() {
12473
12804
  return onSkip(field.id);
12474
12805
  },
12475
- sx: _objectSpread2({
12476
- textTransform: 'none',
12806
+ sx: _objectSpread2(_objectSpread2({}, popupActionButtonSx), {}, {
12477
12807
  fontWeight: 500,
12478
- fontSize: 21,
12479
12808
  px: 4.5,
12480
- py: 1.65,
12481
- borderRadius: '10px',
12482
12809
  color: '#555',
12483
12810
  borderColor: '#d0d5dd',
12484
12811
  '&:hover': {
@@ -12721,6 +13048,7 @@ var InputFieldsDialog = observer(function (_ref2) {
12721
13048
  }
12722
13049
  return /*#__PURE__*/jsx(SingleFieldDialog, {
12723
13050
  field: currentField,
13051
+ store: store,
12724
13052
  onSubmit: handleSubmit,
12725
13053
  onSkip: handleSkip,
12726
13054
  onBack: handleBack,
@@ -13467,5 +13795,5 @@ function WorkspaceWrap(_ref3) {
13467
13795
  }));
13468
13796
  }
13469
13797
 
13470
- export { BackgroundSection, DEFAULT_FONTS, DEFAULT_SECTIONS, DesignContainer, ElementsSection, ImagesGrid, InputFieldsDialog, InputFieldsSection, LayersSection, PolotnoContainer, SectionTab, SidePanel, SidePanelWrap, Store, TextSection, Toolbar, UploadSection, Workspace, WorkspaceWrap, ZoomButtons, createStore, cropImage, fetchGoogleFonts, getImageSize, getInputFieldsConfig, getTheme, getTranslations, loadGoogleFont, loadImage, pxToUnit, setInputFieldsConfig, setTheme, setTranslations, t, unitToPx };
13798
+ export { BackgroundSection, DEFAULT_FONTS, DEFAULT_SECTIONS, DesignContainer, ElementsSection, ImagesGrid, InputFieldsDialog, InputFieldsSection, LayersSection, PolotnoContainer, SectionTab, SidePanel, SidePanelWrap, Store, TextSection, Toolbar, UploadSection, Workspace, WorkspaceWrap, ZoomButtons, createStore, cropImage, fetchGoogleFonts, getImageSize, getInputFieldsConfig, getTheme, getTranslations, loadGoogleFont, loadImage, popupActionButtonSx, pxToUnit, setInputFieldsConfig, setTheme, setTranslations, t, unitToPx };
13471
13799
  //# sourceMappingURL=index.js.map