@@ -60,14 +60,18 @@ export const MAT_DATE_RANGE_INPUT_PARENT =
60
60
* Base class for the individual inputs that can be projected inside a `mat-date-range-input`.
61
61
*/
62
62
@Directive ( )
63
- class MatDateRangeInputPartBase < D >
63
+ abstract class MatDateRangeInputPartBase < D >
64
64
extends MatDatepickerInputBase < DateRange < D > , D > implements OnInit , DoCheck {
65
65
66
66
/** @docs -private */
67
67
ngControl : NgControl ;
68
68
69
69
/** @docs -private */
70
- updateErrorState : ( ) => void ;
70
+ abstract updateErrorState ( ) : void ;
71
+
72
+ protected abstract _validator : ValidatorFn | null ;
73
+ protected abstract _assignValueToModel ( value : D | null ) : void ;
74
+ protected abstract _getValueFromModel ( modelValue : DateRange < D > ) : D | null ;
71
75
72
76
constructor (
73
77
@Inject ( MAT_DATE_RANGE_INPUT_PARENT ) public _rangeInput : MatDateRangeInputParent ,
@@ -129,17 +133,12 @@ class MatDateRangeInputPartBase<D>
129
133
protected _openPopup ( ) : void {
130
134
this . _rangeInput . _openDatepicker ( ) ;
131
135
}
132
-
133
- // Dummy property implementations since we can't pass an abstract class
134
- // into a mixin. These are overridden by the individual input classes.
135
- protected _validator : ValidatorFn | null ;
136
- protected _assignValueToModel : ( value : D | null ) => void ;
137
- protected _getValueFromModel : ( modelValue : DateRange < D > ) => D | null ;
138
136
}
139
137
140
138
const _MatDateRangeInputBase :
141
139
CanUpdateErrorStateCtor & typeof MatDateRangeInputPartBase =
142
- mixinErrorState ( MatDateRangeInputPartBase ) ;
140
+ // Needs to be `as any`, because the base class is abstract.
141
+ mixinErrorState ( MatDateRangeInputPartBase as any ) ;
143
142
144
143
/** Input for entering the start date in a `mat-date-range-input`. */
145
144
@Directive ( {
@@ -170,8 +169,12 @@ export class MatStartDate<D> extends _MatDateRangeInputBase<D>
170
169
implements CanUpdateErrorState {
171
170
// TODO(crisbeto): start-range-specific validators should go here.
172
171
protected _validator = Validators . compose ( [ this . _parseValidator ] ) ;
173
- protected _getValueFromModel = ( modelValue : DateRange < D > ) => modelValue . start ;
174
- protected _assignValueToModel = ( value : D | null ) => {
172
+
173
+ protected _getValueFromModel ( modelValue : DateRange < D > ) {
174
+ return modelValue . start ;
175
+ }
176
+
177
+ protected _assignValueToModel ( value : D | null ) {
175
178
if ( this . _model ) {
176
179
this . _model . updateSelection ( new DateRange ( value , this . _model . selection . end ) , this ) ;
177
180
}
@@ -216,8 +219,12 @@ export class MatStartDate<D> extends _MatDateRangeInputBase<D>
216
219
export class MatEndDate < D > extends _MatDateRangeInputBase < D > implements CanUpdateErrorState {
217
220
// TODO(crisbeto): end-range-specific validators should go here.
218
221
protected _validator = Validators . compose ( [ this . _parseValidator ] ) ;
219
- protected _getValueFromModel = ( modelValue : DateRange < D > ) => modelValue . end ;
220
- protected _assignValueToModel = ( value : D | null ) => {
222
+
223
+ protected _getValueFromModel ( modelValue : DateRange < D > ) {
224
+ return modelValue . end ;
225
+ }
226
+
227
+ protected _assignValueToModel ( value : D | null ) {
221
228
if ( this . _model ) {
222
229
this . _model . updateSelection ( new DateRange ( this . _model . selection . start , value ) , this ) ;
223
230
}
0 commit comments