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
- func Breadcrumbs(th theme.Theme, titles []string) string
- func Header(th theme.Theme, width, height int, context string, badges []string, ...) string
- func Scrollbar(th theme.Theme, height, total, visible, offset int) string
- type CmdBar
- type Event
- type EventKind
- type FilterBar
- type FlashLevel
- type StatusBar
- type Table
- func (t Table) InSortMode() bool
- func (t Table) Len() int
- func (t Table) SelectedID() string
- func (t Table) SelectedRow() (resource.Row, bool)
- func (t *Table) SetCellStyler(fn func(col int, value string) resource.CellClass)
- func (t *Table) SetData(cols []resource.Column, rows []resource.Row)
- func (t *Table) SetSize(width, height int)
- func (t Table) Update(msg tea.Msg) (Table, tea.Cmd)
- func (t Table) View() string
Constants ¶
const Banner = `` /* 623-byte string literal not displayed */
Banner is the top-right logo, k9s-style. Shown only on terminals with room to spare.
Variables ¶
This section is empty.
Functions ¶
func Breadcrumbs ¶
Breadcrumbs renders the navigation trail like `<catalogs> <main>` with the active segment accented.
func Header ¶
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 ¶
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 ¶
NewCmdBar builds the command bar; complete supplies candidate names for the first word (usually Registry.Complete).
type FilterBar ¶
type FilterBar struct {
// contains filtered or unexported fields
}
FilterBar is the `/` live 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.
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 (Table) InSortMode ¶
InSortMode reports whether the column picker is active; while true the owning view should route all key input to the table.
func (Table) SelectedID ¶
SelectedID returns the ID of the row under the cursor, or "".
func (Table) SelectedRow ¶
SelectedRow returns the row under the cursor.
func (*Table) SetCellStyler ¶
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 ¶
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 ¶
SetSize resizes the table region. Reflow only happens on actual size changes — this is called every render.