@pie-element/hotspot 6.1.2-next.44 → 6.1.2-next.57

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/configure/lib/buttons/circle.js +40 -0
  2. package/configure/lib/buttons/circle.js.map +1 -0
  3. package/configure/lib/buttons/polygon.js +46 -0
  4. package/configure/lib/buttons/polygon.js.map +1 -0
  5. package/configure/lib/buttons/rectangle.js +46 -0
  6. package/configure/lib/buttons/rectangle.js.map +1 -0
  7. package/configure/lib/hotspot-container.js +44 -4
  8. package/configure/lib/hotspot-container.js.map +1 -1
  9. package/configure/lib/hotspot-drawable.js +180 -115
  10. package/configure/lib/hotspot-drawable.js.map +1 -1
  11. package/configure/lib/hotspot-polygon.js +11 -2
  12. package/configure/lib/hotspot-polygon.js.map +1 -1
  13. package/configure/lib/shapes/circle.js +96 -0
  14. package/configure/lib/shapes/circle.js.map +1 -0
  15. package/configure/lib/shapes/polygon.js +111 -0
  16. package/configure/lib/shapes/polygon.js.map +1 -0
  17. package/configure/lib/shapes/rectagle.js +115 -0
  18. package/configure/lib/shapes/rectagle.js.map +1 -0
  19. package/configure/package.json +1 -1
  20. package/configure/src/__tests__/__snapshots__/hotspot-container.test.js.snap +16 -0
  21. package/configure/src/__tests__/__snapshots__/hotspot-drawable.test.js.snap +42 -0
  22. package/configure/src/__tests__/hotspot-drawable.test.js +4 -1
  23. package/configure/src/buttons/circle.jsx +18 -0
  24. package/configure/src/buttons/polygon.jsx +29 -0
  25. package/configure/src/buttons/rectangle.jsx +29 -0
  26. package/configure/src/hotspot-container.jsx +31 -2
  27. package/configure/src/hotspot-drawable.jsx +112 -54
  28. package/configure/src/hotspot-polygon.jsx +12 -2
  29. package/configure/src/shapes/circle.js +67 -0
  30. package/configure/src/shapes/polygon.js +79 -0
  31. package/configure/src/shapes/rectagle.js +80 -0
  32. package/controller/package.json +1 -1
  33. package/package.json +3 -3
@@ -17,6 +17,8 @@ exports[`HotspotDrawable render renders 1`] = `
17
17
  </div>
18
18
  <ForwardRef
19
19
  height={291}
20
+ onContentMouseLeave={[Function]}
21
+ onContentMouseOut={[Function]}
20
22
  onMouseDown={[Function]}
21
23
  onMouseMove={[Function]}
22
24
  onMouseUp={[Function]}
@@ -24,6 +26,7 @@ exports[`HotspotDrawable render renders 1`] = `
24
26
  >
25
27
  <Layer>
26
28
  <WithStyles(RectComponent)
29
+ addPolygonPoint={[Function]}
27
30
  correct={true}
28
31
  height={140}
29
32
  hotspotColor="rgba(137, 183, 244, 0.65)"
@@ -33,6 +36,7 @@ exports[`HotspotDrawable render renders 1`] = `
33
36
  isDrawing={false}
34
37
  key="0"
35
38
  onClick={[Function]}
39
+ onDeleteShape={[MockFunction]}
36
40
  onDragEnd={[Function]}
37
41
  outlineColor="blue"
38
42
  strokeWidth={5}
@@ -41,6 +45,7 @@ exports[`HotspotDrawable render renders 1`] = `
41
45
  y={1}
42
46
  />
43
47
  <WithStyles(RectComponent)
48
+ addPolygonPoint={[Function]}
44
49
  height={140}
45
50
  hotspotColor="rgba(137, 183, 244, 0.65)"
46
51
  id="1"
@@ -49,6 +54,7 @@ exports[`HotspotDrawable render renders 1`] = `
49
54
  isDrawing={false}
50
55
  key="1"
51
56
  onClick={[Function]}
57
+ onDeleteShape={[MockFunction]}
52
58
  onDragEnd={[Function]}
53
59
  outlineColor="blue"
54
60
  strokeWidth={5}
@@ -57,6 +63,7 @@ exports[`HotspotDrawable render renders 1`] = `
57
63
  y={1}
58
64
  />
59
65
  <WithStyles(RectComponent)
66
+ addPolygonPoint={[Function]}
60
67
  height={140}
61
68
  hotspotColor="rgba(137, 183, 244, 0.65)"
62
69
  id="2"
@@ -65,6 +72,7 @@ exports[`HotspotDrawable render renders 1`] = `
65
72
  isDrawing={false}
66
73
  key="2"
67
74
  onClick={[Function]}
75
+ onDeleteShape={[MockFunction]}
68
76
  onDragEnd={[Function]}
69
77
  outlineColor="blue"
70
78
  strokeWidth={5}
@@ -73,6 +81,7 @@ exports[`HotspotDrawable render renders 1`] = `
73
81
  y={1}
74
82
  />
75
83
  <WithStyles(PolComponent)
84
+ addPolygonPoint={[Function]}
76
85
  correct={true}
77
86
  hotspotColor="rgba(137, 183, 244, 0.65)"
78
87
  id="3"
@@ -81,6 +90,7 @@ exports[`HotspotDrawable render renders 1`] = `
81
90
  isDrawing={false}
82
91
  key="3"
83
92
  onClick={[Function]}
93
+ onDeleteShape={[MockFunction]}
84
94
  onDragEnd={[Function]}
85
95
  outlineColor="blue"
86
96
  points={
@@ -106,6 +116,7 @@ exports[`HotspotDrawable render renders 1`] = `
106
116
  strokeWidth={5}
107
117
  />
108
118
  <WithStyles(PolComponent)
119
+ addPolygonPoint={[Function]}
109
120
  correct={false}
110
121
  hotspotColor="rgba(137, 183, 244, 0.65)"
111
122
  id="4"
@@ -114,6 +125,7 @@ exports[`HotspotDrawable render renders 1`] = `
114
125
  isDrawing={false}
115
126
  key="4"
116
127
  onClick={[Function]}
128
+ onDeleteShape={[MockFunction]}
117
129
  onDragEnd={[Function]}
118
130
  outlineColor="blue"
119
131
  points={
@@ -139,6 +151,7 @@ exports[`HotspotDrawable render renders 1`] = `
139
151
  strokeWidth={5}
140
152
  />
141
153
  <WithStyles(PolComponent)
154
+ addPolygonPoint={[Function]}
142
155
  correct={false}
143
156
  hotspotColor="rgba(137, 183, 244, 0.65)"
144
157
  id="5"
@@ -147,6 +160,7 @@ exports[`HotspotDrawable render renders 1`] = `
147
160
  isDrawing={false}
148
161
  key="5"
149
162
  onClick={[Function]}
163
+ onDeleteShape={[MockFunction]}
150
164
  onDragEnd={[Function]}
151
165
  outlineColor="blue"
152
166
  points={
@@ -193,6 +207,8 @@ exports[`HotspotDrawable render renders with default strokeWidth 1`] = `
193
207
  </div>
194
208
  <ForwardRef
195
209
  height={291}
210
+ onContentMouseLeave={[Function]}
211
+ onContentMouseOut={[Function]}
196
212
  onMouseDown={[Function]}
197
213
  onMouseMove={[Function]}
198
214
  onMouseUp={[Function]}
@@ -200,6 +216,7 @@ exports[`HotspotDrawable render renders with default strokeWidth 1`] = `
200
216
  >
201
217
  <Layer>
202
218
  <WithStyles(RectComponent)
219
+ addPolygonPoint={[Function]}
203
220
  correct={true}
204
221
  height={140}
205
222
  hotspotColor="rgba(137, 183, 244, 0.65)"
@@ -209,6 +226,7 @@ exports[`HotspotDrawable render renders with default strokeWidth 1`] = `
209
226
  isDrawing={false}
210
227
  key="0"
211
228
  onClick={[Function]}
229
+ onDeleteShape={[MockFunction]}
212
230
  onDragEnd={[Function]}
213
231
  outlineColor="blue"
214
232
  strokeWidth={5}
@@ -217,6 +235,7 @@ exports[`HotspotDrawable render renders with default strokeWidth 1`] = `
217
235
  y={1}
218
236
  />
219
237
  <WithStyles(RectComponent)
238
+ addPolygonPoint={[Function]}
220
239
  height={140}
221
240
  hotspotColor="rgba(137, 183, 244, 0.65)"
222
241
  id="1"
@@ -225,6 +244,7 @@ exports[`HotspotDrawable render renders with default strokeWidth 1`] = `
225
244
  isDrawing={false}
226
245
  key="1"
227
246
  onClick={[Function]}
247
+ onDeleteShape={[MockFunction]}
228
248
  onDragEnd={[Function]}
229
249
  outlineColor="blue"
230
250
  strokeWidth={5}
@@ -233,6 +253,7 @@ exports[`HotspotDrawable render renders with default strokeWidth 1`] = `
233
253
  y={1}
234
254
  />
235
255
  <WithStyles(RectComponent)
256
+ addPolygonPoint={[Function]}
236
257
  height={140}
237
258
  hotspotColor="rgba(137, 183, 244, 0.65)"
238
259
  id="2"
@@ -241,6 +262,7 @@ exports[`HotspotDrawable render renders with default strokeWidth 1`] = `
241
262
  isDrawing={false}
242
263
  key="2"
243
264
  onClick={[Function]}
265
+ onDeleteShape={[MockFunction]}
244
266
  onDragEnd={[Function]}
245
267
  outlineColor="blue"
246
268
  strokeWidth={5}
@@ -249,6 +271,7 @@ exports[`HotspotDrawable render renders with default strokeWidth 1`] = `
249
271
  y={1}
250
272
  />
251
273
  <WithStyles(PolComponent)
274
+ addPolygonPoint={[Function]}
252
275
  correct={true}
253
276
  hotspotColor="rgba(137, 183, 244, 0.65)"
254
277
  id="3"
@@ -257,6 +280,7 @@ exports[`HotspotDrawable render renders with default strokeWidth 1`] = `
257
280
  isDrawing={false}
258
281
  key="3"
259
282
  onClick={[Function]}
283
+ onDeleteShape={[MockFunction]}
260
284
  onDragEnd={[Function]}
261
285
  outlineColor="blue"
262
286
  points={
@@ -282,6 +306,7 @@ exports[`HotspotDrawable render renders with default strokeWidth 1`] = `
282
306
  strokeWidth={5}
283
307
  />
284
308
  <WithStyles(PolComponent)
309
+ addPolygonPoint={[Function]}
285
310
  correct={false}
286
311
  hotspotColor="rgba(137, 183, 244, 0.65)"
287
312
  id="4"
@@ -290,6 +315,7 @@ exports[`HotspotDrawable render renders with default strokeWidth 1`] = `
290
315
  isDrawing={false}
291
316
  key="4"
292
317
  onClick={[Function]}
318
+ onDeleteShape={[MockFunction]}
293
319
  onDragEnd={[Function]}
294
320
  outlineColor="blue"
295
321
  points={
@@ -315,6 +341,7 @@ exports[`HotspotDrawable render renders with default strokeWidth 1`] = `
315
341
  strokeWidth={5}
316
342
  />
317
343
  <WithStyles(PolComponent)
344
+ addPolygonPoint={[Function]}
318
345
  correct={false}
319
346
  hotspotColor="rgba(137, 183, 244, 0.65)"
320
347
  id="5"
@@ -323,6 +350,7 @@ exports[`HotspotDrawable render renders with default strokeWidth 1`] = `
323
350
  isDrawing={false}
324
351
  key="5"
325
352
  onClick={[Function]}
353
+ onDeleteShape={[MockFunction]}
326
354
  onDragEnd={[Function]}
327
355
  outlineColor="blue"
328
356
  points={
@@ -369,6 +397,8 @@ exports[`HotspotDrawable render renders with given strokeWidth 1`] = `
369
397
  </div>
370
398
  <ForwardRef
371
399
  height={291}
400
+ onContentMouseLeave={[Function]}
401
+ onContentMouseOut={[Function]}
372
402
  onMouseDown={[Function]}
373
403
  onMouseMove={[Function]}
374
404
  onMouseUp={[Function]}
@@ -376,6 +406,7 @@ exports[`HotspotDrawable render renders with given strokeWidth 1`] = `
376
406
  >
377
407
  <Layer>
378
408
  <WithStyles(RectComponent)
409
+ addPolygonPoint={[Function]}
379
410
  correct={true}
380
411
  height={140}
381
412
  hotspotColor="rgba(137, 183, 244, 0.65)"
@@ -385,6 +416,7 @@ exports[`HotspotDrawable render renders with given strokeWidth 1`] = `
385
416
  isDrawing={false}
386
417
  key="0"
387
418
  onClick={[Function]}
419
+ onDeleteShape={[MockFunction]}
388
420
  onDragEnd={[Function]}
389
421
  outlineColor="blue"
390
422
  strokeWidth={10}
@@ -393,6 +425,7 @@ exports[`HotspotDrawable render renders with given strokeWidth 1`] = `
393
425
  y={1}
394
426
  />
395
427
  <WithStyles(RectComponent)
428
+ addPolygonPoint={[Function]}
396
429
  height={140}
397
430
  hotspotColor="rgba(137, 183, 244, 0.65)"
398
431
  id="1"
@@ -401,6 +434,7 @@ exports[`HotspotDrawable render renders with given strokeWidth 1`] = `
401
434
  isDrawing={false}
402
435
  key="1"
403
436
  onClick={[Function]}
437
+ onDeleteShape={[MockFunction]}
404
438
  onDragEnd={[Function]}
405
439
  outlineColor="blue"
406
440
  strokeWidth={10}
@@ -409,6 +443,7 @@ exports[`HotspotDrawable render renders with given strokeWidth 1`] = `
409
443
  y={1}
410
444
  />
411
445
  <WithStyles(RectComponent)
446
+ addPolygonPoint={[Function]}
412
447
  height={140}
413
448
  hotspotColor="rgba(137, 183, 244, 0.65)"
414
449
  id="2"
@@ -417,6 +452,7 @@ exports[`HotspotDrawable render renders with given strokeWidth 1`] = `
417
452
  isDrawing={false}
418
453
  key="2"
419
454
  onClick={[Function]}
455
+ onDeleteShape={[MockFunction]}
420
456
  onDragEnd={[Function]}
421
457
  outlineColor="blue"
422
458
  strokeWidth={10}
@@ -425,6 +461,7 @@ exports[`HotspotDrawable render renders with given strokeWidth 1`] = `
425
461
  y={1}
426
462
  />
427
463
  <WithStyles(PolComponent)
464
+ addPolygonPoint={[Function]}
428
465
  correct={true}
429
466
  hotspotColor="rgba(137, 183, 244, 0.65)"
430
467
  id="3"
@@ -433,6 +470,7 @@ exports[`HotspotDrawable render renders with given strokeWidth 1`] = `
433
470
  isDrawing={false}
434
471
  key="3"
435
472
  onClick={[Function]}
473
+ onDeleteShape={[MockFunction]}
436
474
  onDragEnd={[Function]}
437
475
  outlineColor="blue"
438
476
  points={
@@ -458,6 +496,7 @@ exports[`HotspotDrawable render renders with given strokeWidth 1`] = `
458
496
  strokeWidth={10}
459
497
  />
460
498
  <WithStyles(PolComponent)
499
+ addPolygonPoint={[Function]}
461
500
  correct={false}
462
501
  hotspotColor="rgba(137, 183, 244, 0.65)"
463
502
  id="4"
@@ -466,6 +505,7 @@ exports[`HotspotDrawable render renders with given strokeWidth 1`] = `
466
505
  isDrawing={false}
467
506
  key="4"
468
507
  onClick={[Function]}
508
+ onDeleteShape={[MockFunction]}
469
509
  onDragEnd={[Function]}
470
510
  outlineColor="blue"
471
511
  points={
@@ -491,6 +531,7 @@ exports[`HotspotDrawable render renders with given strokeWidth 1`] = `
491
531
  strokeWidth={10}
492
532
  />
493
533
  <WithStyles(PolComponent)
534
+ addPolygonPoint={[Function]}
494
535
  correct={false}
495
536
  hotspotColor="rgba(137, 183, 244, 0.65)"
496
537
  id="5"
@@ -499,6 +540,7 @@ exports[`HotspotDrawable render renders with given strokeWidth 1`] = `
499
540
  isDrawing={false}
500
541
  key="5"
501
542
  onClick={[Function]}
543
+ onDeleteShape={[MockFunction]}
502
544
  onDragEnd={[Function]}
503
545
  outlineColor="blue"
504
546
  points={
@@ -95,6 +95,9 @@ describe('HotspotDrawable', () => {
95
95
  outlineColor: initialModel.outlineColor,
96
96
  shapes: initialModel.shapes,
97
97
  strokeWidth: 5,
98
+ shapeType: 'rectangle',
99
+ handleFinishDrawing: jest.fn(),
100
+ onDeleteShape: jest.fn(),
98
101
  ...extras,
99
102
  };
100
103
 
@@ -168,7 +171,7 @@ describe('HotspotDrawable', () => {
168
171
 
169
172
  it('handleOnMouseUp isDrawing = true', () => {
170
173
  wrapper.instance().state.isDrawing = true;
171
- wrapper.instance().state.stateShapes = initialModel.shapes.slice(0, 2);
174
+ wrapper.instance().state.shapes = initialModel.shapes.slice(0, 2);
172
175
 
173
176
  wrapper.instance().handleOnMouseUp({
174
177
  evt: {
@@ -0,0 +1,18 @@
1
+ import PropTypes from 'prop-types';
2
+ import React from 'react';
3
+
4
+ export const CircleButton = ({ isActive = false }) => (
5
+ <svg xmlns="http://www.w3.org/2000/svg" width="48" height="32" viewBox="0 0 48 32" fill="none">
6
+ <path
7
+ fillRule="evenodd"
8
+ clipRule="evenodd"
9
+ d="M56 4C56 1.79086 57.7909 0 60 0H99C101.209 0 103 1.79086 103 4V28.0001C103 30.2093 101.209 32.0001 99 32.0001H60C57.7909 32.0001 56 30.2093 56 28.0001V4Z"
10
+ fill={isActive ? '#D3D4D9' : '#ECEDF1'}
11
+ />
12
+ <circle cx="79" cy="16" r="7.5" stroke="black" />
13
+ </svg>
14
+ );
15
+
16
+ CircleButton.propTypes = {
17
+ isActive: PropTypes.bool,
18
+ };
@@ -0,0 +1,29 @@
1
+ import PropTypes from 'prop-types';
2
+ import React from 'react';
3
+
4
+ export const PolygonButton = ({ isActive = false }) => (
5
+ <svg xmlns="http://www.w3.org/2000/svg" width="48" height="32" viewBox="112 0 48 32" fill="none">
6
+ <path
7
+ fillRule="evenodd"
8
+ clipRule="evenodd"
9
+ d="M112 4C112 1.79086 113.791 0 116 0H155C157.209 0 159 1.79086 159 4V28.0001C159 30.2093 157.209 32.0001 155 32.0001H116C113.791 32.0001 112 30.2093 112 28.0001V4Z"
10
+ fill={isActive ? '#D3D4D9' : '#ECEDF1'}
11
+ />
12
+ <mask id="path-6-inside-1_2196_700" fill="white">
13
+ <path
14
+ fillRule="evenodd"
15
+ clipRule="evenodd"
16
+ d="M130 8H126V12H127.5V20H126V24H130V22.7145H141V24H145V20H141.737L139.998 18H140V14.4265L142.11 12H145V8H141V9.71451H130V8ZM139.046 14L141 11.7525V10.7145H130V12H128.5V20H130V21.7145H141V20.6765L138.673 18H136V14H139.046Z"
17
+ />
18
+ </mask>
19
+ <path
20
+ d="M126 8V7H125V8H126ZM130 8H131V7H130V8ZM126 12H125V13H126V12ZM127.5 12H128.5V11H127.5V12ZM127.5 20V21H128.5V20H127.5ZM126 20V19H125V20H126ZM126 24H125V25H126V24ZM130 24V25H131V24H130ZM130 22.7145V21.7145H129V22.7145H130ZM141 22.7145H142V21.7145H141V22.7145ZM141 24H140V25H141V24ZM145 24V25H146V24H145ZM145 20H146V19H145V20ZM141.737 20L140.982 20.6562L141.281 21H141.737V20ZM139.998 18V17H137.803L139.243 18.6562L139.998 18ZM140 18V19H141V18H140ZM140 14.4265L139.245 13.7703L139 14.0525V14.4265H140ZM142.11 12V11H141.654L141.355 11.3438L142.11 12ZM145 12V13H146V12H145ZM145 8H146V7H145V8ZM141 8V7H140V8H141ZM141 9.71451V10.7145H142V9.71451H141ZM130 9.71451H129V10.7145H130V9.71451ZM141 11.7525L141.755 12.4087L142 12.1265V11.7525H141ZM139.046 14V15H139.501L139.8 14.6562L139.046 14ZM141 10.7145H142V9.71451H141V10.7145ZM130 10.7145V9.71451H129V10.7145H130ZM130 12V13H131V12H130ZM128.5 12V11H127.5V12H128.5ZM128.5 20H127.5V21H128.5V20ZM130 20H131V19H130V20ZM130 21.7145H129V22.7145H130V21.7145ZM141 21.7145V22.7145H142V21.7145H141ZM141 20.6765H142V20.3025L141.755 20.0203L141 20.6765ZM138.673 18L139.427 17.3438L139.128 17H138.673V18ZM136 18H135V19H136V18ZM136 14V13H135V14H136ZM126 9H130V7H126V9ZM127 12V8H125V12H127ZM127.5 11H126V13H127.5V11ZM128.5 20V12H126.5V20H128.5ZM126 21H127.5V19H126V21ZM127 24V20H125V24H127ZM130 23H126V25H130V23ZM129 22.7145V24H131V22.7145H129ZM141 21.7145H130V23.7145H141V21.7145ZM142 24V22.7145H140V24H142ZM145 23H141V25H145V23ZM144 20V24H146V20H144ZM141.737 21H145V19H141.737V21ZM139.243 18.6562L140.982 20.6562L142.492 19.3438L140.752 17.3438L139.243 18.6562ZM140 17H139.998V19H140V17ZM139 14.4265V18H141V14.4265H139ZM141.355 11.3438L139.245 13.7703L140.755 15.0827L142.865 12.6562L141.355 11.3438ZM145 11H142.11V13H145V11ZM144 8V12H146V8H144ZM141 9H145V7H141V9ZM142 9.71451V8H140V9.71451H142ZM130 10.7145H141V8.71451H130V10.7145ZM129 8V9.71451H131V8H129ZM140.245 11.0963L138.291 13.3438L139.8 14.6562L141.755 12.4087L140.245 11.0963ZM140 10.7145V11.7525H142V10.7145H140ZM130 11.7145H141V9.71451H130V11.7145ZM131 12V10.7145H129V12H131ZM128.5 13H130V11H128.5V13ZM129.5 20V12H127.5V20H129.5ZM130 19H128.5V21H130V19ZM131 21.7145V20H129V21.7145H131ZM141 20.7145H130V22.7145H141V20.7145ZM140 20.6765V21.7145H142V20.6765H140ZM137.918 18.6562L140.245 21.3327L141.755 20.0203L139.427 17.3438L137.918 18.6562ZM138.673 17H136V19H138.673V17ZM137 18V14H135V18H137ZM136 15H139.046V13H136V15Z"
21
+ fill="black"
22
+ mask="url(#path-6-inside-1_2196_700)"
23
+ />
24
+ </svg>
25
+ );
26
+
27
+ PolygonButton.propTypes = {
28
+ isActive: PropTypes.bool,
29
+ };
@@ -0,0 +1,29 @@
1
+ import PropTypes from 'prop-types';
2
+ import React from 'react';
3
+
4
+ export const RectangleButton = ({ isActive = false }) => (
5
+ <svg xmlns="http://www.w3.org/2000/svg" width="48" height="32" viewBox="0 0 48 32" fill="none">
6
+ <path
7
+ fillRule="evenodd"
8
+ clipRule="evenodd"
9
+ d="M0 4C0 1.79086 1.79086 0 4 0H43C45.2091 0 47 1.79086 47 4V28.0001C47 30.2093 45.2091 32.0001 43 32.0001H4C1.79086 32.0001 0 30.2093 0 28.0001V4Z"
10
+ fill={isActive ? '#D3D4D9' : '#ECEDF1'}
11
+ />
12
+ <mask id="path-8-inside-2_2196_700" fill="white">
13
+ <path
14
+ fillRule="evenodd"
15
+ clipRule="evenodd"
16
+ d="M13 8H17V9.5H29V8H33V12H31.5V20H33V24H29V22.5H17V24H13V20H14.5V12H13V8ZM17 21.5V20H15.5V12H17V10.5H29V12H30.5V20H29V21.5H17Z"
17
+ />
18
+ </mask>
19
+ <path
20
+ d="M17 8H18V7H17V8ZM13 8V7H12V8H13ZM17 9.5H16V10.5H17V9.5ZM29 9.5V10.5H30V9.5H29ZM29 8V7H28V8H29ZM33 8H34V7H33V8ZM33 12V13H34V12H33ZM31.5 12V11H30.5V12H31.5ZM31.5 20H30.5V21H31.5V20ZM33 20H34V19H33V20ZM33 24V25H34V24H33ZM29 24H28V25H29V24ZM29 22.5H30V21.5H29V22.5ZM17 22.5V21.5H16V22.5H17ZM17 24V25H18V24H17ZM13 24H12V25H13V24ZM13 20V19H12V20H13ZM14.5 20V21H15.5V20H14.5ZM14.5 12H15.5V11H14.5V12ZM13 12H12V13H13V12ZM17 20H18V19H17V20ZM17 21.5H16V22.5H17V21.5ZM15.5 20H14.5V21H15.5V20ZM15.5 12V11H14.5V12H15.5ZM17 12V13H18V12H17ZM17 10.5V9.5H16V10.5H17ZM29 10.5H30V9.5H29V10.5ZM29 12H28V13H29V12ZM30.5 12H31.5V11H30.5V12ZM30.5 20V21H31.5V20H30.5ZM29 20V19H28V20H29ZM29 21.5V22.5H30V21.5H29ZM17 7H13V9H17V7ZM18 9.5V8H16V9.5H18ZM29 8.5H17V10.5H29V8.5ZM28 8V9.5H30V8H28ZM33 7H29V9H33V7ZM34 12V8H32V12H34ZM31.5 13H33V11H31.5V13ZM32.5 20V12H30.5V20H32.5ZM33 19H31.5V21H33V19ZM34 24V20H32V24H34ZM29 25H33V23H29V25ZM28 22.5V24H30V22.5H28ZM17 23.5H29V21.5H17V23.5ZM16 22.5V24H18V22.5H16ZM17 23H13V25H17V23ZM14 24V20H12V24H14ZM13 21H14.5V19H13V21ZM13.5 12V20H15.5V12H13.5ZM13 13H14.5V11H13V13ZM12 8V12H14V8H12ZM16 20V21.5H18V20H16ZM15.5 21H17V19H15.5V21ZM16.5 20V12H14.5V20H16.5ZM15.5 13H17V11H15.5V13ZM18 12V10.5H16V12H18ZM17 11.5H29V9.5H17V11.5ZM28 10.5V12H30V10.5H28ZM29 13H30.5V11H29V13ZM29.5 12V20H31.5V12H29.5ZM30.5 19H29V21H30.5V19ZM28 20V21.5H30V20H28ZM29 20.5H17V22.5H29V20.5Z"
21
+ fill="black"
22
+ mask="url(#path-8-inside-2_2196_700)"
23
+ />
24
+ </svg>
25
+ );
26
+
27
+ RectangleButton.propTypes = {
28
+ isActive: PropTypes.bool,
29
+ };
@@ -5,6 +5,8 @@ import { withStyles } from '@material-ui/core/styles/index';
5
5
  import Help from '@material-ui/icons/Help';
6
6
 
7
7
  import Drawable from './hotspot-drawable';
8
+ import { RectangleButton } from './buttons/rectangle';
9
+ import { PolygonButton } from './buttons/polygon';
8
10
  import Button from './button';
9
11
  import UploadControl from './upload-control';
10
12
  import { getAllShapes, groupShapes } from './utils';
@@ -31,6 +33,7 @@ export class Container extends Component {
31
33
  dragEnabled: true,
32
34
  // always transform shapes map into shapes array at this level
33
35
  shapes: getAllShapes(props.shapes),
36
+ selectedShape: 'none',
34
37
  };
35
38
  this.fakeImageHandler = {
36
39
  cancel: () => {},
@@ -135,6 +138,11 @@ export class Container extends Component {
135
138
  }
136
139
  };
137
140
 
141
+ handleFinishDrawing = () => {
142
+ // Explicitly end the current shape drawing session
143
+ // This would cause the finalizeCreation method to be called in the HotspotDrawable component
144
+ this.setState({ selectedShape: 'none' });
145
+ };
138
146
  toggleTooltip = () => this.setState({ showTooltip: !this.state.showTooltip });
139
147
 
140
148
  render() {
@@ -151,7 +159,7 @@ export class Container extends Component {
151
159
  preserveAspectRatioEnabled,
152
160
  } = this.props;
153
161
  const { dropzoneActive, dragEnabled, showTooltip } = this.state;
154
- const { shapes } = this.state;
162
+ const { shapes, selectedShape } = this.state;
155
163
 
156
164
  return (
157
165
  <div className={classes.base}>
@@ -171,6 +179,19 @@ export class Container extends Component {
171
179
  : {})}
172
180
  >
173
181
  <div className={classes.toolbar}>
182
+ <div
183
+ onClick={() => this.setState({ selectedShape: selectedShape === 'rectangle' ? 'none' : 'rectangle' })}
184
+ className={classes.buttonShape}
185
+ >
186
+ <RectangleButton isActive={selectedShape === 'rectangle'} />
187
+ </div>
188
+ <div
189
+ onClick={() => this.setState({ selectedShape: selectedShape === 'polygon' ? 'none' : 'polygon' })}
190
+ className={classes.buttonShape}
191
+ >
192
+ <PolygonButton isActive={selectedShape === 'polygon'} />
193
+ </div>
194
+
174
195
  {imageUrl && (
175
196
  <UploadControl
176
197
  classNameButton={classes.replaceButton}
@@ -196,6 +217,8 @@ export class Container extends Component {
196
217
  dimensions={dimensions}
197
218
  disableDrag={this.handleDisableDrag}
198
219
  enableDrag={this.handleEnableDrag}
220
+ shapeType={this.state.selectedShape}
221
+ handleFinishDrawing={this.handleFinishDrawing}
199
222
  imageUrl={imageUrl}
200
223
  hotspotColor={hotspotColor}
201
224
  multipleCorrect={multipleCorrect}
@@ -243,6 +266,12 @@ export class Container extends Component {
243
266
  }
244
267
 
245
268
  const styles = (theme) => ({
269
+ buttonShape: {
270
+ marginRight: '5px',
271
+ '&:hover': {
272
+ cursor: 'pointer',
273
+ },
274
+ },
246
275
  base: {
247
276
  marginTop: theme.spacing.unit * 1.5,
248
277
  marginBottom: theme.spacing.unit * 2.5,
@@ -282,7 +311,7 @@ const styles = (theme) => ({
282
311
  marginRight: 'auto',
283
312
  },
284
313
  toolbar: {
285
- backgroundColor: '#ECEDF1',
314
+ backgroundColor: '#FFF',
286
315
  borderBottom: '1px solid #E0E1E6',
287
316
  borderTopLeftRadius: '5px',
288
317
  borderTopRightRadius: '5px',