UNPKG

@angular/cdk

Version:

Angular Material Component Development Kit

32 lines 11.4 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/cdk/a11y"),require("@angular/cdk/bidi"),require("@angular/cdk/coercion"),require("@angular/cdk/keycodes"),require("@angular/common"),require("@angular/core"),require("rxjs"),require("rxjs/operators")):"function"==typeof define&&define.amd?define("@angular/cdk/stepper",["exports","@angular/cdk/a11y","@angular/cdk/bidi","@angular/cdk/coercion","@angular/cdk/keycodes","@angular/common","@angular/core","rxjs","rxjs/operators"],t):t(((e=e||self).ng=e.ng||{},e.ng.cdk=e.ng.cdk||{},e.ng.cdk.stepper={}),e.ng.cdk.a11y,e.ng.cdk.bidi,e.ng.cdk.coercion,e.ng.cdk.keycodes,e.ng.common,e.ng.core,e.rxjs,e.rxjs.operators)}(this,(function(e,t,r,n,o,i,s,p,c){"use strict"; /** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */var a,d=function(){function e(e){this._elementRef=e}return e.prototype.focus=function(){this._elementRef.nativeElement.focus()},e}();d.decorators=[{type:s.Directive,args:[{selector:"[cdkStepHeader]",host:{role:"tab"}}]}],d.ctorParameters=function(){return[{type:s.ElementRef}]},(a=function a(e){this.template=e}).decorators=[{type:s.Directive,args:[{selector:"[cdkStepLabel]"}]}],a.ctorParameters=function(){return[{type:s.TemplateRef}]}; /** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ var l=0,u=function u(){},h={NUMBER:"number",EDIT:"edit",DONE:"done",ERROR:"error"},y=new s.InjectionToken("STEPPER_GLOBAL_OPTIONS"),_=y,f=function(){function e(e,t){this._stepper=e,this.interacted=!1,this._editable=!0,this._optional=!1,this._completedOverride=null,this._customError=null,this._stepperOptions=t||{},this._displayDefaultIndicatorType=!1!==this._stepperOptions.displayDefaultIndicatorType,this._showError=!!this._stepperOptions.showError}return Object.defineProperty(e.prototype,"editable",{get:function(){return this._editable},set:function(e){this._editable=n.coerceBooleanProperty(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"optional",{get:function(){return this._optional},set:function(e){this._optional=n.coerceBooleanProperty(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"completed",{get:function(){return null==this._completedOverride?this._getDefaultCompleted():this._completedOverride},set:function(e){this._completedOverride=n.coerceBooleanProperty(e)},enumerable:!1,configurable:!0}),e.prototype._getDefaultCompleted=function(){return this.stepControl?this.stepControl.valid&&this.interacted:this.interacted},Object.defineProperty(e.prototype,"hasError",{get:function(){return null==this._customError?this._getDefaultError():this._customError},set:function(e){this._customError=n.coerceBooleanProperty(e)},enumerable:!1,configurable:!0}),e.prototype._getDefaultError=function(){return this.stepControl&&this.stepControl.invalid&&this.interacted},e.prototype.select=function(){this._stepper.selected=this},e.prototype.reset=function(){this.interacted=!1,null!=this._completedOverride&&(this._completedOverride=!1),null!=this._customError&&(this._customError=!1),this.stepControl&&this.stepControl.reset()},e.prototype.ngOnChanges=function(){this._stepper._stateChanged()},e}();f.decorators=[{type:s.Component,args:[{selector:"cdk-step",exportAs:"cdkStep",template:"<ng-template><ng-content></ng-content></ng-template>",encapsulation:s.ViewEncapsulation.None,changeDetection:s.ChangeDetectionStrategy.OnPush}]}],f.ctorParameters=function(){return[{type:g,decorators:[{type:s.Inject,args:[s.forwardRef((function(){return g}))]}]},{type:void 0,decorators:[{type:s.Optional},{type:s.Inject,args:[y]}]}]},f.propDecorators={stepLabel:[{type:s.ContentChild,args:[a]}],content:[{type:s.ViewChild,args:[s.TemplateRef,{static:!0}]}],stepControl:[{type:s.Input}],label:[{type:s.Input}],errorMessage:[{type:s.Input}],ariaLabel:[{type:s.Input,args:["aria-label"]}],ariaLabelledby:[{type:s.Input,args:["aria-labelledby"]}],state:[{type:s.Input}],editable:[{type:s.Input}],optional:[{type:s.Input}],completed:[{type:s.Input}],hasError:[{type:s.Input}]};var g=function(){function e(e,t,r,n){this._dir=e,this._changeDetectorRef=t,this._elementRef=r,this._destroyed=new p.Subject,this.steps=new s.QueryList,this._linear=!1,this._selectedIndex=0,this.selectionChange=new s.EventEmitter,this._orientation="horizontal",this._groupId=l++,this._document=n}return Object.defineProperty(e.prototype,"linear",{get:function(){return this._linear},set:function(e){this._linear=n.coerceBooleanProperty(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"selectedIndex",{get:function(){return this._selectedIndex},set:function(e){var t=n.coerceNumberProperty(e);this.steps&&this._steps?(this._isValidIndex(e),this._selectedIndex!==t&&!this._anyControlsInvalidOrPending(t)&&(t>=this._selectedIndex||this.steps.toArray()[t].editable)&&this._updateSelectedItemIndex(e)):this._selectedIndex=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"selected",{get:function(){return this.steps?this.steps.toArray()[this.selectedIndex]:void 0},set:function(e){this.selectedIndex=this.steps?this.steps.toArray().indexOf(e):-1},enumerable:!1,configurable:!0}),e.prototype.ngAfterContentInit=function(){var e=this;this._steps.changes.pipe(c.startWith(this._steps),c.takeUntil(this._destroyed)).subscribe((function(t){e.steps.reset(t.filter((function(t){return t._stepper===e}))),e.steps.notifyOnChanges()}))},e.prototype.ngAfterViewInit=function(){var e=this;this._keyManager=new t.FocusKeyManager(this._stepHeader).withWrap().withHomeAndEnd().withVerticalOrientation("vertical"===this._orientation),(this._dir?this._dir.change:p.of()).pipe(c.startWith(this._layoutDirection()),c.takeUntil(this._destroyed)).subscribe((function(t){return e._keyManager.withHorizontalOrientation(t)})),this._keyManager.updateActiveItem(this._selectedIndex),this.steps.changes.subscribe((function(){e.selected||(e._selectedIndex=Math.max(e._selectedIndex-1,0))})),this._isValidIndex(this._selectedIndex)||(this._selectedIndex=0)},e.prototype.ngOnDestroy=function(){this.steps.destroy(),this._destroyed.next(),this._destroyed.complete()},e.prototype.next=function(){this.selectedIndex=Math.min(this._selectedIndex+1,this.steps.length-1)},e.prototype.previous=function(){this.selectedIndex=Math.max(this._selectedIndex-1,0)},e.prototype.reset=function(){this._updateSelectedItemIndex(0),this.steps.forEach((function(e){return e.reset()})),this._stateChanged()},e.prototype._getStepLabelId=function(e){return"cdk-step-label-"+this._groupId+"-"+e},e.prototype._getStepContentId=function(e){return"cdk-step-content-"+this._groupId+"-"+e},e.prototype._stateChanged=function(){this._changeDetectorRef.markForCheck()},e.prototype._getAnimationDirection=function(e){var t=e-this._selectedIndex;return t<0?"rtl"===this._layoutDirection()?"next":"previous":t>0?"rtl"===this._layoutDirection()?"previous":"next":"current"},e.prototype._getIndicatorType=function(e,t){void 0===t&&(t=h.NUMBER);var r=this.steps.toArray()[e],n=this._isCurrentStep(e);return r._displayDefaultIndicatorType?this._getDefaultIndicatorLogic(r,n):this._getGuidelineLogic(r,n,t)},e.prototype._getDefaultIndicatorLogic=function(e,t){return e._showError&&e.hasError&&!t?h.ERROR:!e.completed||t?h.NUMBER:e.editable?h.EDIT:h.DONE},e.prototype._getGuidelineLogic=function(e,t,r){return void 0===r&&(r=h.NUMBER),e._showError&&e.hasError&&!t?h.ERROR:e.completed&&!t?h.DONE:e.completed&&t?r:e.editable&&t?h.EDIT:r},e.prototype._isCurrentStep=function(e){return this._selectedIndex===e},e.prototype._getFocusIndex=function(){return this._keyManager?this._keyManager.activeItemIndex:this._selectedIndex},e.prototype._updateSelectedItemIndex=function(e){var t=this.steps.toArray();this.selectionChange.emit({selectedIndex:e,previouslySelectedIndex:this._selectedIndex,selectedStep:t[e],previouslySelectedStep:t[this._selectedIndex]}),this._containsFocus()?this._keyManager.setActiveItem(e):this._keyManager.updateActiveItem(e),this._selectedIndex=e,this._stateChanged()},e.prototype._onKeydown=function(e){var t=o.hasModifierKey(e),r=e.keyCode,n=this._keyManager;null==n.activeItemIndex||t||r!==o.SPACE&&r!==o.ENTER?n.onKeydown(e):(this.selectedIndex=n.activeItemIndex,e.preventDefault())},e.prototype._anyControlsInvalidOrPending=function(e){var t=this.steps.toArray();return t[this._selectedIndex].interacted=!0,!!(this._linear&&e>=0)&&t.slice(0,e).some((function(e){var t=e.stepControl;return(t?t.invalid||t.pending||!e.interacted:!e.completed)&&!e.optional&&!e._completedOverride}))},e.prototype._layoutDirection=function(){return this._dir&&"rtl"===this._dir.value?"rtl":"ltr"},e.prototype._containsFocus=function(){if(!this._document||!this._elementRef)return!1;var e=this._elementRef.nativeElement,t=this._document.activeElement;return e===t||e.contains(t)},e.prototype._isValidIndex=function(e){return e>-1&&(!this.steps||e<this.steps.length)},e}();g.decorators=[{type:s.Directive,args:[{selector:"[cdkStepper]",exportAs:"cdkStepper"}]}],g.ctorParameters=function(){return[{type:r.Directionality,decorators:[{type:s.Optional}]},{type:s.ChangeDetectorRef},{type:s.ElementRef},{type:void 0,decorators:[{type:s.Inject,args:[i.DOCUMENT]}]}]},g.propDecorators={_steps:[{type:s.ContentChildren,args:[f,{descendants:!0}]}],_stepHeader:[{type:s.ContentChildren,args:[d,{descendants:!0}]}],linear:[{type:s.Input}],selectedIndex:[{type:s.Input}],selected:[{type:s.Input}],selectionChange:[{type:s.Output}]}; /** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ var I=function(){function e(e){this._stepper=e,this.type="submit"}return e.prototype._handleClick=function(){this._stepper.next()},e}();I.decorators=[{type:s.Directive,args:[{selector:"button[cdkStepperNext]",host:{"[type]":"type"}}]}],I.ctorParameters=function(){return[{type:g}]},I.propDecorators={type:[{type:s.Input}],_handleClick:[{type:s.HostListener,args:["click"]}]};var m,b=function(){function e(e){this._stepper=e,this.type="button"}return e.prototype._handleClick=function(){this._stepper.previous()},e}();b.decorators=[{type:s.Directive,args:[{selector:"button[cdkStepperPrevious]",host:{"[type]":"type"}}]}],b.ctorParameters=function(){return[{type:g}]},b.propDecorators={type:[{type:s.Input}],_handleClick:[{type:s.HostListener,args:["click"]}]},(m=function m(){}).decorators=[{type:s.NgModule,args:[{imports:[r.BidiModule],exports:[f,g,d,a,I,b],declarations:[f,g,d,a,I,b]}]}], /** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ e.CdkStep=f,e.CdkStepHeader=d,e.CdkStepLabel=a,e.CdkStepper=g,e.CdkStepperModule=m,e.CdkStepperNext=I,e.CdkStepperPrevious=b,e.MAT_STEPPER_GLOBAL_OPTIONS=_,e.STEPPER_GLOBAL_OPTIONS=y,e.STEP_STATE=h,e.StepperSelectionEvent=u,Object.defineProperty(e,"__esModule",{value:!0})}));