@media-quest/builder 0.0.22 → 0.0.24

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 +51 -0
  8. package/src/Builder-schema.ts +47 -15
  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 +146 -0
  53. package/src/{mq-variable.ts → variable/mq-variable.ts} +8 -1
  54. package/src/variable/sum-score.ts +138 -0
  55. package/tsconfig.json +15 -15
  56. package/tsconfig.tsbuildinfo +1 -1
@@ -1,208 +1,208 @@
1
- import { BuilderObject } from "../../BuilderObject";
2
- import { BuilderOperator } from "./Builder-operator";
3
- import type { BuilderVariable, BuilderVariableOption } from "../RuleVariable";
4
- import { OperatorSelectItem, RuleOptionSelectItem, RuleVariableSelectItem } from "../SingleSelectItem";
5
- import { Condition } from "@media-quest/engine";
6
- export interface BuilderConditionDto {
7
- readonly kind: "condition";
8
- readonly operator: BuilderOperator | "";
9
- readonly name: string;
10
- readonly variableId: string;
11
- readonly value: number | string | boolean;
12
- }
13
-
14
- export class BuilderCondition extends BuilderObject<"builder-condition", BuilderConditionDto> {
15
- readonly objectType: "builder-condition" = "builder-condition";
16
- public static readonly NUMBER_OPERATORS: ReadonlyArray<OperatorSelectItem> = [
17
- OperatorSelectItem.EQ,
18
- OperatorSelectItem.NOT_EQ,
19
- ];
20
-
21
- private initialDto: BuilderConditionDto;
22
- name = "";
23
-
24
- public static create = (variableList: ReadonlyArray<BuilderVariable>) => {
25
- const condition = new BuilderCondition(
26
- {
27
- kind: "condition",
28
- name: "",
29
- operator: "",
30
- variableId: "",
31
- value: "",
32
- },
33
- variableList,
34
- );
35
- return condition;
36
- };
37
-
38
- public static fromDto = (dto: BuilderConditionDto, variables: ReadonlyArray<BuilderVariable>) => {
39
- const _dto: BuilderConditionDto = {
40
- kind: "condition",
41
- name: dto.name ?? "",
42
- value: dto.value ?? "",
43
- operator: dto.operator ?? "",
44
- variableId: dto.variableId ?? "",
45
- };
46
- const instance = new BuilderCondition(_dto, variables);
47
- return instance;
48
- };
49
- private _variable: BuilderVariable | false = false;
50
- private _operator: BuilderOperator | "" = "";
51
- private _value: BuilderVariableOption | false = false;
52
- private _variableList: ReadonlyArray<BuilderVariable> = [];
53
-
54
- /**
55
- * Can only set variables that exist in variableList.
56
- * @param variable
57
- */
58
- set variable(variable: BuilderVariable | false) {
59
- if (variable === this._variable) {
60
- return;
61
- }
62
- this._variable = variable;
63
- this._operator = "";
64
- this._value = false;
65
- }
66
-
67
- get variable() {
68
- return this._variable;
69
- }
70
-
71
- set value(variableValue: BuilderVariableOption | false) {
72
- this._value = variableValue;
73
- }
74
- get value() {
75
- return this._value;
76
- }
77
-
78
- validate(): { isValid: true } | { isValid: false; message: string } {
79
- if (this._variableList.length === 0) {
80
- return {
81
- isValid: false,
82
- message: "Has no variableList to check dto against.",
83
- };
84
- }
85
- if (!this._variable) {
86
- return {
87
- isValid: false,
88
- message: "Variable has not been initialized from variableList.",
89
- };
90
- }
91
-
92
- if (!this._operator) {
93
- return { isValid: false, message: "Operator has not been initialized" };
94
- }
95
-
96
- if (!this._value) {
97
- return {
98
- isValid: false,
99
- message: "Value (BuilderVariableOption) is not initialized",
100
- };
101
- }
102
-
103
- return { isValid: true };
104
- }
105
-
106
- toEngineCondition(): Condition.Simple | false {
107
- const val = this.value;
108
- const op = this._operator;
109
- const v = this._variable;
110
- if (!val) return false;
111
- if (!op) return false;
112
- if (!v) return false;
113
- if (op === "equal") {
114
- const engineCondition: Condition.Simple = {
115
- kind: "numeric-condition",
116
- value: val.value,
117
- valueLabel: val.label,
118
- referenceId: v.varId,
119
- referenceLabel: v.label,
120
- operator: "eq",
121
- };
122
- return engineCondition;
123
- }
124
- return false;
125
- }
126
-
127
- private findVariableInUniverse(variableId: string): BuilderVariable | false {
128
- const v = this._variableList.find((v) => v.varId === variableId);
129
- return v ?? false;
130
- }
131
-
132
- set operator(operator: BuilderOperator | "") {
133
- if (BuilderOperator.is(operator)) {
134
- this._operator = operator;
135
- } else {
136
- this._operator = "";
137
- }
138
- }
139
-
140
- get operator() {
141
- return this._operator;
142
- }
143
-
144
- private constructor(dto: BuilderConditionDto, variables: ReadonlyArray<BuilderVariable>) {
145
- super(dto);
146
- this.initialDto = dto;
147
- this.name = dto.name;
148
- this._setVariableList(variables);
149
- }
150
-
151
- get variableSelectItemsInUniverse(): ReadonlyArray<RuleVariableSelectItem> {
152
- return this._variableList.map(RuleVariableSelectItem.create);
153
- }
154
-
155
- get operatorsSelectItems(): ReadonlyArray<OperatorSelectItem> {
156
- return this._variable ? BuilderCondition.NUMBER_OPERATORS : [];
157
- }
158
-
159
- get selectValueItems(): ReadonlyArray<RuleOptionSelectItem> {
160
- if (!this._variable) {
161
- return [];
162
- }
163
- const opt = this._variable.options.map(RuleOptionSelectItem.create);
164
- return opt;
165
- }
166
-
167
- clone(): BuilderConditionDto {
168
- return this.toJson();
169
- }
170
-
171
- private _setVariableList(variables: ReadonlyArray<BuilderVariable>): boolean {
172
- this._variableList = variables;
173
- const v = this._variableList.find((v) => v.varId === this.originalDto.variableId);
174
- if (!v) {
175
- this._variable = false;
176
- this._operator = "";
177
- this._value = false;
178
- return false;
179
- }
180
- this._variable = v;
181
- const op = this.originalDto.operator;
182
-
183
- if (!BuilderOperator.is(op)) {
184
- return false;
185
- }
186
- this._operator = op;
187
- const maybeOption = v.options.find((op) => op.value === this.originalDto.value);
188
- if (!maybeOption) {
189
- return false;
190
- }
191
- this._value = maybeOption;
192
- return true;
193
- }
194
-
195
- toJson(): BuilderConditionDto {
196
- const name = this.name;
197
- const variableId = this._variable ? this._variable.varId : "";
198
- const operator = this._operator ? this._operator : "";
199
- const value = this._value ? this._value.value : "";
200
- return {
201
- kind: "condition",
202
- name,
203
- operator,
204
- variableId,
205
- value,
206
- };
207
- }
208
- }
1
+ import { BuilderObject } from "../../BuilderObject";
2
+ import { BuilderOperator } from "./Builder-operator";
3
+ import type { BuilderVariable, BuilderVariableOption } from "../RuleVariable";
4
+ import { OperatorSelectItem, RuleOptionSelectItem, RuleVariableSelectItem } from "../SingleSelectItem";
5
+ import { Condition } from "@media-quest/engine";
6
+ export interface BuilderConditionDto {
7
+ readonly kind: "condition";
8
+ readonly operator: BuilderOperator | "";
9
+ readonly name: string;
10
+ readonly variableId: string;
11
+ readonly value: number | string | boolean;
12
+ }
13
+
14
+ export class BuilderCondition extends BuilderObject<"builder-condition", BuilderConditionDto> {
15
+ readonly objectType: "builder-condition" = "builder-condition";
16
+ public static readonly NUMBER_OPERATORS: ReadonlyArray<OperatorSelectItem> = [
17
+ OperatorSelectItem.EQ,
18
+ OperatorSelectItem.NOT_EQ,
19
+ ];
20
+
21
+ private initialDto: BuilderConditionDto;
22
+ name = "";
23
+
24
+ public static create = (variableList: ReadonlyArray<BuilderVariable>) => {
25
+ const condition = new BuilderCondition(
26
+ {
27
+ kind: "condition",
28
+ name: "",
29
+ operator: "",
30
+ variableId: "",
31
+ value: "",
32
+ },
33
+ variableList,
34
+ );
35
+ return condition;
36
+ };
37
+
38
+ public static fromDto = (dto: BuilderConditionDto, variables: ReadonlyArray<BuilderVariable>) => {
39
+ const _dto: BuilderConditionDto = {
40
+ kind: "condition",
41
+ name: dto.name ?? "",
42
+ value: dto.value ?? "",
43
+ operator: dto.operator ?? "",
44
+ variableId: dto.variableId ?? "",
45
+ };
46
+ const instance = new BuilderCondition(_dto, variables);
47
+ return instance;
48
+ };
49
+ private _variable: BuilderVariable | false = false;
50
+ private _operator: BuilderOperator | "" = "";
51
+ private _value: BuilderVariableOption | false = false;
52
+ private _variableList: ReadonlyArray<BuilderVariable> = [];
53
+
54
+ /**
55
+ * Can only set variables that exist in variableList.
56
+ * @param variable
57
+ */
58
+ set variable(variable: BuilderVariable | false) {
59
+ if (variable === this._variable) {
60
+ return;
61
+ }
62
+ this._variable = variable;
63
+ this._operator = "";
64
+ this._value = false;
65
+ }
66
+
67
+ get variable() {
68
+ return this._variable;
69
+ }
70
+
71
+ set value(variableValue: BuilderVariableOption | false) {
72
+ this._value = variableValue;
73
+ }
74
+ get value() {
75
+ return this._value;
76
+ }
77
+
78
+ validate(): { isValid: true } | { isValid: false; message: string } {
79
+ if (this._variableList.length === 0) {
80
+ return {
81
+ isValid: false,
82
+ message: "Has no variableList to check dto against.",
83
+ };
84
+ }
85
+ if (!this._variable) {
86
+ return {
87
+ isValid: false,
88
+ message: "Variable has not been initialized from variableList.",
89
+ };
90
+ }
91
+
92
+ if (!this._operator) {
93
+ return { isValid: false, message: "Operator has not been initialized" };
94
+ }
95
+
96
+ if (!this._value) {
97
+ return {
98
+ isValid: false,
99
+ message: "Value (BuilderVariableOption) is not initialized",
100
+ };
101
+ }
102
+
103
+ return { isValid: true };
104
+ }
105
+
106
+ toEngineCondition(): Condition.Simple | false {
107
+ const val = this.value;
108
+ const op = this._operator;
109
+ const v = this._variable;
110
+ if (!val) return false;
111
+ if (!op) return false;
112
+ if (!v) return false;
113
+ if (op === "equal") {
114
+ const engineCondition: Condition.Simple = {
115
+ kind: "numeric-condition",
116
+ value: val.value,
117
+ valueLabel: val.label,
118
+ referenceId: v.varId,
119
+ referenceLabel: v.label,
120
+ operator: "eq",
121
+ };
122
+ return engineCondition;
123
+ }
124
+ return false;
125
+ }
126
+
127
+ private findVariableInUniverse(variableId: string): BuilderVariable | false {
128
+ const v = this._variableList.find((v) => v.varId === variableId);
129
+ return v ?? false;
130
+ }
131
+
132
+ set operator(operator: BuilderOperator | "") {
133
+ if (BuilderOperator.is(operator)) {
134
+ this._operator = operator;
135
+ } else {
136
+ this._operator = "";
137
+ }
138
+ }
139
+
140
+ get operator() {
141
+ return this._operator;
142
+ }
143
+
144
+ private constructor(dto: BuilderConditionDto, variables: ReadonlyArray<BuilderVariable>) {
145
+ super(dto);
146
+ this.initialDto = dto;
147
+ this.name = dto.name;
148
+ this._setVariableList(variables);
149
+ }
150
+
151
+ get variableSelectItemsInUniverse(): ReadonlyArray<RuleVariableSelectItem> {
152
+ return this._variableList.map(RuleVariableSelectItem.create);
153
+ }
154
+
155
+ get operatorsSelectItems(): ReadonlyArray<OperatorSelectItem> {
156
+ return this._variable ? BuilderCondition.NUMBER_OPERATORS : [];
157
+ }
158
+
159
+ get selectValueItems(): ReadonlyArray<RuleOptionSelectItem> {
160
+ if (!this._variable) {
161
+ return [];
162
+ }
163
+ const opt = this._variable.options.map(RuleOptionSelectItem.create);
164
+ return opt;
165
+ }
166
+
167
+ clone(): BuilderConditionDto {
168
+ return this.toJson();
169
+ }
170
+
171
+ private _setVariableList(variables: ReadonlyArray<BuilderVariable>): boolean {
172
+ this._variableList = variables;
173
+ const v = this._variableList.find((v) => v.varId === this.originalDto.variableId);
174
+ if (!v) {
175
+ this._variable = false;
176
+ this._operator = "";
177
+ this._value = false;
178
+ return false;
179
+ }
180
+ this._variable = v;
181
+ const op = this.originalDto.operator;
182
+
183
+ if (!BuilderOperator.is(op)) {
184
+ return false;
185
+ }
186
+ this._operator = op;
187
+ const maybeOption = v.options.find((op) => op.value === this.originalDto.value);
188
+ if (!maybeOption) {
189
+ return false;
190
+ }
191
+ this._value = maybeOption;
192
+ return true;
193
+ }
194
+
195
+ toJson(): BuilderConditionDto {
196
+ const name = this.name;
197
+ const variableId = this._variable ? this._variable.varId : "";
198
+ const operator = this._operator ? this._operator : "";
199
+ const value = this._value ? this._value.value : "";
200
+ return {
201
+ kind: "condition",
202
+ name,
203
+ operator,
204
+ variableId,
205
+ value,
206
+ };
207
+ }
208
+ }
@@ -1,9 +1,9 @@
1
- import { BuilderOperator } from "./Builder-operator";
2
-
3
- describe("Builder Operator", () => {
4
- test("Can validate symbol", () => {
5
- let symbol: BuilderOperator = "notBetween";
6
- expect(BuilderOperator.is("invalid")).toBe(false);
7
- expect(BuilderOperator.is(symbol)).toBe(true);
8
- });
9
- });
1
+ import { BuilderOperator } from "./Builder-operator";
2
+
3
+ describe("Builder Operator", () => {
4
+ test("Can validate symbol", () => {
5
+ let symbol: BuilderOperator = "notBetween";
6
+ expect(BuilderOperator.is("invalid")).toBe(false);
7
+ expect(BuilderOperator.is(symbol)).toBe(true);
8
+ });
9
+ });
@@ -1,31 +1,31 @@
1
- const BuilderOperatorSymbols = {
2
- equal: true,
3
- notEqual: true,
4
- lessThan: true,
5
- lessThanOrEqual: true,
6
- greaterThan: true,
7
- greaterThanOrEqual: true,
8
- between: true,
9
- notBetween: true,
10
- in: true,
11
- notIn: true,
12
- missing: true,
13
- notMissing: true,
14
- contains: true,
15
- notContains: true,
16
- empty: true,
17
- notEmpty: true,
18
- startsWith: true,
19
- endsWith: true,
20
- } as const;
21
-
22
- export type BuilderOperator = keyof typeof BuilderOperatorSymbols;
23
-
24
- export namespace BuilderOperator {
25
- export const is = (symbol?: string): symbol is BuilderOperator => {
26
- if (typeof symbol !== "string") {
27
- return false;
28
- }
29
- return Object.keys(BuilderOperatorSymbols).includes(symbol);
30
- };
31
- }
1
+ const BuilderOperatorSymbols = {
2
+ equal: true,
3
+ notEqual: true,
4
+ lessThan: true,
5
+ lessThanOrEqual: true,
6
+ greaterThan: true,
7
+ greaterThanOrEqual: true,
8
+ between: true,
9
+ notBetween: true,
10
+ in: true,
11
+ notIn: true,
12
+ missing: true,
13
+ notMissing: true,
14
+ contains: true,
15
+ notContains: true,
16
+ empty: true,
17
+ notEmpty: true,
18
+ startsWith: true,
19
+ endsWith: true,
20
+ } as const;
21
+
22
+ export type BuilderOperator = keyof typeof BuilderOperatorSymbols;
23
+
24
+ export namespace BuilderOperator {
25
+ export const is = (symbol?: string): symbol is BuilderOperator => {
26
+ if (typeof symbol !== "string") {
27
+ return false;
28
+ }
29
+ return Object.keys(BuilderOperatorSymbols).includes(symbol);
30
+ };
31
+ }
@@ -1,22 +1,22 @@
1
- export { BuilderCondition, type BuilderConditionDto } from "./condition/Builder-condition";
2
- export {
3
- BuilderConditionGroup,
4
- type BuilderConditionGroupDto,
5
- type ConditionGroupType,
6
- } from "./condition/Builder-condition-group";
7
- export { BuilderOperator } from "./condition/Builder-operator";
8
- export { BuilderRule, type BuilderRuleDto } from "./Builder-rule";
9
- export { JumpToActionManager } from "./jump-to-action-manager";
10
- export { MultiSelectItem, ExcludeByPageIdSelectItem, ExcludeByTagSelectItem } from "./multi-select-item";
11
- export { PageActionManager } from "./page-action-manager";
12
- export { type ExcludeByPageAction, type ExcludeByTagAction, type JumpToPageAction } from "./RuleAction";
13
- export { RuleInput } from "./RuleInput";
14
- export { CustomVariable, BuilderVariableOption, type BuilderVariable, QuestionVariable } from "./RuleVariable";
15
- export {
16
- SingleSelectItem,
17
- OperatorSelectItem,
18
- RuleOptionSelectItem,
19
- RuleVariableSelectItem,
20
- JumpToPageSelectItem,
21
- } from "./SingleSelectItem";
22
- export { TagActionManager } from "./tag-action-manager";
1
+ export { BuilderCondition, type BuilderConditionDto } from "./condition/Builder-condition";
2
+ export {
3
+ BuilderConditionGroup,
4
+ type BuilderConditionGroupDto,
5
+ type ConditionGroupType,
6
+ } from "./condition/Builder-condition-group";
7
+ export { BuilderOperator } from "./condition/Builder-operator";
8
+ export { BuilderRule, type BuilderRuleDto } from "./Builder-rule";
9
+ export { JumpToActionManager } from "./jump-to-action-manager";
10
+ export { MultiSelectItem, ExcludeByPageIdSelectItem, ExcludeByTagSelectItem } from "./multi-select-item";
11
+ export { PageActionManager } from "./page-action-manager";
12
+ export { type ExcludeByPageAction, type ExcludeByTagAction, type JumpToPageAction } from "./RuleAction";
13
+ export { RuleInput } from "./RuleInput";
14
+ export { CustomVariable, BuilderVariableOption, type BuilderVariable, QuestionVariable } from "./RuleVariable";
15
+ export {
16
+ SingleSelectItem,
17
+ OperatorSelectItem,
18
+ RuleOptionSelectItem,
19
+ RuleVariableSelectItem,
20
+ JumpToPageSelectItem,
21
+ } from "./SingleSelectItem";
22
+ export { TagActionManager } from "./tag-action-manager";
@@ -1,33 +1,33 @@
1
- import type { RuleInput } from "./RuleInput";
2
- import { JumpToPageSelectItem } from "./SingleSelectItem";
3
-
4
- export class JumpToActionManager {
5
- readonly options: ReadonlyArray<JumpToPageSelectItem>;
6
- private _selected: JumpToPageSelectItem | false;
7
- constructor(
8
- private readonly validOptions: RuleInput["_jumpActions"],
9
- private readonly initialSelection: string | false | undefined,
10
- ) {
11
- this.options = validOptions.map(JumpToPageSelectItem.create);
12
- this._selected = this.findSelected(initialSelection);
13
- }
14
- get selected(): JumpToPageSelectItem | false {
15
- return this._selected;
16
- }
17
- set selected(selected: JumpToPageSelectItem | false) {
18
- this._selected = this.findSelected(selected);
19
- }
20
- getSelectedPageId(): string | false {
21
- return this._selected ? this._selected.data.pageId : false;
22
- }
23
- private findSelected(value: unknown): JumpToPageSelectItem | false {
24
- if (!value) return false;
25
- if (value instanceof JumpToPageSelectItem) {
26
- return this.options.find((v) => v === value) || false;
27
- }
28
- if (typeof value === "string") {
29
- return this.options.find((v) => v.data.pageId === value) || false;
30
- }
31
- return false;
32
- }
33
- }
1
+ import type { RuleInput } from "./RuleInput";
2
+ import { JumpToPageSelectItem } from "./SingleSelectItem";
3
+
4
+ export class JumpToActionManager {
5
+ readonly options: ReadonlyArray<JumpToPageSelectItem>;
6
+ private _selected: JumpToPageSelectItem | false;
7
+ constructor(
8
+ private readonly validOptions: RuleInput["_jumpActions"],
9
+ private readonly initialSelection: string | false | undefined,
10
+ ) {
11
+ this.options = validOptions.map(JumpToPageSelectItem.create);
12
+ this._selected = this.findSelected(initialSelection);
13
+ }
14
+ get selected(): JumpToPageSelectItem | false {
15
+ return this._selected;
16
+ }
17
+ set selected(selected: JumpToPageSelectItem | false) {
18
+ this._selected = this.findSelected(selected);
19
+ }
20
+ getSelectedPageId(): string | false {
21
+ return this._selected ? this._selected.data.pageId : false;
22
+ }
23
+ private findSelected(value: unknown): JumpToPageSelectItem | false {
24
+ if (!value) return false;
25
+ if (value instanceof JumpToPageSelectItem) {
26
+ return this.options.find((v) => v === value) || false;
27
+ }
28
+ if (typeof value === "string") {
29
+ return this.options.find((v) => v.data.pageId === value) || false;
30
+ }
31
+ return false;
32
+ }
33
+ }