case-editor-tools 1.0.0-beta.7 → 1.0.0
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/constants/key-definitions.d.ts +16 -0
- package/constants/key-definitions.js +38 -0
- package/constants/key-definitions.js.map +1 -0
- package/exporter/index.d.ts +2 -0
- package/exporter/index.js +128 -0
- package/exporter/index.js.map +1 -0
- package/expression-utils/expressionGen.d.ts +2 -0
- package/expression-utils/expressionGen.js +31 -0
- package/expression-utils/expressionGen.js.map +1 -0
- package/expression-utils/studyEngineExpressions.d.ts +195 -0
- package/expression-utils/studyEngineExpressions.js +479 -0
- package/expression-utils/studyEngineExpressions.js.map +1 -0
- package/index.d.ts +0 -0
- package/index.js +3 -0
- package/index.js.map +1 -0
- package/item-editor-59f51ecc.js +542 -0
- package/item-editor-59f51ecc.js.map +1 -0
- package/logger/index.d.ts +1 -0
- package/logger/index.js +10 -0
- package/logger/index.js.map +1 -0
- package/logger/logger.d.ts +9 -0
- package/logger/logger.js +31 -0
- package/logger/logger.js.map +1 -0
- package/package.json +5 -5
- package/surveys/index.d.ts +3 -0
- package/surveys/index.js +29 -0
- package/surveys/index.js.map +1 -0
- package/surveys/responseTypeGenerators/likertGroupComponents.d.ts +27 -0
- package/surveys/responseTypeGenerators/likertGroupComponents.js +350 -0
- package/surveys/responseTypeGenerators/likertGroupComponents.js.map +1 -0
- package/surveys/responseTypeGenerators/matrixGroupComponent.d.ts +49 -0
- package/surveys/responseTypeGenerators/matrixGroupComponent.js +100 -0
- package/surveys/responseTypeGenerators/matrixGroupComponent.js.map +1 -0
- package/surveys/responseTypeGenerators/optionGroupComponents.d.ts +7 -0
- package/surveys/responseTypeGenerators/optionGroupComponents.js +129 -0
- package/surveys/responseTypeGenerators/optionGroupComponents.js.map +1 -0
- package/surveys/survey-editor/component-editor.d.ts +84 -0
- package/surveys/survey-editor/component-editor.js +112 -0
- package/surveys/survey-editor/component-editor.js.map +1 -0
- package/surveys/survey-editor/data-types.d.ts +13 -0
- package/surveys/survey-editor/data-types.js +3 -0
- package/surveys/survey-editor/data-types.js.map +1 -0
- package/surveys/survey-editor/item-editor.d.ts +66 -0
- package/surveys/survey-editor/item-editor.js +13 -0
- package/surveys/survey-editor/item-editor.js.map +1 -0
- package/surveys/survey-editor/survey-editor.d.ts +48 -0
- package/surveys/survey-editor/survey-editor.js +237 -0
- package/surveys/survey-editor/survey-editor.js.map +1 -0
- package/surveys/survey-engine-expressions.d.ts +130 -0
- package/surveys/survey-engine-expressions.js +448 -0
- package/surveys/survey-engine-expressions.js.map +1 -0
- package/surveys/survey-items.d.ts +72 -0
- package/surveys/survey-items.js +384 -0
- package/surveys/survey-items.js.map +1 -0
- package/surveys/types/group.d.ts +23 -0
- package/surveys/types/group.js +72 -0
- package/surveys/types/group.js.map +1 -0
- package/surveys/types/index.d.ts +4 -0
- package/surveys/types/index.js +22 -0
- package/surveys/types/index.js.map +1 -0
- package/surveys/types/item-properties.d.ts +223 -0
- package/surveys/types/item-properties.js +10 -0
- package/surveys/types/item-properties.js.map +1 -0
- package/surveys/types/item.d.ts +22 -0
- package/surveys/types/item.js +34 -0
- package/surveys/types/item.js.map +1 -0
- package/surveys/types/survey-definition.d.ts +23 -0
- package/surveys/types/survey-definition.js +69 -0
- package/surveys/types/survey-definition.js.map +1 -0
- package/surveys/utils/componentGenerators.d.ts +24 -0
- package/surveys/utils/componentGenerators.js +59 -0
- package/surveys/utils/componentGenerators.js.map +1 -0
- package/surveys/utils/optionDefGenerators.d.ts +84 -0
- package/surveys/utils/optionDefGenerators.js +211 -0
- package/surveys/utils/optionDefGenerators.js.map +1 -0
- package/surveys/utils/randomKeyGenerator.d.ts +1 -0
- package/surveys/utils/randomKeyGenerator.js +16 -0
- package/surveys/utils/randomKeyGenerator.js.map +1 -0
- package/surveys/utils/simple-generators.d.ts +14 -0
- package/surveys/utils/simple-generators.js +131 -0
- package/surveys/utils/simple-generators.js.map +1 -0
- package/surveys/utils/simple-question-editor.d.ts +14 -0
- package/surveys/utils/simple-question-editor.js +47 -0
- package/surveys/utils/simple-question-editor.js.map +1 -0
- package/types/duration.d.ts +9 -0
- package/types/duration.js +29 -0
- package/types/duration.js.map +1 -0
- package/types/expression.d.ts +4 -0
- package/types/expression.js +23 -0
- package/types/expression.js.map +1 -0
- package/types/messageConfig.d.ts +49 -0
- package/types/messageConfig.js +23 -0
- package/types/messageConfig.js.map +1 -0
- package/types/study.d.ts +15 -0
- package/types/study.js +3 -0
- package/types/study.js.map +1 -0
- package/types/studyRules.d.ts +9 -0
- package/types/studyRules.js +36 -0
- package/types/studyRules.js.map +1 -0
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var surveys_surveyEditor_componentEditor = require('./survey-editor/component-editor.js');
|
|
6
|
+
var surveys_surveyEditor_itemEditor = require('../item-editor-59f51ecc.js');
|
|
7
|
+
var surveys_utils_componentGenerators = require('./utils/componentGenerators.js');
|
|
8
|
+
var types_duration = require('../types/duration.js');
|
|
9
|
+
var constants_keyDefinitions = require('../constants/key-definitions.js');
|
|
10
|
+
var surveys_utils_simpleGenerators = require('./utils/simple-generators.js');
|
|
11
|
+
var surveys_utils_simpleQuestionEditor = require('./utils/simple-question-editor.js');
|
|
12
|
+
var surveys_surveyEngineExpressions = require('./survey-engine-expressions.js');
|
|
13
|
+
var surveys_types_itemProperties = require('./types/item-properties.js');
|
|
14
|
+
var surveys_responseTypeGenerators_optionGroupComponents = require('./responseTypeGenerators/optionGroupComponents.js');
|
|
15
|
+
var surveys_responseTypeGenerators_likertGroupComponents = require('./responseTypeGenerators/likertGroupComponents.js');
|
|
16
|
+
require('./utils/randomKeyGenerator.js');
|
|
17
|
+
require('../logger/logger.js');
|
|
18
|
+
require('../expression-utils/expressionGen.js');
|
|
19
|
+
|
|
20
|
+
const commonQuestionGenerator = (props, rg_inner) => {
|
|
21
|
+
const simpleEditor = new surveys_utils_simpleQuestionEditor.SimpleQuestionEditor(props.parentKey, props.itemKey, props.version ? props.version : 1, props.confidentialMode);
|
|
22
|
+
// QUESTION TEXT
|
|
23
|
+
simpleEditor.setTitle(props.questionText, props.questionSubText, props.titleClassName);
|
|
24
|
+
if (props.condition) {
|
|
25
|
+
simpleEditor.setCondition(props.condition);
|
|
26
|
+
}
|
|
27
|
+
if (props.helpGroupContent) {
|
|
28
|
+
simpleEditor.editor.setHelpGroupComponent(surveys_utils_simpleGenerators.generateHelpGroupComponent(props.helpGroupContent));
|
|
29
|
+
}
|
|
30
|
+
if (props.topDisplayCompoments) {
|
|
31
|
+
props.topDisplayCompoments.forEach(comp => simpleEditor.addDisplayComponent(comp));
|
|
32
|
+
}
|
|
33
|
+
simpleEditor.setResponseGroupWithContent(rg_inner);
|
|
34
|
+
if (props.bottomDisplayCompoments) {
|
|
35
|
+
props.bottomDisplayCompoments.forEach(comp => simpleEditor.addDisplayComponent(comp));
|
|
36
|
+
}
|
|
37
|
+
if (props.isRequired) {
|
|
38
|
+
simpleEditor.addHasResponseValidation();
|
|
39
|
+
}
|
|
40
|
+
if (props.customValidations) {
|
|
41
|
+
props.customValidations.forEach(v => simpleEditor.editor.addValidation(v));
|
|
42
|
+
}
|
|
43
|
+
if (props.footnoteText) {
|
|
44
|
+
simpleEditor.addDisplayComponent(surveys_utils_componentGenerators.ComponentGenerators.footnote({ content: props.footnoteText }));
|
|
45
|
+
}
|
|
46
|
+
return simpleEditor.getItem();
|
|
47
|
+
};
|
|
48
|
+
const generateNumericInputQuestion = (props) => {
|
|
49
|
+
var _a, _b, _c, _d;
|
|
50
|
+
const style = [];
|
|
51
|
+
if (props.inputMaxWidth) {
|
|
52
|
+
style.push({
|
|
53
|
+
key: 'inputMaxWidth', value: props.inputMaxWidth,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
if (props.labelBehindInput) {
|
|
57
|
+
style.push({ key: 'labelPlacement', value: 'after' });
|
|
58
|
+
}
|
|
59
|
+
const rg_inner = {
|
|
60
|
+
key: constants_keyDefinitions.numericInputKey,
|
|
61
|
+
role: 'numberInput',
|
|
62
|
+
properties: {
|
|
63
|
+
min: ((_a = props.componentProperties) === null || _a === void 0 ? void 0 : _a.min) !== undefined ? (typeof (props.componentProperties.min) === 'number' ? { dtype: 'num', num: props.componentProperties.min } : props.componentProperties.min) : undefined,
|
|
64
|
+
max: ((_b = props.componentProperties) === null || _b === void 0 ? void 0 : _b.max) !== undefined ? (typeof ((_c = props.componentProperties) === null || _c === void 0 ? void 0 : _c.max) === 'number' ? { dtype: 'num', num: props.componentProperties.max } : props.componentProperties.max) : undefined,
|
|
65
|
+
stepSize: ((_d = props.componentProperties) === null || _d === void 0 ? void 0 : _d.stepSize) ? (typeof (props.componentProperties.stepSize) === 'number' ? { dtype: 'num', num: props.componentProperties.stepSize } : props.componentProperties.stepSize) : undefined,
|
|
66
|
+
},
|
|
67
|
+
content: surveys_utils_simpleGenerators.generateLocStrings(props.inputLabel),
|
|
68
|
+
style: style.length > 0 ? style : undefined,
|
|
69
|
+
};
|
|
70
|
+
return commonQuestionGenerator(props, rg_inner);
|
|
71
|
+
};
|
|
72
|
+
const generateSingleChoiceQuestion = (props) => {
|
|
73
|
+
const rg_inner = surveys_responseTypeGenerators_optionGroupComponents.initSingleChoiceGroup(constants_keyDefinitions.singleChoiceKey, props.responseOptions);
|
|
74
|
+
return commonQuestionGenerator(props, rg_inner);
|
|
75
|
+
};
|
|
76
|
+
const generateDropDownQuestion = (props) => {
|
|
77
|
+
const rg_inner = surveys_responseTypeGenerators_optionGroupComponents.initDropdownGroup(constants_keyDefinitions.dropDownKey, props.responseOptions, undefined, undefined, undefined, props.placeholder);
|
|
78
|
+
return commonQuestionGenerator(props, rg_inner);
|
|
79
|
+
};
|
|
80
|
+
const generateMultipleChoiceQuestion = (props) => {
|
|
81
|
+
const rg_inner = surveys_responseTypeGenerators_optionGroupComponents.initMultipleChoiceGroup(constants_keyDefinitions.multipleChoiceKey, props.responseOptions);
|
|
82
|
+
return commonQuestionGenerator(props, rg_inner);
|
|
83
|
+
};
|
|
84
|
+
const generateSimpleLikertGroupQuestion = (props) => {
|
|
85
|
+
var _a;
|
|
86
|
+
const rg_inner = surveys_responseTypeGenerators_likertGroupComponents.initLikertScaleGroup(constants_keyDefinitions.likertScaleGroupKey, props.rows, props.scaleOptions, props.stackOnSmallScreen);
|
|
87
|
+
// Add extra validation for likert
|
|
88
|
+
if (props.isRequired) {
|
|
89
|
+
if (!props.customValidations) {
|
|
90
|
+
props.customValidations = [];
|
|
91
|
+
}
|
|
92
|
+
(_a = props.customValidations) === null || _a === void 0 ? void 0 : _a.push({
|
|
93
|
+
key: 'r',
|
|
94
|
+
type: 'hard',
|
|
95
|
+
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))))
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
return commonQuestionGenerator(props, rg_inner);
|
|
99
|
+
};
|
|
100
|
+
const generateResponsiveSingleChoiceArrayQuestion = (props) => {
|
|
101
|
+
var _a;
|
|
102
|
+
const rg_inner = surveys_responseTypeGenerators_likertGroupComponents.initResponsiveSingleChoiceArray(constants_keyDefinitions.responsiveSingleChoiceArrayKey, Object.assign({}, props));
|
|
103
|
+
// Add extra validation
|
|
104
|
+
if (props.isRequired) {
|
|
105
|
+
if (!props.customValidations) {
|
|
106
|
+
props.customValidations = [];
|
|
107
|
+
}
|
|
108
|
+
(_a = props.customValidations) === null || _a === void 0 ? void 0 : _a.push({
|
|
109
|
+
key: 'r',
|
|
110
|
+
type: 'hard',
|
|
111
|
+
rule: surveys_utils_simpleGenerators.expWithArgs('and', ...props.rows.map(r => {
|
|
112
|
+
const hasRespExp = 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));
|
|
113
|
+
if (r.displayCondition === undefined) {
|
|
114
|
+
return hasRespExp;
|
|
115
|
+
}
|
|
116
|
+
return surveys_surveyEngineExpressions.SurveyEngine.logic.or(surveys_surveyEngineExpressions.SurveyEngine.logic.not(r.displayCondition), hasRespExp);
|
|
117
|
+
}))
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
return commonQuestionGenerator(props, rg_inner);
|
|
121
|
+
};
|
|
122
|
+
const generateResponsiveBipolarLikertArray = (props) => {
|
|
123
|
+
var _a;
|
|
124
|
+
const rg_inner = surveys_responseTypeGenerators_likertGroupComponents.initResponsiveBipolarLikertArray(constants_keyDefinitions.responsiveBipolarLikertArrayKey, Object.assign({}, props));
|
|
125
|
+
// Add extra validation
|
|
126
|
+
if (props.isRequired) {
|
|
127
|
+
if (!props.customValidations) {
|
|
128
|
+
props.customValidations = [];
|
|
129
|
+
}
|
|
130
|
+
(_a = props.customValidations) === null || _a === void 0 ? void 0 : _a.push({
|
|
131
|
+
key: 'r',
|
|
132
|
+
type: 'hard',
|
|
133
|
+
rule: surveys_utils_simpleGenerators.expWithArgs('and', ...props.rows.map(r => {
|
|
134
|
+
const hasRespExp = 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));
|
|
135
|
+
if (r.displayCondition === undefined) {
|
|
136
|
+
return hasRespExp;
|
|
137
|
+
}
|
|
138
|
+
return surveys_surveyEngineExpressions.SurveyEngine.logic.or(surveys_surveyEngineExpressions.SurveyEngine.logic.not(r.displayCondition), hasRespExp);
|
|
139
|
+
}))
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
return commonQuestionGenerator(props, rg_inner);
|
|
143
|
+
};
|
|
144
|
+
const generateNumericSliderQuestion = (props) => {
|
|
145
|
+
const rg_inner = {
|
|
146
|
+
key: 'slider', role: 'sliderNumeric',
|
|
147
|
+
content: surveys_utils_simpleGenerators.generateLocStrings(props.sliderLabel),
|
|
148
|
+
description: surveys_utils_simpleGenerators.generateLocStrings(props.noResponseLabel),
|
|
149
|
+
properties: {
|
|
150
|
+
min: props.min !== undefined ? (typeof (props.min) === 'number' ? { dtype: 'num', num: props.min } : props.min) : undefined,
|
|
151
|
+
max: props.max !== undefined ? (typeof (props.max) === 'number' ? { dtype: 'num', num: props.max } : props.max) : undefined,
|
|
152
|
+
stepSize: props.stepSize ? (typeof (props.stepSize) === 'number' ? { dtype: 'num', num: props.stepSize } : props.stepSize) : undefined,
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
return commonQuestionGenerator(props, rg_inner);
|
|
156
|
+
};
|
|
157
|
+
const generateDatePickerInput = (props) => {
|
|
158
|
+
const rg_inner = {
|
|
159
|
+
key: constants_keyDefinitions.datePickerKey, role: 'dateInput',
|
|
160
|
+
properties: {
|
|
161
|
+
dateInputMode: { str: props.dateInputMode },
|
|
162
|
+
min: props.minRelativeDate ? {
|
|
163
|
+
dtype: 'exp', exp: surveys_surveyEngineExpressions.SurveyEngine.timestampWithOffset(props.minRelativeDate.delta, props.minRelativeDate.reference)
|
|
164
|
+
} : undefined,
|
|
165
|
+
max: props.maxRelativeDate ? {
|
|
166
|
+
dtype: 'exp', exp: surveys_utils_simpleGenerators.expWithArgs('timestampWithOffset', types_duration.durationObjectToSeconds(props.maxRelativeDate.delta), props.maxRelativeDate.reference ? props.maxRelativeDate.reference : undefined)
|
|
167
|
+
} : undefined,
|
|
168
|
+
},
|
|
169
|
+
content: props.inputLabelText ? surveys_utils_simpleGenerators.generateLocStrings(props.inputLabelText) : undefined,
|
|
170
|
+
description: props.placeholderText ? surveys_utils_simpleGenerators.generateLocStrings(props.placeholderText) : undefined,
|
|
171
|
+
};
|
|
172
|
+
return commonQuestionGenerator(props, rg_inner);
|
|
173
|
+
};
|
|
174
|
+
const generateTimeInput = (props) => {
|
|
175
|
+
const style = [];
|
|
176
|
+
if (props.minTime) {
|
|
177
|
+
style.push({
|
|
178
|
+
key: 'minTime', value: props.minTime,
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
if (props.maxTime) {
|
|
182
|
+
style.push({
|
|
183
|
+
key: 'maxTime', value: props.maxTime,
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
if (props.defaultValue) {
|
|
187
|
+
style.push({
|
|
188
|
+
key: 'defaultValue', value: props.defaultValue,
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
if (props.labelBehindInput) {
|
|
192
|
+
style.push({ key: 'labelPlacement', value: 'after' });
|
|
193
|
+
}
|
|
194
|
+
const rg_inner = {
|
|
195
|
+
key: constants_keyDefinitions.timeInputKey, role: 'timeInput',
|
|
196
|
+
properties: {
|
|
197
|
+
stepSize: props.step,
|
|
198
|
+
},
|
|
199
|
+
content: props.inputLabelText ? surveys_utils_simpleGenerators.generateLocStrings(props.inputLabelText) : undefined,
|
|
200
|
+
style: style.length > 0 ? style : undefined,
|
|
201
|
+
};
|
|
202
|
+
return commonQuestionGenerator(props, rg_inner);
|
|
203
|
+
};
|
|
204
|
+
const generateTextInputQuestion = (props) => {
|
|
205
|
+
const style = [];
|
|
206
|
+
if (props.maxLength !== undefined) {
|
|
207
|
+
style.push({ key: 'maxLength', value: props.maxLength.toFixed(0) });
|
|
208
|
+
}
|
|
209
|
+
if (props.className !== undefined) {
|
|
210
|
+
style.push({ key: 'className', value: props.className });
|
|
211
|
+
}
|
|
212
|
+
if (props.inputMaxWidth !== undefined) {
|
|
213
|
+
style.push({ key: 'inputMaxWidth', value: props.inputMaxWidth });
|
|
214
|
+
}
|
|
215
|
+
const rg_inner = {
|
|
216
|
+
key: constants_keyDefinitions.inputKey, role: 'input',
|
|
217
|
+
content: props.inputLabel ? surveys_utils_simpleGenerators.generateLocStrings(props.inputLabel) : undefined,
|
|
218
|
+
description: props.placeholderText ? surveys_utils_simpleGenerators.generateLocStrings(props.placeholderText) : undefined,
|
|
219
|
+
style: style.length > 0 ? [...style] : undefined,
|
|
220
|
+
disabled: props.disabled,
|
|
221
|
+
};
|
|
222
|
+
return commonQuestionGenerator(props, rg_inner);
|
|
223
|
+
};
|
|
224
|
+
const generateConsentQuestion = (props) => {
|
|
225
|
+
const style = props.className ? [{ key: 'className', value: props.className }] : undefined;
|
|
226
|
+
const rg_inner = {
|
|
227
|
+
key: constants_keyDefinitions.consentKey, role: 'consent',
|
|
228
|
+
items: [
|
|
229
|
+
{
|
|
230
|
+
key: 'label', role: 'label',
|
|
231
|
+
content: !Array.isArray(props.checkBoxLabel) ? surveys_utils_simpleGenerators.generateLocStrings(props.checkBoxLabel) : undefined,
|
|
232
|
+
items: Array.isArray(props.checkBoxLabel) ? props.checkBoxLabel.map((item, index) => {
|
|
233
|
+
if (surveys_types_itemProperties.isDateDisplayComponentProp(item)) {
|
|
234
|
+
return surveys_utils_simpleGenerators.generateDateDisplayComp(index.toFixed(), item);
|
|
235
|
+
}
|
|
236
|
+
return {
|
|
237
|
+
key: index.toFixed(),
|
|
238
|
+
role: 'text',
|
|
239
|
+
content: surveys_utils_simpleGenerators.generateLocStrings(item.content),
|
|
240
|
+
style: item.className ? [{ key: 'className', value: item.className }] : undefined
|
|
241
|
+
};
|
|
242
|
+
}) : undefined,
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
key: 'title', role: 'title', content: surveys_utils_simpleGenerators.generateLocStrings(props.dialogTitle)
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
key: 'content', role: 'content', content: surveys_utils_simpleGenerators.generateLocStrings(props.dialogContent)
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
key: 'acceptBtn', role: 'acceptBtn', content: surveys_utils_simpleGenerators.generateLocStrings(props.acceptBtn)
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
key: 'rejectBtn', role: 'rejectBtn', content: surveys_utils_simpleGenerators.generateLocStrings(props.rejectBtn)
|
|
255
|
+
},
|
|
256
|
+
],
|
|
257
|
+
style: style,
|
|
258
|
+
};
|
|
259
|
+
return commonQuestionGenerator(props, rg_inner);
|
|
260
|
+
};
|
|
261
|
+
const generateMultilineInput = (props) => {
|
|
262
|
+
const rg_inner = {
|
|
263
|
+
key: constants_keyDefinitions.inputKey, role: 'multilineTextInput',
|
|
264
|
+
content: props.inputLabelText ? surveys_utils_simpleGenerators.generateLocStrings(props.inputLabelText) : undefined,
|
|
265
|
+
description: props.placeholderText ? surveys_utils_simpleGenerators.generateLocStrings(props.placeholderText) : undefined,
|
|
266
|
+
style: props.maxLength !== undefined ? [{ key: 'maxLength', value: props.maxLength.toFixed(0) }] : undefined
|
|
267
|
+
};
|
|
268
|
+
return commonQuestionGenerator(props, rg_inner);
|
|
269
|
+
};
|
|
270
|
+
const generateClozeQuestion = (props) => {
|
|
271
|
+
const rg_inner = {
|
|
272
|
+
key: constants_keyDefinitions.clozeKey, role: 'cloze',
|
|
273
|
+
items: props.items.map((item) => {
|
|
274
|
+
const clozeItem = item;
|
|
275
|
+
const comp = surveys_responseTypeGenerators_optionGroupComponents.optionDefToItemComponent(clozeItem);
|
|
276
|
+
return comp;
|
|
277
|
+
})
|
|
278
|
+
};
|
|
279
|
+
return commonQuestionGenerator(props, rg_inner);
|
|
280
|
+
};
|
|
281
|
+
const generateCustomQuestion = (props) => {
|
|
282
|
+
const items = [];
|
|
283
|
+
props.responseItemDefs.forEach(item => {
|
|
284
|
+
const rolePrefix = item.mapToRole !== undefined ? `${item.mapToRole}` : '';
|
|
285
|
+
const role = `${rolePrefix}:${item.role}`;
|
|
286
|
+
delete item['mapToRole'];
|
|
287
|
+
const rg_inner = Object.assign(Object.assign({}, item), { role: role });
|
|
288
|
+
items.push(rg_inner);
|
|
289
|
+
});
|
|
290
|
+
const simpleEditor = new surveys_utils_simpleQuestionEditor.SimpleQuestionEditor(props.parentKey, props.itemKey, props.version ? props.version : 1, props.confidentialMode);
|
|
291
|
+
// QUESTION TEXT
|
|
292
|
+
simpleEditor.setTitle(props.questionText, props.questionSubText, props.titleClassName);
|
|
293
|
+
if (props.condition) {
|
|
294
|
+
simpleEditor.setCondition(props.condition);
|
|
295
|
+
}
|
|
296
|
+
if (props.helpGroupContent) {
|
|
297
|
+
simpleEditor.editor.setHelpGroupComponent(surveys_utils_simpleGenerators.generateHelpGroupComponent(props.helpGroupContent));
|
|
298
|
+
}
|
|
299
|
+
if (props.topDisplayCompoments) {
|
|
300
|
+
props.topDisplayCompoments.forEach(comp => simpleEditor.addDisplayComponent(comp));
|
|
301
|
+
}
|
|
302
|
+
simpleEditor.editor.addExistingResponseComponent({
|
|
303
|
+
key: constants_keyDefinitions.responseGroupKey,
|
|
304
|
+
role: 'responseGroup',
|
|
305
|
+
items,
|
|
306
|
+
});
|
|
307
|
+
if (props.bottomDisplayCompoments) {
|
|
308
|
+
props.bottomDisplayCompoments.forEach(comp => simpleEditor.addDisplayComponent(comp));
|
|
309
|
+
}
|
|
310
|
+
if (props.isRequired) {
|
|
311
|
+
simpleEditor.addHasResponseValidation();
|
|
312
|
+
}
|
|
313
|
+
if (props.customValidations) {
|
|
314
|
+
props.customValidations.forEach(v => simpleEditor.editor.addValidation(v));
|
|
315
|
+
}
|
|
316
|
+
if (props.footnoteText) {
|
|
317
|
+
simpleEditor.addDisplayComponent(surveys_utils_componentGenerators.ComponentGenerators.footnote({ content: props.footnoteText }));
|
|
318
|
+
}
|
|
319
|
+
return simpleEditor.getItem();
|
|
320
|
+
};
|
|
321
|
+
const generateDisplay = (props) => {
|
|
322
|
+
const simpleEditor = new surveys_utils_simpleQuestionEditor.SimpleQuestionEditor(props.parentKey, props.itemKey, 1);
|
|
323
|
+
props.content.forEach(item => simpleEditor.addDisplayComponent(item));
|
|
324
|
+
if (props.condition) {
|
|
325
|
+
simpleEditor.setCondition(props.condition);
|
|
326
|
+
}
|
|
327
|
+
return simpleEditor.getItem();
|
|
328
|
+
};
|
|
329
|
+
const generateSurveyEnd = (parentKey, content, condition) => {
|
|
330
|
+
const defaultKey = 'surveyEnd';
|
|
331
|
+
const itemKey = [parentKey, defaultKey].join('.');
|
|
332
|
+
const editor = new surveys_surveyEditor_itemEditor.ItemEditor(undefined, { itemKey: itemKey, type: 'surveyEnd', isGroup: false });
|
|
333
|
+
editor.setTitleComponent(surveys_utils_simpleGenerators.generateTitleComponent(content));
|
|
334
|
+
// CONDITION
|
|
335
|
+
editor.setCondition(condition);
|
|
336
|
+
return editor.getItem();
|
|
337
|
+
};
|
|
338
|
+
const initEQ5DHealthIndicatorQuestion = (props) => {
|
|
339
|
+
// init group
|
|
340
|
+
const groupEdit = new surveys_surveyEditor_componentEditor.ComponentEditor(undefined, {
|
|
341
|
+
key: props.key,
|
|
342
|
+
isGroup: true,
|
|
343
|
+
role: props.role,
|
|
344
|
+
});
|
|
345
|
+
const instructionTextEditor = new surveys_surveyEditor_componentEditor.ComponentEditor(undefined, { role: 'instruction', });
|
|
346
|
+
instructionTextEditor.setContent(surveys_utils_simpleGenerators.generateLocStrings(props.instructionText));
|
|
347
|
+
groupEdit.addItemComponent(instructionTextEditor.getComponent());
|
|
348
|
+
const valueBoxTextEditor = new surveys_surveyEditor_componentEditor.ComponentEditor(undefined, { role: 'valuebox', });
|
|
349
|
+
valueBoxTextEditor.setContent(surveys_utils_simpleGenerators.generateLocStrings(props.valueBoxText));
|
|
350
|
+
groupEdit.addItemComponent(valueBoxTextEditor.getComponent());
|
|
351
|
+
const minHealthTextEditor = new surveys_surveyEditor_componentEditor.ComponentEditor(undefined, { role: 'mintext', });
|
|
352
|
+
minHealthTextEditor.setContent(surveys_utils_simpleGenerators.generateLocStrings(props.minHealthText));
|
|
353
|
+
groupEdit.addItemComponent(minHealthTextEditor.getComponent());
|
|
354
|
+
const maxHealthTextEditor = new surveys_surveyEditor_componentEditor.ComponentEditor(undefined, { role: 'maxtext', });
|
|
355
|
+
maxHealthTextEditor.setContent(surveys_utils_simpleGenerators.generateLocStrings(props.maxHealthText));
|
|
356
|
+
groupEdit.addItemComponent(maxHealthTextEditor.getComponent());
|
|
357
|
+
return groupEdit.getComponent();
|
|
358
|
+
};
|
|
359
|
+
const SurveyItems = {
|
|
360
|
+
consent: generateConsentQuestion,
|
|
361
|
+
singleChoice: generateSingleChoiceQuestion,
|
|
362
|
+
responsiveSingleChoiceArray: generateResponsiveSingleChoiceArrayQuestion,
|
|
363
|
+
responsiveBipolarLikertArray: generateResponsiveBipolarLikertArray,
|
|
364
|
+
multipleChoice: generateMultipleChoiceQuestion,
|
|
365
|
+
dateInput: generateDatePickerInput,
|
|
366
|
+
timeInput: generateTimeInput,
|
|
367
|
+
textInput: generateTextInputQuestion,
|
|
368
|
+
// eq5dSlider: todo,
|
|
369
|
+
clozeQuestion: generateClozeQuestion,
|
|
370
|
+
numericInput: generateNumericInputQuestion,
|
|
371
|
+
multilineTextInput: generateMultilineInput,
|
|
372
|
+
dropDown: generateDropDownQuestion,
|
|
373
|
+
numericSlider: generateNumericSliderQuestion,
|
|
374
|
+
display: generateDisplay,
|
|
375
|
+
surveyEnd: generateSurveyEnd,
|
|
376
|
+
customQuestion: generateCustomQuestion,
|
|
377
|
+
old: {
|
|
378
|
+
simpleLikertGroup: generateSimpleLikertGroupQuestion,
|
|
379
|
+
}
|
|
380
|
+
};
|
|
381
|
+
|
|
382
|
+
exports.SurveyItems = SurveyItems;
|
|
383
|
+
exports.initEQ5DHealthIndicatorQuestion = initEQ5DHealthIndicatorQuestion;
|
|
384
|
+
//# sourceMappingURL=survey-items.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"survey-items.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Expression, SurveyItem } from "survey-engine/data_types";
|
|
2
|
+
import { ItemEditor } from "../survey-editor/item-editor";
|
|
3
|
+
export declare abstract class Group {
|
|
4
|
+
groupEditor: ItemEditor;
|
|
5
|
+
key: string;
|
|
6
|
+
private parentKey;
|
|
7
|
+
constructor(parentKey: string, groupKey: string, selectionMethod?: Expression);
|
|
8
|
+
abstract buildGroup(): void;
|
|
9
|
+
/**
|
|
10
|
+
* Check if this group is currently part of a path, by checking if the key attribute exists in the path of the group.
|
|
11
|
+
* @param partialKey Is this key segment included somewhere in the parent key of this item.
|
|
12
|
+
* @returns
|
|
13
|
+
*/
|
|
14
|
+
isPartOf(partialKey: string): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Use this method to retrieve the generated survey item
|
|
17
|
+
* @returns
|
|
18
|
+
*/
|
|
19
|
+
get(): SurveyItem;
|
|
20
|
+
addPageBreak(): void;
|
|
21
|
+
addItem(item: SurveyItem, pageBreakAfter?: boolean): void;
|
|
22
|
+
private checkDuplicateChildKeys;
|
|
23
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var logger_logger = require('../../logger/logger.js');
|
|
6
|
+
var surveys_surveyEditor_itemEditor = require('../../item-editor-59f51ecc.js');
|
|
7
|
+
var surveys_utils_simpleGenerators = require('../utils/simple-generators.js');
|
|
8
|
+
require('../survey-editor/component-editor.js');
|
|
9
|
+
require('../utils/randomKeyGenerator.js');
|
|
10
|
+
require('./item-properties.js');
|
|
11
|
+
|
|
12
|
+
class Group {
|
|
13
|
+
constructor(parentKey, groupKey, selectionMethod) {
|
|
14
|
+
this.parentKey = parentKey;
|
|
15
|
+
this.key = [this.parentKey, groupKey].join('.');
|
|
16
|
+
this.groupEditor = new surveys_surveyEditor_itemEditor.ItemEditor(undefined, {
|
|
17
|
+
itemKey: this.key,
|
|
18
|
+
isGroup: true
|
|
19
|
+
});
|
|
20
|
+
if (!selectionMethod) {
|
|
21
|
+
this.groupEditor.setSelectionMethod({ name: 'sequential' });
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
this.groupEditor.setSelectionMethod(selectionMethod);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Check if this group is currently part of a path, by checking if the key attribute exists in the path of the group.
|
|
29
|
+
* @param partialKey Is this key segment included somewhere in the parent key of this item.
|
|
30
|
+
* @returns
|
|
31
|
+
*/
|
|
32
|
+
isPartOf(partialKey) {
|
|
33
|
+
return this.parentKey.includes(partialKey);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Use this method to retrieve the generated survey item
|
|
37
|
+
* @returns
|
|
38
|
+
*/
|
|
39
|
+
get() {
|
|
40
|
+
this.buildGroup();
|
|
41
|
+
this.checkDuplicateChildKeys();
|
|
42
|
+
return this.groupEditor.getItem();
|
|
43
|
+
}
|
|
44
|
+
addPageBreak() {
|
|
45
|
+
this.groupEditor.addSurveyItem(surveys_utils_simpleGenerators.generatePageBreak(this.key));
|
|
46
|
+
}
|
|
47
|
+
addItem(item, pageBreakAfter) {
|
|
48
|
+
this.groupEditor.addSurveyItem(item);
|
|
49
|
+
if (pageBreakAfter) {
|
|
50
|
+
this.addPageBreak();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
checkDuplicateChildKeys() {
|
|
54
|
+
const group = this.groupEditor.getItem();
|
|
55
|
+
const keys = group.items.map(item => item.key);
|
|
56
|
+
const hasDuplicates = keys.some((key, index) => {
|
|
57
|
+
const isDuplicateKey = keys.indexOf(key) !== index;
|
|
58
|
+
if (isDuplicateKey) {
|
|
59
|
+
logger_logger.Logger.error('Duplicate key:');
|
|
60
|
+
logger_logger.Logger.criticalError(`${key} is used twice (at index ${keys.indexOf(key)} and at index ${index})`);
|
|
61
|
+
}
|
|
62
|
+
return isDuplicateKey;
|
|
63
|
+
});
|
|
64
|
+
if (hasDuplicates) {
|
|
65
|
+
logger_logger.Logger.error('\nSurvey contains duplicate keys.\nPlease check the lines above for more infos.\nProcess stopped prematurely.');
|
|
66
|
+
process.exit(1);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
exports.Group = Group;
|
|
72
|
+
//# sourceMappingURL=group.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"group.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var surveys_types_group = require('./group.js');
|
|
6
|
+
var surveys_types_item = require('./item.js');
|
|
7
|
+
var surveys_types_itemProperties = require('./item-properties.js');
|
|
8
|
+
var surveys_types_surveyDefinition = require('./survey-definition.js');
|
|
9
|
+
require('../../logger/logger.js');
|
|
10
|
+
require('../../item-editor-59f51ecc.js');
|
|
11
|
+
require('../survey-editor/component-editor.js');
|
|
12
|
+
require('../utils/randomKeyGenerator.js');
|
|
13
|
+
require('../utils/simple-generators.js');
|
|
14
|
+
require('../survey-editor/survey-editor.js');
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
exports.Group = surveys_types_group.Group;
|
|
19
|
+
exports.Item = surveys_types_item.Item;
|
|
20
|
+
exports.isDateDisplayComponentProp = surveys_types_itemProperties.isDateDisplayComponentProp;
|
|
21
|
+
exports.SurveyDefinition = surveys_types_surveyDefinition.SurveyDefinition;
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;"}
|