labellife-design-tool 2.2.3 → 2.2.5

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
@@ -1959,11 +1959,11 @@ var Store = types.model('Store', {
1959
1959
  _toCanvas: function _toCanvas() {
1960
1960
  var _arguments = arguments;
1961
1961
  return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
1962
- var _ref4, _ref4$pixelRatio, pixelRatio, pageId, stage, page, layer, prevX, prevY, prevScaleX, prevScaleY, canvas;
1962
+ var _ref4, _ref4$pixelRatio, pixelRatio, pageId, _ref4$mimeType, mimeType, stage, page, layer, prevX, prevY, prevScaleX, prevScaleY, displayOnlyNodes, rawCanvas, finalCanvas, ctx;
1963
1963
  return _regenerator().w(function (_context) {
1964
1964
  while (1) switch (_context.n) {
1965
1965
  case 0:
1966
- _ref4 = _arguments.length > 0 && _arguments[0] !== undefined ? _arguments[0] : {}, _ref4$pixelRatio = _ref4.pixelRatio, pixelRatio = _ref4$pixelRatio === void 0 ? 1 : _ref4$pixelRatio, _ref4.ignoreBackground, pageId = _ref4.pageId, _ref4.mimeType, _ref4.includeBleed, _ref4._skipTimeout, _ref4.quickMode;
1966
+ _ref4 = _arguments.length > 0 && _arguments[0] !== undefined ? _arguments[0] : {}, _ref4$pixelRatio = _ref4.pixelRatio, pixelRatio = _ref4$pixelRatio === void 0 ? 1 : _ref4$pixelRatio, _ref4.ignoreBackground, pageId = _ref4.pageId, _ref4$mimeType = _ref4.mimeType, mimeType = _ref4$mimeType === void 0 ? 'image/png' : _ref4$mimeType, _ref4.includeBleed, _ref4._skipTimeout, _ref4.quickMode;
1967
1967
  stage = self._stageRef;
1968
1968
  if (stage) {
1969
1969
  _context.n = 1;
@@ -1998,20 +1998,47 @@ var Store = types.model('Store', {
1998
1998
  layer.y(0);
1999
1999
  layer.scaleX(1);
2000
2000
  layer.scaleY(1);
2001
+
2002
+ // Hide display-only nodes (shadow, checkerboard, overlay) — not wanted in export
2003
+ displayOnlyNodes = layer.find('.display-only');
2004
+ displayOnlyNodes.forEach(function (n) {
2005
+ return n.hide();
2006
+ });
2001
2007
  layer.draw();
2002
- canvas = layer.toCanvas({
2008
+ rawCanvas = layer.toCanvas({
2003
2009
  pixelRatio: pixelRatio,
2004
2010
  x: 0,
2005
2011
  y: 0,
2006
2012
  width: self.width,
2007
2013
  height: self.height
2008
- }); // Restore
2014
+ }); // Restore display-only nodes
2015
+ displayOnlyNodes.forEach(function (n) {
2016
+ return n.show();
2017
+ });
2018
+
2019
+ // Restore layer transform
2009
2020
  layer.x(prevX);
2010
2021
  layer.y(prevY);
2011
2022
  layer.scaleX(prevScaleX);
2012
2023
  layer.scaleY(prevScaleY);
2013
2024
  layer.draw();
2014
- return _context.a(2, canvas);
2025
+
2026
+ // For JPEG, composite onto a white canvas to eliminate any remaining transparency
2027
+ // (avoids black areas and reduces file size vs checkerboard patterns)
2028
+ if (!(mimeType === 'image/jpeg')) {
2029
+ _context.n = 4;
2030
+ break;
2031
+ }
2032
+ finalCanvas = document.createElement('canvas');
2033
+ finalCanvas.width = rawCanvas.width;
2034
+ finalCanvas.height = rawCanvas.height;
2035
+ ctx = finalCanvas.getContext('2d');
2036
+ ctx.fillStyle = '#ffffff';
2037
+ ctx.fillRect(0, 0, finalCanvas.width, finalCanvas.height);
2038
+ ctx.drawImage(rawCanvas, 0, 0);
2039
+ return _context.a(2, finalCanvas);
2040
+ case 4:
2041
+ return _context.a(2, rawCanvas);
2015
2042
  }
2016
2043
  }, _callee);
2017
2044
  }))();
@@ -2042,7 +2069,7 @@ var Store = types.model('Store', {
2042
2069
  return _regenerator().w(function (_context3) {
2043
2070
  while (1) switch (_context3.n) {
2044
2071
  case 0:
2045
- _ref6 = _arguments3.length > 0 && _arguments3[0] !== undefined ? _arguments3[0] : {}, _ref6$mimeType = _ref6.mimeType, mimeType = _ref6$mimeType === void 0 ? 'image/png' : _ref6$mimeType, _ref6$quality = _ref6.quality, quality = _ref6$quality === void 0 ? 1 : _ref6$quality, rest = _objectWithoutProperties(_ref6, _excluded2$1);
2072
+ _ref6 = _arguments3.length > 0 && _arguments3[0] !== undefined ? _arguments3[0] : {}, _ref6$mimeType = _ref6.mimeType, mimeType = _ref6$mimeType === void 0 ? 'image/png' : _ref6$mimeType, _ref6$quality = _ref6.quality, quality = _ref6$quality === void 0 ? 0.92 : _ref6$quality, rest = _objectWithoutProperties(_ref6, _excluded2$1);
2046
2073
  _context3.n = 1;
2047
2074
  return self._toCanvas(_objectSpread2({
2048
2075
  mimeType: mimeType
@@ -10687,6 +10714,32 @@ var InputFieldsDialog = observer(function (_ref2) {
10687
10714
  }
10688
10715
  }, [fields.length]);
10689
10716
  var totalCount = initialTotalRef.current || fields.length;
10717
+
10718
+ // Back-from-summary: triggered by parent incrementing backTrigger prop
10719
+ // Must be defined and its useEffect called BEFORE any early returns (Rules of Hooks)
10720
+ var handleBackFromSummary = function handleBackFromSummary() {
10721
+ var last = completedHistoryRef.current.pop();
10722
+ if (!last) return;
10723
+ var el = last.el,
10724
+ previousValue = last.previousValue;
10725
+ if (el) {
10726
+ var isImage = el.custom && el.custom.inputType === 'image';
10727
+ el.set(isImage ? {
10728
+ src: previousValue || ''
10729
+ } : {
10730
+ text: previousValue || ''
10731
+ });
10732
+ isGoingBackRef.current = true;
10733
+ store._unresolveInputField(el);
10734
+ }
10735
+ // displayIndex stays unchanged — it already points to the last step (N-1)
10736
+ };
10737
+ useEffect(function () {
10738
+ if (backTrigger !== prevBackTriggerRef.current) {
10739
+ prevBackTriggerRef.current = backTrigger;
10740
+ handleBackFromSummary();
10741
+ }
10742
+ }, [backTrigger]);
10690
10743
  if (!enabled || fields.length === 0) return null;
10691
10744
 
10692
10745
  // Always show the first remaining field — the array shrinks as fields are resolved
@@ -10762,31 +10815,6 @@ var InputFieldsDialog = observer(function (_ref2) {
10762
10815
  };
10763
10816
  var canGoBack = displayIndex > 0;
10764
10817
 
10765
- // Back-from-summary: triggered by parent incrementing backTrigger prop
10766
- var handleBackFromSummary = function handleBackFromSummary() {
10767
- var last = completedHistoryRef.current.pop();
10768
- if (!last) return;
10769
- var el = last.el,
10770
- previousValue = last.previousValue;
10771
- if (el) {
10772
- var isImage = el.custom && el.custom.inputType === 'image';
10773
- el.set(isImage ? {
10774
- src: previousValue || ''
10775
- } : {
10776
- text: previousValue || ''
10777
- });
10778
- isGoingBackRef.current = true;
10779
- store._unresolveInputField(el);
10780
- }
10781
- // displayIndex stays unchanged — it already points to the last step (N-1)
10782
- };
10783
- useEffect(function () {
10784
- if (backTrigger !== prevBackTriggerRef.current) {
10785
- prevBackTriggerRef.current = backTrigger;
10786
- handleBackFromSummary();
10787
- }
10788
- }, [backTrigger]);
10789
-
10790
10818
  // ── Resolve which dialog component to use ───────────────────────────
10791
10819
  // Priority: per-type custom dialog > global CustomDialog > built-in
10792
10820
  var TYPE_DIALOG_MAP = {
@@ -10878,7 +10906,7 @@ var CheckerboardBackground = function CheckerboardBackground(_ref) {
10878
10906
  height: h,
10879
10907
  fill: "#ffffff",
10880
10908
  listening: false,
10881
- name: "page-background"
10909
+ name: "display-only"
10882
10910
  });
10883
10911
  return /*#__PURE__*/jsx(Rect, {
10884
10912
  x: 0,
@@ -10888,7 +10916,7 @@ var CheckerboardBackground = function CheckerboardBackground(_ref) {
10888
10916
  fillPatternImage: imgRef.current,
10889
10917
  fillPatternRepeat: "repeat",
10890
10918
  listening: false,
10891
- name: "page-background"
10919
+ name: "display-only"
10892
10920
  });
10893
10921
  };
10894
10922
  var ImageBackground = function ImageBackground(_ref2) {
@@ -10972,9 +11000,19 @@ var PageBackground = observer(function (_ref3) {
10972
11000
  });
10973
11001
  }
10974
11002
  if (bg === 'transparent') {
10975
- return /*#__PURE__*/jsx(CheckerboardBackground, {
10976
- w: w,
10977
- h: h
11003
+ return /*#__PURE__*/jsxs(Fragment, {
11004
+ children: [/*#__PURE__*/jsx(Rect, {
11005
+ x: 0,
11006
+ y: 0,
11007
+ width: w,
11008
+ height: h,
11009
+ fill: "#ffffff",
11010
+ listening: false,
11011
+ name: "page-background"
11012
+ }), /*#__PURE__*/jsx(CheckerboardBackground, {
11013
+ w: w,
11014
+ h: h
11015
+ })]
10978
11016
  });
10979
11017
  }
10980
11018
 
@@ -11071,7 +11109,8 @@ var PageOverlayFrame = observer(function (_ref4) {
11071
11109
  ctx.fillStrokeShape(shape);
11072
11110
  },
11073
11111
  fill: "rgba(240,240,240,0.5)",
11074
- listening: false
11112
+ listening: false,
11113
+ name: "display-only"
11075
11114
  });
11076
11115
  });
11077
11116
  var ALL_ANCHORS = ['top-left', 'top-center', 'top-right', 'middle-left', 'middle-right', 'bottom-left', 'bottom-center', 'bottom-right'];
@@ -11406,7 +11445,8 @@ var Workspace = observer(function (_ref6) {
11406
11445
  height: store.height,
11407
11446
  fill: "rgba(0,0,0,0.1)",
11408
11447
  cornerRadius: 0,
11409
- listening: false
11448
+ listening: false,
11449
+ name: "display-only"
11410
11450
  }), /*#__PURE__*/jsx(PageBackground, {
11411
11451
  store: store
11412
11452
  }), page && page.children.map(function (element) {