item.go

 1package lazylist
 2
 3import (
 4	"charm.land/lipgloss/v2"
 5	"github.com/charmbracelet/x/ansi"
 6)
 7
 8// Item represents a single item in the lazy-loaded list.
 9type Item interface {
10	// Render returns the string representation of the item for the given
11	// width.
12	Render(width int) string
13}
14
15// FocusStylable represents an item that can be styled based on focus state.
16type FocusStylable interface {
17	// FocusStyle returns the style to apply when the item is focused.
18	FocusStyle() lipgloss.Style
19	// BlurStyle returns the style to apply when the item is unfocused.
20	BlurStyle() lipgloss.Style
21}
22
23// HighlightStylable represents an item that can be styled for highlighted regions.
24type HighlightStylable interface {
25	// HighlightStyle returns the style to apply for highlighted regions.
26	HighlightStyle() lipgloss.Style
27}
28
29// MouseClickable represents an item that can handle mouse click events.
30type MouseClickable interface {
31	// HandleMouseClick processes a mouse click event at the given coordinates.
32	// It returns true if the event was handled, false otherwise.
33	HandleMouseClick(btn ansi.MouseButton, x, y int) bool
34}