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