UNPKG

@angular/cdk

Version:

Angular Material Component Development Kit

38 lines (36 loc) 7.8 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("rxjs"),require("@angular/core")):"function"==typeof define&&define.amd?define("@angular/cdk/collections",["exports","rxjs","@angular/core"],t):t(((e=e||self).ng=e.ng||{},e.ng.cdk=e.ng.cdk||{},e.ng.cdk.collections={}),e.rxjs,e.ng.core)}(this,(function(e,t,n){"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 i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)};function o(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],i=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&i>=e.length&&(e=void 0),{value:e&&e[i++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")} /** * @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 r,c=function(e){function n(t){var n=e.call(this)||this;return n._data=t,n}return function o(e,t){function n(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}(n,e),n.prototype.connect=function(){return t.isObservable(this._data)?this._data:t.of(this._data)},n.prototype.disconnect=function(){},n}(r=function r(){}),s=function(){function e(){}return e.prototype.applyChanges=function(e,t,n,i,o){e.forEachOperation((function(e,i,r){var c,s;if(null==e.previousIndex){var l=n(e,i,r);c=t.createEmbeddedView(l.templateRef,l.context,l.index),s=1}else null==r?(t.remove(i),s=3):(c=t.get(i),t.move(c,r),s=2);o&&o({context:null==c?void 0:c.context,operation:s,record:e})}))},e.prototype.detach=function(){},e}(),l=function(){function e(){this.viewCacheSize=20,this._viewCache=[]}return e.prototype.applyChanges=function(e,t,n,i,o){var r=this;e.forEachOperation((function(e,c,s){var l,a;null==e.previousIndex?a=(l=r._insertView((function(){return n(e,c,s)}),s,t,i(e)))?1:0:null==s?(r._detachAndCacheView(c,t),a=3):(l=r._moveView(c,s,t,i(e)),a=2),o&&o({context:null==l?void 0:l.context,operation:a,record:e})}))},e.prototype.detach=function(){var e,t;try{for(var n=o(this._viewCache),i=n.next();!i.done;i=n.next())i.value.destroy()}catch(t){e={error:t}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}},e.prototype._insertView=function(e,t,n,i){var o=this._insertViewFromCache(t,n);if(!o){var r=e();return n.createEmbeddedView(r.templateRef,r.context,r.index)}o.context.$implicit=i},e.prototype._detachAndCacheView=function(e,t){var n=this._detachView(e,t);this._maybeCacheView(n,t)},e.prototype._moveView=function(e,t,n,i){var o=n.get(e);return n.move(o,t),o.context.$implicit=i,o},e.prototype._maybeCacheView=function(e,t){if(this._viewCache.length<this.viewCacheSize)this._viewCache.push(e);else{var n=t.indexOf(e);-1===n?e.destroy():t.remove(n)}},e.prototype._insertViewFromCache=function(e,t){var n=this._viewCache.pop();return n&&t.insert(n,e),n||null},e.prototype._detachView=function(e,t){return t.detach(e)},e}(),a=function(){function e(e,n,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 t.Subject,n&&n.length&&(e?n.forEach((function(e){return o._markSelected(e)})):this._markSelected(n[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:!1,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){},e}(),u=function(){function e(){this._listeners=[]}return e.prototype.notify=function(e,t){var n,i;try{for(var r=o(this._listeners),c=r.next();!c.done;c=r.next())(0,c.value)(e,t)}catch(e){n={error:e}}finally{try{c&&!c.done&&(i=r.return)&&i.call(r)}finally{if(n)throw n.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}();u.ɵprov=n.ɵɵdefineInjectable({factory:function e(){return new u},token:u,providedIn:"root"}),u.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}]; /** * @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 n.InjectionToken("_ViewRepeater"); /** * @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=c,e.DataSource=r,e.SelectionModel=a,e.UniqueSelectionDispatcher=u,e._DisposeViewRepeaterStrategy=s,e._RecycleViewRepeaterStrategy=l,e._VIEW_REPEATER_STRATEGY=h,e.getMultipleValuesInSingleSelectionError=function p(){return Error("Cannot pass multiple values into SelectionModel with single-value mode.")},e.isDataSource=function f(e){return e&&"function"==typeof e.connect},Object.defineProperty(e,"__esModule",{value:!0})}));