mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-01 22:12:26 +01:00
✨ add list selection classes
This commit is contained in:
@@ -424,6 +424,7 @@ export class List<T> implements ISpliceable<T>, IDisposable {
|
||||
}
|
||||
|
||||
this.onFocusChange(this._onFocusChange, this, this.disposables);
|
||||
this.onSelectionChange(this._onSelectionChange, this, this.disposables);
|
||||
|
||||
if (options.ariaLabel) {
|
||||
this.view.domNode.setAttribute('aria-label', options.ariaLabel);
|
||||
@@ -485,6 +486,10 @@ export class List<T> implements ISpliceable<T>, IDisposable {
|
||||
return this.selection.get();
|
||||
}
|
||||
|
||||
getSelectedElements(): T[] {
|
||||
return this.getSelection().map(i => this.view.element(i));
|
||||
}
|
||||
|
||||
setFocus(indexes: number[]): void {
|
||||
indexes = indexes.sort(numericSort);
|
||||
|
||||
@@ -620,6 +625,14 @@ export class List<T> implements ISpliceable<T>, IDisposable {
|
||||
DOM.toggleClass(this.view.domNode, 'element-focused', focus.length > 0);
|
||||
}
|
||||
|
||||
private _onSelectionChange(): void {
|
||||
const selection = this.selection.get();
|
||||
|
||||
DOM.toggleClass(this.view.domNode, 'selection-none', selection.length === 0);
|
||||
DOM.toggleClass(this.view.domNode, 'selection-single', selection.length === 1);
|
||||
DOM.toggleClass(this.view.domNode, 'selection-multiple', selection.length > 1);
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
this._onDispose.fire();
|
||||
this.disposables = dispose(this.disposables);
|
||||
|
||||
Reference in New Issue
Block a user