@siemens/live-preview 51.7.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,2681 +1,2 @@
1
- import * as i0 from '@angular/core';
2
- import { inject, ChangeDetectorRef, ChangeDetectionStrategy, Component, InjectionToken, computed, signal, effect, Service, DOCUMENT, Injectable, viewChild, output, input, NgZone, DestroyRef, Directive, ElementRef, untracked, ViewContainerRef, Compiler, Injector, afterNextRender, ɵcompileComponent as _compileComponent, ɵresetCompiledComponents as _resetCompiledComponents, inputBinding, NgModule, ErrorHandler, createComponent, makeEnvironmentProviders, numberAttribute, ViewEncapsulation } 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 { DomSanitizer, 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, { optional: true });
64
- overviewExample = computed(() => {
65
- this.router?.lastSuccessfulNavigation();
66
- const route = this.router && 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 LivePreviewUrlService {
249
- config = inject(SI_LIVE_PREVIEW_CONFIG);
250
- state = inject(LivePreviewStateService);
251
- document = inject(DOCUMENT);
252
- // Keep resolution at runtime to avoid Vite rewriting '.' as a filesystem asset.
253
- applicationUrl = new URL('.', new URL(import.meta.url));
254
- origin = this.applicationUrl.origin;
255
- iframeUrl = this.routeUrl('iframe', new URLSearchParams({ parentOrigin: this.document.location.origin }));
256
- examplesBaseUrl = new URL(this.config.examplesBaseUrl, this.applicationUrl).href;
257
- sourceUrl(path) {
258
- return new URL(path, this.examplesBaseUrl).href;
259
- }
260
- viewerUrl(mode, options = {}) {
261
- const parameters = new URLSearchParams({ theme: this.state.theme() });
262
- if (this.state.isRTL()) {
263
- parameters.set('isRTL', 'true');
264
- }
265
- const locale = this.state.locale();
266
- if (locale) {
267
- parameters.set('locale', locale);
268
- }
269
- const rootFontSize = this.state.rootFontSize();
270
- if (rootFontSize) {
271
- parameters.set('rfs', String(rootFontSize));
272
- }
273
- if (options.deviceMode) {
274
- parameters.set('mode', options.deviceMode);
275
- }
276
- if (!options.skipTemplate) {
277
- const framework = this.state.framework();
278
- if (framework !== 'angular') {
279
- parameters.set('t', this.state.activeWebComponentTemplate());
280
- parameters.set('framework', framework);
281
- }
282
- else if (this.state.templateModified()) {
283
- parameters.set('t', this.state.template());
284
- }
285
- }
286
- const example = this.state.example();
287
- if (example) {
288
- parameters.set('e', example);
289
- }
290
- return this.routeUrl(`viewer/${mode}`, parameters);
291
- }
292
- issueUrl(template) {
293
- const url = new URL(this.config.ticketBaseUrl, this.document.baseURI);
294
- url.searchParams.set('issue[title]', `<${this.state.example()}>:`);
295
- url.searchParams.set('issuable_template', template);
296
- return url.href;
297
- }
298
- routeUrl(route, parameters = new URLSearchParams()) {
299
- const url = new URL(this.applicationUrl);
300
- url.hash = `/${route}${parameters.size ? '?' + parameters : ''}`;
301
- return url.href;
302
- }
303
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: LivePreviewUrlService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
304
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: LivePreviewUrlService, providedIn: 'root' });
305
- }
306
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: LivePreviewUrlService, decorators: [{
307
- type: Injectable,
308
- args: [{ providedIn: 'root' }]
309
- }] });
310
-
311
- /**
312
- * Copyright (c) Siemens 2016 - 2026
313
- * SPDX-License-Identifier: MIT
314
- */
315
- class SiLivePreviewIframeModeComponent {
316
- previewUrl = inject(DomSanitizer).bypassSecurityTrustResourceUrl(inject(LivePreviewUrlService).iframeUrl);
317
- previewIframe = viewChild.required('previewIframe', /* @ts-ignore */
318
- ...(ngDevMode ? [{ debugName: "previewIframe" }] : /* istanbul ignore next */ []));
319
- iframeChange = output();
320
- ngAfterViewInit() {
321
- this.iframeChange.emit(this.previewIframe());
322
- }
323
- ngOnDestroy() {
324
- this.iframeChange.emit(undefined);
325
- }
326
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiLivePreviewIframeModeComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
327
- 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 title="Example view" [src]="previewUrl"></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"] });
328
- }
329
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiLivePreviewIframeModeComponent, decorators: [{
330
- type: Component,
331
- args: [{ selector: 'si-live-preview-iframe-mode', template: `<iframe #previewIframe title="Example view" [src]="previewUrl"></iframe>`, styles: [":host{display:block;flex:1;min-block-size:0}iframe{border:0;display:block;block-size:100%;inline-size:100%}\n"] }]
332
- }], propDecorators: { previewIframe: [{ type: i0.ViewChild, args: ['previewIframe', { isSignal: true }] }], iframeChange: [{ type: i0.Output, args: ["iframeChange"] }] } });
333
-
334
- /**
335
- * Copyright (c) Siemens 2016 - 2026
336
- * SPDX-License-Identifier: MIT
337
- */
338
- class SiLivePreviewQrComponent {
339
- url = input(/* @ts-ignore */
340
- ...(ngDevMode ? [undefined, { debugName: "url" }] : /* istanbul ignore next */ []));
341
- urlShort = input(/* @ts-ignore */
342
- ...(ngDevMode ? [undefined, { debugName: "urlShort" }] : /* istanbul ignore next */ []));
343
- closed = output();
344
- qrImg = computed(() => {
345
- const url = this.url();
346
- const urlShort = this.urlShort();
347
- if (!url || !urlShort) {
348
- return null;
349
- }
350
- const qr = qrcode(0, 'L');
351
- qr.addData(this.qrShort() ? urlShort : url);
352
- qr.make();
353
- return qr.createImgTag(2);
354
- }, /* @ts-ignore */
355
- ...(ngDevMode ? [{ debugName: "qrImg" }] : /* istanbul ignore next */ []));
356
- qrShort = computed(() => (this.url()?.length ?? 0) > 2953, /* @ts-ignore */
357
- ...(ngDevMode ? [{ debugName: "qrShort" }] : /* istanbul ignore next */ []));
358
- unlisten;
359
- ngAfterViewInit() {
360
- const listener = () => this.closed.emit();
361
- setTimeout(() => window.addEventListener('click', listener));
362
- this.unlisten = () => window.removeEventListener('click', listener);
363
- }
364
- ngOnDestroy() {
365
- if (this.unlisten) {
366
- this.unlisten();
367
- }
368
- }
369
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiLivePreviewQrComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
370
- 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(--si-sys-sizing-focus-ring-width, 2px) solid var(--si-sys-color-effects-focus);outline-offset:var(--si-sys-sizing-focus-ring-offset, 1px)}: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 });
371
- }
372
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiLivePreviewQrComponent, decorators: [{
373
- type: Component,
374
- 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(--si-sys-sizing-focus-ring-width, 2px) solid var(--si-sys-color-effects-focus);outline-offset:var(--si-sys-sizing-focus-ring-offset, 1px)}: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"] }]
375
- }], 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"] }] } });
376
-
377
- const availableDevices = [
378
- {
379
- id: 'iphone-12-pro',
380
- mode: 'ios',
381
- name: 'iPhone 12 / 12 Pro',
382
- height: '844',
383
- width: '390',
384
- notch: true,
385
- safeAreaPortrait: { top: 44, bottom: 34, left: 0, right: 0 },
386
- safeAreaLandscape: { top: 0, bottom: 21, left: 44, right: 44 }
387
- },
388
- {
389
- id: 'iphone-11-pro',
390
- mode: 'ios',
391
- name: 'iPhone 11 Pro',
392
- height: '812',
393
- width: '375',
394
- notch: true,
395
- safeAreaPortrait: { top: 44, bottom: 34, left: 0, right: 0 },
396
- safeAreaLandscape: { top: 0, bottom: 21, left: 44, right: 44 }
397
- },
398
- {
399
- id: 'iphone-11',
400
- mode: 'ios',
401
- name: 'iPhone 11',
402
- height: '896',
403
- width: '414',
404
- notch: true,
405
- safeAreaPortrait: { top: 44, bottom: 34, left: 0, right: 0 },
406
- safeAreaLandscape: { top: 0, bottom: 21, left: 44, right: 44 }
407
- },
408
- {
409
- id: 'iphone-x',
410
- mode: 'ios',
411
- name: 'iPhone X / XS',
412
- height: '812',
413
- width: '375',
414
- notch: true,
415
- safeAreaPortrait: { top: 44, bottom: 34, left: 0, right: 0 },
416
- safeAreaLandscape: { top: 0, bottom: 21, left: 44, right: 44 }
417
- },
418
- {
419
- id: 'iphone-8',
420
- mode: 'ios',
421
- name: 'iPhone 8',
422
- height: '667',
423
- width: '375',
424
- safeAreaPortrait: { top: 20, bottom: 0, left: 0, right: 0 },
425
- safeAreaLandscape: { top: 0, bottom: 0, left: 0, right: 0 }
426
- },
427
- {
428
- id: 'samsung-gal-s20',
429
- mode: 'md',
430
- name: 'Samsung Galaxy S20',
431
- height: '800',
432
- width: '360',
433
- safeAreaPortrait: { top: 20, bottom: 10, left: 0, right: 0 },
434
- safeAreaLandscape: { top: 20, bottom: 10, left: 0, right: 0 }
435
- },
436
- {
437
- id: 'samsung-gal-s10',
438
- mode: 'md',
439
- name: 'Samsung Galaxy S10',
440
- height: '760',
441
- width: '360',
442
- safeAreaPortrait: { top: 20, bottom: 10, left: 0, right: 0 },
443
- safeAreaLandscape: { top: 20, bottom: 10, left: 0, right: 0 }
444
- },
445
- {
446
- id: 'samsung-gal-s9',
447
- mode: 'md',
448
- name: 'Samsung Galaxy S9',
449
- height: '740',
450
- width: '360',
451
- safeAreaPortrait: { top: 20, bottom: 10, left: 0, right: 0 },
452
- safeAreaLandscape: { top: 20, bottom: 10, left: 0, right: 0 }
453
- },
454
- {
455
- id: 'samsung-gal-note10',
456
- mode: 'md',
457
- name: 'Samsung Galaxy Note 10',
458
- height: '869',
459
- width: '412',
460
- safeAreaPortrait: { top: 20, bottom: 10, left: 0, right: 0 },
461
- safeAreaLandscape: { top: 20, bottom: 10, left: 0, right: 0 }
462
- }
463
- ];
464
-
465
- /**
466
- * Copyright (c) Siemens 2016 - 2026
467
- * SPDX-License-Identifier: MIT
468
- */
469
- class SiLivePreviewMobileModeComponent {
470
- previewIframe = viewChild.required('previewIframe', /* @ts-ignore */
471
- ...(ngDevMode ? [{ debugName: "previewIframe" }] : /* istanbul ignore next */ []));
472
- config = inject(SI_LIVE_PREVIEW_CONFIG);
473
- urls = inject(LivePreviewUrlService);
474
- previewUrl = inject(DomSanitizer).bypassSecurityTrustResourceUrl(this.urls.iframeUrl);
475
- state = inject(LivePreviewStateService);
476
- iframeChange = output();
477
- switcherEnabled = this.config.themeSwitcher;
478
- landscapeEnabled = this.config.landscapeToggle;
479
- availableDevices = availableDevices;
480
- selectedDevice = signal(undefined, /* @ts-ignore */
481
- ...(ngDevMode ? [{ debugName: "selectedDevice" }] : /* istanbul ignore next */ []));
482
- landscape = signal(false, /* @ts-ignore */
483
- ...(ngDevMode ? [{ debugName: "landscape" }] : /* istanbul ignore next */ []));
484
- showQrMenu = signal(false, /* @ts-ignore */
485
- ...(ngDevMode ? [{ debugName: "showQrMenu" }] : /* istanbul ignore next */ []));
486
- plainUrl = signal('', /* @ts-ignore */
487
- ...(ngDevMode ? [{ debugName: "plainUrl" }] : /* istanbul ignore next */ []));
488
- plainUrlShort = signal('', /* @ts-ignore */
489
- ...(ngDevMode ? [{ debugName: "plainUrlShort" }] : /* istanbul ignore next */ []));
490
- mode = computed(() => this.selectedDevice()?.mode ?? 'ios', /* @ts-ignore */
491
- ...(ngDevMode ? [{ debugName: "mode" }] : /* istanbul ignore next */ []));
492
- showNotch = computed(() => this.selectedDevice()?.notch ?? false, /* @ts-ignore */
493
- ...(ngDevMode ? [{ debugName: "showNotch" }] : /* istanbul ignore next */ []));
494
- currentIFrameHeight = computed(() => {
495
- const device = this.selectedDevice();
496
- return device ? (this.landscape() ? device.width : device.height) : this.state.iFrameHeight();
497
- }, /* @ts-ignore */
498
- ...(ngDevMode ? [{ debugName: "currentIFrameHeight" }] : /* istanbul ignore next */ []));
499
- currentIFrameWidth = computed(() => {
500
- const device = this.selectedDevice();
501
- return device ? (this.landscape() ? device.height : device.width) : this.state.iFrameWidth();
502
- }, /* @ts-ignore */
503
- ...(ngDevMode ? [{ debugName: "currentIFrameWidth" }] : /* istanbul ignore next */ []));
504
- constructor() {
505
- effect(() => {
506
- if (!this.state.supportsLandscape() && this.landscape()) {
507
- this.landscape.set(false);
508
- this.emitViewport();
509
- }
510
- });
511
- }
512
- ngOnInit() {
513
- const deviceId = localStorage.getItem('si-live-preview-selected-device');
514
- this.selectDevice(this.availableDevices.find(device => device.id === deviceId));
515
- }
516
- ngAfterViewInit() {
517
- this.iframeChange.emit(this.previewIframe());
518
- }
519
- ngOnDestroy() {
520
- this.iframeChange.emit(undefined);
521
- }
522
- selectDevice(device) {
523
- const selectedDevice = device ?? this.availableDevices[0];
524
- this.selectedDevice.set(selectedDevice);
525
- localStorage.setItem('si-live-preview-selected-device', selectedDevice.id);
526
- this.emitViewport();
527
- }
528
- deviceChanged() {
529
- this.selectDevice(this.selectedDevice());
530
- }
531
- toggleLandscape() {
532
- this.landscape.update(landscape => !landscape);
533
- this.emitViewport();
534
- }
535
- openQrMenu() {
536
- this.plainUrl.set(this.urls.viewerUrl('plain', { deviceMode: this.mode() }));
537
- this.plainUrlShort.set(this.urls.viewerUrl('plain', { deviceMode: this.mode(), skipTemplate: true }));
538
- this.showQrMenu.set(true);
539
- }
540
- emitViewport() {
541
- const device = this.selectedDevice();
542
- const safeArea = this.landscape() ? device?.safeAreaLandscape : device?.safeAreaPortrait;
543
- this.state.viewport.set({
544
- mode: this.mode(),
545
- safeAreaTop: safeArea?.top,
546
- safeAreaBottom: safeArea?.bottom,
547
- safeAreaLeft: safeArea?.left,
548
- safeAreaRight: safeArea?.right
549
- });
550
- }
551
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiLivePreviewMobileModeComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
552
- 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 title=\"Mobile example view\"\n [src]=\"previewUrl\"\n [height]=\"currentIFrameHeight()\"\n [width]=\"currentIFrameWidth()\"\n ></iframe>\n </div>\n</div>\n", styles: ["*:focus-visible{outline:var(--si-sys-sizing-focus-ring-width, 2px) solid var(--si-sys-color-effects-focus);outline-offset:var(--si-sys-sizing-focus-ring-offset, 1px)}: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"] }] });
553
- }
554
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiLivePreviewMobileModeComponent, decorators: [{
555
- type: Component,
556
- 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 title=\"Mobile example view\"\n [src]=\"previewUrl\"\n [height]=\"currentIFrameHeight()\"\n [width]=\"currentIFrameWidth()\"\n ></iframe>\n </div>\n</div>\n", styles: ["*:focus-visible{outline:var(--si-sys-sizing-focus-ring-width, 2px) solid var(--si-sys-color-effects-focus);outline-offset:var(--si-sys-sizing-focus-ring-offset, 1px)}: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"] }]
557
- }], ctorParameters: () => [], propDecorators: { previewIframe: [{ type: i0.ViewChild, args: ['previewIframe', { isSignal: true }] }], iframeChange: [{ type: i0.Output, args: ["iframeChange"] }] } });
558
-
559
- /**
560
- * Copyright (c) Siemens 2016 - 2026
561
- * SPDX-License-Identifier: MIT
562
- */
563
- class SiLivePreviewIframeComponent {
564
- isFullscreen = input(false, /* @ts-ignore */
565
- ...(ngDevMode ? [{ debugName: "isFullscreen" }] : /* istanbul ignore next */ []));
566
- templateFromComponent = output();
567
- state = inject(LivePreviewStateService);
568
- rendererInProgress = false;
569
- previewIframeRef = signal(undefined, /* @ts-ignore */
570
- ...(ngDevMode ? [{ debugName: "previewIframeRef" }] : /* istanbul ignore next */ []));
571
- rendererReady = signal(false, /* @ts-ignore */
572
- ...(ngDevMode ? [{ debugName: "rendererReady" }] : /* istanbul ignore next */ []));
573
- previewIframe = this.previewIframeRef.asReadonly();
574
- internalConfig = inject(SI_LIVE_PREVIEW_INTERNALS);
575
- urls = inject(LivePreviewUrlService);
576
- ngZone = inject(NgZone);
577
- destroyRef = inject(DestroyRef);
578
- cdRef = inject(ChangeDetectorRef);
579
- isMobile = this.internalConfig.isMobile;
580
- ticketLinkBug = computed(() => this.urls.issueUrl('Bug'), /* @ts-ignore */
581
- ...(ngDevMode ? [{ debugName: "ticketLinkBug" }] : /* istanbul ignore next */ []));
582
- ticketLinkFeature = computed(() => this.urls.issueUrl('Feature Request'), /* @ts-ignore */
583
- ...(ngDevMode ? [{ debugName: "ticketLinkFeature" }] : /* istanbul ignore next */ []));
584
- constructor() {
585
- effect(() => {
586
- // recompute on template changes and re-send whenever any rendered input changes
587
- if (this.previewIframe()) {
588
- this.sendMessage();
589
- }
590
- });
591
- }
592
- ngOnInit() {
593
- this.ngZone.runOutsideAngular(() => fromEvent(window, 'message')
594
- .pipe(takeUntilDestroyed(this.destroyRef))
595
- .subscribe(message => {
596
- this.onMessage(message);
597
- this.cdRef.markForCheck();
598
- }));
599
- }
600
- onMessage(event) {
601
- const previewWindow = this.previewIframe()?.nativeElement.contentWindow;
602
- if (!previewWindow ||
603
- event.origin !== this.urls.origin ||
604
- event.source !== previewWindow ||
605
- event.data?.src !== 'renderer') {
606
- return;
607
- }
608
- this.ngZone.run(() => this.onMessageInZone(event));
609
- }
610
- onMessageInZone(event) {
611
- switch (event.data.type) {
612
- case 'ready':
613
- this.rendererReady.set(true);
614
- this.sendMessage();
615
- break;
616
- case 'landscapeMode':
617
- this.state.supportsLandscape.set(event.data.message);
618
- break;
619
- case 'clear':
620
- this.state.clearLogs(true);
621
- break;
622
- case 'log':
623
- this.state.addLog(event.data.message);
624
- break;
625
- case 'error':
626
- this.state.renderingError.set(event.data.message);
627
- break;
628
- case 'progress':
629
- {
630
- const progress = event.data.message;
631
- if (progress !== this.rendererInProgress) {
632
- // only emit changes since live-previewer does counting
633
- this.rendererInProgress = progress;
634
- this.state.setRenderingProgress(progress);
635
- }
636
- }
637
- break;
638
- case 'templateFromComponent':
639
- this.state.originalTemplate.set(event.data.message ?? '');
640
- this.templateFromComponent.emit(event.data.message);
641
- break;
642
- case 'theme':
643
- this.state.theme.set(event.data.message);
644
- break;
645
- case 'locale':
646
- this.state.locale.set(event.data.message);
647
- break;
648
- }
649
- }
650
- toggleTheme() {
651
- this.state.toggleTheme();
652
- this.sendMessage();
653
- }
654
- setPreviewIframe(iframe) {
655
- this.rendererReady.set(false);
656
- this.previewIframeRef.set(iframe);
657
- }
658
- sendMessage() {
659
- if (!this.rendererReady()) {
660
- return;
661
- }
662
- const viewport = this.state.viewport();
663
- this.previewIframe()?.nativeElement.contentWindow.postMessage({
664
- src: 'editor',
665
- exampleUrl: this.state.example(),
666
- template: this.state.template(),
667
- loadReact: this.state.loadReact(),
668
- loadVue: this.state.loadVue(),
669
- loadJs: this.state.loadJs(),
670
- reactVueTemplate: this.state.activeWebComponentTemplate(),
671
- theme: this.state.theme(),
672
- locale: this.state.locale(),
673
- rootFontSize: this.state.rootFontSize(),
674
- isRTL: this.state.isRTL(),
675
- mode: viewport.mode,
676
- safeAreaTop: viewport.safeAreaTop,
677
- safeAreaBottom: viewport.safeAreaBottom,
678
- safeAreaLeft: viewport.safeAreaLeft,
679
- safeAreaRight: viewport.safeAreaRight
680
- }, this.urls.origin);
681
- }
682
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiLivePreviewIframeComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
683
- 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 });
684
- }
685
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiLivePreviewIframeComponent, decorators: [{
686
- type: Component,
687
- args: [{ selector: 'si-live-preview-iframe', imports: [SiLivePreviewIframeModeComponent, SiLivePreviewMobileModeComponent], changeDetection: ChangeDetectionStrategy.Eager, host: {
688
- '[class.is-mobile]': 'isMobile'
689
- }, 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"] }]
690
- }], ctorParameters: () => [], propDecorators: { isFullscreen: [{ type: i0.Input, args: [{ isSignal: true, alias: "isFullscreen", required: false }] }], templateFromComponent: [{ type: i0.Output, args: ["templateFromComponent"] }] } });
691
-
692
- /**
693
- * Copyright (c) Siemens 2016 - 2026
694
- * SPDX-License-Identifier: MIT
695
- */
696
- const isProject = (item) => {
697
- return !Array.isArray(item.files);
698
- };
699
- const isAssetProject = (item) => {
700
- return 'assetUrl' in item;
701
- };
702
- const folder = (path) => path.substring(0, path.lastIndexOf('/') + 1);
703
- const absolute = (base, relative) => {
704
- if (relative.startsWith('./')) {
705
- return `${base}${relative.substring(2)}`;
706
- }
707
- while (relative.startsWith('../')) {
708
- base = base.split('/').slice(0, -2).join('/') + '/';
709
- relative = relative.substring(3);
710
- }
711
- return `${base}${relative}`;
712
- };
713
- const fileName = (path) => path.substring(path.lastIndexOf('/') + 1);
714
- /** Get the base folder for the example files */
715
- const getBaseFolder = (files) => {
716
- for (const path of Object.keys(files)) {
717
- const file = path.split('/').at(-1);
718
- if (file?.includes('example')) {
719
- return folder(path);
720
- }
721
- }
722
- return '';
723
- };
724
- const updateExampleImport = (files, example) => {
725
- const templateExamplePath = Object.keys(files).find(path => path.split('/').at(-1)?.includes('example'));
726
- delete files[templateExamplePath];
727
- const file = fileName(templateExamplePath);
728
- const toReplace = file.substring(0, file.length - 3);
729
- for (const path of Object.keys(files)) {
730
- files[path] = files[path].replace(toReplace, example);
731
- }
732
- return '';
733
- };
734
- const getRelativeImports = (ts) => {
735
- const imports = [];
736
- // Regex to match relative import statements
737
- const relativeImportRegex = /^import\s+[^'"]*\s+from\s+['"](\.\/|\.\.\/)[^'"]+['"];?/gm;
738
- let match;
739
- while ((match = relativeImportRegex.exec(ts)) !== null) {
740
- const importPath = match[0].match(/from\s+['"]([^'"]+)['"]/);
741
- if (importPath?.[1]) {
742
- imports.push(importPath[1]);
743
- }
744
- }
745
- return imports;
746
- };
747
- const getStyleUrls = (ts) => {
748
- const styleUrls = [];
749
- const singleMatch = ts.match(/styleUrl:\s*['"]([^'"]+)['"]/);
750
- if (singleMatch?.[1]) {
751
- styleUrls.push(singleMatch[1]);
752
- }
753
- const pluralMatch = ts.match(/styleUrls:\s*\[([^\]]+)\]/);
754
- if (pluralMatch?.[1]) {
755
- const urls = pluralMatch[1].matchAll(/['"]([^'"]+)['"]/g);
756
- for (const url of urls) {
757
- if (url[1] && !styleUrls.includes(url[1])) {
758
- styleUrls.push(url[1]);
759
- }
760
- }
761
- }
762
- return styleUrls;
763
- };
764
- const addRelativeImports = async (files, baseUrl, baseFolder, path) => {
765
- const ts = files[path];
766
- for (const item of getRelativeImports(ts)) {
767
- const response = await fetch(`${baseUrl}${item}.ts`);
768
- files[absolute(baseFolder, `${item}.ts`)] = await response.text();
769
- }
770
- };
771
- const openStackblitz = async (options) => {
772
- const { framework, templates, example, baseUrl } = options;
773
- const template = templates.find(item => item.name === framework);
774
- if (!template) {
775
- return;
776
- }
777
- // Get template project files
778
- let files = {};
779
- if (isAssetProject(template)) {
780
- for (const file of template.files) {
781
- const response = await fetch(`${template.assetUrl}/${file}`);
782
- files[file] = await response.text();
783
- }
784
- }
785
- else if (isProject(template)) {
786
- files = { ...template.files };
787
- }
788
- const baseFolder = getBaseFolder(files);
789
- const exampleFolder = folder(example);
790
- updateExampleImport(files, example);
791
- // Add example HTML file
792
- const html = await (await fetch(`${baseUrl}${example}.html`)).text();
793
- files[`${baseFolder}${example}.html`] = html;
794
- // Add example TS file
795
- const ts = await (await fetch(`${baseUrl}${example}.ts`)).text();
796
- const tsPath = `${baseFolder}${example}.ts`;
797
- files[tsPath] = ts;
798
- // Add example style files
799
- for (const styleUrl of getStyleUrls(ts)) {
800
- const response = await fetch(absolute(`${baseUrl}${exampleFolder}`, styleUrl));
801
- if (response.ok) {
802
- const stylePath = absolute(`${baseFolder}${exampleFolder}`, styleUrl);
803
- files[stylePath] = await response.text();
804
- }
805
- }
806
- // Get relative imports files
807
- await addRelativeImports(files, `${baseUrl}${exampleFolder}`, `${baseFolder}${exampleFolder}`, tsPath);
808
- sdk.openProject({
809
- title: `Element ${framework} ${example} example`,
810
- template: 'node',
811
- description: 'Blank starter project for building ES6 apps.',
812
- files: { ...files }
813
- }, {
814
- openFile: tsPath
815
- });
816
- };
817
-
818
- /**
819
- * Copyright (c) Siemens 2016 - 2026
820
- * SPDX-License-Identifier: MIT
821
- */
822
- /** Injection token to configure the open in Stackblitz button. */
823
- const SI_STACKBLITZ_CONFIG = new InjectionToken('SI_STACKBLITZ_CONFIG');
824
- /** Provides the Stackblitz configuration with default template projects. */
825
- const provideStackblitzConfig = (config) => ({
826
- provide: SI_STACKBLITZ_CONFIG,
827
- useFactory: () => {
828
- return { templates: [angularTemplateProject()], ...config };
829
- }
830
- });
831
- /**
832
- * Create default Angular template project config.
833
- * The files are loaded from the assets folder, consumers need to add the following asset configuration
834
- * to their angular.json file:
835
- *
836
- * ```json
837
- * "assets": [
838
- * ...
839
- * {
840
- * "glob": "**\/*",
841
- * "input": "projects/live-preview/assets/",
842
- * "output": "/assets/"
843
- * }]
844
- * ```
845
- */
846
- const angularTemplateProject = () => ({
847
- name: 'angular',
848
- assetUrl: 'assets/angular',
849
- files: [
850
- 'angular.json',
851
- 'package.json',
852
- 'tsconfig.json',
853
- 'tsconfig.app.json',
854
- 'src/index.html',
855
- 'src/main.ts',
856
- 'src/app/app.component.ts',
857
- 'src/app/example.component.ts',
858
- 'src/styles.scss'
859
- ]
860
- });
861
-
862
- /**
863
- * Copyright (c) Siemens 2016 - 2026
864
- * SPDX-License-Identifier: MIT
865
- */
866
- class SiStackblitzButtonDirective {
867
- config = inject(SI_STACKBLITZ_CONFIG, { optional: true });
868
- exampleTs = httpResource.text(() => this.example() ? `${this.baseUrl()}${this.example()}.ts` : undefined, /* @ts-ignore */
869
- ...(ngDevMode ? [{ debugName: "exampleTs" }] : /* istanbul ignore next */ []));
870
- isExample = computed(() => {
871
- if (this.exampleTs.hasValue()) {
872
- const content = this.exampleTs.value();
873
- return /selector: 'app-sample'/gm.test(content);
874
- }
875
- return false;
876
- }, /* @ts-ignore */
877
- ...(ngDevMode ? [{ debugName: "isExample" }] : /* istanbul ignore next */ []));
878
- /** Framework to use for the Stackblitz project. */
879
- framework = input.required(/* @ts-ignore */
880
- ...(ngDevMode ? [{ debugName: "framework" }] : /* istanbul ignore next */ []));
881
- /** The example base URL. */
882
- baseUrl = input.required(/* @ts-ignore */
883
- ...(ngDevMode ? [{ debugName: "baseUrl" }] : /* istanbul ignore next */ []));
884
- /** The example name. */
885
- example = input(/* @ts-ignore */
886
- ...(ngDevMode ? [undefined, { debugName: "example" }] : /* istanbul ignore next */ []));
887
- /** Indicate whether a stackblitz isn't available. */
888
- disabled = computed(() => !this.config?.templates.find(item => item.name === this.framework()) ||
889
- !this.example() ||
890
- !this.isExample(), /* @ts-ignore */
891
- ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
892
- /** Open the Stackblitz editor with the specified configuration. */
893
- async openStackblitz() {
894
- await openStackblitz({
895
- framework: this.framework(),
896
- example: this.example(),
897
- templates: this.config.templates,
898
- baseUrl: this.baseUrl()
899
- });
900
- }
901
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiStackblitzButtonDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
902
- 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 });
903
- }
904
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiStackblitzButtonDirective, decorators: [{
905
- type: Directive,
906
- args: [{
907
- selector: 'button[siStackblitz]',
908
- host: {
909
- 'title': 'Open Stackblitz',
910
- 'attr.aria-label': 'Open in Stackblitz',
911
- '[style.display]': '!config ? "none" : null',
912
- '[disabled]': 'disabled()',
913
- '(click)': 'openStackblitz()'
914
- }
915
- }]
916
- }], 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 }] }] } });
917
-
918
- /**
919
- * Copyright (c) Siemens 2016 - 2026
920
- * SPDX-License-Identifier: MIT
921
- */
922
- class SiLivePreviewComponent {
923
- initialTheme = input(/* @ts-ignore */
924
- ...(ngDevMode ? [undefined, { debugName: "initialTheme" }] : /* istanbul ignore next */ []));
925
- config = inject(SI_LIVE_PREVIEW_CONFIG);
926
- internalConfig = inject(SI_LIVE_PREVIEW_INTERNALS);
927
- self = inject(ElementRef);
928
- http = inject(HttpClient);
929
- urls = inject(LivePreviewUrlService);
930
- localeApi = inject(SiLivePreviewLocaleApi, { optional: true });
931
- state = inject(LivePreviewStateService);
932
- templateElem = viewChild.required('codeTemplate', /* @ts-ignore */
933
- ...(ngDevMode ? [{ debugName: "templateElem" }] : /* istanbul ignore next */ []));
934
- typescriptElem = viewChild.required('codeTypescript', /* @ts-ignore */
935
- ...(ngDevMode ? [{ debugName: "typescriptElem" }] : /* istanbul ignore next */ []));
936
- reactVueElem = viewChild.required('codeReactVue', /* @ts-ignore */
937
- ...(ngDevMode ? [{ debugName: "reactVueElem" }] : /* istanbul ignore next */ []));
938
- consoleElem = viewChild.required('consoleContainer', /* @ts-ignore */
939
- ...(ngDevMode ? [{ debugName: "consoleElem" }] : /* istanbul ignore next */ []));
940
- baseUrl = this.urls.examplesBaseUrl;
941
- isFullscreen = signal(false, /* @ts-ignore */
942
- ...(ngDevMode ? [{ debugName: "isFullscreen" }] : /* istanbul ignore next */ []));
943
- isMobile = this.internalConfig.isMobile;
944
- templateTs = '';
945
- activeTab = signal('template', /* @ts-ignore */
946
- ...(ngDevMode ? [{ debugName: "activeTab" }] : /* istanbul ignore next */ []));
947
- showCopied = signal(false, /* @ts-ignore */
948
- ...(ngDevMode ? [{ debugName: "showCopied" }] : /* istanbul ignore next */ []));
949
- allowFullscreen = !!document.fullscreenEnabled || !!document.webkitFullscreenEnabled;
950
- exampleFullscreen = signal(false, /* @ts-ignore */
951
- ...(ngDevMode ? [{ debugName: "exampleFullscreen" }] : /* istanbul ignore next */ []));
952
- allowCopy = !!navigator.clipboard;
953
- switcherEnabled = this.config.themeSwitcher;
954
- rtlSwitcher = this.config.rtlSwitcher;
955
- rootFontSizes = this.config.rootFontSizes ?? [];
956
- webcomponents = this.config.webcomponents;
957
- frameworks = new Map([['Angular', 'angular']]);
958
- availableLocales = this.localeApi?.availableLocales() ?? [];
959
- editorCollapsed = signal(localStorage.getItem('si-live-preview-editor-collapsed') === 'true' && !this.isMobile, /* @ts-ignore */
960
- ...(ngDevMode ? [{ debugName: "editorCollapsed" }] : /* istanbul ignore next */ []));
961
- showEditor = signal(!this.editorCollapsed(), /* @ts-ignore */
962
- ...(ngDevMode ? [{ debugName: "showEditor" }] : /* istanbul ignore next */ []));
963
- compileSubject = new Subject();
964
- skipInitialLoad = false;
965
- flaskTemplate;
966
- flaskTypescript;
967
- flaskReactVue;
968
- savedScrollPos = { top: 0, left: 0 };
969
- tsLoaded = false;
970
- reactLoaded = false;
971
- vueLoaded = false;
972
- jsLoaded = false;
973
- webcomponentsList = [];
974
- constructor() {
975
- const storedFramework = localStorage.getItem('si-live-preview-framework');
976
- if (storedFramework === 'react' || storedFramework === 'vue' || storedFramework === 'js') {
977
- this.state.framework.set(storedFramework);
978
- }
979
- this.compileSubject
980
- .pipe(throttleTime(500, undefined, { leading: true, trailing: true }))
981
- .pipe(takeUntilDestroyed())
982
- .subscribe(template => {
983
- this.state.template.set(template);
984
- });
985
- this.webcomponentsList = this.config.componentLoader.webcomponentsList;
986
- let previousExample;
987
- effect(() => {
988
- const example = this.state.example();
989
- if (!example || example === previousExample) {
990
- return;
991
- }
992
- const firstLoad = previousExample === undefined;
993
- previousExample = example;
994
- untracked(() => {
995
- this.activeTab.set(this.activeTab() !== 'typescript' ? 'template' : this.activeTab());
996
- this.skipInitialLoad =
997
- firstLoad &&
998
- !!(this.state.template() ||
999
- this.state.templateReact() ||
1000
- this.state.templateVue() ||
1001
- this.state.templateJs());
1002
- this.loadFromUrl(this.skipInitialLoad);
1003
- if (this.webcomponents) {
1004
- this.reactLoaded = false;
1005
- this.vueLoaded = false;
1006
- this.jsLoaded = false;
1007
- this.state.stopWebComponentLoading();
1008
- this.checkWebComponentsAvailable();
1009
- }
1010
- });
1011
- });
1012
- effect(() => localStorage.setItem('si-live-preview-theme', this.state.theme()));
1013
- effect(() => {
1014
- if (this.state.logMessages().length) {
1015
- setTimeout(() => {
1016
- this.consoleElem().nativeElement.scrollTop =
1017
- this.consoleElem().nativeElement.scrollHeight;
1018
- });
1019
- }
1020
- });
1021
- }
1022
- ngOnInit() {
1023
- this.state.theme.set(this.initialTheme() ??
1024
- (localStorage.getItem('si-live-preview-theme') === 'dark' ? 'dark' : 'light'));
1025
- const rfs = localStorage.getItem('si-live-preview-rfs') ?? '';
1026
- this.state.rootFontSize.set(rfs === 'initial' ? rfs : rfs ? parseInt(rfs, 10) : 0);
1027
- }
1028
- ngAfterViewInit() {
1029
- const root = this.self.nativeElement.getRootNode();
1030
- const styleParent = root instanceof ShadowRoot ? root : undefined;
1031
- this.flaskTemplate = new CodeFlask(this.templateElem().nativeElement, {
1032
- styleParent,
1033
- lineNumbers: true,
1034
- language: 'html',
1035
- defaultTheme: false,
1036
- handleSelfClosingCharacters: false,
1037
- handleTabs: false,
1038
- ariaLabelledby: 'templateEditorTab'
1039
- });
1040
- this.flaskTypescript = new CodeFlask(this.typescriptElem().nativeElement, {
1041
- styleParent,
1042
- lineNumbers: true,
1043
- language: 'typescript',
1044
- readonly: true,
1045
- defaultTheme: false,
1046
- handleTabs: false,
1047
- ariaLabelledby: 'typescriptEditorTab'
1048
- });
1049
- this.flaskReactVue = new CodeFlask(this.reactVueElem().nativeElement, {
1050
- styleParent,
1051
- lineNumbers: true,
1052
- language: 'typescript',
1053
- readonly: false,
1054
- defaultTheme: false,
1055
- handleTabs: false,
1056
- areaId: 'reactVueEditor'
1057
- });
1058
- this.flaskTemplate.onUpdate((code) => {
1059
- this.compileSubject.next(code);
1060
- });
1061
- this.flaskReactVue.onUpdate((code) => {
1062
- if (this.activeTab() === 'react') {
1063
- this.state.templateReact.set(code);
1064
- this.state.loadReact.set(true);
1065
- }
1066
- else if (this.activeTab() === 'vue') {
1067
- this.state.templateVue.set(code);
1068
- this.state.loadVue.set(true);
1069
- }
1070
- else if (this.activeTab() === 'js') {
1071
- this.state.templateJs.set(code);
1072
- this.state.loadJs.set(true);
1073
- }
1074
- });
1075
- if (this.skipInitialLoad) {
1076
- if (this.state.templateReact()) {
1077
- this.reactLoaded = true;
1078
- this.changeFramework('react');
1079
- }
1080
- else if (this.state.templateVue()) {
1081
- this.vueLoaded = true;
1082
- this.changeFramework('vue');
1083
- }
1084
- else if (this.state.templateJs()) {
1085
- this.jsLoaded = true;
1086
- this.changeFramework('js');
1087
- }
1088
- else {
1089
- this.flaskTemplate.updateCode(this.state.template());
1090
- this.compileSubject.next(this.state.template());
1091
- }
1092
- this.skipInitialLoad = false;
1093
- }
1094
- }
1095
- activateTab(tab) {
1096
- this.activeTab.set(tab);
1097
- let saveScroll;
1098
- let restoreScroll;
1099
- this.state.loadReact.set(false);
1100
- this.state.loadVue.set(false);
1101
- this.state.loadJs.set(false);
1102
- if (tab === 'template') {
1103
- saveScroll = this.typescriptElem();
1104
- restoreScroll = this.templateElem();
1105
- }
1106
- else {
1107
- if (!this.tsLoaded) {
1108
- this.loadTsFromUrl();
1109
- }
1110
- saveScroll = this.templateElem();
1111
- restoreScroll = this.typescriptElem();
1112
- }
1113
- const areaSave = saveScroll.nativeElement.querySelector('textarea');
1114
- const areaRestore = restoreScroll.nativeElement.querySelector('textarea');
1115
- const scrollPos = this.savedScrollPos;
1116
- this.savedScrollPos = { left: areaSave.scrollLeft, top: areaSave.scrollTop };
1117
- setTimeout(() => {
1118
- areaRestore.scrollTop = scrollPos.top;
1119
- areaRestore.scrollLeft = scrollPos.left;
1120
- });
1121
- }
1122
- themeChange(theme) {
1123
- this.state.theme.set(theme);
1124
- localStorage.setItem('si-live-preview-theme', this.state.theme());
1125
- }
1126
- updateTemplate(template) {
1127
- this.state.template.set(template);
1128
- if (this.flaskTemplate) {
1129
- this.flaskTemplate.updateCode(this.state.template());
1130
- }
1131
- }
1132
- updateTs(ts) {
1133
- this.templateTs = ts;
1134
- if (this.flaskTypescript) {
1135
- this.flaskTypescript.updateCode(this.templateTs);
1136
- }
1137
- }
1138
- updateReact(ts) {
1139
- this.state.templateReact.set(ts);
1140
- if (this.flaskReactVue) {
1141
- this.flaskReactVue.updateCode(this.state.templateReact());
1142
- this.state.loadReact.set(true);
1143
- }
1144
- }
1145
- updateVue(ts) {
1146
- this.state.templateVue.set(ts);
1147
- if (this.flaskReactVue) {
1148
- this.flaskReactVue.updateCode(this.state.templateVue());
1149
- this.state.loadVue.set(true);
1150
- }
1151
- }
1152
- updateJs(js) {
1153
- this.state.templateJs.set(js);
1154
- if (this.flaskReactVue) {
1155
- this.flaskReactVue.updateCode(this.state.templateJs());
1156
- this.state.loadJs.set(true);
1157
- }
1158
- }
1159
- loadFromUrl(skipTemplate) {
1160
- if (!skipTemplate) {
1161
- this.updateTemplate('');
1162
- }
1163
- this.updateTs('');
1164
- this.savedScrollPos = { top: 0, left: 0 };
1165
- this.state.resetRenderingProgress();
1166
- this.tsLoaded = false;
1167
- if (this.activeTab() === 'typescript') {
1168
- this.loadTsFromUrl();
1169
- }
1170
- }
1171
- loadTemplateFromUrl() {
1172
- const example = this.state.example();
1173
- if (!example) {
1174
- return;
1175
- }
1176
- this.handleInProgressEvent(true);
1177
- this.http
1178
- .get(this.urls.sourceUrl(example + '.html'), { responseType: 'text' })
1179
- .pipe(timeout(3000), retry(1))
1180
- .subscribe({
1181
- next: data => {
1182
- this.state.originalTemplate.set(data);
1183
- this.updateTemplate(data);
1184
- setTimeout(() => {
1185
- this.handleInProgressEvent(false);
1186
- });
1187
- },
1188
- error: () => {
1189
- this.handleInProgressEvent(false);
1190
- }
1191
- });
1192
- }
1193
- loadTsFromUrl() {
1194
- const example = this.state.example();
1195
- if (!example) {
1196
- return;
1197
- }
1198
- this.handleInProgressEvent(true);
1199
- this.http
1200
- .get(this.urls.sourceUrl(example + '.ts'), { responseType: 'text' })
1201
- .pipe(timeout(3000), retry(1))
1202
- .subscribe({
1203
- next: data => {
1204
- this.updateTs(data);
1205
- this.tsLoaded = true;
1206
- setTimeout(() => {
1207
- this.handleInProgressEvent(false);
1208
- });
1209
- },
1210
- error: () => {
1211
- this.tsLoaded = true;
1212
- this.handleInProgressEvent(false);
1213
- }
1214
- });
1215
- }
1216
- checkWebComponentsAvailable() {
1217
- const baseUrl = this.config.examplesBaseUrl;
1218
- const example = this.state.example() ?? '';
1219
- if (this.webcomponentsList.includes(baseUrl + example + '-react')) {
1220
- this.frameworks.set('React', 'react');
1221
- }
1222
- else {
1223
- if (this.state.framework() === 'react') {
1224
- this.state.framework.set('angular');
1225
- }
1226
- this.frameworks.delete('React');
1227
- }
1228
- if (this.webcomponentsList.includes(baseUrl + example + '-vue')) {
1229
- this.frameworks.set('Vue', 'vue');
1230
- }
1231
- else {
1232
- if (this.state.framework() === 'vue') {
1233
- this.state.framework.set('angular');
1234
- }
1235
- this.frameworks.delete('Vue');
1236
- }
1237
- if (this.webcomponentsList.includes(baseUrl + example + '-js')) {
1238
- this.frameworks.set('Js', 'js');
1239
- }
1240
- else {
1241
- if (this.state.framework() === 'js') {
1242
- this.state.framework.set('angular');
1243
- }
1244
- this.frameworks.delete('Js');
1245
- }
1246
- this.changeFramework(this.state.framework());
1247
- }
1248
- changeFramework(framework) {
1249
- this.activeTab.set(framework);
1250
- this.state.framework.set(framework);
1251
- localStorage.setItem('si-live-preview-framework', framework);
1252
- this.state.loadReact.set(false);
1253
- this.state.loadVue.set(false);
1254
- this.state.loadJs.set(false);
1255
- let fileType = 'vue';
1256
- if (framework === 'angular') {
1257
- this.activeTab.set('template');
1258
- return;
1259
- }
1260
- else if (framework === 'react') {
1261
- fileType = 'tsx';
1262
- if (this.reactLoaded) {
1263
- this.updateReact(this.state.templateReact());
1264
- return;
1265
- }
1266
- }
1267
- else if (framework === 'vue' && this.vueLoaded) {
1268
- this.updateVue(this.state.templateVue());
1269
- return;
1270
- }
1271
- else if (framework === 'js') {
1272
- fileType = 'html';
1273
- if (this.jsLoaded) {
1274
- this.updateJs(this.state.templateJs());
1275
- return;
1276
- }
1277
- }
1278
- this.handleInProgressEvent(true);
1279
- const example = this.state.example() ?? '';
1280
- this.http
1281
- .get(this.urls.sourceUrl(`${example}-${framework}.${fileType}`), { responseType: 'text' })
1282
- .subscribe({
1283
- next: (res) => {
1284
- if (framework === 'react') {
1285
- this.updateReact(res);
1286
- this.state.templateReact.set(res);
1287
- this.reactLoaded = true;
1288
- }
1289
- else if (framework === 'vue') {
1290
- this.updateVue(res);
1291
- this.state.templateVue.set(res);
1292
- this.vueLoaded = true;
1293
- }
1294
- else if (framework === 'js') {
1295
- this.updateJs(res);
1296
- this.state.templateJs.set(res);
1297
- this.jsLoaded = true;
1298
- }
1299
- setTimeout(() => {
1300
- this.handleInProgressEvent(false);
1301
- });
1302
- },
1303
- error: (err) => {
1304
- if (framework === 'react') {
1305
- this.updateReact('');
1306
- this.reactLoaded = true;
1307
- }
1308
- else if (framework === 'vue') {
1309
- this.updateVue('');
1310
- this.vueLoaded = true;
1311
- }
1312
- else if (framework === 'js') {
1313
- this.updateJs('');
1314
- this.jsLoaded = true;
1315
- }
1316
- this.handleInProgressEvent(false);
1317
- }
1318
- });
1319
- }
1320
- templateFromComponent(template) {
1321
- if (this.state.template()) {
1322
- return;
1323
- }
1324
- if (template === undefined) {
1325
- // there's no component loaded in the renderer, load template from url
1326
- this.loadTemplateFromUrl();
1327
- }
1328
- else {
1329
- // using template from component
1330
- this.updateTemplate(template);
1331
- }
1332
- }
1333
- handleInProgressEvent(inProgress) {
1334
- this.state.setRenderingProgress(inProgress);
1335
- }
1336
- logClear(delayed = false) {
1337
- if (this.state.logMessages().length) {
1338
- this.state.clearLogs(delayed);
1339
- setTimeout(() => {
1340
- this.consoleElem().nativeElement.scrollTop = 0;
1341
- }, delayed ? 100 : 0);
1342
- }
1343
- }
1344
- logEvent(msg) {
1345
- this.state.addLog(msg);
1346
- }
1347
- showCopiedLabel() {
1348
- this.showCopied.set(true);
1349
- setTimeout(() => {
1350
- this.showCopied.set(false);
1351
- }, 1500);
1352
- }
1353
- toggleFullscreen(exampleOnly = false) {
1354
- const fullscreenElement = this.getFullscreenElement();
1355
- if (fullscreenElement) {
1356
- const exitFunction = document.exitFullscreen ?? document.webkitExitFullscreen;
1357
- if (exitFunction) {
1358
- exitFunction.call(document);
1359
- }
1360
- }
1361
- else {
1362
- const elem = exampleOnly
1363
- ? this.self.nativeElement.querySelector(':scope > .example')
1364
- : this.self.nativeElement;
1365
- this.exampleFullscreen.set(exampleOnly);
1366
- const requestFunction = elem.requestFullscreen ?? elem.webkitRequestFullScreen;
1367
- if (requestFunction) {
1368
- requestFunction.call(elem);
1369
- }
1370
- }
1371
- }
1372
- toggleCollapse() {
1373
- this.editorCollapsed.set(!this.editorCollapsed());
1374
- localStorage.setItem('si-live-preview-editor-collapsed', this.editorCollapsed().toString());
1375
- if (this.editorCollapsed()) {
1376
- this.showEditor.set(false);
1377
- setTimeout(() => window.dispatchEvent(new Event('resize')), 500);
1378
- }
1379
- else {
1380
- setTimeout(() => {
1381
- this.showEditor.set(true);
1382
- this.state.newMessages.set(false);
1383
- window.dispatchEvent(new Event('resize'));
1384
- }, 500);
1385
- }
1386
- }
1387
- toggleRTL() {
1388
- this.state.isRTL.set(!this.state.isRTL());
1389
- }
1390
- toggleTheme() {
1391
- this.themeChange(this.state.theme() === 'dark' ? 'light' : 'dark');
1392
- }
1393
- localeSelectionChanged(target) {
1394
- const locale = target?.value;
1395
- this.changeLocale(locale);
1396
- }
1397
- rfsSelectionChanges(value) {
1398
- this.state.rootFontSize.set(value === 'initial' ? value : parseInt(value, 10));
1399
- localStorage.setItem('si-live-preview-rfs', this.state.rootFontSize().toString());
1400
- }
1401
- changeLocale(locale) {
1402
- this.state.locale.set(locale ?? undefined);
1403
- }
1404
- renderingErrorMessage() {
1405
- return String(this.state.renderingError());
1406
- }
1407
- copyTemplate() {
1408
- this.clipboardCopy(this.state.template());
1409
- }
1410
- copyCode() {
1411
- if (this.activeTab() === 'react') {
1412
- this.clipboardCopy(this.state.templateReact());
1413
- }
1414
- else if (this.activeTab() === 'vue') {
1415
- this.clipboardCopy(this.state.templateVue());
1416
- }
1417
- else if (this.activeTab() === 'js') {
1418
- this.clipboardCopy(this.state.templateJs());
1419
- }
1420
- else {
1421
- this.clipboardCopy(this.templateTs);
1422
- }
1423
- }
1424
- clipboardCopy(text) {
1425
- navigator.clipboard.writeText(text);
1426
- this.showCopiedLabel();
1427
- }
1428
- createLink() {
1429
- this.clipboardCopy(this.urls.viewerUrl('editor'));
1430
- }
1431
- openTab() {
1432
- window.open(this.urls.viewerUrl('viewer'), '_blank');
1433
- }
1434
- onFullscreenChange() {
1435
- const fullscreenElement = this.getFullscreenElement();
1436
- this.isFullscreen.set(!!fullscreenElement && this.self.nativeElement.contains(fullscreenElement));
1437
- if (!this.isFullscreen()) {
1438
- this.exampleFullscreen.set(false);
1439
- }
1440
- }
1441
- getFullscreenElement() {
1442
- const root = this.self.nativeElement.getRootNode();
1443
- return (root.fullscreenElement ??
1444
- document.webkitFullscreenElement ??
1445
- null);
1446
- }
1447
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiLivePreviewComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1448
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.8", type: SiLivePreviewComponent, isStandalone: true, selector: "si-live-preview", inputs: { initialTheme: { classPropertyName: "initialTheme", publicName: "initialTheme", isSignal: true, isRequired: false, transformFunction: null } }, 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]=\"\n state.isRTL() ? 'RTL (right-to-left layout)' : 'LTR (left-to-right layout)'\n \"\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 [class.on-danger]=\"state.renderingError()\"\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(--si-sys-sizing-focus-ring-width, 2px))}.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(--si-sys-sizing-focus-ring-width, 2px) solid var(--si-sys-color-effects-focus);outline-offset:var(--si-sys-sizing-focus-ring-offset, 1px)}: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:not(.is-mobile){border-block-start:1px solid var(--si-sys-color-border-4)}.code.is-collapsed{max-block-size:41px;overflow:hidden;background-color:var(--si-sys-color-background-0)}.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.on-danger,.code .console .btn-clear.on-danger:hover,.code .console .btn-clear.on-danger:focus,.code .console .btn-clear.on-danger:active{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:2;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}:host(.embedded:not(.editor-fullscreen):not(.is-mobile)) .example{flex:0 0 var(--preview-height, 204px);min-block-size:0;overflow:hidden}.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(--si-sys-color-background-0)}:host ::ng-deep .codeflask__lines{color:var(--si-sys-color-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 });
1449
- }
1450
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiLivePreviewComponent, decorators: [{
1451
- type: Component,
1452
- args: [{ selector: 'si-live-preview', imports: [KeyValuePipe, FormsModule, SiLivePreviewIframeComponent, SiStackblitzButtonDirective], changeDetection: ChangeDetectionStrategy.Eager, host: {
1453
- '[class.editor-fullscreen]': 'isFullscreen()',
1454
- '[class.is-mobile]': 'isMobile',
1455
- '(document:fullscreenchange)': 'onFullscreenChange()',
1456
- '(document:webkitfullscreenchange)': 'onFullscreenChange()'
1457
- }, 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]=\"\n state.isRTL() ? 'RTL (right-to-left layout)' : 'LTR (left-to-right layout)'\n \"\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 [class.on-danger]=\"state.renderingError()\"\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(--si-sys-sizing-focus-ring-width, 2px))}.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(--si-sys-sizing-focus-ring-width, 2px) solid var(--si-sys-color-effects-focus);outline-offset:var(--si-sys-sizing-focus-ring-offset, 1px)}: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:not(.is-mobile){border-block-start:1px solid var(--si-sys-color-border-4)}.code.is-collapsed{max-block-size:41px;overflow:hidden;background-color:var(--si-sys-color-background-0)}.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.on-danger,.code .console .btn-clear.on-danger:hover,.code .console .btn-clear.on-danger:focus,.code .console .btn-clear.on-danger:active{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:2;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}:host(.embedded:not(.editor-fullscreen):not(.is-mobile)) .example{flex:0 0 var(--preview-height, 204px);min-block-size:0;overflow:hidden}.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(--si-sys-color-background-0)}:host ::ng-deep .codeflask__lines{color:var(--si-sys-color-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"] }]
1458
- }], ctorParameters: () => [], propDecorators: { initialTheme: [{ type: i0.Input, args: [{ isSignal: true, alias: "initialTheme", required: false }] }], 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 }] }] } });
1459
-
1460
- var siLivePreview_component = /*#__PURE__*/Object.freeze({
1461
- __proto__: null,
1462
- SiLivePreviewComponent: SiLivePreviewComponent
1463
- });
1464
-
1465
- /**
1466
- * Copyright (c) Siemens 2016 - 2026
1467
- * SPDX-License-Identifier: MIT
1468
- */
1469
- class SiExampleOverviewComponent {
1470
- route = inject(ActivatedRoute);
1471
- router = inject(Router);
1472
- title = inject(Title);
1473
- config = inject(SI_LIVE_PREVIEW_CONFIG);
1474
- internalConfig = inject(SI_LIVE_PREVIEW_INTERNALS);
1475
- componentList = [];
1476
- darkMediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
1477
- mediaQueryListener = () => this.toggleDark(this.darkMediaQuery.matches);
1478
- cdRef = inject(ChangeDetectorRef);
1479
- tree = [];
1480
- baseUrl = this.config.examplesBaseUrl;
1481
- isCollapsed = localStorage.getItem('si-live-preview-examples-collapsed') === 'true';
1482
- showContent = !this.isCollapsed;
1483
- searchControl = new UntypedFormControl();
1484
- ngOnInit() {
1485
- this.title.setTitle(this.internalConfig.titleBase);
1486
- this.componentList = this.config.componentLoader.list
1487
- .sort()
1488
- .map(component => component.replace(this.baseUrl, ''));
1489
- this.makeTree();
1490
- // Handle the filter query parameter
1491
- this.route.queryParams.subscribe(search => {
1492
- this.makeTree(search.q);
1493
- this.searchControl.setValue(search.q);
1494
- });
1495
- this.searchControl.valueChanges
1496
- .pipe(debounceTime(400), distinctUntilChanged())
1497
- .subscribe((search) => {
1498
- // Do navigation in place to set query param
1499
- this.router.navigate([], {
1500
- relativeTo: this.route,
1501
- queryParams: { q: search },
1502
- queryParamsHandling: 'merge'
1503
- });
1504
- });
1505
- this.mediaQueryListener();
1506
- this.darkMediaQuery.addEventListener('change', this.mediaQueryListener);
1507
- }
1508
- ngOnDestroy() {
1509
- this.darkMediaQuery.removeEventListener('change', this.mediaQueryListener);
1510
- }
1511
- toggleDark(dark) {
1512
- document.documentElement.classList.toggle('app--dark', dark);
1513
- document.documentElement.classList.toggle('app--light', !dark);
1514
- }
1515
- makeTree(filterValue) {
1516
- this.tree = [];
1517
- let prevParents = [];
1518
- for (const item of this.componentList) {
1519
- if (filterValue && !item.toLowerCase().includes(filterValue)) {
1520
- continue;
1521
- }
1522
- const parts = item.split('/');
1523
- const label = parts.pop();
1524
- for (let i = 0; i < parts.length; i++) {
1525
- if (prevParents.length < i || parts[i] !== prevParents[i]) {
1526
- this.tree.push({ label: parts[i], level: i });
1527
- }
1528
- }
1529
- prevParents = parts;
1530
- this.tree.push({ label, link: item, level: parts.length });
1531
- }
1532
- }
1533
- toggleCollapse() {
1534
- this.isCollapsed = !this.isCollapsed;
1535
- localStorage.setItem('si-live-preview-examples-collapsed', this.isCollapsed.toString());
1536
- if (this.isCollapsed) {
1537
- this.showContent = false;
1538
- setTimeout(() => window.dispatchEvent(new Event('resize')), 500);
1539
- this.cdRef.markForCheck();
1540
- }
1541
- else {
1542
- setTimeout(() => {
1543
- this.showContent = true;
1544
- window.dispatchEvent(new Event('resize'));
1545
- this.cdRef.markForCheck();
1546
- }, 500);
1547
- }
1548
- }
1549
- resetSearchBar() {
1550
- this.searchControl.reset();
1551
- }
1552
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiExampleOverviewComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1553
- 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(--si-sys-sizing-focus-ring-width, 2px) solid var(--si-sys-color-effects-focus);outline-offset:var(--si-sys-sizing-focus-ring-offset, 1px)}: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", inputs: ["initialTheme"] }], changeDetection: i0.ChangeDetectionStrategy.Eager });
1554
- }
1555
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiExampleOverviewComponent, decorators: [{
1556
- type: Component,
1557
- 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(--si-sys-sizing-focus-ring-width, 2px) solid var(--si-sys-color-effects-focus);outline-offset:var(--si-sys-sizing-focus-ring-offset, 1px)}: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"] }]
1558
- }] });
1559
-
1560
- const setDeviceMode = (mode) => {
1561
- const htmlTag = document.documentElement;
1562
- htmlTag.setAttribute('mode', mode);
1563
- htmlTag.classList.add(mode);
1564
- htmlTag.classList.remove(mode === 'ios' ? 'md' : 'ios');
1565
- };
1566
- const setDirectionRtl = (rtl) => {
1567
- document.documentElement.setAttribute('dir', rtl ? 'rtl' : 'ltr');
1568
- };
1569
- const setRootFontSize = (rfs) => {
1570
- const htmlTag = document.documentElement;
1571
- if (!rfs) {
1572
- htmlTag.style.removeProperty('font-size');
1573
- }
1574
- else {
1575
- htmlTag.style.setProperty('font-size', rfs === 'initial' ? rfs : rfs + 'px');
1576
- }
1577
- };
1578
- const provideExampleRoutes = (routes) => {
1579
- return {
1580
- provide: SI_LIVE_PREVIEW_EXAMPLE_ROUTES,
1581
- useValue: routes
1582
- };
1583
- };
1584
-
1585
- /**
1586
- * Copyright (c) Siemens 2016 - 2026
1587
- * SPDX-License-Identifier: MIT
1588
- */
1589
- const LOG_EVENT = new InjectionToken('si.live-previewer.log-event');
1590
-
1591
- /**
1592
- * Copyright (c) Siemens 2016 - 2026
1593
- * SPDX-License-Identifier: MIT
1594
- */
1595
- // eslint-disable-next-line @typescript-eslint/no-deprecated
1596
- class LandscapeSupportService {
1597
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: LandscapeSupportService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1598
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: LandscapeSupportService, providedIn: 'any' });
1599
- }
1600
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: LandscapeSupportService, decorators: [{
1601
- type: Injectable,
1602
- args: [{
1603
- providedIn: 'any'
1604
- }]
1605
- }] });
1606
-
1607
- /**
1608
- * Copyright (c) Siemens 2016 - 2026
1609
- * SPDX-License-Identifier: MIT
1610
- */
1611
- /**
1612
- * Base class for components that act as a live-preview runtime shell.
1613
- * Extend this class when providing `SiLivePreviewConfig.runtimeComponent`.
1614
- */
1615
- class SiLivePreviewRuntimeComponent {
1616
- component = input.required(/* @ts-ignore */
1617
- ...(ngDevMode ? [{ debugName: "component" }] : /* istanbul ignore next */ []));
1618
- ready = output();
1619
- renderingError = output();
1620
- changeDetector = inject(ChangeDetectorRef);
1621
- activatedRoute = inject(ActivatedRoute);
1622
- config = inject(SI_LIVE_PREVIEW_CONFIG);
1623
- componentRef;
1624
- childRouteBackup;
1625
- hasRenderingError = false;
1626
- ngAfterViewInit() {
1627
- this.componentRef = this.container().createComponent(this.component());
1628
- const exampleRoutes = this.componentRef.injector.get(SI_LIVE_PREVIEW_EXAMPLE_ROUTES, undefined, {
1629
- optional: true,
1630
- self: true
1631
- }) ??
1632
- this.config.defaultRoutes ??
1633
- this.activatedRoute.routeConfig?.children ??
1634
- [];
1635
- const route = this.activatedRoute.routeConfig;
1636
- if (route) {
1637
- this.childRouteBackup = route.children;
1638
- // Do not reset the router configuration: that destroys child components during navigation.
1639
- route.children = [...exampleRoutes];
1640
- }
1641
- this.ready.emit();
1642
- }
1643
- ngOnDestroy() {
1644
- this.componentRef?.destroy();
1645
- this.componentRef = undefined;
1646
- const route = this.activatedRoute.routeConfig;
1647
- if (route) {
1648
- route.children = this.childRouteBackup;
1649
- }
1650
- }
1651
- ngDoCheck() {
1652
- if (this.hasRenderingError) {
1653
- return;
1654
- }
1655
- try {
1656
- this.changeDetector.detectChanges();
1657
- }
1658
- catch (error) {
1659
- this.hasRenderingError = true;
1660
- this.renderingError.emit(error instanceof Error ? error : new Error(String(error)));
1661
- }
1662
- }
1663
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiLivePreviewRuntimeComponent, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1664
- 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 });
1665
- }
1666
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiLivePreviewRuntimeComponent, decorators: [{
1667
- type: Directive
1668
- }], propDecorators: { component: [{ type: i0.Input, args: [{ isSignal: true, alias: "component", required: true }] }], ready: [{ type: i0.Output, args: ["ready"] }], renderingError: [{ type: i0.Output, args: ["renderingError"] }] } });
1669
-
1670
- /**
1671
- * Copyright (c) Siemens 2016 - 2026
1672
- * SPDX-License-Identifier: MIT
1673
- */
1674
- /** Default standalone shell used to render a live-preview example. */
1675
- class SiDefaultLivePreviewRuntimeComponent extends SiLivePreviewRuntimeComponent {
1676
- container = viewChild.required('container', { ...(ngDevMode ? { debugName: "container" } : /* istanbul ignore next */ {}), read: ViewContainerRef });
1677
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiDefaultLivePreviewRuntimeComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
1678
- 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 });
1679
- }
1680
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiDefaultLivePreviewRuntimeComponent, decorators: [{
1681
- type: Component,
1682
- args: [{
1683
- selector: 'si-live-preview-runtime',
1684
- template: '<ng-container #container />'
1685
- }]
1686
- }], propDecorators: { container: [{ type: i0.ViewChild, args: ['container', { ...{ read: ViewContainerRef }, isSignal: true }] }] } });
1687
-
1688
- // for handling JSON.stringify with circular references, from MDN
1689
- const getCircularReplacer = () => {
1690
- const seen = new WeakSet();
1691
- return (_key, value) => {
1692
- if (typeof value === 'object' && value !== null) {
1693
- if (seen.has(value)) {
1694
- return;
1695
- }
1696
- seen.add(value);
1697
- }
1698
- return value;
1699
- };
1700
- };
1701
- let DummyAppSampleComponent = class DummyAppSampleComponent {
1702
- };
1703
- DummyAppSampleComponent = __decorate([
1704
- Component({
1705
- // eslint-disable-next-line @angular-eslint/component-selector
1706
- selector: 'app-sample',
1707
- template: '',
1708
- jit: true
1709
- })
1710
- ], DummyAppSampleComponent);
1711
- class SiLivePreviewRendererComponent {
1712
- renderedExample = viewChild.required('renderedExample', { ...(ngDevMode ? { debugName: "renderedExample" } : /* istanbul ignore next */ {}), read: ViewContainerRef });
1713
- react = viewChild.required('react', { ...(ngDevMode ? { debugName: "react" } : /* istanbul ignore next */ {}), read: ElementRef });
1714
- state = inject(LivePreviewStateService);
1715
- config = inject(SI_LIVE_PREVIEW_CONFIG);
1716
- // eslint-disable-next-line @typescript-eslint/no-deprecated
1717
- compiler = inject(Compiler);
1718
- injector = Injector.create({
1719
- parent: inject(Injector),
1720
- providers: [
1721
- {
1722
- provide: LOG_EVENT,
1723
- useValue: (...msg) => this.logMessage.emit(this.stringifyLog(msg))
1724
- }
1725
- ]
1726
- });
1727
- rendererFactory = inject(_DomRendererFactory2);
1728
- cdRef = inject(ChangeDetectorRef);
1729
- exampleUrl = computed(() => this.config.examplesBaseUrl + this.state.example(), /* @ts-ignore */
1730
- ...(ngDevMode ? [{ debugName: "exampleUrl" }] : /* istanbul ignore next */ []));
1731
- renderingDone = signal(false, /* @ts-ignore */
1732
- ...(ngDevMode ? [{ debugName: "renderingDone" }] : /* istanbul ignore next */ []));
1733
- templateFromComponent = output();
1734
- logClear = output();
1735
- logMessage = output();
1736
- logRenderingError = output();
1737
- inProgress = output();
1738
- supportsLandscapeMode = output();
1739
- componentRef;
1740
- componentTs;
1741
- componentTsSampleComponent;
1742
- dynamicComponent;
1743
- dynamicComponentId;
1744
- componentTsFirstLoad = true;
1745
- compiledTemplate;
1746
- constructor() {
1747
- effect(() => {
1748
- const url = this.exampleUrl();
1749
- if (url) {
1750
- untracked(() => this.loadFromUrl());
1751
- }
1752
- });
1753
- effect(() => {
1754
- const template = this.state.template();
1755
- // when the initial template is pushed from the renderer to the editor, this.state.template is
1756
- // initially empty, but later changes to what the renderer has pushed out. In this case
1757
- // don't compile
1758
- if (template && template !== this.compiledTemplate) {
1759
- untracked(() => {
1760
- this.setInProgress(true);
1761
- this.compileWhenReady();
1762
- });
1763
- }
1764
- });
1765
- }
1766
- ngOnDestroy() {
1767
- this.clear();
1768
- }
1769
- recompile() {
1770
- this.removeComponentInstance();
1771
- this.logClear.emit();
1772
- this.setRenderingError(false);
1773
- try {
1774
- this.createComponentInstance();
1775
- }
1776
- catch (error) {
1777
- this.setRenderingError(true, error);
1778
- }
1779
- }
1780
- logError(error) {
1781
- if (this.config.errorHandler) {
1782
- this.config.errorHandler(error);
1783
- }
1784
- }
1785
- setRenderingError(hasError, msg) {
1786
- this.logRenderingError.emit(msg);
1787
- if (hasError) {
1788
- setTimeout(() => {
1789
- this.setInProgress(false);
1790
- this.cdRef.markForCheck();
1791
- });
1792
- }
1793
- }
1794
- loadFromUrl() {
1795
- this.logClear.emit();
1796
- this.clear();
1797
- this.componentTsSampleComponent = undefined;
1798
- this.dynamicComponent = undefined;
1799
- this.componentTsFirstLoad = true;
1800
- this.componentTs = this.config.componentLoader.load(this.exampleUrl());
1801
- if (this.componentTs) {
1802
- this.setInProgress(true);
1803
- this.componentTs
1804
- .then(m => {
1805
- this.componentTsSampleComponent = m.SampleComponent;
1806
- this.dynamicComponent = m.SampleComponent;
1807
- this.compileWhenReady();
1808
- if (!this.componentTsSampleComponent && !this.state.template()) {
1809
- afterNextRender(() => {
1810
- this.setInProgress(false);
1811
- this.cdRef.markForCheck();
1812
- }, { injector: this.injector });
1813
- }
1814
- })
1815
- .catch(e => {
1816
- this.componentTs = undefined;
1817
- this.logRenderingError.emit(e ? e.toString() : 'Failed loading TS');
1818
- afterNextRender(() => {
1819
- this.setInProgress(false);
1820
- this.cdRef.markForCheck();
1821
- }, { injector: this.injector });
1822
- });
1823
- }
1824
- else {
1825
- // set the dummy component
1826
- this.componentTsSampleComponent = DummyAppSampleComponent;
1827
- // let the editor know there is no component, so no template
1828
- this.templateFromComponent.emit(undefined);
1829
- }
1830
- }
1831
- setInProgress(inProgress) {
1832
- this.renderingDone.set(!inProgress);
1833
- this.inProgress.emit(inProgress);
1834
- }
1835
- compileWhenReady() {
1836
- if (this.componentTs) {
1837
- if (!this.componentTsSampleComponent) {
1838
- // TS, but code not yet loaded
1839
- return;
1840
- }
1841
- if (!this.componentTsFirstLoad && !this.state.template()) {
1842
- // TS, first load done, template not yet available
1843
- return;
1844
- }
1845
- }
1846
- else if (!this.state.template()) {
1847
- // no TS, no template
1848
- return;
1849
- }
1850
- this.doCompileTemplate();
1851
- }
1852
- doCompileTemplate() {
1853
- this.logClear.emit();
1854
- this.clear();
1855
- this.createComponent();
1856
- }
1857
- stringifyLog(args) {
1858
- return args.map(a => JSON.stringify(a, getCircularReplacer())).join(', ');
1859
- }
1860
- // this exists because in production mode, the ivy internal props are defined as
1861
- // non-configurable and cannot be overwritten
1862
- cloneComponentWithoutIvyStuff() {
1863
- if (!this.componentTsSampleComponent) {
1864
- return;
1865
- }
1866
- const orig = this.componentTsSampleComponent;
1867
- const ignoreProps = ['ɵcmp', 'ɵfac', 'ɵprov'];
1868
- const copy = orig.bind({});
1869
- const descriptors = Object.getOwnPropertyDescriptors(orig);
1870
- for (const name of Object.getOwnPropertyNames(orig)) {
1871
- if (ignoreProps.includes(name)) {
1872
- continue;
1873
- }
1874
- Object.defineProperty(copy, name, descriptors[name]);
1875
- }
1876
- this.dynamicComponent = copy;
1877
- }
1878
- // patches the template into the loaded component (if any), returns the template to use
1879
- updateDynamicTemplate() {
1880
- if (this.componentTsSampleComponent) {
1881
- const ann = this.componentTsSampleComponent?.decorators
1882
- ? this.getAnnotationInAot(this.componentTsSampleComponent)
1883
- : this.getAnnotation(this.componentTsSampleComponent, Component);
1884
- if (ann) {
1885
- const supportsLandscape = ann.providers?.includes(LandscapeSupportService);
1886
- this.supportsLandscapeMode.emit(supportsLandscape);
1887
- if (this.componentTsFirstLoad && !this.state.template()) {
1888
- // skipping compile on first load
1889
- this.compiledTemplate = ann.template;
1890
- this.templateFromComponent.emit(ann.template);
1891
- }
1892
- else if (ann.template !== this.state.template()) {
1893
- // recompile with new template
1894
- this.componentTsFirstLoad = false;
1895
- this.cloneComponentWithoutIvyStuff();
1896
- ann.template = this.state.template();
1897
- this.compiledTemplate = this.state.template();
1898
- _compileComponent(this.dynamicComponent, ann);
1899
- this.reuseResolvedScopeOfOriginalComponent();
1900
- }
1901
- }
1902
- }
1903
- }
1904
- /**
1905
- * When the host application is built with AOT, the Angular compiler tree-shakes the
1906
- * `ɵɵsetNgModuleScope` calls (because `ngJitMode` is `false`). As a result, NgModules that are
1907
- * compiled from source expose no `imports`/`exports` scope on their `ɵmod` at runtime.
1908
- *
1909
- * Re-compiling the edited example via JIT (`compileComponent`) therefore cannot resolve the
1910
- * directives and pipes that are exported through such an imported NgModule. A common symptom is
1911
- * a missing value accessor for a form control component used with `ngModel`, which throws
1912
- * `NG01203`.
1913
- *
1914
- * The originally (AOT-)compiled component already carries the fully resolved scope in its
1915
- * component definition. Reusing its directive and pipe defs on the recompiled component restores
1916
- * the complete scope without depending on runtime NgModule metadata.
1917
- */
1918
- reuseResolvedScopeOfOriginalComponent() {
1919
- const originalDef = this.componentTsSampleComponent?.['ɵcmp'];
1920
- const recompiledDef = this.dynamicComponent?.['ɵcmp'];
1921
- if (!originalDef || !recompiledDef) {
1922
- return;
1923
- }
1924
- if (originalDef.directiveDefs) {
1925
- recompiledDef.directiveDefs = this.mergeDefs(recompiledDef.directiveDefs, originalDef.directiveDefs);
1926
- }
1927
- if (originalDef.pipeDefs) {
1928
- recompiledDef.pipeDefs = this.mergeDefs(recompiledDef.pipeDefs, originalDef.pipeDefs);
1929
- }
1930
- }
1931
- /** Merges two (possibly lazy) Ivy def lists into a single deduplicated factory. */
1932
- mergeDefs(recompiled, original) {
1933
- const resolve = (defs) => typeof defs === 'function' ? defs() : (defs ?? []);
1934
- return () => [...new Set([...resolve(recompiled), ...resolve(original)])];
1935
- }
1936
- getAnnotation(obj, type) {
1937
- return obj?.__annotations__?.find((a) => a instanceof type);
1938
- }
1939
- getAnnotationInAot(obj) {
1940
- return obj.decorators?.[0]?.args?.[0];
1941
- }
1942
- clear() {
1943
- this.removeComponentInstance();
1944
- if (this.dynamicComponent) {
1945
- this.compiler.clearCacheFor(this.dynamicComponent);
1946
- }
1947
- _resetCompiledComponents();
1948
- }
1949
- removeComponentInstance() {
1950
- this.componentRef?.destroy();
1951
- this.componentRef = undefined;
1952
- try {
1953
- this.renderedExample().remove();
1954
- }
1955
- catch (error) {
1956
- // FIXME: there's no point in logging this as rendering error since it will be cleared right away
1957
- console.warn('Error during ngOnDestroy():', error);
1958
- }
1959
- // clear out render for component id:
1960
- // - contains the styles
1961
- // - stays mostly the same for all examples
1962
- if (this.dynamicComponentId) {
1963
- this.rendererFactory.rendererByCompId?.delete(this.dynamicComponentId);
1964
- }
1965
- }
1966
- createComponent() {
1967
- this.setRenderingError(false);
1968
- try {
1969
- this.updateDynamicTemplate();
1970
- this.createComponentInstance();
1971
- }
1972
- catch (error) {
1973
- this.setRenderingError(true, error.toString());
1974
- }
1975
- }
1976
- createComponentInstance() {
1977
- this.dynamicComponentId = this.dynamicComponent?.['ɵcmp']?.id;
1978
- if (!this.dynamicComponent) {
1979
- return;
1980
- }
1981
- if (!this.dynamicComponent['ɵcmp']?.standalone) {
1982
- throw new Error('Live preview examples must be standalone components.');
1983
- }
1984
- const runtimeComponent = this.config.runtimeComponent ?? SiDefaultLivePreviewRuntimeComponent;
1985
- this.componentRef = this.renderedExample().createComponent(runtimeComponent, {
1986
- injector: this.injector,
1987
- bindings: [inputBinding('component', () => this.dynamicComponent)]
1988
- });
1989
- this.componentRef.instance.ready.subscribe(() => {
1990
- queueMicrotask(() => {
1991
- this.setInProgress(false);
1992
- this.cdRef.markForCheck();
1993
- });
1994
- });
1995
- this.componentRef.instance.renderingError.subscribe(error => {
1996
- this.setRenderingError(true, error.message);
1997
- this.logError(error);
1998
- });
1999
- }
2000
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiLivePreviewRendererComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
2001
- 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 });
2002
- }
2003
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiLivePreviewRendererComponent, decorators: [{
2004
- type: Component,
2005
- args: [{
2006
- selector: 'si-live-preview-renderer',
2007
- template: '<div #renderedExample></div><div #react id="app"></div>',
2008
- changeDetection: ChangeDetectionStrategy.Eager,
2009
- host: {
2010
- '[class.live-preview-done]': 'renderingDone()',
2011
- '[attr.data-example]': 'exampleUrl()',
2012
- '[attr.data-id]': 'state.dataId()'
2013
- }
2014
- }]
2015
- }], 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"] }] } });
2016
-
2017
- /**
2018
- * Copyright (c) Siemens 2016 - 2026
2019
- * SPDX-License-Identifier: MIT
2020
- */
2021
- class SiExampleViewerComponent {
2022
- router = inject(Router);
2023
- route = inject(ActivatedRoute);
2024
- internalConfig = inject(SI_LIVE_PREVIEW_INTERNALS);
2025
- themeApi = inject(SiLivePreviewThemeApi, { optional: true });
2026
- localeApi = inject(SiLivePreviewLocaleApi, { optional: true });
2027
- state = inject(LivePreviewStateService);
2028
- renderer = viewChild.required('renderer', /* @ts-ignore */
2029
- ...(ngDevMode ? [{ debugName: "renderer" }] : /* istanbul ignore next */ []));
2030
- mode = signal('viewer', /* @ts-ignore */
2031
- ...(ngDevMode ? [{ debugName: "mode" }] : /* istanbul ignore next */ []));
2032
- tabs = signal([], /* @ts-ignore */
2033
- ...(ngDevMode ? [{ debugName: "tabs" }] : /* istanbul ignore next */ []));
2034
- hasTabs = computed(() => this.tabs().length > 1, /* @ts-ignore */
2035
- ...(ngDevMode ? [{ debugName: "hasTabs" }] : /* istanbul ignore next */ []));
2036
- hasTabsMobile = computed(() => this.tabs().length > 1 && this.internalConfig.isMobile, /* @ts-ignore */
2037
- ...(ngDevMode ? [{ debugName: "hasTabsMobile" }] : /* istanbul ignore next */ []));
2038
- activeTabIndex = signal(0, /* @ts-ignore */
2039
- ...(ngDevMode ? [{ debugName: "activeTabIndex" }] : /* istanbul ignore next */ []));
2040
- constructor() {
2041
- this.route.params.subscribe(params => this.mode.set(params.mode ?? 'editor'));
2042
- this.route.queryParams.subscribe(params => this.handleQueryParams(params));
2043
- }
2044
- handleQueryParams(params) {
2045
- let handled = false;
2046
- let recompile = false;
2047
- const base = params.base ? params.base + '/' : '';
2048
- if (params.e) {
2049
- const prevUrl = this.state.example();
2050
- const previousTemplate = this.state.template();
2051
- this.tabs.set([]);
2052
- this.activeTabIndex.set(0);
2053
- this.state.example.set('');
2054
- this.state.clearTemplates();
2055
- const examples = Array.isArray(params.e) ? params.e : [params.e];
2056
- examples.forEach(element => {
2057
- const parts = element.split(';');
2058
- this.tabs.update(t => [
2059
- ...t,
2060
- {
2061
- heading: parts[1],
2062
- base,
2063
- example: parts[0]
2064
- }
2065
- ]);
2066
- });
2067
- if (this.tabs().length) {
2068
- this.activateTab(0);
2069
- recompile = prevUrl === this.state.example();
2070
- }
2071
- if (this.tabs().length <= 1 && params.t) {
2072
- if (params.framework === 'react') {
2073
- this.state.templateReact.set(params.t);
2074
- }
2075
- else if (params.framework === 'vue') {
2076
- this.state.templateVue.set(params.t);
2077
- }
2078
- else if (params.framework === 'js') {
2079
- this.state.templateJs.set(params.t);
2080
- }
2081
- else {
2082
- recompile = recompile || previousTemplate !== params.t;
2083
- this.state.template.set(params.t);
2084
- }
2085
- }
2086
- handled = true;
2087
- }
2088
- if (params.theme) {
2089
- this.setTheme(params.theme);
2090
- handled = true;
2091
- }
2092
- if (params.locale) {
2093
- this.setLocale(params.locale);
2094
- handled = true;
2095
- }
2096
- if (params.rfs) {
2097
- setRootFontSize(params.rfs === 'initial' ? params.rfs : parseInt(params.rfs, 10));
2098
- }
2099
- if (params.isRTL) {
2100
- this.setRTL(params.isRTL);
2101
- handled = true;
2102
- }
2103
- if (params.mode && this.mode() !== 'editor') {
2104
- setDeviceMode(params.mode);
2105
- recompile = true;
2106
- handled = true;
2107
- }
2108
- if (handled) {
2109
- const { e, t, theme, mode, locale, isRTL, ...newParams } = params;
2110
- this.router.navigate([], { queryParams: newParams });
2111
- }
2112
- if (params.id) {
2113
- recompile = this.state.dataId() !== params.id;
2114
- this.state.dataId.set(params.id);
2115
- }
2116
- if (recompile) {
2117
- this.renderer()?.recompile();
2118
- }
2119
- }
2120
- setUiTheme(theme) {
2121
- document.documentElement.classList.toggle('app--dark', theme === 'dark');
2122
- document.documentElement.classList.toggle('app--light', theme === 'light');
2123
- }
2124
- setTheme(theme) {
2125
- if (this.mode() === 'editor') {
2126
- this.state.theme.set(theme);
2127
- }
2128
- if (this.themeApi) {
2129
- this.themeApi.setThemeFromPreviewer(theme);
2130
- }
2131
- this.setUiTheme(theme);
2132
- }
2133
- setRTL(rtl) {
2134
- this.state.isRTL.set(rtl);
2135
- if (this.mode() !== 'editor') {
2136
- setDirectionRtl(rtl);
2137
- }
2138
- }
2139
- setLocale(locale) {
2140
- if (this.mode() === 'editor') {
2141
- this.state.locale.set(locale);
2142
- return;
2143
- }
2144
- if (this.localeApi) {
2145
- this.localeApi.setLocale(locale);
2146
- }
2147
- }
2148
- activateTab(index) {
2149
- const example = this.tabs()[index].example;
2150
- this.activeTabIndex.set(index);
2151
- this.state.example.set(this.tabs()[index].base + example);
2152
- }
2153
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiExampleViewerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
2154
- 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(--si-sys-sizing-focus-ring-width, 2px))}.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(--si-sys-sizing-focus-ring-width, 2px) solid var(--si-sys-color-effects-focus);outline-offset:var(--si-sys-sizing-focus-ring-offset, 1px)}.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", inputs: ["initialTheme"] }, { kind: "component", type: SiLivePreviewRendererComponent, selector: "si-live-preview-renderer", outputs: ["templateFromComponent", "logClear", "logMessage", "logRenderingError", "inProgress", "supportsLandscapeMode"] }], changeDetection: i0.ChangeDetectionStrategy.Eager });
2155
- }
2156
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiExampleViewerComponent, decorators: [{
2157
- type: Component,
2158
- args: [{ selector: 'si-example-viewer', imports: [SiLivePreviewComponent, SiLivePreviewRendererComponent], changeDetection: ChangeDetectionStrategy.Eager, host: {
2159
- '[class.has-tabs]': 'hasTabs()',
2160
- '[class.has-tabs-mobile]': 'hasTabsMobile()'
2161
- }, 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(--si-sys-sizing-focus-ring-width, 2px))}.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(--si-sys-sizing-focus-ring-width, 2px) solid var(--si-sys-color-effects-focus);outline-offset:var(--si-sys-sizing-focus-ring-offset, 1px)}.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"] }]
2162
- }], ctorParameters: () => [], propDecorators: { renderer: [{ type: i0.ViewChild, args: ['renderer', { isSignal: true }] }] } });
2163
-
2164
- /**
2165
- * Copyright (c) Siemens 2016 - 2026
2166
- * SPDX-License-Identifier: MIT
2167
- */
2168
- class SiLivePreviewWebComponentService {
2169
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiLivePreviewWebComponentService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
2170
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiLivePreviewWebComponentService });
2171
- }
2172
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiLivePreviewWebComponentService, decorators: [{
2173
- type: Injectable
2174
- }] });
2175
-
2176
- /**
2177
- * Copyright (c) Siemens 2016 - 2026
2178
- * SPDX-License-Identifier: MIT
2179
- */
2180
- const filterTargets = ['_self', '_top', '_parent', ''];
2181
- class SiLivePreviewWrapperComponent {
2182
- renderer = viewChild.required('renderer', /* @ts-ignore */
2183
- ...(ngDevMode ? [{ debugName: "renderer" }] : /* istanbul ignore next */ []));
2184
- webcomponentRenderer = viewChild.required('webcomponentRenderer', /* @ts-ignore */
2185
- ...(ngDevMode ? [{ debugName: "webcomponentRenderer" }] : /* istanbul ignore next */ []));
2186
- state = inject(LivePreviewStateService);
2187
- config = inject(SI_LIVE_PREVIEW_CONFIG);
2188
- themeApi = inject(SiLivePreviewThemeApi, { optional: true });
2189
- localeApi = inject(SiLivePreviewLocaleApi, { optional: true });
2190
- internalConfig = inject(SI_LIVE_PREVIEW_INTERNALS);
2191
- ngZone = inject(NgZone);
2192
- webcomponentService = inject(SiLivePreviewWebComponentService, {
2193
- optional: true
2194
- });
2195
- cdRef = inject(ChangeDetectorRef);
2196
- parentOrigin = this.resolveParentOrigin();
2197
- isMobile = false;
2198
- initialUrl;
2199
- constructor() {
2200
- this.themeApi
2201
- ?.getApplicationThemeObservable()
2202
- .pipe(takeUntilDestroyed())
2203
- .subscribe(theme => {
2204
- this.state.theme.set(theme);
2205
- this.sendMessage('theme', theme);
2206
- });
2207
- this.localeApi
2208
- ?.getLocale()
2209
- .pipe(takeUntilDestroyed())
2210
- .subscribe(locale => {
2211
- if (this.state.locale() !== locale) {
2212
- this.state.locale.set(locale);
2213
- this.sendMessage('locale', locale);
2214
- }
2215
- });
2216
- this.initialUrl = window.location.toString();
2217
- this.isMobile = this.internalConfig.isMobile;
2218
- if (this.isMobile) {
2219
- setDeviceMode(this.state.viewport().mode);
2220
- }
2221
- // send ready message only when locale/theme are communicated to avoid loops
2222
- this.sendMessage('ready');
2223
- this.ngZone.runOutsideAngular(() => fromEvent(window, 'message')
2224
- .pipe(takeUntilDestroyed())
2225
- .subscribe(message => {
2226
- this.onMessage(message);
2227
- this.cdRef.markForCheck();
2228
- }));
2229
- }
2230
- onMessage(event) {
2231
- // Render requests contain executable templates. Only trust the embedding editor, with
2232
- // a loopback-only exception for documentation development on a separate local port.
2233
- if (event.origin !== this.parentOrigin ||
2234
- event.source !== window.parent ||
2235
- event.data?.src !== 'editor') {
2236
- return;
2237
- }
2238
- this.ngZone.run(() => this.onMessageInZone(event));
2239
- }
2240
- onMessageInZone(event) {
2241
- const modeChanged = this.state.viewport().mode !== event.data.mode;
2242
- this.state.applyRenderRequest(event.data);
2243
- if (this.state.theme() !== event.data.theme) {
2244
- this.setTheme(event.data.theme);
2245
- }
2246
- if (this.state.locale() !== event.data.locale) {
2247
- this.setLocale(event.data.locale);
2248
- }
2249
- if (this.state.rootFontSize() !== event.data.rootFontSize) {
2250
- this.state.rootFontSize.set(event.data.rootFontSize);
2251
- setRootFontSize(event.data.rootFontSize);
2252
- }
2253
- if (this.state.isRTL() !== event.data.isRTL) {
2254
- this.setRTL(event.data.isRTL);
2255
- }
2256
- if (this.isMobile) {
2257
- this.setSafeArea(event.data.safeAreaTop, event.data.safeAreaBottom, event.data.safeAreaLeft, event.data.safeAreaRight);
2258
- }
2259
- if (modeChanged && this.isMobile) {
2260
- setDeviceMode(event.data.mode);
2261
- this.renderer().recompile();
2262
- }
2263
- const webcomponentRenderer = this.webcomponentRenderer();
2264
- if (webcomponentRenderer &&
2265
- (this.state.loadReact() || this.state.loadVue() || this.state.loadJs())) {
2266
- this.webcomponentService?.injectComponent(webcomponentRenderer, {
2267
- exampleUrl: this.config.examplesBaseUrl + this.state.example(),
2268
- loadReact: this.state.loadReact(),
2269
- loadJs: this.state.loadJs(),
2270
- webcomponentTemplateCode: this.state.activeWebComponentTemplate(),
2271
- loadVue: this.state.loadVue(),
2272
- config: this.config
2273
- }, {
2274
- inProgress: (type, message) => this.sendMessage(type, message)
2275
- });
2276
- }
2277
- else {
2278
- this.webcomponentService?.destroyComponent();
2279
- }
2280
- }
2281
- onClick(event) {
2282
- const target = event?.target;
2283
- if (target?.tagName === 'A' && !event.defaultPrevented) {
2284
- // for normal link: ok if it starts with the proper route, else open in a new window
2285
- const newUrl = target.href;
2286
- const linkTarget = target.target;
2287
- if (newUrl && !newUrl.startsWith(this.initialUrl) && filterTargets.includes(linkTarget)) {
2288
- event.preventDefault();
2289
- window.open(newUrl, '_blank', 'noopener,noreferrer');
2290
- }
2291
- }
2292
- }
2293
- sendMessage(type, message) {
2294
- window.parent.postMessage({ src: 'renderer', type, message }, this.parentOrigin);
2295
- }
2296
- resolveParentOrigin() {
2297
- const location = window.location;
2298
- // Keep the editor origin across locale-triggered reloads, which replace the referrer.
2299
- const parameters = new URLSearchParams(location.hash.split('?')[1]);
2300
- const source = parameters.get('parentOrigin') ?? document.referrer;
2301
- if (!source || !URL.canParse(source)) {
2302
- return location.origin;
2303
- }
2304
- const parent = new URL(source);
2305
- const isLoopback = (hostname) => hostname === 'localhost' || hostname === '[::1]' || /^127(?:\.\d{1,3}){3}$/.test(hostname);
2306
- return parent.origin === location.origin ||
2307
- (parent.protocol === 'http:' &&
2308
- location.protocol === 'http:' &&
2309
- isLoopback(parent.hostname) &&
2310
- isLoopback(location.hostname))
2311
- ? parent.origin
2312
- : location.origin;
2313
- }
2314
- setTheme(theme) {
2315
- this.state.theme.set(theme);
2316
- if (this.themeApi) {
2317
- this.themeApi.setThemeFromPreviewer(theme);
2318
- }
2319
- else {
2320
- document.documentElement.classList.toggle('app--dark', theme === 'dark');
2321
- document.documentElement.classList.toggle('app--light', theme === 'light');
2322
- }
2323
- }
2324
- setRTL(rtl) {
2325
- this.state.isRTL.set(rtl);
2326
- setDirectionRtl(rtl);
2327
- }
2328
- setLocale(locale) {
2329
- if (!locale) {
2330
- return;
2331
- }
2332
- this.state.locale.set(locale);
2333
- if (this.localeApi) {
2334
- this.localeApi.setLocale(locale);
2335
- }
2336
- }
2337
- setSafeArea(top, bottom, left, right) {
2338
- const htmlTag = document.documentElement;
2339
- htmlTag.style.setProperty('--ion-safe-area-top', (top ?? 0) + 'px');
2340
- htmlTag.style.setProperty('--ion-safe-area-bottom', (bottom ?? 0) + 'px');
2341
- htmlTag.style.setProperty('--ion-safe-area-left', (left ?? 0) + 'px');
2342
- htmlTag.style.setProperty('--ion-safe-area-right', (right ?? 0) + 'px');
2343
- }
2344
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiLivePreviewWrapperComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
2345
- 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 });
2346
- }
2347
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiLivePreviewWrapperComponent, decorators: [{
2348
- type: Component,
2349
- args: [{ selector: 'si-live-preview-wrapper', imports: [SiLivePreviewRendererComponent], changeDetection: ChangeDetectionStrategy.Eager, host: {
2350
- '(click)': 'onClick($event)'
2351
- }, 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"] }]
2352
- }], ctorParameters: () => [], propDecorators: { renderer: [{ type: i0.ViewChild, args: ['renderer', { isSignal: true }] }], webcomponentRenderer: [{ type: i0.ViewChild, args: ['webcomponentRenderer', { isSignal: true }] }] } });
2353
-
2354
- /**
2355
- * Copyright (c) Siemens 2016 - 2026
2356
- * SPDX-License-Identifier: MIT
2357
- */
2358
- const livePreviewRoutes = [
2359
- {
2360
- path: 'overview',
2361
- children: [{ path: '**', component: SiExampleOverviewComponent }]
2362
- },
2363
- {
2364
- path: 'viewer/:mode',
2365
- component: SiExampleViewerComponent,
2366
- children: [{ path: '**', component: SiDummyComponent }]
2367
- },
2368
- {
2369
- path: 'iframe',
2370
- component: SiLivePreviewWrapperComponent,
2371
- children: [{ path: '**', component: SiDummyComponent }]
2372
- },
2373
- { path: '', redirectTo: 'viewer/editor', pathMatch: 'full' },
2374
- { path: '**', component: SiExampleViewerComponent }
2375
- ];
2376
- class SiLivePreviewRoutingModule {
2377
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiLivePreviewRoutingModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2378
- static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "22.0.8", ngImport: i0, type: SiLivePreviewRoutingModule, imports: [i1$1.RouterModule], exports: [RouterModule] });
2379
- static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiLivePreviewRoutingModule, imports: [RouterModule.forRoot(livePreviewRoutes, { useHash: true }), RouterModule] });
2380
- }
2381
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiLivePreviewRoutingModule, decorators: [{
2382
- type: NgModule,
2383
- args: [{
2384
- imports: [RouterModule.forRoot(livePreviewRoutes, { useHash: true })],
2385
- exports: [RouterModule]
2386
- }]
2387
- }] });
2388
-
2389
- /**
2390
- * Copyright (c) Siemens 2016 - 2026
2391
- * SPDX-License-Identifier: MIT
2392
- */
2393
- /** A router location that is private to a rendered example application. */
2394
- class ExampleLocationStrategy extends LocationStrategy {
2395
- currentPath = '/';
2396
- state = null;
2397
- path() {
2398
- return this.currentPath;
2399
- }
2400
- prepareExternalUrl(internal) {
2401
- return internal;
2402
- }
2403
- getState() {
2404
- return this.state;
2405
- }
2406
- pushState(state, _title, url, queryParams) {
2407
- this.state = state;
2408
- this.currentPath = url + queryParams;
2409
- }
2410
- replaceState(state, _title, url, queryParams) {
2411
- this.state = state;
2412
- this.currentPath = url + queryParams;
2413
- }
2414
- forward() { }
2415
- back() { }
2416
- onPopState(_fn) { }
2417
- getBaseHref() {
2418
- return '';
2419
- }
2420
- }
2421
-
2422
- /**
2423
- * Copyright (c) Siemens 2016 - 2026
2424
- * SPDX-License-Identifier: MIT
2425
- */
2426
- /**
2427
- * Runtime shell that renders each example in an independent Angular application.
2428
- * The example application owns its router and does not modify the live-preview router.
2429
- */
2430
- class SiLivePreviewApplicationRuntimeComponent extends SiLivePreviewRuntimeComponent {
2431
- applicationConfig = inject(SI_LIVE_PREVIEW_CONFIG);
2432
- parentInjector = inject(Injector);
2433
- exampleComponentRef;
2434
- applicationRef;
2435
- hostElement;
2436
- destroyed = false;
2437
- ngAfterViewInit() {
2438
- this.createExampleApplication();
2439
- }
2440
- ngOnDestroy() {
2441
- this.destroyed = true;
2442
- this.exampleComponentRef?.destroy();
2443
- this.exampleComponentRef = undefined;
2444
- this.applicationRef?.destroy();
2445
- this.hostElement?.remove();
2446
- }
2447
- async createExampleApplication() {
2448
- try {
2449
- const locationStrategy = new ExampleLocationStrategy();
2450
- const configuredApplication = this.applicationConfig.exampleApplicationConfig;
2451
- const exampleApplicationConfig = typeof configuredApplication === 'function'
2452
- ? configuredApplication(this.parentInjector)
2453
- : configuredApplication;
2454
- this.applicationRef = await createApplication({
2455
- ...exampleApplicationConfig,
2456
- providers: [
2457
- ...(exampleApplicationConfig?.providers ?? []),
2458
- provideRouter([], withDisabledInitialNavigation()),
2459
- { provide: LocationStrategy, useValue: locationStrategy },
2460
- {
2461
- provide: Location,
2462
- useFactory: () => new Location(inject(LocationStrategy))
2463
- },
2464
- {
2465
- provide: LOG_EVENT,
2466
- useFactory: () => this.parentInjector.get(LOG_EVENT)
2467
- },
2468
- {
2469
- provide: ErrorHandler,
2470
- useValue: { handleError: (error) => this.handleError(error) }
2471
- }
2472
- ]
2473
- });
2474
- if (this.destroyed) {
2475
- this.applicationRef.destroy();
2476
- return;
2477
- }
2478
- this.exampleComponentRef = createComponent(this.component(), {
2479
- environmentInjector: this.applicationRef.injector
2480
- });
2481
- this.hostElement = this.exampleComponentRef.location.nativeElement;
2482
- const anchor = this.container().element.nativeElement;
2483
- anchor.parentNode?.insertBefore(this.hostElement, anchor);
2484
- const exampleRoutes = this.exampleComponentRef.injector.get(SI_LIVE_PREVIEW_EXAMPLE_ROUTES, this.applicationConfig.defaultRoutes ?? [{ path: '**', component: SiDummyComponent }], { self: true });
2485
- this.applicationRef.injector.get(Router).resetConfig(exampleRoutes);
2486
- this.applicationRef.attachView(this.exampleComponentRef.hostView);
2487
- this.applicationRef.tick();
2488
- this.ready.emit();
2489
- }
2490
- catch (error) {
2491
- this.handleError(error);
2492
- }
2493
- }
2494
- handleError(error) {
2495
- this.renderingError.emit(error instanceof Error ? error : new Error(String(error)));
2496
- }
2497
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiLivePreviewApplicationRuntimeComponent, deps: null, target: i0.ɵɵFactoryTarget.Directive });
2498
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.8", type: SiLivePreviewApplicationRuntimeComponent, isStandalone: true, usesInheritance: true, ngImport: i0 });
2499
- }
2500
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiLivePreviewApplicationRuntimeComponent, decorators: [{
2501
- type: Directive
2502
- }] });
2503
-
2504
- /**
2505
- * Copyright (c) Siemens 2016 - 2026
2506
- * SPDX-License-Identifier: MIT
2507
- */
2508
- /** Default shell that renders an example in an independent Angular application. */
2509
- class SiDefaultLivePreviewApplicationRuntimeComponent extends SiLivePreviewApplicationRuntimeComponent {
2510
- container = viewChild.required('container', { ...(ngDevMode ? { debugName: "container" } : /* istanbul ignore next */ {}), read: ViewContainerRef });
2511
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiDefaultLivePreviewApplicationRuntimeComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
2512
- 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 });
2513
- }
2514
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiDefaultLivePreviewApplicationRuntimeComponent, decorators: [{
2515
- type: Component,
2516
- args: [{
2517
- selector: 'si-live-preview-application-runtime',
2518
- template: '<ng-container #container />'
2519
- }]
2520
- }], propDecorators: { container: [{ type: i0.ViewChild, args: ['container', { ...{ read: ViewContainerRef }, isSignal: true }] }] } });
2521
-
2522
- /**
2523
- * Copyright (c) Siemens 2016 - 2026
2524
- * SPDX-License-Identifier: MIT
2525
- */
2526
- /**
2527
- * Configures live preview with each example rendered in an independent Angular application.
2528
- */
2529
- const provideLivePreview = (config, isMobile = false) => {
2530
- return makeEnvironmentProviders([
2531
- provideRouter(livePreviewRoutes, withHashLocation()),
2532
- {
2533
- provide: SI_LIVE_PREVIEW_CONFIG,
2534
- useValue: {
2535
- ...config,
2536
- runtimeComponent: config.runtimeComponent ?? SiDefaultLivePreviewApplicationRuntimeComponent
2537
- }
2538
- },
2539
- {
2540
- provide: SI_LIVE_PREVIEW_INTERNALS,
2541
- useValue: { isMobile, titleBase: 'Overview - Live Preview' }
2542
- }
2543
- ]);
2544
- };
2545
-
2546
- /**
2547
- * Copyright (c) Siemens 2016 - 2026
2548
- * SPDX-License-Identifier: MIT
2549
- */
2550
- /**
2551
- * Documentation component shared with the optional elements entry point.
2552
- * @internal
2553
- */
2554
- class SiDocsComponentComponent {
2555
- example = input('', /* @ts-ignore */
2556
- ...(ngDevMode ? [{ debugName: "example" }] : /* istanbul ignore next */ []));
2557
- base = input('', /* @ts-ignore */
2558
- ...(ngDevMode ? [{ debugName: "base" }] : /* istanbul ignore next */ []));
2559
- height = input(204, { ...(ngDevMode ? { debugName: "height" } : /* istanbul ignore next */ {}), transform: numberAttribute });
2560
- theme = input(/* @ts-ignore */
2561
- ...(ngDevMode ? [undefined, { debugName: "theme" }] : /* istanbul ignore next */ []));
2562
- state = inject(LivePreviewStateService);
2563
- document = inject(DOCUMENT);
2564
- host = inject(ElementRef).nativeElement;
2565
- documentTheme = signal(this.readDocumentTheme(), /* @ts-ignore */
2566
- ...(ngDevMode ? [{ debugName: "documentTheme" }] : /* istanbul ignore next */ []));
2567
- childExamples = signal([], /* @ts-ignore */
2568
- ...(ngDevMode ? [{ debugName: "childExamples" }] : /* istanbul ignore next */ []));
2569
- previewTheme = computed(() => this.theme() ?? this.documentTheme(), /* @ts-ignore */
2570
- ...(ngDevMode ? [{ debugName: "previewTheme" }] : /* istanbul ignore next */ []));
2571
- activeTabIndex = signal(0, /* @ts-ignore */
2572
- ...(ngDevMode ? [{ debugName: "activeTabIndex" }] : /* istanbul ignore next */ []));
2573
- previewHeight = computed(() => {
2574
- const height = this.height();
2575
- return Number.isFinite(height) && height >= 0 ? height : 204;
2576
- }, /* @ts-ignore */
2577
- ...(ngDevMode ? [{ debugName: "previewHeight" }] : /* istanbul ignore next */ []));
2578
- tabs = computed(() => [
2579
- ...(this.example() ? [{ example: this.example(), heading: '' }] : []),
2580
- ...this.childExamples()
2581
- ], /* @ts-ignore */
2582
- ...(ngDevMode ? [{ debugName: "tabs" }] : /* istanbul ignore next */ []));
2583
- constructor() {
2584
- const readTabs = () => {
2585
- this.childExamples.set(Array.from(this.host.querySelectorAll(':scope > si-docs-tab[example]'), tab => ({
2586
- example: tab.getAttribute('example') ?? '',
2587
- heading: tab.getAttribute('heading') ?? ''
2588
- })));
2589
- };
2590
- readTabs();
2591
- const observer = new MutationObserver(readTabs);
2592
- observer.observe(this.host, {
2593
- childList: true,
2594
- subtree: true,
2595
- attributes: true,
2596
- attributeFilter: ['example', 'heading']
2597
- });
2598
- const themeObserver = new MutationObserver(() => this.documentTheme.set(this.readDocumentTheme()));
2599
- themeObserver.observe(this.document.body, {
2600
- attributes: true,
2601
- attributeFilter: ['data-md-color-scheme']
2602
- });
2603
- inject(DestroyRef).onDestroy(() => {
2604
- observer.disconnect();
2605
- themeObserver.disconnect();
2606
- });
2607
- effect(() => {
2608
- this.tabs();
2609
- this.activeTabIndex.set(0);
2610
- });
2611
- effect(() => {
2612
- const tab = this.tabs()[this.activeTabIndex()];
2613
- const base = this.base().replace(/\/$/, '');
2614
- this.state.clearTemplates();
2615
- this.state.example.set(tab ? `${base ? base + '/' : ''}${tab.example}` : '');
2616
- });
2617
- effect(() => {
2618
- this.state.theme.set(this.previewTheme());
2619
- });
2620
- }
2621
- readDocumentTheme() {
2622
- return this.document.body.getAttribute('data-md-color-scheme') === 'dark' ? 'dark' : 'light';
2623
- }
2624
- activateTab(index, focus = false) {
2625
- this.activeTabIndex.set(index);
2626
- if (focus) {
2627
- this.host.shadowRoot?.querySelector(`#example-tab-${index}`)?.focus();
2628
- }
2629
- }
2630
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiDocsComponentComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
2631
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.8", type: SiDocsComponentComponent, isStandalone: true, selector: "si-docs-component", inputs: { example: { classPropertyName: "example", publicName: "example", isSignal: true, isRequired: false, transformFunction: null }, base: { classPropertyName: "base", publicName: "base", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null }, theme: { classPropertyName: "theme", publicName: "theme", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "style.--preview-height": "previewHeight() + \"px\"" } }, providers: [LivePreviewStateService, LivePreviewUrlService], ngImport: i0, template: "<slot hidden></slot>\n@defer (on viewport) {\n @if (tabs().length > 1) {\n <div role=\"tablist\" class=\"lp-tabs\" aria-label=\"Examples\">\n @for (tab of tabs(); track $index) {\n <button\n type=\"button\"\n role=\"tab\"\n class=\"tab-item tab-link\"\n aria-controls=\"example-panel\"\n [id]=\"'example-tab-' + $index\"\n [class.tab-active]=\"activeTabIndex() === $index\"\n [attr.aria-selected]=\"activeTabIndex() === $index\"\n [tabIndex]=\"activeTabIndex() === $index ? 0 : -1\"\n (click)=\"activateTab($index)\"\n (keydown.arrowRight)=\"activateTab(($index + 1) % $count, true); $event.preventDefault()\"\n (keydown.arrowLeft)=\"\n activateTab(($index + $count - 1) % $count, true); $event.preventDefault()\n \"\n (keydown.home)=\"activateTab(0, true); $event.preventDefault()\"\n (keydown.end)=\"activateTab($count - 1, true); $event.preventDefault()\"\n >\n {{ tab.heading || tab.example }}\n </button>\n }\n </div>\n }\n <div\n id=\"example-panel\"\n class=\"preview\"\n [attr.role]=\"tabs().length > 1 ? 'tabpanel' : null\"\n [attr.aria-labelledby]=\"tabs().length > 1 ? 'example-tab-' + activeTabIndex() : null\"\n >\n <si-live-preview class=\"embedded\" [initialTheme]=\"previewTheme()\" />\n </div>\n} @placeholder {\n <div class=\"preview placeholder\" aria-hidden=\"true\"></div>\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(--si-sys-sizing-focus-ring-width, 2px))}.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)}:host{display:block;box-sizing:border-box;inline-size:100%;border:1px solid var(--si-sys-color-border-4);color:var(--si-sys-color-text-primary);background:var(--si-sys-color-background-0)}*,*:before,*:after{box-sizing:border-box}button,select,textarea{font:inherit}button{cursor:pointer}.preview{display:flex;flex-direction:column}.placeholder{block-size:var(--preview-height, 204px)}.lp-tabs{border-block-end:1px solid var(--si-sys-color-border-4)}\n"], encapsulation: i0.ViewEncapsulation.ShadowDom, deferBlockDependencies: [() => [/* @ts-ignore */
2632
- Promise.resolve().then(function () { return siLivePreview_component; }).then(m => m.SiLivePreviewComponent)]] });
2633
- }
2634
- i0.ɵɵngDeclareClassMetadataAsync({ minVersion: "18.0.0", version: "22.0.8", ngImport: i0, type: SiDocsComponentComponent, resolveDeferredDeps: () => [/* @ts-ignore */
2635
- Promise.resolve().then(function () { return siLivePreview_component; }).then(m => m.SiLivePreviewComponent)], resolveMetadata: SiLivePreviewComponent => ({ decorators: [{
2636
- type: Component,
2637
- args: [{ selector: 'si-docs-component', imports: [SiLivePreviewComponent], providers: [LivePreviewStateService, LivePreviewUrlService], encapsulation: ViewEncapsulation.ShadowDom, host: {
2638
- '[style.--preview-height]': 'previewHeight() + "px"'
2639
- }, template: "<slot hidden></slot>\n@defer (on viewport) {\n @if (tabs().length > 1) {\n <div role=\"tablist\" class=\"lp-tabs\" aria-label=\"Examples\">\n @for (tab of tabs(); track $index) {\n <button\n type=\"button\"\n role=\"tab\"\n class=\"tab-item tab-link\"\n aria-controls=\"example-panel\"\n [id]=\"'example-tab-' + $index\"\n [class.tab-active]=\"activeTabIndex() === $index\"\n [attr.aria-selected]=\"activeTabIndex() === $index\"\n [tabIndex]=\"activeTabIndex() === $index ? 0 : -1\"\n (click)=\"activateTab($index)\"\n (keydown.arrowRight)=\"activateTab(($index + 1) % $count, true); $event.preventDefault()\"\n (keydown.arrowLeft)=\"\n activateTab(($index + $count - 1) % $count, true); $event.preventDefault()\n \"\n (keydown.home)=\"activateTab(0, true); $event.preventDefault()\"\n (keydown.end)=\"activateTab($count - 1, true); $event.preventDefault()\"\n >\n {{ tab.heading || tab.example }}\n </button>\n }\n </div>\n }\n <div\n id=\"example-panel\"\n class=\"preview\"\n [attr.role]=\"tabs().length > 1 ? 'tabpanel' : null\"\n [attr.aria-labelledby]=\"tabs().length > 1 ? 'example-tab-' + activeTabIndex() : null\"\n >\n <si-live-preview class=\"embedded\" [initialTheme]=\"previewTheme()\" />\n </div>\n} @placeholder {\n <div class=\"preview placeholder\" aria-hidden=\"true\"></div>\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(--si-sys-sizing-focus-ring-width, 2px))}.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)}:host{display:block;box-sizing:border-box;inline-size:100%;border:1px solid var(--si-sys-color-border-4);color:var(--si-sys-color-text-primary);background:var(--si-sys-color-background-0)}*,*:before,*:after{box-sizing:border-box}button,select,textarea{font:inherit}button{cursor:pointer}.preview{display:flex;flex-direction:column}.placeholder{block-size:var(--preview-height, 204px)}.lp-tabs{border-block-end:1px solid var(--si-sys-color-border-4)}\n"] }]
2640
- }], ctorParameters: () => [], propDecorators: { example: [{ type: i0.Input, args: [{ isSignal: true, alias: "example", required: false }] }], base: [{ type: i0.Input, args: [{ isSignal: true, alias: "base", required: false }] }], height: [{ type: i0.Input, args: [{ isSignal: true, alias: "height", required: false }] }], theme: [{ type: i0.Input, args: [{ isSignal: true, alias: "theme", required: false }] }] } }) });
2641
-
2642
- /**
2643
- * Copyright (c) Siemens 2016 - 2026
2644
- * SPDX-License-Identifier: MIT
2645
- */
2646
- class SiLivePreviewModule {
2647
- static forRoot(config, isMobile = false) {
2648
- return {
2649
- ngModule: SiLivePreviewModule,
2650
- providers: [
2651
- { provide: SI_LIVE_PREVIEW_CONFIG, useValue: config },
2652
- {
2653
- provide: SI_LIVE_PREVIEW_INTERNALS,
2654
- useValue: { isMobile, titleBase: 'Overview - Live Preview' }
2655
- }
2656
- ]
2657
- };
2658
- }
2659
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiLivePreviewModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2660
- static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "22.0.8", ngImport: i0, type: SiLivePreviewModule });
2661
- 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 }] });
2662
- }
2663
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiLivePreviewModule, decorators: [{
2664
- type: NgModule,
2665
- args: [{
2666
- providers: [{ provide: REMOVE_STYLES_ON_COMPONENT_DESTROY, useValue: true }]
2667
- }]
2668
- }] });
2669
-
2670
- /**
2671
- * Copyright (c) Siemens 2016 - 2026
2672
- * SPDX-License-Identifier: MIT
2673
- */
2674
- // Public API Surface
2675
-
2676
- /**
2677
- * Generated bundle index. Do not edit.
2678
- */
2679
-
2680
- export { LOG_EVENT, LandscapeSupportService, SI_LIVE_PREVIEW_CONFIG, SI_LIVE_PREVIEW_EXAMPLE_ROUTES, SI_LIVE_PREVIEW_INTERNALS, SI_STACKBLITZ_CONFIG, SiDocsComponentComponent, 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';
2681
2
  //# sourceMappingURL=siemens-live-preview.mjs.map