@media-quest/builder 0.0.14 → 0.0.16

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.
@@ -2,32 +2,32 @@ import { AbstractThemeCompiler } from "./AbstractThemeCompiler";
2
2
  import type { BuilderSchemaDto } from "../Builder-schema";
3
3
  import { BuilderSchema } from "../Builder-schema";
4
4
  import type { BuilderPageDto } from "../Builder-page";
5
- import { DStateProps } from "./standard-props";
6
5
  import { ThemeUtils } from "./theme-utils";
7
6
  import { DefaultTheme, type IDefaultTheme } from "./IDefaultTheme";
8
7
  import type { BuilderMainImageDto } from "../BuilderMainImageDto";
9
8
  import type { BuilderMainVideoDto } from "../BuilderMainVideoDto";
10
9
  import {
11
- DAudioDto,
12
- DAutoPlaySequence,
13
- DCommand,
10
+ ButtonClickAction,
14
11
  DDivDto,
15
12
  DElementDto,
16
13
  DImgDto,
17
14
  DTextDto,
18
15
  DUtil,
19
- DVideoDto,
20
- Fact,
21
16
  PageDto,
22
- PageQueCommand,
17
+ PageComponentDto,
18
+ RuleActionPageQue,
19
+ PlayAudioTask,
20
+ PlayVideoTask,
23
21
  Rule,
24
22
  SchemaDto,
23
+ DelayTask,
25
24
  } from "@media-quest/engine";
25
+
26
26
  import { AudioFile } from "../media-files";
27
27
  import { BuilderRule } from "../rulebuilder";
28
28
 
29
29
  const U = DUtil;
30
- const generateElementId = () => U.randomString(32);
30
+
31
31
  export class DefaultThemeCompiler extends AbstractThemeCompiler<IDefaultTheme> {
32
32
  readonly name = "Ispe default theme.";
33
33
  private readonly TAG = "[ DEFAULT_THEME_COMPILER ]: ";
@@ -35,10 +35,10 @@ export class DefaultThemeCompiler extends AbstractThemeCompiler<IDefaultTheme> {
35
35
  super(DefaultTheme);
36
36
  }
37
37
 
38
- private compileRules(source: BuilderSchemaDto): Rule<PageQueCommand, never>[] {
38
+ private compileRules(source: BuilderSchemaDto): Rule<RuleActionPageQue, never>[] {
39
39
  const builderSchema = BuilderSchema.fromJson(source);
40
40
  const ruleInput = builderSchema.getRuleInput();
41
- const pageQueRules: Rule<PageQueCommand, never>[] = [];
41
+ const pageQueRules: Rule<RuleActionPageQue, never>[] = [];
42
42
  source.rules.forEach((rule) => {
43
43
  const engineRule = BuilderRule.fromDto(rule, ruleInput).toEngineRule();
44
44
  if (!Rule.isEmpty(engineRule)) {
@@ -56,7 +56,6 @@ export class DefaultThemeCompiler extends AbstractThemeCompiler<IDefaultTheme> {
56
56
  compile(source: BuilderSchemaDto): SchemaDto {
57
57
  const pages = source.pages.map((p) => this.compilePage(p, source.prefix));
58
58
  const rules = this.compileRules(source);
59
- // console.log(pages.map((p) => p.tags));
60
59
 
61
60
  const dto: SchemaDto = {
62
61
  backgroundColor: source.backgroundColor,
@@ -67,270 +66,219 @@ export class DefaultThemeCompiler extends AbstractThemeCompiler<IDefaultTheme> {
67
66
  pages,
68
67
  predefinedFacts: [],
69
68
  rules,
70
- stateFromEvent: [
71
- {
72
- onEvent: "VIDEO_ENDED_EVENT",
73
- thenExecute: [
74
- DStateProps.userPausedVideo.getSetFalseCommand(),
75
- DStateProps.mediaBlockedByVideo.getSetFalseCommand(),
76
- DStateProps.videoIsPlaying.getSetFalseCommand(),
77
- ],
78
- },
79
- {
80
- onEvent: "VIDEO_PAUSED_EVENT",
81
- thenExecute: [
82
- DStateProps.videoIsPlaying.getSetFalseCommand(),
83
- DStateProps.mediaBlockedByVideo.getSetFalseCommand(),
84
- ],
85
- },
86
- {
87
- onEvent: "VIDEO_PLAY_EVENT",
88
- thenExecute: [
89
- DStateProps.videoIsPlaying.getSetTrueCommand(),
90
- DStateProps.userPausedVideo.getSetFalseCommand(),
91
- ],
92
- },
93
- {
94
- onEvent: "AUDIO_PLAY_EVENT",
95
- thenExecute: [
96
- DStateProps.audioIsPlaying.getSetTrueCommand(),
97
- DStateProps.mediaBlockedByAudio.getSetTrueCommand(),
98
- ],
99
- },
100
- {
101
- onEvent: "AUDIO_ENDED_EVENT",
102
- thenExecute: [
103
- DStateProps.audioIsPlaying.getSetFalseCommand(),
104
- DStateProps.mediaBlockedByAudio.getSetFalseCommand(),
105
- ],
106
- },
107
- {
108
- onEvent: "AUDIO_PAUSED_EVENT",
109
- thenExecute: [
110
- DStateProps.audioIsPlaying.getSetFalseCommand(),
111
- DStateProps.mediaBlockedByAudio.getSetFalseCommand(),
112
- ],
113
- },
114
- ],
115
- stateProps: DStateProps.allDefaultProperties.map((def) => def.propDefinition),
116
- stateQueries: DStateProps.allDefaultQueries,
117
69
  };
118
70
  return dto;
119
71
  }
120
72
  private compilePage(page: BuilderPageDto, modulePrefix: string): PageDto {
121
- // console.log(_moduleId);
122
- // const textElement
123
73
  const tags = page.tags ?? [];
124
74
  const { nextButton, mainText, id, mainMedia, _type } = page;
125
- const elements: DElementDto[] = [];
126
- const audioResourcesDto: DAudioDto[] = [];
127
- const videoResources: DVideoDto[] = [];
128
- let mainVideo: DVideoDto | false = false;
129
- let mainTextAudio: DAudioDto | false = false;
75
+ const staticElements: DElementDto[] = [];
76
+ let initialAudioTasks: Array<PlayAudioTask | DelayTask> = [];
77
+ let initialVideoTaskList: Array<PlayVideoTask | DelayTask> = [];
78
+ const newPage: PageDto = {
79
+ background: "white",
80
+ components: [],
81
+ staticElements,
82
+ id,
83
+ initialTasks: [],
84
+ tags: [...tags],
85
+ };
130
86
 
131
87
  if (page.mainText.audioFile) {
132
- const res = this.compileMainTextAudio(page.mainText.audioFile);
133
- elements.push(...res.elements);
134
- audioResourcesDto.push(res.audioDto);
135
- mainTextAudio = res.audioDto;
88
+ const autoPlay = page.mainText.autoplay;
89
+ const autoPlayDelay = page.mainText.autoplayDelay;
90
+ const res = this.compileMainTextAudio(page.mainText.audioFile, autoPlay, autoPlayDelay);
91
+ initialAudioTasks = [...res.initialTasks];
92
+ newPage.components.push(...res.components);
136
93
  }
137
94
 
138
95
  if (_type === "question") {
139
96
  const variableId = modulePrefix + "_" + page.prefix;
140
- const { buttons, question } = this.compileQuestion(id, page, variableId);
97
+ const { components, question } = this.compileQuestion(id, page, variableId);
98
+ newPage.components.push(...components);
99
+ newPage.staticElements.push(question);
141
100
  // console.log(question);
142
- elements.push(...buttons, question);
101
+ // elements.push(...buttons, question);
143
102
  }
144
103
 
145
104
  if (_type === "info-page") {
146
105
  const infoText = mainText.text;
147
- const nextBtnElement: DElementDto = this.compileButton(id, nextButton, {
106
+ const nextButtonComponent = this.compileButton(nextButton, {
148
107
  kind: "next-button",
149
108
  });
150
- const textStyle = mainMedia ? DefaultTheme.mainText.withMedia.text.css : DefaultTheme.mainText.noMedia.text.css;
151
- const element: DElementDto = {
152
- text: infoText,
109
+
110
+ const textStyle = mainMedia
111
+ ? DefaultTheme.mainText.withMedia.text.css
112
+ : DefaultTheme.mainText.noMedia.text.css;
113
+ const infoTextElement: DElementDto = {
114
+ innerText: infoText,
153
115
  _tag: "p",
154
- id: generateElementId(),
155
116
  style: textStyle,
156
117
  };
157
- elements.push(element);
158
- elements.push(nextBtnElement);
118
+ newPage.staticElements.push(infoTextElement);
119
+ newPage.components.push(nextButtonComponent);
159
120
  }
160
121
  if (mainMedia && mainMedia.kind === "main-image") {
161
122
  const mainImageElement = this.compileImage(mainMedia);
162
- elements.push(mainImageElement);
123
+ newPage.staticElements.push(mainImageElement);
163
124
  }
164
125
 
165
126
  if (mainMedia && mainMedia.kind === "main-video") {
166
127
  const videoOutput = this.compileVideo(mainMedia);
167
- mainVideo = videoOutput.videoDto;
168
- elements.push(...videoOutput.elements);
169
- videoResources.push(videoOutput.videoDto);
170
- }
171
- const mainVideoId = mainVideo ? mainVideo.id : undefined;
172
- const autoPlaySequence: DAutoPlaySequence = {
173
- blockUserInput: true,
174
- id: "1",
175
- items: [],
176
- startCommands: [
177
- DStateProps.mediaBlockedBySequence.getSetTrueCommand(),
178
- DStateProps.inputBlockingBySequence.getSetTrueCommand(),
179
- ],
180
- endCommands: [
181
- DStateProps.mediaBlockedBySequence.getSetFalseCommand(),
182
- DStateProps.inputBlockingBySequence.getSetFalseCommand(),
183
- ],
184
- };
185
-
186
- if (mainVideo && page.mainMedia && page.mainMedia.kind === "main-video" && page.mainMedia.mode === "autoplay") {
187
- autoPlaySequence.items.push({
188
- kind: "autoplay-video",
189
- videoId: mainVideo.id,
190
- });
128
+ newPage.videoPlayer = videoOutput.videoPlayer;
129
+ newPage.components.push(...videoOutput.components);
130
+ initialVideoTaskList = [...videoOutput.autoPlayTasks];
191
131
  }
192
132
 
193
- if (mainTextAudio && page.mainText.autoplay) {
194
- autoPlaySequence.items.push({
195
- kind: "autoplay-audio",
196
- audioId: mainTextAudio.id,
197
- });
198
- }
199
-
200
- const pageDto: PageDto = {
201
- audio: audioResourcesDto,
202
- autoPlaySequence: autoPlaySequence,
203
- backgroundColor: "red",
204
- elements,
205
- id,
206
- mainVideoId,
207
- tags: [...tags],
208
- video: videoResources,
209
- };
210
- return pageDto;
133
+ // ADDING INITIAL TASKS IN CORRECT ORDER
134
+ newPage.initialTasks.push(...initialVideoTaskList);
135
+ newPage.initialTasks.push(...initialAudioTasks);
136
+ const clone = JSON.parse(JSON.stringify(newPage));
137
+ return clone;
211
138
  }
212
139
 
213
140
  private compileImage(image: BuilderMainImageDto) {
214
141
  const img: DImgDto = {
215
142
  _tag: "img",
216
- id: image.file.id,
217
143
  style: this.theme.image.style,
218
144
  url: image.file.downloadUrl,
219
145
  };
220
146
  return img;
221
147
  }
222
148
 
223
- private compileMainTextAudio(audioFile: AudioFile): {
224
- audioDto: DAudioDto;
225
- elements: DElementDto[];
149
+ private compileMainTextAudio(
150
+ audioFile: AudioFile,
151
+ autoPlay: boolean,
152
+ autoPlayDelay: number,
153
+ ): {
154
+ components: PageComponentDto[];
155
+ initialTasks: Array<PlayAudioTask | DelayTask>;
226
156
  } {
227
157
  const t = this.theme.mainText;
228
158
  const audioId = audioFile.id;
229
159
  const iconUrl =
230
160
  "https://firebasestorage.googleapis.com/v0/b/ispe-backend-dev.appspot.com/o/public-assets%2Fvolume_up-24px.svg?alt=media&token=551bd0a6-a515-4f87-a245-da433f4833f9";
231
161
 
232
- const buttonId = U.randomString(30);
233
162
  const playMainTextAudio: DImgDto = {
234
163
  _tag: "img",
235
- id: buttonId,
236
164
  url: iconUrl,
237
165
  style: { ...t.withMedia.audio.css },
238
- onClick: [
239
- {
240
- kind: "AUDIO_PLAY_COMMAND",
241
- target: "AUDIO",
242
- targetId: audioId,
243
- payload: { volume: 1 },
244
- },
245
- ],
246
- onStateChange: [
247
- {
248
- queryName: DStateProps._Queries.disableAudioIconQuery.name,
249
- whenTrue: [...ThemeUtils.disableClickCommands(buttonId, t.withMedia.audio.cssDisabled)],
250
- whenFalse: [...ThemeUtils.enableClickCommands(buttonId, t.withMedia.audio.cssEnabled)],
251
- },
252
- ],
253
166
  };
254
- const audioDto: DAudioDto = {
255
- _tag: "audio",
256
- // eventHandlers: [],
257
- id: audioFile.id,
167
+
168
+ const task: PlayAudioTask = {
169
+ audioId,
170
+ blockAudio: false,
171
+ blockFormInput: false,
172
+ blockResponseButton: false,
173
+ blockVideo: false,
174
+ kind: "play-audio-task",
175
+ priority: "replace-all",
258
176
  url: audioFile.downloadUrl,
259
177
  };
260
- return { audioDto, elements: [playMainTextAudio] };
178
+
179
+ let initialAudioTasks: Array<PlayAudioTask | DelayTask> = [];
180
+ if (autoPlay) {
181
+ const playAudioTask: PlayAudioTask = { ...task, priority: "follow-queue" };
182
+ initialAudioTasks = [playAudioTask];
183
+ if (autoPlayDelay > 0) {
184
+ const delayTask: DelayTask = {
185
+ kind: "delay-task",
186
+ priority: "follow-queue",
187
+ duration: autoPlayDelay,
188
+ blockVideo: false,
189
+ blockAudio: false,
190
+ blockResponseButton: false,
191
+ blockFormInput: false,
192
+ };
193
+ initialAudioTasks = [delayTask, playAudioTask];
194
+ }
195
+ }
196
+ // const autoplayTask =
197
+ const playBtn: PageComponentDto = {
198
+ el: playMainTextAudio,
199
+ onClick: { kind: "play-audio", task },
200
+ };
201
+
202
+ return { components: [playBtn], initialTasks: [...initialAudioTasks] };
261
203
  }
262
204
 
263
- private compileVideo(video: BuilderMainVideoDto) {
205
+ private compileVideo(video: BuilderMainVideoDto): {
206
+ videoPlayer: PageDto["videoPlayer"];
207
+ components: PageComponentDto[];
208
+ autoPlayTasks: Array<PlayVideoTask | DelayTask>;
209
+ } {
264
210
  const t = this.theme.videoPlayer;
265
- const videoId = video.file.id;
266
- const playButtonId = "play-btn-for" + videoId;
267
- const pauseButtonId = "pause-btn-for" + videoId;
268
- const elements: DElementDto[] = [];
269
- const videoDto: DVideoDto = {
270
- _tag: "video",
271
- id: video.file.id,
272
- style: t.videoElement.css,
211
+ const mode = video.mode;
212
+ const components: PageComponentDto[] = [];
213
+
214
+ let autoPlayTasks: Array<PlayVideoTask | DelayTask> = [];
215
+
216
+ let autoplayVideoTask: PlayVideoTask | false = false;
217
+ let autoplayDelayTask: DelayTask | false = false;
218
+
219
+ const playButtonTask: PlayVideoTask = {
220
+ kind: "play-video-task",
273
221
  url: video.file.downloadUrl,
222
+ videoId: video.file.id,
223
+ blockAudio: false,
224
+ blockFormInput: false,
225
+ blockResponseButton: false,
226
+ loop: mode === "gif-mode",
227
+ blockVideo: false,
228
+ priority: "replace-all",
274
229
  };
275
- const playBtn: DImgDto = {
276
- id: playButtonId,
277
- _tag: "img",
278
- url: t.playButton.iconUrl,
279
- style: { ...t.playButton.css, ...t.playButton.cssEnabled },
280
- onClick: [
281
- {
282
- kind: "VIDEO_PLAY_COMMAND",
283
- target: "VIDEO",
284
- targetId: videoId,
285
- payload: {},
286
- },
287
- // TODO Check if this video shall block other media first?
288
- DStateProps.mediaBlockedByVideo.getSetTrueCommand(),
289
- DStateProps.userPausedVideo.getSetFalseCommand(),
290
- ],
291
- onStateChange: [
292
- {
293
- queryName: DStateProps._Queries.disableVideoPlayQuery.name,
294
- whenTrue: [...ThemeUtils.disableClickCommands(playButtonId, t.playButton.cssDisabled)],
295
- whenFalse: [...ThemeUtils.enableClickCommands(playButtonId, t.playButton.cssEnabled)],
296
- },
297
- {
298
- queryName: DStateProps._Queries.hideVideoPlayQuery.name,
299
- whenTrue: [ThemeUtils.hideCommand(playButtonId)],
300
- whenFalse: [ThemeUtils.showCommand(playButtonId)],
301
- },
302
- ],
230
+
231
+ if (video.mode === "autoplay" || video.mode === "gif-mode") {
232
+ autoplayVideoTask = { ...playButtonTask, priority: "follow-queue" };
233
+ autoPlayTasks = [autoplayVideoTask];
234
+ if (video.preDelay > 0) {
235
+ autoplayDelayTask = {
236
+ kind: "delay-task",
237
+ priority: "follow-queue",
238
+ duration: video.preDelay,
239
+ blockVideo: false,
240
+ blockAudio: false,
241
+ blockResponseButton: false,
242
+ blockFormInput: false,
243
+ };
244
+ autoPlayTasks = [autoplayDelayTask, autoplayVideoTask];
245
+ }
246
+ }
247
+
248
+ const videoPlayer: PageDto["videoPlayer"] = {
249
+ playUrl: video.file.downloadUrl,
250
+ style: { h: 45, w: 100, x: 0, y: 55 },
303
251
  };
304
- const pauseBtn: DImgDto = {
305
- id: pauseButtonId,
306
- _tag: "img",
307
- style: {
308
- ...t.pauseButton.css,
309
- visibility: "hidden",
310
- ...t.pauseButton.cssEnabled,
252
+ const playButton: PageComponentDto = {
253
+ el: {
254
+ _tag: "img",
255
+ url: t.playButton.iconUrl,
256
+ style: { ...t.playButton.css, ...t.playButton.cssEnabled },
311
257
  },
312
- url: t.pauseButton.iconUrl,
313
- onClick: [
314
- {
315
- kind: "VIDEO_PAUSE_COMMAND",
316
- target: "VIDEO",
317
- targetId: videoId,
318
- payload: {},
319
- },
320
- DStateProps.mediaBlockedByVideo.getSetFalseCommand(),
321
- DStateProps.userPausedVideo.getSetTrueCommand(),
322
- ],
323
- onStateChange: [
324
- {
325
- queryName: DStateProps._Queries.hideVideoPauseQuery.name,
326
- whenTrue: [ThemeUtils.hideCommand(pauseButtonId)],
327
- whenFalse: [ThemeUtils.showCommand(pauseButtonId)],
258
+ onClick: { kind: "play-video", task: playButtonTask },
259
+ whenVideoPlay: { visibility: "hidden" },
260
+ whenVideoPaused: { visibility: "visible" },
261
+ };
262
+ const pauseBtn: PageComponentDto = {
263
+ el: {
264
+ _tag: "img",
265
+ style: {
266
+ ...t.pauseButton.css,
267
+ visibility: "hidden",
268
+ ...t.pauseButton.cssEnabled,
328
269
  },
329
- ],
270
+ url: t.pauseButton.iconUrl,
271
+ },
272
+ onClick: { kind: "pause-video" },
273
+ whenVideoPlay: { visibility: "visible" },
274
+ whenVideoPaused: { visibility: "hidden" },
330
275
  };
331
- elements.push(playBtn);
332
- elements.push(pauseBtn);
333
- return { videoDto, elements };
276
+
277
+ if (mode !== "gif-mode") {
278
+ components.push(playButton);
279
+ components.push(pauseBtn);
280
+ }
281
+ return { videoPlayer, components, autoPlayTasks: [...autoPlayTasks] };
334
282
  }
335
283
  private compileQuestion(
336
284
  pageId: string,
@@ -338,7 +286,7 @@ export class DefaultThemeCompiler extends AbstractThemeCompiler<IDefaultTheme> {
338
286
  variableId: string,
339
287
  ): {
340
288
  question: DTextDto;
341
- buttons: DDivDto[];
289
+ components: PageComponentDto[];
342
290
  } {
343
291
  // TODO REFACTORE DEFAULT QUESTION TO - (REMOVE USE TEXT1)
344
292
  // console.log(page);
@@ -349,80 +297,63 @@ export class DefaultThemeCompiler extends AbstractThemeCompiler<IDefaultTheme> {
349
297
  : DefaultTheme.mainText.noMedia.text.css;
350
298
  const question: DTextDto = {
351
299
  _tag: "p",
352
- text,
353
- eventHandlers: [],
354
- id: U.randomString(30),
355
- onClick: [],
356
- onStateChange: [],
300
+ innerText: text,
357
301
  style: questionStyle,
358
302
  };
359
- const buttons = q.options.map((o) => {
360
- const btns = this.compileButton(pageId, o, {
303
+ const buttons: PageComponentDto[] = q.options.map((o) => {
304
+ const btns = this.compileButton(o, {
361
305
  kind: "response-button",
362
306
  questionId: variableId,
363
307
  });
364
308
  return btns;
365
309
  });
366
- ThemeUtils.spaceEvenlyX(buttons);
367
- return { question, buttons };
310
+ const rootElements = buttons.map((b) => b.el);
311
+ ThemeUtils.spaceEvenlyX(rootElements);
312
+ return { question, components: buttons };
368
313
  }
369
314
 
370
315
  private compileButton(
371
- pageId: string,
372
316
  buttonDto: BuilderPageDto["nextButton"],
373
317
  options: { kind: "response-button"; questionId: string } | { kind: "next-button" },
374
- ) {
375
- const factsCollected: Fact[] = [];
318
+ ): PageComponentDto {
376
319
  const { id, value, label } = buttonDto;
320
+ const onclickAction: ButtonClickAction =
321
+ options.kind === "response-button"
322
+ ? {
323
+ kind: "submit-fact",
324
+ fact: {
325
+ kind: "numeric-fact",
326
+ label: label,
327
+ value: value,
328
+ referenceId: options.questionId,
329
+ referenceLabel: "QuestionId: " + options.questionId,
330
+ },
331
+ }
332
+ : { kind: "next-page" };
377
333
 
378
- // const { div, text1, dontKnow } = DefaultTheme.responseButtons;
379
- if (options.kind === "response-button") {
380
- const fact: Fact = {
381
- kind: "numeric-fact",
382
- label: label,
383
- value: value,
384
- referenceId: options.questionId,
385
- referenceLabel: "QuestionId: " + options.questionId,
386
- };
387
- factsCollected.push(fact);
388
- }
389
-
390
- const onClickHandler: DCommand = {
391
- kind: "ENGINE_LEAVE_PAGE_COMMAND",
392
- target: "ENGINE",
393
- targetId: "ENGINE",
394
- payload: {
395
- pageId,
396
- factsCollected,
397
- },
398
- };
399
- const btnStyles = value === 9 ? DefaultTheme.responseButtons.dontKnow : DefaultTheme.responseButtons.normal;
334
+ const btnStyles =
335
+ value === 9 ? DefaultTheme.responseButtons.dontKnow : DefaultTheme.responseButtons.normal;
400
336
  const btn: DDivDto = {
401
- id,
402
337
  _tag: "div",
403
338
  children: [
404
339
  {
405
340
  _tag: "p",
406
- id: U.randomString(30),
407
- text: label,
341
+ innerText: label,
408
342
  style: btnStyles.text1,
409
343
  },
410
344
  ],
411
- onStateChange: [
412
- {
413
- queryName: DStateProps._Queries.disableUserInputQuery.name,
414
- whenFalse: [...ThemeUtils.enableClickCommands(id, btnStyles.btn.cssEnabled)],
415
- whenTrue: [...ThemeUtils.disableClickCommands(id, btnStyles.btn.cssDisabled)],
416
- },
417
- ],
418
345
  style: { ...btnStyles.btn.css, ...btnStyles.btn.cssEnabled },
419
- onClick: [onClickHandler],
420
346
  };
347
+
421
348
  if (options.kind === "next-button") {
422
349
  btn.style.x = 50;
423
350
  btn.style.y = 8;
424
351
  btn.style.transform = "translate(-50%, 0%)";
425
352
  }
426
- return btn;
353
+ const component: PageComponentDto = {
354
+ el: btn,
355
+ onClick: onclickAction,
356
+ };
357
+ return component;
427
358
  }
428
359
  }
@@ -1,60 +1,7 @@
1
- import { DCommand, ElementCommand } from "@media-quest/engine";
2
1
  import { DStyle } from "@media-quest/engine";
3
2
  import { DElementDto } from "@media-quest/engine";
4
3
 
5
4
  export namespace ThemeUtils {
6
- export const disableClickCommands = (elementId: string, styleChanges: Partial<DStyle>): ElementCommand[] => {
7
- return [
8
- {
9
- kind: "ELEMENT_DISABLE_CLICK_COMMAND",
10
- target: "ELEMENT",
11
- targetId: elementId,
12
- payload: {},
13
- },
14
- {
15
- kind: "ELEMENT_STYLE_COMMAND",
16
- target: "ELEMENT",
17
- targetId: elementId,
18
- payload: { changes: styleChanges },
19
- },
20
- ];
21
- };
22
-
23
- export const enableClickCommands = (elementId: string, styleChanges: Partial<DStyle>): ElementCommand[] => {
24
- return [
25
- {
26
- kind: "ELEMENT_ENABLE_CLICK_COMMAND",
27
- target: "ELEMENT",
28
- targetId: elementId,
29
- payload: {},
30
- },
31
- {
32
- kind: "ELEMENT_STYLE_COMMAND",
33
- target: "ELEMENT",
34
- targetId: elementId,
35
- payload: { changes: styleChanges },
36
- },
37
- ];
38
- };
39
- export const hideCommand = (elementId: string): ElementCommand => {
40
- const hideCommand: DCommand = {
41
- kind: "ELEMENT_STYLE_COMMAND",
42
- target: "ELEMENT",
43
- targetId: elementId,
44
- payload: { changes: { visibility: "hidden" } },
45
- };
46
- return hideCommand;
47
- };
48
- export const showCommand = (elementId: string): ElementCommand => {
49
- const showCommand: DCommand = {
50
- kind: "ELEMENT_STYLE_COMMAND",
51
- target: "ELEMENT",
52
- targetId: elementId,
53
- payload: { changes: { visibility: "visible" } },
54
- };
55
- return showCommand;
56
- };
57
-
58
5
  export const spaceEvenlyX = <T extends Pick<DElementDto, "style">>(
59
6
  items: ReadonlyArray<T>,
60
7
  options: { startAt: number; endAt: number; defaultItemWidth: number } = {