Documentation
¶
Index ¶
- Constants
- type BackMsg
- type CollapsedSummariser
- type Config
- type DetailsRenderer
- type DrillDownMsg
- type FooterRenderer
- type HeaderRenderer
- type Item
- type ItemExpandedMsg
- type ItemSelectedMsg
- type ItemsUpdatedMsg
- type Model
- func (m *Model) AddItem(item Item)
- func (m Model) Config() Config
- func (m Model) FilterTerm() string
- func (m Model) FocusedPane() PaneType
- func (m Model) HasFilter() bool
- func (m Model) Height() int
- func (m Model) Init() tea.Cmd
- func (m Model) IsExpanded(id string) bool
- func (m Model) IsFiltering() bool
- func (m Model) IsInDrillDown() bool
- func (m Model) IsPickingStatus() bool
- func (m Model) Items() []Item
- func (m Model) LeftPaneWidth() int
- func (m Model) NavigationPath() []string
- func (m Model) NavigationStack() []NavigationFrame
- func (m *Model) RefreshViewports()
- func (m *Model) RemoveItemByID(id string) bool
- func (m Model) RightPaneWidth() int
- func (m Model) RootItems() []Item
- func (m *Model) Select(id string)
- func (m Model) SelectedID() string
- func (m Model) SelectedIndex() int
- func (m Model) SelectedItem() Item
- func (m *Model) SetExpanded(id string, expanded bool)
- func (m *Model) SetFilterTerm(term string)
- func (m *Model) SetItems(items []Item)
- func (m Model) Styles() *styles.Styles
- func (m Model) Update(msg tea.Msg) (Model, tea.Cmd)
- func (m *Model) UpdateItemByID(id string, newItem Item) bool
- func (m *Model) UpdateItems(items []Item)
- func (m Model) View() string
- func (m Model) Width() int
- type NavigationFrame
- type PaneType
- type QuitMsg
- type Section
- type SectionGrouper
Constants ¶
const StatusFilterPrefix = "status:"
StatusFilterPrefix qualifies a filter word as a status rather than a name, as in "status:failed".
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CollapsedSummariser ¶ added in v0.9.0
type CollapsedSummariser interface {
// GetCollapsedSummary describes the hidden children, e.g. "2 resources, 1 link".
// An empty string renders nothing.
GetCollapsedSummary() string
}
CollapsedSummariser is an optional interface for items whose children are hidden while collapsed. The summary is shown next to the item's name so that what is folded away is still visible when scanning the list.
type Config ¶
type Config struct {
// Required
Styles *styles.Styles
DetailsRenderer DetailsRenderer
// Optional: title shown in the left pane header (default: none)
Title string
// Optional with defaults
LeftPaneRatio float64 // Default: 0.4
MaxExpandDepth int // Default: 2
SectionGrouper SectionGrouper // Default: no sections
HeaderRenderer HeaderRenderer // Default: standard header with title and breadcrumb
// StatusKeywords reports the words a "status:" filter can match an item by,
// usually derived from the status it is already showing. Leave nil to filter
// by name only; a status filter then matches nothing rather than everything.
StatusKeywords func(Item) []string
// StatusFilterHints are the status words offered while a filter is being
// typed. The pane does not know what statuses mean, so the vocabulary comes
// from whoever supplied StatusKeywords. Ordered most useful first, since
// only as many as fit the pane are shown.
StatusFilterHints []string
// Section names (if using default grouper)
// e.g., {"resource": "Resources"}
SectionNames map[string]string
}
Config configures the split-pane model.
type DetailsRenderer ¶
type DetailsRenderer interface {
RenderDetails(item Item, width int, styles *styles.Styles) string
}
DetailsRenderer renders the right pane content for a selected item. Consumers implement this for domain-specific detail views.
type DrillDownMsg ¶
type DrillDownMsg struct {
Item Item
}
DrillDownMsg is sent when drilling into an item
type FooterRenderer ¶
type FooterRenderer interface {
}
FooterRenderer renders custom footer content. Optional - if nil, uses default keyboard hints footer.
type HeaderRenderer ¶
HeaderRenderer customizes the left pane header. Optional - if nil, uses default header with title and breadcrumb.
type Item ¶
type Item interface {
// GetID provides a unique identifier that is primarily
// used for expansion tracking in the split pane
GetID() string
// GetName provides a human-readable name for the item
GetName() string
// GetIcon provides a status icon (styled when not selected)
GetIcon(selected bool) string
// GetAction provides action badge text (e.g "CREATE", "UPDATE", etc.)
GetAction() string
// GetDepth provides the nesting depth for indentation
GetDepth() int
// GetParentID returns the parent item ID (empty for top-level items)
GetParentID() string
// GetItemType returns the type for section grouping (e.g., "resource", "child")
GetItemType() string
// IsExpandable indicates whether the item can be expanded in-place
IsExpandable() bool
// CanDrillDown indicates whether the item can be drilled into for detailed view
CanDrillDown() bool
// GetChildren provides a list of child items
// displayed when the current item is expanded
GetChildren() []Item
}
Item represents a selectable item in the left pane. Consumers implement this interface for their domain-specific items.
type ItemExpandedMsg ¶
ItemExpandedMsg is sent when an item is expanded/collapsed
type ItemSelectedMsg ¶
type ItemSelectedMsg struct {
Item Item
}
ItemSelectedMsg is sent when the selected item changes
type ItemsUpdatedMsg ¶
type ItemsUpdatedMsg struct{}
ItemsUpdatedMsg can be sent to trigger a viewport refresh when items have been modified externally
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model is a Bubble Tea model for a two-pane split view. Left pane shows a navigable list; right pane shows details.
func (*Model) AddItem ¶
AddItem adds an item to the end of the root items list. If currently in drill-down, the item is added to root but the view refreshes appropriately.
func (Model) FilterTerm ¶ added in v0.9.0
FilterTerm returns the active search term, empty when nothing is filtered.
func (Model) FocusedPane ¶
FocusedPane returns which pane currently has focus.
func (Model) HasFilter ¶ added in v0.9.0
HasFilter reports whether a search term is narrowing the displayed items.
func (Model) IsExpanded ¶
IsExpanded returns true if the item with the given ID is expanded.
func (Model) IsFiltering ¶ added in v0.9.0
IsFiltering reports whether the filter input is currently accepting keys. Host models check this before handling their own single-key shortcuts, so that typing a search term does not trigger them.
func (Model) IsInDrillDown ¶
IsInDrillDown returns true if currently viewing a drilled-down item.
func (Model) IsPickingStatus ¶ added in v0.9.0
IsPickingStatus reports whether the status picker is open.
func (Model) LeftPaneWidth ¶
LeftPaneWidth returns the left pane width.
func (Model) NavigationPath ¶
NavigationPath returns the breadcrumb path as a slice of names.
func (Model) NavigationStack ¶
func (m Model) NavigationStack() []NavigationFrame
NavigationStack returns the navigation stack for drill-down.
func (*Model) RefreshViewports ¶ added in v0.1.3
func (m *Model) RefreshViewports()
RefreshViewports forces a re-render of both viewport contents. Use this when item data has changed but items themselves haven't been replaced, or when you need to ensure the displayed content is up-to-date.
func (*Model) RemoveItemByID ¶
RemoveItemByID removes an item by ID from root items. Returns true if the item was found and removed.
func (Model) RightPaneWidth ¶
RightPaneWidth returns the right pane width.
func (*Model) Select ¶ added in v0.9.0
Select moves the selection to the item with the given ID, expanding its parent if the item is currently hidden. The selection is left on the first visible item when the ID is not found.
func (Model) SelectedID ¶
SelectedID returns the ID of the currently selected item.
func (Model) SelectedIndex ¶
SelectedIndex returns the currently selected index.
func (Model) SelectedItem ¶
SelectedItem returns the currently selected item, or nil if none. Uses ID-based lookup to ensure the correct item is returned even after updates.
func (*Model) SetExpanded ¶ added in v0.9.0
SetExpanded expands or collapses the item with the given ID, for callers driving the pane programmatically rather than through key presses.
func (*Model) SetFilterTerm ¶ added in v0.9.0
SetFilterTerm applies a search term, for callers driving the pane programmatically rather than through key presses.
func (*Model) SetItems ¶
SetItems sets the items to display, resetting all state. Use UpdateItems() instead if you want to preserve selection and expansion state.
func (*Model) UpdateItemByID ¶
UpdateItemByID replaces an item by ID in both root and current items. Returns true if the item was found and updated.
func (*Model) UpdateItems ¶
UpdateItems replaces items while preserving user state where possible. - Preserves selection if the selected item still exists (by ID) - Preserves expansion state for items that still exist - Properly handles drill-down mode by refreshing children from updated parent
type NavigationFrame ¶
NavigationFrame represents a frame in the drill-down navigation stack