@arsedizioni/ars-utils 22.0.1 → 22.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -27,7 +27,7 @@ import { FlexModule } from '@ngbracket/ngx-layout/flex';
|
|
|
27
27
|
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
28
28
|
import * as i9 from '@angular/material/tree';
|
|
29
29
|
import { MatTree, MatTreeModule } from '@angular/material/tree';
|
|
30
|
-
import { BehaviorSubject, Subject,
|
|
30
|
+
import { BehaviorSubject, Subject, auditTime, animationFrameScheduler } from 'rxjs';
|
|
31
31
|
import { FlexLayoutModule } from '@ngbracket/ngx-layout';
|
|
32
32
|
import * as i2 from '@ngbracket/ngx-layout/extended';
|
|
33
33
|
import { MatOptionModule } from '@angular/material/core';
|
|
@@ -2057,6 +2057,8 @@ class ChipsSelectorComponent {
|
|
|
2057
2057
|
this.stateChanges = new Subject();
|
|
2058
2058
|
this.destroyRef = inject(DestroyRef);
|
|
2059
2059
|
this.changesEnabled = false;
|
|
2060
|
+
/** Debounce bridge for `ResizeObserver` notifications. */
|
|
2061
|
+
this.resize$ = new Subject();
|
|
2060
2062
|
/** List of available options to display as chips. */
|
|
2061
2063
|
this.options = input([], /* @ts-ignore */
|
|
2062
2064
|
...(ngDevMode ? [{ debugName: "options" }] : /* istanbul ignore next */ []));
|
|
@@ -2120,15 +2122,25 @@ class ChipsSelectorComponent {
|
|
|
2120
2122
|
this.placeholder();
|
|
2121
2123
|
this.stateChanges.next();
|
|
2122
2124
|
});
|
|
2125
|
+
// React to container size changes to keep the collapsed state up to date.
|
|
2126
|
+
// `auditTime` on the animation-frame scheduler coalesces ResizeObserver bursts
|
|
2127
|
+
// without adding perceptible latency, and defers the layout read out of the
|
|
2128
|
+
// observer callback to avoid "ResizeObserver loop" warnings.
|
|
2129
|
+
this.resize$
|
|
2130
|
+
.pipe(takeUntilDestroyed(this.destroyRef), auditTime(0, animationFrameScheduler))
|
|
2131
|
+
.subscribe(() => {
|
|
2132
|
+
if (this.collapseAt() > 0) {
|
|
2133
|
+
this.updateContainerWidth();
|
|
2134
|
+
}
|
|
2135
|
+
});
|
|
2123
2136
|
afterNextRender(() => {
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
this.updateContainerWidth();
|
|
2137
|
+
if (SystemUtils.isBrowser() && typeof ResizeObserver !== 'undefined') {
|
|
2138
|
+
const elem = document.getElementById(this.containerId);
|
|
2139
|
+
if (elem) {
|
|
2140
|
+
this.resizeObserver = new ResizeObserver(() => this.resize$.next());
|
|
2141
|
+
this.resizeObserver.observe(elem);
|
|
2130
2142
|
}
|
|
2131
|
-
}
|
|
2143
|
+
}
|
|
2132
2144
|
setTimeout(() => {
|
|
2133
2145
|
this.updateContainerWidth();
|
|
2134
2146
|
this.changesEnabled = true;
|
|
@@ -2136,6 +2148,7 @@ class ChipsSelectorComponent {
|
|
|
2136
2148
|
});
|
|
2137
2149
|
}
|
|
2138
2150
|
ngOnDestroy() {
|
|
2151
|
+
this.resizeObserver?.disconnect();
|
|
2139
2152
|
this.stateChanges.complete();
|
|
2140
2153
|
}
|
|
2141
2154
|
/**
|