kitchen-simulator 2.0.15 → 2.0.17

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.
@@ -26,8 +26,8 @@ var compareSVGRect = function compareSVGRect(value) {
26
26
  };
27
27
  var updateViwer2D = function updateViwer2D(value, viewer2DActions) {
28
28
  var _zoomValue = parseInt((value.a - 0.5) / _constants.ZOOM_VARIABLE);
29
- if (_zoomValue > 404) return;
30
- if (_zoomValue < 35 || Number.isNaN(_zoomValue)) return;
29
+ if (_zoomValue > _constants.MAX_ZOOM_IN_SCALE) return;
30
+ if (_zoomValue < 0 || Number.isNaN(_zoomValue)) return;
31
31
 
32
32
  // modify e, f to fit to SVG
33
33
  while (!(value.e <= 10)) {
@@ -949,21 +949,57 @@ function getElement(objProps, state) {
949
949
  }
950
950
  return curObject;
951
951
  }
952
- function handleExternalEvent(_x1) {
952
+ function loadMoldingSvg(_x1) {
953
+ return _loadMoldingSvg.apply(this, arguments);
954
+ }
955
+ function _loadMoldingSvg() {
956
+ _loadMoldingSvg = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee6(molding) {
957
+ return _regenerator["default"].wrap(function (_context6) {
958
+ while (1) switch (_context6.prev = _context6.next) {
959
+ case 0:
960
+ return _context6.abrupt("return", new Promise(function (resolve, reject) {
961
+ var url = molding === null || molding === void 0 ? void 0 : molding.shape_svg;
962
+ if (!url) {
963
+ // Skip if no SVG URL available
964
+ return resolve();
965
+ }
966
+ var loader = new _SVGLoader.SVGLoader();
967
+ loader.load(url, function (data) {
968
+ var _data$xml$viewBox$ani, _data$xml, _data$xml$viewBox$ani2, _data$xml2;
969
+ molding.data = {
970
+ paths: data.paths,
971
+ svg_width: (_data$xml$viewBox$ani = (_data$xml = data.xml) === null || _data$xml === void 0 || (_data$xml = _data$xml.viewBox) === null || _data$xml === void 0 || (_data$xml = _data$xml.animVal) === null || _data$xml === void 0 ? void 0 : _data$xml.width) !== null && _data$xml$viewBox$ani !== void 0 ? _data$xml$viewBox$ani : 0,
972
+ svg_height: (_data$xml$viewBox$ani2 = (_data$xml2 = data.xml) === null || _data$xml2 === void 0 || (_data$xml2 = _data$xml2.viewBox) === null || _data$xml2 === void 0 || (_data$xml2 = _data$xml2.animVal) === null || _data$xml2 === void 0 ? void 0 : _data$xml2.height) !== null && _data$xml$viewBox$ani2 !== void 0 ? _data$xml$viewBox$ani2 : 0
973
+ };
974
+ resolve();
975
+ }, null, function (error) {
976
+ console.error(error);
977
+ reject(error);
978
+ });
979
+ }));
980
+ case 1:
981
+ case "end":
982
+ return _context6.stop();
983
+ }
984
+ }, _callee6);
985
+ }));
986
+ return _loadMoldingSvg.apply(this, arguments);
987
+ }
988
+ function handleExternalEvent(_x10) {
953
989
  return _handleExternalEvent.apply(this, arguments);
954
990
  }
955
991
  function _handleExternalEvent() {
956
- _handleExternalEvent = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee7(props) {
992
+ _handleExternalEvent = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee8(props) {
957
993
  var _evt$payload3, _evt$payload4;
958
- var evt, state, _evt$payload, cdsItems, itemKeys, _loop3, i, _props$onInternalEven, sLineCnt, element, _state$viewer2D, _evt$payload$initialP, mouseX, mouseY, v2d, vPosX, vPosY, layerID, _evt$payload5, moveType, moveValue, value, defaulTitle, _evt$payload6, doorStyle, itemCDS, isAll, _doorStyle, _value, _value2, layer, bb, w, h, viewer, _evt$payload7, moldingInfo, isGlobal, distElement, _distElement, _evt$payload8, option, _value3, layerId, _layer, _layer$getIn, selectedLines, selectedHoles, selectedItems, _i2, _i3, _i4, _props$onInternalEven2, _t5, _t6;
959
- return _regenerator["default"].wrap(function (_context8) {
960
- while (1) switch (_context8.prev = _context8.next) {
994
+ var evt, state, _evt$payload, cdsItems, itemKeys, _loop3, i, _props$onInternalEven, sLineCnt, element, _state$viewer2D, _evt$payload$initialP, mouseX, mouseY, v2d, vPosX, vPosY, layerID, _evt$payload5, moveType, moveValue, value, defaulTitle, _evt$payload6, doorStyle, itemCDS, isAll, _doorStyle, _value, _value2, layer, bb, w, h, viewer, _evt$payload7, moldingInfo, isGlobal, distElement, _distElement, _evt$payload8, option, _value3, layerId, _layer, _layer$getIn, selectedLines, selectedHoles, selectedItems, _i2, _i3, _i4, _evt$payload9, _evt$payload0, _evt$payload1, _evt$payload10, _layerID, _layer2, orginalItemInfo, originalItem, originalItemPos, replaceItem, _props$onInternalEven2, _t5, _t6;
995
+ return _regenerator["default"].wrap(function (_context9) {
996
+ while (1) switch (_context9.prev = _context9.next) {
961
997
  case 0:
962
998
  // console.log('***external event****', props);
963
999
  evt = props.externalEvent;
964
1000
  state = props.state.get('KitchenConfigurator');
965
1001
  _t5 = evt === null || evt === void 0 ? void 0 : evt.type;
966
- _context8.next = _t5 === _constants.EXTERNAL_EVENT_LOAD_PROJECT ? 1 : _t5 === _constants.EXTERNAL_EVENT_TOGGLE_TO_3D ? 5 : _t5 === _constants.EXTERNAL_EVENT_TOGGLE_TO_2D ? 6 : _t5 === _constants.EXTERNAL_EVENT_TOGGLE_TO_ELEVATION ? 7 : _t5 === _constants.EXTERNAL_EVENT_ADD_WALL ? 8 : _t5 === _constants.EXTERNAL_EVENT_ADD_ITEM ? 9 : _t5 === _constants.EXTERNAL_EVENT_ADD_HOLE ? 12 : _t5 === _constants.EXTERNAL_EVENT_MOVE_PAN ? 13 : _t5 === _constants.EXTERNAL_EVENT_NEW_PROJECT ? 19 : _t5 === _constants.EXTERNAL_EVENT_CHANGE_DOORSTYLE ? 20 : _t5 === _constants.EXTERNAL_EVENT_SET_INITIAL_DATA ? 21 : _t5 === _constants.EXTERNAL_EVENT_ADD_ROOM_SHAPE ? 22 : _t5 === _constants.EXTERNAL_EVENT_ZOOM_IN ? 23 : _t5 === _constants.EXTERNAL_EVENT_ZOOM_OUT ? 24 : _t5 === _constants.EXTERNAL_EVENT_CENTERING_2D ? 25 : _t5 === _constants.EXTERNAL_EVENT_UNDO ? 26 : _t5 === _constants.EXTERNAL_EVENT_REDO ? 27 : _t5 === _constants.EXTERNAL_EVENT_SET_MOLDING ? 28 : _t5 === _constants.EXTERNAL_EVENT_DUPLICATE_ELEMENT ? 29 : _t5 === _constants.EXTERNAL_EVENT_DELETE_ELEMENT ? 30 : _t5 === _constants.EXTERNAL_EVENT_PROJECT_SETTING ? 31 : _t5 === _constants.EXTERNAL_EVENT_UPDATE_ATTRIBUTE ? 32 : _t5 === _constants.EXTERNAL_EVENT_UPDATE_PROPERTY ? 32 : _t5 === _constants.EXTERNAL_EVENT_SYNC_SCENE ? 33 : 34;
1002
+ _context9.next = _t5 === _constants.EXTERNAL_EVENT_LOAD_PROJECT ? 1 : _t5 === _constants.EXTERNAL_EVENT_TOGGLE_TO_3D ? 5 : _t5 === _constants.EXTERNAL_EVENT_TOGGLE_TO_2D ? 6 : _t5 === _constants.EXTERNAL_EVENT_TOGGLE_TO_ELEVATION ? 7 : _t5 === _constants.EXTERNAL_EVENT_ADD_WALL ? 8 : _t5 === _constants.EXTERNAL_EVENT_ADD_ITEM ? 9 : _t5 === _constants.EXTERNAL_EVENT_ADD_HOLE ? 12 : _t5 === _constants.EXTERNAL_EVENT_MOVE_PAN ? 13 : _t5 === _constants.EXTERNAL_EVENT_NEW_PROJECT ? 19 : _t5 === _constants.EXTERNAL_EVENT_CHANGE_DOORSTYLE ? 20 : _t5 === _constants.EXTERNAL_EVENT_SET_INITIAL_DATA ? 21 : _t5 === _constants.EXTERNAL_EVENT_ADD_ROOM_SHAPE ? 22 : _t5 === _constants.EXTERNAL_EVENT_ZOOM_IN ? 23 : _t5 === _constants.EXTERNAL_EVENT_ZOOM_OUT ? 24 : _t5 === _constants.EXTERNAL_EVENT_CENTERING_2D ? 25 : _t5 === _constants.EXTERNAL_EVENT_UNDO ? 26 : _t5 === _constants.EXTERNAL_EVENT_REDO ? 27 : _t5 === _constants.EXTERNAL_EVENT_SET_MOLDING ? 28 : _t5 === _constants.EXTERNAL_EVENT_DUPLICATE_ELEMENT ? 30 : _t5 === _constants.EXTERNAL_EVENT_DELETE_ELEMENT ? 31 : _t5 === _constants.EXTERNAL_EVENT_PROJECT_SETTING ? 32 : _t5 === _constants.EXTERNAL_EVENT_UPDATE_ATTRIBUTE ? 33 : _t5 === _constants.EXTERNAL_EVENT_UPDATE_PROPERTY ? 33 : _t5 === _constants.EXTERNAL_EVENT_REPLACE_CABINET ? 34 : _t5 === _constants.EXTERNAL_EVENT_SYNC_SCENE ? 36 : 37;
967
1003
  break;
968
1004
  case 1:
969
1005
  // prepare item data request
@@ -972,8 +1008,8 @@ function _handleExternalEvent() {
972
1008
  _loop3 = /*#__PURE__*/_regenerator["default"].mark(function _loop3() {
973
1009
  var _evt$payload2, _it$doorStyle2;
974
1010
  var it;
975
- return _regenerator["default"].wrap(function (_context7) {
976
- while (1) switch (_context7.prev = _context7.next) {
1011
+ return _regenerator["default"].wrap(function (_context8) {
1012
+ while (1) switch (_context8.prev = _context8.next) {
977
1013
  case 0:
978
1014
  it = evt === null || evt === void 0 || (_evt$payload2 = evt.payload) === null || _evt$payload2 === void 0 || (_evt$payload2 = _evt$payload2.layers['layer-1']) === null || _evt$payload2 === void 0 ? void 0 : _evt$payload2.items[itemKeys[i]];
979
1015
  if (!cdsItems.some(function (v) {
@@ -985,20 +1021,20 @@ function _handleExternalEvent() {
985
1021
  });
986
1022
  case 1:
987
1023
  case "end":
988
- return _context7.stop();
1024
+ return _context8.stop();
989
1025
  }
990
1026
  }, _loop3);
991
1027
  });
992
1028
  i = 0;
993
1029
  case 2:
994
1030
  if (!(i < itemKeys.length)) {
995
- _context8.next = 4;
1031
+ _context9.next = 4;
996
1032
  break;
997
1033
  }
998
- return _context8.delegateYield(_loop3(), "t0", 3);
1034
+ return _context9.delegateYield(_loop3(), "t0", 3);
999
1035
  case 3:
1000
1036
  i++;
1001
- _context8.next = 2;
1037
+ _context9.next = 2;
1002
1038
  break;
1003
1039
  case 4:
1004
1040
  // request item catalog data to host app
@@ -1009,60 +1045,60 @@ function _handleExternalEvent() {
1009
1045
  cdsItems: cdsItems
1010
1046
  }
1011
1047
  }, /*#__PURE__*/function () {
1012
- var _ref2 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee6(result) {
1048
+ var _ref2 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee7(result) {
1013
1049
  var _i, _result$elements;
1014
- return _regenerator["default"].wrap(function (_context6) {
1015
- while (1) switch (_context6.prev = _context6.next) {
1050
+ return _regenerator["default"].wrap(function (_context7) {
1051
+ while (1) switch (_context7.prev = _context7.next) {
1016
1052
  case 0:
1017
1053
  _i = 0;
1018
1054
  case 1:
1019
1055
  if (!(_i < (result === null || result === void 0 || (_result$elements = result.elements) === null || _result$elements === void 0 ? void 0 : _result$elements.length))) {
1020
- _context6.next = 3;
1056
+ _context7.next = 3;
1021
1057
  break;
1022
1058
  }
1023
- _context6.next = 2;
1059
+ _context7.next = 2;
1024
1060
  return addItemToCatalog(result.elements[_i], state, props.catalog, props.projectActions);
1025
1061
  case 2:
1026
1062
  _i++;
1027
- _context6.next = 1;
1063
+ _context7.next = 1;
1028
1064
  break;
1029
1065
  case 3:
1030
1066
  props.projectActions.loadProject(evt.payload);
1031
1067
  case 4:
1032
1068
  case "end":
1033
- return _context6.stop();
1069
+ return _context7.stop();
1034
1070
  }
1035
- }, _callee6);
1071
+ }, _callee7);
1036
1072
  }));
1037
- return function (_x10) {
1073
+ return function (_x11) {
1038
1074
  return _ref2.apply(this, arguments);
1039
1075
  };
1040
1076
  }());
1041
1077
  }
1042
- return _context8.abrupt("continue", 34);
1078
+ return _context9.abrupt("continue", 37);
1043
1079
  case 5:
1044
1080
  props.projectActions.setMode(_constants.MODE_IDLE_3D);
1045
- return _context8.abrupt("continue", 34);
1081
+ return _context9.abrupt("continue", 37);
1046
1082
  case 6:
1047
1083
  props.projectActions.setMode(_constants.MODE_IDLE);
1048
- return _context8.abrupt("continue", 34);
1084
+ return _context9.abrupt("continue", 37);
1049
1085
  case 7:
1050
1086
  sLineCnt = state.getIn(['scene', 'layers', 'layer-1', 'selected', 'lines']).size;
1051
1087
  if (sLineCnt > 0) props.projectActions.setMode(_constants.MODE_ELEVATION_VIEW);
1052
- return _context8.abrupt("continue", 34);
1088
+ return _context9.abrupt("continue", 37);
1053
1089
  case 8:
1054
1090
  if (state.mode === _constants.MODE_IDLE || state.mode === _constants.MODE_2D_PAN) props.linesActions.selectToolDrawingLine('wall');else {
1055
1091
  props.projectActions.setMode(_constants.MODE_IDLE);
1056
1092
  props.linesActions.selectToolDrawingLine('wall');
1057
1093
  }
1058
- return _context8.abrupt("continue", 34);
1094
+ return _context9.abrupt("continue", 37);
1059
1095
  case 9:
1060
1096
  if ((0, _helper.isEmpty)(evt === null || evt === void 0 ? void 0 : evt.payload)) {
1061
- _context8.next = 11;
1097
+ _context9.next = 11;
1062
1098
  break;
1063
1099
  }
1064
1100
  element = evt.payload;
1065
- _context8.next = 10;
1101
+ _context9.next = 10;
1066
1102
  return addItemToCatalog(element, state, props.catalog, props.projectActions);
1067
1103
  case 10:
1068
1104
  // start drawing item
@@ -1086,47 +1122,47 @@ function _handleExternalEvent() {
1086
1122
  props.projectActions.pushLastSelectedCatalogElementToHistory(element);
1087
1123
  props.projectActions.setIsCabinetDrawing(true);
1088
1124
  case 11:
1089
- return _context8.abrupt("continue", 34);
1125
+ return _context9.abrupt("continue", 37);
1090
1126
  case 12:
1091
1127
  _constants.ARRAY_3D_MODES.includes(state.mode) ? props.holesActions.selectToolDrawingHole3D(evt === null || evt === void 0 || (_evt$payload3 = evt.payload) === null || _evt$payload3 === void 0 ? void 0 : _evt$payload3.holeName) : props.holesActions.selectToolDrawingHole(evt === null || evt === void 0 || (_evt$payload4 = evt.payload) === null || _evt$payload4 === void 0 ? void 0 : _evt$payload4.holeName);
1092
- return _context8.abrupt("continue", 34);
1128
+ return _context9.abrupt("continue", 37);
1093
1129
  case 13:
1094
1130
  _evt$payload5 = evt.payload, moveType = _evt$payload5.moveType, moveValue = _evt$payload5.moveValue;
1095
1131
  value = state.getIn(['viewer2D']).toJS();
1096
1132
  _t6 = moveType;
1097
- _context8.next = _t6 === _constants.TOP ? 14 : _t6 === _constants.BOTTOM ? 15 : _t6 === _constants.RIGHT ? 16 : _t6 === _constants.LEFT ? 17 : 18;
1133
+ _context9.next = _t6 === _constants.TOP ? 14 : _t6 === _constants.BOTTOM ? 15 : _t6 === _constants.RIGHT ? 16 : _t6 === _constants.LEFT ? 17 : 18;
1098
1134
  break;
1099
1135
  case 14:
1100
1136
  value.f -= moveValue;
1101
- return _context8.abrupt("continue", 18);
1137
+ return _context9.abrupt("continue", 18);
1102
1138
  case 15:
1103
1139
  value.f += moveValue;
1104
- return _context8.abrupt("continue", 18);
1140
+ return _context9.abrupt("continue", 18);
1105
1141
  case 16:
1106
1142
  value.e += moveValue;
1107
- return _context8.abrupt("continue", 18);
1143
+ return _context9.abrupt("continue", 18);
1108
1144
  case 17:
1109
1145
  value.e -= moveValue;
1110
- return _context8.abrupt("continue", 18);
1146
+ return _context9.abrupt("continue", 18);
1111
1147
  case 18:
1112
1148
  updateViwer2D(value, props.viewer2DActions);
1113
- return _context8.abrupt("continue", 34);
1149
+ return _context9.abrupt("continue", 37);
1114
1150
  case 19:
1115
1151
  defaulTitle = 'Untitle';
1116
1152
  props.projectActions.newProject();
1117
1153
  props.projectActions.rename(defaulTitle);
1118
- return _context8.abrupt("continue", 34);
1154
+ return _context9.abrupt("continue", 37);
1119
1155
  case 20:
1120
1156
  _evt$payload6 = evt.payload, doorStyle = _evt$payload6.doorStyle, itemCDS = _evt$payload6.itemCDS, isAll = _evt$payload6.isAll;
1121
1157
  props.itemsActions.setDoorStyle(doorStyle, itemCDS, isAll);
1122
- return _context8.abrupt("continue", 34);
1158
+ return _context9.abrupt("continue", 37);
1123
1159
  case 21:
1124
1160
  _doorStyle = evt.payload.doorStyle;
1125
1161
  props.itemsActions.setInitialDoorStyle(_doorStyle.doorStyle);
1126
- return _context8.abrupt("continue", 34);
1162
+ return _context9.abrupt("continue", 37);
1127
1163
  case 22:
1128
1164
  props.projectActions.loadProject(evt.payload);
1129
- return _context8.abrupt("continue", 34);
1165
+ return _context9.abrupt("continue", 37);
1130
1166
  case 23:
1131
1167
  _value = state.getIn(['viewer2D']).toJS();
1132
1168
  _value.a += 0.1;
@@ -1134,7 +1170,7 @@ function _handleExternalEvent() {
1134
1170
  _value.e -= _value.SVGWidth * 0.1 / 2;
1135
1171
  _value.f -= _value.SVGHeight * 0.1 / 2;
1136
1172
  updateViwer2D(_value, props.viewer2DActions);
1137
- return _context8.abrupt("continue", 34);
1173
+ return _context9.abrupt("continue", 37);
1138
1174
  case 24:
1139
1175
  _value2 = state.getIn(['viewer2D']).toJS();
1140
1176
  _value2.a -= 0.1;
@@ -1142,7 +1178,7 @@ function _handleExternalEvent() {
1142
1178
  _value2.e += _value2.SVGWidth * 0.1 / 2;
1143
1179
  _value2.f += _value2.SVGHeight * 0.1 / 2;
1144
1180
  updateViwer2D(_value2, props.viewer2DActions);
1145
- return _context8.abrupt("continue", 34);
1181
+ return _context9.abrupt("continue", 37);
1146
1182
  case 25:
1147
1183
  // calculate the bounding box of all elements in plan
1148
1184
  layer = state.scene.getIn(['layers', state.scene.selectedLayer]);
@@ -1163,32 +1199,42 @@ function _handleExternalEvent() {
1163
1199
  h = bb.maxY - bb.minY; // calc scale and offset to fit view
1164
1200
  viewer = state.getIn(['viewer2D']).toJS();
1165
1201
  if (w != 0 && Math.abs(w) != Infinity && h != 0 && Math.abs(h) != Infinity) {
1166
- viewer.a = viewer.viewerHeight < h ? viewer.viewerHeight / h : viewer.viewerHeight / h * 3 / 5 / _constants.ZOOM_VARIABLE > 400 ? viewer.viewerHeight / h * 400 / (viewer.viewerHeight / h / _constants.ZOOM_VARIABLE) : viewer.viewerHeight / h * 3 / 5;
1202
+ // elements are exist && bounding box size > 0
1203
+ viewer.a = viewer.viewerHeight < h ? viewer.viewerHeight / h : viewer.viewerHeight / h * 3 / 5 / _constants.ZOOM_VARIABLE > _constants.MAX_ZOOM_IN_SCALE ? viewer.viewerHeight / h * _constants.MAX_ZOOM_IN_SCALE / (viewer.viewerHeight / h / _constants.ZOOM_VARIABLE) : viewer.viewerHeight / h * 3 / 5;
1167
1204
  viewer.d = viewer.a;
1168
1205
  viewer.e = (viewer.viewerWidth - (bb.maxX + bb.minX) * viewer.a) / 2;
1169
1206
  viewer.f = (viewer.viewerHeight - (bb.maxY + bb.minY) * viewer.a) / 2;
1170
- updateViwer2D(viewer, props.viewer2DActions);
1207
+ } else {
1208
+ // there is no any element && bounding box size == 0
1209
+ viewer.e = viewer.viewerWidth / 2 - viewer.SVGWidth / 2;
1210
+ viewer.f = viewer.viewerHeight / 2 - viewer.SVGHeight / 2;
1211
+ viewer.a = 0.99;
1212
+ viewer.d = 0.99;
1171
1213
  }
1172
- return _context8.abrupt("continue", 34);
1214
+ updateViwer2D(viewer, props.viewer2DActions);
1215
+ return _context9.abrupt("continue", 37);
1173
1216
  case 26:
1174
1217
  props.projectActions.undo();
1175
- return _context8.abrupt("continue", 34);
1218
+ return _context9.abrupt("continue", 37);
1176
1219
  case 27:
1177
1220
  props.projectActions.redo();
1178
- return _context8.abrupt("continue", 34);
1221
+ return _context9.abrupt("continue", 37);
1179
1222
  case 28:
1180
1223
  _evt$payload7 = evt.payload, moldingInfo = _evt$payload7.moldingInfo, isGlobal = _evt$payload7.isGlobal;
1181
- props.itemsActions.setMolding(moldingInfo, isGlobal);
1182
- return _context8.abrupt("continue", 34);
1224
+ _context9.next = 29;
1225
+ return loadMoldingSvg(moldingInfo);
1183
1226
  case 29:
1227
+ props.itemsActions.setMolding(moldingInfo, isGlobal);
1228
+ return _context9.abrupt("continue", 37);
1229
+ case 30:
1184
1230
  distElement = getElement(evt.payload, state);
1185
1231
  if (distElement) props.itemsActions.duplicateSelected(distElement);
1186
- return _context8.abrupt("continue", 34);
1187
- case 30:
1232
+ return _context9.abrupt("continue", 37);
1233
+ case 31:
1188
1234
  _distElement = getElement(evt.payload, state);
1189
1235
  if (_distElement) props.projectActions.remove(_distElement);
1190
- return _context8.abrupt("continue", 34);
1191
- case 31:
1236
+ return _context9.abrupt("continue", 37);
1237
+ case 32:
1192
1238
  _evt$payload8 = evt.payload, option = _evt$payload8.option, _value3 = _evt$payload8.value;
1193
1239
  if (option === _constants.PROJECT_SETTING_OPTION.UPDATE_CEIL_HEIGHT) {
1194
1240
  props.viewer2DActions.updateCeilHeight(_value3);
@@ -1202,16 +1248,39 @@ function _handleExternalEvent() {
1202
1248
  } else if (option === _constants.PROJECT_SETTING_OPTION.CHANGE_WINDOW_DOOR_MEASURE) {
1203
1249
  props.viewer2DActions.changeWindowDoorMeasure(_value3);
1204
1250
  }
1205
- return _context8.abrupt("continue", 34);
1206
- case 32:
1251
+ return _context9.abrupt("continue", 37);
1252
+ case 33:
1207
1253
  layerId = state.getIn(['scene', 'selectedLayer']);
1208
1254
  _layer = state.getIn(['scene', 'layers', layerId]);
1209
1255
  _layer$getIn = _layer.getIn(['selected']), selectedLines = _layer$getIn.lines, selectedHoles = _layer$getIn.holes, selectedItems = _layer$getIn.items;
1210
1256
  for (_i2 = 0; _i2 < selectedLines.size; _i2++) (evt === null || evt === void 0 ? void 0 : evt.type) === _constants.EXTERNAL_EVENT_UPDATE_ATTRIBUTE ? updateAttributeOfSelectedElement(_layer.getIn(['lines', selectedLines.get(_i2)]), evt.payload, state, _layer, props.projectActions, evt.callback) : updatePropertyOfSelectedElement(_layer.getIn(['lines', selectedLines.get(_i2)]), evt.payload, props.catalog, props.projectActions, evt.callback);
1211
1257
  for (_i3 = 0; _i3 < selectedHoles.size; _i3++) (evt === null || evt === void 0 ? void 0 : evt.type) === _constants.EXTERNAL_EVENT_UPDATE_ATTRIBUTE ? updateAttributeOfSelectedElement(_layer.getIn(['holes', selectedHoles.get(_i3)]), evt.payload, state, _layer, props.projectActions, evt.callback) : updatePropertyOfSelectedElement(_layer.getIn(['holes', selectedHoles.get(_i3)]), evt.payload, props.catalog, props.projectActions, evt.callback);
1212
1258
  for (_i4 = 0; _i4 < selectedItems.size; _i4++) (evt === null || evt === void 0 ? void 0 : evt.type) === _constants.EXTERNAL_EVENT_UPDATE_ATTRIBUTE ? updateAttributeOfSelectedElement(_layer.getIn(['items', selectedItems.get(_i4)]), evt.payload, state, _layer, props.projectActions, evt.callback) : updatePropertyOfSelectedElement(_layer.getIn(['items', selectedItems.get(_i4)]), evt.payload, props.catalog, props.projectActions, evt.callback);
1213
- return _context8.abrupt("continue", 34);
1214
- case 33:
1259
+ return _context9.abrupt("continue", 37);
1260
+ case 34:
1261
+ _layerID = state.scene.selectedLayer;
1262
+ _layer2 = state.scene.getIn(['layers', _layerID]).toJS();
1263
+ orginalItemInfo = evt === null || evt === void 0 || (_evt$payload9 = evt.payload) === null || _evt$payload9 === void 0 ? void 0 : _evt$payload9.orginalItemInfo;
1264
+ originalItem = _layer2 === null || _layer2 === void 0 ? void 0 : _layer2.items[orginalItemInfo.id];
1265
+ _context9.next = 35;
1266
+ return addItemToCatalog(evt.payload.replaceItemInfo, state, props.catalog, props.projectActions);
1267
+ case 35:
1268
+ originalItemPos = {
1269
+ rotation: originalItem.rotation,
1270
+ selectedItemId: originalItem.id,
1271
+ x: originalItem.x,
1272
+ y: originalItem.y
1273
+ };
1274
+ replaceItem = {
1275
+ name: evt === null || evt === void 0 || (_evt$payload0 = evt.payload) === null || _evt$payload0 === void 0 || (_evt$payload0 = _evt$payload0.replaceItemInfo) === null || _evt$payload0 === void 0 ? void 0 : _evt$payload0.name,
1276
+ info: {
1277
+ width: evt === null || evt === void 0 || (_evt$payload1 = evt.payload) === null || _evt$payload1 === void 0 || (_evt$payload1 = _evt$payload1.replaceItemInfo) === null || _evt$payload1 === void 0 || (_evt$payload1 = _evt$payload1.sizeinfo) === null || _evt$payload1 === void 0 ? void 0 : _evt$payload1.width,
1278
+ height: evt === null || evt === void 0 || (_evt$payload10 = evt.payload) === null || _evt$payload10 === void 0 || (_evt$payload10 = _evt$payload10.replaceItemInfo) === null || _evt$payload10 === void 0 || (_evt$payload10 = _evt$payload10.sizeinfo) === null || _evt$payload10 === void 0 ? void 0 : _evt$payload10.height
1279
+ }
1280
+ };
1281
+ props.itemsActions.replaceItem(originalItemPos, originalItem, replaceItem);
1282
+ return _context9.abrupt("continue", 37);
1283
+ case 36:
1215
1284
  // send scene object from 3DTool to HostApp using internalEvent
1216
1285
  (_props$onInternalEven2 = props.onInternalEvent) === null || _props$onInternalEven2 === void 0 || _props$onInternalEven2.call(props, {
1217
1286
  type: _constants.INTERNAL_EVENT_SYNC_SCENE,
@@ -1219,12 +1288,12 @@ function _handleExternalEvent() {
1219
1288
  scene: state.scene.toJS()
1220
1289
  }
1221
1290
  });
1222
- return _context8.abrupt("continue", 34);
1223
- case 34:
1291
+ return _context9.abrupt("continue", 37);
1292
+ case 37:
1224
1293
  case "end":
1225
- return _context8.stop();
1294
+ return _context9.stop();
1226
1295
  }
1227
- }, _callee7);
1296
+ }, _callee8);
1228
1297
  }));
1229
1298
  return _handleExternalEvent.apply(this, arguments);
1230
1299
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kitchen-simulator",
3
- "version": "2.0.15",
3
+ "version": "2.0.17",
4
4
  "description": "It is a kitchen simulator (self-contained micro-frontend).",
5
5
  "license": "MIT",
6
6
  "main": "lib/index.js",