summaryrefslogtreecommitdiff
path: root/components/ui/file-list.tsx
blob: b469a08e2abb22a76561596be83587f51f0b9e9a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
"use client"

import * as React from "react"
import { FileText } from "lucide-react"
import prettyBytes from "pretty-bytes"

import { cn } from "@/lib/utils"
import { Button } from "@/components/ui/button"
import { Progress } from "@/components/ui/progress"

export const FileList = React.forwardRef<
  React.ElementRef<"div">,
  React.ComponentPropsWithoutRef<"div">
>(({ className, ...props }, ref) => (
  <div ref={ref} className={cn("grid gap-4", className)} {...props} />
))
FileList.displayName = "FileList"

export const FileListItem = React.forwardRef<
  React.ElementRef<"div">,
  React.ComponentPropsWithoutRef<"div">
>(({ className, ...props }, ref) => (
  <div
    ref={ref}
    className={cn(
      "flex items-center justify-between gap-4 rounded-xl border bg-card p-4 text-card-foreground shadow",
      className
    )}
    {...props}
  />
))
FileListItem.displayName = "FileListItem"

export const FileListHeader = React.forwardRef<
  React.ElementRef<"div">,
  React.ComponentPropsWithoutRef<"div">
>(({ className, ...props }, ref) => (
  <div
    ref={ref}
    className={cn("flex items-center gap-4", className)}
    {...props}
  />
))
FileListHeader.displayName = "FileListHeader"

export const FileListIcon = React.forwardRef<
  React.ElementRef<"div">,
  React.ComponentPropsWithoutRef<"div">
>(({ className, children, ...props }, ref) => (
  <div
    ref={ref}
    className={cn(
      "flex size-10 items-center justify-center rounded-lg border bg-muted text-muted-foreground [&>svg]:size-5",
      className
    )}
    {...props}
  >
    {children ?? <FileText />}
  </div>
))
FileListIcon.displayName = "FileListIcon"

export const FileListInfo = React.forwardRef<
  React.ElementRef<"div">,
  React.ComponentPropsWithoutRef<"div">
>(({ className, ...props }, ref) => (
  <div ref={ref} className={cn("flex flex-1 items-center gap-2", className)} {...props} />
))
FileListInfo.displayName = "FileListInfo"

export const FileListName = React.forwardRef<
  React.ElementRef<"p">,
  React.ComponentPropsWithoutRef<"p">
>(({ className, ...props }, ref) => (
  <p
    ref={ref}
    className={cn("text-sm font-medium leading-none tracking-tight", className)}
    {...props}
  />
))
FileListName.displayName = "FileListName"

export const FileListDescription = React.forwardRef<
  React.ElementRef<"div">,
  React.ComponentPropsWithoutRef<"div">
>(({ className, ...props }, ref) => (
  <div
    ref={ref}
    className={cn(
      "flex items-center gap-2 text-xs text-muted-foreground",
      className
    )}
    {...props}
  />
))
FileListDescription.displayName = "FileListDescription"

export const FileListDescriptionSeparator = React.forwardRef<
  React.ElementRef<"span">,
  React.ComponentPropsWithoutRef<"span">
>(({ children, ...props }, ref) => (
  <span ref={ref} {...props}>
    {children ?? "•"}
  </span>
))
FileListDescriptionSeparator.displayName = "FileListDescriptionSeparator"

export interface FileListSizeProps
  extends React.ComponentPropsWithoutRef<"span"> {
  children: number
}

export const FileListSize = React.forwardRef<
  React.ElementRef<"span">,
  FileListSizeProps
>(({ children, ...props }, ref) => (
  <span ref={ref} {...props}>
    {prettyBytes(children)}
  </span>
))
FileListSize.displayName = "FileListSize"

export const FileListProgress = React.forwardRef<
  React.ElementRef<typeof Progress>,
  React.ComponentPropsWithoutRef<typeof Progress>
>(({ className, ...props }, ref) => (
  <Progress ref={ref} className={cn("h-1", className)} {...props} />
))
FileListProgress.displayName = "FileListProgress"

export const FileListDescriptionText = React.forwardRef<
  React.ElementRef<"span">,
  React.ComponentPropsWithoutRef<"span">
>(({ className, ...props }, ref) => (
  <span
    ref={ref}
    className={cn("flex items-center gap-1.5 [&>svg]:size-3", className)}
    {...props}
  />
))
FileListDescriptionText.displayName = "FileListDescriptionText"

export const FileListContent = React.forwardRef<
  React.ElementRef<"div">,
  React.ComponentPropsWithoutRef<"div">
>((props, ref) => <div ref={ref} {...props} />)
FileListContent.displayName = "FileListContent"

export const FileListActions = React.forwardRef<
  React.ElementRef<"div">,
  React.ComponentPropsWithoutRef<"div">
>(({ className, ...props }, ref) => (
  <div
    ref={ref}
    className={cn("flex items-center gap-2", className)}
    {...props}
  />
))
FileListActions.displayName = "FileListActions"

export const FileListAction = React.forwardRef<
  React.ElementRef<typeof Button>,
  React.ComponentPropsWithoutRef<typeof Button>
>(({ className, variant = "outline", size = "icon", ...props }, ref) => (
  <Button
    ref={ref}
    variant={variant}
    size={size}
    className={cn("size-7 [&_svg]:size-3.5", className)}
    {...props}
  />
))
FileListAction.displayName = "FileListAction"