datatable

package
v0.0.0-...-3de950c Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT_ITERATOR_COLUMN_MAX_WIDTH = 100
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Column

type Column[T any] struct {
	Name string
	Text string
	// 只有 Table.Style 等于 light 是才会生效
	AutoColor  bool
	ForceColor bool
	RenderFunc func(item T) any
	SlotColumn func(item T, column Column[T]) any
	SortMode   table.SortMode
	Matchs     []string
	Marshal    bool
	WidthMax   int
	Align      text.Align
}

type DataIterator

type DataIterator[T any] struct {
	Items               []T
	Fields              []Field[T]
	MoreFields          []Field[T]
	ValueColumnMaxWidth int
	Title               string
	Style               table.Style
	AutoIndex           bool
	SortBy              []table.SortBy
	SeparateRows        bool
	Output              io.Writer
	// contains filtered or unexported fields
}

func (*DataIterator[T]) AddItems

func (t *DataIterator[T]) AddItems(items []T) *DataIterator[T]

func (DataIterator[T]) Count

func (t DataIterator[T]) Count() int

func (DataIterator[T]) GetJson

func (t DataIterator[T]) GetJson() (string, error)

func (DataIterator[T]) GetYaml

func (t DataIterator[T]) GetYaml() (string, error)

func (DataIterator[T]) IsStyleLight

func (t DataIterator[T]) IsStyleLight() bool

func (DataIterator[T]) Print

func (t DataIterator[T]) Print(more ...bool)

func (*DataIterator[T]) Render

func (t *DataIterator[T]) Render(more ...bool) []string

func (*DataIterator[T]) SetStyle

func (t *DataIterator[T]) SetStyle(style table.Style)

type DataTable

type DataTable[T any] struct {
	Items       []T
	Columns     []Column[T]
	MoreColumns []Column[T]
	Title       string

	Style        table.Style
	AutoIndex    bool
	SortBy       []table.SortBy
	SeparateRows bool
	Output       io.Writer
	// contains filtered or unexported fields
}

func (*DataTable[T]) AddColumns

func (t *DataTable[T]) AddColumns(columns []Column[T]) *DataTable[T]

func (*DataTable[T]) AddItems

func (t *DataTable[T]) AddItems(items []T) *DataTable[T]

func (DataTable[T]) Count

func (t DataTable[T]) Count() int

func (DataTable[T]) GetJson

func (t DataTable[T]) GetJson() (string, error)

func (DataTable[T]) GetYaml

func (t DataTable[T]) GetYaml() (string, error)

func (DataTable[T]) IsStyleLight

func (t DataTable[T]) IsStyleLight() bool

func (DataTable[T]) Print

func (t DataTable[T]) Print(more ...bool)

func (*DataTable[T]) Render

func (t *DataTable[T]) Render(more ...bool) string

func (*DataTable[T]) SetStyle

func (t *DataTable[T]) SetStyle(style table.Style)

type Field

type Field[T any] struct {
	Name string
	Text string
	// 只有 Table.Style 等于 light 是才会生效
	AutoColor  bool
	ForceColor bool
	RenderFunc func(item T) any
	SlotColumn func(item T, column Field[T]) any
	SortMode   table.SortMode
	// 模糊匹配
	Matchs   []string
	Marshal  bool
	WidthMax int
	Align    text.Align
}

Jump to

Keyboard shortcuts

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