Skip to content

Commit

Permalink
refactor!: remove some deprecations (#2272)
Browse files Browse the repository at this point in the history
* refactor!: remove some deprecations

* chore: fix build
  • Loading branch information
nsbarsukov authored and splincode committed Aug 23, 2022
1 parent 82c670b commit 1379522
Show file tree
Hide file tree
Showing 59 changed files with 277 additions and 345 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
ViewChildren,
} from '@angular/core';
import {DomSanitizer, SafeValue} from '@angular/platform-browser';
import {tuiDefaultProp, typedFromEvent} from '@taiga-ui/cdk';
import {tuiDefaultProp, tuiTypedFromEvent} from '@taiga-ui/cdk';
import {TuiSizeXL} from '@taiga-ui/core';
import {merge, Observable, ReplaySubject} from 'rxjs';
import {mapTo, startWith, switchMap, tap} from 'rxjs/operators';
Expand Down Expand Up @@ -145,8 +145,8 @@ function arcsToIndex(arcs: QueryList<ElementRef<SVGElement>>): Array<Observable<
.toArray()
.map(({nativeElement}, index) =>
merge(
typedFromEvent(nativeElement, `mouseenter`).pipe(mapTo(index)),
typedFromEvent(nativeElement, `mouseleave`).pipe(mapTo(NaN)),
tuiTypedFromEvent(nativeElement, `mouseenter`).pipe(mapTo(index)),
tuiTypedFromEvent(nativeElement, `mouseleave`).pipe(mapTo(NaN)),
),
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
TUI_CARD_EXPIRY_TEXTS,
TUI_CARD_NUMBER_TEXTS,
} from '@taiga-ui/addon-commerce/tokens';
import {typedFromEvent} from '@taiga-ui/cdk';
import {tuiTypedFromEvent} from '@taiga-ui/cdk';
import {TuiMedia} from '@taiga-ui/core/interfaces';
import {TUI_MEDIA} from '@taiga-ui/core/tokens';
import {combineLatest, Observable, of} from 'rxjs';
Expand Down Expand Up @@ -42,7 +42,7 @@ export function inputGroupedTextsFactory(
`screen and (min-width: ${(desktopSmall - 1) / 16}em)`,
);

return typedFromEvent(media, `change`).pipe(
return tuiTypedFromEvent(media, `change`).pipe(
startWith(null),
switchMap(() =>
combineLatest([
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {DOCUMENT} from '@angular/common';
import {ChangeDetectionStrategy, Component, Inject, InjectionToken} from '@angular/core';
import {TuiNodeViewNgComponent} from '@taiga-ui/addon-editor/extensions/tiptap-node-view';
import {TuiDestroyService, typedFromEvent} from '@taiga-ui/cdk';
import {TuiDestroyService, tuiTypedFromEvent} from '@taiga-ui/cdk';
import {merge} from 'rxjs';
import {takeUntil} from 'rxjs/operators';

Expand Down Expand Up @@ -52,8 +52,8 @@ export class TuiImageEditorComponent extends TuiNodeViewNgComponent {
super();

merge(
typedFromEvent(this.documentRef, `touchend`),
typedFromEvent(this.documentRef, `mouseup`),
tuiTypedFromEvent(this.documentRef, `touchend`),
tuiTypedFromEvent(this.documentRef, `mouseup`),
)
.pipe(takeUntil(destroy$))
.subscribe(() => this.updateAttributes({width: this.width}));
Expand Down
8 changes: 4 additions & 4 deletions projects/addon-editor/services/picker.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {DOCUMENT} from '@angular/common';
import {ElementRef, Inject, Injectable} from '@angular/core';
import {tuiGetElementPoint} from '@taiga-ui/addon-editor/utils';
import {TuiDestroyService, tuiPreventDefault, typedFromEvent} from '@taiga-ui/cdk';
import {TuiDestroyService, tuiPreventDefault, tuiTypedFromEvent} from '@taiga-ui/cdk';
import {TuiPoint} from '@taiga-ui/core';
import {Observable} from 'rxjs';
import {map, startWith, switchMap, takeUntil} from 'rxjs/operators';
Expand All @@ -13,14 +13,14 @@ export class TuiPickerService extends Observable<TuiPoint> {
@Inject(ElementRef) {nativeElement}: ElementRef<HTMLElement>,
@Inject(DOCUMENT) documentRef: Document,
) {
const point$ = typedFromEvent(nativeElement, `mousedown`).pipe(
const point$ = tuiTypedFromEvent(nativeElement, `mousedown`).pipe(
tuiPreventDefault(),
switchMap(event => {
const mouseMove$ = typedFromEvent(documentRef, `mousemove`).pipe(
const mouseMove$ = tuiTypedFromEvent(documentRef, `mousemove`).pipe(
map(({clientX, clientY}) =>
tuiGetElementPoint(clientX, clientY, nativeElement),
),
takeUntil(typedFromEvent(documentRef, `mouseup`)),
takeUntil(tuiTypedFromEvent(documentRef, `mouseup`)),
);

return event.target === nativeElement
Expand Down
4 changes: 2 additions & 2 deletions projects/addon-editor/tokens/image-loader.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {InjectionToken} from '@angular/core';
import {TuiHandler, typedFromEvent} from '@taiga-ui/cdk';
import {TuiHandler, tuiTypedFromEvent} from '@taiga-ui/cdk';
import {Observable} from 'rxjs';
import {map} from 'rxjs/operators';

Expand All @@ -10,7 +10,7 @@ export const TUI_IMAGE_LOADER: InjectionToken<TuiHandler<File, Observable<string

fileReader.readAsDataURL(file);

return typedFromEvent(fileReader, `load`).pipe(
return tuiTypedFromEvent(fileReader, `load`).pipe(
map(() => String(fileReader.result)),
);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
TuiDestroyService,
TuiMapper,
TuiMonth,
typedFromEvent,
tuiTypedFromEvent,
} from '@taiga-ui/cdk';
import {TUI_CLOSE_WORD, TUI_ORDERED_SHORT_WEEK_DAYS} from '@taiga-ui/core';
import {
Expand Down Expand Up @@ -285,15 +285,18 @@ export class TuiMobileCalendarComponent {
return;
}

const touchstart$ = typedFromEvent(
const touchstart$ = tuiTypedFromEvent(
yearsScrollRef.elementRef.nativeElement,
`touchstart`,
);
const touchend$ = typedFromEvent(
const touchend$ = tuiTypedFromEvent(
yearsScrollRef.elementRef.nativeElement,
`touchend`,
);
const click$ = typedFromEvent(yearsScrollRef.elementRef.nativeElement, `click`);
const click$ = tuiTypedFromEvent(
yearsScrollRef.elementRef.nativeElement,
`click`,
);

// Refresh activeYear
yearsScrollRef
Expand Down Expand Up @@ -349,12 +352,12 @@ export class TuiMobileCalendarComponent {
return;
}

const touchstart$ = typedFromEvent(
const touchstart$ = tuiTypedFromEvent(
monthsScrollRef.elementRef.nativeElement,
`touchstart`,
{passive: true},
);
const touchend$ = typedFromEvent(
const touchend$ = tuiTypedFromEvent(
monthsScrollRef.elementRef.nativeElement,
`touchend`,
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {ElementRef, InjectionToken, Provider} from '@angular/core';
import {TUI_LOADED} from '@taiga-ui/addon-mobile/tokens';
import {TUI_IS_IOS, typedFromEvent} from '@taiga-ui/cdk';
import {TUI_IS_IOS, tuiTypedFromEvent} from '@taiga-ui/cdk';
import {merge, Observable} from 'rxjs';
import {endWith, filter, map, mapTo, scan, switchMap, takeUntil} from 'rxjs/operators';

Expand All @@ -26,15 +26,15 @@ export function pullingFactory(
{nativeElement}: ElementRef<HTMLElement>,
): Observable<number> {
return merge(
typedFromEvent(nativeElement, `touchstart`, {passive: true}).pipe(
tuiTypedFromEvent(nativeElement, `touchstart`, {passive: true}).pipe(
filter(() => nativeElement.scrollTop === 0),
switchMap(touchStart =>
typedFromEvent(nativeElement, `touchmove`).pipe(
tuiTypedFromEvent(nativeElement, `touchmove`).pipe(
map(
touchMove =>
touchMove.touches[0].clientY - touchStart.touches[0].clientY,
),
takeUntil(typedFromEvent(nativeElement, `touchend`)),
takeUntil(tuiTypedFromEvent(nativeElement, `touchend`)),
endWith(0),
),
),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {DOCUMENT} from '@angular/common';
import {ElementRef, forwardRef, NgZone, Provider} from '@angular/core';
import {TUI_IS_IOS, tuiZonefree, typedFromEvent} from '@taiga-ui/cdk';
import {TUI_IS_IOS, tuiTypedFromEvent, tuiZonefree} from '@taiga-ui/cdk';
import {TUI_SCROLL_REF} from '@taiga-ui/core';
import {merge, Observable} from 'rxjs';
import {map, mapTo, share} from 'rxjs/operators';
Expand Down Expand Up @@ -35,8 +35,8 @@ export function sheetDraggedFactory({
nativeElement,
}: ElementRef<HTMLElement>): Observable<boolean> {
return merge(
typedFromEvent(nativeElement, `touchstart`, {passive: true}).pipe(mapTo(true)),
typedFromEvent(nativeElement, `touchend`).pipe(mapTo(false)),
tuiTypedFromEvent(nativeElement, `touchstart`, {passive: true}).pipe(mapTo(true)),
tuiTypedFromEvent(nativeElement, `touchend`).pipe(mapTo(false)),
);
}

Expand All @@ -50,8 +50,8 @@ export function sheetScrollFactory(
return isIos
? iosScrollFactory(nativeElement, documentRef, ngZone)
: merge(
typedFromEvent(nativeElement, `scroll`),
typedFromEvent(nativeElement, `load`, {capture: true}),
tuiTypedFromEvent(nativeElement, `scroll`),
tuiTypedFromEvent(nativeElement, `load`, {capture: true}),
).pipe(
map(() => nativeElement.scrollTop),
tuiZonefree(ngZone),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Directive, ElementRef, Inject, NgZone, Output} from '@angular/core';
import {WINDOW} from '@ng-web-apis/common';
import {tuiZonefull, typedFromEvent} from '@taiga-ui/cdk';
import {tuiTypedFromEvent, tuiZonefull} from '@taiga-ui/cdk';
import {EMPTY, merge, Observable} from 'rxjs';
import {distinctUntilChanged, filter, startWith, switchMap} from 'rxjs/operators';

Expand All @@ -14,7 +14,7 @@ import {TUI_SHEET_DRAGGED, TUI_SHEET_SCROLL} from '../../sheet-tokens';
export class TuiSheetCloseDirective {
@Output()
readonly close: Observable<unknown> = merge(
typedFromEvent(this.elementRef.nativeElement, TUI_SHEET_CLOSE),
tuiTypedFromEvent(this.elementRef.nativeElement, TUI_SHEET_CLOSE),
this.dragged$.pipe(
startWith(false),
switchMap(dragged =>
Expand Down
14 changes: 8 additions & 6 deletions projects/addon-mobile/components/sheet/ios.hacks.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {NgZone} from '@angular/core';
import {tuiZonefree, typedFromEvent} from '@taiga-ui/cdk';
import {tuiTypedFromEvent, tuiZonefree} from '@taiga-ui/cdk';
import {concat, merge, Observable, race, timer, zip} from 'rxjs';
import {
debounceTime,
Expand All @@ -21,11 +21,13 @@ export function iosScrollFactory(
documentRef: Document,
ngZone: NgZone,
): Observable<number> {
const load$ = typedFromEvent(element, `load`, {capture: true});
const touchstart$ = typedFromEvent(element, `touchstart`, {passive: true});
const touchmove$ = typedFromEvent(documentRef, `touchmove`, {passive: true});
const touchend$ = typedFromEvent(documentRef, `touchend`);
const scroll$ = typedFromEvent(element, `scroll`).pipe(map(() => element.scrollTop));
const load$ = tuiTypedFromEvent(element, `load`, {capture: true});
const touchstart$ = tuiTypedFromEvent(element, `touchstart`, {passive: true});
const touchmove$ = tuiTypedFromEvent(documentRef, `touchmove`, {passive: true});
const touchend$ = tuiTypedFromEvent(documentRef, `touchend`);
const scroll$ = tuiTypedFromEvent(element, `scroll`).pipe(
map(() => element.scrollTop),
);
const result$ = merge(
load$.pipe(
delay(0),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import {WINDOW} from '@ng-web-apis/common';
import {
TuiDestroyService,
tuiGetElementOffset,
tuiTypedFromEvent,
tuiZoneOptimized,
typedFromEvent,
} from '@taiga-ui/cdk';
import {SCROLL_REF_SELECTOR, TUI_SCROLL_REF} from '@taiga-ui/core';
import {Observable} from 'rxjs';
Expand Down Expand Up @@ -42,7 +42,7 @@ export class TuiElasticStickyService extends Observable<number> {
nativeElement,
);

return typedFromEvent(host || windowRef, `scroll`).pipe(
return tuiTypedFromEvent(host || windowRef, `scroll`).pipe(
map(() =>
Math.max(
1 -
Expand Down
8 changes: 4 additions & 4 deletions projects/addon-mobile/directives/ripple/ripple.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {Directive, ElementRef, Inject, Input, Renderer2} from '@angular/core';
import {
TuiDestroyService,
TuiDirectiveStylesService,
typedFromEvent,
tuiTypedFromEvent,
} from '@taiga-ui/cdk';
import {Observable, race, timer} from 'rxjs';
import {
Expand Down Expand Up @@ -43,16 +43,16 @@ export class TuiRippleDirective {
) {
directiveStyles.addComponent(TuiRippleStylesComponent);

const touchEnd$ = typedFromEvent(nativeElement, `touchend`);
const touchMove$ = typedFromEvent(nativeElement, `touchmove`);
const touchEnd$ = tuiTypedFromEvent(nativeElement, `touchend`);
const touchMove$ = tuiTypedFromEvent(nativeElement, `touchmove`);

end$.subscribe(element => {
renderer.removeChild(nativeElement, element);
});
start$
.pipe(
mergeMap(ripple => {
const animationEndOn$ = typedFromEvent(ripple, `animationend`);
const animationEndOn$ = tuiTypedFromEvent(ripple, `animationend`);

return race(
timer(TOUCH_MOVE_DELAY).pipe(mapTo(false)),
Expand Down
6 changes: 3 additions & 3 deletions projects/addon-mobile/directives/ripple/ripple.providers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
TUI_TOUCH_SUPPORTED,
TuiDestroyService,
tuiIsPresent,
typedFromEvent,
tuiTypedFromEvent,
} from '@taiga-ui/cdk';
import {EMPTY, Observable} from 'rxjs';
import {filter, map, takeUntil} from 'rxjs/operators';
Expand Down Expand Up @@ -40,7 +40,7 @@ export function rippleStartFactory(
): Observable<HTMLElement> {
return isIOS || !touchSupported
? EMPTY
: typedFromEvent(nativeElement, `touchstart`).pipe(
: tuiTypedFromEvent(nativeElement, `touchstart`).pipe(
map(({touches}) => {
const {clientX, clientY} = touches[touches.length - 1];
const {width, height, top, left} =
Expand Down Expand Up @@ -78,7 +78,7 @@ export function rippleEndFactory(
): Observable<EventTarget> {
return isIOS || !touchSupported
? EMPTY
: typedFromEvent(nativeElement, `animationend`).pipe(
: tuiTypedFromEvent(nativeElement, `animationend`).pipe(
filter(({animationName}) => animationName === RIPPLE_OFF),
map(({target}) => target),
filter(tuiIsPresent),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
TUI_IS_IOS,
tuiDefaultProp,
TuiDestroyService,
typedFromEvent,
tuiTypedFromEvent,
} from '@taiga-ui/cdk';
import {TUI_ELEMENT_REF} from '@taiga-ui/core';
import {race} from 'rxjs';
Expand Down Expand Up @@ -39,20 +39,20 @@ export class TuiTouchableDirective {

const element = elementRef ? elementRef.nativeElement : nativeElement;

typedFromEvent(element, `touchstart`, {passive: true})
tuiTypedFromEvent(element, `touchstart`, {passive: true})
.pipe(
tap(() => {
this.onTouchStart(renderer, element);
}),
map(({touches}) => touches[touches.length - 1].identifier),
switchMap(identifier =>
race(
typedFromEvent(element, `touchmove`, {passive: true}).pipe(
tuiTypedFromEvent(element, `touchmove`, {passive: true}).pipe(
filter(({touches}) =>
this.hasTouchLeft(element, touches, identifier),
),
),
typedFromEvent(element, `touchend`),
tuiTypedFromEvent(element, `touchend`),
).pipe(take(1)),
),
takeUntil(destroy$),
Expand Down
10 changes: 5 additions & 5 deletions projects/addon-preview/components/preview/preview.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import {
TuiDragStage,
tuiPx,
tuiRound,
tuiTypedFromEvent,
TuiZoom,
typedFromEvent,
} from '@taiga-ui/cdk';
import {tuiSlideInTop} from '@taiga-ui/core';
import {TuiLanguagePreview} from '@taiga-ui/i18n';
Expand Down Expand Up @@ -58,10 +58,10 @@ export class TuiPreviewComponent {
tuiDragAndDropFrom(this.elementRef.nativeElement).pipe(
map(({stage}) => stage !== TuiDragStage.Continues),
),
typedFromEvent(this.elementRef.nativeElement, `touchmove`, {passive: true}).pipe(
mapTo(false),
),
typedFromEvent(this.elementRef.nativeElement, `wheel`, {passive: true}).pipe(
tuiTypedFromEvent(this.elementRef.nativeElement, `touchmove`, {
passive: true,
}).pipe(mapTo(false)),
tuiTypedFromEvent(this.elementRef.nativeElement, `wheel`, {passive: true}).pipe(
mapTo(false),
),
);
Expand Down
Loading

0 comments on commit 1379522

Please sign in to comment.