CRUD / foldkit-mixins-crud

Draw an editor, delete confirmation, and toolbar

EditorView wraps your edit form with status feedback, ConfirmView asks before deleting, and Toolbar lays out list controls:

ts
import { ConfirmView, EditorView, Toolbar } from 'foldkit-mixins-crud'

const PostEditorView = EditorView.forMessages<Message>().define()
const DeletePost = ConfirmView.forMessages<Message>().define()
const PostTools = Toolbar.forMessages<Message>().define()

PostTools({ search: h.input([h.Type('search'), h.AriaLabel('Search titles')]) }, h)
PostEditorView(
  {
    id: 'post-editor',
    status: 'Editing',
    title: 'Edit post',
    form: h.form([], []),
    onClose: Message.ClosedPost(),
  },
  h,
)
DeletePost(
  {
    id: 'delete-post',
    status: 'Confirming',
    name: Option.some('Hello'),
    onConfirm: Message.ConfirmedDelete(),
    onCancel: Message.CancelledDelete(),
  },
  h,
)

Each editor status updates the section cleanly while keeping the draft visible on failures:

StatusStatus lineForm shown
ClosedNothing drawn—
LoadingLoading… (aria-busy)No
NotFound, LoadFailedAlert with optional onRetryNo
EditingNoneYes
Saving, SavedSaving… (aria-busy), Saved.Yes
SaveFailed, ConflictShown in the form's failure SlotYes (draft kept)
MovedNotice that record changed elsewhereYes

When placing EditorView inside a foldkit-mixins-ui Dialog or Drawer, answer the dialog's Closed OutMessage with editor.close() so the editor stops holding the record open. ConfirmView renders a role="group" asking Delete {name}? and disables confirmation while name is None.

Style views with theme recipes

foldkit-mixins-crud/recipes provides token-backed Styles for List, RowList, Editor, Confirm, and Toolbar:

ts
import { Style } from 'foldkit-mixins'
import { ListSlots } from 'foldkit-mixins-crud'
import { List } from 'foldkit-mixins-crud/recipes'

const StyledTable = ListView.forMessages<Message>()
  .define(PostList)
  .pipe(Style.attach(Style.forSlots(ListSlots)(List({}))))

Customize recipes with .extend(...) (for example, List.extend({ base: { cell: { padding: '1rem 0.5rem' } } })({})) rather than forking them.