@media-quest/builder 0.0.39 → 0.0.41
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.
- package/dist/public-api.d.ts +82 -100
- package/dist/public-api.js +68 -128
- package/dist/public-api.js.map +1 -1
- package/package.json +29 -29
- package/src/{theme → ARKIV}/button-bar/button-text-utils.ts +233 -233
- package/src/{theme → ARKIV}/button-bar/text-utils.spec.ts +105 -105
- package/src/Builder-option.ts +77 -62
- package/src/Builder-question.spec.ts +1 -0
- package/src/Builder-question.ts +97 -98
- package/src/Builder-schema.spec.ts +348 -348
- package/src/Builder-schema.ts +308 -306
- package/src/builder-compiler.ts +14 -20
- package/src/code-book/codebook-variable.ts +27 -27
- package/src/code-book/codebook.ts +89 -89
- package/src/media-files.ts +28 -32
- package/src/page/Builder-page-collection.spec.ts +224 -219
- package/src/page/Builder-page-collection.ts +129 -129
- package/src/page/Builder-page.spec.ts +177 -177
- package/src/page/Builder-page.ts +250 -250
- package/src/primitives/ID.ts +135 -135
- package/src/public-api.ts +29 -30
- package/src/rulebuilder/RuleAction.ts +105 -105
- package/src/schema-config.ts +25 -26
- package/src/sum-score/sum-score-variable-collection.spec.ts +68 -68
- package/src/sum-score/sum-score-variable-collection.ts +101 -101
- package/src/sum-score/sum-score-variable.ts +0 -1
- package/src/sum-score/sum-score.ts +166 -167
- package/src/tag/BuilderTag.ts +45 -45
- package/src/tag/Tag-Collection.ts +53 -53
- package/src/theme/Default-theme.ts +173 -188
- package/src/theme/IDefault-theme.ts +124 -125
- package/src/theme/ThemeCompiler.ts +10 -11
- package/src/theme/default-theme-compiler.spec.ts +31 -31
- package/src/theme/default-theme-compiler.ts +660 -652
- package/src/theme/icon-urls.ts +29 -29
- package/src/theme/icons.ts +117 -117
- package/src/theme/theme-utils.spec.ts +52 -52
- package/src/theme/theme-utils.ts +56 -56
- package/src/theme/theme2.ts +399 -386
- package/tsconfig.json +19 -19
- package/src/Builder-schema-dto.spec.ts +0 -155
- package/src/Builder-schema-dto.ts +0 -86
package/src/builder-compiler.ts
CHANGED
|
@@ -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
|
-
|
|
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 {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
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);
|
package/src/media-files.ts
CHANGED
|
@@ -1,32 +1,28 @@
|
|
|
1
|
-
export interface AudioFile {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
+
}
|