@micromag/screen-survey 0.3.683 → 0.3.694
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 +78 -66
- package/package.json +3 -2
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-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-input.micromag-screen-survey-focused .micromag-screen-survey-confirm{opacity:1}.micromag-screen-survey-container .micromag-screen-survey-textInput{color:#fff;display:-ms-flexbox;display:flex;margin:0;overflow:hidden;padding:10px 40px;position:relative;text-align:center;-webkit-transition:margin-left .3s ease-out,opacity .5s ease-out,-webkit-transform .3s ease-out;transition:margin-left .3s ease-out,opacity .5s ease-out,-webkit-transform .3s ease-out;transition:margin-left .3s ease-out,transform .3s ease-out,opacity .5s ease-out;transition:margin-left .3s ease-out,transform .3s ease-out,opacity .5s ease-out,-webkit-transform .3s ease-out;width:100%;z-index:0}.micromag-screen-survey-container .micromag-screen-survey-confirm{bottom:0;opacity:0;position:absolute;right:0;top:0;-webkit-transition:opacity .15s ease-out;transition:opacity .15s ease-out;z-index:1}.micromag-screen-survey-container .micromag-screen-survey-confirm.micromag-screen-survey-disabled .micromag-screen-survey-icon{opacity:.5}.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-textInput{padding:10px;pointer-events:none;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-answered.micromag-screen-survey-withPercentage .micromag-screen-survey-textInput{-webkit-transform:translate(0);-ms-transform:translate(0);transform:translate(0)}.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)}
|
|
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,.micromag-screen-survey-container .micromag-screen-survey-input.micromag-screen-survey-selected .micromag-screen-survey-submit{opacity:0}.micromag-screen-survey-container .micromag-screen-survey-input.micromag-screen-survey-filled .micromag-screen-survey-confirm,.micromag-screen-survey-container .micromag-screen-survey-input.micromag-screen-survey-filled .micromag-screen-survey-submit,.micromag-screen-survey-container .micromag-screen-survey-input.micromag-screen-survey-focused .micromag-screen-survey-confirm,.micromag-screen-survey-container .micromag-screen-survey-input.micromag-screen-survey-focused .micromag-screen-survey-submit{opacity:1}.micromag-screen-survey-container .micromag-screen-survey-textInput{color:#fff;display:-ms-flexbox;display:flex;margin:0;overflow:hidden;padding:10px 35px;position:relative;text-align:center;-webkit-transition:margin-left .3s ease-out,opacity .5s ease-out,-webkit-transform .3s ease-out;transition:margin-left .3s ease-out,opacity .5s ease-out,-webkit-transform .3s ease-out;transition:margin-left .3s ease-out,transform .3s ease-out,opacity .5s ease-out;transition:margin-left .3s ease-out,transform .3s ease-out,opacity .5s ease-out,-webkit-transform .3s ease-out;width:100%;z-index:0}.micromag-screen-survey-container .micromag-screen-survey-textInput.micromag-screen-survey-padded{padding:10px 40px}.micromag-screen-survey-container .micromag-screen-survey-confirm{bottom:0;opacity:0;padding:10px;position:absolute;right:0;top:0;-webkit-transition:opacity .15s ease-out;transition:opacity .15s ease-out;z-index:1}.micromag-screen-survey-container .micromag-screen-survey-confirm.micromag-screen-survey-disabled .micromag-screen-survey-icon{opacity:.5}.micromag-screen-survey-container .micromag-screen-survey-confirm.micromag-screen-survey-isClear .micromag-screen-survey-icon{height:10px;margin:0 auto;width:10px}.micromag-screen-survey-container .micromag-screen-survey-submit{margin-top:10px;opacity:0;padding:10px;position:absolute;top:100%;-webkit-transition:opacity .15s ease-out;transition:opacity .15s ease-out;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-textInput{padding:10px;pointer-events:none;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-answered.micromag-screen-survey-withPercentage .micromag-screen-survey-textInput{-webkit-transform:translate(0);-ms-transform:translate(0);transform:translate(0)}.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
|
@@ -6,11 +6,12 @@ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
|
6
6
|
import { faRedo } from '@fortawesome/free-solid-svg-icons/faRedo';
|
|
7
7
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
8
8
|
import classNames from 'classnames';
|
|
9
|
+
import DOMPurify from 'dompurify';
|
|
9
10
|
import isNumber from 'lodash/isNumber';
|
|
10
11
|
import PropTypes from 'prop-types';
|
|
11
12
|
import React, { useState, useMemo, useCallback, useEffect } from 'react';
|
|
12
13
|
import { PropTypes as PropTypes$1 } from '@micromag/core';
|
|
13
|
-
import { ScreenElement, Transitions, ArrowIcon } from '@micromag/core/components';
|
|
14
|
+
import { ScreenElement, Transitions, CloseIcon, ArrowIcon } from '@micromag/core/components';
|
|
14
15
|
import { useScreenSize, useScreenRenderContext, useViewerContext, useViewerWebView, usePlaybackContext, usePlaybackMediaRef } from '@micromag/core/contexts';
|
|
15
16
|
import { useTrackScreenEvent, useDimensionObserver } from '@micromag/core/hooks';
|
|
16
17
|
import { isTextFilled, getLargestRemainderRound, isHeaderFilled, isFooterFilled, getFooterProps, getStyleFromColor } from '@micromag/core/utils';
|
|
@@ -26,7 +27,7 @@ import Scroll from '@micromag/element-scroll';
|
|
|
26
27
|
import Text from '@micromag/element-text';
|
|
27
28
|
import TextInput from '@micromag/element-text-input';
|
|
28
29
|
|
|
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","focused":"micromag-screen-survey-focused","icon":"micromag-screen-survey-icon","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"};
|
|
30
|
+
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","submit":"micromag-screen-survey-submit","focused":"micromag-screen-survey-focused","filled":"micromag-screen-survey-filled","padded":"micromag-screen-survey-padded","icon":"micromag-screen-survey-icon","isClear":"micromag-screen-survey-isClear","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"};
|
|
30
31
|
|
|
31
32
|
var propTypes = {
|
|
32
33
|
id: PropTypes.string,
|
|
@@ -170,7 +171,9 @@ var SurveyScreen = function SurveyScreen(_ref) {
|
|
|
170
171
|
_ref5$textStyle = _ref5.textStyle,
|
|
171
172
|
customAnswerTextStyle = _ref5$textStyle === void 0 ? null : _ref5$textStyle,
|
|
172
173
|
_ref5$boxStyle = _ref5.boxStyle,
|
|
173
|
-
customAnswerBoxStyle = _ref5$boxStyle === void 0 ? null : _ref5$boxStyle
|
|
174
|
+
customAnswerBoxStyle = _ref5$boxStyle === void 0 ? null : _ref5$boxStyle,
|
|
175
|
+
_ref5$submit = _ref5.submit,
|
|
176
|
+
customAnswerSubmit = _ref5$submit === void 0 ? null : _ref5$submit;
|
|
174
177
|
var _ref6 = placeholder || {},
|
|
175
178
|
_ref6$body = _ref6.body,
|
|
176
179
|
placeholderBody = _ref6$body === void 0 ? null : _ref6$body,
|
|
@@ -229,7 +232,7 @@ var SurveyScreen = function SurveyScreen(_ref) {
|
|
|
229
232
|
var onAnswerClick = useCallback(function (answerIndex) {
|
|
230
233
|
if (userAnswerIndex === null) {
|
|
231
234
|
setUserAnswerIndex(answerIndex);
|
|
232
|
-
var answer = answers[answerIndex];
|
|
235
|
+
var answer = answers !== null ? answers[answerIndex] : null;
|
|
233
236
|
submitQuiz({
|
|
234
237
|
choice: answer.label.body || answerIndex,
|
|
235
238
|
value: 1
|
|
@@ -269,11 +272,12 @@ var SurveyScreen = function SurveyScreen(_ref) {
|
|
|
269
272
|
setInputFocused(false);
|
|
270
273
|
}, [setInputFocused]);
|
|
271
274
|
var onTextInputChange = useCallback(function (e) {
|
|
272
|
-
var
|
|
273
|
-
_ref11$value = _ref11.value,
|
|
274
|
-
value = _ref11$value === void 0 ? null : _ref11$value;
|
|
275
|
+
var value = DOMPurify.sanitize(e.currentTarget.value || '');
|
|
275
276
|
setTextInput(value !== '' ? value : null);
|
|
276
277
|
}, [setTextInput]);
|
|
278
|
+
var onTextInputClear = useCallback(function () {
|
|
279
|
+
setTextInput('');
|
|
280
|
+
}, [setTextInput]);
|
|
277
281
|
var onSubmitSuggestion = useCallback(function (e) {
|
|
278
282
|
e.preventDefault();
|
|
279
283
|
e.stopPropagation();
|
|
@@ -284,7 +288,7 @@ var SurveyScreen = function SurveyScreen(_ref) {
|
|
|
284
288
|
});
|
|
285
289
|
setUserAnswerIndex('input');
|
|
286
290
|
setInputFocused(false);
|
|
287
|
-
trackScreenEvent('click_answer', "Answer: ".concat(textInput), {
|
|
291
|
+
trackScreenEvent('click_answer', "Answer input: ".concat(textInput), {
|
|
288
292
|
textInput: textInput,
|
|
289
293
|
answerIndex: null,
|
|
290
294
|
answerType: 'custom'
|
|
@@ -312,8 +316,8 @@ var SurveyScreen = function SurveyScreen(_ref) {
|
|
|
312
316
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
313
317
|
scrolledBottom = _useState8[0],
|
|
314
318
|
setScrolledBottom = _useState8[1];
|
|
315
|
-
var onScrolledBottom = useCallback(function (
|
|
316
|
-
var initial =
|
|
319
|
+
var onScrolledBottom = useCallback(function (_ref11) {
|
|
320
|
+
var initial = _ref11.initial;
|
|
317
321
|
if (initial) {
|
|
318
322
|
trackScreenEvent('scroll', 'Screen');
|
|
319
323
|
}
|
|
@@ -326,9 +330,9 @@ var SurveyScreen = function SurveyScreen(_ref) {
|
|
|
326
330
|
_useState10 = _slicedToArray(_useState9, 2),
|
|
327
331
|
hasScroll = _useState10[0],
|
|
328
332
|
setHasScroll = _useState10[1];
|
|
329
|
-
var onScrollHeightChange = useCallback(function (
|
|
330
|
-
var
|
|
331
|
-
canScroll =
|
|
333
|
+
var onScrollHeightChange = useCallback(function (_ref12) {
|
|
334
|
+
var _ref12$canScroll = _ref12.canScroll,
|
|
335
|
+
canScroll = _ref12$canScroll === void 0 ? false : _ref12$canScroll;
|
|
332
336
|
setHasScroll(canScroll);
|
|
333
337
|
}, [setHasScroll]);
|
|
334
338
|
|
|
@@ -360,19 +364,19 @@ var SurveyScreen = function SurveyScreen(_ref) {
|
|
|
360
364
|
var finalTransitionDuration = useMemo(function () {
|
|
361
365
|
return showInstantAnswer ? 0 : "".concat(resultTransitionDuration, "ms");
|
|
362
366
|
}, [showInstantAnswer, resultTransitionDuration]);
|
|
363
|
-
var
|
|
364
|
-
|
|
365
|
-
resultsBarColor =
|
|
366
|
-
|
|
367
|
-
resultsTextColor =
|
|
368
|
-
|
|
369
|
-
resultsPercentageTextStyle =
|
|
367
|
+
var _ref13 = resultsStyle || {},
|
|
368
|
+
_ref13$barColor = _ref13.barColor,
|
|
369
|
+
resultsBarColor = _ref13$barColor === void 0 ? null : _ref13$barColor,
|
|
370
|
+
_ref13$textColor = _ref13.textColor,
|
|
371
|
+
resultsTextColor = _ref13$textColor === void 0 ? null : _ref13$textColor,
|
|
372
|
+
_ref13$percentageText = _ref13.percentageTextStyle,
|
|
373
|
+
resultsPercentageTextStyle = _ref13$percentageText === void 0 ? null : _ref13$percentageText;
|
|
370
374
|
var finalResult = useMemo(function () {
|
|
371
375
|
var defaultResult = hasDefaultResult ? result : null;
|
|
372
|
-
var answer = userAnswerIndex !== null ? answers[userAnswerIndex] : null;
|
|
373
|
-
var
|
|
374
|
-
|
|
375
|
-
answerResult =
|
|
376
|
+
var answer = answers !== null && userAnswerIndex !== null ? answers[userAnswerIndex] : null;
|
|
377
|
+
var _ref14 = answer || {},
|
|
378
|
+
_ref14$result = _ref14.result,
|
|
379
|
+
answerResult = _ref14$result === void 0 ? null : _ref14$result;
|
|
376
380
|
return answerResult || defaultResult;
|
|
377
381
|
}, [hasDefaultResult, result, answers, userAnswerIndex]);
|
|
378
382
|
var showReset = isEdit && userAnswerIndex !== null;
|
|
@@ -383,43 +387,43 @@ var SurveyScreen = function SurveyScreen(_ref) {
|
|
|
383
387
|
className: styles.items
|
|
384
388
|
}, (isPlaceholder ? _toConsumableArray(new Array(3)) : answers).map(function (answer, answerIndex) {
|
|
385
389
|
var hasAnswer = answer !== null;
|
|
386
|
-
var
|
|
387
|
-
|
|
388
|
-
label =
|
|
389
|
-
|
|
390
|
-
answerButtonStyle =
|
|
391
|
-
|
|
392
|
-
answerButtonTextStyle =
|
|
393
|
-
|
|
394
|
-
answerResultStyle =
|
|
395
|
-
var
|
|
396
|
-
|
|
397
|
-
answerResultBarColor =
|
|
398
|
-
answerResultTextColor =
|
|
399
|
-
|
|
400
|
-
answerResultPercentageTextStyle =
|
|
401
|
-
var
|
|
402
|
-
|
|
403
|
-
body =
|
|
404
|
-
var
|
|
405
|
-
|
|
406
|
-
percent =
|
|
407
|
-
|
|
408
|
-
count =
|
|
409
|
-
var
|
|
410
|
-
|
|
411
|
-
textStyle =
|
|
412
|
-
var
|
|
413
|
-
|
|
414
|
-
labelColor =
|
|
390
|
+
var _ref15 = answer || {},
|
|
391
|
+
_ref15$label = _ref15.label,
|
|
392
|
+
label = _ref15$label === void 0 ? null : _ref15$label,
|
|
393
|
+
_ref15$buttonStyle = _ref15.buttonStyle,
|
|
394
|
+
answerButtonStyle = _ref15$buttonStyle === void 0 ? null : _ref15$buttonStyle,
|
|
395
|
+
_ref15$textStyle = _ref15.textStyle,
|
|
396
|
+
answerButtonTextStyle = _ref15$textStyle === void 0 ? null : _ref15$textStyle,
|
|
397
|
+
_ref15$resultStyle = _ref15.resultStyle,
|
|
398
|
+
answerResultStyle = _ref15$resultStyle === void 0 ? null : _ref15$resultStyle;
|
|
399
|
+
var _ref16 = answerResultStyle || {},
|
|
400
|
+
_ref16$barColor = _ref16.barColor,
|
|
401
|
+
answerResultBarColor = _ref16$barColor === void 0 ? null : _ref16$barColor,
|
|
402
|
+
answerResultTextColor = _ref16.textColor,
|
|
403
|
+
_ref16$percentageText = _ref16.percentageTextStyle,
|
|
404
|
+
answerResultPercentageTextStyle = _ref16$percentageText === void 0 ? null : _ref16$percentageText;
|
|
405
|
+
var _ref17 = label || {},
|
|
406
|
+
_ref17$body = _ref17.body,
|
|
407
|
+
body = _ref17$body === void 0 ? null : _ref17$body;
|
|
408
|
+
var _ref18 = body !== null ? quizAnswersComputed[body] || {} : {},
|
|
409
|
+
_ref18$percent = _ref18.percent,
|
|
410
|
+
percent = _ref18$percent === void 0 ? 0 : _ref18$percent,
|
|
411
|
+
_ref18$count = _ref18.count,
|
|
412
|
+
count = _ref18$count === void 0 ? 0 : _ref18$count;
|
|
413
|
+
var _ref19 = label || {},
|
|
414
|
+
_ref19$textStyle = _ref19.textStyle,
|
|
415
|
+
textStyle = _ref19$textStyle === void 0 ? null : _ref19$textStyle;
|
|
416
|
+
var _ref20 = textStyle || {},
|
|
417
|
+
_ref20$color = _ref20.color,
|
|
418
|
+
labelColor = _ref20$color === void 0 ? null : _ref20$color;
|
|
415
419
|
var hasAnswerLabel = isTextFilled(label);
|
|
416
420
|
var userAnswer = userAnswerIndex === answerIndex;
|
|
417
421
|
var buttonStyles = _objectSpread(_objectSpread(_objectSpread({}, buttonsStyle), answerButtonStyle), answered ? {
|
|
418
422
|
textAlign: 'left'
|
|
419
423
|
} : null);
|
|
420
|
-
var
|
|
421
|
-
|
|
422
|
-
answerResultBorderRadius =
|
|
424
|
+
var _ref21 = buttonStyles || {},
|
|
425
|
+
_ref21$borderRadius = _ref21.borderRadius,
|
|
426
|
+
answerResultBorderRadius = _ref21$borderRadius === void 0 ? null : _ref21$borderRadius;
|
|
423
427
|
var finalBarBorderRadius = answerResultBorderRadius !== null && isNumber(answerResultBorderRadius) && answerResultBorderRadius > 2 ? answerResultBorderRadius - 2 : answerResultBorderRadius;
|
|
424
428
|
return /*#__PURE__*/React.createElement("div", {
|
|
425
429
|
key: "answer-".concat(answerIndex + 1),
|
|
@@ -488,6 +492,7 @@ var SurveyScreen = function SurveyScreen(_ref) {
|
|
|
488
492
|
})
|
|
489
493
|
}) : null)))) : null));
|
|
490
494
|
})) : null));
|
|
495
|
+
var isClear = answers === null || answers.length === 0;
|
|
491
496
|
return /*#__PURE__*/React.createElement("div", {
|
|
492
497
|
className: classNames([styles.container, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, className, className !== null), styles.answered, answered), styles.inputFocused, inputFocused), styles.withPercentage, !withoutPercentage), styles.isPlaceholder, isPlaceholder)])
|
|
493
498
|
}, /*#__PURE__*/React.createElement(Container, {
|
|
@@ -527,10 +532,10 @@ var SurveyScreen = function SurveyScreen(_ref) {
|
|
|
527
532
|
paddingBottom: (current && !isPreview ? viewerBottomHeight : 0) + (footerHeight + spacing)
|
|
528
533
|
} : null
|
|
529
534
|
}, items, !isPlaceholder && allowCustomAnswer ? /*#__PURE__*/React.createElement("form", {
|
|
530
|
-
className: classNames([styles.input, _defineProperty(_defineProperty(_defineProperty({}, styles.focused, inputFocused), styles.disabled, inputDisabled), styles.selected, userAnswerIndex === 'input')]),
|
|
535
|
+
className: classNames([styles.input, _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, styles.focused, inputFocused), styles.filled, textInput !== null && textInput !== ''), styles.disabled, inputDisabled), styles.selected, userAnswerIndex === 'input')]),
|
|
531
536
|
onSubmit: onSubmitSuggestion
|
|
532
537
|
}, /*#__PURE__*/React.createElement(TextInput, {
|
|
533
|
-
className: styles.textInput,
|
|
538
|
+
className: classNames([styles.textInput, _defineProperty({}, styles.padded, answers !== null && answers.length > 0)]),
|
|
534
539
|
disabled: inputDisabled,
|
|
535
540
|
focusable: current && isView,
|
|
536
541
|
buttonStyle: _objectSpread(_objectSpread({}, buttonsStyle), customAnswerBoxStyle),
|
|
@@ -541,13 +546,23 @@ var SurveyScreen = function SurveyScreen(_ref) {
|
|
|
541
546
|
onChange: onTextInputChange,
|
|
542
547
|
onFocus: onInputFocused,
|
|
543
548
|
onBlur: onInputBlurred
|
|
544
|
-
}), /*#__PURE__*/React.createElement(Button, {
|
|
545
|
-
className: classNames([styles.confirm, _defineProperty({}, styles.disabled, inputDisabled || textInput === null || textInput === '')]),
|
|
546
|
-
type:
|
|
549
|
+
}), !answered ? /*#__PURE__*/React.createElement(Button, {
|
|
550
|
+
className: classNames([styles.confirm, _defineProperty(_defineProperty({}, styles.disabled, inputDisabled || textInput === null || textInput === ''), styles.isClear, isClear)]),
|
|
551
|
+
type: isClear ? 'button' : 'submit',
|
|
552
|
+
onClick: isClear ? onTextInputClear : null,
|
|
547
553
|
disabled: inputDisabled || textInput === null || textInput === ''
|
|
548
|
-
}, /*#__PURE__*/React.createElement(
|
|
554
|
+
}, isClear ? /*#__PURE__*/React.createElement(CloseIcon, {
|
|
549
555
|
className: styles.icon
|
|
550
|
-
})
|
|
556
|
+
}) : /*#__PURE__*/React.createElement(ArrowIcon, {
|
|
557
|
+
className: styles.icon
|
|
558
|
+
})) : null, (answers === null || answers.length === 0) && !answered ? /*#__PURE__*/React.createElement(Button, {
|
|
559
|
+
className: classNames([styles.submit, _defineProperty({}, styles.disabled, inputDisabled || textInput === null || textInput === '')]),
|
|
560
|
+
type: "submit",
|
|
561
|
+
buttonStyle: customAnswerSubmit === null || customAnswerSubmit === void 0 ? void 0 : customAnswerSubmit.buttonStyle,
|
|
562
|
+
disabled: inputDisabled || textInput === null || textInput === ''
|
|
563
|
+
}, /*#__PURE__*/React.createElement(Text, Object.assign({}, customAnswerSubmit, {
|
|
564
|
+
inline: true
|
|
565
|
+
}))) : null) : null, userAnswerIndex !== null && finalResult !== null ? /*#__PURE__*/React.createElement(Transitions, {
|
|
551
566
|
transitions: transitions,
|
|
552
567
|
playing: transitionPlaying,
|
|
553
568
|
disabled: transitionDisabled
|
|
@@ -660,9 +675,6 @@ var definition = {
|
|
|
660
675
|
isList: true,
|
|
661
676
|
theme: {
|
|
662
677
|
textStyle: 'button'
|
|
663
|
-
// placeholder: {
|
|
664
|
-
// textStyle: 'text',
|
|
665
|
-
// },
|
|
666
678
|
}
|
|
667
679
|
}, {
|
|
668
680
|
type: 'fields',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micromag/screen-survey",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.694",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"keywords": [
|
|
@@ -77,6 +77,7 @@
|
|
|
77
77
|
"@micromag/element-text-input": "^0.3.683",
|
|
78
78
|
"@micromag/transforms": "^0.3.679",
|
|
79
79
|
"classnames": "^2.2.6",
|
|
80
|
+
"dompurify": "^3.2.6",
|
|
80
81
|
"lodash": "^4.17.21",
|
|
81
82
|
"prop-types": "^15.7.2",
|
|
82
83
|
"react-intl": "^6.6.4",
|
|
@@ -86,5 +87,5 @@
|
|
|
86
87
|
"access": "public",
|
|
87
88
|
"registry": "https://registry.npmjs.org/"
|
|
88
89
|
},
|
|
89
|
-
"gitHead": "
|
|
90
|
+
"gitHead": "7d141396597c43d5951088f0124d1a9ca092e2f8"
|
|
90
91
|
}
|