@angular/cdk
Version:
Angular Material Component Development Kit
22 lines • 4.56 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("tslib"),require("rxjs"),require("@angular/core")):"function"==typeof define&&define.amd?define("@angular/cdk/collections",["exports","tslib","rxjs","@angular/core"],t):t(((e=e||self).ng=e.ng||{},e.ng.cdk=e.ng.cdk||{},e.ng.cdk.collections={}),e.tslib,e.rxjs,e.ng.core)}(this,(function(e,t,n,i){"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 o,s=function(e){function i(t){var n=e.call(this)||this;return n._data=t,n}return t.__extends(i,e),i.prototype.connect=function(){return this._data instanceof n.Observable?this._data:n.of(this._data)},i.prototype.disconnect=function(){},i}(o=function o(){}),r=function(){function e(e,t,i){var o=this;void 0===e&&(e=!1),void 0===i&&(i=!0),this._multiple=e,this._emitChanges=i,this._selection=new Set,this._deselectedToEmit=[],this._selectedToEmit=[],this.changed=new n.Subject,t&&t.length&&(e?t.forEach((function(e){return o._markSelected(e)})):this._markSelected(t[0]),this._selectedToEmit.length=0)}return Object.defineProperty(e.prototype,"selected",{get:function(){return this._selected||(this._selected=Array.from(this._selection.values())),this._selected},enumerable:!0,configurable:!0}),e.prototype.select=function(){for(var e=this,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];this._verifyValueAssignment(t),t.forEach((function(t){return e._markSelected(t)})),this._emitChangeEvent()},e.prototype.deselect=function(){for(var e=this,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];this._verifyValueAssignment(t),t.forEach((function(t){return e._unmarkSelected(t)})),this._emitChangeEvent()},e.prototype.toggle=function(e){this.isSelected(e)?this.deselect(e):this.select(e)},e.prototype.clear=function(){this._unmarkAll(),this._emitChangeEvent()},e.prototype.isSelected=function(e){return this._selection.has(e)},e.prototype.isEmpty=function(){return 0===this._selection.size},e.prototype.hasValue=function(){return!this.isEmpty()},e.prototype.sort=function(e){this._multiple&&this.selected&&this._selected.sort(e)},e.prototype.isMultipleSelection=function(){return this._multiple},e.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=[])},e.prototype._markSelected=function(e){this.isSelected(e)||(this._multiple||this._unmarkAll(),this._selection.add(e),this._emitChanges&&this._selectedToEmit.push(e))},e.prototype._unmarkSelected=function(e){this.isSelected(e)&&(this._selection.delete(e),this._emitChanges&&this._deselectedToEmit.push(e))},e.prototype._unmarkAll=function(){var e=this;this.isEmpty()||this._selection.forEach((function(t){return e._unmarkSelected(t)}))},e.prototype._verifyValueAssignment=function(e){if(e.length>1&&!this._multiple)throw c()},e}();function c(){return Error("Cannot pass multiple values into SelectionModel with single-value mode.")}var l=function(){function e(){this._listeners=[]}return e.prototype.notify=function(e,n){var i,o;try{for(var s=t.__values(this._listeners),r=s.next();!r.done;r=s.next())(0,r.value)(e,n)}catch(e){i={error:e}}finally{try{r&&!r.done&&(o=s.return)&&o.call(s)}finally{if(i)throw i.error}}},e.prototype.listen=function(e){var t=this;return this._listeners.push(e),function(){t._listeners=t._listeners.filter((function(t){return e!==t}))}},e.prototype.ngOnDestroy=function(){this._listeners=[]},e.decorators=[{type:i.Injectable,args:[{providedIn:"root"}]}],e.ɵprov=i.ɵɵdefineInjectable({factory:function t(){return new e},token:e,providedIn:"root"}),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
*/e.ArrayDataSource=s,e.DataSource=o,e.SelectionModel=r,e.UniqueSelectionDispatcher=l,e.getMultipleValuesInSingleSelectionError=c,e.isDataSource=function u(e){return e&&"function"==typeof e.connect}
/**
* @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
*/,Object.defineProperty(e,"__esModule",{value:!0})}));