@sitecore-jss/sitecore-jss-angular 13.2.4 → 13.2.5-canary.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/bundles/sitecore-jss-sitecore-jss-angular.umd.js +1158 -1158
- package/dist/components/date.directive.d.ts +17 -17
- package/dist/components/file.directive.d.ts +14 -14
- package/dist/components/generic-link.directive.d.ts +14 -14
- package/dist/components/image.directive.d.ts +20 -20
- package/dist/components/link.directive.d.ts +18 -18
- package/dist/components/missing-component.component.d.ts +3 -3
- package/dist/components/placeholder-loading.directive.d.ts +5 -5
- package/dist/components/placeholder.component.d.ts +45 -45
- package/dist/components/placeholder.token.d.ts +24 -24
- package/dist/components/raw.component.d.ts +9 -9
- package/dist/components/render-component.component.d.ts +29 -29
- package/dist/components/render-each.directive.d.ts +5 -5
- package/dist/components/render-empty.directive.d.ts +5 -5
- package/dist/components/rendering-field.d.ts +20 -20
- package/dist/components/rendering.d.ts +2 -2
- package/dist/components/rich-text.directive.d.ts +12 -12
- package/dist/components/router-link.directive.d.ts +12 -12
- package/dist/components/text.directive.d.ts +13 -13
- package/dist/esm2015/components/date.directive.js +63 -63
- package/dist/esm2015/components/file.directive.js +44 -44
- package/dist/esm2015/components/generic-link.directive.js +67 -67
- package/dist/esm2015/components/image.directive.js +131 -131
- package/dist/esm2015/components/link.directive.js +92 -92
- package/dist/esm2015/components/missing-component.component.js +14 -14
- package/dist/esm2015/components/placeholder-loading.directive.js +16 -16
- package/dist/esm2015/components/placeholder.component.js +205 -205
- package/dist/esm2015/components/placeholder.token.js +14 -14
- package/dist/esm2015/components/raw.component.js +37 -37
- package/dist/esm2015/components/render-component.component.js +93 -93
- package/dist/esm2015/components/render-each.directive.js +17 -17
- package/dist/esm2015/components/render-empty.directive.js +17 -17
- package/dist/esm2015/components/rendering.js +3 -3
- package/dist/esm2015/components/rich-text.directive.js +45 -45
- package/dist/esm2015/components/router-link.directive.js +51 -51
- package/dist/esm2015/components/text.directive.js +61 -61
- package/dist/esm2015/jss-component-factory.service.js +85 -85
- package/dist/esm2015/layout-service-error.js +2 -2
- package/dist/esm2015/layout.service.js +32 -32
- package/dist/esm2015/lib.module.js +115 -115
- package/dist/esm2015/public_api.js +15 -15
- package/dist/esm2015/sitecore-jss-sitecore-jss-angular.js +12 -12
- package/dist/esm5/components/date.directive.js +65 -65
- package/dist/esm5/components/file.directive.js +45 -45
- package/dist/esm5/components/generic-link.directive.js +72 -72
- package/dist/esm5/components/image.directive.js +139 -139
- package/dist/esm5/components/link.directive.js +101 -101
- package/dist/esm5/components/missing-component.component.js +17 -17
- package/dist/esm5/components/placeholder-loading.directive.js +17 -17
- package/dist/esm5/components/placeholder.component.js +216 -216
- package/dist/esm5/components/placeholder.token.js +18 -18
- package/dist/esm5/components/raw.component.js +38 -38
- package/dist/esm5/components/render-component.component.js +103 -103
- package/dist/esm5/components/render-each.directive.js +18 -18
- package/dist/esm5/components/render-empty.directive.js +18 -18
- package/dist/esm5/components/rendering.js +3 -3
- package/dist/esm5/components/rich-text.directive.js +46 -46
- package/dist/esm5/components/router-link.directive.js +56 -56
- package/dist/esm5/components/text.directive.js +62 -62
- package/dist/esm5/jss-component-factory.service.js +89 -89
- package/dist/esm5/layout-service-error.js +6 -6
- package/dist/esm5/layout.service.js +36 -36
- package/dist/esm5/lib.module.js +118 -118
- package/dist/esm5/public_api.js +15 -15
- package/dist/esm5/sitecore-jss-sitecore-jss-angular.js +12 -12
- package/dist/fesm2015/sitecore-jss-sitecore-jss-angular.js +1083 -1083
- package/dist/fesm5/sitecore-jss-sitecore-jss-angular.js +1160 -1160
- package/dist/jss-component-factory.service.d.ts +19 -19
- package/dist/layout-service-error.d.ts +8 -8
- package/dist/layout.service.d.ts +8 -8
- package/dist/lib.module.d.ts +16 -16
- package/dist/package.json +2 -2
- package/dist/public_api.d.ts +16 -16
- package/dist/sitecore-jss-sitecore-jss-angular.d.ts +12 -12
- package/package.json +3 -3
- package/typings/README.md +2 -2
|
@@ -7,1146 +7,1146 @@ import { Observable, throwError, from } from 'rxjs';
|
|
|
7
7
|
import { takeWhile, catchError } from 'rxjs/operators';
|
|
8
8
|
import { DatePipe, CommonModule } from '@angular/common';
|
|
9
9
|
|
|
10
|
-
/**
|
|
11
|
-
* File fields cannot be managed via the EE. We never output "editable."
|
|
12
|
-
*/
|
|
13
|
-
let FileDirective = class FileDirective {
|
|
14
|
-
constructor(viewContainer, templateRef) {
|
|
15
|
-
this.viewContainer = viewContainer;
|
|
16
|
-
this.templateRef = templateRef;
|
|
17
|
-
}
|
|
18
|
-
ngOnChanges(changes) {
|
|
19
|
-
if (changes['field']) {
|
|
20
|
-
if (!this.viewRef) {
|
|
21
|
-
this.viewContainer.clear();
|
|
22
|
-
this.viewRef = this.viewContainer.createEmbeddedView(this.templateRef);
|
|
23
|
-
}
|
|
24
|
-
this.updateView();
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
updateView() {
|
|
28
|
-
const field = this.field;
|
|
29
|
-
if (!field || (!field.value && !field.src)) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
const file = field.src ? field : field.value;
|
|
33
|
-
this.viewRef.rootNodes.forEach((node) => {
|
|
34
|
-
node.href = file.src;
|
|
35
|
-
if (node.innerHTML === '') {
|
|
36
|
-
node.innerHTML = file.title || file.displayName;
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
FileDirective.ctorParameters = () => [
|
|
42
|
-
{ type: ViewContainerRef },
|
|
43
|
-
{ type: TemplateRef }
|
|
44
|
-
];
|
|
45
|
-
__decorate([
|
|
46
|
-
Input('scFile')
|
|
47
|
-
], FileDirective.prototype, "field", void 0);
|
|
48
|
-
FileDirective = __decorate([
|
|
49
|
-
Directive({ selector: '[scFile]' })
|
|
10
|
+
/**
|
|
11
|
+
* File fields cannot be managed via the EE. We never output "editable."
|
|
12
|
+
*/
|
|
13
|
+
let FileDirective = class FileDirective {
|
|
14
|
+
constructor(viewContainer, templateRef) {
|
|
15
|
+
this.viewContainer = viewContainer;
|
|
16
|
+
this.templateRef = templateRef;
|
|
17
|
+
}
|
|
18
|
+
ngOnChanges(changes) {
|
|
19
|
+
if (changes['field']) {
|
|
20
|
+
if (!this.viewRef) {
|
|
21
|
+
this.viewContainer.clear();
|
|
22
|
+
this.viewRef = this.viewContainer.createEmbeddedView(this.templateRef);
|
|
23
|
+
}
|
|
24
|
+
this.updateView();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
updateView() {
|
|
28
|
+
const field = this.field;
|
|
29
|
+
if (!field || (!field.value && !field.src)) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const file = field.src ? field : field.value;
|
|
33
|
+
this.viewRef.rootNodes.forEach((node) => {
|
|
34
|
+
node.href = file.src;
|
|
35
|
+
if (node.innerHTML === '') {
|
|
36
|
+
node.innerHTML = file.title || file.displayName;
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
FileDirective.ctorParameters = () => [
|
|
42
|
+
{ type: ViewContainerRef },
|
|
43
|
+
{ type: TemplateRef }
|
|
44
|
+
];
|
|
45
|
+
__decorate([
|
|
46
|
+
Input('scFile')
|
|
47
|
+
], FileDirective.prototype, "field", void 0);
|
|
48
|
+
FileDirective = __decorate([
|
|
49
|
+
Directive({ selector: '[scFile]' })
|
|
50
50
|
], FileDirective);
|
|
51
51
|
|
|
52
|
-
let ImageDirective = class ImageDirective {
|
|
53
|
-
constructor(viewContainer, templateRef, renderer, elementRef) {
|
|
54
|
-
this.viewContainer = viewContainer;
|
|
55
|
-
this.templateRef = templateRef;
|
|
56
|
-
this.renderer = renderer;
|
|
57
|
-
this.elementRef = elementRef;
|
|
58
|
-
this.inlineRef = null;
|
|
59
|
-
// tslint:disable-next-line:no-input-rename
|
|
60
|
-
this.editable = true;
|
|
61
|
-
// tslint:disable-next-line:no-input-rename
|
|
62
|
-
this.urlParams = {};
|
|
63
|
-
// tslint:disable-next-line:no-input-rename
|
|
64
|
-
this.attrs = {};
|
|
65
|
-
}
|
|
66
|
-
ngOnChanges(changes) {
|
|
67
|
-
if (changes['field'] || changes['editable'] || changes['urlParams'] || changes['attrs']) {
|
|
68
|
-
this.viewContainer.clear();
|
|
69
|
-
if (this.inlineRef) {
|
|
70
|
-
this.inlineRef.remove();
|
|
71
|
-
this.inlineRef = null;
|
|
72
|
-
}
|
|
73
|
-
this.updateView();
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
updateView() {
|
|
77
|
-
const overrideAttrs = Object.assign({}, this.getElementAttrs(), this.attrs);
|
|
78
|
-
const media = this.field;
|
|
79
|
-
if (!media || (!media.editable && !media.value && !media.src)) {
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
let attrs = {};
|
|
83
|
-
// we likely have an experience editor value, should be a string
|
|
84
|
-
if (this.editable && media.editable) {
|
|
85
|
-
const foundImg = mediaApi.findEditorImageTag(media.editable);
|
|
86
|
-
if (!foundImg) {
|
|
87
|
-
return this.renderInlineWrapper(media.editable);
|
|
88
|
-
}
|
|
89
|
-
attrs = this.getImageAttrs(foundImg.attrs, overrideAttrs, this.urlParams);
|
|
90
|
-
if (!attrs) {
|
|
91
|
-
return this.renderInlineWrapper(media.editable);
|
|
92
|
-
}
|
|
93
|
-
const tempImg = this.renderer.createElement('img');
|
|
94
|
-
Object.entries(attrs).forEach(([key, attrValue]) => tempImg.setAttribute(key, attrValue));
|
|
95
|
-
const editableMarkup = media.editable.replace(foundImg.imgTag, tempImg.outerHTML);
|
|
96
|
-
return this.renderInlineWrapper(editableMarkup);
|
|
97
|
-
}
|
|
98
|
-
// some wise-guy/gal is passing in a 'raw' image object value
|
|
99
|
-
const img = media.src ? media : media.value;
|
|
100
|
-
if (!img) {
|
|
101
|
-
return null;
|
|
102
|
-
}
|
|
103
|
-
attrs = this.getImageAttrs(img, overrideAttrs, this.urlParams);
|
|
104
|
-
if (attrs) {
|
|
105
|
-
this.renderTemplate(attrs);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
getImageAttrs(fieldAttrs, parsedAttrs, imageParams) {
|
|
109
|
-
const combinedAttrs = Object.assign({}, fieldAttrs, parsedAttrs);
|
|
110
|
-
// tslint:disable-next-line:prefer-const
|
|
111
|
-
let { src, srcSet } = combinedAttrs, otherAttrs = __rest(combinedAttrs, ["src", "srcSet"]);
|
|
112
|
-
if (!src) {
|
|
113
|
-
return null;
|
|
114
|
-
}
|
|
115
|
-
const newAttrs = Object.assign({}, otherAttrs);
|
|
116
|
-
// update image URL for jss handler and image rendering params
|
|
117
|
-
src = mediaApi.updateImageUrl(src, imageParams);
|
|
118
|
-
if (srcSet) {
|
|
119
|
-
// replace with HTML-formatted srcset, including updated image URLs
|
|
120
|
-
newAttrs.srcSet = mediaApi.getSrcSet(src, srcSet, imageParams);
|
|
121
|
-
}
|
|
122
|
-
else {
|
|
123
|
-
newAttrs.src = src;
|
|
124
|
-
}
|
|
125
|
-
return newAttrs;
|
|
126
|
-
}
|
|
127
|
-
renderTemplate(imageProps) {
|
|
128
|
-
const viewRef = this.viewContainer.createEmbeddedView(this.templateRef);
|
|
129
|
-
viewRef.rootNodes.forEach((node) => {
|
|
130
|
-
Object.entries(imageProps).forEach(([key, imgPropVal]) => this.renderer.setAttribute(node, key, imgPropVal));
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
getElementAttrs() {
|
|
134
|
-
const view = this.templateRef.createEmbeddedView(null);
|
|
135
|
-
const element = view.rootNodes[0];
|
|
136
|
-
if (!element) {
|
|
137
|
-
return {};
|
|
138
|
-
}
|
|
139
|
-
const attrs = {};
|
|
140
|
-
for (let i = 0; i < element.attributes.length; i++) {
|
|
141
|
-
const attr = element.attributes.item(i);
|
|
142
|
-
if (attr) {
|
|
143
|
-
attrs[attr.name] = attr.value;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
return attrs;
|
|
147
|
-
}
|
|
148
|
-
renderInlineWrapper(editable) {
|
|
149
|
-
const span = this.renderer.createElement('span');
|
|
150
|
-
span.className = 'sc-image-wrapper';
|
|
151
|
-
span.innerHTML = editable;
|
|
152
|
-
const parentNode = this.renderer.parentNode(this.elementRef.nativeElement);
|
|
153
|
-
this.renderer.insertBefore(parentNode, span, this.elementRef.nativeElement);
|
|
154
|
-
parentNode.removeChild(this.elementRef.nativeElement);
|
|
155
|
-
this.inlineRef = span;
|
|
156
|
-
}
|
|
157
|
-
};
|
|
158
|
-
ImageDirective.ctorParameters = () => [
|
|
159
|
-
{ type: ViewContainerRef },
|
|
160
|
-
{ type: TemplateRef },
|
|
161
|
-
{ type: Renderer2 },
|
|
162
|
-
{ type: ElementRef }
|
|
163
|
-
];
|
|
164
|
-
__decorate([
|
|
165
|
-
Input('scImage')
|
|
166
|
-
], ImageDirective.prototype, "field", void 0);
|
|
167
|
-
__decorate([
|
|
168
|
-
Input('scImageEditable')
|
|
169
|
-
], ImageDirective.prototype, "editable", void 0);
|
|
170
|
-
__decorate([
|
|
171
|
-
Input('scImageUrlParams')
|
|
172
|
-
], ImageDirective.prototype, "urlParams", void 0);
|
|
173
|
-
__decorate([
|
|
174
|
-
Input('scImageAttrs')
|
|
175
|
-
], ImageDirective.prototype, "attrs", void 0);
|
|
176
|
-
ImageDirective = __decorate([
|
|
177
|
-
Directive({ selector: '[scImage]' })
|
|
52
|
+
let ImageDirective = class ImageDirective {
|
|
53
|
+
constructor(viewContainer, templateRef, renderer, elementRef) {
|
|
54
|
+
this.viewContainer = viewContainer;
|
|
55
|
+
this.templateRef = templateRef;
|
|
56
|
+
this.renderer = renderer;
|
|
57
|
+
this.elementRef = elementRef;
|
|
58
|
+
this.inlineRef = null;
|
|
59
|
+
// tslint:disable-next-line:no-input-rename
|
|
60
|
+
this.editable = true;
|
|
61
|
+
// tslint:disable-next-line:no-input-rename
|
|
62
|
+
this.urlParams = {};
|
|
63
|
+
// tslint:disable-next-line:no-input-rename
|
|
64
|
+
this.attrs = {};
|
|
65
|
+
}
|
|
66
|
+
ngOnChanges(changes) {
|
|
67
|
+
if (changes['field'] || changes['editable'] || changes['urlParams'] || changes['attrs']) {
|
|
68
|
+
this.viewContainer.clear();
|
|
69
|
+
if (this.inlineRef) {
|
|
70
|
+
this.inlineRef.remove();
|
|
71
|
+
this.inlineRef = null;
|
|
72
|
+
}
|
|
73
|
+
this.updateView();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
updateView() {
|
|
77
|
+
const overrideAttrs = Object.assign({}, this.getElementAttrs(), this.attrs);
|
|
78
|
+
const media = this.field;
|
|
79
|
+
if (!media || (!media.editable && !media.value && !media.src)) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
let attrs = {};
|
|
83
|
+
// we likely have an experience editor value, should be a string
|
|
84
|
+
if (this.editable && media.editable) {
|
|
85
|
+
const foundImg = mediaApi.findEditorImageTag(media.editable);
|
|
86
|
+
if (!foundImg) {
|
|
87
|
+
return this.renderInlineWrapper(media.editable);
|
|
88
|
+
}
|
|
89
|
+
attrs = this.getImageAttrs(foundImg.attrs, overrideAttrs, this.urlParams);
|
|
90
|
+
if (!attrs) {
|
|
91
|
+
return this.renderInlineWrapper(media.editable);
|
|
92
|
+
}
|
|
93
|
+
const tempImg = this.renderer.createElement('img');
|
|
94
|
+
Object.entries(attrs).forEach(([key, attrValue]) => tempImg.setAttribute(key, attrValue));
|
|
95
|
+
const editableMarkup = media.editable.replace(foundImg.imgTag, tempImg.outerHTML);
|
|
96
|
+
return this.renderInlineWrapper(editableMarkup);
|
|
97
|
+
}
|
|
98
|
+
// some wise-guy/gal is passing in a 'raw' image object value
|
|
99
|
+
const img = media.src ? media : media.value;
|
|
100
|
+
if (!img) {
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
attrs = this.getImageAttrs(img, overrideAttrs, this.urlParams);
|
|
104
|
+
if (attrs) {
|
|
105
|
+
this.renderTemplate(attrs);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
getImageAttrs(fieldAttrs, parsedAttrs, imageParams) {
|
|
109
|
+
const combinedAttrs = Object.assign({}, fieldAttrs, parsedAttrs);
|
|
110
|
+
// tslint:disable-next-line:prefer-const
|
|
111
|
+
let { src, srcSet } = combinedAttrs, otherAttrs = __rest(combinedAttrs, ["src", "srcSet"]);
|
|
112
|
+
if (!src) {
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
const newAttrs = Object.assign({}, otherAttrs);
|
|
116
|
+
// update image URL for jss handler and image rendering params
|
|
117
|
+
src = mediaApi.updateImageUrl(src, imageParams);
|
|
118
|
+
if (srcSet) {
|
|
119
|
+
// replace with HTML-formatted srcset, including updated image URLs
|
|
120
|
+
newAttrs.srcSet = mediaApi.getSrcSet(src, srcSet, imageParams);
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
newAttrs.src = src;
|
|
124
|
+
}
|
|
125
|
+
return newAttrs;
|
|
126
|
+
}
|
|
127
|
+
renderTemplate(imageProps) {
|
|
128
|
+
const viewRef = this.viewContainer.createEmbeddedView(this.templateRef);
|
|
129
|
+
viewRef.rootNodes.forEach((node) => {
|
|
130
|
+
Object.entries(imageProps).forEach(([key, imgPropVal]) => this.renderer.setAttribute(node, key, imgPropVal));
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
getElementAttrs() {
|
|
134
|
+
const view = this.templateRef.createEmbeddedView(null);
|
|
135
|
+
const element = view.rootNodes[0];
|
|
136
|
+
if (!element) {
|
|
137
|
+
return {};
|
|
138
|
+
}
|
|
139
|
+
const attrs = {};
|
|
140
|
+
for (let i = 0; i < element.attributes.length; i++) {
|
|
141
|
+
const attr = element.attributes.item(i);
|
|
142
|
+
if (attr) {
|
|
143
|
+
attrs[attr.name] = attr.value;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return attrs;
|
|
147
|
+
}
|
|
148
|
+
renderInlineWrapper(editable) {
|
|
149
|
+
const span = this.renderer.createElement('span');
|
|
150
|
+
span.className = 'sc-image-wrapper';
|
|
151
|
+
span.innerHTML = editable;
|
|
152
|
+
const parentNode = this.renderer.parentNode(this.elementRef.nativeElement);
|
|
153
|
+
this.renderer.insertBefore(parentNode, span, this.elementRef.nativeElement);
|
|
154
|
+
parentNode.removeChild(this.elementRef.nativeElement);
|
|
155
|
+
this.inlineRef = span;
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
ImageDirective.ctorParameters = () => [
|
|
159
|
+
{ type: ViewContainerRef },
|
|
160
|
+
{ type: TemplateRef },
|
|
161
|
+
{ type: Renderer2 },
|
|
162
|
+
{ type: ElementRef }
|
|
163
|
+
];
|
|
164
|
+
__decorate([
|
|
165
|
+
Input('scImage')
|
|
166
|
+
], ImageDirective.prototype, "field", void 0);
|
|
167
|
+
__decorate([
|
|
168
|
+
Input('scImageEditable')
|
|
169
|
+
], ImageDirective.prototype, "editable", void 0);
|
|
170
|
+
__decorate([
|
|
171
|
+
Input('scImageUrlParams')
|
|
172
|
+
], ImageDirective.prototype, "urlParams", void 0);
|
|
173
|
+
__decorate([
|
|
174
|
+
Input('scImageAttrs')
|
|
175
|
+
], ImageDirective.prototype, "attrs", void 0);
|
|
176
|
+
ImageDirective = __decorate([
|
|
177
|
+
Directive({ selector: '[scImage]' })
|
|
178
178
|
], ImageDirective);
|
|
179
179
|
|
|
180
|
-
let LinkDirective = class LinkDirective {
|
|
181
|
-
constructor(viewContainer, templateRef, renderer, elementRef) {
|
|
182
|
-
this.viewContainer = viewContainer;
|
|
183
|
-
this.templateRef = templateRef;
|
|
184
|
-
this.renderer = renderer;
|
|
185
|
-
this.elementRef = elementRef;
|
|
186
|
-
this.inlineRef = null;
|
|
187
|
-
// tslint:disable-next-line:no-input-rename
|
|
188
|
-
this.editable = true;
|
|
189
|
-
// tslint:disable-next-line:no-input-rename
|
|
190
|
-
this.attrs = {};
|
|
191
|
-
}
|
|
192
|
-
ngOnChanges(changes) {
|
|
193
|
-
if (changes['field'] || changes['editable'] || changes['attrs']) {
|
|
194
|
-
this.viewContainer.clear();
|
|
195
|
-
if (this.inlineRef) {
|
|
196
|
-
this.inlineRef.remove();
|
|
197
|
-
this.inlineRef = null;
|
|
198
|
-
}
|
|
199
|
-
this.updateView();
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
updateView() {
|
|
203
|
-
const field = this.field;
|
|
204
|
-
if (this.editable && field && field.editableFirstPart && field.editableLastPart) {
|
|
205
|
-
this.renderInlineWrapper(field.editableFirstPart, field.editableLastPart);
|
|
206
|
-
}
|
|
207
|
-
else if (field && (field.href || field.value)) {
|
|
208
|
-
const props = field.href ? field : field.value;
|
|
209
|
-
const linkText = field.text || field.value.text || field.href || field.value.href;
|
|
210
|
-
const mergedAttrs = Object.assign({}, props, this.attrs);
|
|
211
|
-
this.renderTemplate(mergedAttrs, linkText);
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
renderTemplate(props, linkText) {
|
|
215
|
-
const viewRef = this.viewContainer.createEmbeddedView(this.templateRef);
|
|
216
|
-
viewRef.rootNodes.forEach((node) => {
|
|
217
|
-
Object.entries(props).forEach(([key, propValue]) => this.renderer.setAttribute(node, key, propValue));
|
|
218
|
-
if (node.childNodes && node.childNodes.length === 0 && linkText) {
|
|
219
|
-
node.textContent = linkText;
|
|
220
|
-
}
|
|
221
|
-
});
|
|
222
|
-
}
|
|
223
|
-
renderInlineWrapper(editableFirstPart, editableLastPart) {
|
|
224
|
-
const span = this.renderer.createElement('span');
|
|
225
|
-
span.className = 'sc-link-wrapper';
|
|
226
|
-
span.innerHTML = editableFirstPart + editableLastPart;
|
|
227
|
-
// assign attributes from template to inline wrapper
|
|
228
|
-
const attrs = Object.assign({}, this.getElementAttrs(), this.attrs);
|
|
229
|
-
Object.entries(attrs).forEach(([key, attrValue]) => this.renderer.setAttribute(span, key, attrValue));
|
|
230
|
-
this.viewContainer.createEmbeddedView(this.templateRef);
|
|
231
|
-
const parentNode = this.renderer.parentNode(this.elementRef.nativeElement);
|
|
232
|
-
this.renderer.insertBefore(parentNode, span, this.elementRef.nativeElement);
|
|
233
|
-
this.inlineRef = span;
|
|
234
|
-
}
|
|
235
|
-
getElementAttrs() {
|
|
236
|
-
const view = this.templateRef.createEmbeddedView(null);
|
|
237
|
-
const element = view.rootNodes[0];
|
|
238
|
-
if (!element) {
|
|
239
|
-
return {};
|
|
240
|
-
}
|
|
241
|
-
const attrs = {};
|
|
242
|
-
for (let i = 0; i < element.attributes.length; i++) {
|
|
243
|
-
const attr = element.attributes.item(i);
|
|
244
|
-
if (attr) {
|
|
245
|
-
attrs[attr.name] = attr.value;
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
return attrs;
|
|
249
|
-
}
|
|
250
|
-
};
|
|
251
|
-
LinkDirective.ctorParameters = () => [
|
|
252
|
-
{ type: ViewContainerRef },
|
|
253
|
-
{ type: TemplateRef },
|
|
254
|
-
{ type: Renderer2 },
|
|
255
|
-
{ type: ElementRef }
|
|
256
|
-
];
|
|
257
|
-
__decorate([
|
|
258
|
-
Input('scLinkEditable')
|
|
259
|
-
], LinkDirective.prototype, "editable", void 0);
|
|
260
|
-
__decorate([
|
|
261
|
-
Input('scLinkAttrs')
|
|
262
|
-
], LinkDirective.prototype, "attrs", void 0);
|
|
263
|
-
__decorate([
|
|
264
|
-
Input('scLink')
|
|
265
|
-
], LinkDirective.prototype, "field", void 0);
|
|
266
|
-
LinkDirective = __decorate([
|
|
267
|
-
Directive({ selector: '[scLink]' })
|
|
180
|
+
let LinkDirective = class LinkDirective {
|
|
181
|
+
constructor(viewContainer, templateRef, renderer, elementRef) {
|
|
182
|
+
this.viewContainer = viewContainer;
|
|
183
|
+
this.templateRef = templateRef;
|
|
184
|
+
this.renderer = renderer;
|
|
185
|
+
this.elementRef = elementRef;
|
|
186
|
+
this.inlineRef = null;
|
|
187
|
+
// tslint:disable-next-line:no-input-rename
|
|
188
|
+
this.editable = true;
|
|
189
|
+
// tslint:disable-next-line:no-input-rename
|
|
190
|
+
this.attrs = {};
|
|
191
|
+
}
|
|
192
|
+
ngOnChanges(changes) {
|
|
193
|
+
if (changes['field'] || changes['editable'] || changes['attrs']) {
|
|
194
|
+
this.viewContainer.clear();
|
|
195
|
+
if (this.inlineRef) {
|
|
196
|
+
this.inlineRef.remove();
|
|
197
|
+
this.inlineRef = null;
|
|
198
|
+
}
|
|
199
|
+
this.updateView();
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
updateView() {
|
|
203
|
+
const field = this.field;
|
|
204
|
+
if (this.editable && field && field.editableFirstPart && field.editableLastPart) {
|
|
205
|
+
this.renderInlineWrapper(field.editableFirstPart, field.editableLastPart);
|
|
206
|
+
}
|
|
207
|
+
else if (field && (field.href || field.value)) {
|
|
208
|
+
const props = field.href ? field : field.value;
|
|
209
|
+
const linkText = field.text || field.value.text || field.href || field.value.href;
|
|
210
|
+
const mergedAttrs = Object.assign({}, props, this.attrs);
|
|
211
|
+
this.renderTemplate(mergedAttrs, linkText);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
renderTemplate(props, linkText) {
|
|
215
|
+
const viewRef = this.viewContainer.createEmbeddedView(this.templateRef);
|
|
216
|
+
viewRef.rootNodes.forEach((node) => {
|
|
217
|
+
Object.entries(props).forEach(([key, propValue]) => this.renderer.setAttribute(node, key, propValue));
|
|
218
|
+
if (node.childNodes && node.childNodes.length === 0 && linkText) {
|
|
219
|
+
node.textContent = linkText;
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
renderInlineWrapper(editableFirstPart, editableLastPart) {
|
|
224
|
+
const span = this.renderer.createElement('span');
|
|
225
|
+
span.className = 'sc-link-wrapper';
|
|
226
|
+
span.innerHTML = editableFirstPart + editableLastPart;
|
|
227
|
+
// assign attributes from template to inline wrapper
|
|
228
|
+
const attrs = Object.assign({}, this.getElementAttrs(), this.attrs);
|
|
229
|
+
Object.entries(attrs).forEach(([key, attrValue]) => this.renderer.setAttribute(span, key, attrValue));
|
|
230
|
+
this.viewContainer.createEmbeddedView(this.templateRef);
|
|
231
|
+
const parentNode = this.renderer.parentNode(this.elementRef.nativeElement);
|
|
232
|
+
this.renderer.insertBefore(parentNode, span, this.elementRef.nativeElement);
|
|
233
|
+
this.inlineRef = span;
|
|
234
|
+
}
|
|
235
|
+
getElementAttrs() {
|
|
236
|
+
const view = this.templateRef.createEmbeddedView(null);
|
|
237
|
+
const element = view.rootNodes[0];
|
|
238
|
+
if (!element) {
|
|
239
|
+
return {};
|
|
240
|
+
}
|
|
241
|
+
const attrs = {};
|
|
242
|
+
for (let i = 0; i < element.attributes.length; i++) {
|
|
243
|
+
const attr = element.attributes.item(i);
|
|
244
|
+
if (attr) {
|
|
245
|
+
attrs[attr.name] = attr.value;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
return attrs;
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
LinkDirective.ctorParameters = () => [
|
|
252
|
+
{ type: ViewContainerRef },
|
|
253
|
+
{ type: TemplateRef },
|
|
254
|
+
{ type: Renderer2 },
|
|
255
|
+
{ type: ElementRef }
|
|
256
|
+
];
|
|
257
|
+
__decorate([
|
|
258
|
+
Input('scLinkEditable')
|
|
259
|
+
], LinkDirective.prototype, "editable", void 0);
|
|
260
|
+
__decorate([
|
|
261
|
+
Input('scLinkAttrs')
|
|
262
|
+
], LinkDirective.prototype, "attrs", void 0);
|
|
263
|
+
__decorate([
|
|
264
|
+
Input('scLink')
|
|
265
|
+
], LinkDirective.prototype, "field", void 0);
|
|
266
|
+
LinkDirective = __decorate([
|
|
267
|
+
Directive({ selector: '[scLink]' })
|
|
268
268
|
], LinkDirective);
|
|
269
269
|
|
|
270
|
-
let RouterLinkDirective = class RouterLinkDirective extends LinkDirective {
|
|
271
|
-
constructor(viewContainer, templateRef, renderer, elementRef, router) {
|
|
272
|
-
super(viewContainer, templateRef, renderer, elementRef);
|
|
273
|
-
this.router = router;
|
|
274
|
-
// tslint:disable-next-line:no-input-rename
|
|
275
|
-
this.editable = true;
|
|
276
|
-
// tslint:disable-next-line:no-input-rename
|
|
277
|
-
this.attrs = {};
|
|
278
|
-
}
|
|
279
|
-
renderTemplate(props, linkText) {
|
|
280
|
-
const viewRef = this.viewContainer.createEmbeddedView(this.templateRef);
|
|
281
|
-
viewRef.rootNodes.forEach((node) => {
|
|
282
|
-
Object.entries(props).forEach(([key, propValue]) => {
|
|
283
|
-
this.renderer.setAttribute(node, key, propValue);
|
|
284
|
-
if (key === 'href') {
|
|
285
|
-
this.renderer.listen(node, 'click', (event) => {
|
|
286
|
-
this.router.navigate([propValue]);
|
|
287
|
-
event.preventDefault();
|
|
288
|
-
});
|
|
289
|
-
}
|
|
290
|
-
});
|
|
291
|
-
if (node.childNodes && node.childNodes.length === 0 && linkText) {
|
|
292
|
-
node.textContent = linkText;
|
|
293
|
-
}
|
|
294
|
-
});
|
|
295
|
-
}
|
|
296
|
-
};
|
|
297
|
-
RouterLinkDirective.ctorParameters = () => [
|
|
298
|
-
{ type: ViewContainerRef },
|
|
299
|
-
{ type: TemplateRef },
|
|
300
|
-
{ type: Renderer2 },
|
|
301
|
-
{ type: ElementRef },
|
|
302
|
-
{ type: Router }
|
|
303
|
-
];
|
|
304
|
-
__decorate([
|
|
305
|
-
Input('scRouterLinkEditable')
|
|
306
|
-
], RouterLinkDirective.prototype, "editable", void 0);
|
|
307
|
-
__decorate([
|
|
308
|
-
Input('scRouterLinkAttrs')
|
|
309
|
-
], RouterLinkDirective.prototype, "attrs", void 0);
|
|
310
|
-
__decorate([
|
|
311
|
-
Input('scRouterLink')
|
|
312
|
-
], RouterLinkDirective.prototype, "field", void 0);
|
|
313
|
-
RouterLinkDirective = __decorate([
|
|
314
|
-
Directive({ selector: '[scRouterLink]' })
|
|
270
|
+
let RouterLinkDirective = class RouterLinkDirective extends LinkDirective {
|
|
271
|
+
constructor(viewContainer, templateRef, renderer, elementRef, router) {
|
|
272
|
+
super(viewContainer, templateRef, renderer, elementRef);
|
|
273
|
+
this.router = router;
|
|
274
|
+
// tslint:disable-next-line:no-input-rename
|
|
275
|
+
this.editable = true;
|
|
276
|
+
// tslint:disable-next-line:no-input-rename
|
|
277
|
+
this.attrs = {};
|
|
278
|
+
}
|
|
279
|
+
renderTemplate(props, linkText) {
|
|
280
|
+
const viewRef = this.viewContainer.createEmbeddedView(this.templateRef);
|
|
281
|
+
viewRef.rootNodes.forEach((node) => {
|
|
282
|
+
Object.entries(props).forEach(([key, propValue]) => {
|
|
283
|
+
this.renderer.setAttribute(node, key, propValue);
|
|
284
|
+
if (key === 'href') {
|
|
285
|
+
this.renderer.listen(node, 'click', (event) => {
|
|
286
|
+
this.router.navigate([propValue]);
|
|
287
|
+
event.preventDefault();
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
if (node.childNodes && node.childNodes.length === 0 && linkText) {
|
|
292
|
+
node.textContent = linkText;
|
|
293
|
+
}
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
RouterLinkDirective.ctorParameters = () => [
|
|
298
|
+
{ type: ViewContainerRef },
|
|
299
|
+
{ type: TemplateRef },
|
|
300
|
+
{ type: Renderer2 },
|
|
301
|
+
{ type: ElementRef },
|
|
302
|
+
{ type: Router }
|
|
303
|
+
];
|
|
304
|
+
__decorate([
|
|
305
|
+
Input('scRouterLinkEditable')
|
|
306
|
+
], RouterLinkDirective.prototype, "editable", void 0);
|
|
307
|
+
__decorate([
|
|
308
|
+
Input('scRouterLinkAttrs')
|
|
309
|
+
], RouterLinkDirective.prototype, "attrs", void 0);
|
|
310
|
+
__decorate([
|
|
311
|
+
Input('scRouterLink')
|
|
312
|
+
], RouterLinkDirective.prototype, "field", void 0);
|
|
313
|
+
RouterLinkDirective = __decorate([
|
|
314
|
+
Directive({ selector: '[scRouterLink]' })
|
|
315
315
|
], RouterLinkDirective);
|
|
316
316
|
|
|
317
|
-
let GenericLinkDirective = class GenericLinkDirective extends LinkDirective {
|
|
318
|
-
constructor(viewContainer, templateRef, renderer, elementRef, router) {
|
|
319
|
-
super(viewContainer, templateRef, renderer, elementRef);
|
|
320
|
-
this.router = router;
|
|
321
|
-
// tslint:disable-next-line:no-input-rename
|
|
322
|
-
this.editable = true;
|
|
323
|
-
// tslint:disable-next-line:no-input-rename
|
|
324
|
-
this.attrs = {};
|
|
325
|
-
}
|
|
326
|
-
renderTemplate(props, linkText) {
|
|
327
|
-
const viewRef = this.viewContainer.createEmbeddedView(this.templateRef);
|
|
328
|
-
viewRef.rootNodes.forEach((node) => {
|
|
329
|
-
Object.entries(props).forEach(([key, propValue]) => {
|
|
330
|
-
if (key === 'href' && !this.isAbsoluteUrl(propValue)) {
|
|
331
|
-
const urlTree = this.router.createUrlTree([propValue], this.extras);
|
|
332
|
-
this.renderer.setAttribute(node, key, this.router.serializeUrl(urlTree));
|
|
333
|
-
this.renderer.listen(node, 'click', (event) => {
|
|
334
|
-
this.router.navigate([propValue], this.extras);
|
|
335
|
-
event.preventDefault();
|
|
336
|
-
});
|
|
337
|
-
}
|
|
338
|
-
else {
|
|
339
|
-
this.renderer.setAttribute(node, key, propValue);
|
|
340
|
-
}
|
|
341
|
-
});
|
|
342
|
-
if (node.childNodes && node.childNodes.length === 0 && linkText) {
|
|
343
|
-
node.textContent = linkText;
|
|
344
|
-
}
|
|
345
|
-
});
|
|
346
|
-
}
|
|
347
|
-
isAbsoluteUrl(url) {
|
|
348
|
-
if (url == null) {
|
|
349
|
-
return false;
|
|
350
|
-
}
|
|
351
|
-
if (typeof url !== 'string') {
|
|
352
|
-
throw new TypeError('Expected a string');
|
|
353
|
-
}
|
|
354
|
-
return /^[a-z][a-z0-9+.-]*:/.test(url);
|
|
355
|
-
}
|
|
356
|
-
};
|
|
357
|
-
GenericLinkDirective.ctorParameters = () => [
|
|
358
|
-
{ type: ViewContainerRef },
|
|
359
|
-
{ type: TemplateRef },
|
|
360
|
-
{ type: Renderer2 },
|
|
361
|
-
{ type: ElementRef },
|
|
362
|
-
{ type: Router }
|
|
363
|
-
];
|
|
364
|
-
__decorate([
|
|
365
|
-
Input('scGenericLinkEditable')
|
|
366
|
-
], GenericLinkDirective.prototype, "editable", void 0);
|
|
367
|
-
__decorate([
|
|
368
|
-
Input('scGenericLinkAttrs')
|
|
369
|
-
], GenericLinkDirective.prototype, "attrs", void 0);
|
|
370
|
-
__decorate([
|
|
371
|
-
Input('scGenericLink')
|
|
372
|
-
], GenericLinkDirective.prototype, "field", void 0);
|
|
373
|
-
__decorate([
|
|
374
|
-
Input('scGenericLinkExtras')
|
|
375
|
-
], GenericLinkDirective.prototype, "extras", void 0);
|
|
376
|
-
GenericLinkDirective = __decorate([
|
|
377
|
-
Directive({ selector: '[scGenericLink]' })
|
|
317
|
+
let GenericLinkDirective = class GenericLinkDirective extends LinkDirective {
|
|
318
|
+
constructor(viewContainer, templateRef, renderer, elementRef, router) {
|
|
319
|
+
super(viewContainer, templateRef, renderer, elementRef);
|
|
320
|
+
this.router = router;
|
|
321
|
+
// tslint:disable-next-line:no-input-rename
|
|
322
|
+
this.editable = true;
|
|
323
|
+
// tslint:disable-next-line:no-input-rename
|
|
324
|
+
this.attrs = {};
|
|
325
|
+
}
|
|
326
|
+
renderTemplate(props, linkText) {
|
|
327
|
+
const viewRef = this.viewContainer.createEmbeddedView(this.templateRef);
|
|
328
|
+
viewRef.rootNodes.forEach((node) => {
|
|
329
|
+
Object.entries(props).forEach(([key, propValue]) => {
|
|
330
|
+
if (key === 'href' && !this.isAbsoluteUrl(propValue)) {
|
|
331
|
+
const urlTree = this.router.createUrlTree([propValue], this.extras);
|
|
332
|
+
this.renderer.setAttribute(node, key, this.router.serializeUrl(urlTree));
|
|
333
|
+
this.renderer.listen(node, 'click', (event) => {
|
|
334
|
+
this.router.navigate([propValue], this.extras);
|
|
335
|
+
event.preventDefault();
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
else {
|
|
339
|
+
this.renderer.setAttribute(node, key, propValue);
|
|
340
|
+
}
|
|
341
|
+
});
|
|
342
|
+
if (node.childNodes && node.childNodes.length === 0 && linkText) {
|
|
343
|
+
node.textContent = linkText;
|
|
344
|
+
}
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
isAbsoluteUrl(url) {
|
|
348
|
+
if (url == null) {
|
|
349
|
+
return false;
|
|
350
|
+
}
|
|
351
|
+
if (typeof url !== 'string') {
|
|
352
|
+
throw new TypeError('Expected a string');
|
|
353
|
+
}
|
|
354
|
+
return /^[a-z][a-z0-9+.-]*:/.test(url);
|
|
355
|
+
}
|
|
356
|
+
};
|
|
357
|
+
GenericLinkDirective.ctorParameters = () => [
|
|
358
|
+
{ type: ViewContainerRef },
|
|
359
|
+
{ type: TemplateRef },
|
|
360
|
+
{ type: Renderer2 },
|
|
361
|
+
{ type: ElementRef },
|
|
362
|
+
{ type: Router }
|
|
363
|
+
];
|
|
364
|
+
__decorate([
|
|
365
|
+
Input('scGenericLinkEditable')
|
|
366
|
+
], GenericLinkDirective.prototype, "editable", void 0);
|
|
367
|
+
__decorate([
|
|
368
|
+
Input('scGenericLinkAttrs')
|
|
369
|
+
], GenericLinkDirective.prototype, "attrs", void 0);
|
|
370
|
+
__decorate([
|
|
371
|
+
Input('scGenericLink')
|
|
372
|
+
], GenericLinkDirective.prototype, "field", void 0);
|
|
373
|
+
__decorate([
|
|
374
|
+
Input('scGenericLinkExtras')
|
|
375
|
+
], GenericLinkDirective.prototype, "extras", void 0);
|
|
376
|
+
GenericLinkDirective = __decorate([
|
|
377
|
+
Directive({ selector: '[scGenericLink]' })
|
|
378
378
|
], GenericLinkDirective);
|
|
379
379
|
|
|
380
|
-
/** Registers a statically loaded component */
|
|
381
|
-
class ComponentNameAndType {
|
|
382
|
-
}
|
|
383
|
-
function instanceOfComponentNameAndType(object) {
|
|
384
|
-
return 'type' in object;
|
|
385
|
-
}
|
|
386
|
-
function instanceOfComponentNameAndModule(object) {
|
|
387
|
-
return 'module' in object;
|
|
388
|
-
}
|
|
389
|
-
const PLACEHOLDER_COMPONENTS = new InjectionToken('Sc.placeholder.components');
|
|
390
|
-
const PLACEHOLDER_LAZY_COMPONENTS = new InjectionToken('Sc.placeholder.lazyComponents');
|
|
391
|
-
const PLACEHOLDER_MISSING_COMPONENT_COMPONENT = new InjectionToken('Sc.placeholder.missingComponentComponent');
|
|
380
|
+
/** Registers a statically loaded component */
|
|
381
|
+
class ComponentNameAndType {
|
|
382
|
+
}
|
|
383
|
+
function instanceOfComponentNameAndType(object) {
|
|
384
|
+
return 'type' in object;
|
|
385
|
+
}
|
|
386
|
+
function instanceOfComponentNameAndModule(object) {
|
|
387
|
+
return 'module' in object;
|
|
388
|
+
}
|
|
389
|
+
const PLACEHOLDER_COMPONENTS = new InjectionToken('Sc.placeholder.components');
|
|
390
|
+
const PLACEHOLDER_LAZY_COMPONENTS = new InjectionToken('Sc.placeholder.lazyComponents');
|
|
391
|
+
const PLACEHOLDER_MISSING_COMPONENT_COMPONENT = new InjectionToken('Sc.placeholder.missingComponentComponent');
|
|
392
392
|
const DYNAMIC_COMPONENT = new InjectionToken('Sc.placeholder.dynamicComponent');
|
|
393
393
|
|
|
394
|
-
let RawComponent = class RawComponent {
|
|
395
|
-
constructor(renderer, elementRef) {
|
|
396
|
-
this.renderer = renderer;
|
|
397
|
-
this.elementRef = elementRef;
|
|
398
|
-
}
|
|
399
|
-
ngOnInit() {
|
|
400
|
-
const el = this.renderer.createElement(this.rendering.name);
|
|
401
|
-
const contents = this.renderer.createText(this.rendering.contents || '');
|
|
402
|
-
const attributes = this.rendering.attributes;
|
|
403
|
-
for (const attr in attributes) {
|
|
404
|
-
if (attributes.hasOwnProperty(attr)) {
|
|
405
|
-
const value = attributes[attr];
|
|
406
|
-
this.renderer.setAttribute(el, attr, value || '');
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
this.renderer.appendChild(el, contents);
|
|
410
|
-
const parentNode = this.renderer.parentNode(this.elementRef.nativeElement);
|
|
411
|
-
this.renderer.insertBefore(parentNode, el, this.elementRef.nativeElement);
|
|
412
|
-
parentNode.removeChild(this.elementRef.nativeElement);
|
|
413
|
-
}
|
|
414
|
-
};
|
|
415
|
-
RawComponent.ctorParameters = () => [
|
|
416
|
-
{ type: Renderer2 },
|
|
417
|
-
{ type: ElementRef }
|
|
418
|
-
];
|
|
419
|
-
__decorate([
|
|
420
|
-
Input()
|
|
421
|
-
], RawComponent.prototype, "rendering", void 0);
|
|
422
|
-
RawComponent = __decorate([
|
|
423
|
-
Component({
|
|
424
|
-
selector: 'sc-raw',
|
|
425
|
-
template: ``
|
|
426
|
-
})
|
|
394
|
+
let RawComponent = class RawComponent {
|
|
395
|
+
constructor(renderer, elementRef) {
|
|
396
|
+
this.renderer = renderer;
|
|
397
|
+
this.elementRef = elementRef;
|
|
398
|
+
}
|
|
399
|
+
ngOnInit() {
|
|
400
|
+
const el = this.renderer.createElement(this.rendering.name);
|
|
401
|
+
const contents = this.renderer.createText(this.rendering.contents || '');
|
|
402
|
+
const attributes = this.rendering.attributes;
|
|
403
|
+
for (const attr in attributes) {
|
|
404
|
+
if (attributes.hasOwnProperty(attr)) {
|
|
405
|
+
const value = attributes[attr];
|
|
406
|
+
this.renderer.setAttribute(el, attr, value || '');
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
this.renderer.appendChild(el, contents);
|
|
410
|
+
const parentNode = this.renderer.parentNode(this.elementRef.nativeElement);
|
|
411
|
+
this.renderer.insertBefore(parentNode, el, this.elementRef.nativeElement);
|
|
412
|
+
parentNode.removeChild(this.elementRef.nativeElement);
|
|
413
|
+
}
|
|
414
|
+
};
|
|
415
|
+
RawComponent.ctorParameters = () => [
|
|
416
|
+
{ type: Renderer2 },
|
|
417
|
+
{ type: ElementRef }
|
|
418
|
+
];
|
|
419
|
+
__decorate([
|
|
420
|
+
Input()
|
|
421
|
+
], RawComponent.prototype, "rendering", void 0);
|
|
422
|
+
RawComponent = __decorate([
|
|
423
|
+
Component({
|
|
424
|
+
selector: 'sc-raw',
|
|
425
|
+
template: ``
|
|
426
|
+
})
|
|
427
427
|
], RawComponent);
|
|
428
428
|
|
|
429
|
-
function isRawRendering(rendering) {
|
|
430
|
-
return !rendering.componentName && rendering.name !== undefined;
|
|
429
|
+
function isRawRendering(rendering) {
|
|
430
|
+
return !rendering.componentName && rendering.name !== undefined;
|
|
431
431
|
}
|
|
432
432
|
|
|
433
|
-
let JssComponentFactoryService = class JssComponentFactoryService {
|
|
434
|
-
constructor(injector, components, lazyComponents) {
|
|
435
|
-
this.injector = injector;
|
|
436
|
-
this.components = components;
|
|
437
|
-
this.lazyComponents = lazyComponents;
|
|
438
|
-
this.componentMap = new Map();
|
|
439
|
-
this.lazyComponentMap = new Map();
|
|
440
|
-
this.components.forEach((c) => this.componentMap.set(c.name, c.type));
|
|
441
|
-
if (this.lazyComponents) {
|
|
442
|
-
this.lazyComponents.forEach((c) => this.lazyComponentMap.set(c.path, c));
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
getComponent(component) {
|
|
446
|
-
const loadedComponent = this.componentMap.get(component.componentName);
|
|
447
|
-
if (loadedComponent) {
|
|
448
|
-
return Promise.resolve({
|
|
449
|
-
componentDefinition: component,
|
|
450
|
-
componentImplementation: this.componentMap.get(component.componentName),
|
|
451
|
-
});
|
|
452
|
-
}
|
|
453
|
-
const lazyComponent = this.lazyComponentMap.get(component.componentName);
|
|
454
|
-
if (lazyComponent) {
|
|
455
|
-
return lazyComponent.loadChildren()
|
|
456
|
-
.then((ngModuleFactory) => {
|
|
457
|
-
let componentType = null;
|
|
458
|
-
const moduleRef = ngModuleFactory.create(this.injector);
|
|
459
|
-
const dynamicComponentType = moduleRef.injector.get(DYNAMIC_COMPONENT);
|
|
460
|
-
if (!dynamicComponentType) {
|
|
461
|
-
throw new Error(
|
|
462
|
-
// tslint:disable-next-line:max-line-length
|
|
463
|
-
`JssComponentFactoryService: Lazy load module for component "${lazyComponent.path}" missing DYNAMIC_COMPONENT provider. Missing JssModule.forChild()?`);
|
|
464
|
-
}
|
|
465
|
-
if (component.componentName in dynamicComponentType) {
|
|
466
|
-
componentType = dynamicComponentType[component.componentName];
|
|
467
|
-
}
|
|
468
|
-
else {
|
|
469
|
-
if (typeof dynamicComponentType === 'function') {
|
|
470
|
-
componentType = dynamicComponentType;
|
|
471
|
-
}
|
|
472
|
-
else {
|
|
473
|
-
throw new Error(
|
|
474
|
-
// tslint:disable-next-line:max-line-length
|
|
475
|
-
`JssComponentFactoryService: Lazy load module for component "${lazyComponent.path}" missing DYNAMIC_COMPONENT provider. Missing JssModule.forChild()?`);
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
return {
|
|
479
|
-
componentDefinition: component,
|
|
480
|
-
componentImplementation: componentType,
|
|
481
|
-
componentFactory: moduleRef.componentFactoryResolver.resolveComponentFactory(componentType),
|
|
482
|
-
};
|
|
483
|
-
});
|
|
484
|
-
}
|
|
485
|
-
return Promise.resolve({
|
|
486
|
-
componentDefinition: component,
|
|
487
|
-
});
|
|
488
|
-
}
|
|
489
|
-
getComponents(components) {
|
|
490
|
-
// acquire all components and keep them in order while handling their potential async-ness
|
|
491
|
-
return Promise.all(components.map((component) => isRawRendering(component)
|
|
492
|
-
? this.getRawComponent(component)
|
|
493
|
-
: this.getComponent(component)));
|
|
494
|
-
}
|
|
495
|
-
getRawComponent(component) {
|
|
496
|
-
return Promise.resolve({
|
|
497
|
-
componentImplementation: RawComponent,
|
|
498
|
-
componentDefinition: component,
|
|
499
|
-
});
|
|
500
|
-
}
|
|
501
|
-
};
|
|
502
|
-
JssComponentFactoryService.ctorParameters = () => [
|
|
503
|
-
{ type: Injector },
|
|
504
|
-
{ type: Array, decorators: [{ type: Inject, args: [PLACEHOLDER_COMPONENTS,] }] },
|
|
505
|
-
{ type: Array, decorators: [{ type: Inject, args: [PLACEHOLDER_LAZY_COMPONENTS,] }] }
|
|
506
|
-
];
|
|
507
|
-
JssComponentFactoryService = __decorate([
|
|
508
|
-
Injectable(),
|
|
509
|
-
__param(1, Inject(PLACEHOLDER_COMPONENTS)),
|
|
510
|
-
__param(2, Inject(PLACEHOLDER_LAZY_COMPONENTS))
|
|
433
|
+
let JssComponentFactoryService = class JssComponentFactoryService {
|
|
434
|
+
constructor(injector, components, lazyComponents) {
|
|
435
|
+
this.injector = injector;
|
|
436
|
+
this.components = components;
|
|
437
|
+
this.lazyComponents = lazyComponents;
|
|
438
|
+
this.componentMap = new Map();
|
|
439
|
+
this.lazyComponentMap = new Map();
|
|
440
|
+
this.components.forEach((c) => this.componentMap.set(c.name, c.type));
|
|
441
|
+
if (this.lazyComponents) {
|
|
442
|
+
this.lazyComponents.forEach((c) => this.lazyComponentMap.set(c.path, c));
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
getComponent(component) {
|
|
446
|
+
const loadedComponent = this.componentMap.get(component.componentName);
|
|
447
|
+
if (loadedComponent) {
|
|
448
|
+
return Promise.resolve({
|
|
449
|
+
componentDefinition: component,
|
|
450
|
+
componentImplementation: this.componentMap.get(component.componentName),
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
const lazyComponent = this.lazyComponentMap.get(component.componentName);
|
|
454
|
+
if (lazyComponent) {
|
|
455
|
+
return lazyComponent.loadChildren()
|
|
456
|
+
.then((ngModuleFactory) => {
|
|
457
|
+
let componentType = null;
|
|
458
|
+
const moduleRef = ngModuleFactory.create(this.injector);
|
|
459
|
+
const dynamicComponentType = moduleRef.injector.get(DYNAMIC_COMPONENT);
|
|
460
|
+
if (!dynamicComponentType) {
|
|
461
|
+
throw new Error(
|
|
462
|
+
// tslint:disable-next-line:max-line-length
|
|
463
|
+
`JssComponentFactoryService: Lazy load module for component "${lazyComponent.path}" missing DYNAMIC_COMPONENT provider. Missing JssModule.forChild()?`);
|
|
464
|
+
}
|
|
465
|
+
if (component.componentName in dynamicComponentType) {
|
|
466
|
+
componentType = dynamicComponentType[component.componentName];
|
|
467
|
+
}
|
|
468
|
+
else {
|
|
469
|
+
if (typeof dynamicComponentType === 'function') {
|
|
470
|
+
componentType = dynamicComponentType;
|
|
471
|
+
}
|
|
472
|
+
else {
|
|
473
|
+
throw new Error(
|
|
474
|
+
// tslint:disable-next-line:max-line-length
|
|
475
|
+
`JssComponentFactoryService: Lazy load module for component "${lazyComponent.path}" missing DYNAMIC_COMPONENT provider. Missing JssModule.forChild()?`);
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
return {
|
|
479
|
+
componentDefinition: component,
|
|
480
|
+
componentImplementation: componentType,
|
|
481
|
+
componentFactory: moduleRef.componentFactoryResolver.resolveComponentFactory(componentType),
|
|
482
|
+
};
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
return Promise.resolve({
|
|
486
|
+
componentDefinition: component,
|
|
487
|
+
});
|
|
488
|
+
}
|
|
489
|
+
getComponents(components) {
|
|
490
|
+
// acquire all components and keep them in order while handling their potential async-ness
|
|
491
|
+
return Promise.all(components.map((component) => isRawRendering(component)
|
|
492
|
+
? this.getRawComponent(component)
|
|
493
|
+
: this.getComponent(component)));
|
|
494
|
+
}
|
|
495
|
+
getRawComponent(component) {
|
|
496
|
+
return Promise.resolve({
|
|
497
|
+
componentImplementation: RawComponent,
|
|
498
|
+
componentDefinition: component,
|
|
499
|
+
});
|
|
500
|
+
}
|
|
501
|
+
};
|
|
502
|
+
JssComponentFactoryService.ctorParameters = () => [
|
|
503
|
+
{ type: Injector },
|
|
504
|
+
{ type: Array, decorators: [{ type: Inject, args: [PLACEHOLDER_COMPONENTS,] }] },
|
|
505
|
+
{ type: Array, decorators: [{ type: Inject, args: [PLACEHOLDER_LAZY_COMPONENTS,] }] }
|
|
506
|
+
];
|
|
507
|
+
JssComponentFactoryService = __decorate([
|
|
508
|
+
Injectable(),
|
|
509
|
+
__param(1, Inject(PLACEHOLDER_COMPONENTS)),
|
|
510
|
+
__param(2, Inject(PLACEHOLDER_LAZY_COMPONENTS))
|
|
511
511
|
], JssComponentFactoryService);
|
|
512
512
|
|
|
513
|
-
let PlaceholderLoadingDirective = class PlaceholderLoadingDirective {
|
|
514
|
-
constructor(templateRef) {
|
|
515
|
-
this.templateRef = templateRef;
|
|
516
|
-
}
|
|
517
|
-
};
|
|
518
|
-
PlaceholderLoadingDirective.ctorParameters = () => [
|
|
519
|
-
{ type: TemplateRef }
|
|
520
|
-
];
|
|
521
|
-
PlaceholderLoadingDirective = __decorate([
|
|
522
|
-
Directive({
|
|
523
|
-
selector: '[scPlaceholderLoading]',
|
|
524
|
-
})
|
|
513
|
+
let PlaceholderLoadingDirective = class PlaceholderLoadingDirective {
|
|
514
|
+
constructor(templateRef) {
|
|
515
|
+
this.templateRef = templateRef;
|
|
516
|
+
}
|
|
517
|
+
};
|
|
518
|
+
PlaceholderLoadingDirective.ctorParameters = () => [
|
|
519
|
+
{ type: TemplateRef }
|
|
520
|
+
];
|
|
521
|
+
PlaceholderLoadingDirective = __decorate([
|
|
522
|
+
Directive({
|
|
523
|
+
selector: '[scPlaceholderLoading]',
|
|
524
|
+
})
|
|
525
525
|
], PlaceholderLoadingDirective);
|
|
526
526
|
|
|
527
|
-
let RenderEachDirective = class RenderEachDirective {
|
|
528
|
-
constructor(templateRef) {
|
|
529
|
-
this.templateRef = templateRef;
|
|
530
|
-
}
|
|
531
|
-
};
|
|
532
|
-
RenderEachDirective.ctorParameters = () => [
|
|
533
|
-
{ type: TemplateRef }
|
|
534
|
-
];
|
|
535
|
-
RenderEachDirective = __decorate([
|
|
536
|
-
Directive({
|
|
537
|
-
// tslint:disable-next-line:directive-selector
|
|
538
|
-
selector: '[renderEach]',
|
|
539
|
-
})
|
|
527
|
+
let RenderEachDirective = class RenderEachDirective {
|
|
528
|
+
constructor(templateRef) {
|
|
529
|
+
this.templateRef = templateRef;
|
|
530
|
+
}
|
|
531
|
+
};
|
|
532
|
+
RenderEachDirective.ctorParameters = () => [
|
|
533
|
+
{ type: TemplateRef }
|
|
534
|
+
];
|
|
535
|
+
RenderEachDirective = __decorate([
|
|
536
|
+
Directive({
|
|
537
|
+
// tslint:disable-next-line:directive-selector
|
|
538
|
+
selector: '[renderEach]',
|
|
539
|
+
})
|
|
540
540
|
], RenderEachDirective);
|
|
541
541
|
|
|
542
|
-
let RenderEmptyDirective = class RenderEmptyDirective {
|
|
543
|
-
constructor(templateRef) {
|
|
544
|
-
this.templateRef = templateRef;
|
|
545
|
-
}
|
|
546
|
-
};
|
|
547
|
-
RenderEmptyDirective.ctorParameters = () => [
|
|
548
|
-
{ type: TemplateRef }
|
|
549
|
-
];
|
|
550
|
-
RenderEmptyDirective = __decorate([
|
|
551
|
-
Directive({
|
|
552
|
-
// tslint:disable-next-line:directive-selector
|
|
553
|
-
selector: '[renderEmpty]',
|
|
554
|
-
})
|
|
542
|
+
let RenderEmptyDirective = class RenderEmptyDirective {
|
|
543
|
+
constructor(templateRef) {
|
|
544
|
+
this.templateRef = templateRef;
|
|
545
|
+
}
|
|
546
|
+
};
|
|
547
|
+
RenderEmptyDirective.ctorParameters = () => [
|
|
548
|
+
{ type: TemplateRef }
|
|
549
|
+
];
|
|
550
|
+
RenderEmptyDirective = __decorate([
|
|
551
|
+
Directive({
|
|
552
|
+
// tslint:disable-next-line:directive-selector
|
|
553
|
+
selector: '[renderEmpty]',
|
|
554
|
+
})
|
|
555
555
|
], RenderEmptyDirective);
|
|
556
556
|
|
|
557
|
-
function getPlaceholder(rendering, name) {
|
|
558
|
-
if (rendering && rendering.placeholders && Object.keys(rendering.placeholders).length > 0) {
|
|
559
|
-
return rendering.placeholders[name];
|
|
560
|
-
}
|
|
561
|
-
return null;
|
|
562
|
-
}
|
|
563
|
-
let PlaceholderComponent = class PlaceholderComponent {
|
|
564
|
-
constructor(componentFactoryResolver, differs, componentFactory, changeDetectorRef, elementRef, renderer, missingComponentComponent) {
|
|
565
|
-
this.componentFactoryResolver = componentFactoryResolver;
|
|
566
|
-
this.differs = differs;
|
|
567
|
-
this.componentFactory = componentFactory;
|
|
568
|
-
this.changeDetectorRef = changeDetectorRef;
|
|
569
|
-
this.elementRef = elementRef;
|
|
570
|
-
this.renderer = renderer;
|
|
571
|
-
this.missingComponentComponent = missingComponentComponent;
|
|
572
|
-
this._componentInstances = [];
|
|
573
|
-
this.destroyed = false;
|
|
574
|
-
this.parentStyleAttribute = '';
|
|
575
|
-
this.isLoading = true;
|
|
576
|
-
this.loaded = new EventEmitter();
|
|
577
|
-
}
|
|
578
|
-
set inputs(value) {
|
|
579
|
-
this._inputs = value;
|
|
580
|
-
if (!this._differ && value) {
|
|
581
|
-
this._differ = this.differs.find(value).create();
|
|
582
|
-
}
|
|
583
|
-
}
|
|
584
|
-
ngOnInit() {
|
|
585
|
-
// just to ensure the element exists
|
|
586
|
-
const elem = this.elementRef.nativeElement;
|
|
587
|
-
if (elem) {
|
|
588
|
-
const attributes = elem.attributes;
|
|
589
|
-
for (let i = 0; i < attributes.length; i++) {
|
|
590
|
-
const attr = attributes.item(i);
|
|
591
|
-
if (attr && attr.name.indexOf('_ngcontent') !== -1) {
|
|
592
|
-
this.parentStyleAttribute = attr.name;
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
|
-
ngOnDestroy() {
|
|
598
|
-
this.destroyed = true;
|
|
599
|
-
this._componentInstances = [];
|
|
600
|
-
}
|
|
601
|
-
ngOnChanges(changes) {
|
|
602
|
-
if (changes['rendering'] || changes['renderings']) {
|
|
603
|
-
this._render();
|
|
604
|
-
}
|
|
605
|
-
}
|
|
606
|
-
ngDoCheck() {
|
|
607
|
-
if (!this._differ || !this._inputs || this._componentInstances.length === 0) {
|
|
608
|
-
return;
|
|
609
|
-
}
|
|
610
|
-
const changes = this._differ.diff(this._inputs);
|
|
611
|
-
if (!changes) {
|
|
612
|
-
return;
|
|
613
|
-
}
|
|
614
|
-
const updates = {};
|
|
615
|
-
changes.forEachRemovedItem((change) => updates[change.key] = null);
|
|
616
|
-
changes.forEachAddedItem((change) => updates[change.key] = change.currentValue);
|
|
617
|
-
changes.forEachChangedItem((change) => updates[change.key] = change.currentValue);
|
|
618
|
-
this._componentInstances.forEach((componentInstance) => this._setComponentInputs(componentInstance, updates));
|
|
619
|
-
}
|
|
620
|
-
_setComponentInputs(componentInstance, inputs) {
|
|
621
|
-
Object.entries(inputs).forEach(([input, inputValue]) => componentInstance[input] = inputValue);
|
|
622
|
-
}
|
|
623
|
-
_subscribeComponentOutputs(componentInstance, outputs) {
|
|
624
|
-
Object.keys(outputs)
|
|
625
|
-
.filter((output) => componentInstance[output] && componentInstance[output] instanceof Observable)
|
|
626
|
-
.forEach((output) => componentInstance[output]
|
|
627
|
-
.pipe(takeWhile(() => !this.destroyed))
|
|
628
|
-
.subscribe(outputs[output]));
|
|
629
|
-
}
|
|
630
|
-
_render() {
|
|
631
|
-
this._componentInstances = [];
|
|
632
|
-
this.view.clear();
|
|
633
|
-
if (!this.rendering && !this.renderings) {
|
|
634
|
-
return;
|
|
635
|
-
}
|
|
636
|
-
if (!this.name && !this.renderings) {
|
|
637
|
-
// tslint:disable-next-line:max-line-length
|
|
638
|
-
console.warn(`Placeholder name was not specified, and explicit renderings array was not passed. Placeholder requires either name and rendering, or renderings.`);
|
|
639
|
-
this.isLoading = false;
|
|
640
|
-
return;
|
|
641
|
-
}
|
|
642
|
-
const placeholder = this.renderings || getPlaceholder(this.rendering, this.name || '');
|
|
643
|
-
if (!placeholder) {
|
|
644
|
-
console.warn(`Placeholder '${this.name}' was not found in the current rendering data`, JSON.stringify(this.rendering, null, 2));
|
|
645
|
-
this.isLoading = false;
|
|
646
|
-
return;
|
|
647
|
-
}
|
|
648
|
-
// if the placeholder is empty (contains only raw renderings), then we may need to use the empty template if it's defined
|
|
649
|
-
const placeholderIsEmpty = placeholder.every((rendering) => isRawRendering(rendering));
|
|
650
|
-
if (this.renderEmptyTemplate && placeholderIsEmpty) {
|
|
651
|
-
this.view.createEmbeddedView(this.renderEmptyTemplate.templateRef, {
|
|
652
|
-
renderings: placeholder,
|
|
653
|
-
});
|
|
654
|
-
this.isLoading = false;
|
|
655
|
-
}
|
|
656
|
-
else {
|
|
657
|
-
this.componentFactory.getComponents(placeholder)
|
|
658
|
-
.then((components) => components.forEach((rendering, index) => {
|
|
659
|
-
if (this.renderEachTemplate && !isRawRendering(rendering.componentDefinition)) {
|
|
660
|
-
this._renderTemplatedComponent(rendering.componentDefinition, index);
|
|
661
|
-
}
|
|
662
|
-
else {
|
|
663
|
-
this._renderEmbeddedComponent(rendering, index);
|
|
664
|
-
}
|
|
665
|
-
this.isLoading = false;
|
|
666
|
-
})).then(() => {
|
|
667
|
-
this.changeDetectorRef.markForCheck();
|
|
668
|
-
this.loaded.emit(this.name);
|
|
669
|
-
});
|
|
670
|
-
}
|
|
671
|
-
}
|
|
672
|
-
_renderTemplatedComponent(rendering, index) {
|
|
673
|
-
// the render-each template takes care of all component mapping etc
|
|
674
|
-
// generally using <sc-render-component> which is about like _renderEmbeddedComponent()
|
|
675
|
-
// as a separate component
|
|
676
|
-
this.view.createEmbeddedView(this.renderEachTemplate.templateRef, {
|
|
677
|
-
rendering,
|
|
678
|
-
index,
|
|
679
|
-
});
|
|
680
|
-
}
|
|
681
|
-
_renderEmbeddedComponent(rendering, index) {
|
|
682
|
-
if (!rendering.componentImplementation) {
|
|
683
|
-
const componentName = rendering.componentDefinition.componentName;
|
|
557
|
+
function getPlaceholder(rendering, name) {
|
|
558
|
+
if (rendering && rendering.placeholders && Object.keys(rendering.placeholders).length > 0) {
|
|
559
|
+
return rendering.placeholders[name];
|
|
560
|
+
}
|
|
561
|
+
return null;
|
|
562
|
+
}
|
|
563
|
+
let PlaceholderComponent = class PlaceholderComponent {
|
|
564
|
+
constructor(componentFactoryResolver, differs, componentFactory, changeDetectorRef, elementRef, renderer, missingComponentComponent) {
|
|
565
|
+
this.componentFactoryResolver = componentFactoryResolver;
|
|
566
|
+
this.differs = differs;
|
|
567
|
+
this.componentFactory = componentFactory;
|
|
568
|
+
this.changeDetectorRef = changeDetectorRef;
|
|
569
|
+
this.elementRef = elementRef;
|
|
570
|
+
this.renderer = renderer;
|
|
571
|
+
this.missingComponentComponent = missingComponentComponent;
|
|
572
|
+
this._componentInstances = [];
|
|
573
|
+
this.destroyed = false;
|
|
574
|
+
this.parentStyleAttribute = '';
|
|
575
|
+
this.isLoading = true;
|
|
576
|
+
this.loaded = new EventEmitter();
|
|
577
|
+
}
|
|
578
|
+
set inputs(value) {
|
|
579
|
+
this._inputs = value;
|
|
580
|
+
if (!this._differ && value) {
|
|
581
|
+
this._differ = this.differs.find(value).create();
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
ngOnInit() {
|
|
585
|
+
// just to ensure the element exists
|
|
586
|
+
const elem = this.elementRef.nativeElement;
|
|
587
|
+
if (elem) {
|
|
588
|
+
const attributes = elem.attributes;
|
|
589
|
+
for (let i = 0; i < attributes.length; i++) {
|
|
590
|
+
const attr = attributes.item(i);
|
|
591
|
+
if (attr && attr.name.indexOf('_ngcontent') !== -1) {
|
|
592
|
+
this.parentStyleAttribute = attr.name;
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
ngOnDestroy() {
|
|
598
|
+
this.destroyed = true;
|
|
599
|
+
this._componentInstances = [];
|
|
600
|
+
}
|
|
601
|
+
ngOnChanges(changes) {
|
|
602
|
+
if (changes['rendering'] || changes['renderings']) {
|
|
603
|
+
this._render();
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
ngDoCheck() {
|
|
607
|
+
if (!this._differ || !this._inputs || this._componentInstances.length === 0) {
|
|
608
|
+
return;
|
|
609
|
+
}
|
|
610
|
+
const changes = this._differ.diff(this._inputs);
|
|
611
|
+
if (!changes) {
|
|
612
|
+
return;
|
|
613
|
+
}
|
|
614
|
+
const updates = {};
|
|
615
|
+
changes.forEachRemovedItem((change) => updates[change.key] = null);
|
|
616
|
+
changes.forEachAddedItem((change) => updates[change.key] = change.currentValue);
|
|
617
|
+
changes.forEachChangedItem((change) => updates[change.key] = change.currentValue);
|
|
618
|
+
this._componentInstances.forEach((componentInstance) => this._setComponentInputs(componentInstance, updates));
|
|
619
|
+
}
|
|
620
|
+
_setComponentInputs(componentInstance, inputs) {
|
|
621
|
+
Object.entries(inputs).forEach(([input, inputValue]) => componentInstance[input] = inputValue);
|
|
622
|
+
}
|
|
623
|
+
_subscribeComponentOutputs(componentInstance, outputs) {
|
|
624
|
+
Object.keys(outputs)
|
|
625
|
+
.filter((output) => componentInstance[output] && componentInstance[output] instanceof Observable)
|
|
626
|
+
.forEach((output) => componentInstance[output]
|
|
627
|
+
.pipe(takeWhile(() => !this.destroyed))
|
|
628
|
+
.subscribe(outputs[output]));
|
|
629
|
+
}
|
|
630
|
+
_render() {
|
|
631
|
+
this._componentInstances = [];
|
|
632
|
+
this.view.clear();
|
|
633
|
+
if (!this.rendering && !this.renderings) {
|
|
634
|
+
return;
|
|
635
|
+
}
|
|
636
|
+
if (!this.name && !this.renderings) {
|
|
637
|
+
// tslint:disable-next-line:max-line-length
|
|
638
|
+
console.warn(`Placeholder name was not specified, and explicit renderings array was not passed. Placeholder requires either name and rendering, or renderings.`);
|
|
639
|
+
this.isLoading = false;
|
|
640
|
+
return;
|
|
641
|
+
}
|
|
642
|
+
const placeholder = this.renderings || getPlaceholder(this.rendering, this.name || '');
|
|
643
|
+
if (!placeholder) {
|
|
644
|
+
console.warn(`Placeholder '${this.name}' was not found in the current rendering data`, JSON.stringify(this.rendering, null, 2));
|
|
645
|
+
this.isLoading = false;
|
|
646
|
+
return;
|
|
647
|
+
}
|
|
648
|
+
// if the placeholder is empty (contains only raw renderings), then we may need to use the empty template if it's defined
|
|
649
|
+
const placeholderIsEmpty = placeholder.every((rendering) => isRawRendering(rendering));
|
|
650
|
+
if (this.renderEmptyTemplate && placeholderIsEmpty) {
|
|
651
|
+
this.view.createEmbeddedView(this.renderEmptyTemplate.templateRef, {
|
|
652
|
+
renderings: placeholder,
|
|
653
|
+
});
|
|
654
|
+
this.isLoading = false;
|
|
655
|
+
}
|
|
656
|
+
else {
|
|
657
|
+
this.componentFactory.getComponents(placeholder)
|
|
658
|
+
.then((components) => components.forEach((rendering, index) => {
|
|
659
|
+
if (this.renderEachTemplate && !isRawRendering(rendering.componentDefinition)) {
|
|
660
|
+
this._renderTemplatedComponent(rendering.componentDefinition, index);
|
|
661
|
+
}
|
|
662
|
+
else {
|
|
663
|
+
this._renderEmbeddedComponent(rendering, index);
|
|
664
|
+
}
|
|
665
|
+
this.isLoading = false;
|
|
666
|
+
})).then(() => {
|
|
667
|
+
this.changeDetectorRef.markForCheck();
|
|
668
|
+
this.loaded.emit(this.name);
|
|
669
|
+
});
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
_renderTemplatedComponent(rendering, index) {
|
|
673
|
+
// the render-each template takes care of all component mapping etc
|
|
674
|
+
// generally using <sc-render-component> which is about like _renderEmbeddedComponent()
|
|
675
|
+
// as a separate component
|
|
676
|
+
this.view.createEmbeddedView(this.renderEachTemplate.templateRef, {
|
|
677
|
+
rendering,
|
|
678
|
+
index,
|
|
679
|
+
});
|
|
680
|
+
}
|
|
681
|
+
_renderEmbeddedComponent(rendering, index) {
|
|
682
|
+
if (!rendering.componentImplementation) {
|
|
683
|
+
const componentName = rendering.componentDefinition.componentName;
|
|
684
684
|
console.error(`Placeholder ${this.name} contains unknown component ${componentName}.`, `Ensure component is mapped, like:
|
|
685
685
|
JssModule.withComponents([
|
|
686
686
|
{ name: '${componentName}', type: ${componentName}Component }
|
|
687
|
-
])`);
|
|
688
|
-
rendering.componentImplementation = this.missingComponentComponent;
|
|
689
|
-
}
|
|
690
|
-
const componentFactory = rendering.componentFactory || this.componentFactoryResolver.resolveComponentFactory(rendering.componentImplementation);
|
|
691
|
-
// apply the parent style attribute _ngcontent
|
|
692
|
-
// work-around for https://github.com/angular/angular/issues/12215
|
|
693
|
-
const createdComponentRef = this.view.createComponent(componentFactory, index);
|
|
694
|
-
if (this.parentStyleAttribute) {
|
|
695
|
-
this.renderer.setAttribute(createdComponentRef.location.nativeElement, this.parentStyleAttribute, '');
|
|
696
|
-
}
|
|
697
|
-
const componentInstance = createdComponentRef.instance;
|
|
698
|
-
componentInstance.rendering = rendering.componentDefinition;
|
|
699
|
-
if (this._inputs) {
|
|
700
|
-
this._setComponentInputs(componentInstance, this._inputs);
|
|
701
|
-
}
|
|
702
|
-
if (this.outputs) {
|
|
703
|
-
this._subscribeComponentOutputs(componentInstance, this.outputs);
|
|
704
|
-
}
|
|
705
|
-
this._componentInstances.push(componentInstance);
|
|
706
|
-
}
|
|
707
|
-
};
|
|
708
|
-
PlaceholderComponent.ctorParameters = () => [
|
|
709
|
-
{ type: ComponentFactoryResolver },
|
|
710
|
-
{ type: KeyValueDiffers },
|
|
711
|
-
{ type: JssComponentFactoryService },
|
|
712
|
-
{ type: ChangeDetectorRef },
|
|
713
|
-
{ type: ElementRef },
|
|
714
|
-
{ type: Renderer2 },
|
|
715
|
-
{ type: Type, decorators: [{ type: Inject, args: [PLACEHOLDER_MISSING_COMPONENT_COMPONENT,] }] }
|
|
716
|
-
];
|
|
717
|
-
__decorate([
|
|
718
|
-
Input()
|
|
719
|
-
], PlaceholderComponent.prototype, "name", void 0);
|
|
720
|
-
__decorate([
|
|
721
|
-
Input()
|
|
722
|
-
], PlaceholderComponent.prototype, "rendering", void 0);
|
|
723
|
-
__decorate([
|
|
724
|
-
Input()
|
|
725
|
-
], PlaceholderComponent.prototype, "renderings", void 0);
|
|
726
|
-
__decorate([
|
|
727
|
-
Input()
|
|
728
|
-
], PlaceholderComponent.prototype, "outputs", void 0);
|
|
729
|
-
__decorate([
|
|
730
|
-
Output()
|
|
731
|
-
], PlaceholderComponent.prototype, "loaded", void 0);
|
|
732
|
-
__decorate([
|
|
733
|
-
ViewChild('view', { read: ViewContainerRef, static: true })
|
|
734
|
-
], PlaceholderComponent.prototype, "view", void 0);
|
|
735
|
-
__decorate([
|
|
736
|
-
ContentChild(RenderEachDirective, { static: true })
|
|
737
|
-
], PlaceholderComponent.prototype, "renderEachTemplate", void 0);
|
|
738
|
-
__decorate([
|
|
739
|
-
ContentChild(RenderEmptyDirective, { static: true })
|
|
740
|
-
], PlaceholderComponent.prototype, "renderEmptyTemplate", void 0);
|
|
741
|
-
__decorate([
|
|
742
|
-
ContentChild(PlaceholderLoadingDirective, { static: true })
|
|
743
|
-
], PlaceholderComponent.prototype, "placeholderLoading", void 0);
|
|
744
|
-
__decorate([
|
|
745
|
-
Input()
|
|
746
|
-
], PlaceholderComponent.prototype, "inputs", null);
|
|
747
|
-
PlaceholderComponent = __decorate([
|
|
748
|
-
Component({
|
|
749
|
-
selector: 'sc-placeholder,[sc-placeholder]',
|
|
687
|
+
])`);
|
|
688
|
+
rendering.componentImplementation = this.missingComponentComponent;
|
|
689
|
+
}
|
|
690
|
+
const componentFactory = rendering.componentFactory || this.componentFactoryResolver.resolveComponentFactory(rendering.componentImplementation);
|
|
691
|
+
// apply the parent style attribute _ngcontent
|
|
692
|
+
// work-around for https://github.com/angular/angular/issues/12215
|
|
693
|
+
const createdComponentRef = this.view.createComponent(componentFactory, index);
|
|
694
|
+
if (this.parentStyleAttribute) {
|
|
695
|
+
this.renderer.setAttribute(createdComponentRef.location.nativeElement, this.parentStyleAttribute, '');
|
|
696
|
+
}
|
|
697
|
+
const componentInstance = createdComponentRef.instance;
|
|
698
|
+
componentInstance.rendering = rendering.componentDefinition;
|
|
699
|
+
if (this._inputs) {
|
|
700
|
+
this._setComponentInputs(componentInstance, this._inputs);
|
|
701
|
+
}
|
|
702
|
+
if (this.outputs) {
|
|
703
|
+
this._subscribeComponentOutputs(componentInstance, this.outputs);
|
|
704
|
+
}
|
|
705
|
+
this._componentInstances.push(componentInstance);
|
|
706
|
+
}
|
|
707
|
+
};
|
|
708
|
+
PlaceholderComponent.ctorParameters = () => [
|
|
709
|
+
{ type: ComponentFactoryResolver },
|
|
710
|
+
{ type: KeyValueDiffers },
|
|
711
|
+
{ type: JssComponentFactoryService },
|
|
712
|
+
{ type: ChangeDetectorRef },
|
|
713
|
+
{ type: ElementRef },
|
|
714
|
+
{ type: Renderer2 },
|
|
715
|
+
{ type: Type, decorators: [{ type: Inject, args: [PLACEHOLDER_MISSING_COMPONENT_COMPONENT,] }] }
|
|
716
|
+
];
|
|
717
|
+
__decorate([
|
|
718
|
+
Input()
|
|
719
|
+
], PlaceholderComponent.prototype, "name", void 0);
|
|
720
|
+
__decorate([
|
|
721
|
+
Input()
|
|
722
|
+
], PlaceholderComponent.prototype, "rendering", void 0);
|
|
723
|
+
__decorate([
|
|
724
|
+
Input()
|
|
725
|
+
], PlaceholderComponent.prototype, "renderings", void 0);
|
|
726
|
+
__decorate([
|
|
727
|
+
Input()
|
|
728
|
+
], PlaceholderComponent.prototype, "outputs", void 0);
|
|
729
|
+
__decorate([
|
|
730
|
+
Output()
|
|
731
|
+
], PlaceholderComponent.prototype, "loaded", void 0);
|
|
732
|
+
__decorate([
|
|
733
|
+
ViewChild('view', { read: ViewContainerRef, static: true })
|
|
734
|
+
], PlaceholderComponent.prototype, "view", void 0);
|
|
735
|
+
__decorate([
|
|
736
|
+
ContentChild(RenderEachDirective, { static: true })
|
|
737
|
+
], PlaceholderComponent.prototype, "renderEachTemplate", void 0);
|
|
738
|
+
__decorate([
|
|
739
|
+
ContentChild(RenderEmptyDirective, { static: true })
|
|
740
|
+
], PlaceholderComponent.prototype, "renderEmptyTemplate", void 0);
|
|
741
|
+
__decorate([
|
|
742
|
+
ContentChild(PlaceholderLoadingDirective, { static: true })
|
|
743
|
+
], PlaceholderComponent.prototype, "placeholderLoading", void 0);
|
|
744
|
+
__decorate([
|
|
745
|
+
Input()
|
|
746
|
+
], PlaceholderComponent.prototype, "inputs", null);
|
|
747
|
+
PlaceholderComponent = __decorate([
|
|
748
|
+
Component({
|
|
749
|
+
selector: 'sc-placeholder,[sc-placeholder]',
|
|
750
750
|
template: `
|
|
751
751
|
<ng-template *ngIf="isLoading" [ngTemplateOutlet]="placeholderLoading?.templateRef"></ng-template>
|
|
752
752
|
<ng-template #view></ng-template>
|
|
753
|
-
`
|
|
754
|
-
}),
|
|
755
|
-
__param(6, Inject(PLACEHOLDER_MISSING_COMPONENT_COMPONENT))
|
|
753
|
+
`
|
|
754
|
+
}),
|
|
755
|
+
__param(6, Inject(PLACEHOLDER_MISSING_COMPONENT_COMPONENT))
|
|
756
756
|
], PlaceholderComponent);
|
|
757
757
|
|
|
758
|
-
let RichTextDirective = class RichTextDirective {
|
|
759
|
-
constructor(viewContainer, templateRef) {
|
|
760
|
-
this.viewContainer = viewContainer;
|
|
761
|
-
this.templateRef = templateRef;
|
|
762
|
-
// tslint:disable-next-line:no-input-rename
|
|
763
|
-
this.editable = true;
|
|
764
|
-
}
|
|
765
|
-
ngOnChanges(changes) {
|
|
766
|
-
if (changes['field'] || changes['editable']) {
|
|
767
|
-
if (!this.viewRef) {
|
|
768
|
-
this.viewContainer.clear();
|
|
769
|
-
this.viewRef = this.viewContainer.createEmbeddedView(this.templateRef);
|
|
770
|
-
}
|
|
771
|
-
this.updateView();
|
|
772
|
-
}
|
|
773
|
-
}
|
|
774
|
-
updateView() {
|
|
775
|
-
const field = this.field;
|
|
776
|
-
if (!field || (!field.editable && !field.value)) {
|
|
777
|
-
return;
|
|
778
|
-
}
|
|
779
|
-
const html = (field.editable && this.editable ? field.editable : field.value);
|
|
780
|
-
this.viewRef.rootNodes.forEach((node) => {
|
|
781
|
-
node.innerHTML = html;
|
|
782
|
-
});
|
|
783
|
-
}
|
|
784
|
-
};
|
|
785
|
-
RichTextDirective.ctorParameters = () => [
|
|
786
|
-
{ type: ViewContainerRef },
|
|
787
|
-
{ type: TemplateRef }
|
|
788
|
-
];
|
|
789
|
-
__decorate([
|
|
790
|
-
Input('scRichTextEditable')
|
|
791
|
-
], RichTextDirective.prototype, "editable", void 0);
|
|
792
|
-
__decorate([
|
|
793
|
-
Input('scRichText')
|
|
794
|
-
], RichTextDirective.prototype, "field", void 0);
|
|
795
|
-
RichTextDirective = __decorate([
|
|
796
|
-
Directive({
|
|
797
|
-
selector: '[scRichText]',
|
|
798
|
-
})
|
|
758
|
+
let RichTextDirective = class RichTextDirective {
|
|
759
|
+
constructor(viewContainer, templateRef) {
|
|
760
|
+
this.viewContainer = viewContainer;
|
|
761
|
+
this.templateRef = templateRef;
|
|
762
|
+
// tslint:disable-next-line:no-input-rename
|
|
763
|
+
this.editable = true;
|
|
764
|
+
}
|
|
765
|
+
ngOnChanges(changes) {
|
|
766
|
+
if (changes['field'] || changes['editable']) {
|
|
767
|
+
if (!this.viewRef) {
|
|
768
|
+
this.viewContainer.clear();
|
|
769
|
+
this.viewRef = this.viewContainer.createEmbeddedView(this.templateRef);
|
|
770
|
+
}
|
|
771
|
+
this.updateView();
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
updateView() {
|
|
775
|
+
const field = this.field;
|
|
776
|
+
if (!field || (!field.editable && !field.value)) {
|
|
777
|
+
return;
|
|
778
|
+
}
|
|
779
|
+
const html = (field.editable && this.editable ? field.editable : field.value);
|
|
780
|
+
this.viewRef.rootNodes.forEach((node) => {
|
|
781
|
+
node.innerHTML = html;
|
|
782
|
+
});
|
|
783
|
+
}
|
|
784
|
+
};
|
|
785
|
+
RichTextDirective.ctorParameters = () => [
|
|
786
|
+
{ type: ViewContainerRef },
|
|
787
|
+
{ type: TemplateRef }
|
|
788
|
+
];
|
|
789
|
+
__decorate([
|
|
790
|
+
Input('scRichTextEditable')
|
|
791
|
+
], RichTextDirective.prototype, "editable", void 0);
|
|
792
|
+
__decorate([
|
|
793
|
+
Input('scRichText')
|
|
794
|
+
], RichTextDirective.prototype, "field", void 0);
|
|
795
|
+
RichTextDirective = __decorate([
|
|
796
|
+
Directive({
|
|
797
|
+
selector: '[scRichText]',
|
|
798
|
+
})
|
|
799
799
|
], RichTextDirective);
|
|
800
800
|
|
|
801
|
-
let TextDirective = class TextDirective {
|
|
802
|
-
constructor(viewContainer, templateRef) {
|
|
803
|
-
this.viewContainer = viewContainer;
|
|
804
|
-
this.templateRef = templateRef;
|
|
805
|
-
// tslint:disable-next-line:no-input-rename
|
|
806
|
-
this.editable = true;
|
|
807
|
-
// tslint:disable-next-line:no-input-rename
|
|
808
|
-
this.encode = true;
|
|
809
|
-
}
|
|
810
|
-
ngOnChanges(changes) {
|
|
811
|
-
if (changes['field'] || changes['editable'] || changes['encode']) {
|
|
812
|
-
if (!this.viewRef) {
|
|
813
|
-
this.viewContainer.clear();
|
|
814
|
-
this.viewRef = this.viewContainer.createEmbeddedView(this.templateRef);
|
|
815
|
-
}
|
|
816
|
-
this.updateView();
|
|
817
|
-
}
|
|
818
|
-
}
|
|
819
|
-
updateView() {
|
|
820
|
-
const field = this.field;
|
|
821
|
-
let editable = this.editable;
|
|
822
|
-
if (!field || (!field.editable && !field.value)) {
|
|
823
|
-
return;
|
|
824
|
-
}
|
|
825
|
-
// can't use editable value if we want to output unencoded
|
|
826
|
-
if (!this.encode) {
|
|
827
|
-
editable = false;
|
|
828
|
-
}
|
|
829
|
-
const html = field.editable && editable ? field.editable : field.value;
|
|
830
|
-
const setDangerously = field.editable && editable || !this.encode;
|
|
831
|
-
this.viewRef.rootNodes.forEach((node) => {
|
|
832
|
-
if (setDangerously) {
|
|
833
|
-
node.innerHTML = html;
|
|
834
|
-
}
|
|
835
|
-
else {
|
|
836
|
-
node.textContent = html;
|
|
837
|
-
}
|
|
838
|
-
});
|
|
839
|
-
}
|
|
840
|
-
};
|
|
841
|
-
TextDirective.ctorParameters = () => [
|
|
842
|
-
{ type: ViewContainerRef },
|
|
843
|
-
{ type: TemplateRef }
|
|
844
|
-
];
|
|
845
|
-
__decorate([
|
|
846
|
-
Input('scTextEditable')
|
|
847
|
-
], TextDirective.prototype, "editable", void 0);
|
|
848
|
-
__decorate([
|
|
849
|
-
Input('scTextEncode')
|
|
850
|
-
], TextDirective.prototype, "encode", void 0);
|
|
851
|
-
__decorate([
|
|
852
|
-
Input('scText')
|
|
853
|
-
], TextDirective.prototype, "field", void 0);
|
|
854
|
-
TextDirective = __decorate([
|
|
855
|
-
Directive({
|
|
856
|
-
selector: '[scText]',
|
|
857
|
-
})
|
|
801
|
+
let TextDirective = class TextDirective {
|
|
802
|
+
constructor(viewContainer, templateRef) {
|
|
803
|
+
this.viewContainer = viewContainer;
|
|
804
|
+
this.templateRef = templateRef;
|
|
805
|
+
// tslint:disable-next-line:no-input-rename
|
|
806
|
+
this.editable = true;
|
|
807
|
+
// tslint:disable-next-line:no-input-rename
|
|
808
|
+
this.encode = true;
|
|
809
|
+
}
|
|
810
|
+
ngOnChanges(changes) {
|
|
811
|
+
if (changes['field'] || changes['editable'] || changes['encode']) {
|
|
812
|
+
if (!this.viewRef) {
|
|
813
|
+
this.viewContainer.clear();
|
|
814
|
+
this.viewRef = this.viewContainer.createEmbeddedView(this.templateRef);
|
|
815
|
+
}
|
|
816
|
+
this.updateView();
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
updateView() {
|
|
820
|
+
const field = this.field;
|
|
821
|
+
let editable = this.editable;
|
|
822
|
+
if (!field || (!field.editable && !field.value)) {
|
|
823
|
+
return;
|
|
824
|
+
}
|
|
825
|
+
// can't use editable value if we want to output unencoded
|
|
826
|
+
if (!this.encode) {
|
|
827
|
+
editable = false;
|
|
828
|
+
}
|
|
829
|
+
const html = field.editable && editable ? field.editable : field.value;
|
|
830
|
+
const setDangerously = field.editable && editable || !this.encode;
|
|
831
|
+
this.viewRef.rootNodes.forEach((node) => {
|
|
832
|
+
if (setDangerously) {
|
|
833
|
+
node.innerHTML = html;
|
|
834
|
+
}
|
|
835
|
+
else {
|
|
836
|
+
node.textContent = html;
|
|
837
|
+
}
|
|
838
|
+
});
|
|
839
|
+
}
|
|
840
|
+
};
|
|
841
|
+
TextDirective.ctorParameters = () => [
|
|
842
|
+
{ type: ViewContainerRef },
|
|
843
|
+
{ type: TemplateRef }
|
|
844
|
+
];
|
|
845
|
+
__decorate([
|
|
846
|
+
Input('scTextEditable')
|
|
847
|
+
], TextDirective.prototype, "editable", void 0);
|
|
848
|
+
__decorate([
|
|
849
|
+
Input('scTextEncode')
|
|
850
|
+
], TextDirective.prototype, "encode", void 0);
|
|
851
|
+
__decorate([
|
|
852
|
+
Input('scText')
|
|
853
|
+
], TextDirective.prototype, "field", void 0);
|
|
854
|
+
TextDirective = __decorate([
|
|
855
|
+
Directive({
|
|
856
|
+
selector: '[scText]',
|
|
857
|
+
})
|
|
858
858
|
], TextDirective);
|
|
859
859
|
|
|
860
|
-
class LayoutServiceError {
|
|
860
|
+
class LayoutServiceError {
|
|
861
861
|
}
|
|
862
862
|
|
|
863
|
-
var LayoutService_1;
|
|
864
|
-
const { fetchRouteData, fetchPlaceholderData } = dataApi;
|
|
865
|
-
let LayoutService = LayoutService_1 = class LayoutService {
|
|
866
|
-
static getLayoutServiceError(error) {
|
|
867
|
-
const layoutServiceError = new LayoutServiceError();
|
|
868
|
-
const response = error.response;
|
|
869
|
-
if (response) {
|
|
870
|
-
layoutServiceError.status = response.status;
|
|
871
|
-
layoutServiceError.statusText = response.statusText;
|
|
872
|
-
layoutServiceError.data = response.data;
|
|
873
|
-
}
|
|
874
|
-
return throwError(layoutServiceError);
|
|
875
|
-
}
|
|
876
|
-
getRouteData(route, options) {
|
|
877
|
-
return from(fetchRouteData(route, options))
|
|
878
|
-
.pipe(catchError(LayoutService_1.getLayoutServiceError));
|
|
879
|
-
}
|
|
880
|
-
getPlaceholderData(route, placeholderName, options) {
|
|
881
|
-
return from(fetchPlaceholderData(placeholderName, route, options))
|
|
882
|
-
.pipe(catchError(LayoutService_1.getLayoutServiceError));
|
|
883
|
-
}
|
|
884
|
-
};
|
|
885
|
-
LayoutService = LayoutService_1 = __decorate([
|
|
886
|
-
Injectable()
|
|
863
|
+
var LayoutService_1;
|
|
864
|
+
const { fetchRouteData, fetchPlaceholderData } = dataApi;
|
|
865
|
+
let LayoutService = LayoutService_1 = class LayoutService {
|
|
866
|
+
static getLayoutServiceError(error) {
|
|
867
|
+
const layoutServiceError = new LayoutServiceError();
|
|
868
|
+
const response = error.response;
|
|
869
|
+
if (response) {
|
|
870
|
+
layoutServiceError.status = response.status;
|
|
871
|
+
layoutServiceError.statusText = response.statusText;
|
|
872
|
+
layoutServiceError.data = response.data;
|
|
873
|
+
}
|
|
874
|
+
return throwError(layoutServiceError);
|
|
875
|
+
}
|
|
876
|
+
getRouteData(route, options) {
|
|
877
|
+
return from(fetchRouteData(route, options))
|
|
878
|
+
.pipe(catchError(LayoutService_1.getLayoutServiceError));
|
|
879
|
+
}
|
|
880
|
+
getPlaceholderData(route, placeholderName, options) {
|
|
881
|
+
return from(fetchPlaceholderData(placeholderName, route, options))
|
|
882
|
+
.pipe(catchError(LayoutService_1.getLayoutServiceError));
|
|
883
|
+
}
|
|
884
|
+
};
|
|
885
|
+
LayoutService = LayoutService_1 = __decorate([
|
|
886
|
+
Injectable()
|
|
887
887
|
], LayoutService);
|
|
888
888
|
|
|
889
|
-
let DateDirective = class DateDirective {
|
|
890
|
-
constructor(viewContainer, templateRef, datePipe) {
|
|
891
|
-
this.viewContainer = viewContainer;
|
|
892
|
-
this.templateRef = templateRef;
|
|
893
|
-
this.datePipe = datePipe;
|
|
894
|
-
// tslint:disable-next-line:no-input-rename
|
|
895
|
-
this.editable = true;
|
|
896
|
-
}
|
|
897
|
-
ngOnChanges(changes) {
|
|
898
|
-
if (changes['field'] || changes['format']) {
|
|
899
|
-
if (!this.viewRef) {
|
|
900
|
-
this.viewContainer.clear();
|
|
901
|
-
this.viewRef = this.viewContainer.createEmbeddedView(this.templateRef);
|
|
902
|
-
}
|
|
903
|
-
this.updateView();
|
|
904
|
-
}
|
|
905
|
-
}
|
|
906
|
-
updateView() {
|
|
907
|
-
const field = this.field;
|
|
908
|
-
if (!field || (!field.editable && !field.value)) {
|
|
909
|
-
return;
|
|
910
|
-
}
|
|
911
|
-
const html = field.editable && this.editable ? field.editable : field.value;
|
|
912
|
-
const setDangerously = field.editable && this.editable;
|
|
913
|
-
this.viewRef.rootNodes.forEach((node) => {
|
|
914
|
-
if (setDangerously) {
|
|
915
|
-
node.innerHTML = html;
|
|
916
|
-
}
|
|
917
|
-
else {
|
|
918
|
-
node.textContent = this.datePipe.transform(html, this.format, this.timezone, this.locale);
|
|
919
|
-
}
|
|
920
|
-
});
|
|
921
|
-
}
|
|
922
|
-
};
|
|
923
|
-
DateDirective.ctorParameters = () => [
|
|
924
|
-
{ type: ViewContainerRef },
|
|
925
|
-
{ type: TemplateRef },
|
|
926
|
-
{ type: DatePipe }
|
|
927
|
-
];
|
|
928
|
-
__decorate([
|
|
929
|
-
Input('scDateFormat')
|
|
930
|
-
], DateDirective.prototype, "format", void 0);
|
|
931
|
-
__decorate([
|
|
932
|
-
Input('scDateTimezone')
|
|
933
|
-
], DateDirective.prototype, "timezone", void 0);
|
|
934
|
-
__decorate([
|
|
935
|
-
Input('scDateLocale')
|
|
936
|
-
], DateDirective.prototype, "locale", void 0);
|
|
937
|
-
__decorate([
|
|
938
|
-
Input('scDateEditable')
|
|
939
|
-
], DateDirective.prototype, "editable", void 0);
|
|
940
|
-
__decorate([
|
|
941
|
-
Input('scDate')
|
|
942
|
-
], DateDirective.prototype, "field", void 0);
|
|
943
|
-
DateDirective = __decorate([
|
|
944
|
-
Directive({
|
|
945
|
-
selector: '[scDate]',
|
|
946
|
-
})
|
|
889
|
+
let DateDirective = class DateDirective {
|
|
890
|
+
constructor(viewContainer, templateRef, datePipe) {
|
|
891
|
+
this.viewContainer = viewContainer;
|
|
892
|
+
this.templateRef = templateRef;
|
|
893
|
+
this.datePipe = datePipe;
|
|
894
|
+
// tslint:disable-next-line:no-input-rename
|
|
895
|
+
this.editable = true;
|
|
896
|
+
}
|
|
897
|
+
ngOnChanges(changes) {
|
|
898
|
+
if (changes['field'] || changes['format']) {
|
|
899
|
+
if (!this.viewRef) {
|
|
900
|
+
this.viewContainer.clear();
|
|
901
|
+
this.viewRef = this.viewContainer.createEmbeddedView(this.templateRef);
|
|
902
|
+
}
|
|
903
|
+
this.updateView();
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
updateView() {
|
|
907
|
+
const field = this.field;
|
|
908
|
+
if (!field || (!field.editable && !field.value)) {
|
|
909
|
+
return;
|
|
910
|
+
}
|
|
911
|
+
const html = field.editable && this.editable ? field.editable : field.value;
|
|
912
|
+
const setDangerously = field.editable && this.editable;
|
|
913
|
+
this.viewRef.rootNodes.forEach((node) => {
|
|
914
|
+
if (setDangerously) {
|
|
915
|
+
node.innerHTML = html;
|
|
916
|
+
}
|
|
917
|
+
else {
|
|
918
|
+
node.textContent = this.datePipe.transform(html, this.format, this.timezone, this.locale);
|
|
919
|
+
}
|
|
920
|
+
});
|
|
921
|
+
}
|
|
922
|
+
};
|
|
923
|
+
DateDirective.ctorParameters = () => [
|
|
924
|
+
{ type: ViewContainerRef },
|
|
925
|
+
{ type: TemplateRef },
|
|
926
|
+
{ type: DatePipe }
|
|
927
|
+
];
|
|
928
|
+
__decorate([
|
|
929
|
+
Input('scDateFormat')
|
|
930
|
+
], DateDirective.prototype, "format", void 0);
|
|
931
|
+
__decorate([
|
|
932
|
+
Input('scDateTimezone')
|
|
933
|
+
], DateDirective.prototype, "timezone", void 0);
|
|
934
|
+
__decorate([
|
|
935
|
+
Input('scDateLocale')
|
|
936
|
+
], DateDirective.prototype, "locale", void 0);
|
|
937
|
+
__decorate([
|
|
938
|
+
Input('scDateEditable')
|
|
939
|
+
], DateDirective.prototype, "editable", void 0);
|
|
940
|
+
__decorate([
|
|
941
|
+
Input('scDate')
|
|
942
|
+
], DateDirective.prototype, "field", void 0);
|
|
943
|
+
DateDirective = __decorate([
|
|
944
|
+
Directive({
|
|
945
|
+
selector: '[scDate]',
|
|
946
|
+
})
|
|
947
947
|
], DateDirective);
|
|
948
948
|
|
|
949
|
-
let MissingComponentComponent = class MissingComponentComponent {
|
|
950
|
-
};
|
|
951
|
-
__decorate([
|
|
952
|
-
Input()
|
|
953
|
-
], MissingComponentComponent.prototype, "rendering", void 0);
|
|
954
|
-
MissingComponentComponent = __decorate([
|
|
955
|
-
Component({
|
|
956
|
-
selector: 'sc-missing-component',
|
|
949
|
+
let MissingComponentComponent = class MissingComponentComponent {
|
|
950
|
+
};
|
|
951
|
+
__decorate([
|
|
952
|
+
Input()
|
|
953
|
+
], MissingComponentComponent.prototype, "rendering", void 0);
|
|
954
|
+
MissingComponentComponent = __decorate([
|
|
955
|
+
Component({
|
|
956
|
+
selector: 'sc-missing-component',
|
|
957
957
|
template: `
|
|
958
958
|
<div style="background: darkorange; outline: 5px solid orange; padding: 10px; color: white; max-width: 500px;">
|
|
959
959
|
<h2>{{ rendering.componentName }}</h2>
|
|
960
960
|
<p>JSS component is missing Angular component implementation.</p>
|
|
961
|
-
</div>`
|
|
962
|
-
})
|
|
961
|
+
</div>`
|
|
962
|
+
})
|
|
963
963
|
], MissingComponentComponent);
|
|
964
964
|
|
|
965
|
-
/**
|
|
966
|
-
* Renders a single JSS component given a rendering definition.
|
|
967
|
-
* Useful inside templated placeholders.
|
|
968
|
-
*/
|
|
969
|
-
let RenderComponentComponent = class RenderComponentComponent {
|
|
970
|
-
constructor(componentFactoryResolver, differs, componentFactory, missingComponentComponent) {
|
|
971
|
-
this.componentFactoryResolver = componentFactoryResolver;
|
|
972
|
-
this.differs = differs;
|
|
973
|
-
this.componentFactory = componentFactory;
|
|
974
|
-
this.missingComponentComponent = missingComponentComponent;
|
|
975
|
-
this.destroyed = false;
|
|
976
|
-
}
|
|
977
|
-
set inputs(value) {
|
|
978
|
-
this._inputs = value;
|
|
979
|
-
if (!this._differ && value) {
|
|
980
|
-
this._differ = this.differs.find(value).create();
|
|
981
|
-
}
|
|
982
|
-
}
|
|
983
|
-
ngOnChanges(changes) {
|
|
984
|
-
if (changes['rendering']) {
|
|
985
|
-
this._render();
|
|
986
|
-
}
|
|
987
|
-
}
|
|
988
|
-
_setComponentInputs(componentInstance, inputs) {
|
|
989
|
-
Object.entries(inputs).forEach(([input, inputValue]) => componentInstance[input] = inputValue);
|
|
990
|
-
}
|
|
991
|
-
_subscribeComponentOutputs(componentInstance, outputs) {
|
|
992
|
-
Object.keys(outputs)
|
|
993
|
-
.filter((output) => componentInstance[output] && componentInstance[output] instanceof Observable)
|
|
994
|
-
.forEach((output) => componentInstance[output]
|
|
995
|
-
.pipe(takeWhile(() => !this.destroyed))
|
|
996
|
-
.subscribe(outputs[output]));
|
|
997
|
-
}
|
|
998
|
-
_render() {
|
|
999
|
-
this.view.clear();
|
|
1000
|
-
if (!this.rendering) {
|
|
1001
|
-
return;
|
|
1002
|
-
}
|
|
1003
|
-
const resolveComponent = isRawRendering(this.rendering)
|
|
1004
|
-
? Promise.resolve({ componentImplementation: RawComponent, componentDefinition: this.rendering })
|
|
1005
|
-
: this.componentFactory.getComponent(this.rendering);
|
|
1006
|
-
resolveComponent.then((rendering) => {
|
|
1007
|
-
if (!rendering.componentImplementation) {
|
|
1008
|
-
const componentName = rendering.componentDefinition.componentName;
|
|
965
|
+
/**
|
|
966
|
+
* Renders a single JSS component given a rendering definition.
|
|
967
|
+
* Useful inside templated placeholders.
|
|
968
|
+
*/
|
|
969
|
+
let RenderComponentComponent = class RenderComponentComponent {
|
|
970
|
+
constructor(componentFactoryResolver, differs, componentFactory, missingComponentComponent) {
|
|
971
|
+
this.componentFactoryResolver = componentFactoryResolver;
|
|
972
|
+
this.differs = differs;
|
|
973
|
+
this.componentFactory = componentFactory;
|
|
974
|
+
this.missingComponentComponent = missingComponentComponent;
|
|
975
|
+
this.destroyed = false;
|
|
976
|
+
}
|
|
977
|
+
set inputs(value) {
|
|
978
|
+
this._inputs = value;
|
|
979
|
+
if (!this._differ && value) {
|
|
980
|
+
this._differ = this.differs.find(value).create();
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
ngOnChanges(changes) {
|
|
984
|
+
if (changes['rendering']) {
|
|
985
|
+
this._render();
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
_setComponentInputs(componentInstance, inputs) {
|
|
989
|
+
Object.entries(inputs).forEach(([input, inputValue]) => componentInstance[input] = inputValue);
|
|
990
|
+
}
|
|
991
|
+
_subscribeComponentOutputs(componentInstance, outputs) {
|
|
992
|
+
Object.keys(outputs)
|
|
993
|
+
.filter((output) => componentInstance[output] && componentInstance[output] instanceof Observable)
|
|
994
|
+
.forEach((output) => componentInstance[output]
|
|
995
|
+
.pipe(takeWhile(() => !this.destroyed))
|
|
996
|
+
.subscribe(outputs[output]));
|
|
997
|
+
}
|
|
998
|
+
_render() {
|
|
999
|
+
this.view.clear();
|
|
1000
|
+
if (!this.rendering) {
|
|
1001
|
+
return;
|
|
1002
|
+
}
|
|
1003
|
+
const resolveComponent = isRawRendering(this.rendering)
|
|
1004
|
+
? Promise.resolve({ componentImplementation: RawComponent, componentDefinition: this.rendering })
|
|
1005
|
+
: this.componentFactory.getComponent(this.rendering);
|
|
1006
|
+
resolveComponent.then((rendering) => {
|
|
1007
|
+
if (!rendering.componentImplementation) {
|
|
1008
|
+
const componentName = rendering.componentDefinition.componentName;
|
|
1009
1009
|
console.error(`Attempted to render unknown component ${componentName}.`, `Ensure component is mapped, like:
|
|
1010
1010
|
JssModule.withComponents([
|
|
1011
1011
|
{ name: '${componentName}', type: ${componentName}Component }
|
|
1012
|
-
])`);
|
|
1013
|
-
rendering.componentImplementation = this.missingComponentComponent;
|
|
1014
|
-
}
|
|
1015
|
-
const componentFactory = rendering.componentFactory || this.componentFactoryResolver.resolveComponentFactory(rendering.componentImplementation);
|
|
1016
|
-
const componentInstance = this.view.createComponent(componentFactory, 0).instance;
|
|
1017
|
-
componentInstance.rendering = rendering.componentDefinition;
|
|
1018
|
-
if (this._inputs) {
|
|
1019
|
-
this._setComponentInputs(componentInstance, this._inputs);
|
|
1020
|
-
}
|
|
1021
|
-
if (this.outputs) {
|
|
1022
|
-
this._subscribeComponentOutputs(componentInstance, this.outputs);
|
|
1023
|
-
}
|
|
1024
|
-
});
|
|
1025
|
-
}
|
|
1026
|
-
};
|
|
1027
|
-
RenderComponentComponent.ctorParameters = () => [
|
|
1028
|
-
{ type: ComponentFactoryResolver },
|
|
1029
|
-
{ type: KeyValueDiffers },
|
|
1030
|
-
{ type: JssComponentFactoryService },
|
|
1031
|
-
{ type: Type, decorators: [{ type: Inject, args: [PLACEHOLDER_MISSING_COMPONENT_COMPONENT,] }] }
|
|
1032
|
-
];
|
|
1033
|
-
__decorate([
|
|
1034
|
-
Input()
|
|
1035
|
-
], RenderComponentComponent.prototype, "rendering", void 0);
|
|
1036
|
-
__decorate([
|
|
1037
|
-
Input()
|
|
1038
|
-
], RenderComponentComponent.prototype, "outputs", void 0);
|
|
1039
|
-
__decorate([
|
|
1040
|
-
ViewChild('view', { read: ViewContainerRef, static: true })
|
|
1041
|
-
], RenderComponentComponent.prototype, "view", void 0);
|
|
1042
|
-
__decorate([
|
|
1043
|
-
Input()
|
|
1044
|
-
], RenderComponentComponent.prototype, "inputs", null);
|
|
1045
|
-
RenderComponentComponent = __decorate([
|
|
1046
|
-
Component({
|
|
1047
|
-
selector: 'sc-render-component',
|
|
1012
|
+
])`);
|
|
1013
|
+
rendering.componentImplementation = this.missingComponentComponent;
|
|
1014
|
+
}
|
|
1015
|
+
const componentFactory = rendering.componentFactory || this.componentFactoryResolver.resolveComponentFactory(rendering.componentImplementation);
|
|
1016
|
+
const componentInstance = this.view.createComponent(componentFactory, 0).instance;
|
|
1017
|
+
componentInstance.rendering = rendering.componentDefinition;
|
|
1018
|
+
if (this._inputs) {
|
|
1019
|
+
this._setComponentInputs(componentInstance, this._inputs);
|
|
1020
|
+
}
|
|
1021
|
+
if (this.outputs) {
|
|
1022
|
+
this._subscribeComponentOutputs(componentInstance, this.outputs);
|
|
1023
|
+
}
|
|
1024
|
+
});
|
|
1025
|
+
}
|
|
1026
|
+
};
|
|
1027
|
+
RenderComponentComponent.ctorParameters = () => [
|
|
1028
|
+
{ type: ComponentFactoryResolver },
|
|
1029
|
+
{ type: KeyValueDiffers },
|
|
1030
|
+
{ type: JssComponentFactoryService },
|
|
1031
|
+
{ type: Type, decorators: [{ type: Inject, args: [PLACEHOLDER_MISSING_COMPONENT_COMPONENT,] }] }
|
|
1032
|
+
];
|
|
1033
|
+
__decorate([
|
|
1034
|
+
Input()
|
|
1035
|
+
], RenderComponentComponent.prototype, "rendering", void 0);
|
|
1036
|
+
__decorate([
|
|
1037
|
+
Input()
|
|
1038
|
+
], RenderComponentComponent.prototype, "outputs", void 0);
|
|
1039
|
+
__decorate([
|
|
1040
|
+
ViewChild('view', { read: ViewContainerRef, static: true })
|
|
1041
|
+
], RenderComponentComponent.prototype, "view", void 0);
|
|
1042
|
+
__decorate([
|
|
1043
|
+
Input()
|
|
1044
|
+
], RenderComponentComponent.prototype, "inputs", null);
|
|
1045
|
+
RenderComponentComponent = __decorate([
|
|
1046
|
+
Component({
|
|
1047
|
+
selector: 'sc-render-component',
|
|
1048
1048
|
template: `
|
|
1049
1049
|
<ng-template #view></ng-template>
|
|
1050
|
-
`
|
|
1051
|
-
}),
|
|
1052
|
-
__param(3, Inject(PLACEHOLDER_MISSING_COMPONENT_COMPONENT))
|
|
1050
|
+
`
|
|
1051
|
+
}),
|
|
1052
|
+
__param(3, Inject(PLACEHOLDER_MISSING_COMPONENT_COMPONENT))
|
|
1053
1053
|
], RenderComponentComponent);
|
|
1054
1054
|
|
|
1055
|
-
var JssModule_1;
|
|
1056
|
-
let JssModule = JssModule_1 = class JssModule {
|
|
1057
|
-
/**
|
|
1058
|
-
* Instantiates the JSS module with no component factory.
|
|
1059
|
-
* Useful for using it from libraries. Most of the time you'd want withComponents()
|
|
1060
|
-
*/
|
|
1061
|
-
static forRoot() {
|
|
1062
|
-
return {
|
|
1063
|
-
ngModule: JssModule_1,
|
|
1064
|
-
providers: [
|
|
1065
|
-
LayoutService,
|
|
1066
|
-
DatePipe,
|
|
1067
|
-
JssComponentFactoryService,
|
|
1068
|
-
],
|
|
1069
|
-
};
|
|
1070
|
-
}
|
|
1071
|
-
/** Instantiates a module for a lazy-loaded JSS component */
|
|
1072
|
-
static forChild(component) {
|
|
1073
|
-
return {
|
|
1074
|
-
ngModule: JssModule_1,
|
|
1075
|
-
providers: [
|
|
1076
|
-
{ provide: ANALYZE_FOR_ENTRY_COMPONENTS, useValue: component, multi: true },
|
|
1077
|
-
{ provide: ROUTES, useValue: [], multi: true },
|
|
1078
|
-
{ provide: DYNAMIC_COMPONENT, useValue: component },
|
|
1079
|
-
],
|
|
1080
|
-
};
|
|
1081
|
-
}
|
|
1082
|
-
/**
|
|
1083
|
-
* Instantiates the JSS module and specifies the mapping from component name to component implementation.
|
|
1084
|
-
* Appropriate when defining the set of JSS components that your app is aware of.
|
|
1085
|
-
*/
|
|
1086
|
-
static withComponents(components, lazyComponents) {
|
|
1087
|
-
return {
|
|
1088
|
-
ngModule: JssModule_1,
|
|
1089
|
-
providers: [
|
|
1090
|
-
{
|
|
1091
|
-
provide: ANALYZE_FOR_ENTRY_COMPONENTS,
|
|
1092
|
-
useValue: components,
|
|
1093
|
-
multi: true,
|
|
1094
|
-
},
|
|
1095
|
-
{ provide: PLACEHOLDER_COMPONENTS, useValue: components },
|
|
1096
|
-
{ provide: PLACEHOLDER_LAZY_COMPONENTS, useValue: lazyComponents || [] },
|
|
1097
|
-
{ provide: ROUTES, useValue: lazyComponents || [], multi: true },
|
|
1098
|
-
{ provide: PLACEHOLDER_MISSING_COMPONENT_COMPONENT, useValue: MissingComponentComponent },
|
|
1099
|
-
...JssModule_1.forRoot().providers,
|
|
1100
|
-
],
|
|
1101
|
-
};
|
|
1102
|
-
}
|
|
1103
|
-
};
|
|
1104
|
-
JssModule = JssModule_1 = __decorate([
|
|
1105
|
-
NgModule({
|
|
1106
|
-
imports: [
|
|
1107
|
-
CommonModule,
|
|
1108
|
-
],
|
|
1109
|
-
declarations: [
|
|
1110
|
-
FileDirective,
|
|
1111
|
-
ImageDirective,
|
|
1112
|
-
LinkDirective,
|
|
1113
|
-
RouterLinkDirective,
|
|
1114
|
-
GenericLinkDirective,
|
|
1115
|
-
DateDirective,
|
|
1116
|
-
RenderEachDirective,
|
|
1117
|
-
RenderEmptyDirective,
|
|
1118
|
-
PlaceholderLoadingDirective,
|
|
1119
|
-
RenderComponentComponent,
|
|
1120
|
-
PlaceholderComponent,
|
|
1121
|
-
RawComponent,
|
|
1122
|
-
RichTextDirective,
|
|
1123
|
-
TextDirective,
|
|
1124
|
-
MissingComponentComponent,
|
|
1125
|
-
],
|
|
1126
|
-
exports: [
|
|
1127
|
-
FileDirective,
|
|
1128
|
-
ImageDirective,
|
|
1129
|
-
DateDirective,
|
|
1130
|
-
LinkDirective,
|
|
1131
|
-
RouterLinkDirective,
|
|
1132
|
-
GenericLinkDirective,
|
|
1133
|
-
RenderEachDirective,
|
|
1134
|
-
RenderEmptyDirective,
|
|
1135
|
-
RenderComponentComponent,
|
|
1136
|
-
PlaceholderComponent,
|
|
1137
|
-
PlaceholderLoadingDirective,
|
|
1138
|
-
RichTextDirective,
|
|
1139
|
-
TextDirective,
|
|
1140
|
-
],
|
|
1141
|
-
entryComponents: [
|
|
1142
|
-
RawComponent,
|
|
1143
|
-
MissingComponentComponent,
|
|
1144
|
-
],
|
|
1145
|
-
})
|
|
1055
|
+
var JssModule_1;
|
|
1056
|
+
let JssModule = JssModule_1 = class JssModule {
|
|
1057
|
+
/**
|
|
1058
|
+
* Instantiates the JSS module with no component factory.
|
|
1059
|
+
* Useful for using it from libraries. Most of the time you'd want withComponents()
|
|
1060
|
+
*/
|
|
1061
|
+
static forRoot() {
|
|
1062
|
+
return {
|
|
1063
|
+
ngModule: JssModule_1,
|
|
1064
|
+
providers: [
|
|
1065
|
+
LayoutService,
|
|
1066
|
+
DatePipe,
|
|
1067
|
+
JssComponentFactoryService,
|
|
1068
|
+
],
|
|
1069
|
+
};
|
|
1070
|
+
}
|
|
1071
|
+
/** Instantiates a module for a lazy-loaded JSS component */
|
|
1072
|
+
static forChild(component) {
|
|
1073
|
+
return {
|
|
1074
|
+
ngModule: JssModule_1,
|
|
1075
|
+
providers: [
|
|
1076
|
+
{ provide: ANALYZE_FOR_ENTRY_COMPONENTS, useValue: component, multi: true },
|
|
1077
|
+
{ provide: ROUTES, useValue: [], multi: true },
|
|
1078
|
+
{ provide: DYNAMIC_COMPONENT, useValue: component },
|
|
1079
|
+
],
|
|
1080
|
+
};
|
|
1081
|
+
}
|
|
1082
|
+
/**
|
|
1083
|
+
* Instantiates the JSS module and specifies the mapping from component name to component implementation.
|
|
1084
|
+
* Appropriate when defining the set of JSS components that your app is aware of.
|
|
1085
|
+
*/
|
|
1086
|
+
static withComponents(components, lazyComponents) {
|
|
1087
|
+
return {
|
|
1088
|
+
ngModule: JssModule_1,
|
|
1089
|
+
providers: [
|
|
1090
|
+
{
|
|
1091
|
+
provide: ANALYZE_FOR_ENTRY_COMPONENTS,
|
|
1092
|
+
useValue: components,
|
|
1093
|
+
multi: true,
|
|
1094
|
+
},
|
|
1095
|
+
{ provide: PLACEHOLDER_COMPONENTS, useValue: components },
|
|
1096
|
+
{ provide: PLACEHOLDER_LAZY_COMPONENTS, useValue: lazyComponents || [] },
|
|
1097
|
+
{ provide: ROUTES, useValue: lazyComponents || [], multi: true },
|
|
1098
|
+
{ provide: PLACEHOLDER_MISSING_COMPONENT_COMPONENT, useValue: MissingComponentComponent },
|
|
1099
|
+
...JssModule_1.forRoot().providers,
|
|
1100
|
+
],
|
|
1101
|
+
};
|
|
1102
|
+
}
|
|
1103
|
+
};
|
|
1104
|
+
JssModule = JssModule_1 = __decorate([
|
|
1105
|
+
NgModule({
|
|
1106
|
+
imports: [
|
|
1107
|
+
CommonModule,
|
|
1108
|
+
],
|
|
1109
|
+
declarations: [
|
|
1110
|
+
FileDirective,
|
|
1111
|
+
ImageDirective,
|
|
1112
|
+
LinkDirective,
|
|
1113
|
+
RouterLinkDirective,
|
|
1114
|
+
GenericLinkDirective,
|
|
1115
|
+
DateDirective,
|
|
1116
|
+
RenderEachDirective,
|
|
1117
|
+
RenderEmptyDirective,
|
|
1118
|
+
PlaceholderLoadingDirective,
|
|
1119
|
+
RenderComponentComponent,
|
|
1120
|
+
PlaceholderComponent,
|
|
1121
|
+
RawComponent,
|
|
1122
|
+
RichTextDirective,
|
|
1123
|
+
TextDirective,
|
|
1124
|
+
MissingComponentComponent,
|
|
1125
|
+
],
|
|
1126
|
+
exports: [
|
|
1127
|
+
FileDirective,
|
|
1128
|
+
ImageDirective,
|
|
1129
|
+
DateDirective,
|
|
1130
|
+
LinkDirective,
|
|
1131
|
+
RouterLinkDirective,
|
|
1132
|
+
GenericLinkDirective,
|
|
1133
|
+
RenderEachDirective,
|
|
1134
|
+
RenderEmptyDirective,
|
|
1135
|
+
RenderComponentComponent,
|
|
1136
|
+
PlaceholderComponent,
|
|
1137
|
+
PlaceholderLoadingDirective,
|
|
1138
|
+
RichTextDirective,
|
|
1139
|
+
TextDirective,
|
|
1140
|
+
],
|
|
1141
|
+
entryComponents: [
|
|
1142
|
+
RawComponent,
|
|
1143
|
+
MissingComponentComponent,
|
|
1144
|
+
],
|
|
1145
|
+
})
|
|
1146
1146
|
], JssModule);
|
|
1147
1147
|
|
|
1148
|
-
/**
|
|
1149
|
-
* Generated bundle index. Do not edit.
|
|
1148
|
+
/**
|
|
1149
|
+
* Generated bundle index. Do not edit.
|
|
1150
1150
|
*/
|
|
1151
1151
|
|
|
1152
1152
|
export { ComponentNameAndType, DYNAMIC_COMPONENT, FileDirective, GenericLinkDirective, ImageDirective, JssModule, LayoutService, LayoutServiceError, LinkDirective, PlaceholderComponent, PlaceholderLoadingDirective, RichTextDirective, RouterLinkDirective, TextDirective, 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 };
|