@aws-amplify/ui-react-storage 3.2.1 → 3.3.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/dist/esm/components/FileUploader/FileUploader.mjs +185 -0
- package/dist/esm/components/FileUploader/hooks/useFileUploader/actions.mjs +39 -0
- package/dist/esm/components/FileUploader/hooks/useFileUploader/reducer.mjs +93 -0
- package/dist/esm/components/FileUploader/hooks/useFileUploader/types.mjs +13 -0
- package/dist/esm/components/FileUploader/hooks/useFileUploader/useFileUploader.mjs +62 -0
- package/dist/esm/components/FileUploader/hooks/useUploadFiles/useUploadFiles.mjs +79 -0
- package/dist/esm/components/FileUploader/types.mjs +11 -0
- package/dist/esm/components/FileUploader/ui/Container/Container.mjs +8 -0
- package/dist/esm/components/FileUploader/ui/DropZone/DropZone.mjs +16 -0
- package/dist/esm/components/FileUploader/ui/FileList/FileControl.mjs +23 -0
- package/dist/esm/components/FileUploader/ui/FileList/FileDetails.mjs +12 -0
- package/dist/esm/components/FileUploader/ui/FileList/FileList.mjs +44 -0
- package/dist/esm/components/FileUploader/ui/FileList/FileRemoveButton.mjs +12 -0
- package/dist/esm/components/FileUploader/ui/FileList/FileStatusMessage.mjs +28 -0
- package/dist/esm/components/FileUploader/ui/FileList/FileThumbnail.mjs +12 -0
- package/dist/esm/components/FileUploader/ui/FileListFooter/FileListFooter.mjs +13 -0
- package/dist/esm/components/FileUploader/ui/FileListHeader/FileListHeader.mjs +14 -0
- package/dist/esm/components/FileUploader/ui/FilePicker/FilePicker.mjs +9 -0
- package/dist/esm/components/FileUploader/utils/checkMaxFileSize.mjs +12 -0
- package/dist/esm/components/FileUploader/utils/displayText.mjs +39 -0
- package/dist/esm/components/FileUploader/utils/filterAllowedFiles.mjs +27 -0
- package/dist/esm/components/FileUploader/utils/getInput.mjs +39 -0
- package/dist/esm/components/FileUploader/utils/resolveFile.mjs +20 -0
- package/dist/esm/components/FileUploader/utils/uploadFile.mjs +26 -0
- package/dist/esm/components/StorageManager/StorageManager.mjs +4 -0
- package/dist/esm/index.mjs +1 -0
- package/dist/esm/version.mjs +1 -1
- package/dist/index.js +721 -7
- package/dist/styles.css +250 -0
- package/dist/types/components/FileUploader/FileUploader.d.ts +15 -0
- package/dist/types/components/FileUploader/hooks/index.d.ts +2 -0
- package/dist/types/components/FileUploader/hooks/useFileUploader/actions.d.ts +22 -0
- package/dist/types/components/FileUploader/hooks/useFileUploader/index.d.ts +1 -0
- package/dist/types/components/FileUploader/hooks/useFileUploader/reducer.d.ts +2 -0
- package/dist/types/components/FileUploader/hooks/useFileUploader/types.d.ts +50 -0
- package/dist/types/components/FileUploader/hooks/useFileUploader/useFileUploader.d.ts +35 -0
- package/dist/types/components/FileUploader/hooks/useUploadFiles/index.d.ts +1 -0
- package/dist/types/components/FileUploader/hooks/useUploadFiles/useUploadFiles.d.ts +12 -0
- package/dist/types/components/FileUploader/index.d.ts +3 -0
- package/dist/types/components/FileUploader/types.d.ts +129 -0
- package/dist/types/components/FileUploader/ui/Container/Container.d.ts +6 -0
- package/dist/types/components/FileUploader/ui/Container/index.d.ts +1 -0
- package/dist/types/components/FileUploader/ui/DropZone/DropZone.d.ts +3 -0
- package/dist/types/components/FileUploader/ui/DropZone/index.d.ts +2 -0
- package/dist/types/components/FileUploader/ui/DropZone/types.d.ts +13 -0
- package/dist/types/components/FileUploader/ui/FileList/FileControl.d.ts +3 -0
- package/dist/types/components/FileUploader/ui/FileList/FileDetails.d.ts +3 -0
- package/dist/types/components/FileUploader/ui/FileList/FileList.d.ts +3 -0
- package/dist/types/components/FileUploader/ui/FileList/FileRemoveButton.d.ts +3 -0
- package/dist/types/components/FileUploader/ui/FileList/FileStatusMessage.d.ts +3 -0
- package/dist/types/components/FileUploader/ui/FileList/FileThumbnail.d.ts +3 -0
- package/dist/types/components/FileUploader/ui/FileList/index.d.ts +2 -0
- package/dist/types/components/FileUploader/ui/FileList/types.d.ts +51 -0
- package/dist/types/components/FileUploader/ui/FileListFooter/FileListFooter.d.ts +9 -0
- package/dist/types/components/FileUploader/ui/FileListFooter/index.d.ts +1 -0
- package/dist/types/components/FileUploader/ui/FileListHeader/FileListHeader.d.ts +10 -0
- package/dist/types/components/FileUploader/ui/FileListHeader/index.d.ts +1 -0
- package/dist/types/components/FileUploader/ui/FilePicker/FilePicker.d.ts +4 -0
- package/dist/types/components/FileUploader/ui/FilePicker/index.d.ts +1 -0
- package/dist/types/components/FileUploader/ui/index.d.ts +6 -0
- package/dist/types/components/FileUploader/utils/checkMaxFileSize.d.ts +5 -0
- package/dist/types/components/FileUploader/utils/displayText.d.ts +22 -0
- package/dist/types/components/FileUploader/utils/filterAllowedFiles.d.ts +1 -0
- package/dist/types/components/FileUploader/utils/getInput.d.ts +17 -0
- package/dist/types/components/FileUploader/utils/index.d.ts +5 -0
- package/dist/types/components/FileUploader/utils/resolveFile.d.ts +9 -0
- package/dist/types/components/FileUploader/utils/uploadFile.d.ts +32 -0
- package/dist/types/components/index.d.ts +1 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +17 -5
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { FileUploaderDisplayTextDefault, TaskHandler } from '../../utils';
|
|
2
|
+
import { FileStatus, StorageFile } from '../../types';
|
|
3
|
+
export interface FileListProps {
|
|
4
|
+
displayText: FileUploaderDisplayTextDefault;
|
|
5
|
+
files: StorageFile[];
|
|
6
|
+
isResumable: boolean;
|
|
7
|
+
onCancelUpload: TaskHandler;
|
|
8
|
+
onDeleteUpload: (params: {
|
|
9
|
+
id: string;
|
|
10
|
+
}) => void;
|
|
11
|
+
onPause: TaskHandler;
|
|
12
|
+
onResume: TaskHandler;
|
|
13
|
+
showThumbnails: boolean;
|
|
14
|
+
hasMaxFilesError: boolean;
|
|
15
|
+
maxFileCount: number;
|
|
16
|
+
}
|
|
17
|
+
export interface FileControlProps {
|
|
18
|
+
displayText: FileUploaderDisplayTextDefault;
|
|
19
|
+
displayName: string;
|
|
20
|
+
errorMessage: string;
|
|
21
|
+
isImage: boolean;
|
|
22
|
+
isResumable: boolean;
|
|
23
|
+
isUploading: boolean;
|
|
24
|
+
loaderIsDeterminate: boolean;
|
|
25
|
+
onRemove: () => void;
|
|
26
|
+
onPause: () => void;
|
|
27
|
+
onResume: () => void;
|
|
28
|
+
progress: number;
|
|
29
|
+
showThumbnails: boolean;
|
|
30
|
+
size?: number;
|
|
31
|
+
status: FileStatus;
|
|
32
|
+
thumbnailUrl: string;
|
|
33
|
+
}
|
|
34
|
+
export interface FileStatusMessageProps extends Pick<FileUploaderDisplayTextDefault, 'getUploadingText' | 'getPausedText' | 'uploadSuccessfulText'> {
|
|
35
|
+
status: FileStatus;
|
|
36
|
+
errorMessage: string;
|
|
37
|
+
percentage: number;
|
|
38
|
+
}
|
|
39
|
+
export interface UploadDetailsProps {
|
|
40
|
+
displayName: string;
|
|
41
|
+
fileSize?: number;
|
|
42
|
+
}
|
|
43
|
+
export interface FileThumbnailProps {
|
|
44
|
+
isImage: boolean;
|
|
45
|
+
fileName: string;
|
|
46
|
+
url: string;
|
|
47
|
+
}
|
|
48
|
+
export interface FileRemoveButtonProps {
|
|
49
|
+
altText: string;
|
|
50
|
+
onClick: () => void;
|
|
51
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { FileUploaderDisplayTextDefault } from '../../utils';
|
|
3
|
+
export interface FileListFooterProps {
|
|
4
|
+
remainingFilesCount: number;
|
|
5
|
+
displayText: FileUploaderDisplayTextDefault;
|
|
6
|
+
onClearAll: () => void;
|
|
7
|
+
onUploadAll: () => void;
|
|
8
|
+
}
|
|
9
|
+
export declare function FileListFooter({ displayText, remainingFilesCount, onClearAll, onUploadAll, }: FileListFooterProps): JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { FileListFooter, FileListFooterProps } from './FileListFooter';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { FileUploaderDisplayTextDefault } from '../../utils';
|
|
3
|
+
export interface FileListHeaderProps {
|
|
4
|
+
allUploadsSuccessful: boolean;
|
|
5
|
+
displayText: FileUploaderDisplayTextDefault;
|
|
6
|
+
fileCount: number;
|
|
7
|
+
remainingFilesCount: number;
|
|
8
|
+
selectedFilesCount?: number;
|
|
9
|
+
}
|
|
10
|
+
export declare function FileListHeader({ allUploadsSuccessful, displayText, fileCount, remainingFilesCount, selectedFilesCount, }: FileListHeaderProps): JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { FileListHeader, FileListHeaderProps } from './FileListHeader';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { FilePicker, FilePickerProps } from './FilePicker';
|
|
@@ -0,0 +1,6 @@
|
|
|
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 { FileListFooter, FileListFooterProps } from './FileListFooter';
|
|
6
|
+
export { FilePicker, FilePickerProps } from './FilePicker';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { DisplayTextTemplate } from '@aws-amplify/ui';
|
|
2
|
+
export type FileUploaderDisplayText = DisplayTextTemplate<{
|
|
3
|
+
getFilesUploadedText?: (count: number) => string;
|
|
4
|
+
getFileSizeErrorText?: (sizeText: string) => string;
|
|
5
|
+
getRemainingFilesText?: (count: number) => string;
|
|
6
|
+
getSelectedFilesText?: (count: number) => string;
|
|
7
|
+
getUploadingText?: (percentage: number) => string;
|
|
8
|
+
getUploadButtonText?: (count: number) => string;
|
|
9
|
+
getMaxFilesErrorText?: (count: number) => string;
|
|
10
|
+
getErrorText?: (message: string) => string;
|
|
11
|
+
doneButtonText?: string;
|
|
12
|
+
clearAllButtonText?: string;
|
|
13
|
+
extensionNotAllowedText?: string;
|
|
14
|
+
browseFilesText?: string;
|
|
15
|
+
dropFilesText?: string;
|
|
16
|
+
pauseButtonText?: string;
|
|
17
|
+
resumeButtonText?: string;
|
|
18
|
+
uploadSuccessfulText?: string;
|
|
19
|
+
getPausedText?: (percentage: number) => string;
|
|
20
|
+
}>;
|
|
21
|
+
export type FileUploaderDisplayTextDefault = Required<FileUploaderDisplayText>;
|
|
22
|
+
export declare const defaultFileUploaderDisplayText: FileUploaderDisplayTextDefault;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const filterAllowedFiles: (files: File[], acceptedFileTypes?: string[]) => File[];
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { StorageAccessLevel } from '@aws-amplify/core';
|
|
2
|
+
import { UploadDataWithPathInput, UploadDataInput } from 'aws-amplify/storage';
|
|
3
|
+
import { ProcessFile } from '../types';
|
|
4
|
+
import { PathCallback, PathInput } from './uploadFile';
|
|
5
|
+
export interface GetInputParams {
|
|
6
|
+
accessLevel: StorageAccessLevel | undefined;
|
|
7
|
+
file: File;
|
|
8
|
+
key: string;
|
|
9
|
+
onProcessFileSuccess: (input: {
|
|
10
|
+
processedKey: string;
|
|
11
|
+
}) => void;
|
|
12
|
+
onProgress: NonNullable<UploadDataWithPathInput['options']>['onProgress'];
|
|
13
|
+
path: string | PathCallback | undefined;
|
|
14
|
+
processFile: ProcessFile | undefined;
|
|
15
|
+
useAccelerateEndpoint?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export declare const getInput: ({ accessLevel, file, key, onProcessFileSuccess, onProgress, path, processFile, useAccelerateEndpoint, }: GetInputParams) => () => Promise<PathInput | UploadDataInput>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { checkMaxFileSize } from './checkMaxFileSize';
|
|
2
|
+
export { defaultFileUploaderDisplayText, FileUploaderDisplayText, FileUploaderDisplayTextDefault, } from './displayText';
|
|
3
|
+
export { filterAllowedFiles } from './filterAllowedFiles';
|
|
4
|
+
export { getInput } from './getInput';
|
|
5
|
+
export { PathCallback, TaskEvent, TaskHandler, uploadFile, UploadTask, } from './uploadFile';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ProcessFile, ProcessFileParams } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Utility function that takes the processFile prop, along with a file a key
|
|
4
|
+
* and returns a Promise that resolves to { file, key, ..rest }
|
|
5
|
+
* regardless if processFile is defined and if it is sync or async
|
|
6
|
+
*/
|
|
7
|
+
export declare const resolveFile: ({ processFile, ...input }: ProcessFileParams & {
|
|
8
|
+
processFile?: ProcessFile | undefined;
|
|
9
|
+
}) => Promise<ProcessFileParams>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { UploadDataInput, UploadDataWithPathOutput, UploadDataWithPathInput, UploadDataOutput } from 'aws-amplify/storage';
|
|
2
|
+
/**
|
|
3
|
+
* Callback provided an input containing the current `identityId`
|
|
4
|
+
*
|
|
5
|
+
* @param {{identityId: string | undefined}} input - Input parameters
|
|
6
|
+
* @returns target S3 bucket key
|
|
7
|
+
*/
|
|
8
|
+
export type PathCallback = (input: {
|
|
9
|
+
identityId: string | undefined;
|
|
10
|
+
}) => string;
|
|
11
|
+
export type UploadTask = UploadDataOutput | UploadDataWithPathOutput;
|
|
12
|
+
export interface TaskEvent {
|
|
13
|
+
id: string;
|
|
14
|
+
uploadTask: UploadTask;
|
|
15
|
+
}
|
|
16
|
+
export type PathInput = Omit<UploadDataWithPathInput, 'path'> & {
|
|
17
|
+
path: string;
|
|
18
|
+
};
|
|
19
|
+
export type TaskHandler = (event: TaskEvent) => void;
|
|
20
|
+
export interface UploadFileProps {
|
|
21
|
+
input: () => Promise<PathInput | UploadDataInput>;
|
|
22
|
+
onComplete?: (result: Awaited<(UploadDataWithPathOutput | UploadDataOutput)['result']>) => void;
|
|
23
|
+
onError?: (event: {
|
|
24
|
+
key: string;
|
|
25
|
+
error: Error;
|
|
26
|
+
}) => void;
|
|
27
|
+
onStart?: (event: {
|
|
28
|
+
key: string;
|
|
29
|
+
uploadTask: UploadTask;
|
|
30
|
+
}) => void;
|
|
31
|
+
}
|
|
32
|
+
export declare function uploadFile({ input, onError, onStart, onComplete, }: UploadFileProps): Promise<UploadDataWithPathOutput | UploadDataOutput>;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
+
export { FileUploader, FileUploaderProps } from './FileUploader';
|
|
1
2
|
export { StorageImage, StorageImageProps } from './StorageImage';
|
|
2
3
|
export { StorageManager, StorageManagerProps, DropZoneProps, ContainerProps, FileListProps, FilePickerProps, FileListHeaderProps, FileListFooterProps, } from './StorageManager';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { StorageImage, StorageImageProps, StorageManager, StorageManagerProps, DropZoneProps, ContainerProps, FileListProps, FilePickerProps, FileListHeaderProps, FileListFooterProps, } from './components';
|
|
1
|
+
export { FileUploader, FileUploaderProps, StorageImage, StorageImageProps, StorageManager, StorageManagerProps, DropZoneProps, ContainerProps, FileListProps, FilePickerProps, FileListHeaderProps, FileListFooterProps, } from './components';
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "3.
|
|
1
|
+
export declare const VERSION = "3.3.1";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-amplify/ui-react-storage",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.1",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/esm/index.mjs",
|
|
6
6
|
"exports": {
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
"typecheck": "tsc --noEmit"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@aws-amplify/ui": "6.
|
|
43
|
-
"@aws-amplify/ui-react": "6.
|
|
44
|
-
"@aws-amplify/ui-react-core": "3.0.
|
|
42
|
+
"@aws-amplify/ui": "6.4.0",
|
|
43
|
+
"@aws-amplify/ui-react": "6.3.0",
|
|
44
|
+
"@aws-amplify/ui-react-core": "3.0.21",
|
|
45
45
|
"lodash": "4.17.21",
|
|
46
46
|
"tslib": "^2.5.2"
|
|
47
47
|
},
|
|
@@ -54,11 +54,23 @@
|
|
|
54
54
|
"dist/**/*.css"
|
|
55
55
|
],
|
|
56
56
|
"size-limit": [
|
|
57
|
+
{
|
|
58
|
+
"name": "FileUploader",
|
|
59
|
+
"path": "dist/esm/index.mjs",
|
|
60
|
+
"import": "{ FileUploader }",
|
|
61
|
+
"limit": "25 kB"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"name": "StorageImage",
|
|
65
|
+
"path": "dist/esm/index.mjs",
|
|
66
|
+
"import": "{ StorageImage }",
|
|
67
|
+
"limit": "17 kB"
|
|
68
|
+
},
|
|
57
69
|
{
|
|
58
70
|
"name": "StorageManager",
|
|
59
71
|
"path": "dist/esm/index.mjs",
|
|
60
72
|
"import": "{ StorageManager }",
|
|
61
|
-
"limit": "25
|
|
73
|
+
"limit": "25 kB"
|
|
62
74
|
}
|
|
63
75
|
]
|
|
64
76
|
}
|