mirror of
https://github.com/material-components/material-web.git
synced 2026-01-09 07:21:09 +08:00
delegates helper in the list controller
This commit is contained in:
parent
c3a5c0e7b3
commit
470710b2ad
@ -138,6 +138,14 @@ export class ListController<Item extends ListItem> {
|
||||
return items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the first activated item of the array of items regarding
|
||||
* controller's configuration.
|
||||
*/
|
||||
get activeItem() {
|
||||
return getActiveItem(this.items, this.isActivatable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles keyboard navigation. Should be bound to the node that will act as
|
||||
* the List.
|
||||
|
||||
@ -8,11 +8,7 @@ import {html, isServer, LitElement} from 'lit';
|
||||
import {queryAssignedElements} from 'lit/decorators.js';
|
||||
|
||||
import {ListController, NavigableKeys} from './list-controller.js';
|
||||
import {
|
||||
getActiveItem,
|
||||
type ItemRecord,
|
||||
ListItem as SharedListItem,
|
||||
} from './list-navigation-helpers.js';
|
||||
import {ListItem as SharedListItem} from './list-navigation-helpers.js';
|
||||
|
||||
const NAVIGABLE_KEY_SET = new Set<string>(Object.values(NavigableKeys));
|
||||
|
||||
@ -96,12 +92,12 @@ export class List extends LitElement {
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the first activated item of a given array of items.
|
||||
* Retrieves the first activated item of the array of items.
|
||||
*
|
||||
* @return A record of the first activated item including the item and the
|
||||
* index of the item or `null` if none are activated.
|
||||
*/
|
||||
get activeItem(): ItemRecord<ListItem> | null {
|
||||
return getActiveItem(this.items);
|
||||
get activeItem() {
|
||||
return this.listController.activeItem;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user