From 48d9655a6bde0a70107cb60ce7e603d239792266 Mon Sep 17 00:00:00 2001 From: kartikchawla22 Date: Thu, 4 Jul 2024 09:31:51 -0400 Subject: [PATCH 01/14] Fix for issue 6640 (#6641) Co-authored-by: Alexey Umanskiy --- src/datepicker/bs-datepicker-input.directive.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/datepicker/bs-datepicker-input.directive.ts b/src/datepicker/bs-datepicker-input.directive.ts index 81bf0e69f9..dceac0a139 100644 --- a/src/datepicker/bs-datepicker-input.directive.ts +++ b/src/datepicker/bs-datepicker-input.directive.ts @@ -190,6 +190,7 @@ export class BsDatepickerInputDirective implements ControlValueAccessor, Validat } this._picker.bsValue = this._value; + this._onChange(this._value); } setDisabledState(isDisabled: boolean): void { From 4a8a35e0f61824ab7eb02caa3247741ebd99457f Mon Sep 17 00:00:00 2001 From: Alexey Umanskiy Date: Thu, 4 Jul 2024 19:54:05 +0300 Subject: [PATCH 02/14] chore: sorted versions in docs dropdown (#6659) * 13.0.0 * 14.0.0 * 15.0.0 * 16.0.0 * 17.0.0 * 18.0.0 * chore: version of the lib synced with the version of the angular * chore(common-docs): added versions sorting * chore(common-docs): switched from '+' to Number() for more explicit conversion --- .../src/lib/common/top-menu/top-menu.component.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libs/common-docs/src/lib/common/top-menu/top-menu.component.ts b/libs/common-docs/src/lib/common/top-menu/top-menu.component.ts index 06f7d2e2f6..b21e45da08 100644 --- a/libs/common-docs/src/lib/common/top-menu/top-menu.component.ts +++ b/libs/common-docs/src/lib/common/top-menu/top-menu.component.ts @@ -44,8 +44,11 @@ export class TopMenuComponent implements AfterViewInit { this.http .get<{ url: string; version: string; unprefixedUrl: string }[]>('assets/json/versions.json') .subscribe((data) => { - this.previousDocs.push(data[0]); - this.previousDocs = this.previousDocs.concat(data.reverse()).slice(0, -1); + this.previousDocs = data.sort((versionA, versionB) => { + const versionAsNumberA = Number(versionA.version.split('.').join('')); + const versionAsNumberB = Number(versionB.version.split('.').join('')); + return versionAsNumberB - versionAsNumberA; + }); }); this.http.get<{ version: string }>('assets/json/current-version.json').subscribe((data: { version: string }) => { From e6e374d2d077221378d185f2a4bc1e7d48edafa6 Mon Sep 17 00:00:00 2001 From: hansi_reit Date: Fri, 5 Jul 2024 09:36:00 +0200 Subject: [PATCH 03/14] test(timepicker): fix silently failing unit-tests (#6628) Unit-tests that cannot fail are useless, therefore this fix * unit test now fail if the expected value does not match * remove duplicated unit test Closes #6545 Co-authored-by: Alexey Umanskiy --- .../testing/bs-daterangepicker.spec.ts | 52 +++++-------------- 1 file changed, 12 insertions(+), 40 deletions(-) diff --git a/src/datepicker/testing/bs-daterangepicker.spec.ts b/src/datepicker/testing/bs-daterangepicker.spec.ts index bb085ab6a2..617235f365 100644 --- a/src/datepicker/testing/bs-daterangepicker.spec.ts +++ b/src/datepicker/testing/bs-daterangepicker.spec.ts @@ -7,6 +7,7 @@ import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { By } from '@angular/platform-browser'; import { BsCustomDates } from '../themes/bs/bs-custom-dates-view.component'; +import { firstValueFrom } from 'rxjs'; @Component({ selector: 'test-cmp', @@ -87,7 +88,7 @@ describe('daterangepicker:', () => { expect(timepickerZone).not.toBeTruthy(); }); - it('should update time when time is changed in timepicker', () => { + it('should update time when time is changed in timepicker', (done) => { const directive = getDaterangepickerDirective(fixture); directive.bsConfig = { withTimepicker: true @@ -119,6 +120,7 @@ describe('daterangepicker:', () => { .subscribe(view => { expect(view[0].getMinutes()).toEqual(ranges[1].value[0].getMinutes()); expect(view[1].getMinutes()).toEqual(ranges[1].value[1].getMinutes()); + done(); }); }); @@ -185,7 +187,7 @@ describe('daterangepicker:', () => { expect(getDaterangepickerContainer(datepicker)).toBeNull(); }); - it('should display correct date range in input when selected from ranges', () => { + it('should display correct date range in input when selected from ranges', (done) => { const datepicker = showDatepicker(fixture); const ranges = [ { @@ -207,6 +209,7 @@ describe('daterangepicker:', () => { .select(state => state.selectedRange) .subscribe(view => { expect(view).toEqual(ranges[0].value); + done(); }); }); @@ -230,31 +233,6 @@ describe('daterangepicker:', () => { const rangesButton = document.querySelector('.bs-datepicker-predefined-btns'); expect(rangesButton.childElementCount).toEqual(ranges.length); - - }); - - it('should display correct date range in input when selected from ranges', () => { - const datepicker = showDatepicker(fixture); - const ranges = [ - { - label: 'Last 7 days', - value: [new Date('12-10-2019'), new Date('12-16-2019')] - }, - { - label: 'Next 7 days', - value: [new Date('12-16-2019'), new Date('12-22-2019')] - } - ]; - datepicker.bsConfig.ranges = ranges; - const datepickerContainerInstance = getDaterangepickerContainer(datepicker); - datepickerContainerInstance.setRangeOnCalendar(ranges[0]); - - fixture.detectChanges(); - datepickerContainerInstance[`_store`] - .select(state => state.selectedRange) - .subscribe(view => { - expect(view).toEqual(ranges[0].value); - }); }); it('should correctly display the selected range button with active custom class', () => { @@ -286,7 +264,7 @@ describe('daterangepicker:', () => { expect(activeRangeButton[0].innerHTML.trim()).toEqual(ranges[0].label); }); - it('should not allow to select date behind max value', () => { + it('should not allow to select date behind max value', async () => { const datepicker = showDatepicker(fixture); datepicker.bsConfig.maxDate = new Date(); datepicker.bsConfig.maxDateRange = 10; @@ -300,15 +278,12 @@ describe('daterangepicker:', () => { value: [correctDateStart, correctDateEnd] }; - datepickerContainerInstance.setMaxDateRangeOnCalendar(correctDateStart); + datepickerContainerInstance.setMaxDateRangeOnCalendar(correctDateEnd); datepickerContainerInstance.setRangeOnCalendar(selectedRange); fixture.detectChanges(); - datepickerContainerInstance[`_store`] - .select(state => state) - .subscribe(view => { - expect(view.maxDate).toEqual(correctDateEnd); - }); + let view = await firstValueFrom(datepickerContainerInstance[`_store`].select((state) => state)); + expect(view.maxDate).toEqual(correctDateEnd); const incorrectCaseStart = new Date(new Date().setDate(new Date().getDate() - 5)); const incorrectCaseEnd = new Date(new Date().setDate(new Date().getDate() + 15)); @@ -321,10 +296,7 @@ describe('daterangepicker:', () => { datepickerContainerInstance.setRangeOnCalendar(selectedRange1); fixture.detectChanges(); - datepickerContainerInstance[`_store`] - .select(state => state) - .subscribe(view => { - expect(view.maxDate).not.toEqual(incorrectCaseEnd); - }); - }); + view = await firstValueFrom(datepickerContainerInstance[`_store`].select((state) => state)); + expect(view.maxDate).not.toEqual(incorrectCaseEnd); }); +}); From 876f20d29042c53b0d111eecd84e87fad8e6f22d Mon Sep 17 00:00:00 2001 From: Joschua Schneider Date: Fri, 5 Jul 2024 13:27:36 +0200 Subject: [PATCH 04/14] fix(ComponentLoader): loader leaks memory in multiple places (#6625) * fix(ComponentLoader): loader leaks memory in multiple places * Fix(component-loader): fixing lint --------- Co-authored-by: Alexey Umanskiy --- src/component-loader/component-loader.class.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/component-loader/component-loader.class.ts b/src/component-loader/component-loader.class.ts index 2f60d5f23c..a6e46f5eb5 100644 --- a/src/component-loader/component-loader.class.ts +++ b/src/component-loader/component-loader.class.ts @@ -226,6 +226,7 @@ export class ComponentLoader { ); } this._contentRef?.viewRef?.destroy(); + this._componentRef?.destroy(); this._contentRef = void 0; this._componentRef = void 0; @@ -312,12 +313,16 @@ export class ComponentLoader { if (!this._componentRef || !this._componentRef.location) { return; } + + let unsubscribeOutsideClick = Function.prototype; + let unsubscribeEscClick = Function.prototype; + // why: should run after first event bubble if (this._listenOpts.outsideClick) { const target = this._componentRef.location.nativeElement; setTimeout(() => { if (this._renderer && this._elementRef) { - this._globalListener = registerOutsideClick(this._renderer, { + unsubscribeOutsideClick = registerOutsideClick(this._renderer, { targets: [target, this._elementRef.nativeElement], outsideClick: this._listenOpts.outsideClick, hide: () => this._listenOpts.hide && this._listenOpts.hide() @@ -327,12 +332,17 @@ export class ComponentLoader { } if (this._listenOpts.outsideEsc && this._renderer && this._elementRef) { const target = this._componentRef.location.nativeElement; - this._globalListener = registerEscClick(this._renderer, { + unsubscribeEscClick = registerEscClick(this._renderer, { targets: [target, this._elementRef.nativeElement], outsideEsc: this._listenOpts.outsideEsc, hide: () => this._listenOpts.hide && this._listenOpts.hide() }); } + + this._globalListener = () => { + unsubscribeOutsideClick(); + unsubscribeEscClick(); + }; } getInnerComponent(): ComponentRef | undefined { From 740a10f9d07f57b2743362afb956df60b7bad773 Mon Sep 17 00:00:00 2001 From: Alexey Umanskiy Date: Fri, 12 Jul 2024 12:50:58 +0300 Subject: [PATCH 05/14] feat(ng-add): added warning for applications without modules (#6664) * feat(ng-add): added warning for applications without modules * feat(docs): fixed typo * feat(docs): fixed typo --- .../documentation/documentation.component.html | 18 +++++++++++++++++- src/schematics/src/utils/index.ts | 4 ++++ src/schematics/src/utils/project-main-file.ts | 4 ++-- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/libs/common-docs/src/lib/common/documentation/documentation.component.html b/libs/common-docs/src/lib/common/documentation/documentation.component.html index ae40a3d03a..332a04922f 100644 --- a/libs/common-docs/src/lib/common/documentation/documentation.component.html +++ b/libs/common-docs/src/lib/common/documentation/documentation.component.html @@ -112,6 +112,22 @@

#

Angular CLI way

+

Make sure that your app uses modular approach and you have app.module.ts set as your starting point before you proceed

+
+import {{'{'}} platformBrowser {{'}'}} from '@angular/platform-browser';
+import {{'{'}} AppModule {{'}'}} from './app.module';
+ 
+platformBrowser().bootstrapModule(AppModule).catch((err) => console.error(err));
+      
+ + + + +

Use the Angular CLI ng add command for updating your Angular project.

ng add ngx-bootstrap
@@ -233,7 +249,7 @@

- 13.x.x + 18.x.x 18.x.x 5.x.x or 4.x.x diff --git a/src/schematics/src/utils/index.ts b/src/schematics/src/utils/index.ts index c577271b94..ecf5c8a097 100644 --- a/src/schematics/src/utils/index.ts +++ b/src/schematics/src/utils/index.ts @@ -92,6 +92,10 @@ export function addModuleImportToRootModule( if (!moduleSource) { throw new SchematicsException(`Module not found: ${modulePath}`); } + if (modulePath.includes('component')) { + throw new SchematicsException(`ngx-bootstrap doesn't support moduleless approach if we couldn't find + your starting *.module.ts learn more here https://valor-software.com/ngx-bootstrap/#/documentation#installation`); + } const changes: Change[] = addImportToModule(moduleSource, modulePath, moduleName, src); const recorder = host.beginUpdate(modulePath); diff --git a/src/schematics/src/utils/project-main-file.ts b/src/schematics/src/utils/project-main-file.ts index f55135f2ee..c739ac7ec8 100644 --- a/src/schematics/src/utils/project-main-file.ts +++ b/src/schematics/src/utils/project-main-file.ts @@ -13,10 +13,10 @@ import { workspaces } from '@angular-devkit/core'; /** Looks for the main TypeScript file in the given project and returns its path. */ export function getProjectMainFile(project: workspaces.ProjectDefinition): string { const buildOptions = getProjectTargetOptions(project, 'build'); - if (!buildOptions.main) { + if (!buildOptions.main && !buildOptions.browser) { throw new SchematicsException(`Could not find the project main file inside of the ` + `workspace config (${project.sourceRoot})`); } - return buildOptions.main.toString(); + return buildOptions.main?.toString() ?? buildOptions.browser.toString(); } From 7c187599ee2a1475791452e290435b3a3ee63796 Mon Sep 17 00:00:00 2001 From: Alexey Umanskiy Date: Mon, 15 Jul 2024 15:35:28 +0300 Subject: [PATCH 06/14] chore: version bump v18.0.2 (#6667) * 18.0.1 * chore(release): v18.0.1 * 18.0.2 * chore(release): v18.0.2 --- apps/ngx-bootstrap-docs/src/assets/json/current-version.json | 2 +- package-lock.json | 4 ++-- package.json | 2 +- src/accordion/package.json | 2 +- src/alert/package.json | 2 +- src/buttons/package.json | 2 +- src/carousel/package.json | 2 +- src/chronos/package.json | 2 +- src/collapse/package.json | 2 +- src/component-loader/package.json | 2 +- src/datepicker/package.json | 2 +- src/dropdown/package.json | 2 +- src/focus-trap/package.json | 2 +- src/locale/package.json | 2 +- src/mini-ngrx/package.json | 2 +- src/modal/package.json | 2 +- src/pagination/package.json | 2 +- src/popover/package.json | 2 +- src/positioning/package.json | 2 +- src/progressbar/package.json | 2 +- src/rating/package.json | 2 +- src/root/package.json | 2 +- src/schematics/package.json | 2 +- src/schematics/src/utils/current_dependency_versions.json | 2 +- src/sortable/package.json | 2 +- src/tabs/package.json | 2 +- src/timepicker/package.json | 2 +- src/tooltip/package.json | 2 +- src/typeahead/package.json | 2 +- src/utils/package.json | 2 +- 30 files changed, 31 insertions(+), 31 deletions(-) diff --git a/apps/ngx-bootstrap-docs/src/assets/json/current-version.json b/apps/ngx-bootstrap-docs/src/assets/json/current-version.json index fba18155b3..51e97297c7 100644 --- a/apps/ngx-bootstrap-docs/src/assets/json/current-version.json +++ b/apps/ngx-bootstrap-docs/src/assets/json/current-version.json @@ -1,3 +1,3 @@ { - "version": "18.0.0" + "version": "18.0.2" } diff --git a/package-lock.json b/package-lock.json index 6a18751841..786605b43e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "ngx-bootstrap-base", - "version": "18.0.0", + "version": "18.0.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "ngx-bootstrap-base", - "version": "18.0.0", + "version": "18.0.2", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index 86078f6343..b40b6ebd27 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap-base", - "version": "18.0.0", + "version": "18.0.2", "license": "MIT", "author": "Dmitriy Shekhovtsov ", "schematics": "./schematics/src/collection.json", diff --git a/src/accordion/package.json b/src/accordion/package.json index d69e0fea79..b21be99d7b 100644 --- a/src/accordion/package.json +++ b/src/accordion/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/accordion", - "version": "18.0.0", + "version": "18.0.2", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/alert/package.json b/src/alert/package.json index 32b5f4f581..37e220999b 100644 --- a/src/alert/package.json +++ b/src/alert/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/alert", - "version": "18.0.0", + "version": "18.0.2", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/buttons/package.json b/src/buttons/package.json index fee7f3d4fd..25e606aaf8 100644 --- a/src/buttons/package.json +++ b/src/buttons/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/buttons", - "version": "18.0.0", + "version": "18.0.2", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/carousel/package.json b/src/carousel/package.json index b0c315151e..a8e3144d42 100644 --- a/src/carousel/package.json +++ b/src/carousel/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/carousel", - "version": "18.0.0", + "version": "18.0.2", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/chronos/package.json b/src/chronos/package.json index 8efd7d4fea..59b022b551 100644 --- a/src/chronos/package.json +++ b/src/chronos/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/chronos", - "version": "18.0.0", + "version": "18.0.2", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/collapse/package.json b/src/collapse/package.json index 929bcef135..5f137f3b3c 100644 --- a/src/collapse/package.json +++ b/src/collapse/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/collapse", - "version": "18.0.0", + "version": "18.0.2", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/component-loader/package.json b/src/component-loader/package.json index ebefd08682..33cb1b1a24 100644 --- a/src/component-loader/package.json +++ b/src/component-loader/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/component-loader", - "version": "18.0.0", + "version": "18.0.2", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/datepicker/package.json b/src/datepicker/package.json index b5836c8c1d..e6aec3d959 100644 --- a/src/datepicker/package.json +++ b/src/datepicker/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/datepicker", - "version": "18.0.0", + "version": "18.0.2", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/dropdown/package.json b/src/dropdown/package.json index 4592b8e8df..b979ff0d5f 100644 --- a/src/dropdown/package.json +++ b/src/dropdown/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/dropdown", - "version": "18.0.0", + "version": "18.0.2", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/focus-trap/package.json b/src/focus-trap/package.json index d40cd175a2..798cddf9e9 100644 --- a/src/focus-trap/package.json +++ b/src/focus-trap/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/focus-trap", - "version": "18.0.0", + "version": "18.0.2", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/locale/package.json b/src/locale/package.json index 100734411d..f798d0e568 100644 --- a/src/locale/package.json +++ b/src/locale/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/locale", - "version": "18.0.0", + "version": "18.0.2", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/mini-ngrx/package.json b/src/mini-ngrx/package.json index 74a40c3bfc..0a88fb31d2 100644 --- a/src/mini-ngrx/package.json +++ b/src/mini-ngrx/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/mini-ngrx", - "version": "18.0.0", + "version": "18.0.2", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/modal/package.json b/src/modal/package.json index 4116d7c4e2..0b076c8e90 100644 --- a/src/modal/package.json +++ b/src/modal/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/modal", - "version": "18.0.0", + "version": "18.0.2", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/pagination/package.json b/src/pagination/package.json index 901e067682..65ea992f8e 100644 --- a/src/pagination/package.json +++ b/src/pagination/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/pagination", - "version": "18.0.0", + "version": "18.0.2", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/popover/package.json b/src/popover/package.json index 18292a548c..181f647f9a 100644 --- a/src/popover/package.json +++ b/src/popover/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/popover", - "version": "18.0.0", + "version": "18.0.2", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/positioning/package.json b/src/positioning/package.json index dd538d52dd..16268dc595 100644 --- a/src/positioning/package.json +++ b/src/positioning/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/positioning", - "version": "18.0.0", + "version": "18.0.2", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/progressbar/package.json b/src/progressbar/package.json index 5a863a19b5..adba2d57f4 100644 --- a/src/progressbar/package.json +++ b/src/progressbar/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/progressbar", - "version": "18.0.0", + "version": "18.0.2", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/rating/package.json b/src/rating/package.json index bf4f414597..d3ee92def2 100644 --- a/src/rating/package.json +++ b/src/rating/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/rating", - "version": "18.0.0", + "version": "18.0.2", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/root/package.json b/src/root/package.json index e7c21d8e33..5e198f62d0 100644 --- a/src/root/package.json +++ b/src/root/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap", - "version": "18.0.0", + "version": "18.0.2", "description": "Angular Bootstrap", "author": "Dmitriy Shekhovtsov ", "license": "MIT", diff --git a/src/schematics/package.json b/src/schematics/package.json index 5804886b53..31bad55d78 100644 --- a/src/schematics/package.json +++ b/src/schematics/package.json @@ -1,6 +1,6 @@ { "name": "schematics", - "version": "18.0.0", + "version": "18.0.2", "schematics": "./collection.json", "author": "Dmitriy Shekhovtsov ", "license": "MIT" diff --git a/src/schematics/src/utils/current_dependency_versions.json b/src/schematics/src/utils/current_dependency_versions.json index d027466700..389d54faa6 100644 --- a/src/schematics/src/utils/current_dependency_versions.json +++ b/src/schematics/src/utils/current_dependency_versions.json @@ -1,4 +1,4 @@ { - "NGX_BOOTSTRAP_VERSION": "18.0.0", + "NGX_BOOTSTRAP_VERSION": "18.0.2", "BOOTSTRAP_VERSION": "^5.2.3" } diff --git a/src/sortable/package.json b/src/sortable/package.json index a1051849b9..5b3c90df38 100644 --- a/src/sortable/package.json +++ b/src/sortable/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/sortable", - "version": "18.0.0", + "version": "18.0.2", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/tabs/package.json b/src/tabs/package.json index 11fecbf5a8..f069af6371 100644 --- a/src/tabs/package.json +++ b/src/tabs/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/tabs", - "version": "18.0.0", + "version": "18.0.2", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/timepicker/package.json b/src/timepicker/package.json index 76a5b5892f..b9a371e8f9 100644 --- a/src/timepicker/package.json +++ b/src/timepicker/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/timepicker", - "version": "18.0.0", + "version": "18.0.2", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/tooltip/package.json b/src/tooltip/package.json index d5ccef2018..f7d6326dad 100644 --- a/src/tooltip/package.json +++ b/src/tooltip/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/tooltip", - "version": "18.0.0", + "version": "18.0.2", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/typeahead/package.json b/src/typeahead/package.json index e6235176e3..f982c99d2c 100644 --- a/src/typeahead/package.json +++ b/src/typeahead/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/typeahead", - "version": "18.0.0", + "version": "18.0.2", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/utils/package.json b/src/utils/package.json index 1274afb3ee..799da4bf79 100644 --- a/src/utils/package.json +++ b/src/utils/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/utils", - "version": "18.0.0", + "version": "18.0.2", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } From d210ca6dcdf213bfb63f4499ceffd258b3cd5a68 Mon Sep 17 00:00:00 2001 From: alihasan0786 <129028093+alihasan00@users.noreply.github.com> Date: Mon, 15 Jul 2024 20:46:49 +0500 Subject: [PATCH 07/14] [Feature]: FR-CA integration (#6598) * integrate fr-ca * fr-cal locale added * fr-ca locale added for datepicker and demo date-picker * feat(fr-ca): added tests * feat(fr-ca): added tests --------- Co-authored-by: githubhasanali Co-authored-by: Dmitriy Shekhovtsov Co-authored-by: Alexey Umanskiy --- .../datepicker/src/lib/datepicker.module.ts | 4 +- .../src/lib/demo-datepicker.module.ts | 4 +- src/chronos/i18n/fr-ca.ts | 73 ++++++ src/chronos/public_api.ts | 1 + src/chronos/testing/locale/fr-ca.spec.ts | 243 ++++++++++++++++++ src/locale/public_api.ts | 1 + src/schematics/src/ng-add/index.ts | 9 +- src/schematics/src/utils/index.ts | 11 +- 8 files changed, 335 insertions(+), 11 deletions(-) create mode 100644 src/chronos/i18n/fr-ca.ts create mode 100644 src/chronos/testing/locale/fr-ca.spec.ts diff --git a/libs/doc-pages/datepicker/src/lib/datepicker.module.ts b/libs/doc-pages/datepicker/src/lib/datepicker.module.ts index 6b096a1b80..2fadc6ba23 100644 --- a/libs/doc-pages/datepicker/src/lib/datepicker.module.ts +++ b/libs/doc-pages/datepicker/src/lib/datepicker.module.ts @@ -10,7 +10,7 @@ import { arLocale, bgLocale, caLocale, csLocale, daLocale, deLocale, enGbLocale, esDoLocale, esLocale, esUsLocale, etLocale, frLocale, heLocale, hiLocale, hrLocale, fiLocale, glLocale, huLocale, idLocale, itLocale, jaLocale, kaLocale, kkLocale, koLocale, ltLocale, lvLocale, mnLocale, nbLocale, nlBeLocale, nlLocale, plLocale, ptBrLocale, ruLocale, roLocale, skLocale, slLocale, sqLocale, svLocale, thLocale, thBeLocale, trLocale, viLocale, - zhCnLocale, ukLocale + zhCnLocale, ukLocale, frCaLocale } from 'ngx-bootstrap/locale'; import { TabsModule } from 'ngx-bootstrap/tabs'; @@ -26,7 +26,7 @@ const locales = [ arLocale, bgLocale, caLocale, csLocale, daLocale, deLocale, enGbLocale, esDoLocale, esLocale, esUsLocale, etLocale, frLocale, heLocale, hiLocale, hrLocale, fiLocale, glLocale, huLocale, idLocale, itLocale, jaLocale, kaLocale, kkLocale, koLocale, ltLocale, lvLocale, mnLocale, nbLocale, nlBeLocale, nlLocale, plLocale, ptBrLocale, ruLocale, roLocale, skLocale, slLocale, sqLocale, svLocale, thLocale, thBeLocale, - trLocale, ukLocale, viLocale, zhCnLocale + trLocale, ukLocale, viLocale, zhCnLocale, frCaLocale ]; locales.forEach((locale: LocaleData) => { diff --git a/libs/doc-pages/datepicker/src/lib/demo-datepicker.module.ts b/libs/doc-pages/datepicker/src/lib/demo-datepicker.module.ts index 72c4f5ba41..2fc35ba559 100644 --- a/libs/doc-pages/datepicker/src/lib/demo-datepicker.module.ts +++ b/libs/doc-pages/datepicker/src/lib/demo-datepicker.module.ts @@ -10,7 +10,7 @@ import { arLocale, bgLocale, caLocale, csLocale, daLocale, deLocale, enGbLocale, esDoLocale, esLocale, esPrLocale, esUsLocale, etLocale, frLocale, heLocale, hiLocale, hrLocale, fiLocale, glLocale, huLocale, idLocale, itLocale, jaLocale, kaLocale, kkLocale, koLocale, ltLocale, lvLocale, mnLocale, nbLocale, nlBeLocale, nlLocale, plLocale, ptBrLocale, ruLocale, roLocale, skLocale, slLocale, sqLocale, svLocale, thLocale, thBeLocale, trLocale, viLocale, - zhCnLocale, ukLocale + zhCnLocale, ukLocale, frCaLocale } from 'ngx-bootstrap/locale'; import { TabsModule } from 'ngx-bootstrap/tabs'; @@ -24,7 +24,7 @@ const locales = [ arLocale, bgLocale, caLocale, csLocale, daLocale, deLocale, enGbLocale, esDoLocale, esLocale, esPrLocale, esUsLocale, etLocale, frLocale, heLocale, hiLocale, hrLocale, fiLocale, glLocale, huLocale, idLocale, itLocale, jaLocale, kaLocale, kkLocale, koLocale, ltLocale, lvLocale, mnLocale, nbLocale, nlBeLocale, nlLocale, plLocale, ptBrLocale, ruLocale, roLocale, skLocale, slLocale, sqLocale, svLocale, thLocale, thBeLocale, - trLocale, ukLocale, viLocale, zhCnLocale + trLocale, ukLocale, viLocale, zhCnLocale, frCaLocale ]; locales.forEach((locale: LocaleData) => { diff --git a/src/chronos/i18n/fr-ca.ts b/src/chronos/i18n/fr-ca.ts new file mode 100644 index 0000000000..00a9fa86cb --- /dev/null +++ b/src/chronos/i18n/fr-ca.ts @@ -0,0 +1,73 @@ +import { LocaleData } from '../locale/locale.class'; + +//! moment.js locale configuration +//! locale : French Canadian [fr-ca] +//! author : Ali Hasan : https://github.com/alihasan00 + +export const frCaLocale: LocaleData = { + abbr: 'fr-ca', + months: 'janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre'.split('_'), + monthsShort: 'janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.'.split('_'), + monthsParseExact: true, + weekdays: 'dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi'.split('_'), + weekdaysShort: 'dim._lun._mar._mer._jeu._ven._sam.'.split('_'), + weekdaysMin: 'di_lu_ma_me_je_ve_sa'.split('_'), + weekdaysParseExact: true, + longDateFormat: { + LT: 'HH:mm', + LTS: 'HH:mm:ss', + L: 'YYYY-MM-DD', + LL: 'D MMMM YYYY', + LLL: 'D MMMM YYYY HH:mm', + LLLL: 'dddd D MMMM YYYY HH:mm' + }, + calendar: { + sameDay: '[Aujourd’hui à] LT', + nextDay: '[Demain à] LT', + nextWeek: 'dddd [à] LT', + lastDay: '[Hier à] LT', + lastWeek: 'dddd [dernier à] LT', + sameElse: 'L' + }, + relativeTime: { + future: 'dans %s', + past: 'il y a %s', + s: 'quelques secondes', + ss: '%d secondes', + m: 'une minute', + mm: '%d minutes', + h: 'une heure', + hh: '%d heures', + d: 'un jour', + dd: '%d jours', + M: 'un mois', + MM: '%d mois', + y: 'un an', + yy: '%d ans' + }, + dayOfMonthOrdinalParse: /\d{1,2}(er|e|)/, + ordinal(_num: number, period: string): string { + const num = Number(_num); + switch (period) { + case 'D': + return num + (num === 1 ? 'er' : ''); + + // Words with masculine grammatical gender: mois, trimestre, jour + default: + case 'M': + case 'Q': + case 'DDD': + case 'd': + return num + (num === 1 ? 'er' : 'e'); + + // Words with feminine grammatical gender: semaine + case 'w': + case 'W': + return num + (num === 1 ? 're' : 'e'); + } + }, + week: { + dow: 1, // Monday is the first day of the week. + doy: 4 // The week that contains Jan 4th is the first week of the year. + } +}; diff --git a/src/chronos/public_api.ts b/src/chronos/public_api.ts index 3e72eccbc3..24c705c558 100644 --- a/src/chronos/public_api.ts +++ b/src/chronos/public_api.ts @@ -48,6 +48,7 @@ export { esUsLocale } from './i18n/es-us'; export { etLocale } from './i18n/et'; export { fiLocale } from './i18n/fi'; export { frLocale } from './i18n/fr'; +export {frCaLocale} from './i18n/fr-ca'; export { glLocale } from './i18n/gl'; export { heLocale } from './i18n/he'; export { hiLocale } from './i18n/hi'; diff --git a/src/chronos/testing/locale/fr-ca.spec.ts b/src/chronos/testing/locale/fr-ca.spec.ts new file mode 100644 index 0000000000..fcb4499645 --- /dev/null +++ b/src/chronos/testing/locale/fr-ca.spec.ts @@ -0,0 +1,243 @@ + +import { assertEq, assertDeepEq } from '../test-helpers'; +import { moment } from '../chain'; +import { frCaLocale } from '../../i18n/fr-ca'; + +describe('locale: fr-ca', () => { + beforeAll(() => { + moment.locale('fr-ca', frCaLocale); + }); + + afterAll(() => { + moment.locale('en'); + }); + + it('parse', function () { + var i, + _tests = 'janvier janv._février févr._mars mars_avril avr._mai mai_juin juin_juillet juil._août août_septembre sept._octobre oct._novembre nov._décembre déc.'.split('_'); + + function equalTest(input, mmm, i) { + assertEq(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1)); + } + + let tests: string[][] = []; + for (i = 0; i < 12; i++) { + tests[i] = _tests[i].split(' '); + equalTest(tests[i][0], 'MMM', i); + equalTest(tests[i][1], 'MMM', i); + equalTest(tests[i][0], 'MMMM', i); + equalTest(tests[i][1], 'MMMM', i); + equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i); + equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i); + equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i); + equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i); + } + }); + + it('format', function () { + var a = [ + ['dddd, MMMM Do YYYY, h:mm:ss a', 'dimanche, février 14 2010, 3:25:50 pm'], + ['ddd, hA', 'dim., 3PM'], + ['M Mo MM MMMM MMM', '2 2e 02 février févr.'], + ['YYYY YY', '2010 10'], + ['D Do DD', '14 14 14'], + ['d do dddd ddd dd', '0 0e dimanche dim. di'], + ['DDD DDDo DDDD', '45 45e 045'], + ['w wo ww', '6 6e 06'], + ['h hh', '3 03'], + ['H HH', '15 15'], + ['m mm', '25 25'], + ['s ss', '50 50'], + ['a A', 'pm PM'], + ['[le] Do [jour du mois]', 'le 14 jour du mois'], + ['[le] DDDo [jour de l’année]', 'le 45e jour de l’année'], + ['LTS', '15:25:50'], + ['L', '2010-02-14'], + ['LL', '14 février 2010'], + ['LLL', '14 février 2010 15:25'], + ['LLLL', 'dimanche 14 février 2010 15:25'], + ['l', '2010-2-14'], + ['ll', '14 févr. 2010'], + ['lll', '14 févr. 2010 15:25'], + ['llll', 'dim. 14 févr. 2010 15:25'] + ], + b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)), + i; + + for (i = 0; i < a.length; i++) { + assertEq(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]); + } + }); + + it('format ordinal', function () { + assertEq(moment([2017, 0, 1]).format('Mo'), '1er', '1er'); + assertEq(moment([2017, 1, 1]).format('Mo'), '2e', '2e'); + + assertEq(moment([2017, 0, 1]).format('Qo'), '1er', '1er'); + assertEq(moment([2017, 3, 1]).format('Qo'), '2e', '2e'); + + assertEq(moment([2017, 0, 1]).format('Do'), '1er', '1er'); + assertEq(moment([2017, 0, 2]).format('Do'), '2', '2'); + + assertEq(moment([2011, 0, 1]).format('DDDo'), '1er', '1er'); + assertEq(moment([2011, 0, 2]).format('DDDo'), '2e', '2e'); + assertEq(moment([2011, 0, 3]).format('DDDo'), '3e', '3e'); + assertEq(moment([2011, 0, 4]).format('DDDo'), '4e', '4e'); + assertEq(moment([2011, 0, 5]).format('DDDo'), '5e', '5e'); + assertEq(moment([2011, 0, 6]).format('DDDo'), '6e', '6e'); + assertEq(moment([2011, 0, 7]).format('DDDo'), '7e', '7e'); + assertEq(moment([2011, 0, 8]).format('DDDo'), '8e', '8e'); + assertEq(moment([2011, 0, 9]).format('DDDo'), '9e', '9e'); + assertEq(moment([2011, 0, 10]).format('DDDo'), '10e', '10e'); + + assertEq(moment([2011, 0, 11]).format('DDDo'), '11e', '11e'); + assertEq(moment([2011, 0, 12]).format('DDDo'), '12e', '12e'); + assertEq(moment([2011, 0, 13]).format('DDDo'), '13e', '13e'); + assertEq(moment([2011, 0, 14]).format('DDDo'), '14e', '14e'); + assertEq(moment([2011, 0, 15]).format('DDDo'), '15e', '15e'); + assertEq(moment([2011, 0, 16]).format('DDDo'), '16e', '16e'); + assertEq(moment([2011, 0, 17]).format('DDDo'), '17e', '17e'); + assertEq(moment([2011, 0, 18]).format('DDDo'), '18e', '18e'); + assertEq(moment([2011, 0, 19]).format('DDDo'), '19e', '19e'); + assertEq(moment([2011, 0, 20]).format('DDDo'), '20e', '20e'); + + assertEq(moment([2011, 0, 21]).format('DDDo'), '21e', '21e'); + assertEq(moment([2011, 0, 22]).format('DDDo'), '22e', '22e'); + assertEq(moment([2011, 0, 23]).format('DDDo'), '23e', '23e'); + assertEq(moment([2011, 0, 24]).format('DDDo'), '24e', '24e'); + assertEq(moment([2011, 0, 25]).format('DDDo'), '25e', '25e'); + assertEq(moment([2011, 0, 26]).format('DDDo'), '26e', '26e'); + assertEq(moment([2011, 0, 27]).format('DDDo'), '27e', '27e'); + assertEq(moment([2011, 0, 28]).format('DDDo'), '28e', '28e'); + assertEq(moment([2011, 0, 29]).format('DDDo'), '29e', '29e'); + assertEq(moment([2011, 0, 30]).format('DDDo'), '30e', '30e'); + + assertEq(moment([2011, 0, 31]).format('DDDo'), '31e', '31e'); + + assertEq(moment([2017, 0, 1]).format('do'), '0e', '0e'); + assertEq(moment([2017, 0, 2]).format('do'), '1er', '1er'); + + assertEq(moment([2017, 0, 4]).format('wo Wo'), '1re 1re', '1re 1re'); + assertEq(moment([2017, 0, 11]).format('wo Wo'), '2e 2e', '2e 2e'); + }); + + it('format month', function () { + var i, + expected = 'janvier janv._février févr._mars mars_avril avr._mai mai_juin juin_juillet juil._août août_septembre sept._octobre oct._novembre nov._décembre déc.'.split('_'); + + for (i = 0; i < expected.length; i++) { + assertEq(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]); + } + }); + + it('format week', function () { + var i, + expected = 'dimanche dim. di_lundi lun. lu_mardi mar. ma_mercredi mer. me_jeudi jeu. je_vendredi ven. ve_samedi sam. sa'.split('_'); + + for (i = 0; i < expected.length; i++) { + assertEq(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]); + } + }); + + it('from', function () { + var start = moment([2007, 1, 28]); + + assertEq(start.from(moment([2007, 1, 28]).add({ s: 44 }), true), 'quelques secondes', '44 seconds = a few seconds'); + assertEq(start.from(moment([2007, 1, 28]).add({ s: 45 }), true), 'une minute', '45 seconds = a minute'); + assertEq(start.from(moment([2007, 1, 28]).add({ s: 89 }), true), 'une minute', '89 seconds = a minute'); + assertEq(start.from(moment([2007, 1, 28]).add({ s: 90 }), true), '2 minutes', '90 seconds = 2 minutes'); + assertEq(start.from(moment([2007, 1, 28]).add({ m: 44 }), true), '44 minutes', '44 minutes = 44 minutes'); + assertEq(start.from(moment([2007, 1, 28]).add({ m: 45 }), true), 'une heure', '45 minutes = an hour'); + assertEq(start.from(moment([2007, 1, 28]).add({ m: 89 }), true), 'une heure', '89 minutes = an hour'); + assertEq(start.from(moment([2007, 1, 28]).add({ m: 90 }), true), '2 heures', '90 minutes = 2 hours'); + assertEq(start.from(moment([2007, 1, 28]).add({ h: 5 }), true), '5 heures', '5 hours = 5 hours'); + assertEq(start.from(moment([2007, 1, 28]).add({ h: 21 }), true), '21 heures', '21 hours = 21 hours'); + assertEq(start.from(moment([2007, 1, 28]).add({ h: 22 }), true), 'un jour', '22 hours = a day'); + assertEq(start.from(moment([2007, 1, 28]).add({ h: 35 }), true), 'un jour', '35 hours = a day'); + assertEq(start.from(moment([2007, 1, 28]).add({ h: 36 }), true), '2 jours', '36 hours = 2 days'); + assertEq(start.from(moment([2007, 1, 28]).add({ d: 1 }), true), 'un jour', '1 day = a day'); + assertEq(start.from(moment([2007, 1, 28]).add({ d: 5 }), true), '5 jours', '5 days = 5 days'); + assertEq(start.from(moment([2007, 1, 28]).add({ d: 25 }), true), '25 jours', '25 days = 25 days'); + assertEq(start.from(moment([2007, 1, 28]).add({ d: 26 }), true), 'un mois', '26 days = a month'); + assertEq(start.from(moment([2007, 1, 28]).add({ d: 30 }), true), 'un mois', '30 days = a month'); + assertEq(start.from(moment([2007, 1, 28]).add({ d: 43 }), true), 'un mois', '43 days = a month'); + assertEq(start.from(moment([2007, 1, 28]).add({ d: 46 }), true), '2 mois', '46 days = 2 months'); + assertEq(start.from(moment([2007, 1, 28]).add({ d: 74 }), true), '2 mois', '75 days = 2 months'); + assertEq(start.from(moment([2007, 1, 28]).add({ d: 76 }), true), '3 mois', '76 days = 3 months'); + assertEq(start.from(moment([2007, 1, 28]).add({ M: 1 }), true), 'un mois', '1 month = a month'); + assertEq(start.from(moment([2007, 1, 28]).add({ M: 5 }), true), '5 mois', '5 months = 5 months'); + assertEq(start.from(moment([2007, 1, 28]).add({ d: 345 }), true), 'un an', '345 days = a year'); + assertEq(start.from(moment([2007, 1, 28]).add({ d: 548 }), true), '2 ans', '548 days = 2 years'); + assertEq(start.from(moment([2007, 1, 28]).add({ y: 1 }), true), 'un an', '1 year = a year'); + assertEq(start.from(moment([2007, 1, 28]).add({ y: 5 }), true), '5 ans', '5 years = 5 years'); + }); + + it('suffix', function () { + assertEq(moment(30000).from(0), 'dans quelques secondes', 'prefix'); + assertEq(moment(0).from(30000), 'il y a quelques secondes', 'suffix'); + }); + + it('fromNow', function () { + assertEq(moment().add({ s: 30 }).fromNow(), 'dans quelques secondes', 'in a few seconds'); + assertEq(moment().add({ d: 5 }).fromNow(), 'dans 5 jours', 'in 5 days'); + }); + + it('same day', function () { + var a = moment().hours(12).minutes(0).seconds(0); + + assertEq(moment(a).calendar(), 'Aujourd’hui à 12:00', 'Today at the same time'); + assertEq(moment(a).add({ m: 25 }).calendar(), 'Aujourd’hui à 12:25', 'Now plus 25 min'); + assertEq(moment(a).add({ h: 1 }).calendar(), 'Aujourd’hui à 13:00', 'Now plus 1 hour'); + assertEq(moment(a).add({ d: 1 }).calendar(), 'Demain à 12:00', 'Tomorrow at the same time'); + assertEq(moment(a).subtract({ h: 1 }).calendar(), 'Aujourd’hui à 11:00', 'Now minus 1 hour'); + assertEq(moment(a).subtract({ d: 1 }).calendar(), 'Hier à 12:00', 'Yesterday at the same time'); + }); + + it('same next week', function () { + var i, m; + + for (i = 2; i < 7; i++) { + m = moment().add({ d: i }); + assertEq(m.calendar(), m.format('dddd [à] LT'), 'Today + ' + i + ' days current time'); + m.hours(0).minutes(0).seconds(0).milliseconds(0); + assertEq(m.calendar(), m.format('dddd [à] LT'), 'Today + ' + i + ' days beginning of day'); + m.hours(23).minutes(59).seconds(59).milliseconds(999); + assertEq(m.calendar(), m.format('dddd [à] LT'), 'Today + ' + i + ' days end of day'); + } + }); + + it('same last week', function () { + var i, m; + + for (i = 2; i < 7; i++) { + m = moment().subtract({ d: i }); + assertEq(m.calendar(), m.format('dddd [dernier à] LT'), 'Today - ' + i + ' days current time'); + m.hours(0).minutes(0).seconds(0).milliseconds(0); + assertEq(m.calendar(), m.format('dddd [dernier à] LT'), 'Today - ' + i + ' days beginning of day'); + m.hours(23).minutes(59).seconds(59).milliseconds(999); + assertEq(m.calendar(), m.format('dddd [dernier à] LT'), 'Today - ' + i + ' days end of day'); + } + }); + + it('same all else', function () { + var weeksAgo = moment().subtract({ w: 1 }), + weeksFromNow = moment().add({ w: 1 }); + + assertEq(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago'); + assertEq(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week'); + + weeksAgo = moment().subtract({ w: 2 }); + weeksFromNow = moment().add({ w: 2 }); + + assertEq(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago'); + assertEq(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks'); + }); + + it('weeks year starting sunday formatted', function () { + assertEq(moment([2012, 0, 1]).format('w ww wo'), '52 52 52e', 'Jan 1 2012 should be week 52'); + assertEq(moment([2012, 0, 2]).format('w ww wo'), '1 01 1re', 'Jan 2 2012 should be week 1'); + assertEq(moment([2012, 0, 8]).format('w ww wo'), '1 01 1re', 'Jan 8 2012 should be week 1'); + assertEq(moment([2012, 0, 9]).format('w ww wo'), '2 02 2e', 'Jan 9 2012 should be week 2'); + assertEq(moment([2012, 0, 15]).format('w ww wo'), '2 02 2e', 'Jan 15 2012 should be week 2'); + }); +}); diff --git a/src/locale/public_api.ts b/src/locale/public_api.ts index cde050c766..c3932ae907 100644 --- a/src/locale/public_api.ts +++ b/src/locale/public_api.ts @@ -12,6 +12,7 @@ export { esUsLocale } from 'ngx-bootstrap/chronos'; export { etLocale } from 'ngx-bootstrap/chronos'; export { fiLocale } from 'ngx-bootstrap/chronos'; export { frLocale } from 'ngx-bootstrap/chronos'; +export {frCaLocale} from 'ngx-bootstrap/chronos'; export { glLocale } from 'ngx-bootstrap/chronos'; export { heLocale } from 'ngx-bootstrap/chronos'; export { hiLocale } from 'ngx-bootstrap/chronos'; diff --git a/src/schematics/src/ng-add/index.ts b/src/schematics/src/ng-add/index.ts index d370565385..e1f37d7a41 100644 --- a/src/schematics/src/ng-add/index.ts +++ b/src/schematics/src/ng-add/index.ts @@ -6,9 +6,9 @@ * found in the LICENSE file at https://angular.io/license */ import { workspaces } from '@angular-devkit/core'; -import { Rule, SchematicContext, Tree } from '@angular-devkit/schematics'; +import { Rule, SchematicContext, SchematicsException, Tree } from '@angular-devkit/schematics'; import { NodePackageInstallTask } from '@angular-devkit/schematics/tasks'; -import { getAppModulePath } from '@schematics/angular/utility/ng-ast-utils'; +import { getAppModulePath, isStandaloneApp } from '@schematics/angular/utility/ng-ast-utils'; import { addModuleImportToRootModule, addPackageToPackageJson } from '../utils'; import { hasNgModuleImport } from '../utils/ng-module-imports'; import { getProjectMainFile } from '../utils/project-main-file'; @@ -85,6 +85,11 @@ function addModuleOfComponent(project: workspaces.ProjectDefinition, host: Tree, return; } + if (isStandaloneApp(host, getProjectMainFile(project))) { + throw new SchematicsException(`ngx-bootstrap doesn't support moduleless approach if we couldn't find + your starting *.module.ts learn more here https://valor-software.com/ngx-bootstrap/#/documentation#installation`); + } + const appModulePath = getAppModulePath(host, getProjectMainFile(project)); if (componentName && components[componentName]) { if (hasNgModuleImport(host, appModulePath, components[componentName].moduleName)) { diff --git a/src/schematics/src/utils/index.ts b/src/schematics/src/utils/index.ts index ecf5c8a097..e1486adf20 100644 --- a/src/schematics/src/utils/index.ts +++ b/src/schematics/src/utils/index.ts @@ -9,7 +9,7 @@ import { SchematicsException, Tree } from '@angular-devkit/schematics'; import { SchematicTestRunner, UnitTestTree } from '@angular-devkit/schematics/testing'; import { addImportToModule } from '@schematics/angular/utility/ast-utils'; import { Change, InsertChange } from '@schematics/angular/utility/change'; -import { getAppModulePath } from '@schematics/angular/utility/ng-ast-utils'; +import { getAppModulePath, isStandaloneApp } from '@schematics/angular/utility/ng-ast-utils'; import * as ts from 'typescript'; import { getProjectMainFile } from './project-main-file'; import { workspaces } from '@angular-devkit/core'; @@ -87,15 +87,16 @@ export function addModuleImportToRootModule( src: string, project: workspaces.ProjectDefinition ) { + if (isStandaloneApp(host, getProjectMainFile(project))) { + throw new SchematicsException(`ngx-bootstrap doesn't support moduleless approach if we couldn't find + your starting *.module.ts learn more here https://valor-software.com/ngx-bootstrap/#/documentation#installation`); + } + const modulePath = getAppModulePath(host, getProjectMainFile(project)); const moduleSource = getSourceFile(host, modulePath); if (!moduleSource) { throw new SchematicsException(`Module not found: ${modulePath}`); } - if (modulePath.includes('component')) { - throw new SchematicsException(`ngx-bootstrap doesn't support moduleless approach if we couldn't find - your starting *.module.ts learn more here https://valor-software.com/ngx-bootstrap/#/documentation#installation`); - } const changes: Change[] = addImportToModule(moduleSource, modulePath, moduleName, src); const recorder = host.beginUpdate(modulePath); From 2c7d6f01e55f92783b56214d41a1dec33bb4111c Mon Sep 17 00:00:00 2001 From: Alexey Umanskiy Date: Wed, 16 Oct 2024 13:36:18 +0300 Subject: [PATCH 08/14] feat(moduleless): migrating to standalone modules support (#6669) * feat(accordion): migrated to standalone * feat(accordion): migrated to standalone * feat(alert)): migrated to standalone * feat(buttons): migrated to standalone * feat(carousel): migrated to standalone * feat(collapse): migrated to standalone * feat(datepicker): migrated to standalone * fix(accordion): fixed tests * fix(accordion): fixed tests * fix(accordion): fixed tests * fix(accordion): fixed tests * fix(accordion): fixed tests * fix(carousel): fixed tests * feat(dropdown): added moduleless support * feat(focustrap): added moduleless support * feat(modal): added moduleless support * feat(pagination): added moduleless support * feat(popover): added moduleless support * feat(progressbar): added moduleless support * feat(rating): added moduleless support * feat(sortable): added moduleless support * feat(tabs): added moduleless support * feat(timepicker): added moduleless support * feat(timepicker): added moduleless support * feat(typeahead): added moduleless support * feat(typeahead): added moduleless support * fix(rating): tests ajust to moduleless * fix(progressbar): tests ajust to moduleless * chore(docs): added deprecations * chore(docs): updated documentation regarding standalone usage * chore(docs): updated documentation regarding standalone usage * fix(modal): fixed nested backdrop issue * 18.1.0 * chore(version): bumped version to 18.1.0 --- README.md | 2 +- apps/ngx-bootstrap-docs/src/app/app.module.ts | 2 +- .../src/assets/json/current-version.json | 2 +- .../schematics/schematics.component.html | 2 +- .../demo-examples-section/index.ts | 2 +- .../stackblitz/app.module.ts | 4 +- libs/common-docs/src/lib/docs.module.ts | 4 +- .../accordion/src/lib/accordion.module.ts | 2 +- .../doc-pages/accordion/src/lib/docs/usage.md | 20 ++++++++- .../doc-pages/alerts/src/lib/alerts.module.ts | 2 +- libs/doc-pages/alerts/src/lib/docs/usage.md | 13 +++++- .../buttons/src/lib/buttons.module.ts | 2 +- libs/doc-pages/buttons/src/lib/docs/usage.md | 15 ++++++- .../carousel/src/lib/carousel.module.ts | 2 +- libs/doc-pages/carousel/src/lib/docs/usage.md | 15 ++++++- .../collapse/src/lib/collapse.module.ts | 2 +- libs/doc-pages/collapse/src/lib/docs/usage.md | 18 +++++++- .../datepicker/src/lib/datepicker.module.ts | 4 +- .../src/lib/demo-datepicker.module.ts | 4 +- .../datepicker/src/lib/docs/usage.md | 18 +++++++- libs/doc-pages/dropdown/src/lib/docs/usage.md | 19 ++++++++- .../dropdown/src/lib/dropdown.module.ts | 2 +- libs/doc-pages/modal/src/lib/docs/usage.md | 14 ++++++- libs/doc-pages/modal/src/lib/modal.module.ts | 11 ++--- .../pagination/src/lib/docs/usage.md | 12 +++++- .../pagination/src/lib/pagination.module.ts | 2 +- libs/doc-pages/popover/src/lib/docs/usage.md | 12 +++++- .../popover/src/lib/popover.module.ts | 2 +- .../progressbar/src/lib/docs/usage.md | 12 +++++- .../progressbar/src/lib/progressbar.module.ts | 2 +- libs/doc-pages/rating/src/lib/docs/usage.md | 12 +++++- .../doc-pages/rating/src/lib/rating.module.ts | 2 +- libs/doc-pages/sortable/src/lib/docs/usage.md | 12 +++++- .../sortable/src/lib/sortable.module.ts | 2 +- libs/doc-pages/tabs/src/lib/docs/usage.md | 12 +++++- libs/doc-pages/tabs/src/lib/tabs.module.ts | 2 +- .../timepicker/src/lib/docs/usage.md | 12 +++++- .../timepicker/src/lib/timepicker.module.ts | 2 +- libs/doc-pages/tooltip/src/lib/docs/usage.md | 12 +++++- .../tooltip/src/lib/tooltip.module.ts | 2 +- .../doc-pages/typeahead/src/lib/docs/usage.md | 17 +++++++- .../typeahead/src/lib/typeahead.module.ts | 2 +- package-lock.json | 4 +- package.json | 2 +- src/accordion/accordion-group.component.ts | 20 +++++---- src/accordion/accordion.component.ts | 19 +++++---- src/accordion/accordion.module.ts | 14 +++---- src/accordion/package.json | 2 +- .../testing/accordion.component.spec.ts | 8 ++-- src/alert/alert.component.ts | 9 ++-- src/alert/alert.module.ts | 11 +++-- src/alert/package.json | 2 +- src/alert/testing/alert.component.spec.ts | 10 +++-- src/buttons/button-checkbox.directive.ts | 5 ++- src/buttons/button-radio-group.directive.ts | 5 ++- src/buttons/button-radio.directive.ts | 5 ++- src/buttons/buttons.module.ts | 11 ++--- src/buttons/package.json | 2 +- src/buttons/testing/button.directive.spec.ts | 13 +++--- src/carousel/carousel.component.ts | 8 ++-- src/carousel/carousel.module.ts | 13 +++--- src/carousel/package.json | 2 +- src/carousel/slide.component.ts | 19 +++++---- .../testing/carousel.component.spec.ts | 12 ++++-- src/chronos/package.json | 2 +- src/collapse/collapse.directive.ts | 13 +++--- src/collapse/collapse.module.ts | 11 ++--- src/collapse/package.json | 2 +- .../testing/collapse.directive.spec.ts | 16 ++++---- src/component-loader/package.json | 2 +- .../bs-datepicker-inline.component.ts | 6 ++- .../bs-datepicker-input.directive.ts | 9 +++- src/datepicker/bs-datepicker.component.ts | 6 ++- src/datepicker/bs-datepicker.module.ts | 33 ++++----------- .../bs-daterangepicker-inline.component.ts | 6 ++- .../bs-daterangepicker-input.directive.ts | 23 +++++++---- .../bs-daterangepicker.component.ts | 8 +++- src/datepicker/package.json | 2 +- .../bs-datepicker-day-decorator.spec.ts | 11 ++--- .../bs-datepicker-navigation-view.spec.ts | 13 +++--- .../testing/bs-datepicker-utils.spec.ts | 2 +- src/datepicker/testing/bs-datepicker.spec.ts | 18 ++++---- .../testing/bs-daterangepicker.spec.ts | 16 ++++---- .../bs-inline-datepicker-minmode-year.spec.ts | 17 ++++---- .../testing/bs-inline-datepicker.spec.ts | 17 ++++---- .../testing/bs-inline-daterangepicker.spec.ts | 18 ++++---- .../themes/bs/bs-calendar-layout.component.ts | 11 +++-- .../bs/bs-current-date-view.component.ts | 5 ++- .../bs/bs-custom-dates-view.component.ts | 9 ++-- .../bs/bs-datepicker-container.component.ts | 30 +++++++++----- .../bs-datepicker-day-decorator.directive.ts | 27 ++++++------ ...s-datepicker-inline-container.component.ts | 22 ++++++---- ...bs-datepicker-navigation-view.component.ts | 11 +++-- .../bs-daterangepicker-container.component.ts | 41 ++++++++++++++----- ...erangepicker-inline-container.component.ts | 22 ++++++---- .../bs/bs-days-calendar-view.component.ts | 15 +++++-- .../bs/bs-months-calendar-view.component.ts | 11 +++-- .../themes/bs/bs-timepicker-view.component.ts | 7 ++-- .../bs/bs-years-calendar-view.component.ts | 11 +++-- .../bs-dropdown-container.component.ts | 6 ++- src/dropdown/bs-dropdown-menu.directive.ts | 3 +- src/dropdown/bs-dropdown-toggle.directive.ts | 3 +- src/dropdown/bs-dropdown.directive.ts | 3 +- src/dropdown/bs-dropdown.module.ts | 29 ++++--------- src/dropdown/package.json | 2 +- .../bs-dropdown-container.component.spec.ts | 2 +- .../testing/bs-dropdown.directive.spec.ts | 2 +- src/focus-trap/focus-trap.module.ts | 22 +++------- src/focus-trap/focus-trap.ts | 12 +++++- src/focus-trap/package.json | 2 +- src/locale/package.json | 2 +- src/mini-ngrx/package.json | 2 +- src/modal/bs-modal.service.ts | 5 +++ src/modal/modal-backdrop.component.ts | 9 ++-- src/modal/modal-container.component.ts | 26 +++++++----- src/modal/modal.directive.ts | 5 ++- src/modal/modal.module.ts | 21 +++++----- src/modal/package.json | 2 +- .../testing/modal-backdrop.component.spec.ts | 4 +- .../testing/modal.default-setting.spec.ts | 2 +- src/modal/testing/modal.service.spec.ts | 2 +- src/pagination/package.json | 2 +- src/pagination/pager.component.ts | 9 ++-- src/pagination/pagination.component.ts | 9 ++-- src/pagination/pagination.module.ts | 12 +++--- .../testing/pager.component.spec.ts | 2 +- .../testing/pagination.component.spec.ts | 2 +- src/popover/package.json | 2 +- src/popover/popover-container.component.ts | 34 +++++++-------- src/popover/popover.directive.ts | 7 +++- src/popover/popover.module.ts | 15 +++---- src/positioning/package.json | 2 +- src/progressbar/bar.component.ts | 33 +++++++-------- src/progressbar/package.json | 2 +- src/progressbar/progressbar.component.ts | 24 ++++++----- src/progressbar/progressbar.module.ts | 13 +++--- .../testing/progressbar.component.spec.ts | 14 +++---- src/rating/package.json | 2 +- src/rating/rating.component.ts | 11 +++-- src/rating/rating.module.ts | 16 +++----- src/rating/testing/rating.component.spec.ts | 6 +-- src/root/README.md | 2 +- src/root/package.json | 2 +- src/schematics/package.json | 2 +- .../utils/current_dependency_versions.json | 2 +- src/sortable/package.json | 2 +- src/sortable/sortable.component.ts | 24 ++++++----- src/sortable/sortable.module.ts | 14 +++---- .../testing/draggable-item.service.spec.ts | 9 ++-- .../testing/sortable.component.spec.ts | 13 +++--- src/tabs/ng-transclude.directive.ts | 3 +- src/tabs/package.json | 2 +- src/tabs/tab-heading.directive.ts | 5 ++- src/tabs/tab.directive.ts | 5 ++- src/tabs/tabs.module.ts | 31 ++++++-------- src/tabs/tabset.component.ts | 10 +++-- src/tabs/testing/tabset.component.spec.ts | 2 +- src/timepicker/package.json | 2 +- .../testing/timepicker.component.spec.ts | 2 +- src/timepicker/timepicker.component.ts | 15 ++++--- src/timepicker/timepicker.module.ts | 19 +++------ src/tooltip/package.json | 2 +- src/tooltip/testing/tooltip.directive.spec.ts | 2 +- src/tooltip/tooltip-container.component.ts | 28 ++++++------- src/tooltip/tooltip.directive.ts | 8 +++- src/tooltip/tooltip.module.ts | 15 +++---- src/typeahead/package.json | 2 +- .../typeahead-container.component.spec.ts | 3 +- .../testing/typeahead.directive.spec.ts | 7 ++-- .../typeahead-container.component.ts | 34 ++++++++------- src/typeahead/typeahead.directive.ts | 21 ++++++---- src/typeahead/typeahead.module.ts | 15 +++---- src/utils/package.json | 2 +- 173 files changed, 1005 insertions(+), 664 deletions(-) diff --git a/README.md b/README.md index bdff34ff81..0230c075ff 100644 --- a/README.md +++ b/README.md @@ -106,7 +106,7 @@ import { TooltipModule } from 'ngx-bootstrap/tooltip'; @NgModule({ ... - imports: [TooltipModule.forRoot(),...] + imports: [TooltipModule,...] ... }) ``` diff --git a/apps/ngx-bootstrap-docs/src/app/app.module.ts b/apps/ngx-bootstrap-docs/src/app/app.module.ts index 92a30bc309..fcc97e640f 100644 --- a/apps/ngx-bootstrap-docs/src/app/app.module.ts +++ b/apps/ngx-bootstrap-docs/src/app/app.module.ts @@ -16,7 +16,7 @@ import { routes } from './app.routing'; bootstrap: [AppComponent], imports: [BrowserAnimationsModule, DocsModule, RouterModule.forRoot(routes, { useHash: environment.useHash }), - BsDropdownModule.forRoot()], providers: [ + BsDropdownModule], providers: [ { provide: NgApiDoc, useValue: ngdoc }, { provide: DOCS_TOKENS, useValue: routes }, { provide: SIDEBAR_ROUTES, useValue: SidebarRoutesStructure }, diff --git a/apps/ngx-bootstrap-docs/src/assets/json/current-version.json b/apps/ngx-bootstrap-docs/src/assets/json/current-version.json index 51e97297c7..468bce7d10 100644 --- a/apps/ngx-bootstrap-docs/src/assets/json/current-version.json +++ b/apps/ngx-bootstrap-docs/src/assets/json/current-version.json @@ -1,3 +1,3 @@ { - "version": "18.0.2" + "version": "18.1.0" } diff --git a/libs/common-docs/src/lib/common/schematics/schematics.component.html b/libs/common-docs/src/lib/common/schematics/schematics.component.html index e3c89fbff3..bee3230604 100644 --- a/libs/common-docs/src/lib/common/schematics/schematics.component.html +++ b/libs/common-docs/src/lib/common/schematics/schematics.component.html @@ -138,7 +138,7 @@

Schematics

], imports: [ - AccordionModule.forRoot(), + AccordionModule, ], bootstrap: [AppComponent] {{'}'}}) diff --git a/libs/common-docs/src/lib/demo-section-components/demo-examples-section/index.ts b/libs/common-docs/src/lib/demo-section-components/demo-examples-section/index.ts index ba874f9e36..916aa27eb2 100644 --- a/libs/common-docs/src/lib/demo-section-components/demo-examples-section/index.ts +++ b/libs/common-docs/src/lib/demo-section-components/demo-examples-section/index.ts @@ -20,7 +20,7 @@ export { ExamplesComponent } from './examples.component'; CommonModule, NgApiDocModule, RouterModule, - TabsModule.forRoot(), + TabsModule, ], exports: [ ExamplesComponent, diff --git a/libs/common-docs/src/lib/demo-section-components/demo-examples-section/stackblitz/app.module.ts b/libs/common-docs/src/lib/demo-section-components/demo-examples-section/stackblitz/app.module.ts index bcc6c66c87..99d8fbfde8 100644 --- a/libs/common-docs/src/lib/demo-section-components/demo-examples-section/stackblitz/app.module.ts +++ b/libs/common-docs/src/lib/demo-section-components/demo-examples-section/stackblitz/app.module.ts @@ -25,8 +25,8 @@ import { ${className === 'DemoModalServiceFromComponent' ? `${className}, ModalC declarations: [${className === 'DemoModalServiceFromComponent' ? `${className}, ModalContentComponent` : className}], imports: [ ${moduleData.moduleName}.forRoot(), - ${className === 'DemoModalWithPopupsComponent' ? `TooltipModule.forRoot(), - PopoverModule.forRoot(),` : ''} + ${className === 'DemoModalWithPopupsComponent' ? `TooltipModule, + PopoverModule,` : ''} BrowserAnimationsModule, CommonModule, FormsModule, diff --git a/libs/common-docs/src/lib/docs.module.ts b/libs/common-docs/src/lib/docs.module.ts index c5ebec82ef..63d909c472 100644 --- a/libs/common-docs/src/lib/docs.module.ts +++ b/libs/common-docs/src/lib/docs.module.ts @@ -79,8 +79,8 @@ export { ThemesComponent } from './common/themes/themes.component'; NgApiDocModule, ExamplesComponentModule, ApiSectionsComponentModule, - TabsModule.forRoot(), - BsDropdownModule.forRoot(), + TabsModule, + BsDropdownModule, RouterModule ], exports: [ diff --git a/libs/doc-pages/accordion/src/lib/accordion.module.ts b/libs/doc-pages/accordion/src/lib/accordion.module.ts index 8cdc8ced3e..06e856a2d8 100644 --- a/libs/doc-pages/accordion/src/lib/accordion.module.ts +++ b/libs/doc-pages/accordion/src/lib/accordion.module.ts @@ -17,7 +17,7 @@ export { AccordionSectionComponent } from './accordion-section.component'; ...DEMO_COMPONENTS ], imports: [ - AccordionModule.forRoot(), + AccordionModule, CommonModule, FormsModule, DocsModule, diff --git a/libs/doc-pages/accordion/src/lib/docs/usage.md b/libs/doc-pages/accordion/src/lib/docs/usage.md index 7f803207de..e27b73912e 100644 --- a/libs/doc-pages/accordion/src/lib/docs/usage.md +++ b/libs/doc-pages/accordion/src/lib/docs/usage.md @@ -1,3 +1,21 @@ +### Standalone component usage +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; + +import { AccordionComponent, AccordionPanelComponent } from 'ngx-bootstrap/accordion'; + +@Component({ + standalone: true, + imports: [ + BrowserAnimationsModule, + AccordionComponent, + AccordionPanelComponent + ... + ] +}) +export class AppComponent(){} + +Also should be added web-animations-js polyfill for IE browser (Edge) +### Module usage import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { AccordionModule } from 'ngx-bootstrap/accordion'; @@ -5,7 +23,7 @@ import { AccordionModule } from 'ngx-bootstrap/accordion'; @NgModule({ imports: [ BrowserAnimationsModule, - AccordionModule.forRoot(), + AccordionModule, ... ] }) diff --git a/libs/doc-pages/alerts/src/lib/alerts.module.ts b/libs/doc-pages/alerts/src/lib/alerts.module.ts index 61b8bfe9ae..b706ee6b07 100644 --- a/libs/doc-pages/alerts/src/lib/alerts.module.ts +++ b/libs/doc-pages/alerts/src/lib/alerts.module.ts @@ -15,7 +15,7 @@ export { AlertsSectionComponent } from './alerts-section.component'; ...DEMO_COMPONENTS ], imports: [ - AlertModule.forRoot(), + AlertModule, CommonModule, DocsModule, RouterModule.forChild(routes) diff --git a/libs/doc-pages/alerts/src/lib/docs/usage.md b/libs/doc-pages/alerts/src/lib/docs/usage.md index 9377ee9726..2538714a2d 100644 --- a/libs/doc-pages/alerts/src/lib/docs/usage.md +++ b/libs/doc-pages/alerts/src/lib/docs/usage.md @@ -1,6 +1,17 @@ +### Standalone component usage +import { AlertComponent } from 'ngx-bootstrap/alert'; + +@Components({ + standalone: true, + imports: [AlertComponent,...] +}) +export class AppComponent(){} + + +### Module usage import { AlertModule } from 'ngx-bootstrap/alert'; @NgModule({ - imports: [AlertModule.forRoot(),...] + imports: [AlertModule,...] }) export class AppModule(){} diff --git a/libs/doc-pages/buttons/src/lib/buttons.module.ts b/libs/doc-pages/buttons/src/lib/buttons.module.ts index f5c2d6ce69..dc843fcb4e 100644 --- a/libs/doc-pages/buttons/src/lib/buttons.module.ts +++ b/libs/doc-pages/buttons/src/lib/buttons.module.ts @@ -22,7 +22,7 @@ export { ButtonsSectionComponent } from './buttons-section.component'; CommonModule, DocsModule, RouterModule.forChild(routes), - ButtonsModule.forRoot() + ButtonsModule ], exports: [ButtonsSectionComponent] }) diff --git a/libs/doc-pages/buttons/src/lib/docs/usage.md b/libs/doc-pages/buttons/src/lib/docs/usage.md index e2f35603f9..1dcb59c41d 100644 --- a/libs/doc-pages/buttons/src/lib/docs/usage.md +++ b/libs/doc-pages/buttons/src/lib/docs/usage.md @@ -1,6 +1,19 @@ +### Standalone component usage +import { ButtonsModule } from 'ngx-bootstrap/buttons'; + +@Component({ + imports: [ + ButtonsModule, + ... + ] +}) +export class AppComponent(){} + + +### Module usage import { ButtonsModule } from 'ngx-bootstrap/buttons'; @NgModule({ - imports: [ButtonsModule.forRoot(),...] + imports: [ButtonsModule,...] }) export class AppModule(){} diff --git a/libs/doc-pages/carousel/src/lib/carousel.module.ts b/libs/doc-pages/carousel/src/lib/carousel.module.ts index 331b263cce..b25d084e33 100644 --- a/libs/doc-pages/carousel/src/lib/carousel.module.ts +++ b/libs/doc-pages/carousel/src/lib/carousel.module.ts @@ -16,7 +16,7 @@ export { CarouselSectionComponent } from './carousel-section.component'; ...DEMO_COMPONENTS ], imports: [ - CarouselModule.forRoot(), + CarouselModule, CommonModule, FormsModule, DocsModule, diff --git a/libs/doc-pages/carousel/src/lib/docs/usage.md b/libs/doc-pages/carousel/src/lib/docs/usage.md index 771bca859f..c08c4f3ac1 100644 --- a/libs/doc-pages/carousel/src/lib/docs/usage.md +++ b/libs/doc-pages/carousel/src/lib/docs/usage.md @@ -1,6 +1,19 @@ +### Standalone component usage +import { CarouselModule } from 'ngx-bootstrap/carousel'; + +@Component({ + imports: [ + CarouselModule, + ... +] +}) +export class AppComponent(){} + + +### Module usage import { CarouselModule } from 'ngx-bootstrap/carousel'; @NgModule({ - imports: [CarouselModule.forRoot(),...] + imports: [CarouselModule,...] }) export class AppModule(){} diff --git a/libs/doc-pages/collapse/src/lib/collapse.module.ts b/libs/doc-pages/collapse/src/lib/collapse.module.ts index 0608a8280a..3fc120c352 100644 --- a/libs/doc-pages/collapse/src/lib/collapse.module.ts +++ b/libs/doc-pages/collapse/src/lib/collapse.module.ts @@ -17,7 +17,7 @@ export { CollapseSectionComponent } from './collapse-section.component'; ...DEMO_COMPONENTS ], imports: [ - CollapseModule.forRoot(), + CollapseModule, CommonModule, FormsModule, DocsModule, diff --git a/libs/doc-pages/collapse/src/lib/docs/usage.md b/libs/doc-pages/collapse/src/lib/docs/usage.md index 0a93782a8d..9294e7d0c8 100644 --- a/libs/doc-pages/collapse/src/lib/docs/usage.md +++ b/libs/doc-pages/collapse/src/lib/docs/usage.md @@ -1,3 +1,19 @@ +### Standalone component usage +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; + +import { CollapseDirective } from 'ngx-bootstrap/collapse'; + +@Component({ + imports: [ + BrowserAnimationsModule, + CollapseDirective, + ... + ] +}) +export class AppComponent(){} + + +### Module usage import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { CollapseModule } from 'ngx-bootstrap/collapse'; @@ -5,7 +21,7 @@ import { CollapseModule } from 'ngx-bootstrap/collapse'; @NgModule({ imports: [ BrowserAnimationsModule, - CollapseModule.forRoot(), + CollapseModule, ... ] }) diff --git a/libs/doc-pages/datepicker/src/lib/datepicker.module.ts b/libs/doc-pages/datepicker/src/lib/datepicker.module.ts index 2fadc6ba23..35920e95b0 100644 --- a/libs/doc-pages/datepicker/src/lib/datepicker.module.ts +++ b/libs/doc-pages/datepicker/src/lib/datepicker.module.ts @@ -43,8 +43,8 @@ locales.forEach((locale: LocaleData) => { ...DEMO_COMPONENTS ], imports: [ - BsDatepickerModule.forRoot(), - TabsModule.forRoot(), + BsDatepickerModule, + TabsModule, CommonModule, FormsModule, ReactiveFormsModule, diff --git a/libs/doc-pages/datepicker/src/lib/demo-datepicker.module.ts b/libs/doc-pages/datepicker/src/lib/demo-datepicker.module.ts index 2fc35ba559..4c6894e684 100644 --- a/libs/doc-pages/datepicker/src/lib/demo-datepicker.module.ts +++ b/libs/doc-pages/datepicker/src/lib/demo-datepicker.module.ts @@ -41,8 +41,8 @@ locales.forEach((locale: LocaleData) => { ...DEMO_COMPONENTS ], imports: [ - BsDatepickerModule.forRoot(), - TabsModule.forRoot(), + BsDatepickerModule, + TabsModule, CommonModule, FormsModule, ReactiveFormsModule, diff --git a/libs/doc-pages/datepicker/src/lib/docs/usage.md b/libs/doc-pages/datepicker/src/lib/docs/usage.md index a2799ce796..dbd68f24fd 100644 --- a/libs/doc-pages/datepicker/src/lib/docs/usage.md +++ b/libs/doc-pages/datepicker/src/lib/docs/usage.md @@ -1,3 +1,19 @@ +### Standalone component usage +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; + +import { BsDatepickerModule } from 'ngx-bootstrap/datepicker'; + +@Components({ + imports: [ + BrowserAnimationsModule, + BsDatepickerModule, + ... + ] +}) +export class AppComponents(){} + + +### Module usage import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { BsDatepickerModule } from 'ngx-bootstrap/datepicker'; @@ -5,7 +21,7 @@ import { BsDatepickerModule } from 'ngx-bootstrap/datepicker'; @NgModule({ imports: [ BrowserAnimationsModule, - BsDatepickerModule.forRoot(), + BsDatepickerModule, ... ] }) diff --git a/libs/doc-pages/dropdown/src/lib/docs/usage.md b/libs/doc-pages/dropdown/src/lib/docs/usage.md index da282ecc1b..d553ac89b7 100644 --- a/libs/doc-pages/dropdown/src/lib/docs/usage.md +++ b/libs/doc-pages/dropdown/src/lib/docs/usage.md @@ -1,3 +1,20 @@ +### Standalone component usage +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; + +import { BsDropdownModule } from 'ngx-bootstrap/datepicker'; + +@Components({ + standalone: true, + imports: [ + BrowserAnimationsModule, + BsDropdownModule, + ... + ] +}) +export class AppComponents(){} + + +### Module usage import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { BsDropdownModule } from 'ngx-bootstrap/dropdown'; @@ -5,7 +22,7 @@ import { BsDropdownModule } from 'ngx-bootstrap/dropdown'; @NgModule({ imports: [ BrowserAnimationsModule, - BsDropdownModule.forRoot() + BsDropdownModule ] }) export class AppModule(){} diff --git a/libs/doc-pages/dropdown/src/lib/dropdown.module.ts b/libs/doc-pages/dropdown/src/lib/dropdown.module.ts index 008a79d149..5e80244baf 100644 --- a/libs/doc-pages/dropdown/src/lib/dropdown.module.ts +++ b/libs/doc-pages/dropdown/src/lib/dropdown.module.ts @@ -17,7 +17,7 @@ export { DropdownSectionComponent } from './dropdown-section.component'; ...DEMO_COMPONENTS ], imports: [ - BsDropdownModule.forRoot(), + BsDropdownModule, CommonModule, FormsModule, DocsModule, diff --git a/libs/doc-pages/modal/src/lib/docs/usage.md b/libs/doc-pages/modal/src/lib/docs/usage.md index 179a43940c..15a3beadd5 100644 --- a/libs/doc-pages/modal/src/lib/docs/usage.md +++ b/libs/doc-pages/modal/src/lib/docs/usage.md @@ -1,6 +1,18 @@ +### Standalone component usage +import { ModalModule, BsModalService } from 'ngx-bootstrap/modal'; + +@Component({ + standalone: true, + imports: [ModalModule,...], // module can be optional + providers: [BsModalService] +}) +export class AppComponent(){} + +### Module usage import { ModalModule } from 'ngx-bootstrap/modal'; @NgModule({ - imports: [ModalModule.forRoot(),...] + imports: [ModalModule,...], + providers: [BsModalService] }) export class AppModule(){} diff --git a/libs/doc-pages/modal/src/lib/modal.module.ts b/libs/doc-pages/modal/src/lib/modal.module.ts index cb0498270f..cad8420865 100644 --- a/libs/doc-pages/modal/src/lib/modal.module.ts +++ b/libs/doc-pages/modal/src/lib/modal.module.ts @@ -2,7 +2,7 @@ import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { FormsModule } from '@angular/forms'; import { RouterModule } from '@angular/router'; -import { ModalModule } from 'ngx-bootstrap/modal'; +import { BsModalService, ModalModule } from 'ngx-bootstrap/modal'; import { DocsModule } from '@ngx-bootstrap-doc/docs'; import { ModalSectionComponent } from './modal-section.component'; @@ -24,14 +24,15 @@ export { ModalSectionComponent } from './modal-section.component'; ...DEMO_COMPONENTS ], imports: [ - ModalModule.forRoot(), - PopoverModule.forRoot(), - TooltipModule.forRoot(), + ModalModule, + PopoverModule, + TooltipModule, CommonModule, FormsModule, DocsModule, RouterModule.forChild(routes) ], - exports: [ModalSectionComponent] + exports: [ModalSectionComponent], + providers: [BsModalService] }) export class DemoModalModule {} diff --git a/libs/doc-pages/pagination/src/lib/docs/usage.md b/libs/doc-pages/pagination/src/lib/docs/usage.md index 07f1cbb7ee..6e87078c94 100644 --- a/libs/doc-pages/pagination/src/lib/docs/usage.md +++ b/libs/doc-pages/pagination/src/lib/docs/usage.md @@ -1,6 +1,16 @@ +### Standalone component usage +import { PaginationModule } from 'ngx-bootstrap/pagination'; + +@Component({ + standalone: true, + imports: [PaginationModule,...], +}) +export class AppComponent(){} + +### Module usage import { PaginationModule } from 'ngx-bootstrap/pagination'; @NgModule({ - imports: [PaginationModule.forRoot(),...] + imports: [PaginationModule,...] }) export class AppModule(){} diff --git a/libs/doc-pages/pagination/src/lib/pagination.module.ts b/libs/doc-pages/pagination/src/lib/pagination.module.ts index 1b1fb1900b..10b7ce1c2d 100644 --- a/libs/doc-pages/pagination/src/lib/pagination.module.ts +++ b/libs/doc-pages/pagination/src/lib/pagination.module.ts @@ -17,7 +17,7 @@ export { PaginationSectionComponent } from './pagination-section.component'; ...DEMO_COMPONENTS ], imports: [ - PaginationModule.forRoot(), + PaginationModule, CommonModule, FormsModule, DocsModule, diff --git a/libs/doc-pages/popover/src/lib/docs/usage.md b/libs/doc-pages/popover/src/lib/docs/usage.md index 249cf11056..8fcd116a33 100644 --- a/libs/doc-pages/popover/src/lib/docs/usage.md +++ b/libs/doc-pages/popover/src/lib/docs/usage.md @@ -1,6 +1,16 @@ +### Standalone component usage +import { PopoverModule } from 'ngx-bootstrap/popover'; + +@Component({ + standalone: true, + imports: [PopoverModule,...] +}) +export class AppComponent(){} + +### Module usage import { PopoverModule } from 'ngx-bootstrap/popover'; @NgModule({ - imports: [PopoverModule.forRoot(),...] + imports: [PopoverModule,...] }) export class AppModule(){} diff --git a/libs/doc-pages/popover/src/lib/popover.module.ts b/libs/doc-pages/popover/src/lib/popover.module.ts index 29db72567b..a4993a19df 100644 --- a/libs/doc-pages/popover/src/lib/popover.module.ts +++ b/libs/doc-pages/popover/src/lib/popover.module.ts @@ -20,7 +20,7 @@ export { PopoverSectionComponent } from './popover-section.component'; CommonModule, FormsModule, DocsModule, - PopoverModule.forRoot(), + PopoverModule, RouterModule.forChild(routes) ], exports: [PopoverSectionComponent] diff --git a/libs/doc-pages/progressbar/src/lib/docs/usage.md b/libs/doc-pages/progressbar/src/lib/docs/usage.md index 4e07857dcf..cfd43bec3e 100644 --- a/libs/doc-pages/progressbar/src/lib/docs/usage.md +++ b/libs/doc-pages/progressbar/src/lib/docs/usage.md @@ -1,6 +1,16 @@ +### Standalone component usage +import { ProgressbarModule } from 'ngx-bootstrap/progressbar'; + +@Component({ + standalone: true, + imports: [ProgressbarModule,...] +}) +export class AppComponent(){} + +### Module usage import { ProgressbarModule } from 'ngx-bootstrap/progressbar'; @NgModule({ - imports: [ProgressbarModule.forRoot(),...] + imports: [ProgressbarModule,...] }) export class AppModule(){} diff --git a/libs/doc-pages/progressbar/src/lib/progressbar.module.ts b/libs/doc-pages/progressbar/src/lib/progressbar.module.ts index 3fa7493cca..9de9163afa 100644 --- a/libs/doc-pages/progressbar/src/lib/progressbar.module.ts +++ b/libs/doc-pages/progressbar/src/lib/progressbar.module.ts @@ -20,7 +20,7 @@ export { ProgressbarSectionComponent } from './progressbar-section.component'; CommonModule, FormsModule, DocsModule, - ProgressbarModule.forRoot(), + ProgressbarModule, RouterModule.forChild(routes) ], exports: [ProgressbarSectionComponent] diff --git a/libs/doc-pages/rating/src/lib/docs/usage.md b/libs/doc-pages/rating/src/lib/docs/usage.md index 5d87d36b73..a3c6fce690 100644 --- a/libs/doc-pages/rating/src/lib/docs/usage.md +++ b/libs/doc-pages/rating/src/lib/docs/usage.md @@ -1,6 +1,16 @@ +### Standalone component usage +import { RatingModule } from 'ngx-bootstrap/rating'; + +@Component({ + standalone: true, + imports: [RatingModule,...] +}) +export class AppComponent(){} + +### Module usage import { RatingModule } from 'ngx-bootstrap/rating'; @NgModule({ - imports: [RatingModule.forRoot(),...] + imports: [RatingModule,...] }) export class AppModule(){} diff --git a/libs/doc-pages/rating/src/lib/rating.module.ts b/libs/doc-pages/rating/src/lib/rating.module.ts index b6d50d84d5..6c5977037f 100644 --- a/libs/doc-pages/rating/src/lib/rating.module.ts +++ b/libs/doc-pages/rating/src/lib/rating.module.ts @@ -20,7 +20,7 @@ export { RatingSectionComponent } from './rating-section.component'; CommonModule, FormsModule, DocsModule, - RatingModule.forRoot(), + RatingModule, RouterModule.forChild(routes) ], exports: [RatingSectionComponent] diff --git a/libs/doc-pages/sortable/src/lib/docs/usage.md b/libs/doc-pages/sortable/src/lib/docs/usage.md index 9e361d631d..fcb9091a9a 100644 --- a/libs/doc-pages/sortable/src/lib/docs/usage.md +++ b/libs/doc-pages/sortable/src/lib/docs/usage.md @@ -1,6 +1,16 @@ +### Standalone component usage +import { SortableModule } from 'ngx-bootstrap/sortable'; + +@Component({ + standalone: true, + imports: [SortableModule,...] +}) +export class AppComponent(){} + +### Module usage import { SortableModule } from 'ngx-bootstrap/sortable'; @NgModule({ - imports: [SortableModule.forRoot(),...] + imports: [SortableModule,...] }) export class AppModule(){} diff --git a/libs/doc-pages/sortable/src/lib/sortable.module.ts b/libs/doc-pages/sortable/src/lib/sortable.module.ts index 3f0c51ff49..0d0c837d25 100644 --- a/libs/doc-pages/sortable/src/lib/sortable.module.ts +++ b/libs/doc-pages/sortable/src/lib/sortable.module.ts @@ -20,7 +20,7 @@ export { SortableSectionComponent } from './sortable-section.component'; CommonModule, FormsModule, DocsModule, - SortableModule.forRoot(), + SortableModule, RouterModule.forChild(routes) ], exports: [SortableSectionComponent] diff --git a/libs/doc-pages/tabs/src/lib/docs/usage.md b/libs/doc-pages/tabs/src/lib/docs/usage.md index 338fa69b36..2bac90e16f 100644 --- a/libs/doc-pages/tabs/src/lib/docs/usage.md +++ b/libs/doc-pages/tabs/src/lib/docs/usage.md @@ -1,6 +1,16 @@ +### Standalone component usage +import { TabsModule } from 'ngx-bootstrap/tabs'; + +@Component({ + standalone: true, + imports: [TabsModule,...] +}) +export class AppComponent(){} + +### Module usage import { TabsModule } from 'ngx-bootstrap/tabs'; @NgModule({ - imports: [TabsModule.forRoot(),...] + imports: [TabsModule,...] }) export class AppModule(){} diff --git a/libs/doc-pages/tabs/src/lib/tabs.module.ts b/libs/doc-pages/tabs/src/lib/tabs.module.ts index 595e725bb3..68824a2545 100644 --- a/libs/doc-pages/tabs/src/lib/tabs.module.ts +++ b/libs/doc-pages/tabs/src/lib/tabs.module.ts @@ -20,7 +20,7 @@ export { TabsSectionComponent } from './tabs-section.component'; CommonModule, FormsModule, DocsModule, - TabsModule.forRoot(), + TabsModule, RouterModule.forChild(routes) ], exports: [TabsSectionComponent] diff --git a/libs/doc-pages/timepicker/src/lib/docs/usage.md b/libs/doc-pages/timepicker/src/lib/docs/usage.md index 1ccef910f7..3a4b5b8c2b 100644 --- a/libs/doc-pages/timepicker/src/lib/docs/usage.md +++ b/libs/doc-pages/timepicker/src/lib/docs/usage.md @@ -1,6 +1,16 @@ +### Standalone component usage +import { TimepickerModule } from 'ngx-bootstrap/timepicker'; + +@Component({ + standalone: true, + imports: [TimepickerModule,...] +}) +export class AppComponent(){} + +### Module usage import { TimepickerModule } from 'ngx-bootstrap/timepicker'; @NgModule({ - imports: [TimepickerModule.forRoot(),...] + imports: [TimepickerModule,...] }) export class AppModule(){} diff --git a/libs/doc-pages/timepicker/src/lib/timepicker.module.ts b/libs/doc-pages/timepicker/src/lib/timepicker.module.ts index 2079b441cb..85bdf36048 100644 --- a/libs/doc-pages/timepicker/src/lib/timepicker.module.ts +++ b/libs/doc-pages/timepicker/src/lib/timepicker.module.ts @@ -21,7 +21,7 @@ export { TimepickerSectionComponent } from './timepicker-section.component'; FormsModule, ReactiveFormsModule, DocsModule, - TimepickerModule.forRoot(), + TimepickerModule, RouterModule.forChild(routes) ], exports: [TimepickerSectionComponent] diff --git a/libs/doc-pages/tooltip/src/lib/docs/usage.md b/libs/doc-pages/tooltip/src/lib/docs/usage.md index f35fe98d1d..c89ad98ffc 100644 --- a/libs/doc-pages/tooltip/src/lib/docs/usage.md +++ b/libs/doc-pages/tooltip/src/lib/docs/usage.md @@ -1,6 +1,16 @@ +### Standalone component usage +import { TooltipModule } from 'ngx-bootstrap/timepicker'; + +@Component({ + standalone: true, + imports: [TooltipModule,...] +}) +export class AppComponent(){} + +### Module usage import { TooltipModule } from 'ngx-bootstrap/tooltip'; @NgModule({ - imports: [TooltipModule.forRoot(),...] + imports: [TooltipModule,...] }) export class AppModule(){} diff --git a/libs/doc-pages/tooltip/src/lib/tooltip.module.ts b/libs/doc-pages/tooltip/src/lib/tooltip.module.ts index 8ee443d1b1..a63adde26f 100644 --- a/libs/doc-pages/tooltip/src/lib/tooltip.module.ts +++ b/libs/doc-pages/tooltip/src/lib/tooltip.module.ts @@ -20,7 +20,7 @@ export { TooltipSectionComponent } from './tooltip-section.component'; CommonModule, FormsModule, DocsModule, - TooltipModule.forRoot(), + TooltipModule, RouterModule.forChild(routes) ], exports: [TooltipSectionComponent] diff --git a/libs/doc-pages/typeahead/src/lib/docs/usage.md b/libs/doc-pages/typeahead/src/lib/docs/usage.md index 843de6f716..5a7c9bb6b7 100644 --- a/libs/doc-pages/typeahead/src/lib/docs/usage.md +++ b/libs/doc-pages/typeahead/src/lib/docs/usage.md @@ -1,3 +1,18 @@ +### Standalone component usage +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; + +import { TypeaheadModule } from 'ngx-bootstrap/typeahead'; +@Component({ + standalone: true, + imports: [ + BrowserAnimationsModule, + TypeaheadModule, + ... + ] +}) +export class AppComponent(){} + +### Module usage import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { TypeaheadModule } from 'ngx-bootstrap/typeahead'; @@ -5,7 +20,7 @@ import { TypeaheadModule } from 'ngx-bootstrap/typeahead'; @NgModule({ imports: [ BrowserAnimationsModule, - TypeaheadModule.forRoot(), + TypeaheadModule, ... ] }) diff --git a/libs/doc-pages/typeahead/src/lib/typeahead.module.ts b/libs/doc-pages/typeahead/src/lib/typeahead.module.ts index e7c76c37c9..0a8ea17691 100644 --- a/libs/doc-pages/typeahead/src/lib/typeahead.module.ts +++ b/libs/doc-pages/typeahead/src/lib/typeahead.module.ts @@ -21,7 +21,7 @@ export { TypeaheadSectionComponent } from './typeahead-section.component'; FormsModule, ReactiveFormsModule, DocsModule, - TypeaheadModule.forRoot(), + TypeaheadModule, RouterModule.forChild(routes) ], exports: [TypeaheadSectionComponent] diff --git a/package-lock.json b/package-lock.json index 786605b43e..d64369dc7a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "ngx-bootstrap-base", - "version": "18.0.2", + "version": "18.1.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "ngx-bootstrap-base", - "version": "18.0.2", + "version": "18.1.0", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index b40b6ebd27..65ed365e53 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap-base", - "version": "18.0.2", + "version": "18.1.0", "license": "MIT", "author": "Dmitriy Shekhovtsov ", "schematics": "./schematics/src/collection.json", diff --git a/src/accordion/accordion-group.component.ts b/src/accordion/accordion-group.component.ts index f0dbc8ecd7..20e01f29a4 100644 --- a/src/accordion/accordion-group.component.ts +++ b/src/accordion/accordion-group.component.ts @@ -2,6 +2,8 @@ import { Component, HostBinding, Inject, Input, OnDestroy, OnInit, Output, EventEmitter } from '@angular/core'; import { AccordionComponent } from './accordion.component'; +import { CollapseModule } from 'ngx-bootstrap/collapse'; +import { NgClass, NgIf } from '@angular/common'; /** * ### Accordion heading @@ -10,14 +12,16 @@ import { AccordionComponent } from './accordion.component'; * will be used as group's header template. */ @Component({ - selector: 'accordion-group, accordion-panel', - templateUrl: './accordion-group.component.html', - // eslint-disable-next-line @angular-eslint/no-host-metadata-property - host: { - class: 'panel', - style: 'display: block' - }, - styleUrls: ['./accordion.scss'] + selector: 'accordion-group, accordion-panel', + templateUrl: './accordion-group.component.html', + // eslint-disable-next-line @angular-eslint/no-host-metadata-property + host: { + class: 'panel', + style: 'display: block' + }, + styleUrls: ['./accordion.scss'], + standalone: true, + imports: [NgClass, NgIf, CollapseModule] }) export class AccordionPanelComponent implements OnInit, OnDestroy { /** turn on/off animation */ diff --git a/src/accordion/accordion.component.ts b/src/accordion/accordion.component.ts index 6fd63d7cfa..c6782fa87a 100644 --- a/src/accordion/accordion.component.ts +++ b/src/accordion/accordion.component.ts @@ -4,15 +4,16 @@ import { AccordionConfig } from './accordion.config'; /** Displays collapsible content panels for presenting information in a limited amount of space. */ @Component({ - selector: 'accordion', - template: ``, - // eslint-disable-next-line @angular-eslint/no-host-metadata-property - host: { - '[attr.aria-multiselectable]': 'closeOthers', - role: 'tablist', - class: 'panel-group', - style: 'display: block' - } + selector: 'accordion', + template: ``, + // eslint-disable-next-line @angular-eslint/no-host-metadata-property + host: { + '[attr.aria-multiselectable]': 'closeOthers', + role: 'tablist', + class: 'panel-group', + style: 'display: block' + }, + standalone: true }) export class AccordionComponent { /** turn on/off animation */ diff --git a/src/accordion/accordion.module.ts b/src/accordion/accordion.module.ts index 667f85686d..60a8a70db1 100644 --- a/src/accordion/accordion.module.ts +++ b/src/accordion/accordion.module.ts @@ -1,17 +1,15 @@ -import { CommonModule } from '@angular/common'; -import { NgModule, ModuleWithProviders } from '@angular/core'; +import { NgModule } from '@angular/core'; import { AccordionComponent } from './accordion.component'; import { AccordionPanelComponent } from './accordion-group.component'; -import { CollapseModule } from 'ngx-bootstrap/collapse'; @NgModule({ - imports: [CommonModule, CollapseModule], - declarations: [AccordionComponent, AccordionPanelComponent], - exports: [AccordionComponent, AccordionPanelComponent] + imports: [AccordionComponent, AccordionPanelComponent], + exports: [AccordionComponent, AccordionPanelComponent] }) export class AccordionModule { - static forRoot(): ModuleWithProviders { - return { ngModule: AccordionModule, providers: [] }; + // @deprecated method not required anymore, will be deleted in v19.0.0 + static forRoot() { + return AccordionModule; } } diff --git a/src/accordion/package.json b/src/accordion/package.json index b21be99d7b..1f30f5dc8b 100644 --- a/src/accordion/package.json +++ b/src/accordion/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/accordion", - "version": "18.0.2", + "version": "18.1.0", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/accordion/testing/accordion.component.spec.ts b/src/accordion/testing/accordion.component.spec.ts index 335a2c0eee..f2b097925f 100644 --- a/src/accordion/testing/accordion.component.spec.ts +++ b/src/accordion/testing/accordion.component.spec.ts @@ -4,8 +4,8 @@ import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { AccordionConfig, AccordionModule } from '../index'; @Component({ - selector: 'accordion-test', - template: '' + selector: 'accordion-test', + template: '' }) class TestAccordionComponent { oneAtATime = true; @@ -77,10 +77,10 @@ describe('Component: Accordion', () => { TestBed.configureTestingModule({ declarations: [TestAccordionComponent], imports: [ - AccordionModule.forRoot(), + AccordionModule, BrowserAnimationsModule ] - }); +}); TestBed.overrideComponent(TestAccordionComponent, { set: { template: html } }); diff --git a/src/alert/alert.component.ts b/src/alert/alert.component.ts index 07885ae597..47b1c92176 100644 --- a/src/alert/alert.component.ts +++ b/src/alert/alert.component.ts @@ -9,11 +9,14 @@ import { } from '@angular/core'; import { AlertConfig } from './alert.config'; import { OnChange } from 'ngx-bootstrap/utils'; +import { NgIf, NgClass } from '@angular/common'; @Component({ - selector: 'alert,bs-alert', - templateUrl: './alert.component.html', - changeDetection: ChangeDetectionStrategy.OnPush + selector: 'alert,bs-alert', + templateUrl: './alert.component.html', + changeDetection: ChangeDetectionStrategy.OnPush, + standalone: true, + imports: [NgIf, NgClass] }) export class AlertComponent implements OnInit { /** Alert type. diff --git a/src/alert/alert.module.ts b/src/alert/alert.module.ts index c43aeb56bf..d682d7cbce 100644 --- a/src/alert/alert.module.ts +++ b/src/alert/alert.module.ts @@ -1,14 +1,13 @@ -import { CommonModule } from '@angular/common'; -import { NgModule, ModuleWithProviders } from '@angular/core'; +import { NgModule } from '@angular/core'; import { AlertComponent } from './alert.component'; @NgModule({ - imports: [CommonModule], - declarations: [AlertComponent], + imports: [AlertComponent], exports: [AlertComponent] }) export class AlertModule { - static forRoot(): ModuleWithProviders { - return { ngModule: AlertModule, providers: [] }; + // @deprecated method not required anymore, will be deleted in v19.0.0 + static forRoot() { + return AlertModule; } } diff --git a/src/alert/package.json b/src/alert/package.json index 37e220999b..a1b343725d 100644 --- a/src/alert/package.json +++ b/src/alert/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/alert", - "version": "18.0.2", + "version": "18.1.0", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/alert/testing/alert.component.spec.ts b/src/alert/testing/alert.component.spec.ts index d589800d6d..e247d4888b 100644 --- a/src/alert/testing/alert.component.spec.ts +++ b/src/alert/testing/alert.component.spec.ts @@ -3,7 +3,10 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { AlertComponent, AlertConfig, AlertModule } from '../index'; -@Component({selector: 'alert-test', template: ''}) +@Component({ + selector: 'alert-test', template: '', + standalone: true +}) class TestAlertComponent extends AlertComponent { constructor(config: AlertConfig, changeDetection: ChangeDetectorRef) { super(config, changeDetection); @@ -25,9 +28,8 @@ describe('Component: Alert', () => { beforeEach(() => { TestBed.configureTestingModule({ - declarations: [TestAlertComponent], - imports: [AlertModule.forRoot()] - }); + imports: [AlertModule, TestAlertComponent] +}); TestBed.overrideComponent(TestAlertComponent, { set: {template: overTemplate} }); diff --git a/src/buttons/button-checkbox.directive.ts b/src/buttons/button-checkbox.directive.ts index fa60148960..7bd2a6552b 100644 --- a/src/buttons/button-checkbox.directive.ts +++ b/src/buttons/button-checkbox.directive.ts @@ -22,8 +22,9 @@ type AvailableValues = boolean | string | number; * Add checkbox functionality to any element */ @Directive({ - selector: '[btnCheckbox]', - providers: [CHECKBOX_CONTROL_VALUE_ACCESSOR] + selector: '[btnCheckbox]', + providers: [CHECKBOX_CONTROL_VALUE_ACCESSOR], + standalone: true }) export class ButtonCheckboxDirective implements ControlValueAccessor, OnInit { /** Truthy value, will be set to ngModel */ diff --git a/src/buttons/button-radio-group.directive.ts b/src/buttons/button-radio-group.directive.ts index d4ad61c9d5..7e18ca1fc5 100644 --- a/src/buttons/button-radio-group.directive.ts +++ b/src/buttons/button-radio-group.directive.ts @@ -22,8 +22,9 @@ export const RADIO_CONTROL_VALUE_ACCESSOR: Provider = { * A value of a selected button is bound to a variable specified via ngModel. */ @Directive({ - selector: '[btnRadioGroup]', - providers: [RADIO_CONTROL_VALUE_ACCESSOR] + selector: '[btnRadioGroup]', + providers: [RADIO_CONTROL_VALUE_ACCESSOR], + standalone: true }) export class ButtonRadioGroupDirective implements ControlValueAccessor { onChange = Function.prototype; diff --git a/src/buttons/button-radio.directive.ts b/src/buttons/button-radio.directive.ts index 4a477a66ba..5f8004282e 100644 --- a/src/buttons/button-radio.directive.ts +++ b/src/buttons/button-radio.directive.ts @@ -27,8 +27,9 @@ export const RADIO_CONTROL_VALUE_ACCESSOR: Provider = { * A value of a selected button is bound to a variable specified via ngModel. */ @Directive({ - selector: '[btnRadio]', - providers: [RADIO_CONTROL_VALUE_ACCESSOR] + selector: '[btnRadio]', + providers: [RADIO_CONTROL_VALUE_ACCESSOR], + standalone: true }) export class ButtonRadioDirective implements ControlValueAccessor, OnChanges { onChange = Function.prototype; diff --git a/src/buttons/buttons.module.ts b/src/buttons/buttons.module.ts index 7c59bbe825..dd6ad1d660 100644 --- a/src/buttons/buttons.module.ts +++ b/src/buttons/buttons.module.ts @@ -1,15 +1,16 @@ -import { NgModule, ModuleWithProviders } from '@angular/core'; +import { NgModule } from '@angular/core'; import { ButtonCheckboxDirective } from './button-checkbox.directive'; import { ButtonRadioDirective } from './button-radio.directive'; import { ButtonRadioGroupDirective } from './button-radio-group.directive'; @NgModule({ - declarations: [ButtonCheckboxDirective, ButtonRadioDirective, ButtonRadioGroupDirective], - exports: [ButtonCheckboxDirective, ButtonRadioDirective, ButtonRadioGroupDirective] + imports: [ButtonCheckboxDirective, ButtonRadioDirective, ButtonRadioGroupDirective], + exports: [ButtonCheckboxDirective, ButtonRadioDirective, ButtonRadioGroupDirective] }) export class ButtonsModule { - static forRoot(): ModuleWithProviders { - return { ngModule: ButtonsModule, providers: [] }; + // @deprecated method not required anymore, will be deleted in v19.0.0 + static forRoot() { + return ButtonsModule; } } diff --git a/src/buttons/package.json b/src/buttons/package.json index 25e606aaf8..d37d360daa 100644 --- a/src/buttons/package.json +++ b/src/buttons/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/buttons", - "version": "18.0.2", + "version": "18.1.0", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/buttons/testing/button.directive.spec.ts b/src/buttons/testing/button.directive.spec.ts index 838a954020..618520f884 100644 --- a/src/buttons/testing/button.directive.spec.ts +++ b/src/buttons/testing/button.directive.spec.ts @@ -3,7 +3,11 @@ import { ComponentFixture, ComponentFixtureAutoDetect, fakeAsync, TestBed, tick import { FormBuilder, FormControl, FormGroup, FormsModule, ReactiveFormsModule } from '@angular/forms'; import { ButtonsModule } from '../index'; -@Component({ selector: 'buttons-test', template: '' }) +@Component({ + selector: 'buttons-test', template: '', + standalone: true, + imports: [ButtonsModule, FormsModule, ReactiveFormsModule] +}) class TestButtonsComponent implements OnInit { singleModel = '0'; // eslint-disable-next-line @typescript-eslint/no-explicit-any @@ -136,10 +140,9 @@ describe('Directive: Buttons', () => { beforeEach( fakeAsync(() => { TestBed.configureTestingModule({ - declarations: [TestButtonsComponent], - imports: [ButtonsModule, FormsModule, ReactiveFormsModule], - providers: [{ provide: ComponentFixtureAutoDetect, useValue: true }] - }); + imports: [ButtonsModule, FormsModule, ReactiveFormsModule, TestButtonsComponent], + providers: [{ provide: ComponentFixtureAutoDetect, useValue: true }] +}); }) ); diff --git a/src/carousel/carousel.component.ts b/src/carousel/carousel.component.ts index 366ed1ac82..c47e370251 100644 --- a/src/carousel/carousel.component.ts +++ b/src/carousel/carousel.component.ts @@ -18,7 +18,7 @@ import { Component, EventEmitter, Input, NgZone, OnDestroy, Output, AfterViewInit, Inject, PLATFORM_ID } from '@angular/core'; -import { isPlatformBrowser } from '@angular/common'; +import { isPlatformBrowser, NgIf, NgFor, NgStyle } from '@angular/common'; import { LinkedList, getBsVer, IBsVersion } from 'ngx-bootstrap/utils'; import { SlideComponent } from './slide.component'; @@ -38,8 +38,10 @@ let _currentId = 1; * Base element to create carousel */ @Component({ - selector: 'carousel', - templateUrl: './carousel.component.html' + selector: 'carousel', + templateUrl: './carousel.component.html', + standalone: true, + imports: [NgIf, NgFor, NgStyle] }) export class CarouselComponent implements AfterViewInit, OnDestroy { /* If `true` — carousel will not cycle continuously and will have hard stops (prevent looping) */ diff --git a/src/carousel/carousel.module.ts b/src/carousel/carousel.module.ts index 03a86e0389..177452e83c 100644 --- a/src/carousel/carousel.module.ts +++ b/src/carousel/carousel.module.ts @@ -1,16 +1,15 @@ -import { CommonModule } from '@angular/common'; -import { NgModule, ModuleWithProviders } from '@angular/core'; +import { NgModule } from '@angular/core'; import { CarouselComponent } from './carousel.component'; import { SlideComponent } from './slide.component'; @NgModule({ - imports: [CommonModule], - declarations: [SlideComponent, CarouselComponent], - exports: [SlideComponent, CarouselComponent] + imports: [SlideComponent, CarouselComponent], + exports: [SlideComponent, CarouselComponent] }) export class CarouselModule { - static forRoot(): ModuleWithProviders { - return { ngModule: CarouselModule, providers: [] }; + // @deprecated method not required anymore, will be deleted in v19.0.0 + static forRoot() { + return CarouselModule; } } diff --git a/src/carousel/package.json b/src/carousel/package.json index a8e3144d42..e1f4da7134 100644 --- a/src/carousel/package.json +++ b/src/carousel/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/carousel", - "version": "18.0.2", + "version": "18.1.0", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/carousel/slide.component.ts b/src/carousel/slide.component.ts index 87c310cc5b..3f4940904a 100644 --- a/src/carousel/slide.component.ts +++ b/src/carousel/slide.component.ts @@ -9,18 +9,18 @@ import { import { CarouselComponent } from './carousel.component'; @Component({ - selector: 'slide', - template: ` + selector: 'slide', + template: `
`, - // eslint-disable-next-line @angular-eslint/no-host-metadata-property - host: { - '[attr.aria-hidden]': '!active', - '[class.multilist-margin]': 'multilist' - }, - styles: [` + // eslint-disable-next-line @angular-eslint/no-host-metadata-property + host: { + '[attr.aria-hidden]': '!active', + '[class.multilist-margin]': 'multilist' + }, + styles: [` :host.carousel-animation { transition: opacity 0.6s ease, visibility 0.6s ease; float: left; @@ -41,7 +41,8 @@ import { CarouselComponent } from './carousel.component'; :host.carousel-item { perspective: 1000px; } - `] + `], + standalone: true }) export class SlideComponent implements OnInit, OnDestroy { /** Is current slide active */ diff --git a/src/carousel/testing/carousel.component.spec.ts b/src/carousel/testing/carousel.component.spec.ts index f910e07310..332d6857e0 100644 --- a/src/carousel/testing/carousel.component.spec.ts +++ b/src/carousel/testing/carousel.component.spec.ts @@ -4,8 +4,13 @@ import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testin import '../../../scripts/jest/toHaveCssClass'; import { CarouselModule } from '../index'; import { getBsVer, IBsVersion } from 'ngx-bootstrap/utils'; +import { CommonModule } from '@angular/common'; -@Component({ selector: 'carousel-test', template: '' }) +@Component({ + selector: 'carousel-test', template: '', + standalone: true, + imports: [CommonModule, CarouselModule] +}) class TestCarouselComponent { myInterval = 5000; noWrapSlides = false; @@ -84,9 +89,8 @@ describe('Component: Carousel', () => { beforeEach(() => { TestBed.configureTestingModule({ - declarations: [TestCarouselComponent], - imports: [CarouselModule] - }); + imports: [CarouselModule, TestCarouselComponent] +}); TestBed.overrideComponent(TestCarouselComponent, { set: { template: html } }); diff --git a/src/chronos/package.json b/src/chronos/package.json index 59b022b551..d6be16bbc2 100644 --- a/src/chronos/package.json +++ b/src/chronos/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/chronos", - "version": "18.0.2", + "version": "18.1.0", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/collapse/collapse.directive.ts b/src/collapse/collapse.directive.ts index 9c9ca36a97..c69338234a 100644 --- a/src/collapse/collapse.directive.ts +++ b/src/collapse/collapse.directive.ts @@ -21,12 +21,13 @@ import { } from './collapse-animations'; @Directive({ - selector: '[collapse]', - exportAs: 'bs-collapse', - // eslint-disable-next-line @angular-eslint/no-host-metadata-property - host: { - '[class.collapse]': 'true' - } + selector: '[collapse]', + exportAs: 'bs-collapse', + // eslint-disable-next-line @angular-eslint/no-host-metadata-property + host: { + '[class.collapse]': 'true' + }, + standalone: true }) export class CollapseDirective implements AfterViewChecked { /** This event fires as soon as content collapses */ diff --git a/src/collapse/collapse.module.ts b/src/collapse/collapse.module.ts index 94751fb209..769cddbde2 100644 --- a/src/collapse/collapse.module.ts +++ b/src/collapse/collapse.module.ts @@ -1,13 +1,14 @@ -import { NgModule, ModuleWithProviders } from '@angular/core'; +import { NgModule } from '@angular/core'; import { CollapseDirective } from './collapse.directive'; @NgModule({ - declarations: [CollapseDirective], - exports: [CollapseDirective] + imports: [CollapseDirective], + exports: [CollapseDirective] }) export class CollapseModule { - static forRoot(): ModuleWithProviders { - return { ngModule: CollapseModule, providers: [] }; + // @deprecated method not required anymore, will be deleted in v19.0.0 + static forRoot() { + return CollapseModule; } } diff --git a/src/collapse/package.json b/src/collapse/package.json index 5f137f3b3c..994c31561c 100644 --- a/src/collapse/package.json +++ b/src/collapse/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/collapse", - "version": "18.0.2", + "version": "18.1.0", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/collapse/testing/collapse.directive.spec.ts b/src/collapse/testing/collapse.directive.spec.ts index 27d0e25ec1..90c42c8d1a 100644 --- a/src/collapse/testing/collapse.directive.spec.ts +++ b/src/collapse/testing/collapse.directive.spec.ts @@ -13,8 +13,10 @@ const template = ` `; @Component({ - selector: 'collapse-test', - template + selector: 'collapse-test', + template, + standalone: true, + imports: [CollapseModule] }) class TestCollapseComponent {} @@ -28,12 +30,12 @@ describe('Directive: Collapse', () => { beforeEach(() => { TestBed.configureTestingModule({ - declarations: [TestCollapseComponent], - imports: [ + imports: [ CollapseModule, - BrowserAnimationsModule - ] - }); + BrowserAnimationsModule, + TestCollapseComponent + ] +}); fixture = TestBed.createComponent(TestCollapseComponent); fixture.detectChanges(); context = fixture.componentInstance; diff --git a/src/component-loader/package.json b/src/component-loader/package.json index 33cb1b1a24..d0f479a3e9 100644 --- a/src/component-loader/package.json +++ b/src/component-loader/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/component-loader", - "version": "18.0.2", + "version": "18.1.0", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/datepicker/bs-datepicker-inline.component.ts b/src/datepicker/bs-datepicker-inline.component.ts index d47457dad8..dc41e915c2 100644 --- a/src/datepicker/bs-datepicker-inline.component.ts +++ b/src/datepicker/bs-datepicker-inline.component.ts @@ -25,8 +25,10 @@ import { copyTime } from './utils/copy-time-utils'; import { checkBsValue, setCurrentTimeOnDateSelect } from './utils/bs-calendar-utils'; @Directive({ - selector: 'bs-datepicker-inline', - exportAs: 'bsDatepickerInline' + selector: 'bs-datepicker-inline', + exportAs: 'bsDatepickerInline', + standalone: true, + providers: [ComponentLoaderFactory] }) export class BsDatepickerInlineDirective implements OnInit, OnDestroy, OnChanges { /** diff --git a/src/datepicker/bs-datepicker-input.directive.ts b/src/datepicker/bs-datepicker-input.directive.ts index dceac0a139..98d9d4b87f 100644 --- a/src/datepicker/bs-datepicker-input.directive.ts +++ b/src/datepicker/bs-datepicker-input.directive.ts @@ -49,8 +49,13 @@ const BS_DATEPICKER_VALIDATOR: Provider = { }; @Directive({ - selector: `input[bsDatepicker]`, - providers: [BS_DATEPICKER_VALUE_ACCESSOR, BS_DATEPICKER_VALIDATOR] + selector: `input[bsDatepicker]`, + providers: [ + BsLocaleService, + BS_DATEPICKER_VALUE_ACCESSOR, + BS_DATEPICKER_VALIDATOR + ], + standalone: true }) export class BsDatepickerInputDirective implements ControlValueAccessor, Validator, OnInit, OnDestroy { private _onChange = Function.prototype; diff --git a/src/datepicker/bs-datepicker.component.ts b/src/datepicker/bs-datepicker.component.ts index c3a1c69e67..e17cc59516 100644 --- a/src/datepicker/bs-datepicker.component.ts +++ b/src/datepicker/bs-datepicker.component.ts @@ -25,8 +25,10 @@ import { checkBsValue, setCurrentTimeOnDateSelect } from './utils/bs-calendar-ut export let previousDate: Date | Date[] | undefined; @Directive({ - selector: '[bsDatepicker]', - exportAs: 'bsDatepicker' + selector: '[bsDatepicker]', + exportAs: 'bsDatepicker', + providers: [ComponentLoaderFactory], + standalone: true }) export class BsDatepickerDirective implements OnInit, OnDestroy, OnChanges, AfterViewInit { /** diff --git a/src/datepicker/bs-datepicker.module.ts b/src/datepicker/bs-datepicker.module.ts index 76b6920f14..88abae332f 100644 --- a/src/datepicker/bs-datepicker.module.ts +++ b/src/datepicker/bs-datepicker.module.ts @@ -1,10 +1,8 @@ import { CommonModule } from '@angular/common'; -import { ModuleWithProviders, NgModule } from '@angular/core'; -import { ComponentLoaderFactory } from 'ngx-bootstrap/component-loader'; -import { PositioningService } from 'ngx-bootstrap/positioning'; +import { NgModule } from '@angular/core'; import { TooltipModule } from 'ngx-bootstrap/tooltip'; -import { TimepickerModule, TimepickerActions } from 'ngx-bootstrap/timepicker'; +import { TimepickerModule } from 'ngx-bootstrap/timepicker'; import { BsDatepickerInputDirective } from './bs-datepicker-input.directive'; import { BsDatepickerDirective } from './bs-datepicker.component'; @@ -13,10 +11,6 @@ import { BsDaterangepickerDirective } from './bs-daterangepicker.component'; import { BsDatepickerInlineDirective } from './bs-datepicker-inline.component'; -import { BsLocaleService } from './bs-locale.service'; -import { BsDatepickerActions } from './reducer/bs-datepicker.actions'; -import { BsDatepickerEffects } from './reducer/bs-datepicker.effects'; -import { BsDatepickerStore } from './reducer/bs-datepicker.store'; import { BsDatepickerContainerComponent } from './themes/bs/bs-datepicker-container.component'; import { BsDaterangepickerContainerComponent } from './themes/bs/bs-daterangepicker-container.component'; @@ -36,9 +30,7 @@ import { BsTimepickerViewComponent } from './themes/bs/bs-timepicker-view.compon import { BsYearsCalendarViewComponent } from './themes/bs/bs-years-calendar-view.component'; @NgModule({ - imports: [CommonModule, TooltipModule, TimepickerModule], - declarations: [ - BsCalendarLayoutComponent, + imports: [CommonModule, TooltipModule, TimepickerModule, BsCalendarLayoutComponent, BsCurrentDateViewComponent, BsCustomDatesViewComponent, BsDatepickerDayDecoratorComponent, @@ -56,8 +48,7 @@ import { BsYearsCalendarViewComponent } from './themes/bs/bs-years-calendar-view BsDaterangepickerDirective, BsDaterangepickerInlineContainerComponent, BsDaterangepickerInlineDirective, - BsDaterangepickerInputDirective - ], + BsDaterangepickerInputDirective], exports: [ BsDatepickerContainerComponent, BsDatepickerDirective, @@ -72,18 +63,8 @@ import { BsYearsCalendarViewComponent } from './themes/bs/bs-years-calendar-view ] }) export class BsDatepickerModule { - static forRoot(): ModuleWithProviders { - return { - ngModule: BsDatepickerModule, - providers: [ - ComponentLoaderFactory, - PositioningService, - BsDatepickerStore, - BsDatepickerActions, - BsDatepickerEffects, - BsLocaleService, - TimepickerActions - ] - }; + // @deprecated method not required anymore, will be deleted in v19.0.0 + static forRoot() { + return BsDatepickerModule; } } diff --git a/src/datepicker/bs-daterangepicker-inline.component.ts b/src/datepicker/bs-daterangepicker-inline.component.ts index 2570ced468..0d1e0fd341 100644 --- a/src/datepicker/bs-daterangepicker-inline.component.ts +++ b/src/datepicker/bs-daterangepicker-inline.component.ts @@ -20,7 +20,11 @@ import { @Directive({ selector: 'bs-daterangepicker-inline', - exportAs: 'bsDaterangepickerInline' + exportAs: 'bsDaterangepickerInline', + standalone: true, + providers: [ + ComponentLoaderFactory + ] }) export class BsDaterangepickerInlineDirective implements OnInit, OnDestroy, OnChanges { _bsValue?: (Date|undefined)[] | undefined; diff --git a/src/datepicker/bs-daterangepicker-input.directive.ts b/src/datepicker/bs-daterangepicker-input.directive.ts index 89a659060f..7c5750ce6f 100644 --- a/src/datepicker/bs-daterangepicker-input.directive.ts +++ b/src/datepicker/bs-daterangepicker-input.directive.ts @@ -49,15 +49,20 @@ const BS_DATERANGEPICKER_VALIDATOR: Provider = { @Directive({ - selector: `input[bsDaterangepicker]`, - // eslint-disable-next-line @angular-eslint/no-host-metadata-property - host: { - '(change)': 'onChange($event)', - '(keyup.esc)': 'hide()', - '(keydown)': 'onKeydownEvent($event)', - '(blur)': 'onBlur()' - }, - providers: [BS_DATERANGEPICKER_VALUE_ACCESSOR, BS_DATERANGEPICKER_VALIDATOR] + selector: `input[bsDaterangepicker]`, + // eslint-disable-next-line @angular-eslint/no-host-metadata-property + host: { + '(change)': 'onChange($event)', + '(keyup.esc)': 'hide()', + '(keydown)': 'onKeydownEvent($event)', + '(blur)': 'onBlur()' + }, + providers: [ + BsLocaleService, + BS_DATERANGEPICKER_VALUE_ACCESSOR, + BS_DATERANGEPICKER_VALIDATOR + ], + standalone: true }) export class BsDaterangepickerInputDirective implements ControlValueAccessor, Validator, OnInit, OnDestroy { diff --git a/src/datepicker/bs-daterangepicker.component.ts b/src/datepicker/bs-daterangepicker.component.ts index 7a2773af94..fa7bac9dbf 100644 --- a/src/datepicker/bs-daterangepicker.component.ts +++ b/src/datepicker/bs-daterangepicker.component.ts @@ -22,8 +22,12 @@ export let previousDate: (Date | undefined)[] | undefined; @Directive({ - selector: '[bsDaterangepicker]', - exportAs: 'bsDaterangepicker' + selector: '[bsDaterangepicker]', + exportAs: 'bsDaterangepicker', + standalone: true, + providers: [ + ComponentLoaderFactory + ] }) export class BsDaterangepickerDirective implements OnInit, OnDestroy, OnChanges, AfterViewInit { diff --git a/src/datepicker/package.json b/src/datepicker/package.json index e6aec3d959..13b0b449e2 100644 --- a/src/datepicker/package.json +++ b/src/datepicker/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/datepicker", - "version": "18.0.2", + "version": "18.1.0", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/datepicker/testing/bs-datepicker-day-decorator.spec.ts b/src/datepicker/testing/bs-datepicker-day-decorator.spec.ts index eab3b3d894..d18f46b7cb 100644 --- a/src/datepicker/testing/bs-datepicker-day-decorator.spec.ts +++ b/src/datepicker/testing/bs-datepicker-day-decorator.spec.ts @@ -8,8 +8,8 @@ import { BsDatepickerDayDecoratorComponent } from '../themes/bs/bs-datepicker-da import '../../../scripts/jest/toHaveCssClass'; @Component({ - selector: 'test-cmp', - template: `{{ day.label }}` + selector: 'test-cmp', + template: `{{ day.label }}`, }) class TestComponent { day: DayViewModel = { date: new Date(), label: '' }; @@ -32,10 +32,11 @@ describe('datepicker: [bsDatepickerDayDecorator]', () => { beforeEach(waitForAsync(() => TestBed.configureTestingModule({ - declarations: [TestComponent, BsDatepickerDayDecoratorComponent], + declarations: [TestComponent], + imports: [BsDatepickerDayDecoratorComponent], providers: [BsDatepickerConfig] - }).compileComponents() - )); + }).compileComponents()) + ); beforeEach(() => { fixture = TestBed.createComponent(TestComponent); diff --git a/src/datepicker/testing/bs-datepicker-navigation-view.spec.ts b/src/datepicker/testing/bs-datepicker-navigation-view.spec.ts index c7319bb339..20cf6f7b5c 100644 --- a/src/datepicker/testing/bs-datepicker-navigation-view.spec.ts +++ b/src/datepicker/testing/bs-datepicker-navigation-view.spec.ts @@ -5,12 +5,12 @@ import { BsDatepickerNavigationViewComponent } from '../themes/bs/bs-datepicker- @Component({ - selector: 'test-cmp', - template: ` + selector: 'test-cmp', + template: ` ` + >`, }) class TestComponent { month!: DaysCalendarViewModel; @@ -54,9 +54,10 @@ describe('datepicker: bs-datepicker-navigation-view', () => { let fixture: TestFixture; beforeEach( waitForAsync(() => TestBed.configureTestingModule({ - declarations: [TestComponent, BsDatepickerNavigationViewComponent] - }).compileComponents() - )); + declarations: [TestComponent], + imports: [BsDatepickerNavigationViewComponent] + }).compileComponents()) + ); beforeEach(() => { fixture = TestBed.createComponent(TestComponent); }); diff --git a/src/datepicker/testing/bs-datepicker-utils.spec.ts b/src/datepicker/testing/bs-datepicker-utils.spec.ts index 7a08240f36..5541bb082c 100644 --- a/src/datepicker/testing/bs-datepicker-utils.spec.ts +++ b/src/datepicker/testing/bs-datepicker-utils.spec.ts @@ -15,7 +15,7 @@ describe('daterangepicker:', () => { beforeEach( waitForAsync(() => TestBed.configureTestingModule({ imports: [ - BsDatepickerModule.forRoot(), + BsDatepickerModule, BrowserAnimationsModule ] }).compileComponents() diff --git a/src/datepicker/testing/bs-datepicker.spec.ts b/src/datepicker/testing/bs-datepicker.spec.ts index 560a5abac3..b9bb957a2e 100644 --- a/src/datepicker/testing/bs-datepicker.spec.ts +++ b/src/datepicker/testing/bs-datepicker.spec.ts @@ -11,10 +11,10 @@ import { BsDatepickerViewMode, CalendarCellViewModel, WeekViewModel } from '../m import { BsDatepickerContainerComponent } from '../themes/bs/bs-datepicker-container.component'; @Component({ - selector: 'test-cmp', - template: `` + [bsConfig]='bsConfig'>`, }) class TestComponent { @ViewChild(BsDatepickerDirective, { static: false }) datepicker: BsDatepickerDirective; @@ -55,12 +55,12 @@ describe('datepicker:', () => { let fixture: TestFixture; beforeEach( waitForAsync(() => TestBed.configureTestingModule({ - declarations: [TestComponent], - imports: [ - BsDatepickerModule.forRoot(), - BrowserAnimationsModule - ] - }).compileComponents() + declarations: [TestComponent], + imports: [ + BsDatepickerModule, + BrowserAnimationsModule + ] +}).compileComponents() )); beforeEach(() => { fixture = TestBed.createComponent(TestComponent); diff --git a/src/datepicker/testing/bs-daterangepicker.spec.ts b/src/datepicker/testing/bs-daterangepicker.spec.ts index 617235f365..9fa64bcb8f 100644 --- a/src/datepicker/testing/bs-daterangepicker.spec.ts +++ b/src/datepicker/testing/bs-daterangepicker.spec.ts @@ -13,7 +13,7 @@ import { firstValueFrom } from 'rxjs'; selector: 'test-cmp', template: `` + [bsConfig]="bsConfig">`, }) class TestComponent { @ViewChild(BsDaterangepickerDirective, { static: false }) daterangepicker: BsDaterangepickerDirective; @@ -54,13 +54,13 @@ describe('daterangepicker:', () => { let fixture: TestFixture; beforeEach( waitForAsync(() => TestBed.configureTestingModule({ - declarations: [TestComponent], - imports: [ - BsDatepickerModule.forRoot(), - BrowserAnimationsModule - ] - }).compileComponents() - )); + declarations: [TestComponent], + imports: [ + BsDatepickerModule, + BrowserAnimationsModule + ] + }).compileComponents()) + ); beforeEach(() => { fixture = TestBed.createComponent(TestComponent); fixture.detectChanges(); diff --git a/src/datepicker/testing/bs-inline-datepicker-minmode-year.spec.ts b/src/datepicker/testing/bs-inline-datepicker-minmode-year.spec.ts index 72bb0d28b5..6b76deb7ed 100644 --- a/src/datepicker/testing/bs-inline-datepicker-minmode-year.spec.ts +++ b/src/datepicker/testing/bs-inline-datepicker-minmode-year.spec.ts @@ -13,8 +13,9 @@ import { CalendarCellViewModel } from '../models'; import { getYearsCalendarInitialDate } from '../utils/bs-calendar-utils'; @Component({ - selector: 'test-cmp', - template: `>` + selector: 'test-cmp', + template: `>`, + standalone: true }) class TestComponent { @ViewChild(BsDatepickerInlineDirective, { static: false }) datepicker: BsDatepickerInlineDirective; @@ -38,12 +39,12 @@ xdescribe('datepicker inline minMode="year":', () => { let fixture: TestFixture; beforeEach( waitForAsync(() => TestBed.configureTestingModule({ - declarations: [TestComponent], - imports: [ - BsDatepickerModule.forRoot(), - BrowserAnimationsModule - ] - }).compileComponents() + imports: [ + BsDatepickerModule, + BrowserAnimationsModule, + TestComponent + ] +}).compileComponents() )); beforeEach(() => { fixture = TestBed.createComponent(TestComponent); diff --git a/src/datepicker/testing/bs-inline-datepicker.spec.ts b/src/datepicker/testing/bs-inline-datepicker.spec.ts index 9016d2cb8b..87909cd339 100644 --- a/src/datepicker/testing/bs-inline-datepicker.spec.ts +++ b/src/datepicker/testing/bs-inline-datepicker.spec.ts @@ -12,8 +12,8 @@ import { take } from 'rxjs/operators'; import { getYearsCalendarInitialDate } from '../utils/bs-calendar-utils'; @Component({ - selector: 'test-cmp', - template: `>` + selector: 'test-cmp', + template: `>` }) class TestComponent { @ViewChild(BsDatepickerInlineDirective, { static: false }) datepicker: BsDatepickerInlineDirective; @@ -39,13 +39,12 @@ describe('datepicker inline:', () => { let fixture: TestFixture; beforeEach( waitForAsync(() => TestBed.configureTestingModule({ - declarations: [TestComponent], - imports: [ - BsDatepickerModule.forRoot(), - BrowserAnimationsModule - ] - }).compileComponents() - )); + declarations: [TestComponent], + imports: [ + BsDatepickerModule, + BrowserAnimationsModule + ]}).compileComponents()) + ); beforeEach(() => { fixture = TestBed.createComponent(TestComponent); fixture.detectChanges(); diff --git a/src/datepicker/testing/bs-inline-daterangepicker.spec.ts b/src/datepicker/testing/bs-inline-daterangepicker.spec.ts index 4f4d4df06a..1a9651a946 100644 --- a/src/datepicker/testing/bs-inline-daterangepicker.spec.ts +++ b/src/datepicker/testing/bs-inline-daterangepicker.spec.ts @@ -11,8 +11,8 @@ import { getYearsCalendarInitialDate } from '../utils/bs-calendar-utils'; import { initialYearShift } from '../engine/format-years-calendar'; @Component({ - selector: 'test-cmp', - template: ` + selector: 'test-cmp', + template: ` ` }) class TestComponent { @@ -40,13 +40,13 @@ describe('daterangepicker inline:', () => { let fixture: TestFixture; beforeEach( waitForAsync(() => TestBed.configureTestingModule({ - declarations: [TestComponent], - imports: [ - BsDatepickerModule.forRoot(), - BrowserAnimationsModule - ] - }).compileComponents() - )); + declarations: [TestComponent], + imports: [ + BsDatepickerModule, + BrowserAnimationsModule + ] + }).compileComponents()) + ); beforeEach(() => { fixture = TestBed.createComponent(TestComponent); fixture.detectChanges(); diff --git a/src/datepicker/themes/bs/bs-calendar-layout.component.ts b/src/datepicker/themes/bs/bs-calendar-layout.component.ts index a15a4cecb6..5a28eaaad1 100644 --- a/src/datepicker/themes/bs/bs-calendar-layout.component.ts +++ b/src/datepicker/themes/bs/bs-calendar-layout.component.ts @@ -1,8 +1,11 @@ import { Component } from '@angular/core'; +import { BsTimepickerViewComponent } from './bs-timepicker-view.component'; +import { BsCurrentDateViewComponent } from './bs-current-date-view.component'; +import { NgIf } from '@angular/common'; @Component({ - selector: 'bs-calendar-layout', - template: ` + selector: 'bs-calendar-layout', + template: ` @@ -17,6 +20,8 @@ import { Component } from '@angular/core'; - ` + `, + standalone: true, + imports: [NgIf, BsCurrentDateViewComponent, BsTimepickerViewComponent] }) export class BsCalendarLayoutComponent {} diff --git a/src/datepicker/themes/bs/bs-current-date-view.component.ts b/src/datepicker/themes/bs/bs-current-date-view.component.ts index 081839b6bd..530f5e8921 100644 --- a/src/datepicker/themes/bs/bs-current-date-view.component.ts +++ b/src/datepicker/themes/bs/bs-current-date-view.component.ts @@ -1,8 +1,9 @@ import { Component, Input } from '@angular/core'; @Component({ - selector: 'bs-current-date', - template: `
{{ title }}
` + selector: 'bs-current-date', + template: `
{{ title }}
`, + standalone: true }) export class BsCurrentDateViewComponent { @Input() title?: string; diff --git a/src/datepicker/themes/bs/bs-custom-dates-view.component.ts b/src/datepicker/themes/bs/bs-custom-dates-view.component.ts index ea84edb1df..9bc17f543b 100644 --- a/src/datepicker/themes/bs/bs-custom-dates-view.component.ts +++ b/src/datepicker/themes/bs/bs-custom-dates-view.component.ts @@ -1,4 +1,5 @@ import { Component, ChangeDetectionStrategy, Input, Output, EventEmitter } from '@angular/core'; +import { NgFor } from '@angular/common'; export interface BsCustomDates { label: string; @@ -6,8 +7,8 @@ export interface BsCustomDates { } @Component({ - selector: 'bs-custom-date-view', - template: ` + selector: 'bs-custom-date-view', + template: `
`, - changeDetection: ChangeDetectionStrategy.OnPush + changeDetection: ChangeDetectionStrategy.OnPush, + standalone: true, + imports: [NgFor] }) export class BsCustomDatesViewComponent { @Input() ranges?: BsCustomDates[]; diff --git a/src/datepicker/themes/bs/bs-datepicker-container.component.ts b/src/datepicker/themes/bs/bs-datepicker-container.component.ts index 51162c53d0..c2913bfbca 100644 --- a/src/datepicker/themes/bs/bs-datepicker-container.component.ts +++ b/src/datepicker/themes/bs/bs-datepicker-container.component.ts @@ -24,18 +24,28 @@ import { CalendarCellViewModel, DayViewModel } from '../../models'; import { BsDatepickerActions } from '../../reducer/bs-datepicker.actions'; import { BsDatepickerEffects } from '../../reducer/bs-datepicker.effects'; import { BsDatepickerStore } from '../../reducer/bs-datepicker.store'; +import { BsCustomDatesViewComponent } from './bs-custom-dates-view.component'; +import { BsYearsCalendarViewComponent } from './bs-years-calendar-view.component'; +import { BsMonthCalendarViewComponent } from './bs-months-calendar-view.component'; +import { TimepickerModule } from 'ngx-bootstrap/timepicker'; +import { BsDaysCalendarViewComponent } from './bs-days-calendar-view.component'; +import { NgIf, NgClass, NgSwitch, NgSwitchCase, NgFor, AsyncPipe } from '@angular/common'; @Component({ - selector: 'bs-datepicker-container', - providers: [BsDatepickerStore, BsDatepickerEffects], - templateUrl: './bs-datepicker-view.html', - host: { - class: 'bottom', - '(click)': '_stopPropagation($event)', - role: 'dialog', - 'aria-label': 'calendar' - }, - animations: [datepickerAnimation] + selector: 'bs-datepicker-container', + providers: [BsDatepickerStore, BsDatepickerEffects, BsDatepickerActions, PositioningService], + templateUrl: './bs-datepicker-view.html', + host: { + class: 'bottom', + '(click)': '_stopPropagation($event)', + role: 'dialog', + 'aria-label': 'calendar' + }, + animations: [datepickerAnimation], + standalone: true, + imports: [NgIf, NgClass, NgSwitch, NgSwitchCase, NgFor, BsDaysCalendarViewComponent, TimepickerModule, + BsMonthCalendarViewComponent, BsYearsCalendarViewComponent, BsCustomDatesViewComponent, AsyncPipe + ] }) export class BsDatepickerContainerComponent extends BsDatepickerAbstractComponent diff --git a/src/datepicker/themes/bs/bs-datepicker-day-decorator.directive.ts b/src/datepicker/themes/bs/bs-datepicker-day-decorator.directive.ts index 2fab4ba25b..3cefe25748 100644 --- a/src/datepicker/themes/bs/bs-datepicker-day-decorator.directive.ts +++ b/src/datepicker/themes/bs/bs-datepicker-day-decorator.directive.ts @@ -11,19 +11,20 @@ import { BsDatepickerConfig } from '../../bs-datepicker.config'; import { DayViewModel } from '../../models'; @Component({ - selector: '[bsDatepickerDayDecorator]', - changeDetection: ChangeDetectionStrategy.OnPush, - host: { - '[class.disabled]': 'day.isDisabled', - '[class.is-highlighted]': 'day.isHovered', - '[class.is-other-month]': 'day.isOtherMonth', - '[class.is-active-other-month]': 'day.isOtherMonthHovered', - '[class.in-range]': 'day.isInRange', - '[class.select-start]': 'day.isSelectionStart', - '[class.select-end]': 'day.isSelectionEnd', - '[class.selected]': 'day.isSelected' - }, - template: `{{ day && day.label || '' }}` + selector: '[bsDatepickerDayDecorator]', + changeDetection: ChangeDetectionStrategy.OnPush, + host: { + '[class.disabled]': 'day.isDisabled', + '[class.is-highlighted]': 'day.isHovered', + '[class.is-other-month]': 'day.isOtherMonth', + '[class.is-active-other-month]': 'day.isOtherMonthHovered', + '[class.in-range]': 'day.isInRange', + '[class.select-start]': 'day.isSelectionStart', + '[class.select-end]': 'day.isSelectionEnd', + '[class.selected]': 'day.isSelected' + }, + template: `{{ day && day.label || '' }}`, + standalone: true }) export class BsDatepickerDayDecoratorComponent implements OnInit { @Input() day: DayViewModel = { date: new Date(), label: '' }; diff --git a/src/datepicker/themes/bs/bs-datepicker-inline-container.component.ts b/src/datepicker/themes/bs/bs-datepicker-inline-container.component.ts index 749804be27..184a8eec67 100644 --- a/src/datepicker/themes/bs/bs-datepicker-inline-container.component.ts +++ b/src/datepicker/themes/bs/bs-datepicker-inline-container.component.ts @@ -8,15 +8,23 @@ import { BsDatepickerStore } from '../../reducer/bs-datepicker.store'; import { PositioningService } from 'ngx-bootstrap/positioning'; import { datepickerAnimation } from '../../datepicker-animations'; +import { BsCustomDatesViewComponent } from './bs-custom-dates-view.component'; +import { BsYearsCalendarViewComponent } from './bs-years-calendar-view.component'; +import { BsMonthCalendarViewComponent } from './bs-months-calendar-view.component'; +import { TimepickerModule } from 'ngx-bootstrap/timepicker'; +import { BsDaysCalendarViewComponent } from './bs-days-calendar-view.component'; +import { NgIf, NgClass, NgSwitch, NgSwitchCase, NgFor, AsyncPipe } from '@angular/common'; @Component({ - selector: 'bs-datepicker-inline-container', - providers: [BsDatepickerStore, BsDatepickerEffects], - templateUrl: './bs-datepicker-view.html', - host: { - '(click)': '_stopPropagation($event)' - }, - animations: [datepickerAnimation] + selector: 'bs-datepicker-inline-container', + providers: [BsDatepickerStore, BsDatepickerEffects, PositioningService], + templateUrl: './bs-datepicker-view.html', + host: { + '(click)': '_stopPropagation($event)' + }, + animations: [datepickerAnimation], + standalone: true, + imports: [NgIf, NgClass, NgSwitch, NgSwitchCase, NgFor, BsDaysCalendarViewComponent, TimepickerModule, BsMonthCalendarViewComponent, BsYearsCalendarViewComponent, BsCustomDatesViewComponent, AsyncPipe] }) export class BsDatepickerInlineContainerComponent extends BsDatepickerContainerComponent implements OnInit, OnDestroy { diff --git a/src/datepicker/themes/bs/bs-datepicker-navigation-view.component.ts b/src/datepicker/themes/bs/bs-datepicker-navigation-view.component.ts index 406db3e13e..415122349d 100644 --- a/src/datepicker/themes/bs/bs-datepicker-navigation-view.component.ts +++ b/src/datepicker/themes/bs/bs-datepicker-navigation-view.component.ts @@ -1,10 +1,11 @@ import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core'; import { BsDatepickerViewMode, BsNavigationDirection, NavigationViewModel } from '../../models'; +import { NgIf } from '@angular/common'; @Component({ - selector: 'bs-datepicker-navigation-view', - changeDetection: ChangeDetectionStrategy.OnPush, - template: ` + selector: 'bs-datepicker-navigation-view', + changeDetection: ChangeDetectionStrategy.OnPush, + template: ` - ` + `, + standalone: true, + imports: [NgIf] }) export class BsDatepickerNavigationViewComponent { @Input() calendar!: NavigationViewModel; diff --git a/src/datepicker/themes/bs/bs-daterangepicker-container.component.ts b/src/datepicker/themes/bs/bs-daterangepicker-container.component.ts index 5dc2c65c26..b930213239 100644 --- a/src/datepicker/themes/bs/bs-daterangepicker-container.component.ts +++ b/src/datepicker/themes/bs/bs-daterangepicker-container.component.ts @@ -24,20 +24,39 @@ import { BsDatepickerActions } from '../../reducer/bs-datepicker.actions'; import { BsDatepickerEffects } from '../../reducer/bs-datepicker.effects'; import { BsDatepickerStore } from '../../reducer/bs-datepicker.store'; import { datepickerAnimation } from '../../datepicker-animations'; -import { BsCustomDates } from './bs-custom-dates-view.component'; +import { BsCustomDates, BsCustomDatesViewComponent } from './bs-custom-dates-view.component'; import { dayInMilliseconds } from '../../reducer/_defaults'; +import { BsYearsCalendarViewComponent } from './bs-years-calendar-view.component'; +import { BsMonthCalendarViewComponent } from './bs-months-calendar-view.component'; +import { TimepickerModule } from 'ngx-bootstrap/timepicker'; +import { BsDaysCalendarViewComponent } from './bs-days-calendar-view.component'; +import { NgIf, NgClass, NgSwitch, NgSwitchCase, NgFor, AsyncPipe } from '@angular/common'; @Component({ - selector: 'bs-daterangepicker-container', - providers: [BsDatepickerStore, BsDatepickerEffects], - templateUrl: './bs-datepicker-view.html', - host: { - class: 'bottom', - '(click)': '_stopPropagation($event)', - role: 'dialog', - 'aria-label': 'calendar' - }, - animations: [datepickerAnimation] + selector: 'bs-daterangepicker-container', + providers: [BsDatepickerStore, BsDatepickerEffects, BsDatepickerActions, PositioningService], + templateUrl: './bs-datepicker-view.html', + host: { + class: 'bottom', + '(click)': '_stopPropagation($event)', + role: 'dialog', + 'aria-label': 'calendar' + }, + animations: [datepickerAnimation], + standalone: true, + imports: [ + NgIf, + NgClass, + NgSwitch, + NgSwitchCase, + NgFor, + BsDaysCalendarViewComponent, + TimepickerModule, + BsMonthCalendarViewComponent, + BsYearsCalendarViewComponent, + BsCustomDatesViewComponent, + AsyncPipe + ] }) export class BsDaterangepickerContainerComponent extends BsDatepickerAbstractComponent diff --git a/src/datepicker/themes/bs/bs-daterangepicker-inline-container.component.ts b/src/datepicker/themes/bs/bs-daterangepicker-inline-container.component.ts index 62ec9084b6..df68a3ced9 100644 --- a/src/datepicker/themes/bs/bs-daterangepicker-inline-container.component.ts +++ b/src/datepicker/themes/bs/bs-daterangepicker-inline-container.component.ts @@ -8,15 +8,23 @@ import { BsDatepickerStore } from '../../reducer/bs-datepicker.store'; import { PositioningService } from 'ngx-bootstrap/positioning'; import { datepickerAnimation } from '../../datepicker-animations'; +import { BsCustomDatesViewComponent } from './bs-custom-dates-view.component'; +import { BsYearsCalendarViewComponent } from './bs-years-calendar-view.component'; +import { BsMonthCalendarViewComponent } from './bs-months-calendar-view.component'; +import { TimepickerModule } from 'ngx-bootstrap/timepicker'; +import { BsDaysCalendarViewComponent } from './bs-days-calendar-view.component'; +import { NgIf, NgClass, NgSwitch, NgSwitchCase, NgFor, AsyncPipe } from '@angular/common'; @Component({ - selector: 'bs-daterangepicker-inline-container', - providers: [BsDatepickerStore, BsDatepickerEffects], - templateUrl: './bs-datepicker-view.html', - host: { - '(click)': '_stopPropagation($event)' - }, - animations: [datepickerAnimation] + selector: 'bs-daterangepicker-inline-container', + providers: [BsDatepickerStore, BsDatepickerEffects, BsDatepickerActions, PositioningService], + templateUrl: './bs-datepicker-view.html', + host: { + '(click)': '_stopPropagation($event)' + }, + animations: [datepickerAnimation], + standalone: true, + imports: [NgIf, NgClass, NgSwitch, NgSwitchCase, NgFor, BsDaysCalendarViewComponent, TimepickerModule, BsMonthCalendarViewComponent, BsYearsCalendarViewComponent, BsCustomDatesViewComponent, AsyncPipe] }) export class BsDaterangepickerInlineContainerComponent extends BsDaterangepickerContainerComponent implements OnInit, OnDestroy { diff --git a/src/datepicker/themes/bs/bs-days-calendar-view.component.ts b/src/datepicker/themes/bs/bs-days-calendar-view.component.ts index e4a4ee05bc..5d17b3096f 100644 --- a/src/datepicker/themes/bs/bs-days-calendar-view.component.ts +++ b/src/datepicker/themes/bs/bs-days-calendar-view.component.ts @@ -18,11 +18,16 @@ import { } from '../../models'; import { BsDatepickerConfig } from '../../bs-datepicker.config'; +import { TooltipModule } from 'ngx-bootstrap/tooltip'; +import { BsDatepickerDayDecoratorComponent } from './bs-datepicker-day-decorator.directive'; +import { NgIf, NgFor } from '@angular/common'; +import { BsDatepickerNavigationViewComponent } from './bs-datepicker-navigation-view.component'; +import { BsCalendarLayoutComponent } from './bs-calendar-layout.component'; @Component({ - selector: 'bs-days-calendar-view', - // changeDetection: ChangeDetectionStrategy.OnPush, - template: ` + selector: 'bs-days-calendar-view', + // changeDetection: ChangeDetectionStrategy.OnPush, + template: ` - ` + `, + standalone: true, + imports: [BsCalendarLayoutComponent, BsDatepickerNavigationViewComponent, NgIf, NgFor, BsDatepickerDayDecoratorComponent, TooltipModule] }) export class BsDaysCalendarViewComponent { @Input() calendar!: DaysCalendarViewModel; diff --git a/src/datepicker/themes/bs/bs-months-calendar-view.component.ts b/src/datepicker/themes/bs/bs-months-calendar-view.component.ts index be554adc1d..cc7f911eed 100644 --- a/src/datepicker/themes/bs/bs-months-calendar-view.component.ts +++ b/src/datepicker/themes/bs/bs-months-calendar-view.component.ts @@ -7,10 +7,13 @@ import { MonthsCalendarViewModel, CalendarCellViewModel } from '../../models'; +import { NgFor } from '@angular/common'; +import { BsDatepickerNavigationViewComponent } from './bs-datepicker-navigation-view.component'; +import { BsCalendarLayoutComponent } from './bs-calendar-layout.component'; @Component({ - selector: 'bs-month-calendar-view', - template: ` + selector: 'bs-month-calendar-view', + template: ` - ` + `, + standalone: true, + imports: [BsCalendarLayoutComponent, BsDatepickerNavigationViewComponent, NgFor] }) export class BsMonthCalendarViewComponent { @Input() calendar!: MonthsCalendarViewModel; diff --git a/src/datepicker/themes/bs/bs-timepicker-view.component.ts b/src/datepicker/themes/bs/bs-timepicker-view.component.ts index 6b666da4e3..4fa22243d5 100644 --- a/src/datepicker/themes/bs/bs-timepicker-view.component.ts +++ b/src/datepicker/themes/bs/bs-timepicker-view.component.ts @@ -1,8 +1,8 @@ import { Component } from '@angular/core'; @Component({ - selector: 'bs-timepicker', - template: ` + selector: 'bs-timepicker', + template: `
@@ -20,7 +20,8 @@ import { Component } from '@angular/core'; alt="">
- ` + `, + standalone: true }) export class BsTimepickerViewComponent { ampm = 'ok'; diff --git a/src/datepicker/themes/bs/bs-years-calendar-view.component.ts b/src/datepicker/themes/bs/bs-years-calendar-view.component.ts index 5b0a658c29..7641aeb478 100644 --- a/src/datepicker/themes/bs/bs-years-calendar-view.component.ts +++ b/src/datepicker/themes/bs/bs-years-calendar-view.component.ts @@ -8,10 +8,13 @@ import { CellHoverEvent, YearsCalendarViewModel } from '../../models'; +import { NgFor } from '@angular/common'; +import { BsDatepickerNavigationViewComponent } from './bs-datepicker-navigation-view.component'; +import { BsCalendarLayoutComponent } from './bs-calendar-layout.component'; @Component({ - selector: 'bs-years-calendar-view', - template: ` + selector: 'bs-years-calendar-view', + template: ` - ` + `, + standalone: true, + imports: [BsCalendarLayoutComponent, BsDatepickerNavigationViewComponent, NgFor] }) export class BsYearsCalendarViewComponent { @Input() calendar!: YearsCalendarViewModel; diff --git a/src/dropdown/bs-dropdown-container.component.ts b/src/dropdown/bs-dropdown-container.component.ts index e24ce958aa..ea8e5749a8 100644 --- a/src/dropdown/bs-dropdown-container.component.ts +++ b/src/dropdown/bs-dropdown-container.component.ts @@ -12,12 +12,15 @@ import { BsDropdownState } from './bs-dropdown.state'; import { dropdownAnimation } from './dropdown-animations'; import { AnimationBuilder, AnimationFactory } from '@angular/animations'; import { Subscription } from 'rxjs'; +import { NgClass } from '@angular/common'; // todo: revert ngClass to [class] when false positive angular-cli issue is fixed // [class.dropdown]="direction === 'down'"--> @Component({ selector: 'bs-dropdown-container', changeDetection: ChangeDetectionStrategy.OnPush, + standalone: true, + imports: [NgClass], // eslint-disable-next-line @angular-eslint/no-host-metadata-property host: { style: 'display:block;position: absolute;z-index: 1040' @@ -28,7 +31,8 @@ import { Subscription } from 'rxjs'; [class.show]="isOpen" [class.open]="isOpen">
- ` + `, + providers: [BsDropdownState] }) export class BsDropdownContainerComponent implements OnDestroy { isOpen = false; diff --git a/src/dropdown/bs-dropdown-menu.directive.ts b/src/dropdown/bs-dropdown-menu.directive.ts index 2fdc8898cd..5bc064e579 100644 --- a/src/dropdown/bs-dropdown-menu.directive.ts +++ b/src/dropdown/bs-dropdown-menu.directive.ts @@ -3,7 +3,8 @@ import { BsDropdownState } from './bs-dropdown.state'; @Directive({ selector: '[bsDropdownMenu],[dropdownMenu]', - exportAs: 'bs-dropdown-menu' + exportAs: 'bs-dropdown-menu', + standalone: true }) export class BsDropdownMenuDirective { constructor( diff --git a/src/dropdown/bs-dropdown-toggle.directive.ts b/src/dropdown/bs-dropdown-toggle.directive.ts index a42ec9d076..68566d0e95 100644 --- a/src/dropdown/bs-dropdown-toggle.directive.ts +++ b/src/dropdown/bs-dropdown-toggle.directive.ts @@ -18,7 +18,8 @@ import { BsDropdownDirective } from './bs-dropdown.directive'; // eslint-disable-next-line @angular-eslint/no-host-metadata-property host: { '[attr.aria-haspopup]': 'true' - } + }, + standalone: true }) export class BsDropdownToggleDirective implements OnDestroy { @HostBinding('attr.disabled') isDisabled: undefined | true; diff --git a/src/dropdown/bs-dropdown.directive.ts b/src/dropdown/bs-dropdown.directive.ts index e4bff6932e..dd6f4f3578 100644 --- a/src/dropdown/bs-dropdown.directive.ts +++ b/src/dropdown/bs-dropdown.directive.ts @@ -25,7 +25,8 @@ import { dropdownAnimation } from './dropdown-animations'; @Directive({ selector: '[bsDropdown], [dropdown]', exportAs: 'bs-dropdown', - providers: [BsDropdownState], + providers: [BsDropdownState, ComponentLoaderFactory, BsDropdownConfig], + standalone: true, // eslint-disable-next-line @angular-eslint/no-host-metadata-property host: { '[class.dropup]': 'dropup', diff --git a/src/dropdown/bs-dropdown.module.ts b/src/dropdown/bs-dropdown.module.ts index d7b0d8010a..5ab54af6fd 100644 --- a/src/dropdown/bs-dropdown.module.ts +++ b/src/dropdown/bs-dropdown.module.ts @@ -1,22 +1,17 @@ -import { CommonModule } from '@angular/common'; -import { ModuleWithProviders, NgModule } from '@angular/core'; -import { ComponentLoaderFactory } from 'ngx-bootstrap/component-loader'; +import { NgModule } from '@angular/core'; -import { PositioningService } from 'ngx-bootstrap/positioning'; import { BsDropdownContainerComponent } from './bs-dropdown-container.component'; import { BsDropdownMenuDirective } from './bs-dropdown-menu.directive'; import { BsDropdownToggleDirective } from './bs-dropdown-toggle.directive'; import { BsDropdownDirective } from './bs-dropdown.directive'; -import { BsDropdownState } from './bs-dropdown.state'; @NgModule({ - imports: [CommonModule], - declarations: [ - BsDropdownMenuDirective, - BsDropdownToggleDirective, - BsDropdownContainerComponent, - BsDropdownDirective + imports: [ + BsDropdownDirective, + BsDropdownContainerComponent, + BsDropdownMenuDirective, + BsDropdownToggleDirective ], exports: [ BsDropdownMenuDirective, @@ -25,14 +20,8 @@ import { BsDropdownState } from './bs-dropdown.state'; ] }) export class BsDropdownModule { - static forRoot(): ModuleWithProviders { - return { - ngModule: BsDropdownModule, - providers: [ - ComponentLoaderFactory, - PositioningService, - BsDropdownState - ] - }; + // @deprecated method not required anymore, will be deleted in v19.0.0 + static forRoot() { + return BsDropdownModule; } } diff --git a/src/dropdown/package.json b/src/dropdown/package.json index b979ff0d5f..1c22dd6f4b 100644 --- a/src/dropdown/package.json +++ b/src/dropdown/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/dropdown", - "version": "18.0.2", + "version": "18.1.0", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/dropdown/testing/bs-dropdown-container.component.spec.ts b/src/dropdown/testing/bs-dropdown-container.component.spec.ts index be541cfcbb..d9ff630454 100644 --- a/src/dropdown/testing/bs-dropdown-container.component.spec.ts +++ b/src/dropdown/testing/bs-dropdown-container.component.spec.ts @@ -17,7 +17,7 @@ describe('BsDropdownContainerComponent tests', () => { }; TestBed.configureTestingModule({ imports: [ - BsDropdownModule.forRoot(), + BsDropdownModule, BrowserAnimationsModule ], providers: [{ provide: BsDropdownState, useValue: fakeService }] diff --git a/src/dropdown/testing/bs-dropdown.directive.spec.ts b/src/dropdown/testing/bs-dropdown.directive.spec.ts index 52cab11926..173ed3fdff 100644 --- a/src/dropdown/testing/bs-dropdown.directive.spec.ts +++ b/src/dropdown/testing/bs-dropdown.directive.spec.ts @@ -50,7 +50,7 @@ describe('Directive: Dropdown', () => { TestBed.configureTestingModule({ declarations: [TestDropdownComponent], imports: [ - BsDropdownModule.forRoot(), + BsDropdownModule, BrowserAnimationsModule ] }); diff --git a/src/focus-trap/focus-trap.module.ts b/src/focus-trap/focus-trap.module.ts index 4fec94fc00..60ecd48574 100644 --- a/src/focus-trap/focus-trap.module.ts +++ b/src/focus-trap/focus-trap.module.ts @@ -1,25 +1,15 @@ -import { ModuleWithProviders, NgModule } from '@angular/core'; +import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; -import { FocusTrapManager } from './focus-trap-manager'; -import { InteractivityChecker } from './interactivity-checker'; import { FocusTrapDirective } from './focus-trap'; -import { Platform } from './platform'; @NgModule({ - imports: [CommonModule], - declarations: [FocusTrapDirective], - exports: [FocusTrapDirective] + imports: [CommonModule, FocusTrapDirective], + exports: [FocusTrapDirective] }) export class FocusTrapModule { - static forRoot(): ModuleWithProviders { - return { - ngModule: FocusTrapModule, - providers: [ - FocusTrapManager, - Platform, - InteractivityChecker - ] - }; + // @deprecated method not required anymore, will be deleted in v19.0.0 + static forRoot() { + return FocusTrapModule; } } diff --git a/src/focus-trap/focus-trap.ts b/src/focus-trap/focus-trap.ts index 42daa06875..bd0c43dc49 100644 --- a/src/focus-trap/focus-trap.ts +++ b/src/focus-trap/focus-trap.ts @@ -25,6 +25,8 @@ import { } from '@angular/core'; import { take } from 'rxjs/operators'; import { InteractivityChecker } from './interactivity-checker'; +import { FocusTrapManager } from './focus-trap-manager'; +import { Platform } from './platform'; /** @@ -386,8 +388,14 @@ export class FocusTrapFactory { /** Directive for trapping focus within a region. */ @Directive({ - selector: '[focusTrap]', - exportAs: 'focusTrap' + selector: '[focusTrap]', + exportAs: 'focusTrap', + standalone: true, + providers: [ + FocusTrapManager, + Platform, + InteractivityChecker + ] }) export class FocusTrapDirective implements OnDestroy, AfterContentInit, OnChanges, DoCheck { private _document: Document; diff --git a/src/focus-trap/package.json b/src/focus-trap/package.json index 798cddf9e9..a68da03899 100644 --- a/src/focus-trap/package.json +++ b/src/focus-trap/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/focus-trap", - "version": "18.0.2", + "version": "18.1.0", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/locale/package.json b/src/locale/package.json index f798d0e568..fbe62dc60b 100644 --- a/src/locale/package.json +++ b/src/locale/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/locale", - "version": "18.0.2", + "version": "18.1.0", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/mini-ngrx/package.json b/src/mini-ngrx/package.json index 0a88fb31d2..fb562980c5 100644 --- a/src/mini-ngrx/package.json +++ b/src/mini-ngrx/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/mini-ngrx", - "version": "18.0.2", + "version": "18.1.0", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/modal/bs-modal.service.ts b/src/modal/bs-modal.service.ts index a5a253b24a..490bf2b4cd 100644 --- a/src/modal/bs-modal.service.ts +++ b/src/modal/bs-modal.service.ts @@ -42,6 +42,7 @@ export class BsModalService { protected backdropRef?: ComponentRef; private _backdropLoader: ComponentLoader; private modalsCount = 0; + private lastHiddenId: number | string | undefined = 0; private lastDismissReason?: string; private loaders: ComponentLoader[] = []; @@ -83,6 +84,10 @@ export class BsModalService { } hide(id?: number | string) { + if (this.lastHiddenId === id) { + return; + } + this.lastHiddenId = id; if (this.modalsCount === 1 || id == null) { this._hideBackdrop(); this.resetScrollbar(); diff --git a/src/modal/modal-backdrop.component.ts b/src/modal/modal-backdrop.component.ts index 3ae8796015..4271a25cf8 100644 --- a/src/modal/modal-backdrop.component.ts +++ b/src/modal/modal-backdrop.component.ts @@ -6,10 +6,11 @@ import { Utils } from 'ngx-bootstrap/utils'; /** This component will be added as background layout for modals if enabled */ @Component({ - selector: 'bs-modal-backdrop', - template: ' ', - // eslint-disable-next-line @angular-eslint/no-host-metadata-property - host: { class: CLASS_NAME.BACKDROP } + selector: 'bs-modal-backdrop', + template: ' ', + // eslint-disable-next-line @angular-eslint/no-host-metadata-property + host: { class: CLASS_NAME.BACKDROP }, + standalone: true }) export class ModalBackdropComponent implements OnInit { get isAnimated(): boolean { diff --git a/src/modal/modal-container.component.ts b/src/modal/modal-container.component.ts index fd3f09ccb8..5f09ecdd73 100644 --- a/src/modal/modal-container.component.ts +++ b/src/modal/modal-container.component.ts @@ -14,10 +14,11 @@ import { } from './modal-options.class'; import { BsModalService } from './bs-modal.service'; import { document } from 'ngx-bootstrap/utils'; +import { FocusTrapDirective } from 'ngx-bootstrap/focus-trap'; @Component({ - selector: 'modal-container', - template: ` + selector: 'modal-container', + template: `
@@ -26,15 +27,18 @@ import { document } from 'ngx-bootstrap/utils';
`, - // eslint-disable-next-line @angular-eslint/no-host-metadata-property - host: { - class: 'modal', - role: 'dialog', - tabindex: '-1', - '[attr.aria-modal]': 'true', - '[attr.aria-labelledby]': 'config.ariaLabelledBy', - '[attr.aria-describedby]': 'config.ariaDescribedby' - } + // eslint-disable-next-line @angular-eslint/no-host-metadata-property + host: { + class: 'modal', + role: 'dialog', + tabindex: '-1', + '[attr.aria-modal]': 'true', + '[attr.aria-labelledby]': 'config.ariaLabelledBy', + '[attr.aria-describedby]': 'config.ariaDescribedby' + }, + standalone: true, + imports: [FocusTrapDirective], + providers: [BsModalService] }) export class ModalContainerComponent implements OnInit, OnDestroy { config: ModalOptions; diff --git a/src/modal/modal.directive.ts b/src/modal/modal.directive.ts index 0d72bccf62..9093448ca1 100644 --- a/src/modal/modal.directive.ts +++ b/src/modal/modal.directive.ts @@ -20,8 +20,9 @@ const BACKDROP_TRANSITION_DURATION = 150; /** Mark any code with directive to show it's content in modal */ @Directive({ - selector: '[bsModal]', - exportAs: 'bs-modal' + selector: '[bsModal]', + exportAs: 'bs-modal', + standalone: true }) export class ModalDirective implements OnDestroy, OnInit { /** allows to set modal configuration via element property */ diff --git a/src/modal/modal.module.ts b/src/modal/modal.module.ts index 85f0a91b6d..76b5b06e6f 100644 --- a/src/modal/modal.module.ts +++ b/src/modal/modal.module.ts @@ -1,32 +1,33 @@ -import { NgModule, ModuleWithProviders } from '@angular/core'; +import { ModuleWithProviders, NgModule } from '@angular/core'; -import { PositioningService } from 'ngx-bootstrap/positioning'; -import { ComponentLoaderFactory } from 'ngx-bootstrap/component-loader'; import { FocusTrapModule } from 'ngx-bootstrap/focus-trap'; import { ModalBackdropComponent } from './modal-backdrop.component'; import { ModalDirective } from './modal.directive'; import { ModalContainerComponent } from './modal-container.component'; import { BsModalService } from './bs-modal.service'; - -export const focusTrapModule = FocusTrapModule.forRoot(); +import { ComponentLoaderFactory } from 'ngx-bootstrap/component-loader'; +import { PositioningService } from 'ngx-bootstrap/positioning'; @NgModule({ - imports: [FocusTrapModule], - declarations: [ - ModalBackdropComponent, - ModalDirective, - ModalContainerComponent + imports: [ + FocusTrapModule, + ModalBackdropComponent, + ModalDirective, + ModalContainerComponent ], exports: [ModalBackdropComponent, ModalDirective] }) export class ModalModule { + // @deprecated method not required anymore, will be deleted in v19.0.0 static forRoot(): ModuleWithProviders { return { ngModule: ModalModule, providers: [BsModalService, ComponentLoaderFactory, PositioningService] }; } + + // @deprecated method not required anymore, will be deleted in v19.0.0 static forChild(): ModuleWithProviders { return { ngModule: ModalModule, diff --git a/src/modal/package.json b/src/modal/package.json index 0b076c8e90..26ad72a93b 100644 --- a/src/modal/package.json +++ b/src/modal/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/modal", - "version": "18.0.2", + "version": "18.1.0", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/modal/testing/modal-backdrop.component.spec.ts b/src/modal/testing/modal-backdrop.component.spec.ts index 15afb57292..0a65861a8f 100644 --- a/src/modal/testing/modal-backdrop.component.spec.ts +++ b/src/modal/testing/modal-backdrop.component.spec.ts @@ -6,8 +6,8 @@ describe('ModalBackdropComponent tests', () => { let component: ModalBackdropComponent; beforeEach(() => { TestBed.configureTestingModule({ - declarations: [ModalBackdropComponent] - }); + imports: [ModalBackdropComponent] +}); fixture = TestBed.createComponent(ModalBackdropComponent); component = fixture.componentInstance; fixture.detectChanges(); diff --git a/src/modal/testing/modal.default-setting.spec.ts b/src/modal/testing/modal.default-setting.spec.ts index 22639672c3..5ec395d1f5 100644 --- a/src/modal/testing/modal.default-setting.spec.ts +++ b/src/modal/testing/modal.default-setting.spec.ts @@ -29,7 +29,7 @@ describe('Modal service', () => { TestBed.configureTestingModule({ declarations: [DummyComponent], providers: [BsModalService], - imports: [ModalModule.forRoot(), TestModule] + imports: [ModalModule, TestModule] }); fixture = TestBed.createComponent(DummyComponent); modalService = fixture.debugElement.injector.get(BsModalService); diff --git a/src/modal/testing/modal.service.spec.ts b/src/modal/testing/modal.service.spec.ts index 5e827167cc..c40b8f3e1f 100644 --- a/src/modal/testing/modal.service.spec.ts +++ b/src/modal/testing/modal.service.spec.ts @@ -28,7 +28,7 @@ describe('Modal service', () => { TestBed.configureTestingModule({ declarations: [DummyComponent], providers: [BsModalService], - imports: [ModalModule.forRoot(), TestModule] + imports: [ModalModule, TestModule] }); fixture = TestBed.createComponent(DummyComponent); modalService = fixture.debugElement.injector.get(BsModalService); diff --git a/src/pagination/package.json b/src/pagination/package.json index 65ea992f8e..91a730bb89 100644 --- a/src/pagination/package.json +++ b/src/pagination/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/pagination", - "version": "18.0.2", + "version": "18.1.0", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/pagination/pager.component.ts b/src/pagination/pager.component.ts index 92e3e923fb..04347cac08 100644 --- a/src/pagination/pager.component.ts +++ b/src/pagination/pager.component.ts @@ -15,6 +15,7 @@ import { ConfigModel, PagesModel } from './models'; import { PageChangedEvent } from './pagination.component'; import { PaginationConfig } from './pagination.config'; +import { NgClass } from '@angular/common'; export const PAGER_CONTROL_VALUE_ACCESSOR: Provider = { provide: NG_VALUE_ACCESSOR, @@ -23,9 +24,11 @@ export const PAGER_CONTROL_VALUE_ACCESSOR: Provider = { }; @Component({ - selector: 'pager', - templateUrl: './pager.component.html', - providers: [PAGER_CONTROL_VALUE_ACCESSOR] + selector: 'pager', + templateUrl: './pager.component.html', + providers: [PAGER_CONTROL_VALUE_ACCESSOR], + standalone: true, + imports: [NgClass] }) export class PagerComponent implements ControlValueAccessor, OnInit { config?: Partial; diff --git a/src/pagination/pagination.component.ts b/src/pagination/pagination.component.ts index abfdb1c3f2..9bb0fdee0e 100644 --- a/src/pagination/pagination.component.ts +++ b/src/pagination/pagination.component.ts @@ -14,6 +14,7 @@ import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'; import { ConfigModel, PagesModel, PaginationLinkContext, PaginationNumberLinkContext } from './models'; import { PaginationConfig } from './pagination.config'; +import { NgClass, NgIf, NgTemplateOutlet, NgFor } from '@angular/common'; export interface PageChangedEvent { itemsPerPage: number; @@ -27,9 +28,11 @@ export const PAGINATION_CONTROL_VALUE_ACCESSOR: Provider = { }; @Component({ - selector: 'pagination', - templateUrl: './pagination.component.html', - providers: [PAGINATION_CONTROL_VALUE_ACCESSOR] + selector: 'pagination', + templateUrl: './pagination.component.html', + providers: [PAGINATION_CONTROL_VALUE_ACCESSOR], + standalone: true, + imports: [NgClass, NgIf, NgTemplateOutlet, NgFor] }) export class PaginationComponent implements ControlValueAccessor, OnInit { config?: Partial; diff --git a/src/pagination/pagination.module.ts b/src/pagination/pagination.module.ts index ff9c1a926e..0dc6fd8334 100644 --- a/src/pagination/pagination.module.ts +++ b/src/pagination/pagination.module.ts @@ -1,16 +1,16 @@ import { CommonModule } from '@angular/common'; -import { NgModule, ModuleWithProviders } from '@angular/core'; +import { NgModule } from '@angular/core'; import { PagerComponent } from './pager.component'; import { PaginationComponent } from './pagination.component'; @NgModule({ - imports: [CommonModule], - declarations: [PagerComponent, PaginationComponent], - exports: [PagerComponent, PaginationComponent] + imports: [CommonModule, PagerComponent, PaginationComponent], + exports: [PagerComponent, PaginationComponent] }) export class PaginationModule { - static forRoot(): ModuleWithProviders { - return { ngModule: PaginationModule, providers: [] }; + // @deprecated method not required anymore, will be deleted in v19.0.0 + static forRoot() { + return PaginationModule; } } diff --git a/src/pagination/testing/pager.component.spec.ts b/src/pagination/testing/pager.component.spec.ts index ebbab050ac..b91ed275ba 100644 --- a/src/pagination/testing/pager.component.spec.ts +++ b/src/pagination/testing/pager.component.spec.ts @@ -16,7 +16,7 @@ describe('Component: Pager:', () => { beforeEach(() => { TestBed.configureTestingModule({ - imports: [PaginationModule.forRoot()] + imports: [PaginationModule] }); fixture = TestBed.createComponent(PagerComponent); context = fixture.debugElement.componentInstance; diff --git a/src/pagination/testing/pagination.component.spec.ts b/src/pagination/testing/pagination.component.spec.ts index f7633d267b..a48dce7f27 100644 --- a/src/pagination/testing/pagination.component.spec.ts +++ b/src/pagination/testing/pagination.component.spec.ts @@ -14,7 +14,7 @@ describe('Component: Pagination:', () => { beforeEach(() => { TestBed.configureTestingModule({ - imports: [PaginationModule.forRoot()] + imports: [PaginationModule] }); fixture = TestBed.createComponent(PaginationComponent); context = fixture.debugElement.componentInstance; diff --git a/src/popover/package.json b/src/popover/package.json index 181f647f9a..7f533c3196 100644 --- a/src/popover/package.json +++ b/src/popover/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/popover", - "version": "18.0.2", + "version": "18.1.0", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/popover/popover-container.component.ts b/src/popover/popover-container.component.ts index be845b9693..44fe02989c 100644 --- a/src/popover/popover-container.component.ts +++ b/src/popover/popover-container.component.ts @@ -2,22 +2,22 @@ import { ChangeDetectionStrategy, Input, Component } from '@angular/core'; import { PopoverConfig } from './popover.config'; import { getBsVer, IBsVersion } from 'ngx-bootstrap/utils'; import { PlacementForBs5, checkMargins, AvailableBSPositions } from 'ngx-bootstrap/positioning'; +import { NgIf } from '@angular/common'; @Component({ - selector: 'popover-container', - changeDetection: ChangeDetectionStrategy.OnPush, - // eslint-disable-next-line @angular-eslint/no-host-metadata-property - host: { - '[attr.id]': 'popoverId', - '[class]': - '"popover in popover-" + _placement + " " + "bs-popover-" + _placement + " " + _placement + " " + containerClass + " " + checkMarginNecessity()', - '[class.show]': '!_bsVersions.isBs3', - '[class.bs3]': '_bsVersions.isBs3', - role: 'tooltip', - style: 'display:block; position:absolute' - }, - styles: [ - ` + selector: 'popover-container', + changeDetection: ChangeDetectionStrategy.OnPush, + // eslint-disable-next-line @angular-eslint/no-host-metadata-property + host: { + '[attr.id]': 'popoverId', + '[class]': '"popover in popover-" + _placement + " " + "bs-popover-" + _placement + " " + _placement + " " + containerClass + " " + checkMarginNecessity()', + '[class.show]': '!_bsVersions.isBs3', + '[class.bs3]': '_bsVersions.isBs3', + role: 'tooltip', + style: 'display:block; position:absolute' + }, + styles: [ + ` :host.popover.bottom > .arrow { margin-left: -4px; } @@ -26,8 +26,10 @@ import { PlacementForBs5, checkMargins, AvailableBSPositions } from 'ngx-bootstr position: absolute; } ` - ], - templateUrl: './popover-container.component.html' + ], + templateUrl: './popover-container.component.html', + standalone: true, + imports: [NgIf] }) export class PopoverContainerComponent { @Input() set placement(value: AvailableBSPositions) { diff --git a/src/popover/popover.directive.ts b/src/popover/popover.directive.ts index 2a99169143..cb9d953d95 100644 --- a/src/popover/popover.directive.ts +++ b/src/popover/popover.directive.ts @@ -22,7 +22,12 @@ let id = 0; /** * A lightweight, extensible directive for fancy popover creation. */ -@Directive({ selector: '[popover]', exportAs: 'bs-popover' }) +@Directive({ + selector: '[popover]', + exportAs: 'bs-popover', + standalone: true, + providers: [ PositioningService, ComponentLoaderFactory ] +}) export class PopoverDirective implements OnInit, OnDestroy { /** unique id popover - use for aria-describedby */ popoverId = id++; diff --git a/src/popover/popover.module.ts b/src/popover/popover.module.ts index ef030556f7..d992626951 100644 --- a/src/popover/popover.module.ts +++ b/src/popover/popover.module.ts @@ -1,21 +1,16 @@ -import { NgModule, ModuleWithProviders } from '@angular/core'; +import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; -import { ComponentLoaderFactory } from 'ngx-bootstrap/component-loader'; -import { PositioningService } from 'ngx-bootstrap/positioning'; import { PopoverDirective } from './popover.directive'; import { PopoverContainerComponent } from './popover-container.component'; @NgModule({ - imports: [CommonModule], - declarations: [PopoverDirective, PopoverContainerComponent], + imports: [CommonModule, PopoverDirective, PopoverContainerComponent], exports: [PopoverDirective] }) export class PopoverModule { - static forRoot(): ModuleWithProviders { - return { - ngModule: PopoverModule, - providers: [ComponentLoaderFactory, PositioningService] - }; + // @deprecated method not required anymore, will be deleted in v19.0.0 + static forRoot() { + return PopoverModule; } } diff --git a/src/positioning/package.json b/src/positioning/package.json index 16268dc595..6043faf3a7 100644 --- a/src/positioning/package.json +++ b/src/positioning/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/positioning", - "version": "18.0.2", + "version": "18.1.0", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/progressbar/bar.component.ts b/src/progressbar/bar.component.ts index 35a8a86907..23fd07a5dc 100644 --- a/src/progressbar/bar.component.ts +++ b/src/progressbar/bar.component.ts @@ -11,22 +11,23 @@ import { import { ProgressbarType } from './progressbar-type.interface'; @Component({ - selector: 'bar', - templateUrl: './bar.component.html', - changeDetection: ChangeDetectionStrategy.OnPush, - // eslint-disable-next-line @angular-eslint/no-host-metadata-property - host: { - role: 'progressbar', - 'aria-valuemin': '0', - '[class.progress-bar]': 'true', - '[class.progress-bar-animated]': 'animate', - '[class.progress-bar-striped]': 'striped', - '[attr.aria-valuenow]': 'value', - '[attr.aria-valuetext]': 'percent ? percent.toFixed(0) + "%" : ""', - '[attr.aria-valuemax]': 'max', - '[style.height.%]': '"100"', - '[style.width.%]': 'percent' - } + selector: 'bar', + templateUrl: './bar.component.html', + changeDetection: ChangeDetectionStrategy.OnPush, + // eslint-disable-next-line @angular-eslint/no-host-metadata-property + host: { + role: 'progressbar', + 'aria-valuemin': '0', + '[class.progress-bar]': 'true', + '[class.progress-bar-animated]': 'animate', + '[class.progress-bar-striped]': 'striped', + '[attr.aria-valuenow]': 'value', + '[attr.aria-valuetext]': 'percent ? percent.toFixed(0) + "%" : ""', + '[attr.aria-valuemax]': 'max', + '[style.height.%]': '"100"', + '[style.width.%]': 'percent' + }, + standalone: true }) export class BarComponent implements OnChanges { /** maximum total value of progress element */ diff --git a/src/progressbar/package.json b/src/progressbar/package.json index adba2d57f4..2339be3541 100644 --- a/src/progressbar/package.json +++ b/src/progressbar/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/progressbar", - "version": "18.0.2", + "version": "18.1.0", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/progressbar/progressbar.component.ts b/src/progressbar/progressbar.component.ts index 4e78dc1f10..b8967f9ae7 100644 --- a/src/progressbar/progressbar.component.ts +++ b/src/progressbar/progressbar.component.ts @@ -1,21 +1,25 @@ import { ChangeDetectionStrategy, Component, Input } from '@angular/core'; import { BarValue, ProgressbarType } from './progressbar-type.interface'; import { ProgressbarConfig } from './progressbar.config'; +import { BarComponent } from './bar.component'; +import { NgIf, NgFor } from '@angular/common'; @Component({ - selector: 'progressbar', - templateUrl: './progressbar.component.html', - changeDetection: ChangeDetectionStrategy.OnPush, - // eslint-disable-next-line @angular-eslint/no-host-metadata-property - host: { - '[class.progress]': 'true', - '[attr.max]': 'max' - }, - styles: [` + selector: 'progressbar', + templateUrl: './progressbar.component.html', + changeDetection: ChangeDetectionStrategy.OnPush, + // eslint-disable-next-line @angular-eslint/no-host-metadata-property + host: { + '[class.progress]': 'true', + '[attr.max]': 'max' + }, + styles: [` :host { width: 100%; display: flex; - } `] + } `], + standalone: true, + imports: [NgIf, BarComponent, NgFor] }) export class ProgressbarComponent { /** maximum total value of progress element */ diff --git a/src/progressbar/progressbar.module.ts b/src/progressbar/progressbar.module.ts index 207ed17a45..feb7ac4f90 100644 --- a/src/progressbar/progressbar.module.ts +++ b/src/progressbar/progressbar.module.ts @@ -1,16 +1,15 @@ -import { CommonModule } from '@angular/common'; -import { NgModule, ModuleWithProviders } from '@angular/core'; +import { NgModule } from '@angular/core'; import { BarComponent } from './bar.component'; import { ProgressbarComponent } from './progressbar.component'; @NgModule({ - imports: [CommonModule], - declarations: [BarComponent, ProgressbarComponent], - exports: [BarComponent, ProgressbarComponent] + imports: [BarComponent, ProgressbarComponent], + exports: [BarComponent, ProgressbarComponent] }) export class ProgressbarModule { - static forRoot(): ModuleWithProviders { - return { ngModule: ProgressbarModule, providers: [] }; + // @deprecated method not required anymore, will be deleted in v19.0.0 + static forRoot() { + return ProgressbarModule; } } diff --git a/src/progressbar/testing/progressbar.component.spec.ts b/src/progressbar/testing/progressbar.component.spec.ts index 273545d29b..7028dbe435 100644 --- a/src/progressbar/testing/progressbar.component.spec.ts +++ b/src/progressbar/testing/progressbar.component.spec.ts @@ -20,7 +20,7 @@ describe('Component: Progress Bar', () => { it('check animate setter when _animate is equal to setter\'s argument', () => { TestBed.configureTestingModule({ declarations: [TestProgressbarComponent], - imports: [ProgressbarModule.forRoot()] + imports: [ProgressbarModule] }); fixture = TestBed.createComponent(TestProgressbarComponent); component = fixture.componentInstance; @@ -33,7 +33,7 @@ describe('Component: Progress Bar', () => { it('check striped setter when _striped is equal to setter\'s argument', () => { TestBed.configureTestingModule({ declarations: [TestProgressbarComponent], - imports: [ProgressbarModule.forRoot()] + imports: [ProgressbarModule] }); fixture = TestBed.createComponent(TestProgressbarComponent); component = fixture.componentInstance; @@ -47,7 +47,7 @@ describe('Component: Progress Bar', () => { const tpl = ``; TestBed.configureTestingModule({ declarations: [TestProgressbarComponent], - imports: [ProgressbarModule.forRoot()] + imports: [ProgressbarModule] }); TestBed.overrideComponent(TestProgressbarComponent, { set: { template: tpl } @@ -65,7 +65,7 @@ describe('Component: Progress Bar', () => { const tpl = ``; TestBed.configureTestingModule({ declarations: [TestProgressbarComponent], - imports: [ProgressbarModule.forRoot()] + imports: [ProgressbarModule] }); TestBed.overrideComponent(TestProgressbarComponent, { set: { template: tpl } @@ -85,7 +85,7 @@ describe('Component: Progress Bar', () => { const tpl = ``; TestBed.configureTestingModule({ declarations: [TestProgressbarComponent], - imports: [ProgressbarModule.forRoot()] + imports: [ProgressbarModule] }); TestBed.overrideComponent(TestProgressbarComponent, { set: { template: tpl } @@ -113,7 +113,7 @@ describe('Component: Progress Bar', () => { const tpl = ``; TestBed.configureTestingModule({ declarations: [TestProgressbarComponent], - imports: [ProgressbarModule.forRoot()] + imports: [ProgressbarModule] }); TestBed.overrideComponent(TestProgressbarComponent, { set: { template: tpl } @@ -147,7 +147,7 @@ describe('progress bar', () => { beforeEach(() => { TestBed.configureTestingModule({ declarations: [TestProgressbarComponent], - imports: [ProgressbarModule.forRoot()] + imports: [ProgressbarModule] }); fixture = TestBed.overrideComponent(TestProgressbarComponent, { set: { template: tpl } diff --git a/src/rating/package.json b/src/rating/package.json index d3ee92def2..ee9399e5ab 100644 --- a/src/rating/package.json +++ b/src/rating/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/rating", - "version": "18.0.2", + "version": "18.1.0", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/rating/rating.component.ts b/src/rating/rating.component.ts index e382b7d9b3..e1fd2a3285 100644 --- a/src/rating/rating.component.ts +++ b/src/rating/rating.component.ts @@ -14,6 +14,7 @@ import { import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'; import { RatingResults } from './models'; import { RatingConfig } from './rating.config'; +import { NgFor, NgTemplateOutlet } from '@angular/common'; export const RATING_CONTROL_VALUE_ACCESSOR: Provider = { provide: NG_VALUE_ACCESSOR, @@ -22,10 +23,12 @@ export const RATING_CONTROL_VALUE_ACCESSOR: Provider = { }; @Component({ - selector: 'rating', - templateUrl: './rating.component.html', - providers: [RATING_CONTROL_VALUE_ACCESSOR], - changeDetection: ChangeDetectionStrategy.OnPush + selector: 'rating', + templateUrl: './rating.component.html', + providers: [RATING_CONTROL_VALUE_ACCESSOR], + changeDetection: ChangeDetectionStrategy.OnPush, + standalone: true, + imports: [NgFor, NgTemplateOutlet] }) export class RatingComponent implements ControlValueAccessor, OnInit { /** number of icons */ diff --git a/src/rating/rating.module.ts b/src/rating/rating.module.ts index eb6df14b6d..2b75fd726d 100644 --- a/src/rating/rating.module.ts +++ b/src/rating/rating.module.ts @@ -1,18 +1,14 @@ -import { CommonModule } from '@angular/common'; -import { NgModule, ModuleWithProviders } from '@angular/core'; +import { NgModule } from '@angular/core'; import { RatingComponent } from './rating.component'; @NgModule({ - imports: [CommonModule], - declarations: [RatingComponent], - exports: [RatingComponent] + imports: [RatingComponent], + exports: [RatingComponent] }) export class RatingModule { - static forRoot(): ModuleWithProviders { - return { - ngModule: RatingModule, - providers: [] - }; + // @deprecated method not required anymore, will be deleted in v19.0.0 + static forRoot() { + return RatingModule; } } diff --git a/src/rating/testing/rating.component.spec.ts b/src/rating/testing/rating.component.spec.ts index b22cedca8d..21cc76245a 100644 --- a/src/rating/testing/rating.component.spec.ts +++ b/src/rating/testing/rating.component.spec.ts @@ -26,7 +26,7 @@ describe('Component: Rating. Init:', () => { beforeEach(() => { TestBed.configureTestingModule({ - declarations: [RatingComponent], + imports: [RatingComponent], providers: [RatingConfig] }); fixture = TestBed.createComponent(RatingComponent); @@ -90,7 +90,7 @@ describe('Component: Rating. Custom template:', () => { fakeAsync(() => { TestBed.configureTestingModule({ declarations: [TestRatingComponent], - imports: [RatingModule.forRoot(), FormsModule] + imports: [RatingModule, FormsModule] }); TestBed.overrideComponent(TestRatingComponent, { set: { template: ` @@ -126,7 +126,7 @@ describe('Component: Rating. Clicks:', () => { fakeAsync(() => { TestBed.configureTestingModule({ declarations: [TestRatingComponent], - imports: [RatingModule.forRoot(), FormsModule] + imports: [RatingModule, FormsModule] }); TestBed.overrideComponent(TestRatingComponent, { set: {template: tpl} diff --git a/src/root/README.md b/src/root/README.md index d3f4aab4e0..9816ae7b90 100644 --- a/src/root/README.md +++ b/src/root/README.md @@ -98,7 +98,7 @@ import { TooltipModule } from 'ngx-bootstrap/tooltip'; @NgModule({ ... - imports: [TooltipModule.forRoot(),...] + imports: [TooltipModule,...] ... }) ``` diff --git a/src/root/package.json b/src/root/package.json index 5e198f62d0..cac63c15f4 100644 --- a/src/root/package.json +++ b/src/root/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap", - "version": "18.0.2", + "version": "18.1.0", "description": "Angular Bootstrap", "author": "Dmitriy Shekhovtsov ", "license": "MIT", diff --git a/src/schematics/package.json b/src/schematics/package.json index 31bad55d78..845a97bd64 100644 --- a/src/schematics/package.json +++ b/src/schematics/package.json @@ -1,6 +1,6 @@ { "name": "schematics", - "version": "18.0.2", + "version": "18.1.0", "schematics": "./collection.json", "author": "Dmitriy Shekhovtsov ", "license": "MIT" diff --git a/src/schematics/src/utils/current_dependency_versions.json b/src/schematics/src/utils/current_dependency_versions.json index 389d54faa6..49465a7534 100644 --- a/src/schematics/src/utils/current_dependency_versions.json +++ b/src/schematics/src/utils/current_dependency_versions.json @@ -1,4 +1,4 @@ { - "NGX_BOOTSTRAP_VERSION": "18.0.2", + "NGX_BOOTSTRAP_VERSION": "18.1.0", "BOOTSTRAP_VERSION": "^5.2.3" } diff --git a/src/sortable/package.json b/src/sortable/package.json index 5b3c90df38..d41793f039 100644 --- a/src/sortable/package.json +++ b/src/sortable/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/sortable", - "version": "18.0.2", + "version": "18.1.0", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/sortable/sortable.component.ts b/src/sortable/sortable.component.ts index 7761bc6394..4440d05c80 100644 --- a/src/sortable/sortable.component.ts +++ b/src/sortable/sortable.component.ts @@ -9,11 +9,12 @@ import { import { NG_VALUE_ACCESSOR, ControlValueAccessor } from '@angular/forms'; import { DraggableItem } from './draggable-item'; import { DraggableItemService } from './draggable-item.service'; +import { NgClass, NgStyle, NgIf, NgFor, NgTemplateOutlet } from '@angular/common'; @Component({ - selector: 'bs-sortable', - exportAs: 'bs-sortable', - template: ` + selector: 'bs-sortable', + exportAs: 'bs-sortable', + template: `
{{item.value}} `, - providers: [ - { - provide: NG_VALUE_ACCESSOR, - useExisting: forwardRef(() => SortableComponent), - multi: true - } - ] + providers: [ + { + provide: NG_VALUE_ACCESSOR, + useExisting: forwardRef(() => SortableComponent), + multi: true + }, + DraggableItemService + ], + standalone: true, + imports: [NgClass, NgStyle, NgIf, NgFor, NgTemplateOutlet] }) export class SortableComponent implements ControlValueAccessor { private static globalZoneIndex = 0; diff --git a/src/sortable/sortable.module.ts b/src/sortable/sortable.module.ts index ab4ef68b4d..1bddcf40cc 100644 --- a/src/sortable/sortable.module.ts +++ b/src/sortable/sortable.module.ts @@ -1,16 +1,14 @@ -import { NgModule, ModuleWithProviders } from '@angular/core'; -import { CommonModule } from '@angular/common'; +import { NgModule } from '@angular/core'; import { SortableComponent } from './sortable.component'; -import { DraggableItemService } from './draggable-item.service'; @NgModule({ - declarations: [SortableComponent], - imports: [CommonModule], - exports: [SortableComponent] + imports: [SortableComponent], + exports: [SortableComponent] }) export class SortableModule { - static forRoot(): ModuleWithProviders { - return { ngModule: SortableModule, providers: [DraggableItemService] }; + // @deprecated method not required anymore, will be deleted in v19.0.0 + static forRoot() { + return SortableModule; } } diff --git a/src/sortable/testing/draggable-item.service.spec.ts b/src/sortable/testing/draggable-item.service.spec.ts index c302addf32..a447be91a4 100644 --- a/src/sortable/testing/draggable-item.service.spec.ts +++ b/src/sortable/testing/draggable-item.service.spec.ts @@ -3,7 +3,8 @@ import { fakeAsync, inject, TestBed } from '@angular/core/testing'; import { DraggableItem, DraggableItemService, SortableItem } from '../index'; @Component({ - template: `

Test

` + template: `

Test

`, + standalone: true }) class TestComponent {} @@ -14,9 +15,9 @@ describe('Service: DraggableItem', () => { beforeEach( fakeAsync(() => { TestBed.configureTestingModule({ - declarations: [TestComponent], - providers: [DraggableItemService] - }).createComponent(TestComponent); + imports: [TestComponent], + providers: [DraggableItemService] +}).createComponent(TestComponent); }) ); diff --git a/src/sortable/testing/sortable.component.spec.ts b/src/sortable/testing/sortable.component.spec.ts index 2647868a0c..d409d1a431 100644 --- a/src/sortable/testing/sortable.component.spec.ts +++ b/src/sortable/testing/sortable.component.spec.ts @@ -14,7 +14,7 @@ const HEROES_OBJ: { id: number; name: string }[] = [ ]; @Component({ - template: ` + template: ` - ` + `, + standalone: true, + imports: [FormsModule] }) class TestSortableComponent { selectedState?: string; @@ -38,10 +40,9 @@ xdescribe('Component: Sortable', () => { beforeEach(() => { fixture = TestBed.configureTestingModule({ - declarations: [TestSortableComponent], - imports: [SortableModule.forRoot(), FormsModule], - providers: [{ provide: ComponentFixtureAutoDetect, useValue: true }] - }).createComponent(TestSortableComponent); + imports: [SortableModule, FormsModule, TestSortableComponent], + providers: [{ provide: ComponentFixtureAutoDetect, useValue: true }] +}).createComponent(TestSortableComponent); fixture.detectChanges(); diff --git a/src/tabs/ng-transclude.directive.ts b/src/tabs/ng-transclude.directive.ts index 833549af16..0c99a46ac9 100644 --- a/src/tabs/ng-transclude.directive.ts +++ b/src/tabs/ng-transclude.directive.ts @@ -1,7 +1,8 @@ import { Directive, Input, TemplateRef, ViewContainerRef } from '@angular/core'; @Directive({ - selector: '[ngTransclude]' + selector: '[ngTransclude]', + standalone: true }) export class NgTranscludeDirective { viewRef: ViewContainerRef; diff --git a/src/tabs/package.json b/src/tabs/package.json index f069af6371..56770abf88 100644 --- a/src/tabs/package.json +++ b/src/tabs/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/tabs", - "version": "18.0.2", + "version": "18.1.0", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/tabs/tab-heading.directive.ts b/src/tabs/tab-heading.directive.ts index 15d811b373..10bc975c2a 100644 --- a/src/tabs/tab-heading.directive.ts +++ b/src/tabs/tab-heading.directive.ts @@ -3,7 +3,10 @@ import { Directive, TemplateRef } from '@angular/core'; import { TabDirective } from './tab.directive'; /** Should be used to mark element as a template for tab heading */ -@Directive({ selector: '[tabHeading]' }) +@Directive({ + selector: '[tabHeading]', + standalone: true +}) export class TabHeadingDirective { // eslint-disable-next-line @typescript-eslint/no-explicit-any templateRef?: TemplateRef; diff --git a/src/tabs/tab.directive.ts b/src/tabs/tab.directive.ts index 20a53500c0..e81950a7e9 100644 --- a/src/tabs/tab.directive.ts +++ b/src/tabs/tab.directive.ts @@ -12,7 +12,10 @@ import { } from '@angular/core'; import { TabsetComponent } from './tabset.component'; -@Directive({ selector: 'tab, [tab]', exportAs: 'tab' }) +@Directive({ + selector: 'tab, [tab]', exportAs: 'tab', + standalone: true +}) export class TabDirective implements OnInit, OnDestroy { /** tab header text */ @Input() heading?: string; diff --git a/src/tabs/tabs.module.ts b/src/tabs/tabs.module.ts index e407d65304..359d111fcc 100644 --- a/src/tabs/tabs.module.ts +++ b/src/tabs/tabs.module.ts @@ -7,25 +7,20 @@ import { TabDirective } from './tab.directive'; import { TabsetComponent } from './tabset.component'; @NgModule({ - imports: [CommonModule], - declarations: [ - NgTranscludeDirective, - TabDirective, - TabsetComponent, - TabHeadingDirective - ], - exports: [ - TabDirective, - TabsetComponent, - TabHeadingDirective, - NgTranscludeDirective - ] + imports: [CommonModule, NgTranscludeDirective, + TabDirective, + TabsetComponent, + TabHeadingDirective], + exports: [ + TabDirective, + TabsetComponent, + TabHeadingDirective, + NgTranscludeDirective + ] }) export class TabsModule { - static forRoot(): ModuleWithProviders { - return { - ngModule: TabsModule, - providers: [] - }; + // @deprecated method not required anymore, will be deleted in v19.0.0 + static forRoot() { + return TabsModule; } } diff --git a/src/tabs/tabset.component.ts b/src/tabs/tabset.component.ts index b7a5880480..50060e0ffb 100644 --- a/src/tabs/tabset.component.ts +++ b/src/tabs/tabset.component.ts @@ -2,12 +2,16 @@ import { Component, HostBinding, Input, OnDestroy, Renderer2, ElementRef } from import { TabDirective } from './tab.directive'; import { TabsetConfig } from './tabset.config'; +import { NgTranscludeDirective } from './ng-transclude.directive'; +import { NgClass, NgFor, NgIf } from '@angular/common'; // todo: add active event to tab // todo: fix? mixing static and dynamic tabs position tabs in order of creation @Component({ - selector: 'tabset', - templateUrl: './tabset.component.html', - styleUrls: ['./tabs.scss'] + selector: 'tabset', + templateUrl: './tabset.component.html', + styleUrls: ['./tabs.scss'], + standalone: true, + imports: [NgClass, NgFor, NgTranscludeDirective, NgIf] }) export class TabsetComponent implements OnDestroy { /** if true tabs will be placed vertically */ diff --git a/src/tabs/testing/tabset.component.spec.ts b/src/tabs/testing/tabset.component.spec.ts index 18ddb84caa..1e6f2afeb3 100644 --- a/src/tabs/testing/tabset.component.spec.ts +++ b/src/tabs/testing/tabset.component.spec.ts @@ -105,7 +105,7 @@ describe('Component: Tabs', () => { beforeEach(() => { TestBed.configureTestingModule({ declarations: [TestTabsetComponent], - imports: [TabsModule.forRoot()] + imports: [TabsModule] }); TestBed.overrideComponent(TestTabsetComponent, { set: { template: html } }); fixture = TestBed.createComponent(TestTabsetComponent); diff --git a/src/timepicker/package.json b/src/timepicker/package.json index b9a371e8f9..c8ead5ed52 100644 --- a/src/timepicker/package.json +++ b/src/timepicker/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/timepicker", - "version": "18.0.2", + "version": "18.1.0", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/timepicker/testing/timepicker.component.spec.ts b/src/timepicker/testing/timepicker.component.spec.ts index e6d8a04cd8..ceeb5a5fe8 100644 --- a/src/timepicker/testing/timepicker.component.spec.ts +++ b/src/timepicker/testing/timepicker.component.spec.ts @@ -50,7 +50,7 @@ describe('Component: TimepickerComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ - imports: [TimepickerModule.forRoot(), FormsModule, ReactiveFormsModule], + imports: [TimepickerModule, FormsModule, ReactiveFormsModule], providers: [TimepickerConfig, TimepickerActions] }); }); diff --git a/src/timepicker/timepicker.component.ts b/src/timepicker/timepicker.component.ts index 9540912f08..5442e2720a 100644 --- a/src/timepicker/timepicker.component.ts +++ b/src/timepicker/timepicker.component.ts @@ -35,6 +35,7 @@ import { padNumber, parseTime } from './timepicker.utils'; +import { NgIf } from '@angular/common'; export const TIMEPICKER_CONTROL_VALUE_ACCESSOR: ControlValueAccessorModel = { provide: NG_VALUE_ACCESSOR, @@ -43,11 +44,11 @@ export const TIMEPICKER_CONTROL_VALUE_ACCESSOR: ControlValueAccessorModel = { }; @Component({ - selector: 'timepicker', - changeDetection: ChangeDetectionStrategy.OnPush, - providers: [TIMEPICKER_CONTROL_VALUE_ACCESSOR, TimepickerStore], - templateUrl: './timepicker.component.html', - styles: [` + selector: 'timepicker', + changeDetection: ChangeDetectionStrategy.OnPush, + providers: [TIMEPICKER_CONTROL_VALUE_ACCESSOR, TimepickerStore, TimepickerActions], + templateUrl: './timepicker.component.html', + styles: [` .bs-chevron { border-style: solid; display: block; @@ -74,7 +75,9 @@ export const TIMEPICKER_CONTROL_VALUE_ACCESSOR: ControlValueAccessorModel = { padding: .375rem .55rem; } `], - encapsulation: ViewEncapsulation.None + encapsulation: ViewEncapsulation.None, + standalone: true, + imports: [NgIf] }) export class TimepickerComponent implements ControlValueAccessor, diff --git a/src/timepicker/timepicker.module.ts b/src/timepicker/timepicker.module.ts index 336bcdf22a..9b10a82df5 100644 --- a/src/timepicker/timepicker.module.ts +++ b/src/timepicker/timepicker.module.ts @@ -1,21 +1,14 @@ -import { ModuleWithProviders, NgModule } from '@angular/core'; -import { CommonModule } from '@angular/common'; +import { NgModule } from '@angular/core'; import { TimepickerComponent } from './timepicker.component'; -import { TimepickerActions } from './reducer/timepicker.actions'; -import { TimepickerStore } from './reducer/timepicker.store'; @NgModule({ - imports: [CommonModule], - declarations: [TimepickerComponent], - exports: [TimepickerComponent], - providers:[TimepickerStore] + imports: [TimepickerComponent], + exports: [TimepickerComponent], }) export class TimepickerModule { - static forRoot(): ModuleWithProviders { - return { - ngModule: TimepickerModule, - providers: [TimepickerActions, TimepickerStore] - }; + // @deprecated method not required anymore, will be deleted in v19.0.0 + static forRoot() { + return TimepickerModule; } } diff --git a/src/tooltip/package.json b/src/tooltip/package.json index f7d6326dad..83552bf072 100644 --- a/src/tooltip/package.json +++ b/src/tooltip/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/tooltip", - "version": "18.0.2", + "version": "18.1.0", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/tooltip/testing/tooltip.directive.spec.ts b/src/tooltip/testing/tooltip.directive.spec.ts index 4465ea6e19..eb9b1c5762 100644 --- a/src/tooltip/testing/tooltip.directive.spec.ts +++ b/src/tooltip/testing/tooltip.directive.spec.ts @@ -41,7 +41,7 @@ describe('Directives: Tooltips', () => { beforeEach(() => { TestBed.configureTestingModule({ declarations: [TestTooltipComponent], - imports: [TooltipModule.forRoot(), FormsModule] + imports: [TooltipModule, FormsModule] }); TestBed.overrideComponent(TestTooltipComponent, { set: {template: overTemplate} diff --git a/src/tooltip/tooltip-container.component.ts b/src/tooltip/tooltip-container.component.ts index 3548287f94..e907f4fd53 100644 --- a/src/tooltip/tooltip-container.component.ts +++ b/src/tooltip/tooltip-container.component.ts @@ -8,17 +8,16 @@ import { getBsVer, IBsVersion } from 'ngx-bootstrap/utils'; import { PlacementForBs5 } from 'ngx-bootstrap/positioning'; @Component({ - selector: 'bs-tooltip-container', - changeDetection: ChangeDetectionStrategy.OnPush, - // eslint-disable-next-line @angular-eslint/no-host-metadata-property - host: { - '[class]': - '"show tooltip in tooltip-" + placement + " " + "bs-tooltip-" + placement + " " + placement + " " + containerClass', - '[attr.id]': 'this.id', - role: 'tooltip' - }, - styles: [ - ` + selector: 'bs-tooltip-container', + changeDetection: ChangeDetectionStrategy.OnPush, + // eslint-disable-next-line @angular-eslint/no-host-metadata-property + host: { + '[class]': '"show tooltip in tooltip-" + placement + " " + "bs-tooltip-" + placement + " " + placement + " " + containerClass', + '[attr.id]': 'this.id', + role: 'tooltip' + }, + styles: [ + ` :host.tooltip { display: block; pointer-events: none; @@ -29,11 +28,12 @@ import { PlacementForBs5 } from 'ngx-bootstrap/positioning'; position: absolute; } ` - ], - template: ` + ], + template: `
- ` + `, + standalone: true }) export class TooltipContainerComponent implements AfterViewInit { classMap?: { [key: string]: boolean }; diff --git a/src/tooltip/tooltip.directive.ts b/src/tooltip/tooltip.directive.ts index 263da9325a..a31141acdc 100644 --- a/src/tooltip/tooltip.directive.ts +++ b/src/tooltip/tooltip.directive.ts @@ -24,8 +24,12 @@ import { AvailableBSPositions } from 'ngx-bootstrap/positioning'; let id = 0; @Directive({ - selector: '[tooltip], [tooltipHtml]', - exportAs: 'bs-tooltip' + selector: '[tooltip], [tooltipHtml]', + exportAs: 'bs-tooltip', + standalone: true, + providers: [ + ComponentLoaderFactory, PositioningService + ] }) export class TooltipDirective implements OnInit, OnDestroy { tooltipId = id++; diff --git a/src/tooltip/tooltip.module.ts b/src/tooltip/tooltip.module.ts index 7fbeef6d2c..928ca7a217 100644 --- a/src/tooltip/tooltip.module.ts +++ b/src/tooltip/tooltip.module.ts @@ -1,20 +1,15 @@ import { CommonModule } from '@angular/common'; -import { NgModule, ModuleWithProviders } from '@angular/core'; +import { NgModule } from '@angular/core'; import { TooltipContainerComponent } from './tooltip-container.component'; import { TooltipDirective } from './tooltip.directive'; -import { ComponentLoaderFactory } from 'ngx-bootstrap/component-loader'; -import { PositioningService } from 'ngx-bootstrap/positioning'; @NgModule({ - imports: [CommonModule], - declarations: [TooltipDirective, TooltipContainerComponent], + imports: [CommonModule, TooltipDirective, TooltipContainerComponent], exports: [TooltipDirective] }) export class TooltipModule { - static forRoot(): ModuleWithProviders { - return { - ngModule: TooltipModule, - providers: [ComponentLoaderFactory, PositioningService] - }; + // @deprecated method not required anymore, will be deleted in v19.0.0 + static forRoot() { + return TooltipModule; } } diff --git a/src/typeahead/package.json b/src/typeahead/package.json index f982c99d2c..86d148ddf8 100644 --- a/src/typeahead/package.json +++ b/src/typeahead/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/typeahead", - "version": "18.0.2", + "version": "18.1.0", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/typeahead/testing/typeahead-container.component.spec.ts b/src/typeahead/testing/typeahead-container.component.spec.ts index 054d89343c..6bc23400da 100644 --- a/src/typeahead/testing/typeahead-container.component.spec.ts +++ b/src/typeahead/testing/typeahead-container.component.spec.ts @@ -34,8 +34,7 @@ describe('Component: TypeaheadContainer', () => { beforeEach(fakeAsync(() => { TestBed.configureTestingModule({ - declarations: [TypeaheadContainerComponent], - imports: [BrowserAnimationsModule], + imports: [BrowserAnimationsModule, TypeaheadContainerComponent], providers: [ { provide: TypeaheadOptions, diff --git a/src/typeahead/testing/typeahead.directive.spec.ts b/src/typeahead/testing/typeahead.directive.spec.ts index c750486577..203265ae0a 100644 --- a/src/typeahead/testing/typeahead.directive.spec.ts +++ b/src/typeahead/testing/typeahead.directive.spec.ts @@ -16,7 +16,7 @@ interface State { } @Component({ - template: ` { beforeEach(waitForAsync(() => TestBed.configureTestingModule({ declarations: [TestTypeaheadComponent], - imports: [TypeaheadModule.forRoot(), BrowserAnimationsModule, FormsModule] - }).compileComponents())); + imports: [TypeaheadModule, BrowserAnimationsModule, FormsModule] + }).compileComponents()) + ); beforeEach(() => { fixture = TestBed.createComponent(TestTypeaheadComponent); diff --git a/src/typeahead/typeahead-container.component.ts b/src/typeahead/typeahead-container.component.ts index 5220e44621..6cc0a6e7c5 100644 --- a/src/typeahead/typeahead-container.component.ts +++ b/src/typeahead/typeahead-container.component.ts @@ -22,23 +22,24 @@ import { TypeaheadMatch } from './typeahead-match.class'; import { TypeaheadDirective } from './typeahead.directive'; import { typeaheadAnimation } from './typeahead-animations'; import { TypeaheadOptionItemContext, TypeaheadOptionListContext, TypeaheadTemplateMethods } from './models'; +import { NgTemplateOutlet, NgFor, NgIf } from '@angular/common'; let nextWindowId = 0; @Component({ - selector: 'typeahead-container', - templateUrl: './typeahead-container.component.html', - // eslint-disable-next-line @angular-eslint/no-host-metadata-property - host: { - class: 'dropdown open bottom dropdown-menu', - '[style.height]': `needScrollbar ? guiHeight: 'auto'`, - '[style.visibility]': `'inherit'`, - '[class.dropup]': 'dropup', - style: 'position: absolute;display: block;', - '[attr.role]': `'listbox'` - }, - styles: [ - ` + selector: 'typeahead-container', + templateUrl: './typeahead-container.component.html', + // eslint-disable-next-line @angular-eslint/no-host-metadata-property + host: { + class: 'dropdown open bottom dropdown-menu', + '[style.height]': `needScrollbar ? guiHeight: 'auto'`, + '[style.visibility]': `'inherit'`, + '[class.dropup]': 'dropup', + style: 'position: absolute;display: block;', + '[attr.role]': `'listbox'` + }, + styles: [ + ` :host.dropdown { z-index: 1000; } @@ -48,8 +49,11 @@ let nextWindowId = 0; height: 100px; } ` - ], - animations: [typeaheadAnimation] + ], + animations: [typeaheadAnimation], + standalone: true, + imports: [NgTemplateOutlet, NgFor, NgIf], + providers: [PositioningService] }) export class TypeaheadContainerComponent implements OnDestroy { diff --git a/src/typeahead/typeahead.directive.ts b/src/typeahead/typeahead.directive.ts index 1722256f12..2296e55ce6 100644 --- a/src/typeahead/typeahead.directive.ts +++ b/src/typeahead/typeahead.directive.ts @@ -24,21 +24,24 @@ import { TypeaheadMatch } from './typeahead-match.class'; import { TypeaheadOrder } from './typeahead-order.class'; import { getValueFromObject, latinize, tokenize } from './typeahead-utils'; import { TypeaheadConfig } from './typeahead.config'; +import { PositioningService } from 'ngx-bootstrap/positioning'; // eslint-disable-next-line type TypeaheadOption = string | Record; type TypeaheadOptionArr = TypeaheadOption[] | Observable; @Directive({ - selector: '[typeahead]', - exportAs: 'bs-typeahead', - // eslint-disable-next-line @angular-eslint/no-host-metadata-property - host: { - '[attr.aria-activedescendant]': 'activeDescendant', - '[attr.aria-owns]': 'isOpen ? this._container.popupId : null', - '[attr.aria-expanded]': 'isOpen', - '[attr.aria-autocomplete]': 'list' - } + selector: '[typeahead]', + exportAs: 'bs-typeahead', + // eslint-disable-next-line @angular-eslint/no-host-metadata-property + host: { + '[attr.aria-activedescendant]': 'activeDescendant', + '[attr.aria-owns]': 'isOpen ? this._container.popupId : null', + '[attr.aria-expanded]': 'isOpen', + '[attr.aria-autocomplete]': 'list' + }, + standalone: true, + providers: [ComponentLoaderFactory, PositioningService] }) export class TypeaheadDirective implements OnInit, OnDestroy { /** options source, can be Array of strings, objects or diff --git a/src/typeahead/typeahead.module.ts b/src/typeahead/typeahead.module.ts index f5729decee..ccdd9d35dd 100644 --- a/src/typeahead/typeahead.module.ts +++ b/src/typeahead/typeahead.module.ts @@ -1,21 +1,16 @@ import { CommonModule } from '@angular/common'; -import { NgModule, ModuleWithProviders } from '@angular/core'; +import { NgModule } from '@angular/core'; import { TypeaheadContainerComponent } from './typeahead-container.component'; import { TypeaheadDirective } from './typeahead.directive'; -import { ComponentLoaderFactory } from 'ngx-bootstrap/component-loader'; -import { PositioningService } from 'ngx-bootstrap/positioning'; @NgModule({ - imports: [CommonModule], - declarations: [TypeaheadContainerComponent, TypeaheadDirective], + imports: [CommonModule, TypeaheadContainerComponent, TypeaheadDirective], exports: [TypeaheadContainerComponent, TypeaheadDirective] }) export class TypeaheadModule { - static forRoot(): ModuleWithProviders { - return { - ngModule: TypeaheadModule, - providers: [ComponentLoaderFactory, PositioningService] - }; + // @deprecated method not required anymore, will be deleted in v19.0.0 + static forRoot() { + return TypeaheadModule; } } diff --git a/src/utils/package.json b/src/utils/package.json index 799da4bf79..52ada5e345 100644 --- a/src/utils/package.json +++ b/src/utils/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/utils", - "version": "18.0.2", + "version": "18.1.0", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } From b15cea22ac53948c0eb6ffe9f0fa35c389d259ee Mon Sep 17 00:00:00 2001 From: Alexey Umanskiy Date: Thu, 17 Oct 2024 15:07:15 +0300 Subject: [PATCH 09/14] =?UTF-8?q?hotfix(typescript):=20some=20angular=20se?= =?UTF-8?q?tups=20can't=20handle=20.forRoot()=20retur=E2=80=A6=20(#6689)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * hotfix(typescript): some angular setups can't handle .forRoot() returning just module * 18.1.1 * chore(version): version bumped --- apps/ngx-bootstrap-docs/src/assets/css/style.scss | 4 +++- .../src/assets/json/current-version.json | 2 +- package-lock.json | 4 ++-- package.json | 2 +- src/accordion/accordion.module.ts | 9 ++++++--- src/accordion/package.json | 2 +- src/alert/alert.module.ts | 9 ++++++--- src/alert/package.json | 2 +- src/buttons/buttons.module.ts | 9 ++++++--- src/buttons/package.json | 2 +- src/carousel/carousel.module.ts | 9 ++++++--- src/carousel/package.json | 2 +- src/chronos/package.json | 2 +- src/collapse/collapse.module.ts | 9 ++++++--- src/collapse/package.json | 2 +- src/component-loader/package.json | 2 +- src/datepicker/bs-datepicker.module.ts | 9 ++++++--- src/datepicker/package.json | 2 +- src/dropdown/bs-dropdown.module.ts | 9 ++++++--- src/dropdown/package.json | 2 +- src/focus-trap/focus-trap.module.ts | 9 ++++++--- src/focus-trap/package.json | 2 +- src/locale/package.json | 2 +- src/mini-ngrx/package.json | 2 +- src/modal/package.json | 2 +- src/pagination/package.json | 2 +- src/pagination/pagination.module.ts | 9 ++++++--- src/popover/package.json | 2 +- src/popover/popover.module.ts | 9 ++++++--- src/positioning/package.json | 2 +- src/progressbar/package.json | 2 +- src/progressbar/progressbar.module.ts | 9 ++++++--- src/rating/package.json | 2 +- src/rating/rating.module.ts | 9 ++++++--- src/root/package.json | 2 +- src/schematics/package.json | 2 +- .../src/utils/current_dependency_versions.json | 2 +- src/sortable/package.json | 2 +- src/sortable/sortable.module.ts | 9 ++++++--- src/tabs/package.json | 2 +- src/tabs/tabs.module.ts | 7 +++++-- src/timepicker/package.json | 2 +- src/timepicker/timepicker.module.ts | 9 ++++++--- src/tooltip/package.json | 2 +- src/tooltip/tooltip.module.ts | 9 ++++++--- src/typeahead/package.json | 2 +- src/typeahead/typeahead.module.ts | 9 ++++++--- src/utils/package.json | 2 +- 48 files changed, 135 insertions(+), 82 deletions(-) diff --git a/apps/ngx-bootstrap-docs/src/assets/css/style.scss b/apps/ngx-bootstrap-docs/src/assets/css/style.scss index 8020c1da36..3db1f2272a 100644 --- a/apps/ngx-bootstrap-docs/src/assets/css/style.scss +++ b/apps/ngx-bootstrap-docs/src/assets/css/style.scss @@ -2,7 +2,9 @@ @import "bs-datepicker"; /* HEADER */ - +.bs-datepicker-head { + width: 150px; +} header { padding: 10px 50px 10px 30px; height: $header-height; diff --git a/apps/ngx-bootstrap-docs/src/assets/json/current-version.json b/apps/ngx-bootstrap-docs/src/assets/json/current-version.json index 468bce7d10..068131925c 100644 --- a/apps/ngx-bootstrap-docs/src/assets/json/current-version.json +++ b/apps/ngx-bootstrap-docs/src/assets/json/current-version.json @@ -1,3 +1,3 @@ { - "version": "18.1.0" + "version": "18.1.1" } diff --git a/package-lock.json b/package-lock.json index d64369dc7a..ed712ed5d5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "ngx-bootstrap-base", - "version": "18.1.0", + "version": "18.1.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "ngx-bootstrap-base", - "version": "18.1.0", + "version": "18.1.1", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index 65ed365e53..c1c0252f27 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap-base", - "version": "18.1.0", + "version": "18.1.1", "license": "MIT", "author": "Dmitriy Shekhovtsov ", "schematics": "./schematics/src/collection.json", diff --git a/src/accordion/accordion.module.ts b/src/accordion/accordion.module.ts index 60a8a70db1..23541e2d23 100644 --- a/src/accordion/accordion.module.ts +++ b/src/accordion/accordion.module.ts @@ -1,4 +1,4 @@ -import { NgModule } from '@angular/core'; +import { ModuleWithProviders, NgModule } from '@angular/core'; import { AccordionComponent } from './accordion.component'; import { AccordionPanelComponent } from './accordion-group.component'; @@ -9,7 +9,10 @@ import { AccordionPanelComponent } from './accordion-group.component'; }) export class AccordionModule { // @deprecated method not required anymore, will be deleted in v19.0.0 - static forRoot() { - return AccordionModule; + static forRoot(): ModuleWithProviders { + return { + ngModule: AccordionModule, + providers: [] + }; } } diff --git a/src/accordion/package.json b/src/accordion/package.json index 1f30f5dc8b..0dd7738830 100644 --- a/src/accordion/package.json +++ b/src/accordion/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/accordion", - "version": "18.1.0", + "version": "18.1.1", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/alert/alert.module.ts b/src/alert/alert.module.ts index d682d7cbce..2cfca0257a 100644 --- a/src/alert/alert.module.ts +++ b/src/alert/alert.module.ts @@ -1,4 +1,4 @@ -import { NgModule } from '@angular/core'; +import { ModuleWithProviders, NgModule } from '@angular/core'; import { AlertComponent } from './alert.component'; @NgModule({ @@ -7,7 +7,10 @@ import { AlertComponent } from './alert.component'; }) export class AlertModule { // @deprecated method not required anymore, will be deleted in v19.0.0 - static forRoot() { - return AlertModule; + static forRoot(): ModuleWithProviders { + return { + ngModule: AlertModule, + providers: [] + }; } } diff --git a/src/alert/package.json b/src/alert/package.json index a1b343725d..6a35a023b9 100644 --- a/src/alert/package.json +++ b/src/alert/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/alert", - "version": "18.1.0", + "version": "18.1.1", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/buttons/buttons.module.ts b/src/buttons/buttons.module.ts index dd6ad1d660..f2a4854d52 100644 --- a/src/buttons/buttons.module.ts +++ b/src/buttons/buttons.module.ts @@ -1,4 +1,4 @@ -import { NgModule } from '@angular/core'; +import { ModuleWithProviders, NgModule } from '@angular/core'; import { ButtonCheckboxDirective } from './button-checkbox.directive'; import { ButtonRadioDirective } from './button-radio.directive'; @@ -10,7 +10,10 @@ import { ButtonRadioGroupDirective } from './button-radio-group.directive'; }) export class ButtonsModule { // @deprecated method not required anymore, will be deleted in v19.0.0 - static forRoot() { - return ButtonsModule; + static forRoot(): ModuleWithProviders { + return { + ngModule: ButtonsModule, + providers: [] + }; } } diff --git a/src/buttons/package.json b/src/buttons/package.json index d37d360daa..c7d4807fc7 100644 --- a/src/buttons/package.json +++ b/src/buttons/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/buttons", - "version": "18.1.0", + "version": "18.1.1", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/carousel/carousel.module.ts b/src/carousel/carousel.module.ts index 177452e83c..4bf02720f8 100644 --- a/src/carousel/carousel.module.ts +++ b/src/carousel/carousel.module.ts @@ -1,4 +1,4 @@ -import { NgModule } from '@angular/core'; +import { ModuleWithProviders, NgModule } from '@angular/core'; import { CarouselComponent } from './carousel.component'; import { SlideComponent } from './slide.component'; @@ -9,7 +9,10 @@ import { SlideComponent } from './slide.component'; }) export class CarouselModule { // @deprecated method not required anymore, will be deleted in v19.0.0 - static forRoot() { - return CarouselModule; + static forRoot(): ModuleWithProviders { + return { + ngModule: CarouselModule, + providers: [] + }; } } diff --git a/src/carousel/package.json b/src/carousel/package.json index e1f4da7134..0cd2f05f2d 100644 --- a/src/carousel/package.json +++ b/src/carousel/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/carousel", - "version": "18.1.0", + "version": "18.1.1", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/chronos/package.json b/src/chronos/package.json index d6be16bbc2..cdf2cf8eca 100644 --- a/src/chronos/package.json +++ b/src/chronos/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/chronos", - "version": "18.1.0", + "version": "18.1.1", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/collapse/collapse.module.ts b/src/collapse/collapse.module.ts index 769cddbde2..611d9f5aa6 100644 --- a/src/collapse/collapse.module.ts +++ b/src/collapse/collapse.module.ts @@ -1,4 +1,4 @@ -import { NgModule } from '@angular/core'; +import { ModuleWithProviders, NgModule } from '@angular/core'; import { CollapseDirective } from './collapse.directive'; @@ -8,7 +8,10 @@ import { CollapseDirective } from './collapse.directive'; }) export class CollapseModule { // @deprecated method not required anymore, will be deleted in v19.0.0 - static forRoot() { - return CollapseModule; + static forRoot(): ModuleWithProviders { + return { + ngModule: CollapseModule, + providers: [] + }; } } diff --git a/src/collapse/package.json b/src/collapse/package.json index 994c31561c..6bb0c979f9 100644 --- a/src/collapse/package.json +++ b/src/collapse/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/collapse", - "version": "18.1.0", + "version": "18.1.1", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/component-loader/package.json b/src/component-loader/package.json index d0f479a3e9..5024032b46 100644 --- a/src/component-loader/package.json +++ b/src/component-loader/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/component-loader", - "version": "18.1.0", + "version": "18.1.1", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/datepicker/bs-datepicker.module.ts b/src/datepicker/bs-datepicker.module.ts index 88abae332f..5677ba96cd 100644 --- a/src/datepicker/bs-datepicker.module.ts +++ b/src/datepicker/bs-datepicker.module.ts @@ -1,5 +1,5 @@ import { CommonModule } from '@angular/common'; -import { NgModule } from '@angular/core'; +import { ModuleWithProviders, NgModule } from '@angular/core'; import { TooltipModule } from 'ngx-bootstrap/tooltip'; import { TimepickerModule } from 'ngx-bootstrap/timepicker'; @@ -64,7 +64,10 @@ import { BsYearsCalendarViewComponent } from './themes/bs/bs-years-calendar-view }) export class BsDatepickerModule { // @deprecated method not required anymore, will be deleted in v19.0.0 - static forRoot() { - return BsDatepickerModule; + static forRoot(): ModuleWithProviders { + return { + ngModule: BsDatepickerModule, + providers: [] + }; } } diff --git a/src/datepicker/package.json b/src/datepicker/package.json index 13b0b449e2..f50a853cd6 100644 --- a/src/datepicker/package.json +++ b/src/datepicker/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/datepicker", - "version": "18.1.0", + "version": "18.1.1", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/dropdown/bs-dropdown.module.ts b/src/dropdown/bs-dropdown.module.ts index 5ab54af6fd..7f7624ea4c 100644 --- a/src/dropdown/bs-dropdown.module.ts +++ b/src/dropdown/bs-dropdown.module.ts @@ -1,4 +1,4 @@ -import { NgModule } from '@angular/core'; +import { ModuleWithProviders, NgModule } from '@angular/core'; import { BsDropdownContainerComponent } from './bs-dropdown-container.component'; import { BsDropdownMenuDirective } from './bs-dropdown-menu.directive'; @@ -21,7 +21,10 @@ import { BsDropdownDirective } from './bs-dropdown.directive'; }) export class BsDropdownModule { // @deprecated method not required anymore, will be deleted in v19.0.0 - static forRoot() { - return BsDropdownModule; + static forRoot(): ModuleWithProviders { + return { + ngModule: BsDropdownModule, + providers: [] + }; } } diff --git a/src/dropdown/package.json b/src/dropdown/package.json index 1c22dd6f4b..08048953bf 100644 --- a/src/dropdown/package.json +++ b/src/dropdown/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/dropdown", - "version": "18.1.0", + "version": "18.1.1", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/focus-trap/focus-trap.module.ts b/src/focus-trap/focus-trap.module.ts index 60ecd48574..509b87439b 100644 --- a/src/focus-trap/focus-trap.module.ts +++ b/src/focus-trap/focus-trap.module.ts @@ -1,4 +1,4 @@ -import { NgModule } from '@angular/core'; +import { ModuleWithProviders, NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { FocusTrapDirective } from './focus-trap'; @@ -9,7 +9,10 @@ import { FocusTrapDirective } from './focus-trap'; }) export class FocusTrapModule { // @deprecated method not required anymore, will be deleted in v19.0.0 - static forRoot() { - return FocusTrapModule; + static forRoot(): ModuleWithProviders { + return { + ngModule: FocusTrapModule, + providers: [] + }; } } diff --git a/src/focus-trap/package.json b/src/focus-trap/package.json index a68da03899..82b05ef148 100644 --- a/src/focus-trap/package.json +++ b/src/focus-trap/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/focus-trap", - "version": "18.1.0", + "version": "18.1.1", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/locale/package.json b/src/locale/package.json index fbe62dc60b..5eb51ee06d 100644 --- a/src/locale/package.json +++ b/src/locale/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/locale", - "version": "18.1.0", + "version": "18.1.1", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/mini-ngrx/package.json b/src/mini-ngrx/package.json index fb562980c5..9112c1fe30 100644 --- a/src/mini-ngrx/package.json +++ b/src/mini-ngrx/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/mini-ngrx", - "version": "18.1.0", + "version": "18.1.1", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/modal/package.json b/src/modal/package.json index 26ad72a93b..0a303c5f24 100644 --- a/src/modal/package.json +++ b/src/modal/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/modal", - "version": "18.1.0", + "version": "18.1.1", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/pagination/package.json b/src/pagination/package.json index 91a730bb89..df20f24377 100644 --- a/src/pagination/package.json +++ b/src/pagination/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/pagination", - "version": "18.1.0", + "version": "18.1.1", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/pagination/pagination.module.ts b/src/pagination/pagination.module.ts index 0dc6fd8334..a7c377f4af 100644 --- a/src/pagination/pagination.module.ts +++ b/src/pagination/pagination.module.ts @@ -1,5 +1,5 @@ import { CommonModule } from '@angular/common'; -import { NgModule } from '@angular/core'; +import { ModuleWithProviders, NgModule } from '@angular/core'; import { PagerComponent } from './pager.component'; import { PaginationComponent } from './pagination.component'; @@ -10,7 +10,10 @@ import { PaginationComponent } from './pagination.component'; }) export class PaginationModule { // @deprecated method not required anymore, will be deleted in v19.0.0 - static forRoot() { - return PaginationModule; + static forRoot(): ModuleWithProviders { + return { + ngModule: PaginationModule, + providers: [] + }; } } diff --git a/src/popover/package.json b/src/popover/package.json index 7f533c3196..462b00b143 100644 --- a/src/popover/package.json +++ b/src/popover/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/popover", - "version": "18.1.0", + "version": "18.1.1", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/popover/popover.module.ts b/src/popover/popover.module.ts index d992626951..d69a1f8864 100644 --- a/src/popover/popover.module.ts +++ b/src/popover/popover.module.ts @@ -1,4 +1,4 @@ -import { NgModule } from '@angular/core'; +import { ModuleWithProviders, NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { PopoverDirective } from './popover.directive'; @@ -10,7 +10,10 @@ import { PopoverContainerComponent } from './popover-container.component'; }) export class PopoverModule { // @deprecated method not required anymore, will be deleted in v19.0.0 - static forRoot() { - return PopoverModule; + static forRoot(): ModuleWithProviders { + return { + ngModule: PopoverModule, + providers: [] + }; } } diff --git a/src/positioning/package.json b/src/positioning/package.json index 6043faf3a7..17d421294f 100644 --- a/src/positioning/package.json +++ b/src/positioning/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/positioning", - "version": "18.1.0", + "version": "18.1.1", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/progressbar/package.json b/src/progressbar/package.json index 2339be3541..c3c9f44ae8 100644 --- a/src/progressbar/package.json +++ b/src/progressbar/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/progressbar", - "version": "18.1.0", + "version": "18.1.1", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/progressbar/progressbar.module.ts b/src/progressbar/progressbar.module.ts index feb7ac4f90..27385314b9 100644 --- a/src/progressbar/progressbar.module.ts +++ b/src/progressbar/progressbar.module.ts @@ -1,4 +1,4 @@ -import { NgModule } from '@angular/core'; +import { ModuleWithProviders, NgModule } from '@angular/core'; import { BarComponent } from './bar.component'; import { ProgressbarComponent } from './progressbar.component'; @@ -9,7 +9,10 @@ import { ProgressbarComponent } from './progressbar.component'; }) export class ProgressbarModule { // @deprecated method not required anymore, will be deleted in v19.0.0 - static forRoot() { - return ProgressbarModule; + static forRoot(): ModuleWithProviders { + return { + ngModule: ProgressbarModule, + providers: [] + }; } } diff --git a/src/rating/package.json b/src/rating/package.json index ee9399e5ab..7680095734 100644 --- a/src/rating/package.json +++ b/src/rating/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/rating", - "version": "18.1.0", + "version": "18.1.1", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/rating/rating.module.ts b/src/rating/rating.module.ts index 2b75fd726d..0c85ba15c6 100644 --- a/src/rating/rating.module.ts +++ b/src/rating/rating.module.ts @@ -1,4 +1,4 @@ -import { NgModule } from '@angular/core'; +import { ModuleWithProviders, NgModule } from '@angular/core'; import { RatingComponent } from './rating.component'; @@ -8,7 +8,10 @@ import { RatingComponent } from './rating.component'; }) export class RatingModule { // @deprecated method not required anymore, will be deleted in v19.0.0 - static forRoot() { - return RatingModule; + static forRoot(): ModuleWithProviders { + return { + ngModule: RatingModule, + providers: [] + }; } } diff --git a/src/root/package.json b/src/root/package.json index cac63c15f4..7b6f69ccdf 100644 --- a/src/root/package.json +++ b/src/root/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap", - "version": "18.1.0", + "version": "18.1.1", "description": "Angular Bootstrap", "author": "Dmitriy Shekhovtsov ", "license": "MIT", diff --git a/src/schematics/package.json b/src/schematics/package.json index 845a97bd64..1bcc1fdd4a 100644 --- a/src/schematics/package.json +++ b/src/schematics/package.json @@ -1,6 +1,6 @@ { "name": "schematics", - "version": "18.1.0", + "version": "18.1.1", "schematics": "./collection.json", "author": "Dmitriy Shekhovtsov ", "license": "MIT" diff --git a/src/schematics/src/utils/current_dependency_versions.json b/src/schematics/src/utils/current_dependency_versions.json index 49465a7534..092ceceb24 100644 --- a/src/schematics/src/utils/current_dependency_versions.json +++ b/src/schematics/src/utils/current_dependency_versions.json @@ -1,4 +1,4 @@ { - "NGX_BOOTSTRAP_VERSION": "18.1.0", + "NGX_BOOTSTRAP_VERSION": "18.1.1", "BOOTSTRAP_VERSION": "^5.2.3" } diff --git a/src/sortable/package.json b/src/sortable/package.json index d41793f039..7595c8a7cd 100644 --- a/src/sortable/package.json +++ b/src/sortable/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/sortable", - "version": "18.1.0", + "version": "18.1.1", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/sortable/sortable.module.ts b/src/sortable/sortable.module.ts index 1bddcf40cc..29cda7c63c 100644 --- a/src/sortable/sortable.module.ts +++ b/src/sortable/sortable.module.ts @@ -1,4 +1,4 @@ -import { NgModule } from '@angular/core'; +import { ModuleWithProviders, NgModule } from '@angular/core'; import { SortableComponent } from './sortable.component'; @@ -8,7 +8,10 @@ import { SortableComponent } from './sortable.component'; }) export class SortableModule { // @deprecated method not required anymore, will be deleted in v19.0.0 - static forRoot() { - return SortableModule; + static forRoot(): ModuleWithProviders { + return { + ngModule: SortableModule, + providers: [] + }; } } diff --git a/src/tabs/package.json b/src/tabs/package.json index 56770abf88..c15d73143f 100644 --- a/src/tabs/package.json +++ b/src/tabs/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/tabs", - "version": "18.1.0", + "version": "18.1.1", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/tabs/tabs.module.ts b/src/tabs/tabs.module.ts index 359d111fcc..ce779c96e1 100644 --- a/src/tabs/tabs.module.ts +++ b/src/tabs/tabs.module.ts @@ -20,7 +20,10 @@ import { TabsetComponent } from './tabset.component'; }) export class TabsModule { // @deprecated method not required anymore, will be deleted in v19.0.0 - static forRoot() { - return TabsModule; + static forRoot(): ModuleWithProviders { + return { + ngModule: TabsModule, + providers: [] + }; } } diff --git a/src/timepicker/package.json b/src/timepicker/package.json index c8ead5ed52..cc2c357e5c 100644 --- a/src/timepicker/package.json +++ b/src/timepicker/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/timepicker", - "version": "18.1.0", + "version": "18.1.1", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/timepicker/timepicker.module.ts b/src/timepicker/timepicker.module.ts index 9b10a82df5..bdb8678a4a 100644 --- a/src/timepicker/timepicker.module.ts +++ b/src/timepicker/timepicker.module.ts @@ -1,4 +1,4 @@ -import { NgModule } from '@angular/core'; +import { ModuleWithProviders, NgModule } from '@angular/core'; import { TimepickerComponent } from './timepicker.component'; @@ -8,7 +8,10 @@ import { TimepickerComponent } from './timepicker.component'; }) export class TimepickerModule { // @deprecated method not required anymore, will be deleted in v19.0.0 - static forRoot() { - return TimepickerModule; + static forRoot(): ModuleWithProviders { + return { + ngModule: TimepickerModule, + providers: [] + }; } } diff --git a/src/tooltip/package.json b/src/tooltip/package.json index 83552bf072..cfec702241 100644 --- a/src/tooltip/package.json +++ b/src/tooltip/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/tooltip", - "version": "18.1.0", + "version": "18.1.1", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/tooltip/tooltip.module.ts b/src/tooltip/tooltip.module.ts index 928ca7a217..6a390afbd8 100644 --- a/src/tooltip/tooltip.module.ts +++ b/src/tooltip/tooltip.module.ts @@ -1,5 +1,5 @@ import { CommonModule } from '@angular/common'; -import { NgModule } from '@angular/core'; +import { ModuleWithProviders, NgModule } from '@angular/core'; import { TooltipContainerComponent } from './tooltip-container.component'; import { TooltipDirective } from './tooltip.directive'; @@ -9,7 +9,10 @@ import { TooltipDirective } from './tooltip.directive'; }) export class TooltipModule { // @deprecated method not required anymore, will be deleted in v19.0.0 - static forRoot() { - return TooltipModule; + static forRoot(): ModuleWithProviders { + return { + ngModule: TooltipModule, + providers: [] + }; } } diff --git a/src/typeahead/package.json b/src/typeahead/package.json index 86d148ddf8..deb804e7fb 100644 --- a/src/typeahead/package.json +++ b/src/typeahead/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/typeahead", - "version": "18.1.0", + "version": "18.1.1", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/typeahead/typeahead.module.ts b/src/typeahead/typeahead.module.ts index ccdd9d35dd..334b3df41c 100644 --- a/src/typeahead/typeahead.module.ts +++ b/src/typeahead/typeahead.module.ts @@ -1,5 +1,5 @@ import { CommonModule } from '@angular/common'; -import { NgModule } from '@angular/core'; +import { ModuleWithProviders, NgModule } from '@angular/core'; import { TypeaheadContainerComponent } from './typeahead-container.component'; import { TypeaheadDirective } from './typeahead.directive'; @@ -10,7 +10,10 @@ import { TypeaheadDirective } from './typeahead.directive'; }) export class TypeaheadModule { // @deprecated method not required anymore, will be deleted in v19.0.0 - static forRoot() { - return TypeaheadModule; + static forRoot(): ModuleWithProviders { + return { + ngModule: TypeaheadModule, + providers: [] + }; } } diff --git a/src/utils/package.json b/src/utils/package.json index 52ada5e345..442f87287b 100644 --- a/src/utils/package.json +++ b/src/utils/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/utils", - "version": "18.1.0", + "version": "18.1.1", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } From 9968df424425e1fb61c9aa7e027ee4557e97da22 Mon Sep 17 00:00:00 2001 From: Meysam Bahadori Date: Thu, 17 Oct 2024 15:47:52 +0330 Subject: [PATCH 10/14] Add persian locale (#6560) Co-authored-by: Alexey Umanskiy --- src/chronos/i18n/fa.ts | 138 +++++++++++++ src/chronos/public_api.ts | 1 + src/chronos/testing/locale/fa.Spec.ts | 269 ++++++++++++++++++++++++++ 3 files changed, 408 insertions(+) create mode 100644 src/chronos/i18n/fa.ts create mode 100644 src/chronos/testing/locale/fa.Spec.ts diff --git a/src/chronos/i18n/fa.ts b/src/chronos/i18n/fa.ts new file mode 100644 index 0000000000..d2a31df237 --- /dev/null +++ b/src/chronos/i18n/fa.ts @@ -0,0 +1,138 @@ +//! moment.js locale configuration +//! locale : Persian [fa] +//! author : Meysam Bahadori: https://github.com/MeysamBahadori + +import { LocaleData } from '../locale/locale.class'; + +const symbolMap: {[key: string]: string} = { + 1: '١', + 2: '٢', + 3: '٣', + 4: '٤', + 5: '٥', + 6: '٦', + 7: '٧', + 8: '٨', + 9: '٩', + 0: '٠' + }; + +const numberMap: {[key: string]: string} = { + '١': '1', + '٢': '2', + '٣': '3', + '٤': '4', + '٥': '5', + '٦': '6', + '٧': '7', + '٨': '8', + '٩': '9', + '٠': '0' +}; + +const pluralForm = function (num: number): number { + return num === 0 ? 0 : num === 1 ? 1 : num === 2 ? 2 : num % 100 >= 3 && num % 100 <= 10 ? 3 : num % 100 >= 11 ? 4 : 5; + }; + +var plurals : {[key: string]: [string, string, [string, string], string, string, string]} = { + s: ['کمتر از یک ثانیه', 'یک ثانیه', ['دو ثانیه', 'دو ثانیه'], '%d ثانیه', '%d ثانیه', '%d ثانیه'], + m: ['کمتر از یک دقیقه', 'یک دقیقه', ['دو دقیقه', 'دو دقیقه'], '%d دقیقه', '%d دقیقه', '%d دقیقه'], + h: ['کمتر از یک ساعت', 'یک ساعت', ['دو ساعت', 'دو ساعت'], '%d ساعت', '%d ساعت', '%d ساعت'], + d: ['کمتر از یک روز', 'یک روز', ['دو روز', 'دو روز'], '%d روز', '%d روز', '%d روز'], + M: ['کمتر از یک ماه', 'یک ماه', ['دو ماه', 'دو ماه'], '%d ماه', '%d ماه', '%d ماه'], + y: ['کمتر از یک سال', 'یک سال', ['دو سال', 'دو سال'], '%d سال', '%d سال', '%d سال'] +}; + +const pluralize = function (u: string) { + return function (num: number, withoutSuffix: boolean): string { + const f = pluralForm(num); + let str = plurals[u][pluralForm(num)]; + if (f === 2) { + str = str[withoutSuffix ? 0 : 1]; + } + + return (str as string).replace(/%d/i, num.toString()); + }; + }; + + const months: string[] = [ + 'ژانویه', + 'فوریه', + 'مارس', + 'آوریل', + 'می', + 'ژوئن', + 'جولای', + 'آگوست', + 'سپتامبر', + 'اکتبر', + 'نوامبر', + 'دسامبر' +]; + +export const faLocale: LocaleData = { + abbr: 'fa', + months: months, + monthsShort: months, + weekdays: 'یکشنبه_دوشنبه_سه شنبه_چهارشنبه_پنج شنبه_جمعه_شنبه'.split('_'), + weekdaysShort: 'یکشنبه_دو‌شنبه_سه‌شنبه_چهار‌شنبه_پنج‌شنبه_جمعه_شنبه'.split('_'), + weekdaysMin: 'ی_د_س_چ_پ_ج_ش'.split('_'), + weekdaysParseExact: true, + longDateFormat: { + LT: 'HH:mm', + LTS: 'HH:mm:ss', + L: 'D/\u200FM/\u200FYYYY', + LL: 'D MMMM YYYY', + LLL: 'D MMMM YYYY HH:mm', + LLLL: 'dddd D MMMM YYYY HH:mm' + }, + meridiemParse: /ص|م/, + isPM(input) { + return 'م' === input; + }, + meridiem(hour, minute, isLower) { + if (hour < 12) { + return 'ص'; + } else { + return 'م'; + } + }, + calendar: { + sameDay: '[امروز در ساعت] LT', + nextDay: '[فردا در ساعت] LT', + nextWeek: 'dddd [در ساعت] LT', + lastDay: '[دیروز در ساعت] LT', + lastWeek: 'dddd [در ساعت] LT', + sameElse: 'L' + }, + relativeTime: { + future: 'بعد %s', + past: 'پیش %s', + s: pluralize('s'), + ss: pluralize('s'), + m: pluralize('m'), + mm: pluralize('m'), + h: pluralize('h'), + hh: pluralize('h'), + d: pluralize('d'), + dd: pluralize('d'), + M: pluralize('M'), + MM: pluralize('M'), + y: pluralize('y'), + yy: pluralize('y') + }, + preparse(str: string): string { + return str.replace(/[١٢٣٤٥٦٧٨٩٠]/g, function (match) { + return numberMap[match]; + }).replace(/،/g, ','); + }, + postformat(str: string) { + return str.replace(/\d/g, function (match) { + return symbolMap[match]; + }).replace(/,/g, '،'); + }, + week: { + dow: 6, // Saturday is the first day of the week. + doy: 80 // The week that contains March 21th is the first week of the year. + } +}; diff --git a/src/chronos/public_api.ts b/src/chronos/public_api.ts index 24c705c558..d5f67b54a7 100644 --- a/src/chronos/public_api.ts +++ b/src/chronos/public_api.ts @@ -80,3 +80,4 @@ export { trLocale } from './i18n/tr'; export { ukLocale } from './i18n/uk'; export { viLocale } from './i18n/vi'; export { zhCnLocale } from './i18n/zh-cn'; +export { faLocale } from './i18n/fa'; \ No newline at end of file diff --git a/src/chronos/testing/locale/fa.Spec.ts b/src/chronos/testing/locale/fa.Spec.ts new file mode 100644 index 0000000000..e0d4924448 --- /dev/null +++ b/src/chronos/testing/locale/fa.Spec.ts @@ -0,0 +1,269 @@ +// tslint:disable:max-line-length max-file-line-count prefer-const forin prefer-template one-variable-per-declaration newline-before-return +// tslint:disable:binary-expression-operand-order comment-format one-line no-var-keyword object-literal-shorthand +// tslint:disable:variable-name no-shadowed-variable + +import { assertEq, assertDeepEq } from '../test-helpers'; +import { moment } from '../chain'; +import { faLocale } from '../../i18n/fa'; + +// localeModule('fa'); + +var months = [ + 'ژانویه', + 'فوریه', + 'مارس', + 'آوریل', + 'می', + 'ژوئن', + 'جولای', + 'آگوست', + 'سپتامبر', + 'اکتبر', + 'نوامبر', + 'دسامبر' +]; +describe('locale: fa', () => { + beforeAll(() => { + moment.locale('fa', faLocale); + }); + + afterAll(() => { + moment.locale('en'); + }); + + it('parse', function () { + var tests = months, i; + + function equalit(input, mmm, i) { + assertEq(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1) + ' instead is month ' + moment(input, mmm).month()); + } + + for (i = 0; i < 12; i++) { + equalit(tests[i], 'MMM', i); + equalit(tests[i], 'MMM', i); + equalit(tests[i], 'MMMM', i); + equalit(tests[i], 'MMMM', i); + equalit(tests[i].toLocaleLowerCase(), 'MMMM', i); + equalit(tests[i].toLocaleLowerCase(), 'MMMM', i); + equalit(tests[i].toLocaleUpperCase(), 'MMMM', i); + equalit(tests[i].toLocaleUpperCase(), 'MMMM', i); + } + }); + + it('format', function () { + var a = [ + ['dddd, MMMM Do YYYY, h:mm:ss a', 'یکشنبه، فوریه ١٤ ٢٠١٠، ٣:٢٥:٥٠ م'], + ['ddd, hA', 'یکشنبه، ٣م'], + ['M Mo MM MMMM MMM', '٢ ٢ ٠٢ فوریه فوریه'], + ['YYYY YY', '٢٠١٠ ١٠'], + ['D Do DD', '١٤ ١٤ ١٤'], + ['d do dddd ddd dd', '٠ ٠ یکشنبه یکشنبه ی'], + ['DDD DDDo DDDD', '٤٥ ٤٥ ٠٤٥'], + ['w wo ww', '٨ ٨ ٠٨'], + ['h hh', '٣ ٠٣'], + ['H HH', '١٥ ١٥'], + ['m mm', '٢٥ ٢٥'], + ['s ss', '٥٠ ٥٠'], + ['a A', 'م م'], + ['[the] DDDo [day of the year]', 'the ٤٥ day of the year'], + ['LT', '١٥:٢٥'], + ['LTS', '١٥:٢٥:٥٠'], + ['L', '١٤/\u200f٢/\u200f٢٠١٠'], + ['LL', '١٤ فوریه ٢٠١٠'], + ['LLL', '١٤ فوریه ٢٠١٠ ١٥:٢٥'], + ['LLLL', 'یکشنبه ١٤ فوریه ٢٠١٠ ١٥:٢٥'], + ['l', '١٤/\u200f٢/\u200f٢٠١٠'], + ['ll', '١٤ فوریه ٢٠١٠'], + ['lll', '١٤ فوریه ٢٠١٠ ١٥:٢٥'], + ['llll', 'یکشنبه ١٤ فوریه ٢٠١٠ ١٥:٢٥'] + ], + b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)), + i; + for (i = 0; i < a.length; i++) { + assertEq(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]); + } + }); + + it('format ordinal', function () { + assertEq(moment([2011, 0, 1]).format('DDDo'), '١', '1'); + assertEq(moment([2011, 0, 2]).format('DDDo'), '٢', '2'); + assertEq(moment([2011, 0, 3]).format('DDDo'), '٣', '3'); + assertEq(moment([2011, 0, 4]).format('DDDo'), '٤', '4'); + assertEq(moment([2011, 0, 5]).format('DDDo'), '٥', '5'); + assertEq(moment([2011, 0, 6]).format('DDDo'), '٦', '6'); + assertEq(moment([2011, 0, 7]).format('DDDo'), '٧', '7'); + assertEq(moment([2011, 0, 8]).format('DDDo'), '٨', '8'); + assertEq(moment([2011, 0, 9]).format('DDDo'), '٩', '9'); + assertEq(moment([2011, 0, 10]).format('DDDo'), '١٠', '10'); + + assertEq(moment([2011, 0, 11]).format('DDDo'), '١١', '11'); + assertEq(moment([2011, 0, 12]).format('DDDo'), '١٢', '12'); + assertEq(moment([2011, 0, 13]).format('DDDo'), '١٣', '13'); + assertEq(moment([2011, 0, 14]).format('DDDo'), '١٤', '14'); + assertEq(moment([2011, 0, 15]).format('DDDo'), '١٥', '15'); + assertEq(moment([2011, 0, 16]).format('DDDo'), '١٦', '16'); + assertEq(moment([2011, 0, 17]).format('DDDo'), '١٧', '17'); + assertEq(moment([2011, 0, 18]).format('DDDo'), '١٨', '18'); + assertEq(moment([2011, 0, 19]).format('DDDo'), '١٩', '19'); + assertEq(moment([2011, 0, 20]).format('DDDo'), '٢٠', '20'); + + assertEq(moment([2011, 0, 21]).format('DDDo'), '٢١', '21'); + assertEq(moment([2011, 0, 22]).format('DDDo'), '٢٢', '22'); + assertEq(moment([2011, 0, 23]).format('DDDo'), '٢٣', '23'); + assertEq(moment([2011, 0, 24]).format('DDDo'), '٢٤', '24'); + assertEq(moment([2011, 0, 25]).format('DDDo'), '٢٥', '25'); + assertEq(moment([2011, 0, 26]).format('DDDo'), '٢٦', '26'); + assertEq(moment([2011, 0, 27]).format('DDDo'), '٢٧', '27'); + assertEq(moment([2011, 0, 28]).format('DDDo'), '٢٨', '28'); + assertEq(moment([2011, 0, 29]).format('DDDo'), '٢٩', '29'); + assertEq(moment([2011, 0, 30]).format('DDDo'), '٣٠', '30'); + + assertEq(moment([2011, 0, 31]).format('DDDo'), '٣١', '31'); + }); + + it('format month', function () { + var expected = months, i; + for (i = 0; i < expected.length; i++) { + assertEq(moment([2011, i, 1]).format('MMMM'), expected[i], expected[i]); + assertEq(moment([2011, i, 1]).format('MMM'), expected[i], expected[i]); + } + }); + + it('format week', function () { + var expected = 'یکشنبه یکشنبه ی_دوشنبه دوشنبه د_سه‌شنبه سه‌شنبه س_چهارشنبه چهارشنبه چ_پنج‌شنبه پنج‌شنبه پ_جمعه جمعه ج_شنبه شنبه ش'.split('_'), + i; + for (i = 0; i < expected.length; i++) { + assertEq(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]); + } + }); + + it('from', function () { + var start = moment([2007, 1, 28]); + assertEq(start.from(moment([2007, 1, 28]).add({ s: 44 }), true), '٤٤ ثانیه', '44 seconds = a few seconds'); + assertEq(start.from(moment([2007, 1, 28]).add({ s: 45 }), true), 'یک دقیقه', '45 seconds = a minute'); + assertEq(start.from(moment([2007, 1, 28]).add({ s: 89 }), true), 'یک دقیقه', '89 seconds = a minute'); + assertEq(start.from(moment([2007, 1, 28]).add({ s: 90 }), true), 'دقیقه', '90 seconds = 2 minutes'); + assertEq(start.from(moment([2007, 1, 28]).add({ m: 44 }), true), '٤٤ دقیقه', '44 minutes = 44 minutes'); + assertEq(start.from(moment([2007, 1, 28]).add({ m: 45 }), true), 'یک ساعت', '45 minutes = an hour'); + assertEq(start.from(moment([2007, 1, 28]).add({ m: 89 }), true), 'یک ساعت', '89 minutes = an hour'); + assertEq(start.from(moment([2007, 1, 28]).add({ m: 90 }), true), 'ساعت', '90 minutes = 2 hours'); + assertEq(start.from(moment([2007, 1, 28]).add({ h: 5 }), true), '٥ ساعت', '5 hours = 5 hours'); + assertEq(start.from(moment([2007, 1, 28]).add({ h: 21 }), true), '٢١ ساعت', '21 hours = 21 hours'); + assertEq(start.from(moment([2007, 1, 28]).add({ h: 22 }), true), 'یک روز', '22 hours = a day'); + assertEq(start.from(moment([2007, 1, 28]).add({ h: 35 }), true), 'یک روز', '35 hours = a day'); + assertEq(start.from(moment([2007, 1, 28]).add({ h: 36 }), true), 'روز', '36 hours = 2 days'); + assertEq(start.from(moment([2007, 1, 28]).add({ d: 1 }), true), 'یک روز', '1 day = a day'); + assertEq(start.from(moment([2007, 1, 28]).add({ d: 5 }), true), '٥ روز', '5 days = 5 days'); + assertEq(start.from(moment([2007, 1, 28]).add({ d: 25 }), true), '٢٥ روز', '25 days = 25 days'); + assertEq(start.from(moment([2007, 1, 28]).add({ d: 26 }), true), 'یک ماه', '26 days = a month'); + assertEq(start.from(moment([2007, 1, 28]).add({ d: 30 }), true), 'یک ماه', '30 days = a month'); + assertEq(start.from(moment([2007, 1, 28]).add({ d: 43 }), true), 'یک ماه', '43 days = a month'); + assertEq(start.from(moment([2007, 1, 28]).add({ d: 46 }), true), 'ماه', '46 days = 2 months'); + assertEq(start.from(moment([2007, 1, 28]).add({ d: 74 }), true), 'ماه', '75 days = 2 months'); + assertEq(start.from(moment([2007, 1, 28]).add({ d: 76 }), true), '٣ ماه', '76 days = 3 months'); + assertEq(start.from(moment([2007, 1, 28]).add({ M: 1 }), true), 'یک ماه', '1 month = a month'); + assertEq(start.from(moment([2007, 1, 28]).add({ M: 5 }), true), '٥ ماه', '5 months = 5 months'); + assertEq(start.from(moment([2007, 1, 28]).add({ d: 345 }), true), 'یک سال', '345 days = a year'); + assertEq(start.from(moment([2007, 1, 28]).add({ d: 548 }), true), 'سال', '548 days = 2 years'); + assertEq(start.from(moment([2007, 1, 28]).add({ y: 1 }), true), 'سال', '1 year = a year'); + assertEq(start.from(moment([2007, 1, 28]).add({ y: 5 }), true), '٥ سال', '5 years = 5 years'); + }); + + it('suffix', function () { + assertEq(moment(30000).from(0), '٣٠ ثانیه بعد', 'prefix'); + assertEq(moment(0).from(30000), '٣٠ ثانیه پیش', 'suffix'); + }); + + it('now from now', function () { + assertEq(moment().fromNow(), 'یک ثانیه پیش', 'now from now should display as in the past'); + }); + + it('fromNow', function () { + assertEq(moment().add({ s: 30 }).fromNow(), '٣٠ ثانیه بعد', 'in a few seconds'); + assertEq(moment().add({ d: 5 }).fromNow(), '٥ روز بعد', 'in 5 days'); + }); + + it('calendar day', function () { + var a = moment().hours(12).minutes(0).seconds(0); + + assertEq(moment(a).calendar(), 'اليوم عند الساعة امروز ساعت ١٢:٠٠', 'today at the same time'); + assertEq(moment(a).add({ m: 25 }).calendar(), 'امروز ساعت ١٢:٢٥', 'Now plus 25 min'); + assertEq(moment(a).add({ h: 1 }).calendar(), 'امروز ساعت ١٣:٠٠', 'Now plus 1 hour'); + assertEq(moment(a).add({ d: 1 }).calendar(), 'فردا ساعت ١٢:٠٠', 'tomorrow at the same time'); + assertEq(moment(a).subtract({ h: 1 }).calendar(), 'امروز ساعت ١١:٠٠', 'Now minus 1 hour'); + assertEq(moment(a).subtract({ d: 1 }).calendar(), 'دیروز ساعت ١٢:٠٠', 'yesterday at the same time'); + }); + + it('calendar next week', function () { + var i, m; + for (i = 2; i < 7; i++) { + m = moment().add({ d: i }); + assertEq(m.calendar(), m.format('dddd [در ساعت] LT'), 'Today + ' + i + ' days current time'); + m.hours(0).minutes(0).seconds(0).milliseconds(0); + assertEq(m.calendar(), m.format('dddd [در ساعت] LT'), 'Today + ' + i + ' days beginning of day'); + m.hours(23).minutes(59).seconds(59).milliseconds(999); + assertEq(m.calendar(), m.format('dddd [در ساعت] LT'), 'Today + ' + i + ' days end of day'); + } + }); + + it('calendar last week', function () { + var i, m; + for (i = 2; i < 7; i++) { + m = moment().subtract({ d: i }); + assertEq(m.calendar(), m.format('dddd [در ساعت] LT'), 'Today - ' + i + ' days current time'); + m.hours(0).minutes(0).seconds(0).milliseconds(0); + assertEq(m.calendar(), m.format('dddd [در ساعت] LT'), 'Today - ' + i + ' days beginning of day'); + m.hours(23).minutes(59).seconds(59).milliseconds(999); + assertEq(m.calendar(), m.format('dddd [در ساعت] LT'), 'Today - ' + i + ' days end of day'); + } + }); + + it('calendar all else', function () { + var weeksAgo = moment().subtract({ w: 1 }), + weeksFromNow = moment().add({ w: 1 }); + + assertEq(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago'); + assertEq(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week'); + + weeksAgo = moment().subtract({ w: 2 }); + weeksFromNow = moment().add({ w: 2 }); + + assertEq(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago'); + assertEq(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks'); + }); + + it('weeks year starting wednesday custom', function () { + assertEq(moment('2003 1 6', 'gggg w d').format('YYYY-MM-DD'), '٢٠٠٢-١٢-٢٨', 'Week 1 of 2003 should be Dec 28 2002'); + assertEq(moment('2003 1 0', 'gggg w e').format('YYYY-MM-DD'), '٢٠٠٢-١٢-٢٨', 'Week 1 of 2003 should be Dec 28 2002'); + assertEq(moment('2003 1 6', 'gggg w d').format('gggg w d'), '٢٠٠٣ ١ ٦', 'Saturday of week 1 of 2003 parsed should be formatted as 2003 1 6'); + assertEq(moment('2003 1 0', 'gggg w e').format('gggg w e'), '٢٠٠٣ ١ ٠', '1st day of week 1 of 2003 parsed should be formatted as 2003 1 0'); + }); + + it('weeks year starting sunday formatted', function () { + assertEq(moment([2011, 11, 31]).format('w ww wo'), '١ ٠١ ١', 'Dec 31 2011 should be week 1'); + assertEq(moment([2012, 0, 6]).format('w ww wo'), '١ ٠١ ١', 'Jan 6 2012 should be week 1'); + assertEq(moment([2012, 0, 7]).format('w ww wo'), '٢ ٠٢ ٢', 'Jan 7 2012 should be week 2'); + assertEq(moment([2012, 0, 13]).format('w ww wo'), '٢ ٠٢ ٢', 'Jan 13 2012 should be week 2'); + assertEq(moment([2012, 0, 14]).format('w ww wo'), '٣ ٠٣ ٣', 'Jan 14 2012 should be week 3'); + }); + + it('no leading zeros in long date formats', function () { + var i, j, longDateStr, shortDateStr; + for (i = 1; i <= 9; ++i) { + for (j = 1; j <= 9; ++j) { + longDateStr = moment([2014, i, j]).format('L'); + shortDateStr = moment([2014, i, j]).format('l'); + assertEq(longDateStr, shortDateStr, 'should not have leading zeros in month or day'); + } + } + }); + + // locale-specific + it('fa strict mode parsing works', function () { + var m, formattedDate; + m = moment().locale('fa'); + formattedDate = m.format('l'); + assertEq(moment.utc(formattedDate, 'l', 'fa', false).isValid(), true, 'Non-strict parsing works'); + assertEq(moment.utc(formattedDate, 'l', 'fa', true).isValid(), true, 'Strict parsing must work'); + }); +}); \ No newline at end of file From 83c3912c30876626f9075d89ef85595b0bb1d27e Mon Sep 17 00:00:00 2001 From: Christian Oliff Date: Thu, 17 Oct 2024 21:26:30 +0900 Subject: [PATCH 11/14] Add syntax highlighting to README (#6603) Co-authored-by: Dmitriy Shekhovtsov Co-authored-by: Alexey Umanskiy --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 0230c075ff..8891c7de6a 100644 --- a/README.md +++ b/README.md @@ -101,7 +101,7 @@ npm install ngx-bootstrap --save Add wanted package to NgModule imports: -``` +```ts import { TooltipModule } from 'ngx-bootstrap/tooltip'; @NgModule({ @@ -113,7 +113,7 @@ import { TooltipModule } from 'ngx-bootstrap/tooltip'; Add component to your page: -``` +```html
`, - providers: [BsDropdownState] }) export class BsDropdownContainerComponent implements OnDestroy { isOpen = false; diff --git a/src/typeahead/typeahead-container.component.ts b/src/typeahead/typeahead-container.component.ts index 6cc0a6e7c5..032fe11a72 100644 --- a/src/typeahead/typeahead-container.component.ts +++ b/src/typeahead/typeahead-container.component.ts @@ -276,7 +276,7 @@ export class TypeaheadContainerComponent implements OnDestroy { `${itemStr.substring(0, startIdx)}${itemStr.substring(startIdx, startIdx + tokenLen)}` + `${itemStr.substring(startIdx + tokenLen)}`; itemStrHelper = - `${itemStrHelper.substring(0, startIdx)} ${' '.repeat(tokenLen)} ` + + `${itemStrHelper.substring(0, startIdx)}????????${'??'.repeat(tokenLen)}??????????` + `${itemStrHelper.substring(startIdx + tokenLen)}`; } } From b56863dad3f81a45ae289202426d82cac159d30a Mon Sep 17 00:00:00 2001 From: Alexey Umanskiy Date: Mon, 21 Oct 2024 13:29:30 +0300 Subject: [PATCH 14/14] Alex bump to 18 1 2 (#6694) * fix(Typeahead) Typeahead highlight displays tag when empty spaces added at the end of query and does not escape html tags (#6434) Co-authored-by: udayk Co-authored-by: Alexey Umanskiy * 18.1.2 * chore(version): version bump * chore(version): version bump * chore(version): version bump --------- Co-authored-by: UdayAppam Co-authored-by: udayk --- apps/ngx-bootstrap-docs/src/assets/json/current-version.json | 2 +- package-lock.json | 4 ++-- package.json | 2 +- src/accordion/package.json | 2 +- src/alert/package.json | 2 +- src/buttons/package.json | 2 +- src/carousel/package.json | 2 +- src/chronos/package.json | 2 +- src/collapse/package.json | 2 +- src/component-loader/package.json | 2 +- src/datepicker/package.json | 2 +- src/dropdown/package.json | 2 +- src/focus-trap/package.json | 2 +- src/locale/package.json | 2 +- src/mini-ngrx/package.json | 2 +- src/modal/package.json | 2 +- src/pagination/package.json | 2 +- src/popover/package.json | 2 +- src/positioning/package.json | 2 +- src/progressbar/package.json | 2 +- src/rating/package.json | 2 +- src/root/package.json | 2 +- src/schematics/package.json | 2 +- src/schematics/src/utils/current_dependency_versions.json | 2 +- src/sortable/package.json | 2 +- src/tabs/package.json | 2 +- src/timepicker/package.json | 2 +- src/tooltip/package.json | 2 +- src/typeahead/package.json | 2 +- src/utils/package.json | 2 +- 30 files changed, 31 insertions(+), 31 deletions(-) diff --git a/apps/ngx-bootstrap-docs/src/assets/json/current-version.json b/apps/ngx-bootstrap-docs/src/assets/json/current-version.json index 068131925c..7f9a58507d 100644 --- a/apps/ngx-bootstrap-docs/src/assets/json/current-version.json +++ b/apps/ngx-bootstrap-docs/src/assets/json/current-version.json @@ -1,3 +1,3 @@ { - "version": "18.1.1" + "version": "18.1.2" } diff --git a/package-lock.json b/package-lock.json index ed712ed5d5..ffb88e7452 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "ngx-bootstrap-base", - "version": "18.1.1", + "version": "18.1.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "ngx-bootstrap-base", - "version": "18.1.1", + "version": "18.1.2", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index c1c0252f27..ed0b68be09 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap-base", - "version": "18.1.1", + "version": "18.1.2", "license": "MIT", "author": "Dmitriy Shekhovtsov ", "schematics": "./schematics/src/collection.json", diff --git a/src/accordion/package.json b/src/accordion/package.json index 0dd7738830..e79f72b000 100644 --- a/src/accordion/package.json +++ b/src/accordion/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/accordion", - "version": "18.1.1", + "version": "18.1.2", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/alert/package.json b/src/alert/package.json index 6a35a023b9..7d8c90b81c 100644 --- a/src/alert/package.json +++ b/src/alert/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/alert", - "version": "18.1.1", + "version": "18.1.2", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/buttons/package.json b/src/buttons/package.json index c7d4807fc7..a7c2292e0a 100644 --- a/src/buttons/package.json +++ b/src/buttons/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/buttons", - "version": "18.1.1", + "version": "18.1.2", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/carousel/package.json b/src/carousel/package.json index 0cd2f05f2d..fd6ea5c7bf 100644 --- a/src/carousel/package.json +++ b/src/carousel/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/carousel", - "version": "18.1.1", + "version": "18.1.2", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/chronos/package.json b/src/chronos/package.json index cdf2cf8eca..55d2a31046 100644 --- a/src/chronos/package.json +++ b/src/chronos/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/chronos", - "version": "18.1.1", + "version": "18.1.2", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/collapse/package.json b/src/collapse/package.json index 6bb0c979f9..c13c7966f1 100644 --- a/src/collapse/package.json +++ b/src/collapse/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/collapse", - "version": "18.1.1", + "version": "18.1.2", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/component-loader/package.json b/src/component-loader/package.json index 5024032b46..62943895dc 100644 --- a/src/component-loader/package.json +++ b/src/component-loader/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/component-loader", - "version": "18.1.1", + "version": "18.1.2", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/datepicker/package.json b/src/datepicker/package.json index f50a853cd6..d6f9896fd7 100644 --- a/src/datepicker/package.json +++ b/src/datepicker/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/datepicker", - "version": "18.1.1", + "version": "18.1.2", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/dropdown/package.json b/src/dropdown/package.json index 08048953bf..8242ab9142 100644 --- a/src/dropdown/package.json +++ b/src/dropdown/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/dropdown", - "version": "18.1.1", + "version": "18.1.2", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/focus-trap/package.json b/src/focus-trap/package.json index 82b05ef148..4b2264a1b0 100644 --- a/src/focus-trap/package.json +++ b/src/focus-trap/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/focus-trap", - "version": "18.1.1", + "version": "18.1.2", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/locale/package.json b/src/locale/package.json index 5eb51ee06d..0addb735c1 100644 --- a/src/locale/package.json +++ b/src/locale/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/locale", - "version": "18.1.1", + "version": "18.1.2", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/mini-ngrx/package.json b/src/mini-ngrx/package.json index 9112c1fe30..ec51e945d2 100644 --- a/src/mini-ngrx/package.json +++ b/src/mini-ngrx/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/mini-ngrx", - "version": "18.1.1", + "version": "18.1.2", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/modal/package.json b/src/modal/package.json index 0a303c5f24..135b931931 100644 --- a/src/modal/package.json +++ b/src/modal/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/modal", - "version": "18.1.1", + "version": "18.1.2", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/pagination/package.json b/src/pagination/package.json index df20f24377..965757b409 100644 --- a/src/pagination/package.json +++ b/src/pagination/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/pagination", - "version": "18.1.1", + "version": "18.1.2", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/popover/package.json b/src/popover/package.json index 462b00b143..5b18c017de 100644 --- a/src/popover/package.json +++ b/src/popover/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/popover", - "version": "18.1.1", + "version": "18.1.2", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/positioning/package.json b/src/positioning/package.json index 17d421294f..e8407dfc6c 100644 --- a/src/positioning/package.json +++ b/src/positioning/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/positioning", - "version": "18.1.1", + "version": "18.1.2", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/progressbar/package.json b/src/progressbar/package.json index c3c9f44ae8..d1ec324032 100644 --- a/src/progressbar/package.json +++ b/src/progressbar/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/progressbar", - "version": "18.1.1", + "version": "18.1.2", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/rating/package.json b/src/rating/package.json index 7680095734..2c2049d0d0 100644 --- a/src/rating/package.json +++ b/src/rating/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/rating", - "version": "18.1.1", + "version": "18.1.2", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/root/package.json b/src/root/package.json index 7b6f69ccdf..4cd5008c30 100644 --- a/src/root/package.json +++ b/src/root/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap", - "version": "18.1.1", + "version": "18.1.2", "description": "Angular Bootstrap", "author": "Dmitriy Shekhovtsov ", "license": "MIT", diff --git a/src/schematics/package.json b/src/schematics/package.json index 1bcc1fdd4a..2fb67140af 100644 --- a/src/schematics/package.json +++ b/src/schematics/package.json @@ -1,6 +1,6 @@ { "name": "schematics", - "version": "18.1.1", + "version": "18.1.2", "schematics": "./collection.json", "author": "Dmitriy Shekhovtsov ", "license": "MIT" diff --git a/src/schematics/src/utils/current_dependency_versions.json b/src/schematics/src/utils/current_dependency_versions.json index 092ceceb24..47c322c2d5 100644 --- a/src/schematics/src/utils/current_dependency_versions.json +++ b/src/schematics/src/utils/current_dependency_versions.json @@ -1,4 +1,4 @@ { - "NGX_BOOTSTRAP_VERSION": "18.1.1", + "NGX_BOOTSTRAP_VERSION": "18.1.2", "BOOTSTRAP_VERSION": "^5.2.3" } diff --git a/src/sortable/package.json b/src/sortable/package.json index 7595c8a7cd..7bd5818b93 100644 --- a/src/sortable/package.json +++ b/src/sortable/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/sortable", - "version": "18.1.1", + "version": "18.1.2", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/tabs/package.json b/src/tabs/package.json index c15d73143f..74e986575b 100644 --- a/src/tabs/package.json +++ b/src/tabs/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/tabs", - "version": "18.1.1", + "version": "18.1.2", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/timepicker/package.json b/src/timepicker/package.json index cc2c357e5c..908a5e4554 100644 --- a/src/timepicker/package.json +++ b/src/timepicker/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/timepicker", - "version": "18.1.1", + "version": "18.1.2", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/tooltip/package.json b/src/tooltip/package.json index cfec702241..06f4e714b4 100644 --- a/src/tooltip/package.json +++ b/src/tooltip/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/tooltip", - "version": "18.1.1", + "version": "18.1.2", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/typeahead/package.json b/src/typeahead/package.json index deb804e7fb..f352e05e24 100644 --- a/src/typeahead/package.json +++ b/src/typeahead/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/typeahead", - "version": "18.1.1", + "version": "18.1.2", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/utils/package.json b/src/utils/package.json index 442f87287b..9f1924a89c 100644 --- a/src/utils/package.json +++ b/src/utils/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/utils", - "version": "18.1.1", + "version": "18.1.2", "author": "Dmitriy Shekhovtsov ", "license": "MIT" }