@aws-amplify/ui-react-storage 3.4.1 → 3.5.1

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 (134) hide show
  1. package/dist/browser.js +35 -2
  2. package/dist/{createAmplifyAuthAdapter-BRctUWdR.js → createAmplifyAuthAdapter-0MaHde-Z.js} +3053 -2919
  3. package/dist/esm/browser.mjs +2 -0
  4. package/dist/esm/components/StorageBrowser/StorageBrowserAmplify.mjs +2 -7
  5. package/dist/esm/components/StorageBrowser/StorageBrowserDefault.mjs +3 -16
  6. package/dist/esm/components/StorageBrowser/actions/configs/context.mjs +4 -9
  7. package/dist/esm/components/StorageBrowser/actions/configs/defaults.mjs +14 -39
  8. package/dist/esm/components/StorageBrowser/actions/configs/utils.mjs +8 -0
  9. package/dist/esm/components/StorageBrowser/actions/handlers/copy.mjs +13 -13
  10. package/dist/esm/components/StorageBrowser/actions/handlers/createFolder.mjs +9 -6
  11. package/dist/esm/components/StorageBrowser/actions/handlers/delete.mjs +9 -7
  12. package/dist/esm/components/StorageBrowser/actions/handlers/download.mjs +7 -11
  13. package/dist/esm/components/StorageBrowser/actions/handlers/listLocationItems.mjs +3 -3
  14. package/dist/esm/components/StorageBrowser/actions/handlers/upload.mjs +11 -7
  15. package/dist/esm/components/StorageBrowser/actions/handlers/utils.mjs +1 -11
  16. package/dist/esm/components/StorageBrowser/adapters/createManagedAuthAdapter/createManagedAuthAdapter.mjs +1 -3
  17. package/dist/esm/components/StorageBrowser/controls/PaginationControl.mjs +3 -3
  18. package/dist/esm/components/StorageBrowser/controls/SearchFieldControl.mjs +12 -0
  19. package/dist/esm/components/StorageBrowser/controls/hooks/usePagination.mjs +9 -0
  20. package/dist/esm/components/StorageBrowser/controls/hooks/useSearchField.mjs +17 -0
  21. package/dist/esm/components/StorageBrowser/createStorageBrowser.mjs +42 -27
  22. package/dist/esm/components/StorageBrowser/displayText/libraries/en/locationDetailView.mjs +6 -0
  23. package/dist/esm/components/StorageBrowser/displayText/libraries/en/locationsView.mjs +2 -2
  24. package/dist/esm/components/StorageBrowser/providers/configuration/createConfigurationProvider.mjs +4 -10
  25. package/dist/esm/components/StorageBrowser/providers/configuration/useGetActionInputCallback.mjs +7 -7
  26. package/dist/esm/components/StorageBrowser/providers/store/locationItems/context.mjs +1 -1
  27. package/dist/esm/components/StorageBrowser/tasks/useProcessTasks.mjs +27 -6
  28. package/dist/esm/components/StorageBrowser/useAction/constants.mjs +4 -0
  29. package/dist/esm/components/StorageBrowser/useAction/context.mjs +8 -0
  30. package/dist/esm/components/StorageBrowser/useAction/useAction.mjs +18 -0
  31. package/dist/esm/components/StorageBrowser/useAction/useHandler.mjs +40 -0
  32. package/dist/esm/components/StorageBrowser/useAction/useList.mjs +19 -0
  33. package/dist/esm/components/StorageBrowser/useAction/useListFolderItems.mjs +23 -0
  34. package/dist/esm/components/StorageBrowser/useAction/useListLocationItems.mjs +23 -0
  35. package/dist/esm/components/StorageBrowser/{actions/useAction → useAction}/useListLocations.mjs +7 -6
  36. package/dist/esm/components/StorageBrowser/useAction/utils.mjs +26 -0
  37. package/dist/esm/components/StorageBrowser/views/LocationActionView/CopyView/CopyView.mjs +3 -3
  38. package/dist/esm/components/StorageBrowser/views/LocationActionView/CopyView/useCopyView.mjs +32 -17
  39. package/dist/esm/components/StorageBrowser/views/LocationActionView/CopyView/useFolders.mjs +12 -17
  40. package/dist/esm/components/StorageBrowser/views/LocationActionView/CreateFolderView/useCreateFolderView.mjs +18 -15
  41. package/dist/esm/components/StorageBrowser/views/LocationActionView/DeleteView/useDeleteView.mjs +17 -12
  42. package/dist/esm/components/StorageBrowser/views/LocationActionView/LocationActionView.mjs +9 -16
  43. package/dist/esm/components/StorageBrowser/views/LocationActionView/UploadView/useUploadView.mjs +44 -49
  44. package/dist/esm/components/StorageBrowser/views/LocationActionView/getActionViewTableData.mjs +5 -5
  45. package/dist/esm/components/StorageBrowser/views/LocationDetailView/LocationDetailView.mjs +3 -3
  46. package/dist/esm/components/StorageBrowser/views/LocationDetailView/LocationDetailViewProvider.mjs +12 -8
  47. package/dist/esm/components/StorageBrowser/views/LocationDetailView/getLocationDetailViewTableData/getLocationDetailViewTableData.mjs +1 -0
  48. package/dist/esm/components/StorageBrowser/views/LocationDetailView/useLocationDetailView.mjs +50 -69
  49. package/dist/esm/components/StorageBrowser/views/LocationsView/LocationsView.mjs +3 -3
  50. package/dist/esm/components/StorageBrowser/views/LocationsView/LocationsViewProvider.mjs +2 -3
  51. package/dist/esm/components/StorageBrowser/views/LocationsView/useLocationsView.mjs +22 -29
  52. package/dist/esm/components/StorageBrowser/views/context/actionViews.mjs +33 -0
  53. package/dist/esm/components/StorageBrowser/views/context/getViews.mjs +32 -0
  54. package/dist/esm/components/StorageBrowser/views/context/primaryViews.mjs +32 -0
  55. package/dist/esm/components/StorageBrowser/views/context/views.mjs +19 -0
  56. package/dist/esm/components/StorageBrowser/views/{createUseView.mjs → useView.mjs} +19 -28
  57. package/dist/esm/version.mjs +1 -1
  58. package/dist/index.js +5 -10
  59. package/dist/styles.css +6 -2
  60. package/dist/types/components/StorageBrowser/actions/configs/context.d.ts +4 -5
  61. package/dist/types/components/StorageBrowser/actions/configs/defaults.d.ts +6 -7
  62. package/dist/types/components/StorageBrowser/actions/configs/index.d.ts +3 -2
  63. package/dist/types/components/StorageBrowser/actions/configs/types.d.ts +39 -69
  64. package/dist/types/components/StorageBrowser/actions/configs/utils.d.ts +2 -0
  65. package/dist/types/components/StorageBrowser/actions/handlers/copy.d.ts +12 -5
  66. package/dist/types/components/StorageBrowser/actions/handlers/createFolder.d.ts +7 -4
  67. package/dist/types/components/StorageBrowser/actions/handlers/delete.d.ts +6 -3
  68. package/dist/types/components/StorageBrowser/actions/handlers/download.d.ts +6 -3
  69. package/dist/types/components/StorageBrowser/actions/handlers/types.d.ts +11 -2
  70. package/dist/types/components/StorageBrowser/actions/handlers/upload.d.ts +8 -4
  71. package/dist/types/components/StorageBrowser/actions/handlers/utils.d.ts +0 -1
  72. package/dist/types/components/StorageBrowser/actions/index.d.ts +2 -4
  73. package/dist/types/components/StorageBrowser/adapters/permissionParsers.d.ts +1 -1
  74. package/dist/types/components/StorageBrowser/composables/ActionsList.d.ts +2 -2
  75. package/dist/types/components/StorageBrowser/controls/SearchFieldControl.d.ts +2 -0
  76. package/dist/types/components/StorageBrowser/controls/hooks/usePagination.d.ts +2 -0
  77. package/dist/types/components/StorageBrowser/controls/hooks/useSearchField.d.ts +2 -0
  78. package/dist/types/components/StorageBrowser/controls/types.d.ts +3 -3
  79. package/dist/types/components/StorageBrowser/createStorageBrowser.d.ts +3 -7
  80. package/dist/types/components/StorageBrowser/displayText/index.d.ts +1 -1
  81. package/dist/types/components/StorageBrowser/displayText/types.d.ts +1 -1
  82. package/dist/types/components/StorageBrowser/index.d.ts +3 -1
  83. package/dist/types/components/StorageBrowser/providers/configuration/index.d.ts +1 -1
  84. package/dist/types/components/StorageBrowser/providers/configuration/types.d.ts +2 -2
  85. package/dist/types/components/StorageBrowser/providers/store/files/types.d.ts +10 -1
  86. package/dist/types/components/StorageBrowser/providers/store/files/utils.d.ts +1 -2
  87. package/dist/types/components/StorageBrowser/tasks/types.d.ts +16 -13
  88. package/dist/types/components/StorageBrowser/tasks/useProcessTasks.d.ts +2 -3
  89. package/dist/types/components/StorageBrowser/types.d.ts +42 -12
  90. package/dist/types/components/StorageBrowser/useAction/constants.d.ts +3 -0
  91. package/dist/types/components/StorageBrowser/useAction/context.d.ts +5 -0
  92. package/dist/types/components/StorageBrowser/{actions/useAction → useAction}/createEnhancedListHandler.d.ts +3 -3
  93. package/dist/types/components/StorageBrowser/useAction/index.d.ts +6 -0
  94. package/dist/types/components/StorageBrowser/useAction/types.d.ts +76 -0
  95. package/dist/types/components/StorageBrowser/useAction/useAction.d.ts +3 -0
  96. package/dist/types/components/StorageBrowser/useAction/useHandler.d.ts +3 -0
  97. package/dist/types/components/StorageBrowser/useAction/useList.d.ts +9 -0
  98. package/dist/types/components/StorageBrowser/useAction/useListFolderItems.d.ts +13 -0
  99. package/dist/types/components/StorageBrowser/useAction/useListLocationItems.d.ts +10 -0
  100. package/dist/types/components/StorageBrowser/useAction/useListLocations.d.ts +8 -0
  101. package/dist/types/components/StorageBrowser/useAction/utils.d.ts +6 -0
  102. package/dist/types/components/StorageBrowser/views/LocationActionView/CopyView/useFolders.d.ts +1 -4
  103. package/dist/types/components/StorageBrowser/views/LocationActionView/CreateFolderView/types.d.ts +2 -2
  104. package/dist/types/components/StorageBrowser/views/LocationActionView/LocationActionView.d.ts +2 -6
  105. package/dist/types/components/StorageBrowser/views/LocationActionView/getActionViewTableData.d.ts +2 -4
  106. package/dist/types/components/StorageBrowser/views/LocationActionView/index.d.ts +6 -6
  107. package/dist/types/components/StorageBrowser/views/LocationActionView/types.d.ts +4 -8
  108. package/dist/types/components/StorageBrowser/views/LocationDetailView/getLocationDetailViewTableData/getLocationDetailViewTableData.d.ts +1 -3
  109. package/dist/types/components/StorageBrowser/views/LocationDetailView/types.d.ts +16 -17
  110. package/dist/types/components/StorageBrowser/views/LocationsView/types.d.ts +8 -12
  111. package/dist/types/components/StorageBrowser/views/context/actionViews.d.ts +6 -0
  112. package/dist/types/components/StorageBrowser/views/context/getViews.d.ts +4 -0
  113. package/dist/types/components/StorageBrowser/views/context/index.d.ts +1 -0
  114. package/dist/types/components/StorageBrowser/views/context/primaryViews.d.ts +6 -0
  115. package/dist/types/components/StorageBrowser/views/context/types.d.ts +9 -0
  116. package/dist/types/components/StorageBrowser/views/context/views.d.ts +10 -0
  117. package/dist/types/components/StorageBrowser/views/index.d.ts +2 -2
  118. package/dist/types/components/StorageBrowser/views/types.d.ts +22 -0
  119. package/dist/types/components/StorageBrowser/views/useView.d.ts +16 -0
  120. package/dist/types/version.d.ts +1 -1
  121. package/package.json +5 -5
  122. package/dist/esm/components/StorageBrowser/controls/SearchControl.mjs +0 -13
  123. package/dist/esm/components/StorageBrowser/views/LocationActionView/constants.mjs +0 -3
  124. package/dist/esm/components/StorageBrowser/views/LocationActionView/useActionView.mjs +0 -20
  125. package/dist/esm/components/StorageBrowser/views/context.mjs +0 -43
  126. package/dist/types/components/StorageBrowser/actions/createUseAction.d.ts +0 -2
  127. package/dist/types/components/StorageBrowser/actions/types.d.ts +0 -8
  128. package/dist/types/components/StorageBrowser/actions/useAction/index.d.ts +0 -1
  129. package/dist/types/components/StorageBrowser/actions/useAction/useListLocations.d.ts +0 -8
  130. package/dist/types/components/StorageBrowser/controls/SearchControl.d.ts +0 -2
  131. package/dist/types/components/StorageBrowser/views/LocationActionView/constants.d.ts +0 -1
  132. package/dist/types/components/StorageBrowser/views/context.d.ts +0 -16
  133. package/dist/types/components/StorageBrowser/views/createUseView.d.ts +0 -19
  134. /package/dist/esm/components/StorageBrowser/{actions/useAction → useAction}/createEnhancedListHandler.mjs +0 -0
@@ -1,32 +1,37 @@
1
- import { isFunction } from '@aws-amplify/ui';
2
- import '@aws-amplify/storage/internals';
3
- import { deleteHandler } from '../../../actions/handlers/delete.mjs';
4
- import 'aws-amplify/storage';
5
1
  import React__default from 'react';
2
+ import { isFunction } from '@aws-amplify/ui';
6
3
  import '../../../providers/store/location/context.mjs';
7
4
  import '../../../providers/store/files/context.mjs';
8
5
  import '../../../providers/store/actionType/context.mjs';
9
6
  import '../../../providers/store/locationItems/context.mjs';
10
7
  import { useStore } from '../../../providers/store/useStore.mjs';
11
- import { useGetActionInput } from '../../../providers/configuration/context.mjs';
12
- import '@aws-amplify/ui-react-core/elements';
13
- import '../../../actions/configs/context.mjs';
8
+ import '../../../useAction/context.mjs';
9
+ import { useAction } from '../../../useAction/useAction.mjs';
14
10
  import '@aws-amplify/ui-react-core';
11
+ import '@aws-amplify/ui-react-core/elements';
15
12
  import '../../../providers/configuration/credentials/context.mjs';
16
- import { useProcessTasks } from '../../../tasks/useProcessTasks.mjs';
13
+ import '../../../providers/configuration/context.mjs';
14
+ import '@aws-amplify/storage/internals';
15
+ import 'aws-amplify/storage';
16
+ import '../../../actions/configs/context.mjs';
17
17
 
18
18
  const useDeleteView = (options) => {
19
19
  const { onExit: _onExit } = options ?? {};
20
20
  const [{ location, locationItems }, dispatchStoreAction] = useStore();
21
21
  const { fileDataItems } = locationItems;
22
- const { current } = location;
23
- const getInput = useGetActionInput();
24
- const [processState, handleProcess] = useProcessTasks(deleteHandler, fileDataItems, { concurrency: 4 });
22
+ const { current, key } = location;
23
+ const data = React__default.useMemo(() => !fileDataItems
24
+ ? []
25
+ : fileDataItems.map((item) => ({
26
+ ...item,
27
+ key: `${key}${item.fileKey}`,
28
+ })), [fileDataItems, key]);
29
+ const [processState, handleProcess] = useAction('delete', { items: data });
25
30
  const { isProcessing, isProcessingComplete, statusCounts, tasks } = processState;
26
31
  const onActionStart = () => {
27
32
  if (!current)
28
33
  return;
29
- handleProcess({ config: getInput() });
34
+ handleProcess();
30
35
  };
31
36
  const onActionCancel = () => {
32
37
  tasks.forEach((task) => {
@@ -1,28 +1,21 @@
1
1
  import React__default from 'react';
2
- import '../../actions/configs/context.mjs';
3
- import { isDefaultActionViewType } from '../../actions/configs/defaults.mjs';
4
- import '@aws-amplify/storage/internals';
5
- import '@aws-amplify/ui';
6
- import 'aws-amplify/storage';
7
- import '@aws-amplify/ui-react-core';
8
2
  import '../../providers/store/location/context.mjs';
9
3
  import '../../providers/store/files/context.mjs';
10
4
  import '../../providers/store/actionType/context.mjs';
11
5
  import '../../providers/store/locationItems/context.mjs';
12
6
  import { useStore } from '../../providers/store/useStore.mjs';
13
- import { CreateFolderView } from './CreateFolderView/CreateFolderView.mjs';
14
- import '../../providers/configuration/context.mjs';
15
- import '@aws-amplify/ui-react-core/elements';
16
- import '../../providers/configuration/credentials/context.mjs';
17
- import { CopyView } from './CopyView/CopyView.mjs';
18
- import { DeleteView } from './DeleteView/DeleteView.mjs';
19
- import { UploadView } from './UploadView/UploadView.mjs';
7
+ import { useActionViews } from '../context/actionViews.mjs';
20
8
 
21
9
  const LocationActionView = ({ type, ...props }) => {
22
10
  const [{ actionType = type }] = useStore();
23
- if (!isDefaultActionViewType(actionType))
24
- return null;
25
- return (React__default.createElement(React__default.Fragment, null, actionType === 'createFolder' ? (React__default.createElement(CreateFolderView, { ...props })) : actionType === 'delete' ? (React__default.createElement(DeleteView, { ...props })) : actionType === 'copy' ? (React__default.createElement(CopyView, { ...props })) : (React__default.createElement(UploadView, { ...props }))));
11
+ const views = useActionViews().action;
12
+ const ActionView = actionType
13
+ ? views[actionType]
14
+ : undefined;
15
+ if (ActionView) {
16
+ return React__default.createElement(ActionView, { ...props });
17
+ }
18
+ return null;
26
19
  };
27
20
 
28
21
  export { LocationActionView };
@@ -1,85 +1,80 @@
1
1
  import React__default from 'react';
2
- import '../../../actions/configs/context.mjs';
3
- import '@aws-amplify/storage/internals';
4
2
  import { isUndefined } from '@aws-amplify/ui';
5
- import { isFileTooBig } from '../../../validators/isFileTooBig.mjs';
6
- import { uploadHandler } from '../../../actions/handlers/upload.mjs';
7
- import '@aws-amplify/ui-react-core';
8
- import { useGetActionInput } from '../../../providers/configuration/context.mjs';
9
- import '@aws-amplify/ui-react-core/elements';
10
- import '../../../providers/configuration/credentials/context.mjs';
11
3
  import '../../../providers/store/location/context.mjs';
12
4
  import '../../../providers/store/files/context.mjs';
13
5
  import '../../../providers/store/actionType/context.mjs';
14
6
  import '../../../providers/store/locationItems/context.mjs';
15
7
  import { useStore } from '../../../providers/store/useStore.mjs';
16
- import { useProcessTasks } from '../../../tasks/useProcessTasks.mjs';
17
- import { DEFAULT_ACTION_CONCURRENCY } from '../constants.mjs';
8
+ import '../../../useAction/context.mjs';
9
+ import { useAction } from '../../../useAction/useAction.mjs';
10
+ import '@aws-amplify/ui-react-core';
11
+ import '@aws-amplify/ui-react-core/elements';
12
+ import '../../../providers/configuration/credentials/context.mjs';
13
+ import '../../../providers/configuration/context.mjs';
14
+ import '@aws-amplify/storage/internals';
15
+ import { isFileTooBig } from '../../../validators/isFileTooBig.mjs';
16
+ import 'aws-amplify/storage';
17
+ import '../../../actions/configs/context.mjs';
18
18
  import { DEFAULT_OVERWRITE_ENABLED } from './constants.mjs';
19
19
 
20
20
  const useUploadView = (options) => {
21
21
  const { onExit: _onExit } = options ?? {};
22
- const getInput = useGetActionInput();
23
22
  const [{ files, location }, dispatchStoreAction] = useStore();
24
- const { current, key } = location;
25
- const { invalidFiles, validFiles } = React__default.useMemo(() => (files ?? [])?.reduce((curr, file) => {
26
- if (isFileTooBig(file.file)) {
23
+ const { current } = location;
24
+ const [isOverwritingEnabled, setIsOverwritingEnabled] = React__default.useState(DEFAULT_OVERWRITE_ENABLED);
25
+ const filesData = React__default.useMemo(() => (files ?? [])?.reduce((curr, item) => {
26
+ if (isFileTooBig(item.file)) {
27
27
  curr.invalidFiles = isUndefined(curr.invalidFiles)
28
- ? [file]
29
- : curr.invalidFiles.concat(file);
28
+ ? [item]
29
+ : curr.invalidFiles.concat(item);
30
30
  }
31
31
  else {
32
32
  curr.validFiles = isUndefined(curr.validFiles)
33
- ? [file]
34
- : curr.validFiles.concat(file);
33
+ ? [item]
34
+ : curr.validFiles.concat(item);
35
+ const parsedFileItem = {
36
+ ...item,
37
+ key: `${location.key}${item.key}`,
38
+ };
39
+ curr.data = curr.data.concat({
40
+ ...parsedFileItem,
41
+ preventOverwrite: !isOverwritingEnabled,
42
+ });
35
43
  }
36
44
  return curr;
37
- }, {}), [files]);
38
- const [isOverwritingEnabled, setIsOverwritingEnabled] = React__default.useState(DEFAULT_OVERWRITE_ENABLED);
39
- const [{ isProcessing, isProcessingComplete, statusCounts, tasks }, handleProcess,] = useProcessTasks(uploadHandler, validFiles, {
40
- concurrency: DEFAULT_ACTION_CONCURRENCY,
41
- });
42
- const onDropFiles = React__default.useCallback((files) => {
45
+ }, { invalidFiles: undefined, validFiles: undefined, data: [] }), [files, isOverwritingEnabled, location.key]);
46
+ const { data, invalidFiles } = filesData;
47
+ const [{ isProcessing, isProcessingComplete, statusCounts, tasks }, handleUploads,] = useAction('upload', { items: data });
48
+ const onDropFiles = (files) => {
43
49
  if (files) {
44
50
  dispatchStoreAction({ type: 'ADD_FILE_ITEMS', files });
45
51
  }
46
- }, [dispatchStoreAction]);
47
- const onSelectFiles = React__default.useCallback((type) => {
52
+ };
53
+ const onSelectFiles = (type) => {
48
54
  dispatchStoreAction({ type: 'SELECT_FILES', selectionType: type });
49
- }, [dispatchStoreAction]);
50
- const onActionStart = React__default.useCallback(() => {
55
+ };
56
+ const onActionStart = () => {
51
57
  invalidFiles?.forEach((file) => {
52
58
  dispatchStoreAction({ type: 'REMOVE_FILE_ITEM', id: file.id });
53
59
  });
54
- handleProcess({
55
- config: getInput(),
56
- destinationPrefix: key,
57
- options: { preventOverwrite: !isOverwritingEnabled },
58
- });
59
- }, [
60
- isOverwritingEnabled,
61
- key,
62
- getInput,
63
- handleProcess,
64
- invalidFiles,
65
- dispatchStoreAction,
66
- ]);
67
- const onActionCancel = React__default.useCallback(() => {
60
+ handleUploads();
61
+ };
62
+ const onActionCancel = () => {
68
63
  tasks.forEach((task) => task.cancel?.());
69
- }, [tasks]);
70
- const onActionExit = React__default.useCallback(() => {
64
+ };
65
+ const onActionExit = () => {
71
66
  // clear files state
72
67
  dispatchStoreAction({ type: 'RESET_FILE_ITEMS' });
73
68
  // clear selected action
74
69
  dispatchStoreAction({ type: 'RESET_ACTION_TYPE' });
75
70
  _onExit?.(current);
76
- }, [dispatchStoreAction, _onExit, current]);
77
- const onToggleOverwrite = React__default.useCallback(() => {
71
+ };
72
+ const onToggleOverwrite = () => {
78
73
  setIsOverwritingEnabled((prev) => !prev);
79
- }, []);
80
- const onTaskRemove = React__default.useCallback(({ data }) => {
74
+ };
75
+ const onTaskRemove = ({ data }) => {
81
76
  dispatchStoreAction({ type: 'REMOVE_FILE_ITEM', id: data.id });
82
- }, [dispatchStoreAction]);
77
+ };
83
78
  return {
84
79
  isProcessing,
85
80
  isProcessingComplete,
@@ -1,10 +1,8 @@
1
1
  import { humanFileSize } from '@aws-amplify/ui';
2
- import '../../actions/configs/context.mjs';
3
2
  import '@aws-amplify/storage/internals';
4
3
  import { isFileDataItem, isFileItem } from '../../actions/handlers/utils.mjs';
5
4
  import 'aws-amplify/storage';
6
- import 'react';
7
- import '@aws-amplify/ui-react-core';
5
+ import '../../actions/configs/context.mjs';
8
6
  import { getActionIcon } from './getActionIcon.mjs';
9
7
  import { getFileTypeDisplayValue } from './getFileTypeDisplayValue.mjs';
10
8
  import { getPercentValue } from './getPercentValue.mjs';
@@ -118,7 +116,9 @@ const getActionViewTableData = ({ tasks, displayText, isProcessing, locationKey,
118
116
  type: 'number',
119
117
  content: {
120
118
  value: progress,
121
- displayValue: `${getPercentValue(progress ?? 0)}%`,
119
+ displayValue: `${getPercentValue(
120
+ // Default progress to 100% if progress value is unavailable but status is recognized as complete
121
+ progress ?? status === 'COMPLETE' ? 1 : 0)}%`,
122
122
  },
123
123
  };
124
124
  }
@@ -152,4 +152,4 @@ const getActionViewTableData = ({ tasks, displayText, isProcessing, locationKey,
152
152
  return { headers, rows };
153
153
  };
154
154
 
155
- export { getActionViewTableData, getProgressHeader };
155
+ export { getActionViewTableData };
@@ -11,7 +11,7 @@ import { LoadingIndicatorControl } from '../../controls/LoadingIndicatorControl.
11
11
  import { MessageControl } from '../../controls/MessageControl.mjs';
12
12
  import { NavigationControl } from '../../controls/NavigationControl.mjs';
13
13
  import { PaginationControl } from '../../controls/PaginationControl.mjs';
14
- import { SearchControl } from '../../controls/SearchControl.mjs';
14
+ import { SearchFieldControl } from '../../controls/SearchFieldControl.mjs';
15
15
  import { SearchSubfoldersToggleControl } from '../../controls/SearchSubfoldersToggleControl.mjs';
16
16
  import { TitleControl } from '../../controls/TitleControl.mjs';
17
17
  import { useLocationDetailView } from './useLocationDetailView.mjs';
@@ -27,7 +27,7 @@ const LocationDetailView = ({ className, ...props }) => {
27
27
  React__default.createElement(TitleControl, null),
28
28
  React__default.createElement(ViewElement, { className: `${STORAGE_BROWSER_BLOCK}__controls` },
29
29
  React__default.createElement(ViewElement, { className: `${STORAGE_BROWSER_BLOCK}__search` },
30
- React__default.createElement(SearchControl, null),
30
+ React__default.createElement(SearchFieldControl, null),
31
31
  React__default.createElement(SearchSubfoldersToggleControl, null)),
32
32
  React__default.createElement(PaginationControl, null),
33
33
  React__default.createElement(DataRefreshControl, null),
@@ -49,7 +49,7 @@ LocationDetailView.Message = MessageControl;
49
49
  LocationDetailView.Navigation = NavigationControl;
50
50
  LocationDetailView.Pagination = PaginationControl;
51
51
  LocationDetailView.Refresh = DataRefreshControl;
52
- LocationDetailView.Search = SearchControl;
52
+ LocationDetailView.Search = SearchFieldControl;
53
53
  LocationDetailView.SearchSubfoldersToggle = SearchSubfoldersToggleControl;
54
54
  LocationDetailView.Title = TitleControl;
55
55
 
@@ -6,11 +6,14 @@ import { getLocationDetailViewTableData } from './getLocationDetailViewTableData
6
6
 
7
7
  function LocationDetailViewProvider({ children, ...props }) {
8
8
  const { LocationDetailView: { loadingIndicatorLabel, searchSubfoldersToggleLabel, selectFileLabel, selectAllFilesLabel, searchPlaceholder, searchSubmitLabel, searchClearLabel, getActionListItemLabel, getDateDisplayValue, getTitle, getListItemsResultMessage, }, } = useDisplayText();
9
- const { actions, page, pageItems, hasNextPage, highestPageVisited, isLoading, isSearchingSubfolders, location, areAllFilesSelected, fileDataItems, hasFiles, hasError, hasDownloadError, message, downloadErrorMessage, searchQuery, hasExhaustedSearch, onActionSelect, onDropFiles, onRefresh, onPaginate, onDownload, onNavigate, onNavigateHome, onSelect, onSelectAll, onSearch, onSearchQueryChange, onSearchClear, onToggleSearchSubfolders, } = props;
10
- const actionsWithDisplayText = actions.map((item) => ({
9
+ const { actionItems, page, pageItems, hasNextPage, highestPageVisited, isLoading, isSearchSubfoldersEnabled, location, fileDataItems, hasError, hasDownloadError, message, downloadErrorMessage, searchQuery, hasExhaustedSearch, onActionSelect, onDropFiles, onRefresh, onPaginate, onDownload, onNavigate, onNavigateHome, onSelect, onToggleSelectAll, onSearch, onSearchQueryChange, onSearchClear, onToggleSearchSubfolders, } = props;
10
+ const actionsWithDisplayText = actionItems.map((item) => ({
11
11
  ...item,
12
12
  label: getActionListItemLabel(item.label),
13
13
  }));
14
+ const fileItems = pageItems.filter((item) => item.type === 'FILE');
15
+ const areAllFilesSelected = fileDataItems?.length === fileItems.length;
16
+ const hasFiles = fileItems.length > 0;
14
17
  const messageControlContent = getListItemsResultMessage({
15
18
  isLoading,
16
19
  items: pageItems,
@@ -18,20 +21,21 @@ function LocationDetailViewProvider({ children, ...props }) {
18
21
  hasExhaustedSearch,
19
22
  message: hasError ? message : downloadErrorMessage,
20
23
  });
21
- const isNoActionAvailable = !Array.isArray(actions) || actions?.every((action) => action.isHidden);
24
+ const isActionsListDisabled = isLoading ||
25
+ !actionItems?.length ||
26
+ actionItems.every(({ isHidden }) => isHidden);
22
27
  return (React__default.createElement(ControlsContextProvider, { data: {
23
28
  actions: actionsWithDisplayText,
24
- isActionsListDisabled: isLoading || isNoActionAvailable,
29
+ isActionsListDisabled,
25
30
  isDataRefreshDisabled: isLoading,
26
31
  isLoading,
27
- isSearchingSubfolders,
32
+ isSearchingSubfolders: isSearchSubfoldersEnabled,
28
33
  loadingIndicatorLabel,
29
34
  location,
30
35
  paginationData: {
31
36
  page,
32
37
  hasNextPage,
33
38
  highestPageVisited,
34
- onPaginate,
35
39
  },
36
40
  searchPlaceholder,
37
41
  searchSubfoldersToggleLabel,
@@ -50,11 +54,11 @@ function LocationDetailViewProvider({ children, ...props }) {
50
54
  onDownload,
51
55
  onNavigate,
52
56
  onSelect,
53
- onSelectAll,
57
+ onSelectAll: onToggleSelectAll,
54
58
  }),
55
59
  title: getTitle(location),
56
60
  message: messageControlContent,
57
- }, onActionSelect: onActionSelect, onDropFiles: onDropFiles, onNavigate: onNavigate, onNavigateHome: onNavigateHome, onRefresh: onRefresh, onSearch: onSearch, onSearchQueryChange: onSearchQueryChange, onSearchClear: onSearchClear, onToggleSearchSubfolders: onToggleSearchSubfolders }, children));
61
+ }, onActionSelect: onActionSelect, onDropFiles: onDropFiles, onNavigate: onNavigate, onNavigateHome: onNavigateHome, onPaginate: onPaginate, onRefresh: onRefresh, onSearch: onSearch, onSearchQueryChange: onSearchQueryChange, onSearchClear: onSearchClear, onToggleSearchSubfolders: onToggleSearchSubfolders }, children));
58
62
  }
59
63
 
60
64
  export { LocationDetailViewProvider };
@@ -2,6 +2,7 @@ import '@aws-amplify/storage/internals';
2
2
  import { createFileDataItem } from '../../../actions/handlers/utils.mjs';
3
3
  import '@aws-amplify/ui';
4
4
  import 'aws-amplify/storage';
5
+ import '../../../actions/configs/context.mjs';
5
6
  import { getFileRowContent } from './getFileRowContent.mjs';
6
7
  import { getFolderRowContent } from './getFolderRowContent.mjs';
7
8
  import { LOCATION_DETAIL_VIEW_HEADERS } from './constants.mjs';
@@ -1,52 +1,43 @@
1
1
  import React__default from 'react';
2
2
  import { isUndefined, isFunction } from '@aws-amplify/ui';
3
- import { useDataState } from '@aws-amplify/ui-react-core';
4
3
  import { usePaginate } from '../hooks/usePaginate.mjs';
5
4
  import '../../providers/store/location/context.mjs';
6
5
  import '../../providers/store/files/context.mjs';
7
6
  import '../../providers/store/actionType/context.mjs';
8
7
  import '../../providers/store/locationItems/context.mjs';
9
8
  import { useStore } from '../../providers/store/useStore.mjs';
10
- import '../../actions/configs/context.mjs';
11
- import { defaultActionViewConfigs } from '../../actions/configs/defaults.mjs';
12
9
  import '@aws-amplify/storage/internals';
13
- import { downloadHandler } from '../../actions/handlers/download.mjs';
14
- import { listLocationItemsHandler } from '../../actions/handlers/listLocationItems.mjs';
15
10
  import 'aws-amplify/storage';
16
- import { createEnhancedListHandler } from '../../actions/useAction/createEnhancedListHandler.mjs';
17
- import { useGetActionInput } from '../../providers/configuration/context.mjs';
18
- import '@aws-amplify/ui-react-core/elements';
19
- import '../../providers/configuration/credentials/context.mjs';
11
+ import { useActionConfigs } from '../../actions/configs/context.mjs';
12
+ import '../../useAction/context.mjs';
13
+ import { useAction } from '../../useAction/useAction.mjs';
14
+ import { useList } from '../../useAction/useList.mjs';
20
15
  import { useSearch } from '../hooks/useSearch.mjs';
21
- import { useProcessTasks } from '../../tasks/useProcessTasks.mjs';
22
16
 
23
17
  const DEFAULT_PAGE_SIZE = 100;
24
18
  const DEFAULT_LIST_OPTIONS = {
25
19
  delimiter: '/',
26
20
  pageSize: DEFAULT_PAGE_SIZE,
27
21
  };
28
- const listLocationItemsAction = createEnhancedListHandler(listLocationItemsHandler);
29
- const getDownloadErrorMessageFromFailedDownloadTask = (tasks) => {
30
- if (!tasks.length) {
31
- return undefined;
32
- }
33
- return `Failed to download ${tasks[0].data.fileKey ?? tasks[0].data.key} due to error: ${tasks[0].message}.`;
22
+ const getDownloadErrorMessageFromFailedDownloadTask = (task) => {
23
+ if (!task)
24
+ return;
25
+ return `Failed to download ${task.data.fileKey ?? task.data.key} due to error: ${task.message}.`;
34
26
  };
35
27
  const useLocationDetailView = (options) => {
36
- const getConfig = useGetActionInput();
37
28
  const { initialValues, onExit, onNavigate } = options ?? {};
38
29
  const listOptionsRef = React__default.useRef({
39
30
  ...DEFAULT_LIST_OPTIONS,
40
31
  ...initialValues,
41
32
  });
42
33
  const listOptions = listOptionsRef.current;
43
- const [{ location, locationItems }, dispatchStoreAction] = useStore();
34
+ const [{ location, locationItems, actionType }, dispatchStoreAction] = useStore();
44
35
  const { current, key } = location;
45
36
  const { permissions, prefix } = current ?? {};
46
37
  const { fileDataItems } = locationItems;
47
38
  const hasInvalidPrefix = isUndefined(prefix);
48
- const [downloadTaskResult, handleDownload] = useProcessTasks(downloadHandler);
49
- const [{ data, isLoading, hasError, message }, handleList] = useDataState(listLocationItemsAction, { items: [], nextToken: undefined });
39
+ const [{ task }, handleDownload] = useAction('download');
40
+ const [{ data, isLoading, hasError, message }, handleList] = useList('locationItems');
50
41
  // set up pagination
51
42
  const { items, nextToken, search } = data;
52
43
  const { hasExhaustedSearch = false } = search ?? {};
@@ -56,7 +47,6 @@ const useLocationDetailView = (options) => {
56
47
  return;
57
48
  dispatchStoreAction({ type: 'RESET_LOCATION_ITEMS' });
58
49
  handleList({
59
- config: getConfig(),
60
50
  prefix: key,
61
51
  options: { ...listOptions, nextToken },
62
52
  });
@@ -80,17 +70,16 @@ const useLocationDetailView = (options) => {
80
70
  },
81
71
  };
82
72
  handleReset();
83
- handleList({ config: getConfig(), prefix: key, options: searchOptions });
73
+ handleList({ prefix: key, options: searchOptions });
84
74
  dispatchStoreAction({ type: 'RESET_LOCATION_ITEMS' });
85
75
  };
86
- const { searchQuery, isSearchingSubfolders, onSearchQueryChange, onSearchSubmit, onToggleSearchSubfolders, resetSearch, } = useSearch({ onSearch });
76
+ const { searchQuery, isSearchingSubfolders: isSearchSubfoldersEnabled, onSearchQueryChange, onSearchSubmit, onToggleSearchSubfolders, resetSearch, } = useSearch({ onSearch });
87
77
  const onRefresh = () => {
88
78
  if (hasInvalidPrefix)
89
79
  return;
90
80
  handleReset();
91
81
  resetSearch();
92
82
  handleList({
93
- config: getConfig(),
94
83
  prefix: key,
95
84
  options: { ...listOptions, refresh: true },
96
85
  });
@@ -100,63 +89,60 @@ const useLocationDetailView = (options) => {
100
89
  if (hasInvalidPrefix)
101
90
  return;
102
91
  handleList({
103
- config: getConfig(),
104
92
  prefix: key,
105
93
  options: { ...listOptions, refresh: true },
106
94
  });
107
95
  handleReset();
108
- }, [
109
- handleList,
110
- handleReset,
111
- listOptions,
112
- hasInvalidPrefix,
113
- getConfig,
114
- prefix,
115
- key,
116
- ]);
117
- // Logic for Select All Files functionality
118
- const fileItems = React__default.useMemo(() => pageItems.filter((item) => item.type === 'FILE'), [pageItems]);
119
- const areAllFilesSelected = fileDataItems?.length === fileItems.length;
120
- const shouldShowEmptyMessage = pageItems.length === 0 && !isLoading && !hasError;
121
- const actions = React__default.useMemo(() => {
96
+ }, [handleList, handleReset, listOptions, hasInvalidPrefix, key]);
97
+ const { actionConfigs } = useActionConfigs();
98
+ const actionItems = React__default.useMemo(() => {
122
99
  if (!permissions) {
123
100
  return [];
124
101
  }
125
- return Object.entries(defaultActionViewConfigs).map(([actionType, config]) => {
126
- const { actionsListItemConfig } = config ?? {};
127
- const { icon, hide, disable, label } = actionsListItemConfig ?? {};
128
- return {
129
- actionType,
130
- icon,
131
- isDisabled: isFunction(disable)
132
- ? disable(fileDataItems)
133
- : disable ?? false,
134
- isHidden: isFunction(hide) ? hide(permissions) : hide,
135
- label,
136
- };
137
- });
138
- }, [fileDataItems, permissions]);
102
+ return !actionConfigs
103
+ ? []
104
+ : Object.entries(actionConfigs).map(([type, { actionListItem }]) => {
105
+ const { icon, hide, disable, label } = actionListItem ?? {};
106
+ return {
107
+ actionType: type,
108
+ icon,
109
+ isDisabled: isFunction(disable)
110
+ ? disable(fileDataItems)
111
+ : disable ?? false,
112
+ isHidden: isFunction(hide) ? hide(permissions) : hide,
113
+ label,
114
+ };
115
+ });
116
+ }, [actionConfigs, fileDataItems, permissions]);
139
117
  return {
140
- actions,
118
+ actionItems,
119
+ actionType,
141
120
  page: currentPage,
142
121
  pageItems,
143
122
  location,
144
- areAllFilesSelected,
145
123
  fileDataItems,
146
- hasFiles: fileItems.length > 0,
147
124
  hasError,
148
- hasDownloadError: downloadTaskResult.statusCounts.FAILED > 0,
125
+ hasDownloadError: task?.status === 'FAILED',
149
126
  hasNextPage: hasNextToken,
150
127
  highestPageVisited,
151
128
  message,
152
- downloadErrorMessage: getDownloadErrorMessageFromFailedDownloadTask(downloadTaskResult.tasks),
153
- shouldShowEmptyMessage,
129
+ downloadErrorMessage: getDownloadErrorMessageFromFailedDownloadTask(task),
154
130
  isLoading,
155
- isSearchingSubfolders,
131
+ isSearchSubfoldersEnabled,
156
132
  onPaginate,
157
133
  searchQuery,
158
134
  hasExhaustedSearch,
159
135
  onRefresh,
136
+ onActionExit: () => {
137
+ dispatchStoreAction({ type: 'RESET_ACTION_TYPE' });
138
+ },
139
+ onActionSelect: (nextActionType) => {
140
+ options?.onActionSelect?.(nextActionType);
141
+ dispatchStoreAction({
142
+ type: 'SET_ACTION_TYPE',
143
+ actionType: nextActionType,
144
+ });
145
+ },
160
146
  onNavigate: (location, path) => {
161
147
  onNavigate?.(location, path);
162
148
  resetSearch();
@@ -170,13 +156,12 @@ const useLocationDetailView = (options) => {
170
156
  options?.onActionSelect?.(actionType);
171
157
  },
172
158
  onDownload: (data) => {
173
- handleDownload({ config: getConfig(), data });
159
+ handleDownload({ data });
174
160
  },
175
161
  onNavigateHome: () => {
176
162
  onExit?.();
177
163
  dispatchStoreAction({ type: 'RESET_LOCATION' });
178
164
  handleList({
179
- config: getConfig(),
180
165
  // @todo: prefix should not be required to refresh
181
166
  prefix: prefix ?? '',
182
167
  options: { reset: true },
@@ -184,17 +169,14 @@ const useLocationDetailView = (options) => {
184
169
  dispatchStoreAction({ type: 'RESET_ACTION_TYPE' });
185
170
  dispatchStoreAction({ type: 'RESET_LOCATION_ITEMS' });
186
171
  },
187
- onActionSelect: (actionType) => {
188
- options?.onActionSelect?.(actionType);
189
- dispatchStoreAction({ type: 'SET_ACTION_TYPE', actionType });
190
- },
191
172
  onSelect: (isSelected, fileItem) => {
192
173
  dispatchStoreAction(isSelected
193
174
  ? { type: 'REMOVE_LOCATION_ITEM', id: fileItem.id }
194
175
  : { type: 'SET_LOCATION_ITEMS', items: [fileItem] });
195
176
  },
196
- onSelectAll: () => {
197
- dispatchStoreAction(areAllFilesSelected
177
+ onToggleSelectAll: () => {
178
+ const fileItems = pageItems.filter((item) => item.type === 'FILE');
179
+ dispatchStoreAction(fileItems.length === fileDataItems?.length
198
180
  ? { type: 'RESET_LOCATION_ITEMS' }
199
181
  : { type: 'SET_LOCATION_ITEMS', items: fileItems });
200
182
  },
@@ -204,7 +186,6 @@ const useLocationDetailView = (options) => {
204
186
  if (hasInvalidPrefix)
205
187
  return;
206
188
  handleList({
207
- config: getConfig(),
208
189
  prefix: key,
209
190
  options: { ...listOptions, refresh: true },
210
191
  });
@@ -8,7 +8,7 @@ import { DataTableControl } from '../../controls/DataTableControl.mjs';
8
8
  import { LoadingIndicatorControl } from '../../controls/LoadingIndicatorControl.mjs';
9
9
  import { MessageControl } from '../../controls/MessageControl.mjs';
10
10
  import { PaginationControl } from '../../controls/PaginationControl.mjs';
11
- import { SearchControl } from '../../controls/SearchControl.mjs';
11
+ import { SearchFieldControl } from '../../controls/SearchFieldControl.mjs';
12
12
  import { TitleControl } from '../../controls/TitleControl.mjs';
13
13
  import { LocationsViewProvider } from './LocationsViewProvider.mjs';
14
14
  import { useLocationsView } from './useLocationsView.mjs';
@@ -22,7 +22,7 @@ const LocationsView = ({ className, ...props }) => {
22
22
  React__default.createElement(TitleControl, null),
23
23
  React__default.createElement(ViewElement, { className: `${STORAGE_BROWSER_BLOCK}__controls` },
24
24
  React__default.createElement(ViewElement, { className: `${STORAGE_BROWSER_BLOCK}__search` },
25
- React__default.createElement(SearchControl, null)),
25
+ React__default.createElement(SearchFieldControl, null)),
26
26
  React__default.createElement(PaginationControl, null),
27
27
  React__default.createElement(DataRefreshControl, null)),
28
28
  React__default.createElement(ViewElement, { className: `${STORAGE_BROWSER_BLOCK}__data-table` },
@@ -38,7 +38,7 @@ LocationsView.LocationsTable = DataTableControl;
38
38
  LocationsView.Message = MessageControl;
39
39
  LocationsView.Pagination = PaginationControl;
40
40
  LocationsView.Refresh = DataRefreshControl;
41
- LocationsView.Search = SearchControl;
41
+ LocationsView.Search = SearchFieldControl;
42
42
  LocationsView.Title = TitleControl;
43
43
 
44
44
  export { LocationsView };
@@ -11,7 +11,7 @@ function LocationsViewProvider({ children, ...props }) {
11
11
  const messageControlContent = getListLocationsResultMessage({
12
12
  hasExhaustedSearch,
13
13
  isLoading,
14
- locations: pageItems,
14
+ items: pageItems,
15
15
  hasError,
16
16
  message,
17
17
  });
@@ -28,7 +28,6 @@ function LocationsViewProvider({ children, ...props }) {
28
28
  page,
29
29
  hasNextPage,
30
30
  highestPageVisited,
31
- onPaginate,
32
31
  },
33
32
  title,
34
33
  searchPlaceholder,
@@ -37,7 +36,7 @@ function LocationsViewProvider({ children, ...props }) {
37
36
  searchQuery,
38
37
  message: messageControlContent,
39
38
  isLoading,
40
- }, onSearch: onSearch, onRefresh: onRefresh, onSearchQueryChange: onSearchQueryChange, onSearchClear: onSearchClear }, children));
39
+ }, onPaginate: onPaginate, onRefresh: onRefresh, onSearch: onSearch, onSearchQueryChange: onSearchQueryChange, onSearchClear: onSearchClear }, children));
41
40
  }
42
41
 
43
42
  export { LocationsViewProvider };