@@ -21,8 +21,12 @@ import {
21
21
UP_ARROW ,
22
22
} from '@angular/cdk/keycodes' ;
23
23
import {
24
+ createBlockScrollStrategy ,
25
+ createFlexibleConnectedPositionStrategy ,
26
+ createGlobalPositionStrategy ,
27
+ createOverlayRef ,
28
+ createRepositionScrollStrategy ,
24
29
FlexibleConnectedPositionStrategy ,
25
- Overlay ,
26
30
OverlayConfig ,
27
31
OverlayRef ,
28
32
ScrollStrategy ,
@@ -82,8 +86,8 @@ export const MAT_DATEPICKER_SCROLL_STRATEGY = new InjectionToken<() => ScrollStr
82
86
{
83
87
providedIn : 'root' ,
84
88
factory : ( ) => {
85
- const overlay = inject ( Overlay ) ;
86
- return ( ) => overlay . scrollStrategies . reposition ( ) ;
89
+ const injector = inject ( Injector ) ;
90
+ return ( ) => createRepositionScrollStrategy ( injector ) ;
87
91
} ,
88
92
} ,
89
93
) ;
@@ -93,8 +97,9 @@ export const MAT_DATEPICKER_SCROLL_STRATEGY = new InjectionToken<() => ScrollStr
93
97
* @deprecated No longer used, will be removed.
94
98
* @breaking -change 21.0.0
95
99
*/
96
- export function MAT_DATEPICKER_SCROLL_STRATEGY_FACTORY ( overlay : Overlay ) : ( ) => ScrollStrategy {
97
- return ( ) => overlay . scrollStrategies . reposition ( ) ;
100
+ export function MAT_DATEPICKER_SCROLL_STRATEGY_FACTORY ( _overlay : unknown ) : ( ) => ScrollStrategy {
101
+ const injector = inject ( Injector ) ;
102
+ return ( ) => createRepositionScrollStrategy ( injector ) ;
98
103
}
99
104
100
105
/** Possible positions for the datepicker dropdown along the X axis. */
@@ -110,7 +115,7 @@ export type DatepickerDropdownPositionY = 'above' | 'below';
110
115
*/
111
116
export const MAT_DATEPICKER_SCROLL_STRATEGY_FACTORY_PROVIDER = {
112
117
provide : MAT_DATEPICKER_SCROLL_STRATEGY ,
113
- deps : [ Overlay ] ,
118
+ deps : [ ] as any [ ] ,
114
119
useFactory : MAT_DATEPICKER_SCROLL_STRATEGY_FACTORY ,
115
120
} ;
116
121
@@ -390,7 +395,7 @@ export abstract class MatDatepickerBase<
390
395
>
391
396
implements MatDatepickerPanel < C , S , D > , OnDestroy , OnChanges
392
397
{
393
- private _overlay = inject ( Overlay ) ;
398
+ private _injector = inject ( Injector ) ;
394
399
private _viewContainerRef = inject ( ViewContainerRef ) ;
395
400
private _dateAdapter = inject < DateAdapter < D > > ( DateAdapter , { optional : true } ) ! ;
396
401
private _dir = inject ( Directionality , { optional : true } ) ;
@@ -565,8 +570,6 @@ export abstract class MatDatepickerBase<
565
570
/** Emits when the datepicker's state changes. */
566
571
readonly stateChanges = new Subject < void > ( ) ;
567
572
568
- private _injector = inject ( Injector ) ;
569
-
570
573
private readonly _changeDetectorRef = inject ( ChangeDetectorRef ) ;
571
574
572
575
constructor ( ...args : unknown [ ] ) ;
@@ -760,7 +763,8 @@ export abstract class MatDatepickerBase<
760
763
MatDatepickerContent ,
761
764
this . _viewContainerRef ,
762
765
) ;
763
- const overlayRef = ( this . _overlayRef = this . _overlay . create (
766
+ const overlayRef = ( this . _overlayRef = createOverlayRef (
767
+ this . _injector ,
764
768
new OverlayConfig ( {
765
769
positionStrategy : isDialog ? this . _getDialogStrategy ( ) : this . _getDropdownStrategy ( ) ,
766
770
hasBackdrop : true ,
@@ -769,7 +773,9 @@ export abstract class MatDatepickerBase<
769
773
this . _backdropHarnessClass ,
770
774
] ,
771
775
direction : this . _dir || 'ltr' ,
772
- scrollStrategy : isDialog ? this . _overlay . scrollStrategies . block ( ) : this . _scrollStrategy ( ) ,
776
+ scrollStrategy : isDialog
777
+ ? createBlockScrollStrategy ( this . _injector )
778
+ : this . _scrollStrategy ( ) ,
773
779
panelClass : `mat-datepicker-${ isDialog ? 'dialog' : 'popup' } ` ,
774
780
disableAnimations : this . _animationsDisabled ,
775
781
} ) ,
@@ -825,14 +831,15 @@ export abstract class MatDatepickerBase<
825
831
826
832
/** Gets a position strategy that will open the calendar as a dropdown. */
827
833
private _getDialogStrategy ( ) {
828
- return this . _overlay . position ( ) . global ( ) . centerHorizontally ( ) . centerVertically ( ) ;
834
+ return createGlobalPositionStrategy ( this . _injector ) . centerHorizontally ( ) . centerVertically ( ) ;
829
835
}
830
836
831
837
/** Gets a position strategy that will open the calendar as a dropdown. */
832
838
private _getDropdownStrategy ( ) {
833
- const strategy = this . _overlay
834
- . position ( )
835
- . flexibleConnectedTo ( this . datepickerInput . getConnectedOverlayOrigin ( ) )
839
+ const strategy = createFlexibleConnectedPositionStrategy (
840
+ this . _injector ,
841
+ this . datepickerInput . getConnectedOverlayOrigin ( ) ,
842
+ )
836
843
. withTransformOriginOn ( '.mat-datepicker-content' )
837
844
. withFlexibleDimensions ( false )
838
845
. withViewportMargin ( 8 )
0 commit comments