@media-quest/builder 0.0.38 → 0.0.40

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 (41) hide show
  1. package/dist/public-api.d.ts +82 -99
  2. package/dist/public-api.js +36 -101
  3. package/dist/public-api.js.map +1 -1
  4. package/package.json +29 -29
  5. package/src/{theme → ARKIV}/button-bar/button-text-utils.ts +233 -233
  6. package/src/{theme → ARKIV}/button-bar/text-utils.spec.ts +105 -105
  7. package/src/Builder-option.ts +78 -62
  8. package/src/Builder-question.ts +98 -98
  9. package/src/Builder-schema.spec.ts +348 -348
  10. package/src/Builder-schema.ts +308 -306
  11. package/src/builder-compiler.ts +14 -20
  12. package/src/code-book/codebook-variable.ts +27 -27
  13. package/src/code-book/codebook.ts +89 -89
  14. package/src/media-files.ts +28 -32
  15. package/src/page/Builder-page-collection.spec.ts +219 -219
  16. package/src/page/Builder-page-collection.ts +129 -129
  17. package/src/page/Builder-page.spec.ts +177 -177
  18. package/src/page/Builder-page.ts +250 -250
  19. package/src/primitives/ID.ts +135 -135
  20. package/src/public-api.ts +29 -30
  21. package/src/rulebuilder/RuleAction.ts +105 -105
  22. package/src/schema-config.ts +25 -26
  23. package/src/sum-score/sum-score-variable-collection.spec.ts +68 -68
  24. package/src/sum-score/sum-score-variable-collection.ts +101 -101
  25. package/src/sum-score/sum-score-variable.ts +0 -1
  26. package/src/sum-score/sum-score.ts +166 -167
  27. package/src/tag/BuilderTag.ts +45 -45
  28. package/src/tag/Tag-Collection.ts +53 -53
  29. package/src/theme/Default-theme.ts +173 -188
  30. package/src/theme/IDefault-theme.ts +125 -125
  31. package/src/theme/ThemeCompiler.ts +10 -11
  32. package/src/theme/default-theme-compiler.spec.ts +31 -31
  33. package/src/theme/default-theme-compiler.ts +655 -652
  34. package/src/theme/icon-urls.ts +29 -29
  35. package/src/theme/icons.ts +117 -117
  36. package/src/theme/theme-utils.spec.ts +52 -52
  37. package/src/theme/theme-utils.ts +56 -56
  38. package/src/theme/theme2.ts +388 -386
  39. package/tsconfig.json +19 -19
  40. package/src/Builder-schema-dto.spec.ts +0 -155
  41. package/src/Builder-schema-dto.ts +0 -86
@@ -1,20 +1,14 @@
1
- import { SchemaDto } from "@media-quest/engine";
2
- import { Codebook } from "./code-book/codebook";
3
- import { SchemaConfig } from "./schema-config";
4
-
5
- export interface CompilerOutput {
6
- schema: SchemaDto;
7
- codebook: Codebook;
8
- schemaConfig: SchemaConfig;
9
- }
10
-
11
- export interface CompilerOption {
12
- blockAutoplayQuestion: boolean;
13
- blockAutoplayVideo: boolean;
14
- mediaAssets: {
15
- audioFilesBaseUrl: string;
16
- videoFilesBaseUrl: string;
17
- imageFilesBaseUrl: string;
18
- fileNameStrategy: "id" | "newFileName" | "originalFileName" | "relativePath";
19
- } | null;
20
- }
1
+ import { SchemaDto } from "@media-quest/engine";
2
+ import { Codebook } from "./code-book/codebook";
3
+ import { SchemaConfig } from "./schema-config";
4
+
5
+ export interface CompilerOutput {
6
+ schema: SchemaDto;
7
+ codebook: Codebook;
8
+ schemaConfig: SchemaConfig;
9
+ }
10
+
11
+ export interface CompilerOption {
12
+ blockAutoplayQuestion: boolean;
13
+ blockAutoplayVideo: boolean;
14
+ }
@@ -1,27 +1,27 @@
1
- import { PageID } from "../primitives/ID";
2
- import { SumScoreVariableDto } from "../sum-score/sum-score-variable";
3
-
4
- /**
5
- * Interface representing a code book question sum-score.
6
- *
7
- * @interface
8
- */
9
- export interface CodeBookQuestionVariable {
10
- readonly kind: "codebook-question-variable";
11
- readonly label: string;
12
- readonly varId: string;
13
- readonly pageId: PageID;
14
- readonly pagePrefix: string;
15
- readonly modulePrefix: string;
16
- readonly pagePosition: number;
17
- readonly options: ReadonlyArray<{ label: string; value: number }>;
18
- readonly includedInSumScores: ReadonlyArray<SumScoreVariableDto>;
19
- }
20
-
21
- export interface CodebookPredefinedVariable {
22
- readonly kind: "codebook-predefined-variable";
23
- readonly modulePrefix: string;
24
- readonly moduleID: string;
25
- defaultValue: number;
26
- options: Array<{ label: string; value: number }>;
27
- }
1
+ import { PageID } from "../primitives/ID";
2
+ import { SumScoreVariableDto } from "../sum-score/sum-score-variable";
3
+
4
+ /**
5
+ * Interface representing a code book question sum-score.
6
+ *
7
+ * @interface
8
+ */
9
+ export interface CodeBookQuestionVariable {
10
+ readonly kind: "codebook-question-variable";
11
+ readonly label: string;
12
+ readonly varId: string;
13
+ readonly pageId: PageID;
14
+ readonly pagePrefix: string;
15
+ readonly modulePrefix: string;
16
+ readonly pagePosition: number;
17
+ readonly options: ReadonlyArray<{ label: string; value: number }>;
18
+ readonly includedInSumScores: ReadonlyArray<SumScoreVariableDto>;
19
+ }
20
+
21
+ export interface CodebookPredefinedVariable {
22
+ readonly kind: "codebook-predefined-variable";
23
+ readonly modulePrefix: string;
24
+ readonly moduleID: string;
25
+ defaultValue: number;
26
+ options: Array<{ label: string; value: number }>;
27
+ }
@@ -1,89 +1,89 @@
1
- import { BuilderPageDto } from "../page/Builder-page";
2
- import { CodeBookQuestionVariable, CodebookPredefinedVariable } from "./codebook-variable";
3
- import { SumScoreVariableDto } from "../sum-score/sum-score-variable";
4
- import { BuilderSchemaDto } from "../Builder-schema-dto";
5
-
6
- export interface Codebook {
7
- readonly predefinedVariables: ReadonlyArray<CodebookPredefinedVariable>;
8
- readonly pageVariables: ReadonlyArray<CodeBookQuestionVariable>;
9
- }
10
-
11
- const fromPage = (
12
- page: BuilderPageDto,
13
- sumScoreVariables: ReadonlyArray<SumScoreVariableDto>,
14
- pagePosition: number,
15
- modulePrefix: string,
16
- ): CodeBookQuestionVariable[] => {
17
- const variables: CodeBookQuestionVariable[] = [];
18
-
19
- if (page._type !== "question") {
20
- // TODO Implement form field variables
21
- return [];
22
- }
23
-
24
- const options: CodeBookQuestionVariable["options"] = page.defaultQuestion.options.map((o) => {
25
- return { value: o.value, label: o.label };
26
- });
27
-
28
- const varId = modulePrefix + "_" + page.prefix;
29
- const pageIncludedInSumScoresArray = page.includedInSumScores ?? [];
30
-
31
- const includedInSumScores: SumScoreVariableDto[] = [];
32
- pageIncludedInSumScoresArray.forEach((p) => {
33
- sumScoreVariables.forEach((ssv) => {
34
- if (p.sumScoreVariableId === ssv.id) {
35
- includedInSumScores.push(ssv);
36
- }
37
- });
38
- });
39
-
40
- const variable: CodeBookQuestionVariable = {
41
- kind: "codebook-question-variable",
42
- label: page.mainText.text,
43
- pageId: page.id,
44
- pagePrefix: page.prefix,
45
- options,
46
- modulePrefix,
47
- pagePosition,
48
- varId,
49
- includedInSumScores,
50
- };
51
-
52
- variables.push(variable);
53
-
54
- return variables;
55
- };
56
-
57
- /**
58
- * Converts a list of pages into a list of question-variables
59
- * @param pages
60
- * @param sumScoreVariables
61
- * @param modulePrefix
62
- */
63
- const getPageVariablesFromPages = (
64
- pages: ReadonlyArray<BuilderPageDto>,
65
- sumScoreVariables: ReadonlyArray<SumScoreVariableDto>,
66
- modulePrefix: string,
67
- ): CodeBookQuestionVariable[] => {
68
- const variables: CodeBookQuestionVariable[] = [];
69
- pages.forEach((page, index) => {
70
- const pageVariables = fromPage(page, sumScoreVariables, index, modulePrefix);
71
- variables.push(...pageVariables);
72
- });
73
- return variables;
74
- };
75
-
76
- const fromSchema = (schema: BuilderSchemaDto): Codebook => {
77
- const modulePrefix = schema.prefix;
78
- const sumScoreVariables = schema.sumScoreVariables ?? [];
79
- const pageVariables = getPageVariablesFromPages(schema.pages, sumScoreVariables, modulePrefix);
80
- const vs = schema.predefinedVariables;
81
- const predefinedVariables: CodebookPredefinedVariable[] = vs ? [...vs] : [];
82
- return { pageVariables, predefinedVariables };
83
- };
84
-
85
- export const _CodeBook = {
86
- fromSchema,
87
- } as const;
88
-
89
- export const CodeBook = Object.freeze(_CodeBook);
1
+ import { BuilderPageDto } from "../page/Builder-page";
2
+ import { BuilderSchemaDto } from "../Builder-schema";
3
+ import { CodeBookQuestionVariable, CodebookPredefinedVariable } from "./codebook-variable";
4
+ import { SumScoreVariableDto } from "../sum-score/sum-score-variable";
5
+
6
+ export interface Codebook {
7
+ readonly predefinedVariables: ReadonlyArray<CodebookPredefinedVariable>;
8
+ readonly pageVariables: ReadonlyArray<CodeBookQuestionVariable>;
9
+ }
10
+
11
+ const fromPage = (
12
+ page: BuilderPageDto,
13
+ sumScoreVariables: ReadonlyArray<SumScoreVariableDto>,
14
+ pagePosition: number,
15
+ modulePrefix: string,
16
+ ): CodeBookQuestionVariable[] => {
17
+ const variables: CodeBookQuestionVariable[] = [];
18
+
19
+ if (page._type !== "question") {
20
+ // TODO Implement form field variables
21
+ return [];
22
+ }
23
+
24
+ const options: CodeBookQuestionVariable["options"] = page.defaultQuestion.options.map((o) => {
25
+ return { value: o.value, label: o.label };
26
+ });
27
+
28
+ const varId = modulePrefix + "_" + page.prefix;
29
+ const pageIncludedInSumScoresArray = page.includedInSumScores ?? [];
30
+
31
+ const includedInSumScores: SumScoreVariableDto[] = [];
32
+ pageIncludedInSumScoresArray.forEach((p) => {
33
+ sumScoreVariables.forEach((ssv) => {
34
+ if (p.sumScoreVariableId === ssv.id) {
35
+ includedInSumScores.push(ssv);
36
+ }
37
+ });
38
+ });
39
+
40
+ const variable: CodeBookQuestionVariable = {
41
+ kind: "codebook-question-variable",
42
+ label: page.mainText.text,
43
+ pageId: page.id,
44
+ pagePrefix: page.prefix,
45
+ options,
46
+ modulePrefix,
47
+ pagePosition,
48
+ varId,
49
+ includedInSumScores,
50
+ };
51
+
52
+ variables.push(variable);
53
+
54
+ return variables;
55
+ };
56
+
57
+ /**
58
+ * Converts a list of pages into a list of question-variables
59
+ * @param pages
60
+ * @param sumScoreVariables
61
+ * @param modulePrefix
62
+ */
63
+ const getPageVariablesFromPages = (
64
+ pages: ReadonlyArray<BuilderPageDto>,
65
+ sumScoreVariables: ReadonlyArray<SumScoreVariableDto>,
66
+ modulePrefix: string,
67
+ ): CodeBookQuestionVariable[] => {
68
+ const variables: CodeBookQuestionVariable[] = [];
69
+ pages.forEach((page, index) => {
70
+ const pageVariables = fromPage(page, sumScoreVariables, index, modulePrefix);
71
+ variables.push(...pageVariables);
72
+ });
73
+ return variables;
74
+ };
75
+
76
+ const fromSchema = (schema: BuilderSchemaDto): Codebook => {
77
+ const modulePrefix = schema.prefix;
78
+ const sumScoreVariables = schema.sumScoreVariables ?? [];
79
+ const pageVariables = getPageVariablesFromPages(schema.pages, sumScoreVariables, modulePrefix);
80
+ const vs = schema.predefinedVariables;
81
+ const predefinedVariables: CodebookPredefinedVariable[] = vs ? [...vs] : [];
82
+ return { pageVariables, predefinedVariables };
83
+ };
84
+
85
+ export const _CodeBook = {
86
+ fromSchema,
87
+ } as const;
88
+
89
+ export const CodeBook = Object.freeze(_CodeBook);
@@ -1,32 +1,28 @@
1
- export interface AudioFile {
2
- readonly kind: "audio-file";
3
- readonly id: string;
4
- downloadUrl: string;
5
- readonly duration: number;
6
- readonly originalFileName: string;
7
- readonly name: string;
8
- readonly size: number;
9
- readonly relativePath?: string;
10
- }
11
-
12
- export interface VideoFile {
13
- readonly kind: "video-file";
14
- readonly id: string;
15
- downloadUrl: string;
16
- readonly duration: number;
17
- readonly name: string;
18
- readonly size: number;
19
- readonly type: string;
20
- readonly originalFileName: string;
21
- readonly relativePath?: string;
22
- }
23
- export interface ImageFile {
24
- readonly kind: "image-file";
25
- readonly id: string;
26
- downloadUrl: string;
27
- readonly name: string;
28
- readonly size: number;
29
- readonly type: string;
30
- readonly originalFileName?: string;
31
- readonly relativePath?: string;
32
- }
1
+ export interface AudioFile {
2
+ readonly kind: "audio-file";
3
+ readonly id: string;
4
+ readonly downloadUrl: string;
5
+ readonly duration: number;
6
+ readonly originalFileName: string;
7
+ readonly name: string;
8
+ readonly size: number;
9
+ }
10
+
11
+ export interface VideoFile {
12
+ readonly kind: "video-file";
13
+ readonly id: string;
14
+ readonly downloadUrl: string;
15
+ readonly duration: number;
16
+ readonly name: string;
17
+ readonly size: number;
18
+ readonly type: string;
19
+ readonly originalFileName: string;
20
+ }
21
+ export interface ImageFile {
22
+ readonly kind: "image-file";
23
+ readonly id: string;
24
+ readonly downloadUrl: string;
25
+ readonly name: string;
26
+ readonly size: number;
27
+ readonly type: string;
28
+ }