-
Notifications
You must be signed in to change notification settings - Fork 473
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): refactor dialogs to no longer require module import
- Loading branch information
Showing
60 changed files
with
272 additions
and
590 deletions.
There are no files selected for viewing
3 changes: 0 additions & 3 deletions
3
projects/addon-mobile/components/mobile-dialog/mobile-dialog.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,14 @@ | ||
import {CommonModule} from '@angular/common'; | ||
import {NgModule} from '@angular/core'; | ||
import {TuiRippleModule} from '@taiga-ui/addon-mobile/directives/ripple'; | ||
import {tuiAsDialog} from '@taiga-ui/cdk'; | ||
import {TuiButtonModule} from '@taiga-ui/core'; | ||
import {PolymorpheusModule} from '@tinkoff/ng-polymorpheus'; | ||
|
||
import {TuiMobileDialogComponent} from './mobile-dialog.component'; | ||
import {TuiMobileDialogService} from './mobile-dialog.service'; | ||
|
||
@NgModule({ | ||
imports: [CommonModule, TuiButtonModule, TuiRippleModule, PolymorpheusModule], | ||
declarations: [TuiMobileDialogComponent], | ||
providers: [tuiAsDialog(TuiMobileDialogService)], | ||
exports: [TuiMobileDialogComponent], | ||
}) | ||
export class TuiMobileDialogModule {} |
12 changes: 6 additions & 6 deletions
12
projects/addon-mobile/components/mobile-dialog/mobile-dialog.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 1 addition & 3 deletions
4
projects/addon-mobile/components/sheet-dialog/sheet-dialog.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,15 @@ | ||
import {CommonModule} from '@angular/common'; | ||
import {NgModule} from '@angular/core'; | ||
import {tuiAsDialog, TuiClickOutsideModule} from '@taiga-ui/cdk'; | ||
import {TuiClickOutsideModule} from '@taiga-ui/cdk'; | ||
import {TuiButtonModule} from '@taiga-ui/core'; | ||
import {PolymorpheusModule} from '@tinkoff/ng-polymorpheus'; | ||
|
||
import {TuiSheetDialogComponent} from './sheet-dialog.component'; | ||
import {TuiSheetDialogDirective} from './sheet-dialog.directive'; | ||
import {TuiSheetDialogService} from './sheet-dialog.service'; | ||
|
||
@NgModule({ | ||
imports: [CommonModule, PolymorpheusModule, TuiClickOutsideModule, TuiButtonModule], | ||
declarations: [TuiSheetDialogComponent, TuiSheetDialogDirective], | ||
providers: [tuiAsDialog(TuiSheetDialogService)], | ||
exports: [TuiSheetDialogComponent, TuiSheetDialogDirective], | ||
}) | ||
export class TuiSheetDialogModule {} |
14 changes: 6 additions & 8 deletions
14
projects/addon-mobile/components/sheet-dialog/sheet-dialog.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 7 additions & 5 deletions
12
projects/addon-preview/components/preview-dialog/preview-dialog.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
import {Injectable} from '@angular/core'; | ||
import {AbstractTuiDialogService} from '@taiga-ui/cdk'; | ||
import {inject, Injectable} from '@angular/core'; | ||
import {TuiPopoverService} from '@taiga-ui/cdk'; | ||
import {TUI_DIALOGS} from '@taiga-ui/core'; | ||
import {PolymorpheusComponent} from '@tinkoff/ng-polymorpheus'; | ||
|
||
import {TuiPreviewDialogComponent} from './preview-dialog.component'; | ||
|
||
@Injectable({providedIn: 'root'}) | ||
export class TuiPreviewDialogService extends AbstractTuiDialogService<unknown> { | ||
readonly defaultOptions = {}; | ||
readonly component = new PolymorpheusComponent(TuiPreviewDialogComponent); | ||
export class TuiPreviewDialogService extends TuiPopoverService<unknown> { | ||
protected readonly items$ = inject(TUI_DIALOGS); | ||
protected readonly options = {}; | ||
protected readonly component = new PolymorpheusComponent(TuiPreviewDialogComponent); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
126 changes: 0 additions & 126 deletions
126
projects/cdk/components/dialog-host/dialog-host.component.ts
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
24 changes: 0 additions & 24 deletions
24
projects/cdk/components/dialog-host/dialog-host.template.html
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
export * from '@taiga-ui/cdk/components/alert-host'; | ||
export * from '@taiga-ui/cdk/components/dialog-host'; | ||
export * from '@taiga-ui/cdk/components/dropdown-host'; | ||
export * from '@taiga-ui/cdk/components/scroll-controls'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './popover.directive'; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import {Directive, inject, OnChanges} from '@angular/core'; | ||
import {tuiIfMap} from '@taiga-ui/cdk/observables'; | ||
import {TuiPopover, TuiPopoverService} from '@taiga-ui/cdk/services'; | ||
import {PolymorpheusTemplate} from '@tinkoff/ng-polymorpheus'; | ||
import {distinctUntilChanged, endWith, ignoreElements, share, Subject} from 'rxjs'; | ||
|
||
@Directive() | ||
// eslint-disable-next-line @typescript-eslint/naming-convention | ||
export abstract class TuiPopoverDirective<T> | ||
extends PolymorpheusTemplate<TuiPopover<T, void>> | ||
implements OnChanges | ||
{ | ||
private readonly service = inject(TuiPopoverService<T>); | ||
private readonly open$ = new Subject<boolean>(); | ||
|
||
options: Partial<T> = {}; | ||
open = false; | ||
|
||
readonly openChange = this.open$.pipe( | ||
distinctUntilChanged(), | ||
tuiIfMap(() => | ||
this.service.open(this, this.options).pipe(ignoreElements(), endWith(false)), | ||
), | ||
share(), | ||
); | ||
|
||
ngOnChanges(): void { | ||
this.open$.next(this.open); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
File renamed without changes.
Oops, something went wrong.