mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-16 03:40:37 +08:00
22 lines
941 B
TypeScript
22 lines
941 B
TypeScript
import type { FileDiffMetadata } from "@pierre/diffs";
|
|
|
|
export type FileStatus = "added" | "deleted" | "modified" | "moved" | "copied";
|
|
export type FileNote = "binary" | "empty";
|
|
|
|
// Reactive state for a single `DiffFileHeader`. One instance is created per
|
|
// pooled CodeView item element and mutated in place as the element is recycled
|
|
// for different files while scrolling (see `PierreDiff.svelte`), so the header
|
|
// updates without remounting.
|
|
export class DiffFileHeaderState {
|
|
fileDiff = $state.raw<FileDiffMetadata | undefined>(undefined);
|
|
status = $state<FileStatus | undefined>(undefined);
|
|
note = $state<FileNote | undefined>(undefined);
|
|
collapsed = $state(false);
|
|
// `undefined` hides the actions menu.
|
|
text = $state<(() => Promise<string>) | undefined>(undefined);
|
|
// Not `$state`: read only at click time. Set per file in `syncHeaderSlots`.
|
|
onToggleCollapse: () => void = () => {
|
|
// Replaced per file.
|
|
};
|
|
}
|