Skip to content

Commit 89ff55f

Browse files
committed
fix(material/datepicker): remove deprecated factory functions
Removes factory functions that we had marked as deprecated for v21. These functions aren't necessary since we switched to standalone. BREAKING CHANGE: * `MAT_DATEPICKER_SCROLL_STRATEGY_FACTORY` has been removed. * `MAT_DATEPICKER_SCROLL_STRATEGY_FACTORY_PROVIDER` has been removed. * `MAT_RANGE_DATE_SELECTION_MODEL_FACTORY` has been removed. * `MAT_RANGE_DATE_SELECTION_MODEL_PROVIDER` has been removed. * `MAT_SINGLE_DATE_SELECTION_MODEL_FACTORY` has been removed. * `MAT_SINGLE_DATE_SELECTION_MODEL_PROVIDER` has been removed.
1 parent 24932b6 commit 89ff55f

File tree

7 files changed

+33
-112
lines changed

7 files changed

+33
-112
lines changed

goldens/material/datepicker/index.api.md

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import { Directionality } from '@angular/cdk/bidi';
1616
import { DoCheck } from '@angular/core';
1717
import { ElementRef } from '@angular/core';
1818
import { EventEmitter } from '@angular/core';
19-
import { FactoryProvider } from '@angular/core';
2019
import { FocusOrigin } from '@angular/cdk/a11y';
2120
import { FormGroupDirective } from '@angular/forms';
2221
import * as i0 from '@angular/core';
@@ -92,34 +91,12 @@ export const MAT_DATE_RANGE_SELECTION_STRATEGY: InjectionToken<MatDateRangeSelec
9291
// @public
9392
export const MAT_DATEPICKER_SCROLL_STRATEGY: InjectionToken<() => ScrollStrategy>;
9493

95-
// @public @deprecated
96-
export function MAT_DATEPICKER_SCROLL_STRATEGY_FACTORY(_overlay: unknown): () => ScrollStrategy;
97-
98-
// @public @deprecated
99-
export const MAT_DATEPICKER_SCROLL_STRATEGY_FACTORY_PROVIDER: {
100-
provide: InjectionToken<() => ScrollStrategy>;
101-
deps: any[];
102-
useFactory: typeof MAT_DATEPICKER_SCROLL_STRATEGY_FACTORY;
103-
};
104-
10594
// @public
10695
export const MAT_DATEPICKER_VALIDATORS: any;
10796

10897
// @public
10998
export const MAT_DATEPICKER_VALUE_ACCESSOR: any;
11099

111-
// @public @deprecated
112-
export function MAT_RANGE_DATE_SELECTION_MODEL_FACTORY(parent: MatSingleDateSelectionModel<unknown>, adapter: DateAdapter<unknown>): MatSingleDateSelectionModel<unknown>;
113-
114-
// @public @deprecated
115-
export const MAT_RANGE_DATE_SELECTION_MODEL_PROVIDER: FactoryProvider;
116-
117-
// @public @deprecated
118-
export function MAT_SINGLE_DATE_SELECTION_MODEL_FACTORY(parent: MatSingleDateSelectionModel<unknown>, adapter: DateAdapter<unknown>): MatSingleDateSelectionModel<unknown>;
119-
120-
// @public @deprecated
121-
export const MAT_SINGLE_DATE_SELECTION_MODEL_PROVIDER: FactoryProvider;
122-
123100
// @public
124101
export class MatCalendar<D> implements AfterContentInit, AfterViewChecked, OnDestroy, OnChanges {
125102
constructor(...args: unknown[]);

src/material/datepicker/date-range-picker.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,14 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9-
import {ChangeDetectionStrategy, Component, ViewEncapsulation} from '@angular/core';
9+
import {ChangeDetectionStrategy, Component, inject, ViewEncapsulation} from '@angular/core';
1010
import {MatDatepickerBase, MatDatepickerContent, MatDatepickerControl} from './datepicker-base';
1111
import {MAT_RANGE_DATE_SELECTION_MODEL_PROVIDER, DateRange} from './date-selection-model';
12-
import {MAT_CALENDAR_RANGE_STRATEGY_PROVIDER} from './date-range-selection-strategy';
12+
import {
13+
DefaultMatCalendarRangeStrategy,
14+
MAT_DATE_RANGE_SELECTION_STRATEGY,
15+
} from './date-range-selection-strategy';
16+
import {DateAdapter} from '../core';
1317

1418
/**
1519
* Input that can be associated with a date range picker.
@@ -34,7 +38,13 @@ export interface MatDateRangePickerInput<D> extends MatDatepickerControl<D> {
3438
encapsulation: ViewEncapsulation.None,
3539
providers: [
3640
MAT_RANGE_DATE_SELECTION_MODEL_PROVIDER,
37-
MAT_CALENDAR_RANGE_STRATEGY_PROVIDER,
41+
{
42+
provide: MAT_DATE_RANGE_SELECTION_STRATEGY,
43+
useFactory: () => {
44+
const parent = inject(MAT_DATE_RANGE_SELECTION_STRATEGY, {optional: true, skipSelf: true});
45+
return parent || new DefaultMatCalendarRangeStrategy(inject(DateAdapter));
46+
},
47+
},
3848
{provide: MatDatepickerBase, useExisting: MatDateRangePicker},
3949
],
4050
})

src/material/datepicker/date-range-selection-strategy.ts

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9-
import {Injectable, InjectionToken, Optional, SkipSelf, FactoryProvider} from '@angular/core';
9+
import {Injectable, InjectionToken} from '@angular/core';
1010
import {DateAdapter} from '../core';
1111
import {DateRange} from './date-selection-model';
1212

@@ -130,26 +130,3 @@ export class DefaultMatCalendarRangeStrategy<D> implements MatDateRangeSelection
130130
return new DateRange<D>(start, end);
131131
}
132132
}
133-
134-
/**
135-
* @docs-private
136-
* @deprecated No longer used, will be removed.
137-
* @breaking-change 21.0.0
138-
*/
139-
export function MAT_CALENDAR_RANGE_STRATEGY_PROVIDER_FACTORY(
140-
parent: MatDateRangeSelectionStrategy<unknown>,
141-
adapter: DateAdapter<unknown>,
142-
) {
143-
return parent || new DefaultMatCalendarRangeStrategy(adapter);
144-
}
145-
146-
/**
147-
* @docs-private
148-
* @deprecated No longer used, will be removed.
149-
* @breaking-change 21.0.0
150-
*/
151-
export const MAT_CALENDAR_RANGE_STRATEGY_PROVIDER: FactoryProvider = {
152-
provide: MAT_DATE_RANGE_SELECTION_STRATEGY,
153-
deps: [[new Optional(), new SkipSelf(), MAT_DATE_RANGE_SELECTION_STRATEGY], DateAdapter],
154-
useFactory: MAT_CALENDAR_RANGE_STRATEGY_PROVIDER_FACTORY,
155-
};

src/material/datepicker/date-selection-model.ts

Lines changed: 9 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9-
import {FactoryProvider, Injectable, Optional, SkipSelf, OnDestroy} from '@angular/core';
9+
import {FactoryProvider, Injectable, OnDestroy, inject} from '@angular/core';
1010
import {DateAdapter} from '../core';
1111
import {Observable, Subject} from 'rxjs';
1212

@@ -211,50 +211,26 @@ export class MatRangeDateSelectionModel<D> extends MatDateSelectionModel<DateRan
211211
}
212212
}
213213

214-
/**
215-
* @docs-private
216-
* @deprecated No longer used, will be removed.
217-
* @breaking-change 21.0.0
218-
*/
219-
export function MAT_SINGLE_DATE_SELECTION_MODEL_FACTORY(
220-
parent: MatSingleDateSelectionModel<unknown>,
221-
adapter: DateAdapter<unknown>,
222-
) {
223-
return parent || new MatSingleDateSelectionModel(adapter);
224-
}
225-
226214
/**
227215
* Used to provide a single selection model to a component.
228216
* @docs-private
229-
* @deprecated No longer used, will be removed.
230-
* @breaking-change 21.0.0
231217
*/
232218
export const MAT_SINGLE_DATE_SELECTION_MODEL_PROVIDER: FactoryProvider = {
233219
provide: MatDateSelectionModel,
234-
deps: [[new Optional(), new SkipSelf(), MatDateSelectionModel], DateAdapter],
235-
useFactory: MAT_SINGLE_DATE_SELECTION_MODEL_FACTORY,
220+
useFactory: () => {
221+
const parent = inject(MatDateSelectionModel, {optional: true, skipSelf: true});
222+
return parent || new MatSingleDateSelectionModel(inject(DateAdapter));
223+
},
236224
};
237225

238-
/**
239-
* @docs-private
240-
* @deprecated No longer used, will be removed.
241-
* @breaking-change 21.0.0
242-
*/
243-
export function MAT_RANGE_DATE_SELECTION_MODEL_FACTORY(
244-
parent: MatSingleDateSelectionModel<unknown>,
245-
adapter: DateAdapter<unknown>,
246-
) {
247-
return parent || new MatRangeDateSelectionModel(adapter);
248-
}
249-
250226
/**
251227
* Used to provide a range selection model to a component.
252228
* @docs-private
253-
* @deprecated No longer used, will be removed.
254-
* @breaking-change 21.0.0
255229
*/
256230
export const MAT_RANGE_DATE_SELECTION_MODEL_PROVIDER: FactoryProvider = {
257231
provide: MatDateSelectionModel,
258-
deps: [[new Optional(), new SkipSelf(), MatDateSelectionModel], DateAdapter],
259-
useFactory: MAT_RANGE_DATE_SELECTION_MODEL_FACTORY,
232+
useFactory: () => {
233+
const parent = inject(MatDateSelectionModel, {optional: true, skipSelf: true});
234+
return parent || new MatRangeDateSelectionModel(inject(DateAdapter));
235+
},
260236
};

src/material/datepicker/datepicker-base.ts

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -92,33 +92,12 @@ export const MAT_DATEPICKER_SCROLL_STRATEGY = new InjectionToken<() => ScrollStr
9292
},
9393
);
9494

95-
/**
96-
* @docs-private
97-
* @deprecated No longer used, will be removed.
98-
* @breaking-change 21.0.0
99-
*/
100-
export function MAT_DATEPICKER_SCROLL_STRATEGY_FACTORY(_overlay: unknown): () => ScrollStrategy {
101-
const injector = inject(Injector);
102-
return () => createRepositionScrollStrategy(injector);
103-
}
104-
10595
/** Possible positions for the datepicker dropdown along the X axis. */
10696
export type DatepickerDropdownPositionX = 'start' | 'end';
10797

10898
/** Possible positions for the datepicker dropdown along the Y axis. */
10999
export type DatepickerDropdownPositionY = 'above' | 'below';
110100

111-
/**
112-
* @docs-private
113-
* @deprecated No longer used, will be removed.
114-
* @breaking-change 21.0.0
115-
*/
116-
export const MAT_DATEPICKER_SCROLL_STRATEGY_FACTORY_PROVIDER = {
117-
provide: MAT_DATEPICKER_SCROLL_STRATEGY,
118-
deps: [] as any[],
119-
useFactory: MAT_DATEPICKER_SCROLL_STRATEGY_FACTORY,
120-
};
121-
122101
/**
123102
* Component used as the content for the datepicker overlay. We use this instead of using
124103
* MatCalendar directly as the content so we can control the initial focus. This also gives us a

src/material/datepicker/datepicker-module.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@ import {MatCommonModule} from '../core';
1616
import {MatCalendar, MatCalendarHeader} from './calendar';
1717
import {MatCalendarBody} from './calendar-body';
1818
import {MatDatepicker} from './datepicker';
19-
import {
20-
MatDatepickerContent,
21-
MAT_DATEPICKER_SCROLL_STRATEGY_FACTORY_PROVIDER,
22-
} from './datepicker-base';
19+
import {MatDatepickerContent} from './datepicker-base';
2320
import {MatDatepickerInput} from './datepicker-input';
2421
import {MatDatepickerIntl} from './datepicker-intl';
2522
import {MatDatepickerToggle, MatDatepickerToggleIcon} from './datepicker-toggle';
@@ -78,6 +75,6 @@ import {MatDatepickerActions, MatDatepickerApply, MatDatepickerCancel} from './d
7875
MatDatepickerCancel,
7976
MatDatepickerApply,
8077
],
81-
providers: [MatDatepickerIntl, MAT_DATEPICKER_SCROLL_STRATEGY_FACTORY_PROVIDER],
78+
providers: [MatDatepickerIntl],
8279
})
8380
export class MatDatepickerModule {}

src/material/datepicker/public-api.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ export {
1717
} from './date-range-selection-strategy';
1818
export {
1919
MAT_DATEPICKER_SCROLL_STRATEGY,
20-
MAT_DATEPICKER_SCROLL_STRATEGY_FACTORY,
21-
MAT_DATEPICKER_SCROLL_STRATEGY_FACTORY_PROVIDER,
2220
MatDatepickerContent,
2321
DatepickerDropdownPositionX,
2422
DatepickerDropdownPositionY,
@@ -37,7 +35,14 @@ export * from './month-view';
3735
export * from './year-view';
3836
export * from './date-range-input';
3937
export {MatDateRangePicker} from './date-range-picker';
40-
export * from './date-selection-model';
38+
export {
39+
DateRange,
40+
ExtractDateTypeFromSelection,
41+
DateSelectionModelChange,
42+
MatDateSelectionModel,
43+
MatSingleDateSelectionModel,
44+
MatRangeDateSelectionModel,
45+
} from './date-selection-model';
4146
export {MatStartDate, MatEndDate} from './date-range-input-parts';
4247
export {MatMultiYearView, yearsPerPage, yearsPerRow} from './multi-year-view';
4348
export * from './datepicker-actions';

0 commit comments

Comments
 (0)