tables

package
v1.3.21 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2024 License: MIT Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultLimits = []int{5, 10, 25, 50}

DefaultLimits is a list of default limits

Functions

func Next added in v1.0.32

func Next(p PaginationProps) htmx.Node

Next ...

func Paginate added in v1.3.18

func Paginate[T any](value interface{}, pagination *Paginated[T], db *gorm.DB) func(db *gorm.DB) *gorm.DB

Paginate returns a function that paginates the results.

func PaginatedResults added in v1.3.12

func PaginatedResults[T any](value interface{}, pagination *Results[T], db *gorm.DB) func(db *gorm.DB) *gorm.DB

PaginatedResults returns a function that paginates the results.

func Pagination added in v1.0.22

func Pagination(p PaginationProps, children ...htmx.Node) htmx.Node

Pagination ...

func Prev added in v1.0.32

func Prev(p PaginationProps) htmx.Node

Prev ...

func RowsPtr added in v1.3.18

func RowsPtr[T any](rows []T) []*T

RowsPtr is a function that returns the rows as pointers.

func Select added in v1.0.32

func Select(p SelectProps, children ...htmx.Node) htmx.Node

Select ...

func Table

func Table[S ~[]R, R Row](p TableProps, columns Columns[R], s S) htmx.Node

Table is a struct that contains the properties of a table

func TablePagination added in v1.0.32

func TablePagination(p TablePaginationProps, children ...htmx.Node) htmx.Node

TablePagination is a component that renders a table pagination

func TableToolbar added in v1.0.32

func TableToolbar(p TableToolbarProps, children ...htmx.Node) htmx.Node

TableToolbar is a component that renders a table toolbar

Types

type ColumnDef

type ColumnDef[R Row] struct {
	ID              string
	AccessorKey     string
	Header          func(p TableProps) htmx.Node
	Cell            func(p TableProps, row R) htmx.Node
	EnableSorting   bool
	EnableFiltering bool
}

ColumnDef returns a new column definition.

type Columns

type Columns[R Row] []ColumnDef[R]

Columns returns a new column definition.

type Paginated added in v1.3.18

type Paginated[T any] struct {
	// Limit is the number of items to return.
	Limit int `json:"limit" xml:"limit" form:"limit" query:"limit"`
	// Offset is the number of items to skip.
	Offset int `json:"offset" xml:"offset" form:"offset" query:"offset"`
	// Search is the search term to filter the results.
	Search string `json:"search,omitempty" xml:"search" form:"search" query:"search"`
	// Sort is the sorting order.
	Sort string `json:"sort,omitempty" xml:"sort" form:"sort" query:"sort"`
	// Value is the value to paginate.
	Value T `json:"value,omitempty" xml:"value" form:"value" query:"value"`
}

Paginated is a struct that contains the properties of a pagination

func (*Paginated[T]) GetLimit added in v1.3.18

func (p *Paginated[T]) GetLimit() int

GetLimit returns the limit.

func (*Paginated[T]) GetOffset added in v1.3.18

func (p *Paginated[T]) GetOffset() int

GetOffset returns the page.

func (*Paginated[T]) GetSearch added in v1.3.18

func (p *Paginated[T]) GetSearch() string

GetSearch returns the search.

func (*Paginated[T]) GetSort added in v1.3.18

func (p *Paginated[T]) GetSort() string

GetSort returns the sort.

type PaginationProps added in v1.0.32

type PaginationProps struct {
	ClassNames htmx.ClassNames
	Limit      int
	Offset     int
	Target     string
	Total      int
	URL        string
}

PaginationProps is a struct that contains the properties of a pagination

type Results added in v1.3.12

type Results[T any] struct {
	// Limit is the number of items to return.
	Limit int `json:"limit" xml:"limit" form:"limit" query:"limit"`
	// Offset is the number of items to skip.
	Offset int `json:"offset" xml:"offset" form:"offset" query:"offset"`
	// Search is the search term to filter the results.
	Search string `json:"search,omitempty" xml:"search" form:"search" query:"search"`
	// Sort is the sorting order.
	Sort string `json:"sort,omitempty" xml:"sort" form:"sort" query:"sort"`
	// TotalRows is the total number of rows.
	TotalRows int `json:"total_rows"`
	// TotalPages is the total number of pages.
	TotalPages int `json:"total_pages"`
	// Rows is the items to return.
	Rows []T `json:"rows" xml:"rows"`
}

Results is a struct that contains the results of a query

func FromContext added in v1.3.14

func FromContext[T any](c *fiber.Ctx) (Results[T], error)

FromContext returns the results from the context.

func (*Results[T]) GetLen added in v1.3.12

func (p *Results[T]) GetLen() int

GetLen returns the length of the rows.

func (*Results[T]) GetLimit added in v1.3.12

func (p *Results[T]) GetLimit() int

GetLimit returns the limit.

func (*Results[T]) GetOffset added in v1.3.12

func (p *Results[T]) GetOffset() int

GetOffset returns the page.

func (*Results[T]) GetRows added in v1.3.12

func (p *Results[T]) GetRows() []*T

GetRows returns the rows as pointers.

func (*Results[T]) GetSort added in v1.3.12

func (p *Results[T]) GetSort() string

GetSort returns the sort.

func (*Results[T]) GetTotalPages added in v1.3.12

func (p *Results[T]) GetTotalPages() int

GetTotalPages returns the total pages.

func (*Results[T]) GetTotalRows added in v1.3.12

func (p *Results[T]) GetTotalRows() int

GetTotalRows returns the total rows.

type Row added in v1.2.8

type Row interface {
	comparable
}

Row is a struct that contains the properties of a row

type SelectProps added in v1.0.32

type SelectProps struct {
	ClassNames htmx.ClassNames
	Limit      int
	Limits     []int
	Offset     int
	Target     string
	Total      int
	URL        string
}

SelectProps ...

type TablePaginationProps added in v1.0.32

type TablePaginationProps struct {
	ClassNames htmx.ClassNames
}

TablePaginationProps is a struct that contains the properties of a table pagination

type TableProps

type TableProps struct {
	ClassNames htmx.ClassNames
	ID         string
	Pagination htmx.Node
	Toolbar    htmx.Node
}

TableProps is a struct that contains the properties of a table

type TableToolbarProps added in v1.0.32

type TableToolbarProps struct {
	ClassNames htmx.ClassNames
}

TableToolbarProps is a struct that contains the properties of a table toolbar

Jump to

Keyboard shortcuts

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