{"version":3,"file":"collections.js","sources":["../../packages/cdk/collections/data-source.js","../../packages/cdk/collections/selection.js","../../packages/cdk/collections/unique-selection-dispatcher.js","../../packages/cdk/collections/index.js"],"sourcesContent":["/**\n * @license\n * Copyright Google Inc. All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n/**\n * @abstract\n */\nexport class DataSource {\n /**\n * Connects a collection viewer (such as a data-table) to this data source. Note that\n * the stream provided will be accessed during change detection and should not directly change\n * values that are bound in template views.\n * @abstract\n * @param {?} collectionViewer The component that exposes a view over the data provided by this\n * data source.\n * @return {?} Observable that emits a new value when the data changes.\n */\n connect(collectionViewer) { }\n /**\n * Disconnects a collection viewer (such as a data-table) from this data source. Can be used\n * to perform any clean-up or tear-down operations when a view is being destroyed.\n *\n * @abstract\n * @param {?} collectionViewer The component that exposes a view over the data provided by this\n * data source.\n * @return {?}\n */\n disconnect(collectionViewer) { }\n}\n//# sourceMappingURL=data-source.js.map","/**\n * @license\n * Copyright Google Inc. All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\nimport { Subject } from 'rxjs/Subject';\n/**\n * Class to be used to power selecting one or more options from a list.\n */\nexport class SelectionModel {\n /**\n * @param {?=} _isMulti\n * @param {?=} initiallySelectedValues\n * @param {?=} _emitChanges\n */\n constructor(_isMulti = false, initiallySelectedValues, _emitChanges = true) {\n this._isMulti = _isMulti;\n this._emitChanges = _emitChanges;\n /**\n * Currently-selected values.\n */\n this._selection = new Set();\n /**\n * Keeps track of the deselected options that haven't been emitted by the change event.\n */\n this._deselectedToEmit = [];\n /**\n * Keeps track of the selected option that haven't been emitted by the change event.\n */\n this._selectedToEmit = [];\n /**\n * Event emitted when the value has changed.\n */\n this.onChange = this._emitChanges ? new Subject() : null;\n if (initiallySelectedValues) {\n if (_isMulti) {\n initiallySelectedValues.forEach(value => this._markSelected(value));\n }\n else {\n this._markSelected(initiallySelectedValues[0]);\n }\n // Clear the array in order to avoid firing the change event for preselected values.\n this._selectedToEmit.length = 0;\n }\n }\n /**\n * Selected value(s).\n * @return {?}\n */\n get selected() {\n if (!this._selected) {\n this._selected = Array.from(this._selection.values());\n }\n return this._selected;\n }\n /**\n * Selects a value or an array of values.\n * @param {...?} values\n * @return {?}\n */\n select(...values) {\n this._verifyValueAssignment(values);\n values.forEach(value => this._markSelected(value));\n this._emitChangeEvent();\n }\n /**\n * Deselects a value or an array of values.\n * @param {...?} values\n * @return {?}\n */\n deselect(...values) {\n this._verifyValueAssignment(values);\n values.forEach(value => this._unmarkSelected(value));\n this._emitChangeEvent();\n }\n /**\n * Toggles a value between selected and deselected.\n * @param {?} value\n * @return {?}\n */\n toggle(value) {\n this.isSelected(value) ? this.deselect(value) : this.select(value);\n }\n /**\n * Clears all of the selected values.\n * @return {?}\n */\n clear() {\n this._unmarkAll();\n this._emitChangeEvent();\n }\n /**\n * Determines whether a value is selected.\n * @param {?} value\n * @return {?}\n */\n isSelected(value) {\n return this._selection.has(value);\n }\n /**\n * Determines whether the model does not have a value.\n * @return {?}\n */\n isEmpty() {\n return this._selection.size === 0;\n }\n /**\n * Determines whether the model has a value.\n * @return {?}\n */\n hasValue() {\n return !this.isEmpty();\n }\n /**\n * Sorts the selected values based on a predicate function.\n * @param {?=} predicate\n * @return {?}\n */\n sort(predicate) {\n if (this._isMulti && this._selected) {\n this._selected.sort(predicate);\n }\n }\n /**\n * Emits a change event and clears the records of selected and deselected values.\n * @return {?}\n */\n _emitChangeEvent() {\n if (this._selectedToEmit.length || this._deselectedToEmit.length) {\n let /** @type {?} */ eventData = new SelectionChange(this._selectedToEmit, this._deselectedToEmit);\n if (this.onChange) {\n this.onChange.next(eventData);\n }\n this._deselectedToEmit = [];\n this._selectedToEmit = [];\n }\n this._selected = null;\n }\n /**\n * Selects a value.\n * @param {?} value\n * @return {?}\n */\n _markSelected(value) {\n if (!this.isSelected(value)) {\n if (!this._isMulti) {\n this._unmarkAll();\n }\n this._selection.add(value);\n if (this._emitChanges) {\n this._selectedToEmit.push(value);\n }\n }\n }\n /**\n * Deselects a value.\n * @param {?} value\n * @return {?}\n */\n _unmarkSelected(value) {\n if (this.isSelected(value)) {\n this._selection.delete(value);\n if (this._emitChanges) {\n this._deselectedToEmit.push(value);\n }\n }\n }\n /**\n * Clears out the selected values.\n * @return {?}\n */\n _unmarkAll() {\n if (!this.isEmpty()) {\n this._selection.forEach(value => this._unmarkSelected(value));\n }\n }\n /**\n * Verifies the value assignment and throws an error if the specified value array is\n * including multiple values while the selection model is not supporting multiple values.\n * @param {?} values\n * @return {?}\n */\n _verifyValueAssignment(values) {\n if (values.length > 1 && !this._isMulti) {\n throw getMultipleValuesInSingleSelectionError();\n }\n }\n}\nfunction SelectionModel_tsickle_Closure_declarations() {\n /**\n * Currently-selected values.\n * @type {?}\n */\n SelectionModel.prototype._selection;\n /**\n * Keeps track of the deselected options that haven't been emitted by the change event.\n * @type {?}\n */\n SelectionModel.prototype._deselectedToEmit;\n /**\n * Keeps track of the selected option that haven't been emitted by the change event.\n * @type {?}\n */\n SelectionModel.prototype._selectedToEmit;\n /**\n * Cache for the array value of the selected items.\n * @type {?}\n */\n SelectionModel.prototype._selected;\n /**\n * Event emitted when the value has changed.\n * @type {?}\n */\n SelectionModel.prototype.onChange;\n /** @type {?} */\n SelectionModel.prototype._isMulti;\n /** @type {?} */\n SelectionModel.prototype._emitChanges;\n}\n/**\n * Describes an event emitted when the value of a MatSelectionModel has changed.\n * \\@docs-private\n */\nexport class SelectionChange {\n /**\n * @param {?=} added\n * @param {?=} removed\n */\n constructor(added, removed) {\n this.added = added;\n this.removed = removed;\n }\n}\nfunction SelectionChange_tsickle_Closure_declarations() {\n /** @type {?} */\n SelectionChange.prototype.added;\n /** @type {?} */\n SelectionChange.prototype.removed;\n}\n/**\n * Returns an error that reports that multiple values are passed into a selection model\n * with a single value.\n * @return {?}\n */\nexport function getMultipleValuesInSingleSelectionError() {\n return Error('Cannot pass multiple values into SelectionModel with single-value mode.');\n}\n//# sourceMappingURL=selection.js.map","/**\n * @license\n * Copyright Google Inc. All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\nimport { Injectable, Optional, SkipSelf } from '@angular/core';\n/**\n * Class to coordinate unique selection based on name.\n * Intended to be consumed as an Angular service.\n * This service is needed because native radio change events are only fired on the item currently\n * being selected, and we still need to uncheck the previous selection.\n *\n * This service does not *store* any IDs and names because they may change at any time, so it is\n * less error-prone if they are simply passed through when the events occur.\n */\nexport class UniqueSelectionDispatcher {\n constructor() {\n this._listeners = [];\n }\n /**\n * Notify other items that selection for the given name has been set.\n * @param {?} id ID of the item.\n * @param {?} name Name of the item.\n * @return {?}\n */\n notify(id, name) {\n for (let /** @type {?} */ listener of this._listeners) {\n listener(id, name);\n }\n }\n /**\n * Listen for future changes to item selection.\n * @param {?} listener\n * @return {?} Function used to deregister listener\n */\n listen(listener) {\n this._listeners.push(listener);\n return () => {\n this._listeners = this._listeners.filter((registered) => {\n return listener !== registered;\n });\n };\n }\n}\nUniqueSelectionDispatcher.decorators = [\n { type: Injectable },\n];\n/**\n * @nocollapse\n */\nUniqueSelectionDispatcher.ctorParameters = () => [];\nfunction UniqueSelectionDispatcher_tsickle_Closure_declarations() {\n /** @type {?} */\n UniqueSelectionDispatcher.decorators;\n /**\n * @nocollapse\n * @type {?}\n */\n UniqueSelectionDispatcher.ctorParameters;\n /** @type {?} */\n UniqueSelectionDispatcher.prototype._listeners;\n}\n/**\n * \\@docs-private\n * @param {?} parentDispatcher\n * @return {?}\n */\nexport function UNIQUE_SELECTION_DISPATCHER_PROVIDER_FACTORY(parentDispatcher) {\n return parentDispatcher || new UniqueSelectionDispatcher();\n}\n/**\n * \\@docs-private\n */\nexport const UNIQUE_SELECTION_DISPATCHER_PROVIDER = {\n // If there is already a dispatcher available, use that. Otherwise, provide a new one.\n provide: UniqueSelectionDispatcher,\n deps: [[new Optional(), new SkipSelf(), UniqueSelectionDispatcher]],\n useFactory: UNIQUE_SELECTION_DISPATCHER_PROVIDER_FACTORY\n};\n//# sourceMappingURL=unique-selection-dispatcher.js.map","/**\n * Generated bundle index. Do not edit.\n */\nexport { UniqueSelectionDispatcher, UNIQUE_SELECTION_DISPATCHER_PROVIDER, DataSource, SelectionModel, SelectionChange, getMultipleValuesInSingleSelectionError } from './public-api';\nexport { UNIQUE_SELECTION_DISPATCHER_PROVIDER_FACTORY as ɵa } from './unique-selection-dispatcher';\n//# sourceMappingURL=index.js.map"],"names":[],"mappings":";;;;;;;;;;AAOA;;;AAGA,AAAO,MAAM,UAAU,CAAC;;;;;;;;;;IAUpB,OAAO,CAAC,gBAAgB,EAAE,GAAG;;;;;;;;;;IAU7B,UAAU,CAAC,gBAAgB,EAAE,GAAG;CACnC,AACD;;ACxBA;;;AAGA,AAAO,MAAM,cAAc,CAAC;;;;;;IAMxB,WAAW,CAAC,QAAQ,GAAG,KAAK,EAAE,uBAAuB,EAAE,YAAY,GAAG,IAAI,EAAE;QACxE,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;;;;QAIjC,IAAI,CAAC,UAAU,GAAG,IAAI,GAAG,EAAE,CAAC;;;;QAI5B,IAAI,CAAC,iBAAiB,GAAG,EAAE,CAAC;;;;QAI5B,IAAI,CAAC,eAAe,GAAG,EAAE,CAAC;;;;QAI1B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,YAAY,GAAG,IAAI,OAAO,EAAE,GAAG,IAAI,CAAC;QACzD,IAAI,uBAAuB,EAAE;YACzB,IAAI,QAAQ,EAAE;gBACV,uBAAuB,CAAC,OAAO,CAAC,KAAK,IAAI,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC;aACvE;iBACI;gBACD,IAAI,CAAC,aAAa,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC,CAAC;aAClD;;YAED,IAAI,CAAC,eAAe,CA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