Version History

A file's named versions and autosaves, to preview and restore.

Installation

pnpm dlx shadcn@latest add checkfu/uicontext/version-history

Usage

import { type FileVersion, VersionHistory } from "./ui/uicontext/components/canvas/VersionHistory.ts"
const Message = UiSchema.TaggedEnum({ PickedVersion: { id: Schema.String }, ToggledRun: { first: Schema.String } })export const History = (h: Html.H<typeof Message.Type>, versions: ReadonlyArray<FileVersion>, now: string) =>	VersionHistory(h, {		versions, current: null, open: [], now,		onPick: (id) => Message.PickedVersion({ id }),		onToggleRun: (first) => Message.ToggledRun({ first }),	})

API reference

Options

VersionHistory options
NameTypeDescription
versionsrequiredFileVersion[]—
currentrequiredstring | nullThe version shown now; the newest is the live file
openrequiredstring[]Runs of autosaves people opened, by the id of the first
nowrequiredstring—
onPickrequired(id: string) => Message—
onToggleRunrequired(first: string) => Message—
onRestore(id: string) => Message—
onName(id: string) => Message—

Source