Components

Editable Record Detail

Inline record editing with change tracking, validation, hidden fields, and a floating action bar.

Client Only

Installation

pnpm dlx @docyrus/cli add @docyrus/ui-editable-record-detail
UI Primitives(3 components)
npx shadcn@latest add action-bar button popover

Usage

import {
  EditableRecordDetail,
  EditableRecordDetailField,
  useEditableRecordDetail
} from "@docyrus/ui/components/editable-record-detail";

<EditableRecordDetail
  fields={fields}
  record={record}
  onSave={handleSave}
>
  <EditableRecordDetailField slug="name" />
  <EditableRecordDetailField slug="status" />
</EditableRecordDetail>

API Reference

EditableRecordDetailProps

PropTypeDefaultDescription
fieldsArray<RecordDetailField>—Field configurations
recordRecord<string, unknown>—Current record values keyed by field slug
onSave(changes: Array<FieldChange>, values: Record<string, unknown>) => void | Promise<void>—Called when save is triggered
onCancel() => void—Called when cancel is triggered
formany—External TanStack Form instance (skips internal macro-form)
readOnlybooleanfalseWhether all fields are read-only
disabledbooleanfalseWhether all fields are disabled
trackChangesbooleantrueWhether changed fields should be visually highlighted
actionBarSideOffsetnumber—Side offset for the floating action bar
childrenReactNode—Content (EditableRecordDetailField components)
classNamestring—Additional CSS class

RecordDetailField

PropertyTypeDefaultDescription
fieldIField—Field configuration object
enumOptionsArray<EnumOption>—Enum options for select-based fields
readOnlyboolean—Whether this field is read-only
requiredboolean | ((values: Record<string, unknown>) => boolean)—Whether the field is required. Supports a callback for computed required based on other field values
hiddenboolean | ((values: Record<string, unknown>) => boolean)—Whether the field should be hidden. Supports a callback for computed visibility based on other field values. Hidden fields are excluded from validation
appSlugstring—App slug for dynamic enum loading
dataSourceSlugstring—Data source slug for dynamic enum loading

EditableRecordDetailFieldProps

PropTypeDefaultDescription
slugstring—Field slug (looks up config from context)
labelReactNode—Optional label override
showLabelbooleantrueRender label + value row
classNamestring—Additional CSS class

useEditableRecordDetail

Hook to access the EditableRecordDetail context from within the provider.

ReturnTypeDescription
formanyThe form instance (internal macro-form or external)
valuesRecord<string, unknown>Current record values
changedFieldsSet<string>Set of changed field slugs
changedFieldCountnumberNumber of changed fields
valuesVersionnumberCounter that increments on every field value change. Use to trigger re-renders for cross-field reactivity
isFieldChanged(slug: string) => booleanCheck if a specific field has changed
getFieldValue(slug: string) => unknownGet the current value of a field
setFieldValue(slug: string, value: unknown) => voidProgrammatically set a field value and trigger re-render
getChanges() => Array<FieldChange>Get all pending changes
handleSave() => Promise<void>Trigger save with validation
handleCancel() => voidDiscard all changes and reset to original values
isSavingbooleanWhether a save is in progress

FieldChange

PropertyTypeDescription
fieldSlugstringField slug
fieldNamestringField display name
originalValueunknownValue before change
newValueunknownCurrent value

On this page