Skip to content

Commit f958318

Browse files
authored
fix(material/progress-spinner): remove dependency on legacy progress spinner (#25583)
Fixes that the non-legacy progress spinner was depending on the legacy version.
1 parent c5c8e64 commit f958318

23 files changed

+132
-162
lines changed

src/components-examples/material/table/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ ng_module(
2424
"//src/material/legacy-checkbox",
2525
"//src/material/legacy-input",
2626
"//src/material/legacy-paginator",
27-
"//src/material/progress-spinner",
27+
"//src/material/legacy-progress-spinner",
2828
"//src/material/sort",
2929
"//src/material/table",
3030
"//src/material/table/testing",

src/material/legacy-progress-spinner/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ ng_module(
2323
"//src/cdk/platform",
2424
"//src/cdk/scrolling",
2525
"//src/material/core",
26+
"//src/material/progress-spinner",
2627
"@npm//@angular/animations",
2728
"@npm//@angular/common",
2829
"@npm//@angular/core",

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

Lines changed: 9 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import {
1515
Component,
1616
ElementRef,
1717
Inject,
18-
InjectionToken,
1918
Input,
2019
Optional,
2120
ViewEncapsulation,
@@ -24,17 +23,15 @@ import {
2423
OnDestroy,
2524
NgZone,
2625
} from '@angular/core';
27-
import {CanColor, mixinColor, ThemePalette} from '@angular/material/core';
26+
import {CanColor, mixinColor} from '@angular/material/core';
2827
import {ANIMATION_MODULE_TYPE} from '@angular/platform-browser/animations';
28+
import {
29+
MatProgressSpinnerDefaultOptions,
30+
MAT_PROGRESS_SPINNER_DEFAULT_OPTIONS,
31+
ProgressSpinnerMode,
32+
} from '@angular/material/progress-spinner';
2933
import {Subscription} from 'rxjs';
3034

31-
/**
32-
* Possible mode for a progress spinner.
33-
* @deprecated Use `ProgressSpinnerMode` from `@angular/material/progress-spinner` instead. See https://material.angular.io/guide/mdc-migration for information about migrating.
34-
* @breaking-change 17.0.0
35-
*/
36-
export type LegacyProgressSpinnerMode = 'determinate' | 'indeterminate';
37-
3835
/**
3936
* Base reference size of the spinner.
4037
* @docs-private
@@ -56,48 +53,6 @@ const _MatProgressSpinnerBase = mixinColor(
5653
'primary',
5754
);
5855

59-
/**
60-
* Default `mat-progress-spinner` options that can be overridden.
61-
* @deprecated Use `MatProgressSpinnerDefaultOptions` from `@angular/material/progress-spinner` instead. See https://material.angular.io/guide/mdc-migration for information about migrating.
62-
* @breaking-change 17.0.0
63-
*/
64-
export interface MatLegacyProgressSpinnerDefaultOptions {
65-
/** Default color of the spinner. */
66-
color?: ThemePalette;
67-
/** Diameter of the spinner. */
68-
diameter?: number;
69-
/** Width of the spinner's stroke. */
70-
strokeWidth?: number;
71-
/**
72-
* Whether the animations should be force to be enabled, ignoring if the current environment is
73-
* using NoopAnimationsModule.
74-
*/
75-
_forceAnimations?: boolean;
76-
}
77-
78-
/**
79-
* Injection token to be used to override the default options for `mat-progress-spinner`.
80-
* @deprecated Use `MAT_PROGRESS_SPINNER_DEFAULT_OPTIONS` from `@angular/material/progress-spinner` instead. See https://material.angular.io/guide/mdc-migration for information about migrating.
81-
* @breaking-change 17.0.0
82-
*/
83-
export const MAT_LEGACY_PROGRESS_SPINNER_DEFAULT_OPTIONS =
84-
new InjectionToken<MatLegacyProgressSpinnerDefaultOptions>(
85-
'mat-progress-spinner-default-options',
86-
{
87-
providedIn: 'root',
88-
factory: MAT_LEGACY_PROGRESS_SPINNER_DEFAULT_OPTIONS_FACTORY,
89-
},
90-
);
91-
92-
/**
93-
* @docs-private
94-
* @deprecated Use `MAT_PROGRESS_SPINNER_DEFAULT_OPTIONS_FACTORY` from `@angular/material/progress-spinner` instead. See https://material.angular.io/guide/mdc-migration for information about migrating.
95-
* @breaking-change 17.0.0
96-
*/
97-
export function MAT_LEGACY_PROGRESS_SPINNER_DEFAULT_OPTIONS_FACTORY(): MatLegacyProgressSpinnerDefaultOptions {
98-
return {diameter: BASE_SIZE};
99-
}
100-
10156
// .0001 percentage difference is necessary in order to avoid unwanted animation frames
10257
// for example because the animation duration is 4 seconds, .1% accounts to 4ms
10358
// which are enough to see the flicker described in
@@ -210,7 +165,7 @@ export class MatLegacyProgressSpinner
210165
}
211166

212167
/** Mode of the progress circle */
213-
@Input() mode: LegacyProgressSpinnerMode = 'determinate';
168+
@Input() mode: ProgressSpinnerMode = 'determinate';
214169

215170
/** Value of the progress circle. */
216171
@Input()
@@ -226,8 +181,8 @@ export class MatLegacyProgressSpinner
226181
_platform: Platform,
227182
@Optional() @Inject(DOCUMENT) private _document: any,
228183
@Optional() @Inject(ANIMATION_MODULE_TYPE) animationMode: string,
229-
@Inject(MAT_LEGACY_PROGRESS_SPINNER_DEFAULT_OPTIONS)
230-
defaults?: MatLegacyProgressSpinnerDefaultOptions,
184+
@Inject(MAT_PROGRESS_SPINNER_DEFAULT_OPTIONS)
185+
defaults?: MatProgressSpinnerDefaultOptions,
231186
/**
232187
* @deprecated `changeDetectorRef`, `viewportRuler` and `ngZone`
233188
* parameters to become required.

src/material/legacy-progress-spinner/public-api.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@
99
import {MatLegacyProgressSpinner} from './progress-spinner';
1010

1111
export {MatLegacyProgressSpinnerModule} from './progress-spinner-module';
12+
export {MatLegacyProgressSpinner} from './progress-spinner';
13+
1214
export {
13-
MatLegacyProgressSpinner,
14-
MAT_LEGACY_PROGRESS_SPINNER_DEFAULT_OPTIONS,
15-
LegacyProgressSpinnerMode,
16-
MatLegacyProgressSpinnerDefaultOptions,
17-
MAT_LEGACY_PROGRESS_SPINNER_DEFAULT_OPTIONS_FACTORY,
18-
} from './progress-spinner';
15+
MAT_PROGRESS_SPINNER_DEFAULT_OPTIONS as MAT_LEGACY_PROGRESS_SPINNER_DEFAULT_OPTIONS,
16+
MatProgressSpinnerDefaultOptions as MatLegacyProgressSpinnerDefaultOptions,
17+
MAT_PROGRESS_SPINNER_DEFAULT_OPTIONS_FACTORY as MAT_LEGACY_PROGRESS_SPINNER_DEFAULT_OPTIONS_FACTORY,
18+
ProgressSpinnerMode as LegacyProgressSpinnerMode,
19+
} from '@angular/material/progress-spinner';
1920

2021
/**
2122
* @deprecated Import Progress Spinner instead. Note that the

src/material/legacy-progress-spinner/testing/BUILD.bazel

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ ts_library(
1212
"//src/cdk/coercion",
1313
"//src/cdk/testing",
1414
"//src/material/legacy-progress-spinner",
15+
"//src/material/progress-spinner/testing",
1516
],
1617
)
1718

@@ -20,28 +21,13 @@ filegroup(
2021
srcs = glob(["**/*.ts"]),
2122
)
2223

23-
ng_test_library(
24-
name = "harness_tests_lib",
25-
srcs = ["shared.spec.ts"],
26-
deps = [
27-
":testing",
28-
"//src/cdk/testing",
29-
"//src/cdk/testing/testbed",
30-
"//src/material/legacy-progress-spinner",
31-
"@npm//@angular/platform-browser",
32-
],
33-
)
34-
3524
ng_test_library(
3625
name = "unit_tests_lib",
37-
srcs = glob(
38-
["**/*.spec.ts"],
39-
exclude = ["shared.spec.ts"],
40-
),
26+
srcs = glob(["**/*.spec.ts"]),
4127
deps = [
42-
":harness_tests_lib",
4328
":testing",
4429
"//src/material/legacy-progress-spinner",
30+
"//src/material/progress-spinner/testing:harness_tests_lib",
4531
],
4632
)
4733

src/material/legacy-progress-spinner/testing/progress-spinner-harness-filters.ts

Lines changed: 0 additions & 16 deletions
This file was deleted.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {MatLegacyProgressSpinnerModule} from '@angular/material/legacy-progress-spinner';
2-
import {runHarnessTests} from '@angular/material/legacy-progress-spinner/testing/shared.spec';
2+
import {runHarnessTests} from '@angular/material/progress-spinner/testing/shared.spec';
33
import {MatLegacyProgressSpinnerHarness} from './progress-spinner-harness';
44

55
describe('Non-MDC-based MatProgressSpinnerHarness', () => {
6-
runHarnessTests(MatLegacyProgressSpinnerModule, MatLegacyProgressSpinnerHarness);
6+
runHarnessTests(MatLegacyProgressSpinnerModule, MatLegacyProgressSpinnerHarness as any);
77
});

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import {coerceNumberProperty} from '@angular/cdk/coercion';
1010
import {ComponentHarness, HarnessPredicate} from '@angular/cdk/testing';
1111
import {LegacyProgressSpinnerMode} from '@angular/material/legacy-progress-spinner';
12-
import {LegacyProgressSpinnerHarnessFilters} from './progress-spinner-harness-filters';
12+
import {ProgressSpinnerHarnessFilters} from '@angular/material/progress-spinner/testing';
1313

1414
/**
1515
* Harness for interacting with a standard mat-progress-spinner in tests.
@@ -27,7 +27,7 @@ export class MatLegacyProgressSpinnerHarness extends ComponentHarness {
2727
* @return a `HarnessPredicate` configured with the given options.
2828
*/
2929
static with(
30-
options: LegacyProgressSpinnerHarnessFilters = {},
30+
options: ProgressSpinnerHarnessFilters = {},
3131
): HarnessPredicate<MatLegacyProgressSpinnerHarness> {
3232
return new HarnessPredicate(MatLegacyProgressSpinnerHarness, options);
3333
}

src/material/legacy-progress-spinner/testing/public-api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
*/
88

99
export {MatLegacyProgressSpinnerHarness} from './progress-spinner-harness';
10-
export {LegacyProgressSpinnerHarnessFilters} from './progress-spinner-harness-filters';
10+
export {ProgressSpinnerHarnessFilters as LegacyProgressSpinnerHarnessFilters} from '@angular/material/progress-spinner/testing';

src/material/progress-spinner/BUILD.bazel

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ ng_module(
2424
deps = [
2525
"//src/cdk/platform",
2626
"//src/material/core",
27-
"//src/material/legacy-progress-spinner",
2827
"@npm//@angular/common",
2928
"@npm//@angular/core",
3029
],
@@ -58,7 +57,6 @@ ng_test_library(
5857
deps = [
5958
":progress-spinner",
6059
"//src/cdk/platform",
61-
"//src/material/legacy-progress-spinner",
6260
"@npm//@angular/common",
6361
"@npm//@angular/platform-browser",
6462
],

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import {waitForAsync, TestBed} from '@angular/core/testing';
2-
import {MatProgressSpinner, MatProgressSpinnerModule} from '@angular/material/progress-spinner';
32
import {CommonModule} from '@angular/common';
43
import {By} from '@angular/platform-browser';
5-
import {MAT_LEGACY_PROGRESS_SPINNER_DEFAULT_OPTIONS} from '@angular/material/legacy-progress-spinner';
64
import {Component, ElementRef, ViewChild, ViewEncapsulation} from '@angular/core';
5+
import {MatProgressSpinnerModule} from './module';
6+
import {MatProgressSpinner, MAT_PROGRESS_SPINNER_DEFAULT_OPTIONS} from './progress-spinner';
77

88
describe('MDC-based MatProgressSpinner', () => {
99
beforeEach(waitForAsync(() => {
@@ -301,7 +301,7 @@ describe('MDC-based MatProgressSpinner', () => {
301301
declarations: [BasicProgressSpinner],
302302
providers: [
303303
{
304-
provide: MAT_LEGACY_PROGRESS_SPINNER_DEFAULT_OPTIONS,
304+
provide: MAT_PROGRESS_SPINNER_DEFAULT_OPTIONS,
305305
useValue: {diameter: 23},
306306
},
307307
],
@@ -322,7 +322,7 @@ describe('MDC-based MatProgressSpinner', () => {
322322
declarations: [BasicProgressSpinner],
323323
providers: [
324324
{
325-
provide: MAT_LEGACY_PROGRESS_SPINNER_DEFAULT_OPTIONS,
325+
provide: MAT_PROGRESS_SPINNER_DEFAULT_OPTIONS,
326326
useValue: {strokeWidth: 7},
327327
},
328328
],
@@ -343,7 +343,7 @@ describe('MDC-based MatProgressSpinner', () => {
343343
declarations: [BasicProgressSpinner],
344344
providers: [
345345
{
346-
provide: MAT_LEGACY_PROGRESS_SPINNER_DEFAULT_OPTIONS,
346+
provide: MAT_PROGRESS_SPINNER_DEFAULT_OPTIONS,
347347
useValue: {color: 'warn'},
348348
},
349349
],

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

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,14 @@ import {
1111
Component,
1212
ElementRef,
1313
Inject,
14+
InjectionToken,
1415
Input,
1516
Optional,
1617
ViewChild,
1718
ViewEncapsulation,
1819
} from '@angular/core';
19-
import {CanColor, mixinColor} from '@angular/material/core';
20+
import {CanColor, mixinColor, ThemePalette} from '@angular/material/core';
2021
import {ANIMATION_MODULE_TYPE} from '@angular/platform-browser/animations';
21-
import {
22-
MAT_LEGACY_PROGRESS_SPINNER_DEFAULT_OPTIONS,
23-
MatLegacyProgressSpinnerDefaultOptions,
24-
} from '@angular/material/legacy-progress-spinner';
2522
import {coerceNumberProperty, NumberInput} from '@angular/cdk/coercion';
2623

2724
// Boilerplate for applying mixins to MatProgressBar.
@@ -35,6 +32,33 @@ const _MatProgressSpinnerBase = mixinColor(
3532
/** Possible mode for a progress spinner. */
3633
export type ProgressSpinnerMode = 'determinate' | 'indeterminate';
3734

35+
/** Default `mat-progress-spinner` options that can be overridden. */
36+
export interface MatProgressSpinnerDefaultOptions {
37+
/** Default color of the spinner. */
38+
color?: ThemePalette;
39+
/** Diameter of the spinner. */
40+
diameter?: number;
41+
/** Width of the spinner's stroke. */
42+
strokeWidth?: number;
43+
/**
44+
* Whether the animations should be force to be enabled, ignoring if the current environment is
45+
* using NoopAnimationsModule.
46+
*/
47+
_forceAnimations?: boolean;
48+
}
49+
50+
/** Injection token to be used to override the default options for `mat-progress-spinner`. */
51+
export const MAT_PROGRESS_SPINNER_DEFAULT_OPTIONS =
52+
new InjectionToken<MatProgressSpinnerDefaultOptions>('mat-progress-spinner-default-options', {
53+
providedIn: 'root',
54+
factory: MAT_PROGRESS_SPINNER_DEFAULT_OPTIONS_FACTORY,
55+
});
56+
57+
/** @docs-private */
58+
export function MAT_PROGRESS_SPINNER_DEFAULT_OPTIONS_FACTORY(): MatProgressSpinnerDefaultOptions {
59+
return {diameter: BASE_SIZE};
60+
}
61+
3862
/**
3963
* Base reference size of the spinner.
4064
*/
@@ -79,8 +103,8 @@ export class MatProgressSpinner extends _MatProgressSpinnerBase implements CanCo
79103
constructor(
80104
elementRef: ElementRef<HTMLElement>,
81105
@Optional() @Inject(ANIMATION_MODULE_TYPE) animationMode: string,
82-
@Inject(MAT_LEGACY_PROGRESS_SPINNER_DEFAULT_OPTIONS)
83-
defaults?: MatLegacyProgressSpinnerDefaultOptions,
106+
@Inject(MAT_PROGRESS_SPINNER_DEFAULT_OPTIONS)
107+
defaults?: MatProgressSpinnerDefaultOptions,
84108
) {
85109
super(elementRef);
86110
this._noopAnimations =

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,3 @@
88

99
export * from './progress-spinner';
1010
export * from './module';
11-
12-
export {
13-
MAT_LEGACY_PROGRESS_SPINNER_DEFAULT_OPTIONS as MAT_PROGRESS_SPINNER_DEFAULT_OPTIONS,
14-
MatLegacyProgressSpinnerDefaultOptions as MatProgressSpinnerDefaultOptions,
15-
MAT_LEGACY_PROGRESS_SPINNER_DEFAULT_OPTIONS_FACTORY as MAT_PROGRESS_SPINNER_DEFAULT_OPTIONS_FACTORY,
16-
} from '@angular/material/legacy-progress-spinner';

src/material/progress-spinner/testing/BUILD.bazel

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ ng_module(
1111
deps = [
1212
"//src/cdk/coercion",
1313
"//src/cdk/testing",
14-
"//src/material/legacy-progress-spinner/testing",
14+
"//src/material/progress-spinner",
1515
],
1616
)
1717

@@ -20,12 +20,27 @@ filegroup(
2020
srcs = glob(["**/*.ts"]),
2121
)
2222

23+
ng_test_library(
24+
name = "harness_tests_lib",
25+
srcs = ["shared.spec.ts"],
26+
deps = [
27+
":testing",
28+
"//src/cdk/testing",
29+
"//src/cdk/testing/testbed",
30+
"//src/material/progress-spinner",
31+
"@npm//@angular/platform-browser",
32+
],
33+
)
34+
2335
ng_test_library(
2436
name = "unit_tests_lib",
25-
srcs = glob(["**/*.spec.ts"]),
37+
srcs = glob(
38+
["**/*.spec.ts"],
39+
exclude = ["shared.spec.ts"],
40+
),
2641
deps = [
42+
":harness_tests_lib",
2743
":testing",
28-
"//src/material/legacy-progress-spinner/testing:harness_tests_lib",
2944
"//src/material/progress-spinner",
3045
],
3146
)

0 commit comments

Comments
 (0)