Blocks / Trash list

Trash list

Deleted items with who and when, days left, restore, delete forever and empty trash.

import { TrashList, retentionDaysLeft, retentionText, sortByRetention } from "@forgeron/ui";
/01 → Default
Note
Kept for a whileDeleted items stay here for 30 days, then they are deleted forever.
4 items
  • Old onboarding checklistDocument · deleted by Léa Martin, 28 days ago2 days left
  • Q3 planningDocument · deleted by Sam Roche, 17 days ago13 days left
  • Acme renewalProject · deleted by Ada Lovelace, 2 days ago28 days left
  • Invoice 214Invoice · deleted by Ada Lovelace, yesterday29 days left
import { TrashList, type TrashEntry } from "@forgeron/ui";
import { useState } from "react";

const initial: TrashEntry[] = [
  {
    id: "a",
    name: "Invoice 214",
    kind: "Invoice",
    deletedBy: "Ada Lovelace",
    deletedAt: "2026-11-18",
  },
  {
    id: "b",
    name: "Q3 planning",
    kind: "Document",
    deletedBy: "Sam Roche",
    deletedAt: "2026-11-02",
  },
  {
    id: "c",
    name: "Old onboarding checklist",
    kind: "Document",
    deletedBy: "Léa Martin",
    deletedAt: "2026-10-22",
  },
  {
    id: "d",
    name: "Acme renewal",
    kind: "Project",
    deletedBy: "Ada Lovelace",
    deletedAt: "2026-11-17",
  },
];

export default function Default() {
  const [items, setItems] = useState(initial);
  const drop = (ids: string[]) => setItems(items.filter((i) => !ids.includes(i.id)));
  return (
    <div style={{ width: "100%", maxWidth: 760 }}>
      <TrashList
        items={items}
        today="2026-11-19"
        onRestore={drop}
        onDeleteForever={drop}
        onEmpty={() => setItems([])}
      />
    </div>
  );
}
API → Props
PropTypeDefaultDescription
items{ id, name, kind?, deletedBy, deletedAt }[]—The soonest to go first.
todaystring—YYYY-MM-DD: dates are told from it (“3 days ago”, “In 5 days”).
retentionDaysnumber30Days before it is deleted for good.
onRestore(ids: string[]) => void—One id from a row, several from the selection.
onDeleteForever(ids: string[]) => void—After the confirmation.
onEmpty() => void—Empty trash, after the confirmation; without it, no button.
notice / noun / emptyboolean; string; string—The retention banner; the word for one item.
classNamestring—Extra classes.