kitchen-simulator 4.0.1-react-18 → 4.0.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 (180) hide show
  1. package/README.md +3 -0
  2. package/es/AppContext.js +1 -1
  3. package/es/LiteKitchenConfigurator.js +156 -108
  4. package/es/LiteRenderer.js +159 -130
  5. package/es/actions/export.js +25 -12
  6. package/es/assets/gltf/door_sliding.bin +0 -0
  7. package/es/assets/img/png/helper/video_preview_start.png +0 -0
  8. package/es/assets/img/svg/bottombar/elevation.svg +12 -5
  9. package/es/catalog/catalog.js +21 -5
  10. package/es/catalog/holes/window-clear/planner-element.js +2 -2
  11. package/es/catalog/properties/export.js +21 -0
  12. package/es/catalog/properties/property-checkbox.js +68 -0
  13. package/es/catalog/properties/property-color.js +39 -0
  14. package/es/catalog/properties/property-enum.js +50 -0
  15. package/es/catalog/properties/property-hidden.js +19 -0
  16. package/es/catalog/properties/property-lenght-measure.js +100 -0
  17. package/es/catalog/properties/property-length-measure.js +84 -0
  18. package/es/catalog/properties/property-length-measure_hole.js +100 -0
  19. package/es/catalog/properties/property-number.js +48 -0
  20. package/es/catalog/properties/property-read-only.js +26 -0
  21. package/es/catalog/properties/property-string.js +48 -0
  22. package/es/catalog/properties/property-toggle.js +39 -0
  23. package/es/catalog/properties/shared-property-style.js +14 -0
  24. package/es/catalog/utils/exporter.js +1 -0
  25. package/es/catalog/utils/item-loader.js +17 -12
  26. package/es/class/hole.js +0 -2
  27. package/es/class/item.js +95 -69
  28. package/es/class/line.js +4 -8
  29. package/es/class/project.js +91 -80
  30. package/es/components/content.js +5 -2
  31. package/es/components/export.js +4 -6
  32. package/es/components/style/button.js +106 -0
  33. package/es/components/style/cancel-button.js +21 -0
  34. package/es/components/style/content-container.js +30 -0
  35. package/es/components/style/content-title.js +25 -0
  36. package/es/components/style/delete-button.js +24 -0
  37. package/es/components/style/export.js +28 -2
  38. package/es/components/style/form-block.js +20 -0
  39. package/es/components/style/form-color-input.js +26 -0
  40. package/es/components/style/form-label.js +22 -0
  41. package/es/components/style/form-number-input.js +11 -22
  42. package/es/components/style/form-number-input_2.js +200 -0
  43. package/es/components/style/form-select.js +19 -0
  44. package/es/components/style/form-slider.js +60 -0
  45. package/es/components/style/form-submit-button.js +25 -0
  46. package/es/components/style/form-text-input.js +69 -0
  47. package/es/components/viewer2d/group.js +5 -4
  48. package/es/components/viewer2d/item.js +339 -299
  49. package/es/components/viewer2d/layer.js +1 -1
  50. package/es/components/viewer2d/line.js +17 -47
  51. package/es/components/viewer2d/ruler.js +5 -3
  52. package/es/components/viewer2d/rulerDist.js +8 -7
  53. package/es/components/viewer2d/rulerX.js +3 -0
  54. package/es/components/viewer2d/rulerY.js +3 -0
  55. package/es/components/viewer2d/scene.js +4 -1
  56. package/es/components/viewer2d/state.js +1 -1
  57. package/es/components/viewer2d/utils.js +2 -2
  58. package/es/components/viewer2d/viewer2d.js +51 -84
  59. package/es/components/viewer3d/scene-creator.js +51 -15
  60. package/es/components/viewer3d/viewer3d-first-person.js +8 -0
  61. package/es/components/viewer3d/viewer3d.js +80 -88
  62. package/es/constants.js +6 -2
  63. package/es/devLiteRenderer.js +491 -150
  64. package/es/index.js +567 -25
  65. package/es/models.js +2 -1
  66. package/es/plugins/SVGLoader.js +1414 -0
  67. package/es/plugins/console-debugger.js +0 -2
  68. package/es/styles/export.js +5 -0
  69. package/es/styles/tabs.css +40 -0
  70. package/es/utils/geometry.js +52 -96
  71. package/es/utils/helper.js +38 -1
  72. package/es/utils/isolate-event-handler.js +781 -577
  73. package/es/utils/molding.js +457 -11
  74. package/lib/AppContext.js +1 -1
  75. package/lib/LiteKitchenConfigurator.js +155 -108
  76. package/lib/LiteRenderer.js +158 -130
  77. package/lib/actions/export.js +35 -39
  78. package/lib/assets/gltf/door_sliding.bin +0 -0
  79. package/lib/assets/img/png/helper/video_preview_start.png +0 -0
  80. package/lib/assets/img/svg/bottombar/elevation.svg +12 -5
  81. package/lib/catalog/catalog.js +20 -4
  82. package/lib/catalog/holes/window-clear/planner-element.js +2 -2
  83. package/lib/catalog/properties/export.js +81 -0
  84. package/lib/catalog/properties/property-checkbox.js +76 -0
  85. package/lib/catalog/properties/property-color.js +47 -0
  86. package/lib/catalog/properties/property-enum.js +58 -0
  87. package/lib/catalog/properties/property-hidden.js +27 -0
  88. package/lib/catalog/properties/property-lenght-measure.js +108 -0
  89. package/lib/catalog/properties/property-length-measure.js +92 -0
  90. package/lib/catalog/properties/property-length-measure_hole.js +108 -0
  91. package/lib/catalog/properties/property-number.js +56 -0
  92. package/lib/catalog/properties/property-read-only.js +34 -0
  93. package/lib/catalog/properties/property-string.js +56 -0
  94. package/lib/catalog/properties/property-toggle.js +47 -0
  95. package/lib/catalog/properties/shared-property-style.js +21 -0
  96. package/lib/catalog/utils/exporter.js +1 -0
  97. package/lib/catalog/utils/item-loader.js +17 -12
  98. package/lib/class/hole.js +0 -2
  99. package/lib/class/item.js +93 -67
  100. package/lib/class/line.js +3 -7
  101. package/lib/class/project.js +91 -80
  102. package/lib/components/content.js +5 -2
  103. package/lib/components/export.js +6 -26
  104. package/lib/components/style/button.js +115 -0
  105. package/lib/components/style/cancel-button.js +29 -0
  106. package/lib/components/style/content-container.js +38 -0
  107. package/lib/components/style/content-title.js +35 -0
  108. package/lib/components/style/delete-button.js +34 -0
  109. package/lib/components/style/export.js +105 -1
  110. package/lib/components/style/form-block.js +28 -0
  111. package/lib/components/style/form-color-input.js +34 -0
  112. package/lib/components/style/form-label.js +30 -0
  113. package/lib/components/style/form-number-input.js +11 -22
  114. package/lib/components/style/form-number-input_2.js +209 -0
  115. package/lib/components/style/form-select.js +29 -0
  116. package/lib/components/style/form-slider.js +68 -0
  117. package/lib/components/style/form-submit-button.js +35 -0
  118. package/lib/components/style/form-text-input.js +78 -0
  119. package/lib/components/viewer2d/group.js +5 -4
  120. package/lib/components/viewer2d/item.js +337 -297
  121. package/lib/components/viewer2d/layer.js +1 -1
  122. package/lib/components/viewer2d/line.js +17 -47
  123. package/lib/components/viewer2d/ruler.js +4 -2
  124. package/lib/components/viewer2d/rulerDist.js +8 -7
  125. package/lib/components/viewer2d/rulerX.js +3 -0
  126. package/lib/components/viewer2d/rulerY.js +3 -0
  127. package/lib/components/viewer2d/scene.js +4 -1
  128. package/lib/components/viewer2d/state.js +1 -1
  129. package/lib/components/viewer2d/utils.js +2 -2
  130. package/lib/components/viewer2d/viewer2d.js +49 -81
  131. package/lib/components/viewer3d/scene-creator.js +49 -13
  132. package/lib/components/viewer3d/viewer3d-first-person.js +8 -0
  133. package/lib/components/viewer3d/viewer3d.js +77 -84
  134. package/lib/constants.js +11 -7
  135. package/lib/devLiteRenderer.js +489 -148
  136. package/lib/index.js +567 -25
  137. package/lib/models.js +2 -1
  138. package/lib/plugins/SVGLoader.js +1419 -0
  139. package/lib/plugins/console-debugger.js +0 -2
  140. package/lib/styles/export.js +13 -0
  141. package/lib/styles/tabs.css +40 -0
  142. package/lib/utils/geometry.js +52 -96
  143. package/lib/utils/helper.js +40 -1
  144. package/lib/utils/isolate-event-handler.js +781 -576
  145. package/lib/utils/molding.js +458 -9
  146. package/package.json +21 -16
  147. package/es/mocks/appliancePayload.json +0 -27
  148. package/es/mocks/cabinetPayload.json +0 -1914
  149. package/es/mocks/cabinetPayload2.json +0 -76
  150. package/es/mocks/dataBundle2.json +0 -4
  151. package/es/mocks/distancePayload.json +0 -6
  152. package/es/mocks/doorStylePayload2.json +0 -84
  153. package/es/mocks/furnishingPayload.json +0 -23
  154. package/es/mocks/itemCDSPayload.json +0 -27
  155. package/es/mocks/lightingPayload.json +0 -23
  156. package/es/mocks/mockProps.json +0 -43
  157. package/es/mocks/mockProps2.json +0 -9
  158. package/es/mocks/moldingPayload.json +0 -19
  159. package/es/mocks/projectItemsCatalog.json +0 -133
  160. package/es/mocks/rectangleShape.json +0 -238
  161. package/es/mocks/replaceCabinetPayload.json +0 -81
  162. package/es/mocks/roomShapePayload.json +0 -5
  163. package/es/useAppContext.js +0 -8
  164. package/lib/mocks/appliancePayload.json +0 -27
  165. package/lib/mocks/cabinetPayload.json +0 -1914
  166. package/lib/mocks/cabinetPayload2.json +0 -76
  167. package/lib/mocks/dataBundle2.json +0 -4
  168. package/lib/mocks/distancePayload.json +0 -6
  169. package/lib/mocks/doorStylePayload2.json +0 -84
  170. package/lib/mocks/furnishingPayload.json +0 -23
  171. package/lib/mocks/itemCDSPayload.json +0 -27
  172. package/lib/mocks/lightingPayload.json +0 -23
  173. package/lib/mocks/mockProps.json +0 -43
  174. package/lib/mocks/mockProps2.json +0 -9
  175. package/lib/mocks/moldingPayload.json +0 -19
  176. package/lib/mocks/projectItemsCatalog.json +0 -133
  177. package/lib/mocks/rectangleShape.json +0 -238
  178. package/lib/mocks/replaceCabinetPayload.json +0 -81
  179. package/lib/mocks/roomShapePayload.json +0 -5
  180. package/lib/useAppContext.js +0 -16
@@ -116,7 +116,7 @@ export default function Layer(_ref) {
116
116
  var lineData = [];
117
117
  lines.sort(function compare(a, b) {
118
118
  return a.createdDateTime - b.createdDateTime;
119
- }).valueSeq().forEach(function (line, index) {
119
+ }).valueSeq().forEach(function (line) {
120
120
  lineData.push(/*#__PURE__*/React.createElement(Line, {
121
121
  key: line.id,
122
122
  layer: layer,
@@ -247,13 +247,11 @@ export default function Line(_ref) {
247
247
  if (!showWallCabinetMeasure || wall_posArray.length <= 2) {
248
248
  wallSpace = 0;
249
249
  }
250
- wallRuler = wall_posAndwidth.map(function (pAw, idx) {
250
+ wallRuler = wall_posAndwidth.map(function (pAw) {
251
251
  if (pAw.length > 1) {
252
252
  if (Math.sin(angle) === 0 || GeometryUtils.almostEqual(y1, y2)) {
253
253
  if (x1 - x2 > 0) {
254
- return /*#__PURE__*/React.createElement("g", {
255
- key: "wallRuler-".concat(idx)
256
- }, /*#__PURE__*/React.createElement("line", {
254
+ return /*#__PURE__*/React.createElement("g", null, /*#__PURE__*/React.createElement("line", {
257
255
  x1: pAw.pos.x + pAw.length,
258
256
  y1: pAw.pos.y,
259
257
  x2: pAw.pos.x + pAw.length,
@@ -275,9 +273,7 @@ export default function Line(_ref) {
275
273
  style: STYLE_DASH
276
274
  }));
277
275
  } else {
278
- return /*#__PURE__*/React.createElement("g", {
279
- key: "wallRuler-".concat(idx)
280
- }, /*#__PURE__*/React.createElement("line", {
276
+ return /*#__PURE__*/React.createElement("g", null, /*#__PURE__*/React.createElement("line", {
281
277
  x1: pAw.pos.x + pAw.length,
282
278
  y1: pAw.pos.y,
283
279
  x2: pAw.pos.x + pAw.length,
@@ -302,9 +298,7 @@ export default function Line(_ref) {
302
298
  } else {
303
299
  if (y1 - y2 > 0) {
304
300
  if (x1 - x2 < 0 || GeometryUtils.almostEqual(x1, x2)) {
305
- return /*#__PURE__*/React.createElement("g", {
306
- key: "wallRuler-".concat(idx)
307
- }, /*#__PURE__*/React.createElement("line", {
301
+ return /*#__PURE__*/React.createElement("g", null, /*#__PURE__*/React.createElement("line", {
308
302
  x1: pAw.pos.x - pAw.length * Math.cos(angle / 180 * Math.PI),
309
303
  y1: pAw.pos.y - pAw.length * Math.sin(angle / 180 * Math.PI),
310
304
  x2: pAw.pos.x - pAw.length * Math.cos(angle / 180 * Math.PI) - (thickness / 2 + wallSpace) * Math.sin(angle / 180 * Math.PI),
@@ -326,9 +320,7 @@ export default function Line(_ref) {
326
320
  style: STYLE_DASH
327
321
  }));
328
322
  } else {
329
- return /*#__PURE__*/React.createElement("g", {
330
- key: "wallRuler-".concat(idx)
331
- }, /*#__PURE__*/React.createElement("line", {
323
+ return /*#__PURE__*/React.createElement("g", null, /*#__PURE__*/React.createElement("line", {
332
324
  x1: pAw.pos.x,
333
325
  y1: pAw.pos.y,
334
326
  x2: pAw.pos.x - (thickness / 2 + wallSpace) * Math.sin(angle / 180 * Math.PI),
@@ -352,9 +344,7 @@ export default function Line(_ref) {
352
344
  }
353
345
  } else {
354
346
  if (x1 - x2 < 0 || GeometryUtils.almostEqual(x1, x2)) {
355
- return /*#__PURE__*/React.createElement("g", {
356
- key: "wallRuler-".concat(idx)
357
- }, /*#__PURE__*/React.createElement("line", {
347
+ return /*#__PURE__*/React.createElement("g", null, /*#__PURE__*/React.createElement("line", {
358
348
  x1: pAw.pos.x,
359
349
  y1: pAw.pos.y,
360
350
  x2: pAw.pos.x - (thickness / 2 + wallSpace) * Math.sin(angle / 180 * Math.PI),
@@ -376,9 +366,7 @@ export default function Line(_ref) {
376
366
  style: STYLE_DASH
377
367
  }));
378
368
  } else {
379
- return /*#__PURE__*/React.createElement("g", {
380
- key: "wallRuler-".concat(idx)
381
- }, /*#__PURE__*/React.createElement("line", {
369
+ return /*#__PURE__*/React.createElement("g", null, /*#__PURE__*/React.createElement("line", {
382
370
  x1: pAw.pos.x + pAw.length * Math.cos(angle / 180 * Math.PI),
383
371
  y1: pAw.pos.y + pAw.length * Math.sin(angle / 180 * Math.PI),
384
372
  x2: pAw.pos.x + pAw.length * Math.cos(angle / 180 * Math.PI) - (thickness / 2 + wallSpace) * Math.sin(angle / 180 * Math.PI),
@@ -471,13 +459,11 @@ export default function Line(_ref) {
471
459
  if (!showBaseCabinetMeasure || base_posArray.length <= 2) {
472
460
  baseSpace -= STEP;
473
461
  }
474
- baseRuler = base_posAndwidth.map(function (pAw, idx) {
462
+ baseRuler = base_posAndwidth.map(function (pAw) {
475
463
  if (pAw.length > 1) {
476
464
  if (Math.sin(angle) === 0 || GeometryUtils.almostEqual(y1, y2)) {
477
465
  if (x1 - x2 > 0) {
478
- return /*#__PURE__*/React.createElement("g", {
479
- key: "baseRuler-".concat(idx)
480
- }, /*#__PURE__*/React.createElement("line", {
466
+ return /*#__PURE__*/React.createElement("g", null, /*#__PURE__*/React.createElement("line", {
481
467
  x1: pAw.pos.x + pAw.length,
482
468
  y1: pAw.pos.y,
483
469
  x2: pAw.pos.x + pAw.length,
@@ -499,9 +485,7 @@ export default function Line(_ref) {
499
485
  style: STYLE_DASH
500
486
  }));
501
487
  } else {
502
- return /*#__PURE__*/React.createElement("g", {
503
- key: "baseRuler-".concat(idx)
504
- }, /*#__PURE__*/React.createElement("line", {
488
+ return /*#__PURE__*/React.createElement("g", null, /*#__PURE__*/React.createElement("line", {
505
489
  x1: pAw.pos.x + pAw.length,
506
490
  y1: pAw.pos.y,
507
491
  x2: pAw.pos.x + pAw.length,
@@ -526,9 +510,7 @@ export default function Line(_ref) {
526
510
  } else {
527
511
  if (y1 - y2 > 0) {
528
512
  if (x1 - x2 < 0 || GeometryUtils.almostEqual(x1, x2)) {
529
- return /*#__PURE__*/React.createElement("g", {
530
- key: "baseRuler-".concat(idx)
531
- }, /*#__PURE__*/React.createElement("line", {
513
+ return /*#__PURE__*/React.createElement("g", null, /*#__PURE__*/React.createElement("line", {
532
514
  x1: pAw.pos.x - pAw.length * Math.cos(angle / 180 * Math.PI),
533
515
  y1: pAw.pos.y - pAw.length * Math.sin(angle / 180 * Math.PI),
534
516
  x2: pAw.pos.x - pAw.length * Math.cos(angle / 180 * Math.PI) - (thickness / 2 + baseSpace) * Math.sin(angle / 180 * Math.PI),
@@ -550,9 +532,7 @@ export default function Line(_ref) {
550
532
  style: STYLE_DASH
551
533
  }));
552
534
  } else {
553
- return /*#__PURE__*/React.createElement("g", {
554
- key: "baseRuler-".concat(idx)
555
- }, /*#__PURE__*/React.createElement("line", {
535
+ return /*#__PURE__*/React.createElement("g", null, /*#__PURE__*/React.createElement("line", {
556
536
  x1: pAw.pos.x,
557
537
  y1: pAw.pos.y,
558
538
  x2: pAw.pos.x - (thickness / 2 + baseSpace) * Math.sin(angle / 180 * Math.PI),
@@ -576,9 +556,7 @@ export default function Line(_ref) {
576
556
  }
577
557
  } else {
578
558
  if (x1 - x2 < 0 || GeometryUtils.almostEqual(x1, x2)) {
579
- return /*#__PURE__*/React.createElement("g", {
580
- key: "baseRuler-".concat(idx)
581
- }, /*#__PURE__*/React.createElement("line", {
559
+ return /*#__PURE__*/React.createElement("g", null, /*#__PURE__*/React.createElement("line", {
582
560
  x1: pAw.pos.x,
583
561
  y1: pAw.pos.y,
584
562
  x2: pAw.pos.x - (thickness / 2 + baseSpace) * Math.sin(angle / 180 * Math.PI),
@@ -600,9 +578,7 @@ export default function Line(_ref) {
600
578
  style: STYLE_DASH
601
579
  }));
602
580
  } else {
603
- return /*#__PURE__*/React.createElement("g", {
604
- key: "baseRuler-".concat(idx)
605
- }, /*#__PURE__*/React.createElement("line", {
581
+ return /*#__PURE__*/React.createElement("g", null, /*#__PURE__*/React.createElement("line", {
606
582
  x1: pAw.pos.x + pAw.length * Math.cos(angle / 180 * Math.PI),
607
583
  y1: pAw.pos.y + pAw.length * Math.sin(angle / 180 * Math.PI),
608
584
  x2: pAw.pos.x + pAw.length * Math.cos(angle / 180 * Math.PI) - (thickness / 2 + baseSpace) * Math.sin(angle / 180 * Math.PI),
@@ -676,9 +652,7 @@ export default function Line(_ref) {
676
652
  //the space from the dimensioning line to the bottom
677
653
  var lineSpacedimension2 = 14;
678
654
  if (compareVertices(vertex0, vertex1) >= 0 && vertex0.x !== vertex1.x) {
679
- renderedRuler.push(/*#__PURE__*/React.createElement("g", {
680
- key: 'ruler_' + line.id
681
- }, /*#__PURE__*/React.createElement("line", {
655
+ renderedRuler.push(/*#__PURE__*/React.createElement("g", null, /*#__PURE__*/React.createElement("line", {
682
656
  x1: length,
683
657
  y1: lineSpace + lineSpacedimension1,
684
658
  x2: length,
@@ -700,9 +674,7 @@ export default function Line(_ref) {
700
674
  style: STYLE_ROOM_SHAPE
701
675
  })));
702
676
  } else {
703
- renderedRuler.push(/*#__PURE__*/React.createElement("g", {
704
- key: 'ruler_' + line.id
705
- }, /*#__PURE__*/React.createElement("line", {
677
+ renderedRuler.push(/*#__PURE__*/React.createElement("g", null, /*#__PURE__*/React.createElement("line", {
706
678
  x1: 0,
707
679
  y1: lineSpace + lineSpacedimension1,
708
680
  x2: 0,
@@ -801,9 +773,7 @@ export default function Line(_ref) {
801
773
  }
802
774
  });
803
775
  }
804
- return /*#__PURE__*/React.createElement("g", {
805
- key: line.id
806
- }, /*#__PURE__*/React.createElement("g", {
776
+ return /*#__PURE__*/React.createElement("g", null, /*#__PURE__*/React.createElement("g", {
807
777
  transform: "translate(".concat(x1, ", ").concat(y1, ") rotate(").concat(angle, ", 0, 0)"),
808
778
  "data-element-root": true,
809
779
  "data-prototype": 'ruler',
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { convert } from "../../utils/convert-units-lite";
4
4
  import IDBroker from "../../utils/id-broker";
5
- import { LINE_THICKNESS, TEXT_COLOR_NEUTRAL_7 } from "../../constants";
5
+ import { LINE_THICKNESS, TEXT_COLOR_NEUTRAL_7, UNIT_FOOT, UNIT_METER } from "../../constants";
6
6
  import { STYLE_ROOM_SHAPE } from "./line";
7
7
  var STYLE = {
8
8
  stroke: TEXT_COLOR_NEUTRAL_7,
@@ -31,7 +31,9 @@ export default function Ruler(_ref) {
31
31
  rulerUnit = _ref.rulerUnit,
32
32
  transform = _ref.transform,
33
33
  style = _ref.style;
34
- var distanceText = convert(length).from(unit).to(rulerUnit).toFixed(0);
34
+ var ruLength = convert(length).from(unit).to(rulerUnit);
35
+ var fixedLength = layer.unit === UNIT_METER || layer.unit === UNIT_FOOT ? 2 : 0;
36
+ var distanceText = (Math.round(convert(ruLength).from(rulerUnit).to(layer.unit) * 100) / 100).toFixed(fixedLength);
35
37
  var textLength = (distanceText.length + layer.unit.length) * 9;
36
38
  return /*#__PURE__*/React.createElement("g", {
37
39
  transform: transform
@@ -52,7 +54,7 @@ export default function Ruler(_ref) {
52
54
  transform: "scale(1, -1)",
53
55
  style: STYLE_TEXT,
54
56
  fill: TEXT_COLOR_NEUTRAL_7
55
- }, Math.round(convert(distanceText).from('in').to(layer.unit) * 100) / 100, layer.unit === 'in' ? '"' : layer.unit)), /*#__PURE__*/React.createElement("line", {
57
+ }, distanceText, layer.unit === 'in' ? '"' : layer.unit)), /*#__PURE__*/React.createElement("line", {
56
58
  x1: style === STYLE_ROOM_SHAPE ? 0 : 4,
57
59
  y1: "0",
58
60
  x2: (length - textLength) / 2 < 0 ? 0 : (length - textLength) / 2,
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { convert } from "../../utils/convert-units-lite";
4
+ import { UNIT_FOOT, UNIT_METER } from "../../constants";
4
5
  var ARROW_STYLE = {
5
6
  stroke: '#1183B7',
6
7
  strokeWidth: '2px',
@@ -31,9 +32,9 @@ export default function RulerDist(_ref) {
31
32
  transform = _ref.transform,
32
33
  angle = _ref.angle,
33
34
  rotation = _ref.rotation;
34
- var _unit = 'in';
35
- // let _length = convert(length).from(unit).to(rulerUnit);
36
- var distanceText = "".concat(convert(length).from('cm').to(rulerUnit).toFixed(0));
35
+ var ruLength = convert(length).from(unit).to(rulerUnit);
36
+ var fixedLength = layer.unit === UNIT_METER || layer.unit === UNIT_FOOT ? 2 : 0;
37
+ var distanceText = (Math.round(convert(ruLength).from(rulerUnit).to(layer.unit) * 100) / 100).toFixed(fixedLength);
37
38
  var textLength = (distanceText.length + layer.unit.length) * 8;
38
39
  var textangle = angle + 90;
39
40
  var textRotation = 1;
@@ -66,8 +67,8 @@ export default function RulerDist(_ref) {
66
67
  textRotation = 180;
67
68
  ay = 5;
68
69
  }
69
- if (distanceText > 0) {
70
- if (distanceText < 28) {
70
+ if (ruLength > 0) {
71
+ if (ruLength < 28) {
71
72
  return /*#__PURE__*/React.createElement("g", {
72
73
  transform: transform
73
74
  }, /*#__PURE__*/React.createElement("g", null, /*#__PURE__*/React.createElement("text", {
@@ -75,7 +76,7 @@ export default function RulerDist(_ref) {
75
76
  y: "0",
76
77
  transform: "translate(".concat(length / 2, ",").concat(ay, ") scale(1, -1) rotate(").concat(textRotation, ")"),
77
78
  style: STYLE_TEXT
78
- }, Math.round(convert(distanceText).from('in').to(layer.unit) * 100) / 100, layer.unit === 'in' ? '"' : layer.unit)));
79
+ }, distanceText, layer.unit === 'in' ? '"' : layer.unit)));
79
80
  } else {
80
81
  return /*#__PURE__*/React.createElement("g", {
81
82
  transform: transform
@@ -84,7 +85,7 @@ export default function RulerDist(_ref) {
84
85
  y: "0",
85
86
  transform: "translate(".concat(length / 2, ",").concat(ay, ") scale(1, -1) rotate(").concat(textRotation, ")"),
86
87
  style: STYLE_TEXT
87
- }, Math.round(convert(distanceText).from('in').to(layer.unit) * 100) / 100, layer.unit === 'in' ? '"' : layer.unit)), /*#__PURE__*/React.createElement("line", {
88
+ }, distanceText, layer.unit === 'in' ? '"' : layer.unit)), /*#__PURE__*/React.createElement("line", {
88
89
  x1: "2",
89
90
  y1: "0",
90
91
  x2: (length - textLength) / 2 < 0 ? 0 : (length - textLength) / 2,
@@ -139,4 +139,7 @@ RulerX.defaultProps = {
139
139
  backgroundColor: SharedStyle.PRIMARY_COLOR.main,
140
140
  fontColor: SharedStyle.COLORS.white,
141
141
  markerColor: SharedStyle.SECONDARY_COLOR.main
142
+ };
143
+ RulerX.contextTypes = {
144
+ translator: PropTypes.object.isRequired
142
145
  };
@@ -141,4 +141,7 @@ RulerY.defaultProps = {
141
141
  backgroundColor: SharedStyle.PRIMARY_COLOR.main,
142
142
  fontColor: SharedStyle.COLORS.white,
143
143
  markerColor: SharedStyle.SECONDARY_COLOR.main
144
+ };
145
+ RulerY.contextTypes = {
146
+ translator: PropTypes.object.isRequired
144
147
  };
@@ -121,5 +121,8 @@ export { Scene as default };
121
121
  Scene.propTypes = {
122
122
  scene: PropTypes.object.isRequired,
123
123
  catalog: PropTypes.object.isRequired,
124
- relatedLines: PropTypes.array.isRequired
124
+ relatedLines: PropTypes.object.isRequired
125
+ };
126
+ Scene.contextTypes = {
127
+ projectActions: PropTypes.object.isRequired
125
128
  };
@@ -69,5 +69,5 @@ export default function State(_ref) {
69
69
  State.propTypes = {
70
70
  state: PropTypes.object.isRequired,
71
71
  catalog: PropTypes.object.isRequired,
72
- relatedLines: PropTypes.array.isRequired
72
+ relatedLines: PropTypes.object.isRequired
73
73
  };
@@ -187,7 +187,7 @@ export var areaPolygon = function areaPolygon(points) {
187
187
  };
188
188
  export var isWarningItem = function isWarningItem(item) {
189
189
  var _item$toJS$doorStyle;
190
- return !(item !== null && item !== void 0 && (_item$toJS$doorStyle = item.toJS().doorStyle) !== null && _item$toJS$doorStyle !== void 0 && (_item$toJS$doorStyle = _item$toJS$doorStyle.doorStyles) !== null && _item$toJS$doorStyle !== void 0 && (_item$toJS$doorStyle = _item$toJS$doorStyle.cds) !== null && _item$toJS$doorStyle !== void 0 && _item$toJS$doorStyle.filter(function (cd) {
190
+ if (item.category === 'cabinet') return !(item !== null && item !== void 0 && (_item$toJS$doorStyle = item.toJS().doorStyle) !== null && _item$toJS$doorStyle !== void 0 && (_item$toJS$doorStyle = _item$toJS$doorStyle.doorStyles) !== null && _item$toJS$doorStyle !== void 0 && (_item$toJS$doorStyle = _item$toJS$doorStyle.cds) !== null && _item$toJS$doorStyle !== void 0 && _item$toJS$doorStyle.filter(function (cd) {
191
191
  return cd.itemID == (item === null || item === void 0 ? void 0 : item.getIn(['itemID']));
192
- }).length) > 0;
192
+ }).length) > 0;else return false;
193
193
  };
@@ -4,7 +4,7 @@ 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 React, { useEffect, useRef, useState } from 'react';
6
6
  import PropTypes from 'prop-types';
7
- import { INITIAL_VALUE, POSITION_NONE, ReactSVGPanZoom, TOOL_AUTO, TOOL_NONE, TOOL_PAN, TOOL_ZOOM_IN, TOOL_ZOOM_OUT } from 'react-svg-pan-zoom';
7
+ import { ReactSVGPanZoom, TOOL_AUTO, TOOL_NONE, TOOL_PAN, TOOL_ZOOM_IN, TOOL_ZOOM_OUT } from 'react-svg-pan-zoom';
8
8
  import * as constants from "../../constants";
9
9
  import { DECIMAL_PLACES_2, LINE_THICKNESS, MIN_ANGLE_DISALLOW_DRAW_WALL, MODE_ELEVATION_VIEW, MODE_IDLE, UNIT_ANGLE, INTERNAL_EVENT_SELECT_ELEMENT, INTERNAL_EVENT_DRAG_ELEMENT, INTERNAL_EVENT_DRAW_ELEMENT, INTERNAL_EVENT_ROTATE_ELEMENT } from "../../constants";
10
10
  import State from "./state";
@@ -15,10 +15,8 @@ import FormNumberInput from "../style/form-number-input";
15
15
  import { convert } from "../../utils/convert-units-lite";
16
16
  import { Map } from 'immutable';
17
17
  import { formatNumber } from "../../utils/math";
18
- import { isEmpty } from "../../utils/helper"; // variables
18
+ import { isEmpty, updatePayloadOfInternalEvent } from "../../utils/helper"; // variables
19
19
  import { isWarningItem } from "./utils";
20
- import { MoldingUtils } from "../../utils/export";
21
- import { useAppContext } from "../../useAppContext";
22
20
  // variables
23
21
  var pinFlag = false;
24
22
  var sFlag = false; //for all object move
@@ -122,22 +120,21 @@ function extractElementData(node) {
122
120
  direct: node.attributes.getNamedItem('data-direct') ? node.attributes.getNamedItem('data-direct').value : 0
123
121
  };
124
122
  }
125
- export default function Viewer2D(_ref) {
123
+ export default function Viewer2D(_ref, _ref2) {
126
124
  var state = _ref.state,
127
125
  width = _ref.width,
128
126
  height = _ref.height,
129
127
  setToolbar = _ref.setToolbar,
130
128
  replaceCabinet = _ref.replaceCabinet,
131
129
  onInternalEvent = _ref.onInternalEvent;
132
- var _useAppContext = useAppContext(),
133
- viewer2DActions = _useAppContext.viewer2DActions,
134
- linesActions = _useAppContext.linesActions,
135
- holesActions = _useAppContext.holesActions,
136
- verticesActions = _useAppContext.verticesActions,
137
- itemsActions = _useAppContext.itemsActions,
138
- areaActions = _useAppContext.areaActions,
139
- projectActions = _useAppContext.projectActions,
140
- catalog = _useAppContext.catalog;
130
+ var viewer2DActions = _ref2.viewer2DActions,
131
+ linesActions = _ref2.linesActions,
132
+ holesActions = _ref2.holesActions,
133
+ verticesActions = _ref2.verticesActions,
134
+ itemsActions = _ref2.itemsActions,
135
+ areaActions = _ref2.areaActions,
136
+ projectActions = _ref2.projectActions,
137
+ catalog = _ref2.catalog;
141
138
  var _useState = useState(null),
142
139
  _useState2 = _slicedToArray(_useState, 2),
143
140
  rulerEdit = _useState2[0],
@@ -160,26 +157,6 @@ export default function Viewer2D(_ref) {
160
157
  _useState8 = _slicedToArray(_useState7, 2),
161
158
  drawStart = _useState8[0],
162
159
  setdrawStart = _useState8[1];
163
- var _useState9 = useState(function () {
164
- return viewer2D && !viewer2D.isEmpty() ? viewer2D.toJS() : INITIAL_VALUE;
165
- }),
166
- _useState0 = _slicedToArray(_useState9, 2),
167
- svgValue = _useState0[0],
168
- setSvgValue = _useState0[1];
169
- var _useState1 = useState(function () {
170
- return mode2Tool(mode);
171
- }),
172
- _useState10 = _slicedToArray(_useState1, 2),
173
- svgTool = _useState10[0],
174
- setSvgTool = _useState10[1];
175
- useEffect(function () {
176
- // keep tool controlled from app mode
177
- setSvgTool(mode2Tool(mode));
178
- }, [mode]);
179
- useEffect(function () {
180
- // keep value controlled from store, but never null
181
- if (viewer2D && !viewer2D.isEmpty()) setSvgValue(viewer2D.toJS());
182
- }, [viewer2D]);
183
160
  useEffect(function () {
184
161
  // move viewer point to center
185
162
  var selectedLayer = state.scene.layers.get(state.scene.selectedLayer);
@@ -204,9 +181,9 @@ export default function Viewer2D(_ref) {
204
181
  var layerID = scene.selectedLayer;
205
182
  var wall_thickness = LINE_THICKNESS / 2;
206
183
  var layer = scene.getIn(['layers', layerID]);
207
- var mapCursorPosition = function mapCursorPosition(_ref2) {
208
- var x = _ref2.x,
209
- y = _ref2.y;
184
+ var mapCursorPosition = function mapCursorPosition(_ref3) {
185
+ var x = _ref3.x,
186
+ y = _ref3.y;
210
187
  return {
211
188
  x: x,
212
189
  y: -y + scene.height
@@ -855,15 +832,17 @@ export default function Viewer2D(_ref) {
855
832
  var onMouseUp = function onMouseUp(viewerEvent) {
856
833
  //set move all flag false
857
834
  sFlag = false;
858
- // //////////////////////
859
- // setRulerEdit(null);
860
835
  var event = viewerEvent.originalEvent;
861
- var bbox = event.target.getBoundingClientRect();
836
+ var parent = document.querySelector('#kitchen-simulator-container');
837
+ var targetRect = event.target.getBoundingClientRect();
838
+ var parentRect = parent.getBoundingClientRect();
839
+ var left = targetRect.left - parentRect.left;
840
+ var top = targetRect.top - parentRect.top;
841
+ left = left - (200 - targetRect.width) / 2;
842
+ top = top - (50 - targetRect.height) / 2;
862
843
  if (!mode.includes('ING')) {
863
844
  setToolbar('');
864
845
  }
865
- // bbox.width = event.target.getBBox().width;
866
- // bbox.height = event.target.getBBox().height;
867
846
  if (event.target.tagName === 'rect') {
868
847
  if (event.target.id) {
869
848
  setRulerEditID(event.target.id);
@@ -995,8 +974,8 @@ export default function Viewer2D(_ref) {
995
974
  id: "ruler_numberInput",
996
975
  style: {
997
976
  position: 'absolute',
998
- left: bbox.left - (150 - bbox.width) / 2,
999
- top: bbox.top - (50 - bbox.height) / 2,
977
+ left: left,
978
+ top: top,
1000
979
  zIndex: 1000
1001
980
  }
1002
981
  }, /*#__PURE__*/React.createElement(FormNumberInput, {
@@ -1027,8 +1006,8 @@ export default function Viewer2D(_ref) {
1027
1006
  id: "ruler_numberInput",
1028
1007
  style: {
1029
1008
  position: 'absolute',
1030
- left: bbox.left - (150 - bbox.width) / 2,
1031
- top: bbox.top - (50 - bbox.height) / 2,
1009
+ left: left,
1010
+ top: top,
1032
1011
  zIndex: 1000
1033
1012
  }
1034
1013
  }, /*#__PURE__*/React.createElement(FormNumberInput, {
@@ -1060,8 +1039,8 @@ export default function Viewer2D(_ref) {
1060
1039
  id: "ruler_numberInput",
1061
1040
  style: {
1062
1041
  position: 'absolute',
1063
- left: bbox.left - (150 - bbox.width) / 2,
1064
- top: bbox.top - (50 - bbox.height) / 2,
1042
+ left: left,
1043
+ top: top,
1065
1044
  zIndex: 1000
1066
1045
  }
1067
1046
  }, /*#__PURE__*/React.createElement(FormNumberInput, {
@@ -1093,8 +1072,8 @@ export default function Viewer2D(_ref) {
1093
1072
  id: "ruler_numberInput",
1094
1073
  style: {
1095
1074
  position: 'absolute',
1096
- left: bbox.left - (150 - bbox.width) / 2,
1097
- top: bbox.top - (50 - bbox.height) / 2,
1075
+ left: left,
1076
+ top: top,
1098
1077
  zIndex: 1000
1099
1078
  }
1100
1079
  }, /*#__PURE__*/React.createElement(FormNumberInput, {
@@ -1126,8 +1105,8 @@ export default function Viewer2D(_ref) {
1126
1105
  id: "ruler_numberInput",
1127
1106
  style: {
1128
1107
  position: 'absolute',
1129
- left: bbox.left - (150 - bbox.width) / 2,
1130
- top: bbox.top - (50 - bbox.height) / 2,
1108
+ left: left,
1109
+ top: top,
1131
1110
  zIndex: 1000
1132
1111
  }
1133
1112
  }, /*#__PURE__*/React.createElement(FormNumberInput, {
@@ -1159,8 +1138,8 @@ export default function Viewer2D(_ref) {
1159
1138
  id: "ruler_numberInput",
1160
1139
  style: {
1161
1140
  position: 'absolute',
1162
- left: bbox.left - (150 - bbox.width) / 2,
1163
- top: bbox.top - (50 - bbox.height) / 2,
1141
+ left: left,
1142
+ top: top,
1164
1143
  zIndex: 1000
1165
1144
  }
1166
1145
  }, /*#__PURE__*/React.createElement(FormNumberInput, {
@@ -1191,8 +1170,8 @@ export default function Viewer2D(_ref) {
1191
1170
  id: "ruler_numberInput",
1192
1171
  style: {
1193
1172
  position: 'absolute',
1194
- left: bbox.left - (150 - bbox.width) / 2,
1195
- top: bbox.top - (50 - bbox.height) / 2,
1173
+ left: left,
1174
+ top: top,
1196
1175
  zIndex: 1000
1197
1176
  }
1198
1177
  }, /*#__PURE__*/React.createElement(FormNumberInput, {
@@ -1273,24 +1252,7 @@ export default function Viewer2D(_ref) {
1273
1252
  _currentObject = state.getIn(['scene', 'layers', layerID, elementPrototype, elementID]);
1274
1253
  }
1275
1254
  if (_currentObject) {
1276
- var _currentObject3, _currentObject4, _currentObject5;
1277
- var payload = (_currentObject3 = _currentObject) === null || _currentObject3 === void 0 ? void 0 : _currentObject3.toJS();
1278
- if (((_currentObject4 = _currentObject) === null || _currentObject4 === void 0 ? void 0 : _currentObject4.prototype) === 'lines') {
1279
- // caculating length of selected line//
1280
- var v_a = layer.vertices.get(_currentObject.vertices.get(0));
1281
- var v_b = layer.vertices.get(_currentObject.vertices.get(1));
1282
- var distance = GeometryUtils.pointsDistance(v_a.x, v_a.y, v_b.x, v_b.y);
1283
- var _length3 = convert(distance).from('cm').to('in');
1284
- payload.length = _length3;
1285
- //////////////////////////////////////
1286
- } else if (((_currentObject5 = _currentObject) === null || _currentObject5 === void 0 ? void 0 : _currentObject5.prototype) === 'items') {
1287
- // check this cabinet has warning box
1288
- payload.isWarning = isWarningItem(_currentObject);
1289
- // check this item is available molding
1290
- payload.isMoldingAvailable = MoldingUtils.isEnableItemForMolding(layer, _currentObject);
1291
- // check this item is snapped to wall
1292
- payload.isAttachedWall = MoldingUtils.isAttachedWall(layer, _currentObject);
1293
- }
1255
+ var payload = updatePayloadOfInternalEvent(_currentObject, layer, catalog);
1294
1256
 
1295
1257
  // send selection event befor replace event
1296
1258
  if (internalType === constants.INTERNAL_EVENT_REPLACE_CABINET) {
@@ -1309,7 +1271,6 @@ export default function Viewer2D(_ref) {
1309
1271
  };
1310
1272
  var onChangeValue = function onChangeValue(value) {
1311
1273
  if (sFlag) return;
1312
- setSvgValue(value);
1313
1274
  var _zoomValue = parseInt((value.a - 0.5) / constants.ZOOM_VARIABLE);
1314
1275
  if (_zoomValue > constants.MAX_ZOOM_IN_SCALE) return;
1315
1276
  if (_zoomValue < 0 || Number.isNaN(_zoomValue)) return;
@@ -1322,8 +1283,6 @@ export default function Viewer2D(_ref) {
1322
1283
  var bbox;
1323
1284
  if (_rect && _rulerEdit) {
1324
1285
  bbox = _rect.getBoundingClientRect();
1325
- // bbox.width = _rect.getBBox().width;
1326
- // bbox.height = _rect.getBBox().height;
1327
1286
  _rulerEdit.style.left = "".concat(bbox.left - (150 - bbox.width) / 2, "px");
1328
1287
  _rulerEdit.style.top = "".concat(bbox.top - (50 - bbox.height) / 2, "px");
1329
1288
  }
@@ -1341,7 +1300,6 @@ export default function Viewer2D(_ref) {
1341
1300
  }
1342
1301
  };
1343
1302
  var onChangeTool = function onChangeTool(tool) {
1344
- setSvgTool(tool);
1345
1303
  switch (tool) {
1346
1304
  case TOOL_NONE:
1347
1305
  projectActions.selectToolEdit();
@@ -1440,20 +1398,19 @@ export default function Viewer2D(_ref) {
1440
1398
  },
1441
1399
  width: width - rulerSize,
1442
1400
  height: height - rulerSize,
1443
- value: svgValue,
1444
- tool: svgTool,
1401
+ value: viewer2D.isEmpty() ? null : viewer2D.toJS(),
1445
1402
  onChangeValue: onChangeValue,
1403
+ tool: mode2Tool(mode),
1446
1404
  onChangeTool: onChangeTool,
1447
1405
  detectAutoPan: mode2DetectAutopan(mode),
1448
1406
  onMouseDown: onMouseDown,
1449
1407
  onMouseMove: onMouseMove,
1450
1408
  onMouseUp: onMouseUp,
1409
+ miniaturePosition: "none",
1410
+ toolbarPosition: "none",
1451
1411
  detectPinchGesture: false,
1452
1412
  disableDoubleClickZoomWithToolAuto: true,
1453
- ref: Viewer,
1454
- toolbarProps: {
1455
- position: POSITION_NONE
1456
- }
1413
+ ref: Viewer
1457
1414
  }, /*#__PURE__*/React.createElement("svg", {
1458
1415
  width: scene.width,
1459
1416
  height: scene.height
@@ -1488,4 +1445,14 @@ Viewer2D.propTypes = {
1488
1445
  state: PropTypes.object.isRequired,
1489
1446
  width: PropTypes.number.isRequired,
1490
1447
  height: PropTypes.number.isRequired
1448
+ };
1449
+ Viewer2D.contextTypes = {
1450
+ viewer2DActions: PropTypes.object.isRequired,
1451
+ linesActions: PropTypes.object.isRequired,
1452
+ holesActions: PropTypes.object.isRequired,
1453
+ verticesActions: PropTypes.object.isRequired,
1454
+ itemsActions: PropTypes.object.isRequired,
1455
+ areaActions: PropTypes.object.isRequired,
1456
+ projectActions: PropTypes.object.isRequired,
1457
+ catalog: PropTypes.object.isRequired
1491
1458
  };