Skip to content

Commit fc51dcc

Browse files
jelbourndevversion
authored andcommitted
feat: expand input types with coercion to work with ngtsc input type checking
1 parent ed6f133 commit fc51dcc

File tree

148 files changed

+687
-67
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

148 files changed

+687
-67
lines changed

src/a11y-demo/datepicker/datepicker-a11y.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ export class DatepickerAccessibilityDemo {
3131
appointmentDate: Date;
3232
minAppointmentDate = new Date();
3333
maxAppointmentDate = new Date(Date.now() + 365 * 24 * 60 * 60 * 1000);
34-
weekdaysOnly = (d: Date) => d.getDay() != 0 && d.getDay() != 6;
34+
weekdaysOnly = (d: Date|null) => d !== null && d.getDay() != 0 && d.getDay() != 6;
3535
}

src/cdk-experimental/scrolling/auto-size-virtual-scroll.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,4 +463,7 @@ export class CdkAutoSizeVirtualScroll implements OnChanges {
463463
ngOnChanges() {
464464
this._scrollStrategy.updateBufferSize(this.minBufferPx, this.maxBufferPx);
465465
}
466+
467+
static ngAcceptInputType_minBufferPx: number | string;
468+
static ngAcceptInputType_maxBufferPx: number | string;
466469
}

src/cdk/a11y/focus-trap/focus-trap.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,4 +418,7 @@ export class CdkTrapFocus implements OnDestroy, AfterContentInit, DoCheck {
418418
this.focusTrap.attachAnchors();
419419
}
420420
}
421+
422+
static ngAcceptInputType_enabled: boolean | string;
423+
static ngAcceptInputType_autoCapture: boolean | string;
421424
}

src/cdk/accordion/accordion-item.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,4 +152,7 @@ export class CdkAccordionItem implements OnDestroy {
152152
}
153153
});
154154
}
155+
156+
static ngAcceptInputType_expanded: boolean | string;
157+
static ngAcceptInputType_disabled: boolean | string;
155158
}

src/cdk/accordion/accordion.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,6 @@ export class CdkAccordion implements OnDestroy, OnChanges {
5959
this._openCloseAllActions.next(expanded);
6060
}
6161
}
62+
63+
static ngAcceptInputType_multi: boolean | string;
6264
}

src/cdk/drag-drop/directives/drag-handle.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,6 @@ export class CdkDragHandle implements OnDestroy {
4646
ngOnDestroy() {
4747
this._stateChanges.complete();
4848
}
49+
50+
static ngAcceptInputType_disabled: boolean | string;
4951
}

src/cdk/drag-drop/directives/drag.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,8 @@ export class CdkDrag<T = any> implements AfterViewInit, OnChanges, OnDestroy {
408408
});
409409
});
410410
}
411+
412+
static ngAcceptInputType_disabled: boolean | string;
411413
}
412414

413415
/** Gets the closest ancestor of an element that matches a selector. */

src/cdk/drag-drop/directives/drop-list-group.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,6 @@ export class CdkDropListGroup<T> implements OnDestroy {
3434
ngOnDestroy() {
3535
this._items.clear();
3636
}
37+
38+
static ngAcceptInputType_disabled: boolean | string;
3739
}

src/cdk/drag-drop/directives/drop-list.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,4 +328,7 @@ export class CdkDropList<T = any> implements AfterContentInit, OnDestroy {
328328
});
329329
}
330330

331+
static ngAcceptInputType_disabled: boolean | string;
332+
static ngAcceptInputType_sortingDisabled: boolean | string;
333+
static ngAcceptInputType_autoScrollDisabled: boolean | string;
331334
}

src/cdk/observers/observe-content.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,9 @@ export class CdkObserveContent implements AfterContentInit, OnDestroy {
193193
this._currentSubscription.unsubscribe();
194194
}
195195
}
196+
197+
static ngAcceptInputType_disabled: boolean | string;
198+
static ngAcceptInputType_debounce: boolean | string;
196199
}
197200

198201

src/cdk/overlay/overlay-directives.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,12 @@ export class CdkConnectedOverlay implements OnDestroy, OnChanges {
383383

384384
this._backdropSubscription.unsubscribe();
385385
}
386+
387+
static ngAcceptInputType_hasBackdrop: boolean | string;
388+
static ngAcceptInputType_lockPosition: boolean | string;
389+
static ngAcceptInputType_flexibleDimensions: boolean | string;
390+
static ngAcceptInputType_growAfterOpen: boolean | string;
391+
static ngAcceptInputType_push: boolean | string;
386392
}
387393

388394

src/cdk/portal/portal-directives.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ export class CdkPortalOutlet extends BasePortalOutlet implements OnInit, OnDestr
170170

171171
return viewRef;
172172
}
173+
174+
static ngAcceptInputType_portal: Portal<any> | null | undefined | '';
173175
}
174176

175177
/**

src/cdk/scrolling/fixed-size-virtual-scroll.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,4 +203,8 @@ export class CdkFixedSizeVirtualScroll implements OnChanges {
203203
ngOnChanges() {
204204
this._scrollStrategy.updateItemAndBufferSize(this.itemSize, this.minBufferPx, this.maxBufferPx);
205205
}
206+
207+
static ngAcceptInputType_itemSize: string | number;
208+
static ngAcceptInputType_minBufferPx: string | number;
209+
static ngAcceptInputType_maxBufferPx: string | number;
206210
}

src/cdk/stepper/stepper.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,11 @@ export class CdkStep implements OnChanges {
231231
// underlying MatStepHeader, we have to make sure that change detection runs correctly.
232232
this._stepper._stateChanged();
233233
}
234+
235+
static ngAcceptInputType_editable: boolean | string;
236+
static ngAcceptInputType_hasError: boolean | string;
237+
static ngAcceptInputType_optional: boolean | string;
238+
static ngAcceptInputType_completed: boolean | string;
234239
}
235240

236241
@Directive({
@@ -519,6 +524,13 @@ export class CdkStepper implements AfterViewInit, OnDestroy {
519524
const focusedElement = this._document.activeElement;
520525
return stepperElement === focusedElement || stepperElement.contains(focusedElement);
521526
}
527+
528+
static ngAcceptInputType_editable: boolean | string;
529+
static ngAcceptInputType_optional: boolean | string;
530+
static ngAcceptInputType_completed: boolean | string;
531+
static ngAcceptInputType_hasError: boolean | string;
532+
static ngAcceptInputType_linear: boolean | string;
533+
static ngAcceptInputType_selectedIndex: number | string;
522534
}
523535

524536

src/cdk/table/cell.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ export class CdkColumnDef extends _CdkColumnDefBase implements CanStick {
107107
* do not match are replaced by the '-' character.
108108
*/
109109
cssClassFriendlyName: string;
110+
111+
static ngAcceptInputType_sticky: boolean | string;
112+
static ngAcceptInputType_stickyEnd: boolean | string;
110113
}
111114

112115
/** Base class for the cells. Adds a CSS classname that identifies the column it renders in. */

src/cdk/table/row.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ export class CdkHeaderRowDef extends _CdkHeaderRowDefBase implements CanStick, O
9999
ngOnChanges(changes: SimpleChanges): void {
100100
super.ngOnChanges(changes);
101101
}
102+
103+
static ngAcceptInputType_sticky: boolean | string;
102104
}
103105

104106
// Boilerplate for applying mixins to CdkFooterRowDef.
@@ -125,6 +127,8 @@ export class CdkFooterRowDef extends _CdkFooterRowDefBase implements CanStick, O
125127
ngOnChanges(changes: SimpleChanges): void {
126128
super.ngOnChanges(changes);
127129
}
130+
131+
static ngAcceptInputType_sticky: boolean | string;
128132
}
129133

130134
/**

src/cdk/table/table.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,6 +1077,8 @@ export class CdkTable<T> implements AfterContentChecked, CollectionViewer, OnDes
10771077
this.updateStickyColumnStyles();
10781078
});
10791079
}
1080+
1081+
static ngAcceptInputType_multiTemplateDataRows: boolean | string;
10801082
}
10811083

10821084
/** Utility function that gets a merged list of the entries in a QueryList and values of a Set. */

src/cdk/text-field/autosize.ts

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

9-
import {coerceBooleanProperty} from '@angular/cdk/coercion';
9+
import {coerceBooleanProperty, coerceNumberProperty} from '@angular/cdk/coercion';
1010
import {
1111
Directive,
1212
ElementRef,
@@ -56,15 +56,15 @@ export class CdkTextareaAutosize implements AfterViewInit, DoCheck, OnDestroy {
5656
@Input('cdkAutosizeMinRows')
5757
get minRows(): number { return this._minRows; }
5858
set minRows(value: number) {
59-
this._minRows = value;
59+
this._minRows = coerceNumberProperty(value);
6060
this._setMinHeight();
6161
}
6262

6363
/** Maximum amount of rows in the textarea. */
6464
@Input('cdkAutosizeMaxRows')
6565
get maxRows(): number { return this._maxRows; }
6666
set maxRows(value: number) {
67-
this._maxRows = value;
67+
this._maxRows = coerceNumberProperty(value);
6868
this._setMaxHeight();
6969
}
7070

@@ -272,4 +272,8 @@ export class CdkTextareaAutosize implements AfterViewInit, DoCheck, OnDestroy {
272272
textarea.setSelectionRange(selectionStart, selectionEnd);
273273
}
274274
}
275+
276+
static ngAcceptInputType_minRows: number | string;
277+
static ngAcceptInputType_maxRows: number | string;
278+
static ngAcceptInputType_enabled: boolean | string;
275279
}

src/cdk/tree/padding.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,6 @@ export class CdkTreeNodePadding<T> implements OnDestroy {
109109
this._currentPadding = padding;
110110
}
111111
}
112+
113+
static ngAcceptInputType_level: number | string;
112114
}

src/cdk/tree/toggle.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,6 @@ export class CdkTreeNodeToggle<T> {
3838

3939
event.stopPropagation();
4040
}
41+
42+
static ngAcceptInputType_recursive: boolean | string;
4143
}

src/dev-app/badge/badge-demo.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ <h3>Buttons</h3>
6565
</button>
6666

6767
<button mat-raised-button>
68-
<mat-icon color="primary" matBadge="22" color="accent">home</mat-icon>
68+
<mat-icon matBadge="22" color="accent">home</mat-icon>
6969
</button>
7070
</div>
7171

src/dev-app/checkbox/checkbox-demo.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ <h1>mat-checkbox: Basic Example</h1>
3030
value="after"
3131
id="align-after"
3232
name="labelPosition"
33-
(click)="labelPosition = after.value"
33+
(click)="labelPosition = 'after'"
3434
checked>
3535
<label for="align-after">After</label>
3636
</div>
@@ -39,7 +39,7 @@ <h1>mat-checkbox: Basic Example</h1>
3939
value="before"
4040
id="align-before"
4141
name="labelPosition"
42-
(click)="labelPosition = before.value">
42+
(click)="labelPosition = 'before'">
4343
<label for="align-before">Before</label>
4444
</div>
4545
</div>

src/dev-app/dialog/dialog-demo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ export class JazzDialog {
175175
176176
<button
177177
mat-button
178-
color="secondary"
178+
color="accent"
179179
(click)="showInStackedDialog()">
180180
Show in Dialog</button>
181181
</mat-dialog-actions>

src/dev-app/example/example-list.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,6 @@ export class ExampleList {
6565
_expandAll: boolean;
6666

6767
exampleComponents = EXAMPLE_COMPONENTS;
68+
69+
static ngAcceptInputType_expandAll: boolean | string;
6870
}

src/dev-app/input/input-demo.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ <h3>Regular &lt;textarea&gt; with maxRows and minRows</h3>
552552
cdkTextareaAutosize
553553
[cdkAutosizeMinRows]="parseNumber(minRows.value)"
554554
[cdkAutosizeMaxRows]="parseNumber(maxRows.value)"></textarea>
555-
<button type="button" (click)="minRows.value = parseNumber(minRows.value) - 1">Decrement minRows</button>
555+
<button type="button" (click)="minRows.value = (parseNumber(minRows.value) - 1) + ''">Decrement minRows</button>
556556

557557
<h3>&lt;textarea&gt; with mat-form-field</h3>
558558
<div>

src/dev-app/mdc-checkbox/mdc-checkbox-demo.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ <h1>mat-checkbox: Basic Example</h1>
3030
value="after"
3131
id="align-after"
3232
name="labelPosition"
33-
(click)="labelPosition = after.value"
33+
(click)="labelPosition = 'after'"
3434
checked>
3535
<label for="align-after">After</label>
3636
</div>
@@ -39,7 +39,7 @@ <h1>mat-checkbox: Basic Example</h1>
3939
value="before"
4040
id="align-before"
4141
name="labelPosition"
42-
(click)="labelPosition = before.value">
42+
(click)="labelPosition = 'before'">
4343
<label for="align-before">Before</label>
4444
</div>
4545
</div>

src/dev-app/toolbar/toolbar-demo.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646

4747
<button mat-button>Text</button>
4848
<button mat-flat-button>Flat</button>
49-
<button mat-mini-fab color="">
49+
<button mat-mini-fab>
5050
<mat-icon>done</mat-icon>
5151
</button>
5252
<button mat-mini-fab color="primary">

src/material-examples/cdk/drag-drop/cdk-drag-drop-enter-predicate/cdk-drag-drop-enter-predicate-example.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export class CdkDragDropEnterPredicateExample {
1313
all = [1, 2, 3, 4, 5, 6, 7, 8, 9];
1414
even = [10];
1515

16-
drop(event: CdkDragDrop<string[]>) {
16+
drop(event: CdkDragDrop<number[]>) {
1717
if (event.previousContainer === event.container) {
1818
moveItemInArray(event.container.data, event.previousIndex, event.currentIndex);
1919
} else {

src/material-examples/material/datepicker/datepicker-filter/datepicker-filter-example.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import {Component} from '@angular/core';
77
styleUrls: ['datepicker-filter-example.css'],
88
})
99
export class DatepickerFilterExample {
10-
myFilter = (d: Date): boolean => {
11-
const day = d.getDay();
10+
myFilter = (d: Date | null): boolean => {
11+
const day = (d || new Date()).getDay();
1212
// Prevent Saturday and Sunday from being selected.
1313
return day !== 0 && day !== 6;
1414
}

src/material-examples/material/form-field/form-field-custom-control/form-field-custom-control-example.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,4 +149,7 @@ export class MyTelInput implements ControlValueAccessor, MatFormFieldControl<MyT
149149
_handleInput(): void {
150150
this.onChange(this.parts.value);
151151
}
152+
153+
static ngAcceptInputType_disabled: boolean | string;
154+
static ngAcceptInputType_required: boolean | string;
152155
}

src/material-experimental/mdc-button/button.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ export class MatButton extends MatButtonBase {
5656
@Optional() @Inject(ANIMATION_MODULE_TYPE) animationMode?: string) {
5757
super(elementRef, platform, ngZone, animationMode);
5858
}
59+
60+
static ngAcceptInputType_disabled: boolean | string;
61+
static ngAcceptInputType_disableRipple: boolean | string;
5962
}
6063

6164
/**
@@ -85,4 +88,7 @@ export class MatAnchor extends MatAnchorBase {
8588
@Optional() @Inject(ANIMATION_MODULE_TYPE) animationMode?: string) {
8689
super(elementRef, platform, ngZone, animationMode);
8790
}
91+
92+
static ngAcceptInputType_disabled: boolean | string;
93+
static ngAcceptInputType_disableRipple: boolean | string;
8894
}

src/material-experimental/mdc-button/fab.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ export class MatFabButton extends MatButtonBase {
5555
@Optional() @Inject(ANIMATION_MODULE_TYPE) animationMode?: string) {
5656
super(elementRef, platform, ngZone, animationMode);
5757
}
58+
59+
static ngAcceptInputType_disabled: boolean | string;
60+
static ngAcceptInputType_disableRipple: boolean | string;
5861
}
5962

6063

@@ -85,4 +88,7 @@ export class MatFabAnchor extends MatAnchor {
8588
@Optional() @Inject(ANIMATION_MODULE_TYPE) animationMode?: string) {
8689
super(elementRef, platform, ngZone, animationMode);
8790
}
91+
92+
static ngAcceptInputType_disabled: boolean | string;
93+
static ngAcceptInputType_disableRipple: boolean | string;
8894
}

src/material-experimental/mdc-button/icon-button.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ export class MatIconButton extends MatButtonBase {
5252
@Optional() @Inject(ANIMATION_MODULE_TYPE) animationMode?: string) {
5353
super(elementRef, platform, ngZone, animationMode);
5454
}
55+
56+
static ngAcceptInputType_disabled: boolean | string;
57+
static ngAcceptInputType_disableRipple: boolean | string;
5558
}
5659

5760
/**
@@ -79,4 +82,7 @@ export class MatIconAnchor extends MatAnchorBase {
7982
@Optional() @Inject(ANIMATION_MODULE_TYPE) animationMode?: string) {
8083
super(elementRef, platform, ngZone, animationMode);
8184
}
85+
86+
static ngAcceptInputType_disabled: boolean | string;
87+
static ngAcceptInputType_disableRipple: boolean | string;
8288
}

src/material-experimental/mdc-checkbox/checkbox.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,4 +349,10 @@ export class MatCheckbox implements AfterViewInit, OnDestroy, ControlValueAccess
349349
this._classes[cssClass] = active;
350350
this._changeDetectorRef.markForCheck();
351351
}
352+
353+
static ngAcceptInputType_checked: boolean | string;
354+
static ngAcceptInputType_indeterminate: boolean | string;
355+
static ngAcceptInputType_disabled: boolean | string;
356+
static ngAcceptInputType_required: boolean | string;
357+
static ngAcceptInputType_disableRipple: boolean | string;
352358
}

0 commit comments

Comments
 (0)