case-editor-tools 1.0.0-beta.17 → 1.0.0-beta.18
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/package.json +1 -1
- package/surveys/index.js +2 -0
- package/surveys/index.js.map +1 -1
- package/surveys/responseTypeGenerators/likertGroupComponents.d.ts +27 -0
- package/surveys/responseTypeGenerators/likertGroupComponents.js +347 -0
- package/surveys/responseTypeGenerators/likertGroupComponents.js.map +1 -0
- package/surveys/responseTypeGenerators/matrixGroupComponent.d.ts +49 -0
- package/surveys/responseTypeGenerators/matrixGroupComponent.js +99 -0
- package/surveys/responseTypeGenerators/matrixGroupComponent.js.map +1 -0
- package/surveys/responseTypeGenerators/optionGroupComponents.d.ts +7 -0
- package/surveys/responseTypeGenerators/optionGroupComponents.js +125 -0
- package/surveys/responseTypeGenerators/optionGroupComponents.js.map +1 -0
- package/surveys/survey-items.d.ts +10 -78
- package/surveys/survey-items.js +65 -848
- package/surveys/survey-items.js.map +1 -1
package/surveys/survey-items.js
CHANGED
|
@@ -7,15 +7,16 @@ var surveys_surveyEditor_itemEditor = require('../item-editor-7f825952.js');
|
|
|
7
7
|
var surveys_utils_componentGenerators = require('./utils/componentGenerators.js');
|
|
8
8
|
var types_duration = require('../types/duration.js');
|
|
9
9
|
var constants_keyDefinitions = require('../constants/key-definitions.js');
|
|
10
|
-
var surveys_utils_randomKeyGenerator = require('./utils/randomKeyGenerator.js');
|
|
11
10
|
var surveys_utils_simpleGenerators = require('./utils/simple-generators.js');
|
|
12
11
|
var surveys_utils_simpleQuestionEditor = require('./utils/simple-question-editor.js');
|
|
13
12
|
var surveys_surveyEngineExpressions = require('./survey-engine-expressions.js');
|
|
13
|
+
var surveys_responseTypeGenerators_optionGroupComponents = require('./responseTypeGenerators/optionGroupComponents.js');
|
|
14
|
+
var surveys_responseTypeGenerators_likertGroupComponents = require('./responseTypeGenerators/likertGroupComponents.js');
|
|
15
|
+
require('./utils/randomKeyGenerator.js');
|
|
14
16
|
require('../logger/logger.js');
|
|
15
17
|
require('../expression-utils/expressionGen.js');
|
|
16
18
|
|
|
17
|
-
const
|
|
18
|
-
var _a, _b, _c, _d;
|
|
19
|
+
const commonQuestionGenerator = (props, rg_inner) => {
|
|
19
20
|
const simpleEditor = new surveys_utils_simpleQuestionEditor.SimpleQuestionEditor(props.parentKey, props.itemKey, props.version ? props.version : 1);
|
|
20
21
|
// QUESTION TEXT
|
|
21
22
|
simpleEditor.setTitle(props.questionText, props.questionSubText, props.titleClassName);
|
|
@@ -28,6 +29,23 @@ const generateNumericInputQuestion = (props) => {
|
|
|
28
29
|
if (props.topDisplayCompoments) {
|
|
29
30
|
props.topDisplayCompoments.forEach(comp => simpleEditor.addDisplayComponent(comp));
|
|
30
31
|
}
|
|
32
|
+
simpleEditor.setResponseGroupWithContent(rg_inner);
|
|
33
|
+
if (props.bottomDisplayCompoments) {
|
|
34
|
+
props.bottomDisplayCompoments.forEach(comp => simpleEditor.addDisplayComponent(comp));
|
|
35
|
+
}
|
|
36
|
+
if (props.isRequired) {
|
|
37
|
+
simpleEditor.addHasResponseValidation();
|
|
38
|
+
}
|
|
39
|
+
if (props.customValidations) {
|
|
40
|
+
props.customValidations.forEach(v => simpleEditor.editor.addValidation(v));
|
|
41
|
+
}
|
|
42
|
+
if (props.footnoteText) {
|
|
43
|
+
simpleEditor.addDisplayComponent(surveys_utils_componentGenerators.ComponentGenerators.footnote({ content: props.footnoteText }));
|
|
44
|
+
}
|
|
45
|
+
return simpleEditor.getItem();
|
|
46
|
+
};
|
|
47
|
+
const generateNumericInputQuestion = (props) => {
|
|
48
|
+
var _a, _b, _c, _d;
|
|
31
49
|
const style = [];
|
|
32
50
|
if (props.inputMaxWidth) {
|
|
33
51
|
style.push({
|
|
@@ -48,239 +66,69 @@ const generateNumericInputQuestion = (props) => {
|
|
|
48
66
|
content: surveys_utils_simpleGenerators.generateLocStrings(props.inputLabel),
|
|
49
67
|
style: style.length > 0 ? style : undefined,
|
|
50
68
|
};
|
|
51
|
-
|
|
52
|
-
if (props.bottomDisplayCompoments) {
|
|
53
|
-
props.bottomDisplayCompoments.forEach(comp => simpleEditor.addDisplayComponent(comp));
|
|
54
|
-
}
|
|
55
|
-
if (props.isRequired) {
|
|
56
|
-
simpleEditor.addHasResponseValidation();
|
|
57
|
-
}
|
|
58
|
-
if (props.customValidations) {
|
|
59
|
-
props.customValidations.forEach(v => simpleEditor.editor.addValidation(v));
|
|
60
|
-
}
|
|
61
|
-
if (props.footnoteText) {
|
|
62
|
-
simpleEditor.addDisplayComponent({
|
|
63
|
-
role: 'footnote', content: surveys_utils_simpleGenerators.generateLocStrings(props.footnoteText), style: [
|
|
64
|
-
{ key: 'className', value: 'fs-small fst-italic text-center' }
|
|
65
|
-
]
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
return simpleEditor.getItem();
|
|
69
|
+
return commonQuestionGenerator(props, rg_inner);
|
|
69
70
|
};
|
|
70
71
|
const generateSingleChoiceQuestion = (props) => {
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
simpleEditor.setTitle(props.questionText, props.questionSubText, props.titleClassName);
|
|
74
|
-
if (props.condition) {
|
|
75
|
-
simpleEditor.setCondition(props.condition);
|
|
76
|
-
}
|
|
77
|
-
if (props.helpGroupContent) {
|
|
78
|
-
simpleEditor.editor.setHelpGroupComponent(surveys_utils_simpleGenerators.generateHelpGroupComponent(props.helpGroupContent));
|
|
79
|
-
}
|
|
80
|
-
if (props.topDisplayCompoments) {
|
|
81
|
-
props.topDisplayCompoments.forEach(comp => simpleEditor.addDisplayComponent(comp));
|
|
82
|
-
}
|
|
83
|
-
const rg_inner = initSingleChoiceGroup(constants_keyDefinitions.singleChoiceKey, props.responseOptions);
|
|
84
|
-
simpleEditor.setResponseGroupWithContent(rg_inner);
|
|
85
|
-
if (props.bottomDisplayCompoments) {
|
|
86
|
-
props.bottomDisplayCompoments.forEach(comp => simpleEditor.addDisplayComponent(comp));
|
|
87
|
-
}
|
|
88
|
-
if (props.isRequired) {
|
|
89
|
-
simpleEditor.addHasResponseValidation();
|
|
90
|
-
}
|
|
91
|
-
if (props.customValidations) {
|
|
92
|
-
props.customValidations.forEach(v => simpleEditor.editor.addValidation(v));
|
|
93
|
-
}
|
|
94
|
-
if (props.footnoteText) {
|
|
95
|
-
simpleEditor.addDisplayComponent({
|
|
96
|
-
role: 'footnote', content: surveys_utils_simpleGenerators.generateLocStrings(props.footnoteText), style: [
|
|
97
|
-
{ key: 'className', value: 'fs-small fst-italic text-center' }
|
|
98
|
-
]
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
return simpleEditor.getItem();
|
|
72
|
+
const rg_inner = surveys_responseTypeGenerators_optionGroupComponents.initSingleChoiceGroup(constants_keyDefinitions.singleChoiceKey, props.responseOptions);
|
|
73
|
+
return commonQuestionGenerator(props, rg_inner);
|
|
102
74
|
};
|
|
103
75
|
const generateDropDownQuestion = (props) => {
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
simpleEditor.setTitle(props.questionText, props.questionSubText, props.titleClassName);
|
|
107
|
-
if (props.condition) {
|
|
108
|
-
simpleEditor.setCondition(props.condition);
|
|
109
|
-
}
|
|
110
|
-
if (props.helpGroupContent) {
|
|
111
|
-
simpleEditor.editor.setHelpGroupComponent(surveys_utils_simpleGenerators.generateHelpGroupComponent(props.helpGroupContent));
|
|
112
|
-
}
|
|
113
|
-
if (props.topDisplayCompoments) {
|
|
114
|
-
props.topDisplayCompoments.forEach(comp => simpleEditor.addDisplayComponent(comp));
|
|
115
|
-
}
|
|
116
|
-
const rg_inner = initDropdownGroup(constants_keyDefinitions.dropDownKey, props.responseOptions);
|
|
117
|
-
simpleEditor.setResponseGroupWithContent(rg_inner);
|
|
118
|
-
if (props.bottomDisplayCompoments) {
|
|
119
|
-
props.bottomDisplayCompoments.forEach(comp => simpleEditor.addDisplayComponent(comp));
|
|
120
|
-
}
|
|
121
|
-
if (props.isRequired) {
|
|
122
|
-
simpleEditor.addHasResponseValidation();
|
|
123
|
-
}
|
|
124
|
-
if (props.footnoteText) {
|
|
125
|
-
simpleEditor.addDisplayComponent({
|
|
126
|
-
role: 'footnote', content: surveys_utils_simpleGenerators.generateLocStrings(props.footnoteText), style: [
|
|
127
|
-
{ key: 'className', value: 'fs-small fst-italic text-center' }
|
|
128
|
-
]
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
return simpleEditor.getItem();
|
|
76
|
+
const rg_inner = surveys_responseTypeGenerators_optionGroupComponents.initDropdownGroup(constants_keyDefinitions.dropDownKey, props.responseOptions);
|
|
77
|
+
return commonQuestionGenerator(props, rg_inner);
|
|
132
78
|
};
|
|
133
79
|
const generateMultipleChoiceQuestion = (props) => {
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
simpleEditor.setTitle(props.questionText, props.questionSubText, props.titleClassName);
|
|
137
|
-
if (props.condition) {
|
|
138
|
-
simpleEditor.setCondition(props.condition);
|
|
139
|
-
}
|
|
140
|
-
if (props.helpGroupContent) {
|
|
141
|
-
simpleEditor.editor.setHelpGroupComponent(surveys_utils_simpleGenerators.generateHelpGroupComponent(props.helpGroupContent));
|
|
142
|
-
}
|
|
143
|
-
if (props.topDisplayCompoments) {
|
|
144
|
-
props.topDisplayCompoments.forEach(comp => simpleEditor.addDisplayComponent(comp));
|
|
145
|
-
}
|
|
146
|
-
const rg_inner = initMultipleChoiceGroup(constants_keyDefinitions.multipleChoiceKey, props.responseOptions);
|
|
147
|
-
simpleEditor.setResponseGroupWithContent(rg_inner);
|
|
148
|
-
if (props.bottomDisplayCompoments) {
|
|
149
|
-
props.bottomDisplayCompoments.forEach(comp => simpleEditor.addDisplayComponent(comp));
|
|
150
|
-
}
|
|
151
|
-
if (props.isRequired) {
|
|
152
|
-
simpleEditor.addHasResponseValidation();
|
|
153
|
-
}
|
|
154
|
-
if (props.customValidations) {
|
|
155
|
-
props.customValidations.forEach(v => simpleEditor.editor.addValidation(v));
|
|
156
|
-
}
|
|
157
|
-
if (props.footnoteText) {
|
|
158
|
-
simpleEditor.addDisplayComponent({
|
|
159
|
-
role: 'footnote', content: surveys_utils_simpleGenerators.generateLocStrings(props.footnoteText), style: [
|
|
160
|
-
{ key: 'className', value: 'fs-small fst-italic text-center' }
|
|
161
|
-
]
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
return simpleEditor.getItem();
|
|
80
|
+
const rg_inner = surveys_responseTypeGenerators_optionGroupComponents.initMultipleChoiceGroup(constants_keyDefinitions.multipleChoiceKey, props.responseOptions);
|
|
81
|
+
return commonQuestionGenerator(props, rg_inner);
|
|
165
82
|
};
|
|
166
83
|
const generateSimpleLikertGroupQuestion = (props) => {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
if (props.condition) {
|
|
171
|
-
simpleEditor.setCondition(props.condition);
|
|
172
|
-
}
|
|
173
|
-
if (props.helpGroupContent) {
|
|
174
|
-
simpleEditor.editor.setHelpGroupComponent(surveys_utils_simpleGenerators.generateHelpGroupComponent(props.helpGroupContent));
|
|
175
|
-
}
|
|
176
|
-
if (props.topDisplayCompoments) {
|
|
177
|
-
props.topDisplayCompoments.forEach(comp => simpleEditor.addDisplayComponent(comp));
|
|
178
|
-
}
|
|
179
|
-
const rg_inner = initLikertScaleGroup(constants_keyDefinitions.likertScaleGroupKey, props.rows, props.scaleOptions, props.stackOnSmallScreen);
|
|
180
|
-
simpleEditor.setResponseGroupWithContent(rg_inner);
|
|
181
|
-
if (props.bottomDisplayCompoments) {
|
|
182
|
-
props.bottomDisplayCompoments.forEach(comp => simpleEditor.addDisplayComponent(comp));
|
|
183
|
-
}
|
|
84
|
+
var _a;
|
|
85
|
+
const rg_inner = surveys_responseTypeGenerators_likertGroupComponents.initLikertScaleGroup(constants_keyDefinitions.likertScaleGroupKey, props.rows, props.scaleOptions, props.stackOnSmallScreen);
|
|
86
|
+
// Add extra validation for likert
|
|
184
87
|
if (props.isRequired) {
|
|
185
|
-
|
|
88
|
+
if (!props.customValidations) {
|
|
89
|
+
props.customValidations = [];
|
|
90
|
+
}
|
|
91
|
+
(_a = props.customValidations) === null || _a === void 0 ? void 0 : _a.push({
|
|
186
92
|
key: 'r',
|
|
187
93
|
type: 'hard',
|
|
188
94
|
rule: surveys_utils_simpleGenerators.expWithArgs('and', ...props.rows.map(r => surveys_utils_simpleGenerators.expWithArgs('responseHasKeysAny', [props.parentKey, props.itemKey].join('.'), [constants_keyDefinitions.responseGroupKey, constants_keyDefinitions.likertScaleGroupKey, r.key].join('.'), ...props.scaleOptions.map(o => o.key))))
|
|
189
95
|
});
|
|
190
|
-
simpleEditor.addHasResponseValidation();
|
|
191
96
|
}
|
|
192
|
-
|
|
193
|
-
simpleEditor.addDisplayComponent({
|
|
194
|
-
role: 'footnote', content: surveys_utils_simpleGenerators.generateLocStrings(props.footnoteText), style: [
|
|
195
|
-
{ key: 'className', value: 'fs-small fst-italic text-center' }
|
|
196
|
-
]
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
|
-
return simpleEditor.getItem();
|
|
97
|
+
return commonQuestionGenerator(props, rg_inner);
|
|
200
98
|
};
|
|
201
99
|
const generateResponsiveSingleChoiceArrayQuestion = (props) => {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
if (props.condition) {
|
|
206
|
-
simpleEditor.setCondition(props.condition);
|
|
207
|
-
}
|
|
208
|
-
if (props.helpGroupContent) {
|
|
209
|
-
simpleEditor.editor.setHelpGroupComponent(surveys_utils_simpleGenerators.generateHelpGroupComponent(props.helpGroupContent));
|
|
210
|
-
}
|
|
211
|
-
if (props.topDisplayCompoments) {
|
|
212
|
-
props.topDisplayCompoments.forEach(comp => simpleEditor.addDisplayComponent(comp));
|
|
213
|
-
}
|
|
214
|
-
const rg_inner = initResponsiveSingleChoiceArray(constants_keyDefinitions.responsiveSingleChoiceArrayKey, Object.assign({}, props));
|
|
215
|
-
simpleEditor.setResponseGroupWithContent(rg_inner);
|
|
216
|
-
if (props.bottomDisplayCompoments) {
|
|
217
|
-
props.bottomDisplayCompoments.forEach(comp => simpleEditor.addDisplayComponent(comp));
|
|
218
|
-
}
|
|
100
|
+
var _a;
|
|
101
|
+
const rg_inner = surveys_responseTypeGenerators_likertGroupComponents.initResponsiveSingleChoiceArray(constants_keyDefinitions.responsiveSingleChoiceArrayKey, Object.assign({}, props));
|
|
102
|
+
// Add extra validation
|
|
219
103
|
if (props.isRequired) {
|
|
220
|
-
|
|
104
|
+
if (!props.customValidations) {
|
|
105
|
+
props.customValidations = [];
|
|
106
|
+
}
|
|
107
|
+
(_a = props.customValidations) === null || _a === void 0 ? void 0 : _a.push({
|
|
221
108
|
key: 'r',
|
|
222
109
|
type: 'hard',
|
|
223
110
|
rule: surveys_utils_simpleGenerators.expWithArgs('and', ...props.rows.map(r => surveys_utils_simpleGenerators.expWithArgs('responseHasKeysAny', [props.parentKey, props.itemKey].join('.'), [constants_keyDefinitions.responseGroupKey, constants_keyDefinitions.responsiveSingleChoiceArrayKey, r.key].join('.'), ...props.scaleOptions.map(o => o.key))))
|
|
224
111
|
});
|
|
225
|
-
simpleEditor.addHasResponseValidation();
|
|
226
112
|
}
|
|
227
|
-
|
|
228
|
-
simpleEditor.addDisplayComponent({
|
|
229
|
-
role: 'footnote', content: surveys_utils_simpleGenerators.generateLocStrings(props.footnoteText), style: [
|
|
230
|
-
{ key: 'className', value: 'fs-small fst-italic text-center' }
|
|
231
|
-
]
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
return simpleEditor.getItem();
|
|
113
|
+
return commonQuestionGenerator(props, rg_inner);
|
|
235
114
|
};
|
|
236
115
|
const generateResponsiveBipolarLikertArray = (props) => {
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
if (props.condition) {
|
|
241
|
-
simpleEditor.setCondition(props.condition);
|
|
242
|
-
}
|
|
243
|
-
if (props.helpGroupContent) {
|
|
244
|
-
simpleEditor.editor.setHelpGroupComponent(surveys_utils_simpleGenerators.generateHelpGroupComponent(props.helpGroupContent));
|
|
245
|
-
}
|
|
246
|
-
if (props.topDisplayCompoments) {
|
|
247
|
-
props.topDisplayCompoments.forEach(comp => simpleEditor.addDisplayComponent(comp));
|
|
248
|
-
}
|
|
249
|
-
const rg_inner = initResponsiveBipolarLikertArray(constants_keyDefinitions.responsiveBipolarLikertArrayKey, Object.assign({}, props));
|
|
250
|
-
simpleEditor.setResponseGroupWithContent(rg_inner);
|
|
251
|
-
if (props.bottomDisplayCompoments) {
|
|
252
|
-
props.bottomDisplayCompoments.forEach(comp => simpleEditor.addDisplayComponent(comp));
|
|
253
|
-
}
|
|
116
|
+
var _a;
|
|
117
|
+
const rg_inner = surveys_responseTypeGenerators_likertGroupComponents.initResponsiveBipolarLikertArray(constants_keyDefinitions.responsiveBipolarLikertArrayKey, Object.assign({}, props));
|
|
118
|
+
// Add extra validation
|
|
254
119
|
if (props.isRequired) {
|
|
255
|
-
|
|
120
|
+
if (!props.customValidations) {
|
|
121
|
+
props.customValidations = [];
|
|
122
|
+
}
|
|
123
|
+
(_a = props.customValidations) === null || _a === void 0 ? void 0 : _a.push({
|
|
256
124
|
key: 'r',
|
|
257
125
|
type: 'hard',
|
|
258
126
|
rule: surveys_utils_simpleGenerators.expWithArgs('and', ...props.rows.map(r => surveys_utils_simpleGenerators.expWithArgs('responseHasKeysAny', [props.parentKey, props.itemKey].join('.'), [constants_keyDefinitions.responseGroupKey, constants_keyDefinitions.responsiveBipolarLikertArrayKey, r.key].join('.'), ...props.scaleOptions.map(o => o.key))))
|
|
259
127
|
});
|
|
260
|
-
simpleEditor.addHasResponseValidation();
|
|
261
128
|
}
|
|
262
|
-
|
|
263
|
-
simpleEditor.addDisplayComponent({
|
|
264
|
-
role: 'footnote', content: surveys_utils_simpleGenerators.generateLocStrings(props.footnoteText), style: [
|
|
265
|
-
{ key: 'className', value: 'fs-small fst-italic text-center' }
|
|
266
|
-
]
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
|
-
return simpleEditor.getItem();
|
|
129
|
+
return commonQuestionGenerator(props, rg_inner);
|
|
270
130
|
};
|
|
271
131
|
const generateNumericSliderQuestion = (props) => {
|
|
272
|
-
const simpleEditor = new surveys_utils_simpleQuestionEditor.SimpleQuestionEditor(props.parentKey, props.itemKey, props.version ? props.version : 1);
|
|
273
|
-
// QUESTION TEXT
|
|
274
|
-
simpleEditor.setTitle(props.questionText, props.questionSubText, props.titleClassName);
|
|
275
|
-
if (props.condition) {
|
|
276
|
-
simpleEditor.setCondition(props.condition);
|
|
277
|
-
}
|
|
278
|
-
if (props.helpGroupContent) {
|
|
279
|
-
simpleEditor.editor.setHelpGroupComponent(surveys_utils_simpleGenerators.generateHelpGroupComponent(props.helpGroupContent));
|
|
280
|
-
}
|
|
281
|
-
if (props.topDisplayCompoments) {
|
|
282
|
-
props.topDisplayCompoments.forEach(comp => simpleEditor.addDisplayComponent(comp));
|
|
283
|
-
}
|
|
284
132
|
const rg_inner = {
|
|
285
133
|
key: 'slider', role: 'sliderNumeric',
|
|
286
134
|
content: surveys_utils_simpleGenerators.generateLocStrings(props.sliderLabel),
|
|
@@ -291,31 +139,9 @@ const generateNumericSliderQuestion = (props) => {
|
|
|
291
139
|
stepSize: props.stepSize ? (typeof (props.stepSize) === 'number' ? { dtype: 'num', num: props.stepSize } : props.stepSize) : undefined,
|
|
292
140
|
}
|
|
293
141
|
};
|
|
294
|
-
|
|
295
|
-
if (props.bottomDisplayCompoments) {
|
|
296
|
-
props.bottomDisplayCompoments.forEach(comp => simpleEditor.addDisplayComponent(comp));
|
|
297
|
-
}
|
|
298
|
-
if (props.isRequired) {
|
|
299
|
-
simpleEditor.addHasResponseValidation();
|
|
300
|
-
}
|
|
301
|
-
if (props.footnoteText) {
|
|
302
|
-
simpleEditor.addDisplayComponent(surveys_utils_componentGenerators.ComponentGenerators.footnote({ content: props.footnoteText }));
|
|
303
|
-
}
|
|
304
|
-
return simpleEditor.getItem();
|
|
142
|
+
return commonQuestionGenerator(props, rg_inner);
|
|
305
143
|
};
|
|
306
144
|
const generateDatePickerInput = (props) => {
|
|
307
|
-
const simpleEditor = new surveys_utils_simpleQuestionEditor.SimpleQuestionEditor(props.parentKey, props.itemKey, props.version ? props.version : 1);
|
|
308
|
-
// QUESTION TEXT
|
|
309
|
-
simpleEditor.setTitle(props.questionText, props.questionSubText, props.titleClassName);
|
|
310
|
-
if (props.condition) {
|
|
311
|
-
simpleEditor.setCondition(props.condition);
|
|
312
|
-
}
|
|
313
|
-
if (props.helpGroupContent) {
|
|
314
|
-
simpleEditor.editor.setHelpGroupComponent(surveys_utils_simpleGenerators.generateHelpGroupComponent(props.helpGroupContent));
|
|
315
|
-
}
|
|
316
|
-
if (props.topDisplayCompoments) {
|
|
317
|
-
props.topDisplayCompoments.forEach(comp => simpleEditor.addDisplayComponent(comp));
|
|
318
|
-
}
|
|
319
145
|
const rg_inner = {
|
|
320
146
|
key: constants_keyDefinitions.datePickerKey, role: 'dateInput',
|
|
321
147
|
properties: {
|
|
@@ -330,31 +156,9 @@ const generateDatePickerInput = (props) => {
|
|
|
330
156
|
content: props.inputLabelText ? surveys_utils_simpleGenerators.generateLocStrings(props.inputLabelText) : undefined,
|
|
331
157
|
description: props.placeholderText ? surveys_utils_simpleGenerators.generateLocStrings(props.placeholderText) : undefined,
|
|
332
158
|
};
|
|
333
|
-
|
|
334
|
-
if (props.bottomDisplayCompoments) {
|
|
335
|
-
props.bottomDisplayCompoments.forEach(comp => simpleEditor.addDisplayComponent(comp));
|
|
336
|
-
}
|
|
337
|
-
if (props.isRequired) {
|
|
338
|
-
simpleEditor.addHasResponseValidation();
|
|
339
|
-
}
|
|
340
|
-
if (props.footnoteText) {
|
|
341
|
-
simpleEditor.addDisplayComponent(surveys_utils_componentGenerators.ComponentGenerators.footnote({ content: props.footnoteText }));
|
|
342
|
-
}
|
|
343
|
-
return simpleEditor.getItem();
|
|
159
|
+
return commonQuestionGenerator(props, rg_inner);
|
|
344
160
|
};
|
|
345
161
|
const generateTextInputQuestion = (props) => {
|
|
346
|
-
const simpleEditor = new surveys_utils_simpleQuestionEditor.SimpleQuestionEditor(props.parentKey, props.itemKey, props.version ? props.version : 1);
|
|
347
|
-
// QUESTION TEXT
|
|
348
|
-
simpleEditor.setTitle(props.questionText, props.questionSubText, props.titleClassName);
|
|
349
|
-
if (props.condition) {
|
|
350
|
-
simpleEditor.setCondition(props.condition);
|
|
351
|
-
}
|
|
352
|
-
if (props.helpGroupContent) {
|
|
353
|
-
simpleEditor.editor.setHelpGroupComponent(surveys_utils_simpleGenerators.generateHelpGroupComponent(props.helpGroupContent));
|
|
354
|
-
}
|
|
355
|
-
if (props.topDisplayCompoments) {
|
|
356
|
-
props.topDisplayCompoments.forEach(comp => simpleEditor.addDisplayComponent(comp));
|
|
357
|
-
}
|
|
358
162
|
const style = [];
|
|
359
163
|
if (props.maxLength !== undefined) {
|
|
360
164
|
style.push({ key: 'maxLength', value: props.maxLength.toFixed(0) });
|
|
@@ -372,81 +176,33 @@ const generateTextInputQuestion = (props) => {
|
|
|
372
176
|
style: style.length > 0 ? [...style] : undefined,
|
|
373
177
|
disabled: props.disabled,
|
|
374
178
|
};
|
|
375
|
-
|
|
376
|
-
if (props.bottomDisplayCompoments) {
|
|
377
|
-
props.bottomDisplayCompoments.forEach(comp => simpleEditor.addDisplayComponent(comp));
|
|
378
|
-
}
|
|
379
|
-
if (props.isRequired) {
|
|
380
|
-
simpleEditor.addHasResponseValidation();
|
|
381
|
-
}
|
|
382
|
-
if (props.footnoteText) {
|
|
383
|
-
simpleEditor.addDisplayComponent(surveys_utils_componentGenerators.ComponentGenerators.footnote({ content: props.footnoteText }));
|
|
384
|
-
}
|
|
385
|
-
return simpleEditor.getItem();
|
|
179
|
+
return commonQuestionGenerator(props, rg_inner);
|
|
386
180
|
};
|
|
387
181
|
const generateMultilineInput = (props) => {
|
|
388
|
-
const simpleEditor = new surveys_utils_simpleQuestionEditor.SimpleQuestionEditor(props.parentKey, props.itemKey, props.version ? props.version : 1);
|
|
389
|
-
// QUESTION TEXT
|
|
390
|
-
simpleEditor.setTitle(props.questionText, props.questionSubText, props.titleClassName);
|
|
391
|
-
if (props.condition) {
|
|
392
|
-
simpleEditor.setCondition(props.condition);
|
|
393
|
-
}
|
|
394
|
-
if (props.helpGroupContent) {
|
|
395
|
-
simpleEditor.editor.setHelpGroupComponent(surveys_utils_simpleGenerators.generateHelpGroupComponent(props.helpGroupContent));
|
|
396
|
-
}
|
|
397
|
-
if (props.topDisplayCompoments) {
|
|
398
|
-
props.topDisplayCompoments.forEach(comp => simpleEditor.addDisplayComponent(comp));
|
|
399
|
-
}
|
|
400
182
|
const rg_inner = {
|
|
401
183
|
key: constants_keyDefinitions.inputKey, role: 'multilineTextInput',
|
|
402
184
|
content: props.inputLabelText ? surveys_utils_simpleGenerators.generateLocStrings(props.inputLabelText) : undefined,
|
|
403
185
|
description: props.placeholderText ? surveys_utils_simpleGenerators.generateLocStrings(props.placeholderText) : undefined,
|
|
404
186
|
style: props.maxLength !== undefined ? [{ key: 'maxLength', value: props.maxLength.toFixed(0) }] : undefined
|
|
405
187
|
};
|
|
406
|
-
|
|
407
|
-
if (props.bottomDisplayCompoments) {
|
|
408
|
-
props.bottomDisplayCompoments.forEach(comp => simpleEditor.addDisplayComponent(comp));
|
|
409
|
-
}
|
|
410
|
-
if (props.isRequired) {
|
|
411
|
-
simpleEditor.addHasResponseValidation();
|
|
412
|
-
}
|
|
413
|
-
if (props.footnoteText) {
|
|
414
|
-
simpleEditor.addDisplayComponent(surveys_utils_componentGenerators.ComponentGenerators.footnote({ content: props.footnoteText }));
|
|
415
|
-
}
|
|
416
|
-
return simpleEditor.getItem();
|
|
188
|
+
return commonQuestionGenerator(props, rg_inner);
|
|
417
189
|
};
|
|
418
190
|
const generateClozeQuestion = (props) => {
|
|
419
|
-
const simpleEditor = new surveys_utils_simpleQuestionEditor.SimpleQuestionEditor(props.parentKey, props.itemKey, props.version ? props.version : 1);
|
|
420
|
-
// QUESTION TEXT
|
|
421
|
-
simpleEditor.setTitle(props.questionText, props.questionSubText, props.titleClassName);
|
|
422
|
-
if (props.condition) {
|
|
423
|
-
simpleEditor.setCondition(props.condition);
|
|
424
|
-
}
|
|
425
|
-
if (props.helpGroupContent) {
|
|
426
|
-
simpleEditor.editor.setHelpGroupComponent(surveys_utils_simpleGenerators.generateHelpGroupComponent(props.helpGroupContent));
|
|
427
|
-
}
|
|
428
|
-
if (props.topDisplayCompoments) {
|
|
429
|
-
props.topDisplayCompoments.forEach(comp => simpleEditor.addDisplayComponent(comp));
|
|
430
|
-
}
|
|
431
191
|
const rg_inner = {
|
|
432
192
|
key: constants_keyDefinitions.clozeKey, role: 'cloze',
|
|
433
193
|
items: props.items.map((item) => {
|
|
434
194
|
const clozeItem = item;
|
|
435
|
-
const comp = optionDefToItemComponent(clozeItem);
|
|
195
|
+
const comp = surveys_responseTypeGenerators_optionGroupComponents.optionDefToItemComponent(clozeItem);
|
|
436
196
|
return comp;
|
|
437
197
|
})
|
|
438
198
|
};
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
if (props.footnoteText) {
|
|
447
|
-
simpleEditor.addDisplayComponent(surveys_utils_componentGenerators.ComponentGenerators.footnote({ content: props.footnoteText }));
|
|
448
|
-
}
|
|
449
|
-
return simpleEditor.getItem();
|
|
199
|
+
return commonQuestionGenerator(props, rg_inner);
|
|
200
|
+
};
|
|
201
|
+
const generateCustomQuestion = (props) => {
|
|
202
|
+
const roleSuffix = props.responseItemDef.mapToRole !== undefined ? `:${props.responseItemDef.mapToRole}` : '';
|
|
203
|
+
const role = `${props.responseItemDef}${roleSuffix}`;
|
|
204
|
+
const rg_inner = Object.assign(Object.assign({}, props.responseItemDef), { role: role });
|
|
205
|
+
return commonQuestionGenerator(props, rg_inner);
|
|
450
206
|
};
|
|
451
207
|
const generateDisplay = (props) => {
|
|
452
208
|
const simpleEditor = new surveys_utils_simpleQuestionEditor.SimpleQuestionEditor(props.parentKey, props.itemKey, 1);
|
|
@@ -465,204 +221,6 @@ const generateSurveyEnd = (parentKey, content, condition) => {
|
|
|
465
221
|
editor.setCondition(condition);
|
|
466
222
|
return editor.getItem();
|
|
467
223
|
};
|
|
468
|
-
const initSingleChoiceGroup = (key, optionItems, order) => {
|
|
469
|
-
// init group
|
|
470
|
-
return initResponseGroup('singleChoiceGroup', key, optionItems, order);
|
|
471
|
-
};
|
|
472
|
-
const initMultipleChoiceGroup = (key, optionItems, order) => {
|
|
473
|
-
// init group
|
|
474
|
-
return initResponseGroup('multipleChoiceGroup', key, optionItems, order);
|
|
475
|
-
};
|
|
476
|
-
const initDropdownGroup = (key, optionItems, order, groupDisabled, groupContent, groupDescription) => {
|
|
477
|
-
// init group
|
|
478
|
-
return initResponseGroup('dropDownGroup', key, optionItems, order, groupDisabled, groupContent ? surveys_utils_simpleGenerators.generateLocStrings(groupContent) : undefined, groupDescription ? surveys_utils_simpleGenerators.generateLocStrings(groupDescription) : undefined);
|
|
479
|
-
};
|
|
480
|
-
const initSliderCategoricalGroup = (key, optionItems, order, groupDisabled) => {
|
|
481
|
-
// init group
|
|
482
|
-
return initResponseGroup('sliderCategorical', key, optionItems, order, groupDisabled);
|
|
483
|
-
};
|
|
484
|
-
const optionDefToItemComponent = (optionDef) => {
|
|
485
|
-
const isGroup = optionDef.items && optionDef.items.length > 0;
|
|
486
|
-
const optEditor = new surveys_surveyEditor_componentEditor.ComponentEditor(undefined, {
|
|
487
|
-
key: optionDef.key,
|
|
488
|
-
role: optionDef.role,
|
|
489
|
-
isGroup: isGroup
|
|
490
|
-
});
|
|
491
|
-
if (isGroup) {
|
|
492
|
-
optEditor.setOrder({
|
|
493
|
-
name: 'sequential'
|
|
494
|
-
});
|
|
495
|
-
}
|
|
496
|
-
if (optionDef.content) {
|
|
497
|
-
optEditor.setContent(surveys_utils_simpleGenerators.generateLocStrings(optionDef.content));
|
|
498
|
-
}
|
|
499
|
-
if (optionDef.description) {
|
|
500
|
-
optEditor.setDescription(surveys_utils_simpleGenerators.generateLocStrings(optionDef.description));
|
|
501
|
-
}
|
|
502
|
-
switch (optionDef.role) {
|
|
503
|
-
case 'date':
|
|
504
|
-
optEditor.setDType('date');
|
|
505
|
-
break;
|
|
506
|
-
case 'numberInput':
|
|
507
|
-
optEditor.setDType('number');
|
|
508
|
-
break;
|
|
509
|
-
}
|
|
510
|
-
if (optionDef.displayCondition) {
|
|
511
|
-
optEditor.setDisplayCondition(optionDef.displayCondition);
|
|
512
|
-
}
|
|
513
|
-
if (optionDef.disabled) {
|
|
514
|
-
optEditor.setDisabled(optionDef.disabled);
|
|
515
|
-
}
|
|
516
|
-
if (optionDef.style) {
|
|
517
|
-
optEditor.setStyles(optionDef.style);
|
|
518
|
-
}
|
|
519
|
-
if (optionDef.optionProps) {
|
|
520
|
-
if (typeof (optionDef.optionProps.min) === 'number') {
|
|
521
|
-
optionDef.optionProps.min = { dtype: 'num', num: optionDef.optionProps.min };
|
|
522
|
-
}
|
|
523
|
-
if (typeof (optionDef.optionProps.max) === 'number') {
|
|
524
|
-
optionDef.optionProps.max = { dtype: 'num', num: optionDef.optionProps.max };
|
|
525
|
-
}
|
|
526
|
-
if (typeof (optionDef.optionProps.stepSize) === 'number') {
|
|
527
|
-
optionDef.optionProps.stepSize = { dtype: 'num', num: optionDef.optionProps.stepSize };
|
|
528
|
-
}
|
|
529
|
-
optEditor.setProperties(optionDef.optionProps);
|
|
530
|
-
}
|
|
531
|
-
if (optionDef.items) {
|
|
532
|
-
if (optionDef.role === 'text') {
|
|
533
|
-
optionDef.items.forEach((item, index) => {
|
|
534
|
-
const textItem = item;
|
|
535
|
-
optEditor.addItemComponent({
|
|
536
|
-
key: index.toFixed(),
|
|
537
|
-
role: 'text',
|
|
538
|
-
content: surveys_utils_simpleGenerators.generateLocStrings(textItem.content),
|
|
539
|
-
style: textItem.className ? [{ key: 'className', value: textItem.className }] : undefined
|
|
540
|
-
});
|
|
541
|
-
});
|
|
542
|
-
}
|
|
543
|
-
else {
|
|
544
|
-
optionDef.items.forEach((item) => {
|
|
545
|
-
const clozeItem = item;
|
|
546
|
-
const comp = optionDefToItemComponent(clozeItem);
|
|
547
|
-
optEditor.addItemComponent(comp);
|
|
548
|
-
});
|
|
549
|
-
}
|
|
550
|
-
}
|
|
551
|
-
return optEditor.getComponent();
|
|
552
|
-
};
|
|
553
|
-
const initResponseGroup = (type, key, optionItems, order, groupDisabled, groupContent, groupDescription) => {
|
|
554
|
-
// init group
|
|
555
|
-
const groupEdit = new surveys_surveyEditor_componentEditor.ComponentEditor(undefined, {
|
|
556
|
-
key: key,
|
|
557
|
-
isGroup: true,
|
|
558
|
-
role: type,
|
|
559
|
-
});
|
|
560
|
-
groupEdit.setOrder(order ? order : {
|
|
561
|
-
name: 'sequential'
|
|
562
|
-
});
|
|
563
|
-
if (groupDisabled) {
|
|
564
|
-
groupEdit.setDisabled(groupDisabled);
|
|
565
|
-
}
|
|
566
|
-
if (groupContent) {
|
|
567
|
-
groupEdit.setContent(groupContent);
|
|
568
|
-
}
|
|
569
|
-
if (groupDescription) {
|
|
570
|
-
groupEdit.setDescription(groupDescription);
|
|
571
|
-
}
|
|
572
|
-
// add option items
|
|
573
|
-
optionItems.forEach(optionDef => {
|
|
574
|
-
groupEdit.addItemComponent(optionDefToItemComponent(optionDef));
|
|
575
|
-
});
|
|
576
|
-
return groupEdit.getComponent();
|
|
577
|
-
};
|
|
578
|
-
const initMatrixQuestion = (key, rows, order) => {
|
|
579
|
-
// init group
|
|
580
|
-
const groupEdit = new surveys_surveyEditor_componentEditor.ComponentEditor(undefined, {
|
|
581
|
-
key: key,
|
|
582
|
-
isGroup: true,
|
|
583
|
-
role: 'matrix',
|
|
584
|
-
});
|
|
585
|
-
groupEdit.setOrder(order ? order : {
|
|
586
|
-
name: 'sequential'
|
|
587
|
-
});
|
|
588
|
-
// init rows
|
|
589
|
-
rows.forEach(rowDef => {
|
|
590
|
-
const rowEditor = new surveys_surveyEditor_componentEditor.ComponentEditor(undefined, {
|
|
591
|
-
key: rowDef.key,
|
|
592
|
-
role: rowDef.role,
|
|
593
|
-
});
|
|
594
|
-
if (rowDef.displayCondition) {
|
|
595
|
-
rowEditor.setDisplayCondition(rowDef.displayCondition);
|
|
596
|
-
}
|
|
597
|
-
if (rowDef.disabled) {
|
|
598
|
-
rowEditor.setDisabled(rowDef.disabled);
|
|
599
|
-
}
|
|
600
|
-
switch (rowDef.role) {
|
|
601
|
-
case 'headerRow':
|
|
602
|
-
rowDef.cells.forEach(cell => {
|
|
603
|
-
const cellEditor = new surveys_surveyEditor_componentEditor.ComponentEditor(undefined, {
|
|
604
|
-
key: cell.key,
|
|
605
|
-
role: cell.role,
|
|
606
|
-
});
|
|
607
|
-
if (cell.content) {
|
|
608
|
-
cellEditor.setContent(surveys_utils_simpleGenerators.generateLocStrings(cell.content));
|
|
609
|
-
}
|
|
610
|
-
if (cell.description) {
|
|
611
|
-
cellEditor.setDescription(surveys_utils_simpleGenerators.generateLocStrings(cell.description));
|
|
612
|
-
}
|
|
613
|
-
rowEditor.addItemComponent(cellEditor.getComponent());
|
|
614
|
-
});
|
|
615
|
-
break;
|
|
616
|
-
case 'radioRow':
|
|
617
|
-
rowDef.cells.forEach(cell => {
|
|
618
|
-
const cellEditor = new surveys_surveyEditor_componentEditor.ComponentEditor(undefined, {
|
|
619
|
-
key: cell.key,
|
|
620
|
-
role: cell.role,
|
|
621
|
-
});
|
|
622
|
-
if (cell.content) {
|
|
623
|
-
cellEditor.setContent(surveys_utils_simpleGenerators.generateLocStrings(cell.content));
|
|
624
|
-
}
|
|
625
|
-
if (cell.description) {
|
|
626
|
-
cellEditor.setDescription(surveys_utils_simpleGenerators.generateLocStrings(cell.description));
|
|
627
|
-
}
|
|
628
|
-
rowEditor.addItemComponent(cellEditor.getComponent());
|
|
629
|
-
});
|
|
630
|
-
break;
|
|
631
|
-
case 'responseRow':
|
|
632
|
-
rowDef.cells.forEach(cell => {
|
|
633
|
-
const cellEditor = new surveys_surveyEditor_componentEditor.ComponentEditor(undefined, {
|
|
634
|
-
key: cell.key,
|
|
635
|
-
role: cell.role,
|
|
636
|
-
});
|
|
637
|
-
if (cell.content) {
|
|
638
|
-
cellEditor.setContent(surveys_utils_simpleGenerators.generateLocStrings(cell.content));
|
|
639
|
-
}
|
|
640
|
-
if (cell.description) {
|
|
641
|
-
cellEditor.setDescription(surveys_utils_simpleGenerators.generateLocStrings(cell.description));
|
|
642
|
-
}
|
|
643
|
-
cellEditor.setProperties(cell.properties);
|
|
644
|
-
if (cell.items) {
|
|
645
|
-
cell.items.forEach(opt => {
|
|
646
|
-
const cellOptionEditor = new surveys_surveyEditor_componentEditor.ComponentEditor(undefined, {
|
|
647
|
-
key: opt.key,
|
|
648
|
-
role: opt.role,
|
|
649
|
-
});
|
|
650
|
-
if (opt.content) {
|
|
651
|
-
cellOptionEditor.setContent(surveys_utils_simpleGenerators.generateLocStrings(opt.content));
|
|
652
|
-
}
|
|
653
|
-
cellOptionEditor.setDisabled(opt.disabled);
|
|
654
|
-
cellOptionEditor.setDisplayCondition(opt.displayCondition);
|
|
655
|
-
cellEditor.addItemComponent(cellOptionEditor.getComponent());
|
|
656
|
-
});
|
|
657
|
-
}
|
|
658
|
-
rowEditor.addItemComponent(cellEditor.getComponent());
|
|
659
|
-
});
|
|
660
|
-
break;
|
|
661
|
-
}
|
|
662
|
-
groupEdit.addItemComponent(rowEditor.getComponent());
|
|
663
|
-
});
|
|
664
|
-
return groupEdit.getComponent();
|
|
665
|
-
};
|
|
666
224
|
const initEQ5DHealthIndicatorQuestion = (props) => {
|
|
667
225
|
// init group
|
|
668
226
|
const groupEdit = new surveys_surveyEditor_componentEditor.ComponentEditor(undefined, {
|
|
@@ -684,339 +242,6 @@ const initEQ5DHealthIndicatorQuestion = (props) => {
|
|
|
684
242
|
groupEdit.addItemComponent(maxHealthTextEditor.getComponent());
|
|
685
243
|
return groupEdit.getComponent();
|
|
686
244
|
};
|
|
687
|
-
const initLikertScaleGroup = (key, rows, scaleOptions, stackOnSmallScreen, displayCondition) => {
|
|
688
|
-
const groupEdit = new surveys_surveyEditor_componentEditor.ComponentEditor(undefined, {
|
|
689
|
-
key: key,
|
|
690
|
-
isGroup: true,
|
|
691
|
-
role: 'likertGroup',
|
|
692
|
-
});
|
|
693
|
-
if (displayCondition) {
|
|
694
|
-
groupEdit.setDisplayCondition(displayCondition);
|
|
695
|
-
}
|
|
696
|
-
rows.forEach((row, index) => {
|
|
697
|
-
groupEdit.addItemComponent({
|
|
698
|
-
key: surveys_utils_randomKeyGenerator.generateRandomKey(4),
|
|
699
|
-
role: 'text',
|
|
700
|
-
style: [{
|
|
701
|
-
key: 'className', value: 'fw-bold' + (index !== 0 ? ' pt-1 mt-2' : '') + ((!row.hideTopBorder && index > 0) ? ' border-top border-1 border-grey-2' : '') + (row.descriptions ? ' mb-0' : ' mb-1')
|
|
702
|
-
}, { key: 'variant', value: 'h6' }],
|
|
703
|
-
content: surveys_utils_simpleGenerators.generateLocStrings(row.content),
|
|
704
|
-
});
|
|
705
|
-
if (row.descriptions) {
|
|
706
|
-
row.descriptions.forEach(desc => {
|
|
707
|
-
groupEdit.addItemComponent(desc);
|
|
708
|
-
});
|
|
709
|
-
}
|
|
710
|
-
const item = initLikertScaleItem(row.key, scaleOptions.map(option => {
|
|
711
|
-
var _a, _b;
|
|
712
|
-
return {
|
|
713
|
-
key: option.key,
|
|
714
|
-
className: option.className,
|
|
715
|
-
content: row.hideLabels ? undefined : option.content,
|
|
716
|
-
disabled: (_b = (_a = row.optionDisabled) === null || _a === void 0 ? void 0 : _a.find(cond => cond.optionKey === option.key)) === null || _b === void 0 ? void 0 : _b.exp,
|
|
717
|
-
};
|
|
718
|
-
}), stackOnSmallScreen, row.displayCondition);
|
|
719
|
-
groupEdit.addItemComponent(item);
|
|
720
|
-
});
|
|
721
|
-
return groupEdit.getComponent();
|
|
722
|
-
};
|
|
723
|
-
const initResponsiveSingleChoiceArray = (rgKey, props, displayCondition) => {
|
|
724
|
-
var _a, _b;
|
|
725
|
-
const groupEdit = new surveys_surveyEditor_componentEditor.ComponentEditor(undefined, {
|
|
726
|
-
key: rgKey,
|
|
727
|
-
isGroup: true,
|
|
728
|
-
role: 'responsiveSingleChoiceArray',
|
|
729
|
-
});
|
|
730
|
-
if (displayCondition) {
|
|
731
|
-
groupEdit.setDisplayCondition(displayCondition);
|
|
732
|
-
}
|
|
733
|
-
const style = [
|
|
734
|
-
{ key: 'defaultMode', value: props.defaultMode },
|
|
735
|
-
];
|
|
736
|
-
if (props.responsiveModes) {
|
|
737
|
-
if (props.responsiveModes.sm) {
|
|
738
|
-
style.push({ key: 'smMode', value: props.responsiveModes.sm });
|
|
739
|
-
}
|
|
740
|
-
if (props.responsiveModes.md) {
|
|
741
|
-
style.push({ key: 'mdMode', value: props.responsiveModes.md });
|
|
742
|
-
}
|
|
743
|
-
if (props.responsiveModes.lg) {
|
|
744
|
-
style.push({ key: 'lgMode', value: props.responsiveModes.lg });
|
|
745
|
-
}
|
|
746
|
-
if (props.responsiveModes.xl) {
|
|
747
|
-
style.push({ key: 'xlMode', value: props.responsiveModes.xl });
|
|
748
|
-
}
|
|
749
|
-
if (props.responsiveModes.xxl) {
|
|
750
|
-
style.push({ key: 'xxlMode', value: props.responsiveModes.xxl });
|
|
751
|
-
}
|
|
752
|
-
}
|
|
753
|
-
if (props.rgClassName) {
|
|
754
|
-
style.push({ key: 'className', value: props.rgClassName });
|
|
755
|
-
}
|
|
756
|
-
if (props.verticalModeProps) {
|
|
757
|
-
if (props.verticalModeProps.useReverseOptionOrder) {
|
|
758
|
-
style.push({ key: 'verticalModeReverseOrder', value: 'true' });
|
|
759
|
-
}
|
|
760
|
-
}
|
|
761
|
-
if (props.tableModeProps) {
|
|
762
|
-
style.push({ key: 'tableModeClassName', value: 'table-borderless mb-0 ' + props.tableModeProps.className });
|
|
763
|
-
if (props.tableModeProps.layout) {
|
|
764
|
-
style.push({ key: 'tableModeLayout', value: props.tableModeProps.layout });
|
|
765
|
-
}
|
|
766
|
-
if (props.tableModeProps.firstColWidth) {
|
|
767
|
-
style.push({ key: 'tableModeFirstColWidth', value: props.tableModeProps.firstColWidth });
|
|
768
|
-
}
|
|
769
|
-
}
|
|
770
|
-
groupEdit.setStyles(style);
|
|
771
|
-
const defaultBorderClass = 'border-bottom border-grey-2';
|
|
772
|
-
let tableModeOptionHeaderClassName = undefined;
|
|
773
|
-
if (!((_a = props.tableModeProps) === null || _a === void 0 ? void 0 : _a.hideRowBorder)) {
|
|
774
|
-
tableModeOptionHeaderClassName = defaultBorderClass;
|
|
775
|
-
}
|
|
776
|
-
if ((_b = props.tableModeProps) === null || _b === void 0 ? void 0 : _b.optionHeaderClassName) {
|
|
777
|
-
tableModeOptionHeaderClassName += ' ' + props.tableModeProps.optionHeaderClassName;
|
|
778
|
-
}
|
|
779
|
-
const optionStyles = [];
|
|
780
|
-
if (tableModeOptionHeaderClassName) {
|
|
781
|
-
optionStyles.push({ key: 'tableModeClassName', value: tableModeOptionHeaderClassName });
|
|
782
|
-
}
|
|
783
|
-
groupEdit.addItemComponent({
|
|
784
|
-
key: 'header',
|
|
785
|
-
role: 'options',
|
|
786
|
-
style: optionStyles.length > 0 ? optionStyles : undefined,
|
|
787
|
-
items: props.scaleOptions.map(option => {
|
|
788
|
-
return {
|
|
789
|
-
key: option.key,
|
|
790
|
-
role: 'option',
|
|
791
|
-
style: option.className ? [{ key: 'className', value: option.className }] : undefined,
|
|
792
|
-
content: !Array.isArray(option.content) ? surveys_utils_simpleGenerators.generateLocStrings(option.content) : undefined,
|
|
793
|
-
items: Array.isArray(option.content) ? option.content.map((cont, index) => {
|
|
794
|
-
return {
|
|
795
|
-
key: index.toFixed(),
|
|
796
|
-
role: 'text',
|
|
797
|
-
content: surveys_utils_simpleGenerators.generateLocStrings(cont.content),
|
|
798
|
-
style: cont.className ? [{ key: 'className', value: cont.className }] : undefined,
|
|
799
|
-
};
|
|
800
|
-
}) : [],
|
|
801
|
-
};
|
|
802
|
-
})
|
|
803
|
-
});
|
|
804
|
-
props.rows.forEach((row, index) => {
|
|
805
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
806
|
-
let tableModeRowClassName = undefined;
|
|
807
|
-
let horizontalModeRowClassName = undefined;
|
|
808
|
-
let verticalModeRowClassName = undefined;
|
|
809
|
-
const isLast = index === props.rows.length - 1;
|
|
810
|
-
if (!((_a = props.tableModeProps) === null || _a === void 0 ? void 0 : _a.hideRowBorder) && !isLast) {
|
|
811
|
-
tableModeRowClassName = defaultBorderClass;
|
|
812
|
-
}
|
|
813
|
-
if ((_b = row.tableModeProps) === null || _b === void 0 ? void 0 : _b.className) {
|
|
814
|
-
tableModeRowClassName += ' ' + ((_c = row.tableModeProps) === null || _c === void 0 ? void 0 : _c.className);
|
|
815
|
-
}
|
|
816
|
-
if (!((_d = props.horizontalModeProps) === null || _d === void 0 ? void 0 : _d.hideRowBorder) && !isLast) {
|
|
817
|
-
horizontalModeRowClassName = defaultBorderClass;
|
|
818
|
-
}
|
|
819
|
-
if ((_e = row.horizontalModeProps) === null || _e === void 0 ? void 0 : _e.className) {
|
|
820
|
-
horizontalModeRowClassName += ' ' + ((_f = row.horizontalModeProps) === null || _f === void 0 ? void 0 : _f.className);
|
|
821
|
-
}
|
|
822
|
-
if (!((_g = props.verticalModeProps) === null || _g === void 0 ? void 0 : _g.hideRowBorder) && !isLast) {
|
|
823
|
-
verticalModeRowClassName = defaultBorderClass;
|
|
824
|
-
}
|
|
825
|
-
if ((_h = row.verticalModeProps) === null || _h === void 0 ? void 0 : _h.className) {
|
|
826
|
-
verticalModeRowClassName += ' ' + ((_j = row.verticalModeProps) === null || _j === void 0 ? void 0 : _j.className);
|
|
827
|
-
}
|
|
828
|
-
const rowStyles = [];
|
|
829
|
-
if (tableModeRowClassName) {
|
|
830
|
-
rowStyles.push({ key: 'tableModeClassName', value: tableModeRowClassName });
|
|
831
|
-
}
|
|
832
|
-
if (horizontalModeRowClassName) {
|
|
833
|
-
rowStyles.push({ key: 'horizontalModeClassName', value: horizontalModeRowClassName });
|
|
834
|
-
}
|
|
835
|
-
if (verticalModeRowClassName) {
|
|
836
|
-
rowStyles.push({ key: 'verticalModeClassName', value: verticalModeRowClassName });
|
|
837
|
-
}
|
|
838
|
-
if ((_k = row.horizontalModeProps) === null || _k === void 0 ? void 0 : _k.labelPlacement) {
|
|
839
|
-
rowStyles.push({ key: 'horizontalModeLabelPlacement', value: row.horizontalModeProps.labelPlacement });
|
|
840
|
-
}
|
|
841
|
-
groupEdit.addItemComponent({
|
|
842
|
-
key: row.key,
|
|
843
|
-
role: 'row',
|
|
844
|
-
style: rowStyles.length > 0 ? rowStyles : undefined,
|
|
845
|
-
content: !Array.isArray(row.content) ? surveys_utils_simpleGenerators.generateLocStrings(row.content) : undefined,
|
|
846
|
-
items: Array.isArray(row.content) ? row.content.map((cont, index) => {
|
|
847
|
-
return {
|
|
848
|
-
key: index.toFixed(),
|
|
849
|
-
role: 'text',
|
|
850
|
-
content: surveys_utils_simpleGenerators.generateLocStrings(cont.content),
|
|
851
|
-
style: cont.className ? [{ key: 'className', value: cont.className }] : undefined,
|
|
852
|
-
};
|
|
853
|
-
}) : [],
|
|
854
|
-
});
|
|
855
|
-
});
|
|
856
|
-
return groupEdit.getComponent();
|
|
857
|
-
};
|
|
858
|
-
const initResponsiveBipolarLikertArray = (rgKey, props, displayCondition) => {
|
|
859
|
-
var _a;
|
|
860
|
-
const groupEdit = new surveys_surveyEditor_componentEditor.ComponentEditor(undefined, {
|
|
861
|
-
key: rgKey,
|
|
862
|
-
isGroup: true,
|
|
863
|
-
role: 'responsiveBipolarLikertScaleArray',
|
|
864
|
-
});
|
|
865
|
-
if (displayCondition) {
|
|
866
|
-
groupEdit.setDisplayCondition(displayCondition);
|
|
867
|
-
}
|
|
868
|
-
const style = [
|
|
869
|
-
{ key: 'defaultMode', value: props.defaultMode },
|
|
870
|
-
];
|
|
871
|
-
if (props.responsiveModes) {
|
|
872
|
-
if (props.responsiveModes.sm) {
|
|
873
|
-
style.push({ key: 'smMode', value: props.responsiveModes.sm });
|
|
874
|
-
}
|
|
875
|
-
if (props.responsiveModes.md) {
|
|
876
|
-
style.push({ key: 'mdMode', value: props.responsiveModes.md });
|
|
877
|
-
}
|
|
878
|
-
if (props.responsiveModes.lg) {
|
|
879
|
-
style.push({ key: 'lgMode', value: props.responsiveModes.lg });
|
|
880
|
-
}
|
|
881
|
-
if (props.responsiveModes.xl) {
|
|
882
|
-
style.push({ key: 'xlMode', value: props.responsiveModes.xl });
|
|
883
|
-
}
|
|
884
|
-
if (props.responsiveModes.xxl) {
|
|
885
|
-
style.push({ key: 'xxlMode', value: props.responsiveModes.xxl });
|
|
886
|
-
}
|
|
887
|
-
}
|
|
888
|
-
if (props.rgClassName) {
|
|
889
|
-
style.push({ key: 'className', value: props.rgClassName });
|
|
890
|
-
}
|
|
891
|
-
if (props.withLabelRowModeProps) {
|
|
892
|
-
if (props.withLabelRowModeProps.maxLabelWidth) {
|
|
893
|
-
style.push({ key: 'labelRowMaxLabelWidth', value: props.withLabelRowModeProps.maxLabelWidth });
|
|
894
|
-
}
|
|
895
|
-
}
|
|
896
|
-
style.push({ key: 'labelRowPosition', value: ((_a = props.withLabelRowModeProps) === null || _a === void 0 ? void 0 : _a.useBottomLabel) ? 'bottom' : 'top' });
|
|
897
|
-
if (props.tableModeProps) {
|
|
898
|
-
style.push({ key: 'tableModeClassName', value: 'table-borderless mb-0 ' + props.tableModeProps.className });
|
|
899
|
-
if (props.tableModeProps.layout) {
|
|
900
|
-
style.push({ key: 'tableModeLayout', value: props.tableModeProps.layout });
|
|
901
|
-
}
|
|
902
|
-
if (props.tableModeProps.labelColWidth) {
|
|
903
|
-
style.push({ key: 'tableModeLabelColWidth', value: props.tableModeProps.labelColWidth });
|
|
904
|
-
}
|
|
905
|
-
}
|
|
906
|
-
groupEdit.setStyles(style);
|
|
907
|
-
const defaultBorderClass = 'border-bottom border-grey-2';
|
|
908
|
-
groupEdit.addItemComponent({
|
|
909
|
-
key: 'options',
|
|
910
|
-
role: 'options',
|
|
911
|
-
items: props.scaleOptions.map(option => {
|
|
912
|
-
return {
|
|
913
|
-
key: option.key,
|
|
914
|
-
role: 'option',
|
|
915
|
-
};
|
|
916
|
-
})
|
|
917
|
-
});
|
|
918
|
-
props.rows.forEach((row, index) => {
|
|
919
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
920
|
-
let tableModeRowClassName = undefined;
|
|
921
|
-
let withLabelRowModeClassName = undefined;
|
|
922
|
-
let verticalModeRowClassName = undefined;
|
|
923
|
-
const isLast = index === props.rows.length - 1;
|
|
924
|
-
if (!((_a = props.tableModeProps) === null || _a === void 0 ? void 0 : _a.hideRowBorder) && !isLast) {
|
|
925
|
-
tableModeRowClassName = defaultBorderClass;
|
|
926
|
-
}
|
|
927
|
-
if ((_b = row.tableModeProps) === null || _b === void 0 ? void 0 : _b.className) {
|
|
928
|
-
tableModeRowClassName += ' ' + ((_c = row.tableModeProps) === null || _c === void 0 ? void 0 : _c.className);
|
|
929
|
-
}
|
|
930
|
-
if (!((_d = props.withLabelRowModeProps) === null || _d === void 0 ? void 0 : _d.hideRowBorder) && !isLast) {
|
|
931
|
-
withLabelRowModeClassName = defaultBorderClass;
|
|
932
|
-
}
|
|
933
|
-
if ((_e = row.withLabelRowModeProps) === null || _e === void 0 ? void 0 : _e.className) {
|
|
934
|
-
withLabelRowModeClassName += ' ' + ((_f = row.withLabelRowModeProps) === null || _f === void 0 ? void 0 : _f.className);
|
|
935
|
-
}
|
|
936
|
-
if (!((_g = props.verticalModeProps) === null || _g === void 0 ? void 0 : _g.hideRowBorder) && !isLast) {
|
|
937
|
-
verticalModeRowClassName = defaultBorderClass;
|
|
938
|
-
}
|
|
939
|
-
if ((_h = row.verticalModeProps) === null || _h === void 0 ? void 0 : _h.className) {
|
|
940
|
-
verticalModeRowClassName += ' ' + ((_j = row.verticalModeProps) === null || _j === void 0 ? void 0 : _j.className);
|
|
941
|
-
}
|
|
942
|
-
const rowStyles = [];
|
|
943
|
-
if (tableModeRowClassName) {
|
|
944
|
-
rowStyles.push({ key: 'tableModeClassName', value: tableModeRowClassName });
|
|
945
|
-
}
|
|
946
|
-
if (withLabelRowModeClassName) {
|
|
947
|
-
rowStyles.push({ key: 'withLabelRowModeClassName', value: withLabelRowModeClassName });
|
|
948
|
-
}
|
|
949
|
-
if (verticalModeRowClassName) {
|
|
950
|
-
rowStyles.push({ key: 'verticalModeClassName', value: verticalModeRowClassName });
|
|
951
|
-
}
|
|
952
|
-
const startLabel = {
|
|
953
|
-
key: 'start',
|
|
954
|
-
role: 'start',
|
|
955
|
-
content: !Array.isArray(row.startLabel) ? surveys_utils_simpleGenerators.generateLocStrings(row.startLabel) : undefined,
|
|
956
|
-
items: Array.isArray(row.startLabel) ? row.startLabel.map((cont, index) => {
|
|
957
|
-
return {
|
|
958
|
-
key: index.toFixed(),
|
|
959
|
-
role: 'text',
|
|
960
|
-
content: surveys_utils_simpleGenerators.generateLocStrings(cont.content),
|
|
961
|
-
style: cont.className ? [{ key: 'className', value: cont.className }] : undefined,
|
|
962
|
-
};
|
|
963
|
-
}) : [],
|
|
964
|
-
};
|
|
965
|
-
const endLabel = {
|
|
966
|
-
key: 'end',
|
|
967
|
-
role: 'end',
|
|
968
|
-
content: !Array.isArray(row.endLabel) ? surveys_utils_simpleGenerators.generateLocStrings(row.endLabel) : undefined,
|
|
969
|
-
items: Array.isArray(row.endLabel) ? row.endLabel.map((cont, index) => {
|
|
970
|
-
return {
|
|
971
|
-
key: index.toFixed(),
|
|
972
|
-
role: 'text',
|
|
973
|
-
content: surveys_utils_simpleGenerators.generateLocStrings(cont.content),
|
|
974
|
-
style: cont.className ? [{ key: 'className', value: cont.className }] : undefined,
|
|
975
|
-
};
|
|
976
|
-
}) : [],
|
|
977
|
-
};
|
|
978
|
-
groupEdit.addItemComponent({
|
|
979
|
-
key: row.key,
|
|
980
|
-
role: 'row',
|
|
981
|
-
style: rowStyles.length > 0 ? rowStyles : undefined,
|
|
982
|
-
items: [
|
|
983
|
-
startLabel, endLabel
|
|
984
|
-
],
|
|
985
|
-
});
|
|
986
|
-
});
|
|
987
|
-
return groupEdit.getComponent();
|
|
988
|
-
};
|
|
989
|
-
const initLikertScaleItem = (key, options, stackOnSmallScreen, displayCondition) => {
|
|
990
|
-
// init group
|
|
991
|
-
const groupEdit = new surveys_surveyEditor_componentEditor.ComponentEditor(undefined, {
|
|
992
|
-
key: key,
|
|
993
|
-
isGroup: true,
|
|
994
|
-
role: 'likert',
|
|
995
|
-
});
|
|
996
|
-
groupEdit.setDisplayCondition(displayCondition);
|
|
997
|
-
if (stackOnSmallScreen) {
|
|
998
|
-
groupEdit.setStyles([
|
|
999
|
-
{ key: 'responsive', value: 'stackOnSmallScreen' }
|
|
1000
|
-
]);
|
|
1001
|
-
}
|
|
1002
|
-
options.forEach((option) => {
|
|
1003
|
-
const optionComponent = new surveys_surveyEditor_componentEditor.ComponentEditor(undefined, {
|
|
1004
|
-
key: option.key,
|
|
1005
|
-
role: 'option',
|
|
1006
|
-
});
|
|
1007
|
-
if (option.content) {
|
|
1008
|
-
optionComponent.setContent(surveys_utils_simpleGenerators.generateLocStrings(option.content));
|
|
1009
|
-
}
|
|
1010
|
-
if (option.className) {
|
|
1011
|
-
optionComponent.setStyles([{
|
|
1012
|
-
key: 'className', value: option.className
|
|
1013
|
-
}]);
|
|
1014
|
-
}
|
|
1015
|
-
optionComponent.setDisabled(option.disabled);
|
|
1016
|
-
groupEdit.addItemComponent(optionComponent.getComponent());
|
|
1017
|
-
});
|
|
1018
|
-
return groupEdit.getComponent();
|
|
1019
|
-
};
|
|
1020
245
|
const SurveyItems = {
|
|
1021
246
|
singleChoice: generateSingleChoiceQuestion,
|
|
1022
247
|
responsiveSingleChoiceArray: generateResponsiveSingleChoiceArrayQuestion,
|
|
@@ -1032,20 +257,12 @@ const SurveyItems = {
|
|
|
1032
257
|
numericSlider: generateNumericSliderQuestion,
|
|
1033
258
|
display: generateDisplay,
|
|
1034
259
|
surveyEnd: generateSurveyEnd,
|
|
260
|
+
customQuestion: generateCustomQuestion,
|
|
1035
261
|
old: {
|
|
1036
262
|
simpleLikertGroup: generateSimpleLikertGroupQuestion,
|
|
1037
263
|
}
|
|
1038
264
|
};
|
|
1039
265
|
|
|
1040
266
|
exports.SurveyItems = SurveyItems;
|
|
1041
|
-
exports.initDropdownGroup = initDropdownGroup;
|
|
1042
267
|
exports.initEQ5DHealthIndicatorQuestion = initEQ5DHealthIndicatorQuestion;
|
|
1043
|
-
exports.initLikertScaleGroup = initLikertScaleGroup;
|
|
1044
|
-
exports.initLikertScaleItem = initLikertScaleItem;
|
|
1045
|
-
exports.initMatrixQuestion = initMatrixQuestion;
|
|
1046
|
-
exports.initMultipleChoiceGroup = initMultipleChoiceGroup;
|
|
1047
|
-
exports.initResponsiveBipolarLikertArray = initResponsiveBipolarLikertArray;
|
|
1048
|
-
exports.initResponsiveSingleChoiceArray = initResponsiveSingleChoiceArray;
|
|
1049
|
-
exports.initSingleChoiceGroup = initSingleChoiceGroup;
|
|
1050
|
-
exports.initSliderCategoricalGroup = initSliderCategoricalGroup;
|
|
1051
268
|
//# sourceMappingURL=survey-items.js.map
|