@micromag/screen-quiz 0.3.816 → 0.3.820

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}.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-withSquareItems .micromag-screen-quiz-answers-button{aspect-ratio:1}.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:34px;justify-content:center;margin-top:-18px;opacity:0;padding:5px;-webkit-transition:opacity .15s ease;transition:opacity .15s ease;width:34px}.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;height:24px}.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
@@ -5,12 +5,12 @@ import { faRedo } from '@fortawesome/free-solid-svg-icons/faRedo';
5
5
  import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
6
6
  import classNames from 'classnames';
7
7
  import PropTypes from 'prop-types';
8
- import React, { useState, useEffect, useCallback, useRef, useMemo } from 'react';
8
+ import React, { useState, useEffect, useRef, useMemo, useCallback } from 'react';
9
9
  import { PropTypes as PropTypes$1 } from '@micromag/core';
10
- import { ScreenElement, Transitions, Button as Button$1 } from '@micromag/core/components';
10
+ import { ScreenElement, Transitions, Button } from '@micromag/core/components';
11
11
  import { useScreenRenderContext, useScreenSize, useViewerContext, useViewerWebView, usePlaybackContext, usePlaybackMediaRef, useScreenState } from '@micromag/core/contexts';
12
12
  import { useTrackScreenEvent, useDimensionObserver } from '@micromag/core/hooks';
13
- import { isTextFilled, getStyleFromColor, isImageFilled, isHeaderFilled, isFooterFilled, getFooterProps } from '@micromag/core/utils';
13
+ import { isTextFilled, isImageFilled, getStyleFromColor, isHeaderFilled, isFooterFilled, getFooterProps } from '@micromag/core/utils';
14
14
  import { useQuizCreate } from '@micromag/data';
15
15
  import Background from '@micromag/element-background';
16
16
  import Container from '@micromag/element-container';
@@ -25,14 +25,16 @@ import Visual from '@micromag/element-visual';
25
25
  import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
26
26
  import { faCheck } from '@fortawesome/free-solid-svg-icons/faCheck';
27
27
  import { faTimes } from '@fortawesome/free-solid-svg-icons/faTimes';
28
- import { animated, useTransition, easings } from '@react-spring/web';
29
- import Button from '@micromag/element-button';
28
+ import { animated } from '@react-spring/web';
29
+ import Button$1, { RichButton } from '@micromag/element-button';
30
+ import Keypad from '@micromag/element-keypad';
30
31
  import { TransitionGroup, CSSTransition } from 'react-transition-group';
31
32
 
32
- var styles$4 = {"emptyAnswer":"micromag-screen-quiz-answers-emptyAnswer","button":"micromag-screen-quiz-answers-button","container":"micromag-screen-quiz-answers-container","items":"micromag-screen-quiz-answers-items","item":"micromag-screen-quiz-answers-item","isPlaceholder":"micromag-screen-quiz-answers-isPlaceholder","userAnswer":"micromag-screen-quiz-answers-userAnswer","otherAnswer":"micromag-screen-quiz-answers-otherAnswer","withoutOpacity":"micromag-screen-quiz-answers-withoutOpacity","withIcon":"micromag-screen-quiz-answers-withIcon","resultIcon":"micromag-screen-quiz-answers-resultIcon","answered":"micromag-screen-quiz-answers-answered","rightAnswer":"micromag-screen-quiz-answers-rightAnswer","faIcon":"micromag-screen-quiz-answers-faIcon","itemContent":"micromag-screen-quiz-answers-itemContent"};
33
+ var styles$4 = {"emptyAnswer":"micromag-screen-quiz-answers-emptyAnswer","button":"micromag-screen-quiz-answers-button","container":"micromag-screen-quiz-answers-container","items":"micromag-screen-quiz-answers-items","item":"micromag-screen-quiz-answers-item","isPlaceholder":"micromag-screen-quiz-answers-isPlaceholder","userAnswer":"micromag-screen-quiz-answers-userAnswer","otherAnswer":"micromag-screen-quiz-answers-otherAnswer","withoutOpacity":"micromag-screen-quiz-answers-withoutOpacity","withIcon":"micromag-screen-quiz-answers-withIcon","withSquareItems":"micromag-screen-quiz-answers-withSquareItems","resultIcon":"micromag-screen-quiz-answers-resultIcon","answered":"micromag-screen-quiz-answers-answered","rightAnswer":"micromag-screen-quiz-answers-rightAnswer","faIcon":"micromag-screen-quiz-answers-faIcon","itemContent":"micromag-screen-quiz-answers-itemContent"};
33
34
 
34
35
  var propTypes$5 = {
35
36
  items: PropTypes$1.quizAnswers.isRequired,
37
+ keypadLayout: PropTypes.shape({}),
36
38
  answeredIndex: PropTypes.number,
37
39
  answersCollapseDelay: PropTypes.number,
38
40
  buttonsStyle: PropTypes$1.boxStyle,
@@ -55,6 +57,7 @@ var propTypes$5 = {
55
57
  className: PropTypes.string
56
58
  };
57
59
  var defaultProps$5 = {
60
+ keypadLayout: null,
58
61
  answeredIndex: null,
59
62
  answersCollapseDelay: 1000,
60
63
  buttonsStyle: null,
@@ -78,6 +81,7 @@ var defaultProps$5 = {
78
81
  };
79
82
  var Answers = function Answers(_ref) {
80
83
  var items = _ref.items,
84
+ keypadLayout = _ref.keypadLayout,
81
85
  answeredIndex = _ref.answeredIndex,
82
86
  answersCollapseDelay = _ref.answersCollapseDelay,
83
87
  buttonsStyle = _ref.buttonsStyle,
@@ -124,8 +128,8 @@ var Answers = function Answers(_ref) {
124
128
  setAnswersCollapsed = _useState4[1];
125
129
  var _useState5 = useState(initialCollapsed || answeredIndex !== null),
126
130
  _useState6 = _slicedToArray(_useState5, 2),
127
- answersDidCollapse = _useState6[0],
128
- setAnswersDidCollapse = _useState6[1];
131
+ answersDidCollapse = _useState6[0];
132
+ _useState6[1];
129
133
  var _useState7 = useState(initialCollapsed || answeredIndex !== null),
130
134
  _useState8 = _slicedToArray(_useState7, 2),
131
135
  answersFinalCollapse = _useState8[0],
@@ -185,19 +189,25 @@ var Answers = function Answers(_ref) {
185
189
  }
186
190
  };
187
191
  }, [answersCollapsed, onTransitionEnd, setAnswersFinalCollapse]);
188
- var _useState9 = useState(false),
189
- _useState0 = _slicedToArray(_useState9, 2),
190
- transitioned = _useState0[0],
191
- setTransitioned = _useState0[1];
192
- var onAnswerTransitionEnd = useCallback(function () {
193
- setTransitioned(true);
194
- if (shouldCollapse && answersCollapsed && !answersDidCollapse) {
195
- setAnswersDidCollapse(true);
196
- if (onCollapsed !== null) {
197
- onCollapsed();
198
- }
199
- }
200
- }, [shouldCollapse, answersCollapsed, answersDidCollapse, setAnswersCollapsed, onCollapsed, onTransitionEnd]);
192
+
193
+ // const [transitioned, setTransitioned] = useState(false);
194
+ // const onAnswerTransitionEnd = useCallback(() => {
195
+ // setTransitioned(true);
196
+ // if (shouldCollapse && answersCollapsed && !answersDidCollapse) {
197
+ // setAnswersDidCollapse(true);
198
+ // if (onCollapsed !== null) {
199
+ // onCollapsed();
200
+ // }
201
+ // }
202
+ // }, [
203
+ // shouldCollapse,
204
+ // answersCollapsed,
205
+ // answersDidCollapse,
206
+ // setAnswersCollapsed,
207
+ // onCollapsed,
208
+ // onTransitionEnd,
209
+ // ]);
210
+
201
211
  var itemsRefs = useRef([]);
202
212
  var listOfItems = isPlaceholder || isEdit && items.length === 0 ? _toConsumableArray(new Array(2)) : items;
203
213
  var heights = useMemo(function () {
@@ -241,61 +251,97 @@ var Answers = function Answers(_ref) {
241
251
  key: key
242
252
  });
243
253
  });
244
- var transitions = useTransition(filteredListOfItems, {
245
- key: function key(_ref7) {
246
- var _key = _ref7.key;
247
- return _key;
248
- },
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;
254
- return {
255
- opacity: hidden && showAnimation && !withoutGoodAnswer ? 0 : 1,
256
- // Animate this, not height
257
- maxHeight:
258
- // eslint-disable-next-line no-nested-ternary
259
- hidden && showAnimation && !withoutGoodAnswer && collapseAnimated && answersFinalCollapse ? 0 : maxHeight > 0 ? maxHeight : null,
260
- height: hidden && showAnimation && !withoutGoodAnswer && !collapseAnimated && answersFinalCollapse ? 0 : 'auto'
261
- };
262
- },
263
- // config: { tension: 300, friction: 35 },
264
- config: {
265
- duration: 300,
266
- easing: easings.easeOutSine
267
- }
268
- });
269
- useEffect(function () {
270
- if (transitioned && onTransitionEnd !== null) {
271
- onTransitionEnd();
254
+
255
+ // const transitions = useTransition(filteredListOfItems, {
256
+ // key: ({ key }) => key,
257
+ // update: ({ hidden = false, maxHeight = 0 }) => ({
258
+ // opacity: hidden && showAnimation && !withoutGoodAnswer ? 0 : 1,
259
+ // // Animate this, not height
260
+ // maxHeight:
261
+ // // eslint-disable-next-line no-nested-ternary
262
+ // hidden &&
263
+ // showAnimation &&
264
+ // !withoutGoodAnswer &&
265
+ // collapseAnimated &&
266
+ // answersFinalCollapse
267
+ // ? 0
268
+ // : maxHeight > 0
269
+ // ? maxHeight
270
+ // : null,
271
+ // height:
272
+ // hidden &&
273
+ // showAnimation &&
274
+ // !withoutGoodAnswer &&
275
+ // !collapseAnimated &&
276
+ // answersFinalCollapse
277
+ // ? 0
278
+ // : 'auto',
279
+ // }),
280
+ // // config: { tension: 300, friction: 35 },
281
+ // config: { duration: 300, easing: easings.easeOutSine },
282
+ // });
283
+
284
+ // useEffect(() => {
285
+ // if (transitioned && onTransitionEnd !== null) {
286
+ // onTransitionEnd();
287
+ // }
288
+ // }, [transitioned, onTransitionEnd]);
289
+
290
+ var hasGoodOrBadAnswerInList = useMemo(function () {
291
+ if (filteredListOfItems !== null) {
292
+ return filteredListOfItems.reduce(function (hasGoodOrBad, answer) {
293
+ return hasGoodOrBad || answer.good === true && !withoutGoodAnswer || answer.good === false && !withoutIcon;
294
+ }, false);
272
295
  }
273
- }, [transitioned, onTransitionEnd]);
296
+ return false;
297
+ }, [filteredListOfItems, withoutGoodAnswer, withoutIcon]);
274
298
  var hasOpacity = useMemo(function () {
275
- var _ref9 = inactiveButtonsStyle || {},
276
- _ref9$backgroundColor = _ref9.backgroundColor,
277
- backgroundColor = _ref9$backgroundColor === void 0 ? null : _ref9$backgroundColor;
299
+ var _ref7 = inactiveButtonsStyle || {},
300
+ _ref7$backgroundColor = _ref7.backgroundColor,
301
+ backgroundColor = _ref7$backgroundColor === void 0 ? null : _ref7$backgroundColor;
278
302
  return backgroundColor === null;
279
303
  }, [inactiveButtonsStyle]);
280
- return /*#__PURE__*/React.createElement("div", {
281
- className: classNames([styles$4.container, _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, styles$4.answered, answered), styles$4.withIcon, !withoutIcon), styles$4.isPlaceholder, isPlaceholder), className, className !== null)])
282
- }, filteredListOfItems !== null || isPlaceholder ? /*#__PURE__*/React.createElement("div", {
283
- className: styles$4.items
284
- }, transitions(function (style, answer, t, answerI) {
304
+ var itemsWithStyle = filteredListOfItems.map(function (answer) {
305
+ var _ref8 = answer || {},
306
+ hidden = _ref8.hidden,
307
+ maxHeight = _ref8.maxHeight;
308
+ var style = {
309
+ opacity: hidden && showAnimation && !withoutGoodAnswer ? 0 : 1,
310
+ // Animate this, not height
311
+ maxHeight:
312
+ // eslint-disable-next-line no-nested-ternary
313
+ hidden && showAnimation && !withoutGoodAnswer && collapseAnimated && answersFinalCollapse ? 0 : maxHeight > 0 ? maxHeight : null,
314
+ height: hidden && showAnimation && !withoutGoodAnswer && !collapseAnimated && answersFinalCollapse ? 0 : 'auto'
315
+ };
316
+ return _objectSpread(_objectSpread({}, answer), {}, {
317
+ style: style
318
+ });
319
+ });
320
+
321
+ // const keypadItems = transitions((style, answer, t, answerI) => {
322
+ var keypadItems = (itemsWithStyle || []).map(function (answer, answerI) {
285
323
  var userAnswer = answerI === answeredIndex;
286
- var _ref1 = answer || {},
287
- _ref1$good = _ref1.good,
288
- rightAnswer = _ref1$good === void 0 ? null : _ref1$good,
289
- _ref1$label = _ref1.label,
290
- label = _ref1$label === void 0 ? null : _ref1$label,
291
- _ref1$buttonStyle = _ref1.buttonStyle,
292
- answerButtonStyle = _ref1$buttonStyle === void 0 ? null : _ref1$buttonStyle,
293
- _ref1$textStyle = _ref1.textStyle,
294
- answerButtonTextStyle = _ref1$textStyle === void 0 ? null : _ref1$textStyle;
295
- var _ref10 = label || {},
296
- _ref10$textStyle = _ref10.textStyle,
297
- textStyle = _ref10$textStyle === void 0 ? null : _ref10$textStyle;
298
- var hasAnswer = isTextFilled(label);
324
+ var _ref9 = answer || {},
325
+ _ref9$good = _ref9.good,
326
+ rightAnswer = _ref9$good === void 0 ? null : _ref9$good,
327
+ _ref9$label = _ref9.label,
328
+ label = _ref9$label === void 0 ? null : _ref9$label,
329
+ _ref9$visual = _ref9.visual,
330
+ visual = _ref9$visual === void 0 ? null : _ref9$visual,
331
+ _ref9$buttonLayout = _ref9.buttonLayout,
332
+ buttonLayout = _ref9$buttonLayout === void 0 ? null : _ref9$buttonLayout,
333
+ _ref9$buttonStyle = _ref9.buttonStyle,
334
+ answerButtonStyle = _ref9$buttonStyle === void 0 ? null : _ref9$buttonStyle,
335
+ _ref9$textStyle = _ref9.textStyle,
336
+ answerButtonTextStyle = _ref9$textStyle === void 0 ? null : _ref9$textStyle,
337
+ _ref9$style = _ref9.style,
338
+ style = _ref9$style === void 0 ? null : _ref9$style;
339
+ var _ref0 = label || {},
340
+ _ref0$textStyle = _ref0.textStyle,
341
+ textStyle = _ref0$textStyle === void 0 ? null : _ref0$textStyle;
342
+ var hasText = isTextFilled(label);
343
+ var hasVisual = isImageFilled(visual);
344
+ var hasAnswer = hasText || hasVisual;
299
345
  var isUserAnswer = withoutGoodAnswer && userAnswer;
300
346
  var isOtherAnswer = withoutGoodAnswer && !userAnswer;
301
347
  var isInactive = isOtherAnswer && answeredIndex !== null;
@@ -303,8 +349,9 @@ var Answers = function Answers(_ref) {
303
349
  var inactiveButtonTextStyle = isInactive ? inactiveButtonsTextStyle : null;
304
350
  return /*#__PURE__*/React.createElement(animated.div, {
305
351
  key: "answer-".concat(answerI),
306
- className: classNames([styles$4.item, _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, styles$4.rightAnswer, !withoutGoodAnswer && rightAnswer === true), styles$4.userAnswer, isUserAnswer), styles$4.otherAnswer, isOtherAnswer), styles$4.withoutOpacity, !hasOpacity)]),
307
- onTransitionEnd: onAnswerTransitionEnd,
352
+ className: classNames([styles$4.item, _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, styles$4.rightAnswer, !withoutGoodAnswer && rightAnswer === true), styles$4.userAnswer, isUserAnswer), styles$4.otherAnswer, isOtherAnswer), styles$4.withoutOpacity, !hasOpacity)])
353
+ // onTransitionEnd={onAnswerTransitionEnd}
354
+ ,
308
355
  style: _objectSpread({}, style)
309
356
  }, /*#__PURE__*/React.createElement("div", {
310
357
  className: styles$4.itemContent,
@@ -325,7 +372,7 @@ var Answers = function Answers(_ref) {
325
372
  }),
326
373
  emptyClassName: styles$4.emptyAnswer,
327
374
  isEmpty: !hasAnswer
328
- }, hasAnswer ? /*#__PURE__*/React.createElement(Button, {
375
+ }, hasAnswer ? /*#__PURE__*/React.createElement(RichButton, {
329
376
  className: styles$4.button,
330
377
  onPointerUp: function onPointerUp(e) {
331
378
  if (e.pointerType !== 'mouse' || e.button === 0) {
@@ -335,7 +382,12 @@ var Answers = function Answers(_ref) {
335
382
  disabled: !visible || isPreview || answered,
336
383
  focusable: focusable,
337
384
  buttonStyle: _objectSpread(_objectSpread(_objectSpread({}, buttonsStyle), inactiveButtonStyle), answerButtonStyle),
338
- textStyle: _objectSpread(_objectSpread(_objectSpread({}, buttonsTextStyle), inactiveButtonTextStyle), answerButtonTextStyle)
385
+ textStyle: _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, buttonsTextStyle), textStyle), inactiveButtonTextStyle), answerButtonTextStyle),
386
+ label: label,
387
+ visual: visual,
388
+ visualClassName: styles$4.optionVisual,
389
+ imageClassName: styles$4.optionImage,
390
+ layout: buttonLayout || (hasVisual ? 'label-right' : null)
339
391
  }, answered && !withoutIcon && rightAnswer === true ? /*#__PURE__*/React.createElement("span", {
340
392
  className: styles$4.resultIcon,
341
393
  style: getStyleFromColor(goodAnswerColor, 'backgroundColor')
@@ -348,11 +400,26 @@ var Answers = function Answers(_ref) {
348
400
  }, /*#__PURE__*/React.createElement(FontAwesomeIcon, {
349
401
  className: styles$4.faIcon,
350
402
  icon: faTimes
351
- })) : null, /*#__PURE__*/React.createElement(Text, Object.assign({}, label, {
352
- className: styles$4.optionLabel,
353
- textStyle: _objectSpread(_objectSpread(_objectSpread({}, buttonsTextStyle), textStyle), answerButtonTextStyle)
354
- }))) : null)));
355
- })) : null);
403
+ })) : null) : null)));
404
+ });
405
+ var _ref10 = keypadLayout || {},
406
+ _ref10$columnAlign = _ref10.columnAlign,
407
+ align = _ref10$columnAlign === void 0 ? null : _ref10$columnAlign,
408
+ _ref10$columns = _ref10.columns,
409
+ columns = _ref10$columns === void 0 ? 1 : _ref10$columns,
410
+ _ref10$spacing = _ref10.spacing,
411
+ spacing = _ref10$spacing === void 0 ? null : _ref10$spacing,
412
+ _ref10$withSquareItem = _ref10.withSquareItems,
413
+ withSquareItems = _ref10$withSquareItem === void 0 ? false : _ref10$withSquareItem;
414
+ return /*#__PURE__*/React.createElement("div", {
415
+ className: classNames([styles$4.container, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, styles$4.answered, answered), styles$4.withIcon, !withoutIcon && hasGoodOrBadAnswerInList), styles$4.withSquareItems, withSquareItems === true), styles$4.isPlaceholder, isPlaceholder), className, className !== null)])
416
+ }, filteredListOfItems !== null || isPlaceholder ? /*#__PURE__*/React.createElement(Keypad, {
417
+ className: styles$4.items,
418
+ items: keypadItems,
419
+ align: align,
420
+ columns: columns,
421
+ spacing: spacing
422
+ }) : null);
356
423
  };
357
424
  Answers.propTypes = propTypes$5;
358
425
  Answers.defaultProps = defaultProps$5;
@@ -362,6 +429,7 @@ var styles$3 = {"container":"micromag-screen-quiz-question-container","emptyQues
362
429
  var propTypes$4 = {
363
430
  question: PropTypes$1.textElement,
364
431
  answers: PropTypes$1.quizAnswers,
432
+ keypadLayout: PropTypes.shape({}),
365
433
  result: PropTypes.shape({
366
434
  image: PropTypes$1.imageElement,
367
435
  text: PropTypes$1.textElement
@@ -400,6 +468,7 @@ var propTypes$4 = {
400
468
  var defaultProps$4 = {
401
469
  question: null,
402
470
  answers: null,
471
+ keypadLayout: null,
403
472
  result: null,
404
473
  resultImage: null,
405
474
  index: null,
@@ -435,6 +504,7 @@ var defaultProps$4 = {
435
504
  var Question = function Question(_ref) {
436
505
  var question = _ref.question,
437
506
  answers = _ref.answers,
507
+ keypadLayout = _ref.keypadLayout,
438
508
  result = _ref.result,
439
509
  resultImage = _ref.resultImage,
440
510
  index = _ref.index,
@@ -538,6 +608,7 @@ var Question = function Question(_ref) {
538
608
  }) : null, /*#__PURE__*/React.createElement(Answers, {
539
609
  key: "answers",
540
610
  items: answers || [],
611
+ keypadLayout: keypadLayout,
541
612
  answeredIndex: answeredIndex,
542
613
  goodAnswerColor: goodAnswerColor,
543
614
  badAnswerColor: badAnswerColor,
@@ -595,6 +666,7 @@ var styles$2 = {"container":"micromag-screen-quiz-container","background":"micro
595
666
  var propTypes$3 = {
596
667
  id: PropTypes.string,
597
668
  layout: PropTypes.oneOf(['top', 'middle', 'bottom', 'split']),
669
+ keypadLayout: PropTypes.shape({}),
598
670
  question: PropTypes$1.textElement,
599
671
  answers: PropTypes$1.quizAnswers,
600
672
  result: PropTypes.shape({
@@ -626,6 +698,7 @@ var propTypes$3 = {
626
698
  var defaultProps$3 = {
627
699
  id: null,
628
700
  layout: 'middle',
701
+ keypadLayout: null,
629
702
  question: null,
630
703
  answers: null,
631
704
  result: null,
@@ -654,6 +727,7 @@ var defaultProps$3 = {
654
727
  var QuizScreen = function QuizScreen(_ref) {
655
728
  var id = _ref.id,
656
729
  layout = _ref.layout,
730
+ keypadLayout = _ref.keypadLayout,
657
731
  question = _ref.question,
658
732
  answers = _ref.answers,
659
733
  result = _ref.result,
@@ -823,7 +897,7 @@ var QuizScreen = function QuizScreen(_ref) {
823
897
  width: width,
824
898
  height: height,
825
899
  className: styles$2.content
826
- }, showReset ? /*#__PURE__*/React.createElement(Button$1, {
900
+ }, showReset ? /*#__PURE__*/React.createElement(Button, {
827
901
  className: styles$2.reset,
828
902
  icon: /*#__PURE__*/React.createElement(FontAwesomeIcon, {
829
903
  icon: faRedo,
@@ -853,6 +927,7 @@ var QuizScreen = function QuizScreen(_ref) {
853
927
  }, /*#__PURE__*/React.createElement(Header, header)) : null, /*#__PURE__*/React.createElement(Question, {
854
928
  question: question,
855
929
  answers: answers,
930
+ keypadLayout: keypadLayout,
856
931
  result: result,
857
932
  resultImage: resultImage,
858
933
  answeredIndex: userAnswerIndex,
@@ -1087,7 +1162,7 @@ var Title = function Title(_ref) {
1087
1162
  }) : null, /*#__PURE__*/React.createElement(ScreenElement, {
1088
1163
  key: "button",
1089
1164
  placeholder: "button"
1090
- }, /*#__PURE__*/React.createElement(Button, {
1165
+ }, /*#__PURE__*/React.createElement(Button$1, {
1091
1166
  disabled: buttonDisabled,
1092
1167
  focusable: focusable,
1093
1168
  buttonStyle: button !== null ? button.buttonStyle : null,
@@ -1315,6 +1390,8 @@ var QuizMultipleScreen = function QuizMultipleScreen(_ref) {
1315
1390
  questionBackground = _ref4$background === void 0 ? null : _ref4$background,
1316
1391
  _ref4$layout = _ref4.layout,
1317
1392
  questionLayout = _ref4$layout === void 0 ? null : _ref4$layout,
1393
+ _ref4$keypadLayout = _ref4.keypadLayout,
1394
+ keypadLayout = _ref4$keypadLayout === void 0 ? null : _ref4$keypadLayout,
1318
1395
  _ref4$result = _ref4.result,
1319
1396
  questionResult = _ref4$result === void 0 ? null : _ref4$result,
1320
1397
  _ref4$resultImage = _ref4.resultImage,
@@ -1522,7 +1599,7 @@ var QuizMultipleScreen = function QuizMultipleScreen(_ref) {
1522
1599
  "type": 0,
1523
1600
  "value": "points gained"
1524
1601
  }]
1525
- })) : null, showReset ? /*#__PURE__*/React.createElement(Button, {
1602
+ })) : null, showReset ? /*#__PURE__*/React.createElement(Button$1, {
1526
1603
  className: styles$2.reset,
1527
1604
  icon: /*#__PURE__*/React.createElement(FontAwesomeIcon, {
1528
1605
  icon: faRedo,
@@ -1579,6 +1656,7 @@ var QuizMultipleScreen = function QuizMultipleScreen(_ref) {
1579
1656
  totalCount: (questions || []).length,
1580
1657
  question: text,
1581
1658
  answers: answers,
1659
+ keypadLayout: keypadLayout,
1582
1660
  answeredIndex: currentAnsweredIndex,
1583
1661
  buttonsStyle: buttonsStyle,
1584
1662
  inactiveButtonsStyle: inactiveButtonsStyle,
@@ -1621,7 +1699,7 @@ var QuizMultipleScreen = function QuizMultipleScreen(_ref) {
1621
1699
  paddingTop: (current && !isPreview ? viewerTopHeight : 0) + (headerHeight || spacing),
1622
1700
  paddingBottom: (current && !isPreview ? viewerBottomHeight : 0) + (callToActionHeight || spacing)
1623
1701
  } : null
1624
- }, /*#__PURE__*/React.createElement(Button, {
1702
+ }, /*#__PURE__*/React.createElement(Button$1, {
1625
1703
  disabled: currentAnsweredIndex === null,
1626
1704
  focusable: true,
1627
1705
  buttonStyle: nextButton !== null ? nextButton.buttonStyle : null,
@@ -1707,18 +1785,17 @@ var definition = [{
1707
1785
  }),
1708
1786
  component: QuizScreen,
1709
1787
  layouts: ['top', 'middle', 'bottom', 'split'],
1710
- fields: [{
1711
- name: 'layout',
1712
- type: 'screen-layout',
1713
- defaultValue: 'top',
1714
- label: defineMessage({
1715
- id: "4iBXj2",
1716
- defaultMessage: [{
1717
- "type": 0,
1718
- "value": "Layout"
1719
- }]
1720
- })
1721
- }, {
1788
+ fields: [
1789
+ // {
1790
+ // name: 'layout',
1791
+ // type: 'screen-layout',
1792
+ // defaultValue: 'top',
1793
+ // label: defineMessage({
1794
+ // defaultMessage: 'Layout',
1795
+ // description: 'Layout field label',
1796
+ // }),
1797
+ // },
1798
+ {
1722
1799
  name: 'question',
1723
1800
  type: 'heading-element',
1724
1801
  theme: {
@@ -1746,6 +1823,24 @@ var definition = [{
1746
1823
  "value": "Answers"
1747
1824
  }]
1748
1825
  })
1826
+ }, {
1827
+ name: 'keypadLayout',
1828
+ type: 'keypad-layout',
1829
+ isList: false,
1830
+ withoutLabel: true,
1831
+ defaultValue: {
1832
+ columnAlign: 'middle',
1833
+ columns: 1,
1834
+ spacing: 10,
1835
+ withSquareItems: false
1836
+ },
1837
+ label: defineMessage({
1838
+ id: "FjuRaw",
1839
+ defaultMessage: [{
1840
+ "type": 0,
1841
+ "value": "Keypad settings"
1842
+ }]
1843
+ })
1749
1844
  }, {
1750
1845
  name: 'withoutTrueFalse',
1751
1846
  type: 'toggle',
@@ -2039,6 +2134,24 @@ var definition = [{
2039
2134
  "value": "Answers"
2040
2135
  }]
2041
2136
  })
2137
+ }, {
2138
+ name: 'keypadLayout',
2139
+ type: 'keypad-layout',
2140
+ isList: false,
2141
+ withoutLabel: true,
2142
+ defaultValue: {
2143
+ columnAlign: 'middle',
2144
+ columns: 1,
2145
+ spacing: 10,
2146
+ withSquareItems: false
2147
+ },
2148
+ label: defineMessage({
2149
+ id: "FjuRaw",
2150
+ defaultMessage: [{
2151
+ "type": 0,
2152
+ "value": "Keypad settings"
2153
+ }]
2154
+ })
2042
2155
  },
2043
2156
  // {
2044
2157
  // name: 'result',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micromag/screen-quiz",
3
- "version": "0.3.816",
3
+ "version": "0.3.820",
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.814",
67
- "@micromag/data": "^0.3.814",
68
- "@micromag/element-background": "^0.3.816",
69
- "@micromag/element-button": "^0.3.814",
70
- "@micromag/element-container": "^0.3.814",
71
- "@micromag/element-footer": "^0.3.814",
72
- "@micromag/element-header": "^0.3.814",
73
- "@micromag/element-heading": "^0.3.814",
74
- "@micromag/element-layout": "^0.3.814",
75
- "@micromag/element-scroll": "^0.3.814",
76
- "@micromag/element-text": "^0.3.814",
77
- "@micromag/element-visual": "^0.3.816",
78
- "@micromag/transforms": "^0.3.814",
66
+ "@micromag/core": "^0.3.820",
67
+ "@micromag/data": "^0.3.820",
68
+ "@micromag/element-background": "^0.3.820",
69
+ "@micromag/element-button": "^0.3.820",
70
+ "@micromag/element-container": "^0.3.820",
71
+ "@micromag/element-footer": "^0.3.820",
72
+ "@micromag/element-header": "^0.3.820",
73
+ "@micromag/element-heading": "^0.3.820",
74
+ "@micromag/element-layout": "^0.3.820",
75
+ "@micromag/element-scroll": "^0.3.820",
76
+ "@micromag/element-text": "^0.3.820",
77
+ "@micromag/element-visual": "^0.3.820",
78
+ "@micromag/transforms": "^0.3.820",
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": "85a6c6c833b345a90bf74323299ec3500c0099d0"
92
+ "gitHead": "c4ef0ae4055720a367551328e824ad3b111e4c9f"
93
93
  }