@aws-amplify/ui-react-storage 3.12.2 → 3.13.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/browser.js +1 -1
- package/dist/{createStorageBrowser-pzJe4BD8.js → createStorageBrowser-BazPNsU_.js} +1884 -1068
- package/dist/esm/browser.mjs +6 -2
- package/dist/esm/components/StorageBrowser/ErrorBoundary/ErrorBoundary.mjs +9 -0
- package/dist/esm/components/StorageBrowser/components/ComponentsProvider.mjs +9 -0
- package/dist/esm/components/StorageBrowser/components/base/Table.mjs +1 -1
- package/dist/esm/components/StorageBrowser/components/base/preview/DownloadButton.mjs +39 -0
- package/dist/esm/components/StorageBrowser/components/base/preview/FileMetadata.mjs +40 -0
- package/dist/esm/components/StorageBrowser/components/base/preview/FilePreviewLayout.mjs +19 -0
- package/dist/esm/components/StorageBrowser/components/base/preview/ImagePreview.mjs +37 -0
- package/dist/esm/components/StorageBrowser/components/base/preview/PreviewFallback.mjs +34 -0
- package/dist/esm/components/StorageBrowser/components/base/preview/PreviewPlaceholder.mjs +13 -0
- package/dist/esm/components/StorageBrowser/components/base/preview/TextPreview.mjs +64 -0
- package/dist/esm/components/StorageBrowser/components/base/preview/VideoPreview.mjs +61 -0
- package/dist/esm/components/StorageBrowser/components/composables/DataTable/DataTable.mjs +2 -1
- package/dist/esm/components/StorageBrowser/components/composables/FilePreview.mjs +85 -0
- package/dist/esm/components/StorageBrowser/components/composables/defaults.mjs +2 -0
- package/dist/esm/components/StorageBrowser/components/elements/definitions.mjs +2 -2
- package/dist/esm/components/StorageBrowser/controls/DataTableControl.mjs +9 -0
- package/dist/esm/components/StorageBrowser/controls/FilePreviewControl.mjs +24 -0
- package/dist/esm/components/StorageBrowser/createStorageBrowser/StorageBrowserDefault.mjs +1 -0
- package/dist/esm/components/StorageBrowser/createStorageBrowser/createProvider.mjs +4 -2
- package/dist/esm/components/StorageBrowser/createStorageBrowser/createStorageBrowser.mjs +1 -0
- package/dist/esm/components/StorageBrowser/displayText/context.mjs +4 -0
- package/dist/esm/components/StorageBrowser/displayText/libraries/en/locationDetailView.mjs +28 -0
- package/dist/esm/components/StorageBrowser/filePreview/context.mjs +12 -0
- package/dist/esm/components/StorageBrowser/views/LocationActionView/CopyView/CopyView.mjs +9 -0
- package/dist/esm/components/StorageBrowser/views/LocationActionView/CopyView/CopyViewProvider.mjs +8 -0
- package/dist/esm/components/StorageBrowser/views/LocationActionView/CopyView/FoldersMessageControl.mjs +8 -0
- package/dist/esm/components/StorageBrowser/views/LocationActionView/CreateFolderView/CreateFolderView.mjs +9 -0
- package/dist/esm/components/StorageBrowser/views/LocationActionView/DeleteView/DeleteView.mjs +9 -0
- package/dist/esm/components/StorageBrowser/views/LocationActionView/DownloadView/DownloadView.mjs +9 -0
- package/dist/esm/components/StorageBrowser/views/LocationActionView/UploadView/UploadView.mjs +9 -0
- package/dist/esm/components/StorageBrowser/views/LocationDetailView/LocationDetailView.mjs +17 -4
- package/dist/esm/components/StorageBrowser/views/LocationDetailView/LocationDetailViewProvider.mjs +9 -2
- package/dist/esm/components/StorageBrowser/views/LocationDetailView/getLocationDetailViewTableData/constants.mjs +69 -1
- package/dist/esm/components/StorageBrowser/views/LocationDetailView/getLocationDetailViewTableData/fileIcon.mjs +11 -0
- package/dist/esm/components/StorageBrowser/views/LocationDetailView/getLocationDetailViewTableData/getFileRowContent.mjs +8 -5
- package/dist/esm/components/StorageBrowser/views/LocationDetailView/getLocationDetailViewTableData/getLocationDetailViewTableData.mjs +8 -1
- package/dist/esm/components/StorageBrowser/views/LocationDetailView/useLocationDetailView.mjs +76 -3
- package/dist/esm/components/StorageBrowser/views/LocationsView/LocationsView.mjs +9 -0
- package/dist/esm/components/StorageBrowser/views/LocationsView/LocationsViewProvider.mjs +8 -0
- package/dist/esm/components/StorageBrowser/views/context/primaryViews.mjs +1 -0
- package/dist/esm/components/StorageBrowser/views/hooks/useFilePreview/useFilePreview.mjs +115 -0
- package/dist/esm/components/StorageBrowser/views/utils/files/const.mjs +62 -0
- package/dist/esm/components/StorageBrowser/views/utils/files/fileName.mjs +12 -0
- package/dist/esm/components/StorageBrowser/views/utils/files/fileSize.mjs +23 -0
- package/dist/esm/components/StorageBrowser/views/utils/files/fileType.mjs +87 -0
- package/dist/esm/components/StorageBrowser/views/utils/files/safeGetProperties.mjs +12 -0
- package/dist/esm/components/StorageBrowser/views/utils/files/url.mjs +16 -0
- package/dist/esm/version.mjs +1 -1
- package/dist/index.js +1 -1
- package/dist/styles.css +250 -0
- package/dist/types/components/StorageBrowser/actions/configs/defaults.d.ts +2 -2
- package/dist/types/components/StorageBrowser/actions/handlers/types.d.ts +4 -0
- package/dist/types/components/StorageBrowser/components/base/Table.d.ts +1 -0
- package/dist/types/components/StorageBrowser/components/base/preview/DownloadButton.d.ts +4 -0
- package/dist/types/components/StorageBrowser/components/base/preview/FileMetadata.d.ts +7 -0
- package/dist/types/components/StorageBrowser/components/base/preview/FilePreviewLayout.d.ts +8 -0
- package/dist/types/components/StorageBrowser/components/base/preview/ImagePreview.d.ts +3 -0
- package/dist/types/components/StorageBrowser/components/base/preview/PreviewFallback.d.ts +10 -0
- package/dist/types/components/StorageBrowser/components/base/preview/PreviewPlaceholder.d.ts +2 -0
- package/dist/types/components/StorageBrowser/components/base/preview/TextPreview.d.ts +3 -0
- package/dist/types/components/StorageBrowser/components/base/preview/VideoPreview.d.ts +3 -0
- package/dist/types/components/StorageBrowser/components/base/preview/type.d.ts +6 -0
- package/dist/types/components/StorageBrowser/components/composables/DataTable/DataTable.d.ts +1 -0
- package/dist/types/components/StorageBrowser/components/composables/FilePreview.d.ts +12 -0
- package/dist/types/components/StorageBrowser/components/composables/types.d.ts +2 -0
- package/dist/types/components/StorageBrowser/controls/FilePreviewControl.d.ts +2 -0
- package/dist/types/components/StorageBrowser/controls/types.d.ts +11 -2
- package/dist/types/components/StorageBrowser/createStorageBrowser/createProvider.d.ts +2 -1
- package/dist/types/components/StorageBrowser/createStorageBrowser/createStorageBrowser.d.ts +4 -1
- package/dist/types/components/StorageBrowser/createStorageBrowser/types.d.ts +78 -2
- package/dist/types/components/StorageBrowser/displayText/types.d.ts +30 -1
- package/dist/types/components/StorageBrowser/filePreview/context.d.ts +10 -0
- package/dist/types/components/StorageBrowser/filePreview/index.d.ts +1 -0
- package/dist/types/components/StorageBrowser/views/LocationDetailView/getLocationDetailViewTableData/constants.d.ts +6 -0
- package/dist/types/components/StorageBrowser/views/LocationDetailView/getLocationDetailViewTableData/fileIcon.d.ts +2 -0
- package/dist/types/components/StorageBrowser/views/LocationDetailView/getLocationDetailViewTableData/getFileRowContent.d.ts +3 -1
- package/dist/types/components/StorageBrowser/views/LocationDetailView/getLocationDetailViewTableData/getLocationDetailViewTableData.d.ts +5 -2
- package/dist/types/components/StorageBrowser/views/LocationDetailView/types.d.ts +10 -0
- package/dist/types/components/StorageBrowser/views/hooks/useFilePreview/index.d.ts +2 -0
- package/dist/types/components/StorageBrowser/views/hooks/useFilePreview/types.d.ts +28 -0
- package/dist/types/components/StorageBrowser/views/hooks/useFilePreview/useFilePreview.d.ts +5 -0
- package/dist/types/components/StorageBrowser/views/utils/files/const.d.ts +9 -0
- package/dist/types/components/StorageBrowser/views/utils/files/fileName.d.ts +6 -0
- package/dist/types/components/StorageBrowser/views/utils/files/fileSize.d.ts +2 -0
- package/dist/types/components/StorageBrowser/views/utils/files/fileType.d.ts +12 -0
- package/dist/types/components/StorageBrowser/views/utils/files/safeGetProperties.d.ts +2 -0
- package/dist/types/components/StorageBrowser/views/utils/files/url.d.ts +2 -0
- package/dist/types/version.d.ts +1 -1
- package/package.json +6 -6
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { useState, useCallback, useEffect, useMemo } from 'react';
|
|
2
|
+
import { determineFileType } from '../../utils/files/fileType.mjs';
|
|
3
|
+
import { useFilePreviewContext } from '../../../filePreview/context.mjs';
|
|
4
|
+
import { useGetActionInput } from '../../../configuration/context.mjs';
|
|
5
|
+
import { resolveUrlOptions } from '../../utils/files/url.mjs';
|
|
6
|
+
import { resolveMaxFileSize } from '../../utils/files/fileSize.mjs';
|
|
7
|
+
import { safeGetProperties } from '../../utils/files/safeGetProperties.mjs';
|
|
8
|
+
import { getUrl } from '@aws-amplify/storage/internals';
|
|
9
|
+
import { constructBucket } from '../../../actions/handlers/utils.mjs';
|
|
10
|
+
import '@aws-amplify/ui';
|
|
11
|
+
import 'aws-amplify/storage';
|
|
12
|
+
import { useStore } from '../../../store/context.mjs';
|
|
13
|
+
|
|
14
|
+
function useFilePreview({ activeFile, }) {
|
|
15
|
+
const filePreviewContext = useFilePreviewContext();
|
|
16
|
+
const [enabled, setEnabled] = useState(true);
|
|
17
|
+
const getConfig = useGetActionInput();
|
|
18
|
+
const [{ location }] = useStore();
|
|
19
|
+
const [filePreviewContent, setFilePreviewContent] = useState({ isLoading: true });
|
|
20
|
+
const { fileTypeResolver, urlOptions, maxFileSize } = (filePreviewContext ?? {}) || {};
|
|
21
|
+
const getFilePreview = useCallback(async () => {
|
|
22
|
+
if (!activeFile || !activeFile?.key || !location.current) {
|
|
23
|
+
setEnabled(false);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const config = getConfig(location.current);
|
|
27
|
+
const { accountId, customEndpoint, credentials } = config;
|
|
28
|
+
const sharedOptions = {
|
|
29
|
+
bucket: constructBucket(config),
|
|
30
|
+
expectedBucketOwner: accountId,
|
|
31
|
+
};
|
|
32
|
+
try {
|
|
33
|
+
setEnabled(true);
|
|
34
|
+
setFilePreviewContent({
|
|
35
|
+
isLoading: true,
|
|
36
|
+
});
|
|
37
|
+
const properties = await safeGetProperties({
|
|
38
|
+
path: activeFile.key,
|
|
39
|
+
options: sharedOptions,
|
|
40
|
+
});
|
|
41
|
+
const enrichedFile = {
|
|
42
|
+
...activeFile,
|
|
43
|
+
...properties,
|
|
44
|
+
};
|
|
45
|
+
const fileType = determineFileType({
|
|
46
|
+
fileData: enrichedFile,
|
|
47
|
+
fileTypeResolver,
|
|
48
|
+
});
|
|
49
|
+
const finalFile = {
|
|
50
|
+
...enrichedFile,
|
|
51
|
+
fileType,
|
|
52
|
+
};
|
|
53
|
+
const sizeLimit = resolveMaxFileSize(maxFileSize, fileType);
|
|
54
|
+
const isLimitExceeded = ((finalFile.size || activeFile?.size) ?? 0) > sizeLimit;
|
|
55
|
+
if (isLimitExceeded) {
|
|
56
|
+
setFilePreviewContent({
|
|
57
|
+
ok: false,
|
|
58
|
+
isLoading: false,
|
|
59
|
+
error: 'LIMIT_EXCEEDED',
|
|
60
|
+
});
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const { url } = await getUrl({
|
|
64
|
+
path: finalFile.key,
|
|
65
|
+
options: {
|
|
66
|
+
customEndpoint,
|
|
67
|
+
locationCredentialsProvider: credentials,
|
|
68
|
+
contentDisposition: 'attachment',
|
|
69
|
+
...sharedOptions,
|
|
70
|
+
...resolveUrlOptions(urlOptions, fileType),
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
setFilePreviewContent({
|
|
74
|
+
ok: true,
|
|
75
|
+
isLoading: false,
|
|
76
|
+
fileData: finalFile,
|
|
77
|
+
url: url.toString(),
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
setFilePreviewContent({
|
|
82
|
+
isLoading: false,
|
|
83
|
+
ok: false,
|
|
84
|
+
error: 'GENERIC_ERROR',
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}, [
|
|
88
|
+
location,
|
|
89
|
+
getConfig,
|
|
90
|
+
fileTypeResolver,
|
|
91
|
+
maxFileSize,
|
|
92
|
+
urlOptions,
|
|
93
|
+
activeFile,
|
|
94
|
+
]);
|
|
95
|
+
useEffect(() => {
|
|
96
|
+
getFilePreview();
|
|
97
|
+
}, [getFilePreview, activeFile]);
|
|
98
|
+
return useMemo(() => {
|
|
99
|
+
if (filePreviewContext === false || !enabled) {
|
|
100
|
+
return {
|
|
101
|
+
optout: filePreviewContext === false,
|
|
102
|
+
enabled: false,
|
|
103
|
+
handleRetry: () => undefined,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
return {
|
|
107
|
+
optout: false,
|
|
108
|
+
enabled: true,
|
|
109
|
+
handleRetry: () => getFilePreview(),
|
|
110
|
+
...filePreviewContent,
|
|
111
|
+
};
|
|
112
|
+
}, [getFilePreview, filePreviewContext, filePreviewContent, enabled]);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export { useFilePreview };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
const DEFAULT_URL_OPTIONS = {
|
|
2
|
+
expiresIn: 7200,
|
|
3
|
+
validateObjectExistence: true,
|
|
4
|
+
};
|
|
5
|
+
const DEFAULT_FILE_SIZE_LIMIT = 200 * 1024 * 1024; // 200MB
|
|
6
|
+
const DEFAULT_FILE_SIZE_LIMITS = {
|
|
7
|
+
image: 200 * 1024 * 1024,
|
|
8
|
+
video: 2 * 1024 * 1024 * 1024,
|
|
9
|
+
text: 10 * 1024 * 1024, // 10MB
|
|
10
|
+
};
|
|
11
|
+
const GENERIC_CONTENT_TYPES = new Set([
|
|
12
|
+
'application/octet-stream',
|
|
13
|
+
'binary/octet-stream',
|
|
14
|
+
'application/unknown',
|
|
15
|
+
'unknown/unknown',
|
|
16
|
+
'application/force-download',
|
|
17
|
+
'application/download',
|
|
18
|
+
'application/x-download',
|
|
19
|
+
'application/binary',
|
|
20
|
+
]);
|
|
21
|
+
const EXTENSION_MAPPINGS = {
|
|
22
|
+
// Images
|
|
23
|
+
jpg: 'image',
|
|
24
|
+
jpeg: 'image',
|
|
25
|
+
png: 'image',
|
|
26
|
+
gif: 'image',
|
|
27
|
+
webp: 'image',
|
|
28
|
+
svg: 'image',
|
|
29
|
+
bmp: 'image',
|
|
30
|
+
tiff: 'image',
|
|
31
|
+
tif: 'image',
|
|
32
|
+
ico: 'image',
|
|
33
|
+
heic: 'image',
|
|
34
|
+
heif: 'image',
|
|
35
|
+
avif: 'image',
|
|
36
|
+
// Videos
|
|
37
|
+
mp4: 'video',
|
|
38
|
+
avi: 'video',
|
|
39
|
+
mov: 'video',
|
|
40
|
+
wmv: 'video',
|
|
41
|
+
flv: 'video',
|
|
42
|
+
webm: 'video',
|
|
43
|
+
mkv: 'video',
|
|
44
|
+
m4v: 'video',
|
|
45
|
+
mpg: 'video',
|
|
46
|
+
mpeg: 'video',
|
|
47
|
+
'3gp': 'video',
|
|
48
|
+
ogv: 'video',
|
|
49
|
+
// Plain text files only
|
|
50
|
+
txt: 'text',
|
|
51
|
+
csv: 'text',
|
|
52
|
+
log: 'text',
|
|
53
|
+
json: 'text',
|
|
54
|
+
xml: 'text',
|
|
55
|
+
yaml: 'text',
|
|
56
|
+
yml: 'text',
|
|
57
|
+
ini: 'text',
|
|
58
|
+
conf: 'text',
|
|
59
|
+
cfg: 'text',
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export { DEFAULT_FILE_SIZE_LIMIT, DEFAULT_FILE_SIZE_LIMITS, DEFAULT_URL_OPTIONS, EXTENSION_MAPPINGS, GENERIC_CONTENT_TYPES };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extracts the filename from a file key path
|
|
3
|
+
* @param fileKey - The full file key/path
|
|
4
|
+
* @returns The filename (last part after '/') or empty string if fileKey is null/undefined
|
|
5
|
+
*/
|
|
6
|
+
function getFileName(fileKey) {
|
|
7
|
+
if (!fileKey)
|
|
8
|
+
return '';
|
|
9
|
+
return fileKey.split('/').pop() ?? fileKey;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { getFileName };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { DEFAULT_FILE_SIZE_LIMITS, DEFAULT_FILE_SIZE_LIMIT } from './const.mjs';
|
|
2
|
+
|
|
3
|
+
function resolveMaxFileSize(maxFileSize, fileType) {
|
|
4
|
+
if (typeof maxFileSize === 'number') {
|
|
5
|
+
return maxFileSize;
|
|
6
|
+
}
|
|
7
|
+
if (typeof maxFileSize === 'function' && fileType) {
|
|
8
|
+
try {
|
|
9
|
+
const result = maxFileSize(fileType);
|
|
10
|
+
if (typeof result === 'number') {
|
|
11
|
+
return result;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
//
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return fileType
|
|
19
|
+
? DEFAULT_FILE_SIZE_LIMITS[fileType] || DEFAULT_FILE_SIZE_LIMIT
|
|
20
|
+
: DEFAULT_FILE_SIZE_LIMIT;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { resolveMaxFileSize };
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { GENERIC_CONTENT_TYPES, EXTENSION_MAPPINGS } from './const.mjs';
|
|
2
|
+
|
|
3
|
+
function isGenericContentType(contentType) {
|
|
4
|
+
if (!contentType || typeof contentType !== 'string') {
|
|
5
|
+
return true;
|
|
6
|
+
}
|
|
7
|
+
const normalizedContentType = contentType.toLowerCase().trim();
|
|
8
|
+
return GENERIC_CONTENT_TYPES.has(normalizedContentType);
|
|
9
|
+
}
|
|
10
|
+
function isTextBasedApplicationType(contentType) {
|
|
11
|
+
if (contentType === 'application/json' ||
|
|
12
|
+
(contentType.startsWith('application/') && contentType.includes('+json'))) {
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
if (contentType === 'application/xml' ||
|
|
16
|
+
(contentType.startsWith('application/') && contentType.includes('+xml'))) {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
const textBasedTypes = [
|
|
20
|
+
'application/csv',
|
|
21
|
+
'application/yaml',
|
|
22
|
+
'application/toml',
|
|
23
|
+
];
|
|
24
|
+
return textBasedTypes.includes(contentType);
|
|
25
|
+
}
|
|
26
|
+
function getFileTypeFromContentType(contentType) {
|
|
27
|
+
if (!contentType || typeof contentType !== 'string') {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
const normalizedContentType = contentType.toLowerCase().trim().split(';')[0];
|
|
31
|
+
if (normalizedContentType.startsWith('image/')) {
|
|
32
|
+
return 'image';
|
|
33
|
+
}
|
|
34
|
+
if (normalizedContentType.startsWith('video/')) {
|
|
35
|
+
return 'video';
|
|
36
|
+
}
|
|
37
|
+
if (normalizedContentType.startsWith('text/') ||
|
|
38
|
+
isTextBasedApplicationType(normalizedContentType)) {
|
|
39
|
+
return 'text';
|
|
40
|
+
}
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
function getFileExtension(key) {
|
|
44
|
+
if (!key || typeof key !== 'string') {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
const lastDotIndex = key.lastIndexOf('.');
|
|
48
|
+
if (lastDotIndex === -1 || lastDotIndex === key.length - 1) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
return key.slice(lastDotIndex + 1).toLowerCase();
|
|
52
|
+
}
|
|
53
|
+
function getFileTypeFromExtension(extension) {
|
|
54
|
+
if (!extension || typeof extension !== 'string') {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
const normalizedExtension = extension.toLowerCase().trim();
|
|
58
|
+
return EXTENSION_MAPPINGS[normalizedExtension] || null;
|
|
59
|
+
}
|
|
60
|
+
function determineFileType(options) {
|
|
61
|
+
const { fileData, fileTypeResolver } = options;
|
|
62
|
+
const { contentType, key } = fileData ?? {};
|
|
63
|
+
if (typeof fileTypeResolver === 'function') {
|
|
64
|
+
try {
|
|
65
|
+
const customResult = fileTypeResolver(fileData);
|
|
66
|
+
if (customResult !== undefined && customResult !== null) {
|
|
67
|
+
return customResult;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
//
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (!isGenericContentType(contentType)) {
|
|
75
|
+
const typeFromContentType = getFileTypeFromContentType(contentType);
|
|
76
|
+
if (typeFromContentType) {
|
|
77
|
+
return typeFromContentType;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
const extension = getFileExtension(key);
|
|
81
|
+
if (extension) {
|
|
82
|
+
return getFileTypeFromExtension(extension);
|
|
83
|
+
}
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export { determineFileType, getFileExtension, getFileTypeFromContentType, getFileTypeFromExtension, isGenericContentType };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { DEFAULT_URL_OPTIONS } from './const.mjs';
|
|
2
|
+
|
|
3
|
+
function resolveUrlOptions(options, fileType) {
|
|
4
|
+
if (!options) {
|
|
5
|
+
return DEFAULT_URL_OPTIONS;
|
|
6
|
+
}
|
|
7
|
+
if (typeof options === 'function' && fileType) {
|
|
8
|
+
return options(fileType) ?? DEFAULT_URL_OPTIONS;
|
|
9
|
+
}
|
|
10
|
+
return {
|
|
11
|
+
...DEFAULT_URL_OPTIONS,
|
|
12
|
+
...options,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { resolveUrlOptions };
|
package/dist/esm/version.mjs
CHANGED
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ var uiReactCore = require('@aws-amplify/ui-react-core');
|
|
|
9
9
|
var auth = require('aws-amplify/auth');
|
|
10
10
|
var storage = require('aws-amplify/storage');
|
|
11
11
|
var internal = require('@aws-amplify/ui-react/internal');
|
|
12
|
-
var createStorageBrowser = require('./createStorageBrowser-
|
|
12
|
+
var createStorageBrowser = require('./createStorageBrowser-BazPNsU_.js');
|
|
13
13
|
require('@aws-amplify/storage/internals');
|
|
14
14
|
require('aws-amplify');
|
|
15
15
|
require('aws-amplify/utils');
|
package/dist/styles.css
CHANGED
|
@@ -5668,6 +5668,9 @@ html[dir=rtl] .amplify-field-group__inner-start {
|
|
|
5668
5668
|
.amplify-table--striped .amplify-table__row:not(.amplify-table__head *):nth-child(odd) {
|
|
5669
5669
|
background-color: var(--amplify-components-table-row-striped-background-color);
|
|
5670
5670
|
}
|
|
5671
|
+
.amplify-table--striped .amplify-table__row.amplify-storage-browser__table-row_active:nth-child(odd) {
|
|
5672
|
+
background-color: var(--amplify-colors-background-info);
|
|
5673
|
+
}
|
|
5671
5674
|
.amplify-table__caption {
|
|
5672
5675
|
caption-side: var(--amplify-components-table-caption-caption-side);
|
|
5673
5676
|
color: var(--amplify-components-table-caption-color);
|
|
@@ -6686,6 +6689,9 @@ html[dir=rtl] .amplify-field-group__inner-start {
|
|
|
6686
6689
|
box-shadow: var(--amplify-shadows-small);
|
|
6687
6690
|
z-index: 2;
|
|
6688
6691
|
}
|
|
6692
|
+
.amplify-storage-browser__table-row_active {
|
|
6693
|
+
background-color: var(--amplify-colors-background-info);
|
|
6694
|
+
}
|
|
6689
6695
|
.amplify-storage-browser__table-header {
|
|
6690
6696
|
border: none;
|
|
6691
6697
|
padding: var(--amplify-space-xxxs);
|
|
@@ -6768,7 +6774,251 @@ html[dir=rtl] .amplify-field-group__inner-start {
|
|
|
6768
6774
|
top: 0;
|
|
6769
6775
|
z-index: 3;
|
|
6770
6776
|
}
|
|
6777
|
+
.amplify-storage-browser__content-with-preview {
|
|
6778
|
+
display: flex;
|
|
6779
|
+
height: 100%;
|
|
6780
|
+
}
|
|
6781
|
+
.amplify-storage-browser__file-preview {
|
|
6782
|
+
overflow: auto;
|
|
6783
|
+
flex: 1;
|
|
6784
|
+
width: 50%;
|
|
6785
|
+
position: sticky;
|
|
6786
|
+
top: 10px;
|
|
6787
|
+
bottom: 10px;
|
|
6788
|
+
height: -moz-fit-content;
|
|
6789
|
+
height: fit-content;
|
|
6790
|
+
max-height: calc(100svh - 20px);
|
|
6791
|
+
padding: var(--amplify-space-medium);
|
|
6792
|
+
border: var(--amplify-border-widths-small) solid var(--amplify-colors-border-primary);
|
|
6793
|
+
border-radius: var(--amplify-radii-small);
|
|
6794
|
+
margin-inline-start: var(--amplify-space-large);
|
|
6795
|
+
padding-block-end: var(--amplify-space-large);
|
|
6796
|
+
}
|
|
6797
|
+
.amplify-storage-browser__file-preview-header {
|
|
6798
|
+
margin-block-end: var(--amplify-space-medium);
|
|
6799
|
+
display: flex;
|
|
6800
|
+
justify-content: flex-end;
|
|
6801
|
+
}
|
|
6802
|
+
.amplify-storage-browser__file-preview-container {
|
|
6803
|
+
display: flex;
|
|
6804
|
+
flex-direction: column;
|
|
6805
|
+
gap: var(--amplify-space-large);
|
|
6806
|
+
}
|
|
6807
|
+
.amplify-storage-browser__file-preview-content {
|
|
6808
|
+
display: flex;
|
|
6809
|
+
flex-direction: column;
|
|
6810
|
+
gap: var(--amplify-space-large);
|
|
6811
|
+
align-items: center;
|
|
6812
|
+
}
|
|
6813
|
+
.amplify-storage-browser__file-preview-section {
|
|
6814
|
+
display: flex;
|
|
6815
|
+
flex-direction: column;
|
|
6816
|
+
min-height: 400px;
|
|
6817
|
+
flex: 1;
|
|
6818
|
+
}
|
|
6819
|
+
.amplify-storage-browser__file-preview-title {
|
|
6820
|
+
margin-block-end: var(--amplify-space-medium);
|
|
6821
|
+
color: var(--amplify-colors-font-primary);
|
|
6822
|
+
font-size: var(--amplify-font-sizes-large);
|
|
6823
|
+
font-weight: var(--amplify-font-weights-semibold);
|
|
6824
|
+
flex-shrink: 0;
|
|
6825
|
+
}
|
|
6826
|
+
.amplify-storage-browser__file-metadata {
|
|
6827
|
+
display: grid;
|
|
6828
|
+
gap: var(--amplify-space-small);
|
|
6829
|
+
background-color: var(--amplify-colors-background-secondary);
|
|
6830
|
+
padding: var(--amplify-space-medium);
|
|
6831
|
+
border-radius: var(--amplify-radii-small);
|
|
6832
|
+
border: var(--amplify-border-widths-small) solid var(--amplify-colors-border-secondary);
|
|
6833
|
+
}
|
|
6834
|
+
.amplify-storage-browser__file-metadata-item {
|
|
6835
|
+
display: flex;
|
|
6836
|
+
justify-content: space-between;
|
|
6837
|
+
align-items: center;
|
|
6838
|
+
padding-block: var(--amplify-space-xs);
|
|
6839
|
+
border-block-end: var(--amplify-border-widths-small) solid var(--amplify-colors-border-secondary);
|
|
6840
|
+
}
|
|
6841
|
+
.amplify-storage-browser__file-metadata-item:last-child {
|
|
6842
|
+
border-block-end: none;
|
|
6843
|
+
}
|
|
6844
|
+
.amplify-storage-browser__file-metadata-label {
|
|
6845
|
+
font-weight: var(--amplify-font-weights-medium);
|
|
6846
|
+
color: var(--amplify-colors-font-primary);
|
|
6847
|
+
margin: 0;
|
|
6848
|
+
}
|
|
6849
|
+
.amplify-storage-browser__file-metadata-value {
|
|
6850
|
+
color: var(--amplify-colors-font-secondary);
|
|
6851
|
+
margin: 0;
|
|
6852
|
+
word-break: break-all;
|
|
6853
|
+
text-align: end;
|
|
6854
|
+
max-width: 60%;
|
|
6855
|
+
}
|
|
6856
|
+
.amplify-storage-browser__preview-fallback {
|
|
6857
|
+
width: 100%;
|
|
6858
|
+
height: 400px;
|
|
6859
|
+
display: flex;
|
|
6860
|
+
flex-direction: column;
|
|
6861
|
+
align-items: center;
|
|
6862
|
+
justify-content: center;
|
|
6863
|
+
gap: var(--amplify-space-medium);
|
|
6864
|
+
background-color: var(--amplify-colors-background-secondary);
|
|
6865
|
+
border: var(--amplify-border-widths-small) dashed var(--amplify-colors-border-secondary);
|
|
6866
|
+
border-radius: var(--amplify-radii-small);
|
|
6867
|
+
padding: var(--amplify-space-large);
|
|
6868
|
+
text-align: center;
|
|
6869
|
+
}
|
|
6870
|
+
.amplify-storage-browser__preview-fallback--error {
|
|
6871
|
+
color: var(--amplify-colors-font-error);
|
|
6872
|
+
background-color: var(--amplify-colors-background-error);
|
|
6873
|
+
border-color: var(--amplify-colors-border-error);
|
|
6874
|
+
}
|
|
6875
|
+
.amplify-storage-browser__preview-fallback--default {
|
|
6876
|
+
color: var(--amplify-colors-font-secondary);
|
|
6877
|
+
background-color: var(--amplify-colors-background-secondary);
|
|
6878
|
+
border-color: var(--amplify-colors-border-secondary);
|
|
6879
|
+
}
|
|
6880
|
+
.amplify-storage-browser__preview-fallback-icon {
|
|
6881
|
+
font-size: var(--amplify-font-sizes-xxxxl);
|
|
6882
|
+
margin-block-end: var(--amplify-space-xs);
|
|
6883
|
+
}
|
|
6884
|
+
.amplify-storage-browser__preview-fallback-title {
|
|
6885
|
+
font-weight: var(--amplify-font-weights-bold);
|
|
6886
|
+
font-size: var(--amplify-font-sizes-large);
|
|
6887
|
+
margin-block-end: var(--amplify-space-xs);
|
|
6888
|
+
}
|
|
6889
|
+
.amplify-storage-browser__preview-fallback-description {
|
|
6890
|
+
font-size: var(--amplify-font-sizes-small);
|
|
6891
|
+
margin-block-end: var(--amplify-space-xs);
|
|
6892
|
+
}
|
|
6893
|
+
.amplify-storage-browser__preview-fallback-filename {
|
|
6894
|
+
font-size: var(--amplify-font-sizes-xs);
|
|
6895
|
+
font-family: var(--amplify-fonts-monospace), monospace;
|
|
6896
|
+
}
|
|
6897
|
+
.amplify-storage-browser__preview-fallback-actions {
|
|
6898
|
+
display: flex;
|
|
6899
|
+
gap: var(--amplify-space-small);
|
|
6900
|
+
flex-wrap: wrap;
|
|
6901
|
+
justify-content: center;
|
|
6902
|
+
}
|
|
6903
|
+
.amplify-storage-browser__preview-placeholder {
|
|
6904
|
+
display: flex;
|
|
6905
|
+
flex-direction: column;
|
|
6906
|
+
align-items: center;
|
|
6907
|
+
justify-content: center;
|
|
6908
|
+
gap: var(--amplify-space-medium);
|
|
6909
|
+
height: 400px;
|
|
6910
|
+
width: 100%;
|
|
6911
|
+
}
|
|
6912
|
+
.amplify-storage-browser__preview-placeholder-content {
|
|
6913
|
+
display: flex;
|
|
6914
|
+
flex-direction: column;
|
|
6915
|
+
align-items: center;
|
|
6916
|
+
gap: var(--amplify-space-small);
|
|
6917
|
+
width: 100%;
|
|
6918
|
+
}
|
|
6919
|
+
.amplify-storage-browser__preview-placeholder-info {
|
|
6920
|
+
color: var(--amplify-colors-font-secondary);
|
|
6921
|
+
font-size: var(--amplify-font-sizes-small);
|
|
6922
|
+
text-align: center;
|
|
6923
|
+
}
|
|
6924
|
+
.amplify-storage-browser__text-container {
|
|
6925
|
+
display: flex;
|
|
6926
|
+
flex-flow: column nowrap;
|
|
6927
|
+
gap: 8px;
|
|
6928
|
+
align-items: center;
|
|
6929
|
+
}
|
|
6930
|
+
.amplify-storage-browser__text-preview {
|
|
6931
|
+
height: 400px;
|
|
6932
|
+
width: 100%;
|
|
6933
|
+
display: block;
|
|
6934
|
+
background-color: var(--amplify-colors-background-secondary);
|
|
6935
|
+
border: var(--amplify-border-widths-small) solid var(--amplify-colors-border-secondary);
|
|
6936
|
+
border-radius: var(--amplify-radii-small);
|
|
6937
|
+
padding: var(--amplify-space-medium);
|
|
6938
|
+
font-family: var(--amplify-fonts-monospace), monospace;
|
|
6939
|
+
font-size: var(--amplify-font-sizes-small);
|
|
6940
|
+
line-height: 1.5;
|
|
6941
|
+
overflow-y: auto;
|
|
6942
|
+
word-wrap: break-word;
|
|
6943
|
+
white-space: pre-wrap;
|
|
6944
|
+
word-break: break-word;
|
|
6945
|
+
}
|
|
6946
|
+
.amplify-storage-browser__video-container {
|
|
6947
|
+
display: flex;
|
|
6948
|
+
flex-flow: column nowrap;
|
|
6949
|
+
gap: 8px;
|
|
6950
|
+
align-items: center;
|
|
6951
|
+
}
|
|
6952
|
+
.amplify-storage-browser__video-preview {
|
|
6953
|
+
display: flex;
|
|
6954
|
+
align-items: center;
|
|
6955
|
+
justify-content: center;
|
|
6956
|
+
width: 100%;
|
|
6957
|
+
height: 400px;
|
|
6958
|
+
border-radius: var(--amplify-radii-small);
|
|
6959
|
+
background-color: var(--amplify-colors-background-secondary);
|
|
6960
|
+
flex-shrink: 0;
|
|
6961
|
+
}
|
|
6962
|
+
.amplify-storage-browser__video-preview video {
|
|
6963
|
+
max-width: 100%;
|
|
6964
|
+
max-height: 100%;
|
|
6965
|
+
width: auto;
|
|
6966
|
+
height: auto;
|
|
6967
|
+
-o-object-fit: contain;
|
|
6968
|
+
object-fit: contain;
|
|
6969
|
+
}
|
|
6970
|
+
.amplify-storage-browser__image-container {
|
|
6971
|
+
display: flex;
|
|
6972
|
+
flex-flow: column nowrap;
|
|
6973
|
+
gap: 8px;
|
|
6974
|
+
align-items: center;
|
|
6975
|
+
}
|
|
6976
|
+
.amplify-storage-browser__image-preview {
|
|
6977
|
+
display: flex;
|
|
6978
|
+
align-items: center;
|
|
6979
|
+
justify-content: center;
|
|
6980
|
+
height: 400px;
|
|
6981
|
+
width: 100%;
|
|
6982
|
+
background-color: var(--amplify-colors-background-secondary);
|
|
6983
|
+
border-radius: var(--amplify-radii-small);
|
|
6984
|
+
flex-shrink: 0;
|
|
6985
|
+
flex-flow: column nowrap;
|
|
6986
|
+
gap: 8px;
|
|
6987
|
+
}
|
|
6988
|
+
.amplify-storage-browser__image-preview img {
|
|
6989
|
+
max-width: 100%;
|
|
6990
|
+
max-height: 100%;
|
|
6991
|
+
width: auto;
|
|
6992
|
+
height: auto;
|
|
6993
|
+
-o-object-fit: contain;
|
|
6994
|
+
object-fit: contain;
|
|
6995
|
+
border-radius: var(--amplify-radii-small);
|
|
6996
|
+
}
|
|
6997
|
+
.amplify-storage-browser__download-button {
|
|
6998
|
+
display: flex;
|
|
6999
|
+
flex-flow: row nowrap;
|
|
7000
|
+
gap: 8px;
|
|
7001
|
+
}
|
|
7002
|
+
.amplify-storage-browser__download-button_icon {
|
|
7003
|
+
animation-delay: 0s;
|
|
7004
|
+
animation-direction: normal;
|
|
7005
|
+
animation-duration: 1s;
|
|
7006
|
+
animation-iteration-count: infinite;
|
|
7007
|
+
animation-timing-function: linear;
|
|
7008
|
+
animation-name: spin;
|
|
7009
|
+
}
|
|
6771
7010
|
|
|
7011
|
+
@keyframes spin {
|
|
7012
|
+
0% {
|
|
7013
|
+
transform: rotate(0deg);
|
|
7014
|
+
}
|
|
7015
|
+
50% {
|
|
7016
|
+
transform: rotate(180deg);
|
|
7017
|
+
}
|
|
7018
|
+
100% {
|
|
7019
|
+
transform: rotate(360deg);
|
|
7020
|
+
}
|
|
7021
|
+
}
|
|
6772
7022
|
.amplify-ai-conversation {
|
|
6773
7023
|
display: flex;
|
|
6774
7024
|
flex-direction: column;
|
|
@@ -12,8 +12,8 @@ export declare const defaultActionViewConfigs: {
|
|
|
12
12
|
upload: UploadActionConfig;
|
|
13
13
|
};
|
|
14
14
|
export type DefaultActionViewType = keyof typeof defaultActionViewConfigs;
|
|
15
|
-
export declare const DEFAULT_ACTION_VIEW_TYPES: ("upload" | "copy" | "
|
|
16
|
-
export declare const isDefaultActionViewType: (value?: string) => value is "upload" | "copy" | "
|
|
15
|
+
export declare const DEFAULT_ACTION_VIEW_TYPES: ("upload" | "copy" | "download" | "delete" | "createFolder")[];
|
|
16
|
+
export declare const isDefaultActionViewType: (value?: string) => value is "upload" | "copy" | "download" | "delete" | "createFolder";
|
|
17
17
|
export declare const defaultActionConfigs: {
|
|
18
18
|
listLocationItems: import("../handlers").ListLocationItemsHandler;
|
|
19
19
|
copy: CopyActionConfig;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { AllFileTypes } from '../../createStorageBrowser/types';
|
|
1
2
|
import type { LocationCredentialsProvider } from '../../storage-internal';
|
|
2
3
|
/**
|
|
3
4
|
* `location` grant scope
|
|
@@ -44,6 +45,9 @@ export interface FileData {
|
|
|
44
45
|
id: string;
|
|
45
46
|
size: number;
|
|
46
47
|
type: 'FILE';
|
|
48
|
+
contentType?: string;
|
|
49
|
+
fileType?: AllFileTypes | null;
|
|
50
|
+
versionId?: string;
|
|
47
51
|
}
|
|
48
52
|
export type LocationItemData = FileData | FolderData;
|
|
49
53
|
export interface FileDataItem extends FileData, TaskData {
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { FileData } from '../../../actions';
|
|
3
|
+
interface FilePreviewLayoutProps {
|
|
4
|
+
fileData: FileData;
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
}
|
|
7
|
+
export declare function FilePreviewLayout({ fileData, children, }: FilePreviewLayoutProps): React.JSX.Element;
|
|
8
|
+
export {};
|