add action row component
This commit is contained in:
26
library/core/components/action-row.tsx
Normal file
26
library/core/components/action-row.tsx
Normal file
@@ -0,0 +1,26 @@
|
||||
import type { ReactNode } from "react"
|
||||
import React from "react"
|
||||
import { ReacordElement } from "../../internal/element.js"
|
||||
import type { MessageOptions } from "../../internal/message"
|
||||
import { Node } from "../../internal/node.js"
|
||||
|
||||
export type ActionRowProps = {
|
||||
children?: ReactNode
|
||||
}
|
||||
|
||||
export function ActionRow(props: ActionRowProps) {
|
||||
return (
|
||||
<ReacordElement props={props} createNode={() => new ActionRowNode(props)}>
|
||||
{props.children}
|
||||
</ReacordElement>
|
||||
)
|
||||
}
|
||||
|
||||
class ActionRowNode extends Node<{}> {
|
||||
override modifyMessageOptions(options: MessageOptions): void {
|
||||
options.actionRows.push([])
|
||||
for (const child of this.children) {
|
||||
child.modifyMessageOptions(options)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ export type MessageOptions = {
|
||||
actionRows: ActionRow[]
|
||||
}
|
||||
|
||||
type ActionRow = Array<
|
||||
export type ActionRow = Array<
|
||||
MessageButtonOptions | MessageLinkOptions | MessageSelectOptions
|
||||
>
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
export * from "./core/adapters/adapter"
|
||||
export * from "./core/adapters/discord-js-adapter"
|
||||
export * from "./core/components/action-row"
|
||||
export * from "./core/components/button"
|
||||
export * from "./core/components/embed"
|
||||
export * from "./core/components/embed-author"
|
||||
|
||||
Reference in New Issue
Block a user