Skip to content

Commit 5242169

Browse files
authored
refactor(multiple): remove focus indicators structural styles from core (angular#29804)
* refactor(multiple): remove focus indicators structural styles from core * fixup! refactor(multiple): remove focus indicators structural styles from core * fixup! refactor(multiple): remove focus indicators structural styles from core
1 parent 49308cd commit 5242169

File tree

20 files changed

+71
-11
lines changed

20 files changed

+71
-11
lines changed

src/material/button-toggle/button-toggle.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ import {
3434
} from '@angular/core';
3535
import {Direction, Directionality} from '@angular/cdk/bidi';
3636
import {ControlValueAccessor, NG_VALUE_ACCESSOR} from '@angular/forms';
37-
import {MatRipple, MatPseudoCheckbox} from '@angular/material/core';
37+
import {MatRipple, MatPseudoCheckbox, _StructuralStylesLoader} from '@angular/material/core';
38+
import {_CdkPrivateStyleLoader} from '@angular/cdk/private';
3839

3940
/**
4041
* @deprecated No longer used.
@@ -668,6 +669,7 @@ export class MatButtonToggle implements OnInit, AfterViewInit, OnDestroy {
668669
constructor(...args: unknown[]);
669670

670671
constructor() {
672+
inject(_CdkPrivateStyleLoader).load(_StructuralStylesLoader);
671673
const toggleGroup = inject<MatButtonToggleGroup>(MAT_BUTTON_TOGGLE_GROUP, {optional: true})!;
672674
const defaultTabIndex = inject(new HostAttributeToken('tabindex'), {optional: true});
673675
const defaultOptions = inject<MatButtonToggleDefaultOptions>(

src/material/button/button-base.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ import {
2222
OnDestroy,
2323
OnInit,
2424
} from '@angular/core';
25-
import {MatRippleLoader, ThemePalette} from '@angular/material/core';
25+
import {_StructuralStylesLoader, MatRippleLoader, ThemePalette} from '@angular/material/core';
26+
import {_CdkPrivateStyleLoader} from '@angular/cdk/private';
2627

2728
/** Object that can be used to configure the default options for the button component. */
2829
export interface MatButtonConfig {
@@ -156,6 +157,7 @@ export class MatButtonBase implements AfterViewInit, OnDestroy {
156157
constructor(...args: unknown[]);
157158

158159
constructor() {
160+
inject(_CdkPrivateStyleLoader).load(_StructuralStylesLoader);
159161
const config = inject(MAT_BUTTON_CONFIG, {optional: true});
160162
const element = this._elementRef.nativeElement;
161163
const classList = (element as HTMLElement).classList;

src/material/checkbox/checkbox.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,13 @@ import {
3636
ValidationErrors,
3737
Validator,
3838
} from '@angular/forms';
39-
import {MatRipple, _MatInternalFormField} from '@angular/material/core';
39+
import {MatRipple, _MatInternalFormField, _StructuralStylesLoader} from '@angular/material/core';
4040
import {
4141
MAT_CHECKBOX_DEFAULT_OPTIONS,
4242
MAT_CHECKBOX_DEFAULT_OPTIONS_FACTORY,
4343
MatCheckboxDefaultOptions,
4444
} from './checkbox-config';
45+
import {_CdkPrivateStyleLoader} from '@angular/cdk/private';
4546

4647
/**
4748
* Represents the different states that require custom transitions between them.
@@ -250,6 +251,7 @@ export class MatCheckbox
250251
constructor(...args: unknown[]);
251252

252253
constructor() {
254+
inject(_CdkPrivateStyleLoader).load(_StructuralStylesLoader);
253255
const tabIndex = inject(new HostAttributeToken('tabindex'), {optional: true});
254256
this._options = this._options || defaults;
255257
this.color = this._options.color || defaults.color;

src/material/chips/chip-action.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import {
1616
} from '@angular/core';
1717
import {ENTER, SPACE} from '@angular/cdk/keycodes';
1818
import {MAT_CHIP} from './tokens';
19+
import {_CdkPrivateStyleLoader} from '@angular/cdk/private';
20+
import {_StructuralStylesLoader} from '@angular/material/core';
1921

2022
/**
2123
* Section within a chip.
@@ -94,6 +96,7 @@ export class MatChipAction {
9496
constructor(...args: unknown[]);
9597

9698
constructor() {
99+
inject(_CdkPrivateStyleLoader).load(_StructuralStylesLoader);
97100
if (this._elementRef.nativeElement.nodeName === 'BUTTON') {
98101
this._elementRef.nativeElement.setAttribute('type', 'button');
99102
}

src/material/chips/chip.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import {
3535
inject,
3636
} from '@angular/core';
3737
import {
38+
_StructuralStylesLoader,
3839
MAT_RIPPLE_GLOBAL_OPTIONS,
3940
MatRippleLoader,
4041
RippleGlobalOptions,
@@ -43,6 +44,7 @@ import {Subject, Subscription, merge} from 'rxjs';
4344
import {MatChipAction} from './chip-action';
4445
import {MatChipAvatar, MatChipRemove, MatChipTrailingIcon} from './chip-icons';
4546
import {MAT_CHIP, MAT_CHIP_AVATAR, MAT_CHIP_REMOVE, MAT_CHIP_TRAILING_ICON} from './tokens';
47+
import {_CdkPrivateStyleLoader} from '@angular/cdk/private';
4648

4749
let uid = 0;
4850

@@ -244,6 +246,7 @@ export class MatChip implements OnInit, AfterViewInit, AfterContentInit, DoCheck
244246
constructor(...args: unknown[]);
245247

246248
constructor() {
249+
inject(_CdkPrivateStyleLoader).load(_StructuralStylesLoader);
247250
const animationMode = inject(ANIMATION_MODULE_TYPE, {optional: true});
248251
this._animationsDisabled = animationMode === 'NoopAnimations';
249252
this._monitorFocus();

src/material/core/_core.scss

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@
22
@use './tokens/m2/mat/app' as tokens-mat-app;
33
@use './tokens/token-utils';
44
@use './style/elevation';
5-
@use './focus-indicators/private';
65

76
// Mixin that renders all of the core styles that are not theme-dependent.
87
@mixin core() {
98
@include cdk.a11y-visually-hidden();
10-
@include private.structural-styling();
119
}
1210

1311
// Emits the mat-app-background CSS class. This predefined class sets the

src/material/core/option/option.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ import {MAT_OPTGROUP, MatOptgroup} from './optgroup';
3131
import {MatOptionParentComponent, MAT_OPTION_PARENT_COMPONENT} from './option-parent';
3232
import {MatRipple} from '../ripple/ripple';
3333
import {MatPseudoCheckbox} from '../selection/pseudo-checkbox/pseudo-checkbox';
34+
import {_StructuralStylesLoader} from '../focus-indicators/structural-styles';
35+
import {_CdkPrivateStyleLoader} from '@angular/cdk/private';
3436

3537
/**
3638
* Option IDs need to be unique across components, so this counter exists outside of
@@ -144,6 +146,7 @@ export class MatOption<T = any> implements FocusableOption, AfterViewChecked, On
144146

145147
constructor(...args: unknown[]);
146148
constructor() {
149+
inject(_CdkPrivateStyleLoader).load(_StructuralStylesLoader);
147150
this._signalDisableRipple = !!this._parent && isSignal(this._parent.disableRipple);
148151
}
149152

src/material/core/public-api.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export * from './animation/animation';
1111
export * from './common-behaviors/index';
1212
export * from './datetime/index';
1313
export * from './error/error-options';
14+
export * from './focus-indicators/structural-styles';
1415
export * from './line/line';
1516
export * from './option/index';
1617
export * from './private/index';

src/material/datepicker/calendar-body.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ import {
2525
Injector,
2626
} from '@angular/core';
2727
import {NgClass} from '@angular/common';
28+
import {_CdkPrivateStyleLoader} from '@angular/cdk/private';
29+
import {_StructuralStylesLoader} from '@angular/material/core';
2830

2931
/** Extra CSS classes that can be associated with a calendar cell. */
3032
export type MatCalendarCellCssClasses = string | string[] | Set<string> | {[key: string]: any};
@@ -208,6 +210,7 @@ export class MatCalendarBody<D = any> implements OnChanges, OnDestroy, AfterView
208210
constructor(...args: unknown[]);
209211

210212
constructor() {
213+
inject(_CdkPrivateStyleLoader).load(_StructuralStylesLoader);
211214
this._ngZone.runOutsideAngular(() => {
212215
const element = this._elementRef.nativeElement;
213216

src/material/expansion/expansion-panel-header.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ import {
3232
MatExpansionPanelDefaultOptions,
3333
MAT_EXPANSION_PANEL_DEFAULT_OPTIONS,
3434
} from './expansion-panel';
35+
import {_CdkPrivateStyleLoader} from '@angular/cdk/private';
36+
import {_StructuralStylesLoader} from '@angular/material/core';
3537

3638
/**
3739
* Header element of a `<mat-expansion-panel>`.
@@ -73,6 +75,7 @@ export class MatExpansionPanelHeader implements AfterViewInit, OnDestroy, Focusa
7375
constructor(...args: unknown[]);
7476

7577
constructor() {
78+
inject(_CdkPrivateStyleLoader).load(_StructuralStylesLoader);
7679
const panel = this.panel;
7780
const defaultOptions = inject<MatExpansionPanelDefaultOptions>(
7881
MAT_EXPANSION_PANEL_DEFAULT_OPTIONS,

0 commit comments

Comments
 (0)