Skip to content

Commit 72fe576

Browse files
committed
fix(material/progress-spinner): remove dependency on legacy progress spinner
Fixes that the non-legacy progress spinner was depending on the legacy version.
1 parent f379e80 commit 72fe576

22 files changed

+121
-131
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 & 38 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,13 +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-
/** Possible mode for a progress spinner. */
32-
export type LegacyProgressSpinnerMode = 'determinate' | 'indeterminate';
33-
3435
/**
3536
* Base reference size of the spinner.
3637
* @docs-private
@@ -52,36 +53,6 @@ const _MatProgressSpinnerBase = mixinColor(
5253
'primary',
5354
);
5455

55-
/** Default `mat-progress-spinner` options that can be overridden. */
56-
export interface MatLegacyProgressSpinnerDefaultOptions {
57-
/** Default color of the spinner. */
58-
color?: ThemePalette;
59-
/** Diameter of the spinner. */
60-
diameter?: number;
61-
/** Width of the spinner's stroke. */
62-
strokeWidth?: number;
63-
/**
64-
* Whether the animations should be force to be enabled, ignoring if the current environment is
65-
* using NoopAnimationsModule.
66-
*/
67-
_forceAnimations?: boolean;
68-
}
69-
70-
/** Injection token to be used to override the default options for `mat-progress-spinner`. */
71-
export const MAT_LEGACY_PROGRESS_SPINNER_DEFAULT_OPTIONS =
72-
new InjectionToken<MatLegacyProgressSpinnerDefaultOptions>(
73-
'mat-progress-spinner-default-options',
74-
{
75-
providedIn: 'root',
76-
factory: MAT_LEGACY_PROGRESS_SPINNER_DEFAULT_OPTIONS_FACTORY,
77-
},
78-
);
79-
80-
/** @docs-private */
81-
export function MAT_LEGACY_PROGRESS_SPINNER_DEFAULT_OPTIONS_FACTORY(): MatLegacyProgressSpinnerDefaultOptions {
82-
return {diameter: BASE_SIZE};
83-
}
84-
8556
// .0001 percentage difference is necessary in order to avoid unwanted animation frames
8657
// for example because the animation duration is 4 seconds, .1% accounts to 4ms
8758
// which are enough to see the flicker described in
@@ -192,7 +163,7 @@ export class MatLegacyProgressSpinner
192163
}
193164

194165
/** Mode of the progress circle */
195-
@Input() mode: LegacyProgressSpinnerMode = 'determinate';
166+
@Input() mode: ProgressSpinnerMode = 'determinate';
196167

197168
/** Value of the progress circle. */
198169
@Input()
@@ -208,8 +179,8 @@ export class MatLegacyProgressSpinner
208179
_platform: Platform,
209180
@Optional() @Inject(DOCUMENT) private _document: any,
210181
@Optional() @Inject(ANIMATION_MODULE_TYPE) animationMode: string,
211-
@Inject(MAT_LEGACY_PROGRESS_SPINNER_DEFAULT_OPTIONS)
212-
defaults?: MatLegacyProgressSpinnerDefaultOptions,
182+
@Inject(MAT_PROGRESS_SPINNER_DEFAULT_OPTIONS)
183+
defaults?: MatProgressSpinnerDefaultOptions,
213184
/**
214185
* @deprecated `changeDetectorRef`, `viewportRuler` and `ngZone`
215186
* 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

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
/** Harness for interacting with a standard mat-progress-spinner in tests. */
1515
export class MatLegacyProgressSpinnerHarness extends ComponentHarness {
@@ -23,7 +23,7 @@ export class MatLegacyProgressSpinnerHarness extends ComponentHarness {
2323
* @return a `HarnessPredicate` configured with the given options.
2424
*/
2525
static with(
26-
options: LegacyProgressSpinnerHarnessFilters = {},
26+
options: ProgressSpinnerHarnessFilters = {},
2727
): HarnessPredicate<MatLegacyProgressSpinnerHarness> {
2828
return new HarnessPredicate(MatLegacyProgressSpinnerHarness, options);
2929
}

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
)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
import {BaseHarnessFilters} from '@angular/cdk/testing';
1010

1111
/** A set of criteria that can be used to filter a list of `MatProgressSpinnerHarness` instances. */
12-
export interface LegacyProgressSpinnerHarnessFilters extends BaseHarnessFilters {}
12+
export interface ProgressSpinnerHarnessFilters extends BaseHarnessFilters {}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {runHarnessTests} from '@angular/material/legacy-progress-spinner/testing/shared.spec';
1+
import {runHarnessTests} from '@angular/material/progress-spinner/testing/shared.spec';
22
import {MatProgressSpinnerHarness} from './progress-spinner-harness';
33
import {MatProgressSpinnerModule} from '../index';
44

0 commit comments

Comments
 (0)