case-editor-tools 1.0.0-beta.2 → 1.0.0-beta.23
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 +3 -3
- package/{build/expression-utils → expression-utils}/studyEngineExpressions.js +0 -0
- package/{build/expression-utils → expression-utils}/studyEngineExpressions.js.map +0 -0
- 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 +9 -12
- 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} +1 -1
- package/{build/expression-utils/surveyEngineExpressions.js → surveys/survey-engine-expressions.js} +2 -2
- 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} +5 -2
- package/{build/types/surveyDefinition.js → surveys/types/survey-definition.js} +12 -10
- 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/LICENSE +0 -202
- package/build/item-editor-8fd24b61.js.map +0 -1
- 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
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { ComponentProperties, 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 OptionDef {
|
|
8
|
+
key: string;
|
|
9
|
+
role: string;
|
|
10
|
+
content?: Map<string, string>;
|
|
11
|
+
items?: Array<StyledTextComponentProp> | Array<OptionDef>;
|
|
12
|
+
description?: Map<string, string>;
|
|
13
|
+
displayCondition?: Expression;
|
|
14
|
+
disabled?: Expression;
|
|
15
|
+
style?: Array<{
|
|
16
|
+
key: string;
|
|
17
|
+
value: string;
|
|
18
|
+
}>;
|
|
19
|
+
optionProps?: ComponentProperties;
|
|
20
|
+
}
|
|
21
|
+
export interface GenericQuestionProps {
|
|
22
|
+
parentKey: string;
|
|
23
|
+
itemKey: string;
|
|
24
|
+
version?: number;
|
|
25
|
+
questionText: Map<string, string> | Array<StyledTextComponentProp>;
|
|
26
|
+
questionSubText?: Map<string, string>;
|
|
27
|
+
titleClassName?: string;
|
|
28
|
+
helpGroupContent?: Array<{
|
|
29
|
+
content: Map<string, string>;
|
|
30
|
+
style?: Array<{
|
|
31
|
+
key: string;
|
|
32
|
+
value: string;
|
|
33
|
+
}>;
|
|
34
|
+
}>;
|
|
35
|
+
condition?: Expression;
|
|
36
|
+
topDisplayCompoments?: Array<ItemComponent>;
|
|
37
|
+
bottomDisplayCompoments?: Array<ItemComponent>;
|
|
38
|
+
isRequired?: boolean;
|
|
39
|
+
footnoteText?: Map<string, string>;
|
|
40
|
+
customValidations?: Array<Validation>;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Numeric Input
|
|
44
|
+
*/
|
|
45
|
+
export interface NumericInputProps {
|
|
46
|
+
inputLabel: Map<string, string>;
|
|
47
|
+
labelBehindInput?: boolean;
|
|
48
|
+
componentProperties?: ComponentProperties;
|
|
49
|
+
inputMaxWidth?: string;
|
|
50
|
+
disabled?: Expression;
|
|
51
|
+
}
|
|
52
|
+
export declare type NumericInputQuestionProps = GenericQuestionProps & NumericInputProps;
|
|
53
|
+
/**
|
|
54
|
+
* Date Input
|
|
55
|
+
*/
|
|
56
|
+
export interface DateInputProps {
|
|
57
|
+
dateInputMode: 'YMD' | 'YM' | 'Y';
|
|
58
|
+
inputLabelText?: Map<string, string>;
|
|
59
|
+
placeholderText?: Map<string, string>;
|
|
60
|
+
minRelativeDate?: {
|
|
61
|
+
reference?: number | Expression;
|
|
62
|
+
delta: Duration;
|
|
63
|
+
};
|
|
64
|
+
maxRelativeDate?: {
|
|
65
|
+
reference?: number | Expression;
|
|
66
|
+
delta: Duration;
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
export declare type DateInputQuestionProps = DateInputProps & GenericQuestionProps;
|
|
70
|
+
/**
|
|
71
|
+
* Text Input
|
|
72
|
+
*/
|
|
73
|
+
export interface TextInputProps {
|
|
74
|
+
placeholderText?: Map<string, string>;
|
|
75
|
+
inputLabel?: Map<string, string>;
|
|
76
|
+
inputMaxWidth?: string;
|
|
77
|
+
className?: string;
|
|
78
|
+
maxLength?: number;
|
|
79
|
+
disabled?: Expression;
|
|
80
|
+
}
|
|
81
|
+
export declare type TextInputQuestionProps = TextInputProps & GenericQuestionProps;
|
|
82
|
+
export interface MultiLineTextInput extends GenericQuestionProps {
|
|
83
|
+
inputLabelText?: Map<string, string>;
|
|
84
|
+
placeholderText?: Map<string, string>;
|
|
85
|
+
maxLength?: number;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Cloze Question
|
|
89
|
+
*/
|
|
90
|
+
export interface ClozeProps {
|
|
91
|
+
items: Array<OptionDef>;
|
|
92
|
+
}
|
|
93
|
+
export declare type ClozeQuestionProps = ClozeProps & GenericQuestionProps;
|
|
94
|
+
/**
|
|
95
|
+
* Response Single Choice Likert Array
|
|
96
|
+
*/
|
|
97
|
+
export declare type ResponsiveSingleChoiceArrayVariant = 'horizontal' | 'vertical' | 'table';
|
|
98
|
+
export interface ResponsiveSingleChoiceArrayProps {
|
|
99
|
+
scaleOptions: Array<{
|
|
100
|
+
key: string;
|
|
101
|
+
className?: string;
|
|
102
|
+
content: Map<string, string> | StyledTextComponentProp[];
|
|
103
|
+
}>;
|
|
104
|
+
rows: Array<{
|
|
105
|
+
key: string;
|
|
106
|
+
content: Map<string, string> | StyledTextComponentProp[];
|
|
107
|
+
horizontalModeProps?: {
|
|
108
|
+
labelPlacement?: 'none' | 'top' | 'bottom';
|
|
109
|
+
className?: string;
|
|
110
|
+
};
|
|
111
|
+
verticalModeProps?: {
|
|
112
|
+
className?: string;
|
|
113
|
+
};
|
|
114
|
+
tableModeProps?: {
|
|
115
|
+
className?: string;
|
|
116
|
+
};
|
|
117
|
+
}>;
|
|
118
|
+
defaultMode: ResponsiveSingleChoiceArrayVariant;
|
|
119
|
+
responsiveModes?: {
|
|
120
|
+
sm?: ResponsiveSingleChoiceArrayVariant;
|
|
121
|
+
md?: ResponsiveSingleChoiceArrayVariant;
|
|
122
|
+
lg?: ResponsiveSingleChoiceArrayVariant;
|
|
123
|
+
xl?: ResponsiveSingleChoiceArrayVariant;
|
|
124
|
+
xxl?: ResponsiveSingleChoiceArrayVariant;
|
|
125
|
+
};
|
|
126
|
+
rgClassName?: string;
|
|
127
|
+
tableModeProps?: {
|
|
128
|
+
className?: string;
|
|
129
|
+
layout?: "fixed";
|
|
130
|
+
firstColWidth?: string;
|
|
131
|
+
optionHeaderClassName?: string;
|
|
132
|
+
hideRowBorder?: boolean;
|
|
133
|
+
};
|
|
134
|
+
horizontalModeProps?: {
|
|
135
|
+
hideRowBorder?: boolean;
|
|
136
|
+
};
|
|
137
|
+
verticalModeProps?: {
|
|
138
|
+
hideRowBorder?: boolean;
|
|
139
|
+
useReverseOptionOrder?: boolean;
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
export declare type ResponsiveSingleChoiceArrayQuestionProps = GenericQuestionProps & ResponsiveSingleChoiceArrayProps;
|
|
143
|
+
/**
|
|
144
|
+
* Response Bipolar Likert Array
|
|
145
|
+
*/
|
|
146
|
+
export declare type ResponsiveBipolarLikertArrayVariant = 'withLabelRow' | 'vertical' | 'table';
|
|
147
|
+
export interface ResponsiveBipolarLikertArrayProps {
|
|
148
|
+
scaleOptions: Array<{
|
|
149
|
+
key: string;
|
|
150
|
+
}>;
|
|
151
|
+
rows: Array<{
|
|
152
|
+
key: string;
|
|
153
|
+
startLabel: Map<string, string> | StyledTextComponentProp[];
|
|
154
|
+
endLabel: Map<string, string> | StyledTextComponentProp[];
|
|
155
|
+
withLabelRowModeProps?: {
|
|
156
|
+
className?: string;
|
|
157
|
+
};
|
|
158
|
+
verticalModeProps?: {
|
|
159
|
+
className?: string;
|
|
160
|
+
};
|
|
161
|
+
tableModeProps?: {
|
|
162
|
+
className?: string;
|
|
163
|
+
};
|
|
164
|
+
}>;
|
|
165
|
+
defaultMode: ResponsiveBipolarLikertArrayVariant;
|
|
166
|
+
responsiveModes?: {
|
|
167
|
+
sm?: ResponsiveBipolarLikertArrayVariant;
|
|
168
|
+
md?: ResponsiveBipolarLikertArrayVariant;
|
|
169
|
+
lg?: ResponsiveBipolarLikertArrayVariant;
|
|
170
|
+
xl?: ResponsiveBipolarLikertArrayVariant;
|
|
171
|
+
xxl?: ResponsiveBipolarLikertArrayVariant;
|
|
172
|
+
};
|
|
173
|
+
rgClassName?: string;
|
|
174
|
+
tableModeProps?: {
|
|
175
|
+
className?: string;
|
|
176
|
+
layout?: "fixed";
|
|
177
|
+
labelColWidth?: string;
|
|
178
|
+
hideRowBorder?: boolean;
|
|
179
|
+
};
|
|
180
|
+
withLabelRowModeProps?: {
|
|
181
|
+
hideRowBorder?: boolean;
|
|
182
|
+
maxLabelWidth?: string;
|
|
183
|
+
useBottomLabel?: boolean;
|
|
184
|
+
};
|
|
185
|
+
verticalModeProps?: {
|
|
186
|
+
hideRowBorder?: boolean;
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
export declare type ResponsiveBipolarLikertArrayQuestionProps = GenericQuestionProps & ResponsiveBipolarLikertArrayProps;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"item-properties.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
|
|
File without changes
|
|
File without changes
|
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
import { SurveyItem } from "survey-engine/
|
|
1
|
+
import { SurveyItem } from "survey-engine/data_types";
|
|
2
2
|
import { SurveyEditor } from "../survey-editor/survey-editor";
|
|
3
|
+
export declare type SurveyAvailableFor = 'public' | 'temporary_participants' | 'active_participants';
|
|
3
4
|
export interface SurveyProps {
|
|
4
5
|
surveyKey: string;
|
|
5
6
|
name: Map<string, string>;
|
|
6
7
|
description: Map<string, string>;
|
|
7
8
|
durationText: Map<string, string>;
|
|
9
|
+
availableFor?: SurveyAvailableFor;
|
|
10
|
+
requireLoginBeforeSubmission?: boolean;
|
|
8
11
|
}
|
|
9
12
|
export declare abstract class SurveyDefinition {
|
|
10
13
|
key: string;
|
|
11
14
|
editor: SurveyEditor;
|
|
12
15
|
constructor(props: SurveyProps);
|
|
13
16
|
abstract buildSurvey(): void;
|
|
14
|
-
getSurvey(): import("survey-engine/
|
|
17
|
+
getSurvey(): import("survey-engine/data_types").Survey;
|
|
15
18
|
getSurveyJSON(pretty?: boolean): string;
|
|
16
19
|
addItem(item: SurveyItem): void;
|
|
17
20
|
addSurveyItemToPath(item: SurveyItem, parentKey: string): void;
|
|
@@ -2,23 +2,25 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var logger_logger = require('
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
5
|
+
var logger_logger = require('../../logger/logger.js');
|
|
6
|
+
var surveys_surveyEditor_itemEditor = require('../../item-editor-c6933791.js');
|
|
7
|
+
var surveys_surveyEditor_surveyEditor = require('../survey-editor/survey-editor.js');
|
|
8
|
+
var surveys_utils_simpleGenerators = require('../utils/simple-generators.js');
|
|
9
9
|
require('../survey-editor/component-editor.js');
|
|
10
10
|
require('../utils/randomKeyGenerator.js');
|
|
11
11
|
|
|
12
12
|
class SurveyDefinition {
|
|
13
13
|
constructor(props) {
|
|
14
|
-
this.editor = new
|
|
14
|
+
this.editor = new surveys_surveyEditor_surveyEditor.SurveyEditor();
|
|
15
15
|
this.editor.changeItemKey('survey', props.surveyKey);
|
|
16
16
|
this.key = props.surveyKey;
|
|
17
17
|
// define name and description of the survey
|
|
18
|
-
this.editor.setSurveyName(
|
|
19
|
-
this.editor.setSurveyDescription(
|
|
20
|
-
this.editor.setSurveyDuration(
|
|
21
|
-
|
|
18
|
+
this.editor.setSurveyName(surveys_utils_simpleGenerators.generateLocStrings(props.name));
|
|
19
|
+
this.editor.setSurveyDescription(surveys_utils_simpleGenerators.generateLocStrings(props.description));
|
|
20
|
+
this.editor.setSurveyDuration(surveys_utils_simpleGenerators.generateLocStrings(props.durationText));
|
|
21
|
+
this.editor.setAvailableFor(props.availableFor);
|
|
22
|
+
this.editor.setRequireLoginBeforeSubmission(props.requireLoginBeforeSubmission);
|
|
23
|
+
const rootItemEditor = new surveys_surveyEditor_itemEditor.ItemEditor(this.editor.findSurveyItem(props.surveyKey));
|
|
22
24
|
rootItemEditor.setSelectionMethod({ name: 'sequential' });
|
|
23
25
|
this.editor.updateSurveyItem(rootItemEditor.getItem());
|
|
24
26
|
}
|
|
@@ -57,4 +59,4 @@ class SurveyDefinition {
|
|
|
57
59
|
}
|
|
58
60
|
|
|
59
61
|
exports.SurveyDefinition = SurveyDefinition;
|
|
60
|
-
//# sourceMappingURL=
|
|
62
|
+
//# sourceMappingURL=survey-definition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"survey-definition.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,19 +1,10 @@
|
|
|
1
|
-
import { Expression, ItemComponent } from "survey-engine/
|
|
2
|
-
import {
|
|
1
|
+
import { Expression, ItemComponent } from "survey-engine/data_types";
|
|
2
|
+
import { StyledTextComponentProp } from "../types/item-properties";
|
|
3
3
|
interface CommonProps {
|
|
4
4
|
key?: string;
|
|
5
5
|
content?: Map<string, string> | StyledTextComponentProp[];
|
|
6
6
|
displayCondition?: Expression;
|
|
7
7
|
}
|
|
8
|
-
interface OptionProps extends CommonProps {
|
|
9
|
-
key: string;
|
|
10
|
-
disabled?: Expression;
|
|
11
|
-
className?: string;
|
|
12
|
-
}
|
|
13
|
-
interface OptionTextProps extends CommonProps {
|
|
14
|
-
key: string;
|
|
15
|
-
className?: string;
|
|
16
|
-
}
|
|
17
8
|
interface TextProps extends CommonProps {
|
|
18
9
|
content: Map<string, string>;
|
|
19
10
|
variant?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'p' | 'li';
|
|
@@ -24,8 +15,6 @@ interface MarkdownProps extends CommonProps {
|
|
|
24
15
|
className?: string;
|
|
25
16
|
}
|
|
26
17
|
export declare const ComponentGenerators: {
|
|
27
|
-
option: (props: OptionProps) => OptionDef;
|
|
28
|
-
multipleChoiceOptionSubtitle: (props: OptionTextProps) => OptionDef;
|
|
29
18
|
footnote: (props: {
|
|
30
19
|
content: Map<string, string>;
|
|
31
20
|
}) => ItemComponent;
|
|
@@ -0,0 +1,58 @@
|
|
|
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
|
+
|
|
9
|
+
const text = (props) => {
|
|
10
|
+
const styles = [];
|
|
11
|
+
if (props.className !== undefined) {
|
|
12
|
+
styles.push({
|
|
13
|
+
key: 'className', value: props.className
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
if (props.variant !== undefined) {
|
|
17
|
+
styles.push({
|
|
18
|
+
key: 'variant', value: props.variant
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return {
|
|
22
|
+
key: surveys_utils_randomKeyGenerator.generateRandomKey(3),
|
|
23
|
+
role: 'text',
|
|
24
|
+
style: styles.length > 0 ? styles : undefined,
|
|
25
|
+
content: surveys_utils_simpleGenerators.generateLocStrings(props.content),
|
|
26
|
+
displayCondition: props.displayCondition,
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
const markdown = (props) => {
|
|
30
|
+
const styles = [];
|
|
31
|
+
if (props.className !== undefined) {
|
|
32
|
+
styles.push({
|
|
33
|
+
key: 'className', value: props.className
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
key: surveys_utils_randomKeyGenerator.generateRandomKey(3),
|
|
38
|
+
role: 'markdown',
|
|
39
|
+
style: styles.length > 0 ? styles : undefined,
|
|
40
|
+
content: surveys_utils_simpleGenerators.generateLocStrings(props.content),
|
|
41
|
+
displayCondition: props.displayCondition,
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
const footnote = (props) => {
|
|
45
|
+
return {
|
|
46
|
+
role: 'footnote', content: surveys_utils_simpleGenerators.generateLocStrings(props.content), style: [
|
|
47
|
+
{ key: 'className', value: 'fs-small fst-italic text-center' }
|
|
48
|
+
]
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
const ComponentGenerators = {
|
|
52
|
+
footnote,
|
|
53
|
+
text,
|
|
54
|
+
markdown,
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
exports.ComponentGenerators = ComponentGenerators;
|
|
58
|
+
//# sourceMappingURL=componentGenerators.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"componentGenerators.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"componentGenerators.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Expression } from "survey-engine/data_types";
|
|
2
|
+
import { ClozeProps, DateInputProps, NumericInputProps, OptionDef, StyledTextComponentProp, TextInputProps } 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
|
+
numberInput: (props: NumericInputProps & {
|
|
23
|
+
key: string;
|
|
24
|
+
displayCondition?: Expression;
|
|
25
|
+
}) => OptionDef;
|
|
26
|
+
cloze: (props: ClozeProps & {
|
|
27
|
+
key: string;
|
|
28
|
+
displayCondition?: Expression;
|
|
29
|
+
}) => OptionDef;
|
|
30
|
+
};
|
|
31
|
+
export declare const MultipleChoiceOptionTypes: {
|
|
32
|
+
option: (key: string, content: Map<string, string> | StyledTextComponentProp[], extraProps?: OptionProps | undefined) => OptionDef;
|
|
33
|
+
subtitle: (props: OptionTextProps) => OptionDef;
|
|
34
|
+
textInput: (props: TextInputProps & {
|
|
35
|
+
key: string;
|
|
36
|
+
displayCondition?: Expression;
|
|
37
|
+
}) => OptionDef;
|
|
38
|
+
numberInput: (props: NumericInputProps & {
|
|
39
|
+
key: string;
|
|
40
|
+
displayCondition?: Expression;
|
|
41
|
+
}) => OptionDef;
|
|
42
|
+
cloze: (props: ClozeProps & {
|
|
43
|
+
key: string;
|
|
44
|
+
displayCondition?: Expression;
|
|
45
|
+
}) => OptionDef;
|
|
46
|
+
};
|
|
47
|
+
export declare const ClozeItemTypes: {
|
|
48
|
+
text: (props: OptionTextProps) => OptionDef;
|
|
49
|
+
markdown: (props: OptionTextProps) => OptionDef;
|
|
50
|
+
textInput: (props: TextInputProps & {
|
|
51
|
+
key: string;
|
|
52
|
+
displayCondition?: Expression;
|
|
53
|
+
}) => OptionDef;
|
|
54
|
+
dateInput: (props: DateInputProps & {
|
|
55
|
+
key: string;
|
|
56
|
+
displayCondition?: Expression;
|
|
57
|
+
}) => OptionDef;
|
|
58
|
+
clozeLineBreak: () => OptionDef;
|
|
59
|
+
numberInput: (props: NumericInputProps & {
|
|
60
|
+
key: string;
|
|
61
|
+
displayCondition?: Expression;
|
|
62
|
+
}) => OptionDef;
|
|
63
|
+
dropDown: (props: {
|
|
64
|
+
key: string;
|
|
65
|
+
displayCondition?: Expression;
|
|
66
|
+
options: Array<OptionDef>;
|
|
67
|
+
}) => OptionDef;
|
|
68
|
+
};
|
|
69
|
+
export {};
|
|
@@ -0,0 +1,169 @@
|
|
|
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 dropDown = (props) => {
|
|
120
|
+
return {
|
|
121
|
+
key: props.key,
|
|
122
|
+
role: 'dropDownGroup',
|
|
123
|
+
displayCondition: props.displayCondition,
|
|
124
|
+
items: props.options,
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
const cloze = (props) => {
|
|
128
|
+
return {
|
|
129
|
+
key: props.key,
|
|
130
|
+
role: 'cloze',
|
|
131
|
+
items: props.items,
|
|
132
|
+
displayCondition: props.displayCondition,
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
const clozeLineBreak = () => {
|
|
136
|
+
return {
|
|
137
|
+
key: surveys_utils_randomKeyGenerator.generateRandomKey(5),
|
|
138
|
+
role: 'lineBreak',
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
const SingleChoiceOptionTypes = {
|
|
142
|
+
option,
|
|
143
|
+
textInput,
|
|
144
|
+
//dateInput,
|
|
145
|
+
numberInput,
|
|
146
|
+
cloze,
|
|
147
|
+
};
|
|
148
|
+
const MultipleChoiceOptionTypes = {
|
|
149
|
+
option,
|
|
150
|
+
subtitle: multipleChoiceOptionSubtitle,
|
|
151
|
+
textInput,
|
|
152
|
+
// dateInput,
|
|
153
|
+
numberInput,
|
|
154
|
+
cloze,
|
|
155
|
+
};
|
|
156
|
+
const ClozeItemTypes = {
|
|
157
|
+
text: multipleChoiceOptionSubtitle,
|
|
158
|
+
markdown,
|
|
159
|
+
textInput,
|
|
160
|
+
dateInput,
|
|
161
|
+
clozeLineBreak,
|
|
162
|
+
numberInput,
|
|
163
|
+
dropDown,
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
exports.ClozeItemTypes = ClozeItemTypes;
|
|
167
|
+
exports.MultipleChoiceOptionTypes = MultipleChoiceOptionTypes;
|
|
168
|
+
exports.SingleChoiceOptionTypes = SingleChoiceOptionTypes;
|
|
169
|
+
//# sourceMappingURL=optionDefGenerators.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"optionDefGenerators.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { LocalizedString, ItemComponent, ExpressionName, Expression, ItemGroupComponent, SurveySingleItem } from "survey-engine/
|
|
2
|
-
import { StyledTextComponentProp } from "
|
|
1
|
+
import { LocalizedString, ItemComponent, ExpressionName, Expression, ItemGroupComponent, SurveySingleItem } from "survey-engine/data_types";
|
|
2
|
+
import { StyledTextComponentProp } from "../types/item-properties";
|
|
3
3
|
export declare const generateLocStrings: (translations: Map<string, string>) => LocalizedString[];
|
|
4
4
|
export declare const generateTitleComponent: (content: Map<string, string> | Array<StyledTextComponentProp>, description?: Map<string, string> | undefined, className?: string | undefined) => ItemComponent;
|
|
5
5
|
export declare const generateHelpGroupComponent: (items: Array<{
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
6
|
-
var
|
|
5
|
+
var surveys_surveyEditor_componentEditor = require('../survey-editor/component-editor.js');
|
|
6
|
+
var surveys_utils_randomKeyGenerator = require('./randomKeyGenerator.js');
|
|
7
7
|
|
|
8
8
|
const generateLocStrings = (translations) => {
|
|
9
9
|
// console.log(translations);
|
|
@@ -44,7 +44,7 @@ const generateTitleComponent = (content, description, className) => {
|
|
|
44
44
|
};
|
|
45
45
|
const generateHelpGroupComponent = (items) => {
|
|
46
46
|
// init group
|
|
47
|
-
const groupEdit = new
|
|
47
|
+
const groupEdit = new surveys_surveyEditor_componentEditor.ComponentEditor(undefined, {
|
|
48
48
|
isGroup: true,
|
|
49
49
|
role: 'helpGroup',
|
|
50
50
|
});
|
|
@@ -52,7 +52,7 @@ const generateHelpGroupComponent = (items) => {
|
|
|
52
52
|
name: 'sequential'
|
|
53
53
|
});
|
|
54
54
|
items.forEach(item => {
|
|
55
|
-
const itemEditor = new
|
|
55
|
+
const itemEditor = new surveys_surveyEditor_componentEditor.ComponentEditor(undefined, {
|
|
56
56
|
role: 'text',
|
|
57
57
|
});
|
|
58
58
|
itemEditor.setContent(generateLocStrings(item.content));
|
|
@@ -88,7 +88,7 @@ const expWithArgs = (name, ...args) => {
|
|
|
88
88
|
};
|
|
89
89
|
const generatePageBreak = (parentKey, key) => {
|
|
90
90
|
return {
|
|
91
|
-
key: parentKey + '.' + (key ? key : "PB_" +
|
|
91
|
+
key: parentKey + '.' + (key ? key : "PB_" + surveys_utils_randomKeyGenerator.generateRandomKey(4)),
|
|
92
92
|
version: 0,
|
|
93
93
|
type: 'pageBreak'
|
|
94
94
|
};
|
|
File without changes
|