refactor(table): rename OverwriteStylesFromLipgloss to LipglossTable

Also, keeps any previously set data on the Lip Gloss table, if set.
This commit is contained in:
Andrey Nering
2025-05-29 17:42:12 -03:00
parent 2110223809
commit fe39af2a4d
4 changed files with 62 additions and 20 deletions
+9 -4
View File
@@ -364,14 +364,19 @@ func (m *Model) OverwriteStyles(s Styles) *Model {
return m
}
// OverwriteStylesFromLipgloss sets the [Model]'s style attributes from an
// existing [lipgloss.Table].
func (m *Model) OverwriteStylesFromLipgloss(t *table.Table) {
// LipglossTable sets the inner [lipgloss.Table].
func (m *Model) LipglossTable(t *table.Table) {
var (
previousHeaders = m.table.GetHeaders()
previousData = m.table.GetData()
)
m.table = t.Headers(previousHeaders...).Data(previousData)
if len(t.GetHeaders()) == 0 {
t = t.Headers(previousHeaders...)
}
if t.GetData() == nil || t.GetData().Rows() == 0 {
t = t.Rows(table.DataToMatrix(previousData)...)
}
m.table = t
m.useStyleFunc = true
}