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.
@@ -2055,7 +2055,9 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
2055
2055
  var store = _ref2.store,
2056
2056
  _onComplete = _ref2.onComplete,
2057
2057
  _ref2$enabled = _ref2.enabled,
2058
- enabled = _ref2$enabled === void 0 ? true : _ref2$enabled;
2058
+ enabled = _ref2$enabled === void 0 ? true : _ref2$enabled,
2059
+ _ref2$backTrigger = _ref2.backTrigger,
2060
+ backTrigger = _ref2$backTrigger === void 0 ? 0 : _ref2$backTrigger;
2059
2061
  // displayIndex counts how many fields have been answered (for step indicator only).
2060
2062
  // Navigation always uses fields[0] — the first remaining pending field.
2061
2063
  var _useState5 = react.useState(0),
@@ -2064,6 +2066,8 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
2064
2066
  setDisplayIndex = _useState6[1];
2065
2067
  var initialTotalRef = react.useRef(0);
2066
2068
  var completedHistoryRef = react.useRef([]);
2069
+ var isGoingBackRef = react.useRef(false);
2070
+ var prevBackTriggerRef = react.useRef(backTrigger);
2067
2071
  var config = getInputFieldsConfig();
2068
2072
  var pendingFields = store._pendingInputFields || [];
2069
2073
 
@@ -2080,13 +2084,20 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
2080
2084
  // Capture total and reset display counter when a fresh batch appears
2081
2085
  react.useEffect(function () {
2082
2086
  if (fields.length > 0 && initialTotalRef.current === 0) {
2083
- initialTotalRef.current = fields.length;
2084
- setDisplayIndex(0);
2085
- completedHistoryRef.current = [];
2087
+ if (isGoingBackRef.current) {
2088
+ // Back-from-summary restored a field — recover total from history + pending
2089
+ isGoingBackRef.current = false;
2090
+ initialTotalRef.current = completedHistoryRef.current.length + fields.length;
2091
+ } else {
2092
+ // Genuine fresh batch
2093
+ initialTotalRef.current = fields.length;
2094
+ setDisplayIndex(0);
2095
+ completedHistoryRef.current = [];
2096
+ }
2086
2097
  }
2087
2098
  if (fields.length === 0) {
2088
2099
  initialTotalRef.current = 0;
2089
- completedHistoryRef.current = [];
2100
+ // History is intentionally kept so back-from-summary can use it
2090
2101
  }
2091
2102
  }, [fields.length]);
2092
2103
  var totalCount = initialTotalRef.current || fields.length;
@@ -2165,6 +2176,31 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
2165
2176
  };
2166
2177
  var canGoBack = displayIndex > 0;
2167
2178
 
2179
+ // Back-from-summary: triggered by parent incrementing backTrigger prop
2180
+ var handleBackFromSummary = function handleBackFromSummary() {
2181
+ var last = completedHistoryRef.current.pop();
2182
+ if (!last) return;
2183
+ var el = last.el,
2184
+ previousValue = last.previousValue;
2185
+ if (el) {
2186
+ var isImage = el.custom && el.custom.inputType === 'image';
2187
+ el.set(isImage ? {
2188
+ src: previousValue || ''
2189
+ } : {
2190
+ text: previousValue || ''
2191
+ });
2192
+ isGoingBackRef.current = true;
2193
+ store._unresolveInputField(el);
2194
+ }
2195
+ // displayIndex stays unchanged — it already points to the last step (N-1)
2196
+ };
2197
+ react.useEffect(function () {
2198
+ if (backTrigger !== prevBackTriggerRef.current) {
2199
+ prevBackTriggerRef.current = backTrigger;
2200
+ handleBackFromSummary();
2201
+ }
2202
+ }, [backTrigger]);
2203
+
2168
2204
  // ── Resolve which dialog component to use ───────────────────────────
2169
2205
  // Priority: per-type custom dialog > global CustomDialog > built-in
2170
2206
  var TYPE_DIALOG_MAP = {
@@ -2518,7 +2554,9 @@ var Workspace = mobxReactLite.observer(function (_ref6) {
2518
2554
  components = _ref6$components === void 0 ? {} : _ref6$components,
2519
2555
  _ref6$showInputFields = _ref6.showInputFieldsPopup,
2520
2556
  showInputFieldsPopup = _ref6$showInputFields === void 0 ? true : _ref6$showInputFields,
2521
- onInputFieldsComplete = _ref6.onInputFieldsComplete;
2557
+ onInputFieldsComplete = _ref6.onInputFieldsComplete,
2558
+ _ref6$backTrigger = _ref6.backTrigger,
2559
+ backTrigger = _ref6$backTrigger === void 0 ? 0 : _ref6$backTrigger;
2522
2560
  var stageRef = react.useRef(null);
2523
2561
  var containerRef = react.useRef(null);
2524
2562
  var _useState5 = react.useState({
@@ -2804,7 +2842,8 @@ var Workspace = mobxReactLite.observer(function (_ref6) {
2804
2842
  }) : null, /*#__PURE__*/jsxRuntime.jsx(InputFieldsDialog, {
2805
2843
  store: store,
2806
2844
  enabled: showInputFieldsPopup,
2807
- onComplete: onInputFieldsComplete
2845
+ onComplete: onInputFieldsComplete,
2846
+ backTrigger: backTrigger
2808
2847
  })]
2809
2848
  });
2810
2849
  });