@pie-element/hotspot 9.3.4-next.3 → 10.0.0-beta.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.
- package/CHANGELOG.md +0 -11
- package/configure/CHANGELOG.md +0 -11
- package/configure/lib/DeleteWidget.js +30 -43
- package/configure/lib/DeleteWidget.js.map +1 -1
- package/configure/lib/button.js +26 -45
- package/configure/lib/button.js.map +1 -1
- package/configure/lib/buttons/circle.js +20 -27
- package/configure/lib/buttons/circle.js.map +1 -1
- package/configure/lib/buttons/polygon.js +26 -33
- package/configure/lib/buttons/polygon.js.map +1 -1
- package/configure/lib/buttons/rectangle.js +26 -33
- package/configure/lib/buttons/rectangle.js.map +1 -1
- package/configure/lib/defaults.js +2 -3
- package/configure/lib/defaults.js.map +1 -1
- package/configure/lib/hotspot-circle.js +132 -198
- package/configure/lib/hotspot-circle.js.map +1 -1
- package/configure/lib/hotspot-container.js +250 -355
- package/configure/lib/hotspot-container.js.map +1 -1
- package/configure/lib/hotspot-drawable.js +360 -472
- package/configure/lib/hotspot-drawable.js.map +1 -1
- package/configure/lib/hotspot-palette.js +92 -139
- package/configure/lib/hotspot-palette.js.map +1 -1
- package/configure/lib/hotspot-polygon.js +212 -317
- package/configure/lib/hotspot-polygon.js.map +1 -1
- package/configure/lib/hotspot-rectangle.js +128 -192
- package/configure/lib/hotspot-rectangle.js.map +1 -1
- package/configure/lib/icons.js.map +1 -1
- package/configure/lib/image-konva.js +46 -86
- package/configure/lib/image-konva.js.map +1 -1
- package/configure/lib/index.js +162 -222
- package/configure/lib/index.js.map +1 -1
- package/configure/lib/root.js +302 -394
- package/configure/lib/root.js.map +1 -1
- package/configure/lib/shapes/circle.js +69 -101
- package/configure/lib/shapes/circle.js.map +1 -1
- package/configure/lib/shapes/index.js +4 -12
- package/configure/lib/shapes/index.js.map +1 -1
- package/configure/lib/shapes/polygon.js +64 -96
- package/configure/lib/shapes/polygon.js.map +1 -1
- package/configure/lib/shapes/rectagle.js +69 -101
- package/configure/lib/shapes/rectagle.js.map +1 -1
- package/configure/lib/shapes/utils.js +2 -8
- package/configure/lib/shapes/utils.js.map +1 -1
- package/configure/lib/upload-control.js +25 -52
- package/configure/lib/upload-control.js.map +1 -1
- package/configure/lib/utils.js +84 -137
- package/configure/lib/utils.js.map +1 -1
- package/configure/package.json +11 -10
- package/configure/src/__tests__/hotspot-container.test.js +50 -19
- package/configure/src/__tests__/hotspot-drawable.test.js +55 -34
- package/configure/src/__tests__/index.test.js +167 -5
- package/configure/src/__tests__/root.test.js +89 -63
- package/configure/src/button.jsx +12 -20
- package/configure/src/hotspot-circle.jsx +5 -18
- package/configure/src/hotspot-container.jsx +82 -98
- package/configure/src/hotspot-drawable.jsx +43 -45
- package/configure/src/hotspot-palette.jsx +45 -37
- package/configure/src/hotspot-polygon.jsx +4 -20
- package/configure/src/hotspot-rectangle.jsx +4 -17
- package/configure/src/index.js +12 -2
- package/configure/src/root.jsx +86 -80
- package/configure/src/upload-control.jsx +6 -16
- package/controller/CHANGELOG.md +0 -11
- package/controller/lib/defaults.js +2 -3
- package/controller/lib/defaults.js.map +1 -1
- package/controller/lib/index.js +151 -205
- package/controller/lib/index.js.map +1 -1
- package/controller/lib/utils.js +14 -34
- package/controller/lib/utils.js.map +1 -1
- package/controller/package.json +2 -2
- package/lib/hotspot/circle.js +110 -169
- package/lib/hotspot/circle.js.map +1 -1
- package/lib/hotspot/container.js +174 -260
- package/lib/hotspot/container.js.map +1 -1
- package/lib/hotspot/icons.js.map +1 -1
- package/lib/hotspot/image-konva-tooltip.js +65 -112
- package/lib/hotspot/image-konva-tooltip.js.map +1 -1
- package/lib/hotspot/index.js +135 -198
- package/lib/hotspot/index.js.map +1 -1
- package/lib/hotspot/polygon.js +150 -214
- package/lib/hotspot/polygon.js.map +1 -1
- package/lib/hotspot/rectangle.js +128 -185
- package/lib/hotspot/rectangle.js.map +1 -1
- package/lib/index.js +187 -256
- package/lib/index.js.map +1 -1
- package/lib/session-updater.js +12 -18
- package/lib/session-updater.js.map +1 -1
- package/package.json +14 -11
- package/src/__tests__/container.test.jsx +27 -175
- package/src/__tests__/index.test.js +70 -30
- package/src/hotspot/circle.jsx +2 -13
- package/src/hotspot/container.jsx +35 -50
- package/src/hotspot/index.jsx +16 -28
- package/src/hotspot/polygon.jsx +4 -13
- package/src/hotspot/rectangle.jsx +5 -15
- package/src/index.js +21 -12
- package/configure/src/__tests__/DeleteWidget.test.js +0 -64
- package/configure/src/__tests__/__snapshots__/hotspot-container.test.js.snap +0 -192
- package/configure/src/__tests__/__snapshots__/hotspot-drawable.test.js.snap +0 -562
- package/configure/src/__tests__/__snapshots__/root.test.js.snap +0 -469
- package/src/__tests__/__snapshots__/container.test.jsx.snap +0 -264
- package/src/__tests__/__snapshots__/index.test.js.snap +0 -81
- package/src/__tests__/__snapshots__/polygon.test.jsx.snap +0 -192
- package/src/__tests__/__snapshots__/rectangle.test.jsx.snap +0 -127
- package/src/__tests__/polygon.test.jsx +0 -230
- package/src/__tests__/rectangle.test.jsx +0 -232
|
@@ -1,400 +1,365 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
|
-
exports
|
|
9
|
-
|
|
7
|
+
exports.default = exports.Drawable = void 0;
|
|
10
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
|
-
|
|
12
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
13
|
-
|
|
14
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
15
|
-
|
|
16
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
17
|
-
|
|
18
|
-
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
19
|
-
|
|
20
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
21
|
-
|
|
22
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
23
|
-
|
|
24
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
25
|
-
|
|
26
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
27
|
-
|
|
28
10
|
var _react = _interopRequireDefault(require("react"));
|
|
29
|
-
|
|
30
11
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
31
|
-
|
|
32
12
|
var _reactKonva = require("react-konva");
|
|
33
|
-
|
|
34
13
|
var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
|
|
35
|
-
|
|
36
|
-
var _index = require("@material-ui/core/styles/index");
|
|
37
|
-
|
|
14
|
+
var _styles = require("@mui/material/styles");
|
|
38
15
|
var _hotspotRectangle = _interopRequireDefault(require("./hotspot-rectangle"));
|
|
39
|
-
|
|
40
16
|
var _hotspotPolygon = _interopRequireDefault(require("./hotspot-polygon"));
|
|
41
|
-
|
|
42
17
|
var _hotspotCircle = _interopRequireDefault(require("./hotspot-circle"));
|
|
43
|
-
|
|
44
18
|
var _utils = require("./utils");
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
19
|
+
var _shapes = require("./shapes");
|
|
20
|
+
const BaseContainer = (0, _styles.styled)('div')({
|
|
21
|
+
position: 'relative'
|
|
22
|
+
});
|
|
23
|
+
const ImageContainer = (0, _styles.styled)('div')({
|
|
24
|
+
position: 'relative',
|
|
25
|
+
width: 'fit-content'
|
|
26
|
+
});
|
|
27
|
+
const Image = (0, _styles.styled)('img')({
|
|
28
|
+
alignItems: 'center',
|
|
29
|
+
display: 'flex',
|
|
30
|
+
justifyContent: 'center'
|
|
31
|
+
});
|
|
32
|
+
const ResizeHandle = (0, _styles.styled)('div')({
|
|
33
|
+
borderBottom: '1px solid #727272',
|
|
34
|
+
borderRight: '1px solid #727272',
|
|
35
|
+
bottom: '-10px',
|
|
36
|
+
cursor: 'se-resize',
|
|
37
|
+
height: '10px',
|
|
38
|
+
position: 'absolute',
|
|
39
|
+
right: '-10px',
|
|
40
|
+
width: '10px'
|
|
41
|
+
});
|
|
42
|
+
const StyledStage = (0, _styles.styled)(_reactKonva.Stage)({
|
|
43
|
+
left: 0,
|
|
44
|
+
top: 0,
|
|
45
|
+
position: 'absolute'
|
|
46
|
+
});
|
|
47
|
+
const IMAGE_MAX_WIDTH = 800;
|
|
48
|
+
class Drawable extends _react.default.Component {
|
|
49
|
+
static getDerivedStateFromProps(nextProps, prevState) {
|
|
50
|
+
// Update the state only if the props have changed
|
|
51
|
+
if (nextProps.shapes !== prevState.shapes) {
|
|
52
|
+
return {
|
|
53
|
+
shapes: nextProps.shapes
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
constructor(props) {
|
|
59
|
+
super(props);
|
|
60
|
+
(0, _defineProperty2.default)(this, "handleOnMouseDown", e => {
|
|
61
|
+
const {
|
|
62
|
+
shapeType,
|
|
63
|
+
onUpdateShapes,
|
|
64
|
+
shapes
|
|
65
|
+
} = this.props;
|
|
66
|
+
let newState, newShapeId;
|
|
67
|
+
|
|
68
|
+
// Ensure that the click originated from the expected element
|
|
75
69
|
if (e.target !== e.currentTarget) {
|
|
76
70
|
return;
|
|
77
71
|
}
|
|
78
|
-
|
|
79
|
-
if (!Object.values(_shapes2.SUPPORTED_SHAPES).includes(shapeType)) {
|
|
72
|
+
if (!Object.values(_shapes.SUPPORTED_SHAPES).includes(shapeType)) {
|
|
80
73
|
return;
|
|
81
74
|
}
|
|
82
|
-
|
|
83
75
|
switch (shapeType) {
|
|
84
|
-
case
|
|
85
|
-
newState =
|
|
76
|
+
case _shapes.SUPPORTED_SHAPES.RECTANGLE:
|
|
77
|
+
newState = _shapes.RectangleShape.create(shapes, e);
|
|
86
78
|
break;
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
newState = _shapes2.CircleShape.create(shapes, e);
|
|
79
|
+
case _shapes.SUPPORTED_SHAPES.CIRCLE:
|
|
80
|
+
newState = _shapes.CircleShape.create(shapes, e);
|
|
90
81
|
break;
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
newShapeId = _this.state.isDrawingShapeId;
|
|
94
|
-
|
|
82
|
+
case _shapes.SUPPORTED_SHAPES.POLYGON:
|
|
83
|
+
newShapeId = this.state.isDrawingShapeId;
|
|
95
84
|
if (newShapeId) {
|
|
96
85
|
// If a polygon is in progress, add a new point
|
|
97
|
-
|
|
98
|
-
|
|
86
|
+
const shapes = this.addPolygonPoint(e);
|
|
99
87
|
newState = {
|
|
100
88
|
isDrawing: true,
|
|
101
89
|
isDrawingShapeId: newShapeId,
|
|
102
|
-
shapes:
|
|
90
|
+
shapes: shapes
|
|
103
91
|
};
|
|
104
92
|
} else {
|
|
105
93
|
// Else start a new one
|
|
106
|
-
newState =
|
|
94
|
+
newState = _shapes.PolygonShape.create(shapes, e);
|
|
107
95
|
}
|
|
108
|
-
|
|
109
96
|
break;
|
|
110
|
-
|
|
111
97
|
default:
|
|
112
98
|
return;
|
|
113
99
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
100
|
+
this.setState({
|
|
101
|
+
...newState
|
|
102
|
+
});
|
|
117
103
|
onUpdateShapes(newState.shapes);
|
|
118
104
|
});
|
|
119
|
-
(0, _defineProperty2
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
if (shapeType ===
|
|
105
|
+
(0, _defineProperty2.default)(this, "handleOnMouseUp", () => {
|
|
106
|
+
const {
|
|
107
|
+
shapeType,
|
|
108
|
+
onUpdateShapes
|
|
109
|
+
} = this.props;
|
|
110
|
+
let newState;
|
|
111
|
+
if (shapeType === _shapes.SUPPORTED_SHAPES.POLYGON) {
|
|
126
112
|
return;
|
|
127
113
|
}
|
|
128
|
-
|
|
129
114
|
switch (shapeType) {
|
|
130
|
-
case
|
|
131
|
-
newState =
|
|
115
|
+
case _shapes.SUPPORTED_SHAPES.RECTANGLE:
|
|
116
|
+
newState = _shapes.RectangleShape.finalizeCreation(this.state, this.props);
|
|
132
117
|
break;
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
newState = _shapes2.CircleShape.finalizeCreation(_this.state, _this.props);
|
|
118
|
+
case _shapes.SUPPORTED_SHAPES.CIRCLE:
|
|
119
|
+
newState = _shapes.CircleShape.finalizeCreation(this.state, this.props);
|
|
136
120
|
break;
|
|
137
|
-
|
|
138
121
|
default:
|
|
139
122
|
return;
|
|
140
123
|
}
|
|
141
|
-
|
|
142
|
-
|
|
124
|
+
this.setState({
|
|
125
|
+
...newState,
|
|
143
126
|
isDrawing: false
|
|
144
|
-
})
|
|
145
|
-
|
|
127
|
+
});
|
|
146
128
|
onUpdateShapes(newState.shapes);
|
|
147
129
|
});
|
|
148
|
-
(0, _defineProperty2
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
if (!
|
|
130
|
+
(0, _defineProperty2.default)(this, "handleMouseMove", e => {
|
|
131
|
+
const {
|
|
132
|
+
shapeType,
|
|
133
|
+
onUpdateShapes
|
|
134
|
+
} = this.props;
|
|
135
|
+
let newState;
|
|
136
|
+
if (!this.state.isDrawing || !Object.values(_shapes.SUPPORTED_SHAPES).includes(shapeType)) {
|
|
155
137
|
return;
|
|
156
138
|
}
|
|
157
|
-
|
|
158
139
|
switch (shapeType) {
|
|
159
|
-
case
|
|
160
|
-
newState =
|
|
140
|
+
case _shapes.SUPPORTED_SHAPES.RECTANGLE:
|
|
141
|
+
newState = _shapes.RectangleShape.handleMouseMove(this.state, e);
|
|
161
142
|
break;
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
newState = _shapes2.CircleShape.handleMouseMove(_this.state, e);
|
|
143
|
+
case _shapes.SUPPORTED_SHAPES.CIRCLE:
|
|
144
|
+
newState = _shapes.CircleShape.handleMouseMove(this.state, e);
|
|
165
145
|
break;
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
newState = _shapes2.PolygonShape.handleMouseMove(_this.state, e);
|
|
146
|
+
case _shapes.SUPPORTED_SHAPES.POLYGON:
|
|
147
|
+
newState = _shapes.PolygonShape.handleMouseMove(this.state, e);
|
|
169
148
|
break;
|
|
170
|
-
|
|
171
149
|
default:
|
|
172
150
|
return;
|
|
173
151
|
}
|
|
174
|
-
|
|
175
|
-
_this.setState(newState);
|
|
176
|
-
|
|
152
|
+
this.setState(newState);
|
|
177
153
|
onUpdateShapes(newState.shapes);
|
|
178
154
|
});
|
|
179
|
-
(0, _defineProperty2
|
|
180
|
-
if (
|
|
181
|
-
|
|
155
|
+
(0, _defineProperty2.default)(this, "handleOnMouseOutOrLeave", e => {
|
|
156
|
+
if (this.state.isDrawing) {
|
|
157
|
+
this.handleOnMouseUp(e);
|
|
182
158
|
}
|
|
183
159
|
});
|
|
184
|
-
(0, _defineProperty2
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
160
|
+
(0, _defineProperty2.default)(this, "handleOnDragEnd", (id, updatedProps) => {
|
|
161
|
+
const {
|
|
162
|
+
shapes,
|
|
163
|
+
onUpdateShapes,
|
|
164
|
+
dimensions
|
|
165
|
+
} = this.props;
|
|
166
|
+
const {
|
|
167
|
+
width: canvasWidth,
|
|
168
|
+
height: canvasHeight
|
|
169
|
+
} = dimensions;
|
|
170
|
+
|
|
171
|
+
// when a shape is moved completely outside the canvas
|
|
191
172
|
// remove that shape
|
|
192
|
-
|
|
193
|
-
var newShapes = shapes.map(function (shape) {
|
|
173
|
+
const newShapes = shapes.map(shape => {
|
|
194
174
|
if (shape.id !== id) {
|
|
195
175
|
return shape;
|
|
196
176
|
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
var newY = updatedProps.y;
|
|
200
|
-
|
|
177
|
+
let newX = updatedProps.x;
|
|
178
|
+
let newY = updatedProps.y;
|
|
201
179
|
if (shape.group === 'rectangles') {
|
|
202
180
|
if (newX + shape.width < 0 || newX > canvasWidth || newY + shape.height < 0 || newY > canvasHeight) {
|
|
203
181
|
return null;
|
|
204
182
|
}
|
|
205
|
-
|
|
206
|
-
|
|
183
|
+
return {
|
|
184
|
+
...shape,
|
|
185
|
+
...updatedProps
|
|
186
|
+
};
|
|
207
187
|
}
|
|
208
|
-
|
|
209
188
|
if (shape.group === 'circles') {
|
|
210
|
-
|
|
211
|
-
|
|
189
|
+
const radius = shape.radius;
|
|
212
190
|
if (newX + radius < 0 || newX - radius > canvasWidth || newY + radius < 0 || newY - radius > canvasHeight) {
|
|
213
191
|
return null;
|
|
214
192
|
}
|
|
215
|
-
|
|
216
|
-
|
|
193
|
+
return {
|
|
194
|
+
...shape,
|
|
195
|
+
...updatedProps
|
|
196
|
+
};
|
|
217
197
|
}
|
|
218
|
-
|
|
219
198
|
if (shape.group === 'polygons') {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
var deltaX = updatedProps['points'][0].x - points[0].x;
|
|
233
|
-
var deltaY = updatedProps['points'][0].y - points[0].y;
|
|
199
|
+
const points = shape.points;
|
|
200
|
+
const xValues = points.map(point => point.x);
|
|
201
|
+
const yValues = points.map(point => point.y);
|
|
202
|
+
let minX = Math.min(...xValues);
|
|
203
|
+
let minY = Math.min(...yValues);
|
|
204
|
+
let maxX = Math.max(...xValues);
|
|
205
|
+
let maxY = Math.max(...yValues);
|
|
206
|
+
|
|
207
|
+
// Calculate deltas based on the first point as a reference
|
|
208
|
+
const deltaX = updatedProps['points'][0].x - points[0].x;
|
|
209
|
+
const deltaY = updatedProps['points'][0].y - points[0].y;
|
|
234
210
|
minX = minX + deltaX;
|
|
235
211
|
maxX = maxX + deltaX;
|
|
236
212
|
minY = minY + deltaY;
|
|
237
213
|
maxY = maxY + deltaY;
|
|
238
|
-
|
|
239
214
|
if (maxX < 0 || minX > canvasWidth || maxY < 0 || minY > canvasHeight) {
|
|
240
215
|
return null;
|
|
241
216
|
}
|
|
242
|
-
|
|
243
|
-
|
|
217
|
+
return {
|
|
218
|
+
...shape,
|
|
219
|
+
...updatedProps
|
|
220
|
+
};
|
|
244
221
|
}
|
|
245
|
-
|
|
246
222
|
return shape;
|
|
247
|
-
}).filter(
|
|
248
|
-
|
|
249
|
-
});
|
|
250
|
-
onUpdateShapes((0, _cloneDeep["default"])(newShapes));
|
|
223
|
+
}).filter(shape => shape !== null);
|
|
224
|
+
onUpdateShapes((0, _cloneDeep.default)(newShapes));
|
|
251
225
|
});
|
|
252
|
-
(0, _defineProperty2
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
_shapes2.PolygonShape.finalizeCreation(_this.state, function (newShapes) {
|
|
262
|
-
_this.setState({
|
|
226
|
+
(0, _defineProperty2.default)(this, "closeInProgressPolygons", id => {
|
|
227
|
+
const {
|
|
228
|
+
shapes,
|
|
229
|
+
onUpdateShapes
|
|
230
|
+
} = this.props;
|
|
231
|
+
const inProgressPolygon = (shapes || []).find(shape => shape.id === 'newPolygon');
|
|
232
|
+
if (id === 'newPolygon' || inProgressPolygon && this.state.isDrawing) {
|
|
233
|
+
_shapes.PolygonShape.finalizeCreation(this.state, newShapes => {
|
|
234
|
+
this.setState({
|
|
263
235
|
isDrawing: false,
|
|
264
236
|
shapes: newShapes,
|
|
265
237
|
isDrawingShapeId: undefined
|
|
266
238
|
});
|
|
267
|
-
|
|
268
|
-
onUpdateShapes((0, _cloneDeep["default"])(newShapes));
|
|
239
|
+
onUpdateShapes((0, _cloneDeep.default)(newShapes));
|
|
269
240
|
});
|
|
270
241
|
}
|
|
271
242
|
});
|
|
272
|
-
(0, _defineProperty2
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
243
|
+
(0, _defineProperty2.default)(this, "handleOnSetAsCorrect", shape => {
|
|
244
|
+
const {
|
|
245
|
+
id
|
|
246
|
+
} = shape;
|
|
247
|
+
const {
|
|
248
|
+
multipleCorrect,
|
|
249
|
+
shapes,
|
|
250
|
+
onUpdateShapes
|
|
251
|
+
} = this.props;
|
|
252
|
+
let newShapes;
|
|
280
253
|
if (multipleCorrect) {
|
|
281
|
-
newShapes = shapes.map(
|
|
254
|
+
newShapes = shapes.map(shape => {
|
|
282
255
|
if (shape.id === id) {
|
|
283
256
|
shape.correct = !shape.correct;
|
|
284
257
|
}
|
|
285
|
-
|
|
286
258
|
return shape;
|
|
287
259
|
});
|
|
288
260
|
} else {
|
|
289
|
-
newShapes = shapes.map(
|
|
261
|
+
newShapes = shapes.map(shape => {
|
|
290
262
|
shape.correct = shape.id === id;
|
|
291
263
|
return shape;
|
|
292
264
|
});
|
|
293
265
|
}
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
_this.closeInProgressPolygons(id);
|
|
266
|
+
onUpdateShapes((0, _cloneDeep.default)(newShapes));
|
|
267
|
+
this.closeInProgressPolygons(id);
|
|
298
268
|
});
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
269
|
+
/// end of handling HotSpots section
|
|
270
|
+
/// start of handling Image section
|
|
271
|
+
(0, _defineProperty2.default)(this, "handleOnImageLoad", ({
|
|
272
|
+
target
|
|
273
|
+
}) => {
|
|
274
|
+
const {
|
|
275
|
+
onUpdateImageDimension
|
|
276
|
+
} = this.props;
|
|
277
|
+
const resizeHandle = this.resize;
|
|
278
|
+
const elementStyle = getComputedStyle(target);
|
|
279
|
+
const newHeight = parseFloat(elementStyle.height);
|
|
280
|
+
const newWidth = parseFloat(elementStyle.width);
|
|
281
|
+
const aspectWidth = newWidth / IMAGE_MAX_WIDTH;
|
|
282
|
+
const dimensions = newWidth > IMAGE_MAX_WIDTH ? {
|
|
308
283
|
height: newHeight / aspectWidth,
|
|
309
284
|
width: IMAGE_MAX_WIDTH
|
|
310
285
|
} : {
|
|
311
286
|
height: newHeight,
|
|
312
287
|
width: newWidth
|
|
313
288
|
};
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
return onUpdateImageDimension(dimensions);
|
|
319
|
-
});
|
|
320
|
-
|
|
321
|
-
resizeHandle.addEventListener('mousedown', _this.initialiseResize, false);
|
|
289
|
+
this.setState({
|
|
290
|
+
dimensions
|
|
291
|
+
}, () => onUpdateImageDimension(dimensions));
|
|
292
|
+
resizeHandle.addEventListener('mousedown', this.initialiseResize, false);
|
|
322
293
|
});
|
|
323
|
-
(0, _defineProperty2
|
|
324
|
-
window.addEventListener('mousemove',
|
|
325
|
-
window.addEventListener('mouseup',
|
|
294
|
+
(0, _defineProperty2.default)(this, "initialiseResize", () => {
|
|
295
|
+
window.addEventListener('mousemove', this.startResizing, false);
|
|
296
|
+
window.addEventListener('mouseup', this.stopResizing, false);
|
|
326
297
|
});
|
|
327
|
-
(0, _defineProperty2
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
298
|
+
(0, _defineProperty2.default)(this, "startResizing", e => {
|
|
299
|
+
const bounds = e.target.getBoundingClientRect();
|
|
300
|
+
const box = this.image;
|
|
301
|
+
const {
|
|
302
|
+
disableDrag,
|
|
303
|
+
preserveAspectRatioEnabled,
|
|
304
|
+
dimensions,
|
|
305
|
+
shapes
|
|
306
|
+
} = this.props;
|
|
307
|
+
const {
|
|
308
|
+
width,
|
|
309
|
+
height
|
|
310
|
+
} = (0, _utils.updateImageDimensions)(dimensions, {
|
|
337
311
|
width: e.clientX - bounds.left,
|
|
338
312
|
height: e.clientY - bounds.top
|
|
339
|
-
}, preserveAspectRatioEnabled)
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
var resizeValid = _this.checkIfResizeValid(width, height);
|
|
344
|
-
|
|
345
|
-
var hasMinimumWidth = width > 150 && height > 150;
|
|
346
|
-
|
|
313
|
+
}, preserveAspectRatioEnabled);
|
|
314
|
+
const resizeValid = this.checkIfResizeValid(width, height);
|
|
315
|
+
const hasMinimumWidth = width > 150 && height > 150;
|
|
347
316
|
if (resizeValid && hasMinimumWidth && box) {
|
|
348
|
-
box.style.width =
|
|
349
|
-
box.style.height =
|
|
350
|
-
|
|
351
|
-
_this.setState({
|
|
317
|
+
box.style.width = `${width}px`;
|
|
318
|
+
box.style.height = `${height}px`;
|
|
319
|
+
this.setState({
|
|
352
320
|
resizing: true,
|
|
353
321
|
dimensions: {
|
|
354
322
|
height: height,
|
|
355
323
|
width: width
|
|
356
324
|
},
|
|
357
325
|
stateShapes: (0, _utils.getUpdatedShapes)(dimensions, {
|
|
358
|
-
width
|
|
359
|
-
height
|
|
326
|
+
width,
|
|
327
|
+
height
|
|
360
328
|
}, shapes)
|
|
361
329
|
});
|
|
362
330
|
}
|
|
363
|
-
|
|
364
331
|
disableDrag();
|
|
365
332
|
});
|
|
366
|
-
(0, _defineProperty2
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
333
|
+
(0, _defineProperty2.default)(this, "stopResizing", () => {
|
|
334
|
+
const {
|
|
335
|
+
enableDrag,
|
|
336
|
+
onUpdateImageDimension,
|
|
337
|
+
onUpdateShapes
|
|
338
|
+
} = this.props;
|
|
339
|
+
const {
|
|
340
|
+
dimensions,
|
|
341
|
+
stateShapes
|
|
342
|
+
} = this.state;
|
|
374
343
|
enableDrag();
|
|
375
|
-
|
|
376
344
|
if (stateShapes) {
|
|
377
|
-
onUpdateShapes((0, _cloneDeep
|
|
345
|
+
onUpdateShapes((0, _cloneDeep.default)(stateShapes));
|
|
378
346
|
}
|
|
379
|
-
|
|
380
347
|
onUpdateImageDimension(dimensions);
|
|
381
|
-
window.removeEventListener('mousemove',
|
|
382
|
-
window.removeEventListener('mouseup',
|
|
383
|
-
|
|
384
|
-
_this.setState({
|
|
348
|
+
window.removeEventListener('mousemove', this.startResizing, false);
|
|
349
|
+
window.removeEventListener('mouseup', this.stopResizing, false);
|
|
350
|
+
this.setState({
|
|
385
351
|
resizing: false,
|
|
386
352
|
stateShapes: false
|
|
387
353
|
});
|
|
388
354
|
});
|
|
389
|
-
(0, _defineProperty2
|
|
390
|
-
|
|
355
|
+
(0, _defineProperty2.default)(this, "deleteShape", id => {
|
|
356
|
+
this.setState({
|
|
391
357
|
isDrawing: false,
|
|
392
358
|
isDrawingShapeId: undefined
|
|
393
359
|
});
|
|
394
|
-
|
|
395
|
-
_this.props.onDeleteShape(id);
|
|
360
|
+
this.props.onDeleteShape(id);
|
|
396
361
|
});
|
|
397
|
-
|
|
362
|
+
this.state = {
|
|
398
363
|
isDrawing: false,
|
|
399
364
|
stateShapes: false,
|
|
400
365
|
resizing: false,
|
|
@@ -405,227 +370,150 @@ var Drawable = /*#__PURE__*/function (_React$Component) {
|
|
|
405
370
|
width: 0
|
|
406
371
|
}
|
|
407
372
|
};
|
|
408
|
-
return _this;
|
|
409
373
|
}
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
isDrawing: false,
|
|
419
|
-
shapes: newShapes,
|
|
420
|
-
isDrawingShapeId: undefined
|
|
421
|
-
});
|
|
422
|
-
|
|
423
|
-
_this2.props.onUpdateShapes(newShapes);
|
|
424
|
-
}),
|
|
425
|
-
shapes = _PolygonShape$addPoin.shapes;
|
|
426
|
-
|
|
427
|
-
return shapes;
|
|
428
|
-
}
|
|
429
|
-
}, {
|
|
430
|
-
key: "checkIfResizeValid",
|
|
431
|
-
value: function checkIfResizeValid(x, y) {
|
|
432
|
-
var shapes = this.state.shapes;
|
|
433
|
-
var drawable = true; // Do not allow resizing over the hotspots
|
|
434
|
-
|
|
435
|
-
shapes && shapes.forEach(function (shape) {
|
|
436
|
-
var right = shape.x + shape.width + 5;
|
|
437
|
-
var bottom = shape.y + shape.height + 5;
|
|
438
|
-
|
|
439
|
-
if (x <= right || y <= bottom) {
|
|
440
|
-
drawable = false;
|
|
441
|
-
}
|
|
374
|
+
addPolygonPoint(e) {
|
|
375
|
+
const {
|
|
376
|
+
shapes
|
|
377
|
+
} = _shapes.PolygonShape.addPoint(this.state, e, newShapes => {
|
|
378
|
+
this.setState({
|
|
379
|
+
isDrawing: false,
|
|
380
|
+
shapes: newShapes,
|
|
381
|
+
isDrawingShapeId: undefined
|
|
442
382
|
});
|
|
443
|
-
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
shapes = _this$props9.shapes,
|
|
460
|
-
strokeWidth = _this$props9.strokeWidth,
|
|
461
|
-
hoverOutlineColor = _this$props9.hoverOutlineColor,
|
|
462
|
-
selectedHotspotColor = _this$props9.selectedHotspotColor;
|
|
463
|
-
var _this$state2 = this.state,
|
|
464
|
-
stateShapes = _this$state2.stateShapes,
|
|
465
|
-
isDrawing = _this$state2.isDrawing,
|
|
466
|
-
_this$state2$dimensio = _this$state2.dimensions,
|
|
467
|
-
heightFromState = _this$state2$dimensio.height,
|
|
468
|
-
widthFromState = _this$state2$dimensio.width;
|
|
469
|
-
var shapesToUse = stateShapes || shapes;
|
|
470
|
-
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
471
|
-
className: classes.base
|
|
472
|
-
}, imageUrl && /*#__PURE__*/_react["default"].createElement("div", {
|
|
473
|
-
className: classes.imageContainer
|
|
474
|
-
}, /*#__PURE__*/_react["default"].createElement("img", (0, _extends2["default"])({
|
|
475
|
-
className: classes.image,
|
|
476
|
-
onLoad: this.handleOnImageLoad,
|
|
477
|
-
ref: function ref(_ref2) {
|
|
478
|
-
_this3.image = _ref2;
|
|
479
|
-
},
|
|
480
|
-
src: imageUrl
|
|
481
|
-
}, height && width ? {
|
|
482
|
-
style: {
|
|
483
|
-
height: height,
|
|
484
|
-
width: width
|
|
485
|
-
}
|
|
486
|
-
} : {})), /*#__PURE__*/_react["default"].createElement("div", {
|
|
487
|
-
ref: function ref(_ref3) {
|
|
488
|
-
_this3.resize = _ref3;
|
|
489
|
-
},
|
|
490
|
-
className: classes.resize
|
|
491
|
-
})), /*#__PURE__*/_react["default"].createElement(_reactKonva.Stage, {
|
|
492
|
-
className: classes.stage,
|
|
493
|
-
height: heightFromState || height,
|
|
494
|
-
width: widthFromState || width,
|
|
495
|
-
onMouseDown: this.handleOnMouseDown,
|
|
496
|
-
onMouseUp: this.handleOnMouseUp,
|
|
497
|
-
onMouseMove: this.handleMouseMove,
|
|
498
|
-
onContentMouseOut: this.handleOnMouseOutOrLeave,
|
|
499
|
-
onContentMouseLeave: this.handleOnMouseOutOrLeave
|
|
500
|
-
}, /*#__PURE__*/_react["default"].createElement(_reactKonva.Layer, null, shapesToUse.map(function (shape, i) {
|
|
501
|
-
var Tag;
|
|
502
|
-
|
|
503
|
-
switch (shape.group) {
|
|
504
|
-
case _shapes2.SHAPE_GROUPS.RECTANGLES:
|
|
505
|
-
Tag = _hotspotRectangle["default"];
|
|
506
|
-
break;
|
|
507
|
-
|
|
508
|
-
case _shapes2.SHAPE_GROUPS.CIRCLES:
|
|
509
|
-
Tag = _hotspotCircle["default"];
|
|
510
|
-
break;
|
|
511
|
-
|
|
512
|
-
case _shapes2.SHAPE_GROUPS.POLYGONS:
|
|
513
|
-
Tag = _hotspotPolygon["default"];
|
|
514
|
-
break;
|
|
515
|
-
|
|
516
|
-
default:
|
|
517
|
-
return null;
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
return /*#__PURE__*/_react["default"].createElement(Tag, (0, _extends2["default"])({}, shape.group === _shapes2.SHAPE_GROUPS.CIRCLES ? {
|
|
521
|
-
radius: shape.radius
|
|
522
|
-
} : {}, shape.group === _shapes2.SHAPE_GROUPS.RECTANGLES ? {
|
|
523
|
-
height: shape.height,
|
|
524
|
-
width: shape.width
|
|
525
|
-
} : {}, shape.group === _shapes2.SHAPE_GROUPS.POLYGONS ? {
|
|
526
|
-
points: shape.points,
|
|
527
|
-
addPolygonPoint: function addPolygonPoint(e) {
|
|
528
|
-
return _this3.addPolygonPoint(e);
|
|
529
|
-
}
|
|
530
|
-
} : {}, {
|
|
531
|
-
correct: shape.correct,
|
|
532
|
-
isDrawing: isDrawing,
|
|
533
|
-
hotspotColor: hotspotColor,
|
|
534
|
-
hoverOutlineColor: hoverOutlineColor,
|
|
535
|
-
selectedHotspotColor: selectedHotspotColor,
|
|
536
|
-
id: shape.id,
|
|
537
|
-
key: i,
|
|
538
|
-
onClick: function onClick() {
|
|
539
|
-
return _this3.handleOnSetAsCorrect(shape);
|
|
540
|
-
},
|
|
541
|
-
onDragEnd: _this3.handleOnDragEnd,
|
|
542
|
-
onDeleteShape: _this3.deleteShape,
|
|
543
|
-
outlineColor: outlineColor,
|
|
544
|
-
width: shape.width,
|
|
545
|
-
x: shape.x,
|
|
546
|
-
y: shape.y,
|
|
547
|
-
strokeWidth: strokeWidth,
|
|
548
|
-
imageHeight: heightFromState || height,
|
|
549
|
-
imageWidth: widthFromState || width
|
|
550
|
-
}, shape.group === 'polygons' ? {
|
|
551
|
-
addPolygonPoint: function addPolygonPoint(e) {
|
|
552
|
-
return _this3.addPolygonPoint(e);
|
|
553
|
-
}
|
|
554
|
-
} : {}));
|
|
555
|
-
}))));
|
|
556
|
-
}
|
|
557
|
-
}], [{
|
|
558
|
-
key: "getDerivedStateFromProps",
|
|
559
|
-
value: function getDerivedStateFromProps(nextProps, prevState) {
|
|
560
|
-
// Update the state only if the props have changed
|
|
561
|
-
if (nextProps.shapes !== prevState.shapes) {
|
|
562
|
-
return {
|
|
563
|
-
shapes: nextProps.shapes
|
|
564
|
-
};
|
|
383
|
+
this.props.onUpdateShapes(newShapes);
|
|
384
|
+
});
|
|
385
|
+
return shapes;
|
|
386
|
+
}
|
|
387
|
+
checkIfResizeValid(x, y) {
|
|
388
|
+
const {
|
|
389
|
+
shapes
|
|
390
|
+
} = this.state;
|
|
391
|
+
let drawable = true;
|
|
392
|
+
|
|
393
|
+
// Do not allow resizing over the hotspots
|
|
394
|
+
shapes && shapes.forEach(shape => {
|
|
395
|
+
const right = shape.x + shape.width + 5;
|
|
396
|
+
const bottom = shape.y + shape.height + 5;
|
|
397
|
+
if (x <= right || y <= bottom) {
|
|
398
|
+
drawable = false;
|
|
565
399
|
}
|
|
400
|
+
});
|
|
401
|
+
return drawable;
|
|
402
|
+
}
|
|
403
|
+
/// end of handling Image section
|
|
566
404
|
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
405
|
+
render() {
|
|
406
|
+
const {
|
|
407
|
+
imageUrl,
|
|
408
|
+
dimensions: {
|
|
409
|
+
height,
|
|
410
|
+
width
|
|
411
|
+
},
|
|
412
|
+
hotspotColor,
|
|
413
|
+
outlineColor,
|
|
414
|
+
shapes,
|
|
415
|
+
strokeWidth,
|
|
416
|
+
hoverOutlineColor,
|
|
417
|
+
selectedHotspotColor
|
|
418
|
+
} = this.props;
|
|
419
|
+
const {
|
|
420
|
+
stateShapes,
|
|
421
|
+
isDrawing,
|
|
422
|
+
dimensions: {
|
|
423
|
+
height: heightFromState,
|
|
424
|
+
width: widthFromState
|
|
425
|
+
}
|
|
426
|
+
} = this.state;
|
|
427
|
+
const shapesToUse = stateShapes || shapes;
|
|
428
|
+
return /*#__PURE__*/_react.default.createElement(BaseContainer, null, imageUrl && /*#__PURE__*/_react.default.createElement(ImageContainer, null, /*#__PURE__*/_react.default.createElement(Image, (0, _extends2.default)({
|
|
429
|
+
onLoad: this.handleOnImageLoad,
|
|
430
|
+
ref: ref => {
|
|
431
|
+
this.image = ref;
|
|
432
|
+
},
|
|
433
|
+
src: imageUrl
|
|
434
|
+
}, height && width ? {
|
|
435
|
+
style: {
|
|
436
|
+
height,
|
|
437
|
+
width
|
|
438
|
+
}
|
|
439
|
+
} : {})), /*#__PURE__*/_react.default.createElement(ResizeHandle, {
|
|
440
|
+
ref: ref => {
|
|
441
|
+
this.resize = ref;
|
|
442
|
+
}
|
|
443
|
+
})), /*#__PURE__*/_react.default.createElement(StyledStage, {
|
|
444
|
+
height: heightFromState || height,
|
|
445
|
+
width: widthFromState || width,
|
|
446
|
+
onMouseDown: this.handleOnMouseDown,
|
|
447
|
+
onMouseUp: this.handleOnMouseUp,
|
|
448
|
+
onMouseMove: this.handleMouseMove,
|
|
449
|
+
onContentMouseOut: this.handleOnMouseOutOrLeave,
|
|
450
|
+
onContentMouseLeave: this.handleOnMouseOutOrLeave
|
|
451
|
+
}, /*#__PURE__*/_react.default.createElement(_reactKonva.Layer, null, shapesToUse.map((shape, i) => {
|
|
452
|
+
let Tag;
|
|
453
|
+
switch (shape.group) {
|
|
454
|
+
case _shapes.SHAPE_GROUPS.RECTANGLES:
|
|
455
|
+
Tag = _hotspotRectangle.default;
|
|
456
|
+
break;
|
|
457
|
+
case _shapes.SHAPE_GROUPS.CIRCLES:
|
|
458
|
+
Tag = _hotspotCircle.default;
|
|
459
|
+
break;
|
|
460
|
+
case _shapes.SHAPE_GROUPS.POLYGONS:
|
|
461
|
+
Tag = _hotspotPolygon.default;
|
|
462
|
+
break;
|
|
463
|
+
default:
|
|
464
|
+
return null;
|
|
465
|
+
}
|
|
466
|
+
return /*#__PURE__*/_react.default.createElement(Tag, (0, _extends2.default)({}, shape.group === _shapes.SHAPE_GROUPS.CIRCLES ? {
|
|
467
|
+
radius: shape.radius
|
|
468
|
+
} : {}, shape.group === _shapes.SHAPE_GROUPS.RECTANGLES ? {
|
|
469
|
+
height: shape.height,
|
|
470
|
+
width: shape.width
|
|
471
|
+
} : {}, shape.group === _shapes.SHAPE_GROUPS.POLYGONS ? {
|
|
472
|
+
points: shape.points,
|
|
473
|
+
addPolygonPoint: e => this.addPolygonPoint(e)
|
|
474
|
+
} : {}, {
|
|
475
|
+
correct: shape.correct,
|
|
476
|
+
isDrawing: isDrawing,
|
|
477
|
+
hotspotColor: hotspotColor,
|
|
478
|
+
hoverOutlineColor: hoverOutlineColor,
|
|
479
|
+
selectedHotspotColor: selectedHotspotColor,
|
|
480
|
+
id: shape.id,
|
|
481
|
+
key: i,
|
|
482
|
+
onClick: () => this.handleOnSetAsCorrect(shape),
|
|
483
|
+
onDragEnd: this.handleOnDragEnd,
|
|
484
|
+
onDeleteShape: this.deleteShape,
|
|
485
|
+
outlineColor: outlineColor,
|
|
486
|
+
width: shape.width,
|
|
487
|
+
x: shape.x,
|
|
488
|
+
y: shape.y,
|
|
489
|
+
strokeWidth: strokeWidth,
|
|
490
|
+
imageHeight: heightFromState || height,
|
|
491
|
+
imageWidth: widthFromState || width
|
|
492
|
+
}, shape.group === 'polygons' ? {
|
|
493
|
+
addPolygonPoint: e => this.addPolygonPoint(e)
|
|
494
|
+
} : {}));
|
|
495
|
+
}))));
|
|
496
|
+
}
|
|
497
|
+
}
|
|
573
498
|
exports.Drawable = Drawable;
|
|
574
|
-
|
|
575
|
-
var styles = function styles() {
|
|
576
|
-
return {
|
|
577
|
-
base: {
|
|
578
|
-
position: 'relative'
|
|
579
|
-
},
|
|
580
|
-
image: {
|
|
581
|
-
alignItems: 'center',
|
|
582
|
-
display: 'flex',
|
|
583
|
-
justifyContent: 'center'
|
|
584
|
-
},
|
|
585
|
-
imageContainer: {
|
|
586
|
-
position: 'relative',
|
|
587
|
-
width: 'fit-content'
|
|
588
|
-
},
|
|
589
|
-
resize: {
|
|
590
|
-
borderBottom: '1px solid #727272',
|
|
591
|
-
borderRight: '1px solid #727272',
|
|
592
|
-
bottom: '-10px',
|
|
593
|
-
cursor: 'se-resize',
|
|
594
|
-
height: '10px',
|
|
595
|
-
position: 'absolute',
|
|
596
|
-
right: '-10px',
|
|
597
|
-
width: '10px'
|
|
598
|
-
},
|
|
599
|
-
stage: {
|
|
600
|
-
left: 0,
|
|
601
|
-
top: 0,
|
|
602
|
-
position: 'absolute'
|
|
603
|
-
}
|
|
604
|
-
};
|
|
605
|
-
};
|
|
606
|
-
|
|
607
499
|
Drawable.propTypes = {
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
preserveAspectRatioEnabled: _propTypes["default"].bool
|
|
500
|
+
disableDrag: _propTypes.default.func.isRequired,
|
|
501
|
+
dimensions: _propTypes.default.object.isRequired,
|
|
502
|
+
enableDrag: _propTypes.default.func.isRequired,
|
|
503
|
+
shapeType: _propTypes.default.oneOf(Object.values(_shapes.SUPPORTED_SHAPES)),
|
|
504
|
+
imageUrl: _propTypes.default.string.isRequired,
|
|
505
|
+
handleFinishDrawing: _propTypes.default.func.isRequired,
|
|
506
|
+
hotspotColor: _propTypes.default.string.isRequired,
|
|
507
|
+
selectedHotspotColor: _propTypes.default.string,
|
|
508
|
+
hoverOutlineColor: _propTypes.default.string,
|
|
509
|
+
multipleCorrect: _propTypes.default.bool.isRequired,
|
|
510
|
+
onUpdateImageDimension: _propTypes.default.func.isRequired,
|
|
511
|
+
onUpdateShapes: _propTypes.default.func.isRequired,
|
|
512
|
+
onDeleteShape: _propTypes.default.func.isRequired,
|
|
513
|
+
outlineColor: _propTypes.default.string.isRequired,
|
|
514
|
+
shapes: _propTypes.default.array.isRequired,
|
|
515
|
+
strokeWidth: _propTypes.default.number,
|
|
516
|
+
preserveAspectRatioEnabled: _propTypes.default.bool
|
|
626
517
|
};
|
|
627
|
-
|
|
628
|
-
var _default = (0, _index.withStyles)(styles)(Drawable);
|
|
629
|
-
|
|
630
|
-
exports["default"] = _default;
|
|
518
|
+
var _default = exports.default = Drawable;
|
|
631
519
|
//# sourceMappingURL=hotspot-drawable.js.map
|