mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-29 09:37:26 +00:00
* tests: improve coverage * refactor: clean up nodes * chore: lint * feat(parser): ignore `BrandVideoShelf` Seems to be used for ads. * feat(parser): ignore `BrandVideoSingleton` too
39 lines
1.0 KiB
TypeScript
39 lines
1.0 KiB
TypeScript
import { YTNode } from '../helpers.js';
|
|
import type { RawNode } from '../index.js';
|
|
import Text from './misc/Text.js';
|
|
import NavigationEndpoint from './NavigationEndpoint.js';
|
|
|
|
export default class DropdownItem extends YTNode {
|
|
static type = 'DropdownItem';
|
|
|
|
label: string;
|
|
selected: boolean;
|
|
value?: number | string;
|
|
icon_type?: string;
|
|
description?: Text;
|
|
endpoint?: NavigationEndpoint;
|
|
|
|
constructor(data: RawNode) {
|
|
super();
|
|
this.label = new Text(data.label).toString();
|
|
this.selected = !!data.isSelected;
|
|
|
|
if (Reflect.has(data, 'int32Value')) {
|
|
this.value = data.int32Value;
|
|
} else if (data.stringValue) {
|
|
this.value = data.stringValue;
|
|
}
|
|
|
|
if (Reflect.has(data, 'onSelectCommand')) {
|
|
this.endpoint = new NavigationEndpoint(data.onSelectCommand);
|
|
}
|
|
|
|
if (Reflect.has(data, 'icon')) {
|
|
this.icon_type = data.icon?.iconType;
|
|
}
|
|
|
|
if (Reflect.has(data, 'descriptionText')) {
|
|
this.description = new Text(data.descriptionText);
|
|
}
|
|
}
|
|
} |