components

package
v0.260414.2000 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2026 License: MPL-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRequired = errors.New("this field is required")
)

Validation errors

Functions

func Confirm

func Confirm(prompt string, opts ...ConfirmOptions) (tui.Result[bool], error)

Confirm displays a yes/no prompt

func Input

func Input(prompt string, opts ...InputOptions) (tui.Result[string], error)

Input displays a text input prompt

func MultiSelect

func MultiSelect[T any](prompt string, items []MultiSelectItem[T], opts ...MultiSelectOptions) (tui.Result[[]T], error)

MultiSelect displays a multi-select list and returns the selected items

func RunWizard

func RunWizard[T any](title string, initialState T, steps []Step[T]) (T, error)

RunWizard is a convenience function to run a wizard

func Select

func Select[T any](prompt string, items []SelectItem[T], opts ...SelectOptions) (tui.Result[T], error)

Select displays a selection list and returns the selected item's value

func WithProgress

func WithProgress[T any](message string, fn func() (T, error)) (T, error)

WithProgress runs an async operation with a spinner

Types

type ConfirmModel

type ConfirmModel struct {

	// Result
	Result tui.Result[bool]
	// contains filtered or unexported fields
}

ConfirmModel is the bubbletea model for confirmation

func (*ConfirmModel) Init

func (m *ConfirmModel) Init() tea.Cmd

Init implements tea.Model

func (*ConfirmModel) Update

func (m *ConfirmModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update implements tea.Model

func (*ConfirmModel) View

func (m *ConfirmModel) View() string

View implements tea.Model

type ConfirmOptions

type ConfirmOptions struct {
	DefaultYes  bool   // Default to Yes (default: true)
	CanGoBack   bool   // Allow back navigation
	Description string // Optional description text
}

ConfirmOptions for confirmation dialog

type InputModel

type InputModel struct {

	// Result
	Result tui.Result[string]
	// contains filtered or unexported fields
}

InputModel is the bubbletea model for text input

func (*InputModel) Init

func (m *InputModel) Init() tea.Cmd

Init implements tea.Model

func (*InputModel) Update

func (m *InputModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update implements tea.Model

func (*InputModel) View

func (m *InputModel) View() string

View implements tea.Model

type InputOptions

type InputOptions struct {
	Placeholder string             // Placeholder text
	Required    bool               // Whether input is required
	Mask        bool               // Mask input (for passwords)
	Initial     string             // Initial value
	Validate    func(string) error // Validation function
	CharLimit   int                // Character limit (0 = unlimited)
	ShowHelp    bool               // Show help footer
	CanGoBack   bool               // Allow back navigation
}

InputOptions for text input customization

type MultiSelectItem

type MultiSelectItem[T any] struct {
	Title       string
	Description string
	Value       T
	Selected    bool
}

MultiSelectItem represents an item in a multi-select list

type MultiSelectModel

type MultiSelectModel[T any] struct {

	// Result
	Result tui.Result[[]T]
	// contains filtered or unexported fields
}

MultiSelectModel is the bubbletea model for multi-selection

func (*MultiSelectModel[T]) Init

func (m *MultiSelectModel[T]) Init() tea.Cmd

Init implements tea.Model

func (*MultiSelectModel[T]) Update

func (m *MultiSelectModel[T]) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update implements tea.Model

func (*MultiSelectModel[T]) View

func (m *MultiSelectModel[T]) View() string

View implements tea.Model

type MultiSelectOptions

type MultiSelectOptions struct {
	Initial   map[any]bool // Initial selection state (by Value)
	PageSize  int          // Number of items to show (default: 8)
	CanGoBack bool         // Allow back navigation (default: true)
}

MultiSelectOptions for customization

type ProgressModel

type ProgressModel[T any] struct {
	// contains filtered or unexported fields
}

ProgressModel shows a spinner while running an async operation

func (*ProgressModel[T]) Init

func (m *ProgressModel[T]) Init() tea.Cmd

Init implements tea.Model

func (*ProgressModel[T]) Update

func (m *ProgressModel[T]) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update implements tea.Model

func (*ProgressModel[T]) View

func (m *ProgressModel[T]) View() string

View implements tea.Model

type SelectItem

type SelectItem[T any] struct {
	Title       string
	Description string
	Value       T
}

SelectItem represents an item in a selection list

type SelectModel

type SelectModel[T any] struct {

	// Result
	Result tui.Result[T]
	// contains filtered or unexported fields
}

SelectModel is the bubbletea model for selection

func (*SelectModel[T]) Init

func (m *SelectModel[T]) Init() tea.Cmd

Init implements tea.Model

func (*SelectModel[T]) Update

func (m *SelectModel[T]) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update implements tea.Model

func (*SelectModel[T]) View

func (m *SelectModel[T]) View() string

View implements tea.Model

type SelectOptions

type SelectOptions struct {
	Initial    any    // Initial selection value
	PageSize   int    // Number of items to show (default: 8)
	ShowHelp   bool   // Show help footer (default: true)
	CanGoBack  bool   // Allow back navigation (default: true)
	BackLabel  string // Label for back action (default: "Back")
	EmptyLabel string // Label when no items
}

SelectOptions for customization

type Step

type Step[T any] struct {
	Name    string             // Step name shown in UI
	Skip    func(state T) bool // Return true to skip this step
	Execute func(ctx context.Context, state T) (T, StepResult, error)
}

Step defines a single step in the wizard

type StepResult

type StepResult int

StepResult indicates what the wizard should do after a step

const (
	StepContinue StepResult = iota // Move to next step
	StepBack                       // Go back to previous step
	StepDone                       // Wizard complete
	StepSkip                       // Skip this step
	StepCancel                     // User cancelled
)

type Wizard

type Wizard[T any] struct {
	// contains filtered or unexported fields
}

Wizard manages multi-step flows with back navigation

func NewWizard

func NewWizard[T any](initialState T, steps []Step[T], opts ...WizardOption[T]) *Wizard[T]

NewWizard creates a new wizard

func (*Wizard[T]) Run

func (w *Wizard[T]) Run() (T, error)

Run executes the wizard procedurally

type WizardOption

type WizardOption[T any] func(*Wizard[T])

WizardOption for customizing wizard behavior

func WithTitle

func WithTitle[T any](title string) WizardOption[T]

WithTitle sets the wizard title

Jump to

Keyboard shortcuts

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