tablegrid

package
v0.0.20 Latest Latest
Warning

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

Go to latest
Published: May 12, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Copyright Project Harbor Authors

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CellStatus

type CellStatus bool

CellStatus represents a cell's toggle state

type Config

type Config struct {
	RowLabels    []string
	ColLabels    []string
	Data         [][]CellStatus
	Disabled     map[int]map[int]bool
	ColumnWidths []int
	Styles       *Styles
	Icons        *Icons
	Footer       string
}

Config holds parameters for creating a new TableGrid

type Icons

type Icons struct {
	Selected   string // Icon for selected cells
	Unselected string // Icon for unselected cells
	Empty      string // Icon for disabled cells
}

Icons defines how cells are displayed

func DefaultIcons

func DefaultIcons() Icons

DefaultIcons returns the default icons

type Styles

type Styles struct {
	Selected   lipgloss.Style
	Unselected lipgloss.Style
	Disabled   lipgloss.Style
	Header     lipgloss.Style
	Cursor     string // Cursor indicator
}

Styles contains customizable styles for the table grid

func DefaultStyles

func DefaultStyles() Styles

DefaultStyles returns the default styles

type TableGrid

type TableGrid struct {
	Table       table.Model
	Data        [][]CellStatus       // 2D grid of cell states (true = selected, false = not selected)
	RowLabels   []string             // Labels for rows
	ColLabels   []string             // Labels for columns
	Disabled    map[int]map[int]bool // Which cells are disabled
	SelectedCol int                  // Currently selected column
	Styles      Styles               // Custom styles
	Icons       Icons                // Custom icons
	Footer      string               // Custom footer text
}

TableGrid is a generic interactive grid for toggling options

func New

func New(config Config) *TableGrid

New creates a new TableGrid

func (*TableGrid) GetData

func (m *TableGrid) GetData() [][]CellStatus

GetData returns the current selection state

func (*TableGrid) GetSelectedItems

func (m *TableGrid) GetSelectedItems() [][]int

GetSelectedItems returns the coordinates of all selected cells

func (*TableGrid) Init

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

Init initializes the model

func (*TableGrid) Update

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

Update handles UI updates

func (*TableGrid) View

func (m *TableGrid) View() string

View renders the component

Jump to

Keyboard shortcuts

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