CRUD / foldkit-mixins-crud
Render custom rows with RowListView
When a list represents navigation items or pickers rather than tabular columns, use RowListView to render a <ul> / <li> list with the same loading, empty, retry, and pagination handling as ListView:
import { RowListView } from 'foldkit-mixins-crud'
const PageList = RowListView.forMessages<Message>().define<PageRow>({ name: 'Pages' })
const pages = (model: Model, h: HtmlBuilder<Message>): Html =>
PageList(
{
page: SitePages.read(model),
row: (page, h) => [h.span([], [page.label])],
onOpen: page => Message.OpenedPage({ id: page.id }),
onRetry: Message.RetriedPages(),
},
h,
)RowListSlots exposes root, status, list, row, open, more, and retry. Every row element carries data-row-key (including in server-rendered HTML) so you can restore focus with Dom.focus(`[data-row-key="${CSS.escape(id)}"] button`).
Wire row clicks, pagination, and sorting in update
onOpen, onMore, and column sort headers only dispatch your Messages—rendering never triggers queries on its own. Handle those Messages in update to open the placed editor (open(id)), advance your query window, or change the sort order.
Recover from failed reads with onRetry
When a read fails, the view renders a role="alert" paragraph (keeping stale rows visible below it during a failed refresh). Pass onRetry to display a retry button, and return a Dom.focus Command in your retry handler so keyboard focus moves to the list when the retry button disappears:
PostTable({ page: Posts.page(model), onRetry: Message.RetriedPosts() }, h)
const retryPosts = (current: Model) => ({
model: Posts.refresh(current),
// Also emit your Dom.focus('#Posts', { makeFocusable: true }) Command here.
})DetailView behaves identically, placing its alert and retry button above the description list.
Reuse loading, empty, and failure status views
Export Loading, Empty, and Failure for standalone status slots outside lists or details:
import { Empty, Failure, Loading } from 'foldkit-mixins-crud'
Loading.view(slots.status, h, 'Loading…')
Empty.view(slots.status, h, 'Nothing yet.')
Failure.view(slots.status, h, 'The pages could not be read.')Loading and Empty render role="status" (aria-busy while loading), and Failure renders role="alert". Attaching Utilities.busyReveal from foldkit-mixins/utilities delays showing loading text so fast responses never flash.