mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-16 19:12:24 +00:00
482 lines
12 KiB
Markdown
482 lines
12 KiB
Markdown
[youtubei.js](../../../README.md) / [YTNodes](../README.md) / ButtonView
|
|
|
|
# Class: ButtonView
|
|
|
|
## Extends
|
|
|
|
- [`YTNode`](../../Helpers/classes/YTNode.md)
|
|
|
|
## Constructors
|
|
|
|
### new ButtonView()
|
|
|
|
> **new ButtonView**(`data`): [`ButtonView`](ButtonView.md)
|
|
|
|
#### Parameters
|
|
|
|
• **data**: [`RawNode`](../../APIResponseTypes/type-aliases/RawNode.md)
|
|
|
|
#### Returns
|
|
|
|
[`ButtonView`](ButtonView.md)
|
|
|
|
#### Overrides
|
|
|
|
[`YTNode`](../../Helpers/classes/YTNode.md).[`constructor`](../../Helpers/classes/YTNode.md#constructors)
|
|
|
|
#### Defined in
|
|
|
|
[src/parser/classes/ButtonView.ts:38](https://github.com/LuanRT/YouTube.js/blob/4ae0cc5c523a2080e68d6c0c1437c78fe318ea30/src/parser/classes/ButtonView.ts#L38)
|
|
|
|
## Properties
|
|
|
|
### accessibility\_id?
|
|
|
|
> `optional` **accessibility\_id**: `string`
|
|
|
|
#### Defined in
|
|
|
|
[src/parser/classes/ButtonView.ts:30](https://github.com/LuanRT/YouTube.js/blob/4ae0cc5c523a2080e68d6c0c1437c78fe318ea30/src/parser/classes/ButtonView.ts#L30)
|
|
|
|
***
|
|
|
|
### accessibility\_text?
|
|
|
|
> `optional` **accessibility\_text**: `string`
|
|
|
|
#### Defined in
|
|
|
|
[src/parser/classes/ButtonView.ts:36](https://github.com/LuanRT/YouTube.js/blob/4ae0cc5c523a2080e68d6c0c1437c78fe318ea30/src/parser/classes/ButtonView.ts#L36)
|
|
|
|
***
|
|
|
|
### button\_size?
|
|
|
|
> `optional` **button\_size**: `"BUTTON_VIEW_MODEL_SIZE_UNKNOWN"` \| `"BUTTON_VIEW_MODEL_SIZE_DEFAULT"` \| `"BUTTON_VIEW_MODEL_SIZE_COMPACT"` \| `"BUTTON_VIEW_MODEL_SIZE_XSMALL"` \| `"BUTTON_VIEW_MODEL_SIZE_LARGE"` \| `"BUTTON_VIEW_MODEL_SIZE_XLARGE"` \| `"BUTTON_VIEW_MODEL_SIZE_XXLARGE"`
|
|
|
|
#### Defined in
|
|
|
|
[src/parser/classes/ButtonView.ts:14](https://github.com/LuanRT/YouTube.js/blob/4ae0cc5c523a2080e68d6c0c1437c78fe318ea30/src/parser/classes/ButtonView.ts#L14)
|
|
|
|
***
|
|
|
|
### button\_type?
|
|
|
|
> `optional` **button\_type**: `"BUTTON_VIEW_MODEL_TYPE_UNKNOWN"` \| `"BUTTON_VIEW_MODEL_TYPE_FILLED"` \| `"BUTTON_VIEW_MODEL_TYPE_OUTLINE"` \| `"BUTTON_VIEW_MODEL_TYPE_TEXT"` \| `"BUTTON_VIEW_MODEL_TYPE_TONAL"`
|
|
|
|
#### Defined in
|
|
|
|
[src/parser/classes/ButtonView.ts:28](https://github.com/LuanRT/YouTube.js/blob/4ae0cc5c523a2080e68d6c0c1437c78fe318ea30/src/parser/classes/ButtonView.ts#L28)
|
|
|
|
***
|
|
|
|
### custom\_background\_color?
|
|
|
|
> `optional` **custom\_background\_color**: `number`
|
|
|
|
#### Defined in
|
|
|
|
[src/parser/classes/ButtonView.ts:31](https://github.com/LuanRT/YouTube.js/blob/4ae0cc5c523a2080e68d6c0c1437c78fe318ea30/src/parser/classes/ButtonView.ts#L31)
|
|
|
|
***
|
|
|
|
### custom\_border\_color?
|
|
|
|
> `optional` **custom\_border\_color**: `number`
|
|
|
|
#### Defined in
|
|
|
|
[src/parser/classes/ButtonView.ts:19](https://github.com/LuanRT/YouTube.js/blob/4ae0cc5c523a2080e68d6c0c1437c78fe318ea30/src/parser/classes/ButtonView.ts#L19)
|
|
|
|
***
|
|
|
|
### custom\_dark\_theme\_border\_color?
|
|
|
|
> `optional` **custom\_dark\_theme\_border\_color**: `number`
|
|
|
|
#### Defined in
|
|
|
|
[src/parser/classes/ButtonView.ts:23](https://github.com/LuanRT/YouTube.js/blob/4ae0cc5c523a2080e68d6c0c1437c78fe318ea30/src/parser/classes/ButtonView.ts#L23)
|
|
|
|
***
|
|
|
|
### custom\_font\_color?
|
|
|
|
> `optional` **custom\_font\_color**: `number`
|
|
|
|
#### Defined in
|
|
|
|
[src/parser/classes/ButtonView.ts:27](https://github.com/LuanRT/YouTube.js/blob/4ae0cc5c523a2080e68d6c0c1437c78fe318ea30/src/parser/classes/ButtonView.ts#L27)
|
|
|
|
***
|
|
|
|
### enable\_full\_width\_margins?
|
|
|
|
> `optional` **enable\_full\_width\_margins**: `boolean`
|
|
|
|
#### Defined in
|
|
|
|
[src/parser/classes/ButtonView.ts:26](https://github.com/LuanRT/YouTube.js/blob/4ae0cc5c523a2080e68d6c0c1437c78fe318ea30/src/parser/classes/ButtonView.ts#L26)
|
|
|
|
***
|
|
|
|
### enable\_icon\_button?
|
|
|
|
> `optional` **enable\_icon\_button**: `boolean`
|
|
|
|
#### Defined in
|
|
|
|
[src/parser/classes/ButtonView.ts:11](https://github.com/LuanRT/YouTube.js/blob/4ae0cc5c523a2080e68d6c0c1437c78fe318ea30/src/parser/classes/ButtonView.ts#L11)
|
|
|
|
***
|
|
|
|
### enabled?
|
|
|
|
> `optional` **enabled**: `boolean`
|
|
|
|
#### Defined in
|
|
|
|
[src/parser/classes/ButtonView.ts:29](https://github.com/LuanRT/YouTube.js/blob/4ae0cc5c523a2080e68d6c0c1437c78fe318ea30/src/parser/classes/ButtonView.ts#L29)
|
|
|
|
***
|
|
|
|
### icon\_image?
|
|
|
|
> `optional` **icon\_image**: `object`
|
|
|
|
#### Defined in
|
|
|
|
[src/parser/classes/ButtonView.ts:22](https://github.com/LuanRT/YouTube.js/blob/4ae0cc5c523a2080e68d6c0c1437c78fe318ea30/src/parser/classes/ButtonView.ts#L22)
|
|
|
|
***
|
|
|
|
### icon\_image\_flip\_for\_rtl?
|
|
|
|
> `optional` **icon\_image\_flip\_for\_rtl**: `boolean`
|
|
|
|
#### Defined in
|
|
|
|
[src/parser/classes/ButtonView.ts:13](https://github.com/LuanRT/YouTube.js/blob/4ae0cc5c523a2080e68d6c0c1437c78fe318ea30/src/parser/classes/ButtonView.ts#L13)
|
|
|
|
***
|
|
|
|
### icon\_name?
|
|
|
|
> `optional` **icon\_name**: `string`
|
|
|
|
#### Defined in
|
|
|
|
[src/parser/classes/ButtonView.ts:10](https://github.com/LuanRT/YouTube.js/blob/4ae0cc5c523a2080e68d6c0c1437c78fe318ea30/src/parser/classes/ButtonView.ts#L10)
|
|
|
|
***
|
|
|
|
### icon\_position?
|
|
|
|
> `optional` **icon\_position**: `"BUTTON_VIEW_MODEL_ICON_POSITION_UNKNOWN"` \| `"BUTTON_VIEW_MODEL_ICON_POSITION_TRAILING"` \| `"BUTTON_VIEW_MODEL_ICON_POSITION_LEADING"` \| `"BUTTON_VIEW_MODEL_ICON_POSITION_ABOVE"` \| `"BUTTON_VIEW_MODEL_ICON_POSITION_LEADING_TRAILING"`
|
|
|
|
#### Defined in
|
|
|
|
[src/parser/classes/ButtonView.ts:15](https://github.com/LuanRT/YouTube.js/blob/4ae0cc5c523a2080e68d6c0c1437c78fe318ea30/src/parser/classes/ButtonView.ts#L15)
|
|
|
|
***
|
|
|
|
### icon\_trailing?
|
|
|
|
> `optional` **icon\_trailing**: `boolean`
|
|
|
|
#### Defined in
|
|
|
|
[src/parser/classes/ButtonView.ts:35](https://github.com/LuanRT/YouTube.js/blob/4ae0cc5c523a2080e68d6c0c1437c78fe318ea30/src/parser/classes/ButtonView.ts#L35)
|
|
|
|
***
|
|
|
|
### is\_full\_width?
|
|
|
|
> `optional` **is\_full\_width**: `boolean`
|
|
|
|
#### Defined in
|
|
|
|
[src/parser/classes/ButtonView.ts:16](https://github.com/LuanRT/YouTube.js/blob/4ae0cc5c523a2080e68d6c0c1437c78fe318ea30/src/parser/classes/ButtonView.ts#L16)
|
|
|
|
***
|
|
|
|
### on\_disabled\_tap?
|
|
|
|
> `optional` **on\_disabled\_tap**: [`NavigationEndpoint`](NavigationEndpoint.md)
|
|
|
|
#### Defined in
|
|
|
|
[src/parser/classes/ButtonView.ts:18](https://github.com/LuanRT/YouTube.js/blob/4ae0cc5c523a2080e68d6c0c1437c78fe318ea30/src/parser/classes/ButtonView.ts#L18)
|
|
|
|
***
|
|
|
|
### on\_long\_press?
|
|
|
|
> `optional` **on\_long\_press**: [`NavigationEndpoint`](NavigationEndpoint.md)
|
|
|
|
#### Defined in
|
|
|
|
[src/parser/classes/ButtonView.ts:32](https://github.com/LuanRT/YouTube.js/blob/4ae0cc5c523a2080e68d6c0c1437c78fe318ea30/src/parser/classes/ButtonView.ts#L32)
|
|
|
|
***
|
|
|
|
### on\_tap?
|
|
|
|
> `optional` **on\_tap**: [`NavigationEndpoint`](NavigationEndpoint.md)
|
|
|
|
#### Defined in
|
|
|
|
[src/parser/classes/ButtonView.ts:20](https://github.com/LuanRT/YouTube.js/blob/4ae0cc5c523a2080e68d6c0c1437c78fe318ea30/src/parser/classes/ButtonView.ts#L20)
|
|
|
|
***
|
|
|
|
### on\_visible?
|
|
|
|
> `optional` **on\_visible**: `object`
|
|
|
|
#### Defined in
|
|
|
|
[src/parser/classes/ButtonView.ts:34](https://github.com/LuanRT/YouTube.js/blob/4ae0cc5c523a2080e68d6c0c1437c78fe318ea30/src/parser/classes/ButtonView.ts#L34)
|
|
|
|
***
|
|
|
|
### secondary\_icon\_image?
|
|
|
|
> `optional` **secondary\_icon\_image**: [`Thumbnail`](../../Misc/classes/Thumbnail.md)[]
|
|
|
|
#### Defined in
|
|
|
|
[src/parser/classes/ButtonView.ts:9](https://github.com/LuanRT/YouTube.js/blob/4ae0cc5c523a2080e68d6c0c1437c78fe318ea30/src/parser/classes/ButtonView.ts#L9)
|
|
|
|
***
|
|
|
|
### state?
|
|
|
|
> `optional` **state**: `"BUTTON_VIEW_MODEL_STATE_UNKNOWN"` \| `"BUTTON_VIEW_MODEL_STATE_ACTIVE"` \| `"BUTTON_VIEW_MODEL_STATE_INACTIVE"` \| `"BUTTON_VIEW_MODEL_STATE_DISABLED"`
|
|
|
|
#### Defined in
|
|
|
|
[src/parser/classes/ButtonView.ts:17](https://github.com/LuanRT/YouTube.js/blob/4ae0cc5c523a2080e68d6c0c1437c78fe318ea30/src/parser/classes/ButtonView.ts#L17)
|
|
|
|
***
|
|
|
|
### style?
|
|
|
|
> `optional` **style**: `"BUTTON_VIEW_MODEL_STYLE_UNKNOWN"` \| `"BUTTON_VIEW_MODEL_STYLE_CTA"` \| `"BUTTON_VIEW_MODEL_STYLE_BRAND"` \| `"BUTTON_VIEW_MODEL_STYLE_ADS_CTA"` \| `"BUTTON_VIEW_MODEL_STYLE_OVERLAY"` \| `"BUTTON_VIEW_MODEL_STYLE_CTA_THEMED"` \| `"BUTTON_VIEW_MODEL_STYLE_BLACK_CTA"` \| `"BUTTON_VIEW_MODEL_STYLE_CUSTOM"` \| `"BUTTON_VIEW_MODEL_STYLE_MONO"` \| `"BUTTON_VIEW_MODEL_STYLE_OVERLAY_DARK"` \| `"BUTTON_VIEW_MODEL_STYLE_CTA_OVERLAY"` \| `"BUTTON_VIEW_MODEL_STYLE_BRAND_AI"` \| `"BUTTON_VIEW_MODEL_STYLE_YT_GRADIENT"` \| `"BUTTON_VIEW_MODEL_STYLE_BRAND_GRADIENT"`
|
|
|
|
#### Defined in
|
|
|
|
[src/parser/classes/ButtonView.ts:21](https://github.com/LuanRT/YouTube.js/blob/4ae0cc5c523a2080e68d6c0c1437c78fe318ea30/src/parser/classes/ButtonView.ts#L21)
|
|
|
|
***
|
|
|
|
### target\_id?
|
|
|
|
> `optional` **target\_id**: `string`
|
|
|
|
#### Defined in
|
|
|
|
[src/parser/classes/ButtonView.ts:25](https://github.com/LuanRT/YouTube.js/blob/4ae0cc5c523a2080e68d6c0c1437c78fe318ea30/src/parser/classes/ButtonView.ts#L25)
|
|
|
|
***
|
|
|
|
### title?
|
|
|
|
> `optional` **title**: `string`
|
|
|
|
#### Defined in
|
|
|
|
[src/parser/classes/ButtonView.ts:24](https://github.com/LuanRT/YouTube.js/blob/4ae0cc5c523a2080e68d6c0c1437c78fe318ea30/src/parser/classes/ButtonView.ts#L24)
|
|
|
|
***
|
|
|
|
### title\_formatted?
|
|
|
|
> `optional` **title\_formatted**: `object`
|
|
|
|
#### Defined in
|
|
|
|
[src/parser/classes/ButtonView.ts:33](https://github.com/LuanRT/YouTube.js/blob/4ae0cc5c523a2080e68d6c0c1437c78fe318ea30/src/parser/classes/ButtonView.ts#L33)
|
|
|
|
***
|
|
|
|
### tooltip?
|
|
|
|
> `optional` **tooltip**: `string`
|
|
|
|
#### Defined in
|
|
|
|
[src/parser/classes/ButtonView.ts:12](https://github.com/LuanRT/YouTube.js/blob/4ae0cc5c523a2080e68d6c0c1437c78fe318ea30/src/parser/classes/ButtonView.ts#L12)
|
|
|
|
***
|
|
|
|
### type
|
|
|
|
> `readonly` **type**: `string`
|
|
|
|
#### Inherited from
|
|
|
|
[`YTNode`](../../Helpers/classes/YTNode.md).[`type`](../../Helpers/classes/YTNode.md#type)
|
|
|
|
#### Defined in
|
|
|
|
[src/parser/helpers.ts:8](https://github.com/LuanRT/YouTube.js/blob/4ae0cc5c523a2080e68d6c0c1437c78fe318ea30/src/parser/helpers.ts#L8)
|
|
|
|
***
|
|
|
|
### type
|
|
|
|
> `static` **type**: `string` = `'ButtonView'`
|
|
|
|
#### Overrides
|
|
|
|
[`YTNode`](../../Helpers/classes/YTNode.md).[`type`](../../Helpers/classes/YTNode.md#type-1)
|
|
|
|
#### Defined in
|
|
|
|
[src/parser/classes/ButtonView.ts:7](https://github.com/LuanRT/YouTube.js/blob/4ae0cc5c523a2080e68d6c0c1437c78fe318ea30/src/parser/classes/ButtonView.ts#L7)
|
|
|
|
## Methods
|
|
|
|
### as()
|
|
|
|
> **as**\<`T`, `K`\>(...`types`): `InstanceType`\<`K`\[`number`\]\>
|
|
|
|
Cast to one of the given types.
|
|
|
|
#### Type Parameters
|
|
|
|
• **T** *extends* [`YTNode`](../../Helpers/classes/YTNode.md)
|
|
|
|
• **K** *extends* [`YTNodeConstructor`](../../Helpers/interfaces/YTNodeConstructor.md)\<`T`\>[]
|
|
|
|
#### Parameters
|
|
|
|
• ...**types**: `K`
|
|
|
|
The types to cast to
|
|
|
|
#### Returns
|
|
|
|
`InstanceType`\<`K`\[`number`\]\>
|
|
|
|
The node cast to one of the given types
|
|
|
|
#### Throws
|
|
|
|
If the node is not of the given type
|
|
|
|
#### Inherited from
|
|
|
|
[`YTNode`](../../Helpers/classes/YTNode.md).[`as`](../../Helpers/classes/YTNode.md#as)
|
|
|
|
#### Defined in
|
|
|
|
[src/parser/helpers.ts:29](https://github.com/LuanRT/YouTube.js/blob/4ae0cc5c523a2080e68d6c0c1437c78fe318ea30/src/parser/helpers.ts#L29)
|
|
|
|
***
|
|
|
|
### hasKey()
|
|
|
|
> **hasKey**\<`T`, `R`\>(`key`): `this is ButtonView & { [k in string]: R }`
|
|
|
|
Check for a key without asserting the type.
|
|
|
|
#### Type Parameters
|
|
|
|
• **T** *extends* `string`
|
|
|
|
• **R** = `any`
|
|
|
|
#### Parameters
|
|
|
|
• **key**: `T`
|
|
|
|
The key to check
|
|
|
|
#### Returns
|
|
|
|
`this is ButtonView & { [k in string]: R }`
|
|
|
|
Whether the node has the key
|
|
|
|
#### Inherited from
|
|
|
|
[`YTNode`](../../Helpers/classes/YTNode.md).[`hasKey`](../../Helpers/classes/YTNode.md#haskey)
|
|
|
|
#### Defined in
|
|
|
|
[src/parser/helpers.ts:41](https://github.com/LuanRT/YouTube.js/blob/4ae0cc5c523a2080e68d6c0c1437c78fe318ea30/src/parser/helpers.ts#L41)
|
|
|
|
***
|
|
|
|
### is()
|
|
|
|
> **is**\<`T`, `K`\>(...`types`): `this is InstanceType<K[number]>`
|
|
|
|
Check if the node is of the given type.
|
|
|
|
#### Type Parameters
|
|
|
|
• **T** *extends* [`YTNode`](../../Helpers/classes/YTNode.md)
|
|
|
|
• **K** *extends* [`YTNodeConstructor`](../../Helpers/interfaces/YTNodeConstructor.md)\<`T`\>[]
|
|
|
|
#### Parameters
|
|
|
|
• ...**types**: `K`
|
|
|
|
The type to check
|
|
|
|
#### Returns
|
|
|
|
`this is InstanceType<K[number]>`
|
|
|
|
whether the node is of the given type
|
|
|
|
#### Inherited from
|
|
|
|
[`YTNode`](../../Helpers/classes/YTNode.md).[`is`](../../Helpers/classes/YTNode.md#is)
|
|
|
|
#### Defined in
|
|
|
|
[src/parser/helpers.ts:19](https://github.com/LuanRT/YouTube.js/blob/4ae0cc5c523a2080e68d6c0c1437c78fe318ea30/src/parser/helpers.ts#L19)
|
|
|
|
***
|
|
|
|
### key()
|
|
|
|
> **key**\<`T`, `R`\>(`key`): [`Maybe`](../../Helpers/classes/Maybe.md)
|
|
|
|
Assert that the node has the given key and return it.
|
|
|
|
#### Type Parameters
|
|
|
|
• **T** *extends* `string`
|
|
|
|
• **R** = `any`
|
|
|
|
#### Parameters
|
|
|
|
• **key**: `T`
|
|
|
|
The key to check
|
|
|
|
#### Returns
|
|
|
|
[`Maybe`](../../Helpers/classes/Maybe.md)
|
|
|
|
The value of the key wrapped in a Maybe
|
|
|
|
#### Throws
|
|
|
|
If the node does not have the key
|
|
|
|
#### Inherited from
|
|
|
|
[`YTNode`](../../Helpers/classes/YTNode.md).[`key`](../../Helpers/classes/YTNode.md#key)
|
|
|
|
#### Defined in
|
|
|
|
[src/parser/helpers.ts:51](https://github.com/LuanRT/YouTube.js/blob/4ae0cc5c523a2080e68d6c0c1437c78fe318ea30/src/parser/helpers.ts#L51)
|