components

package
v0.1.12 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// FadeIn smoothly fades in from 0 to 1 with quick response
	FadeIn = AnimationConfig{
		Duration:         200 * time.Millisecond,
		FPS:              60,
		AngularFrequency: 8.0,
		DampingRatio:     1.2,
		Loop:             false,
		Reverse:          false,
	}

	// FadeOut smoothly fades out from 1 to 0
	FadeOut = AnimationConfig{
		Duration:         150 * time.Millisecond,
		FPS:              60,
		AngularFrequency: 10.0,
		DampingRatio:     1.0,
		Loop:             false,
		Reverse:          false,
	}

	// SlideIn slides content in with smooth motion
	SlideIn = AnimationConfig{
		Duration:         250 * time.Millisecond,
		FPS:              60,
		AngularFrequency: 7.0,
		DampingRatio:     1.0,
		Loop:             false,
		Reverse:          false,
	}

	// SlideOut slides content out quickly
	SlideOut = AnimationConfig{
		Duration:         200 * time.Millisecond,
		FPS:              60,
		AngularFrequency: 8.0,
		DampingRatio:     1.0,
		Loop:             false,
		Reverse:          false,
	}

	// Spring creates a bouncy spring effect
	Spring = AnimationConfig{
		Duration:         400 * time.Millisecond,
		FPS:              60,
		AngularFrequency: 5.0,
		DampingRatio:     0.5,
		Loop:             false,
		Reverse:          false,
	}

	// Bounce creates a bouncing effect with multiple oscillations
	Bounce = AnimationConfig{
		Duration:         500 * time.Millisecond,
		FPS:              60,
		AngularFrequency: 6.0,
		DampingRatio:     0.3,
		Loop:             false,
		Reverse:          false,
	}

	// Smooth provides a smooth, subtle animation with no overshoot
	Smooth = AnimationConfig{
		Duration:         300 * time.Millisecond,
		FPS:              60,
		AngularFrequency: 6.0,
		DampingRatio:     1.5,
		Loop:             false,
		Reverse:          false,
	}

	// Spinner creates a continuous looping animation for spinners
	Spinner = AnimationConfig{
		Duration:         1000 * time.Millisecond,
		FPS:              60,
		AngularFrequency: 6.0,
		DampingRatio:     1.0,
		Loop:             true,
		Reverse:          false,
	}

	// Pulse creates a pulsing effect that reverses
	Pulse = AnimationConfig{
		Duration:         600 * time.Millisecond,
		FPS:              60,
		AngularFrequency: 5.0,
		DampingRatio:     1.0,
		Loop:             true,
		Reverse:          true,
	}

	// Snap creates a quick, snappy animation
	Snap = AnimationConfig{
		Duration:         100 * time.Millisecond,
		FPS:              60,
		AngularFrequency: 12.0,
		DampingRatio:     1.0,
		Loop:             false,
		Reverse:          false,
	}
)
View Source
var TransitionPresets = map[string]AnimationConfig{
	"fadeIn":   FadeIn,
	"fadeOut":  FadeOut,
	"slideIn":  SlideIn,
	"slideOut": SlideOut,
	"spring":   Spring,
	"bounce":   Bounce,
	"smooth":   Smooth,
	"spinner":  Spinner,
	"pulse":    Pulse,
	"snap":     Snap,
}

TransitionPresets provides easy access to all transition presets

Functions

func GetMousePosition

func GetMousePosition(msg tea.MouseMsg) (x, y int)

GetMousePosition extracts the X and Y coordinates from a tea.MouseMsg

func IsInBounds

func IsInBounds(mouseX, mouseY int, rect layout.Rectangle) bool

IsInBounds checks if the mouse position is within the specified rectangle

func IsInBoundsXY

func IsInBoundsXY(mouseX, mouseY, x, y, width, height int) bool

IsInBoundsXY is a convenience function for checking bounds with separate coordinates

func IsLeftClick

func IsLeftClick(msg tea.MouseMsg) bool

IsLeftClick checks if the message is a left mouse button press

func IsLeftRelease

func IsLeftRelease(msg tea.MouseMsg) bool

IsLeftRelease checks if the message is a left mouse button release

func IsMiddleClick

func IsMiddleClick(msg tea.MouseMsg) bool

IsMiddleClick checks if the message is a middle mouse button press

func IsMouseMotion

func IsMouseMotion(msg tea.MouseMsg) bool

IsMouseMotion checks if the message is a mouse motion event

func IsRightClick

func IsRightClick(msg tea.MouseMsg) bool

IsRightClick checks if the message is a right mouse button press

func IsScrollDown

func IsScrollDown(msg tea.MouseMsg) bool

IsScrollDown checks if the message is a scroll down event

func IsScrollUp

func IsScrollUp(msg tea.MouseMsg) bool

IsScrollUp checks if the message is a scroll up event

Types

type Animatable

type Animatable interface {
	Component

	// StartAnimation starts the animation
	StartAnimation() tea.Cmd

	// StopAnimation stops the animation
	StopAnimation()

	// IsAnimating returns true if the animation is running
	IsAnimating() bool

	// UpdateAnimation updates the animation state based on tick
	UpdateAnimation(tick int)
}

Animatable represents components that support animations. This is useful for loading indicators, transitions, and visual effects.

type AnimatedComponent

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

AnimatedComponent wraps any component with animation support

func BounceComponent

func BounceComponent(c Component) *AnimatedComponent

BounceComponent wraps a component with a bounce animation

func FadeInComponent

func FadeInComponent(c Component) *AnimatedComponent

FadeInComponent wraps a component with a fade-in animation

func FadeOutComponent

func FadeOutComponent(c Component) *AnimatedComponent

FadeOutComponent wraps a component with a fade-out animation

func NewAnimatedComponent

func NewAnimatedComponent(component Component, config AnimationConfig) *AnimatedComponent

NewAnimatedComponent creates a new animated component wrapper

func NewAnimatedComponentWithID

func NewAnimatedComponentWithID(id string, component Component, config AnimationConfig) *AnimatedComponent

NewAnimatedComponentWithID creates an animated component with a custom ID

func PulseComponent

func PulseComponent(c Component) *AnimatedComponent

PulseComponent wraps a component with a pulsing animation

func SlideInComponent

func SlideInComponent(c Component, from, to float64) *AnimatedComponent

SlideInComponent wraps a component with a slide-in animation from: starting position (e.g., -100 for off-screen left) to: ending position (e.g., 0 for on-screen)

func SlideOutComponent

func SlideOutComponent(c Component, from, to float64) *AnimatedComponent

SlideOutComponent wraps a component with a slide-out animation

func SmoothComponent

func SmoothComponent(c Component) *AnimatedComponent

SmoothComponent wraps a component with a smooth animation

func SnapComponent

func SnapComponent(c Component) *AnimatedComponent

SnapComponent wraps a component with a quick snap animation

func SpinnerComponent

func SpinnerComponent(c Component) *AnimatedComponent

SpinnerComponent wraps a component with a continuous spinner animation This is ideal for loading indicators and progress spinners

func SpringComponent

func SpringComponent(c Component) *AnimatedComponent

SpringComponent wraps a component with a spring animation

func (*AnimatedComponent) Component

func (a *AnimatedComponent) Component() Component

Component returns the wrapped component (useful for accessing specific interfaces)

func (*AnimatedComponent) GetID

func (a *AnimatedComponent) GetID() string

GetID returns the animation's unique identifier

func (*AnimatedComponent) GetValue

func (a *AnimatedComponent) GetValue() float64

GetValue returns the current animated value

func (*AnimatedComponent) Init

func (a *AnimatedComponent) Init() tea.Cmd

Init initializes both the animation and wrapped component

func (*AnimatedComponent) IsAnimating

func (a *AnimatedComponent) IsAnimating() bool

IsAnimating returns whether the animation is currently running

func (*AnimatedComponent) Progress

func (a *AnimatedComponent) Progress() float64

Progress returns the animation progress as a percentage (0.0 to 1.0)

func (*AnimatedComponent) Reset

func (a *AnimatedComponent) Reset()

Reset resets the animation to its initial state

func (*AnimatedComponent) SetValue

func (a *AnimatedComponent) SetValue(value float64)

SetValue directly sets the current value (bypasses animation)

func (*AnimatedComponent) StartAnimation

func (a *AnimatedComponent) StartAnimation(from, to float64) tea.Cmd

StartAnimation begins animating from the current value to the target

func (*AnimatedComponent) StopAnimation

func (a *AnimatedComponent) StopAnimation() tea.Cmd

StopAnimation stops the animation

func (*AnimatedComponent) Update

func (a *AnimatedComponent) Update(msg tea.Msg) (Component, tea.Cmd)

Update handles animation ticks and updates the wrapped component

func (*AnimatedComponent) View

func (a *AnimatedComponent) View() string

View renders the wrapped component

type AnimatedProgress

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

AnimatedProgress demonstrates a smooth progress bar animation

func NewAnimatedProgress

func NewAnimatedProgress(width int, label string) *AnimatedProgress

NewAnimatedProgress creates a new animated progress bar

func (*AnimatedProgress) Init

func (p *AnimatedProgress) Init() tea.Cmd

Init initializes the progress bar

func (*AnimatedProgress) SetProgress

func (p *AnimatedProgress) SetProgress(target float64) tea.Cmd

SetProgress animates the progress bar to the target percentage (0.0 to 1.0)

func (*AnimatedProgress) Update

func (p *AnimatedProgress) Update(msg tea.Msg) (Component, tea.Cmd)

Update handles animation updates

func (*AnimatedProgress) View

func (p *AnimatedProgress) View() string

View renders the animated progress bar

type AnimatedPulse

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

AnimatedPulse demonstrates a pulsing animation effect

func NewAnimatedPulse

func NewAnimatedPulse(text string, color lipgloss.Color) *AnimatedPulse

NewAnimatedPulse creates a new pulsing text animation

func (*AnimatedPulse) Init

func (p *AnimatedPulse) Init() tea.Cmd

Init initializes the pulse animation

func (*AnimatedPulse) Start

func (p *AnimatedPulse) Start() tea.Cmd

Start begins the pulse animation

func (*AnimatedPulse) Update

func (p *AnimatedPulse) Update(msg tea.Msg) (Component, tea.Cmd)

Update handles animation updates

func (*AnimatedPulse) View

func (p *AnimatedPulse) View() string

View renders the pulsing text

type AnimatedRotation

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

AnimatedRotation demonstrates a rotating animation (for spinners)

func NewAnimatedRotation

func NewAnimatedRotation(radius float64, char string) *AnimatedRotation

NewAnimatedRotation creates a new rotating animation

func (*AnimatedRotation) Init

func (r *AnimatedRotation) Init() tea.Cmd

Init initializes the rotation animation

func (*AnimatedRotation) Start

func (r *AnimatedRotation) Start() tea.Cmd

Start begins the rotation animation

func (*AnimatedRotation) Update

func (r *AnimatedRotation) Update(msg tea.Msg) (Component, tea.Cmd)

Update handles animation updates

func (*AnimatedRotation) View

func (r *AnimatedRotation) View() string

View renders the rotating element

type AnimatedSlide

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

AnimatedSlide demonstrates a sliding animation

func NewAnimatedSlide

func NewAnimatedSlide(content string, width int) *AnimatedSlide

NewAnimatedSlide creates a new sliding content animation

func (*AnimatedSlide) Init

func (s *AnimatedSlide) Init() tea.Cmd

Init initializes the slide animation

func (*AnimatedSlide) SlideIn

func (s *AnimatedSlide) SlideIn() tea.Cmd

SlideIn animates the content sliding in from the left

func (*AnimatedSlide) SlideOut

func (s *AnimatedSlide) SlideOut() tea.Cmd

SlideOut animates the content sliding out to the right

func (*AnimatedSlide) Update

func (s *AnimatedSlide) Update(msg tea.Msg) (Component, tea.Cmd)

Update handles animation updates

func (*AnimatedSlide) View

func (s *AnimatedSlide) View() string

View renders the sliding content

type AnimatedSpinner

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

AnimatedSpinner demonstrates using AnimatedComponent for a smooth rotating spinner

func NewAnimatedSpinner

func NewAnimatedSpinner(message string) *AnimatedSpinner

NewAnimatedSpinner creates a new animated spinner component

func (*AnimatedSpinner) Init

func (s *AnimatedSpinner) Init() tea.Cmd

Init initializes the animated spinner

func (*AnimatedSpinner) Start

func (s *AnimatedSpinner) Start() tea.Cmd

Start begins the spinner animation

func (*AnimatedSpinner) Stop

func (s *AnimatedSpinner) Stop() tea.Cmd

Stop stops the spinner animation

func (*AnimatedSpinner) Update

func (s *AnimatedSpinner) Update(msg tea.Msg) (Component, tea.Cmd)

Update handles animation updates

func (*AnimatedSpinner) View

func (s *AnimatedSpinner) View() string

View renders the spinner with smooth animation

type AnimationCompleteMsg

type AnimationCompleteMsg struct {
	ID    string  // Animation ID
	Value float64 // Final value
}

AnimationCompleteMsg is sent when an animation completes

type AnimationConfig

type AnimationConfig struct {
	Duration         time.Duration // Animation duration (used to calculate spring params)
	FPS              int           // Frames per second (default: 60)
	AngularFrequency float64       // Spring angular frequency (default: 6.0)
	DampingRatio     float64       // Spring damping ratio (default: 1.0 for critical damping)
	Loop             bool          // Repeat animation when complete
	Reverse          bool          // Reverse direction on loop
}

AnimationConfig configures animation behavior

func CustomTransition

func CustomTransition(duration time.Duration, fps int, angularFreq, dampingRatio float64, loop, reverse bool) AnimationConfig

CustomTransition creates a custom animation configuration

func DefaultAnimationConfig

func DefaultAnimationConfig() AnimationConfig

DefaultAnimationConfig returns sensible defaults for animations

func GetTransitionPreset

func GetTransitionPreset(name string) (AnimationConfig, bool)

GetTransitionPreset returns a preset animation configuration by name

func MediumTransition

func MediumTransition() AnimationConfig

MediumTransition creates a medium-speed animation (300ms)

func QuickTransition

func QuickTransition() AnimationConfig

QuickTransition creates a fast animation (100ms)

func RotationAnimation

func RotationAnimation(duration time.Duration, loop bool) AnimationConfig

RotationAnimation creates a smooth rotation animation for spinners

func SlowTransition

func SlowTransition() AnimationConfig

SlowTransition creates a slow animation (500ms)

type AnimationTickMsg

type AnimationTickMsg struct {
	ID    string  // Animation ID
	Value float64 // Current interpolated value
	Time  time.Time
}

AnimationTickMsg is sent on each animation frame update

type ClickDetector

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

ClickDetector detects click events within a bounds

func NewClickDetector

func NewClickDetector(bounds layout.Rectangle, onClick, onDoubleClick MouseEventHandler) *ClickDetector

NewClickDetector creates a new click detector

func (*ClickDetector) HandleClick

func (cd *ClickDetector) HandleClick(msg tea.MouseMsg) tea.Cmd

HandleClick processes click events

func (*ClickDetector) SetBounds

func (cd *ClickDetector) SetBounds(bounds layout.Rectangle)

SetBounds updates the click detection bounds

type Cloneable

type Cloneable interface {
	Component

	// Clone creates a deep copy of the component
	Clone() Component
}

Cloneable represents components that can be cloned. This is useful for creating copies of components without affecting the original.

type ColumnAlignment

type ColumnAlignment int

ColumnAlignment defines how columns are vertically aligned

const (
	// ColumnAlignTop aligns columns to the top
	ColumnAlignTop ColumnAlignment = iota
	// ColumnAlignCenter centers columns vertically
	ColumnAlignCenter
	// ColumnAlignBottom aligns columns to the bottom
	ColumnAlignBottom
	// ColumnAlignStretch stretches columns to fill available height
	ColumnAlignStretch
)

func (ColumnAlignment) String

func (ca ColumnAlignment) String() string

String returns the string representation of the alignment

type Component

type Component interface {
	// Init initializes the component and returns an initial command
	Init() tea.Cmd

	// Update handles messages and updates component state
	Update(msg tea.Msg) (Component, tea.Cmd)

	// View renders the component as a string
	View() string
}

Component is the base interface that all TUI components must implement. It follows the Bubble Tea pattern of Init, Update, and View methods.

type ComponentAdapter

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

ComponentAdapter provides a base implementation for components. It can be embedded in concrete component implementations to reduce boilerplate.

func NewComponentAdapter

func NewComponentAdapter() *ComponentAdapter

NewComponentAdapter creates a new component adapter.

func (*ComponentAdapter) Blur

func (c *ComponentAdapter) Blur()

Blur implements Focusable.

func (*ComponentAdapter) Focus

func (c *ComponentAdapter) Focus() tea.Cmd

Focus implements Focusable.

func (*ComponentAdapter) Focused

func (c *ComponentAdapter) Focused() bool

Focused implements Focusable.

func (*ComponentAdapter) GetLifecycleState

func (c *ComponentAdapter) GetLifecycleState() LifecycleState

GetLifecycleState implements Lifecycle.

func (*ComponentAdapter) GetSize

func (c *ComponentAdapter) GetSize() (width, height int)

GetSize implements Sizeable.

func (*ComponentAdapter) Hide

func (c *ComponentAdapter) Hide()

Hide implements Stateful.

func (*ComponentAdapter) Init

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

Init initializes the component adapter.

func (*ComponentAdapter) IsInitialized

func (c *ComponentAdapter) IsInitialized() bool

IsInitialized implements Lifecycle.

func (*ComponentAdapter) IsMounted

func (c *ComponentAdapter) IsMounted() bool

IsMounted implements Lifecycle.

func (*ComponentAdapter) IsVisible

func (c *ComponentAdapter) IsVisible() bool

IsVisible implements Stateful.

func (*ComponentAdapter) OnAfterUpdate

func (c *ComponentAdapter) OnAfterUpdate(msg tea.Msg) tea.Cmd

OnAfterUpdate implements Lifecycle.

func (*ComponentAdapter) OnBeforeUpdate

func (c *ComponentAdapter) OnBeforeUpdate(msg tea.Msg) bool

OnBeforeUpdate implements Lifecycle.

func (*ComponentAdapter) OnBlur

func (c *ComponentAdapter) OnBlur() tea.Cmd

OnBlur implements Lifecycle.

func (*ComponentAdapter) OnFocus

func (c *ComponentAdapter) OnFocus() tea.Cmd

OnFocus implements Lifecycle.

func (*ComponentAdapter) OnHide

func (c *ComponentAdapter) OnHide() tea.Cmd

OnHide implements Lifecycle.

func (*ComponentAdapter) OnInit

func (c *ComponentAdapter) OnInit() tea.Cmd

OnInit implements Lifecycle.

func (*ComponentAdapter) OnMount

func (c *ComponentAdapter) OnMount() tea.Cmd

OnMount implements Lifecycle.

func (*ComponentAdapter) OnResize

func (c *ComponentAdapter) OnResize(width, height int) tea.Cmd

OnResize implements Lifecycle.

func (*ComponentAdapter) OnShow

func (c *ComponentAdapter) OnShow() tea.Cmd

OnShow implements Lifecycle.

func (*ComponentAdapter) OnUnmount

func (c *ComponentAdapter) OnUnmount() tea.Cmd

OnUnmount implements Lifecycle.

func (*ComponentAdapter) SetSize

func (c *ComponentAdapter) SetSize(width, height int)

SetSize implements Sizeable.

func (*ComponentAdapter) Show

func (c *ComponentAdapter) Show()

Show implements Stateful.

func (*ComponentAdapter) Toggle

func (c *ComponentAdapter) Toggle()

Toggle implements Stateful.

func (*ComponentAdapter) Update

func (c *ComponentAdapter) Update(msg tea.Msg) (Component, tea.Cmd)

Update handles messages (default implementation).

func (*ComponentAdapter) View

func (c *ComponentAdapter) View() string

View renders the component (default implementation).

type Configurable

type Configurable interface {
	Component

	// SetConfig applies configuration to the component
	SetConfig(config interface{}) error

	// GetConfig returns the current configuration
	GetConfig() interface{}
}

Configurable represents components with configuration options. This allows components to be customized after initialization.

type ConfirmationPopup

type ConfirmationPopup interface {
	PopupComponent

	// GetMessage returns the confirmation message
	GetMessage() string

	// SetMessage sets the confirmation message
	SetMessage(message string)

	// GetButtons returns the button labels
	GetButtons() []string

	// SetButtons sets the button labels
	SetButtons(buttons []string)

	// GetDefaultButton returns the index of the default button
	GetDefaultButton() int

	// SetDefaultButton sets the default button index
	SetDefaultButton(index int)

	// GetSelectedButton returns the index of the currently selected button
	GetSelectedButton() int

	// Confirm triggers the confirmation action
	Confirm() tea.Cmd

	// Cancel triggers the cancel action
	Cancel() tea.Cmd
}

ConfirmationPopup represents a popup that asks for user confirmation. This is useful for destructive actions and important decisions.

type Disposable

type Disposable interface {
	Component

	// Dispose cleans up component resources
	Dispose() error

	// IsDisposed returns true if the component has been disposed
	IsDisposed() bool
}

Disposable represents components that need cleanup when destroyed. This ensures proper resource management and prevents memory leaks.

type DragHandler

type DragHandler struct {
	IsActive    bool
	StartX      int
	StartY      int
	CurrentX    int
	CurrentY    int
	OnDragStart MouseEventHandler
	OnDrag      MouseEventHandler
	OnDragEnd   MouseEventHandler
}

DragHandler tracks drag operations

func NewDragHandler

func NewDragHandler(onStart, onDrag, onEnd MouseEventHandler) *DragHandler

NewDragHandler creates a new drag handler with the specified callbacks

func (*DragHandler) DragDelta

func (dh *DragHandler) DragDelta() (dx, dy int)

DragDelta returns the current drag delta from the start position

func (*DragHandler) HandleMouseMsg

func (dh *DragHandler) HandleMouseMsg(msg tea.MouseMsg) tea.Cmd

HandleMouseMsg processes mouse messages for drag operations

func (*DragHandler) Reset

func (dh *DragHandler) Reset()

Reset resets the drag handler state

type DraggableComponent

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

DraggableComponent wraps any component and makes it draggable with mouse and keyboard

func NewDraggable

func NewDraggable(component Component, x, y int) *DraggableComponent

NewDraggable creates a new draggable wrapper around a component

func (*DraggableComponent) Blur

func (d *DraggableComponent) Blur()

Blur removes keyboard focus

func (*DraggableComponent) DisableSnapToGrid

func (d *DraggableComponent) DisableSnapToGrid()

DisableSnapToGrid disables grid snapping

func (*DraggableComponent) EnableSnapToGrid

func (d *DraggableComponent) EnableSnapToGrid(size int)

EnableSnapToGrid enables snapping to a grid with the specified size

func (*DraggableComponent) EndDrag

func (d *DraggableComponent) EndDrag()

EndDrag ends the drag operation

func (*DraggableComponent) Focus

func (d *DraggableComponent) Focus() tea.Cmd

Focus gives keyboard focus to the component

func (*DraggableComponent) Focused

func (d *DraggableComponent) Focused() bool

Focused returns whether component has focus

func (*DraggableComponent) GetComponent

func (d *DraggableComponent) GetComponent() Component

GetComponent returns the wrapped component

func (*DraggableComponent) GetSize

func (d *DraggableComponent) GetSize() (width, height int)

GetSize returns the component size

func (*DraggableComponent) Init

func (d *DraggableComponent) Init() tea.Cmd

Init initializes the component

func (*DraggableComponent) IsDragging

func (d *DraggableComponent) IsDragging() bool

IsDragging returns whether currently dragging

func (*DraggableComponent) Position

func (d *DraggableComponent) Position() (x, y int)

Position returns the current position

func (*DraggableComponent) SetBorderStyle

func (d *DraggableComponent) SetBorderStyle(style lipgloss.Style)

SetBorderStyle sets the border style

func (*DraggableComponent) SetBounds

func (d *DraggableComponent) SetBounds(x, y, width, height int)

SetBounds sets the constraint boundaries for dragging

func (*DraggableComponent) SetComponent

func (d *DraggableComponent) SetComponent(component Component)

SetComponent sets the wrapped component

func (*DraggableComponent) SetDragHandle

func (d *DraggableComponent) SetDragHandle(x, y, width, height int)

SetDragHandle sets the area that can be used to drag (relative to component)

func (*DraggableComponent) SetDragStyle

func (d *DraggableComponent) SetDragStyle(style lipgloss.Style)

SetDragStyle sets the style used when dragging

func (*DraggableComponent) SetPosition

func (d *DraggableComponent) SetPosition(x, y int)

SetPosition sets the position (with constraints)

func (*DraggableComponent) SetSize

func (d *DraggableComponent) SetSize(width, height int)

SetSize sets the component size (needed for boundary checking)

func (*DraggableComponent) StartDrag

func (d *DraggableComponent) StartDrag(mouseX, mouseY int)

StartDrag initiates a drag operation

func (*DraggableComponent) Update

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

Update handles messages and updates state

func (*DraggableComponent) UpdateDrag

func (d *DraggableComponent) UpdateDrag(mouseX, mouseY int)

UpdateDrag updates the position during a drag operation

func (*DraggableComponent) View

func (d *DraggableComponent) View() string

View renders the component with positioning

type Eventable

type Eventable interface {
	Component

	// On registers an event handler for the specified event type
	On(eventType string, handler func(interface{}))

	// Off removes an event handler for the specified event type
	Off(eventType string)

	// Emit triggers an event with the specified type and data
	Emit(eventType string, data interface{})
}

Eventable represents components that can emit custom events. This enables pub-sub patterns and component communication.

type FilterablePopup

type FilterablePopup interface {
	PopupComponent

	// GetFilter returns the current filter text
	GetFilter() string

	// SetFilter sets the filter text and filters content
	SetFilter(filter string)

	// ClearFilter removes the filter and shows all content
	ClearFilter()

	// IsFiltered returns true if a filter is active
	IsFiltered() bool
}

FilterablePopup represents a popup with filterable content. This is useful for search dialogs and filtered lists.

type Focusable

type Focusable interface {
	Component

	// Focus gives keyboard focus to the component
	Focus() tea.Cmd

	// Blur removes keyboard focus from the component
	Blur()

	// Focused returns true if the component currently has focus
	Focused() bool
}

Focusable represents components that can receive keyboard focus. This is useful for input components, text areas, and interactive elements.

type HoverDetector

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

HoverDetector detects mouse hover over areas

func NewHoverDetector

func NewHoverDetector(bounds layout.Rectangle, onEnter, onLeave, onHover MouseEventHandler) *HoverDetector

NewHoverDetector creates a new hover detector

func (*HoverDetector) IsHovering

func (hd *HoverDetector) IsHovering() bool

IsHovering returns whether the mouse is currently hovering

func (*HoverDetector) SetBounds

func (hd *HoverDetector) SetBounds(bounds layout.Rectangle)

SetBounds updates the hover detection bounds

func (*HoverDetector) Update

func (hd *HoverDetector) Update(msg tea.MouseMsg) tea.Cmd

Update updates the hover state

type Initializable

type Initializable interface {
	Component

	// Initialize initializes the component.
	Initialize() tea.Cmd

	// IsInitialized returns true if the component has been initialized.
	IsInitialized() bool

	// GetInitError returns any error that occurred during initialization.
	GetInitError() error
}

Initializable represents components that need explicit initialization. This is useful for components with expensive setup operations.

type Lifecycle

type Lifecycle interface {
	Component

	// OnInit is called when the component is first initialized.
	// Use this for setting up initial state and configuration.
	OnInit() tea.Cmd

	// OnMount is called when the component is mounted to the DOM/UI tree.
	// Use this for operations that require the component to be rendered.
	OnMount() tea.Cmd

	// OnUnmount is called when the component is about to be removed.
	// Use this for cleanup operations like closing connections or timers.
	OnUnmount() tea.Cmd

	// OnBeforeUpdate is called before the component processes an update.
	// Return false to cancel the update.
	OnBeforeUpdate(msg tea.Msg) bool

	// OnAfterUpdate is called after the component has processed an update.
	// Use this for side effects that depend on the updated state.
	OnAfterUpdate(msg tea.Msg) tea.Cmd

	// OnShow is called when the component becomes visible.
	OnShow() tea.Cmd

	// OnHide is called when the component becomes hidden.
	OnHide() tea.Cmd

	// OnResize is called when the component's size changes.
	OnResize(width, height int) tea.Cmd

	// OnFocus is called when the component receives focus.
	OnFocus() tea.Cmd

	// OnBlur is called when the component loses focus.
	OnBlur() tea.Cmd

	// GetLifecycleState returns the current lifecycle state.
	GetLifecycleState() LifecycleState

	// IsInitialized returns true if the component has been initialized.
	IsInitialized() bool

	// IsMounted returns true if the component is currently mounted.
	IsMounted() bool
}

Lifecycle represents the complete lifecycle of a component. Components implementing this interface can hook into various lifecycle events for initialization, mounting, updating, and cleanup operations.

type LifecycleEvent

type LifecycleEvent struct {
	Type      LifecycleEventType
	Component string
	Timestamp int64
	Data      interface{}
}

LifecycleEvent represents an event in a component's lifecycle.

type LifecycleEventBus

type LifecycleEventBus interface {
	// Subscribe adds an observer to receive lifecycle events.
	Subscribe(observer LifecycleObserver)

	// Unsubscribe removes an observer from receiving lifecycle events.
	Unsubscribe(observer LifecycleObserver)

	// Publish publishes a lifecycle event to all observers.
	Publish(event LifecycleEvent)

	// GetObserverCount returns the number of subscribed observers.
	GetObserverCount() int

	// Clear removes all observers.
	Clear()
}

LifecycleEventBus manages lifecycle event distribution to observers.

type LifecycleEventType

type LifecycleEventType int

LifecycleEventType represents the type of lifecycle event.

const (
	// EventInit represents an initialization event
	EventInit LifecycleEventType = iota

	// EventMount represents a mount event
	EventMount

	// EventUnmount represents an unmount event
	EventUnmount

	// EventUpdate represents an update event
	EventUpdate

	// EventShow represents a show event
	EventShow

	// EventHide represents a hide event
	EventHide

	// EventResize represents a resize event
	EventResize

	// EventFocus represents a focus event
	EventFocus

	// EventBlur represents a blur event
	EventBlur

	// EventError represents an error event
	EventError

	// EventDispose represents a dispose event
	EventDispose
)

func (LifecycleEventType) String

func (e LifecycleEventType) String() string

String returns the string representation of a LifecycleEventType.

type LifecycleHooks

type LifecycleHooks struct {
	OnInitFunc         func() tea.Cmd
	OnMountFunc        func() tea.Cmd
	OnUnmountFunc      func() tea.Cmd
	OnBeforeUpdateFunc func(msg tea.Msg) bool
	OnAfterUpdateFunc  func(msg tea.Msg) tea.Cmd
	OnShowFunc         func() tea.Cmd
	OnHideFunc         func() tea.Cmd
	OnResizeFunc       func(width, height int) tea.Cmd
	OnFocusFunc        func() tea.Cmd
	OnBlurFunc         func() tea.Cmd
}

LifecycleHooks provides a way to register lifecycle hooks without implementing the full interface.

func (*LifecycleHooks) ExecuteAfterUpdate

func (h *LifecycleHooks) ExecuteAfterUpdate(msg tea.Msg) tea.Cmd

ExecuteAfterUpdate executes the OnAfterUpdate hook if defined.

func (*LifecycleHooks) ExecuteBeforeUpdate

func (h *LifecycleHooks) ExecuteBeforeUpdate(msg tea.Msg) bool

ExecuteBeforeUpdate executes the OnBeforeUpdate hook if defined. Returns true if the update should proceed, false to cancel.

func (*LifecycleHooks) ExecuteBlur

func (h *LifecycleHooks) ExecuteBlur() tea.Cmd

ExecuteBlur executes the OnBlur hook if defined.

func (*LifecycleHooks) ExecuteFocus

func (h *LifecycleHooks) ExecuteFocus() tea.Cmd

ExecuteFocus executes the OnFocus hook if defined.

func (*LifecycleHooks) ExecuteHide

func (h *LifecycleHooks) ExecuteHide() tea.Cmd

ExecuteHide executes the OnHide hook if defined.

func (*LifecycleHooks) ExecuteInit

func (h *LifecycleHooks) ExecuteInit() tea.Cmd

ExecuteInit executes the OnInit hook if defined.

func (*LifecycleHooks) ExecuteMount

func (h *LifecycleHooks) ExecuteMount() tea.Cmd

ExecuteMount executes the OnMount hook if defined.

func (*LifecycleHooks) ExecuteResize

func (h *LifecycleHooks) ExecuteResize(width, height int) tea.Cmd

ExecuteResize executes the OnResize hook if defined.

func (*LifecycleHooks) ExecuteShow

func (h *LifecycleHooks) ExecuteShow() tea.Cmd

ExecuteShow executes the OnShow hook if defined.

func (*LifecycleHooks) ExecuteUnmount

func (h *LifecycleHooks) ExecuteUnmount() tea.Cmd

ExecuteUnmount executes the OnUnmount hook if defined.

type LifecycleManager

type LifecycleManager interface {
	// RegisterComponent registers a component with the lifecycle manager.
	RegisterComponent(name string, component Lifecycle) error

	// UnregisterComponent unregisters a component from the lifecycle manager.
	UnregisterComponent(name string) error

	// GetComponent returns a registered component by name.
	GetComponent(name string) (Lifecycle, error)

	// InitializeAll initializes all registered components.
	InitializeAll() []tea.Cmd

	// MountAll mounts all registered components.
	MountAll() []tea.Cmd

	// UnmountAll unmounts all registered components.
	UnmountAll() []tea.Cmd

	// GetRegisteredComponents returns the names of all registered components.
	GetRegisteredComponents() []string

	// HasComponent returns true if a component with the given name is registered.
	HasComponent(name string) bool
}

LifecycleManager manages the lifecycle of multiple components.

type LifecycleObserver

type LifecycleObserver interface {
	// OnLifecycleEvent is called when a lifecycle event occurs.
	OnLifecycleEvent(event LifecycleEvent)
}

LifecycleObserver can observe lifecycle events from components.

type LifecycleState

type LifecycleState int

LifecycleState represents the current state in a component's lifecycle.

const (
	// StateUninitialized indicates the component has not been initialized
	StateUninitialized LifecycleState = iota

	// StateInitializing indicates the component is being initialized
	StateInitializing

	// StateInitialized indicates the component has been initialized
	StateInitialized

	// StateMounting indicates the component is being mounted
	StateMounting

	// StateMounted indicates the component is mounted and active
	StateMounted

	// StateUpdating indicates the component is processing an update
	StateUpdating

	// StateUnmounting indicates the component is being unmounted
	StateUnmounting

	// StateUnmounted indicates the component has been unmounted
	StateUnmounted

	// StateError indicates the component encountered an error
	StateError

	// StateDisposed indicates the component has been disposed
	StateDisposed
)

func (LifecycleState) String

func (s LifecycleState) String() string

String returns the string representation of a LifecycleState.

type Mountable

type Mountable interface {
	Component

	// Mount mounts the component.
	Mount() tea.Cmd

	// Unmount unmounts the component.
	Unmount() tea.Cmd

	// IsMounted returns true if the component is currently mounted.
	IsMounted() bool
}

Mountable represents components that can be mounted and unmounted. This is a simplified version of Lifecycle for components that only need mount/unmount hooks.

type MouseEventHandler

type MouseEventHandler func(msg tea.MouseMsg) tea.Cmd

MouseEventHandler is a function type for handling mouse events

type MouseState

type MouseState struct {
	X          int  // Current X position
	Y          int  // Current Y position
	Button     int  // Currently pressed button
	IsPressed  bool // Whether any button is pressed
	IsDragging bool // Whether a drag operation is in progress
	DragStartX int  // X position where drag started
	DragStartY int  // Y position where drag started
}

MouseState tracks the current mouse state for drag and click operations

func NewMouseState

func NewMouseState() *MouseState

NewMouseState creates a new mouse state tracker

func (*MouseState) DragDistance

func (ms *MouseState) DragDistance() (dx, dy int)

DragDistance returns the distance dragged from the start position

func (*MouseState) Update

func (ms *MouseState) Update(msg tea.MouseMsg)

Update updates the mouse state based on a tea.MouseMsg

type MultiColumnLayout

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

MultiColumnLayout displays content in multiple columns with flexible widths

func NewMultiColumnLayout

func NewMultiColumnLayout(columns []Component) *MultiColumnLayout

NewMultiColumnLayout creates a new multi-column layout

func (*MultiColumnLayout) AddColumn

func (mcl *MultiColumnLayout) AddColumn(component Component)

AddColumn adds a new column to the layout

func (*MultiColumnLayout) Blur

func (mcl *MultiColumnLayout) Blur()

Blur removes keyboard focus

func (*MultiColumnLayout) Focus

func (mcl *MultiColumnLayout) Focus() tea.Cmd

Focus gives keyboard focus to the component

func (*MultiColumnLayout) Focused

func (mcl *MultiColumnLayout) Focused() bool

Focused returns whether component has focus

func (*MultiColumnLayout) GetActiveColumn

func (mcl *MultiColumnLayout) GetActiveColumn() int

GetActiveColumn returns the index of the active column

func (*MultiColumnLayout) GetColumn

func (mcl *MultiColumnLayout) GetColumn(index int) Component

GetColumn returns the component at the specified index

func (*MultiColumnLayout) GetColumnCount

func (mcl *MultiColumnLayout) GetColumnCount() int

GetColumnCount returns the number of columns

func (*MultiColumnLayout) GetSize

func (mcl *MultiColumnLayout) GetSize() (width, height int)

GetSize returns the total size

func (*MultiColumnLayout) Init

func (mcl *MultiColumnLayout) Init() tea.Cmd

Init initializes the component

func (*MultiColumnLayout) RemoveColumn

func (mcl *MultiColumnLayout) RemoveColumn(index int)

RemoveColumn removes a column by index

func (*MultiColumnLayout) SetActiveColumn

func (mcl *MultiColumnLayout) SetActiveColumn(index int)

SetActiveColumn sets the active column for focus

func (*MultiColumnLayout) SetAlignment

func (mcl *MultiColumnLayout) SetAlignment(align ColumnAlignment)

SetAlignment sets the vertical alignment of columns

func (*MultiColumnLayout) SetColumnStyle

func (mcl *MultiColumnLayout) SetColumnStyle(index int, style lipgloss.Style)

SetColumnStyle sets the style for a specific column

func (*MultiColumnLayout) SetColumnWeight

func (mcl *MultiColumnLayout) SetColumnWeight(index, weight int)

SetColumnWeight sets the flex weight of a specific column

func (*MultiColumnLayout) SetColumnWeights

func (mcl *MultiColumnLayout) SetColumnWeights(weights []int)

SetColumnWeights sets flex weights for auto-sized columns

func (*MultiColumnLayout) SetColumnWidth

func (mcl *MultiColumnLayout) SetColumnWidth(index, width int)

SetColumnWidth sets the width of a specific column (0 = flex)

func (*MultiColumnLayout) SetColumnWidths

func (mcl *MultiColumnLayout) SetColumnWidths(widths []int)

SetColumnWidths sets fixed widths for columns (0 = flex)

func (*MultiColumnLayout) SetGap

func (mcl *MultiColumnLayout) SetGap(gap int)

SetGap sets the space between columns

func (*MultiColumnLayout) SetSize

func (mcl *MultiColumnLayout) SetSize(width, height int)

SetSize sets the total size of the layout

func (*MultiColumnLayout) Update

func (mcl *MultiColumnLayout) Update(msg tea.Msg) (Component, tea.Cmd)

Update handles messages and updates state

func (*MultiColumnLayout) View

func (mcl *MultiColumnLayout) View() string

View renders the multi-column layout

type NotificationPopup

type NotificationPopup interface {
	PopupComponent

	// GetMessage returns the notification message
	GetMessage() string

	// SetMessage sets the notification message
	SetMessage(message string)

	// GetType returns the notification type (info, success, warning, error)
	GetType() string

	// SetType sets the notification type
	SetType(notificationType string)

	// GetDuration returns how long the notification should be displayed
	GetDuration() int

	// SetDuration sets how long the notification should be displayed (in milliseconds)
	SetDuration(duration int)

	// AutoClose returns true if the notification closes automatically
	AutoClose() bool

	// SetAutoClose sets whether the notification closes automatically
	SetAutoClose(autoClose bool)
}

NotificationPopup represents a temporary notification popup. This is useful for status messages, alerts, and toast notifications.

type PopupAdapter

type PopupAdapter struct {
	*ComponentAdapter
	// contains filtered or unexported fields
}

PopupAdapter provides a base implementation for popup components.

func NewPopupAdapter

func NewPopupAdapter() *PopupAdapter

NewPopupAdapter creates a new popup adapter with default configuration.

func (*PopupAdapter) Close

func (p *PopupAdapter) Close() tea.Cmd

Close implements PopupComponent.

func (*PopupAdapter) GetConfig

func (p *PopupAdapter) GetConfig() PopupConfig

GetConfig returns the popup configuration.

func (*PopupAdapter) GetPopupDimensions

func (p *PopupAdapter) GetPopupDimensions() (width, height int)

GetPopupDimensions implements PopupComponent.

func (*PopupAdapter) GetPopupPosition

func (p *PopupAdapter) GetPopupPosition() (x, y, width, height int)

GetPopupPosition implements PopupComponent.

func (*PopupAdapter) GetZIndex

func (p *PopupAdapter) GetZIndex() int

GetZIndex implements PopupComponent.

func (*PopupAdapter) IsModal

func (p *PopupAdapter) IsModal() bool

IsModal implements PopupComponent.

func (*PopupAdapter) OnClose

func (p *PopupAdapter) OnClose(callback func())

OnClose implements PopupComponent.

func (*PopupAdapter) RenderPopup

func (p *PopupAdapter) RenderPopup() string

RenderPopup implements PopupComponent (default implementation).

func (*PopupAdapter) SetConfig

func (p *PopupAdapter) SetConfig(config PopupConfig)

SetConfig sets the popup configuration.

func (*PopupAdapter) SetModal

func (p *PopupAdapter) SetModal(modal bool)

SetModal implements PopupComponent.

func (*PopupAdapter) SetPopupDimensions

func (p *PopupAdapter) SetPopupDimensions(width, height int)

SetPopupDimensions implements PopupComponent.

func (*PopupAdapter) SetPopupPosition

func (p *PopupAdapter) SetPopupPosition(x, y int)

SetPopupPosition implements PopupComponent.

func (*PopupAdapter) SetZIndex

func (p *PopupAdapter) SetZIndex(zIndex int)

SetZIndex implements PopupComponent.

type PopupAlignment

type PopupAlignment int

PopupAlignment specifies how a popup should be aligned relative to a reference point.

const (
	// AlignTopLeft aligns popup's top-left corner to reference point
	AlignTopLeft PopupAlignment = iota

	// AlignTopCenter aligns popup's top edge center to reference point
	AlignTopCenter

	// AlignTopRight aligns popup's top-right corner to reference point
	AlignTopRight

	// AlignCenterLeft aligns popup's left edge center to reference point
	AlignCenterLeft

	// AlignCenter centers popup at reference point
	AlignCenter

	// AlignCenterRight aligns popup's right edge center to reference point
	AlignCenterRight

	// AlignBottomLeft aligns popup's bottom-left corner to reference point
	AlignBottomLeft

	// AlignBottomCenter aligns popup's bottom edge center to reference point
	AlignBottomCenter

	// AlignBottomRight aligns popup's bottom-right corner to reference point
	AlignBottomRight
)

type PopupComponent

type PopupComponent interface {
	Component
	Stateful
	Sizeable

	// RenderPopup renders the popup content without applying overlay positioning.
	// The returned string contains the popup's visual content.
	RenderPopup() string

	// GetPopupPosition returns the preferred position for the popup.
	// Returns (x, y, width, height) coordinates relative to the screen.
	GetPopupPosition() (x, y, width, height int)

	// SetPopupPosition sets the popup's position on the screen.
	SetPopupPosition(x, y int)

	// GetPopupDimensions returns the popup's dimensions.
	GetPopupDimensions() (width, height int)

	// SetPopupDimensions sets the popup's dimensions.
	SetPopupDimensions(width, height int)

	// IsModal returns true if the popup should block interaction with underlying content.
	IsModal() bool

	// SetModal sets whether the popup blocks underlying content interaction.
	SetModal(modal bool)

	// GetZIndex returns the popup's z-index for stacking order.
	// Higher values appear on top of lower values.
	GetZIndex() int

	// SetZIndex sets the popup's z-index.
	SetZIndex(zIndex int)

	// Close closes the popup and performs any necessary cleanup.
	Close() tea.Cmd

	// OnClose registers a callback to be called when the popup closes.
	OnClose(callback func())
}

PopupComponent represents a component that can be displayed as an overlay popup. Popups are temporary UI elements that appear on top of the main content. They typically handle user interactions like completions, hover info, and navigation.

type PopupConfig

type PopupConfig struct {
	Width           int
	Height          int
	X               int
	Y               int
	Alignment       PopupAlignment
	Style           PopupStyle
	Modal           bool
	ZIndex          int
	CloseOnEscape   bool
	CloseOnClickOut bool
	AnimateOpen     bool
	AnimateClose    bool
	FocusOnOpen     bool
}

PopupConfig contains configuration for popup behavior.

func DefaultPopupConfig

func DefaultPopupConfig() PopupConfig

DefaultPopupConfig returns a default popup configuration.

type PopupManager

type PopupManager interface {
	// AddPopup adds a popup to the manager
	AddPopup(popup PopupComponent) error

	// RemovePopup removes a popup from the manager
	RemovePopup(popup PopupComponent) error

	// GetActivePopup returns the currently active (topmost) popup
	GetActivePopup() PopupComponent

	// GetPopups returns all managed popups sorted by z-index
	GetPopups() []PopupComponent

	// CloseAll closes all managed popups
	CloseAll() tea.Cmd

	// HasPopups returns true if any popups are open
	HasPopups() bool

	// GetPopupCount returns the number of open popups
	GetPopupCount() int

	// BringToFront brings a popup to the front by increasing its z-index
	BringToFront(popup PopupComponent)

	// SendToBack sends a popup to the back by decreasing its z-index
	SendToBack(popup PopupComponent)
}

PopupManager manages multiple popups and their stacking order.

type PopupStyle

type PopupStyle struct {
	BorderStyle     string // "rounded", "double", "single", "none"
	BorderColor     string
	BackgroundColor string
	Shadow          bool
	Padding         int
	Margin          int
	Transparency    float64 // 0.0 (opaque) to 1.0 (transparent)
	BlurBackground  bool    // Whether to blur the background content
}

PopupStyle defines the visual style of a popup.

type Reloadable

type Reloadable interface {
	Component

	// Reload reloads the component's content.
	Reload() tea.Cmd

	// IsReloading returns true if the component is currently reloading.
	IsReloading() bool

	// GetLastReloadTime returns the timestamp of the last reload.
	GetLastReloadTime() int64
}

Reloadable represents components that can reload their content.

type Resettable

type Resettable interface {
	Component

	// Reset resets the component to its initial state.
	Reset() tea.Cmd

	// CanReset returns true if the component can be reset.
	CanReset() bool
}

Resettable represents components that can be reset to their initial state.

type ResizableComponent

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

ResizableComponent wraps a component and makes it resizable

func NewResizable

func NewResizable(component Component, width, height int) *ResizableComponent

NewResizable creates a new resizable wrapper around a component

func (*ResizableComponent) AddAllResizeHandles

func (r *ResizableComponent) AddAllResizeHandles()

AddAllResizeHandles adds resize handles at all 8 positions

func (*ResizableComponent) AddResizeHandle

func (r *ResizableComponent) AddResizeHandle(pos ResizePosition)

AddResizeHandle adds a resize handle at the specified position

func (*ResizableComponent) Blur

func (r *ResizableComponent) Blur()

Blur removes keyboard focus

func (*ResizableComponent) DisableAspectRatio

func (r *ResizableComponent) DisableAspectRatio()

DisableAspectRatio disables aspect ratio preservation

func (*ResizableComponent) EnableAspectRatio

func (r *ResizableComponent) EnableAspectRatio(ratio float64)

EnableAspectRatio enables aspect ratio preservation

func (*ResizableComponent) EndResize

func (r *ResizableComponent) EndResize()

EndResize ends the resize operation

func (*ResizableComponent) Focus

func (r *ResizableComponent) Focus() tea.Cmd

Focus gives keyboard focus to the component

func (*ResizableComponent) Focused

func (r *ResizableComponent) Focused() bool

Focused returns whether component has focus

func (*ResizableComponent) GetComponent

func (r *ResizableComponent) GetComponent() Component

GetComponent returns the wrapped component

func (*ResizableComponent) GetSize

func (r *ResizableComponent) GetSize() (width, height int)

GetSize returns the current size

func (*ResizableComponent) Init

func (r *ResizableComponent) Init() tea.Cmd

Init initializes the component

func (*ResizableComponent) IsResizing

func (r *ResizableComponent) IsResizing() bool

IsResizing returns whether currently resizing

func (*ResizableComponent) Position

func (r *ResizableComponent) Position() (x, y int)

Position returns the position

func (*ResizableComponent) SetBorderStyle

func (r *ResizableComponent) SetBorderStyle(style lipgloss.Style)

SetBorderStyle sets the border style

func (*ResizableComponent) SetComponent

func (r *ResizableComponent) SetComponent(component Component)

SetComponent sets the wrapped component

func (*ResizableComponent) SetMaxSize

func (r *ResizableComponent) SetMaxSize(width, height int)

SetMaxSize sets the maximum size constraints (0 = unlimited)

func (*ResizableComponent) SetMinSize

func (r *ResizableComponent) SetMinSize(width, height int)

SetMinSize sets the minimum size constraints

func (*ResizableComponent) SetPosition

func (r *ResizableComponent) SetPosition(x, y int)

SetPosition sets the position

func (*ResizableComponent) SetResizeStyle

func (r *ResizableComponent) SetResizeStyle(style lipgloss.Style)

SetResizeStyle sets the style used when resizing

func (*ResizableComponent) SetSize

func (r *ResizableComponent) SetSize(width, height int)

SetSize sets the size (with constraints)

func (*ResizableComponent) Size

func (r *ResizableComponent) Size() (width, height int)

Size returns the current size

func (*ResizableComponent) StartResize

func (r *ResizableComponent) StartResize(mouseX, mouseY int)

StartResize initiates a resize operation

func (*ResizableComponent) Update

func (r *ResizableComponent) Update(msg tea.Msg) (Component, tea.Cmd)

Update handles messages and updates state

func (*ResizableComponent) UpdateResize

func (r *ResizableComponent) UpdateResize(mouseX, mouseY int)

UpdateResize updates the size during a resize operation

func (*ResizableComponent) View

func (r *ResizableComponent) View() string

View renders the component with resize handles

type ResizeHandle

type ResizeHandle struct {
	Position ResizePosition
	X        int    // X position relative to component
	Y        int    // Y position relative to component
	Width    int    // Handle width
	Height   int    // Handle height
	Cursor   string // Character to display (e.g., "◢")
}

ResizeHandle defines a resize grab area

type ResizePosition

type ResizePosition int

ResizePosition defines the position of a resize handle

const (
	TopLeft ResizePosition = iota
	Top
	TopRight
	Right
	BottomRight
	Bottom
	BottomLeft
	Left
)

func (ResizePosition) String

func (rp ResizePosition) String() string

String returns the string representation of the resize position

type Scrollable

type Scrollable interface {
	Component

	// ScrollUp scrolls the content up by the specified number of lines
	ScrollUp(lines int)

	// ScrollDown scrolls the content down by the specified number of lines
	ScrollDown(lines int)

	// ScrollToTop scrolls to the top of the content
	ScrollToTop()

	// ScrollToBottom scrolls to the bottom of the content
	ScrollToBottom()

	// GetScrollPosition returns the current scroll position
	GetScrollPosition() int

	// SetScrollPosition sets the scroll position
	SetScrollPosition(position int)
}

Scrollable represents components that support scrolling. This is useful for large content areas like viewports and lists.

type ScrollablePopup

type ScrollablePopup interface {
	PopupComponent
	Scrollable

	// GetVisibleItemCount returns the number of items visible at once
	GetVisibleItemCount() int

	// SetVisibleItemCount sets the number of items visible at once
	SetVisibleItemCount(count int)

	// GetScrollOffset returns the current scroll offset
	GetScrollOffset() int

	// SetScrollOffset sets the current scroll offset
	SetScrollOffset(offset int)

	// CanScrollUp returns true if scrolling up is possible
	CanScrollUp() bool

	// CanScrollDown returns true if scrolling down is possible
	CanScrollDown() bool
}

ScrollablePopup represents a popup with scrollable content. This is useful for popups with long content that doesn't fit in the visible area.

type Selectable

type Selectable interface {
	Component

	// SelectNext moves selection to the next item
	SelectNext()

	// SelectPrevious moves selection to the previous item
	SelectPrevious()

	// GetSelectedIndex returns the index of the currently selected item
	GetSelectedIndex() int

	// SetSelectedIndex sets the selected item by index
	SetSelectedIndex(index int)

	// GetSelectedValue returns the value of the currently selected item
	GetSelectedValue() interface{}
}

Selectable represents components with selectable items. This is useful for lists, menus, and completion popups.

type SelectablePopup

type SelectablePopup interface {
	PopupComponent
	Selectable

	// GetItems returns all items in the popup
	GetItems() []interface{}

	// SetItems sets the items in the popup
	SetItems(items []interface{})

	// GetItemCount returns the number of items
	GetItemCount() int

	// ClearItems removes all items
	ClearItems()

	// FilterItems filters items based on a predicate
	FilterItems(filter func(item interface{}) bool)

	// SortItems sorts items using a comparator
	SortItems(less func(i, j interface{}) bool)
}

SelectablePopup represents a popup with selectable items. This is useful for completion popups, dropdown menus, and picker dialogs.

type Serializable

type Serializable interface {
	Component

	// Serialize converts the component state to a byte slice
	Serialize() ([]byte, error)

	// Deserialize restores component state from a byte slice
	Deserialize(data []byte) error
}

Serializable represents components that can be serialized. This is useful for state persistence and debugging.

type Sizeable

type Sizeable interface {
	Component

	// SetSize updates the component's dimensions
	SetSize(width, height int)

	// GetSize returns the current component dimensions
	GetSize() (width, height int)
}

Sizeable represents components that can be resized. Components implementing this interface can adapt to terminal size changes.

type SplitView

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

SplitView creates a resizable split pane layout

func NewSplitView

func NewSplitView(left, right Component, orientation layout.Orientation) *SplitView

NewSplitView creates a new split view with two panes

func (*SplitView) Blur

func (sv *SplitView) Blur()

Blur removes keyboard focus

func (*SplitView) DisableDivider

func (sv *SplitView) DisableDivider()

DisableDivider hides the divider

func (*SplitView) EnableDivider

func (sv *SplitView) EnableDivider()

EnableDivider shows the divider

func (*SplitView) EndDividerDrag

func (sv *SplitView) EndDividerDrag()

EndDividerDrag ends the drag operation

func (*SplitView) Focus

func (sv *SplitView) Focus() tea.Cmd

Focus gives keyboard focus to the component

func (*SplitView) Focused

func (sv *SplitView) Focused() bool

Focused returns whether component has focus

func (*SplitView) GetLeftPane

func (sv *SplitView) GetLeftPane() Component

GetLeftPane returns the left/top pane component

func (*SplitView) GetRightPane

func (sv *SplitView) GetRightPane() Component

GetRightPane returns the right/bottom pane component

func (*SplitView) GetSize

func (sv *SplitView) GetSize() (width, height int)

GetSize returns the total size

func (*SplitView) Init

func (sv *SplitView) Init() tea.Cmd

Init initializes the component

func (*SplitView) SetDividerSize

func (sv *SplitView) SetDividerSize(size int)

SetDividerSize sets the divider size (width for vertical, height for horizontal)

func (*SplitView) SetDividerStyle

func (sv *SplitView) SetDividerStyle(style lipgloss.Style)

SetDividerStyle sets the divider style

func (*SplitView) SetDragStyle

func (sv *SplitView) SetDragStyle(style lipgloss.Style)

SetDragStyle sets the style used when dragging

func (*SplitView) SetLeftPane

func (sv *SplitView) SetLeftPane(component Component)

SetLeftPane sets the left/top pane component

func (*SplitView) SetMinMaxRatio

func (sv *SplitView) SetMinMaxRatio(min, max float64)

SetMinMaxRatio sets the minimum and maximum split ratios

func (*SplitView) SetRightPane

func (sv *SplitView) SetRightPane(component Component)

SetRightPane sets the right/bottom pane component

func (*SplitView) SetSize

func (sv *SplitView) SetSize(width, height int)

SetSize sets the total size of the split view

func (*SplitView) SetSplitRatio

func (sv *SplitView) SetSplitRatio(ratio float64)

SetSplitRatio sets the split ratio (constrained by min/max)

func (*SplitView) StartDividerDrag

func (sv *SplitView) StartDividerDrag(mouseX, mouseY int)

StartDividerDrag initiates a divider drag operation

func (*SplitView) SwapPanes

func (sv *SplitView) SwapPanes()

SwapPanes swaps the left and right panes

func (*SplitView) Update

func (sv *SplitView) Update(msg tea.Msg) (Component, tea.Cmd)

Update handles messages and updates state

func (*SplitView) UpdateDividerDrag

func (sv *SplitView) UpdateDividerDrag(mouseX, mouseY int)

UpdateDividerDrag updates the split ratio during a drag operation

func (*SplitView) View

func (sv *SplitView) View() string

View renders the split view

type Stateful

type Stateful interface {
	Component

	// Show makes the component visible
	Show()

	// Hide makes the component invisible
	Hide()

	// Toggle switches between visible and invisible states
	Toggle()

	// IsVisible returns true if the component is currently visible
	IsVisible() bool
}

Stateful represents components with visibility and state management. This interface is particularly useful for overlays, popups, and toggleable components.

type Theme

type Theme struct {
	Name            string
	PrimaryColor    string
	SecondaryColor  string
	BackgroundColor string
	TextColor       string
	BorderColor     string
	AccentColor     string
}

Theme represents a visual theme for components.

type Themeable

type Themeable interface {
	Component

	// SetTheme applies a theme to the component
	SetTheme(theme Theme)

	// GetTheme returns the current theme
	GetTheme() Theme
}

Themeable represents components that support theming. This allows components to adapt their appearance based on theme settings.

type Validatable

type Validatable interface {
	Component

	// Validate checks if the component's content is valid
	Validate() error

	// IsValid returns true if the component's content is valid
	IsValid() bool

	// GetValidationError returns the current validation error, if any
	GetValidationError() error
}

Validatable represents components that can validate their content. This is useful for form inputs and data entry components.

Jump to

Keyboard shortcuts

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