Skip to content

Commit

Permalink
chore: fix directionality
Browse files Browse the repository at this point in the history
  • Loading branch information
cipchk committed Jan 20, 2024
1 parent 712cf0a commit 4cab0de
Show file tree
Hide file tree
Showing 12 changed files with 17 additions and 19 deletions.
4 changes: 2 additions & 2 deletions packages/abc/auto-focus/auto-focus.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { timer } from 'rxjs';
export class AutoFocusDirective implements AfterViewInit {
private readonly el: HTMLElement = inject(ElementRef).nativeElement;
private readonly platform = inject(Platform);
private readonly d$ = inject(DestroyRef);
private readonly destroy$ = inject(DestroyRef);

@Input({ transform: booleanAttribute }) enabled = true;
@Input({ transform: numberAttribute }) delay = 300;
Expand All @@ -31,7 +31,7 @@ export class AutoFocusDirective implements AfterViewInit {
return;
}
timer(this.delay)
.pipe(takeUntilDestroyed(this.d$))
.pipe(takeUntilDestroyed(this.destroy$))
.subscribe(() => el.focus({ preventScroll: false }));
}
}
5 changes: 3 additions & 2 deletions packages/abc/avatar-list/avatar-list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
ChangeDetectorRef,
Component,
ContentChildren,
DestroyRef,
Input,
OnChanges,
QueryList,
Expand Down Expand Up @@ -38,7 +39,7 @@ import { AvatarListItemComponent } from './avatar-list-item.component';
export class AvatarListComponent implements AfterViewInit, OnChanges {
private readonly cdr = inject(ChangeDetectorRef);
private readonly directionality = inject(Directionality, { optional: true });
private dir$ = this.directionality?.change?.pipe(takeUntilDestroyed());
private readonly destroy$ = inject(DestroyRef);

private inited = false;
@ContentChildren(AvatarListItemComponent, { descendants: false })
Expand Down Expand Up @@ -79,7 +80,7 @@ export class AvatarListComponent implements AfterViewInit, OnChanges {

ngAfterViewInit(): void {
this.dir = this.directionality?.value;
this.dir$?.subscribe((direction: Direction) => {
this.directionality?.change.pipe(takeUntilDestroyed(this.destroy$)).subscribe(direction => {
this.dir = direction;
this.cdr.detectChanges();
});
Expand Down
2 changes: 1 addition & 1 deletion packages/abc/error-collect/error-collect.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export class ErrorCollectComponent implements OnInit {

private install(): void {
this.dir = this.directionality?.value;
this.directionality?.change?.pipe(takeUntilDestroyed(this.destroy$)).subscribe((direction: Direction) => {
this.directionality?.change.pipe(takeUntilDestroyed(this.destroy$)).subscribe(direction => {
this.dir = direction;
this.cdr.detectChanges();
});
Expand Down
2 changes: 1 addition & 1 deletion packages/abc/exception/exception.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export class ExceptionComponent implements OnInit {

ngOnInit(): void {
this.dir = this.directionality?.value;
this.directionality?.change?.pipe(takeUntilDestroyed(this.destroy$)).subscribe((direction: Direction) => {
this.directionality?.change.pipe(takeUntilDestroyed(this.destroy$)).subscribe(direction => {
this.dir = direction;
this.cdr.detectChanges();
});
Expand Down
3 changes: 1 addition & 2 deletions packages/abc/global-footer/global-footer.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ export class GlobalFooterComponent implements OnInit {
private readonly cdr = inject(ChangeDetectorRef);
private readonly destroy$ = inject(DestroyRef);

private dir$ = this.directionality?.change?.pipe(takeUntilDestroyed());
private _links: GlobalFooterLink[] = [];

dir?: Direction = 'ltr';
Expand Down Expand Up @@ -76,7 +75,7 @@ export class GlobalFooterComponent implements OnInit {

ngOnInit(): void {
this.dir = this.directionality?.value;
this.dir$?.pipe(takeUntilDestroyed(this.destroy$)).subscribe((direction: Direction) => {
this.directionality?.change.pipe(takeUntilDestroyed(this.destroy$)).subscribe(direction => {
this.dir = direction;
this.cdr.detectChanges();
});
Expand Down
3 changes: 1 addition & 2 deletions packages/abc/page-header/page-header.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ export class PageHeaderComponent implements OnInit, OnChanges, AfterViewInit {
private readonly reuseSrv = inject(ReuseTabService, { optional: true });
private readonly directionality = inject(Directionality, { optional: true });

private dir$ = this.directionality?.change?.pipe(takeUntilDestroyed());
@ViewChild('conTpl', { static: false }) private conTpl!: ElementRef;
@ViewChild('affix', { static: false }) private affix!: NzAffixComponent;
inited = false;
Expand Down Expand Up @@ -207,7 +206,7 @@ export class PageHeaderComponent implements OnInit, OnChanges, AfterViewInit {

ngOnInit(): void {
this.dir = this.directionality?.value;
this.dir$?.subscribe((direction: Direction) => {
this.directionality?.change.pipe(takeUntilDestroyed()).subscribe(direction => {
this.dir = direction;
this.cdr.detectChanges();
});
Expand Down
4 changes: 2 additions & 2 deletions packages/abc/result/result.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import { NzIconDirective } from 'ng-zorro-antd/icon';
export class ResultComponent implements OnInit {
private readonly cdr = inject(ChangeDetectorRef);
private readonly directionality = inject(Directionality, { optional: true });
private dir$ = this.directionality?.change?.pipe(takeUntilDestroyed());

_type = '';
_icon = '';
@Input()
Expand All @@ -57,7 +57,7 @@ export class ResultComponent implements OnInit {

ngOnInit(): void {
this.dir = this.directionality?.value;
this.dir$?.subscribe((direction: Direction) => {
this.directionality?.change.pipe(takeUntilDestroyed()).subscribe(direction => {
this.dir = direction;
this.cdr.detectChanges();
});
Expand Down
2 changes: 1 addition & 1 deletion packages/abc/reuse-tab/reuse-tab.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ export class ReuseTabComponent implements OnInit, OnChanges {

ngOnInit(): void {
this.dir = this.directionality?.value;
this.directionality?.change?.pipe(takeUntilDestroyed(this.destroy$)).subscribe((direction: Direction) => {
this.directionality?.change.pipe(takeUntilDestroyed(this.destroy$)).subscribe(direction => {
this.dir = direction;
this.cdr.detectChanges();
});
Expand Down
3 changes: 2 additions & 1 deletion packages/abc/tag-select/tag-select.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ export class TagSelectComponent implements OnInit {

ngOnInit(): void {
this.dir = this.directionality?.value;
this.directionality?.change?.pipe(takeUntilDestroyed(this.destroy$)).subscribe((direction: Direction) => {
this.directionality?.change.pipe(takeUntilDestroyed(this.destroy$)).subscribe(direction => {
this.dir = direction;
this.cdr.detectChanges();
});
this.i18n.change.pipe(takeUntilDestroyed(this.destroy$)).subscribe(() => {
this.locale = this.i18n.getData('tagSelect');
Expand Down
2 changes: 1 addition & 1 deletion packages/theme/layout-default/layout-nav.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ export class LayoutDefaultNavComponent implements OnInit, OnDestroy {
this.underPad();

this.dir = this.directionality?.value;
this.directionality?.change?.pipe(takeUntilDestroyed(this.destroy$)).subscribe((direction: Direction) => {
this.directionality?.change.pipe(takeUntilDestroyed(this.destroy$)).subscribe(direction => {
this.dir = direction;
this.cdr.detectChanges();
});
Expand Down
3 changes: 1 addition & 2 deletions packages/theme/setting-drawer/setting-drawer.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ export class SettingDrawerComponent implements OnInit {
@Input() lessJs = 'https://cdn.jsdelivr.net/npm/less';

private loadedLess = false;
private dir$ = this.directionality?.change?.pipe(takeUntilDestroyed());
dir?: Direction = 'ltr';
isDev = isDevMode();
collapse = false;
Expand All @@ -72,7 +71,7 @@ export class SettingDrawerComponent implements OnInit {

ngOnInit(): void {
this.dir = this.directionality?.value;
this.dir$?.subscribe((direction: Direction) => {
this.directionality?.change.pipe(takeUntilDestroyed()).subscribe(direction => {
this.dir = direction;
this.cdr.detectChanges();
});
Expand Down
3 changes: 1 addition & 2 deletions packages/theme/theme-btn/theme-btn.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,12 @@ export class ThemeBtnComponent implements OnInit, OnDestroy {
@Input() devTips = `When the dark.css file can't be found, you need to run it once: npm run theme`;
@Input() deployUrl = '';
@Output() readonly themeChange = new EventEmitter<string>();
private dir$ = this.directionality?.change?.pipe(takeUntilDestroyed());
dir?: Direction = 'ltr';
private key = inject(ALAIN_THEME_BTN_KEYS, { optional: true }) ?? 'site-theme';

ngOnInit(): void {
this.dir = this.directionality?.value;
this.dir$?.subscribe((direction: Direction) => {
this.directionality?.change.pipe(takeUntilDestroyed()).subscribe((direction: Direction) => {
this.dir = direction;
this.cdr.detectChanges();
});
Expand Down

0 comments on commit 4cab0de

Please sign in to comment.