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

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 +7 -7
  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 +216 -222
  14. package/fesm2015/ethlete-contentful.mjs.map +1 -1
  15. package/fesm2020/ethlete-contentful.mjs +217 -218
  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,30 @@
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 = {
15
- file: ContentfulFileComponent,
16
- image: ContentfulImageComponent,
17
- 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
- };
10
+ const createContentfulConfig = (config = {}) => (Object.assign({
11
+ useTailwindClasses: false,
12
+ components: {
13
+ audio: ContentfulAudioComponent,
14
+ file: ContentfulFileComponent,
15
+ image: ContentfulImageComponent,
16
+ video: ContentfulVideoComponent,
17
+ },
18
+ customComponents: {},
19
+ }, (config || {})));
30
20
 
31
21
  const RICH_TEXT_RENDERER_COMPONENT_DATA = new InjectionToken('RICH_TEXT_RENDERER_COMPONENT_DATA');
32
22
 
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 && v !== void 0 ? 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 && v !== void 0 ? 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 && v !== void 0 ? 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
23
  const createRenderCommandsFromContentfulRichText = (options) => {
208
24
  const { data, config } = options;
209
25
  const commands = [];
210
- const assetComponents = getAssetComponentsFromConfig(config);
211
26
  const resourceMap = createContentfulResourceMap(data.links);
212
- createContentfulRenderCommand(data.json, { children: commands, payload: data.json.nodeType }, resourceMap, config.useTailwindClasses, assetComponents, config.customComponents);
27
+ createContentfulRenderCommand(data.json, { children: commands, payload: data.json.nodeType }, resourceMap, config.useTailwindClasses, config.components, config.customComponents);
213
28
  return commands;
214
29
  };
215
30
  const createContentfulRenderCommand = (node, parent, resourceMap, useTailwindClasses, assetComponents, customComponents) => {
@@ -295,15 +110,6 @@ const getContentfulNodeProps = (node) => {
295
110
  value,
296
111
  };
297
112
  };
298
- const getAssetComponentsFromConfig = (config) => {
299
- var _a, _b, _c, _d, _e, _f, _g, _h;
300
- return {
301
- file: (_b = (_a = config.components) === null || _a === void 0 ? void 0 : _a.file) !== null && _b !== void 0 ? _b : ContentfulFileComponent,
302
- image: (_d = (_c = config.components) === null || _c === void 0 ? void 0 : _c.image) !== null && _d !== void 0 ? _d : ContentfulImageComponent,
303
- video: (_f = (_e = config.components) === null || _e === void 0 ? void 0 : _e.video) !== null && _f !== void 0 ? _f : ContentfulVideoComponent,
304
- audio: (_h = (_g = config.components) === null || _g === void 0 ? void 0 : _g.audio) !== null && _h !== void 0 ? _h : ContentfulAudioComponent,
305
- };
306
- };
307
113
  const transformContentfulMarks = (marks, useTailwindClasses) => {
308
114
  return marks
309
115
  .map((mark) => {
@@ -369,7 +175,6 @@ const translateContentfulNodeTypeToHtmlTag = (nodeType) => {
369
175
  // Will be ignored by the renderer
370
176
  case 'document':
371
177
  return 'document';
372
- // TODO(TRB): These should render components
373
178
  case BLOCKS.EMBEDDED_ENTRY:
374
179
  return 'div';
375
180
  case INLINES.EMBEDDED_ENTRY:
@@ -413,7 +218,7 @@ class ContentfulRichTextRendererComponent {
413
218
  this._document = inject(DOCUMENT);
414
219
  this._appRef = inject(ApplicationRef);
415
220
  this._injector = inject(Injector);
416
- this._config = (_a = inject(CONTENTFUL_CONFIG, { optional: true })) !== null && _a !== void 0 ? _a : new ContentfulConfig();
221
+ this._config = (_a = inject(CONTENTFUL_CONFIG, { optional: true })) !== null && _a !== void 0 ? _a : createContentfulConfig();
417
222
  }
418
223
  get richText() {
419
224
  return this._richText;
@@ -478,9 +283,9 @@ class ContentfulRichTextRendererComponent {
478
283
  }
479
284
  }
480
285
  }
481
- ContentfulRichTextRendererComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.9", ngImport: i0, type: ContentfulRichTextRendererComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
482
- 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 });
483
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.9", ngImport: i0, type: ContentfulRichTextRendererComponent, decorators: [{
286
+ ContentfulRichTextRendererComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: ContentfulRichTextRendererComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
287
+ ContentfulRichTextRendererComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.0.0", 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 });
288
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: ContentfulRichTextRendererComponent, decorators: [{
484
289
  type: Component,
485
290
  args: [{
486
291
  selector: 'et-contentful-rich-text-renderer',
@@ -524,14 +329,14 @@ class ContentfulAudioComponent {
524
329
  }
525
330
  }
526
331
  }
527
- ContentfulAudioComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.9", ngImport: i0, type: ContentfulAudioComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
528
- 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: `
332
+ ContentfulAudioComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: ContentfulAudioComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
333
+ ContentfulAudioComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.0.0", type: ContentfulAudioComponent, isStandalone: true, selector: "et-contentful-audio", inputs: { data: "data", audioClass: "audioClass", figureClass: "figureClass", figcaptionClass: "figcaptionClass" }, ngImport: i0, template: `
529
334
  <figure *ngIf="data" [ngClass]="figureClass">
530
335
  <figcaption [ngClass]="figcaptionClass">{{ data.title }}</figcaption>
531
336
  <audio [ngClass]="audioClass" controls src="{{ data.url }}"></audio>
532
337
  </figure>
533
338
  `, 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: "14.2.9", ngImport: i0, type: ContentfulAudioComponent, decorators: [{
339
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: ContentfulAudioComponent, decorators: [{
535
340
  type: Component,
536
341
  args: [{
537
342
  selector: 'et-contentful-audio',
@@ -556,10 +361,195 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.9", ngImpor
556
361
  type: Input
557
362
  }] } });
558
363
 
364
+ class ContentfulFileComponent {
365
+ constructor() {
366
+ this._richTextData = inject(RICH_TEXT_RENDERER_COMPONENT_DATA, { optional: true });
367
+ this._data = null;
368
+ this.fileClass = null;
369
+ }
370
+ get data() {
371
+ return this._data;
372
+ }
373
+ set data(v) {
374
+ if (v && !v.contentType) {
375
+ this._data = null;
376
+ console.warn('The provided asset is invalid', v);
377
+ return;
378
+ }
379
+ this._data = v !== null && v !== void 0 ? v : null;
380
+ }
381
+ ngOnInit() {
382
+ if (this._richTextData && !this.data) {
383
+ this.data = this._richTextData;
384
+ }
385
+ }
386
+ }
387
+ ContentfulFileComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: ContentfulFileComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
388
+ ContentfulFileComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.0.0", type: ContentfulFileComponent, isStandalone: true, selector: "et-contentful-file", inputs: { data: "data", fileClass: "fileClass" }, ngImport: i0, template: `
389
+ <a *ngIf="data" [href]="data.url" [ngClass]="fileClass" class="underline" target="_blank">
390
+ {{ data.title }} ({{ data.size }} Bytes)
391
+ </a>
392
+ `, 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 });
393
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: ContentfulFileComponent, decorators: [{
394
+ type: Component,
395
+ args: [{
396
+ selector: 'et-contentful-file',
397
+ template: `
398
+ <a *ngIf="data" [href]="data.url" [ngClass]="fileClass" class="underline" target="_blank">
399
+ {{ data.title }} ({{ data.size }} Bytes)
400
+ </a>
401
+ `,
402
+ changeDetection: ChangeDetectionStrategy.OnPush,
403
+ encapsulation: ViewEncapsulation.None,
404
+ standalone: true,
405
+ imports: [NgIf, NgClass],
406
+ }]
407
+ }], propDecorators: { data: [{
408
+ type: Input
409
+ }], fileClass: [{
410
+ type: Input
411
+ }] } });
412
+
413
+ class ContentfulImageComponent {
414
+ constructor() {
415
+ this._richTextData = inject(RICH_TEXT_RENDERER_COMPONENT_DATA, { optional: true });
416
+ this._data = null;
417
+ this.imgClass = null;
418
+ this.pictureClass = null;
419
+ this._priority = false;
420
+ }
421
+ get data() {
422
+ return this._data;
423
+ }
424
+ set data(v) {
425
+ if (v && !v.contentType) {
426
+ this._data = null;
427
+ console.warn('The provided asset is invalid', v);
428
+ return;
429
+ }
430
+ if (v && !v.contentType.startsWith('image/')) {
431
+ throw new Error('The provided asset is not an image');
432
+ }
433
+ this._data = v !== null && v !== void 0 ? v : null;
434
+ }
435
+ get priority() {
436
+ return this._priority;
437
+ }
438
+ set priority(value) {
439
+ this._priority = coerceBooleanProperty(value);
440
+ }
441
+ ngOnInit() {
442
+ if (this._richTextData && !this.data) {
443
+ this.data = this._richTextData;
444
+ }
445
+ }
446
+ }
447
+ ContentfulImageComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: ContentfulImageComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
448
+ ContentfulImageComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.0.0", type: ContentfulImageComponent, isStandalone: true, selector: "et-contentful-image", inputs: { data: "data", imgClass: "imgClass", pictureClass: "pictureClass", priority: "priority" }, ngImport: i0, template: `
449
+ <picture *ngIf="data" [ngClass]="pictureClass">
450
+ <source srcset="{{ data.url }}?fm=avif" type="image/avif" />
451
+ <source srcset="{{ data.url }}?fm=webp" type="image/webp" />
452
+ <source srcset="{{ data.url }}?fm=jpg" type="image/jpeg" />
453
+ <img
454
+ [attr.alt]="data.description ?? undefined"
455
+ [width]="data.width ?? undefined"
456
+ [height]="data.height ?? undefined"
457
+ [priority]="data.priority ?? priority"
458
+ [ngClass]="imgClass"
459
+ ngSrc="{{ data.url }}"
460
+ />
461
+ </picture>
462
+ `, 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 });
463
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: ContentfulImageComponent, decorators: [{
464
+ type: Component,
465
+ args: [{
466
+ selector: 'et-contentful-image',
467
+ template: `
468
+ <picture *ngIf="data" [ngClass]="pictureClass">
469
+ <source srcset="{{ data.url }}?fm=avif" type="image/avif" />
470
+ <source srcset="{{ data.url }}?fm=webp" type="image/webp" />
471
+ <source srcset="{{ data.url }}?fm=jpg" type="image/jpeg" />
472
+ <img
473
+ [attr.alt]="data.description ?? undefined"
474
+ [width]="data.width ?? undefined"
475
+ [height]="data.height ?? undefined"
476
+ [priority]="data.priority ?? priority"
477
+ [ngClass]="imgClass"
478
+ ngSrc="{{ data.url }}"
479
+ />
480
+ </picture>
481
+ `,
482
+ changeDetection: ChangeDetectionStrategy.OnPush,
483
+ encapsulation: ViewEncapsulation.None,
484
+ standalone: true,
485
+ imports: [NgIf, NgClass, NgOptimizedImage],
486
+ }]
487
+ }], propDecorators: { data: [{
488
+ type: Input
489
+ }], imgClass: [{
490
+ type: Input
491
+ }], pictureClass: [{
492
+ type: Input
493
+ }], priority: [{
494
+ type: Input
495
+ }] } });
496
+
497
+ class ContentfulVideoComponent {
498
+ constructor() {
499
+ this._richTextData = inject(RICH_TEXT_RENDERER_COMPONENT_DATA, { optional: true });
500
+ this._data = null;
501
+ this.videoClass = null;
502
+ }
503
+ get data() {
504
+ return this._data;
505
+ }
506
+ set data(v) {
507
+ if (v && !v.contentType) {
508
+ this._data = null;
509
+ console.warn('The provided asset is invalid', v);
510
+ return;
511
+ }
512
+ if (v && !v.contentType.startsWith('video/')) {
513
+ throw new Error('The provided asset is not an video');
514
+ }
515
+ this._data = v !== null && v !== void 0 ? v : null;
516
+ }
517
+ ngOnInit() {
518
+ if (this._richTextData && !this.data) {
519
+ this.data = this._richTextData;
520
+ }
521
+ }
522
+ }
523
+ ContentfulVideoComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: ContentfulVideoComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
524
+ ContentfulVideoComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.0.0", type: ContentfulVideoComponent, isStandalone: true, selector: "et-contentful-video", inputs: { data: "data", videoClass: "videoClass" }, ngImport: i0, template: `
525
+ <video *ngIf="data" [ngClass]="videoClass" controls>
526
+ <source src="{{ data.url }}" type="{{ data.contentType }}" />
527
+ </video>
528
+ `, 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 });
529
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: ContentfulVideoComponent, decorators: [{
530
+ type: Component,
531
+ args: [{
532
+ selector: 'et-contentful-video',
533
+ template: `
534
+ <video *ngIf="data" [ngClass]="videoClass" controls>
535
+ <source src="{{ data.url }}" type="{{ data.contentType }}" />
536
+ </video>
537
+ `,
538
+ changeDetection: ChangeDetectionStrategy.OnPush,
539
+ encapsulation: ViewEncapsulation.None,
540
+ standalone: true,
541
+ imports: [NgIf, NgClass],
542
+ }]
543
+ }], propDecorators: { data: [{
544
+ type: Input
545
+ }], videoClass: [{
546
+ type: Input
547
+ }] } });
548
+
559
549
  class ContentfulModule {
560
550
  }
561
- ContentfulModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.9", ngImport: i0, type: ContentfulModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
562
- ContentfulModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.2.9", ngImport: i0, type: ContentfulModule, imports: [ContentfulAudioComponent,
551
+ ContentfulModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: ContentfulModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
552
+ ContentfulModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.0.0", ngImport: i0, type: ContentfulModule, imports: [ContentfulAudioComponent,
563
553
  ContentfulFileComponent,
564
554
  ContentfulImageComponent,
565
555
  ContentfulVideoComponent,
@@ -568,12 +558,12 @@ ContentfulModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", versio
568
558
  ContentfulImageComponent,
569
559
  ContentfulVideoComponent,
570
560
  ContentfulRichTextRendererComponent] });
571
- ContentfulModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.2.9", ngImport: i0, type: ContentfulModule, imports: [ContentfulAudioComponent,
561
+ ContentfulModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: ContentfulModule, imports: [ContentfulAudioComponent,
572
562
  ContentfulFileComponent,
573
563
  ContentfulImageComponent,
574
564
  ContentfulVideoComponent,
575
565
  ContentfulRichTextRendererComponent] });
576
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.9", ngImport: i0, type: ContentfulModule, decorators: [{
566
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: ContentfulModule, decorators: [{
577
567
  type: NgModule,
578
568
  args: [{
579
569
  imports: [
@@ -593,9 +583,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.9", ngImpor
593
583
  }]
594
584
  }] });
595
585
 
586
+ const provideContentfulConfig = (contentfulConfig = {}) => {
587
+ return { provide: CONTENTFUL_CONFIG, useValue: createContentfulConfig(contentfulConfig) };
588
+ };
589
+
596
590
  /**
597
591
  * Generated bundle index. Do not edit.
598
592
  */
599
593
 
600
- export { CONTENTFUL_CONFIG, ContentfulAudioComponent, ContentfulConfig, ContentfulFileComponent, ContentfulImageComponent, ContentfulModule, ContentfulRichTextRendererComponent, ContentfulVideoComponent, RICH_TEXT_RENDERER_COMPONENT_DATA, createContentfulMap, createContentfulRenderCommand, createContentfulResourceMap, createRenderCommandsFromContentfulRichText, getAssetComponentsFromConfig, getContentfulNodeProps, provideContentfulConfig, transformContentfulMarks, translateContentfulNodeTypeToHtmlTag };
594
+ export { CONTENTFUL_CONFIG, ContentfulAudioComponent, ContentfulFileComponent, ContentfulImageComponent, ContentfulModule, ContentfulRichTextRendererComponent, ContentfulVideoComponent, RICH_TEXT_RENDERER_COMPONENT_DATA, createContentfulConfig, createContentfulMap, createContentfulRenderCommand, createContentfulResourceMap, createRenderCommandsFromContentfulRichText, getContentfulNodeProps, provideContentfulConfig, transformContentfulMarks, translateContentfulNodeTypeToHtmlTag };
601
595
  //# sourceMappingURL=ethlete-contentful.mjs.map