blob: acba2eb75640171bf27a97ea3ce6eb8d3447d627 [file] [log] [blame]
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/cdk/a11y"),require("@angular/cdk/coercion"),require("@angular/cdk/collections"),require("@angular/core"),require("@angular/forms"),require("@angular/material/core")):"function"==typeof define&&define.amd?define("@angular/material/button-toggle",["exports","@angular/cdk/a11y","@angular/cdk/coercion","@angular/cdk/collections","@angular/core","@angular/forms","@angular/material/core"],e):e(((t=t||self).ng=t.ng||{},t.ng.material=t.ng.material||{},t.ng.material.buttonToggle={}),t.ng.cdk.a11y,t.ng.cdk.coercion,t.ng.cdk.collections,t.ng.core,t.ng.forms,t.ng.material.core)}(this,(function(t,e,o,n,a,r,i){"use strict";
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */var l=function(t,e){return(l=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])})(t,e)};function c(t,e){var o="function"==typeof Symbol&&t[Symbol.iterator];if(!o)return t;var n,a,r=o.call(t),i=[];try{for(;(void 0===e||e-- >0)&&!(n=r.next()).done;)i.push(n.value)}catch(t){a={error:t}}finally{try{n&&!n.done&&(o=r.return)&&o.call(r)}finally{if(a)throw a.error}}return i}var u=new a.InjectionToken("MAT_BUTTON_TOGGLE_DEFAULT_OPTIONS"),s=new a.InjectionToken("MatButtonToggleGroup"),g={provide:r.NG_VALUE_ACCESSOR,useExisting:a.forwardRef((function(){return h})),multi:!0},p=0,d=function d(t,e){this.source=t,this.value=e},h=function(){function t(t,e){this._changeDetector=t,this._vertical=!1,this._multiple=!1,this._disabled=!1,this._controlValueAccessorChangeFn=function(){},this._onTouched=function(){},this._name="mat-button-toggle-group-"+p++,this.valueChange=new a.EventEmitter,this.change=new a.EventEmitter,this.appearance=e&&e.appearance?e.appearance:"standard"}return Object.defineProperty(t.prototype,"name",{get:function(){return this._name},set:function(t){var e=this;this._name=t,this._buttonToggles&&this._buttonToggles.forEach((function(t){t.name=e._name,t._markForCheck()}))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"vertical",{get:function(){return this._vertical},set:function(t){this._vertical=o.coerceBooleanProperty(t)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"value",{get:function(){var t=this._selectionModel?this._selectionModel.selected:[];return this.multiple?t.map((function(t){return t.value})):t[0]?t[0].value:void 0},set:function(t){this._setSelectionByValue(t),this.valueChange.emit(this.value)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"selected",{get:function(){var t=this._selectionModel?this._selectionModel.selected:[];return this.multiple?t:t[0]||null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"multiple",{get:function(){return this._multiple},set:function(t){this._multiple=o.coerceBooleanProperty(t)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"disabled",{get:function(){return this._disabled},set:function(t){this._disabled=o.coerceBooleanProperty(t),this._buttonToggles&&this._buttonToggles.forEach((function(t){return t._markForCheck()}))},enumerable:!1,configurable:!0}),t.prototype.ngOnInit=function(){this._selectionModel=new n.SelectionModel(this.multiple,void 0,!1)},t.prototype.ngAfterContentInit=function(){var t;(t=this._selectionModel).select.apply(t,function e(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(c(arguments[e]));return t}(this._buttonToggles.filter((function(t){return t.checked}))))},t.prototype.writeValue=function(t){this.value=t,this._changeDetector.markForCheck()},t.prototype.registerOnChange=function(t){this._controlValueAccessorChangeFn=t},t.prototype.registerOnTouched=function(t){this._onTouched=t},t.prototype.setDisabledState=function(t){this.disabled=t},t.prototype._emitChangeEvent=function(){var t=this.selected,e=Array.isArray(t)?t[t.length-1]:t,o=new d(e,this.value);this._controlValueAccessorChangeFn(o.value),this.change.emit(o)},t.prototype._syncButtonToggle=function(t,e,o,n){var a=this;void 0===o&&(o=!1),void 0===n&&(n=!1),this.multiple||!this.selected||t.checked||(this.selected.checked=!1),this._selectionModel?e?this._selectionModel.select(t):this._selectionModel.deselect(t):n=!0,n?Promise.resolve().then((function(){return a._updateModelValue(o)})):this._updateModelValue(o)},t.prototype._isSelected=function(t){return this._selectionModel&&this._selectionModel.isSelected(t)},t.prototype._isPrechecked=function(t){return void 0!==this._rawValue&&(this.multiple&&Array.isArray(this._rawValue)?this._rawValue.some((function(e){return null!=t.value&&e===t.value})):t.value===this._rawValue)},t.prototype._setSelectionByValue=function(t){var e=this;this._rawValue=t,this._buttonToggles&&(this.multiple&&t?(Array.isArray(t),this._clearSelection(),t.forEach((function(t){return e._selectValue(t)}))):(this._clearSelection(),this._selectValue(t)))},t.prototype._clearSelection=function(){this._selectionModel.clear(),this._buttonToggles.forEach((function(t){return t.checked=!1}))},t.prototype._selectValue=function(t){var e=this._buttonToggles.find((function(e){return null!=e.value&&e.value===t}));e&&(e.checked=!0,this._selectionModel.select(e))},t.prototype._updateModelValue=function(t){t&&this._emitChangeEvent(),this.valueChange.emit(this.value)},t}();h.decorators=[{type:a.Directive,args:[{selector:"mat-button-toggle-group",providers:[g,{provide:s,useExisting:h}],host:{role:"group",class:"mat-button-toggle-group","[attr.aria-disabled]":"disabled","[class.mat-button-toggle-vertical]":"vertical","[class.mat-button-toggle-group-appearance-standard]":'appearance === "standard"'},exportAs:"matButtonToggleGroup"}]}],h.ctorParameters=function(){return[{type:a.ChangeDetectorRef},{type:void 0,decorators:[{type:a.Optional},{type:a.Inject,args:[u]}]}]},h.propDecorators={_buttonToggles:[{type:a.ContentChildren,args:[a.forwardRef((function(){return m})),{descendants:!0}]}],appearance:[{type:a.Input}],name:[{type:a.Input}],vertical:[{type:a.Input}],value:[{type:a.Input}],valueChange:[{type:a.Output}],multiple:[{type:a.Input}],disabled:[{type:a.Input}],change:[{type:a.Output}]};var b,m=function(t){function e(e,o,n,r,i,l){var c=t.call(this)||this;c._changeDetectorRef=o,c._elementRef=n,c._focusMonitor=r,c._isSingleSelector=!1,c._checked=!1,c.ariaLabelledby=null,c._disabled=!1,c.change=new a.EventEmitter;var u=Number(i);return c.tabIndex=u||0===u?u:null,c.buttonToggleGroup=e,c.appearance=l&&l.appearance?l.appearance:"standard",c}return function n(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function o(){this.constructor=t}l(t,e),t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)}(e,t),Object.defineProperty(e.prototype,"buttonId",{get:function(){return this.id+"-button"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"appearance",{get:function(){return this.buttonToggleGroup?this.buttonToggleGroup.appearance:this._appearance},set:function(t){this._appearance=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"checked",{get:function(){return this.buttonToggleGroup?this.buttonToggleGroup._isSelected(this):this._checked},set:function(t){var e=o.coerceBooleanProperty(t);e!==this._checked&&(this._checked=e,this.buttonToggleGroup&&this.buttonToggleGroup._syncButtonToggle(this,this._checked),this._changeDetectorRef.markForCheck())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"disabled",{get:function(){return this._disabled||this.buttonToggleGroup&&this.buttonToggleGroup.disabled},set:function(t){this._disabled=o.coerceBooleanProperty(t)},enumerable:!1,configurable:!0}),e.prototype.ngOnInit=function(){var t=this.buttonToggleGroup;this._isSingleSelector=t&&!t.multiple,this.id=this.id||"mat-button-toggle-"+p++,this._isSingleSelector&&(this.name=t.name),t&&(t._isPrechecked(this)?this.checked=!0:t._isSelected(this)!==this._checked&&t._syncButtonToggle(this,this._checked))},e.prototype.ngAfterViewInit=function(){this._focusMonitor.monitor(this._elementRef,!0)},e.prototype.ngOnDestroy=function(){var t=this.buttonToggleGroup;this._focusMonitor.stopMonitoring(this._elementRef),t&&t._isSelected(this)&&t._syncButtonToggle(this,!1,!1,!0)},e.prototype.focus=function(t){this._buttonElement.nativeElement.focus(t)},e.prototype._onButtonClick=function(){var t=!!this._isSingleSelector||!this._checked;t!==this._checked&&(this._checked=t,this.buttonToggleGroup&&(this.buttonToggleGroup._syncButtonToggle(this,this._checked,!0),this.buttonToggleGroup._onTouched())),this.change.emit(new d(this,this.value))},e.prototype._markForCheck=function(){this._changeDetectorRef.markForCheck()},e}(i.mixinDisableRipple((function f(){})));m.decorators=[{type:a.Component,args:[{selector:"mat-button-toggle",template:'<button #button class="mat-button-toggle-button mat-focus-indicator"\n type="button"\n [id]="buttonId"\n [attr.tabindex]="disabled ? -1 : tabIndex"\n [attr.aria-pressed]="checked"\n [disabled]="disabled || null"\n [attr.name]="name || null"\n [attr.aria-label]="ariaLabel"\n [attr.aria-labelledby]="ariaLabelledby"\n (click)="_onButtonClick()">\n <span class="mat-button-toggle-label-content">\n <ng-content></ng-content>\n </span>\n</button>\n\n<span class="mat-button-toggle-focus-overlay"></span>\n<span class="mat-button-toggle-ripple" matRipple\n [matRippleTrigger]="button"\n [matRippleDisabled]="this.disableRipple || this.disabled">\n</span>\n',encapsulation:a.ViewEncapsulation.None,exportAs:"matButtonToggle",changeDetection:a.ChangeDetectionStrategy.OnPush,inputs:["disableRipple"],host:{"[class.mat-button-toggle-standalone]":"!buttonToggleGroup","[class.mat-button-toggle-checked]":"checked","[class.mat-button-toggle-disabled]":"disabled","[class.mat-button-toggle-appearance-standard]":'appearance === "standard"',class:"mat-button-toggle","[attr.aria-label]":"null","[attr.aria-labelledby]":"null","[attr.id]":"id","[attr.name]":"null","(focus)":"focus()",role:"presentation"},styles:[".mat-button-toggle-standalone,.mat-button-toggle-group{position:relative;display:inline-flex;flex-direction:row;white-space:nowrap;overflow:hidden;border-radius:2px;-webkit-tap-highlight-color:transparent}.cdk-high-contrast-active .mat-button-toggle-standalone,.cdk-high-contrast-active .mat-button-toggle-group{outline:solid 1px}.mat-button-toggle-standalone.mat-button-toggle-appearance-standard,.mat-button-toggle-group-appearance-standard{border-radius:4px}.cdk-high-contrast-active .mat-button-toggle-standalone.mat-button-toggle-appearance-standard,.cdk-high-contrast-active .mat-button-toggle-group-appearance-standard{outline:0}.mat-button-toggle-vertical{flex-direction:column}.mat-button-toggle-vertical .mat-button-toggle-label-content{display:block}.mat-button-toggle{white-space:nowrap;position:relative}.mat-button-toggle .mat-icon svg{vertical-align:top}.mat-button-toggle.cdk-keyboard-focused .mat-button-toggle-focus-overlay{opacity:1}.cdk-high-contrast-active .mat-button-toggle.cdk-keyboard-focused .mat-button-toggle-focus-overlay{opacity:.5}.mat-button-toggle-appearance-standard:not(.mat-button-toggle-disabled):hover .mat-button-toggle-focus-overlay{opacity:.04}.mat-button-toggle-appearance-standard.cdk-keyboard-focused:not(.mat-button-toggle-disabled) .mat-button-toggle-focus-overlay{opacity:.12}.cdk-high-contrast-active .mat-button-toggle-appearance-standard.cdk-keyboard-focused:not(.mat-button-toggle-disabled) .mat-button-toggle-focus-overlay{opacity:.5}@media(hover: none){.mat-button-toggle-appearance-standard:not(.mat-button-toggle-disabled):hover .mat-button-toggle-focus-overlay{display:none}}.mat-button-toggle-label-content{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;display:inline-block;line-height:36px;padding:0 16px;position:relative}.mat-button-toggle-appearance-standard .mat-button-toggle-label-content{padding:0 12px}.mat-button-toggle-label-content>*{vertical-align:middle}.mat-button-toggle-focus-overlay{border-radius:inherit;pointer-events:none;opacity:0;top:0;left:0;right:0;bottom:0;position:absolute}.mat-button-toggle-checked .mat-button-toggle-focus-overlay{border-bottom:solid 36px}.cdk-high-contrast-active .mat-button-toggle-checked .mat-button-toggle-focus-overlay{opacity:.5;height:0}.cdk-high-contrast-active .mat-button-toggle-checked.mat-button-toggle-appearance-standard .mat-button-toggle-focus-overlay{border-bottom:solid 500px}.mat-button-toggle .mat-button-toggle-ripple{top:0;left:0;right:0;bottom:0;position:absolute;pointer-events:none}.mat-button-toggle-button{border:0;background:none;color:inherit;padding:0;margin:0;font:inherit;outline:none;width:100%;cursor:pointer}.mat-button-toggle-disabled .mat-button-toggle-button{cursor:default}.mat-button-toggle-button::-moz-focus-inner{border:0}\n"]}]}],m.ctorParameters=function(){return[{type:h,decorators:[{type:a.Optional},{type:a.Inject,args:[s]}]},{type:a.ChangeDetectorRef},{type:a.ElementRef},{type:e.FocusMonitor},{type:String,decorators:[{type:a.Attribute,args:["tabindex"]}]},{type:void 0,decorators:[{type:a.Optional},{type:a.Inject,args:[u]}]}]},m.propDecorators={ariaLabel:[{type:a.Input,args:["aria-label"]}],ariaLabelledby:[{type:a.Input,args:["aria-labelledby"]}],_buttonElement:[{type:a.ViewChild,args:["button"]}],id:[{type:a.Input}],name:[{type:a.Input}],value:[{type:a.Input}],tabIndex:[{type:a.Input}],appearance:[{type:a.Input}],checked:[{type:a.Input}],disabled:[{type:a.Input}],change:[{type:a.Output}]},(b=function b(){}).decorators=[{type:a.NgModule,args:[{imports:[i.MatCommonModule,i.MatRippleModule],exports:[i.MatCommonModule,h,m],declarations:[h,m]}]}],
/**
* @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
*/
t.MAT_BUTTON_TOGGLE_DEFAULT_OPTIONS=u,t.MAT_BUTTON_TOGGLE_GROUP=s,t.MAT_BUTTON_TOGGLE_GROUP_VALUE_ACCESSOR=g,t.MatButtonToggle=m,t.MatButtonToggleChange=d,t.MatButtonToggleGroup=h,t.MatButtonToggleModule=b,Object.defineProperty(t,"__esModule",{value:!0})}));