@media-quest/builder 0.0.22 → 0.0.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.
Files changed (56) hide show
  1. package/package.json +1 -1
  2. package/src/Builder-option.ts +66 -66
  3. package/src/Builder-page.spec.ts +320 -320
  4. package/src/Builder-page.ts +257 -257
  5. package/src/Builder-question.spec.ts +68 -68
  6. package/src/Builder-question.ts +101 -101
  7. package/src/Builder-schema.spec.ts +357 -306
  8. package/src/Builder-schema.ts +287 -254
  9. package/src/Builder-text.spec.ts +24 -24
  10. package/src/Builder-text.ts +57 -57
  11. package/src/BuilderMainImageDto.ts +7 -7
  12. package/src/BuilderMainText.ts +81 -81
  13. package/src/BuilderMainVideoDto.ts +10 -10
  14. package/src/BuilderObject.ts +61 -61
  15. package/src/BuilderTag.ts +97 -97
  16. package/src/builder-compiler.ts +14 -0
  17. package/src/codebook.ts +72 -72
  18. package/src/media-files.ts +28 -28
  19. package/src/primitives/page-prefix.ts +58 -58
  20. package/src/primitives/prefix.spec.ts +5 -5
  21. package/src/primitives/schema-prefix.ts +52 -52
  22. package/src/primitives/varID.ts +11 -11
  23. package/src/public-api.ts +3 -1
  24. package/src/rulebuilder/Builder-rule.spec.ts +322 -322
  25. package/src/rulebuilder/Builder-rule.ts +190 -190
  26. package/src/rulebuilder/RuleAction.ts +106 -106
  27. package/src/rulebuilder/RuleBuilder-test-utils.ts +316 -316
  28. package/src/rulebuilder/RuleInput.ts +44 -44
  29. package/src/rulebuilder/RuleVariable.ts +49 -49
  30. package/src/rulebuilder/SingleSelectItem.ts +135 -135
  31. package/src/rulebuilder/condition/Builder-condition-group.spec.ts +47 -47
  32. package/src/rulebuilder/condition/Builder-condition-group.ts +118 -118
  33. package/src/rulebuilder/condition/Builder-condition.spec.ts +195 -195
  34. package/src/rulebuilder/condition/Builder-condition.ts +208 -208
  35. package/src/rulebuilder/condition/Builder-operator.spec.ts +9 -9
  36. package/src/rulebuilder/condition/Builder-operator.ts +31 -31
  37. package/src/rulebuilder/index.ts +22 -22
  38. package/src/rulebuilder/jump-to-action-manager.ts +33 -33
  39. package/src/rulebuilder/multi-select-item.ts +73 -73
  40. package/src/rulebuilder/page-action-manager.ts +31 -31
  41. package/src/rulebuilder/rule2/Rule2.ts +211 -211
  42. package/src/rulebuilder/tag-action-manager.spec.ts +44 -44
  43. package/src/rulebuilder/tag-action-manager.ts +28 -28
  44. package/src/schema-config.ts +25 -25
  45. package/src/theme/AbstractThemeCompiler.ts +7 -7
  46. package/src/theme/IDefaultTheme.ts +226 -226
  47. package/src/theme/css-theme.ts +7 -7
  48. package/src/theme/default-theme-compiler.ts +358 -358
  49. package/src/theme/icon-urls.ts +29 -29
  50. package/src/theme/theme-utils.ts +57 -57
  51. package/src/theme/theme1.spec.ts +52 -52
  52. package/src/variable/mq-variable.spec.ts +91 -0
  53. package/src/{mq-variable.ts → variable/mq-variable.ts} +63 -61
  54. package/src/variable/sum-score-variable.ts +56 -0
  55. package/tsconfig.json +15 -15
  56. package/tsconfig.tsbuildinfo +1 -1
@@ -1,101 +1,101 @@
1
- import type { BuilderOptionDto } from "./Builder-option";
2
- import { BuilderOption } from "./Builder-option";
3
- import { BuilderObject, BuilderObjectId } from "./BuilderObject";
4
-
5
- export type BuilderQuestionType =
6
- | "select-one"
7
- | "select-many"
8
- | "text"
9
- | "color"
10
- | "radio"
11
- | "email"
12
- | "time"
13
- | "checkbox"
14
- | "textarea"
15
- | "date"
16
- | "numeric-range"
17
- | "duration";
18
-
19
- export interface BuilderQuestionDto {
20
- readonly id: BuilderObjectId.QuestionID;
21
- _type: BuilderQuestionType;
22
- text: string;
23
- options: ReadonlyArray<BuilderOptionDto>;
24
- prefix: string;
25
- }
26
-
27
- export class BuilderQuestion extends BuilderObject<"builder-question", BuilderQuestionDto> {
28
- readonly objectType = "builder-question";
29
- id: BuilderObjectId.QuestionID;
30
- type: BuilderQuestionType;
31
- questionText = "";
32
- options: BuilderOption[] = [];
33
- prefix = "";
34
-
35
- static create = (type: BuilderQuestionType) => {
36
- const id = BuilderObjectId.questionId();
37
-
38
- return new BuilderQuestion({
39
- id,
40
- _type: type,
41
- text: "",
42
- options: [],
43
- prefix: "",
44
- });
45
- };
46
-
47
- public static fromJson(dto: BuilderQuestionDto): BuilderQuestion {
48
- const question = new BuilderQuestion(dto);
49
- return question;
50
- }
51
-
52
- private constructor(dto: BuilderQuestionDto) {
53
- super(dto);
54
- this.id = dto.id as BuilderObjectId.QuestionID;
55
- this.type = dto._type;
56
- this.questionText = dto.text;
57
- this.prefix = dto.prefix;
58
- this.options = dto.options.map((o) => BuilderOption.fromJson(o));
59
- }
60
-
61
- addOption(label: string, value: number, atIndex = -1) {
62
- const option = BuilderOption.create(value, label);
63
- if (atIndex >= 0 && atIndex < this.options.length) {
64
- this.options.splice(atIndex, 0, option);
65
- } else {
66
- this.options.push(option);
67
- }
68
- return option;
69
- }
70
-
71
- deleteOption(option: BuilderOption): boolean {
72
- const filtered = this.options.filter((o) => o.id !== option.id);
73
- const didDelete = filtered.length === this.options.length - 1;
74
- this.options = filtered;
75
- return didDelete;
76
- }
77
-
78
- toJson() {
79
- const optionsJson = this.options.map((o) => o.toJson());
80
- const dto: BuilderQuestionDto = {
81
- id: this.id,
82
- prefix: this.prefix,
83
- _type: this.type,
84
- text: this.questionText,
85
- options: optionsJson,
86
- };
87
- return dto;
88
- }
89
-
90
- clone(): BuilderQuestionDto {
91
- const cloneId = BuilderObjectId.questionId();
92
- const dto = this.toJson();
93
- const optionsClone = this.options.map((o) => o.clone());
94
- const clonedDto: BuilderQuestionDto = {
95
- ...dto,
96
- id: cloneId,
97
- options: optionsClone,
98
- };
99
- return clonedDto;
100
- }
101
- }
1
+ import type { BuilderOptionDto } from "./Builder-option";
2
+ import { BuilderOption } from "./Builder-option";
3
+ import { BuilderObject, BuilderObjectId } from "./BuilderObject";
4
+
5
+ export type BuilderQuestionType =
6
+ | "select-one"
7
+ | "select-many"
8
+ | "text"
9
+ | "color"
10
+ | "radio"
11
+ | "email"
12
+ | "time"
13
+ | "checkbox"
14
+ | "textarea"
15
+ | "date"
16
+ | "numeric-range"
17
+ | "duration";
18
+
19
+ export interface BuilderQuestionDto {
20
+ readonly id: BuilderObjectId.QuestionID;
21
+ _type: BuilderQuestionType;
22
+ text: string;
23
+ options: ReadonlyArray<BuilderOptionDto>;
24
+ prefix: string;
25
+ }
26
+
27
+ export class BuilderQuestion extends BuilderObject<"builder-question", BuilderQuestionDto> {
28
+ readonly objectType = "builder-question";
29
+ id: BuilderObjectId.QuestionID;
30
+ type: BuilderQuestionType;
31
+ questionText = "";
32
+ options: BuilderOption[] = [];
33
+ prefix = "";
34
+
35
+ static create = (type: BuilderQuestionType) => {
36
+ const id = BuilderObjectId.questionId();
37
+
38
+ return new BuilderQuestion({
39
+ id,
40
+ _type: type,
41
+ text: "",
42
+ options: [],
43
+ prefix: "",
44
+ });
45
+ };
46
+
47
+ public static fromJson(dto: BuilderQuestionDto): BuilderQuestion {
48
+ const question = new BuilderQuestion(dto);
49
+ return question;
50
+ }
51
+
52
+ private constructor(dto: BuilderQuestionDto) {
53
+ super(dto);
54
+ this.id = dto.id as BuilderObjectId.QuestionID;
55
+ this.type = dto._type;
56
+ this.questionText = dto.text;
57
+ this.prefix = dto.prefix;
58
+ this.options = dto.options.map((o) => BuilderOption.fromJson(o));
59
+ }
60
+
61
+ addOption(label: string, value: number, atIndex = -1) {
62
+ const option = BuilderOption.create(value, label);
63
+ if (atIndex >= 0 && atIndex < this.options.length) {
64
+ this.options.splice(atIndex, 0, option);
65
+ } else {
66
+ this.options.push(option);
67
+ }
68
+ return option;
69
+ }
70
+
71
+ deleteOption(option: BuilderOption): boolean {
72
+ const filtered = this.options.filter((o) => o.id !== option.id);
73
+ const didDelete = filtered.length === this.options.length - 1;
74
+ this.options = filtered;
75
+ return didDelete;
76
+ }
77
+
78
+ toJson() {
79
+ const optionsJson = this.options.map((o) => o.toJson());
80
+ const dto: BuilderQuestionDto = {
81
+ id: this.id,
82
+ prefix: this.prefix,
83
+ _type: this.type,
84
+ text: this.questionText,
85
+ options: optionsJson,
86
+ };
87
+ return dto;
88
+ }
89
+
90
+ clone(): BuilderQuestionDto {
91
+ const cloneId = BuilderObjectId.questionId();
92
+ const dto = this.toJson();
93
+ const optionsClone = this.options.map((o) => o.clone());
94
+ const clonedDto: BuilderQuestionDto = {
95
+ ...dto,
96
+ id: cloneId,
97
+ options: optionsClone,
98
+ };
99
+ return clonedDto;
100
+ }
101
+ }