labellife-design-tool 2.3.5 → 2.3.7

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
@@ -1971,7 +1971,7 @@ var Store = types.model('Store', {
1971
1971
  _toCanvas: function _toCanvas() {
1972
1972
  var _arguments = arguments;
1973
1973
  return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
1974
- var _ref4, _ref4$pixelRatio, pixelRatio, pageId, _ref4$mimeType, mimeType, stage, page, layer, prevX, prevY, prevScaleX, prevScaleY, displayOnlyNodes, transformerNodes, rawCanvas, finalCanvas, ctx;
1974
+ var _ref4, _ref4$pixelRatio, pixelRatio, pageId, _ref4$mimeType, mimeType, stage, page, layer, fontFamilies, _collectFonts, prevX, prevY, prevScaleX, prevScaleY, prevStageWidth, prevStageHeight, displayOnlyNodes, transformerNodes, rawCanvas, finalCanvas, ctx;
1975
1975
  return _regenerator().w(function (_context) {
1976
1976
  while (1) switch (_context.n) {
1977
1977
  case 0:
@@ -2002,10 +2002,39 @@ var Store = types.model('Store', {
2002
2002
  }
2003
2003
  throw new Error('No layer found in stage for export.');
2004
2004
  case 3:
2005
+ // Ensure all fonts used in text elements are fully loaded before rendering.
2006
+ // _autoLoadFonts fires them asynchronously after loadJSON; without this
2007
+ // await the export can run before they arrive, causing the fallback font to
2008
+ // be used which produces garbled / mis-sized text in the output image.
2009
+ fontFamilies = new Set();
2010
+ _collectFonts = function collectFonts(elements) {
2011
+ elements.forEach(function (el) {
2012
+ if (el.type === 'text' && el.fontFamily) fontFamilies.add(el.fontFamily);
2013
+ if (Array.isArray(el.children)) _collectFonts(el.children);
2014
+ });
2015
+ };
2016
+ _collectFonts(page.children || []);
2017
+ if (!(fontFamilies.size > 0)) {
2018
+ _context.n = 4;
2019
+ break;
2020
+ }
2021
+ _context.n = 4;
2022
+ return Promise.allSettled(_toConsumableArray(fontFamilies).flatMap(function (f) {
2023
+ return [document.fonts.load("16px \"".concat(f, "\"")), document.fonts.load("bold 16px \"".concat(f, "\""))];
2024
+ }));
2025
+ case 4:
2005
2026
  prevX = layer.x();
2006
2027
  prevY = layer.y();
2007
2028
  prevScaleX = layer.scaleX();
2008
- prevScaleY = layer.scaleY();
2029
+ prevScaleY = layer.scaleY(); // Temporarily resize the stage to the exact design dimensions.
2030
+ // The viewport (stage) is usually smaller than the design when the design is
2031
+ // taller/wider than the screen. layer.draw() renders to the stage canvas, so
2032
+ // without this resize any element below stageSize.height would be clipped in
2033
+ // the internal canvas and potentially bleed into the export.
2034
+ prevStageWidth = stage.width();
2035
+ prevStageHeight = stage.height();
2036
+ stage.width(self.width);
2037
+ stage.height(self.height);
2009
2038
  layer.x(0);
2010
2039
  layer.y(0);
2011
2040
  layer.scaleX(1);
@@ -2037,17 +2066,19 @@ var Store = types.model('Store', {
2037
2066
  return n.show();
2038
2067
  });
2039
2068
 
2040
- // Restore layer transform
2069
+ // Restore layer transform and stage dimensions
2041
2070
  layer.x(prevX);
2042
2071
  layer.y(prevY);
2043
2072
  layer.scaleX(prevScaleX);
2044
2073
  layer.scaleY(prevScaleY);
2074
+ stage.width(prevStageWidth);
2075
+ stage.height(prevStageHeight);
2045
2076
  layer.draw();
2046
2077
 
2047
2078
  // For JPEG, composite onto a white canvas to eliminate any remaining transparency
2048
2079
  // (avoids black areas and reduces file size vs checkerboard patterns)
2049
2080
  if (!(mimeType === 'image/jpeg')) {
2050
- _context.n = 4;
2081
+ _context.n = 5;
2051
2082
  break;
2052
2083
  }
2053
2084
  finalCanvas = document.createElement('canvas');
@@ -2058,7 +2089,7 @@ var Store = types.model('Store', {
2058
2089
  ctx.fillRect(0, 0, finalCanvas.width, finalCanvas.height);
2059
2090
  ctx.drawImage(rawCanvas, 0, 0);
2060
2091
  return _context.a(2, finalCanvas);
2061
- case 4:
2092
+ case 5:
2062
2093
  return _context.a(2, rawCanvas);
2063
2094
  }
2064
2095
  }, _callee);
@@ -11288,7 +11319,7 @@ var SingleFieldDialog = function SingleFieldDialog(_ref) {
11288
11319
  case 'radio':
11289
11320
  {
11290
11321
  var otherSelected = value === '__custom__';
11291
- return /*#__PURE__*/jsxs(Box, {
11322
+ return /*#__PURE__*/jsx(Box, {
11292
11323
  sx: {
11293
11324
  mt: 1,
11294
11325
  flex: 1,
@@ -11309,7 +11340,7 @@ var SingleFieldDialog = function SingleFieldDialog(_ref) {
11309
11340
  background: '#aaa'
11310
11341
  }
11311
11342
  },
11312
- children: [/*#__PURE__*/jsxs(RadioGroup, {
11343
+ children: /*#__PURE__*/jsxs(RadioGroup, {
11313
11344
  value: value,
11314
11345
  onChange: function onChange(e) {
11315
11346
  return setValue(e.target.value);
@@ -11317,7 +11348,73 @@ var SingleFieldDialog = function SingleFieldDialog(_ref) {
11317
11348
  sx: {
11318
11349
  gap: 1
11319
11350
  },
11320
- children: [options.map(function (opt) {
11351
+ children: [/*#__PURE__*/jsxs(Box, {
11352
+ sx: {
11353
+ display: 'flex',
11354
+ flexDirection: 'column'
11355
+ },
11356
+ children: [/*#__PURE__*/jsx(FormControlLabel, {
11357
+ value: "__custom__",
11358
+ control: /*#__PURE__*/jsx(Radio, {
11359
+ sx: {
11360
+ color: '#d0d5dd',
11361
+ '&.Mui-checked': {
11362
+ color: accentColor
11363
+ }
11364
+ }
11365
+ }),
11366
+ label: /*#__PURE__*/jsx(Typography, {
11367
+ sx: {
11368
+ fontSize: 18
11369
+ },
11370
+ children: t('inputFieldsDialog.other', 'Other')
11371
+ }),
11372
+ sx: {
11373
+ m: 0,
11374
+ border: '1px solid',
11375
+ borderColor: otherSelected ? accentColor : '#d0d5dd',
11376
+ borderRadius: otherSelected ? '8px 8px 0 0' : '8px',
11377
+ borderBottom: otherSelected ? 'none' : undefined,
11378
+ px: 2,
11379
+ py: 0.75,
11380
+ transition: 'border-color 0.15s ease, border-radius 0.15s ease',
11381
+ backgroundColor: otherSelected ? 'rgba(13,131,205,0.04)' : 'transparent',
11382
+ '&:hover': {
11383
+ borderColor: accentColor,
11384
+ backgroundColor: 'rgba(13,131,205,0.03)'
11385
+ }
11386
+ }
11387
+ }), otherSelected && /*#__PURE__*/jsx(TextField, {
11388
+ autoFocus: true,
11389
+ fullWidth: true,
11390
+ value: customRadioValue,
11391
+ onChange: function onChange(e) {
11392
+ return setCustomRadioValue(e.target.value);
11393
+ },
11394
+ onKeyDown: function onKeyDown(e) {
11395
+ if (e.key === 'Enter' && customRadioValue.trim()) handleSubmit();
11396
+ },
11397
+ placeholder: t('inputFieldsDialog.otherPlaceholder', 'Type your answer…'),
11398
+ sx: {
11399
+ '& .MuiOutlinedInput-root': {
11400
+ borderRadius: '0 0 8px 8px',
11401
+ fontSize: 18,
11402
+ '& fieldset': {
11403
+ borderColor: accentColor,
11404
+ borderTopColor: 'transparent'
11405
+ },
11406
+ '&:hover fieldset': {
11407
+ borderColor: accentColor,
11408
+ borderTopColor: 'transparent'
11409
+ },
11410
+ '&.Mui-focused fieldset': {
11411
+ borderColor: accentColor,
11412
+ borderTopColor: 'transparent'
11413
+ }
11414
+ }
11415
+ }
11416
+ })]
11417
+ }), options.map(function (opt) {
11321
11418
  return /*#__PURE__*/jsx(FormControlLabel, {
11322
11419
  value: opt,
11323
11420
  control: /*#__PURE__*/jsx(Radio, {
@@ -11349,68 +11446,8 @@ var SingleFieldDialog = function SingleFieldDialog(_ref) {
11349
11446
  }
11350
11447
  }
11351
11448
  }, opt);
11352
- }), /*#__PURE__*/jsx(FormControlLabel, {
11353
- value: "__custom__",
11354
- control: /*#__PURE__*/jsx(Radio, {
11355
- sx: {
11356
- color: '#d0d5dd',
11357
- '&.Mui-checked': {
11358
- color: accentColor
11359
- }
11360
- }
11361
- }),
11362
- label: /*#__PURE__*/jsx(Typography, {
11363
- sx: {
11364
- fontSize: 18
11365
- },
11366
- children: t('inputFieldsDialog.other', 'Other')
11367
- }),
11368
- sx: {
11369
- m: 0,
11370
- border: '1px solid',
11371
- borderColor: otherSelected ? accentColor : '#d0d5dd',
11372
- borderRadius: otherSelected ? '8px 8px 0 0' : '8px',
11373
- borderBottom: otherSelected ? 'none' : undefined,
11374
- px: 2,
11375
- py: 0.75,
11376
- transition: 'border-color 0.15s ease, border-radius 0.15s ease',
11377
- backgroundColor: otherSelected ? 'rgba(13,131,205,0.04)' : 'transparent',
11378
- '&:hover': {
11379
- borderColor: accentColor,
11380
- backgroundColor: 'rgba(13,131,205,0.03)'
11381
- }
11382
- }
11383
11449
  })]
11384
- }), otherSelected && /*#__PURE__*/jsx(TextField, {
11385
- autoFocus: true,
11386
- fullWidth: true,
11387
- value: customRadioValue,
11388
- onChange: function onChange(e) {
11389
- return setCustomRadioValue(e.target.value);
11390
- },
11391
- onKeyDown: function onKeyDown(e) {
11392
- if (e.key === 'Enter' && customRadioValue.trim()) handleSubmit();
11393
- },
11394
- placeholder: t('inputFieldsDialog.otherPlaceholder', 'Type your answer…'),
11395
- sx: {
11396
- '& .MuiOutlinedInput-root': {
11397
- borderRadius: '0 0 8px 8px',
11398
- fontSize: 18,
11399
- '& fieldset': {
11400
- borderColor: accentColor,
11401
- borderTopColor: 'transparent'
11402
- },
11403
- '&:hover fieldset': {
11404
- borderColor: accentColor,
11405
- borderTopColor: 'transparent'
11406
- },
11407
- '&.Mui-focused fieldset': {
11408
- borderColor: accentColor,
11409
- borderTopColor: 'transparent'
11410
- }
11411
- }
11412
- }
11413
- })]
11450
+ })
11414
11451
  });
11415
11452
  }
11416
11453
  case 'list':