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