Add fonts, autotable, autotable examples
This commit is contained in:
@@ -192,14 +192,14 @@ func SortableHeader(p SortableHeaderProps) *vdom.VNode {
|
||||
|
||||
inner := []vdom.Mod{
|
||||
vdom.Attr("class", "flex items-center gap-0.5 min-w-0"),
|
||||
vdom.El("span", vdom.Attr("class", "truncate min-w-0 flex-1"), vdom.Text(p.Label)),
|
||||
vdom.Span(vdom.Attr("class", "truncate min-w-0 flex-1"), vdom.Text(p.Label)),
|
||||
}
|
||||
if isActive {
|
||||
icon := "caret-up"
|
||||
if p.Desc {
|
||||
icon = "caret-down"
|
||||
}
|
||||
inner = append(inner, vdom.El("span", vdom.Attr("class", "shrink-0"), Icon(icon, 10, "")))
|
||||
inner = append(inner, vdom.Span(vdom.Attr("class", "shrink-0"), Icon(icon, 10, "")))
|
||||
}
|
||||
|
||||
mods := []vdom.Mod{vdom.Attr("class", cls)}
|
||||
@@ -207,8 +207,8 @@ func SortableHeader(p SortableHeaderProps) *vdom.VNode {
|
||||
key := p.SortKey
|
||||
mods = append(mods, vdom.On(vdom.EVENT_CLICK, func() { p.OnSort(key) }))
|
||||
}
|
||||
mods = append(mods, vdom.El("div", inner...))
|
||||
return vdom.El("th", mods...)
|
||||
mods = append(mods, vdom.Div(inner...))
|
||||
return vdom.Th(mods...)
|
||||
}
|
||||
|
||||
func cellGridConflictSets(p CellGridProps) map[string]map[string]bool {
|
||||
@@ -366,7 +366,7 @@ func CellGrid(p CellGridProps) *vdom.VNode {
|
||||
if sz := cellGridColumnSize(col.Width, col.MinWidth); sz != "" {
|
||||
cls += " " + sz
|
||||
}
|
||||
return vdom.El("th", vdom.Attr("class", cls), vdom.Text(col.Label))
|
||||
return vdom.Th(vdom.Attr("class", cls), vdom.Text(col.Label))
|
||||
}
|
||||
|
||||
renderCell := func(row map[string]any, col CellGridColumn) *vdom.VNode {
|
||||
@@ -393,7 +393,7 @@ func CellGrid(p CellGridProps) *vdom.VNode {
|
||||
mods = append(mods, vdom.On(vdom.EVENT_CLICK, func() { col.OnClick(row) }))
|
||||
}
|
||||
mods = append(mods, col.Render(row))
|
||||
return vdom.El("td", mods...)
|
||||
return vdom.Td(mods...)
|
||||
}
|
||||
|
||||
// Read-only cell.
|
||||
@@ -407,7 +407,7 @@ func CellGrid(p CellGridProps) *vdom.VNode {
|
||||
} else {
|
||||
mods = append(mods, vdom.Text(cellGridStr(row[col.Key])))
|
||||
}
|
||||
return vdom.El("td", mods...)
|
||||
return vdom.Td(mods...)
|
||||
}
|
||||
|
||||
// Editable cell.
|
||||
@@ -424,8 +424,7 @@ func CellGrid(p CellGridProps) *vdom.VNode {
|
||||
if im == "" {
|
||||
im = "text"
|
||||
}
|
||||
input := vdom.El("input",
|
||||
vdom.Attr("class", inputCls),
|
||||
input := vdom.Input(vdom.Attr("class", inputCls),
|
||||
vdom.Attr("type", "text"),
|
||||
vdom.Attr("inputmode", im),
|
||||
vdom.Attr("placeholder", col.Placeholder),
|
||||
@@ -442,20 +441,19 @@ func CellGrid(p CellGridProps) *vdom.VNode {
|
||||
)
|
||||
mods := []vdom.Mod{vdom.Attr("class", tdCls), input}
|
||||
if inList && hasConflict {
|
||||
mods = append(mods, vdom.El("span",
|
||||
vdom.Attr("class", "pointer-events-none absolute right-0.5 top-1/2 -translate-y-1/2 text-amber-600"),
|
||||
mods = append(mods, vdom.Span(vdom.Attr("class", "pointer-events-none absolute right-0.5 top-1/2 -translate-y-1/2 text-amber-600"),
|
||||
vdom.Attr("title", "Duplicate value"),
|
||||
Icon("triangle-exclamation", 12, ""),
|
||||
))
|
||||
}
|
||||
return vdom.El("td", mods...)
|
||||
return vdom.Td(mods...)
|
||||
}
|
||||
|
||||
var headerCells []*vdom.VNode
|
||||
for _, col := range p.Columns {
|
||||
headerCells = append(headerCells, renderHeader(col))
|
||||
}
|
||||
thead := vdom.El("thead", vdom.El("tr", kids(nil, headerCells)...))
|
||||
thead := vdom.Thead(vdom.Tr(kids(nil, headerCells)...))
|
||||
|
||||
var bodyRows []*vdom.VNode
|
||||
for _, row := range cellGridSortedRows(p) {
|
||||
@@ -463,17 +461,15 @@ func CellGrid(p CellGridProps) *vdom.VNode {
|
||||
for _, col := range p.Columns {
|
||||
cells = append(cells, renderCell(row, col))
|
||||
}
|
||||
bodyRows = append(bodyRows, vdom.El("tr",
|
||||
kids([]vdom.Mod{vdom.Attr("class", "odd:bg-white even:bg-neutral-100")}, cells)...))
|
||||
bodyRows = append(bodyRows, vdom.Tr(kids([]vdom.Mod{vdom.Attr("class", "odd:bg-white even:bg-neutral-100")}, cells)...))
|
||||
}
|
||||
tbody := vdom.El("tbody", kids(nil, bodyRows)...)
|
||||
tbody := vdom.Tbody(kids(nil, bodyRows)...)
|
||||
|
||||
tableCls := "min-w-full w-max border-collapse text-sm"
|
||||
if p.Dense {
|
||||
tableCls = "min-w-full w-max border-collapse text-xs"
|
||||
}
|
||||
return vdom.El("div",
|
||||
vdom.Attr("class", "relative max-w-full overflow-x-auto border border-neutral-300 rounded-default bg-white tabular-nums"),
|
||||
vdom.El("table", vdom.Attr("class", tableCls), thead, tbody),
|
||||
return vdom.Div(vdom.Attr("class", "relative max-w-full overflow-x-auto border border-neutral-300 rounded-default bg-white tabular-nums"),
|
||||
vdom.Table(vdom.Attr("class", tableCls), thead, tbody),
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user