@gamelearn/arcade-components 0.2.0 → 0.4.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.
Files changed (30) hide show
  1. package/dist/components/arcade-render/background/scene-elements/index.js +4 -2
  2. package/dist/components/arcade-render/element/AnimateElement.js +9 -15
  3. package/dist/components/arcade-render/element/index.js +15 -5
  4. package/dist/components/arcade-render/elements-list/index.js +4 -2
  5. package/dist/components/arcade-render/light/useLight.js +1 -0
  6. package/dist/components/arcade-render/loading/Loading.js +3 -4
  7. package/dist/components/arcade-render/loading/LoadingLogic.js +4 -31
  8. package/dist/components/arcade-render/scene/index.js +8 -8
  9. package/dist/components/conversational-pro-component/components/scene/Panel.js +0 -8
  10. package/dist/components/hacker-puzzle-component/components/Area/index.js +150 -0
  11. package/dist/components/hacker-puzzle-component/components/Feedback/index.js +72 -0
  12. package/dist/components/hacker-puzzle-component/components/KonvaMapper/index.js +230 -0
  13. package/dist/components/hanged-puzzle-component/components/HangedPuzzleComponent.js +429 -0
  14. package/dist/components/{pikachu-component → hanged-puzzle-component}/index.js +2 -2
  15. package/dist/components/hanged-puzzle-component/mocks/mockForStory.js +54 -0
  16. package/dist/components/hanged-puzzle-component/utils.js +36 -0
  17. package/dist/components/image-click-puzzle-component/components/ImageClickPuzzleComponent.js +23 -0
  18. package/dist/components/image-click-puzzle-component/index.js +13 -0
  19. package/dist/components/image-click-puzzle-component/mocks/mockForStory.js +423 -0
  20. package/dist/components/image-click-wrapper-component/components/Area/index.js +150 -0
  21. package/dist/components/image-click-wrapper-component/components/Feedback/index.js +51 -0
  22. package/dist/components/image-click-wrapper-component/components/ImageClickWrapperComponent.js +351 -0
  23. package/dist/components/image-click-wrapper-component/components/KonvaMapper/index.js +230 -0
  24. package/dist/components/image-click-wrapper-component/index.js +13 -0
  25. package/dist/components/image-click-wrapper-component/mocks/mockForStory.js +307 -0
  26. package/dist/components/index.js +16 -0
  27. package/dist/helpers/useGLB.js +9 -22
  28. package/package.json +16 -3
  29. package/dist/components/pikachu-component/components/PikachuComponent.js +0 -24
  30. package/dist/components/pikachu-component/mocks/mockForStory.js +0 -15
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.mockProps = void 0;
7
+
8
+ var emitEvent = function emitEvent() {
9
+ console.log('Emit event called');
10
+ };
11
+
12
+ var soundActions = [function (sound) {
13
+ console.log('PlaySound called :', sound);
14
+ }, function () {}];
15
+
16
+ var disableExit = function disableExit(attr) {
17
+ return attr;
18
+ };
19
+
20
+ var mockProps = {
21
+ emitEvent: emitEvent,
22
+ soundActions: soundActions,
23
+ disableExit: disableExit,
24
+ image: {
25
+ img: {
26
+ url: 'https://s3-eu-west-1.amazonaws.com/gl-lms-storage/development/clients/58dccfba26561500117caf53/image/60508f84901f3e00123a0796/holamundo.jpg'
27
+ }
28
+ },
29
+ question: 'Hola amigos, ¿como están?',
30
+ answer: 'muy bien',
31
+ info: {
32
+ hint: {
33
+ active: true,
34
+ desc: 'hint',
35
+ rewards: []
36
+ },
37
+ resolve: {
38
+ rewards: []
39
+ },
40
+ solution: {
41
+ right: {
42
+ desc: 'correctSolution',
43
+ rewards: []
44
+ },
45
+ wrong: {
46
+ desc: 'wrongSolution',
47
+ rewards: []
48
+ }
49
+ },
50
+ instructions: 'cghgfdhgch',
51
+ description: 'description'
52
+ }
53
+ };
54
+ exports.mockProps = mockProps;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.makeChar = exports.sortChar = exports.restrictCharacters = void 0;
7
+
8
+ var restrictCharacters = function restrictCharacters(char, operator) {
9
+ var restrictedChar = false;
10
+
11
+ if (operator === 'or') {
12
+ restrictedChar = char === '' || char === ' ' || char === ',' || char === '.' || char === '/';
13
+ }
14
+
15
+ if (operator === 'and') {
16
+ restrictedChar = char && char !== ' ' && char !== ',' && char !== '.' && char !== '' && char !== '/';
17
+ }
18
+
19
+ return restrictedChar;
20
+ };
21
+
22
+ exports.restrictCharacters = restrictCharacters;
23
+
24
+ var sortChar = function sortChar(a, b) {
25
+ return a.char > b.char ? 1 : a.char < b.char ? -1 : 0;
26
+ };
27
+
28
+ exports.sortChar = sortChar;
29
+
30
+ var makeChar = function makeChar() {
31
+ var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
32
+ var charactersLength = characters.length;
33
+ return characters.charAt(Math.floor(Math.random() * charactersLength));
34
+ };
35
+
36
+ exports.makeChar = makeChar;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ var _imageClickWrapperComponent = _interopRequireDefault(require("../../image-click-wrapper-component"));
11
+
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+
14
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
15
+
16
+ var ImageClickPuzzleComponent = function ImageClickPuzzleComponent(props) {
17
+ return /*#__PURE__*/_react.default.createElement(_imageClickWrapperComponent.default, _extends({}, props, {
18
+ name: "image-click-puzzle"
19
+ }));
20
+ };
21
+
22
+ var _default = ImageClickPuzzleComponent;
23
+ exports.default = _default;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _ImageClickPuzzleComponent = _interopRequireDefault(require("./components/ImageClickPuzzleComponent"));
9
+
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+
12
+ var _default = _ImageClickPuzzleComponent.default;
13
+ exports.default = _default;
@@ -0,0 +1,423 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.mockProps4 = exports.mockProps3 = exports.mockProps2 = exports.mockProps = void 0;
7
+
8
+ var emitEvent = function emitEvent() {
9
+ console.log('Emit event called');
10
+ };
11
+
12
+ var mockProps = {
13
+ emitEvent: emitEvent,
14
+ disableExit: function disableExit() {},
15
+ setResolveAction: function setResolveAction() {},
16
+ info: {
17
+ hint: {
18
+ active: true,
19
+ desc: 'hint',
20
+ rewards: []
21
+ },
22
+ resolve: {
23
+ rewards: []
24
+ },
25
+ solution: {
26
+ right: {
27
+ desc: 'correctSolution',
28
+ desc_labelId: 'alfalfa01',
29
+ rewards: []
30
+ },
31
+ wrong: {
32
+ desc: 'wrongSolution',
33
+ desc_labelId: 'fabada01',
34
+ rewards: [{
35
+ id: 'grade',
36
+ name: 'grade',
37
+ points: -17,
38
+ type: 'grade'
39
+ }]
40
+ }
41
+ },
42
+ instructions: 'instructions'
43
+ },
44
+ itemOrder: 1,
45
+ image: {
46
+ imgName: 'image-click.jpg',
47
+ img: {
48
+ url: 'https://min.gamelearn.io/css-resources/gamelearn/resources/image-click.jpg',
49
+ imgName: 'image-click.jpg',
50
+ resourceId: '6007f80eac41ad001120f135'
51
+ },
52
+ width: 1280,
53
+ height: 800
54
+ },
55
+ areas: [{
56
+ name: 'Uno',
57
+ x: 0,
58
+ y: 0,
59
+ fill: 'rgba(255, 255, 255, 0.1)',
60
+ draggable: true,
61
+ points: [261.6, 186.4, 344.8, 183.2, 341.6, 404, 255.2, 400.8],
62
+ stroke: 'rgb(101,154,93)',
63
+ closed: true
64
+ }, {
65
+ name: 'Dos',
66
+ x: 0,
67
+ y: 0,
68
+ fill: 'rgba(255, 255, 255, 0.1)',
69
+ draggable: true,
70
+ points: [644, 138.4, 728.8, 140, 728.8, 400.8, 640.8, 396],
71
+ stroke: 'rgb(147,126,155)',
72
+ closed: true
73
+ }, {
74
+ name: 'Tres',
75
+ x: 0,
76
+ y: 0,
77
+ fill: 'rgba(255, 255, 255, 0.1)',
78
+ draggable: true,
79
+ points: [8.8, 493.6, 1256.8, 487.2, 1269.6, 775.2, 7.2, 786.4],
80
+ stroke: 'rgb(157,131,205)',
81
+ closed: true
82
+ }],
83
+ badAreas: [{
84
+ name: 'Bad1',
85
+ x: 0,
86
+ y: 0,
87
+ fill: 'rgba(255, 255, 255, 0.1)',
88
+ draggable: true,
89
+ points: [700, 200, 800, 190, 900, 450, 640.8, 396],
90
+ stroke: 'rgb(101,154,93)',
91
+ closed: true
92
+ }, {
93
+ name: 'Bad',
94
+ x: 0,
95
+ y: 0,
96
+ fill: 'rgba(255, 255, 255, 0.1)',
97
+ draggable: true,
98
+ points: [900, 300, 900, 233, 1200, 555, 777, 555],
99
+ stroke: 'rgb(101,154,93)',
100
+ closed: true
101
+ }, {
102
+ name: 'Bad',
103
+ x: 0,
104
+ y: 0,
105
+ fill: 'rgba(255, 255, 255, 0.1)',
106
+ draggable: true,
107
+ points: [111, 111, 222, 111, 666, 450, 640.8, 396],
108
+ stroke: 'rgb(101,154,93)',
109
+ closed: true
110
+ }],
111
+ hasClickOrder: true,
112
+ hasHighlights: true
113
+ };
114
+ exports.mockProps = mockProps;
115
+ var mockProps2 = {
116
+ emitEvent: emitEvent,
117
+ disableExit: function disableExit() {},
118
+ setResolveAction: function setResolveAction() {},
119
+ info: {
120
+ hint: {
121
+ active: true,
122
+ desc: 'hint',
123
+ rewards: []
124
+ },
125
+ resolve: {
126
+ rewards: []
127
+ },
128
+ solution: {
129
+ right: {
130
+ desc: 'correctSolution',
131
+ desc_labelId: 'alfalfa01',
132
+ rewards: []
133
+ },
134
+ wrong: {
135
+ desc: 'wrongSolution',
136
+ desc_labelId: 'fabada01',
137
+ rewards: [{
138
+ id: 'grade',
139
+ name: 'grade',
140
+ points: -17,
141
+ type: 'grade'
142
+ }]
143
+ }
144
+ },
145
+ instructions: 'instructions'
146
+ },
147
+ itemOrder: 1,
148
+ image: {
149
+ imgName: 'image-click.jpg',
150
+ img: {
151
+ url: 'https://min.gamelearn.io/css-resources/gamelearn/resources/image-click.jpg',
152
+ imgName: 'image-click.jpg',
153
+ resourceId: '6007f80eac41ad001120f135'
154
+ },
155
+ width: 1280,
156
+ height: 800
157
+ },
158
+ areas: [{
159
+ name: 'Uno',
160
+ x: 0,
161
+ y: 0,
162
+ fill: 'rgba(255, 255, 255, 0.1)',
163
+ draggable: true,
164
+ points: [261.6, 186.4, 344.8, 183.2, 341.6, 404, 255.2, 400.8],
165
+ stroke: 'rgb(101,154,93)',
166
+ closed: true
167
+ }, {
168
+ name: 'Dos',
169
+ x: 0,
170
+ y: 0,
171
+ fill: 'rgba(255, 255, 255, 0.1)',
172
+ draggable: true,
173
+ points: [644, 138.4, 728.8, 140, 728.8, 400.8, 640.8, 396],
174
+ stroke: 'rgb(147,126,155)',
175
+ closed: true
176
+ }, {
177
+ name: 'Tres',
178
+ x: 0,
179
+ y: 0,
180
+ fill: 'rgba(255, 255, 255, 0.1)',
181
+ draggable: true,
182
+ points: [8.8, 493.6, 1256.8, 487.2, 1269.6, 775.2, 7.2, 786.4],
183
+ stroke: 'rgb(157,131,205)',
184
+ closed: true
185
+ }],
186
+ badAreas: [{
187
+ name: 'Bad1',
188
+ x: 0,
189
+ y: 0,
190
+ fill: 'rgba(255, 255, 255, 0.1)',
191
+ draggable: true,
192
+ points: [700, 200, 800, 190, 900, 450, 640.8, 396],
193
+ stroke: 'rgb(101,154,93)',
194
+ closed: true
195
+ }, {
196
+ name: 'Bad',
197
+ x: 0,
198
+ y: 0,
199
+ fill: 'rgba(255, 255, 255, 0.1)',
200
+ draggable: true,
201
+ points: [900, 300, 900, 233, 1200, 555, 777, 555],
202
+ stroke: 'rgb(101,154,93)',
203
+ closed: true
204
+ }, {
205
+ name: 'Bad',
206
+ x: 0,
207
+ y: 0,
208
+ fill: 'rgba(255, 255, 255, 0.1)',
209
+ draggable: true,
210
+ points: [111, 111, 222, 111, 666, 450, 640.8, 396],
211
+ stroke: 'rgb(101,154,93)',
212
+ closed: true
213
+ }],
214
+ hasClickOrder: true,
215
+ hasHighlights: false
216
+ };
217
+ exports.mockProps2 = mockProps2;
218
+ var mockProps3 = {
219
+ emitEvent: emitEvent,
220
+ disableExit: function disableExit() {},
221
+ setResolveAction: function setResolveAction() {},
222
+ info: {
223
+ hint: {
224
+ active: true,
225
+ desc: 'hint',
226
+ rewards: []
227
+ },
228
+ resolve: {
229
+ rewards: []
230
+ },
231
+ solution: {
232
+ right: {
233
+ desc: 'correctSolution',
234
+ desc_labelId: 'alfalfa01',
235
+ rewards: []
236
+ },
237
+ wrong: {
238
+ desc: 'wrongSolution',
239
+ desc_labelId: 'fabada01',
240
+ rewards: [{
241
+ id: 'grade',
242
+ name: 'grade',
243
+ points: -17,
244
+ type: 'grade'
245
+ }]
246
+ }
247
+ },
248
+ instructions: 'instructions'
249
+ },
250
+ itemOrder: 1,
251
+ image: {
252
+ imgName: 'image-click.jpg',
253
+ img: {
254
+ url: 'https://min.gamelearn.io/css-resources/gamelearn/resources/image-click.jpg',
255
+ imgName: 'image-click.jpg',
256
+ resourceId: '6007f80eac41ad001120f135'
257
+ },
258
+ width: 1280,
259
+ height: 800
260
+ },
261
+ areas: [{
262
+ name: 'Uno',
263
+ x: 0,
264
+ y: 0,
265
+ fill: 'rgba(255, 255, 255, 0.1)',
266
+ draggable: true,
267
+ points: [261.6, 186.4, 344.8, 183.2, 341.6, 404, 255.2, 400.8],
268
+ stroke: 'rgb(101,154,93)',
269
+ closed: true
270
+ }, {
271
+ name: 'Dos',
272
+ x: 0,
273
+ y: 0,
274
+ fill: 'rgba(255, 255, 255, 0.1)',
275
+ draggable: true,
276
+ points: [644, 138.4, 728.8, 140, 728.8, 400.8, 640.8, 396],
277
+ stroke: 'rgb(147,126,155)',
278
+ closed: true
279
+ }, {
280
+ name: 'Tres',
281
+ x: 0,
282
+ y: 0,
283
+ fill: 'rgba(255, 255, 255, 0.1)',
284
+ draggable: true,
285
+ points: [8.8, 493.6, 1256.8, 487.2, 1269.6, 775.2, 7.2, 786.4],
286
+ stroke: 'rgb(157,131,205)',
287
+ closed: true
288
+ }],
289
+ badAreas: [{
290
+ name: 'Bad1',
291
+ x: 0,
292
+ y: 0,
293
+ fill: 'rgba(255, 255, 255, 0.1)',
294
+ draggable: true,
295
+ points: [700, 200, 800, 190, 900, 450, 640.8, 396],
296
+ stroke: 'rgb(101,154,93)',
297
+ closed: true
298
+ }, {
299
+ name: 'Bad',
300
+ x: 0,
301
+ y: 0,
302
+ fill: 'rgba(255, 255, 255, 0.1)',
303
+ draggable: true,
304
+ points: [900, 300, 900, 233, 1200, 555, 777, 555],
305
+ stroke: 'rgb(101,154,93)',
306
+ closed: true
307
+ }, {
308
+ name: 'Bad',
309
+ x: 0,
310
+ y: 0,
311
+ fill: 'rgba(255, 255, 255, 0.1)',
312
+ draggable: true,
313
+ points: [111, 111, 222, 111, 666, 450, 640.8, 396],
314
+ stroke: 'rgb(101,154,93)',
315
+ closed: true
316
+ }],
317
+ hasClickOrder: false,
318
+ hasHighlights: true
319
+ };
320
+ exports.mockProps3 = mockProps3;
321
+ var mockProps4 = {
322
+ emitEvent: emitEvent,
323
+ disableExit: function disableExit() {},
324
+ setResolveAction: function setResolveAction() {},
325
+ info: {
326
+ hint: {
327
+ active: true,
328
+ desc: 'hint',
329
+ rewards: []
330
+ },
331
+ resolve: {
332
+ rewards: []
333
+ },
334
+ solution: {
335
+ right: {
336
+ desc: 'correctSolution',
337
+ desc_labelId: 'alfalfa01',
338
+ rewards: []
339
+ },
340
+ wrong: {
341
+ desc: 'wrongSolution',
342
+ desc_labelId: 'fabada01',
343
+ rewards: [{
344
+ id: 'grade',
345
+ name: 'grade',
346
+ points: -17,
347
+ type: 'grade'
348
+ }]
349
+ }
350
+ },
351
+ instructions: 'instructions'
352
+ },
353
+ itemOrder: 1,
354
+ image: {
355
+ imgName: 'image-click.jpg',
356
+ img: {
357
+ url: 'https://min.gamelearn.io/css-resources/gamelearn/resources/image-click.jpg',
358
+ imgName: 'image-click.jpg',
359
+ resourceId: '6007f80eac41ad001120f135'
360
+ },
361
+ width: 1280,
362
+ height: 800
363
+ },
364
+ areas: [{
365
+ name: 'Uno',
366
+ x: 0,
367
+ y: 0,
368
+ fill: 'rgba(255, 255, 255, 0.1)',
369
+ draggable: true,
370
+ points: [261.6, 186.4, 344.8, 183.2, 341.6, 404, 255.2, 400.8],
371
+ stroke: 'rgb(101,154,93)',
372
+ closed: true
373
+ }, {
374
+ name: 'Dos',
375
+ x: 0,
376
+ y: 0,
377
+ fill: 'rgba(255, 255, 255, 0.1)',
378
+ draggable: true,
379
+ points: [644, 138.4, 728.8, 140, 728.8, 400.8, 640.8, 396],
380
+ stroke: 'rgb(147,126,155)',
381
+ closed: true
382
+ }, {
383
+ name: 'Tres',
384
+ x: 0,
385
+ y: 0,
386
+ fill: 'rgba(255, 255, 255, 0.1)',
387
+ draggable: true,
388
+ points: [8.8, 493.6, 1256.8, 487.2, 1269.6, 775.2, 7.2, 786.4],
389
+ stroke: 'rgb(157,131,205)',
390
+ closed: true
391
+ }],
392
+ badAreas: [{
393
+ name: 'Bad1',
394
+ x: 0,
395
+ y: 0,
396
+ fill: 'rgba(255, 255, 255, 0.1)',
397
+ draggable: true,
398
+ points: [700, 200, 800, 190, 900, 450, 640.8, 396],
399
+ stroke: 'rgb(101,154,93)',
400
+ closed: true
401
+ }, {
402
+ name: 'Bad',
403
+ x: 0,
404
+ y: 0,
405
+ fill: 'rgba(255, 255, 255, 0.1)',
406
+ draggable: true,
407
+ points: [900, 300, 900, 233, 1200, 555, 777, 555],
408
+ stroke: 'rgb(101,154,93)',
409
+ closed: true
410
+ }, {
411
+ name: 'Bad',
412
+ x: 0,
413
+ y: 0,
414
+ fill: 'rgba(255, 255, 255, 0.1)',
415
+ draggable: true,
416
+ points: [111, 111, 222, 111, 666, 450, 640.8, 396],
417
+ stroke: 'rgb(101,154,93)',
418
+ closed: true
419
+ }],
420
+ hasClickOrder: false,
421
+ hasHighlights: false
422
+ };
423
+ exports.mockProps4 = mockProps4;
@@ -0,0 +1,150 @@
1
+ "use strict";
2
+
3
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+
10
+ var _react = _interopRequireWildcard(require("react"));
11
+
12
+ var _reactKonva = require("react-konva");
13
+
14
+ var _propTypes = _interopRequireDefault(require("prop-types"));
15
+
16
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
+
18
+ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
19
+
20
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
21
+
22
+ var Area = function Area(_ref) {
23
+ var area = _ref.area,
24
+ finished = _ref.finished,
25
+ isClicked = _ref.isClicked,
26
+ isBad = _ref.isBad,
27
+ hasHighlights = _ref.hasHighlights,
28
+ completed = _ref.completed,
29
+ onClick = _ref.onClick,
30
+ onClickOutside = _ref.onClickOutside;
31
+ var areaRef = (0, _react.useRef)();
32
+ var fillColor = isBad ? 'rgba(255, 99, 77, 0.32)' : 'rgba(75, 215, 169, 0.32)';
33
+ var strokeColor = isBad ? '#ff634d' : '#4bd7a9';
34
+
35
+ var mouseEnterArea = function mouseEnterArea() {
36
+ if (hasHighlights && !completed && !isClicked) {
37
+ areaRef.current.setAttr('fill', 'rgba(130, 134, 142, 0.4)');
38
+ areaRef.current.setAttr('stroke', 'rgba(255, 255, 255, 0.3)');
39
+ areaRef.current.to({
40
+ duration: 0.25,
41
+ opacity: 1
42
+ });
43
+ }
44
+ };
45
+
46
+ var mouseLeaveArea = function mouseLeaveArea() {
47
+ if (hasHighlights && !completed && !isClicked) {
48
+ areaRef.current.to({
49
+ duration: 0.25,
50
+ opacity: 0
51
+ });
52
+ }
53
+ };
54
+
55
+ (0, _react.useEffect)(function () {
56
+ if (completed && !finished) {
57
+ if (!isBad) {
58
+ areaRef.current.to({
59
+ duration: 0.25,
60
+ opacity: 1
61
+ });
62
+ areaRef.current.globalCompositeOperation('destination-out');
63
+ } else {
64
+ areaRef.current.to({
65
+ duration: 0.25,
66
+ opacity: 0
67
+ });
68
+ }
69
+ }
70
+ }, [completed]);
71
+
72
+ var clickArea = function clickArea() {
73
+ if (!completed) {
74
+ if (isBad) {
75
+ onClickOutside();
76
+ } else {
77
+ onClick(area);
78
+ }
79
+
80
+ areaRef.current.setAttr('fill', fillColor);
81
+ areaRef.current.setAttr('stroke', strokeColor);
82
+ }
83
+ };
84
+
85
+ var scaleX = area.scaleX ? area.scaleX : 1;
86
+ var scaleY = area.scaleY ? area.scaleY : 1;
87
+ return /*#__PURE__*/_react.default.createElement(_reactKonva.Line, {
88
+ name: area.id,
89
+ ref: areaRef,
90
+ onFocus: function onFocus() {
91
+ return mouseEnterArea(area);
92
+ },
93
+ onMouseOver: function onMouseOver() {
94
+ return mouseEnterArea(area);
95
+ },
96
+ onMouseLeave: mouseLeaveArea,
97
+ onClick: function onClick() {
98
+ return clickArea();
99
+ },
100
+ onTap: function onTap() {
101
+ return clickArea();
102
+ },
103
+ x: area.x,
104
+ y: area.y,
105
+ scale: {
106
+ x: scaleX,
107
+ y: scaleY
108
+ },
109
+ skew: {
110
+ x: area.skewX,
111
+ y: area.skewY
112
+ },
113
+ rotation: area.rotation,
114
+ shape: "poly",
115
+ points: area.points,
116
+ fill: finished ? '' : fillColor,
117
+ stroke: finished || isClicked ? strokeColor : '',
118
+ strokeWidth: 2,
119
+ opacity: finished || isClicked ? 1 : 0,
120
+ closed: true
121
+ });
122
+ };
123
+
124
+ Area.defaultProps = {
125
+ finished: false,
126
+ isBad: false,
127
+ isClicked: false,
128
+ hasHighlights: false,
129
+ completed: false,
130
+ onClick: function onClick() {},
131
+ onClickOutside: function onClickOutside() {}
132
+ };
133
+ Area.propTypes = {
134
+ area: _propTypes.default.shape({
135
+ index: _propTypes.default.number,
136
+ x: _propTypes.default.number,
137
+ y: _propTypes.default.number,
138
+ points: _propTypes.default.arrayOf(_propTypes.default.number),
139
+ name: _propTypes.default.string
140
+ }).isRequired,
141
+ onClick: _propTypes.default.func,
142
+ onClickOutside: _propTypes.default.func,
143
+ finished: _propTypes.default.bool,
144
+ hasHighlights: _propTypes.default.bool,
145
+ completed: _propTypes.default.bool,
146
+ isBad: _propTypes.default.bool,
147
+ isClicked: _propTypes.default.bool
148
+ };
149
+ var _default = Area;
150
+ exports.default = _default;