labellife-design-tool 2.2.2 → 2.2.3

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
@@ -10643,7 +10643,9 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
10643
10643
  var store = _ref2.store,
10644
10644
  _onComplete = _ref2.onComplete,
10645
10645
  _ref2$enabled = _ref2.enabled,
10646
- enabled = _ref2$enabled === void 0 ? true : _ref2$enabled;
10646
+ enabled = _ref2$enabled === void 0 ? true : _ref2$enabled,
10647
+ _ref2$backTrigger = _ref2.backTrigger,
10648
+ backTrigger = _ref2$backTrigger === void 0 ? 0 : _ref2$backTrigger;
10647
10649
  // displayIndex counts how many fields have been answered (for step indicator only).
10648
10650
  // Navigation always uses fields[0] — the first remaining pending field.
10649
10651
  var _useState5 = React.useState(0),
@@ -10652,6 +10654,8 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
10652
10654
  setDisplayIndex = _useState6[1];
10653
10655
  var initialTotalRef = React.useRef(0);
10654
10656
  var completedHistoryRef = React.useRef([]);
10657
+ var isGoingBackRef = React.useRef(false);
10658
+ var prevBackTriggerRef = React.useRef(backTrigger);
10655
10659
  var config = getInputFieldsConfig();
10656
10660
  var pendingFields = store._pendingInputFields || [];
10657
10661
 
@@ -10668,13 +10672,20 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
10668
10672
  // Capture total and reset display counter when a fresh batch appears
10669
10673
  React.useEffect(function () {
10670
10674
  if (fields.length > 0 && initialTotalRef.current === 0) {
10671
- initialTotalRef.current = fields.length;
10672
- setDisplayIndex(0);
10673
- completedHistoryRef.current = [];
10675
+ if (isGoingBackRef.current) {
10676
+ // Back-from-summary restored a field — recover total from history + pending
10677
+ isGoingBackRef.current = false;
10678
+ initialTotalRef.current = completedHistoryRef.current.length + fields.length;
10679
+ } else {
10680
+ // Genuine fresh batch
10681
+ initialTotalRef.current = fields.length;
10682
+ setDisplayIndex(0);
10683
+ completedHistoryRef.current = [];
10684
+ }
10674
10685
  }
10675
10686
  if (fields.length === 0) {
10676
10687
  initialTotalRef.current = 0;
10677
- completedHistoryRef.current = [];
10688
+ // History is intentionally kept so back-from-summary can use it
10678
10689
  }
10679
10690
  }, [fields.length]);
10680
10691
  var totalCount = initialTotalRef.current || fields.length;
@@ -10753,6 +10764,31 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
10753
10764
  };
10754
10765
  var canGoBack = displayIndex > 0;
10755
10766
 
10767
+ // Back-from-summary: triggered by parent incrementing backTrigger prop
10768
+ var handleBackFromSummary = function handleBackFromSummary() {
10769
+ var last = completedHistoryRef.current.pop();
10770
+ if (!last) return;
10771
+ var el = last.el,
10772
+ previousValue = last.previousValue;
10773
+ if (el) {
10774
+ var isImage = el.custom && el.custom.inputType === 'image';
10775
+ el.set(isImage ? {
10776
+ src: previousValue || ''
10777
+ } : {
10778
+ text: previousValue || ''
10779
+ });
10780
+ isGoingBackRef.current = true;
10781
+ store._unresolveInputField(el);
10782
+ }
10783
+ // displayIndex stays unchanged — it already points to the last step (N-1)
10784
+ };
10785
+ React.useEffect(function () {
10786
+ if (backTrigger !== prevBackTriggerRef.current) {
10787
+ prevBackTriggerRef.current = backTrigger;
10788
+ handleBackFromSummary();
10789
+ }
10790
+ }, [backTrigger]);
10791
+
10756
10792
  // ── Resolve which dialog component to use ───────────────────────────
10757
10793
  // Priority: per-type custom dialog > global CustomDialog > built-in
10758
10794
  var TYPE_DIALOG_MAP = {
@@ -11106,7 +11142,9 @@ var Workspace = mobxReactLite.observer(function (_ref6) {
11106
11142
  components = _ref6$components === void 0 ? {} : _ref6$components,
11107
11143
  _ref6$showInputFields = _ref6.showInputFieldsPopup,
11108
11144
  showInputFieldsPopup = _ref6$showInputFields === void 0 ? true : _ref6$showInputFields,
11109
- onInputFieldsComplete = _ref6.onInputFieldsComplete;
11145
+ onInputFieldsComplete = _ref6.onInputFieldsComplete,
11146
+ _ref6$backTrigger = _ref6.backTrigger,
11147
+ backTrigger = _ref6$backTrigger === void 0 ? 0 : _ref6$backTrigger;
11110
11148
  var stageRef = React.useRef(null);
11111
11149
  var containerRef = React.useRef(null);
11112
11150
  var _useState5 = React.useState({
@@ -11392,7 +11430,8 @@ var Workspace = mobxReactLite.observer(function (_ref6) {
11392
11430
  }) : null, /*#__PURE__*/jsxRuntime.jsx(InputFieldsDialog, {
11393
11431
  store: store,
11394
11432
  enabled: showInputFieldsPopup,
11395
- onComplete: onInputFieldsComplete
11433
+ onComplete: onInputFieldsComplete,
11434
+ backTrigger: backTrigger
11396
11435
  })]
11397
11436
  });
11398
11437
  });