Skip to content

Commit

Permalink
chore: drop waResizeObserver
Browse files Browse the repository at this point in the history
  • Loading branch information
mdlufy committed Sep 16, 2024
1 parent 40943ea commit 9975242
Show file tree
Hide file tree
Showing 12 changed files with 32 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
import {toSignal} from '@angular/core/rxjs-interop';
import {FormsModule} from '@angular/forms';
import {MaskitoDirective} from '@maskito/angular';
import {WaResizeObserver} from '@ng-web-apis/resize-observer';
import {
TUI_MASK_CARD,
TUI_MASK_CVC,
Expand Down Expand Up @@ -85,7 +84,6 @@ export interface TuiCard {
TuiIconPipe,
TuiLet,
TuiMapperPipe,
WaResizeObserver,
],
templateUrl: './input-card-group.template.html',
styleUrls: ['./input-card-group.style.less'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
class="t-collapsed"
[attr.data-before]="masked"
[class.t-collapsed_enable-mask]="cardCollapsed"
(waResizeObserver)="onResize()"
(resize)="onResize()"
>
<span
#ghost
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ import {
Component,
inject,
} from '@angular/core';
import {WaResizeObserver} from '@ng-web-apis/resize-observer';

@Component({
standalone: true,
selector: 'tui-swipe-actions',
imports: [WaResizeObserver],
templateUrl: './swipe-actions.template.html',
styleUrls: ['./swipe-actions.style.less'],
changeDetection: ChangeDetectionStrategy.OnPush,
Expand All @@ -22,8 +20,14 @@ export class TuiSwipeActions {

protected readonly cdr = inject(ChangeDetectorRef);

protected onResize({target}: ResizeObserverEntry): void {
this.actionsWidth = target.clientWidth;
protected onResize(event: UIEvent): void {
const [entry] = event as unknown as ResizeObserverEntry[];

if (!entry) {
return;
}

this.actionsWidth = entry.target.clientWidth;
this.cdr.detectChanges();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<div
class="t-actions"
(waResizeObserver)="$event[0] && onResize($event[0])"
(resize)="onResize($event)"
>
<ng-content select="[tuiSwipeAction]" />
</div>
13 changes: 9 additions & 4 deletions projects/core/components/textfield/textfield.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
ViewEncapsulation,
} from '@angular/core';
import {NgControl} from '@angular/forms';
import {WaResizeObserver} from '@ng-web-apis/resize-observer';
import {tuiInjectId} from '@taiga-ui/cdk/services';
import type {TuiContext, TuiStringHandler} from '@taiga-ui/cdk/types';
import {tuiInjectElement} from '@taiga-ui/cdk/utils/dom';
Expand Down Expand Up @@ -42,7 +41,7 @@ import {TuiWithTextfieldDropdown} from './textfield-dropdown.directive';
@Component({
standalone: true,
selector: 'tui-textfield',
imports: [NgIf, PolymorpheusOutlet, TuiButton, WaResizeObserver],
imports: [NgIf, PolymorpheusOutlet, TuiButton],
templateUrl: './textfield.template.html',
styles: ['@import "@taiga-ui/core/styles/components/textfield.less";'],
encapsulation: ViewEncapsulation.None,
Expand Down Expand Up @@ -137,8 +136,14 @@ export class TuiTextfieldComponent<T> implements TuiDataListHost<T> {
return Boolean(this.label?.nativeElement?.childNodes.length);
}

protected onResize(entry: readonly ResizeObserverEntry[]): void {
this.side = entry[0]?.contentRect?.width || 0;
protected onResize(event: UIEvent): void {
const [entry] = event as unknown as ResizeObserverEntry[];

if (!entry) {
return;
}

this.side = entry?.contentRect?.width || 0;
this.cdr.detectChanges();
}
}
2 changes: 1 addition & 1 deletion projects/core/components/textfield/textfield.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<span
class="t-content"
(mousedown.prevent)="el?.nativeElement?.focus()"
(waResizeObserver)="onResize($event)"
(resize)="onResize($event)"
>
<ng-content />
<button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ import {
Component,
inject,
} from '@angular/core';
import {WaResizeObserver} from '@ng-web-apis/resize-observer';

import {TuiBadgedContentDirective} from './badged-content.directive';

@Component({
standalone: true,
selector: 'tui-badged-content',
imports: [TuiBadgedContentDirective, WaResizeObserver],
imports: [TuiBadgedContentDirective],
templateUrl: './badged-content.template.html',
styleUrls: ['./badged-content.style.less'],
changeDetection: ChangeDetectionStrategy.OnPush,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#badgeTop
class="t-badge t-badge_top"
[style.--t-badge-height.px]="badgeTop.offsetHeight"
(waResizeObserver)="onResize()"
(resize)="onResize()"
>
<ng-content select="tui-badge-notification[tuiSlot='top']" />
<div class="t-border">
Expand All @@ -16,7 +16,7 @@
#badgeBottom
class="t-badge t-badge_bottom"
[style.--t-badge-height.px]="badgeBottom.offsetHeight"
(waResizeObserver)="onResize()"
(resize)="onResize()"
>
<ng-content select="tui-badge-notification[tuiSlot='bottom']" />
<div class="t-border">
Expand Down
2 changes: 0 additions & 2 deletions projects/kit/components/line-clamp/line-clamp.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
signal,
ViewChild,
} from '@angular/core';
import {WaResizeObserver} from '@ng-web-apis/resize-observer';
import {TuiLet} from '@taiga-ui/cdk/directives/let';
import {tuiTypedFromEvent, tuiZonefree} from '@taiga-ui/cdk/observables';
import {tuiInjectElement, tuiIsCurrentTarget} from '@taiga-ui/cdk/utils/dom';
Expand Down Expand Up @@ -53,7 +52,6 @@ import {TuiLineClampPositionDirective} from './line-clamp-position.directive';
TuiHint,
TuiLet,
TuiLineClampPositionDirective,
WaResizeObserver,
],
templateUrl: './line-clamp.template.html',
styleUrls: ['./line-clamp.style.less'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[style.word-break]="(lineClamp || 0) > 1 ? 'break-word' : 'break-all'"
[tuiHint]="computedContent"
(mouseenter)="updateView()"
(waResizeObserver)="updateView()"
(resize)="updateView()"
>
<ng-container *polymorpheusOutlet="content as text">
{{ text }}
Expand Down
10 changes: 7 additions & 3 deletions projects/kit/components/preview/preview.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
Input,
} from '@angular/core';
import {WaMutationObserver} from '@ng-web-apis/mutation-observer';
import {WaResizeObserver} from '@ng-web-apis/resize-observer';
import {TUI_FALSE_HANDLER} from '@taiga-ui/cdk/constants';
import {TuiPan} from '@taiga-ui/cdk/directives/pan';
import type {TuiZoomEvent} from '@taiga-ui/cdk/directives/zoom';
Expand Down Expand Up @@ -42,7 +41,6 @@ const ROTATION_ANGLE = 90;
TuiPreviewZoom,
TuiZoom,
WaMutationObserver,
WaResizeObserver,
],
templateUrl: './preview.template.html',
styleUrls: ['./preview.style.less'],
Expand Down Expand Up @@ -119,7 +117,13 @@ export class TuiPreviewComponent {
}
}

protected onResize([entry]: readonly ResizeObserverEntry[]): void {
protected onResize(event: UIEvent): void {
const [entry] = event as unknown as ResizeObserverEntry[];

if (!entry) {
return;
}

if (entry?.contentRect) {
this.refresh(entry.contentRect.width, entry.contentRect.height);
this.cdr.detectChanges();
Expand Down
2 changes: 1 addition & 1 deletion projects/kit/components/preview/preview.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
[class.t-transitive]="transitioned$ | async"
[style.cursor]="cursor$ | async"
[style.transform]="wrapperTransform$ | async"
(resize)="onResize($event)"
(tuiPan)="onPan($event)"
(tuiZoom)="onZoom($event)"
(waMutationObserver)="onMutation(contentWrapper)"
(waResizeObserver)="onResize($event)"
>
<ng-content />
</section>
Expand Down

0 comments on commit 9975242

Please sign in to comment.