blob: 104004a0d00bb91fd1dffabe4b17d236571e3c00 [file] [log] [blame]
import { CommonModule } from '@angular/common';
import { MatIconModule } from '@angular/material/icon';
import { MatRippleModule } from '@angular/material/core';
import { TemplatePortalDirective, TemplatePortal, PortalModule } from '@angular/cdk/portal';
import { mixinDisabled, mixinDisableRipple, tdCollapseAnimation, CovalentCommonModule } from '@covalent/core/common';
import { Directionality } from '@angular/cdk/bidi';
import { RIGHT_ARROW, LEFT_ARROW } from '@angular/cdk/keycodes';
import { ViewportRuler, ScrollDispatchModule } from '@angular/cdk/scrolling';
import { coerceBooleanProperty } from '@angular/cdk/coercion';
import { Component, Directive, Input, Output, TemplateRef, ViewChild, ViewContainerRef, ContentChild, EventEmitter, ContentChildren, ElementRef, ChangeDetectionStrategy, ChangeDetectorRef, Optional, Renderer2, NgModule } from '@angular/core';
import { Subject, merge, of } from 'rxjs';
import { distinctUntilChanged, takeUntil } from 'rxjs/operators';
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingReturn,uselessCode} checked by tsc
*/
/** @enum {string} */
const StepState = {
None: 'none',
Required: 'required',
Complete: 'complete',
};
class TdStepLabelDirective extends TemplatePortalDirective {
/**
* @param {?} templateRef
* @param {?} viewContainerRef
*/
constructor(templateRef, viewContainerRef) {
super(templateRef, viewContainerRef);
}
}
TdStepLabelDirective.decorators = [
{ type: Directive, args: [{
selector: '[td-step-label]ng-template',
},] }
];
/** @nocollapse */
TdStepLabelDirective.ctorParameters = () => [
{ type: TemplateRef },
{ type: ViewContainerRef }
];
class TdStepActionsDirective extends TemplatePortalDirective {
/**
* @param {?} templateRef
* @param {?} viewContainerRef
*/
constructor(templateRef, viewContainerRef) {
super(templateRef, viewContainerRef);
}
}
TdStepActionsDirective.decorators = [
{ type: Directive, args: [{
selector: '[td-step-actions]ng-template',
},] }
];
/** @nocollapse */
TdStepActionsDirective.ctorParameters = () => [
{ type: TemplateRef },
{ type: ViewContainerRef }
];
class TdStepSummaryDirective extends TemplatePortalDirective {
/**
* @param {?} templateRef
* @param {?} viewContainerRef
*/
constructor(templateRef, viewContainerRef) {
super(templateRef, viewContainerRef);
}
}
TdStepSummaryDirective.decorators = [
{ type: Directive, args: [{
selector: '[td-step-summary]ng-template',
},] }
];
/** @nocollapse */
TdStepSummaryDirective.ctorParameters = () => [
{ type: TemplateRef },
{ type: ViewContainerRef }
];
class TdStepBase {
}
/* tslint:disable-next-line */
/** @type {?} */
const _TdStepMixinBase = mixinDisableRipple(mixinDisabled(TdStepBase));
class TdStepComponent extends _TdStepMixinBase {
/**
* @param {?} _viewContainerRef
*/
constructor(_viewContainerRef) {
super();
this._viewContainerRef = _viewContainerRef;
this._active = false;
this._state = StepState.None;
/**
* activated?: function
* Event emitted when [TdStepComponent] is activated.
*/
this.onActivated = new EventEmitter();
/**
* deactivated?: function
* Event emitted when [TdStepComponent] is deactivated.
*/
this.onDeactivated = new EventEmitter();
}
/**
* @return {?}
*/
get stepContent() {
return this._contentPortal;
}
/**
* active?: boolean
* Toggles [TdStepComponent] between active/deactive.
* @param {?} active
* @return {?}
*/
set active(active) {
this._setActive(coerceBooleanProperty(active));
}
/**
* @return {?}
*/
get active() {
return this._active;
}
/**
* state?: StepState or ['none' | 'required' | 'complete']
* Sets state of [TdStepComponent] depending on value.
* Defaults to [StepState.None | 'none'].
* @param {?} state
* @return {?}
*/
set state(state) {
switch (state) {
case StepState.Complete:
this._state = StepState.Complete;
break;
case StepState.Required:
this._state = StepState.Required;
break;
default:
this._state = StepState.None;
break;
}
}
/**
* @return {?}
*/
get state() {
return this._state;
}
/**
* @return {?}
*/
ngOnInit() {
this._contentPortal = new TemplatePortal(this._content, this._viewContainerRef);
}
/**
* Toggle active state of [TdStepComponent]
* retuns 'true' if successful, else 'false'.
* @return {?}
*/
toggle() {
return this._setActive(!this._active);
}
/**
* Opens [TdStepComponent]
* retuns 'true' if successful, else 'false'.
* @return {?}
*/
open() {
return this._setActive(true);
}
/**
* Closes [TdStepComponent]
* retuns 'true' if successful, else 'false'.
* @return {?}
*/
close() {
return this._setActive(false);
}
/**
* Returns 'true' if [state] equals to [StepState.Complete | 'complete'], else 'false'.
* @return {?}
*/
isComplete() {
return this._state === StepState.Complete;
}
/**
* Method executed when the disabled value changes
* @param {?} v
* @return {?}
*/
onDisabledChange(v) {
if (v && this._active) {
this._active = false;
this._onDeactivated();
}
}
/**
* Method to change active state internally and emit the [onActivated] event if 'true' or [onDeactivated]
* event if 'false'. (Blocked if [disabled] is 'true')
* returns true if successfully changed state
* @param {?} newActive
* @return {?}
*/
_setActive(newActive) {
if (this.disabled) {
return false;
}
if (this._active !== newActive) {
this._active = newActive;
if (newActive) {
this._onActivated();
}
else {
this._onDeactivated();
}
return true;
}
return false;
}
/**
* @return {?}
*/
_onActivated() {
this.onActivated.emit(undefined);
}
/**
* @return {?}
*/
_onDeactivated() {
this.onDeactivated.emit(undefined);
}
}
TdStepComponent.decorators = [
{ type: Component, args: [{
selector: 'td-step',
inputs: ['disabled', 'disableRipple'],
template: "<ng-template>\n <ng-content></ng-content>\n</ng-template>"
}] }
];
/** @nocollapse */
TdStepComponent.ctorParameters = () => [
{ type: ViewContainerRef }
];
TdStepComponent.propDecorators = {
_content: [{ type: ViewChild, args: [TemplateRef,] }],
stepLabel: [{ type: ContentChild, args: [TdStepLabelDirective,] }],
stepActions: [{ type: ContentChild, args: [TdStepActionsDirective,] }],
stepSummary: [{ type: ContentChild, args: [TdStepSummaryDirective,] }],
label: [{ type: Input, args: ['label',] }],
sublabel: [{ type: Input, args: ['sublabel',] }],
active: [{ type: Input, args: ['active',] }],
state: [{ type: Input, args: ['state',] }],
onActivated: [{ type: Output, args: ['activated',] }],
onDeactivated: [{ type: Output, args: ['deactivated',] }]
};
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingReturn,uselessCode} checked by tsc
*/
/** @enum {string} */
const StepMode = {
Vertical: 'vertical',
Horizontal: 'horizontal',
};
class TdStepsComponent {
constructor() {
this._mode = StepMode.Vertical;
/**
* stepChange?: function
* Method to be executed when [onStepChange] event is emitted.
* Emits an [IStepChangeEvent] implemented object.
*/
this.onStepChange = new EventEmitter();
}
/**
* @param {?} steps
* @return {?}
*/
set stepsContent(steps) {
if (steps) {
this._steps = steps;
this._registerSteps();
}
}
/**
* @return {?}
*/
get steps() {
return this._steps.toArray();
}
/**
* mode?: StepMode or ["vertical" | "horizontal"]
* Defines if the mode of the [TdStepsComponent]. Defaults to [StepMode.Vertical | "vertical"]
* @param {?} mode
* @return {?}
*/
set mode(mode) {
switch (mode) {
case StepMode.Horizontal:
this._mode = StepMode.Horizontal;
break;
default:
this._mode = StepMode.Vertical;
}
}
/**
* @return {?}
*/
get mode() {
return this._mode;
}
/**
* Executed after content is initialized, loops through any [TdStepComponent] children elements,
* assigns them a number and subscribes as an observer to their [onActivated] event.
* @return {?}
*/
ngAfterContentInit() {
this._registerSteps();
}
/**
* Unsubscribes from [TdStepComponent] children elements when component is destroyed.
* @return {?}
*/
ngOnDestroy() {
this._deregisterSteps();
}
/**
* Returns 'true' if [mode] equals to [StepMode.Horizontal | 'horizontal'], else 'false'.
* @return {?}
*/
isHorizontal() {
return this._mode === StepMode.Horizontal;
}
/**
* Returns 'true' if [mode] equals to [StepMode.Vertical | 'vertical'], else 'false'.
* @return {?}
*/
isVertical() {
return this._mode === StepMode.Vertical;
}
/**
* @return {?}
*/
areStepsActive() {
return this._steps.filter((step) => {
return step.active;
}).length > 0;
}
/**
* Wraps previous and new [TdStepComponent] numbers in an object that implements [IStepChangeEvent]
* and emits [onStepChange] event.
* @param {?} step
* @return {?}
*/
_onStepSelection(step) {
if (this.prevStep !== step) {
/** @type {?} */
let prevStep = this.prevStep;
this.prevStep = step;
/** @type {?} */
let event = {
newStep: step,
prevStep: prevStep,
};
this._deactivateAllBut(step);
this.onStepChange.emit(event);
}
}
/**
* Loops through [TdStepComponent] children elements and deactivates them ignoring the one passed as an argument.
* @param {?} activeStep
* @return {?}
*/
_deactivateAllBut(activeStep) {
this._steps.filter((step) => step !== activeStep)
.forEach((step) => {
step.active = false;
});
}
/**
* @return {?}
*/
_registerSteps() {
this._subcriptions = [];
this._steps.toArray().forEach((step) => {
/** @type {?} */
let subscription = step.onActivated.asObservable().subscribe(() => {
this._onStepSelection(step);
});
this._subcriptions.push(subscription);
});
}
/**
* @return {?}
*/
_deregisterSteps() {
if (this._subcriptions) {
this._subcriptions.forEach((subs) => {
subs.unsubscribe();
});
this._subcriptions = undefined;
}
}
}
TdStepsComponent.decorators = [
{ type: Component, args: [{
selector: 'td-steps',
template: "<div *ngIf=\"isHorizontal()\" class=\"td-steps-header\">\n <ng-template let-step let-index=\"index\" let-last=\"last\" ngFor [ngForOf]=\"steps\">\n <td-step-header class=\"td-step-horizontal-header\"\n (keydown.enter)=\"step.open()\"\n [number]=\"index + 1\"\n [active]=\"step.active\"\n [disableRipple]=\"step.disableRipple\"\n [disabled]=\"step.disabled\" \n [state]=\"step.state\"\n (click)=\"step.open()\">\n <ng-template td-step-header-label [cdkPortalOutlet]=\"step.stepLabel\"></ng-template>\n <ng-template td-step-header-label [ngIf]=\"!step.stepLabel\">{{step.label}}</ng-template>\n <ng-template td-step-header-sublabel [ngIf]=\"true\">{{step.sublabel | truncate:30}}</ng-template>\n </td-step-header>\n <span *ngIf=\"!last\" class=\"td-horizontal-line\"></span>\n </ng-template>\n</div>\n<div *ngFor=\"let step of steps; let index = index; let last = last\" class=\"td-step\">\n <td-step-header class=\"td-step-vertical-header\"\n (keydown.enter)=\"step.toggle()\"\n [number]=\"index + 1\"\n [active]=\"step.active\" \n [disabled]=\"step.disabled\"\n [disableRipple]=\"step.disableRipple\"\n [state]=\"step.state\"\n (click)=\"step.toggle()\"\n *ngIf=\"isVertical()\">\n <ng-template td-step-header-label [cdkPortalOutlet]=\"step.stepLabel\"></ng-template>\n <ng-template td-step-header-label [ngIf]=\"!step.stepLabel\">{{step.label}}</ng-template>\n <ng-template td-step-header-sublabel [ngIf]=\"true\">{{step.sublabel}}</ng-template>\n </td-step-header>\n <ng-template [ngIf]=\"isVertical() || step.active || (!areStepsActive() && prevStep === step)\">\n <td-step-body [active]=\"step.active\" [state]=\"step.state\">\n <div *ngIf=\"isVertical()\" class=\"td-line-wrapper\">\n <div *ngIf=\"!last\" class=\"td-vertical-line\"></div>\n </div>\n <ng-template td-step-body-content [cdkPortalOutlet]=\"step.stepContent\"></ng-template>\n <ng-template td-step-body-actions [cdkPortalOutlet]=\"step.stepActions\"></ng-template>\n <ng-template td-step-body-summary [cdkPortalOutlet]=\"step.stepSummary\"></ng-template>\n </td-step-body>\n </ng-template>\n</div>\n",
/* tslint:disable-next-line */
host: {
class: 'td-steps',
},
styles: [".td-line-wrapper,.td-step{position:relative}.td-steps-header{-webkit-box-sizing:border-box;box-sizing:border-box;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:horizontal;-webkit-box-direction:normal;-ms-flex-direction:row;flex-direction:row}.td-line-wrapper{width:24px;min-height:1px}.td-horizontal-line{border-bottom-width:1px;border-bottom-style:solid;height:1px;position:relative;top:36px;min-width:15px;-webkit-box-flex:1;-ms-flex:1;flex:1;-webkit-box-sizing:border-box;box-sizing:border-box}::ng-deep :not([dir=rtl]) .td-horizontal-line{left:-6px;right:-3px}::ng-deep [dir=rtl] .td-horizontal-line{left:-3px;right:-6px}.td-vertical-line{position:absolute;bottom:-16px;top:-16px;border-left-width:1px;border-left-style:solid}::ng-deep :not([dir=rtl]) .td-vertical-line{left:20px;right:auto}::ng-deep [dir=rtl] .td-vertical-line{left:auto;right:20px}"]
}] }
];
TdStepsComponent.propDecorators = {
stepsContent: [{ type: ContentChildren, args: [TdStepComponent,] }],
mode: [{ type: Input, args: ['mode',] }],
onStepChange: [{ type: Output, args: ['stepChange',] }]
};
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingReturn,uselessCode} checked by tsc
*/
class TdStepHeaderBase {
}
/* tslint:disable-next-line */
/** @type {?} */
const _TdStepHeaderMixinBase = mixinDisableRipple(mixinDisabled(TdStepHeaderBase));
class TdStepHeaderComponent extends _TdStepHeaderMixinBase {
constructor() {
super(...arguments);
/**
* state?: StepState or ['none' | 'required' | 'complete']
* Sets styles for state of header.
* Defaults to [StepState.None | 'none'].
*/
this.state = StepState.None;
}
/**
* Returns 'true' if [state] equals to [StepState.Complete | 'complete'], else 'false'.
* @return {?}
*/
isComplete() {
return this.state === StepState.Complete;
}
/**
* Returns 'true' if [state] equals to [StepState.Required | 'required'], else 'false'.
* @return {?}
*/
isRequired() {
return this.state === StepState.Required;
}
}
TdStepHeaderComponent.decorators = [
{ type: Component, args: [{
selector: 'td-step-header',
inputs: ['disabled', 'disableRipple'],
template: "<div class=\"td-step-header\"\n [class.mat-disabled]=\"disabled\"\n matRipple\n [matRippleDisabled]=\"disabled || disableRipple\"\n [tabIndex]=\"disabled ? -1 : (tabIndex || 0)\">\n <div class=\"td-circle\"\n [class.mat-inactive]=\"(!active && !isComplete()) || disabled\"\n [class.mat-active]=\"active && !disabled\"\n *ngIf=\"!isRequired() && !isComplete()\">\n <span *ngIf=\"(active || !isComplete())\">{{number || ''}}</span>\n </div>\n <div class=\"td-complete\" *ngIf=\"isComplete()\">\n <mat-icon class=\"mat-complete\">check_circle</mat-icon>\n </div>\n <div class=\"td-triangle\"\n [class.bg-muted]=\"disabled\"\n *ngIf=\"isRequired()\">\n <mat-icon class=\"mat-warn\">warning</mat-icon>\n </div>\n <div class=\"td-step-label-wrapper\"\n [class.mat-inactive]=\"(!active && !isComplete()) || disabled\"\n [class.mat-warn]=\"isRequired() && !disabled\">\n <div class=\"td-step-label\">\n <ng-content select=\"[td-step-header-label]\"></ng-content>\n </div>\n <div class=\"td-step-sublabel\">\n <ng-content select=\"[td-step-header-sublabel]\"></ng-content>\n </div>\n </div>\n <span class=\"td-step-header-separator\"></span>\n <mat-icon class=\"td-edit-icon\" *ngIf=\"isComplete() && !active && !disabled\">mode_edit</mat-icon>\n</div>",
styles: [".td-step-header{position:relative;outline:0;min-width:120px;height:72px;-webkit-box-orient:horizontal;-webkit-box-direction:normal;-ms-flex-direction:row;flex-direction:row;-webkit-box-sizing:border-box;box-sizing:border-box;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-flex:1;-ms-flex:1;flex:1;-webkit-box-pack:start;-ms-flex-pack:start;justify-content:flex-start;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-ms-flex-line-pack:center;align-content:center;max-width:100%}.td-step-header:hover:not(.mat-disabled){cursor:pointer}.td-step-header mat-icon.td-edit-icon{margin:0 8px}.td-step-header mat-icon.mat-warn{font-size:24px;height:24px;width:24px}.td-step-header mat-icon.mat-complete{position:relative;left:-2px;top:2px;font-size:28px;height:24px;width:24px}.td-step-header .td-circle{height:24px;width:24px;line-height:24px;border-radius:99%;text-align:center;-webkit-box-flex:0;-ms-flex:none;flex:none}.td-step-header .td-circle mat-icon{margin-top:2px;font-weight:700}.td-step-header .td-triangle>mat-icon{font-size:25px}::ng-deep :not([dir=rtl]) .td-step-header .td-circle,::ng-deep :not([dir=rtl]) .td-step-header .td-complete,::ng-deep :not([dir=rtl]) .td-step-header .td-triangle{margin-left:8px;margin-right:0}::ng-deep [dir=rtl] .td-step-header .td-circle,::ng-deep [dir=rtl] .td-step-header .td-complete,::ng-deep [dir=rtl] .td-step-header .td-triangle{margin-left:0;margin-right:8px}.td-step-header .td-circle,.td-step-header .td-complete{font-size:14px}.td-step-header .td-step-label-wrapper{padding-left:8px;padding-right:8px}.td-step-header .td-step-header-separator{-webkit-box-flex:1;-ms-flex:1;flex:1;-webkit-box-sizing:border-box;box-sizing:border-box}"]
}] }
];
TdStepHeaderComponent.propDecorators = {
number: [{ type: Input, args: ['number',] }],
active: [{ type: Input, args: ['active',] }],
state: [{ type: Input, args: ['state',] }],
tabIndex: [{ type: Input, args: ['tabIndex',] }]
};
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingReturn,uselessCode} checked by tsc
*/
class TdStepBodyComponent {
constructor() {
/**
* state?: StepState or ['none' | 'required' | 'complete']
* Sets styles for state of body.
* Defaults to [StepState.None | 'none'].
*/
this.state = StepState.None;
}
/**
* @return {?}
*/
get hasContent() {
return this.contentRef &&
(this.contentRef.nativeElement.children.length > 0 || !!this.contentRef.nativeElement.textContent.trim());
}
/**
* @return {?}
*/
get hasActions() {
return this.actionsRef &&
(this.actionsRef.nativeElement.children.length > 0 || !!this.actionsRef.nativeElement.textContent.trim());
}
/**
* @return {?}
*/
get hasSummary() {
return this.summaryRef &&
(this.summaryRef.nativeElement.children.length > 0 || !!this.summaryRef.nativeElement.textContent.trim());
}
/**
* Returns 'true' if [state] equals to [StepState.Complete | 'complete'], else 'false'.
* @return {?}
*/
isComplete() {
return this.state === StepState.Complete;
}
}
TdStepBodyComponent.decorators = [
{ type: Component, args: [{
selector: 'td-step-body',
template: "<ng-content></ng-content>\n<div class=\"td-step-body\">\n <div class=\"td-step-content-wrapper\"\n [@tdCollapse]=\"!active\">\n <div #contentRef cdkScrollable [class.td-step-content]=\"hasContent\">\n <ng-content select=\"[td-step-body-content]\"></ng-content>\n </div>\n <div #actionsRef\n [class.td-step-actions]=\"hasActions\">\n <ng-content select=\"[td-step-body-actions]\"></ng-content>\n </div>\n </div>\n <div #summaryRef\n [@tdCollapse]=\"active || !isComplete()\"\n [class.td-step-summary]=\"hasSummary\">\n <ng-content select=\"[td-step-body-summary]\"></ng-content>\n </div>\n</div>",
animations: [
tdCollapseAnimation,
],
styles: [":host{-webkit-box-sizing:border-box;box-sizing:border-box;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:horizontal;-webkit-box-direction:normal;-ms-flex-direction:row;flex-direction:row}:host .td-step-body{overflow-x:hidden;-webkit-box-flex:1;-ms-flex:1;flex:1;-webkit-box-sizing:border-box;box-sizing:border-box}:host .td-step-body .td-step-content-wrapper.ng-animating,:host .td-step-body .td-step-summary.ng-animating{overflow:hidden}:host .td-step-body .td-step-content{overflow-x:auto}:host .td-step-body .td-step-actions{-webkit-box-sizing:border-box;box-sizing:border-box;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:horizontal;-webkit-box-direction:normal;-ms-flex-direction:row;flex-direction:row}"]
}] }
];
TdStepBodyComponent.propDecorators = {
contentRef: [{ type: ViewChild, args: ['contentRef', { read: ElementRef },] }],
actionsRef: [{ type: ViewChild, args: ['actionsRef', { read: ElementRef },] }],
summaryRef: [{ type: ViewChild, args: ['summaryRef', { read: ElementRef },] }],
active: [{ type: Input, args: ['active',] }],
state: [{ type: Input, args: ['state',] }]
};
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingReturn,uselessCode} checked by tsc
*/
class TdNavStepLinkComponent extends _TdStepMixinBase {
/**
* @param {?} _changeDetectorRef
* @param {?} elementRef
*/
constructor(_changeDetectorRef, elementRef) {
super();
this._changeDetectorRef = _changeDetectorRef;
this.elementRef = elementRef;
this._active = false;
this._state = StepState.None;
}
/**
* state?: StepState or ['none' | 'required' | 'complete']
* Sets state of component depending on value.
* Defaults to [StepState.None | 'none'].
* @param {?} state
* @return {?}
*/
set state(state) {
switch (state) {
case StepState.Complete:
this._state = StepState.Complete;
break;
case StepState.Required:
this._state = StepState.Required;
break;
default:
this._state = StepState.None;
break;
}
}
/**
* @return {?}
*/
get state() {
return this._state;
}
/**
* active?: boolean
* Toggles component between active/deactive.
* @param {?} active
* @return {?}
*/
set active(active) {
this._active = coerceBooleanProperty(active);
this._changeDetectorRef.markForCheck();
}
/**
* @return {?}
*/
get active() {
return this._active;
}
/**
* @param {?} click
* @return {?}
*/
_handleClick(click) {
if (this.disabled) {
click.preventDefault();
click.stopImmediatePropagation();
}
}
}
TdNavStepLinkComponent.decorators = [
{ type: Component, args: [{
selector: '[td-step-link],[tdStepLink]',
template: "<td-step-header class=\"td-step-header-wrapper\"\n [tabIndex]=\"-1\"\n [number]=\"number\"\n [active]=\"active\"\n [disableRipple]=\"disableRipple || disabled\"\n [disabled]=\"disabled\" \n [state]=\"state\">\n <ng-template td-step-header-label [ngIf]=\"true\">{{label}}</ng-template>\n <ng-template td-step-header-sublabel [ngIf]=\"true\">{{sublabel | truncate:30}}</ng-template>\n <ng-content></ng-content>\n</td-step-header>",
inputs: ['disabled', 'disableRipple'],
changeDetection: ChangeDetectionStrategy.OnPush,
/* tslint:disable-next-line */
host: {
'[class.td-step-link]': 'true',
'[attr.tabindex]': 'disabled ? -1 : (tabIndex || 0)',
'[attr.disabled]': 'disabled || null',
'[class.mat-disabled]': 'disabled || null',
'(click)': '_handleClick($event)',
},
styles: [":host{-webkit-box-sizing:border-box;box-sizing:border-box;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:horizontal;-webkit-box-direction:normal;-ms-flex-direction:row;flex-direction:row;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-ms-flex-line-pack:center;align-content:center;max-width:100%;-webkit-box-pack:start;-ms-flex-pack:start;justify-content:flex-start}:host.mat-disabled{pointer-events:none}:host .td-step-header-wrapper{width:100%}"]
}] }
];
/** @nocollapse */
TdNavStepLinkComponent.ctorParameters = () => [
{ type: ChangeDetectorRef },
{ type: ElementRef }
];
TdNavStepLinkComponent.propDecorators = {
state: [{ type: Input, args: ['state',] }],
label: [{ type: Input, args: ['label',] }],
sublabel: [{ type: Input, args: ['sublabel',] }],
active: [{ type: Input, args: ['active',] }],
tabIndex: [{ type: Input, args: ['tabIndex',] }]
};
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingReturn,uselessCode} checked by tsc
*/
class TdNavStepsHorizontalComponent {
/**
* @param {?} _elementRef
* @param {?} _viewportRuler
* @param {?} _dir
* @param {?} _renderer
* @param {?} _changeDetectorRef
*/
constructor(_elementRef, _viewportRuler, _dir, _renderer, _changeDetectorRef) {
this._elementRef = _elementRef;
this._viewportRuler = _viewportRuler;
this._dir = _dir;
this._renderer = _renderer;
this._changeDetectorRef = _changeDetectorRef;
this._separators = [];
/**
* Emits when the component is destroyed.
*/
this._destroyed = new Subject();
this._widthSubject = new Subject();
this._scrollDistance = 0;
this._scrollDistanceChanged = false;
/**
* Whether the controls for pagination should be displayed
*/
this._showPaginationControls = false;
/**
* Whether the step list can be scrolled more towards the end.
*/
this._disableScrollAfter = true;
/**
* Whether the step list can be scrolled more towards the beginning.
*/
this._disableScrollBefore = true;
}
/*
* Current width of the element container
*/
/**
* @return {?}
*/
get nativeElementWidth() {
/** @type {?} */
let element = ((/** @type {?} */ (this._elementRef.nativeElement)));
// Need to take into account border, margin and padding that might be around all the crumbs
/** @type {?} */
let style = window.getComputedStyle(element);
/** @type {?} */
let borderLeft = parseInt(style.borderLeft, 10);
/** @type {?} */
let borderRight = parseInt(style.borderRight, 10);
/** @type {?} */
let marginLeft = parseInt(style.marginLeft, 10);
/** @type {?} */
let marginRight = parseInt(style.marginRight, 10);
/** @type {?} */
let paddingLeft = parseInt(style.paddingLeft, 10);
/** @type {?} */
let paddingRight = parseInt(style.paddingRight, 10);
return element.getBoundingClientRect().width - borderLeft - borderRight - marginLeft - marginRight - paddingLeft - paddingRight;
}
/**
* @return {?}
*/
ngAfterContentInit() {
merge(this._widthSubject.asObservable().pipe(distinctUntilChanged()), this._viewportRuler.change(150), this._dir ? this._dir.change : of(undefined), this._steps.changes).pipe(takeUntil(this._destroyed)).subscribe(() => {
this._configureSteps();
this.updatePagination();
this._changeDetectorRef.markForCheck();
});
this._configureSteps();
this._changeDetectorRef.markForCheck();
}
/**
* @return {?}
*/
ngAfterContentChecked() {
if (this._elementRef && this._elementRef.nativeElement) {
this._widthSubject.next(this.nativeElementWidth);
}
if (this._scrollDistanceChanged) {
this._updateStepScrollPosition();
this._scrollDistanceChanged = false;
this._changeDetectorRef.markForCheck();
}
}
/**
* @return {?}
*/
ngOnDestroy() {
this._destroyed.next();
this._destroyed.complete();
}
/**
* Listen to right and left key events to move the the viewport.
* @param {?} event
* @return {?}
*/
_handleKeydown(event) {
switch (event.keyCode) {
case LEFT_ARROW:
this._scrollHeader('before');
event.preventDefault();
break;
case RIGHT_ARROW:
this._scrollHeader('after');
event.preventDefault();
break;
default:
// do something
}
}
/**
* Updates the view whether pagination should be enabled or not.
* @return {?}
*/
updatePagination() {
this._checkPaginationEnabled();
this._checkScrollingControls();
this._updateStepScrollPosition();
}
/**
* The layout direction of the containing app.
* @return {?}
*/
_getLayoutDirection() {
return this._dir && this._dir.value === 'rtl' ? 'rtl' : 'ltr';
}
/**
* Performs the CSS transformation on the step list that will cause the list to scroll.
* @return {?}
*/
_updateStepScrollPosition() {
/** @type {?} */
const translateX = this._getLayoutDirection() === 'ltr' ? -this.scrollDistance : this.scrollDistance;
// Move step list the amount of pixels scrolled
this._stepList.nativeElement.style.transform = `translateX(${Math.round(translateX)}px)`;
// Setting the `transform` on IE will change the scroll offset of the parent, causing the
// position to be thrown off in some cases. We have to reset it ourselves to ensure that
// it doesn't get thrown off.
if (this._getLayoutDirection() === 'ltr') {
this._stepListContainer.nativeElement.scrollLeft = 0;
}
else {
this._stepListContainer.nativeElement.scrollLeft = this._getMaxScrollDistance();
}
}
/**
* Sets the distance in pixels that the step header should be transformed in the X-axis.
* @return {?}
*/
get scrollDistance() { return this._scrollDistance; }
/**
* @param {?} v
* @return {?}
*/
set scrollDistance(v) {
this._scrollDistance = Math.max(0, Math.min(this._getMaxScrollDistance(), v));
// Mark that the scroll distance has changed so that after the view is checked, the CSS
// transformation can move the header.
this._scrollDistanceChanged = true;
this._checkScrollingControls();
}
/**
* Moves the step list in the 'before' or 'after' direction (towards the beginning of the list or
* the end of the list, respectively).
* @param {?} scrollDir
* @return {?}
*/
_scrollHeader(scrollDir) {
// Move the scroll distance one-half the length of the step list's viewport.
this.scrollDistance += (scrollDir === 'before' ? -1 : 1) * this._stepListContainer.nativeElement.offsetWidth / 2;
}
/**
* Evaluate whether the pagination controls should be displayed. If the scroll width of the
* step list is wider than the size of the header container, then the pagination controls should
* be shown.
* @return {?}
*/
_checkPaginationEnabled() {
/** @type {?} */
const isEnabled = this._stepList.nativeElement.scrollWidth > this._elementRef.nativeElement.offsetWidth;
if (!isEnabled) {
this.scrollDistance = 0;
}
if (isEnabled !== this._showPaginationControls) {
this._changeDetectorRef.markForCheck();
}
this._showPaginationControls = isEnabled;
}
/**
* Evaluate whether the before and after controls should be enabled or disabled.
* If the header is at the beginning of the list (scroll distance is equal to 0) then disable the
* before button. If the header is at the end of the list (scroll distance is equal to the
* maximum distance we can scroll), then disable the after button.
* @return {?}
*/
_checkScrollingControls() {
// Check if the pagination arrows should be activated.
this._disableScrollBefore = this.scrollDistance === 0;
this._disableScrollAfter = this.scrollDistance === this._getMaxScrollDistance();
this._changeDetectorRef.markForCheck();
}
/**
* Determines what is the maximum length in pixels that can be set for the scroll distance. This
* is equal to the difference in width between the step list container and step header container.
* @return {?}
*/
_getMaxScrollDistance() {
return (this._stepList.nativeElement.scrollWidth - this._stepListContainer.nativeElement.offsetWidth) || 0;
}
/**
* Set the step line separators and display numbers
* @return {?}
*/
_configureSteps() {
this._separators.forEach((separator) => {
this._renderer.removeChild(this._stepList.nativeElement, separator);
});
/** @type {?} */
let stepsArray = this._steps.toArray();
// set the index number of the step so can display that number in circle
stepsArray.forEach((step, index) => {
if (index > 0 && index < stepsArray.length) {
/** @type {?} */
let separator = this._renderer.createElement('div');
this._renderer.addClass(separator, 'td-horizontal-line');
this._separators.push(separator);
this._renderer.insertBefore(this._stepList.nativeElement, separator, step.elementRef.nativeElement);
}
step.number = index + 1;
});
}
}
TdNavStepsHorizontalComponent.decorators = [
{ type: Component, args: [{
selector: 'nav[td-steps][horizontal]',
template: "<div class=\"td-steps-header\">\n <div class=\"td-step-header-pagination td-step-header-pagination-before mat-elevation-z4\"\n aria-hidden=\"true\"\n mat-ripple [matRippleDisabled]=\"_disableScrollBefore\"\n [class.td-step-header-pagination-disabled]=\"_disableScrollBefore\"\n (click)=\"_scrollHeader('before')\">\n <div class=\"td-step-header-pagination-chevron\"></div>\n </div>\n <div #stepListContainer class=\"td-steps-header-container\" (keydown)=\"_handleKeydown($event)\">\n <div #stepList class=\"td-steps-header-list\">\n <ng-content></ng-content>\n </div>\n </div>\n <div class=\"td-step-header-pagination td-step-header-pagination-after mat-elevation-z4\"\n aria-hidden=\"true\"\n mat-ripple [matRippleDisabled]=\"_disableScrollAfter\"\n [class.td-step-header-pagination-disabled]=\"_disableScrollAfter\"\n (click)=\"_scrollHeader('after')\">\n <div class=\"td-step-header-pagination-chevron\"></div>\n </div>\n</div>\n",
changeDetection: ChangeDetectionStrategy.OnPush,
/* tslint:disable-next-line */
host: {
class: 'td-steps td-steps-horizontal',
'[class.td-step-header-pagination-controls-enabled]': '_showPaginationControls',
'[class.td-step-header-rtl]': "_getLayoutDirection() == 'rtl'",
},
styles: [":host{width:100%;display:block}.td-steps-header,.td-steps-header-list{-webkit-box-sizing:border-box;box-sizing:border-box;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:horizontal;-webkit-box-direction:normal;-ms-flex-direction:row;flex-direction:row}.td-steps-header-container{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-flex:1;-ms-flex-positive:1;flex-grow:1;overflow:hidden;z-index:1}.td-steps-header-list{-webkit-box-flex:1;-ms-flex-positive:1;flex-grow:1;position:relative;-webkit-transition:-webkit-transform .5s cubic-bezier(.35,0,.25,1);transition:transform .5s cubic-bezier(.35,0,.25,1),-webkit-transform .5s cubic-bezier(.35,0,.25,1);-webkit-box-align:center;-ms-flex-align:center;align-items:center;-ms-flex-line-pack:center;align-content:center;max-width:100%;-webkit-box-pack:start;-ms-flex-pack:start;justify-content:flex-start}.td-step-header-pagination{position:relative;display:none;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;min-width:32px;cursor:pointer;z-index:2}:host.td-step-header-pagination-controls-enabled .td-step-header-pagination{display:-webkit-box;display:-ms-flexbox;display:flex}.td-step-header-pagination-before,:host.td-step-header-rtl .td-step-header-pagination-after{padding-left:4px}.td-step-header-pagination-before .td-step-header-pagination-chevron,:host.td-step-header-rtl .td-step-header-pagination-after .td-step-header-pagination-chevron{-webkit-transform:rotate(-135deg);-ms-transform:rotate(-135deg);transform:rotate(-135deg)}.td-step-header-pagination-after,:host.td-step-header-rtl .td-step-header-pagination-before{padding-right:4px}.td-step-header-pagination-after .td-step-header-pagination-chevron,:host.td-step-header-rtl .td-step-header-pagination-before .td-step-header-pagination-chevron{-webkit-transform:rotate(45deg);-ms-transform:rotate(45deg);transform:rotate(45deg)}.td-step-header-pagination-chevron{border-style:solid;border-width:2px 2px 0 0;content:'';height:8px;width:8px}.td-step-header-pagination-disabled{-webkit-box-shadow:none;box-shadow:none;cursor:default}.td-horizontal-line{border-bottom-width:1px;border-bottom-style:solid;height:1px;min-width:20px;-webkit-box-flex:1;-ms-flex:1;flex:1;-webkit-box-sizing:border-box;box-sizing:border-box}"]
}] }
];
/** @nocollapse */
TdNavStepsHorizontalComponent.ctorParameters = () => [
{ type: ElementRef },
{ type: ViewportRuler },
{ type: Directionality, decorators: [{ type: Optional }] },
{ type: Renderer2 },
{ type: ChangeDetectorRef }
];
TdNavStepsHorizontalComponent.propDecorators = {
_steps: [{ type: ContentChildren, args: [TdNavStepLinkComponent,] }],
_stepListContainer: [{ type: ViewChild, args: ['stepListContainer',] }],
_stepList: [{ type: ViewChild, args: ['stepList',] }]
};
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingReturn,uselessCode} checked by tsc
*/
class TdNavStepsVerticalComponent {
/**
* @param {?} _renderer
* @param {?} _changeDetectorRef
*/
constructor(_renderer, _changeDetectorRef) {
this._renderer = _renderer;
this._changeDetectorRef = _changeDetectorRef;
this._separators = [];
/**
* Emits when the component is destroyed.
*/
this._destroyed = new Subject();
}
/**
* @return {?}
*/
ngAfterContentInit() {
this._steps.changes.pipe(takeUntil(this._destroyed)).subscribe(() => {
this._configureSteps();
this._changeDetectorRef.markForCheck();
});
this._configureSteps();
this._changeDetectorRef.markForCheck();
}
/**
* @return {?}
*/
ngOnDestroy() {
this._destroyed.next();
this._destroyed.complete();
}
/**
* Set the step line separators and display numbers
* @return {?}
*/
_configureSteps() {
this._separators.forEach((separator) => {
this._renderer.removeChild(this._stepList.nativeElement, separator);
});
/** @type {?} */
let stepsArray = this._steps.toArray();
// set the index number of the step so can display that number in circle
stepsArray.forEach((step, index) => {
if (index > 0 && index < stepsArray.length) {
/** @type {?} */
let separator = this._renderer.createElement('div');
this._renderer.addClass(separator, 'td-vertical-line-wrapper');
/** @type {?} */
let separatorChild = this._renderer.createElement('div');
this._renderer.addClass(separatorChild, 'td-vertical-line');
this._renderer.appendChild(separator, separatorChild);
this._separators.push(separator);
this._renderer.insertBefore(this._stepList.nativeElement, separator, step.elementRef.nativeElement);
}
step.number = index + 1;
});
}
}
TdNavStepsVerticalComponent.decorators = [
{ type: Component, args: [{
selector: 'nav[td-steps][vertical]',
template: "<div class=\"td-steps-header\">\n <div class=\"td-steps-header-container\">\n <div #stepList class=\"td-steps-header-list\">\n <ng-content></ng-content>\n </div>\n </div>\n</div>\n ",
changeDetection: ChangeDetectionStrategy.OnPush,
/* tslint:disable-next-line */
host: {
class: 'td-steps td-steps-vertical',
},
styles: [".td-vertical-line-wrapper{position:relative}.td-vertical-line-wrapper .td-vertical-line{position:absolute;top:-16px;height:34px;border-left-width:1px;border-left-style:solid}::ng-deep :not([dir=rtl]) .td-vertical-line-wrapper .td-vertical-line{left:20px;right:auto}::ng-deep [dir=rtl] .td-vertical-line-wrapper .td-vertical-line{left:auto;right:20px}"]
}] }
];
/** @nocollapse */
TdNavStepsVerticalComponent.ctorParameters = () => [
{ type: Renderer2 },
{ type: ChangeDetectorRef }
];
TdNavStepsVerticalComponent.propDecorators = {
_steps: [{ type: ContentChildren, args: [TdNavStepLinkComponent,] }],
_stepList: [{ type: ViewChild, args: ['stepList',] }]
};
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingReturn,uselessCode} checked by tsc
*/
/** @type {?} */
const TD_STEPS = [
TdStepsComponent,
TdStepComponent,
TdStepHeaderComponent,
TdStepBodyComponent,
TdStepLabelDirective,
TdStepActionsDirective,
TdStepSummaryDirective,
TdNavStepsHorizontalComponent,
TdNavStepsVerticalComponent,
TdNavStepLinkComponent,
];
class CovalentStepsModule {
}
CovalentStepsModule.decorators = [
{ type: NgModule, args: [{
imports: [
CommonModule,
MatIconModule,
MatRippleModule,
PortalModule,
ScrollDispatchModule,
CovalentCommonModule,
],
declarations: [
TD_STEPS,
],
exports: [
TD_STEPS,
],
},] }
];
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingReturn,uselessCode} checked by tsc
*/
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingReturn,uselessCode} checked by tsc
*/
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingReturn,uselessCode} checked by tsc
*/
export { CovalentStepsModule, StepState, TdStepLabelDirective, TdStepActionsDirective, TdStepSummaryDirective, TdStepBase, _TdStepMixinBase, TdStepComponent, StepMode, TdStepsComponent, TdStepBodyComponent, TdStepHeaderBase, _TdStepHeaderMixinBase, TdStepHeaderComponent, TdNavStepLinkComponent as ɵb, TdNavStepsHorizontalComponent as ɵa, TdNavStepsVerticalComponent as ɵc };
//# sourceMappingURL=covalent-core-steps.js.map