zynactradocs

Diff

What changed between two versions of a record, field by field, for audit logs and reviews before saving.

DescriptionAdded
After: Approves leave in their units
PermissionsChanged
Before: ["leave.request:approve"]After: ["leave.request:approve","leave.request:read"]
ScopeRemoved
Before: org_unit

Usage

import { Diff, diffValues } from "@zynactra/ui/diff"
<Diff before={previous} after={current} label={(path) => labels[path] ?? path} />

Nested objects flatten to dotted paths (scope.type). Arrays and other values compare as a whole. Each row says Added, Removed or Changed in a badge, with the old value on a danger-soft background and the new one on success-soft. before={null} lists everything as added. diffValues(before, after) returns the same entries if you need them yourself.

Guidelines

  • Rename paths to the words people see on the form (label), and format dates and IDs (formatValue).
  • Leave unchanged fields out (the default). Show them with includeUnchanged only when context matters more than length.
  • Put it in a Sheet or an expanded Activity Log entry, not in a table cell.
Edit on GitHub

On this page