[6a3a178] | 1 | import { TemplatePortal, PortalModule } from '@angular/cdk/portal';
|
---|
| 2 | import { CdkStepLabel, CdkStepHeader, CdkStep, STEPPER_GLOBAL_OPTIONS, CdkStepper, CdkStepperNext, CdkStepperPrevious, CdkStepperModule } from '@angular/cdk/stepper';
|
---|
| 3 | import { DOCUMENT, CommonModule } from '@angular/common';
|
---|
| 4 | import * as i0 from '@angular/core';
|
---|
| 5 | import { Directive, Injectable, Optional, SkipSelf, Component, ViewEncapsulation, ChangeDetectionStrategy, ElementRef, ChangeDetectorRef, Input, TemplateRef, Inject, forwardRef, ViewContainerRef, ContentChild, QueryList, EventEmitter, ViewChildren, ContentChildren, Output, NgModule } from '@angular/core';
|
---|
| 6 | import { MatButtonModule } from '@angular/material/button';
|
---|
| 7 | import { mixinColor, ErrorStateMatcher, MatCommonModule, MatRippleModule } from '@angular/material/core';
|
---|
| 8 | import { MatIconModule } from '@angular/material/icon';
|
---|
| 9 | import { FocusMonitor } from '@angular/cdk/a11y';
|
---|
| 10 | import { Subject, Subscription } from 'rxjs';
|
---|
| 11 | import { Directionality } from '@angular/cdk/bidi';
|
---|
| 12 | import { switchMap, map, startWith, takeUntil, distinctUntilChanged } from 'rxjs/operators';
|
---|
| 13 | import { trigger, state, style, transition, animate } from '@angular/animations';
|
---|
| 14 |
|
---|
| 15 | /**
|
---|
| 16 | * @license
|
---|
| 17 | * Copyright Google LLC All Rights Reserved.
|
---|
| 18 | *
|
---|
| 19 | * Use of this source code is governed by an MIT-style license that can be
|
---|
| 20 | * found in the LICENSE file at https://angular.io/license
|
---|
| 21 | */
|
---|
| 22 | class MatStepLabel extends CdkStepLabel {
|
---|
| 23 | }
|
---|
| 24 | MatStepLabel.decorators = [
|
---|
| 25 | { type: Directive, args: [{
|
---|
| 26 | selector: '[matStepLabel]',
|
---|
| 27 | },] }
|
---|
| 28 | ];
|
---|
| 29 |
|
---|
| 30 | /**
|
---|
| 31 | * @license
|
---|
| 32 | * Copyright Google LLC All Rights Reserved.
|
---|
| 33 | *
|
---|
| 34 | * Use of this source code is governed by an MIT-style license that can be
|
---|
| 35 | * found in the LICENSE file at https://angular.io/license
|
---|
| 36 | */
|
---|
| 37 | /** Stepper data that is required for internationalization. */
|
---|
| 38 | class MatStepperIntl {
|
---|
| 39 | constructor() {
|
---|
| 40 | /**
|
---|
| 41 | * Stream that emits whenever the labels here are changed. Use this to notify
|
---|
| 42 | * components if the labels have changed after initialization.
|
---|
| 43 | */
|
---|
| 44 | this.changes = new Subject();
|
---|
| 45 | /** Label that is rendered below optional steps. */
|
---|
| 46 | this.optionalLabel = 'Optional';
|
---|
| 47 | /** Label that is used to indicate step as completed to screen readers. */
|
---|
| 48 | this.completedLabel = 'Completed';
|
---|
| 49 | /** Label that is used to indicate step as editable to screen readers. */
|
---|
| 50 | this.editableLabel = 'Editable';
|
---|
| 51 | }
|
---|
| 52 | }
|
---|
| 53 | MatStepperIntl.ɵprov = i0.ɵɵdefineInjectable({ factory: function MatStepperIntl_Factory() { return new MatStepperIntl(); }, token: MatStepperIntl, providedIn: "root" });
|
---|
| 54 | MatStepperIntl.decorators = [
|
---|
| 55 | { type: Injectable, args: [{ providedIn: 'root' },] }
|
---|
| 56 | ];
|
---|
| 57 | /** @docs-private */
|
---|
| 58 | function MAT_STEPPER_INTL_PROVIDER_FACTORY(parentIntl) {
|
---|
| 59 | return parentIntl || new MatStepperIntl();
|
---|
| 60 | }
|
---|
| 61 | /** @docs-private */
|
---|
| 62 | const MAT_STEPPER_INTL_PROVIDER = {
|
---|
| 63 | provide: MatStepperIntl,
|
---|
| 64 | deps: [[new Optional(), new SkipSelf(), MatStepperIntl]],
|
---|
| 65 | useFactory: MAT_STEPPER_INTL_PROVIDER_FACTORY
|
---|
| 66 | };
|
---|
| 67 |
|
---|
| 68 | /**
|
---|
| 69 | * @license
|
---|
| 70 | * Copyright Google LLC All Rights Reserved.
|
---|
| 71 | *
|
---|
| 72 | * Use of this source code is governed by an MIT-style license that can be
|
---|
| 73 | * found in the LICENSE file at https://angular.io/license
|
---|
| 74 | */
|
---|
| 75 | // Boilerplate for applying mixins to MatStepHeader.
|
---|
| 76 | /** @docs-private */
|
---|
| 77 | const _MatStepHeaderBase = mixinColor(class MatStepHeaderBase extends CdkStepHeader {
|
---|
| 78 | constructor(elementRef) {
|
---|
| 79 | super(elementRef);
|
---|
| 80 | }
|
---|
| 81 | }, 'primary');
|
---|
| 82 | class MatStepHeader extends _MatStepHeaderBase {
|
---|
| 83 | constructor(_intl, _focusMonitor, _elementRef, changeDetectorRef) {
|
---|
| 84 | super(_elementRef);
|
---|
| 85 | this._intl = _intl;
|
---|
| 86 | this._focusMonitor = _focusMonitor;
|
---|
| 87 | this._intlSubscription = _intl.changes.subscribe(() => changeDetectorRef.markForCheck());
|
---|
| 88 | }
|
---|
| 89 | ngAfterViewInit() {
|
---|
| 90 | this._focusMonitor.monitor(this._elementRef, true);
|
---|
| 91 | }
|
---|
| 92 | ngOnDestroy() {
|
---|
| 93 | this._intlSubscription.unsubscribe();
|
---|
| 94 | this._focusMonitor.stopMonitoring(this._elementRef);
|
---|
| 95 | }
|
---|
| 96 | /** Focuses the step header. */
|
---|
| 97 | focus(origin, options) {
|
---|
| 98 | if (origin) {
|
---|
| 99 | this._focusMonitor.focusVia(this._elementRef, origin, options);
|
---|
| 100 | }
|
---|
| 101 | else {
|
---|
| 102 | this._elementRef.nativeElement.focus(options);
|
---|
| 103 | }
|
---|
| 104 | }
|
---|
| 105 | /** Returns string label of given step if it is a text label. */
|
---|
| 106 | _stringLabel() {
|
---|
| 107 | return this.label instanceof MatStepLabel ? null : this.label;
|
---|
| 108 | }
|
---|
| 109 | /** Returns MatStepLabel if the label of given step is a template label. */
|
---|
| 110 | _templateLabel() {
|
---|
| 111 | return this.label instanceof MatStepLabel ? this.label : null;
|
---|
| 112 | }
|
---|
| 113 | /** Returns the host HTML element. */
|
---|
| 114 | _getHostElement() {
|
---|
| 115 | return this._elementRef.nativeElement;
|
---|
| 116 | }
|
---|
| 117 | /** Template context variables that are exposed to the `matStepperIcon` instances. */
|
---|
| 118 | _getIconContext() {
|
---|
| 119 | return {
|
---|
| 120 | index: this.index,
|
---|
| 121 | active: this.active,
|
---|
| 122 | optional: this.optional
|
---|
| 123 | };
|
---|
| 124 | }
|
---|
| 125 | _getDefaultTextForState(state) {
|
---|
| 126 | if (state == 'number') {
|
---|
| 127 | return `${this.index + 1}`;
|
---|
| 128 | }
|
---|
| 129 | if (state == 'edit') {
|
---|
| 130 | return 'create';
|
---|
| 131 | }
|
---|
| 132 | if (state == 'error') {
|
---|
| 133 | return 'warning';
|
---|
| 134 | }
|
---|
| 135 | return state;
|
---|
| 136 | }
|
---|
| 137 | }
|
---|
| 138 | MatStepHeader.decorators = [
|
---|
| 139 | { type: Component, args: [{
|
---|
| 140 | selector: 'mat-step-header',
|
---|
| 141 | template: "<div class=\"mat-step-header-ripple mat-focus-indicator\" matRipple\n [matRippleTrigger]=\"_getHostElement()\"\n [matRippleDisabled]=\"disableRipple\"></div>\n\n<div class=\"mat-step-icon-state-{{state}} mat-step-icon\" [class.mat-step-icon-selected]=\"selected\">\n <div class=\"mat-step-icon-content\" [ngSwitch]=\"!!(iconOverrides && iconOverrides[state])\">\n <ng-container\n *ngSwitchCase=\"true\"\n [ngTemplateOutlet]=\"iconOverrides[state]\"\n [ngTemplateOutletContext]=\"_getIconContext()\"></ng-container>\n <ng-container *ngSwitchDefault [ngSwitch]=\"state\">\n <span *ngSwitchCase=\"'number'\">{{_getDefaultTextForState(state)}}</span>\n <span class=\"cdk-visually-hidden\" *ngIf=\"state === 'done'\">{{_intl.completedLabel}}</span>\n <span class=\"cdk-visually-hidden\" *ngIf=\"state === 'edit'\">{{_intl.editableLabel}}</span>\n <mat-icon *ngSwitchDefault>{{_getDefaultTextForState(state)}}</mat-icon>\n </ng-container>\n </div>\n</div>\n<div class=\"mat-step-label\"\n [class.mat-step-label-active]=\"active\"\n [class.mat-step-label-selected]=\"selected\"\n [class.mat-step-label-error]=\"state == 'error'\">\n <!-- If there is a label template, use it. -->\n <div class=\"mat-step-text-label\" *ngIf=\"_templateLabel()\">\n <ng-container [ngTemplateOutlet]=\"_templateLabel()!.template\"></ng-container>\n </div>\n <!-- If there is no label template, fall back to the text label. -->\n <div class=\"mat-step-text-label\" *ngIf=\"_stringLabel()\">{{label}}</div>\n\n <div class=\"mat-step-optional\" *ngIf=\"optional && state != 'error'\">{{_intl.optionalLabel}}</div>\n <div class=\"mat-step-sub-label-error\" *ngIf=\"state == 'error'\">{{errorMessage}}</div>\n</div>\n\n",
|
---|
| 142 | inputs: ['color'],
|
---|
| 143 | host: {
|
---|
| 144 | 'class': 'mat-step-header',
|
---|
| 145 | 'role': 'tab',
|
---|
| 146 | },
|
---|
| 147 | encapsulation: ViewEncapsulation.None,
|
---|
| 148 | changeDetection: ChangeDetectionStrategy.OnPush,
|
---|
| 149 | styles: [".mat-step-header{overflow:hidden;outline:none;cursor:pointer;position:relative;box-sizing:content-box;-webkit-tap-highlight-color:transparent}.cdk-high-contrast-active .mat-step-header{outline:solid 1px}.cdk-high-contrast-active .mat-step-header.cdk-keyboard-focused,.cdk-high-contrast-active .mat-step-header.cdk-program-focused{outline:solid 3px}.cdk-high-contrast-active .mat-step-header[aria-selected=true] .mat-step-label{text-decoration:underline}.mat-step-optional,.mat-step-sub-label-error{font-size:12px}.mat-step-icon{border-radius:50%;height:24px;width:24px;flex-shrink:0;position:relative}.mat-step-icon-content,.mat-step-icon .mat-icon{position:absolute;top:50%;left:50%;transform:translate(-50%, -50%)}.mat-step-icon .mat-icon{font-size:16px;height:16px;width:16px}.mat-step-icon-state-error .mat-icon{font-size:24px;height:24px;width:24px}.mat-step-label{display:inline-block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:50px;vertical-align:middle}.mat-step-text-label{text-overflow:ellipsis;overflow:hidden}.mat-step-header .mat-step-header-ripple{top:0;left:0;right:0;bottom:0;position:absolute;pointer-events:none}\n"]
|
---|
| 150 | },] }
|
---|
| 151 | ];
|
---|
| 152 | MatStepHeader.ctorParameters = () => [
|
---|
| 153 | { type: MatStepperIntl },
|
---|
| 154 | { type: FocusMonitor },
|
---|
| 155 | { type: ElementRef },
|
---|
| 156 | { type: ChangeDetectorRef }
|
---|
| 157 | ];
|
---|
| 158 | MatStepHeader.propDecorators = {
|
---|
| 159 | state: [{ type: Input }],
|
---|
| 160 | label: [{ type: Input }],
|
---|
| 161 | errorMessage: [{ type: Input }],
|
---|
| 162 | iconOverrides: [{ type: Input }],
|
---|
| 163 | index: [{ type: Input }],
|
---|
| 164 | selected: [{ type: Input }],
|
---|
| 165 | active: [{ type: Input }],
|
---|
| 166 | optional: [{ type: Input }],
|
---|
| 167 | disableRipple: [{ type: Input }]
|
---|
| 168 | };
|
---|
| 169 |
|
---|
| 170 | /**
|
---|
| 171 | * @license
|
---|
| 172 | * Copyright Google LLC All Rights Reserved.
|
---|
| 173 | *
|
---|
| 174 | * Use of this source code is governed by an MIT-style license that can be
|
---|
| 175 | * found in the LICENSE file at https://angular.io/license
|
---|
| 176 | */
|
---|
| 177 | /**
|
---|
| 178 | * Animations used by the Material steppers.
|
---|
| 179 | * @docs-private
|
---|
| 180 | */
|
---|
| 181 | const matStepperAnimations = {
|
---|
| 182 | /** Animation that transitions the step along the X axis in a horizontal stepper. */
|
---|
| 183 | horizontalStepTransition: trigger('horizontalStepTransition', [
|
---|
| 184 | state('previous', style({ transform: 'translate3d(-100%, 0, 0)', visibility: 'hidden' })),
|
---|
| 185 | // Transition to `inherit`, rather than `visible`,
|
---|
| 186 | // because visibility on a child element the one from the parent,
|
---|
| 187 | // making this element focusable inside of a `hidden` element.
|
---|
| 188 | state('current', style({ transform: 'none', visibility: 'inherit' })),
|
---|
| 189 | state('next', style({ transform: 'translate3d(100%, 0, 0)', visibility: 'hidden' })),
|
---|
| 190 | transition('* => *', animate('500ms cubic-bezier(0.35, 0, 0.25, 1)'))
|
---|
| 191 | ]),
|
---|
| 192 | /** Animation that transitions the step along the Y axis in a vertical stepper. */
|
---|
| 193 | verticalStepTransition: trigger('verticalStepTransition', [
|
---|
| 194 | state('previous', style({ height: '0px', visibility: 'hidden' })),
|
---|
| 195 | state('next', style({ height: '0px', visibility: 'hidden' })),
|
---|
| 196 | // Transition to `inherit`, rather than `visible`,
|
---|
| 197 | // because visibility on a child element the one from the parent,
|
---|
| 198 | // making this element focusable inside of a `hidden` element.
|
---|
| 199 | state('current', style({ height: '*', visibility: 'inherit' })),
|
---|
| 200 | transition('* <=> current', animate('225ms cubic-bezier(0.4, 0.0, 0.2, 1)'))
|
---|
| 201 | ])
|
---|
| 202 | };
|
---|
| 203 |
|
---|
| 204 | /**
|
---|
| 205 | * @license
|
---|
| 206 | * Copyright Google LLC All Rights Reserved.
|
---|
| 207 | *
|
---|
| 208 | * Use of this source code is governed by an MIT-style license that can be
|
---|
| 209 | * found in the LICENSE file at https://angular.io/license
|
---|
| 210 | */
|
---|
| 211 | /**
|
---|
| 212 | * Template to be used to override the icons inside the step header.
|
---|
| 213 | */
|
---|
| 214 | class MatStepperIcon {
|
---|
| 215 | constructor(templateRef) {
|
---|
| 216 | this.templateRef = templateRef;
|
---|
| 217 | }
|
---|
| 218 | }
|
---|
| 219 | MatStepperIcon.decorators = [
|
---|
| 220 | { type: Directive, args: [{
|
---|
| 221 | selector: 'ng-template[matStepperIcon]',
|
---|
| 222 | },] }
|
---|
| 223 | ];
|
---|
| 224 | MatStepperIcon.ctorParameters = () => [
|
---|
| 225 | { type: TemplateRef }
|
---|
| 226 | ];
|
---|
| 227 | MatStepperIcon.propDecorators = {
|
---|
| 228 | name: [{ type: Input, args: ['matStepperIcon',] }]
|
---|
| 229 | };
|
---|
| 230 |
|
---|
| 231 | /**
|
---|
| 232 | * @license
|
---|
| 233 | * Copyright Google LLC All Rights Reserved.
|
---|
| 234 | *
|
---|
| 235 | * Use of this source code is governed by an MIT-style license that can be
|
---|
| 236 | * found in the LICENSE file at https://angular.io/license
|
---|
| 237 | */
|
---|
| 238 | /**
|
---|
| 239 | * Content for a `mat-step` that will be rendered lazily.
|
---|
| 240 | */
|
---|
| 241 | class MatStepContent {
|
---|
| 242 | constructor(_template) {
|
---|
| 243 | this._template = _template;
|
---|
| 244 | }
|
---|
| 245 | }
|
---|
| 246 | MatStepContent.decorators = [
|
---|
| 247 | { type: Directive, args: [{
|
---|
| 248 | selector: 'ng-template[matStepContent]'
|
---|
| 249 | },] }
|
---|
| 250 | ];
|
---|
| 251 | MatStepContent.ctorParameters = () => [
|
---|
| 252 | { type: TemplateRef }
|
---|
| 253 | ];
|
---|
| 254 |
|
---|
| 255 | /**
|
---|
| 256 | * @license
|
---|
| 257 | * Copyright Google LLC All Rights Reserved.
|
---|
| 258 | *
|
---|
| 259 | * Use of this source code is governed by an MIT-style license that can be
|
---|
| 260 | * found in the LICENSE file at https://angular.io/license
|
---|
| 261 | */
|
---|
| 262 | class MatStep extends CdkStep {
|
---|
| 263 | constructor(stepper, _errorStateMatcher, _viewContainerRef, stepperOptions) {
|
---|
| 264 | super(stepper, stepperOptions);
|
---|
| 265 | this._errorStateMatcher = _errorStateMatcher;
|
---|
| 266 | this._viewContainerRef = _viewContainerRef;
|
---|
| 267 | this._isSelected = Subscription.EMPTY;
|
---|
| 268 | }
|
---|
| 269 | ngAfterContentInit() {
|
---|
| 270 | this._isSelected = this._stepper.steps.changes.pipe(switchMap(() => {
|
---|
| 271 | return this._stepper.selectionChange.pipe(map(event => event.selectedStep === this), startWith(this._stepper.selected === this));
|
---|
| 272 | })).subscribe(isSelected => {
|
---|
| 273 | if (isSelected && this._lazyContent && !this._portal) {
|
---|
| 274 | this._portal = new TemplatePortal(this._lazyContent._template, this._viewContainerRef);
|
---|
| 275 | }
|
---|
| 276 | });
|
---|
| 277 | }
|
---|
| 278 | ngOnDestroy() {
|
---|
| 279 | this._isSelected.unsubscribe();
|
---|
| 280 | }
|
---|
| 281 | /** Custom error state matcher that additionally checks for validity of interacted form. */
|
---|
| 282 | isErrorState(control, form) {
|
---|
| 283 | const originalErrorState = this._errorStateMatcher.isErrorState(control, form);
|
---|
| 284 | // Custom error state checks for the validity of form that is not submitted or touched
|
---|
| 285 | // since user can trigger a form change by calling for another step without directly
|
---|
| 286 | // interacting with the current form.
|
---|
| 287 | const customErrorState = !!(control && control.invalid && this.interacted);
|
---|
| 288 | return originalErrorState || customErrorState;
|
---|
| 289 | }
|
---|
| 290 | }
|
---|
| 291 | MatStep.decorators = [
|
---|
| 292 | { type: Component, args: [{
|
---|
| 293 | selector: 'mat-step',
|
---|
| 294 | template: "<ng-template>\n <ng-content></ng-content>\n <ng-template [cdkPortalOutlet]=\"_portal\"></ng-template>\n</ng-template>\n",
|
---|
| 295 | providers: [
|
---|
| 296 | { provide: ErrorStateMatcher, useExisting: MatStep },
|
---|
| 297 | { provide: CdkStep, useExisting: MatStep },
|
---|
| 298 | ],
|
---|
| 299 | encapsulation: ViewEncapsulation.None,
|
---|
| 300 | exportAs: 'matStep',
|
---|
| 301 | changeDetection: ChangeDetectionStrategy.OnPush
|
---|
| 302 | },] }
|
---|
| 303 | ];
|
---|
| 304 | MatStep.ctorParameters = () => [
|
---|
| 305 | { type: MatStepper, decorators: [{ type: Inject, args: [forwardRef(() => MatStepper),] }] },
|
---|
| 306 | { type: ErrorStateMatcher, decorators: [{ type: SkipSelf }] },
|
---|
| 307 | { type: ViewContainerRef },
|
---|
| 308 | { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [STEPPER_GLOBAL_OPTIONS,] }] }
|
---|
| 309 | ];
|
---|
| 310 | MatStep.propDecorators = {
|
---|
| 311 | stepLabel: [{ type: ContentChild, args: [MatStepLabel,] }],
|
---|
| 312 | color: [{ type: Input }],
|
---|
| 313 | _lazyContent: [{ type: ContentChild, args: [MatStepContent, { static: false },] }]
|
---|
| 314 | };
|
---|
| 315 | /**
|
---|
| 316 | * Proxies the public APIs from `MatStepper` to the deprecated `MatHorizontalStepper` and
|
---|
| 317 | * `MatVerticalStepper`.
|
---|
| 318 | * @deprecated Use `MatStepper` instead.
|
---|
| 319 | * @breaking-change 13.0.0
|
---|
| 320 | * @docs-private
|
---|
| 321 | */
|
---|
| 322 | class _MatProxyStepperBase extends CdkStepper {
|
---|
| 323 | }
|
---|
| 324 | _MatProxyStepperBase.decorators = [
|
---|
| 325 | { type: Directive }
|
---|
| 326 | ];
|
---|
| 327 | /**
|
---|
| 328 | * @deprecated Use `MatStepper` instead.
|
---|
| 329 | * @breaking-change 13.0.0
|
---|
| 330 | */
|
---|
| 331 | class MatHorizontalStepper extends _MatProxyStepperBase {
|
---|
| 332 | }
|
---|
| 333 | MatHorizontalStepper.decorators = [
|
---|
| 334 | { type: Directive, args: [{ selector: 'mat-horizontal-stepper' },] }
|
---|
| 335 | ];
|
---|
| 336 | /**
|
---|
| 337 | * @deprecated Use `MatStepper` instead.
|
---|
| 338 | * @breaking-change 13.0.0
|
---|
| 339 | */
|
---|
| 340 | class MatVerticalStepper extends _MatProxyStepperBase {
|
---|
| 341 | }
|
---|
| 342 | MatVerticalStepper.decorators = [
|
---|
| 343 | { type: Directive, args: [{ selector: 'mat-vertical-stepper' },] }
|
---|
| 344 | ];
|
---|
| 345 | class MatStepper extends CdkStepper {
|
---|
| 346 | constructor(dir, changeDetectorRef, elementRef, _document) {
|
---|
| 347 | super(dir, changeDetectorRef, elementRef, _document);
|
---|
| 348 | /** Steps that belong to the current stepper, excluding ones from nested steppers. */
|
---|
| 349 | this.steps = new QueryList();
|
---|
| 350 | /** Event emitted when the current step is done transitioning in. */
|
---|
| 351 | this.animationDone = new EventEmitter();
|
---|
| 352 | /**
|
---|
| 353 | * Whether the label should display in bottom or end position.
|
---|
| 354 | * Only applies in the `horizontal` orientation.
|
---|
| 355 | */
|
---|
| 356 | this.labelPosition = 'end';
|
---|
| 357 | /** Consumer-specified template-refs to be used to override the header icons. */
|
---|
| 358 | this._iconOverrides = {};
|
---|
| 359 | /** Stream of animation `done` events when the body expands/collapses. */
|
---|
| 360 | this._animationDone = new Subject();
|
---|
| 361 | const nodeName = elementRef.nativeElement.nodeName.toLowerCase();
|
---|
| 362 | this.orientation = nodeName === 'mat-vertical-stepper' ? 'vertical' : 'horizontal';
|
---|
| 363 | }
|
---|
| 364 | ngAfterContentInit() {
|
---|
| 365 | super.ngAfterContentInit();
|
---|
| 366 | this._icons.forEach(({ name, templateRef }) => this._iconOverrides[name] = templateRef);
|
---|
| 367 | // Mark the component for change detection whenever the content children query changes
|
---|
| 368 | this.steps.changes.pipe(takeUntil(this._destroyed)).subscribe(() => {
|
---|
| 369 | this._stateChanged();
|
---|
| 370 | });
|
---|
| 371 | this._animationDone.pipe(
|
---|
| 372 | // This needs a `distinctUntilChanged` in order to avoid emitting the same event twice due
|
---|
| 373 | // to a bug in animations where the `.done` callback gets invoked twice on some browsers.
|
---|
| 374 | // See https://github.com/angular/angular/issues/24084
|
---|
| 375 | distinctUntilChanged((x, y) => x.fromState === y.fromState && x.toState === y.toState), takeUntil(this._destroyed)).subscribe(event => {
|
---|
| 376 | if (event.toState === 'current') {
|
---|
| 377 | this.animationDone.emit();
|
---|
| 378 | }
|
---|
| 379 | });
|
---|
| 380 | }
|
---|
| 381 | _stepIsNavigable(index, step) {
|
---|
| 382 | return step.completed || this.selectedIndex === index || !this.linear;
|
---|
| 383 | }
|
---|
| 384 | }
|
---|
| 385 | MatStepper.decorators = [
|
---|
| 386 | { type: Component, args: [{
|
---|
| 387 | selector: 'mat-stepper, mat-vertical-stepper, mat-horizontal-stepper, [matStepper]',
|
---|
| 388 | exportAs: 'matStepper, matVerticalStepper, matHorizontalStepper',
|
---|
| 389 | template: "<ng-container [ngSwitch]=\"orientation\">\n <!-- Horizontal stepper -->\n <ng-container *ngSwitchCase=\"'horizontal'\">\n <div class=\"mat-horizontal-stepper-header-container\">\n <ng-container *ngFor=\"let step of steps; let i = index; let isLast = last\">\n <ng-container\n [ngTemplateOutlet]=\"stepTemplate\"\n [ngTemplateOutletContext]=\"{step: step, i: i}\"></ng-container>\n <div *ngIf=\"!isLast\" class=\"mat-stepper-horizontal-line\"></div>\n </ng-container>\n </div>\n\n <div class=\"mat-horizontal-content-container\">\n <div *ngFor=\"let step of steps; let i = index\"\n class=\"mat-horizontal-stepper-content\" role=\"tabpanel\"\n [@horizontalStepTransition]=\"_getAnimationDirection(i)\"\n (@horizontalStepTransition.done)=\"_animationDone.next($event)\"\n [id]=\"_getStepContentId(i)\"\n [attr.aria-labelledby]=\"_getStepLabelId(i)\"\n [attr.aria-expanded]=\"selectedIndex === i\">\n <ng-container [ngTemplateOutlet]=\"step.content\"></ng-container>\n </div>\n </div>\n </ng-container>\n\n <!-- Vertical stepper -->\n <ng-container *ngSwitchCase=\"'vertical'\">\n <div class=\"mat-step\" *ngFor=\"let step of steps; let i = index; let isLast = last\">\n <ng-container\n [ngTemplateOutlet]=\"stepTemplate\"\n [ngTemplateOutletContext]=\"{step: step, i: i}\"></ng-container>\n <div class=\"mat-vertical-content-container\" [class.mat-stepper-vertical-line]=\"!isLast\">\n <div class=\"mat-vertical-stepper-content\" role=\"tabpanel\"\n [@verticalStepTransition]=\"_getAnimationDirection(i)\"\n (@verticalStepTransition.done)=\"_animationDone.next($event)\"\n [id]=\"_getStepContentId(i)\"\n [attr.aria-labelledby]=\"_getStepLabelId(i)\"\n [attr.aria-expanded]=\"selectedIndex === i\">\n <div class=\"mat-vertical-content\">\n <ng-container [ngTemplateOutlet]=\"step.content\"></ng-container>\n </div>\n </div>\n </div>\n </div>\n </ng-container>\n\n</ng-container>\n\n<!-- Common step templating -->\n<ng-template let-step=\"step\" let-i=\"i\" #stepTemplate>\n <mat-step-header\n [class.mat-horizontal-stepper-header]=\"orientation === 'horizontal'\"\n [class.mat-vertical-stepper-header]=\"orientation === 'vertical'\"\n (click)=\"step.select()\"\n (keydown)=\"_onKeydown($event)\"\n [tabIndex]=\"_getFocusIndex() === i ? 0 : -1\"\n [id]=\"_getStepLabelId(i)\"\n [attr.aria-posinset]=\"i + 1\"\n [attr.aria-setsize]=\"steps.length\"\n [attr.aria-controls]=\"_getStepContentId(i)\"\n [attr.aria-selected]=\"selectedIndex == i\"\n [attr.aria-label]=\"step.ariaLabel || null\"\n [attr.aria-labelledby]=\"(!step.ariaLabel && step.ariaLabelledby) ? step.ariaLabelledby : null\"\n [attr.aria-disabled]=\"_stepIsNavigable(i, step) ? null : true\"\n [index]=\"i\"\n [state]=\"_getIndicatorType(i, step.state)\"\n [label]=\"step.stepLabel || step.label\"\n [selected]=\"selectedIndex === i\"\n [active]=\"_stepIsNavigable(i, step)\"\n [optional]=\"step.optional\"\n [errorMessage]=\"step.errorMessage\"\n [iconOverrides]=\"_iconOverrides\"\n [disableRipple]=\"disableRipple || !_stepIsNavigable(i, step)\"\n [color]=\"step.color || color\"></mat-step-header>\n</ng-template>\n",
|
---|
| 390 | inputs: ['selectedIndex'],
|
---|
| 391 | host: {
|
---|
| 392 | '[class.mat-stepper-horizontal]': 'orientation === "horizontal"',
|
---|
| 393 | '[class.mat-stepper-vertical]': 'orientation === "vertical"',
|
---|
| 394 | '[class.mat-stepper-label-position-end]': 'orientation === "horizontal" && labelPosition == "end"',
|
---|
| 395 | '[class.mat-stepper-label-position-bottom]': 'orientation === "horizontal" && labelPosition == "bottom"',
|
---|
| 396 | '[attr.aria-orientation]': 'orientation',
|
---|
| 397 | 'role': 'tablist',
|
---|
| 398 | },
|
---|
| 399 | animations: [
|
---|
| 400 | matStepperAnimations.horizontalStepTransition,
|
---|
| 401 | matStepperAnimations.verticalStepTransition,
|
---|
| 402 | ],
|
---|
| 403 | providers: [
|
---|
| 404 | { provide: CdkStepper, useExisting: MatStepper },
|
---|
| 405 | { provide: MatHorizontalStepper, useExisting: MatStepper },
|
---|
| 406 | { provide: MatVerticalStepper, useExisting: MatStepper },
|
---|
| 407 | ],
|
---|
| 408 | encapsulation: ViewEncapsulation.None,
|
---|
| 409 | changeDetection: ChangeDetectionStrategy.OnPush,
|
---|
| 410 | styles: [".mat-stepper-vertical,.mat-stepper-horizontal{display:block}.mat-horizontal-stepper-header-container{white-space:nowrap;display:flex;align-items:center}.mat-stepper-label-position-bottom .mat-horizontal-stepper-header-container{align-items:flex-start}.mat-stepper-horizontal-line{border-top-width:1px;border-top-style:solid;flex:auto;height:0;margin:0 -16px;min-width:32px}.mat-stepper-label-position-bottom .mat-stepper-horizontal-line{margin:0;min-width:0;position:relative}.mat-stepper-label-position-bottom .mat-horizontal-stepper-header:not(:first-child)::before,[dir=rtl] .mat-stepper-label-position-bottom .mat-horizontal-stepper-header:not(:last-child)::before,.mat-stepper-label-position-bottom .mat-horizontal-stepper-header:not(:last-child)::after,[dir=rtl] .mat-stepper-label-position-bottom .mat-horizontal-stepper-header:not(:first-child)::after{border-top-width:1px;border-top-style:solid;content:\"\";display:inline-block;height:0;position:absolute;width:calc(50% - 20px)}.mat-horizontal-stepper-header{display:flex;height:72px;overflow:hidden;align-items:center;padding:0 24px}.mat-horizontal-stepper-header .mat-step-icon{margin-right:8px;flex:none}[dir=rtl] .mat-horizontal-stepper-header .mat-step-icon{margin-right:0;margin-left:8px}.mat-stepper-label-position-bottom .mat-horizontal-stepper-header{box-sizing:border-box;flex-direction:column;height:auto}.mat-stepper-label-position-bottom .mat-horizontal-stepper-header:not(:last-child)::after,[dir=rtl] .mat-stepper-label-position-bottom .mat-horizontal-stepper-header:not(:first-child)::after{right:0}.mat-stepper-label-position-bottom .mat-horizontal-stepper-header:not(:first-child)::before,[dir=rtl] .mat-stepper-label-position-bottom .mat-horizontal-stepper-header:not(:last-child)::before{left:0}[dir=rtl] .mat-stepper-label-position-bottom .mat-horizontal-stepper-header:last-child::before,[dir=rtl] .mat-stepper-label-position-bottom .mat-horizontal-stepper-header:first-child::after{display:none}.mat-stepper-label-position-bottom .mat-horizontal-stepper-header .mat-step-icon{margin-right:0;margin-left:0}.mat-stepper-label-position-bottom .mat-horizontal-stepper-header .mat-step-label{padding:16px 0 0 0;text-align:center;width:100%}.mat-vertical-stepper-header{display:flex;align-items:center;height:24px}.mat-vertical-stepper-header .mat-step-icon{margin-right:12px}[dir=rtl] .mat-vertical-stepper-header .mat-step-icon{margin-right:0;margin-left:12px}.mat-horizontal-stepper-content{outline:0}.mat-horizontal-stepper-content[aria-expanded=false]{height:0;overflow:hidden}.mat-horizontal-content-container{overflow:hidden;padding:0 24px 24px 24px}.cdk-high-contrast-active .mat-horizontal-content-container{outline:solid 1px}.mat-vertical-content-container{margin-left:36px;border:0;position:relative}.cdk-high-contrast-active .mat-vertical-content-container{outline:solid 1px}[dir=rtl] .mat-vertical-content-container{margin-left:0;margin-right:36px}.mat-stepper-vertical-line::before{content:\"\";position:absolute;left:0;border-left-width:1px;border-left-style:solid}[dir=rtl] .mat-stepper-vertical-line::before{left:auto;right:0}.mat-vertical-stepper-content{overflow:hidden;outline:0}.mat-vertical-content{padding:0 24px 24px 24px}.mat-step:last-child .mat-vertical-content-container{border:none}\n"]
|
---|
| 411 | },] }
|
---|
| 412 | ];
|
---|
| 413 | MatStepper.ctorParameters = () => [
|
---|
| 414 | { type: Directionality, decorators: [{ type: Optional }] },
|
---|
| 415 | { type: ChangeDetectorRef },
|
---|
| 416 | { type: ElementRef },
|
---|
| 417 | { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] }
|
---|
| 418 | ];
|
---|
| 419 | MatStepper.propDecorators = {
|
---|
| 420 | _stepHeader: [{ type: ViewChildren, args: [MatStepHeader,] }],
|
---|
| 421 | _steps: [{ type: ContentChildren, args: [MatStep, { descendants: true },] }],
|
---|
| 422 | _icons: [{ type: ContentChildren, args: [MatStepperIcon, { descendants: true },] }],
|
---|
| 423 | animationDone: [{ type: Output }],
|
---|
| 424 | disableRipple: [{ type: Input }],
|
---|
| 425 | color: [{ type: Input }],
|
---|
| 426 | labelPosition: [{ type: Input }]
|
---|
| 427 | };
|
---|
| 428 |
|
---|
| 429 | /**
|
---|
| 430 | * @license
|
---|
| 431 | * Copyright Google LLC All Rights Reserved.
|
---|
| 432 | *
|
---|
| 433 | * Use of this source code is governed by an MIT-style license that can be
|
---|
| 434 | * found in the LICENSE file at https://angular.io/license
|
---|
| 435 | */
|
---|
| 436 | /** Button that moves to the next step in a stepper workflow. */
|
---|
| 437 | class MatStepperNext extends CdkStepperNext {
|
---|
| 438 | }
|
---|
| 439 | MatStepperNext.decorators = [
|
---|
| 440 | { type: Directive, args: [{
|
---|
| 441 | selector: 'button[matStepperNext]',
|
---|
| 442 | host: {
|
---|
| 443 | 'class': 'mat-stepper-next',
|
---|
| 444 | '[type]': 'type',
|
---|
| 445 | },
|
---|
| 446 | inputs: ['type']
|
---|
| 447 | },] }
|
---|
| 448 | ];
|
---|
| 449 | /** Button that moves to the previous step in a stepper workflow. */
|
---|
| 450 | class MatStepperPrevious extends CdkStepperPrevious {
|
---|
| 451 | }
|
---|
| 452 | MatStepperPrevious.decorators = [
|
---|
| 453 | { type: Directive, args: [{
|
---|
| 454 | selector: 'button[matStepperPrevious]',
|
---|
| 455 | host: {
|
---|
| 456 | 'class': 'mat-stepper-previous',
|
---|
| 457 | '[type]': 'type',
|
---|
| 458 | },
|
---|
| 459 | inputs: ['type']
|
---|
| 460 | },] }
|
---|
| 461 | ];
|
---|
| 462 |
|
---|
| 463 | /**
|
---|
| 464 | * @license
|
---|
| 465 | * Copyright Google LLC All Rights Reserved.
|
---|
| 466 | *
|
---|
| 467 | * Use of this source code is governed by an MIT-style license that can be
|
---|
| 468 | * found in the LICENSE file at https://angular.io/license
|
---|
| 469 | */
|
---|
| 470 | class MatStepperModule {
|
---|
| 471 | }
|
---|
| 472 | MatStepperModule.decorators = [
|
---|
| 473 | { type: NgModule, args: [{
|
---|
| 474 | imports: [
|
---|
| 475 | MatCommonModule,
|
---|
| 476 | CommonModule,
|
---|
| 477 | PortalModule,
|
---|
| 478 | MatButtonModule,
|
---|
| 479 | CdkStepperModule,
|
---|
| 480 | MatIconModule,
|
---|
| 481 | MatRippleModule,
|
---|
| 482 | ],
|
---|
| 483 | exports: [
|
---|
| 484 | MatCommonModule,
|
---|
| 485 | MatStep,
|
---|
| 486 | MatStepLabel,
|
---|
| 487 | MatStepper,
|
---|
| 488 | MatStepperNext,
|
---|
| 489 | MatStepperPrevious,
|
---|
| 490 | MatStepHeader,
|
---|
| 491 | MatStepperIcon,
|
---|
| 492 | MatStepContent,
|
---|
| 493 | ],
|
---|
| 494 | declarations: [
|
---|
| 495 | MatHorizontalStepper,
|
---|
| 496 | MatVerticalStepper,
|
---|
| 497 | MatStep,
|
---|
| 498 | MatStepLabel,
|
---|
| 499 | MatStepper,
|
---|
| 500 | MatStepperNext,
|
---|
| 501 | MatStepperPrevious,
|
---|
| 502 | MatStepHeader,
|
---|
| 503 | MatStepperIcon,
|
---|
| 504 | MatStepContent,
|
---|
| 505 | ],
|
---|
| 506 | providers: [MAT_STEPPER_INTL_PROVIDER, ErrorStateMatcher],
|
---|
| 507 | },] }
|
---|
| 508 | ];
|
---|
| 509 |
|
---|
| 510 | /**
|
---|
| 511 | * @license
|
---|
| 512 | * Copyright Google LLC All Rights Reserved.
|
---|
| 513 | *
|
---|
| 514 | * Use of this source code is governed by an MIT-style license that can be
|
---|
| 515 | * found in the LICENSE file at https://angular.io/license
|
---|
| 516 | */
|
---|
| 517 |
|
---|
| 518 | /**
|
---|
| 519 | * Generated bundle index. Do not edit.
|
---|
| 520 | */
|
---|
| 521 |
|
---|
| 522 | export { MAT_STEPPER_INTL_PROVIDER, MAT_STEPPER_INTL_PROVIDER_FACTORY, MatHorizontalStepper, MatStep, MatStepContent, MatStepHeader, MatStepLabel, MatStepper, MatStepperIcon, MatStepperIntl, MatStepperModule, MatStepperNext, MatStepperPrevious, MatVerticalStepper, matStepperAnimations };
|
---|
| 523 | //# sourceMappingURL=stepper.js.map
|
---|