labellife-design-tool 2.2.8 → 2.3.0

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.
@@ -27,6 +27,15 @@ var ArrowDownwardIcon = require('@mui/icons-material/ArrowDownward');
27
27
  var AutoAwesomeIcon = require('@mui/icons-material/AutoAwesome');
28
28
  var SwapHorizIcon = require('@mui/icons-material/SwapHoriz');
29
29
  var SwapVertIcon = require('@mui/icons-material/SwapVert');
30
+ var OpenWithIcon = require('@mui/icons-material/OpenWith');
31
+ require('@mui/icons-material/AlignHorizontalLeft');
32
+ require('@mui/icons-material/AlignHorizontalCenter');
33
+ require('@mui/icons-material/AlignHorizontalRight');
34
+ require('@mui/icons-material/AlignVerticalTop');
35
+ require('@mui/icons-material/AlignVerticalCenter');
36
+ require('@mui/icons-material/AlignVerticalBottom');
37
+ var VerticalAlignTopIcon = require('@mui/icons-material/VerticalAlignTop');
38
+ var VerticalAlignBottomIcon = require('@mui/icons-material/VerticalAlignBottom');
30
39
  var jsxRuntime = require('react/jsx-runtime');
31
40
 
32
41
  function _arrayLikeToArray(r, a) {
@@ -388,6 +397,21 @@ if (typeof window !== 'undefined' && !window[INPUT_FIELDS_CONFIG_KEY]) {
388
397
  }
389
398
 
390
399
  var _excluded = ["fontFamily"];
400
+ var _positionMenuItemSx = {
401
+ textTransform: 'none',
402
+ fontSize: 12,
403
+ fontWeight: 400,
404
+ color: '#333',
405
+ justifyContent: 'flex-start',
406
+ px: 1,
407
+ py: 0.6,
408
+ minWidth: 0,
409
+ '&:hover': {
410
+ backgroundColor: 'rgba(13,131,205,0.08)'
411
+ }
412
+ };
413
+
414
+ // ── Font preview: lightweight Google Font subsets for dropdown ──
391
415
  var _fontPreviewLoaded = new Set();
392
416
  function loadFontPreview(fontFamily) {
393
417
  if (_fontPreviewLoaded.has(fontFamily)) return;
@@ -1068,10 +1092,270 @@ var LineToolbar = mobxReactLite.observer(function (_ref7) {
1068
1092
  });
1069
1093
  });
1070
1094
 
1071
- // Common controls for all element types
1072
- var CommonControls = mobxReactLite.observer(function (_ref8) {
1095
+ // Position + alignment popover button
1096
+ var PositionButton = mobxReactLite.observer(function (_ref8) {
1073
1097
  var element = _ref8.element,
1074
1098
  store = _ref8.store;
1099
+ var _useState3 = React.useState(null),
1100
+ _useState4 = _slicedToArray(_useState3, 2),
1101
+ anchorEl = _useState4[0],
1102
+ setAnchorEl = _useState4[1];
1103
+ var open = Boolean(anchorEl);
1104
+ var pageW = store.width;
1105
+ var pageH = store.height;
1106
+ var alignEl = function alignEl(xVal, yVal) {
1107
+ var attrs = {};
1108
+ if (xVal !== null) attrs.x = xVal;
1109
+ if (yVal !== null) attrs.y = yVal;
1110
+ element.set(attrs);
1111
+ store.history.addUndoState();
1112
+ };
1113
+ var layer = function layer(fn) {
1114
+ fn();
1115
+ store.history.addUndoState();
1116
+ };
1117
+ return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
1118
+ children: [/*#__PURE__*/jsxRuntime.jsx(material.Button, {
1119
+ size: "small",
1120
+ onClick: function onClick(e) {
1121
+ return setAnchorEl(e.currentTarget);
1122
+ },
1123
+ startIcon: /*#__PURE__*/jsxRuntime.jsx(OpenWithIcon, {
1124
+ sx: {
1125
+ fontSize: '16px !important'
1126
+ }
1127
+ }),
1128
+ sx: _objectSpread2({
1129
+ textTransform: 'none',
1130
+ fontSize: 12,
1131
+ whiteSpace: 'nowrap',
1132
+ px: 1.5,
1133
+ minWidth: 'auto'
1134
+ }, open ? {
1135
+ backgroundColor: '#e3f2fd',
1136
+ color: '#0d83cd'
1137
+ } : {}),
1138
+ children: t('toolbar.position', 'Position')
1139
+ }), /*#__PURE__*/jsxRuntime.jsxs(material.Popover, {
1140
+ open: open,
1141
+ anchorEl: anchorEl,
1142
+ onClose: function onClose() {
1143
+ return setAnchorEl(null);
1144
+ },
1145
+ anchorOrigin: {
1146
+ vertical: 'bottom',
1147
+ horizontal: 'left'
1148
+ },
1149
+ transformOrigin: {
1150
+ vertical: 'top',
1151
+ horizontal: 'left'
1152
+ },
1153
+ slotProps: {
1154
+ paper: {
1155
+ sx: {
1156
+ mt: 0.5,
1157
+ p: 2,
1158
+ width: 300,
1159
+ borderRadius: '10px',
1160
+ boxShadow: '0 4px 20px rgba(0,0,0,0.12)'
1161
+ }
1162
+ }
1163
+ },
1164
+ children: [/*#__PURE__*/jsxRuntime.jsx(material.Typography, {
1165
+ variant: "caption",
1166
+ sx: {
1167
+ fontWeight: 700,
1168
+ color: '#111',
1169
+ display: 'block',
1170
+ mb: 1,
1171
+ fontSize: 12
1172
+ },
1173
+ children: t('toolbar.layering', 'Layer order')
1174
+ }), /*#__PURE__*/jsxRuntime.jsxs(material.Box, {
1175
+ sx: {
1176
+ display: 'grid',
1177
+ gridTemplateColumns: '1fr 1fr',
1178
+ gap: 0.5,
1179
+ mb: 2
1180
+ },
1181
+ children: [/*#__PURE__*/jsxRuntime.jsx(material.Button, {
1182
+ size: "small",
1183
+ startIcon: /*#__PURE__*/jsxRuntime.jsx(ArrowUpwardIcon, {}),
1184
+ onClick: function onClick() {
1185
+ return layer(function () {
1186
+ return element.moveUp();
1187
+ });
1188
+ },
1189
+ sx: _positionMenuItemSx,
1190
+ children: t('toolbar.up', 'Up')
1191
+ }), /*#__PURE__*/jsxRuntime.jsx(material.Button, {
1192
+ size: "small",
1193
+ startIcon: /*#__PURE__*/jsxRuntime.jsx(ArrowDownwardIcon, {}),
1194
+ onClick: function onClick() {
1195
+ return layer(function () {
1196
+ return element.moveDown();
1197
+ });
1198
+ },
1199
+ sx: _positionMenuItemSx,
1200
+ children: t('toolbar.down', 'Down')
1201
+ }), /*#__PURE__*/jsxRuntime.jsx(material.Button, {
1202
+ size: "small",
1203
+ startIcon: /*#__PURE__*/jsxRuntime.jsx(VerticalAlignTopIcon, {}),
1204
+ onClick: function onClick() {
1205
+ return layer(function () {
1206
+ return element.moveTop();
1207
+ });
1208
+ },
1209
+ sx: _positionMenuItemSx,
1210
+ children: t('toolbar.toForward', 'To front')
1211
+ }), /*#__PURE__*/jsxRuntime.jsx(material.Button, {
1212
+ size: "small",
1213
+ startIcon: /*#__PURE__*/jsxRuntime.jsx(VerticalAlignBottomIcon, {}),
1214
+ onClick: function onClick() {
1215
+ return layer(function () {
1216
+ return element.moveBottom();
1217
+ });
1218
+ },
1219
+ sx: _positionMenuItemSx,
1220
+ children: t('toolbar.toBottom', 'To back')
1221
+ })]
1222
+ }), /*#__PURE__*/jsxRuntime.jsx(material.Divider, {
1223
+ sx: {
1224
+ mb: 1.5
1225
+ }
1226
+ }), /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
1227
+ variant: "caption",
1228
+ sx: {
1229
+ fontWeight: 700,
1230
+ color: '#111',
1231
+ display: 'block',
1232
+ mb: 1,
1233
+ fontSize: 12
1234
+ },
1235
+ children: t('toolbar.position', 'Position')
1236
+ }), function () {
1237
+ var cx = (pageW - element.width) / 2;
1238
+ var cy = (pageH - element.height) / 2;
1239
+ var rx = pageW - element.width;
1240
+ var by = pageH - element.height;
1241
+ var positions = [{
1242
+ label: 'Top left',
1243
+ x: 0,
1244
+ y: 0,
1245
+ row: 0,
1246
+ col: 0
1247
+ }, {
1248
+ label: 'Top center',
1249
+ x: cx,
1250
+ y: 0,
1251
+ row: 0,
1252
+ col: 1
1253
+ }, {
1254
+ label: 'Top right',
1255
+ x: rx,
1256
+ y: 0,
1257
+ row: 0,
1258
+ col: 2
1259
+ }, {
1260
+ label: 'Middle left',
1261
+ x: 0,
1262
+ y: cy,
1263
+ row: 1,
1264
+ col: 0
1265
+ }, {
1266
+ label: 'Center',
1267
+ x: cx,
1268
+ y: cy,
1269
+ row: 1,
1270
+ col: 1
1271
+ }, {
1272
+ label: 'Middle right',
1273
+ x: rx,
1274
+ y: cy,
1275
+ row: 1,
1276
+ col: 2
1277
+ }, {
1278
+ label: 'Bottom left',
1279
+ x: 0,
1280
+ y: by,
1281
+ row: 2,
1282
+ col: 0
1283
+ }, {
1284
+ label: 'Bottom center',
1285
+ x: cx,
1286
+ y: by,
1287
+ row: 2,
1288
+ col: 1
1289
+ }, {
1290
+ label: 'Bottom right',
1291
+ x: rx,
1292
+ y: by,
1293
+ row: 2,
1294
+ col: 2
1295
+ }];
1296
+ return /*#__PURE__*/jsxRuntime.jsx(material.Box, {
1297
+ sx: {
1298
+ display: 'grid',
1299
+ gridTemplateColumns: 'repeat(3, 1fr)',
1300
+ gap: 0.5
1301
+ },
1302
+ children: positions.map(function (_ref9) {
1303
+ var label = _ref9.label,
1304
+ x = _ref9.x,
1305
+ y = _ref9.y;
1306
+ return /*#__PURE__*/jsxRuntime.jsx(material.Tooltip, {
1307
+ title: label,
1308
+ placement: "top",
1309
+ children: /*#__PURE__*/jsxRuntime.jsx(material.IconButton, {
1310
+ size: "small",
1311
+ onClick: function onClick() {
1312
+ return alignEl(x, y);
1313
+ },
1314
+ sx: {
1315
+ borderRadius: '6px',
1316
+ border: '1px solid #e0e0e0',
1317
+ p: 0.75,
1318
+ '&:hover': {
1319
+ backgroundColor: 'rgba(13,131,205,0.08)',
1320
+ borderColor: '#0d83cd'
1321
+ }
1322
+ },
1323
+ children: /*#__PURE__*/jsxRuntime.jsx(material.Box, {
1324
+ sx: {
1325
+ display: 'grid',
1326
+ gridTemplateColumns: 'repeat(3, 5px)',
1327
+ gap: '2px'
1328
+ },
1329
+ children: [0, 1, 2].map(function (r) {
1330
+ return [0, 1, 2].map(function (c) {
1331
+ return /*#__PURE__*/jsxRuntime.jsx(material.Box, {
1332
+ sx: {
1333
+ width: 5,
1334
+ height: 5,
1335
+ borderRadius: '1px',
1336
+ backgroundColor: r === positions.find(function (p) {
1337
+ return p.label === label;
1338
+ }).row && c === positions.find(function (p) {
1339
+ return p.label === label;
1340
+ }).col ? '#0d83cd' : '#ccc'
1341
+ }
1342
+ }, "".concat(r, "-").concat(c));
1343
+ });
1344
+ })
1345
+ })
1346
+ })
1347
+ }, label);
1348
+ })
1349
+ });
1350
+ }()]
1351
+ })]
1352
+ });
1353
+ });
1354
+
1355
+ // Common controls for all element types
1356
+ var CommonControls = mobxReactLite.observer(function (_ref0) {
1357
+ var element = _ref0.element,
1358
+ store = _ref0.store;
1075
1359
  var isLocked = element.locked;
1076
1360
  var handleDuplicate = function handleDuplicate() {
1077
1361
  if (element.clone) {
@@ -1112,14 +1396,6 @@ var CommonControls = mobxReactLite.observer(function (_ref8) {
1112
1396
  var handleOpacityCommit = function handleOpacityCommit() {
1113
1397
  store.history.addUndoState();
1114
1398
  };
1115
- var handleMoveUp = function handleMoveUp() {
1116
- element.moveUp();
1117
- store.history.addUndoState();
1118
- };
1119
- var handleMoveDown = function handleMoveDown() {
1120
- element.moveDown();
1121
- store.history.addUndoState();
1122
- };
1123
1399
  return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
1124
1400
  children: [/*#__PURE__*/jsxRuntime.jsx(material.Tooltip, {
1125
1401
  title: t('toolbar.opacity', 'Opacity'),
@@ -1154,24 +1430,9 @@ var CommonControls = mobxReactLite.observer(function (_ref8) {
1154
1430
  sx: {
1155
1431
  mx: 0.5
1156
1432
  }
1157
- }), /*#__PURE__*/jsxRuntime.jsx(material.Tooltip, {
1158
- title: t('toolbar.up', 'Move up'),
1159
- children: /*#__PURE__*/jsxRuntime.jsx(material.IconButton, {
1160
- size: "small",
1161
- onClick: handleMoveUp,
1162
- children: /*#__PURE__*/jsxRuntime.jsx(ArrowUpwardIcon, {
1163
- fontSize: "small"
1164
- })
1165
- })
1166
- }), /*#__PURE__*/jsxRuntime.jsx(material.Tooltip, {
1167
- title: t('toolbar.down', 'Move down'),
1168
- children: /*#__PURE__*/jsxRuntime.jsx(material.IconButton, {
1169
- size: "small",
1170
- onClick: handleMoveDown,
1171
- children: /*#__PURE__*/jsxRuntime.jsx(ArrowDownwardIcon, {
1172
- fontSize: "small"
1173
- })
1174
- })
1433
+ }), /*#__PURE__*/jsxRuntime.jsx(PositionButton, {
1434
+ element: element,
1435
+ store: store
1175
1436
  }), /*#__PURE__*/jsxRuntime.jsx(material.Divider, {
1176
1437
  orientation: "vertical",
1177
1438
  flexItem: true,
@@ -1215,26 +1476,26 @@ var CommonControls = mobxReactLite.observer(function (_ref8) {
1215
1476
  });
1216
1477
 
1217
1478
  // Download button with format/quality popover
1218
- var DefaultDownloadButton = mobxReactLite.observer(function (_ref9) {
1219
- var store = _ref9.store;
1220
- var _useState3 = React.useState(null),
1221
- _useState4 = _slicedToArray(_useState3, 2),
1222
- anchorEl = _useState4[0],
1223
- setAnchorEl = _useState4[1];
1224
- var _useState5 = React.useState('png'),
1479
+ var DefaultDownloadButton = mobxReactLite.observer(function (_ref1) {
1480
+ var store = _ref1.store;
1481
+ var _useState5 = React.useState(null),
1225
1482
  _useState6 = _slicedToArray(_useState5, 2),
1226
- fileType = _useState6[0],
1227
- setFileType = _useState6[1];
1483
+ anchorEl = _useState6[0],
1484
+ setAnchorEl = _useState6[1];
1485
+ var _useState7 = React.useState('png'),
1486
+ _useState8 = _slicedToArray(_useState7, 2),
1487
+ fileType = _useState8[0],
1488
+ setFileType = _useState8[1];
1228
1489
  // Default quality so pixelRatio=1 (output = template's own pixel size).
1229
1490
  // qualityToPixelRatio(q) = q * 3, so q = 1/3 → pixelRatio = 1.
1230
- var _useState7 = React.useState(1 / 3),
1231
- _useState8 = _slicedToArray(_useState7, 2),
1232
- quality = _useState8[0],
1233
- setQuality = _useState8[1];
1234
- var _useState9 = React.useState(false),
1491
+ var _useState9 = React.useState(1 / 3),
1235
1492
  _useState0 = _slicedToArray(_useState9, 2),
1236
- exporting = _useState0[0],
1237
- setExporting = _useState0[1];
1493
+ quality = _useState0[0],
1494
+ setQuality = _useState0[1];
1495
+ var _useState1 = React.useState(false),
1496
+ _useState10 = _slicedToArray(_useState1, 2),
1497
+ exporting = _useState10[0],
1498
+ setExporting = _useState10[1];
1238
1499
  var open = Boolean(anchorEl);
1239
1500
  var handleClick = function handleClick(e) {
1240
1501
  setAnchorEl(e.currentTarget);
@@ -1467,15 +1728,15 @@ var DefaultDownloadButton = mobxReactLite.observer(function (_ref9) {
1467
1728
  });
1468
1729
 
1469
1730
  // Import button — loads a JSON template file into the store
1470
- var DefaultImportButton = mobxReactLite.observer(function (_ref1) {
1471
- var store = _ref1.store;
1472
- var _useState1 = React.useState(false),
1473
- _useState10 = _slicedToArray(_useState1, 2),
1474
- importing = _useState10[0],
1475
- setImporting = _useState10[1];
1731
+ var DefaultImportButton = mobxReactLite.observer(function (_ref11) {
1732
+ var store = _ref11.store;
1733
+ var _useState11 = React.useState(false),
1734
+ _useState12 = _slicedToArray(_useState11, 2),
1735
+ importing = _useState12[0],
1736
+ setImporting = _useState12[1];
1476
1737
  var fileInputRef = React.useRef(null);
1477
1738
  var handleFileChange = React.useCallback(/*#__PURE__*/function () {
1478
- var _ref10 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(e) {
1739
+ var _ref12 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(e) {
1479
1740
  var _e$target$files;
1480
1741
  var file, text, jsonData, _t3;
1481
1742
  return _regenerator().w(function (_context2) {
@@ -1513,7 +1774,7 @@ var DefaultImportButton = mobxReactLite.observer(function (_ref1) {
1513
1774
  }, _callee2, null, [[2, 4, 5, 6]]);
1514
1775
  }));
1515
1776
  return function (_x) {
1516
- return _ref10.apply(this, arguments);
1777
+ return _ref12.apply(this, arguments);
1517
1778
  };
1518
1779
  }(), [store]);
1519
1780
  return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
@@ -1579,10 +1840,10 @@ var rowSx = {
1579
1840
  display: 'none'
1580
1841
  }
1581
1842
  };
1582
- var Toolbar = mobxReactLite.observer(function (_ref11) {
1583
- var store = _ref11.store,
1584
- _ref11$components = _ref11.components,
1585
- components = _ref11$components === void 0 ? {} : _ref11$components;
1843
+ var Toolbar = mobxReactLite.observer(function (_ref13) {
1844
+ var store = _ref13.store,
1845
+ _ref13$components = _ref13.components,
1846
+ components = _ref13$components === void 0 ? {} : _ref13$components;
1586
1847
  var ActionControls = components.ActionControls;
1587
1848
  var ImportButton = 'ImportButton' in components ? components.ImportButton : DefaultImportButton;
1588
1849
  var DownloadButton = 'DownloadButton' in components ? components.DownloadButton : DefaultDownloadButton;