components

package
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2025 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package components provides reusable UI components for terminal applications.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DisplayErrorNotification

func DisplayErrorNotification(message string)

func DisplayInfoNotification

func DisplayInfoNotification(message string)

func DisplayNotification

func DisplayNotification(message, messageType string)

func DisplayWarningNotification

func DisplayWarningNotification(message string)

func GetTableScreen

func GetTableScreen(tbHandler tp.TableDataHandler, customStyles map[string]lipgloss.Color) string

GetTableScreen returns the string representation of the table with custom styles.

func GetTableScreenCustom

func GetTableScreenCustom(tbHandler tp.TableDataHandler, customStyles map[string]lipgloss.Color, styleFunc StyleFunc) string

GetTableScreenCustom returns the string representation of the table with custom styles and an optional style function.

func NavigateAndExecuteForm(config tp.FormConfig) (map[string]string, error)
func NavigateAndExecuteTable(tbHandler tp.TableDataHandler, customStyles map[string]lipgloss.Color) error

NavigateAndExecuteTable navigates and executes the table screen with custom styles.

func NavigateAndExecuteTableCustom(tbHandler tp.TableDataHandler, customStyles map[string]lipgloss.Color, styleFunc StyleFunc) error

NavigateAndExecuteTableCustom navigates and executes the table screen with custom styles and an optional style function.

func ShowForm

func ShowForm(config tp.FormConfig) (map[string]string, error)

func ShowFormWithNotification

func ShowFormWithNotification(config tp.FormConfig) (map[string]string, error)

func ShowNotification

func ShowNotification(notification Notification)

func StartTableScreen

func StartTableScreen(tbHandler tp.TableDataHandler, customStyles map[string]lipgloss.Color) error

StartTableScreen starts the table screen with custom styles.

func StartTableScreenCustom

func StartTableScreenCustom(tbHandler tp.TableDataHandler, customStyles map[string]lipgloss.Color, styleFunc StyleFunc) error

StartTableScreenCustom starts the table screen with custom styles and an optional style function.

func StartTableScreenFromRenderer

func StartTableScreenFromRenderer(k *TableRenderer) error

StartTableScreenFromRenderer starts the table screen from a given TableRenderer.

Types

type FormModel

type FormModel struct {
	Title        string
	FocusIndex   int
	Inputs       []textinput.Model
	CursorMode   cursor.Mode
	Fields       []tp.FormInputObject[any]
	ErrorMessage string
}

func (*FormModel) Init

func (m *FormModel) Init() tea.Cmd

func (*FormModel) Update

func (m *FormModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*FormModel) View

func (m *FormModel) View() string

type Notification

type Notification struct {
	Message string
	Type    NotificationType
}

type NotificationType

type NotificationType string
const (
	Info    NotificationType = "info"
	Warning NotificationType = "warning"
	Error   NotificationType = "error"
)

type StyleFunc

type StyleFunc func(row, col int, cellValue string) lipgloss.Style

StyleFunc defines a function that returns a lipgloss.Style based on row, column, and cell value.

type TableRenderer

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

TableRenderer is responsible for rendering tables in the terminal with customizable styles and dynamic behavior.

func NewTableRenderer

func NewTableRenderer(tbHandler tp.TableDataHandler, customStyles map[string]lipgloss.Color, styleFunc StyleFunc) *TableRenderer

NewTableRenderer creates a new TableRenderer with custom styles and an optional style function.

func (*TableRenderer) ApplyFilter

func (k *TableRenderer) ApplyFilter()

ApplyFilter applies a filter to the table rows.

func (*TableRenderer) ExportToCSV

func (k *TableRenderer) ExportToCSV(filename string)

ExportToCSV exports the table data to a CSV file.

func (*TableRenderer) ExportToExcel

func (k *TableRenderer) ExportToExcel(filename string)

ExportToExcel is a placeholder for exporting the table data to an Excel file.

func (*TableRenderer) ExportToJSON

func (k *TableRenderer) ExportToJSON(filename string)

ExportToJSON exports the table data to a JSON file.

func (*TableRenderer) ExportToMarkdown

func (k *TableRenderer) ExportToMarkdown(filename string)

ExportToMarkdown exports the table data to a Markdown file.

func (*TableRenderer) ExportToPDF

func (k *TableRenderer) ExportToPDF(filename string)

ExportToPDF exports the table data to a PDF file.

func (*TableRenderer) ExportToXML

func (k *TableRenderer) ExportToXML(filename string)

ExportToXML exports the table data to an XML file.

func (*TableRenderer) ExportToYAML

func (k *TableRenderer) ExportToYAML(filename string)

ExportToYAML exports the table data to a YAML file.

func (*TableRenderer) GetArrayMap

func (k *TableRenderer) GetArrayMap() map[string][]string

GetArrayMap returns the table data as a map of arrays.

func (*TableRenderer) GetByteMap

func (k *TableRenderer) GetByteMap() map[string][]byte

GetByteMap returns the table data as a map of byte slices.

func (*TableRenderer) GetCurrentPageRows

func (k *TableRenderer) GetCurrentPageRows() [][]string

GetCurrentPageRows returns the rows for the current page.

func (*TableRenderer) GetHashMap

func (k *TableRenderer) GetHashMap() map[string]string

GetHashMap returns the table data as a hash map.

func (*TableRenderer) GetHeaders

func (k *TableRenderer) GetHeaders() []string

GetHeaders returns the table headers.

func (*TableRenderer) GetObjectMap

func (k *TableRenderer) GetObjectMap() []map[string]string

GetObjectMap returns the table data as a slice of maps.

func (*TableRenderer) GetRows

func (k *TableRenderer) GetRows() [][]string

GetRows returns the table rows.

func (*TableRenderer) Init

func (k *TableRenderer) Init() tea.Cmd

Init initializes the table renderer.

func (*TableRenderer) RowsNavigate

func (k *TableRenderer) RowsNavigate(direction string) error

RowsNavigate navigates through the table rows.

func (*TableRenderer) SortRows

func (k *TableRenderer) SortRows()

SortRows sorts the table rows.

func (*TableRenderer) ToggleColumnVisibility

func (k *TableRenderer) ToggleColumnVisibility()

ToggleColumnVisibility toggles the visibility of the columns in the table.

func (*TableRenderer) Update

func (k *TableRenderer) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update updates the table renderer based on user input.

func (*TableRenderer) View

func (k *TableRenderer) View() string

View returns the string representation of the table for rendering.

Jump to

Keyboard shortcuts

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