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,211 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var surveys_surveyEngineExpressions = require('../survey-engine-expressions.js');
|
|
6
|
+
var surveys_utils_randomKeyGenerator = require('./randomKeyGenerator.js');
|
|
7
|
+
require('../../constants/key-definitions.js');
|
|
8
|
+
require('../../types/duration.js');
|
|
9
|
+
require('../../expression-utils/expressionGen.js');
|
|
10
|
+
|
|
11
|
+
const option = (key, content, extraProps) => {
|
|
12
|
+
const styles = [];
|
|
13
|
+
if ((extraProps === null || extraProps === void 0 ? void 0 : extraProps.className) !== undefined) {
|
|
14
|
+
styles.push({
|
|
15
|
+
key: 'className', value: extraProps.className
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
key: key,
|
|
20
|
+
role: 'option',
|
|
21
|
+
content: !Array.isArray(content) ? content : undefined,
|
|
22
|
+
items: Array.isArray(content) ? content : undefined,
|
|
23
|
+
displayCondition: extraProps === null || extraProps === void 0 ? void 0 : extraProps.displayCondition,
|
|
24
|
+
disabled: extraProps === null || extraProps === void 0 ? void 0 : extraProps.disabled,
|
|
25
|
+
style: styles,
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
const multipleChoiceOptionSubtitle = (props) => {
|
|
29
|
+
const styles = [];
|
|
30
|
+
if (props.className !== undefined) {
|
|
31
|
+
styles.push({
|
|
32
|
+
key: 'className', value: props.className
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
key: props.key ? props.key : surveys_utils_randomKeyGenerator.generateRandomKey(6),
|
|
37
|
+
role: 'text',
|
|
38
|
+
content: !Array.isArray(props.content) ? props.content : undefined,
|
|
39
|
+
displayCondition: props.displayCondition,
|
|
40
|
+
style: styles,
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
const markdown = (props) => {
|
|
44
|
+
const styles = [];
|
|
45
|
+
if (props.className !== undefined) {
|
|
46
|
+
styles.push({
|
|
47
|
+
key: 'className', value: props.className
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
key: props.key ? props.key : surveys_utils_randomKeyGenerator.generateRandomKey(6),
|
|
52
|
+
role: 'markdown',
|
|
53
|
+
content: !Array.isArray(props.content) ? props.content : undefined,
|
|
54
|
+
displayCondition: props.displayCondition,
|
|
55
|
+
style: styles,
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
const textInput = (props) => {
|
|
59
|
+
const style = [];
|
|
60
|
+
if (props.maxLength !== undefined) {
|
|
61
|
+
style.push({ key: 'maxLength', value: props.maxLength.toFixed(0) });
|
|
62
|
+
}
|
|
63
|
+
if (props.className !== undefined) {
|
|
64
|
+
style.push({ key: 'className', value: props.className });
|
|
65
|
+
}
|
|
66
|
+
if (props.inputMaxWidth !== undefined) {
|
|
67
|
+
style.push({ key: 'inputMaxWidth', value: props.inputMaxWidth });
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
key: props.key,
|
|
71
|
+
role: 'input',
|
|
72
|
+
content: props.inputLabel,
|
|
73
|
+
description: props.placeholderText,
|
|
74
|
+
displayCondition: props.displayCondition,
|
|
75
|
+
disabled: props.disabled,
|
|
76
|
+
style: style.length > 0 ? style : undefined,
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
const numberInput = (props) => {
|
|
80
|
+
var _a, _b, _c, _d;
|
|
81
|
+
const style = [];
|
|
82
|
+
if (props.inputMaxWidth !== undefined) {
|
|
83
|
+
style.push({ key: 'inputMaxWidth', value: props.inputMaxWidth });
|
|
84
|
+
}
|
|
85
|
+
if (props.labelBehindInput) {
|
|
86
|
+
style.push({ key: 'labelPlacement', value: 'after' });
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
key: props.key,
|
|
90
|
+
role: 'numberInput',
|
|
91
|
+
content: props.inputLabel,
|
|
92
|
+
displayCondition: props.displayCondition,
|
|
93
|
+
disabled: props.disabled,
|
|
94
|
+
optionProps: {
|
|
95
|
+
min: ((_a = props.componentProperties) === null || _a === void 0 ? void 0 : _a.min) !== undefined ? (typeof (props.componentProperties.min) === 'number' ? { dtype: 'num', num: props.componentProperties.min } : props.componentProperties.min) : undefined,
|
|
96
|
+
max: ((_b = props.componentProperties) === null || _b === void 0 ? void 0 : _b.max) !== undefined ? (typeof ((_c = props.componentProperties) === null || _c === void 0 ? void 0 : _c.max) === 'number' ? { dtype: 'num', num: props.componentProperties.max } : props.componentProperties.max) : undefined,
|
|
97
|
+
stepSize: ((_d = props.componentProperties) === null || _d === void 0 ? void 0 : _d.stepSize) ? (typeof (props.componentProperties.stepSize) === 'number' ? { dtype: 'num', num: props.componentProperties.stepSize } : props.componentProperties.stepSize) : undefined,
|
|
98
|
+
},
|
|
99
|
+
style: style.length > 0 ? style : undefined,
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
const dateInput = (props) => {
|
|
103
|
+
return {
|
|
104
|
+
key: props.key,
|
|
105
|
+
role: 'dateInput',
|
|
106
|
+
optionProps: {
|
|
107
|
+
dateInputMode: { str: props.dateInputMode },
|
|
108
|
+
min: props.minRelativeDate ? {
|
|
109
|
+
dtype: 'exp', exp: surveys_surveyEngineExpressions.SurveyEngine.timestampWithOffset(props.minRelativeDate.delta, props.minRelativeDate.reference)
|
|
110
|
+
} : undefined,
|
|
111
|
+
max: props.maxRelativeDate ? {
|
|
112
|
+
dtype: 'exp', exp: surveys_surveyEngineExpressions.SurveyEngine.timestampWithOffset(props.maxRelativeDate.delta, props.maxRelativeDate.reference ? props.maxRelativeDate.reference : undefined)
|
|
113
|
+
} : undefined,
|
|
114
|
+
},
|
|
115
|
+
content: props.inputLabelText,
|
|
116
|
+
displayCondition: props.displayCondition,
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
const timeInput = (props) => {
|
|
120
|
+
const style = [];
|
|
121
|
+
if (props.minTime) {
|
|
122
|
+
style.push({
|
|
123
|
+
key: 'minTime', value: props.minTime,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
if (props.maxTime) {
|
|
127
|
+
style.push({
|
|
128
|
+
key: 'maxTime', value: props.maxTime,
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
if (props.defaultValue) {
|
|
132
|
+
style.push({
|
|
133
|
+
key: 'defaultValue', value: props.defaultValue,
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
if (props.labelBehindInput) {
|
|
137
|
+
style.push({ key: 'labelPlacement', value: 'after' });
|
|
138
|
+
}
|
|
139
|
+
return {
|
|
140
|
+
key: props.key,
|
|
141
|
+
role: 'timeInput',
|
|
142
|
+
optionProps: {
|
|
143
|
+
stepSize: props.step,
|
|
144
|
+
},
|
|
145
|
+
content: props.inputLabelText,
|
|
146
|
+
displayCondition: props.displayCondition,
|
|
147
|
+
style: style.length > 0 ? style : undefined,
|
|
148
|
+
};
|
|
149
|
+
};
|
|
150
|
+
const dropDown = (props) => {
|
|
151
|
+
return {
|
|
152
|
+
key: props.key,
|
|
153
|
+
role: 'dropDownGroup',
|
|
154
|
+
displayCondition: props.displayCondition,
|
|
155
|
+
description: props.placeholder,
|
|
156
|
+
items: props.options,
|
|
157
|
+
};
|
|
158
|
+
};
|
|
159
|
+
const cloze = (props) => {
|
|
160
|
+
const styles = [];
|
|
161
|
+
if (props.className !== undefined) {
|
|
162
|
+
styles.push({
|
|
163
|
+
key: 'className', value: props.className
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
return {
|
|
167
|
+
key: props.key,
|
|
168
|
+
role: 'cloze',
|
|
169
|
+
items: props.items,
|
|
170
|
+
displayCondition: props.displayCondition,
|
|
171
|
+
style: styles.length > 0 ? styles : undefined,
|
|
172
|
+
};
|
|
173
|
+
};
|
|
174
|
+
const clozeLineBreak = () => {
|
|
175
|
+
return {
|
|
176
|
+
key: surveys_utils_randomKeyGenerator.generateRandomKey(5),
|
|
177
|
+
role: 'lineBreak',
|
|
178
|
+
};
|
|
179
|
+
};
|
|
180
|
+
const SingleChoiceOptionTypes = {
|
|
181
|
+
option,
|
|
182
|
+
textInput,
|
|
183
|
+
//dateInput,
|
|
184
|
+
timeInput,
|
|
185
|
+
numberInput,
|
|
186
|
+
cloze,
|
|
187
|
+
};
|
|
188
|
+
const MultipleChoiceOptionTypes = {
|
|
189
|
+
option,
|
|
190
|
+
subtitle: multipleChoiceOptionSubtitle,
|
|
191
|
+
textInput,
|
|
192
|
+
// dateInput
|
|
193
|
+
timeInput,
|
|
194
|
+
numberInput,
|
|
195
|
+
cloze,
|
|
196
|
+
};
|
|
197
|
+
const ClozeItemTypes = {
|
|
198
|
+
text: multipleChoiceOptionSubtitle,
|
|
199
|
+
markdown,
|
|
200
|
+
textInput,
|
|
201
|
+
dateInput,
|
|
202
|
+
timeInput,
|
|
203
|
+
clozeLineBreak,
|
|
204
|
+
numberInput,
|
|
205
|
+
dropDown,
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
exports.ClozeItemTypes = ClozeItemTypes;
|
|
209
|
+
exports.MultipleChoiceOptionTypes = MultipleChoiceOptionTypes;
|
|
210
|
+
exports.SingleChoiceOptionTypes = SingleChoiceOptionTypes;
|
|
211
|
+
//# sourceMappingURL=optionDefGenerators.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"optionDefGenerators.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const generateRandomKey: (length: number) => string;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const generateRandomKey = (length) => {
|
|
6
|
+
var result = '';
|
|
7
|
+
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
8
|
+
var charactersLength = characters.length;
|
|
9
|
+
for (var i = 0; i < length; i++) {
|
|
10
|
+
result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
|
11
|
+
}
|
|
12
|
+
return result;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
exports.generateRandomKey = generateRandomKey;
|
|
16
|
+
//# sourceMappingURL=randomKeyGenerator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"randomKeyGenerator.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { LocalizedString, ItemComponent, ExpressionName, Expression, ItemGroupComponent, SurveySingleItem } from "survey-engine/data_types";
|
|
2
|
+
import { DateDisplayComponentProp, StyledTextComponentProp } from "../types/item-properties";
|
|
3
|
+
export declare const generateLocStrings: (translations: Map<string, string>) => LocalizedString[];
|
|
4
|
+
export declare const generateDateDisplayComp: (key: string, item: DateDisplayComponentProp) => ItemComponent;
|
|
5
|
+
export declare const generateTitleComponent: (content: Map<string, string> | Array<StyledTextComponentProp | DateDisplayComponentProp>, description?: Map<string, string> | undefined, className?: string | undefined) => ItemComponent;
|
|
6
|
+
export declare const generateHelpGroupComponent: (items: Array<{
|
|
7
|
+
content: Map<string, string>;
|
|
8
|
+
style?: Array<{
|
|
9
|
+
key: string;
|
|
10
|
+
value: string;
|
|
11
|
+
}>;
|
|
12
|
+
}>) => ItemGroupComponent;
|
|
13
|
+
export declare const expWithArgs: (name: ExpressionName, ...args: any[]) => Expression;
|
|
14
|
+
export declare const generatePageBreak: (parentKey: string, key?: string | undefined) => SurveySingleItem;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var surveys_surveyEditor_componentEditor = require('../survey-editor/component-editor.js');
|
|
6
|
+
var surveys_types_itemProperties = require('../types/item-properties.js');
|
|
7
|
+
var surveys_utils_randomKeyGenerator = require('./randomKeyGenerator.js');
|
|
8
|
+
|
|
9
|
+
const generateLocStrings = (translations) => {
|
|
10
|
+
// console.log(translations);
|
|
11
|
+
const locString = new Array();
|
|
12
|
+
translations.forEach((value, key) => {
|
|
13
|
+
const item = {
|
|
14
|
+
code: key,
|
|
15
|
+
parts: [{ str: value }]
|
|
16
|
+
};
|
|
17
|
+
locString.push(item);
|
|
18
|
+
});
|
|
19
|
+
return locString;
|
|
20
|
+
};
|
|
21
|
+
const generateDateDisplayComp = (key, item) => {
|
|
22
|
+
// console.log(translations);
|
|
23
|
+
const styleArray = [
|
|
24
|
+
{ key: 'dateFormat', value: item.dateFormat }
|
|
25
|
+
];
|
|
26
|
+
if (item.className) {
|
|
27
|
+
styleArray.push({ key: 'className', value: item.className });
|
|
28
|
+
}
|
|
29
|
+
const locString = new Array();
|
|
30
|
+
const dateExp = item.date;
|
|
31
|
+
item.languageCodes.forEach((code) => {
|
|
32
|
+
const translatedItem = {
|
|
33
|
+
code: code,
|
|
34
|
+
parts: [{ dtype: 'exp', exp: dateExp }]
|
|
35
|
+
};
|
|
36
|
+
locString.push(translatedItem);
|
|
37
|
+
});
|
|
38
|
+
return {
|
|
39
|
+
key: key,
|
|
40
|
+
role: 'dateDisplay',
|
|
41
|
+
content: locString,
|
|
42
|
+
style: styleArray,
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
const generateTitleComponent = (content, description, className) => {
|
|
46
|
+
let items = undefined;
|
|
47
|
+
let currentContent = undefined;
|
|
48
|
+
if (Array.isArray(content)) {
|
|
49
|
+
items = content.map((item, index) => {
|
|
50
|
+
if (surveys_types_itemProperties.isDateDisplayComponentProp(item)) {
|
|
51
|
+
return generateDateDisplayComp(index.toFixed(), item);
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
key: index.toFixed(),
|
|
55
|
+
role: 'text',
|
|
56
|
+
content: generateLocStrings(item.content),
|
|
57
|
+
style: item.className ? [{ key: 'className', value: item.className }] : undefined
|
|
58
|
+
};
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
currentContent = generateLocStrings(content);
|
|
63
|
+
}
|
|
64
|
+
const style = className ? [{ key: 'className', value: className }] : undefined;
|
|
65
|
+
return {
|
|
66
|
+
role: 'title',
|
|
67
|
+
content: currentContent,
|
|
68
|
+
items: items,
|
|
69
|
+
style: style,
|
|
70
|
+
description: description ? generateLocStrings(description) : undefined,
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
const generateHelpGroupComponent = (items) => {
|
|
74
|
+
// init group
|
|
75
|
+
const groupEdit = new surveys_surveyEditor_componentEditor.ComponentEditor(undefined, {
|
|
76
|
+
isGroup: true,
|
|
77
|
+
role: 'helpGroup',
|
|
78
|
+
});
|
|
79
|
+
groupEdit.setOrder({
|
|
80
|
+
name: 'sequential'
|
|
81
|
+
});
|
|
82
|
+
items.forEach(item => {
|
|
83
|
+
const itemEditor = new surveys_surveyEditor_componentEditor.ComponentEditor(undefined, {
|
|
84
|
+
role: 'text',
|
|
85
|
+
});
|
|
86
|
+
itemEditor.setContent(generateLocStrings(item.content));
|
|
87
|
+
if (item.style) {
|
|
88
|
+
itemEditor.setStyles(item.style);
|
|
89
|
+
}
|
|
90
|
+
groupEdit.addItemComponent(itemEditor.getComponent());
|
|
91
|
+
});
|
|
92
|
+
return groupEdit.getComponent();
|
|
93
|
+
};
|
|
94
|
+
const expWithArgs = (name, ...args) => {
|
|
95
|
+
return {
|
|
96
|
+
name: name,
|
|
97
|
+
data: args.filter(a => a !== undefined).map(arg => {
|
|
98
|
+
if (typeof (arg) === 'string') {
|
|
99
|
+
return {
|
|
100
|
+
dtype: 'str',
|
|
101
|
+
str: arg
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
else if (typeof (arg) === 'number') {
|
|
105
|
+
return {
|
|
106
|
+
dtype: 'num',
|
|
107
|
+
num: arg
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
return {
|
|
111
|
+
dtype: 'exp',
|
|
112
|
+
exp: arg
|
|
113
|
+
};
|
|
114
|
+
})
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
const generatePageBreak = (parentKey, key) => {
|
|
118
|
+
return {
|
|
119
|
+
key: parentKey + '.' + (key ? key : "PB_" + surveys_utils_randomKeyGenerator.generateRandomKey(4)),
|
|
120
|
+
version: 0,
|
|
121
|
+
type: 'pageBreak'
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
exports.expWithArgs = expWithArgs;
|
|
126
|
+
exports.generateDateDisplayComp = generateDateDisplayComp;
|
|
127
|
+
exports.generateHelpGroupComponent = generateHelpGroupComponent;
|
|
128
|
+
exports.generateLocStrings = generateLocStrings;
|
|
129
|
+
exports.generatePageBreak = generatePageBreak;
|
|
130
|
+
exports.generateTitleComponent = generateTitleComponent;
|
|
131
|
+
//# sourceMappingURL=simple-generators.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"simple-generators.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ConfidentialMode, Expression, ItemComponent } from "survey-engine/data_types";
|
|
2
|
+
import { ItemEditor } from "../survey-editor/item-editor";
|
|
3
|
+
import { DateDisplayComponentProp, StyledTextComponentProp } from "../types/item-properties";
|
|
4
|
+
export declare class SimpleQuestionEditor {
|
|
5
|
+
editor: ItemEditor;
|
|
6
|
+
key: string;
|
|
7
|
+
constructor(parentKey: string, key: string, version: number, confidentialMode?: ConfidentialMode);
|
|
8
|
+
getItem(): import("survey-engine/data_types").SurveyItem;
|
|
9
|
+
setTitle(title: Map<string, string> | Array<StyledTextComponentProp | DateDisplayComponentProp>, description?: Map<string, string>, className?: string): void;
|
|
10
|
+
setCondition(exp: Expression): void;
|
|
11
|
+
addDisplayComponent(comp: ItemComponent, atPosition?: number): void;
|
|
12
|
+
addHasResponseValidation(): void;
|
|
13
|
+
setResponseGroupWithContent(content: ItemComponent): void;
|
|
14
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var constants_keyDefinitions = require('../../constants/key-definitions.js');
|
|
6
|
+
var surveys_surveyEditor_itemEditor = require('../../item-editor-59f51ecc.js');
|
|
7
|
+
var surveys_utils_simpleGenerators = require('./simple-generators.js');
|
|
8
|
+
require('../survey-editor/component-editor.js');
|
|
9
|
+
require('./randomKeyGenerator.js');
|
|
10
|
+
require('../../logger/logger.js');
|
|
11
|
+
require('../types/item-properties.js');
|
|
12
|
+
|
|
13
|
+
class SimpleQuestionEditor {
|
|
14
|
+
constructor(parentKey, key, version, confidentialMode) {
|
|
15
|
+
const itemKey = [parentKey, key].join('.');
|
|
16
|
+
this.key = itemKey;
|
|
17
|
+
this.editor = new surveys_surveyEditor_itemEditor.ItemEditor(undefined, { itemKey: itemKey, isGroup: false });
|
|
18
|
+
this.editor.setVersion(version);
|
|
19
|
+
this.editor.setConfidentialMode(confidentialMode);
|
|
20
|
+
}
|
|
21
|
+
getItem() {
|
|
22
|
+
return this.editor.getItem();
|
|
23
|
+
}
|
|
24
|
+
setTitle(title, description, className) {
|
|
25
|
+
this.editor.setTitleComponent(surveys_utils_simpleGenerators.generateTitleComponent(title, description, className));
|
|
26
|
+
}
|
|
27
|
+
setCondition(exp) {
|
|
28
|
+
this.editor.setCondition(exp);
|
|
29
|
+
}
|
|
30
|
+
addDisplayComponent(comp, atPosition) {
|
|
31
|
+
this.editor.addDisplayComponent(comp, atPosition);
|
|
32
|
+
}
|
|
33
|
+
addHasResponseValidation() {
|
|
34
|
+
this.editor.addValidation({
|
|
35
|
+
key: 'r1',
|
|
36
|
+
type: 'hard',
|
|
37
|
+
rule: surveys_utils_simpleGenerators.expWithArgs('hasResponse', this.key, constants_keyDefinitions.responseGroupKey)
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
setResponseGroupWithContent(content) {
|
|
41
|
+
const rg = this.editor.addNewResponseComponent({ role: 'responseGroup' });
|
|
42
|
+
this.editor.addExistingResponseComponent(content, rg === null || rg === void 0 ? void 0 : rg.key);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
exports.SimpleQuestionEditor = SimpleQuestionEditor;
|
|
47
|
+
//# sourceMappingURL=simple-question-editor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"simple-question-editor.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const durationObjectToSeconds = (duration) => {
|
|
6
|
+
let value = 0;
|
|
7
|
+
if (duration.years !== undefined) {
|
|
8
|
+
value += duration.years * 31536000;
|
|
9
|
+
}
|
|
10
|
+
if (duration.months !== undefined) {
|
|
11
|
+
value += duration.months * 2592000;
|
|
12
|
+
}
|
|
13
|
+
if (duration.days !== undefined) {
|
|
14
|
+
value += duration.days * 86400;
|
|
15
|
+
}
|
|
16
|
+
if (duration.hours !== undefined) {
|
|
17
|
+
value += duration.hours * 3600;
|
|
18
|
+
}
|
|
19
|
+
if (duration.minutes !== undefined) {
|
|
20
|
+
value += duration.minutes * 60;
|
|
21
|
+
}
|
|
22
|
+
if (duration.seconds !== undefined) {
|
|
23
|
+
value += duration.seconds;
|
|
24
|
+
}
|
|
25
|
+
return value;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
exports.durationObjectToSeconds = durationObjectToSeconds;
|
|
29
|
+
//# sourceMappingURL=duration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"duration.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Expression, ExpressionArg } from "survey-engine/data_types";
|
|
2
|
+
export declare const isExpression: (value: Expression | any) => value is Expression;
|
|
3
|
+
export declare type ExpressionArgDType = 'exp' | 'num' | 'str';
|
|
4
|
+
export declare const expressionArgParser: (arg: ExpressionArg) => any;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const isExpression = (value) => {
|
|
6
|
+
return typeof (value) === 'object' && value.name !== undefined && value.name.length > 0;
|
|
7
|
+
};
|
|
8
|
+
const expressionArgParser = (arg) => {
|
|
9
|
+
switch (arg.dtype) {
|
|
10
|
+
case 'num':
|
|
11
|
+
return arg.num;
|
|
12
|
+
case 'str':
|
|
13
|
+
return arg.str;
|
|
14
|
+
case 'exp':
|
|
15
|
+
return arg.exp;
|
|
16
|
+
default:
|
|
17
|
+
return arg.str;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
exports.expressionArgParser = expressionArgParser;
|
|
22
|
+
exports.isExpression = isExpression;
|
|
23
|
+
//# sourceMappingURL=expression.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expression.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Expression } from "survey-engine/data_types";
|
|
2
|
+
import { Duration } from "./duration";
|
|
3
|
+
export declare type MessageType = 'registration' | 'invitation' | 'verify-email' | 'verification-code' | 'password-reset' | 'password-changed' | 'account-id-changed' | 'weekly' | 'study-reminder' | 'newsletter' | 'account-deleted';
|
|
4
|
+
export interface MessageConfig {
|
|
5
|
+
sendTo: 'study-participants' | 'all-users' | 'scheduled-participant-messages';
|
|
6
|
+
label: string;
|
|
7
|
+
headerOverrides?: {
|
|
8
|
+
from: string;
|
|
9
|
+
sender: string;
|
|
10
|
+
replyTo: string[];
|
|
11
|
+
};
|
|
12
|
+
messageType: MessageType;
|
|
13
|
+
sendingTime: {
|
|
14
|
+
hour: number;
|
|
15
|
+
minute: number;
|
|
16
|
+
};
|
|
17
|
+
period: Duration;
|
|
18
|
+
defaultLanguage: string;
|
|
19
|
+
condition?: Expression;
|
|
20
|
+
translations: Array<{
|
|
21
|
+
lang: string;
|
|
22
|
+
subject: string;
|
|
23
|
+
}>;
|
|
24
|
+
}
|
|
25
|
+
export declare const buildMessageConfig: (props: MessageConfig, studyKey: string) => {
|
|
26
|
+
sendTo: "study-participants" | "all-users" | "scheduled-participant-messages";
|
|
27
|
+
studyKey: string;
|
|
28
|
+
label: string;
|
|
29
|
+
headerOverrides: {
|
|
30
|
+
from: string;
|
|
31
|
+
sender: string;
|
|
32
|
+
replyTo: string[];
|
|
33
|
+
} | undefined;
|
|
34
|
+
messageType: MessageType;
|
|
35
|
+
sendingTime: {
|
|
36
|
+
hour: number;
|
|
37
|
+
minute: number;
|
|
38
|
+
};
|
|
39
|
+
condition: {
|
|
40
|
+
dtype: string;
|
|
41
|
+
exp: Expression | undefined;
|
|
42
|
+
};
|
|
43
|
+
period: number;
|
|
44
|
+
defaultLanguage: string;
|
|
45
|
+
translations: {
|
|
46
|
+
lang: string;
|
|
47
|
+
subject: string;
|
|
48
|
+
}[];
|
|
49
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var types_duration = require('./duration.js');
|
|
6
|
+
|
|
7
|
+
const buildMessageConfig = (props, studyKey) => {
|
|
8
|
+
return {
|
|
9
|
+
sendTo: props.sendTo,
|
|
10
|
+
studyKey: studyKey,
|
|
11
|
+
label: props.label,
|
|
12
|
+
headerOverrides: props.headerOverrides,
|
|
13
|
+
messageType: props.messageType,
|
|
14
|
+
sendingTime: props.sendingTime,
|
|
15
|
+
condition: { dtype: 'exp', exp: props.condition },
|
|
16
|
+
period: Math.floor(types_duration.durationObjectToSeconds(props.period)),
|
|
17
|
+
defaultLanguage: props.defaultLanguage,
|
|
18
|
+
translations: props.translations,
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
exports.buildMessageConfig = buildMessageConfig;
|
|
23
|
+
//# sourceMappingURL=messageConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messageConfig.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;"}
|
package/types/study.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Expression } from "survey-engine/data_types";
|
|
2
|
+
import { StudyRules } from "./studyRules";
|
|
3
|
+
import { SurveyDefinition } from "../surveys/types/survey-definition";
|
|
4
|
+
import { MessageConfig } from "./messageConfig";
|
|
5
|
+
export interface Study {
|
|
6
|
+
studyKey: string;
|
|
7
|
+
outputFolderName?: string;
|
|
8
|
+
surveys: SurveyDefinition[];
|
|
9
|
+
studyRules?: StudyRules;
|
|
10
|
+
customStudyRules?: Array<{
|
|
11
|
+
name: string;
|
|
12
|
+
rules: Expression[];
|
|
13
|
+
}>;
|
|
14
|
+
messageConfigs?: Array<MessageConfig>;
|
|
15
|
+
}
|
package/types/study.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"study.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Expression } from 'survey-engine/data_types';
|
|
2
|
+
export declare class StudyRules {
|
|
3
|
+
private enterRules?;
|
|
4
|
+
private submitRules?;
|
|
5
|
+
private timerRules?;
|
|
6
|
+
private mergeRules?;
|
|
7
|
+
constructor(enterRules?: Expression[], submitRules?: Expression[], timerRules?: Expression[], mergeRules?: Expression[]);
|
|
8
|
+
get(): Expression[];
|
|
9
|
+
}
|