# Audit History Panel
URL: https://pro.rv-grid.com/api/audit-history-panel/
Source: src/content/docs/api/audit-history-panel.md
### `createAuditHistoryPanelDock`

```ts
export function createAuditHistoryPanelDock(
  panel: HTMLElement,
  grid: HTMLRevoGridElement,
  placement: AuditHistoryPanelPlacement,
);
```

---

### `defineAuditHistoryPanel`

Renders the Audit History panel into `el` for the given RevoGrid element.

The grid must have `AuditHistoryPlugin` installed.

```ts
export function defineAuditHistoryPanel(el: HTMLElement, grid: HTMLRevoGridElement, options: AuditHistoryPanelOptions =;
```

---

### `AuditHistoryPanelDateFormatContext`

```ts
export type AuditHistoryPanelDateFormatContext = {
  mode: 'time' | 'day' | 'filter';
  record?: AuditRecord;
};
```

---

### `AuditHistoryPanelEvents`

```ts
export type AuditHistoryPanelEvents = {
  beforeRecordSelect?: (context: AuditHistoryPanelRecordContext) => boolean | void;
  beforeCompareOpen?: (context: AuditHistoryPanelRecordContext) => boolean | void;
  beforeJumpToCell?: (context: AuditHistoryPanelJumpContext) => boolean | void;
  beforeRestore?: (context: AuditHistoryPanelRestoreContext) => boolean | void;
  beforeExport?: (context: AuditHistoryPanelExportContext) => boolean | void;
};
```

---

### `AuditHistoryPanelExportContext`

```ts
export type AuditHistoryPanelExportContext = {
  format: AuditHistoryExportFormat;
};
```

---

### `AuditHistoryPanelJumpContext`

```ts
export type AuditHistoryPanelJumpContext = {
  record: AuditRecord;
  change: AuditChange;
};
```

---

### `AuditHistoryPanelLabels`

```ts
export type AuditHistoryPanelLabels = {
  title: string;
  liveStatus: string;
  recordsSummary: (count: number) => string;
  changesSummary: (count: number) => string;
  allTab: string;
  rowTab: string;
  cellTab: string;
  tableTab: string;
  selectedCell: (rowId: string, column: ColumnProp) => string;
  selectedRow: (rowId: string) => string;
  export: string;
  exportCsv: string;
  exportJson: string;
  exportCsvTitle: string;
  exportJsonTitle: string;
  close: string;
  openPanel: string;
  searchPlaceholder: string;
  searchAriaLabel: string;
  searchShortcut: string;
  userPlaceholder: string;
  userAriaLabel: string;
  columnAriaLabel: string;
  actionAriaLabel: string;
  dateFromAriaLabel: string;
  dateToAriaLabel: string;
  allColumns: string;
  allActions: string;
  clearFilters: string;
  addFilter: string;
  removeFilter: (label: string) => string;
  noRecords: string;
  noComparableRecord: string;
  scopedRecordCount: (visibleChanges: number, totalChanges: number) => string;
  changedBy: (changedAt: string, user: string) => string;
  rowTarget: (rowId: string | undefined, column: ColumnProp | undefined) => string;
  cellValues: (oldValue: string, newValue: string) => string;
  rowSnapshotAvailable: string;
  rowRemoved: string;
  restoreCell: string;
  restoreRow: string;
  restoreTransaction: string;
  restoreSnapshot: string;
  jumpToCell: string;
  revertAll: string;
  moreActions: string;
  compare: string;
  compareTitle: string;
  compareBefore: string;
  compareAfter: string;
  closeCompare: string;
  compareEmpty: string;
  viewChanges: (count: number) => string;
  previousPage: string;
  nextPage: string;
  pageStatus: (currentPage: number, pageCount: number) => string;
  dayToday: string;
  dayYesterday: string;
  sourceLabels: Record<AuditHistorySource, string>;
  actions: Partial<Record<AuditActionType, string>>;
  actionVerbs: Partial<Record<AuditActionType, string>>;
};
```

---

### `AuditHistoryPanelLabelsOptions` (Extended from `index.tsx`)

```ts
export type AuditHistoryPanelLabelsOptions = Partial<Omit<AuditHistoryPanelLabels, 'actions' | 'actionVerbs' | 'sourceLabels'>> & {
  actions?: Partial<Record<AuditActionType, string>>;
  actionVerbs?: Partial<Record<AuditActionType, string>>;
  sourceLabels?: Partial<Record<AuditHistorySource, string>>;
};
```

---

### `AuditHistoryPanelHandle`

```ts
export type AuditHistoryPanelHandle = {
  destroy: () => void;
  setPlacement: (placement: AuditHistoryPanelPlacement) => void;
  refresh: () => Promise<void>;
};
```

---

### `AuditHistoryPanelOptions`

```ts
export type AuditHistoryPanelOptions = {
  pageSize?: number;
  allowExport?: boolean;
  allowCompare?: boolean | ((context: AuditHistoryPanelRecordContext) => boolean);
  allowClose?: boolean;
  miniOnClose?: boolean;
  restoreActions?: false | AuditRestoreType[] | ((context: AuditHistoryPanelRestoreContext) => boolean);
  formatDate?: (value: string, context: AuditHistoryPanelDateFormatContext) => string;
  events?: AuditHistoryPanelEvents;
  placement?: AuditHistoryPanelPlacement;
  tooltips?: false | Partial<Record<AuditHistoryPanelTooltipKey, string | false>>;
  labels?: AuditHistoryPanelLabelsOptions;
};
```

---

### `AuditHistoryPanelRecordContext`

```ts
export type AuditHistoryPanelRecordContext = {
  record: AuditRecord;
  changes: AuditChange[];
};
```

---

### `AuditHistoryPanelRestoreContext`

```ts
export type AuditHistoryPanelRestoreContext = {
  type: AuditRestoreType;
  record?: AuditRecord;
  change?: AuditChange;
  transactionId?: string;
};
```

---

### `AuditHistoryPanelPlacement`

```ts
export type AuditHistoryPanelPlacement = 'right' | 'left' | 'top' | 'bottom' | 'none';
```

---

### `AuditHistoryPanelTooltipKey`

```ts
export type AuditHistoryPanelTooltipKey =
  | 'totalRecords'
  | 'totalChanges'
  | 'selectedScope'
  | 'searchFilter'
  | 'userFilter'
  | 'columnFilter'
  | 'actionFilter'
  | 'dateFromFilter'
  | 'dateToFilter'
  | 'clearFilters';
```

---

### `resolveLabels`

```ts
export function resolveLabels(labels?: AuditHistoryPanelLabelsOptions): AuditHistoryPanelLabels;
```

---

### `getAuditActionLabel`

```ts
export function getAuditActionLabel(labels: AuditHistoryPanelLabels, actionType: AuditActionType): string;
```

---

### `getAuditActionVerb`

```ts
export function getAuditActionVerb(labels: AuditHistoryPanelLabels, actionType: AuditActionType): string;
```

---

### `actionTypes`

```ts
actionTypes: AuditActionType[];
```

---

### `titleizeActionType`

```ts
titleizeActionType: (value: string) => string;
```

---

### `createInitialFilters`

```ts
export function createInitialFilters(): AuditPanelFilters;
```

---

### `stringifyValue`

```ts
export function stringifyValue(value: unknown): string;
```

---

### `formatTime`

```ts
export function formatTime(value: string, mode: 'compact' | 'day' = 'compact');
```

---

### `formatPanelDate`

```ts
export function formatPanelDate(
  value: string,
  options: AuditHistoryPanelOptions,
  context:;
```

---

### `getUserLabel`

```ts
export function getUserLabel(record: AuditRecord);
```

---

### `getAvatarLabel`

```ts
export function getAvatarLabel(record: AuditRecord);
```

---

### `matchesFilters`

```ts
export function matchesFilters(record: AuditRecord, filters: AuditPanelFilters);
```

---

### `getScopedChanges`

```ts
export function getScopedChanges(record: AuditRecord, tab: AuditPanelTab, selected: SelectedAuditTarget): AuditChange[];
```

---

### `getRecordSource`

```ts
export function getRecordSource(type: AuditActionType, record?: AuditRecord): AuditHistorySource;
```

---

### `getTargetLabel`

```ts
export function getTargetLabel(record: AuditRecord, changes: AuditChange[], labels: AuditHistoryPanelLabels);
```

---

### `getDetailLabel`

```ts
export function getDetailLabel(record: AuditRecord, changes: AuditChange[]);
```

---

### `isComparable`

```ts
export function isComparable(record: AuditRecord, changes: AuditChange[]);
```

---

### `toTimelineRecord`

```ts
export function toTimelineRecord(
  record: AuditRecord,
  changes: AuditChange[],
  labels: AuditHistoryPanelLabels,
  options: AuditHistoryPanelOptions =;
```

---

### `groupTimelineRecords`

```ts
export function groupTimelineRecords(records: TimelineRecord[]): TimelineGroup[];
```

---

### `getPlugin`

```ts
export async function getPlugin(grid: HTMLRevoGridElement): Promise<AuditHistoryPluginRuntime | undefined>;
```

---

### `panelRefreshEvents`

```ts
panelRefreshEvents: readonly ["auditrecord", "auditrecordsloaded", "auditrestore"];
```

---

### `canSelectRecord`

```ts
export function canSelectRecord(options: AuditHistoryPanelOptions, context: AuditHistoryPanelRecordContext);
```

---

### `canOpenCompare`

```ts
export function canOpenCompare(options: AuditHistoryPanelOptions, context: AuditHistoryPanelRecordContext);
```

---

### `canJumpToCell`

```ts
export function canJumpToCell(options: AuditHistoryPanelOptions, context: AuditHistoryPanelJumpContext);
```

---

### `canUseRestoreAction`

```ts
export function canUseRestoreAction(options: AuditHistoryPanelOptions, context: AuditHistoryPanelRestoreContext);
```

---

### `canExportAuditHistory`

```ts
export function canExportAuditHistory(options: AuditHistoryPanelOptions, format: AuditHistoryExportFormat);
```

---

### `AuditHistoryTooltip`

```ts
export function AuditHistoryTooltip(;
```

---

### `AuditPanelTab`

```ts
export type AuditPanelTab = 'cell' | 'row' | 'table';
```

---

### `SelectedAuditTarget`

```ts
export type SelectedAuditTarget = {
  rowId?: string;
  column?: ColumnProp;
  columnLabel?: ColumnProp;
  rowIndex?: number;
  rowType?: DimensionRows;
};
```

---

### `AuditPanelFilters`

```ts
export type AuditPanelFilters = {
  search: string;
  user: string;
  column: string;
  actionType: '' | AuditActionType;
  dateFrom: string;
  dateTo: string;
};
```

---

### `AuditHistoryPluginRuntime`

```ts
export type AuditHistoryPluginRuntime = {
  getRecords: () => AuditRecord[];
  getCellHistory: (rowId: string, column: ColumnProp) => AuditRecord[];
  getRowHistory: (rowId: string) => AuditRecord[];
  getStats: () => AuditHistoryStats;
  exportRecords: (options?: AuditHistoryExportOptions) => string;
  getRowIdentity: (row: DataType | undefined, rowIndex: number, rowType: DimensionRows) => string | undefined;
  canRestoreRecord: (context: { type: AuditRestoreType; record?: AuditRecord; change?: AuditChange; transactionId?: string }) => boolean;
  restoreCell: (change: AuditChange) => boolean;
  restoreRow: (record: AuditRecord) => boolean;
  restoreTransaction: (transactionId: string) => boolean;
  restoreSnapshot?: (recordOrId: AuditRecord | string) => boolean;
  recordEvent?: (input: AuditRecordEventInput) => AuditRecord | undefined;
  createSnapshot?: (label: string, options?: AuditSnapshotOptions) => AuditRecord | undefined;
};
```

---

### `VisibleAuditRecord`

```ts
export type VisibleAuditRecord = {
  record: AuditRecord;
  changes: AuditChange[];
};
```

---

### `TimelineRecord` (Extended from `types.ts`)

```ts
export type TimelineRecord = VisibleAuditRecord & {
  id: string;
  source: AuditHistorySource;
  verb: string;
  userLabel: string;
  avatarLabel: string;
  avatarIndex?: number;
  avatarColor?: string;
  targetLabel: string;
  detailLabel?: string;
  rangeLabel?: string;
  changedAtLabel: string;
  dayKey: string;
  dayLabel: string;
  daySubLabel?: string;
  accent: boolean;
  comparable: boolean;
};
```

---

### `TimelineGroup`

```ts
export type TimelineGroup = {
  key: string;
  label: string;
  subLabel?: string;
  records: TimelineRecord[];
};
```

---

### `AuditHistoryPanel`

```ts
export function AuditHistoryPanel(;
```

---

### `CompareDrawer`

```ts
export function CompareDrawer(;
```

---

### `Filters`

```ts
export function Filters(;
```

---

### `MiniAuditHistoryPanel`

```ts
export function MiniAuditHistoryPanel(;
```

---

### `Pagination`

```ts
export function Pagination(;
```

---

### `RecordsList`

```ts
export function RecordsList(;
```

---

### `Toolbar`

```ts
export function Toolbar(;
```
