Constructor
new Menu(player, config)
Creates an instance of the Menu class.
| Name | Type | Description |
|---|---|---|
player |
Player |
Reference to the media player instance. |
config |
Object |
Additional config. |
Members
private #player :Player
private #config :Object
Holds the instance configuration for this component.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
id
|
string | Menu id, used for aria-labelledby connection. |
||
header
|
string | optional | '' | Optional Menu header. |
className
|
string | optional | '' | Additional classname applied to the root element. |
selected
|
number | optional | 0 | Index of currently selected item. |
highlighted
|
number | optional | 0 | Index of currently highlighted item. |
target
|
HTMLElement | A dom node to attach the menu to. |
||
insertMode
|
string | optional | 'append' | Defines how the menu is inserted into the target DOM node. |
showPlaceholder
|
boolean | optional | false | If enabled, display a 'not available' placeholder text if no menu items are available, otherwise completely hide the menu. |
selectMenuThreshold
|
number | optional | 5 | Number of items above which a select-based menu will be used. |
verticalMenuThreshold
|
number | optional | 3 | Number of items above which the button menu switches to vertical layout. |
onSelected
|
function | Callback invoked when a menu item is selected. Signature: (index: number, item: { value: any, label: string }, target: HTMLElement) => void. |
private #data :Array<{value: any, label: string}>
private #menu :DomSmith
Methods
create(data)
Builds or rebuilds the menu UI.
| Name | Type | Description |
|---|---|---|
data |
Array<(null|number|string)> |
List of menu entries. |
setIndex(selected, highlighted)
Sets the active state of the menu item at the selected index.
| Name | Type | Description |
|---|---|---|
selected |
number |
Index of item to mark as selected. |
highlighted |
number |
Index of item to mark as hightlighted. |
private #createSelectMenu() → Object
Creates the select variant of the menu.
private #createButtonMenu() → Object
Creates the button variant of the menu.
getDomSmithInstance() → DomSmith
Returns the menus' DomSmith instance for additional manipulation.