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.
- package/dist/cjs/canvas/workspace.js +65 -3
- package/dist/cjs/canvas/workspace.js.map +1 -1
- package/dist/cjs/index.js +85 -7
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/model/store.js +20 -4
- package/dist/cjs/model/store.js.map +1 -1
- package/dist/esm/canvas/workspace.js +65 -3
- package/dist/esm/canvas/workspace.js.map +1 -1
- package/dist/esm/index.js +85 -7
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/model/store.js +20 -4
- 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);
|
|
@@ -1429,15 +1430,22 @@ var _excluded$5 = ["mimeType", "quality", "dpi", "dpiMetadata"],
|
|
|
1429
1430
|
_excluded4 = ["fileName"];
|
|
1430
1431
|
|
|
1431
1432
|
// Detect embedded base64 data URLs (data:...;base64,...).
|
|
1432
|
-
// These bloat exported JSON significantly (a single image can be 1MB+).
|
|
1433
1433
|
// Regular http/https/blob URLs are preserved.
|
|
1434
1434
|
var isBase64DataUrl = function isBase64DataUrl(v) {
|
|
1435
1435
|
return typeof v === 'string' && v.startsWith('data:') && v.includes(';base64,');
|
|
1436
1436
|
};
|
|
1437
|
+
|
|
1438
|
+
// Only strip base64 from variable input-field images (inputField: true).
|
|
1439
|
+
// Static design images ARE the template content — stripping them clears the design.
|
|
1440
|
+
// Variable input-field placeholders are replaced at runtime anyway, so stripping
|
|
1441
|
+
// their (usually tiny SVG) placeholder base64 is safe and keeps exports clean.
|
|
1437
1442
|
var _stripBase64FromElement = function stripBase64FromElement(el) {
|
|
1438
1443
|
var out = _objectSpread2({}, el);
|
|
1439
|
-
|
|
1440
|
-
if (
|
|
1444
|
+
var isInputField = out.custom && out.custom.inputField;
|
|
1445
|
+
if (isInputField) {
|
|
1446
|
+
if (isBase64DataUrl(out.src)) out.src = '';
|
|
1447
|
+
if (isBase64DataUrl(out.clipSrc)) out.clipSrc = '';
|
|
1448
|
+
}
|
|
1441
1449
|
if (Array.isArray(out.children)) {
|
|
1442
1450
|
out.children = out.children.map(_stripBase64FromElement);
|
|
1443
1451
|
}
|
|
@@ -1671,6 +1679,15 @@ var Store = types.model('Store', {
|
|
|
1671
1679
|
return el.id !== id;
|
|
1672
1680
|
});
|
|
1673
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
|
+
},
|
|
1674
1691
|
clearPendingInputFields: function clearPendingInputFields() {
|
|
1675
1692
|
self._pendingInputFields = [];
|
|
1676
1693
|
}
|
|
@@ -2158,7 +2175,7 @@ var Store = types.model('Store', {
|
|
|
2158
2175
|
_ref0$fileName = _ref0.fileName,
|
|
2159
2176
|
fileName = _ref0$fileName === void 0 ? 'design.json' : _ref0$fileName,
|
|
2160
2177
|
_ref0$stripBase = _ref0.stripBase64,
|
|
2161
|
-
stripBase64 = _ref0$stripBase === void 0 ?
|
|
2178
|
+
stripBase64 = _ref0$stripBase === void 0 ? false : _ref0$stripBase;
|
|
2162
2179
|
var data = stripBase64 ? stripBase64FromExport(self.toJSON()) : self.toJSON();
|
|
2163
2180
|
var json = JSON.stringify(data, null, 2);
|
|
2164
2181
|
var blob = new Blob([json], {
|
|
@@ -10244,6 +10261,8 @@ var SingleFieldDialog = function SingleFieldDialog(_ref) {
|
|
|
10244
10261
|
var field = _ref.field,
|
|
10245
10262
|
onSubmit = _ref.onSubmit,
|
|
10246
10263
|
onSkip = _ref.onSkip,
|
|
10264
|
+
onBack = _ref.onBack,
|
|
10265
|
+
canGoBack = _ref.canGoBack,
|
|
10247
10266
|
currentIndex = _ref.currentIndex,
|
|
10248
10267
|
totalCount = _ref.totalCount;
|
|
10249
10268
|
var _useState = useState(''),
|
|
@@ -10552,7 +10571,26 @@ var SingleFieldDialog = function SingleFieldDialog(_ref) {
|
|
|
10552
10571
|
gap: 2,
|
|
10553
10572
|
mt: 4.5
|
|
10554
10573
|
},
|
|
10555
|
-
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, {
|
|
10556
10594
|
variant: "contained",
|
|
10557
10595
|
onClick: handleSubmit,
|
|
10558
10596
|
disabled: isRequired && !value,
|
|
@@ -10611,6 +10649,7 @@ var InputFieldsDialog = observer(function (_ref2) {
|
|
|
10611
10649
|
displayIndex = _useState6[0],
|
|
10612
10650
|
setDisplayIndex = _useState6[1];
|
|
10613
10651
|
var initialTotalRef = useRef(0);
|
|
10652
|
+
var completedHistoryRef = useRef([]);
|
|
10614
10653
|
var config = getInputFieldsConfig();
|
|
10615
10654
|
var pendingFields = store._pendingInputFields || [];
|
|
10616
10655
|
|
|
@@ -10629,9 +10668,11 @@ var InputFieldsDialog = observer(function (_ref2) {
|
|
|
10629
10668
|
if (fields.length > 0 && initialTotalRef.current === 0) {
|
|
10630
10669
|
initialTotalRef.current = fields.length;
|
|
10631
10670
|
setDisplayIndex(0);
|
|
10671
|
+
completedHistoryRef.current = [];
|
|
10632
10672
|
}
|
|
10633
10673
|
if (fields.length === 0) {
|
|
10634
10674
|
initialTotalRef.current = 0;
|
|
10675
|
+
completedHistoryRef.current = [];
|
|
10635
10676
|
}
|
|
10636
10677
|
}, [fields.length]);
|
|
10637
10678
|
var totalCount = initialTotalRef.current || fields.length;
|
|
@@ -10641,11 +10682,17 @@ var InputFieldsDialog = observer(function (_ref2) {
|
|
|
10641
10682
|
var currentField = fields[0];
|
|
10642
10683
|
if (!currentField) return null;
|
|
10643
10684
|
|
|
10644
|
-
// ── Shared submit / skip helpers
|
|
10685
|
+
// ── Shared submit / skip / back helpers ─────────────────────────────
|
|
10645
10686
|
var handleSubmit = function handleSubmit(elementId, value) {
|
|
10646
10687
|
var el = store.getElementById(elementId);
|
|
10688
|
+
var isImage = el && el.custom && el.custom.inputType === 'image';
|
|
10689
|
+
var previousValue = el ? isImage ? el.src : el.text : '';
|
|
10690
|
+
completedHistoryRef.current.push({
|
|
10691
|
+
el: el,
|
|
10692
|
+
previousValue: previousValue,
|
|
10693
|
+
skipped: false
|
|
10694
|
+
});
|
|
10647
10695
|
if (el && el.set) {
|
|
10648
|
-
var isImage = el.custom && el.custom.inputType === 'image';
|
|
10649
10696
|
if (isImage) {
|
|
10650
10697
|
el.set({
|
|
10651
10698
|
src: String(value)
|
|
@@ -10667,6 +10714,14 @@ var InputFieldsDialog = observer(function (_ref2) {
|
|
|
10667
10714
|
}
|
|
10668
10715
|
};
|
|
10669
10716
|
var handleSkip = function handleSkip(elementId) {
|
|
10717
|
+
var el = store.getElementById(elementId);
|
|
10718
|
+
var isImage = el && el.custom && el.custom.inputType === 'image';
|
|
10719
|
+
var previousValue = el ? isImage ? el.src : el.text : '';
|
|
10720
|
+
completedHistoryRef.current.push({
|
|
10721
|
+
el: el,
|
|
10722
|
+
previousValue: previousValue,
|
|
10723
|
+
skipped: true
|
|
10724
|
+
});
|
|
10670
10725
|
store._resolveInputField(elementId);
|
|
10671
10726
|
if (fields.length <= 1) {
|
|
10672
10727
|
if (_onComplete) _onComplete();
|
|
@@ -10676,6 +10731,25 @@ var InputFieldsDialog = observer(function (_ref2) {
|
|
|
10676
10731
|
});
|
|
10677
10732
|
}
|
|
10678
10733
|
};
|
|
10734
|
+
var handleBack = function handleBack() {
|
|
10735
|
+
var last = completedHistoryRef.current.pop();
|
|
10736
|
+
if (!last) return;
|
|
10737
|
+
var el = last.el,
|
|
10738
|
+
previousValue = last.previousValue;
|
|
10739
|
+
if (el) {
|
|
10740
|
+
var isImage = el.custom && el.custom.inputType === 'image';
|
|
10741
|
+
el.set(isImage ? {
|
|
10742
|
+
src: previousValue || ''
|
|
10743
|
+
} : {
|
|
10744
|
+
text: previousValue || ''
|
|
10745
|
+
});
|
|
10746
|
+
store._unresolveInputField(el);
|
|
10747
|
+
}
|
|
10748
|
+
setDisplayIndex(function (prev) {
|
|
10749
|
+
return Math.max(0, prev - 1);
|
|
10750
|
+
});
|
|
10751
|
+
};
|
|
10752
|
+
var canGoBack = displayIndex > 0;
|
|
10679
10753
|
|
|
10680
10754
|
// ── Resolve which dialog component to use ───────────────────────────
|
|
10681
10755
|
// Priority: per-type custom dialog > global CustomDialog > built-in
|
|
@@ -10697,6 +10771,8 @@ var InputFieldsDialog = observer(function (_ref2) {
|
|
|
10697
10771
|
totalCount: totalCount,
|
|
10698
10772
|
onSubmit: handleSubmit,
|
|
10699
10773
|
onSkip: handleSkip,
|
|
10774
|
+
onBack: handleBack,
|
|
10775
|
+
canGoBack: canGoBack,
|
|
10700
10776
|
onComplete: function onComplete() {
|
|
10701
10777
|
store.history.addUndoState();
|
|
10702
10778
|
if (_onComplete) _onComplete();
|
|
@@ -10707,6 +10783,8 @@ var InputFieldsDialog = observer(function (_ref2) {
|
|
|
10707
10783
|
field: currentField,
|
|
10708
10784
|
onSubmit: handleSubmit,
|
|
10709
10785
|
onSkip: handleSkip,
|
|
10786
|
+
onBack: handleBack,
|
|
10787
|
+
canGoBack: canGoBack,
|
|
10710
10788
|
currentIndex: displayIndex,
|
|
10711
10789
|
totalCount: totalCount
|
|
10712
10790
|
});
|