@siemens/live-preview 47.0.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.
- package/README.md +13 -0
- package/component-loader.cjs +54 -0
- package/components/si-dummy.component.d.ts +8 -0
- package/components/si-example-overview/si-example-overview.component.d.ts +35 -0
- package/components/si-example-viewer/si-example-viewer.component.d.ts +40 -0
- package/components/si-live-preview/si-live-preview.component.d.ts +103 -0
- package/components/si-live-preview-iframe/devices.d.ts +25 -0
- package/components/si-live-preview-iframe/si-live-preview-iframe.component.d.ts +65 -0
- package/components/si-live-preview-qr/si-live-preview-qr.component.d.ts +20 -0
- package/components/si-live-preview-renderer/si-live-preview-renderer.component.d.ts +64 -0
- package/components/si-live-preview-renderer/webcomponent/si-live-webcomponent.service.d.ts +12 -0
- package/components/si-live-preview-wrapper/si-live-preview-wrapper.component.d.ts +41 -0
- package/esbuild-component-loader.mjs +64 -0
- package/fesm2022/siemens-live-preview-webcomponents.mjs +205 -0
- package/fesm2022/siemens-live-preview-webcomponents.mjs.map +1 -0
- package/fesm2022/siemens-live-preview.mjs +2027 -0
- package/fesm2022/siemens-live-preview.mjs.map +1 -0
- package/helpers/log-event.d.ts +6 -0
- package/helpers/utils.d.ts +9 -0
- package/index.d.ts +5 -0
- package/interfaces/live-preview-config.d.ts +28 -0
- package/interfaces/si-live-preview.api.d.ts +15 -0
- package/live-preview-routes.d.ts +9 -0
- package/package.json +74 -0
- package/public-api.d.ts +20 -0
- package/public-api.module.d.ts +19 -0
- package/services/landscape-support.service.d.ts +5 -0
- package/styles/_variables.scss +23 -0
- package/styles/components/_links.scss +14 -0
- package/styles/components/_tabs.scss +46 -0
- package/styles/live-preview.scss +16 -0
- package/webcomponents/components/si-live-preview-renderer/webcomponent/si-live-preview-web.component.d.ts +28 -0
- package/webcomponents/components/si-live-preview-renderer/webcomponent/si-live-webcomponent.service.d.ts +12 -0
- package/webcomponents/components/si-live-preview-renderer/webcomponent/si-webcomponent-render.service.d.ts +20 -0
- package/webcomponents/index.d.ts +5 -0
- package/webcomponents/interfaces/live-preview-config.d.ts +28 -0
- package/webcomponents/package.json +3 -0
- package/webcomponents/public-api.webcomponents.d.ts +6 -0
|
@@ -0,0 +1,2027 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { Component, InjectionToken, EventEmitter, Output, Input, viewChild, inject, NgZone, DestroyRef, HostBinding, ElementRef, HostListener, Injectable, ViewContainerRef, Compiler, Injector, EnvironmentInjector, ɵcompileComponent as _compileComponent, ChangeDetectorRef, ViewChild, NgModule, ɵcompileNgModule as _compileNgModule, ɵresetCompiledComponents as _resetCompiledComponents, createNgModule } from '@angular/core';
|
|
3
|
+
import * as i1 from '@angular/router';
|
|
4
|
+
import { ActivatedRoute, Router, RouterModule } from '@angular/router';
|
|
5
|
+
import * as i1$1 from '@angular/forms';
|
|
6
|
+
import { UntypedFormControl, FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|
7
|
+
import { Title, ɵDomRendererFactory2 as _DomRendererFactory2, REMOVE_STYLES_ON_COMPONENT_DESTROY } from '@angular/platform-browser';
|
|
8
|
+
import { throttleTime, timeout, retry, filter, map, debounceTime, distinctUntilChanged } from 'rxjs/operators';
|
|
9
|
+
import { HttpClient } from '@angular/common/http';
|
|
10
|
+
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
11
|
+
import CodeFlask from 'codeflask';
|
|
12
|
+
import { fromEvent, Subject } from 'rxjs';
|
|
13
|
+
import 'prismjs/components/prism-typescript';
|
|
14
|
+
import qrcode from 'qrcode-generator';
|
|
15
|
+
import * as i3 from '@angular/common';
|
|
16
|
+
import { CommonModule } from '@angular/common';
|
|
17
|
+
import { __decorate } from 'tslib';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Copyright Siemens 2016 - 2025.
|
|
21
|
+
* SPDX-License-Identifier: MIT
|
|
22
|
+
*/
|
|
23
|
+
class SiDummyComponent {
|
|
24
|
+
path = '';
|
|
25
|
+
constructor(activeRoute) {
|
|
26
|
+
activeRoute.url.subscribe(url => (this.path = url.toString()));
|
|
27
|
+
}
|
|
28
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: SiDummyComponent, deps: [{ token: i1.ActivatedRoute }], target: i0.ɵɵFactoryTarget.Component });
|
|
29
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.0.6", type: SiDummyComponent, isStandalone: false, selector: "si-dummy", ngImport: i0, template: `<div class="ion-padding"> Content with path '{{ path }}'</div>`, isInline: true });
|
|
30
|
+
}
|
|
31
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: SiDummyComponent, decorators: [{
|
|
32
|
+
type: Component,
|
|
33
|
+
args: [{
|
|
34
|
+
selector: 'si-dummy',
|
|
35
|
+
// eslint-disable-next-line @angular-eslint/prefer-standalone
|
|
36
|
+
standalone: false,
|
|
37
|
+
template: `<div class="ion-padding"> Content with path '{{ path }}'</div>`
|
|
38
|
+
}]
|
|
39
|
+
}], ctorParameters: () => [{ type: i1.ActivatedRoute }] });
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Copyright Siemens 2016 - 2025.
|
|
43
|
+
* SPDX-License-Identifier: MIT
|
|
44
|
+
*/
|
|
45
|
+
const SI_LIVE_PREVIEW_CONFIG = new InjectionToken('SI_LIVE_PREVIEW_CONFIG');
|
|
46
|
+
const SI_LIVE_PREVIEW_INTERNALS = new InjectionToken('SI_LIVE_PREVIEW_INTERNALS');
|
|
47
|
+
const SI_LIVE_PREVIEW_EXAMPLE_ROUTES = new InjectionToken('SI_LIVE_PREVIEW_EXAMPLE_ROUTES');
|
|
48
|
+
|
|
49
|
+
class SiLivePreviewThemeApi {
|
|
50
|
+
}
|
|
51
|
+
class SiLivePreviewLocaleApi {
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const availableDevices = [
|
|
55
|
+
{
|
|
56
|
+
id: 'iphone-12-pro',
|
|
57
|
+
mode: 'ios',
|
|
58
|
+
name: 'iPhone 12 / 12 Pro',
|
|
59
|
+
height: '844',
|
|
60
|
+
width: '390',
|
|
61
|
+
notch: true,
|
|
62
|
+
safeAreaPortrait: { top: 44, bottom: 34, left: 0, right: 0 },
|
|
63
|
+
safeAreaLandscape: { top: 0, bottom: 21, left: 44, right: 44 }
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
id: 'iphone-11-pro',
|
|
67
|
+
mode: 'ios',
|
|
68
|
+
name: 'iPhone 11 Pro',
|
|
69
|
+
height: '812',
|
|
70
|
+
width: '375',
|
|
71
|
+
notch: true,
|
|
72
|
+
safeAreaPortrait: { top: 44, bottom: 34, left: 0, right: 0 },
|
|
73
|
+
safeAreaLandscape: { top: 0, bottom: 21, left: 44, right: 44 }
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
id: 'iphone-11',
|
|
77
|
+
mode: 'ios',
|
|
78
|
+
name: 'iPhone 11',
|
|
79
|
+
height: '896',
|
|
80
|
+
width: '414',
|
|
81
|
+
notch: true,
|
|
82
|
+
safeAreaPortrait: { top: 44, bottom: 34, left: 0, right: 0 },
|
|
83
|
+
safeAreaLandscape: { top: 0, bottom: 21, left: 44, right: 44 }
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
id: 'iphone-x',
|
|
87
|
+
mode: 'ios',
|
|
88
|
+
name: 'iPhone X / XS',
|
|
89
|
+
height: '812',
|
|
90
|
+
width: '375',
|
|
91
|
+
notch: true,
|
|
92
|
+
safeAreaPortrait: { top: 44, bottom: 34, left: 0, right: 0 },
|
|
93
|
+
safeAreaLandscape: { top: 0, bottom: 21, left: 44, right: 44 }
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
id: 'iphone-8',
|
|
97
|
+
mode: 'ios',
|
|
98
|
+
name: 'iPhone 8',
|
|
99
|
+
height: '667',
|
|
100
|
+
width: '375',
|
|
101
|
+
safeAreaPortrait: { top: 20, bottom: 0, left: 0, right: 0 },
|
|
102
|
+
safeAreaLandscape: { top: 0, bottom: 0, left: 0, right: 0 }
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
id: 'samsung-gal-s20',
|
|
106
|
+
mode: 'md',
|
|
107
|
+
name: 'Samsung Galaxy S20',
|
|
108
|
+
height: '800',
|
|
109
|
+
width: '360',
|
|
110
|
+
safeAreaPortrait: { top: 20, bottom: 10, left: 0, right: 0 },
|
|
111
|
+
safeAreaLandscape: { top: 20, bottom: 10, left: 0, right: 0 }
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
id: 'samsung-gal-s10',
|
|
115
|
+
mode: 'md',
|
|
116
|
+
name: 'Samsung Galaxy S10',
|
|
117
|
+
height: '760',
|
|
118
|
+
width: '360',
|
|
119
|
+
safeAreaPortrait: { top: 20, bottom: 10, left: 0, right: 0 },
|
|
120
|
+
safeAreaLandscape: { top: 20, bottom: 10, left: 0, right: 0 }
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
id: 'samsung-gal-s9',
|
|
124
|
+
mode: 'md',
|
|
125
|
+
name: 'Samsung Galaxy S9',
|
|
126
|
+
height: '740',
|
|
127
|
+
width: '360',
|
|
128
|
+
safeAreaPortrait: { top: 20, bottom: 10, left: 0, right: 0 },
|
|
129
|
+
safeAreaLandscape: { top: 20, bottom: 10, left: 0, right: 0 }
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
id: 'samsung-gal-note10',
|
|
133
|
+
mode: 'md',
|
|
134
|
+
name: 'Samsung Galaxy Note 10',
|
|
135
|
+
height: '869',
|
|
136
|
+
width: '412',
|
|
137
|
+
safeAreaPortrait: { top: 20, bottom: 10, left: 0, right: 0 },
|
|
138
|
+
safeAreaLandscape: { top: 20, bottom: 10, left: 0, right: 0 }
|
|
139
|
+
}
|
|
140
|
+
];
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Copyright Siemens 2016 - 2025.
|
|
144
|
+
* SPDX-License-Identifier: MIT
|
|
145
|
+
*/
|
|
146
|
+
class SiLivePreviewQrComponent {
|
|
147
|
+
url;
|
|
148
|
+
urlShort;
|
|
149
|
+
closed = new EventEmitter();
|
|
150
|
+
qrImg = '';
|
|
151
|
+
qrShort = false;
|
|
152
|
+
unlisten;
|
|
153
|
+
ngOnChanges(changes) {
|
|
154
|
+
if (changes.url && changes.urlShort) {
|
|
155
|
+
this.generateQr();
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
ngAfterViewInit() {
|
|
159
|
+
const listener = () => this.closed.emit();
|
|
160
|
+
setTimeout(() => window.addEventListener('click', listener));
|
|
161
|
+
this.unlisten = () => window.removeEventListener('click', listener);
|
|
162
|
+
}
|
|
163
|
+
ngOnDestroy() {
|
|
164
|
+
if (this.unlisten) {
|
|
165
|
+
this.unlisten();
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
generateQr() {
|
|
169
|
+
this.qrShort = (this.url?.length ?? 0) > 2953;
|
|
170
|
+
const url = this.qrShort ? this.urlShort : this.url;
|
|
171
|
+
const qr = qrcode(0, 'L');
|
|
172
|
+
qr.addData(url);
|
|
173
|
+
qr.make();
|
|
174
|
+
this.qrImg = qr.createImgTag(2);
|
|
175
|
+
}
|
|
176
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: SiLivePreviewQrComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
177
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.6", type: SiLivePreviewQrComponent, isStandalone: false, selector: "si-live-preview-qr", inputs: { url: "url", urlShort: "urlShort" }, outputs: { closed: "closed" }, usesOnChanges: true, 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(--element-action-secondary-text)}a:after{display:none}a:hover{color:var(--element-action-secondary-text-hover)}: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(--element-base-0)}.qr ::ng-deep img{max-inline-size:unset}hr{margin-block:12px;border:0;border-block-start:1px solid var(--element-ui-4)}.url-length{display:none}\n"] });
|
|
178
|
+
}
|
|
179
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: SiLivePreviewQrComponent, decorators: [{
|
|
180
|
+
type: Component,
|
|
181
|
+
args: [{ selector: 'si-live-preview-qr', standalone: false, 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(--element-action-secondary-text)}a:after{display:none}a:hover{color:var(--element-action-secondary-text-hover)}: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(--element-base-0)}.qr ::ng-deep img{max-inline-size:unset}hr{margin-block:12px;border:0;border-block-start:1px solid var(--element-ui-4)}.url-length{display:none}\n"] }]
|
|
182
|
+
}], propDecorators: { url: [{
|
|
183
|
+
type: Input
|
|
184
|
+
}], urlShort: [{
|
|
185
|
+
type: Input
|
|
186
|
+
}], closed: [{
|
|
187
|
+
type: Output
|
|
188
|
+
}] } });
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Copyright Siemens 2016 - 2025.
|
|
192
|
+
* SPDX-License-Identifier: MIT
|
|
193
|
+
*/
|
|
194
|
+
class SiLivePreviewIframeComponent {
|
|
195
|
+
previewIframe = viewChild('previewIframe');
|
|
196
|
+
baseUrl;
|
|
197
|
+
exampleUrl;
|
|
198
|
+
template;
|
|
199
|
+
ticketLinkBug;
|
|
200
|
+
ticketLinkFeature;
|
|
201
|
+
isFullscreen = false;
|
|
202
|
+
iFrameHeight;
|
|
203
|
+
iFrameWidth;
|
|
204
|
+
theme = 'light';
|
|
205
|
+
locale;
|
|
206
|
+
isRTL;
|
|
207
|
+
loadReact;
|
|
208
|
+
loadVue;
|
|
209
|
+
loadJs;
|
|
210
|
+
reactVueTemplate;
|
|
211
|
+
templateFromComponent = new EventEmitter(true);
|
|
212
|
+
logClear = new EventEmitter();
|
|
213
|
+
logMessage = new EventEmitter();
|
|
214
|
+
logRenderingError = new EventEmitter();
|
|
215
|
+
inProgress = new EventEmitter();
|
|
216
|
+
themeChange = new EventEmitter();
|
|
217
|
+
localeChange = new EventEmitter();
|
|
218
|
+
originalTemplate = '';
|
|
219
|
+
templateModified = false;
|
|
220
|
+
rendererInProgress = false;
|
|
221
|
+
config = inject(SI_LIVE_PREVIEW_CONFIG);
|
|
222
|
+
internalConfig = inject(SI_LIVE_PREVIEW_INTERNALS);
|
|
223
|
+
ngZone = inject(NgZone);
|
|
224
|
+
destroyRef = inject(DestroyRef);
|
|
225
|
+
isMobile = this.internalConfig.isMobile;
|
|
226
|
+
mode = 'ios';
|
|
227
|
+
landscape = false;
|
|
228
|
+
switcherEnabled = this.config.themeSwitcher;
|
|
229
|
+
landscapeEnabled = this.config.landscapeToggle;
|
|
230
|
+
supportsLandscape = false;
|
|
231
|
+
availableDevices = availableDevices;
|
|
232
|
+
selectedDevice;
|
|
233
|
+
showNotch;
|
|
234
|
+
showQrMenu = false;
|
|
235
|
+
plainUrl = '';
|
|
236
|
+
plainUrlShort = '';
|
|
237
|
+
ngOnChanges(changes) {
|
|
238
|
+
if (!this.previewIframe()) {
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
if (changes.template) {
|
|
242
|
+
this.templateModified = this.originalTemplate !== this.template;
|
|
243
|
+
}
|
|
244
|
+
this.sendMessage();
|
|
245
|
+
}
|
|
246
|
+
ngOnInit() {
|
|
247
|
+
this.ngZone.runOutsideAngular(() => fromEvent(window, 'message')
|
|
248
|
+
.pipe(takeUntilDestroyed(this.destroyRef))
|
|
249
|
+
.subscribe(message => this.onMessage(message)));
|
|
250
|
+
if (this.isMobile) {
|
|
251
|
+
const deviceId = localStorage.getItem('si-live-preview-selected-device');
|
|
252
|
+
this.selectedDevice =
|
|
253
|
+
this.availableDevices.find(dev => dev.id === deviceId) ?? this.availableDevices[0];
|
|
254
|
+
this.deviceChanged();
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
deviceChanged() {
|
|
258
|
+
this.selectedDevice ??= this.availableDevices[0];
|
|
259
|
+
this.iFrameHeight = this.landscape ? this.selectedDevice.width : this.selectedDevice.height;
|
|
260
|
+
this.iFrameWidth = this.landscape ? this.selectedDevice.height : this.selectedDevice.width;
|
|
261
|
+
this.showNotch = this.selectedDevice.notch ?? false;
|
|
262
|
+
this.mode = this.selectedDevice.mode;
|
|
263
|
+
localStorage.setItem('si-live-preview-selected-device', this.selectedDevice.id);
|
|
264
|
+
this.sendMessage();
|
|
265
|
+
}
|
|
266
|
+
onMessage(event) {
|
|
267
|
+
if (!event.data || event.data.src !== 'renderer') {
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
this.ngZone.run(() => this.onMessageInZone(event));
|
|
271
|
+
}
|
|
272
|
+
onMessageInZone(event) {
|
|
273
|
+
switch (event.data.type) {
|
|
274
|
+
case 'landscapeMode':
|
|
275
|
+
this.supportsLandscape = event.data.message;
|
|
276
|
+
if (!this.supportsLandscape && this.landscape) {
|
|
277
|
+
this.landscape = false;
|
|
278
|
+
this.deviceChanged();
|
|
279
|
+
}
|
|
280
|
+
break;
|
|
281
|
+
case 'clear':
|
|
282
|
+
this.logClear.emit();
|
|
283
|
+
break;
|
|
284
|
+
case 'log':
|
|
285
|
+
this.logMessage.emit(event.data.message);
|
|
286
|
+
break;
|
|
287
|
+
case 'error':
|
|
288
|
+
this.logRenderingError.emit(event.data.message);
|
|
289
|
+
break;
|
|
290
|
+
case 'progress':
|
|
291
|
+
{
|
|
292
|
+
const progress = event.data.message;
|
|
293
|
+
if (progress !== this.rendererInProgress) {
|
|
294
|
+
// only emit changes since live-previewer does counting
|
|
295
|
+
this.rendererInProgress = progress;
|
|
296
|
+
this.inProgress.emit(progress);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
break;
|
|
300
|
+
case 'templateFromComponent':
|
|
301
|
+
this.originalTemplate = event.data.message;
|
|
302
|
+
this.templateModified = false;
|
|
303
|
+
this.templateFromComponent.emit(event.data.message);
|
|
304
|
+
break;
|
|
305
|
+
case 'theme':
|
|
306
|
+
this.theme = event.data.message;
|
|
307
|
+
this.themeChange.emit(event.data.message);
|
|
308
|
+
break;
|
|
309
|
+
case 'locale':
|
|
310
|
+
this.locale = event.data.message;
|
|
311
|
+
this.localeChange.emit(event.data.message);
|
|
312
|
+
break;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
toggleTheme() {
|
|
316
|
+
this.theme = this.theme === 'dark' ? 'light' : 'dark';
|
|
317
|
+
this.themeChange.emit(this.theme);
|
|
318
|
+
this.sendMessage();
|
|
319
|
+
}
|
|
320
|
+
toggleLandscape() {
|
|
321
|
+
this.landscape = !this.landscape;
|
|
322
|
+
this.iFrameHeight = this.landscape ? this.selectedDevice?.width : this.selectedDevice?.height;
|
|
323
|
+
this.iFrameWidth = this.landscape ? this.selectedDevice?.height : this.selectedDevice?.width;
|
|
324
|
+
this.sendMessage();
|
|
325
|
+
}
|
|
326
|
+
iframeLoaded() {
|
|
327
|
+
this.sendMessage();
|
|
328
|
+
}
|
|
329
|
+
openQrMenu() {
|
|
330
|
+
this.plainUrl = this.createTemplateLink('plain');
|
|
331
|
+
this.plainUrlShort = this.createTemplateLink('plain', true);
|
|
332
|
+
this.showQrMenu = true;
|
|
333
|
+
}
|
|
334
|
+
createTemplateLink(mode, skipTemplate = false) {
|
|
335
|
+
let url = `${window.location.protocol}//${window.location.host}`;
|
|
336
|
+
url += window.location.pathname;
|
|
337
|
+
url += `#/viewer/${mode}?`;
|
|
338
|
+
url += 'theme=' + this.theme;
|
|
339
|
+
url += '&mode=' + this.mode;
|
|
340
|
+
if (this.isRTL) {
|
|
341
|
+
url += '&isRTL=true';
|
|
342
|
+
}
|
|
343
|
+
if (this.locale) {
|
|
344
|
+
url += '&locale=' + this.locale;
|
|
345
|
+
}
|
|
346
|
+
if (this.templateModified && !skipTemplate) {
|
|
347
|
+
url += '&t=' + this.encode(this.template);
|
|
348
|
+
}
|
|
349
|
+
if (this.exampleUrl) {
|
|
350
|
+
url += '&e=' + this.encode(this.exampleUrl);
|
|
351
|
+
}
|
|
352
|
+
return url;
|
|
353
|
+
}
|
|
354
|
+
encode(value) {
|
|
355
|
+
// using `+` for space is shorter than `%20`
|
|
356
|
+
return encodeURIComponent(value).replace(/%20/g, '+');
|
|
357
|
+
}
|
|
358
|
+
sendMessage() {
|
|
359
|
+
this.previewIframe()?.nativeElement.contentWindow.postMessage({
|
|
360
|
+
src: 'editor',
|
|
361
|
+
exampleUrl: this.baseUrl + this.exampleUrl,
|
|
362
|
+
template: this.template,
|
|
363
|
+
loadReact: this.loadReact,
|
|
364
|
+
loadVue: this.loadVue,
|
|
365
|
+
loadJs: this.loadJs,
|
|
366
|
+
reactVueTemplate: this.reactVueTemplate,
|
|
367
|
+
theme: this.theme,
|
|
368
|
+
locale: this.locale,
|
|
369
|
+
isRTL: this.isRTL,
|
|
370
|
+
mode: this.mode,
|
|
371
|
+
safeAreaTop: this.landscape
|
|
372
|
+
? this.selectedDevice?.safeAreaLandscape?.top
|
|
373
|
+
: this.selectedDevice?.safeAreaPortrait?.top,
|
|
374
|
+
safeAreaBottom: this.landscape
|
|
375
|
+
? this.selectedDevice?.safeAreaLandscape?.bottom
|
|
376
|
+
: this.selectedDevice?.safeAreaPortrait?.bottom,
|
|
377
|
+
safeAreaLeft: this.landscape
|
|
378
|
+
? this.selectedDevice?.safeAreaLandscape?.left
|
|
379
|
+
: this.selectedDevice?.safeAreaPortrait?.left,
|
|
380
|
+
safeAreaRight: this.landscape
|
|
381
|
+
? this.selectedDevice?.safeAreaLandscape?.right
|
|
382
|
+
: this.selectedDevice?.safeAreaPortrait?.right
|
|
383
|
+
}, '*');
|
|
384
|
+
}
|
|
385
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: SiLivePreviewIframeComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
386
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.6", type: SiLivePreviewIframeComponent, isStandalone: false, selector: "si-live-preview-iframe", inputs: { baseUrl: "baseUrl", exampleUrl: "exampleUrl", template: "template", ticketLinkBug: "ticketLinkBug", ticketLinkFeature: "ticketLinkFeature", isFullscreen: "isFullscreen", iFrameHeight: "iFrameHeight", iFrameWidth: "iFrameWidth", theme: "theme", locale: "locale", isRTL: "isRTL", loadReact: "loadReact", loadVue: "loadVue", loadJs: "loadJs", reactVueTemplate: "reactVueTemplate" }, outputs: { templateFromComponent: "templateFromComponent", logClear: "logClear", logMessage: "logMessage", logRenderingError: "logRenderingError", inProgress: "inProgress", themeChange: "themeChange", localeChange: "localeChange" }, host: { properties: { "class.is-mobile": "this.isMobile" } }, viewQueries: [{ propertyName: "previewIframe", first: true, predicate: ["previewIframe"], descendants: true, isSignal: true }], usesOnChanges: true, ngImport: i0, template: "<section class=\"header-links\">\n <h1 class=\"example-text\">Example: {{ exampleUrl }}</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 <section class=\"settings-selection\">\n <select class=\"device-selection\" [(ngModel)]=\"selectedDevice\" (ngModelChange)=\"deviceChanged()\">\n @for (device of availableDevices; track $index) {\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 [disabled]=\"!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 }\n @if (landscape) {\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\n 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 />\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 type=\"button\" title=\"Toggle theme\" (click)=\"toggleTheme()\">\n @if (theme === 'light') {\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 @if (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 }\n </button>\n }\n <button type=\"button\" title=\"Show QR code\" class=\"qr-button\" (click)=\"openQrMenu()\">\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 = 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]=\"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]=\"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]=\"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 }\n\n <!-- iOS devices with notch -->\n @if (mode === 'ios' && showNotch) {\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 }\n\n <!-- iOS devices without notch -->\n @if (mode === 'ios' && !showNotch) {\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 <div class=\"screen\">\n <iframe\n #previewIframe\n src=\"#/iframe\"\n [height]=\"iFrameHeight\"\n [width]=\"iFrameWidth\"\n (load)=\"iframeLoaded()\"\n ></iframe>\n </div>\n </div>\n} @else {\n <iframe #previewIframe src=\"#/iframe\" title=\"Example view\" (load)=\"iframeLoaded()\"></iframe>\n}\n", styles: ["a{color:var(--element-action-secondary-text)}a:after{display:none}a:hover{color:var(--element-action-secondary-text-hover)}:host{display:inline-flex;flex-direction:column}:host.is-mobile{margin-block-end:28px}:host:not(.is-mobile){flex:1}iframe{border:0;display:block}:host:not(.is-mobile) iframe{block-size:100%}.header-links{block-size:32px;padding-block:9px;color:var(--element-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(--element-text-primary);display:inline;font-size:11px;font-weight:700;margin-block:0;margin-inline:0 8px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex:1 1 0;inline-size:0}.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(--element-action-secondary);display:flex;align-items:center;justify-content:center;block-size:40px;inline-size:40px;border:1px solid var(--element-ui-4);border-radius:50%;margin-inline-start:10px;position:relative}.settings-selection .toggle-wrapper button>svg{block-size:24px;fill:var(--element-text-primary)}.settings-selection .toggle-wrapper button>svg:hover{fill:var(--element-action-secondary-text-hover)}.settings-selection .toggle-wrapper button:disabled>svg{fill:var(--element-text-primary)}.device-selection{appearance:none;background-color:var(--element-base-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(--element-text-primary);block-size:35px;min-inline-size:200px;border-radius:2px;border:1px solid var(--element-ui-4);padding:6px;margin-block:0;display:flex;flex:1}.device-selection:focus{box-shadow:0 0 0 2px var(--element-button-focus-width) solid var(--element-focus-default)}.device{position:relative;box-sizing:content-box}.device .screen{background:var(--element-base-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: "directive", type: i1$1.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i1$1.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i1$1.SelectControlValueAccessor, selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", inputs: ["compareWith"] }, { kind: "directive", type: i1$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1$1.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"] }] });
|
|
387
|
+
}
|
|
388
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: SiLivePreviewIframeComponent, decorators: [{
|
|
389
|
+
type: Component,
|
|
390
|
+
args: [{ selector: 'si-live-preview-iframe', standalone: false, template: "<section class=\"header-links\">\n <h1 class=\"example-text\">Example: {{ exampleUrl }}</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 <section class=\"settings-selection\">\n <select class=\"device-selection\" [(ngModel)]=\"selectedDevice\" (ngModelChange)=\"deviceChanged()\">\n @for (device of availableDevices; track $index) {\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 [disabled]=\"!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 }\n @if (landscape) {\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\n 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 />\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 type=\"button\" title=\"Toggle theme\" (click)=\"toggleTheme()\">\n @if (theme === 'light') {\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 @if (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 }\n </button>\n }\n <button type=\"button\" title=\"Show QR code\" class=\"qr-button\" (click)=\"openQrMenu()\">\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 = 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]=\"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]=\"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]=\"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 }\n\n <!-- iOS devices with notch -->\n @if (mode === 'ios' && showNotch) {\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 }\n\n <!-- iOS devices without notch -->\n @if (mode === 'ios' && !showNotch) {\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 <div class=\"screen\">\n <iframe\n #previewIframe\n src=\"#/iframe\"\n [height]=\"iFrameHeight\"\n [width]=\"iFrameWidth\"\n (load)=\"iframeLoaded()\"\n ></iframe>\n </div>\n </div>\n} @else {\n <iframe #previewIframe src=\"#/iframe\" title=\"Example view\" (load)=\"iframeLoaded()\"></iframe>\n}\n", styles: ["a{color:var(--element-action-secondary-text)}a:after{display:none}a:hover{color:var(--element-action-secondary-text-hover)}:host{display:inline-flex;flex-direction:column}:host.is-mobile{margin-block-end:28px}:host:not(.is-mobile){flex:1}iframe{border:0;display:block}:host:not(.is-mobile) iframe{block-size:100%}.header-links{block-size:32px;padding-block:9px;color:var(--element-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(--element-text-primary);display:inline;font-size:11px;font-weight:700;margin-block:0;margin-inline:0 8px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex:1 1 0;inline-size:0}.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(--element-action-secondary);display:flex;align-items:center;justify-content:center;block-size:40px;inline-size:40px;border:1px solid var(--element-ui-4);border-radius:50%;margin-inline-start:10px;position:relative}.settings-selection .toggle-wrapper button>svg{block-size:24px;fill:var(--element-text-primary)}.settings-selection .toggle-wrapper button>svg:hover{fill:var(--element-action-secondary-text-hover)}.settings-selection .toggle-wrapper button:disabled>svg{fill:var(--element-text-primary)}.device-selection{appearance:none;background-color:var(--element-base-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(--element-text-primary);block-size:35px;min-inline-size:200px;border-radius:2px;border:1px solid var(--element-ui-4);padding:6px;margin-block:0;display:flex;flex:1}.device-selection:focus{box-shadow:0 0 0 2px var(--element-button-focus-width) solid var(--element-focus-default)}.device{position:relative;box-sizing:content-box}.device .screen{background:var(--element-base-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"] }]
|
|
391
|
+
}], propDecorators: { baseUrl: [{
|
|
392
|
+
type: Input
|
|
393
|
+
}], exampleUrl: [{
|
|
394
|
+
type: Input
|
|
395
|
+
}], template: [{
|
|
396
|
+
type: Input
|
|
397
|
+
}], ticketLinkBug: [{
|
|
398
|
+
type: Input
|
|
399
|
+
}], ticketLinkFeature: [{
|
|
400
|
+
type: Input
|
|
401
|
+
}], isFullscreen: [{
|
|
402
|
+
type: Input
|
|
403
|
+
}], iFrameHeight: [{
|
|
404
|
+
type: Input
|
|
405
|
+
}], iFrameWidth: [{
|
|
406
|
+
type: Input
|
|
407
|
+
}], theme: [{
|
|
408
|
+
type: Input
|
|
409
|
+
}], locale: [{
|
|
410
|
+
type: Input
|
|
411
|
+
}], isRTL: [{
|
|
412
|
+
type: Input
|
|
413
|
+
}], loadReact: [{
|
|
414
|
+
type: Input
|
|
415
|
+
}], loadVue: [{
|
|
416
|
+
type: Input
|
|
417
|
+
}], loadJs: [{
|
|
418
|
+
type: Input
|
|
419
|
+
}], reactVueTemplate: [{
|
|
420
|
+
type: Input
|
|
421
|
+
}], templateFromComponent: [{
|
|
422
|
+
type: Output
|
|
423
|
+
}], logClear: [{
|
|
424
|
+
type: Output
|
|
425
|
+
}], logMessage: [{
|
|
426
|
+
type: Output
|
|
427
|
+
}], logRenderingError: [{
|
|
428
|
+
type: Output
|
|
429
|
+
}], inProgress: [{
|
|
430
|
+
type: Output
|
|
431
|
+
}], themeChange: [{
|
|
432
|
+
type: Output
|
|
433
|
+
}], localeChange: [{
|
|
434
|
+
type: Output
|
|
435
|
+
}], isMobile: [{
|
|
436
|
+
type: HostBinding,
|
|
437
|
+
args: ['class.is-mobile']
|
|
438
|
+
}] } });
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* Copyright Siemens 2016 - 2025.
|
|
442
|
+
* SPDX-License-Identifier: MIT
|
|
443
|
+
*/
|
|
444
|
+
class SiLivePreviewComponent {
|
|
445
|
+
config = inject(SI_LIVE_PREVIEW_CONFIG);
|
|
446
|
+
internalConfig = inject(SI_LIVE_PREVIEW_INTERNALS);
|
|
447
|
+
self = inject(ElementRef);
|
|
448
|
+
http = inject(HttpClient);
|
|
449
|
+
destroyRef = inject(DestroyRef);
|
|
450
|
+
localeApi = inject(SiLivePreviewLocaleApi, { optional: true });
|
|
451
|
+
templateElem = viewChild.required('codeTemplate');
|
|
452
|
+
typescriptElem = viewChild.required('codeTypescript');
|
|
453
|
+
reactVueElem = viewChild.required('codeReactVue');
|
|
454
|
+
consoleElem = viewChild.required('consoleContainer');
|
|
455
|
+
baseUrl;
|
|
456
|
+
example;
|
|
457
|
+
template = '';
|
|
458
|
+
theme = 'light';
|
|
459
|
+
locale;
|
|
460
|
+
isRTL = false;
|
|
461
|
+
ticketBaseUrl;
|
|
462
|
+
templateReact = '';
|
|
463
|
+
templateVue = '';
|
|
464
|
+
templateJs = '';
|
|
465
|
+
isFullscreen = false;
|
|
466
|
+
isMobile = this.internalConfig.isMobile;
|
|
467
|
+
templateTs = '';
|
|
468
|
+
renderingError;
|
|
469
|
+
logMessages = [];
|
|
470
|
+
activeTab = 'template';
|
|
471
|
+
showCopied = false;
|
|
472
|
+
inProgress = false;
|
|
473
|
+
allowFullscreen = !!document.fullscreenEnabled || !!document.webkitFullscreenEnabled;
|
|
474
|
+
exampleFullscreen = false;
|
|
475
|
+
allowCopy = !!navigator.clipboard;
|
|
476
|
+
loadReact = false;
|
|
477
|
+
loadVue = false;
|
|
478
|
+
loadJs = false;
|
|
479
|
+
switcherEnabled = this.config.themeSwitcher;
|
|
480
|
+
rtlSwitcher = this.config.rtlSwitcher;
|
|
481
|
+
webcomponents = this.config.webcomponents;
|
|
482
|
+
frameworks = new Map([['Angular', 'angular']]);
|
|
483
|
+
selectedFramework = localStorage.getItem('si-live-preview-framework') ?? 'angular';
|
|
484
|
+
availableLocales = [];
|
|
485
|
+
ticketLinkBug;
|
|
486
|
+
ticketLinkFeature;
|
|
487
|
+
editorCollapsed = localStorage.getItem('si-live-preview-editor-collapsed') === 'true' && !this.isMobile;
|
|
488
|
+
showEditor = !this.editorCollapsed;
|
|
489
|
+
newMsgs = false;
|
|
490
|
+
compileSubject = new Subject();
|
|
491
|
+
templateModified = false;
|
|
492
|
+
skipInitialLoad = false;
|
|
493
|
+
flaskTemplate;
|
|
494
|
+
flaskTypescript;
|
|
495
|
+
flaskReactVue;
|
|
496
|
+
savedScrollPos = { top: 0, left: 0 };
|
|
497
|
+
inProgressCounter = 0;
|
|
498
|
+
tsLoaded = false;
|
|
499
|
+
reactLoaded = false;
|
|
500
|
+
vueLoaded = false;
|
|
501
|
+
jsLoaded = false;
|
|
502
|
+
delayClearTimer;
|
|
503
|
+
webcomponentsList = [];
|
|
504
|
+
constructor() {
|
|
505
|
+
this.compileSubject
|
|
506
|
+
.pipe(throttleTime(500, undefined, { leading: true, trailing: true }))
|
|
507
|
+
.pipe(takeUntilDestroyed(this.destroyRef))
|
|
508
|
+
.subscribe(template => (this.template = template));
|
|
509
|
+
this.webcomponentsList = this.config.componentLoader.webcomponentsList;
|
|
510
|
+
}
|
|
511
|
+
ngOnChanges(changes) {
|
|
512
|
+
this.activeTab = this.activeTab !== 'typescript' ? 'template' : this.activeTab;
|
|
513
|
+
if (changes.template?.currentValue) {
|
|
514
|
+
this.skipInitialLoad = !!changes.template.isFirstChange;
|
|
515
|
+
this.templateModified = true;
|
|
516
|
+
this.templateReact = '';
|
|
517
|
+
this.templateVue = '';
|
|
518
|
+
this.templateJs = '';
|
|
519
|
+
}
|
|
520
|
+
else {
|
|
521
|
+
this.skipInitialLoad =
|
|
522
|
+
changes.templateReact?.currentValue ??
|
|
523
|
+
changes.templateVue?.currentValue ??
|
|
524
|
+
changes.templateJs?.currentValue;
|
|
525
|
+
}
|
|
526
|
+
if (changes.example?.currentValue) {
|
|
527
|
+
this.loadFromUrl(changes.example.firstChange && this.skipInitialLoad);
|
|
528
|
+
if (this.webcomponents) {
|
|
529
|
+
this.checkWebComponentsAvailable();
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
if (this.webcomponents) {
|
|
533
|
+
this.reactLoaded = false;
|
|
534
|
+
this.vueLoaded = false;
|
|
535
|
+
this.jsLoaded = false;
|
|
536
|
+
this.loadReact = false;
|
|
537
|
+
this.loadVue = false;
|
|
538
|
+
this.loadJs = false;
|
|
539
|
+
}
|
|
540
|
+
this.createTicketLinks();
|
|
541
|
+
}
|
|
542
|
+
ngOnInit() {
|
|
543
|
+
this.availableLocales = this.localeApi?.availableLocales() ?? [];
|
|
544
|
+
this.theme = localStorage.getItem('si-live-preview-theme') ?? 'light';
|
|
545
|
+
}
|
|
546
|
+
ngAfterViewInit() {
|
|
547
|
+
this.flaskTemplate = new CodeFlask(this.templateElem().nativeElement, {
|
|
548
|
+
lineNumbers: true,
|
|
549
|
+
language: 'html',
|
|
550
|
+
defaultTheme: false,
|
|
551
|
+
handleSelfClosingCharacters: false,
|
|
552
|
+
handleTabs: false,
|
|
553
|
+
ariaLabelledby: 'templateEditorTab'
|
|
554
|
+
});
|
|
555
|
+
this.flaskTypescript = new CodeFlask(this.typescriptElem().nativeElement, {
|
|
556
|
+
lineNumbers: true,
|
|
557
|
+
language: 'typescript',
|
|
558
|
+
readonly: true,
|
|
559
|
+
defaultTheme: false,
|
|
560
|
+
handleTabs: false,
|
|
561
|
+
ariaLabelledby: 'typescriptEditorTab'
|
|
562
|
+
});
|
|
563
|
+
this.flaskReactVue = new CodeFlask(this.reactVueElem().nativeElement, {
|
|
564
|
+
lineNumbers: true,
|
|
565
|
+
language: 'typescript',
|
|
566
|
+
readonly: false,
|
|
567
|
+
defaultTheme: false,
|
|
568
|
+
handleTabs: false,
|
|
569
|
+
areaId: 'reactVueEditor'
|
|
570
|
+
});
|
|
571
|
+
this.flaskTemplate.onUpdate((code) => {
|
|
572
|
+
if (code !== this.template) {
|
|
573
|
+
this.templateModified = true;
|
|
574
|
+
}
|
|
575
|
+
this.compileSubject.next(code);
|
|
576
|
+
});
|
|
577
|
+
this.flaskReactVue.onUpdate((code) => {
|
|
578
|
+
if (this.activeTab === 'react') {
|
|
579
|
+
this.templateReact = code;
|
|
580
|
+
this.loadReact = true;
|
|
581
|
+
}
|
|
582
|
+
else if (this.activeTab === 'vue') {
|
|
583
|
+
this.templateVue = code;
|
|
584
|
+
this.loadVue = true;
|
|
585
|
+
}
|
|
586
|
+
else if (this.activeTab === 'js') {
|
|
587
|
+
this.templateJs = code;
|
|
588
|
+
this.loadJs = true;
|
|
589
|
+
}
|
|
590
|
+
});
|
|
591
|
+
if (this.skipInitialLoad) {
|
|
592
|
+
if (this.templateReact) {
|
|
593
|
+
this.reactLoaded = true;
|
|
594
|
+
this.changeFramework('react');
|
|
595
|
+
}
|
|
596
|
+
else if (this.templateVue) {
|
|
597
|
+
this.vueLoaded = true;
|
|
598
|
+
this.changeFramework('vue');
|
|
599
|
+
}
|
|
600
|
+
else if (this.templateJs) {
|
|
601
|
+
this.jsLoaded = true;
|
|
602
|
+
this.changeFramework('js');
|
|
603
|
+
}
|
|
604
|
+
else {
|
|
605
|
+
this.flaskTemplate.updateCode(this.template);
|
|
606
|
+
this.compileSubject.next(this.template);
|
|
607
|
+
}
|
|
608
|
+
this.skipInitialLoad = false;
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
activateTab(tab) {
|
|
612
|
+
this.activeTab = tab;
|
|
613
|
+
let saveScroll;
|
|
614
|
+
let restoreScroll;
|
|
615
|
+
this.loadReact = false;
|
|
616
|
+
this.loadVue = false;
|
|
617
|
+
this.loadJs = false;
|
|
618
|
+
if (tab === 'template') {
|
|
619
|
+
saveScroll = this.typescriptElem();
|
|
620
|
+
restoreScroll = this.templateElem();
|
|
621
|
+
}
|
|
622
|
+
else {
|
|
623
|
+
if (!this.tsLoaded) {
|
|
624
|
+
this.loadTsFromUrl();
|
|
625
|
+
}
|
|
626
|
+
saveScroll = this.templateElem();
|
|
627
|
+
restoreScroll = this.typescriptElem();
|
|
628
|
+
}
|
|
629
|
+
const areaSave = saveScroll.nativeElement.querySelector('textarea');
|
|
630
|
+
const areaRestore = restoreScroll.nativeElement.querySelector('textarea');
|
|
631
|
+
const scrollPos = this.savedScrollPos;
|
|
632
|
+
this.savedScrollPos = { left: areaSave.scrollLeft, top: areaSave.scrollTop };
|
|
633
|
+
setTimeout(() => {
|
|
634
|
+
areaRestore.scrollTop = scrollPos.top;
|
|
635
|
+
areaRestore.scrollLeft = scrollPos.left;
|
|
636
|
+
});
|
|
637
|
+
}
|
|
638
|
+
themeChange(theme) {
|
|
639
|
+
this.theme = theme;
|
|
640
|
+
localStorage.setItem('si-live-preview-theme', this.theme);
|
|
641
|
+
}
|
|
642
|
+
updateTemplate(template) {
|
|
643
|
+
this.templateModified = false;
|
|
644
|
+
this.template = template;
|
|
645
|
+
if (this.flaskTemplate) {
|
|
646
|
+
this.flaskTemplate.updateCode(this.template);
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
updateTs(ts) {
|
|
650
|
+
this.templateTs = ts;
|
|
651
|
+
if (this.flaskTypescript) {
|
|
652
|
+
this.flaskTypescript.updateCode(this.templateTs);
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
updateReact(ts) {
|
|
656
|
+
this.templateReact = ts;
|
|
657
|
+
if (this.flaskReactVue) {
|
|
658
|
+
this.flaskReactVue.updateCode(this.templateReact);
|
|
659
|
+
this.loadReact = true;
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
updateVue(ts) {
|
|
663
|
+
this.templateVue = ts;
|
|
664
|
+
if (this.flaskReactVue) {
|
|
665
|
+
this.flaskReactVue.updateCode(this.templateVue);
|
|
666
|
+
this.loadVue = true;
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
updateJs(js) {
|
|
670
|
+
this.templateJs = js;
|
|
671
|
+
if (this.flaskReactVue) {
|
|
672
|
+
this.flaskReactVue.updateCode(this.templateJs);
|
|
673
|
+
this.loadJs = true;
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
loadFromUrl(skipTemplate) {
|
|
677
|
+
if (!skipTemplate) {
|
|
678
|
+
this.updateTemplate('');
|
|
679
|
+
}
|
|
680
|
+
this.updateTs('');
|
|
681
|
+
this.savedScrollPos = { top: 0, left: 0 };
|
|
682
|
+
this.inProgressCounter = 0;
|
|
683
|
+
this.inProgress = false;
|
|
684
|
+
this.tsLoaded = false;
|
|
685
|
+
if (this.activeTab === 'typescript') {
|
|
686
|
+
this.loadTsFromUrl();
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
loadTemplateFromUrl() {
|
|
690
|
+
if (!this.example) {
|
|
691
|
+
return;
|
|
692
|
+
}
|
|
693
|
+
this.handleInProgressEvent(true);
|
|
694
|
+
this.http
|
|
695
|
+
.get(this.baseUrl + this.example + '.html', { responseType: 'text' })
|
|
696
|
+
.pipe(timeout(3000), retry(1))
|
|
697
|
+
.subscribe({
|
|
698
|
+
next: data => {
|
|
699
|
+
this.updateTemplate(data);
|
|
700
|
+
setTimeout(() => this.handleInProgressEvent(false));
|
|
701
|
+
},
|
|
702
|
+
error: () => this.handleInProgressEvent(false)
|
|
703
|
+
});
|
|
704
|
+
}
|
|
705
|
+
loadTsFromUrl() {
|
|
706
|
+
if (!this.example) {
|
|
707
|
+
return;
|
|
708
|
+
}
|
|
709
|
+
this.handleInProgressEvent(true);
|
|
710
|
+
this.http
|
|
711
|
+
.get(this.baseUrl + this.example + '.ts', { responseType: 'text' })
|
|
712
|
+
.pipe(timeout(3000), retry(1))
|
|
713
|
+
.subscribe({
|
|
714
|
+
next: data => {
|
|
715
|
+
this.updateTs(data);
|
|
716
|
+
this.tsLoaded = true;
|
|
717
|
+
setTimeout(() => this.handleInProgressEvent(false));
|
|
718
|
+
},
|
|
719
|
+
error: () => {
|
|
720
|
+
this.tsLoaded = true;
|
|
721
|
+
this.handleInProgressEvent(false);
|
|
722
|
+
}
|
|
723
|
+
});
|
|
724
|
+
}
|
|
725
|
+
checkWebComponentsAvailable() {
|
|
726
|
+
if (this.webcomponentsList.includes(this.baseUrl + this.example + '-react')) {
|
|
727
|
+
this.frameworks.set('React', 'react');
|
|
728
|
+
}
|
|
729
|
+
else {
|
|
730
|
+
if (this.selectedFramework === 'react') {
|
|
731
|
+
this.selectedFramework = 'angular';
|
|
732
|
+
}
|
|
733
|
+
this.frameworks.delete('React');
|
|
734
|
+
}
|
|
735
|
+
if (this.webcomponentsList.includes(this.baseUrl + this.example + '-vue')) {
|
|
736
|
+
this.frameworks.set('Vue', 'vue');
|
|
737
|
+
}
|
|
738
|
+
else {
|
|
739
|
+
if (this.selectedFramework === 'vue') {
|
|
740
|
+
this.selectedFramework = 'angular';
|
|
741
|
+
}
|
|
742
|
+
this.frameworks.delete('Vue');
|
|
743
|
+
}
|
|
744
|
+
if (this.webcomponentsList.includes(this.baseUrl + this.example + '-js')) {
|
|
745
|
+
this.frameworks.set('Js', 'js');
|
|
746
|
+
}
|
|
747
|
+
else {
|
|
748
|
+
if (this.selectedFramework === 'js') {
|
|
749
|
+
this.selectedFramework = 'angular';
|
|
750
|
+
}
|
|
751
|
+
this.frameworks.delete('Js');
|
|
752
|
+
}
|
|
753
|
+
this.changeFramework(this.selectedFramework);
|
|
754
|
+
}
|
|
755
|
+
changeFramework(framework) {
|
|
756
|
+
this.activeTab = framework;
|
|
757
|
+
localStorage.setItem('si-live-preview-framework', framework);
|
|
758
|
+
this.loadReact = false;
|
|
759
|
+
this.loadVue = false;
|
|
760
|
+
this.loadJs = false;
|
|
761
|
+
let fileType = 'vue';
|
|
762
|
+
if (framework === 'angular') {
|
|
763
|
+
this.activeTab = 'template';
|
|
764
|
+
return;
|
|
765
|
+
}
|
|
766
|
+
else if (framework === 'react') {
|
|
767
|
+
fileType = 'tsx';
|
|
768
|
+
if (this.reactLoaded) {
|
|
769
|
+
this.updateReact(this.templateReact);
|
|
770
|
+
return;
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
else if (framework === 'vue' && this.vueLoaded) {
|
|
774
|
+
this.updateVue(this.templateVue);
|
|
775
|
+
return;
|
|
776
|
+
}
|
|
777
|
+
else if (framework === 'js') {
|
|
778
|
+
fileType = 'html';
|
|
779
|
+
if (this.jsLoaded) {
|
|
780
|
+
this.updateJs(this.templateJs);
|
|
781
|
+
return;
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
this.handleInProgressEvent(true);
|
|
785
|
+
this.http
|
|
786
|
+
.get(`${this.baseUrl}${this.example}-${framework}.${fileType}`, { responseType: 'text' })
|
|
787
|
+
.subscribe({
|
|
788
|
+
next: (res) => {
|
|
789
|
+
if (framework === 'react') {
|
|
790
|
+
this.updateReact(res);
|
|
791
|
+
this.reactLoaded = true;
|
|
792
|
+
}
|
|
793
|
+
else if (framework === 'vue') {
|
|
794
|
+
this.updateVue(res);
|
|
795
|
+
this.vueLoaded = true;
|
|
796
|
+
}
|
|
797
|
+
else if (framework === 'js') {
|
|
798
|
+
this.updateJs(res);
|
|
799
|
+
this.jsLoaded = true;
|
|
800
|
+
}
|
|
801
|
+
setTimeout(() => this.handleInProgressEvent(false));
|
|
802
|
+
},
|
|
803
|
+
error: (err) => {
|
|
804
|
+
if (framework === 'react') {
|
|
805
|
+
this.updateReact('');
|
|
806
|
+
this.reactLoaded = true;
|
|
807
|
+
}
|
|
808
|
+
else if (framework === 'vue') {
|
|
809
|
+
this.updateVue('');
|
|
810
|
+
this.vueLoaded = true;
|
|
811
|
+
}
|
|
812
|
+
else if (framework === 'js') {
|
|
813
|
+
this.updateJs('');
|
|
814
|
+
this.jsLoaded = true;
|
|
815
|
+
}
|
|
816
|
+
this.handleInProgressEvent(false);
|
|
817
|
+
}
|
|
818
|
+
});
|
|
819
|
+
}
|
|
820
|
+
templateFromComponent(template) {
|
|
821
|
+
if (this.template) {
|
|
822
|
+
return;
|
|
823
|
+
}
|
|
824
|
+
if (template === undefined) {
|
|
825
|
+
// there's no component loaded in the renderer, load template from url
|
|
826
|
+
this.loadTemplateFromUrl();
|
|
827
|
+
}
|
|
828
|
+
else {
|
|
829
|
+
// using template from component
|
|
830
|
+
this.updateTemplate(template);
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
handleInProgressEvent(inProgress) {
|
|
834
|
+
if (inProgress) {
|
|
835
|
+
this.inProgressCounter++;
|
|
836
|
+
}
|
|
837
|
+
else {
|
|
838
|
+
this.inProgressCounter--;
|
|
839
|
+
}
|
|
840
|
+
this.inProgress = !!this.inProgressCounter;
|
|
841
|
+
}
|
|
842
|
+
logClear(delayed = false) {
|
|
843
|
+
if (delayed && this.logMessages.length) {
|
|
844
|
+
this.delayClearTimer = setTimeout(() => {
|
|
845
|
+
this.delayClearTimer = undefined;
|
|
846
|
+
this.doLogClear();
|
|
847
|
+
}, 100);
|
|
848
|
+
return;
|
|
849
|
+
}
|
|
850
|
+
this.doLogClear();
|
|
851
|
+
}
|
|
852
|
+
doLogClear() {
|
|
853
|
+
if (this.logMessages.length) {
|
|
854
|
+
this.logMessages = [];
|
|
855
|
+
setTimeout(() => {
|
|
856
|
+
this.consoleElem().nativeElement.scrollTop = 0;
|
|
857
|
+
});
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
logEvent(msg) {
|
|
861
|
+
if (this.delayClearTimer) {
|
|
862
|
+
this.logMessages = [];
|
|
863
|
+
clearTimeout(this.delayClearTimer);
|
|
864
|
+
this.delayClearTimer = undefined;
|
|
865
|
+
}
|
|
866
|
+
this.logMessages.push(msg);
|
|
867
|
+
this.newMsgs = true;
|
|
868
|
+
setTimeout(() => {
|
|
869
|
+
this.consoleElem().nativeElement.scrollTop = this.consoleElem().nativeElement.scrollHeight;
|
|
870
|
+
});
|
|
871
|
+
}
|
|
872
|
+
showCopiedLabel() {
|
|
873
|
+
this.showCopied = true;
|
|
874
|
+
setTimeout(() => (this.showCopied = false), 1500);
|
|
875
|
+
}
|
|
876
|
+
toggleFullscreen(exampleOnly = false) {
|
|
877
|
+
const fullscreenElement = document.fullscreenElement ?? document.webkitFullscreenElement;
|
|
878
|
+
if (fullscreenElement) {
|
|
879
|
+
const exitFunction = document.exitFullscreen ?? document.webkitExitFullscreen;
|
|
880
|
+
if (exitFunction) {
|
|
881
|
+
exitFunction.call(document);
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
else {
|
|
885
|
+
const elem = exampleOnly
|
|
886
|
+
? this.self.nativeElement.querySelector(':scope > .example')
|
|
887
|
+
: this.self.nativeElement;
|
|
888
|
+
this.exampleFullscreen = exampleOnly;
|
|
889
|
+
const requestFunction = elem.requestFullscreen ?? elem.webkitRequestFullScreen;
|
|
890
|
+
if (requestFunction) {
|
|
891
|
+
requestFunction.call(elem);
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
toggleCollapse() {
|
|
896
|
+
this.editorCollapsed = !this.editorCollapsed;
|
|
897
|
+
localStorage.setItem('si-live-preview-editor-collapsed', this.editorCollapsed.toString());
|
|
898
|
+
if (this.editorCollapsed) {
|
|
899
|
+
this.showEditor = false;
|
|
900
|
+
setTimeout(() => window.dispatchEvent(new Event('resize')), 500);
|
|
901
|
+
}
|
|
902
|
+
else {
|
|
903
|
+
setTimeout(() => {
|
|
904
|
+
this.showEditor = true;
|
|
905
|
+
this.newMsgs = false;
|
|
906
|
+
window.dispatchEvent(new Event('resize'));
|
|
907
|
+
}, 500);
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
toggleRTL() {
|
|
911
|
+
this.isRTL = !this.isRTL;
|
|
912
|
+
}
|
|
913
|
+
toggleTheme() {
|
|
914
|
+
this.themeChange(this.theme === 'dark' ? 'light' : 'dark');
|
|
915
|
+
}
|
|
916
|
+
localeSelectionChanged(target) {
|
|
917
|
+
const locale = target?.value;
|
|
918
|
+
this.changeLocale(locale);
|
|
919
|
+
}
|
|
920
|
+
changeLocale(locale) {
|
|
921
|
+
this.locale = locale;
|
|
922
|
+
}
|
|
923
|
+
copyTemplate() {
|
|
924
|
+
this.clipboardCopy(this.template);
|
|
925
|
+
}
|
|
926
|
+
copyCode() {
|
|
927
|
+
if (this.activeTab === 'react') {
|
|
928
|
+
this.clipboardCopy(this.templateReact);
|
|
929
|
+
}
|
|
930
|
+
else if (this.activeTab === 'vue') {
|
|
931
|
+
this.clipboardCopy(this.templateVue);
|
|
932
|
+
}
|
|
933
|
+
else if (this.activeTab === 'js') {
|
|
934
|
+
this.clipboardCopy(this.templateJs);
|
|
935
|
+
}
|
|
936
|
+
else {
|
|
937
|
+
this.clipboardCopy(this.templateTs);
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
clipboardCopy(text) {
|
|
941
|
+
navigator.clipboard.writeText(text);
|
|
942
|
+
this.showCopiedLabel();
|
|
943
|
+
}
|
|
944
|
+
createLink() {
|
|
945
|
+
const url = this.createTemplateLink('editor');
|
|
946
|
+
this.clipboardCopy(url);
|
|
947
|
+
}
|
|
948
|
+
openTab() {
|
|
949
|
+
const url = this.createTemplateLink('viewer');
|
|
950
|
+
window.open(url, '_blank');
|
|
951
|
+
}
|
|
952
|
+
createTemplateLink(mode) {
|
|
953
|
+
let url = `${window.location.protocol}//${window.location.host}`;
|
|
954
|
+
url += window.location.pathname;
|
|
955
|
+
url += `#/viewer/${mode}?`;
|
|
956
|
+
url += 'theme=' + this.theme;
|
|
957
|
+
if (this.isRTL) {
|
|
958
|
+
url += '&isRTL=true';
|
|
959
|
+
}
|
|
960
|
+
if (this.locale) {
|
|
961
|
+
url += '&locale=' + this.locale;
|
|
962
|
+
}
|
|
963
|
+
if (this.activeTab === 'react') {
|
|
964
|
+
url += '&t=' + encodeURIComponent(this.templateReact) + '&framework=react';
|
|
965
|
+
}
|
|
966
|
+
else if (this.activeTab === 'vue') {
|
|
967
|
+
url += '&t=' + encodeURIComponent(this.templateVue) + '&framework=vue';
|
|
968
|
+
}
|
|
969
|
+
else if (this.activeTab === 'js') {
|
|
970
|
+
url += '&t=' + encodeURIComponent(this.templateJs) + '&framework=js';
|
|
971
|
+
}
|
|
972
|
+
else if (this.templateModified) {
|
|
973
|
+
url += '&t=' + encodeURIComponent(this.template);
|
|
974
|
+
}
|
|
975
|
+
if (this.example) {
|
|
976
|
+
url += '&e=' + encodeURIComponent(this.example);
|
|
977
|
+
}
|
|
978
|
+
return url;
|
|
979
|
+
}
|
|
980
|
+
createTicketLinks() {
|
|
981
|
+
this.ticketLinkBug = `${this.ticketBaseUrl}?issue%5Btitle%5D=%3C${this.example}%3E:&issuable_template=Bug`;
|
|
982
|
+
this.ticketLinkFeature = `${this.ticketBaseUrl}?issue%5Btitle%5D=%3C${this.example}%3E:&issuable_template=Feature Request`;
|
|
983
|
+
}
|
|
984
|
+
onFullscreenChange() {
|
|
985
|
+
this.isFullscreen = !!document.fullscreenElement || !!document.webkitFullscreenElement;
|
|
986
|
+
if (!this.isFullscreen) {
|
|
987
|
+
this.exampleFullscreen = false;
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: SiLivePreviewComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
991
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.6", type: SiLivePreviewComponent, isStandalone: false, selector: "si-live-preview", inputs: { baseUrl: "baseUrl", example: "example", template: "template", theme: "theme", locale: "locale", isRTL: "isRTL", ticketBaseUrl: "ticketBaseUrl", templateReact: "templateReact", templateVue: "templateVue", templateJs: "templateJs" }, host: { listeners: { "document:fullscreenchange": "onFullscreenChange()", "document:webkitfullscreenchange": "onFullscreenChange()" }, properties: { "class.editor-fullscreen": "this.isFullscreen", "class.is-mobile": "this.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 }], usesOnChanges: true, ngImport: i0, template: "<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 [template]=\"template\"\n [baseUrl]=\"baseUrl\"\n [exampleUrl]=\"example ?? ''\"\n [ticketLinkBug]=\"ticketLinkBug\"\n [ticketLinkFeature]=\"ticketLinkFeature\"\n [isFullscreen]=\"isFullscreen\"\n [theme]=\"theme\"\n [locale]=\"locale\"\n [isRTL]=\"isRTL\"\n [loadReact]=\"loadReact\"\n [loadVue]=\"loadVue\"\n [loadJs]=\"loadJs\"\n [reactVueTemplate]=\"\n activeTab === 'react' ? templateReact : activeTab === 'vue' ? templateVue : templateJs\n \"\n (templateFromComponent)=\"templateFromComponent($event)\"\n (logClear)=\"logClear(true)\"\n (logMessage)=\"logEvent($event)\"\n (logRenderingError)=\"renderingError = $event\"\n (inProgress)=\"handleInProgressEvent($event)\"\n (themeChange)=\"themeChange($event)\"\n (localeChange)=\"changeLocale($event)\"\n />\n @if (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 && (activeTab === 'template' || activeTab === 'typescript')) {\n <button\n type=\"button\"\n role=\"tab\"\n class=\"tab-item tab-link focus-inside\"\n id=\"templateEditorTab\"\n [class.tab-active]=\"activeTab === '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]=\"activeTab === '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)]=\"selectedFramework\"\n (ngModelChange)=\"changeFramework($event)\"\n >\n @for (aFramework of frameworks | keyvalue; track $index) {\n <option [value]=\"aFramework.value\" [selected]=\"selectedFramework === aFramework.value\">\n {{ aFramework.key }}\n </option>\n }\n </select>\n }\n @if (!!localeApi && showEditor) {\n <select\n aria-label=\"select 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]=\"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]=\"isRTL ? 'Right-to-left layout' : 'Left-to-right layout'\"\n [attr.aria-label]=\"isRTL ? 'Right-to-left layout' : 'Left-to-right layout'\"\n (click)=\"toggleRTL()\"\n >\n {{ isRTL ? 'RTL' : 'LTR' }}\n </button>\n }\n @if (!isMobile && !showEditor && (renderingError || (logMessages.length && newMsgs))) {\n <button\n type=\"button\"\n class=\"btn-command\"\n title=\"Show console\"\n aria-label=\"Show console\"\n [class.alert]=\"renderingError\"\n [class.info]=\"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 (theme === 'light') {\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 @if (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 }\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 </div>\n }\n <div class=\"tab-content\" [class.is-mobile]=\"isMobile\">\n <fieldset\n class=\"tab-pane\"\n [class.tab-active]=\"activeTab === '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]=\"activeTab === '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]=\"activeTab === 'react' || activeTab === 'vue' || activeTab === '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]=\"!renderingError && !logMessages.length\">\n <div class=\"buttons\">\n @if (logMessages.length) {\n <button\n type=\"button\"\n class=\"btn-command btn-clear\"\n title=\"Clear log\"\n aria-label=\"Clear log\"\n (click)=\"logClear()\"\n >\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\">\n <path\n d=\"M400,144H328V132a44.05,44.05,0,0,0-44-44H228a44.05,44.05,0,0,0-44,44v12H112a12,12,0,0,0,0,24h20V380a44.05,44.05,0,0,0,44,44H336a44.05,44.05,0,0,0,44-44V168h20a12,12,0,0,0,0-24ZM208,132a20,20,0,0,1,20-20h56a20,20,0,0,1,20,20v12H208ZM356,380a20,20,0,0,1-20,20H176a20,20,0,0,1-20-20V168H356Z\"\n />\n <path d=\"M224,344a12,12,0,0,0,12-12V236a12,12,0,0,0-24,0v96A12,12,0,0,0,224,344Z\" />\n <path d=\"M288,344a12,12,0,0,0,12-12V236a12,12,0,0,0-24,0v96A12,12,0,0,0,288,344Z\" />\n </svg>\n </button>\n }\n </div>\n <div #consoleContainer class=\"scroller\">\n @if (renderingError) {\n <pre class=\"alert-danger\"><code>{{ renderingError.toString() }}</code></pre>\n }\n @if (!renderingError && logMessages.length) {\n <ul>\n @for (msg of 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.tab-active.tab-link{color:var(--element-action-secondary-text);border-block-end-color:var(--element-action-secondary-text)!important}.lp-tabs .tab-item.tab-active.tab-link:hover{color:var(--element-action-secondary-text-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(--element-text-primary);border:0;border-block-end:4px solid transparent}.lp-tabs .tab-item.tab-link:hover{text-decoration:none;color:var(--element-action-secondary-text-hover);border-block-end-color:var(--element-ui-4)}: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(--element-base-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(--element-text-primary)}.collapse-button button:hover,.collapse-button button:focus,.collapse-button button:active{color:var(--element-action-secondary-text-hover)}.collapse-button button:hover>svg,.collapse-button button:focus>svg,.collapse-button button:active>svg{fill:currentColor}.code{position:relative;background-color:var(--element-base-0);max-block-size:414px;transition:max-block-size .5s}.code.is-collapsed{max-block-size:41px;overflow:hidden;background-color:var(--element-base-0);border-block-start:1px solid var(--element-ui-4)}.code.is-collapsed .collapse-icon{transform:rotate(180deg)}.code .console{block-size:68px;position:relative;border-block-start:1px solid var(--element-ui-4);color:var(--element-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(--element-action-danger-text);background-color:var(--element-action-danger)}.code .console ul{list-style:none;margin:0;padding:5px;font-family:Menlo,Ubuntu Mono,Liberation Mono,Consolas,Courier,monospace}.code .console .btn-clear:hover{color:var(--element-action-danger-text)}.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(--element-ui-4)}pre{border-radius:0}.tab-content{display:flex;flex-direction:column}.tab-content.is-mobile{border-inline-end:1px solid var(--element-ui-4);flex:1}.tab-content:not(.is-mobile){block-size:305px}.tab-pane{flex:1;display:none;position:relative}.tab-pane.tab-active{display:flex;flex-direction:column}fieldset{padding:0;margin:0;border:0}.buttons{position:absolute;z-index:100;inset-inline-end:16px;display:flex;align-items:center;inset-block-start:0;block-size:40px}.is-mobile .buttons{inset-inline-end:0}.btn-command{background-color:transparent;border:0;color:var(--element-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(--element-action-secondary-text-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(--element-action-danger);color:var(--element-action-danger-text)}.btn-command.info svg{background-color:var(--element-action-secondary);color:var(--element-action-secondary-text)}.rtl-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(--element-base-0);background:var(--element-text-primary);margin-inline-end:10px;margin-block-start:12px}.show-copied .copied{display:block!important}.readonly-label{color:var(--element-text-primary);border:1px solid var(--element-text-primary)}.show-copied>*{display:none}.codeflask-editor{flex:1;position:relative;border-block-start:1px solid var(--element-ui-4)}.codeflask-editor ::ng-deep textarea{box-shadow:none}.progress-container{position:absolute;inset:0;pointer-events:none}.progress-container,.progress-container .progress-inner{display:flex;justify-content:center;align-items:center}.progress-container .progress-inner{inline-size:64px;block-size:40px;background:#fffc;border:1px solid #ddd;border-radius:12px}.progress-dots:before,.progress-dots:after,.progress-dots{inline-size:10px;block-size:10px;border-radius:50%;background-color:#ddd;animation:dot-flashing .6s infinite linear alternate}.progress-dots{position:relative;animation-delay:.3s}.progress-dots:before,.progress-dots:after{content:\"\";display:inline-block;position:absolute;inset-block-start:0}.progress-dots:before{inset-inline-start:-15px;animation-delay:0s}.progress-dots:after{inset-inline-start:15px;animation-delay:.6s}@keyframes dot-flashing{0%{background-color:#333}50%,to{background-color:#ddd}}\n", ":host ::ng-deep .readonly .codeflask{background-color:#f9f9f9}:host ::ng-deep .codeflask{background-color:#fff}:host ::ng-deep .codeflask pre,:host ::ng-deep .codeflask code{color:#000;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 .codeflask__flatten,:host ::ng-deep .codeflask .codeflask__code{font-family:Menlo,Ubuntu Mono,Liberation Mono,Consolas,Courier,monospace}: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:#000}:host ::ng-deep .codeflask.codeflask--has-line-numbers:before{background:#eee}:host ::ng-deep .codeflask__lines{color:#999}: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:#a0a1a7;font-style:italic}:host ::ng-deep .token.punctuation{color:#000}:host ::ng-deep .token.constant,:host ::ng-deep .token.symbol,:host ::ng-deep .token.keyword{color:#a626a4}:host ::ng-deep .token.builtin{color:#0184bc}:host ::ng-deep .token.property{color:#986801}:host ::ng-deep .token.tag{color:#e45649}:host ::ng-deep .token.boolean{color:#986801}:host ::ng-deep .token.number{color:#986801}:host ::ng-deep .token.attr-name{color:#986801}:host ::ng-deep .token.attr-value{color:#50a14f}:host ::ng-deep .token.string,:host ::ng-deep .token.char{color:#50a14f}:host ::ng-deep .token.function{color:#4078f2}:host ::ng-deep .token.class-name{color:#c18401}:host ::ng-deep .token.regex,:host ::ng-deep .token.important,:host ::ng-deep .token.variable{color:#e90}:host ::ng-deep .token.important,:host ::ng-deep .token.bold{font-weight:700}:host ::ng-deep .token.italic{font-style:italic}:host ::ng-deep .token.entity{cursor:help}:host ::ng-deep .token.inserted{color:#690}:host ::ng-deep .token.deleted{color:#905}@media (prefers-color-scheme: dark){:host ::ng-deep code[class*=language-],:host ::ng-deep pre[class*=language-]{color:#bcbcbc}:host ::ng-deep .token.punctuation{color:#bcbcbc}:host ::ng-deep .codeflask{background-color:#222}:host ::ng-deep .codeflask.codeflask--has-line-numbers:before{background:#666}:host ::ng-deep .codeflask pre,:host ::ng-deep .codeflask code{color:#bcbcbc}:host ::ng-deep .codeflask .codeflask__textarea{caret-color:#fff}:host ::ng-deep .readonly .codeflask{background-color:#333}:host ::ng-deep .codeflask__lines{color:#eee}}:host-context(.app--dark) :host ::ng-deep code[class*=language-],:host-context(.app--dark) :host ::ng-deep pre[class*=language-]{color:#bcbcbc}:host-context(.app--dark) :host ::ng-deep .token.punctuation{color:#bcbcbc}:host-context(.app--dark) :host ::ng-deep .codeflask{background-color:#222}:host-context(.app--dark) :host ::ng-deep .codeflask.codeflask--has-line-numbers:before{background:#666}:host-context(.app--dark) :host ::ng-deep .codeflask pre,:host-context(.app--dark) :host ::ng-deep .codeflask code{color:#bcbcbc}:host-context(.app--dark) :host ::ng-deep .codeflask .codeflask__textarea{caret-color:#fff}:host-context(.app--dark) :host ::ng-deep .readonly .codeflask{background-color:#333}:host-context(.app--dark) :host ::ng-deep .codeflask__lines{color:#eee}@media (min-width: 0){:host-context(.app--light) :host ::ng-deep code[class*=language-],:host-context(.app--light) :host ::ng-deep pre[class*=language-]{color:#000}:host-context(.app--light) :host ::ng-deep .token.punctuation{color:#000}:host-context(.app--light) :host ::ng-deep .codeflask{background-color:#fff}:host-context(.app--light) :host ::ng-deep .codeflask.codeflask--has-line-numbers:before{background:#eee}:host-context(.app--light) :host ::ng-deep .codeflask pre,:host-context(.app--light) :host ::ng-deep .codeflask code{color:#000}:host-context(.app--light) :host ::ng-deep .codeflask .codeflask__textarea{caret-color:#000}:host-context(.app--light) :host ::ng-deep .readonly .codeflask{background-color:#f9f9f9}:host-context(.app--light) :host ::ng-deep .codeflask__lines{color:#999}}\n"], dependencies: [{ kind: "directive", type: i1$1.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i1$1.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i1$1.SelectControlValueAccessor, selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", inputs: ["compareWith"] }, { kind: "directive", type: i1$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1$1.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: ["baseUrl", "exampleUrl", "template", "ticketLinkBug", "ticketLinkFeature", "isFullscreen", "iFrameHeight", "iFrameWidth", "theme", "locale", "isRTL", "loadReact", "loadVue", "loadJs", "reactVueTemplate"], outputs: ["templateFromComponent", "logClear", "logMessage", "logRenderingError", "inProgress", "themeChange", "localeChange"] }, { kind: "pipe", type: i3.KeyValuePipe, name: "keyvalue" }] });
|
|
992
|
+
}
|
|
993
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: SiLivePreviewComponent, decorators: [{
|
|
994
|
+
type: Component,
|
|
995
|
+
args: [{ selector: 'si-live-preview', standalone: false, template: "<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 [template]=\"template\"\n [baseUrl]=\"baseUrl\"\n [exampleUrl]=\"example ?? ''\"\n [ticketLinkBug]=\"ticketLinkBug\"\n [ticketLinkFeature]=\"ticketLinkFeature\"\n [isFullscreen]=\"isFullscreen\"\n [theme]=\"theme\"\n [locale]=\"locale\"\n [isRTL]=\"isRTL\"\n [loadReact]=\"loadReact\"\n [loadVue]=\"loadVue\"\n [loadJs]=\"loadJs\"\n [reactVueTemplate]=\"\n activeTab === 'react' ? templateReact : activeTab === 'vue' ? templateVue : templateJs\n \"\n (templateFromComponent)=\"templateFromComponent($event)\"\n (logClear)=\"logClear(true)\"\n (logMessage)=\"logEvent($event)\"\n (logRenderingError)=\"renderingError = $event\"\n (inProgress)=\"handleInProgressEvent($event)\"\n (themeChange)=\"themeChange($event)\"\n (localeChange)=\"changeLocale($event)\"\n />\n @if (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 && (activeTab === 'template' || activeTab === 'typescript')) {\n <button\n type=\"button\"\n role=\"tab\"\n class=\"tab-item tab-link focus-inside\"\n id=\"templateEditorTab\"\n [class.tab-active]=\"activeTab === '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]=\"activeTab === '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)]=\"selectedFramework\"\n (ngModelChange)=\"changeFramework($event)\"\n >\n @for (aFramework of frameworks | keyvalue; track $index) {\n <option [value]=\"aFramework.value\" [selected]=\"selectedFramework === aFramework.value\">\n {{ aFramework.key }}\n </option>\n }\n </select>\n }\n @if (!!localeApi && showEditor) {\n <select\n aria-label=\"select 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]=\"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]=\"isRTL ? 'Right-to-left layout' : 'Left-to-right layout'\"\n [attr.aria-label]=\"isRTL ? 'Right-to-left layout' : 'Left-to-right layout'\"\n (click)=\"toggleRTL()\"\n >\n {{ isRTL ? 'RTL' : 'LTR' }}\n </button>\n }\n @if (!isMobile && !showEditor && (renderingError || (logMessages.length && newMsgs))) {\n <button\n type=\"button\"\n class=\"btn-command\"\n title=\"Show console\"\n aria-label=\"Show console\"\n [class.alert]=\"renderingError\"\n [class.info]=\"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 (theme === 'light') {\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 @if (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 }\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 </div>\n }\n <div class=\"tab-content\" [class.is-mobile]=\"isMobile\">\n <fieldset\n class=\"tab-pane\"\n [class.tab-active]=\"activeTab === '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]=\"activeTab === '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]=\"activeTab === 'react' || activeTab === 'vue' || activeTab === '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]=\"!renderingError && !logMessages.length\">\n <div class=\"buttons\">\n @if (logMessages.length) {\n <button\n type=\"button\"\n class=\"btn-command btn-clear\"\n title=\"Clear log\"\n aria-label=\"Clear log\"\n (click)=\"logClear()\"\n >\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\">\n <path\n d=\"M400,144H328V132a44.05,44.05,0,0,0-44-44H228a44.05,44.05,0,0,0-44,44v12H112a12,12,0,0,0,0,24h20V380a44.05,44.05,0,0,0,44,44H336a44.05,44.05,0,0,0,44-44V168h20a12,12,0,0,0,0-24ZM208,132a20,20,0,0,1,20-20h56a20,20,0,0,1,20,20v12H208ZM356,380a20,20,0,0,1-20,20H176a20,20,0,0,1-20-20V168H356Z\"\n />\n <path d=\"M224,344a12,12,0,0,0,12-12V236a12,12,0,0,0-24,0v96A12,12,0,0,0,224,344Z\" />\n <path d=\"M288,344a12,12,0,0,0,12-12V236a12,12,0,0,0-24,0v96A12,12,0,0,0,288,344Z\" />\n </svg>\n </button>\n }\n </div>\n <div #consoleContainer class=\"scroller\">\n @if (renderingError) {\n <pre class=\"alert-danger\"><code>{{ renderingError.toString() }}</code></pre>\n }\n @if (!renderingError && logMessages.length) {\n <ul>\n @for (msg of 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.tab-active.tab-link{color:var(--element-action-secondary-text);border-block-end-color:var(--element-action-secondary-text)!important}.lp-tabs .tab-item.tab-active.tab-link:hover{color:var(--element-action-secondary-text-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(--element-text-primary);border:0;border-block-end:4px solid transparent}.lp-tabs .tab-item.tab-link:hover{text-decoration:none;color:var(--element-action-secondary-text-hover);border-block-end-color:var(--element-ui-4)}: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(--element-base-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(--element-text-primary)}.collapse-button button:hover,.collapse-button button:focus,.collapse-button button:active{color:var(--element-action-secondary-text-hover)}.collapse-button button:hover>svg,.collapse-button button:focus>svg,.collapse-button button:active>svg{fill:currentColor}.code{position:relative;background-color:var(--element-base-0);max-block-size:414px;transition:max-block-size .5s}.code.is-collapsed{max-block-size:41px;overflow:hidden;background-color:var(--element-base-0);border-block-start:1px solid var(--element-ui-4)}.code.is-collapsed .collapse-icon{transform:rotate(180deg)}.code .console{block-size:68px;position:relative;border-block-start:1px solid var(--element-ui-4);color:var(--element-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(--element-action-danger-text);background-color:var(--element-action-danger)}.code .console ul{list-style:none;margin:0;padding:5px;font-family:Menlo,Ubuntu Mono,Liberation Mono,Consolas,Courier,monospace}.code .console .btn-clear:hover{color:var(--element-action-danger-text)}.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(--element-ui-4)}pre{border-radius:0}.tab-content{display:flex;flex-direction:column}.tab-content.is-mobile{border-inline-end:1px solid var(--element-ui-4);flex:1}.tab-content:not(.is-mobile){block-size:305px}.tab-pane{flex:1;display:none;position:relative}.tab-pane.tab-active{display:flex;flex-direction:column}fieldset{padding:0;margin:0;border:0}.buttons{position:absolute;z-index:100;inset-inline-end:16px;display:flex;align-items:center;inset-block-start:0;block-size:40px}.is-mobile .buttons{inset-inline-end:0}.btn-command{background-color:transparent;border:0;color:var(--element-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(--element-action-secondary-text-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(--element-action-danger);color:var(--element-action-danger-text)}.btn-command.info svg{background-color:var(--element-action-secondary);color:var(--element-action-secondary-text)}.rtl-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(--element-base-0);background:var(--element-text-primary);margin-inline-end:10px;margin-block-start:12px}.show-copied .copied{display:block!important}.readonly-label{color:var(--element-text-primary);border:1px solid var(--element-text-primary)}.show-copied>*{display:none}.codeflask-editor{flex:1;position:relative;border-block-start:1px solid var(--element-ui-4)}.codeflask-editor ::ng-deep textarea{box-shadow:none}.progress-container{position:absolute;inset:0;pointer-events:none}.progress-container,.progress-container .progress-inner{display:flex;justify-content:center;align-items:center}.progress-container .progress-inner{inline-size:64px;block-size:40px;background:#fffc;border:1px solid #ddd;border-radius:12px}.progress-dots:before,.progress-dots:after,.progress-dots{inline-size:10px;block-size:10px;border-radius:50%;background-color:#ddd;animation:dot-flashing .6s infinite linear alternate}.progress-dots{position:relative;animation-delay:.3s}.progress-dots:before,.progress-dots:after{content:\"\";display:inline-block;position:absolute;inset-block-start:0}.progress-dots:before{inset-inline-start:-15px;animation-delay:0s}.progress-dots:after{inset-inline-start:15px;animation-delay:.6s}@keyframes dot-flashing{0%{background-color:#333}50%,to{background-color:#ddd}}\n", ":host ::ng-deep .readonly .codeflask{background-color:#f9f9f9}:host ::ng-deep .codeflask{background-color:#fff}:host ::ng-deep .codeflask pre,:host ::ng-deep .codeflask code{color:#000;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 .codeflask__flatten,:host ::ng-deep .codeflask .codeflask__code{font-family:Menlo,Ubuntu Mono,Liberation Mono,Consolas,Courier,monospace}: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:#000}:host ::ng-deep .codeflask.codeflask--has-line-numbers:before{background:#eee}:host ::ng-deep .codeflask__lines{color:#999}: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:#a0a1a7;font-style:italic}:host ::ng-deep .token.punctuation{color:#000}:host ::ng-deep .token.constant,:host ::ng-deep .token.symbol,:host ::ng-deep .token.keyword{color:#a626a4}:host ::ng-deep .token.builtin{color:#0184bc}:host ::ng-deep .token.property{color:#986801}:host ::ng-deep .token.tag{color:#e45649}:host ::ng-deep .token.boolean{color:#986801}:host ::ng-deep .token.number{color:#986801}:host ::ng-deep .token.attr-name{color:#986801}:host ::ng-deep .token.attr-value{color:#50a14f}:host ::ng-deep .token.string,:host ::ng-deep .token.char{color:#50a14f}:host ::ng-deep .token.function{color:#4078f2}:host ::ng-deep .token.class-name{color:#c18401}:host ::ng-deep .token.regex,:host ::ng-deep .token.important,:host ::ng-deep .token.variable{color:#e90}:host ::ng-deep .token.important,:host ::ng-deep .token.bold{font-weight:700}:host ::ng-deep .token.italic{font-style:italic}:host ::ng-deep .token.entity{cursor:help}:host ::ng-deep .token.inserted{color:#690}:host ::ng-deep .token.deleted{color:#905}@media (prefers-color-scheme: dark){:host ::ng-deep code[class*=language-],:host ::ng-deep pre[class*=language-]{color:#bcbcbc}:host ::ng-deep .token.punctuation{color:#bcbcbc}:host ::ng-deep .codeflask{background-color:#222}:host ::ng-deep .codeflask.codeflask--has-line-numbers:before{background:#666}:host ::ng-deep .codeflask pre,:host ::ng-deep .codeflask code{color:#bcbcbc}:host ::ng-deep .codeflask .codeflask__textarea{caret-color:#fff}:host ::ng-deep .readonly .codeflask{background-color:#333}:host ::ng-deep .codeflask__lines{color:#eee}}:host-context(.app--dark) :host ::ng-deep code[class*=language-],:host-context(.app--dark) :host ::ng-deep pre[class*=language-]{color:#bcbcbc}:host-context(.app--dark) :host ::ng-deep .token.punctuation{color:#bcbcbc}:host-context(.app--dark) :host ::ng-deep .codeflask{background-color:#222}:host-context(.app--dark) :host ::ng-deep .codeflask.codeflask--has-line-numbers:before{background:#666}:host-context(.app--dark) :host ::ng-deep .codeflask pre,:host-context(.app--dark) :host ::ng-deep .codeflask code{color:#bcbcbc}:host-context(.app--dark) :host ::ng-deep .codeflask .codeflask__textarea{caret-color:#fff}:host-context(.app--dark) :host ::ng-deep .readonly .codeflask{background-color:#333}:host-context(.app--dark) :host ::ng-deep .codeflask__lines{color:#eee}@media (min-width: 0){:host-context(.app--light) :host ::ng-deep code[class*=language-],:host-context(.app--light) :host ::ng-deep pre[class*=language-]{color:#000}:host-context(.app--light) :host ::ng-deep .token.punctuation{color:#000}:host-context(.app--light) :host ::ng-deep .codeflask{background-color:#fff}:host-context(.app--light) :host ::ng-deep .codeflask.codeflask--has-line-numbers:before{background:#eee}:host-context(.app--light) :host ::ng-deep .codeflask pre,:host-context(.app--light) :host ::ng-deep .codeflask code{color:#000}:host-context(.app--light) :host ::ng-deep .codeflask .codeflask__textarea{caret-color:#000}:host-context(.app--light) :host ::ng-deep .readonly .codeflask{background-color:#f9f9f9}:host-context(.app--light) :host ::ng-deep .codeflask__lines{color:#999}}\n"] }]
|
|
996
|
+
}], ctorParameters: () => [], propDecorators: { baseUrl: [{
|
|
997
|
+
type: Input
|
|
998
|
+
}], example: [{
|
|
999
|
+
type: Input
|
|
1000
|
+
}], template: [{
|
|
1001
|
+
type: Input
|
|
1002
|
+
}], theme: [{
|
|
1003
|
+
type: Input
|
|
1004
|
+
}], locale: [{
|
|
1005
|
+
type: Input
|
|
1006
|
+
}], isRTL: [{
|
|
1007
|
+
type: Input
|
|
1008
|
+
}], ticketBaseUrl: [{
|
|
1009
|
+
type: Input
|
|
1010
|
+
}], templateReact: [{
|
|
1011
|
+
type: Input
|
|
1012
|
+
}], templateVue: [{
|
|
1013
|
+
type: Input
|
|
1014
|
+
}], templateJs: [{
|
|
1015
|
+
type: Input
|
|
1016
|
+
}], isFullscreen: [{
|
|
1017
|
+
type: HostBinding,
|
|
1018
|
+
args: ['class.editor-fullscreen']
|
|
1019
|
+
}], isMobile: [{
|
|
1020
|
+
type: HostBinding,
|
|
1021
|
+
args: ['class.is-mobile']
|
|
1022
|
+
}], onFullscreenChange: [{
|
|
1023
|
+
type: HostListener,
|
|
1024
|
+
args: ['document:fullscreenchange']
|
|
1025
|
+
}, {
|
|
1026
|
+
type: HostListener,
|
|
1027
|
+
args: ['document:webkitfullscreenchange']
|
|
1028
|
+
}] } });
|
|
1029
|
+
|
|
1030
|
+
/**
|
|
1031
|
+
* Copyright Siemens 2016 - 2025.
|
|
1032
|
+
* SPDX-License-Identifier: MIT
|
|
1033
|
+
*/
|
|
1034
|
+
class SiExampleOverviewComponent {
|
|
1035
|
+
route = inject(ActivatedRoute);
|
|
1036
|
+
router = inject(Router);
|
|
1037
|
+
title = inject(Title);
|
|
1038
|
+
config = inject(SI_LIVE_PREVIEW_CONFIG);
|
|
1039
|
+
internalConfig = inject(SI_LIVE_PREVIEW_INTERNALS);
|
|
1040
|
+
componentList = [];
|
|
1041
|
+
activeExampleRoute;
|
|
1042
|
+
tree = [];
|
|
1043
|
+
baseUrl = this.config.examplesBaseUrl;
|
|
1044
|
+
ticketBaseUrl = this.config.ticketBaseUrl;
|
|
1045
|
+
isCollapsed = localStorage.getItem('si-live-preview-examples-collapsed') === 'true';
|
|
1046
|
+
showContent = !this.isCollapsed;
|
|
1047
|
+
searchControl = new UntypedFormControl();
|
|
1048
|
+
ngOnInit() {
|
|
1049
|
+
this.title.setTitle(this.internalConfig.titleBase);
|
|
1050
|
+
this.componentList = this.config.componentLoader.list
|
|
1051
|
+
.sort()
|
|
1052
|
+
.map(component => component.replace(this.baseUrl, ''));
|
|
1053
|
+
this.makeTree();
|
|
1054
|
+
this.activeExampleRoute = this.route.url.pipe(filter(segments => !!segments.length), map(segments => segments.join('/')));
|
|
1055
|
+
// Handle the filter query parameter
|
|
1056
|
+
this.route.queryParams.subscribe(search => {
|
|
1057
|
+
this.makeTree(search.q);
|
|
1058
|
+
this.searchControl.setValue(search.q);
|
|
1059
|
+
});
|
|
1060
|
+
this.searchControl.valueChanges
|
|
1061
|
+
.pipe(debounceTime(400), distinctUntilChanged())
|
|
1062
|
+
.subscribe((search) => {
|
|
1063
|
+
// Do navigation in place to set query param
|
|
1064
|
+
this.router.navigate([], {
|
|
1065
|
+
relativeTo: this.route,
|
|
1066
|
+
queryParams: { q: search },
|
|
1067
|
+
queryParamsHandling: 'merge'
|
|
1068
|
+
});
|
|
1069
|
+
});
|
|
1070
|
+
}
|
|
1071
|
+
makeTree(filterValue) {
|
|
1072
|
+
this.tree = [];
|
|
1073
|
+
let prevParents = [];
|
|
1074
|
+
for (const item of this.componentList) {
|
|
1075
|
+
if (filterValue && !item.toLowerCase().includes(filterValue)) {
|
|
1076
|
+
continue;
|
|
1077
|
+
}
|
|
1078
|
+
const parts = item.split('/');
|
|
1079
|
+
const label = parts.pop();
|
|
1080
|
+
for (let i = 0; i < parts.length; i++) {
|
|
1081
|
+
if (prevParents.length < i || parts[i] !== prevParents[i]) {
|
|
1082
|
+
this.tree.push({ label: parts[i], level: i });
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
prevParents = parts;
|
|
1086
|
+
this.tree.push({ label, link: item, level: parts.length });
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
toggleCollapse() {
|
|
1090
|
+
this.isCollapsed = !this.isCollapsed;
|
|
1091
|
+
localStorage.setItem('si-live-preview-examples-collapsed', this.isCollapsed.toString());
|
|
1092
|
+
if (this.isCollapsed) {
|
|
1093
|
+
this.showContent = false;
|
|
1094
|
+
setTimeout(() => window.dispatchEvent(new Event('resize')), 500);
|
|
1095
|
+
}
|
|
1096
|
+
else {
|
|
1097
|
+
setTimeout(() => {
|
|
1098
|
+
this.showContent = true;
|
|
1099
|
+
window.dispatchEvent(new Event('resize'));
|
|
1100
|
+
}, 500);
|
|
1101
|
+
}
|
|
1102
|
+
}
|
|
1103
|
+
resetSearchBar() {
|
|
1104
|
+
this.searchControl.reset();
|
|
1105
|
+
}
|
|
1106
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: SiExampleOverviewComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1107
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.6", type: SiExampleOverviewComponent, isStandalone: false, 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 [ticketBaseUrl]=\"ticketBaseUrl\"\n [baseUrl]=\"baseUrl\"\n [example]=\"activeExampleRoute | async\"\n />\n</main>\n", styles: ["a{color:var(--element-action-secondary-text)}a:after{display:none}a:hover{color:var(--element-action-secondary-text-hover)}:host{display:flex;flex-direction:row;background-color:var(--element-base-0)}.component-list{border-inline-end:1px solid var(--element-ui-4);display:flex;flex:0 0 auto;inline-size:400px;flex-direction:column;transition:inline-size .5s;color:var(--element-text-primary)}.component-list.is-collapsed{inline-size:40px;overflow:hidden;background-color:var(--element-base-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(--element-base-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(--element-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(--element-action-secondary-text-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(--element-ui-4);font-size:14px;background:var(--element-base-0);color:var(--element-text-primary)}.component-list .search-bar .search-bar-icon{position:absolute;inset-block-start:8px;inset-inline-start:6px;fill:var(--element-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(--element-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(--element-ui-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:700}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: "directive", type: i1$1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1$1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "directive", type: i1.RouterLink, selector: "[routerLink]", inputs: ["target", "queryParams", "fragment", "queryParamsHandling", "state", "info", "relativeTo", "preserveFragment", "skipLocationChange", "replaceUrl", "routerLink"] }, { kind: "directive", type: i1.RouterLinkActive, selector: "[routerLinkActive]", inputs: ["routerLinkActiveOptions", "ariaCurrentWhenActive", "routerLinkActive"], outputs: ["isActiveChange"], exportAs: ["routerLinkActive"] }, { kind: "component", type: SiLivePreviewComponent, selector: "si-live-preview", inputs: ["baseUrl", "example", "template", "theme", "locale", "isRTL", "ticketBaseUrl", "templateReact", "templateVue", "templateJs"] }, { kind: "pipe", type: i3.AsyncPipe, name: "async" }] });
|
|
1108
|
+
}
|
|
1109
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: SiExampleOverviewComponent, decorators: [{
|
|
1110
|
+
type: Component,
|
|
1111
|
+
args: [{ selector: 'si-example-overview', standalone: false, 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 [ticketBaseUrl]=\"ticketBaseUrl\"\n [baseUrl]=\"baseUrl\"\n [example]=\"activeExampleRoute | async\"\n />\n</main>\n", styles: ["a{color:var(--element-action-secondary-text)}a:after{display:none}a:hover{color:var(--element-action-secondary-text-hover)}:host{display:flex;flex-direction:row;background-color:var(--element-base-0)}.component-list{border-inline-end:1px solid var(--element-ui-4);display:flex;flex:0 0 auto;inline-size:400px;flex-direction:column;transition:inline-size .5s;color:var(--element-text-primary)}.component-list.is-collapsed{inline-size:40px;overflow:hidden;background-color:var(--element-base-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(--element-base-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(--element-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(--element-action-secondary-text-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(--element-ui-4);font-size:14px;background:var(--element-base-0);color:var(--element-text-primary)}.component-list .search-bar .search-bar-icon{position:absolute;inset-block-start:8px;inset-inline-start:6px;fill:var(--element-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(--element-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(--element-ui-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:700}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"] }]
|
|
1112
|
+
}] });
|
|
1113
|
+
|
|
1114
|
+
const setDeviceMode = (mode) => {
|
|
1115
|
+
const htmlTag = document.documentElement;
|
|
1116
|
+
htmlTag.setAttribute('mode', mode);
|
|
1117
|
+
htmlTag.classList.add(mode);
|
|
1118
|
+
htmlTag.classList.remove(mode === 'ios' ? 'md' : 'ios');
|
|
1119
|
+
};
|
|
1120
|
+
const setDirectionRtl = (rtl) => {
|
|
1121
|
+
document.documentElement.setAttribute('dir', rtl ? 'rtl' : 'ltr');
|
|
1122
|
+
};
|
|
1123
|
+
const provideExampleRoutes = (routes) => {
|
|
1124
|
+
return {
|
|
1125
|
+
provide: SI_LIVE_PREVIEW_EXAMPLE_ROUTES,
|
|
1126
|
+
useValue: routes
|
|
1127
|
+
};
|
|
1128
|
+
};
|
|
1129
|
+
|
|
1130
|
+
/**
|
|
1131
|
+
* Copyright Siemens 2016 - 2025.
|
|
1132
|
+
* SPDX-License-Identifier: MIT
|
|
1133
|
+
*/
|
|
1134
|
+
const LOG_EVENT = new InjectionToken('si.live-previewer.log-event');
|
|
1135
|
+
|
|
1136
|
+
/**
|
|
1137
|
+
* Copyright Siemens 2016 - 2025.
|
|
1138
|
+
* SPDX-License-Identifier: MIT
|
|
1139
|
+
*/
|
|
1140
|
+
class LandscapeSupportService {
|
|
1141
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: LandscapeSupportService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1142
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: LandscapeSupportService, providedIn: 'any' });
|
|
1143
|
+
}
|
|
1144
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: LandscapeSupportService, decorators: [{
|
|
1145
|
+
type: Injectable,
|
|
1146
|
+
args: [{
|
|
1147
|
+
providedIn: 'any'
|
|
1148
|
+
}]
|
|
1149
|
+
}] });
|
|
1150
|
+
|
|
1151
|
+
// for handling JSON.stringify with circular references, from MDN
|
|
1152
|
+
const getCircularReplacer = () => {
|
|
1153
|
+
const seen = new WeakSet();
|
|
1154
|
+
return (_key, value) => {
|
|
1155
|
+
if (typeof value === 'object' && value !== null) {
|
|
1156
|
+
if (seen.has(value)) {
|
|
1157
|
+
return;
|
|
1158
|
+
}
|
|
1159
|
+
seen.add(value);
|
|
1160
|
+
}
|
|
1161
|
+
return value;
|
|
1162
|
+
};
|
|
1163
|
+
};
|
|
1164
|
+
let DummyAppSampleComponent = class DummyAppSampleComponent {
|
|
1165
|
+
};
|
|
1166
|
+
DummyAppSampleComponent = __decorate([
|
|
1167
|
+
Component({
|
|
1168
|
+
// eslint-disable-next-line @angular-eslint/component-selector
|
|
1169
|
+
selector: 'app-sample',
|
|
1170
|
+
// eslint-disable-next-line @angular-eslint/prefer-standalone
|
|
1171
|
+
standalone: false,
|
|
1172
|
+
template: '',
|
|
1173
|
+
jit: true
|
|
1174
|
+
})
|
|
1175
|
+
], DummyAppSampleComponent);
|
|
1176
|
+
class SiLivePreviewRendererComponent {
|
|
1177
|
+
renderedExample = viewChild.required('renderedExample', { read: ViewContainerRef });
|
|
1178
|
+
react = viewChild.required('react', { read: ElementRef });
|
|
1179
|
+
renderingDone = false;
|
|
1180
|
+
exampleUrl;
|
|
1181
|
+
dataId = '';
|
|
1182
|
+
template = '';
|
|
1183
|
+
templateFromComponent = new EventEmitter(true);
|
|
1184
|
+
logClear = new EventEmitter();
|
|
1185
|
+
logMessage = new EventEmitter(true);
|
|
1186
|
+
logRenderingError = new EventEmitter(true);
|
|
1187
|
+
inProgress = new EventEmitter();
|
|
1188
|
+
supportsLandscapeMode = new EventEmitter();
|
|
1189
|
+
componentRef;
|
|
1190
|
+
moduleRef;
|
|
1191
|
+
hasRenderingError = false;
|
|
1192
|
+
componentTs;
|
|
1193
|
+
componentTsSampleComponent;
|
|
1194
|
+
dynamicComponent;
|
|
1195
|
+
dynamicComponentId;
|
|
1196
|
+
componentTsFirstLoad = true;
|
|
1197
|
+
componentTsSampleModule;
|
|
1198
|
+
component;
|
|
1199
|
+
componentModule;
|
|
1200
|
+
compiledTemplate;
|
|
1201
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
1202
|
+
compiler = inject(Compiler);
|
|
1203
|
+
injector = Injector.create({
|
|
1204
|
+
parent: inject(Injector),
|
|
1205
|
+
providers: [
|
|
1206
|
+
{
|
|
1207
|
+
provide: LOG_EVENT,
|
|
1208
|
+
useValue: (...msg) => this.logMessage.emit(this.stringifyLog(msg))
|
|
1209
|
+
}
|
|
1210
|
+
]
|
|
1211
|
+
});
|
|
1212
|
+
envInjector = inject(EnvironmentInjector);
|
|
1213
|
+
rendererFactory = inject(_DomRendererFactory2);
|
|
1214
|
+
config = inject(SI_LIVE_PREVIEW_CONFIG);
|
|
1215
|
+
internalConfig = inject(SI_LIVE_PREVIEW_INTERNALS);
|
|
1216
|
+
activatedRouted = inject(ActivatedRoute);
|
|
1217
|
+
defaultRoutes = this.activatedRouted.routeConfig?.children ?? [];
|
|
1218
|
+
ngOnChanges(changes) {
|
|
1219
|
+
if (changes.exampleUrl?.currentValue) {
|
|
1220
|
+
this.loadFromUrl();
|
|
1221
|
+
}
|
|
1222
|
+
if (changes.template?.currentValue) {
|
|
1223
|
+
// when the initial template is pushed from the renderer to the editor, this.template is
|
|
1224
|
+
// initially empty, but later changes to what the renderer has pushed out. In this case
|
|
1225
|
+
// don't compile
|
|
1226
|
+
if (this.template !== this.compiledTemplate) {
|
|
1227
|
+
this.setInProgress(true);
|
|
1228
|
+
this.compileWhenReady();
|
|
1229
|
+
}
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
ngOnDestroy() {
|
|
1233
|
+
this.clear();
|
|
1234
|
+
}
|
|
1235
|
+
recompile() {
|
|
1236
|
+
this.removeComponentInstance();
|
|
1237
|
+
this.logClear.emit();
|
|
1238
|
+
this.setRenderingError(false);
|
|
1239
|
+
try {
|
|
1240
|
+
this.createComponentInstance();
|
|
1241
|
+
}
|
|
1242
|
+
catch (error) {
|
|
1243
|
+
this.setRenderingError(true, error);
|
|
1244
|
+
}
|
|
1245
|
+
}
|
|
1246
|
+
logError(error) {
|
|
1247
|
+
if (this.config.errorHandler) {
|
|
1248
|
+
this.config.errorHandler(error);
|
|
1249
|
+
}
|
|
1250
|
+
}
|
|
1251
|
+
setRenderingError(hasError, msg) {
|
|
1252
|
+
this.hasRenderingError = hasError;
|
|
1253
|
+
this.logRenderingError.emit(msg);
|
|
1254
|
+
if (hasError) {
|
|
1255
|
+
setTimeout(() => this.setInProgress(false));
|
|
1256
|
+
}
|
|
1257
|
+
}
|
|
1258
|
+
loadFromUrl() {
|
|
1259
|
+
this.logClear.emit();
|
|
1260
|
+
this.clear();
|
|
1261
|
+
this.componentTsSampleComponent = undefined;
|
|
1262
|
+
this.componentTsSampleModule = undefined;
|
|
1263
|
+
this.dynamicComponent = undefined;
|
|
1264
|
+
this.componentTsFirstLoad = true;
|
|
1265
|
+
this.componentTs = this.config.componentLoader.load(this.exampleUrl);
|
|
1266
|
+
if (this.componentTs) {
|
|
1267
|
+
this.setInProgress(true);
|
|
1268
|
+
this.componentTs
|
|
1269
|
+
.then(m => {
|
|
1270
|
+
this.componentTsSampleComponent = m.SampleComponent;
|
|
1271
|
+
this.dynamicComponent = m.SampleComponent;
|
|
1272
|
+
this.componentTsSampleModule = m.SampleModule;
|
|
1273
|
+
this.compileWhenReady();
|
|
1274
|
+
if (!this.componentTsSampleComponent && !this.template) {
|
|
1275
|
+
setTimeout(() => this.setInProgress(false));
|
|
1276
|
+
}
|
|
1277
|
+
})
|
|
1278
|
+
.catch(e => {
|
|
1279
|
+
this.componentTs = undefined;
|
|
1280
|
+
this.logRenderingError.emit(e ? e.toString() : 'Failed loading TS');
|
|
1281
|
+
setTimeout(() => this.setInProgress(false));
|
|
1282
|
+
});
|
|
1283
|
+
}
|
|
1284
|
+
else {
|
|
1285
|
+
// set the dummy component
|
|
1286
|
+
this.componentTsSampleComponent = DummyAppSampleComponent;
|
|
1287
|
+
// let the editor know there is no component, so no template
|
|
1288
|
+
this.templateFromComponent.emit(undefined);
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
setInProgress(inProgress) {
|
|
1292
|
+
this.renderingDone = !inProgress;
|
|
1293
|
+
this.inProgress.emit(inProgress);
|
|
1294
|
+
}
|
|
1295
|
+
compileWhenReady() {
|
|
1296
|
+
if (this.componentTs) {
|
|
1297
|
+
if (!this.componentTsSampleComponent) {
|
|
1298
|
+
// TS, but code not yet loaded
|
|
1299
|
+
return;
|
|
1300
|
+
}
|
|
1301
|
+
if (!this.componentTsFirstLoad && !this.template) {
|
|
1302
|
+
// TS, first load done, template not yet available
|
|
1303
|
+
return;
|
|
1304
|
+
}
|
|
1305
|
+
}
|
|
1306
|
+
else if (!this.template) {
|
|
1307
|
+
// no TS, no template
|
|
1308
|
+
return;
|
|
1309
|
+
}
|
|
1310
|
+
this.doCompileTemplate();
|
|
1311
|
+
}
|
|
1312
|
+
doCompileTemplate() {
|
|
1313
|
+
this.logClear.emit();
|
|
1314
|
+
this.clear();
|
|
1315
|
+
this.createComponent();
|
|
1316
|
+
}
|
|
1317
|
+
stringifyLog(args) {
|
|
1318
|
+
return args.map(a => JSON.stringify(a, getCircularReplacer())).join(', ');
|
|
1319
|
+
}
|
|
1320
|
+
// this exists because in production mode, the ivy internal props are defined as
|
|
1321
|
+
// non-configurable and cannot be overwritten
|
|
1322
|
+
cloneComponentWithoutIvyStuff() {
|
|
1323
|
+
if (!this.componentTsSampleComponent) {
|
|
1324
|
+
return;
|
|
1325
|
+
}
|
|
1326
|
+
const orig = this.componentTsSampleComponent;
|
|
1327
|
+
const ignoreProps = ['ɵcmp', 'ɵfac', 'ɵprov'];
|
|
1328
|
+
const copy = orig.bind({});
|
|
1329
|
+
const descriptors = Object.getOwnPropertyDescriptors(orig);
|
|
1330
|
+
for (const name of Object.getOwnPropertyNames(orig)) {
|
|
1331
|
+
if (ignoreProps.includes(name)) {
|
|
1332
|
+
continue;
|
|
1333
|
+
}
|
|
1334
|
+
Object.defineProperty(copy, name, descriptors[name]);
|
|
1335
|
+
}
|
|
1336
|
+
this.dynamicComponent = copy;
|
|
1337
|
+
}
|
|
1338
|
+
// patches the template into the loaded component (if any), returns the template to use
|
|
1339
|
+
updateDynamicTemplate() {
|
|
1340
|
+
if (this.componentTsSampleComponent) {
|
|
1341
|
+
const ann = this.getAnnotation(this.componentTsSampleComponent, Component);
|
|
1342
|
+
if (ann) {
|
|
1343
|
+
const supportsLandscape = ann.providers?.includes(LandscapeSupportService);
|
|
1344
|
+
this.supportsLandscapeMode.emit(supportsLandscape);
|
|
1345
|
+
if (this.componentTsFirstLoad && !this.template) {
|
|
1346
|
+
// skipping compile on first load
|
|
1347
|
+
this.compiledTemplate = ann.template;
|
|
1348
|
+
this.templateFromComponent.emit(ann.template);
|
|
1349
|
+
}
|
|
1350
|
+
else if (ann.template !== this.template) {
|
|
1351
|
+
// recompile with new template
|
|
1352
|
+
this.componentTsFirstLoad = false;
|
|
1353
|
+
this.cloneComponentWithoutIvyStuff();
|
|
1354
|
+
ann.template = this.template;
|
|
1355
|
+
this.compiledTemplate = this.template;
|
|
1356
|
+
_compileComponent(this.dynamicComponent, ann);
|
|
1357
|
+
}
|
|
1358
|
+
}
|
|
1359
|
+
}
|
|
1360
|
+
}
|
|
1361
|
+
getAnnotation(obj, type) {
|
|
1362
|
+
return obj?.__annotations__?.find((a) => a instanceof type);
|
|
1363
|
+
}
|
|
1364
|
+
createAbstractComponentClass(ionic) {
|
|
1365
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
1366
|
+
const self = this;
|
|
1367
|
+
this.updateDynamicTemplate();
|
|
1368
|
+
let AbstractRuntimeComponent = class AbstractRuntimeComponent {
|
|
1369
|
+
changeDetector = inject(ChangeDetectorRef);
|
|
1370
|
+
container;
|
|
1371
|
+
constructor() {
|
|
1372
|
+
this.changeDetector.detach();
|
|
1373
|
+
}
|
|
1374
|
+
logEvent(...msg) {
|
|
1375
|
+
self.logMessage.emit(self.stringifyLog(msg));
|
|
1376
|
+
}
|
|
1377
|
+
ngDoCheck() {
|
|
1378
|
+
if (self.hasRenderingError) {
|
|
1379
|
+
return;
|
|
1380
|
+
}
|
|
1381
|
+
try {
|
|
1382
|
+
this.changeDetector.detectChanges();
|
|
1383
|
+
}
|
|
1384
|
+
catch (error) {
|
|
1385
|
+
setTimeout(() => this.handleError(error));
|
|
1386
|
+
}
|
|
1387
|
+
}
|
|
1388
|
+
ngAfterViewInit() {
|
|
1389
|
+
setTimeout(() => {
|
|
1390
|
+
self.setInProgress(false);
|
|
1391
|
+
const exampleRoutes = this.container?.injector.get(SI_LIVE_PREVIEW_EXAMPLE_ROUTES, undefined, {
|
|
1392
|
+
optional: true,
|
|
1393
|
+
self: true
|
|
1394
|
+
}) ?? self.defaultRoutes;
|
|
1395
|
+
const route = self.activatedRouted.routeConfig;
|
|
1396
|
+
if (route) {
|
|
1397
|
+
// cannot use router.resetConfig here as it destroys the components on child route navigations
|
|
1398
|
+
route.children = [...exampleRoutes];
|
|
1399
|
+
}
|
|
1400
|
+
});
|
|
1401
|
+
}
|
|
1402
|
+
handleError(error) {
|
|
1403
|
+
let msg = error.message;
|
|
1404
|
+
if (error.stack) {
|
|
1405
|
+
const stack = error.stack.split('\n', 3);
|
|
1406
|
+
stack.forEach(s => (msg += `\n${s}`));
|
|
1407
|
+
}
|
|
1408
|
+
self.setRenderingError(true, msg);
|
|
1409
|
+
// since these kind of errors are most likely bugs in the components, forward error
|
|
1410
|
+
self.logError(error);
|
|
1411
|
+
}
|
|
1412
|
+
static ctorParameters = () => [];
|
|
1413
|
+
static propDecorators = {
|
|
1414
|
+
container: [{ type: ViewChild, args: ['container', { read: ViewContainerRef },] }]
|
|
1415
|
+
};
|
|
1416
|
+
};
|
|
1417
|
+
AbstractRuntimeComponent = __decorate([
|
|
1418
|
+
Component({
|
|
1419
|
+
template: '',
|
|
1420
|
+
// eslint-disable-next-line @angular-eslint/prefer-standalone
|
|
1421
|
+
standalone: false,
|
|
1422
|
+
jit: true
|
|
1423
|
+
})
|
|
1424
|
+
], AbstractRuntimeComponent);
|
|
1425
|
+
if (ionic) {
|
|
1426
|
+
let RuntimeComponent = class RuntimeComponent extends AbstractRuntimeComponent {
|
|
1427
|
+
};
|
|
1428
|
+
RuntimeComponent = __decorate([
|
|
1429
|
+
Component({
|
|
1430
|
+
selector: 'si-rendered-example',
|
|
1431
|
+
// eslint-disable-next-line @angular-eslint/prefer-standalone
|
|
1432
|
+
standalone: false,
|
|
1433
|
+
template: '<ion-app><app-sample #container class="ion-page"></app-sample></ion-app>',
|
|
1434
|
+
jit: true
|
|
1435
|
+
})
|
|
1436
|
+
], RuntimeComponent);
|
|
1437
|
+
return RuntimeComponent;
|
|
1438
|
+
}
|
|
1439
|
+
let RuntimeComponent = class RuntimeComponent extends AbstractRuntimeComponent {
|
|
1440
|
+
};
|
|
1441
|
+
RuntimeComponent = __decorate([
|
|
1442
|
+
Component({
|
|
1443
|
+
selector: 'si-rendered-example',
|
|
1444
|
+
// eslint-disable-next-line @angular-eslint/prefer-standalone
|
|
1445
|
+
standalone: false,
|
|
1446
|
+
template: '<app-sample #container></app-sample>',
|
|
1447
|
+
jit: true
|
|
1448
|
+
})
|
|
1449
|
+
], RuntimeComponent);
|
|
1450
|
+
return RuntimeComponent;
|
|
1451
|
+
}
|
|
1452
|
+
createComponentClass() {
|
|
1453
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
1454
|
+
const RuntimeComponent = this.createAbstractComponentClass(this.internalConfig.isMobile);
|
|
1455
|
+
const compAnn = this.getAnnotation(RuntimeComponent, Component);
|
|
1456
|
+
if (!Object.prototype.hasOwnProperty.call(RuntimeComponent, 'ɵcmp')) {
|
|
1457
|
+
_compileComponent(RuntimeComponent, compAnn);
|
|
1458
|
+
}
|
|
1459
|
+
return RuntimeComponent;
|
|
1460
|
+
}
|
|
1461
|
+
createModule() {
|
|
1462
|
+
const meta = {
|
|
1463
|
+
declarations: [this.component],
|
|
1464
|
+
imports: [...this.config.modules],
|
|
1465
|
+
jit: true
|
|
1466
|
+
};
|
|
1467
|
+
if (this.dynamicComponent) {
|
|
1468
|
+
if (this.dynamicComponent['ɵcmp'].standalone) {
|
|
1469
|
+
meta.imports.push(this.dynamicComponent);
|
|
1470
|
+
}
|
|
1471
|
+
else {
|
|
1472
|
+
meta.declarations.push(this.dynamicComponent);
|
|
1473
|
+
}
|
|
1474
|
+
}
|
|
1475
|
+
// Merge the provided NgModule into the one to be constructed. This is necessary to have everything at the
|
|
1476
|
+
// right level. Otherwise, the provided module would have to declare and export the component as well
|
|
1477
|
+
const ann = this.getAnnotation(this.componentTsSampleModule, NgModule);
|
|
1478
|
+
if (ann) {
|
|
1479
|
+
for (const field of ['imports', 'declarations', 'exports', 'providers']) {
|
|
1480
|
+
const fieldAnn = ann[field];
|
|
1481
|
+
if (fieldAnn) {
|
|
1482
|
+
if (!meta[field]) {
|
|
1483
|
+
meta[field] = [];
|
|
1484
|
+
}
|
|
1485
|
+
meta[field].push(...fieldAnn);
|
|
1486
|
+
}
|
|
1487
|
+
}
|
|
1488
|
+
}
|
|
1489
|
+
let RuntimeComponentModule = class RuntimeComponentModule {
|
|
1490
|
+
};
|
|
1491
|
+
RuntimeComponentModule = __decorate([
|
|
1492
|
+
NgModule({
|
|
1493
|
+
declarations: meta.declarations,
|
|
1494
|
+
imports: meta.imports,
|
|
1495
|
+
exports: meta.exports,
|
|
1496
|
+
providers: meta.providers,
|
|
1497
|
+
jit: true
|
|
1498
|
+
})
|
|
1499
|
+
], RuntimeComponentModule);
|
|
1500
|
+
if (!Object.hasOwnProperty.call(RuntimeComponentModule, 'ɵmod')) {
|
|
1501
|
+
_compileNgModule(RuntimeComponentModule, this.getAnnotation(RuntimeComponentModule, NgModule));
|
|
1502
|
+
}
|
|
1503
|
+
return RuntimeComponentModule;
|
|
1504
|
+
}
|
|
1505
|
+
clear() {
|
|
1506
|
+
this.removeComponentInstance();
|
|
1507
|
+
this.moduleRef?.destroy();
|
|
1508
|
+
this.moduleRef = undefined;
|
|
1509
|
+
if (this.componentModule) {
|
|
1510
|
+
this.compiler.clearCacheFor(this.component);
|
|
1511
|
+
this.compiler.clearCacheFor(this.componentModule);
|
|
1512
|
+
this.component = undefined;
|
|
1513
|
+
this.componentModule = undefined;
|
|
1514
|
+
}
|
|
1515
|
+
if (this.dynamicComponent) {
|
|
1516
|
+
this.compiler.clearCacheFor(this.dynamicComponent);
|
|
1517
|
+
}
|
|
1518
|
+
_resetCompiledComponents();
|
|
1519
|
+
}
|
|
1520
|
+
removeComponentInstance() {
|
|
1521
|
+
try {
|
|
1522
|
+
this.renderedExample().remove();
|
|
1523
|
+
}
|
|
1524
|
+
catch (error) {
|
|
1525
|
+
// FIXME: there's no point in logging this as rendering error since it will be cleared right away
|
|
1526
|
+
console.warn('Error during ngOnDestroy():', error);
|
|
1527
|
+
}
|
|
1528
|
+
this.componentRef?.destroy();
|
|
1529
|
+
this.componentRef = undefined;
|
|
1530
|
+
// clear out render for component id:
|
|
1531
|
+
// - contains the styles
|
|
1532
|
+
// - stays mostly the same for all examples
|
|
1533
|
+
if (this.dynamicComponentId) {
|
|
1534
|
+
this.rendererFactory.rendererByCompId?.delete(this.dynamicComponentId);
|
|
1535
|
+
}
|
|
1536
|
+
}
|
|
1537
|
+
createComponent() {
|
|
1538
|
+
this.setRenderingError(false);
|
|
1539
|
+
try {
|
|
1540
|
+
this.component = this.createComponentClass();
|
|
1541
|
+
this.componentModule = this.createModule();
|
|
1542
|
+
this.moduleRef = createNgModule(this.componentModule, this.envInjector);
|
|
1543
|
+
this.createComponentInstance();
|
|
1544
|
+
}
|
|
1545
|
+
catch (error) {
|
|
1546
|
+
this.setRenderingError(true, error.toString());
|
|
1547
|
+
}
|
|
1548
|
+
}
|
|
1549
|
+
createComponentInstance() {
|
|
1550
|
+
this.dynamicComponentId = this.dynamicComponent?.['ɵcmp']?.id;
|
|
1551
|
+
if (this.moduleRef) {
|
|
1552
|
+
this.componentRef = this.renderedExample().createComponent(this.component, {
|
|
1553
|
+
injector: this.injector,
|
|
1554
|
+
ngModuleRef: this.moduleRef
|
|
1555
|
+
});
|
|
1556
|
+
}
|
|
1557
|
+
}
|
|
1558
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: SiLivePreviewRendererComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1559
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "19.0.6", type: SiLivePreviewRendererComponent, isStandalone: false, selector: "si-live-preview-renderer", inputs: { exampleUrl: "exampleUrl", dataId: "dataId", template: "template" }, outputs: { templateFromComponent: "templateFromComponent", logClear: "logClear", logMessage: "logMessage", logRenderingError: "logRenderingError", inProgress: "inProgress", supportsLandscapeMode: "supportsLandscapeMode" }, host: { properties: { "class.live-preview-done": "this.renderingDone", "attr.data-example": "this.exampleUrl", "attr.data-id": "this.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 }], usesOnChanges: true, ngImport: i0, template: '<div #renderedExample></div><div #react id="app"></div>', isInline: true });
|
|
1560
|
+
}
|
|
1561
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: SiLivePreviewRendererComponent, decorators: [{
|
|
1562
|
+
type: Component,
|
|
1563
|
+
args: [{
|
|
1564
|
+
selector: 'si-live-preview-renderer',
|
|
1565
|
+
// eslint-disable-next-line @angular-eslint/prefer-standalone
|
|
1566
|
+
standalone: false,
|
|
1567
|
+
template: '<div #renderedExample></div><div #react id="app"></div>'
|
|
1568
|
+
}]
|
|
1569
|
+
}], propDecorators: { renderingDone: [{
|
|
1570
|
+
type: HostBinding,
|
|
1571
|
+
args: ['class.live-preview-done']
|
|
1572
|
+
}], exampleUrl: [{
|
|
1573
|
+
type: HostBinding,
|
|
1574
|
+
args: ['attr.data-example']
|
|
1575
|
+
}, {
|
|
1576
|
+
type: Input
|
|
1577
|
+
}], dataId: [{
|
|
1578
|
+
type: HostBinding,
|
|
1579
|
+
args: ['attr.data-id']
|
|
1580
|
+
}, {
|
|
1581
|
+
type: Input
|
|
1582
|
+
}], template: [{
|
|
1583
|
+
type: Input
|
|
1584
|
+
}], templateFromComponent: [{
|
|
1585
|
+
type: Output
|
|
1586
|
+
}], logClear: [{
|
|
1587
|
+
type: Output
|
|
1588
|
+
}], logMessage: [{
|
|
1589
|
+
type: Output
|
|
1590
|
+
}], logRenderingError: [{
|
|
1591
|
+
type: Output
|
|
1592
|
+
}], inProgress: [{
|
|
1593
|
+
type: Output
|
|
1594
|
+
}], supportsLandscapeMode: [{
|
|
1595
|
+
type: Output
|
|
1596
|
+
}] } });
|
|
1597
|
+
|
|
1598
|
+
/**
|
|
1599
|
+
* Copyright Siemens 2016 - 2025.
|
|
1600
|
+
* SPDX-License-Identifier: MIT
|
|
1601
|
+
*/
|
|
1602
|
+
class SiExampleViewerComponent {
|
|
1603
|
+
router = inject(Router);
|
|
1604
|
+
route = inject(ActivatedRoute);
|
|
1605
|
+
config = inject(SI_LIVE_PREVIEW_CONFIG);
|
|
1606
|
+
internalConfig = inject(SI_LIVE_PREVIEW_INTERNALS);
|
|
1607
|
+
themeApi = inject(SiLivePreviewThemeApi, { optional: true });
|
|
1608
|
+
localeApi = inject(SiLivePreviewLocaleApi, { optional: true });
|
|
1609
|
+
renderer = viewChild.required('renderer');
|
|
1610
|
+
get hasTabs() {
|
|
1611
|
+
return this.tabs.length > 1;
|
|
1612
|
+
}
|
|
1613
|
+
get hasTabsMobile() {
|
|
1614
|
+
return this.tabs.length > 1 && this.internalConfig.isMobile;
|
|
1615
|
+
}
|
|
1616
|
+
ticketBaseUrl = this.config.ticketBaseUrl;
|
|
1617
|
+
baseUrl = this.config.examplesBaseUrl;
|
|
1618
|
+
exampleUrl;
|
|
1619
|
+
dataId = '';
|
|
1620
|
+
mode = 'viewer';
|
|
1621
|
+
theme = 'light';
|
|
1622
|
+
locale;
|
|
1623
|
+
isRTL = false;
|
|
1624
|
+
template = '';
|
|
1625
|
+
reactTemplate = '';
|
|
1626
|
+
vueTemplate = '';
|
|
1627
|
+
jsTemplate = '';
|
|
1628
|
+
tabs = [];
|
|
1629
|
+
activeTabIndex = 0;
|
|
1630
|
+
constructor() {
|
|
1631
|
+
this.route.params.subscribe(params => (this.mode = params.mode ?? 'editor'));
|
|
1632
|
+
this.route.queryParams.subscribe(params => this.handleQueryParams(params));
|
|
1633
|
+
}
|
|
1634
|
+
handleQueryParams(params) {
|
|
1635
|
+
let handled = false;
|
|
1636
|
+
let recompile = false;
|
|
1637
|
+
const base = params.base ? params.base + '/' : '';
|
|
1638
|
+
if (params.e) {
|
|
1639
|
+
const prevUrl = this.exampleUrl;
|
|
1640
|
+
this.tabs = [];
|
|
1641
|
+
this.activeTabIndex = 0;
|
|
1642
|
+
this.exampleUrl = '';
|
|
1643
|
+
const examples = Array.isArray(params.e) ? params.e : [params.e];
|
|
1644
|
+
examples.forEach(element => {
|
|
1645
|
+
const parts = element.split(';');
|
|
1646
|
+
this.tabs.push({
|
|
1647
|
+
heading: parts[1],
|
|
1648
|
+
base,
|
|
1649
|
+
example: parts[0]
|
|
1650
|
+
});
|
|
1651
|
+
});
|
|
1652
|
+
if (this.tabs.length) {
|
|
1653
|
+
this.activateTab(0);
|
|
1654
|
+
recompile = prevUrl === this.exampleUrl;
|
|
1655
|
+
}
|
|
1656
|
+
if (this.tabs.length <= 1 && params.t) {
|
|
1657
|
+
if (params.framework === 'react') {
|
|
1658
|
+
this.reactTemplate = params.t;
|
|
1659
|
+
}
|
|
1660
|
+
else if (params.framework === 'vue') {
|
|
1661
|
+
this.vueTemplate = params.t;
|
|
1662
|
+
}
|
|
1663
|
+
else if (params.framework === 'js') {
|
|
1664
|
+
this.jsTemplate = params.t;
|
|
1665
|
+
}
|
|
1666
|
+
else {
|
|
1667
|
+
this.template = params.t;
|
|
1668
|
+
recompile = recompile || this.template !== params.t;
|
|
1669
|
+
}
|
|
1670
|
+
}
|
|
1671
|
+
handled = true;
|
|
1672
|
+
}
|
|
1673
|
+
if (params.theme) {
|
|
1674
|
+
this.setTheme(params.theme);
|
|
1675
|
+
handled = true;
|
|
1676
|
+
}
|
|
1677
|
+
if (params.locale) {
|
|
1678
|
+
this.setLocale(params.locale);
|
|
1679
|
+
handled = true;
|
|
1680
|
+
}
|
|
1681
|
+
if (params.isRTL) {
|
|
1682
|
+
this.setRTL(params.isRTL);
|
|
1683
|
+
handled = true;
|
|
1684
|
+
}
|
|
1685
|
+
if (params.mode && this.mode !== 'editor') {
|
|
1686
|
+
setDeviceMode(params.mode);
|
|
1687
|
+
recompile = true;
|
|
1688
|
+
handled = true;
|
|
1689
|
+
}
|
|
1690
|
+
if (handled) {
|
|
1691
|
+
const { e, t, theme, mode, locale, isRTL, ...newParams } = params;
|
|
1692
|
+
this.router.navigate([], { queryParams: newParams });
|
|
1693
|
+
}
|
|
1694
|
+
if (params.id) {
|
|
1695
|
+
recompile = this.dataId !== params.id;
|
|
1696
|
+
this.dataId = params.id;
|
|
1697
|
+
}
|
|
1698
|
+
if (recompile) {
|
|
1699
|
+
this.renderer()?.recompile();
|
|
1700
|
+
}
|
|
1701
|
+
}
|
|
1702
|
+
setUiTheme(theme) {
|
|
1703
|
+
document.documentElement.classList.toggle('app--dark', theme === 'dark');
|
|
1704
|
+
document.documentElement.classList.toggle('app--light', theme === 'light');
|
|
1705
|
+
}
|
|
1706
|
+
setTheme(theme) {
|
|
1707
|
+
if (this.mode === 'editor') {
|
|
1708
|
+
this.theme = theme;
|
|
1709
|
+
}
|
|
1710
|
+
if (this.themeApi) {
|
|
1711
|
+
this.themeApi.setThemeFromPreviewer(theme);
|
|
1712
|
+
}
|
|
1713
|
+
this.setUiTheme(theme);
|
|
1714
|
+
}
|
|
1715
|
+
setRTL(rtl) {
|
|
1716
|
+
this.isRTL = rtl;
|
|
1717
|
+
if (this.mode !== 'editor') {
|
|
1718
|
+
setDirectionRtl(rtl);
|
|
1719
|
+
}
|
|
1720
|
+
}
|
|
1721
|
+
setLocale(locale) {
|
|
1722
|
+
if (this.mode === 'editor') {
|
|
1723
|
+
this.locale = locale;
|
|
1724
|
+
return;
|
|
1725
|
+
}
|
|
1726
|
+
if (this.localeApi) {
|
|
1727
|
+
this.localeApi.setLocale(locale);
|
|
1728
|
+
}
|
|
1729
|
+
}
|
|
1730
|
+
activateTab(index) {
|
|
1731
|
+
const example = this.tabs[index].example;
|
|
1732
|
+
this.activeTabIndex = index;
|
|
1733
|
+
this.exampleUrl = this.tabs[index].base + example;
|
|
1734
|
+
}
|
|
1735
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: SiExampleViewerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1736
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.6", type: SiExampleViewerComponent, isStandalone: false, selector: "si-example-viewer", host: { properties: { "class.has-tabs": "this.hasTabs", "class.has-tabs-mobile": "this.hasTabsMobile" } }, viewQueries: [{ propertyName: "renderer", first: true, predicate: ["renderer"], descendants: true, isSignal: true }], ngImport: i0, template: "<div class=\"wrapper\">\n @if (!exampleUrl && !template) {\n <p class=\"text-info\" 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 ((template || reactTemplate || vueTemplate || jsTemplate) && mode === 'editor') {\n <p class=\"text-info\" 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\n #renderer\n [exampleUrl]=\"baseUrl + exampleUrl\"\n [dataId]=\"dataId\"\n [template]=\"template\"\n />\n}\n\n@if (mode === 'editor') {\n <si-live-preview\n [ticketBaseUrl]=\"ticketBaseUrl\"\n [baseUrl]=\"baseUrl\"\n [example]=\"exampleUrl\"\n [template]=\"template\"\n [templateReact]=\"reactTemplate\"\n [templateVue]=\"vueTemplate\"\n [templateJs]=\"jsTemplate\"\n [theme]=\"theme\"\n [locale]=\"locale\"\n [isRTL]=\"isRTL\"\n />\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.tab-active.tab-link{color:var(--element-action-secondary-text);border-block-end-color:var(--element-action-secondary-text)!important}.lp-tabs .tab-item.tab-active.tab-link:hover{color:var(--element-action-secondary-text-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(--element-text-primary);border:0;border-block-end:4px solid transparent}.lp-tabs .tab-item.tab-link:hover{text-decoration:none;color:var(--element-action-secondary-text-hover);border-block-end-color:var(--element-ui-4)}.wrapper{background-color:var(--element-base-0);color:var(--element-text-primary)}.wrapper.has-tabs .tab-wrapper,.wrapper.has-tabs-mobile{background-color:var(--element-base-0)}.tab-wrapper{margin-block-end:10px;border-block-end:1px solid var(--element-ui-4)}si-live-preview-renderer{flex:1;transform:translate(0)}\n"], dependencies: [{ kind: "component", type: SiLivePreviewComponent, selector: "si-live-preview", inputs: ["baseUrl", "example", "template", "theme", "locale", "isRTL", "ticketBaseUrl", "templateReact", "templateVue", "templateJs"] }, { kind: "component", type: SiLivePreviewRendererComponent, selector: "si-live-preview-renderer", inputs: ["exampleUrl", "dataId", "template"], outputs: ["templateFromComponent", "logClear", "logMessage", "logRenderingError", "inProgress", "supportsLandscapeMode"] }] });
|
|
1737
|
+
}
|
|
1738
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: SiExampleViewerComponent, decorators: [{
|
|
1739
|
+
type: Component,
|
|
1740
|
+
args: [{ selector: 'si-example-viewer', standalone: false, template: "<div class=\"wrapper\">\n @if (!exampleUrl && !template) {\n <p class=\"text-info\" 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 ((template || reactTemplate || vueTemplate || jsTemplate) && mode === 'editor') {\n <p class=\"text-info\" 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\n #renderer\n [exampleUrl]=\"baseUrl + exampleUrl\"\n [dataId]=\"dataId\"\n [template]=\"template\"\n />\n}\n\n@if (mode === 'editor') {\n <si-live-preview\n [ticketBaseUrl]=\"ticketBaseUrl\"\n [baseUrl]=\"baseUrl\"\n [example]=\"exampleUrl\"\n [template]=\"template\"\n [templateReact]=\"reactTemplate\"\n [templateVue]=\"vueTemplate\"\n [templateJs]=\"jsTemplate\"\n [theme]=\"theme\"\n [locale]=\"locale\"\n [isRTL]=\"isRTL\"\n />\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.tab-active.tab-link{color:var(--element-action-secondary-text);border-block-end-color:var(--element-action-secondary-text)!important}.lp-tabs .tab-item.tab-active.tab-link:hover{color:var(--element-action-secondary-text-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(--element-text-primary);border:0;border-block-end:4px solid transparent}.lp-tabs .tab-item.tab-link:hover{text-decoration:none;color:var(--element-action-secondary-text-hover);border-block-end-color:var(--element-ui-4)}.wrapper{background-color:var(--element-base-0);color:var(--element-text-primary)}.wrapper.has-tabs .tab-wrapper,.wrapper.has-tabs-mobile{background-color:var(--element-base-0)}.tab-wrapper{margin-block-end:10px;border-block-end:1px solid var(--element-ui-4)}si-live-preview-renderer{flex:1;transform:translate(0)}\n"] }]
|
|
1741
|
+
}], ctorParameters: () => [], propDecorators: { hasTabs: [{
|
|
1742
|
+
type: HostBinding,
|
|
1743
|
+
args: ['class.has-tabs']
|
|
1744
|
+
}], hasTabsMobile: [{
|
|
1745
|
+
type: HostBinding,
|
|
1746
|
+
args: ['class.has-tabs-mobile']
|
|
1747
|
+
}] } });
|
|
1748
|
+
|
|
1749
|
+
/**
|
|
1750
|
+
* Copyright Siemens 2016 - 2025.
|
|
1751
|
+
* SPDX-License-Identifier: MIT
|
|
1752
|
+
*/
|
|
1753
|
+
class SiLivePreviewWebComponentService {
|
|
1754
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: SiLivePreviewWebComponentService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1755
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: SiLivePreviewWebComponentService });
|
|
1756
|
+
}
|
|
1757
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: SiLivePreviewWebComponentService, decorators: [{
|
|
1758
|
+
type: Injectable
|
|
1759
|
+
}] });
|
|
1760
|
+
|
|
1761
|
+
/**
|
|
1762
|
+
* Copyright Siemens 2016 - 2025.
|
|
1763
|
+
* SPDX-License-Identifier: MIT
|
|
1764
|
+
*/
|
|
1765
|
+
const filterTargets = ['_self', '_top', '_parent', ''];
|
|
1766
|
+
class SiLivePreviewWrapperComponent {
|
|
1767
|
+
renderer = viewChild.required('renderer');
|
|
1768
|
+
webcomponentRenderer = viewChild.required('webcomponentRenderer');
|
|
1769
|
+
exampleUrl;
|
|
1770
|
+
template = '';
|
|
1771
|
+
loadReact = false;
|
|
1772
|
+
loadVue = false;
|
|
1773
|
+
loadJs = false;
|
|
1774
|
+
webcomponentTemplateCode = '';
|
|
1775
|
+
isMobile = false;
|
|
1776
|
+
theme;
|
|
1777
|
+
isRTL = false;
|
|
1778
|
+
mode;
|
|
1779
|
+
locale;
|
|
1780
|
+
initialUrl;
|
|
1781
|
+
config = inject(SI_LIVE_PREVIEW_CONFIG);
|
|
1782
|
+
themeApi = inject(SiLivePreviewThemeApi, { optional: true });
|
|
1783
|
+
localeApi = inject(SiLivePreviewLocaleApi, { optional: true });
|
|
1784
|
+
internalConfig = inject(SI_LIVE_PREVIEW_INTERNALS);
|
|
1785
|
+
ngZone = inject(NgZone);
|
|
1786
|
+
destroyRef = inject(DestroyRef);
|
|
1787
|
+
webcomponentService = inject(SiLivePreviewWebComponentService, { optional: true });
|
|
1788
|
+
constructor() {
|
|
1789
|
+
this.themeApi
|
|
1790
|
+
?.getApplicationThemeObservable()
|
|
1791
|
+
.pipe(takeUntilDestroyed(this.destroyRef))
|
|
1792
|
+
.subscribe(theme => {
|
|
1793
|
+
this.theme = theme;
|
|
1794
|
+
this.sendMessage('theme', this.theme);
|
|
1795
|
+
});
|
|
1796
|
+
this.localeApi
|
|
1797
|
+
?.getLocale()
|
|
1798
|
+
.pipe(takeUntilDestroyed(this.destroyRef))
|
|
1799
|
+
.subscribe(locale => {
|
|
1800
|
+
if (this.locale !== locale) {
|
|
1801
|
+
this.locale = locale;
|
|
1802
|
+
this.sendMessage('locale', this.locale);
|
|
1803
|
+
}
|
|
1804
|
+
});
|
|
1805
|
+
this.initialUrl = window.location.toString();
|
|
1806
|
+
this.isMobile = this.internalConfig.isMobile;
|
|
1807
|
+
this.ngZone.runOutsideAngular(() => fromEvent(window, 'message')
|
|
1808
|
+
.pipe(takeUntilDestroyed(this.destroyRef))
|
|
1809
|
+
.subscribe(message => this.onMessage(message)));
|
|
1810
|
+
}
|
|
1811
|
+
onMessage(event) {
|
|
1812
|
+
if (!event.data || event.data.src !== 'editor') {
|
|
1813
|
+
return;
|
|
1814
|
+
}
|
|
1815
|
+
this.ngZone.run(() => this.onMessageInZone(event));
|
|
1816
|
+
}
|
|
1817
|
+
onMessageInZone(event) {
|
|
1818
|
+
this.exampleUrl = event.data.exampleUrl;
|
|
1819
|
+
this.template = event.data.template;
|
|
1820
|
+
this.loadReact = event.data.loadReact;
|
|
1821
|
+
this.loadVue = event.data.loadVue;
|
|
1822
|
+
this.loadJs = event.data.loadJs;
|
|
1823
|
+
this.webcomponentTemplateCode = event.data.reactVueTemplate;
|
|
1824
|
+
if (this.theme !== event.data.theme) {
|
|
1825
|
+
this.setTheme(event.data.theme);
|
|
1826
|
+
}
|
|
1827
|
+
if (this.locale !== event.data.locale) {
|
|
1828
|
+
this.setLocale(event.data.locale);
|
|
1829
|
+
}
|
|
1830
|
+
if (this.isRTL !== event.data.isRTL) {
|
|
1831
|
+
this.setRTL(event.data.isRTL);
|
|
1832
|
+
}
|
|
1833
|
+
if (this.isMobile) {
|
|
1834
|
+
this.setSafeArea(event.data.safeAreaTop, event.data.safeAreaBottom, event.data.safeAreaLeft, event.data.safeAreaRight);
|
|
1835
|
+
}
|
|
1836
|
+
if (this.mode !== event.data.mode && this.isMobile) {
|
|
1837
|
+
this.mode = event.data.mode;
|
|
1838
|
+
setDeviceMode(this.mode);
|
|
1839
|
+
this.renderer().recompile();
|
|
1840
|
+
}
|
|
1841
|
+
const webcomponentRenderer = this.webcomponentRenderer();
|
|
1842
|
+
if (webcomponentRenderer && (this.loadReact || this.loadVue || this.loadJs)) {
|
|
1843
|
+
this.webcomponentService?.injectComponent(webcomponentRenderer, {
|
|
1844
|
+
exampleUrl: this.exampleUrl,
|
|
1845
|
+
loadReact: this.loadReact,
|
|
1846
|
+
loadJs: this.loadJs,
|
|
1847
|
+
webcomponentTemplateCode: this.webcomponentTemplateCode,
|
|
1848
|
+
loadVue: this.loadVue,
|
|
1849
|
+
config: this.config
|
|
1850
|
+
}, {
|
|
1851
|
+
inProgress: this.sendMessage
|
|
1852
|
+
});
|
|
1853
|
+
}
|
|
1854
|
+
else {
|
|
1855
|
+
this.webcomponentService?.destroyComponent();
|
|
1856
|
+
}
|
|
1857
|
+
}
|
|
1858
|
+
onClick(event) {
|
|
1859
|
+
const target = event?.target;
|
|
1860
|
+
if (target?.tagName === 'A' && !event.defaultPrevented) {
|
|
1861
|
+
// for normal link: ok if it starts with the proper route, else open in a new window
|
|
1862
|
+
const newUrl = target.href;
|
|
1863
|
+
const linkTarget = target.target;
|
|
1864
|
+
if (newUrl && !newUrl.startsWith(this.initialUrl) && filterTargets.includes(linkTarget)) {
|
|
1865
|
+
event.preventDefault();
|
|
1866
|
+
window.open(newUrl, '_blank');
|
|
1867
|
+
}
|
|
1868
|
+
}
|
|
1869
|
+
}
|
|
1870
|
+
sendMessage(type, message) {
|
|
1871
|
+
window.parent.postMessage({ src: 'renderer', type, message }, '*');
|
|
1872
|
+
}
|
|
1873
|
+
setTheme(theme) {
|
|
1874
|
+
this.theme = theme;
|
|
1875
|
+
if (this.themeApi) {
|
|
1876
|
+
this.themeApi.setThemeFromPreviewer(this.theme);
|
|
1877
|
+
}
|
|
1878
|
+
else {
|
|
1879
|
+
document.documentElement.classList.toggle('app--dark', this.theme === 'dark');
|
|
1880
|
+
document.documentElement.classList.toggle('app--light', this.theme === 'light');
|
|
1881
|
+
}
|
|
1882
|
+
}
|
|
1883
|
+
setRTL(rtl) {
|
|
1884
|
+
this.isRTL = rtl;
|
|
1885
|
+
setDirectionRtl(rtl);
|
|
1886
|
+
}
|
|
1887
|
+
setLocale(locale) {
|
|
1888
|
+
if (!locale) {
|
|
1889
|
+
return;
|
|
1890
|
+
}
|
|
1891
|
+
this.locale = locale;
|
|
1892
|
+
if (this.localeApi) {
|
|
1893
|
+
this.localeApi.setLocale(this.locale);
|
|
1894
|
+
}
|
|
1895
|
+
}
|
|
1896
|
+
setSafeArea(top, bottom, left, right) {
|
|
1897
|
+
const htmlTag = document.documentElement;
|
|
1898
|
+
htmlTag.style.setProperty('--ion-safe-area-top', (top ?? 0) + 'px');
|
|
1899
|
+
htmlTag.style.setProperty('--ion-safe-area-bottom', (bottom ?? 0) + 'px');
|
|
1900
|
+
htmlTag.style.setProperty('--ion-safe-area-left', (left ?? 0) + 'px');
|
|
1901
|
+
htmlTag.style.setProperty('--ion-safe-area-right', (right ?? 0) + 'px');
|
|
1902
|
+
}
|
|
1903
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: SiLivePreviewWrapperComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1904
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "19.0.6", type: SiLivePreviewWrapperComponent, isStandalone: false, 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]=\"loadReact || loadVue || loadJs\"\n [template]=\"template\"\n [exampleUrl]=\"exampleUrl\"\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", inputs: ["exampleUrl", "dataId", "template"], outputs: ["templateFromComponent", "logClear", "logMessage", "logRenderingError", "inProgress", "supportsLandscapeMode"] }] });
|
|
1905
|
+
}
|
|
1906
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: SiLivePreviewWrapperComponent, decorators: [{
|
|
1907
|
+
type: Component,
|
|
1908
|
+
args: [{ selector: 'si-live-preview-wrapper', standalone: false, template: "<si-live-preview-renderer\n #renderer\n [hidden]=\"loadReact || loadVue || loadJs\"\n [template]=\"template\"\n [exampleUrl]=\"exampleUrl\"\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"] }]
|
|
1909
|
+
}], ctorParameters: () => [], propDecorators: { onClick: [{
|
|
1910
|
+
type: HostListener,
|
|
1911
|
+
args: ['click', ['$event']]
|
|
1912
|
+
}] } });
|
|
1913
|
+
|
|
1914
|
+
/**
|
|
1915
|
+
* Copyright Siemens 2016 - 2025.
|
|
1916
|
+
* SPDX-License-Identifier: MIT
|
|
1917
|
+
*/
|
|
1918
|
+
const livePreviewRoutes = [
|
|
1919
|
+
{
|
|
1920
|
+
path: 'overview',
|
|
1921
|
+
children: [
|
|
1922
|
+
// those need to be explicit for Ionic router related components like tabs
|
|
1923
|
+
{ path: 'route1', component: SiDummyComponent },
|
|
1924
|
+
{ path: 'route2', component: SiDummyComponent },
|
|
1925
|
+
{ path: 'route3', component: SiDummyComponent },
|
|
1926
|
+
{ path: 'route4', component: SiDummyComponent },
|
|
1927
|
+
{ path: 'route5', component: SiDummyComponent },
|
|
1928
|
+
{ path: '**', component: SiExampleOverviewComponent }
|
|
1929
|
+
]
|
|
1930
|
+
},
|
|
1931
|
+
{
|
|
1932
|
+
path: 'viewer/:mode',
|
|
1933
|
+
component: SiExampleViewerComponent,
|
|
1934
|
+
children: [
|
|
1935
|
+
{ path: 'route1', component: SiDummyComponent },
|
|
1936
|
+
{ path: 'route2', component: SiDummyComponent },
|
|
1937
|
+
{ path: 'route3', component: SiDummyComponent },
|
|
1938
|
+
{ path: 'route4', component: SiDummyComponent },
|
|
1939
|
+
{ path: 'route5', component: SiDummyComponent },
|
|
1940
|
+
{ path: '**', component: SiDummyComponent }
|
|
1941
|
+
]
|
|
1942
|
+
},
|
|
1943
|
+
{
|
|
1944
|
+
path: 'iframe',
|
|
1945
|
+
component: SiLivePreviewWrapperComponent,
|
|
1946
|
+
children: [
|
|
1947
|
+
{ path: 'route1', component: SiDummyComponent },
|
|
1948
|
+
{ path: 'route2', component: SiDummyComponent },
|
|
1949
|
+
{ path: 'route3', component: SiDummyComponent },
|
|
1950
|
+
{ path: 'route4', component: SiDummyComponent },
|
|
1951
|
+
{ path: 'route5', component: SiDummyComponent },
|
|
1952
|
+
{ path: '**', component: SiDummyComponent }
|
|
1953
|
+
]
|
|
1954
|
+
},
|
|
1955
|
+
{ path: '', redirectTo: 'viewer/editor', pathMatch: 'full' },
|
|
1956
|
+
{ path: '**', component: SiExampleViewerComponent }
|
|
1957
|
+
];
|
|
1958
|
+
class SimplLivePreviewRoutingModule {
|
|
1959
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: SimplLivePreviewRoutingModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
1960
|
+
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.0.6", ngImport: i0, type: SimplLivePreviewRoutingModule, imports: [i1.RouterModule], exports: [RouterModule] });
|
|
1961
|
+
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: SimplLivePreviewRoutingModule, imports: [RouterModule.forRoot(livePreviewRoutes, { useHash: true }), RouterModule] });
|
|
1962
|
+
}
|
|
1963
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: SimplLivePreviewRoutingModule, decorators: [{
|
|
1964
|
+
type: NgModule,
|
|
1965
|
+
args: [{
|
|
1966
|
+
imports: [RouterModule.forRoot(livePreviewRoutes, { useHash: true })],
|
|
1967
|
+
exports: [RouterModule]
|
|
1968
|
+
}]
|
|
1969
|
+
}] });
|
|
1970
|
+
|
|
1971
|
+
/**
|
|
1972
|
+
* Copyright Siemens 2016 - 2025.
|
|
1973
|
+
* SPDX-License-Identifier: MIT
|
|
1974
|
+
*/
|
|
1975
|
+
class SimplLivePreviewModule {
|
|
1976
|
+
static forRoot(config, isMobile = false) {
|
|
1977
|
+
return {
|
|
1978
|
+
ngModule: SimplLivePreviewModule,
|
|
1979
|
+
providers: [
|
|
1980
|
+
{ provide: SI_LIVE_PREVIEW_CONFIG, useValue: config },
|
|
1981
|
+
{
|
|
1982
|
+
provide: SI_LIVE_PREVIEW_INTERNALS,
|
|
1983
|
+
useValue: { isMobile, titleBase: 'Overview - Live Preview' }
|
|
1984
|
+
}
|
|
1985
|
+
]
|
|
1986
|
+
};
|
|
1987
|
+
}
|
|
1988
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: SimplLivePreviewModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
1989
|
+
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.0.6", ngImport: i0, type: SimplLivePreviewModule, declarations: [SiExampleOverviewComponent,
|
|
1990
|
+
SiExampleViewerComponent,
|
|
1991
|
+
SiLivePreviewComponent,
|
|
1992
|
+
SiLivePreviewIframeComponent,
|
|
1993
|
+
SiLivePreviewQrComponent,
|
|
1994
|
+
SiLivePreviewRendererComponent,
|
|
1995
|
+
SiLivePreviewWrapperComponent], imports: [CommonModule, FormsModule, ReactiveFormsModule, RouterModule], exports: [SiExampleOverviewComponent, SiExampleViewerComponent] });
|
|
1996
|
+
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: SimplLivePreviewModule, providers: [{ provide: REMOVE_STYLES_ON_COMPONENT_DESTROY, useValue: true }], imports: [CommonModule, FormsModule, ReactiveFormsModule, RouterModule] });
|
|
1997
|
+
}
|
|
1998
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: SimplLivePreviewModule, decorators: [{
|
|
1999
|
+
type: NgModule,
|
|
2000
|
+
args: [{
|
|
2001
|
+
declarations: [
|
|
2002
|
+
SiExampleOverviewComponent,
|
|
2003
|
+
SiExampleViewerComponent,
|
|
2004
|
+
SiLivePreviewComponent,
|
|
2005
|
+
SiLivePreviewIframeComponent,
|
|
2006
|
+
SiLivePreviewQrComponent,
|
|
2007
|
+
SiLivePreviewRendererComponent,
|
|
2008
|
+
SiLivePreviewWrapperComponent
|
|
2009
|
+
],
|
|
2010
|
+
imports: [CommonModule, FormsModule, ReactiveFormsModule, RouterModule],
|
|
2011
|
+
exports: [SiExampleOverviewComponent, SiExampleViewerComponent],
|
|
2012
|
+
providers: [{ provide: REMOVE_STYLES_ON_COMPONENT_DESTROY, useValue: true }]
|
|
2013
|
+
}]
|
|
2014
|
+
}] });
|
|
2015
|
+
|
|
2016
|
+
/**
|
|
2017
|
+
* Copyright Siemens 2016 - 2025.
|
|
2018
|
+
* SPDX-License-Identifier: MIT
|
|
2019
|
+
*/
|
|
2020
|
+
// Public API Surface
|
|
2021
|
+
|
|
2022
|
+
/**
|
|
2023
|
+
* Generated bundle index. Do not edit.
|
|
2024
|
+
*/
|
|
2025
|
+
|
|
2026
|
+
export { DummyAppSampleComponent, LOG_EVENT, LandscapeSupportService, SI_LIVE_PREVIEW_CONFIG, SI_LIVE_PREVIEW_EXAMPLE_ROUTES, SI_LIVE_PREVIEW_INTERNALS, SiDummyComponent, SiExampleOverviewComponent, SiExampleViewerComponent, SiLivePreviewComponent, SiLivePreviewIframeComponent, SiLivePreviewLocaleApi, SiLivePreviewQrComponent, SiLivePreviewRendererComponent, SiLivePreviewThemeApi, SiLivePreviewWebComponentService, SiLivePreviewWrapperComponent, SimplLivePreviewModule, SimplLivePreviewRoutingModule, livePreviewRoutes, provideExampleRoutes };
|
|
2027
|
+
//# sourceMappingURL=siemens-live-preview.mjs.map
|