labellife-design-tool 2.2.0 → 2.2.2

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.
@@ -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,
@@ -2041,6 +2063,7 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
2041
2063
  displayIndex = _useState6[0],
2042
2064
  setDisplayIndex = _useState6[1];
2043
2065
  var initialTotalRef = react.useRef(0);
2066
+ var completedHistoryRef = react.useRef([]);
2044
2067
  var config = getInputFieldsConfig();
2045
2068
  var pendingFields = store._pendingInputFields || [];
2046
2069
 
@@ -2059,9 +2082,11 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
2059
2082
  if (fields.length > 0 && initialTotalRef.current === 0) {
2060
2083
  initialTotalRef.current = fields.length;
2061
2084
  setDisplayIndex(0);
2085
+ completedHistoryRef.current = [];
2062
2086
  }
2063
2087
  if (fields.length === 0) {
2064
2088
  initialTotalRef.current = 0;
2089
+ completedHistoryRef.current = [];
2065
2090
  }
2066
2091
  }, [fields.length]);
2067
2092
  var totalCount = initialTotalRef.current || fields.length;
@@ -2071,11 +2096,17 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
2071
2096
  var currentField = fields[0];
2072
2097
  if (!currentField) return null;
2073
2098
 
2074
- // ── Shared submit / skip helpers ────────────────────────────────────
2099
+ // ── Shared submit / skip / back helpers ─────────────────────────────
2075
2100
  var handleSubmit = function handleSubmit(elementId, value) {
2076
2101
  var el = store.getElementById(elementId);
2102
+ var isImage = el && el.custom && el.custom.inputType === 'image';
2103
+ var previousValue = el ? isImage ? el.src : el.text : '';
2104
+ completedHistoryRef.current.push({
2105
+ el: el,
2106
+ previousValue: previousValue,
2107
+ skipped: false
2108
+ });
2077
2109
  if (el && el.set) {
2078
- var isImage = el.custom && el.custom.inputType === 'image';
2079
2110
  if (isImage) {
2080
2111
  el.set({
2081
2112
  src: String(value)
@@ -2097,6 +2128,14 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
2097
2128
  }
2098
2129
  };
2099
2130
  var handleSkip = function handleSkip(elementId) {
2131
+ var el = store.getElementById(elementId);
2132
+ var isImage = el && el.custom && el.custom.inputType === 'image';
2133
+ var previousValue = el ? isImage ? el.src : el.text : '';
2134
+ completedHistoryRef.current.push({
2135
+ el: el,
2136
+ previousValue: previousValue,
2137
+ skipped: true
2138
+ });
2100
2139
  store._resolveInputField(elementId);
2101
2140
  if (fields.length <= 1) {
2102
2141
  if (_onComplete) _onComplete();
@@ -2106,6 +2145,25 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
2106
2145
  });
2107
2146
  }
2108
2147
  };
2148
+ var handleBack = function handleBack() {
2149
+ var last = completedHistoryRef.current.pop();
2150
+ if (!last) return;
2151
+ var el = last.el,
2152
+ previousValue = last.previousValue;
2153
+ if (el) {
2154
+ var isImage = el.custom && el.custom.inputType === 'image';
2155
+ el.set(isImage ? {
2156
+ src: previousValue || ''
2157
+ } : {
2158
+ text: previousValue || ''
2159
+ });
2160
+ store._unresolveInputField(el);
2161
+ }
2162
+ setDisplayIndex(function (prev) {
2163
+ return Math.max(0, prev - 1);
2164
+ });
2165
+ };
2166
+ var canGoBack = displayIndex > 0;
2109
2167
 
2110
2168
  // ── Resolve which dialog component to use ───────────────────────────
2111
2169
  // Priority: per-type custom dialog > global CustomDialog > built-in
@@ -2127,6 +2185,8 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
2127
2185
  totalCount: totalCount,
2128
2186
  onSubmit: handleSubmit,
2129
2187
  onSkip: handleSkip,
2188
+ onBack: handleBack,
2189
+ canGoBack: canGoBack,
2130
2190
  onComplete: function onComplete() {
2131
2191
  store.history.addUndoState();
2132
2192
  if (_onComplete) _onComplete();
@@ -2137,6 +2197,8 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
2137
2197
  field: currentField,
2138
2198
  onSubmit: handleSubmit,
2139
2199
  onSkip: handleSkip,
2200
+ onBack: handleBack,
2201
+ canGoBack: canGoBack,
2140
2202
  currentIndex: displayIndex,
2141
2203
  totalCount: totalCount
2142
2204
  });