@micromag/screen-survey 0.3.649 → 0.3.652
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/assets/css/styles.css +1 -1
- package/es/index.js +161 -64
- package/package.json +15 -15
package/assets/css/styles.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.micromag-screen-survey-container .micromag-screen-survey-background{height:100%;left:0;position:absolute;top:0;width:100%}.micromag-screen-survey-container{height:100%;overflow:hidden;position:relative;width:100%}.micromag-screen-survey-disabled.micromag-screen-survey-container{overflow:hidden;pointer-events:none}.micromag-screen-survey-hidden.micromag-screen-survey-container{display:none;visibility:hidden}.micromag-screen-survey-placeholder.micromag-screen-survey-container .micromag-screen-survey-content{padding:6px;position:relative}.micromag-screen-survey-container .micromag-screen-survey-emptyAnswer,.micromag-screen-survey-container .micromag-screen-survey-emptyQuestion{border:2px dashed #343434;color:#343434;margin:5px auto}.micromag-screen-survey-container .micromag-screen-survey-background{z-index:0}.micromag-screen-survey-container .micromag-screen-survey-content{z-index:1}.micromag-screen-survey-container .micromag-screen-survey-question{margin-bottom:20px}.micromag-screen-survey-container .micromag-screen-survey-answers,.micromag-screen-survey-container .micromag-screen-survey-items{position:relative}.micromag-screen-survey-container .micromag-screen-survey-header{left:0;position:absolute;top:0;-webkit-transition:opacity .2s ease-out;transition:opacity .2s ease-out;width:100%}.micromag-screen-survey-container .micromag-screen-survey-header.micromag-screen-survey-disabled{opacity:0;pointer-events:none}.micromag-screen-survey-container .micromag-screen-survey-footer{bottom:0;left:0;position:absolute;-webkit-transition:opacity .2s ease-out;transition:opacity .2s ease-out;width:100%}.micromag-screen-survey-container .micromag-screen-survey-footer a{padding:0}.micromag-screen-survey-container .micromag-screen-survey-footer.micromag-screen-survey-disabled{opacity:0;pointer-events:none}.micromag-screen-survey-container .micromag-screen-survey-item{padding:5px 0}.micromag-screen-survey-container .micromag-screen-survey-item:first-child .micromag-screen-survey-placeholderAnswer{width:80%}.micromag-screen-survey-container .micromag-screen-survey-item:last-child .micromag-screen-survey-placeholderAnswer{width:90%}.micromag-screen-survey-container .micromag-screen-survey-itemContent{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center}.micromag-screen-survey-container .micromag-screen-survey-resultBar{background-color:hsla(0,0%,100%,.2);height:100%;left:0;position:absolute;top:0}.micromag-screen-survey-container .micromag-screen-survey-resultLabel{color:#fff;padding:0 8px;position:absolute;right:0;text-align:right;top:50%;-webkit-transform:translateY(-50%);-ms-transform:translateY(-50%);transform:translateY(-50%);width:4em;z-index:1}.micromag-screen-survey-container .micromag-screen-survey-itemInner{width:100%}.micromag-screen-survey-container .micromag-screen-survey-button{display:-ms-flexbox;display:flex;overflow:hidden;padding:10px;position:relative;-webkit-transition:opacity .5s ease-out;transition:opacity .5s ease-out;width:100%}.micromag-screen-survey-container .micromag-screen-survey-button:disabled{opacity:1;pointer-events:none}.micromag-screen-survey-container .micromag-screen-survey-itemLabel{width:100%}.micromag-screen-survey-container .micromag-screen-survey-itemLabel,.micromag-screen-survey-container .micromag-screen-survey-itemText{display:inline-block;-webkit-transition:margin-left .3s ease-out,-webkit-transform .3s ease-out;transition:margin-left .3s ease-out,-webkit-transform .3s ease-out;transition:margin-left .3s ease-out,transform .3s ease-out;transition:margin-left .3s ease-out,transform .3s ease-out,-webkit-transform .3s ease-out}.micromag-screen-survey-container .micromag-screen-survey-itemText{position:relative;z-index:1}.micromag-screen-survey-container .micromag-screen-survey-emptyAnswer,.micromag-screen-survey-container .micromag-screen-survey-emptyQuestion{margin:0 auto;width:100%}.micromag-screen-survey-container .micromag-screen-survey-emptyQuestion{height:75px}.micromag-screen-survey-container .micromag-screen-survey-emptyAnswer{height:50px}.micromag-screen-survey-container .micromag-screen-survey-userAnswer .micromag-screen-survey-button,.micromag-screen-survey-container .micromag-screen-survey-userAnswer .micromag-screen-survey-result,.micromag-screen-survey-container .micromag-screen-survey-userAnswer .micromag-screen-survey-resultLabel{opacity:1!important}.micromag-screen-survey-container.micromag-screen-survey-answered{line-height:1}.micromag-screen-survey-container.micromag-screen-survey-answered .micromag-screen-survey-resultContainer{padding-left:15px;padding-right:50px}.micromag-screen-survey-container.micromag-screen-survey-answered .micromag-screen-survey-resultContent{opacity:1;width:100%}.micromag-screen-survey-container.micromag-screen-survey-answered .micromag-screen-survey-button{background-color:transparent;border-color:transparent}.micromag-screen-survey-container.micromag-screen-survey-answered .micromag-screen-survey-button,.micromag-screen-survey-container.micromag-screen-survey-answered .micromag-screen-survey-result,.micromag-screen-survey-container.micromag-screen-survey-answered .micromag-screen-survey-resultLabel{opacity:.6}.micromag-screen-survey-container.micromag-screen-survey-answered .micromag-screen-survey-itemLabel{margin-left:0;margin-right:0;text-align:left}.micromag-screen-survey-container.micromag-screen-survey-answered.micromag-screen-survey-withPercentage .micromag-screen-survey-itemText{-webkit-transform:translate(-2em);-ms-transform:translate(-2em);transform:translate(-2em)}.micromag-screen-survey-container.micromag-screen-survey-withPercentage .micromag-screen-survey-itemLabel{margin-left:2em;margin-right:2em}.micromag-screen-survey-container.micromag-screen-survey-isPlaceholder .micromag-screen-survey-layout{padding:10px}.micromag-screen-survey-container.micromag-screen-survey-isPlaceholder .micromag-screen-survey-item{padding:1px 0}
|
|
1
|
+
.micromag-screen-survey-container .micromag-screen-survey-background{height:100%;left:0;position:absolute;top:0;width:100%}.micromag-screen-survey-container{height:100%;overflow:hidden;position:relative;width:100%}.micromag-screen-survey-disabled.micromag-screen-survey-container{overflow:hidden;pointer-events:none}.micromag-screen-survey-hidden.micromag-screen-survey-container{display:none;visibility:hidden}.micromag-screen-survey-placeholder.micromag-screen-survey-container .micromag-screen-survey-content{padding:6px;position:relative}.micromag-screen-survey-container .micromag-screen-survey-emptyAnswer,.micromag-screen-survey-container .micromag-screen-survey-emptyQuestion{border:2px dashed #343434;color:#343434;margin:5px auto}.micromag-screen-survey-container .micromag-screen-survey-background{z-index:0}.micromag-screen-survey-container .micromag-screen-survey-content{z-index:1}.micromag-screen-survey-container .micromag-screen-survey-question{margin-bottom:20px}.micromag-screen-survey-container .micromag-screen-survey-answers,.micromag-screen-survey-container .micromag-screen-survey-items{position:relative}.micromag-screen-survey-container .micromag-screen-survey-header{left:0;position:absolute;top:0;-webkit-transition:opacity .2s ease-out;transition:opacity .2s ease-out;width:100%}.micromag-screen-survey-container .micromag-screen-survey-header.micromag-screen-survey-disabled{opacity:0;pointer-events:none}.micromag-screen-survey-container .micromag-screen-survey-footer{bottom:0;left:0;position:absolute;-webkit-transition:opacity .2s ease-out;transition:opacity .2s ease-out;width:100%}.micromag-screen-survey-container .micromag-screen-survey-footer a{padding:0}.micromag-screen-survey-container .micromag-screen-survey-footer.micromag-screen-survey-disabled{opacity:0;pointer-events:none}.micromag-screen-survey-container .micromag-screen-survey-item{padding:5px 0}.micromag-screen-survey-container .micromag-screen-survey-item:first-child .micromag-screen-survey-placeholderAnswer{width:80%}.micromag-screen-survey-container .micromag-screen-survey-item:last-child .micromag-screen-survey-placeholderAnswer{width:90%}.micromag-screen-survey-container .micromag-screen-survey-itemContent{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center}.micromag-screen-survey-container .micromag-screen-survey-resultBar{background-color:hsla(0,0%,100%,.2);height:100%;left:0;position:absolute;top:0}.micromag-screen-survey-container .micromag-screen-survey-resultLabel{color:#fff;padding:0 8px;position:absolute;right:0;text-align:right;top:50%;-webkit-transform:translateY(-50%);-ms-transform:translateY(-50%);transform:translateY(-50%);width:4em;z-index:1}.micromag-screen-survey-container .micromag-screen-survey-resultText{margin-top:10px}.micromag-screen-survey-container .micromag-screen-survey-itemInner{width:100%}.micromag-screen-survey-container .micromag-screen-survey-button{display:-ms-flexbox;display:flex;overflow:hidden;padding:10px;position:relative;-webkit-transition:opacity .5s ease-out;transition:opacity .5s ease-out;width:100%}.micromag-screen-survey-container .micromag-screen-survey-button:disabled{opacity:1;pointer-events:none}.micromag-screen-survey-container .micromag-screen-survey-itemLabel{width:100%}.micromag-screen-survey-container .micromag-screen-survey-itemLabel,.micromag-screen-survey-container .micromag-screen-survey-itemText{display:inline-block;-webkit-transition:margin-left .3s ease-out,-webkit-transform .3s ease-out;transition:margin-left .3s ease-out,-webkit-transform .3s ease-out;transition:margin-left .3s ease-out,transform .3s ease-out;transition:margin-left .3s ease-out,transform .3s ease-out,-webkit-transform .3s ease-out}.micromag-screen-survey-container .micromag-screen-survey-itemText{position:relative;z-index:1}.micromag-screen-survey-container .micromag-screen-survey-emptyAnswer,.micromag-screen-survey-container .micromag-screen-survey-emptyQuestion{margin:0 auto;width:100%}.micromag-screen-survey-container .micromag-screen-survey-emptyQuestion{height:75px}.micromag-screen-survey-container .micromag-screen-survey-emptyAnswer{height:50px}.micromag-screen-survey-container .micromag-screen-survey-userAnswer .micromag-screen-survey-button,.micromag-screen-survey-container .micromag-screen-survey-userAnswer .micromag-screen-survey-result,.micromag-screen-survey-container .micromag-screen-survey-userAnswer .micromag-screen-survey-resultLabel{opacity:1!important}.micromag-screen-survey-container .micromag-screen-survey-input{margin:5px 0;position:relative}.micromag-screen-survey-container .micromag-screen-survey-input.micromag-screen-survey-disabled{opacity:.5}.micromag-screen-survey-container .micromag-screen-survey-input.micromag-screen-survey-disabled .micromag-screen-survey-confirm,.micromag-screen-survey-container .micromag-screen-survey-input.micromag-screen-survey-disabled .micromag-screen-survey-textInput{background:transparent}.micromag-screen-survey-container .micromag-screen-survey-input.micromag-screen-survey-selected{opacity:1!important}.micromag-screen-survey-container .micromag-screen-survey-input.micromag-screen-survey-selected .micromag-screen-survey-confirm{opacity:0}.micromag-screen-survey-container .micromag-screen-survey-textInput{color:#fff;display:-ms-flexbox;display:flex;margin:0;overflow:hidden;padding:10px 40px 10px 10px;position:relative;-webkit-transition:opacity .5s ease-out;transition:opacity .5s ease-out;width:100%;z-index:0}.micromag-screen-survey-container .micromag-screen-survey-confirm{bottom:0;position:absolute;right:0;top:0;z-index:1}.micromag-screen-survey-container.micromag-screen-survey-answered{line-height:1}.micromag-screen-survey-container.micromag-screen-survey-answered .micromag-screen-survey-resultContainer{padding-left:15px;padding-right:50px}.micromag-screen-survey-container.micromag-screen-survey-answered .micromag-screen-survey-resultContent{opacity:1;width:100%}.micromag-screen-survey-container.micromag-screen-survey-answered .micromag-screen-survey-button{background-color:transparent;border-color:transparent}.micromag-screen-survey-container.micromag-screen-survey-answered .micromag-screen-survey-button,.micromag-screen-survey-container.micromag-screen-survey-answered .micromag-screen-survey-result,.micromag-screen-survey-container.micromag-screen-survey-answered .micromag-screen-survey-resultLabel{opacity:.6}.micromag-screen-survey-container.micromag-screen-survey-answered .micromag-screen-survey-itemLabel{margin-left:0;margin-right:0;text-align:left}.micromag-screen-survey-container.micromag-screen-survey-answered.micromag-screen-survey-withPercentage .micromag-screen-survey-itemText{-webkit-transform:translate(-2em);-ms-transform:translate(-2em);transform:translate(-2em)}.micromag-screen-survey-container.micromag-screen-survey-withPercentage .micromag-screen-survey-itemLabel{margin-left:2em;margin-right:2em}.micromag-screen-survey-container.micromag-screen-survey-inputFocused .micromag-screen-survey-answers,.micromag-screen-survey-container.micromag-screen-survey-inputFocused .micromag-screen-survey-question{opacity:.5}.micromag-screen-survey-container.micromag-screen-survey-isPlaceholder .micromag-screen-survey-layout{padding:10px}.micromag-screen-survey-container.micromag-screen-survey-isPlaceholder .micromag-screen-survey-item{padding:1px 0}.micromag-screen-survey-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-survey-reset:hover{border:0;opacity:.8}.micromag-screen-survey-reset:hover:active{-webkit-transform:rotate(30deg);-ms-transform:rotate(30deg);transform:rotate(30deg)}
|
package/es/index.js
CHANGED
|
@@ -3,12 +3,14 @@ import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
|
3
3
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
4
4
|
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
5
5
|
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
6
|
+
import { faRedo } from '@fortawesome/free-solid-svg-icons/faRedo';
|
|
7
|
+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
6
8
|
import classNames from 'classnames';
|
|
7
9
|
import isNumber from 'lodash/isNumber';
|
|
8
10
|
import PropTypes from 'prop-types';
|
|
9
11
|
import React, { useState, useMemo, useCallback, useEffect } from 'react';
|
|
10
12
|
import { PropTypes as PropTypes$1 } from '@micromag/core';
|
|
11
|
-
import { ScreenElement, Transitions } from '@micromag/core/components';
|
|
13
|
+
import { ScreenElement, Transitions, ArrowIcon } from '@micromag/core/components';
|
|
12
14
|
import { useScreenSize, useScreenRenderContext, useViewerContext, useViewerWebView, usePlaybackContext, usePlaybackMediaRef } from '@micromag/core/contexts';
|
|
13
15
|
import { useTrackScreenEvent, useDimensionObserver } from '@micromag/core/hooks';
|
|
14
16
|
import { isTextFilled, getLargestRemainderRound, isHeaderFilled, isFooterFilled, getFooterProps, getStyleFromColor } from '@micromag/core/utils';
|
|
@@ -22,14 +24,16 @@ import Heading from '@micromag/element-heading';
|
|
|
22
24
|
import Layout, { Spacer } from '@micromag/element-layout';
|
|
23
25
|
import Scroll from '@micromag/element-scroll';
|
|
24
26
|
import Text from '@micromag/element-text';
|
|
27
|
+
import TextInput from '@micromag/element-text-input';
|
|
25
28
|
|
|
26
|
-
var styles = {"container":"micromag-screen-survey-container","background":"micromag-screen-survey-background","disabled":"micromag-screen-survey-disabled","content":"micromag-screen-survey-content","emptyQuestion":"micromag-screen-survey-emptyQuestion","emptyAnswer":"micromag-screen-survey-emptyAnswer","question":"micromag-screen-survey-question","answers":"micromag-screen-survey-answers","items":"micromag-screen-survey-items","header":"micromag-screen-survey-header","footer":"micromag-screen-survey-footer","item":"micromag-screen-survey-item","placeholderAnswer":"micromag-screen-survey-placeholderAnswer","itemContent":"micromag-screen-survey-itemContent","resultBar":"micromag-screen-survey-resultBar","resultLabel":"micromag-screen-survey-resultLabel","itemInner":"micromag-screen-survey-itemInner","button":"micromag-screen-survey-button","itemLabel":"micromag-screen-survey-itemLabel","itemText":"micromag-screen-survey-itemText","userAnswer":"micromag-screen-survey-userAnswer","answered":"micromag-screen-survey-answered","withPercentage":"micromag-screen-survey-withPercentage","isPlaceholder":"micromag-screen-survey-isPlaceholder","layout":"micromag-screen-survey-layout"};
|
|
29
|
+
var styles = {"container":"micromag-screen-survey-container","background":"micromag-screen-survey-background","disabled":"micromag-screen-survey-disabled","content":"micromag-screen-survey-content","emptyQuestion":"micromag-screen-survey-emptyQuestion","emptyAnswer":"micromag-screen-survey-emptyAnswer","question":"micromag-screen-survey-question","answers":"micromag-screen-survey-answers","items":"micromag-screen-survey-items","header":"micromag-screen-survey-header","footer":"micromag-screen-survey-footer","item":"micromag-screen-survey-item","placeholderAnswer":"micromag-screen-survey-placeholderAnswer","itemContent":"micromag-screen-survey-itemContent","resultBar":"micromag-screen-survey-resultBar","resultLabel":"micromag-screen-survey-resultLabel","resultText":"micromag-screen-survey-resultText","itemInner":"micromag-screen-survey-itemInner","button":"micromag-screen-survey-button","itemLabel":"micromag-screen-survey-itemLabel","itemText":"micromag-screen-survey-itemText","userAnswer":"micromag-screen-survey-userAnswer","input":"micromag-screen-survey-input","textInput":"micromag-screen-survey-textInput","confirm":"micromag-screen-survey-confirm","selected":"micromag-screen-survey-selected","answered":"micromag-screen-survey-answered","withPercentage":"micromag-screen-survey-withPercentage","inputFocused":"micromag-screen-survey-inputFocused","isPlaceholder":"micromag-screen-survey-isPlaceholder","layout":"micromag-screen-survey-layout","reset":"micromag-screen-survey-reset"};
|
|
27
30
|
|
|
28
31
|
var propTypes = {
|
|
29
32
|
id: PropTypes.string,
|
|
30
33
|
layout: PropTypes.oneOf(['top', 'middle', 'bottom', 'split']),
|
|
31
34
|
question: PropTypes$1.textElement,
|
|
32
35
|
answers: PropTypes$1.answers,
|
|
36
|
+
result: PropTypes$1.result,
|
|
33
37
|
buttonsStyle: PropTypes$1.boxStyle,
|
|
34
38
|
buttonsTextStyle: PropTypes$1.textStyle,
|
|
35
39
|
resultsStyle: PropTypes.shape({
|
|
@@ -58,6 +62,7 @@ var defaultProps = {
|
|
|
58
62
|
layout: 'middle',
|
|
59
63
|
question: null,
|
|
60
64
|
answers: null,
|
|
65
|
+
result: null,
|
|
61
66
|
buttonsStyle: null,
|
|
62
67
|
buttonsTextStyle: null,
|
|
63
68
|
resultsStyle: null,
|
|
@@ -82,15 +87,16 @@ var SurveyScreen = function SurveyScreen(_ref) {
|
|
|
82
87
|
layout = _ref.layout,
|
|
83
88
|
question = _ref.question,
|
|
84
89
|
answers = _ref.answers,
|
|
90
|
+
result = _ref.result,
|
|
85
91
|
buttonsStyle = _ref.buttonsStyle,
|
|
86
92
|
buttonsTextStyle = _ref.buttonsTextStyle,
|
|
87
93
|
resultsStyle = _ref.resultsStyle,
|
|
88
94
|
spacing = _ref.spacing,
|
|
89
95
|
header = _ref.header,
|
|
90
96
|
footer = _ref.footer,
|
|
91
|
-
background = _ref.background
|
|
92
|
-
_ref.showInput
|
|
93
|
-
|
|
97
|
+
background = _ref.background,
|
|
98
|
+
showInput = _ref.showInput,
|
|
99
|
+
showCount = _ref.showCount,
|
|
94
100
|
withoutPercentage = _ref.withoutPercentage,
|
|
95
101
|
withoutBar = _ref.withoutBar,
|
|
96
102
|
current = _ref.current,
|
|
@@ -157,6 +163,7 @@ var SurveyScreen = function SurveyScreen(_ref) {
|
|
|
157
163
|
return false;
|
|
158
164
|
});
|
|
159
165
|
var hasQuestion = isTextFilled(question);
|
|
166
|
+
var hasDefaultResult = isTextFilled(result);
|
|
160
167
|
var showInstantAnswer = isStatic || isCapture;
|
|
161
168
|
var _useState = useState(showInstantAnswer ? -1 : null),
|
|
162
169
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -227,16 +234,51 @@ var SurveyScreen = function SurveyScreen(_ref) {
|
|
|
227
234
|
setUserAnswerIndex(null);
|
|
228
235
|
}
|
|
229
236
|
}, [isEdit, current, userAnswerIndex, setUserAnswerIndex]);
|
|
237
|
+
var onQuizReset = useCallback(function () {
|
|
238
|
+
setUserAnswerIndex(null);
|
|
239
|
+
}, [setUserAnswerIndex]);
|
|
230
240
|
var _useState3 = useState(null),
|
|
231
|
-
_useState4 = _slicedToArray(_useState3, 2)
|
|
232
|
-
_useState4[0]
|
|
233
|
-
|
|
234
|
-
|
|
241
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
242
|
+
textInput = _useState4[0],
|
|
243
|
+
setTextInput = _useState4[1];
|
|
244
|
+
var _useState5 = useState(false),
|
|
245
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
246
|
+
inputFocused = _useState6[0],
|
|
247
|
+
setInputFocused = _useState6[1];
|
|
248
|
+
var inputDisabled = isPreview || answered;
|
|
249
|
+
var onInputFocused = useCallback(function (e) {
|
|
250
|
+
e.preventDefault();
|
|
251
|
+
e.stopPropagation();
|
|
252
|
+
setInputFocused(true);
|
|
253
|
+
}, [setInputFocused]);
|
|
254
|
+
var onInputBlurred = useCallback(function (e) {
|
|
255
|
+
e.preventDefault();
|
|
256
|
+
e.stopPropagation();
|
|
257
|
+
setInputFocused(false);
|
|
258
|
+
}, [setInputFocused]);
|
|
259
|
+
var onTextInputChange = useCallback(function (e) {
|
|
235
260
|
var _ref9 = e.target || {},
|
|
236
261
|
_ref9$value = _ref9.value,
|
|
237
262
|
value = _ref9$value === undefined ? null : _ref9$value;
|
|
238
263
|
setTextInput(value);
|
|
239
264
|
}, [setTextInput]);
|
|
265
|
+
var onSubmitSuggestion = useCallback(function (e) {
|
|
266
|
+
e.preventDefault();
|
|
267
|
+
e.stopPropagation();
|
|
268
|
+
if (textInput !== null && textInput !== '' && !answered) {
|
|
269
|
+
// console.log('submitting survey suggestion', textInput);
|
|
270
|
+
submitQuiz({
|
|
271
|
+
choice: textInput,
|
|
272
|
+
value: 1
|
|
273
|
+
});
|
|
274
|
+
setUserAnswerIndex('input');
|
|
275
|
+
setInputFocused(false);
|
|
276
|
+
trackScreenEvent('submit_answer', "Answer: ".concat(textInput), {
|
|
277
|
+
textInput: textInput,
|
|
278
|
+
answerIndex: -1
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
}, [textInput, submitQuiz, answered, setUserAnswerIndex, setInputFocused, trackScreenEvent]);
|
|
240
282
|
var hasHeader = isHeaderFilled(header);
|
|
241
283
|
var hasFooter = isFooterFilled(footer);
|
|
242
284
|
var footerProps = getFooterProps(footer, {
|
|
@@ -254,10 +296,10 @@ var SurveyScreen = function SurveyScreen(_ref) {
|
|
|
254
296
|
_useDimensionObserver4 = _useDimensionObserver3.height,
|
|
255
297
|
footerHeight = _useDimensionObserver4 === undefined ? 0 : _useDimensionObserver4;
|
|
256
298
|
var scrollingDisabled = !isEdit && transitionDisabled || !current;
|
|
257
|
-
var
|
|
258
|
-
|
|
259
|
-
scrolledBottom =
|
|
260
|
-
setScrolledBottom =
|
|
299
|
+
var _useState7 = useState(false),
|
|
300
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
301
|
+
scrolledBottom = _useState8[0],
|
|
302
|
+
setScrolledBottom = _useState8[1];
|
|
261
303
|
var onScrolledBottom = useCallback(function (_ref10) {
|
|
262
304
|
var initial = _ref10.initial;
|
|
263
305
|
if (initial) {
|
|
@@ -268,10 +310,10 @@ var SurveyScreen = function SurveyScreen(_ref) {
|
|
|
268
310
|
var onScrolledNotBottom = useCallback(function () {
|
|
269
311
|
setScrolledBottom(false);
|
|
270
312
|
}, [setScrolledBottom]);
|
|
271
|
-
var
|
|
272
|
-
|
|
273
|
-
hasScroll =
|
|
274
|
-
setHasScroll =
|
|
313
|
+
var _useState9 = useState(false),
|
|
314
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
315
|
+
hasScroll = _useState10[0],
|
|
316
|
+
setHasScroll = _useState10[1];
|
|
275
317
|
var onScrollHeightChange = useCallback(function (_ref11) {
|
|
276
318
|
var _ref11$canScroll = _ref11.canScroll,
|
|
277
319
|
canScroll = _ref11$canScroll === undefined ? false : _ref11$canScroll;
|
|
@@ -303,7 +345,9 @@ var SurveyScreen = function SurveyScreen(_ref) {
|
|
|
303
345
|
key: "spacer"
|
|
304
346
|
}));
|
|
305
347
|
}
|
|
306
|
-
var finalTransitionDuration =
|
|
348
|
+
var finalTransitionDuration = useMemo(function () {
|
|
349
|
+
return showInstantAnswer ? 0 : "".concat(resultTransitionDuration, "ms");
|
|
350
|
+
}, [showInstantAnswer, resultTransitionDuration]);
|
|
307
351
|
var _ref12 = resultsStyle || {},
|
|
308
352
|
_ref12$barColor = _ref12.barColor,
|
|
309
353
|
resultsBarColor = _ref12$barColor === undefined ? null : _ref12$barColor,
|
|
@@ -311,6 +355,15 @@ var SurveyScreen = function SurveyScreen(_ref) {
|
|
|
311
355
|
resultsTextColor = _ref12$textColor === undefined ? null : _ref12$textColor,
|
|
312
356
|
_ref12$percentageText = _ref12.percentageTextStyle,
|
|
313
357
|
resultsPercentageTextStyle = _ref12$percentageText === undefined ? null : _ref12$percentageText;
|
|
358
|
+
var finalResult = useMemo(function () {
|
|
359
|
+
var defaultResult = hasDefaultResult ? result : null;
|
|
360
|
+
var answer = userAnswerIndex !== null ? answers[userAnswerIndex] : null;
|
|
361
|
+
var _ref13 = answer || {},
|
|
362
|
+
_ref13$result = _ref13.result,
|
|
363
|
+
answerResult = _ref13$result === undefined ? null : _ref13$result;
|
|
364
|
+
return answerResult || defaultResult;
|
|
365
|
+
}, [hasDefaultResult, result, answers, userAnswerIndex]);
|
|
366
|
+
var showReset = isEdit && userAnswerIndex !== null;
|
|
314
367
|
items.push(/*#__PURE__*/React.createElement("div", {
|
|
315
368
|
key: "answers",
|
|
316
369
|
className: styles.answers
|
|
@@ -318,43 +371,43 @@ var SurveyScreen = function SurveyScreen(_ref) {
|
|
|
318
371
|
className: styles.items
|
|
319
372
|
}, (isPlaceholder ? _toConsumableArray(new Array(3)) : answers).map(function (answer, answerIndex) {
|
|
320
373
|
var hasAnswer = answer !== null;
|
|
321
|
-
var
|
|
322
|
-
|
|
323
|
-
label =
|
|
324
|
-
|
|
325
|
-
answerButtonStyle =
|
|
326
|
-
|
|
327
|
-
answerButtonTextStyle =
|
|
328
|
-
|
|
329
|
-
answerResultStyle =
|
|
330
|
-
var
|
|
331
|
-
|
|
332
|
-
answerResultBarColor =
|
|
333
|
-
answerResultTextColor =
|
|
334
|
-
|
|
335
|
-
answerResultPercentageTextStyle =
|
|
336
|
-
var
|
|
337
|
-
|
|
338
|
-
body =
|
|
339
|
-
var
|
|
340
|
-
|
|
341
|
-
percent =
|
|
342
|
-
|
|
343
|
-
count =
|
|
344
|
-
var
|
|
345
|
-
|
|
346
|
-
textStyle =
|
|
347
|
-
var
|
|
348
|
-
|
|
349
|
-
labelColor =
|
|
374
|
+
var _ref14 = answer || {},
|
|
375
|
+
_ref14$label = _ref14.label,
|
|
376
|
+
label = _ref14$label === undefined ? null : _ref14$label,
|
|
377
|
+
_ref14$buttonStyle = _ref14.buttonStyle,
|
|
378
|
+
answerButtonStyle = _ref14$buttonStyle === undefined ? null : _ref14$buttonStyle,
|
|
379
|
+
_ref14$textStyle = _ref14.textStyle,
|
|
380
|
+
answerButtonTextStyle = _ref14$textStyle === undefined ? null : _ref14$textStyle,
|
|
381
|
+
_ref14$resultStyle = _ref14.resultStyle,
|
|
382
|
+
answerResultStyle = _ref14$resultStyle === undefined ? null : _ref14$resultStyle;
|
|
383
|
+
var _ref15 = answerResultStyle || {},
|
|
384
|
+
_ref15$barColor = _ref15.barColor,
|
|
385
|
+
answerResultBarColor = _ref15$barColor === undefined ? null : _ref15$barColor,
|
|
386
|
+
answerResultTextColor = _ref15.textColor,
|
|
387
|
+
_ref15$percentageText = _ref15.percentageTextStyle,
|
|
388
|
+
answerResultPercentageTextStyle = _ref15$percentageText === undefined ? null : _ref15$percentageText;
|
|
389
|
+
var _ref16 = label || {},
|
|
390
|
+
_ref16$body = _ref16.body,
|
|
391
|
+
body = _ref16$body === undefined ? null : _ref16$body;
|
|
392
|
+
var _ref17 = body !== null ? quizAnswersComputed[body] || {} : {},
|
|
393
|
+
_ref17$percent = _ref17.percent,
|
|
394
|
+
percent = _ref17$percent === undefined ? 0 : _ref17$percent,
|
|
395
|
+
_ref17$count = _ref17.count,
|
|
396
|
+
count = _ref17$count === undefined ? 0 : _ref17$count;
|
|
397
|
+
var _ref18 = label || {},
|
|
398
|
+
_ref18$textStyle = _ref18.textStyle,
|
|
399
|
+
textStyle = _ref18$textStyle === undefined ? null : _ref18$textStyle;
|
|
400
|
+
var _ref19 = textStyle || {},
|
|
401
|
+
_ref19$color = _ref19.color,
|
|
402
|
+
labelColor = _ref19$color === undefined ? null : _ref19$color;
|
|
350
403
|
var hasAnswerLabel = isTextFilled(label);
|
|
351
404
|
var userAnswer = userAnswerIndex === answerIndex;
|
|
352
405
|
var buttonStyles = _objectSpread(_objectSpread(_objectSpread({}, buttonsStyle), answerButtonStyle), answered ? {
|
|
353
406
|
textAlign: 'left'
|
|
354
407
|
} : null);
|
|
355
|
-
var
|
|
356
|
-
|
|
357
|
-
answerResultBorderRadius =
|
|
408
|
+
var _ref20 = buttonStyles || {},
|
|
409
|
+
_ref20$borderRadius = _ref20.borderRadius,
|
|
410
|
+
answerResultBorderRadius = _ref20$borderRadius === undefined ? null : _ref20$borderRadius;
|
|
358
411
|
var finalBarBorderRadius = answerResultBorderRadius !== null && isNumber(answerResultBorderRadius) && answerResultBorderRadius > 2 ? answerResultBorderRadius - 2 : answerResultBorderRadius;
|
|
359
412
|
return /*#__PURE__*/React.createElement("div", {
|
|
360
413
|
key: "answer-".concat(answerIndex),
|
|
@@ -424,7 +477,7 @@ var SurveyScreen = function SurveyScreen(_ref) {
|
|
|
424
477
|
}) : null)))) : null));
|
|
425
478
|
})) : null));
|
|
426
479
|
return /*#__PURE__*/React.createElement("div", {
|
|
427
|
-
className: classNames([styles.container, _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, className, className !== null), styles.answered, answered), styles.withPercentage, !withoutPercentage), styles.isPlaceholder, isPlaceholder)])
|
|
480
|
+
className: classNames([styles.container, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, className, className !== null), styles.answered, answered), styles.inputFocused, inputFocused), styles.withPercentage, !withoutPercentage), styles.isPlaceholder, isPlaceholder)])
|
|
428
481
|
}, /*#__PURE__*/React.createElement(Container, {
|
|
429
482
|
width: width,
|
|
430
483
|
height: height,
|
|
@@ -436,7 +489,14 @@ var SurveyScreen = function SurveyScreen(_ref) {
|
|
|
436
489
|
onScrolledNotBottom: onScrolledNotBottom,
|
|
437
490
|
onScrollHeightChange: onScrollHeightChange,
|
|
438
491
|
withShadow: true
|
|
439
|
-
},
|
|
492
|
+
}, showReset ? /*#__PURE__*/React.createElement(Button, {
|
|
493
|
+
className: styles.reset,
|
|
494
|
+
icon: /*#__PURE__*/React.createElement(FontAwesomeIcon, {
|
|
495
|
+
icon: faRedo,
|
|
496
|
+
size: "md"
|
|
497
|
+
}),
|
|
498
|
+
onClick: onQuizReset
|
|
499
|
+
}) : null, !isPlaceholder && hasHeader ? /*#__PURE__*/React.createElement("div", {
|
|
440
500
|
className: classNames([styles.header, _defineProperty({}, styles.disabled, scrolledBottom && !scrollingDisabled && hasScroll)]),
|
|
441
501
|
ref: headerRef,
|
|
442
502
|
style: {
|
|
@@ -454,7 +514,30 @@ var SurveyScreen = function SurveyScreen(_ref) {
|
|
|
454
514
|
paddingTop: (current && !isPreview ? viewerTopHeight : 0) + (headerHeight || spacing),
|
|
455
515
|
paddingBottom: (current && !isPreview ? viewerBottomHeight : 0) + (footerHeight + spacing)
|
|
456
516
|
} : null
|
|
457
|
-
}, items
|
|
517
|
+
}, items, !isPlaceholder && showInput ? /*#__PURE__*/React.createElement("form", {
|
|
518
|
+
className: classNames([styles.input, _defineProperty(_defineProperty(_defineProperty({}, styles.focused, inputFocused), styles.disabled, inputDisabled), styles.selected, userAnswerIndex === 'input')]),
|
|
519
|
+
onSubmit: onSubmitSuggestion
|
|
520
|
+
}, /*#__PURE__*/React.createElement(TextInput, {
|
|
521
|
+
className: styles.textInput,
|
|
522
|
+
disabled: inputDisabled,
|
|
523
|
+
focusable: current && isView,
|
|
524
|
+
buttonStyle: buttonsStyle,
|
|
525
|
+
textStyle: _objectSpread({}, buttonsTextStyle),
|
|
526
|
+
value: textInput,
|
|
527
|
+
onChange: onTextInputChange,
|
|
528
|
+
onFocus: onInputFocused,
|
|
529
|
+
onBlur: onInputBlurred
|
|
530
|
+
}), /*#__PURE__*/React.createElement(Button, {
|
|
531
|
+
className: styles.confirm,
|
|
532
|
+
type: "submit",
|
|
533
|
+
disabled: inputDisabled
|
|
534
|
+
}, /*#__PURE__*/React.createElement(ArrowIcon, null))) : null, userAnswerIndex !== null && finalResult !== null ? /*#__PURE__*/React.createElement(Transitions, {
|
|
535
|
+
transitions: transitions,
|
|
536
|
+
playing: transitionPlaying,
|
|
537
|
+
disabled: transitionDisabled
|
|
538
|
+
}, /*#__PURE__*/React.createElement(Text, Object.assign({}, finalResult || {}, {
|
|
539
|
+
className: styles.resultText
|
|
540
|
+
}))) : null)), !isPlaceholder && hasFooter ? /*#__PURE__*/React.createElement("div", {
|
|
458
541
|
ref: footerRef,
|
|
459
542
|
className: classNames([styles.footer, _defineProperty({}, styles.disabled, !scrolledBottom)]),
|
|
460
543
|
style: {
|
|
@@ -541,6 +624,19 @@ var definition = {
|
|
|
541
624
|
"value": "Answers"
|
|
542
625
|
}]
|
|
543
626
|
})
|
|
627
|
+
}, {
|
|
628
|
+
name: 'result',
|
|
629
|
+
type: 'text-element',
|
|
630
|
+
theme: {
|
|
631
|
+
textStyle: 'text'
|
|
632
|
+
},
|
|
633
|
+
label: defineMessage({
|
|
634
|
+
id: "iQ5Uf7",
|
|
635
|
+
defaultMessage: [{
|
|
636
|
+
"type": 0,
|
|
637
|
+
"value": "Default feedback"
|
|
638
|
+
}]
|
|
639
|
+
})
|
|
544
640
|
}, {
|
|
545
641
|
type: 'fields',
|
|
546
642
|
isList: true,
|
|
@@ -551,17 +647,18 @@ var definition = {
|
|
|
551
647
|
"value": "Styles"
|
|
552
648
|
}]
|
|
553
649
|
}),
|
|
554
|
-
fields: [
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
650
|
+
fields: [{
|
|
651
|
+
name: 'showInput',
|
|
652
|
+
type: 'toggle',
|
|
653
|
+
defaultValue: false,
|
|
654
|
+
label: defineMessage({
|
|
655
|
+
id: "sLskqO",
|
|
656
|
+
defaultMessage: [{
|
|
657
|
+
"type": 0,
|
|
658
|
+
"value": "Show input answer"
|
|
659
|
+
}]
|
|
660
|
+
})
|
|
661
|
+
}, {
|
|
565
662
|
name: 'showCount',
|
|
566
663
|
type: 'toggle',
|
|
567
664
|
defaultValue: false,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micromag/screen-survey",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.652",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"keywords": [
|
|
@@ -60,19 +60,19 @@
|
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
62
|
"@babel/runtime": "^7.13.10",
|
|
63
|
-
"@micromag/core": "^0.3.
|
|
64
|
-
"@micromag/data": "^0.3.
|
|
65
|
-
"@micromag/element-background": "^0.3.
|
|
66
|
-
"@micromag/element-button": "^0.3.
|
|
67
|
-
"@micromag/element-container": "^0.3.
|
|
68
|
-
"@micromag/element-footer": "^0.3.
|
|
69
|
-
"@micromag/element-header": "^0.3.
|
|
70
|
-
"@micromag/element-heading": "^0.3.
|
|
71
|
-
"@micromag/element-layout": "^0.3.
|
|
72
|
-
"@micromag/element-scroll": "^0.3.
|
|
73
|
-
"@micromag/element-text": "^0.3.
|
|
74
|
-
"@micromag/element-text-input": "^0.3.
|
|
75
|
-
"@micromag/transforms": "^0.3.
|
|
63
|
+
"@micromag/core": "^0.3.651",
|
|
64
|
+
"@micromag/data": "^0.3.651",
|
|
65
|
+
"@micromag/element-background": "^0.3.651",
|
|
66
|
+
"@micromag/element-button": "^0.3.651",
|
|
67
|
+
"@micromag/element-container": "^0.3.651",
|
|
68
|
+
"@micromag/element-footer": "^0.3.651",
|
|
69
|
+
"@micromag/element-header": "^0.3.651",
|
|
70
|
+
"@micromag/element-heading": "^0.3.651",
|
|
71
|
+
"@micromag/element-layout": "^0.3.651",
|
|
72
|
+
"@micromag/element-scroll": "^0.3.651",
|
|
73
|
+
"@micromag/element-text": "^0.3.651",
|
|
74
|
+
"@micromag/element-text-input": "^0.3.651",
|
|
75
|
+
"@micromag/transforms": "^0.3.651",
|
|
76
76
|
"classnames": "^2.2.6",
|
|
77
77
|
"lodash": "^4.17.21",
|
|
78
78
|
"prop-types": "^15.7.2",
|
|
@@ -83,5 +83,5 @@
|
|
|
83
83
|
"access": "public",
|
|
84
84
|
"registry": "https://registry.npmjs.org/"
|
|
85
85
|
},
|
|
86
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "77f459a1fabeb2d40fb26866e2d2c8353d54fd9f"
|
|
87
87
|
}
|