@aws-amplify/ui-react-storage 0.0.0-next-3c3fbf4-20230404001107
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/LICENSE +201 -0
- package/README.md +23 -0
- package/dist/esm/components/StorageManager/StorageManager.mjs +1 -0
- package/dist/esm/components/StorageManager/hooks/useDropZone/useDropZone.mjs +1 -0
- package/dist/esm/components/StorageManager/hooks/useStorageManager/actions.mjs +1 -0
- package/dist/esm/components/StorageManager/hooks/useStorageManager/reducer.mjs +1 -0
- package/dist/esm/components/StorageManager/hooks/useStorageManager/types.mjs +1 -0
- package/dist/esm/components/StorageManager/hooks/useStorageManager/useStorageManager.mjs +1 -0
- package/dist/esm/components/StorageManager/hooks/useUploadFiles/useUploadFiles.mjs +1 -0
- package/dist/esm/components/StorageManager/types.mjs +1 -0
- package/dist/esm/components/StorageManager/ui/Container/Container.mjs +1 -0
- package/dist/esm/components/StorageManager/ui/DropZone/DropZone.mjs +1 -0
- package/dist/esm/components/StorageManager/ui/FileList/FileControl.mjs +1 -0
- package/dist/esm/components/StorageManager/ui/FileList/FileDetails.mjs +1 -0
- package/dist/esm/components/StorageManager/ui/FileList/FileList.mjs +1 -0
- package/dist/esm/components/StorageManager/ui/FileList/FileRemoveButton.mjs +1 -0
- package/dist/esm/components/StorageManager/ui/FileList/FileStatusMessage.mjs +1 -0
- package/dist/esm/components/StorageManager/ui/FileList/FileThumbnail.mjs +1 -0
- package/dist/esm/components/StorageManager/ui/FileListHeader/FileListHeader.mjs +1 -0
- package/dist/esm/components/StorageManager/ui/FilePicker/FilePicker.mjs +1 -0
- package/dist/esm/components/StorageManager/utils/checkMaxFileSize.mjs +1 -0
- package/dist/esm/components/StorageManager/utils/displayText.mjs +1 -0
- package/dist/esm/components/StorageManager/utils/filterAllowedFiles.mjs +1 -0
- package/dist/esm/components/StorageManager/utils/humanFileSize.mjs +1 -0
- package/dist/esm/components/StorageManager/utils/uploadFile.mjs +1 -0
- package/dist/esm/index.mjs +1 -0
- package/dist/index.js +1 -0
- package/dist/styles.css +4627 -0
- package/dist/styles.js +2 -0
- package/dist/types/components/StorageManager/StorageManager.d.ts +11 -0
- package/dist/types/components/StorageManager/hooks/index.d.ts +3 -0
- package/dist/types/components/StorageManager/hooks/useDropZone/index.d.ts +1 -0
- package/dist/types/components/StorageManager/hooks/useDropZone/useDropZone.d.ts +13 -0
- package/dist/types/components/StorageManager/hooks/useStorageManager/actions.d.ts +19 -0
- package/dist/types/components/StorageManager/hooks/useStorageManager/index.d.ts +1 -0
- package/dist/types/components/StorageManager/hooks/useStorageManager/reducer.d.ts +2 -0
- package/dist/types/components/StorageManager/hooks/useStorageManager/types.d.ts +37 -0
- package/dist/types/components/StorageManager/hooks/useStorageManager/useStorageManager.d.ts +31 -0
- package/dist/types/components/StorageManager/hooks/useUploadFiles/index.d.ts +1 -0
- package/dist/types/components/StorageManager/hooks/useUploadFiles/useUploadFiles.d.ts +5 -0
- package/dist/types/components/StorageManager/index.d.ts +3 -0
- package/dist/types/components/StorageManager/types.d.ts +100 -0
- package/dist/types/components/StorageManager/ui/Container/Container.d.ts +6 -0
- package/dist/types/components/StorageManager/ui/Container/index.d.ts +1 -0
- package/dist/types/components/StorageManager/ui/DropZone/DropZone.d.ts +3 -0
- package/dist/types/components/StorageManager/ui/DropZone/index.d.ts +2 -0
- package/dist/types/components/StorageManager/ui/DropZone/types.d.ts +13 -0
- package/dist/types/components/StorageManager/ui/FileList/FileControl.d.ts +3 -0
- package/dist/types/components/StorageManager/ui/FileList/FileDetails.d.ts +3 -0
- package/dist/types/components/StorageManager/ui/FileList/FileList.d.ts +3 -0
- package/dist/types/components/StorageManager/ui/FileList/FileRemoveButton.d.ts +3 -0
- package/dist/types/components/StorageManager/ui/FileList/FileStatusMessage.d.ts +3 -0
- package/dist/types/components/StorageManager/ui/FileList/FileThumbnail.d.ts +3 -0
- package/dist/types/components/StorageManager/ui/FileList/index.d.ts +2 -0
- package/dist/types/components/StorageManager/ui/FileList/types.d.ts +61 -0
- package/dist/types/components/StorageManager/ui/FileListHeader/FileListHeader.d.ts +9 -0
- package/dist/types/components/StorageManager/ui/FileListHeader/index.d.ts +1 -0
- package/dist/types/components/StorageManager/ui/FilePicker/FilePicker.d.ts +6 -0
- package/dist/types/components/StorageManager/ui/FilePicker/index.d.ts +1 -0
- package/dist/types/components/StorageManager/ui/index.d.ts +5 -0
- package/dist/types/components/StorageManager/utils/checkMaxFileSize.d.ts +5 -0
- package/dist/types/components/StorageManager/utils/displayText.d.ts +19 -0
- package/dist/types/components/StorageManager/utils/filterAllowedFiles.d.ts +1 -0
- package/dist/types/components/StorageManager/utils/humanFileSize.d.ts +11 -0
- package/dist/types/components/StorageManager/utils/index.d.ts +5 -0
- package/dist/types/components/StorageManager/utils/uploadFile.d.ts +19 -0
- package/dist/types/components/index.d.ts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/styles.d.ts +1 -0
- package/package.json +94 -0
package/dist/styles.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { StorageManagerProps } from './types';
|
|
3
|
+
declare function StorageManager({ acceptedFileTypes, accessLevel, defaultFiles, displayText: overrideDisplayText, isResumable, maxFileCount, maxFileSize, onUploadError, onUploadSuccess, onFileRemove, showThumbnails, processFile, components, provider, path, }: StorageManagerProps): JSX.Element;
|
|
4
|
+
declare namespace StorageManager {
|
|
5
|
+
var Container: typeof import("./ui").Container;
|
|
6
|
+
var DropZone: typeof import("./ui").DropZone;
|
|
7
|
+
var FileList: typeof import("./ui").FileList;
|
|
8
|
+
var FileListHeader: typeof import("./ui").FileListHeader;
|
|
9
|
+
var FilePicker: typeof import("./ui").FilePicker;
|
|
10
|
+
}
|
|
11
|
+
export { StorageManager };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useDropZone } from './useDropZone';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export interface UseDropZoneProps {
|
|
3
|
+
onChange: (event: React.DragEvent<HTMLDivElement>) => void;
|
|
4
|
+
}
|
|
5
|
+
export interface UseDropZoneReturn {
|
|
6
|
+
onDragStart: (event: React.DragEvent<HTMLDivElement>) => void;
|
|
7
|
+
onDragEnter: (event: React.DragEvent<HTMLDivElement>) => void;
|
|
8
|
+
onDragLeave: (event: React.DragEvent<HTMLDivElement>) => void;
|
|
9
|
+
onDragOver: (event: React.DragEvent<HTMLDivElement>) => void;
|
|
10
|
+
onDrop: (event: React.DragEvent<HTMLDivElement>) => void;
|
|
11
|
+
inDropZone: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare function useDropZone({ onChange }: UseDropZoneProps): UseDropZoneReturn;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { UploadTask } from '@aws-amplify/storage';
|
|
2
|
+
import { FileStatus } from '../../types';
|
|
3
|
+
import { Action, AddFilesActionParams } from './types';
|
|
4
|
+
export declare const addFilesAction: ({ files, getFileErrorMessage, }: AddFilesActionParams) => Action;
|
|
5
|
+
export declare const setUploadingFileAction: ({ id, uploadTask, }: {
|
|
6
|
+
id: string;
|
|
7
|
+
uploadTask: UploadTask | undefined;
|
|
8
|
+
}) => Action;
|
|
9
|
+
export declare const setUploadProgressAction: ({ id, progress, }: {
|
|
10
|
+
id: string;
|
|
11
|
+
progress: number;
|
|
12
|
+
}) => Action;
|
|
13
|
+
export declare const setUploadStatusAction: ({ id, status, }: {
|
|
14
|
+
id: string;
|
|
15
|
+
status: FileStatus;
|
|
16
|
+
}) => Action;
|
|
17
|
+
export declare const removeUploadAction: ({ id }: {
|
|
18
|
+
id: string;
|
|
19
|
+
}) => Action;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useStorageManager, UseStorageManager } from './useStorageManager';
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { UploadTask } from '@aws-amplify/storage';
|
|
2
|
+
import { FileStatus, StorageFiles } from '../../types';
|
|
3
|
+
export interface UseStorageManagerState {
|
|
4
|
+
files: StorageFiles;
|
|
5
|
+
}
|
|
6
|
+
export declare enum StorageManagerActionTypes {
|
|
7
|
+
ADD_FILES = "ADD_FILES",
|
|
8
|
+
SET_STATUS = "SET_STATUS",
|
|
9
|
+
SET_STATUS_UPLOADING = "SET_STATUS_UPLOADING",
|
|
10
|
+
SET_UPLOAD_PROGRESS = "SET_UPLOAD_PROGRESS",
|
|
11
|
+
REMOVE_UPLOAD = "REMOVE_UPLOAD"
|
|
12
|
+
}
|
|
13
|
+
export declare type GetFileErrorMessage = (file: File) => string;
|
|
14
|
+
export declare type Action = {
|
|
15
|
+
type: StorageManagerActionTypes.ADD_FILES;
|
|
16
|
+
files: File[];
|
|
17
|
+
getFileErrorMessage: GetFileErrorMessage;
|
|
18
|
+
} | {
|
|
19
|
+
type: StorageManagerActionTypes.SET_STATUS;
|
|
20
|
+
id: string;
|
|
21
|
+
status: FileStatus;
|
|
22
|
+
} | {
|
|
23
|
+
type: StorageManagerActionTypes.SET_STATUS_UPLOADING;
|
|
24
|
+
id: string;
|
|
25
|
+
uploadTask?: UploadTask;
|
|
26
|
+
} | {
|
|
27
|
+
type: StorageManagerActionTypes.SET_UPLOAD_PROGRESS;
|
|
28
|
+
id: string;
|
|
29
|
+
progress: number;
|
|
30
|
+
} | {
|
|
31
|
+
type: StorageManagerActionTypes.REMOVE_UPLOAD;
|
|
32
|
+
id: string;
|
|
33
|
+
};
|
|
34
|
+
export interface AddFilesActionParams {
|
|
35
|
+
files: File[];
|
|
36
|
+
getFileErrorMessage: GetFileErrorMessage;
|
|
37
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { UploadTask } from '@aws-amplify/storage';
|
|
2
|
+
import { StorageFiles, DefaultFile } from '../../types';
|
|
3
|
+
import { GetFileErrorMessage } from './types';
|
|
4
|
+
export interface UseStorageManager {
|
|
5
|
+
addFiles: (params: {
|
|
6
|
+
files: File[];
|
|
7
|
+
getFileErrorMessage: GetFileErrorMessage;
|
|
8
|
+
}) => void;
|
|
9
|
+
setUploadingFile: (params: {
|
|
10
|
+
id: string;
|
|
11
|
+
uploadTask?: UploadTask;
|
|
12
|
+
}) => void;
|
|
13
|
+
setUploadProgress: (params: {
|
|
14
|
+
id: string;
|
|
15
|
+
progress: number;
|
|
16
|
+
}) => void;
|
|
17
|
+
setUploadSuccess: (params: {
|
|
18
|
+
id: string;
|
|
19
|
+
}) => void;
|
|
20
|
+
setUploadResumed: (params: {
|
|
21
|
+
id: string;
|
|
22
|
+
}) => void;
|
|
23
|
+
setUploadPaused: (params: {
|
|
24
|
+
id: string;
|
|
25
|
+
}) => void;
|
|
26
|
+
removeUpload: (params: {
|
|
27
|
+
id: string;
|
|
28
|
+
}) => void;
|
|
29
|
+
files: StorageFiles;
|
|
30
|
+
}
|
|
31
|
+
export declare function useStorageManager(defaultFiles?: Array<DefaultFile>): UseStorageManager;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useUploadFiles, UseUploadFilesProps } from './useUploadFiles';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { StorageManagerProps } from '../../types';
|
|
2
|
+
import { UseStorageManager } from '../useStorageManager';
|
|
3
|
+
export interface UseUploadFilesProps extends Pick<StorageManagerProps, 'accessLevel' | 'isResumable' | 'onUploadSuccess' | 'onUploadError' | 'maxFileCount' | 'processFile' | 'provider' | 'path'>, Pick<UseStorageManager, 'setUploadingFile' | 'setUploadProgress' | 'setUploadSuccess' | 'files'> {
|
|
4
|
+
}
|
|
5
|
+
export declare function useUploadFiles({ files, accessLevel, isResumable, setUploadProgress, setUploadingFile, setUploadSuccess, onUploadError, onUploadSuccess, maxFileCount, processFile, provider, path, }: UseUploadFilesProps): void;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { StorageAccessLevel, UploadTask } from '@aws-amplify/storage';
|
|
3
|
+
import { ContainerProps, DropZoneProps, FileListHeaderProps, FileListProps, FilePickerProps } from './ui';
|
|
4
|
+
import { StorageManagerDisplayText } from './utils';
|
|
5
|
+
export declare enum FileStatus {
|
|
6
|
+
QUEUED = "queued",
|
|
7
|
+
UPLOADING = "uploading",
|
|
8
|
+
PAUSED = "paused",
|
|
9
|
+
ERROR = "error",
|
|
10
|
+
UPLOADED = "uploaded"
|
|
11
|
+
}
|
|
12
|
+
export interface StorageFile {
|
|
13
|
+
id: string;
|
|
14
|
+
file?: File;
|
|
15
|
+
status: FileStatus;
|
|
16
|
+
progress: number;
|
|
17
|
+
uploadTask?: UploadTask;
|
|
18
|
+
key: string;
|
|
19
|
+
error: string;
|
|
20
|
+
isImage: boolean;
|
|
21
|
+
}
|
|
22
|
+
export declare type StorageFiles = StorageFile[];
|
|
23
|
+
export declare type DefaultFile = Pick<StorageFile, 'key'>;
|
|
24
|
+
export interface StorageManagerProps {
|
|
25
|
+
/**
|
|
26
|
+
* List of accepted File types
|
|
27
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/accept
|
|
28
|
+
*/
|
|
29
|
+
acceptedFileTypes: string[];
|
|
30
|
+
/**
|
|
31
|
+
* Access level for file uploads
|
|
32
|
+
* @see https://docs.amplify.aws/lib/storage/configureaccess/q/platform/js/
|
|
33
|
+
*/
|
|
34
|
+
accessLevel: StorageAccessLevel;
|
|
35
|
+
/**
|
|
36
|
+
* Component overrides
|
|
37
|
+
*/
|
|
38
|
+
components?: {
|
|
39
|
+
Container?: React.ComponentType<ContainerProps>;
|
|
40
|
+
DropZone?: React.ComponentType<DropZoneProps>;
|
|
41
|
+
FileList?: React.ComponentType<FileListProps>;
|
|
42
|
+
FilePicker?: React.ComponentType<FilePickerProps>;
|
|
43
|
+
FileListHeader?: React.ComponentType<FileListHeaderProps>;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* List of default files already uploaded
|
|
47
|
+
*/
|
|
48
|
+
defaultFiles?: DefaultFile[];
|
|
49
|
+
/**
|
|
50
|
+
* Overrides default display text
|
|
51
|
+
*/
|
|
52
|
+
displayText?: Partial<StorageManagerDisplayText>;
|
|
53
|
+
/**
|
|
54
|
+
* Determines if upload can be paused / resumed
|
|
55
|
+
*/
|
|
56
|
+
isResumable?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Maximum total files to upload in each batch
|
|
59
|
+
*/
|
|
60
|
+
maxFileCount: number;
|
|
61
|
+
/**
|
|
62
|
+
* Maximum file size in bytes
|
|
63
|
+
*/
|
|
64
|
+
maxFileSize?: number;
|
|
65
|
+
/**
|
|
66
|
+
* When a file is removed
|
|
67
|
+
*/
|
|
68
|
+
onFileRemove?: (file: {
|
|
69
|
+
key: string;
|
|
70
|
+
}) => void;
|
|
71
|
+
/**
|
|
72
|
+
* Monitor upload errors
|
|
73
|
+
*/
|
|
74
|
+
onUploadError?: (error: string) => void;
|
|
75
|
+
/**
|
|
76
|
+
* Monitor upload success
|
|
77
|
+
*/
|
|
78
|
+
onUploadSuccess?: (event: {
|
|
79
|
+
key?: string;
|
|
80
|
+
}) => void;
|
|
81
|
+
/**
|
|
82
|
+
* Process file before upload
|
|
83
|
+
*/
|
|
84
|
+
processFile?: (storageFile: Required<Pick<StorageFile, 'file' | 'key'>>) => Required<Pick<StorageFile, 'file' | 'key'>>;
|
|
85
|
+
/**
|
|
86
|
+
* Determines if thumbnails show for image files
|
|
87
|
+
*/
|
|
88
|
+
showThumbnails?: boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Storage provider name
|
|
91
|
+
* @see https://docs.amplify.aws/lib/storage/custom-plugin/q/platform/js/
|
|
92
|
+
*/
|
|
93
|
+
provider?: string;
|
|
94
|
+
/**
|
|
95
|
+
* A path to put files in the s3 bucket.
|
|
96
|
+
* This will be prepended to the key sent to
|
|
97
|
+
* s3 for each file.
|
|
98
|
+
*/
|
|
99
|
+
path?: string;
|
|
100
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Container, ContainerProps } from './Container';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { StorageManagerDisplayText } from '../../utils/displayText';
|
|
3
|
+
export interface DropZoneProps {
|
|
4
|
+
children?: React.ReactNode;
|
|
5
|
+
displayText: StorageManagerDisplayText;
|
|
6
|
+
inDropZone: boolean;
|
|
7
|
+
onDragEnter: (event: React.DragEvent<HTMLDivElement>) => void;
|
|
8
|
+
onDragLeave: (event: React.DragEvent<HTMLDivElement>) => void;
|
|
9
|
+
onDragOver: (event: React.DragEvent<HTMLDivElement>) => void;
|
|
10
|
+
onDragStart: (event: React.DragEvent<HTMLDivElement>) => void;
|
|
11
|
+
onDrop: (event: React.DragEvent<HTMLDivElement>) => void;
|
|
12
|
+
testId?: string;
|
|
13
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { FileControlProps } from './types';
|
|
3
|
+
export declare function FileControl({ onPause, onResume, displayName, errorMessage, isImage, isResumable, loaderIsDeterminate, onRemove, progress, showThumbnails, size, status, displayText, thumbnailUrl, }: FileControlProps): JSX.Element;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { FileListProps } from './types';
|
|
3
|
+
export declare function FileList({ displayText, files, hasMaxFilesError, isResumable, onCancelUpload, onDeleteUpload, onResume, onPause, showThumbnails, maxFileCount, }: FileListProps): JSX.Element | null;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { UploadTask } from '@aws-amplify/storage';
|
|
2
|
+
import { StorageManagerDisplayText } from '../../utils/displayText';
|
|
3
|
+
import { FileStatus, StorageFile } from '../../types';
|
|
4
|
+
export interface FileListProps {
|
|
5
|
+
displayText: StorageManagerDisplayText;
|
|
6
|
+
files: StorageFile[];
|
|
7
|
+
isResumable: boolean;
|
|
8
|
+
onCancelUpload: (params: {
|
|
9
|
+
id: string;
|
|
10
|
+
uploadTask: UploadTask;
|
|
11
|
+
}) => void;
|
|
12
|
+
onDeleteUpload: (params: {
|
|
13
|
+
id: string;
|
|
14
|
+
}) => void;
|
|
15
|
+
onPause: (params: {
|
|
16
|
+
id: string;
|
|
17
|
+
uploadTask: UploadTask;
|
|
18
|
+
}) => void;
|
|
19
|
+
onResume: (params: {
|
|
20
|
+
id: string;
|
|
21
|
+
uploadTask: UploadTask;
|
|
22
|
+
}) => void;
|
|
23
|
+
showThumbnails: boolean;
|
|
24
|
+
hasMaxFilesError: boolean;
|
|
25
|
+
maxFileCount: number;
|
|
26
|
+
}
|
|
27
|
+
export interface FileControlProps {
|
|
28
|
+
displayText: StorageManagerDisplayText;
|
|
29
|
+
displayName: string;
|
|
30
|
+
errorMessage: string;
|
|
31
|
+
isImage: boolean;
|
|
32
|
+
isResumable: boolean;
|
|
33
|
+
isUploading: boolean;
|
|
34
|
+
loaderIsDeterminate: boolean;
|
|
35
|
+
onRemove: () => void;
|
|
36
|
+
onPause: () => void;
|
|
37
|
+
onResume: () => void;
|
|
38
|
+
progress: number;
|
|
39
|
+
showThumbnails: boolean;
|
|
40
|
+
size?: number;
|
|
41
|
+
status: FileStatus;
|
|
42
|
+
thumbnailUrl: string;
|
|
43
|
+
}
|
|
44
|
+
export interface FileStatusMessageProps extends Pick<StorageManagerDisplayText, 'getUploadingText' | 'getPausedText' | 'uploadSuccessfulText'> {
|
|
45
|
+
status: FileStatus;
|
|
46
|
+
errorMessage: string;
|
|
47
|
+
percentage: number;
|
|
48
|
+
}
|
|
49
|
+
export interface UploadDetailsProps {
|
|
50
|
+
displayName: string;
|
|
51
|
+
fileSize?: number;
|
|
52
|
+
}
|
|
53
|
+
export interface FileThumbnailProps {
|
|
54
|
+
isImage: boolean;
|
|
55
|
+
fileName: string;
|
|
56
|
+
url: string;
|
|
57
|
+
}
|
|
58
|
+
export interface FileRemoveButtonProps {
|
|
59
|
+
altText: string;
|
|
60
|
+
onClick: () => void;
|
|
61
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { StorageManagerDisplayText } from '../../utils/displayText';
|
|
3
|
+
export interface FileListHeaderProps {
|
|
4
|
+
fileCount: number;
|
|
5
|
+
remainingFilesCount: number;
|
|
6
|
+
displayText: StorageManagerDisplayText;
|
|
7
|
+
allUploadsSuccessful: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare function FileListHeader({ fileCount, remainingFilesCount, displayText, allUploadsSuccessful, }: FileListHeaderProps): JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { FileListHeader, FileListHeaderProps } from './FileListHeader';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Button } from '@aws-amplify/ui-react';
|
|
3
|
+
export declare type FilePickerProps = Parameters<typeof Button>[0] & {
|
|
4
|
+
onClick: React.MouseEventHandler<HTMLButtonElement>;
|
|
5
|
+
};
|
|
6
|
+
export declare function FilePicker({ children, className, size, ...props }: FilePickerProps): JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { FilePicker, FilePickerProps } from './FilePicker';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { Container, ContainerProps } from './Container';
|
|
2
|
+
export { DropZone, DropZoneProps } from './DropZone';
|
|
3
|
+
export { FileList, FileListProps } from './FileList';
|
|
4
|
+
export { FileListHeader, FileListHeaderProps } from './FileListHeader';
|
|
5
|
+
export { FilePicker, FilePickerProps } from './FilePicker';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare const defaultStorageManagerDisplayText: {
|
|
2
|
+
getFilesUploadedText(count: number): string;
|
|
3
|
+
getFileSizeErrorText(sizeText: string): string;
|
|
4
|
+
getRemainingFilesText(count: number): string;
|
|
5
|
+
getUploadingText(percentage: number): string;
|
|
6
|
+
getUploadButtonText(count: number): string;
|
|
7
|
+
getMaxFilesErrorText(count: number): string;
|
|
8
|
+
getErrorText(message: string): string;
|
|
9
|
+
doneButtonText: string;
|
|
10
|
+
clearAllButtonText: string;
|
|
11
|
+
extensionNotAllowedText: string;
|
|
12
|
+
browseFilesText: string;
|
|
13
|
+
dropFilesText: string;
|
|
14
|
+
pauseText: string;
|
|
15
|
+
resumeText: string;
|
|
16
|
+
uploadSuccessfulText: string;
|
|
17
|
+
getPausedText(percentage: number): string;
|
|
18
|
+
};
|
|
19
|
+
export declare type StorageManagerDisplayText = typeof defaultStorageManagerDisplayText;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const filterAllowedFiles: (files: File[], acceptedFileTypes: string[]) => File[];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Format bytes as human-readable text.
|
|
3
|
+
*
|
|
4
|
+
* @param bytes Number of bytes.
|
|
5
|
+
* @param si True to use metric (SI) units, aka powers of 1000. False to use
|
|
6
|
+
* binary (IEC), aka powers of 1024.
|
|
7
|
+
* @param dp Number of decimal places to display.
|
|
8
|
+
*
|
|
9
|
+
* @return Formatted string.
|
|
10
|
+
*/
|
|
11
|
+
export declare function humanFileSize(bytes: number, si?: boolean, dp?: number): string;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { checkMaxFileSize } from './checkMaxFileSize';
|
|
2
|
+
export { defaultStorageManagerDisplayText, StorageManagerDisplayText, } from './displayText';
|
|
3
|
+
export { filterAllowedFiles } from './filterAllowedFiles';
|
|
4
|
+
export { humanFileSize } from './humanFileSize';
|
|
5
|
+
export { uploadFile } from './uploadFile';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { StorageAccessLevel, UploadTask } from '@aws-amplify/storage';
|
|
2
|
+
interface UploadFileProps {
|
|
3
|
+
file: File;
|
|
4
|
+
fileName: string;
|
|
5
|
+
level: StorageAccessLevel;
|
|
6
|
+
isResumable?: boolean;
|
|
7
|
+
progressCallback: (progress: {
|
|
8
|
+
loaded: number;
|
|
9
|
+
total: number;
|
|
10
|
+
}) => void;
|
|
11
|
+
errorCallback: (error: string) => void;
|
|
12
|
+
completeCallback: (event: {
|
|
13
|
+
key: string | undefined;
|
|
14
|
+
}) => void;
|
|
15
|
+
provider?: string;
|
|
16
|
+
}
|
|
17
|
+
declare type UploadFile = Promise<void> | UploadTask;
|
|
18
|
+
export declare function uploadFile({ file, fileName, level, progressCallback, errorCallback, completeCallback, isResumable, provider, ...rest }: UploadFileProps): UploadFile;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { StorageManager, StorageManagerProps, DropZoneProps, ContainerProps, FileListProps, FilePickerProps, FileListHeaderProps, } from './StorageManager';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { StorageManager, StorageManagerProps, DropZoneProps, ContainerProps, FileListProps, FilePickerProps, FileListHeaderProps, } from './components';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './styles.css';
|
package/package.json
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aws-amplify/ui-react-storage",
|
|
3
|
+
"version": "0.0.0-next-3c3fbf4-20230404001107",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"module": "dist/esm/index.mjs",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./dist/types/index.d.ts",
|
|
9
|
+
"import": "./dist/esm/index.mjs",
|
|
10
|
+
"require": "./dist/index.js"
|
|
11
|
+
},
|
|
12
|
+
"./styles.css": "./dist/styles.css"
|
|
13
|
+
},
|
|
14
|
+
"browser": {
|
|
15
|
+
"./styles.css": "./dist/styles.css"
|
|
16
|
+
},
|
|
17
|
+
"types": "dist/types/index.d.ts",
|
|
18
|
+
"license": "Apache-2.0",
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "https://github.com/aws-amplify/amplify-ui",
|
|
22
|
+
"directory": "packages/react-storage"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"dist",
|
|
26
|
+
"LICENSE"
|
|
27
|
+
],
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "yarn build:rollup",
|
|
30
|
+
"build:rollup": "rollup --config",
|
|
31
|
+
"check:esm": "node --input-type=module --eval 'import \"@aws-amplify/ui-react-storage\"'",
|
|
32
|
+
"clean": "rimraf dist node_modules",
|
|
33
|
+
"dev": "yarn build:rollup --watch",
|
|
34
|
+
"lint": "yarn typecheck && eslint src --ext .js,.ts,.tsx",
|
|
35
|
+
"prebuild": "rimraf dist",
|
|
36
|
+
"size": "yarn size-limit",
|
|
37
|
+
"test": "jest",
|
|
38
|
+
"test:ci": "yarn test && yarn check:esm",
|
|
39
|
+
"test:watch": "yarn test --watch",
|
|
40
|
+
"typecheck": "tsc --noEmit"
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@aws-amplify/ui": "0.0.0-next-3c3fbf4-20230404001107",
|
|
44
|
+
"@aws-amplify/ui-react-core": "0.0.0-next-3c3fbf4-20230404001107",
|
|
45
|
+
"classnames": "2.3.1",
|
|
46
|
+
"lodash": "4.17.21",
|
|
47
|
+
"tslib": "2.4.1"
|
|
48
|
+
},
|
|
49
|
+
"peerDependencies": {
|
|
50
|
+
"aws-amplify": ">= 5.0.1",
|
|
51
|
+
"react": ">= 16.14.0",
|
|
52
|
+
"react-dom": ">= 16.14.0"
|
|
53
|
+
},
|
|
54
|
+
"peerDependenciesMeta": {
|
|
55
|
+
"aws-amplify": {
|
|
56
|
+
"optional": true
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"devDependencies": {
|
|
60
|
+
"@rollup/plugin-typescript": "^8.3.1",
|
|
61
|
+
"@size-limit/preset-big-lib": "^7.0.8",
|
|
62
|
+
"@testing-library/jest-dom": "^5.14.1",
|
|
63
|
+
"@testing-library/react": "^12.0.0",
|
|
64
|
+
"@testing-library/react-hooks": "^7.0.1",
|
|
65
|
+
"@testing-library/user-event": "^13.2.1",
|
|
66
|
+
"@types/jest": "^26.0.23",
|
|
67
|
+
"@types/react": "^17.0.2",
|
|
68
|
+
"@types/testing-library__jest-dom": "^5.14.1",
|
|
69
|
+
"eslint": "^8.13.0",
|
|
70
|
+
"eslint-config-amplify-ui": "0.0.0",
|
|
71
|
+
"jest": "^27.0.4",
|
|
72
|
+
"react": "^17.0.2",
|
|
73
|
+
"react-dom": "^17.0.2",
|
|
74
|
+
"rimraf": "^3.0.2",
|
|
75
|
+
"rollup": "^2.70.0",
|
|
76
|
+
"rollup-plugin-node-externals": "^4.1.1",
|
|
77
|
+
"rollup-plugin-styles": "^4.0.0",
|
|
78
|
+
"rollup-plugin-terser": "^7.0.2",
|
|
79
|
+
"size-limit": "^7.0.8",
|
|
80
|
+
"ts-jest": "^27.0.3",
|
|
81
|
+
"ts-morph": "^12.0.0"
|
|
82
|
+
},
|
|
83
|
+
"sideEffects": [
|
|
84
|
+
"dist/**/*.css"
|
|
85
|
+
],
|
|
86
|
+
"size-limit": [
|
|
87
|
+
{
|
|
88
|
+
"name": "StorageManager",
|
|
89
|
+
"path": "dist/esm/index.mjs",
|
|
90
|
+
"import": "{ StorageManager }",
|
|
91
|
+
"limit": "120 kB"
|
|
92
|
+
}
|
|
93
|
+
]
|
|
94
|
+
}
|