diff --git a/angular.json b/angular.json index c8aba8d..ca56ab8 100644 --- a/angular.json +++ b/angular.json @@ -20,7 +20,9 @@ "outputPath": "dist/angular-material-date-fns-adapter", "index": "src/index.html", "main": "src/main.ts", - "polyfills": "src/polyfills.ts", + "polyfills": [ + "zone.js" + ], "tsConfig": "tsconfig.app.json", "inlineStyleLanguage": "scss", "assets": [ @@ -86,10 +88,11 @@ "test": { "builder": "@angular-devkit/build-angular:karma", "options": { - "main": "src/test.ts", - "polyfills": "src/polyfills.ts", + "polyfills": [ + "zone.js", + "zone.js/testing" + ], "tsConfig": "tsconfig.spec.json", - "karmaConfig": "karma.conf.js", "inlineStyleLanguage": "scss", "assets": [ "src/favicon.ico", @@ -127,9 +130,11 @@ "test": { "builder": "@angular-devkit/build-angular:karma", "options": { - "main": "projects/ngx-material-date-fns-adapter/src/test.ts", - "tsConfig": "projects/ngx-material-date-fns-adapter/tsconfig.spec.json", - "karmaConfig": "projects/ngx-material-date-fns-adapter/karma.conf.js" + "polyfills": [ + "zone.js", + "zone.js/testing" + ], + "tsConfig": "projects/ngx-material-date-fns-adapter/tsconfig.spec.json" } } } diff --git a/karma.conf.js b/karma.conf.js deleted file mode 100644 index 95034e6..0000000 --- a/karma.conf.js +++ /dev/null @@ -1,44 +0,0 @@ -// Karma configuration file, see link for more information -// https://karma-runner.github.io/1.0/config/configuration-file.html - -module.exports = function (config) { - config.set({ - basePath: '', - frameworks: ['jasmine', '@angular-devkit/build-angular'], - plugins: [ - require('karma-jasmine'), - require('karma-chrome-launcher'), - require('karma-jasmine-html-reporter'), - require('karma-coverage'), - require('@angular-devkit/build-angular/plugins/karma') - ], - client: { - jasmine: { - // you can add configuration options for Jasmine here - // the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html - // for example, you can disable the random execution with `random: false` - // or set a specific seed with `seed: 4321` - }, - clearContext: false // leave Jasmine Spec Runner output visible in browser - }, - jasmineHtmlReporter: { - suppressAll: true // removes the duplicated traces - }, - coverageReporter: { - dir: require('path').join(__dirname, './coverage/angular-material-date-fns-adapter'), - subdir: '.', - reporters: [ - { type: 'html' }, - { type: 'text-summary' } - ] - }, - reporters: ['progress', 'kjhtml'], - port: 9876, - colors: true, - logLevel: config.LOG_INFO, - autoWatch: true, - browsers: ['Chrome'], - singleRun: false, - restartOnFileChange: true - }); -}; diff --git a/projects/ngx-material-date-fns-adapter/karma.conf.js b/projects/ngx-material-date-fns-adapter/karma.conf.js deleted file mode 100644 index 6baabf8..0000000 --- a/projects/ngx-material-date-fns-adapter/karma.conf.js +++ /dev/null @@ -1,44 +0,0 @@ -// Karma configuration file, see link for more information -// https://karma-runner.github.io/1.0/config/configuration-file.html - -module.exports = function (config) { - config.set({ - basePath: '', - frameworks: ['jasmine', '@angular-devkit/build-angular'], - plugins: [ - require('karma-jasmine'), - require('karma-chrome-launcher'), - require('karma-jasmine-html-reporter'), - require('karma-coverage'), - require('@angular-devkit/build-angular/plugins/karma') - ], - client: { - jasmine: { - // you can add configuration options for Jasmine here - // the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html - // for example, you can disable the random execution with `random: false` - // or set a specific seed with `seed: 4321` - }, - clearContext: false // leave Jasmine Spec Runner output visible in browser - }, - jasmineHtmlReporter: { - suppressAll: true // removes the duplicated traces - }, - coverageReporter: { - dir: require('path').join(__dirname, '../../coverage/ngx-material-date-fns-adapter'), - subdir: '.', - reporters: [ - { type: 'html' }, - { type: 'text-summary' } - ] - }, - reporters: ['progress', 'kjhtml'], - port: 9876, - colors: true, - logLevel: config.LOG_INFO, - autoWatch: true, - browsers: ['Chrome'], - singleRun: false, - restartOnFileChange: true - }); -}; diff --git a/projects/ngx-material-date-fns-adapter/src/test.ts b/projects/ngx-material-date-fns-adapter/src/test.ts deleted file mode 100644 index 4380836..0000000 --- a/projects/ngx-material-date-fns-adapter/src/test.ts +++ /dev/null @@ -1,15 +0,0 @@ -// This file is required by karma.conf.js and loads recursively all the .spec and framework files - -import 'zone.js'; -import 'zone.js/testing'; -import { getTestBed } from '@angular/core/testing'; -import { - BrowserDynamicTestingModule, - platformBrowserDynamicTesting -} from '@angular/platform-browser-dynamic/testing'; - -// First, initialize the Angular testing environment. -getTestBed().initTestEnvironment( - BrowserDynamicTestingModule, - platformBrowserDynamicTesting(), -); diff --git a/projects/ngx-material-date-fns-adapter/tsconfig.spec.json b/projects/ngx-material-date-fns-adapter/tsconfig.spec.json index 715dd0a..ce7048b 100644 --- a/projects/ngx-material-date-fns-adapter/tsconfig.spec.json +++ b/projects/ngx-material-date-fns-adapter/tsconfig.spec.json @@ -7,9 +7,6 @@ "jasmine" ] }, - "files": [ - "src/test.ts" - ], "include": [ "**/*.spec.ts", "**/*.d.ts" diff --git a/src/app/app.component.spec.ts b/src/app/app.component.spec.ts index 6560349..1006ff3 100644 --- a/src/app/app.component.spec.ts +++ b/src/app/app.component.spec.ts @@ -1,31 +1,13 @@ import { TestBed } from '@angular/core/testing'; -import { MatIconModule } from '@angular/material/icon'; -import { MatCardModule } from '@angular/material/card'; -import { MatInputModule } from '@angular/material/input'; -import { MatButtonModule } from '@angular/material/button'; -import { MatTooltipModule } from '@angular/material/tooltip'; -import { MatToolbarModule } from '@angular/material/toolbar'; -import { MatFormFieldModule } from '@angular/material/form-field'; -import { MatDatepickerModule } from '@angular/material/datepicker'; import { AppComponent } from './app.component'; -import { NgxMatDateFnsModule } from 'ngx-material-date-fns-adapter'; +import { provideDateFnsAdapter } from 'ngx-material-date-fns-adapter'; describe('AppComponent', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - imports: [ - MatIconModule, - MatCardModule, - MatInputModule, - MatButtonModule, - MatTooltipModule, - MatToolbarModule, - MatFormFieldModule, - MatDatepickerModule, - NgxMatDateFnsModule, - ], - declarations: [AppComponent], + imports: [AppComponent], + providers: [provideDateFnsAdapter()], }).compileComponents(); }); diff --git a/src/app/app.component.ts b/src/app/app.component.ts index f983bfa..ee54309 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,10 +1,29 @@ import { Component, Inject, ViewEncapsulation } from '@angular/core'; import { DateAdapter, MAT_DATE_LOCALE } from '@angular/material/core'; +import { MatIconModule } from '@angular/material/icon'; +import { MatCardModule } from '@angular/material/card'; +import { MatInputModule } from '@angular/material/input'; +import { MatButtonModule } from '@angular/material/button'; +import { MatTooltipModule } from '@angular/material/tooltip'; +import { MatToolbarModule } from '@angular/material/toolbar'; +import { MatFormFieldModule } from '@angular/material/form-field'; +import { MatDatepickerModule } from '@angular/material/datepicker'; import packageJson from '../../projects/ngx-material-date-fns-adapter/package.json'; import { enUS, faIR, ar, fr, ja, ru } from 'date-fns/locale'; @Component({ + standalone: true, + imports: [ + MatIconModule, + MatCardModule, + MatInputModule, + MatButtonModule, + MatTooltipModule, + MatToolbarModule, + MatFormFieldModule, + MatDatepickerModule, + ], selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.scss'], diff --git a/src/app/app.config.ts b/src/app/app.config.ts new file mode 100644 index 0000000..f7cc734 --- /dev/null +++ b/src/app/app.config.ts @@ -0,0 +1,7 @@ +import { ApplicationConfig } from '@angular/core'; +import { provideAnimations } from '@angular/platform-browser/animations'; +import { provideDateFnsAdapter } from 'ngx-material-date-fns-adapter'; + +export const appConfig: ApplicationConfig = { + providers: [provideAnimations(), provideDateFnsAdapter()], +}; diff --git a/src/app/app.module.ts b/src/app/app.module.ts deleted file mode 100644 index 60c0b4f..0000000 --- a/src/app/app.module.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { NgModule } from '@angular/core'; -import { BrowserModule } from '@angular/platform-browser'; -import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; - -import { MatIconModule } from '@angular/material/icon'; -import { MatCardModule } from '@angular/material/card'; -import { MatInputModule } from '@angular/material/input'; -import { MatButtonModule } from '@angular/material/button'; -import { MatTooltipModule } from '@angular/material/tooltip'; -import { MatToolbarModule } from '@angular/material/toolbar'; -import { MatFormFieldModule } from '@angular/material/form-field'; -import { MatDatepickerModule } from '@angular/material/datepicker'; - -import { NgxMatDateFnsModule } from 'ngx-material-date-fns-adapter'; - -import { AppComponent } from './app.component'; - -@NgModule({ - declarations: [AppComponent], - imports: [ - BrowserModule, - BrowserAnimationsModule, - MatIconModule, - MatCardModule, - MatInputModule, - MatButtonModule, - MatTooltipModule, - MatToolbarModule, - MatFormFieldModule, - MatDatepickerModule, - NgxMatDateFnsModule, - ], - bootstrap: [AppComponent], -}) -export class AppModule {} diff --git a/src/main.ts b/src/main.ts index c7b673c..a0dbb2c 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,12 +1,7 @@ -import { enableProdMode } from '@angular/core'; -import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; +import { bootstrapApplication } from '@angular/platform-browser'; +import { AppComponent } from './app/app.component'; +import { appConfig } from './app/app.config'; -import { AppModule } from './app/app.module'; -import { environment } from './environments/environment'; - -if (environment.production) { - enableProdMode(); -} - -platformBrowserDynamic().bootstrapModule(AppModule) - .catch(err => console.error(err)); +bootstrapApplication(AppComponent, appConfig).catch((err) => + console.error(err) +); diff --git a/src/polyfills.ts b/src/polyfills.ts deleted file mode 100644 index 429bb9e..0000000 --- a/src/polyfills.ts +++ /dev/null @@ -1,53 +0,0 @@ -/** - * This file includes polyfills needed by Angular and is loaded before the app. - * You can add your own extra polyfills to this file. - * - * This file is divided into 2 sections: - * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. - * 2. Application imports. Files imported after ZoneJS that should be loaded before your main - * file. - * - * The current setup is for so-called "evergreen" browsers; the last versions of browsers that - * automatically update themselves. This includes recent versions of Safari, Chrome (including - * Opera), Edge on the desktop, and iOS and Chrome on mobile. - * - * Learn more in https://angular.io/guide/browser-support - */ - -/*************************************************************************************************** - * BROWSER POLYFILLS - */ - -/** - * By default, zone.js will patch all possible macroTask and DomEvents - * user can disable parts of macroTask/DomEvents patch by setting following flags - * because those flags need to be set before `zone.js` being loaded, and webpack - * will put import in the top of bundle, so user need to create a separate file - * in this directory (for example: zone-flags.ts), and put the following flags - * into that file, and then add the following code before importing zone.js. - * import './zone-flags'; - * - * The flags allowed in zone-flags.ts are listed here. - * - * The following flags will work for all browsers. - * - * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame - * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick - * (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames - * - * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js - * with the following flag, it will bypass `zone.js` patch for IE/Edge - * - * (window as any).__Zone_enable_cross_context_check = true; - * - */ - -/*************************************************************************************************** - * Zone JS is required by default for Angular itself. - */ -import 'zone.js'; // Included with Angular CLI. - - -/*************************************************************************************************** - * APPLICATION IMPORTS - */ diff --git a/src/test.ts b/src/test.ts deleted file mode 100644 index 51bb020..0000000 --- a/src/test.ts +++ /dev/null @@ -1,14 +0,0 @@ -// This file is required by karma.conf.js and loads recursively all the .spec and framework files - -import 'zone.js/testing'; -import { getTestBed } from '@angular/core/testing'; -import { - BrowserDynamicTestingModule, - platformBrowserDynamicTesting -} from '@angular/platform-browser-dynamic/testing'; - -// First, initialize the Angular testing environment. -getTestBed().initTestEnvironment( - BrowserDynamicTestingModule, - platformBrowserDynamicTesting(), -); diff --git a/tsconfig.app.json b/tsconfig.app.json index 82d91dc..374cc9d 100644 --- a/tsconfig.app.json +++ b/tsconfig.app.json @@ -6,8 +6,7 @@ "types": [] }, "files": [ - "src/main.ts", - "src/polyfills.ts" + "src/main.ts" ], "include": [ "src/**/*.d.ts" diff --git a/tsconfig.spec.json b/tsconfig.spec.json index 092345b..be7e9da 100644 --- a/tsconfig.spec.json +++ b/tsconfig.spec.json @@ -7,10 +7,6 @@ "jasmine" ] }, - "files": [ - "src/test.ts", - "src/polyfills.ts" - ], "include": [ "src/**/*.spec.ts", "src/**/*.d.ts"