@aws-amplify/ui-react-storage 3.0.18 → 3.1.0
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/StorageImage/StorageImage.mjs +46 -20
- package/dist/esm/components/StorageManager/StorageManager.mjs +23 -10
- package/dist/esm/components/StorageManager/hooks/useStorageManager/actions.mjs +31 -45
- package/dist/esm/components/StorageManager/hooks/useStorageManager/reducer.mjs +1 -1
- package/dist/esm/components/StorageManager/hooks/useUploadFiles/useUploadFiles.mjs +34 -31
- package/dist/esm/components/StorageManager/ui/FileList/FileDetails.mjs +1 -0
- package/dist/esm/components/StorageManager/utils/getInput.mjs +25 -0
- package/dist/esm/components/StorageManager/{hooks/useUploadFiles → utils}/resolveFile.mjs +2 -4
- package/dist/esm/components/StorageManager/utils/uploadFile.mjs +18 -21
- package/dist/esm/version.mjs +1 -1
- package/dist/index.js +264 -222
- package/dist/types/components/StorageImage/StorageImage.d.ts +6 -2
- package/dist/types/components/StorageImage/types.d.ts +30 -0
- package/dist/types/components/StorageManager/StorageManager.d.ts +5 -2
- package/dist/types/components/StorageManager/hooks/useStorageManager/actions.d.ts +2 -5
- package/dist/types/components/StorageManager/hooks/useStorageManager/types.d.ts +2 -2
- package/dist/types/components/StorageManager/hooks/useStorageManager/useStorageManager.d.ts +2 -5
- package/dist/types/components/StorageManager/hooks/useUploadFiles/useUploadFiles.d.ts +4 -1
- package/dist/types/components/StorageManager/types.d.ts +17 -7
- package/dist/types/components/StorageManager/ui/FileList/types.d.ts +4 -14
- package/dist/types/components/StorageManager/utils/getInput.d.ts +13 -0
- package/dist/types/components/StorageManager/utils/index.d.ts +2 -1
- package/dist/types/components/StorageManager/utils/resolveFile.d.ts +9 -0
- package/dist/types/components/StorageManager/utils/uploadFile.d.ts +31 -12
- package/dist/types/version.d.ts +1 -1
- package/package.json +6 -6
- package/dist/types/components/StorageManager/hooks/useUploadFiles/resolveFile.d.ts +0 -10
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { UploadDataOutput } from 'aws-amplify/storage';
|
|
2
1
|
import { StorageFiles, FileStatus, DefaultFile } from '../../types';
|
|
3
2
|
import { GetFileErrorMessage } from './types';
|
|
3
|
+
import { TaskHandler } from '../../utils';
|
|
4
4
|
export interface UseStorageManager {
|
|
5
5
|
addFiles: (params: {
|
|
6
6
|
files: File[];
|
|
@@ -9,10 +9,7 @@ export interface UseStorageManager {
|
|
|
9
9
|
}) => void;
|
|
10
10
|
clearFiles: () => void;
|
|
11
11
|
queueFiles: () => void;
|
|
12
|
-
setUploadingFile:
|
|
13
|
-
id: string;
|
|
14
|
-
uploadTask?: UploadDataOutput;
|
|
15
|
-
}) => void;
|
|
12
|
+
setUploadingFile: TaskHandler;
|
|
16
13
|
setUploadProgress: (params: {
|
|
17
14
|
id: string;
|
|
18
15
|
progress: number;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import { PathCallback } from '../../utils';
|
|
1
2
|
import { StorageManagerProps } from '../../types';
|
|
2
3
|
import { UseStorageManager } from '../useStorageManager';
|
|
3
|
-
export interface UseUploadFilesProps extends Pick<StorageManagerProps, '
|
|
4
|
+
export interface UseUploadFilesProps extends Pick<StorageManagerProps, 'isResumable' | 'onUploadSuccess' | 'onUploadError' | 'onUploadStart' | 'maxFileCount' | 'processFile'>, Pick<UseStorageManager, 'setUploadingFile' | 'setUploadProgress' | 'setUploadSuccess' | 'files'> {
|
|
5
|
+
accessLevel?: StorageManagerProps['accessLevel'];
|
|
6
|
+
path?: string | PathCallback;
|
|
4
7
|
}
|
|
5
8
|
export declare function useUploadFiles({ files, accessLevel, isResumable, setUploadProgress, setUploadingFile, setUploadSuccess, onUploadError, onUploadSuccess, onUploadStart, maxFileCount, processFile, path, }: UseUploadFilesProps): void;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import type { UploadDataOutput } from 'aws-amplify/storage';
|
|
3
2
|
import type { StorageAccessLevel } from '@aws-amplify/core';
|
|
4
3
|
import { ContainerProps, DropZoneProps, FileListHeaderProps, FileListFooterProps, FileListProps, FilePickerProps } from './ui';
|
|
5
|
-
import { StorageManagerDisplayText } from './utils';
|
|
4
|
+
import { StorageManagerDisplayText, PathCallback, UploadTask } from './utils';
|
|
6
5
|
export declare enum FileStatus {
|
|
7
6
|
ADDED = "added",
|
|
8
7
|
QUEUED = "queued",
|
|
@@ -16,14 +15,17 @@ export interface StorageFile {
|
|
|
16
15
|
file?: File;
|
|
17
16
|
status: FileStatus;
|
|
18
17
|
progress: number;
|
|
19
|
-
uploadTask?:
|
|
18
|
+
uploadTask?: UploadTask;
|
|
20
19
|
key: string;
|
|
21
20
|
error: string;
|
|
22
21
|
isImage: boolean;
|
|
23
22
|
}
|
|
24
23
|
export type StorageFiles = StorageFile[];
|
|
25
24
|
export type DefaultFile = Pick<StorageFile, 'key'>;
|
|
26
|
-
export
|
|
25
|
+
export interface ProcessFileParams extends Record<string, any> {
|
|
26
|
+
file: File;
|
|
27
|
+
key: string;
|
|
28
|
+
}
|
|
27
29
|
export type ProcessFile = (params: ProcessFileParams) => Promise<ProcessFileParams> | ProcessFileParams;
|
|
28
30
|
export interface StorageManagerHandle {
|
|
29
31
|
clearFiles: () => void;
|
|
@@ -107,9 +109,17 @@ export interface StorageManagerProps {
|
|
|
107
109
|
*/
|
|
108
110
|
showThumbnails?: boolean;
|
|
109
111
|
/**
|
|
110
|
-
*
|
|
111
|
-
* This will be prepended to the key sent to
|
|
112
|
-
* s3 for each file.
|
|
112
|
+
* Provided value is prefixed to the file `key` for each file
|
|
113
113
|
*/
|
|
114
114
|
path?: string;
|
|
115
115
|
}
|
|
116
|
+
export interface StorageManagerPathProps extends Omit<StorageManagerProps, 'accessLevel' | 'path'> {
|
|
117
|
+
/**
|
|
118
|
+
* S3 bucket key, allows either a `string` or a `PathCallback`:
|
|
119
|
+
* - `string`: `path` is prefixed to the file `key` for each file
|
|
120
|
+
* - `PathCallback`: callback provided an input containing the current `identityId`,
|
|
121
|
+
* resolved value is prefixed to the file `key` for each file
|
|
122
|
+
*/
|
|
123
|
+
path: string | PathCallback;
|
|
124
|
+
accessLevel?: never;
|
|
125
|
+
}
|
|
@@ -1,25 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { StorageManagerDisplayTextDefault } from '../../utils';
|
|
1
|
+
import { StorageManagerDisplayTextDefault, TaskHandler } from '../../utils';
|
|
3
2
|
import { FileStatus, StorageFile } from '../../types';
|
|
4
3
|
export interface FileListProps {
|
|
5
4
|
displayText: StorageManagerDisplayTextDefault;
|
|
6
5
|
files: StorageFile[];
|
|
7
6
|
isResumable: boolean;
|
|
8
|
-
onCancelUpload:
|
|
9
|
-
id: string;
|
|
10
|
-
uploadTask: UploadDataOutput;
|
|
11
|
-
}) => void;
|
|
7
|
+
onCancelUpload: TaskHandler;
|
|
12
8
|
onDeleteUpload: (params: {
|
|
13
9
|
id: string;
|
|
14
10
|
}) => void;
|
|
15
|
-
onPause:
|
|
16
|
-
|
|
17
|
-
uploadTask: UploadDataOutput;
|
|
18
|
-
}) => void;
|
|
19
|
-
onResume: (params: {
|
|
20
|
-
id: string;
|
|
21
|
-
uploadTask: UploadDataOutput;
|
|
22
|
-
}) => void;
|
|
11
|
+
onPause: TaskHandler;
|
|
12
|
+
onResume: TaskHandler;
|
|
23
13
|
showThumbnails: boolean;
|
|
24
14
|
hasMaxFilesError: boolean;
|
|
25
15
|
maxFileCount: number;
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
onProgress: NonNullable<UploadDataWithPathInput['options']>['onProgress'];
|
|
10
|
+
path: string | PathCallback | undefined;
|
|
11
|
+
processFile: ProcessFile | undefined;
|
|
12
|
+
}
|
|
13
|
+
export declare const getInput: ({ accessLevel, file, key, onProgress, path, processFile, }: GetInputParams) => () => Promise<PathInput | UploadDataInput>;
|
|
@@ -2,4 +2,5 @@ export { checkMaxFileSize } from './checkMaxFileSize';
|
|
|
2
2
|
export { defaultStorageManagerDisplayText, StorageManagerDisplayText, StorageManagerDisplayTextDefault, } from './displayText';
|
|
3
3
|
export { filterAllowedFiles } from './filterAllowedFiles';
|
|
4
4
|
export { humanFileSize } from './humanFileSize';
|
|
5
|
-
export {
|
|
5
|
+
export { getInput } from './getInput';
|
|
6
|
+
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>;
|
|
@@ -1,13 +1,32 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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;
|
|
11
26
|
}) => void;
|
|
12
|
-
|
|
13
|
-
|
|
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>;
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "3.0
|
|
1
|
+
export declare const VERSION = "3.1.0";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-amplify/ui-react-storage",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/esm/index.mjs",
|
|
6
6
|
"exports": {
|
|
@@ -39,14 +39,14 @@
|
|
|
39
39
|
"typecheck": "tsc --noEmit"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@aws-amplify/ui": "6.0.
|
|
43
|
-
"@aws-amplify/ui-react": "6.1.
|
|
44
|
-
"@aws-amplify/ui-react-core": "3.0.
|
|
42
|
+
"@aws-amplify/ui": "6.0.14",
|
|
43
|
+
"@aws-amplify/ui-react": "6.1.9",
|
|
44
|
+
"@aws-amplify/ui-react-core": "3.0.14",
|
|
45
45
|
"lodash": "4.17.21",
|
|
46
46
|
"tslib": "^2.5.2"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
|
-
"aws-amplify": "^6.0
|
|
49
|
+
"aws-amplify": "^6.2.0",
|
|
50
50
|
"react": "^16.14.0 || ^17.0 || ^18.0",
|
|
51
51
|
"react-dom": "^16.14.0 || ^17.0 || ^18.0"
|
|
52
52
|
},
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"name": "StorageManager",
|
|
59
59
|
"path": "dist/esm/index.mjs",
|
|
60
60
|
"import": "{ StorageManager }",
|
|
61
|
-
"limit": "25 kB"
|
|
61
|
+
"limit": "25.5 kB"
|
|
62
62
|
}
|
|
63
63
|
]
|
|
64
64
|
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { ProcessFileParams, StorageManagerProps } from '../../types';
|
|
2
|
-
interface ResolveFileParams extends Pick<StorageManagerProps, 'processFile'>, ProcessFileParams {
|
|
3
|
-
}
|
|
4
|
-
/**
|
|
5
|
-
* Utility function that takes the processFile prop, along with a file a key
|
|
6
|
-
* and returns a Promise that resolves to { file, key, ..rest }
|
|
7
|
-
* regardless if processFile is defined and if it is sync or async
|
|
8
|
-
*/
|
|
9
|
-
export declare const resolveFile: ({ processFile, file, key, }: ResolveFileParams) => Promise<ProcessFileParams>;
|
|
10
|
-
export {};
|