Record details and activity
Read typed details and connect an application-owned audit trail.
The current registry can open a record in a drawer, modal or inline consultation surface. The application supplies the audit data and implements undo.
With the default rowClickMode, a row click opens this record view in every display mode. You don't have to pass details to get it: without it, the record view derives its fields from the table columns. Pass details={productDetails} (:details="productDetails" in Vue) to control sections, labels and formats, or details={false} (:details="false" in Vue) to remove the built-in view entirely — a plain click then only calls onOpenDetails/onRowActivate when you supply one. enableRowClickEdit or rowClickMode: 'edit' open the edit form instead, and a row-link column still navigates.
Use the root TableConfig.presentation option for a shared view/create/edit/bulk surface, with an optional mobile choice. The default is a right drawer on every viewport. See shared record presentation for configuration and migration.
Configuration example
Start from the React quick start or Vue quick start. The following file extends their product catalog. Pass this configuration through getTableConfig in React or config in Vue.
import type {
DetailRevertHandler,
RecordDetailsConfig,
} from "@/components/ui/yayaw-table/utils/record-details";
import { productStore } from "../shared/store";
export const productDetails: RecordDetailsConfig = {
presentation: "drawer",
title: (row) => String(row.name),
updatedAt: (row) => String(row.updatedAt),
sections: [
{
id: "product",
title: "Product",
fields: [
{ id: "name", label: "Name", type: "text" },
{
id: "price",
label: "Price",
type: "number",
numberFormat: { style: "currency", currency: "EUR" },
},
{ id: "stock", label: "Stock", type: "number" },
{ id: "status", label: "Status", type: "text" },
],
},
],
activity: (row) => productStore.activity(String(row.id)),
};
export const revertActivity: DetailRevertHandler = (row, entry) =>
productStore.revert(String(row.id), entry.id);import type {
DetailRevertHandler,
RecordDetailsConfig,
} from "@/components/ui/yayaw-table-vue/record-details";
import { productStore } from "../shared/store";
export const productDetails: RecordDetailsConfig = {
presentation: "drawer",
title: (row) => String(row.name),
updatedAt: (row) => String(row.updatedAt),
sections: [
{
id: "product",
title: "Product",
fields: [
{ id: "name", label: "Name", type: "text" },
{
id: "price",
label: "Price",
type: "number",
numberFormat: { style: "currency", currency: "EUR" },
},
{ id: "stock", label: "Stock", type: "number" },
{ id: "status", label: "Status", type: "text" },
],
},
],
activity: (row) => productStore.activity(String(row.id)),
};
export const revertActivity: DetailRevertHandler = (row, entry) =>
productStore.revert(String(row.id), entry.id);Choose the visible fields
Pass details={productDetails} in React or :details="productDetails" in Vue. Without explicit sections, fields derive from table columns. Explicit sections let you choose readable labels, formats and which fields are omitted. The record recipe supplies the store imported above and wires onRevertActivity.
Append-only undo
Each activity item has an ID, actor, timestamp, action and optional before/after changes. Undo appends a new event with reverts pointing to the original event; the original is retained. The UI prevents invalid repeated or conflicting undo, but the backend must recheck current values and permissions atomically before writing.
Activity in the edit form
Since v3.12.0, editing a record shows the same Details | Activity tabs as the record view when details supplies activity or history: the fields and their footer on the first tab, the timeline and its undo buttons on the second. The fields stay mounted while the activity shows, so a draft survives a tab switch. A successful undo refreshes the table and reloads the fields from the refreshed row. Creating, bulk editing and tables without an activity log keep the plain form. The timeline names a change by the edited form field of that name.
Distribution requirement
Record details are in the current /r/ distribution and in the immutable v3.1.0 snapshot used by these examples; they are absent from v3.0.0. Do not combine a details example with that older snapshot. See compatibility.
Keyboard undo and deleted records
Ctrl/Cmd+Z calls the existing onRevertActivity(row, entry) handler for the newest eligible event. It uses the same reversible, reverts, conflict and details.canRevert checks as the Activity tab. The application must persist history, enforce authorization and recheck current values atomically; the library does not create a database audit log or make permanent deletion reversible.
Supply details.history: () => records where each record is { row, activity } to include events from deleted or off-page records. Without it, undo uses the loaded rows and details.activity(row). Supply only the intended undo scope, and mark events from other users or unsupported operations non-reversible. If activity is omitted, the record's Activity tab also reads this history.
Events from one bulk operation can share transactionId. One shortcut reverts its eligible members through the same handler. Successful members are refreshed and are not retried after partial failure; the remaining failed members stay available. This is sequential application-level compensation, not an atomic cross-record database transaction. Return { success: false, error } on failure and append a compensating event with reverts: originalEvent.id on success.
An event undone since cancels out with its undo: it no longer blocks undoing an older change of the same fields, so repeated Ctrl/Cmd+Z walks a field back one change at a time.
Ctrl/Cmd+Shift+Z and Ctrl+Y redo through the opt-in onRedoActivity(row, undoEvent) handler, for the newest undo event that was not redone and whose fields did not change since. Re-apply the undo event's before values and append an event with redoes: undoEvent.id; the undo event stays in the log. A newer change that is not a redo clears what could be redone. Undo events sharing a transactionId are redone together, so give an undo event the transaction of the change it inverts. Without onRedoActivity the redo keys keep their native behavior; macOS Cmd+Y always does.
Inputs, text editors, open dialogs and menus keep native shortcuts; a dialog that contains the table counts as its page, so a table inside a dialog keeps them. The active table owns shortcuts; a single visible table also handles them when browser focus is on the page body. Multiple tables require interaction to choose the active one. Clipboard mutation shortcuts are not implied by an undo handler.
Video in a record
A detail field with type: "video" accepts a URL or { url, poster, tracks }. It renders native controls without autoplay; tracks can provide src, label, srcLang and kind: "captions" | "subtitles". Unsafe URLs are rejected in both frameworks.
Undo notifications
A successful undo displays one notification after the entire operation succeeds, including a grouped keyboard undo. Partial failures display their error and do not claim the whole action was undone. The Activity tab and Ctrl/Cmd+Z use the same localized sentence.
details.labels.undoSuccess accepts a complete sentence with an optional {action} placeholder. The defaults are Action “{action}” undone. in English and Action « {action} » annulée. in French. A media application can provide Deletion undone / Suppression annulée; translate the whole sentence instead of concatenating a suffix or inferring grammatical gender from the activity label.
A redo notification names the change it re-applies with details.labels.redoSuccess: Action “{action}” redone. in English and Action « {action} » rétablie. in French. redoError and redoUnavailable complete the redo labels.
Try it inline
Edit a record, open its information drawer and revert the activity entry.
Sample data. Changes stay in this preview.
"use client";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { NuqsAdapter } from "nuqs/adapters/react";
import { useState } from "react";
import { Toaster } from "sonner";
import { DataTable } from "@/components/ui/yayaw-table";
import { editableActions } from "./editable-actions";
import { getFormConfig } from "./get-form-config";
import type { ExamplePresentation } from "./presentation";
import { productDetails, revertActivity } from "./product-details";
import { recordConfig } from "./record-config";
import { viewActions } from "./view-actions";
const getConfig = () => recordConfig;
const recordActions = { ...editableActions, views: viewActions };
const getRecordActions = () => recordActions;
export default function RecordRecipe(presentation: ExamplePresentation = {}) {
const [queryClient] = useState(() => new QueryClient());
return (
<QueryClientProvider client={queryClient}>
<NuqsAdapter>
<DataTable
{...presentation}
details={productDetails}
getFormConfig={getFormConfig}
getRowId={(row) => String(row.id)}
getTableActions={getRecordActions}
getTableConfig={getConfig}
onRevertActivity={revertActivity}
tableId="recipe-record"
tableType="products"
title={presentation.title ?? "Record"}
/>
<Toaster />
</NuqsAdapter>
</QueryClientProvider>
);
}Sample data. Changes stay in this preview.
<script setup lang="ts">
import type { ExamplePresentation } from "./presentation";
defineProps<ExamplePresentation>();
import { YayawDataTable } from "@/components/ui/yayaw-table-vue";
import { editableActions } from "./editable-actions";
import { getFormConfig } from "./get-form-config";
import { productDetails, revertActivity } from "./product-details";
import { recordConfig } from "./record-config";
import { viewActions } from "./view-actions";
const recordActions = { ...editableActions, views: viewActions };
const getRecordActions = () => recordActions;
const getRowId = (row: Record<string, unknown>) => String(row.id);
</script>
<template>
<YayawDataTable v-bind="$props" table-type="products" table-id="recipe-record" :title="title ?? 'Record'"
:config="recordConfig" :get-table-actions="getRecordActions" :get-row-id="getRowId"
:get-form-config="getFormConfig" :details="productDetails" :on-revert-activity="revertActivity" />
</template>Typed delete confirmation
table.deleteConfirmation: { type: "typed", match?, column?, text?, bulkMatch?, caseSensitive? } keeps the row, bulk and record Delete buttons disabled until the user types the expected value: the record's title (match: "title", the default), a column's value (match: "column" with column) or a fixed word (match: "text", by default the localized "DELETE"). Bulk deletion asks for the number of selected records (bulkMatch: "count", the default) or the word ("text"). Letter case is ignored unless caseSensitive is set; surrounding spaces always are. details.deleteConfirmation overrides it for the record view. The confirmation guards against mistakes only: the server still authorizes every deletion.
Related lists
A { kind: "related" } section lists records of another source linked to this one, such as the people of a company:
{
"kind": "related",
"id": "people",
"title": "People",
"source": "people",
"foreignKey": "companyId",
"columns": [
{ "id": "name", "label": "Name" },
{ "id": "email", "label": "Email", "type": "email" }
],
"sort": { "id": "name" },
"limit": 10,
"empty": "No people yet.",
"open": { "action": "open-person" },
"add": { "action": "add-person", "label": "Add person" }
}The table does not know your backend: pass static rows (filtered by foreignKey, a value or a list of values, against this record's localKey, id by default), or load them with details.loadRelated(section, row, { value, sort, limit }). Records load once the section is open and visible (collapsed: true waits until it is opened), then are sorted and limited, with a count of the rest. Loading, empty, error and retry states are built in. Open (per row) and Add (in the header) call details.onRelatedAction({ action, kind, section, row, related }). When sections lists only related or custom sections, the fields derived from the columns stay first.
Host-defined fields and sections
details.renderField(field, value, row) renders any field (return undefined for the standard renderer); fields can read JSON columns through dot paths, such as customFields.industry. A { kind: "custom", id, title, data? } section is drawn by details.renderSection(section, row); returning nothing hides it. Use them for values the table does not own, such as custom fields stored elsewhere. In Vue, the #detail-field and #record-section-<id> slots do the same.