| 73 | ], |
| 74 | }) |
| 75 | export class MatSelectionList |
| 76 | extends MatListBase |
| 77 | implements SelectionList, ControlValueAccessor, AfterViewInit, OnChanges, OnDestroy |
| 78 | { |
| 79 | _element = inject<ElementRef<HTMLElement>>(ElementRef); |
| 80 | private _ngZone = inject(NgZone); |
| 81 | private _renderer = inject(Renderer2); |
| 82 | |
| 83 | private _initialized = false; |
| 84 | private _keyManager!: FocusKeyManager<MatListOption>; |
| 85 | private _listenerCleanups: (() => void)[] | undefined; |
| 86 | |
| 87 | /** Emits when the list has been destroyed. */ |
| 88 | private _destroyed = new Subject<void>(); |
| 89 | |
| 90 | /** Whether the list has been destroyed. */ |
| 91 | private _isDestroyed = false; |
| 92 | |
| 93 | /** View to model callback that should be called whenever the selected options change. */ |
| 94 | private _onChange: (value: any) => void = (_: any) => {}; |
| 95 | |
| 96 | @ContentChildren(MatListOption, {descendants: true}) _items!: QueryList<MatListOption>; |
| 97 | |
| 98 | /** Emits a change event whenever the selected state of an option changes. */ |
| 99 | @Output() readonly selectionChange: EventEmitter<MatSelectionListChange> = |
| 100 | new EventEmitter<MatSelectionListChange>(); |
| 101 | |
| 102 | /** |
| 103 | * Theme color of the selection list. This sets the checkbox color for all |
| 104 | * list options. This API is supported in M2 themes only, it has no effect in |
| 105 | * M3 themes. For color customization in M3, see https://material.angular.dev/components/list/styling. |
| 106 | * |
| 107 | * For information on applying color variants in M3, see |
| 108 | * https://material.angular.dev/guide/material-2-theming#optional-add-backwards-compatibility-styles-for-color-variants |
| 109 | */ |
| 110 | @Input() color: ThemePalette = 'accent'; |
| 111 | |
| 112 | /** |
| 113 | * Function used for comparing an option against the selected value when determining which |
| 114 | * options should appear as selected. The first argument is the value of an options. The second |
| 115 | * one is a value from the selected value. A boolean must be returned. |
| 116 | */ |
| 117 | @Input() compareWith: (o1: any, o2: any) => boolean = (a1, a2) => a1 === a2; |
| 118 | |
| 119 | /** Whether selection is limited to one or multiple items (default multiple). */ |
| 120 | @Input() |
| 121 | get multiple(): boolean { |
| 122 | return this._multiple; |
| 123 | } |
| 124 | set multiple(value: BooleanInput) { |
| 125 | const newValue = coerceBooleanProperty(value); |
| 126 | |
| 127 | if (newValue !== this._multiple) { |
| 128 | if ((typeof ngDevMode === 'undefined' || ngDevMode) && this._initialized) { |
| 129 | throw new Error( |
| 130 | 'Cannot change `multiple` mode of mat-selection-list after initialization.', |
| 131 | ); |
| 132 | } |
nothing calls this directly
no test coverage detected