From d053b821b58e8524cbbeb5360538678dcfa383d0 Mon Sep 17 00:00:00 2001 From: Dirk Van Haerenborgh Date: Fri, 9 Dec 2022 12:26:51 +0100 Subject: [PATCH] fix(echarts): make echarts tree-shakeable --- .../echarts/echarts-demos/bar/bar.module.ts | 8 ++- .../bar-demo-basic/bar-demo-basic.shared.ts | 5 +- .../bar/demos/bar-demo.module.ts | 5 +- .../combination/combination.module.ts | 5 +- .../demos/combination-demo.module.ts | 5 +- .../graph/demos/graph-demo.module.ts | 5 +- .../echarts-demos/graph/graph.module.ts | 5 +- .../line/demos/line-demo.module.ts | 5 +- .../echarts/echarts-demos/line/line.module.ts | 5 +- .../map-demo-basic/map-demo-basic.shared.ts | 5 +- .../map/demos/map-demo.module.ts | 5 +- .../pie/demos/pie-demo.module.ts | 5 +- .../echarts/echarts-demos/pie/pie.module.ts | 5 +- .../sankey/demos/sankey-demo.module.ts | 5 +- .../echarts-demos/sankey/sankey.module.ts | 5 +- .../scatter/demos/scatter-demo.module.ts | 5 +- .../echarts-demos/scatter/scatter.module.ts | 5 +- .../tree-demo-basic/tree-demo-basic.shared.ts | 5 +- .../tree/demos/tree-demo.module.ts | 5 +- .../echarts/echarts-demos/tree/tree.module.ts | 5 +- .../treemap/demos/treemap-demo.module.ts | 5 +- .../echarts-demos/treemap/treemap.module.ts | 5 +- .../wordcloud-demo.shared.ts | 5 +- .../wordcloud/demos/wordcloud-demo.module.ts | 5 +- libs/angular-echarts/base/src/base.module.ts | 24 ++++++- .../base/src/chart.component.ts | 19 ++++-- .../angular-echarts/base/src/utils/echarts.ts | 24 +++---- .../dynamic-menu/src/dynamic-menu.module.ts | 0 .../user-profile/src/user-profile.module.ts | 0 scripts/a11y/a11y.sh | 64 +++++++++++++++++++ scripts/precommit-schematics.sh | 22 +++++++ src/platform/core/schematics/migration.json | 10 +++ 32 files changed, 240 insertions(+), 46 deletions(-) mode change 100755 => 100644 libs/angular/dynamic-menu/src/dynamic-menu.module.ts mode change 100755 => 100644 libs/angular/user-profile/src/user-profile.module.ts create mode 100644 scripts/a11y/a11y.sh create mode 100644 scripts/precommit-schematics.sh create mode 100644 src/platform/core/schematics/migration.json diff --git a/apps/docs-app/src/app/content/echarts/echarts-demos/bar/bar.module.ts b/apps/docs-app/src/app/content/echarts/echarts-demos/bar/bar.module.ts index 2e3e5ca8d..81d1b02c8 100644 --- a/apps/docs-app/src/app/content/echarts/echarts-demos/bar/bar.module.ts +++ b/apps/docs-app/src/app/content/echarts/echarts-demos/bar/bar.module.ts @@ -7,7 +7,7 @@ import { MatIconModule } from '@angular/material/icon'; import { ComponentDetailsModule } from '../../../../components/shared/component-details/component-details.module'; -import { CovalentBaseEchartsModule } from '@covalent/echarts/base'; +import { CovalentBaseEchartsModule, TD_ECHARTS_CONFIG } from '@covalent/echarts/base'; import { CovalentLineEchartsModule } from '@covalent/echarts/line'; import { CovalentBarEchartsModule } from '@covalent/echarts/bar'; import { CovalentTooltipEchartsModule } from '@covalent/echarts/tooltip'; @@ -17,6 +17,8 @@ import { DocumentationToolsModule } from '../../../../documentation-tools'; import { BarBasicSharedModule } from './demos/bar-demo-basic/bar-demo-basic.shared'; import { BarDemoBasicComponent } from './demos/bar-demo-basic/bar-demo-basic.component'; +import * as echarts from 'echarts'; + const routes: Routes = setEchartRoutes({ overviewDemoComponent: BarDemoBasicComponent, id: 'bar', @@ -30,7 +32,9 @@ const routes: Routes = setEchartRoutes({ MatSelectModule, MatIconModule, // Covalent Echarts - CovalentBaseEchartsModule, + CovalentBaseEchartsModule.forRoot({ + echarts + }), CovalentLineEchartsModule, CovalentBarEchartsModule, CovalentTooltipEchartsModule, diff --git a/apps/docs-app/src/app/content/echarts/echarts-demos/bar/demos/bar-demo-basic/bar-demo-basic.shared.ts b/apps/docs-app/src/app/content/echarts/echarts-demos/bar/demos/bar-demo-basic/bar-demo-basic.shared.ts index 499d2df71..fb6a2eb13 100644 --- a/apps/docs-app/src/app/content/echarts/echarts-demos/bar/demos/bar-demo-basic/bar-demo-basic.shared.ts +++ b/apps/docs-app/src/app/content/echarts/echarts-demos/bar/demos/bar-demo-basic/bar-demo-basic.shared.ts @@ -9,12 +9,15 @@ import { CovalentBarEchartsModule } from '@covalent/echarts/bar'; import { CovalentTooltipEchartsModule } from '@covalent/echarts/tooltip'; import { CovalentToolboxEchartsModule } from '@covalent/echarts/toolbox'; import { BarDemoBasicComponent } from './bar-demo-basic.component'; +import * as echarts from 'echarts'; @NgModule({ declarations: [BarDemoBasicComponent], imports: [ /** Covalent Modules */ - CovalentBaseEchartsModule, + CovalentBaseEchartsModule.forRoot({ + echarts, + }), CovalentBarEchartsModule, CovalentTooltipEchartsModule, CovalentToolboxEchartsModule, diff --git a/apps/docs-app/src/app/content/echarts/echarts-demos/bar/demos/bar-demo.module.ts b/apps/docs-app/src/app/content/echarts/echarts-demos/bar/demos/bar-demo.module.ts index f00b2686c..29432be2b 100644 --- a/apps/docs-app/src/app/content/echarts/echarts-demos/bar/demos/bar-demo.module.ts +++ b/apps/docs-app/src/app/content/echarts/echarts-demos/bar/demos/bar-demo.module.ts @@ -14,6 +14,7 @@ import { BarBasicSharedModule } from './bar-demo-basic/bar-demo-basic.shared'; import { BarDemoComponent } from './bar-demo.component'; import { BarDemoRoutingModule } from './bar-demo-routing.module'; import { DemoModule } from '../../../../../components/shared/demo-tools/demo.module'; +import * as echarts from 'echarts'; @NgModule({ declarations: [BarDemoComponent], @@ -22,7 +23,9 @@ import { DemoModule } from '../../../../../components/shared/demo-tools/demo.mod DemoModule, BarDemoRoutingModule, /** Covalent Modules */ - CovalentBaseEchartsModule, + CovalentBaseEchartsModule.forRoot({ + echarts, + }), CovalentLineEchartsModule, CovalentBarEchartsModule, CovalentTooltipEchartsModule, diff --git a/apps/docs-app/src/app/content/echarts/echarts-demos/combination/combination.module.ts b/apps/docs-app/src/app/content/echarts/echarts-demos/combination/combination.module.ts index b19388e90..cd996e940 100644 --- a/apps/docs-app/src/app/content/echarts/echarts-demos/combination/combination.module.ts +++ b/apps/docs-app/src/app/content/echarts/echarts-demos/combination/combination.module.ts @@ -13,6 +13,7 @@ import { CovalentToolboxEchartsModule } from '@covalent/echarts/toolbox'; import { setEchartRoutes } from '../../echarts-content'; import { TypesCombinationComponent } from './combination.component'; import { DocumentationToolsModule } from '../../../../documentation-tools'; +import * as echarts from 'echarts'; const routes: Routes = setEchartRoutes({ overviewDemoComponent: TypesCombinationComponent, @@ -27,7 +28,9 @@ const routes: Routes = setEchartRoutes({ MatSelectModule, MatIconModule, // Covalent Echarts - CovalentBaseEchartsModule, + CovalentBaseEchartsModule.forRoot({ + echarts, + }), CovalentLineEchartsModule, CovalentBarEchartsModule, CovalentTooltipEchartsModule, diff --git a/apps/docs-app/src/app/content/echarts/echarts-demos/combination/demos/combination-demo.module.ts b/apps/docs-app/src/app/content/echarts/echarts-demos/combination/demos/combination-demo.module.ts index 1a5fccc33..2021d1b5a 100644 --- a/apps/docs-app/src/app/content/echarts/echarts-demos/combination/demos/combination-demo.module.ts +++ b/apps/docs-app/src/app/content/echarts/echarts-demos/combination/demos/combination-demo.module.ts @@ -14,6 +14,7 @@ import { CombinationDemoBasicComponent } from './combination-demo-basic/combinat import { CombinationDemoComponent } from './combination-demo.component'; import { CombinationDemoRoutingModule } from './combination-demo-routing.module'; import { DemoModule } from '../../../../../components/shared/demo-tools/demo.module'; +import * as echarts from 'echarts'; @NgModule({ declarations: [CombinationDemoComponent, CombinationDemoBasicComponent], @@ -21,7 +22,9 @@ import { DemoModule } from '../../../../../components/shared/demo-tools/demo.mod DemoModule, CombinationDemoRoutingModule, /** Covalent Modules */ - CovalentBaseEchartsModule, + CovalentBaseEchartsModule.forRoot({ + echarts, + }), CovalentLineEchartsModule, CovalentBarEchartsModule, CovalentTooltipEchartsModule, diff --git a/apps/docs-app/src/app/content/echarts/echarts-demos/graph/demos/graph-demo.module.ts b/apps/docs-app/src/app/content/echarts/echarts-demos/graph/demos/graph-demo.module.ts index eca04c7ac..1aeeb3bc7 100644 --- a/apps/docs-app/src/app/content/echarts/echarts-demos/graph/demos/graph-demo.module.ts +++ b/apps/docs-app/src/app/content/echarts/echarts-demos/graph/demos/graph-demo.module.ts @@ -13,6 +13,7 @@ import { GraphDemoBasicComponent } from './graph-demo-basic/graph-demo-basic.com import { GraphDemoComponent } from './graph-demo.component'; import { GraphDemoRoutingModule } from './graph-demo-routing.module'; import { CovalentGraphEchartsModule } from '@covalent/echarts/graph'; +import * as echarts from 'echarts'; @NgModule({ declarations: [GraphDemoBasicComponent, GraphDemoComponent], @@ -20,7 +21,9 @@ import { CovalentGraphEchartsModule } from '@covalent/echarts/graph'; DemoModule, GraphDemoRoutingModule, /** Covalent Modules */ - CovalentBaseEchartsModule, + CovalentBaseEchartsModule.forRoot({ + echarts, + }), CovalentTooltipEchartsModule, CovalentToolboxEchartsModule, CovalentGraphEchartsModule, diff --git a/apps/docs-app/src/app/content/echarts/echarts-demos/graph/graph.module.ts b/apps/docs-app/src/app/content/echarts/echarts-demos/graph/graph.module.ts index 3e4bb9c77..ca622a98f 100644 --- a/apps/docs-app/src/app/content/echarts/echarts-demos/graph/graph.module.ts +++ b/apps/docs-app/src/app/content/echarts/echarts-demos/graph/graph.module.ts @@ -12,6 +12,7 @@ import { CovalentTooltipEchartsModule } from '@covalent/echarts/tooltip'; import { setEchartRoutes } from '../../echarts-content'; import { DocumentationToolsModule } from '../../../../documentation-tools'; import { TypesGraphComponent } from './graph.component'; +import * as echarts from 'echarts'; const routes: Routes = setEchartRoutes({ overviewDemoComponent: TypesGraphComponent, @@ -26,7 +27,9 @@ const routes: Routes = setEchartRoutes({ MatSelectModule, MatIconModule, // Covalent Echarts - CovalentBaseEchartsModule, + CovalentBaseEchartsModule.forRoot({ + echarts, + }), CovalentGraphEchartsModule, CovalentTooltipEchartsModule, // Docs diff --git a/apps/docs-app/src/app/content/echarts/echarts-demos/line/demos/line-demo.module.ts b/apps/docs-app/src/app/content/echarts/echarts-demos/line/demos/line-demo.module.ts index 16bacbdf2..930b27b4f 100644 --- a/apps/docs-app/src/app/content/echarts/echarts-demos/line/demos/line-demo.module.ts +++ b/apps/docs-app/src/app/content/echarts/echarts-demos/line/demos/line-demo.module.ts @@ -13,6 +13,7 @@ import { LineDemoComponent } from './line-demo.component'; import { LineDemoRoutingModule } from './line-demo-routing.module'; import { LineDemoBasicComponent } from './line-demo-basic/line-demo-basic.component'; import { CovalentLineEchartsModule } from '@covalent/echarts/line'; +import * as echarts from 'echarts'; @NgModule({ declarations: [LineDemoComponent, LineDemoBasicComponent], @@ -20,7 +21,9 @@ import { CovalentLineEchartsModule } from '@covalent/echarts/line'; DemoModule, LineDemoRoutingModule, /** Covalent Modules */ - CovalentBaseEchartsModule, + CovalentBaseEchartsModule.forRoot({ + echarts, + }), CovalentTooltipEchartsModule, CovalentToolboxEchartsModule, CovalentLineEchartsModule, diff --git a/apps/docs-app/src/app/content/echarts/echarts-demos/line/line.module.ts b/apps/docs-app/src/app/content/echarts/echarts-demos/line/line.module.ts index a808ffcd2..95ecdca40 100644 --- a/apps/docs-app/src/app/content/echarts/echarts-demos/line/line.module.ts +++ b/apps/docs-app/src/app/content/echarts/echarts-demos/line/line.module.ts @@ -11,6 +11,7 @@ import { CovalentTooltipEchartsModule } from '@covalent/echarts/tooltip'; import { setEchartRoutes } from '../../echarts-content'; import { DocumentationToolsModule } from '../../../../documentation-tools'; import { TypesLineComponent } from './line.component'; +import * as echarts from 'echarts'; const routes: Routes = setEchartRoutes({ overviewDemoComponent: TypesLineComponent, @@ -25,7 +26,9 @@ const routes: Routes = setEchartRoutes({ MatSelectModule, MatIconModule, // Covalent Echarts - CovalentBaseEchartsModule, + CovalentBaseEchartsModule.forRoot({ + echarts, + }), CovalentLineEchartsModule, CovalentTooltipEchartsModule, // Docs diff --git a/apps/docs-app/src/app/content/echarts/echarts-demos/map/demos/map-demo-basic/map-demo-basic.shared.ts b/apps/docs-app/src/app/content/echarts/echarts-demos/map/demos/map-demo-basic/map-demo-basic.shared.ts index 882d78116..c02b053b0 100644 --- a/apps/docs-app/src/app/content/echarts/echarts-demos/map/demos/map-demo-basic/map-demo-basic.shared.ts +++ b/apps/docs-app/src/app/content/echarts/echarts-demos/map/demos/map-demo-basic/map-demo-basic.shared.ts @@ -5,12 +5,15 @@ import { CovalentBaseEchartsModule } from '@covalent/echarts/base'; import { CovalentTooltipEchartsModule } from '@covalent/echarts/tooltip'; import { MapDemoBasicComponent } from './map-demo-basic.component'; import { CovalentMapEchartsModule } from '@covalent/echarts/map'; +import * as echarts from 'echarts'; @NgModule({ declarations: [MapDemoBasicComponent], imports: [ /** Covalent Modules */ - CovalentBaseEchartsModule, + CovalentBaseEchartsModule.forRoot({ + echarts, + }), CovalentMapEchartsModule, CovalentTooltipEchartsModule, /** Angular Modules */ diff --git a/apps/docs-app/src/app/content/echarts/echarts-demos/map/demos/map-demo.module.ts b/apps/docs-app/src/app/content/echarts/echarts-demos/map/demos/map-demo.module.ts index 92857cefb..725e08773 100644 --- a/apps/docs-app/src/app/content/echarts/echarts-demos/map/demos/map-demo.module.ts +++ b/apps/docs-app/src/app/content/echarts/echarts-demos/map/demos/map-demo.module.ts @@ -14,6 +14,7 @@ import { MapDemoRoutingModule } from './map-demo-routing.module'; import { DemoModule } from '../../../../../components/shared/demo-tools/demo.module'; import { CovalentMapEchartsModule } from '@covalent/echarts/map'; import { MapBasicSharedModule } from './map-demo-basic/map-demo-basic.shared'; +import * as echarts from 'echarts'; @NgModule({ declarations: [MapDemoComponent], @@ -22,7 +23,9 @@ import { MapBasicSharedModule } from './map-demo-basic/map-demo-basic.shared'; DemoModule, MapDemoRoutingModule, /** Covalent Modules */ - CovalentBaseEchartsModule, + CovalentBaseEchartsModule.forRoot({ + echarts, + }), CovalentLineEchartsModule, CovalentMapEchartsModule, CovalentTooltipEchartsModule, diff --git a/apps/docs-app/src/app/content/echarts/echarts-demos/pie/demos/pie-demo.module.ts b/apps/docs-app/src/app/content/echarts/echarts-demos/pie/demos/pie-demo.module.ts index 43b622964..e973c2cc4 100644 --- a/apps/docs-app/src/app/content/echarts/echarts-demos/pie/demos/pie-demo.module.ts +++ b/apps/docs-app/src/app/content/echarts/echarts-demos/pie/demos/pie-demo.module.ts @@ -13,6 +13,7 @@ import { CovalentPieEchartsModule } from '@covalent/echarts/pie'; import { PieDemoBasicComponent } from './pie-demo-basic/pie-demo-basic.component'; import { PieDemoComponent } from './pie-demo.component'; import { PieDemoRoutingModule } from './pie-demo-routing.module'; +import * as echarts from 'echarts'; @NgModule({ declarations: [PieDemoBasicComponent, PieDemoComponent], @@ -20,7 +21,9 @@ import { PieDemoRoutingModule } from './pie-demo-routing.module'; DemoModule, PieDemoRoutingModule, /** Covalent Modules */ - CovalentBaseEchartsModule, + CovalentBaseEchartsModule.forRoot({ + echarts, + }), CovalentTooltipEchartsModule, CovalentToolboxEchartsModule, CovalentPieEchartsModule, diff --git a/apps/docs-app/src/app/content/echarts/echarts-demos/pie/pie.module.ts b/apps/docs-app/src/app/content/echarts/echarts-demos/pie/pie.module.ts index b1257351e..482e1f82e 100644 --- a/apps/docs-app/src/app/content/echarts/echarts-demos/pie/pie.module.ts +++ b/apps/docs-app/src/app/content/echarts/echarts-demos/pie/pie.module.ts @@ -12,6 +12,7 @@ import { CovalentPieEchartsModule } from '@covalent/echarts/pie'; import { setEchartRoutes } from '../../echarts-content'; import { DocumentationToolsModule } from '../../../../documentation-tools'; import { TypesPieComponent } from './pie.component'; +import * as echarts from 'echarts'; const routes: Routes = setEchartRoutes({ overviewDemoComponent: TypesPieComponent, @@ -26,7 +27,9 @@ const routes: Routes = setEchartRoutes({ MatSelectModule, MatIconModule, // Covalent Echarts - CovalentBaseEchartsModule, + CovalentBaseEchartsModule.forRoot({ + echarts, + }), CovalentPieEchartsModule, CovalentTooltipEchartsModule, CovalentToolboxEchartsModule, diff --git a/apps/docs-app/src/app/content/echarts/echarts-demos/sankey/demos/sankey-demo.module.ts b/apps/docs-app/src/app/content/echarts/echarts-demos/sankey/demos/sankey-demo.module.ts index 92afde230..3865dc32a 100644 --- a/apps/docs-app/src/app/content/echarts/echarts-demos/sankey/demos/sankey-demo.module.ts +++ b/apps/docs-app/src/app/content/echarts/echarts-demos/sankey/demos/sankey-demo.module.ts @@ -13,6 +13,7 @@ import { SankeyDemoBasicComponent } from './sankey-demo-basic/sankey-demo-basic. import { SankeyDemoComponent } from './sankey-demo.component'; import { SankeyDemoRoutingModule } from './sankey-demo-routing.module'; import { CovalentSankeyEchartsModule } from '@covalent/echarts/sankey'; +import * as echarts from 'echarts'; @NgModule({ declarations: [SankeyDemoBasicComponent, SankeyDemoComponent], @@ -20,7 +21,9 @@ import { CovalentSankeyEchartsModule } from '@covalent/echarts/sankey'; DemoModule, SankeyDemoRoutingModule, /** Covalent Modules */ - CovalentBaseEchartsModule, + CovalentBaseEchartsModule.forRoot({ + echarts, + }), CovalentTooltipEchartsModule, CovalentToolboxEchartsModule, CovalentSankeyEchartsModule, diff --git a/apps/docs-app/src/app/content/echarts/echarts-demos/sankey/sankey.module.ts b/apps/docs-app/src/app/content/echarts/echarts-demos/sankey/sankey.module.ts index 5ffa6e02c..3788f838a 100644 --- a/apps/docs-app/src/app/content/echarts/echarts-demos/sankey/sankey.module.ts +++ b/apps/docs-app/src/app/content/echarts/echarts-demos/sankey/sankey.module.ts @@ -11,6 +11,7 @@ import { CovalentSankeyEchartsModule } from '@covalent/echarts/sankey'; import { setEchartRoutes } from '../../echarts-content'; import { DocumentationToolsModule } from '../../../../documentation-tools'; import { TypesSankeyComponent } from './sankey.component'; +import * as echarts from 'echarts'; const routes: Routes = setEchartRoutes({ overviewDemoComponent: TypesSankeyComponent, @@ -25,7 +26,9 @@ const routes: Routes = setEchartRoutes({ MatSelectModule, MatIconModule, // Covalent Echarts - CovalentBaseEchartsModule, + CovalentBaseEchartsModule.forRoot({ + echarts, + }), CovalentSankeyEchartsModule, CovalentTooltipEchartsModule, // Docs diff --git a/apps/docs-app/src/app/content/echarts/echarts-demos/scatter/demos/scatter-demo.module.ts b/apps/docs-app/src/app/content/echarts/echarts-demos/scatter/demos/scatter-demo.module.ts index 59f865dad..61ccc0fbd 100644 --- a/apps/docs-app/src/app/content/echarts/echarts-demos/scatter/demos/scatter-demo.module.ts +++ b/apps/docs-app/src/app/content/echarts/echarts-demos/scatter/demos/scatter-demo.module.ts @@ -13,6 +13,7 @@ import { ScatterDemoBasicComponent } from './scatter-demo-basic/scatter-demo-bas import { ScatterDemoComponent } from './scatter-demo.component'; import { ScatterDemoRoutingModule } from './scatter-demo-routing.module'; import { DemoModule } from '../../../../../components/shared/demo-tools/demo.module'; +import * as echarts from 'echarts'; @NgModule({ declarations: [ScatterDemoComponent, ScatterDemoBasicComponent], @@ -20,7 +21,9 @@ import { DemoModule } from '../../../../../components/shared/demo-tools/demo.mod DemoModule, ScatterDemoRoutingModule, /** Covalent Modules */ - CovalentBaseEchartsModule, + CovalentBaseEchartsModule.forRoot({ + echarts, + }), CovalentTooltipEchartsModule, CovalentToolboxEchartsModule, CovalentScatterEchartsModule, diff --git a/apps/docs-app/src/app/content/echarts/echarts-demos/scatter/scatter.module.ts b/apps/docs-app/src/app/content/echarts/echarts-demos/scatter/scatter.module.ts index 54dafe261..77beaf5f6 100644 --- a/apps/docs-app/src/app/content/echarts/echarts-demos/scatter/scatter.module.ts +++ b/apps/docs-app/src/app/content/echarts/echarts-demos/scatter/scatter.module.ts @@ -11,6 +11,7 @@ import { CovalentScatterEchartsModule } from '@covalent/echarts/scatter'; import { setEchartRoutes } from '../../echarts-content'; import { DocumentationToolsModule } from '../../../../documentation-tools'; import { TypesScatterComponent } from './scatter.component'; +import * as echarts from 'echarts'; const routes: Routes = setEchartRoutes({ overviewDemoComponent: TypesScatterComponent, @@ -25,7 +26,9 @@ const routes: Routes = setEchartRoutes({ MatSelectModule, MatIconModule, // Covalent Echarts - CovalentBaseEchartsModule, + CovalentBaseEchartsModule.forRoot({ + echarts, + }), CovalentScatterEchartsModule, CovalentTooltipEchartsModule, // Docs diff --git a/apps/docs-app/src/app/content/echarts/echarts-demos/tree/demos/tree-demo-basic/tree-demo-basic.shared.ts b/apps/docs-app/src/app/content/echarts/echarts-demos/tree/demos/tree-demo-basic/tree-demo-basic.shared.ts index b729931f3..ee074c0dc 100644 --- a/apps/docs-app/src/app/content/echarts/echarts-demos/tree/demos/tree-demo-basic/tree-demo-basic.shared.ts +++ b/apps/docs-app/src/app/content/echarts/echarts-demos/tree/demos/tree-demo-basic/tree-demo-basic.shared.ts @@ -10,12 +10,15 @@ import { CovalentToolboxEchartsModule } from '@covalent/echarts/toolbox'; import { CovalentTreeEchartsModule } from '@covalent/echarts/tree'; import { TreeDemoBasicComponent } from './tree-demo-basic.component'; +import * as echarts from 'echarts'; @NgModule({ declarations: [TreeDemoBasicComponent], imports: [ /** Covalent Modules */ - CovalentBaseEchartsModule, + CovalentBaseEchartsModule.forRoot({ + echarts, + }), CovalentTooltipEchartsModule, CovalentToolboxEchartsModule, CovalentTreeEchartsModule, diff --git a/apps/docs-app/src/app/content/echarts/echarts-demos/tree/demos/tree-demo.module.ts b/apps/docs-app/src/app/content/echarts/echarts-demos/tree/demos/tree-demo.module.ts index 1a91044f5..e743b16b4 100644 --- a/apps/docs-app/src/app/content/echarts/echarts-demos/tree/demos/tree-demo.module.ts +++ b/apps/docs-app/src/app/content/echarts/echarts-demos/tree/demos/tree-demo.module.ts @@ -13,6 +13,7 @@ import { TreeDemoComponent } from './tree-demo.component'; import { TreeDemoRoutingModule } from './tree-demo-routing.module'; import { DemoModule } from '../../../../../components/shared/demo-tools/demo.module'; import { TreeBasicSharedModule } from './tree-demo-basic/tree-demo-basic.shared'; +import * as echarts from 'echarts'; @NgModule({ declarations: [TreeDemoComponent], @@ -21,7 +22,9 @@ import { TreeBasicSharedModule } from './tree-demo-basic/tree-demo-basic.shared' DemoModule, TreeDemoRoutingModule, /** Covalent Modules */ - CovalentBaseEchartsModule, + CovalentBaseEchartsModule.forRoot({ + echarts, + }), CovalentTooltipEchartsModule, CovalentToolboxEchartsModule, CovalentTreeEchartsModule, diff --git a/apps/docs-app/src/app/content/echarts/echarts-demos/tree/tree.module.ts b/apps/docs-app/src/app/content/echarts/echarts-demos/tree/tree.module.ts index 2500af502..daffc92d0 100644 --- a/apps/docs-app/src/app/content/echarts/echarts-demos/tree/tree.module.ts +++ b/apps/docs-app/src/app/content/echarts/echarts-demos/tree/tree.module.ts @@ -12,6 +12,7 @@ import { DocumentationToolsModule } from '../../../../documentation-tools'; import { TreeBasicSharedModule } from './demos/tree-demo-basic/tree-demo-basic.shared'; import { TreeDemoBasicComponent } from './demos/tree-demo-basic/tree-demo-basic.component'; import { ComponentDetailsModule } from '../../../../components/shared/component-details/component-details.module'; +import * as echarts from 'echarts'; const routes: Routes = setEchartRoutes({ overviewDemoComponent: TreeDemoBasicComponent, @@ -26,7 +27,9 @@ const routes: Routes = setEchartRoutes({ MatSelectModule, MatIconModule, // Covalent Echarts - CovalentBaseEchartsModule, + CovalentBaseEchartsModule.forRoot({ + echarts, + }), CovalentTreeEchartsModule, CovalentTooltipEchartsModule, // Docs diff --git a/apps/docs-app/src/app/content/echarts/echarts-demos/treemap/demos/treemap-demo.module.ts b/apps/docs-app/src/app/content/echarts/echarts-demos/treemap/demos/treemap-demo.module.ts index aea248aa9..05cb10474 100644 --- a/apps/docs-app/src/app/content/echarts/echarts-demos/treemap/demos/treemap-demo.module.ts +++ b/apps/docs-app/src/app/content/echarts/echarts-demos/treemap/demos/treemap-demo.module.ts @@ -13,6 +13,7 @@ import { TreemapDemoBasicComponent } from './treemap-demo-basic/treemap-demo-bas import { TreemapDemoComponent } from './treemap-demo.component'; import { TreemapDemoRoutingModule } from './treemap-demo-routing.module'; import { DemoModule } from '../../../../../components/shared/demo-tools/demo.module'; +import * as echarts from 'echarts'; @NgModule({ declarations: [TreemapDemoComponent, TreemapDemoBasicComponent], @@ -20,7 +21,9 @@ import { DemoModule } from '../../../../../components/shared/demo-tools/demo.mod DemoModule, TreemapDemoRoutingModule, /** Covalent Modules */ - CovalentBaseEchartsModule, + CovalentBaseEchartsModule.forRoot({ + echarts, + }), CovalentTooltipEchartsModule, CovalentToolboxEchartsModule, CovalentTreemapEchartsModule, diff --git a/apps/docs-app/src/app/content/echarts/echarts-demos/treemap/treemap.module.ts b/apps/docs-app/src/app/content/echarts/echarts-demos/treemap/treemap.module.ts index f04a0c88c..f656ea9aa 100644 --- a/apps/docs-app/src/app/content/echarts/echarts-demos/treemap/treemap.module.ts +++ b/apps/docs-app/src/app/content/echarts/echarts-demos/treemap/treemap.module.ts @@ -11,6 +11,7 @@ import { CovalentTreemapEchartsModule } from '@covalent/echarts/treemap'; import { setEchartRoutes } from '../../echarts-content'; import { DocumentationToolsModule } from '../../../../documentation-tools'; import { TypesTreemapComponent } from './treemap.component'; +import * as echarts from 'echarts'; const routes: Routes = setEchartRoutes({ overviewDemoComponent: TypesTreemapComponent, @@ -25,7 +26,9 @@ const routes: Routes = setEchartRoutes({ MatSelectModule, MatIconModule, // Covalent Echarts - CovalentBaseEchartsModule, + CovalentBaseEchartsModule.forRoot({ + echarts, + }), CovalentTreemapEchartsModule, CovalentTooltipEchartsModule, // Docs diff --git a/apps/docs-app/src/app/content/echarts/echarts-demos/wordcloud/demos/wordcloud-demo-basic/wordcloud-demo.shared.ts b/apps/docs-app/src/app/content/echarts/echarts-demos/wordcloud/demos/wordcloud-demo-basic/wordcloud-demo.shared.ts index 50d551d50..02f7b1ec5 100644 --- a/apps/docs-app/src/app/content/echarts/echarts-demos/wordcloud/demos/wordcloud-demo-basic/wordcloud-demo.shared.ts +++ b/apps/docs-app/src/app/content/echarts/echarts-demos/wordcloud/demos/wordcloud-demo-basic/wordcloud-demo.shared.ts @@ -5,12 +5,15 @@ import { CovalentBaseEchartsModule } from '@covalent/echarts/base'; import { CovalentTooltipEchartsModule } from '@covalent/echarts/tooltip'; import { WordcloudDemoBasicComponent } from './wordcloud-demo-basic.component'; import { CovalentWordcloudEchartsModule } from '@covalent/echarts/wordcloud'; +import * as echarts from 'echarts'; @NgModule({ declarations: [WordcloudDemoBasicComponent], imports: [ /** Covalent Modules */ - CovalentBaseEchartsModule, + CovalentBaseEchartsModule.forRoot({ + echarts, + }), CovalentTooltipEchartsModule, CovalentWordcloudEchartsModule, /** Angular Modules */ diff --git a/apps/docs-app/src/app/content/echarts/echarts-demos/wordcloud/demos/wordcloud-demo.module.ts b/apps/docs-app/src/app/content/echarts/echarts-demos/wordcloud/demos/wordcloud-demo.module.ts index 22e74b8e0..b4046dbb4 100644 --- a/apps/docs-app/src/app/content/echarts/echarts-demos/wordcloud/demos/wordcloud-demo.module.ts +++ b/apps/docs-app/src/app/content/echarts/echarts-demos/wordcloud/demos/wordcloud-demo.module.ts @@ -14,6 +14,7 @@ import { WordcloudDemoRoutingModule } from './wordcloud-demo-routing.module'; import { DemoModule } from '../../../../../components/shared/demo-tools/demo.module'; import { CovalentWordcloudEchartsModule } from '@covalent/echarts/wordcloud'; import { WordcloudDemoSharedModule } from './wordcloud-demo-basic/wordcloud-demo.shared'; +import * as echarts from 'echarts'; @NgModule({ declarations: [WordcloudDemoComponent], @@ -22,7 +23,9 @@ import { WordcloudDemoSharedModule } from './wordcloud-demo-basic/wordcloud-demo DemoModule, WordcloudDemoRoutingModule, /** Covalent Modules */ - CovalentBaseEchartsModule, + CovalentBaseEchartsModule.forRoot({ + echarts, + }), CovalentLineEchartsModule, CovalentWordcloudEchartsModule, CovalentTooltipEchartsModule, diff --git a/libs/angular-echarts/base/src/base.module.ts b/libs/angular-echarts/base/src/base.module.ts index 2910edbf3..26bfae06b 100644 --- a/libs/angular-echarts/base/src/base.module.ts +++ b/libs/angular-echarts/base/src/base.module.ts @@ -1,4 +1,4 @@ -import { NgModule, Type } from '@angular/core'; +import { InjectionToken, ModuleWithProviders, NgModule, Type } from '@angular/core'; import { CommonModule } from '@angular/common'; import { TdChartComponent } from './chart.component'; @@ -15,11 +15,29 @@ export const BASE_MODULE_COMPONENTS: Type[] = [ TdDatasetComponent, ]; -registerDefaultThemes(); +export interface TdEchartsConfig { + echarts: typeof echarts; + defaultThemes?: boolean; +} + +export const TD_ECHARTS_CONFIG = new InjectionToken('TD_ECHARTS_CONFIG'); + +import 'zrender/lib/svg/svg'; @NgModule({ imports: [CommonModule], declarations: [BASE_MODULE_COMPONENTS], exports: [BASE_MODULE_COMPONENTS], }) -export class CovalentBaseEchartsModule {} +export class CovalentBaseEchartsModule { + static forRoot(config: TdEchartsConfig): ModuleWithProviders { + if (config.defaultThemes !== false) { + registerDefaultThemes(config.echarts); + } + + return { + ngModule: CovalentBaseEchartsModule, + providers: [{ provide: TD_ECHARTS_CONFIG, useValue: config }], + }; + } +} diff --git a/libs/angular-echarts/base/src/chart.component.ts b/libs/angular-echarts/base/src/chart.component.ts index c2873bb37..4308ef00e 100644 --- a/libs/angular-echarts/base/src/chart.component.ts +++ b/libs/angular-echarts/base/src/chart.component.ts @@ -10,6 +10,7 @@ import { OnChanges, OnDestroy, SimpleChanges, + Inject, } from '@angular/core'; import { Subject, fromEvent, merge, timer } from 'rxjs'; @@ -22,6 +23,8 @@ import { import { TdChartOptionsService, CHART_PROVIDER } from './chart-options.service'; import { assignDefined } from './utils'; +import { TdEchartsConfig, TD_ECHARTS_CONFIG } from './base.module'; +import { ECharts } from 'echarts'; @Component({ selector: 'td-chart', @@ -35,12 +38,13 @@ export class TdChartComponent implements AfterViewInit, OnChanges, OnDestroy { private _widthSubject: Subject = new Subject(); private _heightSubject: Subject = new Subject(); - private _instance: any; + private _instance?: ECharts; + private _echarts: typeof echarts; /** * returns the echarts instance */ - get instance(): any { + get instance(): ECharts | undefined { return this._instance; } @@ -88,8 +92,11 @@ export class TdChartComponent implements AfterViewInit, OnChanges, OnDestroy { constructor( private _changeDetectorRef: ChangeDetectorRef, private _elementRef: ElementRef, - private _optionsService: TdChartOptionsService - ) {} + private _optionsService: TdChartOptionsService, + @Inject(TD_ECHARTS_CONFIG) private _config: TdEchartsConfig + ) { + this._echarts = _config.echarts || (window as any).echarts; + } ngAfterViewInit(): void { this._initializeChart(); @@ -149,7 +156,7 @@ export class TdChartComponent implements AfterViewInit, OnChanges, OnDestroy { } private _initializeChart(): void { - this._instance = echarts.init( + this._instance = this._echarts.init( this._elementRef.nativeElement, this.themeName ?? '', { @@ -193,7 +200,7 @@ export class TdChartComponent implements AfterViewInit, OnChanges, OnDestroy { }); if (this.group) { this._instance.group = this.group; - echarts.connect(this.group); + this._echarts.connect(this.group); this._changeDetectorRef.markForCheck(); } merge( diff --git a/libs/angular-echarts/base/src/utils/echarts.ts b/libs/angular-echarts/base/src/utils/echarts.ts index 47a9ba309..758eedaf5 100644 --- a/libs/angular-echarts/base/src/utils/echarts.ts +++ b/libs/angular-echarts/base/src/utils/echarts.ts @@ -13,24 +13,24 @@ import volcanicEruption from '../themes/volcanic-eruption'; * Theme name and theme object needed as stated in * https://ecomfe.github.io/echarts-doc/public/en/api.html#echarts.registerTheme */ -export function registerTheme(themeName: string, theme: object): void { - echarts.registerTheme(themeName, theme); +export function registerTheme(echartsLibrary: typeof echarts, themeName: string, theme: object): void { + echartsLibrary.registerTheme(themeName, theme); } /** * Function to register all default themes * @internal */ -export function registerDefaultThemes(): void { - registerTheme('aqua-splash', aquaSplash); - registerTheme('california-coast', californiaCoast); - registerTheme('hawaiian-sunrise', hawaiianSunrise); - registerTheme('passion-flower', passionFlower); - registerTheme('razzleberry-pie', razzleberryPie); - registerTheme('teradata-classic', teradataClassic); - registerTheme('teradata-default', teradataDefault); - registerTheme('urban-sunrise', urbanSunrise); - registerTheme('volcanic-eruption', volcanicEruption); +export function registerDefaultThemes(echartsLibrary: typeof echarts): void { + registerTheme(echartsLibrary, 'aqua-splash', aquaSplash); + registerTheme(echartsLibrary, 'california-coast', californiaCoast); + registerTheme(echartsLibrary, 'hawaiian-sunrise', hawaiianSunrise); + registerTheme(echartsLibrary, 'passion-flower', passionFlower); + registerTheme(echartsLibrary, 'razzleberry-pie', razzleberryPie); + registerTheme(echartsLibrary, 'teradata-classic', teradataClassic); + registerTheme(echartsLibrary, 'teradata-default', teradataDefault); + registerTheme(echartsLibrary, 'urban-sunrise', urbanSunrise); + registerTheme(echartsLibrary, 'volcanic-eruption', volcanicEruption); } /** diff --git a/libs/angular/dynamic-menu/src/dynamic-menu.module.ts b/libs/angular/dynamic-menu/src/dynamic-menu.module.ts old mode 100755 new mode 100644 diff --git a/libs/angular/user-profile/src/user-profile.module.ts b/libs/angular/user-profile/src/user-profile.module.ts old mode 100755 new mode 100644 diff --git a/scripts/a11y/a11y.sh b/scripts/a11y/a11y.sh new file mode 100644 index 000000000..0a584d853 --- /dev/null +++ b/scripts/a11y/a11y.sh @@ -0,0 +1,64 @@ +#!/bin/bash + +# Set a number of loops before timing out. +LIMIT=20 + +# Time to wait before re-checking +SLEEP=10 + +# Initialize the timeout variable +timeout=0 + +# Function to wait for ng serve to finish. +wait_for() { + until curl -sf "$1" + do + if [ $timeout -eq $LIMIT ]; then + echo -e "\nBuild timed out.\n" + kill $NPM_PID + exit 1 + fi + echo -e "\nWaiting for $1...\n" + sleep $SLEEP + timeout=$((timeout + 1)) + done + echo "" +} + +# Reset in case getopts has been used previously in the shell. +OPTIND=1 + +# Initialize our own variables: +routes="routes.txt" +server="localhost:4200" + +# Get command line args +while getopts "r:s:" opt; do + case "$opt" in + r) routes=$OPTARG + ;; + s) server=$OPTARG + ;; + esac +done + +shift $((OPTIND-1)) + +[ "$1" = "--" ] && shift + +# Run ng serve in the background and save the process ID. +npm run serve & +NPM_PID=$! + +# wait for the server to return. +wait_for $server + +# iterate over routes and pa11y them. +for route in $(cat ${routes}); +do + route=$(echo $route|tr -d '\n') + ./node_modules/.bin/pa11y ${server}/\#/${route}; +done + +# stop the ng server process. +kill $NPM_PID diff --git a/scripts/precommit-schematics.sh b/scripts/precommit-schematics.sh new file mode 100644 index 000000000..0aff9ebf7 --- /dev/null +++ b/scripts/precommit-schematics.sh @@ -0,0 +1,22 @@ +# Run test and linter +npm run test:schematics +npm run tslint +npm run build:lib + +# Link project +cd ../deploy/platform/core +npm link + +# Create Angular base project +cd /tmp +rm -rf testxyz +ng new testxyz + +# Run covalent schematics +cd testxyz +npm link @covalent/core +ng g @covalent/core:ng-add + +# Check generated files +git status +npm ci diff --git a/src/platform/core/schematics/migration.json b/src/platform/core/schematics/migration.json new file mode 100644 index 000000000..e812649cb --- /dev/null +++ b/src/platform/core/schematics/migration.json @@ -0,0 +1,10 @@ +{ + "$schema": "../../../../node_modules/@angular-devkit/schematics/collection-schema.json", + "schematics": { + "migration-v3": { + "version": "3.0.0", + "description": "Updates Covalent to v3", + "factory": "./ng-update/index#updateToV3" + } + } +}