@pie-element/hotspot 9.3.4-next.0 → 10.0.0-beta.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.
- 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 +301 -393
- 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 +85 -79
- package/configure/src/upload-control.jsx +6 -16
- 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,7 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import { Circle, Group,
|
|
4
|
-
import { withStyles } from '@material-ui/core/styles';
|
|
3
|
+
import { Circle, Group, Transformer } from 'react-konva';
|
|
5
4
|
import DeleteWidget from './DeleteWidget';
|
|
6
5
|
|
|
7
6
|
class CircleComponent extends React.Component {
|
|
@@ -77,7 +76,6 @@ class CircleComponent extends React.Component {
|
|
|
77
76
|
|
|
78
77
|
render() {
|
|
79
78
|
const {
|
|
80
|
-
classes,
|
|
81
79
|
correct,
|
|
82
80
|
radius,
|
|
83
81
|
hotspotColor,
|
|
@@ -95,9 +93,8 @@ class CircleComponent extends React.Component {
|
|
|
95
93
|
const validRadius = isNaN(radius) || radius <= 0 ? 5 : radius;
|
|
96
94
|
|
|
97
95
|
return (
|
|
98
|
-
<Group
|
|
96
|
+
<Group onMouseLeave={this.handleMouseLeave} onMouseEnter={this.handleMouseEnter} padding={12}>
|
|
99
97
|
<Circle
|
|
100
|
-
classes={classes.base}
|
|
101
98
|
ref={this.shapeRef}
|
|
102
99
|
radius={validRadius}
|
|
103
100
|
fill={correct && selectedHotspotColor ? selectedHotspotColor : hotspotColor}
|
|
@@ -112,6 +109,8 @@ class CircleComponent extends React.Component {
|
|
|
112
109
|
onTransformEnd={this.onResizeEnd}
|
|
113
110
|
x={x}
|
|
114
111
|
y={y}
|
|
112
|
+
opacity={0.5}
|
|
113
|
+
cursor="pointer"
|
|
115
114
|
/>
|
|
116
115
|
|
|
117
116
|
{!isDragging && hovered && (
|
|
@@ -158,19 +157,7 @@ class CircleComponent extends React.Component {
|
|
|
158
157
|
}
|
|
159
158
|
}
|
|
160
159
|
|
|
161
|
-
const styles = () => ({
|
|
162
|
-
base: {
|
|
163
|
-
cursor: 'pointer',
|
|
164
|
-
opacity: 0.5,
|
|
165
|
-
},
|
|
166
|
-
|
|
167
|
-
group: {
|
|
168
|
-
padding: '12px',
|
|
169
|
-
},
|
|
170
|
-
});
|
|
171
|
-
|
|
172
160
|
CircleComponent.propTypes = {
|
|
173
|
-
classes: PropTypes.object.isRequired,
|
|
174
161
|
correct: PropTypes.bool,
|
|
175
162
|
isDrawing: PropTypes.bool.isRequired,
|
|
176
163
|
id: PropTypes.string.isRequired,
|
|
@@ -191,4 +178,4 @@ CircleComponent.defaultProps = {
|
|
|
191
178
|
correct: false,
|
|
192
179
|
};
|
|
193
180
|
|
|
194
|
-
export default
|
|
181
|
+
export default CircleComponent;
|
|
@@ -1,17 +1,65 @@
|
|
|
1
|
-
import { withStyles } from '@material-ui/core/styles/index';
|
|
2
|
-
import classNames from 'classnames';
|
|
3
|
-
import { SUPPORTED_SHAPES } from './shapes';
|
|
4
|
-
import PropTypes from 'prop-types';
|
|
5
1
|
import React, { Component } from 'react';
|
|
2
|
+
import { styled } from '@mui/material/styles';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
6
4
|
import Button from './button';
|
|
7
5
|
import { CircleButton } from './buttons/circle';
|
|
8
6
|
import { PolygonButton } from './buttons/polygon';
|
|
9
7
|
import { RectangleButton } from './buttons/rectangle';
|
|
10
|
-
|
|
8
|
+
import { SUPPORTED_SHAPES } from './shapes';
|
|
11
9
|
import Drawable from './hotspot-drawable';
|
|
12
10
|
import UploadControl from './upload-control';
|
|
13
11
|
import { getAllShapes, groupShapes } from './utils';
|
|
14
12
|
|
|
13
|
+
const BaseContainer = styled('div')(({ theme }) => ({
|
|
14
|
+
marginTop: theme.spacing(1.5),
|
|
15
|
+
marginBottom: theme.spacing(2.5),
|
|
16
|
+
}));
|
|
17
|
+
|
|
18
|
+
const BoxContainer = styled('div')(({ theme, hasErrors, dropzoneActive }) => ({
|
|
19
|
+
border: '1px solid #E0E1E6',
|
|
20
|
+
borderRadius: '5px',
|
|
21
|
+
...(dropzoneActive && {
|
|
22
|
+
border: '1px solid #0032C2',
|
|
23
|
+
}),
|
|
24
|
+
...(hasErrors && !dropzoneActive && {
|
|
25
|
+
border: `1px solid ${theme.palette.error.main}`,
|
|
26
|
+
}),
|
|
27
|
+
}));
|
|
28
|
+
|
|
29
|
+
const ButtonShape = styled('div')({
|
|
30
|
+
marginRight: '5px',
|
|
31
|
+
'&:hover': {
|
|
32
|
+
cursor: 'pointer',
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const CenteredContainer = styled('div')({
|
|
37
|
+
alignItems: 'center',
|
|
38
|
+
display: 'flex',
|
|
39
|
+
flexDirection: 'column',
|
|
40
|
+
justifyContent: 'center',
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const DrawableHeight = styled('div')(({ theme }) => ({
|
|
44
|
+
minHeight: 350,
|
|
45
|
+
paddingBottom: theme.spacing(5),
|
|
46
|
+
paddingRight: theme.spacing(5),
|
|
47
|
+
}));
|
|
48
|
+
|
|
49
|
+
const Toolbar = styled('div')(({ theme }) => ({
|
|
50
|
+
backgroundColor: '#FFF',
|
|
51
|
+
borderBottom: '1px solid #E0E1E6',
|
|
52
|
+
borderTopLeftRadius: '5px',
|
|
53
|
+
borderTopRightRadius: '5px',
|
|
54
|
+
display: 'flex',
|
|
55
|
+
justifyContent: 'flex-end',
|
|
56
|
+
padding: theme.spacing(1),
|
|
57
|
+
}));
|
|
58
|
+
|
|
59
|
+
const ReplaceSection = styled('div')({
|
|
60
|
+
marginRight: 'auto',
|
|
61
|
+
});
|
|
62
|
+
|
|
15
63
|
const isImage = (file) => {
|
|
16
64
|
const imageType = /image.*/;
|
|
17
65
|
|
|
@@ -147,7 +195,6 @@ export class Container extends Component {
|
|
|
147
195
|
|
|
148
196
|
render() {
|
|
149
197
|
const {
|
|
150
|
-
classes,
|
|
151
198
|
dimensions,
|
|
152
199
|
hasErrors,
|
|
153
200
|
hotspotColor,
|
|
@@ -160,17 +207,15 @@ export class Container extends Component {
|
|
|
160
207
|
hoverOutlineColor,
|
|
161
208
|
selectedHotspotColor,
|
|
162
209
|
} = this.props;
|
|
163
|
-
|
|
210
|
+
|
|
164
211
|
const { dropzoneActive, dragEnabled } = this.state;
|
|
165
212
|
const { shapes, selectedShape } = this.state;
|
|
166
213
|
|
|
167
214
|
return (
|
|
168
|
-
<
|
|
169
|
-
<
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
[classes.boxActive]: dropzoneActive,
|
|
173
|
-
})}
|
|
215
|
+
<BaseContainer>
|
|
216
|
+
<BoxContainer
|
|
217
|
+
hasErrors={hasErrors}
|
|
218
|
+
dropzoneActive={dropzoneActive}
|
|
174
219
|
{...(dragEnabled
|
|
175
220
|
? {
|
|
176
221
|
onDragExit: this.handleOnDragExit,
|
|
@@ -181,45 +226,41 @@ export class Container extends Component {
|
|
|
181
226
|
}
|
|
182
227
|
: {})}
|
|
183
228
|
>
|
|
184
|
-
<
|
|
185
|
-
<
|
|
229
|
+
<Toolbar>
|
|
230
|
+
<ButtonShape
|
|
186
231
|
onClick={() => this.setState({ selectedShape: selectedShape === SUPPORTED_SHAPES.RECTANGLE ? SUPPORTED_SHAPES.NONE : SUPPORTED_SHAPES.RECTANGLE })}
|
|
187
|
-
className={classes.buttonShape}
|
|
188
232
|
>
|
|
189
233
|
<RectangleButton isActive={selectedShape === SUPPORTED_SHAPES.RECTANGLE} />
|
|
190
|
-
</
|
|
191
|
-
<
|
|
234
|
+
</ButtonShape>
|
|
235
|
+
<ButtonShape
|
|
192
236
|
onClick={() => this.setState({ selectedShape: selectedShape === SUPPORTED_SHAPES.POLYGON ? SUPPORTED_SHAPES.NONE : SUPPORTED_SHAPES.POLYGON })}
|
|
193
|
-
className={classes.buttonShape}
|
|
194
237
|
>
|
|
195
238
|
<PolygonButton isActive={selectedShape === SUPPORTED_SHAPES.POLYGON} />
|
|
196
|
-
</
|
|
197
|
-
<
|
|
239
|
+
</ButtonShape>
|
|
240
|
+
<ButtonShape
|
|
198
241
|
onClick={() => this.setState({ selectedShape: selectedShape === SUPPORTED_SHAPES.CIRCLE ? SUPPORTED_SHAPES.NONE : SUPPORTED_SHAPES.CIRCLE })}
|
|
199
|
-
className={classes.buttonShape}
|
|
200
242
|
>
|
|
201
243
|
<CircleButton isActive={selectedShape === SUPPORTED_SHAPES.CIRCLE} />
|
|
202
|
-
</
|
|
244
|
+
</ButtonShape>
|
|
203
245
|
|
|
204
246
|
{imageUrl && (
|
|
205
|
-
<
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
247
|
+
<ReplaceSection>
|
|
248
|
+
<UploadControl
|
|
249
|
+
label="Replace Image"
|
|
250
|
+
onInputClick={this.handleInputClick}
|
|
251
|
+
setRef={(ref) => {
|
|
252
|
+
this.input = ref;
|
|
253
|
+
}}
|
|
254
|
+
/>
|
|
255
|
+
</ReplaceSection>
|
|
214
256
|
)}
|
|
215
257
|
<Button disabled={!(shapes && shapes.length)} onClick={this.handleClearAll} label="Clear all" />
|
|
216
|
-
</
|
|
258
|
+
</Toolbar>
|
|
217
259
|
|
|
218
|
-
<
|
|
260
|
+
<DrawableHeight
|
|
219
261
|
ref={(ref) => {
|
|
220
262
|
this.imageSection = ref;
|
|
221
263
|
}}
|
|
222
|
-
className={classes.drawableHeight}
|
|
223
264
|
>
|
|
224
265
|
{imageUrl ? (
|
|
225
266
|
<Drawable
|
|
@@ -242,7 +283,7 @@ export class Container extends Component {
|
|
|
242
283
|
preserveAspectRatioEnabled={preserveAspectRatioEnabled}
|
|
243
284
|
/>
|
|
244
285
|
) : (
|
|
245
|
-
<
|
|
286
|
+
<CenteredContainer>
|
|
246
287
|
<label>Drag and drop or upload image from computer</label>
|
|
247
288
|
<br />
|
|
248
289
|
<UploadControl
|
|
@@ -252,73 +293,16 @@ export class Container extends Component {
|
|
|
252
293
|
this.input = ref;
|
|
253
294
|
}}
|
|
254
295
|
/>
|
|
255
|
-
</
|
|
296
|
+
</CenteredContainer>
|
|
256
297
|
)}
|
|
257
|
-
</
|
|
258
|
-
</
|
|
259
|
-
</
|
|
298
|
+
</DrawableHeight>
|
|
299
|
+
</BoxContainer>
|
|
300
|
+
</BaseContainer>
|
|
260
301
|
);
|
|
261
302
|
}
|
|
262
303
|
}
|
|
263
304
|
|
|
264
|
-
const styles = (theme) => ({
|
|
265
|
-
buttonShape: {
|
|
266
|
-
marginRight: '5px',
|
|
267
|
-
'&:hover': {
|
|
268
|
-
cursor: 'pointer',
|
|
269
|
-
},
|
|
270
|
-
},
|
|
271
|
-
base: {
|
|
272
|
-
marginTop: theme.spacing.unit * 1.5,
|
|
273
|
-
marginBottom: theme.spacing.unit * 2.5,
|
|
274
|
-
},
|
|
275
|
-
box: {
|
|
276
|
-
border: '1px solid #E0E1E6',
|
|
277
|
-
borderRadius: '5px',
|
|
278
|
-
},
|
|
279
|
-
boxActive: {
|
|
280
|
-
border: '1px solid #0032C2',
|
|
281
|
-
},
|
|
282
|
-
boxError: {
|
|
283
|
-
border: `1px solid ${theme.palette.error.main}`,
|
|
284
|
-
},
|
|
285
|
-
centered: {
|
|
286
|
-
alignItems: 'center',
|
|
287
|
-
display: 'flex',
|
|
288
|
-
flexDirection: 'column',
|
|
289
|
-
justifyContent: 'center',
|
|
290
|
-
},
|
|
291
|
-
drawableHeight: {
|
|
292
|
-
minHeight: 350,
|
|
293
|
-
paddingBottom: theme.spacing.unit * 5,
|
|
294
|
-
paddingRight: theme.spacing.unit * 5,
|
|
295
|
-
},
|
|
296
|
-
icon: {
|
|
297
|
-
'&:hover': {
|
|
298
|
-
color: '#333131',
|
|
299
|
-
cursor: 'help',
|
|
300
|
-
},
|
|
301
|
-
color: '#C1C1C1',
|
|
302
|
-
},
|
|
303
|
-
replaceButton: {
|
|
304
|
-
marginLeft: 0,
|
|
305
|
-
},
|
|
306
|
-
replaceSection: {
|
|
307
|
-
marginRight: 'auto',
|
|
308
|
-
},
|
|
309
|
-
toolbar: {
|
|
310
|
-
backgroundColor: '#FFF',
|
|
311
|
-
borderBottom: '1px solid #E0E1E6',
|
|
312
|
-
borderTopLeftRadius: '5px',
|
|
313
|
-
borderTopRightRadius: '5px',
|
|
314
|
-
display: 'flex',
|
|
315
|
-
justifyContent: 'flex-end',
|
|
316
|
-
padding: theme.spacing.unit,
|
|
317
|
-
},
|
|
318
|
-
});
|
|
319
|
-
|
|
320
305
|
Container.propTypes = {
|
|
321
|
-
classes: PropTypes.object.isRequired,
|
|
322
306
|
dimensions: PropTypes.object.isRequired,
|
|
323
307
|
imageUrl: PropTypes.string.isRequired,
|
|
324
308
|
hotspotColor: PropTypes.string.isRequired,
|
|
@@ -343,4 +327,4 @@ Container.defaultProps = {
|
|
|
343
327
|
strokeWidth: 5,
|
|
344
328
|
};
|
|
345
329
|
|
|
346
|
-
export default
|
|
330
|
+
export default Container;
|
|
@@ -2,13 +2,46 @@ import React from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { Layer, Stage } from 'react-konva';
|
|
4
4
|
import cloneDeep from 'lodash/cloneDeep';
|
|
5
|
-
import {
|
|
5
|
+
import { styled } from '@mui/material/styles';
|
|
6
6
|
|
|
7
7
|
import Rectangle from './hotspot-rectangle';
|
|
8
8
|
import Polygon from './hotspot-polygon';
|
|
9
9
|
import Circle from './hotspot-circle';
|
|
10
10
|
import { getUpdatedShapes, updateImageDimensions } from './utils';
|
|
11
11
|
import { RectangleShape, CircleShape, PolygonShape, SUPPORTED_SHAPES, SHAPE_GROUPS } from './shapes';
|
|
12
|
+
|
|
13
|
+
const BaseContainer = styled('div')({
|
|
14
|
+
position: 'relative',
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const ImageContainer = styled('div')({
|
|
18
|
+
position: 'relative',
|
|
19
|
+
width: 'fit-content',
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const Image = styled('img')({
|
|
23
|
+
alignItems: 'center',
|
|
24
|
+
display: 'flex',
|
|
25
|
+
justifyContent: 'center',
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const ResizeHandle = styled('div')({
|
|
29
|
+
borderBottom: '1px solid #727272',
|
|
30
|
+
borderRight: '1px solid #727272',
|
|
31
|
+
bottom: '-10px',
|
|
32
|
+
cursor: 'se-resize',
|
|
33
|
+
height: '10px',
|
|
34
|
+
position: 'absolute',
|
|
35
|
+
right: '-10px',
|
|
36
|
+
width: '10px',
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const StyledStage = styled(Stage)({
|
|
40
|
+
left: 0,
|
|
41
|
+
top: 0,
|
|
42
|
+
position: 'absolute',
|
|
43
|
+
});
|
|
44
|
+
|
|
12
45
|
const IMAGE_MAX_WIDTH = 800;
|
|
13
46
|
|
|
14
47
|
export class Drawable extends React.Component {
|
|
@@ -373,7 +406,6 @@ export class Drawable extends React.Component {
|
|
|
373
406
|
|
|
374
407
|
render() {
|
|
375
408
|
const {
|
|
376
|
-
classes,
|
|
377
409
|
imageUrl,
|
|
378
410
|
dimensions: { height, width },
|
|
379
411
|
hotspotColor,
|
|
@@ -392,11 +424,10 @@ export class Drawable extends React.Component {
|
|
|
392
424
|
const shapesToUse = stateShapes || shapes;
|
|
393
425
|
|
|
394
426
|
return (
|
|
395
|
-
<
|
|
427
|
+
<BaseContainer>
|
|
396
428
|
{imageUrl && (
|
|
397
|
-
<
|
|
398
|
-
<
|
|
399
|
-
className={classes.image}
|
|
429
|
+
<ImageContainer>
|
|
430
|
+
<Image
|
|
400
431
|
onLoad={this.handleOnImageLoad}
|
|
401
432
|
ref={(ref) => {
|
|
402
433
|
this.image = ref;
|
|
@@ -404,17 +435,15 @@ export class Drawable extends React.Component {
|
|
|
404
435
|
src={imageUrl}
|
|
405
436
|
{...(height && width ? { style: { height, width } } : {})}
|
|
406
437
|
/>
|
|
407
|
-
<
|
|
438
|
+
<ResizeHandle
|
|
408
439
|
ref={(ref) => {
|
|
409
440
|
this.resize = ref;
|
|
410
441
|
}}
|
|
411
|
-
className={classes.resize}
|
|
412
442
|
/>
|
|
413
|
-
</
|
|
443
|
+
</ImageContainer>
|
|
414
444
|
)}
|
|
415
445
|
|
|
416
|
-
<
|
|
417
|
-
className={classes.stage}
|
|
446
|
+
<StyledStage
|
|
418
447
|
height={heightFromState || height}
|
|
419
448
|
width={widthFromState || width}
|
|
420
449
|
onMouseDown={this.handleOnMouseDown}
|
|
@@ -469,44 +498,13 @@ export class Drawable extends React.Component {
|
|
|
469
498
|
);
|
|
470
499
|
})}
|
|
471
500
|
</Layer>
|
|
472
|
-
</
|
|
473
|
-
</
|
|
501
|
+
</StyledStage>
|
|
502
|
+
</BaseContainer>
|
|
474
503
|
);
|
|
475
504
|
}
|
|
476
505
|
}
|
|
477
506
|
|
|
478
|
-
const styles = () => ({
|
|
479
|
-
base: {
|
|
480
|
-
position: 'relative',
|
|
481
|
-
},
|
|
482
|
-
image: {
|
|
483
|
-
alignItems: 'center',
|
|
484
|
-
display: 'flex',
|
|
485
|
-
justifyContent: 'center',
|
|
486
|
-
},
|
|
487
|
-
imageContainer: {
|
|
488
|
-
position: 'relative',
|
|
489
|
-
width: 'fit-content',
|
|
490
|
-
},
|
|
491
|
-
resize: {
|
|
492
|
-
borderBottom: '1px solid #727272',
|
|
493
|
-
borderRight: '1px solid #727272',
|
|
494
|
-
bottom: '-10px',
|
|
495
|
-
cursor: 'se-resize',
|
|
496
|
-
height: '10px',
|
|
497
|
-
position: 'absolute',
|
|
498
|
-
right: '-10px',
|
|
499
|
-
width: '10px',
|
|
500
|
-
},
|
|
501
|
-
stage: {
|
|
502
|
-
left: 0,
|
|
503
|
-
top: 0,
|
|
504
|
-
position: 'absolute',
|
|
505
|
-
},
|
|
506
|
-
});
|
|
507
|
-
|
|
508
507
|
Drawable.propTypes = {
|
|
509
|
-
classes: PropTypes.object.isRequired,
|
|
510
508
|
disableDrag: PropTypes.func.isRequired,
|
|
511
509
|
dimensions: PropTypes.object.isRequired,
|
|
512
510
|
enableDrag: PropTypes.func.isRequired,
|
|
@@ -526,4 +524,4 @@ Drawable.propTypes = {
|
|
|
526
524
|
preserveAspectRatioEnabled: PropTypes.bool,
|
|
527
525
|
};
|
|
528
526
|
|
|
529
|
-
export default
|
|
527
|
+
export default Drawable;
|
|
@@ -1,9 +1,27 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { InputContainer } from '@pie-lib/config-ui';
|
|
4
|
-
import Select from '@material
|
|
5
|
-
import MenuItem from '@material
|
|
6
|
-
import {
|
|
4
|
+
import Select from '@mui/material/Select';
|
|
5
|
+
import MenuItem from '@mui/material/MenuItem';
|
|
6
|
+
import { styled } from '@mui/material/styles';
|
|
7
|
+
|
|
8
|
+
const BaseContainer = styled('div')(({ theme }) => ({
|
|
9
|
+
marginTop: theme.spacing(2),
|
|
10
|
+
display: 'flex',
|
|
11
|
+
}));
|
|
12
|
+
|
|
13
|
+
const StyledInputContainer = styled(InputContainer)({
|
|
14
|
+
flex: 1,
|
|
15
|
+
width: '90%',
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const StyledMenuItem = styled(MenuItem)(({ theme }) => ({
|
|
19
|
+
borderRadius: '2px',
|
|
20
|
+
height: '22px',
|
|
21
|
+
marginLeft: theme.spacing(2),
|
|
22
|
+
marginRight: theme.spacing(2),
|
|
23
|
+
marginTop: theme.spacing(2),
|
|
24
|
+
}));
|
|
7
25
|
|
|
8
26
|
class Palette extends React.Component {
|
|
9
27
|
onChange = (name) => (event) => {
|
|
@@ -18,59 +36,49 @@ class Palette extends React.Component {
|
|
|
18
36
|
};
|
|
19
37
|
|
|
20
38
|
render() {
|
|
21
|
-
const {
|
|
39
|
+
const { hotspotColor, outlineColor, hotspotList, outlineList } = this.props;
|
|
22
40
|
|
|
23
41
|
return (
|
|
24
|
-
<
|
|
25
|
-
<
|
|
26
|
-
<Select
|
|
42
|
+
<BaseContainer>
|
|
43
|
+
<StyledInputContainer label="Hot Spot">
|
|
44
|
+
<Select
|
|
45
|
+
onChange={this.onChange('hotspot')}
|
|
46
|
+
value={hotspotColor}
|
|
47
|
+
variant='standard'
|
|
48
|
+
MenuProps={{ transitionDuration: { enter: 225, exit: 195 } }}
|
|
49
|
+
>
|
|
27
50
|
{hotspotList.map((hotspot) => (
|
|
28
|
-
<
|
|
51
|
+
<StyledMenuItem key={hotspot} value={hotspot} style={{ backgroundColor: hotspot }}>
|
|
29
52
|
{hotspot}
|
|
30
|
-
</
|
|
53
|
+
</StyledMenuItem>
|
|
31
54
|
))}
|
|
32
55
|
</Select>
|
|
33
|
-
</
|
|
56
|
+
</StyledInputContainer>
|
|
34
57
|
|
|
35
|
-
<
|
|
36
|
-
<Select
|
|
58
|
+
<StyledInputContainer label="Response Outline">
|
|
59
|
+
<Select
|
|
60
|
+
onChange={this.onChange('outline')}
|
|
61
|
+
value={outlineColor}
|
|
62
|
+
variant='standard'
|
|
63
|
+
MenuProps={{ transitionDuration: { enter: 225, exit: 195 } }}
|
|
64
|
+
>
|
|
37
65
|
{outlineList.map((outline) => (
|
|
38
|
-
<
|
|
66
|
+
<StyledMenuItem
|
|
39
67
|
key={outline}
|
|
40
68
|
value={outline}
|
|
41
|
-
className={classes.item}
|
|
42
69
|
style={{ border: `2px solid ${outline}` }}
|
|
43
70
|
>
|
|
44
71
|
{outline}
|
|
45
|
-
</
|
|
72
|
+
</StyledMenuItem>
|
|
46
73
|
))}
|
|
47
74
|
</Select>
|
|
48
|
-
</
|
|
49
|
-
</
|
|
75
|
+
</StyledInputContainer>
|
|
76
|
+
</BaseContainer>
|
|
50
77
|
);
|
|
51
78
|
}
|
|
52
79
|
}
|
|
53
80
|
|
|
54
|
-
const styles = (theme) => ({
|
|
55
|
-
base: {
|
|
56
|
-
marginTop: theme.spacing.unit * 2,
|
|
57
|
-
display: 'flex',
|
|
58
|
-
},
|
|
59
|
-
input: {
|
|
60
|
-
flex: 1,
|
|
61
|
-
width: '90%',
|
|
62
|
-
},
|
|
63
|
-
item: {
|
|
64
|
-
borderRadius: '2px',
|
|
65
|
-
height: '22px',
|
|
66
|
-
marginLeft: theme.spacing.unit * 2,
|
|
67
|
-
marginRight: theme.spacing.unit * 2,
|
|
68
|
-
marginTop: theme.spacing.unit * 2,
|
|
69
|
-
},
|
|
70
|
-
});
|
|
71
|
-
|
|
72
81
|
Palette.propTypes = {
|
|
73
|
-
classes: PropTypes.object.isRequired,
|
|
74
82
|
hotspotColor: PropTypes.string.isRequired,
|
|
75
83
|
hotspotList: PropTypes.array.isRequired,
|
|
76
84
|
onHotspotColorChange: PropTypes.func.isRequired,
|
|
@@ -79,4 +87,4 @@ Palette.propTypes = {
|
|
|
79
87
|
outlineList: PropTypes.array.isRequired,
|
|
80
88
|
};
|
|
81
89
|
|
|
82
|
-
export default
|
|
90
|
+
export default Palette;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { Group, Line, Circle } from 'react-konva';
|
|
4
|
-
import { withStyles } from '@material-ui/core/styles/index';
|
|
5
4
|
import { Rect } from 'react-konva/lib/ReactKonvaCore';
|
|
6
5
|
import DeleteWidget from './DeleteWidget';
|
|
7
6
|
|
|
@@ -188,7 +187,6 @@ class PolComponent extends React.Component {
|
|
|
188
187
|
|
|
189
188
|
render() {
|
|
190
189
|
const {
|
|
191
|
-
classes,
|
|
192
190
|
correct,
|
|
193
191
|
id,
|
|
194
192
|
hotspotColor,
|
|
@@ -208,7 +206,7 @@ class PolComponent extends React.Component {
|
|
|
208
206
|
const calculatedFill = correct && selectedHotspotColor ? selectedHotspotColor : hotspotColor;
|
|
209
207
|
|
|
210
208
|
return (
|
|
211
|
-
<Group
|
|
209
|
+
<Group onMouseLeave={this.handleMouseLeave} onMouseEnter={this.handleMouseEnter}>
|
|
212
210
|
{hoverOutlineColor && hovered && (
|
|
213
211
|
<Rect
|
|
214
212
|
x={boundingBox.x}
|
|
@@ -221,7 +219,6 @@ class PolComponent extends React.Component {
|
|
|
221
219
|
/>
|
|
222
220
|
)}
|
|
223
221
|
<Line
|
|
224
|
-
classes={classes.base}
|
|
225
222
|
points={this.serialize(points)}
|
|
226
223
|
closed={!isInProgress}
|
|
227
224
|
fill={isInProgress ? 'transparent' : calculatedFill}
|
|
@@ -235,13 +232,13 @@ class PolComponent extends React.Component {
|
|
|
235
232
|
onDragEnd={(e) => this.handleOnDragEnd(e, true)}
|
|
236
233
|
x={x}
|
|
237
234
|
y={y}
|
|
235
|
+
opacity={0.5}
|
|
238
236
|
/>
|
|
239
237
|
|
|
240
238
|
{showPoints &&
|
|
241
239
|
points.map((point, index) => (
|
|
242
240
|
<Circle
|
|
243
241
|
key={index}
|
|
244
|
-
className={classes.circle}
|
|
245
242
|
x={point.x}
|
|
246
243
|
y={point.y}
|
|
247
244
|
radius={5}
|
|
@@ -257,6 +254,7 @@ class PolComponent extends React.Component {
|
|
|
257
254
|
this.handleOnDragVertex(e, index, true);
|
|
258
255
|
}}
|
|
259
256
|
draggable
|
|
257
|
+
opacity={4}
|
|
260
258
|
/>
|
|
261
259
|
))}
|
|
262
260
|
{!this.state.isDragging && this.state.hovered && (
|
|
@@ -267,21 +265,7 @@ class PolComponent extends React.Component {
|
|
|
267
265
|
}
|
|
268
266
|
}
|
|
269
267
|
|
|
270
|
-
const styles = () => ({
|
|
271
|
-
base: {
|
|
272
|
-
cursor: 'pointer',
|
|
273
|
-
opacity: 0.5,
|
|
274
|
-
},
|
|
275
|
-
circle: {
|
|
276
|
-
opacity: 4,
|
|
277
|
-
},
|
|
278
|
-
group: {
|
|
279
|
-
padding: '12px',
|
|
280
|
-
},
|
|
281
|
-
});
|
|
282
|
-
|
|
283
268
|
PolComponent.propTypes = {
|
|
284
|
-
classes: PropTypes.object.isRequired,
|
|
285
269
|
correct: PropTypes.bool,
|
|
286
270
|
isDrawing: PropTypes.bool.isRequired,
|
|
287
271
|
id: PropTypes.string.isRequired,
|
|
@@ -308,4 +292,4 @@ PolComponent.defaultProps = {
|
|
|
308
292
|
correct: false,
|
|
309
293
|
};
|
|
310
294
|
|
|
311
|
-
export default
|
|
295
|
+
export default PolComponent;
|