Skip to content

Commit

Permalink
Generate new Angular configuration components (#28015)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexslavr authored Sep 10, 2024
1 parent 1a05059 commit 459dba5
Show file tree
Hide file tree
Showing 1,113 changed files with 147,909 additions and 416 deletions.
1 change: 1 addition & 0 deletions apps/demos/configs/Angular/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ window.config = {
'devextreme-angular/http': 'bundles:devextreme-angular/devextreme-angular-http.umd.js',
...componentNames.reduce((acc, name) => {
acc[`devextreme-angular/ui/${name}`] = `bundles:devextreme-angular/devextreme-angular-ui-${name}.umd.js`;
acc[`devextreme-angular/ui/${name}/nested`] = `bundles:devextreme-angular/devextreme-angular-ui-${name}-nested.umd.js`;
return acc;
}, {}),

Expand Down
4 changes: 2 additions & 2 deletions apps/demos/utils/bundle/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,15 @@ const prepareConfigs = (framework)=> {
'devextreme-angular/core': `${bundlesRoot}/devextreme-angular-core.umd.js`,
...componentNames.reduce((items, item) => {
// eslint-disable-next-line no-param-reassign
items[`devextreme-angular/ui/${item}`] = `${bundlesRoot}/devextreme-angular-ui-${item}.umd.js`;
items[`devextreme-angular/ui/${item.replace('-nested', '/nested')}`] = `${bundlesRoot}/devextreme-angular-ui-${item}.umd.js`;
return items;
}, {}),
};

modulesMap = {
...componentNames.reduce((items, item) => {
// eslint-disable-next-line no-param-reassign
items[`devextreme-angular/ui/${item}`] = `${bundlesRoot}/devextreme-angular-ui-${item}.umd.js`;
items[`devextreme-angular/ui/${item.replace('-nested', '/nested')}`] = `${bundlesRoot}/devextreme-angular-ui-${item}.umd.js`;
return items;
}, {}),
};
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"axe-core": "4.10.0",
"cheerio": "1.0.0-rc.10",
"codelyzer": "6.0.2",
"devextreme-internal-tools": "14.0.0-beta.6",
"devextreme-internal-tools": "16.0.0-beta.3",
"http-server": "14.1.1",
"husky": "8.0.3",
"jest": "29.7.0",
Expand Down
22 changes: 22 additions & 0 deletions packages/devextreme-angular/src/core/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,28 @@ export abstract class DxComponent implements OnChanges, OnInit, DoCheck, AfterCo
this.templateUpdateRequired = true;
}

contentChildren = {};

checkContentChildren<T>(propertyName: string, items: QueryList<T>, className: string) {
if (this.contentChildren[propertyName]) {
if (items.length > 0) {
if (console && console.warn) {
console.warn(`In ${this.constructor.name},
the nested ${className} and ${this.contentChildren[propertyName]} components are incompatible.
Ensure that all nested components in the content area match.`);
}
}
return false;
}
return true;
}

setContentChildren<T>(propertyName: string, items: QueryList<T>, className: string) {
if (items.length > 0) {
this.contentChildren[propertyName] = className;
}
}

setChildren<T extends ICollectionNestedOption>(propertyName: string, items: QueryList<T>) {
this.resetOptions(propertyName);
return this._collectionContainerImpl.setChildren(propertyName, items);
Expand Down
4 changes: 2 additions & 2 deletions packages/devextreme-angular/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ export { DxAutocompleteComponent, DxAutocompleteModule } from 'devextreme-angula
export { DxBarGaugeComponent, DxBarGaugeModule } from 'devextreme-angular/ui/bar-gauge';
export { DxBoxComponent, DxBoxModule } from 'devextreme-angular/ui/box';
export { DxBulletComponent, DxBulletModule } from 'devextreme-angular/ui/bullet';
export { DxButtonGroupComponent, DxButtonGroupModule } from 'devextreme-angular/ui/button-group';
export { DxButtonComponent, DxButtonModule } from 'devextreme-angular/ui/button';
export { DxButtonGroupComponent, DxButtonGroupModule } from 'devextreme-angular/ui/button-group';
export { DxCalendarComponent, DxCalendarModule } from 'devextreme-angular/ui/calendar';
export { DxChartComponent, DxChartModule } from 'devextreme-angular/ui/chart';
export { DxChatComponent, DxChatModule } from 'devextreme-angular/ui/chat';
Expand Down Expand Up @@ -45,8 +45,8 @@ export { DxMenuComponent, DxMenuModule } from 'devextreme-angular/ui/menu';
export { DxMultiViewComponent, DxMultiViewModule } from 'devextreme-angular/ui/multi-view';
export { DxNumberBoxComponent, DxNumberBoxModule } from 'devextreme-angular/ui/number-box';
export { DxPieChartComponent, DxPieChartModule } from 'devextreme-angular/ui/pie-chart';
export { DxPivotGridFieldChooserComponent, DxPivotGridFieldChooserModule } from 'devextreme-angular/ui/pivot-grid-field-chooser';
export { DxPivotGridComponent, DxPivotGridModule } from 'devextreme-angular/ui/pivot-grid';
export { DxPivotGridFieldChooserComponent, DxPivotGridFieldChooserModule } from 'devextreme-angular/ui/pivot-grid-field-chooser';
export { DxPolarChartComponent, DxPolarChartModule } from 'devextreme-angular/ui/polar-chart';
export { DxPopoverComponent, DxPopoverModule } from 'devextreme-angular/ui/popover';
export { DxPopupComponent, DxPopupModule } from 'devextreme-angular/ui/popup';
Expand Down
21 changes: 19 additions & 2 deletions packages/devextreme-angular/src/ui/accordion/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,11 @@ import {

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

import { DxiAccordionItemModule } from 'devextreme-angular/ui/accordion/nested';

import { DxiItemComponent } from 'devextreme-angular/ui/nested';

import { DxiAccordionItemComponent } from 'devextreme-angular/ui/accordion/nested';


/**
Expand Down Expand Up @@ -705,15 +708,27 @@ export class DxAccordionComponent<TItem = any, TKey = any> extends DxComponent i



@ContentChildren(DxiItemComponent)
get itemsChildren(): QueryList<DxiItemComponent> {
@ContentChildren(DxiAccordionItemComponent)
get itemsChildren(): QueryList<DxiAccordionItemComponent> {
return this._getOption('items');
}
set itemsChildren(value) {
this.setContentChildren('items', value, 'DxiAccordionItemComponent');
this.setChildren('items', value);
}


@ContentChildren(DxiItemComponent)
get itemsLegacyChildren(): QueryList<DxiItemComponent> {
return this._getOption('items');
}
set itemsLegacyChildren(value) {
if (this.checkContentChildren('items', value, 'DxiItemComponent')) {
this.setChildren('items', value);
}
}




constructor(elementRef: ElementRef, ngZone: NgZone, templateHost: DxTemplateHost,
Expand Down Expand Up @@ -817,6 +832,7 @@ export class DxAccordionComponent<TItem = any, TKey = any> extends DxComponent i
@NgModule({
imports: [
DxiItemModule,
DxiAccordionItemModule,
DxIntegrationModule,
DxTemplateModule
],
Expand All @@ -826,6 +842,7 @@ export class DxAccordionComponent<TItem = any, TKey = any> extends DxComponent i
exports: [
DxAccordionComponent,
DxiItemModule,
DxiAccordionItemModule,
DxTemplateModule
]
})
Expand Down
2 changes: 2 additions & 0 deletions packages/devextreme-angular/src/ui/accordion/nested/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './item-dxi';

143 changes: 143 additions & 0 deletions packages/devextreme-angular/src/ui/accordion/nested/item-dxi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
/* tslint:disable:max-line-length */


import {
Component,
NgModule,
Host,
ElementRef,
Renderer2,
Inject,
AfterViewInit,
SkipSelf,
Input
} from '@angular/core';

import { DOCUMENT } from '@angular/common';



import {
NestedOptionHost,
extractTemplate,
DxTemplateDirective,
IDxTemplateHost,
DxTemplateHost
} from 'devextreme-angular/core';
import { CollectionNestedOption } from 'devextreme-angular/core';


@Component({
selector: 'dxi-accordion-item',
template: '<ng-content></ng-content>',
styles: [':host { display: block; }'],
providers: [NestedOptionHost, DxTemplateHost]
})
export class DxiAccordionItemComponent extends CollectionNestedOption implements AfterViewInit,
IDxTemplateHost {
@Input()
get disabled(): boolean {
return this._getOption('disabled');
}
set disabled(value: boolean) {
this._setOption('disabled', value);
}

@Input()
get html(): string {
return this._getOption('html');
}
set html(value: string) {
this._setOption('html', value);
}

@Input()
get icon(): string {
return this._getOption('icon');
}
set icon(value: string) {
this._setOption('icon', value);
}

@Input()
get template(): any {
return this._getOption('template');
}
set template(value: any) {
this._setOption('template', value);
}

@Input()
get text(): string {
return this._getOption('text');
}
set text(value: string) {
this._setOption('text', value);
}

@Input()
get title(): string {
return this._getOption('title');
}
set title(value: string) {
this._setOption('title', value);
}

@Input()
get titleTemplate(): any {
return this._getOption('titleTemplate');
}
set titleTemplate(value: any) {
this._setOption('titleTemplate', value);
}

@Input()
get visible(): boolean {
return this._getOption('visible');
}
set visible(value: boolean) {
this._setOption('visible', value);
}


protected get _optionPath() {
return 'items';
}


constructor(@SkipSelf() @Host() parentOptionHost: NestedOptionHost,
@Host() optionHost: NestedOptionHost,
private renderer: Renderer2,
@Inject(DOCUMENT) private document: any,
@Host() templateHost: DxTemplateHost,
private element: ElementRef) {
super();
parentOptionHost.setNestedOption(this);
optionHost.setHost(this, this._fullOptionPath.bind(this));
templateHost.setHost(this);
}

setTemplate(template: DxTemplateDirective) {
this.template = template;
}
ngAfterViewInit() {
extractTemplate(this, this.element, this.renderer, this.document);
}



ngOnDestroy() {
this._deleteRemovedOptions(this._fullOptionPath());
}

}

@NgModule({
declarations: [
DxiAccordionItemComponent
],
exports: [
DxiAccordionItemComponent
],
})
export class DxiAccordionItemModule { }
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"lib": {
"entryFile": "index.ts"
}
}
21 changes: 19 additions & 2 deletions packages/devextreme-angular/src/ui/action-sheet/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,11 @@ import {

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

import { DxiActionSheetItemModule } from 'devextreme-angular/ui/action-sheet/nested';

import { DxiItemComponent } from 'devextreme-angular/ui/nested';

import { DxiActionSheetItemComponent } from 'devextreme-angular/ui/action-sheet/nested';


/**
Expand Down Expand Up @@ -499,15 +502,27 @@ export class DxActionSheetComponent<TItem = any, TKey = any> extends DxComponent



@ContentChildren(DxiItemComponent)
get itemsChildren(): QueryList<DxiItemComponent> {
@ContentChildren(DxiActionSheetItemComponent)
get itemsChildren(): QueryList<DxiActionSheetItemComponent> {
return this._getOption('items');
}
set itemsChildren(value) {
this.setContentChildren('items', value, 'DxiActionSheetItemComponent');
this.setChildren('items', value);
}


@ContentChildren(DxiItemComponent)
get itemsLegacyChildren(): QueryList<DxiItemComponent> {
return this._getOption('items');
}
set itemsLegacyChildren(value) {
if (this.checkContentChildren('items', value, 'DxiItemComponent')) {
this.setChildren('items', value);
}
}




constructor(elementRef: ElementRef, ngZone: NgZone, templateHost: DxTemplateHost,
Expand Down Expand Up @@ -596,6 +611,7 @@ export class DxActionSheetComponent<TItem = any, TKey = any> extends DxComponent
@NgModule({
imports: [
DxiItemModule,
DxiActionSheetItemModule,
DxIntegrationModule,
DxTemplateModule
],
Expand All @@ -605,6 +621,7 @@ export class DxActionSheetComponent<TItem = any, TKey = any> extends DxComponent
exports: [
DxActionSheetComponent,
DxiItemModule,
DxiActionSheetItemModule,
DxTemplateModule
]
})
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './item-dxi';

Loading

0 comments on commit 459dba5

Please sign in to comment.