@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,425 +1,320 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
-
|
|
7
4
|
Object.defineProperty(exports, "__esModule", {
|
|
8
5
|
value: true
|
|
9
6
|
});
|
|
10
|
-
exports
|
|
11
|
-
|
|
7
|
+
exports.default = exports.Container = void 0;
|
|
12
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
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
|
-
var _index = require("@material-ui/core/styles/index");
|
|
29
|
-
|
|
30
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
31
|
-
|
|
32
|
-
var _shapes = require("./shapes");
|
|
33
|
-
|
|
34
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
35
|
-
|
|
36
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
37
|
-
|
|
11
|
+
var _styles = require("@mui/material/styles");
|
|
12
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
38
13
|
var _button = _interopRequireDefault(require("./button"));
|
|
39
|
-
|
|
40
14
|
var _circle = require("./buttons/circle");
|
|
41
|
-
|
|
42
15
|
var _polygon = require("./buttons/polygon");
|
|
43
|
-
|
|
44
16
|
var _rectangle = require("./buttons/rectangle");
|
|
45
|
-
|
|
17
|
+
var _shapes = require("./shapes");
|
|
46
18
|
var _hotspotDrawable = _interopRequireDefault(require("./hotspot-drawable"));
|
|
47
|
-
|
|
48
19
|
var _uploadControl = _interopRequireDefault(require("./upload-control"));
|
|
49
|
-
|
|
50
20
|
var _utils = require("./utils");
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
21
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
22
|
+
const BaseContainer = (0, _styles.styled)('div')(({
|
|
23
|
+
theme
|
|
24
|
+
}) => ({
|
|
25
|
+
marginTop: theme.spacing(1.5),
|
|
26
|
+
marginBottom: theme.spacing(2.5)
|
|
27
|
+
}));
|
|
28
|
+
const BoxContainer = (0, _styles.styled)('div')(({
|
|
29
|
+
theme,
|
|
30
|
+
hasErrors,
|
|
31
|
+
dropzoneActive
|
|
32
|
+
}) => ({
|
|
33
|
+
border: '1px solid #E0E1E6',
|
|
34
|
+
borderRadius: '5px',
|
|
35
|
+
...(dropzoneActive && {
|
|
36
|
+
border: '1px solid #0032C2'
|
|
37
|
+
}),
|
|
38
|
+
...(hasErrors && !dropzoneActive && {
|
|
39
|
+
border: `1px solid ${theme.palette.error.main}`
|
|
40
|
+
})
|
|
41
|
+
}));
|
|
42
|
+
const ButtonShape = (0, _styles.styled)('div')({
|
|
43
|
+
marginRight: '5px',
|
|
44
|
+
'&:hover': {
|
|
45
|
+
cursor: 'pointer'
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
const CenteredContainer = (0, _styles.styled)('div')({
|
|
49
|
+
alignItems: 'center',
|
|
50
|
+
display: 'flex',
|
|
51
|
+
flexDirection: 'column',
|
|
52
|
+
justifyContent: 'center'
|
|
53
|
+
});
|
|
54
|
+
const DrawableHeight = (0, _styles.styled)('div')(({
|
|
55
|
+
theme
|
|
56
|
+
}) => ({
|
|
57
|
+
minHeight: 350,
|
|
58
|
+
paddingBottom: theme.spacing(5),
|
|
59
|
+
paddingRight: theme.spacing(5)
|
|
60
|
+
}));
|
|
61
|
+
const Toolbar = (0, _styles.styled)('div')(({
|
|
62
|
+
theme
|
|
63
|
+
}) => ({
|
|
64
|
+
backgroundColor: '#FFF',
|
|
65
|
+
borderBottom: '1px solid #E0E1E6',
|
|
66
|
+
borderTopLeftRadius: '5px',
|
|
67
|
+
borderTopRightRadius: '5px',
|
|
68
|
+
display: 'flex',
|
|
69
|
+
justifyContent: 'flex-end',
|
|
70
|
+
padding: theme.spacing(1)
|
|
71
|
+
}));
|
|
72
|
+
const ReplaceSection = (0, _styles.styled)('div')({
|
|
73
|
+
marginRight: 'auto'
|
|
74
|
+
});
|
|
75
|
+
const isImage = file => {
|
|
76
|
+
const imageType = /image.*/;
|
|
66
77
|
return file.type.match(imageType);
|
|
67
78
|
};
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
(
|
|
78
|
-
|
|
79
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleFileRead", function (file) {
|
|
79
|
+
class Container extends _react.Component {
|
|
80
|
+
static getDerivedStateFromProps(nextProps, prevState) {
|
|
81
|
+
// always transform shapes map into shapes array at this level
|
|
82
|
+
return {
|
|
83
|
+
...prevState,
|
|
84
|
+
shapes: (0, _utils.getAllShapes)(nextProps.shapes)
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
constructor(props) {
|
|
88
|
+
super(props);
|
|
89
|
+
(0, _defineProperty2.default)(this, "handleFileRead", file => {
|
|
80
90
|
if (file instanceof Blob) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
reader.onloadend =
|
|
87
|
-
return onImageUpload(reader.result);
|
|
88
|
-
};
|
|
89
|
-
|
|
91
|
+
const {
|
|
92
|
+
onImageUpload,
|
|
93
|
+
insertImage
|
|
94
|
+
} = this.props;
|
|
95
|
+
const reader = new FileReader();
|
|
96
|
+
reader.onloadend = () => onImageUpload(reader.result);
|
|
90
97
|
reader.readAsDataURL(file);
|
|
91
|
-
|
|
92
98
|
if (insertImage) {
|
|
93
|
-
insertImage(
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
},
|
|
99
|
+
insertImage({
|
|
100
|
+
...this.fakeImageHandler,
|
|
101
|
+
getChosenFile: () => file,
|
|
97
102
|
isPasted: true
|
|
98
|
-
})
|
|
103
|
+
});
|
|
99
104
|
}
|
|
100
105
|
}
|
|
101
106
|
});
|
|
102
|
-
(0, _defineProperty2
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleOnPaste", function (e) {
|
|
113
|
-
var files = e.clipboardData.files;
|
|
114
|
-
|
|
107
|
+
(0, _defineProperty2.default)(this, "enableDropzone", () => this.setState({
|
|
108
|
+
dropzoneActive: true
|
|
109
|
+
}));
|
|
110
|
+
(0, _defineProperty2.default)(this, "disableDropzone", () => this.setState({
|
|
111
|
+
dropzoneActive: false
|
|
112
|
+
}));
|
|
113
|
+
(0, _defineProperty2.default)(this, "handleOnPaste", e => {
|
|
114
|
+
const {
|
|
115
|
+
files
|
|
116
|
+
} = e.clipboardData;
|
|
115
117
|
if (files && isImage(files[0])) {
|
|
116
|
-
|
|
118
|
+
this.handleFileRead(files[0]);
|
|
117
119
|
}
|
|
118
120
|
});
|
|
119
|
-
(0, _defineProperty2
|
|
121
|
+
(0, _defineProperty2.default)(this, "handleOnDrop", e => {
|
|
120
122
|
e.preventDefault();
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
123
|
+
const {
|
|
124
|
+
items,
|
|
125
|
+
files
|
|
126
|
+
} = e.dataTransfer;
|
|
125
127
|
if (items && items[0].kind === 'file') {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
+
const file = items[0].getAsFile();
|
|
128
129
|
if (isImage(file)) {
|
|
129
|
-
|
|
130
|
+
this.handleFileRead(file);
|
|
130
131
|
}
|
|
131
132
|
} else if (isImage(files[0])) {
|
|
132
|
-
|
|
133
|
+
this.handleFileRead(files[0]);
|
|
133
134
|
}
|
|
134
|
-
|
|
135
|
-
_this.disableDropzone();
|
|
135
|
+
this.disableDropzone();
|
|
136
136
|
});
|
|
137
|
-
(0, _defineProperty2
|
|
137
|
+
(0, _defineProperty2.default)(this, "handleOnDragOver", e => {
|
|
138
138
|
e.preventDefault();
|
|
139
|
-
|
|
140
|
-
|
|
139
|
+
const {
|
|
140
|
+
dropzoneActive
|
|
141
|
+
} = this.state;
|
|
141
142
|
if (!dropzoneActive) {
|
|
142
|
-
|
|
143
|
+
this.enableDropzone();
|
|
143
144
|
}
|
|
144
145
|
});
|
|
145
|
-
(0, _defineProperty2
|
|
146
|
+
(0, _defineProperty2.default)(this, "handleOnDragExit", e => {
|
|
146
147
|
e.preventDefault();
|
|
147
|
-
|
|
148
|
-
_this.disableDropzone();
|
|
148
|
+
this.disableDropzone();
|
|
149
149
|
});
|
|
150
|
-
(0, _defineProperty2
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
150
|
+
(0, _defineProperty2.default)(this, "onUpdateShapes", newShapes => {
|
|
151
|
+
const {
|
|
152
|
+
onUpdateShapes
|
|
153
|
+
} = this.props;
|
|
154
|
+
this.setState({
|
|
154
155
|
shapes: newShapes
|
|
155
|
-
},
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
});
|
|
156
|
+
},
|
|
157
|
+
// always transform shapes array back into shapes map when saving changes
|
|
158
|
+
() => onUpdateShapes((0, _utils.groupShapes)(newShapes)));
|
|
159
159
|
});
|
|
160
|
-
(0, _defineProperty2
|
|
161
|
-
|
|
162
|
-
|
|
160
|
+
(0, _defineProperty2.default)(this, "onDeleteShape", id => {
|
|
161
|
+
const {
|
|
162
|
+
shapes
|
|
163
|
+
} = this.state;
|
|
163
164
|
if (shapes && shapes.length) {
|
|
164
165
|
// filter the deleted shape out
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
_this.onUpdateShapes(newShapes);
|
|
166
|
+
let newShapes = shapes.filter(shape => shape.id !== id);
|
|
167
|
+
this.onUpdateShapes(newShapes);
|
|
170
168
|
}
|
|
171
169
|
});
|
|
172
|
-
(0, _defineProperty2
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
});
|
|
184
|
-
});
|
|
185
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleInputClick", function () {
|
|
186
|
-
var insertImage = _this.props.insertImage;
|
|
187
|
-
|
|
170
|
+
(0, _defineProperty2.default)(this, "handleClearAll", () => this.onUpdateShapes([]));
|
|
171
|
+
(0, _defineProperty2.default)(this, "handleEnableDrag", () => this.setState({
|
|
172
|
+
dragEnabled: true
|
|
173
|
+
}));
|
|
174
|
+
(0, _defineProperty2.default)(this, "handleDisableDrag", () => this.setState({
|
|
175
|
+
dragEnabled: false
|
|
176
|
+
}));
|
|
177
|
+
(0, _defineProperty2.default)(this, "handleInputClick", () => {
|
|
178
|
+
const {
|
|
179
|
+
insertImage
|
|
180
|
+
} = this.props;
|
|
188
181
|
if (insertImage) {
|
|
189
|
-
insertImage(
|
|
182
|
+
insertImage(this.fakeImageHandler);
|
|
190
183
|
}
|
|
191
184
|
});
|
|
192
|
-
(0, _defineProperty2
|
|
185
|
+
(0, _defineProperty2.default)(this, "handleFinishDrawing", () => {
|
|
193
186
|
// Explicitly end the current shape drawing session
|
|
194
187
|
// This would cause the finalizeCreation method to be called in the HotspotDrawable component
|
|
195
|
-
|
|
188
|
+
this.setState({
|
|
196
189
|
selectedShape: _shapes.SUPPORTED_SHAPES.NONE
|
|
197
190
|
});
|
|
198
191
|
});
|
|
199
|
-
|
|
192
|
+
this.state = {
|
|
200
193
|
dragEnabled: true,
|
|
201
194
|
// always transform shapes map into shapes array at this level
|
|
202
195
|
shapes: (0, _utils.getAllShapes)(props.shapes),
|
|
203
196
|
selectedShape: _shapes.SUPPORTED_SHAPES.NONE
|
|
204
197
|
};
|
|
205
|
-
|
|
206
|
-
cancel:
|
|
207
|
-
done:
|
|
208
|
-
|
|
209
|
-
}
|
|
210
|
-
fileChosen: function fileChosen() {},
|
|
211
|
-
progress: function progress() {}
|
|
198
|
+
this.fakeImageHandler = {
|
|
199
|
+
cancel: () => {},
|
|
200
|
+
done: (a, url) => this.props.onImageUpload(url),
|
|
201
|
+
fileChosen: () => {},
|
|
202
|
+
progress: () => {}
|
|
212
203
|
};
|
|
213
|
-
return _this;
|
|
214
204
|
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
}, /*#__PURE__*/_react["default"].createElement(_polygon.PolygonButton, {
|
|
270
|
-
isActive: selectedShape === _shapes.SUPPORTED_SHAPES.POLYGON
|
|
271
|
-
})), /*#__PURE__*/_react["default"].createElement("div", {
|
|
272
|
-
onClick: function onClick() {
|
|
273
|
-
return _this2.setState({
|
|
274
|
-
selectedShape: selectedShape === _shapes.SUPPORTED_SHAPES.CIRCLE ? _shapes.SUPPORTED_SHAPES.NONE : _shapes.SUPPORTED_SHAPES.CIRCLE
|
|
275
|
-
});
|
|
276
|
-
},
|
|
277
|
-
className: classes.buttonShape
|
|
278
|
-
}, /*#__PURE__*/_react["default"].createElement(_circle.CircleButton, {
|
|
279
|
-
isActive: selectedShape === _shapes.SUPPORTED_SHAPES.CIRCLE
|
|
280
|
-
})), imageUrl && /*#__PURE__*/_react["default"].createElement(_uploadControl["default"], {
|
|
281
|
-
classNameButton: classes.replaceButton,
|
|
282
|
-
classNameSection: classes.replaceSection,
|
|
283
|
-
label: "Replace Image",
|
|
284
|
-
onInputClick: this.handleInputClick,
|
|
285
|
-
setRef: function setRef(ref) {
|
|
286
|
-
_this2.input = ref;
|
|
287
|
-
}
|
|
288
|
-
}), /*#__PURE__*/_react["default"].createElement(_button["default"], {
|
|
289
|
-
disabled: !(shapes && shapes.length),
|
|
290
|
-
onClick: this.handleClearAll,
|
|
291
|
-
label: "Clear all"
|
|
292
|
-
})), /*#__PURE__*/_react["default"].createElement("div", {
|
|
293
|
-
ref: function ref(_ref) {
|
|
294
|
-
_this2.imageSection = _ref;
|
|
295
|
-
},
|
|
296
|
-
className: classes.drawableHeight
|
|
297
|
-
}, imageUrl ? /*#__PURE__*/_react["default"].createElement(_hotspotDrawable["default"], {
|
|
298
|
-
dimensions: dimensions,
|
|
299
|
-
disableDrag: this.handleDisableDrag,
|
|
300
|
-
enableDrag: this.handleEnableDrag,
|
|
301
|
-
shapeType: this.state.selectedShape,
|
|
302
|
-
handleFinishDrawing: this.handleFinishDrawing,
|
|
303
|
-
imageUrl: imageUrl,
|
|
304
|
-
hotspotColor: hotspotColor,
|
|
305
|
-
selectedHotspotColor: selectedHotspotColor,
|
|
306
|
-
hoverOutlineColor: hoverOutlineColor,
|
|
307
|
-
multipleCorrect: multipleCorrect,
|
|
308
|
-
onUpdateImageDimension: onUpdateImageDimension,
|
|
309
|
-
onUpdateShapes: this.onUpdateShapes,
|
|
310
|
-
onDeleteShape: this.onDeleteShape,
|
|
311
|
-
outlineColor: outlineColor,
|
|
312
|
-
shapes: shapes,
|
|
313
|
-
strokeWidth: strokeWidth,
|
|
314
|
-
preserveAspectRatioEnabled: preserveAspectRatioEnabled
|
|
315
|
-
}) : /*#__PURE__*/_react["default"].createElement("div", {
|
|
316
|
-
className: (0, _classnames["default"])(classes.drawableHeight, classes.centered)
|
|
317
|
-
}, /*#__PURE__*/_react["default"].createElement("label", null, "Drag and drop or upload image from computer"), /*#__PURE__*/_react["default"].createElement("br", null), /*#__PURE__*/_react["default"].createElement(_uploadControl["default"], {
|
|
318
|
-
label: "Upload Image",
|
|
319
|
-
onInputClick: this.handleInputClick,
|
|
320
|
-
setRef: function setRef(ref) {
|
|
321
|
-
_this2.input = ref;
|
|
322
|
-
}
|
|
323
|
-
})))));
|
|
324
|
-
}
|
|
325
|
-
}], [{
|
|
326
|
-
key: "getDerivedStateFromProps",
|
|
327
|
-
value: function getDerivedStateFromProps(nextProps, prevState) {
|
|
328
|
-
// always transform shapes map into shapes array at this level
|
|
329
|
-
return _objectSpread(_objectSpread({}, prevState), {}, {
|
|
330
|
-
shapes: (0, _utils.getAllShapes)(nextProps.shapes)
|
|
331
|
-
});
|
|
332
|
-
}
|
|
333
|
-
}]);
|
|
334
|
-
return Container;
|
|
335
|
-
}(_react.Component);
|
|
336
|
-
|
|
337
|
-
exports.Container = Container;
|
|
338
|
-
|
|
339
|
-
var styles = function styles(theme) {
|
|
340
|
-
return {
|
|
341
|
-
buttonShape: {
|
|
342
|
-
marginRight: '5px',
|
|
343
|
-
'&:hover': {
|
|
344
|
-
cursor: 'pointer'
|
|
205
|
+
render() {
|
|
206
|
+
const {
|
|
207
|
+
dimensions,
|
|
208
|
+
hasErrors,
|
|
209
|
+
hotspotColor,
|
|
210
|
+
imageUrl,
|
|
211
|
+
multipleCorrect,
|
|
212
|
+
onUpdateImageDimension,
|
|
213
|
+
outlineColor,
|
|
214
|
+
strokeWidth,
|
|
215
|
+
preserveAspectRatioEnabled,
|
|
216
|
+
hoverOutlineColor,
|
|
217
|
+
selectedHotspotColor
|
|
218
|
+
} = this.props;
|
|
219
|
+
const {
|
|
220
|
+
dropzoneActive,
|
|
221
|
+
dragEnabled
|
|
222
|
+
} = this.state;
|
|
223
|
+
const {
|
|
224
|
+
shapes,
|
|
225
|
+
selectedShape
|
|
226
|
+
} = this.state;
|
|
227
|
+
return /*#__PURE__*/_react.default.createElement(BaseContainer, null, /*#__PURE__*/_react.default.createElement(BoxContainer, (0, _extends2.default)({
|
|
228
|
+
hasErrors: hasErrors,
|
|
229
|
+
dropzoneActive: dropzoneActive
|
|
230
|
+
}, dragEnabled ? {
|
|
231
|
+
onDragExit: this.handleOnDragExit,
|
|
232
|
+
onDragLeave: this.handleOnDragExit,
|
|
233
|
+
onDragOver: this.handleOnDragOver,
|
|
234
|
+
onDrop: this.handleOnDrop,
|
|
235
|
+
onPaste: this.handleOnPaste
|
|
236
|
+
} : {}), /*#__PURE__*/_react.default.createElement(Toolbar, null, /*#__PURE__*/_react.default.createElement(ButtonShape, {
|
|
237
|
+
onClick: () => this.setState({
|
|
238
|
+
selectedShape: selectedShape === _shapes.SUPPORTED_SHAPES.RECTANGLE ? _shapes.SUPPORTED_SHAPES.NONE : _shapes.SUPPORTED_SHAPES.RECTANGLE
|
|
239
|
+
})
|
|
240
|
+
}, /*#__PURE__*/_react.default.createElement(_rectangle.RectangleButton, {
|
|
241
|
+
isActive: selectedShape === _shapes.SUPPORTED_SHAPES.RECTANGLE
|
|
242
|
+
})), /*#__PURE__*/_react.default.createElement(ButtonShape, {
|
|
243
|
+
onClick: () => this.setState({
|
|
244
|
+
selectedShape: selectedShape === _shapes.SUPPORTED_SHAPES.POLYGON ? _shapes.SUPPORTED_SHAPES.NONE : _shapes.SUPPORTED_SHAPES.POLYGON
|
|
245
|
+
})
|
|
246
|
+
}, /*#__PURE__*/_react.default.createElement(_polygon.PolygonButton, {
|
|
247
|
+
isActive: selectedShape === _shapes.SUPPORTED_SHAPES.POLYGON
|
|
248
|
+
})), /*#__PURE__*/_react.default.createElement(ButtonShape, {
|
|
249
|
+
onClick: () => this.setState({
|
|
250
|
+
selectedShape: selectedShape === _shapes.SUPPORTED_SHAPES.CIRCLE ? _shapes.SUPPORTED_SHAPES.NONE : _shapes.SUPPORTED_SHAPES.CIRCLE
|
|
251
|
+
})
|
|
252
|
+
}, /*#__PURE__*/_react.default.createElement(_circle.CircleButton, {
|
|
253
|
+
isActive: selectedShape === _shapes.SUPPORTED_SHAPES.CIRCLE
|
|
254
|
+
})), imageUrl && /*#__PURE__*/_react.default.createElement(ReplaceSection, null, /*#__PURE__*/_react.default.createElement(_uploadControl.default, {
|
|
255
|
+
label: "Replace Image",
|
|
256
|
+
onInputClick: this.handleInputClick,
|
|
257
|
+
setRef: ref => {
|
|
258
|
+
this.input = ref;
|
|
345
259
|
}
|
|
346
|
-
},
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
},
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
},
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
replaceSection: {
|
|
383
|
-
marginRight: 'auto'
|
|
384
|
-
},
|
|
385
|
-
toolbar: {
|
|
386
|
-
backgroundColor: '#FFF',
|
|
387
|
-
borderBottom: '1px solid #E0E1E6',
|
|
388
|
-
borderTopLeftRadius: '5px',
|
|
389
|
-
borderTopRightRadius: '5px',
|
|
390
|
-
display: 'flex',
|
|
391
|
-
justifyContent: 'flex-end',
|
|
392
|
-
padding: theme.spacing.unit
|
|
393
|
-
}
|
|
394
|
-
};
|
|
395
|
-
};
|
|
396
|
-
|
|
260
|
+
})), /*#__PURE__*/_react.default.createElement(_button.default, {
|
|
261
|
+
disabled: !(shapes && shapes.length),
|
|
262
|
+
onClick: this.handleClearAll,
|
|
263
|
+
label: "Clear all"
|
|
264
|
+
})), /*#__PURE__*/_react.default.createElement(DrawableHeight, {
|
|
265
|
+
ref: ref => {
|
|
266
|
+
this.imageSection = ref;
|
|
267
|
+
}
|
|
268
|
+
}, imageUrl ? /*#__PURE__*/_react.default.createElement(_hotspotDrawable.default, {
|
|
269
|
+
dimensions: dimensions,
|
|
270
|
+
disableDrag: this.handleDisableDrag,
|
|
271
|
+
enableDrag: this.handleEnableDrag,
|
|
272
|
+
shapeType: this.state.selectedShape,
|
|
273
|
+
handleFinishDrawing: this.handleFinishDrawing,
|
|
274
|
+
imageUrl: imageUrl,
|
|
275
|
+
hotspotColor: hotspotColor,
|
|
276
|
+
selectedHotspotColor: selectedHotspotColor,
|
|
277
|
+
hoverOutlineColor: hoverOutlineColor,
|
|
278
|
+
multipleCorrect: multipleCorrect,
|
|
279
|
+
onUpdateImageDimension: onUpdateImageDimension,
|
|
280
|
+
onUpdateShapes: this.onUpdateShapes,
|
|
281
|
+
onDeleteShape: this.onDeleteShape,
|
|
282
|
+
outlineColor: outlineColor,
|
|
283
|
+
shapes: shapes,
|
|
284
|
+
strokeWidth: strokeWidth,
|
|
285
|
+
preserveAspectRatioEnabled: preserveAspectRatioEnabled
|
|
286
|
+
}) : /*#__PURE__*/_react.default.createElement(CenteredContainer, null, /*#__PURE__*/_react.default.createElement("label", null, "Drag and drop or upload image from computer"), /*#__PURE__*/_react.default.createElement("br", null), /*#__PURE__*/_react.default.createElement(_uploadControl.default, {
|
|
287
|
+
label: "Upload Image",
|
|
288
|
+
onInputClick: this.handleInputClick,
|
|
289
|
+
setRef: ref => {
|
|
290
|
+
this.input = ref;
|
|
291
|
+
}
|
|
292
|
+
})))));
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
exports.Container = Container;
|
|
397
296
|
Container.propTypes = {
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
polygons: _propTypes["default"].array
|
|
297
|
+
dimensions: _propTypes.default.object.isRequired,
|
|
298
|
+
imageUrl: _propTypes.default.string.isRequired,
|
|
299
|
+
hotspotColor: _propTypes.default.string.isRequired,
|
|
300
|
+
selectedHotspotColor: _propTypes.default.string,
|
|
301
|
+
hoverOutlineColor: _propTypes.default.string,
|
|
302
|
+
multipleCorrect: _propTypes.default.bool.isRequired,
|
|
303
|
+
onImageUpload: _propTypes.default.func.isRequired,
|
|
304
|
+
onUpdateImageDimension: _propTypes.default.func.isRequired,
|
|
305
|
+
insertImage: _propTypes.default.func,
|
|
306
|
+
onUpdateShapes: _propTypes.default.func.isRequired,
|
|
307
|
+
outlineColor: _propTypes.default.string.isRequired,
|
|
308
|
+
shapes: _propTypes.default.shape({
|
|
309
|
+
rectangles: _propTypes.default.array,
|
|
310
|
+
polygons: _propTypes.default.array
|
|
413
311
|
}).isRequired,
|
|
414
|
-
strokeWidth: _propTypes
|
|
415
|
-
preserveAspectRatioEnabled: _propTypes
|
|
416
|
-
hasErrors: _propTypes
|
|
312
|
+
strokeWidth: _propTypes.default.number,
|
|
313
|
+
preserveAspectRatioEnabled: _propTypes.default.bool,
|
|
314
|
+
hasErrors: _propTypes.default.bool
|
|
417
315
|
};
|
|
418
316
|
Container.defaultProps = {
|
|
419
317
|
strokeWidth: 5
|
|
420
318
|
};
|
|
421
|
-
|
|
422
|
-
var _default = (0, _index.withStyles)(styles)(Container);
|
|
423
|
-
|
|
424
|
-
exports["default"] = _default;
|
|
319
|
+
var _default = exports.default = Container;
|
|
425
320
|
//# sourceMappingURL=hotspot-container.js.map
|