Skip to content

Commit d1366ba

Browse files
crisbetommalerba
authored andcommitted
refactor: remove mixin classes from public api (#15743)
* 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. * fix experimental checkbox
1 parent 07a16de commit d1366ba

Some content is hidden

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

58 files changed

+91
-300
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/material-experimental/mdc-checkbox/public-api.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@ export {
1717
MatCheckboxClickAction,
1818
MatCheckboxRequiredValidator,
1919
_MatCheckboxRequiredValidatorModule,
20-
/**
21-
* @deprecated
22-
* @breaking-change 9.0.0
23-
*/
24-
MatCheckboxBase,
2520
/**
2621
* @deprecated
2722
* @breaking-change 9.0.0

src/material/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/material/badge/badge.ts

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

2929
// Boilerplate for applying mixins to MatBadge.
3030
/** @docs-private */
31-
export class MatBadgeBase {}
31+
class MatBadgeBase {}
3232

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

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

src/material/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/material/button/button.ts

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

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

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

6261
/**
6362
* Material design button.

src/material/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/material/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/material/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() {

0 commit comments

Comments
 (0)