ui

package
v0.12.4 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeTableComponent

func MakeTableComponent[T any](componentName string) vdom.Component[TableProps[T]]

Types

type CellContext

type CellContext[T any] struct {
	Data   T      `json:"row"`
	Value  any    `json:"value"`
	RowIdx int    `json:"rowIdx"`
	ColIdx int    `json:"colIdx"`
	Column string `json:"column"`
}

Core table types

type HeaderContext

type HeaderContext struct {
	Column        string `json:"column"`
	IsSorted      bool   `json:"isSorted"`
	SortDirection string `json:"sortDirection"`
}

type PaginationConfig

type PaginationConfig struct {
	PageSize    int   `json:"pageSize"`
	CurrentPage int   `json:"currentPage"`
	ShowSizes   []int `json:"showSizes,omitempty"` // [10, 25, 50, 100]
}

type RowContext

type RowContext[T any] struct {
	Data   T   `json:"row"`
	RowIdx int `json:"rowIdx"`
}

type TableColumn

type TableColumn[T any] struct {
	AccessorKey     string                         `json:"accessorKey"` // Field name in the data
	AccessorFn      func(rowCtx RowContext[T]) any `json:"-"`           // Function to extract value from row
	Header          string                         `json:"header"`      // Display name
	Width           string                         `json:"width,omitempty"`
	Sortable        bool                           `json:"sortable"`
	CellClassName   string
	HeaderClassName string
	CellRender      func(ctx CellContext[T]) any `json:"-"` // Custom cell renderer
	HeaderRender    func(ctx HeaderContext) any  `json:"-"` // Custom header renderer
}

Column definition - similar to TanStack Table

type TableProps

type TableProps[T any] struct {
	Data              []T                                   `json:"data"`
	Columns           []TableColumn[T]                      `json:"columns"`
	RowRender         func(ctx RowContext[T]) any           `json:"-"` // Custom row renderer (overrides columns)
	RowClassName      func(ctx RowContext[T]) string        `json:"-"` // Custom row class names
	OnRowClick        func(row T, idx int)                  `json:"-"`
	OnSort            func(column string, direction string) `json:"-"`
	DefaultSort       string                                `json:"defaultSort,omitempty"`
	Pagination        *PaginationConfig                     `json:"pagination,omitempty"`
	Selectable        bool                                  `json:"selectable"`
	SelectedRows      []int                                 `json:"selectedRows,omitempty"`
	OnSelectionChange func(selectedRows []int)              `json:"-"`
}

Table props

Jump to

Keyboard shortcuts

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