Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(experimental): Fade add new component #5169

Merged
merged 3 commits into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ export class TuiLineChartHintDirective implements AfterViewInit {
constructor(
@Inject(Renderer2) private readonly renderer: Renderer2,
@Self() @Inject(TuiDestroyService) private readonly destroy$: TuiDestroyService,
@Inject(NgZone) private readonly ngZone: NgZone,
@Inject(NgZone) private readonly zone: NgZone,
@Inject(TuiHoveredService) private readonly hovered$: Observable<boolean>,
) {}

ngAfterViewInit(): void {
combineLatest([tuiLineChartDrivers(this.charts), this.hovered$])
.pipe(
filter(result => !result.some(Boolean)),
tuiZonefree(this.ngZone),
tuiZonefree(this.zone),
takeUntil(this.destroy$),
)
.subscribe(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export class TuiLineChartComponent {

constructor(
@Inject(TuiIdService) idService: TuiIdService,
@Inject(NgZone) private readonly ngZone: NgZone,
@Inject(NgZone) private readonly zone: NgZone,
@Optional()
@Inject(TuiLineChartHintDirective)
readonly hintDirective: TuiLineChartHintDirective | null,
Expand All @@ -97,7 +97,7 @@ export class TuiLineChartComponent {

@tuiPure
get hovered$(): Observable<number> {
return this._hovered$.pipe(distinctUntilChanged(), tuiZoneOptimized(this.ngZone));
return this._hovered$.pipe(distinctUntilChanged(), tuiZoneOptimized(this.zone));
}

get hintContent(): PolymorpheusContent<TuiLineChartHintContext<TuiPoint>> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class TuiLineDaysChartHintDirective implements AfterContentInit {

constructor(
@Self() @Inject(TuiDestroyService) private readonly destroy$: TuiDestroyService,
@Inject(NgZone) private readonly ngZone: NgZone,
@Inject(NgZone) private readonly zone: NgZone,
@Inject(TuiHoveredService) private readonly hovered$: Observable<boolean>,
) {}

Expand All @@ -51,7 +51,7 @@ export class TuiLineDaysChartHintDirective implements AfterContentInit {
])
.pipe(
filter(result => !result.some(Boolean)),
tuiZonefree(this.ngZone),
tuiZonefree(this.zone),
takeUntil(this.destroy$),
)
.subscribe(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export class TuiLineDaysChartComponent implements AfterViewInit {
@Inject(TuiLineDaysChartHintDirective)
private readonly hintDirective: TuiLineDaysChartHintDirective | null,
@Self() @Inject(TuiDestroyService) private readonly destroy$: TuiDestroyService,
@Inject(NgZone) private readonly ngZone: NgZone,
@Inject(NgZone) private readonly zone: NgZone,
@Inject(TuiHoveredService) private readonly hovered$: Observable<boolean>,
@Inject(TUI_LINE_CHART_OPTIONS) private readonly options: TuiLineChartOptions,
) {}
Expand Down Expand Up @@ -144,7 +144,7 @@ export class TuiLineDaysChartComponent implements AfterViewInit {
combineLatest([tuiLineChartDrivers(this.charts), this.hovered$])
.pipe(
filter(result => !result.some(Boolean)),
tuiZonefree(this.ngZone),
tuiZonefree(this.zone),
takeUntil(this.destroy$),
)
.subscribe(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class TuiPieChartDirective {

constructor(
@Inject(ElementRef) {nativeElement}: ElementRef<SVGPathElement>,
@Inject(NgZone) ngZone: NgZone,
@Inject(NgZone) zone: NgZone,
@Self() @Inject(TuiDestroyService) destroy$: Observable<unknown>,
@Inject(PERFORMANCE) performance: Performance,
@Inject(ANIMATION_FRAME) animationFrame$: Observable<number>,
Expand All @@ -47,7 +47,7 @@ export class TuiPieChartDirective {
]),
);
}),
tuiZonefree(ngZone),
tuiZonefree(zone),
takeUntil(destroy$),
)
.subscribe(([start, end]) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class TuiPullToRefreshComponent {
);

constructor(
@Inject(NgZone) ngZone: NgZone,
@Inject(NgZone) zone: NgZone,
@Inject(TuiDestroyService) @Self() destroy$: Observable<unknown>,
@Inject(TUI_SCROLL_REF) {nativeElement}: ElementRef<HTMLElement>,
@Inject(TUI_IS_IOS) private readonly isIOS: boolean,
Expand All @@ -64,7 +64,7 @@ export class TuiPullToRefreshComponent {
// Ensure scrolling down is impossible while pulling
if (this.component) {
tuiScrollFrom(nativeElement)
.pipe(startWith(null), tuiZonefree(ngZone), takeUntil(destroy$))
.pipe(startWith(null), tuiZonefree(zone), takeUntil(destroy$))
.subscribe(() => {
if (nativeElement.scrollTop) {
nativeElement.style.touchAction = '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ import {TUI_SHEET, TUI_SHEET_SCROLL} from '../../sheet-tokens';
})
export class TuiSheetBarComponent {
readonly rotate$ = this.scroll$.pipe(
tuiZonefulMap(y => tuiClamp(10 - (y - this.stop) / 5, 0, 10), this.ngZone),
tuiZonefulMap(y => tuiClamp(10 - (y - this.stop) / 5, 0, 10), this.zone),
);

constructor(
@Inject(TUI_SHEET) private readonly sheet: TuiSheetRequiredProps,
@Inject(TUI_SHEET_SCROLL) private readonly scroll$: Observable<number>,
@Inject(NgZone) private readonly ngZone: NgZone,
@Inject(NgZone) private readonly zone: NgZone,
) {}

private get stop(): number {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class TuiSheetComponent<T> implements TuiSheetRequiredProps<T>, AfterView
constructor(
@Inject(TUI_SHEET_SCROLL) private readonly scroll$: Observable<number>,
@Inject(ElementRef) private readonly el: ElementRef<HTMLElement>,
@Inject(NgZone) private readonly ngZone: NgZone,
@Inject(NgZone) private readonly zone: NgZone,
@Inject(TUI_IS_IOS) readonly isIos: boolean,
@Inject(TUI_MORE_WORD) readonly moreWord$: Observable<string>,
) {}
Expand All @@ -80,7 +80,7 @@ export class TuiSheetComponent<T> implements TuiSheetRequiredProps<T>, AfterView
get context(): TuiSheet<T> {
return {
...this.item,
scroll$: this.scroll$.pipe(tuiZonefull(this.ngZone)),
scroll$: this.scroll$.pipe(tuiZonefull(this.zone)),
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@ export const TUI_SHEET_PROVIDERS: Provider[] = [
deps: [ElementRef, NgZone, DOCUMENT, TUI_IS_IOS],
useFactory: (
{nativeElement}: ElementRef<HTMLElement>,
ngZone: NgZone,
zone: NgZone,
doc: Document,
isIos: boolean,
): Observable<number> => {
return isIos
? iosScrollFactory(nativeElement, doc, ngZone)
? iosScrollFactory(nativeElement, doc, zone)
: merge(
tuiTypedFromEvent(nativeElement, `scroll`),
tuiTypedFromEvent(nativeElement, `load`, {capture: true}),
).pipe(
map(() => nativeElement.scrollTop),
tuiZonefree(ngZone),
tuiZonefree(zone),
share(),
);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ export class TuiSheetCloseDirective {
),
filter(y => this.sheet.item?.closeable && this.shouldClose(y)),
distinctUntilChanged(),
tuiZonefull(this.ngZone),
tuiZonefull(this.zone),
),
);

constructor(
@Inject(NgZone) private readonly ngZone: NgZone,
@Inject(NgZone) private readonly zone: NgZone,
@Inject(TUI_SHEET_DRAGGED) private readonly dragged$: Observable<boolean>,
@Inject(TUI_SHEET_SCROLL) private readonly scroll$: Observable<number>,
@Inject(WINDOW) private readonly win: Window,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class TuiSheetWrapperDirective {
tuiSheetWrapper = 16;

constructor(
@Inject(NgZone) private readonly ngZone: NgZone,
@Inject(NgZone) private readonly zone: NgZone,
@Inject(WINDOW) private readonly win: Window,
) {}

Expand All @@ -51,15 +51,15 @@ export class TuiSheetWrapperDirective {
return this.scroll$.pipe(
map(y => y + 16 > this.win.innerHeight - this.tuiSheetWrapper),
distinctUntilChanged(),
tuiZonefull(this.ngZone),
tuiZonefull(this.zone),
);
}

@tuiPure
get visible$(): Observable<boolean> {
return processDragged(this.dragged$, this.scroll$).pipe(
distinctUntilChanged(),
tuiZonefull(this.ngZone),
tuiZonefull(this.zone),
);
}

Expand Down
4 changes: 2 additions & 2 deletions projects/addon-mobile/components/sheet/ios.hacks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {delay, map, share, switchMap, take, takeUntil} from 'rxjs/operators';
export function iosScrollFactory(
element: HTMLElement,
doc: Document,
ngZone: NgZone,
zone: NgZone,
): Observable<number> {
const load$ = tuiTypedFromEvent(element, `load`, {capture: true});
const touchstart$ = tuiTypedFromEvent(element, `touchstart`, {passive: true});
Expand Down Expand Up @@ -38,7 +38,7 @@ export function iosScrollFactory(
),
);

return concat(scroll$.pipe(take(1)), result$).pipe(tuiZonefree(ngZone), share());
return concat(scroll$.pipe(take(1)), result$).pipe(tuiZonefree(zone), share());
}

// eslint-disable-next-line @typescript-eslint/naming-convention
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ export class TuiElasticStickyService extends Observable<number> {
constructor(
@Inject(TUI_SCROLL_REF) scrollRef: ElementRef<HTMLElement>,
@Inject(ElementRef) {nativeElement}: ElementRef<HTMLElement>,
@Inject(NgZone) ngZone: NgZone,
@Inject(NgZone) zone: NgZone,
@Self() @Inject(TuiDestroyService) destroy$: TuiDestroyService,
) {
super(subscriber =>
ngZone.onStable
zone.onStable
.pipe(
take(1),
switchMap(() => {
Expand All @@ -53,7 +53,7 @@ export class TuiElasticStickyService extends Observable<number> {
startWith(1),
distinctUntilChanged(),
skip(1),
tuiZoneOptimized(ngZone),
tuiZoneOptimized(zone),
takeUntil(destroy$),
)
.subscribe(subscriber),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ export class TuiActiveZoneDirective implements OnDestroy {
startWith(false),
distinctUntilChanged(),
skip(1),
tuiZoneOptimized(this.ngZone),
tuiZoneOptimized(this.zone),
);

constructor(
@Inject(TUI_ACTIVE_ELEMENT)
private readonly active$: Observable<Element | null>,
@Inject(NgZone) private readonly ngZone: NgZone,
@Inject(NgZone) private readonly zone: NgZone,
@Inject(ElementRef) private readonly el: ElementRef<Element>,
@Optional()
@SkipSelf()
Expand Down
4 changes: 2 additions & 2 deletions projects/cdk/directives/auto-focus/autofocus.options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ export const TUI_AUTOFOCUS_PROVIDERS = [
el: ElementRef<HTMLElement>,
animationFrame$: Observable<number>,
renderer: Renderer2,
ngZone: NgZone,
zone: NgZone,
win: Window,
isIos: boolean,
) =>
isIos
? new TuiIosAutofocusHandler(focusable, el, renderer, ngZone, win)
? new TuiIosAutofocusHandler(focusable, el, renderer, zone, win)
: new TuiDefaultAutofocusHandler(focusable, el, animationFrame$),
deps: [
[new Optional(), new Self(), TUI_FOCUSABLE_ITEM_ACCESSOR],
Expand Down
4 changes: 2 additions & 2 deletions projects/cdk/directives/auto-focus/handlers/ios.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class TuiIosAutofocusHandler extends AbstractTuiAutofocusHandler {
focusable: TuiFocusableElementAccessor | null,
@Inject(ElementRef) el: ElementRef<HTMLElement>,
@Inject(Renderer2) private readonly renderer: Renderer2,
@Inject(NgZone) private readonly ngZone: NgZone,
@Inject(NgZone) private readonly zone: NgZone,
@Inject(WINDOW) private readonly win: Window,
) {
super(focusable, el);
Expand All @@ -45,7 +45,7 @@ export class TuiIosAutofocusHandler extends AbstractTuiAutofocusHandler {

setFocus(): void {
if (this.isTextFieldElement) {
this.ngZone.runOutsideAngular(() => this.iosWebkitAutofocus());
this.zone.runOutsideAngular(() => this.iosWebkitAutofocus());
} else {
this.element.focus();
}
Expand Down
4 changes: 2 additions & 2 deletions projects/cdk/directives/focused/focused.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class TuiFocusedDirective {
constructor(
@Inject(ElementRef)
{nativeElement}: ElementRef<HTMLElement>,
@Inject(NgZone) ngZone: NgZone,
@Inject(NgZone) zone: NgZone,
) {
this.tuiFocusedChange = merge(
tuiTypedFromEvent(nativeElement, 'focusin'),
Expand All @@ -29,7 +29,7 @@ export class TuiFocusedDirective {
startWith(false),
distinctUntilChanged(),
skip(1),
tuiZoneOptimized(ngZone),
tuiZoneOptimized(zone),
);
}
}
4 changes: 2 additions & 2 deletions projects/cdk/directives/hovered/hovered.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ export class TuiHoveredService extends Observable<boolean> {
filter(movedOut),
map(ALWAYS_FALSE_HANDLER),
),
).pipe(distinctUntilChanged(), tuiZoneOptimized(this.ngZone));
).pipe(distinctUntilChanged(), tuiZoneOptimized(this.zone));

constructor(
@Inject(ElementRef) private readonly el: ElementRef<Element>,
@Inject(NgZone) private readonly ngZone: NgZone,
@Inject(NgZone) private readonly zone: NgZone,
) {
super(subscriber => this.stream$.subscribe(subscriber));
}
Expand Down
6 changes: 3 additions & 3 deletions projects/cdk/directives/overscroll/overscroll.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ export class TuiOverscrollDirective {

constructor(
@Inject(ElementRef) {nativeElement}: ElementRef<HTMLElement>,
@Inject(NgZone) ngZone: NgZone,
@Inject(NgZone) zone: NgZone,
@Self() @Inject(TuiDestroyService) destroy$: Observable<void>,
) {
tuiTypedFromEvent(nativeElement, 'wheel', {passive: false})
.pipe(
filter(() => this.enabled),
tuiZonefree(ngZone),
tuiZonefree(zone),
takeUntil(destroy$),
)
.subscribe(event => {
Expand Down Expand Up @@ -77,7 +77,7 @@ export class TuiOverscrollDirective {
}),
);
}),
tuiZonefree(ngZone),
tuiZonefree(zone),
takeUntil(destroy$),
)
.subscribe();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ export class TuiPreventDefaultDirective implements OnInit {

constructor(
@Inject(ElementRef) private readonly el: ElementRef<HTMLElement>,
@Inject(NgZone) private readonly ngZone: NgZone,
@Inject(NgZone) private readonly zone: NgZone,
@Self() @Inject(TuiDestroyService) private readonly destroy$: Observable<void>,
) {}

ngOnInit(): void {
fromEvent(this.el.nativeElement, this.eventName, {passive: false})
.pipe(tuiZonefree(this.ngZone), tuiPreventDefault(), takeUntil(this.destroy$))
.pipe(tuiZonefree(this.zone), tuiPreventDefault(), takeUntil(this.destroy$))
.subscribe();
}
}
Loading