Skip to content

Commit 8cafc89

Browse files
committed
refactor(material/core): convert to standalone
Converts `material/core` to standalone.
1 parent af4a9a7 commit 8cafc89

File tree

13 files changed

+51
-31
lines changed

13 files changed

+51
-31
lines changed

src/material/core/line/line.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {MatCommonModule} from '../common-behaviors/common-module';
1818
@Directive({
1919
selector: '[mat-line], [matLine]',
2020
host: {'class': 'mat-line'},
21+
standalone: true,
2122
})
2223
export class MatLine {}
2324

@@ -51,8 +52,7 @@ function setClass(element: ElementRef<HTMLElement>, className: string, isAdd: bo
5152
}
5253

5354
@NgModule({
54-
imports: [MatCommonModule],
55+
imports: [MatCommonModule, MatLine],
5556
exports: [MatLine, MatCommonModule],
56-
declarations: [MatLine],
5757
})
5858
export class MatLineModule {}

src/material/core/option/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@ import {MatOption} from './option';
1414
import {MatOptgroup} from './optgroup';
1515

1616
@NgModule({
17-
imports: [MatRippleModule, MatCommonModule, MatPseudoCheckboxModule],
17+
imports: [MatRippleModule, MatCommonModule, MatPseudoCheckboxModule, MatOption, MatOptgroup],
1818
exports: [MatOption, MatOptgroup],
19-
declarations: [MatOption, MatOptgroup],
2019
})
2120
export class MatOptionModule {}
2221

src/material/core/option/optgroup.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ export const MAT_OPTGROUP = new InjectionToken<MatOptgroup>('MatOptgroup');
6565
'[attr.aria-labelledby]': '_inert ? null : _labelId',
6666
},
6767
providers: [{provide: MAT_OPTGROUP, useExisting: MatOptgroup}],
68+
standalone: true,
6869
})
6970
export class MatOptgroup {
7071
/** Label for the option group. */

src/material/core/option/option.spec.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ import {MatOption, MatOptionModule, MAT_OPTION_PARENT_COMPONENT} from './index';
1313
describe('MatOption component', () => {
1414
beforeEach(waitForAsync(() => {
1515
TestBed.configureTestingModule({
16-
imports: [MatOptionModule],
17-
declarations: [BasicOption],
16+
imports: [MatOptionModule, BasicOption],
1817
}).compileComponents();
1918
}));
2019

@@ -215,8 +214,7 @@ describe('MatOption component', () => {
215214
beforeEach(waitForAsync(() => {
216215
TestBed.resetTestingModule();
217216
TestBed.configureTestingModule({
218-
imports: [MatOptionModule],
219-
declarations: [InsideGroup],
217+
imports: [MatOptionModule, InsideGroup],
220218
providers: [
221219
{
222220
provide: MAT_OPTION_PARENT_COMPONENT,
@@ -245,6 +243,8 @@ describe('MatOption component', () => {
245243

246244
@Component({
247245
template: `<mat-option [id]="id" [disabled]="disabled"></mat-option>`,
246+
standalone: true,
247+
imports: [MatOptionModule],
248248
})
249249
class BasicOption {
250250
disabled: boolean;
@@ -257,5 +257,7 @@ class BasicOption {
257257
<mat-option>Option</mat-option>
258258
</mat-optgroup>
259259
`,
260+
standalone: true,
261+
imports: [MatOptionModule],
260262
})
261263
class InsideGroup {}

src/material/core/option/option.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ import {
2828
import {Subject} from 'rxjs';
2929
import {MAT_OPTGROUP, MatOptgroup} from './optgroup';
3030
import {MatOptionParentComponent, MAT_OPTION_PARENT_COMPONENT} from './option-parent';
31+
import {MatRipple} from '../ripple/ripple';
32+
import {MatPseudoCheckbox} from '../selection/pseudo-checkbox/pseudo-checkbox';
3133

3234
/**
3335
* Option IDs need to be unique across components, so this counter exists outside of
@@ -77,6 +79,8 @@ export class MatOptionSelectionChange<T = any> {
7779
templateUrl: 'option.html',
7880
encapsulation: ViewEncapsulation.None,
7981
changeDetection: ChangeDetectionStrategy.OnPush,
82+
standalone: true,
83+
imports: [MatPseudoCheckbox, MatRipple],
8084
})
8185
export class MatOption<T = any> implements FocusableOption, AfterViewChecked, OnDestroy {
8286
private _selected = false;

src/material/core/ripple/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ export * from './ripple-ref';
1515
export * from './ripple-renderer';
1616

1717
@NgModule({
18-
imports: [MatCommonModule],
18+
imports: [MatCommonModule, MatRipple],
1919
exports: [MatRipple, MatCommonModule],
20-
declarations: [MatRipple],
2120
})
2221
export class MatRippleModule {}

src/material/core/ripple/ripple.spec.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ describe('MatRipple', () => {
3737

3838
beforeEach(() => {
3939
TestBed.configureTestingModule({
40-
imports: [MatRippleModule],
41-
declarations: [
40+
imports: [
41+
MatRippleModule,
4242
BasicRippleContainer,
4343
RippleContainerWithInputBindings,
4444
RippleContainerWithoutBindings,
@@ -511,8 +511,7 @@ describe('MatRipple', () => {
511511
// The testing module has been initialized in the root describe group for the ripples.
512512
TestBed.resetTestingModule();
513513
TestBed.configureTestingModule({
514-
imports: [MatRippleModule, ...extraImports],
515-
declarations: [testComponent],
514+
imports: [MatRippleModule, ...extraImports, testComponent],
516515
providers: [{provide: MAT_RIPPLE_GLOBAL_OPTIONS, useValue: rippleConfig}],
517516
});
518517

@@ -612,8 +611,7 @@ describe('MatRipple', () => {
612611
beforeEach(() => {
613612
TestBed.resetTestingModule();
614613
TestBed.configureTestingModule({
615-
imports: [NoopAnimationsModule, MatRippleModule],
616-
declarations: [BasicRippleContainer],
614+
imports: [NoopAnimationsModule, MatRippleModule, BasicRippleContainer],
617615
});
618616

619617
fixture = TestBed.createComponent(BasicRippleContainer);
@@ -839,6 +837,8 @@ describe('MatRipple', () => {
839837
style="position: relative; width:300px; height:200px;">
840838
</div>
841839
`,
840+
standalone: true,
841+
imports: [MatRippleModule],
842842
})
843843
class BasicRippleContainer {
844844
@ViewChild('ripple') ripple: MatRipple;
@@ -857,6 +857,8 @@ class BasicRippleContainer {
857857
</div>
858858
<div class="alternateTrigger"></div>
859859
`,
860+
standalone: true,
861+
imports: [MatRippleModule],
860862
})
861863
class RippleContainerWithInputBindings {
862864
animationConfig: RippleAnimationConfig;
@@ -870,11 +872,15 @@ class RippleContainerWithInputBindings {
870872

871873
@Component({
872874
template: `<div id="container" #ripple="matRipple" matRipple></div>`,
875+
standalone: true,
876+
imports: [MatRippleModule],
873877
})
874878
class RippleContainerWithoutBindings {}
875879

876880
@Component({
877881
template: `@if (!isDestroyed) {<div id="container" matRipple></div>}`,
882+
standalone: true,
883+
imports: [MatRippleModule],
878884
})
879885
class RippleContainerWithNgIf {
880886
@ViewChild(MatRipple) ripple: MatRipple;
@@ -885,13 +891,17 @@ class RippleContainerWithNgIf {
885891
styles: [`* { transition: none !important; }`],
886892
template: `<div id="container" matRipple></div>`,
887893
encapsulation: ViewEncapsulation.None,
894+
standalone: true,
895+
imports: [MatRippleModule],
888896
})
889897
class RippleCssTransitionNone {}
890898

891899
@Component({
892900
styles: [`* { transition-duration: 0ms !important; }`],
893901
template: `<div id="container" matRipple></div>`,
894902
encapsulation: ViewEncapsulation.None,
903+
standalone: true,
904+
imports: [MatRippleModule],
895905
})
896906
class RippleCssTransitionDurationZero {}
897907

@@ -901,6 +911,8 @@ class RippleCssTransitionDurationZero {}
901911
<div (click)="show = false" matRipple>Click to remove this element.</div>
902912
}
903913
`,
914+
standalone: true,
915+
imports: [MatRippleModule],
904916
})
905917
class RippleWithDomRemovalOnClick {
906918
show = true;

src/material/core/ripple/ripple.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export const MAT_RIPPLE_GLOBAL_OPTIONS = new InjectionToken<RippleGlobalOptions>
5656
'class': 'mat-ripple',
5757
'[class.mat-ripple-unbounded]': 'unbounded',
5858
},
59+
standalone: true,
5960
})
6061
export class MatRipple implements OnInit, OnDestroy, RippleTarget {
6162
/** Custom color for all ripples. */

src/material/core/selection/pseudo-checkbox/pseudo-checkbox-module.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ import {MatPseudoCheckbox} from './pseudo-checkbox';
1111
import {MatCommonModule} from '../../common-behaviors/common-module';
1212

1313
@NgModule({
14-
imports: [MatCommonModule],
14+
imports: [MatCommonModule, MatPseudoCheckbox],
1515
exports: [MatPseudoCheckbox],
16-
declarations: [MatPseudoCheckbox],
1716
})
1817
export class MatPseudoCheckboxModule {}

src/material/core/selection/pseudo-checkbox/pseudo-checkbox.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export type MatPseudoCheckboxState = 'unchecked' | 'checked' | 'indeterminate';
5050
'[class.mat-pseudo-checkbox-full]': 'appearance === "full"',
5151
'[class._mat-animation-noopable]': '_animationMode === "NoopAnimations"',
5252
},
53+
standalone: true,
5354
})
5455
export class MatPseudoCheckbox {
5556
/** Display state of the checkbox. */

0 commit comments

Comments
 (0)