Skip to content

Commit e5eda69

Browse files
refactor. Use a separate ContentChildren for each property (collection option)
+ update making bundle in demos
1 parent d765548 commit e5eda69

1,456 files changed

Lines changed: 5686 additions & 2887 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

apps/demos/configs/Angular/config.bundle.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ const bundleConfig = {
4141
'devextreme-angular/common/core/*',
4242
'devextreme-angular/common/export/*',
4343
'devextreme-angular/core/*',
44+
'devextreme-angular/tokens/*',
4445
'devexpress-gantt',
4546
'devexpress-diagram',
4647
'rxjs/*',

apps/demos/configs/Angular/config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ window.config = {
195195
'devextreme-angular/common/grids': 'bundles:devextreme-angular/devextreme-angular-common-grids.umd.js',
196196
'devextreme-angular/common': 'bundles:devextreme-angular/devextreme-angular-common.umd.js',
197197
'devextreme-angular/http': 'bundles:devextreme-angular/devextreme-angular-http.umd.js',
198+
'devextreme-angular/tokens': 'bundles:devextreme-angular/devextreme-angular-tokens.umd.js',
198199
...componentNames.reduce((acc, name) => {
199200
acc[`devextreme-angular/ui/${name}`] = `bundles:devextreme-angular/devextreme-angular-ui-${name}.umd.js`;
200201
acc[`devextreme-angular/ui/${name}/nested`] = `bundles:devextreme-angular/devextreme-angular-ui-${name}-nested.umd.js`;

apps/demos/rollup.devextreme-angular.umd.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const inputs = {
1616
'devextreme-angular': `${baseDir}devextreme-angular.mjs`,
1717
'devextreme-angular-core': `${baseDir}devextreme-angular-core.mjs`,
1818
'devextreme-angular-http': `${baseDir}devextreme-angular-http.mjs`,
19+
'devextreme-angular-tokens': `${baseDir}devextreme-angular-tokens.mjs`,
1920
...fileNames.reduce((acc, name) => {
2021
acc[name] = `${baseDir}${name}.mjs`;
2122

apps/demos/utils/bundle/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ const prepareConfigs = (framework)=> {
146146
additionPaths = {
147147
'devextreme-angular': `${bundlesRoot}/devextreme-angular.umd.js`,
148148
'devextreme-angular/core': `${bundlesRoot}/devextreme-angular-core.umd.js`,
149+
'devextreme-angular/tokens': `${bundlesRoot}/devextreme-angular-tokens.umd.js`,
149150
...componentNames.reduce((items, item) => {
150151
// eslint-disable-next-line no-param-reassign
151152
items[`devextreme-angular/ui/${item.replace('-nested', '/nested')}`] = `${bundlesRoot}/devextreme-angular-ui-${item}.umd.js`;

packages/devextreme-angular/src/core/nested-option.ts

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {
2-
Component, QueryList, ElementRef, Renderer2, EventEmitter, InjectionToken, Directive,
2+
Component, QueryList, ElementRef, Renderer2, EventEmitter, Directive,
33
} from '@angular/core';
44

55
import render from 'devextreme/core/renderer';
@@ -22,43 +22,12 @@ export interface INestedOptionContainer {
2222

2323
export type IOptionPathGetter = () => string;
2424

25-
export const СOLLECTION_NESTED_OPTION_TOKEN = new InjectionToken<string>('collection-nested-option-token');
26-
2725
@Directive()
2826
export abstract class DxBaseClass {
29-
private _activatedProps: string[] = [];
30-
3127
private _activatedQueries = {};
3228

3329
protected abstract _setOption(name: string, value: any): void;
3430

35-
protected _setCollectionOptionChildren(value: QueryList<{ propertyName: string; component: CollectionNestedOption }>) {
36-
const groupedItems: Record<string, CollectionNestedOption[]> = {};
37-
38-
value.forEach(({ propertyName, component }) => {
39-
groupedItems[propertyName] = groupedItems[propertyName] || [];
40-
groupedItems[propertyName].push(component);
41-
});
42-
43-
const notEmptyProps: string[] = [];
44-
45-
Object.entries(groupedItems).forEach(([propertyName, items]) => {
46-
const q = new QueryList<CollectionNestedOption>();
47-
q.reset(items);
48-
49-
this.setChildren(propertyName, q);
50-
notEmptyProps.push(propertyName);
51-
});
52-
53-
this._activatedProps.forEach((propertyName) => {
54-
if (!notEmptyProps.includes(propertyName)) {
55-
this.setChildren(propertyName, new QueryList<CollectionNestedOption>());
56-
}
57-
});
58-
59-
this._activatedProps = notEmptyProps;
60-
}
61-
6231
setChildren(propertyName: string, items: QueryList<CollectionNestedOption>) {
6332
if (items.length) {
6433
this._activatedQueries[propertyName] = true;
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { InjectionToken } from '@angular/core';
2+
3+
export const PROPERTY_TOKEN_items = new InjectionToken<string>('property-token-items');
4+
export const PROPERTY_TOKEN_buttons = new InjectionToken<string>('property-token-buttons');
5+
export const PROPERTY_TOKEN_toolbarItems = new InjectionToken<string>('property-token-toolbarItems');
6+
export const PROPERTY_TOKEN_validationRules = new InjectionToken<string>('property-token-validationRules');
7+
export const PROPERTY_TOKEN_changes = new InjectionToken<string>('property-token-changes');
8+
export const PROPERTY_TOKEN_columns = new InjectionToken<string>('property-token-columns');
9+
export const PROPERTY_TOKEN_customOperations = new InjectionToken<string>('property-token-customOperations');
10+
export const PROPERTY_TOKEN_fields = new InjectionToken<string>('property-token-fields');
11+
export const PROPERTY_TOKEN_tabs = new InjectionToken<string>('property-token-tabs');
12+
export const PROPERTY_TOKEN_annotations = new InjectionToken<string>('property-token-annotations');
13+
export const PROPERTY_TOKEN_breaks = new InjectionToken<string>('property-token-breaks');
14+
export const PROPERTY_TOKEN_constantLines = new InjectionToken<string>('property-token-constantLines');
15+
export const PROPERTY_TOKEN_panes = new InjectionToken<string>('property-token-panes');
16+
export const PROPERTY_TOKEN_series = new InjectionToken<string>('property-token-series');
17+
export const PROPERTY_TOKEN_strips = new InjectionToken<string>('property-token-strips');
18+
export const PROPERTY_TOKEN_valueAxis = new InjectionToken<string>('property-token-valueAxis');
19+
export const PROPERTY_TOKEN_alerts = new InjectionToken<string>('property-token-alerts');
20+
export const PROPERTY_TOKEN_typingUsers = new InjectionToken<string>('property-token-typingUsers');
21+
export const PROPERTY_TOKEN_ranges = new InjectionToken<string>('property-token-ranges');
22+
export const PROPERTY_TOKEN_groupItems = new InjectionToken<string>('property-token-groupItems');
23+
export const PROPERTY_TOKEN_sortByGroupSummaryInfo = new InjectionToken<string>('property-token-sortByGroupSummaryInfo');
24+
export const PROPERTY_TOKEN_totalItems = new InjectionToken<string>('property-token-totalItems');
25+
export const PROPERTY_TOKEN_commands = new InjectionToken<string>('property-token-commands');
26+
export const PROPERTY_TOKEN_connectionPoints = new InjectionToken<string>('property-token-connectionPoints');
27+
export const PROPERTY_TOKEN_customShapes = new InjectionToken<string>('property-token-customShapes');
28+
export const PROPERTY_TOKEN_groups = new InjectionToken<string>('property-token-groups');
29+
export const PROPERTY_TOKEN_fileSelectionItems = new InjectionToken<string>('property-token-fileSelectionItems');
30+
export const PROPERTY_TOKEN_stripLines = new InjectionToken<string>('property-token-stripLines');
31+
export const PROPERTY_TOKEN_mentions = new InjectionToken<string>('property-token-mentions');
32+
export const PROPERTY_TOKEN_menuItems = new InjectionToken<string>('property-token-menuItems');
33+
export const PROPERTY_TOKEN_locations = new InjectionToken<string>('property-token-locations');
34+
export const PROPERTY_TOKEN_markers = new InjectionToken<string>('property-token-markers');
35+
export const PROPERTY_TOKEN_routes = new InjectionToken<string>('property-token-routes');
36+
export const PROPERTY_TOKEN_cols = new InjectionToken<string>('property-token-cols');
37+
export const PROPERTY_TOKEN_location = new InjectionToken<string>('property-token-location');
38+
export const PROPERTY_TOKEN_rows = new InjectionToken<string>('property-token-rows');
39+
export const PROPERTY_TOKEN_resources = new InjectionToken<string>('property-token-resources');
40+
export const PROPERTY_TOKEN_views = new InjectionToken<string>('property-token-views');
41+
export const PROPERTY_TOKEN_layers = new InjectionToken<string>('property-token-layers');
42+
export const PROPERTY_TOKEN_legends = new InjectionToken<string>('property-token-legends');
43+
export const PROPERTY_TOKEN_center = new InjectionToken<string>('property-token-center');
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"lib": {
3+
"entryFile": "index.ts"
4+
}
5+
}

packages/devextreme-angular/src/ui/accordion/index.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,14 @@ import {
4040
IterableDifferHelper,
4141
WatcherHelper,
4242
CollectionNestedOption,
43-
СOLLECTION_NESTED_OPTION_TOKEN,
4443
} from 'devextreme-angular/core';
4544

4645
import { DxiItemModule } from 'devextreme-angular/ui/nested';
4746

4847
import { DxiAccordionItemModule } from 'devextreme-angular/ui/accordion/nested';
48+
import {
49+
PROPERTY_TOKEN_items,
50+
} from 'devextreme-angular/tokens';
4951

5052

5153
/**
@@ -67,9 +69,9 @@ import { DxiAccordionItemModule } from 'devextreme-angular/ui/accordion/nested';
6769
})
6870
export class DxAccordionComponent<TItem = any, TKey = any> extends DxComponent implements OnDestroy, OnChanges, DoCheck {
6971

70-
@ContentChildren(СOLLECTION_NESTED_OPTION_TOKEN)
71-
set _CollectionOptionChildren(value: QueryList<{ propertyName: string, component: CollectionNestedOption }>) {
72-
this._setCollectionOptionChildren(value);
72+
@ContentChildren(PROPERTY_TOKEN_items)
73+
set _itemsContentChildren(value: QueryList<CollectionNestedOption>) {
74+
this.setChildren('items', value);
7375
}
7476

7577
instance: DxAccordion<TItem, TKey> = null;

packages/devextreme-angular/src/ui/accordion/nested/item-dxi.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@ import {
2424
DxTemplateDirective,
2525
IDxTemplateHost,
2626
DxTemplateHost,
27-
СOLLECTION_NESTED_OPTION_TOKEN,
2827
} from 'devextreme-angular/core';
2928
import { CollectionNestedOption } from 'devextreme-angular/core';
3029

30+
import { PROPERTY_TOKEN_items } from 'devextreme-angular/tokens';
31+
32+
3133
@Component({
3234
selector: 'dxi-accordion-item',
3335
standalone: true,
@@ -37,14 +39,10 @@ import { CollectionNestedOption } from 'devextreme-angular/core';
3739
providers: [
3840
NestedOptionHost,
3941
DxTemplateHost,
40-
{
41-
provide: СOLLECTION_NESTED_OPTION_TOKEN,
42-
useFactory: (component: DxiAccordionItemComponent) => ({
43-
propertyName: 'items',
44-
component
45-
}),
46-
deps: [DxiAccordionItemComponent],
47-
}
42+
{
43+
provide: PROPERTY_TOKEN_items,
44+
useExisting: DxiAccordionItemComponent,
45+
}
4846
],
4947
})
5048
export class DxiAccordionItemComponent extends CollectionNestedOption implements AfterViewInit,

packages/devextreme-angular/src/ui/action-sheet/index.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,14 @@ import {
4040
IterableDifferHelper,
4141
WatcherHelper,
4242
CollectionNestedOption,
43-
СOLLECTION_NESTED_OPTION_TOKEN,
4443
} from 'devextreme-angular/core';
4544

4645
import { DxiItemModule } from 'devextreme-angular/ui/nested';
4746

4847
import { DxiActionSheetItemModule } from 'devextreme-angular/ui/action-sheet/nested';
48+
import {
49+
PROPERTY_TOKEN_items,
50+
} from 'devextreme-angular/tokens';
4951

5052

5153
/**
@@ -67,9 +69,9 @@ import { DxiActionSheetItemModule } from 'devextreme-angular/ui/action-sheet/nes
6769
})
6870
export class DxActionSheetComponent<TItem = any, TKey = any> extends DxComponent implements OnDestroy, OnChanges, DoCheck {
6971

70-
@ContentChildren(СOLLECTION_NESTED_OPTION_TOKEN)
71-
set _CollectionOptionChildren(value: QueryList<{ propertyName: string, component: CollectionNestedOption }>) {
72-
this._setCollectionOptionChildren(value);
72+
@ContentChildren(PROPERTY_TOKEN_items)
73+
set _itemsContentChildren(value: QueryList<CollectionNestedOption>) {
74+
this.setChildren('items', value);
7375
}
7476

7577
instance: DxActionSheet<TItem, TKey> = null;

0 commit comments

Comments
 (0)