@aws-amplify/ui-react-storage 3.2.0 → 3.3.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/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/components/StorageManager/ui/FileList/FileDetails.mjs +1 -4
- package/dist/esm/components/StorageManager/utils/checkMaxFileSize.mjs +1 -1
- package/dist/esm/index.mjs +1 -0
- package/dist/esm/version.mjs +1 -1
- package/dist/index.js +723 -37
- package/dist/styles.css +23 -42
- 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/StorageManager/utils/index.d.ts +0 -1
- 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 +4 -4
- package/dist/esm/components/StorageManager/utils/humanFileSize.mjs +0 -29
- package/dist/types/components/StorageManager/utils/humanFileSize.d.ts +0 -11
package/dist/styles.css
CHANGED
|
@@ -1640,9 +1640,8 @@ strong.amplify-text {
|
|
|
1640
1640
|
padding-inline-start: var(--amplify-components-button-padding-inline-start);
|
|
1641
1641
|
padding-inline-end: var(--amplify-components-button-padding-inline-end);
|
|
1642
1642
|
transition: all var(--amplify-components-button-transition-duration);
|
|
1643
|
-
-
|
|
1644
|
-
|
|
1645
|
-
user-select: none;
|
|
1643
|
+
-moz-user-select: none;
|
|
1644
|
+
user-select: none;
|
|
1646
1645
|
--amplify-internal-button-disabled-color: var(
|
|
1647
1646
|
--amplify-components-button-disabled-color
|
|
1648
1647
|
);
|
|
@@ -2663,58 +2662,50 @@ strong.amplify-text {
|
|
|
2663
2662
|
background-color: var(--amplify-internal-button-disabled-background-color);
|
|
2664
2663
|
border-color: var(--amplify-internal-button-disabled-border-color);
|
|
2665
2664
|
color: var(--amplify-internal-button-disabled-color);
|
|
2666
|
-
|
|
2667
|
-
text-decoration: var(--amplify-internal-button-disabled-text-decoration);
|
|
2665
|
+
text-decoration: var(--amplify-internal-button-disabled-text-decoration);
|
|
2668
2666
|
cursor: not-allowed;
|
|
2669
2667
|
}
|
|
2670
2668
|
.amplify-button--disabled:hover {
|
|
2671
2669
|
background-color: var(--amplify-internal-button-disabled-background-color);
|
|
2672
2670
|
border-color: var(--amplify-internal-button-disabled-border-color);
|
|
2673
2671
|
color: var(--amplify-internal-button-disabled-color);
|
|
2674
|
-
|
|
2675
|
-
text-decoration: var(--amplify-internal-button-disabled-text-decoration);
|
|
2672
|
+
text-decoration: var(--amplify-internal-button-disabled-text-decoration);
|
|
2676
2673
|
}
|
|
2677
2674
|
.amplify-button--disabled :focus {
|
|
2678
2675
|
background-color: var(--amplify-internal-button-disabled-background-color);
|
|
2679
2676
|
border-color: var(--amplify-internal-button-disabled-border-color);
|
|
2680
2677
|
color: var(--amplify-internal-button-disabled-color);
|
|
2681
|
-
|
|
2682
|
-
text-decoration: var(--amplify-internal-button-disabled-text-decoration);
|
|
2678
|
+
text-decoration: var(--amplify-internal-button-disabled-text-decoration);
|
|
2683
2679
|
}
|
|
2684
2680
|
.amplify-button--disabled:active {
|
|
2685
2681
|
background-color: var(--amplify-internal-button-disabled-background-color);
|
|
2686
2682
|
border-color: var(--amplify-internal-button-disabled-border-color);
|
|
2687
2683
|
color: var(--amplify-internal-button-disabled-color);
|
|
2688
|
-
|
|
2689
|
-
text-decoration: var(--amplify-internal-button-disabled-text-decoration);
|
|
2684
|
+
text-decoration: var(--amplify-internal-button-disabled-text-decoration);
|
|
2690
2685
|
}
|
|
2691
2686
|
.amplify-button--loading {
|
|
2692
2687
|
background-color: var(--amplify-internal-button-loading-background-color);
|
|
2693
2688
|
border-color: var(--amplify-internal-button-loading-border-color);
|
|
2694
2689
|
color: var(--amplify-components-button-loading-color);
|
|
2695
|
-
|
|
2696
|
-
text-decoration: var(--amplify-internal-button-loading-text-decoration);
|
|
2690
|
+
text-decoration: var(--amplify-internal-button-loading-text-decoration);
|
|
2697
2691
|
}
|
|
2698
2692
|
.amplify-button--loading:hover {
|
|
2699
2693
|
background-color: var(--amplify-internal-button-loading-background-color);
|
|
2700
2694
|
border-color: var(--amplify-internal-button-loading-border-color);
|
|
2701
2695
|
color: var(--amplify-components-button-loading-color);
|
|
2702
|
-
|
|
2703
|
-
text-decoration: var(--amplify-internal-button-loading-text-decoration);
|
|
2696
|
+
text-decoration: var(--amplify-internal-button-loading-text-decoration);
|
|
2704
2697
|
}
|
|
2705
2698
|
.amplify-button--loading:focus {
|
|
2706
2699
|
background-color: var(--amplify-internal-button-loading-background-color);
|
|
2707
2700
|
border-color: var(--amplify-internal-button-loading-border-color);
|
|
2708
2701
|
color: var(--amplify-components-button-loading-color);
|
|
2709
|
-
|
|
2710
|
-
text-decoration: var(--amplify-internal-button-loading-text-decoration);
|
|
2702
|
+
text-decoration: var(--amplify-internal-button-loading-text-decoration);
|
|
2711
2703
|
}
|
|
2712
2704
|
.amplify-button--loading:active {
|
|
2713
2705
|
background-color: var(--amplify-internal-button-loading-background-color);
|
|
2714
2706
|
border-color: var(--amplify-internal-button-loading-border-color);
|
|
2715
2707
|
color: var(--amplify-components-button-loading-color);
|
|
2716
|
-
|
|
2717
|
-
text-decoration: var(--amplify-internal-button-loading-text-decoration);
|
|
2708
|
+
text-decoration: var(--amplify-internal-button-loading-text-decoration);
|
|
2718
2709
|
}
|
|
2719
2710
|
.amplify-button__loader-wrapper {
|
|
2720
2711
|
align-items: var(--amplify-components-button-loader-wrapper-align-items);
|
|
@@ -2862,9 +2853,8 @@ strong.amplify-text {
|
|
|
2862
2853
|
outline-style: var(--amplify-components-fieldcontrol-outline-style);
|
|
2863
2854
|
outline-width: var(--amplify-components-fieldcontrol-outline-width);
|
|
2864
2855
|
outline-offset: var(--amplify-components-fieldcontrol-outline-offset);
|
|
2865
|
-
-
|
|
2866
|
-
|
|
2867
|
-
user-select: text;
|
|
2856
|
+
-moz-user-select: text;
|
|
2857
|
+
user-select: text;
|
|
2868
2858
|
display: inline-block;
|
|
2869
2859
|
--amplify-components-fieldcontrol-color: var(
|
|
2870
2860
|
--amplify-components-input-color
|
|
@@ -2947,9 +2937,8 @@ strong.amplify-text {
|
|
|
2947
2937
|
outline-style: var(--amplify-components-fieldcontrol-outline-style);
|
|
2948
2938
|
outline-width: var(--amplify-components-fieldcontrol-outline-width);
|
|
2949
2939
|
outline-offset: var(--amplify-components-fieldcontrol-outline-offset);
|
|
2950
|
-
-
|
|
2951
|
-
|
|
2952
|
-
user-select: text;
|
|
2940
|
+
-moz-user-select: text;
|
|
2941
|
+
user-select: text;
|
|
2953
2942
|
white-space: pre-wrap;
|
|
2954
2943
|
}
|
|
2955
2944
|
.amplify-textarea:focus {
|
|
@@ -3013,29 +3002,24 @@ strong.amplify-text {
|
|
|
3013
3002
|
|
|
3014
3003
|
.amplify-link {
|
|
3015
3004
|
color: var(--amplify-components-link-color);
|
|
3016
|
-
|
|
3017
|
-
text-decoration: var(--amplify-components-link-text-decoration);
|
|
3005
|
+
text-decoration: var(--amplify-components-link-text-decoration);
|
|
3018
3006
|
cursor: pointer;
|
|
3019
3007
|
}
|
|
3020
3008
|
.amplify-link:visited {
|
|
3021
3009
|
color: var(--amplify-components-link-visited-color);
|
|
3022
|
-
|
|
3023
|
-
text-decoration: var(--amplify-components-link-visited-text-decoration);
|
|
3010
|
+
text-decoration: var(--amplify-components-link-visited-text-decoration);
|
|
3024
3011
|
}
|
|
3025
3012
|
.amplify-link:active {
|
|
3026
3013
|
color: var(--amplify-components-link-active-color);
|
|
3027
|
-
|
|
3028
|
-
text-decoration: var(--amplify-components-link-active-text-decoration);
|
|
3014
|
+
text-decoration: var(--amplify-components-link-active-text-decoration);
|
|
3029
3015
|
}
|
|
3030
3016
|
.amplify-link:focus {
|
|
3031
3017
|
color: var(--amplify-components-link-focus-color);
|
|
3032
|
-
|
|
3033
|
-
text-decoration: var(--amplify-components-link-focus-text-decoration);
|
|
3018
|
+
text-decoration: var(--amplify-components-link-focus-text-decoration);
|
|
3034
3019
|
}
|
|
3035
3020
|
.amplify-link:hover {
|
|
3036
3021
|
color: var(--amplify-components-link-hover-color);
|
|
3037
|
-
|
|
3038
|
-
text-decoration: var(--amplify-components-link-hover-text-decoration);
|
|
3022
|
+
text-decoration: var(--amplify-components-link-hover-text-decoration);
|
|
3039
3023
|
}
|
|
3040
3024
|
|
|
3041
3025
|
.amplify-loader {
|
|
@@ -3466,16 +3450,14 @@ strong.amplify-text {
|
|
|
3466
3450
|
font-weight: var(--amplify-components-breadcrumbs-link-font-weight);
|
|
3467
3451
|
padding-inline: var(--amplify-components-breadcrumbs-link-padding-inline);
|
|
3468
3452
|
padding-block: var(--amplify-components-breadcrumbs-link-padding-block);
|
|
3469
|
-
|
|
3470
|
-
text-decoration: var(--amplify-components-breadcrumbs-link-text-decoration);
|
|
3453
|
+
text-decoration: var(--amplify-components-breadcrumbs-link-text-decoration);
|
|
3471
3454
|
}
|
|
3472
3455
|
|
|
3473
3456
|
.amplify-breadcrumbs__link--current {
|
|
3474
3457
|
color: var(--amplify-components-breadcrumbs-link-current-color);
|
|
3475
3458
|
font-size: var(--amplify-components-breadcrumbs-link-current-font-size);
|
|
3476
3459
|
font-weight: var(--amplify-components-breadcrumbs-link-current-font-weight);
|
|
3477
|
-
|
|
3478
|
-
text-decoration: var(--amplify-components-breadcrumbs-link-current-text-decoration);
|
|
3460
|
+
text-decoration: var(--amplify-components-breadcrumbs-link-current-text-decoration);
|
|
3479
3461
|
}
|
|
3480
3462
|
|
|
3481
3463
|
.amplify-card {
|
|
@@ -5025,9 +5007,8 @@ html[dir=rtl] .amplify-field-group__inner-start {
|
|
|
5025
5007
|
padding-block: var(--amplify-components-sliderfield-padding-block);
|
|
5026
5008
|
position: relative;
|
|
5027
5009
|
touch-action: none;
|
|
5028
|
-
-
|
|
5029
|
-
|
|
5030
|
-
user-select: none;
|
|
5010
|
+
-moz-user-select: none;
|
|
5011
|
+
user-select: none;
|
|
5031
5012
|
--amplify-internal-sliderfield-root-height: var(
|
|
5032
5013
|
--amplify-components-sliderfield-thumb-height
|
|
5033
5014
|
);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { FileUploaderProps, FileUploaderPathProps, FileUploaderHandle } from './types';
|
|
3
|
+
import { Container, DropZone, FileList, FileListHeader, FileListFooter, FilePicker } from './ui';
|
|
4
|
+
export declare const MISSING_REQUIRED_PROPS_MESSAGE = "`FileUploader` requires a `maxFileCount` prop to be provided.";
|
|
5
|
+
export declare const ACCESS_LEVEL_WITH_PATH_CALLBACK_MESSAGE = "`FileUploader` does not allow usage of a `path` callback prop with an `accessLevel` prop.";
|
|
6
|
+
export declare const ACCESS_LEVEL_DEPRECATION_MESSAGE = "`accessLevel` has been deprecated and will be removed in a future major version. See migration notes at https://ui.docs.amplify.aws/react/connected-components/storage/FileUploader";
|
|
7
|
+
declare const FileUploader: React.ForwardRefExoticComponent<(FileUploaderProps | FileUploaderPathProps) & React.RefAttributes<FileUploaderHandle>> & {
|
|
8
|
+
Container: typeof Container;
|
|
9
|
+
DropZone: typeof DropZone;
|
|
10
|
+
FileList: typeof FileList;
|
|
11
|
+
FileListHeader: typeof FileListHeader;
|
|
12
|
+
FileListFooter: typeof FileListFooter;
|
|
13
|
+
FilePicker: typeof FilePicker;
|
|
14
|
+
};
|
|
15
|
+
export { FileUploader };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { FileStatus } from '../../types';
|
|
2
|
+
import { Action, AddFilesActionParams } from './types';
|
|
3
|
+
import { TaskEvent } from '../../utils';
|
|
4
|
+
export declare const addFilesAction: ({ files, status, getFileErrorMessage, }: AddFilesActionParams) => Action;
|
|
5
|
+
export declare const clearFilesAction: () => Action;
|
|
6
|
+
export declare const queueFilesAction: () => Action;
|
|
7
|
+
export declare const setProcessedKeyAction: (input: {
|
|
8
|
+
id: string;
|
|
9
|
+
processedKey: string;
|
|
10
|
+
}) => Action;
|
|
11
|
+
export declare const setUploadingFileAction: ({ id, uploadTask, }: TaskEvent) => Action;
|
|
12
|
+
export declare const setUploadProgressAction: ({ id, progress, }: {
|
|
13
|
+
id: string;
|
|
14
|
+
progress: number;
|
|
15
|
+
}) => Action;
|
|
16
|
+
export declare const setUploadStatusAction: ({ id, status, }: {
|
|
17
|
+
id: string;
|
|
18
|
+
status: FileStatus;
|
|
19
|
+
}) => Action;
|
|
20
|
+
export declare const removeUploadAction: ({ id }: {
|
|
21
|
+
id: string;
|
|
22
|
+
}) => Action;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useFileUploader, UseFileUploader } from './useFileUploader';
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { FileStatus, StorageFiles } from '../../types';
|
|
2
|
+
import { UploadTask } from '../../utils';
|
|
3
|
+
export interface UseFileUploaderState {
|
|
4
|
+
files: StorageFiles;
|
|
5
|
+
}
|
|
6
|
+
export declare enum FileUploaderActionTypes {
|
|
7
|
+
ADD_FILES = "ADD_FILES",
|
|
8
|
+
CLEAR_FILES = "CLEAR_FILES",
|
|
9
|
+
QUEUE_FILES = "QUEUE_FILES",
|
|
10
|
+
SET_STATUS = "SET_STATUS",
|
|
11
|
+
SET_PROCESSED_FILE_KEY = "SET_PROCESSED_FILE_KEY",
|
|
12
|
+
SET_STATUS_UPLOADING = "SET_STATUS_UPLOADING",
|
|
13
|
+
SET_UPLOAD_PROGRESS = "SET_UPLOAD_PROGRESS",
|
|
14
|
+
REMOVE_UPLOAD = "REMOVE_UPLOAD"
|
|
15
|
+
}
|
|
16
|
+
export type GetFileErrorMessage = (file: File) => string;
|
|
17
|
+
export type Action = {
|
|
18
|
+
type: FileUploaderActionTypes.ADD_FILES;
|
|
19
|
+
files: File[];
|
|
20
|
+
status: FileStatus;
|
|
21
|
+
getFileErrorMessage: GetFileErrorMessage;
|
|
22
|
+
} | {
|
|
23
|
+
type: FileUploaderActionTypes.CLEAR_FILES;
|
|
24
|
+
} | {
|
|
25
|
+
type: FileUploaderActionTypes.SET_STATUS;
|
|
26
|
+
id: string;
|
|
27
|
+
status: FileStatus;
|
|
28
|
+
} | {
|
|
29
|
+
type: FileUploaderActionTypes.QUEUE_FILES;
|
|
30
|
+
} | {
|
|
31
|
+
type: FileUploaderActionTypes.SET_STATUS_UPLOADING;
|
|
32
|
+
id: string;
|
|
33
|
+
uploadTask?: UploadTask;
|
|
34
|
+
} | {
|
|
35
|
+
type: FileUploaderActionTypes.SET_UPLOAD_PROGRESS;
|
|
36
|
+
id: string;
|
|
37
|
+
progress: number;
|
|
38
|
+
} | {
|
|
39
|
+
type: FileUploaderActionTypes.SET_PROCESSED_FILE_KEY;
|
|
40
|
+
id: string;
|
|
41
|
+
processedKey: string;
|
|
42
|
+
} | {
|
|
43
|
+
type: FileUploaderActionTypes.REMOVE_UPLOAD;
|
|
44
|
+
id: string;
|
|
45
|
+
};
|
|
46
|
+
export interface AddFilesActionParams {
|
|
47
|
+
files: File[];
|
|
48
|
+
status: FileStatus;
|
|
49
|
+
getFileErrorMessage: GetFileErrorMessage;
|
|
50
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { StorageFiles, FileStatus, DefaultFile } from '../../types';
|
|
2
|
+
import { GetFileErrorMessage } from './types';
|
|
3
|
+
import { TaskHandler } from '../../utils';
|
|
4
|
+
export interface UseFileUploader {
|
|
5
|
+
addFiles: (params: {
|
|
6
|
+
files: File[];
|
|
7
|
+
status: FileStatus;
|
|
8
|
+
getFileErrorMessage: GetFileErrorMessage;
|
|
9
|
+
}) => void;
|
|
10
|
+
clearFiles: () => void;
|
|
11
|
+
queueFiles: () => void;
|
|
12
|
+
setUploadingFile: TaskHandler;
|
|
13
|
+
setProcessedKey: (params: {
|
|
14
|
+
id: string;
|
|
15
|
+
processedKey: string;
|
|
16
|
+
}) => void;
|
|
17
|
+
setUploadProgress: (params: {
|
|
18
|
+
id: string;
|
|
19
|
+
progress: number;
|
|
20
|
+
}) => void;
|
|
21
|
+
setUploadSuccess: (params: {
|
|
22
|
+
id: string;
|
|
23
|
+
}) => void;
|
|
24
|
+
setUploadResumed: (params: {
|
|
25
|
+
id: string;
|
|
26
|
+
}) => void;
|
|
27
|
+
setUploadPaused: (params: {
|
|
28
|
+
id: string;
|
|
29
|
+
}) => void;
|
|
30
|
+
removeUpload: (params: {
|
|
31
|
+
id: string;
|
|
32
|
+
}) => void;
|
|
33
|
+
files: StorageFiles;
|
|
34
|
+
}
|
|
35
|
+
export declare function useFileUploader(defaultFiles?: Array<DefaultFile>): UseFileUploader;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useUploadFiles, UseUploadFilesProps } from './useUploadFiles';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { PathCallback } from '../../utils';
|
|
2
|
+
import { FileUploaderProps } from '../../types';
|
|
3
|
+
import { UseFileUploader } from '../useFileUploader';
|
|
4
|
+
export interface UseUploadFilesProps extends Pick<FileUploaderProps, 'isResumable' | 'onUploadSuccess' | 'onUploadError' | 'onUploadStart' | 'maxFileCount' | 'processFile' | 'useAccelerateEndpoint'>, Pick<UseFileUploader, 'setUploadingFile' | 'setUploadProgress' | 'setUploadSuccess' | 'files'> {
|
|
5
|
+
accessLevel?: FileUploaderProps['accessLevel'];
|
|
6
|
+
onProcessFileSuccess: (input: {
|
|
7
|
+
id: string;
|
|
8
|
+
processedKey: string;
|
|
9
|
+
}) => void;
|
|
10
|
+
path?: string | PathCallback;
|
|
11
|
+
}
|
|
12
|
+
export declare function useUploadFiles({ accessLevel, files, isResumable, maxFileCount, onProcessFileSuccess, onUploadError, onUploadStart, onUploadSuccess, path, processFile, setUploadingFile, setUploadProgress, setUploadSuccess, useAccelerateEndpoint, }: UseUploadFilesProps): void;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { StorageAccessLevel } from '@aws-amplify/core';
|
|
3
|
+
import { ContainerProps, DropZoneProps, FileListHeaderProps, FileListFooterProps, FileListProps, FilePickerProps } from './ui';
|
|
4
|
+
import { FileUploaderDisplayText, PathCallback, UploadTask } from './utils';
|
|
5
|
+
export declare enum FileStatus {
|
|
6
|
+
ADDED = "added",
|
|
7
|
+
QUEUED = "queued",
|
|
8
|
+
UPLOADING = "uploading",
|
|
9
|
+
PAUSED = "paused",
|
|
10
|
+
ERROR = "error",
|
|
11
|
+
UPLOADED = "uploaded"
|
|
12
|
+
}
|
|
13
|
+
export interface StorageFile {
|
|
14
|
+
id: string;
|
|
15
|
+
file?: File;
|
|
16
|
+
status: FileStatus;
|
|
17
|
+
progress: number;
|
|
18
|
+
processedKey?: string;
|
|
19
|
+
uploadTask?: UploadTask;
|
|
20
|
+
key: string;
|
|
21
|
+
error: string;
|
|
22
|
+
isImage: boolean;
|
|
23
|
+
}
|
|
24
|
+
export type StorageFiles = StorageFile[];
|
|
25
|
+
export type DefaultFile = Pick<StorageFile, 'key'>;
|
|
26
|
+
export interface ProcessFileParams extends Record<string, any> {
|
|
27
|
+
file: File;
|
|
28
|
+
key: string;
|
|
29
|
+
useAccelerateEndpoint?: boolean;
|
|
30
|
+
}
|
|
31
|
+
export type ProcessFile = (params: ProcessFileParams) => Promise<ProcessFileParams> | ProcessFileParams;
|
|
32
|
+
export interface FileUploaderHandle {
|
|
33
|
+
clearFiles: () => void;
|
|
34
|
+
}
|
|
35
|
+
export interface FileUploaderProps {
|
|
36
|
+
/**
|
|
37
|
+
* List of accepted File types, values of `['*']` or undefined allow any files
|
|
38
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/accept
|
|
39
|
+
*/
|
|
40
|
+
acceptedFileTypes?: string[];
|
|
41
|
+
/**
|
|
42
|
+
* Access level for file uploads
|
|
43
|
+
* @see https://docs.amplify.aws/lib/storage/configureaccess/q/platform/js/
|
|
44
|
+
*/
|
|
45
|
+
accessLevel: StorageAccessLevel;
|
|
46
|
+
/**
|
|
47
|
+
* Determines if the upload will automatically start after a file is selected, default value: true
|
|
48
|
+
*/
|
|
49
|
+
autoUpload?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Component overrides
|
|
52
|
+
*/
|
|
53
|
+
components?: {
|
|
54
|
+
Container?: React.ComponentType<ContainerProps>;
|
|
55
|
+
DropZone?: React.ComponentType<DropZoneProps>;
|
|
56
|
+
FileList?: React.ComponentType<FileListProps>;
|
|
57
|
+
FilePicker?: React.ComponentType<FilePickerProps>;
|
|
58
|
+
FileListHeader?: React.ComponentType<FileListHeaderProps>;
|
|
59
|
+
FileListFooter?: React.ComponentType<FileListFooterProps>;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* List of default files already uploaded
|
|
63
|
+
*/
|
|
64
|
+
defaultFiles?: DefaultFile[];
|
|
65
|
+
/**
|
|
66
|
+
* Overrides default display text
|
|
67
|
+
*/
|
|
68
|
+
displayText?: FileUploaderDisplayText;
|
|
69
|
+
/**
|
|
70
|
+
* Determines if upload can be paused / resumed
|
|
71
|
+
*/
|
|
72
|
+
isResumable?: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Maximum total files to upload in each batch
|
|
75
|
+
*/
|
|
76
|
+
maxFileCount: number;
|
|
77
|
+
/**
|
|
78
|
+
* Maximum file size in bytes
|
|
79
|
+
*/
|
|
80
|
+
maxFileSize?: number;
|
|
81
|
+
/**
|
|
82
|
+
* When a file is removed
|
|
83
|
+
*/
|
|
84
|
+
onFileRemove?: (file: {
|
|
85
|
+
key: string;
|
|
86
|
+
}) => void;
|
|
87
|
+
/**
|
|
88
|
+
* Monitor upload errors
|
|
89
|
+
*/
|
|
90
|
+
onUploadError?: (error: string, file: {
|
|
91
|
+
key: string;
|
|
92
|
+
}) => void;
|
|
93
|
+
/**
|
|
94
|
+
* Monitor upload success
|
|
95
|
+
*/
|
|
96
|
+
onUploadSuccess?: (event: {
|
|
97
|
+
key?: string;
|
|
98
|
+
}) => void;
|
|
99
|
+
/**
|
|
100
|
+
* When a file begins uploading
|
|
101
|
+
*/
|
|
102
|
+
onUploadStart?: (event: {
|
|
103
|
+
key?: string;
|
|
104
|
+
}) => void;
|
|
105
|
+
/**
|
|
106
|
+
* Process file before upload
|
|
107
|
+
*/
|
|
108
|
+
processFile?: ProcessFile;
|
|
109
|
+
/**
|
|
110
|
+
* Determines if thumbnails show for image files
|
|
111
|
+
*/
|
|
112
|
+
showThumbnails?: boolean;
|
|
113
|
+
/**
|
|
114
|
+
* Provided value is prefixed to the file `key` for each file
|
|
115
|
+
*/
|
|
116
|
+
path?: string;
|
|
117
|
+
useAccelerateEndpoint?: boolean;
|
|
118
|
+
}
|
|
119
|
+
export interface FileUploaderPathProps extends Omit<FileUploaderProps, 'accessLevel' | 'path'> {
|
|
120
|
+
/**
|
|
121
|
+
* S3 bucket key, allows either a `string` or a `PathCallback`:
|
|
122
|
+
* - `string`: `path` is prefixed to the file `key` for each file
|
|
123
|
+
* - `PathCallback`: callback provided an input containing the current `identityId`,
|
|
124
|
+
* resolved value is prefixed to the file `key` for each file
|
|
125
|
+
*/
|
|
126
|
+
path: string | PathCallback;
|
|
127
|
+
accessLevel?: never;
|
|
128
|
+
useAccelerateEndpoint?: boolean;
|
|
129
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Container, ContainerProps } from './Container';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { FileUploaderDisplayText } from '../../utils/displayText';
|
|
3
|
+
export interface DropZoneProps {
|
|
4
|
+
children?: React.ReactNode;
|
|
5
|
+
displayText: FileUploaderDisplayText;
|
|
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,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';
|