Scrollable list component with item selection.
Usage: (def my-list (item-list ["Apple" "Banana" "Cherry"]))
;; In update function: (list-update my-list msg)
;; In view function: (list-view my-list)
Scrollable list component with item selection. Usage: (def my-list (item-list ["Apple" "Banana" "Cherry"])) ;; In update function: (list-update my-list msg) ;; In view function: (list-view my-list)
(filter-items lst pred)Filter items by a predicate function. Returns a new list with only matching items.
Filter items by a predicate function. Returns a new list with only matching items.
(find-item lst pred)Find the first item matching a predicate. Returns the index or nil.
Find the first item matching a predicate. Returns the index or nil.
(item-list items
&
{:keys [height width cursor title show-title cursor-style item-style
title-style cursor-prefix item-prefix show-descriptions
infinite-scroll id]
:or {show-title true
height 0
infinite-scroll false
item-prefix " "
show-descriptions false
width 0
cursor 0
cursor-prefix "> "
id (rand-int 1000000)}})Create a list component.
Items can be strings, maps with :title/:description, or any type implementing the ListItem protocol.
Options: :height - Visible height in lines (0 = show all) :width - Width constraint (0 = unlimited) :cursor - Initial cursor position (default 0) :title - Optional list title :show-title - Show title (default true if title provided) :cursor-style - Style for selected item :item-style - Style for unselected items :title-style - Style for title :cursor-prefix - Prefix for selected item (default "> ") :item-prefix - Prefix for unselected items (default " ") :show-descriptions - Show item descriptions (default false) :infinite-scroll - Wrap around at ends (default false) :id - Unique ID
Create a list component. Items can be strings, maps with :title/:description, or any type implementing the ListItem protocol. Options: :height - Visible height in lines (0 = show all) :width - Width constraint (0 = unlimited) :cursor - Initial cursor position (default 0) :title - Optional list title :show-title - Show title (default true if title provided) :cursor-style - Style for selected item :item-style - Style for unselected items :title-style - Style for title :cursor-prefix - Prefix for selected item (default "> ") :item-prefix - Prefix for unselected items (default " ") :show-descriptions - Show item descriptions (default false) :infinite-scroll - Wrap around at ends (default false) :id - Unique ID
(list-init lst)Initialize the list, returns [list cmd]. Currently just returns the list with no command.
Initialize the list, returns [list cmd]. Currently just returns the list with no command.
(list-update lst msg)Update list state based on a message. Returns [new-list cmd] or [list nil] if message not handled.
Update list state based on a message. Returns [new-list cmd] or [list nil] if message not handled.
(list-view lst)Render the list to a string.
Render the list to a string.
Protocol for items in a list.
Protocol for items in a list.
(item-description item)Get an optional description for the item.
Get an optional description for the item.
(item-title item)Get the display title for the item.
Get the display title for the item.
(page-down lst)Move cursor down by one page.
Move cursor down by one page.
(select-first-match lst pred)Select the first item matching a predicate.
Select the first item matching a predicate.
(selected-index lst)Get the currently selected index.
Get the currently selected index.
(selected-item lst)Get the currently selected item, or nil if list is empty.
Get the currently selected item, or nil if list is empty.
(set-height lst height)Set the visible height.
Set the visible height.
(set-items lst new-items)Set the items, adjusting cursor if needed.
Set the items, adjusting cursor if needed.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |