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