@micromag/screen-survey 0.3.649 → 0.3.651
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 +147 -63
- 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}
|
package/es/index.js
CHANGED
|
@@ -8,7 +8,7 @@ import isNumber from 'lodash/isNumber';
|
|
|
8
8
|
import PropTypes from 'prop-types';
|
|
9
9
|
import React, { useState, useMemo, useCallback, useEffect } from 'react';
|
|
10
10
|
import { PropTypes as PropTypes$1 } from '@micromag/core';
|
|
11
|
-
import { ScreenElement, Transitions } from '@micromag/core/components';
|
|
11
|
+
import { ScreenElement, Transitions, ArrowIcon } from '@micromag/core/components';
|
|
12
12
|
import { useScreenSize, useScreenRenderContext, useViewerContext, useViewerWebView, usePlaybackContext, usePlaybackMediaRef } from '@micromag/core/contexts';
|
|
13
13
|
import { useTrackScreenEvent, useDimensionObserver } from '@micromag/core/hooks';
|
|
14
14
|
import { isTextFilled, getLargestRemainderRound, isHeaderFilled, isFooterFilled, getFooterProps, getStyleFromColor } from '@micromag/core/utils';
|
|
@@ -22,14 +22,16 @@ import Heading from '@micromag/element-heading';
|
|
|
22
22
|
import Layout, { Spacer } from '@micromag/element-layout';
|
|
23
23
|
import Scroll from '@micromag/element-scroll';
|
|
24
24
|
import Text from '@micromag/element-text';
|
|
25
|
+
import TextInput from '@micromag/element-text-input';
|
|
25
26
|
|
|
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"};
|
|
27
|
+
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"};
|
|
27
28
|
|
|
28
29
|
var propTypes = {
|
|
29
30
|
id: PropTypes.string,
|
|
30
31
|
layout: PropTypes.oneOf(['top', 'middle', 'bottom', 'split']),
|
|
31
32
|
question: PropTypes$1.textElement,
|
|
32
33
|
answers: PropTypes$1.answers,
|
|
34
|
+
result: PropTypes$1.result,
|
|
33
35
|
buttonsStyle: PropTypes$1.boxStyle,
|
|
34
36
|
buttonsTextStyle: PropTypes$1.textStyle,
|
|
35
37
|
resultsStyle: PropTypes.shape({
|
|
@@ -58,6 +60,7 @@ var defaultProps = {
|
|
|
58
60
|
layout: 'middle',
|
|
59
61
|
question: null,
|
|
60
62
|
answers: null,
|
|
63
|
+
result: null,
|
|
61
64
|
buttonsStyle: null,
|
|
62
65
|
buttonsTextStyle: null,
|
|
63
66
|
resultsStyle: null,
|
|
@@ -82,15 +85,16 @@ var SurveyScreen = function SurveyScreen(_ref) {
|
|
|
82
85
|
layout = _ref.layout,
|
|
83
86
|
question = _ref.question,
|
|
84
87
|
answers = _ref.answers,
|
|
88
|
+
result = _ref.result,
|
|
85
89
|
buttonsStyle = _ref.buttonsStyle,
|
|
86
90
|
buttonsTextStyle = _ref.buttonsTextStyle,
|
|
87
91
|
resultsStyle = _ref.resultsStyle,
|
|
88
92
|
spacing = _ref.spacing,
|
|
89
93
|
header = _ref.header,
|
|
90
94
|
footer = _ref.footer,
|
|
91
|
-
background = _ref.background
|
|
92
|
-
_ref.showInput
|
|
93
|
-
|
|
95
|
+
background = _ref.background,
|
|
96
|
+
showInput = _ref.showInput,
|
|
97
|
+
showCount = _ref.showCount,
|
|
94
98
|
withoutPercentage = _ref.withoutPercentage,
|
|
95
99
|
withoutBar = _ref.withoutBar,
|
|
96
100
|
current = _ref.current,
|
|
@@ -157,6 +161,7 @@ var SurveyScreen = function SurveyScreen(_ref) {
|
|
|
157
161
|
return false;
|
|
158
162
|
});
|
|
159
163
|
var hasQuestion = isTextFilled(question);
|
|
164
|
+
var hasDefaultResult = isTextFilled(result);
|
|
160
165
|
var showInstantAnswer = isStatic || isCapture;
|
|
161
166
|
var _useState = useState(showInstantAnswer ? -1 : null),
|
|
162
167
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -228,15 +233,47 @@ var SurveyScreen = function SurveyScreen(_ref) {
|
|
|
228
233
|
}
|
|
229
234
|
}, [isEdit, current, userAnswerIndex, setUserAnswerIndex]);
|
|
230
235
|
var _useState3 = useState(null),
|
|
231
|
-
_useState4 = _slicedToArray(_useState3, 2)
|
|
232
|
-
_useState4[0]
|
|
233
|
-
|
|
234
|
-
|
|
236
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
237
|
+
textInput = _useState4[0],
|
|
238
|
+
setTextInput = _useState4[1];
|
|
239
|
+
var _useState5 = useState(false),
|
|
240
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
241
|
+
inputFocused = _useState6[0],
|
|
242
|
+
setInputFocused = _useState6[1];
|
|
243
|
+
var inputDisabled = isPreview || answered;
|
|
244
|
+
var onInputFocused = useCallback(function (e) {
|
|
245
|
+
e.preventDefault();
|
|
246
|
+
e.stopPropagation();
|
|
247
|
+
setInputFocused(true);
|
|
248
|
+
}, [setInputFocused]);
|
|
249
|
+
var onInputBlurred = useCallback(function (e) {
|
|
250
|
+
e.preventDefault();
|
|
251
|
+
e.stopPropagation();
|
|
252
|
+
setInputFocused(false);
|
|
253
|
+
}, [setInputFocused]);
|
|
254
|
+
var onTextInputChange = useCallback(function (e) {
|
|
235
255
|
var _ref9 = e.target || {},
|
|
236
256
|
_ref9$value = _ref9.value,
|
|
237
257
|
value = _ref9$value === undefined ? null : _ref9$value;
|
|
238
258
|
setTextInput(value);
|
|
239
259
|
}, [setTextInput]);
|
|
260
|
+
var onSubmitSuggestion = useCallback(function (e) {
|
|
261
|
+
e.preventDefault();
|
|
262
|
+
e.stopPropagation();
|
|
263
|
+
if (textInput !== null && textInput !== '' && !answered) {
|
|
264
|
+
// console.log('submitting survey suggestion', textInput);
|
|
265
|
+
submitQuiz({
|
|
266
|
+
choice: textInput,
|
|
267
|
+
value: 1
|
|
268
|
+
});
|
|
269
|
+
setUserAnswerIndex('input');
|
|
270
|
+
setInputFocused(false);
|
|
271
|
+
trackScreenEvent('submit_answer', "Answer: ".concat(textInput), {
|
|
272
|
+
textInput: textInput,
|
|
273
|
+
answerIndex: -1
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
}, [textInput, submitQuiz, answered, setUserAnswerIndex, setInputFocused, trackScreenEvent]);
|
|
240
277
|
var hasHeader = isHeaderFilled(header);
|
|
241
278
|
var hasFooter = isFooterFilled(footer);
|
|
242
279
|
var footerProps = getFooterProps(footer, {
|
|
@@ -254,10 +291,10 @@ var SurveyScreen = function SurveyScreen(_ref) {
|
|
|
254
291
|
_useDimensionObserver4 = _useDimensionObserver3.height,
|
|
255
292
|
footerHeight = _useDimensionObserver4 === undefined ? 0 : _useDimensionObserver4;
|
|
256
293
|
var scrollingDisabled = !isEdit && transitionDisabled || !current;
|
|
257
|
-
var
|
|
258
|
-
|
|
259
|
-
scrolledBottom =
|
|
260
|
-
setScrolledBottom =
|
|
294
|
+
var _useState7 = useState(false),
|
|
295
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
296
|
+
scrolledBottom = _useState8[0],
|
|
297
|
+
setScrolledBottom = _useState8[1];
|
|
261
298
|
var onScrolledBottom = useCallback(function (_ref10) {
|
|
262
299
|
var initial = _ref10.initial;
|
|
263
300
|
if (initial) {
|
|
@@ -268,10 +305,10 @@ var SurveyScreen = function SurveyScreen(_ref) {
|
|
|
268
305
|
var onScrolledNotBottom = useCallback(function () {
|
|
269
306
|
setScrolledBottom(false);
|
|
270
307
|
}, [setScrolledBottom]);
|
|
271
|
-
var
|
|
272
|
-
|
|
273
|
-
hasScroll =
|
|
274
|
-
setHasScroll =
|
|
308
|
+
var _useState9 = useState(false),
|
|
309
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
310
|
+
hasScroll = _useState10[0],
|
|
311
|
+
setHasScroll = _useState10[1];
|
|
275
312
|
var onScrollHeightChange = useCallback(function (_ref11) {
|
|
276
313
|
var _ref11$canScroll = _ref11.canScroll,
|
|
277
314
|
canScroll = _ref11$canScroll === undefined ? false : _ref11$canScroll;
|
|
@@ -303,7 +340,9 @@ var SurveyScreen = function SurveyScreen(_ref) {
|
|
|
303
340
|
key: "spacer"
|
|
304
341
|
}));
|
|
305
342
|
}
|
|
306
|
-
var finalTransitionDuration =
|
|
343
|
+
var finalTransitionDuration = useMemo(function () {
|
|
344
|
+
return showInstantAnswer ? 0 : "".concat(resultTransitionDuration, "ms");
|
|
345
|
+
}, [showInstantAnswer, resultTransitionDuration]);
|
|
307
346
|
var _ref12 = resultsStyle || {},
|
|
308
347
|
_ref12$barColor = _ref12.barColor,
|
|
309
348
|
resultsBarColor = _ref12$barColor === undefined ? null : _ref12$barColor,
|
|
@@ -311,6 +350,14 @@ var SurveyScreen = function SurveyScreen(_ref) {
|
|
|
311
350
|
resultsTextColor = _ref12$textColor === undefined ? null : _ref12$textColor,
|
|
312
351
|
_ref12$percentageText = _ref12.percentageTextStyle,
|
|
313
352
|
resultsPercentageTextStyle = _ref12$percentageText === undefined ? null : _ref12$percentageText;
|
|
353
|
+
var finalResult = useMemo(function () {
|
|
354
|
+
var defaultResult = hasDefaultResult ? result : null;
|
|
355
|
+
var answer = userAnswerIndex !== null ? answers[userAnswerIndex] : null;
|
|
356
|
+
var _ref13 = answer || {},
|
|
357
|
+
_ref13$result = _ref13.result,
|
|
358
|
+
answerResult = _ref13$result === undefined ? null : _ref13$result;
|
|
359
|
+
return answerResult || defaultResult;
|
|
360
|
+
}, [hasDefaultResult, result, answers, userAnswerIndex]);
|
|
314
361
|
items.push(/*#__PURE__*/React.createElement("div", {
|
|
315
362
|
key: "answers",
|
|
316
363
|
className: styles.answers
|
|
@@ -318,43 +365,43 @@ var SurveyScreen = function SurveyScreen(_ref) {
|
|
|
318
365
|
className: styles.items
|
|
319
366
|
}, (isPlaceholder ? _toConsumableArray(new Array(3)) : answers).map(function (answer, answerIndex) {
|
|
320
367
|
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 =
|
|
368
|
+
var _ref14 = answer || {},
|
|
369
|
+
_ref14$label = _ref14.label,
|
|
370
|
+
label = _ref14$label === undefined ? null : _ref14$label,
|
|
371
|
+
_ref14$buttonStyle = _ref14.buttonStyle,
|
|
372
|
+
answerButtonStyle = _ref14$buttonStyle === undefined ? null : _ref14$buttonStyle,
|
|
373
|
+
_ref14$textStyle = _ref14.textStyle,
|
|
374
|
+
answerButtonTextStyle = _ref14$textStyle === undefined ? null : _ref14$textStyle,
|
|
375
|
+
_ref14$resultStyle = _ref14.resultStyle,
|
|
376
|
+
answerResultStyle = _ref14$resultStyle === undefined ? null : _ref14$resultStyle;
|
|
377
|
+
var _ref15 = answerResultStyle || {},
|
|
378
|
+
_ref15$barColor = _ref15.barColor,
|
|
379
|
+
answerResultBarColor = _ref15$barColor === undefined ? null : _ref15$barColor,
|
|
380
|
+
answerResultTextColor = _ref15.textColor,
|
|
381
|
+
_ref15$percentageText = _ref15.percentageTextStyle,
|
|
382
|
+
answerResultPercentageTextStyle = _ref15$percentageText === undefined ? null : _ref15$percentageText;
|
|
383
|
+
var _ref16 = label || {},
|
|
384
|
+
_ref16$body = _ref16.body,
|
|
385
|
+
body = _ref16$body === undefined ? null : _ref16$body;
|
|
386
|
+
var _ref17 = body !== null ? quizAnswersComputed[body] || {} : {},
|
|
387
|
+
_ref17$percent = _ref17.percent,
|
|
388
|
+
percent = _ref17$percent === undefined ? 0 : _ref17$percent,
|
|
389
|
+
_ref17$count = _ref17.count,
|
|
390
|
+
count = _ref17$count === undefined ? 0 : _ref17$count;
|
|
391
|
+
var _ref18 = label || {},
|
|
392
|
+
_ref18$textStyle = _ref18.textStyle,
|
|
393
|
+
textStyle = _ref18$textStyle === undefined ? null : _ref18$textStyle;
|
|
394
|
+
var _ref19 = textStyle || {},
|
|
395
|
+
_ref19$color = _ref19.color,
|
|
396
|
+
labelColor = _ref19$color === undefined ? null : _ref19$color;
|
|
350
397
|
var hasAnswerLabel = isTextFilled(label);
|
|
351
398
|
var userAnswer = userAnswerIndex === answerIndex;
|
|
352
399
|
var buttonStyles = _objectSpread(_objectSpread(_objectSpread({}, buttonsStyle), answerButtonStyle), answered ? {
|
|
353
400
|
textAlign: 'left'
|
|
354
401
|
} : null);
|
|
355
|
-
var
|
|
356
|
-
|
|
357
|
-
answerResultBorderRadius =
|
|
402
|
+
var _ref20 = buttonStyles || {},
|
|
403
|
+
_ref20$borderRadius = _ref20.borderRadius,
|
|
404
|
+
answerResultBorderRadius = _ref20$borderRadius === undefined ? null : _ref20$borderRadius;
|
|
358
405
|
var finalBarBorderRadius = answerResultBorderRadius !== null && isNumber(answerResultBorderRadius) && answerResultBorderRadius > 2 ? answerResultBorderRadius - 2 : answerResultBorderRadius;
|
|
359
406
|
return /*#__PURE__*/React.createElement("div", {
|
|
360
407
|
key: "answer-".concat(answerIndex),
|
|
@@ -424,7 +471,7 @@ var SurveyScreen = function SurveyScreen(_ref) {
|
|
|
424
471
|
}) : null)))) : null));
|
|
425
472
|
})) : null));
|
|
426
473
|
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)])
|
|
474
|
+
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
475
|
}, /*#__PURE__*/React.createElement(Container, {
|
|
429
476
|
width: width,
|
|
430
477
|
height: height,
|
|
@@ -454,7 +501,30 @@ var SurveyScreen = function SurveyScreen(_ref) {
|
|
|
454
501
|
paddingTop: (current && !isPreview ? viewerTopHeight : 0) + (headerHeight || spacing),
|
|
455
502
|
paddingBottom: (current && !isPreview ? viewerBottomHeight : 0) + (footerHeight + spacing)
|
|
456
503
|
} : null
|
|
457
|
-
}, items
|
|
504
|
+
}, items, !isPlaceholder && showInput ? /*#__PURE__*/React.createElement("form", {
|
|
505
|
+
className: classNames([styles.input, _defineProperty(_defineProperty(_defineProperty({}, styles.focused, inputFocused), styles.disabled, inputDisabled), styles.selected, userAnswerIndex === 'input')]),
|
|
506
|
+
onSubmit: onSubmitSuggestion
|
|
507
|
+
}, /*#__PURE__*/React.createElement(TextInput, {
|
|
508
|
+
className: styles.textInput,
|
|
509
|
+
disabled: inputDisabled,
|
|
510
|
+
focusable: current && isView,
|
|
511
|
+
buttonStyle: buttonsStyle,
|
|
512
|
+
textStyle: _objectSpread({}, buttonsTextStyle),
|
|
513
|
+
value: textInput,
|
|
514
|
+
onChange: onTextInputChange,
|
|
515
|
+
onFocus: onInputFocused,
|
|
516
|
+
onBlur: onInputBlurred
|
|
517
|
+
}), /*#__PURE__*/React.createElement(Button, {
|
|
518
|
+
className: styles.confirm,
|
|
519
|
+
type: "submit",
|
|
520
|
+
disabled: inputDisabled
|
|
521
|
+
}, /*#__PURE__*/React.createElement(ArrowIcon, null))) : null, userAnswerIndex !== null && finalResult !== null ? /*#__PURE__*/React.createElement(Transitions, {
|
|
522
|
+
transitions: transitions,
|
|
523
|
+
playing: transitionPlaying,
|
|
524
|
+
disabled: transitionDisabled
|
|
525
|
+
}, /*#__PURE__*/React.createElement(Text, Object.assign({}, finalResult || {}, {
|
|
526
|
+
className: styles.resultText
|
|
527
|
+
}))) : null)), !isPlaceholder && hasFooter ? /*#__PURE__*/React.createElement("div", {
|
|
458
528
|
ref: footerRef,
|
|
459
529
|
className: classNames([styles.footer, _defineProperty({}, styles.disabled, !scrolledBottom)]),
|
|
460
530
|
style: {
|
|
@@ -541,6 +611,19 @@ var definition = {
|
|
|
541
611
|
"value": "Answers"
|
|
542
612
|
}]
|
|
543
613
|
})
|
|
614
|
+
}, {
|
|
615
|
+
name: 'result',
|
|
616
|
+
type: 'text-element',
|
|
617
|
+
theme: {
|
|
618
|
+
textStyle: 'text'
|
|
619
|
+
},
|
|
620
|
+
label: defineMessage({
|
|
621
|
+
id: "iQ5Uf7",
|
|
622
|
+
defaultMessage: [{
|
|
623
|
+
"type": 0,
|
|
624
|
+
"value": "Default feedback"
|
|
625
|
+
}]
|
|
626
|
+
})
|
|
544
627
|
}, {
|
|
545
628
|
type: 'fields',
|
|
546
629
|
isList: true,
|
|
@@ -551,17 +634,18 @@ var definition = {
|
|
|
551
634
|
"value": "Styles"
|
|
552
635
|
}]
|
|
553
636
|
}),
|
|
554
|
-
fields: [
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
637
|
+
fields: [{
|
|
638
|
+
name: 'showInput',
|
|
639
|
+
type: 'toggle',
|
|
640
|
+
defaultValue: false,
|
|
641
|
+
label: defineMessage({
|
|
642
|
+
id: "sLskqO",
|
|
643
|
+
defaultMessage: [{
|
|
644
|
+
"type": 0,
|
|
645
|
+
"value": "Show input answer"
|
|
646
|
+
}]
|
|
647
|
+
})
|
|
648
|
+
}, {
|
|
565
649
|
name: 'showCount',
|
|
566
650
|
type: 'toggle',
|
|
567
651
|
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.651",
|
|
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": "9639dccc046f7adfe9673f53ede77360b8b75d51"
|
|
87
87
|
}
|