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,223 @@
|
|
|
1
|
+
import { ComponentProperties, ConfidentialMode, Expression, ItemComponent, Validation } from "survey-engine/data_types";
|
|
2
|
+
import { Duration } from "../../types/duration";
|
|
3
|
+
export interface StyledTextComponentProp {
|
|
4
|
+
content: Map<string, string>;
|
|
5
|
+
className?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface DateDisplayComponentProp {
|
|
8
|
+
languageCodes: string[];
|
|
9
|
+
date: Expression;
|
|
10
|
+
dateFormat: string;
|
|
11
|
+
className?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare const isDateDisplayComponentProp: (value: DateDisplayComponentProp | any) => value is DateDisplayComponentProp;
|
|
14
|
+
export interface OptionDef {
|
|
15
|
+
key: string;
|
|
16
|
+
role: string;
|
|
17
|
+
content?: Map<string, string>;
|
|
18
|
+
items?: Array<StyledTextComponentProp> | Array<OptionDef>;
|
|
19
|
+
description?: Map<string, string>;
|
|
20
|
+
displayCondition?: Expression;
|
|
21
|
+
disabled?: Expression;
|
|
22
|
+
style?: Array<{
|
|
23
|
+
key: string;
|
|
24
|
+
value: string;
|
|
25
|
+
}>;
|
|
26
|
+
optionProps?: ComponentProperties;
|
|
27
|
+
}
|
|
28
|
+
export interface GenericQuestionProps {
|
|
29
|
+
parentKey: string;
|
|
30
|
+
itemKey: string;
|
|
31
|
+
version?: number;
|
|
32
|
+
questionText: Map<string, string> | Array<StyledTextComponentProp | DateDisplayComponentProp>;
|
|
33
|
+
questionSubText?: Map<string, string>;
|
|
34
|
+
titleClassName?: string;
|
|
35
|
+
helpGroupContent?: Array<{
|
|
36
|
+
content: Map<string, string>;
|
|
37
|
+
style?: Array<{
|
|
38
|
+
key: string;
|
|
39
|
+
value: string;
|
|
40
|
+
}>;
|
|
41
|
+
}>;
|
|
42
|
+
condition?: Expression;
|
|
43
|
+
topDisplayCompoments?: Array<ItemComponent>;
|
|
44
|
+
bottomDisplayCompoments?: Array<ItemComponent>;
|
|
45
|
+
isRequired?: boolean;
|
|
46
|
+
footnoteText?: Map<string, string>;
|
|
47
|
+
customValidations?: Array<Validation>;
|
|
48
|
+
confidentialMode?: ConfidentialMode;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Numeric Input
|
|
52
|
+
*/
|
|
53
|
+
export interface NumericInputProps {
|
|
54
|
+
inputLabel: Map<string, string>;
|
|
55
|
+
labelBehindInput?: boolean;
|
|
56
|
+
componentProperties?: ComponentProperties;
|
|
57
|
+
inputMaxWidth?: string;
|
|
58
|
+
disabled?: Expression;
|
|
59
|
+
}
|
|
60
|
+
export declare type NumericInputQuestionProps = GenericQuestionProps & NumericInputProps;
|
|
61
|
+
/**
|
|
62
|
+
* Date Input
|
|
63
|
+
*/
|
|
64
|
+
export interface DateInputProps {
|
|
65
|
+
dateInputMode: 'YMD' | 'YM' | 'Y';
|
|
66
|
+
inputLabelText?: Map<string, string>;
|
|
67
|
+
placeholderText?: Map<string, string>;
|
|
68
|
+
minRelativeDate?: {
|
|
69
|
+
reference?: number | Expression;
|
|
70
|
+
delta: Duration;
|
|
71
|
+
};
|
|
72
|
+
maxRelativeDate?: {
|
|
73
|
+
reference?: number | Expression;
|
|
74
|
+
delta: Duration;
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
export declare type DateInputQuestionProps = DateInputProps & GenericQuestionProps;
|
|
78
|
+
/**
|
|
79
|
+
* Time Input
|
|
80
|
+
*/
|
|
81
|
+
export interface TimeInputProps {
|
|
82
|
+
inputLabelText?: Map<string, string>;
|
|
83
|
+
labelBehindInput?: boolean;
|
|
84
|
+
defaultValue?: string;
|
|
85
|
+
minTime?: string;
|
|
86
|
+
maxTime?: string;
|
|
87
|
+
step?: number;
|
|
88
|
+
}
|
|
89
|
+
export declare type TimeInputQuestionProps = TimeInputProps & GenericQuestionProps;
|
|
90
|
+
/**
|
|
91
|
+
* Text Input
|
|
92
|
+
*/
|
|
93
|
+
export interface TextInputProps {
|
|
94
|
+
placeholderText?: Map<string, string>;
|
|
95
|
+
inputLabel?: Map<string, string>;
|
|
96
|
+
inputMaxWidth?: string;
|
|
97
|
+
className?: string;
|
|
98
|
+
maxLength?: number;
|
|
99
|
+
disabled?: Expression;
|
|
100
|
+
}
|
|
101
|
+
export declare type TextInputQuestionProps = TextInputProps & GenericQuestionProps;
|
|
102
|
+
export interface MultiLineTextInput extends GenericQuestionProps {
|
|
103
|
+
inputLabelText?: Map<string, string>;
|
|
104
|
+
placeholderText?: Map<string, string>;
|
|
105
|
+
maxLength?: number;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Cloze Question
|
|
109
|
+
*/
|
|
110
|
+
export interface ClozeProps {
|
|
111
|
+
items: Array<OptionDef>;
|
|
112
|
+
}
|
|
113
|
+
export declare type ClozeQuestionProps = ClozeProps & GenericQuestionProps;
|
|
114
|
+
/**
|
|
115
|
+
* Consent Question
|
|
116
|
+
*/
|
|
117
|
+
export interface ConsentProps {
|
|
118
|
+
checkBoxLabel: Map<string, string> | Array<StyledTextComponentProp | DateDisplayComponentProp>;
|
|
119
|
+
dialogTitle: Map<string, string>;
|
|
120
|
+
dialogContent: Map<string, string>;
|
|
121
|
+
acceptBtn: Map<string, string>;
|
|
122
|
+
rejectBtn: Map<string, string>;
|
|
123
|
+
className?: string;
|
|
124
|
+
}
|
|
125
|
+
export declare type ConsentQuestionProps = ConsentProps & GenericQuestionProps;
|
|
126
|
+
/**
|
|
127
|
+
* Response Single Choice Likert Array
|
|
128
|
+
*/
|
|
129
|
+
export declare type ResponsiveSingleChoiceArrayVariant = 'horizontal' | 'vertical' | 'table';
|
|
130
|
+
export interface ResponsiveSingleChoiceArrayProps {
|
|
131
|
+
scaleOptions: Array<{
|
|
132
|
+
key: string;
|
|
133
|
+
className?: string;
|
|
134
|
+
content: Map<string, string> | StyledTextComponentProp[];
|
|
135
|
+
}>;
|
|
136
|
+
rows: Array<{
|
|
137
|
+
key: string;
|
|
138
|
+
displayCondition?: Expression;
|
|
139
|
+
content: Map<string, string> | StyledTextComponentProp[];
|
|
140
|
+
horizontalModeProps?: {
|
|
141
|
+
labelPlacement?: 'none' | 'top' | 'bottom';
|
|
142
|
+
className?: string;
|
|
143
|
+
};
|
|
144
|
+
verticalModeProps?: {
|
|
145
|
+
className?: string;
|
|
146
|
+
};
|
|
147
|
+
tableModeProps?: {
|
|
148
|
+
className?: string;
|
|
149
|
+
};
|
|
150
|
+
}>;
|
|
151
|
+
defaultMode: ResponsiveSingleChoiceArrayVariant;
|
|
152
|
+
responsiveModes?: {
|
|
153
|
+
sm?: ResponsiveSingleChoiceArrayVariant;
|
|
154
|
+
md?: ResponsiveSingleChoiceArrayVariant;
|
|
155
|
+
lg?: ResponsiveSingleChoiceArrayVariant;
|
|
156
|
+
xl?: ResponsiveSingleChoiceArrayVariant;
|
|
157
|
+
xxl?: ResponsiveSingleChoiceArrayVariant;
|
|
158
|
+
};
|
|
159
|
+
rgClassName?: string;
|
|
160
|
+
tableModeProps?: {
|
|
161
|
+
className?: string;
|
|
162
|
+
layout?: "fixed";
|
|
163
|
+
firstColWidth?: string;
|
|
164
|
+
optionHeaderClassName?: string;
|
|
165
|
+
hideRowBorder?: boolean;
|
|
166
|
+
};
|
|
167
|
+
horizontalModeProps?: {
|
|
168
|
+
hideRowBorder?: boolean;
|
|
169
|
+
};
|
|
170
|
+
verticalModeProps?: {
|
|
171
|
+
hideRowBorder?: boolean;
|
|
172
|
+
useReverseOptionOrder?: boolean;
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
export declare type ResponsiveSingleChoiceArrayQuestionProps = GenericQuestionProps & ResponsiveSingleChoiceArrayProps;
|
|
176
|
+
/**
|
|
177
|
+
* Response Bipolar Likert Array
|
|
178
|
+
*/
|
|
179
|
+
export declare type ResponsiveBipolarLikertArrayVariant = 'withLabelRow' | 'vertical' | 'table';
|
|
180
|
+
export interface ResponsiveBipolarLikertArrayProps {
|
|
181
|
+
scaleOptions: Array<{
|
|
182
|
+
key: string;
|
|
183
|
+
}>;
|
|
184
|
+
rows: Array<{
|
|
185
|
+
key: string;
|
|
186
|
+
startLabel: Map<string, string> | StyledTextComponentProp[];
|
|
187
|
+
endLabel: Map<string, string> | StyledTextComponentProp[];
|
|
188
|
+
displayCondition?: Expression;
|
|
189
|
+
withLabelRowModeProps?: {
|
|
190
|
+
className?: string;
|
|
191
|
+
};
|
|
192
|
+
verticalModeProps?: {
|
|
193
|
+
className?: string;
|
|
194
|
+
};
|
|
195
|
+
tableModeProps?: {
|
|
196
|
+
className?: string;
|
|
197
|
+
};
|
|
198
|
+
}>;
|
|
199
|
+
defaultMode: ResponsiveBipolarLikertArrayVariant;
|
|
200
|
+
responsiveModes?: {
|
|
201
|
+
sm?: ResponsiveBipolarLikertArrayVariant;
|
|
202
|
+
md?: ResponsiveBipolarLikertArrayVariant;
|
|
203
|
+
lg?: ResponsiveBipolarLikertArrayVariant;
|
|
204
|
+
xl?: ResponsiveBipolarLikertArrayVariant;
|
|
205
|
+
xxl?: ResponsiveBipolarLikertArrayVariant;
|
|
206
|
+
};
|
|
207
|
+
rgClassName?: string;
|
|
208
|
+
tableModeProps?: {
|
|
209
|
+
className?: string;
|
|
210
|
+
layout?: "fixed";
|
|
211
|
+
labelColWidth?: string;
|
|
212
|
+
hideRowBorder?: boolean;
|
|
213
|
+
};
|
|
214
|
+
withLabelRowModeProps?: {
|
|
215
|
+
hideRowBorder?: boolean;
|
|
216
|
+
maxLabelWidth?: string;
|
|
217
|
+
useBottomLabel?: boolean;
|
|
218
|
+
};
|
|
219
|
+
verticalModeProps?: {
|
|
220
|
+
hideRowBorder?: boolean;
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
export declare type ResponsiveBipolarLikertArrayQuestionProps = GenericQuestionProps & ResponsiveBipolarLikertArrayProps;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const isDateDisplayComponentProp = (value) => {
|
|
6
|
+
return typeof (value) === 'object' && value.date !== undefined && value.dateFormat !== undefined && value.languageCodes !== undefined;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
exports.isDateDisplayComponentProp = isDateDisplayComponentProp;
|
|
10
|
+
//# sourceMappingURL=item-properties.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"item-properties.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Expression, SurveySingleItem } from "survey-engine/data_types";
|
|
2
|
+
export declare abstract class Item {
|
|
3
|
+
key: string;
|
|
4
|
+
item: SurveySingleItem;
|
|
5
|
+
protected itemKey: string;
|
|
6
|
+
protected parentKey: string;
|
|
7
|
+
protected condition?: Expression;
|
|
8
|
+
protected isRequired?: boolean;
|
|
9
|
+
constructor(parentKey: string, itemKey: string);
|
|
10
|
+
abstract buildItem(): SurveySingleItem;
|
|
11
|
+
/**
|
|
12
|
+
* Check if this item is currently part of a path, by checking if the key attribute exists in the path of the group.
|
|
13
|
+
* @param partialKey Is this key segment included somewhere in the parent key of this item.
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
isPartOf(partialKey: string): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Use this method to retrieve the generated survey item
|
|
19
|
+
* @returns
|
|
20
|
+
*/
|
|
21
|
+
get(): SurveySingleItem;
|
|
22
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
class Item {
|
|
6
|
+
constructor(parentKey, itemKey) {
|
|
7
|
+
this.parentKey = parentKey;
|
|
8
|
+
this.itemKey = itemKey;
|
|
9
|
+
this.key = [this.parentKey, itemKey].join('.');
|
|
10
|
+
this.item = {
|
|
11
|
+
version: 0,
|
|
12
|
+
key: "not defined"
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Check if this item is currently part of a path, by checking if the key attribute exists in the path of the group.
|
|
17
|
+
* @param partialKey Is this key segment included somewhere in the parent key of this item.
|
|
18
|
+
* @returns
|
|
19
|
+
*/
|
|
20
|
+
isPartOf(partialKey) {
|
|
21
|
+
return this.parentKey.includes(partialKey);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Use this method to retrieve the generated survey item
|
|
25
|
+
* @returns
|
|
26
|
+
*/
|
|
27
|
+
get() {
|
|
28
|
+
this.item = this.buildItem();
|
|
29
|
+
return this.item;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
exports.Item = Item;
|
|
34
|
+
//# sourceMappingURL=item.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"item.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { SurveyItem } from "survey-engine/data_types";
|
|
2
|
+
import { SurveyEditor } from "../survey-editor/survey-editor";
|
|
3
|
+
export declare type SurveyAvailableFor = 'public' | 'temporary_participants' | 'active_participants';
|
|
4
|
+
export interface SurveyProps {
|
|
5
|
+
surveyKey: string;
|
|
6
|
+
name: Map<string, string>;
|
|
7
|
+
description: Map<string, string>;
|
|
8
|
+
durationText: Map<string, string>;
|
|
9
|
+
availableFor?: SurveyAvailableFor;
|
|
10
|
+
requireLoginBeforeSubmission?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare abstract class SurveyDefinition {
|
|
13
|
+
key: string;
|
|
14
|
+
editor: SurveyEditor;
|
|
15
|
+
constructor(props: SurveyProps);
|
|
16
|
+
abstract buildSurvey(): void;
|
|
17
|
+
getSurvey(): import("survey-engine/data_types").Survey;
|
|
18
|
+
getSurveyJSON(pretty?: boolean): string;
|
|
19
|
+
addItem(item: SurveyItem, pageBreakAfter?: boolean): void;
|
|
20
|
+
addPageBreak(): void;
|
|
21
|
+
addSurveyItemToPath(item: SurveyItem, parentKey: string): void;
|
|
22
|
+
private checkDuplicateChildKeys;
|
|
23
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
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_surveyEditor_surveyEditor = require('../survey-editor/survey-editor.js');
|
|
8
|
+
var surveys_utils_simpleGenerators = require('../utils/simple-generators.js');
|
|
9
|
+
require('../survey-editor/component-editor.js');
|
|
10
|
+
require('../utils/randomKeyGenerator.js');
|
|
11
|
+
require('./item-properties.js');
|
|
12
|
+
|
|
13
|
+
class SurveyDefinition {
|
|
14
|
+
constructor(props) {
|
|
15
|
+
this.editor = new surveys_surveyEditor_surveyEditor.SurveyEditor();
|
|
16
|
+
this.editor.changeItemKey('survey', props.surveyKey);
|
|
17
|
+
this.key = props.surveyKey;
|
|
18
|
+
// define name and description of the survey
|
|
19
|
+
this.editor.setSurveyName(surveys_utils_simpleGenerators.generateLocStrings(props.name));
|
|
20
|
+
this.editor.setSurveyDescription(surveys_utils_simpleGenerators.generateLocStrings(props.description));
|
|
21
|
+
this.editor.setSurveyDuration(surveys_utils_simpleGenerators.generateLocStrings(props.durationText));
|
|
22
|
+
this.editor.setAvailableFor(props.availableFor);
|
|
23
|
+
this.editor.setRequireLoginBeforeSubmission(props.requireLoginBeforeSubmission);
|
|
24
|
+
const rootItemEditor = new surveys_surveyEditor_itemEditor.ItemEditor(this.editor.findSurveyItem(props.surveyKey));
|
|
25
|
+
rootItemEditor.setSelectionMethod({ name: 'sequential' });
|
|
26
|
+
this.editor.updateSurveyItem(rootItemEditor.getItem());
|
|
27
|
+
}
|
|
28
|
+
getSurvey() {
|
|
29
|
+
this.buildSurvey();
|
|
30
|
+
this.checkDuplicateChildKeys();
|
|
31
|
+
return this.editor.getSurvey();
|
|
32
|
+
}
|
|
33
|
+
getSurveyJSON(pretty) {
|
|
34
|
+
this.buildSurvey();
|
|
35
|
+
this.checkDuplicateChildKeys();
|
|
36
|
+
return this.editor.getSurveyJSON(pretty);
|
|
37
|
+
}
|
|
38
|
+
addItem(item, pageBreakAfter) {
|
|
39
|
+
this.editor.addExistingSurveyItem(item, this.key);
|
|
40
|
+
if (pageBreakAfter) {
|
|
41
|
+
this.addPageBreak();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
addPageBreak() {
|
|
45
|
+
this.editor.addExistingSurveyItem(surveys_utils_simpleGenerators.generatePageBreak(this.key), this.key);
|
|
46
|
+
}
|
|
47
|
+
addSurveyItemToPath(item, parentKey) {
|
|
48
|
+
this.editor.addExistingSurveyItem(item, parentKey);
|
|
49
|
+
}
|
|
50
|
+
checkDuplicateChildKeys() {
|
|
51
|
+
const group = this.editor.getSurvey().current.surveyDefinition;
|
|
52
|
+
const keys = group.items.map(item => item.key);
|
|
53
|
+
const hasDuplicates = keys.some((key, index) => {
|
|
54
|
+
const isDuplicateKey = keys.indexOf(key) !== index;
|
|
55
|
+
if (isDuplicateKey) {
|
|
56
|
+
logger_logger.Logger.error('Duplicate key:');
|
|
57
|
+
logger_logger.Logger.criticalError(`${key} is used twice (at index ${keys.indexOf(key)} and at index ${index})`);
|
|
58
|
+
}
|
|
59
|
+
return isDuplicateKey;
|
|
60
|
+
});
|
|
61
|
+
if (hasDuplicates) {
|
|
62
|
+
logger_logger.Logger.error('\nSurvey item contains duplicate keys.\nPlease check the lines above for more infos.\nProcess stopped prematurely.');
|
|
63
|
+
process.exit(1);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
exports.SurveyDefinition = SurveyDefinition;
|
|
69
|
+
//# sourceMappingURL=survey-definition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"survey-definition.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Expression, ItemComponent } from "survey-engine/data_types";
|
|
2
|
+
import { StyledTextComponentProp } from "../types/item-properties";
|
|
3
|
+
interface CommonProps {
|
|
4
|
+
key?: string;
|
|
5
|
+
content?: Map<string, string> | StyledTextComponentProp[];
|
|
6
|
+
displayCondition?: Expression;
|
|
7
|
+
}
|
|
8
|
+
interface TextProps extends CommonProps {
|
|
9
|
+
content: Map<string, string>;
|
|
10
|
+
variant?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'p' | 'li';
|
|
11
|
+
className?: string;
|
|
12
|
+
}
|
|
13
|
+
interface MarkdownProps extends CommonProps {
|
|
14
|
+
content: Map<string, string>;
|
|
15
|
+
className?: string;
|
|
16
|
+
}
|
|
17
|
+
export declare const ComponentGenerators: {
|
|
18
|
+
footnote: (props: {
|
|
19
|
+
content: Map<string, string>;
|
|
20
|
+
}) => ItemComponent;
|
|
21
|
+
text: (props: TextProps) => ItemComponent;
|
|
22
|
+
markdown: (props: MarkdownProps) => ItemComponent;
|
|
23
|
+
};
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var surveys_utils_randomKeyGenerator = require('./randomKeyGenerator.js');
|
|
6
|
+
var surveys_utils_simpleGenerators = require('./simple-generators.js');
|
|
7
|
+
require('../survey-editor/component-editor.js');
|
|
8
|
+
require('../types/item-properties.js');
|
|
9
|
+
|
|
10
|
+
const text = (props) => {
|
|
11
|
+
const styles = [];
|
|
12
|
+
if (props.className !== undefined) {
|
|
13
|
+
styles.push({
|
|
14
|
+
key: 'className', value: props.className
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
if (props.variant !== undefined) {
|
|
18
|
+
styles.push({
|
|
19
|
+
key: 'variant', value: props.variant
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
key: surveys_utils_randomKeyGenerator.generateRandomKey(3),
|
|
24
|
+
role: 'text',
|
|
25
|
+
style: styles.length > 0 ? styles : undefined,
|
|
26
|
+
content: surveys_utils_simpleGenerators.generateLocStrings(props.content),
|
|
27
|
+
displayCondition: props.displayCondition,
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
const markdown = (props) => {
|
|
31
|
+
const styles = [];
|
|
32
|
+
if (props.className !== undefined) {
|
|
33
|
+
styles.push({
|
|
34
|
+
key: 'className', value: props.className
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
key: surveys_utils_randomKeyGenerator.generateRandomKey(3),
|
|
39
|
+
role: 'markdown',
|
|
40
|
+
style: styles.length > 0 ? styles : undefined,
|
|
41
|
+
content: surveys_utils_simpleGenerators.generateLocStrings(props.content),
|
|
42
|
+
displayCondition: props.displayCondition,
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
const footnote = (props) => {
|
|
46
|
+
return {
|
|
47
|
+
role: 'footnote', content: surveys_utils_simpleGenerators.generateLocStrings(props.content), style: [
|
|
48
|
+
{ key: 'className', value: 'fs-small fst-italic text-center' }
|
|
49
|
+
]
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
const ComponentGenerators = {
|
|
53
|
+
footnote,
|
|
54
|
+
text,
|
|
55
|
+
markdown,
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
exports.ComponentGenerators = ComponentGenerators;
|
|
59
|
+
//# sourceMappingURL=componentGenerators.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"componentGenerators.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { Expression } from "survey-engine/data_types";
|
|
2
|
+
import { ClozeProps, DateInputProps, NumericInputProps, OptionDef, StyledTextComponentProp, TextInputProps, TimeInputProps } from "../types/item-properties";
|
|
3
|
+
interface CommonProps {
|
|
4
|
+
key?: string;
|
|
5
|
+
content?: Map<string, string> | StyledTextComponentProp[];
|
|
6
|
+
displayCondition?: Expression;
|
|
7
|
+
}
|
|
8
|
+
interface OptionProps {
|
|
9
|
+
disabled?: Expression;
|
|
10
|
+
className?: string;
|
|
11
|
+
displayCondition?: Expression;
|
|
12
|
+
}
|
|
13
|
+
interface OptionTextProps extends CommonProps {
|
|
14
|
+
className?: string;
|
|
15
|
+
}
|
|
16
|
+
export declare const SingleChoiceOptionTypes: {
|
|
17
|
+
option: (key: string, content: Map<string, string> | StyledTextComponentProp[], extraProps?: OptionProps | undefined) => OptionDef;
|
|
18
|
+
textInput: (props: TextInputProps & {
|
|
19
|
+
key: string;
|
|
20
|
+
displayCondition?: Expression;
|
|
21
|
+
}) => OptionDef;
|
|
22
|
+
timeInput: (props: TimeInputProps & {
|
|
23
|
+
key: string;
|
|
24
|
+
displayCondition?: Expression;
|
|
25
|
+
}) => OptionDef;
|
|
26
|
+
numberInput: (props: NumericInputProps & {
|
|
27
|
+
key: string;
|
|
28
|
+
displayCondition?: Expression;
|
|
29
|
+
}) => OptionDef;
|
|
30
|
+
cloze: (props: ClozeProps & {
|
|
31
|
+
key: string;
|
|
32
|
+
displayCondition?: Expression;
|
|
33
|
+
className?: string;
|
|
34
|
+
}) => OptionDef;
|
|
35
|
+
};
|
|
36
|
+
export declare const MultipleChoiceOptionTypes: {
|
|
37
|
+
option: (key: string, content: Map<string, string> | StyledTextComponentProp[], extraProps?: OptionProps | undefined) => OptionDef;
|
|
38
|
+
subtitle: (props: OptionTextProps) => OptionDef;
|
|
39
|
+
textInput: (props: TextInputProps & {
|
|
40
|
+
key: string;
|
|
41
|
+
displayCondition?: Expression;
|
|
42
|
+
}) => OptionDef;
|
|
43
|
+
timeInput: (props: TimeInputProps & {
|
|
44
|
+
key: string;
|
|
45
|
+
displayCondition?: Expression;
|
|
46
|
+
}) => OptionDef;
|
|
47
|
+
numberInput: (props: NumericInputProps & {
|
|
48
|
+
key: string;
|
|
49
|
+
displayCondition?: Expression;
|
|
50
|
+
}) => OptionDef;
|
|
51
|
+
cloze: (props: ClozeProps & {
|
|
52
|
+
key: string;
|
|
53
|
+
displayCondition?: Expression;
|
|
54
|
+
className?: string;
|
|
55
|
+
}) => OptionDef;
|
|
56
|
+
};
|
|
57
|
+
export declare const ClozeItemTypes: {
|
|
58
|
+
text: (props: OptionTextProps) => OptionDef;
|
|
59
|
+
markdown: (props: OptionTextProps) => OptionDef;
|
|
60
|
+
textInput: (props: TextInputProps & {
|
|
61
|
+
key: string;
|
|
62
|
+
displayCondition?: Expression;
|
|
63
|
+
}) => OptionDef;
|
|
64
|
+
dateInput: (props: DateInputProps & {
|
|
65
|
+
key: string;
|
|
66
|
+
displayCondition?: Expression;
|
|
67
|
+
}) => OptionDef;
|
|
68
|
+
timeInput: (props: TimeInputProps & {
|
|
69
|
+
key: string;
|
|
70
|
+
displayCondition?: Expression;
|
|
71
|
+
}) => OptionDef;
|
|
72
|
+
clozeLineBreak: () => OptionDef;
|
|
73
|
+
numberInput: (props: NumericInputProps & {
|
|
74
|
+
key: string;
|
|
75
|
+
displayCondition?: Expression;
|
|
76
|
+
}) => OptionDef;
|
|
77
|
+
dropDown: (props: {
|
|
78
|
+
key: string;
|
|
79
|
+
placeholder?: Map<string, string>;
|
|
80
|
+
displayCondition?: Expression;
|
|
81
|
+
options: Array<OptionDef>;
|
|
82
|
+
}) => OptionDef;
|
|
83
|
+
};
|
|
84
|
+
export {};
|