kitchen-simulator 1.0.0-alin.4 → 1.0.0-alin.40

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.
@@ -4,11 +4,14 @@ import ContainerDimensions from 'react-container-dimensions';
4
4
  import mockProps from "./mocks/mockProps.json";
5
5
  import mockCategoryData from "./mocks/categoryData.json";
6
6
  import mockDataBundle from "./mocks/dataBundle.json";
7
- import cabinetPaylod from "./mocks/cabinetPayload.json";
7
+ import cabinetPaylod from "./mocks/cabinetPayload2.json";
8
+ import doorStylePaylod from "./mocks/doorStylePayload.json";
9
+ import oStylePaylod from "./mocks/oStylePayload.json";
10
+ import rectangleData from "./mocks/rectangleShape.json";
8
11
  import ReactDOM from 'react-dom';
9
12
  import LiteRenderer from "./LiteRenderer";
10
13
  import { Button } from 'antd';
11
- import { LEFT, RIGHT, TOP, BOTTOM, EXTERNAL_EVENT_ADD_ITEM, EXTERNAL_EVENT_ADD_WALL, EXTERNAL_EVENT_TOGGLE_TO_3D, EXTERNAL_EVENT_TOGGLE_TO_2D, EXTERNAL_EVENT_TOGGLE_TO_ELEVATION, EXTERNAL_EVENT_MOVE_PAN, EXTERNAL_EVENT_NEW_PROJECT } from "./constants";
14
+ import { LEFT, RIGHT, TOP, BOTTOM, EXTERNAL_EVENT_ADD_ITEM, EXTERNAL_EVENT_ADD_WALL, EXTERNAL_EVENT_TOGGLE_TO_3D, EXTERNAL_EVENT_TOGGLE_TO_2D, EXTERNAL_EVENT_TOGGLE_TO_ELEVATION, EXTERNAL_EVENT_MOVE_PAN, EXTERNAL_EVENT_NEW_PROJECT, EXTERNAL_EVENT_CHANGE_DOORSTYLE, EXTERNAL_EVENT_SET_INITIAL_DATA, EXTERNAL_EVENT_ADD_ROOM_SHAPE, EXTERNAL_EVENT_ZOOM_IN, EXTERNAL_EVENT_ZOOM_OUT } from "./constants";
12
15
 
13
16
  // --- renderer props ---
14
17
  var options = {
@@ -22,6 +25,18 @@ function WorkSpace(props) {
22
25
  externalEvent = _useState2[0],
23
26
  setExternalEvent = _useState2[1];
24
27
  var offset = 5;
28
+ useEffect(function () {
29
+ var evt = {
30
+ type: EXTERNAL_EVENT_SET_INITIAL_DATA,
31
+ payload: {
32
+ doorStyle: {
33
+ doorStyle: doorStylePaylod,
34
+ oStyle: oStylePaylod
35
+ }
36
+ }
37
+ };
38
+ setExternalEvent(evt);
39
+ }, []);
25
40
  return /*#__PURE__*/React.createElement("div", {
26
41
  className: "flex gap-4"
27
42
  }, /*#__PURE__*/React.createElement(Button, {
@@ -107,6 +122,28 @@ function WorkSpace(props) {
107
122
  }
108
123
  }, /*#__PURE__*/React.createElement("img", {
109
124
  src: "/assets/img/svg/bottombar/arrow-right.svg"
125
+ })), /*#__PURE__*/React.createElement(Button, {
126
+ actionType: "primary",
127
+ onClick: function onClick() {
128
+ var evt = {
129
+ type: EXTERNAL_EVENT_ZOOM_IN,
130
+ payload: {}
131
+ };
132
+ setExternalEvent(evt);
133
+ }
134
+ }, /*#__PURE__*/React.createElement("img", {
135
+ src: "/assets/img/svg/bottombar/arrow-minus.svg"
136
+ })), /*#__PURE__*/React.createElement(Button, {
137
+ actionType: "primary",
138
+ onClick: function onClick() {
139
+ var evt = {
140
+ type: EXTERNAL_EVENT_ZOOM_OUT,
141
+ payload: {}
142
+ };
143
+ setExternalEvent(evt);
144
+ }
145
+ }, /*#__PURE__*/React.createElement("img", {
146
+ src: "/assets/img/svg/bottombar/arrow-plus.svg"
110
147
  })), /*#__PURE__*/React.createElement(Button, {
111
148
  actionType: "primary",
112
149
  onClick: function onClick() {
@@ -134,9 +171,30 @@ function WorkSpace(props) {
134
171
  };
135
172
  setExternalEvent(evt);
136
173
  }
137
- }, "Add B12 Cabinet"), /*#__PURE__*/React.createElement(LiteRenderer, {
138
- width: 1200,
139
- height: 953,
174
+ }, "Add B12 Cabinet"), /*#__PURE__*/React.createElement(Button, {
175
+ actionType: "danger",
176
+ onClick: function onClick() {
177
+ var evt = {
178
+ type: EXTERNAL_EVENT_CHANGE_DOORSTYLE,
179
+ payload: {
180
+ doorStyle: doorStylePaylod,
181
+ isAll: true
182
+ }
183
+ };
184
+ setExternalEvent(evt);
185
+ }
186
+ }, "DoorStyle (Change into Midtown White Shaker)"), /*#__PURE__*/React.createElement(Button, {
187
+ actionType: "danger",
188
+ onClick: function onClick() {
189
+ var evt = {
190
+ type: EXTERNAL_EVENT_ADD_ROOM_SHAPE,
191
+ payload: rectangleData
192
+ };
193
+ setExternalEvent(evt);
194
+ }
195
+ }, "Add Room shape(rectangle)"), /*#__PURE__*/React.createElement(LiteRenderer, {
196
+ width: props.width,
197
+ height: props.height,
140
198
  projectElement: mockProps.projectElement,
141
199
  categoryData: mockCategoryData,
142
200
  dataBundle: mockDataBundle,
@@ -158,4 +216,11 @@ function WorkSpace(props) {
158
216
  }
159
217
  }));
160
218
  }
161
- ReactDOM.render(/*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(WorkSpace, null)), document.getElementById('app'));
219
+ ReactDOM.render(/*#__PURE__*/React.createElement(ContainerDimensions, null, function (_ref) {
220
+ var width = _ref.width,
221
+ height = _ref.height;
222
+ return /*#__PURE__*/React.createElement(WorkSpace, {
223
+ width: width,
224
+ height: height
225
+ });
226
+ }), document.getElementById('app'));
package/es/index.js CHANGED
@@ -7,19 +7,21 @@ import LiteRenderer from "./LiteRenderer";
7
7
  export function renderKitchenSimulator(container) {
8
8
  var props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
9
9
  var currentProps = props;
10
- var render = function render(newProps) {
11
- ReactDOM.render(/*#__PURE__*/React.createElement(LiteRenderer, newProps), container);
12
- };
13
- render(props);
10
+
11
+ // Initial render
12
+ var root = ReactDOM.render(/*#__PURE__*/React.createElement(LiteRenderer, props), container);
14
13
  return {
15
- updateExternalEvent: function updateExternalEvent(externalEvent) {
16
- currentProps = _objectSpread(_objectSpread({}, currentProps), {}, {
17
- externalEvent: externalEvent
18
- });
19
- render(currentProps);
20
- },
21
- unmount: function unmount() {
22
- ReactDOM.unmountComponentAtNode(container);
14
+ root: root,
15
+ updateExternalEvent: function updateExternalEvent(newExternalEvent) {
16
+ var prevEvent = currentProps.externalEvent;
17
+ var isSameEvent = prevEvent && newExternalEvent && prevEvent.type === newExternalEvent.type && JSON.stringify(prevEvent.payload) === JSON.stringify(newExternalEvent.payload);
18
+ if (!isSameEvent) {
19
+ currentProps = _objectSpread(_objectSpread({}, currentProps), {}, {
20
+ externalEvent: newExternalEvent
21
+ });
22
+ ReactDOM.render(/*#__PURE__*/React.createElement(LiteRenderer, currentProps), container);
23
+ }
23
24
  }
24
25
  };
25
- }
26
+ }
27
+ export default renderKitchenSimulator;
@@ -105,7 +105,7 @@ export default function (state, action) {
105
105
  case SELECT_TOOL_DRAWING_ITEM_3D:
106
106
  return Item.selectToolDrawingItem3D(state, action.sceneComponentType).updatedState;
107
107
  case SET_DOOR_STYLE:
108
- return Item.setDoorStyle(state, action.doorStyle, action.pathes, action.isAll).updatedState;
108
+ return Item.setDoorStyle(state, action.doorStyle, action.isAll).updatedState;
109
109
  case SET_HANDLE_MATERIAL:
110
110
  return Item.setHandleMaterial(state, action.material).updatedState;
111
111
  case SET_DOOR_HANDLE:
@@ -873,18 +873,18 @@ export function getAllItemSnap(allItemRects) {
873
873
  var snap4 = itemrectInfo(rect.rect[3].x + ox0, rect.rect[3].y + oy0, nrot, cur && cur.size, rect.layoutpos, rect.is_corner);
874
874
  var sizeinfo = otherItems[index].cat && otherItems[index].cat.info.sizeinfo;
875
875
  if (sizeinfo) {
876
- var leftBlindLength = sizeinfo.leftBlindLength,
877
- rightBlindLength = sizeinfo.rightBlindLength;
878
- if (leftBlindLength > 0) {
879
- var vx = leftBlindLength - ch;
876
+ var left_blind_length = sizeinfo.left_blind_length,
877
+ right_blind_length = sizeinfo.right_blind_length;
878
+ if (left_blind_length > 0) {
879
+ var vx = left_blind_length - ch;
880
880
  var vy = cw;
881
881
  var dx = vx * cos + vy * sin;
882
882
  var dy = vx * sin - vy * cos;
883
883
  var snap6 = itemrectInfo(rect.rect[0].x + dx, rect.rect[0].y + dy, rect.rotRad + Math.PI / 2, cur && cur.size, rect.layoutpos, rect.is_corner);
884
884
  allItemSnap.push(snap6);
885
885
  }
886
- if (rightBlindLength > 0) {
887
- var _vx = ch - rightBlindLength;
886
+ if (right_blind_length > 0) {
887
+ var _vx = ch - right_blind_length;
888
888
  var _vy = cw;
889
889
  var _dx = _vx * cos + _vy * sin;
890
890
  var _dy = _vx * sin - _vy * cos;
@@ -4,12 +4,10 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
4
4
  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; }
5
5
  import _regeneratorRuntime from "@babel/runtime/regenerator";
6
6
  import { fromJS, List, Map, Record } from 'immutable';
7
- import { EXTERNAL_EVENT_ADD_WALL, EXTERNAL_EVENT_TOGGLE_TO_3D, EXTERNAL_EVENT_TOGGLE_TO_2D, EXTERNAL_EVENT_TOGGLE_TO_ELEVATION, EXTERNAL_EVENT_MOVE_PAN, MODE_IDLE, MODE_2D_PAN, EXTERNAL_EVENT_ADD_ITEM, ARRAY_3D_MODES, MODE_IDLE_3D, MODE_ELEVATION_VIEW, TOP, BOTTOM, LEFT, RIGHT, EXTERNAL_EVENT_NEW_PROJECT } from "../constants";
7
+ import { EXTERNAL_EVENT_ADD_WALL, EXTERNAL_EVENT_TOGGLE_TO_3D, EXTERNAL_EVENT_TOGGLE_TO_2D, EXTERNAL_EVENT_TOGGLE_TO_ELEVATION, EXTERNAL_EVENT_MOVE_PAN, MODE_IDLE, MODE_2D_PAN, EXTERNAL_EVENT_ADD_ITEM, ARRAY_3D_MODES, MODE_IDLE_3D, MODE_ELEVATION_VIEW, TOP, BOTTOM, LEFT, RIGHT, EXTERNAL_EVENT_NEW_PROJECT, EXTERNAL_EVENT_CHANGE_DOORSTYLE, EXTERNAL_EVENT_SET_INITIAL_DATA, EXTERNAL_EVENT_ADD_ROOM_SHAPE, EXTERNAL_EVENT_ZOOM_IN, EXTERNAL_EVENT_ZOOM_OUT, ZOOM_VARIABLE } from "../constants";
8
8
  import { isEmpty } from "./helper";
9
9
  import exporter from "../catalog/utils/exporter";
10
10
  import { render2DItem, render3DItem } from "../catalog/utils/item-loader";
11
- import Catalog from "../catalog/catalog";
12
- import { CatalogElement, safeLoadMapList } from "../models";
13
11
  var loadSVGsByItem = /*#__PURE__*/function () {
14
12
  var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(item) {
15
13
  var _parsed$xml$viewBox, _parsed$xml$viewBox2, response, svgText, loader, parsed, _t;
@@ -62,42 +60,46 @@ var loadSVGsByItem = /*#__PURE__*/function () {
62
60
  return _ref.apply(this, arguments);
63
61
  };
64
62
  }();
65
- export function handleExternalEvent(_x2, _x3) {
63
+ var compareSVGRect = function compareSVGRect(value) {
64
+ return value.e <= 10 && value.e + value.a * value.SVGWidth + 10 >= value.viewerWidth && value.f <= 80 && value.f + value.d * value.SVGHeight + 10 >= value.viewerHeight ? true : false;
65
+ };
66
+ export function handleExternalEvent(_x2) {
66
67
  return _handleExternalEvent.apply(this, arguments);
67
68
  }
68
69
  function _handleExternalEvent() {
69
- _handleExternalEvent = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(evt, props) {
70
- var state, sLineCnt, element, catalog, outlineSVGData, catalogInstance, elementJs, _evt$payload, moveType, moveValue, value, defaulTitle, _t2, _t3;
70
+ _handleExternalEvent = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(props) {
71
+ var evt, state, sLineCnt, element, catalog, outlineSVGData, catalogInstance, elementJs, _evt$payload, moveType, moveValue, value, defaulTitle, _evt$payload2, doorStyle, isAll, _doorStyle, _value, _zoomValue, _value2, _zoomValue2, _t2, _t3;
71
72
  return _regeneratorRuntime.wrap(function (_context2) {
72
73
  while (1) switch (_context2.prev = _context2.next) {
73
74
  case 0:
74
- state = props.state;
75
+ evt = props.externalEvent;
76
+ state = props.state.get('KitchenConfigurator');
75
77
  _t2 = evt === null || evt === void 0 ? void 0 : evt.type;
76
- _context2.next = _t2 === EXTERNAL_EVENT_TOGGLE_TO_3D ? 1 : _t2 === EXTERNAL_EVENT_TOGGLE_TO_2D ? 2 : _t2 === EXTERNAL_EVENT_TOGGLE_TO_ELEVATION ? 3 : _t2 === EXTERNAL_EVENT_ADD_WALL ? 4 : _t2 === EXTERNAL_EVENT_ADD_ITEM ? 5 : _t2 === EXTERNAL_EVENT_MOVE_PAN ? 9 : _t2 === EXTERNAL_EVENT_NEW_PROJECT ? 15 : 16;
78
+ _context2.next = _t2 === EXTERNAL_EVENT_TOGGLE_TO_3D ? 1 : _t2 === EXTERNAL_EVENT_TOGGLE_TO_2D ? 2 : _t2 === EXTERNAL_EVENT_TOGGLE_TO_ELEVATION ? 3 : _t2 === EXTERNAL_EVENT_ADD_WALL ? 4 : _t2 === EXTERNAL_EVENT_ADD_ITEM ? 5 : _t2 === EXTERNAL_EVENT_MOVE_PAN ? 9 : _t2 === EXTERNAL_EVENT_NEW_PROJECT ? 15 : _t2 === EXTERNAL_EVENT_CHANGE_DOORSTYLE ? 16 : _t2 === EXTERNAL_EVENT_SET_INITIAL_DATA ? 17 : _t2 === EXTERNAL_EVENT_ADD_ROOM_SHAPE ? 18 : _t2 === EXTERNAL_EVENT_ZOOM_IN ? 19 : _t2 === EXTERNAL_EVENT_ZOOM_OUT ? 22 : 25;
77
79
  break;
78
80
  case 1:
79
81
  props.projectActions.setMode(MODE_IDLE_3D);
80
- return _context2.abrupt("continue", 16);
82
+ return _context2.abrupt("continue", 25);
81
83
  case 2:
82
84
  props.projectActions.setMode(MODE_IDLE);
83
- return _context2.abrupt("continue", 16);
85
+ return _context2.abrupt("continue", 25);
84
86
  case 3:
85
- sLineCnt = state.getIn(['KitchenConfigurator', 'scene', 'layers', 'layer-1', 'selected', 'lines']).size;
87
+ sLineCnt = state.getIn(['scene', 'layers', 'layer-1', 'selected', 'lines']).size;
86
88
  if (sLineCnt > 0) props.projectActions.setMode(MODE_ELEVATION_VIEW);
87
- return _context2.abrupt("continue", 16);
89
+ return _context2.abrupt("continue", 25);
88
90
  case 4:
89
91
  if (state.mode === MODE_IDLE || state.mode === MODE_2D_PAN) props.linesActions.selectToolDrawingLine('wall');else {
90
92
  props.projectActions.setMode(MODE_IDLE);
91
93
  props.linesActions.selectToolDrawingLine('wall');
92
94
  }
93
- return _context2.abrupt("continue", 16);
95
+ return _context2.abrupt("continue", 25);
94
96
  case 5:
95
97
  if (isEmpty(evt === null || evt === void 0 ? void 0 : evt.payload)) {
96
98
  _context2.next = 8;
97
99
  break;
98
100
  }
99
101
  element = evt.payload;
100
- catalog = state.getIn(['KitchenConfigurator', 'catalog']).toJS(); // add item to catalog of state
102
+ catalog = state.getIn(['catalog']).toJS(); // add item to catalog of state
101
103
  if (!isEmpty(catalog === null || catalog === void 0 ? void 0 : catalog.elements[element.name])) {
102
104
  _context2.next = 7;
103
105
  break;
@@ -122,10 +124,10 @@ function _handleExternalEvent() {
122
124
  props.projectActions.pushLastSelectedCatalogElementToHistory(element);
123
125
  props.projectActions.setIsCabinetDrawing(true);
124
126
  case 8:
125
- return _context2.abrupt("continue", 16);
127
+ return _context2.abrupt("continue", 25);
126
128
  case 9:
127
129
  _evt$payload = evt.payload, moveType = _evt$payload.moveType, moveValue = _evt$payload.moveValue;
128
- value = state.getIn(['KitchenConfigurator', 'viewer2D']).toJS();
130
+ value = state.getIn(['viewer2D']).toJS();
129
131
  _t3 = moveType;
130
132
  _context2.next = _t3 === TOP ? 10 : _t3 === BOTTOM ? 11 : _t3 === RIGHT ? 12 : _t3 === LEFT ? 13 : 14;
131
133
  break;
@@ -142,14 +144,79 @@ function _handleExternalEvent() {
142
144
  value.e -= moveValue;
143
145
  return _context2.abrupt("continue", 14);
144
146
  case 14:
145
- if (value.e <= 10 && value.e + value.a * value.SVGWidth + 10 >= value.viewerWidth && value.f <= 80 && value.f + value.d * value.SVGHeight + 10 >= value.viewerHeight) props.viewer2DActions.updateCameraView(value);
146
- return _context2.abrupt("continue", 16);
147
+ if (compareSVGRect(value)) props.viewer2DActions.updateCameraView(value);
148
+ return _context2.abrupt("continue", 25);
147
149
  case 15:
148
150
  defaulTitle = 'Untitle';
149
151
  props.projectActions.newProject();
150
152
  props.projectActions.rename(defaulTitle);
151
- return _context2.abrupt("continue", 16);
153
+ return _context2.abrupt("continue", 25);
152
154
  case 16:
155
+ _evt$payload2 = evt.payload, doorStyle = _evt$payload2.doorStyle, isAll = _evt$payload2.isAll;
156
+ props.itemsActions.setDoorStyle(doorStyle, isAll);
157
+ return _context2.abrupt("continue", 25);
158
+ case 17:
159
+ _doorStyle = evt.payload.doorStyle;
160
+ props.itemsActions.setInitialDoorStyle(_doorStyle.doorStyle, _doorStyle.oStyle);
161
+ return _context2.abrupt("continue", 25);
162
+ case 18:
163
+ props.projectActions.loadProject(evt.payload, props.categoryData);
164
+ return _context2.abrupt("continue", 25);
165
+ case 19:
166
+ _value = state.getIn(['viewer2D']).toJS();
167
+ _value.a -= 0.1;
168
+ _value.d -= 0.1;
169
+ _value.e += _value.SVGWidth * 0.1 / 2;
170
+ _value.f += _value.SVGHeight * 0.1 / 2;
171
+ _zoomValue = parseInt((_value.a - 0.5) / ZOOM_VARIABLE);
172
+ if (!(_zoomValue > 404)) {
173
+ _context2.next = 20;
174
+ break;
175
+ }
176
+ return _context2.abrupt("return");
177
+ case 20:
178
+ if (!(_zoomValue < 35 || Number.isNaN(_zoomValue))) {
179
+ _context2.next = 21;
180
+ break;
181
+ }
182
+ return _context2.abrupt("return");
183
+ case 21:
184
+ while (!(_value.e <= 10)) {
185
+ _value.e -= 0.1;
186
+ }
187
+ while (!(_value.e + _value.a * _value.SVGWidth + 10 >= _value.viewerWidth)) {
188
+ _value.e += 0.1;
189
+ }
190
+ while (!(_value.f <= 80)) {
191
+ _value.f -= 0.1;
192
+ }
193
+ while (!(_value.f + _value.a * _value.SVGHeight + 10 >= _value.viewerHeight)) {
194
+ _value.f += 0.1;
195
+ }
196
+ if (compareSVGRect(_value)) props.viewer2DActions.updateCameraView(_value);
197
+ return _context2.abrupt("continue", 25);
198
+ case 22:
199
+ _value2 = state.getIn(['viewer2D']).toJS();
200
+ _value2.a += 0.1;
201
+ _value2.d += 0.1;
202
+ _value2.e -= _value2.SVGWidth * 0.1 / 2;
203
+ _value2.f -= _value2.SVGHeight * 0.1 / 2;
204
+ _zoomValue2 = parseInt((_value2.a - 0.5) / ZOOM_VARIABLE);
205
+ if (!(_zoomValue2 > 404)) {
206
+ _context2.next = 23;
207
+ break;
208
+ }
209
+ return _context2.abrupt("return");
210
+ case 23:
211
+ if (!(_zoomValue2 < 35 || Number.isNaN(_zoomValue2))) {
212
+ _context2.next = 24;
213
+ break;
214
+ }
215
+ return _context2.abrupt("return");
216
+ case 24:
217
+ if (compareSVGRect(_value2)) props.viewer2DActions.updateCameraView(_value2);
218
+ return _context2.abrupt("continue", 25);
219
+ case 25:
153
220
  case "end":
154
221
  return _context2.stop();
155
222
  }
@@ -112,7 +112,8 @@ var LiteKitchenConfigurator = /*#__PURE__*/function (_Component) {
112
112
  redirectURL: '',
113
113
  snackBarMessage: '',
114
114
  isSaved: false,
115
- isLeaving: false
115
+ isLeaving: false,
116
+ stateCatalog: _this.props.catalog
116
117
  };
117
118
 
118
119
  // For UTM tracking
@@ -476,6 +477,7 @@ var LiteKitchenConfigurator = /*#__PURE__*/function (_Component) {
476
477
  }, {
477
478
  key: "componentWillReceiveProps",
478
479
  value: function componentWillReceiveProps(nextProps) {
480
+ var _oldState$catalog, _plannerState$catalog;
479
481
  var stateExtractor = nextProps.stateExtractor,
480
482
  state = nextProps.state,
481
483
  projectActions = nextProps.projectActions,
@@ -484,9 +486,18 @@ var LiteKitchenConfigurator = /*#__PURE__*/function (_Component) {
484
486
 
485
487
  // handle external events
486
488
  if (this.props.externalEvent !== externalEvent) {
487
- (0, _isolateEventHandler.handleExternalEvent)(externalEvent, this.props);
489
+ (0, _isolateEventHandler.handleExternalEvent)(nextProps);
488
490
  }
489
491
  var plannerState = stateExtractor(state);
492
+ var oldState = stateExtractor(this.props.state);
493
+ if ((oldState === null || oldState === void 0 || (_oldState$catalog = oldState.catalog) === null || _oldState$catalog === void 0 ? void 0 : _oldState$catalog.elements) !== (plannerState === null || plannerState === void 0 || (_plannerState$catalog = plannerState.catalog) === null || _plannerState$catalog === void 0 ? void 0 : _plannerState$catalog.elements)) {
494
+ // copy state.catalog to the props.catalog
495
+ // let catalog = this.state.stateCatalog;
496
+ // console.log('111111', plannerState?.catalog?.elements.toJS());
497
+ // catalog.elements = plannerState?.catalog?.elements.toJS();
498
+ // console.log('222222', catalog);
499
+ // this.setState({ stateCatalog: catalog });
500
+ }
490
501
  var catalogReady = plannerState.getIn(['catalog', 'ready']);
491
502
  if (!catalogReady) {
492
503
  projectActions.initCatalog(catalog);
@@ -582,7 +593,7 @@ var LiteKitchenConfigurator = /*#__PURE__*/function (_Component) {
582
593
  }, /*#__PURE__*/_react["default"].createElement(_export2.Content, (0, _extends2["default"])({
583
594
  width: contentW,
584
595
  height: contentH,
585
- catalog: this.props.catalog,
596
+ catalog: this.state.stateCatalog,
586
597
  state: extractedState,
587
598
  toolBar: this.state.toolbar,
588
599
  setToolbar: this.setToolbar,
@@ -41,7 +41,7 @@ var _exporter = _interopRequireDefault(require("./catalog/utils/exporter"));
41
41
  var THREE = _interopRequireWildcard(require("three"));
42
42
  var _LiteKitchenConfigurator = _interopRequireDefault(require("./LiteKitchenConfigurator"));
43
43
  var _excluded = ["width", "height", "projectElement", "categoryData", "dataBundle", "configData", "options", "user", "auth", "featureFlags", "sentry", "analytics", "externalEvent", "onError"];
44
- 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 _t2 in e) "default" !== _t2 && {}.hasOwnProperty.call(e, _t2) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t2)) && (i.get || i.set) ? o(f, _t2, i) : f[_t2] = e[_t2]); return f; })(e, t); }
44
+ 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); }
45
45
  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; }
46
46
  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) { (0, _defineProperty2["default"])(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; }
47
47
  function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2["default"])(o), (0, _possibleConstructorReturn2["default"])(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2["default"])(t).constructor) : o.apply(t, e)); }
@@ -258,8 +258,6 @@ function LiteRenderer(props) {
258
258
  colorAlias = _ref.colorAlias,
259
259
  subgroups = _ref.subgroups;
260
260
  var _ref2 = dataBundle || {},
261
- _ref2$data = _ref2.data,
262
- data = _ref2$data === void 0 ? [] : _ref2$data,
263
261
  _ref2$appliances = _ref2.appliances,
264
262
  appliances = _ref2$appliances === void 0 ? [] : _ref2$appliances,
265
263
  _ref2$furnishing = _ref2.furnishing,
@@ -271,14 +269,10 @@ function LiteRenderer(props) {
271
269
  var id = configData.id,
272
270
  logoImg = configData.logoImg,
273
271
  companyUrl = configData.companyUrl;
274
- var _React$useState = _react["default"].useState([]),
272
+ var _React$useState = _react["default"].useState(false),
275
273
  _React$useState2 = (0, _slicedToArray2["default"])(_React$useState, 2),
276
- outlineSVGData = _React$useState2[0],
277
- setOutlineSVGData = _React$useState2[1];
278
- var _React$useState3 = _react["default"].useState(false),
279
- _React$useState4 = (0, _slicedToArray2["default"])(_React$useState3, 2),
280
- catalogInitiated = _React$useState4[0],
281
- setCatalogInitiated = _React$useState4[1];
274
+ catalogInitiated = _React$useState2[0],
275
+ setCatalogInitiated = _React$useState2[1];
282
276
  (0, _react.useEffect)(function () {
283
277
  var initMyCatalog = /*#__PURE__*/function () {
284
278
  var _ref3 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee() {
@@ -397,103 +391,27 @@ function LiteRenderer(props) {
397
391
  return _ref4.apply(this, arguments);
398
392
  };
399
393
  }();
400
- var loadSVGs = /*#__PURE__*/function () {
401
- var _ref5 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee4() {
402
- var svgLoadPromises, outlineData;
403
- return _regenerator["default"].wrap(function (_context4) {
404
- while (1) switch (_context4.prev = _context4.next) {
405
- case 0:
406
- svgLoadPromises = data.map(/*#__PURE__*/function () {
407
- var _ref6 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee3(item) {
408
- var _parsed$xml$viewBox, _parsed$xml$viewBox2, response, svgText, loader, parsed, _t;
409
- return _regenerator["default"].wrap(function (_context3) {
410
- while (1) switch (_context3.prev = _context3.next) {
411
- case 0:
412
- if (item.outline) {
413
- _context3.next = 1;
414
- break;
415
- }
416
- return _context3.abrupt("return", null);
417
- case 1:
418
- _context3.prev = 1;
419
- _context3.next = 2;
420
- return fetch(item.outline, {
421
- cache: 'no-store'
422
- });
423
- case 2:
424
- response = _context3.sent;
425
- _context3.next = 3;
426
- return response.text();
427
- case 3:
428
- svgText = _context3.sent;
429
- loader = new _SVGLoader.SVGLoader();
430
- parsed = loader.parse(svgText);
431
- if (!(0, _helper.isEmpty)(parsed.paths)) {
432
- _context3.next = 4;
433
- break;
434
- }
435
- return _context3.abrupt("return", null);
436
- case 4:
437
- return _context3.abrupt("return", {
438
- paths: parsed.paths,
439
- svgWidth: parseFloat(parsed.xml.getAttribute('width')) || ((_parsed$xml$viewBox = parsed.xml.viewBox) === null || _parsed$xml$viewBox === void 0 || (_parsed$xml$viewBox = _parsed$xml$viewBox.animVal) === null || _parsed$xml$viewBox === void 0 ? void 0 : _parsed$xml$viewBox.width) || 0,
440
- svgHeight: parseFloat(parsed.xml.getAttribute('height')) || ((_parsed$xml$viewBox2 = parsed.xml.viewBox) === null || _parsed$xml$viewBox2 === void 0 || (_parsed$xml$viewBox2 = _parsed$xml$viewBox2.animVal) === null || _parsed$xml$viewBox2 === void 0 ? void 0 : _parsed$xml$viewBox2.height) || 0,
441
- reverse: !parseFloat(parsed.xml.getAttribute('height'))
442
- });
443
- case 5:
444
- _context3.prev = 5;
445
- _t = _context3["catch"](1);
446
- console.error('Failed to load SVG:', item.outline, _t);
447
- return _context3.abrupt("return", null);
448
- case 6:
449
- case "end":
450
- return _context3.stop();
451
- }
452
- }, _callee3, null, [[1, 5]]);
453
- }));
454
- return function (_x3) {
455
- return _ref6.apply(this, arguments);
456
- };
457
- }());
458
- _context4.next = 1;
459
- return Promise.all(svgLoadPromises);
460
- case 1:
461
- outlineData = _context4.sent;
462
- setOutlineSVGData(outlineData);
463
- case 2:
464
- case "end":
465
- return _context4.stop();
466
- }
467
- }, _callee4);
468
- }));
469
- return function loadSVGs() {
470
- return _ref5.apply(this, arguments);
471
- };
472
- }();
473
394
  var initCatalog = /*#__PURE__*/function () {
474
- var _ref7 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee5() {
475
- return _regenerator["default"].wrap(function (_context5) {
476
- while (1) switch (_context5.prev = _context5.next) {
395
+ var _ref5 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee3() {
396
+ return _regenerator["default"].wrap(function (_context3) {
397
+ while (1) switch (_context3.prev = _context3.next) {
477
398
  case 0:
478
399
  setCatalogInitiated(false);
479
- _context5.next = 1;
400
+ _context3.next = 1;
480
401
  return initMyCatalog();
481
402
  case 1:
482
- _context5.next = 2;
403
+ _context3.next = 2;
483
404
  return loadMoldings();
484
405
  case 2:
485
- _context5.next = 3;
486
- return loadSVGs();
487
- case 3:
488
406
  setCatalogInitiated(true);
489
- case 4:
407
+ case 3:
490
408
  case "end":
491
- return _context5.stop();
409
+ return _context3.stop();
492
410
  }
493
- }, _callee5);
411
+ }, _callee3);
494
412
  }));
495
413
  return function initCatalog() {
496
- return _ref7.apply(this, arguments);
414
+ return _ref5.apply(this, arguments);
497
415
  };
498
416
  }();
499
417
  initCatalog();
@@ -502,16 +420,7 @@ function LiteRenderer(props) {
502
420
 
503
421
  // Register items once SVGs are loaded
504
422
  (0, _react.useEffect)(function () {
505
- if (!outlineSVGData.length) return;
506
423
  var Item = [];
507
- data.forEach(function (obj, index) {
508
- Item.push((0, _exporter["default"])(_objectSpread(_objectSpread({}, obj), {}, {
509
- type: 'cabinet',
510
- outlineSVGData: outlineSVGData[index],
511
- render2DItem: _itemLoader.render2DItem,
512
- render3DItem: _itemLoader.render3DItem
513
- })));
514
- });
515
424
  appliances.forEach(function (obj) {
516
425
  Item.push((0, _exporter["default"])(_objectSpread(_objectSpread({}, obj), {}, {
517
426
  render2DItem: _itemLoader.render2DItem,
@@ -534,7 +443,7 @@ function LiteRenderer(props) {
534
443
  })));
535
444
  });
536
445
  for (var x in Item) MyCatalog.registerElement(Item[x]);
537
- }, [outlineSVGData, data, appliances, furnishing, lighting]);
446
+ }, [appliances, furnishing, lighting]);
538
447
  (0, _react.useEffect)(function () {
539
448
  if (projectElement.length === 0) return;
540
449
  if (!catalogInitiated) return;
@@ -565,7 +474,6 @@ function LiteRenderer(props) {
565
474
  return state.get('KitchenConfigurator');
566
475
  },
567
476
  categoryData: categoryData,
568
- data: data,
569
477
  configData: configData,
570
478
  externalEvent: externalEvent
571
479
  }, passThrough)))));
@@ -274,11 +274,10 @@ function updateItemsAltitude(layerID, itemID, value) {
274
274
  value: value
275
275
  };
276
276
  }
277
- function setDoorStyle(doorStyle, pathes, isAll) {
277
+ function setDoorStyle(doorStyle, isAll) {
278
278
  return {
279
279
  type: _constants.SET_DOOR_STYLE,
280
280
  doorStyle: doorStyle,
281
- pathes: pathes,
282
281
  isAll: isAll
283
282
  };
284
283
  }
@@ -254,7 +254,10 @@ var Catalog = exports["default"] = /*#__PURE__*/function () {
254
254
  if (name === '') {
255
255
  throw new Error('Category has empty name');
256
256
  }
257
- return !this.hasCategory(name);
257
+ if (this.hasCategory(name)) {
258
+ throw new Error('Category has already been registered');
259
+ }
260
+ return true;
258
261
  }
259
262
 
260
263
  /**
package/lib/class/item.js CHANGED
@@ -1171,7 +1171,7 @@ var Item = exports["default"] = /*#__PURE__*/function () {
1171
1171
  }
1172
1172
  }, {
1173
1173
  key: "setDoorStyle",
1174
- value: function setDoorStyle(state, doorStyle, pathes, isAll) {
1174
+ value: function setDoorStyle(state, doorStyle, isAll) {
1175
1175
  var _this2 = this;
1176
1176
  var keys = Object.keys(doorStyle.doorStyles);
1177
1177
  keys = keys.filter(function (elem) {
@@ -487,6 +487,10 @@ var Project = exports["default"] = /*#__PURE__*/function () {
487
487
  };
488
488
  }
489
489
  var mode;
490
+ var isLineAction = false;
491
+ if (state.mode.includes('LINE')) {
492
+ isLineAction = true;
493
+ }
490
494
  if (state.mode == _constants.MODE_DRAWING_ITEM_3D) {
491
495
  mode = _constants.MODE_IDLE_3D;
492
496
  if (state.drawingSupport.has('currentID')) state = _export2.Layer.removeElement(state, state.scene.selectedLayer, 'items', state.drawingSupport.get('currentID')).updatedState;
@@ -529,6 +533,9 @@ var Project = exports["default"] = /*#__PURE__*/function () {
529
533
  draggingSupport: new _immutable.Map(),
530
534
  rotatingSupport: new _immutable.Map()
531
535
  });
536
+ if (isLineAction) {
537
+ state = _export2.Line.applyWallChanges(state, _constants.END_DRAWING_LINE).updatedState;
538
+ }
532
539
  return {
533
540
  updatedState: state
534
541
  };
@@ -613,7 +620,7 @@ var Project = exports["default"] = /*#__PURE__*/function () {
613
620
  updatedState: state
614
621
  };
615
622
  } catch (error) {
616
- console.log('initCatalogError', error);
623
+ console.log('addElementToCatalogError', error);
617
624
  return {
618
625
  updatedState: state
619
626
  };