blob: 9db03cfb41d661097754773fc55693787d82ee26 [file] [log] [blame]
/**
* @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
*/
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("rxjs"),require("@angular/core")):"function"==typeof define&&define.amd?define("@angular/cdk/collections",["exports","rxjs","@angular/core"],e):e((t.ng=t.ng||{},t.ng.cdk=t.ng.cdk||{},t.ng.cdk.collections={}),t.rxjs,t.ng.core)}(this,function(t,e,n){"use strict";function i(t,e){function n(){this.constructor=t}s(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}function o(t){return t&&"function"==typeof t.connect}function r(){return Error("Cannot pass multiple values into SelectionModel with single-value mode.")}var s=function(t,e){return(s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},c=function(){function t(){}return t}(),l=function(t){function n(e){var n=t.call(this)||this;return n._data=e,n}return i(n,t),n.prototype.connect=function(){return this._data instanceof e.Observable?this._data:e.of(this._data)},n.prototype.disconnect=function(){},n}(c),u=function(){function t(t,n,i){var o=this;void 0===t&&(t=!1),void 0===i&&(i=!0),this._multiple=t,this._emitChanges=i,this._selection=new Set,this._deselectedToEmit=[],this._selectedToEmit=[],this.changed=new e.Subject,this.onChange=this.changed,n&&n.length&&(t?n.forEach(function(t){return o._markSelected(t)}):this._markSelected(n[0]),this._selectedToEmit.length=0)}return Object.defineProperty(t.prototype,"selected",{get:function(){return this._selected||(this._selected=Array.from(this._selection.values())),this._selected},enumerable:!0,configurable:!0}),t.prototype.select=function(){for(var t=this,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];this._verifyValueAssignment(e),e.forEach(function(e){return t._markSelected(e)}),this._emitChangeEvent()},t.prototype.deselect=function(){for(var t=this,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];this._verifyValueAssignment(e),e.forEach(function(e){return t._unmarkSelected(e)}),this._emitChangeEvent()},t.prototype.toggle=function(t){this.isSelected(t)?this.deselect(t):this.select(t)},t.prototype.clear=function(){this._unmarkAll(),this._emitChangeEvent()},t.prototype.isSelected=function(t){return this._selection.has(t)},t.prototype.isEmpty=function(){return 0===this._selection.size},t.prototype.hasValue=function(){return!this.isEmpty()},t.prototype.sort=function(t){this._multiple&&this.selected&&this._selected.sort(t)},t.prototype.isMultipleSelection=function(){return this._multiple},t.prototype._emitChangeEvent=function(){this._selected=null,(this._selectedToEmit.length||this._deselectedToEmit.length)&&(this.changed.next({source:this,added:this._selectedToEmit,removed:this._deselectedToEmit}),this._deselectedToEmit=[],this._selectedToEmit=[])},t.prototype._markSelected=function(t){this.isSelected(t)||(this._multiple||this._unmarkAll(),this._selection.add(t),this._emitChanges&&this._selectedToEmit.push(t))},t.prototype._unmarkSelected=function(t){this.isSelected(t)&&(this._selection.delete(t),this._emitChanges&&this._deselectedToEmit.push(t))},t.prototype._unmarkAll=function(){var t=this;this.isEmpty()||this._selection.forEach(function(e){return t._unmarkSelected(e)})},t.prototype._verifyValueAssignment=function(t){if(t.length>1&&!this._multiple)throw r()},t}(),h=function(){function t(){this._listeners=[]}return t.prototype.notify=function(t,e){for(var n=0,i=this._listeners;n<i.length;n++){(0,i[n])(t,e)}},t.prototype.listen=function(t){var e=this;return this._listeners.push(t),function(){e._listeners=e._listeners.filter(function(e){return t!==e})}},t.prototype.ngOnDestroy=function(){this._listeners=[]},t.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],t.ngInjectableDef=n.ɵɵdefineInjectable({factory:function(){return new t},token:t,providedIn:"root"}),t}();t.UniqueSelectionDispatcher=h,t.ArrayDataSource=l,t.isDataSource=o,t.DataSource=c,t.getMultipleValuesInSingleSelectionError=r,t.SelectionModel=u,Object.defineProperty(t,"__esModule",{value:!0})});
//# sourceMappingURL=cdk-collections.umd.min.js.map