feat: API for user to set value for the NoItems render [List]
jaymorelli96 opened this issue · comments
Is your feature request related to a problem? Please describe.
At the moment I couldn't find a way to remove the default "No " + m.itemNamePlural + " found."
that is set when there are no visible items in the list.
Describe the solution you'd like
I would like an API in the model that I could do the following:
l := list.New() // New list is created, I am omitting the params for simplicity
l.SetNoItemsPlaceHolder("Currently this list is empty") // Accepts a string
l.SetNoItemsPlaceHolder() // Possibility to leave blank
Describe alternatives you've considered
I tried something like this, but I couldn't get the title bar to show as well. Also it seems to much of a effort that could be easily done with an API 😄
func (m Model) requestsView() string {
items := m.requests.VisibleItems()
if len(items) == 0 {
noItems := m.requests.Styles.NoItems.Render("Nothing found.")
return lipgloss.NewStyle().Height(m.height).Render(noItems)
}
return m.requests.View()
}
Additional context
This logic is already being done by the func (m Model) populatedView() string
in the list.go
line 1153. Should be simple to add a new showNoItems bool
in the model for at least have the option to omit this