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