Inline Database

A view of records inside a document, with its title and a switcher between its views.

4
CandidateStageRole
1Amara OkaforInterviewBackend engineer
2Jonas WeberScreenProduct designer
3Sofia MarinoOfferBackend engineer
4Kenji SatoScreenSupport lead
4 rows

Installation

pnpm dlx shadcn@latest add checkfu/uicontext/inline-database

Usage

import { InlineDatabase } from "./ui/uicontext/components/kit/InlineDatabase.ts"
const Message = UiSchema.TaggedEnum({	PickedView: { view: Schema.String },	AddedTask: {},})// the frame around a record view: pass the Table, Board or List that shows the current viewexport const Tasks = (h: Html.H<typeof Message.Type>, view: string, count: number, records: View.Content<typeof Message.Type>) =>	InlineDatabase(h, {		props: {			block: "tasks",			title: "Launch tasks",			views: [{ id: "all", label: "All tasks", layout: "table" }, { id: "board", label: "By status", layout: "board" }],			view,			count,			create: "New task",		},		onEmit: {			RequestedView: ({ view }) => Message.PickedView({ view }),			RequestedCreate: () => Message.AddedTask(),			RequestedTitle: () => undefined,			RequestedOpen: () => undefined,		},		slots: { view: records },	})

Examples

Read-only

With can: [] the title can't be renamed and there's no add button; views still switch.

Release log

3
  • Offline draftsFeb 18
  • Shared templatesJan 27
  • Faster searchJan 9

Many views, loading and empty

In a narrow column the views fold into a menu. loading marks the view while its records arrive, and empty speaks for a view with none.

3
  • Invoice shows the wrong tax ratePriya
  • Can't reset password from the appMarco
  • Export stops at 10,000 rowsPriya

API reference

Props

InlineDatabase props
NameTypeDefaultDescription
blockrequiredstring—The database block's id in the document (or any id unique on the page outside an editor)
titlerequiredstring—The collection's name
viewsrequiredDatabaseView[]—The saved views the switcher offers: an id, a name and a layout each
viewrequiredstring—The view shown now, by id
countnumber—How many records the view shows
canCan(["edit", "create"])both"edit" renames the collection, "create" adds records; both by default
createstring—The add button's words: "New task"
loadingboolean—The records are on their way: the view says so instead of looking empty
emptystring—What to say when count is 0, in place of the view: "No tasks in this view yet"

Events

InlineDatabase events
EventPayloadDescription
RequestedView{ block: string; view: string }Show another saved view
RequestedTitle{ block: string; title: string }The person renamed the collection
RequestedOpen{ block: string }Open the collection as a page of its own
RequestedCreate{ block: string }Add a new record to the collection

Slots

view

Accessibility

  • The views are tabs: one Tab stop, the arrow keys move between them and show each.
  • The title is a button that turns into a field; Enter keeps the new name and Escape cancels.

Source