case-editor-tools 1.0.0-beta.2 → 1.0.0-beta.20

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 (103) hide show
  1. package/{build/constants → constants}/key-definitions.d.ts +1 -0
  2. package/{build/constants → constants}/key-definitions.js +3 -1
  3. package/{build/constants → constants}/key-definitions.js.map +1 -1
  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/{build/expression-utils → expression-utils}/expressionGen.d.ts +1 -1
  8. package/{build/expression-utils → expression-utils}/expressionGen.js +0 -0
  9. package/{build/expression-utils → expression-utils}/expressionGen.js.map +0 -0
  10. package/{build/expression-utils → expression-utils}/studyEngineExpressions.d.ts +3 -3
  11. package/{build/expression-utils → expression-utils}/studyEngineExpressions.js +0 -0
  12. package/{build/expression-utils → expression-utils}/studyEngineExpressions.js.map +0 -0
  13. package/{build/index.d.ts → index.d.ts} +0 -0
  14. package/{build/index.js → index.js} +0 -0
  15. package/{build/index.js.map → index.js.map} +0 -0
  16. package/{build/item-editor-8fd24b61.js → item-editor-c6933791.js} +69 -51
  17. package/item-editor-c6933791.js.map +1 -0
  18. package/logger/index.d.ts +1 -0
  19. package/logger/index.js +10 -0
  20. package/logger/index.js.map +1 -0
  21. package/{build/logger → logger}/logger.d.ts +0 -0
  22. package/{build/logger → logger}/logger.js +0 -0
  23. package/{build/logger → logger}/logger.js.map +0 -0
  24. package/package.json +9 -12
  25. package/surveys/index.d.ts +3 -0
  26. package/surveys/index.js +28 -0
  27. package/surveys/index.js.map +1 -0
  28. package/surveys/responseTypeGenerators/likertGroupComponents.d.ts +27 -0
  29. package/surveys/responseTypeGenerators/likertGroupComponents.js +347 -0
  30. package/surveys/responseTypeGenerators/likertGroupComponents.js.map +1 -0
  31. package/surveys/responseTypeGenerators/matrixGroupComponent.d.ts +49 -0
  32. package/surveys/responseTypeGenerators/matrixGroupComponent.js +99 -0
  33. package/surveys/responseTypeGenerators/matrixGroupComponent.js.map +1 -0
  34. package/surveys/responseTypeGenerators/optionGroupComponents.d.ts +7 -0
  35. package/surveys/responseTypeGenerators/optionGroupComponents.js +125 -0
  36. package/surveys/responseTypeGenerators/optionGroupComponents.js.map +1 -0
  37. package/{build → surveys}/survey-editor/component-editor.d.ts +1 -1
  38. package/{build → surveys}/survey-editor/component-editor.js +0 -0
  39. package/{build → surveys}/survey-editor/component-editor.js.map +0 -0
  40. package/{build → surveys}/survey-editor/data-types.d.ts +1 -1
  41. package/{build → surveys}/survey-editor/data-types.js +0 -0
  42. package/{build → surveys}/survey-editor/data-types.js.map +0 -0
  43. package/{build → surveys}/survey-editor/item-editor.d.ts +1 -1
  44. package/{build → surveys}/survey-editor/item-editor.js +3 -2
  45. package/{build → surveys}/survey-editor/item-editor.js.map +1 -1
  46. package/{build → surveys}/survey-editor/survey-editor.d.ts +6 -1
  47. package/{build → surveys}/survey-editor/survey-editor.js +15 -8
  48. package/{build → surveys}/survey-editor/survey-editor.js.map +1 -1
  49. package/{build/expression-utils/surveyEngineExpressions.d.ts → surveys/survey-engine-expressions.d.ts} +1 -1
  50. package/{build/expression-utils/surveyEngineExpressions.js → surveys/survey-engine-expressions.js} +2 -2
  51. package/{build/expression-utils/surveyEngineExpressions.js.map → surveys/survey-engine-expressions.js.map} +1 -1
  52. package/surveys/survey-items.d.ts +65 -0
  53. package/surveys/survey-items.js +268 -0
  54. package/surveys/survey-items.js.map +1 -0
  55. package/{build → surveys}/types/group.d.ts +1 -1
  56. package/{build → surveys}/types/group.js +5 -5
  57. package/{build → surveys}/types/group.js.map +0 -0
  58. package/surveys/types/index.d.ts +4 -0
  59. package/surveys/types/index.js +20 -0
  60. package/surveys/types/index.js.map +1 -0
  61. package/surveys/types/item-properties.d.ts +189 -0
  62. package/surveys/types/item-properties.js +3 -0
  63. package/surveys/types/item-properties.js.map +1 -0
  64. package/{build → surveys}/types/item.d.ts +1 -1
  65. package/{build → surveys}/types/item.js +0 -0
  66. package/{build → surveys}/types/item.js.map +0 -0
  67. package/{build/types/surveyDefinition.d.ts → surveys/types/survey-definition.d.ts} +5 -2
  68. package/{build/types/surveyDefinition.js → surveys/types/survey-definition.js} +12 -10
  69. package/surveys/types/survey-definition.js.map +1 -0
  70. package/{build → surveys}/utils/componentGenerators.d.ts +2 -13
  71. package/surveys/utils/componentGenerators.js +58 -0
  72. package/{build → surveys}/utils/componentGenerators.js.map +1 -1
  73. package/surveys/utils/optionDefGenerators.d.ts +69 -0
  74. package/surveys/utils/optionDefGenerators.js +169 -0
  75. package/surveys/utils/optionDefGenerators.js.map +1 -0
  76. package/{build → surveys}/utils/randomKeyGenerator.d.ts +0 -0
  77. package/{build → surveys}/utils/randomKeyGenerator.js +0 -0
  78. package/{build → surveys}/utils/randomKeyGenerator.js.map +0 -0
  79. package/{build → surveys}/utils/simple-generators.d.ts +2 -2
  80. package/{build → surveys}/utils/simple-generators.js +5 -5
  81. package/{build → surveys}/utils/simple-generators.js.map +0 -0
  82. package/{build → surveys}/utils/simple-question-editor.d.ts +3 -3
  83. package/{build → surveys}/utils/simple-question-editor.js +7 -6
  84. package/{build → surveys}/utils/simple-question-editor.js.map +1 -1
  85. package/{build/types → types}/duration.d.ts +0 -0
  86. package/{build/types → types}/duration.js +0 -0
  87. package/{build/types → types}/duration.js.map +0 -0
  88. package/{build/types → types}/expression.d.ts +1 -1
  89. package/{build/types → types}/expression.js +0 -0
  90. package/{build/types → types}/expression.js.map +0 -0
  91. package/{build/types → types}/study.d.ts +2 -2
  92. package/{build/types → types}/study.js +0 -0
  93. package/{build/types → types}/study.js.map +0 -0
  94. package/{build/types → types}/studyRules.d.ts +1 -1
  95. package/{build/types → types}/studyRules.js +0 -0
  96. package/{build/types → types}/studyRules.js.map +0 -0
  97. package/LICENSE +0 -202
  98. package/build/item-editor-8fd24b61.js.map +0 -1
  99. package/build/types/surveyDefinition.js.map +0 -1
  100. package/build/utils/componentGenerators.js +0 -92
  101. package/build/utils/question-type-generator.d.ts +0 -283
  102. package/build/utils/question-type-generator.js +0 -949
  103. package/build/utils/question-type-generator.js.map +0 -1
@@ -0,0 +1,347 @@
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('../utils/randomKeyGenerator.js');
7
+ var surveys_utils_simpleGenerators = require('../utils/simple-generators.js');
8
+
9
+ const initLikertScaleGroup = (key, rows, scaleOptions, stackOnSmallScreen, displayCondition) => {
10
+ const groupEdit = new surveys_surveyEditor_componentEditor.ComponentEditor(undefined, {
11
+ key: key,
12
+ isGroup: true,
13
+ role: 'likertGroup',
14
+ });
15
+ if (displayCondition) {
16
+ groupEdit.setDisplayCondition(displayCondition);
17
+ }
18
+ rows.forEach((row, index) => {
19
+ groupEdit.addItemComponent({
20
+ key: surveys_utils_randomKeyGenerator.generateRandomKey(4),
21
+ role: 'text',
22
+ style: [{
23
+ key: 'className', value: 'fw-bold' + (index !== 0 ? ' pt-1 mt-2' : '') + ((!row.hideTopBorder && index > 0) ? ' border-top border-1 border-grey-2' : '') + (row.descriptions ? ' mb-0' : ' mb-1')
24
+ }, { key: 'variant', value: 'h6' }],
25
+ content: surveys_utils_simpleGenerators.generateLocStrings(row.content),
26
+ });
27
+ if (row.descriptions) {
28
+ row.descriptions.forEach(desc => {
29
+ groupEdit.addItemComponent(desc);
30
+ });
31
+ }
32
+ const item = initLikertScaleItem(row.key, scaleOptions.map(option => {
33
+ var _a, _b;
34
+ return {
35
+ key: option.key,
36
+ className: option.className,
37
+ content: row.hideLabels ? undefined : option.content,
38
+ disabled: (_b = (_a = row.optionDisabled) === null || _a === void 0 ? void 0 : _a.find(cond => cond.optionKey === option.key)) === null || _b === void 0 ? void 0 : _b.exp,
39
+ };
40
+ }), stackOnSmallScreen, row.displayCondition);
41
+ groupEdit.addItemComponent(item);
42
+ });
43
+ return groupEdit.getComponent();
44
+ };
45
+ const initResponsiveSingleChoiceArray = (rgKey, props, displayCondition) => {
46
+ var _a, _b;
47
+ const groupEdit = new surveys_surveyEditor_componentEditor.ComponentEditor(undefined, {
48
+ key: rgKey,
49
+ isGroup: true,
50
+ role: 'responsiveSingleChoiceArray',
51
+ });
52
+ if (displayCondition) {
53
+ groupEdit.setDisplayCondition(displayCondition);
54
+ }
55
+ const style = [
56
+ { key: 'defaultMode', value: props.defaultMode },
57
+ ];
58
+ if (props.responsiveModes) {
59
+ if (props.responsiveModes.sm) {
60
+ style.push({ key: 'smMode', value: props.responsiveModes.sm });
61
+ }
62
+ if (props.responsiveModes.md) {
63
+ style.push({ key: 'mdMode', value: props.responsiveModes.md });
64
+ }
65
+ if (props.responsiveModes.lg) {
66
+ style.push({ key: 'lgMode', value: props.responsiveModes.lg });
67
+ }
68
+ if (props.responsiveModes.xl) {
69
+ style.push({ key: 'xlMode', value: props.responsiveModes.xl });
70
+ }
71
+ if (props.responsiveModes.xxl) {
72
+ style.push({ key: 'xxlMode', value: props.responsiveModes.xxl });
73
+ }
74
+ }
75
+ if (props.rgClassName) {
76
+ style.push({ key: 'className', value: props.rgClassName });
77
+ }
78
+ if (props.verticalModeProps) {
79
+ if (props.verticalModeProps.useReverseOptionOrder) {
80
+ style.push({ key: 'verticalModeReverseOrder', value: 'true' });
81
+ }
82
+ }
83
+ if (props.tableModeProps) {
84
+ style.push({ key: 'tableModeClassName', value: 'table-borderless mb-0 ' + props.tableModeProps.className });
85
+ if (props.tableModeProps.layout) {
86
+ style.push({ key: 'tableModeLayout', value: props.tableModeProps.layout });
87
+ }
88
+ if (props.tableModeProps.firstColWidth) {
89
+ style.push({ key: 'tableModeFirstColWidth', value: props.tableModeProps.firstColWidth });
90
+ }
91
+ }
92
+ groupEdit.setStyles(style);
93
+ const defaultBorderClass = 'border-bottom border-grey-2';
94
+ let tableModeOptionHeaderClassName = undefined;
95
+ if (!((_a = props.tableModeProps) === null || _a === void 0 ? void 0 : _a.hideRowBorder)) {
96
+ tableModeOptionHeaderClassName = defaultBorderClass;
97
+ }
98
+ if ((_b = props.tableModeProps) === null || _b === void 0 ? void 0 : _b.optionHeaderClassName) {
99
+ tableModeOptionHeaderClassName += ' ' + props.tableModeProps.optionHeaderClassName;
100
+ }
101
+ const optionStyles = [];
102
+ if (tableModeOptionHeaderClassName) {
103
+ optionStyles.push({ key: 'tableModeClassName', value: tableModeOptionHeaderClassName });
104
+ }
105
+ groupEdit.addItemComponent({
106
+ key: 'header',
107
+ role: 'options',
108
+ style: optionStyles.length > 0 ? optionStyles : undefined,
109
+ items: props.scaleOptions.map(option => {
110
+ return {
111
+ key: option.key,
112
+ role: 'option',
113
+ style: option.className ? [{ key: 'className', value: option.className }] : undefined,
114
+ content: !Array.isArray(option.content) ? surveys_utils_simpleGenerators.generateLocStrings(option.content) : undefined,
115
+ items: Array.isArray(option.content) ? option.content.map((cont, index) => {
116
+ return {
117
+ key: index.toFixed(),
118
+ role: 'text',
119
+ content: surveys_utils_simpleGenerators.generateLocStrings(cont.content),
120
+ style: cont.className ? [{ key: 'className', value: cont.className }] : undefined,
121
+ };
122
+ }) : [],
123
+ };
124
+ })
125
+ });
126
+ props.rows.forEach((row, index) => {
127
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
128
+ let tableModeRowClassName = undefined;
129
+ let horizontalModeRowClassName = undefined;
130
+ let verticalModeRowClassName = undefined;
131
+ const isLast = index === props.rows.length - 1;
132
+ if (!((_a = props.tableModeProps) === null || _a === void 0 ? void 0 : _a.hideRowBorder) && !isLast) {
133
+ tableModeRowClassName = defaultBorderClass;
134
+ }
135
+ if ((_b = row.tableModeProps) === null || _b === void 0 ? void 0 : _b.className) {
136
+ tableModeRowClassName += ' ' + ((_c = row.tableModeProps) === null || _c === void 0 ? void 0 : _c.className);
137
+ }
138
+ if (!((_d = props.horizontalModeProps) === null || _d === void 0 ? void 0 : _d.hideRowBorder) && !isLast) {
139
+ horizontalModeRowClassName = defaultBorderClass;
140
+ }
141
+ if ((_e = row.horizontalModeProps) === null || _e === void 0 ? void 0 : _e.className) {
142
+ horizontalModeRowClassName += ' ' + ((_f = row.horizontalModeProps) === null || _f === void 0 ? void 0 : _f.className);
143
+ }
144
+ if (!((_g = props.verticalModeProps) === null || _g === void 0 ? void 0 : _g.hideRowBorder) && !isLast) {
145
+ verticalModeRowClassName = defaultBorderClass;
146
+ }
147
+ if ((_h = row.verticalModeProps) === null || _h === void 0 ? void 0 : _h.className) {
148
+ verticalModeRowClassName += ' ' + ((_j = row.verticalModeProps) === null || _j === void 0 ? void 0 : _j.className);
149
+ }
150
+ const rowStyles = [];
151
+ if (tableModeRowClassName) {
152
+ rowStyles.push({ key: 'tableModeClassName', value: tableModeRowClassName });
153
+ }
154
+ if (horizontalModeRowClassName) {
155
+ rowStyles.push({ key: 'horizontalModeClassName', value: horizontalModeRowClassName });
156
+ }
157
+ if (verticalModeRowClassName) {
158
+ rowStyles.push({ key: 'verticalModeClassName', value: verticalModeRowClassName });
159
+ }
160
+ if ((_k = row.horizontalModeProps) === null || _k === void 0 ? void 0 : _k.labelPlacement) {
161
+ rowStyles.push({ key: 'horizontalModeLabelPlacement', value: row.horizontalModeProps.labelPlacement });
162
+ }
163
+ groupEdit.addItemComponent({
164
+ key: row.key,
165
+ role: 'row',
166
+ style: rowStyles.length > 0 ? rowStyles : undefined,
167
+ content: !Array.isArray(row.content) ? surveys_utils_simpleGenerators.generateLocStrings(row.content) : undefined,
168
+ items: Array.isArray(row.content) ? row.content.map((cont, index) => {
169
+ return {
170
+ key: index.toFixed(),
171
+ role: 'text',
172
+ content: surveys_utils_simpleGenerators.generateLocStrings(cont.content),
173
+ style: cont.className ? [{ key: 'className', value: cont.className }] : undefined,
174
+ };
175
+ }) : [],
176
+ });
177
+ });
178
+ return groupEdit.getComponent();
179
+ };
180
+ const initResponsiveBipolarLikertArray = (rgKey, props, displayCondition) => {
181
+ var _a;
182
+ const groupEdit = new surveys_surveyEditor_componentEditor.ComponentEditor(undefined, {
183
+ key: rgKey,
184
+ isGroup: true,
185
+ role: 'responsiveBipolarLikertScaleArray',
186
+ });
187
+ if (displayCondition) {
188
+ groupEdit.setDisplayCondition(displayCondition);
189
+ }
190
+ const style = [
191
+ { key: 'defaultMode', value: props.defaultMode },
192
+ ];
193
+ if (props.responsiveModes) {
194
+ if (props.responsiveModes.sm) {
195
+ style.push({ key: 'smMode', value: props.responsiveModes.sm });
196
+ }
197
+ if (props.responsiveModes.md) {
198
+ style.push({ key: 'mdMode', value: props.responsiveModes.md });
199
+ }
200
+ if (props.responsiveModes.lg) {
201
+ style.push({ key: 'lgMode', value: props.responsiveModes.lg });
202
+ }
203
+ if (props.responsiveModes.xl) {
204
+ style.push({ key: 'xlMode', value: props.responsiveModes.xl });
205
+ }
206
+ if (props.responsiveModes.xxl) {
207
+ style.push({ key: 'xxlMode', value: props.responsiveModes.xxl });
208
+ }
209
+ }
210
+ if (props.rgClassName) {
211
+ style.push({ key: 'className', value: props.rgClassName });
212
+ }
213
+ if (props.withLabelRowModeProps) {
214
+ if (props.withLabelRowModeProps.maxLabelWidth) {
215
+ style.push({ key: 'labelRowMaxLabelWidth', value: props.withLabelRowModeProps.maxLabelWidth });
216
+ }
217
+ }
218
+ style.push({ key: 'labelRowPosition', value: ((_a = props.withLabelRowModeProps) === null || _a === void 0 ? void 0 : _a.useBottomLabel) ? 'bottom' : 'top' });
219
+ if (props.tableModeProps) {
220
+ style.push({ key: 'tableModeClassName', value: 'table-borderless mb-0 ' + props.tableModeProps.className });
221
+ if (props.tableModeProps.layout) {
222
+ style.push({ key: 'tableModeLayout', value: props.tableModeProps.layout });
223
+ }
224
+ if (props.tableModeProps.labelColWidth) {
225
+ style.push({ key: 'tableModeLabelColWidth', value: props.tableModeProps.labelColWidth });
226
+ }
227
+ }
228
+ groupEdit.setStyles(style);
229
+ const defaultBorderClass = 'border-bottom border-grey-2';
230
+ groupEdit.addItemComponent({
231
+ key: 'options',
232
+ role: 'options',
233
+ items: props.scaleOptions.map(option => {
234
+ return {
235
+ key: option.key,
236
+ role: 'option',
237
+ };
238
+ })
239
+ });
240
+ props.rows.forEach((row, index) => {
241
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
242
+ let tableModeRowClassName = undefined;
243
+ let withLabelRowModeClassName = undefined;
244
+ let verticalModeRowClassName = undefined;
245
+ const isLast = index === props.rows.length - 1;
246
+ if (!((_a = props.tableModeProps) === null || _a === void 0 ? void 0 : _a.hideRowBorder) && !isLast) {
247
+ tableModeRowClassName = defaultBorderClass;
248
+ }
249
+ if ((_b = row.tableModeProps) === null || _b === void 0 ? void 0 : _b.className) {
250
+ tableModeRowClassName += ' ' + ((_c = row.tableModeProps) === null || _c === void 0 ? void 0 : _c.className);
251
+ }
252
+ if (!((_d = props.withLabelRowModeProps) === null || _d === void 0 ? void 0 : _d.hideRowBorder) && !isLast) {
253
+ withLabelRowModeClassName = defaultBorderClass;
254
+ }
255
+ if ((_e = row.withLabelRowModeProps) === null || _e === void 0 ? void 0 : _e.className) {
256
+ withLabelRowModeClassName += ' ' + ((_f = row.withLabelRowModeProps) === null || _f === void 0 ? void 0 : _f.className);
257
+ }
258
+ if (!((_g = props.verticalModeProps) === null || _g === void 0 ? void 0 : _g.hideRowBorder) && !isLast) {
259
+ verticalModeRowClassName = defaultBorderClass;
260
+ }
261
+ if ((_h = row.verticalModeProps) === null || _h === void 0 ? void 0 : _h.className) {
262
+ verticalModeRowClassName += ' ' + ((_j = row.verticalModeProps) === null || _j === void 0 ? void 0 : _j.className);
263
+ }
264
+ const rowStyles = [];
265
+ if (tableModeRowClassName) {
266
+ rowStyles.push({ key: 'tableModeClassName', value: tableModeRowClassName });
267
+ }
268
+ if (withLabelRowModeClassName) {
269
+ rowStyles.push({ key: 'withLabelRowModeClassName', value: withLabelRowModeClassName });
270
+ }
271
+ if (verticalModeRowClassName) {
272
+ rowStyles.push({ key: 'verticalModeClassName', value: verticalModeRowClassName });
273
+ }
274
+ const startLabel = {
275
+ key: 'start',
276
+ role: 'start',
277
+ content: !Array.isArray(row.startLabel) ? surveys_utils_simpleGenerators.generateLocStrings(row.startLabel) : undefined,
278
+ items: Array.isArray(row.startLabel) ? row.startLabel.map((cont, index) => {
279
+ return {
280
+ key: index.toFixed(),
281
+ role: 'text',
282
+ content: surveys_utils_simpleGenerators.generateLocStrings(cont.content),
283
+ style: cont.className ? [{ key: 'className', value: cont.className }] : undefined,
284
+ };
285
+ }) : [],
286
+ };
287
+ const endLabel = {
288
+ key: 'end',
289
+ role: 'end',
290
+ content: !Array.isArray(row.endLabel) ? surveys_utils_simpleGenerators.generateLocStrings(row.endLabel) : undefined,
291
+ items: Array.isArray(row.endLabel) ? row.endLabel.map((cont, index) => {
292
+ return {
293
+ key: index.toFixed(),
294
+ role: 'text',
295
+ content: surveys_utils_simpleGenerators.generateLocStrings(cont.content),
296
+ style: cont.className ? [{ key: 'className', value: cont.className }] : undefined,
297
+ };
298
+ }) : [],
299
+ };
300
+ groupEdit.addItemComponent({
301
+ key: row.key,
302
+ role: 'row',
303
+ style: rowStyles.length > 0 ? rowStyles : undefined,
304
+ items: [
305
+ startLabel, endLabel
306
+ ],
307
+ });
308
+ });
309
+ return groupEdit.getComponent();
310
+ };
311
+ const initLikertScaleItem = (key, options, stackOnSmallScreen, displayCondition) => {
312
+ // init group
313
+ const groupEdit = new surveys_surveyEditor_componentEditor.ComponentEditor(undefined, {
314
+ key: key,
315
+ isGroup: true,
316
+ role: 'likert',
317
+ });
318
+ groupEdit.setDisplayCondition(displayCondition);
319
+ if (stackOnSmallScreen) {
320
+ groupEdit.setStyles([
321
+ { key: 'responsive', value: 'stackOnSmallScreen' }
322
+ ]);
323
+ }
324
+ options.forEach((option) => {
325
+ const optionComponent = new surveys_surveyEditor_componentEditor.ComponentEditor(undefined, {
326
+ key: option.key,
327
+ role: 'option',
328
+ });
329
+ if (option.content) {
330
+ optionComponent.setContent(surveys_utils_simpleGenerators.generateLocStrings(option.content));
331
+ }
332
+ if (option.className) {
333
+ optionComponent.setStyles([{
334
+ key: 'className', value: option.className
335
+ }]);
336
+ }
337
+ optionComponent.setDisabled(option.disabled);
338
+ groupEdit.addItemComponent(optionComponent.getComponent());
339
+ });
340
+ return groupEdit.getComponent();
341
+ };
342
+
343
+ exports.initLikertScaleGroup = initLikertScaleGroup;
344
+ exports.initLikertScaleItem = initLikertScaleItem;
345
+ exports.initResponsiveBipolarLikertArray = initResponsiveBipolarLikertArray;
346
+ exports.initResponsiveSingleChoiceArray = initResponsiveSingleChoiceArray;
347
+ //# sourceMappingURL=likertGroupComponents.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"likertGroupComponents.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -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;
File without changes
@@ -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;