case-editor-tools 1.0.0-beta.15 → 1.0.0-beta.19

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 (49) hide show
  1. package/constants/key-definitions.d.ts +1 -0
  2. package/constants/key-definitions.js +3 -1
  3. package/constants/key-definitions.js.map +1 -1
  4. package/expression-utils/expressionGen.d.ts +1 -1
  5. package/expression-utils/studyEngineExpressions.d.ts +1 -1
  6. package/{item-editor-7f825952.js → item-editor-c6933791.js} +61 -44
  7. package/item-editor-c6933791.js.map +1 -0
  8. package/package.json +5 -5
  9. package/surveys/index.js +3 -1
  10. package/surveys/index.js.map +1 -1
  11. package/surveys/responseTypeGenerators/likertGroupComponents.d.ts +27 -0
  12. package/surveys/responseTypeGenerators/likertGroupComponents.js +347 -0
  13. package/surveys/responseTypeGenerators/likertGroupComponents.js.map +1 -0
  14. package/surveys/responseTypeGenerators/matrixGroupComponent.d.ts +49 -0
  15. package/surveys/responseTypeGenerators/matrixGroupComponent.js +99 -0
  16. package/surveys/responseTypeGenerators/matrixGroupComponent.js.map +1 -0
  17. package/surveys/responseTypeGenerators/optionGroupComponents.d.ts +7 -0
  18. package/surveys/responseTypeGenerators/optionGroupComponents.js +125 -0
  19. package/surveys/responseTypeGenerators/optionGroupComponents.js.map +1 -0
  20. package/surveys/survey-editor/component-editor.d.ts +1 -1
  21. package/surveys/survey-editor/data-types.d.ts +1 -1
  22. package/surveys/survey-editor/item-editor.d.ts +1 -1
  23. package/surveys/survey-editor/item-editor.js +1 -1
  24. package/surveys/survey-editor/survey-editor.d.ts +6 -1
  25. package/surveys/survey-editor/survey-editor.js +9 -3
  26. package/surveys/survey-editor/survey-editor.js.map +1 -1
  27. package/surveys/survey-engine-expressions.d.ts +1 -1
  28. package/surveys/survey-items.d.ts +11 -78
  29. package/surveys/survey-items.js +76 -826
  30. package/surveys/survey-items.js.map +1 -1
  31. package/surveys/types/group.d.ts +1 -1
  32. package/surveys/types/group.js +1 -1
  33. package/surveys/types/index.js +1 -1
  34. package/surveys/types/item-properties.d.ts +1 -1
  35. package/surveys/types/item.d.ts +1 -1
  36. package/surveys/types/survey-definition.d.ts +5 -2
  37. package/surveys/types/survey-definition.js +3 -1
  38. package/surveys/types/survey-definition.js.map +1 -1
  39. package/surveys/utils/componentGenerators.d.ts +1 -1
  40. package/surveys/utils/optionDefGenerators.d.ts +2 -1
  41. package/surveys/utils/optionDefGenerators.js +7 -0
  42. package/surveys/utils/optionDefGenerators.js.map +1 -1
  43. package/surveys/utils/simple-generators.d.ts +1 -1
  44. package/surveys/utils/simple-question-editor.d.ts +2 -2
  45. package/surveys/utils/simple-question-editor.js +1 -1
  46. package/types/expression.d.ts +1 -1
  47. package/types/study.d.ts +1 -1
  48. package/types/studyRules.d.ts +1 -1
  49. package/item-editor-7f825952.js.map +0 -1
@@ -0,0 +1,49 @@
1
+ import { ComponentProperties, Expression, ItemGroupComponent } from "survey-engine/data_types";
2
+ interface HeaderRow {
3
+ role: 'headerRow';
4
+ key: string;
5
+ displayCondition?: Expression;
6
+ disabled?: Expression;
7
+ cells: Array<{
8
+ role: 'text';
9
+ key: string;
10
+ content?: Map<string, string>;
11
+ description?: Map<string, string>;
12
+ }>;
13
+ }
14
+ interface RadioRow {
15
+ role: 'radioRow';
16
+ key: string;
17
+ displayCondition?: Expression;
18
+ disabled?: Expression;
19
+ cells: Array<{
20
+ role: 'label' | 'option';
21
+ key: string;
22
+ content?: Map<string, string>;
23
+ description?: Map<string, string>;
24
+ }>;
25
+ }
26
+ export interface ResponseRowCell {
27
+ role: 'label' | 'check' | 'input' | 'numberInput' | 'dropDownGroup';
28
+ key: string;
29
+ content?: Map<string, string>;
30
+ description?: Map<string, string>;
31
+ properties?: ComponentProperties;
32
+ items?: Array<{
33
+ role: 'option';
34
+ key: string;
35
+ content?: Map<string, string>;
36
+ disabled?: Expression;
37
+ displayCondition?: Expression;
38
+ }>;
39
+ }
40
+ interface ResponseRow {
41
+ role: 'responseRow';
42
+ key: string;
43
+ displayCondition?: Expression;
44
+ disabled?: Expression;
45
+ cells: Array<ResponseRowCell>;
46
+ }
47
+ declare type MatrixRow = HeaderRow | RadioRow | ResponseRow;
48
+ export declare const initMatrixQuestion: (key: string, rows: Array<MatrixRow>, order?: Expression | undefined) => ItemGroupComponent;
49
+ export {};
@@ -0,0 +1,99 @@
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 initMatrixQuestion = (key, rows, order) => {
10
+ // init group
11
+ const groupEdit = new surveys_surveyEditor_componentEditor.ComponentEditor(undefined, {
12
+ key: key,
13
+ isGroup: true,
14
+ role: 'matrix',
15
+ });
16
+ groupEdit.setOrder(order ? order : {
17
+ name: 'sequential'
18
+ });
19
+ // init rows
20
+ rows.forEach(rowDef => {
21
+ const rowEditor = new surveys_surveyEditor_componentEditor.ComponentEditor(undefined, {
22
+ key: rowDef.key,
23
+ role: rowDef.role,
24
+ });
25
+ if (rowDef.displayCondition) {
26
+ rowEditor.setDisplayCondition(rowDef.displayCondition);
27
+ }
28
+ if (rowDef.disabled) {
29
+ rowEditor.setDisabled(rowDef.disabled);
30
+ }
31
+ switch (rowDef.role) {
32
+ case 'headerRow':
33
+ rowDef.cells.forEach(cell => {
34
+ const cellEditor = new surveys_surveyEditor_componentEditor.ComponentEditor(undefined, {
35
+ key: cell.key,
36
+ role: cell.role,
37
+ });
38
+ if (cell.content) {
39
+ cellEditor.setContent(surveys_utils_simpleGenerators.generateLocStrings(cell.content));
40
+ }
41
+ if (cell.description) {
42
+ cellEditor.setDescription(surveys_utils_simpleGenerators.generateLocStrings(cell.description));
43
+ }
44
+ rowEditor.addItemComponent(cellEditor.getComponent());
45
+ });
46
+ break;
47
+ case 'radioRow':
48
+ rowDef.cells.forEach(cell => {
49
+ const cellEditor = new surveys_surveyEditor_componentEditor.ComponentEditor(undefined, {
50
+ key: cell.key,
51
+ role: cell.role,
52
+ });
53
+ if (cell.content) {
54
+ cellEditor.setContent(surveys_utils_simpleGenerators.generateLocStrings(cell.content));
55
+ }
56
+ if (cell.description) {
57
+ cellEditor.setDescription(surveys_utils_simpleGenerators.generateLocStrings(cell.description));
58
+ }
59
+ rowEditor.addItemComponent(cellEditor.getComponent());
60
+ });
61
+ break;
62
+ case 'responseRow':
63
+ rowDef.cells.forEach(cell => {
64
+ const cellEditor = new surveys_surveyEditor_componentEditor.ComponentEditor(undefined, {
65
+ key: cell.key,
66
+ role: cell.role,
67
+ });
68
+ if (cell.content) {
69
+ cellEditor.setContent(surveys_utils_simpleGenerators.generateLocStrings(cell.content));
70
+ }
71
+ if (cell.description) {
72
+ cellEditor.setDescription(surveys_utils_simpleGenerators.generateLocStrings(cell.description));
73
+ }
74
+ cellEditor.setProperties(cell.properties);
75
+ if (cell.items) {
76
+ cell.items.forEach(opt => {
77
+ const cellOptionEditor = new surveys_surveyEditor_componentEditor.ComponentEditor(undefined, {
78
+ key: opt.key,
79
+ role: opt.role,
80
+ });
81
+ if (opt.content) {
82
+ cellOptionEditor.setContent(surveys_utils_simpleGenerators.generateLocStrings(opt.content));
83
+ }
84
+ cellOptionEditor.setDisabled(opt.disabled);
85
+ cellOptionEditor.setDisplayCondition(opt.displayCondition);
86
+ cellEditor.addItemComponent(cellOptionEditor.getComponent());
87
+ });
88
+ }
89
+ rowEditor.addItemComponent(cellEditor.getComponent());
90
+ });
91
+ break;
92
+ }
93
+ groupEdit.addItemComponent(rowEditor.getComponent());
94
+ });
95
+ return groupEdit.getComponent();
96
+ };
97
+
98
+ exports.initMatrixQuestion = initMatrixQuestion;
99
+ //# sourceMappingURL=matrixGroupComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"matrixGroupComponent.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,7 @@
1
+ import { Expression, ItemComponent, ItemGroupComponent } from "survey-engine/data_types";
2
+ import { OptionDef } from "../types";
3
+ export declare const optionDefToItemComponent: (optionDef: OptionDef) => ItemComponent;
4
+ export declare const initSingleChoiceGroup: (key: string, optionItems: OptionDef[], order?: Expression | undefined) => ItemGroupComponent;
5
+ export declare const initMultipleChoiceGroup: (key: string, optionItems: OptionDef[], order?: Expression | undefined) => ItemGroupComponent;
6
+ 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;
7
+ export declare const initSliderCategoricalGroup: (key: string, optionItems: OptionDef[], order?: Expression | undefined, groupDisabled?: Expression | undefined) => ItemGroupComponent;
@@ -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,4 +1,4 @@
1
- import { ItemComponent, Expression, LocalizedObject, ComponentProperties } from "survey-engine/lib/data_types";
1
+ import { ItemComponent, Expression, LocalizedObject, ComponentProperties } from "survey-engine/data_types";
2
2
  import { NewComponentProps } from "./data-types";
3
3
  interface ComponentEditorInt {
4
4
  getComponent: () => ItemComponent;
@@ -1,4 +1,4 @@
1
- import { SurveyItemTypes } from "survey-engine/lib/data_types";
1
+ import { SurveyItemTypes } from "survey-engine/data_types";
2
2
  export interface NewItemProps {
3
3
  itemKey?: string;
4
4
  isGroup?: boolean;
@@ -1,4 +1,4 @@
1
- import { SurveyItem, SurveyItemTypes, Expression, Validation, ItemComponent, ItemGroupComponent } from "survey-engine/lib/data_types";
1
+ import { SurveyItem, SurveyItemTypes, Expression, Validation, ItemComponent, ItemGroupComponent } from "survey-engine/data_types";
2
2
  import { NewItemProps, NewComponentProps } from "./data-types";
3
3
  interface ItemEditorInt {
4
4
  getItem: () => SurveyItem;
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var surveys_surveyEditor_itemEditor = require('../../item-editor-7f825952.js');
5
+ var surveys_surveyEditor_itemEditor = require('../../item-editor-c6933791.js');
6
6
  require('./component-editor.js');
7
7
  require('../utils/randomKeyGenerator.js');
8
8
  require('../../logger/logger.js');
@@ -1,4 +1,5 @@
1
- import { Survey, LocalizedString, SurveyItem, SurveyContextDef, Expression } from "survey-engine/lib/data_types";
1
+ import { Survey, LocalizedString, SurveyItem, SurveyContextDef, Expression } from "survey-engine/data_types";
2
+ import { SurveyAvailableFor } from "../types";
2
3
  import { NewItemProps } from "./data-types";
3
4
  interface SurveyEditorInt {
4
5
  setSurveyName: (name: Array<LocalizedString>) => void;
@@ -6,6 +7,8 @@ interface SurveyEditorInt {
6
7
  setSurveyDuration: (duration: Array<LocalizedString>) => void;
7
8
  setSurveyContextRules: (contextRules: SurveyContextDef) => void;
8
9
  setPrefillRules: (rules: Expression[]) => void;
10
+ setAvailableFor: (value?: SurveyAvailableFor) => void;
11
+ setRequireLoginBeforeSubmission: (value?: boolean) => void;
9
12
  changeItemKey: (oldKey: string, newKey: string) => void;
10
13
  addNewSurveyItem: (itemProps: NewItemProps, parentKey?: string, atPosition?: number) => SurveyItem | undefined;
11
14
  updateSurveyItem: (item: SurveyItem) => void;
@@ -26,6 +29,8 @@ export declare class SurveyEditor implements SurveyEditorInt {
26
29
  small: number;
27
30
  large: number;
28
31
  }): void;
32
+ setAvailableFor(value?: SurveyAvailableFor | undefined): void;
33
+ setRequireLoginBeforeSubmission(value?: boolean | undefined): void;
29
34
  setSurveyContextRules(contextRules: SurveyContextDef): void;
30
35
  setPrefillRules(rules: Expression[]): void;
31
36
  addNewSurveyItem(newItem: NewItemProps, parentKey?: string, atPosition?: number): SurveyItem | undefined;
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var surveys_surveyEditor_itemEditor = require('../../item-editor-7f825952.js');
5
+ var surveys_surveyEditor_itemEditor = require('../../item-editor-c6933791.js');
6
6
  var logger_logger = require('../../logger/logger.js');
7
7
  require('./component-editor.js');
8
8
  require('../utils/randomKeyGenerator.js');
@@ -52,6 +52,12 @@ class SurveyEditor {
52
52
  setMaxItemPerPage(itemLimits) {
53
53
  this.survey.maxItemsPerPage = itemLimits;
54
54
  }
55
+ setAvailableFor(value) {
56
+ this.survey.availableFor = value;
57
+ }
58
+ setRequireLoginBeforeSubmission(value) {
59
+ this.survey.requireLoginBeforeSubmission = value;
60
+ }
55
61
  setSurveyContextRules(contextRules) {
56
62
  this.survey.contextRules = Object.assign({}, contextRules);
57
63
  }
@@ -176,7 +182,7 @@ class SurveyEditor {
176
182
  obj = this.survey.current.surveyDefinition;
177
183
  continue;
178
184
  }
179
- if (!surveys_surveyEditor_itemEditor.data_types.isSurveyGroupItem(obj)) {
185
+ if (!surveys_surveyEditor_itemEditor.isSurveyGroupItem(obj)) {
180
186
  console.warn('survey item is not a group: ', obj.key);
181
187
  return;
182
188
  }
@@ -216,7 +222,7 @@ class SurveyEditor {
216
222
  }
217
223
  changeItemKeyForSubtree(currentItem, newKey) {
218
224
  currentItem = Object.assign({}, currentItem);
219
- if (surveys_surveyEditor_itemEditor.data_types.isSurveyGroupItem(currentItem)) {
225
+ if (surveys_surveyEditor_itemEditor.isSurveyGroupItem(currentItem)) {
220
226
  currentItem.items = currentItem.items.map(item => {
221
227
  const newSubkey = newKey + '.' + item.key.slice(item.key.lastIndexOf('.') + 1);
222
228
  return this.changeItemKeyForSubtree(item, newSubkey);
@@ -1 +1 @@
1
- {"version":3,"file":"survey-editor.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"survey-editor.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,4 +1,4 @@
1
- import { Expression } from "survey-engine/lib/data_types";
1
+ import { Expression } from "survey-engine/data_types";
2
2
  import { Duration } from "../types/duration";
3
3
  export declare const NativeSurveyEngineExpressions: {
4
4
  getters: {
@@ -1,5 +1,6 @@
1
- import { ItemGroupComponent, Expression, ComponentProperties, ItemComponent, SurveyItem, ExpressionArg } from "survey-engine/lib/data_types";
2
- import { DateInputQuestionProps, GenericQuestionProps, MultiLineTextInput, NumericInputQuestionProps, OptionDef, ResponsiveBipolarLikertArrayProps, ResponsiveBipolarLikertArrayQuestionProps, ResponsiveSingleChoiceArrayProps, ResponsiveSingleChoiceArrayQuestionProps, TextInputQuestionProps } from "./types/item-properties";
1
+ import { ItemGroupComponent, Expression, ItemComponent, SurveyItem, ExpressionArg, ResponseItem } from "survey-engine/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;
@@ -119,12 +50,14 @@ export declare const SurveyItems: {
119
50
  multipleChoice: (props: OptionQuestionProps) => SurveyItem;
120
51
  dateInput: (props: DateInputQuestionProps) => SurveyItem;
121
52
  textInput: (props: TextInputQuestionProps) => SurveyItem;
53
+ clozeQuestion: (props: ClozeQuestionProps) => SurveyItem;
122
54
  numericInput: (props: NumericInputQuestionProps) => SurveyItem;
123
55
  multilineTextInput: (props: MultiLineTextInput) => SurveyItem;
124
56
  dropDown: (props: OptionQuestionProps) => SurveyItem;
125
57
  numericSlider: (props: NumericSliderProps) => SurveyItem;
126
58
  display: (props: DisplayProps) => SurveyItem;
127
59
  surveyEnd: (parentKey: string, content: Map<string, string>, condition?: Expression | undefined) => SurveyItem;
60
+ customQuestion: (props: CustomQuestionProps) => SurveyItem;
128
61
  old: {
129
62
  simpleLikertGroup: (props: LikertGroupQuestionProps) => SurveyItem;
130
63
  };