UNPKG

@angular/material

Version:
38 lines (36 loc) 19.4 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/cdk/a11y"),require("@angular/cdk/coercion"),require("@angular/core"),require("@angular/forms"),require("@angular/material/core"),require("@angular/platform-browser/animations"),require("@angular/cdk/observers")):"function"==typeof define&&define.amd?define("@angular/material/checkbox",["exports","@angular/cdk/a11y","@angular/cdk/coercion","@angular/core","@angular/forms","@angular/material/core","@angular/platform-browser/animations","@angular/cdk/observers"],t):t(((e=e||self).ng=e.ng||{},e.ng.material=e.ng.material||{},e.ng.material.checkbox={}),e.ng.cdk.a11y,e.ng.cdk.coercion,e.ng.core,e.ng.forms,e.ng.material.core,e.ng.platformBrowser.animations,e.ng.cdk.observers)}(this,(function(e,t,n,a,i,c,o,r){"use strict"; /*! ***************************************************************************** Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */var s=function(e,t){return(s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)};function m(e,t){function n(){this.constructor=e}s(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)} /** * @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 h=new a.InjectionToken("mat-checkbox-default-options",{providedIn:"root",factory:d});function d(){return{color:"accent",clickAction:"check-indeterminate"}}var k=new a.InjectionToken("mat-checkbox-click-action"),l=0,p={provide:i.NG_VALUE_ACCESSOR,useExisting:a.forwardRef((function(){return b})),multi:!0},u=function u(){},b=function(e){function i(t,n,i,c,o,r,s,m){var h=e.call(this,t)||this;return h._changeDetectorRef=n,h._focusMonitor=i,h._ngZone=c,h._clickAction=r,h._animationMode=s,h._options=m,h.ariaLabel="",h.ariaLabelledby=null,h._uniqueId="mat-checkbox-"+ ++l,h.id=h._uniqueId,h.labelPosition="after",h.name=null,h.change=new a.EventEmitter,h.indeterminateChange=new a.EventEmitter,h._onTouched=function(){},h._currentAnimationClass="",h._currentCheckState=0,h._controlValueAccessorChangeFn=function(){},h._checked=!1,h._disabled=!1,h._indeterminate=!1,h._options=h._options||{},h._options.color&&(h.color=h._options.color),h.tabIndex=parseInt(o)||0,h._focusMonitor.monitor(t,!0).subscribe((function(e){e||Promise.resolve().then((function(){h._onTouched(),n.markForCheck()}))})),h._clickAction=h._clickAction||h._options.clickAction,h}return m(i,e),Object.defineProperty(i.prototype,"inputId",{get:function(){return(this.id||this._uniqueId)+"-input"},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"required",{get:function(){return this._required},set:function(e){this._required=n.coerceBooleanProperty(e)},enumerable:!0,configurable:!0}),i.prototype.ngAfterViewInit=function(){this._syncIndeterminate(this._indeterminate)},i.prototype.ngAfterViewChecked=function(){},i.prototype.ngOnDestroy=function(){this._focusMonitor.stopMonitoring(this._elementRef)},Object.defineProperty(i.prototype,"checked",{get:function(){return this._checked},set:function(e){e!=this.checked&&(this._checked=e,this._changeDetectorRef.markForCheck())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"disabled",{get:function(){return this._disabled},set:function(e){var t=n.coerceBooleanProperty(e);t!==this.disabled&&(this._disabled=t,this._changeDetectorRef.markForCheck())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"indeterminate",{get:function(){return this._indeterminate},set:function(e){var t=e!=this._indeterminate;this._indeterminate=n.coerceBooleanProperty(e),t&&(this._transitionCheckState(this._indeterminate?3:this.checked?1:2),this.indeterminateChange.emit(this._indeterminate)),this._syncIndeterminate(this._indeterminate)},enumerable:!0,configurable:!0}),i.prototype._isRippleDisabled=function(){return this.disableRipple||this.disabled},i.prototype._onLabelTextChange=function(){this._changeDetectorRef.detectChanges()},i.prototype.writeValue=function(e){this.checked=!!e},i.prototype.registerOnChange=function(e){this._controlValueAccessorChangeFn=e},i.prototype.registerOnTouched=function(e){this._onTouched=e},i.prototype.setDisabledState=function(e){this.disabled=e},i.prototype._getAriaChecked=function(){return this.checked?"true":this.indeterminate?"mixed":"false"},i.prototype._transitionCheckState=function(e){var t=this._currentCheckState,n=this._elementRef.nativeElement;if(t!==e&&(this._currentAnimationClass.length>0&&n.classList.remove(this._currentAnimationClass),this._currentAnimationClass=this._getAnimationClassForCheckStateTransition(t,e),this._currentCheckState=e,this._currentAnimationClass.length>0)){n.classList.add(this._currentAnimationClass);var a=this._currentAnimationClass;this._ngZone.runOutsideAngular((function(){setTimeout((function(){n.classList.remove(a)}),1e3)}))}},i.prototype._emitChangeEvent=function(){var e=new u;e.source=this,e.checked=this.checked,this._controlValueAccessorChangeFn(this.checked),this.change.emit(e)},i.prototype.toggle=function(){this.checked=!this.checked},i.prototype._onInputClick=function(e){var t=this;e.stopPropagation(),this.disabled||"noop"===this._clickAction?this.disabled||"noop"!==this._clickAction||(this._inputElement.nativeElement.checked=this.checked,this._inputElement.nativeElement.indeterminate=this.indeterminate):(this.indeterminate&&"check"!==this._clickAction&&Promise.resolve().then((function(){t._indeterminate=!1,t.indeterminateChange.emit(t._indeterminate)})),this.toggle(),this._transitionCheckState(this._checked?1:2),this._emitChangeEvent())},i.prototype.focus=function(e,t){void 0===e&&(e="keyboard"),this._focusMonitor.focusVia(this._inputElement,e,t)},i.prototype._onInteractionEvent=function(e){e.stopPropagation()},i.prototype._getAnimationClassForCheckStateTransition=function(e,t){if("NoopAnimations"===this._animationMode)return"";var n="";switch(e){case 0:if(1===t)n="unchecked-checked";else{if(3!=t)return"";n="unchecked-indeterminate"}break;case 2:n=1===t?"unchecked-checked":"unchecked-indeterminate";break;case 1:n=2===t?"checked-unchecked":"checked-indeterminate";break;case 3:n=1===t?"indeterminate-checked":"indeterminate-unchecked"}return"mat-checkbox-anim-"+n},i.prototype._syncIndeterminate=function(e){var t=this._inputElement;t&&(t.nativeElement.indeterminate=e)},i.decorators=[{type:a.Component,args:[{selector:"mat-checkbox",template:'<label [attr.for]="inputId" class="mat-checkbox-layout" #label>\n <div class="mat-checkbox-inner-container"\n [class.mat-checkbox-inner-container-no-side-margin]="!checkboxLabel.textContent || !checkboxLabel.textContent.trim()">\n <input #input\n class="mat-checkbox-input cdk-visually-hidden" type="checkbox"\n [id]="inputId"\n [required]="required"\n [checked]="checked"\n [attr.value]="value"\n [disabled]="disabled"\n [attr.name]="name"\n [tabIndex]="tabIndex"\n [attr.aria-label]="ariaLabel || null"\n [attr.aria-labelledby]="ariaLabelledby"\n [attr.aria-checked]="_getAriaChecked()"\n (change)="_onInteractionEvent($event)"\n (click)="_onInputClick($event)">\n <div matRipple class="mat-checkbox-ripple mat-focus-indicator"\n [matRippleTrigger]="label"\n [matRippleDisabled]="_isRippleDisabled()"\n [matRippleRadius]="20"\n [matRippleCentered]="true"\n [matRippleAnimation]="{enterDuration: 150}">\n <div class="mat-ripple-element mat-checkbox-persistent-ripple"></div>\n </div>\n <div class="mat-checkbox-frame"></div>\n <div class="mat-checkbox-background">\n <svg version="1.1"\n focusable="false"\n class="mat-checkbox-checkmark"\n viewBox="0 0 24 24"\n xml:space="preserve">\n <path class="mat-checkbox-checkmark-path"\n fill="none"\n stroke="white"\n d="M4.1,12.7 9,17.6 20.3,6.3"/>\n </svg>\n \x3c!-- Element for rendering the indeterminate state checkbox. --\x3e\n <div class="mat-checkbox-mixedmark"></div>\n </div>\n </div>\n <span class="mat-checkbox-label" #checkboxLabel (cdkObserveContent)="_onLabelTextChange()">\n \x3c!-- Add an invisible span so JAWS can read the label --\x3e\n <span style="display:none">&nbsp;</span>\n <ng-content></ng-content>\n </span>\n</label>\n',exportAs:"matCheckbox",host:{class:"mat-checkbox","[id]":"id","[attr.tabindex]":"null","[class.mat-checkbox-indeterminate]":"indeterminate","[class.mat-checkbox-checked]":"checked","[class.mat-checkbox-disabled]":"disabled","[class.mat-checkbox-label-before]":'labelPosition == "before"',"[class._mat-animation-noopable]":"_animationMode === 'NoopAnimations'"},providers:[p],inputs:["disableRipple","color","tabIndex"],encapsulation:a.ViewEncapsulation.None,changeDetection:a.ChangeDetectionStrategy.OnPush,styles:["@keyframes mat-checkbox-fade-in-background{0%{opacity:0}50%{opacity:1}}@keyframes mat-checkbox-fade-out-background{0%,50%{opacity:1}100%{opacity:0}}@keyframes mat-checkbox-unchecked-checked-checkmark-path{0%,50%{stroke-dashoffset:22.910259}50%{animation-timing-function:cubic-bezier(0, 0, 0.2, 0.1)}100%{stroke-dashoffset:0}}@keyframes mat-checkbox-unchecked-indeterminate-mixedmark{0%,68.2%{transform:scaleX(0)}68.2%{animation-timing-function:cubic-bezier(0, 0, 0, 1)}100%{transform:scaleX(1)}}@keyframes mat-checkbox-checked-unchecked-checkmark-path{from{animation-timing-function:cubic-bezier(0.4, 0, 1, 1);stroke-dashoffset:0}to{stroke-dashoffset:-22.910259}}@keyframes mat-checkbox-checked-indeterminate-checkmark{from{animation-timing-function:cubic-bezier(0, 0, 0.2, 0.1);opacity:1;transform:rotate(0deg)}to{opacity:0;transform:rotate(45deg)}}@keyframes mat-checkbox-indeterminate-checked-checkmark{from{animation-timing-function:cubic-bezier(0.14, 0, 0, 1);opacity:0;transform:rotate(45deg)}to{opacity:1;transform:rotate(360deg)}}@keyframes mat-checkbox-checked-indeterminate-mixedmark{from{animation-timing-function:cubic-bezier(0, 0, 0.2, 0.1);opacity:0;transform:rotate(-45deg)}to{opacity:1;transform:rotate(0deg)}}@keyframes mat-checkbox-indeterminate-checked-mixedmark{from{animation-timing-function:cubic-bezier(0.14, 0, 0, 1);opacity:1;transform:rotate(0deg)}to{opacity:0;transform:rotate(315deg)}}@keyframes mat-checkbox-indeterminate-unchecked-mixedmark{0%{animation-timing-function:linear;opacity:1;transform:scaleX(1)}32.8%,100%{opacity:0;transform:scaleX(0)}}.mat-checkbox-background,.mat-checkbox-frame{top:0;left:0;right:0;bottom:0;position:absolute;border-radius:2px;box-sizing:border-box;pointer-events:none}.mat-checkbox{transition:background 400ms cubic-bezier(0.25, 0.8, 0.25, 1),box-shadow 280ms cubic-bezier(0.4, 0, 0.2, 1);cursor:pointer;-webkit-tap-highlight-color:transparent}._mat-animation-noopable.mat-checkbox{transition:none;animation:none}.mat-checkbox .mat-ripple-element:not(.mat-checkbox-persistent-ripple){opacity:.16}.mat-checkbox-layout{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;cursor:inherit;align-items:baseline;vertical-align:middle;display:inline-flex;white-space:nowrap}.mat-checkbox-label{-webkit-user-select:auto;-moz-user-select:auto;-ms-user-select:auto;user-select:auto}.mat-checkbox-inner-container{display:inline-block;height:16px;line-height:0;margin:auto;margin-right:8px;order:0;position:relative;vertical-align:middle;white-space:nowrap;width:16px;flex-shrink:0}[dir=rtl] .mat-checkbox-inner-container{margin-left:8px;margin-right:auto}.mat-checkbox-inner-container-no-side-margin{margin-left:0;margin-right:0}.mat-checkbox-frame{background-color:transparent;transition:border-color 90ms cubic-bezier(0, 0, 0.2, 0.1);border-width:2px;border-style:solid}._mat-animation-noopable .mat-checkbox-frame{transition:none}.mat-checkbox.cdk-keyboard-focused .cdk-high-contrast-active .mat-checkbox-frame{border-style:dotted}.mat-checkbox-background{align-items:center;display:inline-flex;justify-content:center;transition:background-color 90ms cubic-bezier(0, 0, 0.2, 0.1),opacity 90ms cubic-bezier(0, 0, 0.2, 0.1)}._mat-animation-noopable .mat-checkbox-background{transition:none}.cdk-high-contrast-active .mat-checkbox .mat-checkbox-background{background:none}.mat-checkbox-persistent-ripple{width:100%;height:100%;transform:none}.mat-checkbox-inner-container:hover .mat-checkbox-persistent-ripple{opacity:.04}.mat-checkbox.cdk-keyboard-focused .mat-checkbox-persistent-ripple{opacity:.12}.mat-checkbox-persistent-ripple,.mat-checkbox.mat-checkbox-disabled .mat-checkbox-inner-container:hover .mat-checkbox-persistent-ripple{opacity:0}@media(hover: none){.mat-checkbox-inner-container:hover .mat-checkbox-persistent-ripple{display:none}}.mat-checkbox-checkmark{top:0;left:0;right:0;bottom:0;position:absolute;width:100%}.mat-checkbox-checkmark-path{stroke-dashoffset:22.910259;stroke-dasharray:22.910259;stroke-width:2.1333333333px}.cdk-high-contrast-black-on-white .mat-checkbox-checkmark-path{stroke:#000 !important}.mat-checkbox-mixedmark{width:calc(100% - 6px);height:2px;opacity:0;transform:scaleX(0) rotate(0deg);border-radius:2px}.cdk-high-contrast-active .mat-checkbox-mixedmark{height:0;border-top:solid 2px;margin-top:2px}.mat-checkbox-label-before .mat-checkbox-inner-container{order:1;margin-left:8px;margin-right:auto}[dir=rtl] .mat-checkbox-label-before .mat-checkbox-inner-container{margin-left:auto;margin-right:8px}.mat-checkbox-checked .mat-checkbox-checkmark{opacity:1}.mat-checkbox-checked .mat-checkbox-checkmark-path{stroke-dashoffset:0}.mat-checkbox-checked .mat-checkbox-mixedmark{transform:scaleX(1) rotate(-45deg)}.mat-checkbox-indeterminate .mat-checkbox-checkmark{opacity:0;transform:rotate(45deg)}.mat-checkbox-indeterminate .mat-checkbox-checkmark-path{stroke-dashoffset:0}.mat-checkbox-indeterminate .mat-checkbox-mixedmark{opacity:1;transform:scaleX(1) rotate(0deg)}.mat-checkbox-unchecked .mat-checkbox-background{background-color:transparent}.mat-checkbox-disabled{cursor:default}.cdk-high-contrast-active .mat-checkbox-disabled{opacity:.5}.mat-checkbox-anim-unchecked-checked .mat-checkbox-background{animation:180ms linear 0ms mat-checkbox-fade-in-background}.mat-checkbox-anim-unchecked-checked .mat-checkbox-checkmark-path{animation:180ms linear 0ms mat-checkbox-unchecked-checked-checkmark-path}.mat-checkbox-anim-unchecked-indeterminate .mat-checkbox-background{animation:180ms linear 0ms mat-checkbox-fade-in-background}.mat-checkbox-anim-unchecked-indeterminate .mat-checkbox-mixedmark{animation:90ms linear 0ms mat-checkbox-unchecked-indeterminate-mixedmark}.mat-checkbox-anim-checked-unchecked .mat-checkbox-background{animation:180ms linear 0ms mat-checkbox-fade-out-background}.mat-checkbox-anim-checked-unchecked .mat-checkbox-checkmark-path{animation:90ms linear 0ms mat-checkbox-checked-unchecked-checkmark-path}.mat-checkbox-anim-checked-indeterminate .mat-checkbox-checkmark{animation:90ms linear 0ms mat-checkbox-checked-indeterminate-checkmark}.mat-checkbox-anim-checked-indeterminate .mat-checkbox-mixedmark{animation:90ms linear 0ms mat-checkbox-checked-indeterminate-mixedmark}.mat-checkbox-anim-indeterminate-checked .mat-checkbox-checkmark{animation:500ms linear 0ms mat-checkbox-indeterminate-checked-checkmark}.mat-checkbox-anim-indeterminate-checked .mat-checkbox-mixedmark{animation:500ms linear 0ms mat-checkbox-indeterminate-checked-mixedmark}.mat-checkbox-anim-indeterminate-unchecked .mat-checkbox-background{animation:180ms linear 0ms mat-checkbox-fade-out-background}.mat-checkbox-anim-indeterminate-unchecked .mat-checkbox-mixedmark{animation:300ms linear 0ms mat-checkbox-indeterminate-unchecked-mixedmark}.mat-checkbox-input{bottom:0;left:50%}.mat-checkbox .mat-checkbox-ripple{position:absolute;left:calc(50% - 20px);top:calc(50% - 20px);height:40px;width:40px;z-index:1;pointer-events:none}\n"]}]}],i.ctorParameters=function(){return[{type:a.ElementRef},{type:a.ChangeDetectorRef},{type:t.FocusMonitor},{type:a.NgZone},{type:String,decorators:[{type:a.Attribute,args:["tabindex"]}]},{type:void 0,decorators:[{type:a.Optional},{type:a.Inject,args:[k]}]},{type:String,decorators:[{type:a.Optional},{type:a.Inject,args:[o.ANIMATION_MODULE_TYPE]}]},{type:void 0,decorators:[{type:a.Optional},{type:a.Inject,args:[h]}]}]},i.propDecorators={ariaLabel:[{type:a.Input,args:["aria-label"]}],ariaLabelledby:[{type:a.Input,args:["aria-labelledby"]}],id:[{type:a.Input}],required:[{type:a.Input}],labelPosition:[{type:a.Input}],name:[{type:a.Input}],change:[{type:a.Output}],indeterminateChange:[{type:a.Output}],value:[{type:a.Input}],_inputElement:[{type:a.ViewChild,args:["input"]}],ripple:[{type:a.ViewChild,args:[c.MatRipple]}],checked:[{type:a.Input}],disabled:[{type:a.Input}],indeterminate:[{type:a.Input}]},i}(c.mixinTabIndex(c.mixinColor(c.mixinDisableRipple(c.mixinDisabled((function x(e){this._elementRef=e})))))),f={provide:i.NG_VALIDATORS,useExisting:a.forwardRef((function(){return g})),multi:!0},g=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return m(t,e),t.decorators=[{type:a.Directive,args:[{selector:"mat-checkbox[required][formControlName],\n mat-checkbox[required][formControl], mat-checkbox[required][ngModel]",providers:[f]}]}],t}(i.CheckboxRequiredValidator),y=function(){function e(){}return e.decorators=[{type:a.NgModule,args:[{exports:[g],declarations:[g]}]}],e}(),_=function(){function e(){}return e.decorators=[{type:a.NgModule,args:[{imports:[c.MatRippleModule,c.MatCommonModule,r.ObserversModule,y],exports:[b,c.MatCommonModule,y],declarations:[b]}]}],e}(); /** * @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 */ /** * @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.MAT_CHECKBOX_CLICK_ACTION=k,e.MAT_CHECKBOX_CONTROL_VALUE_ACCESSOR=p,e.MAT_CHECKBOX_DEFAULT_OPTIONS=h,e.MAT_CHECKBOX_DEFAULT_OPTIONS_FACTORY=d,e.MAT_CHECKBOX_REQUIRED_VALIDATOR=f,e.MatCheckbox=b,e.MatCheckboxChange=u,e.MatCheckboxModule=_,e.MatCheckboxRequiredValidator=g,e._MatCheckboxRequiredValidatorModule=y,Object.defineProperty(e,"__esModule",{value:!0})}));