@sitecore-jss/sitecore-jss-angular 21.7.0 → 21.7.1-canary.2

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