@configuratorware/configurator-frontendgui 1.57.12 → 1.57.14

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.
Files changed (24) hide show
  1. package/App/Modules/Designer/Components/DesignerSelectionToolbox/DesignerSelectionToolbox.js +5 -1
  2. package/App/Modules/Designer/Containers/DesignerSelectionToolbox.js +10 -2
  3. package/App/Reducers/Configurator/Reducer.js +35 -14
  4. package/App/Reducers/DesignArea/Selectors.js +39 -7
  5. package/App/Reducers/Fonts/Selectors.js +35 -10
  6. package/App/Services/DesignerService.js +23 -5
  7. package/App/Shared/Components/AmountInput/index.js +65 -44
  8. package/App/Shared/Components/ProductVariant/index.js +1 -1
  9. package/package.json +4 -4
  10. package/src/App/Modules/Designer/Components/DesignerSelectionToolbox/DesignerSelectionToolbox.js +4 -0
  11. package/src/App/Modules/Designer/Containers/DesignerSelectionToolbox.js +5 -1
  12. package/src/App/Reducers/Configurator/Reducer.js +67 -17
  13. package/src/App/Reducers/Configurator/__tests__/Reducer.test.js +230 -30
  14. package/src/App/Reducers/DesignArea/Selectors.js +26 -0
  15. package/src/App/Reducers/DesignArea/__tests__/Selectors.test.js +19 -0
  16. package/src/App/Reducers/Fonts/Selectors.js +25 -5
  17. package/src/App/Reducers/Fonts/__tests__/Selectors.test.js +14 -1
  18. package/src/App/Services/DesignerService.js +28 -9
  19. package/src/App/Services/__tests__/DesignerService.test.js +111 -0
  20. package/src/App/Shared/Components/AmountInput/__tests__/AmountInput.blur.test.js +249 -0
  21. package/src/App/Shared/Components/AmountInput/__tests__/AmountInput.retyp.test.js +57 -0
  22. package/src/App/Shared/Components/AmountInput/__tests__/index.test.js +16 -0
  23. package/src/App/Shared/Components/AmountInput/index.js +42 -38
  24. package/src/App/Shared/Components/ProductVariant/index.js +1 -1
@@ -299,7 +299,11 @@ var DesignerSelectionToolbox = function DesignerSelectionToolbox(props) {
299
299
  var isBulkName = !selectedObject.isBulkName;
300
300
  canvas.selectedObject.isBulkName = isBulkName;
301
301
  canvas.selectedObject.content = getTextContent({
302
- isBulkName: isBulkName
302
+ isBulkName: isBulkName,
303
+ styleColors: selectedObject.style.colors,
304
+ fontItem: currentFontItem,
305
+ isBold: isBold,
306
+ isItalic: isItalic
303
307
  });
304
308
  },
305
309
  alignVerticalCenterIcon: alignVerticalCenterIcon,
@@ -79,9 +79,17 @@ var mapDispatchToProps = function mapDispatchToProps(dispatch) {
79
79
  });
80
80
  },
81
81
  getTextContent: function getTextContent(_ref) {
82
- var isBulkName = _ref.isBulkName;
82
+ var isBulkName = _ref.isBulkName,
83
+ styleColors = _ref.styleColors,
84
+ fontItem = _ref.fontItem,
85
+ isBold = _ref.isBold,
86
+ isItalic = _ref.isItalic;
83
87
  return _ServiceLocator.Services.designer.createColorizedTextContent((0, _i18n.t)(isBulkName ? 'textControlbox.bulknames' : 'addVisualElement.initialText'), 1, {
84
- withPlaceholder: !isBulkName
88
+ withPlaceholder: !isBulkName,
89
+ styleColors: styleColors,
90
+ fontItem: fontItem,
91
+ isBold: isBold,
92
+ isItalic: isItalic
85
93
  });
86
94
  },
87
95
  addCustomFont: function addCustomFont(customFont) {
@@ -24,12 +24,17 @@ var _isArray = _interopRequireDefault(require("lodash/isArray"));
24
24
  var _find = _interopRequireDefault(require("lodash/find"));
25
25
  var _findIndex = _interopRequireDefault(require("lodash/findIndex"));
26
26
  var _omit = _interopRequireDefault(require("lodash/omit"));
27
- var _forEach = _interopRequireDefault(require("lodash/forEach"));
28
27
  var _reduce = _interopRequireDefault(require("lodash/reduce"));
29
28
  var _set = _interopRequireDefault(require("../../../Utils/Immutable/set"));
30
29
  var _Reducer = require("../DesignData/Reducer");
31
30
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
32
31
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
32
+ function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
33
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
34
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
35
+ function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
36
+ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
37
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
33
38
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
34
39
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
35
40
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
@@ -397,6 +402,10 @@ function baseHandler(state, action) {
397
402
  var selectedAmountsPath = 'customdata.selectedAmounts';
398
403
  var selectedAmounts = (0, _get["default"])(state.configuration, selectedAmountsPath, {});
399
404
  var configuration = (0, _set["default"])(state.configuration, selectedAmountsPath, action.amount === 0 ? (0, _omit["default"])(selectedAmounts, action.identifier) : _objectSpread(_objectSpread({}, selectedAmounts), {}, _defineProperty({}, action.identifier, action.amount)));
405
+ if (action.amount === 0) {
406
+ var bulkNames = (0, _get["default"])(configuration, 'customdata.bulkNames', {});
407
+ configuration = (0, _set["default"])(configuration, 'customdata.bulkNames', (0, _omit["default"])(bulkNames, action.identifier));
408
+ }
400
409
  return _objectSpread(_objectSpread({}, state), {}, {
401
410
  selectedAmountsUpdated: !!action.isUpdatedByUser,
402
411
  configuration: configuration
@@ -406,12 +415,21 @@ function baseHandler(state, action) {
406
415
  {
407
416
  var srcIdentifier = action.srcIdentifier,
408
417
  dstIdentifier = action.dstIdentifier;
418
+ if (srcIdentifier === dstIdentifier) {
419
+ return state;
420
+ }
409
421
  var _selectedAmountsPath = 'customdata.selectedAmounts';
410
422
  var _selectedAmounts = (0, _get["default"])(state.configuration, _selectedAmountsPath, {});
411
423
  if (!(srcIdentifier in _selectedAmounts)) {
412
424
  return state;
413
425
  }
414
426
  var _configuration3 = (0, _set["default"])(state.configuration, _selectedAmountsPath, (0, _omit["default"])(_objectSpread(_objectSpread({}, _selectedAmounts), {}, _defineProperty({}, dstIdentifier, _selectedAmounts[srcIdentifier])), srcIdentifier));
427
+ var _bulkNames = (0, _get["default"])(_configuration3, 'customdata.bulkNames', {});
428
+ if (srcIdentifier in _bulkNames) {
429
+ _configuration3 = (0, _set["default"])(_configuration3, 'customdata.bulkNames', (0, _omit["default"])(_objectSpread(_objectSpread({}, _bulkNames), {}, _defineProperty({}, dstIdentifier, _bulkNames[srcIdentifier])), srcIdentifier));
430
+ } else if (dstIdentifier in _bulkNames) {
431
+ _configuration3 = (0, _set["default"])(_configuration3, 'customdata.bulkNames', (0, _omit["default"])(_bulkNames, dstIdentifier));
432
+ }
415
433
  return _objectSpread(_objectSpread({}, state), {}, {
416
434
  configuration: _configuration3
417
435
  });
@@ -419,11 +437,18 @@ function baseHandler(state, action) {
419
437
  case actionTypes.SET_SELECTED_AMOUNTS:
420
438
  {
421
439
  var _selectedAmountsPath2 = 'configuration.customdata.selectedAmounts';
440
+ var bulkNamesPath = 'configuration.customdata.bulkNames';
422
441
  var _selectedAmounts2 = (0, _get["default"])(state, _selectedAmountsPath2, {});
423
442
  var nextAmounts = _objectSpread(_objectSpread({}, _selectedAmounts2), action.sizes);
443
+ var removedIdentifiers = (0, _filter["default"])(Object.keys(action.sizes || {}), function (identifier) {
444
+ return action.sizes[identifier] === 0;
445
+ });
424
446
  var newState = _objectSpread(_objectSpread({}, state), {}, {
425
447
  selectedAmountsUpdated: !!action.isUpdatedByUser
426
448
  });
449
+ if (removedIdentifiers.length > 0) {
450
+ newState = (0, _set["default"])(newState, bulkNamesPath, (0, _omit["default"])((0, _get["default"])(state, bulkNamesPath, {}), removedIdentifiers));
451
+ }
427
452
  return (0, _set["default"])(newState, _selectedAmountsPath2, _objectSpread({}, (0, _reduce["default"])(nextAmounts, function (selectedAmounts, amount, identifier) {
428
453
  if (amount !== 0) {
429
454
  return _objectSpread(_objectSpread({}, selectedAmounts), {}, _defineProperty({}, identifier, amount));
@@ -435,16 +460,12 @@ function baseHandler(state, action) {
435
460
  case actionTypes.DELETE_SELECTED_AMOUNTS:
436
461
  {
437
462
  var _selectedAmountsPath3 = 'configuration.customdata.selectedAmounts';
438
- var _selectedAmounts3 = (0, _cloneDeep["default"])((0, _get["default"])(state, _selectedAmountsPath3, {}));
439
- (0, _forEach["default"])(_selectedAmounts3, function (selectedAmount, identifier) {
440
- var variantIdentifier = (0, _find["default"])(action.variant.sizes, {
441
- identifier: identifier
442
- });
443
- if (variantIdentifier) {
444
- delete _selectedAmounts3[variantIdentifier.identifier];
445
- }
446
- });
447
- return (0, _set["default"])(state, _selectedAmountsPath3, _selectedAmounts3);
463
+ var _bulkNamesPath = 'configuration.customdata.bulkNames';
464
+ var sizeIdentifiers = (0, _reduce["default"])((0, _get["default"])(action, 'variant.sizes', []), function (identifiers, size) {
465
+ return size !== null && size !== void 0 && size.identifier ? [].concat(_toConsumableArray(identifiers), [size.identifier]) : identifiers;
466
+ }, []);
467
+ var nextState = (0, _set["default"])(state, _selectedAmountsPath3, (0, _omit["default"])((0, _get["default"])(state, _selectedAmountsPath3, {}), sizeIdentifiers));
468
+ return (0, _set["default"])(nextState, _bulkNamesPath, (0, _omit["default"])((0, _get["default"])(state, _bulkNamesPath, {}), sizeIdentifiers));
448
469
  }
449
470
  default:
450
471
  return state;
@@ -485,9 +506,9 @@ function configurationModifierHandler(state, action) {
485
506
  case actionTypes.DELETE_SELECTED_AMOUNT:
486
507
  {
487
508
  var selectedAmountsPath = 'configuration.customdata.selectedAmounts';
488
- var selectedAmounts = (0, _cloneDeep["default"])((0, _get["default"])(state, selectedAmountsPath, {}));
489
- delete selectedAmounts[action.identifier];
490
- return (0, _set["default"])(state, selectedAmountsPath, selectedAmounts);
509
+ var _bulkNamesPath2 = 'configuration.customdata.bulkNames';
510
+ var nextState = (0, _set["default"])(state, selectedAmountsPath, (0, _omit["default"])((0, _get["default"])(state, selectedAmountsPath, {}), action.identifier));
511
+ return (0, _set["default"])(nextState, _bulkNamesPath2, (0, _omit["default"])((0, _get["default"])(state, _bulkNamesPath2, {}), action.identifier));
491
512
  }
492
513
  case actionTypes.SET_SELECTED_CALCULATION:
493
514
  {
@@ -61,6 +61,8 @@ var _exportNames = {
61
61
  findSmallestFontSizeInCanvasData: true,
62
62
  createColorData: true,
63
63
  parseColorData: true,
64
+ normalizeTextColorData: true,
65
+ getColorDataForTextContent: true,
64
66
  getCameraViewListForDesignAreaList: true,
65
67
  getDesignViewListForDesignAreas: true,
66
68
  getDesignAreaFromSelectedDesignView: true,
@@ -93,6 +95,7 @@ exports.getAvailableColorsForDesignProductionMethod = getAvailableColorsForDesig
93
95
  exports.getCameraViewListForDesignAreaList = void 0;
94
96
  exports.getCanvasSizeFromDesignArea = getCanvasSizeFromDesignArea;
95
97
  exports.getCanvasSizeFromDesignProductionMethod = getCanvasSizeFromDesignProductionMethod;
98
+ exports.getColorDataForTextContent = void 0;
96
99
  exports.getColorOverlayData = getColorOverlayData;
97
100
  exports.getColorPalettes = void 0;
98
101
  exports.getColors = getColors;
@@ -139,7 +142,7 @@ exports.isHighlighted = isHighlighted;
139
142
  exports.isOneLineText = isOneLineText;
140
143
  exports.isPlaceholderContent = void 0;
141
144
  exports.isThereAFatalError = isThereAFatalError;
142
- exports.rgbToHex = exports.rgbString2hex = exports.rgbObjToHex = exports.parseColorData = exports.isVectorizedLogoMandatory = exports.isValidHex = void 0;
145
+ exports.rgbToHex = exports.rgbString2hex = exports.rgbObjToHex = exports.parseColorData = exports.normalizeTextColorData = exports.isVectorizedLogoMandatory = exports.isValidHex = void 0;
143
146
  var _get = _interopRequireDefault(require("lodash/get"));
144
147
  var _first = _interopRequireDefault(require("lodash/first"));
145
148
  var _find2 = _interopRequireDefault(require("lodash/find"));
@@ -801,6 +804,35 @@ var parseColorData = exports.parseColorData = function parseColorData(jsonStr) {
801
804
  color: null
802
805
  }, colorData);
803
806
  };
807
+
808
+ /**
809
+ * Normalizes canvas text color entries (style.colors or text editor) for HTML generation.
810
+ * @param {{ identifier: string|object, value: string }|null|undefined} color
811
+ * @returns {{ identifier: string, value: string }|null}
812
+ */
813
+ var normalizeTextColorData = exports.normalizeTextColorData = function normalizeTextColorData(color) {
814
+ if (!(color !== null && color !== void 0 && color.identifier) || !(color !== null && color !== void 0 && color.value)) {
815
+ return null;
816
+ }
817
+ var identifier = typeof color.identifier === 'string' ? color.identifier : JSON.stringify(color.identifier);
818
+ return {
819
+ identifier: identifier,
820
+ value: color.value.toLowerCase()
821
+ };
822
+ };
823
+
824
+ /**
825
+ * Color from canvas object style.colors (parsed from content HTML).
826
+ * @param {{ styleColors?: Array }} params
827
+ * @returns {{ identifier: string, value: string }|null}
828
+ */
829
+ var getColorDataForTextContent = exports.getColorDataForTextContent = function getColorDataForTextContent(_ref10) {
830
+ var styleColors = _ref10.styleColors;
831
+ if ((styleColors === null || styleColors === void 0 ? void 0 : styleColors.length) > 0) {
832
+ return normalizeTextColorData(styleColors[0]);
833
+ }
834
+ return null;
835
+ };
804
836
  var getCameraViewListForDesignAreaList = exports.getCameraViewListForDesignAreaList = function getCameraViewListForDesignAreaList(filteredDesignAreas, designedAreas) {
805
837
  return ['default'].concat(filteredDesignAreas
806
838
  // get the design area objects by their id
@@ -958,8 +990,8 @@ var contentHasText = exports.contentHasText = function contentHasText(content) {
958
990
  return /\S/.test(div.textContent);
959
991
  };
960
992
  var getDesignAreaImageCompatibilityInfo = exports.getDesignAreaImageCompatibilityInfo = function getDesignAreaImageCompatibilityInfo(designProductionMethod) {
961
- var colorPalettes = ((0, _get["default"])(designProductionMethod, 'colorPalettes') || []).map(function (_ref10) {
962
- var identifier = _ref10.identifier;
993
+ var colorPalettes = ((0, _get["default"])(designProductionMethod, 'colorPalettes') || []).map(function (_ref11) {
994
+ var identifier = _ref11.identifier;
963
995
  return identifier;
964
996
  }).sort();
965
997
  var vectorsRequired = !!(0, _get["default"])(designProductionMethod, 'options.vectorsRequired');
@@ -1016,8 +1048,8 @@ var getVectorizedImageColor = exports.getVectorizedImageColor = function getVect
1016
1048
  }
1017
1049
  return {};
1018
1050
  };
1019
- var areAllDesignAreasEmpty = exports.areAllDesignAreasEmpty = function areAllDesignAreasEmpty(_ref11) {
1020
- var configuration = _ref11.configuration;
1051
+ var areAllDesignAreasEmpty = exports.areAllDesignAreasEmpty = function areAllDesignAreasEmpty(_ref12) {
1052
+ var configuration = _ref12.configuration;
1021
1053
  var designdata = (0, _get["default"])(configuration, 'designdata', {});
1022
1054
  for (var key in designdata) {
1023
1055
  if (!designdata.hasOwnProperty(key)) {
@@ -1082,8 +1114,8 @@ var getImagesByDesignArea = exports.getImagesByDesignArea = function getImagesBy
1082
1114
  designAreaIdentifier = getSelectedDesignArea(state).identifier;
1083
1115
  }
1084
1116
  var designData = getDesignDataByDesignAreaIdentifier(state, designAreaIdentifier);
1085
- return (0, _get["default"])(designData, 'canvasData.objects', []).filter(function (_ref12) {
1086
- var type = _ref12.type;
1117
+ return (0, _get["default"])(designData, 'canvasData.objects', []).filter(function (_ref13) {
1118
+ var type = _ref13.type;
1087
1119
  return type === 'Image';
1088
1120
  });
1089
1121
  };
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getDefaultFont = getDefaultFont;
7
- exports.getFontMapping = exports.getDefaultFontParams = void 0;
7
+ exports.getTextContentFontParamsFromSelection = exports.getFontMapping = exports.getDefaultFontParams = void 0;
8
8
  exports.getUsedCustomFontsInEditor = getUsedCustomFontsInEditor;
9
9
  var _first = _interopRequireDefault(require("lodash/first"));
10
10
  var _each = _interopRequireDefault(require("lodash/each"));
@@ -27,6 +27,33 @@ function getDefaultFont(state) {
27
27
  isDefault: true
28
28
  }) || (0, _first["default"])(fonts);
29
29
  }
30
+ var stringifyFontParams = function stringifyFontParams(fontParams) {
31
+ return Object.keys(fontParams).map(function (prop) {
32
+ return "".concat(prop, ": ").concat(fontParams[prop], ";");
33
+ }).join(' ');
34
+ };
35
+
36
+ /**
37
+ * Inline font CSS from the text toolbar selection (font family + bold/italic).
38
+ * @param {{ fontItem?: { family?: string }, isBold?: boolean, isItalic?: boolean }} params
39
+ * @returns {string}
40
+ */
41
+ var getTextContentFontParamsFromSelection = exports.getTextContentFontParamsFromSelection = function getTextContentFontParamsFromSelection(_ref) {
42
+ var fontItem = _ref.fontItem,
43
+ isBold = _ref.isBold,
44
+ isItalic = _ref.isItalic;
45
+ if (!(fontItem !== null && fontItem !== void 0 && fontItem.family)) {
46
+ return '';
47
+ }
48
+ var fontParams = {
49
+ 'font-family': "\"".concat(escapeQuotes(fontItem.family), "\""),
50
+ 'font-weight': isBold ? 'bold' : 'normal',
51
+ 'font-style': isItalic ? 'italic' : 'normal'
52
+ };
53
+ return Object.keys(fontParams).map(function (prop) {
54
+ return "".concat(prop, ": ").concat(fontParams[prop], ";");
55
+ }).join(' ');
56
+ };
30
57
  var getDefaultFontParams = exports.getDefaultFontParams = function getDefaultFontParams(state) {
31
58
  var stringify = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
32
59
  var defaultFont = getDefaultFont(state);
@@ -35,12 +62,10 @@ var getDefaultFontParams = exports.getDefaultFontParams = function getDefaultFon
35
62
  'font-weight': 'normal',
36
63
  'font-style': 'normal'
37
64
  };
38
- return stringify ? Object.keys(fontParams).map(function (prop) {
39
- return "".concat(prop, ": ").concat(fontParams[prop], ";");
40
- }).join(' ') : fontParams;
65
+ return stringify ? stringifyFontParams(fontParams) : fontParams;
41
66
  };
42
- var getFontMapping = exports.getFontMapping = (0, _createSelector["default"])(function (_ref) {
43
- var fonts = _ref.fonts;
67
+ var getFontMapping = exports.getFontMapping = (0, _createSelector["default"])(function (_ref2) {
68
+ var fonts = _ref2.fonts;
44
69
  return fonts;
45
70
  }, function (fonts) {
46
71
  var typeToUrlProp = {
@@ -67,11 +92,11 @@ function getUsedCustomFontsInEditor(state) {
67
92
  var designdata = (0, _get["default"])(state, 'configurator.configuration.designdata') || {};
68
93
  Object.values(designdata).forEach(function (designAreaData) {
69
94
  var objects = (0, _get["default"])(designAreaData, 'canvasData.objects') || [];
70
- objects.filter(function (_ref2) {
71
- var type = _ref2.type;
95
+ objects.filter(function (_ref3) {
96
+ var type = _ref3.type;
72
97
  return type === 'Text';
73
- }).forEach(function (_ref3) {
74
- var fontItem = _ref3.fontItem;
98
+ }).forEach(function (_ref4) {
99
+ var fontItem = _ref4.fontItem;
75
100
  if (fontItem.isCustomFont) {
76
101
  var customFontObj = _objectSpread(_objectSpread({}, getDefaultFont(state)), fontItem);
77
102
  !(0, _find["default"])(usedCustomFonts, customFontObj) && usedCustomFonts.push(customFontObj);
@@ -477,14 +477,32 @@ var DesignerService = exports["default"] = /*#__PURE__*/function () {
477
477
  var colorCount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
478
478
  var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
479
479
  var _options$withPlacehol = options.withPlaceholder,
480
- withPlaceholder = _options$withPlacehol === void 0 ? true : _options$withPlacehol;
480
+ withPlaceholder = _options$withPlacehol === void 0 ? true : _options$withPlacehol,
481
+ _options$styleColors = options.styleColors,
482
+ styleColors = _options$styleColors === void 0 ? null : _options$styleColors,
483
+ _options$fontItem2 = options.fontItem,
484
+ fontItem = _options$fontItem2 === void 0 ? null : _options$fontItem2,
485
+ _options$isBold = options.isBold,
486
+ isBold = _options$isBold === void 0 ? false : _options$isBold,
487
+ _options$isItalic = options.isItalic,
488
+ isItalic = _options$isItalic === void 0 ? false : _options$isItalic;
481
489
  var state = _ServiceLocator.Services.store.state;
482
- var fontParams = (0, _Selectors3.getDefaultFontParams)(state);
490
+ var selectionFontParams = (0, _Selectors3.getTextContentFontParamsFromSelection)({
491
+ fontItem: fontItem,
492
+ isBold: isBold,
493
+ isItalic: isItalic
494
+ });
495
+ var fontParams = selectionFontParams || (0, _Selectors3.getDefaultFontParams)(state);
483
496
  var chunkLength = Math.ceil(str.length / colorCount);
484
497
  var content = str.match(new RegExp(".{1,".concat(chunkLength, "}"), 'g')).map(function (chunk, idx) {
485
- var color = (0, _Selectors2.getDefaultTextColor)(state, colorCount > 1 ? idx : null);
486
- var lastImageColor = (0, _Selectors2.getVectorizedImageColor)(state);
487
- var colorData = (0, _isEmpty["default"])(lastImageColor) ? (0, _Selectors2.createColorData)(color.identifier, color.paletteIdentifier, color.custom, color.value) : lastImageColor;
498
+ var colorData = (0, _Selectors2.getColorDataForTextContent)({
499
+ styleColors: styleColors
500
+ });
501
+ if (!colorData) {
502
+ var color = (0, _Selectors2.getDefaultTextColor)(state, colorCount > 1 ? idx : null);
503
+ var lastImageColor = (0, _Selectors2.getVectorizedImageColor)(state);
504
+ colorData = (0, _isEmpty["default"])(lastImageColor) ? (0, _Selectors2.createColorData)(color.identifier, color.paletteIdentifier, color.custom, color.value) : lastImageColor;
505
+ }
488
506
  return "<span style='color: ".concat(colorData.value, "; ").concat(fontParams, "' data-color='").concat(colorData.identifier, "'>").concat(chunk, "</span>");
489
507
  }).join('');
490
508
  return withPlaceholder ? (0, _Modifiers.createTextPlaceholder)(content) : content;
@@ -87,15 +87,6 @@ var AmountInput = /*#__PURE__*/function (_React$Component) {
87
87
  value: '',
88
88
  changeInprogress: false
89
89
  });
90
- _defineProperty(_assertThisInitialized(_this), "updateDebounced", (0, _debounce["default"])(function () {
91
- var _assertThisInitialize = _assertThisInitialized(_this),
92
- value = _assertThisInitialize.props.value;
93
- if (value !== _this.state.value) {
94
- _this.setState({
95
- value: value
96
- });
97
- }
98
- }, 500));
99
90
  _defineProperty(_assertThisInitialized(_this), "validateKey", function (event) {
100
91
  var regEx = /^[0-9\b]+$/;
101
92
  var keyCode = event.keyCode || event.which;
@@ -104,46 +95,65 @@ var AmountInput = /*#__PURE__*/function (_React$Component) {
104
95
  event.preventDefault();
105
96
  }
106
97
  });
98
+ _defineProperty(_assertThisInitialized(_this), "hasPendingChange", false);
99
+ // An empty field means the user is retyping: committing 0 here would drop data tied to the amount
100
+ // (e.g. bulk names). It is committed on blur or unmount instead.
107
101
  _defineProperty(_assertThisInitialized(_this), "onChangeDebounced", (0, _debounce["default"])(function () {
108
- _this.props.onChange(_this.state.value === '' ? 0 : _this.state.value);
102
+ if (_this.state.value === '') {
103
+ return;
104
+ }
105
+ _this.hasPendingChange = false;
106
+ _this.props.onChange(_this.state.value);
109
107
  }, _this.props.onChangeDebounceWait));
110
108
  _defineProperty(_assertThisInitialized(_this), "onChange", function (_ref) {
111
109
  var inputValue = _ref.target.value;
112
110
  var _this$props = _this.props,
113
111
  min = _this$props.min,
114
112
  max = _this$props.max;
115
- var value = !inputValue ? inputValue : Math.min(max, Math.max(min, parseInt(inputValue)));
113
+ var value = !inputValue ? inputValue : Math.min(max, Math.max(min, parseInt(inputValue, 10)));
114
+ _this.hasPendingChange = true;
116
115
  _this.setState({
117
- value: isNaN(value) ? '' : value
116
+ value: Number.isNaN(value) ? '' : value
118
117
  }, _this.onChangeDebounced);
119
118
  });
120
119
  _defineProperty(_assertThisInitialized(_this), "onBlur", function (event) {
121
- var value = event.target.value;
122
120
  var _this$props2 = _this.props,
123
121
  onChange = _this$props2.onChange,
124
122
  onBlur = _this$props2.onBlur,
125
123
  min = _this$props2.min,
124
+ readOnly = _this$props2.readOnly,
126
125
  hasValueLabel = _this$props2.hasValueLabel;
127
- _this.setState({
128
- changeInprogress: false
129
- });
130
- if (value === '') {
131
- var initialValue = min;
126
+ if (readOnly) {
132
127
  _this.setState({
133
- value: initialValue
128
+ changeInprogress: false,
129
+ value: _this.props.value
134
130
  });
135
- onChange(initialValue);
131
+ onBlur && onBlur(event);
132
+ return;
136
133
  }
137
- if (hasValueLabel) {
138
- _this.updateDebounced();
134
+ _this.onChangeDebounced.cancel();
135
+ var isCleared = _this.state.value === '';
136
+ var shouldCommit = _this.hasPendingChange || isCleared;
137
+ var committedValue = isCleared ? min : _this.state.value;
138
+ _this.hasPendingChange = false;
139
+ _this.setState({
140
+ changeInprogress: false,
141
+ value: hasValueLabel ? _this.props.value : committedValue
142
+ });
143
+ if (shouldCommit) {
144
+ onChange(committedValue);
139
145
  }
140
146
  onBlur && onBlur(event);
141
147
  });
142
148
  _defineProperty(_assertThisInitialized(_this), "onFocus", function (event) {
143
- var onFocus = _this.props.onFocus;
144
- _this.setState({
145
- changeInprogress: true
146
- });
149
+ var _this$props3 = _this.props,
150
+ onFocus = _this$props3.onFocus,
151
+ readOnly = _this$props3.readOnly;
152
+ if (!readOnly) {
153
+ _this.setState({
154
+ changeInprogress: true
155
+ });
156
+ }
147
157
  onFocus && onFocus(event);
148
158
  });
149
159
  return _this;
@@ -151,35 +161,46 @@ var AmountInput = /*#__PURE__*/function (_React$Component) {
151
161
  _createClass(AmountInput, [{
152
162
  key: "componentDidMount",
153
163
  value: function componentDidMount() {
154
- var value = this.props.value;
155
164
  this.setState({
156
- value: value
165
+ value: this.props.value
157
166
  });
158
167
  }
159
168
  }, {
160
169
  key: "componentDidUpdate",
161
170
  value: function componentDidUpdate(prevProps) {
162
- var value = this.props.value;
163
- if (prevProps.value !== value && !this.state.changeInprogress) {
164
- this.updateDebounced();
171
+ var _this$props4 = this.props,
172
+ value = _this$props4.value,
173
+ readOnly = _this$props4.readOnly;
174
+ if (prevProps.value !== value && (readOnly || !this.state.changeInprogress)) {
175
+ this.setState({
176
+ value: value
177
+ });
178
+ }
179
+ }
180
+ }, {
181
+ key: "componentWillUnmount",
182
+ value: function componentWillUnmount() {
183
+ this.onChangeDebounced.cancel();
184
+ if (this.hasPendingChange) {
185
+ this.props.onChange(this.state.value === '' ? this.props.min : this.state.value);
165
186
  }
166
187
  }
167
188
  }, {
168
189
  key: "render",
169
190
  value: function render() {
170
- var _this$props3 = this.props,
171
- classes = _this$props3.classes,
172
- amountLabel = _this$props3.amountLabel,
173
- min = _this$props3.min,
174
- max = _this$props3.max,
175
- autoFocus = _this$props3.autoFocus,
176
- error = _this$props3.error,
177
- disabled = _this$props3.disabled,
178
- onClick = _this$props3.onClick,
179
- readOnly = _this$props3.readOnly,
180
- rootProps = _this$props3.rootProps,
181
- inputProps = _this$props3.inputProps,
182
- type = _this$props3.type;
191
+ var _this$props5 = this.props,
192
+ classes = _this$props5.classes,
193
+ amountLabel = _this$props5.amountLabel,
194
+ min = _this$props5.min,
195
+ max = _this$props5.max,
196
+ autoFocus = _this$props5.autoFocus,
197
+ error = _this$props5.error,
198
+ disabled = _this$props5.disabled,
199
+ onClick = _this$props5.onClick,
200
+ readOnly = _this$props5.readOnly,
201
+ rootProps = _this$props5.rootProps,
202
+ inputProps = _this$props5.inputProps,
203
+ type = _this$props5.type;
183
204
  return /*#__PURE__*/_react["default"].createElement(_TextField["default"], {
184
205
  value: this.state.value,
185
206
  onChange: this.onChange,
@@ -351,8 +351,8 @@ var ProductVariant = /*#__PURE__*/function (_React$Component) {
351
351
  }
352
352
  }, (0, _i18n.t)('productVariant.confirmSelection'))), (0, _get["default"])(variant, 'sizes.length', 0) === 0 && /*#__PURE__*/_react["default"].createElement(_AmountInput["default"], {
353
353
  value: variant.amount + ' ' + (0, _i18n.t)('amountSelection.amount'),
354
- hasValueLabel: true,
355
354
  amountLabel: (0, _i18n.t)('productVariant.amountLabel'),
355
+ hasValueLabel: true,
356
356
  onChange: _this2.handleChange(variant),
357
357
  onClick: _this2.handleBulkNameForm(variant),
358
358
  error: hasError(variant.identifier, error),
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@configuratorware/configurator-frontendgui",
3
- "version": "1.57.12",
3
+ "version": "1.57.14",
4
4
  "license": "UNLICENSED",
5
5
  "private": false,
6
6
  "main": "./index.js",
7
7
  "dependencies": {
8
8
  "@babel/polyfill": "^7.12.1",
9
- "@configuratorware/scripts": "1.57.12",
9
+ "@configuratorware/scripts": "1.57.14",
10
10
  "@material-ui/core": "^4.12.4",
11
11
  "@material-ui/icons": "^4.11.3",
12
12
  "@material-ui/lab": "^4.0.0-alpha.61",
@@ -36,8 +36,8 @@
36
36
  "react-router-dom": "^5.3.4",
37
37
  "react-swipeable": "^5.5.1",
38
38
  "react-zoom-pan-pinch": "^2.1.3",
39
- "redhotmagma-graphics-editor": "1.57.12",
40
- "redhotmagma-visualization": "1.57.12",
39
+ "redhotmagma-graphics-editor": "1.57.14",
40
+ "redhotmagma-visualization": "1.57.14",
41
41
  "redux": "^4.1.0",
42
42
  "redux-logger": "^3.0.6",
43
43
  "redux-persist": "^5.10.0",
@@ -345,6 +345,10 @@ const DesignerSelectionToolbox = props => {
345
345
  canvas.selectedObject.isBulkName = isBulkName;
346
346
  canvas.selectedObject.content = getTextContent({
347
347
  isBulkName,
348
+ styleColors: selectedObject.style.colors,
349
+ fontItem: currentFontItem,
350
+ isBold,
351
+ isItalic,
348
352
  });
349
353
  }}
350
354
  alignVerticalCenterIcon={alignVerticalCenterIcon}
@@ -59,12 +59,16 @@ const mapDispatchToProps = dispatch => ({
59
59
  },
60
60
  openImageEditDialog: (identifier, canvas, placeholderImageUpdate = false) =>
61
61
  Services.designer.openImageEditDialog(identifier, canvas, { placeholderImageUpdate }),
62
- getTextContent: ({ isBulkName }) =>
62
+ getTextContent: ({ isBulkName, styleColors, fontItem, isBold, isItalic }) =>
63
63
  Services.designer.createColorizedTextContent(
64
64
  t(isBulkName ? 'textControlbox.bulknames' : 'addVisualElement.initialText'),
65
65
  1,
66
66
  {
67
67
  withPlaceholder: !isBulkName,
68
+ styleColors,
69
+ fontItem,
70
+ isBold,
71
+ isItalic,
68
72
  }
69
73
  ),
70
74
  addCustomFont: customFont => {