labellife-design-tool 2.2.0 → 2.2.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/cjs/index.js CHANGED
@@ -52,6 +52,7 @@ var ZoomOutIcon = require('@mui/icons-material/ZoomOut');
52
52
  var FitScreenIcon = require('@mui/icons-material/FitScreen');
53
53
  var reactKonva = require('react-konva');
54
54
  var Konva = require('konva');
55
+ var ArrowBackIcon = require('@mui/icons-material/ArrowBack');
55
56
 
56
57
  function _arrayLikeToArray(r, a) {
57
58
  (null == a || a > r.length) && (a = r.length);
@@ -1431,15 +1432,22 @@ var _excluded$5 = ["mimeType", "quality", "dpi", "dpiMetadata"],
1431
1432
  _excluded4 = ["fileName"];
1432
1433
 
1433
1434
  // Detect embedded base64 data URLs (data:...;base64,...).
1434
- // These bloat exported JSON significantly (a single image can be 1MB+).
1435
1435
  // Regular http/https/blob URLs are preserved.
1436
1436
  var isBase64DataUrl = function isBase64DataUrl(v) {
1437
1437
  return typeof v === 'string' && v.startsWith('data:') && v.includes(';base64,');
1438
1438
  };
1439
+
1440
+ // Only strip base64 from variable input-field images (inputField: true).
1441
+ // Static design images ARE the template content — stripping them clears the design.
1442
+ // Variable input-field placeholders are replaced at runtime anyway, so stripping
1443
+ // their (usually tiny SVG) placeholder base64 is safe and keeps exports clean.
1439
1444
  var _stripBase64FromElement = function stripBase64FromElement(el) {
1440
1445
  var out = _objectSpread2({}, el);
1441
- if (isBase64DataUrl(out.src)) out.src = '';
1442
- if (isBase64DataUrl(out.clipSrc)) out.clipSrc = '';
1446
+ var isInputField = out.custom && out.custom.inputField;
1447
+ if (isInputField) {
1448
+ if (isBase64DataUrl(out.src)) out.src = '';
1449
+ if (isBase64DataUrl(out.clipSrc)) out.clipSrc = '';
1450
+ }
1443
1451
  if (Array.isArray(out.children)) {
1444
1452
  out.children = out.children.map(_stripBase64FromElement);
1445
1453
  }
@@ -1673,6 +1681,15 @@ var Store = mobxStateTree.types.model('Store', {
1673
1681
  return el.id !== id;
1674
1682
  });
1675
1683
  },
1684
+ _unresolveInputField: function _unresolveInputField(el) {
1685
+ // Re-insert at the front so it becomes the next field shown (back navigation)
1686
+ var alreadyPending = self._pendingInputFields.some(function (f) {
1687
+ return f.id === el.id;
1688
+ });
1689
+ if (!alreadyPending) {
1690
+ self._pendingInputFields.unshift(el);
1691
+ }
1692
+ },
1676
1693
  clearPendingInputFields: function clearPendingInputFields() {
1677
1694
  self._pendingInputFields = [];
1678
1695
  }
@@ -2160,7 +2177,7 @@ var Store = mobxStateTree.types.model('Store', {
2160
2177
  _ref0$fileName = _ref0.fileName,
2161
2178
  fileName = _ref0$fileName === void 0 ? 'design.json' : _ref0$fileName,
2162
2179
  _ref0$stripBase = _ref0.stripBase64,
2163
- stripBase64 = _ref0$stripBase === void 0 ? true : _ref0$stripBase;
2180
+ stripBase64 = _ref0$stripBase === void 0 ? false : _ref0$stripBase;
2164
2181
  var data = stripBase64 ? stripBase64FromExport(self.toJSON()) : self.toJSON();
2165
2182
  var json = JSON.stringify(data, null, 2);
2166
2183
  var blob = new Blob([json], {
@@ -10246,6 +10263,8 @@ var SingleFieldDialog = function SingleFieldDialog(_ref) {
10246
10263
  var field = _ref.field,
10247
10264
  onSubmit = _ref.onSubmit,
10248
10265
  onSkip = _ref.onSkip,
10266
+ onBack = _ref.onBack,
10267
+ canGoBack = _ref.canGoBack,
10249
10268
  currentIndex = _ref.currentIndex,
10250
10269
  totalCount = _ref.totalCount;
10251
10270
  var _useState = React.useState(''),
@@ -10554,7 +10573,26 @@ var SingleFieldDialog = function SingleFieldDialog(_ref) {
10554
10573
  gap: 2,
10555
10574
  mt: 4.5
10556
10575
  },
10557
- children: [/*#__PURE__*/jsxRuntime.jsx(material.Button, {
10576
+ children: [canGoBack && /*#__PURE__*/jsxRuntime.jsx(material.Button, {
10577
+ variant: "outlined",
10578
+ onClick: onBack,
10579
+ startIcon: /*#__PURE__*/jsxRuntime.jsx(ArrowBackIcon, {}),
10580
+ sx: {
10581
+ textTransform: 'none',
10582
+ fontWeight: 500,
10583
+ fontSize: 21,
10584
+ px: 3,
10585
+ py: 1.65,
10586
+ borderRadius: '10px',
10587
+ color: '#555',
10588
+ borderColor: '#d0d5dd',
10589
+ '&:hover': {
10590
+ borderColor: '#aaa',
10591
+ backgroundColor: 'rgba(0,0,0,0.02)'
10592
+ }
10593
+ },
10594
+ children: t('inputFieldsDialog.back', 'Back')
10595
+ }), /*#__PURE__*/jsxRuntime.jsx(material.Button, {
10558
10596
  variant: "contained",
10559
10597
  onClick: handleSubmit,
10560
10598
  disabled: isRequired && !value,
@@ -10613,6 +10651,7 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
10613
10651
  displayIndex = _useState6[0],
10614
10652
  setDisplayIndex = _useState6[1];
10615
10653
  var initialTotalRef = React.useRef(0);
10654
+ var completedHistoryRef = React.useRef([]);
10616
10655
  var config = getInputFieldsConfig();
10617
10656
  var pendingFields = store._pendingInputFields || [];
10618
10657
 
@@ -10631,9 +10670,11 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
10631
10670
  if (fields.length > 0 && initialTotalRef.current === 0) {
10632
10671
  initialTotalRef.current = fields.length;
10633
10672
  setDisplayIndex(0);
10673
+ completedHistoryRef.current = [];
10634
10674
  }
10635
10675
  if (fields.length === 0) {
10636
10676
  initialTotalRef.current = 0;
10677
+ completedHistoryRef.current = [];
10637
10678
  }
10638
10679
  }, [fields.length]);
10639
10680
  var totalCount = initialTotalRef.current || fields.length;
@@ -10643,11 +10684,17 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
10643
10684
  var currentField = fields[0];
10644
10685
  if (!currentField) return null;
10645
10686
 
10646
- // ── Shared submit / skip helpers ────────────────────────────────────
10687
+ // ── Shared submit / skip / back helpers ─────────────────────────────
10647
10688
  var handleSubmit = function handleSubmit(elementId, value) {
10648
10689
  var el = store.getElementById(elementId);
10690
+ var isImage = el && el.custom && el.custom.inputType === 'image';
10691
+ var previousValue = el ? isImage ? el.src : el.text : '';
10692
+ completedHistoryRef.current.push({
10693
+ el: el,
10694
+ previousValue: previousValue,
10695
+ skipped: false
10696
+ });
10649
10697
  if (el && el.set) {
10650
- var isImage = el.custom && el.custom.inputType === 'image';
10651
10698
  if (isImage) {
10652
10699
  el.set({
10653
10700
  src: String(value)
@@ -10669,6 +10716,14 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
10669
10716
  }
10670
10717
  };
10671
10718
  var handleSkip = function handleSkip(elementId) {
10719
+ var el = store.getElementById(elementId);
10720
+ var isImage = el && el.custom && el.custom.inputType === 'image';
10721
+ var previousValue = el ? isImage ? el.src : el.text : '';
10722
+ completedHistoryRef.current.push({
10723
+ el: el,
10724
+ previousValue: previousValue,
10725
+ skipped: true
10726
+ });
10672
10727
  store._resolveInputField(elementId);
10673
10728
  if (fields.length <= 1) {
10674
10729
  if (_onComplete) _onComplete();
@@ -10678,6 +10733,25 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
10678
10733
  });
10679
10734
  }
10680
10735
  };
10736
+ var handleBack = function handleBack() {
10737
+ var last = completedHistoryRef.current.pop();
10738
+ if (!last) return;
10739
+ var el = last.el,
10740
+ previousValue = last.previousValue;
10741
+ if (el) {
10742
+ var isImage = el.custom && el.custom.inputType === 'image';
10743
+ el.set(isImage ? {
10744
+ src: previousValue || ''
10745
+ } : {
10746
+ text: previousValue || ''
10747
+ });
10748
+ store._unresolveInputField(el);
10749
+ }
10750
+ setDisplayIndex(function (prev) {
10751
+ return Math.max(0, prev - 1);
10752
+ });
10753
+ };
10754
+ var canGoBack = displayIndex > 0;
10681
10755
 
10682
10756
  // ── Resolve which dialog component to use ───────────────────────────
10683
10757
  // Priority: per-type custom dialog > global CustomDialog > built-in
@@ -10699,6 +10773,8 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
10699
10773
  totalCount: totalCount,
10700
10774
  onSubmit: handleSubmit,
10701
10775
  onSkip: handleSkip,
10776
+ onBack: handleBack,
10777
+ canGoBack: canGoBack,
10702
10778
  onComplete: function onComplete() {
10703
10779
  store.history.addUndoState();
10704
10780
  if (_onComplete) _onComplete();
@@ -10709,6 +10785,8 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
10709
10785
  field: currentField,
10710
10786
  onSubmit: handleSubmit,
10711
10787
  onSkip: handleSkip,
10788
+ onBack: handleBack,
10789
+ canGoBack: canGoBack,
10712
10790
  currentIndex: displayIndex,
10713
10791
  totalCount: totalCount
10714
10792
  });