@protoyard/views-ui
v1.9.4
Published
Svelte 5 components for Protoyard's rich views kit (board, calendar, timeline, data grid, tree, simulated map, editor, activity, notifications, files, settings, states, command palette). One lazy subpath per view, never re-exported from @protoyard/ui.
Maintainers
Readme
@protoyard/views-ui
Svelte 5 components for Protoyard's rich views kit (ADR-022): board, calendar,
timeline, data grid, tree, simulated map, editor, activity, notifications,
files, settings, states and an app command palette. The engines live in
@protoyard/views.
Where each view comes from (ADR-044):
- Texuli view adapters: board, calendar, timeline, grid (
DataGrid), tree (TreeView), map, files and activity (ActivityFeed) render the matching@texuli/datacomponent.virtual-listre-exports@texuli/data/virtual-list. The grid toolkit and settings rows keep their stable Protoyard props while composing Texuli controls; Lucide glyphs render throughIconorLucideIconfromtexuli/icons. - Protoyard host behavior: comments, notification service callbacks,
Markdown source commands and outline editing retain Protoyard's callbacks,
state and keyboard contracts. The grid filter editor wraps Texuli's
@texuli/data/filter-builderwhile retaining Protoyard's nullable value contract. Texuli's@texuli/editor/markdowncodec now reads host inline extensions in the@{id|label}form@protoyard/views/editorstores mentions in (G48), and reads the\@escape stored text uses for a literal@(G100, Texuli 0.10.0); their codec test was removed in PLAN_009. The editor does not use Texuli'screateInlineExtensionsorEDITOR_EXTENSION_SIGILS(Texuli 0.6.0): it still parses with@protoyard/views/editor, because its document model and source commands are a public Protoyard API.NotificationCenterrenders Texuli's@texuli/data/activity/inboxwithallowMarkUnread={false}(G50) and keeps recipient-scoped rows and the mark-read service callbacks. Itslabelsprop (Partial<NotificationCenterLabels>: Texuli's inbox labels plus its own) is forwarded whole to the inbox.
Some adapters still accept props from the earlier Protoyard API that they do not forward; each section below lists them. The mapping table is in TEXULI. The views kit guide has the selection guide, service contract, measured chunks and limits.
Install
{
"dependencies": {
"@protoyard/views-ui": "workspace:*",
"@protoyard/views": "workspace:*",
"@protoyard/ui": "workspace:*"
}
}Import the kit styles after Tailwind, themes and @protoyard/ui, so Tailwind
scans the kit's markup:
@import '@protoyard/renderer-svelte/app.css';
@import '@protoyard/views-ui/styles.css';
@source './';One subpath per view
There is no root entry. Import a view only from a lazy route screen, so each view stays its own chunk and adds 0 KB to a prototype's initial JS:
// src/routes.ts
{ path: '/board', name: 'Board', load: () => import('./screens/Board.svelte') }
// src/screens/Board.svelte imports from '@protoyard/views-ui/board'Subpaths: ./board, ./calendar, ./timeline, ./sheet, ./canvas, ./grid, ./tree, ./map,
./editor, ./activity, ./notifications, ./files, ./settings,
./states, ./commands, ./scenarios, ./virtual-list, ./player.css,
./blocks.css and ./styles.css. Views are never re-exported from
@protoyard/ui.
Three stylesheets scan different sets of view families:
player.css: the board, calendar, map, states and timeline families the prebuilt player renders.blocks.css: only the map and states families that content blocks render (the deck template and generated decks).styles.css: every view family; other hosts should import this one.
Bundle hygiene
tests/bundle-hygiene.test.ts fails when:
- a view statically imports another view's subpath or folder. Only
lib/andstates/are shared, plus the edges declared inDEPENDS(filesmay usetree; the files adapter does not use it today). Dynamic imports are allowed, which is how the activity thread loads the editor; - any file imports
@protoyard/uidynamically, which would put the ui barrel in every initial chunk (see docs/PERFORMANCE.md, Shells); - a runtime value is imported from the
@protoyard/viewsroot instead of an engine subpath; - the exports drift from one subpath per view.
pnpm vitest run packages/views-ui
pnpm --filter @protoyard/views-ui typecheckCalendar (@protoyard/views-ui/calendar)
CalendarView is a host adapter over Texuli's CalendarView
(@texuli/data/calendar/view, also exported here as TexuliCalendarView). It
shows calendar series (with recurrence, from
@protoyard/views/calendar)
as a month, week, day or agenda view. It never writes data itself: moves and
new slots go out through onChange / onCreate, which call the prototype's
services.
<script lang="ts">
import { getRuntime, liveQuery } from '@protoyard/renderer-svelte';
import { CalendarView, type CalendarChange } from '@protoyard/views-ui/calendar';
const runtime = getRuntime();
const persona = runtime.session.principal()?.persona;
const bookings = liveQuery(() => services.listSeries(), { initial: undefined });
// writes.put / writes.delete in one transaction (session.assert → zod → environment.run → db.transaction)
const save = (change: CalendarChange<Booking>) => services.applySeriesWrites(change.writes);
</script>
<CalendarView
query={bookings}
timeZone={persona?.timezone ?? 'UTC'}
locale={persona?.locale ?? 'en-US'}
getTitle={(o) => o.data?.title ?? 'Booking'}
getTone={(o) => (o.data?.status === 'cancelled' ? 'neutral' : 'primary')}
onChange={save}
onCreate={(slot) => services.createBooking({ start: slot.start, end: slot.end })}
onOpen={(o) => navigate(`/bookings/${o.seriesId}`)}
/>What the adapter adds:
- Data:
query(aliveQueryofCalendarSeriesrows) becomes Texuli'sevents, insideQueryStatefor loading, offline, denied and failed states. - Clock: "now" comes from the runtime clock (
useClock), so DevTools time travel moves the now-line and today; passnowfor a fixed time. The visible range is seeded once fromanchoror the clock; later clock jumps leave it in place until the person picks Today. - Series writes: Texuli emits a move (
id,occurrenceId,start,end,allDay,recurring,occurrence). The adapter addsscopeandwrites(fromsplitSeries) and callsonChangethroughrunService. A repeating occurrence always uses scopethis; one-off events useall.newIdnames any series the split creates. - Forwarded props:
viewandanchor(bindable),timeZone,locale,weekStartsOn,getTitle,getTone,onOpen,readOnly,canMove,min,max,slotMinutes,showYear(defaultalwayshere),agendaDaysandlabels(any Texuli calendar label, such asmoreEvents). - Phone agenda (
phone): a day-by-day list instead of the grid, on its own lazy chunk (desktop calendars never load it). It pages byagendaDaysdays (default 7) with Previous, Today and Next, marks today, and renders each event as one button: thechipsnippet ((occurrence, { title, tone, when })) or the title and time. A day with more thanmaxPerDayevents (default 3) shows "+N more events", a toggle (aria-expanded) that lists the rest. WithonCreate, each day has an "Add event" button that creates an all-day slot. Moving events is not offered in this mode.
<CalendarView query={bookings} phone maxPerDay={2} {getTitle} onOpen={openBooking}>
{#snippet chip(occurrence, { title, when })}
<strong>{title}</strong> <small>{when}</small>
{/snippet}
</CalendarView>What Texuli's view does (see its docs for the full keyboard model):
- Views: month, week, day (a time grid with an all-day row and a now-line) and agenda. M / W / D / A switch views.
- Moving: drag an event, press Alt or Control with an arrow key, or press Space to grab it, move with the arrows and drop with Space or Enter. Shift+F10 or a right-click opens a lazy Move menu. The agenda view does not move events.
- Creating: with
onCreate, Enter on a focused empty slot or a click on an empty part of a day creates a one-hour event; date buttons create all-day ones. - Day overflow: a month cell shows
maxPerDayevents (default 3) and a "N more events" note (rename it withlabels.moreEvents). WithonMoreEvents(date)the note is a button named "N more events on " that reports the ISO day, for example to open the day view. - Event content: the
eventsnippet ((item, { view, compact, time })) renders each chip's content in month, week, day, the all-day row and agenda; the chip stays Texuli's button. Render no controls inside it. - Limits: events cannot be resized, and there is no "this / following /
all" prompt for repeating events. The phone agenda uses
chip, notevent.
pnpm vitest run packages/views-ui/tests/calendar.test.tsMap (@protoyard/views-ui/map)
SimulatedMap is a host adapter over Texuli's MapView (@texuli/data/map).
It draws a fictional basemap (Port Meridian by default) as SVG, with markers,
clusters, routes and geofences, from the offline engine in
@protoyard/views/map. No tiles,
no network, no real geography.
<script lang="ts">
import { type MapMarker, SimulatedMap } from '@protoyard/views-ui/map';
let selected = $state<string | null>(null);
const markers: MapMarker[] = vans.map((van) => ({
id: van.id, label: van.name, detail: van.status, lng: van.position.lng, lat: van.position.lat,
tone: van.late ? 'warning' : 'primary', shape: 'square', glyph: 'V',
}));
</script>
<SimulatedMap
{markers}
routes={[{ id: 'loop', label: 'Morning loop', stops, progress: done / total }]}
fences={zones}
listLabel="Vans on the map"
bind:selected
/>What the adapter maps:
- Markers and routes: Protoyard tones pass through as Texuli's strong
tones; the
triangleshape becomes Texuli'spin. - Selection:
selected(string | null) andselectedIdare both bindable and kept in step;onSelectreceives the Protoyard marker. - List: the place list sits below the map by default
(
listPlacement="below"; Texuli's default isside), and its region is named bylistLabel. - Forwarded props:
fences,basemap,label,direction,cellPx(cluster cell size;1keeps nearby markers separate) andonPick.
What Texuli's view does:
- Moving: zoom in, zoom out, reset and pan buttons. On the focused map,
the arrow keys pan, + and − zoom and 0 resets. With
onPick, a click without dragging, or Enter or Space on the focused map, reports a point. - Markers are named by
labelanddetail, and drawn with a shape, a glyph and a tone (never color alone). Nearby markers cluster; activating a cluster zooms in. - Place list: a virtualized list of every marker, route and fence, with
aria-setsize/aria-posinsetandaria-currenton the selected place. - Positions come from props only. The prototype advances them through its services and the runtime clock; the map runs no timers that write data.
- Geofence editing is not implemented.
editableFenceIdandonFenceChangeare accepted and forwarded, but no handles are drawn.
No unit test covers this view since PLAN_009 kept host-adapter tests for board, calendar, grid, sheet and canvas only.
Settings (@protoyard/views-ui/settings)
Settings page patterns. Writes go through the prototype's services with
runService; nothing here touches data.
| Component | What it does |
| --- | --- |
| SettingsLayout | Title, a section nav (aria-current on the open one) and the open section, rendered fresh per section ({#key}). Below md it is a list → detail flow: picking a section focuses its heading, and the back button returns focus to the list. |
| SettingsSection | A titled card for a group of rows, with an optional footer. |
| SwitchRow, SelectRow, RadioRow | Labelled preference rows with descriptions (aria-describedby); a disabled switch says why (disabledReason). |
| SaveBar | Appears while dirty. Save runs onSave and shows the Button spinner until its promise settles; a failed runService result with validation issues fills errors (bindable) and lists them. While dirty it guards navigation: hash changes are stopped before the router sees them and an in-app "Leave without saving?" dialog asks ("Keep editing" / "Discard and leave"); a reload or tab close asks through the browser (beforeunload). |
| DangerZone | A destructive action behind a dialog where the person types the exact confirmText; a failed result keeps the dialog open. |
| guardHashNavigation | The guard on its own, for custom forms. |
Composing with the SaaS kit
@protoyard/saas-ui ships a complete Settings screen (profile, security,
members, notifications) and does not need changing. When a prototype wants
its own settings page, build it from these patterns on top of the same
@protoyard/saas engine services:
<script lang="ts">
import { getRuntime, runService } from '@protoyard/renderer-svelte';
import { createSettingsServices, DEFAULT_SAAS_NOTIFICATION_PREFERENCES } from '@protoyard/saas';
import { SaveBar, SettingsLayout, SettingsSection, SwitchRow } from '@protoyard/views-ui/settings';
const settings = createSettingsServices(getRuntime());
let saved = $state({ ...DEFAULT_SAAS_NOTIFICATION_PREFERENCES });
let draft = $state({ ...DEFAULT_SAAS_NOTIFICATION_PREFERENCES });
let errors = $state({});
const dirty = $derived(JSON.stringify(draft) !== JSON.stringify(saved));
$effect(() => {
void runService(() => settings.notificationPreferences()).then((result) => {
if (!result.ok) return;
saved = { ...result.value };
draft = { ...result.value };
});
});
async function save() {
const result = await runService(() => settings.updateNotificationPreferences(draft), { success: 'Preferences saved' });
if (result.ok) saved = { ...draft };
return result; // validation issues show in the SaveBar
}
</script>
<SettingsLayout sections={[{ id: 'notifications', label: 'Notifications' }]}>
{#snippet children(section)}
<SettingsSection title="Email">
<SwitchRow label="Product updates" bind:checked={draft.productUpdates} />
<SwitchRow label="Security alerts" bind:checked={draft.securityAlerts} />
<SwitchRow label="Workspace activity" bind:checked={draft.workspaceActivity} />
</SettingsSection>
{/snippet}
</SettingsLayout>
<SaveBar {dirty} bind:errors onSave={save} onDiscard={() => (draft = { ...saved })} />- Loading: import
./settingsfrom a lazy route; it adds nothing to the initial JavaScript of routes that do not use it.
States (@protoyard/views-ui/states)
QueryState is the one boundary for a liveQuery result, so no screen shows
a blank or a fake success. Every view in this kit uses it for its own
data-less states.
<script lang="ts">
import { liveQuery } from '@protoyard/renderer-svelte';
import { QueryState } from '@protoyard/views-ui/states';
let attempt = $state(0);
const deals = liveQuery(() => services.listDeals(), { initial: [], deps: () => [attempt] });
</script>
<QueryState query={deals} label="Loading deals" emptyTitle="No deals yet" onRetry={() => attempt++}>
{#snippet children(list)}<DealTable rows={list} />{/snippet}
{#snippet emptyAction()}<Button onclick={() => runService(() => services.createDeal(draft))}>New deal</Button>{/snippet}
</QueryState>| State | When | Shows |
| --- | --- | --- |
| loading | before the first result | nothing for 150 ms (like the renderer's pending bar), then a skeleton (role="status" named by label), or your loading snippet |
| reloading | loading again with data on screen | the data, with aria-busy |
| empty | isEmpty(current) (default: undefined, null or []) | EmptyState named by emptyTitle, with emptyAction |
| offline | SimulatedServiceError with code offline | an alert that says the simulated network is off, with retry |
| denied | PermissionDeniedError | an alert naming the missing capability and saying roles are simulated (switch persona in DevTools); no retry, since retrying cannot help |
| failed | any other error | an alert with the error message and retry |
- Errors are sorted by class (
classifyQueryError, exported), never by message text; a class with the samenamealso counts, because a duplicated core copy breaksinstanceof(the renderer'srunServicedoes the same). onRetryshould re-run the query, e.g. by bumping a value in itsdeps.- The titles and messages come from the prototype's dictionary
(
protoyard.views.query-state.*, listed in docs/TEXULI.md).classifyQueryError(error, messages?)takes a lookup such asuseMessages()for code outside the component. - Every adapter in this package uses it for its own data-less states, so it ships with any view you import.
Commands (@protoyard/views-ui/commands)
An app command palette on ⌘K (Mac) / Ctrl+K (elsewhere). DevTools keep
Ctrl/⌘ + ., keys typed inside the DevTools panel are ignored, and mod+k
and mod+. cannot be registered as action shortcuts. The pure registry and
contracts are also available from @protoyard/views/commands.
<script lang="ts">
import { getRuntime, runService } from '@protoyard/renderer-svelte';
import { AppCommandPalette, createCommands } from '@protoyard/views-ui/commands';
import { routes } from './routes.ts';
const runtime = getRuntime();
const commands = createCommands(runtime, routes); // pages from defineRoutes metadata
commands.register({
id: 'new-deal',
label: 'New deal',
shortcut: 'mod+shift+n',
capability: 'deals:create',
run: () => services.createDeal(draft), // the palette wraps it in runService
});
// when a record opens: commands.addRecent({ id: deal.id, label: deal.name, path: `/deals/${deal.id}` })
</script>
<AppCommandPalette registry={commands}>
{#snippet trigger({ open, keys })}
<Button variant="outline" onclick={open}>Search <Kbd>{keys.join('')}</Kbd></Button>
{/snippet}
</AppCommandPalette>- What it lists: recent records first, then pages (routes with a
name; routes with:paramsor*are reached through recent records), then actions. Everything with acapabilityis filtered throughsession.can, and the list is re-filtered when the persona switches (session.subscribe).createCommandsreads onlypath,name,descriptionandcapabilityfrom route metadata and never callsload, so no screen chunk is fetched. - Running: pages navigate and close. Actions run through
runService(pending bar, toasts for denied or simulated failures) with the capability asserted first; the item shows a spinner andaria-busyuntil the promise settles, and the palette closes only on success. Registered shortcuts run their action from anywhere; shortcuts withoutmodnever fire while typing in a field. - Hints: shortcuts show as
Kbdkeys,⌘ ⇧ Non Mac andCtrl Shift Nelsewhere (platform read fromnavigatorin UI code only), witharia-keyshortcutson the item. - Async search: register an abortable source with
commands.registerSearchSource((query, signal) => search(query, signal)). The palette displays pending and failure feedback and ignores stale results. - Nested steps: an action may expose static or lazy
children; selecting it opens those results in the same dialog with a Back control. - Create fallback: pass
createFallback(query)tocreateCommandsto offer a create action for typed text when ordinary search has no match. Selection still runs throughrunServiceand displays pending feedback. - Scopes: actions may list
scopes. They appear only when one matches the registry's active scopes, updated throughcommands.setScopes(...). - Shortcut sheet:
ShortcutSheetrenders explicitly supplied hotkey data in accessible groups, formats chords for Mac or other platforms, and filters scoped bindings againstactiveScopes. It supports label/chord search and never registers keyboard listeners; the host remains responsible for dispatch.
<script lang="ts">
import { ShortcutSheet } from '@protoyard/views-ui/commands';
import type { HotkeyBinding } from '@protoyard/views/commands';
const bindings: HotkeyBinding[] = [
{ id: 'save', label: 'Save', group: 'Editing', keys: ['mod+s'], scopes: ['editor'] },
];
</script>
<ShortcutSheet {bindings} activeScopes={['editor']} />- Loading: the palette dialog is a separate chunk fetched on first open.
Editor (@protoyard/views-ui/editor)
A dependency-free Markdown source editor on Texuli's Textarea (no
contenteditable library). Text commands and the document model are the pure
functions of @protoyard/views/editor. Values leave through typed callbacks
(bind:value, onChange, onDraft); the editor never writes database tables.
<script lang="ts">
import { MarkdownEditor, RichTextView } from '@protoyard/views-ui/editor';
let body = $state(draft?.body ?? '');
</script>
<MarkdownEditor
bind:value={body}
label="Comment"
mentions={people.map((p) => ({ id: p.id, value: p.handle, label: p.name }))}
references={deals.map((d) => ({ id: d.id, value: d.code, label: d.name }))}
maxLength={2000}
onDraft={(text) => services.saveDraft(text)}
onChange={(text) => { /* optional live hook */ }}
/>
<!-- Read-only: safe document model (no {@html}) -->
<RichTextView value={body} label="Comment body" />- Toolbar and shortcuts (
modis ⌘ on Mac, Ctrl elsewhere; matched onevent.code): boldmod+B, italicmod+I, strikethroughmod+Shift+X, inline codemod+E, linkmod+K(it does not reach the app command palette), headingmod+Alt+2, bulletedmod+Shift+8, numberedmod+Shift+7, taskmod+Shift+9and quotemod+Shift+.lists, code blockmod+Alt+C. The toolbar is one tab stop with arrow-key focus. Enter continues lists, and Enter on an empty item ends them. - Slash commands: typing
/at the start of a line (or after whitespace) opens a command listbox (heading, lists, quote, code block). Filter by name; arrows move, Enter or Tab applies, Escape closes. Override withslashCommands(DEFAULT_SLASH_COMMANDSis the built-in set). - Completion: typing
@or#(after a space or at the start) offersmentionsorreferencesin a listbox anchored at the caret (mirror-div measurement). The textarea keeps its textbox role and points at the list witharia-autocomplete,aria-controlsandaria-activedescendant(the textbox-with-popup form of the ARIA combobox pattern; a textarea may not take thecomboboxrole). Arrow keys move, Enter or Tab inserts@value, Escape closes only the list. - Preview: Write / Preview tabs (default) or
layout="split". The preview renders the safe parser's AST (@protoyard/ai/markdown) as elements and text only, never{@html}; links passsafeHrefand imagessafeImageSrcagain, sojavascript:links render as text and remote ordata:images as their alt text. Headings start ath2because the preview sits inside a page.MarkdownPreviewis also exported for showing saved Markdown. Scrollable fenced-code<pre>blocks usetabindex="0"and an accessible name (axescrollable-region-focusable), matching ui-kitCodeBlock(its unit test was removed in PLAN_009). - RichTextView: read-only renderer over
parseEditorDocument/EditorDocumentfrom@protoyard/views/editor. Mentions (@{id|label}), marks, lists, quotes and code fences become elements; unsafehrefvalues are stripped to plain text. OptionalonLinkClick/onMentionClickcallbacks — still no database writes. - LinkMenu: small dialog to apply or remove a URL; refuses non-web
schemes via
safeHref. Use beside a custom toolbar if you want an explicit URL field instead of the defaultmod+Kplaceholder link. - Limits and drafts:
maxLength(default 5,000) sets the textarea limit and a counter, and a command that would pass it is refused with a polite announcement.onDraftruns after typing pauses (draftDelayMs, default 800 ms), on blur and on unmount. - Size: the real-build guard measured the editor at 9,508 B gzip over the
shell on Texuli 0.5.0 (ceiling 9,958 B; see
docs/VIEWS.md). Slash and
RichTextViewstay in the same lazy./editorsubpath. - Limits: toolbar commands set the textarea value directly, so the browser's undo history does not include them.
Board (@protoyard/views-ui/board)
BoardView is the rich kanban: a host adapter over Texuli's Board
(@texuli/data/board, also exported here with its helpers), on the
@protoyard/views/board engine. The simple Kanban in @protoyard/ui is
unchanged; use it for small boards without ranks, lanes or WIP limits.
<script lang="ts">
import { liveQuery } from '@protoyard/renderer-svelte';
import { BoardView } from '@protoyard/views-ui/board';
const tasks = liveQuery(() => services.listTasks(), { initial: [], deps: () => [] });
</script>
<BoardView
query={tasks}
label="Sprint board"
columns={[
{ id: 'todo', title: 'To do' },
{ id: 'doing', title: 'Doing', wip: { soft: 3, hard: 5 } },
{ id: 'done', title: 'Done' },
]}
lanes={[{ id: 'web', title: 'Web' }, { id: 'mobile', title: 'Mobile' }]}
getId={(t) => t.id} getColumn={(t) => t.status} getLane={(t) => t.team}
getRank={(t) => t.rank} getLabel={(t) => t.title}
onMove={(move) => services.moveTask(move)}
onOpen={(t) => navigate(`/tasks/${t.id}`)}
>
{#snippet card(task)}<span class="font-medium">{task.title}</span>{/snippet}
</BoardView>What the adapter adds:
- Data:
querybecomes Texuli'sitems, insideQueryState(loading, errors withonRetry, offline). - Moves:
onMove(move, item)runs throughrunService. The service writes the column, lane and rank (andmove.rerank, when older data needed fresh ranks) in one transaction and must enforce hard WIP limits too. - Opening: with
onOpen, the card content becomes a button that opens the card without starting a drag. - Labels:
labelnames the board andemptyColumnText(default "No cards") fills empty cells;labelsoverrides any other Texuli label. - Forwarded props:
columns,lanes, the accessors,canMove,isLocked,density,dir,class, and thecolumnHeaderandcolumnFootersnippets ((column, { count })). - In-column create: with
onCreate(column), each column ends with an "Add card" button (named "Add card to "; rename it withcreateLabel, limit it withcanCreate(column)). On a board with lanes the button sits in each column × lane cell instead ("Add card to , ") andonCreate(column, lane)receives the lane. It runs throughrunServiceand shows pending feedback; the service decides what the new card holds (or opens a form). - Lane collapse: each lane heading is a Texuli toggle (0.14.1).
Collapsed lanes, bindable as
collapsedLanes(ids, withonCollapsedLanesChange), hide their cards behind a count and still count in column totals and WIP limits.collapsibleLanes(two or more lanes) adds a "Lanes" toolbar that folds a lane in every column at once.
What Texuli's board does:
- Keyboard: focus a card, press Space or Enter to pick it up, choose a position with the arrows (Shift + Up/Down changes lane), and press Space or Enter to drop. Escape cancels. Every step is announced.
- Move menu: each card has a lazy "Move" menu listing columns and positions.
- Pointer drag starts after a small threshold (
DRAG_THRESHOLD_PX), so a click still works. - WIP: each column shows its count against the hard limit, with warn and full styling.
- Motion only without
prefers-reduced-motion.
pnpm vitest run packages/views-ui/tests/board.test.tsTimeline (@protoyard/views-ui/timeline)
TimelineView is a host adapter over Texuli's TimelineView
(@texuli/data/timeline, also exported here as TexuliTimelineView). Texuli
renders a Gantt plan with dependency links, critical path, progress, zoom and
a today line. It takes schedule task rows and dependencies from
@protoyard/views/timeline:
<TimelineView
query={tasks}
{dependencies}
bind:zoom
now={runtime.clock.now()}
getTitle={(task) => task.title}
getProgress={(task) => task.progress}
onReschedule={(changes) => services.rescheduleTasks(changes)}
/>onReschedule receives every date change produced by the dependency cascade,
through runService; persist the full list in one service transaction and
validate permissions and dependency rules there. Without the callback the
timeline is read-only.
- Data:
querybecomes Texuli'stasks, insideQueryState(passonRetryfor an actionable retry). - Clock: pass
now, orruntimeto follow the runtime clock. - Zoom: bindable
zoomacceptsday,week,monthorquarter. - Keyboard: Tab reaches each task bar. Space picks up a task; ←/→ changes its dates one day at a time; Shift+Space picks up its end for resizing; Enter saves and Escape cancels. A live region announces previews.
- Pointer: drag a bar to move it or drag its ends to resize it.
- Texuli extras: a "Milestones only" toggle and an unscheduled tray for tasks without dates.
- Forwarded (Texuli 0.14.0):
onOpen(task bars and the unscheduled tray),maxRows(with a truncation notice),getGroupreturning{ id, label, band?: { start, end, label?, tone? } }(a header row per group, with the band drawn across it), bindablecollapsedgroup ids withonCollapsedChange,onGroupAdd(group)(an Add action on each group header, run throughrunService), bindableselectedRowwithonRowSelect(task),markers({ at, label, tone? }vertical lines) andlabels.
<TimelineView
query={tasks}
getGroup={(task) => ({ id: task.projectId, label: task.projectName, band: projectBand(task) })}
bind:collapsed
bind:selectedRow
onRowSelect={(task) => openPanel(task.id)}
onGroupAdd={(group) => services.addTask({ projectId: group.id })}
markers={[{ at: '2026-10-30', label: 'Review window closes', tone: 'warning' }]}
/>pnpm vitest run packages/views-ui/tests/timeline.test.tsCanvas (@protoyard/views-ui/canvas)
CanvasView is a thin host adapter over @texuli/canvas/editor: an infinite canvas of shapes,
text, sticky notes, frames and connectors with snapping and guides, a JSON clipboard, undo, a
minimap and a shape tree for screen readers. The surface is one role="application": Tab moves
between shapes in reading order, arrow keys move them, Enter edits text.
<CanvasView query={board} onChange={(canvas) => services.boards.saveCanvas(id, canvas)} />queryis a liveQuery of one stored canvas (Texuli'sCanvasDocumentJSON). It is untrusted:validateCanvaschecks it first (closed shapes and palette, limits; text paints as SVG text, never markup), and an invalid one shows an alert instead of the editor.onChangeis the service that persists every change (runService); a refused save (falseor a throw) puts the stored canvas back. Without it the canvas is read-only. A change that comes back unchanged through the query keeps the editor's canvas, so undo survives.files(default on): "Download SVG" exports the canvas with escaped text; "Import JSON" (editable only) replaces the canvas with a file that passesloadUntrustedCanvas.resolveImage(ref)turns an image shape's ref into a URL, which still passes Texuli's URL policy.- Also exported:
validateCanvas,loadUntrustedCanvas,createCanvas,CANVAS_LIMITSandcanvasToSvg. - Scenario data:
generateCanvasBoard(ctx, { level })from@protoyard/views/scenarios(a fictional planning board:empty,typical,densewith 1,500 notes, oredgewith nested frames, a rotated and a locked note and free and frame-to-frame connectors), andviewsFragments.canvas(level).
pnpm vitest run packages/views-ui/tests/canvas.test.tsSheet (@protoyard/views-ui/sheet)
SheetView is a thin host adapter over @texuli/sheets/view: an accessible spreadsheet (one tab
stop, arrow keys, Enter or F2 to edit, undo and redo, TSV copy and paste) with a formula bar and
Texuli's closed, bounded formula language (54 functions; cycles show #CYCLE!, overruns
#LIMIT!, nothing throws or hangs).
<SheetView query={workbook} onChange={(sheet) => services.budget.save(sheet)} {runtime} />queryis a liveQuery of one stored workbook (Texuli'sSheetDocumentJSON). It is untrusted:validateSheetchecks it first, and an invalid one shows an alert instead of the grid.onChangeis the service that persists every edit (pending feedback throughrunService); a refused save (falseor a throw) puts the stored workbook back. Without it the sheet is read-only. An edit that comes back unchanged through the query keeps the view's workbook, so undo history and focus survive the round trip.TODAY()andNOW()read the runtime's simulated clock (ornow), never the system clock.csv(default on): "Download CSV" exports the active sheet's computed values with formula injection neutralized; "Import CSV" (editable only) adds a CSV file as a new sheet, with=fields kept as text.csvImport={false}hides the import whenonChangesaves only existing sheets; a refused import puts the shown sheet back.- Also exported:
validateSheet,createSheet,createWorkbook,displayValue,SHEET_LIMITS,csvToSheetandsheetToCsvfrom@texuli/sheets. - Scenario data:
generateSheetWorkbook(ctx, { level })from@protoyard/views/scenarios(a fictional yearly budget;empty,typical,densewith 2,000 lines, oredgewith a division by zero, a cycle and a cross-sheet summary), andviewsFragments.sheet(level).
pnpm vitest run packages/views-ui/tests/sheet.test.tsTree (@protoyard/views-ui/tree)
Two components over { id, parentId, rank } rows and the
@protoyard/views/tree engine:
TreeView(page trees, folders, org charts) is a host adapter over Texuli'sTreeDataView(@texuli/data/tree-view, also exported here).OutlineEditor(an outline of inline titles) is a Protoyard component.
<TreeView
query={pages} label="Pages" bind:expanded bind:selected
getId={(p) => p.id} getParentId={(p) => p.parentId} getRank={(p) => p.rank} getLabel={(p) => p.title}
onSelect={(p) => navigate(`/pages/${p.id}`)}
onMove={(move) => services.movePage(move)}
/>
<OutlineEditor
query={items} label="Plan"
getId={(i) => i.id} getParentId={(i) => i.parentId} getRank={(i) => i.rank} getTitle={(i) => i.title}
onCreate={(input) => services.createItem(input)}
onRename={(item, title) => services.renameItem(item.id, title)}
onMove={(move) => services.moveItem(move)}
onDelete={(item) => services.deleteItem(item.id)}
/>- TreeView adapter:
querybecomes Texuli'sitems, insideQueryState.selectedstays a single id (string | null); Texuli's row checkboxes are multi-select, and the adapter keeps the first selected id and callsonSelectwith its row.onMoveruns throughrunService.expanded(bindable),hasChildren,loadChildrenand theitemsnippet are forwarded.- Not forwarded yet:
onOpen,emptyTitle,height,virtualizeAboveandrowHeightare accepted and ignored.
- TreeView keyboard (Texuli): arrows move focus; Left and Right collapse or expand; Space toggles the row checkbox; Alt+Up/Down reorders among siblings; Tab indents and Shift+Tab outdents. Rows also move by dragging the grip. Moves and load errors are announced.
- OutlineEditor: Enter adds a sibling (focus follows the new item when
onCreateresolves with its id), Tab and Shift+Tab indent and outdent, Alt+↑/↓ move among siblings, ↑/↓ change item, Escape reverts an edit, Backspace on an empty item deletes it (withonDelete). Titles save on blur or Enter and go back to the saved title if saving fails. Rows drag from a grip, and a "Move to…" menu lists only valid parents. Moves show at once witharia-busyand roll back when they fail. Texuli 0.5.0'sTreeDataViewhas no inline-editing/service-move contract; this component remains the Protoyard host adapter and composes Texuli controls.
No unit test covers this view since PLAN_009 kept host-adapter tests for board, calendar, grid, sheet and canvas only.
Grid (@protoyard/views-ui/grid)
DataGrid (tables of records) is a host adapter over Texuli's grid modules,
on the @protoyard/views/grid engine. It picks one of three Texuli
components:
| When | Texuli component |
| --- | --- |
| onCommit is set | EditableDataGrid (@texuli/data/grid-editing) |
| no onCommit and more rows than virtualizeAbove (default 200) | VirtualDataGrid (@texuli/data/grid-virtual) |
| otherwise | DataGrid (@texuli/data/grid-core) |
The three are also exported directly (TexuliDataGrid, EditableDataGrid,
VirtualDataGrid), with CellEditor and createUndoStack.
<DataGrid
query={deals} label="Deals" getRowId={(d) => d.id}
columns={[
{ key: 'name', header: 'Name', type: 'text', editable: true, width: 220 },
{ key: 'stage', header: 'Stage', type: 'enum', options: ['lead', 'won', 'lost'], editable: true },
{ key: 'amountCents', header: 'Amount', type: 'number', format: (v) => money(v) },
]}
onCommit={(deal, key, value) => services.updateDeal(deal.id, { [key]: value })}
onRowOpen={(deal) => navigate(`/deals/${deal.id}`)}
/>- Data:
querybecomesrows, insideQueryState.label(orcaption) names the grid. - Core grid (read-only, few rows):
sortandsearch(bindable),searchable,filter(aFilterNode),selectablewith bindableselected,onRowActivate(oronRowOpen), acellsnippet,empty,density,localeandmaxBlockSize(orheight). One tab stop with the APG grid keys: arrows, Home/End, Ctrl/Cmd+Home/End, PageUp/PageDown; Enter or Space on a header sorts and Shift adds a key; Space toggles a row. - Editing: Enter or F2 (or a double-click) on an
editablecell opens a native editor; Enter saves and Escape cancels. The adapter awaitsonCommit; a failed commit keeps the old value and shows an alert under the cell. Undo and redo needonApplytoo. In this modesearchable,selectableanddensityare forwarded, butsort,filter,celland row activation are not. - Virtual: the rows are windowed (
rowHeight, default 36 px;heightinpxsets the viewport, else 360 px). Cells show formatted text only, with no sorting, filter, selection or editing. - Phones: below
md, the same rows show as cards: the first column is the title and the next four are details, 50 cards at a time with Show more. - Not forwarded:
savedViews,aggregates,activeViewId,onCreateView,onRenameView,onDeleteViewandonViewChangeare accepted and ignored. There is no grouping, column resizing, reordering or pinning UI.
Grid toolkit
These Protoyard components are exported on their own and are not drawn by
DataGrid. Each is controlled, edits plain engine state and calls typed
callbacks:
FilterBuilderedits the engine's filter AST as nested and/or fieldsets (valuebindable,onchange). Every control is labelled and the operators match each column type.completeFilterdrops conditions that have no value yet. The adapter maps Protoyard'scolumns, nullablevalueandonchangeprops to Texuli's recursive filter editor. Analytics uses a separate property-filter grammar in@protoyard/analytics-ui.FacetPicker: a keyboard-first multi-select for one column (arrows, Home/End, Enter or Space toggle; typing searches; Escape closes). Picks are OR within the column and AND with everything else.FilterChipsshows every top-level condition as a removable chip, with "Clear all".SavedViewspicks, saves, renames and deletes views through your callbacks, with pending feedback and a confirm step before deleting. WithcurrentandonUpdate, a changed view shows "Modified", Save changes and Revert.ColumnChooser: a checkbox per column, move up and down, Show all and Reset; the last visible column cannot be hidden.BulkActionBarruns eachBulkActionthroughrunService(pending, aconfirmstep for destructive actions, and the selection clears on success unlesskeepSelection).
Pass the filter they build to DataGrid's filter prop, which only the core
grid applies.
pnpm vitest run packages/views-ui/tests/grid.test.tsActivity (@protoyard/views-ui/activity)
Two components on the @protoyard/views/activity engine:
ActivityFeedis a host adapter over Texuli'sActivityFeed(@texuli/data/activity, also exported here asTexuliActivityFeed).CommentThreadis a Protoyard component.
<CommentThread
query={comments} people={personas} records={deals} currentUserId={me.id}
now={runtime.clock.now()}
canEdit={(c) => c.authorId === me.id}
onSend={(input) => services.addComment(deal.id, input)}
onEdit={(c, body) => services.editComment(c.id, body)}
onDelete={(c) => services.deleteComment(c.id)}
onReact={(c, emoji) => services.toggleReaction(c.id, emoji)}
/>
<ActivityFeed query={activity} people={personas} now={runtime.clock.now()} />Build activity from blueprint audit rows with auditToActivity (and
comments as kind: 'comment' items with their body).
- ActivityFeed adapter:
querybecomes Texuli'sitems, insideQueryState.- Actor names and images come from
people(name,avatar) unless you passgetActorName/getActorSrc. - Forwarded:
now,timeZone,locale,personaId,filter,onFilterChangeandonReactionToggle. - Texuli groups items under day headings relative to
nowand pages them locally. Keys: arrows, Home/End and Enter. - Not forwarded yet:
records, and any other prop (such asonOpenRecord,pageSize,hasMoreoronLoadMore), is accepted and ignored. Kind filter chips are off.
- CommentThread:
- Threads: root comments are shown oldest first, each with one level of replies. A comment that was deleted but still has replies shows as a note.
- Names and avatars: names, avatars and
#references are resolved from ids when shown. A person'savatar(a library id such asav-001, anhttps://URL or a root-relative path) shows through the renderer'savatarImage;avatarSrcoverrides it. Missing or unsafe images show initials. Stored bodies use the editor view's lazyMarkdownPreview; rendering creates elements and text, never HTML. - Composer:
@and#typed in the composer are stored as id tokens. Saving a comment, a reply or an edit goes through the callback inrunService. A new comment shows at once as "Sending…" (witharia-busy) until the promise settles. If saving fails, the draft comes back and the reason is announced. - Edit and delete: both appear only where
canEdit(comment)says so (default: your own); the service still enforces policy. Delete asks first, and the dialog stays open with the error if deleting fails. - Reactions: chips with counts and
aria-pressedfor your own, plus a React picker. Each toggle goes throughonReact. - Rich editor: the
MarkdownEditoris loaded from the editor view when a composer opens. Override its loader withloadEditorwhen needed. It is a separate chunk; activity has no static dependency on another view. While it loads, Texuli'sTextareais used: ⌘/Ctrl+Enter sends, and Escape cancels a reply or an edit.
No unit test covers this view since PLAN_009 kept host-adapter tests for board, calendar, grid, sheet and canvas only.
Notifications (@protoyard/views-ui/notifications)
NotificationCenter accepts rows such as NotificationRow from
@protoyard/views/scenarios or blueprint notification-service rows (id, kind, title, subjectId,
createdAt/at, and readAt). Pass live query results and service callbacks;
the component owns only temporary optimistic state. At narrow widths it opens
in a bottom sheet, otherwise in a popover. A custom trigger snippet can use
an app's bell button. Opening a row calls the hash router with hrefFor(row);
the default route is /<subjectId>.
<script lang="ts">
import { Bell } from '@lucide/svelte';
import { Button } from '@protoyard/ui';
import { LucideIcon } from 'texuli/icons/lucide';
</script>
{#snippet bellTrigger({ props })}
<Button {...props} variant="ghost" size="icon" aria-label="Notifications">
<LucideIcon icon={Bell} />
</Button>
{/snippet}
<NotificationCenter
trigger={bellTrigger}
query={notifications}
onMarkRead={(id) => services.notifications.markRead(id)}
onMarkAllRead={() => services.notifications.markAllRead()}
hrefFor={(row) => `/tasks/${row.subjectId}`}
/>Pass onMuteChange when the prototype has a per-type preference service; its
callback receives the notification kind and the requested muted state.
The list is Texuli's NotificationInbox (all/unread view, opening on the
Unread view, relative time labels, "Mark as read" per row, "Mark all as read",
and a polite announcement for new arrivals). Read items offer no "Mark as
unread" (allowMarkUnread={false}, G50), because the service contract is
mark-read only. "Mark all as read" goes to Texuli's own onMarkAllRead, and
each save returns its promise, so the control that started it stays pending
(aria-disabled, aria-busy) until it settles (G106). The adapter keeps the
Protoyard service contract (optimistic
read state, rolled back when the service fails or returns false), loading
and error states, mute preferences in each row's actions, and the responsive
host surface.
- Loading: import this subpath from a lazy route so the panel stays out of initial JavaScript.
Replace the <NotificationsBell> instance with NotificationCenter, move its
existing bell button markup into the trigger snippet, and pass the prototype's
live query and service callbacks. For comment mentions, call
mentionedIds(body) in the comment service and write one notification row per
mentioned recipient in the same transaction as the comment. The task-manager
template demonstrates this with actor filtering and recipient-scoped reads.
Files (@protoyard/views-ui/files)
FileManager is a host adapter over Texuli's FileBrowser
(@texuli/data/files, also exported here). FilePreview (below) previews
files in a lightbox. It reads flat
{ id, parentId, name, kind: 'folder' | 'file', type?, size?, updatedAt? }
rows on the @protoyard/views/files engine.
<FileManager
query={entries} bind:folder bind:view bind:selected
onOpenFile={(entry) => navigate(`/files/${entry.id}`)}
/>- Adapter:
querybecomes Texuli'sentries, insideQueryState. The open folder is bindable asfolderorfolderId(nullis the root) and the layout asvieworlayout(gridorlist); each pair stays in step.selected,onFolderChange,onSelectedChange,onLayoutChangeandonOpenFileare forwarded, andlabelnames the browser. - Texuli's browser: breadcrumbs, grid and list layouts with multi-select, and a side preview with a deterministic SVG thumbnail made from the entry (no network). Keys: arrows (grid-aware), Enter opens, Space selects, Backspace goes up a folder.
- Read-only today:
onCreateFolder,onRename,onMove,onDelete,onUpload,getBlob,accept,maxSizeandrootLabelare accepted so existing screens typecheck, but the adapter does not forward them. There is no rename, move, delete, new folder, upload or blob preview in the UI. - The engine still exports
nameProblem,moveProblemandthumbnailSvgfor services. Storage caveats for uploaded files are in docs/DATABASE.md (Uploaded files).
FilePreview
FilePreview shows entries (folders are skipped) as a gallery of
thumbnail buttons. Activating one opens a lightbox on the @protoyard/ui
Dialog:
<FilePreview
entries={files}
bind:current
getSrc={(file) => file.url}
getBlob={(file) => services.readBlob(file.id)}
/>- By type (
previewKind): images show the file (or the deterministic thumbnail without a source), PDFs embed in an<object>with an "Open" link as fallback, text renders in a scrollable<pre>as text (never HTML, clipped atMAX_PREVIEW_TEXTcharacters), video and audio get native controls, and anything else shows its thumbnail and details. - Sources:
getSrc(entry)returns a URL that must passsafePreviewSrc(https:,http:,blob:, relative paths, and base64 rasterdata:for images; neverjavascript:, otherdata:or//host). Without one,getBlob(entry)is shown through an object URL (revoked when the file changes), and text comes fromgetText(entry)or the blob. - Lightbox: the title is the file name and the description its type,
size and date. Previous and Next buttons and ArrowLeft / ArrowRight step
through the files ("2 of 5" is announced), Escape or Close closes, and
focus returns to the thumbnail of the file that was showing.
current(the open file id, bindable) andonCurrentChangelet the host open it. FilePreviewwas a deprecated alias ofFileBrowserbefore 1.3; it is now this component. UseFileBrowserfor the browser.
pnpm vitest run packages/views-ui/tests/files.test.tsPackage output
The repository keeps source exports for workspace development. pnpm build:packages --filter svelte creates the compiled ESM, declarations and Svelte components under dist/ that the packed manifest exposes.
