component

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package component holds the dumb, reusable widgets composed by the app shell and views. Components never do I/O and never import the SDK, the engine, or resource defs' packages — they render what they're given.

Index

Constants

View Source

Banner is the top-right logo, k9s-style. Shown only on terminals with room to spare.

Variables

This section is empty.

Functions

func Breadcrumbs(th theme.Theme, titles []string) string

Breadcrumbs renders the navigation trail like `<catalogs> <main>` with the active segment accented.

func Header(th theme.Theme, width, height int, context string, badges []string, hints []key.Binding) string

Header renders the top chrome: identity line plus a k9s-style grid of the key hints valid right now, with the logo banner on the right when the terminal has room. Its height varies — measure with lipgloss.Height.

func Scrollbar

func Scrollbar(th theme.Theme, height, total, visible, offset int) string

Scrollbar renders a vertical shaded scrollbar `height` rows tall, indicating which slice of `total` content lines is visible given a window of `visible` lines scrolled to `offset`.

It is a pure formatter over scroll metrics — pass a viewport's TotalLineCount / VisibleLineCount / YOffset — so any viewport-backed view can drop it in. When everything fits (total <= visible) it renders a column of blanks the same height, so layout stays stable without drawing a needless bar. The returned string is `height` lines tall and one cell wide.

Types

type CmdBar

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

CmdBar is the `:` command prompt with prefix autocomplete.

func NewCmdBar

func NewCmdBar(complete func(string) []string) CmdBar

NewCmdBar builds the command bar; complete supplies candidate names for the first word (usually Registry.Complete).

func (CmdBar) Open

func (c CmdBar) Open() (CmdBar, tea.Cmd)

Open resets and focuses the bar, listing all completions immediately.

func (CmdBar) Update

func (c CmdBar) Update(msg tea.Msg) (CmdBar, Event, tea.Cmd)

Update processes one message while the bar is open.

func (CmdBar) View

func (c CmdBar) View(th theme.Theme, width int) string

View renders the prompt plus a one-line suggestion strip.

type Event

type Event struct {
	Kind  EventKind
	Value string
}

Event is the result of feeding a message to an input bar.

type EventKind

type EventKind int

EventKind classifies what an input-bar Update produced.

const (
	EventNone EventKind = iota
	EventChanged
	EventSubmit
	EventCancel
)

Input bar event kinds.

type FilterBar

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

FilterBar is the `/` live filter prompt.

func NewFilterBar

func NewFilterBar() FilterBar

NewFilterBar builds the filter bar.

func (FilterBar) Open

func (f FilterBar) Open(current string) (FilterBar, tea.Cmd)

Open focuses the bar seeded with the current filter.

func (FilterBar) Update

func (f FilterBar) Update(msg tea.Msg) (FilterBar, Event, tea.Cmd)

Update processes one message; EventChanged fires on every edit so the view can filter live.

func (FilterBar) View

func (f FilterBar) View(th theme.Theme, width int) string

View renders the filter prompt.

type FlashLevel

type FlashLevel int

FlashLevel classifies a status bar flash. It lives here (not in view) so both packages can use it without an import cycle.

const (
	FlashInfo FlashLevel = iota
	FlashWarn
	FlashError
)

Flash levels.

type StatusBar

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

StatusBar renders the bottom line: breadcrumbs on the left, transient flash or view status on the right.

func (*StatusBar) Flash

func (s *StatusBar) Flash(level FlashLevel, text string, now time.Time)

Flash shows a message until it expires.

func (StatusBar) Render

func (s StatusBar) Render(th theme.Theme, width int, left, right string, now time.Time) string

Render draws the bar. left is the breadcrumb trail; right is the top view's status (freshness, counts) which a live flash overrides.

type Table

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

Table wraps the bubbles table with resource-aware column sizing, cursor preservation across data refreshes, and interactive column sorting: `s` enters sort mode, ←/→ pick a column, `s`/space select it (selecting the sorted column again reverses direction — applied live), enter confirms, esc reverts.

func NewTable

func NewTable(th theme.Theme) Table

NewTable builds a themed table.

func (Table) InSortMode

func (t Table) InSortMode() bool

InSortMode reports whether the column picker is active; while true the owning view should route all key input to the table.

func (Table) Len

func (t Table) Len() int

Len is the number of rows currently displayed.

func (Table) SelectedID

func (t Table) SelectedID() string

SelectedID returns the ID of the row under the cursor, or "".

func (Table) SelectedRow

func (t Table) SelectedRow() (resource.Row, bool)

SelectedRow returns the row under the cursor.

func (*Table) SetCellStyler

func (t *Table) SetCellStyler(fn func(col int, value string) resource.CellClass)

SetCellStyler installs a semantic classifier for cell values; nil disables styling. fn receives the ORIGINAL column index (into Columns()) and the raw value, and returns a CellClass mapped to a theme style at render time. The underlying Row.Cells are never mutated.

func (*Table) SetData

func (t *Table) SetData(cols []resource.Column, rows []resource.Row)

SetData replaces columns and rows, keeping the cursor on the same row ID across refreshes so background polls don't yank the selection. The active sort is re-applied to fresh data.

func (*Table) SetSize

func (t *Table) SetSize(width, height int)

SetSize resizes the table region. Reflow only happens on actual size changes — this is called every render.

func (Table) Update

func (t Table) Update(msg tea.Msg) (Table, tea.Cmd)

Update forwards navigation keys to the underlying table and drives sort mode.

func (Table) View

func (t Table) View() string

View renders the table.

Jump to

Keyboard shortcuts

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