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
|
@@ -6,6 +6,7 @@ import CloseIcon from '@mui/icons-material/Close';
|
|
|
6
6
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
7
7
|
import Konva from 'konva';
|
|
8
8
|
import CloudUploadIcon from '@mui/icons-material/CloudUpload';
|
|
9
|
+
import ArrowBackIcon from '@mui/icons-material/ArrowBack';
|
|
9
10
|
|
|
10
11
|
function _arrayLikeToArray(r, a) {
|
|
11
12
|
(null == a || a > r.length) && (a = r.length);
|
|
@@ -1670,6 +1671,8 @@ var SingleFieldDialog = function SingleFieldDialog(_ref) {
|
|
|
1670
1671
|
var field = _ref.field,
|
|
1671
1672
|
onSubmit = _ref.onSubmit,
|
|
1672
1673
|
onSkip = _ref.onSkip,
|
|
1674
|
+
onBack = _ref.onBack,
|
|
1675
|
+
canGoBack = _ref.canGoBack,
|
|
1673
1676
|
currentIndex = _ref.currentIndex,
|
|
1674
1677
|
totalCount = _ref.totalCount;
|
|
1675
1678
|
var _useState = useState(''),
|
|
@@ -1978,7 +1981,26 @@ var SingleFieldDialog = function SingleFieldDialog(_ref) {
|
|
|
1978
1981
|
gap: 2,
|
|
1979
1982
|
mt: 4.5
|
|
1980
1983
|
},
|
|
1981
|
-
children: [/*#__PURE__*/jsx(Button, {
|
|
1984
|
+
children: [canGoBack && /*#__PURE__*/jsx(Button, {
|
|
1985
|
+
variant: "outlined",
|
|
1986
|
+
onClick: onBack,
|
|
1987
|
+
startIcon: /*#__PURE__*/jsx(ArrowBackIcon, {}),
|
|
1988
|
+
sx: {
|
|
1989
|
+
textTransform: 'none',
|
|
1990
|
+
fontWeight: 500,
|
|
1991
|
+
fontSize: 21,
|
|
1992
|
+
px: 3,
|
|
1993
|
+
py: 1.65,
|
|
1994
|
+
borderRadius: '10px',
|
|
1995
|
+
color: '#555',
|
|
1996
|
+
borderColor: '#d0d5dd',
|
|
1997
|
+
'&:hover': {
|
|
1998
|
+
borderColor: '#aaa',
|
|
1999
|
+
backgroundColor: 'rgba(0,0,0,0.02)'
|
|
2000
|
+
}
|
|
2001
|
+
},
|
|
2002
|
+
children: t('inputFieldsDialog.back', 'Back')
|
|
2003
|
+
}), /*#__PURE__*/jsx(Button, {
|
|
1982
2004
|
variant: "contained",
|
|
1983
2005
|
onClick: handleSubmit,
|
|
1984
2006
|
disabled: isRequired && !value,
|
|
@@ -2029,7 +2051,9 @@ var InputFieldsDialog = observer(function (_ref2) {
|
|
|
2029
2051
|
var store = _ref2.store,
|
|
2030
2052
|
_onComplete = _ref2.onComplete,
|
|
2031
2053
|
_ref2$enabled = _ref2.enabled,
|
|
2032
|
-
enabled = _ref2$enabled === void 0 ? true : _ref2$enabled
|
|
2054
|
+
enabled = _ref2$enabled === void 0 ? true : _ref2$enabled,
|
|
2055
|
+
_ref2$backTrigger = _ref2.backTrigger,
|
|
2056
|
+
backTrigger = _ref2$backTrigger === void 0 ? 0 : _ref2$backTrigger;
|
|
2033
2057
|
// displayIndex counts how many fields have been answered (for step indicator only).
|
|
2034
2058
|
// Navigation always uses fields[0] — the first remaining pending field.
|
|
2035
2059
|
var _useState5 = useState(0),
|
|
@@ -2037,6 +2061,9 @@ var InputFieldsDialog = observer(function (_ref2) {
|
|
|
2037
2061
|
displayIndex = _useState6[0],
|
|
2038
2062
|
setDisplayIndex = _useState6[1];
|
|
2039
2063
|
var initialTotalRef = useRef(0);
|
|
2064
|
+
var completedHistoryRef = useRef([]);
|
|
2065
|
+
var isGoingBackRef = useRef(false);
|
|
2066
|
+
var prevBackTriggerRef = useRef(backTrigger);
|
|
2040
2067
|
var config = getInputFieldsConfig();
|
|
2041
2068
|
var pendingFields = store._pendingInputFields || [];
|
|
2042
2069
|
|
|
@@ -2053,11 +2080,20 @@ var InputFieldsDialog = observer(function (_ref2) {
|
|
|
2053
2080
|
// Capture total and reset display counter when a fresh batch appears
|
|
2054
2081
|
useEffect(function () {
|
|
2055
2082
|
if (fields.length > 0 && initialTotalRef.current === 0) {
|
|
2056
|
-
|
|
2057
|
-
|
|
2083
|
+
if (isGoingBackRef.current) {
|
|
2084
|
+
// Back-from-summary restored a field — recover total from history + pending
|
|
2085
|
+
isGoingBackRef.current = false;
|
|
2086
|
+
initialTotalRef.current = completedHistoryRef.current.length + fields.length;
|
|
2087
|
+
} else {
|
|
2088
|
+
// Genuine fresh batch
|
|
2089
|
+
initialTotalRef.current = fields.length;
|
|
2090
|
+
setDisplayIndex(0);
|
|
2091
|
+
completedHistoryRef.current = [];
|
|
2092
|
+
}
|
|
2058
2093
|
}
|
|
2059
2094
|
if (fields.length === 0) {
|
|
2060
2095
|
initialTotalRef.current = 0;
|
|
2096
|
+
// History is intentionally kept so back-from-summary can use it
|
|
2061
2097
|
}
|
|
2062
2098
|
}, [fields.length]);
|
|
2063
2099
|
var totalCount = initialTotalRef.current || fields.length;
|
|
@@ -2067,11 +2103,17 @@ var InputFieldsDialog = observer(function (_ref2) {
|
|
|
2067
2103
|
var currentField = fields[0];
|
|
2068
2104
|
if (!currentField) return null;
|
|
2069
2105
|
|
|
2070
|
-
// ── Shared submit / skip helpers
|
|
2106
|
+
// ── Shared submit / skip / back helpers ─────────────────────────────
|
|
2071
2107
|
var handleSubmit = function handleSubmit(elementId, value) {
|
|
2072
2108
|
var el = store.getElementById(elementId);
|
|
2109
|
+
var isImage = el && el.custom && el.custom.inputType === 'image';
|
|
2110
|
+
var previousValue = el ? isImage ? el.src : el.text : '';
|
|
2111
|
+
completedHistoryRef.current.push({
|
|
2112
|
+
el: el,
|
|
2113
|
+
previousValue: previousValue,
|
|
2114
|
+
skipped: false
|
|
2115
|
+
});
|
|
2073
2116
|
if (el && el.set) {
|
|
2074
|
-
var isImage = el.custom && el.custom.inputType === 'image';
|
|
2075
2117
|
if (isImage) {
|
|
2076
2118
|
el.set({
|
|
2077
2119
|
src: String(value)
|
|
@@ -2093,6 +2135,14 @@ var InputFieldsDialog = observer(function (_ref2) {
|
|
|
2093
2135
|
}
|
|
2094
2136
|
};
|
|
2095
2137
|
var handleSkip = function handleSkip(elementId) {
|
|
2138
|
+
var el = store.getElementById(elementId);
|
|
2139
|
+
var isImage = el && el.custom && el.custom.inputType === 'image';
|
|
2140
|
+
var previousValue = el ? isImage ? el.src : el.text : '';
|
|
2141
|
+
completedHistoryRef.current.push({
|
|
2142
|
+
el: el,
|
|
2143
|
+
previousValue: previousValue,
|
|
2144
|
+
skipped: true
|
|
2145
|
+
});
|
|
2096
2146
|
store._resolveInputField(elementId);
|
|
2097
2147
|
if (fields.length <= 1) {
|
|
2098
2148
|
if (_onComplete) _onComplete();
|
|
@@ -2102,6 +2152,50 @@ var InputFieldsDialog = observer(function (_ref2) {
|
|
|
2102
2152
|
});
|
|
2103
2153
|
}
|
|
2104
2154
|
};
|
|
2155
|
+
var handleBack = function handleBack() {
|
|
2156
|
+
var last = completedHistoryRef.current.pop();
|
|
2157
|
+
if (!last) return;
|
|
2158
|
+
var el = last.el,
|
|
2159
|
+
previousValue = last.previousValue;
|
|
2160
|
+
if (el) {
|
|
2161
|
+
var isImage = el.custom && el.custom.inputType === 'image';
|
|
2162
|
+
el.set(isImage ? {
|
|
2163
|
+
src: previousValue || ''
|
|
2164
|
+
} : {
|
|
2165
|
+
text: previousValue || ''
|
|
2166
|
+
});
|
|
2167
|
+
store._unresolveInputField(el);
|
|
2168
|
+
}
|
|
2169
|
+
setDisplayIndex(function (prev) {
|
|
2170
|
+
return Math.max(0, prev - 1);
|
|
2171
|
+
});
|
|
2172
|
+
};
|
|
2173
|
+
var canGoBack = displayIndex > 0;
|
|
2174
|
+
|
|
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]);
|
|
2105
2199
|
|
|
2106
2200
|
// ── Resolve which dialog component to use ───────────────────────────
|
|
2107
2201
|
// Priority: per-type custom dialog > global CustomDialog > built-in
|
|
@@ -2123,6 +2217,8 @@ var InputFieldsDialog = observer(function (_ref2) {
|
|
|
2123
2217
|
totalCount: totalCount,
|
|
2124
2218
|
onSubmit: handleSubmit,
|
|
2125
2219
|
onSkip: handleSkip,
|
|
2220
|
+
onBack: handleBack,
|
|
2221
|
+
canGoBack: canGoBack,
|
|
2126
2222
|
onComplete: function onComplete() {
|
|
2127
2223
|
store.history.addUndoState();
|
|
2128
2224
|
if (_onComplete) _onComplete();
|
|
@@ -2133,6 +2229,8 @@ var InputFieldsDialog = observer(function (_ref2) {
|
|
|
2133
2229
|
field: currentField,
|
|
2134
2230
|
onSubmit: handleSubmit,
|
|
2135
2231
|
onSkip: handleSkip,
|
|
2232
|
+
onBack: handleBack,
|
|
2233
|
+
canGoBack: canGoBack,
|
|
2136
2234
|
currentIndex: displayIndex,
|
|
2137
2235
|
totalCount: totalCount
|
|
2138
2236
|
});
|
|
@@ -2452,7 +2550,9 @@ var Workspace = observer(function (_ref6) {
|
|
|
2452
2550
|
components = _ref6$components === void 0 ? {} : _ref6$components,
|
|
2453
2551
|
_ref6$showInputFields = _ref6.showInputFieldsPopup,
|
|
2454
2552
|
showInputFieldsPopup = _ref6$showInputFields === void 0 ? true : _ref6$showInputFields,
|
|
2455
|
-
onInputFieldsComplete = _ref6.onInputFieldsComplete
|
|
2553
|
+
onInputFieldsComplete = _ref6.onInputFieldsComplete,
|
|
2554
|
+
_ref6$backTrigger = _ref6.backTrigger,
|
|
2555
|
+
backTrigger = _ref6$backTrigger === void 0 ? 0 : _ref6$backTrigger;
|
|
2456
2556
|
var stageRef = useRef(null);
|
|
2457
2557
|
var containerRef = useRef(null);
|
|
2458
2558
|
var _useState5 = useState({
|
|
@@ -2738,7 +2838,8 @@ var Workspace = observer(function (_ref6) {
|
|
|
2738
2838
|
}) : null, /*#__PURE__*/jsx(InputFieldsDialog, {
|
|
2739
2839
|
store: store,
|
|
2740
2840
|
enabled: showInputFieldsPopup,
|
|
2741
|
-
onComplete: onInputFieldsComplete
|
|
2841
|
+
onComplete: onInputFieldsComplete,
|
|
2842
|
+
backTrigger: backTrigger
|
|
2742
2843
|
})]
|
|
2743
2844
|
});
|
|
2744
2845
|
});
|