88
99import { Directionality } from '@angular/cdk/bidi' ;
1010import { 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' ;
2212import {
2313 AbstractControl ,
2414 FormGroupDirective ,
@@ -33,34 +23,8 @@ import {
3323import { ErrorStateMatcher , _ErrorStateTracker } from '@angular/material/core' ;
3424import { _computeAriaAccessibleName } from './aria-accessible-name' ;
3525import { 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' ;
6428
6529/**
6630 * Base class for the individual inputs that can be projected inside a `mat-date-range-input`.
@@ -70,7 +34,7 @@ abstract class MatDateRangeInputPartBase<D>
7034 extends MatDatepickerInputBase < DateRange < D > >
7135 implements OnInit , DoCheck
7236{
73- _rangeInput = inject < MatDateRangeInputParent < D > > ( MAT_DATE_RANGE_INPUT_PARENT ) ;
37+ _rangeInput = inject < MatDateRangeInput < D > > ( MatDateRangeInput ) ;
7438 override _elementRef = inject < ElementRef < HTMLInputElement > > ( ElementRef ) ;
7539 _defaultErrorStateMatcher = inject ( ErrorStateMatcher ) ;
7640 private _injector = inject ( Injector ) ;
@@ -208,7 +172,7 @@ abstract class MatDateRangeInputPartBase<D>
208172 protected override _assignValueProgrammatically ( value : D | null ) {
209173 super . _assignValueProgrammatically ( value ) ;
210174 const opposite = (
211- this === this . _rangeInput . _startInput
175+ this === ( this . _rangeInput . _startInput as MatDateRangeInputPartBase < D > )
212176 ? this . _rangeInput . _endInput
213177 : this . _rangeInput . _startInput
214178 ) as MatDateRangeInputPartBase < D > | undefined ;
@@ -261,6 +225,13 @@ export class MatStartDate<D> extends MatDateRangeInputPartBase<D> {
261225
262226 protected _validator = Validators . compose ( [ ...super . _getValidators ( ) , this . _startValidator ] ) ;
263227
228+ constructor ( ...args : unknown [ ] ) ;
229+
230+ constructor ( ) {
231+ super ( ) ;
232+ this . _rangeInput . _startInput = this ;
233+ }
234+
264235 protected _getValueFromModel ( modelValue : DateRange < D > ) {
265236 return modelValue . start ;
266237 }
@@ -349,6 +320,13 @@ export class MatEndDate<D> extends MatDateRangeInputPartBase<D> {
349320 : { 'matEndDateInvalid' : { 'start' : start , 'actual' : end } } ;
350321 } ;
351322
323+ constructor ( ...args : unknown [ ] ) ;
324+
325+ constructor ( ) {
326+ super ( ) ;
327+ this . _rangeInput . _endInput = this ;
328+ }
329+
352330 protected _validator = Validators . compose ( [ ...super . _getValidators ( ) , this . _endValidator ] ) ;
353331
354332 protected _getValueFromModel ( modelValue : DateRange < D > ) {
0 commit comments