kitchen-simulator 4.1.0-react-18 → 4.1.1

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 (202) hide show
  1. package/README.md +3 -0
  2. package/es/AppContext.js +1 -1
  3. package/es/LiteKitchenConfigurator.js +162 -111
  4. package/es/LiteRenderer.js +161 -129
  5. package/es/actions/export.js +25 -12
  6. package/es/assets/gltf/door_sliding.bin +0 -0
  7. package/es/assets/img/svg/bottombar/elevation.svg +12 -5
  8. package/es/catalog/catalog.js +21 -5
  9. package/es/catalog/factories/area-factory-3d.js +17 -17
  10. package/es/catalog/factories/wall-factory.js +1 -1
  11. package/es/catalog/holes/window-clear/planner-element.js +2 -2
  12. package/es/catalog/properties/export.js +21 -0
  13. package/es/catalog/properties/property-checkbox.js +68 -0
  14. package/es/catalog/properties/property-color.js +39 -0
  15. package/es/catalog/properties/property-enum.js +50 -0
  16. package/es/catalog/properties/property-hidden.js +19 -0
  17. package/es/catalog/properties/property-lenght-measure.js +100 -0
  18. package/es/catalog/properties/property-length-measure.js +84 -0
  19. package/es/catalog/properties/property-length-measure_hole.js +100 -0
  20. package/es/catalog/properties/property-number.js +48 -0
  21. package/es/catalog/properties/property-read-only.js +26 -0
  22. package/es/catalog/properties/property-string.js +48 -0
  23. package/es/catalog/properties/property-toggle.js +39 -0
  24. package/es/catalog/properties/shared-property-style.js +14 -0
  25. package/es/catalog/utils/exporter.js +24 -11
  26. package/es/catalog/utils/item-loader.js +222 -213
  27. package/es/class/hole.js +0 -2
  28. package/es/class/item.js +89 -70
  29. package/es/class/layer.js +1 -1
  30. package/es/class/line.js +4 -8
  31. package/es/class/project.js +97 -80
  32. package/es/components/content.js +5 -93
  33. package/es/components/export.js +4 -6
  34. package/es/components/style/button.js +106 -0
  35. package/es/components/style/cancel-button.js +21 -0
  36. package/es/components/style/content-container.js +30 -0
  37. package/es/components/style/content-title.js +25 -0
  38. package/es/components/style/delete-button.js +24 -0
  39. package/es/components/style/export.js +28 -2
  40. package/es/components/style/form-block.js +20 -0
  41. package/es/components/style/form-color-input.js +26 -0
  42. package/es/components/style/form-label.js +22 -0
  43. package/es/components/style/form-number-input.js +29 -27
  44. package/es/components/style/form-number-input_2.js +200 -0
  45. package/es/components/style/form-select.js +19 -0
  46. package/es/components/style/form-slider.js +60 -0
  47. package/es/components/style/form-submit-button.js +25 -0
  48. package/es/components/style/form-text-input.js +69 -0
  49. package/es/components/viewer2d/grids/grid-streak.js +1 -1
  50. package/es/components/viewer2d/group.js +5 -4
  51. package/es/components/viewer2d/item.js +155 -359
  52. package/es/components/viewer2d/layer.js +1 -1
  53. package/es/components/viewer2d/line.js +22 -52
  54. package/es/components/viewer2d/ruler.js +16 -11
  55. package/es/components/viewer2d/rulerDist.js +38 -51
  56. package/es/components/viewer2d/rulerX.js +4 -2
  57. package/es/components/viewer2d/rulerY.js +3 -0
  58. package/es/components/viewer2d/scene.js +17 -12
  59. package/es/components/viewer2d/state.js +1 -1
  60. package/es/components/viewer2d/utils.js +2 -2
  61. package/es/components/viewer2d/vertex.js +3 -2
  62. package/es/components/viewer2d/viewer2d.js +56 -87
  63. package/es/components/viewer3d/ruler-utils/scene3D.js +1 -1
  64. package/es/components/viewer3d/scene-creator.js +255 -58
  65. package/es/components/viewer3d/viewer3d-first-person.js +24 -26
  66. package/es/components/viewer3d/viewer3d.js +103 -124
  67. package/es/constants.js +7 -2
  68. package/es/devLiteRenderer.js +491 -150
  69. package/es/index.js +590 -21
  70. package/es/models.js +13 -8
  71. package/es/plugins/SVGLoader.js +1414 -0
  72. package/es/plugins/console-debugger.js +34 -0
  73. package/es/plugins/export.js +7 -0
  74. package/es/plugins/keyboard.js +110 -0
  75. package/es/reducers/project-reducer.js +3 -0
  76. package/es/reducers/viewer2d-reducer.js +3 -1
  77. package/es/reducers/viewer3d-reducer.js +3 -1
  78. package/es/styles/export.js +5 -0
  79. package/es/styles/tabs.css +40 -0
  80. package/es/utils/geometry.js +77 -119
  81. package/es/utils/helper.js +38 -1
  82. package/es/utils/isolate-event-handler.js +827 -607
  83. package/es/utils/molding.js +459 -11
  84. package/es/utils/ruler.js +58 -0
  85. package/lib/AppContext.js +1 -1
  86. package/lib/LiteKitchenConfigurator.js +161 -111
  87. package/lib/LiteRenderer.js +160 -129
  88. package/lib/actions/export.js +35 -39
  89. package/lib/assets/gltf/door_sliding.bin +0 -0
  90. package/lib/assets/img/svg/bottombar/elevation.svg +12 -5
  91. package/lib/catalog/catalog.js +20 -4
  92. package/lib/catalog/factories/area-factory-3d.js +14 -14
  93. package/lib/catalog/factories/wall-factory.js +1 -1
  94. package/lib/catalog/holes/window-clear/planner-element.js +2 -2
  95. package/lib/catalog/properties/export.js +81 -0
  96. package/lib/catalog/properties/property-checkbox.js +76 -0
  97. package/lib/catalog/properties/property-color.js +47 -0
  98. package/lib/catalog/properties/property-enum.js +58 -0
  99. package/lib/catalog/properties/property-hidden.js +27 -0
  100. package/lib/catalog/properties/property-lenght-measure.js +108 -0
  101. package/lib/catalog/properties/property-length-measure.js +92 -0
  102. package/lib/catalog/properties/property-length-measure_hole.js +108 -0
  103. package/lib/catalog/properties/property-number.js +56 -0
  104. package/lib/catalog/properties/property-read-only.js +34 -0
  105. package/lib/catalog/properties/property-string.js +56 -0
  106. package/lib/catalog/properties/property-toggle.js +47 -0
  107. package/lib/catalog/properties/shared-property-style.js +21 -0
  108. package/lib/catalog/utils/exporter.js +24 -11
  109. package/lib/catalog/utils/item-loader.js +219 -210
  110. package/lib/class/hole.js +0 -2
  111. package/lib/class/item.js +87 -68
  112. package/lib/class/layer.js +1 -1
  113. package/lib/class/line.js +3 -7
  114. package/lib/class/project.js +97 -80
  115. package/lib/components/content.js +5 -93
  116. package/lib/components/export.js +6 -26
  117. package/lib/components/style/button.js +115 -0
  118. package/lib/components/style/cancel-button.js +29 -0
  119. package/lib/components/style/content-container.js +38 -0
  120. package/lib/components/style/content-title.js +35 -0
  121. package/lib/components/style/delete-button.js +34 -0
  122. package/lib/components/style/export.js +105 -1
  123. package/lib/components/style/form-block.js +28 -0
  124. package/lib/components/style/form-color-input.js +34 -0
  125. package/lib/components/style/form-label.js +30 -0
  126. package/lib/components/style/form-number-input.js +29 -27
  127. package/lib/components/style/form-number-input_2.js +209 -0
  128. package/lib/components/style/form-select.js +29 -0
  129. package/lib/components/style/form-slider.js +68 -0
  130. package/lib/components/style/form-submit-button.js +35 -0
  131. package/lib/components/style/form-text-input.js +78 -0
  132. package/lib/components/viewer2d/grids/grid-streak.js +1 -1
  133. package/lib/components/viewer2d/group.js +5 -4
  134. package/lib/components/viewer2d/item.js +152 -356
  135. package/lib/components/viewer2d/layer.js +1 -1
  136. package/lib/components/viewer2d/line.js +22 -52
  137. package/lib/components/viewer2d/ruler.js +15 -10
  138. package/lib/components/viewer2d/rulerDist.js +38 -51
  139. package/lib/components/viewer2d/rulerX.js +4 -2
  140. package/lib/components/viewer2d/rulerY.js +3 -0
  141. package/lib/components/viewer2d/scene.js +17 -12
  142. package/lib/components/viewer2d/state.js +1 -1
  143. package/lib/components/viewer2d/utils.js +2 -2
  144. package/lib/components/viewer2d/vertex.js +3 -2
  145. package/lib/components/viewer2d/viewer2d.js +54 -84
  146. package/lib/components/viewer3d/ruler-utils/scene3D.js +1 -1
  147. package/lib/components/viewer3d/scene-creator.js +252 -55
  148. package/lib/components/viewer3d/viewer3d-first-person.js +24 -26
  149. package/lib/components/viewer3d/viewer3d.js +100 -120
  150. package/lib/constants.js +12 -7
  151. package/lib/devLiteRenderer.js +489 -148
  152. package/lib/index.js +592 -21
  153. package/lib/models.js +13 -8
  154. package/lib/plugins/SVGLoader.js +1419 -0
  155. package/lib/plugins/console-debugger.js +42 -0
  156. package/lib/plugins/export.js +25 -0
  157. package/lib/plugins/keyboard.js +117 -0
  158. package/lib/reducers/project-reducer.js +3 -0
  159. package/lib/reducers/viewer2d-reducer.js +3 -1
  160. package/lib/reducers/viewer3d-reducer.js +3 -1
  161. package/lib/styles/export.js +13 -0
  162. package/lib/styles/tabs.css +40 -0
  163. package/lib/utils/geometry.js +77 -119
  164. package/lib/utils/helper.js +40 -1
  165. package/lib/utils/isolate-event-handler.js +827 -606
  166. package/lib/utils/molding.js +460 -9
  167. package/lib/utils/ruler.js +63 -0
  168. package/package.json +20 -15
  169. package/es/mocks/appliancePayload.json +0 -27
  170. package/es/mocks/cabinetPayload.json +0 -1914
  171. package/es/mocks/cabinetPayload2.json +0 -76
  172. package/es/mocks/dataBundle2.json +0 -4
  173. package/es/mocks/distancePayload.json +0 -6
  174. package/es/mocks/doorStylePayload2.json +0 -84
  175. package/es/mocks/furnishingPayload.json +0 -23
  176. package/es/mocks/itemCDSPayload.json +0 -27
  177. package/es/mocks/lightingPayload.json +0 -23
  178. package/es/mocks/mockProps.json +0 -43
  179. package/es/mocks/mockProps2.json +0 -9
  180. package/es/mocks/moldingPayload.json +0 -19
  181. package/es/mocks/projectItemsCatalog.json +0 -133
  182. package/es/mocks/rectangleShape.json +0 -238
  183. package/es/mocks/replaceCabinetPayload.json +0 -81
  184. package/es/mocks/roomShapePayload.json +0 -5
  185. package/es/useAppContext.js +0 -8
  186. package/lib/mocks/appliancePayload.json +0 -27
  187. package/lib/mocks/cabinetPayload.json +0 -1914
  188. package/lib/mocks/cabinetPayload2.json +0 -76
  189. package/lib/mocks/dataBundle2.json +0 -4
  190. package/lib/mocks/distancePayload.json +0 -6
  191. package/lib/mocks/doorStylePayload2.json +0 -84
  192. package/lib/mocks/furnishingPayload.json +0 -23
  193. package/lib/mocks/itemCDSPayload.json +0 -27
  194. package/lib/mocks/lightingPayload.json +0 -23
  195. package/lib/mocks/mockProps.json +0 -43
  196. package/lib/mocks/mockProps2.json +0 -9
  197. package/lib/mocks/moldingPayload.json +0 -19
  198. package/lib/mocks/projectItemsCatalog.json +0 -133
  199. package/lib/mocks/rectangleShape.json +0 -238
  200. package/lib/mocks/replaceCabinetPayload.json +0 -81
  201. package/lib/mocks/roomShapePayload.json +0 -5
  202. package/lib/useAppContext.js +0 -16
@@ -12,6 +12,9 @@ exports.getItemRect = getItemRect;
12
12
  exports.getLinesFromItems = getLinesFromItems;
13
13
  exports.getLinesFromItems2 = getLinesFromItems2;
14
14
  exports.getLinesOfItem = getLinesOfItem;
15
+ exports.getLinesOfItem2 = getLinesOfItem2;
16
+ exports.getMoldingDataOfScene = getMoldingDataOfScene;
17
+ exports.getMoldingDataOfScene2 = getMoldingDataOfScene2;
15
18
  exports.hasMoldingLayout = hasMoldingLayout;
16
19
  exports.isAttachedWall = isAttachedWall;
17
20
  exports.isEnableItemForMolding = isEnableItemForMolding;
@@ -330,6 +333,76 @@ function getLinesOfItem(item, allLineRects, catalog) {
330
333
  }
331
334
  return lines;
332
335
  }
336
+ function getLinesOfItem2(item, allLineRects, catalog) {
337
+ var _lines;
338
+ var lines = [];
339
+ var outline = null;
340
+ var element = catalog.elements[item.get('type')];
341
+ if (!element) element = catalog.elements[(0, _utils.returnReplaceableDeepSearchType)(item.get('type'))];
342
+ // get edge lines
343
+ var newWidth = item.properties.get('width').get('_length');
344
+ var wUnit = item.properties.get('width').get('_unit') || 'cm';
345
+ newWidth = (0, _convertUnitsLite.convert)(newWidth).from(wUnit).to('cm');
346
+ var newDepth = item.properties.get('depth').get('_length');
347
+ var hUnit = item.properties.get('depth').get('_unit') || 'cm';
348
+ newDepth = (0, _convertUnitsLite.convert)(newDepth).from(hUnit).to('cm');
349
+ if (item) {
350
+ var _element;
351
+ // Get Outline Data of Selected Item
352
+ outline = (_element = element) === null || _element === void 0 ? void 0 : _element.info.outline;
353
+ if (outline) {
354
+ // Extract Points from `outline`
355
+ var outlinePaths = outline.paths;
356
+ var outlineWidth = outline.svgWidth;
357
+ var outlineHeight = outline.svgHeight;
358
+ var outlinePoints = []; // Hold Points Of SVG
359
+ var _iterator3 = _createForOfIteratorHelper(outlinePaths),
360
+ _step3;
361
+ try {
362
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
363
+ var path = _step3.value;
364
+ var _iterator4 = _createForOfIteratorHelper(path.subPaths),
365
+ _step4;
366
+ try {
367
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
368
+ var subPath = _step4.value;
369
+ outlinePoints = outlinePoints.concat(subPath.getPoints());
370
+ }
371
+ } catch (err) {
372
+ _iterator4.e(err);
373
+ } finally {
374
+ _iterator4.f();
375
+ }
376
+ }
377
+ } catch (err) {
378
+ _iterator3.e(err);
379
+ } finally {
380
+ _iterator3.f();
381
+ }
382
+ outline.reverse && outlinePoints.reverse();
383
+ for (var i = 0; i < outlinePoints.length - 1; i++) {
384
+ lines.push([_export.GeometryUtils.rotatePointAroundPoint((outlinePoints[i].x / outlineWidth - 0.5) * newWidth + item.x, (outlinePoints[i].y / outlineHeight - 0.5) * newDepth + item.y, item.x, item.y, item.rotation + 90), _export.GeometryUtils.rotatePointAroundPoint((outlinePoints[i + 1].x / outlineWidth - 0.5) * newWidth + item.x, (outlinePoints[i + 1].y / outlineHeight - 0.5) * newDepth + item.y, item.x, item.y, item.rotation + 90), _idBroker["default"].acquireID()]);
385
+ }
386
+ } else {
387
+ var pos = [[-1, -1], [1, -1], [1, 1], [-1, 1]];
388
+ for (var _i2 = 0; _i2 < 4; _i2++) {
389
+ lines.push([_export.GeometryUtils.rotatePointAroundPoint(pos[_i2][0] * newWidth / 2 + item.x, pos[_i2][1] * newDepth / 2 + item.y, item.x, item.y, item.rotation), _export.GeometryUtils.rotatePointAroundPoint(pos[(_i2 + 1) % 4][0] * newWidth / 2 + item.x, pos[(_i2 + 1) % 4][1] * newDepth / 2 + item.y, item.x, item.y, item.rotation), _idBroker["default"].acquireID()]);
390
+ }
391
+ }
392
+ }
393
+ lines = (_lines = lines) === null || _lines === void 0 ? void 0 : _lines.filter(function (line) {
394
+ return !_export.GeometryUtils.isSnappedLine({
395
+ rect: [{
396
+ x: 0,
397
+ y: 0
398
+ }, {
399
+ x: 0,
400
+ y: 0
401
+ }, line[0], line[1]]
402
+ }, allLineRects);
403
+ });
404
+ return lines;
405
+ }
333
406
  function isParallelLines(line1, line2) {
334
407
  var isParallel = false;
335
408
  if (Math.abs(line1[0].y - line1[1].y) <= _constants.EPSILON && Math.abs(line2[0].y - line2[1].y) <= _constants.EPSILON) isParallel = true;
@@ -511,20 +584,20 @@ function getLinesFromItems2(moldingGroup, layer, catalog) {
511
584
  // merge the collinear linked lines to one line
512
585
  var newMGlines = [];
513
586
  var filteredMGlines = MGlines;
514
- var _loop3 = function _loop3(_i2) {
587
+ var _loop3 = function _loop3(_i3) {
515
588
  if (filteredMGlines.length < 1) return 0; // break
516
589
  if (!filteredMGlines.some(function (v) {
517
- return v[2] === MGlines[_i2][2];
590
+ return v[2] === MGlines[_i3][2];
518
591
  })) return 1; // continue
519
- var mergedResult = getMergedLine(MGlines[_i2], filteredMGlines, 0);
592
+ var mergedResult = getMergedLine(MGlines[_i3], filteredMGlines, 0);
520
593
  if (mergedResult) {
521
594
  newMGlines.push(mergedResult.mergedLine);
522
595
  filteredMGlines = mergedResult.filteredMGlines;
523
596
  }
524
597
  },
525
598
  _ret;
526
- for (var _i2 = 0; _i2 < MGlines.length; _i2++) {
527
- _ret = _loop3(_i2);
599
+ for (var _i3 = 0; _i3 < MGlines.length; _i3++) {
600
+ _ret = _loop3(_i3);
528
601
  if (_ret === 0) break;
529
602
  if (_ret === 1) continue;
530
603
  }
@@ -613,11 +686,12 @@ function getTrimmedContourLineSegs(lineSegs, otherLines, cnt) {
613
686
  };
614
687
  var bContourSeg = true;
615
688
  var _loop6 = function _loop6(j) {
689
+ var _otherLines$j$0$x, _otherLines$j$, _otherLines$j$line$, _otherLines$j$0$y, _otherLines$j$2, _otherLines$j$line$2, _otherLines$j$1$x, _otherLines$j$3, _otherLines$j$line$3, _otherLines$j$1$y, _otherLines$j$4, _otherLines$j$line$4;
616
690
  var destLine = {
617
- x1: otherLines[j][0].x,
618
- y1: otherLines[j][0].y,
619
- x2: otherLines[j][1].x,
620
- y2: otherLines[j][1].y
691
+ x1: (_otherLines$j$0$x = (_otherLines$j$ = otherLines[j][0]) === null || _otherLines$j$ === void 0 ? void 0 : _otherLines$j$.x) !== null && _otherLines$j$0$x !== void 0 ? _otherLines$j$0$x : (_otherLines$j$line$ = otherLines[j].line[0]) === null || _otherLines$j$line$ === void 0 ? void 0 : _otherLines$j$line$.x,
692
+ y1: (_otherLines$j$0$y = (_otherLines$j$2 = otherLines[j][0]) === null || _otherLines$j$2 === void 0 ? void 0 : _otherLines$j$2.y) !== null && _otherLines$j$0$y !== void 0 ? _otherLines$j$0$y : (_otherLines$j$line$2 = otherLines[j].line[0]) === null || _otherLines$j$line$2 === void 0 ? void 0 : _otherLines$j$line$2.y,
693
+ x2: (_otherLines$j$1$x = (_otherLines$j$3 = otherLines[j][1]) === null || _otherLines$j$3 === void 0 ? void 0 : _otherLines$j$3.x) !== null && _otherLines$j$1$x !== void 0 ? _otherLines$j$1$x : (_otherLines$j$line$3 = otherLines[j].line[1]) === null || _otherLines$j$line$3 === void 0 ? void 0 : _otherLines$j$line$3.x,
694
+ y2: (_otherLines$j$1$y = (_otherLines$j$4 = otherLines[j][1]) === null || _otherLines$j$4 === void 0 ? void 0 : _otherLines$j$4.y) !== null && _otherLines$j$1$y !== void 0 ? _otherLines$j$1$y : (_otherLines$j$line$4 = otherLines[j].line[1]) === null || _otherLines$j$line$4 === void 0 ? void 0 : _otherLines$j$line$4.y
621
695
  };
622
696
  var rst = _export.GeometryUtils.relationshipOfTwoOverlappedLines(srcLine, destLine);
623
697
  if (rst.result == _constants.OVERLAP_SAME || rst.result == _constants.OVERLAP_INCLUDED) {
@@ -892,4 +966,381 @@ function createMonldingGroup(oldMG, layer, molding, catalog) {
892
966
  newMG.lines.reverse();
893
967
  newMG = getMDPoints(newMG);
894
968
  return newMG;
969
+ }
970
+ function getMoldingDataOfScene2(layer, catalog, doorStyle) {
971
+ var moldingData = [];
972
+ var items = layer.items.toArray();
973
+ var allLineRects = _export.GeometryUtils.buildRectFromLines(layer, _export.GeometryUtils.getAllLines(layer));
974
+
975
+ // get all molding line segments
976
+ var moldingLines = [];
977
+ items.forEach(function (item) {
978
+ if (item.category === _constants.ITEM_TYPE.CABINET) {
979
+ var _item$molding;
980
+ var MGlines = getLinesOfItem2(item, allLineRects, catalog); // exclude overlayed to wall
981
+ // z position of molding line
982
+ var z = item.properties.get('altitude').get('_length');
983
+ var zUnit = item.properties.get('altitude').get('_unit') || 'cm';
984
+ z = (0, _convertUnitsLite.convert)(z).from(zUnit).to('cm');
985
+ var h = item.properties.get('height').get('_length');
986
+ var hUnit = item.properties.get('height').get('_unit') || 'cm';
987
+ h = (0, _convertUnitsLite.convert)(h).from(hUnit).to('cm');
988
+ if (!(0, _helper.isEmpty)(item.molding) && isEnableItemForMolding(layer, item)) {
989
+ // calc normal molding line
990
+ item === null || item === void 0 || item.molding.forEach(function (molding) {
991
+ var lineZ = z;
992
+ switch (molding.location_type) {
993
+ case _constants.TOP_MOLDING_LOCATION:
994
+ lineZ = z + h;
995
+ break;
996
+ case _constants.MIDDLE_MOLDING_LOCATION:
997
+ lineZ = z + h / 2;
998
+ break;
999
+ }
1000
+ MGlines === null || MGlines === void 0 || MGlines.forEach(function (line) {
1001
+ return moldingLines.push({
1002
+ molding: _objectSpread({}, molding),
1003
+ doorStyle: item.doorStyle.hasOwnProperty('id') ? item.doorStyle : !(0, _helper.isEmpty)(item.doorStyle) && item.doorStyle.toJS(),
1004
+ line: line,
1005
+ z: lineZ
1006
+ });
1007
+ });
1008
+ });
1009
+ } else if (
1010
+ // calc toe kick molding line
1011
+ item.layoutpos === _constants.BASE_CABINET_LAYOUTPOS && ((0, _helper.isEmpty)(item.molding) || ((_item$molding = item.molding) === null || _item$molding === void 0 ? void 0 : _item$molding.length) < 1 || !isEnableItemForMolding(layer, item))) {
1012
+ var skuName = (0, _utils.getToeKickSKU)(item.doorStyle, catalog);
1013
+ var thumbnail = skuName ? skuName : '';
1014
+ MGlines === null || MGlines === void 0 || MGlines.forEach(function (line) {
1015
+ return moldingLines.push({
1016
+ molding: {
1017
+ name: _constants.TOE_KICK_MOLDING,
1018
+ sku: (0, _utils.getToeKickSKU)(item.doorStyle, catalog),
1019
+ thumbnail: thumbnail,
1020
+ category: 'molding',
1021
+ type: 'cabinet'
1022
+ },
1023
+ doorStyle: item.doorStyle.hasOwnProperty('id') ? item.doorStyle : !(0, _helper.isEmpty)(item.doorStyle) && item.doorStyle.toJS(),
1024
+ line: line,
1025
+ z: z
1026
+ });
1027
+ });
1028
+ }
1029
+ }
1030
+ });
1031
+
1032
+ // filter the real molding line segments
1033
+ var removeLineIds = []; // remove the line that fully overlapped to other line
1034
+ var newLines = []; // new countour line segment that except the overlapped part
1035
+ var _loop9 = function _loop9(i) {
1036
+ var srcLine = {
1037
+ x1: moldingLines[i].line[0].x,
1038
+ y1: moldingLines[i].line[0].y,
1039
+ x2: moldingLines[i].line[1].x,
1040
+ y2: moldingLines[i].line[1].y
1041
+ };
1042
+ var _loop1 = function _loop1(j) {
1043
+ if (i === j) return 0; // continue
1044
+ if (Math.abs(moldingLines[i].z - moldingLines[j].z) > _constants.EPSILON) return 0; // continue
1045
+ var destLine = {
1046
+ x1: moldingLines[j].line[0].x,
1047
+ y1: moldingLines[j].line[0].y,
1048
+ x2: moldingLines[j].line[1].x,
1049
+ y2: moldingLines[j].line[1].y
1050
+ };
1051
+ var rst = _export.GeometryUtils.relationshipOfTwoOverlappedLines(srcLine, destLine);
1052
+ if (rst.result === _constants.OVERLAP_SAME || rst.result === _constants.OVERLAP_INCLUDED) {
1053
+ removeLineIds.push(i);
1054
+ return 1; // break
1055
+ } else if (rst.result === _constants.OVERLAP_SOME) {
1056
+ removeLineIds.push(i);
1057
+ var lineSegs = getTrimmedContourLineSegs(rst.trimmedSegs, moldingLines.filter(function (v, idx) {
1058
+ return idx !== i && idx !== j && Math.abs(v.z - moldingLines[i].z) < _constants.EPSILON;
1059
+ }), 0);
1060
+ if (lineSegs.length > 0) {
1061
+ lineSegs.forEach(function (ls) {
1062
+ return newLines.push({
1063
+ molding: _objectSpread({}, moldingLines[i].molding),
1064
+ doorStyle: moldingLines[i].doorStyle,
1065
+ line: (0, _toConsumableArray2["default"])(ls),
1066
+ z: moldingLines[i].z
1067
+ });
1068
+ });
1069
+ }
1070
+ return 1; // break
1071
+ }
1072
+ },
1073
+ _ret4;
1074
+ for (var j = 0; j < moldingLines.length; j++) {
1075
+ _ret4 = _loop1(j);
1076
+ if (_ret4 === 0) continue;
1077
+ if (_ret4 === 1) break;
1078
+ }
1079
+ };
1080
+ for (var i = 0; i < moldingLines.length; i++) {
1081
+ _loop9(i);
1082
+ }
1083
+ moldingLines = moldingLines.filter(function (line, idx) {
1084
+ return !removeLineIds.some(function (id) {
1085
+ return idx === id;
1086
+ });
1087
+ });
1088
+ if (newLines.length > 0) moldingLines = [].concat((0, _toConsumableArray2["default"])(moldingLines), newLines);
1089
+ // console.log('moldingLines: ', moldingLines);
1090
+
1091
+ // make molding data with sorting molding & doorStyle
1092
+ var _loop0 = function _loop0() {
1093
+ var ml = moldingLines[k];
1094
+ var mlLength = (0, _convertUnitsLite.convert)(_export.GeometryUtils.verticesDistance(ml.line[0], ml.line[1])).from('cm').to('in');
1095
+ var idx = moldingData.findIndex(function (v) {
1096
+ var _ml$molding, _v$doorStyle, _ml$doorStyle;
1097
+ return (v === null || v === void 0 ? void 0 : v.name) === ((_ml$molding = ml.molding) === null || _ml$molding === void 0 ? void 0 : _ml$molding.name) && ((_v$doorStyle = v.doorStyle) === null || _v$doorStyle === void 0 ? void 0 : _v$doorStyle.id) === ((_ml$doorStyle = ml.doorStyle) === null || _ml$doorStyle === void 0 ? void 0 : _ml$doorStyle.id);
1098
+ });
1099
+ if (idx < 0) moldingData.push(_objectSpread(_objectSpread({}, ml.molding), {}, {
1100
+ doorStyle: ml.doorStyle,
1101
+ totalLength: mlLength,
1102
+ count: Math.ceil(mlLength * 1.1 / 96)
1103
+ }));else {
1104
+ moldingData[idx].totalLength += mlLength;
1105
+ moldingData[idx].count = Math.ceil(moldingData[idx].totalLength * 1.1 / 96);
1106
+ }
1107
+ };
1108
+ for (var k = 0; k < moldingLines.length; k++) {
1109
+ _loop0();
1110
+ }
1111
+ // console.log('moldingData: ', moldingData);
1112
+
1113
+ return moldingData;
1114
+ }
1115
+ function getMoldingDataOfScene(layer, catalog, doorStyle) {
1116
+ var moldingData = [];
1117
+ var items = layer.items.toArray();
1118
+ var moldings = [];
1119
+ // get all moldings info
1120
+ items.forEach(function (itemCat) {
1121
+ var _itemCat$molding;
1122
+ itemCat === null || itemCat === void 0 || (_itemCat$molding = itemCat.molding) === null || _itemCat$molding === void 0 || _itemCat$molding.forEach(function (molding) {
1123
+ if (!moldings.some(function (m) {
1124
+ return m.name === molding.name;
1125
+ })) moldings.push(molding);
1126
+ });
1127
+ });
1128
+
1129
+ // calc normal molding
1130
+ moldings.forEach(function (molding) {
1131
+ var itemGroups = [];
1132
+ var temp_items = [];
1133
+ items.forEach(function (item) {
1134
+ if (item.molding.some(function (mol) {
1135
+ return mol.itemID === molding.itemID;
1136
+ }) && isEnableItemForMolding(layer, item)) {
1137
+ temp_items.push(item);
1138
+ }
1139
+ });
1140
+ if (temp_items.length) {
1141
+ while (temp_items.length > 0) {
1142
+ var itemGroup = [temp_items[0]];
1143
+ var _loop10 = function _loop10(_idx) {
1144
+ if (!itemGroup.some(function (it) {
1145
+ return it.id === temp_items[_idx].id;
1146
+ }) && isItemSnappedGroup(temp_items[_idx], itemGroup)) {
1147
+ itemGroup.push(temp_items[_idx]);
1148
+ _idx = 0;
1149
+ }
1150
+ idx = _idx;
1151
+ };
1152
+ for (var idx = 0; idx < temp_items.length; idx++) {
1153
+ _loop10(idx);
1154
+ }
1155
+ itemGroup.forEach(function (item) {
1156
+ var index = temp_items.findIndex(function (it) {
1157
+ return it.id === item.id;
1158
+ });
1159
+ if (index > -1) {
1160
+ temp_items.splice(index, 1);
1161
+ }
1162
+ });
1163
+ itemGroups.push(itemGroup);
1164
+ }
1165
+ var molding_totalLength = 0;
1166
+ itemGroups.forEach(function (itemgroup) {
1167
+ var allLineRects = _export.GeometryUtils.buildRectFromLines(layer, _export.GeometryUtils.getAllLines(layer));
1168
+ var items = (0, _toConsumableArray2["default"])(itemgroup);
1169
+ var MGlines = getLinesOfItem(items[0], allLineRects, catalog);
1170
+ items = sortItemsByDistance(items, items[0]);
1171
+ var _loop11 = function _loop11() {
1172
+ var itemLines = getLinesOfItem(items[i], allLineRects, catalog);
1173
+ var temp_MGLines = [];
1174
+ MGlines.forEach(function (line) {
1175
+ var idx = itemLines.findIndex(function (itemLine) {
1176
+ return isLinesOverlapped(line, itemLine);
1177
+ });
1178
+ var curItemLine = itemLines[idx];
1179
+ if (idx > -1) {
1180
+ if (!(_export.GeometryUtils.samePoints(line[0], curItemLine[0]) && _export.GeometryUtils.samePoints(line[1], curItemLine[1]) || _export.GeometryUtils.samePoints(line[0], curItemLine[1]) && _export.GeometryUtils.samePoints(line[1], curItemLine[0]))) {
1181
+ var MGLine = mergeOverlappedLines(line, curItemLine);
1182
+ temp_MGLines.push(MGLine);
1183
+ }
1184
+ itemLines.splice(idx, 1);
1185
+ } else {
1186
+ temp_MGLines.push(line);
1187
+ }
1188
+ });
1189
+ itemLines.forEach(function (itemLine) {
1190
+ return temp_MGLines.push(itemLine);
1191
+ });
1192
+ MGlines = [].concat(temp_MGLines);
1193
+ };
1194
+ for (var i = 1; i < items.length; i++) {
1195
+ _loop11();
1196
+ }
1197
+ MGlines.forEach(function (line) {
1198
+ molding_totalLength += _export.GeometryUtils.verticesDistance(line[0], line[1]);
1199
+ });
1200
+ });
1201
+ molding_totalLength = (0, _convertUnitsLite.convert)(molding_totalLength).from('cm').to('in');
1202
+ moldingData.push(_objectSpread(_objectSpread({}, molding), {}, {
1203
+ doorStyle: doorStyle,
1204
+ count: Math.ceil(molding_totalLength * 1.1 / 96)
1205
+ }));
1206
+ }
1207
+ });
1208
+
1209
+ // calc toe kick molding
1210
+ var tmp = [];
1211
+ items.forEach(function (item) {
1212
+ if (item.category === 'cabinet' && !item.cabinet_category.toLowerCase().includes('microwave')) {
1213
+ tmp.push(item);
1214
+ }
1215
+ });
1216
+ var tmpMoldingData = [];
1217
+ var toedoorStyles = [];
1218
+ tmp.map(function (item) {
1219
+ var _item$molding2;
1220
+ if (item.layoutpos === _constants.BASE_CABINET_LAYOUTPOS && ((0, _helper.isEmpty)(item.molding) || ((_item$molding2 = item.molding) === null || _item$molding2 === void 0 ? void 0 : _item$molding2.length) < 1 || !isEnableItemForMolding(layer, item))) {
1221
+ var w = item.properties.get('width').get('_length');
1222
+ var wUnit = item.properties.get('width').get('_unit') || 'cm';
1223
+ w = (0, _convertUnitsLite.convert)(w / 2).from(wUnit).to('cm');
1224
+ var h = item.properties.get('depth').get('_length');
1225
+ var hUnit = item.properties.get('depth').get('_unit') || 'cm';
1226
+ h = (0, _convertUnitsLite.convert)(h / 2).from(hUnit).to('cm');
1227
+ var outline = null;
1228
+ var element = catalog.elements[item.get('type')];
1229
+ if (!element) element = catalog.elements[(0, _utils.returnReplaceableDeepSearchType)(item.get('type'))];
1230
+ outline = element.info.outline;
1231
+ var len = 0;
1232
+ if (outline) {
1233
+ // Extract Points from `outline`
1234
+ var outlinePaths = outline.paths;
1235
+ var outlineWidth = outline.svgWidth;
1236
+ var outlineHeight = outline.svgHeight;
1237
+ var outlinePoints = []; // Hold Points Of SVG
1238
+ var _iterator5 = _createForOfIteratorHelper(outlinePaths),
1239
+ _step5;
1240
+ try {
1241
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
1242
+ var path = _step5.value;
1243
+ var _iterator6 = _createForOfIteratorHelper(path.subPaths),
1244
+ _step6;
1245
+ try {
1246
+ for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
1247
+ var subPath = _step6.value;
1248
+ outlinePoints = outlinePoints.concat(subPath.getPoints());
1249
+ }
1250
+ } catch (err) {
1251
+ _iterator6.e(err);
1252
+ } finally {
1253
+ _iterator6.f();
1254
+ }
1255
+ }
1256
+ } catch (err) {
1257
+ _iterator5.e(err);
1258
+ } finally {
1259
+ _iterator5.f();
1260
+ }
1261
+ var maxX = outlinePoints[0].x,
1262
+ minX = outlinePoints[0].x;
1263
+ var maxY = outlinePoints[0].y,
1264
+ minY = outlinePoints[0].y;
1265
+ outlinePoints.forEach(function (point) {
1266
+ if (point.x > maxX) {
1267
+ maxX = point.x;
1268
+ }
1269
+ if (point.x < minX) {
1270
+ minX = point.x;
1271
+ }
1272
+ if (point.y > maxY) {
1273
+ maxY = point.y;
1274
+ }
1275
+ if (point.y < minY) {
1276
+ minY = point.y;
1277
+ }
1278
+ });
1279
+ outlinePoints.forEach(function (point) {
1280
+ if (_export.GeometryUtils.isPointInRect([{
1281
+ x: minX,
1282
+ y: minY
1283
+ }, {
1284
+ x: minX,
1285
+ y: maxY
1286
+ }, {
1287
+ x: maxX,
1288
+ y: maxY
1289
+ }, {
1290
+ x: maxX,
1291
+ y: minY
1292
+ }], point)) {
1293
+ if (point.x > 10) len += (point.x / outlineWidth - 0.5) * w * 2 + h * 2 - (point.y / outlineHeight - 0.5) * h * 2;
1294
+ }
1295
+ });
1296
+ len = (0, _convertUnitsLite.convert)(len).from('cm').to('in');
1297
+ } else {
1298
+ w = (0, _convertUnitsLite.convert)(w * 2).from('cm').to('in');
1299
+ len += w;
1300
+ }
1301
+ var doorIndex = toedoorStyles.findIndex(function (a) {
1302
+ var iDS = item === null || item === void 0 ? void 0 : item.doorStyle;
1303
+ if (!iDS) return false;
1304
+ if (!iDS.hasOwnProperty('id')) {
1305
+ iDS = iDS.toJS();
1306
+ }
1307
+ return a.doorStyle.id === iDS.id && (0, _utils.isEqualInstallationType)(a.doorStyle, iDS);
1308
+ });
1309
+ if (doorIndex > -1) {
1310
+ toedoorStyles[doorIndex].totalLength += len;
1311
+ } else {
1312
+ toedoorStyles.push({
1313
+ doorStyle: item.doorStyle.hasOwnProperty('id') ? item.doorStyle : item.doorStyle && item.doorStyle.toJS(),
1314
+ totalLength: len
1315
+ });
1316
+ }
1317
+ }
1318
+ });
1319
+ toedoorStyles.forEach(function (doorStyle) {
1320
+ var skuName = (0, _utils.getToeKickSKU)(doorStyle.doorStyle, catalog);
1321
+ var thumbnail = skuName ? skuName : '';
1322
+ // moldings.forEach(molding => {
1323
+ // if (
1324
+ // molding.name ===
1325
+ // getToeKickSKU(
1326
+ // doorStyle.doorStyle,
1327
+ // catalog,
1328
+ // true
1329
+ // )
1330
+ // )
1331
+ // thumbnail = molding.thumbnail;
1332
+ // });
1333
+
1334
+ doorStyle.totalLength && tmpMoldingData.push({
1335
+ name: _constants.TOE_KICK_MOLDING,
1336
+ sku: (0, _utils.getToeKickSKU)(doorStyle.doorStyle, catalog),
1337
+ thumbnail: thumbnail,
1338
+ category: 'molding',
1339
+ type: 'cabinet',
1340
+ doorStyle: doorStyle.doorStyle,
1341
+ count: Math.ceil(doorStyle.totalLength * 1.1 / 96)
1342
+ });
1343
+ });
1344
+ if (tmpMoldingData.length > 0) moldingData = [].concat((0, _toConsumableArray2["default"])(moldingData), tmpMoldingData);
1345
+ return moldingData;
895
1346
  }
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getRulerDisplayData = getRulerDisplayData;
7
+ var _convertUnitsLite = require("../utils/convert-units-lite.js");
8
+ var _constants = require("../constants");
9
+ // Below this length, the measurement LINE is hidden
10
+ var MIN_LENGTH_TO_SHOW_RULER_LINE_INCH = 13;
11
+
12
+ // Below this length, the measurement VALUE (text) is hidden
13
+ var MIN_LENGTH_TO_SHOW_RULER_VALUE_INCH = 5;
14
+ function formatDistance(value, fixed) {
15
+ // format with fixed decimals first
16
+ var text = value.toFixed(fixed);
17
+
18
+ // remove trailing zeros AFTER decimal, then remove trailing dot if needed
19
+ // examples:
20
+ // 2.00 -> 2
21
+ // 2.50 -> 2.5
22
+ // 200.00 -> 200
23
+ text = text.replace(/\.?0+$/, '');
24
+ return text;
25
+ }
26
+ function getUnitString(unit) {
27
+ if (unit === 'cm' || unit === 'mm') return '';
28
+ if (unit === 'in') return '"';
29
+ return unit;
30
+ }
31
+ function getRulerDisplayData(_ref) {
32
+ var length = _ref.length,
33
+ unit = _ref.unit,
34
+ rulerUnit = _ref.rulerUnit,
35
+ layerUnit = _ref.layerUnit,
36
+ _ref$charWidth = _ref.charWidth,
37
+ charWidth = _ref$charWidth === void 0 ? 8 : _ref$charWidth;
38
+ // 7.62 cm -> ruLength 2.99 in
39
+ var ruLength = (0, _convertUnitsLite.convert)(length).from(unit).to(rulerUnit);
40
+ var fixedLength = layerUnit === _constants.UNIT_MILLIMETER ? 0 : layerUnit === _constants.UNIT_CENTIMETER ? 1 : 2;
41
+
42
+ // 2.99 in -> valueInLayerUnit 2.99 in
43
+ var valueInLayerUnit = (0, _convertUnitsLite.convert)(ruLength).from(rulerUnit).to(layerUnit);
44
+
45
+ // 2.99 -> "3"
46
+ var distanceText = formatDistance(valueInLayerUnit, fixedLength);
47
+ var unitStr = getUnitString(layerUnit);
48
+ var textCount = distanceText.length + unitStr.length;
49
+ // textLength = (3 + ") * 8 = 16
50
+ var textLength = textCount * charWidth;
51
+
52
+ // lengthInInch = 7.62 cm -> 2.99 inch
53
+ var lengthInInch = (0, _convertUnitsLite.convert)(length).from(unit).to(_constants.UNIT_INCH);
54
+ var bShowText = lengthInInch > MIN_LENGTH_TO_SHOW_RULER_VALUE_INCH && length - textLength + 24 > 0;
55
+ var bShowLine = lengthInInch > MIN_LENGTH_TO_SHOW_RULER_LINE_INCH && length - textLength - 8 > 0;
56
+ return {
57
+ distanceText: distanceText,
58
+ unitStr: unitStr,
59
+ textLength: textLength,
60
+ bShowText: bShowText,
61
+ bShowLine: bShowLine
62
+ };
63
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kitchen-simulator",
3
- "version": "4.1.0-react-18",
3
+ "version": "4.1.1",
4
4
  "description": "It is a kitchen simulator (self-contained micro-frontend).",
5
5
  "license": "MIT",
6
6
  "main": "lib/index.js",
@@ -72,32 +72,41 @@
72
72
  "immutablediff": "0.4.4",
73
73
  "immutablepatch": "0.5.0",
74
74
  "invariant": "^2.0.0",
75
- "jwt-decode": "^2.2.0",
76
- "moment": "^2.30.1",
77
75
  "nanoid": "^5.1.6",
78
76
  "polylabel": "1.0.2",
79
77
  "posthog-js": "^1.271.0",
80
78
  "prop-types": "^15.8.1",
81
- "react-ga4": "^1.4.1",
79
+ "react": "^16.9.0",
80
+ "react-container-dimensions": "1.4.1",
81
+ "react-dom": "16.9.0",
82
82
  "react-hotjar": "^1.0.11",
83
83
  "react-icons": "3.5.0",
84
- "react-redux": "^9.2.0",
85
- "react-svg-pan-zoom": "^3.13.1",
86
- "react-use-measure": "^2.1.7",
87
- "redux": "^5.0.1",
84
+ "react-redux": "5.0.7",
85
+ "react-svg-pan-zoom": "2.18.0",
86
+ "redux": "4.0.1",
88
87
  "three": "0.166.0",
89
- "react": "^18.3.1",
90
- "react-dom": "^18.3.1"
88
+ "moment": "^2.30.1",
89
+ "jwt-decode": "^2.2.0",
90
+ "react-ga4": "^1.4.1",
91
+ "styled-components": "^5.2.0"
91
92
  },
92
93
  "devDependencies": {
94
+ "localstorage-slim": "^1.3.0",
95
+ "react-tabs": "3.0.0",
96
+ "sass": "^1.29.0",
97
+ "reactjs-popup": "^2.0.4",
98
+ "sass-loader": "^10.0.5",
99
+ "antd": "^4.24.16",
93
100
  "@babel/cli": "^7.28.3",
94
101
  "@babel/core": "^7.28.4",
95
102
  "@babel/plugin-transform-modules-commonjs": "^7.27.1",
96
103
  "@babel/plugin-transform-runtime": "^7.28.3",
97
104
  "@babel/preset-env": "^7.28.3",
98
105
  "@babel/preset-react": "^7.27.1",
106
+ "@material-ui/core": "^4.12.3",
107
+ "@material-ui/icons": "^4.11.2",
108
+ "@material-ui/lab": "^4.0.0-alpha.61",
99
109
  "@sentry/webpack-plugin": "^3.2.4",
100
- "antd": "^4.24.16",
101
110
  "assert": "^2.1.0",
102
111
  "babel-loader": "^9.1.3",
103
112
  "babel-plugin-add-module-exports": "^1.0.4",
@@ -113,15 +122,11 @@
113
122
  "file-loader": "6.2.0",
114
123
  "html-webpack-plugin": "5.6.0",
115
124
  "immutable-devtools": "0.1.4",
116
- "localstorage-slim": "^1.3.0",
117
125
  "mobile-detect": "^1.4.5",
118
126
  "path-browserify": "^1.0.1",
119
127
  "react-query": "^3.39.3",
120
128
  "react-router-dom": "5.1.2",
121
- "reactjs-popup": "^2.0.4",
122
129
  "rimraf": "^2.6.3",
123
- "sass": "^1.29.0",
124
- "sass-loader": "^10.0.5",
125
130
  "stream-browserify": "^3.0.0",
126
131
  "style-loader": "*",
127
132
  "webpack": "5.92.1",
@@ -1,27 +0,0 @@
1
- {
2
- "itemID": "7",
3
- "long_name": "30\" Bottom Freezer",
4
- "name": "30\" Bottom Freezer",
5
- "sizeinfo": {
6
- "width": 30,
7
- "depth": 27,
8
- "height": 67
9
- },
10
- "description": "",
11
- "prototype": "items",
12
- "type": "appliance",
13
- "base": "https://media.test.diydesignspace.com/uploads/Appliance/202205121705_7/thumbnail/Bottom%20freezer%2030.webp",
14
- "shape_svg": "https://media.test.diydesignspace.com/uploads/Appliance/202205121705_7/shape_svg/Top%20Freezer%2030.svg",
15
- "structure_json": {
16
- "base": "https://media.test.diydesignspace.com/uploads/Appliance/202205121705_7/gltf/refrigerator_1_30inch.gltf"
17
- },
18
- "layoutpos": "Base",
19
- "is_corner": 0,
20
- "alti": 0,
21
- "obj_property": {
22
- "category": "Bottom Freezer",
23
- "sku_number": "#app_7",
24
- "skuArray": []
25
- },
26
- "initialPosition": { "mouseX": 100, "mouseY": 100 }
27
- }