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

[WIP] chore: drop waResizeObserver #9049

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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 @@ -13,7 +13,6 @@ import {
import {takeUntilDestroyed, 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 @@ -87,7 +86,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>
17 changes: 13 additions & 4 deletions projects/core/components/textfield/textfield.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {NgIf} from '@angular/common';
import {
ChangeDetectionStrategy,
ChangeDetectorRef,
Component,
computed,
ContentChild,
Expand All @@ -15,7 +16,6 @@ import {
} from '@angular/core';
import {toSignal} from '@angular/core/rxjs-interop';
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 @@ -44,7 +44,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 @@ -81,6 +81,8 @@ export class TuiTextfieldComponent<T> implements TuiDataListHost<T> {
@ContentChild(NgControl)
protected readonly control?: NgControl;

protected readonly cdr = inject(ChangeDetectorRef);

protected readonly icons = inject(TUI_COMMON_ICONS);
protected readonly clear = toSignal(inject(TUI_CLEAR_WORD));

Expand Down Expand Up @@ -138,7 +140,14 @@ export class TuiTextfieldComponent<T> implements TuiDataListHost<T> {
return Boolean(this.label?.nativeElement?.childNodes.length);
}

protected onResize({contentRect}: ResizeObserverEntry): void {
this.el.style.setProperty('--t-side', tuiPx(contentRect.width));
protected onResize(event: UIEvent): void {
const [entry] = event as unknown as ResizeObserverEntry[];

if (!entry) {
return;
}

this.el.style.setProperty('--t-side', tuiPx(entry.contentRect.width));
this.cdr.detectChanges();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<span
class="t-content"
(mousedown.prevent)="input?.nativeElement?.focus()"
(waResizeObserver)="$event[0] && onResize($event[0])"
(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
6 changes: 2 additions & 4 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 {
ViewChild,
} from '@angular/core';
import {takeUntilDestroyed, toSignal} from '@angular/core/rxjs-interop';
import {WaResizeObserver} from '@ng-web-apis/resize-observer';
import {tuiTypedFromEvent, tuiZonefree} from '@taiga-ui/cdk/observables';
import {tuiInjectElement, tuiIsCurrentTarget} from '@taiga-ui/cdk/utils/dom';
import {
Expand Down Expand Up @@ -50,7 +49,6 @@ import {TuiLineClampPositionDirective} from './line-clamp-position.directive';
PolymorpheusTemplate,
TuiHint,
TuiLineClampPositionDirective,
WaResizeObserver,
],
templateUrl: './line-clamp.template.html',
styleUrls: ['./line-clamp.style.less'],
Expand All @@ -76,7 +74,7 @@ export class TuiLineClamp implements DoCheck, AfterViewInit {

private readonly options = inject(TUI_LINE_CLAMP_OPTIONS);
private readonly el = tuiInjectElement();
private readonly cd = inject(ChangeDetectorRef);
private readonly cdr = inject(ChangeDetectorRef);
private readonly zone: NgZone = inject(NgZone);
private readonly linesLimit$ = new BehaviorSubject(1);
private readonly isOverflown$ = new Subject<boolean>();
Expand Down Expand Up @@ -146,7 +144,7 @@ export class TuiLineClamp implements DoCheck, AfterViewInit {
}

protected updateView(): void {
this.cd.detectChanges();
this.cdr.detectChanges();
}

private update(): void {
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
Loading