@micromag/screen-quiz 0.3.663 → 0.3.667
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/es/index.js +67 -14
- package/package.json +15 -15
package/es/index.js
CHANGED
|
@@ -51,6 +51,7 @@ var propTypes$5 = {
|
|
|
51
51
|
onCollapse: PropTypes.func,
|
|
52
52
|
onCollapsed: PropTypes.func,
|
|
53
53
|
onTransitionEnd: PropTypes.func,
|
|
54
|
+
withoutCollapse: PropTypes.bool,
|
|
54
55
|
className: PropTypes.string
|
|
55
56
|
};
|
|
56
57
|
var defaultProps$5 = {
|
|
@@ -72,6 +73,7 @@ var defaultProps$5 = {
|
|
|
72
73
|
onCollapse: null,
|
|
73
74
|
onCollapsed: null,
|
|
74
75
|
onTransitionEnd: null,
|
|
76
|
+
withoutCollapse: false,
|
|
75
77
|
className: null
|
|
76
78
|
};
|
|
77
79
|
var Answers = function Answers(_ref) {
|
|
@@ -94,6 +96,7 @@ var Answers = function Answers(_ref) {
|
|
|
94
96
|
onCollapse = _ref.onCollapse,
|
|
95
97
|
onCollapsed = _ref.onCollapsed,
|
|
96
98
|
onTransitionEnd = _ref.onTransitionEnd,
|
|
99
|
+
withoutCollapse = _ref.withoutCollapse,
|
|
97
100
|
className = _ref.className;
|
|
98
101
|
var _useScreenRenderConte = useScreenRenderContext(),
|
|
99
102
|
isView = _useScreenRenderConte.isView,
|
|
@@ -114,7 +117,7 @@ var Answers = function Answers(_ref) {
|
|
|
114
117
|
return hasGood || good;
|
|
115
118
|
}, false) : false;
|
|
116
119
|
var finalShowUserAnswer = showUserAnswer || !hasRightAnswer;
|
|
117
|
-
var shouldCollapse = !withoutGoodAnswer || finalShowUserAnswer && answeredIndex !== null;
|
|
120
|
+
var shouldCollapse = (!withoutGoodAnswer || finalShowUserAnswer && answeredIndex !== null) && !withoutCollapse;
|
|
118
121
|
var _useState3 = useState(answeredIndex !== null),
|
|
119
122
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
120
123
|
answersCollapsed = _useState4[0],
|
|
@@ -136,6 +139,18 @@ var Answers = function Answers(_ref) {
|
|
|
136
139
|
onCollapse();
|
|
137
140
|
}
|
|
138
141
|
}, hasAnsweredRight || finalShowUserAnswer ? 500 : answersCollapseDelay);
|
|
142
|
+
} else if (answeredIndex !== null && !shouldCollapse) {
|
|
143
|
+
timeout = setTimeout(function () {
|
|
144
|
+
if (onCollapse !== null) {
|
|
145
|
+
onCollapse();
|
|
146
|
+
}
|
|
147
|
+
if (onCollapsed !== null) {
|
|
148
|
+
onCollapsed();
|
|
149
|
+
}
|
|
150
|
+
if (onTransitionEnd !== null) {
|
|
151
|
+
onTransitionEnd();
|
|
152
|
+
}
|
|
153
|
+
}, answersCollapseDelay);
|
|
139
154
|
} else if (answeredIndex === null && shouldCollapse) {
|
|
140
155
|
setAnswersCollapsed(false);
|
|
141
156
|
}
|
|
@@ -144,7 +159,7 @@ var Answers = function Answers(_ref) {
|
|
|
144
159
|
clearTimeout(timeout);
|
|
145
160
|
}
|
|
146
161
|
};
|
|
147
|
-
}, [answeredIndex, withoutGoodAnswer, setAnswersCollapsed, onCollapse, answersCollapseDelay, hasAnsweredRight, finalShowUserAnswer]);
|
|
162
|
+
}, [answeredIndex, withoutGoodAnswer, setAnswersCollapsed, onCollapse, onCollapsed, onTransitionEnd, answersCollapseDelay, hasAnsweredRight, finalShowUserAnswer, shouldCollapse]);
|
|
148
163
|
useEffect(function () {
|
|
149
164
|
var timeout = null;
|
|
150
165
|
if (answersCollapsed) {
|
|
@@ -351,6 +366,7 @@ var propTypes$4 = {
|
|
|
351
366
|
inactiveButtonsTextStyle: PropTypes$1.textStyle,
|
|
352
367
|
questionsHeadingStyle: PropTypes$1.textStyle,
|
|
353
368
|
feedbackTextStyle: PropTypes$1.textStyle,
|
|
369
|
+
numbersTextStyle: PropTypes$1.textStyle,
|
|
354
370
|
goodAnswerColor: PropTypes$1.color,
|
|
355
371
|
badAnswerColor: PropTypes$1.color,
|
|
356
372
|
focusable: PropTypes.bool,
|
|
@@ -367,6 +383,7 @@ var propTypes$4 = {
|
|
|
367
383
|
transitionDisabled: PropTypes.bool,
|
|
368
384
|
onAnswerClick: PropTypes.func,
|
|
369
385
|
onAnswerTransitionEnd: PropTypes.func,
|
|
386
|
+
withoutCollapse: PropTypes.bool,
|
|
370
387
|
className: PropTypes.string,
|
|
371
388
|
style: PropTypes.objectOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number]))
|
|
372
389
|
};
|
|
@@ -384,6 +401,7 @@ var defaultProps$4 = {
|
|
|
384
401
|
inactiveButtonsTextStyle: null,
|
|
385
402
|
questionsHeadingStyle: null,
|
|
386
403
|
feedbackTextStyle: null,
|
|
404
|
+
numbersTextStyle: null,
|
|
387
405
|
goodAnswerColor: null,
|
|
388
406
|
badAnswerColor: null,
|
|
389
407
|
focusable: false,
|
|
@@ -400,6 +418,7 @@ var defaultProps$4 = {
|
|
|
400
418
|
transitionDisabled: false,
|
|
401
419
|
onAnswerClick: null,
|
|
402
420
|
onAnswerTransitionEnd: null,
|
|
421
|
+
withoutCollapse: false,
|
|
403
422
|
className: null,
|
|
404
423
|
style: null
|
|
405
424
|
};
|
|
@@ -417,6 +436,7 @@ var Question = function Question(_ref) {
|
|
|
417
436
|
inactiveButtonsTextStyle = _ref.inactiveButtonsTextStyle,
|
|
418
437
|
questionsHeadingStyle = _ref.questionsHeadingStyle,
|
|
419
438
|
feedbackTextStyle = _ref.feedbackTextStyle,
|
|
439
|
+
numbersTextStyle = _ref.numbersTextStyle,
|
|
420
440
|
goodAnswerColor = _ref.goodAnswerColor,
|
|
421
441
|
badAnswerColor = _ref.badAnswerColor,
|
|
422
442
|
focusable = _ref.focusable,
|
|
@@ -433,6 +453,7 @@ var Question = function Question(_ref) {
|
|
|
433
453
|
transitionDisabled = _ref.transitionDisabled,
|
|
434
454
|
onAnswerClick = _ref.onAnswerClick,
|
|
435
455
|
onAnswerTransitionEnd = _ref.onAnswerTransitionEnd,
|
|
456
|
+
withoutCollapse = _ref.withoutCollapse,
|
|
436
457
|
className = _ref.className,
|
|
437
458
|
style = _ref.style;
|
|
438
459
|
var _useScreenRenderConte = useScreenRenderContext(),
|
|
@@ -479,9 +500,11 @@ var Question = function Question(_ref) {
|
|
|
479
500
|
transitions: transitions,
|
|
480
501
|
playing: transitionPlaying,
|
|
481
502
|
disabled: transitionDisabled
|
|
482
|
-
}, /*#__PURE__*/React.createElement(
|
|
483
|
-
className: styles$3.index
|
|
484
|
-
|
|
503
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
504
|
+
className: styles$3.index,
|
|
505
|
+
body: "".concat(index + 1, " / ").concat(totalCount),
|
|
506
|
+
textStyle: numbersTextStyle
|
|
507
|
+
})) : null) : null, /*#__PURE__*/React.createElement(ScreenElement, {
|
|
485
508
|
key: "question",
|
|
486
509
|
placeholder: "title",
|
|
487
510
|
emptyLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
@@ -523,9 +546,10 @@ var Question = function Question(_ref) {
|
|
|
523
546
|
transitionDisabled: transitionDisabled,
|
|
524
547
|
onClick: onAnswerClick,
|
|
525
548
|
onCollapse: onAnswersCollapse,
|
|
526
|
-
onTransitionEnd: onAnswerTransitionEnd
|
|
549
|
+
onTransitionEnd: onAnswerTransitionEnd,
|
|
550
|
+
withoutCollapse: withoutCollapse
|
|
527
551
|
}), withResult ? /*#__PURE__*/React.createElement("div", {
|
|
528
|
-
className:
|
|
552
|
+
className: styles$3.result,
|
|
529
553
|
key: "results"
|
|
530
554
|
}, /*#__PURE__*/React.createElement("div", {
|
|
531
555
|
className: styles$3.resultContent
|
|
@@ -573,6 +597,7 @@ var propTypes$3 = {
|
|
|
573
597
|
buttonsTextStyle: PropTypes$1.textStyle,
|
|
574
598
|
inactiveButtonsTextStyle: PropTypes$1.textStyle,
|
|
575
599
|
feedbackTextStyle: PropTypes$1.textStyle,
|
|
600
|
+
numbersTextStyle: PropTypes$1.textStyle,
|
|
576
601
|
goodAnswerColor: PropTypes$1.color,
|
|
577
602
|
badAnswerColor: PropTypes$1.color,
|
|
578
603
|
withoutTrueFalse: PropTypes.bool,
|
|
@@ -600,6 +625,7 @@ var defaultProps$3 = {
|
|
|
600
625
|
buttonsTextStyle: null,
|
|
601
626
|
inactiveButtonsTextStyle: null,
|
|
602
627
|
feedbackTextStyle: null,
|
|
628
|
+
numbersTextStyle: null,
|
|
603
629
|
goodAnswerColor: null,
|
|
604
630
|
badAnswerColor: null,
|
|
605
631
|
withoutTrueFalse: false,
|
|
@@ -627,6 +653,7 @@ var QuizScreen = function QuizScreen(_ref) {
|
|
|
627
653
|
buttonsTextStyle = _ref.buttonsTextStyle,
|
|
628
654
|
inactiveButtonsTextStyle = _ref.inactiveButtonsTextStyle,
|
|
629
655
|
feedbackTextStyle = _ref.feedbackTextStyle,
|
|
656
|
+
numbersTextStyle = _ref.numbersTextStyle,
|
|
630
657
|
goodAnswerColor = _ref.goodAnswerColor,
|
|
631
658
|
badAnswerColor = _ref.badAnswerColor,
|
|
632
659
|
withoutTrueFalse = _ref.withoutTrueFalse,
|
|
@@ -809,6 +836,7 @@ var QuizScreen = function QuizScreen(_ref) {
|
|
|
809
836
|
inactiveButtonsStyle: inactiveButtonsStyle,
|
|
810
837
|
inactiveButtonsTextStyle: inactiveButtonsTextStyle,
|
|
811
838
|
feedbackTextStyle: feedbackTextStyle,
|
|
839
|
+
numbersTextStyle: numbersTextStyle,
|
|
812
840
|
goodAnswerColor: goodAnswerColor,
|
|
813
841
|
badAnswerColor: badAnswerColor,
|
|
814
842
|
withoutTrueFalse: withoutTrueFalse,
|
|
@@ -1074,6 +1102,8 @@ var propTypes = {
|
|
|
1074
1102
|
questionsHeadingStyle: PropTypes$1.textStyle,
|
|
1075
1103
|
resultsHeadingStyle: PropTypes$1.textStyle,
|
|
1076
1104
|
resultsTextStyle: PropTypes$1.textStyle,
|
|
1105
|
+
feedbackTextStyle: PropTypes$1.textStyle,
|
|
1106
|
+
numbersTextStyle: PropTypes$1.textStyle,
|
|
1077
1107
|
goodAnswerColor: PropTypes$1.color,
|
|
1078
1108
|
badAnswerColor: PropTypes$1.color,
|
|
1079
1109
|
spacing: PropTypes.number,
|
|
@@ -1105,6 +1135,8 @@ var defaultProps = {
|
|
|
1105
1135
|
questionsHeadingStyle: null,
|
|
1106
1136
|
resultsHeadingStyle: null,
|
|
1107
1137
|
resultsTextStyle: null,
|
|
1138
|
+
feedbackTextStyle: null,
|
|
1139
|
+
numbersTextStyle: null,
|
|
1108
1140
|
goodAnswerColor: null,
|
|
1109
1141
|
badAnswerColor: null,
|
|
1110
1142
|
spacing: 20,
|
|
@@ -1136,6 +1168,8 @@ var QuizMultipleScreen = function QuizMultipleScreen(_ref) {
|
|
|
1136
1168
|
questionsHeadingStyle = _ref.questionsHeadingStyle,
|
|
1137
1169
|
resultsHeadingStyle = _ref.resultsHeadingStyle,
|
|
1138
1170
|
resultsTextStyle = _ref.resultsTextStyle,
|
|
1171
|
+
feedbackTextStyle = _ref.feedbackTextStyle,
|
|
1172
|
+
numbersTextStyle = _ref.numbersTextStyle,
|
|
1139
1173
|
goodAnswerColor = _ref.goodAnswerColor,
|
|
1140
1174
|
badAnswerColor = _ref.badAnswerColor,
|
|
1141
1175
|
spacing = _ref.spacing,
|
|
@@ -1261,11 +1295,17 @@ var QuizMultipleScreen = function QuizMultipleScreen(_ref) {
|
|
|
1261
1295
|
var _ref5 = answer || {},
|
|
1262
1296
|
_ref5$result = _ref5.result,
|
|
1263
1297
|
answerResult = _ref5$result === void 0 ? null : _ref5$result;
|
|
1264
|
-
var
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1298
|
+
var hasTrueFalse = answers !== null ? (answers || []).find(function (ans) {
|
|
1299
|
+
return (ans === null || ans === void 0 ? void 0 : ans.good) === true || (ans === null || ans === void 0 ? void 0 : ans.good) === false;
|
|
1300
|
+
}) !== undefined : false;
|
|
1301
|
+
var goodAnswerIndex = answers !== null ? answers.findIndex(function (ans) {
|
|
1302
|
+
return ans !== null && ans.good === true;
|
|
1303
|
+
}) : null;
|
|
1304
|
+
var withoutGoodAnswer = goodAnswerIndex === null || goodAnswerIndex === -1;
|
|
1305
|
+
var questionResultHasText = isTextFilled(questionResult);
|
|
1306
|
+
var questionResultHasImage = isImageFilled(questionResultImage);
|
|
1307
|
+
var answerResultHasText = isTextFilled(answerResult);
|
|
1308
|
+
var hasResult = questionResultHasText || questionResultHasImage || answerResultHasText;
|
|
1269
1309
|
var onNextSlide = useCallback(function () {
|
|
1270
1310
|
if (isEdit) {
|
|
1271
1311
|
return;
|
|
@@ -1492,6 +1532,8 @@ var QuizMultipleScreen = function QuizMultipleScreen(_ref) {
|
|
|
1492
1532
|
buttonsTextStyle: buttonsTextStyle,
|
|
1493
1533
|
inactiveButtonsTextStyle: inactiveButtonsTextStyle,
|
|
1494
1534
|
questionsHeadingStyle: questionsHeadingStyle,
|
|
1535
|
+
feedbackTextStyle: feedbackTextStyle,
|
|
1536
|
+
numbersTextStyle: numbersTextStyle,
|
|
1495
1537
|
goodAnswerColor: goodAnswerColor,
|
|
1496
1538
|
badAnswerColor: badAnswerColor,
|
|
1497
1539
|
focusable: current && isView,
|
|
@@ -1500,8 +1542,9 @@ var QuizMultipleScreen = function QuizMultipleScreen(_ref) {
|
|
|
1500
1542
|
result: questionResult,
|
|
1501
1543
|
resultImage: questionResultImage,
|
|
1502
1544
|
withResult: hasResult,
|
|
1503
|
-
withoutGoodAnswer:
|
|
1504
|
-
withoutTrueFalse:
|
|
1545
|
+
withoutGoodAnswer: withoutGoodAnswer,
|
|
1546
|
+
withoutTrueFalse: !hasTrueFalse,
|
|
1547
|
+
withoutCollapse: hasTrueFalse,
|
|
1505
1548
|
transitions: transitions,
|
|
1506
1549
|
transitionPlaying: transitionPlaying,
|
|
1507
1550
|
transitionStagger: transitionStagger,
|
|
@@ -2145,6 +2188,16 @@ var definition = [{
|
|
|
2145
2188
|
"value": "Results description"
|
|
2146
2189
|
}]
|
|
2147
2190
|
})
|
|
2191
|
+
}, {
|
|
2192
|
+
name: 'numbersTextStyle',
|
|
2193
|
+
type: 'text-style-form',
|
|
2194
|
+
label: defineMessage({
|
|
2195
|
+
id: "iltluX",
|
|
2196
|
+
defaultMessage: [{
|
|
2197
|
+
"type": 0,
|
|
2198
|
+
"value": "Numbers text"
|
|
2199
|
+
}]
|
|
2200
|
+
})
|
|
2148
2201
|
}]
|
|
2149
2202
|
}, {
|
|
2150
2203
|
name: 'nextButton',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micromag/screen-quiz",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.667",
|
|
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.
|
|
67
|
-
"@micromag/data": "^0.3.
|
|
68
|
-
"@micromag/element-background": "^0.3.
|
|
69
|
-
"@micromag/element-button": "^0.3.
|
|
70
|
-
"@micromag/element-container": "^0.3.
|
|
71
|
-
"@micromag/element-footer": "^0.3.
|
|
72
|
-
"@micromag/element-header": "^0.3.
|
|
73
|
-
"@micromag/element-heading": "^0.3.
|
|
74
|
-
"@micromag/element-layout": "^0.3.
|
|
75
|
-
"@micromag/element-scroll": "^0.3.
|
|
76
|
-
"@micromag/element-text": "^0.3.
|
|
77
|
-
"@micromag/element-visual": "^0.3.
|
|
78
|
-
"@micromag/transforms": "^0.3.
|
|
66
|
+
"@micromag/core": "^0.3.667",
|
|
67
|
+
"@micromag/data": "^0.3.667",
|
|
68
|
+
"@micromag/element-background": "^0.3.667",
|
|
69
|
+
"@micromag/element-button": "^0.3.667",
|
|
70
|
+
"@micromag/element-container": "^0.3.667",
|
|
71
|
+
"@micromag/element-footer": "^0.3.667",
|
|
72
|
+
"@micromag/element-header": "^0.3.667",
|
|
73
|
+
"@micromag/element-heading": "^0.3.667",
|
|
74
|
+
"@micromag/element-layout": "^0.3.667",
|
|
75
|
+
"@micromag/element-scroll": "^0.3.667",
|
|
76
|
+
"@micromag/element-text": "^0.3.667",
|
|
77
|
+
"@micromag/element-visual": "^0.3.667",
|
|
78
|
+
"@micromag/transforms": "^0.3.667",
|
|
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": "
|
|
92
|
+
"gitHead": "8974de0b7dbe3ab5d632d0449b7a25ee20336a1c"
|
|
93
93
|
}
|