forked from shesha-io/shesha-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.tsx
More file actions
71 lines (66 loc) · 2.12 KB
/
index.tsx
File metadata and controls
71 lines (66 loc) · 2.12 KB
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
import React, { FC } from 'react';
import { IUploadFilePayload } from '@/providers/storedFiles/contexts';
import { StoredFilesRendererBase } from '@/components/';
import { IInputStyles, IStyleType, useSheshaApplication, useStoredFilesStore } from '@/providers';
import { layoutType, listType } from '@/designer-components/attachmentsEditor/attachmentsEditor';
export interface ICustomFileProps extends IInputStyles {
id?: string;
ownerId?: string;
uploadFile?: (payload: IUploadFilePayload) => void;
maxCount?: number;
allowAdd?: boolean;
allowReplace?: boolean;
allowDelete?: boolean;
allowRename?: boolean;
isStub?: boolean;
disabled?: boolean;
allowedFileTypes?: string[];
maxHeight?: string;
isDragger?: boolean;
downloadZip?: boolean;
filesLayout?: layoutType;
listType?: listType;
thumbnailWidth?: string;
thumbnailHeight?: string;
borderRadius?: number;
hideFileName?: boolean;
container?: IStyleType;
primaryColor?: string;
enableStyleOnReadonly?: boolean;
}
export const CustomFile: FC<ICustomFileProps> = (props) => {
const {
fileList,
// downloadFile,
deleteFile,
uploadFile,
downloadZipFile,
downloadFile,
isInProgress: { downloadZip },
succeeded: { downloadZip: downloadZipSuccess },
} = useStoredFilesStore();
const { backendUrl } = useSheshaApplication();
return (
<StoredFilesRendererBase
{...props}
isStub={props.isStub}
disabled={props.disabled || !props.allowAdd}
isDragger={props?.isDragger}
fileList={fileList?.map(({ url, ...rest }) => ({ url: `${backendUrl}${url}`, ...rest }))}
allowUpload={false}
allowDelete={props.allowDelete}
deleteFile={deleteFile}
uploadFile={props.uploadFile ?? uploadFile}
downloadZipFile={downloadZipFile}
downloadZip={props.downloadZip}
downloadFile={downloadFile}
isDownloadingFileListZip={downloadZip}
isDownloadZipSucceeded={downloadZipSuccess}
allowedFileTypes={props?.allowedFileTypes}
maxHeight={props?.maxHeight}
layout={props?.filesLayout}
listType={props?.listType}
/>
);
};
export default CustomFile;