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 | */
|
---|
8 | import { Subject } from 'rxjs';
|
---|
9 | /**
|
---|
10 | * Class to be used to power selecting one or more options from a list.
|
---|
11 | */
|
---|
12 | export declare class SelectionModel<T> {
|
---|
13 | private _multiple;
|
---|
14 | private _emitChanges;
|
---|
15 | /** Currently-selected values. */
|
---|
16 | private _selection;
|
---|
17 | /** Keeps track of the deselected options that haven't been emitted by the change event. */
|
---|
18 | private _deselectedToEmit;
|
---|
19 | /** Keeps track of the selected options that haven't been emitted by the change event. */
|
---|
20 | private _selectedToEmit;
|
---|
21 | /** Cache for the array value of the selected items. */
|
---|
22 | private _selected;
|
---|
23 | /** Selected values. */
|
---|
24 | get selected(): T[];
|
---|
25 | /** Event emitted when the value has changed. */
|
---|
26 | readonly changed: Subject<SelectionChange<T>>;
|
---|
27 | constructor(_multiple?: boolean, initiallySelectedValues?: T[], _emitChanges?: boolean);
|
---|
28 | /**
|
---|
29 | * Selects a value or an array of values.
|
---|
30 | */
|
---|
31 | select(...values: T[]): void;
|
---|
32 | /**
|
---|
33 | * Deselects a value or an array of values.
|
---|
34 | */
|
---|
35 | deselect(...values: T[]): void;
|
---|
36 | /**
|
---|
37 | * Toggles a value between selected and deselected.
|
---|
38 | */
|
---|
39 | toggle(value: T): void;
|
---|
40 | /**
|
---|
41 | * Clears all of the selected values.
|
---|
42 | */
|
---|
43 | clear(): void;
|
---|
44 | /**
|
---|
45 | * Determines whether a value is selected.
|
---|
46 | */
|
---|
47 | isSelected(value: T): boolean;
|
---|
48 | /**
|
---|
49 | * Determines whether the model does not have a value.
|
---|
50 | */
|
---|
51 | isEmpty(): boolean;
|
---|
52 | /**
|
---|
53 | * Determines whether the model has a value.
|
---|
54 | */
|
---|
55 | hasValue(): boolean;
|
---|
56 | /**
|
---|
57 | * Sorts the selected values based on a predicate function.
|
---|
58 | */
|
---|
59 | sort(predicate?: (a: T, b: T) => number): void;
|
---|
60 | /**
|
---|
61 | * Gets whether multiple values can be selected.
|
---|
62 | */
|
---|
63 | isMultipleSelection(): boolean;
|
---|
64 | /** Emits a change event and clears the records of selected and deselected values. */
|
---|
65 | private _emitChangeEvent;
|
---|
66 | /** Selects a value. */
|
---|
67 | private _markSelected;
|
---|
68 | /** Deselects a value. */
|
---|
69 | private _unmarkSelected;
|
---|
70 | /** Clears out the selected values. */
|
---|
71 | private _unmarkAll;
|
---|
72 | /**
|
---|
73 | * Verifies the value assignment and throws an error if the specified value array is
|
---|
74 | * including multiple values while the selection model is not supporting multiple values.
|
---|
75 | */
|
---|
76 | private _verifyValueAssignment;
|
---|
77 | }
|
---|
78 | /**
|
---|
79 | * Event emitted when the value of a MatSelectionModel has changed.
|
---|
80 | * @docs-private
|
---|
81 | */
|
---|
82 | export interface SelectionChange<T> {
|
---|
83 | /** Model that dispatched the event. */
|
---|
84 | source: SelectionModel<T>;
|
---|
85 | /** Options that were added to the model. */
|
---|
86 | added: T[];
|
---|
87 | /** Options that were removed from the model. */
|
---|
88 | removed: T[];
|
---|
89 | }
|
---|
90 | /**
|
---|
91 | * Returns an error that reports that multiple values are passed into a selection model
|
---|
92 | * with a single value.
|
---|
93 | * @docs-private
|
---|
94 | */
|
---|
95 | export declare function getMultipleValuesInSingleSelectionError(): Error;
|
---|