selection-list.ts (material2-7.3.2) | : | selection-list.ts (material2-7.3.3) | ||
---|---|---|---|---|
skipping to change at line 41 | skipping to change at line 41 | |||
EventEmitter, | EventEmitter, | |||
forwardRef, | forwardRef, | |||
Inject, | Inject, | |||
Input, | Input, | |||
OnDestroy, | OnDestroy, | |||
OnInit, | OnInit, | |||
Output, | Output, | |||
QueryList, | QueryList, | |||
ViewChild, | ViewChild, | |||
ViewEncapsulation, | ViewEncapsulation, | |||
SimpleChanges, | ||||
OnChanges, | ||||
} from '@angular/core'; | } from '@angular/core'; | |||
import { | import { | |||
CanDisableRipple, CanDisableRippleCtor, | CanDisableRipple, CanDisableRippleCtor, | |||
MatLine, | MatLine, | |||
setLines, | setLines, | |||
mixinDisableRipple, | mixinDisableRipple, | |||
} from '@angular/material/core'; | } from '@angular/material/core'; | |||
import {ControlValueAccessor, NG_VALUE_ACCESSOR} from '@angular/forms'; | import {ControlValueAccessor, NG_VALUE_ACCESSOR} from '@angular/forms'; | |||
import {Subscription} from 'rxjs'; | import {Subscription} from 'rxjs'; | |||
import {MatListAvatarCssMatStyler, MatListIconCssMatStyler} from './list'; | import {MatListAvatarCssMatStyler, MatListIconCssMatStyler} from './list'; | |||
skipping to change at line 300 | skipping to change at line 302 | |||
'aria-multiselectable': 'true', | 'aria-multiselectable': 'true', | |||
'[attr.aria-disabled]': 'disabled.toString()', | '[attr.aria-disabled]': 'disabled.toString()', | |||
}, | }, | |||
template: '<ng-content></ng-content>', | template: '<ng-content></ng-content>', | |||
styleUrls: ['list.css'], | styleUrls: ['list.css'], | |||
encapsulation: ViewEncapsulation.None, | encapsulation: ViewEncapsulation.None, | |||
providers: [MAT_SELECTION_LIST_VALUE_ACCESSOR], | providers: [MAT_SELECTION_LIST_VALUE_ACCESSOR], | |||
changeDetection: ChangeDetectionStrategy.OnPush | changeDetection: ChangeDetectionStrategy.OnPush | |||
}) | }) | |||
export class MatSelectionList extends _MatSelectionListMixinBase implements Focu sableOption, | export class MatSelectionList extends _MatSelectionListMixinBase implements Focu sableOption, | |||
CanDisableRipple, AfterContentInit, ControlValueAccessor, OnDestroy { | CanDisableRipple, AfterContentInit, ControlValueAccessor, OnDestroy, OnChang es { | |||
/** The FocusKeyManager which handles focus. */ | /** The FocusKeyManager which handles focus. */ | |||
_keyManager: FocusKeyManager<MatListOption>; | _keyManager: FocusKeyManager<MatListOption>; | |||
/** The option components contained within this selection-list. */ | /** The option components contained within this selection-list. */ | |||
@ContentChildren(MatListOption, {descendants: true}) options: QueryList<MatLis tOption>; | @ContentChildren(MatListOption, {descendants: true}) options: QueryList<MatLis tOption>; | |||
/** Emits a change event whenever the selected state of an option changes. */ | /** Emits a change event whenever the selected state of an option changes. */ | |||
@Output() readonly selectionChange: EventEmitter<MatSelectionListChange> = | @Output() readonly selectionChange: EventEmitter<MatSelectionListChange> = | |||
new EventEmitter<MatSelectionListChange>(); | new EventEmitter<MatSelectionListChange>(); | |||
skipping to change at line 332 | skipping to change at line 334 | |||
/** Whether the selection list is disabled. */ | /** Whether the selection list is disabled. */ | |||
@Input() | @Input() | |||
get disabled(): boolean { return this._disabled; } | get disabled(): boolean { return this._disabled; } | |||
set disabled(value: boolean) { | set disabled(value: boolean) { | |||
this._disabled = coerceBooleanProperty(value); | this._disabled = coerceBooleanProperty(value); | |||
// The `MatSelectionList` and `MatListOption` are using the `OnPush` change detection | // The `MatSelectionList` and `MatListOption` are using the `OnPush` change detection | |||
// strategy. Therefore the options will not check for any changes if the `Ma tSelectionList` | // strategy. Therefore the options will not check for any changes if the `Ma tSelectionList` | |||
// changed its state. Since we know that a change to `disabled` property of the list affects | // changed its state. Since we know that a change to `disabled` property of the list affects | |||
// the state of the options, we manually mark each option for check. | // the state of the options, we manually mark each option for check. | |||
if (this.options) { | this._markOptionsForCheck(); | |||
this.options.forEach(option => option._markForCheck()); | ||||
} | ||||
} | } | |||
private _disabled: boolean = false; | private _disabled: boolean = false; | |||
/** The currently selected options. */ | /** The currently selected options. */ | |||
selectedOptions: SelectionModel<MatListOption> = new SelectionModel<MatListOpt ion>(true); | selectedOptions: SelectionModel<MatListOption> = new SelectionModel<MatListOpt ion>(true); | |||
/** View to model callback that should be called whenever the selected options change. */ | /** View to model callback that should be called whenever the selected options change. */ | |||
private _onChange: (value: any) => void = (_: any) => {}; | private _onChange: (value: any) => void = (_: any) => {}; | |||
/** Used for storing the values that were assigned before the options were ini tialized. */ | /** Used for storing the values that were assigned before the options were ini tialized. */ | |||
skipping to change at line 388 | skipping to change at line 388 | |||
} | } | |||
if (event.removed) { | if (event.removed) { | |||
for (let item of event.removed) { | for (let item of event.removed) { | |||
item.selected = false; | item.selected = false; | |||
} | } | |||
} | } | |||
}); | }); | |||
} | } | |||
ngOnChanges(changes: SimpleChanges) { | ||||
const disableRippleChanges = changes.disableRipple; | ||||
if (disableRippleChanges && !disableRippleChanges.firstChange) { | ||||
this._markOptionsForCheck(); | ||||
} | ||||
} | ||||
ngOnDestroy() { | ngOnDestroy() { | |||
this._modelChanges.unsubscribe(); | this._modelChanges.unsubscribe(); | |||
} | } | |||
/** Focuses the last active list option. */ | /** Focuses the last active list option. */ | |||
focus() { | focus() { | |||
this._element.nativeElement.focus(); | this._element.nativeElement.focus(); | |||
} | } | |||
/** Selects all of the options. */ | /** Selects all of the options. */ | |||
skipping to change at line 582 | skipping to change at line 590 | |||
* @returns True if the index is valid for our list of options. | * @returns True if the index is valid for our list of options. | |||
*/ | */ | |||
private _isValidIndex(index: number): boolean { | private _isValidIndex(index: number): boolean { | |||
return index >= 0 && index < this.options.length; | return index >= 0 && index < this.options.length; | |||
} | } | |||
/** Returns the index of the specified list option. */ | /** Returns the index of the specified list option. */ | |||
private _getOptionIndex(option: MatListOption): number { | private _getOptionIndex(option: MatListOption): number { | |||
return this.options.toArray().indexOf(option); | return this.options.toArray().indexOf(option); | |||
} | } | |||
/** Marks all the options to be checked in the next change detection run. */ | ||||
private _markOptionsForCheck() { | ||||
if (this.options) { | ||||
this.options.forEach(option => option._markForCheck()); | ||||
} | ||||
} | ||||
} | } | |||
End of changes. 5 change blocks. | ||||
4 lines changed or deleted | 19 lines changed or added |