BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/files-sdk/trash-bin

Trash Bin

files-sdk/trash-bin
FreeComponent

Lists, restores and permanently purges soft-deleted files (softDelete plugin).

Install it

npx shadcn@latest add https://files-sdk.dev/r/trash-bin.json

Source

registry/files-sdk/trash-bin/trash-bin.tsxfiles-sdk.dev/r/trash-bin.json · first 6 KB
1"use client";
2
3import type { TrashedFile, UseFilesResult } from "files-sdk/react";
4import {
5 Loader2Icon,
6 RotateCcwIcon,
7 Trash2Icon,
8 TrashIcon,
9} from "lucide-react";
10import { useCallback, useEffect, useRef, useState } from "react";
11
12import { Button } from "@/components/ui/button";
13import {
14 Dialog,
15 DialogContent,
16 DialogDescription,
17 DialogFooter,
18 DialogHeader,
19 DialogTitle,
20} from "@/components/ui/dialog";
21import { cn } from "@/lib/utils";
22
23export interface TrashBinProps {
24 /** A `useFiles()` instance backed by a gateway with the `softDelete()` plugin. */
25 files: UseFilesResult;
26 /** Called after a successful restore or purge. */
27 onChanged?: () => void;
28 className?: string;
29}
30
31const formatBytes = (bytes: number): string => {
32 if (bytes === 0) {
33 return "0 B";
34 }
35 const units = ["B", "KB", "MB", "GB", "TB"];
36 const exponent = Math.min(
37 Math.floor(Math.log(bytes) / Math.log(1024)),
38 units.length - 1
39 );
40 return `${(bytes / 1024 ** exponent).toFixed(exponent === 0 ? 0 : 1)} ${units[exponent]}`;
41};
42
43/**
44 * A recycle bin backed by the `softDelete()` plugin. Lists trashed objects and
45 * restores or permanently purges them through the same `useFiles()` instance.
46 * Purges (single + "empty trash") confirm first, since they're the only way the
47 * bytes actually leave storage.
48 */
49export const TrashBin = ({ files, onChanged, className }: TrashBinProps) => {
50 const [trashed, setTrashed] = useState<TrashedFile[]>([]);
51 const [isLoading, setIsLoading] = useState(true);
52 const [busy, setBusy] = useState<string>();
53 // `null` = closed; `{ key }` = purge one; `{}` = empty the whole trash.
54 const [pending, setPending] = useState<{ key?: string } | null>(null);
55
56 const filesRef = useRef(files);
57 filesRef.current = files;
58
59 const refresh = useCallback(async () => {
60 setIsLoading(true);
61 try {
62 setTrashed(await filesRef.current.trashed());
63 } catch {
64 // The hook mirrors the error to `files.error` for display.
65 } finally {
66 setIsLoading(false);
67 }
68 }, []);
69
70 useEffect(() => {
71 void refresh();
72 }, [refresh]);
73
74 const restore = useCallback(
75 async (key: string) => {
76 setBusy(key);
77 try {
78 await filesRef.current.restoreTrashed(key);
79 await refresh();
80 onChanged?.();
81 } catch {
82 // Mirrored to `files.error`.
83 } finally {
84 setBusy(undefined);
85 }
86 },
87 [refresh, onChanged]
88 );
89
90 const purge = useCallback(async () => {
91// … truncated

What it pulls in

npm packages

  • files-sdk
  • lucide-react

Other registry items

  • button
  • dialog

Files it writes

  • registry/files-sdk/trash-bin/trash-bin.tsx

Facts

Registry
files-sdk
Type
registry:component
Access
Free
Files written
1
Licence
MIT
In the index
at or before 2026-08-11
Last confirmed
yesterday

Go to the source

files-sdk.dev haydenbleasel/files-sdk on GitHub Raw registry item This item as JSON

More from files-sdk

All 12 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
Capabilities Badgescapabilities-badgesfiles-sdkComponentsFree2 deps
Dropzonedropzonefiles-sdkComponentsFree2 deps
File Actionsfile-actionsfiles-sdkComponentsFree2 deps
File Browserfile-browserfiles-sdkComponentsFree2 deps
File Listfile-listfiles-sdkComponentsFree2 deps
File Previewfile-previewfiles-sdkComponentsFree2 deps
File Searchfile-searchfiles-sdkComponentsFree2 deps
Multipart Uploadermultipart-uploaderfiles-sdkComponentsFree2 deps

Also from Kynth Studios

Built for the same person as BlockDex

SkillWorks

Claude Code skills and plugins, scored

skillworks.kynth.studio

RuleStack

AGENTS.md gallery and agent-config comparison

rulestack.kynth.studio

KitGrade

SaaS starter kits, scored from measured facts

kitgrade.kynth.studio

The studio list

One product, taken apart, once a month

Kynth Studios pulls one shipped product open every month — what it does, what it cost to build, what the pipeline behind it looks like, and what the numbers did. One email a month, nothing in between.

Double opt-in — we send one confirmation link and nothing else until you click it.

BlockDex

Built by

Kynth Studios

the studio behind SkillWorks, RuleStack and KitGrade

part of Toolproof, the measurement layer for AI agent tooling

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

© 2026 BlockDex. A Kynth Studios product. Changelog

BlockDex

The studio list

One product, taken apart, once a month

Kynth Studios pulls one shipped product open every month — what it does, what it cost to build, what the pipeline behind it looks like, and what the numbers did. One email a month, nothing in between.

Double opt-in — we send one confirmation link and nothing else until you click it.

BlockDex

Built by

Kynth Studios

the studio behind SkillWorks, RuleStack and KitGrade

part of Toolproof, the measurement layer for AI agent tooling

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

© 2026 BlockDex. A Kynth Studios product. Changelog

BlockDex

The studio list

One product, taken apart, once a month

Kynth Studios pulls one shipped product open every month — what it does, what it cost to build, what the pipeline behind it looks like, and what the numbers did. One email a month, nothing in between.

Double opt-in — we send one confirmation link and nothing else until you click it.

BlockDex

Built by

Kynth Studios

the studio behind SkillWorks, RuleStack and KitGrade

part of Toolproof, the measurement layer for AI agent tooling

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

© 2026 BlockDex. A Kynth Studios product. Changelog

BlockDex