labellife-design-tool 2.2.1 → 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/esm/index.js CHANGED
@@ -50,6 +50,7 @@ import ZoomOutIcon from '@mui/icons-material/ZoomOut';
50
50
  import FitScreenIcon from '@mui/icons-material/FitScreen';
51
51
  import { Image as Image$1, Group, Rect, Text, Arrow, Path, RegularPolygon, Star, Circle, Line, Shape as Shape$1, Transformer, Stage, Layer } from 'react-konva';
52
52
  import Konva from 'konva';
53
+ import ArrowBackIcon from '@mui/icons-material/ArrowBack';
53
54
 
54
55
  function _arrayLikeToArray(r, a) {
55
56
  (null == a || a > r.length) && (a = r.length);
@@ -1678,6 +1679,15 @@ var Store = types.model('Store', {
1678
1679
  return el.id !== id;
1679
1680
  });
1680
1681
  },
1682
+ _unresolveInputField: function _unresolveInputField(el) {
1683
+ // Re-insert at the front so it becomes the next field shown (back navigation)
1684
+ var alreadyPending = self._pendingInputFields.some(function (f) {
1685
+ return f.id === el.id;
1686
+ });
1687
+ if (!alreadyPending) {
1688
+ self._pendingInputFields.unshift(el);
1689
+ }
1690
+ },
1681
1691
  clearPendingInputFields: function clearPendingInputFields() {
1682
1692
  self._pendingInputFields = [];
1683
1693
  }
@@ -10251,6 +10261,8 @@ var SingleFieldDialog = function SingleFieldDialog(_ref) {
10251
10261
  var field = _ref.field,
10252
10262
  onSubmit = _ref.onSubmit,
10253
10263
  onSkip = _ref.onSkip,
10264
+ onBack = _ref.onBack,
10265
+ canGoBack = _ref.canGoBack,
10254
10266
  currentIndex = _ref.currentIndex,
10255
10267
  totalCount = _ref.totalCount;
10256
10268
  var _useState = useState(''),
@@ -10559,7 +10571,26 @@ var SingleFieldDialog = function SingleFieldDialog(_ref) {
10559
10571
  gap: 2,
10560
10572
  mt: 4.5
10561
10573
  },
10562
- children: [/*#__PURE__*/jsx(Button, {
10574
+ children: [canGoBack && /*#__PURE__*/jsx(Button, {
10575
+ variant: "outlined",
10576
+ onClick: onBack,
10577
+ startIcon: /*#__PURE__*/jsx(ArrowBackIcon, {}),
10578
+ sx: {
10579
+ textTransform: 'none',
10580
+ fontWeight: 500,
10581
+ fontSize: 21,
10582
+ px: 3,
10583
+ py: 1.65,
10584
+ borderRadius: '10px',
10585
+ color: '#555',
10586
+ borderColor: '#d0d5dd',
10587
+ '&:hover': {
10588
+ borderColor: '#aaa',
10589
+ backgroundColor: 'rgba(0,0,0,0.02)'
10590
+ }
10591
+ },
10592
+ children: t('inputFieldsDialog.back', 'Back')
10593
+ }), /*#__PURE__*/jsx(Button, {
10563
10594
  variant: "contained",
10564
10595
  onClick: handleSubmit,
10565
10596
  disabled: isRequired && !value,
@@ -10618,6 +10649,7 @@ var InputFieldsDialog = observer(function (_ref2) {
10618
10649
  displayIndex = _useState6[0],
10619
10650
  setDisplayIndex = _useState6[1];
10620
10651
  var initialTotalRef = useRef(0);
10652
+ var completedHistoryRef = useRef([]);
10621
10653
  var config = getInputFieldsConfig();
10622
10654
  var pendingFields = store._pendingInputFields || [];
10623
10655
 
@@ -10636,9 +10668,11 @@ var InputFieldsDialog = observer(function (_ref2) {
10636
10668
  if (fields.length > 0 && initialTotalRef.current === 0) {
10637
10669
  initialTotalRef.current = fields.length;
10638
10670
  setDisplayIndex(0);
10671
+ completedHistoryRef.current = [];
10639
10672
  }
10640
10673
  if (fields.length === 0) {
10641
10674
  initialTotalRef.current = 0;
10675
+ completedHistoryRef.current = [];
10642
10676
  }
10643
10677
  }, [fields.length]);
10644
10678
  var totalCount = initialTotalRef.current || fields.length;
@@ -10648,11 +10682,17 @@ var InputFieldsDialog = observer(function (_ref2) {
10648
10682
  var currentField = fields[0];
10649
10683
  if (!currentField) return null;
10650
10684
 
10651
- // ── Shared submit / skip helpers ────────────────────────────────────
10685
+ // ── Shared submit / skip / back helpers ─────────────────────────────
10652
10686
  var handleSubmit = function handleSubmit(elementId, value) {
10653
10687
  var el = store.getElementById(elementId);
10688
+ var isImage = el && el.custom && el.custom.inputType === 'image';
10689
+ var previousValue = el ? isImage ? el.src : el.text : '';
10690
+ completedHistoryRef.current.push({
10691
+ el: el,
10692
+ previousValue: previousValue,
10693
+ skipped: false
10694
+ });
10654
10695
  if (el && el.set) {
10655
- var isImage = el.custom && el.custom.inputType === 'image';
10656
10696
  if (isImage) {
10657
10697
  el.set({
10658
10698
  src: String(value)
@@ -10674,6 +10714,14 @@ var InputFieldsDialog = observer(function (_ref2) {
10674
10714
  }
10675
10715
  };
10676
10716
  var handleSkip = function handleSkip(elementId) {
10717
+ var el = store.getElementById(elementId);
10718
+ var isImage = el && el.custom && el.custom.inputType === 'image';
10719
+ var previousValue = el ? isImage ? el.src : el.text : '';
10720
+ completedHistoryRef.current.push({
10721
+ el: el,
10722
+ previousValue: previousValue,
10723
+ skipped: true
10724
+ });
10677
10725
  store._resolveInputField(elementId);
10678
10726
  if (fields.length <= 1) {
10679
10727
  if (_onComplete) _onComplete();
@@ -10683,6 +10731,25 @@ var InputFieldsDialog = observer(function (_ref2) {
10683
10731
  });
10684
10732
  }
10685
10733
  };
10734
+ var handleBack = function handleBack() {
10735
+ var last = completedHistoryRef.current.pop();
10736
+ if (!last) return;
10737
+ var el = last.el,
10738
+ previousValue = last.previousValue;
10739
+ if (el) {
10740
+ var isImage = el.custom && el.custom.inputType === 'image';
10741
+ el.set(isImage ? {
10742
+ src: previousValue || ''
10743
+ } : {
10744
+ text: previousValue || ''
10745
+ });
10746
+ store._unresolveInputField(el);
10747
+ }
10748
+ setDisplayIndex(function (prev) {
10749
+ return Math.max(0, prev - 1);
10750
+ });
10751
+ };
10752
+ var canGoBack = displayIndex > 0;
10686
10753
 
10687
10754
  // ── Resolve which dialog component to use ───────────────────────────
10688
10755
  // Priority: per-type custom dialog > global CustomDialog > built-in
@@ -10704,6 +10771,8 @@ var InputFieldsDialog = observer(function (_ref2) {
10704
10771
  totalCount: totalCount,
10705
10772
  onSubmit: handleSubmit,
10706
10773
  onSkip: handleSkip,
10774
+ onBack: handleBack,
10775
+ canGoBack: canGoBack,
10707
10776
  onComplete: function onComplete() {
10708
10777
  store.history.addUndoState();
10709
10778
  if (_onComplete) _onComplete();
@@ -10714,6 +10783,8 @@ var InputFieldsDialog = observer(function (_ref2) {
10714
10783
  field: currentField,
10715
10784
  onSubmit: handleSubmit,
10716
10785
  onSkip: handleSkip,
10786
+ onBack: handleBack,
10787
+ canGoBack: canGoBack,
10717
10788
  currentIndex: displayIndex,
10718
10789
  totalCount: totalCount
10719
10790
  });