modal

package
v0.0.0-...-11db399 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2025 License: MIT Imports: 3 Imported by: 0

README

Modal

Modals are simply a dimension to a world in which components can return values without any setters, as simple as


name := c.modal.Show(&NameSelection{})

// or

task := c.modal.ShowAsync(&NameSelection{})
// Compute something
name := task.Result()

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get[T any](c *Controller, modal ModalComponent[T]) T

Types

type Controller

type Controller struct {
	reactea.BasicComponent
	// contains filtered or unexported fields
}

func NewController

func NewController(initFunc func(*Controller) func() tea.Cmd) *Controller

func (*Controller) Init

func (c *Controller) Init() tea.Cmd

func (*Controller) Render

func (c *Controller) Render(width, height int) string

func (*Controller) Run

func (c *Controller) Run(f func(*Controller) func() tea.Cmd) tea.Cmd

func (*Controller) Update

func (c *Controller) Update(msg tea.Msg) tea.Cmd
type Modal[T any] struct {
	// contains filtered or unexported fields
}

func (*Modal[T]) Error

func (modal *Modal[T]) Error(err error) tea.Cmd

func (*Modal[T]) Ok

func (modal *Modal[T]) Ok(result T) tea.Cmd

func (*Modal[T]) Return

func (modal *Modal[T]) Return(result ModalResult[T]) tea.Cmd

type ModalComponent

type ModalComponent[TReturn any] interface {
	reactea.Component

	Return(ModalResult[TReturn]) tea.Cmd
	// contains filtered or unexported methods
}

type ModalResult

type ModalResult[T any] struct {
	Return T
	Err    error
}

func Error

func Error[T any](err error) ModalResult[T]

func Ok

func Ok[T any](ret T) ModalResult[T]

func Show

func Show[T any](c *Controller, modal ModalComponent[T]) ModalResult[T]

func (*ModalResult[T]) Get

func (result *ModalResult[T]) Get() (T, error)

Allows for value, err := result.Get() syntactic sugar instead of manually destructuring fields

Jump to

Keyboard shortcuts

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