@micromag/screen-quiz 0.3.673 → 0.3.676

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.
@@ -1,4 +1,4 @@
1
- .micromag-screen-quiz-answers-emptyAnswer{border:2px dashed #343434;color:#343434;margin:5px auto}.micromag-screen-quiz-answers-button:focus-visible{outline:3px solid #a13dff;outline-offset:4px}.micromag-screen-quiz-answers-container,.micromag-screen-quiz-answers-items{position:relative}.micromag-screen-quiz-answers-emptyAnswer{font-size:.75em;height:40px;margin:0 auto;width:100%}.micromag-screen-quiz-answers-item{margin:0;padding:0;position:relative;-webkit-transition:opacity .6s ease-out;transition:opacity .6s ease-out}.micromag-screen-quiz-answers-isPlaceholder .micromag-screen-quiz-answers-item{padding:1px 0}.micromag-screen-quiz-answers-item.micromag-screen-quiz-answers-userAnswer{opacity:1!important}.micromag-screen-quiz-answers-item.micromag-screen-quiz-answers-otherAnswer{opacity:.6!important}.micromag-screen-quiz-answers-item.micromag-screen-quiz-answers-withoutOpacity{opacity:1!important}.micromag-screen-quiz-answers-button{color:#fff;padding:10px;position:relative;width:100%}.micromag-screen-quiz-answers-button:disabled{opacity:1;pointer-events:none}.micromag-screen-quiz-answers-withIcon .micromag-screen-quiz-answers-button{padding-left:42px;padding-right:42px}.micromag-screen-quiz-answers-resultIcon{display:-ms-flexbox;display:flex;left:5px;position:absolute;top:50%;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;background-color:#ff2945;border:2px solid #1c1c1c;border-radius:50%;height:32px;justify-content:center;margin-top:-16px;opacity:0;padding:5px;-webkit-transition:opacity .15s ease;transition:opacity .15s ease;width:32px}.micromag-screen-quiz-answers-answered .micromag-screen-quiz-answers-resultIcon{opacity:1}.micromag-screen-quiz-answers-rightAnswer .micromag-screen-quiz-answers-resultIcon{background-color:#0ed88f}.micromag-screen-quiz-answers-resultIcon .micromag-screen-quiz-answers-faIcon{display:block}.micromag-screen-quiz-answers-itemContent{padding:5px 0}
1
+ .micromag-screen-quiz-answers-emptyAnswer{border:2px dashed #343434;color:#343434;margin:5px auto}.micromag-screen-quiz-answers-button:focus-visible{outline:3px solid #a13dff;outline-offset:4px}.micromag-screen-quiz-answers-container,.micromag-screen-quiz-answers-items{position:relative}.micromag-screen-quiz-answers-emptyAnswer{font-size:.75em;height:40px;margin:0 auto;width:100%}.micromag-screen-quiz-answers-item{margin:0;padding:0;position:relative;-webkit-transition:opacity .6s ease-out;transition:opacity .6s ease-out}.micromag-screen-quiz-answers-isPlaceholder .micromag-screen-quiz-answers-item{padding:1px 0}.micromag-screen-quiz-answers-item.micromag-screen-quiz-answers-userAnswer{opacity:1!important}.micromag-screen-quiz-answers-item.micromag-screen-quiz-answers-otherAnswer{opacity:.6!important}.micromag-screen-quiz-answers-item.micromag-screen-quiz-answers-withoutOpacity{opacity:1!important}.micromag-screen-quiz-answers-button{color:#fff;padding:10px;position:relative;width:100%}.micromag-screen-quiz-answers-button:disabled{opacity:1}.micromag-screen-quiz-answers-withIcon .micromag-screen-quiz-answers-button{padding-left:42px;padding-right:42px}.micromag-screen-quiz-answers-resultIcon{display:-ms-flexbox;display:flex;left:5px;position:absolute;top:50%;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;background-color:#ff2945;border:2px solid #1c1c1c;border-radius:50%;height:32px;justify-content:center;margin-top:-16px;opacity:0;padding:5px;-webkit-transition:opacity .15s ease;transition:opacity .15s ease;width:32px}.micromag-screen-quiz-answers-answered .micromag-screen-quiz-answers-resultIcon{opacity:1}.micromag-screen-quiz-answers-rightAnswer .micromag-screen-quiz-answers-resultIcon{background-color:#0ed88f}.micromag-screen-quiz-answers-resultIcon .micromag-screen-quiz-answers-faIcon{display:block}.micromag-screen-quiz-answers-itemContent{padding:5px 0}
2
2
  .micromag-screen-quiz-question-container .micromag-screen-quiz-question-emptyQuestion,.micromag-screen-quiz-question-container .micromag-screen-quiz-question-emptyResult{border:2px dashed #343434;color:#343434;margin:5px auto}.micromag-screen-quiz-question-container .micromag-screen-quiz-question-question{margin-bottom:10px}.micromag-screen-quiz-question-container .micromag-screen-quiz-question-index{display:block;margin-bottom:1em;text-align:center;width:100%}.micromag-screen-quiz-question-container .micromag-screen-quiz-question-resultContent{padding:20px 0}.micromag-screen-quiz-question-container .micromag-screen-quiz-question-result{opacity:0;pointer-events:none;position:absolute;-webkit-transition:opacity .5s ease;transition:opacity .5s ease;-webkit-transition-delay:.3s;transition-delay:.3s}.micromag-screen-quiz-question-container .micromag-screen-quiz-question-emptyQuestion,.micromag-screen-quiz-question-container .micromag-screen-quiz-question-emptyResult{margin:0 auto;width:100%}.micromag-screen-quiz-question-container .micromag-screen-quiz-question-emptyQuestion{height:60px;margin-bottom:10px}.micromag-screen-quiz-question-container .micromag-screen-quiz-question-emptyResult{height:100px}.micromag-screen-quiz-question-container.micromag-screen-quiz-question-resultVisible .micromag-screen-quiz-question-result{opacity:1;pointer-events:all;position:relative}.micromag-screen-quiz-question-container.micromag-screen-quiz-question-resultHidden .micromag-screen-quiz-question-result{opacity:0;pointer-events:none;position:absolute}.micromag-screen-quiz-question-container.micromag-screen-quiz-question-resultHidden .micromag-screen-quiz-question-result .micromag-screen-quiz-question-resultContent{padding:0}.micromag-screen-quiz-question-container.micromag-screen-quiz-question-isPlaceholder{padding:10px}.micromag-screen-quiz-question-container.micromag-screen-quiz-question-isPlaceholder .micromag-screen-quiz-question-index{color:hsla(0,0%,100%,.6);font-size:8px;mix-blend-mode:difference}
3
3
  .micromag-screen-quiz-container .micromag-screen-quiz-background{height:100%;left:0;position:absolute;top:0;width:100%}.micromag-screen-quiz-container{height:100%;overflow:hidden;position:relative;width:100%}.micromag-screen-quiz-disabled.micromag-screen-quiz-container{overflow:hidden;pointer-events:none}.micromag-screen-quiz-hidden.micromag-screen-quiz-container{display:none;visibility:hidden}.micromag-screen-quiz-placeholder.micromag-screen-quiz-container .micromag-screen-quiz-content{padding:6px;position:relative}.micromag-screen-quiz-nextButton:focus-visible{outline:3px solid #a13dff;outline-offset:4px}.micromag-screen-quiz-container .micromag-screen-quiz-background{z-index:0}.micromag-screen-quiz-container .micromag-screen-quiz-content{z-index:2}.micromag-screen-quiz-container.micromag-screen-quiz-disabled{pointer-events:none}.micromag-screen-quiz-reset{background-color:transparent;border:0;padding:10px;position:absolute;right:0;top:0;-webkit-transform-origin:center;-ms-transform-origin:center;transform-origin:center;-webkit-transition:opacity .15s ease-out,-webkit-transform .15s ease-out;transition:opacity .15s ease-out,-webkit-transform .15s ease-out;transition:opacity .15s ease-out,transform .15s ease-out;transition:opacity .15s ease-out,transform .15s ease-out,-webkit-transform .15s ease-out;z-index:1000}.micromag-screen-quiz-reset:hover{border:0;opacity:.8}.micromag-screen-quiz-reset:hover:active{-webkit-transform:rotate(30deg);-ms-transform:rotate(30deg);transform:rotate(30deg)}.micromag-screen-quiz-points{color:#fff;left:0;padding:10px;position:absolute;top:0;z-index:1000}.micromag-screen-quiz-layout{bottom:0;left:0;position:absolute;right:0;top:0}.micromag-screen-quiz-header{left:0;position:absolute;top:0;-webkit-transition:opacity .2s ease-out;transition:opacity .2s ease-out;width:100%}.micromag-screen-quiz-header.micromag-screen-quiz-disabled{opacity:0;pointer-events:none}.micromag-screen-quiz-footer{bottom:0;left:0;position:absolute;-webkit-transition:opacity .2s ease-out;transition:opacity .2s ease-out;width:100%}.micromag-screen-quiz-footer a{padding:0}.micromag-screen-quiz-footer.micromag-screen-quiz-disabled{opacity:0;pointer-events:none}.micromag-screen-quiz-transition{bottom:0;left:0;position:absolute;right:0;top:0}.micromag-screen-quiz-intro,.micromag-screen-quiz-nextButton,.micromag-screen-quiz-question,.micromag-screen-quiz-results{overflow:hidden}.micromag-screen-quiz-intro.micromag-screen-quiz-enter,.micromag-screen-quiz-nextButton.micromag-screen-quiz-enter,.micromag-screen-quiz-question.micromag-screen-quiz-enter,.micromag-screen-quiz-results.micromag-screen-quiz-enter{-webkit-transform:translateX(100%);-ms-transform:translateX(100%);transform:translateX(100%)}.micromag-screen-quiz-left .micromag-screen-quiz-intro.micromag-screen-quiz-enter,.micromag-screen-quiz-left .micromag-screen-quiz-nextButton.micromag-screen-quiz-enter,.micromag-screen-quiz-left .micromag-screen-quiz-question.micromag-screen-quiz-enter,.micromag-screen-quiz-left .micromag-screen-quiz-results.micromag-screen-quiz-enter{-webkit-transform:translateX(-100%);-ms-transform:translateX(-100%);transform:translateX(-100%)}.micromag-screen-quiz-intro.micromag-screen-quiz-enterActive,.micromag-screen-quiz-left .micromag-screen-quiz-intro.micromag-screen-quiz-enterActive,.micromag-screen-quiz-left .micromag-screen-quiz-nextButton.micromag-screen-quiz-enterActive,.micromag-screen-quiz-left .micromag-screen-quiz-question.micromag-screen-quiz-enterActive,.micromag-screen-quiz-left .micromag-screen-quiz-results.micromag-screen-quiz-enterActive,.micromag-screen-quiz-nextButton.micromag-screen-quiz-enterActive,.micromag-screen-quiz-question.micromag-screen-quiz-enterActive,.micromag-screen-quiz-results.micromag-screen-quiz-enterActive{left:0;min-height:100%;position:absolute;top:0;-webkit-transform:translateX(0);-ms-transform:translateX(0);transform:translateX(0);-webkit-transition:-webkit-transform 1s ease;transition:-webkit-transform 1s ease;transition:transform 1s ease;transition:transform 1s ease,-webkit-transform 1s ease;width:100%}.micromag-screen-quiz-intro.micromag-screen-quiz-exit,.micromag-screen-quiz-nextButton.micromag-screen-quiz-exit,.micromag-screen-quiz-question.micromag-screen-quiz-exit,.micromag-screen-quiz-results.micromag-screen-quiz-exit{-webkit-transform:translateX(0);-ms-transform:translateX(0);transform:translateX(0)}.micromag-screen-quiz-intro.micromag-screen-quiz-exitActive,.micromag-screen-quiz-nextButton.micromag-screen-quiz-exitActive,.micromag-screen-quiz-question.micromag-screen-quiz-exitActive,.micromag-screen-quiz-results.micromag-screen-quiz-exitActive{left:0;min-height:100%;position:absolute;top:0;-webkit-transform:translateX(-100%);-ms-transform:translateX(-100%);transform:translateX(-100%);-webkit-transition:-webkit-transform 1s ease;transition:-webkit-transform 1s ease;transition:transform 1s ease;transition:transform 1s ease,-webkit-transform 1s ease;width:100%}.micromag-screen-quiz-left .micromag-screen-quiz-intro.micromag-screen-quiz-exitActive,.micromag-screen-quiz-left .micromag-screen-quiz-nextButton.micromag-screen-quiz-exitActive,.micromag-screen-quiz-left .micromag-screen-quiz-question.micromag-screen-quiz-exitActive,.micromag-screen-quiz-left .micromag-screen-quiz-results.micromag-screen-quiz-exitActive{-webkit-transform:translateX(100%);-ms-transform:translateX(100%);transform:translateX(100%)}.micromag-screen-quiz-nextButton{color:#fff;padding:10px;position:relative;width:100%}.micromag-screen-quiz-nextButton:disabled{opacity:1;pointer-events:none}.micromag-screen-quiz-withIcon .micromag-screen-quiz-nextButton{padding-left:42px;padding-right:42px}.micromag-screen-quiz-background.micromag-screen-quiz-enter{opacity:0}.micromag-screen-quiz-background.micromag-screen-quiz-enterActive{opacity:1;-webkit-transition:opacity 1s ease;transition:opacity 1s ease;z-index:1}.micromag-screen-quiz-background.micromag-screen-quiz-exit{opacity:1}.micromag-screen-quiz-background.micromag-screen-quiz-exitActive{opacity:0;-webkit-transition:opacity 1s ease;transition:opacity 1s ease;z-index:0}
4
4
  .micromag-screen-quiz-results-container .micromag-screen-quiz-results-emptyDescription,.micromag-screen-quiz-results-container .micromag-screen-quiz-results-emptyTitle{border:2px dashed #343434;color:#343434;margin:5px auto}.micromag-screen-quiz-results-container .micromag-screen-quiz-results-title{margin-bottom:10px}.micromag-screen-quiz-results-container .micromag-screen-quiz-results-emptyDescription,.micromag-screen-quiz-results-container .micromag-screen-quiz-results-emptyTitle{margin:0 auto;width:100%}.micromag-screen-quiz-results-container .micromag-screen-quiz-results-emptyTitle{height:60px}.micromag-screen-quiz-results-container .micromag-screen-quiz-results-emptyDescription{height:100px}.micromag-screen-quiz-results-container.micromag-screen-quiz-results-isPlaceholder{padding:10px}
package/es/index.js CHANGED
@@ -117,7 +117,7 @@ var Answers = function Answers(_ref) {
117
117
  return hasGood || good;
118
118
  }, false) : false;
119
119
  var finalShowUserAnswer = showUserAnswer || !hasRightAnswer;
120
- var shouldCollapse = (!withoutGoodAnswer || finalShowUserAnswer && answeredIndex !== null) && !withoutCollapse;
120
+ var shouldCollapse = !withoutGoodAnswer || finalShowUserAnswer && answeredIndex !== null && !withoutCollapse;
121
121
  var _useState3 = useState(answeredIndex !== null),
122
122
  _useState4 = _slicedToArray(_useState3, 2),
123
123
  answersCollapsed = _useState4[0],
@@ -134,6 +134,7 @@ var Answers = function Answers(_ref) {
134
134
  var timeout = null;
135
135
  if (answeredIndex !== null && shouldCollapse) {
136
136
  timeout = setTimeout(function () {
137
+ // console.log('ok should collapse');
137
138
  setAnswersCollapsed(true);
138
139
  if (onCollapse !== null) {
139
140
  onCollapse();
@@ -141,6 +142,7 @@ var Answers = function Answers(_ref) {
141
142
  }, hasAnsweredRight || finalShowUserAnswer ? 500 : answersCollapseDelay);
142
143
  } else if (answeredIndex !== null && !shouldCollapse) {
143
144
  timeout = setTimeout(function () {
145
+ // console.log('ok no collapse');
144
146
  if (onCollapse !== null) {
145
147
  onCollapse();
146
148
  }
@@ -162,17 +164,27 @@ var Answers = function Answers(_ref) {
162
164
  }, [answeredIndex, withoutGoodAnswer, setAnswersCollapsed, onCollapse, onCollapsed, onTransitionEnd, answersCollapseDelay, hasAnsweredRight, finalShowUserAnswer, shouldCollapse]);
163
165
  useEffect(function () {
164
166
  var timeout = null;
167
+ var endTimeout = null;
165
168
  if (answersCollapsed) {
166
169
  timeout = setTimeout(function () {
167
170
  setAnswersFinalCollapse(true);
168
171
  }, 300);
172
+ endTimeout = setTimeout(function () {
173
+ // Failsafe cause collapse transition is not always active
174
+ if (onTransitionEnd !== null) {
175
+ onTransitionEnd();
176
+ }
177
+ }, 625);
169
178
  }
170
179
  return function () {
171
180
  if (timeout !== null) {
172
181
  clearTimeout(timeout);
173
182
  }
183
+ if (endTimeout !== null) {
184
+ clearTimeout(endTimeout);
185
+ }
174
186
  };
175
- }, [answersCollapsed]);
187
+ }, [answersCollapsed, onTransitionEnd, setAnswersFinalCollapse]);
176
188
  var _useState9 = useState(false),
177
189
  _useState10 = _slicedToArray(_useState9, 2),
178
190
  transitioned = _useState10[0],
@@ -217,26 +229,28 @@ var Answers = function Answers(_ref) {
217
229
  if (answeredIndex !== null && showAnimation && answersCollapsed && !rightAnswer) {
218
230
  hidden = true;
219
231
  }
232
+ var _ref6 = answer || {},
233
+ _ref6$label = _ref6.label,
234
+ label = _ref6$label === void 0 ? null : _ref6$label;
235
+ var key = "key-".concat(answerI, "-").concat((label === null || label === void 0 ? void 0 : label.body) || null);
220
236
  return _objectSpread(_objectSpread({}, answer), {}, {
221
237
  hidden: hidden,
222
238
  userAnswer: userAnswer,
223
239
  index: answerI,
224
- maxHeight: height
240
+ maxHeight: height,
241
+ key: key
225
242
  });
226
243
  });
227
244
  var transitions = useTransition(filteredListOfItems, {
228
- key: function key(_ref6) {
229
- var _ref6$index = _ref6.index,
230
- index = _ref6$index === void 0 ? 0 : _ref6$index,
231
- _ref6$label = _ref6.label,
232
- label = _ref6$label === void 0 ? null : _ref6$label;
233
- return "key-".concat(index, "-").concat((label === null || label === void 0 ? void 0 : label.body) || null);
245
+ key: function key(_ref7) {
246
+ var _key = _ref7.key;
247
+ return _key;
234
248
  },
235
- update: function update(_ref7) {
236
- var _ref7$hidden = _ref7.hidden,
237
- hidden = _ref7$hidden === void 0 ? false : _ref7$hidden,
238
- _ref7$maxHeight = _ref7.maxHeight,
239
- maxHeight = _ref7$maxHeight === void 0 ? 0 : _ref7$maxHeight;
249
+ update: function update(_ref8) {
250
+ var _ref8$hidden = _ref8.hidden,
251
+ hidden = _ref8$hidden === void 0 ? false : _ref8$hidden,
252
+ _ref8$maxHeight = _ref8.maxHeight,
253
+ maxHeight = _ref8$maxHeight === void 0 ? 0 : _ref8$maxHeight;
240
254
  return {
241
255
  opacity: hidden && showAnimation && !withoutGoodAnswer ? 0 : 1,
242
256
  // Animate this, not height
@@ -258,9 +272,9 @@ var Answers = function Answers(_ref) {
258
272
  }
259
273
  }, [transitioned, onTransitionEnd]);
260
274
  var hasOpacity = useMemo(function () {
261
- var _ref8 = inactiveButtonsStyle || {},
262
- _ref8$backgroundColor = _ref8.backgroundColor,
263
- backgroundColor = _ref8$backgroundColor === void 0 ? null : _ref8$backgroundColor;
275
+ var _ref9 = inactiveButtonsStyle || {},
276
+ _ref9$backgroundColor = _ref9.backgroundColor,
277
+ backgroundColor = _ref9$backgroundColor === void 0 ? null : _ref9$backgroundColor;
264
278
  return backgroundColor === null;
265
279
  }, [inactiveButtonsStyle]);
266
280
  return /*#__PURE__*/React.createElement("div", {
@@ -269,18 +283,18 @@ var Answers = function Answers(_ref) {
269
283
  className: styles$4.items
270
284
  }, transitions(function (style, answer, t, answerI) {
271
285
  var userAnswer = answerI === answeredIndex;
272
- var _ref10 = answer || {},
273
- _ref10$good = _ref10.good,
274
- rightAnswer = _ref10$good === void 0 ? null : _ref10$good,
275
- _ref10$label = _ref10.label,
276
- label = _ref10$label === void 0 ? null : _ref10$label,
277
- _ref10$buttonStyle = _ref10.buttonStyle,
278
- answerButtonStyle = _ref10$buttonStyle === void 0 ? null : _ref10$buttonStyle,
279
- _ref10$textStyle = _ref10.textStyle,
280
- answerButtonTextStyle = _ref10$textStyle === void 0 ? null : _ref10$textStyle;
281
- var _ref11 = label || {},
286
+ var _ref11 = answer || {},
287
+ _ref11$good = _ref11.good,
288
+ rightAnswer = _ref11$good === void 0 ? null : _ref11$good,
289
+ _ref11$label = _ref11.label,
290
+ label = _ref11$label === void 0 ? null : _ref11$label,
291
+ _ref11$buttonStyle = _ref11.buttonStyle,
292
+ answerButtonStyle = _ref11$buttonStyle === void 0 ? null : _ref11$buttonStyle,
282
293
  _ref11$textStyle = _ref11.textStyle,
283
- textStyle = _ref11$textStyle === void 0 ? null : _ref11$textStyle;
294
+ answerButtonTextStyle = _ref11$textStyle === void 0 ? null : _ref11$textStyle;
295
+ var _ref12 = label || {},
296
+ _ref12$textStyle = _ref12.textStyle,
297
+ textStyle = _ref12$textStyle === void 0 ? null : _ref12$textStyle;
284
298
  var hasAnswer = isTextFilled(label);
285
299
  var isUserAnswer = withoutGoodAnswer && userAnswer;
286
300
  var isOtherAnswer = withoutGoodAnswer && !userAnswer;
@@ -316,10 +330,6 @@ var Answers = function Answers(_ref) {
316
330
  onPointerUp: function onPointerUp(e) {
317
331
  if (e.pointerType !== 'mouse' || e.button === 0) {
318
332
  onClick(answer, answerI);
319
- // onTransitionEnd();
320
- // setTimeout(() => {
321
- // onTransitionEnd();
322
- // }, 2000);
323
333
  }
324
334
  },
325
335
  disabled: !visible || isPreview || answered,
@@ -1291,13 +1301,10 @@ var QuizMultipleScreen = function QuizMultipleScreen(_ref) {
1291
1301
  _ref4$resultImage = _ref4.resultImage,
1292
1302
  questionResultImage = _ref4$resultImage === void 0 ? null : _ref4$resultImage;
1293
1303
  var currentAnsweredIndex = userAnswers !== null && typeof userAnswers[questionIndex] !== 'undefined' ? userAnswers[questionIndex] : null;
1294
-
1295
- // const answer =
1296
- // currentAnsweredIndex !== null && typeof answers[currentAnsweredIndex] !== 'undefined'
1297
- // ? answers[currentAnsweredIndex]
1298
- // : null;
1299
- // const { result: answerResult = null } = answer || {};
1300
-
1304
+ var answer = currentAnsweredIndex !== null && typeof answers[currentAnsweredIndex] !== 'undefined' ? answers[currentAnsweredIndex] : null;
1305
+ var _ref5 = answer || {},
1306
+ _ref5$result = _ref5.result,
1307
+ answerResult = _ref5$result === void 0 ? null : _ref5$result;
1301
1308
  var hasTrueFalse = answers !== null ? (answers || []).find(function (ans) {
1302
1309
  return (ans === null || ans === void 0 ? void 0 : ans.good) === true || (ans === null || ans === void 0 ? void 0 : ans.good) === false;
1303
1310
  }) !== undefined : false;
@@ -1307,9 +1314,10 @@ var QuizMultipleScreen = function QuizMultipleScreen(_ref) {
1307
1314
  var withoutGoodAnswer = goodAnswerIndex === null || goodAnswerIndex === -1;
1308
1315
  var questionResultHasText = isTextFilled(questionResult);
1309
1316
  var questionResultHasImage = isImageFilled(questionResultImage);
1310
- // const answerResultHasText = isTextFilled(answerResult);
1311
- var hasResult = questionResultHasText || questionResultHasImage;
1317
+ var answerResultHasText = isTextFilled(answerResult);
1318
+ var hasResult = questionResultHasText || questionResultHasImage || answerResultHasText;
1312
1319
  var onNextSlide = useCallback(function () {
1320
+ // console.log('onNextSlide', isEdit, isPreview);
1313
1321
  if (isEdit || isPreview) {
1314
1322
  return;
1315
1323
  }
@@ -1323,13 +1331,13 @@ var QuizMultipleScreen = function QuizMultipleScreen(_ref) {
1323
1331
  }, [questions, questionIndex, setQuestionIndex, isEdit, isPreview]);
1324
1332
  var currentPoints = useMemo(function () {
1325
1333
  return userAnswers !== null ? Object.keys(userAnswers).reduce(function (totalPoints, answerQuestionIndex) {
1326
- var _ref5 = questions !== null ? questions[answerQuestionIndex] || {} : {},
1327
- _ref5$answers = _ref5.answers,
1328
- questionAnswers = _ref5$answers === void 0 ? [] : _ref5$answers;
1334
+ var _ref6 = questions !== null ? questions[answerQuestionIndex] || {} : {},
1335
+ _ref6$answers = _ref6.answers,
1336
+ questionAnswers = _ref6$answers === void 0 ? [] : _ref6$answers;
1329
1337
  var answerIndex = userAnswers[answerQuestionIndex];
1330
- var _ref6 = questionAnswers[answerIndex] || {},
1331
- _ref6$points = _ref6.points,
1332
- points = _ref6$points === void 0 ? 0 : _ref6$points;
1338
+ var _ref7 = questionAnswers[answerIndex] || {},
1339
+ _ref7$points = _ref7.points,
1340
+ points = _ref7$points === void 0 ? 0 : _ref7$points;
1333
1341
  return points + totalPoints;
1334
1342
  }, 0) : 0;
1335
1343
  }, [userAnswers, questions]);
@@ -1343,30 +1351,30 @@ var QuizMultipleScreen = function QuizMultipleScreen(_ref) {
1343
1351
  if (stateId === 'results') {
1344
1352
  return (results || [])[parseInt(stateIndex, 10)] || null;
1345
1353
  }
1346
- return (results || []).sort(function (_ref7, _ref8) {
1347
- var _ref7$points = _ref7.points,
1348
- pointsA = _ref7$points === void 0 ? 0 : _ref7$points;
1354
+ return (results || []).sort(function (_ref8, _ref9) {
1349
1355
  var _ref8$points = _ref8.points,
1350
- pointsB = _ref8$points === void 0 ? 0 : _ref8$points;
1356
+ pointsA = _ref8$points === void 0 ? 0 : _ref8$points;
1357
+ var _ref9$points = _ref9.points,
1358
+ pointsB = _ref9$points === void 0 ? 0 : _ref9$points;
1351
1359
  if (pointsA === pointsB) {
1352
1360
  return 0;
1353
1361
  }
1354
1362
  return pointsA > pointsB ? 1 : -1;
1355
1363
  }).reduce(function (lastResult, result) {
1356
- var _ref9 = lastResult || {},
1357
- _ref9$points = _ref9.points,
1358
- lastPoints = _ref9$points === void 0 ? 0 : _ref9$points;
1359
- var _ref10 = result || {},
1364
+ var _ref10 = lastResult || {},
1360
1365
  _ref10$points = _ref10.points,
1361
- points = _ref10$points === void 0 ? 0 : _ref10$points;
1366
+ lastPoints = _ref10$points === void 0 ? 0 : _ref10$points;
1367
+ var _ref11 = result || {},
1368
+ _ref11$points = _ref11.points,
1369
+ points = _ref11$points === void 0 ? 0 : _ref11$points;
1362
1370
  return currentPoints >= (lastPoints || 0) && currentPoints >= points ? result : lastResult;
1363
1371
  }, null);
1364
1372
  }, [isResults, results, currentPoints, stateId, stateIndex]);
1365
- var _ref11 = currentResult || {},
1366
- _ref11$background = _ref11.background,
1367
- resultBackground = _ref11$background === void 0 ? null : _ref11$background,
1368
- _ref11$layout = _ref11.layout,
1369
- resultLayout = _ref11$layout === void 0 ? null : _ref11$layout;
1373
+ var _ref12 = currentResult || {},
1374
+ _ref12$background = _ref12.background,
1375
+ resultBackground = _ref12$background === void 0 ? null : _ref12$background,
1376
+ _ref12$layout = _ref12.layout,
1377
+ resultLayout = _ref12$layout === void 0 ? null : _ref12$layout;
1370
1378
  var _useQuizCreate = useQuizCreate({
1371
1379
  screenId: screenId
1372
1380
  }),
@@ -1426,8 +1434,8 @@ var QuizMultipleScreen = function QuizMultipleScreen(_ref) {
1426
1434
  _useState6 = _slicedToArray(_useState5, 2),
1427
1435
  scrolledBottom = _useState6[0],
1428
1436
  setScrolledBottom = _useState6[1];
1429
- var onScrolledBottom = useCallback(function (_ref12) {
1430
- var initial = _ref12.initial;
1437
+ var onScrolledBottom = useCallback(function (_ref13) {
1438
+ var initial = _ref13.initial;
1431
1439
  if (initial) {
1432
1440
  trackScreenEvent('scroll', 'Screen');
1433
1441
  }
@@ -1440,9 +1448,9 @@ var QuizMultipleScreen = function QuizMultipleScreen(_ref) {
1440
1448
  _useState8 = _slicedToArray(_useState7, 2),
1441
1449
  hasScroll = _useState8[0],
1442
1450
  setHasScroll = _useState8[1];
1443
- var onScrollHeightChange = useCallback(function (_ref13) {
1444
- var _ref13$canScroll = _ref13.canScroll,
1445
- canScroll = _ref13$canScroll === void 0 ? false : _ref13$canScroll;
1451
+ var onScrollHeightChange = useCallback(function (_ref14) {
1452
+ var _ref14$canScroll = _ref14.canScroll,
1453
+ canScroll = _ref14$canScroll === void 0 ? false : _ref14$canScroll;
1446
1454
  setHasScroll(canScroll);
1447
1455
  }, [setHasScroll]);
1448
1456
  var onQuizReset = useCallback(function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micromag/screen-quiz",
3
- "version": "0.3.673",
3
+ "version": "0.3.676",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "keywords": [
@@ -63,19 +63,19 @@
63
63
  "@fortawesome/fontawesome-svg-core": "^6.5.2",
64
64
  "@fortawesome/free-solid-svg-icons": "^6.5.2",
65
65
  "@fortawesome/react-fontawesome": "^0.2.0",
66
- "@micromag/core": "^0.3.673",
67
- "@micromag/data": "^0.3.673",
68
- "@micromag/element-background": "^0.3.673",
69
- "@micromag/element-button": "^0.3.673",
70
- "@micromag/element-container": "^0.3.673",
71
- "@micromag/element-footer": "^0.3.673",
72
- "@micromag/element-header": "^0.3.673",
73
- "@micromag/element-heading": "^0.3.673",
74
- "@micromag/element-layout": "^0.3.673",
75
- "@micromag/element-scroll": "^0.3.673",
76
- "@micromag/element-text": "^0.3.673",
77
- "@micromag/element-visual": "^0.3.673",
78
- "@micromag/transforms": "^0.3.673",
66
+ "@micromag/core": "^0.3.676",
67
+ "@micromag/data": "^0.3.676",
68
+ "@micromag/element-background": "^0.3.676",
69
+ "@micromag/element-button": "^0.3.676",
70
+ "@micromag/element-container": "^0.3.676",
71
+ "@micromag/element-footer": "^0.3.676",
72
+ "@micromag/element-header": "^0.3.676",
73
+ "@micromag/element-heading": "^0.3.676",
74
+ "@micromag/element-layout": "^0.3.676",
75
+ "@micromag/element-scroll": "^0.3.676",
76
+ "@micromag/element-text": "^0.3.676",
77
+ "@micromag/element-visual": "^0.3.676",
78
+ "@micromag/transforms": "^0.3.676",
79
79
  "@react-spring/core": "^9.6.1",
80
80
  "@react-spring/web": "^9.6.1",
81
81
  "classnames": "^2.2.6",
@@ -89,5 +89,5 @@
89
89
  "access": "public",
90
90
  "registry": "https://registry.npmjs.org/"
91
91
  },
92
- "gitHead": "6bcd614e97a55a542e28528433b2815be9c487fc"
92
+ "gitHead": "941f3a10c4de917c02ca81f39e6d15a85094e289"
93
93
  }