8
8
9
9
import { Directionality } from '@angular/cdk/bidi' ;
10
10
import { BACKSPACE , LEFT_ARROW , RIGHT_ARROW } from '@angular/cdk/keycodes' ;
11
- import {
12
- Directive ,
13
- DoCheck ,
14
- ElementRef ,
15
- InjectionToken ,
16
- Injector ,
17
- Input ,
18
- OnInit ,
19
- Signal ,
20
- inject ,
21
- } from '@angular/core' ;
11
+ import { Directive , DoCheck , ElementRef , Injector , Input , OnInit , inject } from '@angular/core' ;
22
12
import {
23
13
AbstractControl ,
24
14
FormGroupDirective ,
@@ -33,34 +23,8 @@ import {
33
23
import { ErrorStateMatcher , _ErrorStateTracker } from '@angular/material/core' ;
34
24
import { _computeAriaAccessibleName } from './aria-accessible-name' ;
35
25
import { DateRange , DateSelectionModelChange } from './date-selection-model' ;
36
- import { DateFilterFn , MatDatepickerInputBase } from './datepicker-input-base' ;
37
-
38
- /** Parent component that should be wrapped around `MatStartDate` and `MatEndDate`. */
39
- export interface MatDateRangeInputParent < D > {
40
- id : string ;
41
- min : D | null ;
42
- max : D | null ;
43
- dateFilter : DateFilterFn < D > ;
44
- rangePicker : {
45
- opened : boolean ;
46
- id : string ;
47
- } ;
48
- // @breaking -change 20.0.0 property to become required.
49
- _ariaOwns ?: Signal < string | null > ;
50
- _startInput : MatDateRangeInputPartBase < D > ;
51
- _endInput : MatDateRangeInputPartBase < D > ;
52
- _groupDisabled : boolean ;
53
- _handleChildValueChange ( ) : void ;
54
- _openDatepicker ( ) : void ;
55
- }
56
-
57
- /**
58
- * Used to provide the date range input wrapper component
59
- * to the parts without circular dependencies.
60
- */
61
- export const MAT_DATE_RANGE_INPUT_PARENT = new InjectionToken < MatDateRangeInputParent < unknown > > (
62
- 'MAT_DATE_RANGE_INPUT_PARENT' ,
63
- ) ;
26
+ import { MatDatepickerInputBase } from './datepicker-input-base' ;
27
+ import { MatDateRangeInput } from './date-range-input' ;
64
28
65
29
/**
66
30
* Base class for the individual inputs that can be projected inside a `mat-date-range-input`.
@@ -70,7 +34,7 @@ abstract class MatDateRangeInputPartBase<D>
70
34
extends MatDatepickerInputBase < DateRange < D > >
71
35
implements OnInit , DoCheck
72
36
{
73
- _rangeInput = inject < MatDateRangeInputParent < D > > ( MAT_DATE_RANGE_INPUT_PARENT ) ;
37
+ _rangeInput = inject < MatDateRangeInput < D > > ( MatDateRangeInput ) ;
74
38
override _elementRef = inject < ElementRef < HTMLInputElement > > ( ElementRef ) ;
75
39
_defaultErrorStateMatcher = inject ( ErrorStateMatcher ) ;
76
40
private _injector = inject ( Injector ) ;
@@ -208,7 +172,7 @@ abstract class MatDateRangeInputPartBase<D>
208
172
protected override _assignValueProgrammatically ( value : D | null ) {
209
173
super . _assignValueProgrammatically ( value ) ;
210
174
const opposite = (
211
- this === this . _rangeInput . _startInput
175
+ this === ( this . _rangeInput . _startInput as MatDateRangeInputPartBase < D > )
212
176
? this . _rangeInput . _endInput
213
177
: this . _rangeInput . _startInput
214
178
) as MatDateRangeInputPartBase < D > | undefined ;
@@ -261,6 +225,13 @@ export class MatStartDate<D> extends MatDateRangeInputPartBase<D> {
261
225
262
226
protected _validator = Validators . compose ( [ ...super . _getValidators ( ) , this . _startValidator ] ) ;
263
227
228
+ constructor ( ...args : unknown [ ] ) ;
229
+
230
+ constructor ( ) {
231
+ super ( ) ;
232
+ this . _rangeInput . _startInput = this ;
233
+ }
234
+
264
235
protected _getValueFromModel ( modelValue : DateRange < D > ) {
265
236
return modelValue . start ;
266
237
}
@@ -349,6 +320,13 @@ export class MatEndDate<D> extends MatDateRangeInputPartBase<D> {
349
320
: { 'matEndDateInvalid' : { 'start' : start , 'actual' : end } } ;
350
321
} ;
351
322
323
+ constructor ( ...args : unknown [ ] ) ;
324
+
325
+ constructor ( ) {
326
+ super ( ) ;
327
+ this . _rangeInput . _endInput = this ;
328
+ }
329
+
352
330
protected _validator = Validators . compose ( [ ...super . _getValidators ( ) , this . _endValidator ] ) ;
353
331
354
332
protected _getValueFromModel ( modelValue : DateRange < D > ) {
0 commit comments