labellife-design-tool 2.2.9 → 2.3.0

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.
@@ -2197,6 +2197,7 @@ var InputFieldsDialog = observer(function (_ref2) {
2197
2197
  setDisplayIndex = _useState8[1];
2198
2198
  var initialTotalRef = useRef(0);
2199
2199
  var completedHistoryRef = useRef([]);
2200
+ var removedDueToSkipRef = useRef([]);
2200
2201
  var isGoingBackRef = useRef(false);
2201
2202
  var prevBackTriggerRef = useRef(backTrigger);
2202
2203
  var config = getInputFieldsConfig();
@@ -2239,14 +2240,24 @@ var InputFieldsDialog = observer(function (_ref2) {
2239
2240
  var last = completedHistoryRef.current.pop();
2240
2241
  if (!last) return;
2241
2242
  var el = last.el,
2242
- previousValue = last.previousValue;
2243
+ previousValue = last.previousValue,
2244
+ removed = last.removed;
2243
2245
  if (el) {
2244
2246
  var isImage = el.custom && el.custom.inputType === 'image';
2245
- el.set(isImage ? {
2246
- src: previousValue || ''
2247
- } : {
2248
- text: previousValue || ''
2249
- });
2247
+ if (removed) {
2248
+ el.set({
2249
+ visible: true
2250
+ });
2251
+ removedDueToSkipRef.current = removedDueToSkipRef.current.filter(function (e) {
2252
+ return e.id !== el.id;
2253
+ });
2254
+ } else {
2255
+ el.set(isImage ? {
2256
+ src: previousValue || ''
2257
+ } : {
2258
+ text: previousValue || ''
2259
+ });
2260
+ }
2250
2261
  isGoingBackRef.current = true;
2251
2262
  store._unresolveInputField(el);
2252
2263
  }
@@ -2264,6 +2275,15 @@ var InputFieldsDialog = observer(function (_ref2) {
2264
2275
  var currentField = fields[0];
2265
2276
  if (!currentField) return null;
2266
2277
 
2278
+ // ── Helper: clear the removed-elements tracking ref ──────────────────
2279
+ // Elements are kept in the canvas with visible:false — they don't render
2280
+ // on screen or in exports, and can be restored via back navigation at any
2281
+ // point (including back-from-summary via backTrigger) without touching
2282
+ // deleted MST nodes.
2283
+ var _flushRemovedElements = function _flushRemovedElements() {
2284
+ removedDueToSkipRef.current = [];
2285
+ };
2286
+
2267
2287
  // ── Shared submit / skip / back helpers ─────────────────────────────
2268
2288
  var handleSubmit = function handleSubmit(elementId, value) {
2269
2289
  var el = store.getElementById(elementId);
@@ -2287,6 +2307,7 @@ var InputFieldsDialog = observer(function (_ref2) {
2287
2307
  }
2288
2308
  store._resolveInputField(elementId);
2289
2309
  if (fields.length <= 1) {
2310
+ _flushRemovedElements();
2290
2311
  store.history.addUndoState();
2291
2312
  if (_onComplete) _onComplete();
2292
2313
  } else {
@@ -2299,13 +2320,24 @@ var InputFieldsDialog = observer(function (_ref2) {
2299
2320
  var el = store.getElementById(elementId);
2300
2321
  var isImage = el && el.custom && el.custom.inputType === 'image';
2301
2322
  var previousValue = el ? isImage ? el.src : el.text : '';
2323
+ var shouldRemove = !!(el && el.custom && el.custom.removeIfSkipped);
2324
+ if (shouldRemove) {
2325
+ el.set({
2326
+ visible: false
2327
+ });
2328
+ removedDueToSkipRef.current.push(el);
2329
+ }
2302
2330
  completedHistoryRef.current.push({
2303
2331
  el: el,
2304
2332
  previousValue: previousValue,
2305
- skipped: true
2333
+ skipped: true,
2334
+ removed: shouldRemove
2306
2335
  });
2307
2336
  store._resolveInputField(elementId);
2308
2337
  if (fields.length <= 1) {
2338
+ var hadRemovals = removedDueToSkipRef.current.length > 0;
2339
+ _flushRemovedElements();
2340
+ if (hadRemovals) store.history.addUndoState();
2309
2341
  if (_onComplete) _onComplete();
2310
2342
  } else {
2311
2343
  setDisplayIndex(function (prev) {
@@ -2317,14 +2349,24 @@ var InputFieldsDialog = observer(function (_ref2) {
2317
2349
  var last = completedHistoryRef.current.pop();
2318
2350
  if (!last) return;
2319
2351
  var el = last.el,
2320
- previousValue = last.previousValue;
2352
+ previousValue = last.previousValue,
2353
+ removed = last.removed;
2321
2354
  if (el) {
2322
2355
  var isImage = el.custom && el.custom.inputType === 'image';
2323
- el.set(isImage ? {
2324
- src: previousValue || ''
2325
- } : {
2326
- text: previousValue || ''
2327
- });
2356
+ if (removed) {
2357
+ el.set({
2358
+ visible: true
2359
+ });
2360
+ removedDueToSkipRef.current = removedDueToSkipRef.current.filter(function (e) {
2361
+ return e.id !== el.id;
2362
+ });
2363
+ } else {
2364
+ el.set(isImage ? {
2365
+ src: previousValue || ''
2366
+ } : {
2367
+ text: previousValue || ''
2368
+ });
2369
+ }
2328
2370
  store._unresolveInputField(el);
2329
2371
  }
2330
2372
  setDisplayIndex(function (prev) {
@@ -2358,6 +2400,7 @@ var InputFieldsDialog = observer(function (_ref2) {
2358
2400
  onBack: handleBack,
2359
2401
  canGoBack: canGoBack,
2360
2402
  onComplete: function onComplete() {
2403
+ _flushRemovedElements();
2361
2404
  store.history.addUndoState();
2362
2405
  if (_onComplete) _onComplete();
2363
2406
  }