Skip to content

Commit

Permalink
feat(parser): Add MenuFlexibleItem
Browse files Browse the repository at this point in the history
  • Loading branch information
LuanRT committed Nov 15, 2024
1 parent 126a66f commit bc9a0ed
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/parser/classes/menus/Menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ import SegmentedLikeDislikeButtonView from '../SegmentedLikeDislikeButtonView.js
export default class Menu extends YTNode {
static type = 'Menu';

items: ObservedArray<YTNode>;
top_level_buttons: ObservedArray<Button | ButtonView | SegmentedLikeDislikeButtonView>;
label?: string;
public items: ObservedArray<YTNode>;
public flexible_items: ObservedArray<YTNode>;
public top_level_buttons: ObservedArray<Button | ButtonView | SegmentedLikeDislikeButtonView>;
public label?: string;

constructor(data: RawNode) {
super();
this.items = Parser.parseArray(data.items);
this.flexible_items = Parser.parseArray(data.flexibleItems);
this.top_level_buttons = Parser.parseArray(data.topLevelButtons, [ Button, ButtonView, SegmentedLikeDislikeButtonView ]);

if (Reflect.has(data, 'accessibility') && Reflect.has(data.accessibility, 'accessibilityData')) {
Expand Down
20 changes: 20 additions & 0 deletions src/parser/classes/menus/MenuFlexibleItem.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Parser } from '../../index.js';
import { YTNode } from '../../helpers.js';
import type { RawNode } from '../../index.js';

import Button from '../Button.js';
import ButtonView from '../ButtonView.js';
import MenuServiceItem from './MenuServiceItem.js';

export default class MenuFlexibleItem extends YTNode {
static type = 'MenuFlexibleItem';

public menu_item: MenuServiceItem | null;
public top_level_button: ButtonView | Button | null;

constructor(data: RawNode) {
super();
this.menu_item = Parser.parseItem(data.menuItem, MenuServiceItem);
this.top_level_button = Parser.parseItem(data.topLevelButton, [ ButtonView, Button ]);
}
}
1 change: 1 addition & 0 deletions src/parser/nodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ export { default as MacroMarkersInfoItem } from './classes/MacroMarkersInfoItem.
export { default as MacroMarkersList } from './classes/MacroMarkersList.js';
export { default as MacroMarkersListItem } from './classes/MacroMarkersListItem.js';
export { default as Menu } from './classes/menus/Menu.js';
export { default as MenuFlexibleItem } from './classes/menus/MenuFlexibleItem.js';
export { default as MenuNavigationItem } from './classes/menus/MenuNavigationItem.js';
export { default as MenuPopup } from './classes/menus/MenuPopup.js';
export { default as MenuServiceItem } from './classes/menus/MenuServiceItem.js';
Expand Down

0 comments on commit bc9a0ed

Please sign in to comment.