source: trip-planner-front/node_modules/@angular/cdk/esm2015/collections/selection-model.js

Last change on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 16.9 KB
Line 
1/**
2 * @license
3 * Copyright Google LLC All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://angular.io/license
7 */
8import { Subject } from 'rxjs';
9/**
10 * Class to be used to power selecting one or more options from a list.
11 */
12export class SelectionModel {
13 constructor(_multiple = false, initiallySelectedValues, _emitChanges = true) {
14 this._multiple = _multiple;
15 this._emitChanges = _emitChanges;
16 /** Currently-selected values. */
17 this._selection = new Set();
18 /** Keeps track of the deselected options that haven't been emitted by the change event. */
19 this._deselectedToEmit = [];
20 /** Keeps track of the selected options that haven't been emitted by the change event. */
21 this._selectedToEmit = [];
22 /** Event emitted when the value has changed. */
23 this.changed = new Subject();
24 if (initiallySelectedValues && initiallySelectedValues.length) {
25 if (_multiple) {
26 initiallySelectedValues.forEach(value => this._markSelected(value));
27 }
28 else {
29 this._markSelected(initiallySelectedValues[0]);
30 }
31 // Clear the array in order to avoid firing the change event for preselected values.
32 this._selectedToEmit.length = 0;
33 }
34 }
35 /** Selected values. */
36 get selected() {
37 if (!this._selected) {
38 this._selected = Array.from(this._selection.values());
39 }
40 return this._selected;
41 }
42 /**
43 * Selects a value or an array of values.
44 */
45 select(...values) {
46 this._verifyValueAssignment(values);
47 values.forEach(value => this._markSelected(value));
48 this._emitChangeEvent();
49 }
50 /**
51 * Deselects a value or an array of values.
52 */
53 deselect(...values) {
54 this._verifyValueAssignment(values);
55 values.forEach(value => this._unmarkSelected(value));
56 this._emitChangeEvent();
57 }
58 /**
59 * Toggles a value between selected and deselected.
60 */
61 toggle(value) {
62 this.isSelected(value) ? this.deselect(value) : this.select(value);
63 }
64 /**
65 * Clears all of the selected values.
66 */
67 clear() {
68 this._unmarkAll();
69 this._emitChangeEvent();
70 }
71 /**
72 * Determines whether a value is selected.
73 */
74 isSelected(value) {
75 return this._selection.has(value);
76 }
77 /**
78 * Determines whether the model does not have a value.
79 */
80 isEmpty() {
81 return this._selection.size === 0;
82 }
83 /**
84 * Determines whether the model has a value.
85 */
86 hasValue() {
87 return !this.isEmpty();
88 }
89 /**
90 * Sorts the selected values based on a predicate function.
91 */
92 sort(predicate) {
93 if (this._multiple && this.selected) {
94 this._selected.sort(predicate);
95 }
96 }
97 /**
98 * Gets whether multiple values can be selected.
99 */
100 isMultipleSelection() {
101 return this._multiple;
102 }
103 /** Emits a change event and clears the records of selected and deselected values. */
104 _emitChangeEvent() {
105 // Clear the selected values so they can be re-cached.
106 this._selected = null;
107 if (this._selectedToEmit.length || this._deselectedToEmit.length) {
108 this.changed.next({
109 source: this,
110 added: this._selectedToEmit,
111 removed: this._deselectedToEmit
112 });
113 this._deselectedToEmit = [];
114 this._selectedToEmit = [];
115 }
116 }
117 /** Selects a value. */
118 _markSelected(value) {
119 if (!this.isSelected(value)) {
120 if (!this._multiple) {
121 this._unmarkAll();
122 }
123 this._selection.add(value);
124 if (this._emitChanges) {
125 this._selectedToEmit.push(value);
126 }
127 }
128 }
129 /** Deselects a value. */
130 _unmarkSelected(value) {
131 if (this.isSelected(value)) {
132 this._selection.delete(value);
133 if (this._emitChanges) {
134 this._deselectedToEmit.push(value);
135 }
136 }
137 }
138 /** Clears out the selected values. */
139 _unmarkAll() {
140 if (!this.isEmpty()) {
141 this._selection.forEach(value => this._unmarkSelected(value));
142 }
143 }
144 /**
145 * Verifies the value assignment and throws an error if the specified value array is
146 * including multiple values while the selection model is not supporting multiple values.
147 */
148 _verifyValueAssignment(values) {
149 if (values.length > 1 && !this._multiple && (typeof ngDevMode === 'undefined' || ngDevMode)) {
150 throw getMultipleValuesInSingleSelectionError();
151 }
152 }
153}
154/**
155 * Returns an error that reports that multiple values are passed into a selection model
156 * with a single value.
157 * @docs-private
158 */
159export function getMultipleValuesInSingleSelectionError() {
160 return Error('Cannot pass multiple values into SelectionModel with single-value mode.');
161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