@yorab/react-paint 0.6.5 → 0.6.6

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 (57) hide show
  1. package/README.md +2 -0
  2. package/dist/components/App.js +224 -384
  3. package/dist/components/Canvas.js +104 -114
  4. package/dist/components/common/Button.js +41 -50
  5. package/dist/components/common/Loading.js +21 -33
  6. package/dist/components/common/Modal.js +18 -17
  7. package/dist/components/common/Panel.js +20 -24
  8. package/dist/components/common/Snackbar.js +27 -34
  9. package/dist/components/settings/ColorField.js +59 -68
  10. package/dist/components/settings/DeleteButton.js +10 -9
  11. package/dist/components/settings/FontFamilyField.js +24 -19
  12. package/dist/components/settings/LayoutButton.js +11 -9
  13. package/dist/components/settings/Layouts.js +93 -103
  14. package/dist/components/settings/LineArrowField.js +25 -22
  15. package/dist/components/settings/LineTypeField.js +23 -20
  16. package/dist/components/settings/PointsNumberField.js +14 -13
  17. package/dist/components/settings/RangeField.js +35 -47
  18. package/dist/components/settings/SelectField.js +34 -43
  19. package/dist/components/settings/SettingsBar.js +95 -118
  20. package/dist/components/settings/ToggleField.js +18 -25
  21. package/dist/components/toolbox/EditTextBox.js +53 -42
  22. package/dist/components/toolbox/LoadFileTool.js +19 -21
  23. package/dist/components/toolbox/MenuGroup.js +60 -96
  24. package/dist/components/toolbox/PictureUrlInput.js +33 -62
  25. package/dist/components/toolbox/Tool.js +13 -13
  26. package/dist/components/toolbox/Toolbar.js +74 -106
  27. package/dist/components/toolbox/ToolbarGroup.js +41 -57
  28. package/dist/constants/icons.js +43 -43
  29. package/dist/constants/shapes.js +6 -6
  30. package/dist/constants/snackbar.js +3 -3
  31. package/dist/constants/style.js +13 -13
  32. package/dist/constants/tools.js +80 -80
  33. package/dist/hooks/useComponent.js +12 -19
  34. package/dist/hooks/useDoubleClick.js +12 -12
  35. package/dist/hooks/useDrag.js +24 -32
  36. package/dist/hooks/useDrawableCanvas.js +86 -100
  37. package/dist/hooks/useKeyboard.js +26 -36
  38. package/dist/hooks/useResizeObserver.js +18 -16
  39. package/dist/hooks/useShapes.js +91 -143
  40. package/dist/hooks/useSnackbar.js +28 -58
  41. package/dist/styles.css +55 -55
  42. package/dist/types/Mode.js +1 -1
  43. package/dist/types/Shapes.js +1 -1
  44. package/dist/types/keyboard.js +2 -2
  45. package/dist/types/tools.js +1 -1
  46. package/dist/utils/data.js +91 -107
  47. package/dist/utils/draw.js +116 -146
  48. package/dist/utils/file.js +69 -119
  49. package/dist/utils/intersect.js +57 -97
  50. package/dist/utils/selection.js +12 -12
  51. package/dist/utils/shapeData.js +33 -51
  52. package/dist/utils/string.js +10 -16
  53. package/dist/utils/style.js +1 -1
  54. package/dist/utils/toolbar.js +26 -38
  55. package/dist/utils/transform.js +183 -239
  56. package/package.json +6 -5
  57. package/Changelog.md +0 -123
@@ -7,12 +7,6 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.updatePolygonLinesCount = exports.translateShape = exports.transformShape = exports.rotateShape = exports.resizeText = exports.resizeShape = exports.resizeRect = exports.resizePicture = exports.resizeLine = exports.resizeEllipse = exports.resizeCircle = exports.resizeBrush = exports.radiansToDegrees = exports.paintNewPointToShape = exports.getNormalizedSize = exports.fitContentInsideContainer = exports.degreesToRadians = exports.createNewPointGroupToShape = exports.calculateTextWidth = exports.calculateTextFontSize = void 0;
9
9
 
10
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
-
12
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
13
-
14
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
15
-
16
10
  var _fp = _interopRequireDefault(require("lodash/fp"));
17
11
 
18
12
  var _shapeData = require("./shapeData");
@@ -23,13 +17,9 @@ var _intersect = require("./intersect");
23
17
 
24
18
  var _style = require("../constants/style");
25
19
 
26
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
27
-
28
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
29
-
30
- var getNormalizedSize = function getNormalizedSize(originalShape, width, height) {
31
- var originalRatio = originalShape.width / originalShape.height;
32
- var newRatio = width / height;
20
+ const getNormalizedSize = (originalShape, width, height) => {
21
+ const originalRatio = originalShape.width / originalShape.height;
22
+ const newRatio = width / height;
33
23
 
34
24
  if (newRatio > originalRatio || height < 0) {
35
25
  return width > originalShape.width ? [width, width / originalRatio] : [height * originalRatio, height];
@@ -42,294 +32,256 @@ var getNormalizedSize = function getNormalizedSize(originalShape, width, height)
42
32
 
43
33
  exports.getNormalizedSize = getNormalizedSize;
44
34
 
45
- var translateShape = function translateShape(shape, cursorPosition, originalShape, originalCursorPosition) {
46
- return _objectSpread(_objectSpread({}, shape), {
47
- translation: [originalShape.translation[0] + cursorPosition[0] - originalCursorPosition[0], originalShape.translation[1] + cursorPosition[1] - originalCursorPosition[1]]
48
- });
35
+ const translateShape = (shape, cursorPosition, originalShape, originalCursorPosition) => {
36
+ return { ...shape,
37
+ ...{
38
+ translation: [originalShape.translation[0] + cursorPosition[0] - originalCursorPosition[0], originalShape.translation[1] + cursorPosition[1] - originalCursorPosition[1]]
39
+ }
40
+ };
49
41
  };
50
42
 
51
43
  exports.translateShape = translateShape;
52
44
 
53
- var rotateShape = function rotateShape(shape, cursorPosition, originalShape, originalCursorPosition, shapeCenter) {
54
- var p1x = shapeCenter[0] + originalShape.translation[0] - originalCursorPosition[0];
55
- var p1y = shapeCenter[1] + originalShape.translation[1] - originalCursorPosition[1];
56
- var p2x = shapeCenter[0] + originalShape.translation[0] - cursorPosition[0];
57
- var p2y = shapeCenter[1] + originalShape.translation[1] - cursorPosition[1];
58
- var rotation = originalShape.rotation + Math.atan2(p2y, p2x) - Math.atan2(p1y, p1x);
59
- return _objectSpread(_objectSpread({}, shape), {
60
- rotation: rotation
61
- });
45
+ const rotateShape = (shape, cursorPosition, originalShape, originalCursorPosition, shapeCenter) => {
46
+ const p1x = shapeCenter[0] + originalShape.translation[0] - originalCursorPosition[0];
47
+ const p1y = shapeCenter[1] + originalShape.translation[1] - originalCursorPosition[1];
48
+ const p2x = shapeCenter[0] + originalShape.translation[0] - cursorPosition[0];
49
+ const p2y = shapeCenter[1] + originalShape.translation[1] - cursorPosition[1];
50
+ const rotation = originalShape.rotation + Math.atan2(p2y, p2x) - Math.atan2(p1y, p1x);
51
+ return { ...shape,
52
+ ...{
53
+ rotation
54
+ }
55
+ };
62
56
  };
63
57
 
64
58
  exports.rotateShape = rotateShape;
65
59
 
66
- var paintNewPointToShape = function paintNewPointToShape(shape, cursorPosition) {
67
- return _objectSpread(_objectSpread({}, shape), {
68
- points: _fp["default"].set(shape.points.length - 1, [].concat((0, _toConsumableArray2["default"])(shape.points[shape.points.length - 1]), [cursorPosition]), shape.points)
69
- });
60
+ const paintNewPointToShape = (shape, cursorPosition) => {
61
+ return { ...shape,
62
+ ...{
63
+ points: _fp.default.set(shape.points.length - 1, [...shape.points[shape.points.length - 1], cursorPosition], shape.points)
64
+ }
65
+ };
70
66
  };
71
67
 
72
68
  exports.paintNewPointToShape = paintNewPointToShape;
73
69
 
74
- var createNewPointGroupToShape = function createNewPointGroupToShape(shape, cursorPosition) {
75
- return _objectSpread(_objectSpread({}, shape), {
76
- points: _fp["default"].set(shape.points.length, [cursorPosition], shape.points)
77
- });
70
+ const createNewPointGroupToShape = (shape, cursorPosition) => {
71
+ return { ...shape,
72
+ ...{
73
+ points: _fp.default.set(shape.points.length, [cursorPosition], shape.points)
74
+ }
75
+ };
78
76
  };
79
77
 
80
78
  exports.createNewPointGroupToShape = createNewPointGroupToShape;
81
79
 
82
- var resizeBrush = function resizeBrush(cursorPosition, canvasOffset, originalShape, selectionMode, selectionPadding) {
83
- var _getShapeInfos = (0, _shapeData.getShapeInfos)(originalShape, selectionPadding),
84
- center = _getShapeInfos.center,
85
- borders = _getShapeInfos.borders;
86
-
87
- var cursorPositionBeforeResize = (0, _intersect.getPointPositionAfterCanvasTransformation)(cursorPosition, canvasOffset, originalShape.translation, originalShape.rotation, center);
88
- var scaledWidth = selectionMode.anchor[0] === 0.5 ? 1 : selectionMode.anchor[0] === 0 ? (borders.x + borders.width - cursorPositionBeforeResize[0] + selectionPadding * -2) / (borders.width + selectionPadding * -2) : (cursorPositionBeforeResize[0] - borders.x - selectionPadding * 2) / (borders.width - selectionPadding * 2);
89
- var scaledHeight = selectionMode.anchor[1] === 0.5 ? 1 : selectionMode.anchor[1] === 0 ? (borders.y + borders.height - cursorPositionBeforeResize[1] + selectionPadding * -2) / (borders.height + selectionPadding * -2) : (cursorPositionBeforeResize[1] - borders.y - selectionPadding * 2) / (borders.height - selectionPadding * 2);
90
-
91
- var shapeWithNewDimensions = _objectSpread(_objectSpread({}, originalShape), {}, {
92
- points: originalShape.points.map(function (points) {
93
- return points.map(function (point) {
94
- return [(point[0] - borders.x) * scaledWidth + borders.x, (point[1] - borders.y) * scaledHeight + borders.y];
95
- });
80
+ const resizeBrush = (cursorPosition, canvasOffset, originalShape, selectionMode, selectionPadding) => {
81
+ const {
82
+ center,
83
+ borders
84
+ } = (0, _shapeData.getShapeInfos)(originalShape, selectionPadding);
85
+ const cursorPositionBeforeResize = (0, _intersect.getPointPositionAfterCanvasTransformation)(cursorPosition, canvasOffset, originalShape.translation, originalShape.rotation, center);
86
+ const scaledWidth = selectionMode.anchor[0] === 0.5 ? 1 : selectionMode.anchor[0] === 0 ? (borders.x + borders.width - cursorPositionBeforeResize[0] + selectionPadding * -2) / (borders.width + selectionPadding * -2) : (cursorPositionBeforeResize[0] - borders.x - selectionPadding * 2) / (borders.width - selectionPadding * 2);
87
+ const scaledHeight = selectionMode.anchor[1] === 0.5 ? 1 : selectionMode.anchor[1] === 0 ? (borders.y + borders.height - cursorPositionBeforeResize[1] + selectionPadding * -2) / (borders.height + selectionPadding * -2) : (cursorPositionBeforeResize[1] - borders.y - selectionPadding * 2) / (borders.height - selectionPadding * 2);
88
+ const shapeWithNewDimensions = { ...originalShape,
89
+ points: originalShape.points.map(points => {
90
+ return points.map(point => [(point[0] - borders.x) * scaledWidth + borders.x, (point[1] - borders.y) * scaledHeight + borders.y]);
96
91
  })
92
+ };
93
+ const {
94
+ center: shapeWithNewDimensionsCenter,
95
+ borders: shapeWithNewDimensionsBorders
96
+ } = (0, _shapeData.getShapeInfos)(shapeWithNewDimensions, selectionPadding);
97
+ const [oppTrueX, oppTrueY] = getRectOppositeAnchorAbsolutePosition(selectionMode.anchor, center, { ...originalShape,
98
+ ...borders
97
99
  });
98
-
99
- var _getShapeInfos2 = (0, _shapeData.getShapeInfos)(shapeWithNewDimensions, selectionPadding),
100
- shapeWithNewDimensionsCenter = _getShapeInfos2.center,
101
- shapeWithNewDimensionsBorders = _getShapeInfos2.borders;
102
-
103
- var _getRectOppositeAncho = getRectOppositeAnchorAbsolutePosition(selectionMode.anchor, center, _objectSpread(_objectSpread({}, originalShape), borders)),
104
- _getRectOppositeAncho2 = (0, _slicedToArray2["default"])(_getRectOppositeAncho, 2),
105
- oppTrueX = _getRectOppositeAncho2[0],
106
- oppTrueY = _getRectOppositeAncho2[1];
107
-
108
- var _getRectOppositeAncho3 = getRectOppositeAnchorAbsolutePosition(selectionMode.anchor, shapeWithNewDimensionsCenter, _objectSpread(_objectSpread({}, shapeWithNewDimensions), shapeWithNewDimensionsBorders), [scaledWidth < 0, scaledHeight < 0]),
109
- _getRectOppositeAncho4 = (0, _slicedToArray2["default"])(_getRectOppositeAncho3, 2),
110
- newOppTrueX = _getRectOppositeAncho4[0],
111
- newOppTrueY = _getRectOppositeAncho4[1];
112
-
113
- return _objectSpread(_objectSpread({}, shapeWithNewDimensions), {
114
- translation: [originalShape.translation[0] - (newOppTrueX - oppTrueX), originalShape.translation[1] - (newOppTrueY - oppTrueY)]
115
- });
100
+ const [newOppTrueX, newOppTrueY] = getRectOppositeAnchorAbsolutePosition(selectionMode.anchor, shapeWithNewDimensionsCenter, { ...shapeWithNewDimensions,
101
+ ...shapeWithNewDimensionsBorders
102
+ }, [scaledWidth < 0, scaledHeight < 0]);
103
+ return { ...shapeWithNewDimensions,
104
+ ...{
105
+ translation: [originalShape.translation[0] - (newOppTrueX - oppTrueX), originalShape.translation[1] - (newOppTrueY - oppTrueY)]
106
+ }
107
+ };
116
108
  };
117
109
 
118
110
  exports.resizeBrush = resizeBrush;
119
111
 
120
- var resizeLine = function resizeLine(cursorPosition, canvasOffset, originalShape, selectionMode, selectionPadding) {
121
- var _getShapeInfos3 = (0, _shapeData.getShapeInfos)(originalShape, selectionPadding),
122
- center = _getShapeInfos3.center;
123
-
124
- var cursorPositionBeforeResize = (0, _intersect.getPointPositionAfterCanvasTransformation)(cursorPosition, canvasOffset, originalShape.translation, originalShape.rotation, center);
112
+ const resizeLine = (cursorPosition, canvasOffset, originalShape, selectionMode, selectionPadding) => {
113
+ const {
114
+ center
115
+ } = (0, _shapeData.getShapeInfos)(originalShape, selectionPadding);
116
+ const cursorPositionBeforeResize = (0, _intersect.getPointPositionAfterCanvasTransformation)(cursorPosition, canvasOffset, originalShape.translation, originalShape.rotation, center);
125
117
 
126
- var updatedShape = _fp["default"].set(['points', selectionMode.anchor], cursorPositionBeforeResize, originalShape);
118
+ const updatedShape = _fp.default.set(['points', selectionMode.anchor], cursorPositionBeforeResize, originalShape);
127
119
 
128
120
  return updatedShape;
129
121
  };
130
122
 
131
123
  exports.resizeLine = resizeLine;
132
124
 
133
- var updatePolygonLinesCount = function updatePolygonLinesCount(shape, newPointsCount) {
134
- var currentPointsCount = shape.points.length;
125
+ const updatePolygonLinesCount = (shape, newPointsCount) => {
126
+ const currentPointsCount = shape.points.length;
135
127
  if (currentPointsCount === newPointsCount) return shape;
136
128
 
137
129
  if (currentPointsCount > newPointsCount) {
138
- var totalPoints = shape.points.slice(0, newPointsCount);
139
- return _objectSpread(_objectSpread({}, shape), {}, {
130
+ const totalPoints = shape.points.slice(0, newPointsCount);
131
+ return { ...shape,
140
132
  points: totalPoints,
141
- style: _objectSpread(_objectSpread({}, shape.style), {}, {
133
+ style: { ...shape.style,
142
134
  pointsCount: totalPoints.length
143
- })
144
- });
135
+ }
136
+ };
145
137
  } else {
146
138
  //TODO : better distribution for new points
147
- var nbPointsToAdd = newPointsCount - currentPointsCount;
139
+ const nbPointsToAdd = newPointsCount - currentPointsCount;
148
140
 
149
- var newPoints = _fp["default"].flow(_fp["default"].range(0), _fp["default"].map(function (index) {
150
- return [shape.points[0][0] + (shape.points[1][0] - shape.points[0][0]) * (index + 1) / (nbPointsToAdd + 1), shape.points[0][1] + (shape.points[1][1] - shape.points[0][1]) * (index + 1) / (nbPointsToAdd + 1)];
151
- }))(nbPointsToAdd);
141
+ const newPoints = _fp.default.flow(_fp.default.range(0), _fp.default.map(index => [shape.points[0][0] + (shape.points[1][0] - shape.points[0][0]) * (index + 1) / (nbPointsToAdd + 1), shape.points[0][1] + (shape.points[1][1] - shape.points[0][1]) * (index + 1) / (nbPointsToAdd + 1)]))(nbPointsToAdd);
152
142
 
153
- var _totalPoints = [shape.points[0]].concat((0, _toConsumableArray2["default"])(newPoints), (0, _toConsumableArray2["default"])(shape.points.slice(1, shape.points.length)));
154
-
155
- return _objectSpread(_objectSpread({}, shape), {}, {
156
- points: _totalPoints,
157
- style: _objectSpread(_objectSpread({}, shape.style), {}, {
158
- pointsCount: _totalPoints.length
159
- })
160
- });
143
+ const totalPoints = [shape.points[0], ...newPoints, ...shape.points.slice(1, shape.points.length)];
144
+ return { ...shape,
145
+ points: totalPoints,
146
+ style: { ...shape.style,
147
+ pointsCount: totalPoints.length
148
+ }
149
+ };
161
150
  }
162
151
  };
163
152
 
164
153
  exports.updatePolygonLinesCount = updatePolygonLinesCount;
165
154
 
166
- var resizeCircle = function resizeCircle(cursorPosition, canvasOffset, originalShape, selectionMode, selectionPadding) {
167
- var _getShapeInfos4 = (0, _shapeData.getShapeInfos)(originalShape, selectionPadding),
168
- center = _getShapeInfos4.center,
169
- borders = _getShapeInfos4.borders;
170
-
171
- var cursorPositionBeforeResize = (0, _intersect.getPointPositionAfterCanvasTransformation)(cursorPosition, canvasOffset, originalShape.translation, originalShape.rotation, center);
172
- var newCursorPosition = [cursorPositionBeforeResize[0], cursorPositionBeforeResize[1]];
173
- var scaledRadius = selectionMode.anchor[1] === 0.5 ? (selectionMode.anchor[0] === 0 ? borders.x + borders.width - newCursorPosition[0] + selectionPadding * (selectionMode.anchor[0] === 0 ? -2 : 2) : newCursorPosition[0] - borders.x - selectionPadding * (selectionMode.anchor[0] === 0 ? -2 : 2)) / 2 : (selectionMode.anchor[1] === 0 ? borders.y + borders.height - newCursorPosition[1] + selectionPadding * (selectionMode.anchor[1] === 0 ? -2 : 2) : newCursorPosition[1] - borders.y - selectionPadding * (selectionMode.anchor[1] === 0 ? -2 : 2)) / 2;
174
-
175
- var shapeWithNewDimensions = _objectSpread(_objectSpread({}, originalShape), {
176
- radius: Math.abs(scaledRadius)
177
- });
178
-
179
- var _getShapeInfos5 = (0, _shapeData.getShapeInfos)(shapeWithNewDimensions, selectionPadding),
180
- shapeWithNewDimensionsCenter = _getShapeInfos5.center;
181
-
182
- var _getCircleOppositeAnc = getCircleOppositeAnchorAbsolutePosition(selectionMode.anchor, center, originalShape),
183
- _getCircleOppositeAnc2 = (0, _slicedToArray2["default"])(_getCircleOppositeAnc, 2),
184
- oppTrueX = _getCircleOppositeAnc2[0],
185
- oppTrueY = _getCircleOppositeAnc2[1];
186
-
187
- var _getCircleOppositeAnc3 = getCircleOppositeAnchorAbsolutePosition(selectionMode.anchor, shapeWithNewDimensionsCenter, shapeWithNewDimensions, [scaledRadius < 0, scaledRadius < 0]),
188
- _getCircleOppositeAnc4 = (0, _slicedToArray2["default"])(_getCircleOppositeAnc3, 2),
189
- newOppTrueX = _getCircleOppositeAnc4[0],
190
- newOppTrueY = _getCircleOppositeAnc4[1];
191
-
192
- return _objectSpread(_objectSpread({}, shapeWithNewDimensions), {
193
- translation: [originalShape.translation[0] - (newOppTrueX - oppTrueX), originalShape.translation[1] - (newOppTrueY - oppTrueY)]
194
- });
155
+ const resizeCircle = (cursorPosition, canvasOffset, originalShape, selectionMode, selectionPadding) => {
156
+ const {
157
+ center,
158
+ borders
159
+ } = (0, _shapeData.getShapeInfos)(originalShape, selectionPadding);
160
+ const cursorPositionBeforeResize = (0, _intersect.getPointPositionAfterCanvasTransformation)(cursorPosition, canvasOffset, originalShape.translation, originalShape.rotation, center);
161
+ const newCursorPosition = [cursorPositionBeforeResize[0], cursorPositionBeforeResize[1]];
162
+ const scaledRadius = selectionMode.anchor[1] === 0.5 ? (selectionMode.anchor[0] === 0 ? borders.x + borders.width - newCursorPosition[0] + selectionPadding * (selectionMode.anchor[0] === 0 ? -2 : 2) : newCursorPosition[0] - borders.x - selectionPadding * (selectionMode.anchor[0] === 0 ? -2 : 2)) / 2 : (selectionMode.anchor[1] === 0 ? borders.y + borders.height - newCursorPosition[1] + selectionPadding * (selectionMode.anchor[1] === 0 ? -2 : 2) : newCursorPosition[1] - borders.y - selectionPadding * (selectionMode.anchor[1] === 0 ? -2 : 2)) / 2;
163
+ const shapeWithNewDimensions = { ...originalShape,
164
+ ...{
165
+ radius: Math.abs(scaledRadius)
166
+ }
167
+ };
168
+ const {
169
+ center: shapeWithNewDimensionsCenter
170
+ } = (0, _shapeData.getShapeInfos)(shapeWithNewDimensions, selectionPadding);
171
+ const [oppTrueX, oppTrueY] = getCircleOppositeAnchorAbsolutePosition(selectionMode.anchor, center, originalShape);
172
+ const [newOppTrueX, newOppTrueY] = getCircleOppositeAnchorAbsolutePosition(selectionMode.anchor, shapeWithNewDimensionsCenter, shapeWithNewDimensions, [scaledRadius < 0, scaledRadius < 0]);
173
+ return { ...shapeWithNewDimensions,
174
+ ...{
175
+ translation: [originalShape.translation[0] - (newOppTrueX - oppTrueX), originalShape.translation[1] - (newOppTrueY - oppTrueY)]
176
+ }
177
+ };
195
178
  };
196
179
 
197
180
  exports.resizeCircle = resizeCircle;
198
181
 
199
- var resizeEllipse = function resizeEllipse(cursorPosition, canvasOffset, originalShape, selectionMode, selectionPadding) {
200
- var _getShapeInfos6 = (0, _shapeData.getShapeInfos)(originalShape, selectionPadding),
201
- center = _getShapeInfos6.center,
202
- borders = _getShapeInfos6.borders;
203
-
204
- var cursorPositionBeforeResize = (0, _intersect.getPointPositionAfterCanvasTransformation)(cursorPosition, canvasOffset, originalShape.translation, originalShape.rotation, center);
205
- var newCursorPosition = [cursorPositionBeforeResize[0], cursorPositionBeforeResize[1]];
206
- var scaledRadiusX = selectionMode.anchor[0] === 0.5 ? originalShape.radiusX : (selectionMode.anchor[0] === 0 ? borders.x + borders.width - newCursorPosition[0] + selectionPadding * (selectionMode.anchor[0] === 0 ? -2 : 2) : newCursorPosition[0] - borders.x - selectionPadding * (selectionMode.anchor[0] === 0 ? -2 : 2)) / 2;
207
- var scaledRadiusY = selectionMode.anchor[1] === 0.5 ? originalShape.radiusY : (selectionMode.anchor[1] === 0 ? borders.y + borders.height - newCursorPosition[1] + selectionPadding * (selectionMode.anchor[1] === 0 ? -2 : 2) : newCursorPosition[1] - borders.y - selectionPadding * (selectionMode.anchor[1] === 0 ? -2 : 2)) / 2;
208
-
209
- var shapeWithNewDimensions = _objectSpread(_objectSpread({}, originalShape), {
210
- radiusX: Math.abs(scaledRadiusX),
211
- radiusY: Math.abs(scaledRadiusY)
212
- });
213
-
214
- var _getShapeInfos7 = (0, _shapeData.getShapeInfos)(shapeWithNewDimensions, selectionPadding),
215
- shapeWithNewDimensionsCenter = _getShapeInfos7.center;
216
-
217
- var _getEllipseOppositeAn = getEllipseOppositeAnchorAbsolutePosition(selectionMode.anchor, center, originalShape),
218
- _getEllipseOppositeAn2 = (0, _slicedToArray2["default"])(_getEllipseOppositeAn, 2),
219
- oppTrueX = _getEllipseOppositeAn2[0],
220
- oppTrueY = _getEllipseOppositeAn2[1];
221
-
222
- var _getEllipseOppositeAn3 = getEllipseOppositeAnchorAbsolutePosition(selectionMode.anchor, shapeWithNewDimensionsCenter, shapeWithNewDimensions, [scaledRadiusX < 0, scaledRadiusY < 0]),
223
- _getEllipseOppositeAn4 = (0, _slicedToArray2["default"])(_getEllipseOppositeAn3, 2),
224
- newOppTrueX = _getEllipseOppositeAn4[0],
225
- newOppTrueY = _getEllipseOppositeAn4[1];
226
-
227
- return _objectSpread(_objectSpread({}, shapeWithNewDimensions), {
228
- translation: [originalShape.translation[0] - (newOppTrueX - oppTrueX), originalShape.translation[1] - (newOppTrueY - oppTrueY)]
229
- });
182
+ const resizeEllipse = (cursorPosition, canvasOffset, originalShape, selectionMode, selectionPadding) => {
183
+ const {
184
+ center,
185
+ borders
186
+ } = (0, _shapeData.getShapeInfos)(originalShape, selectionPadding);
187
+ const cursorPositionBeforeResize = (0, _intersect.getPointPositionAfterCanvasTransformation)(cursorPosition, canvasOffset, originalShape.translation, originalShape.rotation, center);
188
+ const newCursorPosition = [cursorPositionBeforeResize[0], cursorPositionBeforeResize[1]];
189
+ const scaledRadiusX = selectionMode.anchor[0] === 0.5 ? originalShape.radiusX : (selectionMode.anchor[0] === 0 ? borders.x + borders.width - newCursorPosition[0] + selectionPadding * (selectionMode.anchor[0] === 0 ? -2 : 2) : newCursorPosition[0] - borders.x - selectionPadding * (selectionMode.anchor[0] === 0 ? -2 : 2)) / 2;
190
+ const scaledRadiusY = selectionMode.anchor[1] === 0.5 ? originalShape.radiusY : (selectionMode.anchor[1] === 0 ? borders.y + borders.height - newCursorPosition[1] + selectionPadding * (selectionMode.anchor[1] === 0 ? -2 : 2) : newCursorPosition[1] - borders.y - selectionPadding * (selectionMode.anchor[1] === 0 ? -2 : 2)) / 2;
191
+ const shapeWithNewDimensions = { ...originalShape,
192
+ ...{
193
+ radiusX: Math.abs(scaledRadiusX),
194
+ radiusY: Math.abs(scaledRadiusY)
195
+ }
196
+ };
197
+ const {
198
+ center: shapeWithNewDimensionsCenter
199
+ } = (0, _shapeData.getShapeInfos)(shapeWithNewDimensions, selectionPadding);
200
+ const [oppTrueX, oppTrueY] = getEllipseOppositeAnchorAbsolutePosition(selectionMode.anchor, center, originalShape);
201
+ const [newOppTrueX, newOppTrueY] = getEllipseOppositeAnchorAbsolutePosition(selectionMode.anchor, shapeWithNewDimensionsCenter, shapeWithNewDimensions, [scaledRadiusX < 0, scaledRadiusY < 0]);
202
+ return { ...shapeWithNewDimensions,
203
+ ...{
204
+ translation: [originalShape.translation[0] - (newOppTrueX - oppTrueX), originalShape.translation[1] - (newOppTrueY - oppTrueY)]
205
+ }
206
+ };
230
207
  };
231
208
 
232
209
  exports.resizeEllipse = resizeEllipse;
233
210
 
234
- var resizeRect = function resizeRect(cursorPosition, canvasOffset, originalShape, selectionMode, selectionPadding) {
235
- var keepRatio = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
236
-
237
- var _getShapeInfos8 = (0, _shapeData.getShapeInfos)(originalShape, selectionPadding),
238
- center = _getShapeInfos8.center,
239
- borders = _getShapeInfos8.borders;
240
-
241
- var cursorPositionBeforeResize = (0, _intersect.getPointPositionAfterCanvasTransformation)(cursorPosition, canvasOffset, originalShape.translation, originalShape.rotation, center);
242
- var scaledWidth = selectionMode.anchor[0] === 0.5 ? originalShape.width : selectionMode.anchor[0] === 0 ? borders.x + borders.width - cursorPositionBeforeResize[0] + selectionPadding * -2 : cursorPositionBeforeResize[0] - borders.x - selectionPadding * 2;
243
- var scaledHeight = selectionMode.anchor[1] === 0.5 ? originalShape.height : selectionMode.anchor[1] === 0 ? borders.y + borders.height - cursorPositionBeforeResize[1] + selectionPadding * -2 : cursorPositionBeforeResize[1] - borders.y - selectionPadding * 2;
244
-
245
- var _ref = keepRatio ? getNormalizedSize(originalShape, scaledWidth, scaledHeight) : [scaledWidth, scaledHeight],
246
- _ref2 = (0, _slicedToArray2["default"])(_ref, 2),
247
- widthWithRatio = _ref2[0],
248
- heightWithRatio = _ref2[1];
249
-
250
- var shapeWithNewDimensions = _objectSpread(_objectSpread({}, originalShape), {}, {
211
+ const resizeRect = function (cursorPosition, canvasOffset, originalShape, selectionMode, selectionPadding) {
212
+ let keepRatio = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
213
+ const {
214
+ center,
215
+ borders
216
+ } = (0, _shapeData.getShapeInfos)(originalShape, selectionPadding);
217
+ const cursorPositionBeforeResize = (0, _intersect.getPointPositionAfterCanvasTransformation)(cursorPosition, canvasOffset, originalShape.translation, originalShape.rotation, center);
218
+ const scaledWidth = selectionMode.anchor[0] === 0.5 ? originalShape.width : selectionMode.anchor[0] === 0 ? borders.x + borders.width - cursorPositionBeforeResize[0] + selectionPadding * -2 : cursorPositionBeforeResize[0] - borders.x - selectionPadding * 2;
219
+ const scaledHeight = selectionMode.anchor[1] === 0.5 ? originalShape.height : selectionMode.anchor[1] === 0 ? borders.y + borders.height - cursorPositionBeforeResize[1] + selectionPadding * -2 : cursorPositionBeforeResize[1] - borders.y - selectionPadding * 2;
220
+ const [widthWithRatio, heightWithRatio] = keepRatio ? getNormalizedSize(originalShape, scaledWidth, scaledHeight) : [scaledWidth, scaledHeight];
221
+ const shapeWithNewDimensions = { ...originalShape,
251
222
  width: Math.abs(widthWithRatio),
252
223
  height: Math.abs(heightWithRatio)
253
- });
254
-
255
- var _getShapeInfos9 = (0, _shapeData.getShapeInfos)(shapeWithNewDimensions, selectionPadding),
256
- shapeWithNewDimensionsCenter = _getShapeInfos9.center;
257
-
258
- var _getRectOppositeAncho5 = getRectOppositeAnchorAbsolutePosition(selectionMode.anchor, center, originalShape),
259
- _getRectOppositeAncho6 = (0, _slicedToArray2["default"])(_getRectOppositeAncho5, 2),
260
- oppTrueX = _getRectOppositeAncho6[0],
261
- oppTrueY = _getRectOppositeAncho6[1];
262
-
263
- var _getRectOppositeAncho7 = getRectOppositeAnchorAbsolutePosition(selectionMode.anchor, shapeWithNewDimensionsCenter, shapeWithNewDimensions, [widthWithRatio < 0, heightWithRatio < 0]),
264
- _getRectOppositeAncho8 = (0, _slicedToArray2["default"])(_getRectOppositeAncho7, 2),
265
- newOppTrueX = _getRectOppositeAncho8[0],
266
- newOppTrueY = _getRectOppositeAncho8[1];
267
-
268
- return _objectSpread(_objectSpread({}, shapeWithNewDimensions), {
269
- translation: [originalShape.translation[0] - (newOppTrueX - oppTrueX), originalShape.translation[1] - (newOppTrueY - oppTrueY)]
270
- });
224
+ };
225
+ const {
226
+ center: shapeWithNewDimensionsCenter
227
+ } = (0, _shapeData.getShapeInfos)(shapeWithNewDimensions, selectionPadding);
228
+ const [oppTrueX, oppTrueY] = getRectOppositeAnchorAbsolutePosition(selectionMode.anchor, center, originalShape);
229
+ const [newOppTrueX, newOppTrueY] = getRectOppositeAnchorAbsolutePosition(selectionMode.anchor, shapeWithNewDimensionsCenter, shapeWithNewDimensions, [widthWithRatio < 0, heightWithRatio < 0]);
230
+ return { ...shapeWithNewDimensions,
231
+ ...{
232
+ translation: [originalShape.translation[0] - (newOppTrueX - oppTrueX), originalShape.translation[1] - (newOppTrueY - oppTrueY)]
233
+ }
234
+ };
271
235
  };
272
236
 
273
237
  exports.resizeRect = resizeRect;
274
238
 
275
- var resizeText = function resizeText(ctx, cursorPosition, canvasOffset, originalShape, selectionMode, selectionPadding) {
239
+ const resizeText = (ctx, cursorPosition, canvasOffset, originalShape, selectionMode, selectionPadding) => {
276
240
  var _newRect$style$fontBo, _newRect$style, _newRect$style$fontIt, _newRect$style2, _newRect$style3;
277
241
 
278
- var newRect = resizeRect(cursorPosition, canvasOffset, originalShape, selectionMode, selectionPadding, true);
279
- return _objectSpread(_objectSpread({}, newRect), {}, {
242
+ const newRect = resizeRect(cursorPosition, canvasOffset, originalShape, selectionMode, selectionPadding, true);
243
+ return { ...newRect,
280
244
  fontSize: calculateTextFontSize(ctx, newRect.value, newRect.width, (_newRect$style$fontBo = (_newRect$style = newRect.style) === null || _newRect$style === void 0 ? void 0 : _newRect$style.fontBold) !== null && _newRect$style$fontBo !== void 0 ? _newRect$style$fontBo : false, (_newRect$style$fontIt = (_newRect$style2 = newRect.style) === null || _newRect$style2 === void 0 ? void 0 : _newRect$style2.fontItalic) !== null && _newRect$style$fontIt !== void 0 ? _newRect$style$fontIt : false, (_newRect$style3 = newRect.style) === null || _newRect$style3 === void 0 ? void 0 : _newRect$style3.fontFamily)
281
- });
245
+ };
282
246
  };
283
247
 
284
248
  exports.resizeText = resizeText;
285
249
 
286
- var getRectOppositeAnchorAbsolutePosition = function getRectOppositeAnchorAbsolutePosition(anchor, center, shape) {
287
- var _ref3 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [false, false],
288
- _ref4 = (0, _slicedToArray2["default"])(_ref3, 2),
289
- negW = _ref4[0],
290
- negH = _ref4[1];
291
-
292
- var oppositeX = (anchor[0] === 0.5 ? shape.x + shape.width / 2 : anchor[0] === 0 ? shape.x + (negW ? 0 : shape.width) : shape.x + (negW ? shape.width : 0)) + shape.translation[0];
293
- var oppositeY = (anchor[1] === 0.5 ? shape.y + shape.height / 2 : anchor[1] === 0 ? shape.y + (negH ? 0 : shape.height) : shape.y + (negH ? shape.height : 0)) + shape.translation[1];
250
+ const getRectOppositeAnchorAbsolutePosition = function (anchor, center, shape) {
251
+ let [negW, negH] = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [false, false];
252
+ const oppositeX = (anchor[0] === 0.5 ? shape.x + shape.width / 2 : anchor[0] === 0 ? shape.x + (negW ? 0 : shape.width) : shape.x + (negW ? shape.width : 0)) + shape.translation[0];
253
+ const oppositeY = (anchor[1] === 0.5 ? shape.y + shape.height / 2 : anchor[1] === 0 ? shape.y + (negH ? 0 : shape.height) : shape.y + (negH ? shape.height : 0)) + shape.translation[1];
294
254
  return (0, _intersect.getPointPositionBeforeCanvasTransformation)([oppositeX, oppositeY], shape.translation, shape.rotation, center);
295
255
  };
296
256
 
297
- var getEllipseOppositeAnchorAbsolutePosition = function getEllipseOppositeAnchorAbsolutePosition(anchor, center, shape) {
298
- var _ref5 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [false, false],
299
- _ref6 = (0, _slicedToArray2["default"])(_ref5, 2),
300
- negW = _ref6[0],
301
- negH = _ref6[1];
302
-
303
- var oppositeX = (anchor[0] === 0.5 ? shape.x + shape.radiusX / 2 : anchor[0] === 0 ? shape.x + (negW ? -shape.radiusX : shape.radiusX) : shape.x + (negW ? shape.radiusX : -shape.radiusX)) + shape.translation[0];
304
- var oppositeY = (anchor[1] === 0.5 ? shape.y + shape.radiusY / 2 : anchor[1] === 0 ? shape.y + (negH ? -shape.radiusY : shape.radiusY) : shape.y + (negH ? shape.radiusY : -shape.radiusY)) + shape.translation[1];
257
+ const getEllipseOppositeAnchorAbsolutePosition = function (anchor, center, shape) {
258
+ let [negW, negH] = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [false, false];
259
+ const oppositeX = (anchor[0] === 0.5 ? shape.x + shape.radiusX / 2 : anchor[0] === 0 ? shape.x + (negW ? -shape.radiusX : shape.radiusX) : shape.x + (negW ? shape.radiusX : -shape.radiusX)) + shape.translation[0];
260
+ const oppositeY = (anchor[1] === 0.5 ? shape.y + shape.radiusY / 2 : anchor[1] === 0 ? shape.y + (negH ? -shape.radiusY : shape.radiusY) : shape.y + (negH ? shape.radiusY : -shape.radiusY)) + shape.translation[1];
305
261
  return (0, _intersect.getPointPositionBeforeCanvasTransformation)([oppositeX, oppositeY], shape.translation, shape.rotation, center);
306
262
  };
307
263
 
308
- var getCircleOppositeAnchorAbsolutePosition = function getCircleOppositeAnchorAbsolutePosition(anchor, center, shape) {
309
- var _ref7 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [false, false],
310
- _ref8 = (0, _slicedToArray2["default"])(_ref7, 2),
311
- negW = _ref8[0],
312
- negH = _ref8[1];
313
-
314
- var oppositeX = (anchor[0] === 0.5 ? shape.x : anchor[0] === 0 ? shape.x + (negW ? -shape.radius : shape.radius) : shape.x + (negW ? shape.radius : -shape.radius)) + shape.translation[0];
315
- var oppositeY = (anchor[1] === 0.5 ? shape.y : anchor[1] === 0 ? shape.y + (negH ? -shape.radius : shape.radius) : shape.y + (negH ? shape.radius : -shape.radius)) + shape.translation[1];
264
+ const getCircleOppositeAnchorAbsolutePosition = function (anchor, center, shape) {
265
+ let [negW, negH] = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [false, false];
266
+ const oppositeX = (anchor[0] === 0.5 ? shape.x : anchor[0] === 0 ? shape.x + (negW ? -shape.radius : shape.radius) : shape.x + (negW ? shape.radius : -shape.radius)) + shape.translation[0];
267
+ const oppositeY = (anchor[1] === 0.5 ? shape.y : anchor[1] === 0 ? shape.y + (negH ? -shape.radius : shape.radius) : shape.y + (negH ? shape.radius : -shape.radius)) + shape.translation[1];
316
268
  return (0, _intersect.getPointPositionBeforeCanvasTransformation)([oppositeX, oppositeY], shape.translation, shape.rotation, center);
317
269
  };
318
270
 
319
- var resizePicture = function resizePicture(cursorPosition, canvasOffset, originalShape, selectionMode, selectionPadding) {
271
+ const resizePicture = (cursorPosition, canvasOffset, originalShape, selectionMode, selectionPadding) => {
320
272
  return resizeRect(cursorPosition, canvasOffset, originalShape, selectionMode, selectionPadding, true);
321
273
  };
322
274
 
323
275
  exports.resizePicture = resizePicture;
324
276
 
325
- var resizeShape = function resizeShape(ctx, shape, cursorPosition, canvasOffset, originalShape, selectionMode, selectionPadding) {
277
+ const resizeShape = (ctx, shape, cursorPosition, canvasOffset, originalShape, selectionMode, selectionPadding) => {
326
278
  if (shape.type === 'line' || shape.type === 'polygon' || shape.type === 'curve') return resizeLine(cursorPosition, canvasOffset, originalShape, selectionMode, selectionPadding);else if (shape.type === 'brush') return resizeBrush(cursorPosition, canvasOffset, originalShape, selectionMode, selectionPadding);else if (shape.type === 'circle') return resizeCircle(cursorPosition, canvasOffset, originalShape, selectionMode, selectionPadding);else if (shape.type === 'ellipse') return resizeEllipse(cursorPosition, canvasOffset, originalShape, selectionMode, selectionPadding);else if (shape.type === 'rect') return resizeRect(cursorPosition, canvasOffset, originalShape, selectionMode, selectionPadding);else if (shape.type === 'square') return resizeRect(cursorPosition, canvasOffset, originalShape, selectionMode, selectionPadding, true);else if (shape.type === 'text') return resizeText(ctx, cursorPosition, canvasOffset, originalShape, selectionMode, selectionPadding);else if (shape.type === 'picture') return resizePicture(cursorPosition, canvasOffset, originalShape, selectionMode, selectionPadding);
327
279
  return shape;
328
280
  };
329
281
 
330
282
  exports.resizeShape = resizeShape;
331
283
 
332
- var transformShape = function transformShape(ctx, shape, cursorPosition, canvasOffset, selectionMode, selectionPadding) {
284
+ const transformShape = (ctx, shape, cursorPosition, canvasOffset, selectionMode, selectionPadding) => {
333
285
  if (selectionMode.mode === _Mode.SelectionModeLib.brush) {
334
286
  return paintNewPointToShape(shape, cursorPosition);
335
287
  } else if (selectionMode.mode === _Mode.SelectionModeLib.translate) {
@@ -345,52 +297,44 @@ var transformShape = function transformShape(ctx, shape, cursorPosition, canvasO
345
297
 
346
298
  exports.transformShape = transformShape;
347
299
 
348
- var calculateTextFontSize = function calculateTextFontSize(ctx, text, maxWidth, fontBold, fontItalic) {
300
+ const calculateTextFontSize = function (ctx, text, maxWidth, fontBold, fontItalic) {
349
301
  var _$flow;
350
302
 
351
- var fontFamily = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : _style.STYLE_FONT_DEFAULT;
303
+ let fontFamily = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : _style.STYLE_FONT_DEFAULT;
352
304
  ctx.font = "".concat(fontItalic ? 'italic' : '', " ").concat(fontBold ? 'bold' : '', " 1px ").concat(fontFamily);
353
- return (_$flow = _fp["default"].flow(_fp["default"].map(function (value) {
354
- return maxWidth / ctx.measureText(value).width;
355
- }), _fp["default"].min)(text)) !== null && _$flow !== void 0 ? _$flow : _style.STYLE_FONT_SIZE_DEFAULT;
305
+ return (_$flow = _fp.default.flow(_fp.default.map(value => maxWidth / ctx.measureText(value).width), _fp.default.min)(text)) !== null && _$flow !== void 0 ? _$flow : _style.STYLE_FONT_SIZE_DEFAULT;
356
306
  };
357
307
 
358
308
  exports.calculateTextFontSize = calculateTextFontSize;
359
309
 
360
- var calculateTextWidth = function calculateTextWidth(ctx, text, fontSize, fontBold, fontItalic) {
310
+ const calculateTextWidth = function (ctx, text, fontSize, fontBold, fontItalic) {
361
311
  var _$flow2;
362
312
 
363
- var fontFamily = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : _style.STYLE_FONT_DEFAULT;
313
+ let fontFamily = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : _style.STYLE_FONT_DEFAULT;
364
314
  ctx.font = "".concat(fontItalic ? 'italic' : '', " ").concat(fontBold ? 'bold' : '', " ").concat(fontSize, "px ").concat(fontFamily);
365
- return (_$flow2 = _fp["default"].flow(_fp["default"].map(function (value) {
366
- return ctx.measureText(value).width;
367
- }), _fp["default"].max)(text)) !== null && _$flow2 !== void 0 ? _$flow2 : 20;
315
+ return (_$flow2 = _fp.default.flow(_fp.default.map(value => ctx.measureText(value).width), _fp.default.max)(text)) !== null && _$flow2 !== void 0 ? _$flow2 : 20;
368
316
  };
369
317
 
370
318
  exports.calculateTextWidth = calculateTextWidth;
371
319
 
372
- var degreesToRadians = function degreesToRadians(degrees) {
373
- return degrees * (Math.PI / 180);
374
- };
320
+ const degreesToRadians = degrees => degrees * (Math.PI / 180);
375
321
 
376
322
  exports.degreesToRadians = degreesToRadians;
377
323
 
378
- var radiansToDegrees = function radiansToDegrees(radians) {
379
- return radians * 180 / Math.PI;
380
- };
324
+ const radiansToDegrees = radians => radians * 180 / Math.PI;
381
325
 
382
326
  exports.radiansToDegrees = radiansToDegrees;
383
327
 
384
- var fitContentInsideContainer = function fitContentInsideContainer(contentWidth, contentHeight, containerWidth, containerHeight) {
385
- var shouldFillContainer = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
386
- var contentRatio = contentWidth / contentHeight;
387
- var containerRatio = containerWidth / containerHeight;
328
+ const fitContentInsideContainer = function (contentWidth, contentHeight, containerWidth, containerHeight) {
329
+ let shouldFillContainer = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
330
+ const contentRatio = contentWidth / contentHeight;
331
+ const containerRatio = containerWidth / containerHeight;
388
332
 
389
333
  if (contentRatio > containerRatio) {
390
- var newWidth = shouldFillContainer ? containerWidth : Math.min(contentWidth, containerWidth);
334
+ const newWidth = shouldFillContainer ? containerWidth : Math.min(contentWidth, containerWidth);
391
335
  return [newWidth, newWidth / contentRatio];
392
336
  } else {
393
- var newHeight = shouldFillContainer ? containerHeight : Math.min(contentHeight, containerHeight);
337
+ const newHeight = shouldFillContainer ? containerHeight : Math.min(contentHeight, containerHeight);
394
338
  return [newHeight * contentRatio, newHeight];
395
339
  }
396
340
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yorab/react-paint",
3
- "version": "0.6.5",
3
+ "version": "0.6.6",
4
4
  "keywords": [],
5
5
  "author": "Yohann Rabatel",
6
6
  "license": "MIT",
@@ -12,10 +12,7 @@
12
12
  "dist/"
13
13
  ],
14
14
  "dependencies": {
15
- "@babel/runtime": "^7.16.7",
16
- "@linaria/core": "^3.0.0-beta.15",
17
- "@linaria/react": "^3.0.0-beta.15",
18
- "lodash": "^4.17.20"
15
+ "@linaria/react": "^3.0.0-beta.15"
19
16
  },
20
17
  "devDependencies": {
21
18
  "@babel/cli": "7.12.8",
@@ -24,7 +21,9 @@
24
21
  "@babel/preset-env": "^7.16.8",
25
22
  "@babel/preset-react": "^7.16.7",
26
23
  "@babel/preset-typescript": "^7.16.7",
24
+ "@babel/runtime": "^7.16.7",
27
25
  "@linaria/babel-preset": "^3.0.0-beta.15",
26
+ "@linaria/core": "^3.0.0-beta.15",
28
27
  "@linaria/shaker": "^3.0.0-beta.15",
29
28
  "@linaria/webpack-loader": "^3.0.0-beta.16",
30
29
  "@testing-library/jest-dom": "^5.11.4",
@@ -49,6 +48,7 @@
49
48
  "eslint-plugin-react-hooks": "^4.2.0",
50
49
  "html-webpack-plugin": "^5.5.0",
51
50
  "mini-css-extract-plugin": "^2.6.0",
51
+ "lodash": "^4.17.20",
52
52
  "prettier": "^2.3.2",
53
53
  "react": "18.1.0",
54
54
  "react-dom": "18.1.0",
@@ -58,6 +58,7 @@
58
58
  "webpack-dev-server": "^4.7.3"
59
59
  },
60
60
  "peerDependencies": {
61
+ "lodash" : "*",
61
62
  "react": "*",
62
63
  "react-dom": "*"
63
64
  },