@siemens/live-preview 51.6.0 → 51.8.0

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.
@@ -1,2537 +1,2 @@
1
- import * as i0 from '@angular/core';
2
- import { inject, ChangeDetectorRef, ChangeDetectionStrategy, Component, InjectionToken, computed, signal, effect, Service, viewChild, output, input, NgZone, DestroyRef, Directive, ElementRef, untracked, Injectable, ViewContainerRef, Compiler, Injector, afterNextRender, ɵcompileComponent as _compileComponent, ɵresetCompiledComponents as _resetCompiledComponents, inputBinding, NgModule, ErrorHandler, createComponent, makeEnvironmentProviders } from '@angular/core';
3
- import * as i1$1 from '@angular/router';
4
- import { ActivatedRoute, Router, RouterLink, RouterLinkActive, RouterModule, provideRouter, withDisabledInitialNavigation, withHashLocation } from '@angular/router';
5
- import * as i1 from '@angular/forms';
6
- import { FormsModule, UntypedFormControl, ReactiveFormsModule } from '@angular/forms';
7
- import { Title, ɵDomRendererFactory2 as _DomRendererFactory2, createApplication, REMOVE_STYLES_ON_COMPONENT_DESTROY } from '@angular/platform-browser';
8
- import { throttleTime, timeout, retry, debounceTime, distinctUntilChanged } from 'rxjs/operators';
9
- import { KeyValuePipe, LocationStrategy, Location } from '@angular/common';
10
- import { httpResource, HttpClient } from '@angular/common/http';
11
- import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
12
- import CodeFlask from 'codeflask';
13
- import { fromEvent, Subject } from 'rxjs';
14
- import 'prismjs/components/prism-typescript';
15
- import qrcode from 'qrcode-generator';
16
- import sdk from '@stackblitz/sdk';
17
- import { __decorate } from 'tslib';
18
-
19
- /**
20
- * Copyright (c) Siemens 2016 - 2026
21
- * SPDX-License-Identifier: MIT
22
- */
23
- class SiDummyComponent {
24
- path = '';
25
- activeRoute = inject(ActivatedRoute);
26
- cdRef = inject(ChangeDetectorRef);
27
- constructor() {
28
- this.activeRoute.url.subscribe(url => {
29
- this.path = url.toString();
30
- this.cdRef.markForCheck();
31
- });
32
- }
33
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiDummyComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
34
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.8", type: SiDummyComponent, isStandalone: true, selector: "si-dummy", ngImport: i0, template: `<div class="ion-padding"> Content with path '{{ path }}'</div>`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.Eager });
35
- }
36
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiDummyComponent, decorators: [{
37
- type: Component,
38
- args: [{
39
- selector: 'si-dummy',
40
- template: `<div class="ion-padding"> Content with path '{{ path }}'</div>`,
41
- changeDetection: ChangeDetectionStrategy.Eager
42
- }]
43
- }], ctorParameters: () => [] });
44
-
45
- /**
46
- * Copyright (c) Siemens 2016 - 2026
47
- * SPDX-License-Identifier: MIT
48
- */
49
- const SI_LIVE_PREVIEW_CONFIG = new InjectionToken('SI_LIVE_PREVIEW_CONFIG');
50
- const SI_LIVE_PREVIEW_INTERNALS = new InjectionToken('SI_LIVE_PREVIEW_INTERNALS');
51
- const SI_LIVE_PREVIEW_EXAMPLE_ROUTES = new InjectionToken('SI_LIVE_PREVIEW_EXAMPLE_ROUTES');
52
-
53
- class SiLivePreviewThemeApi {
54
- }
55
- class SiLivePreviewLocaleApi {
56
- }
57
-
58
- /**
59
- * Copyright (c) Siemens 2016 - 2026
60
- * SPDX-License-Identifier: MIT
61
- */
62
- class LivePreviewStateService {
63
- router = inject(Router);
64
- overviewExample = computed(() => {
65
- this.router.lastSuccessfulNavigation();
66
- const route = this.findOverviewRoute(this.router.routerState.root);
67
- return this.getOverviewExample(route?.snapshot.url ?? []);
68
- }, /* @ts-ignore */
69
- ...(ngDevMode ? [{ debugName: "overviewExample" }] : /* istanbul ignore next */ []));
70
- delayedLogClearTimer;
71
- example = signal('', /* @ts-ignore */
72
- ...(ngDevMode ? [{ debugName: "example" }] : /* istanbul ignore next */ []));
73
- dataId = signal('', /* @ts-ignore */
74
- ...(ngDevMode ? [{ debugName: "dataId" }] : /* istanbul ignore next */ []));
75
- template = signal('', /* @ts-ignore */
76
- ...(ngDevMode ? [{ debugName: "template" }] : /* istanbul ignore next */ []));
77
- templateReact = signal('', /* @ts-ignore */
78
- ...(ngDevMode ? [{ debugName: "templateReact" }] : /* istanbul ignore next */ []));
79
- templateVue = signal('', /* @ts-ignore */
80
- ...(ngDevMode ? [{ debugName: "templateVue" }] : /* istanbul ignore next */ []));
81
- templateJs = signal('', /* @ts-ignore */
82
- ...(ngDevMode ? [{ debugName: "templateJs" }] : /* istanbul ignore next */ []));
83
- originalTemplate = signal('', /* @ts-ignore */
84
- ...(ngDevMode ? [{ debugName: "originalTemplate" }] : /* istanbul ignore next */ []));
85
- theme = signal('light', /* @ts-ignore */
86
- ...(ngDevMode ? [{ debugName: "theme" }] : /* istanbul ignore next */ []));
87
- locale = signal(undefined, /* @ts-ignore */
88
- ...(ngDevMode ? [{ debugName: "locale" }] : /* istanbul ignore next */ []));
89
- isRTL = signal(false, /* @ts-ignore */
90
- ...(ngDevMode ? [{ debugName: "isRTL" }] : /* istanbul ignore next */ []));
91
- rootFontSize = signal(0, /* @ts-ignore */
92
- ...(ngDevMode ? [{ debugName: "rootFontSize" }] : /* istanbul ignore next */ []));
93
- framework = signal('angular', /* @ts-ignore */
94
- ...(ngDevMode ? [{ debugName: "framework" }] : /* istanbul ignore next */ []));
95
- loadReact = signal(false, /* @ts-ignore */
96
- ...(ngDevMode ? [{ debugName: "loadReact" }] : /* istanbul ignore next */ []));
97
- loadVue = signal(false, /* @ts-ignore */
98
- ...(ngDevMode ? [{ debugName: "loadVue" }] : /* istanbul ignore next */ []));
99
- loadJs = signal(false, /* @ts-ignore */
100
- ...(ngDevMode ? [{ debugName: "loadJs" }] : /* istanbul ignore next */ []));
101
- supportsLandscape = signal(false, /* @ts-ignore */
102
- ...(ngDevMode ? [{ debugName: "supportsLandscape" }] : /* istanbul ignore next */ []));
103
- viewport = signal({ mode: 'ios' }, /* @ts-ignore */
104
- ...(ngDevMode ? [{ debugName: "viewport" }] : /* istanbul ignore next */ []));
105
- iFrameHeight = signal(undefined, /* @ts-ignore */
106
- ...(ngDevMode ? [{ debugName: "iFrameHeight" }] : /* istanbul ignore next */ []));
107
- iFrameWidth = signal(undefined, /* @ts-ignore */
108
- ...(ngDevMode ? [{ debugName: "iFrameWidth" }] : /* istanbul ignore next */ []));
109
- renderingError = signal(undefined, /* @ts-ignore */
110
- ...(ngDevMode ? [{ debugName: "renderingError" }] : /* istanbul ignore next */ []));
111
- logMessages = signal([], /* @ts-ignore */
112
- ...(ngDevMode ? [{ debugName: "logMessages" }] : /* istanbul ignore next */ []));
113
- newMessages = signal(false, /* @ts-ignore */
114
- ...(ngDevMode ? [{ debugName: "newMessages" }] : /* istanbul ignore next */ []));
115
- pendingOperations = signal(0, /* @ts-ignore */
116
- ...(ngDevMode ? [{ debugName: "pendingOperations" }] : /* istanbul ignore next */ []));
117
- inProgress = computed(() => this.pendingOperations() > 0, /* @ts-ignore */
118
- ...(ngDevMode ? [{ debugName: "inProgress" }] : /* istanbul ignore next */ []));
119
- templateModified = computed(() => this.originalTemplate() !== this.template(), /* @ts-ignore */
120
- ...(ngDevMode ? [{ debugName: "templateModified" }] : /* istanbul ignore next */ []));
121
- activeWebComponentTemplate = computed(() => {
122
- switch (this.framework()) {
123
- case 'react':
124
- return this.templateReact();
125
- case 'vue':
126
- return this.templateVue();
127
- case 'js':
128
- return this.templateJs();
129
- default:
130
- return '';
131
- }
132
- }, /* @ts-ignore */
133
- ...(ngDevMode ? [{ debugName: "activeWebComponentTemplate" }] : /* istanbul ignore next */ []));
134
- constructor() {
135
- effect(() => {
136
- const example = this.overviewExample();
137
- if (example !== undefined) {
138
- this.clearTemplates();
139
- this.example.set(example);
140
- }
141
- });
142
- }
143
- findOverviewRoute(route) {
144
- if (route.routeConfig?.path === 'overview') {
145
- let activeRoute = route;
146
- while (activeRoute.firstChild) {
147
- activeRoute = activeRoute.firstChild;
148
- }
149
- return activeRoute;
150
- }
151
- for (const child of route.children) {
152
- const overviewRoute = this.findOverviewRoute(child);
153
- if (overviewRoute) {
154
- return overviewRoute;
155
- }
156
- }
157
- return undefined;
158
- }
159
- getOverviewExample(segments) {
160
- return segments.length ? segments.join('/') : undefined;
161
- }
162
- setFramework(framework) {
163
- this.framework.set(framework);
164
- this.loadReact.set(framework === 'react');
165
- this.loadVue.set(framework === 'vue');
166
- this.loadJs.set(framework === 'js');
167
- }
168
- applyRenderRequest(request) {
169
- this.example.set(request.exampleUrl);
170
- this.template.set(request.template);
171
- this.loadReact.set(request.loadReact);
172
- this.loadVue.set(request.loadVue);
173
- this.loadJs.set(request.loadJs);
174
- if (request.loadReact) {
175
- this.framework.set('react');
176
- this.templateReact.set(request.reactVueTemplate);
177
- }
178
- else if (request.loadVue) {
179
- this.framework.set('vue');
180
- this.templateVue.set(request.reactVueTemplate);
181
- }
182
- else if (request.loadJs) {
183
- this.framework.set('js');
184
- this.templateJs.set(request.reactVueTemplate);
185
- }
186
- else {
187
- this.framework.set('angular');
188
- }
189
- this.viewport.set({
190
- mode: request.mode,
191
- safeAreaTop: request.safeAreaTop,
192
- safeAreaBottom: request.safeAreaBottom,
193
- safeAreaLeft: request.safeAreaLeft,
194
- safeAreaRight: request.safeAreaRight
195
- });
196
- }
197
- stopWebComponentLoading() {
198
- this.loadReact.set(false);
199
- this.loadVue.set(false);
200
- this.loadJs.set(false);
201
- }
202
- clearTemplates() {
203
- this.template.set('');
204
- this.templateReact.set('');
205
- this.templateVue.set('');
206
- this.templateJs.set('');
207
- this.originalTemplate.set('');
208
- }
209
- toggleTheme() {
210
- this.theme.update(theme => (theme === 'dark' ? 'light' : 'dark'));
211
- }
212
- setRenderingProgress(inProgress) {
213
- this.pendingOperations.update(count => Math.max(0, count + (inProgress ? 1 : -1)));
214
- }
215
- resetRenderingProgress() {
216
- this.pendingOperations.set(0);
217
- }
218
- addLog(message) {
219
- if (this.delayedLogClearTimer) {
220
- clearTimeout(this.delayedLogClearTimer);
221
- this.delayedLogClearTimer = undefined;
222
- this.logMessages.set([]);
223
- }
224
- this.logMessages.update(messages => [...messages, message]);
225
- this.newMessages.set(true);
226
- }
227
- clearLogs(delayed = false) {
228
- if (delayed && this.logMessages().length) {
229
- this.delayedLogClearTimer = setTimeout(() => {
230
- this.delayedLogClearTimer = undefined;
231
- this.logMessages.set([]);
232
- }, 100);
233
- return;
234
- }
235
- this.logMessages.set([]);
236
- }
237
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: LivePreviewStateService, deps: [], target: i0.ɵɵFactoryTarget.Service });
238
- static ɵprov = i0.ɵɵngDeclareService({ minVersion: "22.0.0", version: "22.0.8", ngImport: i0, type: LivePreviewStateService });
239
- }
240
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: LivePreviewStateService, decorators: [{
241
- type: Service
242
- }], ctorParameters: () => [] });
243
-
244
- /**
245
- * Copyright (c) Siemens 2016 - 2026
246
- * SPDX-License-Identifier: MIT
247
- */
248
- class SiLivePreviewIframeModeComponent {
249
- previewIframe = viewChild.required('previewIframe', /* @ts-ignore */
250
- ...(ngDevMode ? [{ debugName: "previewIframe" }] : /* istanbul ignore next */ []));
251
- iframeChange = output();
252
- ngAfterViewInit() {
253
- this.iframeChange.emit(this.previewIframe());
254
- }
255
- ngOnDestroy() {
256
- this.iframeChange.emit(undefined);
257
- }
258
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiLivePreviewIframeModeComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
259
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "22.0.8", type: SiLivePreviewIframeModeComponent, isStandalone: true, selector: "si-live-preview-iframe-mode", outputs: { iframeChange: "iframeChange" }, viewQueries: [{ propertyName: "previewIframe", first: true, predicate: ["previewIframe"], descendants: true, isSignal: true }], ngImport: i0, template: `<iframe #previewIframe src="#/iframe" title="Example view"></iframe>`, isInline: true, styles: [":host{display:block;flex:1;min-block-size:0}iframe{border:0;display:block;block-size:100%;inline-size:100%}\n"] });
260
- }
261
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiLivePreviewIframeModeComponent, decorators: [{
262
- type: Component,
263
- args: [{ selector: 'si-live-preview-iframe-mode', template: `<iframe #previewIframe src="#/iframe" title="Example view"></iframe>`, styles: [":host{display:block;flex:1;min-block-size:0}iframe{border:0;display:block;block-size:100%;inline-size:100%}\n"] }]
264
- }], propDecorators: { previewIframe: [{ type: i0.ViewChild, args: ['previewIframe', { isSignal: true }] }], iframeChange: [{ type: i0.Output, args: ["iframeChange"] }] } });
265
-
266
- /**
267
- * Copyright (c) Siemens 2016 - 2026
268
- * SPDX-License-Identifier: MIT
269
- */
270
- class SiLivePreviewQrComponent {
271
- url = input(/* @ts-ignore */
272
- ...(ngDevMode ? [undefined, { debugName: "url" }] : /* istanbul ignore next */ []));
273
- urlShort = input(/* @ts-ignore */
274
- ...(ngDevMode ? [undefined, { debugName: "urlShort" }] : /* istanbul ignore next */ []));
275
- closed = output();
276
- qrImg = computed(() => {
277
- const url = this.url();
278
- const urlShort = this.urlShort();
279
- if (!url || !urlShort) {
280
- return null;
281
- }
282
- const qr = qrcode(0, 'L');
283
- qr.addData(this.qrShort() ? urlShort : url);
284
- qr.make();
285
- return qr.createImgTag(2);
286
- }, /* @ts-ignore */
287
- ...(ngDevMode ? [{ debugName: "qrImg" }] : /* istanbul ignore next */ []));
288
- qrShort = computed(() => (this.url()?.length ?? 0) > 2953, /* @ts-ignore */
289
- ...(ngDevMode ? [{ debugName: "qrShort" }] : /* istanbul ignore next */ []));
290
- unlisten;
291
- ngAfterViewInit() {
292
- const listener = () => this.closed.emit();
293
- setTimeout(() => window.addEventListener('click', listener));
294
- this.unlisten = () => window.removeEventListener('click', listener);
295
- }
296
- ngOnDestroy() {
297
- if (this.unlisten) {
298
- this.unlisten();
299
- }
300
- }
301
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiLivePreviewQrComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
302
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.8", type: SiLivePreviewQrComponent, isStandalone: true, selector: "si-live-preview-qr", inputs: { url: { classPropertyName: "url", publicName: "url", isSignal: true, isRequired: false, transformFunction: null }, urlShort: { classPropertyName: "urlShort", publicName: "urlShort", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { closed: "closed" }, ngImport: i0, template: "<div class=\"qr\" [innerHTML]=\"qrImg()\"></div>\n@if (qrShort()) {\n <span>\n <b>Note</b>: not using template, too long for QR\n <span class=\"url-len\">({{ url()?.length }})</span>\n </span>\n}\n<hr />\n<a target=\"_blank\" [href]=\"url()\">Open in new tab</a>\n", styles: ["a{color:var(--si-sys-color-text-accent)}a:after{display:none}a:hover{color:var(--si-sys-color-text-accent-hover)}*:focus-visible{outline:var(--element-button-focus-width) solid var(--si-sys-color-effects-focus);outline-offset:var(--element-button-focus-overlay-width)}:host{position:absolute;z-index:1000;inset-block-start:100%;inset-inline-end:0;min-inline-size:150px;min-block-size:150px;padding:16px;margin-block-start:4px;border-radius:8px;box-shadow:0 0 8px #00000029,0 8px 8px #00000014;background:var(--si-sys-color-background-0)}.qr ::ng-deep img{max-inline-size:unset}hr{margin-block:12px;border:0;border-block-start:1px solid var(--si-sys-color-border-4)}.url-length{display:none}\n"], changeDetection: i0.ChangeDetectionStrategy.Eager });
303
- }
304
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiLivePreviewQrComponent, decorators: [{
305
- type: Component,
306
- args: [{ selector: 'si-live-preview-qr', changeDetection: ChangeDetectionStrategy.Eager, template: "<div class=\"qr\" [innerHTML]=\"qrImg()\"></div>\n@if (qrShort()) {\n <span>\n <b>Note</b>: not using template, too long for QR\n <span class=\"url-len\">({{ url()?.length }})</span>\n </span>\n}\n<hr />\n<a target=\"_blank\" [href]=\"url()\">Open in new tab</a>\n", styles: ["a{color:var(--si-sys-color-text-accent)}a:after{display:none}a:hover{color:var(--si-sys-color-text-accent-hover)}*:focus-visible{outline:var(--element-button-focus-width) solid var(--si-sys-color-effects-focus);outline-offset:var(--element-button-focus-overlay-width)}:host{position:absolute;z-index:1000;inset-block-start:100%;inset-inline-end:0;min-inline-size:150px;min-block-size:150px;padding:16px;margin-block-start:4px;border-radius:8px;box-shadow:0 0 8px #00000029,0 8px 8px #00000014;background:var(--si-sys-color-background-0)}.qr ::ng-deep img{max-inline-size:unset}hr{margin-block:12px;border:0;border-block-start:1px solid var(--si-sys-color-border-4)}.url-length{display:none}\n"] }]
307
- }], propDecorators: { url: [{ type: i0.Input, args: [{ isSignal: true, alias: "url", required: false }] }], urlShort: [{ type: i0.Input, args: [{ isSignal: true, alias: "urlShort", required: false }] }], closed: [{ type: i0.Output, args: ["closed"] }] } });
308
-
309
- const availableDevices = [
310
- {
311
- id: 'iphone-12-pro',
312
- mode: 'ios',
313
- name: 'iPhone 12 / 12 Pro',
314
- height: '844',
315
- width: '390',
316
- notch: true,
317
- safeAreaPortrait: { top: 44, bottom: 34, left: 0, right: 0 },
318
- safeAreaLandscape: { top: 0, bottom: 21, left: 44, right: 44 }
319
- },
320
- {
321
- id: 'iphone-11-pro',
322
- mode: 'ios',
323
- name: 'iPhone 11 Pro',
324
- height: '812',
325
- width: '375',
326
- notch: true,
327
- safeAreaPortrait: { top: 44, bottom: 34, left: 0, right: 0 },
328
- safeAreaLandscape: { top: 0, bottom: 21, left: 44, right: 44 }
329
- },
330
- {
331
- id: 'iphone-11',
332
- mode: 'ios',
333
- name: 'iPhone 11',
334
- height: '896',
335
- width: '414',
336
- notch: true,
337
- safeAreaPortrait: { top: 44, bottom: 34, left: 0, right: 0 },
338
- safeAreaLandscape: { top: 0, bottom: 21, left: 44, right: 44 }
339
- },
340
- {
341
- id: 'iphone-x',
342
- mode: 'ios',
343
- name: 'iPhone X / XS',
344
- height: '812',
345
- width: '375',
346
- notch: true,
347
- safeAreaPortrait: { top: 44, bottom: 34, left: 0, right: 0 },
348
- safeAreaLandscape: { top: 0, bottom: 21, left: 44, right: 44 }
349
- },
350
- {
351
- id: 'iphone-8',
352
- mode: 'ios',
353
- name: 'iPhone 8',
354
- height: '667',
355
- width: '375',
356
- safeAreaPortrait: { top: 20, bottom: 0, left: 0, right: 0 },
357
- safeAreaLandscape: { top: 0, bottom: 0, left: 0, right: 0 }
358
- },
359
- {
360
- id: 'samsung-gal-s20',
361
- mode: 'md',
362
- name: 'Samsung Galaxy S20',
363
- height: '800',
364
- width: '360',
365
- safeAreaPortrait: { top: 20, bottom: 10, left: 0, right: 0 },
366
- safeAreaLandscape: { top: 20, bottom: 10, left: 0, right: 0 }
367
- },
368
- {
369
- id: 'samsung-gal-s10',
370
- mode: 'md',
371
- name: 'Samsung Galaxy S10',
372
- height: '760',
373
- width: '360',
374
- safeAreaPortrait: { top: 20, bottom: 10, left: 0, right: 0 },
375
- safeAreaLandscape: { top: 20, bottom: 10, left: 0, right: 0 }
376
- },
377
- {
378
- id: 'samsung-gal-s9',
379
- mode: 'md',
380
- name: 'Samsung Galaxy S9',
381
- height: '740',
382
- width: '360',
383
- safeAreaPortrait: { top: 20, bottom: 10, left: 0, right: 0 },
384
- safeAreaLandscape: { top: 20, bottom: 10, left: 0, right: 0 }
385
- },
386
- {
387
- id: 'samsung-gal-note10',
388
- mode: 'md',
389
- name: 'Samsung Galaxy Note 10',
390
- height: '869',
391
- width: '412',
392
- safeAreaPortrait: { top: 20, bottom: 10, left: 0, right: 0 },
393
- safeAreaLandscape: { top: 20, bottom: 10, left: 0, right: 0 }
394
- }
395
- ];
396
-
397
- /**
398
- * Copyright (c) Siemens 2016 - 2026
399
- * SPDX-License-Identifier: MIT
400
- */
401
- class SiLivePreviewMobileModeComponent {
402
- previewIframe = viewChild.required('previewIframe', /* @ts-ignore */
403
- ...(ngDevMode ? [{ debugName: "previewIframe" }] : /* istanbul ignore next */ []));
404
- config = inject(SI_LIVE_PREVIEW_CONFIG);
405
- state = inject(LivePreviewStateService);
406
- iframeChange = output();
407
- switcherEnabled = this.config.themeSwitcher;
408
- landscapeEnabled = this.config.landscapeToggle;
409
- availableDevices = availableDevices;
410
- selectedDevice = signal(undefined, /* @ts-ignore */
411
- ...(ngDevMode ? [{ debugName: "selectedDevice" }] : /* istanbul ignore next */ []));
412
- landscape = signal(false, /* @ts-ignore */
413
- ...(ngDevMode ? [{ debugName: "landscape" }] : /* istanbul ignore next */ []));
414
- showQrMenu = signal(false, /* @ts-ignore */
415
- ...(ngDevMode ? [{ debugName: "showQrMenu" }] : /* istanbul ignore next */ []));
416
- plainUrl = signal('', /* @ts-ignore */
417
- ...(ngDevMode ? [{ debugName: "plainUrl" }] : /* istanbul ignore next */ []));
418
- plainUrlShort = signal('', /* @ts-ignore */
419
- ...(ngDevMode ? [{ debugName: "plainUrlShort" }] : /* istanbul ignore next */ []));
420
- mode = computed(() => this.selectedDevice()?.mode ?? 'ios', /* @ts-ignore */
421
- ...(ngDevMode ? [{ debugName: "mode" }] : /* istanbul ignore next */ []));
422
- showNotch = computed(() => this.selectedDevice()?.notch ?? false, /* @ts-ignore */
423
- ...(ngDevMode ? [{ debugName: "showNotch" }] : /* istanbul ignore next */ []));
424
- currentIFrameHeight = computed(() => {
425
- const device = this.selectedDevice();
426
- return device ? (this.landscape() ? device.width : device.height) : this.state.iFrameHeight();
427
- }, /* @ts-ignore */
428
- ...(ngDevMode ? [{ debugName: "currentIFrameHeight" }] : /* istanbul ignore next */ []));
429
- currentIFrameWidth = computed(() => {
430
- const device = this.selectedDevice();
431
- return device ? (this.landscape() ? device.height : device.width) : this.state.iFrameWidth();
432
- }, /* @ts-ignore */
433
- ...(ngDevMode ? [{ debugName: "currentIFrameWidth" }] : /* istanbul ignore next */ []));
434
- constructor() {
435
- effect(() => {
436
- if (!this.state.supportsLandscape() && this.landscape()) {
437
- this.landscape.set(false);
438
- this.emitViewport();
439
- }
440
- });
441
- }
442
- ngOnInit() {
443
- const deviceId = localStorage.getItem('si-live-preview-selected-device');
444
- this.selectDevice(this.availableDevices.find(device => device.id === deviceId));
445
- }
446
- ngAfterViewInit() {
447
- this.iframeChange.emit(this.previewIframe());
448
- }
449
- ngOnDestroy() {
450
- this.iframeChange.emit(undefined);
451
- }
452
- selectDevice(device) {
453
- const selectedDevice = device ?? this.availableDevices[0];
454
- this.selectedDevice.set(selectedDevice);
455
- localStorage.setItem('si-live-preview-selected-device', selectedDevice.id);
456
- this.emitViewport();
457
- }
458
- deviceChanged() {
459
- this.selectDevice(this.selectedDevice());
460
- }
461
- toggleLandscape() {
462
- this.landscape.update(landscape => !landscape);
463
- this.emitViewport();
464
- }
465
- openQrMenu() {
466
- this.plainUrl.set(this.createTemplateLink(false));
467
- this.plainUrlShort.set(this.createTemplateLink(true));
468
- this.showQrMenu.set(true);
469
- }
470
- emitViewport() {
471
- const device = this.selectedDevice();
472
- const safeArea = this.landscape() ? device?.safeAreaLandscape : device?.safeAreaPortrait;
473
- this.state.viewport.set({
474
- mode: this.mode(),
475
- safeAreaTop: safeArea?.top,
476
- safeAreaBottom: safeArea?.bottom,
477
- safeAreaLeft: safeArea?.left,
478
- safeAreaRight: safeArea?.right
479
- });
480
- }
481
- createTemplateLink(skipTemplate) {
482
- let url = `${window.location.protocol}//${window.location.host}`;
483
- url += window.location.pathname;
484
- url += '#/viewer/plain?';
485
- url += 'theme=' + this.state.theme();
486
- url += '&mode=' + this.mode();
487
- if (this.state.isRTL()) {
488
- url += '&isRTL=true';
489
- }
490
- const locale = this.state.locale();
491
- if (locale) {
492
- url += '&locale=' + locale;
493
- }
494
- if (this.state.rootFontSize()) {
495
- url += '&rfs=' + this.state.rootFontSize();
496
- }
497
- if (this.state.templateModified() && !skipTemplate) {
498
- url += '&t=' + this.encode(this.state.template());
499
- }
500
- const exampleUrl = this.state.example();
501
- if (exampleUrl) {
502
- url += '&e=' + this.encode(exampleUrl);
503
- }
504
- return url;
505
- }
506
- encode(value) {
507
- // Using `+` for spaces produces shorter QR code URLs than `%20`.
508
- return encodeURIComponent(value).replace(/%20/g, '+');
509
- }
510
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiLivePreviewMobileModeComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
511
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.8", type: SiLivePreviewMobileModeComponent, isStandalone: true, selector: "si-live-preview-mobile-mode", outputs: { iframeChange: "iframeChange" }, viewQueries: [{ propertyName: "previewIframe", first: true, predicate: ["previewIframe"], descendants: true, isSignal: true }], ngImport: i0, template: "<section class=\"settings-selection\">\n <select\n class=\"device-selection\"\n aria-label=\"Select preview device\"\n [ngModel]=\"selectedDevice()\"\n (ngModelChange)=\"selectDevice($event)\"\n >\n @for (device of availableDevices; track device.id) {\n <option [ngValue]=\"device\">\n {{ device.name }}\n </option>\n }\n </select>\n <div class=\"toggle-wrapper\">\n @if (landscapeEnabled) {\n <button\n type=\"button\"\n title=\"Rotate phone\"\n aria-label=\"Rotate phone\"\n [disabled]=\"!state.supportsLandscape()\"\n (click)=\"toggleLandscape()\"\n >\n @if (!landscape()) {\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\">\n <path\n d=\"M105.34,240.51c.27.27.56.53.85.77s.29.22.44.33.33.25.51.37l.52.32.48.28c.18.1.37.18.55.27l.52.24.54.19c.19.07.37.14.57.2a5.36,5.36,0,0,0,.54.14c.2,0,.39.11.6.15s.42.06.63.09l.53.08a11.63,11.63,0,0,0,2.36,0l.53-.08c.21,0,.43-.05.63-.09l.6-.15a5.36,5.36,0,0,0,.54-.14c.2-.06.38-.13.57-.2l.54-.19.52-.24c.18-.09.37-.17.55-.27l.48-.28.52-.32c.18-.12.34-.25.51-.37l.44-.33c.29-.24.58-.5.85-.77l0,0,41.87-41.88a12,12,0,1,0-17-17L125.8,203V131.5A21.52,21.52,0,0,1,147.3,110h58.62a12,12,0,0,0,0-24H147.3a45.55,45.55,0,0,0-45.5,45.5V203L80.41,181.64a12,12,0,0,0-17,17l41.87,41.88Z\"\n />\n <path d=\"M100.8,400a12,12,0,1,0,0,24h100a12,12,0,0,0,0-24Z\" />\n <path d=\"M336.11,348h-.22a16,16,0,0,0,0,32h.22a16,16,0,0,0,0-32Z\" />\n <path\n d=\"M407.43,88H264.57C242.2,88,224,107.38,224,131.2V380.8c0,23.82,18.2,43.2,40.57,43.2H407.43C429.8,424,448,404.62,448,380.8V131.2C448,107.38,429.8,88,407.43,88ZM424,380.8c0,10.59-7.43,19.2-16.57,19.2H264.57c-9.14,0-16.57-8.61-16.57-19.2V131.2c0-10.59,7.43-19.2,16.57-19.2H274a12,12,0,0,0,12,12H386a12,12,0,0,0,12-12h9.43c9.14,0,16.57,8.61,16.57,19.2Z\"\n />\n </svg>\n } @else {\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\">\n <path\n d=\"M86,147.3v58.62a12,12,0,0,0,24,0V147.3a21.52,21.52,0,0,1,21.5-21.5H203l-21.39,21.39a12,12,0,0,0,17,17l41.88-41.87,0,0c.27-.27.53-.56.77-.85l.32-.43c.13-.17.26-.34.38-.52s.21-.34.31-.52.2-.32.29-.48.18-.36.26-.54.17-.35.25-.53.13-.35.19-.53.14-.38.2-.58a4.58,4.58,0,0,0,.14-.53c0-.2.11-.4.15-.61s.06-.41.09-.61.06-.36.08-.55a10.88,10.88,0,0,0,.06-1.14v-.08a10.88,10.88,0,0,0-.06-1.14c0-.19-.05-.37-.08-.55s-.05-.41-.09-.61-.1-.41-.15-.61a4.58,4.58,0,0,0-.14-.53c-.06-.2-.13-.39-.2-.58s-.12-.36-.19-.53-.16-.35-.25-.53-.16-.36-.26-.54-.19-.32-.29-.48-.2-.35-.31-.52-.25-.35-.38-.52l-.32-.43c-.24-.29-.5-.58-.77-.85l0,0L198.61,63.44a12,12,0,0,0-17,17L203,101.8H131.5A45.55,45.55,0,0,0,86,147.3Z\"\n />\n <path d=\"M412,88.8a12,12,0,0,0-12,12v100a12,12,0,0,0,24,0v-100A12,12,0,0,0,412,88.8Z\" />\n <path d=\"M362.11,320h-.22a16,16,0,0,0,0,32h.22a16,16,0,0,0,0-32Z\" />\n <path\n d=\"M380.8,224H131.2C107.38,224,88,242.2,88,264.57V407.43C88,429.8,107.38,448,131.2,448H380.8c23.82,0,43.2-18.2,43.2-40.57V264.57C424,242.2,404.62,224,380.8,224ZM400,407.43c0,9.14-8.61,16.57-19.2,16.57H131.2c-10.59,0-19.2-7.43-19.2-16.57V398a12,12,0,0,0,12-12V286a12,12,0,0,0-12-12v-9.43c0-9.14,8.61-16.57,19.2-16.57H380.8c10.59,0,19.2,7.43,19.2,16.57Z\"\n />\n </svg>\n }\n </button>\n }\n @if (switcherEnabled) {\n <button\n type=\"button\"\n title=\"Toggle theme\"\n aria-label=\"Toggle theme\"\n (click)=\"state.toggleTheme()\"\n >\n @if (state.theme() === 'dark') {\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\">\n <path\n d=\"M256,349.82A93.82,93.82,0,1,0,162.18,256,93.93,93.93,0,0,0,256,349.82Zm0-163.64A69.82,69.82,0,1,1,186.18,256,69.9,69.9,0,0,1,256,186.18Z\"\n />\n <path\n d=\"M256,120.73a12,12,0,0,0,12-12V76a12,12,0,0,0-24,0v32.73A12,12,0,0,0,256,120.73Z\"\n />\n <path d=\"M268,436V403.27a12,12,0,0,0-24,0V436a12,12,0,0,0,24,0Z\" />\n <path d=\"M143.44,160.41a12,12,0,1,0,17-17l-23.23-23.23a12,12,0,1,0-17,17Z\" />\n <path\n d=\"M351.59,351.59a12,12,0,0,0,0,17l23.23,23.23a12,12,0,0,0,17-17l-23.23-23.23A12,12,0,0,0,351.59,351.59Z\"\n />\n <path\n d=\"M120.73,256a12,12,0,0,0-12-12H76a12,12,0,0,0,0,24h32.73A12,12,0,0,0,120.73,256Z\"\n />\n <path d=\"M436,244H403.27a12,12,0,0,0,0,24H436a12,12,0,0,0,0-24Z\" />\n <path\n d=\"M137.18,391.79l23.23-23.23a12,12,0,1,0-17-17l-23.23,23.23a12,12,0,1,0,17,17Z\"\n />\n <path\n d=\"M360.07,163.93a12,12,0,0,0,8.49-3.52l23.23-23.23a12,12,0,1,0-17-17l-23.23,23.23a12,12,0,0,0,8.48,20.49Z\"\n />\n </svg>\n } @else {\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\">\n <path\n d=\"M360.07,147.88a12,12,0,0,0,5.89-21.1,168.05,168.05,0,0,0-214.71,0C80,186,70.19,292.1,129.38,363.35a166.9,166.9,0,0,0,113.77,59.93q7.9.74,15.75.73A166.74,166.74,0,0,0,366,385.22a12,12,0,0,0-5.89-21.1,109.33,109.33,0,0,1,0-216.24ZM244.43,275.77A133.48,133.48,0,0,0,330,381.08,144.11,144.11,0,0,1,147.84,348C97.1,287,105.51,196,166.58,145.24A144.08,144.08,0,0,1,330,130.94C272,152.38,234.91,212.29,244.43,275.77Z\"\n />\n </svg>\n }\n </button>\n }\n <button\n type=\"button\"\n title=\"Show QR code\"\n aria-label=\"Show QR code\"\n class=\"qr-button\"\n (click)=\"openQrMenu()\"\n >\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\">\n <path\n d=\"M100 180a12 12 0 01-12-12v-56a24 24 0 0124-24h56a12 12 0 010 24h-56v56a12 12 0 01-12 12zM412 180a12 12 0 01-12-12v-56h-56a12 12 0 010-24h56a24 24 0 0124 24v56a12 12 0 01-12 12zM168 424h-56a24 24 0 01-24-24v-56a12 12 0 0124 0v56h56a12 12 0 010 24zM400 424h-56a12 12 0 010-24h56v-56a12 12 0 0124 0v56a24 24 0 01-24 24zM176.11 172.11h27.79v27.79h-27.79zM424 304H88a12 12 0 010-24h336a12 12 0 010 24z\"\n />\n <path\n d=\"M244.37 377.69H137.4V318h24v35.69h82.97v24zM374.36 193.69h-24V158h-49.87v-24h73.87v59.69z\"\n />\n <path\n d=\"M189.34 318h48.05v24h-48.05zM350.37 318v35.69H333.1V318h-67.54v24h43.54v11.69h-23.86v24h89.13V318h-24zM242 238H138V134h104zm-80-24h56v-56h-56zM261.33 134h24v44.54h-24zM350.36 225.06h24v44.54h-24zM301.77 169h30.29v24h-30.29zM328.18 267h-64v-64h64zm-40-24h16v-16h-16z\"\n />\n </svg>\n @if (showQrMenu()) {\n <si-live-preview-qr\n title=\"\"\n [url]=\"plainUrl()\"\n [urlShort]=\"plainUrlShort()\"\n (closed)=\"showQrMenu.set(false)\"\n />\n }\n </button>\n </div>\n</section>\n\n<div\n class=\"device\"\n [class.md]=\"mode() !== 'ios'\"\n [class.ios]=\"mode() === 'ios' && !showNotch()\"\n [class.ios-with-notch]=\"mode() === 'ios' && showNotch()\"\n [class.dark]=\"state.theme() === 'dark'\"\n [class.landscape]=\"landscape()\"\n>\n @if (mode() !== 'ios') {\n <div class=\"wrapper\">\n <svg class=\"md-bar\" viewBox=\"0 0 130 40.3\" [class.dark]=\"state.theme() === 'dark'\">\n <path\n d=\"m 16,4.2 h 64 c 8.8,0 16,7.2 16,16 0,8.8 -7.2,16 -16,16 H 16 C 7.2,36.2 0,29 0,20.2 0,11.4 7.2,4.2 16,4.2 Z\"\n />\n </svg>\n <svg class=\"md-bar\" viewBox=\"0 0 199.99999 40.3\" [class.dark]=\"state.theme() === 'dark'\">\n <path\n d=\"M 155,5.0124996 173.8,37.3125 c 0.8,1.3 2.7,1.3 3.5,0 L 196,5.0124996 c 0.8,-1.3 -0.2,-3 -1.7,-3 h -37.6 c -1.5,0 -2.5,1.7 -1.7,3 z\"\n />\n <circle r=\"20\" cy=\"20.15\" cx=\"111\" class=\"st0\" />\n <path\n d=\"m 25,1.1499996 h 30 c 2.2,0 4,1.8 4,4 V 35.15 c 0,2.2 -1.8,4 -4,4 H 25 c -2.2,0 -4,-1.8 -4,-4 V 5.1499996 c 0,-2.3 1.8,-4 4,-4 z\"\n />\n </svg>\n </div>\n } @else {\n @if (showNotch()) {\n <!-- iOS devices with notch -->\n <div class=\"notch\">\n <div class=\"camera\"></div>\n <div class=\"speaker\"></div>\n </div>\n <div class=\"sleep\"></div>\n <div class=\"volume\"></div>\n } @else {\n <!-- iOS devices without notch -->\n <div class=\"camera\"></div>\n <div class=\"speaker\"></div>\n <div class=\"sensor\"></div>\n <div class=\"sleep\"></div>\n <div class=\"volume\"></div>\n <div class=\"home\"></div>\n }\n }\n\n <div class=\"screen\">\n <iframe\n #previewIframe\n src=\"#/iframe\"\n title=\"Mobile example view\"\n [height]=\"currentIFrameHeight()\"\n [width]=\"currentIFrameWidth()\"\n ></iframe>\n </div>\n</div>\n", styles: ["*:focus-visible{outline:var(--element-button-focus-width) solid var(--si-sys-color-effects-focus);outline-offset:var(--element-button-focus-overlay-width)}:host{display:block}iframe{border:0;display:block}.settings-selection{display:flex;align-items:center;justify-content:space-between;margin-block:10px 20px;margin-inline:0}.settings-selection .toggle-wrapper{display:flex}.settings-selection .toggle-wrapper button{background:var(--si-sys-color-background-accent-secondary);display:flex;align-items:center;justify-content:center;block-size:40px;inline-size:40px;border:1px solid var(--si-sys-color-border-4);border-radius:50%;margin-inline-start:10px;position:relative}.settings-selection .toggle-wrapper button>svg{block-size:24px;fill:var(--si-sys-color-text-primary)}.settings-selection .toggle-wrapper button>svg:hover{fill:var(--si-sys-color-text-accent-hover)}.settings-selection .toggle-wrapper button:disabled>svg{fill:var(--si-sys-color-text-primary)}.device-selection{appearance:none;background-color:var(--si-sys-color-background-0);background-image:url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'><path d='M352.79 203.21a12.45 12.45 0 011.44 15.86l-1.44 1.72-88 88a12.45 12.45 0 01-15.86 1.44l-1.72-1.44-88-88a12.43 12.43 0 0115.86-19l1.72 1.44L256 282.42l79.21-79.21a12.45 12.45 0 0115.86-1.44z'/></svg>\");background-repeat:no-repeat;background-position:right 2px top 50%;color:var(--si-sys-color-text-primary);block-size:35px;min-inline-size:200px;border-radius:2px;border:1px solid var(--si-sys-color-border-4);padding:6px;margin-block:0;display:flex;flex:1}.device{position:relative;box-sizing:content-box}.device .screen{background:var(--si-sys-color-background-0);box-shadow:0 0 0 3px #111;border-radius:1px;block-size:100%;inline-size:100%;position:relative;overflow:hidden;display:block}.device.md{margin-top:20px;box-shadow:0 0 0 14px #090a0d,0 0 0 17px #9fa3a8,0 0 34px 17px #0003;overflow:hidden;border-radius:20px}.device.md .wrapper{margin:0 auto;position:absolute;top:0;left:0;right:0;z-index:4;display:flex;height:25px;justify-content:space-between}.device.md .wrapper .md-bar{fill:#090a0d;opacity:.2;padding:7px 11px}.device.md .wrapper .md-bar.dark{fill:#fff;opacity:.5}.device.ios-with-notch{padding:26px;background:#fdfdfd;box-shadow:inset 0 0 11px #000;border-radius:66px}.device.ios-with-notch:before{background:#000;border-radius:61px;height:calc(100% - 10px);width:calc(100% - 10px);position:absolute;top:5px;left:5px;content:\"\"}.device.ios-with-notch:after{background:#00000080;border-radius:2px;height:4px;width:130px;position:absolute;right:0;bottom:32px;left:0;content:\"\";margin:0 auto}.device.ios-with-notch.dark:after{background:#fff;opacity:.5}.device.ios-with-notch .screen{border-radius:40px}.device.ios-with-notch .volume,.device.ios-with-notch .volume:before,.device.ios-with-notch .volume:after,.device.ios-with-notch .sleep{background:#b5b5b5;width:3px;position:absolute}.device.ios-with-notch .volume{height:32px;top:116px;left:-3px}.device.ios-with-notch .volume:before{height:62px;top:62px;left:0;content:\"\"}.device.ios-with-notch .volume:after{height:62px;top:140px;left:0;content:\"\"}.device.ios-with-notch .sleep{height:96px;top:200px;right:-3px}.device.ios-with-notch .camera{background:#0d4d71;border-radius:100%;height:6px;width:6px;position:absolute;top:9px;left:154px}.device.ios-with-notch .speaker{background:#171818;border-radius:6px;height:6px;width:60px;position:absolute;top:9px;left:50%;margin-left:-30px}.device.ios-with-notch .notch{background:#000;border-bottom-left-radius:24px;border-bottom-right-radius:24px;height:30px;width:210px;position:absolute;top:26px;left:50%;margin-left:-105px;z-index:4}.device.ios-with-notch .notch:before,.device.ios-with-notch .notch:after{height:8px;width:8px;position:absolute;top:0;content:\"\"}.device.ios-with-notch .notch:after{background:radial-gradient(circle at bottom left,transparent 0,transparent 70%,#000 70%,#000 100%);left:-8px}.device.ios-with-notch .notch:before{background:radial-gradient(circle at bottom right,transparent 0,transparent 70%,#000 70%,#000 100%);right:-8px}.device.ios-with-notch.landscape .volume,.device.ios-with-notch.landscape .volume:before,.device.ios-with-notch.landscape .volume:after,.device.ios-with-notch.landscape .sleep{height:3px}.device.ios-with-notch.landscape .volume{width:32px;top:auto;left:116px;bottom:-3px}.device.ios-with-notch.landscape .volume:before{width:62px;top:0;left:62px}.device.ios-with-notch.landscape .volume:after{width:62px;top:0;left:140px}.device.ios-with-notch.landscape .sleep{width:96px;top:-3px;right:auto;left:200px}.device.ios-with-notch.landscape .camera{top:auto;bottom:154px;left:9px}.device.ios-with-notch.landscape .speaker{height:60px;width:6px;top:50%;left:9px;margin-top:-30px;margin-left:0}.device.ios-with-notch.landscape .notch{border-top-right-radius:24px;border-bottom-right-radius:24px;border-bottom-left-radius:0;height:210px;width:30px;top:50%;margin-top:-105px;margin-left:unset;left:unset}.device.ios-with-notch.landscape .notch:before,.device.ios-with-notch.landscape .notch:after{left:0}.device.ios-with-notch.landscape .notch:after{background:radial-gradient(circle at bottom right,transparent 0,transparent 70%,#000 70%,#000 100%);top:auto;bottom:-8px}.device.ios-with-notch.landscape .notch:before{background:radial-gradient(circle at top right,transparent 0,transparent 70%,#000 70%,#000 100%);top:-8px}.device.ios{background:#464646;box-shadow:inset 0 0 3px #000000b3;border-radius:56px;padding:105px 24px}.device.ios:before{background:#080808;border-radius:50px;height:calc(100% - 12px);width:calc(100% - 12px);position:absolute;top:6px;left:6px;content:\"\"}.device.ios .home{background:linear-gradient(135deg,#080808,#464646,#080808);border-radius:100%;height:68px;width:68px;position:absolute;bottom:22px;left:50%;margin-left:-34px}.device.ios .home:before{background:#080808;border-radius:100%;height:calc(100% - 8px);width:calc(100% - 8px);position:absolute;top:4px;left:4px;content:\"\"}.device.ios .sleep{background:#464646;border-radius:0 2px 2px 0;height:66px;width:4px;position:absolute;top:190px;right:-4px}.device.ios .volume{background:#464646;border-radius:2px 0 0 2px;height:66px;width:4px;position:absolute;top:188px;left:-4px}.device.ios .volume:before{background:inherit;border-radius:2px 0 0 2px;height:40px;width:2px;position:absolute;top:-78px;left:2px;content:\"\"}.device.ios .volume:after{background:inherit;border-radius:2px 0 0 2px;height:66px;width:4px;position:absolute;top:82px;left:0;content:\"\"}.device.ios .camera{background:#080808;border-radius:100%;height:12px;width:12px;position:absolute;top:24px;left:50%;margin-left:-6px}.device.ios .sensor{background:#3c3d3d;border-radius:100%;height:16px;width:16px;position:absolute;top:49px;left:134px}.device.ios .speaker{background:#292728;border-radius:6px;height:6px;width:70px;position:absolute;top:54px;left:50%;margin-left:-35px}.device.ios.landscape{padding:24px 105px}.device.ios.landscape .sleep{border-radius:2px 2px 0 0;height:4px;width:66px;top:unset;bottom:100%;left:190px}.device.ios.landscape .volume{border-radius:0 0 2px 2px;height:4px;width:66px;bottom:-4px;top:unset;right:calc(100% - 254px);left:unset}.device.ios.landscape .volume:before{border-radius:0 0 2px 2px;height:2px;width:40px;top:unset;bottom:2px;left:-78px;right:auto}.device.ios.landscape .volume:after{border-radius:0 0 2px 2px;height:4px;width:66px;top:unset;bottom:0;right:-82px;left:unset}.device.ios.landscape .home{top:50%;right:22px;left:unset;margin-top:-34px;margin-left:unset}.device.ios.landscape .sensor{top:134px;right:calc(100% - 65px);left:unset}.device.ios.landscape .speaker{height:70px;width:6px;top:50%;right:calc(100% - 60px);left:unset;margin-top:-35px;margin-left:unset}.device.ios.landscape .camera{top:50%;right:calc(100% - 32px);left:unset;margin-top:-6px;margin-left:unset}\n"], dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i1.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i1.SelectControlValueAccessor, selector: "select:not([multiple]):not([ngNoCva])[formControlName],select:not([multiple]):not([ngNoCva])[formControl],select:not([multiple]):not([ngNoCva])[ngModel]", inputs: ["compareWith"] }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: SiLivePreviewQrComponent, selector: "si-live-preview-qr", inputs: ["url", "urlShort"], outputs: ["closed"] }] });
512
- }
513
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiLivePreviewMobileModeComponent, decorators: [{
514
- type: Component,
515
- args: [{ selector: 'si-live-preview-mobile-mode', imports: [FormsModule, SiLivePreviewQrComponent], template: "<section class=\"settings-selection\">\n <select\n class=\"device-selection\"\n aria-label=\"Select preview device\"\n [ngModel]=\"selectedDevice()\"\n (ngModelChange)=\"selectDevice($event)\"\n >\n @for (device of availableDevices; track device.id) {\n <option [ngValue]=\"device\">\n {{ device.name }}\n </option>\n }\n </select>\n <div class=\"toggle-wrapper\">\n @if (landscapeEnabled) {\n <button\n type=\"button\"\n title=\"Rotate phone\"\n aria-label=\"Rotate phone\"\n [disabled]=\"!state.supportsLandscape()\"\n (click)=\"toggleLandscape()\"\n >\n @if (!landscape()) {\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\">\n <path\n d=\"M105.34,240.51c.27.27.56.53.85.77s.29.22.44.33.33.25.51.37l.52.32.48.28c.18.1.37.18.55.27l.52.24.54.19c.19.07.37.14.57.2a5.36,5.36,0,0,0,.54.14c.2,0,.39.11.6.15s.42.06.63.09l.53.08a11.63,11.63,0,0,0,2.36,0l.53-.08c.21,0,.43-.05.63-.09l.6-.15a5.36,5.36,0,0,0,.54-.14c.2-.06.38-.13.57-.2l.54-.19.52-.24c.18-.09.37-.17.55-.27l.48-.28.52-.32c.18-.12.34-.25.51-.37l.44-.33c.29-.24.58-.5.85-.77l0,0,41.87-41.88a12,12,0,1,0-17-17L125.8,203V131.5A21.52,21.52,0,0,1,147.3,110h58.62a12,12,0,0,0,0-24H147.3a45.55,45.55,0,0,0-45.5,45.5V203L80.41,181.64a12,12,0,0,0-17,17l41.87,41.88Z\"\n />\n <path d=\"M100.8,400a12,12,0,1,0,0,24h100a12,12,0,0,0,0-24Z\" />\n <path d=\"M336.11,348h-.22a16,16,0,0,0,0,32h.22a16,16,0,0,0,0-32Z\" />\n <path\n d=\"M407.43,88H264.57C242.2,88,224,107.38,224,131.2V380.8c0,23.82,18.2,43.2,40.57,43.2H407.43C429.8,424,448,404.62,448,380.8V131.2C448,107.38,429.8,88,407.43,88ZM424,380.8c0,10.59-7.43,19.2-16.57,19.2H264.57c-9.14,0-16.57-8.61-16.57-19.2V131.2c0-10.59,7.43-19.2,16.57-19.2H274a12,12,0,0,0,12,12H386a12,12,0,0,0,12-12h9.43c9.14,0,16.57,8.61,16.57,19.2Z\"\n />\n </svg>\n } @else {\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\">\n <path\n d=\"M86,147.3v58.62a12,12,0,0,0,24,0V147.3a21.52,21.52,0,0,1,21.5-21.5H203l-21.39,21.39a12,12,0,0,0,17,17l41.88-41.87,0,0c.27-.27.53-.56.77-.85l.32-.43c.13-.17.26-.34.38-.52s.21-.34.31-.52.2-.32.29-.48.18-.36.26-.54.17-.35.25-.53.13-.35.19-.53.14-.38.2-.58a4.58,4.58,0,0,0,.14-.53c0-.2.11-.4.15-.61s.06-.41.09-.61.06-.36.08-.55a10.88,10.88,0,0,0,.06-1.14v-.08a10.88,10.88,0,0,0-.06-1.14c0-.19-.05-.37-.08-.55s-.05-.41-.09-.61-.1-.41-.15-.61a4.58,4.58,0,0,0-.14-.53c-.06-.2-.13-.39-.2-.58s-.12-.36-.19-.53-.16-.35-.25-.53-.16-.36-.26-.54-.19-.32-.29-.48-.2-.35-.31-.52-.25-.35-.38-.52l-.32-.43c-.24-.29-.5-.58-.77-.85l0,0L198.61,63.44a12,12,0,0,0-17,17L203,101.8H131.5A45.55,45.55,0,0,0,86,147.3Z\"\n />\n <path d=\"M412,88.8a12,12,0,0,0-12,12v100a12,12,0,0,0,24,0v-100A12,12,0,0,0,412,88.8Z\" />\n <path d=\"M362.11,320h-.22a16,16,0,0,0,0,32h.22a16,16,0,0,0,0-32Z\" />\n <path\n d=\"M380.8,224H131.2C107.38,224,88,242.2,88,264.57V407.43C88,429.8,107.38,448,131.2,448H380.8c23.82,0,43.2-18.2,43.2-40.57V264.57C424,242.2,404.62,224,380.8,224ZM400,407.43c0,9.14-8.61,16.57-19.2,16.57H131.2c-10.59,0-19.2-7.43-19.2-16.57V398a12,12,0,0,0,12-12V286a12,12,0,0,0-12-12v-9.43c0-9.14,8.61-16.57,19.2-16.57H380.8c10.59,0,19.2,7.43,19.2,16.57Z\"\n />\n </svg>\n }\n </button>\n }\n @if (switcherEnabled) {\n <button\n type=\"button\"\n title=\"Toggle theme\"\n aria-label=\"Toggle theme\"\n (click)=\"state.toggleTheme()\"\n >\n @if (state.theme() === 'dark') {\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\">\n <path\n d=\"M256,349.82A93.82,93.82,0,1,0,162.18,256,93.93,93.93,0,0,0,256,349.82Zm0-163.64A69.82,69.82,0,1,1,186.18,256,69.9,69.9,0,0,1,256,186.18Z\"\n />\n <path\n d=\"M256,120.73a12,12,0,0,0,12-12V76a12,12,0,0,0-24,0v32.73A12,12,0,0,0,256,120.73Z\"\n />\n <path d=\"M268,436V403.27a12,12,0,0,0-24,0V436a12,12,0,0,0,24,0Z\" />\n <path d=\"M143.44,160.41a12,12,0,1,0,17-17l-23.23-23.23a12,12,0,1,0-17,17Z\" />\n <path\n d=\"M351.59,351.59a12,12,0,0,0,0,17l23.23,23.23a12,12,0,0,0,17-17l-23.23-23.23A12,12,0,0,0,351.59,351.59Z\"\n />\n <path\n d=\"M120.73,256a12,12,0,0,0-12-12H76a12,12,0,0,0,0,24h32.73A12,12,0,0,0,120.73,256Z\"\n />\n <path d=\"M436,244H403.27a12,12,0,0,0,0,24H436a12,12,0,0,0,0-24Z\" />\n <path\n d=\"M137.18,391.79l23.23-23.23a12,12,0,1,0-17-17l-23.23,23.23a12,12,0,1,0,17,17Z\"\n />\n <path\n d=\"M360.07,163.93a12,12,0,0,0,8.49-3.52l23.23-23.23a12,12,0,1,0-17-17l-23.23,23.23a12,12,0,0,0,8.48,20.49Z\"\n />\n </svg>\n } @else {\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\">\n <path\n d=\"M360.07,147.88a12,12,0,0,0,5.89-21.1,168.05,168.05,0,0,0-214.71,0C80,186,70.19,292.1,129.38,363.35a166.9,166.9,0,0,0,113.77,59.93q7.9.74,15.75.73A166.74,166.74,0,0,0,366,385.22a12,12,0,0,0-5.89-21.1,109.33,109.33,0,0,1,0-216.24ZM244.43,275.77A133.48,133.48,0,0,0,330,381.08,144.11,144.11,0,0,1,147.84,348C97.1,287,105.51,196,166.58,145.24A144.08,144.08,0,0,1,330,130.94C272,152.38,234.91,212.29,244.43,275.77Z\"\n />\n </svg>\n }\n </button>\n }\n <button\n type=\"button\"\n title=\"Show QR code\"\n aria-label=\"Show QR code\"\n class=\"qr-button\"\n (click)=\"openQrMenu()\"\n >\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\">\n <path\n d=\"M100 180a12 12 0 01-12-12v-56a24 24 0 0124-24h56a12 12 0 010 24h-56v56a12 12 0 01-12 12zM412 180a12 12 0 01-12-12v-56h-56a12 12 0 010-24h56a24 24 0 0124 24v56a12 12 0 01-12 12zM168 424h-56a24 24 0 01-24-24v-56a12 12 0 0124 0v56h56a12 12 0 010 24zM400 424h-56a12 12 0 010-24h56v-56a12 12 0 0124 0v56a24 24 0 01-24 24zM176.11 172.11h27.79v27.79h-27.79zM424 304H88a12 12 0 010-24h336a12 12 0 010 24z\"\n />\n <path\n d=\"M244.37 377.69H137.4V318h24v35.69h82.97v24zM374.36 193.69h-24V158h-49.87v-24h73.87v59.69z\"\n />\n <path\n d=\"M189.34 318h48.05v24h-48.05zM350.37 318v35.69H333.1V318h-67.54v24h43.54v11.69h-23.86v24h89.13V318h-24zM242 238H138V134h104zm-80-24h56v-56h-56zM261.33 134h24v44.54h-24zM350.36 225.06h24v44.54h-24zM301.77 169h30.29v24h-30.29zM328.18 267h-64v-64h64zm-40-24h16v-16h-16z\"\n />\n </svg>\n @if (showQrMenu()) {\n <si-live-preview-qr\n title=\"\"\n [url]=\"plainUrl()\"\n [urlShort]=\"plainUrlShort()\"\n (closed)=\"showQrMenu.set(false)\"\n />\n }\n </button>\n </div>\n</section>\n\n<div\n class=\"device\"\n [class.md]=\"mode() !== 'ios'\"\n [class.ios]=\"mode() === 'ios' && !showNotch()\"\n [class.ios-with-notch]=\"mode() === 'ios' && showNotch()\"\n [class.dark]=\"state.theme() === 'dark'\"\n [class.landscape]=\"landscape()\"\n>\n @if (mode() !== 'ios') {\n <div class=\"wrapper\">\n <svg class=\"md-bar\" viewBox=\"0 0 130 40.3\" [class.dark]=\"state.theme() === 'dark'\">\n <path\n d=\"m 16,4.2 h 64 c 8.8,0 16,7.2 16,16 0,8.8 -7.2,16 -16,16 H 16 C 7.2,36.2 0,29 0,20.2 0,11.4 7.2,4.2 16,4.2 Z\"\n />\n </svg>\n <svg class=\"md-bar\" viewBox=\"0 0 199.99999 40.3\" [class.dark]=\"state.theme() === 'dark'\">\n <path\n d=\"M 155,5.0124996 173.8,37.3125 c 0.8,1.3 2.7,1.3 3.5,0 L 196,5.0124996 c 0.8,-1.3 -0.2,-3 -1.7,-3 h -37.6 c -1.5,0 -2.5,1.7 -1.7,3 z\"\n />\n <circle r=\"20\" cy=\"20.15\" cx=\"111\" class=\"st0\" />\n <path\n d=\"m 25,1.1499996 h 30 c 2.2,0 4,1.8 4,4 V 35.15 c 0,2.2 -1.8,4 -4,4 H 25 c -2.2,0 -4,-1.8 -4,-4 V 5.1499996 c 0,-2.3 1.8,-4 4,-4 z\"\n />\n </svg>\n </div>\n } @else {\n @if (showNotch()) {\n <!-- iOS devices with notch -->\n <div class=\"notch\">\n <div class=\"camera\"></div>\n <div class=\"speaker\"></div>\n </div>\n <div class=\"sleep\"></div>\n <div class=\"volume\"></div>\n } @else {\n <!-- iOS devices without notch -->\n <div class=\"camera\"></div>\n <div class=\"speaker\"></div>\n <div class=\"sensor\"></div>\n <div class=\"sleep\"></div>\n <div class=\"volume\"></div>\n <div class=\"home\"></div>\n }\n }\n\n <div class=\"screen\">\n <iframe\n #previewIframe\n src=\"#/iframe\"\n title=\"Mobile example view\"\n [height]=\"currentIFrameHeight()\"\n [width]=\"currentIFrameWidth()\"\n ></iframe>\n </div>\n</div>\n", styles: ["*:focus-visible{outline:var(--element-button-focus-width) solid var(--si-sys-color-effects-focus);outline-offset:var(--element-button-focus-overlay-width)}:host{display:block}iframe{border:0;display:block}.settings-selection{display:flex;align-items:center;justify-content:space-between;margin-block:10px 20px;margin-inline:0}.settings-selection .toggle-wrapper{display:flex}.settings-selection .toggle-wrapper button{background:var(--si-sys-color-background-accent-secondary);display:flex;align-items:center;justify-content:center;block-size:40px;inline-size:40px;border:1px solid var(--si-sys-color-border-4);border-radius:50%;margin-inline-start:10px;position:relative}.settings-selection .toggle-wrapper button>svg{block-size:24px;fill:var(--si-sys-color-text-primary)}.settings-selection .toggle-wrapper button>svg:hover{fill:var(--si-sys-color-text-accent-hover)}.settings-selection .toggle-wrapper button:disabled>svg{fill:var(--si-sys-color-text-primary)}.device-selection{appearance:none;background-color:var(--si-sys-color-background-0);background-image:url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'><path d='M352.79 203.21a12.45 12.45 0 011.44 15.86l-1.44 1.72-88 88a12.45 12.45 0 01-15.86 1.44l-1.72-1.44-88-88a12.43 12.43 0 0115.86-19l1.72 1.44L256 282.42l79.21-79.21a12.45 12.45 0 0115.86-1.44z'/></svg>\");background-repeat:no-repeat;background-position:right 2px top 50%;color:var(--si-sys-color-text-primary);block-size:35px;min-inline-size:200px;border-radius:2px;border:1px solid var(--si-sys-color-border-4);padding:6px;margin-block:0;display:flex;flex:1}.device{position:relative;box-sizing:content-box}.device .screen{background:var(--si-sys-color-background-0);box-shadow:0 0 0 3px #111;border-radius:1px;block-size:100%;inline-size:100%;position:relative;overflow:hidden;display:block}.device.md{margin-top:20px;box-shadow:0 0 0 14px #090a0d,0 0 0 17px #9fa3a8,0 0 34px 17px #0003;overflow:hidden;border-radius:20px}.device.md .wrapper{margin:0 auto;position:absolute;top:0;left:0;right:0;z-index:4;display:flex;height:25px;justify-content:space-between}.device.md .wrapper .md-bar{fill:#090a0d;opacity:.2;padding:7px 11px}.device.md .wrapper .md-bar.dark{fill:#fff;opacity:.5}.device.ios-with-notch{padding:26px;background:#fdfdfd;box-shadow:inset 0 0 11px #000;border-radius:66px}.device.ios-with-notch:before{background:#000;border-radius:61px;height:calc(100% - 10px);width:calc(100% - 10px);position:absolute;top:5px;left:5px;content:\"\"}.device.ios-with-notch:after{background:#00000080;border-radius:2px;height:4px;width:130px;position:absolute;right:0;bottom:32px;left:0;content:\"\";margin:0 auto}.device.ios-with-notch.dark:after{background:#fff;opacity:.5}.device.ios-with-notch .screen{border-radius:40px}.device.ios-with-notch .volume,.device.ios-with-notch .volume:before,.device.ios-with-notch .volume:after,.device.ios-with-notch .sleep{background:#b5b5b5;width:3px;position:absolute}.device.ios-with-notch .volume{height:32px;top:116px;left:-3px}.device.ios-with-notch .volume:before{height:62px;top:62px;left:0;content:\"\"}.device.ios-with-notch .volume:after{height:62px;top:140px;left:0;content:\"\"}.device.ios-with-notch .sleep{height:96px;top:200px;right:-3px}.device.ios-with-notch .camera{background:#0d4d71;border-radius:100%;height:6px;width:6px;position:absolute;top:9px;left:154px}.device.ios-with-notch .speaker{background:#171818;border-radius:6px;height:6px;width:60px;position:absolute;top:9px;left:50%;margin-left:-30px}.device.ios-with-notch .notch{background:#000;border-bottom-left-radius:24px;border-bottom-right-radius:24px;height:30px;width:210px;position:absolute;top:26px;left:50%;margin-left:-105px;z-index:4}.device.ios-with-notch .notch:before,.device.ios-with-notch .notch:after{height:8px;width:8px;position:absolute;top:0;content:\"\"}.device.ios-with-notch .notch:after{background:radial-gradient(circle at bottom left,transparent 0,transparent 70%,#000 70%,#000 100%);left:-8px}.device.ios-with-notch .notch:before{background:radial-gradient(circle at bottom right,transparent 0,transparent 70%,#000 70%,#000 100%);right:-8px}.device.ios-with-notch.landscape .volume,.device.ios-with-notch.landscape .volume:before,.device.ios-with-notch.landscape .volume:after,.device.ios-with-notch.landscape .sleep{height:3px}.device.ios-with-notch.landscape .volume{width:32px;top:auto;left:116px;bottom:-3px}.device.ios-with-notch.landscape .volume:before{width:62px;top:0;left:62px}.device.ios-with-notch.landscape .volume:after{width:62px;top:0;left:140px}.device.ios-with-notch.landscape .sleep{width:96px;top:-3px;right:auto;left:200px}.device.ios-with-notch.landscape .camera{top:auto;bottom:154px;left:9px}.device.ios-with-notch.landscape .speaker{height:60px;width:6px;top:50%;left:9px;margin-top:-30px;margin-left:0}.device.ios-with-notch.landscape .notch{border-top-right-radius:24px;border-bottom-right-radius:24px;border-bottom-left-radius:0;height:210px;width:30px;top:50%;margin-top:-105px;margin-left:unset;left:unset}.device.ios-with-notch.landscape .notch:before,.device.ios-with-notch.landscape .notch:after{left:0}.device.ios-with-notch.landscape .notch:after{background:radial-gradient(circle at bottom right,transparent 0,transparent 70%,#000 70%,#000 100%);top:auto;bottom:-8px}.device.ios-with-notch.landscape .notch:before{background:radial-gradient(circle at top right,transparent 0,transparent 70%,#000 70%,#000 100%);top:-8px}.device.ios{background:#464646;box-shadow:inset 0 0 3px #000000b3;border-radius:56px;padding:105px 24px}.device.ios:before{background:#080808;border-radius:50px;height:calc(100% - 12px);width:calc(100% - 12px);position:absolute;top:6px;left:6px;content:\"\"}.device.ios .home{background:linear-gradient(135deg,#080808,#464646,#080808);border-radius:100%;height:68px;width:68px;position:absolute;bottom:22px;left:50%;margin-left:-34px}.device.ios .home:before{background:#080808;border-radius:100%;height:calc(100% - 8px);width:calc(100% - 8px);position:absolute;top:4px;left:4px;content:\"\"}.device.ios .sleep{background:#464646;border-radius:0 2px 2px 0;height:66px;width:4px;position:absolute;top:190px;right:-4px}.device.ios .volume{background:#464646;border-radius:2px 0 0 2px;height:66px;width:4px;position:absolute;top:188px;left:-4px}.device.ios .volume:before{background:inherit;border-radius:2px 0 0 2px;height:40px;width:2px;position:absolute;top:-78px;left:2px;content:\"\"}.device.ios .volume:after{background:inherit;border-radius:2px 0 0 2px;height:66px;width:4px;position:absolute;top:82px;left:0;content:\"\"}.device.ios .camera{background:#080808;border-radius:100%;height:12px;width:12px;position:absolute;top:24px;left:50%;margin-left:-6px}.device.ios .sensor{background:#3c3d3d;border-radius:100%;height:16px;width:16px;position:absolute;top:49px;left:134px}.device.ios .speaker{background:#292728;border-radius:6px;height:6px;width:70px;position:absolute;top:54px;left:50%;margin-left:-35px}.device.ios.landscape{padding:24px 105px}.device.ios.landscape .sleep{border-radius:2px 2px 0 0;height:4px;width:66px;top:unset;bottom:100%;left:190px}.device.ios.landscape .volume{border-radius:0 0 2px 2px;height:4px;width:66px;bottom:-4px;top:unset;right:calc(100% - 254px);left:unset}.device.ios.landscape .volume:before{border-radius:0 0 2px 2px;height:2px;width:40px;top:unset;bottom:2px;left:-78px;right:auto}.device.ios.landscape .volume:after{border-radius:0 0 2px 2px;height:4px;width:66px;top:unset;bottom:0;right:-82px;left:unset}.device.ios.landscape .home{top:50%;right:22px;left:unset;margin-top:-34px;margin-left:unset}.device.ios.landscape .sensor{top:134px;right:calc(100% - 65px);left:unset}.device.ios.landscape .speaker{height:70px;width:6px;top:50%;right:calc(100% - 60px);left:unset;margin-top:-35px;margin-left:unset}.device.ios.landscape .camera{top:50%;right:calc(100% - 32px);left:unset;margin-top:-6px;margin-left:unset}\n"] }]
516
- }], ctorParameters: () => [], propDecorators: { previewIframe: [{ type: i0.ViewChild, args: ['previewIframe', { isSignal: true }] }], iframeChange: [{ type: i0.Output, args: ["iframeChange"] }] } });
517
-
518
- /**
519
- * Copyright (c) Siemens 2016 - 2026
520
- * SPDX-License-Identifier: MIT
521
- */
522
- class SiLivePreviewIframeComponent {
523
- isFullscreen = input(false, /* @ts-ignore */
524
- ...(ngDevMode ? [{ debugName: "isFullscreen" }] : /* istanbul ignore next */ []));
525
- templateFromComponent = output();
526
- state = inject(LivePreviewStateService);
527
- rendererInProgress = false;
528
- previewIframeRef = signal(undefined, /* @ts-ignore */
529
- ...(ngDevMode ? [{ debugName: "previewIframeRef" }] : /* istanbul ignore next */ []));
530
- previewIframe = this.previewIframeRef.asReadonly();
531
- internalConfig = inject(SI_LIVE_PREVIEW_INTERNALS);
532
- config = inject(SI_LIVE_PREVIEW_CONFIG);
533
- ngZone = inject(NgZone);
534
- destroyRef = inject(DestroyRef);
535
- cdRef = inject(ChangeDetectorRef);
536
- isMobile = this.internalConfig.isMobile;
537
- ticketLinkBug = computed(() => `${this.config.ticketBaseUrl}?issue%5Btitle%5D=%3C${this.state.example()}%3E:&issuable_template=Bug`, /* @ts-ignore */
538
- ...(ngDevMode ? [{ debugName: "ticketLinkBug" }] : /* istanbul ignore next */ []));
539
- ticketLinkFeature = computed(() => `${this.config.ticketBaseUrl}?issue%5Btitle%5D=%3C${this.state.example()}%3E:&issuable_template=Feature Request`, /* @ts-ignore */
540
- ...(ngDevMode ? [{ debugName: "ticketLinkFeature" }] : /* istanbul ignore next */ []));
541
- constructor() {
542
- effect(() => {
543
- // recompute on template changes and re-send whenever any rendered input changes
544
- if (this.previewIframe()) {
545
- this.sendMessage();
546
- }
547
- });
548
- }
549
- ngOnInit() {
550
- this.ngZone.runOutsideAngular(() => fromEvent(window, 'message')
551
- .pipe(takeUntilDestroyed(this.destroyRef))
552
- .subscribe(message => {
553
- this.onMessage(message);
554
- this.cdRef.markForCheck();
555
- }));
556
- }
557
- onMessage(event) {
558
- const previewWindow = this.previewIframe()?.nativeElement.contentWindow;
559
- if (!previewWindow ||
560
- event.origin !== window.location.origin ||
561
- event.source !== previewWindow ||
562
- event.data?.src !== 'renderer') {
563
- return;
564
- }
565
- this.ngZone.run(() => this.onMessageInZone(event));
566
- }
567
- onMessageInZone(event) {
568
- switch (event.data.type) {
569
- case 'ready':
570
- this.sendMessage();
571
- break;
572
- case 'landscapeMode':
573
- this.state.supportsLandscape.set(event.data.message);
574
- break;
575
- case 'clear':
576
- this.state.clearLogs(true);
577
- break;
578
- case 'log':
579
- this.state.addLog(event.data.message);
580
- break;
581
- case 'error':
582
- this.state.renderingError.set(event.data.message);
583
- break;
584
- case 'progress':
585
- {
586
- const progress = event.data.message;
587
- if (progress !== this.rendererInProgress) {
588
- // only emit changes since live-previewer does counting
589
- this.rendererInProgress = progress;
590
- this.state.setRenderingProgress(progress);
591
- }
592
- }
593
- break;
594
- case 'templateFromComponent':
595
- this.state.originalTemplate.set(event.data.message ?? '');
596
- this.templateFromComponent.emit(event.data.message);
597
- break;
598
- case 'theme':
599
- this.state.theme.set(event.data.message);
600
- break;
601
- case 'locale':
602
- this.state.locale.set(event.data.message);
603
- break;
604
- }
605
- }
606
- toggleTheme() {
607
- this.state.toggleTheme();
608
- this.sendMessage();
609
- }
610
- setPreviewIframe(iframe) {
611
- this.previewIframeRef.set(iframe);
612
- }
613
- sendMessage() {
614
- const viewport = this.state.viewport();
615
- this.previewIframe()?.nativeElement.contentWindow.postMessage({
616
- src: 'editor',
617
- exampleUrl: this.state.example(),
618
- template: this.state.template(),
619
- loadReact: this.state.loadReact(),
620
- loadVue: this.state.loadVue(),
621
- loadJs: this.state.loadJs(),
622
- reactVueTemplate: this.state.activeWebComponentTemplate(),
623
- theme: this.state.theme(),
624
- locale: this.state.locale(),
625
- rootFontSize: this.state.rootFontSize(),
626
- isRTL: this.state.isRTL(),
627
- mode: viewport.mode,
628
- safeAreaTop: viewport.safeAreaTop,
629
- safeAreaBottom: viewport.safeAreaBottom,
630
- safeAreaLeft: viewport.safeAreaLeft,
631
- safeAreaRight: viewport.safeAreaRight
632
- }, window.location.origin);
633
- }
634
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiLivePreviewIframeComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
635
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.8", type: SiLivePreviewIframeComponent, isStandalone: true, selector: "si-live-preview-iframe", inputs: { isFullscreen: { classPropertyName: "isFullscreen", publicName: "isFullscreen", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { templateFromComponent: "templateFromComponent" }, host: { properties: { "class.is-mobile": "isMobile" } }, ngImport: i0, template: "<section class=\"header-links\">\n <h1 class=\"example-text\">Example: {{ state.example() }}</h1>\n @if (!isMobile || !isFullscreen()) {\n <div class=\"ticket-links\">\n <a target=\"_blank\" [href]=\"ticketLinkBug()\">Report a bug</a> |\n <a target=\"_blank\" [href]=\"ticketLinkFeature()\">Request a feature</a>\n </div>\n }\n</section>\n\n@if (isMobile) {\n <si-live-preview-mobile-mode (iframeChange)=\"setPreviewIframe($event)\" />\n} @else {\n <si-live-preview-iframe-mode (iframeChange)=\"setPreviewIframe($event)\" />\n}\n", styles: ["a{color:var(--si-sys-color-text-accent)}a:after{display:none}a:hover{color:var(--si-sys-color-text-accent-hover)}:host{display:inline-flex;flex-direction:column}:host.is-mobile{margin-block-end:28px}:host:not(.is-mobile){flex:1}.header-links{block-size:32px;padding-block:9px;color:var(--si-sys-color-text-primary);font-size:11px;flex-shrink:0;display:flex;align-items:center}:host:not(.is-mobile) .header-links{padding-inline:10px}.header-links .ticket-links,.header-links .example-text{line-height:14px}.header-links .ticket-links{margin-inline-start:auto}.header-links .example-text{color:var(--si-sys-color-text-primary);display:inline;font-size:11px;font-weight:600;margin-block:0;margin-inline:0 8px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex:1 1 0;inline-size:0}\n"], dependencies: [{ kind: "component", type: SiLivePreviewIframeModeComponent, selector: "si-live-preview-iframe-mode", outputs: ["iframeChange"] }, { kind: "component", type: SiLivePreviewMobileModeComponent, selector: "si-live-preview-mobile-mode", outputs: ["iframeChange"] }], changeDetection: i0.ChangeDetectionStrategy.Eager });
636
- }
637
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiLivePreviewIframeComponent, decorators: [{
638
- type: Component,
639
- args: [{ selector: 'si-live-preview-iframe', imports: [SiLivePreviewIframeModeComponent, SiLivePreviewMobileModeComponent], changeDetection: ChangeDetectionStrategy.Eager, host: {
640
- '[class.is-mobile]': 'isMobile'
641
- }, template: "<section class=\"header-links\">\n <h1 class=\"example-text\">Example: {{ state.example() }}</h1>\n @if (!isMobile || !isFullscreen()) {\n <div class=\"ticket-links\">\n <a target=\"_blank\" [href]=\"ticketLinkBug()\">Report a bug</a> |\n <a target=\"_blank\" [href]=\"ticketLinkFeature()\">Request a feature</a>\n </div>\n }\n</section>\n\n@if (isMobile) {\n <si-live-preview-mobile-mode (iframeChange)=\"setPreviewIframe($event)\" />\n} @else {\n <si-live-preview-iframe-mode (iframeChange)=\"setPreviewIframe($event)\" />\n}\n", styles: ["a{color:var(--si-sys-color-text-accent)}a:after{display:none}a:hover{color:var(--si-sys-color-text-accent-hover)}:host{display:inline-flex;flex-direction:column}:host.is-mobile{margin-block-end:28px}:host:not(.is-mobile){flex:1}.header-links{block-size:32px;padding-block:9px;color:var(--si-sys-color-text-primary);font-size:11px;flex-shrink:0;display:flex;align-items:center}:host:not(.is-mobile) .header-links{padding-inline:10px}.header-links .ticket-links,.header-links .example-text{line-height:14px}.header-links .ticket-links{margin-inline-start:auto}.header-links .example-text{color:var(--si-sys-color-text-primary);display:inline;font-size:11px;font-weight:600;margin-block:0;margin-inline:0 8px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex:1 1 0;inline-size:0}\n"] }]
642
- }], ctorParameters: () => [], propDecorators: { isFullscreen: [{ type: i0.Input, args: [{ isSignal: true, alias: "isFullscreen", required: false }] }], templateFromComponent: [{ type: i0.Output, args: ["templateFromComponent"] }] } });
643
-
644
- /**
645
- * Copyright (c) Siemens 2016 - 2026
646
- * SPDX-License-Identifier: MIT
647
- */
648
- const isProject = (item) => {
649
- return !Array.isArray(item.files);
650
- };
651
- const isAssetProject = (item) => {
652
- return 'assetUrl' in item;
653
- };
654
- const folder = (path) => path.substring(0, path.lastIndexOf('/') + 1);
655
- const absolute = (base, relative) => {
656
- if (relative.startsWith('./')) {
657
- return `${base}${relative.substring(2)}`;
658
- }
659
- while (relative.startsWith('../')) {
660
- base = base.split('/').slice(0, -2).join('/') + '/';
661
- relative = relative.substring(3);
662
- }
663
- return `${base}${relative}`;
664
- };
665
- const fileName = (path) => path.substring(path.lastIndexOf('/') + 1);
666
- /** Get the base folder for the example files */
667
- const getBaseFolder = (files) => {
668
- for (const path of Object.keys(files)) {
669
- const file = path.split('/').at(-1);
670
- if (file?.includes('example')) {
671
- return folder(path);
672
- }
673
- }
674
- return '';
675
- };
676
- const updateExampleImport = (files, example) => {
677
- const templateExamplePath = Object.keys(files).find(path => path.split('/').at(-1)?.includes('example'));
678
- delete files[templateExamplePath];
679
- const file = fileName(templateExamplePath);
680
- const toReplace = file.substring(0, file.length - 3);
681
- for (const path of Object.keys(files)) {
682
- files[path] = files[path].replace(toReplace, example);
683
- }
684
- return '';
685
- };
686
- const getRelativeImports = (ts) => {
687
- const imports = [];
688
- // Regex to match relative import statements
689
- const relativeImportRegex = /^import\s+[^'"]*\s+from\s+['"](\.\/|\.\.\/)[^'"]+['"];?/gm;
690
- let match;
691
- while ((match = relativeImportRegex.exec(ts)) !== null) {
692
- const importPath = match[0].match(/from\s+['"]([^'"]+)['"]/);
693
- if (importPath?.[1]) {
694
- imports.push(importPath[1]);
695
- }
696
- }
697
- return imports;
698
- };
699
- const getStyleUrls = (ts) => {
700
- const styleUrls = [];
701
- const singleMatch = ts.match(/styleUrl:\s*['"]([^'"]+)['"]/);
702
- if (singleMatch?.[1]) {
703
- styleUrls.push(singleMatch[1]);
704
- }
705
- const pluralMatch = ts.match(/styleUrls:\s*\[([^\]]+)\]/);
706
- if (pluralMatch?.[1]) {
707
- const urls = pluralMatch[1].matchAll(/['"]([^'"]+)['"]/g);
708
- for (const url of urls) {
709
- if (url[1] && !styleUrls.includes(url[1])) {
710
- styleUrls.push(url[1]);
711
- }
712
- }
713
- }
714
- return styleUrls;
715
- };
716
- const addRelativeImports = async (files, baseUrl, baseFolder, path) => {
717
- const ts = files[path];
718
- for (const item of getRelativeImports(ts)) {
719
- const response = await fetch(`${baseUrl}${item}.ts`);
720
- files[absolute(baseFolder, `${item}.ts`)] = await response.text();
721
- }
722
- };
723
- const openStackblitz = async (options) => {
724
- const { framework, templates, example, baseUrl } = options;
725
- const template = templates.find(item => item.name === framework);
726
- if (!template) {
727
- return;
728
- }
729
- // Get template project files
730
- let files = {};
731
- if (isAssetProject(template)) {
732
- for (const file of template.files) {
733
- const response = await fetch(`${template.assetUrl}/${file}`);
734
- files[file] = await response.text();
735
- }
736
- }
737
- else if (isProject(template)) {
738
- files = { ...template.files };
739
- }
740
- const baseFolder = getBaseFolder(files);
741
- const exampleFolder = folder(example);
742
- updateExampleImport(files, example);
743
- // Add example HTML file
744
- const html = await (await fetch(`${baseUrl}${example}.html`)).text();
745
- files[`${baseFolder}${example}.html`] = html;
746
- // Add example TS file
747
- const ts = await (await fetch(`${baseUrl}${example}.ts`)).text();
748
- const tsPath = `${baseFolder}${example}.ts`;
749
- files[tsPath] = ts;
750
- // Add example style files
751
- for (const styleUrl of getStyleUrls(ts)) {
752
- const response = await fetch(absolute(`${baseUrl}${exampleFolder}`, styleUrl));
753
- if (response.ok) {
754
- const stylePath = absolute(`${baseFolder}${exampleFolder}`, styleUrl);
755
- files[stylePath] = await response.text();
756
- }
757
- }
758
- // Get relative imports files
759
- await addRelativeImports(files, `${baseUrl}${exampleFolder}`, `${baseFolder}${exampleFolder}`, tsPath);
760
- sdk.openProject({
761
- title: `Element ${framework} ${example} example`,
762
- template: 'node',
763
- description: 'Blank starter project for building ES6 apps.',
764
- files: { ...files }
765
- }, {
766
- openFile: tsPath
767
- });
768
- };
769
-
770
- /**
771
- * Copyright (c) Siemens 2016 - 2026
772
- * SPDX-License-Identifier: MIT
773
- */
774
- /** Injection token to configure the open in Stackblitz button. */
775
- const SI_STACKBLITZ_CONFIG = new InjectionToken('SI_STACKBLITZ_CONFIG');
776
- /** Provides the Stackblitz configuration with default template projects. */
777
- const provideStackblitzConfig = (config) => ({
778
- provide: SI_STACKBLITZ_CONFIG,
779
- useFactory: () => {
780
- return { templates: [angularTemplateProject()], ...config };
781
- }
782
- });
783
- /**
784
- * Create default Angular template project config.
785
- * The files are loaded from the assets folder, consumers need to add the following asset configuration
786
- * to their angular.json file:
787
- *
788
- * ```json
789
- * "assets": [
790
- * ...
791
- * {
792
- * "glob": "**\/*",
793
- * "input": "projects/live-preview/assets/",
794
- * "output": "/assets/"
795
- * }]
796
- * ```
797
- */
798
- const angularTemplateProject = () => ({
799
- name: 'angular',
800
- assetUrl: 'assets/angular',
801
- files: [
802
- 'angular.json',
803
- 'package.json',
804
- 'tsconfig.json',
805
- 'tsconfig.app.json',
806
- 'src/index.html',
807
- 'src/main.ts',
808
- 'src/app/app.component.ts',
809
- 'src/app/example.component.ts',
810
- 'src/styles.scss'
811
- ]
812
- });
813
-
814
- /**
815
- * Copyright (c) Siemens 2016 - 2026
816
- * SPDX-License-Identifier: MIT
817
- */
818
- class SiStackblitzButtonDirective {
819
- config = inject(SI_STACKBLITZ_CONFIG, { optional: true });
820
- exampleTs = httpResource.text(() => this.example() ? `${this.baseUrl()}${this.example()}.ts` : undefined, /* @ts-ignore */
821
- ...(ngDevMode ? [{ debugName: "exampleTs" }] : /* istanbul ignore next */ []));
822
- isExample = computed(() => {
823
- if (this.exampleTs.hasValue()) {
824
- const content = this.exampleTs.value();
825
- return /selector: 'app-sample'/gm.test(content);
826
- }
827
- return false;
828
- }, /* @ts-ignore */
829
- ...(ngDevMode ? [{ debugName: "isExample" }] : /* istanbul ignore next */ []));
830
- /** Framework to use for the Stackblitz project. */
831
- framework = input.required(/* @ts-ignore */
832
- ...(ngDevMode ? [{ debugName: "framework" }] : /* istanbul ignore next */ []));
833
- /** The example base URL. */
834
- baseUrl = input.required(/* @ts-ignore */
835
- ...(ngDevMode ? [{ debugName: "baseUrl" }] : /* istanbul ignore next */ []));
836
- /** The example name. */
837
- example = input(/* @ts-ignore */
838
- ...(ngDevMode ? [undefined, { debugName: "example" }] : /* istanbul ignore next */ []));
839
- /** Indicate whether a stackblitz isn't available. */
840
- disabled = computed(() => !this.config?.templates.find(item => item.name === this.framework()) ||
841
- !this.example() ||
842
- !this.isExample(), /* @ts-ignore */
843
- ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
844
- /** Open the Stackblitz editor with the specified configuration. */
845
- async openStackblitz() {
846
- await openStackblitz({
847
- framework: this.framework(),
848
- example: this.example(),
849
- templates: this.config.templates,
850
- baseUrl: this.baseUrl()
851
- });
852
- }
853
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiStackblitzButtonDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
854
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.8", type: SiStackblitzButtonDirective, isStandalone: true, selector: "button[siStackblitz]", inputs: { framework: { classPropertyName: "framework", publicName: "framework", isSignal: true, isRequired: true, transformFunction: null }, baseUrl: { classPropertyName: "baseUrl", publicName: "baseUrl", isSignal: true, isRequired: true, transformFunction: null }, example: { classPropertyName: "example", publicName: "example", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "title": "Open Stackblitz", "attr.aria-label": "Open in Stackblitz" }, listeners: { "click": "openStackblitz()" }, properties: { "style.display": "!config ? \"none\" : null", "disabled": "disabled()" } }, ngImport: i0 });
855
- }
856
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiStackblitzButtonDirective, decorators: [{
857
- type: Directive,
858
- args: [{
859
- selector: 'button[siStackblitz]',
860
- host: {
861
- 'title': 'Open Stackblitz',
862
- 'attr.aria-label': 'Open in Stackblitz',
863
- '[style.display]': '!config ? "none" : null',
864
- '[disabled]': 'disabled()',
865
- '(click)': 'openStackblitz()'
866
- }
867
- }]
868
- }], propDecorators: { framework: [{ type: i0.Input, args: [{ isSignal: true, alias: "framework", required: true }] }], baseUrl: [{ type: i0.Input, args: [{ isSignal: true, alias: "baseUrl", required: true }] }], example: [{ type: i0.Input, args: [{ isSignal: true, alias: "example", required: false }] }] } });
869
-
870
- /**
871
- * Copyright (c) Siemens 2016 - 2026
872
- * SPDX-License-Identifier: MIT
873
- */
874
- class SiLivePreviewComponent {
875
- config = inject(SI_LIVE_PREVIEW_CONFIG);
876
- internalConfig = inject(SI_LIVE_PREVIEW_INTERNALS);
877
- self = inject(ElementRef);
878
- http = inject(HttpClient);
879
- localeApi = inject(SiLivePreviewLocaleApi, { optional: true });
880
- state = inject(LivePreviewStateService);
881
- templateElem = viewChild.required('codeTemplate', /* @ts-ignore */
882
- ...(ngDevMode ? [{ debugName: "templateElem" }] : /* istanbul ignore next */ []));
883
- typescriptElem = viewChild.required('codeTypescript', /* @ts-ignore */
884
- ...(ngDevMode ? [{ debugName: "typescriptElem" }] : /* istanbul ignore next */ []));
885
- reactVueElem = viewChild.required('codeReactVue', /* @ts-ignore */
886
- ...(ngDevMode ? [{ debugName: "reactVueElem" }] : /* istanbul ignore next */ []));
887
- consoleElem = viewChild.required('consoleContainer', /* @ts-ignore */
888
- ...(ngDevMode ? [{ debugName: "consoleElem" }] : /* istanbul ignore next */ []));
889
- baseUrl = this.config.examplesBaseUrl;
890
- isFullscreen = signal(false, /* @ts-ignore */
891
- ...(ngDevMode ? [{ debugName: "isFullscreen" }] : /* istanbul ignore next */ []));
892
- isMobile = this.internalConfig.isMobile;
893
- templateTs = '';
894
- activeTab = signal('template', /* @ts-ignore */
895
- ...(ngDevMode ? [{ debugName: "activeTab" }] : /* istanbul ignore next */ []));
896
- showCopied = signal(false, /* @ts-ignore */
897
- ...(ngDevMode ? [{ debugName: "showCopied" }] : /* istanbul ignore next */ []));
898
- allowFullscreen = !!document.fullscreenEnabled || !!document.webkitFullscreenEnabled;
899
- exampleFullscreen = signal(false, /* @ts-ignore */
900
- ...(ngDevMode ? [{ debugName: "exampleFullscreen" }] : /* istanbul ignore next */ []));
901
- allowCopy = !!navigator.clipboard;
902
- switcherEnabled = this.config.themeSwitcher;
903
- rtlSwitcher = this.config.rtlSwitcher;
904
- rootFontSizes = this.config.rootFontSizes ?? [];
905
- webcomponents = this.config.webcomponents;
906
- frameworks = new Map([['Angular', 'angular']]);
907
- availableLocales = this.localeApi?.availableLocales() ?? [];
908
- editorCollapsed = signal(localStorage.getItem('si-live-preview-editor-collapsed') === 'true' && !this.isMobile, /* @ts-ignore */
909
- ...(ngDevMode ? [{ debugName: "editorCollapsed" }] : /* istanbul ignore next */ []));
910
- showEditor = signal(!this.editorCollapsed(), /* @ts-ignore */
911
- ...(ngDevMode ? [{ debugName: "showEditor" }] : /* istanbul ignore next */ []));
912
- compileSubject = new Subject();
913
- templateModified = false;
914
- skipInitialLoad = false;
915
- flaskTemplate;
916
- flaskTypescript;
917
- flaskReactVue;
918
- savedScrollPos = { top: 0, left: 0 };
919
- tsLoaded = false;
920
- reactLoaded = false;
921
- vueLoaded = false;
922
- jsLoaded = false;
923
- webcomponentsList = [];
924
- constructor() {
925
- const storedFramework = localStorage.getItem('si-live-preview-framework');
926
- if (storedFramework === 'react' || storedFramework === 'vue' || storedFramework === 'js') {
927
- this.state.framework.set(storedFramework);
928
- }
929
- this.compileSubject
930
- .pipe(throttleTime(500, undefined, { leading: true, trailing: true }))
931
- .pipe(takeUntilDestroyed())
932
- .subscribe(template => {
933
- this.state.template.set(template);
934
- });
935
- this.webcomponentsList = this.config.componentLoader.webcomponentsList;
936
- let previousExample;
937
- effect(() => {
938
- const example = this.state.example();
939
- if (!example || example === previousExample) {
940
- return;
941
- }
942
- const firstLoad = previousExample === undefined;
943
- previousExample = example;
944
- untracked(() => {
945
- this.activeTab.set(this.activeTab() !== 'typescript' ? 'template' : this.activeTab());
946
- this.skipInitialLoad =
947
- firstLoad &&
948
- !!(this.state.template() ||
949
- this.state.templateReact() ||
950
- this.state.templateVue() ||
951
- this.state.templateJs());
952
- this.templateModified = !!this.state.template();
953
- this.loadFromUrl(this.skipInitialLoad);
954
- if (this.webcomponents) {
955
- this.reactLoaded = false;
956
- this.vueLoaded = false;
957
- this.jsLoaded = false;
958
- this.state.stopWebComponentLoading();
959
- this.checkWebComponentsAvailable();
960
- }
961
- });
962
- });
963
- effect(() => localStorage.setItem('si-live-preview-theme', this.state.theme()));
964
- effect(() => {
965
- if (this.state.logMessages().length) {
966
- setTimeout(() => {
967
- this.consoleElem().nativeElement.scrollTop =
968
- this.consoleElem().nativeElement.scrollHeight;
969
- });
970
- }
971
- });
972
- }
973
- ngOnInit() {
974
- this.state.theme.set(localStorage.getItem('si-live-preview-theme') === 'dark' ? 'dark' : 'light');
975
- const rfs = localStorage.getItem('si-live-preview-rfs') ?? '';
976
- this.state.rootFontSize.set(rfs === 'initial' ? rfs : rfs ? parseInt(rfs, 10) : 0);
977
- }
978
- ngAfterViewInit() {
979
- this.flaskTemplate = new CodeFlask(this.templateElem().nativeElement, {
980
- lineNumbers: true,
981
- language: 'html',
982
- defaultTheme: false,
983
- handleSelfClosingCharacters: false,
984
- handleTabs: false,
985
- ariaLabelledby: 'templateEditorTab'
986
- });
987
- this.flaskTypescript = new CodeFlask(this.typescriptElem().nativeElement, {
988
- lineNumbers: true,
989
- language: 'typescript',
990
- readonly: true,
991
- defaultTheme: false,
992
- handleTabs: false,
993
- ariaLabelledby: 'typescriptEditorTab'
994
- });
995
- this.flaskReactVue = new CodeFlask(this.reactVueElem().nativeElement, {
996
- lineNumbers: true,
997
- language: 'typescript',
998
- readonly: false,
999
- defaultTheme: false,
1000
- handleTabs: false,
1001
- areaId: 'reactVueEditor'
1002
- });
1003
- this.flaskTemplate.onUpdate((code) => {
1004
- if (code !== this.state.template()) {
1005
- this.templateModified = true;
1006
- }
1007
- this.compileSubject.next(code);
1008
- });
1009
- this.flaskReactVue.onUpdate((code) => {
1010
- if (this.activeTab() === 'react') {
1011
- this.state.templateReact.set(code);
1012
- this.state.loadReact.set(true);
1013
- }
1014
- else if (this.activeTab() === 'vue') {
1015
- this.state.templateVue.set(code);
1016
- this.state.loadVue.set(true);
1017
- }
1018
- else if (this.activeTab() === 'js') {
1019
- this.state.templateJs.set(code);
1020
- this.state.loadJs.set(true);
1021
- }
1022
- });
1023
- if (this.skipInitialLoad) {
1024
- if (this.state.templateReact()) {
1025
- this.reactLoaded = true;
1026
- this.changeFramework('react');
1027
- }
1028
- else if (this.state.templateVue()) {
1029
- this.vueLoaded = true;
1030
- this.changeFramework('vue');
1031
- }
1032
- else if (this.state.templateJs()) {
1033
- this.jsLoaded = true;
1034
- this.changeFramework('js');
1035
- }
1036
- else {
1037
- this.flaskTemplate.updateCode(this.state.template());
1038
- this.compileSubject.next(this.state.template());
1039
- }
1040
- this.skipInitialLoad = false;
1041
- }
1042
- }
1043
- activateTab(tab) {
1044
- this.activeTab.set(tab);
1045
- let saveScroll;
1046
- let restoreScroll;
1047
- this.state.loadReact.set(false);
1048
- this.state.loadVue.set(false);
1049
- this.state.loadJs.set(false);
1050
- if (tab === 'template') {
1051
- saveScroll = this.typescriptElem();
1052
- restoreScroll = this.templateElem();
1053
- }
1054
- else {
1055
- if (!this.tsLoaded) {
1056
- this.loadTsFromUrl();
1057
- }
1058
- saveScroll = this.templateElem();
1059
- restoreScroll = this.typescriptElem();
1060
- }
1061
- const areaSave = saveScroll.nativeElement.querySelector('textarea');
1062
- const areaRestore = restoreScroll.nativeElement.querySelector('textarea');
1063
- const scrollPos = this.savedScrollPos;
1064
- this.savedScrollPos = { left: areaSave.scrollLeft, top: areaSave.scrollTop };
1065
- setTimeout(() => {
1066
- areaRestore.scrollTop = scrollPos.top;
1067
- areaRestore.scrollLeft = scrollPos.left;
1068
- });
1069
- }
1070
- themeChange(theme) {
1071
- this.state.theme.set(theme);
1072
- localStorage.setItem('si-live-preview-theme', this.state.theme());
1073
- }
1074
- updateTemplate(template) {
1075
- this.templateModified = false;
1076
- this.state.template.set(template);
1077
- if (this.flaskTemplate) {
1078
- this.flaskTemplate.updateCode(this.state.template());
1079
- }
1080
- }
1081
- updateTs(ts) {
1082
- this.templateTs = ts;
1083
- if (this.flaskTypescript) {
1084
- this.flaskTypescript.updateCode(this.templateTs);
1085
- }
1086
- }
1087
- updateReact(ts) {
1088
- this.state.templateReact.set(ts);
1089
- if (this.flaskReactVue) {
1090
- this.flaskReactVue.updateCode(this.state.templateReact());
1091
- this.state.loadReact.set(true);
1092
- }
1093
- }
1094
- updateVue(ts) {
1095
- this.state.templateVue.set(ts);
1096
- if (this.flaskReactVue) {
1097
- this.flaskReactVue.updateCode(this.state.templateVue());
1098
- this.state.loadVue.set(true);
1099
- }
1100
- }
1101
- updateJs(js) {
1102
- this.state.templateJs.set(js);
1103
- if (this.flaskReactVue) {
1104
- this.flaskReactVue.updateCode(this.state.templateJs());
1105
- this.state.loadJs.set(true);
1106
- }
1107
- }
1108
- loadFromUrl(skipTemplate) {
1109
- if (!skipTemplate) {
1110
- this.updateTemplate('');
1111
- }
1112
- this.updateTs('');
1113
- this.savedScrollPos = { top: 0, left: 0 };
1114
- this.state.resetRenderingProgress();
1115
- this.tsLoaded = false;
1116
- if (this.activeTab() === 'typescript') {
1117
- this.loadTsFromUrl();
1118
- }
1119
- }
1120
- loadTemplateFromUrl() {
1121
- const example = this.state.example();
1122
- if (!example) {
1123
- return;
1124
- }
1125
- this.handleInProgressEvent(true);
1126
- this.http
1127
- .get(this.baseUrl + example + '.html', { responseType: 'text' })
1128
- .pipe(timeout(3000), retry(1))
1129
- .subscribe({
1130
- next: data => {
1131
- this.updateTemplate(data);
1132
- setTimeout(() => {
1133
- this.handleInProgressEvent(false);
1134
- });
1135
- },
1136
- error: () => {
1137
- this.handleInProgressEvent(false);
1138
- }
1139
- });
1140
- }
1141
- loadTsFromUrl() {
1142
- const example = this.state.example();
1143
- if (!example) {
1144
- return;
1145
- }
1146
- this.handleInProgressEvent(true);
1147
- this.http
1148
- .get(this.baseUrl + example + '.ts', { responseType: 'text' })
1149
- .pipe(timeout(3000), retry(1))
1150
- .subscribe({
1151
- next: data => {
1152
- this.updateTs(data);
1153
- this.tsLoaded = true;
1154
- setTimeout(() => {
1155
- this.handleInProgressEvent(false);
1156
- });
1157
- },
1158
- error: () => {
1159
- this.tsLoaded = true;
1160
- this.handleInProgressEvent(false);
1161
- }
1162
- });
1163
- }
1164
- checkWebComponentsAvailable() {
1165
- const baseUrl = this.baseUrl;
1166
- const example = this.state.example() ?? '';
1167
- if (this.webcomponentsList.includes(baseUrl + example + '-react')) {
1168
- this.frameworks.set('React', 'react');
1169
- }
1170
- else {
1171
- if (this.state.framework() === 'react') {
1172
- this.state.framework.set('angular');
1173
- }
1174
- this.frameworks.delete('React');
1175
- }
1176
- if (this.webcomponentsList.includes(baseUrl + example + '-vue')) {
1177
- this.frameworks.set('Vue', 'vue');
1178
- }
1179
- else {
1180
- if (this.state.framework() === 'vue') {
1181
- this.state.framework.set('angular');
1182
- }
1183
- this.frameworks.delete('Vue');
1184
- }
1185
- if (this.webcomponentsList.includes(baseUrl + example + '-js')) {
1186
- this.frameworks.set('Js', 'js');
1187
- }
1188
- else {
1189
- if (this.state.framework() === 'js') {
1190
- this.state.framework.set('angular');
1191
- }
1192
- this.frameworks.delete('Js');
1193
- }
1194
- this.changeFramework(this.state.framework());
1195
- }
1196
- changeFramework(framework) {
1197
- this.activeTab.set(framework);
1198
- this.state.framework.set(framework);
1199
- localStorage.setItem('si-live-preview-framework', framework);
1200
- this.state.loadReact.set(false);
1201
- this.state.loadVue.set(false);
1202
- this.state.loadJs.set(false);
1203
- let fileType = 'vue';
1204
- if (framework === 'angular') {
1205
- this.activeTab.set('template');
1206
- return;
1207
- }
1208
- else if (framework === 'react') {
1209
- fileType = 'tsx';
1210
- if (this.reactLoaded) {
1211
- this.updateReact(this.state.templateReact());
1212
- return;
1213
- }
1214
- }
1215
- else if (framework === 'vue' && this.vueLoaded) {
1216
- this.updateVue(this.state.templateVue());
1217
- return;
1218
- }
1219
- else if (framework === 'js') {
1220
- fileType = 'html';
1221
- if (this.jsLoaded) {
1222
- this.updateJs(this.state.templateJs());
1223
- return;
1224
- }
1225
- }
1226
- this.handleInProgressEvent(true);
1227
- const baseUrl = this.baseUrl;
1228
- const example = this.state.example() ?? '';
1229
- this.http
1230
- .get(`${baseUrl}${example}-${framework}.${fileType}`, { responseType: 'text' })
1231
- .subscribe({
1232
- next: (res) => {
1233
- if (framework === 'react') {
1234
- this.updateReact(res);
1235
- this.state.templateReact.set(res);
1236
- this.reactLoaded = true;
1237
- }
1238
- else if (framework === 'vue') {
1239
- this.updateVue(res);
1240
- this.state.templateVue.set(res);
1241
- this.vueLoaded = true;
1242
- }
1243
- else if (framework === 'js') {
1244
- this.updateJs(res);
1245
- this.state.templateJs.set(res);
1246
- this.jsLoaded = true;
1247
- }
1248
- setTimeout(() => {
1249
- this.handleInProgressEvent(false);
1250
- });
1251
- },
1252
- error: (err) => {
1253
- if (framework === 'react') {
1254
- this.updateReact('');
1255
- this.reactLoaded = true;
1256
- }
1257
- else if (framework === 'vue') {
1258
- this.updateVue('');
1259
- this.vueLoaded = true;
1260
- }
1261
- else if (framework === 'js') {
1262
- this.updateJs('');
1263
- this.jsLoaded = true;
1264
- }
1265
- this.handleInProgressEvent(false);
1266
- }
1267
- });
1268
- }
1269
- templateFromComponent(template) {
1270
- if (this.state.template()) {
1271
- return;
1272
- }
1273
- if (template === undefined) {
1274
- // there's no component loaded in the renderer, load template from url
1275
- this.loadTemplateFromUrl();
1276
- }
1277
- else {
1278
- // using template from component
1279
- this.updateTemplate(template);
1280
- }
1281
- }
1282
- handleInProgressEvent(inProgress) {
1283
- this.state.setRenderingProgress(inProgress);
1284
- }
1285
- logClear(delayed = false) {
1286
- if (this.state.logMessages().length) {
1287
- this.state.clearLogs(delayed);
1288
- setTimeout(() => {
1289
- this.consoleElem().nativeElement.scrollTop = 0;
1290
- }, delayed ? 100 : 0);
1291
- }
1292
- }
1293
- logEvent(msg) {
1294
- this.state.addLog(msg);
1295
- }
1296
- showCopiedLabel() {
1297
- this.showCopied.set(true);
1298
- setTimeout(() => {
1299
- this.showCopied.set(false);
1300
- }, 1500);
1301
- }
1302
- toggleFullscreen(exampleOnly = false) {
1303
- const fullscreenElement = document.fullscreenElement ?? document.webkitFullscreenElement;
1304
- if (fullscreenElement) {
1305
- const exitFunction = document.exitFullscreen ?? document.webkitExitFullscreen;
1306
- if (exitFunction) {
1307
- exitFunction.call(document);
1308
- }
1309
- }
1310
- else {
1311
- const elem = exampleOnly
1312
- ? this.self.nativeElement.querySelector(':scope > .example')
1313
- : this.self.nativeElement;
1314
- this.exampleFullscreen.set(exampleOnly);
1315
- const requestFunction = elem.requestFullscreen ?? elem.webkitRequestFullScreen;
1316
- if (requestFunction) {
1317
- requestFunction.call(elem);
1318
- }
1319
- }
1320
- }
1321
- toggleCollapse() {
1322
- this.editorCollapsed.set(!this.editorCollapsed());
1323
- localStorage.setItem('si-live-preview-editor-collapsed', this.editorCollapsed().toString());
1324
- if (this.editorCollapsed()) {
1325
- this.showEditor.set(false);
1326
- setTimeout(() => window.dispatchEvent(new Event('resize')), 500);
1327
- }
1328
- else {
1329
- setTimeout(() => {
1330
- this.showEditor.set(true);
1331
- this.state.newMessages.set(false);
1332
- window.dispatchEvent(new Event('resize'));
1333
- }, 500);
1334
- }
1335
- }
1336
- toggleRTL() {
1337
- this.state.isRTL.set(!this.state.isRTL());
1338
- }
1339
- toggleTheme() {
1340
- this.themeChange(this.state.theme() === 'dark' ? 'light' : 'dark');
1341
- }
1342
- localeSelectionChanged(target) {
1343
- const locale = target?.value;
1344
- this.changeLocale(locale);
1345
- }
1346
- rfsSelectionChanges(value) {
1347
- this.state.rootFontSize.set(value === 'initial' ? value : parseInt(value, 10));
1348
- localStorage.setItem('si-live-preview-rfs', this.state.rootFontSize().toString());
1349
- }
1350
- changeLocale(locale) {
1351
- this.state.locale.set(locale ?? undefined);
1352
- }
1353
- renderingErrorMessage() {
1354
- return String(this.state.renderingError());
1355
- }
1356
- copyTemplate() {
1357
- this.clipboardCopy(this.state.template());
1358
- }
1359
- copyCode() {
1360
- if (this.activeTab() === 'react') {
1361
- this.clipboardCopy(this.state.templateReact());
1362
- }
1363
- else if (this.activeTab() === 'vue') {
1364
- this.clipboardCopy(this.state.templateVue());
1365
- }
1366
- else if (this.activeTab() === 'js') {
1367
- this.clipboardCopy(this.state.templateJs());
1368
- }
1369
- else {
1370
- this.clipboardCopy(this.templateTs);
1371
- }
1372
- }
1373
- clipboardCopy(text) {
1374
- navigator.clipboard.writeText(text);
1375
- this.showCopiedLabel();
1376
- }
1377
- createLink() {
1378
- const url = this.createTemplateLink('editor');
1379
- this.clipboardCopy(url);
1380
- }
1381
- openTab() {
1382
- const url = this.createTemplateLink('viewer');
1383
- window.open(url, '_blank');
1384
- }
1385
- createTemplateLink(mode) {
1386
- const locale = this.state.locale();
1387
- let url = `${window.location.protocol}//${window.location.host}`;
1388
- url += window.location.pathname;
1389
- url += `#/viewer/${mode}?`;
1390
- url += 'theme=' + this.state.theme();
1391
- if (this.state.isRTL()) {
1392
- url += '&isRTL=true';
1393
- }
1394
- if (locale) {
1395
- url += '&locale=' + locale;
1396
- }
1397
- if (this.state.rootFontSize()) {
1398
- url += '&rfs=' + this.state.rootFontSize();
1399
- }
1400
- if (this.activeTab() === 'react') {
1401
- url += '&t=' + encodeURIComponent(this.state.templateReact()) + '&framework=react';
1402
- }
1403
- else if (this.activeTab() === 'vue') {
1404
- url += '&t=' + encodeURIComponent(this.state.templateVue()) + '&framework=vue';
1405
- }
1406
- else if (this.activeTab() === 'js') {
1407
- url += '&t=' + encodeURIComponent(this.state.templateJs()) + '&framework=js';
1408
- }
1409
- else if (this.templateModified) {
1410
- url += '&t=' + encodeURIComponent(this.state.template());
1411
- }
1412
- const example = this.state.example();
1413
- if (example) {
1414
- url += '&e=' + encodeURIComponent(example);
1415
- }
1416
- return url;
1417
- }
1418
- onFullscreenChange() {
1419
- this.isFullscreen.set(!!document.fullscreenElement || !!document.webkitFullscreenElement);
1420
- if (!this.isFullscreen()) {
1421
- this.exampleFullscreen.set(false);
1422
- }
1423
- }
1424
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiLivePreviewComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1425
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.8", type: SiLivePreviewComponent, isStandalone: true, selector: "si-live-preview", host: { listeners: { "document:fullscreenchange": "onFullscreenChange()", "document:webkitfullscreenchange": "onFullscreenChange()" }, properties: { "class.editor-fullscreen": "isFullscreen()", "class.is-mobile": "isMobile" } }, viewQueries: [{ propertyName: "templateElem", first: true, predicate: ["codeTemplate"], descendants: true, isSignal: true }, { propertyName: "typescriptElem", first: true, predicate: ["codeTypescript"], descendants: true, isSignal: true }, { propertyName: "reactVueElem", first: true, predicate: ["codeReactVue"], descendants: true, isSignal: true }, { propertyName: "consoleElem", first: true, predicate: ["consoleContainer"], descendants: true, isSignal: true }], ngImport: i0, template: "@let active = activeTab();\n<div class=\"example\" [class.fullscreen]=\"exampleFullscreen()\" [class.is-mobile]=\"isMobile\">\n <div class=\"preview-iframe\" [class.is-mobile]=\"isMobile\">\n <si-live-preview-iframe\n [isFullscreen]=\"isFullscreen()\"\n (templateFromComponent)=\"templateFromComponent($event)\"\n />\n @if (state.inProgress()) {\n <div class=\"progress-container\">\n <div class=\"progress-inner\">\n <div class=\"progress-dots\"></div>\n </div>\n </div>\n }\n @if (isFullscreen()) {\n <div class=\"buttons\">\n <button\n type=\"button\"\n class=\"btn-command fullscreen\"\n title=\"Close fullscreen\"\n aria-label=\"Close fullscreen\"\n (click)=\"toggleFullscreen(true)\"\n >\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\">\n <path\n d=\"M273,256l87.52-87.51a12,12,0,0,0-17-17L256,239l-87.51-87.52a12,12,0,0,0-17,17L239,256l-87.52,87.51a12,12,0,0,0,17,17L256,273l87.51,87.52a12,12,0,0,0,17-17Z\"\n />\n </svg>\n </button>\n </div>\n }\n </div>\n</div>\n\n<div class=\"code\" [class.is-mobile]=\"isMobile\" [class.is-collapsed]=\"editorCollapsed()\">\n <div class=\"collapse-wrapper\">\n <div role=\"tablist\" class=\"nav lp-tabs\">\n @if (showEditor() && (active === 'template' || active === 'typescript')) {\n <button\n type=\"button\"\n role=\"tab\"\n class=\"tab-item tab-link focus-inside\"\n id=\"templateEditorTab\"\n [class.tab-active]=\"active === 'template'\"\n (click)=\"activateTab('template')\"\n >\n Template\n </button>\n <button\n type=\"button\"\n role=\"tab\"\n class=\"tab-item tab-link focus-inside\"\n id=\"typescriptEditorTab\"\n [class.tab-active]=\"active === 'typescript'\"\n (click)=\"activateTab('typescript')\"\n >\n Typescript\n </button>\n }\n </div>\n @if (!isMobile) {\n <div class=\"collapse-button\" [class.is-collapsed]=\"editorCollapsed()\">\n <button\n type=\"button\"\n [attr.title]=\"editorCollapsed() ? 'Show editor' : 'Hide editor'\"\n [attr.aria-label]=\"editorCollapsed() ? 'Show editor' : 'Hide editor'\"\n (click)=\"toggleCollapse()\"\n >\n <svg class=\"collapse-icon\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\">\n <path\n class=\"cls-1\"\n d=\"M248.93,277.23l-1.72-1.44-110-110a12.43,12.43,0,0,1,15.86-19l1.72,1.44L256,249.41l101.21-101.2a12.45,12.45,0,0,1,15.86-1.44l1.72,1.44a12.45,12.45,0,0,1,1.44,15.86l-1.44,1.72-110,110A12.45,12.45,0,0,1,248.93,277.23Z\"\n />\n <path\n class=\"cls-1\"\n d=\"M248.93,365.23l-1.72-1.44-88-88a12.43,12.43,0,0,1,15.86-19l1.72,1.44L256,337.41l79.21-79.2a12.45,12.45,0,0,1,15.86-1.44l1.72,1.44a12.45,12.45,0,0,1,1.44,15.86l-1.44,1.72-88,88A12.45,12.45,0,0,1,248.93,365.23Z\"\n />\n </svg>\n </button>\n </div>\n }\n </div>\n\n @if (allowFullscreen && !isFullscreen()) {\n <div class=\"buttons\">\n @if (webcomponents && showEditor() && frameworks.size > 1) {\n <select\n aria-label=\"Select framework\"\n class=\"btn-command locale-selection\"\n [ngModel]=\"state.framework()\"\n (ngModelChange)=\"changeFramework($event)\"\n >\n @for (aFramework of frameworks | keyvalue; track $index) {\n <option [value]=\"aFramework.value\" [selected]=\"state.framework() === aFramework.value\">\n {{ aFramework.key }}\n </option>\n }\n </select>\n }\n @if (rootFontSizes.length) {\n <select\n name=\"selectRfs\"\n aria-label=\"Root font size\"\n title=\"Root font size\"\n class=\"btn-command rfs-selection\"\n [ngModel]=\"state.rootFontSize()\"\n (ngModelChange)=\"rfsSelectionChanges($event)\"\n >\n <option value=\"0\">none</option>\n <option value=\"initial\">initial</option>\n @for (rfs of rootFontSizes; track rfs) {\n <option [value]=\"rfs\">{{ rfs }}px</option>\n }\n </select>\n }\n @if (!!localeApi && showEditor()) {\n <select\n name=\"selectLocale\"\n aria-label=\"Select locale\"\n title=\"Locale\"\n class=\"btn-command locale-selection\"\n (change)=\"localeSelectionChanged($event.target)\"\n >\n @for (aLocale of availableLocales; track $index) {\n <option [value]=\"aLocale\" [selected]=\"state.locale() === aLocale\">\n {{ aLocale }}\n </option>\n }\n </select>\n }\n @if (rtlSwitcher) {\n <button\n type=\"button\"\n class=\"btn-command rtl-selection\"\n [title]=\"state.isRTL() ? 'Right-to-left layout' : 'Left-to-right layout'\"\n [attr.aria-label]=\"state.isRTL() ? 'Right-to-left layout' : 'Left-to-right layout'\"\n (click)=\"toggleRTL()\"\n >\n {{ state.isRTL() ? 'RTL' : 'LTR' }}\n </button>\n }\n @if (\n !isMobile &&\n !showEditor() &&\n (state.renderingError() || (state.logMessages().length && state.newMessages()))\n ) {\n <button\n type=\"button\"\n class=\"btn-command\"\n title=\"Show console\"\n aria-label=\"Show console\"\n [class.alert]=\"state.renderingError()\"\n [class.info]=\"state.logMessages().length\"\n (click)=\"toggleCollapse()\"\n >\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\">\n <path\n d=\"M255.84,296a12,12,0,0,1-12-12V124a12,12,0,1,1,24,0V284A12,12,0,0,1,255.84,296Z\"\n />\n <path d=\"M256.12,387.81h-.24a16,16,0,0,1,0-32h.24a16,16,0,0,1,0,32Z\" />\n </svg>\n </button>\n }\n @if (switcherEnabled && !isMobile) {\n <button\n type=\"button\"\n class=\"btn-command\"\n title=\"Toggle theme\"\n aria-label=\"Toggle theme\"\n (click)=\"toggleTheme()\"\n >\n @if (state.theme() === 'dark') {\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\">\n <path\n d=\"M256,349.82A93.82,93.82,0,1,0,162.18,256,93.93,93.93,0,0,0,256,349.82Zm0-163.64A69.82,69.82,0,1,1,186.18,256,69.9,69.9,0,0,1,256,186.18Z\"\n />\n <path\n d=\"M256,120.73a12,12,0,0,0,12-12V76a12,12,0,0,0-24,0v32.73A12,12,0,0,0,256,120.73Z\"\n />\n <path d=\"M268,436V403.27a12,12,0,0,0-24,0V436a12,12,0,0,0,24,0Z\" />\n <path d=\"M143.44,160.41a12,12,0,1,0,17-17l-23.23-23.23a12,12,0,1,0-17,17Z\" />\n <path\n d=\"M351.59,351.59a12,12,0,0,0,0,17l23.23,23.23a12,12,0,0,0,17-17l-23.23-23.23A12,12,0,0,0,351.59,351.59Z\"\n />\n <path\n d=\"M120.73,256a12,12,0,0,0-12-12H76a12,12,0,0,0,0,24h32.73A12,12,0,0,0,120.73,256Z\"\n />\n <path d=\"M436,244H403.27a12,12,0,0,0,0,24H436a12,12,0,0,0,0-24Z\" />\n <path\n d=\"M137.18,391.79l23.23-23.23a12,12,0,1,0-17-17l-23.23,23.23a12,12,0,1,0,17,17Z\"\n />\n <path\n d=\"M360.07,163.93a12,12,0,0,0,8.49-3.52l23.23-23.23a12,12,0,1,0-17-17l-23.23,23.23a12,12,0,0,0,8.48,20.49Z\"\n />\n </svg>\n } @else {\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\">\n <path\n d=\"M360.07,147.88a12,12,0,0,0,5.89-21.1,168.05,168.05,0,0,0-214.71,0C80,186,70.19,292.1,129.38,363.35a166.9,166.9,0,0,0,113.77,59.93q7.9.74,15.75.73A166.74,166.74,0,0,0,366,385.22a12,12,0,0,0-5.89-21.1,109.33,109.33,0,0,1,0-216.24ZM244.43,275.77A133.48,133.48,0,0,0,330,381.08,144.11,144.11,0,0,1,147.84,348C97.1,287,105.51,196,166.58,145.24A144.08,144.08,0,0,1,330,130.94C272,152.38,234.91,212.29,244.43,275.77Z\"\n />\n </svg>\n }\n </button>\n }\n @if (!isMobile && showEditor()) {\n <button\n type=\"button\"\n class=\"btn-command\"\n title=\"Example fullscreen\"\n aria-label=\"Example fullscreen\"\n (click)=\"toggleFullscreen(true)\"\n >\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\">\n <path\n d=\"M406,112H106a42,42,0,0,0-42,42V358a42,42,0,0,0,42,42H406a42,42,0,0,0,42-42V154A42,42,0,0,0,406,112Zm18,246a18,18,0,0,1-18,18H106a18,18,0,0,1-18-18V154a18,18,0,0,1,18-18H406a18,18,0,0,1,18,18Z\"\n />\n </svg>\n </button>\n }\n @if (showEditor()) {\n <button\n type=\"button\"\n class=\"btn-command\"\n title=\"Editor + Example fullscreen\"\n aria-label=\"Editor + Example fullscreen\"\n (click)=\"toggleFullscreen()\"\n >\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\">\n <path\n d=\"M406,112H106a42,42,0,0,0-42,42V358a42,42,0,0,0,42,42H406a42,42,0,0,0,42-42V154A42,42,0,0,0,406,112Zm18,42V313.44H199.35V136H406A18,18,0,0,1,424,154ZM88,358V154a18,18,0,0,1,18-18h69.35V376H106A18,18,0,0,1,88,358Zm318,18H199.35V337.44H424V358A18,18,0,0,1,406,376Z\"\n />\n </svg>\n </button>\n }\n <button\n siStackblitz\n class=\"btn-command\"\n type=\"button\"\n [baseUrl]=\"baseUrl\"\n [framework]=\"state.framework()\"\n [example]=\"state.example()\"\n >\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\">\n <path\n d=\"M182.32 480.02c-3.65 0-7.34-1.01-10.68-3.09-8.61-5.36-11.86-15.98-7.72-25.24s65.44-146.6 65.44-146.6c.58-1.29.19-2.34-.23-3-.42-.65-1.23-1.43-2.64-1.43h-54.96c-13.79 0-25.98-7.76-31.83-20.24s-4-26.82 4.83-37.41L314.3 39.26c6.5-7.79 17.46-9.55 26.06-4.19 8.61 5.36 11.85 15.98 7.72 25.24l-65.44 146.6c-.58 1.29-.19 2.34.23 3 .42.65 1.23 1.43 2.64 1.43h54.96c13.79 0 25.98 7.76 31.83 20.24s4 26.82-4.83 37.41L197.69 472.73c-3.97 4.77-9.62 7.28-15.38 7.28Zm101.45-354.13L169.1 263.49c-.85 1.02-1 2.15-.43 3.35.56 1.2 1.52 1.81 2.85 1.81h54.96c11.96 0 22.98 5.99 29.49 16.02s7.48 22.54 2.61 33.46l-30.35 67.98 114.67-137.6c.85-1.02 1-2.15.43-3.35s-1.52-1.81-2.85-1.81h-54.96c-11.96 0-22.98-5.99-29.49-16.02s-7.48-22.54-2.61-33.46l30.35-67.99Z\"\n />\n </svg>\n </button>\n </div>\n }\n <div class=\"tab-content\" [class.is-mobile]=\"isMobile\">\n <fieldset\n class=\"tab-pane\"\n [class.tab-active]=\"active === 'template'\"\n [class.is-mobile]=\"isMobile\"\n [disabled]=\"editorCollapsed()\"\n >\n <div class=\"buttons\" [class.show-copied]=\"showCopied()\">\n @if (!isMobile) {\n <button\n type=\"button\"\n class=\"btn-command\"\n title=\"Open in new tab\"\n aria-label=\"Open in new tab\"\n (click)=\"openTab()\"\n >\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\">\n <path\n d=\"M344.94 150.78l46.12 38L345 226.94v-25.38l-24.19.19c-19.93.16-43.45 1.35-66.84 9a132.91 132.91 0 00-20.6 8.6c1.13-1.56 2.32-3.11 3.57-4.63 13.37-16.27 39-36.14 85.18-38.4l22.83-1.11v-24.43M329.09 109a8.33 8.33 0 00-3.48.77 8.14 8.14 0 00-4.67 7.38v35.15c-54.9 2.69-86 27-102.55 47.14-21.1 25.69-28.56 55.84-28.51 75.48a8.1 8.1 0 006 7.83 7.68 7.68 0 002.1.28 8.13 8.13 0 007.1-4.13c12.67-22.33 31.08-37.18 56.29-45.38 19.82-6.45 40.3-7.62 59.61-7.78v34.91a8 8 0 004.66 7.37 7.84 7.84 0 003.46.79 8.26 8.26 0 005.16-1.85l86.92-72a8.06 8.06 0 002.93-6.26 8.17 8.17 0 00-3-6.25l-86.9-71.66a8.11 8.11 0 00-5.15-1.84z\"\n />\n <path\n d=\"M397.23 399.39H114.94a26.89 26.89 0 01-26.86-26.86V204.26a26.89 26.89 0 0126.86-26.86h70.49a12 12 0 010 24h-70.49a2.9 2.9 0 00-2.86 2.86v168.27a2.9 2.9 0 002.86 2.86h282.29a2.9 2.9 0 002.85-2.86V253.67a12 12 0 0124 0v118.86a26.88 26.88 0 01-26.85 26.86z\"\n />\n </svg>\n </button>\n }\n @if (allowCopy) {\n <button\n type=\"button\"\n class=\"btn-command\"\n title=\"Copy template as URL\"\n aria-label=\"Copy template as URL\"\n (click)=\"createLink()\"\n >\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\">\n <path\n d=\"M333.56,88.16a90,90,0,0,0-62.83,25.39l-.13.12-27,26.82a12,12,0,0,0,16.92,17l26.92-26.76a66.44,66.44,0,0,1,94,93.94l-47,47a67.6,67.6,0,0,1-7.19,6.23,66.44,66.44,0,0,1-93-13.41A12,12,0,0,0,215,278.88a89.88,89.88,0,0,0,59.52,35.34,91.93,91.93,0,0,0,13.1.94,89.77,89.77,0,0,0,54-18,90.87,90.87,0,0,0,9.79-8.48l47.07-47.07.14-.15A90.44,90.44,0,0,0,333.56,88.16Z\"\n />\n <path\n d=\"M251.28,354.51l-26.75,26.75a66.44,66.44,0,0,1-93.95-93.95l47-47a68.76,68.76,0,0,1,7.19-6.23,66.53,66.53,0,0,1,93,13.41A12,12,0,0,0,297,233.12a90.5,90.5,0,0,0-136.39-9.77l-47.06,47.07-.15.15A90.44,90.44,0,0,0,241.28,398.45a.93.93,0,0,0,.14-.14l26.83-26.83a12,12,0,0,0-17-17Z\"\n />\n </svg>\n </button>\n }\n @if (allowCopy) {\n <button\n type=\"button\"\n class=\"btn-command\"\n title=\"Copy template\"\n aria-label=\"Copy template\"\n (click)=\"copyTemplate()\"\n >\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\">\n <path\n d=\"M380.8,197.2H240.4a43.25,43.25,0,0,0-43.2,43.2V380.8A43.25,43.25,0,0,0,240.4,424H380.8A43.25,43.25,0,0,0,424,380.8V240.4A43.25,43.25,0,0,0,380.8,197.2ZM400,380.8A19.22,19.22,0,0,1,380.8,400H240.4a19.22,19.22,0,0,1-19.2-19.2V240.4a19.22,19.22,0,0,1,19.2-19.2H380.8A19.22,19.22,0,0,1,400,240.4Z\"\n />\n <path\n d=\"M146.8,290.8H131.2A19.22,19.22,0,0,1,112,271.6V131.2A19.22,19.22,0,0,1,131.2,112H271.6a19.22,19.22,0,0,1,19.2,19.2v15.6a12,12,0,0,0,24,0V131.2A43.25,43.25,0,0,0,271.6,88H131.2A43.25,43.25,0,0,0,88,131.2V271.6a43.25,43.25,0,0,0,43.2,43.2h15.6a12,12,0,0,0,0-24Z\"\n />\n </svg>\n </button>\n }\n <div class=\"copied\" role=\"tooltip\">copied</div>\n </div>\n <div #codeTemplate class=\"codeflask-editor\"></div>\n </fieldset>\n <fieldset\n class=\"tab-pane\"\n [class.tab-active]=\"active === 'typescript'\"\n [class.is-mobile]=\"isMobile\"\n [disabled]=\"editorCollapsed()\"\n >\n <div class=\"buttons\" [class.show-copied]=\"showCopied()\">\n <span class=\"readonly-label\">read-only</span>\n @if (allowCopy) {\n <button\n type=\"button\"\n class=\"btn-command\"\n title=\"Copy code\"\n aria-label=\"Copy code\"\n (click)=\"copyCode()\"\n >\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\">\n <path\n d=\"M380.8,197.2H240.4a43.25,43.25,0,0,0-43.2,43.2V380.8A43.25,43.25,0,0,0,240.4,424H380.8A43.25,43.25,0,0,0,424,380.8V240.4A43.25,43.25,0,0,0,380.8,197.2ZM400,380.8A19.22,19.22,0,0,1,380.8,400H240.4a19.22,19.22,0,0,1-19.2-19.2V240.4a19.22,19.22,0,0,1,19.2-19.2H380.8A19.22,19.22,0,0,1,400,240.4Z\"\n />\n <path\n d=\"M146.8,290.8H131.2A19.22,19.22,0,0,1,112,271.6V131.2A19.22,19.22,0,0,1,131.2,112H271.6a19.22,19.22,0,0,1,19.2,19.2v15.6a12,12,0,0,0,24,0V131.2A43.25,43.25,0,0,0,271.6,88H131.2A43.25,43.25,0,0,0,88,131.2V271.6a43.25,43.25,0,0,0,43.2,43.2h15.6a12,12,0,0,0,0-24Z\"\n />\n </svg>\n </button>\n }\n <div class=\"copied\" role=\"tooltip\">copied</div>\n </div>\n <fieldset #codeTypescript class=\"codeflask-editor readonly\"></fieldset>\n </fieldset>\n <fieldset\n class=\"tab-pane\"\n [class.tab-active]=\"active === 'react' || active === 'vue' || active === 'js'\"\n [class.is-mobile]=\"isMobile\"\n [disabled]=\"editorCollapsed()\"\n >\n <div class=\"buttons\" [class.show-copied]=\"showCopied()\">\n @if (allowCopy) {\n <button\n type=\"button\"\n class=\"btn-command\"\n title=\"Copy template as URL\"\n aria-label=\"Copy template as URL\"\n (click)=\"createLink()\"\n >\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\">\n <path\n d=\"M333.56,88.16a90,90,0,0,0-62.83,25.39l-.13.12-27,26.82a12,12,0,0,0,16.92,17l26.92-26.76a66.44,66.44,0,0,1,94,93.94l-47,47a67.6,67.6,0,0,1-7.19,6.23,66.44,66.44,0,0,1-93-13.41A12,12,0,0,0,215,278.88a89.88,89.88,0,0,0,59.52,35.34,91.93,91.93,0,0,0,13.1.94,89.77,89.77,0,0,0,54-18,90.87,90.87,0,0,0,9.79-8.48l47.07-47.07.14-.15A90.44,90.44,0,0,0,333.56,88.16Z\"\n />\n <path\n d=\"M251.28,354.51l-26.75,26.75a66.44,66.44,0,0,1-93.95-93.95l47-47a68.76,68.76,0,0,1,7.19-6.23,66.53,66.53,0,0,1,93,13.41A12,12,0,0,0,297,233.12a90.5,90.5,0,0,0-136.39-9.77l-47.06,47.07-.15.15A90.44,90.44,0,0,0,241.28,398.45a.93.93,0,0,0,.14-.14l26.83-26.83a12,12,0,0,0-17-17Z\"\n />\n </svg>\n </button>\n }\n @if (allowCopy) {\n <button\n type=\"button\"\n class=\"btn-command\"\n title=\"Copy code\"\n aria-label=\"Copy code\"\n (click)=\"copyCode()\"\n >\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\">\n <path\n d=\"M380.8,197.2H240.4a43.25,43.25,0,0,0-43.2,43.2V380.8A43.25,43.25,0,0,0,240.4,424H380.8A43.25,43.25,0,0,0,424,380.8V240.4A43.25,43.25,0,0,0,380.8,197.2ZM400,380.8A19.22,19.22,0,0,1,380.8,400H240.4a19.22,19.22,0,0,1-19.2-19.2V240.4a19.22,19.22,0,0,1,19.2-19.2H380.8A19.22,19.22,0,0,1,400,240.4Z\"\n />\n <path\n d=\"M146.8,290.8H131.2A19.22,19.22,0,0,1,112,271.6V131.2A19.22,19.22,0,0,1,131.2,112H271.6a19.22,19.22,0,0,1,19.2,19.2v15.6a12,12,0,0,0,24,0V131.2A43.25,43.25,0,0,0,271.6,88H131.2A43.25,43.25,0,0,0,88,131.2V271.6a43.25,43.25,0,0,0,43.2,43.2h15.6a12,12,0,0,0,0-24Z\"\n />\n </svg>\n </button>\n }\n <div class=\"copied\" role=\"tooltip\">copied</div>\n </div>\n <label for=\"reactVueEditor\">React and Vue code editor</label>\n <fieldset #codeReactVue class=\"codeflask-editor\"></fieldset>\n </fieldset>\n <div class=\"console\" [hidden]=\"!state.renderingError() && !state.logMessages().length\">\n <div class=\"buttons\">\n @if (state.logMessages().length) {\n <button\n type=\"button\"\n class=\"btn-command btn-clear\"\n title=\"Clear log\"\n aria-label=\"Clear log\"\n (click)=\"logClear()\"\n >\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\">\n <path\n d=\"M400,144H328V132a44.05,44.05,0,0,0-44-44H228a44.05,44.05,0,0,0-44,44v12H112a12,12,0,0,0,0,24h20V380a44.05,44.05,0,0,0,44,44H336a44.05,44.05,0,0,0,44-44V168h20a12,12,0,0,0,0-24ZM208,132a20,20,0,0,1,20-20h56a20,20,0,0,1,20,20v12H208ZM356,380a20,20,0,0,1-20,20H176a20,20,0,0,1-20-20V168H356Z\"\n />\n <path d=\"M224,344a12,12,0,0,0,12-12V236a12,12,0,0,0-24,0v96A12,12,0,0,0,224,344Z\" />\n <path d=\"M288,344a12,12,0,0,0,12-12V236a12,12,0,0,0-24,0v96A12,12,0,0,0,288,344Z\" />\n </svg>\n </button>\n }\n </div>\n <div #consoleContainer class=\"scroller\">\n @if (state.renderingError()) {\n <pre class=\"alert-danger\"><code class=\"bg-none\">{{ renderingErrorMessage() }}</code></pre>\n }\n @if (!state.renderingError() && state.logMessages().length) {\n <ul>\n @for (msg of state.logMessages(); track $index) {\n <li>{{ msg }}</li>\n }\n </ul>\n }\n </div>\n </div>\n </div>\n</div>\n", styles: [".lp-tabs{display:flex;flex-wrap:wrap;padding-inline-start:0;margin:0;list-style:none;background:none;inline-size:inherit;font-weight:700}.lp-tabs .tab-item:focus-visible{outline-offset:calc(-1 * var(--element-button-focus-width))}.lp-tabs .tab-item.tab-active.tab-link{color:var(--si-sys-color-text-accent);border-block-end-color:var(--si-sys-color-text-accent)!important}.lp-tabs .tab-item.tab-active.tab-link:hover{color:var(--si-sys-color-text-accent-hover)}.lp-tabs .tab-item.tab-link{font:inherit;background:none;min-inline-size:150px;display:block;padding-block:8px;padding-inline:15px;cursor:pointer;text-align:start;line-height:20px;color:var(--si-sys-color-text-primary);border:0;border-block-end:4px solid transparent}.lp-tabs .tab-item.tab-link:hover{text-decoration:none;color:var(--si-sys-color-text-accent-hover);border-block-end-color:var(--si-sys-color-border-4)}*:focus-visible{outline:var(--element-button-focus-width) solid var(--si-sys-color-effects-focus);outline-offset:var(--element-button-focus-overlay-width)}:host{flex:1 1 auto;display:flex;flex-direction:column;overflow:hidden}:host.is-mobile{flex-direction:row}:host.editor-fullscreen{inline-size:100%}:host.editor-fullscreen ::ng-deep .ticket-links{position:absolute;inset-inline-end:48px;inset-block-start:13px}[hidden]{display:none!important}.example{flex:1 1 auto;background:var(--si-sys-color-background-0);margin:0;position:relative;display:flex;flex-direction:column}.example.is-mobile{order:2;flex:unset}.example.fullscreen{padding:0;block-size:100%;inline-size:100%}.example.fullscreen:after{content:unset}.example .btn-command{padding-block:4px;padding-inline:10px}.example .buttons{inset-inline-end:0}.preview-iframe{display:flex;flex:1}.preview-iframe.is-mobile{flex:1 0 0;min-block-size:0;overflow-y:auto;overflow-x:hidden;padding-block:0;padding-inline:30px;flex-direction:column}.collapse-wrapper{display:flex;min-block-size:40px}.lp-tabs{justify-content:flex-start;inline-size:100%;border-block-end:0}.collapse-button{display:flex;justify-content:flex-start;align-items:center;inline-size:100%}.collapse-button button{background-color:transparent;border:0;padding:6px;margin-inline-start:-16px;block-size:34px}.collapse-button button>svg{block-size:20px;fill:var(--si-sys-color-text-primary)}.collapse-button button:hover,.collapse-button button:focus,.collapse-button button:active{color:var(--si-sys-color-text-accent-hover)}.collapse-button button:hover>svg,.collapse-button button:focus>svg,.collapse-button button:active>svg{fill:currentColor}.code{position:relative;background-color:var(--si-sys-color-background-0);max-block-size:414px;transition:max-block-size .5s}.code.is-collapsed{max-block-size:41px;overflow:hidden;background-color:var(--si-sys-color-background-0);border-block-start:1px solid var(--si-sys-color-border-4)}.code.is-collapsed .collapse-icon{transform:rotate(180deg)}.code .console{block-size:68px;position:relative;border-block-start:1px solid var(--si-sys-color-border-4);color:var(--si-sys-color-text-primary)}.code .console .scroller{block-size:100%;overflow:auto;position:absolute;inset:0}.code .console pre{block-size:100%;border:0;margin:0;overflow:auto}.code .console pre.alert-danger{color:var(--si-sys-color-text-on-danger);background-color:var(--si-sys-color-background-danger)}.code .console code.bg-none{background:none}.code .console ul{list-style:none;margin:0;padding:5px;font-family:Menlo,Ubuntu Mono,Liberation Mono,Consolas,Courier,monospace}.code .console .btn-clear:hover{color:var(--si-sys-color-text-on-danger)}.code.is-mobile{order:1;flex:1;display:flex;flex-direction:column;max-block-size:unset;transition:unset}.code.is-mobile .console{border-inline-end:1px solid var(--si-sys-color-border-4)}pre{border-radius:0}.tab-content{display:flex;flex-direction:column}.tab-content.is-mobile{border-inline-end:1px solid var(--si-sys-color-border-4);flex:1}.tab-content:not(.is-mobile){block-size:305px}.tab-pane{flex:1;display:none;position:relative}.tab-pane.tab-active{display:flex;flex-direction:column}fieldset{padding:0;margin:0;border:0}.buttons{position:absolute;z-index:100;inset-inline-end:16px;display:flex;align-items:center;inset-block-start:0;block-size:40px}.is-mobile .buttons{inset-inline-end:0}.btn-command{background-color:transparent;border:0;color:var(--si-sys-color-text-primary);padding:8px;font-size:20px;line-height:1;block-size:34px}.btn-command>svg{block-size:20px;fill:currentColor;vertical-align:unset!important}.btn-command:hover,.btn-command:focus,.btn-command:active{color:var(--si-sys-color-text-accent-hover)}.btn-command.fullscreen{font-size:30px;padding:4px}.btn-command.alert svg,.btn-command.info svg{border-radius:50%;fill:currentColor}.btn-command.alert svg{background-color:var(--si-sys-color-background-danger);color:var(--si-sys-color-text-on-danger)}.btn-command.info svg{background-color:var(--si-sys-color-background-accent-secondary);color:var(--si-sys-color-text-accent)}.rtl-selection,.rfs-selection,.locale-selection{font-size:14px}.copied,.readonly-label{font-size:12px;padding-block:2px;padding-inline:5px;border-radius:3px}.copied{display:none;color:var(--si-sys-color-background-0);background:var(--si-sys-color-text-primary);margin-inline-end:10px;margin-block-start:12px}.show-copied .copied{display:block!important}.readonly-label{color:var(--si-sys-color-text-primary);border:1px solid var(--si-sys-color-text-primary)}.show-copied>*{display:none}.codeflask-editor{flex:1;position:relative;border-block-start:1px solid var(--si-sys-color-border-4)}.codeflask-editor ::ng-deep textarea{box-shadow:none}.progress-container{position:absolute;inset:0;pointer-events:none}.progress-container,.progress-container .progress-inner{display:flex;justify-content:center;align-items:center}.progress-container .progress-inner{inline-size:64px;block-size:40px;background:#fffc;border:1px solid #ddd;border-radius:12px}.progress-dots:before,.progress-dots:after,.progress-dots{inline-size:10px;block-size:10px;border-radius:50%;background-color:#ddd;animation:dot-flashing .6s infinite linear alternate}.progress-dots{position:relative;animation-delay:.3s}.progress-dots:before,.progress-dots:after{content:\"\";display:inline-block;position:absolute;inset-block-start:0}.progress-dots:before{inset-inline-start:-15px;animation-delay:0s}.progress-dots:after{inset-inline-start:15px;animation-delay:.6s}@keyframes dot-flashing{0%{background-color:#333}50%,to{background-color:#ddd}}\n", ":host ::ng-deep .readonly .codeflask{background-color:var(--si-sys-color-background-1)}:host ::ng-deep .codeflask{background-color:var(--si-sys-color-background-1)}:host ::ng-deep .codeflask pre,:host ::ng-deep .codeflask code{color:var(--si-sys-color-code-1);background:none;border:0;border-radius:0;text-align:start;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;tab-size:2;hyphens:none}:host ::ng-deep .codeflask code{padding:0}:host ::ng-deep .codeflask .codeflask__flatten,:host ::ng-deep .codeflask .codeflask__code{font-family:Menlo,Ubuntu Mono,Liberation Mono,Consolas,Courier,monospace;line-height:20px}:host ::ng-deep .codeflask .codeflask__flatten{min-inline-size:calc(100% - 40px);inline-size:auto}:host ::ng-deep .codeflask .codeflask__pre{z-index:0}:host ::ng-deep .codeflask .codeflask__textarea{z-index:1;color:transparent;caret-color:var(--si-sys-color-code-1)}:host ::ng-deep .codeflask.codeflask--has-line-numbers:before{background:var(--element-base-4)}:host ::ng-deep .codeflask__lines{color:var(--element-text-disabled)}:host ::ng-deep .namespace{opacity:.7}:host ::ng-deep .token.comment,:host ::ng-deep .token.prolog,:host ::ng-deep .token.doctype,:host ::ng-deep .token.cdata{color:var(--si-sys-color-code-8);font-style:italic}:host ::ng-deep .token.punctuation{color:var(--si-sys-color-code-9)}:host ::ng-deep .token.keyword,:host ::ng-deep .token.operator,:host ::ng-deep .token.boolean,:host ::ng-deep .token.symbol{color:var(--si-sys-color-code-2)}:host ::ng-deep .token.constant{color:var(--si-sys-color-code-3)}:host ::ng-deep .token.builtin{color:var(--si-sys-color-code-5)}:host ::ng-deep .token.property{color:var(--si-sys-color-code-4)}:host ::ng-deep .token.tag,:host ::ng-deep .token.selector{color:var(--si-sys-color-code-10)}:host ::ng-deep .token.number{color:var(--si-sys-color-code-7)}:host ::ng-deep .token.attr-name{color:var(--si-sys-color-code-3)}:host ::ng-deep .token.attr-value{color:var(--si-sys-color-code-6)}:host ::ng-deep .token.string,:host ::ng-deep .token.char{color:var(--si-sys-color-code-6)}:host ::ng-deep .token.function{color:var(--si-sys-color-code-5)}:host ::ng-deep .token.class-name{color:var(--si-sys-color-code-11)}:host ::ng-deep .token.important,:host ::ng-deep .token.variable{color:var(--si-sys-color-code-4)}:host ::ng-deep .token.regex{color:var(--si-sys-color-code-6)}:host ::ng-deep .token.important,:host ::ng-deep .token.bold{font-weight:600}:host ::ng-deep .token.italic{font-style:italic}:host ::ng-deep .token.entity{cursor:help}:host ::ng-deep .token.inserted{color:var(--si-sys-color-code-12)}:host ::ng-deep .token.deleted{color:var(--si-sys-color-code-11)}\n"], dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i1.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i1.SelectControlValueAccessor, selector: "select:not([multiple]):not([ngNoCva])[formControlName],select:not([multiple]):not([ngNoCva])[formControl],select:not([multiple]):not([ngNoCva])[ngModel]", inputs: ["compareWith"] }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: SiLivePreviewIframeComponent, selector: "si-live-preview-iframe", inputs: ["isFullscreen"], outputs: ["templateFromComponent"] }, { kind: "directive", type: SiStackblitzButtonDirective, selector: "button[siStackblitz]", inputs: ["framework", "baseUrl", "example"] }, { kind: "pipe", type: KeyValuePipe, name: "keyvalue" }], changeDetection: i0.ChangeDetectionStrategy.Eager });
1426
- }
1427
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiLivePreviewComponent, decorators: [{
1428
- type: Component,
1429
- args: [{ selector: 'si-live-preview', imports: [KeyValuePipe, FormsModule, SiLivePreviewIframeComponent, SiStackblitzButtonDirective], changeDetection: ChangeDetectionStrategy.Eager, host: {
1430
- '[class.editor-fullscreen]': 'isFullscreen()',
1431
- '[class.is-mobile]': 'isMobile',
1432
- '(document:fullscreenchange)': 'onFullscreenChange()',
1433
- '(document:webkitfullscreenchange)': 'onFullscreenChange()'
1434
- }, template: "@let active = activeTab();\n<div class=\"example\" [class.fullscreen]=\"exampleFullscreen()\" [class.is-mobile]=\"isMobile\">\n <div class=\"preview-iframe\" [class.is-mobile]=\"isMobile\">\n <si-live-preview-iframe\n [isFullscreen]=\"isFullscreen()\"\n (templateFromComponent)=\"templateFromComponent($event)\"\n />\n @if (state.inProgress()) {\n <div class=\"progress-container\">\n <div class=\"progress-inner\">\n <div class=\"progress-dots\"></div>\n </div>\n </div>\n }\n @if (isFullscreen()) {\n <div class=\"buttons\">\n <button\n type=\"button\"\n class=\"btn-command fullscreen\"\n title=\"Close fullscreen\"\n aria-label=\"Close fullscreen\"\n (click)=\"toggleFullscreen(true)\"\n >\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\">\n <path\n d=\"M273,256l87.52-87.51a12,12,0,0,0-17-17L256,239l-87.51-87.52a12,12,0,0,0-17,17L239,256l-87.52,87.51a12,12,0,0,0,17,17L256,273l87.51,87.52a12,12,0,0,0,17-17Z\"\n />\n </svg>\n </button>\n </div>\n }\n </div>\n</div>\n\n<div class=\"code\" [class.is-mobile]=\"isMobile\" [class.is-collapsed]=\"editorCollapsed()\">\n <div class=\"collapse-wrapper\">\n <div role=\"tablist\" class=\"nav lp-tabs\">\n @if (showEditor() && (active === 'template' || active === 'typescript')) {\n <button\n type=\"button\"\n role=\"tab\"\n class=\"tab-item tab-link focus-inside\"\n id=\"templateEditorTab\"\n [class.tab-active]=\"active === 'template'\"\n (click)=\"activateTab('template')\"\n >\n Template\n </button>\n <button\n type=\"button\"\n role=\"tab\"\n class=\"tab-item tab-link focus-inside\"\n id=\"typescriptEditorTab\"\n [class.tab-active]=\"active === 'typescript'\"\n (click)=\"activateTab('typescript')\"\n >\n Typescript\n </button>\n }\n </div>\n @if (!isMobile) {\n <div class=\"collapse-button\" [class.is-collapsed]=\"editorCollapsed()\">\n <button\n type=\"button\"\n [attr.title]=\"editorCollapsed() ? 'Show editor' : 'Hide editor'\"\n [attr.aria-label]=\"editorCollapsed() ? 'Show editor' : 'Hide editor'\"\n (click)=\"toggleCollapse()\"\n >\n <svg class=\"collapse-icon\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\">\n <path\n class=\"cls-1\"\n d=\"M248.93,277.23l-1.72-1.44-110-110a12.43,12.43,0,0,1,15.86-19l1.72,1.44L256,249.41l101.21-101.2a12.45,12.45,0,0,1,15.86-1.44l1.72,1.44a12.45,12.45,0,0,1,1.44,15.86l-1.44,1.72-110,110A12.45,12.45,0,0,1,248.93,277.23Z\"\n />\n <path\n class=\"cls-1\"\n d=\"M248.93,365.23l-1.72-1.44-88-88a12.43,12.43,0,0,1,15.86-19l1.72,1.44L256,337.41l79.21-79.2a12.45,12.45,0,0,1,15.86-1.44l1.72,1.44a12.45,12.45,0,0,1,1.44,15.86l-1.44,1.72-88,88A12.45,12.45,0,0,1,248.93,365.23Z\"\n />\n </svg>\n </button>\n </div>\n }\n </div>\n\n @if (allowFullscreen && !isFullscreen()) {\n <div class=\"buttons\">\n @if (webcomponents && showEditor() && frameworks.size > 1) {\n <select\n aria-label=\"Select framework\"\n class=\"btn-command locale-selection\"\n [ngModel]=\"state.framework()\"\n (ngModelChange)=\"changeFramework($event)\"\n >\n @for (aFramework of frameworks | keyvalue; track $index) {\n <option [value]=\"aFramework.value\" [selected]=\"state.framework() === aFramework.value\">\n {{ aFramework.key }}\n </option>\n }\n </select>\n }\n @if (rootFontSizes.length) {\n <select\n name=\"selectRfs\"\n aria-label=\"Root font size\"\n title=\"Root font size\"\n class=\"btn-command rfs-selection\"\n [ngModel]=\"state.rootFontSize()\"\n (ngModelChange)=\"rfsSelectionChanges($event)\"\n >\n <option value=\"0\">none</option>\n <option value=\"initial\">initial</option>\n @for (rfs of rootFontSizes; track rfs) {\n <option [value]=\"rfs\">{{ rfs }}px</option>\n }\n </select>\n }\n @if (!!localeApi && showEditor()) {\n <select\n name=\"selectLocale\"\n aria-label=\"Select locale\"\n title=\"Locale\"\n class=\"btn-command locale-selection\"\n (change)=\"localeSelectionChanged($event.target)\"\n >\n @for (aLocale of availableLocales; track $index) {\n <option [value]=\"aLocale\" [selected]=\"state.locale() === aLocale\">\n {{ aLocale }}\n </option>\n }\n </select>\n }\n @if (rtlSwitcher) {\n <button\n type=\"button\"\n class=\"btn-command rtl-selection\"\n [title]=\"state.isRTL() ? 'Right-to-left layout' : 'Left-to-right layout'\"\n [attr.aria-label]=\"state.isRTL() ? 'Right-to-left layout' : 'Left-to-right layout'\"\n (click)=\"toggleRTL()\"\n >\n {{ state.isRTL() ? 'RTL' : 'LTR' }}\n </button>\n }\n @if (\n !isMobile &&\n !showEditor() &&\n (state.renderingError() || (state.logMessages().length && state.newMessages()))\n ) {\n <button\n type=\"button\"\n class=\"btn-command\"\n title=\"Show console\"\n aria-label=\"Show console\"\n [class.alert]=\"state.renderingError()\"\n [class.info]=\"state.logMessages().length\"\n (click)=\"toggleCollapse()\"\n >\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\">\n <path\n d=\"M255.84,296a12,12,0,0,1-12-12V124a12,12,0,1,1,24,0V284A12,12,0,0,1,255.84,296Z\"\n />\n <path d=\"M256.12,387.81h-.24a16,16,0,0,1,0-32h.24a16,16,0,0,1,0,32Z\" />\n </svg>\n </button>\n }\n @if (switcherEnabled && !isMobile) {\n <button\n type=\"button\"\n class=\"btn-command\"\n title=\"Toggle theme\"\n aria-label=\"Toggle theme\"\n (click)=\"toggleTheme()\"\n >\n @if (state.theme() === 'dark') {\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\">\n <path\n d=\"M256,349.82A93.82,93.82,0,1,0,162.18,256,93.93,93.93,0,0,0,256,349.82Zm0-163.64A69.82,69.82,0,1,1,186.18,256,69.9,69.9,0,0,1,256,186.18Z\"\n />\n <path\n d=\"M256,120.73a12,12,0,0,0,12-12V76a12,12,0,0,0-24,0v32.73A12,12,0,0,0,256,120.73Z\"\n />\n <path d=\"M268,436V403.27a12,12,0,0,0-24,0V436a12,12,0,0,0,24,0Z\" />\n <path d=\"M143.44,160.41a12,12,0,1,0,17-17l-23.23-23.23a12,12,0,1,0-17,17Z\" />\n <path\n d=\"M351.59,351.59a12,12,0,0,0,0,17l23.23,23.23a12,12,0,0,0,17-17l-23.23-23.23A12,12,0,0,0,351.59,351.59Z\"\n />\n <path\n d=\"M120.73,256a12,12,0,0,0-12-12H76a12,12,0,0,0,0,24h32.73A12,12,0,0,0,120.73,256Z\"\n />\n <path d=\"M436,244H403.27a12,12,0,0,0,0,24H436a12,12,0,0,0,0-24Z\" />\n <path\n d=\"M137.18,391.79l23.23-23.23a12,12,0,1,0-17-17l-23.23,23.23a12,12,0,1,0,17,17Z\"\n />\n <path\n d=\"M360.07,163.93a12,12,0,0,0,8.49-3.52l23.23-23.23a12,12,0,1,0-17-17l-23.23,23.23a12,12,0,0,0,8.48,20.49Z\"\n />\n </svg>\n } @else {\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\">\n <path\n d=\"M360.07,147.88a12,12,0,0,0,5.89-21.1,168.05,168.05,0,0,0-214.71,0C80,186,70.19,292.1,129.38,363.35a166.9,166.9,0,0,0,113.77,59.93q7.9.74,15.75.73A166.74,166.74,0,0,0,366,385.22a12,12,0,0,0-5.89-21.1,109.33,109.33,0,0,1,0-216.24ZM244.43,275.77A133.48,133.48,0,0,0,330,381.08,144.11,144.11,0,0,1,147.84,348C97.1,287,105.51,196,166.58,145.24A144.08,144.08,0,0,1,330,130.94C272,152.38,234.91,212.29,244.43,275.77Z\"\n />\n </svg>\n }\n </button>\n }\n @if (!isMobile && showEditor()) {\n <button\n type=\"button\"\n class=\"btn-command\"\n title=\"Example fullscreen\"\n aria-label=\"Example fullscreen\"\n (click)=\"toggleFullscreen(true)\"\n >\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\">\n <path\n d=\"M406,112H106a42,42,0,0,0-42,42V358a42,42,0,0,0,42,42H406a42,42,0,0,0,42-42V154A42,42,0,0,0,406,112Zm18,246a18,18,0,0,1-18,18H106a18,18,0,0,1-18-18V154a18,18,0,0,1,18-18H406a18,18,0,0,1,18,18Z\"\n />\n </svg>\n </button>\n }\n @if (showEditor()) {\n <button\n type=\"button\"\n class=\"btn-command\"\n title=\"Editor + Example fullscreen\"\n aria-label=\"Editor + Example fullscreen\"\n (click)=\"toggleFullscreen()\"\n >\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\">\n <path\n d=\"M406,112H106a42,42,0,0,0-42,42V358a42,42,0,0,0,42,42H406a42,42,0,0,0,42-42V154A42,42,0,0,0,406,112Zm18,42V313.44H199.35V136H406A18,18,0,0,1,424,154ZM88,358V154a18,18,0,0,1,18-18h69.35V376H106A18,18,0,0,1,88,358Zm318,18H199.35V337.44H424V358A18,18,0,0,1,406,376Z\"\n />\n </svg>\n </button>\n }\n <button\n siStackblitz\n class=\"btn-command\"\n type=\"button\"\n [baseUrl]=\"baseUrl\"\n [framework]=\"state.framework()\"\n [example]=\"state.example()\"\n >\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\">\n <path\n d=\"M182.32 480.02c-3.65 0-7.34-1.01-10.68-3.09-8.61-5.36-11.86-15.98-7.72-25.24s65.44-146.6 65.44-146.6c.58-1.29.19-2.34-.23-3-.42-.65-1.23-1.43-2.64-1.43h-54.96c-13.79 0-25.98-7.76-31.83-20.24s-4-26.82 4.83-37.41L314.3 39.26c6.5-7.79 17.46-9.55 26.06-4.19 8.61 5.36 11.85 15.98 7.72 25.24l-65.44 146.6c-.58 1.29-.19 2.34.23 3 .42.65 1.23 1.43 2.64 1.43h54.96c13.79 0 25.98 7.76 31.83 20.24s4 26.82-4.83 37.41L197.69 472.73c-3.97 4.77-9.62 7.28-15.38 7.28Zm101.45-354.13L169.1 263.49c-.85 1.02-1 2.15-.43 3.35.56 1.2 1.52 1.81 2.85 1.81h54.96c11.96 0 22.98 5.99 29.49 16.02s7.48 22.54 2.61 33.46l-30.35 67.98 114.67-137.6c.85-1.02 1-2.15.43-3.35s-1.52-1.81-2.85-1.81h-54.96c-11.96 0-22.98-5.99-29.49-16.02s-7.48-22.54-2.61-33.46l30.35-67.99Z\"\n />\n </svg>\n </button>\n </div>\n }\n <div class=\"tab-content\" [class.is-mobile]=\"isMobile\">\n <fieldset\n class=\"tab-pane\"\n [class.tab-active]=\"active === 'template'\"\n [class.is-mobile]=\"isMobile\"\n [disabled]=\"editorCollapsed()\"\n >\n <div class=\"buttons\" [class.show-copied]=\"showCopied()\">\n @if (!isMobile) {\n <button\n type=\"button\"\n class=\"btn-command\"\n title=\"Open in new tab\"\n aria-label=\"Open in new tab\"\n (click)=\"openTab()\"\n >\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\">\n <path\n d=\"M344.94 150.78l46.12 38L345 226.94v-25.38l-24.19.19c-19.93.16-43.45 1.35-66.84 9a132.91 132.91 0 00-20.6 8.6c1.13-1.56 2.32-3.11 3.57-4.63 13.37-16.27 39-36.14 85.18-38.4l22.83-1.11v-24.43M329.09 109a8.33 8.33 0 00-3.48.77 8.14 8.14 0 00-4.67 7.38v35.15c-54.9 2.69-86 27-102.55 47.14-21.1 25.69-28.56 55.84-28.51 75.48a8.1 8.1 0 006 7.83 7.68 7.68 0 002.1.28 8.13 8.13 0 007.1-4.13c12.67-22.33 31.08-37.18 56.29-45.38 19.82-6.45 40.3-7.62 59.61-7.78v34.91a8 8 0 004.66 7.37 7.84 7.84 0 003.46.79 8.26 8.26 0 005.16-1.85l86.92-72a8.06 8.06 0 002.93-6.26 8.17 8.17 0 00-3-6.25l-86.9-71.66a8.11 8.11 0 00-5.15-1.84z\"\n />\n <path\n d=\"M397.23 399.39H114.94a26.89 26.89 0 01-26.86-26.86V204.26a26.89 26.89 0 0126.86-26.86h70.49a12 12 0 010 24h-70.49a2.9 2.9 0 00-2.86 2.86v168.27a2.9 2.9 0 002.86 2.86h282.29a2.9 2.9 0 002.85-2.86V253.67a12 12 0 0124 0v118.86a26.88 26.88 0 01-26.85 26.86z\"\n />\n </svg>\n </button>\n }\n @if (allowCopy) {\n <button\n type=\"button\"\n class=\"btn-command\"\n title=\"Copy template as URL\"\n aria-label=\"Copy template as URL\"\n (click)=\"createLink()\"\n >\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\">\n <path\n d=\"M333.56,88.16a90,90,0,0,0-62.83,25.39l-.13.12-27,26.82a12,12,0,0,0,16.92,17l26.92-26.76a66.44,66.44,0,0,1,94,93.94l-47,47a67.6,67.6,0,0,1-7.19,6.23,66.44,66.44,0,0,1-93-13.41A12,12,0,0,0,215,278.88a89.88,89.88,0,0,0,59.52,35.34,91.93,91.93,0,0,0,13.1.94,89.77,89.77,0,0,0,54-18,90.87,90.87,0,0,0,9.79-8.48l47.07-47.07.14-.15A90.44,90.44,0,0,0,333.56,88.16Z\"\n />\n <path\n d=\"M251.28,354.51l-26.75,26.75a66.44,66.44,0,0,1-93.95-93.95l47-47a68.76,68.76,0,0,1,7.19-6.23,66.53,66.53,0,0,1,93,13.41A12,12,0,0,0,297,233.12a90.5,90.5,0,0,0-136.39-9.77l-47.06,47.07-.15.15A90.44,90.44,0,0,0,241.28,398.45a.93.93,0,0,0,.14-.14l26.83-26.83a12,12,0,0,0-17-17Z\"\n />\n </svg>\n </button>\n }\n @if (allowCopy) {\n <button\n type=\"button\"\n class=\"btn-command\"\n title=\"Copy template\"\n aria-label=\"Copy template\"\n (click)=\"copyTemplate()\"\n >\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\">\n <path\n d=\"M380.8,197.2H240.4a43.25,43.25,0,0,0-43.2,43.2V380.8A43.25,43.25,0,0,0,240.4,424H380.8A43.25,43.25,0,0,0,424,380.8V240.4A43.25,43.25,0,0,0,380.8,197.2ZM400,380.8A19.22,19.22,0,0,1,380.8,400H240.4a19.22,19.22,0,0,1-19.2-19.2V240.4a19.22,19.22,0,0,1,19.2-19.2H380.8A19.22,19.22,0,0,1,400,240.4Z\"\n />\n <path\n d=\"M146.8,290.8H131.2A19.22,19.22,0,0,1,112,271.6V131.2A19.22,19.22,0,0,1,131.2,112H271.6a19.22,19.22,0,0,1,19.2,19.2v15.6a12,12,0,0,0,24,0V131.2A43.25,43.25,0,0,0,271.6,88H131.2A43.25,43.25,0,0,0,88,131.2V271.6a43.25,43.25,0,0,0,43.2,43.2h15.6a12,12,0,0,0,0-24Z\"\n />\n </svg>\n </button>\n }\n <div class=\"copied\" role=\"tooltip\">copied</div>\n </div>\n <div #codeTemplate class=\"codeflask-editor\"></div>\n </fieldset>\n <fieldset\n class=\"tab-pane\"\n [class.tab-active]=\"active === 'typescript'\"\n [class.is-mobile]=\"isMobile\"\n [disabled]=\"editorCollapsed()\"\n >\n <div class=\"buttons\" [class.show-copied]=\"showCopied()\">\n <span class=\"readonly-label\">read-only</span>\n @if (allowCopy) {\n <button\n type=\"button\"\n class=\"btn-command\"\n title=\"Copy code\"\n aria-label=\"Copy code\"\n (click)=\"copyCode()\"\n >\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\">\n <path\n d=\"M380.8,197.2H240.4a43.25,43.25,0,0,0-43.2,43.2V380.8A43.25,43.25,0,0,0,240.4,424H380.8A43.25,43.25,0,0,0,424,380.8V240.4A43.25,43.25,0,0,0,380.8,197.2ZM400,380.8A19.22,19.22,0,0,1,380.8,400H240.4a19.22,19.22,0,0,1-19.2-19.2V240.4a19.22,19.22,0,0,1,19.2-19.2H380.8A19.22,19.22,0,0,1,400,240.4Z\"\n />\n <path\n d=\"M146.8,290.8H131.2A19.22,19.22,0,0,1,112,271.6V131.2A19.22,19.22,0,0,1,131.2,112H271.6a19.22,19.22,0,0,1,19.2,19.2v15.6a12,12,0,0,0,24,0V131.2A43.25,43.25,0,0,0,271.6,88H131.2A43.25,43.25,0,0,0,88,131.2V271.6a43.25,43.25,0,0,0,43.2,43.2h15.6a12,12,0,0,0,0-24Z\"\n />\n </svg>\n </button>\n }\n <div class=\"copied\" role=\"tooltip\">copied</div>\n </div>\n <fieldset #codeTypescript class=\"codeflask-editor readonly\"></fieldset>\n </fieldset>\n <fieldset\n class=\"tab-pane\"\n [class.tab-active]=\"active === 'react' || active === 'vue' || active === 'js'\"\n [class.is-mobile]=\"isMobile\"\n [disabled]=\"editorCollapsed()\"\n >\n <div class=\"buttons\" [class.show-copied]=\"showCopied()\">\n @if (allowCopy) {\n <button\n type=\"button\"\n class=\"btn-command\"\n title=\"Copy template as URL\"\n aria-label=\"Copy template as URL\"\n (click)=\"createLink()\"\n >\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\">\n <path\n d=\"M333.56,88.16a90,90,0,0,0-62.83,25.39l-.13.12-27,26.82a12,12,0,0,0,16.92,17l26.92-26.76a66.44,66.44,0,0,1,94,93.94l-47,47a67.6,67.6,0,0,1-7.19,6.23,66.44,66.44,0,0,1-93-13.41A12,12,0,0,0,215,278.88a89.88,89.88,0,0,0,59.52,35.34,91.93,91.93,0,0,0,13.1.94,89.77,89.77,0,0,0,54-18,90.87,90.87,0,0,0,9.79-8.48l47.07-47.07.14-.15A90.44,90.44,0,0,0,333.56,88.16Z\"\n />\n <path\n d=\"M251.28,354.51l-26.75,26.75a66.44,66.44,0,0,1-93.95-93.95l47-47a68.76,68.76,0,0,1,7.19-6.23,66.53,66.53,0,0,1,93,13.41A12,12,0,0,0,297,233.12a90.5,90.5,0,0,0-136.39-9.77l-47.06,47.07-.15.15A90.44,90.44,0,0,0,241.28,398.45a.93.93,0,0,0,.14-.14l26.83-26.83a12,12,0,0,0-17-17Z\"\n />\n </svg>\n </button>\n }\n @if (allowCopy) {\n <button\n type=\"button\"\n class=\"btn-command\"\n title=\"Copy code\"\n aria-label=\"Copy code\"\n (click)=\"copyCode()\"\n >\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\">\n <path\n d=\"M380.8,197.2H240.4a43.25,43.25,0,0,0-43.2,43.2V380.8A43.25,43.25,0,0,0,240.4,424H380.8A43.25,43.25,0,0,0,424,380.8V240.4A43.25,43.25,0,0,0,380.8,197.2ZM400,380.8A19.22,19.22,0,0,1,380.8,400H240.4a19.22,19.22,0,0,1-19.2-19.2V240.4a19.22,19.22,0,0,1,19.2-19.2H380.8A19.22,19.22,0,0,1,400,240.4Z\"\n />\n <path\n d=\"M146.8,290.8H131.2A19.22,19.22,0,0,1,112,271.6V131.2A19.22,19.22,0,0,1,131.2,112H271.6a19.22,19.22,0,0,1,19.2,19.2v15.6a12,12,0,0,0,24,0V131.2A43.25,43.25,0,0,0,271.6,88H131.2A43.25,43.25,0,0,0,88,131.2V271.6a43.25,43.25,0,0,0,43.2,43.2h15.6a12,12,0,0,0,0-24Z\"\n />\n </svg>\n </button>\n }\n <div class=\"copied\" role=\"tooltip\">copied</div>\n </div>\n <label for=\"reactVueEditor\">React and Vue code editor</label>\n <fieldset #codeReactVue class=\"codeflask-editor\"></fieldset>\n </fieldset>\n <div class=\"console\" [hidden]=\"!state.renderingError() && !state.logMessages().length\">\n <div class=\"buttons\">\n @if (state.logMessages().length) {\n <button\n type=\"button\"\n class=\"btn-command btn-clear\"\n title=\"Clear log\"\n aria-label=\"Clear log\"\n (click)=\"logClear()\"\n >\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\">\n <path\n d=\"M400,144H328V132a44.05,44.05,0,0,0-44-44H228a44.05,44.05,0,0,0-44,44v12H112a12,12,0,0,0,0,24h20V380a44.05,44.05,0,0,0,44,44H336a44.05,44.05,0,0,0,44-44V168h20a12,12,0,0,0,0-24ZM208,132a20,20,0,0,1,20-20h56a20,20,0,0,1,20,20v12H208ZM356,380a20,20,0,0,1-20,20H176a20,20,0,0,1-20-20V168H356Z\"\n />\n <path d=\"M224,344a12,12,0,0,0,12-12V236a12,12,0,0,0-24,0v96A12,12,0,0,0,224,344Z\" />\n <path d=\"M288,344a12,12,0,0,0,12-12V236a12,12,0,0,0-24,0v96A12,12,0,0,0,288,344Z\" />\n </svg>\n </button>\n }\n </div>\n <div #consoleContainer class=\"scroller\">\n @if (state.renderingError()) {\n <pre class=\"alert-danger\"><code class=\"bg-none\">{{ renderingErrorMessage() }}</code></pre>\n }\n @if (!state.renderingError() && state.logMessages().length) {\n <ul>\n @for (msg of state.logMessages(); track $index) {\n <li>{{ msg }}</li>\n }\n </ul>\n }\n </div>\n </div>\n </div>\n</div>\n", styles: [".lp-tabs{display:flex;flex-wrap:wrap;padding-inline-start:0;margin:0;list-style:none;background:none;inline-size:inherit;font-weight:700}.lp-tabs .tab-item:focus-visible{outline-offset:calc(-1 * var(--element-button-focus-width))}.lp-tabs .tab-item.tab-active.tab-link{color:var(--si-sys-color-text-accent);border-block-end-color:var(--si-sys-color-text-accent)!important}.lp-tabs .tab-item.tab-active.tab-link:hover{color:var(--si-sys-color-text-accent-hover)}.lp-tabs .tab-item.tab-link{font:inherit;background:none;min-inline-size:150px;display:block;padding-block:8px;padding-inline:15px;cursor:pointer;text-align:start;line-height:20px;color:var(--si-sys-color-text-primary);border:0;border-block-end:4px solid transparent}.lp-tabs .tab-item.tab-link:hover{text-decoration:none;color:var(--si-sys-color-text-accent-hover);border-block-end-color:var(--si-sys-color-border-4)}*:focus-visible{outline:var(--element-button-focus-width) solid var(--si-sys-color-effects-focus);outline-offset:var(--element-button-focus-overlay-width)}:host{flex:1 1 auto;display:flex;flex-direction:column;overflow:hidden}:host.is-mobile{flex-direction:row}:host.editor-fullscreen{inline-size:100%}:host.editor-fullscreen ::ng-deep .ticket-links{position:absolute;inset-inline-end:48px;inset-block-start:13px}[hidden]{display:none!important}.example{flex:1 1 auto;background:var(--si-sys-color-background-0);margin:0;position:relative;display:flex;flex-direction:column}.example.is-mobile{order:2;flex:unset}.example.fullscreen{padding:0;block-size:100%;inline-size:100%}.example.fullscreen:after{content:unset}.example .btn-command{padding-block:4px;padding-inline:10px}.example .buttons{inset-inline-end:0}.preview-iframe{display:flex;flex:1}.preview-iframe.is-mobile{flex:1 0 0;min-block-size:0;overflow-y:auto;overflow-x:hidden;padding-block:0;padding-inline:30px;flex-direction:column}.collapse-wrapper{display:flex;min-block-size:40px}.lp-tabs{justify-content:flex-start;inline-size:100%;border-block-end:0}.collapse-button{display:flex;justify-content:flex-start;align-items:center;inline-size:100%}.collapse-button button{background-color:transparent;border:0;padding:6px;margin-inline-start:-16px;block-size:34px}.collapse-button button>svg{block-size:20px;fill:var(--si-sys-color-text-primary)}.collapse-button button:hover,.collapse-button button:focus,.collapse-button button:active{color:var(--si-sys-color-text-accent-hover)}.collapse-button button:hover>svg,.collapse-button button:focus>svg,.collapse-button button:active>svg{fill:currentColor}.code{position:relative;background-color:var(--si-sys-color-background-0);max-block-size:414px;transition:max-block-size .5s}.code.is-collapsed{max-block-size:41px;overflow:hidden;background-color:var(--si-sys-color-background-0);border-block-start:1px solid var(--si-sys-color-border-4)}.code.is-collapsed .collapse-icon{transform:rotate(180deg)}.code .console{block-size:68px;position:relative;border-block-start:1px solid var(--si-sys-color-border-4);color:var(--si-sys-color-text-primary)}.code .console .scroller{block-size:100%;overflow:auto;position:absolute;inset:0}.code .console pre{block-size:100%;border:0;margin:0;overflow:auto}.code .console pre.alert-danger{color:var(--si-sys-color-text-on-danger);background-color:var(--si-sys-color-background-danger)}.code .console code.bg-none{background:none}.code .console ul{list-style:none;margin:0;padding:5px;font-family:Menlo,Ubuntu Mono,Liberation Mono,Consolas,Courier,monospace}.code .console .btn-clear:hover{color:var(--si-sys-color-text-on-danger)}.code.is-mobile{order:1;flex:1;display:flex;flex-direction:column;max-block-size:unset;transition:unset}.code.is-mobile .console{border-inline-end:1px solid var(--si-sys-color-border-4)}pre{border-radius:0}.tab-content{display:flex;flex-direction:column}.tab-content.is-mobile{border-inline-end:1px solid var(--si-sys-color-border-4);flex:1}.tab-content:not(.is-mobile){block-size:305px}.tab-pane{flex:1;display:none;position:relative}.tab-pane.tab-active{display:flex;flex-direction:column}fieldset{padding:0;margin:0;border:0}.buttons{position:absolute;z-index:100;inset-inline-end:16px;display:flex;align-items:center;inset-block-start:0;block-size:40px}.is-mobile .buttons{inset-inline-end:0}.btn-command{background-color:transparent;border:0;color:var(--si-sys-color-text-primary);padding:8px;font-size:20px;line-height:1;block-size:34px}.btn-command>svg{block-size:20px;fill:currentColor;vertical-align:unset!important}.btn-command:hover,.btn-command:focus,.btn-command:active{color:var(--si-sys-color-text-accent-hover)}.btn-command.fullscreen{font-size:30px;padding:4px}.btn-command.alert svg,.btn-command.info svg{border-radius:50%;fill:currentColor}.btn-command.alert svg{background-color:var(--si-sys-color-background-danger);color:var(--si-sys-color-text-on-danger)}.btn-command.info svg{background-color:var(--si-sys-color-background-accent-secondary);color:var(--si-sys-color-text-accent)}.rtl-selection,.rfs-selection,.locale-selection{font-size:14px}.copied,.readonly-label{font-size:12px;padding-block:2px;padding-inline:5px;border-radius:3px}.copied{display:none;color:var(--si-sys-color-background-0);background:var(--si-sys-color-text-primary);margin-inline-end:10px;margin-block-start:12px}.show-copied .copied{display:block!important}.readonly-label{color:var(--si-sys-color-text-primary);border:1px solid var(--si-sys-color-text-primary)}.show-copied>*{display:none}.codeflask-editor{flex:1;position:relative;border-block-start:1px solid var(--si-sys-color-border-4)}.codeflask-editor ::ng-deep textarea{box-shadow:none}.progress-container{position:absolute;inset:0;pointer-events:none}.progress-container,.progress-container .progress-inner{display:flex;justify-content:center;align-items:center}.progress-container .progress-inner{inline-size:64px;block-size:40px;background:#fffc;border:1px solid #ddd;border-radius:12px}.progress-dots:before,.progress-dots:after,.progress-dots{inline-size:10px;block-size:10px;border-radius:50%;background-color:#ddd;animation:dot-flashing .6s infinite linear alternate}.progress-dots{position:relative;animation-delay:.3s}.progress-dots:before,.progress-dots:after{content:\"\";display:inline-block;position:absolute;inset-block-start:0}.progress-dots:before{inset-inline-start:-15px;animation-delay:0s}.progress-dots:after{inset-inline-start:15px;animation-delay:.6s}@keyframes dot-flashing{0%{background-color:#333}50%,to{background-color:#ddd}}\n", ":host ::ng-deep .readonly .codeflask{background-color:var(--si-sys-color-background-1)}:host ::ng-deep .codeflask{background-color:var(--si-sys-color-background-1)}:host ::ng-deep .codeflask pre,:host ::ng-deep .codeflask code{color:var(--si-sys-color-code-1);background:none;border:0;border-radius:0;text-align:start;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;tab-size:2;hyphens:none}:host ::ng-deep .codeflask code{padding:0}:host ::ng-deep .codeflask .codeflask__flatten,:host ::ng-deep .codeflask .codeflask__code{font-family:Menlo,Ubuntu Mono,Liberation Mono,Consolas,Courier,monospace;line-height:20px}:host ::ng-deep .codeflask .codeflask__flatten{min-inline-size:calc(100% - 40px);inline-size:auto}:host ::ng-deep .codeflask .codeflask__pre{z-index:0}:host ::ng-deep .codeflask .codeflask__textarea{z-index:1;color:transparent;caret-color:var(--si-sys-color-code-1)}:host ::ng-deep .codeflask.codeflask--has-line-numbers:before{background:var(--element-base-4)}:host ::ng-deep .codeflask__lines{color:var(--element-text-disabled)}:host ::ng-deep .namespace{opacity:.7}:host ::ng-deep .token.comment,:host ::ng-deep .token.prolog,:host ::ng-deep .token.doctype,:host ::ng-deep .token.cdata{color:var(--si-sys-color-code-8);font-style:italic}:host ::ng-deep .token.punctuation{color:var(--si-sys-color-code-9)}:host ::ng-deep .token.keyword,:host ::ng-deep .token.operator,:host ::ng-deep .token.boolean,:host ::ng-deep .token.symbol{color:var(--si-sys-color-code-2)}:host ::ng-deep .token.constant{color:var(--si-sys-color-code-3)}:host ::ng-deep .token.builtin{color:var(--si-sys-color-code-5)}:host ::ng-deep .token.property{color:var(--si-sys-color-code-4)}:host ::ng-deep .token.tag,:host ::ng-deep .token.selector{color:var(--si-sys-color-code-10)}:host ::ng-deep .token.number{color:var(--si-sys-color-code-7)}:host ::ng-deep .token.attr-name{color:var(--si-sys-color-code-3)}:host ::ng-deep .token.attr-value{color:var(--si-sys-color-code-6)}:host ::ng-deep .token.string,:host ::ng-deep .token.char{color:var(--si-sys-color-code-6)}:host ::ng-deep .token.function{color:var(--si-sys-color-code-5)}:host ::ng-deep .token.class-name{color:var(--si-sys-color-code-11)}:host ::ng-deep .token.important,:host ::ng-deep .token.variable{color:var(--si-sys-color-code-4)}:host ::ng-deep .token.regex{color:var(--si-sys-color-code-6)}:host ::ng-deep .token.important,:host ::ng-deep .token.bold{font-weight:600}:host ::ng-deep .token.italic{font-style:italic}:host ::ng-deep .token.entity{cursor:help}:host ::ng-deep .token.inserted{color:var(--si-sys-color-code-12)}:host ::ng-deep .token.deleted{color:var(--si-sys-color-code-11)}\n"] }]
1435
- }], ctorParameters: () => [], propDecorators: { templateElem: [{ type: i0.ViewChild, args: ['codeTemplate', { isSignal: true }] }], typescriptElem: [{ type: i0.ViewChild, args: ['codeTypescript', { isSignal: true }] }], reactVueElem: [{ type: i0.ViewChild, args: ['codeReactVue', { isSignal: true }] }], consoleElem: [{ type: i0.ViewChild, args: ['consoleContainer', { isSignal: true }] }] } });
1436
-
1437
- /**
1438
- * Copyright (c) Siemens 2016 - 2026
1439
- * SPDX-License-Identifier: MIT
1440
- */
1441
- class SiExampleOverviewComponent {
1442
- route = inject(ActivatedRoute);
1443
- router = inject(Router);
1444
- title = inject(Title);
1445
- config = inject(SI_LIVE_PREVIEW_CONFIG);
1446
- internalConfig = inject(SI_LIVE_PREVIEW_INTERNALS);
1447
- componentList = [];
1448
- darkMediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
1449
- mediaQueryListener = () => this.toggleDark(this.darkMediaQuery.matches);
1450
- cdRef = inject(ChangeDetectorRef);
1451
- tree = [];
1452
- baseUrl = this.config.examplesBaseUrl;
1453
- isCollapsed = localStorage.getItem('si-live-preview-examples-collapsed') === 'true';
1454
- showContent = !this.isCollapsed;
1455
- searchControl = new UntypedFormControl();
1456
- ngOnInit() {
1457
- this.title.setTitle(this.internalConfig.titleBase);
1458
- this.componentList = this.config.componentLoader.list
1459
- .sort()
1460
- .map(component => component.replace(this.baseUrl, ''));
1461
- this.makeTree();
1462
- // Handle the filter query parameter
1463
- this.route.queryParams.subscribe(search => {
1464
- this.makeTree(search.q);
1465
- this.searchControl.setValue(search.q);
1466
- });
1467
- this.searchControl.valueChanges
1468
- .pipe(debounceTime(400), distinctUntilChanged())
1469
- .subscribe((search) => {
1470
- // Do navigation in place to set query param
1471
- this.router.navigate([], {
1472
- relativeTo: this.route,
1473
- queryParams: { q: search },
1474
- queryParamsHandling: 'merge'
1475
- });
1476
- });
1477
- this.mediaQueryListener();
1478
- this.darkMediaQuery.addEventListener('change', this.mediaQueryListener);
1479
- }
1480
- ngOnDestroy() {
1481
- this.darkMediaQuery.removeEventListener('change', this.mediaQueryListener);
1482
- }
1483
- toggleDark(dark) {
1484
- document.documentElement.classList.toggle('app--dark', dark);
1485
- document.documentElement.classList.toggle('app--light', !dark);
1486
- }
1487
- makeTree(filterValue) {
1488
- this.tree = [];
1489
- let prevParents = [];
1490
- for (const item of this.componentList) {
1491
- if (filterValue && !item.toLowerCase().includes(filterValue)) {
1492
- continue;
1493
- }
1494
- const parts = item.split('/');
1495
- const label = parts.pop();
1496
- for (let i = 0; i < parts.length; i++) {
1497
- if (prevParents.length < i || parts[i] !== prevParents[i]) {
1498
- this.tree.push({ label: parts[i], level: i });
1499
- }
1500
- }
1501
- prevParents = parts;
1502
- this.tree.push({ label, link: item, level: parts.length });
1503
- }
1504
- }
1505
- toggleCollapse() {
1506
- this.isCollapsed = !this.isCollapsed;
1507
- localStorage.setItem('si-live-preview-examples-collapsed', this.isCollapsed.toString());
1508
- if (this.isCollapsed) {
1509
- this.showContent = false;
1510
- setTimeout(() => window.dispatchEvent(new Event('resize')), 500);
1511
- this.cdRef.markForCheck();
1512
- }
1513
- else {
1514
- setTimeout(() => {
1515
- this.showContent = true;
1516
- window.dispatchEvent(new Event('resize'));
1517
- this.cdRef.markForCheck();
1518
- }, 500);
1519
- }
1520
- }
1521
- resetSearchBar() {
1522
- this.searchControl.reset();
1523
- }
1524
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiExampleOverviewComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1525
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.8", type: SiExampleOverviewComponent, isStandalone: true, selector: "si-example-overview", ngImport: i0, template: "<nav class=\"component-list\" aria-label=\"Live preview\" [class.is-collapsed]=\"isCollapsed\">\n <div class=\"component-list-header\">\n @if (showContent) {\n <span>Examples</span>\n }\n <button\n type=\"button\"\n class=\"collapse-button\"\n [attr.title]=\"isCollapsed ? 'Expand' : 'Collapse'\"\n [attr.aria-label]=\"isCollapsed ? 'Expand' : 'Collapse'\"\n (click)=\"toggleCollapse()\"\n >\n <svg class=\"collapse-icon\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\">\n <path\n d=\"M234.77,248.93l1.44-1.72,110-110a12.43,12.43,0,0,1,19,15.86l-1.44,1.72L262.59,256l101.2,101.21a12.45,12.45,0,0,1,1.44,15.86l-1.44,1.72a12.45,12.45,0,0,1-15.86,1.44l-1.72-1.44-110-110A12.45,12.45,0,0,1,234.77,248.93Z\"\n />\n <path\n d=\"M146.77,248.93l1.44-1.72,88-88a12.43,12.43,0,0,1,19,15.86l-1.44,1.72L174.59,256l79.2,79.21a12.45,12.45,0,0,1,1.44,15.86l-1.44,1.72a12.45,12.45,0,0,1-15.86,1.44l-1.72-1.44-88-88A12.45,12.45,0,0,1,146.77,248.93Z\"\n />\n </svg>\n </button>\n </div>\n @if (showContent) {\n <div class=\"search-bar\" role=\"search\" aria-label=\"Live preview\">\n <svg class=\"search-bar-icon\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\">\n <path\n d=\"M420.49,403.51l-76.88-76.87A139.39,139.39,0,0,0,377,236c0-77.2-62.8-140-140-140S97,158.8,97,236s62.8,140,140,140a139.33,139.33,0,0,0,89.55-32.48l77,77a12,12,0,0,0,17-17ZM121,236A116,116,0,1,1,237,352,116.13,116.13,0,0,1,121,236Z\"\n />\n </svg>\n <input\n type=\"text\"\n placeholder=\"Filter examples\"\n autocorrect=\"off\"\n autocapitalize=\"none\"\n [formControl]=\"searchControl\"\n />\n @if (searchControl.value) {\n <button\n type=\"button\"\n class=\"cancel-button\"\n aria-label=\"clear search\"\n (click)=\"resetSearchBar()\"\n >\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\">\n <path\n d=\"M273,256l87.52-87.51a12,12,0,0,0-17-17L256,239l-87.51-87.52a12,12,0,0,0-17,17L239,256l-87.52,87.51a12,12,0,0,0,17,17L256,273l87.51,87.52a12,12,0,0,0,17-17Z\"\n />\n </svg>\n </button>\n }\n </div>\n }\n @if (showContent) {\n <div class=\"available-examples\">\n <ul>\n @for (item of tree; track $index) {\n <li [style.--level]=\"item.level\">\n @if (item.link) {\n <a\n routerLinkActive=\"example-active\"\n queryParamsHandling=\"merge\"\n [routerLink]=\"'/overview/' + item.link\"\n >\n {{ item.label }}\n </a>\n } @else {\n {{ item.label }}\n }\n </li>\n }\n </ul>\n </div>\n }\n @if (!showContent && isCollapsed) {\n <div class=\"component-list-text\">\n <span>Examples</span>\n </div>\n }\n</nav>\n<main aria-label=\"Live preview\">\n <si-live-preview />\n</main>\n", styles: ["a{color:var(--si-sys-color-text-accent)}a:after{display:none}a:hover{color:var(--si-sys-color-text-accent-hover)}*:focus-visible{outline:var(--element-button-focus-width) solid var(--si-sys-color-effects-focus);outline-offset:var(--element-button-focus-overlay-width)}:host{display:flex;flex-direction:row;background-color:var(--si-sys-color-background-0)}.component-list{border-inline-end:1px solid var(--si-sys-color-border-4);display:flex;flex:0 0 auto;inline-size:400px;flex-direction:column;transition:inline-size .5s;color:var(--si-sys-color-text-primary)}.component-list.is-collapsed{inline-size:40px;overflow:hidden;background-color:var(--si-sys-color-background-0)}.component-list.is-collapsed .component-list-text{transform:rotate(-90deg);margin-block:auto 2em;word-wrap:normal}.component-list.is-collapsed .collapse-icon{transform:rotate(180deg)}.component-list .component-list-header{display:flex;flex-direction:column;justify-content:center;padding-block:10px;padding-inline:8px;background-color:var(--si-sys-color-background-0);position:relative;block-size:36px}.component-list .component-list-header .collapse-button{background-color:transparent;border:0;padding:4px;position:absolute;inset-inline-end:2px;inset-block-start:4px;inline-size:32px;block-size:32px;cursor:pointer;color:var(--si-sys-color-text-primary)}.component-list .component-list-header .collapse-button>svg{block-size:20px;fill:currentColor}.component-list .component-list-header .collapse-button:hover{color:var(--si-sys-color-text-accent-hover)}.component-list .search-bar{display:flex;margin-block:10px;margin-inline:8px;position:relative;block-size:38px}.component-list .search-bar input{flex:1;padding-block:8px;padding-inline:28px 12px;border:1px solid var(--si-sys-color-border-4);font-size:14px;background:var(--si-sys-color-background-0);color:var(--si-sys-color-text-primary)}.component-list .search-bar .search-bar-icon{position:absolute;inset-block-start:8px;inset-inline-start:6px;fill:var(--si-sys-color-text-primary);block-size:20px}.component-list .search-bar .cancel-button{background-color:transparent;border:0;font-size:20px;line-height:20px;padding:0;pointer-events:auto;position:absolute;inset-inline-end:8px;inset-block-start:8px}.component-list .search-bar .cancel-button>svg{block-size:20px;fill:var(--si-sys-color-text-primary)}.component-list .available-examples{flex:1 1 0;min-block-size:0;overflow-y:auto;padding-block-start:10px;border-block-start:1px solid var(--si-sys-color-border-4)}.component-list .available-examples ul{margin-block:0 16px;margin-inline:0;padding-inline-start:16px;list-style:none}.component-list .available-examples li{margin-inline-start:calc(var(--level) * 16px);padding-block:4px}.example-active{font-weight:600}a{text-decoration:none}main{flex:1 1 auto;display:flex;overflow:hidden}@media(prefers-color-scheme:dark){si-example-overview{color-scheme:dark}}\n"], dependencies: [{ kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox]):not([ngNoCva])[formControlName],textarea:not([ngNoCva])[formControlName],input:not([type=checkbox]):not([ngNoCva])[formControl],textarea:not([ngNoCva])[formControl],input:not([type=checkbox]):not([ngNoCva])[ngModel],textarea:not([ngNoCva])[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "directive", type: RouterLink, selector: "[routerLink]", inputs: ["target", "queryParams", "fragment", "queryParamsHandling", "state", "info", "relativeTo", "preserveFragment", "skipLocationChange", "replaceUrl", "browserUrl", "routerLink"] }, { kind: "directive", type: RouterLinkActive, selector: "[routerLinkActive]", inputs: ["routerLinkActiveOptions", "ariaCurrentWhenActive", "routerLinkActive"], outputs: ["isActiveChange"], exportAs: ["routerLinkActive"] }, { kind: "component", type: SiLivePreviewComponent, selector: "si-live-preview" }], changeDetection: i0.ChangeDetectionStrategy.Eager });
1526
- }
1527
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiExampleOverviewComponent, decorators: [{
1528
- type: Component,
1529
- args: [{ selector: 'si-example-overview', imports: [ReactiveFormsModule, RouterLink, RouterLinkActive, SiLivePreviewComponent], changeDetection: ChangeDetectionStrategy.Eager, template: "<nav class=\"component-list\" aria-label=\"Live preview\" [class.is-collapsed]=\"isCollapsed\">\n <div class=\"component-list-header\">\n @if (showContent) {\n <span>Examples</span>\n }\n <button\n type=\"button\"\n class=\"collapse-button\"\n [attr.title]=\"isCollapsed ? 'Expand' : 'Collapse'\"\n [attr.aria-label]=\"isCollapsed ? 'Expand' : 'Collapse'\"\n (click)=\"toggleCollapse()\"\n >\n <svg class=\"collapse-icon\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\">\n <path\n d=\"M234.77,248.93l1.44-1.72,110-110a12.43,12.43,0,0,1,19,15.86l-1.44,1.72L262.59,256l101.2,101.21a12.45,12.45,0,0,1,1.44,15.86l-1.44,1.72a12.45,12.45,0,0,1-15.86,1.44l-1.72-1.44-110-110A12.45,12.45,0,0,1,234.77,248.93Z\"\n />\n <path\n d=\"M146.77,248.93l1.44-1.72,88-88a12.43,12.43,0,0,1,19,15.86l-1.44,1.72L174.59,256l79.2,79.21a12.45,12.45,0,0,1,1.44,15.86l-1.44,1.72a12.45,12.45,0,0,1-15.86,1.44l-1.72-1.44-88-88A12.45,12.45,0,0,1,146.77,248.93Z\"\n />\n </svg>\n </button>\n </div>\n @if (showContent) {\n <div class=\"search-bar\" role=\"search\" aria-label=\"Live preview\">\n <svg class=\"search-bar-icon\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\">\n <path\n d=\"M420.49,403.51l-76.88-76.87A139.39,139.39,0,0,0,377,236c0-77.2-62.8-140-140-140S97,158.8,97,236s62.8,140,140,140a139.33,139.33,0,0,0,89.55-32.48l77,77a12,12,0,0,0,17-17ZM121,236A116,116,0,1,1,237,352,116.13,116.13,0,0,1,121,236Z\"\n />\n </svg>\n <input\n type=\"text\"\n placeholder=\"Filter examples\"\n autocorrect=\"off\"\n autocapitalize=\"none\"\n [formControl]=\"searchControl\"\n />\n @if (searchControl.value) {\n <button\n type=\"button\"\n class=\"cancel-button\"\n aria-label=\"clear search\"\n (click)=\"resetSearchBar()\"\n >\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\">\n <path\n d=\"M273,256l87.52-87.51a12,12,0,0,0-17-17L256,239l-87.51-87.52a12,12,0,0,0-17,17L239,256l-87.52,87.51a12,12,0,0,0,17,17L256,273l87.51,87.52a12,12,0,0,0,17-17Z\"\n />\n </svg>\n </button>\n }\n </div>\n }\n @if (showContent) {\n <div class=\"available-examples\">\n <ul>\n @for (item of tree; track $index) {\n <li [style.--level]=\"item.level\">\n @if (item.link) {\n <a\n routerLinkActive=\"example-active\"\n queryParamsHandling=\"merge\"\n [routerLink]=\"'/overview/' + item.link\"\n >\n {{ item.label }}\n </a>\n } @else {\n {{ item.label }}\n }\n </li>\n }\n </ul>\n </div>\n }\n @if (!showContent && isCollapsed) {\n <div class=\"component-list-text\">\n <span>Examples</span>\n </div>\n }\n</nav>\n<main aria-label=\"Live preview\">\n <si-live-preview />\n</main>\n", styles: ["a{color:var(--si-sys-color-text-accent)}a:after{display:none}a:hover{color:var(--si-sys-color-text-accent-hover)}*:focus-visible{outline:var(--element-button-focus-width) solid var(--si-sys-color-effects-focus);outline-offset:var(--element-button-focus-overlay-width)}:host{display:flex;flex-direction:row;background-color:var(--si-sys-color-background-0)}.component-list{border-inline-end:1px solid var(--si-sys-color-border-4);display:flex;flex:0 0 auto;inline-size:400px;flex-direction:column;transition:inline-size .5s;color:var(--si-sys-color-text-primary)}.component-list.is-collapsed{inline-size:40px;overflow:hidden;background-color:var(--si-sys-color-background-0)}.component-list.is-collapsed .component-list-text{transform:rotate(-90deg);margin-block:auto 2em;word-wrap:normal}.component-list.is-collapsed .collapse-icon{transform:rotate(180deg)}.component-list .component-list-header{display:flex;flex-direction:column;justify-content:center;padding-block:10px;padding-inline:8px;background-color:var(--si-sys-color-background-0);position:relative;block-size:36px}.component-list .component-list-header .collapse-button{background-color:transparent;border:0;padding:4px;position:absolute;inset-inline-end:2px;inset-block-start:4px;inline-size:32px;block-size:32px;cursor:pointer;color:var(--si-sys-color-text-primary)}.component-list .component-list-header .collapse-button>svg{block-size:20px;fill:currentColor}.component-list .component-list-header .collapse-button:hover{color:var(--si-sys-color-text-accent-hover)}.component-list .search-bar{display:flex;margin-block:10px;margin-inline:8px;position:relative;block-size:38px}.component-list .search-bar input{flex:1;padding-block:8px;padding-inline:28px 12px;border:1px solid var(--si-sys-color-border-4);font-size:14px;background:var(--si-sys-color-background-0);color:var(--si-sys-color-text-primary)}.component-list .search-bar .search-bar-icon{position:absolute;inset-block-start:8px;inset-inline-start:6px;fill:var(--si-sys-color-text-primary);block-size:20px}.component-list .search-bar .cancel-button{background-color:transparent;border:0;font-size:20px;line-height:20px;padding:0;pointer-events:auto;position:absolute;inset-inline-end:8px;inset-block-start:8px}.component-list .search-bar .cancel-button>svg{block-size:20px;fill:var(--si-sys-color-text-primary)}.component-list .available-examples{flex:1 1 0;min-block-size:0;overflow-y:auto;padding-block-start:10px;border-block-start:1px solid var(--si-sys-color-border-4)}.component-list .available-examples ul{margin-block:0 16px;margin-inline:0;padding-inline-start:16px;list-style:none}.component-list .available-examples li{margin-inline-start:calc(var(--level) * 16px);padding-block:4px}.example-active{font-weight:600}a{text-decoration:none}main{flex:1 1 auto;display:flex;overflow:hidden}@media(prefers-color-scheme:dark){si-example-overview{color-scheme:dark}}\n"] }]
1530
- }] });
1531
-
1532
- const setDeviceMode = (mode) => {
1533
- const htmlTag = document.documentElement;
1534
- htmlTag.setAttribute('mode', mode);
1535
- htmlTag.classList.add(mode);
1536
- htmlTag.classList.remove(mode === 'ios' ? 'md' : 'ios');
1537
- };
1538
- const setDirectionRtl = (rtl) => {
1539
- document.documentElement.setAttribute('dir', rtl ? 'rtl' : 'ltr');
1540
- };
1541
- const setRootFontSize = (rfs) => {
1542
- const htmlTag = document.documentElement;
1543
- if (!rfs) {
1544
- htmlTag.style.removeProperty('font-size');
1545
- }
1546
- else {
1547
- htmlTag.style.setProperty('font-size', rfs === 'initial' ? rfs : rfs + 'px');
1548
- }
1549
- };
1550
- const provideExampleRoutes = (routes) => {
1551
- return {
1552
- provide: SI_LIVE_PREVIEW_EXAMPLE_ROUTES,
1553
- useValue: routes
1554
- };
1555
- };
1556
-
1557
- /**
1558
- * Copyright (c) Siemens 2016 - 2026
1559
- * SPDX-License-Identifier: MIT
1560
- */
1561
- const LOG_EVENT = new InjectionToken('si.live-previewer.log-event');
1562
-
1563
- /**
1564
- * Copyright (c) Siemens 2016 - 2026
1565
- * SPDX-License-Identifier: MIT
1566
- */
1567
- // eslint-disable-next-line @typescript-eslint/no-deprecated
1568
- class LandscapeSupportService {
1569
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: LandscapeSupportService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1570
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: LandscapeSupportService, providedIn: 'any' });
1571
- }
1572
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: LandscapeSupportService, decorators: [{
1573
- type: Injectable,
1574
- args: [{
1575
- providedIn: 'any'
1576
- }]
1577
- }] });
1578
-
1579
- /**
1580
- * Copyright (c) Siemens 2016 - 2026
1581
- * SPDX-License-Identifier: MIT
1582
- */
1583
- /**
1584
- * Base class for components that act as a live-preview runtime shell.
1585
- * Extend this class when providing `SiLivePreviewConfig.runtimeComponent`.
1586
- */
1587
- class SiLivePreviewRuntimeComponent {
1588
- component = input.required(/* @ts-ignore */
1589
- ...(ngDevMode ? [{ debugName: "component" }] : /* istanbul ignore next */ []));
1590
- ready = output();
1591
- renderingError = output();
1592
- changeDetector = inject(ChangeDetectorRef);
1593
- activatedRoute = inject(ActivatedRoute);
1594
- config = inject(SI_LIVE_PREVIEW_CONFIG);
1595
- componentRef;
1596
- childRouteBackup;
1597
- hasRenderingError = false;
1598
- ngAfterViewInit() {
1599
- this.componentRef = this.container().createComponent(this.component());
1600
- const exampleRoutes = this.componentRef.injector.get(SI_LIVE_PREVIEW_EXAMPLE_ROUTES, undefined, {
1601
- optional: true,
1602
- self: true
1603
- }) ??
1604
- this.config.defaultRoutes ??
1605
- this.activatedRoute.routeConfig?.children ??
1606
- [];
1607
- const route = this.activatedRoute.routeConfig;
1608
- if (route) {
1609
- this.childRouteBackup = route.children;
1610
- // Do not reset the router configuration: that destroys child components during navigation.
1611
- route.children = [...exampleRoutes];
1612
- }
1613
- this.ready.emit();
1614
- }
1615
- ngOnDestroy() {
1616
- this.componentRef?.destroy();
1617
- this.componentRef = undefined;
1618
- const route = this.activatedRoute.routeConfig;
1619
- if (route) {
1620
- route.children = this.childRouteBackup;
1621
- }
1622
- }
1623
- ngDoCheck() {
1624
- if (this.hasRenderingError) {
1625
- return;
1626
- }
1627
- try {
1628
- this.changeDetector.detectChanges();
1629
- }
1630
- catch (error) {
1631
- this.hasRenderingError = true;
1632
- this.renderingError.emit(error instanceof Error ? error : new Error(String(error)));
1633
- }
1634
- }
1635
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiLivePreviewRuntimeComponent, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1636
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.8", type: SiLivePreviewRuntimeComponent, isStandalone: true, inputs: { component: { classPropertyName: "component", publicName: "component", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { ready: "ready", renderingError: "renderingError" }, ngImport: i0 });
1637
- }
1638
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiLivePreviewRuntimeComponent, decorators: [{
1639
- type: Directive
1640
- }], propDecorators: { component: [{ type: i0.Input, args: [{ isSignal: true, alias: "component", required: true }] }], ready: [{ type: i0.Output, args: ["ready"] }], renderingError: [{ type: i0.Output, args: ["renderingError"] }] } });
1641
-
1642
- /**
1643
- * Copyright (c) Siemens 2016 - 2026
1644
- * SPDX-License-Identifier: MIT
1645
- */
1646
- /** Default standalone shell used to render a live-preview example. */
1647
- class SiDefaultLivePreviewRuntimeComponent extends SiLivePreviewRuntimeComponent {
1648
- container = viewChild.required('container', { ...(ngDevMode ? { debugName: "container" } : /* istanbul ignore next */ {}), read: ViewContainerRef });
1649
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiDefaultLivePreviewRuntimeComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
1650
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "22.0.8", type: SiDefaultLivePreviewRuntimeComponent, isStandalone: true, selector: "si-live-preview-runtime", viewQueries: [{ propertyName: "container", first: true, predicate: ["container"], descendants: true, read: ViewContainerRef, isSignal: true }], usesInheritance: true, ngImport: i0, template: '<ng-container #container />', isInline: true });
1651
- }
1652
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiDefaultLivePreviewRuntimeComponent, decorators: [{
1653
- type: Component,
1654
- args: [{
1655
- selector: 'si-live-preview-runtime',
1656
- template: '<ng-container #container />'
1657
- }]
1658
- }], propDecorators: { container: [{ type: i0.ViewChild, args: ['container', { ...{ read: ViewContainerRef }, isSignal: true }] }] } });
1659
-
1660
- // for handling JSON.stringify with circular references, from MDN
1661
- const getCircularReplacer = () => {
1662
- const seen = new WeakSet();
1663
- return (_key, value) => {
1664
- if (typeof value === 'object' && value !== null) {
1665
- if (seen.has(value)) {
1666
- return;
1667
- }
1668
- seen.add(value);
1669
- }
1670
- return value;
1671
- };
1672
- };
1673
- let DummyAppSampleComponent = class DummyAppSampleComponent {
1674
- };
1675
- DummyAppSampleComponent = __decorate([
1676
- Component({
1677
- // eslint-disable-next-line @angular-eslint/component-selector
1678
- selector: 'app-sample',
1679
- template: '',
1680
- jit: true
1681
- })
1682
- ], DummyAppSampleComponent);
1683
- class SiLivePreviewRendererComponent {
1684
- renderedExample = viewChild.required('renderedExample', { ...(ngDevMode ? { debugName: "renderedExample" } : /* istanbul ignore next */ {}), read: ViewContainerRef });
1685
- react = viewChild.required('react', { ...(ngDevMode ? { debugName: "react" } : /* istanbul ignore next */ {}), read: ElementRef });
1686
- state = inject(LivePreviewStateService);
1687
- config = inject(SI_LIVE_PREVIEW_CONFIG);
1688
- // eslint-disable-next-line @typescript-eslint/no-deprecated
1689
- compiler = inject(Compiler);
1690
- injector = Injector.create({
1691
- parent: inject(Injector),
1692
- providers: [
1693
- {
1694
- provide: LOG_EVENT,
1695
- useValue: (...msg) => this.logMessage.emit(this.stringifyLog(msg))
1696
- }
1697
- ]
1698
- });
1699
- rendererFactory = inject(_DomRendererFactory2);
1700
- cdRef = inject(ChangeDetectorRef);
1701
- exampleUrl = computed(() => this.config.examplesBaseUrl + this.state.example(), /* @ts-ignore */
1702
- ...(ngDevMode ? [{ debugName: "exampleUrl" }] : /* istanbul ignore next */ []));
1703
- renderingDone = signal(false, /* @ts-ignore */
1704
- ...(ngDevMode ? [{ debugName: "renderingDone" }] : /* istanbul ignore next */ []));
1705
- templateFromComponent = output();
1706
- logClear = output();
1707
- logMessage = output();
1708
- logRenderingError = output();
1709
- inProgress = output();
1710
- supportsLandscapeMode = output();
1711
- componentRef;
1712
- componentTs;
1713
- componentTsSampleComponent;
1714
- dynamicComponent;
1715
- dynamicComponentId;
1716
- componentTsFirstLoad = true;
1717
- compiledTemplate;
1718
- constructor() {
1719
- effect(() => {
1720
- const url = this.exampleUrl();
1721
- if (url) {
1722
- untracked(() => this.loadFromUrl());
1723
- }
1724
- });
1725
- effect(() => {
1726
- const template = this.state.template();
1727
- // when the initial template is pushed from the renderer to the editor, this.state.template is
1728
- // initially empty, but later changes to what the renderer has pushed out. In this case
1729
- // don't compile
1730
- if (template && template !== this.compiledTemplate) {
1731
- untracked(() => {
1732
- this.setInProgress(true);
1733
- this.compileWhenReady();
1734
- });
1735
- }
1736
- });
1737
- }
1738
- ngOnDestroy() {
1739
- this.clear();
1740
- }
1741
- recompile() {
1742
- this.removeComponentInstance();
1743
- this.logClear.emit();
1744
- this.setRenderingError(false);
1745
- try {
1746
- this.createComponentInstance();
1747
- }
1748
- catch (error) {
1749
- this.setRenderingError(true, error);
1750
- }
1751
- }
1752
- logError(error) {
1753
- if (this.config.errorHandler) {
1754
- this.config.errorHandler(error);
1755
- }
1756
- }
1757
- setRenderingError(hasError, msg) {
1758
- this.logRenderingError.emit(msg);
1759
- if (hasError) {
1760
- setTimeout(() => {
1761
- this.setInProgress(false);
1762
- this.cdRef.markForCheck();
1763
- });
1764
- }
1765
- }
1766
- loadFromUrl() {
1767
- this.logClear.emit();
1768
- this.clear();
1769
- this.componentTsSampleComponent = undefined;
1770
- this.dynamicComponent = undefined;
1771
- this.componentTsFirstLoad = true;
1772
- this.componentTs = this.config.componentLoader.load(this.exampleUrl());
1773
- if (this.componentTs) {
1774
- this.setInProgress(true);
1775
- this.componentTs
1776
- .then(m => {
1777
- this.componentTsSampleComponent = m.SampleComponent;
1778
- this.dynamicComponent = m.SampleComponent;
1779
- this.compileWhenReady();
1780
- if (!this.componentTsSampleComponent && !this.state.template()) {
1781
- afterNextRender(() => {
1782
- this.setInProgress(false);
1783
- this.cdRef.markForCheck();
1784
- }, { injector: this.injector });
1785
- }
1786
- })
1787
- .catch(e => {
1788
- this.componentTs = undefined;
1789
- this.logRenderingError.emit(e ? e.toString() : 'Failed loading TS');
1790
- afterNextRender(() => {
1791
- this.setInProgress(false);
1792
- this.cdRef.markForCheck();
1793
- }, { injector: this.injector });
1794
- });
1795
- }
1796
- else {
1797
- // set the dummy component
1798
- this.componentTsSampleComponent = DummyAppSampleComponent;
1799
- // let the editor know there is no component, so no template
1800
- this.templateFromComponent.emit(undefined);
1801
- }
1802
- }
1803
- setInProgress(inProgress) {
1804
- this.renderingDone.set(!inProgress);
1805
- this.inProgress.emit(inProgress);
1806
- }
1807
- compileWhenReady() {
1808
- if (this.componentTs) {
1809
- if (!this.componentTsSampleComponent) {
1810
- // TS, but code not yet loaded
1811
- return;
1812
- }
1813
- if (!this.componentTsFirstLoad && !this.state.template()) {
1814
- // TS, first load done, template not yet available
1815
- return;
1816
- }
1817
- }
1818
- else if (!this.state.template()) {
1819
- // no TS, no template
1820
- return;
1821
- }
1822
- this.doCompileTemplate();
1823
- }
1824
- doCompileTemplate() {
1825
- this.logClear.emit();
1826
- this.clear();
1827
- this.createComponent();
1828
- }
1829
- stringifyLog(args) {
1830
- return args.map(a => JSON.stringify(a, getCircularReplacer())).join(', ');
1831
- }
1832
- // this exists because in production mode, the ivy internal props are defined as
1833
- // non-configurable and cannot be overwritten
1834
- cloneComponentWithoutIvyStuff() {
1835
- if (!this.componentTsSampleComponent) {
1836
- return;
1837
- }
1838
- const orig = this.componentTsSampleComponent;
1839
- const ignoreProps = ['ɵcmp', 'ɵfac', 'ɵprov'];
1840
- const copy = orig.bind({});
1841
- const descriptors = Object.getOwnPropertyDescriptors(orig);
1842
- for (const name of Object.getOwnPropertyNames(orig)) {
1843
- if (ignoreProps.includes(name)) {
1844
- continue;
1845
- }
1846
- Object.defineProperty(copy, name, descriptors[name]);
1847
- }
1848
- this.dynamicComponent = copy;
1849
- }
1850
- // patches the template into the loaded component (if any), returns the template to use
1851
- updateDynamicTemplate() {
1852
- if (this.componentTsSampleComponent) {
1853
- const ann = this.componentTsSampleComponent?.decorators
1854
- ? this.getAnnotationInAot(this.componentTsSampleComponent)
1855
- : this.getAnnotation(this.componentTsSampleComponent, Component);
1856
- if (ann) {
1857
- const supportsLandscape = ann.providers?.includes(LandscapeSupportService);
1858
- this.supportsLandscapeMode.emit(supportsLandscape);
1859
- if (this.componentTsFirstLoad && !this.state.template()) {
1860
- // skipping compile on first load
1861
- this.compiledTemplate = ann.template;
1862
- this.templateFromComponent.emit(ann.template);
1863
- }
1864
- else if (ann.template !== this.state.template()) {
1865
- // recompile with new template
1866
- this.componentTsFirstLoad = false;
1867
- this.cloneComponentWithoutIvyStuff();
1868
- ann.template = this.state.template();
1869
- this.compiledTemplate = this.state.template();
1870
- _compileComponent(this.dynamicComponent, ann);
1871
- this.reuseResolvedScopeOfOriginalComponent();
1872
- }
1873
- }
1874
- }
1875
- }
1876
- /**
1877
- * When the host application is built with AOT, the Angular compiler tree-shakes the
1878
- * `ɵɵsetNgModuleScope` calls (because `ngJitMode` is `false`). As a result, NgModules that are
1879
- * compiled from source expose no `imports`/`exports` scope on their `ɵmod` at runtime.
1880
- *
1881
- * Re-compiling the edited example via JIT (`compileComponent`) therefore cannot resolve the
1882
- * directives and pipes that are exported through such an imported NgModule. A common symptom is
1883
- * a missing value accessor for a form control component used with `ngModel`, which throws
1884
- * `NG01203`.
1885
- *
1886
- * The originally (AOT-)compiled component already carries the fully resolved scope in its
1887
- * component definition. Reusing its directive and pipe defs on the recompiled component restores
1888
- * the complete scope without depending on runtime NgModule metadata.
1889
- */
1890
- reuseResolvedScopeOfOriginalComponent() {
1891
- const originalDef = this.componentTsSampleComponent?.['ɵcmp'];
1892
- const recompiledDef = this.dynamicComponent?.['ɵcmp'];
1893
- if (!originalDef || !recompiledDef) {
1894
- return;
1895
- }
1896
- if (originalDef.directiveDefs) {
1897
- recompiledDef.directiveDefs = this.mergeDefs(recompiledDef.directiveDefs, originalDef.directiveDefs);
1898
- }
1899
- if (originalDef.pipeDefs) {
1900
- recompiledDef.pipeDefs = this.mergeDefs(recompiledDef.pipeDefs, originalDef.pipeDefs);
1901
- }
1902
- }
1903
- /** Merges two (possibly lazy) Ivy def lists into a single deduplicated factory. */
1904
- mergeDefs(recompiled, original) {
1905
- const resolve = (defs) => typeof defs === 'function' ? defs() : (defs ?? []);
1906
- return () => [...new Set([...resolve(recompiled), ...resolve(original)])];
1907
- }
1908
- getAnnotation(obj, type) {
1909
- return obj?.__annotations__?.find((a) => a instanceof type);
1910
- }
1911
- getAnnotationInAot(obj) {
1912
- return obj.decorators?.[0]?.args?.[0];
1913
- }
1914
- clear() {
1915
- this.removeComponentInstance();
1916
- if (this.dynamicComponent) {
1917
- this.compiler.clearCacheFor(this.dynamicComponent);
1918
- }
1919
- _resetCompiledComponents();
1920
- }
1921
- removeComponentInstance() {
1922
- this.componentRef?.destroy();
1923
- this.componentRef = undefined;
1924
- try {
1925
- this.renderedExample().remove();
1926
- }
1927
- catch (error) {
1928
- // FIXME: there's no point in logging this as rendering error since it will be cleared right away
1929
- console.warn('Error during ngOnDestroy():', error);
1930
- }
1931
- // clear out render for component id:
1932
- // - contains the styles
1933
- // - stays mostly the same for all examples
1934
- if (this.dynamicComponentId) {
1935
- this.rendererFactory.rendererByCompId?.delete(this.dynamicComponentId);
1936
- }
1937
- }
1938
- createComponent() {
1939
- this.setRenderingError(false);
1940
- try {
1941
- this.updateDynamicTemplate();
1942
- this.createComponentInstance();
1943
- }
1944
- catch (error) {
1945
- this.setRenderingError(true, error.toString());
1946
- }
1947
- }
1948
- createComponentInstance() {
1949
- this.dynamicComponentId = this.dynamicComponent?.['ɵcmp']?.id;
1950
- if (!this.dynamicComponent) {
1951
- return;
1952
- }
1953
- if (!this.dynamicComponent['ɵcmp']?.standalone) {
1954
- throw new Error('Live preview examples must be standalone components.');
1955
- }
1956
- const runtimeComponent = this.config.runtimeComponent ?? SiDefaultLivePreviewRuntimeComponent;
1957
- this.componentRef = this.renderedExample().createComponent(runtimeComponent, {
1958
- injector: this.injector,
1959
- bindings: [inputBinding('component', () => this.dynamicComponent)]
1960
- });
1961
- this.componentRef.instance.ready.subscribe(() => {
1962
- queueMicrotask(() => {
1963
- this.setInProgress(false);
1964
- this.cdRef.markForCheck();
1965
- });
1966
- });
1967
- this.componentRef.instance.renderingError.subscribe(error => {
1968
- this.setRenderingError(true, error.message);
1969
- this.logError(error);
1970
- });
1971
- }
1972
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiLivePreviewRendererComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1973
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "22.0.8", type: SiLivePreviewRendererComponent, isStandalone: true, selector: "si-live-preview-renderer", outputs: { templateFromComponent: "templateFromComponent", logClear: "logClear", logMessage: "logMessage", logRenderingError: "logRenderingError", inProgress: "inProgress", supportsLandscapeMode: "supportsLandscapeMode" }, host: { properties: { "class.live-preview-done": "renderingDone()", "attr.data-example": "exampleUrl()", "attr.data-id": "state.dataId()" } }, viewQueries: [{ propertyName: "renderedExample", first: true, predicate: ["renderedExample"], descendants: true, read: ViewContainerRef, isSignal: true }, { propertyName: "react", first: true, predicate: ["react"], descendants: true, read: ElementRef, isSignal: true }], ngImport: i0, template: '<div #renderedExample></div><div #react id="app"></div>', isInline: true, changeDetection: i0.ChangeDetectionStrategy.Eager });
1974
- }
1975
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiLivePreviewRendererComponent, decorators: [{
1976
- type: Component,
1977
- args: [{
1978
- selector: 'si-live-preview-renderer',
1979
- template: '<div #renderedExample></div><div #react id="app"></div>',
1980
- changeDetection: ChangeDetectionStrategy.Eager,
1981
- host: {
1982
- '[class.live-preview-done]': 'renderingDone()',
1983
- '[attr.data-example]': 'exampleUrl()',
1984
- '[attr.data-id]': 'state.dataId()'
1985
- }
1986
- }]
1987
- }], ctorParameters: () => [], propDecorators: { renderedExample: [{ type: i0.ViewChild, args: ['renderedExample', { ...{ read: ViewContainerRef }, isSignal: true }] }], react: [{ type: i0.ViewChild, args: ['react', { ...{ read: ElementRef }, isSignal: true }] }], templateFromComponent: [{ type: i0.Output, args: ["templateFromComponent"] }], logClear: [{ type: i0.Output, args: ["logClear"] }], logMessage: [{ type: i0.Output, args: ["logMessage"] }], logRenderingError: [{ type: i0.Output, args: ["logRenderingError"] }], inProgress: [{ type: i0.Output, args: ["inProgress"] }], supportsLandscapeMode: [{ type: i0.Output, args: ["supportsLandscapeMode"] }] } });
1988
-
1989
- /**
1990
- * Copyright (c) Siemens 2016 - 2026
1991
- * SPDX-License-Identifier: MIT
1992
- */
1993
- class SiExampleViewerComponent {
1994
- router = inject(Router);
1995
- route = inject(ActivatedRoute);
1996
- internalConfig = inject(SI_LIVE_PREVIEW_INTERNALS);
1997
- themeApi = inject(SiLivePreviewThemeApi, { optional: true });
1998
- localeApi = inject(SiLivePreviewLocaleApi, { optional: true });
1999
- state = inject(LivePreviewStateService);
2000
- renderer = viewChild.required('renderer', /* @ts-ignore */
2001
- ...(ngDevMode ? [{ debugName: "renderer" }] : /* istanbul ignore next */ []));
2002
- mode = signal('viewer', /* @ts-ignore */
2003
- ...(ngDevMode ? [{ debugName: "mode" }] : /* istanbul ignore next */ []));
2004
- tabs = signal([], /* @ts-ignore */
2005
- ...(ngDevMode ? [{ debugName: "tabs" }] : /* istanbul ignore next */ []));
2006
- hasTabs = computed(() => this.tabs().length > 1, /* @ts-ignore */
2007
- ...(ngDevMode ? [{ debugName: "hasTabs" }] : /* istanbul ignore next */ []));
2008
- hasTabsMobile = computed(() => this.tabs().length > 1 && this.internalConfig.isMobile, /* @ts-ignore */
2009
- ...(ngDevMode ? [{ debugName: "hasTabsMobile" }] : /* istanbul ignore next */ []));
2010
- activeTabIndex = signal(0, /* @ts-ignore */
2011
- ...(ngDevMode ? [{ debugName: "activeTabIndex" }] : /* istanbul ignore next */ []));
2012
- constructor() {
2013
- this.route.params.subscribe(params => this.mode.set(params.mode ?? 'editor'));
2014
- this.route.queryParams.subscribe(params => this.handleQueryParams(params));
2015
- }
2016
- handleQueryParams(params) {
2017
- let handled = false;
2018
- let recompile = false;
2019
- const base = params.base ? params.base + '/' : '';
2020
- if (params.e) {
2021
- const prevUrl = this.state.example();
2022
- const previousTemplate = this.state.template();
2023
- this.tabs.set([]);
2024
- this.activeTabIndex.set(0);
2025
- this.state.example.set('');
2026
- this.state.clearTemplates();
2027
- const examples = Array.isArray(params.e) ? params.e : [params.e];
2028
- examples.forEach(element => {
2029
- const parts = element.split(';');
2030
- this.tabs.update(t => [
2031
- ...t,
2032
- {
2033
- heading: parts[1],
2034
- base,
2035
- example: parts[0]
2036
- }
2037
- ]);
2038
- });
2039
- if (this.tabs().length) {
2040
- this.activateTab(0);
2041
- recompile = prevUrl === this.state.example();
2042
- }
2043
- if (this.tabs().length <= 1 && params.t) {
2044
- if (params.framework === 'react') {
2045
- this.state.templateReact.set(params.t);
2046
- }
2047
- else if (params.framework === 'vue') {
2048
- this.state.templateVue.set(params.t);
2049
- }
2050
- else if (params.framework === 'js') {
2051
- this.state.templateJs.set(params.t);
2052
- }
2053
- else {
2054
- recompile = recompile || previousTemplate !== params.t;
2055
- this.state.template.set(params.t);
2056
- }
2057
- }
2058
- handled = true;
2059
- }
2060
- if (params.theme) {
2061
- this.setTheme(params.theme);
2062
- handled = true;
2063
- }
2064
- if (params.locale) {
2065
- this.setLocale(params.locale);
2066
- handled = true;
2067
- }
2068
- if (params.rfs) {
2069
- setRootFontSize(parseInt(params.rfs, 10));
2070
- }
2071
- if (params.isRTL) {
2072
- this.setRTL(params.isRTL);
2073
- handled = true;
2074
- }
2075
- if (params.mode && this.mode() !== 'editor') {
2076
- setDeviceMode(params.mode);
2077
- recompile = true;
2078
- handled = true;
2079
- }
2080
- if (handled) {
2081
- const { e, t, theme, mode, locale, isRTL, ...newParams } = params;
2082
- this.router.navigate([], { queryParams: newParams });
2083
- }
2084
- if (params.id) {
2085
- recompile = this.state.dataId() !== params.id;
2086
- this.state.dataId.set(params.id);
2087
- }
2088
- if (recompile) {
2089
- this.renderer()?.recompile();
2090
- }
2091
- }
2092
- setUiTheme(theme) {
2093
- document.documentElement.classList.toggle('app--dark', theme === 'dark');
2094
- document.documentElement.classList.toggle('app--light', theme === 'light');
2095
- }
2096
- setTheme(theme) {
2097
- if (this.mode() === 'editor') {
2098
- this.state.theme.set(theme);
2099
- }
2100
- if (this.themeApi) {
2101
- this.themeApi.setThemeFromPreviewer(theme);
2102
- }
2103
- this.setUiTheme(theme);
2104
- }
2105
- setRTL(rtl) {
2106
- this.state.isRTL.set(rtl);
2107
- if (this.mode() !== 'editor') {
2108
- setDirectionRtl(rtl);
2109
- }
2110
- }
2111
- setLocale(locale) {
2112
- if (this.mode() === 'editor') {
2113
- this.state.locale.set(locale);
2114
- return;
2115
- }
2116
- if (this.localeApi) {
2117
- this.localeApi.setLocale(locale);
2118
- }
2119
- }
2120
- activateTab(index) {
2121
- const example = this.tabs()[index].example;
2122
- this.activeTabIndex.set(index);
2123
- this.state.example.set(this.tabs()[index].base + example);
2124
- }
2125
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiExampleViewerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
2126
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.8", type: SiExampleViewerComponent, isStandalone: true, selector: "si-example-viewer", host: { properties: { "class.has-tabs": "hasTabs()", "class.has-tabs-mobile": "hasTabsMobile()" } }, viewQueries: [{ propertyName: "renderer", first: true, predicate: ["renderer"], descendants: true, isSignal: true }], ngImport: i0, template: "<div class=\"wrapper\">\n @if (!state.example() && !state.template()) {\n <p class=\"text-information\" style=\"margin: 1em\">\n No example specified. Head to\n <strong><a href=\"#/overview\">/overview</a></strong>\n for a list of them.\n </p>\n }\n @if (\n (state.template() || state.templateReact() || state.templateVue() || state.templateJs()) &&\n mode() === 'editor'\n ) {\n <p class=\"text-information\" style=\"margin: 1em\">\n This is an adopted example built from the URL. Head to\n <strong><a href=\"#/overview\">/overview</a></strong> for a list of examples.\n </p>\n }\n @if (tabs().length > 1) {\n <div class=\"tab-wrapper\">\n <div role=\"tablist\" class=\"nav lp-tabs\">\n @for (tab of tabs(); track $index) {\n <button\n type=\"button\"\n role=\"tab\"\n class=\"tab-item tab-link focus-inside\"\n [class.tab-active]=\"activeTabIndex() === $index\"\n (click)=\"activateTab($index)\"\n (keydown.enter)=\"activateTab($index)\"\n >\n {{ tab.heading }}\n </button>\n }\n </div>\n </div>\n }\n</div>\n\n@if (mode() !== 'editor') {\n <si-live-preview-renderer #renderer />\n} @else {\n <si-live-preview />\n}\n", styles: [".lp-tabs{display:flex;flex-wrap:wrap;padding-inline-start:0;margin:0;list-style:none;background:none;inline-size:inherit;font-weight:700}.lp-tabs .tab-item:focus-visible{outline-offset:calc(-1 * var(--element-button-focus-width))}.lp-tabs .tab-item.tab-active.tab-link{color:var(--si-sys-color-text-accent);border-block-end-color:var(--si-sys-color-text-accent)!important}.lp-tabs .tab-item.tab-active.tab-link:hover{color:var(--si-sys-color-text-accent-hover)}.lp-tabs .tab-item.tab-link{font:inherit;background:none;min-inline-size:150px;display:block;padding-block:8px;padding-inline:15px;cursor:pointer;text-align:start;line-height:20px;color:var(--si-sys-color-text-primary);border:0;border-block-end:4px solid transparent}.lp-tabs .tab-item.tab-link:hover{text-decoration:none;color:var(--si-sys-color-text-accent-hover);border-block-end-color:var(--si-sys-color-border-4)}*:focus-visible{outline:var(--element-button-focus-width) solid var(--si-sys-color-effects-focus);outline-offset:var(--element-button-focus-overlay-width)}.wrapper{background-color:var(--si-sys-color-background-0);color:var(--si-sys-color-text-primary)}.wrapper.has-tabs .tab-wrapper,.wrapper.has-tabs-mobile{background-color:var(--si-sys-color-background-0)}.tab-wrapper{margin-block-end:10px;border-block-end:1px solid var(--si-sys-color-border-4)}si-live-preview-renderer{flex:1;transform:translate(0)}\n"], dependencies: [{ kind: "component", type: SiLivePreviewComponent, selector: "si-live-preview" }, { kind: "component", type: SiLivePreviewRendererComponent, selector: "si-live-preview-renderer", outputs: ["templateFromComponent", "logClear", "logMessage", "logRenderingError", "inProgress", "supportsLandscapeMode"] }], changeDetection: i0.ChangeDetectionStrategy.Eager });
2127
- }
2128
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiExampleViewerComponent, decorators: [{
2129
- type: Component,
2130
- args: [{ selector: 'si-example-viewer', imports: [SiLivePreviewComponent, SiLivePreviewRendererComponent], changeDetection: ChangeDetectionStrategy.Eager, host: {
2131
- '[class.has-tabs]': 'hasTabs()',
2132
- '[class.has-tabs-mobile]': 'hasTabsMobile()'
2133
- }, template: "<div class=\"wrapper\">\n @if (!state.example() && !state.template()) {\n <p class=\"text-information\" style=\"margin: 1em\">\n No example specified. Head to\n <strong><a href=\"#/overview\">/overview</a></strong>\n for a list of them.\n </p>\n }\n @if (\n (state.template() || state.templateReact() || state.templateVue() || state.templateJs()) &&\n mode() === 'editor'\n ) {\n <p class=\"text-information\" style=\"margin: 1em\">\n This is an adopted example built from the URL. Head to\n <strong><a href=\"#/overview\">/overview</a></strong> for a list of examples.\n </p>\n }\n @if (tabs().length > 1) {\n <div class=\"tab-wrapper\">\n <div role=\"tablist\" class=\"nav lp-tabs\">\n @for (tab of tabs(); track $index) {\n <button\n type=\"button\"\n role=\"tab\"\n class=\"tab-item tab-link focus-inside\"\n [class.tab-active]=\"activeTabIndex() === $index\"\n (click)=\"activateTab($index)\"\n (keydown.enter)=\"activateTab($index)\"\n >\n {{ tab.heading }}\n </button>\n }\n </div>\n </div>\n }\n</div>\n\n@if (mode() !== 'editor') {\n <si-live-preview-renderer #renderer />\n} @else {\n <si-live-preview />\n}\n", styles: [".lp-tabs{display:flex;flex-wrap:wrap;padding-inline-start:0;margin:0;list-style:none;background:none;inline-size:inherit;font-weight:700}.lp-tabs .tab-item:focus-visible{outline-offset:calc(-1 * var(--element-button-focus-width))}.lp-tabs .tab-item.tab-active.tab-link{color:var(--si-sys-color-text-accent);border-block-end-color:var(--si-sys-color-text-accent)!important}.lp-tabs .tab-item.tab-active.tab-link:hover{color:var(--si-sys-color-text-accent-hover)}.lp-tabs .tab-item.tab-link{font:inherit;background:none;min-inline-size:150px;display:block;padding-block:8px;padding-inline:15px;cursor:pointer;text-align:start;line-height:20px;color:var(--si-sys-color-text-primary);border:0;border-block-end:4px solid transparent}.lp-tabs .tab-item.tab-link:hover{text-decoration:none;color:var(--si-sys-color-text-accent-hover);border-block-end-color:var(--si-sys-color-border-4)}*:focus-visible{outline:var(--element-button-focus-width) solid var(--si-sys-color-effects-focus);outline-offset:var(--element-button-focus-overlay-width)}.wrapper{background-color:var(--si-sys-color-background-0);color:var(--si-sys-color-text-primary)}.wrapper.has-tabs .tab-wrapper,.wrapper.has-tabs-mobile{background-color:var(--si-sys-color-background-0)}.tab-wrapper{margin-block-end:10px;border-block-end:1px solid var(--si-sys-color-border-4)}si-live-preview-renderer{flex:1;transform:translate(0)}\n"] }]
2134
- }], ctorParameters: () => [], propDecorators: { renderer: [{ type: i0.ViewChild, args: ['renderer', { isSignal: true }] }] } });
2135
-
2136
- /**
2137
- * Copyright (c) Siemens 2016 - 2026
2138
- * SPDX-License-Identifier: MIT
2139
- */
2140
- class SiLivePreviewWebComponentService {
2141
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiLivePreviewWebComponentService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
2142
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiLivePreviewWebComponentService });
2143
- }
2144
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiLivePreviewWebComponentService, decorators: [{
2145
- type: Injectable
2146
- }] });
2147
-
2148
- /**
2149
- * Copyright (c) Siemens 2016 - 2026
2150
- * SPDX-License-Identifier: MIT
2151
- */
2152
- const filterTargets = ['_self', '_top', '_parent', ''];
2153
- class SiLivePreviewWrapperComponent {
2154
- renderer = viewChild.required('renderer', /* @ts-ignore */
2155
- ...(ngDevMode ? [{ debugName: "renderer" }] : /* istanbul ignore next */ []));
2156
- webcomponentRenderer = viewChild.required('webcomponentRenderer', /* @ts-ignore */
2157
- ...(ngDevMode ? [{ debugName: "webcomponentRenderer" }] : /* istanbul ignore next */ []));
2158
- state = inject(LivePreviewStateService);
2159
- config = inject(SI_LIVE_PREVIEW_CONFIG);
2160
- themeApi = inject(SiLivePreviewThemeApi, { optional: true });
2161
- localeApi = inject(SiLivePreviewLocaleApi, { optional: true });
2162
- internalConfig = inject(SI_LIVE_PREVIEW_INTERNALS);
2163
- ngZone = inject(NgZone);
2164
- webcomponentService = inject(SiLivePreviewWebComponentService, {
2165
- optional: true
2166
- });
2167
- cdRef = inject(ChangeDetectorRef);
2168
- isMobile = false;
2169
- initialUrl;
2170
- constructor() {
2171
- this.themeApi
2172
- ?.getApplicationThemeObservable()
2173
- .pipe(takeUntilDestroyed())
2174
- .subscribe(theme => {
2175
- this.state.theme.set(theme);
2176
- this.sendMessage('theme', theme);
2177
- });
2178
- this.localeApi
2179
- ?.getLocale()
2180
- .pipe(takeUntilDestroyed())
2181
- .subscribe(locale => {
2182
- if (this.state.locale() !== locale) {
2183
- this.state.locale.set(locale);
2184
- this.sendMessage('locale', locale);
2185
- }
2186
- });
2187
- this.initialUrl = window.location.toString();
2188
- this.isMobile = this.internalConfig.isMobile;
2189
- if (this.isMobile) {
2190
- setDeviceMode(this.state.viewport().mode);
2191
- }
2192
- // send ready message only when locale/theme are communicated to avoid loops
2193
- this.sendMessage('ready');
2194
- this.ngZone.runOutsideAngular(() => fromEvent(window, 'message')
2195
- .pipe(takeUntilDestroyed())
2196
- .subscribe(message => {
2197
- this.onMessage(message);
2198
- this.cdRef.markForCheck();
2199
- }));
2200
- }
2201
- onMessage(event) {
2202
- // Render requests can contain executable templates, so the sender must be the same-origin editor.
2203
- if (event.origin !== window.location.origin ||
2204
- event.source !== window.parent ||
2205
- event.data?.src !== 'editor') {
2206
- return;
2207
- }
2208
- this.ngZone.run(() => this.onMessageInZone(event));
2209
- }
2210
- onMessageInZone(event) {
2211
- const modeChanged = this.state.viewport().mode !== event.data.mode;
2212
- this.state.applyRenderRequest(event.data);
2213
- if (this.state.theme() !== event.data.theme) {
2214
- this.setTheme(event.data.theme);
2215
- }
2216
- if (this.state.locale() !== event.data.locale) {
2217
- this.setLocale(event.data.locale);
2218
- }
2219
- if (this.state.rootFontSize() !== event.data.rootFontSize) {
2220
- this.state.rootFontSize.set(event.data.rootFontSize);
2221
- setRootFontSize(event.data.rootFontSize);
2222
- }
2223
- if (this.state.isRTL() !== event.data.isRTL) {
2224
- this.setRTL(event.data.isRTL);
2225
- }
2226
- if (this.isMobile) {
2227
- this.setSafeArea(event.data.safeAreaTop, event.data.safeAreaBottom, event.data.safeAreaLeft, event.data.safeAreaRight);
2228
- }
2229
- if (modeChanged && this.isMobile) {
2230
- setDeviceMode(event.data.mode);
2231
- this.renderer().recompile();
2232
- }
2233
- const webcomponentRenderer = this.webcomponentRenderer();
2234
- if (webcomponentRenderer &&
2235
- (this.state.loadReact() || this.state.loadVue() || this.state.loadJs())) {
2236
- this.webcomponentService?.injectComponent(webcomponentRenderer, {
2237
- exampleUrl: this.config.examplesBaseUrl + this.state.example(),
2238
- loadReact: this.state.loadReact(),
2239
- loadJs: this.state.loadJs(),
2240
- webcomponentTemplateCode: this.state.activeWebComponentTemplate(),
2241
- loadVue: this.state.loadVue(),
2242
- config: this.config
2243
- }, {
2244
- inProgress: this.sendMessage
2245
- });
2246
- }
2247
- else {
2248
- this.webcomponentService?.destroyComponent();
2249
- }
2250
- }
2251
- onClick(event) {
2252
- const target = event?.target;
2253
- if (target?.tagName === 'A' && !event.defaultPrevented) {
2254
- // for normal link: ok if it starts with the proper route, else open in a new window
2255
- const newUrl = target.href;
2256
- const linkTarget = target.target;
2257
- if (newUrl && !newUrl.startsWith(this.initialUrl) && filterTargets.includes(linkTarget)) {
2258
- event.preventDefault();
2259
- window.open(newUrl, '_blank', 'noopener,noreferrer');
2260
- }
2261
- }
2262
- }
2263
- sendMessage(type, message) {
2264
- window.parent.postMessage({ src: 'renderer', type, message }, window.location.origin);
2265
- }
2266
- setTheme(theme) {
2267
- this.state.theme.set(theme);
2268
- if (this.themeApi) {
2269
- this.themeApi.setThemeFromPreviewer(theme);
2270
- }
2271
- else {
2272
- document.documentElement.classList.toggle('app--dark', theme === 'dark');
2273
- document.documentElement.classList.toggle('app--light', theme === 'light');
2274
- }
2275
- }
2276
- setRTL(rtl) {
2277
- this.state.isRTL.set(rtl);
2278
- setDirectionRtl(rtl);
2279
- }
2280
- setLocale(locale) {
2281
- if (!locale) {
2282
- return;
2283
- }
2284
- this.state.locale.set(locale);
2285
- if (this.localeApi) {
2286
- this.localeApi.setLocale(locale);
2287
- }
2288
- }
2289
- setSafeArea(top, bottom, left, right) {
2290
- const htmlTag = document.documentElement;
2291
- htmlTag.style.setProperty('--ion-safe-area-top', (top ?? 0) + 'px');
2292
- htmlTag.style.setProperty('--ion-safe-area-bottom', (bottom ?? 0) + 'px');
2293
- htmlTag.style.setProperty('--ion-safe-area-left', (left ?? 0) + 'px');
2294
- htmlTag.style.setProperty('--ion-safe-area-right', (right ?? 0) + 'px');
2295
- }
2296
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiLivePreviewWrapperComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
2297
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "22.0.8", type: SiLivePreviewWrapperComponent, isStandalone: true, selector: "si-live-preview-wrapper", host: { listeners: { "click": "onClick($event)" } }, viewQueries: [{ propertyName: "renderer", first: true, predicate: ["renderer"], descendants: true, isSignal: true }, { propertyName: "webcomponentRenderer", first: true, predicate: ["webcomponentRenderer"], descendants: true, isSignal: true }], ngImport: i0, template: "<si-live-preview-renderer\n #renderer\n [hidden]=\"state.loadReact() || state.loadVue() || state.loadJs()\"\n (templateFromComponent)=\"sendMessage('templateFromComponent', $event)\"\n (logClear)=\"sendMessage('clear')\"\n (logMessage)=\"sendMessage('log', $event)\"\n (logRenderingError)=\"sendMessage('error', $event)\"\n (inProgress)=\"sendMessage('progress', $event)\"\n (supportsLandscapeMode)=\"sendMessage('landscapeMode', $event)\"\n/>\n\n<div #webcomponentRenderer></div>\n", styles: ["si-live-preview-renderer{flex:1}\n"], dependencies: [{ kind: "component", type: SiLivePreviewRendererComponent, selector: "si-live-preview-renderer", outputs: ["templateFromComponent", "logClear", "logMessage", "logRenderingError", "inProgress", "supportsLandscapeMode"] }], changeDetection: i0.ChangeDetectionStrategy.Eager });
2298
- }
2299
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiLivePreviewWrapperComponent, decorators: [{
2300
- type: Component,
2301
- args: [{ selector: 'si-live-preview-wrapper', imports: [SiLivePreviewRendererComponent], changeDetection: ChangeDetectionStrategy.Eager, host: {
2302
- '(click)': 'onClick($event)'
2303
- }, template: "<si-live-preview-renderer\n #renderer\n [hidden]=\"state.loadReact() || state.loadVue() || state.loadJs()\"\n (templateFromComponent)=\"sendMessage('templateFromComponent', $event)\"\n (logClear)=\"sendMessage('clear')\"\n (logMessage)=\"sendMessage('log', $event)\"\n (logRenderingError)=\"sendMessage('error', $event)\"\n (inProgress)=\"sendMessage('progress', $event)\"\n (supportsLandscapeMode)=\"sendMessage('landscapeMode', $event)\"\n/>\n\n<div #webcomponentRenderer></div>\n", styles: ["si-live-preview-renderer{flex:1}\n"] }]
2304
- }], ctorParameters: () => [], propDecorators: { renderer: [{ type: i0.ViewChild, args: ['renderer', { isSignal: true }] }], webcomponentRenderer: [{ type: i0.ViewChild, args: ['webcomponentRenderer', { isSignal: true }] }] } });
2305
-
2306
- /**
2307
- * Copyright (c) Siemens 2016 - 2026
2308
- * SPDX-License-Identifier: MIT
2309
- */
2310
- const livePreviewRoutes = [
2311
- {
2312
- path: 'overview',
2313
- children: [{ path: '**', component: SiExampleOverviewComponent }]
2314
- },
2315
- {
2316
- path: 'viewer/:mode',
2317
- component: SiExampleViewerComponent,
2318
- children: [{ path: '**', component: SiDummyComponent }]
2319
- },
2320
- {
2321
- path: 'iframe',
2322
- component: SiLivePreviewWrapperComponent,
2323
- children: [{ path: '**', component: SiDummyComponent }]
2324
- },
2325
- { path: '', redirectTo: 'viewer/editor', pathMatch: 'full' },
2326
- { path: '**', component: SiExampleViewerComponent }
2327
- ];
2328
- class SiLivePreviewRoutingModule {
2329
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiLivePreviewRoutingModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2330
- static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "22.0.8", ngImport: i0, type: SiLivePreviewRoutingModule, imports: [i1$1.RouterModule], exports: [RouterModule] });
2331
- static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiLivePreviewRoutingModule, imports: [RouterModule.forRoot(livePreviewRoutes, { useHash: true }), RouterModule] });
2332
- }
2333
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiLivePreviewRoutingModule, decorators: [{
2334
- type: NgModule,
2335
- args: [{
2336
- imports: [RouterModule.forRoot(livePreviewRoutes, { useHash: true })],
2337
- exports: [RouterModule]
2338
- }]
2339
- }] });
2340
-
2341
- /**
2342
- * Copyright (c) Siemens 2016 - 2026
2343
- * SPDX-License-Identifier: MIT
2344
- */
2345
- /** A router location that is private to a rendered example application. */
2346
- class ExampleLocationStrategy extends LocationStrategy {
2347
- currentPath = '/';
2348
- state = null;
2349
- path() {
2350
- return this.currentPath;
2351
- }
2352
- prepareExternalUrl(internal) {
2353
- return internal;
2354
- }
2355
- getState() {
2356
- return this.state;
2357
- }
2358
- pushState(state, _title, url, queryParams) {
2359
- this.state = state;
2360
- this.currentPath = url + queryParams;
2361
- }
2362
- replaceState(state, _title, url, queryParams) {
2363
- this.state = state;
2364
- this.currentPath = url + queryParams;
2365
- }
2366
- forward() { }
2367
- back() { }
2368
- onPopState(_fn) { }
2369
- getBaseHref() {
2370
- return '';
2371
- }
2372
- }
2373
-
2374
- /**
2375
- * Copyright (c) Siemens 2016 - 2026
2376
- * SPDX-License-Identifier: MIT
2377
- */
2378
- /**
2379
- * Runtime shell that renders each example in an independent Angular application.
2380
- * The example application owns its router and does not modify the live-preview router.
2381
- */
2382
- class SiLivePreviewApplicationRuntimeComponent extends SiLivePreviewRuntimeComponent {
2383
- applicationConfig = inject(SI_LIVE_PREVIEW_CONFIG);
2384
- parentInjector = inject(Injector);
2385
- exampleComponentRef;
2386
- applicationRef;
2387
- hostElement;
2388
- destroyed = false;
2389
- ngAfterViewInit() {
2390
- this.createExampleApplication();
2391
- }
2392
- ngOnDestroy() {
2393
- this.destroyed = true;
2394
- this.exampleComponentRef?.destroy();
2395
- this.exampleComponentRef = undefined;
2396
- this.applicationRef?.destroy();
2397
- this.hostElement?.remove();
2398
- }
2399
- async createExampleApplication() {
2400
- try {
2401
- const locationStrategy = new ExampleLocationStrategy();
2402
- const configuredApplication = this.applicationConfig.exampleApplicationConfig;
2403
- const exampleApplicationConfig = typeof configuredApplication === 'function'
2404
- ? configuredApplication(this.parentInjector)
2405
- : configuredApplication;
2406
- this.applicationRef = await createApplication({
2407
- ...exampleApplicationConfig,
2408
- providers: [
2409
- ...(exampleApplicationConfig?.providers ?? []),
2410
- provideRouter([], withDisabledInitialNavigation()),
2411
- { provide: LocationStrategy, useValue: locationStrategy },
2412
- {
2413
- provide: Location,
2414
- useFactory: () => new Location(inject(LocationStrategy))
2415
- },
2416
- {
2417
- provide: LOG_EVENT,
2418
- useFactory: () => this.parentInjector.get(LOG_EVENT)
2419
- },
2420
- {
2421
- provide: ErrorHandler,
2422
- useValue: { handleError: (error) => this.handleError(error) }
2423
- }
2424
- ]
2425
- });
2426
- if (this.destroyed) {
2427
- this.applicationRef.destroy();
2428
- return;
2429
- }
2430
- this.exampleComponentRef = createComponent(this.component(), {
2431
- environmentInjector: this.applicationRef.injector
2432
- });
2433
- this.hostElement = this.exampleComponentRef.location.nativeElement;
2434
- const anchor = this.container().element.nativeElement;
2435
- anchor.parentNode?.insertBefore(this.hostElement, anchor);
2436
- const exampleRoutes = this.exampleComponentRef.injector.get(SI_LIVE_PREVIEW_EXAMPLE_ROUTES, this.applicationConfig.defaultRoutes ?? [{ path: '**', component: SiDummyComponent }], { self: true });
2437
- this.applicationRef.injector.get(Router).resetConfig(exampleRoutes);
2438
- this.applicationRef.attachView(this.exampleComponentRef.hostView);
2439
- this.applicationRef.tick();
2440
- this.ready.emit();
2441
- }
2442
- catch (error) {
2443
- this.handleError(error);
2444
- }
2445
- }
2446
- handleError(error) {
2447
- this.renderingError.emit(error instanceof Error ? error : new Error(String(error)));
2448
- }
2449
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiLivePreviewApplicationRuntimeComponent, deps: null, target: i0.ɵɵFactoryTarget.Directive });
2450
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.8", type: SiLivePreviewApplicationRuntimeComponent, isStandalone: true, usesInheritance: true, ngImport: i0 });
2451
- }
2452
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiLivePreviewApplicationRuntimeComponent, decorators: [{
2453
- type: Directive
2454
- }] });
2455
-
2456
- /**
2457
- * Copyright (c) Siemens 2016 - 2026
2458
- * SPDX-License-Identifier: MIT
2459
- */
2460
- /** Default shell that renders an example in an independent Angular application. */
2461
- class SiDefaultLivePreviewApplicationRuntimeComponent extends SiLivePreviewApplicationRuntimeComponent {
2462
- container = viewChild.required('container', { ...(ngDevMode ? { debugName: "container" } : /* istanbul ignore next */ {}), read: ViewContainerRef });
2463
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiDefaultLivePreviewApplicationRuntimeComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
2464
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "22.0.8", type: SiDefaultLivePreviewApplicationRuntimeComponent, isStandalone: true, selector: "si-live-preview-application-runtime", viewQueries: [{ propertyName: "container", first: true, predicate: ["container"], descendants: true, read: ViewContainerRef, isSignal: true }], usesInheritance: true, ngImport: i0, template: '<ng-container #container />', isInline: true });
2465
- }
2466
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiDefaultLivePreviewApplicationRuntimeComponent, decorators: [{
2467
- type: Component,
2468
- args: [{
2469
- selector: 'si-live-preview-application-runtime',
2470
- template: '<ng-container #container />'
2471
- }]
2472
- }], propDecorators: { container: [{ type: i0.ViewChild, args: ['container', { ...{ read: ViewContainerRef }, isSignal: true }] }] } });
2473
-
2474
- /**
2475
- * Copyright (c) Siemens 2016 - 2026
2476
- * SPDX-License-Identifier: MIT
2477
- */
2478
- /**
2479
- * Configures live preview with each example rendered in an independent Angular application.
2480
- */
2481
- const provideLivePreview = (config, isMobile = false) => {
2482
- return makeEnvironmentProviders([
2483
- provideRouter(livePreviewRoutes, withHashLocation()),
2484
- {
2485
- provide: SI_LIVE_PREVIEW_CONFIG,
2486
- useValue: {
2487
- ...config,
2488
- runtimeComponent: config.runtimeComponent ?? SiDefaultLivePreviewApplicationRuntimeComponent
2489
- }
2490
- },
2491
- {
2492
- provide: SI_LIVE_PREVIEW_INTERNALS,
2493
- useValue: { isMobile, titleBase: 'Overview - Live Preview' }
2494
- }
2495
- ]);
2496
- };
2497
-
2498
- /**
2499
- * Copyright (c) Siemens 2016 - 2026
2500
- * SPDX-License-Identifier: MIT
2501
- */
2502
- class SiLivePreviewModule {
2503
- static forRoot(config, isMobile = false) {
2504
- return {
2505
- ngModule: SiLivePreviewModule,
2506
- providers: [
2507
- { provide: SI_LIVE_PREVIEW_CONFIG, useValue: config },
2508
- {
2509
- provide: SI_LIVE_PREVIEW_INTERNALS,
2510
- useValue: { isMobile, titleBase: 'Overview - Live Preview' }
2511
- }
2512
- ]
2513
- };
2514
- }
2515
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiLivePreviewModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2516
- static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "22.0.8", ngImport: i0, type: SiLivePreviewModule });
2517
- static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiLivePreviewModule, providers: [{ provide: REMOVE_STYLES_ON_COMPONENT_DESTROY, useValue: true }] });
2518
- }
2519
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiLivePreviewModule, decorators: [{
2520
- type: NgModule,
2521
- args: [{
2522
- providers: [{ provide: REMOVE_STYLES_ON_COMPONENT_DESTROY, useValue: true }]
2523
- }]
2524
- }] });
2525
-
2526
- /**
2527
- * Copyright (c) Siemens 2016 - 2026
2528
- * SPDX-License-Identifier: MIT
2529
- */
2530
- // Public API Surface
2531
-
2532
- /**
2533
- * Generated bundle index. Do not edit.
2534
- */
2535
-
2536
- export { LOG_EVENT, LandscapeSupportService, SI_LIVE_PREVIEW_CONFIG, SI_LIVE_PREVIEW_EXAMPLE_ROUTES, SI_LIVE_PREVIEW_INTERNALS, SI_STACKBLITZ_CONFIG, SiDummyComponent, SiLivePreviewApplicationRuntimeComponent, SiLivePreviewLocaleApi, SiLivePreviewModule, SiLivePreviewRoutingModule, SiLivePreviewRuntimeComponent, SiLivePreviewThemeApi, SiLivePreviewWebComponentService, SiLivePreviewModule as SimplLivePreviewModule, SiLivePreviewRoutingModule as SimplLivePreviewRoutingModule, angularTemplateProject, livePreviewRoutes, provideExampleRoutes, provideLivePreview, provideStackblitzConfig };
1
+ export { f as LOG_EVENT, g as LandscapeSupportService, S as SI_LIVE_PREVIEW_CONFIG, h as SI_LIVE_PREVIEW_EXAMPLE_ROUTES, a as SI_LIVE_PREVIEW_INTERNALS, d as SI_STACKBLITZ_CONFIG, i as SiDocsComponentComponent, j as SiDummyComponent, k as SiLivePreviewApplicationRuntimeComponent, e as SiLivePreviewLocaleApi, l as SiLivePreviewModule, m as SiLivePreviewRoutingModule, n as SiLivePreviewRuntimeComponent, o as SiLivePreviewThemeApi, p as SiLivePreviewWebComponentService, l as SimplLivePreviewModule, m as SimplLivePreviewRoutingModule, q as angularTemplateProject, r as livePreviewRoutes, s as provideExampleRoutes, t as provideLivePreview, u as provideStackblitzConfig } from './siemens-live-preview-siemens-live-preview-BU--ZYJz.mjs';
2537
2
  //# sourceMappingURL=siemens-live-preview.mjs.map