stepper.js 29 KB

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