Skip to content

Commit 8096208

Browse files
committed
fixup! fix(material/stepper): switch away from animations module
1 parent 1dfa8c7 commit 8096208

File tree

7 files changed

+48
-32
lines changed

7 files changed

+48
-32
lines changed

src/cdk/stepper/public-api.ts

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

99
export * from './stepper';
10-
export * from './step-label';
1110
export * from './stepper-button';
1211
export * from './stepper-module';
1312
export * from './step-header';

src/cdk/stepper/step-label.ts

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/cdk/stepper/stepper-module.ts

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

99
import {NgModule} from '@angular/core';
10-
import {CdkStepper, CdkStep} from './stepper';
11-
import {CdkStepLabel} from './step-label';
10+
import {CdkStepper, CdkStep, CdkStepLabel} from './stepper';
1211
import {CdkStepperNext, CdkStepperPrevious} from './stepper-button';
1312
import {CdkStepHeader} from './step-header';
1413
import {BidiModule} from '@angular/cdk/bidi';

src/cdk/stepper/stepper.ts

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ import {Observable, of as observableOf, Subject} from 'rxjs';
4444
import {startWith, takeUntil} from 'rxjs/operators';
4545

4646
import {CdkStepHeader} from './step-header';
47-
import {CdkStepLabel} from './step-label';
4847

4948
/**
5049
* Position state of the content of each step in stepper that is used for transitioning
@@ -100,6 +99,25 @@ export interface StepperOptions {
10099
displayDefaultIndicatorType?: boolean;
101100
}
102101

102+
@Directive({selector: '[cdkStepLabel]'})
103+
export class CdkStepLabel {
104+
template = inject<TemplateRef<any>>(TemplateRef);
105+
106+
constructor(...args: unknown[]);
107+
108+
constructor() {
109+
const step = inject(CdkStep, {optional: true});
110+
const stepper = inject(CdkStepper, {optional: true});
111+
112+
// The content gets passed down into the step header components so we need to
113+
// notify the stepper if they come in later or they might not get picked up.
114+
if (step) {
115+
step.stepLabel = this;
116+
stepper?._stateChanged();
117+
}
118+
}
119+
}
120+
103121
@Component({
104122
selector: 'cdk-step',
105123
exportAs: 'cdkStep',
@@ -113,7 +131,16 @@ export class CdkStep implements OnChanges {
113131
_displayDefaultIndicatorType: boolean;
114132

115133
/** Template for step label if it exists. */
116-
@ContentChild(CdkStepLabel) stepLabel: CdkStepLabel;
134+
@ContentChild(CdkStepLabel)
135+
get stepLabel() {
136+
return this._stepLabel;
137+
}
138+
set stepLabel(label: CdkStepLabel) {
139+
this._stepLabel = label;
140+
}
141+
protected _stepLabel: CdkStepLabel;
142+
143+
// stepLabel: CdkStepLabel
117144

118145
/** Forms that have been projected into the step. */
119146
@ContentChildren(
@@ -122,9 +149,7 @@ export class CdkStep implements OnChanges {
122149
// the directives. The type is marked as `Partial` in case we run into a class that provides
123150
// itself as `ControlContainer` but doesn't have the same interface as the directives.
124151
ControlContainer,
125-
{
126-
descendants: true,
127-
},
152+
{descendants: true},
128153
)
129154
protected _childForms: QueryList<Partial<NgForm | FormGroupDirective>> | undefined;
130155

src/material/stepper/stepper.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,14 @@ export class MatStep extends CdkStep implements ErrorStateMatcher, AfterContentI
6262
private _isSelected = Subscription.EMPTY;
6363

6464
/** Content for step label given by `<ng-template matStepLabel>`. */
65-
// We need an initializer here to avoid a TS error.
66-
@ContentChild(MatStepLabel) override stepLabel: MatStepLabel = undefined!;
65+
@ContentChild(MatStepLabel)
66+
override get stepLabel() {
67+
return this._stepLabel;
68+
}
69+
override set stepLabel(label: MatStepLabel) {
70+
this._stepLabel = label;
71+
}
72+
protected override _stepLabel: MatStepLabel = undefined!;
6773

6874
/**
6975
* Theme color for the particular step. This API is supported in M2 themes

tools/public_api_guard/cdk/stepper.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@ export class CdkStep implements OnChanges {
5959
_showError(): boolean;
6060
state: StepState;
6161
stepControl: AbstractControl;
62-
stepLabel: CdkStepLabel;
62+
get stepLabel(): CdkStepLabel;
63+
set stepLabel(label: CdkStepLabel);
64+
// (undocumented)
65+
protected _stepLabel: CdkStepLabel;
6366
// (undocumented)
6467
_stepper: CdkStepper;
6568
// (undocumented)
@@ -143,7 +146,7 @@ export class CdkStepperModule {
143146
// (undocumented)
144147
static ɵinj: i0.ɵɵInjectorDeclaration<CdkStepperModule>;
145148
// (undocumented)
146-
static ɵmod: i0.ɵɵNgModuleDeclaration<CdkStepperModule, never, [typeof i1.BidiModule, typeof i2.CdkStep, typeof i2.CdkStepper, typeof i3.CdkStepHeader, typeof i4.CdkStepLabel, typeof i5.CdkStepperNext, typeof i5.CdkStepperPrevious], [typeof i2.CdkStep, typeof i2.CdkStepper, typeof i3.CdkStepHeader, typeof i4.CdkStepLabel, typeof i5.CdkStepperNext, typeof i5.CdkStepperPrevious]>;
149+
static ɵmod: i0.ɵɵNgModuleDeclaration<CdkStepperModule, never, [typeof i1.BidiModule, typeof i2.CdkStep, typeof i2.CdkStepper, typeof i3.CdkStepHeader, typeof i2.CdkStepLabel, typeof i4.CdkStepperNext, typeof i4.CdkStepperPrevious], [typeof i2.CdkStep, typeof i2.CdkStepper, typeof i3.CdkStepHeader, typeof i2.CdkStepLabel, typeof i4.CdkStepperNext, typeof i4.CdkStepperPrevious]>;
147150
}
148151

149152
// @public

tools/public_api_guard/material/stepper.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@ export class MatStep extends CdkStep implements ErrorStateMatcher, AfterContentI
5555
// (undocumented)
5656
ngOnDestroy(): void;
5757
_portal: TemplatePortal;
58-
stepLabel: MatStepLabel;
58+
get stepLabel(): MatStepLabel;
59+
set stepLabel(label: MatStepLabel);
60+
// (undocumented)
61+
protected _stepLabel: MatStepLabel;
5962
// (undocumented)
6063
static ɵcmp: i0.ɵɵComponentDeclaration<MatStep, "mat-step", ["matStep"], { "color": { "alias": "color"; "required": false; }; }, {}, ["stepLabel", "_lazyContent"], ["*"], true, never>;
6164
// (undocumented)

0 commit comments

Comments
 (0)