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