@sitecore-jss/sitecore-jss-angular 21.2.2 → 21.2.3-canary.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +202 -202
- package/README.md +7 -7
- package/angular.json +48 -48
- package/dist/README.md +7 -7
- package/dist/components/data-resolver-factory.d.ts +13 -13
- package/dist/components/date.directive.d.ts +20 -20
- package/dist/components/editframe.component.d.ts +22 -22
- package/dist/components/file.directive.d.ts +17 -17
- package/dist/components/generic-link.directive.d.ts +20 -20
- package/dist/components/guard-resolver-factory.d.ts +11 -11
- package/dist/components/hidden-rendering.component.d.ts +7 -7
- package/dist/components/image.directive.d.ts +35 -35
- package/dist/components/link.directive.d.ts +26 -26
- package/dist/components/missing-component.component.d.ts +7 -7
- package/dist/components/placeholder-loading.directive.d.ts +8 -8
- package/dist/components/placeholder.component.d.ts +59 -59
- package/dist/components/placeholder.token.d.ts +64 -64
- package/dist/components/raw.component.d.ts +12 -12
- package/dist/components/render-component.component.d.ts +33 -33
- package/dist/components/render-each.directive.d.ts +8 -8
- package/dist/components/render-empty.directive.d.ts +8 -8
- package/dist/components/rendering-field.d.ts +41 -41
- package/dist/components/rendering.d.ts +5 -5
- package/dist/components/rich-text.directive.d.ts +18 -18
- package/dist/components/router-link.directive.d.ts +19 -19
- package/dist/components/text.directive.d.ts +16 -16
- package/dist/esm2020/components/data-resolver-factory.mjs +57 -57
- package/dist/esm2020/components/date.directive.mjs +59 -59
- package/dist/esm2020/components/editframe.component.mjs +65 -65
- package/dist/esm2020/components/file.directive.mjs +44 -44
- package/dist/esm2020/components/generic-link.directive.mjs +64 -64
- package/dist/esm2020/components/guard-resolver-factory.mjs +87 -87
- package/dist/esm2020/components/hidden-rendering.component.mjs +20 -20
- package/dist/esm2020/components/image.directive.mjs +137 -137
- package/dist/esm2020/components/link.directive.mjs +117 -117
- package/dist/esm2020/components/missing-component.component.mjs +15 -15
- package/dist/esm2020/components/placeholder-loading.directive.mjs +15 -15
- package/dist/esm2020/components/placeholder.component.mjs +250 -250
- package/dist/esm2020/components/placeholder.token.mjs +23 -23
- package/dist/esm2020/components/raw.component.mjs +35 -35
- package/dist/esm2020/components/render-component.component.mjs +90 -90
- package/dist/esm2020/components/render-each.directive.mjs +15 -15
- package/dist/esm2020/components/render-empty.directive.mjs +15 -15
- package/dist/esm2020/components/rendering-field.mjs +1 -1
- package/dist/esm2020/components/rendering.mjs +7 -7
- package/dist/esm2020/components/rich-text.directive.mjs +62 -62
- package/dist/esm2020/components/router-link.directive.mjs +47 -47
- package/dist/esm2020/components/text.directive.mjs +57 -57
- package/dist/esm2020/jss-component-factory.service.mjs +83 -83
- package/dist/esm2020/lib.module.mjs +167 -167
- package/dist/esm2020/public_api.mjs +24 -24
- package/dist/esm2020/sitecore-jss-sitecore-jss-angular.mjs +4 -4
- package/dist/esm2020/utils.mjs +16 -16
- package/dist/fesm2015/sitecore-jss-sitecore-jss-angular.mjs +1415 -1415
- package/dist/fesm2020/sitecore-jss-sitecore-jss-angular.mjs +1422 -1422
- package/dist/index.d.ts +5 -5
- package/dist/jss-component-factory.service.d.ts +25 -25
- package/dist/lib.module.d.ts +46 -46
- package/dist/public_api.d.ts +25 -25
- package/dist/typings/README.md +2 -2
- package/dist/utils.d.ts +7 -7
- package/ng-package.json +13 -13
- package/package.json +3 -3
- package/tsconfig.json +9 -9
- package/tsconfig.spec.json +16 -16
- package/typings/README.md +2 -2
|
@@ -15,1046 +15,1046 @@ export { GraphQLLayoutService, RestLayoutService, getChildPlaceholder, getFieldV
|
|
|
15
15
|
export { constants, enableDebug } from '@sitecore-jss/sitecore-jss';
|
|
16
16
|
export { trackingApi } from '@sitecore-jss/sitecore-jss/tracking';
|
|
17
17
|
|
|
18
|
-
/**
|
|
19
|
-
* File fields cannot be managed via the EE. We never output "editable."
|
|
20
|
-
*/
|
|
21
|
-
class FileDirective {
|
|
22
|
-
constructor(viewContainer, templateRef) {
|
|
23
|
-
this.viewContainer = viewContainer;
|
|
24
|
-
this.templateRef = templateRef;
|
|
25
|
-
}
|
|
26
|
-
ngOnChanges(changes) {
|
|
27
|
-
if (changes.field) {
|
|
28
|
-
if (!this.viewRef) {
|
|
29
|
-
this.viewContainer.clear();
|
|
30
|
-
this.viewRef = this.viewContainer.createEmbeddedView(this.templateRef);
|
|
31
|
-
}
|
|
32
|
-
this.updateView();
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
updateView() {
|
|
36
|
-
const field = this.field;
|
|
37
|
-
if (!field || (!field.value && !field.src)) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
const file = field.src ? field : field.value;
|
|
41
|
-
this.viewRef.rootNodes.forEach((node) => {
|
|
42
|
-
if (!file)
|
|
43
|
-
return;
|
|
44
|
-
node.href = file.src;
|
|
45
|
-
if (node.innerHTML === '') {
|
|
46
|
-
node.innerHTML = file.title || file.displayName;
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
FileDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: FileDirective, deps: [{ token: i0.ViewContainerRef }, { token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
52
|
-
FileDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.12", type: FileDirective, selector: "[scFile]", inputs: { field: ["scFile", "field"] }, usesOnChanges: true, ngImport: i0 });
|
|
53
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: FileDirective, decorators: [{
|
|
54
|
-
type: Directive,
|
|
55
|
-
args: [{ selector: '[scFile]' }]
|
|
56
|
-
}], ctorParameters: function () { return [{ type: i0.ViewContainerRef }, { type: i0.TemplateRef }]; }, propDecorators: { field: [{
|
|
57
|
-
type: Input,
|
|
58
|
-
args: ['scFile']
|
|
18
|
+
/**
|
|
19
|
+
* File fields cannot be managed via the EE. We never output "editable."
|
|
20
|
+
*/
|
|
21
|
+
class FileDirective {
|
|
22
|
+
constructor(viewContainer, templateRef) {
|
|
23
|
+
this.viewContainer = viewContainer;
|
|
24
|
+
this.templateRef = templateRef;
|
|
25
|
+
}
|
|
26
|
+
ngOnChanges(changes) {
|
|
27
|
+
if (changes.field) {
|
|
28
|
+
if (!this.viewRef) {
|
|
29
|
+
this.viewContainer.clear();
|
|
30
|
+
this.viewRef = this.viewContainer.createEmbeddedView(this.templateRef);
|
|
31
|
+
}
|
|
32
|
+
this.updateView();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
updateView() {
|
|
36
|
+
const field = this.field;
|
|
37
|
+
if (!field || (!field.value && !field.src)) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const file = field.src ? field : field.value;
|
|
41
|
+
this.viewRef.rootNodes.forEach((node) => {
|
|
42
|
+
if (!file)
|
|
43
|
+
return;
|
|
44
|
+
node.href = file.src;
|
|
45
|
+
if (node.innerHTML === '') {
|
|
46
|
+
node.innerHTML = file.title || file.displayName;
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
FileDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: FileDirective, deps: [{ token: i0.ViewContainerRef }, { token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
52
|
+
FileDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.12", type: FileDirective, selector: "[scFile]", inputs: { field: ["scFile", "field"] }, usesOnChanges: true, ngImport: i0 });
|
|
53
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: FileDirective, decorators: [{
|
|
54
|
+
type: Directive,
|
|
55
|
+
args: [{ selector: '[scFile]' }]
|
|
56
|
+
}], ctorParameters: function () { return [{ type: i0.ViewContainerRef }, { type: i0.TemplateRef }]; }, propDecorators: { field: [{
|
|
57
|
+
type: Input,
|
|
58
|
+
args: ['scFile']
|
|
59
59
|
}] } });
|
|
60
60
|
|
|
61
|
-
class ImageDirective {
|
|
62
|
-
constructor(viewContainer, templateRef, renderer, elementRef) {
|
|
63
|
-
this.viewContainer = viewContainer;
|
|
64
|
-
this.templateRef = templateRef;
|
|
65
|
-
this.renderer = renderer;
|
|
66
|
-
this.elementRef = elementRef;
|
|
67
|
-
this.editable = true;
|
|
68
|
-
this.urlParams = {};
|
|
69
|
-
this.attrs = {};
|
|
70
|
-
this.inlineRef = null;
|
|
71
|
-
}
|
|
72
|
-
ngOnChanges(changes) {
|
|
73
|
-
if (changes.field || changes.editable || changes.urlParams || changes.attrs) {
|
|
74
|
-
this.viewContainer.clear();
|
|
75
|
-
if (this.inlineRef) {
|
|
76
|
-
this.inlineRef.remove();
|
|
77
|
-
this.inlineRef = null;
|
|
78
|
-
}
|
|
79
|
-
this.updateView();
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
updateView() {
|
|
83
|
-
const overrideAttrs = {
|
|
84
|
-
...this.getElementAttrs(),
|
|
85
|
-
...this.attrs,
|
|
86
|
-
};
|
|
87
|
-
const media = this.field;
|
|
88
|
-
if (!media || (!media.editable && !media.value && !media.src)) {
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
let attrs = {};
|
|
92
|
-
// we likely have an experience editor value, should be a string
|
|
93
|
-
if (this.editable && media.editable) {
|
|
94
|
-
const foundImg = mediaApi.findEditorImageTag(media.editable);
|
|
95
|
-
if (!foundImg) {
|
|
96
|
-
return this.renderInlineWrapper(media.editable);
|
|
97
|
-
}
|
|
98
|
-
attrs = this.getImageAttrs(foundImg.attrs, overrideAttrs, this.urlParams);
|
|
99
|
-
if (!attrs) {
|
|
100
|
-
return this.renderInlineWrapper(media.editable);
|
|
101
|
-
}
|
|
102
|
-
const tempImg = this.renderer.createElement('img');
|
|
103
|
-
Object.entries(attrs).forEach(([key, attrValue]) => tempImg.setAttribute(key, attrValue));
|
|
104
|
-
const editableMarkup = media.editable.replace(foundImg.imgTag, tempImg.outerHTML);
|
|
105
|
-
return this.renderInlineWrapper(editableMarkup);
|
|
106
|
-
}
|
|
107
|
-
// some wise-guy/gal is passing in a 'raw' image object value
|
|
108
|
-
const img = media.src ? media : media.value;
|
|
109
|
-
if (!img) {
|
|
110
|
-
return null;
|
|
111
|
-
}
|
|
112
|
-
attrs = this.getImageAttrs(img, overrideAttrs, this.urlParams);
|
|
113
|
-
if (attrs) {
|
|
114
|
-
this.renderTemplate(attrs);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
getImageAttrs(fieldAttrs, parsedAttrs, imageParams) {
|
|
118
|
-
const combinedAttrs = {
|
|
119
|
-
...fieldAttrs,
|
|
120
|
-
...parsedAttrs,
|
|
121
|
-
};
|
|
122
|
-
// eslint-disable-next-line prefer-const
|
|
123
|
-
let { src, srcSet, ...otherAttrs } = combinedAttrs;
|
|
124
|
-
if (!src) {
|
|
125
|
-
return null;
|
|
126
|
-
}
|
|
127
|
-
const newAttrs = {
|
|
128
|
-
...otherAttrs,
|
|
129
|
-
};
|
|
130
|
-
// update image URL for jss handler and image rendering params
|
|
131
|
-
src = mediaApi.updateImageUrl(src, imageParams, this.mediaUrlPrefix);
|
|
132
|
-
if (srcSet) {
|
|
133
|
-
// replace with HTML-formatted srcset, including updated image URLs
|
|
134
|
-
newAttrs.srcSet = mediaApi.getSrcSet(src, srcSet, imageParams, this.mediaUrlPrefix);
|
|
135
|
-
}
|
|
136
|
-
else {
|
|
137
|
-
newAttrs.src = src;
|
|
138
|
-
}
|
|
139
|
-
return newAttrs;
|
|
140
|
-
}
|
|
141
|
-
renderTemplate(imageProps) {
|
|
142
|
-
const viewRef = this.viewContainer.createEmbeddedView(this.templateRef);
|
|
143
|
-
viewRef.rootNodes.forEach((node) => {
|
|
144
|
-
Object.entries(imageProps).forEach(([key, imgPropVal]) => this.renderer.setAttribute(node, key, imgPropVal));
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
getElementAttrs() {
|
|
148
|
-
const view = this.templateRef.createEmbeddedView(null);
|
|
149
|
-
const element = view.rootNodes[0];
|
|
150
|
-
if (!element) {
|
|
151
|
-
view.destroy();
|
|
152
|
-
return {};
|
|
153
|
-
}
|
|
154
|
-
const attrs = {};
|
|
155
|
-
for (let i = 0; i < element.attributes.length; i++) {
|
|
156
|
-
const attr = element.attributes.item(i);
|
|
157
|
-
if (attr) {
|
|
158
|
-
attrs[attr.name] = attr.value;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
view.destroy();
|
|
162
|
-
return attrs;
|
|
163
|
-
}
|
|
164
|
-
renderInlineWrapper(editable) {
|
|
165
|
-
const span = this.renderer.createElement('span');
|
|
166
|
-
span.className = 'sc-image-wrapper';
|
|
167
|
-
span.innerHTML = editable;
|
|
168
|
-
const parentNode = this.renderer.parentNode(this.elementRef.nativeElement);
|
|
169
|
-
this.renderer.insertBefore(parentNode, span, this.elementRef.nativeElement);
|
|
170
|
-
parentNode.removeChild(this.elementRef.nativeElement);
|
|
171
|
-
this.inlineRef = span;
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
ImageDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: ImageDirective, deps: [{ token: i0.ViewContainerRef }, { token: i0.TemplateRef }, { token: i0.Renderer2 }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
175
|
-
ImageDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.12", type: ImageDirective, selector: "[scImage]", inputs: { field: ["scImage", "field"], editable: ["scImageEditable", "editable"], mediaUrlPrefix: ["scImageMediaUrlPrefix", "mediaUrlPrefix"], urlParams: ["scImageUrlParams", "urlParams"], attrs: ["scImageAttrs", "attrs"] }, usesOnChanges: true, ngImport: i0 });
|
|
176
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: ImageDirective, decorators: [{
|
|
177
|
-
type: Directive,
|
|
178
|
-
args: [{ selector: '[scImage]' }]
|
|
179
|
-
}], ctorParameters: function () { return [{ type: i0.ViewContainerRef }, { type: i0.TemplateRef }, { type: i0.Renderer2 }, { type: i0.ElementRef }]; }, propDecorators: { field: [{
|
|
180
|
-
type: Input,
|
|
181
|
-
args: ['scImage']
|
|
182
|
-
}], editable: [{
|
|
183
|
-
type: Input,
|
|
184
|
-
args: ['scImageEditable']
|
|
185
|
-
}], mediaUrlPrefix: [{
|
|
186
|
-
type: Input,
|
|
187
|
-
args: ['scImageMediaUrlPrefix']
|
|
188
|
-
}], urlParams: [{
|
|
189
|
-
type: Input,
|
|
190
|
-
args: ['scImageUrlParams']
|
|
191
|
-
}], attrs: [{
|
|
192
|
-
type: Input,
|
|
193
|
-
args: ['scImageAttrs']
|
|
61
|
+
class ImageDirective {
|
|
62
|
+
constructor(viewContainer, templateRef, renderer, elementRef) {
|
|
63
|
+
this.viewContainer = viewContainer;
|
|
64
|
+
this.templateRef = templateRef;
|
|
65
|
+
this.renderer = renderer;
|
|
66
|
+
this.elementRef = elementRef;
|
|
67
|
+
this.editable = true;
|
|
68
|
+
this.urlParams = {};
|
|
69
|
+
this.attrs = {};
|
|
70
|
+
this.inlineRef = null;
|
|
71
|
+
}
|
|
72
|
+
ngOnChanges(changes) {
|
|
73
|
+
if (changes.field || changes.editable || changes.urlParams || changes.attrs) {
|
|
74
|
+
this.viewContainer.clear();
|
|
75
|
+
if (this.inlineRef) {
|
|
76
|
+
this.inlineRef.remove();
|
|
77
|
+
this.inlineRef = null;
|
|
78
|
+
}
|
|
79
|
+
this.updateView();
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
updateView() {
|
|
83
|
+
const overrideAttrs = {
|
|
84
|
+
...this.getElementAttrs(),
|
|
85
|
+
...this.attrs,
|
|
86
|
+
};
|
|
87
|
+
const media = this.field;
|
|
88
|
+
if (!media || (!media.editable && !media.value && !media.src)) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
let attrs = {};
|
|
92
|
+
// we likely have an experience editor value, should be a string
|
|
93
|
+
if (this.editable && media.editable) {
|
|
94
|
+
const foundImg = mediaApi.findEditorImageTag(media.editable);
|
|
95
|
+
if (!foundImg) {
|
|
96
|
+
return this.renderInlineWrapper(media.editable);
|
|
97
|
+
}
|
|
98
|
+
attrs = this.getImageAttrs(foundImg.attrs, overrideAttrs, this.urlParams);
|
|
99
|
+
if (!attrs) {
|
|
100
|
+
return this.renderInlineWrapper(media.editable);
|
|
101
|
+
}
|
|
102
|
+
const tempImg = this.renderer.createElement('img');
|
|
103
|
+
Object.entries(attrs).forEach(([key, attrValue]) => tempImg.setAttribute(key, attrValue));
|
|
104
|
+
const editableMarkup = media.editable.replace(foundImg.imgTag, tempImg.outerHTML);
|
|
105
|
+
return this.renderInlineWrapper(editableMarkup);
|
|
106
|
+
}
|
|
107
|
+
// some wise-guy/gal is passing in a 'raw' image object value
|
|
108
|
+
const img = media.src ? media : media.value;
|
|
109
|
+
if (!img) {
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
attrs = this.getImageAttrs(img, overrideAttrs, this.urlParams);
|
|
113
|
+
if (attrs) {
|
|
114
|
+
this.renderTemplate(attrs);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
getImageAttrs(fieldAttrs, parsedAttrs, imageParams) {
|
|
118
|
+
const combinedAttrs = {
|
|
119
|
+
...fieldAttrs,
|
|
120
|
+
...parsedAttrs,
|
|
121
|
+
};
|
|
122
|
+
// eslint-disable-next-line prefer-const
|
|
123
|
+
let { src, srcSet, ...otherAttrs } = combinedAttrs;
|
|
124
|
+
if (!src) {
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
const newAttrs = {
|
|
128
|
+
...otherAttrs,
|
|
129
|
+
};
|
|
130
|
+
// update image URL for jss handler and image rendering params
|
|
131
|
+
src = mediaApi.updateImageUrl(src, imageParams, this.mediaUrlPrefix);
|
|
132
|
+
if (srcSet) {
|
|
133
|
+
// replace with HTML-formatted srcset, including updated image URLs
|
|
134
|
+
newAttrs.srcSet = mediaApi.getSrcSet(src, srcSet, imageParams, this.mediaUrlPrefix);
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
newAttrs.src = src;
|
|
138
|
+
}
|
|
139
|
+
return newAttrs;
|
|
140
|
+
}
|
|
141
|
+
renderTemplate(imageProps) {
|
|
142
|
+
const viewRef = this.viewContainer.createEmbeddedView(this.templateRef);
|
|
143
|
+
viewRef.rootNodes.forEach((node) => {
|
|
144
|
+
Object.entries(imageProps).forEach(([key, imgPropVal]) => this.renderer.setAttribute(node, key, imgPropVal));
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
getElementAttrs() {
|
|
148
|
+
const view = this.templateRef.createEmbeddedView(null);
|
|
149
|
+
const element = view.rootNodes[0];
|
|
150
|
+
if (!element) {
|
|
151
|
+
view.destroy();
|
|
152
|
+
return {};
|
|
153
|
+
}
|
|
154
|
+
const attrs = {};
|
|
155
|
+
for (let i = 0; i < element.attributes.length; i++) {
|
|
156
|
+
const attr = element.attributes.item(i);
|
|
157
|
+
if (attr) {
|
|
158
|
+
attrs[attr.name] = attr.value;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
view.destroy();
|
|
162
|
+
return attrs;
|
|
163
|
+
}
|
|
164
|
+
renderInlineWrapper(editable) {
|
|
165
|
+
const span = this.renderer.createElement('span');
|
|
166
|
+
span.className = 'sc-image-wrapper';
|
|
167
|
+
span.innerHTML = editable;
|
|
168
|
+
const parentNode = this.renderer.parentNode(this.elementRef.nativeElement);
|
|
169
|
+
this.renderer.insertBefore(parentNode, span, this.elementRef.nativeElement);
|
|
170
|
+
parentNode.removeChild(this.elementRef.nativeElement);
|
|
171
|
+
this.inlineRef = span;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
ImageDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: ImageDirective, deps: [{ token: i0.ViewContainerRef }, { token: i0.TemplateRef }, { token: i0.Renderer2 }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
175
|
+
ImageDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.12", type: ImageDirective, selector: "[scImage]", inputs: { field: ["scImage", "field"], editable: ["scImageEditable", "editable"], mediaUrlPrefix: ["scImageMediaUrlPrefix", "mediaUrlPrefix"], urlParams: ["scImageUrlParams", "urlParams"], attrs: ["scImageAttrs", "attrs"] }, usesOnChanges: true, ngImport: i0 });
|
|
176
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: ImageDirective, decorators: [{
|
|
177
|
+
type: Directive,
|
|
178
|
+
args: [{ selector: '[scImage]' }]
|
|
179
|
+
}], ctorParameters: function () { return [{ type: i0.ViewContainerRef }, { type: i0.TemplateRef }, { type: i0.Renderer2 }, { type: i0.ElementRef }]; }, propDecorators: { field: [{
|
|
180
|
+
type: Input,
|
|
181
|
+
args: ['scImage']
|
|
182
|
+
}], editable: [{
|
|
183
|
+
type: Input,
|
|
184
|
+
args: ['scImageEditable']
|
|
185
|
+
}], mediaUrlPrefix: [{
|
|
186
|
+
type: Input,
|
|
187
|
+
args: ['scImageMediaUrlPrefix']
|
|
188
|
+
}], urlParams: [{
|
|
189
|
+
type: Input,
|
|
190
|
+
args: ['scImageUrlParams']
|
|
191
|
+
}], attrs: [{
|
|
192
|
+
type: Input,
|
|
193
|
+
args: ['scImageAttrs']
|
|
194
194
|
}] } });
|
|
195
195
|
|
|
196
|
-
class LinkDirective {
|
|
197
|
-
constructor(viewContainer, templateRef, renderer, elementRef) {
|
|
198
|
-
this.viewContainer = viewContainer;
|
|
199
|
-
this.templateRef = templateRef;
|
|
200
|
-
this.renderer = renderer;
|
|
201
|
-
this.elementRef = elementRef;
|
|
202
|
-
this.editable = true;
|
|
203
|
-
this.attrs = {};
|
|
204
|
-
this.inlineRef = null;
|
|
205
|
-
}
|
|
206
|
-
ngOnChanges(changes) {
|
|
207
|
-
if (changes.field || changes.editable || changes.attrs) {
|
|
208
|
-
this.viewContainer.clear();
|
|
209
|
-
if (this.inlineRef) {
|
|
210
|
-
this.inlineRef.remove();
|
|
211
|
-
this.inlineRef = null;
|
|
212
|
-
}
|
|
213
|
-
this.updateView();
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
renderTemplate(props, linkText) {
|
|
217
|
-
const viewRef = this.viewContainer.createEmbeddedView(this.templateRef);
|
|
218
|
-
viewRef.rootNodes.forEach((node) => {
|
|
219
|
-
Object.entries(props).forEach(([key, propValue]) => {
|
|
220
|
-
this.updateAttribute(node, key, propValue);
|
|
221
|
-
});
|
|
222
|
-
if (node.childNodes && node.childNodes.length === 0 && linkText) {
|
|
223
|
-
node.textContent = linkText;
|
|
224
|
-
}
|
|
225
|
-
});
|
|
226
|
-
}
|
|
227
|
-
updateAttribute(node, key, propValue) {
|
|
228
|
-
if (typeof propValue !== 'string' || !propValue || propValue === '') {
|
|
229
|
-
return;
|
|
230
|
-
}
|
|
231
|
-
if (key === 'href') {
|
|
232
|
-
const isInvalidLink = !propValue || /^https?:\/\/$/.test(propValue);
|
|
233
|
-
if (isInvalidLink) {
|
|
234
|
-
if (!node.href) {
|
|
235
|
-
return;
|
|
236
|
-
}
|
|
237
|
-
propValue = node.href;
|
|
238
|
-
}
|
|
239
|
-
this.renderer.setAttribute(node, key, propValue);
|
|
240
|
-
}
|
|
241
|
-
else if (key === 'class' && node.className !== '') {
|
|
242
|
-
this.renderer.setAttribute(node, key, `${node.className} ${propValue}`);
|
|
243
|
-
}
|
|
244
|
-
else {
|
|
245
|
-
this.renderer.setAttribute(node, key, propValue);
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
updateView() {
|
|
249
|
-
const field = this.field;
|
|
250
|
-
if (this.editable && field && field.editableFirstPart && field.editableLastPart) {
|
|
251
|
-
this.renderInlineWrapper(field.editableFirstPart, field.editableLastPart);
|
|
252
|
-
}
|
|
253
|
-
else if (field && (field.href || field.value)) {
|
|
254
|
-
const props = field.href ? field : field.value;
|
|
255
|
-
const linkText = field.text || field.value?.text || field.href || field.value?.href;
|
|
256
|
-
const anchor = props?.anchor ? `#${props.anchor}` : '';
|
|
257
|
-
const href = `${props?.href}${anchor}`;
|
|
258
|
-
const mergedAttrs = { ...props, ...this.attrs, href };
|
|
259
|
-
delete mergedAttrs.anchor;
|
|
260
|
-
this.renderTemplate(mergedAttrs, linkText);
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
renderInlineWrapper(editableFirstPart, editableLastPart) {
|
|
264
|
-
const span = this.renderer.createElement('span');
|
|
265
|
-
span.className = 'sc-link-wrapper';
|
|
266
|
-
span.innerHTML = editableFirstPart + editableLastPart;
|
|
267
|
-
// assign attributes from template to inline wrapper
|
|
268
|
-
const attrs = {
|
|
269
|
-
...this.getElementAttrs(),
|
|
270
|
-
...this.attrs,
|
|
271
|
-
};
|
|
272
|
-
Object.entries(attrs).forEach(([key, attrValue]) => this.updateAttribute(span, key, attrValue));
|
|
273
|
-
this.viewContainer.createEmbeddedView(this.templateRef);
|
|
274
|
-
const parentNode = this.renderer.parentNode(this.elementRef.nativeElement);
|
|
275
|
-
this.renderer.insertBefore(parentNode, span, this.elementRef.nativeElement);
|
|
276
|
-
this.inlineRef = span;
|
|
277
|
-
}
|
|
278
|
-
getElementAttrs() {
|
|
279
|
-
const view = this.templateRef.createEmbeddedView(null);
|
|
280
|
-
const element = view.rootNodes[0];
|
|
281
|
-
if (!element) {
|
|
282
|
-
view.destroy();
|
|
283
|
-
return {};
|
|
284
|
-
}
|
|
285
|
-
const attrs = {};
|
|
286
|
-
for (let i = 0; i < element.attributes.length; i++) {
|
|
287
|
-
const attr = element.attributes.item(i);
|
|
288
|
-
if (attr) {
|
|
289
|
-
attrs[attr.name] = attr.value;
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
view.destroy();
|
|
293
|
-
return attrs;
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
LinkDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: LinkDirective, deps: [{ token: i0.ViewContainerRef }, { token: i0.TemplateRef }, { token: i0.Renderer2 }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
297
|
-
LinkDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.12", type: LinkDirective, selector: "[scLink]", inputs: { editable: ["scLinkEditable", "editable"], attrs: ["scLinkAttrs", "attrs"], field: ["scLink", "field"] }, usesOnChanges: true, ngImport: i0 });
|
|
298
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: LinkDirective, decorators: [{
|
|
299
|
-
type: Directive,
|
|
300
|
-
args: [{ selector: '[scLink]' }]
|
|
301
|
-
}], ctorParameters: function () { return [{ type: i0.ViewContainerRef }, { type: i0.TemplateRef }, { type: i0.Renderer2 }, { type: i0.ElementRef }]; }, propDecorators: { editable: [{
|
|
302
|
-
type: Input,
|
|
303
|
-
args: ['scLinkEditable']
|
|
304
|
-
}], attrs: [{
|
|
305
|
-
type: Input,
|
|
306
|
-
args: ['scLinkAttrs']
|
|
307
|
-
}], field: [{
|
|
308
|
-
type: Input,
|
|
309
|
-
args: ['scLink']
|
|
196
|
+
class LinkDirective {
|
|
197
|
+
constructor(viewContainer, templateRef, renderer, elementRef) {
|
|
198
|
+
this.viewContainer = viewContainer;
|
|
199
|
+
this.templateRef = templateRef;
|
|
200
|
+
this.renderer = renderer;
|
|
201
|
+
this.elementRef = elementRef;
|
|
202
|
+
this.editable = true;
|
|
203
|
+
this.attrs = {};
|
|
204
|
+
this.inlineRef = null;
|
|
205
|
+
}
|
|
206
|
+
ngOnChanges(changes) {
|
|
207
|
+
if (changes.field || changes.editable || changes.attrs) {
|
|
208
|
+
this.viewContainer.clear();
|
|
209
|
+
if (this.inlineRef) {
|
|
210
|
+
this.inlineRef.remove();
|
|
211
|
+
this.inlineRef = null;
|
|
212
|
+
}
|
|
213
|
+
this.updateView();
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
renderTemplate(props, linkText) {
|
|
217
|
+
const viewRef = this.viewContainer.createEmbeddedView(this.templateRef);
|
|
218
|
+
viewRef.rootNodes.forEach((node) => {
|
|
219
|
+
Object.entries(props).forEach(([key, propValue]) => {
|
|
220
|
+
this.updateAttribute(node, key, propValue);
|
|
221
|
+
});
|
|
222
|
+
if (node.childNodes && node.childNodes.length === 0 && linkText) {
|
|
223
|
+
node.textContent = linkText;
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
updateAttribute(node, key, propValue) {
|
|
228
|
+
if (typeof propValue !== 'string' || !propValue || propValue === '') {
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
if (key === 'href') {
|
|
232
|
+
const isInvalidLink = !propValue || /^https?:\/\/$/.test(propValue);
|
|
233
|
+
if (isInvalidLink) {
|
|
234
|
+
if (!node.href) {
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
propValue = node.href;
|
|
238
|
+
}
|
|
239
|
+
this.renderer.setAttribute(node, key, propValue);
|
|
240
|
+
}
|
|
241
|
+
else if (key === 'class' && node.className !== '') {
|
|
242
|
+
this.renderer.setAttribute(node, key, `${node.className} ${propValue}`);
|
|
243
|
+
}
|
|
244
|
+
else {
|
|
245
|
+
this.renderer.setAttribute(node, key, propValue);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
updateView() {
|
|
249
|
+
const field = this.field;
|
|
250
|
+
if (this.editable && field && field.editableFirstPart && field.editableLastPart) {
|
|
251
|
+
this.renderInlineWrapper(field.editableFirstPart, field.editableLastPart);
|
|
252
|
+
}
|
|
253
|
+
else if (field && (field.href || field.value)) {
|
|
254
|
+
const props = field.href ? field : field.value;
|
|
255
|
+
const linkText = field.text || field.value?.text || field.href || field.value?.href;
|
|
256
|
+
const anchor = props?.anchor ? `#${props.anchor}` : '';
|
|
257
|
+
const href = `${props?.href}${anchor}`;
|
|
258
|
+
const mergedAttrs = { ...props, ...this.attrs, href };
|
|
259
|
+
delete mergedAttrs.anchor;
|
|
260
|
+
this.renderTemplate(mergedAttrs, linkText);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
renderInlineWrapper(editableFirstPart, editableLastPart) {
|
|
264
|
+
const span = this.renderer.createElement('span');
|
|
265
|
+
span.className = 'sc-link-wrapper';
|
|
266
|
+
span.innerHTML = editableFirstPart + editableLastPart;
|
|
267
|
+
// assign attributes from template to inline wrapper
|
|
268
|
+
const attrs = {
|
|
269
|
+
...this.getElementAttrs(),
|
|
270
|
+
...this.attrs,
|
|
271
|
+
};
|
|
272
|
+
Object.entries(attrs).forEach(([key, attrValue]) => this.updateAttribute(span, key, attrValue));
|
|
273
|
+
this.viewContainer.createEmbeddedView(this.templateRef);
|
|
274
|
+
const parentNode = this.renderer.parentNode(this.elementRef.nativeElement);
|
|
275
|
+
this.renderer.insertBefore(parentNode, span, this.elementRef.nativeElement);
|
|
276
|
+
this.inlineRef = span;
|
|
277
|
+
}
|
|
278
|
+
getElementAttrs() {
|
|
279
|
+
const view = this.templateRef.createEmbeddedView(null);
|
|
280
|
+
const element = view.rootNodes[0];
|
|
281
|
+
if (!element) {
|
|
282
|
+
view.destroy();
|
|
283
|
+
return {};
|
|
284
|
+
}
|
|
285
|
+
const attrs = {};
|
|
286
|
+
for (let i = 0; i < element.attributes.length; i++) {
|
|
287
|
+
const attr = element.attributes.item(i);
|
|
288
|
+
if (attr) {
|
|
289
|
+
attrs[attr.name] = attr.value;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
view.destroy();
|
|
293
|
+
return attrs;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
LinkDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: LinkDirective, deps: [{ token: i0.ViewContainerRef }, { token: i0.TemplateRef }, { token: i0.Renderer2 }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
297
|
+
LinkDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.12", type: LinkDirective, selector: "[scLink]", inputs: { editable: ["scLinkEditable", "editable"], attrs: ["scLinkAttrs", "attrs"], field: ["scLink", "field"] }, usesOnChanges: true, ngImport: i0 });
|
|
298
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: LinkDirective, decorators: [{
|
|
299
|
+
type: Directive,
|
|
300
|
+
args: [{ selector: '[scLink]' }]
|
|
301
|
+
}], ctorParameters: function () { return [{ type: i0.ViewContainerRef }, { type: i0.TemplateRef }, { type: i0.Renderer2 }, { type: i0.ElementRef }]; }, propDecorators: { editable: [{
|
|
302
|
+
type: Input,
|
|
303
|
+
args: ['scLinkEditable']
|
|
304
|
+
}], attrs: [{
|
|
305
|
+
type: Input,
|
|
306
|
+
args: ['scLinkAttrs']
|
|
307
|
+
}], field: [{
|
|
308
|
+
type: Input,
|
|
309
|
+
args: ['scLink']
|
|
310
310
|
}] } });
|
|
311
311
|
|
|
312
|
-
class RouterLinkDirective extends LinkDirective {
|
|
313
|
-
constructor(viewContainer, templateRef, renderer, elementRef, router) {
|
|
314
|
-
super(viewContainer, templateRef, renderer, elementRef);
|
|
315
|
-
this.router = router;
|
|
316
|
-
this.editable = true;
|
|
317
|
-
this.attrs = {};
|
|
318
|
-
}
|
|
319
|
-
renderTemplate(props, linkText) {
|
|
320
|
-
const viewRef = this.viewContainer.createEmbeddedView(this.templateRef);
|
|
321
|
-
viewRef.rootNodes.forEach((node) => {
|
|
322
|
-
Object.entries(props).forEach(([key, propValue]) => {
|
|
323
|
-
this.updateAttribute(node, key, propValue);
|
|
324
|
-
if (key === 'href') {
|
|
325
|
-
this.renderer.listen(node, 'click', (event) => {
|
|
326
|
-
this.router.navigateByUrl(propValue);
|
|
327
|
-
// shouldn't prevent default if the link includes a fragment
|
|
328
|
-
if (!propValue.includes('#')) {
|
|
329
|
-
event.preventDefault();
|
|
330
|
-
}
|
|
331
|
-
});
|
|
332
|
-
}
|
|
333
|
-
});
|
|
334
|
-
if (node.childNodes && node.childNodes.length === 0 && linkText) {
|
|
335
|
-
node.textContent = linkText;
|
|
336
|
-
}
|
|
337
|
-
});
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
RouterLinkDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: RouterLinkDirective, deps: [{ token: i0.ViewContainerRef }, { token: i0.TemplateRef }, { token: i0.Renderer2 }, { token: i0.ElementRef }, { token: i1.Router }], target: i0.ɵɵFactoryTarget.Directive });
|
|
341
|
-
RouterLinkDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.12", type: RouterLinkDirective, selector: "[scRouterLink]", inputs: { editable: ["scRouterLinkEditable", "editable"], attrs: ["scRouterLinkAttrs", "attrs"], field: ["scRouterLink", "field"] }, usesInheritance: true, ngImport: i0 });
|
|
342
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: RouterLinkDirective, decorators: [{
|
|
343
|
-
type: Directive,
|
|
344
|
-
args: [{ selector: '[scRouterLink]' }]
|
|
345
|
-
}], ctorParameters: function () { return [{ type: i0.ViewContainerRef }, { type: i0.TemplateRef }, { type: i0.Renderer2 }, { type: i0.ElementRef }, { type: i1.Router }]; }, propDecorators: { editable: [{
|
|
346
|
-
type: Input,
|
|
347
|
-
args: ['scRouterLinkEditable']
|
|
348
|
-
}], attrs: [{
|
|
349
|
-
type: Input,
|
|
350
|
-
args: ['scRouterLinkAttrs']
|
|
351
|
-
}], field: [{
|
|
352
|
-
type: Input,
|
|
353
|
-
args: ['scRouterLink']
|
|
312
|
+
class RouterLinkDirective extends LinkDirective {
|
|
313
|
+
constructor(viewContainer, templateRef, renderer, elementRef, router) {
|
|
314
|
+
super(viewContainer, templateRef, renderer, elementRef);
|
|
315
|
+
this.router = router;
|
|
316
|
+
this.editable = true;
|
|
317
|
+
this.attrs = {};
|
|
318
|
+
}
|
|
319
|
+
renderTemplate(props, linkText) {
|
|
320
|
+
const viewRef = this.viewContainer.createEmbeddedView(this.templateRef);
|
|
321
|
+
viewRef.rootNodes.forEach((node) => {
|
|
322
|
+
Object.entries(props).forEach(([key, propValue]) => {
|
|
323
|
+
this.updateAttribute(node, key, propValue);
|
|
324
|
+
if (key === 'href') {
|
|
325
|
+
this.renderer.listen(node, 'click', (event) => {
|
|
326
|
+
this.router.navigateByUrl(propValue);
|
|
327
|
+
// shouldn't prevent default if the link includes a fragment
|
|
328
|
+
if (!propValue.includes('#')) {
|
|
329
|
+
event.preventDefault();
|
|
330
|
+
}
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
});
|
|
334
|
+
if (node.childNodes && node.childNodes.length === 0 && linkText) {
|
|
335
|
+
node.textContent = linkText;
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
RouterLinkDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: RouterLinkDirective, deps: [{ token: i0.ViewContainerRef }, { token: i0.TemplateRef }, { token: i0.Renderer2 }, { token: i0.ElementRef }, { token: i1.Router }], target: i0.ɵɵFactoryTarget.Directive });
|
|
341
|
+
RouterLinkDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.12", type: RouterLinkDirective, selector: "[scRouterLink]", inputs: { editable: ["scRouterLinkEditable", "editable"], attrs: ["scRouterLinkAttrs", "attrs"], field: ["scRouterLink", "field"] }, usesInheritance: true, ngImport: i0 });
|
|
342
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: RouterLinkDirective, decorators: [{
|
|
343
|
+
type: Directive,
|
|
344
|
+
args: [{ selector: '[scRouterLink]' }]
|
|
345
|
+
}], ctorParameters: function () { return [{ type: i0.ViewContainerRef }, { type: i0.TemplateRef }, { type: i0.Renderer2 }, { type: i0.ElementRef }, { type: i1.Router }]; }, propDecorators: { editable: [{
|
|
346
|
+
type: Input,
|
|
347
|
+
args: ['scRouterLinkEditable']
|
|
348
|
+
}], attrs: [{
|
|
349
|
+
type: Input,
|
|
350
|
+
args: ['scRouterLinkAttrs']
|
|
351
|
+
}], field: [{
|
|
352
|
+
type: Input,
|
|
353
|
+
args: ['scRouterLink']
|
|
354
354
|
}] } });
|
|
355
355
|
|
|
356
|
-
class GenericLinkDirective extends LinkDirective {
|
|
357
|
-
constructor(viewContainer, templateRef, renderer, elementRef, router) {
|
|
358
|
-
super(viewContainer, templateRef, renderer, elementRef);
|
|
359
|
-
this.router = router;
|
|
360
|
-
this.editable = true;
|
|
361
|
-
this.attrs = {};
|
|
362
|
-
}
|
|
363
|
-
renderTemplate(props, linkText) {
|
|
364
|
-
const viewRef = this.viewContainer.createEmbeddedView(this.templateRef);
|
|
365
|
-
viewRef.rootNodes.forEach((node) => {
|
|
366
|
-
Object.entries(props).forEach(([key, propValue]) => {
|
|
367
|
-
if (key === 'href' && !isAbsoluteUrl(propValue)) {
|
|
368
|
-
const fragments = propValue.split('#');
|
|
369
|
-
const url = fragments[0];
|
|
370
|
-
const anchor = fragments[1];
|
|
371
|
-
const urlTree = this.router.createUrlTree([url], {
|
|
372
|
-
fragment: anchor,
|
|
373
|
-
...this.extras,
|
|
374
|
-
});
|
|
375
|
-
this.updateAttribute(node, key, this.router.serializeUrl(urlTree));
|
|
376
|
-
this.renderer.listen(node, 'click', (event) => {
|
|
377
|
-
this.router.navigate([url], {
|
|
378
|
-
fragment: anchor,
|
|
379
|
-
...this.extras,
|
|
380
|
-
});
|
|
381
|
-
// shouldn't prevent default if the link includes a fragment
|
|
382
|
-
if (!anchor) {
|
|
383
|
-
event.preventDefault();
|
|
384
|
-
}
|
|
385
|
-
});
|
|
386
|
-
}
|
|
387
|
-
else {
|
|
388
|
-
this.updateAttribute(node, key, propValue);
|
|
389
|
-
}
|
|
390
|
-
});
|
|
391
|
-
if (node.childNodes && node.childNodes.length === 0 && linkText) {
|
|
392
|
-
node.textContent = linkText;
|
|
393
|
-
}
|
|
394
|
-
});
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
GenericLinkDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: GenericLinkDirective, deps: [{ token: i0.ViewContainerRef }, { token: i0.TemplateRef }, { token: i0.Renderer2 }, { token: i0.ElementRef }, { token: i1.Router }], target: i0.ɵɵFactoryTarget.Directive });
|
|
398
|
-
GenericLinkDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.12", type: GenericLinkDirective, selector: "[scGenericLink]", inputs: { editable: ["scGenericLinkEditable", "editable"], attrs: ["scGenericLinkAttrs", "attrs"], field: ["scGenericLink", "field"], extras: ["scGenericLinkExtras", "extras"] }, usesInheritance: true, ngImport: i0 });
|
|
399
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: GenericLinkDirective, decorators: [{
|
|
400
|
-
type: Directive,
|
|
401
|
-
args: [{ selector: '[scGenericLink]' }]
|
|
402
|
-
}], ctorParameters: function () { return [{ type: i0.ViewContainerRef }, { type: i0.TemplateRef }, { type: i0.Renderer2 }, { type: i0.ElementRef }, { type: i1.Router }]; }, propDecorators: { editable: [{
|
|
403
|
-
type: Input,
|
|
404
|
-
args: ['scGenericLinkEditable']
|
|
405
|
-
}], attrs: [{
|
|
406
|
-
type: Input,
|
|
407
|
-
args: ['scGenericLinkAttrs']
|
|
408
|
-
}], field: [{
|
|
409
|
-
type: Input,
|
|
410
|
-
args: ['scGenericLink']
|
|
411
|
-
}], extras: [{
|
|
412
|
-
type: Input,
|
|
413
|
-
args: ['scGenericLinkExtras']
|
|
356
|
+
class GenericLinkDirective extends LinkDirective {
|
|
357
|
+
constructor(viewContainer, templateRef, renderer, elementRef, router) {
|
|
358
|
+
super(viewContainer, templateRef, renderer, elementRef);
|
|
359
|
+
this.router = router;
|
|
360
|
+
this.editable = true;
|
|
361
|
+
this.attrs = {};
|
|
362
|
+
}
|
|
363
|
+
renderTemplate(props, linkText) {
|
|
364
|
+
const viewRef = this.viewContainer.createEmbeddedView(this.templateRef);
|
|
365
|
+
viewRef.rootNodes.forEach((node) => {
|
|
366
|
+
Object.entries(props).forEach(([key, propValue]) => {
|
|
367
|
+
if (key === 'href' && !isAbsoluteUrl(propValue)) {
|
|
368
|
+
const fragments = propValue.split('#');
|
|
369
|
+
const url = fragments[0];
|
|
370
|
+
const anchor = fragments[1];
|
|
371
|
+
const urlTree = this.router.createUrlTree([url], {
|
|
372
|
+
fragment: anchor,
|
|
373
|
+
...this.extras,
|
|
374
|
+
});
|
|
375
|
+
this.updateAttribute(node, key, this.router.serializeUrl(urlTree));
|
|
376
|
+
this.renderer.listen(node, 'click', (event) => {
|
|
377
|
+
this.router.navigate([url], {
|
|
378
|
+
fragment: anchor,
|
|
379
|
+
...this.extras,
|
|
380
|
+
});
|
|
381
|
+
// shouldn't prevent default if the link includes a fragment
|
|
382
|
+
if (!anchor) {
|
|
383
|
+
event.preventDefault();
|
|
384
|
+
}
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
else {
|
|
388
|
+
this.updateAttribute(node, key, propValue);
|
|
389
|
+
}
|
|
390
|
+
});
|
|
391
|
+
if (node.childNodes && node.childNodes.length === 0 && linkText) {
|
|
392
|
+
node.textContent = linkText;
|
|
393
|
+
}
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
GenericLinkDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: GenericLinkDirective, deps: [{ token: i0.ViewContainerRef }, { token: i0.TemplateRef }, { token: i0.Renderer2 }, { token: i0.ElementRef }, { token: i1.Router }], target: i0.ɵɵFactoryTarget.Directive });
|
|
398
|
+
GenericLinkDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.12", type: GenericLinkDirective, selector: "[scGenericLink]", inputs: { editable: ["scGenericLinkEditable", "editable"], attrs: ["scGenericLinkAttrs", "attrs"], field: ["scGenericLink", "field"], extras: ["scGenericLinkExtras", "extras"] }, usesInheritance: true, ngImport: i0 });
|
|
399
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: GenericLinkDirective, decorators: [{
|
|
400
|
+
type: Directive,
|
|
401
|
+
args: [{ selector: '[scGenericLink]' }]
|
|
402
|
+
}], ctorParameters: function () { return [{ type: i0.ViewContainerRef }, { type: i0.TemplateRef }, { type: i0.Renderer2 }, { type: i0.ElementRef }, { type: i1.Router }]; }, propDecorators: { editable: [{
|
|
403
|
+
type: Input,
|
|
404
|
+
args: ['scGenericLinkEditable']
|
|
405
|
+
}], attrs: [{
|
|
406
|
+
type: Input,
|
|
407
|
+
args: ['scGenericLinkAttrs']
|
|
408
|
+
}], field: [{
|
|
409
|
+
type: Input,
|
|
410
|
+
args: ['scGenericLink']
|
|
411
|
+
}], extras: [{
|
|
412
|
+
type: Input,
|
|
413
|
+
args: ['scGenericLinkExtras']
|
|
414
414
|
}] } });
|
|
415
415
|
|
|
416
|
-
class HiddenRenderingComponent {
|
|
417
|
-
get style() {
|
|
418
|
-
return 'background-image: linear-gradient(45deg, #ffffff 25%, #dcdcdc 25%, #dcdcdc 50%, #ffffff 50%, #ffffff 75%, #dcdcdc 75%, #dcdcdc 100%); background-size: 3px 3px; display: block; height: 100px;';
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
HiddenRenderingComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: HiddenRenderingComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
422
|
-
HiddenRenderingComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.12", type: HiddenRenderingComponent, selector: "sc-hidden-rendering", host: { properties: { "style": "this.style" } }, ngImport: i0, template: '', isInline: true });
|
|
423
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: HiddenRenderingComponent, decorators: [{
|
|
424
|
-
type: Component,
|
|
425
|
-
args: [{
|
|
426
|
-
selector: 'sc-hidden-rendering',
|
|
427
|
-
template: '',
|
|
428
|
-
}]
|
|
429
|
-
}], propDecorators: { style: [{
|
|
430
|
-
type: HostBinding,
|
|
431
|
-
args: ['style']
|
|
432
|
-
}] } });
|
|
416
|
+
class HiddenRenderingComponent {
|
|
417
|
+
get style() {
|
|
418
|
+
return 'background-image: linear-gradient(45deg, #ffffff 25%, #dcdcdc 25%, #dcdcdc 50%, #ffffff 50%, #ffffff 75%, #dcdcdc 75%, #dcdcdc 100%); background-size: 3px 3px; display: block; height: 100px;';
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
HiddenRenderingComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: HiddenRenderingComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
422
|
+
HiddenRenderingComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.12", type: HiddenRenderingComponent, selector: "sc-hidden-rendering", host: { properties: { "style": "this.style" } }, ngImport: i0, template: '', isInline: true });
|
|
423
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: HiddenRenderingComponent, decorators: [{
|
|
424
|
+
type: Component,
|
|
425
|
+
args: [{
|
|
426
|
+
selector: 'sc-hidden-rendering',
|
|
427
|
+
template: '',
|
|
428
|
+
}]
|
|
429
|
+
}], propDecorators: { style: [{
|
|
430
|
+
type: HostBinding,
|
|
431
|
+
args: ['style']
|
|
432
|
+
}] } });
|
|
433
433
|
const HIDDEN_RENDERING_NAME = 'Hidden Rendering';
|
|
434
434
|
|
|
435
|
-
class PlaceholderLoadingDirective {
|
|
436
|
-
constructor(templateRef) {
|
|
437
|
-
this.templateRef = templateRef;
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
PlaceholderLoadingDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: PlaceholderLoadingDirective, deps: [{ token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
441
|
-
PlaceholderLoadingDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.12", type: PlaceholderLoadingDirective, selector: "[scPlaceholderLoading]", ngImport: i0 });
|
|
442
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: PlaceholderLoadingDirective, decorators: [{
|
|
443
|
-
type: Directive,
|
|
444
|
-
args: [{
|
|
445
|
-
selector: '[scPlaceholderLoading]',
|
|
446
|
-
}]
|
|
435
|
+
class PlaceholderLoadingDirective {
|
|
436
|
+
constructor(templateRef) {
|
|
437
|
+
this.templateRef = templateRef;
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
PlaceholderLoadingDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: PlaceholderLoadingDirective, deps: [{ token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
441
|
+
PlaceholderLoadingDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.12", type: PlaceholderLoadingDirective, selector: "[scPlaceholderLoading]", ngImport: i0 });
|
|
442
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: PlaceholderLoadingDirective, decorators: [{
|
|
443
|
+
type: Directive,
|
|
444
|
+
args: [{
|
|
445
|
+
selector: '[scPlaceholderLoading]',
|
|
446
|
+
}]
|
|
447
447
|
}], ctorParameters: function () { return [{ type: i0.TemplateRef }]; } });
|
|
448
448
|
|
|
449
|
-
/** Registers a statically loaded component */
|
|
450
|
-
class ComponentNameAndType {
|
|
451
|
-
}
|
|
452
|
-
/**
|
|
453
|
-
* @param {unknown} object
|
|
454
|
-
*/
|
|
455
|
-
function instanceOfComponentNameAndType(object) {
|
|
456
|
-
return typeof object === 'object' && object !== null && 'type' in object;
|
|
457
|
-
}
|
|
458
|
-
/**
|
|
459
|
-
* @param {unknown} object
|
|
460
|
-
*/
|
|
461
|
-
function instanceOfComponentNameAndModule(object) {
|
|
462
|
-
return typeof object === 'object' && object !== null && 'module' in object;
|
|
463
|
-
}
|
|
464
|
-
const PLACEHOLDER_COMPONENTS = new InjectionToken('Sc.placeholder.components');
|
|
465
|
-
const PLACEHOLDER_LAZY_COMPONENTS = new InjectionToken('Sc.placeholder.lazyComponents');
|
|
466
|
-
const PLACEHOLDER_MISSING_COMPONENT_COMPONENT = new InjectionToken('Sc.placeholder.missingComponentComponent');
|
|
467
|
-
const PLACEHOLDER_HIDDEN_RENDERING_COMPONENT = new InjectionToken('Sc.placeholder.hiddenRenderingComponent');
|
|
468
|
-
const DYNAMIC_COMPONENT = new InjectionToken('Sc.placeholder.dynamicComponent');
|
|
469
|
-
const GUARD_RESOLVER = new InjectionToken('Sc.placeholder.guardResolver');
|
|
449
|
+
/** Registers a statically loaded component */
|
|
450
|
+
class ComponentNameAndType {
|
|
451
|
+
}
|
|
452
|
+
/**
|
|
453
|
+
* @param {unknown} object
|
|
454
|
+
*/
|
|
455
|
+
function instanceOfComponentNameAndType(object) {
|
|
456
|
+
return typeof object === 'object' && object !== null && 'type' in object;
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* @param {unknown} object
|
|
460
|
+
*/
|
|
461
|
+
function instanceOfComponentNameAndModule(object) {
|
|
462
|
+
return typeof object === 'object' && object !== null && 'module' in object;
|
|
463
|
+
}
|
|
464
|
+
const PLACEHOLDER_COMPONENTS = new InjectionToken('Sc.placeholder.components');
|
|
465
|
+
const PLACEHOLDER_LAZY_COMPONENTS = new InjectionToken('Sc.placeholder.lazyComponents');
|
|
466
|
+
const PLACEHOLDER_MISSING_COMPONENT_COMPONENT = new InjectionToken('Sc.placeholder.missingComponentComponent');
|
|
467
|
+
const PLACEHOLDER_HIDDEN_RENDERING_COMPONENT = new InjectionToken('Sc.placeholder.hiddenRenderingComponent');
|
|
468
|
+
const DYNAMIC_COMPONENT = new InjectionToken('Sc.placeholder.dynamicComponent');
|
|
469
|
+
const GUARD_RESOLVER = new InjectionToken('Sc.placeholder.guardResolver');
|
|
470
470
|
const DATA_RESOLVER = new InjectionToken('Sc.placeholder.dataResolver');
|
|
471
471
|
|
|
472
|
-
class RenderEachDirective {
|
|
473
|
-
constructor(templateRef) {
|
|
474
|
-
this.templateRef = templateRef;
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
RenderEachDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: RenderEachDirective, deps: [{ token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
478
|
-
RenderEachDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.12", type: RenderEachDirective, selector: "[renderEach]", ngImport: i0 });
|
|
479
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: RenderEachDirective, decorators: [{
|
|
480
|
-
type: Directive,
|
|
481
|
-
args: [{
|
|
482
|
-
selector: '[renderEach]',
|
|
483
|
-
}]
|
|
472
|
+
class RenderEachDirective {
|
|
473
|
+
constructor(templateRef) {
|
|
474
|
+
this.templateRef = templateRef;
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
RenderEachDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: RenderEachDirective, deps: [{ token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
478
|
+
RenderEachDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.12", type: RenderEachDirective, selector: "[renderEach]", ngImport: i0 });
|
|
479
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: RenderEachDirective, decorators: [{
|
|
480
|
+
type: Directive,
|
|
481
|
+
args: [{
|
|
482
|
+
selector: '[renderEach]',
|
|
483
|
+
}]
|
|
484
484
|
}], ctorParameters: function () { return [{ type: i0.TemplateRef }]; } });
|
|
485
485
|
|
|
486
|
-
class RenderEmptyDirective {
|
|
487
|
-
constructor(templateRef) {
|
|
488
|
-
this.templateRef = templateRef;
|
|
489
|
-
}
|
|
490
|
-
}
|
|
491
|
-
RenderEmptyDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: RenderEmptyDirective, deps: [{ token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
492
|
-
RenderEmptyDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.12", type: RenderEmptyDirective, selector: "[renderEmpty]", ngImport: i0 });
|
|
493
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: RenderEmptyDirective, decorators: [{
|
|
494
|
-
type: Directive,
|
|
495
|
-
args: [{
|
|
496
|
-
selector: '[renderEmpty]',
|
|
497
|
-
}]
|
|
486
|
+
class RenderEmptyDirective {
|
|
487
|
+
constructor(templateRef) {
|
|
488
|
+
this.templateRef = templateRef;
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
RenderEmptyDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: RenderEmptyDirective, deps: [{ token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
492
|
+
RenderEmptyDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.12", type: RenderEmptyDirective, selector: "[renderEmpty]", ngImport: i0 });
|
|
493
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: RenderEmptyDirective, decorators: [{
|
|
494
|
+
type: Directive,
|
|
495
|
+
args: [{
|
|
496
|
+
selector: '[renderEmpty]',
|
|
497
|
+
}]
|
|
498
498
|
}], ctorParameters: function () { return [{ type: i0.TemplateRef }]; } });
|
|
499
499
|
|
|
500
|
-
/**
|
|
501
|
-
* @param {HtmlElementRendering | ComponentRendering} rendering
|
|
502
|
-
*/
|
|
503
|
-
function isRawRendering(rendering) {
|
|
504
|
-
return (!rendering.componentName &&
|
|
505
|
-
rendering.name !== undefined);
|
|
500
|
+
/**
|
|
501
|
+
* @param {HtmlElementRendering | ComponentRendering} rendering
|
|
502
|
+
*/
|
|
503
|
+
function isRawRendering(rendering) {
|
|
504
|
+
return (!rendering.componentName &&
|
|
505
|
+
rendering.name !== undefined);
|
|
506
506
|
}
|
|
507
507
|
|
|
508
|
-
class RawComponent {
|
|
509
|
-
constructor(renderer, elementRef) {
|
|
510
|
-
this.renderer = renderer;
|
|
511
|
-
this.elementRef = elementRef;
|
|
512
|
-
}
|
|
513
|
-
ngOnInit() {
|
|
514
|
-
const el = this.renderer.createElement(this.rendering.name);
|
|
515
|
-
const contents = this.renderer.createText(this.rendering.contents || '');
|
|
516
|
-
const attributes = this.rendering.attributes;
|
|
517
|
-
for (const attr in attributes) {
|
|
518
|
-
// eslint-disable-next-line no-prototype-builtins
|
|
519
|
-
if (attributes.hasOwnProperty(attr)) {
|
|
520
|
-
const value = attributes[attr];
|
|
521
|
-
this.renderer.setAttribute(el, attr, value || '');
|
|
522
|
-
}
|
|
523
|
-
}
|
|
524
|
-
this.renderer.appendChild(el, contents);
|
|
525
|
-
const parentNode = this.renderer.parentNode(this.elementRef.nativeElement);
|
|
526
|
-
this.renderer.insertBefore(parentNode, el, this.elementRef.nativeElement);
|
|
527
|
-
parentNode.removeChild(this.elementRef.nativeElement);
|
|
528
|
-
}
|
|
529
|
-
}
|
|
530
|
-
RawComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: RawComponent, deps: [{ token: i0.Renderer2 }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
531
|
-
RawComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.12", type: RawComponent, selector: "sc-raw", inputs: { rendering: "rendering" }, ngImport: i0, template: '', isInline: true });
|
|
532
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: RawComponent, decorators: [{
|
|
533
|
-
type: Component,
|
|
534
|
-
args: [{
|
|
535
|
-
selector: 'sc-raw',
|
|
536
|
-
template: '',
|
|
537
|
-
}]
|
|
538
|
-
}], ctorParameters: function () { return [{ type: i0.Renderer2 }, { type: i0.ElementRef }]; }, propDecorators: { rendering: [{
|
|
539
|
-
type: Input
|
|
508
|
+
class RawComponent {
|
|
509
|
+
constructor(renderer, elementRef) {
|
|
510
|
+
this.renderer = renderer;
|
|
511
|
+
this.elementRef = elementRef;
|
|
512
|
+
}
|
|
513
|
+
ngOnInit() {
|
|
514
|
+
const el = this.renderer.createElement(this.rendering.name);
|
|
515
|
+
const contents = this.renderer.createText(this.rendering.contents || '');
|
|
516
|
+
const attributes = this.rendering.attributes;
|
|
517
|
+
for (const attr in attributes) {
|
|
518
|
+
// eslint-disable-next-line no-prototype-builtins
|
|
519
|
+
if (attributes.hasOwnProperty(attr)) {
|
|
520
|
+
const value = attributes[attr];
|
|
521
|
+
this.renderer.setAttribute(el, attr, value || '');
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
this.renderer.appendChild(el, contents);
|
|
525
|
+
const parentNode = this.renderer.parentNode(this.elementRef.nativeElement);
|
|
526
|
+
this.renderer.insertBefore(parentNode, el, this.elementRef.nativeElement);
|
|
527
|
+
parentNode.removeChild(this.elementRef.nativeElement);
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
RawComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: RawComponent, deps: [{ token: i0.Renderer2 }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
531
|
+
RawComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.12", type: RawComponent, selector: "sc-raw", inputs: { rendering: "rendering" }, ngImport: i0, template: '', isInline: true });
|
|
532
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: RawComponent, decorators: [{
|
|
533
|
+
type: Component,
|
|
534
|
+
args: [{
|
|
535
|
+
selector: 'sc-raw',
|
|
536
|
+
template: '',
|
|
537
|
+
}]
|
|
538
|
+
}], ctorParameters: function () { return [{ type: i0.Renderer2 }, { type: i0.ElementRef }]; }, propDecorators: { rendering: [{
|
|
539
|
+
type: Input
|
|
540
540
|
}] } });
|
|
541
541
|
|
|
542
|
-
class JssComponentFactoryService {
|
|
543
|
-
constructor(injector, components, lazyComponents) {
|
|
544
|
-
this.injector = injector;
|
|
545
|
-
this.components = components;
|
|
546
|
-
this.lazyComponents = lazyComponents;
|
|
547
|
-
this.componentMap = new Map();
|
|
548
|
-
this.lazyComponentMap = new Map();
|
|
549
|
-
this.components.forEach((c) => this.componentMap.set(c.name, c));
|
|
550
|
-
if (this.lazyComponents) {
|
|
551
|
-
this.lazyComponents.forEach((c) => this.lazyComponentMap.set(c.path, c));
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
getComponent(component) {
|
|
555
|
-
const loadedComponent = this.componentMap.get(component.componentName);
|
|
556
|
-
if (loadedComponent) {
|
|
557
|
-
return Promise.resolve({
|
|
558
|
-
componentDefinition: component,
|
|
559
|
-
componentImplementation: loadedComponent.type,
|
|
560
|
-
canActivate: loadedComponent.canActivate,
|
|
561
|
-
resolve: loadedComponent.resolve,
|
|
562
|
-
});
|
|
563
|
-
}
|
|
564
|
-
const lazyComponent = this.lazyComponentMap.get(component.componentName);
|
|
565
|
-
if (lazyComponent) {
|
|
566
|
-
return lazyComponent.loadChildren().then((lazyChild) => {
|
|
567
|
-
let componentType = null;
|
|
568
|
-
const moduleRef = createNgModule(lazyChild, this.injector);
|
|
569
|
-
const dynamicComponentType = moduleRef.injector.get(DYNAMIC_COMPONENT);
|
|
570
|
-
if (!dynamicComponentType) {
|
|
571
|
-
throw new Error(`JssComponentFactoryService: Lazy load module for component "${lazyComponent.path}" missing DYNAMIC_COMPONENT provider. Missing JssModule.forChild()?`);
|
|
572
|
-
}
|
|
573
|
-
if (component.componentName in dynamicComponentType) {
|
|
574
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
575
|
-
componentType = dynamicComponentType[component.componentName];
|
|
576
|
-
}
|
|
577
|
-
else {
|
|
578
|
-
if (typeof dynamicComponentType === 'function') {
|
|
579
|
-
componentType = dynamicComponentType;
|
|
580
|
-
}
|
|
581
|
-
else {
|
|
582
|
-
throw new Error(`JssComponentFactoryService: Lazy load module for component "${lazyComponent.path}" missing DYNAMIC_COMPONENT provider. Missing JssModule.forChild()?`);
|
|
583
|
-
}
|
|
584
|
-
}
|
|
585
|
-
return {
|
|
586
|
-
componentDefinition: component,
|
|
587
|
-
componentImplementation: componentType,
|
|
588
|
-
componentFactory: moduleRef.componentFactoryResolver.resolveComponentFactory(componentType),
|
|
589
|
-
canActivate: lazyComponent.canActivate,
|
|
590
|
-
resolve: lazyComponent.resolve,
|
|
591
|
-
};
|
|
592
|
-
});
|
|
593
|
-
}
|
|
594
|
-
return Promise.resolve({
|
|
595
|
-
componentDefinition: component,
|
|
596
|
-
});
|
|
597
|
-
}
|
|
598
|
-
getComponents(components) {
|
|
599
|
-
// acquire all components and keep them in order while handling their potential async-ness
|
|
600
|
-
return Promise.all(components.map((component) => isRawRendering(component) ? this.getRawComponent(component) : this.getComponent(component)));
|
|
601
|
-
}
|
|
602
|
-
getRawComponent(component) {
|
|
603
|
-
return Promise.resolve({
|
|
604
|
-
componentImplementation: RawComponent,
|
|
605
|
-
componentDefinition: component,
|
|
606
|
-
});
|
|
607
|
-
}
|
|
608
|
-
}
|
|
609
|
-
JssComponentFactoryService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: JssComponentFactoryService, deps: [{ token: i0.Injector }, { token: PLACEHOLDER_COMPONENTS }, { token: PLACEHOLDER_LAZY_COMPONENTS }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
610
|
-
JssComponentFactoryService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: JssComponentFactoryService });
|
|
611
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: JssComponentFactoryService, decorators: [{
|
|
612
|
-
type: Injectable
|
|
613
|
-
}], ctorParameters: function () { return [{ type: i0.Injector }, { type: undefined, decorators: [{
|
|
614
|
-
type: Inject,
|
|
615
|
-
args: [PLACEHOLDER_COMPONENTS]
|
|
616
|
-
}] }, { type: undefined, decorators: [{
|
|
617
|
-
type: Inject,
|
|
618
|
-
args: [PLACEHOLDER_LAZY_COMPONENTS]
|
|
542
|
+
class JssComponentFactoryService {
|
|
543
|
+
constructor(injector, components, lazyComponents) {
|
|
544
|
+
this.injector = injector;
|
|
545
|
+
this.components = components;
|
|
546
|
+
this.lazyComponents = lazyComponents;
|
|
547
|
+
this.componentMap = new Map();
|
|
548
|
+
this.lazyComponentMap = new Map();
|
|
549
|
+
this.components.forEach((c) => this.componentMap.set(c.name, c));
|
|
550
|
+
if (this.lazyComponents) {
|
|
551
|
+
this.lazyComponents.forEach((c) => this.lazyComponentMap.set(c.path, c));
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
getComponent(component) {
|
|
555
|
+
const loadedComponent = this.componentMap.get(component.componentName);
|
|
556
|
+
if (loadedComponent) {
|
|
557
|
+
return Promise.resolve({
|
|
558
|
+
componentDefinition: component,
|
|
559
|
+
componentImplementation: loadedComponent.type,
|
|
560
|
+
canActivate: loadedComponent.canActivate,
|
|
561
|
+
resolve: loadedComponent.resolve,
|
|
562
|
+
});
|
|
563
|
+
}
|
|
564
|
+
const lazyComponent = this.lazyComponentMap.get(component.componentName);
|
|
565
|
+
if (lazyComponent) {
|
|
566
|
+
return lazyComponent.loadChildren().then((lazyChild) => {
|
|
567
|
+
let componentType = null;
|
|
568
|
+
const moduleRef = createNgModule(lazyChild, this.injector);
|
|
569
|
+
const dynamicComponentType = moduleRef.injector.get(DYNAMIC_COMPONENT);
|
|
570
|
+
if (!dynamicComponentType) {
|
|
571
|
+
throw new Error(`JssComponentFactoryService: Lazy load module for component "${lazyComponent.path}" missing DYNAMIC_COMPONENT provider. Missing JssModule.forChild()?`);
|
|
572
|
+
}
|
|
573
|
+
if (component.componentName in dynamicComponentType) {
|
|
574
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
575
|
+
componentType = dynamicComponentType[component.componentName];
|
|
576
|
+
}
|
|
577
|
+
else {
|
|
578
|
+
if (typeof dynamicComponentType === 'function') {
|
|
579
|
+
componentType = dynamicComponentType;
|
|
580
|
+
}
|
|
581
|
+
else {
|
|
582
|
+
throw new Error(`JssComponentFactoryService: Lazy load module for component "${lazyComponent.path}" missing DYNAMIC_COMPONENT provider. Missing JssModule.forChild()?`);
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
return {
|
|
586
|
+
componentDefinition: component,
|
|
587
|
+
componentImplementation: componentType,
|
|
588
|
+
componentFactory: moduleRef.componentFactoryResolver.resolveComponentFactory(componentType),
|
|
589
|
+
canActivate: lazyComponent.canActivate,
|
|
590
|
+
resolve: lazyComponent.resolve,
|
|
591
|
+
};
|
|
592
|
+
});
|
|
593
|
+
}
|
|
594
|
+
return Promise.resolve({
|
|
595
|
+
componentDefinition: component,
|
|
596
|
+
});
|
|
597
|
+
}
|
|
598
|
+
getComponents(components) {
|
|
599
|
+
// acquire all components and keep them in order while handling their potential async-ness
|
|
600
|
+
return Promise.all(components.map((component) => isRawRendering(component) ? this.getRawComponent(component) : this.getComponent(component)));
|
|
601
|
+
}
|
|
602
|
+
getRawComponent(component) {
|
|
603
|
+
return Promise.resolve({
|
|
604
|
+
componentImplementation: RawComponent,
|
|
605
|
+
componentDefinition: component,
|
|
606
|
+
});
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
JssComponentFactoryService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: JssComponentFactoryService, deps: [{ token: i0.Injector }, { token: PLACEHOLDER_COMPONENTS }, { token: PLACEHOLDER_LAZY_COMPONENTS }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
610
|
+
JssComponentFactoryService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: JssComponentFactoryService });
|
|
611
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: JssComponentFactoryService, decorators: [{
|
|
612
|
+
type: Injectable
|
|
613
|
+
}], ctorParameters: function () { return [{ type: i0.Injector }, { type: undefined, decorators: [{
|
|
614
|
+
type: Inject,
|
|
615
|
+
args: [PLACEHOLDER_COMPONENTS]
|
|
616
|
+
}] }, { type: undefined, decorators: [{
|
|
617
|
+
type: Inject,
|
|
618
|
+
args: [PLACEHOLDER_LAZY_COMPONENTS]
|
|
619
619
|
}] }]; } });
|
|
620
620
|
|
|
621
|
-
/* eslint-disable @angular-eslint/no-conflicting-lifecycle */
|
|
622
|
-
/**
|
|
623
|
-
* @param {ComponentRendering} rendering
|
|
624
|
-
* @param {string} name
|
|
625
|
-
*/
|
|
626
|
-
function getPlaceholder(rendering, name) {
|
|
627
|
-
if (rendering && rendering.placeholders && Object.keys(rendering.placeholders).length > 0) {
|
|
628
|
-
return rendering.placeholders[name];
|
|
629
|
-
}
|
|
630
|
-
return null;
|
|
631
|
-
}
|
|
632
|
-
class PlaceholderComponent {
|
|
633
|
-
constructor(differs, componentFactory, changeDetectorRef, elementRef, renderer, router, missingComponentComponent, hiddenRenderingComponent, guardResolver, dataResolver,
|
|
634
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
635
|
-
platformId) {
|
|
636
|
-
this.differs = differs;
|
|
637
|
-
this.componentFactory = componentFactory;
|
|
638
|
-
this.changeDetectorRef = changeDetectorRef;
|
|
639
|
-
this.elementRef = elementRef;
|
|
640
|
-
this.renderer = renderer;
|
|
641
|
-
this.router = router;
|
|
642
|
-
this.missingComponentComponent = missingComponentComponent;
|
|
643
|
-
this.hiddenRenderingComponent = hiddenRenderingComponent;
|
|
644
|
-
this.guardResolver = guardResolver;
|
|
645
|
-
this.dataResolver = dataResolver;
|
|
646
|
-
this.platformId = platformId;
|
|
647
|
-
this.clientOnly = false;
|
|
648
|
-
this.loaded = new EventEmitter();
|
|
649
|
-
this.isLoading = true;
|
|
650
|
-
this._componentInstances = [];
|
|
651
|
-
this.destroyed = false;
|
|
652
|
-
this.parentStyleAttribute = '';
|
|
653
|
-
}
|
|
654
|
-
set inputs(value) {
|
|
655
|
-
this._inputs = value;
|
|
656
|
-
if (!this._differ && value) {
|
|
657
|
-
this._differ = this.differs.find(value).create();
|
|
658
|
-
}
|
|
659
|
-
}
|
|
660
|
-
ngOnInit() {
|
|
661
|
-
// just to ensure the element exists
|
|
662
|
-
const elem = this.elementRef.nativeElement;
|
|
663
|
-
if (elem) {
|
|
664
|
-
const attributes = elem.attributes;
|
|
665
|
-
for (let i = 0; i < attributes.length; i++) {
|
|
666
|
-
const attr = attributes.item(i);
|
|
667
|
-
if (attr && attr.name.indexOf('_ngcontent') !== -1) {
|
|
668
|
-
this.parentStyleAttribute = attr.name;
|
|
669
|
-
}
|
|
670
|
-
}
|
|
671
|
-
}
|
|
672
|
-
}
|
|
673
|
-
ngOnDestroy() {
|
|
674
|
-
this.destroyed = true;
|
|
675
|
-
this._componentInstances = [];
|
|
676
|
-
}
|
|
677
|
-
ngOnChanges(changes) {
|
|
678
|
-
if (changes.rendering || changes.renderings) {
|
|
679
|
-
this._render();
|
|
680
|
-
}
|
|
681
|
-
}
|
|
682
|
-
ngDoCheck() {
|
|
683
|
-
if (!this._differ || !this._inputs || this._componentInstances.length === 0) {
|
|
684
|
-
return;
|
|
685
|
-
}
|
|
686
|
-
const changes = this._differ.diff(this._inputs);
|
|
687
|
-
if (!changes) {
|
|
688
|
-
return;
|
|
689
|
-
}
|
|
690
|
-
const updates = {};
|
|
691
|
-
changes.forEachRemovedItem((change) => (updates[change.key] = null));
|
|
692
|
-
changes.forEachAddedItem((change) => (updates[change.key] = change.currentValue));
|
|
693
|
-
changes.forEachChangedItem((change) => (updates[change.key] = change.currentValue));
|
|
694
|
-
this._componentInstances.forEach((componentInstance) => this._setComponentInputs(componentInstance, updates));
|
|
695
|
-
}
|
|
696
|
-
_setComponentInputs(componentInstance, inputs) {
|
|
697
|
-
Object.entries(inputs).forEach(([input, inputValue]) => (componentInstance[input] = inputValue));
|
|
698
|
-
}
|
|
699
|
-
_subscribeComponentOutputs(componentInstance, outputs) {
|
|
700
|
-
Object.keys(outputs)
|
|
701
|
-
.filter((output) => componentInstance[output] && componentInstance[output] instanceof Observable)
|
|
702
|
-
.forEach((output) => componentInstance[output]
|
|
703
|
-
.pipe(takeWhile(() => !this.destroyed))
|
|
704
|
-
.subscribe(outputs[output]));
|
|
705
|
-
}
|
|
706
|
-
async _render() {
|
|
707
|
-
if (this.clientOnly && isPlatformServer(this.platformId)) {
|
|
708
|
-
return;
|
|
709
|
-
}
|
|
710
|
-
this._componentInstances = [];
|
|
711
|
-
this.view.clear();
|
|
712
|
-
if (!this.rendering && !this.renderings) {
|
|
713
|
-
return;
|
|
714
|
-
}
|
|
715
|
-
if (!this.name && !this.renderings) {
|
|
716
|
-
console.warn('Placeholder name was not specified, and explicit renderings array was not passed. Placeholder requires either name and rendering, or renderings.');
|
|
717
|
-
this.isLoading = false;
|
|
718
|
-
return;
|
|
719
|
-
}
|
|
720
|
-
const placeholder = this.renderings || getPlaceholder(this.rendering, this.name || '');
|
|
721
|
-
if (!placeholder) {
|
|
722
|
-
console.warn(`Placeholder '${this.name}' was not found in the current rendering data`, JSON.stringify(this.rendering, null, 2));
|
|
723
|
-
this.isLoading = false;
|
|
724
|
-
return;
|
|
725
|
-
}
|
|
726
|
-
// if the placeholder is empty (contains only raw renderings), then we may need to use the empty template if it's defined
|
|
727
|
-
const placeholderIsEmpty = placeholder.every((rendering) => isRawRendering(rendering));
|
|
728
|
-
if (this.renderEmptyTemplate && placeholderIsEmpty) {
|
|
729
|
-
this.view.createEmbeddedView(this.renderEmptyTemplate.templateRef, {
|
|
730
|
-
renderings: placeholder,
|
|
731
|
-
});
|
|
732
|
-
this.isLoading = false;
|
|
733
|
-
}
|
|
734
|
-
else {
|
|
735
|
-
const factories = await this.componentFactory.getComponents(placeholder);
|
|
736
|
-
try {
|
|
737
|
-
const nonGuarded = await this.guardResolver(factories);
|
|
738
|
-
const withData = await this.dataResolver(nonGuarded);
|
|
739
|
-
withData.forEach((rendering, index) => {
|
|
740
|
-
if (this.renderEachTemplate && !isRawRendering(rendering.factory.componentDefinition)) {
|
|
741
|
-
this._renderTemplatedComponent(rendering.factory.componentDefinition, index);
|
|
742
|
-
}
|
|
743
|
-
else {
|
|
744
|
-
this._renderEmbeddedComponent(rendering.factory, rendering.data, index);
|
|
745
|
-
}
|
|
746
|
-
});
|
|
747
|
-
this.isLoading = false;
|
|
748
|
-
this.changeDetectorRef.markForCheck();
|
|
749
|
-
this.loaded.emit(this.name);
|
|
750
|
-
}
|
|
751
|
-
catch (e) {
|
|
752
|
-
this.isLoading = false;
|
|
753
|
-
if (e instanceof UrlTree) {
|
|
754
|
-
this.router.navigateByUrl(e);
|
|
755
|
-
}
|
|
756
|
-
else if (typeof e === 'string') {
|
|
757
|
-
this.router.navigate([e]);
|
|
758
|
-
}
|
|
759
|
-
else if (Array.isArray(e)) {
|
|
760
|
-
this.router.navigate(e);
|
|
761
|
-
}
|
|
762
|
-
else {
|
|
763
|
-
throw e;
|
|
764
|
-
}
|
|
765
|
-
}
|
|
766
|
-
}
|
|
767
|
-
}
|
|
768
|
-
_renderTemplatedComponent(rendering, index) {
|
|
769
|
-
// the render-each template takes care of all component mapping etc
|
|
770
|
-
// generally using <sc-render-component> which is about like _renderEmbeddedComponent()
|
|
771
|
-
// as a separate component
|
|
772
|
-
this.view.createEmbeddedView(this.renderEachTemplate.templateRef, {
|
|
773
|
-
rendering,
|
|
774
|
-
index,
|
|
775
|
-
});
|
|
776
|
-
}
|
|
777
|
-
_renderEmbeddedComponent(rendering, data, index) {
|
|
778
|
-
if (rendering.componentDefinition.componentName === HIDDEN_RENDERING_NAME) {
|
|
779
|
-
rendering.componentImplementation = this.hiddenRenderingComponent;
|
|
780
|
-
}
|
|
781
|
-
if (!rendering.componentImplementation) {
|
|
782
|
-
const componentName = rendering.componentDefinition.componentName;
|
|
621
|
+
/* eslint-disable @angular-eslint/no-conflicting-lifecycle */
|
|
622
|
+
/**
|
|
623
|
+
* @param {ComponentRendering} rendering
|
|
624
|
+
* @param {string} name
|
|
625
|
+
*/
|
|
626
|
+
function getPlaceholder(rendering, name) {
|
|
627
|
+
if (rendering && rendering.placeholders && Object.keys(rendering.placeholders).length > 0) {
|
|
628
|
+
return rendering.placeholders[name];
|
|
629
|
+
}
|
|
630
|
+
return null;
|
|
631
|
+
}
|
|
632
|
+
class PlaceholderComponent {
|
|
633
|
+
constructor(differs, componentFactory, changeDetectorRef, elementRef, renderer, router, missingComponentComponent, hiddenRenderingComponent, guardResolver, dataResolver,
|
|
634
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
635
|
+
platformId) {
|
|
636
|
+
this.differs = differs;
|
|
637
|
+
this.componentFactory = componentFactory;
|
|
638
|
+
this.changeDetectorRef = changeDetectorRef;
|
|
639
|
+
this.elementRef = elementRef;
|
|
640
|
+
this.renderer = renderer;
|
|
641
|
+
this.router = router;
|
|
642
|
+
this.missingComponentComponent = missingComponentComponent;
|
|
643
|
+
this.hiddenRenderingComponent = hiddenRenderingComponent;
|
|
644
|
+
this.guardResolver = guardResolver;
|
|
645
|
+
this.dataResolver = dataResolver;
|
|
646
|
+
this.platformId = platformId;
|
|
647
|
+
this.clientOnly = false;
|
|
648
|
+
this.loaded = new EventEmitter();
|
|
649
|
+
this.isLoading = true;
|
|
650
|
+
this._componentInstances = [];
|
|
651
|
+
this.destroyed = false;
|
|
652
|
+
this.parentStyleAttribute = '';
|
|
653
|
+
}
|
|
654
|
+
set inputs(value) {
|
|
655
|
+
this._inputs = value;
|
|
656
|
+
if (!this._differ && value) {
|
|
657
|
+
this._differ = this.differs.find(value).create();
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
ngOnInit() {
|
|
661
|
+
// just to ensure the element exists
|
|
662
|
+
const elem = this.elementRef.nativeElement;
|
|
663
|
+
if (elem) {
|
|
664
|
+
const attributes = elem.attributes;
|
|
665
|
+
for (let i = 0; i < attributes.length; i++) {
|
|
666
|
+
const attr = attributes.item(i);
|
|
667
|
+
if (attr && attr.name.indexOf('_ngcontent') !== -1) {
|
|
668
|
+
this.parentStyleAttribute = attr.name;
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
ngOnDestroy() {
|
|
674
|
+
this.destroyed = true;
|
|
675
|
+
this._componentInstances = [];
|
|
676
|
+
}
|
|
677
|
+
ngOnChanges(changes) {
|
|
678
|
+
if (changes.rendering || changes.renderings) {
|
|
679
|
+
this._render();
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
ngDoCheck() {
|
|
683
|
+
if (!this._differ || !this._inputs || this._componentInstances.length === 0) {
|
|
684
|
+
return;
|
|
685
|
+
}
|
|
686
|
+
const changes = this._differ.diff(this._inputs);
|
|
687
|
+
if (!changes) {
|
|
688
|
+
return;
|
|
689
|
+
}
|
|
690
|
+
const updates = {};
|
|
691
|
+
changes.forEachRemovedItem((change) => (updates[change.key] = null));
|
|
692
|
+
changes.forEachAddedItem((change) => (updates[change.key] = change.currentValue));
|
|
693
|
+
changes.forEachChangedItem((change) => (updates[change.key] = change.currentValue));
|
|
694
|
+
this._componentInstances.forEach((componentInstance) => this._setComponentInputs(componentInstance, updates));
|
|
695
|
+
}
|
|
696
|
+
_setComponentInputs(componentInstance, inputs) {
|
|
697
|
+
Object.entries(inputs).forEach(([input, inputValue]) => (componentInstance[input] = inputValue));
|
|
698
|
+
}
|
|
699
|
+
_subscribeComponentOutputs(componentInstance, outputs) {
|
|
700
|
+
Object.keys(outputs)
|
|
701
|
+
.filter((output) => componentInstance[output] && componentInstance[output] instanceof Observable)
|
|
702
|
+
.forEach((output) => componentInstance[output]
|
|
703
|
+
.pipe(takeWhile(() => !this.destroyed))
|
|
704
|
+
.subscribe(outputs[output]));
|
|
705
|
+
}
|
|
706
|
+
async _render() {
|
|
707
|
+
if (this.clientOnly && isPlatformServer(this.platformId)) {
|
|
708
|
+
return;
|
|
709
|
+
}
|
|
710
|
+
this._componentInstances = [];
|
|
711
|
+
this.view.clear();
|
|
712
|
+
if (!this.rendering && !this.renderings) {
|
|
713
|
+
return;
|
|
714
|
+
}
|
|
715
|
+
if (!this.name && !this.renderings) {
|
|
716
|
+
console.warn('Placeholder name was not specified, and explicit renderings array was not passed. Placeholder requires either name and rendering, or renderings.');
|
|
717
|
+
this.isLoading = false;
|
|
718
|
+
return;
|
|
719
|
+
}
|
|
720
|
+
const placeholder = this.renderings || getPlaceholder(this.rendering, this.name || '');
|
|
721
|
+
if (!placeholder) {
|
|
722
|
+
console.warn(`Placeholder '${this.name}' was not found in the current rendering data`, JSON.stringify(this.rendering, null, 2));
|
|
723
|
+
this.isLoading = false;
|
|
724
|
+
return;
|
|
725
|
+
}
|
|
726
|
+
// if the placeholder is empty (contains only raw renderings), then we may need to use the empty template if it's defined
|
|
727
|
+
const placeholderIsEmpty = placeholder.every((rendering) => isRawRendering(rendering));
|
|
728
|
+
if (this.renderEmptyTemplate && placeholderIsEmpty) {
|
|
729
|
+
this.view.createEmbeddedView(this.renderEmptyTemplate.templateRef, {
|
|
730
|
+
renderings: placeholder,
|
|
731
|
+
});
|
|
732
|
+
this.isLoading = false;
|
|
733
|
+
}
|
|
734
|
+
else {
|
|
735
|
+
const factories = await this.componentFactory.getComponents(placeholder);
|
|
736
|
+
try {
|
|
737
|
+
const nonGuarded = await this.guardResolver(factories);
|
|
738
|
+
const withData = await this.dataResolver(nonGuarded);
|
|
739
|
+
withData.forEach((rendering, index) => {
|
|
740
|
+
if (this.renderEachTemplate && !isRawRendering(rendering.factory.componentDefinition)) {
|
|
741
|
+
this._renderTemplatedComponent(rendering.factory.componentDefinition, index);
|
|
742
|
+
}
|
|
743
|
+
else {
|
|
744
|
+
this._renderEmbeddedComponent(rendering.factory, rendering.data, index);
|
|
745
|
+
}
|
|
746
|
+
});
|
|
747
|
+
this.isLoading = false;
|
|
748
|
+
this.changeDetectorRef.markForCheck();
|
|
749
|
+
this.loaded.emit(this.name);
|
|
750
|
+
}
|
|
751
|
+
catch (e) {
|
|
752
|
+
this.isLoading = false;
|
|
753
|
+
if (e instanceof UrlTree) {
|
|
754
|
+
this.router.navigateByUrl(e);
|
|
755
|
+
}
|
|
756
|
+
else if (typeof e === 'string') {
|
|
757
|
+
this.router.navigate([e]);
|
|
758
|
+
}
|
|
759
|
+
else if (Array.isArray(e)) {
|
|
760
|
+
this.router.navigate(e);
|
|
761
|
+
}
|
|
762
|
+
else {
|
|
763
|
+
throw e;
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
_renderTemplatedComponent(rendering, index) {
|
|
769
|
+
// the render-each template takes care of all component mapping etc
|
|
770
|
+
// generally using <sc-render-component> which is about like _renderEmbeddedComponent()
|
|
771
|
+
// as a separate component
|
|
772
|
+
this.view.createEmbeddedView(this.renderEachTemplate.templateRef, {
|
|
773
|
+
rendering,
|
|
774
|
+
index,
|
|
775
|
+
});
|
|
776
|
+
}
|
|
777
|
+
_renderEmbeddedComponent(rendering, data, index) {
|
|
778
|
+
if (rendering.componentDefinition.componentName === HIDDEN_RENDERING_NAME) {
|
|
779
|
+
rendering.componentImplementation = this.hiddenRenderingComponent;
|
|
780
|
+
}
|
|
781
|
+
if (!rendering.componentImplementation) {
|
|
782
|
+
const componentName = rendering.componentDefinition.componentName;
|
|
783
783
|
console.error(`Placeholder ${this.name} contains unknown component ${componentName}.`, `Ensure component is mapped, like:
|
|
784
784
|
JssModule.withComponents([
|
|
785
785
|
{ name: '${componentName}', type: ${componentName}Component }
|
|
786
|
-
])`);
|
|
787
|
-
rendering.componentImplementation = this.missingComponentComponent;
|
|
788
|
-
}
|
|
789
|
-
// apply the parent style attribute _ngcontent
|
|
790
|
-
// work-around for https://github.com/angular/angular/issues/12215
|
|
791
|
-
const createdComponentRef = this.view.createComponent(rendering.componentImplementation, {
|
|
792
|
-
index: index,
|
|
793
|
-
});
|
|
794
|
-
if (this.parentStyleAttribute) {
|
|
795
|
-
this.renderer.setAttribute(createdComponentRef.location.nativeElement, this.parentStyleAttribute, '');
|
|
796
|
-
}
|
|
797
|
-
const componentInstance = createdComponentRef.instance;
|
|
798
|
-
componentInstance.rendering = rendering.componentDefinition;
|
|
799
|
-
componentInstance.data = data;
|
|
800
|
-
if (this._inputs) {
|
|
801
|
-
this._setComponentInputs(componentInstance, this._inputs);
|
|
802
|
-
}
|
|
803
|
-
if (this.outputs) {
|
|
804
|
-
this._subscribeComponentOutputs(componentInstance, this.outputs);
|
|
805
|
-
}
|
|
806
|
-
this._componentInstances.push(componentInstance);
|
|
807
|
-
}
|
|
808
|
-
}
|
|
809
|
-
PlaceholderComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: PlaceholderComponent, deps: [{ token: i0.KeyValueDiffers }, { token: JssComponentFactoryService }, { token: i0.ChangeDetectorRef }, { token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i1.Router }, { token: PLACEHOLDER_MISSING_COMPONENT_COMPONENT }, { token: PLACEHOLDER_HIDDEN_RENDERING_COMPONENT }, { token: GUARD_RESOLVER }, { token: DATA_RESOLVER }, { token: PLATFORM_ID }], target: i0.ɵɵFactoryTarget.Component });
|
|
786
|
+
])`);
|
|
787
|
+
rendering.componentImplementation = this.missingComponentComponent;
|
|
788
|
+
}
|
|
789
|
+
// apply the parent style attribute _ngcontent
|
|
790
|
+
// work-around for https://github.com/angular/angular/issues/12215
|
|
791
|
+
const createdComponentRef = this.view.createComponent(rendering.componentImplementation, {
|
|
792
|
+
index: index,
|
|
793
|
+
});
|
|
794
|
+
if (this.parentStyleAttribute) {
|
|
795
|
+
this.renderer.setAttribute(createdComponentRef.location.nativeElement, this.parentStyleAttribute, '');
|
|
796
|
+
}
|
|
797
|
+
const componentInstance = createdComponentRef.instance;
|
|
798
|
+
componentInstance.rendering = rendering.componentDefinition;
|
|
799
|
+
componentInstance.data = data;
|
|
800
|
+
if (this._inputs) {
|
|
801
|
+
this._setComponentInputs(componentInstance, this._inputs);
|
|
802
|
+
}
|
|
803
|
+
if (this.outputs) {
|
|
804
|
+
this._subscribeComponentOutputs(componentInstance, this.outputs);
|
|
805
|
+
}
|
|
806
|
+
this._componentInstances.push(componentInstance);
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
PlaceholderComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: PlaceholderComponent, deps: [{ token: i0.KeyValueDiffers }, { token: JssComponentFactoryService }, { token: i0.ChangeDetectorRef }, { token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i1.Router }, { token: PLACEHOLDER_MISSING_COMPONENT_COMPONENT }, { token: PLACEHOLDER_HIDDEN_RENDERING_COMPONENT }, { token: GUARD_RESOLVER }, { token: DATA_RESOLVER }, { token: PLATFORM_ID }], target: i0.ɵɵFactoryTarget.Component });
|
|
810
810
|
PlaceholderComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.12", type: PlaceholderComponent, selector: "sc-placeholder,[sc-placeholder]", inputs: { name: "name", rendering: "rendering", renderings: "renderings", outputs: "outputs", clientOnly: "clientOnly", inputs: "inputs" }, outputs: { loaded: "loaded" }, queries: [{ propertyName: "renderEachTemplate", first: true, predicate: RenderEachDirective, descendants: true, static: true }, { propertyName: "renderEmptyTemplate", first: true, predicate: RenderEmptyDirective, descendants: true, static: true }, { propertyName: "placeholderLoading", first: true, predicate: PlaceholderLoadingDirective, descendants: true, static: true }], viewQueries: [{ propertyName: "view", first: true, predicate: ["view"], descendants: true, read: ViewContainerRef, static: true }], usesOnChanges: true, ngImport: i0, template: `
|
|
811
811
|
<ng-template
|
|
812
812
|
*ngIf="isLoading"
|
|
813
813
|
[ngTemplateOutlet]="placeholderLoading?.templateRef"
|
|
814
814
|
></ng-template>
|
|
815
815
|
<ng-template #view></ng-template>
|
|
816
|
-
`, isInline: true, dependencies: [{ kind: "directive", type: i1$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1$1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }] });
|
|
817
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: PlaceholderComponent, decorators: [{
|
|
818
|
-
type: Component,
|
|
819
|
-
args: [{
|
|
820
|
-
selector: 'sc-placeholder,[sc-placeholder]',
|
|
816
|
+
`, isInline: true, dependencies: [{ kind: "directive", type: i1$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1$1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }] });
|
|
817
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: PlaceholderComponent, decorators: [{
|
|
818
|
+
type: Component,
|
|
819
|
+
args: [{
|
|
820
|
+
selector: 'sc-placeholder,[sc-placeholder]',
|
|
821
821
|
template: `
|
|
822
822
|
<ng-template
|
|
823
823
|
*ngIf="isLoading"
|
|
824
824
|
[ngTemplateOutlet]="placeholderLoading?.templateRef"
|
|
825
825
|
></ng-template>
|
|
826
826
|
<ng-template #view></ng-template>
|
|
827
|
-
`,
|
|
828
|
-
}]
|
|
829
|
-
}], ctorParameters: function () { return [{ type: i0.KeyValueDiffers }, { type: JssComponentFactoryService }, { type: i0.ChangeDetectorRef }, { type: i0.ElementRef }, { type: i0.Renderer2 }, { type: i1.Router }, { type: i0.Type, decorators: [{
|
|
830
|
-
type: Inject,
|
|
831
|
-
args: [PLACEHOLDER_MISSING_COMPONENT_COMPONENT]
|
|
832
|
-
}] }, { type: i0.Type, decorators: [{
|
|
833
|
-
type: Inject,
|
|
834
|
-
args: [PLACEHOLDER_HIDDEN_RENDERING_COMPONENT]
|
|
835
|
-
}] }, { type: undefined, decorators: [{
|
|
836
|
-
type: Inject,
|
|
837
|
-
args: [GUARD_RESOLVER]
|
|
838
|
-
}] }, { type: undefined, decorators: [{
|
|
839
|
-
type: Inject,
|
|
840
|
-
args: [DATA_RESOLVER]
|
|
841
|
-
}] }, { type: Object, decorators: [{
|
|
842
|
-
type: Inject,
|
|
843
|
-
args: [PLATFORM_ID]
|
|
844
|
-
}] }]; }, propDecorators: { name: [{
|
|
845
|
-
type: Input
|
|
846
|
-
}], rendering: [{
|
|
847
|
-
type: Input
|
|
848
|
-
}], renderings: [{
|
|
849
|
-
type: Input
|
|
850
|
-
}], outputs: [{
|
|
851
|
-
type: Input
|
|
852
|
-
}], clientOnly: [{
|
|
853
|
-
type: Input
|
|
854
|
-
}], loaded: [{
|
|
855
|
-
type: Output
|
|
856
|
-
}], renderEachTemplate: [{
|
|
857
|
-
type: ContentChild,
|
|
858
|
-
args: [RenderEachDirective, { static: true }]
|
|
859
|
-
}], renderEmptyTemplate: [{
|
|
860
|
-
type: ContentChild,
|
|
861
|
-
args: [RenderEmptyDirective, { static: true }]
|
|
862
|
-
}], placeholderLoading: [{
|
|
863
|
-
type: ContentChild,
|
|
864
|
-
args: [PlaceholderLoadingDirective, { static: true }]
|
|
865
|
-
}], view: [{
|
|
866
|
-
type: ViewChild,
|
|
867
|
-
args: ['view', { read: ViewContainerRef, static: true }]
|
|
868
|
-
}], inputs: [{
|
|
869
|
-
type: Input
|
|
827
|
+
`,
|
|
828
|
+
}]
|
|
829
|
+
}], ctorParameters: function () { return [{ type: i0.KeyValueDiffers }, { type: JssComponentFactoryService }, { type: i0.ChangeDetectorRef }, { type: i0.ElementRef }, { type: i0.Renderer2 }, { type: i1.Router }, { type: i0.Type, decorators: [{
|
|
830
|
+
type: Inject,
|
|
831
|
+
args: [PLACEHOLDER_MISSING_COMPONENT_COMPONENT]
|
|
832
|
+
}] }, { type: i0.Type, decorators: [{
|
|
833
|
+
type: Inject,
|
|
834
|
+
args: [PLACEHOLDER_HIDDEN_RENDERING_COMPONENT]
|
|
835
|
+
}] }, { type: undefined, decorators: [{
|
|
836
|
+
type: Inject,
|
|
837
|
+
args: [GUARD_RESOLVER]
|
|
838
|
+
}] }, { type: undefined, decorators: [{
|
|
839
|
+
type: Inject,
|
|
840
|
+
args: [DATA_RESOLVER]
|
|
841
|
+
}] }, { type: Object, decorators: [{
|
|
842
|
+
type: Inject,
|
|
843
|
+
args: [PLATFORM_ID]
|
|
844
|
+
}] }]; }, propDecorators: { name: [{
|
|
845
|
+
type: Input
|
|
846
|
+
}], rendering: [{
|
|
847
|
+
type: Input
|
|
848
|
+
}], renderings: [{
|
|
849
|
+
type: Input
|
|
850
|
+
}], outputs: [{
|
|
851
|
+
type: Input
|
|
852
|
+
}], clientOnly: [{
|
|
853
|
+
type: Input
|
|
854
|
+
}], loaded: [{
|
|
855
|
+
type: Output
|
|
856
|
+
}], renderEachTemplate: [{
|
|
857
|
+
type: ContentChild,
|
|
858
|
+
args: [RenderEachDirective, { static: true }]
|
|
859
|
+
}], renderEmptyTemplate: [{
|
|
860
|
+
type: ContentChild,
|
|
861
|
+
args: [RenderEmptyDirective, { static: true }]
|
|
862
|
+
}], placeholderLoading: [{
|
|
863
|
+
type: ContentChild,
|
|
864
|
+
args: [PlaceholderLoadingDirective, { static: true }]
|
|
865
|
+
}], view: [{
|
|
866
|
+
type: ViewChild,
|
|
867
|
+
args: ['view', { read: ViewContainerRef, static: true }]
|
|
868
|
+
}], inputs: [{
|
|
869
|
+
type: Input
|
|
870
870
|
}] } });
|
|
871
871
|
|
|
872
|
-
/**
|
|
873
|
-
* Renders a single JSS component given a rendering definition.
|
|
874
|
-
* Useful inside templated placeholders.
|
|
875
|
-
*/
|
|
876
|
-
class RenderComponentComponent {
|
|
877
|
-
constructor(differs, componentFactory, missingComponentComponent) {
|
|
878
|
-
this.differs = differs;
|
|
879
|
-
this.componentFactory = componentFactory;
|
|
880
|
-
this.missingComponentComponent = missingComponentComponent;
|
|
881
|
-
this.destroyed = false;
|
|
882
|
-
}
|
|
883
|
-
set inputs(value) {
|
|
884
|
-
this._inputs = value;
|
|
885
|
-
if (!this._differ && value) {
|
|
886
|
-
this._differ = this.differs.find(value).create();
|
|
887
|
-
}
|
|
888
|
-
}
|
|
889
|
-
ngOnChanges(changes) {
|
|
890
|
-
if (changes.rendering) {
|
|
891
|
-
this._render();
|
|
892
|
-
}
|
|
893
|
-
}
|
|
894
|
-
_setComponentInputs(componentInstance, inputs) {
|
|
895
|
-
Object.entries(inputs).forEach(([input, inputValue]) => (componentInstance[input] = inputValue));
|
|
896
|
-
}
|
|
897
|
-
_subscribeComponentOutputs(componentInstance, outputs) {
|
|
898
|
-
Object.keys(outputs)
|
|
899
|
-
.filter((output) => componentInstance[output] && componentInstance[output] instanceof Observable)
|
|
900
|
-
.forEach((output) => componentInstance[output]
|
|
901
|
-
.pipe(takeWhile(() => !this.destroyed))
|
|
902
|
-
.subscribe(outputs[output]));
|
|
903
|
-
}
|
|
904
|
-
_render() {
|
|
905
|
-
this.view.clear();
|
|
906
|
-
if (!this.rendering) {
|
|
907
|
-
return;
|
|
908
|
-
}
|
|
909
|
-
const resolveComponent = isRawRendering(this.rendering)
|
|
910
|
-
? Promise.resolve({
|
|
911
|
-
componentImplementation: RawComponent,
|
|
912
|
-
componentDefinition: this.rendering,
|
|
913
|
-
})
|
|
914
|
-
: this.componentFactory.getComponent(this.rendering);
|
|
915
|
-
resolveComponent.then((rendering) => {
|
|
916
|
-
if (!rendering.componentImplementation) {
|
|
917
|
-
const componentName = rendering.componentDefinition.componentName;
|
|
872
|
+
/**
|
|
873
|
+
* Renders a single JSS component given a rendering definition.
|
|
874
|
+
* Useful inside templated placeholders.
|
|
875
|
+
*/
|
|
876
|
+
class RenderComponentComponent {
|
|
877
|
+
constructor(differs, componentFactory, missingComponentComponent) {
|
|
878
|
+
this.differs = differs;
|
|
879
|
+
this.componentFactory = componentFactory;
|
|
880
|
+
this.missingComponentComponent = missingComponentComponent;
|
|
881
|
+
this.destroyed = false;
|
|
882
|
+
}
|
|
883
|
+
set inputs(value) {
|
|
884
|
+
this._inputs = value;
|
|
885
|
+
if (!this._differ && value) {
|
|
886
|
+
this._differ = this.differs.find(value).create();
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
ngOnChanges(changes) {
|
|
890
|
+
if (changes.rendering) {
|
|
891
|
+
this._render();
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
_setComponentInputs(componentInstance, inputs) {
|
|
895
|
+
Object.entries(inputs).forEach(([input, inputValue]) => (componentInstance[input] = inputValue));
|
|
896
|
+
}
|
|
897
|
+
_subscribeComponentOutputs(componentInstance, outputs) {
|
|
898
|
+
Object.keys(outputs)
|
|
899
|
+
.filter((output) => componentInstance[output] && componentInstance[output] instanceof Observable)
|
|
900
|
+
.forEach((output) => componentInstance[output]
|
|
901
|
+
.pipe(takeWhile(() => !this.destroyed))
|
|
902
|
+
.subscribe(outputs[output]));
|
|
903
|
+
}
|
|
904
|
+
_render() {
|
|
905
|
+
this.view.clear();
|
|
906
|
+
if (!this.rendering) {
|
|
907
|
+
return;
|
|
908
|
+
}
|
|
909
|
+
const resolveComponent = isRawRendering(this.rendering)
|
|
910
|
+
? Promise.resolve({
|
|
911
|
+
componentImplementation: RawComponent,
|
|
912
|
+
componentDefinition: this.rendering,
|
|
913
|
+
})
|
|
914
|
+
: this.componentFactory.getComponent(this.rendering);
|
|
915
|
+
resolveComponent.then((rendering) => {
|
|
916
|
+
if (!rendering.componentImplementation) {
|
|
917
|
+
const componentName = rendering.componentDefinition.componentName;
|
|
918
918
|
console.error(`Attempted to render unknown component ${componentName}.`, `Ensure component is mapped, like:
|
|
919
919
|
JssModule.withComponents([
|
|
920
920
|
{ name: '${componentName}', type: ${componentName}Component }
|
|
921
|
-
])`);
|
|
922
|
-
rendering.componentImplementation = this.missingComponentComponent;
|
|
923
|
-
}
|
|
924
|
-
const componentInstance = this.view.createComponent(rendering.componentImplementation)
|
|
925
|
-
.instance;
|
|
926
|
-
componentInstance.rendering = rendering.componentDefinition;
|
|
927
|
-
if (this._inputs) {
|
|
928
|
-
this._setComponentInputs(componentInstance, this._inputs);
|
|
929
|
-
}
|
|
930
|
-
if (this.outputs) {
|
|
931
|
-
this._subscribeComponentOutputs(componentInstance, this.outputs);
|
|
932
|
-
}
|
|
933
|
-
});
|
|
934
|
-
}
|
|
935
|
-
}
|
|
936
|
-
RenderComponentComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: RenderComponentComponent, deps: [{ token: i0.KeyValueDiffers }, { token: JssComponentFactoryService }, { token: PLACEHOLDER_MISSING_COMPONENT_COMPONENT }], target: i0.ɵɵFactoryTarget.Component });
|
|
921
|
+
])`);
|
|
922
|
+
rendering.componentImplementation = this.missingComponentComponent;
|
|
923
|
+
}
|
|
924
|
+
const componentInstance = this.view.createComponent(rendering.componentImplementation)
|
|
925
|
+
.instance;
|
|
926
|
+
componentInstance.rendering = rendering.componentDefinition;
|
|
927
|
+
if (this._inputs) {
|
|
928
|
+
this._setComponentInputs(componentInstance, this._inputs);
|
|
929
|
+
}
|
|
930
|
+
if (this.outputs) {
|
|
931
|
+
this._subscribeComponentOutputs(componentInstance, this.outputs);
|
|
932
|
+
}
|
|
933
|
+
});
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
RenderComponentComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: RenderComponentComponent, deps: [{ token: i0.KeyValueDiffers }, { token: JssComponentFactoryService }, { token: PLACEHOLDER_MISSING_COMPONENT_COMPONENT }], target: i0.ɵɵFactoryTarget.Component });
|
|
937
937
|
RenderComponentComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.12", type: RenderComponentComponent, selector: "sc-render-component", inputs: { rendering: "rendering", outputs: "outputs", inputs: "inputs" }, viewQueries: [{ propertyName: "view", first: true, predicate: ["view"], descendants: true, read: ViewContainerRef, static: true }], usesOnChanges: true, ngImport: i0, template: `
|
|
938
938
|
<ng-template #view></ng-template>
|
|
939
|
-
`, isInline: true });
|
|
940
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: RenderComponentComponent, decorators: [{
|
|
941
|
-
type: Component,
|
|
942
|
-
args: [{
|
|
943
|
-
selector: 'sc-render-component',
|
|
939
|
+
`, isInline: true });
|
|
940
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: RenderComponentComponent, decorators: [{
|
|
941
|
+
type: Component,
|
|
942
|
+
args: [{
|
|
943
|
+
selector: 'sc-render-component',
|
|
944
944
|
template: `
|
|
945
945
|
<ng-template #view></ng-template>
|
|
946
|
-
`,
|
|
947
|
-
}]
|
|
948
|
-
}], ctorParameters: function () { return [{ type: i0.KeyValueDiffers }, { type: JssComponentFactoryService }, { type: i0.Type, decorators: [{
|
|
949
|
-
type: Inject,
|
|
950
|
-
args: [PLACEHOLDER_MISSING_COMPONENT_COMPONENT]
|
|
951
|
-
}] }]; }, propDecorators: { rendering: [{
|
|
952
|
-
type: Input
|
|
953
|
-
}], outputs: [{
|
|
954
|
-
type: Input
|
|
955
|
-
}], view: [{
|
|
956
|
-
type: ViewChild,
|
|
957
|
-
args: ['view', { read: ViewContainerRef, static: true }]
|
|
958
|
-
}], inputs: [{
|
|
959
|
-
type: Input
|
|
946
|
+
`,
|
|
947
|
+
}]
|
|
948
|
+
}], ctorParameters: function () { return [{ type: i0.KeyValueDiffers }, { type: JssComponentFactoryService }, { type: i0.Type, decorators: [{
|
|
949
|
+
type: Inject,
|
|
950
|
+
args: [PLACEHOLDER_MISSING_COMPONENT_COMPONENT]
|
|
951
|
+
}] }]; }, propDecorators: { rendering: [{
|
|
952
|
+
type: Input
|
|
953
|
+
}], outputs: [{
|
|
954
|
+
type: Input
|
|
955
|
+
}], view: [{
|
|
956
|
+
type: ViewChild,
|
|
957
|
+
args: ['view', { read: ViewContainerRef, static: true }]
|
|
958
|
+
}], inputs: [{
|
|
959
|
+
type: Input
|
|
960
960
|
}] } });
|
|
961
961
|
|
|
962
|
-
class DateDirective {
|
|
963
|
-
constructor(viewContainer, templateRef, datePipe) {
|
|
964
|
-
this.viewContainer = viewContainer;
|
|
965
|
-
this.templateRef = templateRef;
|
|
966
|
-
this.datePipe = datePipe;
|
|
967
|
-
this.editable = true;
|
|
968
|
-
}
|
|
969
|
-
ngOnChanges(changes) {
|
|
970
|
-
if (changes.field || changes.format) {
|
|
971
|
-
if (!this.viewRef) {
|
|
972
|
-
this.viewContainer.clear();
|
|
973
|
-
this.viewRef = this.viewContainer.createEmbeddedView(this.templateRef);
|
|
974
|
-
}
|
|
975
|
-
this.updateView();
|
|
976
|
-
}
|
|
977
|
-
}
|
|
978
|
-
updateView() {
|
|
979
|
-
const field = this.field;
|
|
980
|
-
if (!field || (!field.editable && !field.value)) {
|
|
981
|
-
return;
|
|
982
|
-
}
|
|
983
|
-
const html = field.editable && this.editable ? field.editable : field.value;
|
|
984
|
-
const setDangerously = field.editable && this.editable;
|
|
985
|
-
this.viewRef.rootNodes.forEach((node) => {
|
|
986
|
-
if (setDangerously) {
|
|
987
|
-
node.innerHTML = html;
|
|
988
|
-
}
|
|
989
|
-
else {
|
|
990
|
-
node.textContent = this.datePipe.transform(html, this.format, this.timezone, this.locale);
|
|
991
|
-
}
|
|
992
|
-
});
|
|
993
|
-
}
|
|
994
|
-
}
|
|
995
|
-
DateDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: DateDirective, deps: [{ token: i0.ViewContainerRef }, { token: i0.TemplateRef }, { token: i1$1.DatePipe }], target: i0.ɵɵFactoryTarget.Directive });
|
|
996
|
-
DateDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.12", type: DateDirective, selector: "[scDate]", inputs: { format: ["scDateFormat", "format"], timezone: ["scDateTimezone", "timezone"], locale: ["scDateLocale", "locale"], editable: ["scDateEditable", "editable"], field: ["scDate", "field"] }, usesOnChanges: true, ngImport: i0 });
|
|
997
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: DateDirective, decorators: [{
|
|
998
|
-
type: Directive,
|
|
999
|
-
args: [{
|
|
1000
|
-
selector: '[scDate]',
|
|
1001
|
-
}]
|
|
1002
|
-
}], ctorParameters: function () { return [{ type: i0.ViewContainerRef }, { type: i0.TemplateRef }, { type: i1$1.DatePipe }]; }, propDecorators: { format: [{
|
|
1003
|
-
type: Input,
|
|
1004
|
-
args: ['scDateFormat']
|
|
1005
|
-
}], timezone: [{
|
|
1006
|
-
type: Input,
|
|
1007
|
-
args: ['scDateTimezone']
|
|
1008
|
-
}], locale: [{
|
|
1009
|
-
type: Input,
|
|
1010
|
-
args: ['scDateLocale']
|
|
1011
|
-
}], editable: [{
|
|
1012
|
-
type: Input,
|
|
1013
|
-
args: ['scDateEditable']
|
|
1014
|
-
}], field: [{
|
|
1015
|
-
type: Input,
|
|
1016
|
-
args: ['scDate']
|
|
962
|
+
class DateDirective {
|
|
963
|
+
constructor(viewContainer, templateRef, datePipe) {
|
|
964
|
+
this.viewContainer = viewContainer;
|
|
965
|
+
this.templateRef = templateRef;
|
|
966
|
+
this.datePipe = datePipe;
|
|
967
|
+
this.editable = true;
|
|
968
|
+
}
|
|
969
|
+
ngOnChanges(changes) {
|
|
970
|
+
if (changes.field || changes.format) {
|
|
971
|
+
if (!this.viewRef) {
|
|
972
|
+
this.viewContainer.clear();
|
|
973
|
+
this.viewRef = this.viewContainer.createEmbeddedView(this.templateRef);
|
|
974
|
+
}
|
|
975
|
+
this.updateView();
|
|
976
|
+
}
|
|
977
|
+
}
|
|
978
|
+
updateView() {
|
|
979
|
+
const field = this.field;
|
|
980
|
+
if (!field || (!field.editable && !field.value)) {
|
|
981
|
+
return;
|
|
982
|
+
}
|
|
983
|
+
const html = field.editable && this.editable ? field.editable : field.value;
|
|
984
|
+
const setDangerously = field.editable && this.editable;
|
|
985
|
+
this.viewRef.rootNodes.forEach((node) => {
|
|
986
|
+
if (setDangerously) {
|
|
987
|
+
node.innerHTML = html;
|
|
988
|
+
}
|
|
989
|
+
else {
|
|
990
|
+
node.textContent = this.datePipe.transform(html, this.format, this.timezone, this.locale);
|
|
991
|
+
}
|
|
992
|
+
});
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
DateDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: DateDirective, deps: [{ token: i0.ViewContainerRef }, { token: i0.TemplateRef }, { token: i1$1.DatePipe }], target: i0.ɵɵFactoryTarget.Directive });
|
|
996
|
+
DateDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.12", type: DateDirective, selector: "[scDate]", inputs: { format: ["scDateFormat", "format"], timezone: ["scDateTimezone", "timezone"], locale: ["scDateLocale", "locale"], editable: ["scDateEditable", "editable"], field: ["scDate", "field"] }, usesOnChanges: true, ngImport: i0 });
|
|
997
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: DateDirective, decorators: [{
|
|
998
|
+
type: Directive,
|
|
999
|
+
args: [{
|
|
1000
|
+
selector: '[scDate]',
|
|
1001
|
+
}]
|
|
1002
|
+
}], ctorParameters: function () { return [{ type: i0.ViewContainerRef }, { type: i0.TemplateRef }, { type: i1$1.DatePipe }]; }, propDecorators: { format: [{
|
|
1003
|
+
type: Input,
|
|
1004
|
+
args: ['scDateFormat']
|
|
1005
|
+
}], timezone: [{
|
|
1006
|
+
type: Input,
|
|
1007
|
+
args: ['scDateTimezone']
|
|
1008
|
+
}], locale: [{
|
|
1009
|
+
type: Input,
|
|
1010
|
+
args: ['scDateLocale']
|
|
1011
|
+
}], editable: [{
|
|
1012
|
+
type: Input,
|
|
1013
|
+
args: ['scDateEditable']
|
|
1014
|
+
}], field: [{
|
|
1015
|
+
type: Input,
|
|
1016
|
+
args: ['scDate']
|
|
1017
1017
|
}] } });
|
|
1018
1018
|
|
|
1019
|
-
class EditFrameComponent {
|
|
1020
|
-
constructor() {
|
|
1021
|
-
this.isEditing = false;
|
|
1022
|
-
this.frameProps = {};
|
|
1023
|
-
this.chromeData = '';
|
|
1024
|
-
}
|
|
1025
|
-
ngOnChanges() {
|
|
1026
|
-
this.isEditing = this.sitecore.context.pageEditing || false;
|
|
1027
|
-
if (!this.isEditing) {
|
|
1028
|
-
return;
|
|
1029
|
-
}
|
|
1030
|
-
this.frameProps.class = 'scLooseFrameZone';
|
|
1031
|
-
if (this.cssClass) {
|
|
1032
|
-
this.frameProps.class = `${this.frameProps.class} ${this.cssClass}`;
|
|
1033
|
-
}
|
|
1034
|
-
// item uri for edit frame target
|
|
1035
|
-
if (this.dataSource) {
|
|
1036
|
-
const route = this.sitecore.route;
|
|
1037
|
-
const databaseName = this.dataSource.databaseName || route?.databaseName;
|
|
1038
|
-
const language = this.dataSource.language || this.sitecore.context.language;
|
|
1039
|
-
this.frameProps.sc_item = `sitecore://${databaseName}/${this.dataSource.itemId}?lang=${language}`;
|
|
1040
|
-
}
|
|
1041
|
-
this.chromeData = this.buildChromeData();
|
|
1042
|
-
}
|
|
1043
|
-
buildChromeData() {
|
|
1044
|
-
const chromeData = {
|
|
1045
|
-
displayName: this.title,
|
|
1046
|
-
expandedDisplayName: this.tooltip,
|
|
1047
|
-
};
|
|
1048
|
-
if (this.dataSource) {
|
|
1049
|
-
chromeData.contextItemUri = this.frameProps.sc_item;
|
|
1050
|
-
}
|
|
1051
|
-
chromeData.commands = this.buttons?.map((value) => {
|
|
1052
|
-
return mapButtonToCommand(value, this.dataSource?.itemId, this.parameters);
|
|
1053
|
-
});
|
|
1054
|
-
return JSON.stringify(chromeData);
|
|
1055
|
-
}
|
|
1056
|
-
}
|
|
1057
|
-
EditFrameComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: EditFrameComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1019
|
+
class EditFrameComponent {
|
|
1020
|
+
constructor() {
|
|
1021
|
+
this.isEditing = false;
|
|
1022
|
+
this.frameProps = {};
|
|
1023
|
+
this.chromeData = '';
|
|
1024
|
+
}
|
|
1025
|
+
ngOnChanges() {
|
|
1026
|
+
this.isEditing = this.sitecore.context.pageEditing || false;
|
|
1027
|
+
if (!this.isEditing) {
|
|
1028
|
+
return;
|
|
1029
|
+
}
|
|
1030
|
+
this.frameProps.class = 'scLooseFrameZone';
|
|
1031
|
+
if (this.cssClass) {
|
|
1032
|
+
this.frameProps.class = `${this.frameProps.class} ${this.cssClass}`;
|
|
1033
|
+
}
|
|
1034
|
+
// item uri for edit frame target
|
|
1035
|
+
if (this.dataSource) {
|
|
1036
|
+
const route = this.sitecore.route;
|
|
1037
|
+
const databaseName = this.dataSource.databaseName || route?.databaseName;
|
|
1038
|
+
const language = this.dataSource.language || this.sitecore.context.language;
|
|
1039
|
+
this.frameProps.sc_item = `sitecore://${databaseName}/${this.dataSource.itemId}?lang=${language}`;
|
|
1040
|
+
}
|
|
1041
|
+
this.chromeData = this.buildChromeData();
|
|
1042
|
+
}
|
|
1043
|
+
buildChromeData() {
|
|
1044
|
+
const chromeData = {
|
|
1045
|
+
displayName: this.title,
|
|
1046
|
+
expandedDisplayName: this.tooltip,
|
|
1047
|
+
};
|
|
1048
|
+
if (this.dataSource) {
|
|
1049
|
+
chromeData.contextItemUri = this.frameProps.sc_item;
|
|
1050
|
+
}
|
|
1051
|
+
chromeData.commands = this.buttons?.map((value) => {
|
|
1052
|
+
return mapButtonToCommand(value, this.dataSource?.itemId, this.parameters);
|
|
1053
|
+
});
|
|
1054
|
+
return JSON.stringify(chromeData);
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
EditFrameComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: EditFrameComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1058
1058
|
EditFrameComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.12", type: EditFrameComponent, selector: "sc-edit-frame,[sc-edit-frame]", inputs: { dataSource: "dataSource", buttons: "buttons", title: "title", tooltip: "tooltip", cssClass: "cssClass", parameters: "parameters", sitecore: "sitecore" }, usesOnChanges: true, ngImport: i0, template: `
|
|
1059
1059
|
<ng-template #childContent>
|
|
1060
1060
|
<ng-content></ng-content>
|
|
@@ -1070,11 +1070,11 @@ EditFrameComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", ver
|
|
|
1070
1070
|
<ng-template #elseBlock>
|
|
1071
1071
|
<ng-container *ngTemplateOutlet="childContent"></ng-container>
|
|
1072
1072
|
</ng-template>
|
|
1073
|
-
`, isInline: true, dependencies: [{ kind: "directive", type: i1$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1$1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }] });
|
|
1074
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: EditFrameComponent, decorators: [{
|
|
1075
|
-
type: Component,
|
|
1076
|
-
args: [{
|
|
1077
|
-
selector: 'sc-edit-frame,[sc-edit-frame]',
|
|
1073
|
+
`, isInline: true, dependencies: [{ kind: "directive", type: i1$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1$1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }] });
|
|
1074
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: EditFrameComponent, decorators: [{
|
|
1075
|
+
type: Component,
|
|
1076
|
+
args: [{
|
|
1077
|
+
selector: 'sc-edit-frame,[sc-edit-frame]',
|
|
1078
1078
|
template: `
|
|
1079
1079
|
<ng-template #childContent>
|
|
1080
1080
|
<ng-content></ng-content>
|
|
@@ -1090,297 +1090,297 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImpo
|
|
|
1090
1090
|
<ng-template #elseBlock>
|
|
1091
1091
|
<ng-container *ngTemplateOutlet="childContent"></ng-container>
|
|
1092
1092
|
</ng-template>
|
|
1093
|
-
`,
|
|
1094
|
-
}]
|
|
1095
|
-
}], propDecorators: { dataSource: [{
|
|
1096
|
-
type: Input
|
|
1097
|
-
}], buttons: [{
|
|
1098
|
-
type: Input
|
|
1099
|
-
}], title: [{
|
|
1100
|
-
type: Input
|
|
1101
|
-
}], tooltip: [{
|
|
1102
|
-
type: Input
|
|
1103
|
-
}], cssClass: [{
|
|
1104
|
-
type: Input
|
|
1105
|
-
}], parameters: [{
|
|
1106
|
-
type: Input
|
|
1107
|
-
}], sitecore: [{
|
|
1108
|
-
type: Input
|
|
1093
|
+
`,
|
|
1094
|
+
}]
|
|
1095
|
+
}], propDecorators: { dataSource: [{
|
|
1096
|
+
type: Input
|
|
1097
|
+
}], buttons: [{
|
|
1098
|
+
type: Input
|
|
1099
|
+
}], title: [{
|
|
1100
|
+
type: Input
|
|
1101
|
+
}], tooltip: [{
|
|
1102
|
+
type: Input
|
|
1103
|
+
}], cssClass: [{
|
|
1104
|
+
type: Input
|
|
1105
|
+
}], parameters: [{
|
|
1106
|
+
type: Input
|
|
1107
|
+
}], sitecore: [{
|
|
1108
|
+
type: Input
|
|
1109
1109
|
}] } });
|
|
1110
1110
|
|
|
1111
|
-
class RichTextDirective {
|
|
1112
|
-
constructor(viewContainer, templateRef, renderer, router) {
|
|
1113
|
-
this.viewContainer = viewContainer;
|
|
1114
|
-
this.templateRef = templateRef;
|
|
1115
|
-
this.renderer = renderer;
|
|
1116
|
-
this.router = router;
|
|
1117
|
-
this.editable = true;
|
|
1118
|
-
}
|
|
1119
|
-
ngOnChanges(changes) {
|
|
1120
|
-
if (changes.field || changes.editable) {
|
|
1121
|
-
if (!this.viewRef) {
|
|
1122
|
-
this.viewContainer.clear();
|
|
1123
|
-
this.viewRef = this.viewContainer.createEmbeddedView(this.templateRef);
|
|
1124
|
-
}
|
|
1125
|
-
this.updateView();
|
|
1126
|
-
}
|
|
1127
|
-
}
|
|
1128
|
-
updateView() {
|
|
1129
|
-
const field = this.field;
|
|
1130
|
-
if (!field || (!field.editable && !field.value)) {
|
|
1131
|
-
return;
|
|
1132
|
-
}
|
|
1133
|
-
const html = field.editable && this.editable ? field.editable : field.value;
|
|
1134
|
-
this.viewRef.rootNodes.forEach((node) => {
|
|
1135
|
-
node.innerHTML = html;
|
|
1136
|
-
if (!node.querySelectorAll) {
|
|
1137
|
-
return;
|
|
1138
|
-
}
|
|
1139
|
-
const links = node.querySelectorAll('a[href]');
|
|
1140
|
-
const linksArray = [].slice.call(links);
|
|
1141
|
-
linksArray.forEach((link) => {
|
|
1142
|
-
const href = link.getAttribute('href');
|
|
1143
|
-
const target = link.getAttribute('target');
|
|
1144
|
-
if (!href || isAbsoluteUrl(href) || target === '_blank' || target === '_top') {
|
|
1145
|
-
return;
|
|
1146
|
-
}
|
|
1147
|
-
this.renderer.listen(link, 'click', (event) => {
|
|
1148
|
-
this.router.navigateByUrl(href);
|
|
1149
|
-
event.preventDefault();
|
|
1150
|
-
});
|
|
1151
|
-
});
|
|
1152
|
-
});
|
|
1153
|
-
}
|
|
1154
|
-
}
|
|
1155
|
-
RichTextDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: RichTextDirective, deps: [{ token: i0.ViewContainerRef }, { token: i0.TemplateRef }, { token: i0.Renderer2 }, { token: i1.Router }], target: i0.ɵɵFactoryTarget.Directive });
|
|
1156
|
-
RichTextDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.12", type: RichTextDirective, selector: "[scRichText]", inputs: { editable: ["scRichTextEditable", "editable"], field: ["scRichText", "field"] }, usesOnChanges: true, ngImport: i0 });
|
|
1157
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: RichTextDirective, decorators: [{
|
|
1158
|
-
type: Directive,
|
|
1159
|
-
args: [{
|
|
1160
|
-
selector: '[scRichText]',
|
|
1161
|
-
}]
|
|
1162
|
-
}], ctorParameters: function () { return [{ type: i0.ViewContainerRef }, { type: i0.TemplateRef }, { type: i0.Renderer2 }, { type: i1.Router }]; }, propDecorators: { editable: [{
|
|
1163
|
-
type: Input,
|
|
1164
|
-
args: ['scRichTextEditable']
|
|
1165
|
-
}], field: [{
|
|
1166
|
-
type: Input,
|
|
1167
|
-
args: ['scRichText']
|
|
1111
|
+
class RichTextDirective {
|
|
1112
|
+
constructor(viewContainer, templateRef, renderer, router) {
|
|
1113
|
+
this.viewContainer = viewContainer;
|
|
1114
|
+
this.templateRef = templateRef;
|
|
1115
|
+
this.renderer = renderer;
|
|
1116
|
+
this.router = router;
|
|
1117
|
+
this.editable = true;
|
|
1118
|
+
}
|
|
1119
|
+
ngOnChanges(changes) {
|
|
1120
|
+
if (changes.field || changes.editable) {
|
|
1121
|
+
if (!this.viewRef) {
|
|
1122
|
+
this.viewContainer.clear();
|
|
1123
|
+
this.viewRef = this.viewContainer.createEmbeddedView(this.templateRef);
|
|
1124
|
+
}
|
|
1125
|
+
this.updateView();
|
|
1126
|
+
}
|
|
1127
|
+
}
|
|
1128
|
+
updateView() {
|
|
1129
|
+
const field = this.field;
|
|
1130
|
+
if (!field || (!field.editable && !field.value)) {
|
|
1131
|
+
return;
|
|
1132
|
+
}
|
|
1133
|
+
const html = field.editable && this.editable ? field.editable : field.value;
|
|
1134
|
+
this.viewRef.rootNodes.forEach((node) => {
|
|
1135
|
+
node.innerHTML = html;
|
|
1136
|
+
if (!node.querySelectorAll) {
|
|
1137
|
+
return;
|
|
1138
|
+
}
|
|
1139
|
+
const links = node.querySelectorAll('a[href]');
|
|
1140
|
+
const linksArray = [].slice.call(links);
|
|
1141
|
+
linksArray.forEach((link) => {
|
|
1142
|
+
const href = link.getAttribute('href');
|
|
1143
|
+
const target = link.getAttribute('target');
|
|
1144
|
+
if (!href || isAbsoluteUrl(href) || target === '_blank' || target === '_top') {
|
|
1145
|
+
return;
|
|
1146
|
+
}
|
|
1147
|
+
this.renderer.listen(link, 'click', (event) => {
|
|
1148
|
+
this.router.navigateByUrl(href);
|
|
1149
|
+
event.preventDefault();
|
|
1150
|
+
});
|
|
1151
|
+
});
|
|
1152
|
+
});
|
|
1153
|
+
}
|
|
1154
|
+
}
|
|
1155
|
+
RichTextDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: RichTextDirective, deps: [{ token: i0.ViewContainerRef }, { token: i0.TemplateRef }, { token: i0.Renderer2 }, { token: i1.Router }], target: i0.ɵɵFactoryTarget.Directive });
|
|
1156
|
+
RichTextDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.12", type: RichTextDirective, selector: "[scRichText]", inputs: { editable: ["scRichTextEditable", "editable"], field: ["scRichText", "field"] }, usesOnChanges: true, ngImport: i0 });
|
|
1157
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: RichTextDirective, decorators: [{
|
|
1158
|
+
type: Directive,
|
|
1159
|
+
args: [{
|
|
1160
|
+
selector: '[scRichText]',
|
|
1161
|
+
}]
|
|
1162
|
+
}], ctorParameters: function () { return [{ type: i0.ViewContainerRef }, { type: i0.TemplateRef }, { type: i0.Renderer2 }, { type: i1.Router }]; }, propDecorators: { editable: [{
|
|
1163
|
+
type: Input,
|
|
1164
|
+
args: ['scRichTextEditable']
|
|
1165
|
+
}], field: [{
|
|
1166
|
+
type: Input,
|
|
1167
|
+
args: ['scRichText']
|
|
1168
1168
|
}] } });
|
|
1169
1169
|
|
|
1170
|
-
class TextDirective {
|
|
1171
|
-
constructor(viewContainer, templateRef) {
|
|
1172
|
-
this.viewContainer = viewContainer;
|
|
1173
|
-
this.templateRef = templateRef;
|
|
1174
|
-
this.editable = true;
|
|
1175
|
-
this.encode = true;
|
|
1176
|
-
}
|
|
1177
|
-
ngOnChanges(changes) {
|
|
1178
|
-
if (changes.field || changes.editable || changes.encode) {
|
|
1179
|
-
if (!this.viewRef) {
|
|
1180
|
-
this.viewContainer.clear();
|
|
1181
|
-
this.viewRef = this.viewContainer.createEmbeddedView(this.templateRef);
|
|
1182
|
-
}
|
|
1183
|
-
this.updateView();
|
|
1184
|
-
}
|
|
1185
|
-
}
|
|
1186
|
-
updateView() {
|
|
1187
|
-
const field = this.field;
|
|
1188
|
-
let editable = this.editable;
|
|
1189
|
-
if (!field || (!field.editable && (field.value === undefined || field.value === ''))) {
|
|
1190
|
-
return;
|
|
1191
|
-
}
|
|
1192
|
-
// can't use editable value if we want to output unencoded
|
|
1193
|
-
if (!this.encode) {
|
|
1194
|
-
editable = false;
|
|
1195
|
-
}
|
|
1196
|
-
const html = field.editable && editable ? field.editable : field.value;
|
|
1197
|
-
const setDangerously = (field.editable && editable) || !this.encode;
|
|
1198
|
-
this.viewRef.rootNodes.forEach((node) => {
|
|
1199
|
-
if (setDangerously) {
|
|
1200
|
-
node.innerHTML = html;
|
|
1201
|
-
}
|
|
1202
|
-
else {
|
|
1203
|
-
node.textContent = html;
|
|
1204
|
-
}
|
|
1205
|
-
});
|
|
1206
|
-
}
|
|
1207
|
-
}
|
|
1208
|
-
TextDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: TextDirective, deps: [{ token: i0.ViewContainerRef }, { token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
1209
|
-
TextDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.12", type: TextDirective, selector: "[scText]", inputs: { editable: ["scTextEditable", "editable"], encode: ["scTextEncode", "encode"], field: ["scText", "field"] }, usesOnChanges: true, ngImport: i0 });
|
|
1210
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: TextDirective, decorators: [{
|
|
1211
|
-
type: Directive,
|
|
1212
|
-
args: [{
|
|
1213
|
-
selector: '[scText]',
|
|
1214
|
-
}]
|
|
1215
|
-
}], ctorParameters: function () { return [{ type: i0.ViewContainerRef }, { type: i0.TemplateRef }]; }, propDecorators: { editable: [{
|
|
1216
|
-
type: Input,
|
|
1217
|
-
args: ['scTextEditable']
|
|
1218
|
-
}], encode: [{
|
|
1219
|
-
type: Input,
|
|
1220
|
-
args: ['scTextEncode']
|
|
1221
|
-
}], field: [{
|
|
1222
|
-
type: Input,
|
|
1223
|
-
args: ['scText']
|
|
1170
|
+
class TextDirective {
|
|
1171
|
+
constructor(viewContainer, templateRef) {
|
|
1172
|
+
this.viewContainer = viewContainer;
|
|
1173
|
+
this.templateRef = templateRef;
|
|
1174
|
+
this.editable = true;
|
|
1175
|
+
this.encode = true;
|
|
1176
|
+
}
|
|
1177
|
+
ngOnChanges(changes) {
|
|
1178
|
+
if (changes.field || changes.editable || changes.encode) {
|
|
1179
|
+
if (!this.viewRef) {
|
|
1180
|
+
this.viewContainer.clear();
|
|
1181
|
+
this.viewRef = this.viewContainer.createEmbeddedView(this.templateRef);
|
|
1182
|
+
}
|
|
1183
|
+
this.updateView();
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
updateView() {
|
|
1187
|
+
const field = this.field;
|
|
1188
|
+
let editable = this.editable;
|
|
1189
|
+
if (!field || (!field.editable && (field.value === undefined || field.value === ''))) {
|
|
1190
|
+
return;
|
|
1191
|
+
}
|
|
1192
|
+
// can't use editable value if we want to output unencoded
|
|
1193
|
+
if (!this.encode) {
|
|
1194
|
+
editable = false;
|
|
1195
|
+
}
|
|
1196
|
+
const html = field.editable && editable ? field.editable : field.value;
|
|
1197
|
+
const setDangerously = (field.editable && editable) || !this.encode;
|
|
1198
|
+
this.viewRef.rootNodes.forEach((node) => {
|
|
1199
|
+
if (setDangerously) {
|
|
1200
|
+
node.innerHTML = html;
|
|
1201
|
+
}
|
|
1202
|
+
else {
|
|
1203
|
+
node.textContent = html;
|
|
1204
|
+
}
|
|
1205
|
+
});
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
TextDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: TextDirective, deps: [{ token: i0.ViewContainerRef }, { token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
1209
|
+
TextDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.12", type: TextDirective, selector: "[scText]", inputs: { editable: ["scTextEditable", "editable"], encode: ["scTextEncode", "encode"], field: ["scText", "field"] }, usesOnChanges: true, ngImport: i0 });
|
|
1210
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: TextDirective, decorators: [{
|
|
1211
|
+
type: Directive,
|
|
1212
|
+
args: [{
|
|
1213
|
+
selector: '[scText]',
|
|
1214
|
+
}]
|
|
1215
|
+
}], ctorParameters: function () { return [{ type: i0.ViewContainerRef }, { type: i0.TemplateRef }]; }, propDecorators: { editable: [{
|
|
1216
|
+
type: Input,
|
|
1217
|
+
args: ['scTextEditable']
|
|
1218
|
+
}], encode: [{
|
|
1219
|
+
type: Input,
|
|
1220
|
+
args: ['scTextEncode']
|
|
1221
|
+
}], field: [{
|
|
1222
|
+
type: Input,
|
|
1223
|
+
args: ['scText']
|
|
1224
1224
|
}] } });
|
|
1225
1225
|
|
|
1226
|
-
/**
|
|
1227
|
-
* @param {T} value
|
|
1228
|
-
* @returns {Promise | Observable | any} resolved value
|
|
1229
|
-
*/
|
|
1230
|
-
function wrapIntoObservable(value) {
|
|
1231
|
-
if (ɵisObservable(value)) {
|
|
1232
|
-
return value;
|
|
1233
|
-
}
|
|
1234
|
-
if (ɵisPromise(value)) {
|
|
1235
|
-
return from(Promise.resolve(value));
|
|
1236
|
-
}
|
|
1237
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1238
|
-
return of(value);
|
|
1226
|
+
/**
|
|
1227
|
+
* @param {T} value
|
|
1228
|
+
* @returns {Promise | Observable | any} resolved value
|
|
1229
|
+
*/
|
|
1230
|
+
function wrapIntoObservable(value) {
|
|
1231
|
+
if (ɵisObservable(value)) {
|
|
1232
|
+
return value;
|
|
1233
|
+
}
|
|
1234
|
+
if (ɵisPromise(value)) {
|
|
1235
|
+
return from(Promise.resolve(value));
|
|
1236
|
+
}
|
|
1237
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1238
|
+
return of(value);
|
|
1239
1239
|
}
|
|
1240
1240
|
|
|
1241
|
-
/**
|
|
1242
|
-
* @param {Injector} injector
|
|
1243
|
-
* @param {ActivatedRoute} activatedRoute
|
|
1244
|
-
* @param {Router} router
|
|
1245
|
-
* @returns resolved data
|
|
1246
|
-
*/
|
|
1247
|
-
function dataResolverFactory(injector, activatedRoute, router) {
|
|
1248
|
-
/**
|
|
1249
|
-
* @param {JssResolve<unknown> | Type<JssResolve<unknown>>} resolver
|
|
1250
|
-
* @returns resolver instance
|
|
1251
|
-
*/
|
|
1252
|
-
function getResolverInstance(resolver) {
|
|
1253
|
-
return 'resolve' in resolver ? resolver : injector.get(resolver);
|
|
1254
|
-
}
|
|
1255
|
-
/**
|
|
1256
|
-
* @param {ComponentFactoryResult} factory
|
|
1257
|
-
* @returns {Array<[string, JssResolve<unknown>]>} resolver instances
|
|
1258
|
-
*/
|
|
1259
|
-
function collectResolverInstances(factory) {
|
|
1260
|
-
if (factory.resolve) {
|
|
1261
|
-
const resolve = factory.resolve;
|
|
1262
|
-
return Object.keys(factory.resolve).map((key) => [
|
|
1263
|
-
key,
|
|
1264
|
-
getResolverInstance(resolve[key]),
|
|
1265
|
-
]);
|
|
1266
|
-
}
|
|
1267
|
-
return [];
|
|
1268
|
-
}
|
|
1269
|
-
/**
|
|
1270
|
-
* @param {JssResolve<unknown>} resolver
|
|
1271
|
-
* @param {ComponentFactoryResult} factory
|
|
1272
|
-
* @returns data
|
|
1273
|
-
*/
|
|
1274
|
-
function _resolveData(resolver, factory) {
|
|
1275
|
-
const data = resolver.resolve({
|
|
1276
|
-
activatedRoute: activatedRoute.snapshot,
|
|
1277
|
-
routerState: router.routerState.snapshot,
|
|
1278
|
-
rendering: factory.componentDefinition,
|
|
1279
|
-
});
|
|
1280
|
-
const data$ = wrapIntoObservable(data);
|
|
1281
|
-
return data$.pipe(take(1)).toPromise();
|
|
1282
|
-
}
|
|
1283
|
-
return function resolveData(factories) {
|
|
1284
|
-
return Promise.all(factories.map((factory) => {
|
|
1285
|
-
const resolvers = collectResolverInstances(factory);
|
|
1286
|
-
const pendingData = resolvers.map(([key, resolver]) => _resolveData(resolver, factory).then((data) => [key, data]));
|
|
1287
|
-
return Promise.all(pendingData)
|
|
1288
|
-
.then((allData) => allData.reduce((acc, [key, data]) => {
|
|
1289
|
-
acc[key] = data;
|
|
1290
|
-
return acc;
|
|
1291
|
-
}, {}))
|
|
1292
|
-
.then((data) => ({ factory, data }));
|
|
1293
|
-
}));
|
|
1294
|
-
};
|
|
1241
|
+
/**
|
|
1242
|
+
* @param {Injector} injector
|
|
1243
|
+
* @param {ActivatedRoute} activatedRoute
|
|
1244
|
+
* @param {Router} router
|
|
1245
|
+
* @returns resolved data
|
|
1246
|
+
*/
|
|
1247
|
+
function dataResolverFactory(injector, activatedRoute, router) {
|
|
1248
|
+
/**
|
|
1249
|
+
* @param {JssResolve<unknown> | Type<JssResolve<unknown>>} resolver
|
|
1250
|
+
* @returns resolver instance
|
|
1251
|
+
*/
|
|
1252
|
+
function getResolverInstance(resolver) {
|
|
1253
|
+
return 'resolve' in resolver ? resolver : injector.get(resolver);
|
|
1254
|
+
}
|
|
1255
|
+
/**
|
|
1256
|
+
* @param {ComponentFactoryResult} factory
|
|
1257
|
+
* @returns {Array<[string, JssResolve<unknown>]>} resolver instances
|
|
1258
|
+
*/
|
|
1259
|
+
function collectResolverInstances(factory) {
|
|
1260
|
+
if (factory.resolve) {
|
|
1261
|
+
const resolve = factory.resolve;
|
|
1262
|
+
return Object.keys(factory.resolve).map((key) => [
|
|
1263
|
+
key,
|
|
1264
|
+
getResolverInstance(resolve[key]),
|
|
1265
|
+
]);
|
|
1266
|
+
}
|
|
1267
|
+
return [];
|
|
1268
|
+
}
|
|
1269
|
+
/**
|
|
1270
|
+
* @param {JssResolve<unknown>} resolver
|
|
1271
|
+
* @param {ComponentFactoryResult} factory
|
|
1272
|
+
* @returns data
|
|
1273
|
+
*/
|
|
1274
|
+
function _resolveData(resolver, factory) {
|
|
1275
|
+
const data = resolver.resolve({
|
|
1276
|
+
activatedRoute: activatedRoute.snapshot,
|
|
1277
|
+
routerState: router.routerState.snapshot,
|
|
1278
|
+
rendering: factory.componentDefinition,
|
|
1279
|
+
});
|
|
1280
|
+
const data$ = wrapIntoObservable(data);
|
|
1281
|
+
return data$.pipe(take(1)).toPromise();
|
|
1282
|
+
}
|
|
1283
|
+
return function resolveData(factories) {
|
|
1284
|
+
return Promise.all(factories.map((factory) => {
|
|
1285
|
+
const resolvers = collectResolverInstances(factory);
|
|
1286
|
+
const pendingData = resolvers.map(([key, resolver]) => _resolveData(resolver, factory).then((data) => [key, data]));
|
|
1287
|
+
return Promise.all(pendingData)
|
|
1288
|
+
.then((allData) => allData.reduce((acc, [key, data]) => {
|
|
1289
|
+
acc[key] = data;
|
|
1290
|
+
return acc;
|
|
1291
|
+
}, {}))
|
|
1292
|
+
.then((data) => ({ factory, data }));
|
|
1293
|
+
}));
|
|
1294
|
+
};
|
|
1295
1295
|
}
|
|
1296
1296
|
|
|
1297
|
-
/**
|
|
1298
|
-
* @param {boolean | string | string[] | UrlTree} value
|
|
1299
|
-
* @returns instance of value
|
|
1300
|
-
*/
|
|
1301
|
-
function isRedirectValue(value) {
|
|
1302
|
-
return value instanceof UrlTree || typeof value === 'string' || Array.isArray(value);
|
|
1303
|
-
}
|
|
1304
|
-
/**
|
|
1305
|
-
* Resolves components based on provided guards
|
|
1306
|
-
* @param {Injector} injector
|
|
1307
|
-
* @param {ActivatedRoute} activatedRoute
|
|
1308
|
-
* @param {Router} router
|
|
1309
|
-
* @returns {(factories: ComponentFactoryResult[]) => Promise<ComponentFactoryResult[]>} factory
|
|
1310
|
-
*/
|
|
1311
|
-
function guardResolverFactory(injector, activatedRoute, router) {
|
|
1312
|
-
/**
|
|
1313
|
-
* @param {JssCanActivate | Type<JssCanActivate> | JssCanActivateFn} guard
|
|
1314
|
-
* @returns resolved guard
|
|
1315
|
-
*/
|
|
1316
|
-
function getGuardInstance(guard) {
|
|
1317
|
-
if ('canActivate' in guard) {
|
|
1318
|
-
return guard;
|
|
1319
|
-
}
|
|
1320
|
-
try {
|
|
1321
|
-
// Class is provided
|
|
1322
|
-
return injector.get(guard);
|
|
1323
|
-
}
|
|
1324
|
-
catch {
|
|
1325
|
-
// Function is provided
|
|
1326
|
-
return guard;
|
|
1327
|
-
}
|
|
1328
|
-
}
|
|
1329
|
-
/**
|
|
1330
|
-
* @param {ComponentFactoryResult} factory
|
|
1331
|
-
* @returns {(JssCanActivate | JssCanActivateFn)[]} guard instances
|
|
1332
|
-
*/
|
|
1333
|
-
function collectGuardInstances(factory) {
|
|
1334
|
-
if (factory.canActivate) {
|
|
1335
|
-
return Array.isArray(factory.canActivate)
|
|
1336
|
-
? factory.canActivate.map(getGuardInstance)
|
|
1337
|
-
: [getGuardInstance(factory.canActivate)];
|
|
1338
|
-
}
|
|
1339
|
-
return [];
|
|
1340
|
-
}
|
|
1341
|
-
/**
|
|
1342
|
-
*
|
|
1343
|
-
* @param {JssCanActivate | JssCanActivateFn} guard
|
|
1344
|
-
* @param {ComponentFactoryResult} factory
|
|
1345
|
-
* @returns canActivate
|
|
1346
|
-
*/
|
|
1347
|
-
function resolveGuard(guard, factory) {
|
|
1348
|
-
const canActivate = 'canActivate' in guard ? guard.canActivate : guard;
|
|
1349
|
-
const guardValue = canActivate({
|
|
1350
|
-
activatedRoute: activatedRoute.snapshot,
|
|
1351
|
-
routerState: router.routerState.snapshot,
|
|
1352
|
-
rendering: factory.componentDefinition,
|
|
1353
|
-
});
|
|
1354
|
-
const canActivate$ = wrapIntoObservable(guardValue);
|
|
1355
|
-
return canActivate$
|
|
1356
|
-
.pipe(take(1), mergeMap((value) => {
|
|
1357
|
-
if (isRedirectValue(value)) {
|
|
1358
|
-
return throwError(value);
|
|
1359
|
-
}
|
|
1360
|
-
else {
|
|
1361
|
-
return of(value);
|
|
1362
|
-
}
|
|
1363
|
-
}))
|
|
1364
|
-
.toPromise();
|
|
1365
|
-
}
|
|
1366
|
-
return function resolveGuards(factories) {
|
|
1367
|
-
const resolved = factories.map((factory) => {
|
|
1368
|
-
const guards = collectGuardInstances(factory);
|
|
1369
|
-
const pending = guards.map((guard) => resolveGuard(guard, factory));
|
|
1370
|
-
return Promise.all(pending)
|
|
1371
|
-
.then((canActive) => canActive.every((v) => v))
|
|
1372
|
-
.then((canActivate) => ({
|
|
1373
|
-
factory,
|
|
1374
|
-
canActivate,
|
|
1375
|
-
}));
|
|
1376
|
-
});
|
|
1377
|
-
return Promise.all(resolved).then((mapped) => mapped.filter((m) => m.canActivate).map((m) => m.factory));
|
|
1378
|
-
};
|
|
1297
|
+
/**
|
|
1298
|
+
* @param {boolean | string | string[] | UrlTree} value
|
|
1299
|
+
* @returns instance of value
|
|
1300
|
+
*/
|
|
1301
|
+
function isRedirectValue(value) {
|
|
1302
|
+
return value instanceof UrlTree || typeof value === 'string' || Array.isArray(value);
|
|
1303
|
+
}
|
|
1304
|
+
/**
|
|
1305
|
+
* Resolves components based on provided guards
|
|
1306
|
+
* @param {Injector} injector
|
|
1307
|
+
* @param {ActivatedRoute} activatedRoute
|
|
1308
|
+
* @param {Router} router
|
|
1309
|
+
* @returns {(factories: ComponentFactoryResult[]) => Promise<ComponentFactoryResult[]>} factory
|
|
1310
|
+
*/
|
|
1311
|
+
function guardResolverFactory(injector, activatedRoute, router) {
|
|
1312
|
+
/**
|
|
1313
|
+
* @param {JssCanActivate | Type<JssCanActivate> | JssCanActivateFn} guard
|
|
1314
|
+
* @returns resolved guard
|
|
1315
|
+
*/
|
|
1316
|
+
function getGuardInstance(guard) {
|
|
1317
|
+
if ('canActivate' in guard) {
|
|
1318
|
+
return guard;
|
|
1319
|
+
}
|
|
1320
|
+
try {
|
|
1321
|
+
// Class is provided
|
|
1322
|
+
return injector.get(guard);
|
|
1323
|
+
}
|
|
1324
|
+
catch {
|
|
1325
|
+
// Function is provided
|
|
1326
|
+
return guard;
|
|
1327
|
+
}
|
|
1328
|
+
}
|
|
1329
|
+
/**
|
|
1330
|
+
* @param {ComponentFactoryResult} factory
|
|
1331
|
+
* @returns {(JssCanActivate | JssCanActivateFn)[]} guard instances
|
|
1332
|
+
*/
|
|
1333
|
+
function collectGuardInstances(factory) {
|
|
1334
|
+
if (factory.canActivate) {
|
|
1335
|
+
return Array.isArray(factory.canActivate)
|
|
1336
|
+
? factory.canActivate.map(getGuardInstance)
|
|
1337
|
+
: [getGuardInstance(factory.canActivate)];
|
|
1338
|
+
}
|
|
1339
|
+
return [];
|
|
1340
|
+
}
|
|
1341
|
+
/**
|
|
1342
|
+
*
|
|
1343
|
+
* @param {JssCanActivate | JssCanActivateFn} guard
|
|
1344
|
+
* @param {ComponentFactoryResult} factory
|
|
1345
|
+
* @returns canActivate
|
|
1346
|
+
*/
|
|
1347
|
+
function resolveGuard(guard, factory) {
|
|
1348
|
+
const canActivate = 'canActivate' in guard ? guard.canActivate : guard;
|
|
1349
|
+
const guardValue = canActivate({
|
|
1350
|
+
activatedRoute: activatedRoute.snapshot,
|
|
1351
|
+
routerState: router.routerState.snapshot,
|
|
1352
|
+
rendering: factory.componentDefinition,
|
|
1353
|
+
});
|
|
1354
|
+
const canActivate$ = wrapIntoObservable(guardValue);
|
|
1355
|
+
return canActivate$
|
|
1356
|
+
.pipe(take(1), mergeMap((value) => {
|
|
1357
|
+
if (isRedirectValue(value)) {
|
|
1358
|
+
return throwError(value);
|
|
1359
|
+
}
|
|
1360
|
+
else {
|
|
1361
|
+
return of(value);
|
|
1362
|
+
}
|
|
1363
|
+
}))
|
|
1364
|
+
.toPromise();
|
|
1365
|
+
}
|
|
1366
|
+
return function resolveGuards(factories) {
|
|
1367
|
+
const resolved = factories.map((factory) => {
|
|
1368
|
+
const guards = collectGuardInstances(factory);
|
|
1369
|
+
const pending = guards.map((guard) => resolveGuard(guard, factory));
|
|
1370
|
+
return Promise.all(pending)
|
|
1371
|
+
.then((canActive) => canActive.every((v) => v))
|
|
1372
|
+
.then((canActivate) => ({
|
|
1373
|
+
factory,
|
|
1374
|
+
canActivate,
|
|
1375
|
+
}));
|
|
1376
|
+
});
|
|
1377
|
+
return Promise.all(resolved).then((mapped) => mapped.filter((m) => m.canActivate).map((m) => m.factory));
|
|
1378
|
+
};
|
|
1379
1379
|
}
|
|
1380
1380
|
|
|
1381
|
-
class MissingComponentComponent {
|
|
1382
|
-
}
|
|
1383
|
-
MissingComponentComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: MissingComponentComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1381
|
+
class MissingComponentComponent {
|
|
1382
|
+
}
|
|
1383
|
+
MissingComponentComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: MissingComponentComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1384
1384
|
MissingComponentComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.12", type: MissingComponentComponent, selector: "sc-missing-component", inputs: { rendering: "rendering" }, ngImport: i0, template: `
|
|
1385
1385
|
<div
|
|
1386
1386
|
style="background: darkorange; outline: 5px solid orange; padding: 10px; color: white; max-width: 500px;"
|
|
@@ -1388,11 +1388,11 @@ MissingComponentComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.
|
|
|
1388
1388
|
<h2>{{ rendering.componentName }}</h2>
|
|
1389
1389
|
<p>JSS component is missing Angular component implementation.</p>
|
|
1390
1390
|
</div>
|
|
1391
|
-
`, isInline: true });
|
|
1392
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: MissingComponentComponent, decorators: [{
|
|
1393
|
-
type: Component,
|
|
1394
|
-
args: [{
|
|
1395
|
-
selector: 'sc-missing-component',
|
|
1391
|
+
`, isInline: true });
|
|
1392
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: MissingComponentComponent, decorators: [{
|
|
1393
|
+
type: Component,
|
|
1394
|
+
args: [{
|
|
1395
|
+
selector: 'sc-missing-component',
|
|
1396
1396
|
template: `
|
|
1397
1397
|
<div
|
|
1398
1398
|
style="background: darkorange; outline: 5px solid orange; padding: 10px; color: white; max-width: 500px;"
|
|
@@ -1400,157 +1400,157 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImpo
|
|
|
1400
1400
|
<h2>{{ rendering.componentName }}</h2>
|
|
1401
1401
|
<p>JSS component is missing Angular component implementation.</p>
|
|
1402
1402
|
</div>
|
|
1403
|
-
`,
|
|
1404
|
-
}]
|
|
1405
|
-
}], propDecorators: { rendering: [{
|
|
1406
|
-
type: Input
|
|
1403
|
+
`,
|
|
1404
|
+
}]
|
|
1405
|
+
}], propDecorators: { rendering: [{
|
|
1406
|
+
type: Input
|
|
1407
1407
|
}] } });
|
|
1408
1408
|
|
|
1409
|
-
class JssModule {
|
|
1410
|
-
/**
|
|
1411
|
-
* Instantiates the JSS module with no component factory.
|
|
1412
|
-
* Useful for using it from libraries. Most of the time you'd want withComponents()
|
|
1413
|
-
* @returns {ModuleWithProviders<JssModule>} module
|
|
1414
|
-
*/
|
|
1415
|
-
static forRoot() {
|
|
1416
|
-
return {
|
|
1417
|
-
ngModule: JssModule,
|
|
1418
|
-
providers: [
|
|
1419
|
-
DatePipe,
|
|
1420
|
-
JssComponentFactoryService,
|
|
1421
|
-
{
|
|
1422
|
-
provide: GUARD_RESOLVER,
|
|
1423
|
-
useFactory: guardResolverFactory,
|
|
1424
|
-
deps: [Injector, ActivatedRoute, Router],
|
|
1425
|
-
},
|
|
1426
|
-
{
|
|
1427
|
-
provide: DATA_RESOLVER,
|
|
1428
|
-
useFactory: dataResolverFactory,
|
|
1429
|
-
deps: [Injector, ActivatedRoute, Router],
|
|
1430
|
-
},
|
|
1431
|
-
],
|
|
1432
|
-
};
|
|
1433
|
-
}
|
|
1434
|
-
/**
|
|
1435
|
-
* Instantiates a module for a lazy-loaded JSS component
|
|
1436
|
-
* @param {Type<unknown>} component
|
|
1437
|
-
* @returns {ModuleWithProviders<JssModule>} module
|
|
1438
|
-
*/
|
|
1439
|
-
static forChild(component) {
|
|
1440
|
-
return {
|
|
1441
|
-
ngModule: JssModule,
|
|
1442
|
-
providers: [
|
|
1443
|
-
{ provide: ANALYZE_FOR_ENTRY_COMPONENTS, useValue: component, multi: true },
|
|
1444
|
-
{ provide: ROUTES, useValue: [], multi: true },
|
|
1445
|
-
{ provide: DYNAMIC_COMPONENT, useValue: component },
|
|
1446
|
-
],
|
|
1447
|
-
};
|
|
1448
|
-
}
|
|
1449
|
-
/**
|
|
1450
|
-
* Instantiates the JSS module and specifies the mapping from component name to component implementation.
|
|
1451
|
-
* Appropriate when defining the set of JSS components that your app is aware of.
|
|
1452
|
-
* @param {ComponentNameAndType[]} components
|
|
1453
|
-
* @param {ComponentNameAndModule[]} [lazyComponents]
|
|
1454
|
-
* @returns {ModuleWithProviders<JssModule>} module
|
|
1455
|
-
*/
|
|
1456
|
-
static withComponents(components, lazyComponents) {
|
|
1457
|
-
return {
|
|
1458
|
-
ngModule: JssModule,
|
|
1459
|
-
providers: [
|
|
1460
|
-
{
|
|
1461
|
-
provide: ANALYZE_FOR_ENTRY_COMPONENTS,
|
|
1462
|
-
useValue: components,
|
|
1463
|
-
multi: true,
|
|
1464
|
-
},
|
|
1465
|
-
{ provide: PLACEHOLDER_COMPONENTS, useValue: components },
|
|
1466
|
-
{ provide: PLACEHOLDER_LAZY_COMPONENTS, useValue: lazyComponents || [] },
|
|
1467
|
-
{ provide: ROUTES, useValue: lazyComponents || [], multi: true },
|
|
1468
|
-
{ provide: PLACEHOLDER_MISSING_COMPONENT_COMPONENT, useValue: MissingComponentComponent },
|
|
1469
|
-
{ provide: PLACEHOLDER_HIDDEN_RENDERING_COMPONENT, useValue: HiddenRenderingComponent },
|
|
1470
|
-
...JssModule.forRoot().providers,
|
|
1471
|
-
],
|
|
1472
|
-
};
|
|
1473
|
-
}
|
|
1474
|
-
}
|
|
1475
|
-
JssModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: JssModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
1476
|
-
JssModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.2.12", ngImport: i0, type: JssModule, declarations: [FileDirective,
|
|
1477
|
-
ImageDirective,
|
|
1478
|
-
LinkDirective,
|
|
1479
|
-
RouterLinkDirective,
|
|
1480
|
-
GenericLinkDirective,
|
|
1481
|
-
DateDirective,
|
|
1482
|
-
RenderEachDirective,
|
|
1483
|
-
RenderEmptyDirective,
|
|
1484
|
-
PlaceholderLoadingDirective,
|
|
1485
|
-
RenderComponentComponent,
|
|
1486
|
-
PlaceholderComponent,
|
|
1487
|
-
RawComponent,
|
|
1488
|
-
RichTextDirective,
|
|
1489
|
-
TextDirective,
|
|
1490
|
-
MissingComponentComponent,
|
|
1491
|
-
HiddenRenderingComponent,
|
|
1492
|
-
EditFrameComponent], imports: [CommonModule], exports: [FileDirective,
|
|
1493
|
-
ImageDirective,
|
|
1494
|
-
DateDirective,
|
|
1495
|
-
LinkDirective,
|
|
1496
|
-
RouterLinkDirective,
|
|
1497
|
-
GenericLinkDirective,
|
|
1498
|
-
RenderEachDirective,
|
|
1499
|
-
RenderEmptyDirective,
|
|
1500
|
-
RenderComponentComponent,
|
|
1501
|
-
PlaceholderComponent,
|
|
1502
|
-
HiddenRenderingComponent,
|
|
1503
|
-
PlaceholderLoadingDirective,
|
|
1504
|
-
RichTextDirective,
|
|
1505
|
-
TextDirective,
|
|
1506
|
-
EditFrameComponent] });
|
|
1507
|
-
JssModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: JssModule, imports: [CommonModule] });
|
|
1508
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: JssModule, decorators: [{
|
|
1509
|
-
type: NgModule,
|
|
1510
|
-
args: [{
|
|
1511
|
-
imports: [CommonModule],
|
|
1512
|
-
declarations: [
|
|
1513
|
-
FileDirective,
|
|
1514
|
-
ImageDirective,
|
|
1515
|
-
LinkDirective,
|
|
1516
|
-
RouterLinkDirective,
|
|
1517
|
-
GenericLinkDirective,
|
|
1518
|
-
DateDirective,
|
|
1519
|
-
RenderEachDirective,
|
|
1520
|
-
RenderEmptyDirective,
|
|
1521
|
-
PlaceholderLoadingDirective,
|
|
1522
|
-
RenderComponentComponent,
|
|
1523
|
-
PlaceholderComponent,
|
|
1524
|
-
RawComponent,
|
|
1525
|
-
RichTextDirective,
|
|
1526
|
-
TextDirective,
|
|
1527
|
-
MissingComponentComponent,
|
|
1528
|
-
HiddenRenderingComponent,
|
|
1529
|
-
EditFrameComponent,
|
|
1530
|
-
],
|
|
1531
|
-
exports: [
|
|
1532
|
-
FileDirective,
|
|
1533
|
-
ImageDirective,
|
|
1534
|
-
DateDirective,
|
|
1535
|
-
LinkDirective,
|
|
1536
|
-
RouterLinkDirective,
|
|
1537
|
-
GenericLinkDirective,
|
|
1538
|
-
RenderEachDirective,
|
|
1539
|
-
RenderEmptyDirective,
|
|
1540
|
-
RenderComponentComponent,
|
|
1541
|
-
PlaceholderComponent,
|
|
1542
|
-
HiddenRenderingComponent,
|
|
1543
|
-
PlaceholderLoadingDirective,
|
|
1544
|
-
RichTextDirective,
|
|
1545
|
-
TextDirective,
|
|
1546
|
-
EditFrameComponent,
|
|
1547
|
-
],
|
|
1548
|
-
entryComponents: [RawComponent, MissingComponentComponent],
|
|
1549
|
-
}]
|
|
1409
|
+
class JssModule {
|
|
1410
|
+
/**
|
|
1411
|
+
* Instantiates the JSS module with no component factory.
|
|
1412
|
+
* Useful for using it from libraries. Most of the time you'd want withComponents()
|
|
1413
|
+
* @returns {ModuleWithProviders<JssModule>} module
|
|
1414
|
+
*/
|
|
1415
|
+
static forRoot() {
|
|
1416
|
+
return {
|
|
1417
|
+
ngModule: JssModule,
|
|
1418
|
+
providers: [
|
|
1419
|
+
DatePipe,
|
|
1420
|
+
JssComponentFactoryService,
|
|
1421
|
+
{
|
|
1422
|
+
provide: GUARD_RESOLVER,
|
|
1423
|
+
useFactory: guardResolverFactory,
|
|
1424
|
+
deps: [Injector, ActivatedRoute, Router],
|
|
1425
|
+
},
|
|
1426
|
+
{
|
|
1427
|
+
provide: DATA_RESOLVER,
|
|
1428
|
+
useFactory: dataResolverFactory,
|
|
1429
|
+
deps: [Injector, ActivatedRoute, Router],
|
|
1430
|
+
},
|
|
1431
|
+
],
|
|
1432
|
+
};
|
|
1433
|
+
}
|
|
1434
|
+
/**
|
|
1435
|
+
* Instantiates a module for a lazy-loaded JSS component
|
|
1436
|
+
* @param {Type<unknown>} component
|
|
1437
|
+
* @returns {ModuleWithProviders<JssModule>} module
|
|
1438
|
+
*/
|
|
1439
|
+
static forChild(component) {
|
|
1440
|
+
return {
|
|
1441
|
+
ngModule: JssModule,
|
|
1442
|
+
providers: [
|
|
1443
|
+
{ provide: ANALYZE_FOR_ENTRY_COMPONENTS, useValue: component, multi: true },
|
|
1444
|
+
{ provide: ROUTES, useValue: [], multi: true },
|
|
1445
|
+
{ provide: DYNAMIC_COMPONENT, useValue: component },
|
|
1446
|
+
],
|
|
1447
|
+
};
|
|
1448
|
+
}
|
|
1449
|
+
/**
|
|
1450
|
+
* Instantiates the JSS module and specifies the mapping from component name to component implementation.
|
|
1451
|
+
* Appropriate when defining the set of JSS components that your app is aware of.
|
|
1452
|
+
* @param {ComponentNameAndType[]} components
|
|
1453
|
+
* @param {ComponentNameAndModule[]} [lazyComponents]
|
|
1454
|
+
* @returns {ModuleWithProviders<JssModule>} module
|
|
1455
|
+
*/
|
|
1456
|
+
static withComponents(components, lazyComponents) {
|
|
1457
|
+
return {
|
|
1458
|
+
ngModule: JssModule,
|
|
1459
|
+
providers: [
|
|
1460
|
+
{
|
|
1461
|
+
provide: ANALYZE_FOR_ENTRY_COMPONENTS,
|
|
1462
|
+
useValue: components,
|
|
1463
|
+
multi: true,
|
|
1464
|
+
},
|
|
1465
|
+
{ provide: PLACEHOLDER_COMPONENTS, useValue: components },
|
|
1466
|
+
{ provide: PLACEHOLDER_LAZY_COMPONENTS, useValue: lazyComponents || [] },
|
|
1467
|
+
{ provide: ROUTES, useValue: lazyComponents || [], multi: true },
|
|
1468
|
+
{ provide: PLACEHOLDER_MISSING_COMPONENT_COMPONENT, useValue: MissingComponentComponent },
|
|
1469
|
+
{ provide: PLACEHOLDER_HIDDEN_RENDERING_COMPONENT, useValue: HiddenRenderingComponent },
|
|
1470
|
+
...JssModule.forRoot().providers,
|
|
1471
|
+
],
|
|
1472
|
+
};
|
|
1473
|
+
}
|
|
1474
|
+
}
|
|
1475
|
+
JssModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: JssModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
1476
|
+
JssModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.2.12", ngImport: i0, type: JssModule, declarations: [FileDirective,
|
|
1477
|
+
ImageDirective,
|
|
1478
|
+
LinkDirective,
|
|
1479
|
+
RouterLinkDirective,
|
|
1480
|
+
GenericLinkDirective,
|
|
1481
|
+
DateDirective,
|
|
1482
|
+
RenderEachDirective,
|
|
1483
|
+
RenderEmptyDirective,
|
|
1484
|
+
PlaceholderLoadingDirective,
|
|
1485
|
+
RenderComponentComponent,
|
|
1486
|
+
PlaceholderComponent,
|
|
1487
|
+
RawComponent,
|
|
1488
|
+
RichTextDirective,
|
|
1489
|
+
TextDirective,
|
|
1490
|
+
MissingComponentComponent,
|
|
1491
|
+
HiddenRenderingComponent,
|
|
1492
|
+
EditFrameComponent], imports: [CommonModule], exports: [FileDirective,
|
|
1493
|
+
ImageDirective,
|
|
1494
|
+
DateDirective,
|
|
1495
|
+
LinkDirective,
|
|
1496
|
+
RouterLinkDirective,
|
|
1497
|
+
GenericLinkDirective,
|
|
1498
|
+
RenderEachDirective,
|
|
1499
|
+
RenderEmptyDirective,
|
|
1500
|
+
RenderComponentComponent,
|
|
1501
|
+
PlaceholderComponent,
|
|
1502
|
+
HiddenRenderingComponent,
|
|
1503
|
+
PlaceholderLoadingDirective,
|
|
1504
|
+
RichTextDirective,
|
|
1505
|
+
TextDirective,
|
|
1506
|
+
EditFrameComponent] });
|
|
1507
|
+
JssModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: JssModule, imports: [CommonModule] });
|
|
1508
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: JssModule, decorators: [{
|
|
1509
|
+
type: NgModule,
|
|
1510
|
+
args: [{
|
|
1511
|
+
imports: [CommonModule],
|
|
1512
|
+
declarations: [
|
|
1513
|
+
FileDirective,
|
|
1514
|
+
ImageDirective,
|
|
1515
|
+
LinkDirective,
|
|
1516
|
+
RouterLinkDirective,
|
|
1517
|
+
GenericLinkDirective,
|
|
1518
|
+
DateDirective,
|
|
1519
|
+
RenderEachDirective,
|
|
1520
|
+
RenderEmptyDirective,
|
|
1521
|
+
PlaceholderLoadingDirective,
|
|
1522
|
+
RenderComponentComponent,
|
|
1523
|
+
PlaceholderComponent,
|
|
1524
|
+
RawComponent,
|
|
1525
|
+
RichTextDirective,
|
|
1526
|
+
TextDirective,
|
|
1527
|
+
MissingComponentComponent,
|
|
1528
|
+
HiddenRenderingComponent,
|
|
1529
|
+
EditFrameComponent,
|
|
1530
|
+
],
|
|
1531
|
+
exports: [
|
|
1532
|
+
FileDirective,
|
|
1533
|
+
ImageDirective,
|
|
1534
|
+
DateDirective,
|
|
1535
|
+
LinkDirective,
|
|
1536
|
+
RouterLinkDirective,
|
|
1537
|
+
GenericLinkDirective,
|
|
1538
|
+
RenderEachDirective,
|
|
1539
|
+
RenderEmptyDirective,
|
|
1540
|
+
RenderComponentComponent,
|
|
1541
|
+
PlaceholderComponent,
|
|
1542
|
+
HiddenRenderingComponent,
|
|
1543
|
+
PlaceholderLoadingDirective,
|
|
1544
|
+
RichTextDirective,
|
|
1545
|
+
TextDirective,
|
|
1546
|
+
EditFrameComponent,
|
|
1547
|
+
],
|
|
1548
|
+
entryComponents: [RawComponent, MissingComponentComponent],
|
|
1549
|
+
}]
|
|
1550
1550
|
}] });
|
|
1551
1551
|
|
|
1552
|
-
/**
|
|
1553
|
-
* Generated bundle index. Do not edit.
|
|
1552
|
+
/**
|
|
1553
|
+
* Generated bundle index. Do not edit.
|
|
1554
1554
|
*/
|
|
1555
1555
|
|
|
1556
1556
|
export { ComponentNameAndType, DYNAMIC_COMPONENT, DateDirective, EditFrameComponent, FileDirective, GenericLinkDirective, HiddenRenderingComponent, ImageDirective, JssModule, LinkDirective, PlaceholderComponent, PlaceholderLoadingDirective, RenderComponentComponent, RenderEachDirective, RenderEmptyDirective, RichTextDirective, RouterLinkDirective, TextDirective, isRawRendering };
|