case-editor-tools 1.0.0-beta.17 → 1.0.0-beta.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/surveys/index.js +2 -0
- package/surveys/index.js.map +1 -1
- 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/surveys/survey-items.d.ts +10 -78
- package/surveys/survey-items.js +65 -848
- package/surveys/survey-items.js.map +1 -1
|
@@ -0,0 +1,125 @@
|
|
|
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_utils_simpleGenerators = require('../utils/simple-generators.js');
|
|
7
|
+
require('../utils/randomKeyGenerator.js');
|
|
8
|
+
|
|
9
|
+
const optionDefToItemComponent = (optionDef) => {
|
|
10
|
+
const isGroup = optionDef.items && optionDef.items.length > 0;
|
|
11
|
+
const optEditor = new surveys_surveyEditor_componentEditor.ComponentEditor(undefined, {
|
|
12
|
+
key: optionDef.key,
|
|
13
|
+
role: optionDef.role,
|
|
14
|
+
isGroup: isGroup
|
|
15
|
+
});
|
|
16
|
+
if (isGroup) {
|
|
17
|
+
optEditor.setOrder({
|
|
18
|
+
name: 'sequential'
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
if (optionDef.content) {
|
|
22
|
+
optEditor.setContent(surveys_utils_simpleGenerators.generateLocStrings(optionDef.content));
|
|
23
|
+
}
|
|
24
|
+
if (optionDef.description) {
|
|
25
|
+
optEditor.setDescription(surveys_utils_simpleGenerators.generateLocStrings(optionDef.description));
|
|
26
|
+
}
|
|
27
|
+
switch (optionDef.role) {
|
|
28
|
+
case 'date':
|
|
29
|
+
optEditor.setDType('date');
|
|
30
|
+
break;
|
|
31
|
+
case 'numberInput':
|
|
32
|
+
optEditor.setDType('number');
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
if (optionDef.displayCondition) {
|
|
36
|
+
optEditor.setDisplayCondition(optionDef.displayCondition);
|
|
37
|
+
}
|
|
38
|
+
if (optionDef.disabled) {
|
|
39
|
+
optEditor.setDisabled(optionDef.disabled);
|
|
40
|
+
}
|
|
41
|
+
if (optionDef.style) {
|
|
42
|
+
optEditor.setStyles(optionDef.style);
|
|
43
|
+
}
|
|
44
|
+
if (optionDef.optionProps) {
|
|
45
|
+
if (typeof (optionDef.optionProps.min) === 'number') {
|
|
46
|
+
optionDef.optionProps.min = { dtype: 'num', num: optionDef.optionProps.min };
|
|
47
|
+
}
|
|
48
|
+
if (typeof (optionDef.optionProps.max) === 'number') {
|
|
49
|
+
optionDef.optionProps.max = { dtype: 'num', num: optionDef.optionProps.max };
|
|
50
|
+
}
|
|
51
|
+
if (typeof (optionDef.optionProps.stepSize) === 'number') {
|
|
52
|
+
optionDef.optionProps.stepSize = { dtype: 'num', num: optionDef.optionProps.stepSize };
|
|
53
|
+
}
|
|
54
|
+
optEditor.setProperties(optionDef.optionProps);
|
|
55
|
+
}
|
|
56
|
+
if (optionDef.items) {
|
|
57
|
+
if (optionDef.role === 'text') {
|
|
58
|
+
optionDef.items.forEach((item, index) => {
|
|
59
|
+
const textItem = item;
|
|
60
|
+
optEditor.addItemComponent({
|
|
61
|
+
key: index.toFixed(),
|
|
62
|
+
role: 'text',
|
|
63
|
+
content: surveys_utils_simpleGenerators.generateLocStrings(textItem.content),
|
|
64
|
+
style: textItem.className ? [{ key: 'className', value: textItem.className }] : undefined
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
optionDef.items.forEach((item) => {
|
|
70
|
+
const clozeItem = item;
|
|
71
|
+
const comp = optionDefToItemComponent(clozeItem);
|
|
72
|
+
optEditor.addItemComponent(comp);
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return optEditor.getComponent();
|
|
77
|
+
};
|
|
78
|
+
const initResponseGroup = (type, key, optionItems, order, groupDisabled, groupContent, groupDescription) => {
|
|
79
|
+
// init group
|
|
80
|
+
const groupEdit = new surveys_surveyEditor_componentEditor.ComponentEditor(undefined, {
|
|
81
|
+
key: key,
|
|
82
|
+
isGroup: true,
|
|
83
|
+
role: type,
|
|
84
|
+
});
|
|
85
|
+
groupEdit.setOrder(order ? order : {
|
|
86
|
+
name: 'sequential'
|
|
87
|
+
});
|
|
88
|
+
if (groupDisabled) {
|
|
89
|
+
groupEdit.setDisabled(groupDisabled);
|
|
90
|
+
}
|
|
91
|
+
if (groupContent) {
|
|
92
|
+
groupEdit.setContent(groupContent);
|
|
93
|
+
}
|
|
94
|
+
if (groupDescription) {
|
|
95
|
+
groupEdit.setDescription(groupDescription);
|
|
96
|
+
}
|
|
97
|
+
// add option items
|
|
98
|
+
optionItems.forEach(optionDef => {
|
|
99
|
+
groupEdit.addItemComponent(optionDefToItemComponent(optionDef));
|
|
100
|
+
});
|
|
101
|
+
return groupEdit.getComponent();
|
|
102
|
+
};
|
|
103
|
+
const initSingleChoiceGroup = (key, optionItems, order) => {
|
|
104
|
+
// init group
|
|
105
|
+
return initResponseGroup('singleChoiceGroup', key, optionItems, order);
|
|
106
|
+
};
|
|
107
|
+
const initMultipleChoiceGroup = (key, optionItems, order) => {
|
|
108
|
+
// init group
|
|
109
|
+
return initResponseGroup('multipleChoiceGroup', key, optionItems, order);
|
|
110
|
+
};
|
|
111
|
+
const initDropdownGroup = (key, optionItems, order, groupDisabled, groupContent, groupDescription) => {
|
|
112
|
+
// init group
|
|
113
|
+
return initResponseGroup('dropDownGroup', key, optionItems, order, groupDisabled, groupContent ? surveys_utils_simpleGenerators.generateLocStrings(groupContent) : undefined, groupDescription ? surveys_utils_simpleGenerators.generateLocStrings(groupDescription) : undefined);
|
|
114
|
+
};
|
|
115
|
+
const initSliderCategoricalGroup = (key, optionItems, order, groupDisabled) => {
|
|
116
|
+
// init group
|
|
117
|
+
return initResponseGroup('sliderCategorical', key, optionItems, order, groupDisabled);
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
exports.initDropdownGroup = initDropdownGroup;
|
|
121
|
+
exports.initMultipleChoiceGroup = initMultipleChoiceGroup;
|
|
122
|
+
exports.initSingleChoiceGroup = initSingleChoiceGroup;
|
|
123
|
+
exports.initSliderCategoricalGroup = initSliderCategoricalGroup;
|
|
124
|
+
exports.optionDefToItemComponent = optionDefToItemComponent;
|
|
125
|
+
//# sourceMappingURL=optionGroupComponents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"optionGroupComponents.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { ItemGroupComponent, Expression,
|
|
2
|
-
import { ClozeQuestionProps, DateInputQuestionProps, GenericQuestionProps, MultiLineTextInput, NumericInputQuestionProps, OptionDef,
|
|
1
|
+
import { ItemGroupComponent, Expression, ItemComponent, SurveyItem, ExpressionArg, ResponseItem } from "survey-engine/lib/data_types";
|
|
2
|
+
import { ClozeQuestionProps, DateInputQuestionProps, GenericQuestionProps, MultiLineTextInput, NumericInputQuestionProps, OptionDef, ResponsiveBipolarLikertArrayQuestionProps, ResponsiveSingleChoiceArrayQuestionProps, TextInputQuestionProps } from "./types/item-properties";
|
|
3
|
+
import { LikertGroupRow } from "./responseTypeGenerators/likertGroupComponents";
|
|
3
4
|
interface OptionQuestionProps extends GenericQuestionProps {
|
|
4
5
|
responseOptions: Array<OptionDef>;
|
|
5
6
|
}
|
|
@@ -19,63 +20,18 @@ interface NumericSliderProps extends GenericQuestionProps {
|
|
|
19
20
|
max?: number | ExpressionArg;
|
|
20
21
|
stepSize?: number | ExpressionArg;
|
|
21
22
|
}
|
|
23
|
+
interface CustomResponseItem extends ResponseItem {
|
|
24
|
+
mapToRole?: 'singleChoiceGroup' | 'multipleChoiceGroup' | 'input';
|
|
25
|
+
}
|
|
26
|
+
interface CustomQuestionProps extends GenericQuestionProps {
|
|
27
|
+
responseItemDef: CustomResponseItem;
|
|
28
|
+
}
|
|
22
29
|
interface DisplayProps {
|
|
23
30
|
parentKey: string;
|
|
24
31
|
itemKey: string;
|
|
25
32
|
content: Array<ItemComponent>;
|
|
26
33
|
condition?: Expression;
|
|
27
34
|
}
|
|
28
|
-
export declare const initSingleChoiceGroup: (key: string, optionItems: OptionDef[], order?: Expression | undefined) => ItemGroupComponent;
|
|
29
|
-
export declare const initMultipleChoiceGroup: (key: string, optionItems: OptionDef[], order?: Expression | undefined) => ItemGroupComponent;
|
|
30
|
-
export declare const initDropdownGroup: (key: string, optionItems: OptionDef[], order?: Expression | undefined, groupDisabled?: Expression | undefined, groupContent?: Map<string, string> | undefined, groupDescription?: Map<string, string> | undefined) => ItemGroupComponent;
|
|
31
|
-
export declare const initSliderCategoricalGroup: (key: string, optionItems: OptionDef[], order?: Expression | undefined, groupDisabled?: Expression | undefined) => ItemGroupComponent;
|
|
32
|
-
interface HeaderRow {
|
|
33
|
-
role: 'headerRow';
|
|
34
|
-
key: string;
|
|
35
|
-
displayCondition?: Expression;
|
|
36
|
-
disabled?: Expression;
|
|
37
|
-
cells: Array<{
|
|
38
|
-
role: 'text';
|
|
39
|
-
key: string;
|
|
40
|
-
content?: Map<string, string>;
|
|
41
|
-
description?: Map<string, string>;
|
|
42
|
-
}>;
|
|
43
|
-
}
|
|
44
|
-
interface RadioRow {
|
|
45
|
-
role: 'radioRow';
|
|
46
|
-
key: string;
|
|
47
|
-
displayCondition?: Expression;
|
|
48
|
-
disabled?: Expression;
|
|
49
|
-
cells: Array<{
|
|
50
|
-
role: 'label' | 'option';
|
|
51
|
-
key: string;
|
|
52
|
-
content?: Map<string, string>;
|
|
53
|
-
description?: Map<string, string>;
|
|
54
|
-
}>;
|
|
55
|
-
}
|
|
56
|
-
export interface ResponseRowCell {
|
|
57
|
-
role: 'label' | 'check' | 'input' | 'numberInput' | 'dropDownGroup';
|
|
58
|
-
key: string;
|
|
59
|
-
content?: Map<string, string>;
|
|
60
|
-
description?: Map<string, string>;
|
|
61
|
-
properties?: ComponentProperties;
|
|
62
|
-
items?: Array<{
|
|
63
|
-
role: 'option';
|
|
64
|
-
key: string;
|
|
65
|
-
content?: Map<string, string>;
|
|
66
|
-
disabled?: Expression;
|
|
67
|
-
displayCondition?: Expression;
|
|
68
|
-
}>;
|
|
69
|
-
}
|
|
70
|
-
interface ResponseRow {
|
|
71
|
-
role: 'responseRow';
|
|
72
|
-
key: string;
|
|
73
|
-
displayCondition?: Expression;
|
|
74
|
-
disabled?: Expression;
|
|
75
|
-
cells: Array<ResponseRowCell>;
|
|
76
|
-
}
|
|
77
|
-
declare type MatrixRow = HeaderRow | RadioRow | ResponseRow;
|
|
78
|
-
export declare const initMatrixQuestion: (key: string, rows: Array<MatrixRow>, order?: Expression | undefined) => ItemGroupComponent;
|
|
79
35
|
interface EQ5DHealthSliderProps {
|
|
80
36
|
role: 'eq5d-health-indicator';
|
|
81
37
|
key: string;
|
|
@@ -87,31 +43,6 @@ interface EQ5DHealthSliderProps {
|
|
|
87
43
|
minHealthText: Map<string, string>;
|
|
88
44
|
}
|
|
89
45
|
export declare const initEQ5DHealthIndicatorQuestion: (props: EQ5DHealthSliderProps) => ItemGroupComponent;
|
|
90
|
-
interface LikertGroupRow {
|
|
91
|
-
key: string;
|
|
92
|
-
content: Map<string, string>;
|
|
93
|
-
descriptions?: ItemComponent[];
|
|
94
|
-
hideTopBorder?: boolean;
|
|
95
|
-
hideLabels?: boolean;
|
|
96
|
-
optionDisabled?: Array<{
|
|
97
|
-
optionKey: string;
|
|
98
|
-
exp: Expression;
|
|
99
|
-
}>;
|
|
100
|
-
displayCondition?: Expression;
|
|
101
|
-
}
|
|
102
|
-
export declare const initLikertScaleGroup: (key: string, rows: Array<LikertGroupRow>, scaleOptions: {
|
|
103
|
-
key: string;
|
|
104
|
-
className?: string | undefined;
|
|
105
|
-
content: Map<string, string>;
|
|
106
|
-
}[], stackOnSmallScreen?: boolean | undefined, displayCondition?: Expression | undefined) => ItemGroupComponent;
|
|
107
|
-
export declare const initResponsiveSingleChoiceArray: (rgKey: string, props: ResponsiveSingleChoiceArrayProps, displayCondition?: Expression | undefined) => ItemGroupComponent;
|
|
108
|
-
export declare const initResponsiveBipolarLikertArray: (rgKey: string, props: ResponsiveBipolarLikertArrayProps, displayCondition?: Expression | undefined) => ItemGroupComponent;
|
|
109
|
-
export declare const initLikertScaleItem: (key: string, options: {
|
|
110
|
-
key: string;
|
|
111
|
-
className?: string | undefined;
|
|
112
|
-
content?: Map<string, string> | undefined;
|
|
113
|
-
disabled?: Expression | undefined;
|
|
114
|
-
}[], stackOnSmallScreen?: boolean | undefined, displayCondition?: Expression | undefined) => ItemGroupComponent;
|
|
115
46
|
export declare const SurveyItems: {
|
|
116
47
|
singleChoice: (props: OptionQuestionProps) => SurveyItem;
|
|
117
48
|
responsiveSingleChoiceArray: (props: ResponsiveSingleChoiceArrayQuestionProps) => SurveyItem;
|
|
@@ -126,6 +57,7 @@ export declare const SurveyItems: {
|
|
|
126
57
|
numericSlider: (props: NumericSliderProps) => SurveyItem;
|
|
127
58
|
display: (props: DisplayProps) => SurveyItem;
|
|
128
59
|
surveyEnd: (parentKey: string, content: Map<string, string>, condition?: Expression | undefined) => SurveyItem;
|
|
60
|
+
customQuestion: (props: CustomQuestionProps) => SurveyItem;
|
|
129
61
|
old: {
|
|
130
62
|
simpleLikertGroup: (props: LikertGroupQuestionProps) => SurveyItem;
|
|
131
63
|
};
|