@aws-amplify/ui-react-storage 0.0.0-studio-e5b8195-20230912200241 → 0.0.0-theming-v2-f8422a3-20240627193426
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 +57 -0
- package/dist/esm/components/StorageManager/StorageManager.mjs +181 -0
- package/dist/esm/components/StorageManager/hooks/useStorageManager/actions.mjs +35 -0
- package/dist/esm/components/StorageManager/hooks/useStorageManager/reducer.mjs +132 -0
- package/dist/esm/components/StorageManager/hooks/useStorageManager/types.mjs +12 -0
- package/dist/esm/components/StorageManager/hooks/useStorageManager/useStorageManager.mjs +58 -0
- package/dist/esm/components/StorageManager/hooks/useUploadFiles/useUploadFiles.mjs +74 -0
- package/dist/esm/components/StorageManager/types.mjs +11 -0
- package/dist/esm/components/StorageManager/ui/Container/Container.mjs +8 -0
- package/dist/esm/components/StorageManager/ui/DropZone/DropZone.mjs +16 -0
- package/dist/esm/components/StorageManager/ui/FileList/FileControl.mjs +23 -0
- package/dist/esm/components/StorageManager/ui/FileList/FileDetails.mjs +15 -0
- package/dist/esm/components/StorageManager/ui/FileList/FileList.mjs +44 -0
- package/dist/esm/components/StorageManager/ui/FileList/FileRemoveButton.mjs +12 -0
- package/dist/esm/components/StorageManager/ui/FileList/FileStatusMessage.mjs +28 -0
- package/dist/esm/components/StorageManager/ui/FileList/FileThumbnail.mjs +12 -0
- package/dist/esm/components/StorageManager/ui/FileListFooter/FileListFooter.mjs +13 -0
- package/dist/esm/components/StorageManager/ui/FileListHeader/FileListHeader.mjs +14 -0
- package/dist/esm/components/StorageManager/ui/FilePicker/FilePicker.mjs +9 -0
- package/dist/esm/components/StorageManager/utils/checkMaxFileSize.mjs +12 -0
- package/dist/esm/components/StorageManager/utils/displayText.mjs +39 -0
- package/dist/esm/components/StorageManager/utils/filterAllowedFiles.mjs +27 -0
- package/dist/esm/components/StorageManager/utils/getInput.mjs +25 -0
- package/dist/esm/components/StorageManager/utils/humanFileSize.mjs +29 -0
- package/dist/esm/components/StorageManager/utils/resolveFile.mjs +20 -0
- package/dist/esm/components/StorageManager/utils/uploadFile.mjs +26 -0
- package/dist/esm/index.mjs +2 -0
- package/dist/esm/version.mjs +3 -0
- package/dist/index.js +832 -1
- package/dist/styles.css +503 -746
- package/dist/types/components/StorageImage/StorageImage.d.ts +6 -2
- package/dist/types/components/StorageImage/types.d.ts +33 -2
- 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 +1 -1
- package/dist/types/components/StorageManager/hooks/useStorageManager/useStorageManager.d.ts +2 -5
- package/dist/types/components/StorageManager/hooks/useUploadFiles/useUploadFiles.d.ts +5 -2
- package/dist/types/components/StorageManager/types.d.ts +17 -11
- package/dist/types/components/StorageManager/ui/FileList/types.d.ts +7 -17
- 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/getInput.d.ts +13 -0
- package/dist/types/components/StorageManager/utils/index.d.ts +3 -2
- package/dist/types/components/StorageManager/utils/resolveFile.d.ts +9 -0
- package/dist/types/components/StorageManager/utils/uploadFile.d.ts +30 -17
- package/dist/types/version.d.ts +1 -0
- package/package.json +13 -44
- package/dist/esm/components/StorageImage/StorageImage.js +0 -1
- package/dist/esm/components/StorageManager/StorageManager.js +0 -1
- package/dist/esm/components/StorageManager/hooks/useStorageManager/actions.js +0 -1
- package/dist/esm/components/StorageManager/hooks/useStorageManager/reducer.js +0 -1
- package/dist/esm/components/StorageManager/hooks/useStorageManager/types.js +0 -1
- package/dist/esm/components/StorageManager/hooks/useStorageManager/useStorageManager.js +0 -1
- package/dist/esm/components/StorageManager/hooks/useUploadFiles/resolveFile.js +0 -1
- package/dist/esm/components/StorageManager/hooks/useUploadFiles/useUploadFiles.js +0 -1
- package/dist/esm/components/StorageManager/types.js +0 -1
- package/dist/esm/components/StorageManager/ui/Container/Container.js +0 -1
- package/dist/esm/components/StorageManager/ui/DropZone/DropZone.js +0 -1
- package/dist/esm/components/StorageManager/ui/FileList/FileControl.js +0 -1
- package/dist/esm/components/StorageManager/ui/FileList/FileDetails.js +0 -1
- package/dist/esm/components/StorageManager/ui/FileList/FileList.js +0 -1
- package/dist/esm/components/StorageManager/ui/FileList/FileRemoveButton.js +0 -1
- package/dist/esm/components/StorageManager/ui/FileList/FileStatusMessage.js +0 -1
- package/dist/esm/components/StorageManager/ui/FileList/FileThumbnail.js +0 -1
- package/dist/esm/components/StorageManager/ui/FileListFooter/FileListFooter.js +0 -1
- package/dist/esm/components/StorageManager/ui/FileListHeader/FileListHeader.js +0 -1
- package/dist/esm/components/StorageManager/ui/FilePicker/FilePicker.js +0 -1
- package/dist/esm/components/StorageManager/utils/checkMaxFileSize.js +0 -1
- package/dist/esm/components/StorageManager/utils/displayText.js +0 -1
- package/dist/esm/components/StorageManager/utils/filterAllowedFiles.js +0 -1
- package/dist/esm/components/StorageManager/utils/humanFileSize.js +0 -1
- package/dist/esm/components/StorageManager/utils/uploadFile.js +0 -1
- package/dist/esm/index.js +0 -1
- package/dist/types/components/StorageImage/_tests_/StorageImage.test.d.ts +0 -1
- package/dist/types/components/StorageManager/hooks/useUploadFiles/resolveFile.d.ts +0 -10
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type { StorageImageProps } from './types';
|
|
3
|
-
export declare const
|
|
2
|
+
import type { StorageImageProps, StorageImagePathProps } from './types';
|
|
3
|
+
export declare const MISSING_REQUIRED_PROP_MESSAGE = "`StorageImage` requires either an `imgKey` or `path` prop.";
|
|
4
|
+
export declare const HAS_DEPRECATED_PROPS_MESSAGE = "`imgKey`, `accessLevel`, and `identityId` will be replaced with `path` in a future major version. See https://ui.docs.amplify.aws/react/connected-components/storage/storageimage#props";
|
|
5
|
+
export declare const HAS_PATH_AND_KEY_MESSAGE = "`imgKey` is ignored when both `imgKey` and `path` props are provided.";
|
|
6
|
+
export declare const HAS_PATH_AND_UNSUPPORTED_OPTIONS_MESSAGE = "`accessLevel` and `identityId` are ignored when the `path` prop is provided.";
|
|
7
|
+
export declare const StorageImage: ({ accessLevel, className, fallbackSrc, identityId, imgKey, path, onStorageGetError, onGetUrlError, validateObjectExistence, ...rest }: StorageImageProps | StorageImagePathProps) => JSX.Element;
|
|
@@ -1,9 +1,40 @@
|
|
|
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
|
+
/**
|
|
5
|
+
* @deprecated
|
|
6
|
+
* `imgKey` will be replaced with `path` in a future major version of Amplify UI. See https://ui.docs.amplify.aws/react/connected-components/storage/storageimage#props
|
|
7
|
+
*/
|
|
4
8
|
imgKey: string;
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated
|
|
11
|
+
* `accessLevel` will be replaced with `path` in a future major version of Amplify UI. See https://ui.docs.amplify.aws/react/connected-components/storage/storageimage#props
|
|
12
|
+
*/
|
|
5
13
|
accessLevel: StorageAccessLevel;
|
|
14
|
+
/**
|
|
15
|
+
* @deprecated
|
|
16
|
+
* `identityId` will be replaced with `path` in a future major version of Amplify UI. See https://ui.docs.amplify.aws/react/connected-components/storage/storageimage#props
|
|
17
|
+
*/
|
|
6
18
|
identityId?: string;
|
|
7
19
|
fallbackSrc?: string;
|
|
20
|
+
validateObjectExistence?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* @deprecated use `onGetUrlError`
|
|
23
|
+
*
|
|
24
|
+
* `onStorageGetError` will be replaced with `onGetUrlError` in a future major version of Amplify UI. See https://ui.docs.amplify.aws/react/connected-components/storage/storageimage#props
|
|
25
|
+
*/
|
|
8
26
|
onStorageGetError?: (error: Error) => void;
|
|
27
|
+
onGetUrlError?: (error: Error) => void;
|
|
28
|
+
path?: never;
|
|
9
29
|
}
|
|
30
|
+
type OmittedPropKey = 'accessLevel' | 'imgKey' | 'identityId' | 'onStorageGetError' | 'path';
|
|
31
|
+
export interface StorageImagePathProps extends Omit<StorageImageProps, OmittedPropKey> {
|
|
32
|
+
path: string | ((input: {
|
|
33
|
+
identityId?: string;
|
|
34
|
+
}) => string);
|
|
35
|
+
imgKey?: never;
|
|
36
|
+
accessLevel?: never;
|
|
37
|
+
identityId?: never;
|
|
38
|
+
onStorageGetError?: never;
|
|
39
|
+
}
|
|
40
|
+
export {};
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { StorageManagerProps, StorageManagerHandle } from './types';
|
|
2
|
+
import { StorageManagerProps, StorageManagerPathProps, StorageManagerHandle } from './types';
|
|
3
3
|
import { Container, DropZone, FileList, FileListHeader, FileListFooter, FilePicker } from './ui';
|
|
4
|
-
declare const StorageManager
|
|
4
|
+
export declare const MISSING_REQUIRED_PROPS_MESSAGE = "`StorageManager` requires a `maxFileCount` prop to be provided.";
|
|
5
|
+
export declare const ACCESS_LEVEL_WITH_PATH_CALLBACK_MESSAGE = "`StorageManager` 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/storagemanager";
|
|
7
|
+
declare const StorageManager: React.ForwardRefExoticComponent<(StorageManagerProps | StorageManagerPathProps) & React.RefAttributes<StorageManagerHandle>> & {
|
|
5
8
|
Container: typeof Container;
|
|
6
9
|
DropZone: typeof DropZone;
|
|
7
10
|
FileList: typeof FileList;
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import { UploadTask } from '@aws-amplify/storage';
|
|
2
1
|
import { FileStatus } from '../../types';
|
|
3
2
|
import { Action, AddFilesActionParams } from './types';
|
|
3
|
+
import { TaskEvent } from '../../utils';
|
|
4
4
|
export declare const addFilesAction: ({ files, status, getFileErrorMessage, }: AddFilesActionParams) => Action;
|
|
5
5
|
export declare const clearFilesAction: () => Action;
|
|
6
6
|
export declare const queueFilesAction: () => Action;
|
|
7
|
-
export declare const setUploadingFileAction: ({ id, uploadTask, }:
|
|
8
|
-
id: string;
|
|
9
|
-
uploadTask: UploadTask | undefined;
|
|
10
|
-
}) => Action;
|
|
7
|
+
export declare const setUploadingFileAction: ({ id, uploadTask, }: TaskEvent) => Action;
|
|
11
8
|
export declare const setUploadProgressAction: ({ id, progress, }: {
|
|
12
9
|
id: string;
|
|
13
10
|
progress: number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { UploadTask } 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?: UploadTask;
|
|
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
|
-
export declare function useUploadFiles({ files, accessLevel, isResumable, setUploadProgress, setUploadingFile, setUploadSuccess, onUploadError, onUploadSuccess, onUploadStart, maxFileCount, processFile,
|
|
8
|
+
export declare function useUploadFiles({ files, accessLevel, isResumable, setUploadProgress, setUploadingFile, setUploadSuccess, onUploadError, onUploadSuccess, onUploadStart, maxFileCount, processFile, path, }: UseUploadFilesProps): void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import type { StorageAccessLevel
|
|
2
|
+
import type { StorageAccessLevel } from '@aws-amplify/core';
|
|
3
3
|
import { ContainerProps, DropZoneProps, FileListHeaderProps, FileListFooterProps, FileListProps, FilePickerProps } from './ui';
|
|
4
|
-
import { StorageManagerDisplayText } from './utils';
|
|
4
|
+
import { StorageManagerDisplayText, PathCallback, UploadTask } from './utils';
|
|
5
5
|
export declare enum FileStatus {
|
|
6
6
|
ADDED = "added",
|
|
7
7
|
QUEUED = "queued",
|
|
@@ -22,7 +22,10 @@ export interface StorageFile {
|
|
|
22
22
|
}
|
|
23
23
|
export type StorageFiles = StorageFile[];
|
|
24
24
|
export type DefaultFile = Pick<StorageFile, 'key'>;
|
|
25
|
-
export
|
|
25
|
+
export interface ProcessFileParams extends Record<string, any> {
|
|
26
|
+
file: File;
|
|
27
|
+
key: string;
|
|
28
|
+
}
|
|
26
29
|
export type ProcessFile = (params: ProcessFileParams) => Promise<ProcessFileParams> | ProcessFileParams;
|
|
27
30
|
export interface StorageManagerHandle {
|
|
28
31
|
clearFiles: () => void;
|
|
@@ -60,7 +63,7 @@ export interface StorageManagerProps {
|
|
|
60
63
|
/**
|
|
61
64
|
* Overrides default display text
|
|
62
65
|
*/
|
|
63
|
-
displayText?:
|
|
66
|
+
displayText?: StorageManagerDisplayText;
|
|
64
67
|
/**
|
|
65
68
|
* Determines if upload can be paused / resumed
|
|
66
69
|
*/
|
|
@@ -106,14 +109,17 @@ export interface StorageManagerProps {
|
|
|
106
109
|
*/
|
|
107
110
|
showThumbnails?: boolean;
|
|
108
111
|
/**
|
|
109
|
-
*
|
|
110
|
-
* @see https://docs.amplify.aws/lib/storage/custom-plugin/q/platform/js/
|
|
112
|
+
* Provided value is prefixed to the file `key` for each file
|
|
111
113
|
*/
|
|
112
|
-
|
|
114
|
+
path?: string;
|
|
115
|
+
}
|
|
116
|
+
export interface StorageManagerPathProps extends Omit<StorageManagerProps, 'accessLevel' | 'path'> {
|
|
113
117
|
/**
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
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
|
|
117
122
|
*/
|
|
118
|
-
path
|
|
123
|
+
path: string | PathCallback;
|
|
124
|
+
accessLevel?: never;
|
|
119
125
|
}
|
|
@@ -1,31 +1,21 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { StorageManagerDisplayText } from '../../utils/displayText';
|
|
1
|
+
import { StorageManagerDisplayTextDefault, TaskHandler } from '../../utils';
|
|
3
2
|
import { FileStatus, StorageFile } from '../../types';
|
|
4
3
|
export interface FileListProps {
|
|
5
|
-
displayText:
|
|
4
|
+
displayText: StorageManagerDisplayTextDefault;
|
|
6
5
|
files: StorageFile[];
|
|
7
6
|
isResumable: boolean;
|
|
8
|
-
onCancelUpload:
|
|
9
|
-
id: string;
|
|
10
|
-
uploadTask: UploadTask;
|
|
11
|
-
}) => void;
|
|
7
|
+
onCancelUpload: TaskHandler;
|
|
12
8
|
onDeleteUpload: (params: {
|
|
13
9
|
id: string;
|
|
14
10
|
}) => void;
|
|
15
|
-
onPause:
|
|
16
|
-
|
|
17
|
-
uploadTask: UploadTask;
|
|
18
|
-
}) => void;
|
|
19
|
-
onResume: (params: {
|
|
20
|
-
id: string;
|
|
21
|
-
uploadTask: UploadTask;
|
|
22
|
-
}) => void;
|
|
11
|
+
onPause: TaskHandler;
|
|
12
|
+
onResume: TaskHandler;
|
|
23
13
|
showThumbnails: boolean;
|
|
24
14
|
hasMaxFilesError: boolean;
|
|
25
15
|
maxFileCount: number;
|
|
26
16
|
}
|
|
27
17
|
export interface FileControlProps {
|
|
28
|
-
displayText:
|
|
18
|
+
displayText: StorageManagerDisplayTextDefault;
|
|
29
19
|
displayName: string;
|
|
30
20
|
errorMessage: string;
|
|
31
21
|
isImage: boolean;
|
|
@@ -41,7 +31,7 @@ export interface FileControlProps {
|
|
|
41
31
|
status: FileStatus;
|
|
42
32
|
thumbnailUrl: string;
|
|
43
33
|
}
|
|
44
|
-
export interface FileStatusMessageProps extends Pick<
|
|
34
|
+
export interface FileStatusMessageProps extends Pick<StorageManagerDisplayTextDefault, 'getUploadingText' | 'getPausedText' | 'uploadSuccessfulText'> {
|
|
45
35
|
status: FileStatus;
|
|
46
36
|
errorMessage: string;
|
|
47
37
|
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;
|
|
@@ -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>;
|
|
@@ -1,5 +1,6 @@
|
|
|
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
|
-
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,19 +1,32 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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;
|
|
10
26
|
}) => void;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
27
|
+
onStart?: (event: {
|
|
28
|
+
key: string;
|
|
29
|
+
uploadTask: UploadTask;
|
|
14
30
|
}) => void;
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
type UploadFile = Promise<void> | UploadTask;
|
|
18
|
-
export declare function uploadFile({ file, key, level, progressCallback, errorCallback, completeCallback, isResumable, provider, ...rest }: UploadFileProps): UploadFile;
|
|
19
|
-
export {};
|
|
31
|
+
}
|
|
32
|
+
export declare function uploadFile({ input, onError, onStart, onComplete, }: UploadFileProps): Promise<UploadDataWithPathOutput | UploadDataOutput>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const VERSION = "3.1.3";
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-amplify/ui-react-storage",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-theming-v2-f8422a3-20240627193426",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
|
-
"module": "dist/esm/index.
|
|
5
|
+
"module": "dist/esm/index.mjs",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
8
8
|
"types": "./dist/types/index.d.ts",
|
|
9
|
-
"import": "./dist/esm/index.
|
|
9
|
+
"import": "./dist/esm/index.mjs",
|
|
10
10
|
"require": "./dist/index.js"
|
|
11
11
|
},
|
|
12
12
|
"./styles.css": "./dist/styles.css"
|
|
@@ -28,58 +28,27 @@
|
|
|
28
28
|
"scripts": {
|
|
29
29
|
"build": "yarn build:rollup",
|
|
30
30
|
"build:rollup": "rollup --config",
|
|
31
|
+
"check:esm": "node --input-type=module --eval 'import \"@aws-amplify/ui-react-storage\"'",
|
|
31
32
|
"clean": "rimraf dist node_modules",
|
|
32
33
|
"dev": "yarn build:rollup --watch",
|
|
33
34
|
"lint": "yarn typecheck && eslint src --ext .js,.ts,.tsx",
|
|
34
35
|
"prebuild": "rimraf dist",
|
|
35
36
|
"size": "yarn size-limit",
|
|
36
37
|
"test": "jest",
|
|
37
|
-
"test:ci": "yarn test",
|
|
38
38
|
"test:watch": "yarn test --watch",
|
|
39
39
|
"typecheck": "tsc --noEmit"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@aws-amplify/ui": "0.0.0-
|
|
43
|
-
"@aws-amplify/ui-react": "0.0.0-
|
|
44
|
-
"@aws-amplify/ui-react-core": "0.0.0-
|
|
45
|
-
"classnames": "2.3.1",
|
|
42
|
+
"@aws-amplify/ui": "0.0.0-theming-v2-f8422a3-20240627193426",
|
|
43
|
+
"@aws-amplify/ui-react": "0.0.0-theming-v2-f8422a3-20240627193426",
|
|
44
|
+
"@aws-amplify/ui-react-core": "0.0.0-theming-v2-f8422a3-20240627193426",
|
|
46
45
|
"lodash": "4.17.21",
|
|
47
|
-
"tslib": "2.
|
|
46
|
+
"tslib": "^2.5.2"
|
|
48
47
|
},
|
|
49
48
|
"peerDependencies": {
|
|
50
|
-
"aws-amplify": "^
|
|
51
|
-
"react": "
|
|
52
|
-
"react-dom": "
|
|
53
|
-
},
|
|
54
|
-
"peerDependenciesMeta": {
|
|
55
|
-
"aws-amplify": {
|
|
56
|
-
"optional": true
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
|
-
"devDependencies": {
|
|
60
|
-
"@aws-amplify/eslint-config-amplify-ui": "0.0.0",
|
|
61
|
-
"@rollup/plugin-commonjs": "^22.0.1",
|
|
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.3.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"
|
|
@@ -87,9 +56,9 @@
|
|
|
87
56
|
"size-limit": [
|
|
88
57
|
{
|
|
89
58
|
"name": "StorageManager",
|
|
90
|
-
"path": "dist/esm/index.
|
|
59
|
+
"path": "dist/esm/index.mjs",
|
|
91
60
|
"import": "{ StorageManager }",
|
|
92
|
-
"limit": "
|
|
61
|
+
"limit": "25.5 kB"
|
|
93
62
|
}
|
|
94
63
|
]
|
|
95
64
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{__rest as e}from"tslib";import*as r from"react";import a from"classnames";import{Image as t,ComponentClassNames as o}from"@aws-amplify/ui-react";import{useStorageURL as s}from"@aws-amplify/ui-react/internal";const c=c=>{var{accessLevel:i,className:m,fallbackSrc:l,identityId:n,imgKey:f,onStorageGetError:p}=c,g=e(c,["accessLevel","className","fallbackSrc","identityId","imgKey","onStorageGetError"]);const y=r.useMemo((()=>({level:i,identityId:n})),[i,n]),d=s({key:f,options:y,fallbackURL:l,onStorageGetError:p});return r.createElement(t,Object.assign({},g,{className:a(o.StorageImage,m),src:d}))};export{c as StorageImage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{__rest as e}from"tslib";import*as i from"react";import{Logger as t}from"aws-amplify";import{ComponentClassNames as l,VisuallyHidden as o}from"@aws-amplify/ui-react";import{useDropZone as s}from"@aws-amplify/ui-react/internal";import{useStorageManager as r}from"./hooks/useStorageManager/useStorageManager.js";import{useUploadFiles as a}from"./hooks/useUploadFiles/useUploadFiles.js";import{FileStatus as n}from"./types.js";import{Container as p}from"./ui/Container/Container.js";import{DropZone as c}from"./ui/DropZone/DropZone.js";import{FileList as u}from"./ui/FileList/FileList.js";import{FileListHeader as m}from"./ui/FileListHeader/FileListHeader.js";import{FileListFooter as d}from"./ui/FileListFooter/FileListFooter.js";import{FilePicker as F}from"./ui/FilePicker/FilePicker.js";import{checkMaxFileSize as f}from"./utils/checkMaxFileSize.js";import{defaultStorageManagerDisplayText as g}from"./utils/displayText.js";import{filterAllowedFiles as U}from"./utils/filterAllowedFiles.js";const E=new t("Storage.StorageManager");const j=Object.assign(i.forwardRef((function({acceptedFileTypes:t=[],accessLevel:j,autoUpload:D=!0,defaultFiles:L,displayText:S,isResumable:h=!1,maxFileCount:x,maxFileSize:y,onUploadError:C,onUploadSuccess:T,onFileRemove:k,onUploadStart:v,showThumbnails:b=!0,processFile:w,components:P,provider:M,path:R},A){j&&x||E.warn("FileUploader requires accessLevel and maxFileCount props");const O=Object.assign({Container:p,DropZone:c,FileList:u,FilePicker:F,FileListHeader:m,FileListFooter:d},P),H=void 0===x||"number"==typeof x&&x>1,Z=Object.assign(Object.assign({},g),S),{getFileSizeErrorText:z}=Z,q=e=>f({file:e,maxFileSize:y,getFileSizeErrorText:z}),{addFiles:I,clearFiles:Q,files:$,removeUpload:N,queueFiles:B,setUploadingFile:G,setUploadPaused:J,setUploadProgress:K,setUploadSuccess:V,setUploadResumed:W}=r(L);i.useImperativeHandle(A,(()=>({clearFiles:Q})));const X=s({acceptedFileTypes:t,onDropComplete:({acceptedFiles:e,rejectedFiles:i})=>{i&&i.length>0&&E.warn("Rejected files: ",i);const l=U(e,t);I({files:l,status:D?n.QUEUED:n.ADDED,getFileErrorMessage:q})}}),{dragState:Y}=X,_=e(X,["dragState"]);a({accessLevel:j,files:$,isResumable:h,maxFileCount:x,onUploadError:C,onUploadSuccess:T,onUploadStart:v,setUploadingFile:G,setUploadProgress:K,setUploadSuccess:V,processFile:w,provider:M,path:R});const ee=0!==$.length&&$.every((e=>(null==e?void 0:e.status)===n.UPLOADED)),ie=$.filter((e=>e.progress<100)).length>x,te=$.filter((e=>(null==e?void 0:e.status)===n.UPLOADED)).length,le=$.length-te,oe=D?0:le,se=$.length>0,re=!D&&le>0,ae=i.useRef(null);return i.createElement(O.Container,{className:`${l.StorageManager} ${se?l.StorageManagerPreviewer:""}`},i.createElement(O.DropZone,Object.assign({inDropZone:"inactive"!==Y},_,{displayText:Z}),i.createElement(i.Fragment,null,i.createElement(O.FilePicker,{onClick:function(){ae.current&&(ae.current.click(),ae.current.value="")}},Z.browseFilesText),i.createElement(o,null,i.createElement("input",{type:"file",tabIndex:-1,ref:ae,onChange:e=>{const{files:i}=e.target;i&&0!==i.length&&I({files:Array.from(i),status:D?n.QUEUED:n.ADDED,getFileErrorMessage:q})},multiple:H,accept:t.join(",")})))),se?i.createElement(O.FileListHeader,{allUploadsSuccessful:ee,displayText:Z,fileCount:$.length,remainingFilesCount:le,selectedFilesCount:oe}):null,i.createElement(O.FileList,{displayText:Z,files:$,isResumable:h,onCancelUpload:({id:e,uploadTask:i})=>{i.pause(),N({id:e})},onDeleteUpload:({id:e})=>{if(N({id:e}),"function"==typeof k){const i=$.find((i=>i.id===e));i&&k({key:i.key})}},onResume:({id:e,uploadTask:i})=>{i.resume(),W({id:e})},onPause:({id:e,uploadTask:i})=>{i.pause(),J({id:e})},showThumbnails:b,hasMaxFilesError:ie,maxFileCount:x}),re?i.createElement(O.FileListFooter,{displayText:Z,remainingFilesCount:le,onClearAll:()=>{Q()},onUploadAll:()=>{B()}}):null)})),{Container:p,DropZone:c,FileList:u,FileListHeader:m,FileListFooter:d,FilePicker:F});export{j as StorageManager};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{StorageManagerActionTypes as s}from"./types.js";const e=({files:e,status:t,getFileErrorMessage:p})=>({type:s.ADD_FILES,files:e,status:t,getFileErrorMessage:p}),t=()=>({type:s.CLEAR_FILES}),p=()=>({type:s.QUEUE_FILES}),E=({id:e,uploadTask:t})=>({type:s.SET_STATUS_UPLOADING,id:e,uploadTask:t}),i=({id:e,progress:t})=>({type:s.SET_UPLOAD_PROGRESS,id:e,progress:t}),r=({id:e,status:t})=>({type:s.SET_STATUS,id:e,status:t}),S=({id:e})=>({type:s.REMOVE_UPLOAD,id:e});export{e as addFilesAction,t as clearFilesAction,p as queueFilesAction,S as removeUploadAction,i as setUploadProgressAction,r as setUploadStatusAction,E as setUploadingFileAction};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{FileStatus as s}from"../../types.js";import{StorageManagerActionTypes as e}from"./types.js";function t(t,i){switch(i.type){case e.ADD_FILES:{const{files:e,status:a}=i,c=e.map((e=>{const t=i.getFileErrorMessage(e);return{id:e.name,file:e,error:t,key:e.name,status:t?s.ERROR:a,isImage:e.type.startsWith("image/"),progress:-1}})),n=[...t.files,...c];return Object.assign(Object.assign({},t),{files:n})}case e.CLEAR_FILES:return Object.assign(Object.assign({},t),{files:[]});case e.QUEUE_FILES:{const{files:e}=t,i=e.reduce(((e,t)=>[...e,Object.assign(Object.assign({},t),{status:s.QUEUED})]),[]);return Object.assign(Object.assign({},t),{files:i})}case e.SET_STATUS_UPLOADING:{const{id:e,uploadTask:a}=i,{files:c}=t,n=c.reduce(((t,i)=>i.id===e?[...t,Object.assign(Object.assign({},i),{status:s.UPLOADING,progress:0,uploadTask:a||void 0})]:[...t,i]),[]);return Object.assign(Object.assign({},t),{files:n})}case e.SET_UPLOAD_PROGRESS:{const{id:s,progress:e}=i,{files:a}=t,c=a.reduce(((t,i)=>i.id===s?[...t,Object.assign(Object.assign({},i),{progress:e})]:[...t,i]),[]);return Object.assign(Object.assign({},t),{files:c})}case e.SET_STATUS:{const{id:s,status:e}=i,{files:a}=t,c=a.reduce(((t,i)=>i.id===s?[...t,Object.assign(Object.assign({},i),{status:e})]:[...t,i]),[]);return Object.assign(Object.assign({},t),{files:c})}case e.REMOVE_UPLOAD:{const{id:s}=i,{files:e}=t,a=e.reduce(((e,t)=>t.id===s?[...e]:[...e,t]),[]);return Object.assign(Object.assign({},t),{files:a})}}}export{t as storageManagerStateReducer};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var E;!function(E){E.ADD_FILES="ADD_FILES",E.CLEAR_FILES="CLEAR_FILES",E.QUEUE_FILES="QUEUE_FILES",E.SET_STATUS="SET_STATUS",E.SET_STATUS_UPLOADING="SET_STATUS_UPLOADING",E.SET_UPLOAD_PROGRESS="SET_UPLOAD_PROGRESS",E.REMOVE_UPLOAD="REMOVE_UPLOAD"}(E||(E={}));export{E as StorageManagerActionTypes};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import s from"react";import{FileStatus as e}from"../../types.js";import{storageManagerStateReducer as i}from"./reducer.js";import{addFilesAction as r,clearFilesAction as t,queueFilesAction as a,setUploadingFileAction as o,setUploadProgressAction as d,setUploadStatusAction as l,removeUploadAction as p}from"./actions.js";import{isObject as u}from"@aws-amplify/ui";const m=s=>(s=>!(!u(s)||!s.key))(s)?Object.assign(Object.assign({},s),{id:s.key,status:e.UPLOADED}):void 0;function f(u=[]){const[{files:f},c]=s.useReducer(i,{files:Array.isArray(u)?u.map(m).filter((s=>!!s)):[]});return{removeUpload:({id:s})=>{c(p({id:s}))},setUploadPaused:({id:s})=>{c(l({id:s,status:e.PAUSED}))},setUploadProgress:({progress:s,id:e})=>{c(d({id:e,progress:s}))},setUploadResumed:({id:s})=>{c(l({id:s,status:e.UPLOADING}))},setUploadSuccess:({id:s})=>{c(l({id:s,status:e.UPLOADED}))},setUploadingFile:({uploadTask:s,id:e})=>{c(o({id:e,uploadTask:s}))},queueFiles:()=>{c(a())},addFiles:({files:s,status:e,getFileErrorMessage:i})=>{c(r({files:s,status:e,getFileErrorMessage:i}))},clearFiles:()=>{c(t())},files:f}}export{f as useStorageManager};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{isFunction as e}from"@aws-amplify/ui";const i=({processFile:i,file:o,key:s})=>new Promise(((t,c)=>{const f=e(i)?i({file:o,key:s}):{file:o,key:s};f instanceof Promise?f.then(t).catch(c):t(f)}));export{i as resolveFile};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{__rest as e}from"tslib";import*as o from"react";import{uploadFile as s}from"../../utils/uploadFile.js";import{FileStatus as l}from"../../types.js";import{resolveFile as t}from"./resolveFile.js";function r({files:r,accessLevel:a,isResumable:i,setUploadProgress:p,setUploadingFile:c,setUploadSuccess:n,onUploadError:d,onUploadSuccess:f,onUploadStart:m,maxFileCount:u,processFile:k,provider:b,path:y=""}){o.useEffect((()=>{const o=r.filter((e=>e.status===l.QUEUED));if(!(o.length>u))for(const{file:l,key:r,id:u}of o){const o=e=>{null==f||f(e),n({id:u})},U=e=>{const o=0===e.total?100:Math.floor(e.loaded/e.total*100);p({id:u,progress:o})},g=e=>{null==d||d(e,{key:r})};l&&t({processFile:k,file:l,key:r}).then((l=>{var{key:t}=l,r=e(l,["key"]);null==m||m({key:t});const p=s(Object.assign(Object.assign({},r),{isResumable:i,provider:b,key:y+t,level:a,completeCallback:o,progressCallback:U,errorCallback:g}));c({id:u,uploadTask:i?p:void 0})}))}}),[r,a,i,p,c,d,f,m,u,n,k,b,y])}export{r as useUploadFiles};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var d;!function(d){d.ADDED="added",d.QUEUED="queued",d.UPLOADING="uploading",d.PAUSED="paused",d.ERROR="error",d.UPLOADED="uploaded"}(d||(d={}));export{d as FileStatus};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import e from"react";import{View as r}from"@aws-amplify/ui-react";function a({children:a,className:t}){return e.createElement(r,{className:t},a)}export{a as Container};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import a from"react";import e from"classnames";import{View as r,ComponentClassNames as o,Text as n}from"@aws-amplify/ui-react";import{classNameModifier as t}from"@aws-amplify/ui";import{useIcons as i,IconUpload as l}from"@aws-amplify/ui-react/internal";function m({children:m,displayText:p,inDropZone:s,onDragEnter:g,onDragLeave:c,onDragOver:D,onDragStart:d,onDrop:f,testId:u}){var v;const{dropFilesText:E}=p,S=i("storageManager");return a.createElement(r,{className:e(s&&t(o.StorageManagerDropZone,"active"),o.StorageManagerDropZone),"data-testid":u,onDragStart:d,onDragEnter:g,onDragLeave:c,onDrop:f,onDragOver:D},a.createElement(r,{as:"span","aria-hidden":!0,className:o.StorageManagerDropZoneIcon},null!==(v=null==S?void 0:S.upload)&&void 0!==v?v:a.createElement(l,null)),a.createElement(n,{className:o.StorageManagerDropZoneText},E),m)}export{m as DropZone};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import e from"react";import{View as a,ComponentClassNames as t,Loader as r,Button as l}from"@aws-amplify/ui-react";import{FileStatus as s}from"../../types.js";import{FileStatusMessage as i}from"./FileStatusMessage.js";import{FileRemoveButton as m}from"./FileRemoveButton.js";import{UploadDetails as n}from"./FileDetails.js";import{FileThumbnail as o}from"./FileThumbnail.js";function u({onPause:u,onResume:c,displayName:p,errorMessage:g,isImage:f,isResumable:d,loaderIsDeterminate:T,onRemove:x,progress:E,showThumbnails:S=!0,size:N,status:P,displayText:D,thumbnailUrl:U}){const{getPausedText:v,getUploadingText:F,uploadSuccessfulText:M,pauseText:j,resumeText:k}=D;return e.createElement(a,{className:t.StorageManagerFile},e.createElement(a,{className:t.StorageManagerFileWrapper},S?e.createElement(o,{isImage:f,fileName:p,url:U}):null,e.createElement(n,{displayName:p,fileSize:N}),P===s.UPLOADING?e.createElement(r,{className:t.StorageManagerLoader,variation:"linear",percentage:E,isDeterminate:T,isPercentageTextHidden:!0}):null,!d||P!==s.UPLOADING&&P!==s.PAUSED?null:P===s.PAUSED?e.createElement(l,{onClick:c,size:"small",variation:"link"},k):e.createElement(l,{onClick:u,size:"small",variation:"link"},j),e.createElement(m,{altText:`Remove file ${p}`,onClick:x})),e.createElement(i,{uploadSuccessfulText:M,getUploadingText:F,getPausedText:v,status:P,errorMessage:g,percentage:E}))}export{u as FileControl};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import e from"react";import{View as a,ComponentClassNames as r,Text as t}from"@aws-amplify/ui-react";import{humanFileSize as m}from"@aws-amplify/ui";const l=({displayName:l,fileSize:i})=>e.createElement(e.Fragment,null,e.createElement(a,{className:r.StorageManagerFileMain},e.createElement(t,{className:r.StorageManagerFileName},l)),e.createElement(t,{as:"span",className:r.StorageManagerFileSize},i?m(i,!0):""));export{l as UploadDetails};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import e from"react";import{View as a,ComponentClassNames as s,Alert as r}from"@aws-amplify/ui-react";import{FileStatus as o}from"../../types.js";import{FileControl as i}from"./FileControl.js";function t({displayText:t,files:l,hasMaxFilesError:n,isResumable:m,onCancelUpload:u,onDeleteUpload:p,onResume:d,onPause:c,showThumbnails:g,maxFileCount:f}){if(l.length<1)return null;const{getMaxFilesErrorText:T}=t,U=T(f);return e.createElement(a,{className:s.StorageManagerFileList},l.map((a=>{const{file:s,status:r,progress:l,error:n,key:f,isImage:T,id:U,uploadTask:h}=a,x=s&&T?URL.createObjectURL(s):"",y=!m||l>0,R=r===o.UPLOADING;return e.createElement(i,{displayName:f,errorMessage:n,displayText:t,isImage:T,isUploading:R,isResumable:m,key:U,loaderIsDeterminate:y,onRemove:()=>{m&&(r===o.UPLOADING||r===o.PAUSED)&&h?u({id:U,uploadTask:h}):p({id:U})},onPause:()=>{h&&c({id:U,uploadTask:h})},onResume:()=>{h&&d({id:U,uploadTask:h})},progress:l,showThumbnails:g,size:null==s?void 0:s.size,status:r,thumbnailUrl:x})})),n&&e.createElement(r,{variation:"error",heading:U}))}export{t as FileList};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import e from"react";import{useIcons as t,IconClose as a}from"@aws-amplify/ui-react/internal";import{Button as r,VisuallyHidden as l,View as n}from"@aws-amplify/ui-react";const i=({altText:i,onClick:m})=>{var o;const c=t("storageManager");return e.createElement(r,{size:"small",onClick:m},e.createElement(l,null,i),e.createElement(n,{as:"span","aria-hidden":!0,fontSize:"medium"},null!==(o=null==c?void 0:c.remove)&&void 0!==o?o:e.createElement(a,null)))};export{i as FileRemoveButton};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import e from"react";import a from"classnames";import{Text as t,ComponentClassNames as r,View as s}from"@aws-amplify/ui-react";import{useIcons as l,IconError as n,IconCheck as o}from"@aws-amplify/ui-react/internal";import{classNameModifier as c}from"@aws-amplify/ui";import{FileStatus as u}from"../../types.js";const m=({errorMessage:m,getPausedText:i,getUploadingText:g,percentage:p,status:S,uploadSuccessfulText:f})=>{var E,d;const M=l("storageManager");switch(S){case u.UPLOADING:return e.createElement(t,{className:r.StorageManagerFileStatus},g(p));case u.PAUSED:return e.createElement(t,{className:r.StorageManagerFileStatus},i(p));case u.UPLOADED:return e.createElement(t,{className:a(r.StorageManagerFileStatus,c(r.StorageManagerFileStatus,"success"))},e.createElement(s,{as:"span",fontSize:"xl"},null!==(E=null==M?void 0:M.success)&&void 0!==E?E:e.createElement(o,null)),f);case u.ERROR:return e.createElement(t,{className:a(r.StorageManagerFileStatus,c(r.StorageManagerFileStatus,"error"))},e.createElement(s,{as:"span",fontSize:"xl"},null!==(d=null==M?void 0:M.error)&&void 0!==d?d:e.createElement(n,null)),m);default:return null}};export{m as FileStatusMessage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import e from"react";import{Image as a,View as r,ComponentClassNames as t}from"@aws-amplify/ui-react";import{useIcons as l,IconFile as m}from"@aws-amplify/ui-react/internal";const i=({fileName:i,isImage:n,url:o})=>{var c;const s=l("storageManager"),f=n?e.createElement(a,{alt:i,src:o}):null!==(c=null==s?void 0:s.file)&&void 0!==c?c:e.createElement(m,null);return e.createElement(r,{className:t.StorageManagerFileImage},f)};export{i as FileThumbnail};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import e from"react";import{View as a,ComponentClassNames as t,Button as r}from"@aws-amplify/ui-react";function l({displayText:l,remainingFilesCount:n,onClearAll:o,onUploadAll:i}){const{clearAllButtonText:m,getUploadButtonText:c}=l;return e.createElement(a,{className:t.StorageManagerPreviewerFooter},e.createElement(a,{className:t.StorageManagerPreviewerActions},e.createElement(r,{size:"small",variation:"link",onClick:o},m),e.createElement(r,{size:"small",variation:"primary",onClick:i},c(n))))}export{l as FileListFooter};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import e from"react";import{Text as t,ComponentClassNames as i}from"@aws-amplify/ui-react";function l({allUploadsSuccessful:l,displayText:a,fileCount:r,remainingFilesCount:s,selectedFilesCount:n=0}){const{getFilesUploadedText:o,getRemainingFilesText:c,getSelectedFilesText:m}=a;return e.createElement(t,{className:i.StorageManagerPreviewerText},n?m(n):l?o(r):c(s))}export{l as FileListHeader};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{__rest as e}from"tslib";import r from"react";import{ComponentClassNames as a,Button as i}from"@aws-amplify/ui-react";function s(s){var{children:t,className:m=a.StorageManagerFilePicker,size:c="small"}=s,l=e(s,["children","className","size"]);return r.createElement(i,Object.assign({},l,{className:m,size:c}),t)}export{s as FilePicker};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{humanFileSize as e}from"./humanFileSize.js";const i=({file:i,getFileSizeErrorText:o,maxFileSize:r})=>void 0===r?"":i.size>r?o(e(r,!0)):"";export{i as checkMaxFileSize};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e={getFilesUploadedText:e=>`${e} ${1===e?"file uploaded":"files uploaded"}`,getFileSizeErrorText:e=>`File size must be below ${e}`,getRemainingFilesText:e=>`${e} ${1===e?"file":"files"} uploading`,getSelectedFilesText:e=>`${e} ${1===e?"file":"files"} selected`,getUploadingText:e=>"Uploading"+(e>0?`: ${e}%`:""),getUploadButtonText:e=>`Upload ${e} ${1===e?"file":"files"}`,getMaxFilesErrorText:e=>`Cannot choose more than ${e} ${1===e?"file":"files"}. Remove files before updating`,getErrorText:e=>e,doneButtonText:"Done",clearAllButtonText:"Clear all",extensionNotAllowedText:"Extension not allowed",browseFilesText:"Browse files",dropFilesText:"Drop files here or",pauseText:"Pause",resumeText:"Resume",uploadSuccessfulText:"Uploaded",getPausedText:e=>`Paused: ${e}%`};export{e as defaultStorageManagerDisplayText};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e=(e,t)=>!t||0===t.length||t.includes("*")?e:e.filter((e=>{const r=e.name||"",o=(e.type||"").toLowerCase(),n=o.replace(/\/.*$/,"");return t.some((e=>{const t=e.trim().toLowerCase();return"."===t.charAt(0)?r.toLowerCase().endsWith(t):t.endsWith("/*")?n===t.replace(/\/.*$/,""):o===t}))}));export{e as filterAllowedFiles};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function B(B,t=!1,i=1){const n=t?1e3:1024;if(Math.abs(B)<n)return`${B} B`;const o=t?["kB","MB","GB","TB","PB","EB","ZB","YB"]:["KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"];let e=-1;const a=Math.pow(10,i);do{B/=n,++e}while(Math.round(Math.abs(B)*a)/a>=n&&e<o.length-1);return B.toFixed(i)+" "+o[e]}export{B as humanFileSize};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{__rest as e}from"tslib";import{Storage as l}from"aws-amplify";function r(r){var{file:a,key:o,level:t="private",progressCallback:s,errorCallback:p,completeCallback:c,isResumable:b=!1,provider:i}=r,m=e(r,["file","key","level","progressCallback","errorCallback","completeCallback","isResumable","provider"]);const k=a.type||"binary/octet-stream";return!0===b?l.put(o,a,Object.assign({level:t,resumable:!0,progressCallback:s,errorCallback:p,completeCallback:c,contentType:k,provider:i},m)):l.put(o,a,Object.assign({level:t,resumable:!1,progressCallback:s,contentType:k,provider:i},m)).then(c,p)}export{r as uploadFile};
|
package/dist/esm/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{StorageImage}from"./components/StorageImage/StorageImage.js";export{StorageManager}from"./components/StorageManager/StorageManager.js";
|