kitchen-simulator 4.1.7-react-18 → 4.2.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 (206) hide show
  1. package/README.md +3 -0
  2. package/es/AppContext.js +1 -1
  3. package/es/LiteKitchenConfigurator.js +171 -111
  4. package/es/LiteRenderer.js +161 -129
  5. package/es/actions/export.js +25 -12
  6. package/es/actions/project-actions.js +2 -1
  7. package/es/assets/gltf/door_sliding.bin +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/factories/area-factory-3d.js +17 -17
  11. package/es/catalog/factories/wall-factory.js +1 -1
  12. package/es/catalog/holes/window-clear/planner-element.js +2 -2
  13. package/es/catalog/properties/export.js +21 -0
  14. package/es/catalog/properties/property-checkbox.js +68 -0
  15. package/es/catalog/properties/property-color.js +39 -0
  16. package/es/catalog/properties/property-enum.js +50 -0
  17. package/es/catalog/properties/property-hidden.js +19 -0
  18. package/es/catalog/properties/property-lenght-measure.js +100 -0
  19. package/es/catalog/properties/property-length-measure.js +84 -0
  20. package/es/catalog/properties/property-length-measure_hole.js +100 -0
  21. package/es/catalog/properties/property-number.js +48 -0
  22. package/es/catalog/properties/property-read-only.js +26 -0
  23. package/es/catalog/properties/property-string.js +48 -0
  24. package/es/catalog/properties/property-toggle.js +39 -0
  25. package/es/catalog/properties/shared-property-style.js +14 -0
  26. package/es/catalog/utils/exporter.js +24 -11
  27. package/es/catalog/utils/item-loader.js +224 -220
  28. package/es/class/hole.js +0 -2
  29. package/es/class/item.js +92 -70
  30. package/es/class/layer.js +1 -1
  31. package/es/class/line.js +4 -8
  32. package/es/class/project.js +96 -81
  33. package/es/components/content.js +10 -93
  34. package/es/components/export.js +4 -6
  35. package/es/components/style/button.js +106 -0
  36. package/es/components/style/cancel-button.js +21 -0
  37. package/es/components/style/content-container.js +30 -0
  38. package/es/components/style/content-title.js +25 -0
  39. package/es/components/style/delete-button.js +24 -0
  40. package/es/components/style/export.js +28 -2
  41. package/es/components/style/form-block.js +20 -0
  42. package/es/components/style/form-color-input.js +26 -0
  43. package/es/components/style/form-label.js +22 -0
  44. package/es/components/style/form-number-input.js +29 -29
  45. package/es/components/style/form-number-input_2.js +200 -0
  46. package/es/components/style/form-select.js +19 -0
  47. package/es/components/style/form-slider.js +60 -0
  48. package/es/components/style/form-submit-button.js +25 -0
  49. package/es/components/style/form-text-input.js +69 -0
  50. package/es/components/viewer2d/grids/grid-streak.js +1 -1
  51. package/es/components/viewer2d/group.js +5 -4
  52. package/es/components/viewer2d/item.js +155 -359
  53. package/es/components/viewer2d/layer.js +1 -1
  54. package/es/components/viewer2d/line.js +22 -54
  55. package/es/components/viewer2d/ruler.js +16 -11
  56. package/es/components/viewer2d/rulerDist.js +38 -51
  57. package/es/components/viewer2d/rulerX.js +4 -2
  58. package/es/components/viewer2d/rulerY.js +3 -0
  59. package/es/components/viewer2d/scene.js +17 -12
  60. package/es/components/viewer2d/state.js +1 -1
  61. package/es/components/viewer2d/utils.js +2 -2
  62. package/es/components/viewer2d/vertex.js +3 -2
  63. package/es/components/viewer2d/viewer2d.js +81 -118
  64. package/es/components/viewer3d/front3D.js +13 -1
  65. package/es/components/viewer3d/ruler-utils/scene3D.js +1 -1
  66. package/es/components/viewer3d/scene-creator.js +270 -69
  67. package/es/components/viewer3d/viewer3d-first-person.js +26 -32
  68. package/es/components/viewer3d/viewer3d.js +110 -130
  69. package/es/constants.js +7 -2
  70. package/es/devLiteRenderer.js +491 -150
  71. package/es/index.js +589 -62
  72. package/es/models.js +13 -8
  73. package/es/plugins/SVGLoader.js +1414 -0
  74. package/es/plugins/console-debugger.js +34 -0
  75. package/es/plugins/export.js +7 -0
  76. package/es/plugins/keyboard.js +110 -0
  77. package/es/reducers/project-reducer.js +4 -1
  78. package/es/reducers/viewer2d-reducer.js +3 -1
  79. package/es/reducers/viewer3d-reducer.js +3 -1
  80. package/es/styles/export.js +5 -0
  81. package/es/styles/tabs.css +40 -0
  82. package/es/utils/geometry.js +77 -119
  83. package/es/utils/helper.js +38 -1
  84. package/es/utils/isolate-event-handler.js +829 -609
  85. package/es/utils/molding.js +459 -11
  86. package/es/utils/ruler.js +58 -0
  87. package/lib/AppContext.js +1 -1
  88. package/lib/LiteKitchenConfigurator.js +170 -111
  89. package/lib/LiteRenderer.js +160 -129
  90. package/lib/actions/export.js +35 -39
  91. package/lib/actions/project-actions.js +2 -1
  92. package/lib/assets/gltf/door_sliding.bin +0 -0
  93. package/lib/assets/img/svg/bottombar/elevation.svg +12 -5
  94. package/lib/catalog/catalog.js +20 -4
  95. package/lib/catalog/factories/area-factory-3d.js +14 -14
  96. package/lib/catalog/factories/wall-factory.js +1 -1
  97. package/lib/catalog/holes/window-clear/planner-element.js +2 -2
  98. package/lib/catalog/properties/export.js +81 -0
  99. package/lib/catalog/properties/property-checkbox.js +76 -0
  100. package/lib/catalog/properties/property-color.js +47 -0
  101. package/lib/catalog/properties/property-enum.js +58 -0
  102. package/lib/catalog/properties/property-hidden.js +27 -0
  103. package/lib/catalog/properties/property-lenght-measure.js +108 -0
  104. package/lib/catalog/properties/property-length-measure.js +92 -0
  105. package/lib/catalog/properties/property-length-measure_hole.js +108 -0
  106. package/lib/catalog/properties/property-number.js +56 -0
  107. package/lib/catalog/properties/property-read-only.js +34 -0
  108. package/lib/catalog/properties/property-string.js +56 -0
  109. package/lib/catalog/properties/property-toggle.js +47 -0
  110. package/lib/catalog/properties/shared-property-style.js +21 -0
  111. package/lib/catalog/utils/exporter.js +24 -11
  112. package/lib/catalog/utils/item-loader.js +221 -217
  113. package/lib/class/hole.js +0 -2
  114. package/lib/class/item.js +90 -68
  115. package/lib/class/layer.js +1 -1
  116. package/lib/class/line.js +3 -7
  117. package/lib/class/project.js +96 -81
  118. package/lib/components/content.js +10 -93
  119. package/lib/components/export.js +6 -26
  120. package/lib/components/style/button.js +115 -0
  121. package/lib/components/style/cancel-button.js +29 -0
  122. package/lib/components/style/content-container.js +38 -0
  123. package/lib/components/style/content-title.js +35 -0
  124. package/lib/components/style/delete-button.js +34 -0
  125. package/lib/components/style/export.js +105 -1
  126. package/lib/components/style/form-block.js +28 -0
  127. package/lib/components/style/form-color-input.js +34 -0
  128. package/lib/components/style/form-label.js +30 -0
  129. package/lib/components/style/form-number-input.js +29 -29
  130. package/lib/components/style/form-number-input_2.js +209 -0
  131. package/lib/components/style/form-select.js +29 -0
  132. package/lib/components/style/form-slider.js +68 -0
  133. package/lib/components/style/form-submit-button.js +35 -0
  134. package/lib/components/style/form-text-input.js +78 -0
  135. package/lib/components/viewer2d/grids/grid-streak.js +1 -1
  136. package/lib/components/viewer2d/group.js +5 -4
  137. package/lib/components/viewer2d/item.js +152 -356
  138. package/lib/components/viewer2d/layer.js +1 -1
  139. package/lib/components/viewer2d/line.js +22 -54
  140. package/lib/components/viewer2d/ruler.js +15 -10
  141. package/lib/components/viewer2d/rulerDist.js +38 -51
  142. package/lib/components/viewer2d/rulerX.js +4 -2
  143. package/lib/components/viewer2d/rulerY.js +3 -0
  144. package/lib/components/viewer2d/scene.js +17 -12
  145. package/lib/components/viewer2d/state.js +1 -1
  146. package/lib/components/viewer2d/utils.js +2 -2
  147. package/lib/components/viewer2d/vertex.js +3 -2
  148. package/lib/components/viewer2d/viewer2d.js +79 -115
  149. package/lib/components/viewer3d/front3D.js +13 -1
  150. package/lib/components/viewer3d/ruler-utils/scene3D.js +1 -1
  151. package/lib/components/viewer3d/scene-creator.js +267 -66
  152. package/lib/components/viewer3d/viewer3d-first-person.js +26 -32
  153. package/lib/components/viewer3d/viewer3d.js +107 -126
  154. package/lib/constants.js +12 -7
  155. package/lib/devLiteRenderer.js +489 -148
  156. package/lib/index.js +591 -62
  157. package/lib/models.js +13 -8
  158. package/lib/plugins/SVGLoader.js +1419 -0
  159. package/lib/plugins/console-debugger.js +42 -0
  160. package/lib/plugins/export.js +25 -0
  161. package/lib/plugins/keyboard.js +117 -0
  162. package/lib/reducers/project-reducer.js +4 -1
  163. package/lib/reducers/viewer2d-reducer.js +3 -1
  164. package/lib/reducers/viewer3d-reducer.js +3 -1
  165. package/lib/styles/export.js +13 -0
  166. package/lib/styles/tabs.css +40 -0
  167. package/lib/utils/geometry.js +77 -119
  168. package/lib/utils/helper.js +40 -1
  169. package/lib/utils/isolate-event-handler.js +829 -608
  170. package/lib/utils/molding.js +460 -9
  171. package/lib/utils/ruler.js +63 -0
  172. package/package.json +21 -20
  173. package/es/mocks/appliancePayload.json +0 -27
  174. package/es/mocks/cabinetPayload.json +0 -1914
  175. package/es/mocks/cabinetPayload2.json +0 -76
  176. package/es/mocks/dataBundle2.json +0 -4
  177. package/es/mocks/distancePayload.json +0 -6
  178. package/es/mocks/doorStylePayload2.json +0 -84
  179. package/es/mocks/furnishingPayload.json +0 -23
  180. package/es/mocks/itemCDSPayload.json +0 -27
  181. package/es/mocks/lightingPayload.json +0 -23
  182. package/es/mocks/mockProps.json +0 -43
  183. package/es/mocks/mockProps2.json +0 -9
  184. package/es/mocks/moldingPayload.json +0 -19
  185. package/es/mocks/projectItemsCatalog.json +0 -133
  186. package/es/mocks/rectangleShape.json +0 -238
  187. package/es/mocks/replaceCabinetPayload.json +0 -81
  188. package/es/mocks/roomShapePayload.json +0 -5
  189. package/es/useAppContext.js +0 -8
  190. package/lib/mocks/appliancePayload.json +0 -27
  191. package/lib/mocks/cabinetPayload.json +0 -1914
  192. package/lib/mocks/cabinetPayload2.json +0 -76
  193. package/lib/mocks/dataBundle2.json +0 -4
  194. package/lib/mocks/distancePayload.json +0 -6
  195. package/lib/mocks/doorStylePayload2.json +0 -84
  196. package/lib/mocks/furnishingPayload.json +0 -23
  197. package/lib/mocks/itemCDSPayload.json +0 -27
  198. package/lib/mocks/lightingPayload.json +0 -23
  199. package/lib/mocks/mockProps.json +0 -43
  200. package/lib/mocks/mockProps2.json +0 -9
  201. package/lib/mocks/moldingPayload.json +0 -19
  202. package/lib/mocks/projectItemsCatalog.json +0 -133
  203. package/lib/mocks/rectangleShape.json +0 -238
  204. package/lib/mocks/replaceCabinetPayload.json +0 -81
  205. package/lib/mocks/roomShapePayload.json +0 -5
  206. package/lib/useAppContext.js +0 -16
@@ -0,0 +1,26 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
+ var _excluded = ["onChange"];
4
+ import React from 'react';
5
+ import FormTextInput from "./form-text-input";
6
+ var STYLE = {
7
+ padding: 0,
8
+ border: 0
9
+ };
10
+ var EREG_NUMBER = /^.*$/;
11
+ export default function FormColorInput(_ref) {
12
+ var onChange = _ref.onChange,
13
+ rest = _objectWithoutProperties(_ref, _excluded);
14
+ var onChangeCustom = function onChangeCustom(event) {
15
+ var value = event.target.value;
16
+ if (EREG_NUMBER.test(value)) {
17
+ onChange(event);
18
+ }
19
+ };
20
+ return /*#__PURE__*/React.createElement(FormTextInput, _extends({
21
+ type: "color",
22
+ style: STYLE,
23
+ onChange: onChangeCustom,
24
+ autoComplete: "off"
25
+ }, rest));
26
+ }
@@ -0,0 +1,22 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
3
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
4
+ var _excluded = ["children", "style"];
5
+ 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; }
6
+ 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; }
7
+ import React from 'react';
8
+ var BASE_STYLE = {
9
+ display: 'block',
10
+ marginBottom: '2px',
11
+ fontSize: '12px'
12
+ };
13
+ export default function FormLabel(_ref) {
14
+ var children = _ref.children,
15
+ style = _ref.style,
16
+ rest = _objectWithoutProperties(_ref, _excluded);
17
+ return /*#__PURE__*/React.createElement("label", _extends({
18
+ style: _objectSpread(_objectSpread({}, BASE_STYLE), {}, {
19
+ style: style
20
+ })
21
+ }, rest), children);
22
+ }
@@ -3,16 +3,16 @@ import _createClass from "@babel/runtime/helpers/esm/createClass";
3
3
  import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
4
4
  import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
5
5
  import _inherits from "@babel/runtime/helpers/esm/inherits";
6
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
7
- 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; }
8
- 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; }
6
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
7
+ var _templateObject;
9
8
  function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
10
9
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
11
10
  import React, { Component } from 'react';
12
11
  import PropTypes from 'prop-types';
13
12
  import { KEYBOARD_BUTTON_CODE, TEXT_COLOR_NEUTRAL_0, SECONDARY_PURPLE_COLOR, DEFAULT_FONT_FAMILY } from "../../constants";
13
+ import styled from 'styled-components';
14
14
  import { isValidNumber } from "../../utils/helper";
15
- import AppContext from "../../AppContext";
15
+ var StyledInput = styled.input(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: block;\n padding: 15px 25px 12px 0px;\n width: 120px;\n color: ", ";\n background-color: rgb(255, 255, 255);\n border: 2px solid;\n text-align: right;\n float: right;\n font-family: ", ";\n font-size: 16px;\n font-weight: 600;\n line-height: 17px;\n border-radius: 5px;\n outline: 0;\n :focus {\n border-color: ", ";\n }\n"])), TEXT_COLOR_NEUTRAL_0, DEFAULT_FONT_FAMILY, SECONDARY_PURPLE_COLOR);
16
16
  var FormNumberInput = /*#__PURE__*/function (_Component) {
17
17
  function FormNumberInput(props, context) {
18
18
  var _this;
@@ -30,14 +30,26 @@ var FormNumberInput = /*#__PURE__*/function (_Component) {
30
30
  }
31
31
  _inherits(FormNumberInput, _Component);
32
32
  return _createClass(FormNumberInput, [{
33
- key: "componentDidUpdate",
34
- value: function componentDidUpdate(prevProps) {
35
- if (this.props.value !== prevProps.value || this.props.focus !== prevProps.focus) {
33
+ key: "componentDidMount",
34
+ value: function componentDidMount() {
35
+ if (this.input.current && ['width', 'length'].includes(this.props.labelName.toLowerCase())) {
36
+ this.input.current.focus();
37
+ this.input.current.select();
38
+ }
39
+ }
40
+ }, {
41
+ key: "componentWillReceiveProps",
42
+ value: function componentWillReceiveProps(nextProps) {
43
+ if (this.props.value !== nextProps.value || this.props.focus !== nextProps.focus) {
36
44
  this.setState({
37
- showedValue: this.props.value,
38
- focusOn: this.props.focus
45
+ showedValue: nextProps.value,
46
+ focusOn: nextProps.focus
39
47
  });
40
48
  }
49
+ }
50
+ }, {
51
+ key: "componentDidUpdate",
52
+ value: function componentDidUpdate(prevProps, preprevState) {
41
53
  if (this.props.value !== prevProps.value && prevProps.labelName !== 'Ceiling Height') {
42
54
  this.input.current.focus();
43
55
  this.input.current.select();
@@ -58,6 +70,7 @@ var FormNumberInput = /*#__PURE__*/function (_Component) {
58
70
  });
59
71
  }
60
72
  }
73
+ return null;
61
74
  }
62
75
  }, {
63
76
  key: "render",
@@ -91,30 +104,13 @@ var FormNumberInput = /*#__PURE__*/function (_Component) {
91
104
  });
92
105
  }
93
106
  };
94
- var baseInputStyle = {
95
- display: 'block',
96
- padding: '15px 25px 12px 0px',
97
- width: '120px',
98
- color: TEXT_COLOR_NEUTRAL_0,
99
- backgroundColor: 'rgb(255, 255, 255)',
100
- border: '2px solid',
101
- textAlign: 'right',
102
- "float": 'right',
103
- fontFamily: DEFAULT_FONT_FAMILY,
104
- fontSize: '16px',
105
- fontWeight: 600,
106
- lineHeight: '17px',
107
- borderRadius: '5px',
108
- outline: 0,
109
- borderColor: this.state.focusOn ? SECONDARY_PURPLE_COLOR : undefined
110
- };
111
- return /*#__PURE__*/React.createElement("input", {
107
+ return /*#__PURE__*/React.createElement(StyledInput, {
112
108
  id: "form_number_input",
113
109
  autoFocus: this.state.focusOn,
114
110
  readOnly: !!this.props.disabled,
115
111
  type: "text",
116
112
  value: currValue,
117
- style: _objectSpread(_objectSpread({}, baseInputStyle), style),
113
+ style: style,
118
114
  onChange: function onChange(evt) {
119
115
  _this2.context.projectActions.copyProperties('ddddd');
120
116
  var valid = regexp.test(evt.nativeEvent.target.value);
@@ -157,7 +153,6 @@ var FormNumberInput = /*#__PURE__*/function (_Component) {
157
153
  }
158
154
  }]);
159
155
  }(Component);
160
- _defineProperty(FormNumberInput, "contextType", AppContext);
161
156
  export { FormNumberInput as default };
162
157
  FormNumberInput.propTypes = {
163
158
  value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
@@ -172,6 +167,11 @@ FormNumberInput.propTypes = {
172
167
  labelName: PropTypes.string,
173
168
  isCeiling: PropTypes.string
174
169
  };
170
+ FormNumberInput.contextTypes = {
171
+ translator: PropTypes.object.isRequired,
172
+ projectActions: PropTypes.object.isRequired,
173
+ linesActions: PropTypes.object.isRequired
174
+ };
175
175
  FormNumberInput.defaultProps = {
176
176
  value: 0,
177
177
  style: {},
@@ -0,0 +1,200 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
4
+ import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
5
+ import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
6
+ import _inherits from "@babel/runtime/helpers/esm/inherits";
7
+ 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; }
8
+ 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; }
9
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
10
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
11
+ import React, { Component } from 'react';
12
+ import PropTypes from 'prop-types';
13
+ import * as SharedStyle from "../../shared-style";
14
+ import { MdUpdate } from 'react-icons/md';
15
+ import { KEYBOARD_BUTTON_CODE } from "../../constants";
16
+ var STYLE_INPUT = {
17
+ display: 'block',
18
+ width: '100%',
19
+ padding: '0 2px',
20
+ fontSize: '13px',
21
+ lineHeight: '1.25',
22
+ color: SharedStyle.PRIMARY_COLOR.input,
23
+ backgroundColor: SharedStyle.COLORS.white,
24
+ backgroundImage: 'none',
25
+ border: '1px solid rgba(0,0,0,.15)',
26
+ outline: 'none',
27
+ height: '30px'
28
+ };
29
+ var confirmStyle = {
30
+ position: 'absolute',
31
+ cursor: 'pointer',
32
+ width: '20px',
33
+ height: '20px',
34
+ right: '5px',
35
+ top: '5px',
36
+ backgroundColor: SharedStyle.SECONDARY_COLOR.main,
37
+ color: '#FFF',
38
+ transition: 'all 0.1s linear'
39
+ };
40
+ var FormNumberInput = /*#__PURE__*/function (_Component) {
41
+ function FormNumberInput(props, context) {
42
+ var _this;
43
+ _classCallCheck(this, FormNumberInput);
44
+ _this = _callSuper(this, FormNumberInput, [props, context]);
45
+ _this.state = {
46
+ focus: false,
47
+ valid: true,
48
+ showedValue: props.value,
49
+ disabled: props.disabled === true ? true : false,
50
+ focusOn: false
51
+ };
52
+ return _this;
53
+ }
54
+ _inherits(FormNumberInput, _Component);
55
+ return _createClass(FormNumberInput, [{
56
+ key: "componentWillReceiveProps",
57
+ value: function componentWillReceiveProps(nextProps) {
58
+ if (this.props.value !== nextProps.value || this.props.focus !== nextProps.focus) {
59
+ this.setState({
60
+ showedValue: nextProps.value,
61
+ focusOn: nextProps.focus
62
+ });
63
+ }
64
+ if (this.props.focus !== nextProps.focus) {
65
+ this.Input.focus();
66
+ this.Input.select();
67
+ }
68
+ }
69
+ }, {
70
+ key: "render",
71
+ value: function render() {
72
+ var _this2 = this;
73
+ var _this$props = this.props,
74
+ value = _this$props.value,
75
+ min = _this$props.min,
76
+ max = _this$props.max,
77
+ precision = _this$props.precision,
78
+ onChange = _this$props.onChange,
79
+ onValid = _this$props.onValid,
80
+ onInvalid = _this$props.onInvalid,
81
+ style = _this$props.style,
82
+ placeholder = _this$props.placeholder;
83
+ var numericInputStyle = _objectSpread(_objectSpread({}, STYLE_INPUT), style);
84
+ if (this.state.focusOn) numericInputStyle.border = "1px solid ".concat(SharedStyle.SECONDARY_COLOR.main);
85
+ var regexp = new RegExp("^-?([0-9]+)?\\.?([0-9]{0,".concat(precision, "})?$"));
86
+ if (!isNaN(min) && isFinite(min) && this.state.showedValue < min) this.setState({
87
+ showedValue: min
88
+ }); // value = min;
89
+ if (!isNaN(max) && isFinite(max) && this.state.showedValue > max) this.setState({
90
+ showedValue: max
91
+ }); // value = max;
92
+
93
+ var currValue = regexp.test(this.state.showedValue) ? this.state.showedValue : parseFloat(this.state.showedValue).toFixed(precision);
94
+ var different = parseFloat(this.props.value).toFixed(precision) !== parseFloat(this.state.showedValue).toFixed(precision);
95
+ var saveFn = function saveFn(e) {
96
+ e.stopPropagation();
97
+ if (_this2.state.valid) {
98
+ var savedValue = _this2.state.showedValue !== '' && _this2.state.showedValue !== '-' ? parseFloat(_this2.state.showedValue) : 0;
99
+ _this2.setState({
100
+ showedValue: savedValue
101
+ });
102
+ onChange({
103
+ target: {
104
+ value: savedValue
105
+ }
106
+ });
107
+ }
108
+ };
109
+ return /*#__PURE__*/React.createElement("div", {
110
+ style: {
111
+ position: 'relative'
112
+ }
113
+ }, /*#__PURE__*/React.createElement("input", {
114
+ autoFocus: this.state.focusOn,
115
+ readOnly: this.state.disabled,
116
+ type: "text",
117
+ value: currValue,
118
+ style: numericInputStyle,
119
+ onChange: function onChange(evt) {
120
+ var valid = regexp.test(evt.nativeEvent.target.value);
121
+ if (valid) {
122
+ _this2.setState({
123
+ showedValue: evt.nativeEvent.target.value
124
+ });
125
+ if (onValid) onValid(evt.nativeEvent);
126
+ } else {
127
+ if (onInvalid) onInvalid(evt.nativeEvent);
128
+ }
129
+ _this2.setState({
130
+ valid: valid
131
+ });
132
+ },
133
+ onFocus: function onFocus(e) {
134
+ return _this2.setState({
135
+ focusOn: true
136
+ });
137
+ },
138
+ onBlur: function onBlur(e) {
139
+ return _this2.setState({
140
+ focusOn: false
141
+ });
142
+ },
143
+ ref: function ref(ele) {
144
+ _this2.Input = ele;
145
+ },
146
+ onKeyDown: function onKeyDown(e) {
147
+ var keyCode = e.keyCode || e.which;
148
+ if (keyCode == KEYBOARD_BUTTON_CODE.ENTER || keyCode == KEYBOARD_BUTTON_CODE.TAB) {
149
+ saveFn(e);
150
+ _this2.Input.blur();
151
+ }
152
+ if (keyCode == KEYBOARD_BUTTON_CODE.ESC) {
153
+ _this2.context.projectActions.rollback();
154
+ }
155
+ },
156
+ placeholder: placeholder
157
+ }), /*#__PURE__*/React.createElement("div", {
158
+ onClick: function onClick(e) {
159
+ if (different) saveFn(e);
160
+ },
161
+ title: this.context.translator.t('Confirm'),
162
+ style: _objectSpread(_objectSpread({}, confirmStyle), {}, {
163
+ visibility: different ? 'visible' : 'hidden',
164
+ opacity: different ? '1' : '0'
165
+ })
166
+ }, /*#__PURE__*/React.createElement(MdUpdate, {
167
+ style: {
168
+ width: '100%',
169
+ height: '100%',
170
+ padding: '0.2em',
171
+ color: '#FFF'
172
+ }
173
+ })));
174
+ }
175
+ }]);
176
+ }(Component);
177
+ export { FormNumberInput as default };
178
+ FormNumberInput.propTypes = {
179
+ value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
180
+ style: PropTypes.object,
181
+ onChange: PropTypes.func.isRequired,
182
+ onValid: PropTypes.func,
183
+ onInvalid: PropTypes.func,
184
+ min: PropTypes.number,
185
+ max: PropTypes.number,
186
+ precision: PropTypes.number,
187
+ placeholder: PropTypes.string
188
+ };
189
+ FormNumberInput.contextTypes = {
190
+ translator: PropTypes.object.isRequired,
191
+ projectActions: PropTypes.object.isRequired
192
+ };
193
+ FormNumberInput.defaultProps = {
194
+ value: 0,
195
+ style: {},
196
+ min: Number.MIN_SAFE_INTEGER,
197
+ max: Number.MAX_SAFE_INTEGER,
198
+ precision: 2,
199
+ disabled: false
200
+ };
@@ -0,0 +1,19 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
4
+ var _excluded = ["children", "style"];
5
+ var _templateObject;
6
+ import React from 'react';
7
+ import * as SharedStyle from "../../shared-style";
8
+ import styled from 'styled-components';
9
+ import { TEXT_COLOR_NEUTRAL_3, DEFAULT_FONT_FAMILY, SECONDARY_PURPLE_COLOR } from "../../constants";
10
+ var StyledSelect = styled.select(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: block;\n width: 120px;\n float: right;\n padding: 15px 10px 12px 0px;\n color: ", ";\n border: 2px solid;\n font-family: ", ";\n font-size: 12px;\n font-weight: 600;\n line-height: 17px;\n text-align: right;\n outline: none;\n border-radius: 5px;\n :hover {\n border-color: ", ";\n }\n :focus {\n border-color: ", ";\n }\n"])), TEXT_COLOR_NEUTRAL_3, DEFAULT_FONT_FAMILY, SECONDARY_PURPLE_COLOR, SECONDARY_PURPLE_COLOR);
11
+ export default function FormSelect(_ref) {
12
+ var children = _ref.children,
13
+ style = _ref.style,
14
+ rest = _objectWithoutProperties(_ref, _excluded);
15
+ return /*#__PURE__*/React.createElement(StyledSelect, _extends({
16
+ type: "text",
17
+ style: style
18
+ }, rest), children);
19
+ }
@@ -0,0 +1,60 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
+ var _excluded = ["value", "onChange", "min", "max", "step"];
4
+ import React from 'react';
5
+ import FormTextInput from "./form-text-input";
6
+ var sliderContainerStyle = {
7
+ display: 'inline-block',
8
+ width: '80%',
9
+ marginRight: '5%'
10
+ };
11
+ var sliderStyle = {
12
+ display: 'block',
13
+ width: '100%',
14
+ height: '30px'
15
+ };
16
+ var textContainerStyle = {
17
+ display: 'inline-block',
18
+ width: '15%',
19
+ "float": 'right'
20
+ };
21
+ var textStyle = {
22
+ height: '34px',
23
+ textAlign: 'center'
24
+ };
25
+ export default function FormNumberInput(_ref) {
26
+ var value = _ref.value,
27
+ onChange = _ref.onChange,
28
+ _ref$min = _ref.min,
29
+ min = _ref$min === void 0 ? 0 : _ref$min,
30
+ _ref$max = _ref.max,
31
+ max = _ref$max === void 0 ? 100 : _ref$max,
32
+ _ref$step = _ref.step,
33
+ step = _ref$step === void 0 ? 1 : _ref$step,
34
+ rest = _objectWithoutProperties(_ref, _excluded);
35
+ // Handle both slider and text input changes
36
+ var handleSliderChange = function handleSliderChange(e) {
37
+ onChange(Number(e.target.value));
38
+ };
39
+ var handleTextChange = function handleTextChange(e) {
40
+ var val = e.target.value === '' ? '' : Number(e.target.value);
41
+ onChange(val);
42
+ };
43
+ return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
44
+ style: sliderContainerStyle
45
+ }, /*#__PURE__*/React.createElement("input", _extends({
46
+ type: "range",
47
+ style: sliderStyle,
48
+ min: min,
49
+ max: max,
50
+ step: step,
51
+ value: value,
52
+ onChange: handleSliderChange
53
+ }, rest))), /*#__PURE__*/React.createElement("div", {
54
+ style: textContainerStyle
55
+ }, /*#__PURE__*/React.createElement(FormTextInput, {
56
+ value: value,
57
+ onChange: handleTextChange,
58
+ style: textStyle
59
+ })));
60
+ }
@@ -0,0 +1,25 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
+ var _excluded = ["children"];
4
+ import React from 'react';
5
+ import Button from "./button";
6
+ import * as SharedStyle from "../../shared-style";
7
+ var STYLE = {
8
+ borderColor: '#415375',
9
+ backgroundColor: '#415375',
10
+ color: SharedStyle.COLORS.white
11
+ };
12
+ var STYLE_HOVER = {
13
+ borderColor: '#1f3149',
14
+ backgroundColor: '#1f3149',
15
+ color: SharedStyle.COLORS.white
16
+ };
17
+ export default function FormSubmitButton(_ref) {
18
+ var children = _ref.children,
19
+ rest = _objectWithoutProperties(_ref, _excluded);
20
+ return /*#__PURE__*/React.createElement(Button, _extends({
21
+ type: "submit",
22
+ style: STYLE,
23
+ styleHover: STYLE_HOVER
24
+ }, rest), children);
25
+ }
@@ -0,0 +1,69 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
4
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
5
+ import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
6
+ import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
7
+ import _inherits from "@babel/runtime/helpers/esm/inherits";
8
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
9
+ var _excluded = ["style"];
10
+ var _templateObject;
11
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
12
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
13
+ import React, { Component } from 'react';
14
+ import * as SharedStyle from "../../shared-style";
15
+ import { PROJECT_NAME_LENGTH_LIMIT, TEXT_COLOR_NEUTRAL_3, BG_COLOR_0, DEFAULT_FONT_FAMILY, SECONDARY_PURPLE_COLOR } from "../../constants";
16
+ import styled from 'styled-components';
17
+ var StyledInput = styled.input(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: block;\n padding: 15px 10px 12px 0px;\n width: 120px;\n font-family: ", ";\n font-size: 12px;\n font-weight: 600;\n line-height: 17px;\n color: ", ";\n background-color: ", ";\n border: 2px solid;\n text-align: right;\n float: right;\n border-radius: 5px;\n outline: 0;\n :focus {\n border-color: ", ";\n }\n"])), DEFAULT_FONT_FAMILY, TEXT_COLOR_NEUTRAL_3, BG_COLOR_0, SECONDARY_PURPLE_COLOR);
18
+ var FormTextInput = /*#__PURE__*/function (_Component) {
19
+ function FormTextInput(props) {
20
+ var _this;
21
+ _classCallCheck(this, FormTextInput);
22
+ _this = _callSuper(this, FormTextInput, [props]);
23
+ _this.state = {
24
+ focus: false
25
+ };
26
+ _this.input = /*#__PURE__*/React.createRef(null);
27
+ return _this;
28
+ }
29
+ _inherits(FormTextInput, _Component);
30
+ return _createClass(FormTextInput, [{
31
+ key: "componentDidMount",
32
+ value: function componentDidMount() {
33
+ if (this.input.current) {
34
+ this.input.current.select();
35
+ }
36
+ }
37
+ }, {
38
+ key: "render",
39
+ value: function render() {
40
+ var _this2 = this;
41
+ var _this$props = this.props,
42
+ style = _this$props.style,
43
+ rest = _objectWithoutProperties(_this$props, _excluded);
44
+ return /*#__PURE__*/React.createElement(StyledInput, _extends({
45
+ ref: this.input,
46
+ onFocus: function onFocus(e) {
47
+ return _this2.setState({
48
+ focus: true
49
+ });
50
+ },
51
+ onBlur: function onBlur(e) {
52
+ return _this2.setState({
53
+ focus: false
54
+ });
55
+ },
56
+ style: style
57
+ // autoFocus
58
+ ,
59
+ type: "text"
60
+ }, rest, {
61
+ maxLength: PROJECT_NAME_LENGTH_LIMIT
62
+ }));
63
+ }
64
+ }]);
65
+ }(Component);
66
+ export { FormTextInput as default };
67
+ FormTextInput.defaultProps = {
68
+ style: {}
69
+ };
@@ -22,7 +22,7 @@ export default function GridStreak(_ref) {
22
22
  key: i,
23
23
  cx: x,
24
24
  cy: y,
25
- r: 2,
25
+ r: 1.5,
26
26
  fill: color
27
27
  }));
28
28
  }
@@ -2,7 +2,6 @@ import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import If from "../../utils/react-if";
4
4
  import * as sharedStyles from "../../shared-style";
5
- import { useAppContext } from "../../useAppContext";
6
5
  var cx = 0;
7
6
  var cy = 0;
8
7
  var radius = 5;
@@ -11,13 +10,12 @@ var STYLE_CIRCLE = {
11
10
  stroke: sharedStyles.MATERIAL_COLORS[500].orange,
12
11
  cursor: 'default'
13
12
  };
14
- export default function Group(_ref) {
13
+ export default function Group(_ref, _ref2) {
15
14
  var layer = _ref.layer,
16
15
  group = _ref.group,
17
16
  scene = _ref.scene,
18
17
  catalog = _ref.catalog;
19
- var _useAppContext = useAppContext(),
20
- translator = _useAppContext.translator;
18
+ var translator = _ref2.translator;
21
19
  return /*#__PURE__*/React.createElement("g", {
22
20
  "data-element-root": true,
23
21
  "data-prototype": group.prototype,
@@ -49,4 +47,7 @@ Group.propTypes = {
49
47
  layer: PropTypes.object.isRequired,
50
48
  scene: PropTypes.object.isRequired,
51
49
  catalog: PropTypes.object.isRequired
50
+ };
51
+ Group.contextTypes = {
52
+ translator: PropTypes.object.isRequired
52
53
  };