Skip to content

Commit 36b4f18

Browse files
committed
refactor(material/progress-spinner): convert to standalone
Converts `material/progress-spinner` to standalone.
1 parent 8bc38ae commit 36b4f18

File tree

5 files changed

+57
-26
lines changed

5 files changed

+57
-26
lines changed

src/material/progress-spinner/module.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ import {MatProgressSpinner, MatSpinner} from './progress-spinner';
1212
import {CommonModule} from '@angular/common';
1313

1414
@NgModule({
15-
imports: [CommonModule],
15+
imports: [CommonModule, MatProgressSpinner, MatSpinner],
1616
exports: [MatProgressSpinner, MatSpinner, MatCommonModule],
17-
declarations: [MatProgressSpinner, MatSpinner],
1817
})
1918
export class MatProgressSpinnerModule {}

src/material/progress-spinner/progress-spinner.spec.ts

Lines changed: 43 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ import {MatProgressSpinner, MAT_PROGRESS_SPINNER_DEFAULT_OPTIONS} from './progre
88
describe('MDC-based MatProgressSpinner', () => {
99
beforeEach(waitForAsync(() => {
1010
TestBed.configureTestingModule({
11-
imports: [MatProgressSpinnerModule, CommonModule],
12-
declarations: [
11+
imports: [
12+
MatProgressSpinnerModule,
13+
CommonModule,
1314
BasicProgressSpinner,
1415
IndeterminateProgressSpinner,
1516
ProgressSpinnerWithValueAndBoundMode,
@@ -297,8 +298,7 @@ describe('MDC-based MatProgressSpinner', () => {
297298
it('should be able to set a default diameter', () => {
298299
TestBed.resetTestingModule()
299300
.configureTestingModule({
300-
imports: [MatProgressSpinnerModule],
301-
declarations: [BasicProgressSpinner],
301+
imports: [MatProgressSpinnerModule, BasicProgressSpinner],
302302
providers: [
303303
{
304304
provide: MAT_PROGRESS_SPINNER_DEFAULT_OPTIONS,
@@ -318,8 +318,7 @@ describe('MDC-based MatProgressSpinner', () => {
318318
it('should be able to set a default stroke width', () => {
319319
TestBed.resetTestingModule()
320320
.configureTestingModule({
321-
imports: [MatProgressSpinnerModule],
322-
declarations: [BasicProgressSpinner],
321+
imports: [MatProgressSpinnerModule, BasicProgressSpinner],
323322
providers: [
324323
{
325324
provide: MAT_PROGRESS_SPINNER_DEFAULT_OPTIONS,
@@ -339,8 +338,7 @@ describe('MDC-based MatProgressSpinner', () => {
339338
it('should be able to set a default color', () => {
340339
TestBed.resetTestingModule()
341340
.configureTestingModule({
342-
imports: [MatProgressSpinnerModule],
343-
declarations: [BasicProgressSpinner],
341+
imports: [MatProgressSpinnerModule, BasicProgressSpinner],
344342
providers: [
345343
{
346344
provide: MAT_PROGRESS_SPINNER_DEFAULT_OPTIONS,
@@ -403,24 +401,42 @@ describe('MDC-based MatProgressSpinner', () => {
403401
});
404402
});
405403

406-
@Component({template: '<mat-progress-spinner></mat-progress-spinner>'})
404+
@Component({
405+
template: '<mat-progress-spinner></mat-progress-spinner>',
406+
standalone: true,
407+
imports: [MatProgressSpinnerModule, CommonModule],
408+
})
407409
class BasicProgressSpinner {}
408410

409-
@Component({template: '<mat-progress-spinner [strokeWidth]="strokeWidth"></mat-progress-spinner>'})
411+
@Component({
412+
template: '<mat-progress-spinner [strokeWidth]="strokeWidth"></mat-progress-spinner>',
413+
standalone: true,
414+
imports: [MatProgressSpinnerModule, CommonModule],
415+
})
410416
class ProgressSpinnerCustomStrokeWidth {
411417
strokeWidth: number;
412418
}
413419

414-
@Component({template: '<mat-progress-spinner [diameter]="diameter"></mat-progress-spinner>'})
420+
@Component({
421+
template: '<mat-progress-spinner [diameter]="diameter"></mat-progress-spinner>',
422+
standalone: true,
423+
imports: [MatProgressSpinnerModule, CommonModule],
424+
})
415425
class ProgressSpinnerCustomDiameter {
416426
diameter: number;
417427
}
418428

419-
@Component({template: '<mat-progress-spinner mode="indeterminate"></mat-progress-spinner>'})
429+
@Component({
430+
template: '<mat-progress-spinner mode="indeterminate"></mat-progress-spinner>',
431+
standalone: true,
432+
imports: [MatProgressSpinnerModule, CommonModule],
433+
})
420434
class IndeterminateProgressSpinner {}
421435

422436
@Component({
423437
template: '<mat-progress-spinner [value]="value" [mode]="mode"></mat-progress-spinner>',
438+
standalone: true,
439+
imports: [MatProgressSpinnerModule, CommonModule],
424440
})
425441
class ProgressSpinnerWithValueAndBoundMode {
426442
mode = 'indeterminate';
@@ -430,6 +446,8 @@ class ProgressSpinnerWithValueAndBoundMode {
430446
@Component({
431447
template: `
432448
<mat-spinner [color]="color"></mat-spinner>`,
449+
standalone: true,
450+
imports: [MatProgressSpinnerModule, CommonModule],
433451
})
434452
class SpinnerWithColor {
435453
color: string = 'primary';
@@ -438,6 +456,8 @@ class SpinnerWithColor {
438456
@Component({
439457
template: `
440458
<mat-progress-spinner value="50" [color]="color"></mat-progress-spinner>`,
459+
standalone: true,
460+
imports: [MatProgressSpinnerModule, CommonModule],
441461
})
442462
class ProgressSpinnerWithColor {
443463
color: string = 'primary';
@@ -447,6 +467,8 @@ class ProgressSpinnerWithColor {
447467
template: `
448468
<mat-progress-spinner value="25" diameter="37" strokeWidth="11"></mat-progress-spinner>
449469
`,
470+
standalone: true,
471+
imports: [MatProgressSpinnerModule, CommonModule],
450472
})
451473
class ProgressSpinnerWithStringValues {}
452474

@@ -455,6 +477,8 @@ class ProgressSpinnerWithStringValues {}
455477
<mat-progress-spinner mode="indeterminate" [diameter]="diameter"></mat-progress-spinner>
456478
`,
457479
encapsulation: ViewEncapsulation.ShadowDom,
480+
standalone: true,
481+
imports: [MatProgressSpinnerModule, CommonModule],
458482
})
459483
class IndeterminateSpinnerInShadowDom {
460484
diameter: number;
@@ -469,6 +493,8 @@ class IndeterminateSpinnerInShadowDom {
469493
}
470494
`,
471495
encapsulation: ViewEncapsulation.ShadowDom,
496+
standalone: true,
497+
imports: [MatProgressSpinnerModule, CommonModule],
472498
})
473499
class IndeterminateSpinnerInShadowDomWithNgIf {
474500
@ViewChild(MatProgressSpinner, {read: ElementRef})
@@ -477,5 +503,9 @@ class IndeterminateSpinnerInShadowDomWithNgIf {
477503
diameter: number;
478504
}
479505

480-
@Component({template: '<mat-spinner mode="determinate"></mat-spinner>'})
506+
@Component({
507+
template: '<mat-spinner mode="determinate"></mat-spinner>',
508+
standalone: true,
509+
imports: [MatProgressSpinnerModule, CommonModule],
510+
})
481511
class SpinnerWithMode {}

src/material/progress-spinner/progress-spinner.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
} from '@angular/core';
2121
import {ThemePalette} from '@angular/material/core';
2222
import {ANIMATION_MODULE_TYPE} from '@angular/platform-browser/animations';
23+
import {NgTemplateOutlet} from '@angular/common';
2324

2425
/** Possible mode for a progress spinner. */
2526
export type ProgressSpinnerMode = 'determinate' | 'indeterminate';
@@ -86,6 +87,8 @@ const BASE_STROKE_WIDTH = 10;
8687
styleUrls: ['progress-spinner.css'],
8788
changeDetection: ChangeDetectionStrategy.OnPush,
8889
encapsulation: ViewEncapsulation.None,
90+
standalone: true,
91+
imports: [NgTemplateOutlet],
8992
})
9093
export class MatProgressSpinner {
9194
/** Whether the _mat-animation-noopable class should be applied, disabling animations. */

src/material/progress-spinner/testing/progress-spinner-harness.spec.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ describe('MatProgressSpinnerHarness', () => {
1111

1212
beforeEach(async () => {
1313
await TestBed.configureTestingModule({
14-
imports: [MatProgressSpinnerModule],
15-
declarations: [ProgressSpinnerHarnessTest],
14+
imports: [MatProgressSpinnerModule, ProgressSpinnerHarnessTest],
1615
}).compileComponents();
1716

1817
fixture = TestBed.createComponent(ProgressSpinnerHarnessTest);
@@ -27,18 +26,16 @@ describe('MatProgressSpinnerHarness', () => {
2726

2827
it('should get the value', async () => {
2928
fixture.componentInstance.value = 50;
30-
const [determinate, indeterminate, impliedIndeterminate] = await loader.getAllHarnesses(
31-
MatProgressSpinnerHarness,
32-
);
29+
const [determinate, indeterminate, impliedIndeterminate] =
30+
await loader.getAllHarnesses(MatProgressSpinnerHarness);
3331
expect(await determinate.getValue()).toBe(50);
3432
expect(await indeterminate.getValue()).toBe(null);
3533
expect(await impliedIndeterminate.getValue()).toBe(null);
3634
});
3735

3836
it('should get the mode', async () => {
39-
const [determinate, indeterminate, impliedIndeterminate] = await loader.getAllHarnesses(
40-
MatProgressSpinnerHarness,
41-
);
37+
const [determinate, indeterminate, impliedIndeterminate] =
38+
await loader.getAllHarnesses(MatProgressSpinnerHarness);
4239
expect(await determinate.getMode()).toBe('determinate');
4340
expect(await indeterminate.getMode()).toBe('indeterminate');
4441
expect(await impliedIndeterminate.getMode()).toBe('indeterminate');
@@ -51,6 +48,8 @@ describe('MatProgressSpinnerHarness', () => {
5148
<mat-progress-spinner mode="indeterminate"></mat-progress-spinner>
5249
<mat-spinner></mat-spinner>
5350
`,
51+
standalone: true,
52+
imports: [MatProgressSpinnerModule],
5453
})
5554
class ProgressSpinnerHarnessTest {
5655
value: number;

tools/public_api_guard/material/progress-spinner.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import { ElementRef } from '@angular/core';
88
import * as i0 from '@angular/core';
9-
import * as i2 from '@angular/common';
9+
import * as i1 from '@angular/common';
1010
import * as i3 from '@angular/material/core';
1111
import { InjectionToken } from '@angular/core';
1212
import { ThemePalette } from '@angular/material/core';
@@ -45,7 +45,7 @@ export class MatProgressSpinner {
4545
set value(v: number);
4646
_viewBox(): string;
4747
// (undocumented)
48-
static ɵcmp: i0.ɵɵComponentDeclaration<MatProgressSpinner, "mat-progress-spinner, mat-spinner", ["matProgressSpinner"], { "color": { "alias": "color"; "required": false; }; "mode": { "alias": "mode"; "required": false; }; "value": { "alias": "value"; "required": false; }; "diameter": { "alias": "diameter"; "required": false; }; "strokeWidth": { "alias": "strokeWidth"; "required": false; }; }, {}, never, never, false, never>;
48+
static ɵcmp: i0.ɵɵComponentDeclaration<MatProgressSpinner, "mat-progress-spinner, mat-spinner", ["matProgressSpinner"], { "color": { "alias": "color"; "required": false; }; "mode": { "alias": "mode"; "required": false; }; "value": { "alias": "value"; "required": false; }; "diameter": { "alias": "diameter"; "required": false; }; "strokeWidth": { "alias": "strokeWidth"; "required": false; }; }, {}, never, never, true, never>;
4949
// (undocumented)
5050
static ɵfac: i0.ɵɵFactoryDeclaration<MatProgressSpinner, [null, { optional: true; }, null]>;
5151
}
@@ -65,7 +65,7 @@ export class MatProgressSpinnerModule {
6565
// (undocumented)
6666
static ɵinj: i0.ɵɵInjectorDeclaration<MatProgressSpinnerModule>;
6767
// (undocumented)
68-
static ɵmod: i0.ɵɵNgModuleDeclaration<MatProgressSpinnerModule, [typeof i1.MatProgressSpinner, typeof i1.MatProgressSpinner], [typeof i2.CommonModule], [typeof i1.MatProgressSpinner, typeof i1.MatProgressSpinner, typeof i3.MatCommonModule]>;
68+
static ɵmod: i0.ɵɵNgModuleDeclaration<MatProgressSpinnerModule, never, [typeof i1.CommonModule, typeof i2.MatProgressSpinner, typeof i2.MatProgressSpinner], [typeof i2.MatProgressSpinner, typeof i2.MatProgressSpinner, typeof i3.MatCommonModule]>;
6969
}
7070

7171
// @public @deprecated (undocumented)

0 commit comments

Comments
 (0)