labellife-design-tool 2.2.1 → 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/canvas/workspace.js +109 -8
- package/dist/cjs/canvas/workspace.js.map +1 -1
- package/dist/cjs/index.js +118 -8
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/model/store.js +9 -0
- package/dist/cjs/model/store.js.map +1 -1
- package/dist/esm/canvas/workspace.js +109 -8
- package/dist/esm/canvas/workspace.js.map +1 -1
- package/dist/esm/index.js +118 -8
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/model/store.js +9 -0
- package/dist/esm/model/store.js.map +1 -1
- package/package.json +1 -1
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,
|
|
@@ -10610,7 +10641,9 @@ var InputFieldsDialog = observer(function (_ref2) {
|
|
|
10610
10641
|
var store = _ref2.store,
|
|
10611
10642
|
_onComplete = _ref2.onComplete,
|
|
10612
10643
|
_ref2$enabled = _ref2.enabled,
|
|
10613
|
-
enabled = _ref2$enabled === void 0 ? true : _ref2$enabled
|
|
10644
|
+
enabled = _ref2$enabled === void 0 ? true : _ref2$enabled,
|
|
10645
|
+
_ref2$backTrigger = _ref2.backTrigger,
|
|
10646
|
+
backTrigger = _ref2$backTrigger === void 0 ? 0 : _ref2$backTrigger;
|
|
10614
10647
|
// displayIndex counts how many fields have been answered (for step indicator only).
|
|
10615
10648
|
// Navigation always uses fields[0] — the first remaining pending field.
|
|
10616
10649
|
var _useState5 = useState(0),
|
|
@@ -10618,6 +10651,9 @@ var InputFieldsDialog = observer(function (_ref2) {
|
|
|
10618
10651
|
displayIndex = _useState6[0],
|
|
10619
10652
|
setDisplayIndex = _useState6[1];
|
|
10620
10653
|
var initialTotalRef = useRef(0);
|
|
10654
|
+
var completedHistoryRef = useRef([]);
|
|
10655
|
+
var isGoingBackRef = useRef(false);
|
|
10656
|
+
var prevBackTriggerRef = useRef(backTrigger);
|
|
10621
10657
|
var config = getInputFieldsConfig();
|
|
10622
10658
|
var pendingFields = store._pendingInputFields || [];
|
|
10623
10659
|
|
|
@@ -10634,11 +10670,20 @@ var InputFieldsDialog = observer(function (_ref2) {
|
|
|
10634
10670
|
// Capture total and reset display counter when a fresh batch appears
|
|
10635
10671
|
useEffect(function () {
|
|
10636
10672
|
if (fields.length > 0 && initialTotalRef.current === 0) {
|
|
10637
|
-
|
|
10638
|
-
|
|
10673
|
+
if (isGoingBackRef.current) {
|
|
10674
|
+
// Back-from-summary restored a field — recover total from history + pending
|
|
10675
|
+
isGoingBackRef.current = false;
|
|
10676
|
+
initialTotalRef.current = completedHistoryRef.current.length + fields.length;
|
|
10677
|
+
} else {
|
|
10678
|
+
// Genuine fresh batch
|
|
10679
|
+
initialTotalRef.current = fields.length;
|
|
10680
|
+
setDisplayIndex(0);
|
|
10681
|
+
completedHistoryRef.current = [];
|
|
10682
|
+
}
|
|
10639
10683
|
}
|
|
10640
10684
|
if (fields.length === 0) {
|
|
10641
10685
|
initialTotalRef.current = 0;
|
|
10686
|
+
// History is intentionally kept so back-from-summary can use it
|
|
10642
10687
|
}
|
|
10643
10688
|
}, [fields.length]);
|
|
10644
10689
|
var totalCount = initialTotalRef.current || fields.length;
|
|
@@ -10648,11 +10693,17 @@ var InputFieldsDialog = observer(function (_ref2) {
|
|
|
10648
10693
|
var currentField = fields[0];
|
|
10649
10694
|
if (!currentField) return null;
|
|
10650
10695
|
|
|
10651
|
-
// ── Shared submit / skip helpers
|
|
10696
|
+
// ── Shared submit / skip / back helpers ─────────────────────────────
|
|
10652
10697
|
var handleSubmit = function handleSubmit(elementId, value) {
|
|
10653
10698
|
var el = store.getElementById(elementId);
|
|
10699
|
+
var isImage = el && el.custom && el.custom.inputType === 'image';
|
|
10700
|
+
var previousValue = el ? isImage ? el.src : el.text : '';
|
|
10701
|
+
completedHistoryRef.current.push({
|
|
10702
|
+
el: el,
|
|
10703
|
+
previousValue: previousValue,
|
|
10704
|
+
skipped: false
|
|
10705
|
+
});
|
|
10654
10706
|
if (el && el.set) {
|
|
10655
|
-
var isImage = el.custom && el.custom.inputType === 'image';
|
|
10656
10707
|
if (isImage) {
|
|
10657
10708
|
el.set({
|
|
10658
10709
|
src: String(value)
|
|
@@ -10674,6 +10725,14 @@ var InputFieldsDialog = observer(function (_ref2) {
|
|
|
10674
10725
|
}
|
|
10675
10726
|
};
|
|
10676
10727
|
var handleSkip = function handleSkip(elementId) {
|
|
10728
|
+
var el = store.getElementById(elementId);
|
|
10729
|
+
var isImage = el && el.custom && el.custom.inputType === 'image';
|
|
10730
|
+
var previousValue = el ? isImage ? el.src : el.text : '';
|
|
10731
|
+
completedHistoryRef.current.push({
|
|
10732
|
+
el: el,
|
|
10733
|
+
previousValue: previousValue,
|
|
10734
|
+
skipped: true
|
|
10735
|
+
});
|
|
10677
10736
|
store._resolveInputField(elementId);
|
|
10678
10737
|
if (fields.length <= 1) {
|
|
10679
10738
|
if (_onComplete) _onComplete();
|
|
@@ -10683,6 +10742,50 @@ var InputFieldsDialog = observer(function (_ref2) {
|
|
|
10683
10742
|
});
|
|
10684
10743
|
}
|
|
10685
10744
|
};
|
|
10745
|
+
var handleBack = function handleBack() {
|
|
10746
|
+
var last = completedHistoryRef.current.pop();
|
|
10747
|
+
if (!last) return;
|
|
10748
|
+
var el = last.el,
|
|
10749
|
+
previousValue = last.previousValue;
|
|
10750
|
+
if (el) {
|
|
10751
|
+
var isImage = el.custom && el.custom.inputType === 'image';
|
|
10752
|
+
el.set(isImage ? {
|
|
10753
|
+
src: previousValue || ''
|
|
10754
|
+
} : {
|
|
10755
|
+
text: previousValue || ''
|
|
10756
|
+
});
|
|
10757
|
+
store._unresolveInputField(el);
|
|
10758
|
+
}
|
|
10759
|
+
setDisplayIndex(function (prev) {
|
|
10760
|
+
return Math.max(0, prev - 1);
|
|
10761
|
+
});
|
|
10762
|
+
};
|
|
10763
|
+
var canGoBack = displayIndex > 0;
|
|
10764
|
+
|
|
10765
|
+
// Back-from-summary: triggered by parent incrementing backTrigger prop
|
|
10766
|
+
var handleBackFromSummary = function handleBackFromSummary() {
|
|
10767
|
+
var last = completedHistoryRef.current.pop();
|
|
10768
|
+
if (!last) return;
|
|
10769
|
+
var el = last.el,
|
|
10770
|
+
previousValue = last.previousValue;
|
|
10771
|
+
if (el) {
|
|
10772
|
+
var isImage = el.custom && el.custom.inputType === 'image';
|
|
10773
|
+
el.set(isImage ? {
|
|
10774
|
+
src: previousValue || ''
|
|
10775
|
+
} : {
|
|
10776
|
+
text: previousValue || ''
|
|
10777
|
+
});
|
|
10778
|
+
isGoingBackRef.current = true;
|
|
10779
|
+
store._unresolveInputField(el);
|
|
10780
|
+
}
|
|
10781
|
+
// displayIndex stays unchanged — it already points to the last step (N-1)
|
|
10782
|
+
};
|
|
10783
|
+
useEffect(function () {
|
|
10784
|
+
if (backTrigger !== prevBackTriggerRef.current) {
|
|
10785
|
+
prevBackTriggerRef.current = backTrigger;
|
|
10786
|
+
handleBackFromSummary();
|
|
10787
|
+
}
|
|
10788
|
+
}, [backTrigger]);
|
|
10686
10789
|
|
|
10687
10790
|
// ── Resolve which dialog component to use ───────────────────────────
|
|
10688
10791
|
// Priority: per-type custom dialog > global CustomDialog > built-in
|
|
@@ -10704,6 +10807,8 @@ var InputFieldsDialog = observer(function (_ref2) {
|
|
|
10704
10807
|
totalCount: totalCount,
|
|
10705
10808
|
onSubmit: handleSubmit,
|
|
10706
10809
|
onSkip: handleSkip,
|
|
10810
|
+
onBack: handleBack,
|
|
10811
|
+
canGoBack: canGoBack,
|
|
10707
10812
|
onComplete: function onComplete() {
|
|
10708
10813
|
store.history.addUndoState();
|
|
10709
10814
|
if (_onComplete) _onComplete();
|
|
@@ -10714,6 +10819,8 @@ var InputFieldsDialog = observer(function (_ref2) {
|
|
|
10714
10819
|
field: currentField,
|
|
10715
10820
|
onSubmit: handleSubmit,
|
|
10716
10821
|
onSkip: handleSkip,
|
|
10822
|
+
onBack: handleBack,
|
|
10823
|
+
canGoBack: canGoBack,
|
|
10717
10824
|
currentIndex: displayIndex,
|
|
10718
10825
|
totalCount: totalCount
|
|
10719
10826
|
});
|
|
@@ -11033,7 +11140,9 @@ var Workspace = observer(function (_ref6) {
|
|
|
11033
11140
|
components = _ref6$components === void 0 ? {} : _ref6$components,
|
|
11034
11141
|
_ref6$showInputFields = _ref6.showInputFieldsPopup,
|
|
11035
11142
|
showInputFieldsPopup = _ref6$showInputFields === void 0 ? true : _ref6$showInputFields,
|
|
11036
|
-
onInputFieldsComplete = _ref6.onInputFieldsComplete
|
|
11143
|
+
onInputFieldsComplete = _ref6.onInputFieldsComplete,
|
|
11144
|
+
_ref6$backTrigger = _ref6.backTrigger,
|
|
11145
|
+
backTrigger = _ref6$backTrigger === void 0 ? 0 : _ref6$backTrigger;
|
|
11037
11146
|
var stageRef = useRef(null);
|
|
11038
11147
|
var containerRef = useRef(null);
|
|
11039
11148
|
var _useState5 = useState({
|
|
@@ -11319,7 +11428,8 @@ var Workspace = observer(function (_ref6) {
|
|
|
11319
11428
|
}) : null, /*#__PURE__*/jsx(InputFieldsDialog, {
|
|
11320
11429
|
store: store,
|
|
11321
11430
|
enabled: showInputFieldsPopup,
|
|
11322
|
-
onComplete: onInputFieldsComplete
|
|
11431
|
+
onComplete: onInputFieldsComplete,
|
|
11432
|
+
backTrigger: backTrigger
|
|
11323
11433
|
})]
|
|
11324
11434
|
});
|
|
11325
11435
|
});
|