@micromag/screen-survey 0.3.541 → 0.3.547
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/index.js +2 -3
- package/package.json +15 -16
- package/lib/index.js +0 -651
package/es/index.js
CHANGED
|
@@ -461,7 +461,6 @@ var SurveyScreen = function SurveyScreen(_ref) {
|
|
|
461
461
|
};
|
|
462
462
|
SurveyScreen.propTypes = propTypes;
|
|
463
463
|
SurveyScreen.defaultProps = defaultProps;
|
|
464
|
-
var SurveyScreen$1 = SurveyScreen;
|
|
465
464
|
|
|
466
465
|
var definition = {
|
|
467
466
|
id: 'survey',
|
|
@@ -483,7 +482,7 @@ var definition = {
|
|
|
483
482
|
"value": "Survey"
|
|
484
483
|
}]
|
|
485
484
|
}),
|
|
486
|
-
component: SurveyScreen
|
|
485
|
+
component: SurveyScreen,
|
|
487
486
|
layouts: ['top', 'middle', 'bottom', 'split'],
|
|
488
487
|
fields: [{
|
|
489
488
|
name: 'layout',
|
|
@@ -643,4 +642,4 @@ var definition = {
|
|
|
643
642
|
}]
|
|
644
643
|
};
|
|
645
644
|
|
|
646
|
-
export { SurveyScreen
|
|
645
|
+
export { SurveyScreen, definition as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micromag/screen-survey",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.547",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"keywords": [
|
|
@@ -30,12 +30,11 @@
|
|
|
30
30
|
}
|
|
31
31
|
],
|
|
32
32
|
"license": "ISC",
|
|
33
|
-
"
|
|
33
|
+
"type": "module",
|
|
34
34
|
"module": "es/index.js",
|
|
35
35
|
"style": "assets/css/styles.css",
|
|
36
36
|
"exports": {
|
|
37
37
|
".": {
|
|
38
|
-
"require": "./lib/index.js",
|
|
39
38
|
"import": "./es/index.js"
|
|
40
39
|
},
|
|
41
40
|
"./assets/css/styles": "./assets/css/styles.css",
|
|
@@ -61,18 +60,18 @@
|
|
|
61
60
|
},
|
|
62
61
|
"dependencies": {
|
|
63
62
|
"@babel/runtime": "^7.13.10",
|
|
64
|
-
"@micromag/core": "^0.3.
|
|
65
|
-
"@micromag/data": "^0.3.
|
|
66
|
-
"@micromag/element-background": "^0.3.
|
|
67
|
-
"@micromag/element-button": "^0.3.
|
|
68
|
-
"@micromag/element-container": "^0.3.
|
|
69
|
-
"@micromag/element-footer": "^0.3.
|
|
70
|
-
"@micromag/element-header": "^0.3.
|
|
71
|
-
"@micromag/element-heading": "^0.3.
|
|
72
|
-
"@micromag/element-layout": "^0.3.
|
|
73
|
-
"@micromag/element-scroll": "^0.3.
|
|
74
|
-
"@micromag/element-text": "^0.3.
|
|
75
|
-
"@micromag/transforms": "^0.3.
|
|
63
|
+
"@micromag/core": "^0.3.547",
|
|
64
|
+
"@micromag/data": "^0.3.547",
|
|
65
|
+
"@micromag/element-background": "^0.3.547",
|
|
66
|
+
"@micromag/element-button": "^0.3.547",
|
|
67
|
+
"@micromag/element-container": "^0.3.547",
|
|
68
|
+
"@micromag/element-footer": "^0.3.547",
|
|
69
|
+
"@micromag/element-header": "^0.3.547",
|
|
70
|
+
"@micromag/element-heading": "^0.3.547",
|
|
71
|
+
"@micromag/element-layout": "^0.3.547",
|
|
72
|
+
"@micromag/element-scroll": "^0.3.547",
|
|
73
|
+
"@micromag/element-text": "^0.3.547",
|
|
74
|
+
"@micromag/transforms": "^0.3.547",
|
|
76
75
|
"classnames": "^2.2.6",
|
|
77
76
|
"lodash": "^4.17.21",
|
|
78
77
|
"prop-types": "^15.7.2",
|
|
@@ -83,5 +82,5 @@
|
|
|
83
82
|
"access": "public",
|
|
84
83
|
"registry": "https://registry.npmjs.org/"
|
|
85
84
|
},
|
|
86
|
-
"gitHead": "
|
|
85
|
+
"gitHead": "3c2f5904ce61fcfa61f673c38c2a5ec56e9e2b07"
|
|
87
86
|
}
|
package/lib/index.js
DELETED
|
@@ -1,651 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var reactIntl = require('react-intl');
|
|
6
|
-
var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
|
|
7
|
-
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
8
|
-
var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
|
|
9
|
-
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
|
|
10
|
-
var classNames = require('classnames');
|
|
11
|
-
var isNumber = require('lodash/isNumber');
|
|
12
|
-
var PropTypes = require('prop-types');
|
|
13
|
-
var React = require('react');
|
|
14
|
-
var core = require('@micromag/core');
|
|
15
|
-
var components = require('@micromag/core/components');
|
|
16
|
-
var contexts = require('@micromag/core/contexts');
|
|
17
|
-
var hooks = require('@micromag/core/hooks');
|
|
18
|
-
var utils = require('@micromag/core/utils');
|
|
19
|
-
var data = require('@micromag/data');
|
|
20
|
-
var Background = require('@micromag/element-background');
|
|
21
|
-
var Button = require('@micromag/element-button');
|
|
22
|
-
var Container = require('@micromag/element-container');
|
|
23
|
-
var Footer = require('@micromag/element-footer');
|
|
24
|
-
var Header = require('@micromag/element-header');
|
|
25
|
-
var Heading = require('@micromag/element-heading');
|
|
26
|
-
var Layout = require('@micromag/element-layout');
|
|
27
|
-
var Scroll = require('@micromag/element-scroll');
|
|
28
|
-
var Text = require('@micromag/element-text');
|
|
29
|
-
|
|
30
|
-
var styles = {"container":"micromag-screen-survey-container","background":"micromag-screen-survey-background","disabled":"micromag-screen-survey-disabled","hidden":"micromag-screen-survey-hidden","placeholder":"micromag-screen-survey-placeholder","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","result":"micromag-screen-survey-result","answered":"micromag-screen-survey-answered","resultContainer":"micromag-screen-survey-resultContainer","resultContent":"micromag-screen-survey-resultContent","withPercentage":"micromag-screen-survey-withPercentage","isPlaceholder":"micromag-screen-survey-isPlaceholder","layout":"micromag-screen-survey-layout"};
|
|
31
|
-
|
|
32
|
-
var propTypes = {
|
|
33
|
-
id: PropTypes.string,
|
|
34
|
-
layout: PropTypes.oneOf(['top', 'middle', 'bottom', 'split']),
|
|
35
|
-
question: core.PropTypes.textElement,
|
|
36
|
-
answers: core.PropTypes.answers,
|
|
37
|
-
buttonsStyle: core.PropTypes.boxStyle,
|
|
38
|
-
buttonsTextStyle: core.PropTypes.textStyle,
|
|
39
|
-
resultsStyle: PropTypes.shape({
|
|
40
|
-
barColor: core.PropTypes.color,
|
|
41
|
-
textColor: core.PropTypes.color,
|
|
42
|
-
percentageTextStyle: core.PropTypes.textStyle
|
|
43
|
-
}),
|
|
44
|
-
spacing: PropTypes.number,
|
|
45
|
-
header: core.PropTypes.header,
|
|
46
|
-
footer: core.PropTypes.footer,
|
|
47
|
-
background: core.PropTypes.backgroundElement,
|
|
48
|
-
withoutPercentage: PropTypes.bool,
|
|
49
|
-
withoutBar: PropTypes.bool,
|
|
50
|
-
current: PropTypes.bool,
|
|
51
|
-
active: PropTypes.bool,
|
|
52
|
-
transitions: core.PropTypes.transitions,
|
|
53
|
-
// transitionStagger: PropTypes.number,
|
|
54
|
-
resultTransitionDuration: PropTypes.number,
|
|
55
|
-
type: PropTypes.string,
|
|
56
|
-
className: PropTypes.string
|
|
57
|
-
};
|
|
58
|
-
var defaultProps = {
|
|
59
|
-
id: null,
|
|
60
|
-
layout: 'middle',
|
|
61
|
-
question: null,
|
|
62
|
-
answers: null,
|
|
63
|
-
buttonsStyle: null,
|
|
64
|
-
buttonsTextStyle: null,
|
|
65
|
-
resultsStyle: null,
|
|
66
|
-
spacing: 20,
|
|
67
|
-
header: null,
|
|
68
|
-
footer: null,
|
|
69
|
-
background: null,
|
|
70
|
-
withoutPercentage: false,
|
|
71
|
-
withoutBar: false,
|
|
72
|
-
current: true,
|
|
73
|
-
active: true,
|
|
74
|
-
transitions: null,
|
|
75
|
-
// transitionStagger: 100,
|
|
76
|
-
resultTransitionDuration: 500,
|
|
77
|
-
type: null,
|
|
78
|
-
className: null
|
|
79
|
-
};
|
|
80
|
-
var SurveyScreen = function SurveyScreen(_ref) {
|
|
81
|
-
var id = _ref.id,
|
|
82
|
-
layout = _ref.layout,
|
|
83
|
-
question = _ref.question,
|
|
84
|
-
answers = _ref.answers,
|
|
85
|
-
buttonsStyle = _ref.buttonsStyle,
|
|
86
|
-
buttonsTextStyle = _ref.buttonsTextStyle,
|
|
87
|
-
resultsStyle = _ref.resultsStyle,
|
|
88
|
-
spacing = _ref.spacing,
|
|
89
|
-
header = _ref.header,
|
|
90
|
-
footer = _ref.footer,
|
|
91
|
-
background = _ref.background,
|
|
92
|
-
withoutPercentage = _ref.withoutPercentage,
|
|
93
|
-
withoutBar = _ref.withoutBar,
|
|
94
|
-
current = _ref.current,
|
|
95
|
-
active = _ref.active,
|
|
96
|
-
transitions = _ref.transitions,
|
|
97
|
-
resultTransitionDuration = _ref.resultTransitionDuration,
|
|
98
|
-
type = _ref.type,
|
|
99
|
-
className = _ref.className;
|
|
100
|
-
var screenId = id || 'screen-id';
|
|
101
|
-
var trackScreenEvent = hooks.useTrackScreenEvent(type);
|
|
102
|
-
var _useScreenSize = contexts.useScreenSize(),
|
|
103
|
-
width = _useScreenSize.width,
|
|
104
|
-
height = _useScreenSize.height,
|
|
105
|
-
resolution = _useScreenSize.resolution;
|
|
106
|
-
var _useQuizCreate = data.useQuizCreate({
|
|
107
|
-
screenId: screenId
|
|
108
|
-
}),
|
|
109
|
-
submitQuiz = _useQuizCreate.create;
|
|
110
|
-
var _useScreenRenderConte = contexts.useScreenRenderContext(),
|
|
111
|
-
isView = _useScreenRenderConte.isView,
|
|
112
|
-
isPreview = _useScreenRenderConte.isPreview,
|
|
113
|
-
isPlaceholder = _useScreenRenderConte.isPlaceholder,
|
|
114
|
-
isEdit = _useScreenRenderConte.isEdit,
|
|
115
|
-
isStatic = _useScreenRenderConte.isStatic,
|
|
116
|
-
isCapture = _useScreenRenderConte.isCapture;
|
|
117
|
-
var _useViewerContext = contexts.useViewerContext(),
|
|
118
|
-
viewerTopHeight = _useViewerContext.topHeight,
|
|
119
|
-
viewerBottomHeight = _useViewerContext.bottomHeight,
|
|
120
|
-
viewerBottomSidesWidth = _useViewerContext.bottomSidesWidth;
|
|
121
|
-
var _useViewerWebView = contexts.useViewerWebView(),
|
|
122
|
-
openWebView = _useViewerWebView.open;
|
|
123
|
-
var _usePlaybackContext = contexts.usePlaybackContext(),
|
|
124
|
-
muted = _usePlaybackContext.muted;
|
|
125
|
-
var mediaRef = contexts.usePlaybackMediaRef(current);
|
|
126
|
-
var _useQuiz = data.useQuiz({
|
|
127
|
-
screenId: screenId,
|
|
128
|
-
opts: {
|
|
129
|
-
autoload: !isPlaceholder
|
|
130
|
-
}
|
|
131
|
-
}),
|
|
132
|
-
_useQuiz$quiz = _useQuiz.quiz,
|
|
133
|
-
allQuizAnswers = _useQuiz$quiz === void 0 ? [] : _useQuiz$quiz;
|
|
134
|
-
var quizAnswers = allQuizAnswers.filter(function (item) {
|
|
135
|
-
var _ref2 = item || {},
|
|
136
|
-
_ref2$choice = _ref2.choice,
|
|
137
|
-
choice = _ref2$choice === void 0 ? null : _ref2$choice;
|
|
138
|
-
var answersBody = (answers || []).map(function (answer) {
|
|
139
|
-
var _ref3 = answer || {},
|
|
140
|
-
_ref3$label = _ref3.label,
|
|
141
|
-
label = _ref3$label === void 0 ? null : _ref3$label;
|
|
142
|
-
var _ref4 = label || {},
|
|
143
|
-
_ref4$body = _ref4.body,
|
|
144
|
-
body = _ref4$body === void 0 ? null : _ref4$body;
|
|
145
|
-
return body;
|
|
146
|
-
}).filter(function (body) {
|
|
147
|
-
return body !== null;
|
|
148
|
-
});
|
|
149
|
-
var hasResult = answersBody.find(function (body) {
|
|
150
|
-
return body === choice;
|
|
151
|
-
});
|
|
152
|
-
if (hasResult) {
|
|
153
|
-
return true;
|
|
154
|
-
}
|
|
155
|
-
return false;
|
|
156
|
-
});
|
|
157
|
-
var hasQuestion = utils.isTextFilled(question);
|
|
158
|
-
var showInstantAnswer = isStatic || isCapture;
|
|
159
|
-
var _useState = React.useState(showInstantAnswer ? -1 : null),
|
|
160
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
161
|
-
userAnswerIndex = _useState2[0],
|
|
162
|
-
setUserAnswerIndex = _useState2[1];
|
|
163
|
-
var answered = userAnswerIndex !== null;
|
|
164
|
-
var quizAnswersComputed = React.useMemo(function () {
|
|
165
|
-
var total = answers !== null ? (quizAnswers || []).reduce(function (points, _ref5) {
|
|
166
|
-
var _ref5$count = _ref5.count,
|
|
167
|
-
count = _ref5$count === void 0 ? 0 : _ref5$count;
|
|
168
|
-
return points + parseInt(count, 10);
|
|
169
|
-
}, userAnswerIndex !== null && userAnswerIndex > -1 ? 1 : 0) : 0;
|
|
170
|
-
var computed = answers !== null ? (answers || []).reduce(function (answersTotal, ans, i) {
|
|
171
|
-
var _ref6 = ans || {},
|
|
172
|
-
_ref6$label = _ref6.label,
|
|
173
|
-
label = _ref6$label === void 0 ? {} : _ref6$label;
|
|
174
|
-
var _ref7 = label || {},
|
|
175
|
-
_ref7$body = _ref7.body,
|
|
176
|
-
body = _ref7$body === void 0 ? null : _ref7$body;
|
|
177
|
-
var _ref8 = quizAnswers.find(function (qa) {
|
|
178
|
-
return qa.choice === body;
|
|
179
|
-
}) || {},
|
|
180
|
-
_ref8$count = _ref8.count,
|
|
181
|
-
count = _ref8$count === void 0 ? 0 : _ref8$count;
|
|
182
|
-
var countWithUser = i === userAnswerIndex ? count + 1 : count;
|
|
183
|
-
if (body !== null) {
|
|
184
|
-
return _objectSpread(_objectSpread({}, answersTotal), {}, _defineProperty({}, body, {
|
|
185
|
-
percent: total > 0 ? countWithUser / total * 100 : 0,
|
|
186
|
-
count: countWithUser
|
|
187
|
-
}));
|
|
188
|
-
}
|
|
189
|
-
return answersTotal;
|
|
190
|
-
}, {}) : {};
|
|
191
|
-
var quizAnswersPct = total > 0 ? Object.keys(computed).map(function (key) {
|
|
192
|
-
return computed[key].percent || 0;
|
|
193
|
-
}) : [];
|
|
194
|
-
var evenlySplit = utils.getLargestRemainderRound(quizAnswersPct, 100);
|
|
195
|
-
return Object.keys(computed).reduce(function (acc, key, i) {
|
|
196
|
-
return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, key, _objectSpread(_objectSpread({}, computed[key]), {}, {
|
|
197
|
-
percent: evenlySplit[i]
|
|
198
|
-
})));
|
|
199
|
-
}, {});
|
|
200
|
-
}, [answers, quizAnswers, userAnswerIndex]);
|
|
201
|
-
var isSplitted = layout === 'split';
|
|
202
|
-
// const isTopLayout = layout === 'top';
|
|
203
|
-
var isMiddleLayout = layout === 'middle';
|
|
204
|
-
var verticalAlign = isSplitted ? null : layout;
|
|
205
|
-
var transitionPlaying = current;
|
|
206
|
-
var transitionDisabled = isStatic || isCapture || isPlaceholder || isPreview || isEdit;
|
|
207
|
-
var backgroundPlaying = current && (isView || isEdit);
|
|
208
|
-
var mediaShouldLoad = current || active;
|
|
209
|
-
var onAnswerClick = React.useCallback(function (answerIndex) {
|
|
210
|
-
if (userAnswerIndex === null) {
|
|
211
|
-
setUserAnswerIndex(answerIndex);
|
|
212
|
-
var answer = answers[answerIndex];
|
|
213
|
-
submitQuiz({
|
|
214
|
-
choice: answer.label.body || answerIndex,
|
|
215
|
-
value: 1
|
|
216
|
-
});
|
|
217
|
-
trackScreenEvent('click_answer', "Answer ".concat(userAnswerIndex + 1, ": ").concat(answer.label.body), {
|
|
218
|
-
answer: answer,
|
|
219
|
-
answerIndex: answerIndex
|
|
220
|
-
});
|
|
221
|
-
}
|
|
222
|
-
}, [userAnswerIndex, setUserAnswerIndex, trackScreenEvent, submitQuiz]);
|
|
223
|
-
React.useEffect(function () {
|
|
224
|
-
if (!current && isEdit && userAnswerIndex !== null) {
|
|
225
|
-
setUserAnswerIndex(null);
|
|
226
|
-
}
|
|
227
|
-
}, [isEdit, current, userAnswerIndex, setUserAnswerIndex]);
|
|
228
|
-
var hasHeader = utils.isHeaderFilled(header);
|
|
229
|
-
var hasFooter = utils.isFooterFilled(footer);
|
|
230
|
-
var footerProps = utils.getFooterProps(footer, {
|
|
231
|
-
isView: isView,
|
|
232
|
-
current: current,
|
|
233
|
-
openWebView: openWebView,
|
|
234
|
-
isPreview: isPreview
|
|
235
|
-
});
|
|
236
|
-
var _useDimensionObserver = hooks.useDimensionObserver(),
|
|
237
|
-
headerRef = _useDimensionObserver.ref,
|
|
238
|
-
_useDimensionObserver2 = _useDimensionObserver.height,
|
|
239
|
-
headerHeight = _useDimensionObserver2 === void 0 ? 0 : _useDimensionObserver2;
|
|
240
|
-
var _useDimensionObserver3 = hooks.useDimensionObserver(),
|
|
241
|
-
footerRef = _useDimensionObserver3.ref,
|
|
242
|
-
_useDimensionObserver4 = _useDimensionObserver3.height,
|
|
243
|
-
footerHeight = _useDimensionObserver4 === void 0 ? 0 : _useDimensionObserver4;
|
|
244
|
-
var scrollingDisabled = !isEdit && transitionDisabled || !current;
|
|
245
|
-
var _useState3 = React.useState(false),
|
|
246
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
247
|
-
scrolledBottom = _useState4[0],
|
|
248
|
-
setScrolledBottom = _useState4[1];
|
|
249
|
-
var onScrolledBottom = React.useCallback(function (_ref9) {
|
|
250
|
-
var initial = _ref9.initial;
|
|
251
|
-
if (initial) {
|
|
252
|
-
trackScreenEvent('scroll', 'Screen');
|
|
253
|
-
}
|
|
254
|
-
setScrolledBottom(true);
|
|
255
|
-
}, [trackScreenEvent]);
|
|
256
|
-
var onScrolledNotBottom = React.useCallback(function () {
|
|
257
|
-
setScrolledBottom(false);
|
|
258
|
-
}, [setScrolledBottom]);
|
|
259
|
-
var _useState5 = React.useState(false),
|
|
260
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
261
|
-
hasScroll = _useState6[0],
|
|
262
|
-
setHasScroll = _useState6[1];
|
|
263
|
-
var onScrollHeightChange = React.useCallback(function (_ref10) {
|
|
264
|
-
var _ref10$canScroll = _ref10.canScroll,
|
|
265
|
-
canScroll = _ref10$canScroll === void 0 ? false : _ref10$canScroll;
|
|
266
|
-
setHasScroll(canScroll);
|
|
267
|
-
}, [setHasScroll]);
|
|
268
|
-
|
|
269
|
-
// Question
|
|
270
|
-
var items = [/*#__PURE__*/React.createElement(components.ScreenElement, {
|
|
271
|
-
key: "question",
|
|
272
|
-
placeholder: "title",
|
|
273
|
-
emptyLabel: /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
|
|
274
|
-
id: "e1I+KU",
|
|
275
|
-
defaultMessage: [{
|
|
276
|
-
"type": 0,
|
|
277
|
-
"value": "Question"
|
|
278
|
-
}]
|
|
279
|
-
}),
|
|
280
|
-
emptyClassName: styles.emptyQuestion,
|
|
281
|
-
isEmpty: !hasQuestion
|
|
282
|
-
}, hasQuestion ? /*#__PURE__*/React.createElement(components.Transitions, {
|
|
283
|
-
transitions: transitions,
|
|
284
|
-
playing: transitionPlaying,
|
|
285
|
-
disabled: transitionDisabled
|
|
286
|
-
}, /*#__PURE__*/React.createElement(Heading, Object.assign({}, question, {
|
|
287
|
-
className: styles.question
|
|
288
|
-
}))) : null)];
|
|
289
|
-
if (isSplitted || !isPlaceholder && hasFooter && isMiddleLayout) {
|
|
290
|
-
items.push( /*#__PURE__*/React.createElement(Layout.Spacer, {
|
|
291
|
-
key: "spacer"
|
|
292
|
-
}));
|
|
293
|
-
}
|
|
294
|
-
var finalTransitionDuration = showInstantAnswer ? 0 : "".concat(resultTransitionDuration, "ms");
|
|
295
|
-
var _ref11 = resultsStyle || {},
|
|
296
|
-
_ref11$barColor = _ref11.barColor,
|
|
297
|
-
resultsBarColor = _ref11$barColor === void 0 ? null : _ref11$barColor,
|
|
298
|
-
_ref11$textColor = _ref11.textColor,
|
|
299
|
-
resultsTextColor = _ref11$textColor === void 0 ? null : _ref11$textColor,
|
|
300
|
-
_ref11$percentageText = _ref11.percentageTextStyle,
|
|
301
|
-
resultsPercentageTextStyle = _ref11$percentageText === void 0 ? null : _ref11$percentageText;
|
|
302
|
-
items.push( /*#__PURE__*/React.createElement("div", {
|
|
303
|
-
key: "answers",
|
|
304
|
-
className: styles.answers
|
|
305
|
-
}, answers !== null || isPlaceholder ? /*#__PURE__*/React.createElement("div", {
|
|
306
|
-
className: styles.items
|
|
307
|
-
}, (isPlaceholder ? _toConsumableArray(new Array(3)) : answers).map(function (answer, answerIndex) {
|
|
308
|
-
var hasAnswer = answer !== null;
|
|
309
|
-
var _ref12 = answer || {},
|
|
310
|
-
_ref12$label = _ref12.label,
|
|
311
|
-
label = _ref12$label === void 0 ? null : _ref12$label,
|
|
312
|
-
_ref12$buttonStyle = _ref12.buttonStyle,
|
|
313
|
-
answerButtonStyle = _ref12$buttonStyle === void 0 ? null : _ref12$buttonStyle,
|
|
314
|
-
_ref12$textStyle = _ref12.textStyle,
|
|
315
|
-
answerButtonTextStyle = _ref12$textStyle === void 0 ? null : _ref12$textStyle,
|
|
316
|
-
_ref12$resultStyle = _ref12.resultStyle,
|
|
317
|
-
answerResultStyle = _ref12$resultStyle === void 0 ? null : _ref12$resultStyle;
|
|
318
|
-
var _ref13 = answerResultStyle || {},
|
|
319
|
-
_ref13$barColor = _ref13.barColor,
|
|
320
|
-
answerResultBarColor = _ref13$barColor === void 0 ? null : _ref13$barColor,
|
|
321
|
-
answerResultTextColor = _ref13.textColor,
|
|
322
|
-
_ref13$percentageText = _ref13.percentageTextStyle,
|
|
323
|
-
answerResultPercentageTextStyle = _ref13$percentageText === void 0 ? null : _ref13$percentageText;
|
|
324
|
-
var _ref14 = label || {},
|
|
325
|
-
_ref14$body = _ref14.body,
|
|
326
|
-
body = _ref14$body === void 0 ? null : _ref14$body;
|
|
327
|
-
var _ref15 = body !== null ? quizAnswersComputed[body] || {} : {},
|
|
328
|
-
_ref15$percent = _ref15.percent,
|
|
329
|
-
percent = _ref15$percent === void 0 ? 0 : _ref15$percent;
|
|
330
|
-
var _ref16 = label || {},
|
|
331
|
-
_ref16$textStyle = _ref16.textStyle,
|
|
332
|
-
textStyle = _ref16$textStyle === void 0 ? null : _ref16$textStyle;
|
|
333
|
-
var _ref17 = textStyle || {},
|
|
334
|
-
_ref17$color = _ref17.color,
|
|
335
|
-
labelColor = _ref17$color === void 0 ? null : _ref17$color;
|
|
336
|
-
var hasAnswerLabel = utils.isTextFilled(label);
|
|
337
|
-
var userAnswer = userAnswerIndex === answerIndex;
|
|
338
|
-
var buttonStyles = _objectSpread(_objectSpread(_objectSpread({}, buttonsStyle), answerButtonStyle), answered ? {
|
|
339
|
-
textAlign: 'left'
|
|
340
|
-
} : null);
|
|
341
|
-
var _ref18 = buttonStyles || {},
|
|
342
|
-
_ref18$borderRadius = _ref18.borderRadius,
|
|
343
|
-
answerResultBorderRadius = _ref18$borderRadius === void 0 ? null : _ref18$borderRadius;
|
|
344
|
-
var finalBarBorderRadius = answerResultBorderRadius !== null && isNumber(answerResultBorderRadius) && answerResultBorderRadius > 2 ? answerResultBorderRadius - 2 : answerResultBorderRadius;
|
|
345
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
346
|
-
key: "answer-".concat(answerIndex),
|
|
347
|
-
className: classNames([styles.item, _defineProperty({}, styles.userAnswer, userAnswer)])
|
|
348
|
-
}, /*#__PURE__*/React.createElement(components.ScreenElement, {
|
|
349
|
-
placeholder: "surveyAnswer",
|
|
350
|
-
placeholderProps: {
|
|
351
|
-
className: styles.placeholderAnswer
|
|
352
|
-
},
|
|
353
|
-
emptyLabel: /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
|
|
354
|
-
id: "+Ok+7S",
|
|
355
|
-
defaultMessage: [{
|
|
356
|
-
"type": 0,
|
|
357
|
-
"value": "Answer"
|
|
358
|
-
}]
|
|
359
|
-
}),
|
|
360
|
-
emptyClassName: styles.emptyAnswer,
|
|
361
|
-
isEmpty: !hasAnswerLabel
|
|
362
|
-
}, hasAnswer ? /*#__PURE__*/React.createElement("div", {
|
|
363
|
-
className: styles.itemContent
|
|
364
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
365
|
-
className: styles.itemInner,
|
|
366
|
-
style: {
|
|
367
|
-
borderRadius: answerResultBorderRadius,
|
|
368
|
-
transitionDuration: finalTransitionDuration
|
|
369
|
-
}
|
|
370
|
-
}, /*#__PURE__*/React.createElement(Button, {
|
|
371
|
-
className: styles.button,
|
|
372
|
-
onPointerUp: function onPointerUp(e) {
|
|
373
|
-
if (e.pointerType !== 'mouse' || e.button === 0) {
|
|
374
|
-
onAnswerClick(answerIndex);
|
|
375
|
-
}
|
|
376
|
-
},
|
|
377
|
-
disabled: isPreview || userAnswerIndex !== null,
|
|
378
|
-
focusable: current && isView,
|
|
379
|
-
buttonStyle: buttonStyles,
|
|
380
|
-
textStyle: _objectSpread(_objectSpread(_objectSpread({}, textStyle), buttonsTextStyle), answerButtonTextStyle)
|
|
381
|
-
}, /*#__PURE__*/React.createElement("span", {
|
|
382
|
-
className: styles.itemLabel
|
|
383
|
-
}, /*#__PURE__*/React.createElement(Text, Object.assign({}, label, {
|
|
384
|
-
textStyle: _objectSpread(_objectSpread(_objectSpread({}, textStyle), buttonsTextStyle), answerButtonTextStyle),
|
|
385
|
-
inline: true,
|
|
386
|
-
className: styles.itemText
|
|
387
|
-
})), !withoutPercentage ? /*#__PURE__*/React.createElement("div", {
|
|
388
|
-
className: styles.resultLabel,
|
|
389
|
-
style: _objectSpread(_objectSpread({}, utils.getStyleFromColor(answered ? answerResultTextColor || resultsTextColor || answerResultBarColor || resultsBarColor || labelColor : null, 'color')), answered ? {
|
|
390
|
-
opacity: 1
|
|
391
|
-
} : {
|
|
392
|
-
opacity: 0
|
|
393
|
-
})
|
|
394
|
-
}, /*#__PURE__*/React.createElement(Text, Object.assign({}, label, {
|
|
395
|
-
textStyle: _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, textStyle), buttonsTextStyle), answerButtonTextStyle), resultsTextColor), resultsPercentageTextStyle), answerResultTextColor), answerResultPercentageTextStyle),
|
|
396
|
-
inline: true,
|
|
397
|
-
className: styles.resultText,
|
|
398
|
-
body: "".concat(percent, "%")
|
|
399
|
-
}))) : null, !withoutBar ? /*#__PURE__*/React.createElement("div", {
|
|
400
|
-
className: styles.resultBar,
|
|
401
|
-
style: _objectSpread(_objectSpread({
|
|
402
|
-
borderRadius: finalBarBorderRadius,
|
|
403
|
-
transitionDuration: finalTransitionDuration,
|
|
404
|
-
width: percent !== null ? "".concat(percent, "%") : '0%'
|
|
405
|
-
}, utils.getStyleFromColor(answerResultBarColor || resultsBarColor || labelColor, 'backgroundColor')), answered ? {
|
|
406
|
-
opacity: 0.5
|
|
407
|
-
} : {
|
|
408
|
-
opacity: 0
|
|
409
|
-
})
|
|
410
|
-
}) : null)))) : null));
|
|
411
|
-
})) : null));
|
|
412
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
413
|
-
className: classNames([styles.container, _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, className, className !== null), styles.answered, answered), styles.withPercentage, !withoutPercentage), styles.isPlaceholder, isPlaceholder)])
|
|
414
|
-
}, /*#__PURE__*/React.createElement(Container, {
|
|
415
|
-
width: width,
|
|
416
|
-
height: height,
|
|
417
|
-
className: styles.content
|
|
418
|
-
}, /*#__PURE__*/React.createElement(Scroll, {
|
|
419
|
-
verticalAlign: verticalAlign,
|
|
420
|
-
disabled: scrollingDisabled,
|
|
421
|
-
onScrolledBottom: onScrolledBottom,
|
|
422
|
-
onScrolledNotBottom: onScrolledNotBottom,
|
|
423
|
-
onScrollHeightChange: onScrollHeightChange,
|
|
424
|
-
withShadow: true
|
|
425
|
-
}, !isPlaceholder && hasHeader ? /*#__PURE__*/React.createElement("div", {
|
|
426
|
-
className: classNames([styles.header, _defineProperty({}, styles.disabled, scrolledBottom && !scrollingDisabled && hasScroll)]),
|
|
427
|
-
ref: headerRef,
|
|
428
|
-
style: {
|
|
429
|
-
paddingTop: spacing / 2,
|
|
430
|
-
paddingLeft: spacing,
|
|
431
|
-
paddingRight: spacing,
|
|
432
|
-
paddingBottom: spacing,
|
|
433
|
-
transform: !isPreview ? "translate(0, ".concat(viewerTopHeight, "px)") : null
|
|
434
|
-
}
|
|
435
|
-
}, /*#__PURE__*/React.createElement(Header, header)) : null, /*#__PURE__*/React.createElement(Layout, {
|
|
436
|
-
className: styles.layout,
|
|
437
|
-
verticalAlign: verticalAlign,
|
|
438
|
-
style: !isPlaceholder ? {
|
|
439
|
-
padding: spacing,
|
|
440
|
-
paddingTop: (current && !isPreview ? viewerTopHeight : 0) + (headerHeight || spacing),
|
|
441
|
-
paddingBottom: (current && !isPreview ? viewerBottomHeight : 0) + (footerHeight + spacing)
|
|
442
|
-
} : null
|
|
443
|
-
}, items)), !isPlaceholder && hasFooter ? /*#__PURE__*/React.createElement("div", {
|
|
444
|
-
ref: footerRef,
|
|
445
|
-
className: classNames([styles.footer, _defineProperty({}, styles.disabled, !scrolledBottom)]),
|
|
446
|
-
style: {
|
|
447
|
-
transform: !isPreview ? "translate(0, -".concat(viewerBottomHeight, "px)") : null,
|
|
448
|
-
paddingLeft: Math.max(spacing / 2, viewerBottomSidesWidth),
|
|
449
|
-
paddingRight: Math.max(spacing / 2, viewerBottomSidesWidth),
|
|
450
|
-
paddingTop: spacing / 2,
|
|
451
|
-
paddingBottom: spacing / 2
|
|
452
|
-
}
|
|
453
|
-
}, /*#__PURE__*/React.createElement(Footer, footerProps)) : null), !isPlaceholder ? /*#__PURE__*/React.createElement(Background, {
|
|
454
|
-
background: background,
|
|
455
|
-
width: width,
|
|
456
|
-
height: height,
|
|
457
|
-
resolution: resolution,
|
|
458
|
-
playing: backgroundPlaying,
|
|
459
|
-
muted: muted,
|
|
460
|
-
shouldLoad: mediaShouldLoad,
|
|
461
|
-
mediaRef: mediaRef,
|
|
462
|
-
withoutVideo: isPreview,
|
|
463
|
-
className: styles.background
|
|
464
|
-
}) : null);
|
|
465
|
-
};
|
|
466
|
-
SurveyScreen.propTypes = propTypes;
|
|
467
|
-
SurveyScreen.defaultProps = defaultProps;
|
|
468
|
-
var SurveyScreen$1 = SurveyScreen;
|
|
469
|
-
|
|
470
|
-
var definition = {
|
|
471
|
-
id: 'survey',
|
|
472
|
-
type: 'screen',
|
|
473
|
-
group: {
|
|
474
|
-
label: reactIntl.defineMessage({
|
|
475
|
-
id: "ZiWlL6",
|
|
476
|
-
defaultMessage: [{
|
|
477
|
-
"type": 0,
|
|
478
|
-
"value": "Questions"
|
|
479
|
-
}]
|
|
480
|
-
}),
|
|
481
|
-
order: 7
|
|
482
|
-
},
|
|
483
|
-
title: reactIntl.defineMessage({
|
|
484
|
-
id: "650XRF",
|
|
485
|
-
defaultMessage: [{
|
|
486
|
-
"type": 0,
|
|
487
|
-
"value": "Survey"
|
|
488
|
-
}]
|
|
489
|
-
}),
|
|
490
|
-
component: SurveyScreen$1,
|
|
491
|
-
layouts: ['top', 'middle', 'bottom', 'split'],
|
|
492
|
-
fields: [{
|
|
493
|
-
name: 'layout',
|
|
494
|
-
type: 'screen-layout',
|
|
495
|
-
defaultValue: 'top',
|
|
496
|
-
label: reactIntl.defineMessage({
|
|
497
|
-
id: "4iBXj2",
|
|
498
|
-
defaultMessage: [{
|
|
499
|
-
"type": 0,
|
|
500
|
-
"value": "Layout"
|
|
501
|
-
}]
|
|
502
|
-
})
|
|
503
|
-
}, {
|
|
504
|
-
name: 'question',
|
|
505
|
-
type: 'heading-element',
|
|
506
|
-
theme: {
|
|
507
|
-
textStyle: 'heading2'
|
|
508
|
-
},
|
|
509
|
-
label: reactIntl.defineMessage({
|
|
510
|
-
id: "hVE7TA",
|
|
511
|
-
defaultMessage: [{
|
|
512
|
-
"type": 0,
|
|
513
|
-
"value": "Question"
|
|
514
|
-
}]
|
|
515
|
-
})
|
|
516
|
-
}, {
|
|
517
|
-
name: 'answers',
|
|
518
|
-
type: 'answers',
|
|
519
|
-
theme: {
|
|
520
|
-
label: {
|
|
521
|
-
textStyle: 'button'
|
|
522
|
-
}
|
|
523
|
-
},
|
|
524
|
-
label: reactIntl.defineMessage({
|
|
525
|
-
id: "KHWeV7",
|
|
526
|
-
defaultMessage: [{
|
|
527
|
-
"type": 0,
|
|
528
|
-
"value": "Answers"
|
|
529
|
-
}]
|
|
530
|
-
})
|
|
531
|
-
}, {
|
|
532
|
-
type: 'fields',
|
|
533
|
-
isList: true,
|
|
534
|
-
label: reactIntl.defineMessage({
|
|
535
|
-
id: "R9DB4a",
|
|
536
|
-
defaultMessage: [{
|
|
537
|
-
"type": 0,
|
|
538
|
-
"value": "Styles"
|
|
539
|
-
}]
|
|
540
|
-
}),
|
|
541
|
-
fields: [{
|
|
542
|
-
name: 'withoutPercentage',
|
|
543
|
-
type: 'toggle',
|
|
544
|
-
defaultValue: false,
|
|
545
|
-
label: reactIntl.defineMessage({
|
|
546
|
-
id: "crLqJd",
|
|
547
|
-
defaultMessage: [{
|
|
548
|
-
"type": 0,
|
|
549
|
-
"value": "Without percentage"
|
|
550
|
-
}]
|
|
551
|
-
})
|
|
552
|
-
}, {
|
|
553
|
-
name: 'withoutBar',
|
|
554
|
-
type: 'toggle',
|
|
555
|
-
defaultValue: false,
|
|
556
|
-
label: reactIntl.defineMessage({
|
|
557
|
-
id: "D7kxD3",
|
|
558
|
-
defaultMessage: [{
|
|
559
|
-
"type": 0,
|
|
560
|
-
"value": "Without bar"
|
|
561
|
-
}]
|
|
562
|
-
})
|
|
563
|
-
}, {
|
|
564
|
-
name: 'buttonsStyle',
|
|
565
|
-
type: 'box-style-form',
|
|
566
|
-
label: reactIntl.defineMessage({
|
|
567
|
-
id: "l5uLMd",
|
|
568
|
-
defaultMessage: [{
|
|
569
|
-
"type": 0,
|
|
570
|
-
"value": "Buttons"
|
|
571
|
-
}]
|
|
572
|
-
})
|
|
573
|
-
}, {
|
|
574
|
-
name: 'buttonsTextStyle',
|
|
575
|
-
type: 'text-style-form',
|
|
576
|
-
label: reactIntl.defineMessage({
|
|
577
|
-
id: "gwPu/I",
|
|
578
|
-
defaultMessage: [{
|
|
579
|
-
"type": 0,
|
|
580
|
-
"value": "Buttons text"
|
|
581
|
-
}]
|
|
582
|
-
})
|
|
583
|
-
}, {
|
|
584
|
-
name: 'resultsStyle',
|
|
585
|
-
type: 'graph-bar-style-form',
|
|
586
|
-
label: reactIntl.defineMessage({
|
|
587
|
-
id: "e4UTx9",
|
|
588
|
-
defaultMessage: [{
|
|
589
|
-
"type": 0,
|
|
590
|
-
"value": "Results"
|
|
591
|
-
}]
|
|
592
|
-
}),
|
|
593
|
-
noValueLabel: reactIntl.defineMessage({
|
|
594
|
-
id: "65rc70",
|
|
595
|
-
defaultMessage: [{
|
|
596
|
-
"type": 0,
|
|
597
|
-
"value": "Edit style..."
|
|
598
|
-
}]
|
|
599
|
-
})
|
|
600
|
-
}]
|
|
601
|
-
}, {
|
|
602
|
-
name: 'background',
|
|
603
|
-
type: 'background',
|
|
604
|
-
label: reactIntl.defineMessage({
|
|
605
|
-
id: "+MPZRu",
|
|
606
|
-
defaultMessage: [{
|
|
607
|
-
"type": 0,
|
|
608
|
-
"value": "Background"
|
|
609
|
-
}]
|
|
610
|
-
})
|
|
611
|
-
}, {
|
|
612
|
-
name: 'header',
|
|
613
|
-
type: 'header',
|
|
614
|
-
label: reactIntl.defineMessage({
|
|
615
|
-
id: "rhuDxI",
|
|
616
|
-
defaultMessage: [{
|
|
617
|
-
"type": 0,
|
|
618
|
-
"value": "Header"
|
|
619
|
-
}]
|
|
620
|
-
}),
|
|
621
|
-
theme: {
|
|
622
|
-
badge: {
|
|
623
|
-
label: {
|
|
624
|
-
textStyle: 'badge'
|
|
625
|
-
},
|
|
626
|
-
boxStyle: 'badge'
|
|
627
|
-
}
|
|
628
|
-
}
|
|
629
|
-
}, {
|
|
630
|
-
name: 'footer',
|
|
631
|
-
type: 'footer',
|
|
632
|
-
label: reactIntl.defineMessage({
|
|
633
|
-
id: "g4nybp",
|
|
634
|
-
defaultMessage: [{
|
|
635
|
-
"type": 0,
|
|
636
|
-
"value": "Footer"
|
|
637
|
-
}]
|
|
638
|
-
}),
|
|
639
|
-
theme: {
|
|
640
|
-
callToAction: {
|
|
641
|
-
label: {
|
|
642
|
-
textStyle: 'cta'
|
|
643
|
-
},
|
|
644
|
-
boxStyle: 'cta'
|
|
645
|
-
}
|
|
646
|
-
}
|
|
647
|
-
}]
|
|
648
|
-
};
|
|
649
|
-
|
|
650
|
-
exports.SurveyScreen = SurveyScreen$1;
|
|
651
|
-
exports.default = definition;
|