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;
|
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
|
* Handles keyboard navigation. Should be bound to the node that will act as
|
||||||
* the List.
|
* the List.
|
||||||
|
|||||||
@ -8,11 +8,7 @@ import {html, isServer, LitElement} from 'lit';
|
|||||||
import {queryAssignedElements} from 'lit/decorators.js';
|
import {queryAssignedElements} from 'lit/decorators.js';
|
||||||
|
|
||||||
import {ListController, NavigableKeys} from './list-controller.js';
|
import {ListController, NavigableKeys} from './list-controller.js';
|
||||||
import {
|
import {ListItem as SharedListItem} from './list-navigation-helpers.js';
|
||||||
getActiveItem,
|
|
||||||
type ItemRecord,
|
|
||||||
ListItem as SharedListItem,
|
|
||||||
} from './list-navigation-helpers.js';
|
|
||||||
|
|
||||||
const NAVIGABLE_KEY_SET = new Set<string>(Object.values(NavigableKeys));
|
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
|
* @return A record of the first activated item including the item and the
|
||||||
* index of the item or `null` if none are activated.
|
* index of the item or `null` if none are activated.
|
||||||
*/
|
*/
|
||||||
get activeItem(): ItemRecord<ListItem> | null {
|
get activeItem() {
|
||||||
return getActiveItem(this.items);
|
return this.listController.activeItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user