labellife-design-tool 2.2.3 → 2.2.4

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.
@@ -2097,6 +2097,32 @@ var InputFieldsDialog = observer(function (_ref2) {
2097
2097
  }
2098
2098
  }, [fields.length]);
2099
2099
  var totalCount = initialTotalRef.current || fields.length;
2100
+
2101
+ // Back-from-summary: triggered by parent incrementing backTrigger prop
2102
+ // Must be defined and its useEffect called BEFORE any early returns (Rules of Hooks)
2103
+ var handleBackFromSummary = function handleBackFromSummary() {
2104
+ var last = completedHistoryRef.current.pop();
2105
+ if (!last) return;
2106
+ var el = last.el,
2107
+ previousValue = last.previousValue;
2108
+ if (el) {
2109
+ var isImage = el.custom && el.custom.inputType === 'image';
2110
+ el.set(isImage ? {
2111
+ src: previousValue || ''
2112
+ } : {
2113
+ text: previousValue || ''
2114
+ });
2115
+ isGoingBackRef.current = true;
2116
+ store._unresolveInputField(el);
2117
+ }
2118
+ // displayIndex stays unchanged — it already points to the last step (N-1)
2119
+ };
2120
+ useEffect(function () {
2121
+ if (backTrigger !== prevBackTriggerRef.current) {
2122
+ prevBackTriggerRef.current = backTrigger;
2123
+ handleBackFromSummary();
2124
+ }
2125
+ }, [backTrigger]);
2100
2126
  if (!enabled || fields.length === 0) return null;
2101
2127
 
2102
2128
  // Always show the first remaining field — the array shrinks as fields are resolved
@@ -2172,31 +2198,6 @@ var InputFieldsDialog = observer(function (_ref2) {
2172
2198
  };
2173
2199
  var canGoBack = displayIndex > 0;
2174
2200
 
2175
- // Back-from-summary: triggered by parent incrementing backTrigger prop
2176
- var handleBackFromSummary = function handleBackFromSummary() {
2177
- var last = completedHistoryRef.current.pop();
2178
- if (!last) return;
2179
- var el = last.el,
2180
- previousValue = last.previousValue;
2181
- if (el) {
2182
- var isImage = el.custom && el.custom.inputType === 'image';
2183
- el.set(isImage ? {
2184
- src: previousValue || ''
2185
- } : {
2186
- text: previousValue || ''
2187
- });
2188
- isGoingBackRef.current = true;
2189
- store._unresolveInputField(el);
2190
- }
2191
- // displayIndex stays unchanged — it already points to the last step (N-1)
2192
- };
2193
- useEffect(function () {
2194
- if (backTrigger !== prevBackTriggerRef.current) {
2195
- prevBackTriggerRef.current = backTrigger;
2196
- handleBackFromSummary();
2197
- }
2198
- }, [backTrigger]);
2199
-
2200
2201
  // ── Resolve which dialog component to use ───────────────────────────
2201
2202
  // Priority: per-type custom dialog > global CustomDialog > built-in
2202
2203
  var TYPE_DIALOG_MAP = {