@gentleduck/registry-ui 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +62 -0
- package/index.css +3 -0
- package/package.json +59 -0
- package/src/_old/_table/index.ts +5 -0
- package/src/_old/_table/table-advanced.constants.tsx +24 -0
- package/src/_old/_table/table-advanced.tsx +311 -0
- package/src/_old/_table/table-advanced.types.ts +272 -0
- package/src/_old/_table/table.constants.ts +2 -0
- package/src/_old/_table/table.hook.tsx +115 -0
- package/src/_old/_table/table.lib.ts +85 -0
- package/src/_old/_table/table.tsx +916 -0
- package/src/_old/_table/table.types.ts +118 -0
- package/src/_old/_table/todo.md +11 -0
- package/src/_old/_upload/index.ts +9 -0
- package/src/_old/_upload/todo.md +38 -0
- package/src/_old/_upload/upload-advanced-chunks.tsx +1624 -0
- package/src/_old/_upload/upload-advanced.tsx +507 -0
- package/src/_old/_upload/upload-sonner.tsx +58 -0
- package/src/_old/_upload/upload.assets.tsx +239 -0
- package/src/_old/_upload/upload.constants.tsx +75 -0
- package/src/_old/_upload/upload.dto.ts +19 -0
- package/src/_old/_upload/upload.lib.tsx +630 -0
- package/src/_old/_upload/upload.tsx +491 -0
- package/src/_old/_upload/upload.types.ts +436 -0
- package/src/accordion/accordion.tsx +247 -0
- package/src/accordion/index.ts +1 -0
- package/src/alert/alert.constants.ts +17 -0
- package/src/alert/alert.tsx +52 -0
- package/src/alert/index.ts +2 -0
- package/src/alert-dialog/alert-dialog.tsx +107 -0
- package/src/alert-dialog/index.ts +1 -0
- package/src/aspect-ratio/aspect-ratio.tsx +33 -0
- package/src/aspect-ratio/index.ts +1 -0
- package/src/audio/audio-record.tsx +776 -0
- package/src/audio/audio-visualizer.tsx +377 -0
- package/src/audio/audio.libs.ts +5 -0
- package/src/audio/audio.types.ts +50 -0
- package/src/audio/index.ts +2 -0
- package/src/avatar/avatar.tsx +78 -0
- package/src/avatar/index.ts +1 -0
- package/src/badge/badge.constants.ts +38 -0
- package/src/badge/badge.tsx +19 -0
- package/src/badge/index.ts +2 -0
- package/src/breadcrumb/breadcrumb.tsx +119 -0
- package/src/breadcrumb/index.ts +1 -0
- package/src/button/button.constants.ts +44 -0
- package/src/button/button.tsx +79 -0
- package/src/button/button.types.ts +38 -0
- package/src/button/index.ts +3 -0
- package/src/button-group/button-group.constants.ts +26 -0
- package/src/button-group/button-group.tsx +65 -0
- package/src/button-group/index.ts +2 -0
- package/src/calendar/calendar.tsx +191 -0
- package/src/calendar/index.ts +1 -0
- package/src/card/card.tsx +81 -0
- package/src/card/index.ts +1 -0
- package/src/carousel/carousel.tsx +211 -0
- package/src/carousel/carousel.types.ts +23 -0
- package/src/carousel/index.ts +2 -0
- package/src/chart/chart.libs.ts +27 -0
- package/src/chart/chart.tsx +260 -0
- package/src/chart/chart.types.ts +38 -0
- package/src/chart/index.ts +3 -0
- package/src/checkbox/checkbox.tsx +144 -0
- package/src/checkbox/checkbox.types.ts +24 -0
- package/src/checkbox/index.ts +2 -0
- package/src/collapsible/collapsible.tsx +151 -0
- package/src/collapsible/index.ts +1 -0
- package/src/combobox/combobox.tsx +132 -0
- package/src/combobox/index.ts +1 -0
- package/src/command/command.tsx +192 -0
- package/src/command/command.types.ts +11 -0
- package/src/command/index.ts +2 -0
- package/src/context-menu/context-menu.tsx +178 -0
- package/src/context-menu/index.ts +1 -0
- package/src/dialog/dialog-responsive.tsx +137 -0
- package/src/dialog/dialog.tsx +97 -0
- package/src/dialog/index.ts +2 -0
- package/src/direction/direction.tsx +13 -0
- package/src/direction/index.ts +1 -0
- package/src/drawer/drawer.tsx +185 -0
- package/src/drawer/index.ts +1 -0
- package/src/dropdown-menu/dropdown-menu.tsx +181 -0
- package/src/dropdown-menu/index.ts +1 -0
- package/src/empty/empty.constants.ts +15 -0
- package/src/empty/empty.tsx +73 -0
- package/src/empty/index.ts +2 -0
- package/src/field/field.constants.ts +22 -0
- package/src/field/field.tsx +203 -0
- package/src/field/index.ts +2 -0
- package/src/hover-card/hover-card.tsx +79 -0
- package/src/hover-card/index.ts +1 -0
- package/src/input/index.ts +1 -0
- package/src/input/input.tsx +45 -0
- package/src/input-group/index.ts +1 -0
- package/src/input-group/input-group.tsx +170 -0
- package/src/input-otp/index.ts +1 -0
- package/src/input-otp/input-otp.tsx +66 -0
- package/src/item/index.ts +2 -0
- package/src/item/item.constants.ts +22 -0
- package/src/item/item.tsx +185 -0
- package/src/json-editor/index.ts +4 -0
- package/src/json-editor/json-editor.hooks.ts +21 -0
- package/src/json-editor/json-editor.libs.ts +34 -0
- package/src/json-editor/json-editor.tsx +425 -0
- package/src/json-editor/json-editor.types.ts +80 -0
- package/src/json-editor/json-editor.view.tsx +110 -0
- package/src/json-editor/json-text-area.tsx +7 -0
- package/src/kbd/index.ts +1 -0
- package/src/kbd/kbd.tsx +39 -0
- package/src/label/index.ts +1 -0
- package/src/label/label.tsx +28 -0
- package/src/menubar/index.ts +1 -0
- package/src/menubar/menubar.tsx +213 -0
- package/src/navigation-menu/index.ts +1 -0
- package/src/navigation-menu/navigation-menu.tsx +152 -0
- package/src/pagination/index.ts +2 -0
- package/src/pagination/pagination.tsx +191 -0
- package/src/pagination/pagination.types.ts +17 -0
- package/src/popover/index.ts +1 -0
- package/src/popover/popover.tsx +35 -0
- package/src/preview-panel/index.ts +3 -0
- package/src/preview-panel/preview-panel-dialog.tsx +99 -0
- package/src/preview-panel/preview-panel.tsx +389 -0
- package/src/preview-panel/preview-panel.types.ts +49 -0
- package/src/progress/index.ts +1 -0
- package/src/progress/progress.tsx +32 -0
- package/src/radio-group/index.ts +1 -0
- package/src/radio-group/radio-group.tsx +92 -0
- package/src/resizable/index.ts +1 -0
- package/src/resizable/resizable.tsx +52 -0
- package/src/scroll-area/index.ts +1 -0
- package/src/scroll-area/scroll-area.tsx +30 -0
- package/src/select/index.ts +1 -0
- package/src/select/select.tsx +138 -0
- package/src/separator/index.ts +1 -0
- package/src/separator/separator.tsx +28 -0
- package/src/sheet/index.ts +2 -0
- package/src/sheet/sheet.constants.tsx +20 -0
- package/src/sheet/sheet.tsx +92 -0
- package/src/sidebar/index.ts +4 -0
- package/src/sidebar/sidebar.constants.ts +30 -0
- package/src/sidebar/sidebar.hooks.ts +13 -0
- package/src/sidebar/sidebar.tsx +676 -0
- package/src/sidebar/sidebar.types.ts +28 -0
- package/src/skeleton/index.ts +1 -0
- package/src/skeleton/skeleton.tsx +22 -0
- package/src/slider/index.ts +1 -0
- package/src/slider/slider.tsx +57 -0
- package/src/sonner/index.ts +4 -0
- package/src/sonner/sonner.chunks.tsx +80 -0
- package/src/sonner/sonner.libs.ts +13 -0
- package/src/sonner/sonner.tsx +31 -0
- package/src/sonner/sonner.types.ts +9 -0
- package/src/switch/index.ts +1 -0
- package/src/switch/switch.tsx +63 -0
- package/src/table/index.ts +1 -0
- package/src/table/table.tsx +95 -0
- package/src/tabs/index.ts +1 -0
- package/src/tabs/tabs.tsx +151 -0
- package/src/textarea/index.ts +1 -0
- package/src/textarea/textarea.tsx +24 -0
- package/src/toggle/index.ts +2 -0
- package/src/toggle/toggle.constants.ts +22 -0
- package/src/toggle/toggle.tsx +24 -0
- package/src/toggle-group/index.ts +1 -0
- package/src/toggle-group/toggle-group.tsx +69 -0
- package/src/tooltip/index.ts +1 -0
- package/src/tooltip/tooltip.tsx +32 -0
- package/src/upload/index.ts +1 -0
- package/src/upload/upload.constants.tsx +19 -0
- package/src/upload/upload.libs.ts +97 -0
- package/src/upload/upload.tsx +340 -0
- package/src/upload/upload.types.ts +44 -0
- package/tsconfig.json +25 -0
|
@@ -0,0 +1,507 @@
|
|
|
1
|
+
// //@ts-nocheck
|
|
2
|
+
// 'use client'
|
|
3
|
+
//
|
|
4
|
+
// import React from 'react'
|
|
5
|
+
// import { ScrollBar, Separator, Skeleton } from '@/registry/default/ui'
|
|
6
|
+
// import { ScrollArea } from '@/registry/default/ui'
|
|
7
|
+
// import { Button, buttonVariants } from '../button'
|
|
8
|
+
// import { Clipboard, X } from 'lucide-react'
|
|
9
|
+
// import {
|
|
10
|
+
// SelectedFoldersType,
|
|
11
|
+
// StateWithExtraFeatures,
|
|
12
|
+
// UploadAdvancedContextType,
|
|
13
|
+
// UploadAdvancedProviderProps,
|
|
14
|
+
// UploadAttachmentsTreeItemProps,
|
|
15
|
+
// } from './upload.types'
|
|
16
|
+
// import {
|
|
17
|
+
// UploadAdvancedNoAttachments,
|
|
18
|
+
// UploadAdvancedAddFolderButton,
|
|
19
|
+
// UploadAdvancedAttachmentFile,
|
|
20
|
+
// UploadAdvancedAttachmentFolder,
|
|
21
|
+
// UploadAdvancedButton,
|
|
22
|
+
// UploadAdvancedAlertDeleteAttachments,
|
|
23
|
+
// UploadAdvancedAlertMoveAction,
|
|
24
|
+
// UploadAdvancedDownloadAttachments,
|
|
25
|
+
// UploadAdvancedNavigationLayout,
|
|
26
|
+
// UploadReloadButton,
|
|
27
|
+
// UploadAdvancedSearchButton,
|
|
28
|
+
// UploadAdvancedSelectAllLayout,
|
|
29
|
+
// UploadAdvancedViewButton,
|
|
30
|
+
// UploadAdvancedAttachmentsRowFile,
|
|
31
|
+
// UploadAdvancedAttachmentsRowFolder,
|
|
32
|
+
// } from './upload-advanced-chunks'
|
|
33
|
+
//
|
|
34
|
+
// import { format } from 'date-fns'
|
|
35
|
+
// import { filesize } from 'filesize'
|
|
36
|
+
// import { cn } from '@/lib'
|
|
37
|
+
// import {
|
|
38
|
+
// CONTENT_WIDTH_PREVIEW_OPEN,
|
|
39
|
+
// PREVIEW_WIDTH,
|
|
40
|
+
// TREE_HEIGHT,
|
|
41
|
+
// TREE_WIDTH,
|
|
42
|
+
// } from './upload.constants'
|
|
43
|
+
// import { Table, TableBody, TableHead, TableHeader, TableRow } from '../table'
|
|
44
|
+
// import {
|
|
45
|
+
// BucketFilesType,
|
|
46
|
+
// BucketFoldersType,
|
|
47
|
+
// } from '../../../../upload-api/src/globals'
|
|
48
|
+
//
|
|
49
|
+
// const UploadAdvancedContext = React.createContext<UploadAdvancedContextType<
|
|
50
|
+
// BucketFilesType | BucketFoldersType
|
|
51
|
+
// > | null>(null)
|
|
52
|
+
//
|
|
53
|
+
// export const useUploadAdvancedContext = (): UploadAdvancedContextType<
|
|
54
|
+
// BucketFilesType | BucketFoldersType
|
|
55
|
+
// > => {
|
|
56
|
+
// const context = React.useContext(UploadAdvancedContext)
|
|
57
|
+
// if (!context) {
|
|
58
|
+
// throw new Error('useUploadContext must be used within an UploadProvider')
|
|
59
|
+
// }
|
|
60
|
+
// return context
|
|
61
|
+
// }
|
|
62
|
+
//
|
|
63
|
+
// export const UploadAdvancedProvider = ({
|
|
64
|
+
// selectedFolder,
|
|
65
|
+
// attachments,
|
|
66
|
+
// className,
|
|
67
|
+
// currentBucket,
|
|
68
|
+
// children,
|
|
69
|
+
// actions,
|
|
70
|
+
// ...props
|
|
71
|
+
// }: UploadAdvancedProviderProps): JSX.Element => {
|
|
72
|
+
// const [_selectedFolder, setSelectedFolder] =
|
|
73
|
+
// React.useState<SelectedFoldersType>(new Map())
|
|
74
|
+
// const [_attachments, setAttachments] = React.useState<
|
|
75
|
+
// StateWithExtraFeatures<(BucketFilesType | BucketFoldersType)[]>
|
|
76
|
+
// >({
|
|
77
|
+
// state: 'pending',
|
|
78
|
+
// data: [],
|
|
79
|
+
// })
|
|
80
|
+
// const [attachmentsState, setAttachmentsState] = React.useState<
|
|
81
|
+
// (BucketFilesType | BucketFoldersType)[]
|
|
82
|
+
// >([])
|
|
83
|
+
// const [previewFile, setPreviewFile] = React.useState<BucketFilesType | null>(
|
|
84
|
+
// null,
|
|
85
|
+
// )
|
|
86
|
+
// const [uploadQuery, setUploadQuery] = React.useState<string>('')
|
|
87
|
+
// const [selectedAttachments, setSelectedAttachments] = React.useState<
|
|
88
|
+
// BucketFilesType[]
|
|
89
|
+
// >([])
|
|
90
|
+
// const [uploadView, setUploadView] = React.useState<'column' | 'row'>(
|
|
91
|
+
// (localStorage.getItem('View') as 'column' | 'row') ?? 'column',
|
|
92
|
+
// )
|
|
93
|
+
//
|
|
94
|
+
// return (
|
|
95
|
+
// <UploadAdvancedContext.Provider
|
|
96
|
+
// value={{
|
|
97
|
+
// attachments: _attachments,
|
|
98
|
+
// setAttachments,
|
|
99
|
+
// attachmentsState,
|
|
100
|
+
// setAttachmentsState,
|
|
101
|
+
// selectedFolder: _selectedFolder,
|
|
102
|
+
// setSelectedFolder,
|
|
103
|
+
// previewFile,
|
|
104
|
+
// setPreviewFile,
|
|
105
|
+
// uploadQuery,
|
|
106
|
+
// setUploadQuery,
|
|
107
|
+
// selectedAttachments,
|
|
108
|
+
// setSelectedAttachments,
|
|
109
|
+
// currentBucket,
|
|
110
|
+
// uploadView,
|
|
111
|
+
// setUploadView,
|
|
112
|
+
// actions,
|
|
113
|
+
// }}
|
|
114
|
+
// >
|
|
115
|
+
// <div
|
|
116
|
+
// className={cn(
|
|
117
|
+
// 'flex flex-col w-full rounded-md bg-muted/10 border-border border overflow-hidden',
|
|
118
|
+
// className,
|
|
119
|
+
// )}
|
|
120
|
+
// {...props}
|
|
121
|
+
// >
|
|
122
|
+
// {children}
|
|
123
|
+
// </div>
|
|
124
|
+
// </UploadAdvancedContext.Provider>
|
|
125
|
+
// )
|
|
126
|
+
// }
|
|
127
|
+
//
|
|
128
|
+
// export const UploadAdvancedHeader = () => {
|
|
129
|
+
// return (
|
|
130
|
+
// <>
|
|
131
|
+
// <div className="w-full h-[42px] relative">
|
|
132
|
+
// <UploadAdvancedActionsLayout />
|
|
133
|
+
// <UploadAdvancedMultiSelectLayout />
|
|
134
|
+
// </div>
|
|
135
|
+
// <Separator />
|
|
136
|
+
// </>
|
|
137
|
+
// )
|
|
138
|
+
// }
|
|
139
|
+
//
|
|
140
|
+
// export const UploadAdvancedActionsLayout = () => {
|
|
141
|
+
// const ctx = useUploadAdvancedContext()
|
|
142
|
+
// // console.log(ctx.selectedFolder)
|
|
143
|
+
// return (
|
|
144
|
+
// <div className="flex items-center justify-between">
|
|
145
|
+
// <UploadAdvancedNavigationLayout />
|
|
146
|
+
// <div
|
|
147
|
+
// className={cn(
|
|
148
|
+
// 'space-x-2 flex items-center place-content-end w-full m-0 p-2 transition-all duration-300 ease-in-out',
|
|
149
|
+
// ctx.selectedAttachments.length > 0
|
|
150
|
+
// ? 'translate-y-[-42px]'
|
|
151
|
+
// : 'translate-y-0',
|
|
152
|
+
// )}
|
|
153
|
+
// >
|
|
154
|
+
// <UploadReloadButton />
|
|
155
|
+
// <UploadAdvancedViewButton />
|
|
156
|
+
// <Separator orientation="vertical" className="h-6" />
|
|
157
|
+
// <UploadAdvancedButton />
|
|
158
|
+
// <UploadAdvancedAddFolderButton />
|
|
159
|
+
// <Separator orientation="vertical" className="h-6" />
|
|
160
|
+
// <UploadAdvancedSearchButton />
|
|
161
|
+
// </div>
|
|
162
|
+
// </div>
|
|
163
|
+
// )
|
|
164
|
+
// }
|
|
165
|
+
//
|
|
166
|
+
// export const UploadAdvancedMultiSelectLayout = () => {
|
|
167
|
+
// const { selectedAttachments, setSelectedAttachments } =
|
|
168
|
+
// useUploadAdvancedContext()
|
|
169
|
+
//
|
|
170
|
+
// return (
|
|
171
|
+
// <>
|
|
172
|
+
// <div
|
|
173
|
+
// className={cn(
|
|
174
|
+
// 'absolute top-1/2 -translate-y-1/2 space-x-2 flex items-center w-full m-0 p-2 transition-all duration-300 ease-in-out bg-background pointer-events-all',
|
|
175
|
+
// selectedAttachments.length > 0 ? '' : 'opacity-0 pointer-events-none',
|
|
176
|
+
// )}
|
|
177
|
+
// >
|
|
178
|
+
// <Button
|
|
179
|
+
// size={'xs'}
|
|
180
|
+
// variant={'ghost'}
|
|
181
|
+
// className="p-1 h-auto"
|
|
182
|
+
// onClick={() => setSelectedAttachments([])}
|
|
183
|
+
// icon={{ children: X }}
|
|
184
|
+
// />
|
|
185
|
+
// <div className="flex items-center gap-3">
|
|
186
|
+
// <span className="text-xs text-muted-foreground">
|
|
187
|
+
// {selectedAttachments.length} Attachment
|
|
188
|
+
// {selectedAttachments.length === 1 ? ' is' : 's are'} selected
|
|
189
|
+
// </span>
|
|
190
|
+
// <Separator orientation="vertical" className="h-6" />
|
|
191
|
+
// <UploadAdvancedDownloadAttachments
|
|
192
|
+
// itemsName={[...selectedAttachments.map((item) => item.name)]}
|
|
193
|
+
// />
|
|
194
|
+
// <Separator orientation="vertical" className="h-6" />
|
|
195
|
+
// <UploadAdvancedAlertMoveAction
|
|
196
|
+
// itemsName={[...selectedAttachments.map((item) => item.name)]}
|
|
197
|
+
// />
|
|
198
|
+
// <UploadAdvancedAlertDeleteAttachments
|
|
199
|
+
// itemsName={[...selectedAttachments.map((item) => item.name)]}
|
|
200
|
+
// className={cn(
|
|
201
|
+
// buttonVariants({
|
|
202
|
+
// className: 'w-fit',
|
|
203
|
+
// size: 'xs',
|
|
204
|
+
// variant: 'destructive',
|
|
205
|
+
// border: 'destructive',
|
|
206
|
+
// }),
|
|
207
|
+
// )}
|
|
208
|
+
// itemsToDelete={[...selectedAttachments.map((item) => item.id)]}
|
|
209
|
+
// />
|
|
210
|
+
// </div>
|
|
211
|
+
// </div>
|
|
212
|
+
// </>
|
|
213
|
+
// )
|
|
214
|
+
// }
|
|
215
|
+
//
|
|
216
|
+
// export const UploadAdnvacedContent = React.memo(() => {
|
|
217
|
+
// const Component = () => {
|
|
218
|
+
// const { uploadView } = useUploadAdvancedContext()
|
|
219
|
+
// return uploadView === 'column' ? (
|
|
220
|
+
// <UploadAdvancedColumnView />
|
|
221
|
+
// ) : (
|
|
222
|
+
// <UploadAdvancedRowView />
|
|
223
|
+
// )
|
|
224
|
+
// }
|
|
225
|
+
//
|
|
226
|
+
// return (
|
|
227
|
+
// <div className="h-full relative">
|
|
228
|
+
// <UploadFilePreview />
|
|
229
|
+
// <Component />
|
|
230
|
+
// </div>
|
|
231
|
+
// )
|
|
232
|
+
// })
|
|
233
|
+
//
|
|
234
|
+
// export const UploadAdvancedColumnView = () => {
|
|
235
|
+
// const ctx = useUploadAdvancedContext() ?? {}
|
|
236
|
+
//
|
|
237
|
+
// return (
|
|
238
|
+
// <ScrollArea
|
|
239
|
+
// className={cn(
|
|
240
|
+
// 'transition-all duration-300 ease-in-out w-full [&>div>div]:h-full',
|
|
241
|
+
// TREE_HEIGHT,
|
|
242
|
+
// ctx.previewFile && CONTENT_WIDTH_PREVIEW_OPEN,
|
|
243
|
+
// )}
|
|
244
|
+
// >
|
|
245
|
+
// <div className="flex items-center h-full rounded-md relative overflow-hidden">
|
|
246
|
+
// <UploadAttachmentsTree
|
|
247
|
+
// key={'main-tree'}
|
|
248
|
+
// data={ctx.attachments}
|
|
249
|
+
// uploadQuery={ctx.uploadQuery}
|
|
250
|
+
// />
|
|
251
|
+
// {Array.from(ctx.selectedFolder.entries()).map(
|
|
252
|
+
// ([folderKey, folderContent], idx) => (
|
|
253
|
+
// <UploadAttachmentsTree
|
|
254
|
+
// key={`${idx}-${folderKey}`}
|
|
255
|
+
// data={folderContent}
|
|
256
|
+
// uploadQuery={ctx.uploadQuery}
|
|
257
|
+
// />
|
|
258
|
+
// ),
|
|
259
|
+
// )}
|
|
260
|
+
// </div>
|
|
261
|
+
// <ScrollBar orientation="horizontal" />
|
|
262
|
+
// </ScrollArea>
|
|
263
|
+
// )
|
|
264
|
+
// }
|
|
265
|
+
//
|
|
266
|
+
// export const UploadAttachmentsTree = React.memo(
|
|
267
|
+
// ({ data, uploadQuery }: UploadAttachmentsTreeItemProps) => {
|
|
268
|
+
// const { data: attachments, state } = data ?? {}
|
|
269
|
+
//
|
|
270
|
+
// if (state === 'pending') {
|
|
271
|
+
// return (
|
|
272
|
+
// <div
|
|
273
|
+
// className={cn(
|
|
274
|
+
// 'flex flex-col p-2 bg-muted/10 [&>div>div]:h-full border-r border-r-border gap-1 opacity-50',
|
|
275
|
+
// TREE_WIDTH,
|
|
276
|
+
// TREE_HEIGHT,
|
|
277
|
+
// )}
|
|
278
|
+
// >
|
|
279
|
+
// {Array.from({
|
|
280
|
+
// length:
|
|
281
|
+
// Number.parseInt(TREE_HEIGHT.match(/\d+/)?.[0] ?? '', 10) / 30,
|
|
282
|
+
// }).map((_, idx) => (
|
|
283
|
+
// <Skeleton className="h-[28px] w-full rounded-md" key={idx} />
|
|
284
|
+
// ))}
|
|
285
|
+
// </div>
|
|
286
|
+
// )
|
|
287
|
+
// // <Loader className="animate-spin opacity-50" />
|
|
288
|
+
// }
|
|
289
|
+
//
|
|
290
|
+
// if (state === 'error') {
|
|
291
|
+
// return (
|
|
292
|
+
// <div className="w-full h-full flex items-center justify-center">
|
|
293
|
+
// <X /> Error
|
|
294
|
+
// </div>
|
|
295
|
+
// )
|
|
296
|
+
// }
|
|
297
|
+
//
|
|
298
|
+
// const filteredItems = (
|
|
299
|
+
// uploadQuery
|
|
300
|
+
// ? attachments?.filter((item) =>
|
|
301
|
+
// item?.name.toLowerCase().includes(uploadQuery.toLowerCase()),
|
|
302
|
+
// )
|
|
303
|
+
// : attachments
|
|
304
|
+
// ) as (BucketFilesType | BucketFoldersType)[]
|
|
305
|
+
//
|
|
306
|
+
// if (state === 'success') {
|
|
307
|
+
// return filteredItems?.length ? (
|
|
308
|
+
// <div className="flex flex-col h-full border-r border-r-border">
|
|
309
|
+
// <UploadAdvancedSelectAllLayout attachments={filteredItems} />
|
|
310
|
+
// <ScrollArea
|
|
311
|
+
// className={cn(
|
|
312
|
+
// 'p-2 bg-muted/10 [&>div>div]:h-full',
|
|
313
|
+
// TREE_WIDTH,
|
|
314
|
+
// TREE_HEIGHT,
|
|
315
|
+
// )}
|
|
316
|
+
// >
|
|
317
|
+
// <div className="flex flex-col gap-1 h-full ">
|
|
318
|
+
// {filteredItems.map((attachment) => {
|
|
319
|
+
// if ((attachment as BucketFilesType).url) {
|
|
320
|
+
// return (
|
|
321
|
+
// <UploadAdvancedAttachmentFile
|
|
322
|
+
// key={attachment.id}
|
|
323
|
+
// attachmentFile={attachment as BucketFilesType}
|
|
324
|
+
// />
|
|
325
|
+
// )
|
|
326
|
+
// }
|
|
327
|
+
// return (
|
|
328
|
+
// <UploadAdvancedAttachmentFolder
|
|
329
|
+
// key={attachment.id}
|
|
330
|
+
// folder={attachment as BucketFoldersType}
|
|
331
|
+
// />
|
|
332
|
+
// )
|
|
333
|
+
// })}
|
|
334
|
+
// </div>
|
|
335
|
+
// </ScrollArea>
|
|
336
|
+
// </div>
|
|
337
|
+
// ) : (
|
|
338
|
+
// <UploadAdvancedNoAttachments />
|
|
339
|
+
// )
|
|
340
|
+
// }
|
|
341
|
+
// },
|
|
342
|
+
// )
|
|
343
|
+
//
|
|
344
|
+
// export const UploadAdvancedRowView = () => {
|
|
345
|
+
// const { previewFile } = useUploadAdvancedContext() ?? {}
|
|
346
|
+
// return (
|
|
347
|
+
// <ScrollArea
|
|
348
|
+
// className={cn(
|
|
349
|
+
// 'transition-all duration-300 ease-in-out w-full',
|
|
350
|
+
// TREE_HEIGHT,
|
|
351
|
+
// previewFile && CONTENT_WIDTH_PREVIEW_OPEN,
|
|
352
|
+
// )}
|
|
353
|
+
// >
|
|
354
|
+
// <ScrollBar orientation="horizontal" />
|
|
355
|
+
// </ScrollArea>
|
|
356
|
+
// )
|
|
357
|
+
// // <UploadAttachmentsRow />
|
|
358
|
+
// }
|
|
359
|
+
//
|
|
360
|
+
// export const UploadAttachmentsRow = () => {
|
|
361
|
+
// const ctx = useUploadAdvancedContext()
|
|
362
|
+
//
|
|
363
|
+
// const filteredItems = (
|
|
364
|
+
// ctx.uploadQuery
|
|
365
|
+
// ? ctx.attachments.data?.filter((item) =>
|
|
366
|
+
// item.name.toLowerCase().includes(ctx.uploadQuery.toLowerCase()),
|
|
367
|
+
// )
|
|
368
|
+
// : ctx.attachments
|
|
369
|
+
// ) as (BucketFilesType | BucketFoldersType)[]
|
|
370
|
+
//
|
|
371
|
+
// return (
|
|
372
|
+
// <div className="w-full h-full">
|
|
373
|
+
// {filteredItems?.length > 0 ? (
|
|
374
|
+
// <Table>
|
|
375
|
+
// <TableHeader className="bg-muted/70 [&_th]:py-2 [&_th]:h-fit [&_th]:text-muted-foreground [&_th]:text-xs">
|
|
376
|
+
// <TableRow>
|
|
377
|
+
// <TableHead className="w-[400px]">Name</TableHead>
|
|
378
|
+
// <TableHead className="w-[100px]">Size</TableHead>
|
|
379
|
+
// <TableHead className="w-[100px]">Type</TableHead>
|
|
380
|
+
// <TableHead className="w-[200px]">Created At</TableHead>
|
|
381
|
+
// <TableHead className="w-[200px]">Updated At</TableHead>
|
|
382
|
+
// </TableRow>
|
|
383
|
+
// </TableHeader>
|
|
384
|
+
// <TableBody>
|
|
385
|
+
// {filteredItems.map((attachment) =>
|
|
386
|
+
// (attachment as BucketFoldersType).files_count >= 0 ? (
|
|
387
|
+
// <UploadAdvancedAttachmentsRowFolder
|
|
388
|
+
// folder={attachment as BucketFoldersType}
|
|
389
|
+
// />
|
|
390
|
+
// ) : (
|
|
391
|
+
// <UploadAdvancedAttachmentsRowFile
|
|
392
|
+
// attachmentFile={attachment as BucketFilesType}
|
|
393
|
+
// />
|
|
394
|
+
// ),
|
|
395
|
+
// )}
|
|
396
|
+
// </TableBody>
|
|
397
|
+
// </Table>
|
|
398
|
+
// ) : (
|
|
399
|
+
// <div className="[&>div]:border-none [&_>div]:w-full [&_div]:h-full h-full">
|
|
400
|
+
// <UploadAdvancedNoAttachments />
|
|
401
|
+
// </div>
|
|
402
|
+
// )}
|
|
403
|
+
// </div>
|
|
404
|
+
// )
|
|
405
|
+
// }
|
|
406
|
+
//
|
|
407
|
+
// export const UploadFilePreview = (): JSX.Element => {
|
|
408
|
+
// const ctx = useUploadAdvancedContext()
|
|
409
|
+
//
|
|
410
|
+
// return (
|
|
411
|
+
// <>
|
|
412
|
+
// <div
|
|
413
|
+
// className={cn(
|
|
414
|
+
// PREVIEW_WIDTH,
|
|
415
|
+
// 'absolute top-0 right-0 h-full duration-300 ease-in-out translate-x-[100%] z-10 dark:bg-[#121212] bg-card',
|
|
416
|
+
// ctx.previewFile && 'translate-x-0',
|
|
417
|
+
// )}
|
|
418
|
+
// >
|
|
419
|
+
// <ScrollArea className="h-full">
|
|
420
|
+
// <Button
|
|
421
|
+
// size={'xs'}
|
|
422
|
+
// variant={'nothing'}
|
|
423
|
+
// className="absolute top-2 right-4 p-0"
|
|
424
|
+
// icon={{ children: X }}
|
|
425
|
+
// onClick={() => ctx.setPreviewFile(null)}
|
|
426
|
+
// />
|
|
427
|
+
// <div className="border-l border-l-border bg-muted/10 w-full h-full px-4 py-8">
|
|
428
|
+
// <div className="border border-border w-full h-[180px] flex items-center justify-center rounded-md overflow-hidden">
|
|
429
|
+
// <img
|
|
430
|
+
// src={ctx.previewFile?.url ?? ''}
|
|
431
|
+
// className="object-contain size-full"
|
|
432
|
+
// alt={ctx.previewFile?.name}
|
|
433
|
+
// />
|
|
434
|
+
// </div>
|
|
435
|
+
// <div className="my-4 flex flex-col gap-1">
|
|
436
|
+
// <h6 className="text-sm font-medium truncate max-w-[70%]">
|
|
437
|
+
// {ctx.previewFile?.name}
|
|
438
|
+
// </h6>
|
|
439
|
+
// <p className="text-accent-foreground/70 text-xs flex items-center gap-1 fno">
|
|
440
|
+
// <span>{ctx.previewFile?.type ?? 'not-specified'}</span>-
|
|
441
|
+
// <span>
|
|
442
|
+
// {filesize(ctx.previewFile?.size ?? 0, {
|
|
443
|
+
// round: 0,
|
|
444
|
+
// })}
|
|
445
|
+
// </span>
|
|
446
|
+
// </p>
|
|
447
|
+
// </div>
|
|
448
|
+
// <div className="my-4 flex flex-col gap-1">
|
|
449
|
+
// <h6 className="text-xs font-medium text-accent-foreground/90">
|
|
450
|
+
// Created at
|
|
451
|
+
// </h6>
|
|
452
|
+
// <p className="text-accent-foreground/70 text-xs flex items-center gap-1 fno">
|
|
453
|
+
// {ctx.previewFile
|
|
454
|
+
// ? format(
|
|
455
|
+
// new Date(ctx.previewFile?.created_at ?? Date.now()),
|
|
456
|
+
// 'dd/MM/yyyy hh:mm:ss a',
|
|
457
|
+
// )
|
|
458
|
+
// : ''}
|
|
459
|
+
// </p>
|
|
460
|
+
// </div>
|
|
461
|
+
// <div className="my-4 flex flex-col gap-1">
|
|
462
|
+
// <h6 className="text-xs font-medium text-accent-foreground/90">
|
|
463
|
+
// Updated at
|
|
464
|
+
// </h6>
|
|
465
|
+
// <p className="text-accent-foreground/70 text-xs flex items-center gap-1 fno">
|
|
466
|
+
// {ctx.previewFile
|
|
467
|
+
// ? format(
|
|
468
|
+
// new Date(ctx.previewFile?.updated_at ?? Date.now()),
|
|
469
|
+
// 'dd/MM/yyyy hh:mm:ss a',
|
|
470
|
+
// )
|
|
471
|
+
// : ''}
|
|
472
|
+
// </p>
|
|
473
|
+
// </div>
|
|
474
|
+
// <div className="flex flex-row gap-2 [&_button]:px-3 mt-4 mb-2 ">
|
|
475
|
+
// <UploadAdvancedDownloadAttachments
|
|
476
|
+
// itemsName={[ctx.previewFile?.name ?? '']}
|
|
477
|
+
// withinDropdown={false}
|
|
478
|
+
// />
|
|
479
|
+
// <Button
|
|
480
|
+
// size={'xs'}
|
|
481
|
+
// // variant={'secondary'}
|
|
482
|
+
// icon={{ children: Clipboard }}
|
|
483
|
+
// >
|
|
484
|
+
// Get URL
|
|
485
|
+
// </Button>
|
|
486
|
+
// </div>
|
|
487
|
+
// <Separator />
|
|
488
|
+
// <div className="my-2 flex flex-row gap-2 [&_button]:px-3">
|
|
489
|
+
// <UploadAdvancedAlertDeleteAttachments
|
|
490
|
+
// itemsName={[ctx.previewFile?.name ?? '']}
|
|
491
|
+
// className={cn(
|
|
492
|
+
// buttonVariants({
|
|
493
|
+
// className: 'w-fit',
|
|
494
|
+
// size: 'xs',
|
|
495
|
+
// variant: 'destructive',
|
|
496
|
+
// border: 'destructive',
|
|
497
|
+
// }),
|
|
498
|
+
// )}
|
|
499
|
+
// itemsToDelete={[ctx.previewFile?.id ?? '']}
|
|
500
|
+
// />
|
|
501
|
+
// </div>
|
|
502
|
+
// </div>
|
|
503
|
+
// </ScrollArea>
|
|
504
|
+
// </div>
|
|
505
|
+
// </>
|
|
506
|
+
// )
|
|
507
|
+
// }
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// //@ts-nocheck
|
|
2
|
+
// import { Progress } from '@/registry/default/ui'
|
|
3
|
+
// import { CircleCheck, Loader } from 'lucide-react'
|
|
4
|
+
// import React from 'react'
|
|
5
|
+
// import { Button } from '../button'
|
|
6
|
+
// import { formatTime } from './upload.lib'
|
|
7
|
+
// import { UploadSonnerProps } from './upload.types'
|
|
8
|
+
//
|
|
9
|
+
// /**
|
|
10
|
+
// * A component that displays the progress of an upload. It includes a progress bar, number of files being uploaded, and a cancel button.
|
|
11
|
+
// *
|
|
12
|
+
// * @param {UploadSonnerProps} props - The properties passed to the component.
|
|
13
|
+
// * @returns {JSX.Element} The rendered upload progress component.
|
|
14
|
+
// */
|
|
15
|
+
// export const UploadSonnerContent = ({
|
|
16
|
+
// progress,
|
|
17
|
+
// files,
|
|
18
|
+
// remainingTime,
|
|
19
|
+
// }: UploadSonnerProps): JSX.Element => (
|
|
20
|
+
// <div className="flex gap-3 w-full">
|
|
21
|
+
// {progress >= 100 ? (
|
|
22
|
+
// <CircleCheck className="fill-primary [&_path]:stroke-primary-foreground mt-2 !size-[18px]" />
|
|
23
|
+
// ) : (
|
|
24
|
+
// <Loader className="animate-spin text-foreground-muted mt-2 opacity-70 !size-[18px]" />
|
|
25
|
+
// )}
|
|
26
|
+
// <div className="flex flex-col gap-2 w-full">
|
|
27
|
+
// <div className="flex w-full justify-between">
|
|
28
|
+
// <p className="text-foreground text-sm">
|
|
29
|
+
// {progress >= 100
|
|
30
|
+
// ? `Upload complete`
|
|
31
|
+
// : files
|
|
32
|
+
// ? `Uploading ${files} file${files > 1 ? 's' : ''}...`
|
|
33
|
+
// : `Uploading...`}
|
|
34
|
+
// </p>
|
|
35
|
+
// <div className="flex items-center gap-2">
|
|
36
|
+
// {remainingTime && (
|
|
37
|
+
// <p className="text-foreground-light text-sm font-mono">{`${remainingTime && !isNaN(remainingTime) && isFinite(remainingTime) && remainingTime !== 0 ? `${formatTime(remainingTime)} remaining – ` : ''}`}</p>
|
|
38
|
+
// )}
|
|
39
|
+
// <p className="text-foreground-light text-sm font-mono">{`${progress}%`}</p>
|
|
40
|
+
// </div>
|
|
41
|
+
// </div>
|
|
42
|
+
// <Progress value={progress} className="w-full h-1" />
|
|
43
|
+
// <div className="flex items-center justify-between gap-2 w-full">
|
|
44
|
+
// <small className="text-foreground-muted text-xs">
|
|
45
|
+
// Please do not close the browser until completed
|
|
46
|
+
// </small>
|
|
47
|
+
//
|
|
48
|
+
// {progress >= 100 && (
|
|
49
|
+
// <Button variant="default" size="xs">
|
|
50
|
+
// Cancel
|
|
51
|
+
// </Button>
|
|
52
|
+
// )}
|
|
53
|
+
// </div>
|
|
54
|
+
// </div>
|
|
55
|
+
// </div>
|
|
56
|
+
// )
|
|
57
|
+
//
|
|
58
|
+
// export const UploadSonnerContentMemo = React.memo(UploadSonnerContent)
|