diff --git a/.editorconfig b/.editorconfig index 6e87a003da..e89330a618 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,4 +1,4 @@ -# Editor configuration, see http://editorconfig.org +# Editor configuration, see https://editorconfig.org root = true [*] diff --git a/README.md b/README.md index bdff34ff81..8891c7de6a 100644 --- a/README.md +++ b/README.md @@ -101,19 +101,19 @@ npm install ngx-bootstrap --save Add wanted package to NgModule imports: -``` +```ts import { TooltipModule } from 'ngx-bootstrap/tooltip'; @NgModule({ ... - imports: [TooltipModule.forRoot(),...] + imports: [TooltipModule,...] ... }) ``` Add component to your page: -``` +```html - ` + `, + 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..981cd0e6ff 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,7 @@ import { Subscription } from 'rxjs'; [class.show]="isOpen" [class.open]="isOpen">
- ` + `, }) 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..7f7624ea4c 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 { 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,11 @@ import { BsDropdownState } from './bs-dropdown.state'; ] }) export class BsDropdownModule { + // @deprecated method not required anymore, will be deleted in v19.0.0 static forRoot(): ModuleWithProviders { return { ngModule: BsDropdownModule, - providers: [ - ComponentLoaderFactory, - PositioningService, - BsDropdownState - ] + providers: [] }; } } diff --git a/src/dropdown/package.json b/src/dropdown/package.json index 4592b8e8df..8242ab9142 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.1.2", "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..509b87439b 100644 --- a/src/focus-trap/focus-trap.module.ts +++ b/src/focus-trap/focus-trap.module.ts @@ -1,25 +1,18 @@ import { ModuleWithProviders, 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 { + // @deprecated method not required anymore, will be deleted in v19.0.0 static forRoot(): ModuleWithProviders { return { ngModule: FocusTrapModule, - providers: [ - FocusTrapManager, - Platform, - InteractivityChecker - ] + providers: [] }; } } 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 d40cd175a2..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.0.0", + "version": "18.1.2", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/locale/package.json b/src/locale/package.json index 100734411d..0addb735c1 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.1.2", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } 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/mini-ngrx/package.json b/src/mini-ngrx/package.json index 74a40c3bfc..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.0.0", + "version": "18.1.2", "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 4116d7c4e2..135b931931 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.1.2", "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 901e067682..965757b409 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.1.2", "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..a7c377f4af 100644 --- a/src/pagination/pagination.module.ts +++ b/src/pagination/pagination.module.ts @@ -1,16 +1,19 @@ import { CommonModule } from '@angular/common'; -import { NgModule, ModuleWithProviders } from '@angular/core'; +import { ModuleWithProviders, 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 { + // @deprecated method not required anymore, will be deleted in v19.0.0 static forRoot(): ModuleWithProviders { - return { ngModule: PaginationModule, providers: [] }; + return { + ngModule: PaginationModule, + providers: [] + }; } } 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 18292a548c..5b18c017de 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.1.2", "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..d69a1f8864 100644 --- a/src/popover/popover.module.ts +++ b/src/popover/popover.module.ts @@ -1,21 +1,19 @@ -import { NgModule, ModuleWithProviders } from '@angular/core'; +import { ModuleWithProviders, 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 { + // @deprecated method not required anymore, will be deleted in v19.0.0 static forRoot(): ModuleWithProviders { return { ngModule: PopoverModule, - providers: [ComponentLoaderFactory, PositioningService] + providers: [] }; } } diff --git a/src/positioning/package.json b/src/positioning/package.json index dd538d52dd..e8407dfc6c 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.1.2", "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 5a863a19b5..d1ec324032 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.1.2", "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..27385314b9 100644 --- a/src/progressbar/progressbar.module.ts +++ b/src/progressbar/progressbar.module.ts @@ -1,16 +1,18 @@ -import { CommonModule } from '@angular/common'; -import { NgModule, ModuleWithProviders } from '@angular/core'; +import { ModuleWithProviders, 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 { + // @deprecated method not required anymore, will be deleted in v19.0.0 static forRoot(): ModuleWithProviders { - return { ngModule: ProgressbarModule, providers: [] }; + return { + ngModule: ProgressbarModule, + providers: [] + }; } } 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 bf4f414597..2c2049d0d0 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.1.2", "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..0c85ba15c6 100644 --- a/src/rating/rating.module.ts +++ b/src/rating/rating.module.ts @@ -1,14 +1,13 @@ -import { CommonModule } from '@angular/common'; -import { NgModule, ModuleWithProviders } from '@angular/core'; +import { ModuleWithProviders, NgModule } from '@angular/core'; import { RatingComponent } from './rating.component'; @NgModule({ - imports: [CommonModule], - declarations: [RatingComponent], - exports: [RatingComponent] + imports: [RatingComponent], + exports: [RatingComponent] }) export class RatingModule { + // @deprecated method not required anymore, will be deleted in v19.0.0 static forRoot(): ModuleWithProviders { return { ngModule: 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 e7c21d8e33..4cd5008c30 100644 --- a/src/root/package.json +++ b/src/root/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap", - "version": "18.0.0", + "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 5804886b53..2fb67140af 100644 --- a/src/schematics/package.json +++ b/src/schematics/package.json @@ -1,6 +1,6 @@ { "name": "schematics", - "version": "18.0.0", + "version": "18.1.2", "schematics": "./collection.json", "author": "Dmitriy Shekhovtsov ", "license": "MIT" 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/current_dependency_versions.json b/src/schematics/src/utils/current_dependency_versions.json index d027466700..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.0.0", + "NGX_BOOTSTRAP_VERSION": "18.1.2", "BOOTSTRAP_VERSION": "^5.2.3" } diff --git a/src/schematics/src/utils/index.ts b/src/schematics/src/utils/index.ts index c577271b94..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,6 +87,11 @@ 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) { 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(); } diff --git a/src/sortable/package.json b/src/sortable/package.json index a1051849b9..7bd5818b93 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.1.2", "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..29cda7c63c 100644 --- a/src/sortable/sortable.module.ts +++ b/src/sortable/sortable.module.ts @@ -1,16 +1,17 @@ -import { NgModule, ModuleWithProviders } from '@angular/core'; -import { CommonModule } from '@angular/common'; +import { ModuleWithProviders, 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 { + // @deprecated method not required anymore, will be deleted in v19.0.0 static forRoot(): ModuleWithProviders { - return { ngModule: SortableModule, providers: [DraggableItemService] }; + return { + ngModule: SortableModule, + providers: [] + }; } } 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 11fecbf5a8..74e986575b 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.1.2", "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..ce779c96e1 100644 --- a/src/tabs/tabs.module.ts +++ b/src/tabs/tabs.module.ts @@ -7,21 +7,19 @@ 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 { + // @deprecated method not required anymore, will be deleted in v19.0.0 static forRoot(): ModuleWithProviders { return { ngModule: 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 76a5b5892f..908a5e4554 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.1.2", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/timepicker/testing/timepicker.component.spec.ts b/src/timepicker/testing/timepicker.component.spec.ts index c9be4b5469..0b4f27823a 100644 --- a/src/timepicker/testing/timepicker.component.spec.ts +++ b/src/timepicker/testing/timepicker.component.spec.ts @@ -54,7 +54,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..bdb8678a4a 100644 --- a/src/timepicker/timepicker.module.ts +++ b/src/timepicker/timepicker.module.ts @@ -1,21 +1,17 @@ import { ModuleWithProviders, NgModule } from '@angular/core'; -import { CommonModule } from '@angular/common'; 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 { + // @deprecated method not required anymore, will be deleted in v19.0.0 static forRoot(): ModuleWithProviders { return { ngModule: TimepickerModule, - providers: [TimepickerActions, TimepickerStore] + providers: [] }; } } diff --git a/src/tooltip/package.json b/src/tooltip/package.json index d5ccef2018..06f4e714b4 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.1.2", "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..6a390afbd8 100644 --- a/src/tooltip/tooltip.module.ts +++ b/src/tooltip/tooltip.module.ts @@ -1,20 +1,18 @@ import { CommonModule } from '@angular/common'; -import { NgModule, ModuleWithProviders } from '@angular/core'; +import { ModuleWithProviders, 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 { + // @deprecated method not required anymore, will be deleted in v19.0.0 static forRoot(): ModuleWithProviders { return { ngModule: TooltipModule, - providers: [ComponentLoaderFactory, PositioningService] + providers: [] }; } } diff --git a/src/typeahead/package.json b/src/typeahead/package.json index e6235176e3..f352e05e24 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.1.2", "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..032fe11a72 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 { @@ -272,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)}`; } } 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..334b3df41c 100644 --- a/src/typeahead/typeahead.module.ts +++ b/src/typeahead/typeahead.module.ts @@ -1,21 +1,19 @@ import { CommonModule } from '@angular/common'; -import { NgModule, ModuleWithProviders } from '@angular/core'; +import { ModuleWithProviders, 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 { + // @deprecated method not required anymore, will be deleted in v19.0.0 static forRoot(): ModuleWithProviders { return { ngModule: TypeaheadModule, - providers: [ComponentLoaderFactory, PositioningService] + providers: [] }; } } diff --git a/src/utils/package.json b/src/utils/package.json index 1274afb3ee..9f1924a89c 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.1.2", "author": "Dmitriy Shekhovtsov ", "license": "MIT" }