case-editor-tools 1.0.0-beta.14 → 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.
@@ -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 generateNumericInputQuestion = (props) => {
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
- simpleEditor.setResponseGroupWithContent(rg_inner);
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 simpleEditor = new surveys_utils_simpleQuestionEditor.SimpleQuestionEditor(props.parentKey, props.itemKey, props.version ? props.version : 1);
72
- // QUESTION TEXT
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 simpleEditor = new surveys_utils_simpleQuestionEditor.SimpleQuestionEditor(props.parentKey, props.itemKey, props.version ? props.version : 1);
105
- // QUESTION TEXT
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 simpleEditor = new surveys_utils_simpleQuestionEditor.SimpleQuestionEditor(props.parentKey, props.itemKey, props.version ? props.version : 1);
135
- // QUESTION TEXT
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
- const simpleEditor = new surveys_utils_simpleQuestionEditor.SimpleQuestionEditor(props.parentKey, props.itemKey, props.version ? props.version : 1);
168
- // QUESTION TEXT
169
- simpleEditor.setTitle(props.questionText, props.questionSubText, props.titleClassName);
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
- simpleEditor.editor.addValidation({
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
- if (props.footnoteText) {
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
- const simpleEditor = new surveys_utils_simpleQuestionEditor.SimpleQuestionEditor(props.parentKey, props.itemKey, props.version ? props.version : 1);
203
- // QUESTION TEXT
204
- simpleEditor.setTitle(props.questionText, props.questionSubText, props.titleClassName);
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
- simpleEditor.editor.addValidation({
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
- }
227
- if (props.footnoteText) {
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
112
  }
234
- return simpleEditor.getItem();
113
+ return commonQuestionGenerator(props, rg_inner);
235
114
  };
236
115
  const generateResponsiveBipolarLikertArray = (props) => {
237
- const simpleEditor = new surveys_utils_simpleQuestionEditor.SimpleQuestionEditor(props.parentKey, props.itemKey, props.version ? props.version : 1);
238
- // QUESTION TEXT
239
- simpleEditor.setTitle(props.questionText, props.questionSubText, props.titleClassName);
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
- simpleEditor.editor.addValidation({
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
- if (props.footnoteText) {
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
- simpleEditor.setResponseGroupWithContent(rg_inner);
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
- simpleEditor.setResponseGroupWithContent(rg_inner);
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,48 +176,33 @@ const generateTextInputQuestion = (props) => {
372
176
  style: style.length > 0 ? [...style] : undefined,
373
177
  disabled: props.disabled,
374
178
  };
375
- simpleEditor.setResponseGroupWithContent(rg_inner);
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
- simpleEditor.setResponseGroupWithContent(rg_inner);
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);
189
+ };
190
+ const generateClozeQuestion = (props) => {
191
+ const rg_inner = {
192
+ key: constants_keyDefinitions.clozeKey, role: 'cloze',
193
+ items: props.items.map((item) => {
194
+ const clozeItem = item;
195
+ const comp = surveys_responseTypeGenerators_optionGroupComponents.optionDefToItemComponent(clozeItem);
196
+ return comp;
197
+ })
198
+ };
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);
417
206
  };
418
207
  const generateDisplay = (props) => {
419
208
  const simpleEditor = new surveys_utils_simpleQuestionEditor.SimpleQuestionEditor(props.parentKey, props.itemKey, 1);
@@ -432,204 +221,6 @@ const generateSurveyEnd = (parentKey, content, condition) => {
432
221
  editor.setCondition(condition);
433
222
  return editor.getItem();
434
223
  };
435
- const initSingleChoiceGroup = (key, optionItems, order) => {
436
- // init group
437
- return initResponseGroup('singleChoiceGroup', key, optionItems, order);
438
- };
439
- const initMultipleChoiceGroup = (key, optionItems, order) => {
440
- // init group
441
- return initResponseGroup('multipleChoiceGroup', key, optionItems, order);
442
- };
443
- const initDropdownGroup = (key, optionItems, order, groupDisabled, groupContent, groupDescription) => {
444
- // init group
445
- return initResponseGroup('dropDownGroup', key, optionItems, order, groupDisabled, groupContent ? surveys_utils_simpleGenerators.generateLocStrings(groupContent) : undefined, groupDescription ? surveys_utils_simpleGenerators.generateLocStrings(groupDescription) : undefined);
446
- };
447
- const initSliderCategoricalGroup = (key, optionItems, order, groupDisabled) => {
448
- // init group
449
- return initResponseGroup('sliderCategorical', key, optionItems, order, groupDisabled);
450
- };
451
- const optionDefToItemComponent = (optionDef) => {
452
- const isGroup = optionDef.items && optionDef.items.length > 0;
453
- const optEditor = new surveys_surveyEditor_componentEditor.ComponentEditor(undefined, {
454
- key: optionDef.key,
455
- role: optionDef.role,
456
- isGroup: isGroup
457
- });
458
- if (isGroup) {
459
- optEditor.setOrder({
460
- name: 'sequential'
461
- });
462
- }
463
- if (optionDef.content) {
464
- optEditor.setContent(surveys_utils_simpleGenerators.generateLocStrings(optionDef.content));
465
- }
466
- if (optionDef.description) {
467
- optEditor.setDescription(surveys_utils_simpleGenerators.generateLocStrings(optionDef.description));
468
- }
469
- switch (optionDef.role) {
470
- case 'date':
471
- optEditor.setDType('date');
472
- break;
473
- case 'numberInput':
474
- optEditor.setDType('number');
475
- break;
476
- }
477
- if (optionDef.displayCondition) {
478
- optEditor.setDisplayCondition(optionDef.displayCondition);
479
- }
480
- if (optionDef.disabled) {
481
- optEditor.setDisabled(optionDef.disabled);
482
- }
483
- if (optionDef.style) {
484
- optEditor.setStyles(optionDef.style);
485
- }
486
- if (optionDef.optionProps) {
487
- if (typeof (optionDef.optionProps.min) === 'number') {
488
- optionDef.optionProps.min = { dtype: 'num', num: optionDef.optionProps.min };
489
- }
490
- if (typeof (optionDef.optionProps.max) === 'number') {
491
- optionDef.optionProps.max = { dtype: 'num', num: optionDef.optionProps.max };
492
- }
493
- if (typeof (optionDef.optionProps.stepSize) === 'number') {
494
- optionDef.optionProps.stepSize = { dtype: 'num', num: optionDef.optionProps.stepSize };
495
- }
496
- optEditor.setProperties(optionDef.optionProps);
497
- }
498
- if (optionDef.items) {
499
- if (optionDef.role === 'text') {
500
- optionDef.items.forEach((item, index) => {
501
- const textItem = item;
502
- optEditor.addItemComponent({
503
- key: index.toFixed(),
504
- role: 'text',
505
- content: surveys_utils_simpleGenerators.generateLocStrings(textItem.content),
506
- style: textItem.className ? [{ key: 'className', value: textItem.className }] : undefined
507
- });
508
- });
509
- }
510
- else {
511
- optionDef.items.forEach((item) => {
512
- const clozeItem = item;
513
- const comp = optionDefToItemComponent(clozeItem);
514
- optEditor.addItemComponent(comp);
515
- });
516
- }
517
- }
518
- return optEditor.getComponent();
519
- };
520
- const initResponseGroup = (type, key, optionItems, order, groupDisabled, groupContent, groupDescription) => {
521
- // init group
522
- const groupEdit = new surveys_surveyEditor_componentEditor.ComponentEditor(undefined, {
523
- key: key,
524
- isGroup: true,
525
- role: type,
526
- });
527
- groupEdit.setOrder(order ? order : {
528
- name: 'sequential'
529
- });
530
- if (groupDisabled) {
531
- groupEdit.setDisabled(groupDisabled);
532
- }
533
- if (groupContent) {
534
- groupEdit.setContent(groupContent);
535
- }
536
- if (groupDescription) {
537
- groupEdit.setDescription(groupDescription);
538
- }
539
- // add option items
540
- optionItems.forEach(optionDef => {
541
- groupEdit.addItemComponent(optionDefToItemComponent(optionDef));
542
- });
543
- return groupEdit.getComponent();
544
- };
545
- const initMatrixQuestion = (key, rows, order) => {
546
- // init group
547
- const groupEdit = new surveys_surveyEditor_componentEditor.ComponentEditor(undefined, {
548
- key: key,
549
- isGroup: true,
550
- role: 'matrix',
551
- });
552
- groupEdit.setOrder(order ? order : {
553
- name: 'sequential'
554
- });
555
- // init rows
556
- rows.forEach(rowDef => {
557
- const rowEditor = new surveys_surveyEditor_componentEditor.ComponentEditor(undefined, {
558
- key: rowDef.key,
559
- role: rowDef.role,
560
- });
561
- if (rowDef.displayCondition) {
562
- rowEditor.setDisplayCondition(rowDef.displayCondition);
563
- }
564
- if (rowDef.disabled) {
565
- rowEditor.setDisabled(rowDef.disabled);
566
- }
567
- switch (rowDef.role) {
568
- case 'headerRow':
569
- rowDef.cells.forEach(cell => {
570
- const cellEditor = new surveys_surveyEditor_componentEditor.ComponentEditor(undefined, {
571
- key: cell.key,
572
- role: cell.role,
573
- });
574
- if (cell.content) {
575
- cellEditor.setContent(surveys_utils_simpleGenerators.generateLocStrings(cell.content));
576
- }
577
- if (cell.description) {
578
- cellEditor.setDescription(surveys_utils_simpleGenerators.generateLocStrings(cell.description));
579
- }
580
- rowEditor.addItemComponent(cellEditor.getComponent());
581
- });
582
- break;
583
- case 'radioRow':
584
- rowDef.cells.forEach(cell => {
585
- const cellEditor = new surveys_surveyEditor_componentEditor.ComponentEditor(undefined, {
586
- key: cell.key,
587
- role: cell.role,
588
- });
589
- if (cell.content) {
590
- cellEditor.setContent(surveys_utils_simpleGenerators.generateLocStrings(cell.content));
591
- }
592
- if (cell.description) {
593
- cellEditor.setDescription(surveys_utils_simpleGenerators.generateLocStrings(cell.description));
594
- }
595
- rowEditor.addItemComponent(cellEditor.getComponent());
596
- });
597
- break;
598
- case 'responseRow':
599
- rowDef.cells.forEach(cell => {
600
- const cellEditor = new surveys_surveyEditor_componentEditor.ComponentEditor(undefined, {
601
- key: cell.key,
602
- role: cell.role,
603
- });
604
- if (cell.content) {
605
- cellEditor.setContent(surveys_utils_simpleGenerators.generateLocStrings(cell.content));
606
- }
607
- if (cell.description) {
608
- cellEditor.setDescription(surveys_utils_simpleGenerators.generateLocStrings(cell.description));
609
- }
610
- cellEditor.setProperties(cell.properties);
611
- if (cell.items) {
612
- cell.items.forEach(opt => {
613
- const cellOptionEditor = new surveys_surveyEditor_componentEditor.ComponentEditor(undefined, {
614
- key: opt.key,
615
- role: opt.role,
616
- });
617
- if (opt.content) {
618
- cellOptionEditor.setContent(surveys_utils_simpleGenerators.generateLocStrings(opt.content));
619
- }
620
- cellOptionEditor.setDisabled(opt.disabled);
621
- cellOptionEditor.setDisplayCondition(opt.displayCondition);
622
- cellEditor.addItemComponent(cellOptionEditor.getComponent());
623
- });
624
- }
625
- rowEditor.addItemComponent(cellEditor.getComponent());
626
- });
627
- break;
628
- }
629
- groupEdit.addItemComponent(rowEditor.getComponent());
630
- });
631
- return groupEdit.getComponent();
632
- };
633
224
  const initEQ5DHealthIndicatorQuestion = (props) => {
634
225
  // init group
635
226
  const groupEdit = new surveys_surveyEditor_componentEditor.ComponentEditor(undefined, {
@@ -651,339 +242,6 @@ const initEQ5DHealthIndicatorQuestion = (props) => {
651
242
  groupEdit.addItemComponent(maxHealthTextEditor.getComponent());
652
243
  return groupEdit.getComponent();
653
244
  };
654
- const initLikertScaleGroup = (key, rows, scaleOptions, stackOnSmallScreen, displayCondition) => {
655
- const groupEdit = new surveys_surveyEditor_componentEditor.ComponentEditor(undefined, {
656
- key: key,
657
- isGroup: true,
658
- role: 'likertGroup',
659
- });
660
- if (displayCondition) {
661
- groupEdit.setDisplayCondition(displayCondition);
662
- }
663
- rows.forEach((row, index) => {
664
- groupEdit.addItemComponent({
665
- key: surveys_utils_randomKeyGenerator.generateRandomKey(4),
666
- role: 'text',
667
- style: [{
668
- 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')
669
- }, { key: 'variant', value: 'h6' }],
670
- content: surveys_utils_simpleGenerators.generateLocStrings(row.content),
671
- });
672
- if (row.descriptions) {
673
- row.descriptions.forEach(desc => {
674
- groupEdit.addItemComponent(desc);
675
- });
676
- }
677
- const item = initLikertScaleItem(row.key, scaleOptions.map(option => {
678
- var _a, _b;
679
- return {
680
- key: option.key,
681
- className: option.className,
682
- content: row.hideLabels ? undefined : option.content,
683
- 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,
684
- };
685
- }), stackOnSmallScreen, row.displayCondition);
686
- groupEdit.addItemComponent(item);
687
- });
688
- return groupEdit.getComponent();
689
- };
690
- const initResponsiveSingleChoiceArray = (rgKey, props, displayCondition) => {
691
- var _a, _b;
692
- const groupEdit = new surveys_surveyEditor_componentEditor.ComponentEditor(undefined, {
693
- key: rgKey,
694
- isGroup: true,
695
- role: 'responsiveSingleChoiceArray',
696
- });
697
- if (displayCondition) {
698
- groupEdit.setDisplayCondition(displayCondition);
699
- }
700
- const style = [
701
- { key: 'defaultMode', value: props.defaultMode },
702
- ];
703
- if (props.responsiveModes) {
704
- if (props.responsiveModes.sm) {
705
- style.push({ key: 'smMode', value: props.responsiveModes.sm });
706
- }
707
- if (props.responsiveModes.md) {
708
- style.push({ key: 'mdMode', value: props.responsiveModes.md });
709
- }
710
- if (props.responsiveModes.lg) {
711
- style.push({ key: 'lgMode', value: props.responsiveModes.lg });
712
- }
713
- if (props.responsiveModes.xl) {
714
- style.push({ key: 'xlMode', value: props.responsiveModes.xl });
715
- }
716
- if (props.responsiveModes.xxl) {
717
- style.push({ key: 'xxlMode', value: props.responsiveModes.xxl });
718
- }
719
- }
720
- if (props.rgClassName) {
721
- style.push({ key: 'className', value: props.rgClassName });
722
- }
723
- if (props.verticalModeProps) {
724
- if (props.verticalModeProps.useReverseOptionOrder) {
725
- style.push({ key: 'verticalModeReverseOrder', value: 'true' });
726
- }
727
- }
728
- if (props.tableModeProps) {
729
- style.push({ key: 'tableModeClassName', value: 'table-borderless mb-0 ' + props.tableModeProps.className });
730
- if (props.tableModeProps.layout) {
731
- style.push({ key: 'tableModeLayout', value: props.tableModeProps.layout });
732
- }
733
- if (props.tableModeProps.firstColWidth) {
734
- style.push({ key: 'tableModeFirstColWidth', value: props.tableModeProps.firstColWidth });
735
- }
736
- }
737
- groupEdit.setStyles(style);
738
- const defaultBorderClass = 'border-bottom border-grey-2';
739
- let tableModeOptionHeaderClassName = undefined;
740
- if (!((_a = props.tableModeProps) === null || _a === void 0 ? void 0 : _a.hideRowBorder)) {
741
- tableModeOptionHeaderClassName = defaultBorderClass;
742
- }
743
- if ((_b = props.tableModeProps) === null || _b === void 0 ? void 0 : _b.optionHeaderClassName) {
744
- tableModeOptionHeaderClassName += ' ' + props.tableModeProps.optionHeaderClassName;
745
- }
746
- const optionStyles = [];
747
- if (tableModeOptionHeaderClassName) {
748
- optionStyles.push({ key: 'tableModeClassName', value: tableModeOptionHeaderClassName });
749
- }
750
- groupEdit.addItemComponent({
751
- key: 'header',
752
- role: 'options',
753
- style: optionStyles.length > 0 ? optionStyles : undefined,
754
- items: props.scaleOptions.map(option => {
755
- return {
756
- key: option.key,
757
- role: 'option',
758
- style: option.className ? [{ key: 'className', value: option.className }] : undefined,
759
- content: !Array.isArray(option.content) ? surveys_utils_simpleGenerators.generateLocStrings(option.content) : undefined,
760
- items: Array.isArray(option.content) ? option.content.map((cont, index) => {
761
- return {
762
- key: index.toFixed(),
763
- role: 'text',
764
- content: surveys_utils_simpleGenerators.generateLocStrings(cont.content),
765
- style: cont.className ? [{ key: 'className', value: cont.className }] : undefined,
766
- };
767
- }) : [],
768
- };
769
- })
770
- });
771
- props.rows.forEach((row, index) => {
772
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
773
- let tableModeRowClassName = undefined;
774
- let horizontalModeRowClassName = undefined;
775
- let verticalModeRowClassName = undefined;
776
- const isLast = index === props.rows.length - 1;
777
- if (!((_a = props.tableModeProps) === null || _a === void 0 ? void 0 : _a.hideRowBorder) && !isLast) {
778
- tableModeRowClassName = defaultBorderClass;
779
- }
780
- if ((_b = row.tableModeProps) === null || _b === void 0 ? void 0 : _b.className) {
781
- tableModeRowClassName += ' ' + ((_c = row.tableModeProps) === null || _c === void 0 ? void 0 : _c.className);
782
- }
783
- if (!((_d = props.horizontalModeProps) === null || _d === void 0 ? void 0 : _d.hideRowBorder) && !isLast) {
784
- horizontalModeRowClassName = defaultBorderClass;
785
- }
786
- if ((_e = row.horizontalModeProps) === null || _e === void 0 ? void 0 : _e.className) {
787
- horizontalModeRowClassName += ' ' + ((_f = row.horizontalModeProps) === null || _f === void 0 ? void 0 : _f.className);
788
- }
789
- if (!((_g = props.verticalModeProps) === null || _g === void 0 ? void 0 : _g.hideRowBorder) && !isLast) {
790
- verticalModeRowClassName = defaultBorderClass;
791
- }
792
- if ((_h = row.verticalModeProps) === null || _h === void 0 ? void 0 : _h.className) {
793
- verticalModeRowClassName += ' ' + ((_j = row.verticalModeProps) === null || _j === void 0 ? void 0 : _j.className);
794
- }
795
- const rowStyles = [];
796
- if (tableModeRowClassName) {
797
- rowStyles.push({ key: 'tableModeClassName', value: tableModeRowClassName });
798
- }
799
- if (horizontalModeRowClassName) {
800
- rowStyles.push({ key: 'horizontalModeClassName', value: horizontalModeRowClassName });
801
- }
802
- if (verticalModeRowClassName) {
803
- rowStyles.push({ key: 'verticalModeClassName', value: verticalModeRowClassName });
804
- }
805
- if ((_k = row.horizontalModeProps) === null || _k === void 0 ? void 0 : _k.labelPlacement) {
806
- rowStyles.push({ key: 'horizontalModeLabelPlacement', value: row.horizontalModeProps.labelPlacement });
807
- }
808
- groupEdit.addItemComponent({
809
- key: row.key,
810
- role: 'row',
811
- style: rowStyles.length > 0 ? rowStyles : undefined,
812
- content: !Array.isArray(row.content) ? surveys_utils_simpleGenerators.generateLocStrings(row.content) : undefined,
813
- items: Array.isArray(row.content) ? row.content.map((cont, index) => {
814
- return {
815
- key: index.toFixed(),
816
- role: 'text',
817
- content: surveys_utils_simpleGenerators.generateLocStrings(cont.content),
818
- style: cont.className ? [{ key: 'className', value: cont.className }] : undefined,
819
- };
820
- }) : [],
821
- });
822
- });
823
- return groupEdit.getComponent();
824
- };
825
- const initResponsiveBipolarLikertArray = (rgKey, props, displayCondition) => {
826
- var _a;
827
- const groupEdit = new surveys_surveyEditor_componentEditor.ComponentEditor(undefined, {
828
- key: rgKey,
829
- isGroup: true,
830
- role: 'responsiveBipolarLikertScaleArray',
831
- });
832
- if (displayCondition) {
833
- groupEdit.setDisplayCondition(displayCondition);
834
- }
835
- const style = [
836
- { key: 'defaultMode', value: props.defaultMode },
837
- ];
838
- if (props.responsiveModes) {
839
- if (props.responsiveModes.sm) {
840
- style.push({ key: 'smMode', value: props.responsiveModes.sm });
841
- }
842
- if (props.responsiveModes.md) {
843
- style.push({ key: 'mdMode', value: props.responsiveModes.md });
844
- }
845
- if (props.responsiveModes.lg) {
846
- style.push({ key: 'lgMode', value: props.responsiveModes.lg });
847
- }
848
- if (props.responsiveModes.xl) {
849
- style.push({ key: 'xlMode', value: props.responsiveModes.xl });
850
- }
851
- if (props.responsiveModes.xxl) {
852
- style.push({ key: 'xxlMode', value: props.responsiveModes.xxl });
853
- }
854
- }
855
- if (props.rgClassName) {
856
- style.push({ key: 'className', value: props.rgClassName });
857
- }
858
- if (props.withLabelRowModeProps) {
859
- if (props.withLabelRowModeProps.maxLabelWidth) {
860
- style.push({ key: 'labelRowMaxLabelWidth', value: props.withLabelRowModeProps.maxLabelWidth });
861
- }
862
- }
863
- style.push({ key: 'labelRowPosition', value: ((_a = props.withLabelRowModeProps) === null || _a === void 0 ? void 0 : _a.useBottomLabel) ? 'bottom' : 'top' });
864
- if (props.tableModeProps) {
865
- style.push({ key: 'tableModeClassName', value: 'table-borderless mb-0 ' + props.tableModeProps.className });
866
- if (props.tableModeProps.layout) {
867
- style.push({ key: 'tableModeLayout', value: props.tableModeProps.layout });
868
- }
869
- if (props.tableModeProps.labelColWidth) {
870
- style.push({ key: 'tableModeLabelColWidth', value: props.tableModeProps.labelColWidth });
871
- }
872
- }
873
- groupEdit.setStyles(style);
874
- const defaultBorderClass = 'border-bottom border-grey-2';
875
- groupEdit.addItemComponent({
876
- key: 'options',
877
- role: 'options',
878
- items: props.scaleOptions.map(option => {
879
- return {
880
- key: option.key,
881
- role: 'option',
882
- };
883
- })
884
- });
885
- props.rows.forEach((row, index) => {
886
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
887
- let tableModeRowClassName = undefined;
888
- let withLabelRowModeClassName = undefined;
889
- let verticalModeRowClassName = undefined;
890
- const isLast = index === props.rows.length - 1;
891
- if (!((_a = props.tableModeProps) === null || _a === void 0 ? void 0 : _a.hideRowBorder) && !isLast) {
892
- tableModeRowClassName = defaultBorderClass;
893
- }
894
- if ((_b = row.tableModeProps) === null || _b === void 0 ? void 0 : _b.className) {
895
- tableModeRowClassName += ' ' + ((_c = row.tableModeProps) === null || _c === void 0 ? void 0 : _c.className);
896
- }
897
- if (!((_d = props.withLabelRowModeProps) === null || _d === void 0 ? void 0 : _d.hideRowBorder) && !isLast) {
898
- withLabelRowModeClassName = defaultBorderClass;
899
- }
900
- if ((_e = row.withLabelRowModeProps) === null || _e === void 0 ? void 0 : _e.className) {
901
- withLabelRowModeClassName += ' ' + ((_f = row.withLabelRowModeProps) === null || _f === void 0 ? void 0 : _f.className);
902
- }
903
- if (!((_g = props.verticalModeProps) === null || _g === void 0 ? void 0 : _g.hideRowBorder) && !isLast) {
904
- verticalModeRowClassName = defaultBorderClass;
905
- }
906
- if ((_h = row.verticalModeProps) === null || _h === void 0 ? void 0 : _h.className) {
907
- verticalModeRowClassName += ' ' + ((_j = row.verticalModeProps) === null || _j === void 0 ? void 0 : _j.className);
908
- }
909
- const rowStyles = [];
910
- if (tableModeRowClassName) {
911
- rowStyles.push({ key: 'tableModeClassName', value: tableModeRowClassName });
912
- }
913
- if (withLabelRowModeClassName) {
914
- rowStyles.push({ key: 'withLabelRowModeClassName', value: withLabelRowModeClassName });
915
- }
916
- if (verticalModeRowClassName) {
917
- rowStyles.push({ key: 'verticalModeClassName', value: verticalModeRowClassName });
918
- }
919
- const startLabel = {
920
- key: 'start',
921
- role: 'start',
922
- content: !Array.isArray(row.startLabel) ? surveys_utils_simpleGenerators.generateLocStrings(row.startLabel) : undefined,
923
- items: Array.isArray(row.startLabel) ? row.startLabel.map((cont, index) => {
924
- return {
925
- key: index.toFixed(),
926
- role: 'text',
927
- content: surveys_utils_simpleGenerators.generateLocStrings(cont.content),
928
- style: cont.className ? [{ key: 'className', value: cont.className }] : undefined,
929
- };
930
- }) : [],
931
- };
932
- const endLabel = {
933
- key: 'end',
934
- role: 'end',
935
- content: !Array.isArray(row.endLabel) ? surveys_utils_simpleGenerators.generateLocStrings(row.endLabel) : undefined,
936
- items: Array.isArray(row.endLabel) ? row.endLabel.map((cont, index) => {
937
- return {
938
- key: index.toFixed(),
939
- role: 'text',
940
- content: surveys_utils_simpleGenerators.generateLocStrings(cont.content),
941
- style: cont.className ? [{ key: 'className', value: cont.className }] : undefined,
942
- };
943
- }) : [],
944
- };
945
- groupEdit.addItemComponent({
946
- key: row.key,
947
- role: 'row',
948
- style: rowStyles.length > 0 ? rowStyles : undefined,
949
- items: [
950
- startLabel, endLabel
951
- ],
952
- });
953
- });
954
- return groupEdit.getComponent();
955
- };
956
- const initLikertScaleItem = (key, options, stackOnSmallScreen, displayCondition) => {
957
- // init group
958
- const groupEdit = new surveys_surveyEditor_componentEditor.ComponentEditor(undefined, {
959
- key: key,
960
- isGroup: true,
961
- role: 'likert',
962
- });
963
- groupEdit.setDisplayCondition(displayCondition);
964
- if (stackOnSmallScreen) {
965
- groupEdit.setStyles([
966
- { key: 'responsive', value: 'stackOnSmallScreen' }
967
- ]);
968
- }
969
- options.forEach((option) => {
970
- const optionComponent = new surveys_surveyEditor_componentEditor.ComponentEditor(undefined, {
971
- key: option.key,
972
- role: 'option',
973
- });
974
- if (option.content) {
975
- optionComponent.setContent(surveys_utils_simpleGenerators.generateLocStrings(option.content));
976
- }
977
- if (option.className) {
978
- optionComponent.setStyles([{
979
- key: 'className', value: option.className
980
- }]);
981
- }
982
- optionComponent.setDisabled(option.disabled);
983
- groupEdit.addItemComponent(optionComponent.getComponent());
984
- });
985
- return groupEdit.getComponent();
986
- };
987
245
  const SurveyItems = {
988
246
  singleChoice: generateSingleChoiceQuestion,
989
247
  responsiveSingleChoiceArray: generateResponsiveSingleChoiceArrayQuestion,
@@ -992,27 +250,19 @@ const SurveyItems = {
992
250
  dateInput: generateDatePickerInput,
993
251
  textInput: generateTextInputQuestion,
994
252
  // eq5dSlider: todo,
995
- // clozeQuestion: todo,
253
+ clozeQuestion: generateClozeQuestion,
996
254
  numericInput: generateNumericInputQuestion,
997
255
  multilineTextInput: generateMultilineInput,
998
256
  dropDown: generateDropDownQuestion,
999
257
  numericSlider: generateNumericSliderQuestion,
1000
258
  display: generateDisplay,
1001
259
  surveyEnd: generateSurveyEnd,
260
+ customQuestion: generateCustomQuestion,
1002
261
  old: {
1003
262
  simpleLikertGroup: generateSimpleLikertGroupQuestion,
1004
263
  }
1005
264
  };
1006
265
 
1007
266
  exports.SurveyItems = SurveyItems;
1008
- exports.initDropdownGroup = initDropdownGroup;
1009
267
  exports.initEQ5DHealthIndicatorQuestion = initEQ5DHealthIndicatorQuestion;
1010
- exports.initLikertScaleGroup = initLikertScaleGroup;
1011
- exports.initLikertScaleItem = initLikertScaleItem;
1012
- exports.initMatrixQuestion = initMatrixQuestion;
1013
- exports.initMultipleChoiceGroup = initMultipleChoiceGroup;
1014
- exports.initResponsiveBipolarLikertArray = initResponsiveBipolarLikertArray;
1015
- exports.initResponsiveSingleChoiceArray = initResponsiveSingleChoiceArray;
1016
- exports.initSingleChoiceGroup = initSingleChoiceGroup;
1017
- exports.initSliderCategoricalGroup = initSliderCategoricalGroup;
1018
268
  //# sourceMappingURL=survey-items.js.map