@sitecore-jss/sitecore-jss-angular 18.0.1 → 18.0.2
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/LICENSE.txt +202 -202
- package/README.md +5 -5
- package/dist/README.md +5 -5
- package/dist/components/date.directive.d.ts +0 -5
- package/dist/components/file.directive.d.ts +0 -5
- package/dist/components/generic-link.directive.d.ts +0 -5
- package/dist/components/image.directive.d.ts +0 -5
- package/dist/components/link.directive.d.ts +0 -5
- package/dist/components/missing-component.component.d.ts +0 -5
- package/dist/components/placeholder-loading.directive.d.ts +0 -5
- package/dist/components/placeholder.component.d.ts +0 -5
- package/dist/components/raw.component.d.ts +0 -5
- package/dist/components/render-component.component.d.ts +0 -5
- package/dist/components/render-each.directive.d.ts +0 -5
- package/dist/components/render-empty.directive.d.ts +0 -5
- package/dist/components/rich-text.directive.d.ts +0 -5
- package/dist/components/router-link.directive.d.ts +0 -5
- package/dist/components/text.directive.d.ts +0 -5
- package/dist/jss-component-factory.service.d.ts +0 -5
- package/dist/layout.service.d.ts +0 -5
- package/dist/lib.module.d.ts +0 -22
- package/dist/package.json +7 -16
- package/dist/sitecore-jss-sitecore-jss-angular.d.ts +0 -2
- package/package.json +3 -3
- package/typings/README.md +2 -2
- package/dist/__ivy_ngcc__/fesm2015/sitecore-jss-sitecore-jss-angular.js +0 -1391
- package/dist/__ivy_ngcc__/fesm2015/sitecore-jss-sitecore-jss-angular.js.map +0 -1
- package/dist/components/date.directive.d.ts.__ivy_ngcc_bak +0 -17
- package/dist/components/date.directive.d.ts.map +0 -1
- package/dist/components/file.directive.d.ts.__ivy_ngcc_bak +0 -14
- package/dist/components/file.directive.d.ts.map +0 -1
- package/dist/components/generic-link.directive.d.ts.__ivy_ngcc_bak +0 -14
- package/dist/components/generic-link.directive.d.ts.map +0 -1
- package/dist/components/image.directive.d.ts.__ivy_ngcc_bak +0 -28
- package/dist/components/image.directive.d.ts.map +0 -1
- package/dist/components/link.directive.d.ts.__ivy_ngcc_bak +0 -18
- package/dist/components/link.directive.d.ts.map +0 -1
- package/dist/components/missing-component.component.d.ts.__ivy_ngcc_bak +0 -3
- package/dist/components/missing-component.component.d.ts.map +0 -1
- package/dist/components/placeholder-loading.directive.d.ts.__ivy_ngcc_bak +0 -5
- package/dist/components/placeholder-loading.directive.d.ts.map +0 -1
- package/dist/components/placeholder.component.d.ts.__ivy_ngcc_bak +0 -45
- package/dist/components/placeholder.component.d.ts.map +0 -1
- package/dist/components/raw.component.d.ts.__ivy_ngcc_bak +0 -9
- package/dist/components/raw.component.d.ts.map +0 -1
- package/dist/components/render-component.component.d.ts.__ivy_ngcc_bak +0 -29
- package/dist/components/render-component.component.d.ts.map +0 -1
- package/dist/components/render-each.directive.d.ts.__ivy_ngcc_bak +0 -5
- package/dist/components/render-each.directive.d.ts.map +0 -1
- package/dist/components/render-empty.directive.d.ts.__ivy_ngcc_bak +0 -5
- package/dist/components/render-empty.directive.d.ts.map +0 -1
- package/dist/components/rich-text.directive.d.ts.__ivy_ngcc_bak +0 -12
- package/dist/components/rich-text.directive.d.ts.map +0 -1
- package/dist/components/router-link.directive.d.ts.__ivy_ngcc_bak +0 -12
- package/dist/components/router-link.directive.d.ts.map +0 -1
- package/dist/components/text.directive.d.ts.__ivy_ngcc_bak +0 -13
- package/dist/components/text.directive.d.ts.map +0 -1
- package/dist/jss-component-factory.service.d.ts.__ivy_ngcc_bak +0 -21
- package/dist/jss-component-factory.service.d.ts.map +0 -1
- package/dist/layout.service.d.ts.__ivy_ngcc_bak +0 -8
- package/dist/layout.service.d.ts.map +0 -1
- package/dist/lib.module.d.ts.__ivy_ngcc_bak +0 -24
- package/dist/lib.module.d.ts.map +0 -1
- package/dist/sitecore-jss-sitecore-jss-angular.d.ts.__ivy_ngcc_bak +0 -12
- package/dist/sitecore-jss-sitecore-jss-angular.d.ts.map +0 -1
|
@@ -1,1391 +0,0 @@
|
|
|
1
|
-
import { Directive, ViewContainerRef, TemplateRef, Input, Renderer2, ElementRef, InjectionToken, Component, NgModuleFactory, Injectable, Injector, Compiler, Inject, EventEmitter, ComponentFactoryResolver, KeyValueDiffers, ChangeDetectorRef, Type, Output, ViewChild, ContentChild, ANALYZE_FOR_ENTRY_COMPONENTS, NgModule } from '@angular/core';
|
|
2
|
-
import { __rest } from 'tslib';
|
|
3
|
-
import { mediaApi, dataApi, isExperienceEditorActive } from '@sitecore-jss/sitecore-jss';
|
|
4
|
-
import * as ɵngcc0 from '@angular/core';
|
|
5
|
-
import * as ɵngcc1 from '@angular/router';
|
|
6
|
-
import * as ɵngcc2 from '@angular/common';
|
|
7
|
-
|
|
8
|
-
const _c0 = ["view"];
|
|
9
|
-
function PlaceholderComponent_0_ng_template_0_Template(rf, ctx) { }
|
|
10
|
-
function PlaceholderComponent_0_Template(rf, ctx) { if (rf & 1) {
|
|
11
|
-
ɵngcc0.ɵɵtemplate(0, PlaceholderComponent_0_ng_template_0_Template, 0, 0, "ng-template", 2);
|
|
12
|
-
} if (rf & 2) {
|
|
13
|
-
const ctx_r0 = ɵngcc0.ɵɵnextContext();
|
|
14
|
-
ɵngcc0.ɵɵproperty("ngTemplateOutlet", ctx_r0.placeholderLoading == null ? null : ctx_r0.placeholderLoading.templateRef);
|
|
15
|
-
} }
|
|
16
|
-
function PlaceholderComponent_ng_template_1_Template(rf, ctx) { }
|
|
17
|
-
function RenderComponentComponent_ng_template_0_Template(rf, ctx) { }
|
|
18
|
-
export { dataApi, getChildPlaceholder, getFieldValue, isExperienceEditorActive, isServer, mediaApi, resetExperienceEditorChromes } from '@sitecore-jss/sitecore-jss';
|
|
19
|
-
import { Router, ROUTES } from '@angular/router';
|
|
20
|
-
import { Observable, throwError, from } from 'rxjs';
|
|
21
|
-
import { takeWhile, catchError } from 'rxjs/operators';
|
|
22
|
-
import { DatePipe, CommonModule } from '@angular/common';
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* File fields cannot be managed via the EE. We never output "editable."
|
|
26
|
-
*/
|
|
27
|
-
class FileDirective {
|
|
28
|
-
constructor(viewContainer, templateRef) {
|
|
29
|
-
this.viewContainer = viewContainer;
|
|
30
|
-
this.templateRef = templateRef;
|
|
31
|
-
}
|
|
32
|
-
ngOnChanges(changes) {
|
|
33
|
-
if (changes.field) {
|
|
34
|
-
if (!this.viewRef) {
|
|
35
|
-
this.viewContainer.clear();
|
|
36
|
-
this.viewRef = this.viewContainer.createEmbeddedView(this.templateRef);
|
|
37
|
-
}
|
|
38
|
-
this.updateView();
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
updateView() {
|
|
42
|
-
const field = this.field;
|
|
43
|
-
if (!field || (!field.value && !field.src)) {
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
const file = field.src ? field : field.value;
|
|
47
|
-
this.viewRef.rootNodes.forEach((node) => {
|
|
48
|
-
node.href = file.src;
|
|
49
|
-
if (node.innerHTML === '') {
|
|
50
|
-
node.innerHTML = file.title || file.displayName;
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
FileDirective.ɵfac = function FileDirective_Factory(t) { return new (t || FileDirective)(ɵngcc0.ɵɵdirectiveInject(ɵngcc0.ViewContainerRef), ɵngcc0.ɵɵdirectiveInject(ɵngcc0.TemplateRef)); };
|
|
56
|
-
FileDirective.ɵdir = ɵngcc0.ɵɵdefineDirective({ type: FileDirective, selectors: [["", "scFile", ""]], inputs: { field: ["scFile", "field"] }, features: [ɵngcc0.ɵɵNgOnChangesFeature] });
|
|
57
|
-
FileDirective.ctorParameters = () => [
|
|
58
|
-
{ type: ViewContainerRef },
|
|
59
|
-
{ type: TemplateRef }
|
|
60
|
-
];
|
|
61
|
-
FileDirective.propDecorators = {
|
|
62
|
-
field: [{ type: Input, args: ['scFile',] }]
|
|
63
|
-
};
|
|
64
|
-
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && ɵngcc0.ɵsetClassMetadata(FileDirective, [{
|
|
65
|
-
type: Directive,
|
|
66
|
-
args: [{ selector: '[scFile]' }]
|
|
67
|
-
}], function () { return [{ type: ɵngcc0.ViewContainerRef }, { type: ɵngcc0.TemplateRef }]; }, { field: [{
|
|
68
|
-
type: Input,
|
|
69
|
-
args: ['scFile']
|
|
70
|
-
}] }); })();
|
|
71
|
-
|
|
72
|
-
class ImageDirective {
|
|
73
|
-
constructor(viewContainer, templateRef, renderer, elementRef) {
|
|
74
|
-
this.viewContainer = viewContainer;
|
|
75
|
-
this.templateRef = templateRef;
|
|
76
|
-
this.renderer = renderer;
|
|
77
|
-
this.elementRef = elementRef;
|
|
78
|
-
this.inlineRef = null;
|
|
79
|
-
this.editable = true;
|
|
80
|
-
this.urlParams = {};
|
|
81
|
-
this.attrs = {};
|
|
82
|
-
}
|
|
83
|
-
ngOnChanges(changes) {
|
|
84
|
-
if (changes.field || changes.editable || changes.urlParams || changes.attrs) {
|
|
85
|
-
this.viewContainer.clear();
|
|
86
|
-
if (this.inlineRef) {
|
|
87
|
-
this.inlineRef.remove();
|
|
88
|
-
this.inlineRef = null;
|
|
89
|
-
}
|
|
90
|
-
this.updateView();
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
updateView() {
|
|
94
|
-
const overrideAttrs = Object.assign(Object.assign({}, this.getElementAttrs()), this.attrs);
|
|
95
|
-
const media = this.field;
|
|
96
|
-
if (!media || (!media.editable && !media.value && !media.src)) {
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
let attrs = {};
|
|
100
|
-
// we likely have an experience editor value, should be a string
|
|
101
|
-
if (this.editable && media.editable) {
|
|
102
|
-
const foundImg = mediaApi.findEditorImageTag(media.editable);
|
|
103
|
-
if (!foundImg) {
|
|
104
|
-
return this.renderInlineWrapper(media.editable);
|
|
105
|
-
}
|
|
106
|
-
attrs = this.getImageAttrs(foundImg.attrs, overrideAttrs, this.urlParams);
|
|
107
|
-
if (!attrs) {
|
|
108
|
-
return this.renderInlineWrapper(media.editable);
|
|
109
|
-
}
|
|
110
|
-
const tempImg = this.renderer.createElement('img');
|
|
111
|
-
Object.entries(attrs).forEach(([key, attrValue]) => tempImg.setAttribute(key, attrValue));
|
|
112
|
-
const editableMarkup = media.editable.replace(foundImg.imgTag, tempImg.outerHTML);
|
|
113
|
-
return this.renderInlineWrapper(editableMarkup);
|
|
114
|
-
}
|
|
115
|
-
// some wise-guy/gal is passing in a 'raw' image object value
|
|
116
|
-
const img = media.src ? media : media.value;
|
|
117
|
-
if (!img) {
|
|
118
|
-
return null;
|
|
119
|
-
}
|
|
120
|
-
attrs = this.getImageAttrs(img, overrideAttrs, this.urlParams);
|
|
121
|
-
if (attrs) {
|
|
122
|
-
this.renderTemplate(attrs);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
getImageAttrs(fieldAttrs, parsedAttrs, imageParams) {
|
|
126
|
-
const combinedAttrs = Object.assign(Object.assign({}, fieldAttrs), parsedAttrs);
|
|
127
|
-
// eslint-disable-next-line prefer-const
|
|
128
|
-
let { src, srcSet } = combinedAttrs, otherAttrs = __rest(combinedAttrs, ["src", "srcSet"]);
|
|
129
|
-
if (!src) {
|
|
130
|
-
return null;
|
|
131
|
-
}
|
|
132
|
-
const newAttrs = Object.assign({}, otherAttrs);
|
|
133
|
-
// update image URL for jss handler and image rendering params
|
|
134
|
-
src = mediaApi.updateImageUrl(src, imageParams, this.mediaUrlPrefix);
|
|
135
|
-
if (srcSet) {
|
|
136
|
-
// replace with HTML-formatted srcset, including updated image URLs
|
|
137
|
-
newAttrs.srcSet = mediaApi.getSrcSet(src, srcSet, imageParams, this.mediaUrlPrefix);
|
|
138
|
-
}
|
|
139
|
-
else {
|
|
140
|
-
newAttrs.src = src;
|
|
141
|
-
}
|
|
142
|
-
return newAttrs;
|
|
143
|
-
}
|
|
144
|
-
renderTemplate(imageProps) {
|
|
145
|
-
const viewRef = this.viewContainer.createEmbeddedView(this.templateRef);
|
|
146
|
-
viewRef.rootNodes.forEach((node) => {
|
|
147
|
-
Object.entries(imageProps).forEach(([key, imgPropVal]) => this.renderer.setAttribute(node, key, imgPropVal));
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
getElementAttrs() {
|
|
151
|
-
const view = this.templateRef.createEmbeddedView(null);
|
|
152
|
-
const element = view.rootNodes[0];
|
|
153
|
-
if (!element) {
|
|
154
|
-
return {};
|
|
155
|
-
}
|
|
156
|
-
const attrs = {};
|
|
157
|
-
for (let i = 0; i < element.attributes.length; i++) {
|
|
158
|
-
const attr = element.attributes.item(i);
|
|
159
|
-
if (attr) {
|
|
160
|
-
attrs[attr.name] = attr.value;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
return attrs;
|
|
164
|
-
}
|
|
165
|
-
renderInlineWrapper(editable) {
|
|
166
|
-
const span = this.renderer.createElement('span');
|
|
167
|
-
span.className = 'sc-image-wrapper';
|
|
168
|
-
span.innerHTML = editable;
|
|
169
|
-
const parentNode = this.renderer.parentNode(this.elementRef.nativeElement);
|
|
170
|
-
this.renderer.insertBefore(parentNode, span, this.elementRef.nativeElement);
|
|
171
|
-
parentNode.removeChild(this.elementRef.nativeElement);
|
|
172
|
-
this.inlineRef = span;
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
ImageDirective.ɵfac = function ImageDirective_Factory(t) { return new (t || ImageDirective)(ɵngcc0.ɵɵdirectiveInject(ɵngcc0.ViewContainerRef), ɵngcc0.ɵɵdirectiveInject(ɵngcc0.TemplateRef), ɵngcc0.ɵɵdirectiveInject(ɵngcc0.Renderer2), ɵngcc0.ɵɵdirectiveInject(ɵngcc0.ElementRef)); };
|
|
176
|
-
ImageDirective.ɵdir = ɵngcc0.ɵɵdefineDirective({ type: ImageDirective, selectors: [["", "scImage", ""]], inputs: { editable: ["scImageEditable", "editable"], urlParams: ["scImageUrlParams", "urlParams"], attrs: ["scImageAttrs", "attrs"], field: ["scImage", "field"], mediaUrlPrefix: ["scImageMediaUrlPrefix", "mediaUrlPrefix"] }, features: [ɵngcc0.ɵɵNgOnChangesFeature] });
|
|
177
|
-
ImageDirective.ctorParameters = () => [
|
|
178
|
-
{ type: ViewContainerRef },
|
|
179
|
-
{ type: TemplateRef },
|
|
180
|
-
{ type: Renderer2 },
|
|
181
|
-
{ type: ElementRef }
|
|
182
|
-
];
|
|
183
|
-
ImageDirective.propDecorators = {
|
|
184
|
-
field: [{ type: Input, args: ['scImage',] }],
|
|
185
|
-
editable: [{ type: Input, args: ['scImageEditable',] }],
|
|
186
|
-
mediaUrlPrefix: [{ type: Input, args: ['scImageMediaUrlPrefix',] }],
|
|
187
|
-
urlParams: [{ type: Input, args: ['scImageUrlParams',] }],
|
|
188
|
-
attrs: [{ type: Input, args: ['scImageAttrs',] }]
|
|
189
|
-
};
|
|
190
|
-
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && ɵngcc0.ɵsetClassMetadata(ImageDirective, [{
|
|
191
|
-
type: Directive,
|
|
192
|
-
args: [{ selector: '[scImage]' }]
|
|
193
|
-
}], function () { return [{ type: ɵngcc0.ViewContainerRef }, { type: ɵngcc0.TemplateRef }, { type: ɵngcc0.Renderer2 }, { type: ɵngcc0.ElementRef }]; }, { editable: [{
|
|
194
|
-
type: Input,
|
|
195
|
-
args: ['scImageEditable']
|
|
196
|
-
}], urlParams: [{
|
|
197
|
-
type: Input,
|
|
198
|
-
args: ['scImageUrlParams']
|
|
199
|
-
}], attrs: [{
|
|
200
|
-
type: Input,
|
|
201
|
-
args: ['scImageAttrs']
|
|
202
|
-
}], field: [{
|
|
203
|
-
type: Input,
|
|
204
|
-
args: ['scImage']
|
|
205
|
-
}], mediaUrlPrefix: [{
|
|
206
|
-
type: Input,
|
|
207
|
-
args: ['scImageMediaUrlPrefix']
|
|
208
|
-
}] }); })();
|
|
209
|
-
|
|
210
|
-
class LinkDirective {
|
|
211
|
-
constructor(viewContainer, templateRef, renderer, elementRef) {
|
|
212
|
-
this.viewContainer = viewContainer;
|
|
213
|
-
this.templateRef = templateRef;
|
|
214
|
-
this.renderer = renderer;
|
|
215
|
-
this.elementRef = elementRef;
|
|
216
|
-
this.inlineRef = null;
|
|
217
|
-
this.editable = true;
|
|
218
|
-
this.attrs = {};
|
|
219
|
-
}
|
|
220
|
-
ngOnChanges(changes) {
|
|
221
|
-
if (changes.field || changes.editable || changes.attrs) {
|
|
222
|
-
this.viewContainer.clear();
|
|
223
|
-
if (this.inlineRef) {
|
|
224
|
-
this.inlineRef.remove();
|
|
225
|
-
this.inlineRef = null;
|
|
226
|
-
}
|
|
227
|
-
this.updateView();
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
updateView() {
|
|
231
|
-
const field = this.field;
|
|
232
|
-
if (this.editable && field && field.editableFirstPart && field.editableLastPart) {
|
|
233
|
-
this.renderInlineWrapper(field.editableFirstPart, field.editableLastPart);
|
|
234
|
-
}
|
|
235
|
-
else if (field && (field.href || field.value)) {
|
|
236
|
-
const props = field.href ? field : field.value;
|
|
237
|
-
const linkText = field.text || field.value.text || field.href || field.value.href;
|
|
238
|
-
const mergedAttrs = Object.assign(Object.assign({}, props), this.attrs);
|
|
239
|
-
this.renderTemplate(mergedAttrs, linkText);
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
renderTemplate(props, linkText) {
|
|
243
|
-
const viewRef = this.viewContainer.createEmbeddedView(this.templateRef);
|
|
244
|
-
viewRef.rootNodes.forEach((node) => {
|
|
245
|
-
Object.entries(props).forEach(([key, propValue]) => {
|
|
246
|
-
if (key === 'href') {
|
|
247
|
-
const isInvalidLink = !propValue || /^https?:\/\/$/.test(propValue);
|
|
248
|
-
if (isInvalidLink) {
|
|
249
|
-
if (!node.href) {
|
|
250
|
-
return;
|
|
251
|
-
}
|
|
252
|
-
propValue = node.href;
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
if (key === 'class' && node.className) {
|
|
256
|
-
propValue += ` ${node.className}`;
|
|
257
|
-
}
|
|
258
|
-
this.renderer.setAttribute(node, key, propValue);
|
|
259
|
-
});
|
|
260
|
-
if (node.childNodes && node.childNodes.length === 0 && linkText) {
|
|
261
|
-
node.textContent = linkText;
|
|
262
|
-
}
|
|
263
|
-
});
|
|
264
|
-
}
|
|
265
|
-
renderInlineWrapper(editableFirstPart, editableLastPart) {
|
|
266
|
-
const span = this.renderer.createElement('span');
|
|
267
|
-
span.className = 'sc-link-wrapper';
|
|
268
|
-
span.innerHTML = editableFirstPart + editableLastPart;
|
|
269
|
-
// assign attributes from template to inline wrapper
|
|
270
|
-
const attrs = Object.assign(Object.assign({}, this.getElementAttrs()), this.attrs);
|
|
271
|
-
Object.entries(attrs).forEach(([key, attrValue]) => this.renderer.setAttribute(span, key, attrValue));
|
|
272
|
-
this.viewContainer.createEmbeddedView(this.templateRef);
|
|
273
|
-
const parentNode = this.renderer.parentNode(this.elementRef.nativeElement);
|
|
274
|
-
this.renderer.insertBefore(parentNode, span, this.elementRef.nativeElement);
|
|
275
|
-
this.inlineRef = span;
|
|
276
|
-
}
|
|
277
|
-
getElementAttrs() {
|
|
278
|
-
const view = this.templateRef.createEmbeddedView(null);
|
|
279
|
-
const element = view.rootNodes[0];
|
|
280
|
-
if (!element) {
|
|
281
|
-
return {};
|
|
282
|
-
}
|
|
283
|
-
const attrs = {};
|
|
284
|
-
for (let i = 0; i < element.attributes.length; i++) {
|
|
285
|
-
const attr = element.attributes.item(i);
|
|
286
|
-
if (attr) {
|
|
287
|
-
attrs[attr.name] = attr.value;
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
return attrs;
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
LinkDirective.ɵfac = function LinkDirective_Factory(t) { return new (t || LinkDirective)(ɵngcc0.ɵɵdirectiveInject(ɵngcc0.ViewContainerRef), ɵngcc0.ɵɵdirectiveInject(ɵngcc0.TemplateRef), ɵngcc0.ɵɵdirectiveInject(ɵngcc0.Renderer2), ɵngcc0.ɵɵdirectiveInject(ɵngcc0.ElementRef)); };
|
|
294
|
-
LinkDirective.ɵdir = ɵngcc0.ɵɵdefineDirective({ type: LinkDirective, selectors: [["", "scLink", ""]], inputs: { editable: ["scLinkEditable", "editable"], attrs: ["scLinkAttrs", "attrs"], field: ["scLink", "field"] }, features: [ɵngcc0.ɵɵNgOnChangesFeature] });
|
|
295
|
-
LinkDirective.ctorParameters = () => [
|
|
296
|
-
{ type: ViewContainerRef },
|
|
297
|
-
{ type: TemplateRef },
|
|
298
|
-
{ type: Renderer2 },
|
|
299
|
-
{ type: ElementRef }
|
|
300
|
-
];
|
|
301
|
-
LinkDirective.propDecorators = {
|
|
302
|
-
editable: [{ type: Input, args: ['scLinkEditable',] }],
|
|
303
|
-
attrs: [{ type: Input, args: ['scLinkAttrs',] }],
|
|
304
|
-
field: [{ type: Input, args: ['scLink',] }]
|
|
305
|
-
};
|
|
306
|
-
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && ɵngcc0.ɵsetClassMetadata(LinkDirective, [{
|
|
307
|
-
type: Directive,
|
|
308
|
-
args: [{ selector: '[scLink]' }]
|
|
309
|
-
}], function () { return [{ type: ɵngcc0.ViewContainerRef }, { type: ɵngcc0.TemplateRef }, { type: ɵngcc0.Renderer2 }, { type: ɵngcc0.ElementRef }]; }, { editable: [{
|
|
310
|
-
type: Input,
|
|
311
|
-
args: ['scLinkEditable']
|
|
312
|
-
}], attrs: [{
|
|
313
|
-
type: Input,
|
|
314
|
-
args: ['scLinkAttrs']
|
|
315
|
-
}], field: [{
|
|
316
|
-
type: Input,
|
|
317
|
-
args: ['scLink']
|
|
318
|
-
}] }); })();
|
|
319
|
-
|
|
320
|
-
class RouterLinkDirective extends LinkDirective {
|
|
321
|
-
constructor(viewContainer, templateRef, renderer, elementRef, router) {
|
|
322
|
-
super(viewContainer, templateRef, renderer, elementRef);
|
|
323
|
-
this.router = router;
|
|
324
|
-
this.editable = true;
|
|
325
|
-
this.attrs = {};
|
|
326
|
-
}
|
|
327
|
-
renderTemplate(props, linkText) {
|
|
328
|
-
const viewRef = this.viewContainer.createEmbeddedView(this.templateRef);
|
|
329
|
-
viewRef.rootNodes.forEach((node) => {
|
|
330
|
-
Object.entries(props).forEach(([key, propValue]) => {
|
|
331
|
-
this.renderer.setAttribute(node, key, propValue);
|
|
332
|
-
if (key === 'href') {
|
|
333
|
-
this.renderer.listen(node, 'click', (event) => {
|
|
334
|
-
this.router.navigate([propValue]);
|
|
335
|
-
event.preventDefault();
|
|
336
|
-
});
|
|
337
|
-
}
|
|
338
|
-
});
|
|
339
|
-
if (node.childNodes && node.childNodes.length === 0 && linkText) {
|
|
340
|
-
node.textContent = linkText;
|
|
341
|
-
}
|
|
342
|
-
});
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
RouterLinkDirective.ɵfac = function RouterLinkDirective_Factory(t) { return new (t || RouterLinkDirective)(ɵngcc0.ɵɵdirectiveInject(ɵngcc0.ViewContainerRef), ɵngcc0.ɵɵdirectiveInject(ɵngcc0.TemplateRef), ɵngcc0.ɵɵdirectiveInject(ɵngcc0.Renderer2), ɵngcc0.ɵɵdirectiveInject(ɵngcc0.ElementRef), ɵngcc0.ɵɵdirectiveInject(ɵngcc1.Router)); };
|
|
346
|
-
RouterLinkDirective.ɵdir = ɵngcc0.ɵɵdefineDirective({ type: RouterLinkDirective, selectors: [["", "scRouterLink", ""]], inputs: { editable: ["scRouterLinkEditable", "editable"], attrs: ["scRouterLinkAttrs", "attrs"], field: ["scRouterLink", "field"] }, features: [ɵngcc0.ɵɵInheritDefinitionFeature] });
|
|
347
|
-
RouterLinkDirective.ctorParameters = () => [
|
|
348
|
-
{ type: ViewContainerRef },
|
|
349
|
-
{ type: TemplateRef },
|
|
350
|
-
{ type: Renderer2 },
|
|
351
|
-
{ type: ElementRef },
|
|
352
|
-
{ type: Router }
|
|
353
|
-
];
|
|
354
|
-
RouterLinkDirective.propDecorators = {
|
|
355
|
-
editable: [{ type: Input, args: ['scRouterLinkEditable',] }],
|
|
356
|
-
attrs: [{ type: Input, args: ['scRouterLinkAttrs',] }],
|
|
357
|
-
field: [{ type: Input, args: ['scRouterLink',] }]
|
|
358
|
-
};
|
|
359
|
-
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && ɵngcc0.ɵsetClassMetadata(RouterLinkDirective, [{
|
|
360
|
-
type: Directive,
|
|
361
|
-
args: [{ selector: '[scRouterLink]' }]
|
|
362
|
-
}], function () { return [{ type: ɵngcc0.ViewContainerRef }, { type: ɵngcc0.TemplateRef }, { type: ɵngcc0.Renderer2 }, { type: ɵngcc0.ElementRef }, { type: ɵngcc1.Router }]; }, { editable: [{
|
|
363
|
-
type: Input,
|
|
364
|
-
args: ['scRouterLinkEditable']
|
|
365
|
-
}], attrs: [{
|
|
366
|
-
type: Input,
|
|
367
|
-
args: ['scRouterLinkAttrs']
|
|
368
|
-
}], field: [{
|
|
369
|
-
type: Input,
|
|
370
|
-
args: ['scRouterLink']
|
|
371
|
-
}] }); })();
|
|
372
|
-
|
|
373
|
-
class GenericLinkDirective extends LinkDirective {
|
|
374
|
-
constructor(viewContainer, templateRef, renderer, elementRef, router) {
|
|
375
|
-
super(viewContainer, templateRef, renderer, elementRef);
|
|
376
|
-
this.router = router;
|
|
377
|
-
this.editable = true;
|
|
378
|
-
this.attrs = {};
|
|
379
|
-
}
|
|
380
|
-
renderTemplate(props, linkText) {
|
|
381
|
-
const viewRef = this.viewContainer.createEmbeddedView(this.templateRef);
|
|
382
|
-
viewRef.rootNodes.forEach((node) => {
|
|
383
|
-
Object.entries(props).forEach(([key, propValue]) => {
|
|
384
|
-
if (key === 'href' && !this.isAbsoluteUrl(propValue)) {
|
|
385
|
-
const urlTree = this.router.createUrlTree([propValue], this.extras);
|
|
386
|
-
this.renderer.setAttribute(node, key, this.router.serializeUrl(urlTree));
|
|
387
|
-
this.renderer.listen(node, 'click', (event) => {
|
|
388
|
-
this.router.navigate([propValue], this.extras);
|
|
389
|
-
event.preventDefault();
|
|
390
|
-
});
|
|
391
|
-
}
|
|
392
|
-
else {
|
|
393
|
-
this.renderer.setAttribute(node, key, propValue);
|
|
394
|
-
}
|
|
395
|
-
});
|
|
396
|
-
if (node.childNodes && node.childNodes.length === 0 && linkText) {
|
|
397
|
-
node.textContent = linkText;
|
|
398
|
-
}
|
|
399
|
-
});
|
|
400
|
-
}
|
|
401
|
-
isAbsoluteUrl(url) {
|
|
402
|
-
if (url === null) {
|
|
403
|
-
return false;
|
|
404
|
-
}
|
|
405
|
-
if (typeof url !== 'string') {
|
|
406
|
-
throw new TypeError('Expected a string');
|
|
407
|
-
}
|
|
408
|
-
return /^[a-z][a-z0-9+.-]*:/.test(url);
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
GenericLinkDirective.ɵfac = function GenericLinkDirective_Factory(t) { return new (t || GenericLinkDirective)(ɵngcc0.ɵɵdirectiveInject(ɵngcc0.ViewContainerRef), ɵngcc0.ɵɵdirectiveInject(ɵngcc0.TemplateRef), ɵngcc0.ɵɵdirectiveInject(ɵngcc0.Renderer2), ɵngcc0.ɵɵdirectiveInject(ɵngcc0.ElementRef), ɵngcc0.ɵɵdirectiveInject(ɵngcc1.Router)); };
|
|
412
|
-
GenericLinkDirective.ɵdir = ɵngcc0.ɵɵdefineDirective({ type: GenericLinkDirective, selectors: [["", "scGenericLink", ""]], inputs: { editable: ["scGenericLinkEditable", "editable"], attrs: ["scGenericLinkAttrs", "attrs"], field: ["scGenericLink", "field"], extras: ["scGenericLinkExtras", "extras"] }, features: [ɵngcc0.ɵɵInheritDefinitionFeature] });
|
|
413
|
-
GenericLinkDirective.ctorParameters = () => [
|
|
414
|
-
{ type: ViewContainerRef },
|
|
415
|
-
{ type: TemplateRef },
|
|
416
|
-
{ type: Renderer2 },
|
|
417
|
-
{ type: ElementRef },
|
|
418
|
-
{ type: Router }
|
|
419
|
-
];
|
|
420
|
-
GenericLinkDirective.propDecorators = {
|
|
421
|
-
editable: [{ type: Input, args: ['scGenericLinkEditable',] }],
|
|
422
|
-
attrs: [{ type: Input, args: ['scGenericLinkAttrs',] }],
|
|
423
|
-
field: [{ type: Input, args: ['scGenericLink',] }],
|
|
424
|
-
extras: [{ type: Input, args: ['scGenericLinkExtras',] }]
|
|
425
|
-
};
|
|
426
|
-
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && ɵngcc0.ɵsetClassMetadata(GenericLinkDirective, [{
|
|
427
|
-
type: Directive,
|
|
428
|
-
args: [{ selector: '[scGenericLink]' }]
|
|
429
|
-
}], function () { return [{ type: ɵngcc0.ViewContainerRef }, { type: ɵngcc0.TemplateRef }, { type: ɵngcc0.Renderer2 }, { type: ɵngcc0.ElementRef }, { type: ɵngcc1.Router }]; }, { editable: [{
|
|
430
|
-
type: Input,
|
|
431
|
-
args: ['scGenericLinkEditable']
|
|
432
|
-
}], attrs: [{
|
|
433
|
-
type: Input,
|
|
434
|
-
args: ['scGenericLinkAttrs']
|
|
435
|
-
}], field: [{
|
|
436
|
-
type: Input,
|
|
437
|
-
args: ['scGenericLink']
|
|
438
|
-
}], extras: [{
|
|
439
|
-
type: Input,
|
|
440
|
-
args: ['scGenericLinkExtras']
|
|
441
|
-
}] }); })();
|
|
442
|
-
|
|
443
|
-
/** Registers a statically loaded component */
|
|
444
|
-
class ComponentNameAndType {
|
|
445
|
-
}
|
|
446
|
-
/**
|
|
447
|
-
* @param {any} object
|
|
448
|
-
*/
|
|
449
|
-
function instanceOfComponentNameAndType(object) {
|
|
450
|
-
return 'type' in object;
|
|
451
|
-
}
|
|
452
|
-
/**
|
|
453
|
-
* @param {any} object
|
|
454
|
-
*/
|
|
455
|
-
function instanceOfComponentNameAndModule(object) {
|
|
456
|
-
return 'module' in object;
|
|
457
|
-
}
|
|
458
|
-
const PLACEHOLDER_COMPONENTS = new InjectionToken('Sc.placeholder.components');
|
|
459
|
-
const PLACEHOLDER_LAZY_COMPONENTS = new InjectionToken('Sc.placeholder.lazyComponents');
|
|
460
|
-
const PLACEHOLDER_MISSING_COMPONENT_COMPONENT = new InjectionToken('Sc.placeholder.missingComponentComponent');
|
|
461
|
-
const DYNAMIC_COMPONENT = new InjectionToken('Sc.placeholder.dynamicComponent');
|
|
462
|
-
|
|
463
|
-
class RawComponent {
|
|
464
|
-
constructor(renderer, elementRef) {
|
|
465
|
-
this.renderer = renderer;
|
|
466
|
-
this.elementRef = elementRef;
|
|
467
|
-
}
|
|
468
|
-
ngOnInit() {
|
|
469
|
-
const el = this.renderer.createElement(this.rendering.name);
|
|
470
|
-
const contents = this.renderer.createText(this.rendering.contents || '');
|
|
471
|
-
const attributes = this.rendering.attributes;
|
|
472
|
-
for (const attr in attributes) {
|
|
473
|
-
// eslint-disable-next-line no-prototype-builtins
|
|
474
|
-
if (attributes.hasOwnProperty(attr)) {
|
|
475
|
-
const value = attributes[attr];
|
|
476
|
-
this.renderer.setAttribute(el, attr, value || '');
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
this.renderer.appendChild(el, contents);
|
|
480
|
-
const parentNode = this.renderer.parentNode(this.elementRef.nativeElement);
|
|
481
|
-
this.renderer.insertBefore(parentNode, el, this.elementRef.nativeElement);
|
|
482
|
-
parentNode.removeChild(this.elementRef.nativeElement);
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
RawComponent.ɵfac = function RawComponent_Factory(t) { return new (t || RawComponent)(ɵngcc0.ɵɵdirectiveInject(ɵngcc0.Renderer2), ɵngcc0.ɵɵdirectiveInject(ɵngcc0.ElementRef)); };
|
|
486
|
-
RawComponent.ɵcmp = ɵngcc0.ɵɵdefineComponent({ type: RawComponent, selectors: [["sc-raw"]], inputs: { rendering: "rendering" }, decls: 0, vars: 0, template: function RawComponent_Template(rf, ctx) { }, encapsulation: 2 });
|
|
487
|
-
RawComponent.ctorParameters = () => [
|
|
488
|
-
{ type: Renderer2 },
|
|
489
|
-
{ type: ElementRef }
|
|
490
|
-
];
|
|
491
|
-
RawComponent.propDecorators = {
|
|
492
|
-
rendering: [{ type: Input }]
|
|
493
|
-
};
|
|
494
|
-
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && ɵngcc0.ɵsetClassMetadata(RawComponent, [{
|
|
495
|
-
type: Component,
|
|
496
|
-
args: [{
|
|
497
|
-
selector: 'sc-raw',
|
|
498
|
-
template: ''
|
|
499
|
-
}]
|
|
500
|
-
}], function () { return [{ type: ɵngcc0.Renderer2 }, { type: ɵngcc0.ElementRef }]; }, { rendering: [{
|
|
501
|
-
type: Input
|
|
502
|
-
}] }); })();
|
|
503
|
-
|
|
504
|
-
/**
|
|
505
|
-
* @param {HtmlElementRendering | ComponentRendering} rendering
|
|
506
|
-
*/
|
|
507
|
-
function isRawRendering(rendering) {
|
|
508
|
-
return (!rendering.componentName &&
|
|
509
|
-
rendering.name !== undefined);
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
class JssComponentFactoryService {
|
|
513
|
-
constructor(injector, compiler, components, lazyComponents) {
|
|
514
|
-
this.injector = injector;
|
|
515
|
-
this.compiler = compiler;
|
|
516
|
-
this.components = components;
|
|
517
|
-
this.lazyComponents = lazyComponents;
|
|
518
|
-
this.componentMap = new Map();
|
|
519
|
-
this.lazyComponentMap = new Map();
|
|
520
|
-
this.components.forEach((c) => this.componentMap.set(c.name, c.type));
|
|
521
|
-
if (this.lazyComponents) {
|
|
522
|
-
this.lazyComponents.forEach((c) => this.lazyComponentMap.set(c.path, c));
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
loadModuleFactory(lazyComponent) {
|
|
526
|
-
return lazyComponent.loadChildren().then((loaded) => {
|
|
527
|
-
if (loaded instanceof NgModuleFactory) {
|
|
528
|
-
return loaded;
|
|
529
|
-
}
|
|
530
|
-
else {
|
|
531
|
-
return this.compiler.compileModuleAsync(loaded);
|
|
532
|
-
}
|
|
533
|
-
});
|
|
534
|
-
}
|
|
535
|
-
getComponent(component) {
|
|
536
|
-
const loadedComponent = this.componentMap.get(component.componentName);
|
|
537
|
-
if (loadedComponent) {
|
|
538
|
-
return Promise.resolve({
|
|
539
|
-
componentDefinition: component,
|
|
540
|
-
componentImplementation: this.componentMap.get(component.componentName),
|
|
541
|
-
});
|
|
542
|
-
}
|
|
543
|
-
const lazyComponent = this.lazyComponentMap.get(component.componentName);
|
|
544
|
-
if (lazyComponent) {
|
|
545
|
-
return this.loadModuleFactory(lazyComponent).then((ngModuleFactory) => {
|
|
546
|
-
let componentType = null;
|
|
547
|
-
const moduleRef = ngModuleFactory.create(this.injector);
|
|
548
|
-
const dynamicComponentType = moduleRef.injector.get(DYNAMIC_COMPONENT);
|
|
549
|
-
if (!dynamicComponentType) {
|
|
550
|
-
throw new Error(`JssComponentFactoryService: Lazy load module for component "${lazyComponent.path}" missing DYNAMIC_COMPONENT provider. Missing JssModule.forChild()?`);
|
|
551
|
-
}
|
|
552
|
-
if (component.componentName in dynamicComponentType) {
|
|
553
|
-
componentType = dynamicComponentType[component.componentName];
|
|
554
|
-
}
|
|
555
|
-
else {
|
|
556
|
-
if (typeof dynamicComponentType === 'function') {
|
|
557
|
-
componentType = dynamicComponentType;
|
|
558
|
-
}
|
|
559
|
-
else {
|
|
560
|
-
throw new Error(`JssComponentFactoryService: Lazy load module for component "${lazyComponent.path}" missing DYNAMIC_COMPONENT provider. Missing JssModule.forChild()?`);
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
return {
|
|
564
|
-
componentDefinition: component,
|
|
565
|
-
componentImplementation: componentType,
|
|
566
|
-
componentFactory: moduleRef.componentFactoryResolver.resolveComponentFactory(componentType),
|
|
567
|
-
};
|
|
568
|
-
});
|
|
569
|
-
}
|
|
570
|
-
return Promise.resolve({
|
|
571
|
-
componentDefinition: component,
|
|
572
|
-
});
|
|
573
|
-
}
|
|
574
|
-
getComponents(components) {
|
|
575
|
-
// acquire all components and keep them in order while handling their potential async-ness
|
|
576
|
-
return Promise.all(components.map((component) => isRawRendering(component) ? this.getRawComponent(component) : this.getComponent(component)));
|
|
577
|
-
}
|
|
578
|
-
getRawComponent(component) {
|
|
579
|
-
return Promise.resolve({
|
|
580
|
-
componentImplementation: RawComponent,
|
|
581
|
-
componentDefinition: component,
|
|
582
|
-
});
|
|
583
|
-
}
|
|
584
|
-
}
|
|
585
|
-
JssComponentFactoryService.ɵfac = function JssComponentFactoryService_Factory(t) { return new (t || JssComponentFactoryService)(ɵngcc0.ɵɵinject(ɵngcc0.Injector), ɵngcc0.ɵɵinject(ɵngcc0.Compiler), ɵngcc0.ɵɵinject(PLACEHOLDER_COMPONENTS), ɵngcc0.ɵɵinject(PLACEHOLDER_LAZY_COMPONENTS)); };
|
|
586
|
-
JssComponentFactoryService.ɵprov = ɵngcc0.ɵɵdefineInjectable({ token: JssComponentFactoryService, factory: JssComponentFactoryService.ɵfac });
|
|
587
|
-
JssComponentFactoryService.ctorParameters = () => [
|
|
588
|
-
{ type: Injector },
|
|
589
|
-
{ type: Compiler },
|
|
590
|
-
{ type: Array, decorators: [{ type: Inject, args: [PLACEHOLDER_COMPONENTS,] }] },
|
|
591
|
-
{ type: Array, decorators: [{ type: Inject, args: [PLACEHOLDER_LAZY_COMPONENTS,] }] }
|
|
592
|
-
];
|
|
593
|
-
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && ɵngcc0.ɵsetClassMetadata(JssComponentFactoryService, [{
|
|
594
|
-
type: Injectable
|
|
595
|
-
}], function () { return [{ type: ɵngcc0.Injector }, { type: ɵngcc0.Compiler }, { type: Array, decorators: [{
|
|
596
|
-
type: Inject,
|
|
597
|
-
args: [PLACEHOLDER_COMPONENTS]
|
|
598
|
-
}] }, { type: Array, decorators: [{
|
|
599
|
-
type: Inject,
|
|
600
|
-
args: [PLACEHOLDER_LAZY_COMPONENTS]
|
|
601
|
-
}] }]; }, null); })();
|
|
602
|
-
|
|
603
|
-
class PlaceholderLoadingDirective {
|
|
604
|
-
constructor(templateRef) {
|
|
605
|
-
this.templateRef = templateRef;
|
|
606
|
-
}
|
|
607
|
-
}
|
|
608
|
-
PlaceholderLoadingDirective.ɵfac = function PlaceholderLoadingDirective_Factory(t) { return new (t || PlaceholderLoadingDirective)(ɵngcc0.ɵɵdirectiveInject(ɵngcc0.TemplateRef)); };
|
|
609
|
-
PlaceholderLoadingDirective.ɵdir = ɵngcc0.ɵɵdefineDirective({ type: PlaceholderLoadingDirective, selectors: [["", "scPlaceholderLoading", ""]] });
|
|
610
|
-
PlaceholderLoadingDirective.ctorParameters = () => [
|
|
611
|
-
{ type: TemplateRef }
|
|
612
|
-
];
|
|
613
|
-
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && ɵngcc0.ɵsetClassMetadata(PlaceholderLoadingDirective, [{
|
|
614
|
-
type: Directive,
|
|
615
|
-
args: [{
|
|
616
|
-
selector: '[scPlaceholderLoading]'
|
|
617
|
-
}]
|
|
618
|
-
}], function () { return [{ type: ɵngcc0.TemplateRef }]; }, null); })();
|
|
619
|
-
|
|
620
|
-
class RenderEachDirective {
|
|
621
|
-
constructor(templateRef) {
|
|
622
|
-
this.templateRef = templateRef;
|
|
623
|
-
}
|
|
624
|
-
}
|
|
625
|
-
RenderEachDirective.ɵfac = function RenderEachDirective_Factory(t) { return new (t || RenderEachDirective)(ɵngcc0.ɵɵdirectiveInject(ɵngcc0.TemplateRef)); };
|
|
626
|
-
RenderEachDirective.ɵdir = ɵngcc0.ɵɵdefineDirective({ type: RenderEachDirective, selectors: [["", "renderEach", ""]] });
|
|
627
|
-
RenderEachDirective.ctorParameters = () => [
|
|
628
|
-
{ type: TemplateRef }
|
|
629
|
-
];
|
|
630
|
-
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && ɵngcc0.ɵsetClassMetadata(RenderEachDirective, [{
|
|
631
|
-
type: Directive,
|
|
632
|
-
args: [{
|
|
633
|
-
selector: '[renderEach]'
|
|
634
|
-
}]
|
|
635
|
-
}], function () { return [{ type: ɵngcc0.TemplateRef }]; }, null); })();
|
|
636
|
-
|
|
637
|
-
class RenderEmptyDirective {
|
|
638
|
-
constructor(templateRef) {
|
|
639
|
-
this.templateRef = templateRef;
|
|
640
|
-
}
|
|
641
|
-
}
|
|
642
|
-
RenderEmptyDirective.ɵfac = function RenderEmptyDirective_Factory(t) { return new (t || RenderEmptyDirective)(ɵngcc0.ɵɵdirectiveInject(ɵngcc0.TemplateRef)); };
|
|
643
|
-
RenderEmptyDirective.ɵdir = ɵngcc0.ɵɵdefineDirective({ type: RenderEmptyDirective, selectors: [["", "renderEmpty", ""]] });
|
|
644
|
-
RenderEmptyDirective.ctorParameters = () => [
|
|
645
|
-
{ type: TemplateRef }
|
|
646
|
-
];
|
|
647
|
-
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && ɵngcc0.ɵsetClassMetadata(RenderEmptyDirective, [{
|
|
648
|
-
type: Directive,
|
|
649
|
-
args: [{
|
|
650
|
-
selector: '[renderEmpty]'
|
|
651
|
-
}]
|
|
652
|
-
}], function () { return [{ type: ɵngcc0.TemplateRef }]; }, null); })();
|
|
653
|
-
|
|
654
|
-
/* eslint-disable @angular-eslint/no-conflicting-lifecycle */
|
|
655
|
-
/**
|
|
656
|
-
* @param {ComponentRendering} rendering
|
|
657
|
-
* @param {string} name
|
|
658
|
-
*/
|
|
659
|
-
function getPlaceholder(rendering, name) {
|
|
660
|
-
if (rendering && rendering.placeholders && Object.keys(rendering.placeholders).length > 0) {
|
|
661
|
-
return rendering.placeholders[name];
|
|
662
|
-
}
|
|
663
|
-
return null;
|
|
664
|
-
}
|
|
665
|
-
class PlaceholderComponent {
|
|
666
|
-
constructor(componentFactoryResolver, differs, componentFactory, changeDetectorRef, elementRef, renderer, missingComponentComponent) {
|
|
667
|
-
this.componentFactoryResolver = componentFactoryResolver;
|
|
668
|
-
this.differs = differs;
|
|
669
|
-
this.componentFactory = componentFactory;
|
|
670
|
-
this.changeDetectorRef = changeDetectorRef;
|
|
671
|
-
this.elementRef = elementRef;
|
|
672
|
-
this.renderer = renderer;
|
|
673
|
-
this.missingComponentComponent = missingComponentComponent;
|
|
674
|
-
this._componentInstances = [];
|
|
675
|
-
this.destroyed = false;
|
|
676
|
-
this.parentStyleAttribute = '';
|
|
677
|
-
this.isLoading = true;
|
|
678
|
-
this.loaded = new EventEmitter();
|
|
679
|
-
}
|
|
680
|
-
set inputs(value) {
|
|
681
|
-
this._inputs = value;
|
|
682
|
-
if (!this._differ && value) {
|
|
683
|
-
this._differ = this.differs.find(value).create();
|
|
684
|
-
}
|
|
685
|
-
}
|
|
686
|
-
ngOnInit() {
|
|
687
|
-
// just to ensure the element exists
|
|
688
|
-
const elem = this.elementRef.nativeElement;
|
|
689
|
-
if (elem) {
|
|
690
|
-
const attributes = elem.attributes;
|
|
691
|
-
for (let i = 0; i < attributes.length; i++) {
|
|
692
|
-
const attr = attributes.item(i);
|
|
693
|
-
if (attr && attr.name.indexOf('_ngcontent') !== -1) {
|
|
694
|
-
this.parentStyleAttribute = attr.name;
|
|
695
|
-
}
|
|
696
|
-
}
|
|
697
|
-
}
|
|
698
|
-
}
|
|
699
|
-
ngOnDestroy() {
|
|
700
|
-
this.destroyed = true;
|
|
701
|
-
this._componentInstances = [];
|
|
702
|
-
}
|
|
703
|
-
ngOnChanges(changes) {
|
|
704
|
-
if (changes.rendering || changes.renderings) {
|
|
705
|
-
this._render();
|
|
706
|
-
}
|
|
707
|
-
}
|
|
708
|
-
ngDoCheck() {
|
|
709
|
-
if (!this._differ || !this._inputs || this._componentInstances.length === 0) {
|
|
710
|
-
return;
|
|
711
|
-
}
|
|
712
|
-
const changes = this._differ.diff(this._inputs);
|
|
713
|
-
if (!changes) {
|
|
714
|
-
return;
|
|
715
|
-
}
|
|
716
|
-
const updates = {};
|
|
717
|
-
changes.forEachRemovedItem((change) => (updates[change.key] = null));
|
|
718
|
-
changes.forEachAddedItem((change) => (updates[change.key] = change.currentValue));
|
|
719
|
-
changes.forEachChangedItem((change) => (updates[change.key] = change.currentValue));
|
|
720
|
-
this._componentInstances.forEach((componentInstance) => this._setComponentInputs(componentInstance, updates));
|
|
721
|
-
}
|
|
722
|
-
_setComponentInputs(componentInstance, inputs) {
|
|
723
|
-
Object.entries(inputs).forEach(([input, inputValue]) => (componentInstance[input] = inputValue));
|
|
724
|
-
}
|
|
725
|
-
_subscribeComponentOutputs(componentInstance, outputs) {
|
|
726
|
-
Object.keys(outputs)
|
|
727
|
-
.filter((output) => componentInstance[output] && componentInstance[output] instanceof Observable)
|
|
728
|
-
.forEach((output) => componentInstance[output]
|
|
729
|
-
.pipe(takeWhile(() => !this.destroyed))
|
|
730
|
-
.subscribe(outputs[output]));
|
|
731
|
-
}
|
|
732
|
-
_render() {
|
|
733
|
-
this._componentInstances = [];
|
|
734
|
-
this.view.clear();
|
|
735
|
-
if (!this.rendering && !this.renderings) {
|
|
736
|
-
return;
|
|
737
|
-
}
|
|
738
|
-
if (!this.name && !this.renderings) {
|
|
739
|
-
console.warn('Placeholder name was not specified, and explicit renderings array was not passed. Placeholder requires either name and rendering, or renderings.');
|
|
740
|
-
this.isLoading = false;
|
|
741
|
-
return;
|
|
742
|
-
}
|
|
743
|
-
const placeholder = this.renderings || getPlaceholder(this.rendering, this.name || '');
|
|
744
|
-
if (!placeholder) {
|
|
745
|
-
console.warn(`Placeholder '${this.name}' was not found in the current rendering data`, JSON.stringify(this.rendering, null, 2));
|
|
746
|
-
this.isLoading = false;
|
|
747
|
-
return;
|
|
748
|
-
}
|
|
749
|
-
// if the placeholder is empty (contains only raw renderings), then we may need to use the empty template if it's defined
|
|
750
|
-
const placeholderIsEmpty = placeholder.every((rendering) => isRawRendering(rendering));
|
|
751
|
-
if (this.renderEmptyTemplate && placeholderIsEmpty) {
|
|
752
|
-
this.view.createEmbeddedView(this.renderEmptyTemplate.templateRef, {
|
|
753
|
-
renderings: placeholder,
|
|
754
|
-
});
|
|
755
|
-
this.isLoading = false;
|
|
756
|
-
}
|
|
757
|
-
else {
|
|
758
|
-
this.componentFactory
|
|
759
|
-
.getComponents(placeholder)
|
|
760
|
-
.then((components) => components.forEach((rendering, index) => {
|
|
761
|
-
if (this.renderEachTemplate && !isRawRendering(rendering.componentDefinition)) {
|
|
762
|
-
this._renderTemplatedComponent(rendering.componentDefinition, index);
|
|
763
|
-
}
|
|
764
|
-
else {
|
|
765
|
-
this._renderEmbeddedComponent(rendering, index);
|
|
766
|
-
}
|
|
767
|
-
this.isLoading = false;
|
|
768
|
-
}))
|
|
769
|
-
.then(() => {
|
|
770
|
-
this.changeDetectorRef.markForCheck();
|
|
771
|
-
this.loaded.emit(this.name);
|
|
772
|
-
});
|
|
773
|
-
}
|
|
774
|
-
}
|
|
775
|
-
_renderTemplatedComponent(rendering, index) {
|
|
776
|
-
// the render-each template takes care of all component mapping etc
|
|
777
|
-
// generally using <sc-render-component> which is about like _renderEmbeddedComponent()
|
|
778
|
-
// as a separate component
|
|
779
|
-
this.view.createEmbeddedView(this.renderEachTemplate.templateRef, {
|
|
780
|
-
rendering,
|
|
781
|
-
index,
|
|
782
|
-
});
|
|
783
|
-
}
|
|
784
|
-
_renderEmbeddedComponent(rendering, index) {
|
|
785
|
-
if (!rendering.componentImplementation) {
|
|
786
|
-
const componentName = rendering.componentDefinition.componentName;
|
|
787
|
-
console.error(`Placeholder ${this.name} contains unknown component ${componentName}.`, `Ensure component is mapped, like:
|
|
788
|
-
JssModule.withComponents([
|
|
789
|
-
{ name: '${componentName}', type: ${componentName}Component }
|
|
790
|
-
])`);
|
|
791
|
-
rendering.componentImplementation = this.missingComponentComponent;
|
|
792
|
-
}
|
|
793
|
-
const componentFactory = rendering.componentFactory ||
|
|
794
|
-
this.componentFactoryResolver.resolveComponentFactory(rendering.componentImplementation);
|
|
795
|
-
// apply the parent style attribute _ngcontent
|
|
796
|
-
// work-around for https://github.com/angular/angular/issues/12215
|
|
797
|
-
const createdComponentRef = this.view.createComponent(componentFactory, index);
|
|
798
|
-
if (this.parentStyleAttribute) {
|
|
799
|
-
this.renderer.setAttribute(createdComponentRef.location.nativeElement, this.parentStyleAttribute, '');
|
|
800
|
-
}
|
|
801
|
-
const componentInstance = createdComponentRef.instance;
|
|
802
|
-
componentInstance.rendering = rendering.componentDefinition;
|
|
803
|
-
if (this._inputs) {
|
|
804
|
-
this._setComponentInputs(componentInstance, this._inputs);
|
|
805
|
-
}
|
|
806
|
-
if (this.outputs) {
|
|
807
|
-
this._subscribeComponentOutputs(componentInstance, this.outputs);
|
|
808
|
-
}
|
|
809
|
-
this._componentInstances.push(componentInstance);
|
|
810
|
-
}
|
|
811
|
-
}
|
|
812
|
-
PlaceholderComponent.ɵfac = function PlaceholderComponent_Factory(t) { return new (t || PlaceholderComponent)(ɵngcc0.ɵɵdirectiveInject(ɵngcc0.ComponentFactoryResolver), ɵngcc0.ɵɵdirectiveInject(ɵngcc0.KeyValueDiffers), ɵngcc0.ɵɵdirectiveInject(JssComponentFactoryService), ɵngcc0.ɵɵdirectiveInject(ɵngcc0.ChangeDetectorRef), ɵngcc0.ɵɵdirectiveInject(ɵngcc0.ElementRef), ɵngcc0.ɵɵdirectiveInject(ɵngcc0.Renderer2), ɵngcc0.ɵɵdirectiveInject(PLACEHOLDER_MISSING_COMPONENT_COMPONENT)); };
|
|
813
|
-
PlaceholderComponent.ɵcmp = ɵngcc0.ɵɵdefineComponent({ type: PlaceholderComponent, selectors: [["sc-placeholder"], ["", "sc-placeholder", ""]], contentQueries: function PlaceholderComponent_ContentQueries(rf, ctx, dirIndex) { if (rf & 1) {
|
|
814
|
-
ɵngcc0.ɵɵcontentQuery(dirIndex, RenderEachDirective, 3);
|
|
815
|
-
ɵngcc0.ɵɵcontentQuery(dirIndex, RenderEmptyDirective, 3);
|
|
816
|
-
ɵngcc0.ɵɵcontentQuery(dirIndex, PlaceholderLoadingDirective, 3);
|
|
817
|
-
} if (rf & 2) {
|
|
818
|
-
let _t;
|
|
819
|
-
ɵngcc0.ɵɵqueryRefresh(_t = ɵngcc0.ɵɵloadQuery()) && (ctx.renderEachTemplate = _t.first);
|
|
820
|
-
ɵngcc0.ɵɵqueryRefresh(_t = ɵngcc0.ɵɵloadQuery()) && (ctx.renderEmptyTemplate = _t.first);
|
|
821
|
-
ɵngcc0.ɵɵqueryRefresh(_t = ɵngcc0.ɵɵloadQuery()) && (ctx.placeholderLoading = _t.first);
|
|
822
|
-
} }, viewQuery: function PlaceholderComponent_Query(rf, ctx) { if (rf & 1) {
|
|
823
|
-
ɵngcc0.ɵɵviewQuery(_c0, 3, ViewContainerRef);
|
|
824
|
-
} if (rf & 2) {
|
|
825
|
-
let _t;
|
|
826
|
-
ɵngcc0.ɵɵqueryRefresh(_t = ɵngcc0.ɵɵloadQuery()) && (ctx.view = _t.first);
|
|
827
|
-
} }, inputs: { inputs: "inputs", name: "name", rendering: "rendering", renderings: "renderings", outputs: "outputs" }, outputs: { loaded: "loaded" }, features: [ɵngcc0.ɵɵNgOnChangesFeature], decls: 3, vars: 1, consts: [[4, "ngIf"], ["view", ""], [3, "ngTemplateOutlet"]], template: function PlaceholderComponent_Template(rf, ctx) { if (rf & 1) {
|
|
828
|
-
ɵngcc0.ɵɵtemplate(0, PlaceholderComponent_0_Template, 1, 1, undefined, 0);
|
|
829
|
-
ɵngcc0.ɵɵtemplate(1, PlaceholderComponent_ng_template_1_Template, 0, 0, "ng-template", null, 1, ɵngcc0.ɵɵtemplateRefExtractor);
|
|
830
|
-
} if (rf & 2) {
|
|
831
|
-
ɵngcc0.ɵɵproperty("ngIf", ctx.isLoading);
|
|
832
|
-
} }, directives: [ɵngcc2.NgIf, ɵngcc2.NgTemplateOutlet], encapsulation: 2 });
|
|
833
|
-
PlaceholderComponent.ctorParameters = () => [
|
|
834
|
-
{ type: ComponentFactoryResolver },
|
|
835
|
-
{ type: KeyValueDiffers },
|
|
836
|
-
{ type: JssComponentFactoryService },
|
|
837
|
-
{ type: ChangeDetectorRef },
|
|
838
|
-
{ type: ElementRef },
|
|
839
|
-
{ type: Renderer2 },
|
|
840
|
-
{ type: Type, decorators: [{ type: Inject, args: [PLACEHOLDER_MISSING_COMPONENT_COMPONENT,] }] }
|
|
841
|
-
];
|
|
842
|
-
PlaceholderComponent.propDecorators = {
|
|
843
|
-
name: [{ type: Input }],
|
|
844
|
-
rendering: [{ type: Input }],
|
|
845
|
-
renderings: [{ type: Input }],
|
|
846
|
-
outputs: [{ type: Input }],
|
|
847
|
-
loaded: [{ type: Output }],
|
|
848
|
-
view: [{ type: ViewChild, args: ['view', { read: ViewContainerRef, static: true },] }],
|
|
849
|
-
renderEachTemplate: [{ type: ContentChild, args: [RenderEachDirective, { static: true },] }],
|
|
850
|
-
renderEmptyTemplate: [{ type: ContentChild, args: [RenderEmptyDirective, { static: true },] }],
|
|
851
|
-
placeholderLoading: [{ type: ContentChild, args: [PlaceholderLoadingDirective, { static: true },] }],
|
|
852
|
-
inputs: [{ type: Input }]
|
|
853
|
-
};
|
|
854
|
-
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && ɵngcc0.ɵsetClassMetadata(PlaceholderComponent, [{
|
|
855
|
-
type: Component,
|
|
856
|
-
args: [{
|
|
857
|
-
selector: 'sc-placeholder,[sc-placeholder]',
|
|
858
|
-
template: `
|
|
859
|
-
<ng-template
|
|
860
|
-
*ngIf="isLoading"
|
|
861
|
-
[ngTemplateOutlet]="placeholderLoading?.templateRef"
|
|
862
|
-
></ng-template>
|
|
863
|
-
<ng-template #view></ng-template>
|
|
864
|
-
`
|
|
865
|
-
}]
|
|
866
|
-
}], function () { return [{ type: ɵngcc0.ComponentFactoryResolver }, { type: ɵngcc0.KeyValueDiffers }, { type: JssComponentFactoryService }, { type: ɵngcc0.ChangeDetectorRef }, { type: ɵngcc0.ElementRef }, { type: ɵngcc0.Renderer2 }, { type: ɵngcc0.Type, decorators: [{
|
|
867
|
-
type: Inject,
|
|
868
|
-
args: [PLACEHOLDER_MISSING_COMPONENT_COMPONENT]
|
|
869
|
-
}] }]; }, { loaded: [{
|
|
870
|
-
type: Output
|
|
871
|
-
}], inputs: [{
|
|
872
|
-
type: Input
|
|
873
|
-
}], name: [{
|
|
874
|
-
type: Input
|
|
875
|
-
}], rendering: [{
|
|
876
|
-
type: Input
|
|
877
|
-
}], renderings: [{
|
|
878
|
-
type: Input
|
|
879
|
-
}], outputs: [{
|
|
880
|
-
type: Input
|
|
881
|
-
}], view: [{
|
|
882
|
-
type: ViewChild,
|
|
883
|
-
args: ['view', { read: ViewContainerRef, static: true }]
|
|
884
|
-
}], renderEachTemplate: [{
|
|
885
|
-
type: ContentChild,
|
|
886
|
-
args: [RenderEachDirective, { static: true }]
|
|
887
|
-
}], renderEmptyTemplate: [{
|
|
888
|
-
type: ContentChild,
|
|
889
|
-
args: [RenderEmptyDirective, { static: true }]
|
|
890
|
-
}], placeholderLoading: [{
|
|
891
|
-
type: ContentChild,
|
|
892
|
-
args: [PlaceholderLoadingDirective, { static: true }]
|
|
893
|
-
}] }); })();
|
|
894
|
-
|
|
895
|
-
class RichTextDirective {
|
|
896
|
-
constructor(viewContainer, templateRef) {
|
|
897
|
-
this.viewContainer = viewContainer;
|
|
898
|
-
this.templateRef = templateRef;
|
|
899
|
-
this.editable = true;
|
|
900
|
-
}
|
|
901
|
-
ngOnChanges(changes) {
|
|
902
|
-
if (changes.field || changes.editable) {
|
|
903
|
-
if (!this.viewRef) {
|
|
904
|
-
this.viewContainer.clear();
|
|
905
|
-
this.viewRef = this.viewContainer.createEmbeddedView(this.templateRef);
|
|
906
|
-
}
|
|
907
|
-
this.updateView();
|
|
908
|
-
}
|
|
909
|
-
}
|
|
910
|
-
updateView() {
|
|
911
|
-
const field = this.field;
|
|
912
|
-
if (!field || (!field.editable && !field.value)) {
|
|
913
|
-
return;
|
|
914
|
-
}
|
|
915
|
-
const html = field.editable && this.editable ? field.editable : field.value;
|
|
916
|
-
this.viewRef.rootNodes.forEach((node) => {
|
|
917
|
-
node.innerHTML = html;
|
|
918
|
-
});
|
|
919
|
-
}
|
|
920
|
-
}
|
|
921
|
-
RichTextDirective.ɵfac = function RichTextDirective_Factory(t) { return new (t || RichTextDirective)(ɵngcc0.ɵɵdirectiveInject(ɵngcc0.ViewContainerRef), ɵngcc0.ɵɵdirectiveInject(ɵngcc0.TemplateRef)); };
|
|
922
|
-
RichTextDirective.ɵdir = ɵngcc0.ɵɵdefineDirective({ type: RichTextDirective, selectors: [["", "scRichText", ""]], inputs: { editable: ["scRichTextEditable", "editable"], field: ["scRichText", "field"] }, features: [ɵngcc0.ɵɵNgOnChangesFeature] });
|
|
923
|
-
RichTextDirective.ctorParameters = () => [
|
|
924
|
-
{ type: ViewContainerRef },
|
|
925
|
-
{ type: TemplateRef }
|
|
926
|
-
];
|
|
927
|
-
RichTextDirective.propDecorators = {
|
|
928
|
-
editable: [{ type: Input, args: ['scRichTextEditable',] }],
|
|
929
|
-
field: [{ type: Input, args: ['scRichText',] }]
|
|
930
|
-
};
|
|
931
|
-
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && ɵngcc0.ɵsetClassMetadata(RichTextDirective, [{
|
|
932
|
-
type: Directive,
|
|
933
|
-
args: [{
|
|
934
|
-
selector: '[scRichText]'
|
|
935
|
-
}]
|
|
936
|
-
}], function () { return [{ type: ɵngcc0.ViewContainerRef }, { type: ɵngcc0.TemplateRef }]; }, { editable: [{
|
|
937
|
-
type: Input,
|
|
938
|
-
args: ['scRichTextEditable']
|
|
939
|
-
}], field: [{
|
|
940
|
-
type: Input,
|
|
941
|
-
args: ['scRichText']
|
|
942
|
-
}] }); })();
|
|
943
|
-
|
|
944
|
-
class TextDirective {
|
|
945
|
-
constructor(viewContainer, templateRef) {
|
|
946
|
-
this.viewContainer = viewContainer;
|
|
947
|
-
this.templateRef = templateRef;
|
|
948
|
-
this.editable = true;
|
|
949
|
-
this.encode = true;
|
|
950
|
-
}
|
|
951
|
-
ngOnChanges(changes) {
|
|
952
|
-
if (changes.field || changes.editable || changes.encode) {
|
|
953
|
-
if (!this.viewRef) {
|
|
954
|
-
this.viewContainer.clear();
|
|
955
|
-
this.viewRef = this.viewContainer.createEmbeddedView(this.templateRef);
|
|
956
|
-
}
|
|
957
|
-
this.updateView();
|
|
958
|
-
}
|
|
959
|
-
}
|
|
960
|
-
updateView() {
|
|
961
|
-
const field = this.field;
|
|
962
|
-
let editable = this.editable;
|
|
963
|
-
if (!field || (!field.editable && (field.value === undefined || field.value === ''))) {
|
|
964
|
-
return;
|
|
965
|
-
}
|
|
966
|
-
// can't use editable value if we want to output unencoded
|
|
967
|
-
if (!this.encode) {
|
|
968
|
-
editable = false;
|
|
969
|
-
}
|
|
970
|
-
const html = field.editable && editable ? field.editable : field.value;
|
|
971
|
-
const setDangerously = (field.editable && editable) || !this.encode;
|
|
972
|
-
this.viewRef.rootNodes.forEach((node) => {
|
|
973
|
-
if (setDangerously) {
|
|
974
|
-
node.innerHTML = html;
|
|
975
|
-
}
|
|
976
|
-
else {
|
|
977
|
-
node.textContent = html;
|
|
978
|
-
}
|
|
979
|
-
});
|
|
980
|
-
}
|
|
981
|
-
}
|
|
982
|
-
TextDirective.ɵfac = function TextDirective_Factory(t) { return new (t || TextDirective)(ɵngcc0.ɵɵdirectiveInject(ɵngcc0.ViewContainerRef), ɵngcc0.ɵɵdirectiveInject(ɵngcc0.TemplateRef)); };
|
|
983
|
-
TextDirective.ɵdir = ɵngcc0.ɵɵdefineDirective({ type: TextDirective, selectors: [["", "scText", ""]], inputs: { editable: ["scTextEditable", "editable"], encode: ["scTextEncode", "encode"], field: ["scText", "field"] }, features: [ɵngcc0.ɵɵNgOnChangesFeature] });
|
|
984
|
-
TextDirective.ctorParameters = () => [
|
|
985
|
-
{ type: ViewContainerRef },
|
|
986
|
-
{ type: TemplateRef }
|
|
987
|
-
];
|
|
988
|
-
TextDirective.propDecorators = {
|
|
989
|
-
editable: [{ type: Input, args: ['scTextEditable',] }],
|
|
990
|
-
encode: [{ type: Input, args: ['scTextEncode',] }],
|
|
991
|
-
field: [{ type: Input, args: ['scText',] }]
|
|
992
|
-
};
|
|
993
|
-
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && ɵngcc0.ɵsetClassMetadata(TextDirective, [{
|
|
994
|
-
type: Directive,
|
|
995
|
-
args: [{
|
|
996
|
-
selector: '[scText]'
|
|
997
|
-
}]
|
|
998
|
-
}], function () { return [{ type: ɵngcc0.ViewContainerRef }, { type: ɵngcc0.TemplateRef }]; }, { editable: [{
|
|
999
|
-
type: Input,
|
|
1000
|
-
args: ['scTextEditable']
|
|
1001
|
-
}], encode: [{
|
|
1002
|
-
type: Input,
|
|
1003
|
-
args: ['scTextEncode']
|
|
1004
|
-
}], field: [{
|
|
1005
|
-
type: Input,
|
|
1006
|
-
args: ['scText']
|
|
1007
|
-
}] }); })();
|
|
1008
|
-
|
|
1009
|
-
class LayoutServiceError {
|
|
1010
|
-
}
|
|
1011
|
-
|
|
1012
|
-
// TODO: these are deprecated and we should switch to using new methods
|
|
1013
|
-
const { fetchRouteData, fetchPlaceholderData } = dataApi;
|
|
1014
|
-
class LayoutService {
|
|
1015
|
-
static getLayoutServiceError(error) {
|
|
1016
|
-
const layoutServiceError = new LayoutServiceError();
|
|
1017
|
-
const response = error.response;
|
|
1018
|
-
if (response) {
|
|
1019
|
-
layoutServiceError.status = response.status;
|
|
1020
|
-
layoutServiceError.statusText = response.statusText;
|
|
1021
|
-
layoutServiceError.data = response.data;
|
|
1022
|
-
}
|
|
1023
|
-
return throwError(layoutServiceError);
|
|
1024
|
-
}
|
|
1025
|
-
getRouteData(route, options) {
|
|
1026
|
-
return from(fetchRouteData(route, options)).pipe(catchError(LayoutService.getLayoutServiceError));
|
|
1027
|
-
}
|
|
1028
|
-
getPlaceholderData(route, placeholderName, options) {
|
|
1029
|
-
return from(fetchPlaceholderData(placeholderName, route, options)).pipe(catchError(LayoutService.getLayoutServiceError));
|
|
1030
|
-
}
|
|
1031
|
-
}
|
|
1032
|
-
LayoutService.ɵfac = function LayoutService_Factory(t) { return new (t || LayoutService)(); };
|
|
1033
|
-
LayoutService.ɵprov = ɵngcc0.ɵɵdefineInjectable({ token: LayoutService, factory: LayoutService.ɵfac });
|
|
1034
|
-
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && ɵngcc0.ɵsetClassMetadata(LayoutService, [{
|
|
1035
|
-
type: Injectable
|
|
1036
|
-
}], null, null); })();
|
|
1037
|
-
|
|
1038
|
-
class DateDirective {
|
|
1039
|
-
constructor(viewContainer, templateRef, datePipe) {
|
|
1040
|
-
this.viewContainer = viewContainer;
|
|
1041
|
-
this.templateRef = templateRef;
|
|
1042
|
-
this.datePipe = datePipe;
|
|
1043
|
-
this.editable = true;
|
|
1044
|
-
}
|
|
1045
|
-
ngOnChanges(changes) {
|
|
1046
|
-
if (changes.field || changes.format) {
|
|
1047
|
-
if (!this.viewRef) {
|
|
1048
|
-
this.viewContainer.clear();
|
|
1049
|
-
this.viewRef = this.viewContainer.createEmbeddedView(this.templateRef);
|
|
1050
|
-
}
|
|
1051
|
-
this.updateView();
|
|
1052
|
-
}
|
|
1053
|
-
}
|
|
1054
|
-
updateView() {
|
|
1055
|
-
const field = this.field;
|
|
1056
|
-
if (!field || (!field.editable && !field.value)) {
|
|
1057
|
-
return;
|
|
1058
|
-
}
|
|
1059
|
-
const html = field.editable && this.editable ? field.editable : field.value;
|
|
1060
|
-
const setDangerously = field.editable && this.editable;
|
|
1061
|
-
this.viewRef.rootNodes.forEach((node) => {
|
|
1062
|
-
if (setDangerously) {
|
|
1063
|
-
node.innerHTML = html;
|
|
1064
|
-
}
|
|
1065
|
-
else {
|
|
1066
|
-
node.textContent = this.datePipe.transform(html, this.format, this.timezone, this.locale);
|
|
1067
|
-
}
|
|
1068
|
-
});
|
|
1069
|
-
}
|
|
1070
|
-
}
|
|
1071
|
-
DateDirective.ɵfac = function DateDirective_Factory(t) { return new (t || DateDirective)(ɵngcc0.ɵɵdirectiveInject(ɵngcc0.ViewContainerRef), ɵngcc0.ɵɵdirectiveInject(ɵngcc0.TemplateRef), ɵngcc0.ɵɵdirectiveInject(ɵngcc2.DatePipe)); };
|
|
1072
|
-
DateDirective.ɵdir = ɵngcc0.ɵɵdefineDirective({ type: DateDirective, selectors: [["", "scDate", ""]], inputs: { editable: ["scDateEditable", "editable"], format: ["scDateFormat", "format"], timezone: ["scDateTimezone", "timezone"], locale: ["scDateLocale", "locale"], field: ["scDate", "field"] }, features: [ɵngcc0.ɵɵNgOnChangesFeature] });
|
|
1073
|
-
DateDirective.ctorParameters = () => [
|
|
1074
|
-
{ type: ViewContainerRef },
|
|
1075
|
-
{ type: TemplateRef },
|
|
1076
|
-
{ type: DatePipe }
|
|
1077
|
-
];
|
|
1078
|
-
DateDirective.propDecorators = {
|
|
1079
|
-
format: [{ type: Input, args: ['scDateFormat',] }],
|
|
1080
|
-
timezone: [{ type: Input, args: ['scDateTimezone',] }],
|
|
1081
|
-
locale: [{ type: Input, args: ['scDateLocale',] }],
|
|
1082
|
-
editable: [{ type: Input, args: ['scDateEditable',] }],
|
|
1083
|
-
field: [{ type: Input, args: ['scDate',] }]
|
|
1084
|
-
};
|
|
1085
|
-
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && ɵngcc0.ɵsetClassMetadata(DateDirective, [{
|
|
1086
|
-
type: Directive,
|
|
1087
|
-
args: [{
|
|
1088
|
-
selector: '[scDate]'
|
|
1089
|
-
}]
|
|
1090
|
-
}], function () { return [{ type: ɵngcc0.ViewContainerRef }, { type: ɵngcc0.TemplateRef }, { type: ɵngcc2.DatePipe }]; }, { editable: [{
|
|
1091
|
-
type: Input,
|
|
1092
|
-
args: ['scDateEditable']
|
|
1093
|
-
}], format: [{
|
|
1094
|
-
type: Input,
|
|
1095
|
-
args: ['scDateFormat']
|
|
1096
|
-
}], timezone: [{
|
|
1097
|
-
type: Input,
|
|
1098
|
-
args: ['scDateTimezone']
|
|
1099
|
-
}], locale: [{
|
|
1100
|
-
type: Input,
|
|
1101
|
-
args: ['scDateLocale']
|
|
1102
|
-
}], field: [{
|
|
1103
|
-
type: Input,
|
|
1104
|
-
args: ['scDate']
|
|
1105
|
-
}] }); })();
|
|
1106
|
-
|
|
1107
|
-
class MissingComponentComponent {
|
|
1108
|
-
}
|
|
1109
|
-
MissingComponentComponent.ɵfac = function MissingComponentComponent_Factory(t) { return new (t || MissingComponentComponent)(); };
|
|
1110
|
-
MissingComponentComponent.ɵcmp = ɵngcc0.ɵɵdefineComponent({ type: MissingComponentComponent, selectors: [["sc-missing-component"]], inputs: { rendering: "rendering" }, decls: 5, vars: 1, consts: [[2, "background", "darkorange", "outline", "5px solid orange", "padding", "10px", "color", "white", "max-width", "500px"]], template: function MissingComponentComponent_Template(rf, ctx) { if (rf & 1) {
|
|
1111
|
-
ɵngcc0.ɵɵelementStart(0, "div", 0);
|
|
1112
|
-
ɵngcc0.ɵɵelementStart(1, "h2");
|
|
1113
|
-
ɵngcc0.ɵɵtext(2);
|
|
1114
|
-
ɵngcc0.ɵɵelementEnd();
|
|
1115
|
-
ɵngcc0.ɵɵelementStart(3, "p");
|
|
1116
|
-
ɵngcc0.ɵɵtext(4, "JSS component is missing Angular component implementation.");
|
|
1117
|
-
ɵngcc0.ɵɵelementEnd();
|
|
1118
|
-
ɵngcc0.ɵɵelementEnd();
|
|
1119
|
-
} if (rf & 2) {
|
|
1120
|
-
ɵngcc0.ɵɵadvance(2);
|
|
1121
|
-
ɵngcc0.ɵɵtextInterpolate(ctx.rendering.componentName);
|
|
1122
|
-
} }, encapsulation: 2 });
|
|
1123
|
-
MissingComponentComponent.propDecorators = {
|
|
1124
|
-
rendering: [{ type: Input }]
|
|
1125
|
-
};
|
|
1126
|
-
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && ɵngcc0.ɵsetClassMetadata(MissingComponentComponent, [{
|
|
1127
|
-
type: Component,
|
|
1128
|
-
args: [{
|
|
1129
|
-
selector: 'sc-missing-component',
|
|
1130
|
-
template: `
|
|
1131
|
-
<div
|
|
1132
|
-
style="background: darkorange; outline: 5px solid orange; padding: 10px; color: white; max-width: 500px;"
|
|
1133
|
-
>
|
|
1134
|
-
<h2>{{ rendering.componentName }}</h2>
|
|
1135
|
-
<p>JSS component is missing Angular component implementation.</p>
|
|
1136
|
-
</div>
|
|
1137
|
-
`
|
|
1138
|
-
}]
|
|
1139
|
-
}], null, { rendering: [{
|
|
1140
|
-
type: Input
|
|
1141
|
-
}] }); })();
|
|
1142
|
-
|
|
1143
|
-
/**
|
|
1144
|
-
* Renders a single JSS component given a rendering definition.
|
|
1145
|
-
* Useful inside templated placeholders.
|
|
1146
|
-
*/
|
|
1147
|
-
class RenderComponentComponent {
|
|
1148
|
-
constructor(componentFactoryResolver, differs, componentFactory, missingComponentComponent) {
|
|
1149
|
-
this.componentFactoryResolver = componentFactoryResolver;
|
|
1150
|
-
this.differs = differs;
|
|
1151
|
-
this.componentFactory = componentFactory;
|
|
1152
|
-
this.missingComponentComponent = missingComponentComponent;
|
|
1153
|
-
this.destroyed = false;
|
|
1154
|
-
}
|
|
1155
|
-
set inputs(value) {
|
|
1156
|
-
this._inputs = value;
|
|
1157
|
-
if (!this._differ && value) {
|
|
1158
|
-
this._differ = this.differs.find(value).create();
|
|
1159
|
-
}
|
|
1160
|
-
}
|
|
1161
|
-
ngOnChanges(changes) {
|
|
1162
|
-
if (changes.rendering) {
|
|
1163
|
-
this._render();
|
|
1164
|
-
}
|
|
1165
|
-
}
|
|
1166
|
-
_setComponentInputs(componentInstance, inputs) {
|
|
1167
|
-
Object.entries(inputs).forEach(([input, inputValue]) => (componentInstance[input] = inputValue));
|
|
1168
|
-
}
|
|
1169
|
-
_subscribeComponentOutputs(componentInstance, outputs) {
|
|
1170
|
-
Object.keys(outputs)
|
|
1171
|
-
.filter((output) => componentInstance[output] && componentInstance[output] instanceof Observable)
|
|
1172
|
-
.forEach((output) => componentInstance[output]
|
|
1173
|
-
.pipe(takeWhile(() => !this.destroyed))
|
|
1174
|
-
.subscribe(outputs[output]));
|
|
1175
|
-
}
|
|
1176
|
-
_render() {
|
|
1177
|
-
this.view.clear();
|
|
1178
|
-
if (!this.rendering) {
|
|
1179
|
-
return;
|
|
1180
|
-
}
|
|
1181
|
-
const resolveComponent = isRawRendering(this.rendering)
|
|
1182
|
-
? Promise.resolve({
|
|
1183
|
-
componentImplementation: RawComponent,
|
|
1184
|
-
componentDefinition: this.rendering,
|
|
1185
|
-
})
|
|
1186
|
-
: this.componentFactory.getComponent(this.rendering);
|
|
1187
|
-
resolveComponent.then((rendering) => {
|
|
1188
|
-
if (!rendering.componentImplementation) {
|
|
1189
|
-
const componentName = rendering.componentDefinition.componentName;
|
|
1190
|
-
console.error(`Attempted to render unknown component ${componentName}.`, `Ensure component is mapped, like:
|
|
1191
|
-
JssModule.withComponents([
|
|
1192
|
-
{ name: '${componentName}', type: ${componentName}Component }
|
|
1193
|
-
])`);
|
|
1194
|
-
rendering.componentImplementation = this.missingComponentComponent;
|
|
1195
|
-
}
|
|
1196
|
-
const componentFactory = rendering.componentFactory ||
|
|
1197
|
-
this.componentFactoryResolver.resolveComponentFactory(rendering.componentImplementation);
|
|
1198
|
-
const componentInstance = this.view.createComponent(componentFactory, 0).instance;
|
|
1199
|
-
componentInstance.rendering = rendering.componentDefinition;
|
|
1200
|
-
if (this._inputs) {
|
|
1201
|
-
this._setComponentInputs(componentInstance, this._inputs);
|
|
1202
|
-
}
|
|
1203
|
-
if (this.outputs) {
|
|
1204
|
-
this._subscribeComponentOutputs(componentInstance, this.outputs);
|
|
1205
|
-
}
|
|
1206
|
-
});
|
|
1207
|
-
}
|
|
1208
|
-
}
|
|
1209
|
-
RenderComponentComponent.ɵfac = function RenderComponentComponent_Factory(t) { return new (t || RenderComponentComponent)(ɵngcc0.ɵɵdirectiveInject(ɵngcc0.ComponentFactoryResolver), ɵngcc0.ɵɵdirectiveInject(ɵngcc0.KeyValueDiffers), ɵngcc0.ɵɵdirectiveInject(JssComponentFactoryService), ɵngcc0.ɵɵdirectiveInject(PLACEHOLDER_MISSING_COMPONENT_COMPONENT)); };
|
|
1210
|
-
RenderComponentComponent.ɵcmp = ɵngcc0.ɵɵdefineComponent({ type: RenderComponentComponent, selectors: [["sc-render-component"]], viewQuery: function RenderComponentComponent_Query(rf, ctx) { if (rf & 1) {
|
|
1211
|
-
ɵngcc0.ɵɵviewQuery(_c0, 3, ViewContainerRef);
|
|
1212
|
-
} if (rf & 2) {
|
|
1213
|
-
let _t;
|
|
1214
|
-
ɵngcc0.ɵɵqueryRefresh(_t = ɵngcc0.ɵɵloadQuery()) && (ctx.view = _t.first);
|
|
1215
|
-
} }, inputs: { inputs: "inputs", rendering: "rendering", outputs: "outputs" }, features: [ɵngcc0.ɵɵNgOnChangesFeature], decls: 2, vars: 0, consts: [["view", ""]], template: function RenderComponentComponent_Template(rf, ctx) { if (rf & 1) {
|
|
1216
|
-
ɵngcc0.ɵɵtemplate(0, RenderComponentComponent_ng_template_0_Template, 0, 0, "ng-template", null, 0, ɵngcc0.ɵɵtemplateRefExtractor);
|
|
1217
|
-
} }, encapsulation: 2 });
|
|
1218
|
-
RenderComponentComponent.ctorParameters = () => [
|
|
1219
|
-
{ type: ComponentFactoryResolver },
|
|
1220
|
-
{ type: KeyValueDiffers },
|
|
1221
|
-
{ type: JssComponentFactoryService },
|
|
1222
|
-
{ type: Type, decorators: [{ type: Inject, args: [PLACEHOLDER_MISSING_COMPONENT_COMPONENT,] }] }
|
|
1223
|
-
];
|
|
1224
|
-
RenderComponentComponent.propDecorators = {
|
|
1225
|
-
rendering: [{ type: Input }],
|
|
1226
|
-
outputs: [{ type: Input }],
|
|
1227
|
-
view: [{ type: ViewChild, args: ['view', { read: ViewContainerRef, static: true },] }],
|
|
1228
|
-
inputs: [{ type: Input }]
|
|
1229
|
-
};
|
|
1230
|
-
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && ɵngcc0.ɵsetClassMetadata(RenderComponentComponent, [{
|
|
1231
|
-
type: Component,
|
|
1232
|
-
args: [{
|
|
1233
|
-
selector: 'sc-render-component',
|
|
1234
|
-
template: `
|
|
1235
|
-
<ng-template #view></ng-template>
|
|
1236
|
-
`
|
|
1237
|
-
}]
|
|
1238
|
-
}], function () { return [{ type: ɵngcc0.ComponentFactoryResolver }, { type: ɵngcc0.KeyValueDiffers }, { type: JssComponentFactoryService }, { type: ɵngcc0.Type, decorators: [{
|
|
1239
|
-
type: Inject,
|
|
1240
|
-
args: [PLACEHOLDER_MISSING_COMPONENT_COMPONENT]
|
|
1241
|
-
}] }]; }, { inputs: [{
|
|
1242
|
-
type: Input
|
|
1243
|
-
}], rendering: [{
|
|
1244
|
-
type: Input
|
|
1245
|
-
}], outputs: [{
|
|
1246
|
-
type: Input
|
|
1247
|
-
}], view: [{
|
|
1248
|
-
type: ViewChild,
|
|
1249
|
-
args: ['view', { read: ViewContainerRef, static: true }]
|
|
1250
|
-
}] }); })();
|
|
1251
|
-
|
|
1252
|
-
class JssModule {
|
|
1253
|
-
/**
|
|
1254
|
-
* Instantiates the JSS module with no component factory.
|
|
1255
|
-
* Useful for using it from libraries. Most of the time you'd want withComponents()
|
|
1256
|
-
* @returns {ModuleWithProviders<JssModule>} module
|
|
1257
|
-
*/
|
|
1258
|
-
static forRoot() {
|
|
1259
|
-
return {
|
|
1260
|
-
ngModule: JssModule,
|
|
1261
|
-
providers: [LayoutService, DatePipe, JssComponentFactoryService],
|
|
1262
|
-
};
|
|
1263
|
-
}
|
|
1264
|
-
/**
|
|
1265
|
-
* Instantiates a module for a lazy-loaded JSS component
|
|
1266
|
-
* @param {Type<any>} component
|
|
1267
|
-
* @returns {ModuleWithProviders<JssModule>} module
|
|
1268
|
-
*/
|
|
1269
|
-
static forChild(component) {
|
|
1270
|
-
return {
|
|
1271
|
-
ngModule: JssModule,
|
|
1272
|
-
providers: [
|
|
1273
|
-
{ provide: ANALYZE_FOR_ENTRY_COMPONENTS, useValue: component, multi: true },
|
|
1274
|
-
{ provide: ROUTES, useValue: [], multi: true },
|
|
1275
|
-
{ provide: DYNAMIC_COMPONENT, useValue: component },
|
|
1276
|
-
],
|
|
1277
|
-
};
|
|
1278
|
-
}
|
|
1279
|
-
/**
|
|
1280
|
-
* Instantiates the JSS module and specifies the mapping from component name to component implementation.
|
|
1281
|
-
* Appropriate when defining the set of JSS components that your app is aware of.
|
|
1282
|
-
* @param {ComponentNameAndType[]} components
|
|
1283
|
-
* @param {ComponentNameAndModule[]} [lazyComponents]
|
|
1284
|
-
* @returns {ModuleWithProviders<JssModule>} module
|
|
1285
|
-
*/
|
|
1286
|
-
static withComponents(components, lazyComponents) {
|
|
1287
|
-
return {
|
|
1288
|
-
ngModule: JssModule,
|
|
1289
|
-
providers: [
|
|
1290
|
-
{
|
|
1291
|
-
provide: ANALYZE_FOR_ENTRY_COMPONENTS,
|
|
1292
|
-
useValue: components,
|
|
1293
|
-
multi: true,
|
|
1294
|
-
},
|
|
1295
|
-
{ provide: PLACEHOLDER_COMPONENTS, useValue: components },
|
|
1296
|
-
{ provide: PLACEHOLDER_LAZY_COMPONENTS, useValue: lazyComponents || [] },
|
|
1297
|
-
{ provide: ROUTES, useValue: lazyComponents || [], multi: true },
|
|
1298
|
-
{ provide: PLACEHOLDER_MISSING_COMPONENT_COMPONENT, useValue: MissingComponentComponent },
|
|
1299
|
-
...JssModule.forRoot().providers,
|
|
1300
|
-
],
|
|
1301
|
-
};
|
|
1302
|
-
}
|
|
1303
|
-
}
|
|
1304
|
-
JssModule.ɵfac = function JssModule_Factory(t) { return new (t || JssModule)(); };
|
|
1305
|
-
JssModule.ɵmod = ɵngcc0.ɵɵdefineNgModule({ type: JssModule });
|
|
1306
|
-
JssModule.ɵinj = ɵngcc0.ɵɵdefineInjector({ imports: [[CommonModule]] });
|
|
1307
|
-
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && ɵngcc0.ɵɵsetNgModuleScope(JssModule, { declarations: function () { return [FileDirective, ImageDirective, LinkDirective, RouterLinkDirective, GenericLinkDirective, DateDirective, RenderEachDirective, RenderEmptyDirective, PlaceholderLoadingDirective, RenderComponentComponent, PlaceholderComponent, RawComponent, RichTextDirective, TextDirective, MissingComponentComponent]; }, imports: function () { return [CommonModule]; }, exports: function () { return [FileDirective, ImageDirective, DateDirective, LinkDirective, RouterLinkDirective, GenericLinkDirective, RenderEachDirective, RenderEmptyDirective, RenderComponentComponent, PlaceholderComponent, PlaceholderLoadingDirective, RichTextDirective, TextDirective]; } }); })();
|
|
1308
|
-
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && ɵngcc0.ɵsetClassMetadata(JssModule, [{
|
|
1309
|
-
type: NgModule,
|
|
1310
|
-
args: [{
|
|
1311
|
-
imports: [CommonModule],
|
|
1312
|
-
declarations: [
|
|
1313
|
-
FileDirective,
|
|
1314
|
-
ImageDirective,
|
|
1315
|
-
LinkDirective,
|
|
1316
|
-
RouterLinkDirective,
|
|
1317
|
-
GenericLinkDirective,
|
|
1318
|
-
DateDirective,
|
|
1319
|
-
RenderEachDirective,
|
|
1320
|
-
RenderEmptyDirective,
|
|
1321
|
-
PlaceholderLoadingDirective,
|
|
1322
|
-
RenderComponentComponent,
|
|
1323
|
-
PlaceholderComponent,
|
|
1324
|
-
RawComponent,
|
|
1325
|
-
RichTextDirective,
|
|
1326
|
-
TextDirective,
|
|
1327
|
-
MissingComponentComponent,
|
|
1328
|
-
],
|
|
1329
|
-
exports: [
|
|
1330
|
-
FileDirective,
|
|
1331
|
-
ImageDirective,
|
|
1332
|
-
DateDirective,
|
|
1333
|
-
LinkDirective,
|
|
1334
|
-
RouterLinkDirective,
|
|
1335
|
-
GenericLinkDirective,
|
|
1336
|
-
RenderEachDirective,
|
|
1337
|
-
RenderEmptyDirective,
|
|
1338
|
-
RenderComponentComponent,
|
|
1339
|
-
PlaceholderComponent,
|
|
1340
|
-
PlaceholderLoadingDirective,
|
|
1341
|
-
RichTextDirective,
|
|
1342
|
-
TextDirective,
|
|
1343
|
-
],
|
|
1344
|
-
entryComponents: [RawComponent, MissingComponentComponent]
|
|
1345
|
-
}]
|
|
1346
|
-
}], null, null); })();
|
|
1347
|
-
|
|
1348
|
-
/**
|
|
1349
|
-
* @description in Experience Editor with an Angular sample app, anchor tags
|
|
1350
|
-
* with both onclick and href attributes will use the href, blocking the onclick from firing.
|
|
1351
|
-
* This function makes it so the anchor tags function as intended in an Angular sample when using Experience Editor
|
|
1352
|
-
*
|
|
1353
|
-
* The Mutation Observer API is used to observe changes to the body, then select all elements with href="#" and an onclick,
|
|
1354
|
-
* and replaces the # value with javascript:void(0); which prevents the anchor tag from blocking the onclick event handler.
|
|
1355
|
-
* @see Mutation Observer API: https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver/MutationObserver
|
|
1356
|
-
*/
|
|
1357
|
-
const handleEditorAnchors = () => {
|
|
1358
|
-
// Angular gives the href attribute priority over the onclick attribute if both are present, so we must replace
|
|
1359
|
-
// the href attribute to avoid overriding the onclick in Experience Editor
|
|
1360
|
-
if (!window || !isExperienceEditorActive()) {
|
|
1361
|
-
return;
|
|
1362
|
-
}
|
|
1363
|
-
const targetNode = document.querySelector('body');
|
|
1364
|
-
const callback = (mutationList) => {
|
|
1365
|
-
mutationList.forEach((mutation) => {
|
|
1366
|
-
const btns = document.querySelectorAll('.scChromeDropDown > a[href="#"], a[onclick]');
|
|
1367
|
-
if (mutation.type === 'childList') {
|
|
1368
|
-
btns.forEach((link) => {
|
|
1369
|
-
link.href = 'javascript:void(0);';
|
|
1370
|
-
});
|
|
1371
|
-
}
|
|
1372
|
-
return;
|
|
1373
|
-
});
|
|
1374
|
-
};
|
|
1375
|
-
const observer = new MutationObserver(callback);
|
|
1376
|
-
const observerOptions = {
|
|
1377
|
-
childList: true,
|
|
1378
|
-
subtree: true,
|
|
1379
|
-
};
|
|
1380
|
-
if (targetNode) {
|
|
1381
|
-
observer.observe(targetNode, observerOptions);
|
|
1382
|
-
}
|
|
1383
|
-
};
|
|
1384
|
-
|
|
1385
|
-
/**
|
|
1386
|
-
* Generated bundle index. Do not edit.
|
|
1387
|
-
*/
|
|
1388
|
-
|
|
1389
|
-
export { ComponentNameAndType, DYNAMIC_COMPONENT, FileDirective, GenericLinkDirective, ImageDirective, JssModule, LayoutService, LayoutServiceError, LinkDirective, PlaceholderComponent, PlaceholderLoadingDirective, RichTextDirective, RouterLinkDirective, TextDirective, handleEditorAnchors, isRawRendering, PLACEHOLDER_COMPONENTS as ɵb, PLACEHOLDER_LAZY_COMPONENTS as ɵc, PLACEHOLDER_MISSING_COMPONENT_COMPONENT as ɵd, RenderEachDirective as ɵe, RenderEmptyDirective as ɵf, JssComponentFactoryService as ɵg, DateDirective as ɵh, RenderComponentComponent as ɵi, RawComponent as ɵj, MissingComponentComponent as ɵk };
|
|
1390
|
-
|
|
1391
|
-
//# sourceMappingURL=sitecore-jss-sitecore-jss-angular.js.map
|