form

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2025 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NextItemCmd = func() tea.Msg { return NextItemMsg{} }
View Source
var SubmitCmd = func() tea.Msg { return SubmitMsg{} }

Functions

func NewErrValidation

func NewErrValidation(err error) error

func WithOnAccept

func WithOnAccept[T comparable](onAccept func() tea.Cmd) inputOptions[T]

func WithRequired

func WithRequired[T comparable]() inputOptions[T]

func WithValidation

func WithValidation[T comparable](parser ParseValidation[T]) inputOptions[T]

func WithValidationFromType

func WithValidationFromType[T comparable, V CustomParseValidation[T]]() inputOptions[T]

Types

type CustomParseValidation

type CustomParseValidation[T any] interface {
	ParseValidationItem(string) (T, error)
}

type ErrValidation

type ErrValidation string

for parsing data in input values

func (ErrValidation) Error

func (err ErrValidation) Error() string

type Form

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

func NewForm

func NewForm(items [][]Item) Form

func (*Form) Cols

func (f *Form) Cols(col int) iter.Seq2[int, Item]

func (Form) GetLinkedValue

func (f Form) GetLinkedValue(labelName string) (any, bool)

func (Form) Init

func (f Form) Init() tea.Cmd

func (*Form) Rows

func (f *Form) Rows(row int) iter.Seq2[int, Item]

func (Form) Update

func (f Form) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (Form) View

func (f Form) View() string

type Item

type Item interface {
	ID() uint32

	View() string
	Update(tea.Msg) (Item, tea.Cmd)
	Blur() Item
	Focus() Item
	// contains filtered or unexported methods
}
func Link[T comparable](label *ItemLabel, input *ItemInput[T]) []Item

type ItemInput

type ItemInput[T comparable] struct {
	// contains filtered or unexported fields
}

Form item that for an input field

func Input

func Input[T comparable](opts ...inputOptions[T]) *ItemInput[T]

func (*ItemInput[T]) Blur

func (item *ItemInput[T]) Blur() Item

func (*ItemInput[T]) Focus

func (item *ItemInput[T]) Focus() Item

func (*ItemInput[T]) ID

func (f *ItemInput[T]) ID() uint32

func (*ItemInput[T]) Set

func (item *ItemInput[T]) Set(v T, t string)

func (*ItemInput[T]) SetText

func (item *ItemInput[T]) SetText(v string)

func (*ItemInput[T]) SetValue

func (item *ItemInput[T]) SetValue(v T)

func (*ItemInput[T]) Update

func (f *ItemInput[T]) Update(msg tea.Msg) (Item, tea.Cmd)

func (*ItemInput[T]) Value

func (item *ItemInput[T]) Value() T

func (ItemInput[T]) View

func (f ItemInput[T]) View() string

type ItemLabel

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

Form item that represent a label

func Label

func Label(text string) *ItemLabel

func (*ItemLabel) Blur

func (item *ItemLabel) Blur() Item

func (*ItemLabel) Focus

func (item *ItemLabel) Focus() Item

func (*ItemLabel) ID

func (f *ItemLabel) ID() uint32

func (*ItemLabel) Update

func (f *ItemLabel) Update(msg tea.Msg) (Item, tea.Cmd)

func (*ItemLabel) View

func (f *ItemLabel) View() string

type NextItemMsg

type NextItemMsg struct{}

type ParseValidation

type ParseValidation[T any] func(string) (T, error)

type SubmitMsg

type SubmitMsg struct{}

Jump to

Keyboard shortcuts

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