form

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 30, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Button

type Button struct {
	Text string

	Image string
}

func NewButton

func NewButton(text, image string) Button

func NoButton

func NoButton() Button

func YesButton

func YesButton() Button

func (Button) MarshalJSON

func (b Button) MarshalJSON() ([]byte, error)

type Closer

type Closer interface {
	Close(submitter Submitter, tx *world.Tx)
}

type Custom

type Custom struct {
	// contains filtered or unexported fields
}

func New

func New(submittable Submittable, title ...any) Custom

func (Custom) Elements

func (f Custom) Elements() []Element

func (Custom) MarshalJSON

func (f Custom) MarshalJSON() ([]byte, error)

func (Custom) SubmitJSON

func (f Custom) SubmitJSON(b []byte, submitter Submitter, tx *world.Tx) error

func (Custom) Title

func (f Custom) Title() string

type Divider

type Divider struct{}

func (Divider) MarshalJSON

func (d Divider) MarshalJSON() ([]byte, error)
type Dropdown struct {
	Text string

	Options []string

	DefaultIndex int

	Tooltip string
	// contains filtered or unexported fields
}

func NewDropdown

func NewDropdown(text string, options []string, defaultIndex int) Dropdown
func (d Dropdown) MarshalJSON() ([]byte, error)
func (d Dropdown) Value() int
func (d Dropdown) WithTooltip(tooltip string) Dropdown

type Element

type Element interface {
	json.Marshaler
	// contains filtered or unexported methods
}

type Form

type Form interface {
	json.Marshaler
	SubmitJSON(b []byte, submitter Submitter, tx *world.Tx) error
}
type Header struct {
	Text string
}

func NewHeader

func NewHeader(text string) Header

func (Header) MarshalJSON

func (h Header) MarshalJSON() ([]byte, error)

type Input

type Input struct {
	Text string

	Default string

	Placeholder string

	Tooltip string
	// contains filtered or unexported fields
}

func NewInput

func NewInput(text, defaultValue, placeholder string) Input

func (Input) MarshalJSON

func (i Input) MarshalJSON() ([]byte, error)

func (Input) Value

func (i Input) Value() string

func (Input) WithTooltip

func (i Input) WithTooltip(tooltip string) Input

type Label

type Label struct {
	Text string
}

func NewLabel

func NewLabel(text string) Label

func (Label) MarshalJSON

func (l Label) MarshalJSON() ([]byte, error)
type Menu struct {
	// contains filtered or unexported fields
}

func NewMenu

func NewMenu(submittable MenuSubmittable, title ...any) Menu
func (m Menu) AddButton(button Button) Menu
func (m Menu) AddDivider(divider Divider) Menu
func (m Menu) AddHeader(header Header) Menu
func (m Menu) AddLabel(label Label) Menu
func (m Menu) Body() string
func (m Menu) Buttons() []Button
func (m Menu) Elements() []MenuElement
func (m Menu) MarshalJSON() ([]byte, error)
func (m Menu) SubmitJSON(b []byte, submitter Submitter, tx *world.Tx) error
func (m Menu) Title() string
func (m Menu) WithBody(body ...any) Menu
func (m Menu) WithButtons(buttons ...Button) Menu
func (m Menu) WithElements(elements ...MenuElement) Menu
type MenuElement interface {
	json.Marshaler
	// contains filtered or unexported methods
}
type MenuSubmittable interface {
	Submit(submitter Submitter, pressed Button, tx *world.Tx)
}
type Modal struct {
	// contains filtered or unexported fields
}

func NewModal

func NewModal(submittable ModalSubmittable, title ...any) Modal

func (Modal) Body

func (m Modal) Body() string

func (Modal) Buttons

func (m Modal) Buttons() []Button

func (Modal) MarshalJSON

func (m Modal) MarshalJSON() ([]byte, error)

func (Modal) SubmitJSON

func (m Modal) SubmitJSON(b []byte, submitter Submitter, tx *world.Tx) error

func (Modal) Title

func (m Modal) Title() string

func (Modal) WithBody

func (m Modal) WithBody(body ...any) Modal

type ModalSubmittable

type ModalSubmittable MenuSubmittable

type Slider

type Slider struct {
	Text string

	Min, Max float64

	StepSize float64

	Default float64

	Tooltip string
	// contains filtered or unexported fields
}

func NewSlider

func NewSlider(text string, min, max, stepSize, defaultValue float64) Slider

func (Slider) MarshalJSON

func (s Slider) MarshalJSON() ([]byte, error)

func (Slider) Value

func (s Slider) Value() float64

func (Slider) WithTooltip

func (s Slider) WithTooltip(tooltip string) Slider

type StepSlider

type StepSlider Dropdown

func NewStepSlider

func NewStepSlider(text string, options []string, defaultIndex int) StepSlider

func (StepSlider) MarshalJSON

func (s StepSlider) MarshalJSON() ([]byte, error)

func (StepSlider) Value

func (s StepSlider) Value() int

func (StepSlider) WithTooltip

func (s StepSlider) WithTooltip(tooltip string) StepSlider

type Submittable

type Submittable interface {
	Submit(submitter Submitter, tx *world.Tx)
}

type Submitter

type Submitter interface {
	SendForm(form Form)
	CloseForm()
}

type Toggle

type Toggle struct {
	Text string

	Default bool

	Tooltip string
	// contains filtered or unexported fields
}

func NewToggle

func NewToggle(text string, defaultValue bool) Toggle

func (Toggle) MarshalJSON

func (t Toggle) MarshalJSON() ([]byte, error)

func (Toggle) Value

func (t Toggle) Value() bool

func (Toggle) WithTooltip

func (t Toggle) WithTooltip(tooltip string) Toggle

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL