@ethlete/contentful 0.1.0-next.6 → 0.1.0-next.8

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 (38) hide show
  1. package/esm2020/lib/components/audio/contentful-audio.component.mjs +3 -3
  2. package/esm2020/lib/components/file/contentful-file.component.mjs +3 -3
  3. package/esm2020/lib/components/image/contentful-image.component.mjs +25 -13
  4. package/esm2020/lib/components/rich-text-renderer/rich-text-renderer.component.mjs +12 -9
  5. package/esm2020/lib/components/rich-text-renderer/rich-text-renderer.util.mjs +2 -16
  6. package/esm2020/lib/components/video/contentful-video.component.mjs +3 -3
  7. package/esm2020/lib/constants/contentful.constants.mjs +2 -2
  8. package/esm2020/lib/contentful.module.mjs +4 -4
  9. package/esm2020/lib/public-api.mjs +2 -2
  10. package/esm2020/lib/types/contentful.types.mjs +1 -1
  11. package/esm2020/lib/utils/contentful-config.mjs +12 -15
  12. package/esm2020/lib/utils/contentful.util.mjs +4 -3
  13. package/fesm2015/ethlete-contentful.mjs +221 -224
  14. package/fesm2015/ethlete-contentful.mjs.map +1 -1
  15. package/fesm2020/ethlete-contentful.mjs +222 -220
  16. package/fesm2020/ethlete-contentful.mjs.map +1 -1
  17. package/lib/components/audio/contentful-audio.component.d.ts +1 -1
  18. package/lib/components/file/contentful-file.component.d.ts +1 -1
  19. package/lib/components/image/contentful-image.component.d.ts +5 -1
  20. package/lib/components/rich-text-renderer/rich-text-renderer.component.d.ts +1 -1
  21. package/lib/components/rich-text-renderer/rich-text-renderer.util.d.ts +1 -16
  22. package/lib/components/video/contentful-video.component.d.ts +1 -1
  23. package/lib/constants/contentful.constants.d.ts +1 -1
  24. package/lib/public-api.d.ts +1 -1
  25. package/lib/types/contentful.types.d.ts +26 -0
  26. package/lib/utils/contentful-config.d.ts +2 -26
  27. package/lib/utils/contentful.util.d.ts +2 -2
  28. package/package.json +4 -4
  29. package/esm2020/lib/components/audio/index.mjs +0 -2
  30. package/esm2020/lib/components/file/index.mjs +0 -2
  31. package/esm2020/lib/components/image/index.mjs +0 -2
  32. package/esm2020/lib/components/video/index.mjs +0 -2
  33. package/esm2020/lib/utils/index.mjs +0 -2
  34. package/lib/components/audio/index.d.ts +0 -1
  35. package/lib/components/file/index.d.ts +0 -1
  36. package/lib/components/image/index.d.ts +0 -1
  37. package/lib/components/video/index.d.ts +0 -1
  38. package/lib/utils/index.d.ts +0 -1
@@ -1,215 +1,34 @@
1
- import { NgIf, NgClass, DOCUMENT } from '@angular/common';
1
+ import { DOCUMENT, NgIf, NgClass, NgOptimizedImage } from '@angular/common';
2
2
  import * as i0 from '@angular/core';
3
- import { InjectionToken, inject, Component, ChangeDetectionStrategy, ViewEncapsulation, Input, Renderer2, ElementRef, ViewContainerRef, ComponentFactoryResolver, ApplicationRef, Injector, NgModule } from '@angular/core';
3
+ import { InjectionToken, inject, Renderer2, ElementRef, ViewContainerRef, ComponentFactoryResolver, ApplicationRef, Injector, Component, ViewEncapsulation, ChangeDetectionStrategy, Input, NgModule } from '@angular/core';
4
4
  import { DomPortalOutlet, ComponentPortal } from '@angular/cdk/portal';
5
+ import { coerceBooleanProperty } from '@angular/cdk/coercion';
5
6
  import { BLOCKS, INLINES } from '@contentful/rich-text-types';
6
7
 
7
- const CONTENTFUL_CONFIG = new InjectionToken('TooltipConfig');
8
+ const CONTENTFUL_CONFIG = new InjectionToken('ContentfulConfig');
8
9
 
9
- class ContentfulConfig {
10
- constructor() {
11
- /**
12
- * Default components for rendering contentful assets
13
- */
14
- this.components = {
10
+ const createContentfulConfig = (config = {}) => ({
11
+ // This default config must be inline and not saved inside a const for some weird webpack reason
12
+ ...{
13
+ useTailwindClasses: false,
14
+ components: {
15
+ audio: ContentfulAudioComponent,
15
16
  file: ContentfulFileComponent,
16
17
  image: ContentfulImageComponent,
17
18
  video: ContentfulVideoComponent,
18
- audio: ContentfulAudioComponent,
19
- };
20
- /**
21
- * Determines if the contentful rich text renderer should render the contentful rich text with tailwind css classes
22
- */
23
- this.useTailwindClasses = false;
24
- }
25
- }
26
-
27
- const provideContentfulConfig = (contentfulConfig) => {
28
- return { provide: CONTENTFUL_CONFIG, useValue: contentfulConfig };
29
- };
19
+ },
20
+ customComponents: {},
21
+ },
22
+ ...(config || {}),
23
+ });
30
24
 
31
25
  const RICH_TEXT_RENDERER_COMPONENT_DATA = new InjectionToken('RICH_TEXT_RENDERER_COMPONENT_DATA');
32
26
 
33
- class ContentfulFileComponent {
34
- constructor() {
35
- this._richTextData = inject(RICH_TEXT_RENDERER_COMPONENT_DATA, { optional: true });
36
- this._data = null;
37
- this.fileClass = null;
38
- }
39
- get data() {
40
- return this._data;
41
- }
42
- set data(v) {
43
- if (v && !v.contentType) {
44
- this._data = null;
45
- console.warn('The provided asset is invalid', v);
46
- return;
47
- }
48
- this._data = v ?? null;
49
- }
50
- ngOnInit() {
51
- if (this._richTextData && !this.data) {
52
- this.data = this._richTextData;
53
- }
54
- }
55
- }
56
- ContentfulFileComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.9", ngImport: i0, type: ContentfulFileComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
57
- ContentfulFileComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.9", type: ContentfulFileComponent, isStandalone: true, selector: "et-contentful-file", inputs: { data: "data", fileClass: "fileClass" }, ngImport: i0, template: `
58
- <a *ngIf="data" [href]="data.url" [ngClass]="fileClass" class="underline" target="_blank">
59
- {{ data.title }} ({{ data.size }} Bytes)
60
- </a>
61
- `, isInline: true, dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
62
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.9", ngImport: i0, type: ContentfulFileComponent, decorators: [{
63
- type: Component,
64
- args: [{
65
- selector: 'et-contentful-file',
66
- template: `
67
- <a *ngIf="data" [href]="data.url" [ngClass]="fileClass" class="underline" target="_blank">
68
- {{ data.title }} ({{ data.size }} Bytes)
69
- </a>
70
- `,
71
- changeDetection: ChangeDetectionStrategy.OnPush,
72
- encapsulation: ViewEncapsulation.None,
73
- standalone: true,
74
- imports: [NgIf, NgClass],
75
- }]
76
- }], propDecorators: { data: [{
77
- type: Input
78
- }], fileClass: [{
79
- type: Input
80
- }] } });
81
-
82
- class ContentfulImageComponent {
83
- constructor() {
84
- this._richTextData = inject(RICH_TEXT_RENDERER_COMPONENT_DATA, { optional: true });
85
- this._data = null;
86
- this.imgClass = null;
87
- this.pictureClass = null;
88
- }
89
- get data() {
90
- return this._data;
91
- }
92
- set data(v) {
93
- if (v && !v.contentType) {
94
- this._data = null;
95
- console.warn('The provided asset is invalid', v);
96
- return;
97
- }
98
- if (v && !v.contentType.startsWith('image/')) {
99
- throw new Error('The provided asset is not an image');
100
- }
101
- this._data = v ?? null;
102
- }
103
- ngOnInit() {
104
- if (this._richTextData && !this.data) {
105
- this.data = this._richTextData;
106
- }
107
- }
108
- }
109
- ContentfulImageComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.9", ngImport: i0, type: ContentfulImageComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
110
- ContentfulImageComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.9", type: ContentfulImageComponent, isStandalone: true, selector: "et-contentful-image", inputs: { data: "data", imgClass: "imgClass", pictureClass: "pictureClass" }, ngImport: i0, template: `
111
- <picture *ngIf="data" [ngClass]="pictureClass">
112
- <source srcset="{{ data.url }}?fm=avif" type="image/avif" />
113
- <source srcset="{{ data.url }}?fm=webp" type="image/webp" />
114
- <source srcset="{{ data.url }}?fm=jpg" type="image/jpeg" />
115
- <img
116
- [attr.alt]="data.description ?? undefined"
117
- [attr.width]="data.width ?? undefined"
118
- [attr.height]="data.height ?? undefined"
119
- [ngClass]="imgClass"
120
- src="{{ data.url }}"
121
- />
122
- </picture>
123
- `, isInline: true, dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
124
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.9", ngImport: i0, type: ContentfulImageComponent, decorators: [{
125
- type: Component,
126
- args: [{
127
- selector: 'et-contentful-image',
128
- template: `
129
- <picture *ngIf="data" [ngClass]="pictureClass">
130
- <source srcset="{{ data.url }}?fm=avif" type="image/avif" />
131
- <source srcset="{{ data.url }}?fm=webp" type="image/webp" />
132
- <source srcset="{{ data.url }}?fm=jpg" type="image/jpeg" />
133
- <img
134
- [attr.alt]="data.description ?? undefined"
135
- [attr.width]="data.width ?? undefined"
136
- [attr.height]="data.height ?? undefined"
137
- [ngClass]="imgClass"
138
- src="{{ data.url }}"
139
- />
140
- </picture>
141
- `,
142
- changeDetection: ChangeDetectionStrategy.OnPush,
143
- encapsulation: ViewEncapsulation.None,
144
- standalone: true,
145
- imports: [NgIf, NgClass],
146
- }]
147
- }], propDecorators: { data: [{
148
- type: Input
149
- }], imgClass: [{
150
- type: Input
151
- }], pictureClass: [{
152
- type: Input
153
- }] } });
154
-
155
- class ContentfulVideoComponent {
156
- constructor() {
157
- this._richTextData = inject(RICH_TEXT_RENDERER_COMPONENT_DATA, { optional: true });
158
- this._data = null;
159
- this.videoClass = null;
160
- }
161
- get data() {
162
- return this._data;
163
- }
164
- set data(v) {
165
- if (v && !v.contentType) {
166
- this._data = null;
167
- console.warn('The provided asset is invalid', v);
168
- return;
169
- }
170
- if (v && !v.contentType.startsWith('video/')) {
171
- throw new Error('The provided asset is not an video');
172
- }
173
- this._data = v ?? null;
174
- }
175
- ngOnInit() {
176
- if (this._richTextData && !this.data) {
177
- this.data = this._richTextData;
178
- }
179
- }
180
- }
181
- ContentfulVideoComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.9", ngImport: i0, type: ContentfulVideoComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
182
- ContentfulVideoComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.9", type: ContentfulVideoComponent, isStandalone: true, selector: "et-contentful-video", inputs: { data: "data", videoClass: "videoClass" }, ngImport: i0, template: `
183
- <video *ngIf="data" [ngClass]="videoClass" controls>
184
- <source src="{{ data.url }}" type="{{ data.contentType }}" />
185
- </video>
186
- `, isInline: true, dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
187
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.9", ngImport: i0, type: ContentfulVideoComponent, decorators: [{
188
- type: Component,
189
- args: [{
190
- selector: 'et-contentful-video',
191
- template: `
192
- <video *ngIf="data" [ngClass]="videoClass" controls>
193
- <source src="{{ data.url }}" type="{{ data.contentType }}" />
194
- </video>
195
- `,
196
- changeDetection: ChangeDetectionStrategy.OnPush,
197
- encapsulation: ViewEncapsulation.None,
198
- standalone: true,
199
- imports: [NgIf, NgClass],
200
- }]
201
- }], propDecorators: { data: [{
202
- type: Input
203
- }], videoClass: [{
204
- type: Input
205
- }] } });
206
-
207
27
  const createRenderCommandsFromContentfulRichText = (options) => {
208
28
  const { data, config } = options;
209
29
  const commands = [];
210
- const assetComponents = getAssetComponentsFromConfig(config);
211
30
  const resourceMap = createContentfulResourceMap(data.links);
212
- createContentfulRenderCommand(data.json, { children: commands, payload: data.json.nodeType }, resourceMap, config.useTailwindClasses, assetComponents, config.customComponents);
31
+ createContentfulRenderCommand(data.json, { children: commands, payload: data.json.nodeType }, resourceMap, config.useTailwindClasses, config.components, config.customComponents);
213
32
  return commands;
214
33
  };
215
34
  const createContentfulRenderCommand = (node, parent, resourceMap, useTailwindClasses, assetComponents, customComponents) => {
@@ -296,14 +115,6 @@ const getContentfulNodeProps = (node) => {
296
115
  value,
297
116
  };
298
117
  };
299
- const getAssetComponentsFromConfig = (config) => {
300
- return {
301
- file: config.components?.file ?? ContentfulFileComponent,
302
- image: config.components?.image ?? ContentfulImageComponent,
303
- video: config.components?.video ?? ContentfulVideoComponent,
304
- audio: config.components?.audio ?? ContentfulAudioComponent,
305
- };
306
- };
307
118
  const transformContentfulMarks = (marks, useTailwindClasses) => {
308
119
  return marks
309
120
  .map((mark) => {
@@ -369,7 +180,6 @@ const translateContentfulNodeTypeToHtmlTag = (nodeType) => {
369
180
  // Will be ignored by the renderer
370
181
  case 'document':
371
182
  return 'document';
372
- // TODO(TRB): These should render components
373
183
  case BLOCKS.EMBEDDED_ENTRY:
374
184
  return 'div';
375
185
  case INLINES.EMBEDDED_ENTRY:
@@ -410,15 +220,18 @@ class ContentfulRichTextRendererComponent {
410
220
  this._document = inject(DOCUMENT);
411
221
  this._appRef = inject(ApplicationRef);
412
222
  this._injector = inject(Injector);
413
- this._config = inject(CONTENTFUL_CONFIG, { optional: true }) ?? new ContentfulConfig();
223
+ this._config = inject(CONTENTFUL_CONFIG, { optional: true }) ?? createContentfulConfig();
414
224
  }
415
225
  get richText() {
416
226
  return this._richText;
417
227
  }
418
228
  set richText(v) {
419
229
  this._richText = v ?? null;
420
- // clear the element
421
- this._viewContainerRef.clear();
230
+ // clear childNodes to prevent appending new richtext elements to existing one
231
+ const childElements = this._elementRef.nativeElement.childNodes;
232
+ for (const child of childElements) {
233
+ this._renderer.removeChild(this._elementRef.nativeElement, child);
234
+ }
422
235
  if (!v) {
423
236
  return;
424
237
  }
@@ -475,9 +288,9 @@ class ContentfulRichTextRendererComponent {
475
288
  }
476
289
  }
477
290
  }
478
- ContentfulRichTextRendererComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.9", ngImport: i0, type: ContentfulRichTextRendererComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
479
- ContentfulRichTextRendererComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.9", type: ContentfulRichTextRendererComponent, isStandalone: true, selector: "et-contentful-rich-text-renderer", inputs: { richText: "richText" }, host: { classAttribute: "et-contentful-rich-text-renderer" }, ngImport: i0, template: ``, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
480
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.9", ngImport: i0, type: ContentfulRichTextRendererComponent, decorators: [{
291
+ ContentfulRichTextRendererComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.2", ngImport: i0, type: ContentfulRichTextRendererComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
292
+ ContentfulRichTextRendererComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.0.2", type: ContentfulRichTextRendererComponent, isStandalone: true, selector: "et-contentful-rich-text-renderer", inputs: { richText: "richText" }, host: { classAttribute: "et-contentful-rich-text-renderer" }, ngImport: i0, template: ``, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
293
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.2", ngImport: i0, type: ContentfulRichTextRendererComponent, decorators: [{
481
294
  type: Component,
482
295
  args: [{
483
296
  selector: 'et-contentful-rich-text-renderer',
@@ -521,14 +334,14 @@ class ContentfulAudioComponent {
521
334
  }
522
335
  }
523
336
  }
524
- ContentfulAudioComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.9", ngImport: i0, type: ContentfulAudioComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
525
- ContentfulAudioComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.9", type: ContentfulAudioComponent, isStandalone: true, selector: "et-contentful-audio", inputs: { data: "data", audioClass: "audioClass", figureClass: "figureClass", figcaptionClass: "figcaptionClass" }, ngImport: i0, template: `
337
+ ContentfulAudioComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.2", ngImport: i0, type: ContentfulAudioComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
338
+ ContentfulAudioComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.0.2", type: ContentfulAudioComponent, isStandalone: true, selector: "et-contentful-audio", inputs: { data: "data", audioClass: "audioClass", figureClass: "figureClass", figcaptionClass: "figcaptionClass" }, ngImport: i0, template: `
526
339
  <figure *ngIf="data" [ngClass]="figureClass">
527
340
  <figcaption [ngClass]="figcaptionClass">{{ data.title }}</figcaption>
528
341
  <audio [ngClass]="audioClass" controls src="{{ data.url }}"></audio>
529
342
  </figure>
530
343
  `, isInline: true, dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
531
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.9", ngImport: i0, type: ContentfulAudioComponent, decorators: [{
344
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.2", ngImport: i0, type: ContentfulAudioComponent, decorators: [{
532
345
  type: Component,
533
346
  args: [{
534
347
  selector: 'et-contentful-audio',
@@ -553,10 +366,195 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.9", ngImpor
553
366
  type: Input
554
367
  }] } });
555
368
 
369
+ class ContentfulFileComponent {
370
+ constructor() {
371
+ this._richTextData = inject(RICH_TEXT_RENDERER_COMPONENT_DATA, { optional: true });
372
+ this._data = null;
373
+ this.fileClass = null;
374
+ }
375
+ get data() {
376
+ return this._data;
377
+ }
378
+ set data(v) {
379
+ if (v && !v.contentType) {
380
+ this._data = null;
381
+ console.warn('The provided asset is invalid', v);
382
+ return;
383
+ }
384
+ this._data = v ?? null;
385
+ }
386
+ ngOnInit() {
387
+ if (this._richTextData && !this.data) {
388
+ this.data = this._richTextData;
389
+ }
390
+ }
391
+ }
392
+ ContentfulFileComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.2", ngImport: i0, type: ContentfulFileComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
393
+ ContentfulFileComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.0.2", type: ContentfulFileComponent, isStandalone: true, selector: "et-contentful-file", inputs: { data: "data", fileClass: "fileClass" }, ngImport: i0, template: `
394
+ <a *ngIf="data" [href]="data.url" [ngClass]="fileClass" class="underline" target="_blank">
395
+ {{ data.title }} ({{ data.size }} Bytes)
396
+ </a>
397
+ `, isInline: true, dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
398
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.2", ngImport: i0, type: ContentfulFileComponent, decorators: [{
399
+ type: Component,
400
+ args: [{
401
+ selector: 'et-contentful-file',
402
+ template: `
403
+ <a *ngIf="data" [href]="data.url" [ngClass]="fileClass" class="underline" target="_blank">
404
+ {{ data.title }} ({{ data.size }} Bytes)
405
+ </a>
406
+ `,
407
+ changeDetection: ChangeDetectionStrategy.OnPush,
408
+ encapsulation: ViewEncapsulation.None,
409
+ standalone: true,
410
+ imports: [NgIf, NgClass],
411
+ }]
412
+ }], propDecorators: { data: [{
413
+ type: Input
414
+ }], fileClass: [{
415
+ type: Input
416
+ }] } });
417
+
418
+ class ContentfulImageComponent {
419
+ constructor() {
420
+ this._richTextData = inject(RICH_TEXT_RENDERER_COMPONENT_DATA, { optional: true });
421
+ this._data = null;
422
+ this.imgClass = null;
423
+ this.pictureClass = null;
424
+ this._priority = false;
425
+ }
426
+ get data() {
427
+ return this._data;
428
+ }
429
+ set data(v) {
430
+ if (v && !v.contentType) {
431
+ this._data = null;
432
+ console.warn('The provided asset is invalid', v);
433
+ return;
434
+ }
435
+ if (v && !v.contentType.startsWith('image/')) {
436
+ throw new Error('The provided asset is not an image');
437
+ }
438
+ this._data = v ?? null;
439
+ }
440
+ get priority() {
441
+ return this._priority;
442
+ }
443
+ set priority(value) {
444
+ this._priority = coerceBooleanProperty(value);
445
+ }
446
+ ngOnInit() {
447
+ if (this._richTextData && !this.data) {
448
+ this.data = this._richTextData;
449
+ }
450
+ }
451
+ }
452
+ ContentfulImageComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.2", ngImport: i0, type: ContentfulImageComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
453
+ ContentfulImageComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.0.2", type: ContentfulImageComponent, isStandalone: true, selector: "et-contentful-image", inputs: { data: "data", imgClass: "imgClass", pictureClass: "pictureClass", priority: "priority" }, ngImport: i0, template: `
454
+ <picture *ngIf="data" [ngClass]="pictureClass">
455
+ <source srcset="{{ data.url }}?fm=avif" type="image/avif" />
456
+ <source srcset="{{ data.url }}?fm=webp" type="image/webp" />
457
+ <source srcset="{{ data.url }}?fm=jpg" type="image/jpeg" />
458
+ <img
459
+ [attr.alt]="data.description ?? undefined"
460
+ [width]="data.width ?? undefined"
461
+ [height]="data.height ?? undefined"
462
+ [priority]="data.priority ?? priority"
463
+ [ngClass]="imgClass"
464
+ ngSrc="{{ data.url }}"
465
+ />
466
+ </picture>
467
+ `, isInline: true, dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: NgOptimizedImage, selector: "img[ngSrc]", inputs: ["ngSrc", "ngSrcset", "sizes", "width", "height", "loading", "priority", "disableOptimizedSrcset", "fill", "src", "srcset"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
468
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.2", ngImport: i0, type: ContentfulImageComponent, decorators: [{
469
+ type: Component,
470
+ args: [{
471
+ selector: 'et-contentful-image',
472
+ template: `
473
+ <picture *ngIf="data" [ngClass]="pictureClass">
474
+ <source srcset="{{ data.url }}?fm=avif" type="image/avif" />
475
+ <source srcset="{{ data.url }}?fm=webp" type="image/webp" />
476
+ <source srcset="{{ data.url }}?fm=jpg" type="image/jpeg" />
477
+ <img
478
+ [attr.alt]="data.description ?? undefined"
479
+ [width]="data.width ?? undefined"
480
+ [height]="data.height ?? undefined"
481
+ [priority]="data.priority ?? priority"
482
+ [ngClass]="imgClass"
483
+ ngSrc="{{ data.url }}"
484
+ />
485
+ </picture>
486
+ `,
487
+ changeDetection: ChangeDetectionStrategy.OnPush,
488
+ encapsulation: ViewEncapsulation.None,
489
+ standalone: true,
490
+ imports: [NgIf, NgClass, NgOptimizedImage],
491
+ }]
492
+ }], propDecorators: { data: [{
493
+ type: Input
494
+ }], imgClass: [{
495
+ type: Input
496
+ }], pictureClass: [{
497
+ type: Input
498
+ }], priority: [{
499
+ type: Input
500
+ }] } });
501
+
502
+ class ContentfulVideoComponent {
503
+ constructor() {
504
+ this._richTextData = inject(RICH_TEXT_RENDERER_COMPONENT_DATA, { optional: true });
505
+ this._data = null;
506
+ this.videoClass = null;
507
+ }
508
+ get data() {
509
+ return this._data;
510
+ }
511
+ set data(v) {
512
+ if (v && !v.contentType) {
513
+ this._data = null;
514
+ console.warn('The provided asset is invalid', v);
515
+ return;
516
+ }
517
+ if (v && !v.contentType.startsWith('video/')) {
518
+ throw new Error('The provided asset is not an video');
519
+ }
520
+ this._data = v ?? null;
521
+ }
522
+ ngOnInit() {
523
+ if (this._richTextData && !this.data) {
524
+ this.data = this._richTextData;
525
+ }
526
+ }
527
+ }
528
+ ContentfulVideoComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.2", ngImport: i0, type: ContentfulVideoComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
529
+ ContentfulVideoComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.0.2", type: ContentfulVideoComponent, isStandalone: true, selector: "et-contentful-video", inputs: { data: "data", videoClass: "videoClass" }, ngImport: i0, template: `
530
+ <video *ngIf="data" [ngClass]="videoClass" controls>
531
+ <source src="{{ data.url }}" type="{{ data.contentType }}" />
532
+ </video>
533
+ `, isInline: true, dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
534
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.2", ngImport: i0, type: ContentfulVideoComponent, decorators: [{
535
+ type: Component,
536
+ args: [{
537
+ selector: 'et-contentful-video',
538
+ template: `
539
+ <video *ngIf="data" [ngClass]="videoClass" controls>
540
+ <source src="{{ data.url }}" type="{{ data.contentType }}" />
541
+ </video>
542
+ `,
543
+ changeDetection: ChangeDetectionStrategy.OnPush,
544
+ encapsulation: ViewEncapsulation.None,
545
+ standalone: true,
546
+ imports: [NgIf, NgClass],
547
+ }]
548
+ }], propDecorators: { data: [{
549
+ type: Input
550
+ }], videoClass: [{
551
+ type: Input
552
+ }] } });
553
+
556
554
  class ContentfulModule {
557
555
  }
558
- ContentfulModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.9", ngImport: i0, type: ContentfulModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
559
- ContentfulModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.2.9", ngImport: i0, type: ContentfulModule, imports: [ContentfulAudioComponent,
556
+ ContentfulModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.2", ngImport: i0, type: ContentfulModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
557
+ ContentfulModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.0.2", ngImport: i0, type: ContentfulModule, imports: [ContentfulAudioComponent,
560
558
  ContentfulFileComponent,
561
559
  ContentfulImageComponent,
562
560
  ContentfulVideoComponent,
@@ -565,12 +563,12 @@ ContentfulModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", versio
565
563
  ContentfulImageComponent,
566
564
  ContentfulVideoComponent,
567
565
  ContentfulRichTextRendererComponent] });
568
- ContentfulModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.2.9", ngImport: i0, type: ContentfulModule, imports: [ContentfulAudioComponent,
566
+ ContentfulModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.0.2", ngImport: i0, type: ContentfulModule, imports: [ContentfulAudioComponent,
569
567
  ContentfulFileComponent,
570
568
  ContentfulImageComponent,
571
569
  ContentfulVideoComponent,
572
570
  ContentfulRichTextRendererComponent] });
573
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.9", ngImport: i0, type: ContentfulModule, decorators: [{
571
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.2", ngImport: i0, type: ContentfulModule, decorators: [{
574
572
  type: NgModule,
575
573
  args: [{
576
574
  imports: [
@@ -590,9 +588,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.9", ngImpor
590
588
  }]
591
589
  }] });
592
590
 
591
+ const provideContentfulConfig = (contentfulConfig = {}) => {
592
+ return { provide: CONTENTFUL_CONFIG, useValue: createContentfulConfig(contentfulConfig) };
593
+ };
594
+
593
595
  /**
594
596
  * Generated bundle index. Do not edit.
595
597
  */
596
598
 
597
- export { CONTENTFUL_CONFIG, ContentfulAudioComponent, ContentfulConfig, ContentfulFileComponent, ContentfulImageComponent, ContentfulModule, ContentfulRichTextRendererComponent, ContentfulVideoComponent, RICH_TEXT_RENDERER_COMPONENT_DATA, createContentfulMap, createContentfulRenderCommand, createContentfulResourceMap, createRenderCommandsFromContentfulRichText, getAssetComponentsFromConfig, getContentfulNodeProps, provideContentfulConfig, transformContentfulMarks, translateContentfulNodeTypeToHtmlTag };
599
+ export { CONTENTFUL_CONFIG, ContentfulAudioComponent, ContentfulFileComponent, ContentfulImageComponent, ContentfulModule, ContentfulRichTextRendererComponent, ContentfulVideoComponent, RICH_TEXT_RENDERER_COMPONENT_DATA, createContentfulConfig, createContentfulMap, createContentfulRenderCommand, createContentfulResourceMap, createRenderCommandsFromContentfulRichText, getContentfulNodeProps, provideContentfulConfig, transformContentfulMarks, translateContentfulNodeTypeToHtmlTag };
598
600
  //# sourceMappingURL=ethlete-contentful.mjs.map