@aws-amplify/ui-react-storage 2.3.2 → 3.0.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 +31 -1
- package/dist/esm/components/StorageManager/StorageManager.mjs +168 -1
- package/dist/esm/components/StorageManager/hooks/useStorageManager/actions.mjs +49 -1
- package/dist/esm/components/StorageManager/hooks/useStorageManager/reducer.mjs +130 -1
- package/dist/esm/components/StorageManager/hooks/useStorageManager/types.mjs +12 -1
- package/dist/esm/components/StorageManager/hooks/useStorageManager/useStorageManager.mjs +58 -1
- package/dist/esm/components/StorageManager/hooks/useUploadFiles/resolveFile.mjs +22 -1
- package/dist/esm/components/StorageManager/hooks/useUploadFiles/useUploadFiles.mjs +64 -1
- package/dist/esm/components/StorageManager/types.mjs +11 -1
- package/dist/esm/components/StorageManager/ui/Container/Container.mjs +8 -1
- package/dist/esm/components/StorageManager/ui/DropZone/DropZone.mjs +16 -1
- package/dist/esm/components/StorageManager/ui/FileList/FileControl.mjs +23 -1
- package/dist/esm/components/StorageManager/ui/FileList/FileDetails.mjs +14 -1
- package/dist/esm/components/StorageManager/ui/FileList/FileList.mjs +44 -1
- package/dist/esm/components/StorageManager/ui/FileList/FileRemoveButton.mjs +12 -1
- package/dist/esm/components/StorageManager/ui/FileList/FileStatusMessage.mjs +28 -1
- package/dist/esm/components/StorageManager/ui/FileList/FileThumbnail.mjs +12 -1
- package/dist/esm/components/StorageManager/ui/FileListFooter/FileListFooter.mjs +13 -1
- package/dist/esm/components/StorageManager/ui/FileListHeader/FileListHeader.mjs +14 -1
- package/dist/esm/components/StorageManager/ui/FilePicker/FilePicker.mjs +9 -1
- package/dist/esm/components/StorageManager/utils/checkMaxFileSize.mjs +12 -1
- package/dist/esm/components/StorageManager/utils/displayText.mjs +39 -1
- package/dist/esm/components/StorageManager/utils/filterAllowedFiles.mjs +27 -1
- package/dist/esm/components/StorageManager/utils/humanFileSize.mjs +29 -1
- package/dist/esm/components/StorageManager/utils/uploadFile.mjs +29 -1
- package/dist/esm/index.mjs +2 -1
- package/dist/esm/version.mjs +3 -0
- package/dist/index.js +782 -1
- package/dist/styles.css +298 -684
- package/dist/types/components/StorageImage/StorageImage.d.ts +1 -1
- package/dist/types/components/StorageImage/types.d.ts +3 -2
- package/dist/types/components/StorageManager/hooks/useStorageManager/actions.d.ts +2 -2
- package/dist/types/components/StorageManager/hooks/useStorageManager/types.d.ts +2 -2
- package/dist/types/components/StorageManager/hooks/useStorageManager/useStorageManager.d.ts +2 -2
- package/dist/types/components/StorageManager/hooks/useUploadFiles/useUploadFiles.d.ts +2 -2
- package/dist/types/components/StorageManager/types.d.ts +4 -8
- package/dist/types/components/StorageManager/ui/FileList/types.d.ts +8 -8
- package/dist/types/components/StorageManager/ui/FileListFooter/FileListFooter.d.ts +2 -2
- package/dist/types/components/StorageManager/ui/FileListHeader/FileListHeader.d.ts +2 -2
- package/dist/types/components/StorageManager/utils/displayText.d.ts +22 -20
- package/dist/types/components/StorageManager/utils/index.d.ts +1 -1
- package/dist/types/components/StorageManager/utils/uploadFile.d.ts +4 -10
- package/dist/types/version.d.ts +1 -0
- package/package.json +8 -39
- package/dist/types/components/StorageImage/_tests_/StorageImage.test.d.ts +0 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { StorageImageProps } from './types';
|
|
3
|
-
export declare const StorageImage: ({ accessLevel, className, fallbackSrc, identityId, imgKey, onStorageGetError, ...rest }: StorageImageProps) => JSX.Element;
|
|
3
|
+
export declare const StorageImage: ({ accessLevel, className, fallbackSrc, identityId, imgKey, onStorageGetError, validateObjectExistence, ...rest }: StorageImageProps) => JSX.Element;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { StorageAccessLevel } from '@aws-amplify/core';
|
|
2
|
+
import { ImageProps } from '@aws-amplify/ui-react';
|
|
3
3
|
export interface StorageImageProps extends Omit<ImageProps, 'src'> {
|
|
4
4
|
imgKey: string;
|
|
5
5
|
accessLevel: StorageAccessLevel;
|
|
6
6
|
identityId?: string;
|
|
7
7
|
fallbackSrc?: string;
|
|
8
|
+
validateObjectExistence?: boolean;
|
|
8
9
|
onStorageGetError?: (error: Error) => void;
|
|
9
10
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { UploadDataOutput } from 'aws-amplify/storage';
|
|
2
2
|
import { FileStatus } from '../../types';
|
|
3
3
|
import { Action, AddFilesActionParams } from './types';
|
|
4
4
|
export declare const addFilesAction: ({ files, status, getFileErrorMessage, }: AddFilesActionParams) => Action;
|
|
@@ -6,7 +6,7 @@ export declare const clearFilesAction: () => Action;
|
|
|
6
6
|
export declare const queueFilesAction: () => Action;
|
|
7
7
|
export declare const setUploadingFileAction: ({ id, uploadTask, }: {
|
|
8
8
|
id: string;
|
|
9
|
-
uploadTask:
|
|
9
|
+
uploadTask: UploadDataOutput | undefined;
|
|
10
10
|
}) => Action;
|
|
11
11
|
export declare const setUploadProgressAction: ({ id, progress, }: {
|
|
12
12
|
id: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { UploadDataOutput } from 'aws-amplify/storage';
|
|
2
2
|
import { FileStatus, StorageFiles } from '../../types';
|
|
3
3
|
export interface UseStorageManagerState {
|
|
4
4
|
files: StorageFiles;
|
|
@@ -29,7 +29,7 @@ export type Action = {
|
|
|
29
29
|
} | {
|
|
30
30
|
type: StorageManagerActionTypes.SET_STATUS_UPLOADING;
|
|
31
31
|
id: string;
|
|
32
|
-
uploadTask?:
|
|
32
|
+
uploadTask?: UploadDataOutput;
|
|
33
33
|
} | {
|
|
34
34
|
type: StorageManagerActionTypes.SET_UPLOAD_PROGRESS;
|
|
35
35
|
id: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { UploadDataOutput } from 'aws-amplify/storage';
|
|
2
2
|
import { StorageFiles, FileStatus, DefaultFile } from '../../types';
|
|
3
3
|
import { GetFileErrorMessage } from './types';
|
|
4
4
|
export interface UseStorageManager {
|
|
@@ -11,7 +11,7 @@ export interface UseStorageManager {
|
|
|
11
11
|
queueFiles: () => void;
|
|
12
12
|
setUploadingFile: (params: {
|
|
13
13
|
id: string;
|
|
14
|
-
uploadTask?:
|
|
14
|
+
uploadTask?: UploadDataOutput;
|
|
15
15
|
}) => void;
|
|
16
16
|
setUploadProgress: (params: {
|
|
17
17
|
id: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { StorageManagerProps } from '../../types';
|
|
2
2
|
import { UseStorageManager } from '../useStorageManager';
|
|
3
|
-
export interface UseUploadFilesProps extends Pick<StorageManagerProps, 'accessLevel' | 'isResumable' | 'onUploadSuccess' | 'onUploadError' | 'onUploadStart' | 'maxFileCount' | 'processFile' | '
|
|
3
|
+
export interface UseUploadFilesProps extends Pick<StorageManagerProps, 'accessLevel' | 'isResumable' | 'onUploadSuccess' | 'onUploadError' | 'onUploadStart' | 'maxFileCount' | 'processFile' | 'path'>, Pick<UseStorageManager, 'setUploadingFile' | 'setUploadProgress' | 'setUploadSuccess' | 'files'> {
|
|
4
4
|
}
|
|
5
|
-
export declare function useUploadFiles({ files, accessLevel, isResumable, setUploadProgress, setUploadingFile, setUploadSuccess, onUploadError, onUploadSuccess, onUploadStart, maxFileCount, processFile,
|
|
5
|
+
export declare function useUploadFiles({ files, accessLevel, isResumable, setUploadProgress, setUploadingFile, setUploadSuccess, onUploadError, onUploadSuccess, onUploadStart, maxFileCount, processFile, path, }: UseUploadFilesProps): void;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import type {
|
|
2
|
+
import type { UploadDataOutput } from 'aws-amplify/storage';
|
|
3
|
+
import type { StorageAccessLevel } from '@aws-amplify/core';
|
|
3
4
|
import { ContainerProps, DropZoneProps, FileListHeaderProps, FileListFooterProps, FileListProps, FilePickerProps } from './ui';
|
|
4
5
|
import { StorageManagerDisplayText } from './utils';
|
|
5
6
|
export declare enum FileStatus {
|
|
@@ -15,7 +16,7 @@ export interface StorageFile {
|
|
|
15
16
|
file?: File;
|
|
16
17
|
status: FileStatus;
|
|
17
18
|
progress: number;
|
|
18
|
-
uploadTask?:
|
|
19
|
+
uploadTask?: UploadDataOutput;
|
|
19
20
|
key: string;
|
|
20
21
|
error: string;
|
|
21
22
|
isImage: boolean;
|
|
@@ -60,7 +61,7 @@ export interface StorageManagerProps {
|
|
|
60
61
|
/**
|
|
61
62
|
* Overrides default display text
|
|
62
63
|
*/
|
|
63
|
-
displayText?:
|
|
64
|
+
displayText?: StorageManagerDisplayText;
|
|
64
65
|
/**
|
|
65
66
|
* Determines if upload can be paused / resumed
|
|
66
67
|
*/
|
|
@@ -105,11 +106,6 @@ export interface StorageManagerProps {
|
|
|
105
106
|
* Determines if thumbnails show for image files
|
|
106
107
|
*/
|
|
107
108
|
showThumbnails?: boolean;
|
|
108
|
-
/**
|
|
109
|
-
* Storage provider name
|
|
110
|
-
* @see https://docs.amplify.aws/lib/storage/custom-plugin/q/platform/js/
|
|
111
|
-
*/
|
|
112
|
-
provider?: string;
|
|
113
109
|
/**
|
|
114
110
|
* A path to put files in the s3 bucket.
|
|
115
111
|
* This will be prepended to the key sent to
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { UploadDataOutput } from 'aws-amplify/storage';
|
|
2
|
+
import { StorageManagerDisplayTextDefault } from '../../utils';
|
|
3
3
|
import { FileStatus, StorageFile } from '../../types';
|
|
4
4
|
export interface FileListProps {
|
|
5
|
-
displayText:
|
|
5
|
+
displayText: StorageManagerDisplayTextDefault;
|
|
6
6
|
files: StorageFile[];
|
|
7
7
|
isResumable: boolean;
|
|
8
8
|
onCancelUpload: (params: {
|
|
9
9
|
id: string;
|
|
10
|
-
uploadTask:
|
|
10
|
+
uploadTask: UploadDataOutput;
|
|
11
11
|
}) => void;
|
|
12
12
|
onDeleteUpload: (params: {
|
|
13
13
|
id: string;
|
|
14
14
|
}) => void;
|
|
15
15
|
onPause: (params: {
|
|
16
16
|
id: string;
|
|
17
|
-
uploadTask:
|
|
17
|
+
uploadTask: UploadDataOutput;
|
|
18
18
|
}) => void;
|
|
19
19
|
onResume: (params: {
|
|
20
20
|
id: string;
|
|
21
|
-
uploadTask:
|
|
21
|
+
uploadTask: UploadDataOutput;
|
|
22
22
|
}) => void;
|
|
23
23
|
showThumbnails: boolean;
|
|
24
24
|
hasMaxFilesError: boolean;
|
|
25
25
|
maxFileCount: number;
|
|
26
26
|
}
|
|
27
27
|
export interface FileControlProps {
|
|
28
|
-
displayText:
|
|
28
|
+
displayText: StorageManagerDisplayTextDefault;
|
|
29
29
|
displayName: string;
|
|
30
30
|
errorMessage: string;
|
|
31
31
|
isImage: boolean;
|
|
@@ -41,7 +41,7 @@ export interface FileControlProps {
|
|
|
41
41
|
status: FileStatus;
|
|
42
42
|
thumbnailUrl: string;
|
|
43
43
|
}
|
|
44
|
-
export interface FileStatusMessageProps extends Pick<
|
|
44
|
+
export interface FileStatusMessageProps extends Pick<StorageManagerDisplayTextDefault, 'getUploadingText' | 'getPausedText' | 'uploadSuccessfulText'> {
|
|
45
45
|
status: FileStatus;
|
|
46
46
|
errorMessage: string;
|
|
47
47
|
percentage: number;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
2
|
+
import { StorageManagerDisplayTextDefault } from '../../utils';
|
|
3
3
|
export interface FileListFooterProps {
|
|
4
4
|
remainingFilesCount: number;
|
|
5
|
-
displayText:
|
|
5
|
+
displayText: StorageManagerDisplayTextDefault;
|
|
6
6
|
onClearAll: () => void;
|
|
7
7
|
onUploadAll: () => void;
|
|
8
8
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
2
|
+
import { StorageManagerDisplayTextDefault } from '../../utils';
|
|
3
3
|
export interface FileListHeaderProps {
|
|
4
4
|
allUploadsSuccessful: boolean;
|
|
5
|
-
displayText:
|
|
5
|
+
displayText: StorageManagerDisplayTextDefault;
|
|
6
6
|
fileCount: number;
|
|
7
7
|
remainingFilesCount: number;
|
|
8
8
|
selectedFilesCount?: number;
|
|
@@ -1,20 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
import { DisplayTextTemplate } from '@aws-amplify/ui';
|
|
2
|
+
export type StorageManagerDisplayText = 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 StorageManagerDisplayTextDefault = Required<StorageManagerDisplayText>;
|
|
22
|
+
export declare const defaultStorageManagerDisplayText: StorageManagerDisplayTextDefault;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { checkMaxFileSize } from './checkMaxFileSize';
|
|
2
|
-
export { defaultStorageManagerDisplayText, StorageManagerDisplayText, } from './displayText';
|
|
2
|
+
export { defaultStorageManagerDisplayText, StorageManagerDisplayText, StorageManagerDisplayTextDefault, } from './displayText';
|
|
3
3
|
export { filterAllowedFiles } from './filterAllowedFiles';
|
|
4
4
|
export { humanFileSize } from './humanFileSize';
|
|
5
5
|
export { uploadFile } from './uploadFile';
|
|
@@ -1,19 +1,13 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { StorageAccessLevel } from '@aws-amplify/core';
|
|
2
|
+
import { TransferProgressEvent, UploadDataOutput } from 'aws-amplify/storage';
|
|
2
3
|
export type UploadFileProps = {
|
|
3
4
|
file: File;
|
|
4
5
|
key: string;
|
|
5
6
|
level: StorageAccessLevel;
|
|
6
|
-
|
|
7
|
-
progressCallback: (progress: {
|
|
8
|
-
loaded: number;
|
|
9
|
-
total: number;
|
|
10
|
-
}) => void;
|
|
7
|
+
progressCallback: (event: TransferProgressEvent) => void;
|
|
11
8
|
errorCallback: (error: string) => void;
|
|
12
9
|
completeCallback: (event: {
|
|
13
10
|
key: string | undefined;
|
|
14
11
|
}) => void;
|
|
15
|
-
provider?: string;
|
|
16
12
|
} & Record<string, any>;
|
|
17
|
-
|
|
18
|
-
export declare function uploadFile({ file, key, level, progressCallback, errorCallback, completeCallback, isResumable, provider, ...rest }: UploadFileProps): UploadFile;
|
|
19
|
-
export {};
|
|
13
|
+
export declare function uploadFile({ file, key, level, progressCallback, errorCallback, completeCallback, ...rest }: UploadFileProps): UploadDataOutput;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const VERSION = "2.3.1";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-amplify/ui-react-storage",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/esm/index.mjs",
|
|
6
6
|
"exports": {
|
|
@@ -35,51 +35,20 @@
|
|
|
35
35
|
"prebuild": "rimraf dist",
|
|
36
36
|
"size": "yarn size-limit",
|
|
37
37
|
"test": "jest",
|
|
38
|
-
"test:ci": "yarn test && yarn check:esm",
|
|
39
38
|
"test:watch": "yarn test --watch",
|
|
40
39
|
"typecheck": "tsc --noEmit"
|
|
41
40
|
},
|
|
42
41
|
"dependencies": {
|
|
43
|
-
"@aws-amplify/ui": "
|
|
44
|
-
"@aws-amplify/ui-react": "
|
|
45
|
-
"@aws-amplify/ui-react-core": "
|
|
46
|
-
"classnames": "2.3.1",
|
|
42
|
+
"@aws-amplify/ui": "6.0.0",
|
|
43
|
+
"@aws-amplify/ui-react": "6.0.0",
|
|
44
|
+
"@aws-amplify/ui-react-core": "3.0.0",
|
|
47
45
|
"lodash": "4.17.21",
|
|
48
|
-
"tslib": "2.
|
|
46
|
+
"tslib": "^2.5.2"
|
|
49
47
|
},
|
|
50
48
|
"peerDependencies": {
|
|
51
|
-
"aws-amplify": "^
|
|
52
|
-
"react": "
|
|
53
|
-
"react-dom": "
|
|
54
|
-
},
|
|
55
|
-
"peerDependenciesMeta": {
|
|
56
|
-
"aws-amplify": {
|
|
57
|
-
"optional": true
|
|
58
|
-
}
|
|
59
|
-
},
|
|
60
|
-
"devDependencies": {
|
|
61
|
-
"@aws-amplify/eslint-config-amplify-ui": "0.0.0",
|
|
62
|
-
"@rollup/plugin-typescript": "^8.3.1",
|
|
63
|
-
"@size-limit/preset-big-lib": "^8.2.6",
|
|
64
|
-
"@testing-library/jest-dom": "^5.14.1",
|
|
65
|
-
"@testing-library/react": "^12.0.0",
|
|
66
|
-
"@testing-library/react-hooks": "^7.0.1",
|
|
67
|
-
"@testing-library/user-event": "^13.2.1",
|
|
68
|
-
"@types/jest": "^26.0.23",
|
|
69
|
-
"@types/react": "^17.0.2",
|
|
70
|
-
"@types/testing-library__jest-dom": "^5.14.1",
|
|
71
|
-
"eslint": "^8.44.0",
|
|
72
|
-
"jest": "^27.0.4",
|
|
73
|
-
"react": "^17.0.2",
|
|
74
|
-
"react-dom": "^17.0.2",
|
|
75
|
-
"rimraf": "^3.0.2",
|
|
76
|
-
"rollup": "^2.70.0",
|
|
77
|
-
"rollup-plugin-node-externals": "^4.1.1",
|
|
78
|
-
"rollup-plugin-styles": "^4.0.0",
|
|
79
|
-
"rollup-plugin-terser": "^7.0.2",
|
|
80
|
-
"size-limit": "^8.2.6",
|
|
81
|
-
"ts-jest": "^27.0.3",
|
|
82
|
-
"ts-morph": "^12.0.0"
|
|
49
|
+
"aws-amplify": "^6.0.2",
|
|
50
|
+
"react": "^16.14.0 || ^17.0 || ^18.0",
|
|
51
|
+
"react-dom": "^16.14.0 || ^17.0 || ^18.0"
|
|
83
52
|
},
|
|
84
53
|
"sideEffects": [
|
|
85
54
|
"dist/**/*.css"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|