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 { FocusableOption, FocusKeyManager, FocusMonitor } from '@angular/cdk/a11y';
|
---|
9 | import { BooleanInput } from '@angular/cdk/coercion';
|
---|
10 | import { SelectionModel } from '@angular/cdk/collections';
|
---|
11 | import { AfterContentInit, ChangeDetectorRef, ElementRef, EventEmitter, OnChanges, OnDestroy, OnInit, QueryList, SimpleChanges } from '@angular/core';
|
---|
12 | import { ControlValueAccessor } from '@angular/forms';
|
---|
13 | import { CanDisableRipple, MatLine, ThemePalette } from '@angular/material/core';
|
---|
14 | import { MatListAvatarCssMatStyler, MatListIconCssMatStyler } from './list';
|
---|
15 | declare const _MatSelectionListBase: import("@angular/material/core/common-behaviors/constructor").Constructor<CanDisableRipple> & import("@angular/material/core/common-behaviors/constructor").AbstractConstructor<CanDisableRipple> & {
|
---|
16 | new (): {};
|
---|
17 | };
|
---|
18 | declare const _MatListOptionBase: import("@angular/material/core/common-behaviors/constructor").Constructor<CanDisableRipple> & import("@angular/material/core/common-behaviors/constructor").AbstractConstructor<CanDisableRipple> & {
|
---|
19 | new (): {};
|
---|
20 | };
|
---|
21 | /** @docs-private */
|
---|
22 | export declare const MAT_SELECTION_LIST_VALUE_ACCESSOR: any;
|
---|
23 | /** Change event that is being fired whenever the selected state of an option changes. */
|
---|
24 | export declare class MatSelectionListChange {
|
---|
25 | /** Reference to the selection list that emitted the event. */
|
---|
26 | source: MatSelectionList;
|
---|
27 | /**
|
---|
28 | * Reference to the option that has been changed.
|
---|
29 | * @deprecated Use `options` instead, because some events may change more than one option.
|
---|
30 | * @breaking-change 12.0.0
|
---|
31 | */
|
---|
32 | option: MatListOption;
|
---|
33 | /** Reference to the options that have been changed. */
|
---|
34 | options: MatListOption[];
|
---|
35 | constructor(
|
---|
36 | /** Reference to the selection list that emitted the event. */
|
---|
37 | source: MatSelectionList,
|
---|
38 | /**
|
---|
39 | * Reference to the option that has been changed.
|
---|
40 | * @deprecated Use `options` instead, because some events may change more than one option.
|
---|
41 | * @breaking-change 12.0.0
|
---|
42 | */
|
---|
43 | option: MatListOption,
|
---|
44 | /** Reference to the options that have been changed. */
|
---|
45 | options: MatListOption[]);
|
---|
46 | }
|
---|
47 | /**
|
---|
48 | * Type describing possible positions of a checkbox in a list option
|
---|
49 | * with respect to the list item's text.
|
---|
50 | */
|
---|
51 | export declare type MatListOptionCheckboxPosition = 'before' | 'after';
|
---|
52 | /**
|
---|
53 | * Component for list-options of selection-list. Each list-option can automatically
|
---|
54 | * generate a checkbox and can put current item into the selectionModel of selection-list
|
---|
55 | * if the current item is selected.
|
---|
56 | */
|
---|
57 | export declare class MatListOption extends _MatListOptionBase implements AfterContentInit, OnDestroy, OnInit, FocusableOption, CanDisableRipple {
|
---|
58 | private _element;
|
---|
59 | private _changeDetector;
|
---|
60 | /** @docs-private */
|
---|
61 | selectionList: MatSelectionList;
|
---|
62 | private _selected;
|
---|
63 | private _disabled;
|
---|
64 | private _hasFocus;
|
---|
65 | _avatar: MatListAvatarCssMatStyler;
|
---|
66 | _icon: MatListIconCssMatStyler;
|
---|
67 | _lines: QueryList<MatLine>;
|
---|
68 | /**
|
---|
69 | * Emits when the selected state of the option has changed.
|
---|
70 | * Use to facilitate two-data binding to the `selected` property.
|
---|
71 | * @docs-private
|
---|
72 | */
|
---|
73 | readonly selectedChange: EventEmitter<boolean>;
|
---|
74 | /** DOM element containing the item's text. */
|
---|
75 | _text: ElementRef;
|
---|
76 | /** Whether the label should appear before or after the checkbox. Defaults to 'after' */
|
---|
77 | checkboxPosition: MatListOptionCheckboxPosition;
|
---|
78 | /** Theme color of the list option. This sets the color of the checkbox. */
|
---|
79 | get color(): ThemePalette;
|
---|
80 | set color(newValue: ThemePalette);
|
---|
81 | private _color;
|
---|
82 | /**
|
---|
83 | * This is set to true after the first OnChanges cycle so we don't clear the value of `selected`
|
---|
84 | * in the first cycle.
|
---|
85 | */
|
---|
86 | private _inputsInitialized;
|
---|
87 | /** Value of the option */
|
---|
88 | get value(): any;
|
---|
89 | set value(newValue: any);
|
---|
90 | private _value;
|
---|
91 | /** Whether the option is disabled. */
|
---|
92 | get disabled(): any;
|
---|
93 | set disabled(value: any);
|
---|
94 | /** Whether the option is selected. */
|
---|
95 | get selected(): boolean;
|
---|
96 | set selected(value: boolean);
|
---|
97 | constructor(_element: ElementRef<HTMLElement>, _changeDetector: ChangeDetectorRef,
|
---|
98 | /** @docs-private */
|
---|
99 | selectionList: MatSelectionList);
|
---|
100 | ngOnInit(): void;
|
---|
101 | ngAfterContentInit(): void;
|
---|
102 | ngOnDestroy(): void;
|
---|
103 | /** Toggles the selection state of the option. */
|
---|
104 | toggle(): void;
|
---|
105 | /** Allows for programmatic focusing of the option. */
|
---|
106 | focus(): void;
|
---|
107 | /**
|
---|
108 | * Returns the list item's text label. Implemented as a part of the FocusKeyManager.
|
---|
109 | * @docs-private
|
---|
110 | */
|
---|
111 | getLabel(): any;
|
---|
112 | /** Whether this list item should show a ripple effect when clicked. */
|
---|
113 | _isRippleDisabled(): any;
|
---|
114 | _handleClick(): void;
|
---|
115 | _handleFocus(): void;
|
---|
116 | _handleBlur(): void;
|
---|
117 | /** Retrieves the DOM element of the component host. */
|
---|
118 | _getHostElement(): HTMLElement;
|
---|
119 | /** Sets the selected state of the option. Returns whether the value has changed. */
|
---|
120 | _setSelected(selected: boolean): boolean;
|
---|
121 | /**
|
---|
122 | * Notifies Angular that the option needs to be checked in the next change detection run. Mainly
|
---|
123 | * used to trigger an update of the list option if the disabled state of the selection list
|
---|
124 | * changed.
|
---|
125 | */
|
---|
126 | _markForCheck(): void;
|
---|
127 | static ngAcceptInputType_disabled: BooleanInput;
|
---|
128 | static ngAcceptInputType_selected: BooleanInput;
|
---|
129 | static ngAcceptInputType_disableRipple: BooleanInput;
|
---|
130 | }
|
---|
131 | /**
|
---|
132 | * Material Design list component where each item is a selectable option. Behaves as a listbox.
|
---|
133 | */
|
---|
134 | export declare class MatSelectionList extends _MatSelectionListBase implements CanDisableRipple, AfterContentInit, ControlValueAccessor, OnDestroy, OnChanges {
|
---|
135 | private _element;
|
---|
136 | private _changeDetector;
|
---|
137 | private _focusMonitor?;
|
---|
138 | private _multiple;
|
---|
139 | private _contentInitialized;
|
---|
140 | /** The FocusKeyManager which handles focus. */
|
---|
141 | _keyManager: FocusKeyManager<MatListOption>;
|
---|
142 | /** The option components contained within this selection-list. */
|
---|
143 | options: QueryList<MatListOption>;
|
---|
144 | /** Emits a change event whenever the selected state of an option changes. */
|
---|
145 | readonly selectionChange: EventEmitter<MatSelectionListChange>;
|
---|
146 | /**
|
---|
147 | * Tabindex of the selection list.
|
---|
148 | * @breaking-change 11.0.0 Remove `tabIndex` input.
|
---|
149 | */
|
---|
150 | tabIndex: number;
|
---|
151 | /** Theme color of the selection list. This sets the checkbox color for all list options. */
|
---|
152 | color: ThemePalette;
|
---|
153 | /**
|
---|
154 | * Function used for comparing an option against the selected value when determining which
|
---|
155 | * options should appear as selected. The first argument is the value of an options. The second
|
---|
156 | * one is a value from the selected value. A boolean must be returned.
|
---|
157 | */
|
---|
158 | compareWith: (o1: any, o2: any) => boolean;
|
---|
159 | /** Whether the selection list is disabled. */
|
---|
160 | get disabled(): boolean;
|
---|
161 | set disabled(value: boolean);
|
---|
162 | private _disabled;
|
---|
163 | /** Whether selection is limited to one or multiple items (default multiple). */
|
---|
164 | get multiple(): boolean;
|
---|
165 | set multiple(value: boolean);
|
---|
166 | /** The currently selected options. */
|
---|
167 | selectedOptions: SelectionModel<MatListOption>;
|
---|
168 | /** The tabindex of the selection list. */
|
---|
169 | _tabIndex: number;
|
---|
170 | /** View to model callback that should be called whenever the selected options change. */
|
---|
171 | private _onChange;
|
---|
172 | /** Keeps track of the currently-selected value. */
|
---|
173 | _value: string[] | null;
|
---|
174 | /** Emits when the list has been destroyed. */
|
---|
175 | private readonly _destroyed;
|
---|
176 | /** View to model callback that should be called if the list or its options lost focus. */
|
---|
177 | _onTouched: () => void;
|
---|
178 | /** Whether the list has been destroyed. */
|
---|
179 | private _isDestroyed;
|
---|
180 | constructor(_element: ElementRef<HTMLElement>, tabIndex: string, _changeDetector: ChangeDetectorRef, _focusMonitor?: FocusMonitor | undefined);
|
---|
181 | ngAfterContentInit(): void;
|
---|
182 | ngOnChanges(changes: SimpleChanges): void;
|
---|
183 | ngOnDestroy(): void;
|
---|
184 | /** Focuses the selection list. */
|
---|
185 | focus(options?: FocusOptions): void;
|
---|
186 | /** Selects all of the options. Returns the options that changed as a result. */
|
---|
187 | selectAll(): MatListOption[];
|
---|
188 | /** Deselects all of the options. Returns the options that changed as a result. */
|
---|
189 | deselectAll(): MatListOption[];
|
---|
190 | /** Sets the focused option of the selection-list. */
|
---|
191 | _setFocusedOption(option: MatListOption): void;
|
---|
192 | /**
|
---|
193 | * Removes an option from the selection list and updates the active item.
|
---|
194 | * @returns Currently-active item.
|
---|
195 | */
|
---|
196 | _removeOptionFromList(option: MatListOption): MatListOption | null;
|
---|
197 | /** Passes relevant key presses to our key manager. */
|
---|
198 | _keydown(event: KeyboardEvent): void;
|
---|
199 | /** Reports a value change to the ControlValueAccessor */
|
---|
200 | _reportValueChange(): void;
|
---|
201 | /** Emits a change event if the selected state of an option changed. */
|
---|
202 | _emitChangeEvent(options: MatListOption[]): void;
|
---|
203 | /** Implemented as part of ControlValueAccessor. */
|
---|
204 | writeValue(values: string[]): void;
|
---|
205 | /** Implemented as a part of ControlValueAccessor. */
|
---|
206 | setDisabledState(isDisabled: boolean): void;
|
---|
207 | /** Implemented as part of ControlValueAccessor. */
|
---|
208 | registerOnChange(fn: (value: any) => void): void;
|
---|
209 | /** Implemented as part of ControlValueAccessor. */
|
---|
210 | registerOnTouched(fn: () => void): void;
|
---|
211 | /** Sets the selected options based on the specified values. */
|
---|
212 | private _setOptionsFromValues;
|
---|
213 | /** Returns the values of the selected options. */
|
---|
214 | private _getSelectedOptionValues;
|
---|
215 | /** Toggles the state of the currently focused option if enabled. */
|
---|
216 | private _toggleFocusedOption;
|
---|
217 | /**
|
---|
218 | * Sets the selected state on all of the options
|
---|
219 | * and emits an event if anything changed.
|
---|
220 | */
|
---|
221 | private _setAllOptionsSelected;
|
---|
222 | /**
|
---|
223 | * Utility to ensure all indexes are valid.
|
---|
224 | * @param index The index to be checked.
|
---|
225 | * @returns True if the index is valid for our list of options.
|
---|
226 | */
|
---|
227 | private _isValidIndex;
|
---|
228 | /** Returns the index of the specified list option. */
|
---|
229 | private _getOptionIndex;
|
---|
230 | /** Marks all the options to be checked in the next change detection run. */
|
---|
231 | private _markOptionsForCheck;
|
---|
232 | /**
|
---|
233 | * Removes the tabindex from the selection list and resets it back afterwards, allowing the user
|
---|
234 | * to tab out of it. This prevents the list from capturing focus and redirecting it back within
|
---|
235 | * the list, creating a focus trap if it user tries to tab away.
|
---|
236 | */
|
---|
237 | private _allowFocusEscape;
|
---|
238 | /** Updates the tabindex based upon if the selection list is empty. */
|
---|
239 | private _updateTabIndex;
|
---|
240 | static ngAcceptInputType_disabled: BooleanInput;
|
---|
241 | static ngAcceptInputType_disableRipple: BooleanInput;
|
---|
242 | static ngAcceptInputType_multiple: BooleanInput;
|
---|
243 | }
|
---|
244 | export {};
|
---|