feat(YouTube/Search): add SearchSubMenu node (#340)

This commit is contained in:
LuanRT
2023-03-07 04:17:58 -03:00
committed by GitHub
parent cf8a33c79f
commit a511608f18
6 changed files with 78 additions and 4 deletions

View File

@@ -0,0 +1,22 @@
import { YTNode } from '../helpers.js';
import type { RawNode } from '../index.js';
import Text from './misc/Text.js';
import NavigationEndpoint from './NavigationEndpoint.js';
class SearchFilter extends YTNode {
static type = 'SearchFilter';
label: Text;
endpoint: NavigationEndpoint;
tooltip: string;
constructor(data: RawNode) {
super();
this.label = new Text(data.label);
this.endpoint = new NavigationEndpoint(data.endpoint);
this.tooltip = data.tooltip;
}
}
export default SearchFilter;

View File

@@ -0,0 +1,20 @@
import { ObservedArray, YTNode } from '../helpers.js';
import type { RawNode } from '../index.js';
import { Parser, YTNodes } from '../index.js';
import Text from './misc/Text.js';
class SearchFilterGroup extends YTNode {
static type = 'SearchFilterGroup';
title: Text;
filters: ObservedArray<YTNodes.SearchFilter> | null;
constructor(data: RawNode) {
super();
this.title = new Text(data.title);
this.filters = Parser.parseArray(data.filters, YTNodes.SearchFilter);
}
}
export default SearchFilterGroup;

View File

@@ -0,0 +1,21 @@
import { ObservedArray, YTNode } from '../helpers.js';
import type { RawNode } from '../index.js';
import Parser, { YTNodes } from '../index.js';
import Text from './misc/Text.js';
class SearchSubMenu extends YTNode {
static type = 'SearchSubMenu';
title: Text;
groups: ObservedArray<YTNodes.SearchFilterGroup> | null;
button: YTNodes.ToggleButton | null;
constructor(data: RawNode) {
super();
this.title = new Text(data.title);
this.groups = Parser.parseArray(data.groups, YTNodes.SearchFilterGroup);
this.button = Parser.parseItem(data.button, YTNodes.ToggleButton);
}
}
export default SearchSubMenu;