@yorab/react-paint 0.4.2 → 0.5.0

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 (37) hide show
  1. package/README.md +1 -0
  2. package/dist/components/App.js +58 -71
  3. package/dist/components/Canvas.js +9 -9
  4. package/dist/components/common/Button.js +4 -4
  5. package/dist/components/common/Loading.js +3 -3
  6. package/dist/components/common/Modal.js +3 -3
  7. package/dist/components/common/Panel.js +2 -2
  8. package/dist/components/common/Snackbar.js +2 -2
  9. package/dist/components/settings/ColorField.js +9 -9
  10. package/dist/components/settings/FontFamilyField.js +7 -5
  11. package/dist/components/settings/LayoutButton.js +1 -1
  12. package/dist/components/settings/Layouts.js +9 -9
  13. package/dist/components/settings/LineArrowField.js +8 -6
  14. package/dist/components/settings/LineTypeField.js +7 -5
  15. package/dist/components/settings/PointsNumberField.js +19 -29
  16. package/dist/components/settings/RangeField.js +2 -1
  17. package/dist/components/settings/SelectField.js +2 -1
  18. package/dist/components/settings/SettingsBar.js +107 -80
  19. package/dist/components/toolbox/EditTextBox.js +6 -6
  20. package/dist/components/toolbox/LoadFileTool.js +5 -3
  21. package/dist/components/toolbox/MenuGroup.js +31 -40
  22. package/dist/components/toolbox/PictureUrlInput.js +1 -1
  23. package/dist/components/toolbox/Tool.js +4 -4
  24. package/dist/components/toolbox/Toolbar.js +77 -73
  25. package/dist/components/toolbox/ToolbarGroup.js +22 -26
  26. package/dist/constants/style.js +3 -1
  27. package/dist/constants/tools.js +420 -0
  28. package/dist/hooks/useDrawableCanvas.js +22 -17
  29. package/dist/styles.css +51 -52
  30. package/dist/types/Shapes.js +2 -16
  31. package/dist/types/tools.js +22 -0
  32. package/dist/utils/data.js +81 -25
  33. package/dist/utils/style.js +4 -2
  34. package/dist/utils/toolbar.js +66 -11
  35. package/dist/utils/transform.js +3 -3
  36. package/package.json +1 -1
  37. package/Changelog.md +0 -75
@@ -25,27 +25,25 @@ var _Panel = _interopRequireDefault(require("../common/Panel"));
25
25
 
26
26
  var _react2 = require("@linaria/react");
27
27
 
28
- var _Shapes = require("../../types/Shapes");
29
-
30
- var _style = require("../../utils/style");
31
-
32
28
  var _Tool = _interopRequireDefault(require("./Tool"));
33
29
 
34
30
  var _LoadFileTool = _interopRequireDefault(require("./LoadFileTool"));
35
31
 
36
32
  var _icons = require("../../constants/icons");
37
33
 
34
+ var _tools = require("../../constants/tools");
35
+
38
36
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
39
37
 
40
38
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
41
39
 
42
40
  var StyledPanel = /*#__PURE__*/(0, _react2.styled)(_Panel["default"])({
43
41
  name: "StyledPanel",
44
- "class": "s1uphjfh"
42
+ "class": "s1qu0ers"
45
43
  });
46
44
  var StyledRelative = /*#__PURE__*/(0, _react2.styled)("div")({
47
45
  name: "StyledRelative",
48
- "class": "s1e5a6k5"
46
+ "class": "s1y35t9y"
49
47
  });
50
48
 
51
49
  var MenuGroup = function MenuGroup(_ref) {
@@ -75,7 +73,8 @@ var MenuGroup = function MenuGroup(_ref) {
75
73
  togglePictureUrlModal = _ref.togglePictureUrlModal,
76
74
  saveFile = _ref.saveFile,
77
75
  exportCanvasInFile = _ref.exportCanvasInFile,
78
- availableTools = _ref.availableTools;
76
+ withUploadPicture = _ref.withUploadPicture,
77
+ withUrlPicture = _ref.withUrlPicture;
79
78
 
80
79
  var _useState = (0, _react.useState)(false),
81
80
  _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
@@ -114,9 +113,9 @@ var MenuGroup = function MenuGroup(_ref) {
114
113
  setIsOpen(true);
115
114
  };
116
115
 
117
- var isActive = _fp["default"].includes(activeTool, group === null || group === void 0 ? void 0 : group.tools);
116
+ var isActive = _fp["default"].includes(activeTool.type, group === null || group === void 0 ? void 0 : group.tools);
118
117
 
119
- var groupIcon = (_ref3 = isActive ? (0, _style.getShapePicture)(activeTool) : group.img) !== null && _ref3 !== void 0 ? _ref3 : group.title;
118
+ var groupIcon = (_ref3 = isActive ? activeTool.icon : group.img) !== null && _ref3 !== void 0 ? _ref3 : group.title;
120
119
  (0, _react.useEffect)(function () {
121
120
  if (!isOpen) return;
122
121
 
@@ -133,10 +132,7 @@ var MenuGroup = function MenuGroup(_ref) {
133
132
  document.removeEventListener('click', closePanel);
134
133
  };
135
134
  }, [isOpen]);
136
-
137
- var withPicture = _fp["default"].includes(_Shapes.ShapeEnum.picture, availableTools);
138
-
139
- var withMenu = withActionsInMenu || withPicture || withLoadAndSave || withExport;
135
+ var withMenu = withActionsInMenu || withUploadPicture || withUrlPicture || withLoadAndSave || withExport;
140
136
  return withMenu ? /*#__PURE__*/_react["default"].createElement(StyledRelative, null, /*#__PURE__*/_react["default"].createElement(_Button["default"], {
141
137
  selected: isActive,
142
138
  title: group.title,
@@ -148,66 +144,61 @@ var MenuGroup = function MenuGroup(_ref) {
148
144
  alignment: alignment
149
145
  }, withActionsInMenu && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_Tool["default"], {
150
146
  withText: true,
151
- type: _Shapes.ToolEnum.undo,
147
+ type: _tools.UNDO_TOOL,
152
148
  disabled: disabled || !hasActionToUndo,
153
- lib: "Undo",
154
- img: _icons.undoIcon,
155
- isActive: activeTool === _Shapes.ToolEnum.undo,
149
+ img: _tools.UNDO_TOOL.icon,
150
+ isActive: activeTool.id === _tools.UNDO_TOOL.id,
156
151
  setActive: undoAction
157
152
  }), /*#__PURE__*/_react["default"].createElement(_Tool["default"], {
158
153
  withText: true,
159
- type: _Shapes.ToolEnum.redo,
154
+ type: _tools.REDO_TOOL,
160
155
  disabled: disabled || !hasActionToRedo,
161
- lib: "Redo",
162
- img: _icons.redoIcon,
163
- isActive: activeTool === _Shapes.ToolEnum.redo,
156
+ img: _tools.REDO_TOOL.icon,
157
+ isActive: activeTool.id === _tools.REDO_TOOL.id,
164
158
  setActive: redoAction
165
159
  }), /*#__PURE__*/_react["default"].createElement(_Tool["default"], {
166
160
  withText: true,
167
- type: _Shapes.ToolEnum.clear,
161
+ type: _tools.CLEAR_TOOL,
168
162
  disabled: disabled || !hasActionToClear,
169
- lib: "Clear",
170
- img: _icons.clearIcon,
171
- isActive: activeTool === _Shapes.ToolEnum.clear,
163
+ img: _tools.CLEAR_TOOL.icon,
164
+ isActive: activeTool.id === _tools.CLEAR_TOOL.id,
172
165
  setActive: function setActive() {
173
166
  return clearCanvas();
174
167
  }
175
- }), (withPicture || withLoadAndSave) && /*#__PURE__*/_react["default"].createElement("hr", null)), withPicture && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_LoadFileTool["default"], {
168
+ }), (withUploadPicture || withUrlPicture || withLoadAndSave) && /*#__PURE__*/_react["default"].createElement("hr", null)), withUploadPicture && /*#__PURE__*/_react["default"].createElement(_LoadFileTool["default"], {
176
169
  withText: true,
170
+ type: _tools.UPLOAD_PICTURE_TOOL,
177
171
  disabled: disabled,
178
172
  loadFile: addPicture,
179
- lib: "Upload picture",
180
- img: _icons.pictureIcon,
173
+ img: _tools.UPLOAD_PICTURE_TOOL.icon,
181
174
  accept: "image/png, image/gif, image/jpeg"
182
- }), /*#__PURE__*/_react["default"].createElement(_Button["default"], {
175
+ }), withUrlPicture && /*#__PURE__*/_react["default"].createElement(_Button["default"], {
183
176
  disabled: disabled,
184
177
  selected: false,
185
178
  onClick: togglePictureUrlModal,
186
179
  title: "Add picture from URL",
187
180
  icon: _icons.publicIcon,
188
181
  children: "Add picture from URL"
189
- }), withLoadAndSave && /*#__PURE__*/_react["default"].createElement("hr", null)), withLoadAndSave && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_LoadFileTool["default"], {
182
+ }), (withUploadPicture || withUrlPicture) && withLoadAndSave && /*#__PURE__*/_react["default"].createElement("hr", null), withLoadAndSave && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_LoadFileTool["default"], {
190
183
  withText: true,
184
+ type: _tools.LOAD_TOOL,
191
185
  disabled: disabled,
192
186
  loadFile: loadFile,
193
- lib: "Load project",
194
- img: _icons.openFileIcon,
187
+ img: _tools.LOAD_TOOL.icon,
195
188
  accept: "application/JSON"
196
189
  }), /*#__PURE__*/_react["default"].createElement(_Tool["default"], {
197
190
  withText: true,
198
191
  disabled: disabled,
199
- type: _Shapes.ToolEnum.saveFile,
200
- lib: "Save project",
201
- img: _icons.saveIcon,
202
- isActive: activeTool === _Shapes.ToolEnum.saveFile,
192
+ type: _tools.SAVE_TOOL,
193
+ img: _tools.SAVE_TOOL.icon,
194
+ isActive: activeTool.id === _tools.SAVE_TOOL.id,
203
195
  setActive: saveFile
204
196
  })), withExport && /*#__PURE__*/_react["default"].createElement(_Tool["default"], {
205
197
  withText: true,
206
198
  disabled: disabled,
207
- type: _Shapes.ToolEnum["export"],
208
- lib: "Export PNG",
209
- img: _icons.exportFileIcon,
210
- isActive: activeTool === _Shapes.ToolEnum["export"],
199
+ type: _tools.EXPORT_TOOL,
200
+ img: _tools.EXPORT_TOOL.icon,
201
+ isActive: activeTool.id === _tools.EXPORT_TOOL.id,
211
202
  setActive: exportCanvasInFile
212
203
  }))) : null;
213
204
  };
@@ -27,7 +27,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
27
27
 
28
28
  var StyledInputModal = /*#__PURE__*/(0, _react2.styled)(_Modal["default"])({
29
29
  name: "StyledInputModal",
30
- "class": "s95bkm9"
30
+ "class": "s1rncfwv"
31
31
  });
32
32
 
33
33
  var PictureUrlModal = function PictureUrlModal(_ref) {
@@ -12,9 +12,9 @@ var _react = _interopRequireDefault(require("react"));
12
12
  var _Button = _interopRequireDefault(require("../common/Button"));
13
13
 
14
14
  var Tool = function Tool(_ref) {
15
+ var _type$lib;
16
+
15
17
  var type = _ref.type,
16
- _ref$lib = _ref.lib,
17
- lib = _ref$lib === void 0 ? '' : _ref$lib,
18
18
  img = _ref.img,
19
19
  isActive = _ref.isActive,
20
20
  _ref$withText = _ref.withText,
@@ -31,9 +31,9 @@ var Tool = function Tool(_ref) {
31
31
  disabled: disabled,
32
32
  selected: isActive,
33
33
  onClick: handleClick,
34
- title: lib,
34
+ title: (_type$lib = type.lib) !== null && _type$lib !== void 0 ? _type$lib : type.type,
35
35
  icon: img,
36
- children: withText ? lib : undefined
36
+ children: withText ? type.lib : undefined
37
37
  });
38
38
  };
39
39
 
@@ -29,41 +29,42 @@ var _MenuGroup = _interopRequireDefault(require("./MenuGroup"));
29
29
 
30
30
  var _Tool = _interopRequireDefault(require("./Tool"));
31
31
 
32
- var _style = require("../../utils/style");
33
-
34
32
  var _Modal = _interopRequireDefault(require("../common/Modal"));
35
33
 
36
34
  var _PictureUrlInput = _interopRequireDefault(require("./PictureUrlInput"));
37
35
 
36
+ var _fp = _interopRequireDefault(require("lodash/fp"));
37
+
38
+ var _tools = require("../../constants/tools");
39
+
38
40
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
39
41
 
40
42
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
41
43
 
42
- var ACTIONS_MENU_BREAKPOINT = 400;
43
- var TOOLS_MENU_BREAKPOINT = 240;
44
+ var TOOL_WIDTH = 40;
44
45
  var StyledShrinkableTools = /*#__PURE__*/(0, _react2.styled)("div")({
45
46
  name: "StyledShrinkableTools",
46
- "class": "so6hnjf"
47
+ "class": "s1gorp95"
47
48
  });
48
49
  var StyledToolbox = /*#__PURE__*/(0, _react2.styled)("div")({
49
50
  name: "StyledToolbox",
50
- "class": "s1c1dllr"
51
+ "class": "s1ivsaf6"
51
52
  });
52
53
  var StyledToolsModal = /*#__PURE__*/(0, _react2.styled)(_Modal["default"])({
53
54
  name: "StyledToolsModal",
54
- "class": "s1g032mh"
55
+ "class": "sv0y70r"
55
56
  });
56
57
  var TOOLBAR_STRUCTURE = [{
57
58
  title: 'brush',
58
- tools: [_Shapes.ShapeEnum.brush],
59
+ toolsType: [_Shapes.ShapeEnum.brush],
59
60
  vertical: false
60
61
  }, {
61
62
  title: 'lines',
62
- tools: [_Shapes.ShapeEnum.line, _Shapes.ShapeEnum.curve, _Shapes.ShapeEnum.polygon],
63
+ toolsType: [_Shapes.ShapeEnum.line, _Shapes.ShapeEnum.curve, _Shapes.ShapeEnum.polygon],
63
64
  vertical: false
64
65
  }, {
65
66
  title: 'shapes',
66
- tools: [_Shapes.ShapeEnum.rect, _Shapes.ShapeEnum.square, _Shapes.ShapeEnum.circle, _Shapes.ShapeEnum.ellipse],
67
+ toolsType: [_Shapes.ShapeEnum.rect, _Shapes.ShapeEnum.square, _Shapes.ShapeEnum.circle, _Shapes.ShapeEnum.ellipse],
67
68
  vertical: false
68
69
  }, _Shapes.ShapeEnum.text];
69
70
 
@@ -88,7 +89,12 @@ var Toolbar = function Toolbar(_ref) {
88
89
  loadFile = _ref.loadFile,
89
90
  saveFile = _ref.saveFile,
90
91
  exportCanvasInFile = _ref.exportCanvasInFile,
91
- availableTools = _ref.availableTools;
92
+ availableTools = _ref.availableTools,
93
+ withUrlPicture = _ref.withUrlPicture,
94
+ withUploadPicture = _ref.withUploadPicture;
95
+ var currentStructure = (0, _toolbar.getCurrentStructure)(availableTools, TOOLBAR_STRUCTURE);
96
+ var fullToolbarSize = (5 + currentStructure.length) * TOOL_WIDTH;
97
+ var withMenuToolbarSize = (2 + currentStructure.length) * TOOL_WIDTH;
92
98
 
93
99
  var _useState = (0, _react.useState)(false),
94
100
  _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
@@ -100,12 +106,12 @@ var Toolbar = function Toolbar(_ref) {
100
106
  isPictureUrlModalOpen = _useState4[0],
101
107
  setIsPictureUrlModalOpen = _useState4[1];
102
108
 
103
- var _useState5 = (0, _react.useState)(width < ACTIONS_MENU_BREAKPOINT),
109
+ var _useState5 = (0, _react.useState)(width < fullToolbarSize),
104
110
  _useState6 = (0, _slicedToArray2["default"])(_useState5, 2),
105
111
  actionsInMenu = _useState6[0],
106
112
  setActionsInMenu = _useState6[1];
107
113
 
108
- var _useState7 = (0, _react.useState)(width < TOOLS_MENU_BREAKPOINT),
114
+ var _useState7 = (0, _react.useState)(width < withMenuToolbarSize),
109
115
  _useState8 = (0, _slicedToArray2["default"])(_useState7, 2),
110
116
  toolsInMenu = _useState8[0],
111
117
  setToolsInMenu = _useState8[1];
@@ -129,19 +135,61 @@ var Toolbar = function Toolbar(_ref) {
129
135
  var setActiveTool = function setActiveTool(tool) {
130
136
  setActiveToolFromProps(tool);
131
137
  setIsMenuOpen(false);
132
- };
138
+ }; //360 240
139
+
133
140
 
134
141
  (0, _react.useEffect)(function () {
135
- setActionsInMenu(width < ACTIONS_MENU_BREAKPOINT);
136
- setToolsInMenu(width < TOOLS_MENU_BREAKPOINT);
137
- }, [width]);
138
- var currentStructure = (0, _toolbar.getCurrentStructure)(availableTools, TOOLBAR_STRUCTURE);
139
- var isAnyToolSelected = availableTools.includes(activeTool);
140
- return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(StyledToolbox, null, /*#__PURE__*/_react["default"].createElement(_MenuGroup["default"], {
142
+ setActionsInMenu(width < fullToolbarSize);
143
+ setToolsInMenu(width < withMenuToolbarSize);
144
+ }, [width, fullToolbarSize, withMenuToolbarSize]);
145
+ var isAnyToolSelected = _fp["default"].find({
146
+ type: activeTool
147
+ }, availableTools) !== undefined;
148
+ return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(StyledToolbox, null, /*#__PURE__*/_react["default"].createElement(StyledShrinkableTools, null, /*#__PURE__*/_react["default"].createElement(_Tool["default"], {
149
+ type: _tools.SELECTION_TOOL,
150
+ disabled: disabled,
151
+ img: _tools.SELECTION_TOOL.icon,
152
+ isActive: activeTool.id === _tools.SELECTION_TOOL.id,
153
+ setActive: setActiveTool
154
+ }), toolsInMenu ? /*#__PURE__*/_react["default"].createElement(_Button["default"], {
155
+ disabled: disabled,
156
+ onClick: toggleTools,
157
+ title: "Toggle tools",
158
+ icon: _icons.shapesIcon,
159
+ selected: isAnyToolSelected
160
+ }) : currentStructure.map(function (group, i) {
161
+ return /*#__PURE__*/_react["default"].createElement(_ToolbarGroup["default"], {
162
+ disabled: disabled,
163
+ key: i,
164
+ activeTool: activeTool,
165
+ group: group,
166
+ setActiveTool: setActiveTool
167
+ });
168
+ })), !actionsInMenu && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_Tool["default"], {
169
+ type: _tools.UNDO_TOOL,
170
+ disabled: disabled || !hasActionToUndo,
171
+ img: _tools.UNDO_TOOL.icon,
172
+ isActive: activeTool.id === _tools.UNDO_TOOL.id,
173
+ setActive: undoAction
174
+ }), /*#__PURE__*/_react["default"].createElement(_Tool["default"], {
175
+ type: _tools.REDO_TOOL,
176
+ disabled: disabled || !hasActionToRedo,
177
+ img: _tools.REDO_TOOL.icon,
178
+ isActive: activeTool.id === _tools.REDO_TOOL.id,
179
+ setActive: redoAction
180
+ }), /*#__PURE__*/_react["default"].createElement(_Tool["default"], {
181
+ type: _tools.CLEAR_TOOL,
182
+ disabled: disabled || !hasActionToClear,
183
+ img: _tools.CLEAR_TOOL.icon,
184
+ isActive: activeTool.id === _tools.CLEAR_TOOL.id,
185
+ setActive: function setActive() {
186
+ return clearCanvas();
187
+ }
188
+ })), /*#__PURE__*/_react["default"].createElement(_MenuGroup["default"], {
141
189
  withActionsInMenu: actionsInMenu,
142
190
  disabled: disabled,
143
191
  vertical: true,
144
- alignment: "left",
192
+ alignment: "right",
145
193
  group: {
146
194
  title: 'Menu',
147
195
  img: _icons.menuIcon
@@ -152,7 +200,8 @@ var Toolbar = function Toolbar(_ref) {
152
200
  saveFile: saveFile,
153
201
  togglePictureUrlModal: openPictureUrlModal,
154
202
  exportCanvasInFile: exportCanvasInFile,
155
- availableTools: availableTools,
203
+ withUploadPicture: withUploadPicture,
204
+ withUrlPicture: withUrlPicture,
156
205
  withLoadAndSave: withLoadAndSave,
157
206
  withExport: withExport,
158
207
  hasActionToUndo: hasActionToUndo,
@@ -161,61 +210,16 @@ var Toolbar = function Toolbar(_ref) {
161
210
  undoAction: undoAction,
162
211
  redoAction: redoAction,
163
212
  clearCanvas: clearCanvas
164
- }), /*#__PURE__*/_react["default"].createElement(_Tool["default"], {
165
- type: _Shapes.ToolEnum.selection,
166
- disabled: disabled,
167
- lib: "selection",
168
- img: _icons.selectIcon,
169
- isActive: activeTool === _Shapes.ToolEnum.selection,
170
- setActive: setActiveTool
171
- }), !actionsInMenu && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_Tool["default"], {
172
- type: _Shapes.ToolEnum.undo,
173
- disabled: disabled || !hasActionToUndo,
174
- lib: "Undo",
175
- img: _icons.undoIcon,
176
- isActive: activeTool === _Shapes.ToolEnum.undo,
177
- setActive: undoAction
178
- }), /*#__PURE__*/_react["default"].createElement(_Tool["default"], {
179
- type: _Shapes.ToolEnum.redo,
180
- disabled: disabled || !hasActionToRedo,
181
- lib: "Redo",
182
- img: _icons.redoIcon,
183
- isActive: activeTool === _Shapes.ToolEnum.redo,
184
- setActive: redoAction
185
- }), /*#__PURE__*/_react["default"].createElement(_Tool["default"], {
186
- type: _Shapes.ToolEnum.clear,
187
- disabled: disabled || !hasActionToClear,
188
- lib: "Clear",
189
- img: _icons.clearIcon,
190
- isActive: activeTool === _Shapes.ToolEnum.clear,
191
- setActive: function setActive() {
192
- return clearCanvas();
193
- }
194
- })), /*#__PURE__*/_react["default"].createElement(StyledShrinkableTools, null, toolsInMenu ? /*#__PURE__*/_react["default"].createElement(_Button["default"], {
195
- disabled: disabled,
196
- onClick: toggleTools,
197
- title: "Toggle tools",
198
- icon: _icons.shapesIcon,
199
- selected: isAnyToolSelected
200
- }) : currentStructure.map(function (group, i) {
201
- return /*#__PURE__*/_react["default"].createElement(_ToolbarGroup["default"], {
202
- disabled: disabled,
203
- key: i,
204
- activeTool: activeTool,
205
- group: group,
206
- setActiveTool: setActiveTool
207
- });
208
- }))), isMenuOpen && /*#__PURE__*/_react["default"].createElement(StyledToolsModal, {
213
+ })), isMenuOpen && /*#__PURE__*/_react["default"].createElement(StyledToolsModal, {
209
214
  onClose: toggleTools
210
- }, availableTools.map(function (toolType) {
211
- return toolType === _Shapes.ShapeEnum.picture ? null : /*#__PURE__*/_react["default"].createElement(_Tool["default"], {
215
+ }, availableTools.map(function (toolType, index) {
216
+ return toolType.type === _Shapes.ShapeEnum.picture ? null : /*#__PURE__*/_react["default"].createElement(_Tool["default"], {
212
217
  disabled: disabled,
213
- key: toolType,
218
+ key: index,
214
219
  type: toolType,
215
- lib: toolType,
220
+ img: toolType.icon,
216
221
  withText: false,
217
- img: (0, _style.getShapePicture)(toolType),
218
- isActive: activeTool === toolType,
222
+ isActive: activeTool.id === toolType.id,
219
223
  setActive: setActiveTool
220
224
  });
221
225
  })), isPictureUrlModalOpen && /*#__PURE__*/_react["default"].createElement(_PictureUrlInput["default"], {
@@ -21,8 +21,6 @@ var _Panel = _interopRequireDefault(require("../common/Panel"));
21
21
 
22
22
  var _react2 = require("@linaria/react");
23
23
 
24
- var _style = require("../../utils/style");
25
-
26
24
  var _Tool = _interopRequireDefault(require("./Tool"));
27
25
 
28
26
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
@@ -31,15 +29,15 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
31
29
 
32
30
  var StyledPanel = /*#__PURE__*/(0, _react2.styled)(_Panel["default"])({
33
31
  name: "StyledPanel",
34
- "class": "s1bvz4xj"
32
+ "class": "s3kynji"
35
33
  });
36
34
  var StyledRelative = /*#__PURE__*/(0, _react2.styled)("div")({
37
35
  name: "StyledRelative",
38
- "class": "siejlch"
36
+ "class": "s1614rl3"
39
37
  });
40
38
 
41
39
  var ToolbarGroup = function ToolbarGroup(_ref) {
42
- var _group$tools, _ref2;
40
+ var _group$toolsType, _ref2;
43
41
 
44
42
  var activeTool = _ref.activeTool,
45
43
  alignment = _ref.alignment,
@@ -80,37 +78,36 @@ var ToolbarGroup = function ToolbarGroup(_ref) {
80
78
  };
81
79
  }, [isOpen]);
82
80
 
83
- if (!_fp["default"].isObject(group)) {
81
+ if ('type' in group) {
84
82
  return /*#__PURE__*/_react["default"].createElement(_Tool["default"], {
85
83
  disabled: disabled,
86
84
  type: group,
87
- lib: group,
88
- img: (0, _style.getShapePicture)(group),
89
- isActive: activeTool === group,
85
+ img: group.icon,
86
+ isActive: activeTool.id === group.id,
90
87
  setActive: setActiveTool
91
88
  });
92
89
  }
93
90
 
94
- if (_fp["default"].isEmpty(group.tools)) return null;
91
+ if (_fp["default"].isEmpty(group.toolsType)) return null;
95
92
 
96
- if (((_group$tools = group.tools) === null || _group$tools === void 0 ? void 0 : _group$tools.length) === 1) {
93
+ if (((_group$toolsType = group.toolsType) === null || _group$toolsType === void 0 ? void 0 : _group$toolsType.length) === 1) {
97
94
  return /*#__PURE__*/_react["default"].createElement(_Tool["default"], {
98
95
  disabled: disabled,
99
- type: group.tools[0],
100
- lib: group.tools[0],
101
- img: (0, _style.getShapePicture)(group.tools[0]),
102
- isActive: activeTool === group.tools[0],
96
+ type: group.toolsType[0],
97
+ img: group.toolsType[0].icon,
98
+ isActive: activeTool.id === group.toolsType[0].id,
103
99
  setActive: setActiveTool
104
100
  });
105
101
  }
106
102
 
107
- var isActive = _fp["default"].includes(activeTool, group === null || group === void 0 ? void 0 : group.tools);
108
-
109
- var groupIcon = (_ref2 = localActiveTool ? (0, _style.getShapePicture)(localActiveTool) : group.tools && group.tools[0] && (0, _style.getShapePicture)(group.tools[0])) !== null && _ref2 !== void 0 ? _ref2 : group.title;
103
+ var isActive = _fp["default"].find({
104
+ type: activeTool.type
105
+ }, group === null || group === void 0 ? void 0 : group.toolsType) !== undefined;
106
+ var groupIcon = (_ref2 = localActiveTool ? localActiveTool.icon : group.toolsType && group.toolsType[0] && group.toolsType[0].icon) !== null && _ref2 !== void 0 ? _ref2 : group.title;
110
107
 
111
108
  var openPanel = function openPanel() {
112
- if (localActiveTool) setActiveToolFromProps(localActiveTool);else group.tools && group.tools[0] && setActiveTool(group.tools[0]);
113
- setIsOpen(true); // group.tools && group.tools[0] && setActiveTool(group.tools[0])
109
+ if (localActiveTool) setActiveToolFromProps(localActiveTool);else group.toolsType && group.toolsType[0] && setActiveTool(group.toolsType[0]);
110
+ setIsOpen(true);
114
111
  };
115
112
 
116
113
  return /*#__PURE__*/_react["default"].createElement(StyledRelative, null, /*#__PURE__*/_react["default"].createElement(_Button["default"], {
@@ -122,17 +119,16 @@ var ToolbarGroup = function ToolbarGroup(_ref) {
122
119
  }), isOpen && /*#__PURE__*/_react["default"].createElement(StyledPanel, {
123
120
  vertical: group.vertical,
124
121
  alignment: alignment
125
- }, _fp["default"].map(function (toolType) {
122
+ }, group.toolsType.map(function (toolType, i) {
126
123
  return /*#__PURE__*/_react["default"].createElement(_Tool["default"], {
127
124
  disabled: disabled,
128
- key: toolType,
125
+ key: i,
129
126
  type: toolType,
130
- lib: toolType,
131
- img: (0, _style.getShapePicture)(toolType),
132
- isActive: activeTool === toolType,
127
+ img: toolType.icon,
128
+ isActive: activeTool.id === toolType.id,
133
129
  setActive: setActiveTool
134
130
  });
135
- }, group.tools)));
131
+ })));
136
132
  };
137
133
 
138
134
  var _default = ToolbarGroup;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.STYLE_ZINDEX_SNACKBAR = exports.STYLE_ZINDEX_PANEL = exports.STYLE_ZINDEX_LOADING = exports.STYLE_ZINDEX_APP = exports.STYLE_LINE_WITH_ARROW = exports.STYLE_LINE_DASH = exports.STYLE_FONT_DEFAULT = exports.STYLE_FONTS = exports.STYLE_COLORS = exports.POLYGON_POINTS_VALUES = exports.LINE_DASH_DATA = exports.CURVE_POINTS_VALUES = void 0;
6
+ exports.STYLE_ZINDEX_SNACKBAR = exports.STYLE_ZINDEX_PANEL = exports.STYLE_ZINDEX_LOADING = exports.STYLE_ZINDEX_APP = exports.STYLE_LINE_WITH_ARROW = exports.STYLE_LINE_DASH = exports.STYLE_FONT_SIZE_DEFAULT = exports.STYLE_FONT_DEFAULT = exports.STYLE_FONTS = exports.STYLE_COLORS = exports.POLYGON_POINTS_VALUES = exports.LINE_DASH_DATA = exports.CURVE_POINTS_VALUES = void 0;
7
7
  var POLYGON_POINTS_VALUES = [3, 4, 5, 6, 7, 8, 9, 10];
8
8
  exports.POLYGON_POINTS_VALUES = POLYGON_POINTS_VALUES;
9
9
  var CURVE_POINTS_VALUES = [3, 4, 5, 6, 7, 8, 9];
@@ -20,6 +20,8 @@ var STYLE_FONTS = ['arial', 'serif', 'monospace'];
20
20
  exports.STYLE_FONTS = STYLE_FONTS;
21
21
  var STYLE_FONT_DEFAULT = 'serif';
22
22
  exports.STYLE_FONT_DEFAULT = STYLE_FONT_DEFAULT;
23
+ var STYLE_FONT_SIZE_DEFAULT = 36;
24
+ exports.STYLE_FONT_SIZE_DEFAULT = STYLE_FONT_SIZE_DEFAULT;
23
25
  var STYLE_ZINDEX_APP = 1;
24
26
  exports.STYLE_ZINDEX_APP = STYLE_ZINDEX_APP;
25
27
  var STYLE_ZINDEX_LOADING = 2;