@aws-amplify/ui-react-storage 3.10.3 → 3.12.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.
Files changed (88) hide show
  1. package/dist/browser.js +1 -1
  2. package/dist/{createStorageBrowser-B75dAYRb.js → createStorageBrowser-D5xaObbd.js} +439 -251
  3. package/dist/esm/components/StorageBrowser/actions/configs/defaults.mjs +12 -3
  4. package/dist/esm/components/StorageBrowser/actions/handlers/listLocationItems.mjs +1 -1
  5. package/dist/esm/components/StorageBrowser/actions/handlers/listLocations.mjs +1 -1
  6. package/dist/esm/components/StorageBrowser/createStorageBrowser/StorageBrowserDefault.mjs +2 -1
  7. package/dist/esm/components/StorageBrowser/createStorageBrowser/createProvider.mjs +6 -3
  8. package/dist/esm/components/StorageBrowser/createStorageBrowser/createStorageBrowser.mjs +3 -1
  9. package/dist/esm/components/StorageBrowser/displayText/context.mjs +5 -1
  10. package/dist/esm/components/StorageBrowser/displayText/libraries/en/default.mjs +2 -0
  11. package/dist/esm/components/StorageBrowser/displayText/libraries/en/downloadView.mjs +23 -0
  12. package/dist/esm/components/StorageBrowser/displayText/libraries/en/locationDetailView.mjs +2 -0
  13. package/dist/esm/components/StorageBrowser/displayText/libraries/en/uploadView.mjs +3 -6
  14. package/dist/esm/components/StorageBrowser/displayText/utils.mjs +3 -1
  15. package/dist/esm/components/StorageBrowser/fileItems/constants.mjs +11 -0
  16. package/dist/esm/components/StorageBrowser/fileItems/context.mjs +42 -0
  17. package/dist/esm/components/StorageBrowser/fileItems/fileItemsReducer.mjs +33 -0
  18. package/dist/esm/components/StorageBrowser/fileItems/utils.mjs +55 -0
  19. package/dist/esm/components/StorageBrowser/useAction/utils.mjs +2 -2
  20. package/dist/esm/components/StorageBrowser/views/LocationActionView/CopyView/CopyViewProvider.mjs +3 -2
  21. package/dist/esm/components/StorageBrowser/views/LocationActionView/CreateFolderView/CreateFolderViewProvider.mjs +0 -1
  22. package/dist/esm/components/StorageBrowser/views/LocationActionView/DeleteView/DeleteViewProvider.mjs +4 -3
  23. package/dist/esm/components/StorageBrowser/views/LocationActionView/DownloadView/DownloadView.mjs +47 -0
  24. package/dist/esm/components/StorageBrowser/views/LocationActionView/DownloadView/DownloadViewProvider.mjs +38 -0
  25. package/dist/esm/components/StorageBrowser/views/LocationActionView/DownloadView/useDownloadView.mjs +66 -0
  26. package/dist/esm/components/StorageBrowser/views/LocationActionView/UploadView/UploadView.mjs +3 -0
  27. package/dist/esm/components/StorageBrowser/views/LocationActionView/UploadView/UploadViewProvider.mjs +7 -2
  28. package/dist/esm/components/StorageBrowser/views/LocationActionView/UploadView/useUploadView.mjs +23 -35
  29. package/dist/esm/components/StorageBrowser/views/LocationDetailView/LocationDetailViewProvider.mjs +0 -1
  30. package/dist/esm/components/StorageBrowser/views/LocationDetailView/useLocationDetailView.mjs +3 -3
  31. package/dist/esm/components/StorageBrowser/views/context/actionViews.mjs +3 -1
  32. package/dist/esm/components/StorageBrowser/views/context/primaryViews.mjs +2 -1
  33. package/dist/esm/components/StorageBrowser/views/hooks/usePaginate.mjs +1 -1
  34. package/dist/esm/components/StorageBrowser/views/useView.mjs +3 -0
  35. package/dist/esm/components/StorageBrowser/views/utils/tableResolvers/constants.mjs +9 -1
  36. package/dist/esm/components/StorageBrowser/views/utils/tableResolvers/copyResolvers.mjs +4 -42
  37. package/dist/esm/components/StorageBrowser/views/utils/tableResolvers/deleteResolvers.mjs +4 -42
  38. package/dist/esm/components/StorageBrowser/views/utils/tableResolvers/downloadResolvers.mjs +36 -0
  39. package/dist/esm/components/StorageBrowser/views/utils/tableResolvers/utils.mjs +45 -5
  40. package/dist/esm/version.mjs +1 -1
  41. package/dist/index.js +1 -1
  42. package/dist/styles.css +17 -2
  43. package/dist/types/components/StorageBrowser/actions/configs/defaults.d.ts +4 -3
  44. package/dist/types/components/StorageBrowser/actions/configs/types.d.ts +3 -1
  45. package/dist/types/components/StorageBrowser/actions/handlers/download.d.ts +2 -2
  46. package/dist/types/components/StorageBrowser/actions/index.d.ts +1 -1
  47. package/dist/types/components/StorageBrowser/createStorageBrowser/createProvider.d.ts +1 -1
  48. package/dist/types/components/StorageBrowser/createStorageBrowser/types.d.ts +23 -4
  49. package/dist/types/components/StorageBrowser/displayText/index.d.ts +2 -2
  50. package/dist/types/components/StorageBrowser/displayText/libraries/en/downloadView.d.ts +2 -0
  51. package/dist/types/components/StorageBrowser/displayText/types.d.ts +8 -2
  52. package/dist/types/components/StorageBrowser/displayText/utils.d.ts +2 -1
  53. package/dist/types/components/StorageBrowser/fileItems/constants.d.ts +4 -0
  54. package/dist/types/components/StorageBrowser/fileItems/context.d.ts +6 -0
  55. package/dist/types/components/StorageBrowser/fileItems/fileItemsReducer.d.ts +6 -0
  56. package/dist/types/components/StorageBrowser/fileItems/index.d.ts +3 -0
  57. package/dist/types/components/StorageBrowser/fileItems/types.d.ts +44 -0
  58. package/dist/types/components/StorageBrowser/fileItems/utils.d.ts +5 -0
  59. package/dist/types/components/StorageBrowser/validators/index.d.ts +1 -2
  60. package/dist/types/components/StorageBrowser/views/LocationActionView/DownloadView/DownloadView.d.ts +2 -0
  61. package/dist/types/components/StorageBrowser/views/LocationActionView/DownloadView/DownloadViewProvider.d.ts +3 -0
  62. package/dist/types/components/StorageBrowser/views/LocationActionView/DownloadView/index.d.ts +3 -0
  63. package/dist/types/components/StorageBrowser/views/LocationActionView/DownloadView/types.d.ts +22 -0
  64. package/dist/types/components/StorageBrowser/views/LocationActionView/DownloadView/useDownloadView.d.ts +2 -0
  65. package/dist/types/components/StorageBrowser/views/LocationActionView/UploadView/types.d.ts +6 -1
  66. package/dist/types/components/StorageBrowser/views/LocationActionView/index.d.ts +2 -0
  67. package/dist/types/components/StorageBrowser/views/index.d.ts +2 -2
  68. package/dist/types/components/StorageBrowser/views/types.d.ts +5 -3
  69. package/dist/types/components/StorageBrowser/views/useView.d.ts +2 -1
  70. package/dist/types/components/StorageBrowser/views/utils/index.d.ts +1 -1
  71. package/dist/types/components/StorageBrowser/views/utils/tableResolvers/__testUtils__/tasks.d.ts +6 -11
  72. package/dist/types/components/StorageBrowser/views/utils/tableResolvers/constants.d.ts +1 -0
  73. package/dist/types/components/StorageBrowser/views/utils/tableResolvers/copyResolvers.d.ts +2 -3
  74. package/dist/types/components/StorageBrowser/views/utils/tableResolvers/deleteResolvers.d.ts +2 -3
  75. package/dist/types/components/StorageBrowser/views/utils/tableResolvers/downloadResolvers.d.ts +2 -0
  76. package/dist/types/components/StorageBrowser/views/utils/tableResolvers/index.d.ts +4 -2
  77. package/dist/types/components/StorageBrowser/views/utils/tableResolvers/types.d.ts +15 -11
  78. package/dist/types/components/StorageBrowser/views/utils/tableResolvers/utils.d.ts +15 -7
  79. package/dist/types/version.d.ts +1 -1
  80. package/package.json +3 -3
  81. package/dist/esm/components/StorageBrowser/files/context.mjs +0 -31
  82. package/dist/esm/components/StorageBrowser/files/utils.mjs +0 -52
  83. package/dist/esm/components/StorageBrowser/validators/isFileTooBig.mjs +0 -4
  84. package/dist/types/components/StorageBrowser/files/context.d.ts +0 -6
  85. package/dist/types/components/StorageBrowser/files/index.d.ts +0 -2
  86. package/dist/types/components/StorageBrowser/files/types.d.ts +0 -28
  87. package/dist/types/components/StorageBrowser/files/utils.d.ts +0 -7
  88. package/dist/types/components/StorageBrowser/validators/isFileTooBig.d.ts +0 -2
@@ -13,7 +13,7 @@ import { UPLOAD_TABLE_RESOLVERS, UPLOAD_TABLE_KEYS } from '../../utils/tableReso
13
13
  function UploadViewProvider({ children, ...props }) {
14
14
  const { UploadView: displayText } = useDisplayText();
15
15
  const { actionCancelLabel, actionDestinationLabel, actionExitLabel, actionStartLabel, addFilesLabel, addFolderLabel, statusDisplayCanceledLabel, statusDisplayCompletedLabel, statusDisplayFailedLabel, statusDisplayQueuedLabel, overwriteToggleLabel, title, getActionCompleteMessage, getFilesValidationMessage, } = displayText;
16
- const { isOverwritingEnabled, isProcessing, isProcessingComplete, location, tasks: items, statusCounts, invalidFiles, onActionStart, onActionCancel, onDropFiles, onActionExit, onTaskRemove, onSelectFiles, onToggleOverwrite, } = props;
16
+ const { hasNextPage, highestPageVisited, page, isOverwritingEnabled, isProcessing, isProcessingComplete, location, tasks: items, statusCounts, invalidFiles, onActionStart, onActionCancel, onDropFiles, onPaginate, onActionExit, onTaskRemove, onSelectFiles, onToggleOverwrite, } = props;
17
17
  const isActionStartDisabled = isProcessing || isProcessingComplete || statusCounts.TOTAL === 0;
18
18
  const isActionCancelDisabled = !isProcessing || isProcessingComplete;
19
19
  const isAddFilesDisabled = isProcessing || isProcessingComplete;
@@ -47,6 +47,11 @@ function UploadViewProvider({ children, ...props }) {
47
47
  isOverwriteToggleDisabled: isProcessing || isProcessingComplete,
48
48
  isOverwritingEnabled,
49
49
  overwriteToggleLabel,
50
+ paginationData: {
51
+ page,
52
+ hasNextPage,
53
+ highestPageVisited,
54
+ },
50
55
  destination: location,
51
56
  message: actionCompleteMessage ?? filesValidationMessage,
52
57
  statusCounts,
@@ -56,7 +61,7 @@ function UploadViewProvider({ children, ...props }) {
56
61
  statusDisplayQueuedLabel,
57
62
  tableData,
58
63
  title,
59
- }, onActionCancel: onActionCancel, onActionExit: onActionExit, onActionStart: onActionStart, onAddFiles: () => {
64
+ }, onActionCancel: onActionCancel, onActionExit: onActionExit, onActionStart: onActionStart, onPaginate: onPaginate, onAddFiles: () => {
60
65
  onSelectFiles('FILE');
61
66
  }, onAddFolder: () => {
62
67
  onSelectFiles('FOLDER');
@@ -1,6 +1,6 @@
1
1
  import React__default from 'react';
2
- import { isUndefined } from '@aws-amplify/ui';
3
- import { useFiles } from '../../../files/context.mjs';
2
+ import { useFileItems } from '../../../fileItems/context.mjs';
3
+ import '@aws-amplify/ui';
4
4
  import { useStore } from '../../../store/context.mjs';
5
5
  import '../../../useAction/context.mjs';
6
6
  import { useAction } from '../../../useAction/useAction.mjs';
@@ -10,52 +10,36 @@ import '../../../credentials/context.mjs';
10
10
  import '@aws-amplify/storage/internals';
11
11
  import '../../../configuration/context.mjs';
12
12
  import 'aws-amplify/storage';
13
- import { isFileTooBig } from '../../../validators/isFileTooBig.mjs';
14
13
  import '../../../actions/configs/context.mjs';
15
14
  import '../../../actions/configs/defaults.mjs';
16
15
  import { DEFAULT_OVERWRITE_ENABLED } from './constants.mjs';
16
+ import { usePaginate } from '../../hooks/usePaginate.mjs';
17
17
 
18
+ const DEFAULT_PAGE_SIZE = 100;
18
19
  const useUploadView = (options) => {
19
20
  const { onExit: _onExit } = options ?? {};
20
21
  const [{ location }, storeDispatch] = useStore();
21
- const [files, filesDispatch] = useFiles();
22
+ const [{ validItems, invalidItems: invalidFiles }, fileItemsDispatch] = useFileItems();
22
23
  const { current } = location;
23
24
  const [isOverwritingEnabled, setIsOverwritingEnabled] = React__default.useState(DEFAULT_OVERWRITE_ENABLED);
24
- const filesData = React__default.useMemo(() => (files ?? [])?.reduce((curr, item) => {
25
- if (isFileTooBig(item.file)) {
26
- curr.invalidFiles = isUndefined(curr.invalidFiles)
27
- ? [item]
28
- : curr.invalidFiles.concat(item);
29
- }
30
- else {
31
- curr.validFiles = isUndefined(curr.validFiles)
32
- ? [item]
33
- : curr.validFiles.concat(item);
34
- const parsedFileItem = {
35
- ...item,
36
- key: `${location.key}${item.key}`,
37
- };
38
- curr.data = curr.data.concat({
39
- ...parsedFileItem,
40
- preventOverwrite: !isOverwritingEnabled,
41
- });
42
- }
43
- return curr;
44
- }, { invalidFiles: undefined, validFiles: undefined, data: [] }), [files, isOverwritingEnabled, location.key]);
45
- const { data, invalidFiles } = filesData;
46
- const [{ isProcessing, isProcessingComplete, statusCounts, tasks }, handleUploads,] = useAction('upload', { items: data });
25
+ const items = React__default.useMemo(() => (validItems ?? []).map((item) => ({
26
+ ...item,
27
+ key: `${location.key}${item.key}`,
28
+ preventOverwrite: !isOverwritingEnabled,
29
+ })), [validItems, isOverwritingEnabled, location.key]);
30
+ const [{ isProcessing, isProcessingComplete, statusCounts, tasks }, handleUploads,] = useAction('upload', { items });
31
+ const { currentPage, handlePaginate, pageItems: pageTasks, } = usePaginate({
32
+ items: tasks,
33
+ });
47
34
  const onDropFiles = (files) => {
48
35
  if (files) {
49
- filesDispatch({ type: 'ADD_FILE_ITEMS', files });
36
+ fileItemsDispatch({ type: 'ADD_FILES', files });
50
37
  }
51
38
  };
52
39
  const onSelectFiles = (type) => {
53
- filesDispatch({ type: 'SELECT_FILES', selectionType: type });
40
+ fileItemsDispatch({ type: 'SELECT_FILES', selectionType: type });
54
41
  };
55
42
  const onActionStart = () => {
56
- invalidFiles?.forEach((file) => {
57
- filesDispatch({ type: 'REMOVE_FILE_ITEM', id: file.id });
58
- });
59
43
  handleUploads();
60
44
  };
61
45
  const onActionCancel = () => {
@@ -63,7 +47,7 @@ const useUploadView = (options) => {
63
47
  };
64
48
  const onActionExit = () => {
65
49
  // clear files state
66
- filesDispatch({ type: 'RESET_FILE_ITEMS' });
50
+ fileItemsDispatch({ type: 'RESET_FILE_ITEMS' });
67
51
  // clear selected action
68
52
  storeDispatch({ type: 'RESET_ACTION_TYPE' });
69
53
  _onExit?.(current);
@@ -72,7 +56,7 @@ const useUploadView = (options) => {
72
56
  setIsOverwritingEnabled((prev) => !prev);
73
57
  };
74
58
  const onTaskRemove = ({ data }) => {
75
- filesDispatch({ type: 'REMOVE_FILE_ITEM', id: data.id });
59
+ fileItemsDispatch({ type: 'REMOVE_FILE_ITEM', id: data.id });
76
60
  };
77
61
  return {
78
62
  isProcessing,
@@ -81,11 +65,15 @@ const useUploadView = (options) => {
81
65
  location,
82
66
  invalidFiles,
83
67
  statusCounts,
84
- tasks,
68
+ tasks: pageTasks,
69
+ page: currentPage,
70
+ hasNextPage: currentPage * DEFAULT_PAGE_SIZE < items.length,
71
+ highestPageVisited: Math.ceil(items.length / DEFAULT_PAGE_SIZE),
85
72
  onActionCancel,
86
73
  onActionExit,
87
74
  onActionStart,
88
75
  onDropFiles,
76
+ onPaginate: handlePaginate,
89
77
  onTaskRemove,
90
78
  onSelectFiles,
91
79
  onToggleOverwrite,
@@ -1,7 +1,6 @@
1
1
  import React__default from 'react';
2
2
  import { ControlsContextProvider } from '../../controls/context.mjs';
3
3
  import { useDisplayText } from '../../displayText/context.mjs';
4
- import '@aws-amplify/ui';
5
4
  import { getLocationDetailViewTableData } from './getLocationDetailViewTableData/getLocationDetailViewTableData.mjs';
6
5
 
7
6
  function LocationDetailViewProvider({ children, ...props }) {
@@ -5,7 +5,7 @@ import '@aws-amplify/storage/internals';
5
5
  import 'aws-amplify/storage';
6
6
  import { useActionConfigs } from '../../actions/configs/context.mjs';
7
7
  import '../../actions/configs/defaults.mjs';
8
- import { useFiles } from '../../files/context.mjs';
8
+ import { useFileItems } from '../../fileItems/context.mjs';
9
9
  import { useLocationItems } from '../../locationItems/context.mjs';
10
10
  import { useStore } from '../../store/context.mjs';
11
11
  import '../../useAction/context.mjs';
@@ -32,7 +32,7 @@ const useLocationDetailView = (options) => {
32
32
  const listOptions = listOptionsRef.current;
33
33
  const [{ location, actionType }, storeDispatch] = useStore();
34
34
  const [locationItems, locationItemsDispatch] = useLocationItems();
35
- const filesDispatch = useFiles()[1];
35
+ const fileItemsDispatch = useFileItems()[1];
36
36
  const { current, key } = location;
37
37
  const { permissions, prefix } = current ?? {};
38
38
  const { fileDataItems } = locationItems;
@@ -148,7 +148,7 @@ const useLocationDetailView = (options) => {
148
148
  locationItemsDispatch({ type: 'RESET_LOCATION_ITEMS' });
149
149
  },
150
150
  onDropFiles: (files) => {
151
- filesDispatch({ type: 'ADD_FILE_ITEMS', files });
151
+ fileItemsDispatch({ type: 'ADD_FILES', files });
152
152
  const actionType = 'upload';
153
153
  storeDispatch({ type: 'CHANGE_ACTION_TYPE', actionType });
154
154
  options?.onActionSelect?.(actionType);
@@ -1,7 +1,7 @@
1
1
  import React__default from 'react';
2
2
  import { UploadView } from '../LocationActionView/UploadView/UploadView.mjs';
3
+ import '../../fileItems/context.mjs';
3
4
  import '@aws-amplify/ui';
4
- import '../../files/context.mjs';
5
5
  import '../../store/context.mjs';
6
6
  import '../../useAction/context.mjs';
7
7
  import '@aws-amplify/ui-react-core/elements';
@@ -16,11 +16,13 @@ import { CreateFolderView } from '../LocationActionView/CreateFolderView/CreateF
16
16
  import { CopyView } from '../LocationActionView/CopyView/CopyView.mjs';
17
17
  import '../../locationItems/context.mjs';
18
18
  import { DeleteView } from '../LocationActionView/DeleteView/DeleteView.mjs';
19
+ import { DownloadView } from '../LocationActionView/DownloadView/DownloadView.mjs';
19
20
 
20
21
  const DEFAULT_ACTION_VIEWS = {
21
22
  createFolder: CreateFolderView,
22
23
  copy: CopyView,
23
24
  delete: DeleteView,
25
+ download: DownloadView,
24
26
  upload: UploadView,
25
27
  };
26
28
  const ActionViewsContext = React__default.createContext({
@@ -14,9 +14,10 @@ import '../../actions/configs/context.mjs';
14
14
  import '../../actions/configs/defaults.mjs';
15
15
  import '../LocationActionView/CreateFolderView/CreateFolderView.mjs';
16
16
  import '../LocationActionView/DeleteView/DeleteView.mjs';
17
+ import '../LocationActionView/DownloadView/DownloadView.mjs';
17
18
  import { LocationActionView } from '../LocationActionView/LocationActionView.mjs';
18
19
  import '../LocationActionView/UploadView/UploadView.mjs';
19
- import '../../files/context.mjs';
20
+ import '../../fileItems/context.mjs';
20
21
  import { LocationDetailView } from '../LocationDetailView/LocationDetailView.mjs';
21
22
  import { LocationsView } from '../LocationsView/LocationsView.mjs';
22
23
 
@@ -24,7 +24,7 @@ const usePaginate = ({ items, onPaginate, page = 1, pageSize = DEFAULT_PAGE_SIZE
24
24
  return;
25
25
  if (isFunction(onPaginate))
26
26
  onPaginate(page);
27
- if (page > currentPage)
27
+ if (page > currentPage && page > highestPageVisited)
28
28
  visitedRef.current = page;
29
29
  setCurrentPage(page);
30
30
  },
@@ -4,6 +4,8 @@ import './LocationActionView/CreateFolderView/CreateFolderView.mjs';
4
4
  import { useCreateFolderView } from './LocationActionView/CreateFolderView/useCreateFolderView.mjs';
5
5
  import './LocationActionView/DeleteView/DeleteView.mjs';
6
6
  import { useDeleteView } from './LocationActionView/DeleteView/useDeleteView.mjs';
7
+ import './LocationActionView/DownloadView/DownloadView.mjs';
8
+ import { useDownloadView } from './LocationActionView/DownloadView/useDownloadView.mjs';
7
9
  import 'react';
8
10
  import '../store/context.mjs';
9
11
  import './context/actionViews.mjs';
@@ -17,6 +19,7 @@ import { useLocationsView } from './LocationsView/useLocationsView.mjs';
17
19
  const USE_VIEW_HOOKS = {
18
20
  Copy: useCopyView,
19
21
  CreateFolder: useCreateFolderView,
22
+ Download: useDownloadView,
20
23
  Delete: useDeleteView,
21
24
  LocationDetail: useLocationDetailView,
22
25
  Locations: useLocationsView,
@@ -14,5 +14,13 @@ const STATUS_ICONS = {
14
14
  CANCELED: 'action-canceled',
15
15
  QUEUED: 'action-queued',
16
16
  };
17
+ const FILE_DATA_ITEM_TABLE_KEYS = [
18
+ 'name',
19
+ 'folder',
20
+ 'type',
21
+ 'size',
22
+ 'status',
23
+ 'cancel',
24
+ ];
17
25
 
18
- export { STATUS_ICONS, STATUS_LABELS };
26
+ export { FILE_DATA_ITEM_TABLE_KEYS, STATUS_ICONS, STATUS_LABELS };
@@ -1,44 +1,11 @@
1
1
  import { noop, capitalize } from '@aws-amplify/ui';
2
2
  import '../../../displayText/context.mjs';
3
3
  import { isCopyViewDisplayTextKey } from '../../../displayText/utils.mjs';
4
- import { STATUS_ICONS, STATUS_LABELS } from './constants.mjs';
5
- import { getCopyOrDeleteCancelCellContent, getFileSize, getFileType, getCopyCellFolder } from './utils.mjs';
4
+ import { STATUS_LABELS } from './constants.mjs';
5
+ import { cancel, size, type, folder, name, getFileDataCellKey } from './utils.mjs';
6
6
 
7
- const COPY_TABLE_KEYS = [
8
- 'name',
9
- 'folder',
10
- 'type',
11
- 'size',
12
- 'status',
13
- 'cancel',
14
- ];
15
- const getCopyCellKey = ({ key, item, }) => `${key}-${item.data.id}`;
16
- const name = (data) => {
17
- const key = getCopyCellKey(data);
18
- const { item } = data;
19
- const text = item.data.fileKey;
20
- const icon = STATUS_ICONS[item.status];
21
- return { key, type: 'text', content: { icon, text } };
22
- };
23
- const folder = (data) => {
24
- const key = getCopyCellKey(data);
25
- const text = getCopyCellFolder(data.item);
26
- return { key, type: 'text', content: { text } };
27
- };
28
- const type = (data) => {
29
- const key = getCopyCellKey(data);
30
- const { fileKey } = data.item.data;
31
- const text = getFileType(fileKey);
32
- return { key, type: 'text', content: { text } };
33
- };
34
- const size = (data) => {
35
- const key = getCopyCellKey(data);
36
- const { size: value } = data.item.data;
37
- const displayValue = getFileSize(value);
38
- return { key, type: 'number', content: { value, displayValue } };
39
- };
40
7
  const status = (data) => {
41
- const key = getCopyCellKey(data);
8
+ const key = getFileDataCellKey(data);
42
9
  const { item: { status }, props: { displayText }, } = data;
43
10
  const statusLabelKey = STATUS_LABELS[status];
44
11
  const text = isCopyViewDisplayTextKey(statusLabelKey)
@@ -46,11 +13,6 @@ const status = (data) => {
46
13
  : '';
47
14
  return { key, type: 'text', content: { text } };
48
15
  };
49
- const cancel = (data) => {
50
- const key = getCopyCellKey(data);
51
- const content = getCopyOrDeleteCancelCellContent(data);
52
- return { key, type: 'button', content };
53
- };
54
16
  const COPY_CELL_RESOLVERS = {
55
17
  name,
56
18
  folder,
@@ -79,4 +41,4 @@ const COPY_TABLE_RESOLVERS = {
79
41
  getRowKey: ({ item }) => item.data.id,
80
42
  };
81
43
 
82
- export { COPY_TABLE_KEYS, COPY_TABLE_RESOLVERS };
44
+ export { COPY_TABLE_RESOLVERS };
@@ -1,44 +1,11 @@
1
1
  import { noop, capitalize } from '@aws-amplify/ui';
2
2
  import '../../../displayText/context.mjs';
3
3
  import { isDeleteViewDisplayTextKey } from '../../../displayText/utils.mjs';
4
- import { STATUS_ICONS, STATUS_LABELS } from './constants.mjs';
5
- import { getCopyOrDeleteCancelCellContent, getFileSize, getFileType, getDeleteCellFolder } from './utils.mjs';
4
+ import { STATUS_LABELS } from './constants.mjs';
5
+ import { cancel, size, type, folder, name, getFileDataCellKey } from './utils.mjs';
6
6
 
7
- const DELETE_TABLE_KEYS = [
8
- 'name',
9
- 'folder',
10
- 'type',
11
- 'size',
12
- 'status',
13
- 'cancel',
14
- ];
15
- const getDeleteCellKey = ({ key, item, }) => `${key}-${item.data.id}`;
16
- const name = (data) => {
17
- const key = getDeleteCellKey(data);
18
- const { item } = data;
19
- const text = item.data.fileKey;
20
- const icon = STATUS_ICONS[item.status];
21
- return { key, type: 'text', content: { icon, text } };
22
- };
23
- const folder = (data) => {
24
- const key = getDeleteCellKey(data);
25
- const text = getDeleteCellFolder(data.item);
26
- return { key, type: 'text', content: { text } };
27
- };
28
- const type = (data) => {
29
- const key = getDeleteCellKey(data);
30
- const { fileKey } = data.item.data;
31
- const text = getFileType(fileKey);
32
- return { key, type: 'text', content: { text } };
33
- };
34
- const size = (data) => {
35
- const key = getDeleteCellKey(data);
36
- const { size: value } = data.item.data;
37
- const displayValue = getFileSize(value);
38
- return { key, type: 'number', content: { value, displayValue } };
39
- };
40
7
  const status = (data) => {
41
- const key = getDeleteCellKey(data);
8
+ const key = getFileDataCellKey(data);
42
9
  const { item: { status }, props: { displayText }, } = data;
43
10
  const statusLabelKey = STATUS_LABELS[status];
44
11
  const text = isDeleteViewDisplayTextKey(statusLabelKey)
@@ -46,11 +13,6 @@ const status = (data) => {
46
13
  : '';
47
14
  return { key, type: 'text', content: { text } };
48
15
  };
49
- const cancel = (data) => {
50
- const key = getDeleteCellKey(data);
51
- const content = getCopyOrDeleteCancelCellContent(data);
52
- return { key, type: 'button', content };
53
- };
54
16
  const DELETE_CELL_RESOLVERS = {
55
17
  name,
56
18
  folder,
@@ -79,4 +41,4 @@ const DELETE_TABLE_RESOLVERS = {
79
41
  getRowKey: ({ item }) => item.data.id,
80
42
  };
81
43
 
82
- export { DELETE_TABLE_KEYS, DELETE_TABLE_RESOLVERS };
44
+ export { DELETE_TABLE_RESOLVERS };
@@ -0,0 +1,36 @@
1
+ import { capitalize } from '@aws-amplify/ui';
2
+ import '../../../displayText/context.mjs';
3
+ import { isDownloadViewDisplayTextKey } from '../../../displayText/utils.mjs';
4
+ import { STATUS_LABELS } from './constants.mjs';
5
+ import { cancel, size, type, folder, name, getFileDataCellKey } from './utils.mjs';
6
+
7
+ const status = (data) => {
8
+ const key = getFileDataCellKey(data);
9
+ const { item: { status }, props: { displayText }, } = data;
10
+ const statusLabelKey = STATUS_LABELS[status];
11
+ const text = isDownloadViewDisplayTextKey(statusLabelKey)
12
+ ? displayText[statusLabelKey]
13
+ : '';
14
+ return { key, type: 'text', content: { text } };
15
+ };
16
+ const DOWNLOAD_CELL_RESOLVERS = {
17
+ name,
18
+ folder,
19
+ type,
20
+ size,
21
+ status,
22
+ cancel,
23
+ };
24
+ const DOWNLOAD_TABLE_RESOLVERS = {
25
+ getCell: (data) => DOWNLOAD_CELL_RESOLVERS[data.key](data),
26
+ getHeader: ({ key, props: { displayText } }) => {
27
+ const text = displayText[`tableColumn${capitalize(key)}Header`];
28
+ if (key === 'cancel') {
29
+ return { key, type: 'text', content: { text } };
30
+ }
31
+ return { key, type: 'sort', content: { label: text } };
32
+ },
33
+ getRowKey: ({ item }) => item.data.id,
34
+ };
35
+
36
+ export { DOWNLOAD_TABLE_RESOLVERS };
@@ -1,17 +1,24 @@
1
1
  import { humanFileSize } from '@aws-amplify/ui';
2
+ import { STATUS_ICONS } from './constants.mjs';
2
3
 
3
4
  const getFileType = (value, fallback = '') => value.lastIndexOf('.') !== -1
4
5
  ? value.slice(value.lastIndexOf('.') + 1)
5
6
  : fallback;
6
7
  const getCellName = (value) =>
7
8
  // `value.split` always returns an array with at least one entry
8
- // ensruing `.pop()` will always return a string
9
+ // ensuring `.pop()` will always return a string
9
10
  value.split('/').pop();
10
11
  const getUploadCellFolder = ({ data: { file: { webkitRelativePath }, }, }, fallback = '-') => webkitRelativePath
11
12
  ? webkitRelativePath.slice(0, webkitRelativePath.lastIndexOf('/') + 1)
12
13
  : fallback;
13
- const getCopyCellFolder = ({ data: { fileKey, sourceKey }, }) => sourceKey.slice(0, -fileKey.length);
14
- const getDeleteCellFolder = ({ data: { fileKey, key }, }) => key.slice(0, -fileKey.length);
14
+ const isCopyActionTask = (task) => 'sourceKey' in task.data;
15
+ const getFileDataCellFolder = (task) => {
16
+ const targetKey = isCopyActionTask(task)
17
+ ? task.data.sourceKey
18
+ : task.data.key;
19
+ const { fileKey } = task.data;
20
+ return targetKey.slice(0, -fileKey.length);
21
+ };
15
22
  const getUploadCellProgress = ({ progress, status, }) => {
16
23
  // prefer `progress` if available, 1 if status is complete, default 0
17
24
  const value = progress ?? (status === 'COMPLETE' ? 1 : 0);
@@ -19,7 +26,7 @@ const getUploadCellProgress = ({ progress, status, }) => {
19
26
  return { displayValue, value };
20
27
  };
21
28
  const getFileSize = (value, fallback = '-') => (!value ? fallback : humanFileSize(value, true));
22
- const getCopyOrDeleteCancelCellContent = (data) => {
29
+ const getFileDataCancelCellContent = (data) => {
23
30
  const { item, props } = data;
24
31
  const { cancel, status } = item;
25
32
  const { isProcessing, onTaskRemove } = props;
@@ -45,5 +52,38 @@ const getCopyOrDeleteCancelCellContent = (data) => {
45
52
  };
46
53
  return { ariaLabel, isDisabled, onClick, icon: 'cancel' };
47
54
  };
55
+ /**
56
+ * Generates a unique key for a table cell based on the key and item id
57
+ */
58
+ const getFileDataCellKey = ({ key, item, }) => `${key}-${item.data.id}`;
59
+ const name = (data) => {
60
+ const key = getFileDataCellKey(data);
61
+ const { item } = data;
62
+ const text = item.data.fileKey;
63
+ const icon = STATUS_ICONS[item.status];
64
+ return { key, type: 'text', content: { icon, text } };
65
+ };
66
+ const folder = (data) => {
67
+ const key = getFileDataCellKey(data);
68
+ const text = getFileDataCellFolder(data.item);
69
+ return { key, type: 'text', content: { text } };
70
+ };
71
+ const type = (data) => {
72
+ const key = getFileDataCellKey(data);
73
+ const { fileKey } = data.item.data;
74
+ const text = getFileType(fileKey);
75
+ return { key, type: 'text', content: { text } };
76
+ };
77
+ const size = (data) => {
78
+ const key = getFileDataCellKey(data);
79
+ const { size: value } = data.item.data;
80
+ const displayValue = getFileSize(value);
81
+ return { key, type: 'number', content: { value, displayValue } };
82
+ };
83
+ const cancel = (data) => {
84
+ const key = getFileDataCellKey(data);
85
+ const content = getFileDataCancelCellContent(data);
86
+ return { key, type: 'button', content };
87
+ };
48
88
 
49
- export { getCellName, getCopyCellFolder, getCopyOrDeleteCancelCellContent, getDeleteCellFolder, getFileSize, getFileType, getUploadCellFolder, getUploadCellProgress };
89
+ export { cancel, folder, getCellName, getFileDataCancelCellContent, getFileDataCellFolder, getFileDataCellKey, getFileSize, getFileType, getUploadCellFolder, getUploadCellProgress, name, size, type };
@@ -1,3 +1,3 @@
1
- const VERSION = '3.10.3';
1
+ const VERSION = '3.12.0';
2
2
 
3
3
  export { VERSION };
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-B75dAYRb.js');
12
+ var createStorageBrowser = require('./createStorageBrowser-D5xaObbd.js');
13
13
  require('@aws-amplify/storage/internals');
14
14
  require('aws-amplify');
15
15
  require('aws-amplify/utils');
package/dist/styles.css CHANGED
@@ -4250,11 +4250,26 @@ html[dir=rtl] .amplify-field-group__inner-start {
4250
4250
  z-index: 1;
4251
4251
  }
4252
4252
 
4253
- .amplify-liveness-loader {
4253
+ .amplify-liveness-loader .amplify-liveness-centered-loader {
4254
+ transform: translate(-50%, -50%);
4255
+ }
4256
+
4257
+ .amplify-liveness-centered-loader {
4254
4258
  position: absolute;
4255
4259
  left: 50%;
4256
4260
  top: 50%;
4257
- transform: translate(-50%, -50%);
4261
+ }
4262
+
4263
+ .amplify-liveness-connecting-loader {
4264
+ display: flex;
4265
+ position: absolute;
4266
+ flex-direction: column;
4267
+ justify-content: center;
4268
+ align-items: center;
4269
+ z-index: 3;
4270
+ width: 100%;
4271
+ height: 100%;
4272
+ background-color: var(--amplify-colors-background-primary);
4258
4273
  }
4259
4274
 
4260
4275
  .amplify-liveness-oval-canvas {
@@ -1,12 +1,13 @@
1
- import type { CopyActionConfig, CreateFolderActionConfig, DeleteActionConfig, UploadActionConfig } from './types';
1
+ import type { CopyActionConfig, CreateFolderActionConfig, DeleteActionConfig, DownloadActionConfig, UploadActionConfig } from './types';
2
2
  export declare const copyActionConfig: CopyActionConfig;
3
3
  export declare const deleteActionConfig: DeleteActionConfig;
4
4
  export declare const createFolderActionConfig: CreateFolderActionConfig;
5
5
  export declare const uploadActionConfig: UploadActionConfig;
6
+ export declare const downloadActionConfig: DownloadActionConfig;
6
7
  export declare const defaultActionViewConfigs: {
7
8
  copy: CopyActionConfig;
8
9
  createFolder: CreateFolderActionConfig;
9
- download: import("../handlers").DownloadHandler;
10
+ download: DownloadActionConfig;
10
11
  delete: DeleteActionConfig;
11
12
  upload: UploadActionConfig;
12
13
  };
@@ -17,7 +18,7 @@ export declare const defaultActionConfigs: {
17
18
  listLocationItems: import("../handlers").ListLocationItemsHandler;
18
19
  copy: CopyActionConfig;
19
20
  createFolder: CreateFolderActionConfig;
20
- download: import("../handlers").DownloadHandler;
21
+ download: DownloadActionConfig;
21
22
  delete: DeleteActionConfig;
22
23
  upload: UploadActionConfig;
23
24
  };
@@ -87,6 +87,8 @@ export interface CopyActionConfig extends ActionViewConfig<CopyHandler, 'CopyVie
87
87
  }
88
88
  export interface CreateFolderActionConfig extends ActionViewConfig<CreateFolderHandler, 'CreateFolderView'> {
89
89
  }
90
+ export interface DownloadActionConfig extends ActionViewConfig<DownloadHandler, 'DownloadView'> {
91
+ }
90
92
  export interface ListActionConfig<T> {
91
93
  /**
92
94
  * action handler
@@ -98,7 +100,7 @@ export interface DefaultActionConfigs {
98
100
  listLocationItems?: ListLocationItemsHandler;
99
101
  upload?: UploadActionConfig;
100
102
  delete?: DeleteActionConfig;
101
- download?: DownloadHandler;
103
+ download?: DownloadHandler | DownloadActionConfig;
102
104
  copy?: CopyActionConfig;
103
105
  }
104
106
  export interface ExtendedDefaultActionConfigs extends Required<DefaultActionConfigs> {
@@ -1,5 +1,5 @@
1
- import type { TaskData, TaskHandler, TaskHandlerInput, TaskHandlerOptions, TaskHandlerOutput } from './types';
2
- export interface DownloadHandlerData extends TaskData {
1
+ import type { OptionalFileData, TaskData, TaskHandler, TaskHandlerInput, TaskHandlerOptions, TaskHandlerOutput } from './types';
2
+ export interface DownloadHandlerData extends OptionalFileData, TaskData {
3
3
  fileKey: string;
4
4
  }
5
5
  export interface DownloadHandlerOptions extends TaskHandlerOptions {
@@ -1,4 +1,4 @@
1
- export type { ActionInputConfig, CopyHandler, CopyHandlerData, CopyHandlerInput, CopyHandlerOutput, CreateFolderHandler, CreateFolderHandlerData, CreateFolderHandlerInput, CreateFolderHandlerOptions, CreateFolderHandlerOutput, DefaultHandlers, DownloadHandler, DownloadHandlerData, DownloadHandlerInput, DownloadHandlerOptions, DownloadHandlerOutput, DeleteHandler, DeleteHandlerData, DeleteHandlerInput, DeleteHandlerOptions, DeleteHandlerOutput, FileData, FileDataItem, FileItem, FolderData, ListHandler, ListHandlerInput, ListHandlerOptions, ListHandlerOutput, ListLocationItemsHandler, ListLocationItemsHandlerInput, ListLocationItemsHandlerOptions, ListLocationItemsHandlerOutput, ListLocationsExcludeOptions, ListLocations, ListLocationsInput, ListLocationsOutput, ListLocationsHandler, ListLocationsHandlerInput, ListLocationsHandlerOptions, ListLocationsHandlerOutput, LocationData, LocationItemData, LocationItemType, LocationPermissions, LocationType, TaskData, TaskHandler, TaskHandlerInput, TaskHandlerOptions, TaskHandlerOutput, TaskResult, TaskResultStatus, UploadHandler, UploadHandlerData, UploadHandlerInput, UploadHandlerOptions, UploadHandlerOutput, } from './handlers';
1
+ export type { ActionInputConfig, CopyHandler, CopyHandlerData, CopyHandlerInput, CopyHandlerOutput, CreateFolderHandler, CreateFolderHandlerData, CreateFolderHandlerInput, CreateFolderHandlerOptions, CreateFolderHandlerOutput, DefaultHandlers, DownloadHandler, DownloadHandlerData, DownloadHandlerInput, DownloadHandlerOptions, DownloadHandlerOutput, DeleteHandler, DeleteHandlerData, DeleteHandlerInput, DeleteHandlerOptions, DeleteHandlerOutput, FileData, FileDataItem, FileItem, FolderData, ListHandler, ListHandlerInput, ListHandlerOptions, ListHandlerOutput, ListLocationItemsHandler, ListLocationItemsHandlerInput, ListLocationItemsHandlerOptions, ListLocationItemsHandlerOutput, ListLocationsExcludeOptions, ListLocations, ListLocationsInput, ListLocationsOutput, ListLocationsHandler, ListLocationsHandlerInput, ListLocationsHandlerOptions, ListLocationsHandlerOutput, LocationData, LocationItemData, LocationItemType, LocationPermissions, LocationType, OptionalFileData, TaskData, TaskHandler, TaskHandlerInput, TaskHandlerOptions, TaskHandlerOutput, TaskResult, TaskResultStatus, UploadHandler, UploadHandlerData, UploadHandlerInput, UploadHandlerOptions, UploadHandlerOutput, } from './handlers';
2
2
  export { copyHandler, createFileDataItem, createFolderHandler, defaultHandlers, downloadHandler, getFileKey, isFileDataItem, isFileItem, isMultipartUpload, listLocationItemsHandler, listLocationsHandler, uploadHandler, } from './handlers';
3
3
  export type { ExtendedActionConfigs, ActionViewConfig, ActionViewConfigs, ActionConfigsProviderProps, ActionHandler, CustomActionConfigs, DefaultActionConfigs, } from './configs';
4
4
  export { ActionConfigsProvider, defaultActionConfigs, defaultActionViewConfigs, getActionConfigs, isDefaultActionViewType, useActionConfigs, } from './configs';
@@ -1,3 +1,3 @@
1
1
  import React from 'react';
2
2
  import type { CreateStorageBrowserInput, StorageBrowserProviderProps } from './types';
3
- export default function createProvider({ actions, components, config, }: CreateStorageBrowserInput): (props: StorageBrowserProviderProps) => React.JSX.Element;
3
+ export default function createProvider({ actions, components, config, options, }: CreateStorageBrowserInput): (props: StorageBrowserProviderProps) => React.JSX.Element;