@gamelearn/arcade-components 0.19.0 → 0.19.2
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/CardsSelectorPuzzleComponent.js +4 -4
- package/dist/components/feedback-component/components/FeedbackComponent.js +15 -0
- package/dist/components/index.js +8 -0
- package/dist/components/text-click-puzzle-component/components/TextClickPuzzleComponent.js +389 -0
- package/dist/components/text-click-puzzle-component/index.js +13 -0
- package/dist/components/text-click-puzzle-component/mocks/mockForStory.js +254 -0
- package/dist/components/text-click-puzzle-component/utils/index.js +76 -0
- package/dist/components/writer-puzzle-component/mocks/mockForStory.js +179 -2
- package/package.json +2 -2
package/dist/components/cards-selector-puzzle-component/components/CardsSelectorPuzzleComponent.js
CHANGED
|
@@ -124,14 +124,14 @@ var CardsSelectorPuzzleComponent = function CardsSelectorPuzzleComponent(_ref) {
|
|
|
124
124
|
var rewards = info.solution.right.rewards;
|
|
125
125
|
var rewardsData = [].concat(_toConsumableArray(accRewards), _toConsumableArray(rewards));
|
|
126
126
|
playSound('score');
|
|
127
|
-
emitEvent({
|
|
128
|
-
type: 'addPoints',
|
|
129
|
-
payload: _toConsumableArray(rewardsData)
|
|
130
|
-
});
|
|
131
127
|
emitEvent({
|
|
132
128
|
type: 'hidePuzzleButtons',
|
|
133
129
|
payload: false
|
|
134
130
|
});
|
|
131
|
+
emitEvent({
|
|
132
|
+
type: 'addPoints',
|
|
133
|
+
payload: _toConsumableArray(rewardsData)
|
|
134
|
+
});
|
|
135
135
|
} else {
|
|
136
136
|
setFeedbackResult(false);
|
|
137
137
|
disableExit(false);
|
|
@@ -34,6 +34,8 @@ var FeedbackComponent = function FeedbackComponent(_ref) {
|
|
|
34
34
|
secondText = _ref.secondText,
|
|
35
35
|
translate = _ref.translate,
|
|
36
36
|
shortText = _ref.shortText,
|
|
37
|
+
hasTimeout = _ref.hasTimeout,
|
|
38
|
+
delay = _ref.delay,
|
|
37
39
|
simpleClose = _ref.simpleClose;
|
|
38
40
|
|
|
39
41
|
var _useState = (0, _react.useState)(),
|
|
@@ -58,6 +60,17 @@ var FeedbackComponent = function FeedbackComponent(_ref) {
|
|
|
58
60
|
if (timerForShowExplain) clearTimeout(timerForShowExplain);
|
|
59
61
|
};
|
|
60
62
|
}, [playSound, success, shortText, text]);
|
|
63
|
+
(0, _react.useEffect)(function () {
|
|
64
|
+
var timeout;
|
|
65
|
+
|
|
66
|
+
if (hasTimeout && functionOnClose) {
|
|
67
|
+
timeout = setTimeout(functionOnClose, delay);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return function () {
|
|
71
|
+
if (timeout) clearTimeout(timeout);
|
|
72
|
+
};
|
|
73
|
+
}, [delay, functionOnClose, hasTimeout]);
|
|
61
74
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
62
75
|
className: "feedback-layer ".concat(explain ? 'feedback-layer--withexplain' : '')
|
|
63
76
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -93,6 +106,8 @@ var FeedbackComponent = function FeedbackComponent(_ref) {
|
|
|
93
106
|
|
|
94
107
|
FeedbackComponent.defaultProps = {
|
|
95
108
|
text: '',
|
|
109
|
+
hasTimeout: false,
|
|
110
|
+
delay: 3000,
|
|
96
111
|
success: false
|
|
97
112
|
};
|
|
98
113
|
var _default = FeedbackComponent;
|
package/dist/components/index.js
CHANGED
|
@@ -203,6 +203,12 @@ Object.defineProperty(exports, "PatternComponent", {
|
|
|
203
203
|
return _patternComponent.default;
|
|
204
204
|
}
|
|
205
205
|
});
|
|
206
|
+
Object.defineProperty(exports, "TextClickPuzzleComponent", {
|
|
207
|
+
enumerable: true,
|
|
208
|
+
get: function get() {
|
|
209
|
+
return _textClickPuzzleComponent.default;
|
|
210
|
+
}
|
|
211
|
+
});
|
|
206
212
|
|
|
207
213
|
var _scene = _interopRequireDefault(require("./arcade-render/scene"));
|
|
208
214
|
|
|
@@ -268,6 +274,8 @@ var _autoEvaluationComponent = _interopRequireDefault(require("./auto-evaluation
|
|
|
268
274
|
|
|
269
275
|
var _patternComponent = _interopRequireDefault(require("./pattern-component"));
|
|
270
276
|
|
|
277
|
+
var _textClickPuzzleComponent = _interopRequireDefault(require("./text-click-puzzle-component"));
|
|
278
|
+
|
|
271
279
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
|
272
280
|
|
|
273
281
|
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; }
|
|
@@ -0,0 +1,389 @@
|
|
|
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 _feedbackComponent = _interopRequireDefault(require("../../feedback-component"));
|
|
13
|
+
|
|
14
|
+
var _htmlReactParser = _interopRequireDefault(require("html-react-parser"));
|
|
15
|
+
|
|
16
|
+
var _utils = require("../utils");
|
|
17
|
+
|
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
+
|
|
20
|
+
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
|
21
|
+
|
|
22
|
+
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; }
|
|
23
|
+
|
|
24
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
25
|
+
|
|
26
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
27
|
+
|
|
28
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
29
|
+
|
|
30
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
31
|
+
|
|
32
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
33
|
+
|
|
34
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
35
|
+
|
|
36
|
+
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; }
|
|
37
|
+
|
|
38
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
39
|
+
|
|
40
|
+
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."); }
|
|
41
|
+
|
|
42
|
+
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); }
|
|
43
|
+
|
|
44
|
+
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; }
|
|
45
|
+
|
|
46
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr && (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; }
|
|
47
|
+
|
|
48
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
49
|
+
|
|
50
|
+
var TextClickPuzzleComponent = function TextClickPuzzleComponent(_ref) {
|
|
51
|
+
var emitEvent = _ref.emitEvent,
|
|
52
|
+
showFrames = _ref.showFrames,
|
|
53
|
+
styles = _ref.styles,
|
|
54
|
+
list = _ref.list,
|
|
55
|
+
soundActions = _ref.soundActions,
|
|
56
|
+
description = _ref.description,
|
|
57
|
+
info = _ref.info,
|
|
58
|
+
setInfo = _ref.setInfo;
|
|
59
|
+
|
|
60
|
+
var _useState = (0, _react.useState)({
|
|
61
|
+
result: null,
|
|
62
|
+
show: false,
|
|
63
|
+
text: '',
|
|
64
|
+
timeout: false
|
|
65
|
+
}),
|
|
66
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
67
|
+
feedbackData = _useState2[0],
|
|
68
|
+
setFeedbackData = _useState2[1];
|
|
69
|
+
|
|
70
|
+
var _soundActions = _slicedToArray(soundActions, 1),
|
|
71
|
+
playSound = _soundActions[0];
|
|
72
|
+
|
|
73
|
+
var _useState3 = (0, _react.useState)(0),
|
|
74
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
75
|
+
currentSlide = _useState4[0],
|
|
76
|
+
setCurrentSlide = _useState4[1];
|
|
77
|
+
|
|
78
|
+
var _useState5 = (0, _react.useState)(0),
|
|
79
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
80
|
+
numberAllCorrectFragments = _useState6[0],
|
|
81
|
+
setNumberAllCorrectFragments = _useState6[1];
|
|
82
|
+
|
|
83
|
+
var _useState7 = (0, _react.useState)(0),
|
|
84
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
85
|
+
correctTextFragmentsAccumulated = _useState8[0],
|
|
86
|
+
setCorrectTextFragmentsAccumulated = _useState8[1];
|
|
87
|
+
|
|
88
|
+
var correctTextFragmentsPartial = (0, _react.useRef)(0);
|
|
89
|
+
var accRewards = (0, _react.useRef)([]);
|
|
90
|
+
|
|
91
|
+
var _useState9 = (0, _react.useState)(0),
|
|
92
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
93
|
+
orderCounter = _useState10[0],
|
|
94
|
+
setOrderCounter = _useState10[1];
|
|
95
|
+
|
|
96
|
+
var _useState11 = (0, _react.useState)(),
|
|
97
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
98
|
+
transitionToNextSlide = _useState12[0],
|
|
99
|
+
setTransitionToNextSlide = _useState12[1];
|
|
100
|
+
|
|
101
|
+
var translate = (0, _react.useCallback)(function (id) {
|
|
102
|
+
return emitEvent({
|
|
103
|
+
type: 'translate',
|
|
104
|
+
payload: id
|
|
105
|
+
});
|
|
106
|
+
}, [emitEvent]);
|
|
107
|
+
var parsedText = (0, _react.useRef)(null);
|
|
108
|
+
var onHoverMark = (0, _react.useCallback)(function (id) {
|
|
109
|
+
for (var i = 0; i < list[currentSlide].correctTexts.length; i++) {
|
|
110
|
+
if (id === list[currentSlide].correctTexts[i].id) {
|
|
111
|
+
var allDataTextIds = document.querySelectorAll("[data-text-id=\"".concat(id, "\"]"));
|
|
112
|
+
allDataTextIds.forEach(function (el) {
|
|
113
|
+
return el.classList.add('text-click__hover-correct');
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}, [currentSlide, list]);
|
|
118
|
+
var goForward = (0, _react.useCallback)(function () {
|
|
119
|
+
if (correctTextFragmentsPartial.current === list[currentSlide].correctTexts.length) {
|
|
120
|
+
setFeedbackData(function (prevState) {
|
|
121
|
+
return _objectSpread(_objectSpread({}, prevState), {}, {
|
|
122
|
+
result: false
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
correctTextFragmentsPartial.current = 0;
|
|
126
|
+
|
|
127
|
+
if (correctTextFragmentsAccumulated === numberAllCorrectFragments) {
|
|
128
|
+
var totalRewards = accRewards.current.reduce(function (acc, current) {
|
|
129
|
+
var existing = acc.findIndex(function (r) {
|
|
130
|
+
return r.id === current.id;
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
if (existing >= 0) {
|
|
134
|
+
acc[existing].points += current.points;
|
|
135
|
+
} else {
|
|
136
|
+
acc.push(current);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return acc;
|
|
140
|
+
}, []);
|
|
141
|
+
emitEvent({
|
|
142
|
+
type: 'addPoints',
|
|
143
|
+
payload: totalRewards
|
|
144
|
+
});
|
|
145
|
+
} else {
|
|
146
|
+
parsedText.current = null;
|
|
147
|
+
setCurrentSlide(currentSlide + 1);
|
|
148
|
+
setTransitionToNextSlide(true);
|
|
149
|
+
setTimeout(function () {
|
|
150
|
+
setTransitionToNextSlide(false);
|
|
151
|
+
}, 1200);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}, [correctTextFragmentsAccumulated, currentSlide, list, numberAllCorrectFragments, emitEvent]);
|
|
155
|
+
var handleFeedbackFuncionOnClose = (0, _react.useCallback)(function () {
|
|
156
|
+
emitEvent({
|
|
157
|
+
type: 'hidePuzzleButtons',
|
|
158
|
+
payload: false
|
|
159
|
+
});
|
|
160
|
+
goForward();
|
|
161
|
+
setFeedbackData(function (prevState) {
|
|
162
|
+
return _objectSpread(_objectSpread({}, prevState), {}, {
|
|
163
|
+
show: false,
|
|
164
|
+
text: ''
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
if (document.querySelector('.text-click__failed')) {
|
|
169
|
+
document.querySelector('.text-click__failed').classList.remove('text-click__failed');
|
|
170
|
+
}
|
|
171
|
+
}, [emitEvent, goForward]);
|
|
172
|
+
var handleCorrectClick = (0, _react.useCallback)(function (allDataTextIds, specificFeedback) {
|
|
173
|
+
var _list$currentSlide$in;
|
|
174
|
+
|
|
175
|
+
allDataTextIds.forEach(function (el) {
|
|
176
|
+
return el.classList.add('text-click__success');
|
|
177
|
+
});
|
|
178
|
+
setFeedbackData(function (prevState) {
|
|
179
|
+
return _objectSpread(_objectSpread({}, prevState), {}, {
|
|
180
|
+
result: 'success',
|
|
181
|
+
timeout: true
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
setCorrectTextFragmentsAccumulated(correctTextFragmentsAccumulated + 1);
|
|
185
|
+
correctTextFragmentsPartial.current += 1;
|
|
186
|
+
emitEvent({
|
|
187
|
+
type: 'hidePuzzleButtons',
|
|
188
|
+
payload: true
|
|
189
|
+
});
|
|
190
|
+
playSound('score'); // si tiene feedback general definido
|
|
191
|
+
|
|
192
|
+
if ((_list$currentSlide$in = list[currentSlide].info.solution.right) !== null && _list$currentSlide$in !== void 0 && _list$currentSlide$in.desc) {
|
|
193
|
+
accRewards.current = [].concat(_toConsumableArray(accRewards.current), _toConsumableArray(list[currentSlide].info.solution.right.rewards));
|
|
194
|
+
setFeedbackData(function (prevState) {
|
|
195
|
+
return _objectSpread(_objectSpread({}, prevState), {}, {
|
|
196
|
+
text: list[currentSlide].info.solution.right.desc,
|
|
197
|
+
timeout: false
|
|
198
|
+
});
|
|
199
|
+
});
|
|
200
|
+
} // si no tiene feedback general y tiene specificFeedbacks definido
|
|
201
|
+
else if (list[currentSlide].info.solution.right.desc === '' && specificFeedback !== null && specificFeedback !== void 0 && specificFeedback.desc) {
|
|
202
|
+
var _specificFeedback$rew;
|
|
203
|
+
|
|
204
|
+
accRewards.current = !!(specificFeedback !== null && specificFeedback !== void 0 && (_specificFeedback$rew = specificFeedback.rewards) !== null && _specificFeedback$rew !== void 0 && _specificFeedback$rew.length) ? [].concat(_toConsumableArray(accRewards.current), _toConsumableArray(specificFeedback === null || specificFeedback === void 0 ? void 0 : specificFeedback.rewards)) : _toConsumableArray(accRewards.current);
|
|
205
|
+
setFeedbackData(function (prevState) {
|
|
206
|
+
return _objectSpread(_objectSpread({}, prevState), {}, {
|
|
207
|
+
text: specificFeedback.desc,
|
|
208
|
+
timeout: false
|
|
209
|
+
});
|
|
210
|
+
});
|
|
211
|
+
} else {
|
|
212
|
+
accRewards.current = [].concat(_toConsumableArray(accRewards.current), _toConsumableArray(list[currentSlide].info.solution.right.rewards));
|
|
213
|
+
}
|
|
214
|
+
}, [correctTextFragmentsAccumulated, emitEvent, playSound, list, currentSlide]);
|
|
215
|
+
var handleIncorrectClick = (0, _react.useCallback)(function (allDataTextIds, specificFeedback) {
|
|
216
|
+
allDataTextIds.forEach(function (el) {
|
|
217
|
+
return el.classList.add('text-click__failed');
|
|
218
|
+
});
|
|
219
|
+
emitEvent({
|
|
220
|
+
type: 'hidePuzzleButtons',
|
|
221
|
+
payload: true
|
|
222
|
+
});
|
|
223
|
+
playSound('fail');
|
|
224
|
+
setFeedbackData(function (prevState) {
|
|
225
|
+
return _objectSpread(_objectSpread({}, prevState), {}, {
|
|
226
|
+
result: null,
|
|
227
|
+
timeout: true
|
|
228
|
+
});
|
|
229
|
+
}); // si tiene feedback general definido
|
|
230
|
+
|
|
231
|
+
if (list[currentSlide].info.solution.wrong.desc !== '') {
|
|
232
|
+
accRewards.current = [].concat(_toConsumableArray(accRewards.current), _toConsumableArray(list[currentSlide].info.solution.wrong.rewards));
|
|
233
|
+
setFeedbackData(function (prevState) {
|
|
234
|
+
return _objectSpread(_objectSpread({}, prevState), {}, {
|
|
235
|
+
text: list[currentSlide].info.solution.wrong.desc,
|
|
236
|
+
timeout: false
|
|
237
|
+
});
|
|
238
|
+
});
|
|
239
|
+
} // si no tiene feedback general y tiene specificFeedbacks definido
|
|
240
|
+
else if (list[currentSlide].info.solution.wrong.desc === '' && specificFeedback.desc !== '') {
|
|
241
|
+
accRewards.current = [].concat(_toConsumableArray(accRewards.current), _toConsumableArray(specificFeedback === null || specificFeedback === void 0 ? void 0 : specificFeedback.rewards)); // accRewards.current = [...accRewards.current, ...feedbackIncorrect.rewards];
|
|
242
|
+
|
|
243
|
+
setFeedbackData(function (prevState) {
|
|
244
|
+
return _objectSpread(_objectSpread({}, prevState), {}, {
|
|
245
|
+
text: specificFeedback.desc,
|
|
246
|
+
timeout: false
|
|
247
|
+
});
|
|
248
|
+
});
|
|
249
|
+
} else {
|
|
250
|
+
accRewards.current = [].concat(_toConsumableArray(accRewards.current), _toConsumableArray(list[currentSlide].info.solution.wrong.rewards));
|
|
251
|
+
}
|
|
252
|
+
}, [emitEvent, playSound, list, currentSlide]);
|
|
253
|
+
var onClickMark = (0, _react.useCallback)(function (e, id) {
|
|
254
|
+
var _list$currentSlide, _list$currentSlide$sp, _list$currentSlide2, _list$currentSlide2$s;
|
|
255
|
+
|
|
256
|
+
setFeedbackData(function (prevState) {
|
|
257
|
+
return _objectSpread(_objectSpread({}, prevState), {}, {
|
|
258
|
+
show: true
|
|
259
|
+
});
|
|
260
|
+
});
|
|
261
|
+
e.stopPropagation();
|
|
262
|
+
var allDataTextIds = document.querySelectorAll("[data-text-id=\"".concat(id, "\"]"));
|
|
263
|
+
var feedbackCorrect = list[currentSlide].correctTexts.find(function (element) {
|
|
264
|
+
return element.id === id;
|
|
265
|
+
});
|
|
266
|
+
var feedbackIncorrect = list[currentSlide].wrongTexts.find(function (element) {
|
|
267
|
+
return element.id === id;
|
|
268
|
+
});
|
|
269
|
+
var specificCorrectFeedback = (_list$currentSlide = list[currentSlide]) === null || _list$currentSlide === void 0 ? void 0 : (_list$currentSlide$sp = _list$currentSlide.specificFeedbacks) === null || _list$currentSlide$sp === void 0 ? void 0 : _list$currentSlide$sp.correctFeedbacks.find(function (fb) {
|
|
270
|
+
return fb.id === id;
|
|
271
|
+
});
|
|
272
|
+
var specificWrongFeedback = (_list$currentSlide2 = list[currentSlide]) === null || _list$currentSlide2 === void 0 ? void 0 : (_list$currentSlide2$s = _list$currentSlide2.specificFeedbacks) === null || _list$currentSlide2$s === void 0 ? void 0 : _list$currentSlide2$s.wrongFeedbacks.find(function (fb) {
|
|
273
|
+
return fb.id === id;
|
|
274
|
+
}); // si va en orden
|
|
275
|
+
|
|
276
|
+
if (list[currentSlide].hasClickOrder) {
|
|
277
|
+
// y lo has hecho bien
|
|
278
|
+
if (list[currentSlide].correctTexts[orderCounter].id === id) {
|
|
279
|
+
setOrderCounter(orderCounter + 1); // hacer verde 🎉
|
|
280
|
+
|
|
281
|
+
handleCorrectClick(allDataTextIds, specificWrongFeedback);
|
|
282
|
+
} else if (list[currentSlide].correctTexts.find(function (c) {
|
|
283
|
+
return c.id === id;
|
|
284
|
+
}) && list[currentSlide].correctTexts[orderCounter].id !== id) {
|
|
285
|
+
// si has dado buena fuera de orden
|
|
286
|
+
emitEvent({
|
|
287
|
+
type: 'hidePuzzleButtons',
|
|
288
|
+
payload: true
|
|
289
|
+
});
|
|
290
|
+
setFeedbackData(function (prevState) {
|
|
291
|
+
return _objectSpread(_objectSpread({}, prevState), {}, {
|
|
292
|
+
result: null,
|
|
293
|
+
text: list[currentSlide].info.orderFeedback.desc || translate('puzzles.incorrectOrder'),
|
|
294
|
+
timeout: false
|
|
295
|
+
});
|
|
296
|
+
});
|
|
297
|
+
} else {
|
|
298
|
+
//si has click en mala repuesta
|
|
299
|
+
handleIncorrectClick(allDataTextIds, specificCorrectFeedback);
|
|
300
|
+
}
|
|
301
|
+
} else {
|
|
302
|
+
// si no va en orden
|
|
303
|
+
//si la opción clickada es correcta
|
|
304
|
+
if ((feedbackCorrect === null || feedbackCorrect === void 0 ? void 0 : feedbackCorrect.id) === id) {
|
|
305
|
+
handleCorrectClick(allDataTextIds, specificCorrectFeedback);
|
|
306
|
+
} //si la opción clickada es incorrecta
|
|
307
|
+
else if ((feedbackIncorrect === null || feedbackIncorrect === void 0 ? void 0 : feedbackIncorrect.id) === id) {
|
|
308
|
+
handleIncorrectClick(allDataTextIds, specificWrongFeedback); // si no tiene ni feedback general ni specificFeedbacks definido
|
|
309
|
+
} else if (id === 'allWrong') {
|
|
310
|
+
// si tiene feedback general definido
|
|
311
|
+
setFeedbackData(function (prevState) {
|
|
312
|
+
return _objectSpread(_objectSpread({}, prevState), {}, {
|
|
313
|
+
timeout: true
|
|
314
|
+
});
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
if (list[currentSlide].info.solution.wrong.desc !== '') {
|
|
318
|
+
setFeedbackData(function (prevState) {
|
|
319
|
+
return _objectSpread(_objectSpread({}, prevState), {}, {
|
|
320
|
+
text: list[currentSlide].info.solution.wrong.desc,
|
|
321
|
+
timeout: false
|
|
322
|
+
});
|
|
323
|
+
});
|
|
324
|
+
} // si no tiene ni feedback general ni specificFeedbacks definido
|
|
325
|
+
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}, [list, currentSlide, orderCounter, handleCorrectClick, emitEvent, translate, handleIncorrectClick]);
|
|
329
|
+
var recursiveStuff = (0, _react.useCallback)(function (jsx) {
|
|
330
|
+
return (0, _utils.getRecursiveJSX)(jsx, 0, list[currentSlide], onClickMark, onHoverMark);
|
|
331
|
+
}, [currentSlide, list, onClickMark, onHoverMark]);
|
|
332
|
+
var getnumberAllCorrectFragments = (0, _react.useCallback)(function () {
|
|
333
|
+
var counter = 0;
|
|
334
|
+
|
|
335
|
+
for (var i = 0; i < list.length; i++) {
|
|
336
|
+
for (var j = 0; j < list[i].correctTexts.length; j++) {
|
|
337
|
+
counter++;
|
|
338
|
+
setNumberAllCorrectFragments(counter);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}, [list]);
|
|
342
|
+
(0, _react.useEffect)(function () {
|
|
343
|
+
setInfo(_objectSpread(_objectSpread({}, list[currentSlide].info), {}, {
|
|
344
|
+
description: description
|
|
345
|
+
}));
|
|
346
|
+
|
|
347
|
+
if (list[currentSlide].text) {
|
|
348
|
+
var jsx = (0, _htmlReactParser.default)(list[currentSlide].text);
|
|
349
|
+
parsedText.current = recursiveStuff(jsx);
|
|
350
|
+
getnumberAllCorrectFragments();
|
|
351
|
+
} else {
|
|
352
|
+
parsedText.current = '';
|
|
353
|
+
}
|
|
354
|
+
}, [currentSlide, description, getnumberAllCorrectFragments, info, list, recursiveStuff, setInfo]);
|
|
355
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
356
|
+
className: "text-click text-click--".concat(styles),
|
|
357
|
+
style: feedbackData.show ? {
|
|
358
|
+
pointerEvents: 'none'
|
|
359
|
+
} : null
|
|
360
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
361
|
+
className: "text-click__overlay"
|
|
362
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
363
|
+
className: "text-click__container ".concat(transitionToNextSlide ? 'slideInLeft' : '', " ")
|
|
364
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
365
|
+
className: "text-click__title"
|
|
366
|
+
}, translate('puzzles.text-click-puzzle.title')), /*#__PURE__*/_react.default.createElement("div", {
|
|
367
|
+
className: "text-click__body"
|
|
368
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
369
|
+
className: "text-click__scroll"
|
|
370
|
+
}, parsedText.current)))), showFrames && /*#__PURE__*/_react.default.createElement("div", {
|
|
371
|
+
className: "text-click__paginator"
|
|
372
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
373
|
+
className: "text-click__icon-check-circle-black"
|
|
374
|
+
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
375
|
+
className: "icon-check-circle-black"
|
|
376
|
+
})), /*#__PURE__*/_react.default.createElement("span", {
|
|
377
|
+
className: "text-click__slide"
|
|
378
|
+
}, correctTextFragmentsAccumulated, " / ", numberAllCorrectFragments))), feedbackData.show && /*#__PURE__*/_react.default.createElement(_feedbackComponent.default, {
|
|
379
|
+
playSound: playSound,
|
|
380
|
+
success: feedbackData.result,
|
|
381
|
+
text: feedbackData.text,
|
|
382
|
+
translate: translate,
|
|
383
|
+
functionOnClose: handleFeedbackFuncionOnClose,
|
|
384
|
+
hasTimeout: feedbackData.timeout
|
|
385
|
+
}));
|
|
386
|
+
};
|
|
387
|
+
|
|
388
|
+
var _default = TextClickPuzzleComponent;
|
|
389
|
+
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 _TextClickPuzzleComponent = _interopRequireDefault(require("./components/TextClickPuzzleComponent"));
|
|
9
|
+
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
|
|
12
|
+
var _default = _TextClickPuzzleComponent.default;
|
|
13
|
+
exports.default = _default;
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.mockProps = exports.messages = void 0;
|
|
7
|
+
|
|
8
|
+
var emitEvent = function emitEvent(_ref) {
|
|
9
|
+
var type = _ref.type,
|
|
10
|
+
payload = _ref.payload;
|
|
11
|
+
|
|
12
|
+
if (type === 'translate') {
|
|
13
|
+
return payload;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
console.log('Emit event called');
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
var messages = {
|
|
20
|
+
fullText1: '<div><p><strong>Texto de prueba:</strong></p><p>Con <span data-text-id="text-click-0">un texto correcto normal</span></p><p>Con <span data-text-id="text-click-2">un texto incorrecto normal</span></p><p>Con un texto <span data-text-id="text-click-1">corr</span></p><p><span data-text-id="text-click-1">ecto partido</span></p></div>',
|
|
21
|
+
fullText2: '<div><mark data-text-id="text-click-4">FRAGMENTO <strong>CORRECTO</strong> id4</mark> que <mark data-text-id="text-click-7">FRAGMENTO <strong>CORRECTO id7</strong> 4</mark> en <mark data-text-id="text-click-6">FRAGMENTO <strong>inCORRECTO id6</strong> 4</mark> asdf asdf asf <mark data-text-id="text-click-5">FRAGMENTO <strong>INCORRECTO id5</strong></mark></div>',
|
|
22
|
+
fullText3: '<div>Todo es incorrecto salvo <span data-text-id="text-click-8">alguna cosa</span></div>'
|
|
23
|
+
};
|
|
24
|
+
exports.messages = messages;
|
|
25
|
+
var mockProps = {
|
|
26
|
+
emitEvent: emitEvent,
|
|
27
|
+
showFrames: true,
|
|
28
|
+
soundActions: [function () {}, function () {}],
|
|
29
|
+
styles: 'chalkboard',
|
|
30
|
+
list: [{
|
|
31
|
+
allWrong: true,
|
|
32
|
+
correctTexts: [{
|
|
33
|
+
id: 'text-click-0',
|
|
34
|
+
value: 'este value no le hace falta a arcade'
|
|
35
|
+
}, {
|
|
36
|
+
id: 'text-click-1',
|
|
37
|
+
value: 'este value no le hace falta a arcade'
|
|
38
|
+
}],
|
|
39
|
+
hasClickOrder: false,
|
|
40
|
+
hasHighlights: true,
|
|
41
|
+
info: {
|
|
42
|
+
solution: {
|
|
43
|
+
right: {
|
|
44
|
+
desc: '',
|
|
45
|
+
rewards: [{
|
|
46
|
+
id: 'k2koxnkq',
|
|
47
|
+
name: 'Power',
|
|
48
|
+
points: 10,
|
|
49
|
+
type: 'score'
|
|
50
|
+
}]
|
|
51
|
+
},
|
|
52
|
+
wrong: {
|
|
53
|
+
desc: '',
|
|
54
|
+
rewards: [{
|
|
55
|
+
id: 'k2koxnkq',
|
|
56
|
+
name: 'Power',
|
|
57
|
+
points: -10,
|
|
58
|
+
type: 'score'
|
|
59
|
+
}]
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
hint: {
|
|
63
|
+
active: false,
|
|
64
|
+
desc: '',
|
|
65
|
+
rewards: []
|
|
66
|
+
},
|
|
67
|
+
resolve: {
|
|
68
|
+
rewards: []
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
itemOrder: 1,
|
|
72
|
+
specificFeedbacks: {
|
|
73
|
+
correctFeedbacks: [{
|
|
74
|
+
id: 'text-click-0',
|
|
75
|
+
desc: '',
|
|
76
|
+
rewards: [{
|
|
77
|
+
id: 'k2koxnkq',
|
|
78
|
+
name: 'Power',
|
|
79
|
+
points: 10,
|
|
80
|
+
type: 'score'
|
|
81
|
+
}]
|
|
82
|
+
}, {
|
|
83
|
+
id: 'text-click-1',
|
|
84
|
+
desc: 'specificFeedbacks text-click-1 correcto',
|
|
85
|
+
rewards: [{
|
|
86
|
+
id: 'k2koxnkq',
|
|
87
|
+
name: 'Power',
|
|
88
|
+
points: 10,
|
|
89
|
+
type: 'score'
|
|
90
|
+
}]
|
|
91
|
+
}],
|
|
92
|
+
wrongFeedbacks: [{
|
|
93
|
+
id: 'text-click-2',
|
|
94
|
+
desc: 'specificFeedbacks text-click-2 incorrecto',
|
|
95
|
+
rewards: [{
|
|
96
|
+
id: 'k2koxnkq',
|
|
97
|
+
name: 'Power',
|
|
98
|
+
points: -10,
|
|
99
|
+
type: 'score'
|
|
100
|
+
}]
|
|
101
|
+
}]
|
|
102
|
+
},
|
|
103
|
+
text: messages.fullText1,
|
|
104
|
+
wrongTexts: [{
|
|
105
|
+
id: "text-click-2",
|
|
106
|
+
value: "este value no le hace falta a arcade"
|
|
107
|
+
}]
|
|
108
|
+
}, {
|
|
109
|
+
allWrong: false,
|
|
110
|
+
correctTexts: [{
|
|
111
|
+
id: 'text-click-4',
|
|
112
|
+
value: 'este value no le hace falta a arcade'
|
|
113
|
+
}, {
|
|
114
|
+
id: 'text-click-7',
|
|
115
|
+
value: 'este value no le hace falta a arcade'
|
|
116
|
+
}],
|
|
117
|
+
hasClickOrder: false,
|
|
118
|
+
hasHighlights: true,
|
|
119
|
+
info: {
|
|
120
|
+
solution: {
|
|
121
|
+
right: {
|
|
122
|
+
desc: '',
|
|
123
|
+
rewards: [{
|
|
124
|
+
id: 'k2koxnkq',
|
|
125
|
+
name: 'Power',
|
|
126
|
+
points: 10,
|
|
127
|
+
type: 'score'
|
|
128
|
+
}]
|
|
129
|
+
},
|
|
130
|
+
wrong: {
|
|
131
|
+
desc: '',
|
|
132
|
+
rewards: [{
|
|
133
|
+
id: 'k2koxnkq',
|
|
134
|
+
name: 'Power',
|
|
135
|
+
points: 10,
|
|
136
|
+
type: 'score'
|
|
137
|
+
}]
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
hint: {
|
|
141
|
+
active: false,
|
|
142
|
+
desc: '',
|
|
143
|
+
rewards: []
|
|
144
|
+
},
|
|
145
|
+
resolve: {
|
|
146
|
+
rewards: []
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
itemOrder: 2,
|
|
150
|
+
specificFeedbacks: {
|
|
151
|
+
correctFeedbacks: [{
|
|
152
|
+
id: 'text-click-4',
|
|
153
|
+
desc: 'item 2 specificFeedbacks correctFeedbacks 4 (1)',
|
|
154
|
+
rewards: [{
|
|
155
|
+
id: 'k2koxnkq',
|
|
156
|
+
name: 'Power',
|
|
157
|
+
points: 10,
|
|
158
|
+
type: 'score'
|
|
159
|
+
}]
|
|
160
|
+
}, {
|
|
161
|
+
id: 'text-click-7',
|
|
162
|
+
desc: '',
|
|
163
|
+
rewards: [{
|
|
164
|
+
id: 'k2koxnkq',
|
|
165
|
+
name: 'Power',
|
|
166
|
+
points: -10,
|
|
167
|
+
type: 'score'
|
|
168
|
+
}]
|
|
169
|
+
}],
|
|
170
|
+
wrongFeedbacks: [{
|
|
171
|
+
id: 'text-click-6',
|
|
172
|
+
desc: 'item 6 specificFeedbacks wrongFeedbacks 6 (1)',
|
|
173
|
+
rewards: [{
|
|
174
|
+
id: 'k2koxnkq',
|
|
175
|
+
name: 'Power',
|
|
176
|
+
points: -10,
|
|
177
|
+
type: 'score'
|
|
178
|
+
}]
|
|
179
|
+
}, {
|
|
180
|
+
id: 'text-click-5',
|
|
181
|
+
desc: 'item 5 specificFeedbacks wrongFeedbacks 5 (1)',
|
|
182
|
+
rewards: [{
|
|
183
|
+
id: 'k2koxnkq',
|
|
184
|
+
name: 'Power',
|
|
185
|
+
points: -10,
|
|
186
|
+
type: 'score'
|
|
187
|
+
}]
|
|
188
|
+
}]
|
|
189
|
+
},
|
|
190
|
+
text: messages.fullText2,
|
|
191
|
+
wrongTexts: [{
|
|
192
|
+
id: 'text-click-5',
|
|
193
|
+
value: "este value no le hace falta a arcade"
|
|
194
|
+
}, {
|
|
195
|
+
id: 'text-click-6',
|
|
196
|
+
value: "este value no le hace falta a arcade"
|
|
197
|
+
}]
|
|
198
|
+
}, {
|
|
199
|
+
allWrong: true,
|
|
200
|
+
correctTexts: [{
|
|
201
|
+
id: 'text-click-8',
|
|
202
|
+
value: 'este value no le hace falta a arcade'
|
|
203
|
+
}],
|
|
204
|
+
hasClickOrder: false,
|
|
205
|
+
hasHighlights: false,
|
|
206
|
+
info: {
|
|
207
|
+
solution: {
|
|
208
|
+
right: {
|
|
209
|
+
desc: '',
|
|
210
|
+
rewards: [{
|
|
211
|
+
id: 'k2koxnkq',
|
|
212
|
+
name: 'Power',
|
|
213
|
+
points: 10,
|
|
214
|
+
type: 'score'
|
|
215
|
+
}]
|
|
216
|
+
},
|
|
217
|
+
wrong: {
|
|
218
|
+
desc: '',
|
|
219
|
+
rewards: [{
|
|
220
|
+
id: 'k2koxnkq',
|
|
221
|
+
name: 'Power',
|
|
222
|
+
points: -10,
|
|
223
|
+
type: 'score'
|
|
224
|
+
}]
|
|
225
|
+
}
|
|
226
|
+
},
|
|
227
|
+
hint: {
|
|
228
|
+
active: false,
|
|
229
|
+
desc: '',
|
|
230
|
+
rewards: []
|
|
231
|
+
},
|
|
232
|
+
resolve: {
|
|
233
|
+
rewards: []
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
|
+
itemOrder: 3,
|
|
237
|
+
specificFeedbacks: {
|
|
238
|
+
correctFeedbacks: [{
|
|
239
|
+
id: 'text-click-8',
|
|
240
|
+
desc: 'text-click-8',
|
|
241
|
+
rewards: [{
|
|
242
|
+
id: 'k2koxnkq',
|
|
243
|
+
name: 'Power',
|
|
244
|
+
points: 10,
|
|
245
|
+
type: 'score'
|
|
246
|
+
}]
|
|
247
|
+
}],
|
|
248
|
+
wrongFeedbacks: []
|
|
249
|
+
},
|
|
250
|
+
text: messages.fullText3,
|
|
251
|
+
wrongTexts: []
|
|
252
|
+
}]
|
|
253
|
+
};
|
|
254
|
+
exports.mockProps = mockProps;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getRecursiveJSX = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
|
|
12
|
+
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); }
|
|
13
|
+
|
|
14
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
15
|
+
|
|
16
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
17
|
+
|
|
18
|
+
var getRecursiveJSX = function getRecursiveJSX(jsx) {
|
|
19
|
+
var _jsx$props;
|
|
20
|
+
|
|
21
|
+
var i = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
22
|
+
var slide = arguments.length > 2 ? arguments[2] : undefined;
|
|
23
|
+
var onClick = arguments.length > 3 ? arguments[3] : undefined;
|
|
24
|
+
var onHover = arguments.length > 4 ? arguments[4] : undefined;
|
|
25
|
+
|
|
26
|
+
if ((_jsx$props = jsx.props) !== null && _jsx$props !== void 0 && _jsx$props.children) {
|
|
27
|
+
var Type = jsx.type; // Tipo de marcado
|
|
28
|
+
|
|
29
|
+
var _jsx$props2 = jsx.props,
|
|
30
|
+
children = _jsx$props2.children,
|
|
31
|
+
props = _objectWithoutProperties(_jsx$props2, ["children"]); // Obtenemos el hijo y los props por separado
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
if (jsx.props['data-text-id']) {
|
|
35
|
+
props.onClick = function (e) {
|
|
36
|
+
return onClick(e, props['data-text-id'] || -1);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
if (slide !== null && slide !== void 0 && slide.hasHighlights) {
|
|
40
|
+
props.onMouseEnter = function () {
|
|
41
|
+
return onHover(props['data-text-id'] || -1);
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
} else if (slide !== null && slide !== void 0 && slide.allWrong && !jsx.props['data-text-id']) {
|
|
45
|
+
props.onClick = function (e) {
|
|
46
|
+
return onClick(e, 'allWrong');
|
|
47
|
+
};
|
|
48
|
+
} // Si hay varios hijos los recorremos y llamamos a la función recursiva
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
if (Array.isArray(children)) {
|
|
52
|
+
// Mantenemos el marcado y los props
|
|
53
|
+
return /*#__PURE__*/_react.default.createElement(Type, _extends({
|
|
54
|
+
key: "".concat(jsx.type, "_").concat(i)
|
|
55
|
+
}, props), children.map(function (child, i) {
|
|
56
|
+
return getRecursiveJSX(child, i, slide, onClick, onHover);
|
|
57
|
+
}));
|
|
58
|
+
} // Nodo sin hijos
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
return /*#__PURE__*/_react.default.createElement(Type, _extends({
|
|
62
|
+
key: "".concat(jsx.type, "_").concat(i)
|
|
63
|
+
}, props), getRecursiveJSX(children, i, slide, onClick, onHover));
|
|
64
|
+
} // console.log('🐮', jsx);
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
return jsx.split(' ').filter(function (word) {
|
|
68
|
+
return word !== '';
|
|
69
|
+
}).map(function (word, i) {
|
|
70
|
+
return /*#__PURE__*/_react.default.createElement("span", {
|
|
71
|
+
key: i
|
|
72
|
+
}, word);
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
exports.getRecursiveJSX = getRecursiveJSX;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.mock6 = exports.mock5 = exports.mock4 = exports.mock3 = exports.mock2 = exports.mock = exports.messages = void 0;
|
|
6
|
+
exports.mock8 = exports.mock7 = exports.mock6 = exports.mock5 = exports.mock4 = exports.mock3 = exports.mock2 = exports.mock = exports.messages = void 0;
|
|
7
7
|
|
|
8
8
|
var emitEvent = function emitEvent(_ref) {
|
|
9
9
|
var type = _ref.type,
|
|
@@ -191,6 +191,7 @@ var mock = {
|
|
|
191
191
|
exports.mock = mock;
|
|
192
192
|
var mock2 = {
|
|
193
193
|
emitEvent: emitEvent,
|
|
194
|
+
soundActions: [function () {}, function () {}],
|
|
194
195
|
texts: [{
|
|
195
196
|
type: 'fixed',
|
|
196
197
|
fullText: messages.fullText1
|
|
@@ -375,6 +376,7 @@ var mock2 = {
|
|
|
375
376
|
exports.mock2 = mock2;
|
|
376
377
|
var mock3 = {
|
|
377
378
|
emitEvent: emitEvent,
|
|
379
|
+
soundActions: [function () {}, function () {}],
|
|
378
380
|
texts: [{
|
|
379
381
|
type: 'fixed',
|
|
380
382
|
fullText: messages.fullText1
|
|
@@ -529,6 +531,7 @@ var mock3 = {
|
|
|
529
531
|
exports.mock3 = mock3;
|
|
530
532
|
var mock4 = {
|
|
531
533
|
emitEvent: emitEvent,
|
|
534
|
+
soundActions: [function () {}, function () {}],
|
|
532
535
|
texts: [{
|
|
533
536
|
type: 'fixed',
|
|
534
537
|
fullText: messages.fullText1
|
|
@@ -713,6 +716,7 @@ var mock4 = {
|
|
|
713
716
|
exports.mock4 = mock4;
|
|
714
717
|
var mock5 = {
|
|
715
718
|
emitEvent: emitEvent,
|
|
719
|
+
soundActions: [function () {}, function () {}],
|
|
716
720
|
texts: [{
|
|
717
721
|
type: 'fixed',
|
|
718
722
|
fullText: messages.fullText11
|
|
@@ -798,6 +802,7 @@ var mock5 = {
|
|
|
798
802
|
exports.mock5 = mock5;
|
|
799
803
|
var mock6 = {
|
|
800
804
|
emitEvent: emitEvent,
|
|
805
|
+
soundActions: [function () {}, function () {}],
|
|
801
806
|
texts: [{
|
|
802
807
|
type: 'fixed',
|
|
803
808
|
fullText: messages.fullText11
|
|
@@ -880,4 +885,176 @@ var mock6 = {
|
|
|
880
885
|
skip: false,
|
|
881
886
|
documentTitle: messages.documentTitle6
|
|
882
887
|
};
|
|
883
|
-
exports.mock6 = mock6;
|
|
888
|
+
exports.mock6 = mock6;
|
|
889
|
+
var mock7 = {
|
|
890
|
+
emitEvent: emitEvent,
|
|
891
|
+
soundActions: [function () {}, function () {}],
|
|
892
|
+
texts: [{
|
|
893
|
+
type: 'fixed',
|
|
894
|
+
fullText: messages.fullText11
|
|
895
|
+
}, {
|
|
896
|
+
type: 'election',
|
|
897
|
+
electionTexts: [{
|
|
898
|
+
previewText: messages.previewText1,
|
|
899
|
+
correct: false,
|
|
900
|
+
fullText: messages.fullText3,
|
|
901
|
+
feedback: {
|
|
902
|
+
title: null,
|
|
903
|
+
body: null,
|
|
904
|
+
rewards: []
|
|
905
|
+
}
|
|
906
|
+
}, {
|
|
907
|
+
previewText: messages.previewText2,
|
|
908
|
+
correct: false,
|
|
909
|
+
fullText: messages.fullText4,
|
|
910
|
+
feedback: {
|
|
911
|
+
title: null,
|
|
912
|
+
body: null,
|
|
913
|
+
rewards: []
|
|
914
|
+
}
|
|
915
|
+
}, {
|
|
916
|
+
previewText: '',
|
|
917
|
+
correct: false,
|
|
918
|
+
fullText: messages.fullText5,
|
|
919
|
+
feedback: {
|
|
920
|
+
title: null,
|
|
921
|
+
body: null,
|
|
922
|
+
rewards: []
|
|
923
|
+
}
|
|
924
|
+
}]
|
|
925
|
+
}, {
|
|
926
|
+
type: 'fixed',
|
|
927
|
+
fullText: messages.fullText6
|
|
928
|
+
}],
|
|
929
|
+
info: {
|
|
930
|
+
solution: {
|
|
931
|
+
right: {
|
|
932
|
+
desc: 'Great!!',
|
|
933
|
+
rewards: [],
|
|
934
|
+
desc_labelId: 'desc_bEo7Tp88'
|
|
935
|
+
},
|
|
936
|
+
wrong: {
|
|
937
|
+
desc: 'Boooo',
|
|
938
|
+
rewards: [],
|
|
939
|
+
desc_labelId: 'desc_bEo7TrDd'
|
|
940
|
+
}
|
|
941
|
+
},
|
|
942
|
+
hint: {
|
|
943
|
+
active: true,
|
|
944
|
+
desc: 'Just choose',
|
|
945
|
+
rewards: [{
|
|
946
|
+
id: 'k7d3gq9i',
|
|
947
|
+
name: 'asdasd',
|
|
948
|
+
rewards: -10,
|
|
949
|
+
type: 'score'
|
|
950
|
+
}],
|
|
951
|
+
desc_labelId: 'desc_bEo7TTUl'
|
|
952
|
+
},
|
|
953
|
+
resolve: {
|
|
954
|
+
rewards: [{
|
|
955
|
+
id: 'k7d3gq9i',
|
|
956
|
+
name: 'asdasd',
|
|
957
|
+
rewards: 100,
|
|
958
|
+
type: 'score'
|
|
959
|
+
}]
|
|
960
|
+
},
|
|
961
|
+
title: 'Writter Title',
|
|
962
|
+
instructions: 'Instructions for doing this Puzzle',
|
|
963
|
+
description: 'This is a puzzle about writting',
|
|
964
|
+
title_labelId: 'title_bEo7SRDk',
|
|
965
|
+
instructions_labelId: 'instructions_bEo7TDEq'
|
|
966
|
+
},
|
|
967
|
+
styles: 'whatsapp-ligth',
|
|
968
|
+
type: 'view',
|
|
969
|
+
visible: true,
|
|
970
|
+
retry: false,
|
|
971
|
+
skip: false,
|
|
972
|
+
documentTitle: messages.documentTitle6
|
|
973
|
+
};
|
|
974
|
+
exports.mock7 = mock7;
|
|
975
|
+
var mock8 = {
|
|
976
|
+
emitEvent: emitEvent,
|
|
977
|
+
soundActions: [function () {}, function () {}],
|
|
978
|
+
texts: [{
|
|
979
|
+
type: 'fixed',
|
|
980
|
+
fullText: messages.fullText11
|
|
981
|
+
}, {
|
|
982
|
+
type: 'election',
|
|
983
|
+
electionTexts: [{
|
|
984
|
+
previewText: messages.previewText1,
|
|
985
|
+
correct: false,
|
|
986
|
+
fullText: messages.fullText3,
|
|
987
|
+
feedback: {
|
|
988
|
+
title: null,
|
|
989
|
+
body: null,
|
|
990
|
+
rewards: []
|
|
991
|
+
}
|
|
992
|
+
}, {
|
|
993
|
+
previewText: messages.previewText2,
|
|
994
|
+
correct: false,
|
|
995
|
+
fullText: messages.fullText4,
|
|
996
|
+
feedback: {
|
|
997
|
+
title: null,
|
|
998
|
+
body: null,
|
|
999
|
+
rewards: []
|
|
1000
|
+
}
|
|
1001
|
+
}, {
|
|
1002
|
+
previewText: '',
|
|
1003
|
+
correct: false,
|
|
1004
|
+
fullText: messages.fullText5,
|
|
1005
|
+
feedback: {
|
|
1006
|
+
title: null,
|
|
1007
|
+
body: null,
|
|
1008
|
+
rewards: []
|
|
1009
|
+
}
|
|
1010
|
+
}]
|
|
1011
|
+
}, {
|
|
1012
|
+
type: 'fixed',
|
|
1013
|
+
fullText: messages.fullText6
|
|
1014
|
+
}],
|
|
1015
|
+
info: {
|
|
1016
|
+
solution: {
|
|
1017
|
+
right: {
|
|
1018
|
+
desc: 'Great!!',
|
|
1019
|
+
rewards: [],
|
|
1020
|
+
desc_labelId: 'desc_bEo7Tp88'
|
|
1021
|
+
},
|
|
1022
|
+
wrong: {
|
|
1023
|
+
desc: 'Boooo',
|
|
1024
|
+
rewards: [],
|
|
1025
|
+
desc_labelId: 'desc_bEo7TrDd'
|
|
1026
|
+
}
|
|
1027
|
+
},
|
|
1028
|
+
hint: {
|
|
1029
|
+
active: true,
|
|
1030
|
+
desc: 'Just choose',
|
|
1031
|
+
rewards: [{
|
|
1032
|
+
id: 'k7d3gq9i',
|
|
1033
|
+
name: 'asdasd',
|
|
1034
|
+
rewards: -10,
|
|
1035
|
+
type: 'score'
|
|
1036
|
+
}],
|
|
1037
|
+
desc_labelId: 'desc_bEo7TTUl'
|
|
1038
|
+
},
|
|
1039
|
+
resolve: {
|
|
1040
|
+
rewards: [{
|
|
1041
|
+
id: 'k7d3gq9i',
|
|
1042
|
+
name: 'asdasd',
|
|
1043
|
+
rewards: 100,
|
|
1044
|
+
type: 'score'
|
|
1045
|
+
}]
|
|
1046
|
+
},
|
|
1047
|
+
title: 'Writter Title',
|
|
1048
|
+
instructions: 'Instructions for doing this Puzzle',
|
|
1049
|
+
description: 'This is a puzzle about writting',
|
|
1050
|
+
title_labelId: 'title_bEo7SRDk',
|
|
1051
|
+
instructions_labelId: 'instructions_bEo7TDEq'
|
|
1052
|
+
},
|
|
1053
|
+
styles: 'whatsapp-dark',
|
|
1054
|
+
type: 'view',
|
|
1055
|
+
visible: true,
|
|
1056
|
+
retry: false,
|
|
1057
|
+
skip: false,
|
|
1058
|
+
documentTitle: messages.documentTitle6
|
|
1059
|
+
};
|
|
1060
|
+
exports.mock8 = mock8;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gamelearn/arcade-components",
|
|
3
3
|
"license": "Gamelearn",
|
|
4
|
-
"version": "0.19.
|
|
4
|
+
"version": "0.19.2",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"@babel/cli": "7.12.10",
|
|
56
56
|
"@babel/preset-env": "7.12.11",
|
|
57
57
|
"@babel/preset-react": "7.12.10",
|
|
58
|
-
"@gamelearn/ui-components-core": "5.
|
|
58
|
+
"@gamelearn/ui-components-core": "5.38.0",
|
|
59
59
|
"@react-three/test-renderer": "6.0.6",
|
|
60
60
|
"@storybook/addon-actions": "6.1.11",
|
|
61
61
|
"@storybook/addon-essentials": "6.1.11",
|