@dotcms/angular 0.0.1-alpha.40 → 0.0.1-alpha.42

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 (78) hide show
  1. package/dotcms-angular.d.ts.map +1 -0
  2. package/esm2022/dotcms-angular.mjs +5 -0
  3. package/esm2022/index.mjs +5 -0
  4. package/esm2022/lib/components/dot-editable-text/dot-editable-text.component.mjs +225 -0
  5. package/esm2022/lib/components/dot-editable-text/utils.mjs +43 -0
  6. package/esm2022/lib/components/no-component/no-component.component.mjs +32 -0
  7. package/esm2022/lib/layout/column/column.component.mjs +45 -0
  8. package/esm2022/lib/layout/container/container.component.mjs +126 -0
  9. package/esm2022/lib/layout/contentlet/contentlet.component.mjs +120 -0
  10. package/esm2022/lib/layout/dotcms-layout/dotcms-layout.component.mjs +100 -0
  11. package/esm2022/lib/layout/row/row.component.mjs +29 -0
  12. package/esm2022/lib/models/dotcms.model.mjs +3 -0
  13. package/esm2022/lib/models/index.mjs +3 -0
  14. package/esm2022/lib/services/dotcms-context/page-context.service.mjs +75 -0
  15. package/esm2022/lib/utils/index.mjs +79 -0
  16. package/fesm2022/dotcms-angular.mjs +858 -0
  17. package/fesm2022/dotcms-angular.mjs.map +1 -0
  18. package/{src/index.ts → index.d.ts} +1 -0
  19. package/index.d.ts.map +1 -0
  20. package/lib/components/dot-editable-text/dot-editable-text.component.d.ts +129 -0
  21. package/lib/components/dot-editable-text/dot-editable-text.component.d.ts.map +1 -0
  22. package/lib/components/dot-editable-text/utils.d.ts +7 -0
  23. package/lib/components/dot-editable-text/utils.d.ts.map +1 -0
  24. package/lib/components/no-component/no-component.component.d.ts +22 -0
  25. package/lib/components/no-component/no-component.component.d.ts.map +1 -0
  26. package/lib/layout/column/column.component.d.ts +29 -0
  27. package/lib/layout/column/column.component.d.ts.map +1 -0
  28. package/lib/layout/container/container.component.d.ts +88 -0
  29. package/lib/layout/container/container.component.d.ts.map +1 -0
  30. package/{src/lib/layout/contentlet/contentlet.component.ts → lib/layout/contentlet/contentlet.component.d.ts} +17 -32
  31. package/lib/layout/contentlet/contentlet.component.d.ts.map +1 -0
  32. package/lib/layout/dotcms-layout/dotcms-layout.component.d.ts +67 -0
  33. package/lib/layout/dotcms-layout/dotcms-layout.component.d.ts.map +1 -0
  34. package/lib/layout/row/row.component.d.ts +20 -0
  35. package/lib/layout/row/row.component.d.ts.map +1 -0
  36. package/{src/lib/models/dotcms.model.ts → lib/models/dotcms.model.d.ts} +3 -21
  37. package/lib/models/dotcms.model.d.ts.map +1 -0
  38. package/{src/lib/models/index.ts → lib/models/index.d.ts} +1 -8
  39. package/lib/models/index.d.ts.map +1 -0
  40. package/{src/lib/services/dotcms-context/page-context.service.ts → lib/services/dotcms-context/page-context.service.d.ts} +12 -41
  41. package/lib/services/dotcms-context/page-context.service.d.ts.map +1 -0
  42. package/lib/utils/index.d.ts +63 -0
  43. package/lib/utils/index.d.ts.map +1 -0
  44. package/package.json +21 -4
  45. package/.eslintrc.json +0 -18
  46. package/jest.config.ts +0 -22
  47. package/ng-package.json +0 -7
  48. package/project.json +0 -33
  49. package/src/lib/components/dot-editable-text/dot-editable-text.component.css +0 -4
  50. package/src/lib/components/dot-editable-text/dot-editable-text.component.html +0 -8
  51. package/src/lib/components/dot-editable-text/dot-editable-text.component.spec.ts +0 -424
  52. package/src/lib/components/dot-editable-text/dot-editable-text.component.ts +0 -269
  53. package/src/lib/components/dot-editable-text/utils.ts +0 -51
  54. package/src/lib/components/no-component/no-component.component.css +0 -3
  55. package/src/lib/components/no-component/no-component.component.spec.ts +0 -24
  56. package/src/lib/components/no-component/no-component.component.ts +0 -31
  57. package/src/lib/layout/column/column.component.css +0 -99
  58. package/src/lib/layout/column/column.component.spec.ts +0 -33
  59. package/src/lib/layout/column/column.component.ts +0 -49
  60. package/src/lib/layout/container/container.component.css +0 -9
  61. package/src/lib/layout/container/container.component.html +0 -26
  62. package/src/lib/layout/container/container.component.spec.ts +0 -205
  63. package/src/lib/layout/container/container.component.ts +0 -140
  64. package/src/lib/layout/contentlet/contentlet.component.spec.ts +0 -22
  65. package/src/lib/layout/dotcms-layout/dotcms-layout.component.css +0 -3
  66. package/src/lib/layout/dotcms-layout/dotcms-layout.component.spec.ts +0 -195
  67. package/src/lib/layout/dotcms-layout/dotcms-layout.component.ts +0 -150
  68. package/src/lib/layout/row/row.component.css +0 -6
  69. package/src/lib/layout/row/row.component.spec.ts +0 -28
  70. package/src/lib/layout/row/row.component.ts +0 -32
  71. package/src/lib/services/dotcms-context/page-context.spec.ts +0 -80
  72. package/src/lib/utils/index.ts +0 -92
  73. package/src/lib/utils/testing.utils.ts +0 -1019
  74. package/src/test-setup.ts +0 -8
  75. package/tsconfig.json +0 -29
  76. package/tsconfig.lib.json +0 -12
  77. package/tsconfig.lib.prod.json +0 -9
  78. package/tsconfig.spec.json +0 -11
@@ -1,22 +0,0 @@
1
- import { ComponentFixture, TestBed } from '@angular/core/testing';
2
-
3
- import { ContentletComponent } from './contentlet.component';
4
-
5
- describe('ContentletComponent', () => {
6
- let component: ContentletComponent;
7
- let fixture: ComponentFixture<ContentletComponent>;
8
-
9
- beforeEach(async () => {
10
- await TestBed.configureTestingModule({
11
- imports: [ContentletComponent]
12
- }).compileComponents();
13
-
14
- fixture = TestBed.createComponent(ContentletComponent);
15
- component = fixture.componentInstance;
16
- fixture.detectChanges();
17
- });
18
-
19
- it('should create', () => {
20
- expect(component).toBeTruthy();
21
- });
22
- });
@@ -1,3 +0,0 @@
1
- :host {
2
- display: block;
3
- }
@@ -1,195 +0,0 @@
1
- import { expect } from '@jest/globals';
2
- import { Spectator, createRoutingFactory } from '@ngneat/spectator/jest';
3
- import { MockComponent } from 'ng-mocks';
4
- import { of } from 'rxjs';
5
-
6
- import { Component, Input } from '@angular/core';
7
- import { ActivatedRoute, Router } from '@angular/router';
8
-
9
- import * as dotcmsClient from '@dotcms/client';
10
-
11
- import { PageResponseMock, PageResponseOneRowMock } from './../../utils/testing.utils';
12
- import { DotcmsLayoutComponent } from './dotcms-layout.component';
13
-
14
- import { DotCMSContentlet, DotCMSPageAsset } from '../../models';
15
- import { PageContextService } from '../../services/dotcms-context/page-context.service';
16
- import { RowComponent } from '../row/row.component';
17
-
18
- interface Callback {
19
- [key: string]: (data: unknown) => void;
20
- }
21
-
22
- interface DotCmsClientMock extends dotcmsClient.DotCmsClient {
23
- editor: {
24
- on: (type: string, callbackFn: (data: unknown) => void) => void;
25
- off: jest.Mock;
26
- callbacks: Callback;
27
- };
28
- }
29
-
30
- @Component({
31
- selector: 'dotcms-mock-component',
32
- standalone: true,
33
- template: 'Hello world'
34
- })
35
- class DotcmsSDKMockComponent {
36
- @Input() contentlet!: DotCMSContentlet;
37
- }
38
-
39
- jest.mock('@dotcms/client', () => ({
40
- ...jest.requireActual('@dotcms/client'),
41
- isInsideEditor: jest.fn().mockReturnValue(true),
42
- initEditor: jest.fn(),
43
- updateNavigation: jest.fn(),
44
- postMessageToEditor: jest.fn(),
45
- DotCmsClient: {
46
- instance: {
47
- editor: {
48
- on: function (type: string, callbackFn: (data: unknown) => void): void {
49
- this.callbacks[type] = callbackFn;
50
- },
51
- off: jest.fn(),
52
- callbacks: {} as Callback
53
- }
54
- }
55
- },
56
- CUSTOMER_ACTIONS: {
57
- GET_PAGE_DATA: 'get-page-data'
58
- }
59
- }));
60
-
61
- const { DotCmsClient } = dotcmsClient as jest.Mocked<typeof dotcmsClient>;
62
-
63
- describe('DotcmsLayoutComponent', () => {
64
- let spectator: Spectator<DotcmsLayoutComponent>;
65
- let pageContextService: PageContextService;
66
-
67
- const createComponent = createRoutingFactory({
68
- component: DotcmsLayoutComponent,
69
- imports: [MockComponent(RowComponent)],
70
- providers: [
71
- PageContextService,
72
- { provide: ActivatedRoute, useValue: { url: of([]) } },
73
- { provide: Router, useValue: {} }
74
- ]
75
- });
76
-
77
- beforeEach(() => {
78
- spectator = createComponent({
79
- props: {
80
- pageAsset: PageResponseMock as unknown as DotCMSPageAsset,
81
- components: {
82
- Banner: Promise.resolve(DotcmsSDKMockComponent)
83
- }
84
- },
85
- detectChanges: false
86
- });
87
-
88
- pageContextService = spectator.inject(PageContextService, true);
89
- });
90
-
91
- afterEach(() => {
92
- jest.clearAllMocks();
93
- });
94
-
95
- it('should render rows', () => {
96
- spectator.detectChanges();
97
- expect(spectator.queryAll(RowComponent).length).toBe(3);
98
- });
99
-
100
- it('should save pageContext', () => {
101
- const setContextSpy = jest.spyOn(pageContextService, 'setContext');
102
- spectator.detectChanges();
103
- expect(setContextSpy).toHaveBeenCalled();
104
- });
105
-
106
- describe('inside editor', () => {
107
- it('should call initEditor and updateNavigation from @dotcms/client', () => {
108
- const initEditorSpy = jest.spyOn(dotcmsClient, 'initEditor');
109
- const updateNavigationSpy = jest.spyOn(dotcmsClient, 'updateNavigation');
110
-
111
- spectator.detectChanges();
112
- expect(initEditorSpy).toHaveBeenCalled();
113
- expect(updateNavigationSpy).toHaveBeenCalled();
114
- });
115
-
116
- describe('onReload', () => {
117
- const client = DotCmsClient.instance;
118
- let editorOnSpy: jest.SpyInstance;
119
-
120
- beforeEach(() => {
121
- editorOnSpy = jest.spyOn(client.editor, 'on');
122
- spectator.setInput('onReload', () => {
123
- /* do nothing */
124
- });
125
- spectator.detectChanges();
126
- });
127
-
128
- it('should subscribe to the `CHANGE` event', () => {
129
- expect(editorOnSpy).toHaveBeenCalled();
130
- });
131
-
132
- it('should remove listener on unmount', () => {
133
- spectator.component.ngOnDestroy();
134
- spectator.detectChanges();
135
-
136
- expect(client.editor.off).toHaveBeenCalledWith('changes');
137
- });
138
- });
139
-
140
- describe('client is ready', () => {
141
- const query = { query: 'query { ... }' };
142
-
143
- beforeEach(() => {
144
- spectator.setInput('editor', query);
145
- spectator.detectChanges();
146
- });
147
-
148
- it('should post message to editor', () => {
149
- spectator.detectChanges();
150
- expect(dotcmsClient.postMessageToEditor).toHaveBeenCalledWith({
151
- action: dotcmsClient.CUSTOMER_ACTIONS.CLIENT_READY,
152
- payload: query
153
- });
154
- });
155
- });
156
-
157
- describe('onChange', () => {
158
- const client = DotCmsClient.instance;
159
- beforeEach(() => spectator.detectChanges());
160
-
161
- it('should update the page asset when changes are made in the editor', () => {
162
- const editorOnSpy = jest.spyOn(client.editor, 'on');
163
- expect(editorOnSpy).toHaveBeenCalledWith('changes', expect.any(Function));
164
- });
165
- });
166
- });
167
-
168
- describe('template', () => {
169
- beforeEach(() => spectator.detectChanges());
170
-
171
- it('should render rows', () => {
172
- expect(spectator.queryAll(RowComponent).length).toBe(3);
173
- });
174
-
175
- it('should pass the correct row to RowComponent', () => {
176
- const rowComponents = spectator.queryAll(RowComponent);
177
- const rows = PageResponseMock.layout.body.rows;
178
- expect(rowComponents.length).toBe(rows.length);
179
-
180
- rowComponents.forEach((component, index) => {
181
- expect(component.row).toEqual(rows[index]);
182
- });
183
- });
184
-
185
- it('should update the page asset when changes are made in the editor', () => {
186
- const { editor } = DotCmsClient.instance as DotCmsClientMock;
187
- editor.callbacks['changes'](PageResponseOneRowMock);
188
- spectator.detectChanges();
189
- const rowComponents = spectator.queryAll(RowComponent);
190
- const rows = PageResponseMock.layout.body.rows;
191
- expect(rowComponents.length).toBe(1);
192
- expect(rowComponents[0].row).toEqual(rows[0]);
193
- });
194
- });
195
- });
@@ -1,150 +0,0 @@
1
- import { AsyncPipe } from '@angular/common';
2
- import {
3
- ChangeDetectionStrategy,
4
- Component,
5
- DestroyRef,
6
- Input,
7
- OnInit,
8
- inject
9
- } from '@angular/core';
10
- import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
11
- import { ActivatedRoute } from '@angular/router';
12
-
13
- import {
14
- CUSTOMER_ACTIONS,
15
- DotCmsClient,
16
- EditorConfig,
17
- initEditor,
18
- isInsideEditor,
19
- postMessageToEditor,
20
- updateNavigation
21
- } from '@dotcms/client';
22
-
23
- import { DotCMSPageComponent } from '../../models';
24
- import { DotCMSPageAsset } from '../../models/dotcms.model';
25
- import { PageContextService } from '../../services/dotcms-context/page-context.service';
26
- import { RowComponent } from '../row/row.component';
27
-
28
- /**
29
- * `DotcmsLayoutComponent` is a class that represents the layout for a DotCMS page.
30
- * It includes a `pageAsset` property that represents the DotCMS page asset and a `components` property that represents the dynamic components for the page.
31
- *
32
- * @export
33
- * @class DotcmsLayoutComponent
34
- */
35
- @Component({
36
- selector: 'dotcms-layout',
37
- standalone: true,
38
- imports: [RowComponent, AsyncPipe],
39
- template: `
40
- @if (pageAsset$ | async; as page) {
41
- @for (row of this.page?.layout?.body?.rows; track $index) {
42
- <dotcms-row [row]="row" />
43
- }
44
- }
45
- `,
46
- styleUrl: './dotcms-layout.component.css',
47
- changeDetection: ChangeDetectionStrategy.OnPush
48
- })
49
- export class DotcmsLayoutComponent implements OnInit {
50
- private _pageAsset!: DotCMSPageAsset;
51
-
52
- /**
53
- * Represents the DotCMS page asset.
54
- *
55
- * @type {DotCMSPageAsset}
56
- * @memberof DotcmsLayoutComponent
57
- */
58
- @Input({ required: true })
59
- set pageAsset(value: DotCMSPageAsset) {
60
- this._pageAsset = value;
61
- if (!value.layout) {
62
- console.warn(
63
- 'Warning: pageAsset does not have a `layout` property. Might be using an advaced template or your dotCMS instance not have a enterprise license.'
64
- );
65
- }
66
- }
67
-
68
- /**
69
- * Returns the DotCMS page asset.
70
- *
71
- * @readonly
72
- * @type {DotCMSPageAsset}
73
- * @memberof DotcmsLayoutComponent
74
- */
75
- get pageAsset(): DotCMSPageAsset {
76
- return this._pageAsset;
77
- }
78
-
79
- /**
80
- * The `components` property is a record of dynamic components for each Contentlet on the page.
81
- *
82
- * @type {DotCMSPageComponent}
83
- * @memberof DotcmsLayoutComponent
84
- * @required
85
- */
86
- @Input({ required: true }) components!: DotCMSPageComponent;
87
-
88
- /**
89
- * The `onReload` property is a function that reloads the page after changes are made.
90
- *
91
- * @memberof DotcmsLayoutComponent
92
- * @deprecated In future implementation we will be listening for the changes from the editor to update the page state so reload will not be needed.
93
- */
94
- @Input() onReload!: () => void;
95
-
96
- /**
97
- *
98
- * @type {DotCMSFetchConfig}
99
- * @memberof DotCMSPageEditorConfig
100
- * @description The configuration custom params for data fetching on Edit Mode.
101
- * @example <caption>Example with Custom GraphQL query</caption>
102
- * <dotcms-layout [editor]="{ query: 'query { ... }' }"/>
103
- *
104
- * @example <caption>Example usage with Custom Page API parameters</caption>
105
- * <dotcms-layout [editor]="{ params: { depth: '2' } }"/>;
106
- */
107
- @Input() editor!: EditorConfig;
108
-
109
- private readonly route = inject(ActivatedRoute);
110
- private readonly pageContextService = inject(PageContextService);
111
- private readonly destroyRef$ = inject(DestroyRef);
112
- private client!: DotCmsClient;
113
- protected readonly pageAsset$ = this.pageContextService.currentPage$;
114
-
115
- ngOnInit() {
116
- this.pageContextService.setContext(this.pageAsset, this.components);
117
-
118
- if (!isInsideEditor()) {
119
- return;
120
- }
121
-
122
- this.client = DotCmsClient.instance;
123
- this.route.url.pipe(takeUntilDestroyed(this.destroyRef$)).subscribe((urlSegments) => {
124
- const pathname = '/' + urlSegments.join('/');
125
-
126
- initEditor({ pathname });
127
- updateNavigation(pathname || '/');
128
- });
129
-
130
- this.client.editor.on('changes', (data) => {
131
- if (this.onReload) {
132
- this.onReload();
133
-
134
- return;
135
- }
136
-
137
- this.pageContextService.setPageAsset(data as DotCMSPageAsset);
138
- });
139
-
140
- postMessageToEditor({ action: CUSTOMER_ACTIONS.CLIENT_READY, payload: this.editor });
141
- }
142
-
143
- ngOnDestroy() {
144
- if (!isInsideEditor()) {
145
- return;
146
- }
147
-
148
- this.client.editor.off('changes');
149
- }
150
- }
@@ -1,6 +0,0 @@
1
- :host {
2
- display: grid;
3
- grid-template-columns: repeat(12, 1fr);
4
- gap: 1rem;
5
- row-gap: 1rem;
6
- }
@@ -1,28 +0,0 @@
1
- import { Spectator, createComponentFactory } from '@ngneat/spectator/jest';
2
- import { MockComponent } from 'ng-mocks';
3
-
4
- import { RowComponent } from './row.component';
5
-
6
- import { DotPageAssetLayoutRow } from '../../models';
7
- import { PageResponseMock } from '../../utils/testing.utils';
8
- import { ColumnComponent } from '../column/column.component';
9
-
10
- describe('RowComponent', () => {
11
- let spectator: Spectator<RowComponent>;
12
- const createComponent = createComponentFactory({
13
- component: RowComponent,
14
- imports: [MockComponent(ColumnComponent)]
15
- });
16
-
17
- beforeEach(() => {
18
- spectator = createComponent({
19
- props: {
20
- row: PageResponseMock.layout.body.rows[1] as DotPageAssetLayoutRow
21
- }
22
- });
23
- });
24
-
25
- it('should render two columns', () => {
26
- expect(spectator.queryAll(ColumnComponent)?.length).toBe(4);
27
- });
28
- });
@@ -1,32 +0,0 @@
1
- import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
2
-
3
- import { DotPageAssetLayoutRow } from '../../models';
4
- import { ColumnComponent } from '../column/column.component';
5
-
6
- /**
7
- * This component is responsible to display a row with columns.
8
- *
9
- * @export
10
- * @class RowComponent
11
- */
12
- @Component({
13
- selector: 'dotcms-row',
14
- standalone: true,
15
- imports: [ColumnComponent],
16
- template: `
17
- @for (column of row.columns; track $index) {
18
- <dotcms-column [column]="column" />
19
- }
20
- `,
21
- styleUrl: './row.component.css',
22
- changeDetection: ChangeDetectionStrategy.OnPush
23
- })
24
- export class RowComponent {
25
- /**
26
- * The row object containing the columns.
27
- *
28
- * @type {DotPageAssetLayoutRow}
29
- * @memberof RowComponent
30
- */
31
- @Input({ required: true }) row!: DotPageAssetLayoutRow;
32
- }
@@ -1,80 +0,0 @@
1
- import { SpectatorService, createServiceFactory } from '@ngneat/spectator';
2
-
3
- import { TestBed } from '@angular/core/testing';
4
-
5
- import { PageContextService } from './page-context.service';
6
-
7
- import { DotCMSPageAsset, DotCMSPageComponent } from '../../models';
8
- import { PageResponseMock } from '../../utils/testing.utils';
9
-
10
- const initialPageAssetMock = {} as DotCMSPageAsset;
11
- const initialComponentsMock = {} as DotCMSPageComponent;
12
-
13
- describe('PageContextService', () => {
14
- let spectator: SpectatorService<PageContextService>;
15
- let service: PageContextService;
16
-
17
- const createService = createServiceFactory(PageContextService);
18
-
19
- beforeEach(() => {
20
- TestBed.configureTestingModule({});
21
- spectator = createService();
22
- service = spectator.service;
23
- });
24
-
25
- it('should set the context', () => {
26
- service.setContext(initialPageAssetMock, initialComponentsMock);
27
-
28
- expect(service.context).toEqual({
29
- components: initialComponentsMock,
30
- pageAsset: initialPageAssetMock,
31
- isInsideEditor: false
32
- });
33
- });
34
-
35
- it('should set the page asset in the context', () => {
36
- service.setContext(initialPageAssetMock, initialComponentsMock);
37
-
38
- const newPageAssetMock = PageResponseMock as unknown as DotCMSPageAsset;
39
-
40
- service.setPageAsset(newPageAssetMock);
41
-
42
- expect(service.context).toEqual({
43
- components: initialComponentsMock,
44
- pageAsset: newPageAssetMock,
45
- isInsideEditor: false
46
- });
47
- });
48
-
49
- it('should return the context', () => {
50
- service.setContext(initialPageAssetMock, initialComponentsMock);
51
-
52
- expect(service.context).toEqual({
53
- components: initialComponentsMock,
54
- pageAsset: initialPageAssetMock,
55
- isInsideEditor: false
56
- });
57
- });
58
-
59
- it('should return the context as an observable', (done) => {
60
- service.setContext(initialPageAssetMock, initialComponentsMock);
61
-
62
- service.contextObs$.subscribe((context) => {
63
- expect(context).toEqual({
64
- components: initialComponentsMock,
65
- pageAsset: initialPageAssetMock,
66
- isInsideEditor: false
67
- });
68
- done();
69
- });
70
- });
71
-
72
- it('should return the page asset as an observable', (done) => {
73
- service.setContext(initialPageAssetMock, initialComponentsMock);
74
-
75
- service.currentPage$.subscribe((pageAsset) => {
76
- expect(pageAsset).toEqual(initialPageAssetMock);
77
- done();
78
- });
79
- });
80
- });
@@ -1,92 +0,0 @@
1
- import { DotCMSContainer, DotCMSPageAssetContainer } from '../models/dotcms.model';
2
-
3
- //Changed the type, to avoid SQ issue.
4
- //This should be put inside a lib
5
- /**
6
- * Represents a mapping of numbers to corresponding CSS class names for column end values.
7
- * @typedef {Record<number, string | null>} EndClassMap
8
- */
9
- const endClassMap: Record<number, string | null> = {
10
- 1: 'col-end-1',
11
- 2: 'col-end-2',
12
- 3: 'col-end-3',
13
- 4: 'col-end-4',
14
- 5: 'col-end-5',
15
- 6: 'col-end-6',
16
- 7: 'col-end-7',
17
- 8: 'col-end-8',
18
- 9: 'col-end-9',
19
- 10: 'col-end-10',
20
- 11: 'col-end-11',
21
- 12: 'col-end-12',
22
- 13: 'col-end-13'
23
- };
24
-
25
- //Changed the type, to avoid SQ issue.
26
- //This should be put inside a lib
27
- /**
28
- * Represents a mapping of numbers to CSS class names for starting columns.
29
- * @typedef {Record<number, string | null>} StartClassMap
30
- */
31
- const startClassMap: Record<number, string | null> = {
32
- 1: 'col-start-1',
33
- 2: 'col-start-2',
34
- 3: 'col-start-3',
35
- 4: 'col-start-4',
36
- 5: 'col-start-5',
37
- 6: 'col-start-6',
38
- 7: 'col-start-7',
39
- 8: 'col-start-8',
40
- 9: 'col-start-9',
41
- 10: 'col-start-10',
42
- 11: 'col-start-11',
43
- 12: 'col-start-12'
44
- };
45
-
46
- /**
47
- * Retrieves the data for a set of containers.
48
- *
49
- * @param containers - The DotCMSPageAssetContainer object containing the containers.
50
- * @param containerRef - The DotCMSContainer object representing the container reference.
51
- * @returns An object containing the container data, accept types, contentlets, and variant ID.
52
- */
53
- export const getContainersData = (
54
- containers: DotCMSPageAssetContainer,
55
- containerRef: DotCMSContainer
56
- ) => {
57
- const { identifier, uuid } = containerRef;
58
-
59
- const { containerStructures, container } = containers[identifier];
60
-
61
- const { variantId } = container?.parentPermissionable || {};
62
-
63
- const acceptTypes: string = containerStructures
64
- .map((structure) => structure.contentTypeVar)
65
- .join(',');
66
-
67
- const contentlets = containers[identifier].contentlets[`uuid-${uuid}`];
68
-
69
- return {
70
- ...containers[identifier].container,
71
- acceptTypes,
72
- contentlets,
73
- variantId
74
- };
75
- };
76
-
77
- /**
78
- * Returns the position style classes based on the start and end values.
79
- * Used to set the grid column start and end values.
80
- * @param start - The start value.
81
- * @param end - The end value.
82
- * @returns An object containing the startClass and endClass.
83
- */
84
- export const getPositionStyleClasses = (start: number, end: number) => {
85
- const startClass = startClassMap[start];
86
- const endClass = endClassMap[end];
87
-
88
- return {
89
- startClass,
90
- endClass
91
- };
92
- };