case-editor-tools 1.0.0-beta.3 → 1.0.0-beta.30
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/{build/constants → constants}/key-definitions.d.ts +1 -0
- package/{build/constants → constants}/key-definitions.js +3 -1
- package/{build/constants → constants}/key-definitions.js.map +1 -1
- package/exporter/index.d.ts +2 -0
- package/exporter/index.js +99 -0
- package/exporter/index.js.map +1 -0
- package/{build/expression-utils → expression-utils}/expressionGen.d.ts +1 -1
- package/{build/expression-utils → expression-utils}/expressionGen.js +0 -0
- package/{build/expression-utils → expression-utils}/expressionGen.js.map +0 -0
- package/{build/expression-utils → expression-utils}/studyEngineExpressions.d.ts +37 -7
- package/{build/expression-utils → expression-utils}/studyEngineExpressions.js +93 -4
- package/{build/expression-utils → expression-utils}/studyEngineExpressions.js.map +1 -1
- package/{build/index.d.ts → index.d.ts} +0 -0
- package/{build/index.js → index.js} +0 -0
- package/{build/index.js.map → index.js.map} +0 -0
- package/{build/item-editor-8fd24b61.js → item-editor-c6933791.js} +69 -51
- package/item-editor-c6933791.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/{build/logger → logger}/logger.d.ts +0 -0
- package/{build/logger → logger}/logger.js +0 -0
- package/{build/logger → logger}/logger.js.map +0 -0
- package/package.json +7 -8
- package/surveys/index.d.ts +3 -0
- package/surveys/index.js +28 -0
- package/surveys/index.js.map +1 -0
- 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/{build → surveys}/survey-editor/component-editor.d.ts +1 -1
- package/{build → surveys}/survey-editor/component-editor.js +0 -0
- package/{build → surveys}/survey-editor/component-editor.js.map +0 -0
- package/{build → surveys}/survey-editor/data-types.d.ts +1 -1
- package/{build → surveys}/survey-editor/data-types.js +0 -0
- package/{build → surveys}/survey-editor/data-types.js.map +0 -0
- package/{build → surveys}/survey-editor/item-editor.d.ts +1 -1
- package/{build → surveys}/survey-editor/item-editor.js +3 -2
- package/{build → surveys}/survey-editor/item-editor.js.map +1 -1
- package/{build → surveys}/survey-editor/survey-editor.d.ts +6 -1
- package/{build → surveys}/survey-editor/survey-editor.js +15 -8
- package/{build → surveys}/survey-editor/survey-editor.js.map +1 -1
- package/{build/expression-utils/surveyEngineExpressions.d.ts → surveys/survey-engine-expressions.d.ts} +9 -2
- package/{build/expression-utils/surveyEngineExpressions.js → surveys/survey-engine-expressions.js} +36 -4
- package/{build/expression-utils/surveyEngineExpressions.js.map → surveys/survey-engine-expressions.js.map} +1 -1
- package/surveys/survey-items.d.ts +66 -0
- package/surveys/survey-items.js +302 -0
- package/surveys/survey-items.js.map +1 -0
- package/{build → surveys}/types/group.d.ts +1 -1
- package/{build → surveys}/types/group.js +5 -5
- package/{build → surveys}/types/group.js.map +0 -0
- package/surveys/types/index.d.ts +4 -0
- package/surveys/types/index.js +20 -0
- package/surveys/types/index.js.map +1 -0
- package/surveys/types/item-properties.d.ts +189 -0
- package/surveys/types/item-properties.js +3 -0
- package/surveys/types/item-properties.js.map +1 -0
- package/{build → surveys}/types/item.d.ts +1 -1
- package/{build → surveys}/types/item.js +0 -0
- package/{build → surveys}/types/item.js.map +0 -0
- package/{build/types/surveyDefinition.d.ts → surveys/types/survey-definition.d.ts} +7 -3
- package/{build/types/surveyDefinition.js → surveys/types/survey-definition.js} +19 -11
- package/surveys/types/survey-definition.js.map +1 -0
- package/{build → surveys}/utils/componentGenerators.d.ts +2 -13
- package/surveys/utils/componentGenerators.js +58 -0
- package/{build → surveys}/utils/componentGenerators.js.map +1 -1
- package/surveys/utils/optionDefGenerators.d.ts +69 -0
- package/surveys/utils/optionDefGenerators.js +169 -0
- package/surveys/utils/optionDefGenerators.js.map +1 -0
- package/{build → surveys}/utils/randomKeyGenerator.d.ts +0 -0
- package/{build → surveys}/utils/randomKeyGenerator.js +0 -0
- package/{build → surveys}/utils/randomKeyGenerator.js.map +0 -0
- package/{build → surveys}/utils/simple-generators.d.ts +2 -2
- package/{build → surveys}/utils/simple-generators.js +5 -5
- package/{build → surveys}/utils/simple-generators.js.map +0 -0
- package/{build → surveys}/utils/simple-question-editor.d.ts +3 -3
- package/{build → surveys}/utils/simple-question-editor.js +7 -6
- package/{build → surveys}/utils/simple-question-editor.js.map +1 -1
- package/{build/types → types}/duration.d.ts +0 -0
- package/{build/types → types}/duration.js +0 -0
- package/{build/types → types}/duration.js.map +0 -0
- package/{build/types → types}/expression.d.ts +1 -1
- package/{build/types → types}/expression.js +0 -0
- package/{build/types → types}/expression.js.map +0 -0
- package/{build/types → types}/study.d.ts +2 -2
- package/{build/types → types}/study.js +0 -0
- package/{build/types → types}/study.js.map +0 -0
- package/{build/types → types}/studyRules.d.ts +1 -1
- package/{build/types → types}/studyRules.js +0 -0
- package/{build/types → types}/studyRules.js.map +0 -0
- package/.babelrc.js +0 -7
- package/.editorconfig +0 -13
- package/LICENSE +0 -202
- package/build/item-editor-8fd24b61.js.map +0 -1
- package/build/package.json +0 -26
- package/build/types/surveyDefinition.js.map +0 -1
- package/build/utils/componentGenerators.js +0 -92
- package/build/utils/question-type-generator.d.ts +0 -283
- package/build/utils/question-type-generator.js +0 -949
- package/build/utils/question-type-generator.js.map +0 -1
- package/rollup.config.js +0 -53
- package/src/constants/key-definitions.ts +0 -13
- package/src/expression-utils/expressionGen.ts +0 -28
- package/src/expression-utils/studyEngineExpressions.ts +0 -359
- package/src/expression-utils/surveyEngineExpressions.ts +0 -483
- package/src/index.ts +0 -1
- package/src/logger/logger.ts +0 -31
- package/src/survey-editor/component-editor.ts +0 -133
- package/src/survey-editor/data-types.ts +0 -18
- package/src/survey-editor/item-editor.ts +0 -528
- package/src/survey-editor/survey-editor.ts +0 -260
- package/src/types/duration.ts +0 -32
- package/src/types/expression.ts +0 -22
- package/src/types/group.ts +0 -73
- package/src/types/item.ts +0 -42
- package/src/types/study.ts +0 -17
- package/src/types/studyRules.ts +0 -39
- package/src/types/surveyDefinition.ts +0 -83
- package/src/utils/componentGenerators.ts +0 -122
- package/src/utils/question-type-generator.ts +0 -1516
- package/src/utils/randomKeyGenerator.ts +0 -11
- package/src/utils/simple-generators.ts +0 -106
- package/src/utils/simple-question-editor.ts +0 -52
- package/tsconfig.json +0 -100
|
@@ -1,1516 +0,0 @@
|
|
|
1
|
-
import { ItemGroupComponent, Expression, ComponentProperties, LocalizedObject, ItemComponent, SurveyItem, ExpressionArg, Validation } from "survey-engine/lib/data_types";
|
|
2
|
-
import { ComponentEditor } from "../survey-editor/component-editor";
|
|
3
|
-
import { ItemEditor } from "../survey-editor/item-editor";
|
|
4
|
-
import { ComponentGenerators } from "./componentGenerators";
|
|
5
|
-
import { Duration, durationObjectToSeconds } from "../types/duration";
|
|
6
|
-
import { datePickerKey, dropDownKey, inputKey, likertScaleGroupKey, multipleChoiceKey, numericInputKey, responseGroupKey, responsiveBipolarLikertArrayKey, responsiveSingleChoiceArrayKey, singleChoiceKey } from "../constants/key-definitions";
|
|
7
|
-
import { generateRandomKey } from "./randomKeyGenerator";
|
|
8
|
-
import { expWithArgs, generateHelpGroupComponent, generateLocStrings, generateTitleComponent } from "./simple-generators";
|
|
9
|
-
import { SimpleQuestionEditor } from "./simple-question-editor";
|
|
10
|
-
import { SurveyEngine } from "../expression-utils/surveyEngineExpressions";
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export interface OptionDef {
|
|
14
|
-
key: string;
|
|
15
|
-
role: string;
|
|
16
|
-
content?: Map<string, string>;
|
|
17
|
-
items?: Array<StyledTextComponentProp>;
|
|
18
|
-
description?: Map<string, string>;
|
|
19
|
-
displayCondition?: Expression;
|
|
20
|
-
disabled?: Expression;
|
|
21
|
-
style?: Array<{ key: string, value: string }>;
|
|
22
|
-
optionProps?: ComponentProperties;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export interface StyledTextComponentProp {
|
|
26
|
-
content: Map<string, string>;
|
|
27
|
-
className?: string;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
interface GenericQuestionProps {
|
|
31
|
-
parentKey: string;
|
|
32
|
-
itemKey: string;
|
|
33
|
-
version?: number;
|
|
34
|
-
questionText: Map<string, string> | Array<StyledTextComponentProp>;
|
|
35
|
-
questionSubText?: Map<string, string>;
|
|
36
|
-
titleClassName?: string;
|
|
37
|
-
helpGroupContent?: Array<{
|
|
38
|
-
content: Map<string, string>,
|
|
39
|
-
style?: Array<{ key: string, value: string }>,
|
|
40
|
-
}>;
|
|
41
|
-
condition?: Expression;
|
|
42
|
-
topDisplayCompoments?: Array<ItemComponent>;
|
|
43
|
-
bottomDisplayCompoments?: Array<ItemComponent>;
|
|
44
|
-
isRequired?: boolean;
|
|
45
|
-
footnoteText?: Map<string, string>;
|
|
46
|
-
customValidations?: Array<Validation>;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
interface NumericInputQuestionProps extends GenericQuestionProps {
|
|
50
|
-
content: Map<string, string>;
|
|
51
|
-
contentBehindInput?: boolean;
|
|
52
|
-
componentProperties?: ComponentProperties;
|
|
53
|
-
inputMaxWidth?: string;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
interface OptionQuestionProps extends GenericQuestionProps {
|
|
57
|
-
responseOptions: Array<OptionDef>;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
interface LikertGroupQuestionProps extends GenericQuestionProps {
|
|
61
|
-
rows: Array<LikertGroupRow>,
|
|
62
|
-
scaleOptions: Array<{
|
|
63
|
-
key: string;
|
|
64
|
-
className?: string;
|
|
65
|
-
content: Map<string, string>;
|
|
66
|
-
}>,
|
|
67
|
-
stackOnSmallScreen?: boolean;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
type ResponsiveSingleChoiceArrayVariant = 'horizontal' | 'vertical' | 'table';
|
|
71
|
-
type ResponsiveBipolarLikertArrayVariant = 'withLabelRow' | 'vertical' | 'table';
|
|
72
|
-
|
|
73
|
-
interface ResponsiveSingleChoiceArrayProps {
|
|
74
|
-
scaleOptions: Array<{
|
|
75
|
-
key: string;
|
|
76
|
-
className?: string;
|
|
77
|
-
content: Map<string, string> | StyledTextComponentProp[];
|
|
78
|
-
}>,
|
|
79
|
-
rows: Array<{
|
|
80
|
-
key: string;
|
|
81
|
-
content: Map<string, string> | StyledTextComponentProp[];
|
|
82
|
-
horizontalModeProps?: {
|
|
83
|
-
labelPlacement?: 'none' | 'top' | 'bottom';
|
|
84
|
-
className?: string;
|
|
85
|
-
},
|
|
86
|
-
verticalModeProps?: {
|
|
87
|
-
className?: string;
|
|
88
|
-
}
|
|
89
|
-
tableModeProps?: {
|
|
90
|
-
className?: string;
|
|
91
|
-
}
|
|
92
|
-
}>,
|
|
93
|
-
defaultMode: ResponsiveSingleChoiceArrayVariant;
|
|
94
|
-
responsiveModes?: {
|
|
95
|
-
sm?: ResponsiveSingleChoiceArrayVariant;
|
|
96
|
-
md?: ResponsiveSingleChoiceArrayVariant;
|
|
97
|
-
lg?: ResponsiveSingleChoiceArrayVariant;
|
|
98
|
-
xl?: ResponsiveSingleChoiceArrayVariant;
|
|
99
|
-
xxl?: ResponsiveSingleChoiceArrayVariant;
|
|
100
|
-
},
|
|
101
|
-
rgClassName?: string;
|
|
102
|
-
tableModeProps?: {
|
|
103
|
-
className?: string;
|
|
104
|
-
layout?: "fixed";
|
|
105
|
-
firstColWidth?: string;
|
|
106
|
-
optionHeaderClassName?: string;
|
|
107
|
-
hideRowBorder?: boolean;
|
|
108
|
-
},
|
|
109
|
-
horizontalModeProps?: {
|
|
110
|
-
hideRowBorder?: boolean;
|
|
111
|
-
},
|
|
112
|
-
verticalModeProps?: {
|
|
113
|
-
hideRowBorder?: boolean;
|
|
114
|
-
useReverseOptionOrder?: boolean;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
interface ResponsiveBipolarLikertArrayProps {
|
|
119
|
-
scaleOptions: Array<{
|
|
120
|
-
key: string;
|
|
121
|
-
}>,
|
|
122
|
-
rows: Array<{
|
|
123
|
-
key: string;
|
|
124
|
-
startLabel: Map<string, string> | StyledTextComponentProp[];
|
|
125
|
-
endLabel: Map<string, string> | StyledTextComponentProp[];
|
|
126
|
-
withLabelRowModeProps?: {
|
|
127
|
-
className?: string;
|
|
128
|
-
},
|
|
129
|
-
verticalModeProps?: {
|
|
130
|
-
className?: string;
|
|
131
|
-
}
|
|
132
|
-
tableModeProps?: {
|
|
133
|
-
className?: string;
|
|
134
|
-
}
|
|
135
|
-
}>,
|
|
136
|
-
defaultMode: ResponsiveBipolarLikertArrayVariant;
|
|
137
|
-
responsiveModes?: {
|
|
138
|
-
sm?: ResponsiveBipolarLikertArrayVariant;
|
|
139
|
-
md?: ResponsiveBipolarLikertArrayVariant;
|
|
140
|
-
lg?: ResponsiveBipolarLikertArrayVariant;
|
|
141
|
-
xl?: ResponsiveBipolarLikertArrayVariant;
|
|
142
|
-
xxl?: ResponsiveBipolarLikertArrayVariant;
|
|
143
|
-
},
|
|
144
|
-
rgClassName?: string;
|
|
145
|
-
tableModeProps?: {
|
|
146
|
-
className?: string;
|
|
147
|
-
layout?: "fixed";
|
|
148
|
-
labelColWidth?: string;
|
|
149
|
-
hideRowBorder?: boolean;
|
|
150
|
-
},
|
|
151
|
-
withLabelRowModeProps?: {
|
|
152
|
-
hideRowBorder?: boolean;
|
|
153
|
-
maxLabelWidth?: string;
|
|
154
|
-
useBottomLabel?: boolean;
|
|
155
|
-
},
|
|
156
|
-
verticalModeProps?: {
|
|
157
|
-
hideRowBorder?: boolean;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
interface ResponsiveSingleChoiceArrayQuestionProps extends GenericQuestionProps, ResponsiveSingleChoiceArrayProps { }
|
|
162
|
-
|
|
163
|
-
interface ResponsiveBipolarLikertArrayQuestionProps extends GenericQuestionProps, ResponsiveBipolarLikertArrayProps { }
|
|
164
|
-
|
|
165
|
-
const generateNumericInputQuestion = (props: NumericInputQuestionProps): SurveyItem => {
|
|
166
|
-
const simpleEditor = new SimpleQuestionEditor(props.parentKey, props.itemKey, props.version ? props.version : 1);
|
|
167
|
-
|
|
168
|
-
// QUESTION TEXT
|
|
169
|
-
simpleEditor.setTitle(props.questionText, props.questionSubText, props.titleClassName);
|
|
170
|
-
|
|
171
|
-
if (props.condition) {
|
|
172
|
-
simpleEditor.setCondition(props.condition);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
if (props.helpGroupContent) {
|
|
176
|
-
simpleEditor.editor.setHelpGroupComponent(
|
|
177
|
-
generateHelpGroupComponent(props.helpGroupContent)
|
|
178
|
-
)
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
if (props.topDisplayCompoments) {
|
|
182
|
-
props.topDisplayCompoments.forEach(comp => simpleEditor.addDisplayComponent(comp))
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
const style: Array<{ key: string, value: string }> = [];
|
|
186
|
-
|
|
187
|
-
if (props.inputMaxWidth) {
|
|
188
|
-
style.push({
|
|
189
|
-
key: 'inputMaxWidth', value: props.inputMaxWidth,
|
|
190
|
-
})
|
|
191
|
-
}
|
|
192
|
-
if (props.contentBehindInput) {
|
|
193
|
-
style.push({ key: 'labelPlacement', value: 'after' });
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
const rg_inner: ItemComponent = {
|
|
198
|
-
key: numericInputKey,
|
|
199
|
-
role: 'numberInput',
|
|
200
|
-
properties: {
|
|
201
|
-
min: props.componentProperties?.min !== undefined ? (typeof (props.componentProperties.min) === 'number' ? { dtype: 'num', num: props.componentProperties.min } : props.componentProperties.min) : undefined,
|
|
202
|
-
max: props.componentProperties?.max !== undefined ? (typeof (props.componentProperties?.max) === 'number' ? { dtype: 'num', num: props.componentProperties.max } : props.componentProperties.max) : undefined,
|
|
203
|
-
stepSize: props.componentProperties?.stepSize ? (typeof (props.componentProperties.stepSize) === 'number' ? { dtype: 'num', num: props.componentProperties.stepSize } : props.componentProperties.stepSize) : undefined,
|
|
204
|
-
},
|
|
205
|
-
content: generateLocStrings(props.content),
|
|
206
|
-
style: style.length > 0 ? style : undefined,
|
|
207
|
-
};
|
|
208
|
-
simpleEditor.setResponseGroupWithContent(rg_inner);
|
|
209
|
-
|
|
210
|
-
if (props.bottomDisplayCompoments) {
|
|
211
|
-
props.bottomDisplayCompoments.forEach(comp => simpleEditor.addDisplayComponent(comp))
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
if (props.isRequired) {
|
|
215
|
-
simpleEditor.addHasResponseValidation();
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
if (props.customValidations) {
|
|
219
|
-
props.customValidations.forEach(v => simpleEditor.editor.addValidation(v));
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
if (props.footnoteText) {
|
|
223
|
-
simpleEditor.addDisplayComponent({
|
|
224
|
-
role: 'footnote', content: generateLocStrings(props.footnoteText), style: [
|
|
225
|
-
{ key: 'className', value: 'fs-small fst-italic text-center' }
|
|
226
|
-
]
|
|
227
|
-
})
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
return simpleEditor.getItem();
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
const generateSingleChoiceQuestion = (props: OptionQuestionProps): SurveyItem => {
|
|
234
|
-
const simpleEditor = new SimpleQuestionEditor(props.parentKey, props.itemKey, props.version ? props.version : 1);
|
|
235
|
-
|
|
236
|
-
// QUESTION TEXT
|
|
237
|
-
simpleEditor.setTitle(props.questionText, props.questionSubText, props.titleClassName);
|
|
238
|
-
|
|
239
|
-
if (props.condition) {
|
|
240
|
-
simpleEditor.setCondition(props.condition);
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
if (props.helpGroupContent) {
|
|
244
|
-
simpleEditor.editor.setHelpGroupComponent(
|
|
245
|
-
generateHelpGroupComponent(props.helpGroupContent)
|
|
246
|
-
)
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
if (props.topDisplayCompoments) {
|
|
250
|
-
props.topDisplayCompoments.forEach(comp => simpleEditor.addDisplayComponent(comp))
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
const rg_inner = initSingleChoiceGroup(singleChoiceKey, props.responseOptions);
|
|
254
|
-
simpleEditor.setResponseGroupWithContent(rg_inner);
|
|
255
|
-
|
|
256
|
-
if (props.bottomDisplayCompoments) {
|
|
257
|
-
props.bottomDisplayCompoments.forEach(comp => simpleEditor.addDisplayComponent(comp))
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
if (props.isRequired) {
|
|
261
|
-
simpleEditor.addHasResponseValidation();
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
if (props.customValidations) {
|
|
265
|
-
props.customValidations.forEach(v => simpleEditor.editor.addValidation(v));
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
if (props.footnoteText) {
|
|
269
|
-
simpleEditor.addDisplayComponent({
|
|
270
|
-
role: 'footnote', content: generateLocStrings(props.footnoteText), style: [
|
|
271
|
-
{ key: 'className', value: 'fs-small fst-italic text-center' }
|
|
272
|
-
]
|
|
273
|
-
})
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
return simpleEditor.getItem();
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
const generateDropDownQuestion = (props: OptionQuestionProps): SurveyItem => {
|
|
280
|
-
const simpleEditor = new SimpleQuestionEditor(props.parentKey, props.itemKey, props.version ? props.version : 1);
|
|
281
|
-
|
|
282
|
-
// QUESTION TEXT
|
|
283
|
-
simpleEditor.setTitle(props.questionText, props.questionSubText, props.titleClassName);
|
|
284
|
-
|
|
285
|
-
if (props.condition) {
|
|
286
|
-
simpleEditor.setCondition(props.condition);
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
if (props.helpGroupContent) {
|
|
290
|
-
simpleEditor.editor.setHelpGroupComponent(
|
|
291
|
-
generateHelpGroupComponent(props.helpGroupContent)
|
|
292
|
-
)
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
if (props.topDisplayCompoments) {
|
|
296
|
-
props.topDisplayCompoments.forEach(comp => simpleEditor.addDisplayComponent(comp))
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
const rg_inner = initDropdownGroup(dropDownKey, props.responseOptions);
|
|
300
|
-
simpleEditor.setResponseGroupWithContent(rg_inner);
|
|
301
|
-
|
|
302
|
-
if (props.bottomDisplayCompoments) {
|
|
303
|
-
props.bottomDisplayCompoments.forEach(comp => simpleEditor.addDisplayComponent(comp))
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
if (props.isRequired) {
|
|
307
|
-
simpleEditor.addHasResponseValidation();
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
if (props.footnoteText) {
|
|
311
|
-
simpleEditor.addDisplayComponent({
|
|
312
|
-
role: 'footnote', content: generateLocStrings(props.footnoteText), style: [
|
|
313
|
-
{ key: 'className', value: 'fs-small fst-italic text-center' }
|
|
314
|
-
]
|
|
315
|
-
})
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
return simpleEditor.getItem();
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
const generateMultipleChoiceQuestion = (props: OptionQuestionProps): SurveyItem => {
|
|
323
|
-
const simpleEditor = new SimpleQuestionEditor(props.parentKey, props.itemKey, props.version ? props.version : 1);
|
|
324
|
-
|
|
325
|
-
// QUESTION TEXT
|
|
326
|
-
simpleEditor.setTitle(props.questionText, props.questionSubText, props.titleClassName);
|
|
327
|
-
|
|
328
|
-
if (props.condition) {
|
|
329
|
-
simpleEditor.setCondition(props.condition);
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
if (props.helpGroupContent) {
|
|
333
|
-
simpleEditor.editor.setHelpGroupComponent(
|
|
334
|
-
generateHelpGroupComponent(props.helpGroupContent)
|
|
335
|
-
)
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
if (props.topDisplayCompoments) {
|
|
339
|
-
props.topDisplayCompoments.forEach(comp => simpleEditor.addDisplayComponent(comp))
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
const rg_inner = initMultipleChoiceGroup(multipleChoiceKey, props.responseOptions);
|
|
343
|
-
simpleEditor.setResponseGroupWithContent(rg_inner);
|
|
344
|
-
|
|
345
|
-
if (props.bottomDisplayCompoments) {
|
|
346
|
-
props.bottomDisplayCompoments.forEach(comp => simpleEditor.addDisplayComponent(comp))
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
if (props.isRequired) {
|
|
350
|
-
simpleEditor.addHasResponseValidation();
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
if (props.customValidations) {
|
|
354
|
-
props.customValidations.forEach(v => simpleEditor.editor.addValidation(v));
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
if (props.footnoteText) {
|
|
358
|
-
simpleEditor.addDisplayComponent({
|
|
359
|
-
role: 'footnote', content: generateLocStrings(props.footnoteText), style: [
|
|
360
|
-
{ key: 'className', value: 'fs-small fst-italic text-center' }
|
|
361
|
-
]
|
|
362
|
-
})
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
return simpleEditor.getItem();
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
const generateSimpleLikertGroupQuestion = (props: LikertGroupQuestionProps): SurveyItem => {
|
|
369
|
-
const simpleEditor = new SimpleQuestionEditor(props.parentKey, props.itemKey, props.version ? props.version : 1);
|
|
370
|
-
|
|
371
|
-
// QUESTION TEXT
|
|
372
|
-
simpleEditor.setTitle(props.questionText, props.questionSubText, props.titleClassName);
|
|
373
|
-
|
|
374
|
-
if (props.condition) {
|
|
375
|
-
simpleEditor.setCondition(props.condition);
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
if (props.helpGroupContent) {
|
|
379
|
-
simpleEditor.editor.setHelpGroupComponent(
|
|
380
|
-
generateHelpGroupComponent(props.helpGroupContent)
|
|
381
|
-
)
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
if (props.topDisplayCompoments) {
|
|
385
|
-
props.topDisplayCompoments.forEach(comp => simpleEditor.addDisplayComponent(comp))
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
const rg_inner = initLikertScaleGroup(
|
|
389
|
-
likertScaleGroupKey,
|
|
390
|
-
props.rows,
|
|
391
|
-
props.scaleOptions,
|
|
392
|
-
props.stackOnSmallScreen,
|
|
393
|
-
);
|
|
394
|
-
simpleEditor.setResponseGroupWithContent(rg_inner);
|
|
395
|
-
|
|
396
|
-
if (props.bottomDisplayCompoments) {
|
|
397
|
-
props.bottomDisplayCompoments.forEach(comp => simpleEditor.addDisplayComponent(comp))
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
if (props.isRequired) {
|
|
401
|
-
simpleEditor.editor.addValidation({
|
|
402
|
-
key: 'r',
|
|
403
|
-
type: 'hard',
|
|
404
|
-
rule: expWithArgs('and',
|
|
405
|
-
...props.rows.map(r => expWithArgs(
|
|
406
|
-
'responseHasKeysAny',
|
|
407
|
-
[props.parentKey, props.itemKey].join('.'),
|
|
408
|
-
[responseGroupKey, likertScaleGroupKey, r.key].join('.'),
|
|
409
|
-
...props.scaleOptions.map(o => o.key)
|
|
410
|
-
))
|
|
411
|
-
)
|
|
412
|
-
})
|
|
413
|
-
simpleEditor.addHasResponseValidation();
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
if (props.footnoteText) {
|
|
417
|
-
simpleEditor.addDisplayComponent({
|
|
418
|
-
role: 'footnote', content: generateLocStrings(props.footnoteText), style: [
|
|
419
|
-
{ key: 'className', value: 'fs-small fst-italic text-center' }
|
|
420
|
-
]
|
|
421
|
-
})
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
return simpleEditor.getItem();
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
const generateResponsiveSingleChoiceArrayQuestion = (props: ResponsiveSingleChoiceArrayQuestionProps): SurveyItem => {
|
|
428
|
-
const simpleEditor = new SimpleQuestionEditor(props.parentKey, props.itemKey, props.version ? props.version : 1);
|
|
429
|
-
|
|
430
|
-
// QUESTION TEXT
|
|
431
|
-
simpleEditor.setTitle(props.questionText, props.questionSubText, props.titleClassName);
|
|
432
|
-
|
|
433
|
-
if (props.condition) {
|
|
434
|
-
simpleEditor.setCondition(props.condition);
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
if (props.helpGroupContent) {
|
|
438
|
-
simpleEditor.editor.setHelpGroupComponent(
|
|
439
|
-
generateHelpGroupComponent(props.helpGroupContent)
|
|
440
|
-
)
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
if (props.topDisplayCompoments) {
|
|
444
|
-
props.topDisplayCompoments.forEach(comp => simpleEditor.addDisplayComponent(comp))
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
const rg_inner = initResponsiveSingleChoiceArray(
|
|
448
|
-
responsiveSingleChoiceArrayKey,
|
|
449
|
-
{
|
|
450
|
-
...props,
|
|
451
|
-
},
|
|
452
|
-
);
|
|
453
|
-
simpleEditor.setResponseGroupWithContent(rg_inner);
|
|
454
|
-
|
|
455
|
-
if (props.bottomDisplayCompoments) {
|
|
456
|
-
props.bottomDisplayCompoments.forEach(comp => simpleEditor.addDisplayComponent(comp))
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
if (props.isRequired) {
|
|
460
|
-
simpleEditor.editor.addValidation({
|
|
461
|
-
key: 'r',
|
|
462
|
-
type: 'hard',
|
|
463
|
-
rule: expWithArgs('and',
|
|
464
|
-
...props.rows.map(r => expWithArgs(
|
|
465
|
-
'responseHasKeysAny',
|
|
466
|
-
[props.parentKey, props.itemKey].join('.'),
|
|
467
|
-
[responseGroupKey, responsiveSingleChoiceArrayKey, r.key].join('.'),
|
|
468
|
-
...props.scaleOptions.map(o => o.key)
|
|
469
|
-
))
|
|
470
|
-
)
|
|
471
|
-
})
|
|
472
|
-
simpleEditor.addHasResponseValidation();
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
if (props.footnoteText) {
|
|
476
|
-
simpleEditor.addDisplayComponent({
|
|
477
|
-
role: 'footnote', content: generateLocStrings(props.footnoteText), style: [
|
|
478
|
-
{ key: 'className', value: 'fs-small fst-italic text-center' }
|
|
479
|
-
]
|
|
480
|
-
})
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
return simpleEditor.getItem();
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
const generateResponsiveBipolarLikertArray = (props: ResponsiveBipolarLikertArrayQuestionProps): SurveyItem => {
|
|
487
|
-
const simpleEditor = new SimpleQuestionEditor(props.parentKey, props.itemKey, props.version ? props.version : 1);
|
|
488
|
-
|
|
489
|
-
// QUESTION TEXT
|
|
490
|
-
simpleEditor.setTitle(props.questionText, props.questionSubText, props.titleClassName);
|
|
491
|
-
|
|
492
|
-
if (props.condition) {
|
|
493
|
-
simpleEditor.setCondition(props.condition);
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
if (props.helpGroupContent) {
|
|
497
|
-
simpleEditor.editor.setHelpGroupComponent(
|
|
498
|
-
generateHelpGroupComponent(props.helpGroupContent)
|
|
499
|
-
)
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
if (props.topDisplayCompoments) {
|
|
503
|
-
props.topDisplayCompoments.forEach(comp => simpleEditor.addDisplayComponent(comp))
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
const rg_inner = initResponsiveBipolarLikertArray(
|
|
507
|
-
responsiveBipolarLikertArrayKey,
|
|
508
|
-
{
|
|
509
|
-
...props,
|
|
510
|
-
},
|
|
511
|
-
);
|
|
512
|
-
simpleEditor.setResponseGroupWithContent(rg_inner);
|
|
513
|
-
|
|
514
|
-
if (props.bottomDisplayCompoments) {
|
|
515
|
-
props.bottomDisplayCompoments.forEach(comp => simpleEditor.addDisplayComponent(comp))
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
if (props.isRequired) {
|
|
519
|
-
simpleEditor.editor.addValidation({
|
|
520
|
-
key: 'r',
|
|
521
|
-
type: 'hard',
|
|
522
|
-
rule: expWithArgs('and',
|
|
523
|
-
...props.rows.map(r => expWithArgs(
|
|
524
|
-
'responseHasKeysAny',
|
|
525
|
-
[props.parentKey, props.itemKey].join('.'),
|
|
526
|
-
[responseGroupKey, responsiveBipolarLikertArrayKey, r.key].join('.'),
|
|
527
|
-
...props.scaleOptions.map(o => o.key)
|
|
528
|
-
))
|
|
529
|
-
)
|
|
530
|
-
})
|
|
531
|
-
simpleEditor.addHasResponseValidation();
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
if (props.footnoteText) {
|
|
535
|
-
simpleEditor.addDisplayComponent({
|
|
536
|
-
role: 'footnote', content: generateLocStrings(props.footnoteText), style: [
|
|
537
|
-
{ key: 'className', value: 'fs-small fst-italic text-center' }
|
|
538
|
-
]
|
|
539
|
-
})
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
return simpleEditor.getItem();
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
interface NumericSliderProps extends GenericQuestionProps {
|
|
546
|
-
sliderLabel: Map<string, string>;
|
|
547
|
-
noResponseLabel: Map<string, string>;
|
|
548
|
-
min?: number | ExpressionArg;
|
|
549
|
-
max?: number | ExpressionArg;
|
|
550
|
-
stepSize?: number | ExpressionArg;
|
|
551
|
-
}
|
|
552
|
-
|
|
553
|
-
const generateNumericSliderQuestion = (props: NumericSliderProps): SurveyItem => {
|
|
554
|
-
const simpleEditor = new SimpleQuestionEditor(props.parentKey, props.itemKey, props.version ? props.version : 1);
|
|
555
|
-
|
|
556
|
-
// QUESTION TEXT
|
|
557
|
-
simpleEditor.setTitle(props.questionText, props.questionSubText, props.titleClassName);
|
|
558
|
-
|
|
559
|
-
if (props.condition) {
|
|
560
|
-
simpleEditor.setCondition(props.condition);
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
if (props.helpGroupContent) {
|
|
564
|
-
simpleEditor.editor.setHelpGroupComponent(
|
|
565
|
-
generateHelpGroupComponent(props.helpGroupContent)
|
|
566
|
-
)
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
if (props.topDisplayCompoments) {
|
|
570
|
-
props.topDisplayCompoments.forEach(comp => simpleEditor.addDisplayComponent(comp))
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
const rg_inner: ItemComponent = {
|
|
574
|
-
key: 'slider', role: 'sliderNumeric',
|
|
575
|
-
content: generateLocStrings(props.sliderLabel),
|
|
576
|
-
description: generateLocStrings(props.noResponseLabel),
|
|
577
|
-
properties: {
|
|
578
|
-
min: props.min !== undefined ? (typeof (props.min) === 'number' ? { dtype: 'num', num: props.min } : props.min) : undefined,
|
|
579
|
-
max: props.max !== undefined ? (typeof (props.max) === 'number' ? { dtype: 'num', num: props.max } : props.max) : undefined,
|
|
580
|
-
stepSize: props.stepSize ? (typeof (props.stepSize) === 'number' ? { dtype: 'num', num: props.stepSize } : props.stepSize) : undefined,
|
|
581
|
-
}
|
|
582
|
-
}
|
|
583
|
-
simpleEditor.setResponseGroupWithContent(rg_inner);
|
|
584
|
-
|
|
585
|
-
if (props.bottomDisplayCompoments) {
|
|
586
|
-
props.bottomDisplayCompoments.forEach(comp => simpleEditor.addDisplayComponent(comp))
|
|
587
|
-
}
|
|
588
|
-
|
|
589
|
-
if (props.isRequired) {
|
|
590
|
-
simpleEditor.addHasResponseValidation();
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
if (props.footnoteText) {
|
|
594
|
-
simpleEditor.addDisplayComponent(ComponentGenerators.footnote({ content: props.footnoteText }))
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
return simpleEditor.getItem();
|
|
598
|
-
}
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
interface DatePickerInput extends GenericQuestionProps {
|
|
603
|
-
dateInputMode: 'YMD' | 'YM' | 'Y';
|
|
604
|
-
inputLabelText?: Map<string, string>;
|
|
605
|
-
placeholderText?: Map<string, string>;
|
|
606
|
-
minRelativeDate?: {
|
|
607
|
-
reference?: number | Expression;
|
|
608
|
-
delta: Duration;
|
|
609
|
-
};
|
|
610
|
-
maxRelativeDate?: {
|
|
611
|
-
reference?: number | Expression;
|
|
612
|
-
delta: Duration;
|
|
613
|
-
};
|
|
614
|
-
}
|
|
615
|
-
|
|
616
|
-
interface MultiLineTextInput extends GenericQuestionProps {
|
|
617
|
-
inputLabelText?: Map<string, string>;
|
|
618
|
-
placeholderText?: Map<string, string>;
|
|
619
|
-
}
|
|
620
|
-
|
|
621
|
-
const generateDatePickerInput = (props: DatePickerInput): SurveyItem => {
|
|
622
|
-
const simpleEditor = new SimpleQuestionEditor(props.parentKey, props.itemKey, props.version ? props.version : 1);
|
|
623
|
-
|
|
624
|
-
// QUESTION TEXT
|
|
625
|
-
simpleEditor.setTitle(props.questionText, props.questionSubText, props.titleClassName);
|
|
626
|
-
|
|
627
|
-
if (props.condition) {
|
|
628
|
-
simpleEditor.setCondition(props.condition);
|
|
629
|
-
}
|
|
630
|
-
|
|
631
|
-
if (props.helpGroupContent) {
|
|
632
|
-
simpleEditor.editor.setHelpGroupComponent(
|
|
633
|
-
generateHelpGroupComponent(props.helpGroupContent)
|
|
634
|
-
)
|
|
635
|
-
}
|
|
636
|
-
|
|
637
|
-
if (props.topDisplayCompoments) {
|
|
638
|
-
props.topDisplayCompoments.forEach(comp => simpleEditor.addDisplayComponent(comp))
|
|
639
|
-
}
|
|
640
|
-
|
|
641
|
-
const rg_inner: ItemComponent = {
|
|
642
|
-
key: datePickerKey, role: 'dateInput',
|
|
643
|
-
properties: {
|
|
644
|
-
dateInputMode: { str: props.dateInputMode },
|
|
645
|
-
min: props.minRelativeDate ? {
|
|
646
|
-
dtype: 'exp', exp: SurveyEngine.timestampWithOffset(
|
|
647
|
-
props.minRelativeDate.delta,
|
|
648
|
-
props.minRelativeDate.reference
|
|
649
|
-
)
|
|
650
|
-
} : undefined,
|
|
651
|
-
max: props.maxRelativeDate ? {
|
|
652
|
-
dtype: 'exp', exp:
|
|
653
|
-
expWithArgs(
|
|
654
|
-
'timestampWithOffset',
|
|
655
|
-
durationObjectToSeconds(props.maxRelativeDate.delta),
|
|
656
|
-
props.maxRelativeDate.reference ? props.maxRelativeDate.reference : undefined
|
|
657
|
-
)
|
|
658
|
-
} : undefined,
|
|
659
|
-
},
|
|
660
|
-
content: props.inputLabelText ? generateLocStrings(props.inputLabelText) : undefined,
|
|
661
|
-
description: props.placeholderText ? generateLocStrings(props.placeholderText) : undefined,
|
|
662
|
-
};
|
|
663
|
-
simpleEditor.setResponseGroupWithContent(rg_inner);
|
|
664
|
-
|
|
665
|
-
if (props.bottomDisplayCompoments) {
|
|
666
|
-
props.bottomDisplayCompoments.forEach(comp => simpleEditor.addDisplayComponent(comp))
|
|
667
|
-
}
|
|
668
|
-
|
|
669
|
-
if (props.isRequired) {
|
|
670
|
-
simpleEditor.addHasResponseValidation();
|
|
671
|
-
}
|
|
672
|
-
|
|
673
|
-
if (props.footnoteText) {
|
|
674
|
-
simpleEditor.addDisplayComponent(ComponentGenerators.footnote({ content: props.footnoteText }))
|
|
675
|
-
}
|
|
676
|
-
|
|
677
|
-
return simpleEditor.getItem();
|
|
678
|
-
}
|
|
679
|
-
|
|
680
|
-
const generateMultilineInput = (props: MultiLineTextInput): SurveyItem => {
|
|
681
|
-
const simpleEditor = new SimpleQuestionEditor(props.parentKey, props.itemKey, props.version ? props.version : 1);
|
|
682
|
-
|
|
683
|
-
// QUESTION TEXT
|
|
684
|
-
simpleEditor.setTitle(props.questionText, props.questionSubText, props.titleClassName);
|
|
685
|
-
|
|
686
|
-
if (props.condition) {
|
|
687
|
-
simpleEditor.setCondition(props.condition);
|
|
688
|
-
}
|
|
689
|
-
|
|
690
|
-
if (props.helpGroupContent) {
|
|
691
|
-
simpleEditor.editor.setHelpGroupComponent(
|
|
692
|
-
generateHelpGroupComponent(props.helpGroupContent)
|
|
693
|
-
)
|
|
694
|
-
}
|
|
695
|
-
|
|
696
|
-
if (props.topDisplayCompoments) {
|
|
697
|
-
props.topDisplayCompoments.forEach(comp => simpleEditor.addDisplayComponent(comp))
|
|
698
|
-
}
|
|
699
|
-
|
|
700
|
-
const rg_inner: ItemComponent = {
|
|
701
|
-
key: inputKey, role: 'multilineTextInput',
|
|
702
|
-
content: props.inputLabelText ? generateLocStrings(props.inputLabelText) : undefined,
|
|
703
|
-
description: props.placeholderText ? generateLocStrings(props.placeholderText) : undefined,
|
|
704
|
-
};
|
|
705
|
-
simpleEditor.setResponseGroupWithContent(rg_inner);
|
|
706
|
-
|
|
707
|
-
if (props.bottomDisplayCompoments) {
|
|
708
|
-
props.bottomDisplayCompoments.forEach(comp => simpleEditor.addDisplayComponent(comp))
|
|
709
|
-
}
|
|
710
|
-
|
|
711
|
-
if (props.isRequired) {
|
|
712
|
-
simpleEditor.addHasResponseValidation();
|
|
713
|
-
}
|
|
714
|
-
|
|
715
|
-
if (props.footnoteText) {
|
|
716
|
-
simpleEditor.addDisplayComponent(ComponentGenerators.footnote({ content: props.footnoteText }))
|
|
717
|
-
}
|
|
718
|
-
|
|
719
|
-
return simpleEditor.getItem();
|
|
720
|
-
}
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
interface DisplayProps {
|
|
724
|
-
parentKey: string;
|
|
725
|
-
itemKey: string;
|
|
726
|
-
content: Array<ItemComponent>;
|
|
727
|
-
condition?: Expression;
|
|
728
|
-
}
|
|
729
|
-
|
|
730
|
-
const generateDisplay = (props: DisplayProps): SurveyItem => {
|
|
731
|
-
const simpleEditor = new SimpleQuestionEditor(props.parentKey, props.itemKey, 1);
|
|
732
|
-
props.content.forEach(item => simpleEditor.addDisplayComponent(item))
|
|
733
|
-
if (props.condition) {
|
|
734
|
-
simpleEditor.setCondition(props.condition);
|
|
735
|
-
}
|
|
736
|
-
return simpleEditor.getItem();
|
|
737
|
-
}
|
|
738
|
-
|
|
739
|
-
const generateSurveyEnd = (parentKey: string, content: Map<string, string>, condition?: Expression): SurveyItem => {
|
|
740
|
-
const defaultKey = 'surveyEnd'
|
|
741
|
-
const itemKey = [parentKey, defaultKey].join('.');
|
|
742
|
-
const editor = new ItemEditor(undefined, { itemKey: itemKey, type: 'surveyEnd', isGroup: false });
|
|
743
|
-
|
|
744
|
-
editor.setTitleComponent(
|
|
745
|
-
generateTitleComponent(content)
|
|
746
|
-
);
|
|
747
|
-
|
|
748
|
-
// CONDITION
|
|
749
|
-
editor.setCondition(condition);
|
|
750
|
-
|
|
751
|
-
return editor.getItem();
|
|
752
|
-
}
|
|
753
|
-
|
|
754
|
-
export const SurveyItemGenerators = {
|
|
755
|
-
singleChoice: generateSingleChoiceQuestion,
|
|
756
|
-
responsiveSingleChoiceArray: generateResponsiveSingleChoiceArrayQuestion,
|
|
757
|
-
responsiveBipolarLikertArray: generateResponsiveBipolarLikertArray,
|
|
758
|
-
multipleChoice: generateMultipleChoiceQuestion,
|
|
759
|
-
simpleLikertGroup: generateSimpleLikertGroupQuestion,
|
|
760
|
-
dateInput: generateDatePickerInput,
|
|
761
|
-
multilineTextInput: generateMultilineInput,
|
|
762
|
-
dropDown: generateDropDownQuestion,
|
|
763
|
-
numericSlider: generateNumericSliderQuestion,
|
|
764
|
-
numericInput: generateNumericInputQuestion,
|
|
765
|
-
display: generateDisplay,
|
|
766
|
-
surveyEnd: generateSurveyEnd,
|
|
767
|
-
}
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
export const initSingleChoiceGroup = (
|
|
771
|
-
key: string,
|
|
772
|
-
optionItems: OptionDef[],
|
|
773
|
-
order?: Expression
|
|
774
|
-
): ItemGroupComponent => {
|
|
775
|
-
// init group
|
|
776
|
-
return initResponseGroup('singleChoiceGroup', key, optionItems, order);
|
|
777
|
-
}
|
|
778
|
-
|
|
779
|
-
export const initMultipleChoiceGroup = (
|
|
780
|
-
key: string,
|
|
781
|
-
optionItems: OptionDef[],
|
|
782
|
-
order?: Expression
|
|
783
|
-
): ItemGroupComponent => {
|
|
784
|
-
// init group
|
|
785
|
-
return initResponseGroup('multipleChoiceGroup', key, optionItems, order);
|
|
786
|
-
}
|
|
787
|
-
|
|
788
|
-
export const initDropdownGroup = (
|
|
789
|
-
key: string,
|
|
790
|
-
optionItems: OptionDef[],
|
|
791
|
-
order?: Expression,
|
|
792
|
-
groupDisabled?: Expression,
|
|
793
|
-
groupContent?: Map<string, string>,
|
|
794
|
-
groupDescription?: Map<string, string>,
|
|
795
|
-
): ItemGroupComponent => {
|
|
796
|
-
// init group
|
|
797
|
-
return initResponseGroup('dropDownGroup', key, optionItems, order, groupDisabled,
|
|
798
|
-
groupContent ? generateLocStrings(groupContent) : undefined,
|
|
799
|
-
groupDescription ? generateLocStrings(groupDescription) : undefined,
|
|
800
|
-
);
|
|
801
|
-
}
|
|
802
|
-
|
|
803
|
-
export const initSliderCategoricalGroup = (
|
|
804
|
-
key: string,
|
|
805
|
-
optionItems: OptionDef[],
|
|
806
|
-
order?: Expression,
|
|
807
|
-
groupDisabled?: Expression,
|
|
808
|
-
): ItemGroupComponent => {
|
|
809
|
-
// init group
|
|
810
|
-
return initResponseGroup('sliderCategorical', key, optionItems, order, groupDisabled);
|
|
811
|
-
}
|
|
812
|
-
|
|
813
|
-
const initResponseGroup = (
|
|
814
|
-
type: 'singleChoiceGroup' | 'multipleChoiceGroup' | 'dropDownGroup' | 'sliderCategorical',
|
|
815
|
-
key: string,
|
|
816
|
-
optionItems: OptionDef[],
|
|
817
|
-
order?: Expression,
|
|
818
|
-
groupDisabled?: Expression,
|
|
819
|
-
groupContent?: LocalizedObject[],
|
|
820
|
-
groupDescription?: LocalizedObject[],
|
|
821
|
-
): ItemGroupComponent => {
|
|
822
|
-
// init group
|
|
823
|
-
const groupEdit = new ComponentEditor(undefined, {
|
|
824
|
-
key: key,
|
|
825
|
-
isGroup: true,
|
|
826
|
-
role: type,
|
|
827
|
-
});
|
|
828
|
-
|
|
829
|
-
groupEdit.setOrder(
|
|
830
|
-
order ? order : {
|
|
831
|
-
name: 'sequential'
|
|
832
|
-
}
|
|
833
|
-
);
|
|
834
|
-
if (groupDisabled) {
|
|
835
|
-
groupEdit.setDisabled(groupDisabled);
|
|
836
|
-
}
|
|
837
|
-
if (groupContent) {
|
|
838
|
-
groupEdit.setContent(groupContent);
|
|
839
|
-
}
|
|
840
|
-
if (groupDescription) {
|
|
841
|
-
groupEdit.setDescription(groupDescription);
|
|
842
|
-
}
|
|
843
|
-
|
|
844
|
-
// add option items
|
|
845
|
-
optionItems.forEach(optionDef => {
|
|
846
|
-
const optEditor = new ComponentEditor(undefined, {
|
|
847
|
-
key: optionDef.key,
|
|
848
|
-
role: optionDef.role,
|
|
849
|
-
});
|
|
850
|
-
if (optionDef.content) {
|
|
851
|
-
optEditor.setContent(generateLocStrings(optionDef.content));
|
|
852
|
-
}
|
|
853
|
-
if (optionDef.description) {
|
|
854
|
-
optEditor.setDescription(generateLocStrings(optionDef.description));
|
|
855
|
-
}
|
|
856
|
-
if (optionDef.items) {
|
|
857
|
-
optionDef.items.forEach((item, index) => {
|
|
858
|
-
optEditor.addItemComponent({
|
|
859
|
-
key: index.toFixed(),
|
|
860
|
-
role: 'text',
|
|
861
|
-
content: generateLocStrings(item.content),
|
|
862
|
-
style: item.className ? [{ key: 'className', value: item.className }] : undefined
|
|
863
|
-
});
|
|
864
|
-
})
|
|
865
|
-
}
|
|
866
|
-
|
|
867
|
-
switch (optionDef.role) {
|
|
868
|
-
case 'date':
|
|
869
|
-
optEditor.setDType('date');
|
|
870
|
-
break;
|
|
871
|
-
case 'numberInput':
|
|
872
|
-
optEditor.setDType('number');
|
|
873
|
-
break;
|
|
874
|
-
}
|
|
875
|
-
|
|
876
|
-
if (optionDef.displayCondition) {
|
|
877
|
-
optEditor.setDisplayCondition(optionDef.displayCondition);
|
|
878
|
-
}
|
|
879
|
-
if (optionDef.disabled) {
|
|
880
|
-
optEditor.setDisabled(optionDef.disabled);
|
|
881
|
-
}
|
|
882
|
-
if (optionDef.style) {
|
|
883
|
-
optEditor.setStyles(optionDef.style);
|
|
884
|
-
}
|
|
885
|
-
if (optionDef.optionProps) {
|
|
886
|
-
if (typeof (optionDef.optionProps.min) === 'number') {
|
|
887
|
-
optionDef.optionProps.min = { dtype: 'num', num: optionDef.optionProps.min }
|
|
888
|
-
}
|
|
889
|
-
if (typeof (optionDef.optionProps.max) === 'number') {
|
|
890
|
-
optionDef.optionProps.max = { dtype: 'num', num: optionDef.optionProps.max }
|
|
891
|
-
}
|
|
892
|
-
if (typeof (optionDef.optionProps.stepSize) === 'number') {
|
|
893
|
-
optionDef.optionProps.stepSize = { dtype: 'num', num: optionDef.optionProps.stepSize }
|
|
894
|
-
}
|
|
895
|
-
optEditor.setProperties(optionDef.optionProps);
|
|
896
|
-
}
|
|
897
|
-
groupEdit.addItemComponent(optEditor.getComponent());
|
|
898
|
-
});
|
|
899
|
-
return groupEdit.getComponent() as ItemGroupComponent;
|
|
900
|
-
}
|
|
901
|
-
|
|
902
|
-
interface HeaderRow {
|
|
903
|
-
role: 'headerRow',
|
|
904
|
-
key: string;
|
|
905
|
-
displayCondition?: Expression;
|
|
906
|
-
disabled?: Expression;
|
|
907
|
-
cells: Array<{
|
|
908
|
-
role: 'text',
|
|
909
|
-
key: string,
|
|
910
|
-
content?: Map<string, string>,
|
|
911
|
-
description?: Map<string, string>,
|
|
912
|
-
}>
|
|
913
|
-
}
|
|
914
|
-
interface RadioRow {
|
|
915
|
-
role: 'radioRow',
|
|
916
|
-
key: string;
|
|
917
|
-
displayCondition?: Expression;
|
|
918
|
-
disabled?: Expression;
|
|
919
|
-
cells: Array<{
|
|
920
|
-
role: 'label' | 'option',
|
|
921
|
-
key: string,
|
|
922
|
-
content?: Map<string, string>,
|
|
923
|
-
description?: Map<string, string>,
|
|
924
|
-
}>
|
|
925
|
-
|
|
926
|
-
}
|
|
927
|
-
|
|
928
|
-
export interface ResponseRowCell {
|
|
929
|
-
role: 'label' | 'check' | 'input' | 'numberInput' | 'dropDownGroup',
|
|
930
|
-
key: string,
|
|
931
|
-
content?: Map<string, string>,
|
|
932
|
-
description?: Map<string, string>,
|
|
933
|
-
properties?: ComponentProperties;
|
|
934
|
-
// for dropdown group
|
|
935
|
-
items?: Array<{
|
|
936
|
-
role: 'option',
|
|
937
|
-
key: string,
|
|
938
|
-
content?: Map<string, string>,
|
|
939
|
-
disabled?: Expression;
|
|
940
|
-
displayCondition?: Expression;
|
|
941
|
-
}>
|
|
942
|
-
}
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
interface ResponseRow {
|
|
946
|
-
role: 'responseRow',
|
|
947
|
-
key: string;
|
|
948
|
-
displayCondition?: Expression;
|
|
949
|
-
disabled?: Expression;
|
|
950
|
-
cells: Array<ResponseRowCell>
|
|
951
|
-
}
|
|
952
|
-
|
|
953
|
-
type MatrixRow = HeaderRow | RadioRow | ResponseRow;
|
|
954
|
-
|
|
955
|
-
export const initMatrixQuestion = (
|
|
956
|
-
key: string,
|
|
957
|
-
rows: Array<MatrixRow>,
|
|
958
|
-
order?: Expression,
|
|
959
|
-
): ItemGroupComponent => {
|
|
960
|
-
// init group
|
|
961
|
-
const groupEdit = new ComponentEditor(undefined, {
|
|
962
|
-
key: key,
|
|
963
|
-
isGroup: true,
|
|
964
|
-
role: 'matrix',
|
|
965
|
-
});
|
|
966
|
-
|
|
967
|
-
groupEdit.setOrder(
|
|
968
|
-
order ? order : {
|
|
969
|
-
name: 'sequential'
|
|
970
|
-
}
|
|
971
|
-
);
|
|
972
|
-
|
|
973
|
-
// init rows
|
|
974
|
-
rows.forEach(rowDef => {
|
|
975
|
-
const rowEditor = new ComponentEditor(undefined, {
|
|
976
|
-
key: rowDef.key,
|
|
977
|
-
role: rowDef.role,
|
|
978
|
-
});
|
|
979
|
-
|
|
980
|
-
if (rowDef.displayCondition) {
|
|
981
|
-
rowEditor.setDisplayCondition(rowDef.displayCondition);
|
|
982
|
-
}
|
|
983
|
-
if (rowDef.disabled) {
|
|
984
|
-
rowEditor.setDisabled(rowDef.disabled);
|
|
985
|
-
}
|
|
986
|
-
|
|
987
|
-
switch (rowDef.role) {
|
|
988
|
-
case 'headerRow':
|
|
989
|
-
rowDef.cells.forEach(cell => {
|
|
990
|
-
const cellEditor = new ComponentEditor(undefined, {
|
|
991
|
-
key: cell.key,
|
|
992
|
-
role: cell.role,
|
|
993
|
-
});
|
|
994
|
-
if (cell.content) {
|
|
995
|
-
cellEditor.setContent(generateLocStrings(cell.content));
|
|
996
|
-
}
|
|
997
|
-
|
|
998
|
-
if (cell.description) {
|
|
999
|
-
cellEditor.setDescription(generateLocStrings(cell.description));
|
|
1000
|
-
}
|
|
1001
|
-
rowEditor.addItemComponent(cellEditor.getComponent());
|
|
1002
|
-
});
|
|
1003
|
-
break;
|
|
1004
|
-
case 'radioRow':
|
|
1005
|
-
rowDef.cells.forEach(cell => {
|
|
1006
|
-
const cellEditor = new ComponentEditor(undefined, {
|
|
1007
|
-
key: cell.key,
|
|
1008
|
-
role: cell.role,
|
|
1009
|
-
});
|
|
1010
|
-
if (cell.content) {
|
|
1011
|
-
cellEditor.setContent(generateLocStrings(cell.content));
|
|
1012
|
-
}
|
|
1013
|
-
|
|
1014
|
-
if (cell.description) {
|
|
1015
|
-
cellEditor.setDescription(generateLocStrings(cell.description));
|
|
1016
|
-
}
|
|
1017
|
-
rowEditor.addItemComponent(cellEditor.getComponent());
|
|
1018
|
-
});
|
|
1019
|
-
break;
|
|
1020
|
-
case 'responseRow':
|
|
1021
|
-
rowDef.cells.forEach(cell => {
|
|
1022
|
-
const cellEditor = new ComponentEditor(undefined, {
|
|
1023
|
-
key: cell.key,
|
|
1024
|
-
role: cell.role,
|
|
1025
|
-
});
|
|
1026
|
-
if (cell.content) {
|
|
1027
|
-
cellEditor.setContent(generateLocStrings(cell.content));
|
|
1028
|
-
}
|
|
1029
|
-
if (cell.description) {
|
|
1030
|
-
cellEditor.setDescription(generateLocStrings(cell.description));
|
|
1031
|
-
}
|
|
1032
|
-
cellEditor.setProperties(cell.properties);
|
|
1033
|
-
if (cell.items) {
|
|
1034
|
-
cell.items.forEach(opt => {
|
|
1035
|
-
const cellOptionEditor = new ComponentEditor(undefined, {
|
|
1036
|
-
key: opt.key,
|
|
1037
|
-
role: opt.role,
|
|
1038
|
-
});
|
|
1039
|
-
if (opt.content) {
|
|
1040
|
-
cellOptionEditor.setContent(generateLocStrings(opt.content));
|
|
1041
|
-
}
|
|
1042
|
-
cellOptionEditor.setDisabled(opt.disabled);
|
|
1043
|
-
cellOptionEditor.setDisplayCondition(opt.displayCondition);
|
|
1044
|
-
cellEditor.addItemComponent(cellOptionEditor.getComponent());
|
|
1045
|
-
})
|
|
1046
|
-
}
|
|
1047
|
-
rowEditor.addItemComponent(cellEditor.getComponent());
|
|
1048
|
-
});
|
|
1049
|
-
break;
|
|
1050
|
-
}
|
|
1051
|
-
|
|
1052
|
-
groupEdit.addItemComponent(rowEditor.getComponent());
|
|
1053
|
-
});
|
|
1054
|
-
|
|
1055
|
-
return groupEdit.getComponent() as ItemGroupComponent;
|
|
1056
|
-
}
|
|
1057
|
-
|
|
1058
|
-
interface EQ5DHealthSliderProps {
|
|
1059
|
-
role: 'eq5d-health-indicator',
|
|
1060
|
-
key: string;
|
|
1061
|
-
displayCondition?: Expression;
|
|
1062
|
-
disabled?: Expression;
|
|
1063
|
-
instructionText: Map<string, string>,
|
|
1064
|
-
valueBoxText: Map<string, string>,
|
|
1065
|
-
maxHealthText: Map<string, string>,
|
|
1066
|
-
minHealthText: Map<string, string>,
|
|
1067
|
-
}
|
|
1068
|
-
|
|
1069
|
-
export const initEQ5DHealthIndicatorQuestion = (
|
|
1070
|
-
props: EQ5DHealthSliderProps
|
|
1071
|
-
): ItemGroupComponent => {
|
|
1072
|
-
// init group
|
|
1073
|
-
const groupEdit = new ComponentEditor(undefined, {
|
|
1074
|
-
key: props.key,
|
|
1075
|
-
isGroup: true,
|
|
1076
|
-
role: props.role,
|
|
1077
|
-
});
|
|
1078
|
-
|
|
1079
|
-
const instructionTextEditor = new ComponentEditor(undefined, { role: 'instruction', });
|
|
1080
|
-
instructionTextEditor.setContent(generateLocStrings(props.instructionText))
|
|
1081
|
-
groupEdit.addItemComponent(instructionTextEditor.getComponent());
|
|
1082
|
-
|
|
1083
|
-
const valueBoxTextEditor = new ComponentEditor(undefined, { role: 'valuebox', });
|
|
1084
|
-
valueBoxTextEditor.setContent(generateLocStrings(props.valueBoxText))
|
|
1085
|
-
groupEdit.addItemComponent(valueBoxTextEditor.getComponent());
|
|
1086
|
-
|
|
1087
|
-
const minHealthTextEditor = new ComponentEditor(undefined, { role: 'mintext', });
|
|
1088
|
-
minHealthTextEditor.setContent(generateLocStrings(props.minHealthText))
|
|
1089
|
-
groupEdit.addItemComponent(minHealthTextEditor.getComponent());
|
|
1090
|
-
|
|
1091
|
-
const maxHealthTextEditor = new ComponentEditor(undefined, { role: 'maxtext', });
|
|
1092
|
-
maxHealthTextEditor.setContent(generateLocStrings(props.maxHealthText))
|
|
1093
|
-
groupEdit.addItemComponent(maxHealthTextEditor.getComponent());
|
|
1094
|
-
|
|
1095
|
-
return groupEdit.getComponent() as ItemGroupComponent;
|
|
1096
|
-
}
|
|
1097
|
-
|
|
1098
|
-
interface LikertGroupRow {
|
|
1099
|
-
key: string;
|
|
1100
|
-
content: Map<string, string>;
|
|
1101
|
-
descriptions?: ItemComponent[];
|
|
1102
|
-
hideTopBorder?: boolean;
|
|
1103
|
-
hideLabels?: boolean;
|
|
1104
|
-
optionDisabled?: Array<{
|
|
1105
|
-
optionKey: string;
|
|
1106
|
-
exp: Expression;
|
|
1107
|
-
}>;
|
|
1108
|
-
displayCondition?: Expression;
|
|
1109
|
-
}
|
|
1110
|
-
|
|
1111
|
-
export const initLikertScaleGroup = (
|
|
1112
|
-
key: string,
|
|
1113
|
-
rows: Array<LikertGroupRow>,
|
|
1114
|
-
scaleOptions: Array<{
|
|
1115
|
-
key: string;
|
|
1116
|
-
className?: string;
|
|
1117
|
-
content: Map<string, string>;
|
|
1118
|
-
}>,
|
|
1119
|
-
stackOnSmallScreen?: boolean,
|
|
1120
|
-
displayCondition?: Expression,
|
|
1121
|
-
): ItemGroupComponent => {
|
|
1122
|
-
const groupEdit = new ComponentEditor(undefined, {
|
|
1123
|
-
key: key,
|
|
1124
|
-
isGroup: true,
|
|
1125
|
-
role: 'likertGroup',
|
|
1126
|
-
});
|
|
1127
|
-
|
|
1128
|
-
if (displayCondition) {
|
|
1129
|
-
groupEdit.setDisplayCondition(displayCondition);
|
|
1130
|
-
}
|
|
1131
|
-
|
|
1132
|
-
rows.forEach((row, index) => {
|
|
1133
|
-
groupEdit.addItemComponent({
|
|
1134
|
-
key: generateRandomKey(4),
|
|
1135
|
-
role: 'text',
|
|
1136
|
-
style: [{
|
|
1137
|
-
key: 'className', value:
|
|
1138
|
-
'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')
|
|
1139
|
-
}, { key: 'variant', value: 'h6' }],
|
|
1140
|
-
content: generateLocStrings(row.content),
|
|
1141
|
-
});
|
|
1142
|
-
|
|
1143
|
-
if (row.descriptions) {
|
|
1144
|
-
row.descriptions.forEach(desc => {
|
|
1145
|
-
groupEdit.addItemComponent(desc);
|
|
1146
|
-
});
|
|
1147
|
-
}
|
|
1148
|
-
|
|
1149
|
-
const item = initLikertScaleItem(
|
|
1150
|
-
row.key,
|
|
1151
|
-
scaleOptions.map(option => {
|
|
1152
|
-
return {
|
|
1153
|
-
key: option.key,
|
|
1154
|
-
className: option.className,
|
|
1155
|
-
content: row.hideLabels ? undefined : option.content,
|
|
1156
|
-
disabled: row.optionDisabled?.find(cond => cond.optionKey === option.key)?.exp,
|
|
1157
|
-
}
|
|
1158
|
-
}),
|
|
1159
|
-
stackOnSmallScreen,
|
|
1160
|
-
row.displayCondition
|
|
1161
|
-
)
|
|
1162
|
-
groupEdit.addItemComponent(item);
|
|
1163
|
-
});
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
return groupEdit.getComponent() as ItemGroupComponent;
|
|
1168
|
-
}
|
|
1169
|
-
|
|
1170
|
-
export const initResponsiveSingleChoiceArray = (
|
|
1171
|
-
rgKey: string,
|
|
1172
|
-
props: ResponsiveSingleChoiceArrayProps,
|
|
1173
|
-
displayCondition?: Expression,
|
|
1174
|
-
): ItemGroupComponent => {
|
|
1175
|
-
const groupEdit = new ComponentEditor(undefined, {
|
|
1176
|
-
key: rgKey,
|
|
1177
|
-
isGroup: true,
|
|
1178
|
-
role: 'responsiveSingleChoiceArray',
|
|
1179
|
-
});
|
|
1180
|
-
|
|
1181
|
-
if (displayCondition) {
|
|
1182
|
-
groupEdit.setDisplayCondition(displayCondition);
|
|
1183
|
-
}
|
|
1184
|
-
|
|
1185
|
-
const style: Array<{ key: string, value: string }> = [
|
|
1186
|
-
{ key: 'defaultMode', value: props.defaultMode },
|
|
1187
|
-
];
|
|
1188
|
-
if (props.responsiveModes) {
|
|
1189
|
-
if (props.responsiveModes.sm) {
|
|
1190
|
-
style.push({ key: 'smMode', value: props.responsiveModes.sm });
|
|
1191
|
-
}
|
|
1192
|
-
if (props.responsiveModes.md) {
|
|
1193
|
-
style.push({ key: 'mdMode', value: props.responsiveModes.md });
|
|
1194
|
-
}
|
|
1195
|
-
if (props.responsiveModes.lg) {
|
|
1196
|
-
style.push({ key: 'lgMode', value: props.responsiveModes.lg });
|
|
1197
|
-
}
|
|
1198
|
-
if (props.responsiveModes.xl) {
|
|
1199
|
-
style.push({ key: 'xlMode', value: props.responsiveModes.xl });
|
|
1200
|
-
}
|
|
1201
|
-
if (props.responsiveModes.xxl) {
|
|
1202
|
-
style.push({ key: 'xxlMode', value: props.responsiveModes.xxl });
|
|
1203
|
-
}
|
|
1204
|
-
}
|
|
1205
|
-
if (props.rgClassName) {
|
|
1206
|
-
style.push({ key: 'className', value: props.rgClassName });
|
|
1207
|
-
}
|
|
1208
|
-
if (props.verticalModeProps) {
|
|
1209
|
-
if (props.verticalModeProps.useReverseOptionOrder) {
|
|
1210
|
-
style.push({ key: 'verticalModeReverseOrder', value: 'true' });
|
|
1211
|
-
}
|
|
1212
|
-
}
|
|
1213
|
-
if (props.tableModeProps) {
|
|
1214
|
-
style.push({ key: 'tableModeClassName', value: 'table-borderless mb-0 ' + props.tableModeProps.className });
|
|
1215
|
-
if (props.tableModeProps.layout) {
|
|
1216
|
-
style.push({ key: 'tableModeLayout', value: props.tableModeProps.layout });
|
|
1217
|
-
}
|
|
1218
|
-
if (props.tableModeProps.firstColWidth) {
|
|
1219
|
-
style.push({ key: 'tableModeFirstColWidth', value: props.tableModeProps.firstColWidth });
|
|
1220
|
-
}
|
|
1221
|
-
}
|
|
1222
|
-
groupEdit.setStyles(style);
|
|
1223
|
-
|
|
1224
|
-
const defaultBorderClass = 'border-bottom border-grey-2';
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
let tableModeOptionHeaderClassName: string | undefined = undefined;
|
|
1228
|
-
if (!props.tableModeProps?.hideRowBorder) {
|
|
1229
|
-
tableModeOptionHeaderClassName = defaultBorderClass;
|
|
1230
|
-
}
|
|
1231
|
-
if (props.tableModeProps?.optionHeaderClassName) {
|
|
1232
|
-
tableModeOptionHeaderClassName += ' ' + props.tableModeProps.optionHeaderClassName;
|
|
1233
|
-
}
|
|
1234
|
-
|
|
1235
|
-
const optionStyles: Array<{ key: string, value: string }> = [];
|
|
1236
|
-
if (tableModeOptionHeaderClassName) {
|
|
1237
|
-
optionStyles.push({ key: 'tableModeClassName', value: tableModeOptionHeaderClassName })
|
|
1238
|
-
}
|
|
1239
|
-
|
|
1240
|
-
groupEdit.addItemComponent({
|
|
1241
|
-
key: 'header',
|
|
1242
|
-
role: 'options',
|
|
1243
|
-
style: optionStyles.length > 0 ? optionStyles : undefined,
|
|
1244
|
-
items: props.scaleOptions.map(option => {
|
|
1245
|
-
return {
|
|
1246
|
-
key: option.key,
|
|
1247
|
-
role: 'option',
|
|
1248
|
-
style: option.className ? [{ key: 'className', value: option.className }] : undefined,
|
|
1249
|
-
content: !Array.isArray(option.content) ? generateLocStrings(option.content) : undefined,
|
|
1250
|
-
items: Array.isArray(option.content) ? option.content.map((cont, index) => {
|
|
1251
|
-
return {
|
|
1252
|
-
key: index.toFixed(),
|
|
1253
|
-
role: 'text',
|
|
1254
|
-
content: generateLocStrings(cont.content),
|
|
1255
|
-
style: cont.className ? [{ key: 'className', value: cont.className }] : undefined,
|
|
1256
|
-
}
|
|
1257
|
-
}) : [],
|
|
1258
|
-
}
|
|
1259
|
-
})
|
|
1260
|
-
})
|
|
1261
|
-
|
|
1262
|
-
props.rows.forEach((row, index) => {
|
|
1263
|
-
let tableModeRowClassName: string | undefined = undefined;
|
|
1264
|
-
let horizontalModeRowClassName: string | undefined = undefined;
|
|
1265
|
-
let verticalModeRowClassName: string | undefined = undefined;
|
|
1266
|
-
|
|
1267
|
-
const isLast = index === props.rows.length - 1;
|
|
1268
|
-
|
|
1269
|
-
if (!props.tableModeProps?.hideRowBorder && !isLast) {
|
|
1270
|
-
tableModeRowClassName = defaultBorderClass;
|
|
1271
|
-
}
|
|
1272
|
-
if (row.tableModeProps?.className) {
|
|
1273
|
-
tableModeRowClassName += ' ' + row.tableModeProps?.className;
|
|
1274
|
-
}
|
|
1275
|
-
|
|
1276
|
-
if (!props.horizontalModeProps?.hideRowBorder && !isLast) {
|
|
1277
|
-
horizontalModeRowClassName = defaultBorderClass;
|
|
1278
|
-
}
|
|
1279
|
-
if (row.horizontalModeProps?.className) {
|
|
1280
|
-
horizontalModeRowClassName += ' ' + row.horizontalModeProps?.className;
|
|
1281
|
-
}
|
|
1282
|
-
|
|
1283
|
-
if (!props.verticalModeProps?.hideRowBorder && !isLast) {
|
|
1284
|
-
verticalModeRowClassName = defaultBorderClass;
|
|
1285
|
-
}
|
|
1286
|
-
if (row.verticalModeProps?.className) {
|
|
1287
|
-
verticalModeRowClassName += ' ' + row.verticalModeProps?.className;
|
|
1288
|
-
}
|
|
1289
|
-
|
|
1290
|
-
const rowStyles: Array<{ key: string, value: string }> = [];
|
|
1291
|
-
if (tableModeRowClassName) {
|
|
1292
|
-
rowStyles.push({ key: 'tableModeClassName', value: tableModeRowClassName })
|
|
1293
|
-
}
|
|
1294
|
-
if (horizontalModeRowClassName) {
|
|
1295
|
-
rowStyles.push({ key: 'horizontalModeClassName', value: horizontalModeRowClassName })
|
|
1296
|
-
}
|
|
1297
|
-
if (verticalModeRowClassName) {
|
|
1298
|
-
rowStyles.push({ key: 'verticalModeClassName', value: verticalModeRowClassName })
|
|
1299
|
-
}
|
|
1300
|
-
|
|
1301
|
-
if (row.horizontalModeProps?.labelPlacement) {
|
|
1302
|
-
rowStyles.push({ key: 'horizontalModeLabelPlacement', value: row.horizontalModeProps.labelPlacement })
|
|
1303
|
-
}
|
|
1304
|
-
|
|
1305
|
-
groupEdit.addItemComponent({
|
|
1306
|
-
key: row.key,
|
|
1307
|
-
role: 'row',
|
|
1308
|
-
style: rowStyles.length > 0 ? rowStyles : undefined,
|
|
1309
|
-
content: !Array.isArray(row.content) ? generateLocStrings(row.content) : undefined,
|
|
1310
|
-
items: Array.isArray(row.content) ? row.content.map((cont, index) => {
|
|
1311
|
-
return {
|
|
1312
|
-
key: index.toFixed(),
|
|
1313
|
-
role: 'text',
|
|
1314
|
-
content: generateLocStrings(cont.content),
|
|
1315
|
-
style: cont.className ? [{ key: 'className', value: cont.className }] : undefined,
|
|
1316
|
-
}
|
|
1317
|
-
}) : [],
|
|
1318
|
-
})
|
|
1319
|
-
})
|
|
1320
|
-
|
|
1321
|
-
return groupEdit.getComponent() as ItemGroupComponent;
|
|
1322
|
-
}
|
|
1323
|
-
|
|
1324
|
-
export const initResponsiveBipolarLikertArray = (
|
|
1325
|
-
rgKey: string,
|
|
1326
|
-
props: ResponsiveBipolarLikertArrayProps,
|
|
1327
|
-
displayCondition?: Expression,
|
|
1328
|
-
): ItemGroupComponent => {
|
|
1329
|
-
const groupEdit = new ComponentEditor(undefined, {
|
|
1330
|
-
key: rgKey,
|
|
1331
|
-
isGroup: true,
|
|
1332
|
-
role: 'responsiveBipolarLikertScaleArray',
|
|
1333
|
-
});
|
|
1334
|
-
|
|
1335
|
-
if (displayCondition) {
|
|
1336
|
-
groupEdit.setDisplayCondition(displayCondition);
|
|
1337
|
-
}
|
|
1338
|
-
|
|
1339
|
-
const style: Array<{ key: string, value: string }> = [
|
|
1340
|
-
{ key: 'defaultMode', value: props.defaultMode },
|
|
1341
|
-
];
|
|
1342
|
-
if (props.responsiveModes) {
|
|
1343
|
-
if (props.responsiveModes.sm) {
|
|
1344
|
-
style.push({ key: 'smMode', value: props.responsiveModes.sm });
|
|
1345
|
-
}
|
|
1346
|
-
if (props.responsiveModes.md) {
|
|
1347
|
-
style.push({ key: 'mdMode', value: props.responsiveModes.md });
|
|
1348
|
-
}
|
|
1349
|
-
if (props.responsiveModes.lg) {
|
|
1350
|
-
style.push({ key: 'lgMode', value: props.responsiveModes.lg });
|
|
1351
|
-
}
|
|
1352
|
-
if (props.responsiveModes.xl) {
|
|
1353
|
-
style.push({ key: 'xlMode', value: props.responsiveModes.xl });
|
|
1354
|
-
}
|
|
1355
|
-
if (props.responsiveModes.xxl) {
|
|
1356
|
-
style.push({ key: 'xxlMode', value: props.responsiveModes.xxl });
|
|
1357
|
-
}
|
|
1358
|
-
}
|
|
1359
|
-
if (props.rgClassName) {
|
|
1360
|
-
style.push({ key: 'className', value: props.rgClassName });
|
|
1361
|
-
}
|
|
1362
|
-
if (props.withLabelRowModeProps) {
|
|
1363
|
-
if (props.withLabelRowModeProps.maxLabelWidth) {
|
|
1364
|
-
style.push({ key: 'labelRowMaxLabelWidth', value: props.withLabelRowModeProps.maxLabelWidth });
|
|
1365
|
-
}
|
|
1366
|
-
}
|
|
1367
|
-
style.push({ key: 'labelRowPosition', value: props.withLabelRowModeProps?.useBottomLabel ? 'bottom' : 'top' })
|
|
1368
|
-
|
|
1369
|
-
if (props.tableModeProps) {
|
|
1370
|
-
style.push({ key: 'tableModeClassName', value: 'table-borderless mb-0 ' + props.tableModeProps.className });
|
|
1371
|
-
if (props.tableModeProps.layout) {
|
|
1372
|
-
style.push({ key: 'tableModeLayout', value: props.tableModeProps.layout });
|
|
1373
|
-
}
|
|
1374
|
-
if (props.tableModeProps.labelColWidth) {
|
|
1375
|
-
style.push({ key: 'tableModeLabelColWidth', value: props.tableModeProps.labelColWidth });
|
|
1376
|
-
}
|
|
1377
|
-
}
|
|
1378
|
-
groupEdit.setStyles(style);
|
|
1379
|
-
|
|
1380
|
-
const defaultBorderClass = 'border-bottom border-grey-2';
|
|
1381
|
-
|
|
1382
|
-
groupEdit.addItemComponent({
|
|
1383
|
-
key: 'options',
|
|
1384
|
-
role: 'options',
|
|
1385
|
-
items: props.scaleOptions.map(option => {
|
|
1386
|
-
return {
|
|
1387
|
-
key: option.key,
|
|
1388
|
-
role: 'option',
|
|
1389
|
-
}
|
|
1390
|
-
})
|
|
1391
|
-
})
|
|
1392
|
-
|
|
1393
|
-
props.rows.forEach((row, index) => {
|
|
1394
|
-
let tableModeRowClassName: string | undefined = undefined;
|
|
1395
|
-
let withLabelRowModeClassName: string | undefined = undefined;
|
|
1396
|
-
let verticalModeRowClassName: string | undefined = undefined;
|
|
1397
|
-
|
|
1398
|
-
const isLast = index === props.rows.length - 1;
|
|
1399
|
-
|
|
1400
|
-
if (!props.tableModeProps?.hideRowBorder && !isLast) {
|
|
1401
|
-
tableModeRowClassName = defaultBorderClass;
|
|
1402
|
-
}
|
|
1403
|
-
if (row.tableModeProps?.className) {
|
|
1404
|
-
tableModeRowClassName += ' ' + row.tableModeProps?.className;
|
|
1405
|
-
}
|
|
1406
|
-
|
|
1407
|
-
if (!props.withLabelRowModeProps?.hideRowBorder && !isLast) {
|
|
1408
|
-
withLabelRowModeClassName = defaultBorderClass;
|
|
1409
|
-
}
|
|
1410
|
-
if (row.withLabelRowModeProps?.className) {
|
|
1411
|
-
withLabelRowModeClassName += ' ' + row.withLabelRowModeProps?.className;
|
|
1412
|
-
}
|
|
1413
|
-
|
|
1414
|
-
if (!props.verticalModeProps?.hideRowBorder && !isLast) {
|
|
1415
|
-
verticalModeRowClassName = defaultBorderClass;
|
|
1416
|
-
}
|
|
1417
|
-
if (row.verticalModeProps?.className) {
|
|
1418
|
-
verticalModeRowClassName += ' ' + row.verticalModeProps?.className;
|
|
1419
|
-
}
|
|
1420
|
-
|
|
1421
|
-
const rowStyles: Array<{ key: string, value: string }> = [];
|
|
1422
|
-
if (tableModeRowClassName) {
|
|
1423
|
-
rowStyles.push({ key: 'tableModeClassName', value: tableModeRowClassName })
|
|
1424
|
-
}
|
|
1425
|
-
if (withLabelRowModeClassName) {
|
|
1426
|
-
rowStyles.push({ key: 'withLabelRowModeClassName', value: withLabelRowModeClassName })
|
|
1427
|
-
}
|
|
1428
|
-
if (verticalModeRowClassName) {
|
|
1429
|
-
rowStyles.push({ key: 'verticalModeClassName', value: verticalModeRowClassName })
|
|
1430
|
-
}
|
|
1431
|
-
|
|
1432
|
-
const startLabel = {
|
|
1433
|
-
key: 'start',
|
|
1434
|
-
role: 'start',
|
|
1435
|
-
content: !Array.isArray(row.startLabel) ? generateLocStrings(row.startLabel) : undefined,
|
|
1436
|
-
items: Array.isArray(row.startLabel) ? row.startLabel.map((cont, index) => {
|
|
1437
|
-
return {
|
|
1438
|
-
key: index.toFixed(),
|
|
1439
|
-
role: 'text',
|
|
1440
|
-
content: generateLocStrings(cont.content),
|
|
1441
|
-
style: cont.className ? [{ key: 'className', value: cont.className }] : undefined,
|
|
1442
|
-
}
|
|
1443
|
-
}) : [],
|
|
1444
|
-
}
|
|
1445
|
-
|
|
1446
|
-
const endLabel = {
|
|
1447
|
-
key: 'end',
|
|
1448
|
-
role: 'end',
|
|
1449
|
-
content: !Array.isArray(row.endLabel) ? generateLocStrings(row.endLabel) : undefined,
|
|
1450
|
-
items: Array.isArray(row.endLabel) ? row.endLabel.map((cont, index) => {
|
|
1451
|
-
return {
|
|
1452
|
-
key: index.toFixed(),
|
|
1453
|
-
role: 'text',
|
|
1454
|
-
content: generateLocStrings(cont.content),
|
|
1455
|
-
style: cont.className ? [{ key: 'className', value: cont.className }] : undefined,
|
|
1456
|
-
}
|
|
1457
|
-
}) : [],
|
|
1458
|
-
}
|
|
1459
|
-
|
|
1460
|
-
groupEdit.addItemComponent({
|
|
1461
|
-
key: row.key,
|
|
1462
|
-
role: 'row',
|
|
1463
|
-
style: rowStyles.length > 0 ? rowStyles : undefined,
|
|
1464
|
-
items: [
|
|
1465
|
-
startLabel, endLabel
|
|
1466
|
-
],
|
|
1467
|
-
})
|
|
1468
|
-
})
|
|
1469
|
-
|
|
1470
|
-
return groupEdit.getComponent() as ItemGroupComponent;
|
|
1471
|
-
}
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
export const initLikertScaleItem = (
|
|
1475
|
-
key: string,
|
|
1476
|
-
options: Array<{
|
|
1477
|
-
key: string;
|
|
1478
|
-
className?: string;
|
|
1479
|
-
content?: Map<string, string>;
|
|
1480
|
-
disabled?: Expression;
|
|
1481
|
-
}>,
|
|
1482
|
-
stackOnSmallScreen?: boolean,
|
|
1483
|
-
displayCondition?: Expression,
|
|
1484
|
-
): ItemGroupComponent => {
|
|
1485
|
-
// init group
|
|
1486
|
-
const groupEdit = new ComponentEditor(undefined, {
|
|
1487
|
-
key: key,
|
|
1488
|
-
isGroup: true,
|
|
1489
|
-
role: 'likert',
|
|
1490
|
-
});
|
|
1491
|
-
groupEdit.setDisplayCondition(displayCondition);
|
|
1492
|
-
if (stackOnSmallScreen) {
|
|
1493
|
-
groupEdit.setStyles([
|
|
1494
|
-
{ key: 'responsive', value: 'stackOnSmallScreen' }
|
|
1495
|
-
])
|
|
1496
|
-
}
|
|
1497
|
-
|
|
1498
|
-
options.forEach((option) => {
|
|
1499
|
-
const optionComponent = new ComponentEditor(undefined, {
|
|
1500
|
-
key: option.key,
|
|
1501
|
-
role: 'option',
|
|
1502
|
-
});
|
|
1503
|
-
if (option.content) {
|
|
1504
|
-
optionComponent.setContent(generateLocStrings(option.content));
|
|
1505
|
-
}
|
|
1506
|
-
if (option.className) {
|
|
1507
|
-
optionComponent.setStyles([{
|
|
1508
|
-
key: 'className', value: option.className
|
|
1509
|
-
}]);
|
|
1510
|
-
}
|
|
1511
|
-
optionComponent.setDisabled(option.disabled);
|
|
1512
|
-
groupEdit.addItemComponent(optionComponent.getComponent());
|
|
1513
|
-
});
|
|
1514
|
-
|
|
1515
|
-
return groupEdit.getComponent() as ItemGroupComponent;
|
|
1516
|
-
}
|