form

package
v0.31.1 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dialog

type Dialog struct {
	Title string
	// contains filtered or unexported fields
}

Dialog is a form container that manages focus cycling, submission, and cancellation across a set of form fields.

func NewDialog

func NewDialog(title string, fields []Field, variables []string) *Dialog

NewDialog creates a form dialog with the given fields and variable names. The first field is focused automatically.

func (*Dialog) Cancelled

func (d *Dialog) Cancelled() bool

Cancelled returns whether the form was cancelled.

func (*Dialog) FormValues

func (d *Dialog) FormValues() map[string]any

FormValues returns a map of variable names to field values.

func (*Dialog) Submitted

func (d *Dialog) Submitted() bool

Submitted returns whether the form was submitted.

func (*Dialog) Update

func (d *Dialog) Update(msg tea.Msg) (*Dialog, tea.Cmd)

Update handles key input for the dialog, managing focus cycling and submit/cancel.

func (*Dialog) View

func (d *Dialog) View() string

View renders all fields vertically with spacing and help text.

type Field

type Field interface {
	Update(msg tea.Msg) (Field, tea.Cmd)
	View() string
	Focus() tea.Cmd
	Blur()
	Focused() bool
	Value() any    // string for text/textarea/select, []string for multi-select, domain types for presets
	Label() string // Display label for the field
}

Field is the interface implemented by all form field types.

type MultiSelectField

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

MultiSelectField is a multi-select form field with checkbox toggles.

func NewMultiSelectFormField

func NewMultiSelectFormField(label string, options []string) *MultiSelectField

NewMultiSelectFormField creates a multi-select field from static options.

func (*MultiSelectField) Blur

func (f *MultiSelectField) Blur()

func (*MultiSelectField) Focus

func (f *MultiSelectField) Focus() tea.Cmd

func (*MultiSelectField) Focused

func (f *MultiSelectField) Focused() bool

func (*MultiSelectField) IsFiltering

func (f *MultiSelectField) IsFiltering() bool

IsFiltering returns whether the list is currently filtering.

func (*MultiSelectField) Label

func (f *MultiSelectField) Label() string

func (*MultiSelectField) SelectedIndices

func (f *MultiSelectField) SelectedIndices() []int

SelectedIndices returns the indices of checked items.

func (*MultiSelectField) Update

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

func (*MultiSelectField) Value

func (f *MultiSelectField) Value() any

Value returns the selected options as []string.

func (*MultiSelectField) View

func (f *MultiSelectField) View() string

type ProjectSelectorField

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

ProjectSelectorField is a preset form field for selecting projects/repositories. It composes SelectFormField (single) or MultiSelectField (multi) based on the multi flag, delegating all Field methods except Value().

func NewProjectSelectorField

func NewProjectSelectorField(label string, repos []Repo, multi bool) *ProjectSelectorField

NewProjectSelectorField creates a project selector preset field. When multi is true, it uses MultiSelectField; otherwise SelectFormField.

func (*ProjectSelectorField) Blur

func (f *ProjectSelectorField) Blur()

func (*ProjectSelectorField) Focus

func (f *ProjectSelectorField) Focus() tea.Cmd

func (*ProjectSelectorField) Focused

func (f *ProjectSelectorField) Focused() bool

func (*ProjectSelectorField) Label

func (f *ProjectSelectorField) Label() string

func (*ProjectSelectorField) Update

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

func (*ProjectSelectorField) Value

func (f *ProjectSelectorField) Value() any

Value returns Repo for single-select or []Repo for multi-select.

func (*ProjectSelectorField) View

func (f *ProjectSelectorField) View() string

type Repo

type Repo struct {
	Name   string
	Path   string
	Remote string
}

Repo represents a project/repository for the ProjectSelector preset. This is a form-package type to avoid import cycles with the tui package.

type SelectFormField

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

SelectFormField is a single-select form field wrapping list.Model.

func NewSelectFormField

func NewSelectFormField(label string, options []string, defaultVal string) *SelectFormField

NewSelectFormField creates a single-select field from static options. defaultVal pre-selects the matching option if found.

func (*SelectFormField) Blur

func (f *SelectFormField) Blur()

func (*SelectFormField) Focus

func (f *SelectFormField) Focus() tea.Cmd

func (*SelectFormField) Focused

func (f *SelectFormField) Focused() bool

func (*SelectFormField) IsFiltering

func (f *SelectFormField) IsFiltering() bool

IsFiltering returns whether the list is currently filtering.

func (*SelectFormField) Label

func (f *SelectFormField) Label() string

func (*SelectFormField) Update

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

func (*SelectFormField) Value

func (f *SelectFormField) Value() any

func (*SelectFormField) View

func (f *SelectFormField) View() string

type SessionSelectorField

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

SessionSelectorField is a preset form field for selecting sessions. It composes SelectFormField (single) or MultiSelectField (multi) based on the multi flag, delegating all Field methods except Value().

func NewSessionSelectorField

func NewSessionSelectorField(label string, sessions []session.Session, multi bool) *SessionSelectorField

NewSessionSelectorField creates a session selector preset field. When multi is true, it uses MultiSelectField; otherwise SelectFormField. Labels are formatted as "repo/session-name" when sessions span multiple remotes.

func (*SessionSelectorField) Blur

func (f *SessionSelectorField) Blur()

func (*SessionSelectorField) Focus

func (f *SessionSelectorField) Focus() tea.Cmd

func (*SessionSelectorField) Focused

func (f *SessionSelectorField) Focused() bool

func (*SessionSelectorField) Label

func (f *SessionSelectorField) Label() string

func (*SessionSelectorField) Update

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

func (*SessionSelectorField) Value

func (f *SessionSelectorField) Value() any

Value returns session.Session for single-select or []session.Session for multi-select.

func (*SessionSelectorField) View

func (f *SessionSelectorField) View() string

type TextAreaField

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

TextAreaField is a multi-line text input form field.

func NewTextAreaField

func NewTextAreaField(label, placeholder, defaultVal string) *TextAreaField

NewTextAreaField creates a new multi-line text input field.

func (*TextAreaField) Blur

func (f *TextAreaField) Blur()

func (*TextAreaField) Focus

func (f *TextAreaField) Focus() tea.Cmd

func (*TextAreaField) Focused

func (f *TextAreaField) Focused() bool

func (*TextAreaField) Label

func (f *TextAreaField) Label() string

func (*TextAreaField) Update

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

func (*TextAreaField) Value

func (f *TextAreaField) Value() any

func (*TextAreaField) View

func (f *TextAreaField) View() string

type TextField

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

TextField is a single-line text input form field.

func NewTextField

func NewTextField(label, placeholder, defaultVal string) *TextField

NewTextField creates a new single-line text input field.

func (*TextField) Blur

func (f *TextField) Blur()

func (*TextField) Focus

func (f *TextField) Focus() tea.Cmd

func (*TextField) Focused

func (f *TextField) Focused() bool

func (*TextField) Label

func (f *TextField) Label() string

func (*TextField) Update

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

func (*TextField) Value

func (f *TextField) Value() any

func (*TextField) View

func (f *TextField) View() string

Jump to

Keyboard shortcuts

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