Skip to content

Commit c3f6892

Browse files
committed
refactor: remove mixin classes from public api
Removes the base classes that are being used to apply mixins from the public API. These classes can't really be consumed outside of Material and exposing them bloats up the public API.
1 parent a258400 commit c3f6892

Some content is hidden

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

57 files changed

+91
-295
lines changed

src/cdk/table/cell.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ export class CdkFooterCellDef implements CellDef {
4545

4646
// Boilerplate for applying mixins to CdkColumnDef.
4747
/** @docs-private */
48-
export class CdkColumnDefBase {}
49-
export const _CdkColumnDefBase: CanStickCtor & typeof CdkColumnDefBase =
48+
class CdkColumnDefBase {}
49+
const _CdkColumnDefBase: CanStickCtor & typeof CdkColumnDefBase =
5050
mixinHasStickyInput(CdkColumnDefBase);
5151

5252
/**

src/cdk/table/row.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ export abstract class BaseRowDef implements OnChanges {
7777

7878
// Boilerplate for applying mixins to CdkHeaderRowDef.
7979
/** @docs-private */
80-
export class CdkHeaderRowDefBase extends BaseRowDef {}
81-
export const _CdkHeaderRowDefBase: CanStickCtor&typeof CdkHeaderRowDefBase =
80+
class CdkHeaderRowDefBase extends BaseRowDef {}
81+
const _CdkHeaderRowDefBase: CanStickCtor&typeof CdkHeaderRowDefBase =
8282
mixinHasStickyInput(CdkHeaderRowDefBase);
8383

8484
/**
@@ -103,8 +103,8 @@ export class CdkHeaderRowDef extends _CdkHeaderRowDefBase implements CanStick, O
103103

104104
// Boilerplate for applying mixins to CdkFooterRowDef.
105105
/** @docs-private */
106-
export class CdkFooterRowDefBase extends BaseRowDef {}
107-
export const _CdkFooterRowDefBase: CanStickCtor&typeof CdkFooterRowDefBase =
106+
class CdkFooterRowDefBase extends BaseRowDef {}
107+
const _CdkFooterRowDefBase: CanStickCtor&typeof CdkFooterRowDefBase =
108108
mixinHasStickyInput(CdkFooterRowDefBase);
109109

110110
/**

src/lib/autocomplete/autocomplete.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ export class MatAutocompleteSelectedEvent {
5353

5454
// Boilerplate for applying mixins to MatAutocomplete.
5555
/** @docs-private */
56-
export class MatAutocompleteBase {}
57-
export const _MatAutocompleteMixinBase: CanDisableRippleCtor & typeof MatAutocompleteBase =
56+
class MatAutocompleteBase {}
57+
const _MatAutocompleteMixinBase: CanDisableRippleCtor & typeof MatAutocompleteBase =
5858
mixinDisableRipple(MatAutocompleteBase);
5959

6060
/** Default `mat-autocomplete` options that can be overridden. */

src/lib/badge/badge.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ let nextId = 0;
2929

3030
// Boilerplate for applying mixins to MatBadge.
3131
/** @docs-private */
32-
export class MatBadgeBase {}
32+
class MatBadgeBase {}
3333

34-
export const _MatBadgeMixinBase:
34+
const _MatBadgeMixinBase:
3535
CanDisableCtor & typeof MatBadgeBase = mixinDisabled(MatBadgeBase);
3636

3737
export type MatBadgePosition = 'above after' | 'above before' | 'below before' | 'below after';

src/lib/button-toggle/button-toggle.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,8 +348,8 @@ export class MatButtonToggleGroup implements ControlValueAccessor, OnInit, After
348348

349349
// Boilerplate for applying mixins to the MatButtonToggle class.
350350
/** @docs-private */
351-
export class MatButtonToggleBase {}
352-
export const _MatButtonToggleMixinBase: CanDisableRippleCtor & typeof MatButtonToggleBase =
351+
class MatButtonToggleBase {}
352+
const _MatButtonToggleMixinBase: CanDisableRippleCtor & typeof MatButtonToggleBase =
353353
mixinDisableRipple(MatButtonToggleBase);
354354

355355
/** Single button inside of a toggle group. */

src/lib/button/button.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,12 @@ const BUTTON_HOST_ATTRIBUTES = [
5252

5353
// Boilerplate for applying mixins to MatButton.
5454
/** @docs-private */
55-
export class MatButtonBase {
55+
class MatButtonBase {
5656
constructor(public _elementRef: ElementRef) {}
5757
}
5858

59-
export const _MatButtonMixinBase:
60-
CanDisableRippleCtor & CanDisableCtor & CanColorCtor & typeof MatButtonBase =
61-
mixinColor(mixinDisabled(mixinDisableRipple(MatButtonBase)));
59+
const _MatButtonMixinBase: CanDisableRippleCtor & CanDisableCtor & CanColorCtor &
60+
typeof MatButtonBase = mixinColor(mixinDisabled(mixinDisableRipple(MatButtonBase)));
6261

6362
/**
6463
* Material design button.

src/lib/checkbox/checkbox.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,10 @@ export class MatCheckboxChange {
8585

8686
// Boilerplate for applying mixins to MatCheckbox.
8787
/** @docs-private */
88-
export class MatCheckboxBase {
88+
class MatCheckboxBase {
8989
constructor(public _elementRef: ElementRef) {}
9090
}
91-
export const _MatCheckboxMixinBase:
91+
const _MatCheckboxMixinBase:
9292
HasTabIndexCtor &
9393
CanColorCtor &
9494
CanDisableRippleCtor &

src/lib/chips/chip-list.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ import {MatChipTextControl} from './chip-text-control';
4545

4646
// Boilerplate for applying mixins to MatChipList.
4747
/** @docs-private */
48-
export class MatChipListBase {
48+
class MatChipListBase {
4949
constructor(public _defaultErrorStateMatcher: ErrorStateMatcher,
5050
public _parentForm: NgForm,
5151
public _parentFormGroup: FormGroupDirective,
5252
/** @docs-private */
5353
public ngControl: NgControl) {}
5454
}
55-
export const _MatChipListMixinBase: CanUpdateErrorStateCtor & typeof MatChipListBase =
55+
const _MatChipListMixinBase: CanUpdateErrorStateCtor & typeof MatChipListBase =
5656
mixinErrorState(MatChipListBase);
5757

5858

src/lib/chips/chip.ts

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,12 @@ export class MatChipSelectionChange {
6363

6464
// Boilerplate for applying mixins to MatChip.
6565
/** @docs-private */
66-
export class MatChipBase {
66+
class MatChipBase {
6767
constructor(public _elementRef: ElementRef) {}
6868
}
6969

70-
export const _MatChipMixinBase:
71-
CanColorCtor & CanDisableRippleCtor & CanDisableCtor & typeof MatChipBase =
72-
mixinColor(mixinDisableRipple(mixinDisabled(MatChipBase)), 'primary');
73-
74-
const CHIP_ATTRIBUTE_NAMES = ['mat-basic-chip'];
70+
const _MatChipMixinBase: CanColorCtor & CanDisableRippleCtor & CanDisableCtor & typeof MatChipBase =
71+
mixinColor(mixinDisableRipple(mixinDisabled(MatChipBase)), 'primary');
7572

7673
/**
7774
* Dummy directive to add CSS class to chip avatar.
@@ -242,15 +239,16 @@ export class MatChip extends _MatChipMixinBase implements FocusableOption, OnDes
242239
}
243240

244241
_addHostClassName() {
245-
// Add class for the different chips
246-
for (const attr of CHIP_ATTRIBUTE_NAMES) {
247-
if (this._elementRef.nativeElement.hasAttribute(attr) ||
248-
this._elementRef.nativeElement.tagName.toLowerCase() === attr) {
249-
(this._elementRef.nativeElement as HTMLElement).classList.add(attr);
250-
return;
251-
}
242+
const basicChipAttrName = 'mat-basic-chip';
243+
const element = this._elementRef.nativeElement as HTMLElement;
244+
245+
if (element.hasAttribute(basicChipAttrName) ||
246+
element.tagName.toLowerCase() === basicChipAttrName) {
247+
element.classList.add(basicChipAttrName);
248+
return;
249+
} else {
250+
element.classList.add('mat-standard-chip');
252251
}
253-
(this._elementRef.nativeElement as HTMLElement).classList.add('mat-standard-chip');
254252
}
255253

256254
ngOnDestroy() {

src/lib/core/option/optgroup.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import {CanDisable, CanDisableCtor, mixinDisabled} from '../common-behaviors/dis
1212

1313
// Boilerplate for applying mixins to MatOptgroup.
1414
/** @docs-private */
15-
export class MatOptgroupBase { }
16-
export const _MatOptgroupMixinBase: CanDisableCtor & typeof MatOptgroupBase =
15+
class MatOptgroupBase { }
16+
const _MatOptgroupMixinBase: CanDisableCtor & typeof MatOptgroupBase =
1717
mixinDisabled(MatOptgroupBase);
1818

1919
// Counter for unique group ids.

src/lib/datepicker/datepicker.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ export const MAT_DATEPICKER_SCROLL_STRATEGY_FACTORY_PROVIDER = {
7373

7474
// Boilerplate for applying mixins to MatDatepickerContent.
7575
/** @docs-private */
76-
export class MatDatepickerContentBase {
76+
class MatDatepickerContentBase {
7777
constructor(public _elementRef: ElementRef) { }
7878
}
79-
export const _MatDatepickerContentMixinBase: CanColorCtor & typeof MatDatepickerContentBase =
79+
const _MatDatepickerContentMixinBase: CanColorCtor & typeof MatDatepickerContentBase =
8080
mixinColor(MatDatepickerContentBase);
8181

8282
/**

src/lib/form-field/form-field.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,15 @@ const outlineGapPadding = 5;
6464
* Boilerplate for applying mixins to MatFormField.
6565
* @docs-private
6666
*/
67-
export class MatFormFieldBase {
67+
class MatFormFieldBase {
6868
constructor(public _elementRef: ElementRef) { }
6969
}
7070

7171
/**
7272
* Base class to which we're applying the form field mixins.
7373
* @docs-private
7474
*/
75-
export const _MatFormFieldMixinBase: CanColorCtor & typeof MatFormFieldBase =
75+
const _MatFormFieldMixinBase: CanColorCtor & typeof MatFormFieldBase =
7676
mixinColor(MatFormFieldBase, 'primary');
7777

7878
/** Possible appearance styles for the form field. */

src/lib/icon/icon.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,10 @@ import {MatIconRegistry} from './icon-registry';
3232

3333
// Boilerplate for applying mixins to MatIcon.
3434
/** @docs-private */
35-
export class MatIconBase {
35+
class MatIconBase {
3636
constructor(public _elementRef: ElementRef) {}
3737
}
38-
export const _MatIconMixinBase: CanColorCtor & typeof MatIconBase =
39-
mixinColor(MatIconBase);
38+
const _MatIconMixinBase: CanColorCtor & typeof MatIconBase = mixinColor(MatIconBase);
4039

4140
/**
4241
* Injection token used to provide the current location to `MatIcon`.

src/lib/input/input.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@ let nextUniqueId = 0;
5252

5353
// Boilerplate for applying mixins to MatInput.
5454
/** @docs-private */
55-
export class MatInputBase {
55+
class MatInputBase {
5656
constructor(public _defaultErrorStateMatcher: ErrorStateMatcher,
5757
public _parentForm: NgForm,
5858
public _parentFormGroup: FormGroupDirective,
5959
/** @docs-private */
6060
public ngControl: NgControl) {}
6161
}
62-
export const _MatInputMixinBase: CanUpdateErrorStateCtor & typeof MatInputBase =
62+
const _MatInputMixinBase: CanUpdateErrorStateCtor & typeof MatInputBase =
6363
mixinErrorState(MatInputBase);
6464

6565
/** Directive that allows a native input to work inside a `MatFormField`. */

src/lib/list/list.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ import {takeUntil} from 'rxjs/operators';
3333

3434
// Boilerplate for applying mixins to MatList.
3535
/** @docs-private */
36-
export class MatListBase {}
37-
export const _MatListMixinBase: CanDisableRippleCtor & typeof MatListBase =
36+
class MatListBase {}
37+
const _MatListMixinBase: CanDisableRippleCtor & typeof MatListBase =
3838
mixinDisableRipple(MatListBase);
3939

4040
// Boilerplate for applying mixins to MatListItem.
4141
/** @docs-private */
42-
export class MatListItemBase {}
43-
export const _MatListItemMixinBase: CanDisableRippleCtor & typeof MatListItemBase =
42+
class MatListItemBase {}
43+
const _MatListItemMixinBase: CanDisableRippleCtor & typeof MatListItemBase =
4444
mixinDisableRipple(MatListItemBase);
4545

4646
@Component({

src/lib/list/selection-list.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ import {MatListAvatarCssMatStyler, MatListIconCssMatStyler} from './list';
5454

5555

5656
/** @docs-private */
57-
export class MatSelectionListBase {}
58-
export const _MatSelectionListMixinBase: CanDisableRippleCtor & typeof MatSelectionListBase =
57+
class MatSelectionListBase {}
58+
const _MatSelectionListMixinBase: CanDisableRippleCtor & typeof MatSelectionListBase =
5959
mixinDisableRipple(MatSelectionListBase);
6060

6161
/** @docs-private */
62-
export class MatListOptionBase {}
63-
export const _MatListOptionMixinBase: CanDisableRippleCtor & typeof MatListOptionBase =
62+
class MatListOptionBase {}
63+
const _MatListOptionMixinBase: CanDisableRippleCtor & typeof MatListOptionBase =
6464
mixinDisableRipple(MatListOptionBase);
6565

6666
/** @docs-private */

src/lib/menu/menu-item.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ import {MAT_MENU_PANEL, MatMenuPanel} from './menu-panel';
2929

3030
// Boilerplate for applying mixins to MatMenuItem.
3131
/** @docs-private */
32-
export class MatMenuItemBase {}
33-
export const _MatMenuItemMixinBase: CanDisableRippleCtor & CanDisableCtor & typeof MatMenuItemBase =
32+
class MatMenuItemBase {}
33+
const _MatMenuItemMixinBase: CanDisableRippleCtor & CanDisableCtor & typeof MatMenuItemBase =
3434
mixinDisableRipple(mixinDisabled(MatMenuItemBase));
3535

3636
/**

src/lib/paginator/paginator.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ export class PageEvent {
5656

5757
// Boilerplate for applying mixins to MatPaginator.
5858
/** @docs-private */
59-
export class MatPaginatorBase {}
60-
export const _MatPaginatorBase: CanDisableCtor & HasInitializedCtor & typeof MatPaginatorBase =
59+
class MatPaginatorBase {}
60+
const _MatPaginatorBase: CanDisableCtor & HasInitializedCtor & typeof MatPaginatorBase =
6161
mixinDisabled(mixinInitialized(MatPaginatorBase));
6262

6363
/**

src/lib/progress-bar/progress-bar.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,18 @@ import {DOCUMENT} from '@angular/common';
3131
// TODO(josephperrott): Benchpress tests.
3232
// TODO(josephperrott): Add ARIA attributes for progress bar "for".
3333

34-
// Boilerplate for applying mixins to MatProgressBar.
35-
/** @docs-private */
36-
export class MatProgressBarBase {
37-
constructor(public _elementRef: ElementRef) { }
38-
}
39-
4034
/** Last animation end data. */
4135
export interface ProgressAnimationEnd {
4236
value: number;
4337
}
4438

45-
export const _MatProgressBarMixinBase: CanColorCtor & typeof MatProgressBarBase =
39+
// Boilerplate for applying mixins to MatProgressBar.
40+
/** @docs-private */
41+
class MatProgressBarBase {
42+
constructor(public _elementRef: ElementRef) { }
43+
}
44+
45+
const _MatProgressBarMixinBase: CanColorCtor & typeof MatProgressBarBase =
4646
mixinColor(MatProgressBarBase, 'primary');
4747

4848
/**

src/lib/progress-spinner/progress-spinner.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ const BASE_STROKE_WIDTH = 10;
4040

4141
// Boilerplate for applying mixins to MatProgressSpinner.
4242
/** @docs-private */
43-
export class MatProgressSpinnerBase {
43+
class MatProgressSpinnerBase {
4444
constructor(public _elementRef: ElementRef) {}
4545
}
46-
export const _MatProgressSpinnerMixinBase: CanColorCtor & typeof MatProgressSpinnerBase =
46+
const _MatProgressSpinnerMixinBase: CanColorCtor & typeof MatProgressSpinnerBase =
4747
mixinColor(MatProgressSpinnerBase, 'primary');
4848

4949
/** Default `mat-progress-spinner` options that can be overridden. */

src/lib/radio/radio.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ export class MatRadioGroup implements AfterContentInit, ControlValueAccessor {
292292

293293
// Boilerplate for applying mixins to MatRadioButton.
294294
/** @docs-private */
295-
export class MatRadioButtonBase {
295+
class MatRadioButtonBase {
296296
// Since the disabled property is manually defined for the MatRadioButton and isn't set up in
297297
// the mixin base class. To be able to use the tabindex mixin, a disabled property must be
298298
// defined to properly work.
@@ -302,8 +302,8 @@ export class MatRadioButtonBase {
302302
}
303303
// As per Material design specifications the selection control radio should use the accent color
304304
// palette by default. https://material.io/guidelines/components/selection-controls.html
305-
export const _MatRadioButtonMixinBase:
306-
CanColorCtor & CanDisableRippleCtor & HasTabIndexCtor & typeof MatRadioButtonBase =
305+
const _MatRadioButtonMixinBase: CanColorCtor & CanDisableRippleCtor & HasTabIndexCtor &
306+
typeof MatRadioButtonBase =
307307
mixinColor(mixinDisableRipple(mixinTabIndex(MatRadioButtonBase)), 'accent');
308308

309309
/**

src/lib/select/select.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,14 +159,14 @@ export class MatSelectChange {
159159

160160
// Boilerplate for applying mixins to MatSelect.
161161
/** @docs-private */
162-
export class MatSelectBase {
162+
class MatSelectBase {
163163
constructor(public _elementRef: ElementRef,
164164
public _defaultErrorStateMatcher: ErrorStateMatcher,
165165
public _parentForm: NgForm,
166166
public _parentFormGroup: FormGroupDirective,
167167
public ngControl: NgControl) {}
168168
}
169-
export const _MatSelectMixinBase:
169+
const _MatSelectMixinBase:
170170
CanDisableCtor &
171171
HasTabIndexCtor &
172172
CanDisableRippleCtor &

src/lib/slide-toggle/slide-toggle.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@ export class MatSlideToggleChange {
6767

6868
// Boilerplate for applying mixins to MatSlideToggle.
6969
/** @docs-private */
70-
export class MatSlideToggleBase {
70+
class MatSlideToggleBase {
7171
constructor(public _elementRef: ElementRef) {}
7272
}
73-
export const _MatSlideToggleMixinBase:
73+
const _MatSlideToggleMixinBase:
7474
HasTabIndexCtor &
7575
CanColorCtor &
7676
CanDisableRippleCtor &

src/lib/slider/slider.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ export class MatSliderChange {
9191

9292
// Boilerplate for applying mixins to MatSlider.
9393
/** @docs-private */
94-
export class MatSliderBase {
94+
class MatSliderBase {
9595
constructor(public _elementRef: ElementRef) {}
9696
}
97-
export const _MatSliderMixinBase:
97+
const _MatSliderMixinBase:
9898
HasTabIndexCtor &
9999
CanColorCtor &
100100
CanDisableCtor &

0 commit comments

Comments
 (0)