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
|
@@ -10,6 +10,7 @@ var CloseIcon = require('@mui/icons-material/Close');
|
|
|
10
10
|
var jsxRuntime = require('react/jsx-runtime');
|
|
11
11
|
var Konva = require('konva');
|
|
12
12
|
var CloudUploadIcon = require('@mui/icons-material/CloudUpload');
|
|
13
|
+
var ArrowBackIcon = require('@mui/icons-material/ArrowBack');
|
|
13
14
|
|
|
14
15
|
function _arrayLikeToArray(r, a) {
|
|
15
16
|
(null == a || a > r.length) && (a = r.length);
|
|
@@ -1674,6 +1675,8 @@ var SingleFieldDialog = function SingleFieldDialog(_ref) {
|
|
|
1674
1675
|
var field = _ref.field,
|
|
1675
1676
|
onSubmit = _ref.onSubmit,
|
|
1676
1677
|
onSkip = _ref.onSkip,
|
|
1678
|
+
onBack = _ref.onBack,
|
|
1679
|
+
canGoBack = _ref.canGoBack,
|
|
1677
1680
|
currentIndex = _ref.currentIndex,
|
|
1678
1681
|
totalCount = _ref.totalCount;
|
|
1679
1682
|
var _useState = react.useState(''),
|
|
@@ -1982,7 +1985,26 @@ var SingleFieldDialog = function SingleFieldDialog(_ref) {
|
|
|
1982
1985
|
gap: 2,
|
|
1983
1986
|
mt: 4.5
|
|
1984
1987
|
},
|
|
1985
|
-
children: [/*#__PURE__*/jsxRuntime.jsx(material.Button, {
|
|
1988
|
+
children: [canGoBack && /*#__PURE__*/jsxRuntime.jsx(material.Button, {
|
|
1989
|
+
variant: "outlined",
|
|
1990
|
+
onClick: onBack,
|
|
1991
|
+
startIcon: /*#__PURE__*/jsxRuntime.jsx(ArrowBackIcon, {}),
|
|
1992
|
+
sx: {
|
|
1993
|
+
textTransform: 'none',
|
|
1994
|
+
fontWeight: 500,
|
|
1995
|
+
fontSize: 21,
|
|
1996
|
+
px: 3,
|
|
1997
|
+
py: 1.65,
|
|
1998
|
+
borderRadius: '10px',
|
|
1999
|
+
color: '#555',
|
|
2000
|
+
borderColor: '#d0d5dd',
|
|
2001
|
+
'&:hover': {
|
|
2002
|
+
borderColor: '#aaa',
|
|
2003
|
+
backgroundColor: 'rgba(0,0,0,0.02)'
|
|
2004
|
+
}
|
|
2005
|
+
},
|
|
2006
|
+
children: t('inputFieldsDialog.back', 'Back')
|
|
2007
|
+
}), /*#__PURE__*/jsxRuntime.jsx(material.Button, {
|
|
1986
2008
|
variant: "contained",
|
|
1987
2009
|
onClick: handleSubmit,
|
|
1988
2010
|
disabled: isRequired && !value,
|
|
@@ -2033,7 +2055,9 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
|
|
|
2033
2055
|
var store = _ref2.store,
|
|
2034
2056
|
_onComplete = _ref2.onComplete,
|
|
2035
2057
|
_ref2$enabled = _ref2.enabled,
|
|
2036
|
-
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;
|
|
2037
2061
|
// displayIndex counts how many fields have been answered (for step indicator only).
|
|
2038
2062
|
// Navigation always uses fields[0] — the first remaining pending field.
|
|
2039
2063
|
var _useState5 = react.useState(0),
|
|
@@ -2041,6 +2065,9 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
|
|
|
2041
2065
|
displayIndex = _useState6[0],
|
|
2042
2066
|
setDisplayIndex = _useState6[1];
|
|
2043
2067
|
var initialTotalRef = react.useRef(0);
|
|
2068
|
+
var completedHistoryRef = react.useRef([]);
|
|
2069
|
+
var isGoingBackRef = react.useRef(false);
|
|
2070
|
+
var prevBackTriggerRef = react.useRef(backTrigger);
|
|
2044
2071
|
var config = getInputFieldsConfig();
|
|
2045
2072
|
var pendingFields = store._pendingInputFields || [];
|
|
2046
2073
|
|
|
@@ -2057,11 +2084,20 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
|
|
|
2057
2084
|
// Capture total and reset display counter when a fresh batch appears
|
|
2058
2085
|
react.useEffect(function () {
|
|
2059
2086
|
if (fields.length > 0 && initialTotalRef.current === 0) {
|
|
2060
|
-
|
|
2061
|
-
|
|
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
|
+
}
|
|
2062
2097
|
}
|
|
2063
2098
|
if (fields.length === 0) {
|
|
2064
2099
|
initialTotalRef.current = 0;
|
|
2100
|
+
// History is intentionally kept so back-from-summary can use it
|
|
2065
2101
|
}
|
|
2066
2102
|
}, [fields.length]);
|
|
2067
2103
|
var totalCount = initialTotalRef.current || fields.length;
|
|
@@ -2071,11 +2107,17 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
|
|
|
2071
2107
|
var currentField = fields[0];
|
|
2072
2108
|
if (!currentField) return null;
|
|
2073
2109
|
|
|
2074
|
-
// ── Shared submit / skip helpers
|
|
2110
|
+
// ── Shared submit / skip / back helpers ─────────────────────────────
|
|
2075
2111
|
var handleSubmit = function handleSubmit(elementId, value) {
|
|
2076
2112
|
var el = store.getElementById(elementId);
|
|
2113
|
+
var isImage = el && el.custom && el.custom.inputType === 'image';
|
|
2114
|
+
var previousValue = el ? isImage ? el.src : el.text : '';
|
|
2115
|
+
completedHistoryRef.current.push({
|
|
2116
|
+
el: el,
|
|
2117
|
+
previousValue: previousValue,
|
|
2118
|
+
skipped: false
|
|
2119
|
+
});
|
|
2077
2120
|
if (el && el.set) {
|
|
2078
|
-
var isImage = el.custom && el.custom.inputType === 'image';
|
|
2079
2121
|
if (isImage) {
|
|
2080
2122
|
el.set({
|
|
2081
2123
|
src: String(value)
|
|
@@ -2097,6 +2139,14 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
|
|
|
2097
2139
|
}
|
|
2098
2140
|
};
|
|
2099
2141
|
var handleSkip = function handleSkip(elementId) {
|
|
2142
|
+
var el = store.getElementById(elementId);
|
|
2143
|
+
var isImage = el && el.custom && el.custom.inputType === 'image';
|
|
2144
|
+
var previousValue = el ? isImage ? el.src : el.text : '';
|
|
2145
|
+
completedHistoryRef.current.push({
|
|
2146
|
+
el: el,
|
|
2147
|
+
previousValue: previousValue,
|
|
2148
|
+
skipped: true
|
|
2149
|
+
});
|
|
2100
2150
|
store._resolveInputField(elementId);
|
|
2101
2151
|
if (fields.length <= 1) {
|
|
2102
2152
|
if (_onComplete) _onComplete();
|
|
@@ -2106,6 +2156,50 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
|
|
|
2106
2156
|
});
|
|
2107
2157
|
}
|
|
2108
2158
|
};
|
|
2159
|
+
var handleBack = function handleBack() {
|
|
2160
|
+
var last = completedHistoryRef.current.pop();
|
|
2161
|
+
if (!last) return;
|
|
2162
|
+
var el = last.el,
|
|
2163
|
+
previousValue = last.previousValue;
|
|
2164
|
+
if (el) {
|
|
2165
|
+
var isImage = el.custom && el.custom.inputType === 'image';
|
|
2166
|
+
el.set(isImage ? {
|
|
2167
|
+
src: previousValue || ''
|
|
2168
|
+
} : {
|
|
2169
|
+
text: previousValue || ''
|
|
2170
|
+
});
|
|
2171
|
+
store._unresolveInputField(el);
|
|
2172
|
+
}
|
|
2173
|
+
setDisplayIndex(function (prev) {
|
|
2174
|
+
return Math.max(0, prev - 1);
|
|
2175
|
+
});
|
|
2176
|
+
};
|
|
2177
|
+
var canGoBack = displayIndex > 0;
|
|
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]);
|
|
2109
2203
|
|
|
2110
2204
|
// ── Resolve which dialog component to use ───────────────────────────
|
|
2111
2205
|
// Priority: per-type custom dialog > global CustomDialog > built-in
|
|
@@ -2127,6 +2221,8 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
|
|
|
2127
2221
|
totalCount: totalCount,
|
|
2128
2222
|
onSubmit: handleSubmit,
|
|
2129
2223
|
onSkip: handleSkip,
|
|
2224
|
+
onBack: handleBack,
|
|
2225
|
+
canGoBack: canGoBack,
|
|
2130
2226
|
onComplete: function onComplete() {
|
|
2131
2227
|
store.history.addUndoState();
|
|
2132
2228
|
if (_onComplete) _onComplete();
|
|
@@ -2137,6 +2233,8 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
|
|
|
2137
2233
|
field: currentField,
|
|
2138
2234
|
onSubmit: handleSubmit,
|
|
2139
2235
|
onSkip: handleSkip,
|
|
2236
|
+
onBack: handleBack,
|
|
2237
|
+
canGoBack: canGoBack,
|
|
2140
2238
|
currentIndex: displayIndex,
|
|
2141
2239
|
totalCount: totalCount
|
|
2142
2240
|
});
|
|
@@ -2456,7 +2554,9 @@ var Workspace = mobxReactLite.observer(function (_ref6) {
|
|
|
2456
2554
|
components = _ref6$components === void 0 ? {} : _ref6$components,
|
|
2457
2555
|
_ref6$showInputFields = _ref6.showInputFieldsPopup,
|
|
2458
2556
|
showInputFieldsPopup = _ref6$showInputFields === void 0 ? true : _ref6$showInputFields,
|
|
2459
|
-
onInputFieldsComplete = _ref6.onInputFieldsComplete
|
|
2557
|
+
onInputFieldsComplete = _ref6.onInputFieldsComplete,
|
|
2558
|
+
_ref6$backTrigger = _ref6.backTrigger,
|
|
2559
|
+
backTrigger = _ref6$backTrigger === void 0 ? 0 : _ref6$backTrigger;
|
|
2460
2560
|
var stageRef = react.useRef(null);
|
|
2461
2561
|
var containerRef = react.useRef(null);
|
|
2462
2562
|
var _useState5 = react.useState({
|
|
@@ -2742,7 +2842,8 @@ var Workspace = mobxReactLite.observer(function (_ref6) {
|
|
|
2742
2842
|
}) : null, /*#__PURE__*/jsxRuntime.jsx(InputFieldsDialog, {
|
|
2743
2843
|
store: store,
|
|
2744
2844
|
enabled: showInputFieldsPopup,
|
|
2745
|
-
onComplete: onInputFieldsComplete
|
|
2845
|
+
onComplete: onInputFieldsComplete,
|
|
2846
|
+
backTrigger: backTrigger
|
|
2746
2847
|
})]
|
|
2747
2848
|
});
|
|
2748
2849
|
});
|