Skip to content

Commit 97c95e6

Browse files
committed
refactor(cdk/scrolling): switch directives to standalone (#26236)
Switches all of the scrolling directives to standalone so they can be used as host directives. Fixes #26219. (cherry picked from commit 49749fd)
1 parent 67db1a6 commit 97c95e6

8 files changed

+21
-14
lines changed

src/cdk/scrolling/fixed-size-virtual-scroll.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ export function _fixedSizeVirtualScrollStrategyFactory(fixedSizeDir: CdkFixedSiz
192192
/** A virtual scroll strategy that supports fixed-size items. */
193193
@Directive({
194194
selector: 'cdk-virtual-scroll-viewport[itemSize]',
195+
standalone: true,
195196
providers: [
196197
{
197198
provide: VIRTUAL_SCROLL_STRATEGY,

src/cdk/scrolling/scrollable.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export type ExtendedScrollToOptions = _XAxis & _YAxis & ScrollOptions;
4343
*/
4444
@Directive({
4545
selector: '[cdk-scrollable], [cdkScrollable]',
46+
standalone: true,
4647
})
4748
export class CdkScrollable implements OnInit, OnDestroy {
4849
protected readonly _destroyed = new Subject<void>();

src/cdk/scrolling/scrolling-module.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,26 @@ import {CdkVirtualScrollableWindow} from './virtual-scrollable-window';
1717

1818
@NgModule({
1919
exports: [CdkScrollable],
20-
declarations: [CdkScrollable],
20+
imports: [CdkScrollable],
2121
})
2222
export class CdkScrollableModule {}
2323

2424
/**
2525
* @docs-primary-export
2626
*/
2727
@NgModule({
28-
imports: [BidiModule, CdkScrollableModule],
29-
exports: [
28+
imports: [
3029
BidiModule,
3130
CdkScrollableModule,
31+
CdkVirtualScrollViewport,
3232
CdkFixedSizeVirtualScroll,
3333
CdkVirtualForOf,
34-
CdkVirtualScrollViewport,
3534
CdkVirtualScrollableWindow,
3635
CdkVirtualScrollableElement,
3736
],
38-
declarations: [
37+
exports: [
38+
BidiModule,
39+
CdkScrollableModule,
3940
CdkFixedSizeVirtualScroll,
4041
CdkVirtualForOf,
4142
CdkVirtualScrollViewport,

src/cdk/scrolling/virtual-for-of.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ function getOffset(orientation: 'horizontal' | 'vertical', direction: 'start' |
8282
@Directive({
8383
selector: '[cdkVirtualFor][cdkVirtualForOf]',
8484
providers: [{provide: _VIEW_REPEATER_STRATEGY, useClass: _RecycleViewRepeaterStrategy}],
85+
standalone: true,
8586
})
8687
export class CdkVirtualForOf<T>
8788
implements CdkVirtualScrollRepeater<T>, CollectionViewer, DoCheck, OnDestroy

src/cdk/scrolling/virtual-scroll-viewport.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ const SCROLL_SCHEDULER =
6767
},
6868
encapsulation: ViewEncapsulation.None,
6969
changeDetection: ChangeDetectionStrategy.OnPush,
70+
standalone: true,
7071
providers: [
7172
{
7273
provide: CdkScrollable,

src/cdk/scrolling/virtual-scrollable-element.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {CdkVirtualScrollable, VIRTUAL_SCROLLABLE} from './virtual-scrollable';
1717
@Directive({
1818
selector: '[cdkVirtualScrollingElement]',
1919
providers: [{provide: VIRTUAL_SCROLLABLE, useExisting: CdkVirtualScrollableElement}],
20+
standalone: true,
2021
host: {
2122
'class': 'cdk-virtual-scrollable',
2223
},

src/cdk/scrolling/virtual-scrollable-window.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {CdkVirtualScrollable, VIRTUAL_SCROLLABLE} from './virtual-scrollable';
1919
@Directive({
2020
selector: 'cdk-virtual-scroll-viewport[scrollWindow]',
2121
providers: [{provide: VIRTUAL_SCROLLABLE, useExisting: CdkVirtualScrollableWindow}],
22+
standalone: true,
2223
})
2324
export class CdkVirtualScrollableWindow extends CdkVirtualScrollable {
2425
protected override _elementScrolled: Observable<Event> = new Observable(

tools/public_api_guard/cdk/scrolling.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { Directionality } from '@angular/cdk/bidi';
1212
import { DoCheck } from '@angular/core';
1313
import { ElementRef } from '@angular/core';
1414
import * as i0 from '@angular/core';
15-
import * as i7 from '@angular/cdk/bidi';
15+
import * as i2 from '@angular/cdk/bidi';
1616
import { InjectionToken } from '@angular/core';
1717
import { IterableDiffers } from '@angular/core';
1818
import { ListRange } from '@angular/cdk/collections';
@@ -54,7 +54,7 @@ export class CdkFixedSizeVirtualScroll implements OnChanges {
5454
ngOnChanges(): void;
5555
_scrollStrategy: FixedSizeVirtualScrollStrategy;
5656
// (undocumented)
57-
static ɵdir: i0.ɵɵDirectiveDeclaration<CdkFixedSizeVirtualScroll, "cdk-virtual-scroll-viewport[itemSize]", never, { "itemSize": "itemSize"; "minBufferPx": "minBufferPx"; "maxBufferPx": "maxBufferPx"; }, {}, never, never, false, never>;
57+
static ɵdir: i0.ɵɵDirectiveDeclaration<CdkFixedSizeVirtualScroll, "cdk-virtual-scroll-viewport[itemSize]", never, { "itemSize": "itemSize"; "minBufferPx": "minBufferPx"; "maxBufferPx": "maxBufferPx"; }, {}, never, never, true, never>;
5858
// (undocumented)
5959
static ɵfac: i0.ɵɵFactoryDeclaration<CdkFixedSizeVirtualScroll, never>;
6060
}
@@ -83,7 +83,7 @@ export class CdkScrollable implements OnInit, OnDestroy {
8383
protected scrollDispatcher: ScrollDispatcher;
8484
scrollTo(options: ExtendedScrollToOptions): void;
8585
// (undocumented)
86-
static ɵdir: i0.ɵɵDirectiveDeclaration<CdkScrollable, "[cdk-scrollable], [cdkScrollable]", never, {}, {}, never, never, false, never>;
86+
static ɵdir: i0.ɵɵDirectiveDeclaration<CdkScrollable, "[cdk-scrollable], [cdkScrollable]", never, {}, {}, never, never, true, never>;
8787
// (undocumented)
8888
static ɵfac: i0.ɵɵFactoryDeclaration<CdkScrollable, [null, null, null, { optional: true; }]>;
8989
}
@@ -95,7 +95,7 @@ export class CdkScrollableModule {
9595
// (undocumented)
9696
static ɵinj: i0.ɵɵInjectorDeclaration<CdkScrollableModule>;
9797
// (undocumented)
98-
static ɵmod: i0.ɵɵNgModuleDeclaration<CdkScrollableModule, [typeof i1.CdkScrollable], never, [typeof i1.CdkScrollable]>;
98+
static ɵmod: i0.ɵɵNgModuleDeclaration<CdkScrollableModule, never, [typeof i1.CdkScrollable], [typeof i1.CdkScrollable]>;
9999
}
100100

101101
// @public
@@ -123,7 +123,7 @@ export class CdkVirtualForOf<T> implements CdkVirtualScrollRepeater<T>, Collecti
123123
ngOnDestroy(): void;
124124
readonly viewChange: Subject<ListRange>;
125125
// (undocumented)
126-
static ɵdir: i0.ɵɵDirectiveDeclaration<CdkVirtualForOf<any>, "[cdkVirtualFor][cdkVirtualForOf]", never, { "cdkVirtualForOf": "cdkVirtualForOf"; "cdkVirtualForTrackBy": "cdkVirtualForTrackBy"; "cdkVirtualForTemplate": "cdkVirtualForTemplate"; "cdkVirtualForTemplateCacheSize": "cdkVirtualForTemplateCacheSize"; }, {}, never, never, false, never>;
126+
static ɵdir: i0.ɵɵDirectiveDeclaration<CdkVirtualForOf<any>, "[cdkVirtualFor][cdkVirtualForOf]", never, { "cdkVirtualForOf": "cdkVirtualForOf"; "cdkVirtualForTrackBy": "cdkVirtualForTrackBy"; "cdkVirtualForTemplate": "cdkVirtualForTemplate"; "cdkVirtualForTemplateCacheSize": "cdkVirtualForTemplateCacheSize"; }, {}, never, never, true, never>;
127127
// (undocumented)
128128
static ɵfac: i0.ɵɵFactoryDeclaration<CdkVirtualForOf<any>, [null, null, null, null, { skipSelf: true; }, null]>;
129129
}
@@ -157,7 +157,7 @@ export class CdkVirtualScrollableElement extends CdkVirtualScrollable {
157157
// (undocumented)
158158
measureBoundingClientRectWithScrollOffset(from: 'left' | 'top' | 'right' | 'bottom'): number;
159159
// (undocumented)
160-
static ɵdir: i0.ɵɵDirectiveDeclaration<CdkVirtualScrollableElement, "[cdkVirtualScrollingElement]", never, {}, {}, never, never, false, never>;
160+
static ɵdir: i0.ɵɵDirectiveDeclaration<CdkVirtualScrollableElement, "[cdkVirtualScrollingElement]", never, {}, {}, never, never, true, never>;
161161
// (undocumented)
162162
static ɵfac: i0.ɵɵFactoryDeclaration<CdkVirtualScrollableElement, [null, null, null, { optional: true; }]>;
163163
}
@@ -170,7 +170,7 @@ export class CdkVirtualScrollableWindow extends CdkVirtualScrollable {
170170
// (undocumented)
171171
measureBoundingClientRectWithScrollOffset(from: 'left' | 'top' | 'right' | 'bottom'): number;
172172
// (undocumented)
173-
static ɵdir: i0.ɵɵDirectiveDeclaration<CdkVirtualScrollableWindow, "cdk-virtual-scroll-viewport[scrollWindow]", never, {}, {}, never, never, false, never>;
173+
static ɵdir: i0.ɵɵDirectiveDeclaration<CdkVirtualScrollableWindow, "cdk-virtual-scroll-viewport[scrollWindow]", never, {}, {}, never, never, true, never>;
174174
// (undocumented)
175175
static ɵfac: i0.ɵɵFactoryDeclaration<CdkVirtualScrollableWindow, [null, null, { optional: true; }]>;
176176
}
@@ -222,7 +222,7 @@ export class CdkVirtualScrollViewport extends CdkVirtualScrollable implements On
222222
_totalContentHeight: string;
223223
_totalContentWidth: string;
224224
// (undocumented)
225-
static ɵcmp: i0.ɵɵComponentDeclaration<CdkVirtualScrollViewport, "cdk-virtual-scroll-viewport", never, { "orientation": "orientation"; "appendOnly": "appendOnly"; }, { "scrolledIndexChange": "scrolledIndexChange"; }, never, ["*"], false, never>;
225+
static ɵcmp: i0.ɵɵComponentDeclaration<CdkVirtualScrollViewport, "cdk-virtual-scroll-viewport", never, { "orientation": "orientation"; "appendOnly": "appendOnly"; }, { "scrolledIndexChange": "scrolledIndexChange"; }, never, ["*"], true, never>;
226226
// (undocumented)
227227
static ɵfac: i0.ɵɵFactoryDeclaration<CdkVirtualScrollViewport, [null, null, null, { optional: true; }, { optional: true; }, null, null, { optional: true; }]>;
228228
}
@@ -294,7 +294,7 @@ export class ScrollingModule {
294294
// (undocumented)
295295
static ɵinj: i0.ɵɵInjectorDeclaration<ScrollingModule>;
296296
// (undocumented)
297-
static ɵmod: i0.ɵɵNgModuleDeclaration<ScrollingModule, [typeof i2.CdkFixedSizeVirtualScroll, typeof i3.CdkVirtualForOf, typeof i4.CdkVirtualScrollViewport, typeof i5.CdkVirtualScrollableWindow, typeof i6.CdkVirtualScrollableElement], [typeof i7.BidiModule, typeof CdkScrollableModule], [typeof i7.BidiModule, typeof CdkScrollableModule, typeof i2.CdkFixedSizeVirtualScroll, typeof i3.CdkVirtualForOf, typeof i4.CdkVirtualScrollViewport, typeof i5.CdkVirtualScrollableWindow, typeof i6.CdkVirtualScrollableElement]>;
297+
static ɵmod: i0.ɵɵNgModuleDeclaration<ScrollingModule, never, [typeof i2.BidiModule, typeof CdkScrollableModule, typeof i3.CdkVirtualScrollViewport, typeof i4.CdkFixedSizeVirtualScroll, typeof i5.CdkVirtualForOf, typeof i6.CdkVirtualScrollableWindow, typeof i7.CdkVirtualScrollableElement], [typeof i2.BidiModule, typeof CdkScrollableModule, typeof i4.CdkFixedSizeVirtualScroll, typeof i5.CdkVirtualForOf, typeof i3.CdkVirtualScrollViewport, typeof i6.CdkVirtualScrollableWindow, typeof i7.CdkVirtualScrollableElement]>;
298298
}
299299

300300
// @public (undocumented)

0 commit comments

Comments
 (0)