@gamelearn/arcade-components 1.27.12 → 1.28.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/drag-item-puzzle-component/components/DragItemPuzzleComponent.js +3 -4
- package/dist/components/feedback-component/components/FeedbackComponent.js +1 -1
- package/dist/components/frame-click-puzzle-component/mocks/mockForStory.js +11 -1
- package/dist/components/image-click-wrapper-component/components/CountDown/index.js +22 -0
- package/dist/components/image-click-wrapper-component/components/ImageClickWrapperComponent.js +37 -4
- package/dist/components/terminal-puzzle-component/components/Visor/index.js +17 -0
- package/dist/components/test-component/components/Container.js +1 -1
- package/package.json +2 -2
|
@@ -195,7 +195,6 @@ var DragItemPuzzleComponent = function DragItemPuzzleComponent(_ref) {
|
|
|
195
195
|
});
|
|
196
196
|
}, [consume, emitEvent, resolveObject.name, resolveObject.uid]);
|
|
197
197
|
var handleClose = (0, _react.useCallback)(function () {
|
|
198
|
-
playSound('score');
|
|
199
198
|
setResolveClass('success');
|
|
200
199
|
emitEvent({
|
|
201
200
|
type: 'hidePuzzleButtons',
|
|
@@ -205,13 +204,12 @@ var DragItemPuzzleComponent = function DragItemPuzzleComponent(_ref) {
|
|
|
205
204
|
setTimeout(function () {
|
|
206
205
|
handleFinish();
|
|
207
206
|
}, 2000);
|
|
208
|
-
}, [emitEvent, handleFinish,
|
|
207
|
+
}, [emitEvent, handleFinish, solution.right.rewards]);
|
|
209
208
|
var handleFail = (0, _react.useCallback)(function () {
|
|
210
209
|
emitEvent({
|
|
211
210
|
type: 'closeUI',
|
|
212
211
|
ui: 'inventory'
|
|
213
212
|
});
|
|
214
|
-
playSound('fail');
|
|
215
213
|
setResolveClass('');
|
|
216
214
|
emitEvent({
|
|
217
215
|
type: 'hidePuzzleButtons',
|
|
@@ -221,7 +219,7 @@ var DragItemPuzzleComponent = function DragItemPuzzleComponent(_ref) {
|
|
|
221
219
|
type: 'failPuzzle'
|
|
222
220
|
});
|
|
223
221
|
accRewards.current = [].concat(_toConsumableArray(accRewards.current), _toConsumableArray(solution.wrong.rewards));
|
|
224
|
-
}, [emitEvent,
|
|
222
|
+
}, [emitEvent, solution.wrong.rewards]);
|
|
225
223
|
var handleDrop = (0, _react.useCallback)(function (e) {
|
|
226
224
|
e.dragEvent.stopPropagation();
|
|
227
225
|
e.dragEvent.preventDefault();
|
|
@@ -414,6 +412,7 @@ var DragItemPuzzleComponent = function DragItemPuzzleComponent(_ref) {
|
|
|
414
412
|
text: info.solution[resolvedClass === 'success' ? 'right' : 'wrong'].desc,
|
|
415
413
|
success: resolvedClass === 'success',
|
|
416
414
|
translate: translate,
|
|
415
|
+
playSound: playSound,
|
|
417
416
|
functionOnClose: handleFeedbackFuncionOnClose
|
|
418
417
|
}) : null);
|
|
419
418
|
};
|
|
@@ -634,6 +634,16 @@ var mockProps3 = {
|
|
|
634
634
|
points: [1150.0742574257429, 217.48228650990103, 1570.95297029703, 65.42288056930694, 1704.0049504950498, 195.7595142326733, 1576.383663366337, 421.13327660891093, 1247.8267326732675, 510.73971225247533],
|
|
635
635
|
stroke: 'rgb(101,154,93)',
|
|
636
636
|
closed: true
|
|
637
|
+
}, {
|
|
638
|
+
id: 'Dos',
|
|
639
|
+
name: 'Dos',
|
|
640
|
+
x: 0,
|
|
641
|
+
y: 0,
|
|
642
|
+
fill: 'rgba(255, 255, 255, 0.1)',
|
|
643
|
+
draggable: true,
|
|
644
|
+
points: [121.11881188118804, 1017.7722772277228, 254.1881188118811, 856.1881188118813, 637.5544554455446, 1144.5049504950496, 406.2673267326732, 1264.90099009901],
|
|
645
|
+
stroke: 'rgb(101,154,93)',
|
|
646
|
+
closed: true
|
|
637
647
|
}],
|
|
638
648
|
badAreas: [{
|
|
639
649
|
id: 'AllArea',
|
|
@@ -648,7 +658,7 @@ var mockProps3 = {
|
|
|
648
658
|
closed: true
|
|
649
659
|
}],
|
|
650
660
|
hasClickOrder: false,
|
|
651
|
-
timer:
|
|
661
|
+
timer: 15,
|
|
652
662
|
hasHighlights: true,
|
|
653
663
|
specificFeedbacks: {
|
|
654
664
|
correctFeedbacks: [{
|
|
@@ -0,0 +1,22 @@
|
|
|
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
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
|
|
12
|
+
var CountDown = function CountDown(_ref) {
|
|
13
|
+
var time = _ref.time;
|
|
14
|
+
var minutes = Math.floor(time / 60);
|
|
15
|
+
var seconds = time % 60;
|
|
16
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
17
|
+
className: "count-down count-down--in-puzzle-frame ".concat(time < 10 ? 'count-down--finalseconds' : '')
|
|
18
|
+
}, /*#__PURE__*/_react.default.createElement("div", null, minutes < 10 ? "0".concat(minutes) : minutes, " : ", seconds < 10 ? "0".concat(Math.floor(seconds)) : Math.floor(seconds)));
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
var _default = CountDown;
|
|
22
|
+
exports.default = _default;
|
package/dist/components/image-click-wrapper-component/components/ImageClickWrapperComponent.js
CHANGED
|
@@ -15,6 +15,8 @@ var _FeedbackComponent = _interopRequireDefault(require("../../feedback-componen
|
|
|
15
15
|
|
|
16
16
|
var _TimerDialog = _interopRequireDefault(require("./TimerDialog"));
|
|
17
17
|
|
|
18
|
+
var _CountDown = _interopRequireDefault(require("./CountDown"));
|
|
19
|
+
|
|
18
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
21
|
|
|
20
22
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
@@ -131,6 +133,12 @@ var ImageClickWrapperComponent = function ImageClickWrapperComponent(props) {
|
|
|
131
133
|
var pauseDate = (0, _react.useRef)(null);
|
|
132
134
|
var whenCloseFeedbackDate = (0, _react.useRef)(null);
|
|
133
135
|
var remainingTime = (0, _react.useRef)(null);
|
|
136
|
+
var intervalForCountDown = (0, _react.useRef)(null);
|
|
137
|
+
|
|
138
|
+
var _useState13 = (0, _react.useState)(timer),
|
|
139
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
|
140
|
+
countDownTime = _useState14[0],
|
|
141
|
+
setCountDownTime = _useState14[1];
|
|
134
142
|
|
|
135
143
|
var translate = function translate(id) {
|
|
136
144
|
if (translateFromParent) return translateFromParent(id); // when there is no emitEvent pass the Translate
|
|
@@ -158,6 +166,14 @@ var ImageClickWrapperComponent = function ImageClickWrapperComponent(props) {
|
|
|
158
166
|
shape: 'poly'
|
|
159
167
|
}, area);
|
|
160
168
|
});
|
|
169
|
+
var startCountDown = (0, _react.useCallback)(function () {
|
|
170
|
+
var timeout = setInterval(function () {
|
|
171
|
+
setCountDownTime(function (t) {
|
|
172
|
+
return t - 1;
|
|
173
|
+
});
|
|
174
|
+
}, 1000);
|
|
175
|
+
intervalForCountDown.current = timeout;
|
|
176
|
+
}, []);
|
|
161
177
|
var handleFinish = (0, _react.useCallback)(function (rewards, success) {
|
|
162
178
|
if (emitFinish) {
|
|
163
179
|
emitFinish(rewards, success);
|
|
@@ -179,6 +195,9 @@ var ImageClickWrapperComponent = function ImageClickWrapperComponent(props) {
|
|
|
179
195
|
var clearListenerForActualDate = (0, _react.useCallback)(function () {
|
|
180
196
|
clearInterval(intervalForActualDate.current);
|
|
181
197
|
}, []);
|
|
198
|
+
var clearIntervalForCountDown = (0, _react.useCallback)(function () {
|
|
199
|
+
clearInterval(intervalForCountDown.current);
|
|
200
|
+
}, []);
|
|
182
201
|
var pauseTheCounter = (0, _react.useCallback)(function () {
|
|
183
202
|
pauseDate.current = Date.now();
|
|
184
203
|
remainingTime.current = finalDate.current - pauseDate.current;
|
|
@@ -201,10 +220,11 @@ var ImageClickWrapperComponent = function ImageClickWrapperComponent(props) {
|
|
|
201
220
|
};
|
|
202
221
|
});
|
|
203
222
|
setTimeExpired(true);
|
|
223
|
+
clearIntervalForCountDown();
|
|
204
224
|
clearListenerForActualDate();
|
|
205
225
|
}
|
|
206
226
|
}, 250);
|
|
207
|
-
}, [clearListenerForActualDate,
|
|
227
|
+
}, [clearListenerForActualDate, clearIntervalForCountDown, (_info$timerFeedback3 = info.timerFeedback) === null || _info$timerFeedback3 === void 0 ? void 0 : _info$timerFeedback3.desc, (_info$timerFeedback4 = info.timerFeedback) === null || _info$timerFeedback4 === void 0 ? void 0 : _info$timerFeedback4.rewards]);
|
|
208
228
|
(0, _react.useEffect)(function () {
|
|
209
229
|
if ((areas.length === clickedZones.length || hasClickOnce && clickedZones.length > 0) && !completed) {
|
|
210
230
|
var _specificFeedbacks$co;
|
|
@@ -236,6 +256,7 @@ var ImageClickWrapperComponent = function ImageClickWrapperComponent(props) {
|
|
|
236
256
|
(0, _react.useEffect)(function () {
|
|
237
257
|
setResolveAction(function (resolve) {
|
|
238
258
|
if (timer) {
|
|
259
|
+
clearIntervalForCountDown();
|
|
239
260
|
setDialogForTimer(false);
|
|
240
261
|
|
|
241
262
|
if (feedbackData.show) {
|
|
@@ -262,7 +283,7 @@ var ImageClickWrapperComponent = function ImageClickWrapperComponent(props) {
|
|
|
262
283
|
}
|
|
263
284
|
}, 4000);
|
|
264
285
|
});
|
|
265
|
-
}, [setResolveAction, emitResolve, playSound, timer, feedbackData.show, clearListenerForActualDate]);
|
|
286
|
+
}, [setResolveAction, emitResolve, playSound, timer, feedbackData.show, clearListenerForActualDate, clearIntervalForCountDown]);
|
|
266
287
|
(0, _react.useEffect)(function () {
|
|
267
288
|
if (finished) {
|
|
268
289
|
disableExit(true);
|
|
@@ -301,6 +322,7 @@ var ImageClickWrapperComponent = function ImageClickWrapperComponent(props) {
|
|
|
301
322
|
}
|
|
302
323
|
|
|
303
324
|
if (timer) {
|
|
325
|
+
clearIntervalForCountDown();
|
|
304
326
|
pauseTheCounter();
|
|
305
327
|
}
|
|
306
328
|
|
|
@@ -327,7 +349,11 @@ var ImageClickWrapperComponent = function ImageClickWrapperComponent(props) {
|
|
|
327
349
|
setClickedZones([]);
|
|
328
350
|
setDialogForTimer(true);
|
|
329
351
|
emitResetPuzzle();
|
|
352
|
+
} else if (areas.length === clickedZones.length || hasClickOnce && clickedZones.length > 0) {
|
|
353
|
+
clearIntervalForCountDown();
|
|
330
354
|
} else {
|
|
355
|
+
setCountDownTime(remainingTime.current * 0.001);
|
|
356
|
+
startCountDown();
|
|
331
357
|
listenerForActualDate();
|
|
332
358
|
}
|
|
333
359
|
}
|
|
@@ -342,7 +368,7 @@ var ImageClickWrapperComponent = function ImageClickWrapperComponent(props) {
|
|
|
342
368
|
rewards: []
|
|
343
369
|
});
|
|
344
370
|
});
|
|
345
|
-
}, [
|
|
371
|
+
}, [timer, timeExpired, handleFinish, feedbackData.rewards, feedbackData.success, playSound, areas.length, clickedZones.length, hasClickOnce, emitResetPuzzle, clearIntervalForCountDown, startCountDown, listenerForActualDate]);
|
|
346
372
|
|
|
347
373
|
var handleCorrectAreaClick = function handleCorrectAreaClick(area) {
|
|
348
374
|
if (!clickedZones.some(function (zone) {
|
|
@@ -381,6 +407,7 @@ var ImageClickWrapperComponent = function ImageClickWrapperComponent(props) {
|
|
|
381
407
|
});
|
|
382
408
|
|
|
383
409
|
if (timer) {
|
|
410
|
+
clearIntervalForCountDown();
|
|
384
411
|
pauseTheCounter();
|
|
385
412
|
}
|
|
386
413
|
}
|
|
@@ -394,6 +421,10 @@ var ImageClickWrapperComponent = function ImageClickWrapperComponent(props) {
|
|
|
394
421
|
};
|
|
395
422
|
|
|
396
423
|
var createStartAndEndDate = (0, _react.useCallback)(function () {
|
|
424
|
+
clearIntervalForCountDown();
|
|
425
|
+
setCountDownTime(timer);
|
|
426
|
+
startCountDown();
|
|
427
|
+
|
|
397
428
|
if (!popupCounterVisible.current && firstTryForFrame) {
|
|
398
429
|
emitOpenPopupCounterInfo();
|
|
399
430
|
}
|
|
@@ -402,7 +433,7 @@ var ImageClickWrapperComponent = function ImageClickWrapperComponent(props) {
|
|
|
402
433
|
startDate.current = Date.now();
|
|
403
434
|
finalDate.current = startDate.current + timer * 1000;
|
|
404
435
|
listenerForActualDate();
|
|
405
|
-
}, [
|
|
436
|
+
}, [clearIntervalForCountDown, timer, startCountDown, firstTryForFrame, listenerForActualDate, emitOpenPopupCounterInfo]);
|
|
406
437
|
(0, _react.useEffect)(function () {
|
|
407
438
|
// start automatically the time
|
|
408
439
|
if (timer && slideNumber > 0) {
|
|
@@ -438,6 +469,8 @@ var ImageClickWrapperComponent = function ImageClickWrapperComponent(props) {
|
|
|
438
469
|
retry: firstTryForFrame || puzzlesAutoCompleted[slideNumber - 1],
|
|
439
470
|
translate: translate,
|
|
440
471
|
onInit: createStartAndEndDate
|
|
472
|
+
}) : null, timer ? /*#__PURE__*/_react.default.createElement(_CountDown.default, {
|
|
473
|
+
time: countDownTime
|
|
441
474
|
}) : null);
|
|
442
475
|
};
|
|
443
476
|
|
|
@@ -23,6 +23,18 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
23
23
|
|
|
24
24
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
25
25
|
|
|
26
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
27
|
+
|
|
28
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
29
|
+
|
|
30
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
31
|
+
|
|
32
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
33
|
+
|
|
34
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
35
|
+
|
|
36
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
37
|
+
|
|
26
38
|
var ICONS = {
|
|
27
39
|
image: 'image-icon',
|
|
28
40
|
video: 'video-icon',
|
|
@@ -47,6 +59,10 @@ var Visor = function Visor(_ref) {
|
|
|
47
59
|
soundActions = _ref.soundActions;
|
|
48
60
|
var fileId = file.fileId;
|
|
49
61
|
var url = ((_file$document = file.document) === null || _file$document === void 0 ? void 0 : _file$document.url) || '';
|
|
62
|
+
|
|
63
|
+
var _soundActions = _slicedToArray(soundActions, 1),
|
|
64
|
+
playSound = _soundActions[0];
|
|
65
|
+
|
|
50
66
|
var COMPONENTS = {
|
|
51
67
|
image: {
|
|
52
68
|
component: _Image.default,
|
|
@@ -105,6 +121,7 @@ var Visor = function Visor(_ref) {
|
|
|
105
121
|
className: "puzzle--terminal__visor"
|
|
106
122
|
}, /*#__PURE__*/_react.default.createElement(_FeedbackComponent.default, {
|
|
107
123
|
shortText: true,
|
|
124
|
+
playSound: playSound,
|
|
108
125
|
success: fileId === solutionId,
|
|
109
126
|
text: fileId === solutionId ? info.solution.right.desc : info.solution.wrong.desc,
|
|
110
127
|
functionOnClose: fileId === solutionId ? resolvePuzzle : backFile,
|
|
@@ -134,7 +134,7 @@ var Container = function Container(_ref) {
|
|
|
134
134
|
className: "test--questions__count"
|
|
135
135
|
}, (0, _LangIsRtl.default)() ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, currentQuestionId + 1, "/", questions.length, " ", /*#__PURE__*/_react.default.createElement("span", null, translate('tests.question'))) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("span", null, translate('tests.question')), " ", currentQuestionId + 1, "/", questions.length)), time >= 0 ? /*#__PURE__*/_react.default.createElement("div", {
|
|
136
136
|
dir: "ltr",
|
|
137
|
-
className: "
|
|
137
|
+
className: "count-down ".concat(time < 10 ? 'count-down--finalseconds' : '')
|
|
138
138
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
139
139
|
id: "test-time"
|
|
140
140
|
}, minutes < 10 ? "0".concat(minutes) : minutes, " : ", seconds < 10 ? "0".concat(seconds) : seconds)) : null), /*#__PURE__*/_react.default.createElement(_Questions.default, {
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@gamelearn/arcade-components",
|
|
3
3
|
"author": "Gamelearn",
|
|
4
4
|
"license": "unlicense",
|
|
5
|
-
"version": "1.
|
|
5
|
+
"version": "1.28.1",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"files": [
|
|
8
8
|
"dist",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"url": "https://github.com/gamelearn/arcade-components"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@gamelearn/arcade-styles": "0.
|
|
16
|
+
"@gamelearn/arcade-styles": "0.14.0",
|
|
17
17
|
"@gamelearn/arcade-three-core": "1.14.5",
|
|
18
18
|
"@react-three/drei": "9.4.3",
|
|
19
19
|
"@react-three/fiber": "8.0.17",
|