@gamelearn/arcade-components 1.4.30-fix1 → 1.4.30
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/cards-selector-puzzle-component/components/Board/index.js +17 -27
- package/dist/components/cards-selector-puzzle-component/components/CardsSelectorPuzzleComponent.js +23 -47
- package/dist/components/drag-item-puzzle-component/components/DragItemPuzzleComponent.js +13 -15
- package/dist/components/pattern-component/components/PatternComponent.js +12 -23
- package/package.json +2 -2
|
@@ -34,13 +34,11 @@ var Board = function Board(_ref) {
|
|
|
34
34
|
currentOrder = _ref.currentOrder,
|
|
35
35
|
setCurrentOrder = _ref.setCurrentOrder,
|
|
36
36
|
handleError = _ref.handleError,
|
|
37
|
-
endPuzzle = _ref.endPuzzle,
|
|
38
37
|
feedbackIsShown = _ref.feedbackIsShown,
|
|
39
38
|
resolvePuzzle = _ref.resolvePuzzle,
|
|
40
39
|
soundActions = _ref.soundActions,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
forceFlipCard = _ref.forceFlipCard;
|
|
40
|
+
onFinish = _ref.onFinish,
|
|
41
|
+
handleSuccess = _ref.handleSuccess;
|
|
44
42
|
|
|
45
43
|
var _useState = (0, _react.useState)(Array(cards.length).fill(false)),
|
|
46
44
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -57,6 +55,11 @@ var Board = function Board(_ref) {
|
|
|
57
55
|
correctCards = _useState6[0],
|
|
58
56
|
setCorrectCards = _useState6[1];
|
|
59
57
|
|
|
58
|
+
var _useState7 = (0, _react.useState)(false),
|
|
59
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
60
|
+
finished = _useState8[0],
|
|
61
|
+
setFinished = _useState8[1];
|
|
62
|
+
|
|
60
63
|
var _soundActions = _slicedToArray(soundActions, 1),
|
|
61
64
|
play = _soundActions[0];
|
|
62
65
|
|
|
@@ -66,14 +69,6 @@ var Board = function Board(_ref) {
|
|
|
66
69
|
var isOrderBased = cards.filter(function (card) {
|
|
67
70
|
return card.order;
|
|
68
71
|
}).length > 0;
|
|
69
|
-
var flipTimer;
|
|
70
|
-
(0, _react.useEffect)(function () {
|
|
71
|
-
if (forceFlipCard) {
|
|
72
|
-
setForceFlipCard(false);
|
|
73
|
-
reset();
|
|
74
|
-
clearTimeout(flipTimer);
|
|
75
|
-
}
|
|
76
|
-
}, [flipTimer, forceFlipCard, reset, setForceFlipCard]);
|
|
77
72
|
var reset = (0, _react.useCallback)(function () {
|
|
78
73
|
setFlipped(Array(cards.length).fill(false)); // reset it to the original length
|
|
79
74
|
|
|
@@ -83,9 +78,9 @@ var Board = function Board(_ref) {
|
|
|
83
78
|
}, [cards.length, setCurrentOrder]);
|
|
84
79
|
|
|
85
80
|
var timedReset = function timedReset() {
|
|
86
|
-
|
|
81
|
+
setTimeout(function () {
|
|
87
82
|
reset();
|
|
88
|
-
},
|
|
83
|
+
}, 1000);
|
|
89
84
|
};
|
|
90
85
|
|
|
91
86
|
function flipACard(index) {
|
|
@@ -94,12 +89,6 @@ var Board = function Board(_ref) {
|
|
|
94
89
|
setFlipped(tempFlipped);
|
|
95
90
|
}
|
|
96
91
|
|
|
97
|
-
var timedFlipped = function timedFlipped(index) {
|
|
98
|
-
setTimeout(function () {
|
|
99
|
-
flipACard(index);
|
|
100
|
-
}, 3000);
|
|
101
|
-
};
|
|
102
|
-
|
|
103
92
|
var flipAllCorrect = (0, _react.useCallback)(function () {
|
|
104
93
|
var arrayToFlip = [];
|
|
105
94
|
cards.forEach(function (card, index) {
|
|
@@ -116,10 +105,11 @@ var Board = function Board(_ref) {
|
|
|
116
105
|
}, [flipAllCorrect, resolvePuzzle]);
|
|
117
106
|
(0, _react.useEffect)(function () {
|
|
118
107
|
if (correctCards === numberOfCorrectCards && numberOfCorrectCards > 0) {
|
|
119
|
-
|
|
108
|
+
onFinish();
|
|
109
|
+
setFinished(true);
|
|
120
110
|
setCorrectCards(0);
|
|
121
111
|
}
|
|
122
|
-
}, [correctCards,
|
|
112
|
+
}, [correctCards, onFinish, numberOfCorrectCards]);
|
|
123
113
|
|
|
124
114
|
var handleCorrect = function handleCorrect(index) {
|
|
125
115
|
flipACard(index);
|
|
@@ -128,6 +118,8 @@ var Board = function Board(_ref) {
|
|
|
128
118
|
};
|
|
129
119
|
|
|
130
120
|
var _handleClick = function handleClick(index) {
|
|
121
|
+
if (finished) return;
|
|
122
|
+
|
|
131
123
|
if (!feedbackIsShown) {
|
|
132
124
|
play('click-ui');
|
|
133
125
|
|
|
@@ -156,8 +148,8 @@ var Board = function Board(_ref) {
|
|
|
156
148
|
|
|
157
149
|
// fails and resets
|
|
158
150
|
handleError(((_cards$index2 = cards[index]) === null || _cards$index2 === void 0 ? void 0 : _cards$index2.id) || null);
|
|
151
|
+
timedReset();
|
|
159
152
|
flipACard(index);
|
|
160
|
-
timedFlipped();
|
|
161
153
|
}
|
|
162
154
|
}
|
|
163
155
|
};
|
|
@@ -182,15 +174,13 @@ var Board = function Board(_ref) {
|
|
|
182
174
|
Board.defaultProps = {
|
|
183
175
|
setCurrentOrder: function setCurrentOrder() {},
|
|
184
176
|
handleError: function handleError() {},
|
|
185
|
-
|
|
177
|
+
onFinish: function onFinish() {},
|
|
186
178
|
handleSuccess: function handleSuccess() {},
|
|
187
|
-
setForceFlipCard: function setForceFlipCard() {},
|
|
188
179
|
documentsDict: {},
|
|
189
180
|
cards: [],
|
|
190
181
|
currentOrder: 1,
|
|
191
182
|
resolvePuzzle: false,
|
|
192
|
-
feedbackIsShown: false
|
|
193
|
-
forceFlipCard: false
|
|
183
|
+
feedbackIsShown: false
|
|
194
184
|
};
|
|
195
185
|
var _default = Board;
|
|
196
186
|
exports.default = _default;
|
package/dist/components/cards-selector-puzzle-component/components/CardsSelectorPuzzleComponent.js
CHANGED
|
@@ -40,6 +40,8 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
|
|
|
40
40
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
41
41
|
|
|
42
42
|
var CardsSelectorPuzzleComponent = function CardsSelectorPuzzleComponent(_ref) {
|
|
43
|
+
var _info$solution2;
|
|
44
|
+
|
|
43
45
|
var emitEvent = _ref.emitEvent,
|
|
44
46
|
info = _ref.info,
|
|
45
47
|
cards = _ref.cards,
|
|
@@ -92,11 +94,6 @@ var CardsSelectorPuzzleComponent = function CardsSelectorPuzzleComponent(_ref) {
|
|
|
92
94
|
var _soundActions = _slicedToArray(soundActions, 1),
|
|
93
95
|
playSound = _soundActions[0];
|
|
94
96
|
|
|
95
|
-
var _useState17 = (0, _react.useState)(false),
|
|
96
|
-
_useState18 = _slicedToArray(_useState17, 2),
|
|
97
|
-
forceFlipCard = _useState18[0],
|
|
98
|
-
setForceFlipCard = _useState18[1];
|
|
99
|
-
|
|
100
97
|
var translate = function translate(id) {
|
|
101
98
|
return emitEvent({
|
|
102
99
|
type: 'translate',
|
|
@@ -118,24 +115,14 @@ var CardsSelectorPuzzleComponent = function CardsSelectorPuzzleComponent(_ref) {
|
|
|
118
115
|
payload: rewardsData
|
|
119
116
|
});
|
|
120
117
|
}, [emitEvent]);
|
|
121
|
-
|
|
122
|
-
var endPuzzle = function endPuzzle() {
|
|
118
|
+
var endPuzzle = (0, _react.useCallback)(function () {
|
|
123
119
|
var _info$solution, _specificFeedbacks$co;
|
|
124
120
|
|
|
125
121
|
emitEvent({
|
|
126
122
|
type: 'hidePuzzleButtons',
|
|
127
123
|
payload: true
|
|
128
124
|
});
|
|
129
|
-
|
|
130
|
-
if (info.solution.right.desc) {
|
|
131
|
-
setFeedBackText(info.solution.right.desc);
|
|
132
|
-
setFeedbackResult(true);
|
|
133
|
-
setFeedbackIsShown(true);
|
|
134
|
-
} else {
|
|
135
|
-
setFeedbackResult(true);
|
|
136
|
-
setFeedbackIsShown(true);
|
|
137
|
-
setFinished(true);
|
|
138
|
-
}
|
|
125
|
+
setFeedbackResult(true);
|
|
139
126
|
|
|
140
127
|
var _info$solution$right = info === null || info === void 0 ? void 0 : (_info$solution = info.solution) === null || _info$solution === void 0 ? void 0 : _info$solution.right,
|
|
141
128
|
rewards = _info$solution$right.rewards;
|
|
@@ -144,16 +131,16 @@ var CardsSelectorPuzzleComponent = function CardsSelectorPuzzleComponent(_ref) {
|
|
|
144
131
|
return spReward.rewards;
|
|
145
132
|
}).flat()) || [];
|
|
146
133
|
var rewardsData = [].concat(_toConsumableArray(accRewards), _toConsumableArray(rewards), _toConsumableArray(specificRewards));
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
134
|
+
playSound('score');
|
|
135
|
+
closeFeedbackAndShowPoints(rewardsData);
|
|
136
|
+
}, [accRewards, closeFeedbackAndShowPoints, emitEvent, info === null || info === void 0 ? void 0 : (_info$solution2 = info.solution) === null || _info$solution2 === void 0 ? void 0 : _info$solution2.right, playSound, specificFeedbacks === null || specificFeedbacks === void 0 ? void 0 : specificFeedbacks.correctFeedbacks]);
|
|
137
|
+
|
|
138
|
+
var onFinish = function onFinish() {
|
|
139
|
+
setFinished(true);
|
|
151
140
|
};
|
|
152
141
|
|
|
153
142
|
var handleFeedbackFuncionOnClose = function handleFeedbackFuncionOnClose() {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
if (feedbackResult) {
|
|
143
|
+
if (feedbackResult || finished) {
|
|
157
144
|
endPuzzle();
|
|
158
145
|
} else {
|
|
159
146
|
setFeedbackResult(false);
|
|
@@ -166,10 +153,6 @@ var CardsSelectorPuzzleComponent = function CardsSelectorPuzzleComponent(_ref) {
|
|
|
166
153
|
}
|
|
167
154
|
|
|
168
155
|
setFeedBackText('');
|
|
169
|
-
|
|
170
|
-
if (!feedbackResult && !isCorrect) {
|
|
171
|
-
setForceFlipCard(true);
|
|
172
|
-
}
|
|
173
156
|
};
|
|
174
157
|
|
|
175
158
|
var handleSuccessPick = function handleSuccessPick(cardId) {
|
|
@@ -182,23 +165,17 @@ var CardsSelectorPuzzleComponent = function CardsSelectorPuzzleComponent(_ref) {
|
|
|
182
165
|
|
|
183
166
|
if (pickedCard !== null && pickedCard !== void 0 && pickedCard.desc) {
|
|
184
167
|
setFeedBackText(pickedCard.desc);
|
|
185
|
-
} else {
|
|
186
|
-
setTimeout(function () {
|
|
187
|
-
playSound('score');
|
|
188
|
-
handleFeedbackFuncionOnClose(true);
|
|
189
|
-
emitEvent({
|
|
190
|
-
type: 'hidePuzzleButtons',
|
|
191
|
-
payload: false
|
|
192
|
-
});
|
|
193
|
-
}, 2000);
|
|
194
168
|
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
emitEvent({
|
|
198
|
-
type: 'hidePuzzleButtons',
|
|
199
|
-
payload: true
|
|
200
|
-
});
|
|
169
|
+
} else if (info.solution.right.desc) {
|
|
170
|
+
setFeedBackText(info.solution.right.desc);
|
|
201
171
|
}
|
|
172
|
+
|
|
173
|
+
playSound('score');
|
|
174
|
+
setFeedbackIsShown(true);
|
|
175
|
+
emitEvent({
|
|
176
|
+
type: 'hidePuzzleButtons',
|
|
177
|
+
payload: true
|
|
178
|
+
});
|
|
202
179
|
};
|
|
203
180
|
|
|
204
181
|
var handleError = function handleError(cardId) {
|
|
@@ -283,17 +260,16 @@ var CardsSelectorPuzzleComponent = function CardsSelectorPuzzleComponent(_ref) {
|
|
|
283
260
|
setCurrentOrder: setCurrentOrder,
|
|
284
261
|
currentOrder: currentOrder,
|
|
285
262
|
cards: cards,
|
|
286
|
-
|
|
263
|
+
onFinish: onFinish,
|
|
287
264
|
handleError: handleError,
|
|
288
265
|
feedbackIsShown: feedbackIsShown,
|
|
289
266
|
resolvePuzzle: resolvePuzzle,
|
|
290
267
|
soundActions: soundActions,
|
|
291
|
-
handleSuccess: handleSuccessPick
|
|
292
|
-
forceFlipCard: forceFlipCard,
|
|
293
|
-
setForceFlipCard: setForceFlipCard
|
|
268
|
+
handleSuccess: handleSuccessPick
|
|
294
269
|
})), feedbackIsShown && /*#__PURE__*/_react.default.createElement(_feedbackComponent.default, {
|
|
295
270
|
success: feedbackResult || rightPick,
|
|
296
271
|
text: feedBackText,
|
|
272
|
+
hasTimeout: !feedBackText,
|
|
297
273
|
translate: translate,
|
|
298
274
|
functionOnClose: handleFeedbackFuncionOnClose
|
|
299
275
|
}));
|
|
@@ -264,21 +264,19 @@ var DragItemPuzzleComponent = function DragItemPuzzleComponent(_ref) {
|
|
|
264
264
|
currentImage.src = imageUrl;
|
|
265
265
|
|
|
266
266
|
currentImage.onload = function () {
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
setImageLoaded(true);
|
|
281
|
-
}
|
|
267
|
+
layerConfig.current = {
|
|
268
|
+
x: canvas.current.clientWidth / 2,
|
|
269
|
+
y: canvas.current.clientHeight / 2,
|
|
270
|
+
width: currentImage.width,
|
|
271
|
+
height: currentImage.height,
|
|
272
|
+
offsetX: currentImage.width / 2,
|
|
273
|
+
offsetY: currentImage.height / 2,
|
|
274
|
+
scale: {
|
|
275
|
+
x: Math.min(canvas.current.clientWidth / currentImage.width, canvas.current.clientHeight / currentImage.height),
|
|
276
|
+
y: Math.min(canvas.current.clientWidth / currentImage.width, canvas.current.clientHeight / currentImage.height)
|
|
277
|
+
}
|
|
278
|
+
};
|
|
279
|
+
setImageLoaded(true);
|
|
282
280
|
};
|
|
283
281
|
|
|
284
282
|
setShowTooltip(true);
|
|
@@ -42,42 +42,31 @@ var PatternComponent = function PatternComponent(_ref) {
|
|
|
42
42
|
emitEvent({
|
|
43
43
|
type: 'emitSavePattern',
|
|
44
44
|
payload: {
|
|
45
|
-
imgId: img.
|
|
45
|
+
imgId: img.imgId,
|
|
46
46
|
name: name,
|
|
47
|
-
viewed: true
|
|
48
|
-
url: imgUrl,
|
|
49
|
-
type: 'pattern'
|
|
47
|
+
viewed: true
|
|
50
48
|
}
|
|
51
49
|
});
|
|
52
50
|
};
|
|
53
51
|
|
|
54
52
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
55
|
-
className: viewed ? 'notes--results' : 'readings--container
|
|
53
|
+
className: viewed ? 'notes--results' : 'readings--container'
|
|
56
54
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
57
|
-
className: viewed ? 'notes--results__text' : '
|
|
58
|
-
},
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}, "Modelo"), /*#__PURE__*/_react.default.createElement("button", {
|
|
55
|
+
className: viewed ? 'notes--results__text' : 'readings readings--image'
|
|
56
|
+
}, imgUrl && /*#__PURE__*/_react.default.createElement("img", {
|
|
57
|
+
src: imgUrl,
|
|
58
|
+
alt: "pattern"
|
|
59
|
+
}), !viewed ? /*#__PURE__*/_react.default.createElement("div", {
|
|
60
|
+
className: "position--absolute top right"
|
|
61
|
+
}, /*#__PURE__*/_react.default.createElement("button", {
|
|
65
62
|
type: "button",
|
|
66
|
-
className: "
|
|
63
|
+
className: "gat--btn__round",
|
|
67
64
|
onClick: function onClick() {
|
|
68
65
|
return close();
|
|
69
66
|
}
|
|
70
67
|
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
71
68
|
className: "icon-close"
|
|
72
|
-
})))
|
|
73
|
-
className: "pattern__figure"
|
|
74
|
-
}, imgUrl && /*#__PURE__*/_react.default.createElement("img", {
|
|
75
|
-
src: imgUrl,
|
|
76
|
-
alt: "pattern"
|
|
77
|
-
}))) : /*#__PURE__*/_react.default.createElement("div", null, imgUrl && /*#__PURE__*/_react.default.createElement("img", {
|
|
78
|
-
src: imgUrl,
|
|
79
|
-
alt: "pattern"
|
|
80
|
-
}))));
|
|
69
|
+
}))) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null)));
|
|
81
70
|
};
|
|
82
71
|
|
|
83
72
|
var _default = PatternComponent;
|
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.4.30
|
|
5
|
+
"version": "1.4.30",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"files": [
|
|
8
8
|
"dist",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"@babel/eslint-parser": "^7.15.8",
|
|
65
65
|
"@babel/preset-env": "7.12.11",
|
|
66
66
|
"@babel/preset-react": "7.12.10",
|
|
67
|
-
"@gamelearn/arcade-styles": "0.5.
|
|
67
|
+
"@gamelearn/arcade-styles": "0.5.10",
|
|
68
68
|
"@gamelearn/version": "^1.3.1",
|
|
69
69
|
"@react-three/test-renderer": "6.0.6",
|
|
70
70
|
"@storybook/addon-actions": "6.1.11",
|