case-editor-tools 1.0.0-beta.16 → 1.0.0-beta.17

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.
Files changed (113) hide show
  1. package/constants/key-definitions.d.ts +14 -0
  2. package/constants/key-definitions.js +34 -0
  3. package/constants/key-definitions.js.map +1 -0
  4. package/exporter/index.d.ts +2 -0
  5. package/exporter/index.js +99 -0
  6. package/exporter/index.js.map +1 -0
  7. package/expression-utils/expressionGen.d.ts +2 -0
  8. package/{src/expression-utils/expressionGen.ts → expression-utils/expressionGen.js} +29 -26
  9. package/expression-utils/expressionGen.js.map +1 -0
  10. package/expression-utils/studyEngineExpressions.d.ts +114 -0
  11. package/expression-utils/studyEngineExpressions.js +283 -0
  12. package/expression-utils/studyEngineExpressions.js.map +1 -0
  13. package/{CHANGELOG.md → index.d.ts} +0 -0
  14. package/index.js +3 -0
  15. package/index.js.map +1 -0
  16. package/item-editor-7f825952.js +522 -0
  17. package/item-editor-7f825952.js.map +1 -0
  18. package/{src/logger/index.ts → logger/index.d.ts} +1 -1
  19. package/logger/index.js +10 -0
  20. package/logger/index.js.map +1 -0
  21. package/logger/logger.d.ts +9 -0
  22. package/logger/logger.js +31 -0
  23. package/logger/logger.js.map +1 -0
  24. package/package.json +1 -1
  25. package/{src/surveys/index.ts → surveys/index.d.ts} +3 -3
  26. package/surveys/index.js +26 -0
  27. package/surveys/index.js.map +1 -0
  28. package/surveys/survey-editor/component-editor.d.ts +84 -0
  29. package/surveys/survey-editor/component-editor.js +112 -0
  30. package/surveys/survey-editor/component-editor.js.map +1 -0
  31. package/{src/surveys/survey-editor/data-types.ts → surveys/survey-editor/data-types.d.ts} +13 -18
  32. package/surveys/survey-editor/data-types.js +3 -0
  33. package/surveys/survey-editor/data-types.js.map +1 -0
  34. package/surveys/survey-editor/item-editor.d.ts +65 -0
  35. package/surveys/survey-editor/item-editor.js +13 -0
  36. package/surveys/survey-editor/item-editor.js.map +1 -0
  37. package/surveys/survey-editor/survey-editor.d.ts +43 -0
  38. package/surveys/survey-editor/survey-editor.js +231 -0
  39. package/surveys/survey-editor/survey-editor.js.map +1 -0
  40. package/surveys/survey-engine-expressions.d.ts +120 -0
  41. package/surveys/survey-engine-expressions.js +407 -0
  42. package/surveys/survey-engine-expressions.js.map +1 -0
  43. package/surveys/survey-items.d.ts +133 -0
  44. package/surveys/survey-items.js +1051 -0
  45. package/surveys/survey-items.js.map +1 -0
  46. package/surveys/types/group.d.ts +23 -0
  47. package/surveys/types/group.js +71 -0
  48. package/surveys/types/group.js.map +1 -0
  49. package/{src/surveys/types/index.ts → surveys/types/index.d.ts} +4 -4
  50. package/surveys/types/index.js +20 -0
  51. package/surveys/types/index.js.map +1 -0
  52. package/surveys/types/item-properties.d.ts +189 -0
  53. package/surveys/types/item-properties.js +3 -0
  54. package/surveys/types/item-properties.js.map +1 -0
  55. package/{src/surveys/types/item.ts → surveys/types/item.d.ts} +22 -42
  56. package/surveys/types/item.js +34 -0
  57. package/surveys/types/item.js.map +1 -0
  58. package/surveys/types/survey-definition.d.ts +19 -0
  59. package/surveys/types/survey-definition.js +60 -0
  60. package/surveys/types/survey-definition.js.map +1 -0
  61. package/surveys/utils/componentGenerators.d.ts +24 -0
  62. package/surveys/utils/componentGenerators.js +58 -0
  63. package/surveys/utils/componentGenerators.js.map +1 -0
  64. package/surveys/utils/optionDefGenerators.d.ts +69 -0
  65. package/surveys/utils/optionDefGenerators.js +169 -0
  66. package/surveys/utils/optionDefGenerators.js.map +1 -0
  67. package/surveys/utils/randomKeyGenerator.d.ts +1 -0
  68. package/{src/surveys/utils/randomKeyGenerator.ts → surveys/utils/randomKeyGenerator.js} +14 -9
  69. package/surveys/utils/randomKeyGenerator.js.map +1 -0
  70. package/surveys/utils/simple-generators.d.ts +13 -0
  71. package/surveys/utils/simple-generators.js +102 -0
  72. package/surveys/utils/simple-generators.js.map +1 -0
  73. package/surveys/utils/simple-question-editor.d.ts +14 -0
  74. package/surveys/utils/simple-question-editor.js +45 -0
  75. package/surveys/utils/simple-question-editor.js.map +1 -0
  76. package/types/duration.d.ts +9 -0
  77. package/{src/types/duration.ts → types/duration.js} +27 -30
  78. package/types/duration.js.map +1 -0
  79. package/types/expression.d.ts +4 -0
  80. package/types/expression.js +23 -0
  81. package/types/expression.js.map +1 -0
  82. package/types/study.d.ts +13 -0
  83. package/types/study.js +3 -0
  84. package/types/study.js.map +1 -0
  85. package/types/studyRules.d.ts +8 -0
  86. package/types/studyRules.js +32 -0
  87. package/types/studyRules.js.map +1 -0
  88. package/.editorconfig +0 -13
  89. package/LICENSE +0 -202
  90. package/publish.sh +0 -9
  91. package/readme.md +0 -18
  92. package/rollup.config.js +0 -49
  93. package/src/constants/key-definitions.ts +0 -14
  94. package/src/exporter/index.ts +0 -101
  95. package/src/expression-utils/studyEngineExpressions.ts +0 -359
  96. package/src/index.ts +0 -1
  97. package/src/logger/logger.ts +0 -31
  98. package/src/surveys/survey-editor/component-editor.ts +0 -133
  99. package/src/surveys/survey-editor/item-editor.ts +0 -529
  100. package/src/surveys/survey-editor/survey-editor.ts +0 -261
  101. package/src/surveys/survey-engine-expressions.ts +0 -483
  102. package/src/surveys/survey-items.ts +0 -1490
  103. package/src/surveys/types/group.ts +0 -73
  104. package/src/surveys/types/item-properties.ts +0 -204
  105. package/src/surveys/types/survey-definition.ts +0 -83
  106. package/src/surveys/utils/componentGenerators.ts +0 -76
  107. package/src/surveys/utils/optionDefGenerators.ts +0 -195
  108. package/src/surveys/utils/simple-generators.ts +0 -106
  109. package/src/surveys/utils/simple-question-editor.ts +0 -52
  110. package/src/types/expression.ts +0 -22
  111. package/src/types/study.ts +0 -17
  112. package/src/types/studyRules.ts +0 -39
  113. package/tsconfig.json +0 -100
@@ -0,0 +1,69 @@
1
+ import { Expression } from "survey-engine/lib/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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1 @@
1
+ export declare const generateRandomKey: (length: number) => string;
@@ -1,11 +1,16 @@
1
+ 'use strict';
1
2
 
3
+ Object.defineProperty(exports, '__esModule', { value: true });
2
4
 
3
- export const generateRandomKey = (length: number): string => {
4
- var result = '';
5
- var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
6
- var charactersLength = characters.length;
7
- for (var i = 0; i < length; i++) {
8
- result += characters.charAt(Math.floor(Math.random() * charactersLength));
9
- }
10
- return result;
11
- }
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,13 @@
1
+ import { LocalizedString, ItemComponent, ExpressionName, Expression, ItemGroupComponent, SurveySingleItem } from "survey-engine/lib/data_types";
2
+ import { StyledTextComponentProp } from "../types/item-properties";
3
+ export declare const generateLocStrings: (translations: Map<string, string>) => LocalizedString[];
4
+ export declare const generateTitleComponent: (content: Map<string, string> | Array<StyledTextComponentProp>, description?: Map<string, string> | undefined, className?: string | undefined) => ItemComponent;
5
+ export declare const generateHelpGroupComponent: (items: Array<{
6
+ content: Map<string, string>;
7
+ style?: Array<{
8
+ key: string;
9
+ value: string;
10
+ }>;
11
+ }>) => ItemGroupComponent;
12
+ export declare const expWithArgs: (name: ExpressionName, ...args: any[]) => Expression;
13
+ export declare const generatePageBreak: (parentKey: string, key?: string | undefined) => SurveySingleItem;
@@ -0,0 +1,102 @@
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_randomKeyGenerator = require('./randomKeyGenerator.js');
7
+
8
+ const generateLocStrings = (translations) => {
9
+ // console.log(translations);
10
+ const locString = new Array();
11
+ translations.forEach((value, key) => {
12
+ const item = {
13
+ code: key,
14
+ parts: [{ str: value }]
15
+ };
16
+ locString.push(item);
17
+ });
18
+ return locString;
19
+ };
20
+ const generateTitleComponent = (content, description, className) => {
21
+ let items = undefined;
22
+ let currentContent = undefined;
23
+ if (Array.isArray(content)) {
24
+ items = content.map((item, index) => {
25
+ return {
26
+ key: index.toFixed(),
27
+ role: 'text',
28
+ content: generateLocStrings(item.content),
29
+ style: item.className ? [{ key: 'className', value: item.className }] : undefined
30
+ };
31
+ });
32
+ }
33
+ else {
34
+ currentContent = generateLocStrings(content);
35
+ }
36
+ const style = className ? [{ key: 'className', value: className }] : undefined;
37
+ return {
38
+ role: 'title',
39
+ content: currentContent,
40
+ items: items,
41
+ style: style,
42
+ description: description ? generateLocStrings(description) : undefined,
43
+ };
44
+ };
45
+ const generateHelpGroupComponent = (items) => {
46
+ // init group
47
+ const groupEdit = new surveys_surveyEditor_componentEditor.ComponentEditor(undefined, {
48
+ isGroup: true,
49
+ role: 'helpGroup',
50
+ });
51
+ groupEdit.setOrder({
52
+ name: 'sequential'
53
+ });
54
+ items.forEach(item => {
55
+ const itemEditor = new surveys_surveyEditor_componentEditor.ComponentEditor(undefined, {
56
+ role: 'text',
57
+ });
58
+ itemEditor.setContent(generateLocStrings(item.content));
59
+ if (item.style) {
60
+ itemEditor.setStyles(item.style);
61
+ }
62
+ groupEdit.addItemComponent(itemEditor.getComponent());
63
+ });
64
+ return groupEdit.getComponent();
65
+ };
66
+ const expWithArgs = (name, ...args) => {
67
+ return {
68
+ name: name,
69
+ data: args.filter(a => a !== undefined).map(arg => {
70
+ if (typeof (arg) === 'string') {
71
+ return {
72
+ dtype: 'str',
73
+ str: arg
74
+ };
75
+ }
76
+ else if (typeof (arg) === 'number') {
77
+ return {
78
+ dtype: 'num',
79
+ num: arg
80
+ };
81
+ }
82
+ return {
83
+ dtype: 'exp',
84
+ exp: arg
85
+ };
86
+ })
87
+ };
88
+ };
89
+ const generatePageBreak = (parentKey, key) => {
90
+ return {
91
+ key: parentKey + '.' + (key ? key : "PB_" + surveys_utils_randomKeyGenerator.generateRandomKey(4)),
92
+ version: 0,
93
+ type: 'pageBreak'
94
+ };
95
+ };
96
+
97
+ exports.expWithArgs = expWithArgs;
98
+ exports.generateHelpGroupComponent = generateHelpGroupComponent;
99
+ exports.generateLocStrings = generateLocStrings;
100
+ exports.generatePageBreak = generatePageBreak;
101
+ exports.generateTitleComponent = generateTitleComponent;
102
+ //# 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 { Expression, ItemComponent } from "survey-engine/lib/data_types";
2
+ import { ItemEditor } from "../survey-editor/item-editor";
3
+ import { StyledTextComponentProp } from "../types/item-properties";
4
+ export declare class SimpleQuestionEditor {
5
+ editor: ItemEditor;
6
+ key: string;
7
+ constructor(parentKey: string, key: string, version: number);
8
+ getItem(): import("survey-engine/lib/data_types").SurveyItem;
9
+ setTitle(title: Map<string, string> | Array<StyledTextComponentProp>, 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,45 @@
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-7f825952.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
+
12
+ class SimpleQuestionEditor {
13
+ constructor(parentKey, key, version) {
14
+ const itemKey = [parentKey, key].join('.');
15
+ this.key = itemKey;
16
+ this.editor = new surveys_surveyEditor_itemEditor.ItemEditor(undefined, { itemKey: itemKey, isGroup: false });
17
+ this.editor.setVersion(version);
18
+ }
19
+ getItem() {
20
+ return this.editor.getItem();
21
+ }
22
+ setTitle(title, description, className) {
23
+ this.editor.setTitleComponent(surveys_utils_simpleGenerators.generateTitleComponent(title, description, className));
24
+ }
25
+ setCondition(exp) {
26
+ this.editor.setCondition(exp);
27
+ }
28
+ addDisplayComponent(comp, atPosition) {
29
+ this.editor.addDisplayComponent(comp, atPosition);
30
+ }
31
+ addHasResponseValidation() {
32
+ this.editor.addValidation({
33
+ key: 'r1',
34
+ type: 'hard',
35
+ rule: surveys_utils_simpleGenerators.expWithArgs('hasResponse', this.key, constants_keyDefinitions.responseGroupKey)
36
+ });
37
+ }
38
+ setResponseGroupWithContent(content) {
39
+ const rg = this.editor.addNewResponseComponent({ role: 'responseGroup' });
40
+ this.editor.addExistingResponseComponent(content, rg === null || rg === void 0 ? void 0 : rg.key);
41
+ }
42
+ }
43
+
44
+ exports.SimpleQuestionEditor = SimpleQuestionEditor;
45
+ //# sourceMappingURL=simple-question-editor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"simple-question-editor.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,9 @@
1
+ export interface Duration {
2
+ years?: number;
3
+ months?: number;
4
+ days?: number;
5
+ hours?: number;
6
+ minutes?: number;
7
+ seconds?: number;
8
+ }
9
+ export declare const durationObjectToSeconds: (duration: Duration) => number;
@@ -1,32 +1,29 @@
1
- export interface Duration {
2
- years?: number;
3
- months?: number;
4
- days?: number;
5
- hours?: number;
6
- minutes?: number;
7
- seconds?: number;
8
- };
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
9
4
 
10
- export const durationObjectToSeconds = (duration: Duration): number => {
11
- let value = 0;
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
+ };
12
27
 
13
- if (duration.years !== undefined) {
14
- value += duration.years * 31536000;
15
- }
16
- if (duration.months !== undefined) {
17
- value += duration.months * 2592000;
18
- }
19
- if (duration.days !== undefined) {
20
- value += duration.days * 86400;
21
- }
22
- if (duration.hours !== undefined) {
23
- value += duration.hours * 3600;
24
- }
25
- if (duration.minutes !== undefined) {
26
- value += duration.minutes * 60;
27
- }
28
- if (duration.seconds !== undefined) {
29
- value += duration.seconds;
30
- }
31
- return value;
32
- }
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/lib/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,13 @@
1
+ import { Expression } from "survey-engine/lib/data_types";
2
+ import { StudyRules } from "./studyRules";
3
+ import { SurveyDefinition } from "../surveys/types/survey-definition";
4
+ export interface Study {
5
+ studyKey: string;
6
+ outputFolderName?: string;
7
+ surveys: SurveyDefinition[];
8
+ studyRules?: StudyRules;
9
+ customStudyRules?: Array<{
10
+ name: string;
11
+ rules: Expression[];
12
+ }>;
13
+ }
package/types/study.js ADDED
@@ -0,0 +1,3 @@
1
+ 'use strict';
2
+
3
+ //# sourceMappingURL=study.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"study.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
@@ -0,0 +1,8 @@
1
+ import { Expression } from 'survey-engine/lib/data_types';
2
+ export declare class StudyRules {
3
+ private enterRules?;
4
+ private submitRules?;
5
+ private timerRules?;
6
+ constructor(enterRules?: Expression[], submitRules?: Expression[], timerRules?: Expression[]);
7
+ get(): Expression[];
8
+ }
@@ -0,0 +1,32 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var expressionUtils_studyEngineExpressions = require('../expression-utils/studyEngineExpressions.js');
6
+ require('../constants/key-definitions.js');
7
+ require('./duration.js');
8
+ require('../expression-utils/expressionGen.js');
9
+
10
+ class StudyRules {
11
+ constructor(enterRules, submitRules, timerRules) {
12
+ this.enterRules = enterRules;
13
+ this.submitRules = submitRules;
14
+ this.timerRules = timerRules;
15
+ }
16
+ get() {
17
+ const rules = [];
18
+ if (this.enterRules) {
19
+ rules.push(expressionUtils_studyEngineExpressions.StudyEngine.ifThen(expressionUtils_studyEngineExpressions.StudyEngine.checkEventType('ENTER'), ...this.enterRules));
20
+ }
21
+ if (this.submitRules) {
22
+ rules.push(expressionUtils_studyEngineExpressions.StudyEngine.ifThen(expressionUtils_studyEngineExpressions.StudyEngine.checkEventType('SUBMIT'), ...this.submitRules));
23
+ }
24
+ if (this.timerRules) {
25
+ rules.push(expressionUtils_studyEngineExpressions.StudyEngine.ifThen(expressionUtils_studyEngineExpressions.StudyEngine.checkEventType('TIMER'), ...this.timerRules));
26
+ }
27
+ return rules;
28
+ }
29
+ }
30
+
31
+ exports.StudyRules = StudyRules;
32
+ //# sourceMappingURL=studyRules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"studyRules.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/.editorconfig DELETED
@@ -1,13 +0,0 @@
1
- # Editor configuration, see https://editorconfig.org
2
- root = true
3
-
4
- [*]
5
- charset = utf-8
6
- indent_style = space
7
- indent_size = 2
8
- insert_final_newline = true
9
- trim_trailing_whitespace = true
10
-
11
- [*.md]
12
- max_line_length = off
13
- trim_trailing_whitespace = false