field

package
v0.11.6 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrValueNotInAllowedSet = errors.New("value not in allowed set")

Functions

func NotEmpty

func NotEmpty(value string) error

Types

type ErrValueNotAccepted

type ErrValueNotAccepted struct {
	Value  string
	Reason error
}

func (ErrValueNotAccepted) Error

func (e ErrValueNotAccepted) Error() string

type Field

type Field interface {
	ID() string
	View() string
	IsDone() bool
	Value() string

	SetBlur() Field
	SetFocus() (Field, tea.Cmd)
	Update(tea.Msg) (Field, tea.Cmd)
	UpdateRequest(request advisory.Request) advisory.Request
	SubmitValue() (Field, error)
}

type ListField

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

func NewListField

func NewListField(cfg ListFieldConfiguration) ListField

func (ListField) ID added in v0.3.0

func (f ListField) ID() string

func (ListField) IsDone

func (f ListField) IsDone() bool

func (ListField) SetBlur

func (f ListField) SetBlur() Field

func (ListField) SetFocus

func (f ListField) SetFocus() (Field, tea.Cmd)

func (ListField) SubmitValue

func (f ListField) SubmitValue() (Field, error)

func (ListField) Update

func (f ListField) Update(msg tea.Msg) (Field, tea.Cmd)

func (ListField) UpdateRequest

func (f ListField) UpdateRequest(req advisory.Request) advisory.Request

func (ListField) Value

func (f ListField) Value() string

func (ListField) View

func (f ListField) View() string

type ListFieldConfiguration

type ListFieldConfiguration struct {
	// ID is a unique identifier for the field.
	ID string

	Prompt         string
	Options        []string
	RequestUpdater func(value string, req advisory.Request) advisory.Request
}

type TextField

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

func NewTextField

func NewTextField(cfg TextFieldConfiguration) TextField

func (TextField) ID added in v0.3.0

func (f TextField) ID() string

func (TextField) IsDone

func (f TextField) IsDone() bool

func (TextField) SetBlur

func (f TextField) SetBlur() Field

func (TextField) SetFocus

func (f TextField) SetFocus() (Field, tea.Cmd)

func (TextField) SubmitValue

func (f TextField) SubmitValue() (Field, error)

func (TextField) Update

func (f TextField) Update(msg tea.Msg) (Field, tea.Cmd)

func (TextField) UpdateRequest

func (f TextField) UpdateRequest(req advisory.Request) advisory.Request

func (TextField) Value

func (f TextField) Value() string

func (TextField) View

func (f TextField) View() string

type TextFieldConfiguration

type TextFieldConfiguration struct {
	// ID is a unique identifier for the field.
	ID string

	// Prompt is the text shown before the input field. (E.g. "Name: ")
	Prompt string

	// RequestUpdater is a function that updates the advisory request with the
	// current field value.
	RequestUpdater func(value string, req advisory.Request) advisory.Request

	// AllowedValues is a list of values that are allowed to be entered and are used
	// as suggestions when the user starts typing.
	AllowedValues []string

	// DefaultSuggestion is the value that is shown as a suggestion when the user
	// hasn't entered anything.
	DefaultSuggestion string

	// EmptyValueHelpMsg is the help message shown when the user hasn't entered
	// anything and there are no suggestions.
	EmptyValueHelpMsg string

	// NoMatchHelpMsg is the help message shown when the user has entered something
	// but there are no matching suggestions.
	NoMatchHelpMsg string

	// ValidationRules is a list of validation rules that are run when the user
	// submits the field. All rules must pass for the field to be valid.
	ValidationRules []TextValidationRule
}

type TextValidationRule

type TextValidationRule func(string) error

Jump to

Keyboard shortcuts

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