@aws-amplify/ui-react-storage 3.4.0 → 3.5.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 (135) hide show
  1. package/dist/browser.js +35 -2
  2. package/dist/{createAmplifyAuthAdapter-BRctUWdR.js → createAmplifyAuthAdapter-BUDNgORg.js} +3045 -2921
  3. package/dist/esm/browser.mjs +2 -0
  4. package/dist/esm/components/FileUploader/utils/getInput.mjs +1 -1
  5. package/dist/esm/components/StorageBrowser/StorageBrowserAmplify.mjs +2 -7
  6. package/dist/esm/components/StorageBrowser/StorageBrowserDefault.mjs +3 -16
  7. package/dist/esm/components/StorageBrowser/actions/configs/context.mjs +4 -9
  8. package/dist/esm/components/StorageBrowser/actions/configs/defaults.mjs +14 -39
  9. package/dist/esm/components/StorageBrowser/actions/configs/utils.mjs +8 -0
  10. package/dist/esm/components/StorageBrowser/actions/handlers/copy.mjs +13 -13
  11. package/dist/esm/components/StorageBrowser/actions/handlers/createFolder.mjs +9 -6
  12. package/dist/esm/components/StorageBrowser/actions/handlers/delete.mjs +9 -7
  13. package/dist/esm/components/StorageBrowser/actions/handlers/download.mjs +7 -11
  14. package/dist/esm/components/StorageBrowser/actions/handlers/listLocationItems.mjs +3 -3
  15. package/dist/esm/components/StorageBrowser/actions/handlers/upload.mjs +11 -7
  16. package/dist/esm/components/StorageBrowser/actions/handlers/utils.mjs +1 -11
  17. package/dist/esm/components/StorageBrowser/adapters/createManagedAuthAdapter/createManagedAuthAdapter.mjs +1 -3
  18. package/dist/esm/components/StorageBrowser/controls/PaginationControl.mjs +3 -3
  19. package/dist/esm/components/StorageBrowser/controls/SearchFieldControl.mjs +12 -0
  20. package/dist/esm/components/StorageBrowser/controls/hooks/usePagination.mjs +9 -0
  21. package/dist/esm/components/StorageBrowser/controls/hooks/useSearchField.mjs +17 -0
  22. package/dist/esm/components/StorageBrowser/createStorageBrowser.mjs +36 -27
  23. package/dist/esm/components/StorageBrowser/displayText/libraries/en/locationDetailView.mjs +6 -0
  24. package/dist/esm/components/StorageBrowser/displayText/libraries/en/locationsView.mjs +2 -2
  25. package/dist/esm/components/StorageBrowser/providers/configuration/createConfigurationProvider.mjs +4 -10
  26. package/dist/esm/components/StorageBrowser/providers/configuration/useGetActionInputCallback.mjs +7 -7
  27. package/dist/esm/components/StorageBrowser/providers/store/locationItems/context.mjs +1 -1
  28. package/dist/esm/components/StorageBrowser/tasks/useProcessTasks.mjs +27 -6
  29. package/dist/esm/components/StorageBrowser/useAction/constants.mjs +4 -0
  30. package/dist/esm/components/StorageBrowser/useAction/context.mjs +8 -0
  31. package/dist/esm/components/StorageBrowser/useAction/useAction.mjs +18 -0
  32. package/dist/esm/components/StorageBrowser/useAction/useHandler.mjs +40 -0
  33. package/dist/esm/components/StorageBrowser/useAction/useList.mjs +19 -0
  34. package/dist/esm/components/StorageBrowser/useAction/useListFolderItems.mjs +23 -0
  35. package/dist/esm/components/StorageBrowser/useAction/useListLocationItems.mjs +23 -0
  36. package/dist/esm/components/StorageBrowser/{actions/useAction → useAction}/useListLocations.mjs +7 -6
  37. package/dist/esm/components/StorageBrowser/useAction/utils.mjs +26 -0
  38. package/dist/esm/components/StorageBrowser/views/LocationActionView/CopyView/CopyView.mjs +3 -3
  39. package/dist/esm/components/StorageBrowser/views/LocationActionView/CopyView/useCopyView.mjs +32 -17
  40. package/dist/esm/components/StorageBrowser/views/LocationActionView/CopyView/useFolders.mjs +12 -17
  41. package/dist/esm/components/StorageBrowser/views/LocationActionView/CreateFolderView/useCreateFolderView.mjs +18 -15
  42. package/dist/esm/components/StorageBrowser/views/LocationActionView/DeleteView/useDeleteView.mjs +17 -12
  43. package/dist/esm/components/StorageBrowser/views/LocationActionView/LocationActionView.mjs +9 -16
  44. package/dist/esm/components/StorageBrowser/views/LocationActionView/UploadView/useUploadView.mjs +44 -49
  45. package/dist/esm/components/StorageBrowser/views/LocationActionView/getActionViewTableData.mjs +2 -4
  46. package/dist/esm/components/StorageBrowser/views/LocationDetailView/LocationDetailView.mjs +3 -3
  47. package/dist/esm/components/StorageBrowser/views/LocationDetailView/LocationDetailViewProvider.mjs +12 -8
  48. package/dist/esm/components/StorageBrowser/views/LocationDetailView/getLocationDetailViewTableData/getLocationDetailViewTableData.mjs +1 -0
  49. package/dist/esm/components/StorageBrowser/views/LocationDetailView/useLocationDetailView.mjs +50 -69
  50. package/dist/esm/components/StorageBrowser/views/LocationsView/LocationsView.mjs +3 -3
  51. package/dist/esm/components/StorageBrowser/views/LocationsView/LocationsViewProvider.mjs +2 -3
  52. package/dist/esm/components/StorageBrowser/views/LocationsView/useLocationsView.mjs +22 -29
  53. package/dist/esm/components/StorageBrowser/views/context/actionViews.mjs +33 -0
  54. package/dist/esm/components/StorageBrowser/views/context/getViews.mjs +32 -0
  55. package/dist/esm/components/StorageBrowser/views/context/primaryViews.mjs +32 -0
  56. package/dist/esm/components/StorageBrowser/views/context/views.mjs +19 -0
  57. package/dist/esm/components/StorageBrowser/views/{createUseView.mjs → useView.mjs} +19 -28
  58. package/dist/esm/version.mjs +1 -1
  59. package/dist/index.js +4 -7
  60. package/dist/styles.css +6 -2
  61. package/dist/types/components/StorageBrowser/actions/configs/context.d.ts +4 -5
  62. package/dist/types/components/StorageBrowser/actions/configs/defaults.d.ts +6 -7
  63. package/dist/types/components/StorageBrowser/actions/configs/index.d.ts +3 -2
  64. package/dist/types/components/StorageBrowser/actions/configs/types.d.ts +39 -69
  65. package/dist/types/components/StorageBrowser/actions/configs/utils.d.ts +2 -0
  66. package/dist/types/components/StorageBrowser/actions/handlers/copy.d.ts +12 -5
  67. package/dist/types/components/StorageBrowser/actions/handlers/createFolder.d.ts +7 -4
  68. package/dist/types/components/StorageBrowser/actions/handlers/delete.d.ts +6 -3
  69. package/dist/types/components/StorageBrowser/actions/handlers/download.d.ts +6 -3
  70. package/dist/types/components/StorageBrowser/actions/handlers/types.d.ts +11 -2
  71. package/dist/types/components/StorageBrowser/actions/handlers/upload.d.ts +8 -4
  72. package/dist/types/components/StorageBrowser/actions/handlers/utils.d.ts +0 -1
  73. package/dist/types/components/StorageBrowser/actions/index.d.ts +2 -4
  74. package/dist/types/components/StorageBrowser/adapters/permissionParsers.d.ts +1 -1
  75. package/dist/types/components/StorageBrowser/composables/ActionsList.d.ts +2 -2
  76. package/dist/types/components/StorageBrowser/controls/SearchFieldControl.d.ts +2 -0
  77. package/dist/types/components/StorageBrowser/controls/hooks/usePagination.d.ts +2 -0
  78. package/dist/types/components/StorageBrowser/controls/hooks/useSearchField.d.ts +2 -0
  79. package/dist/types/components/StorageBrowser/controls/types.d.ts +3 -3
  80. package/dist/types/components/StorageBrowser/createStorageBrowser.d.ts +3 -7
  81. package/dist/types/components/StorageBrowser/displayText/index.d.ts +1 -1
  82. package/dist/types/components/StorageBrowser/displayText/types.d.ts +1 -1
  83. package/dist/types/components/StorageBrowser/index.d.ts +3 -1
  84. package/dist/types/components/StorageBrowser/providers/configuration/index.d.ts +1 -1
  85. package/dist/types/components/StorageBrowser/providers/configuration/types.d.ts +2 -2
  86. package/dist/types/components/StorageBrowser/providers/store/files/types.d.ts +10 -1
  87. package/dist/types/components/StorageBrowser/providers/store/files/utils.d.ts +1 -2
  88. package/dist/types/components/StorageBrowser/tasks/types.d.ts +16 -13
  89. package/dist/types/components/StorageBrowser/tasks/useProcessTasks.d.ts +2 -3
  90. package/dist/types/components/StorageBrowser/types.d.ts +42 -12
  91. package/dist/types/components/StorageBrowser/useAction/constants.d.ts +3 -0
  92. package/dist/types/components/StorageBrowser/useAction/context.d.ts +5 -0
  93. package/dist/types/components/StorageBrowser/{actions/useAction → useAction}/createEnhancedListHandler.d.ts +3 -3
  94. package/dist/types/components/StorageBrowser/useAction/index.d.ts +6 -0
  95. package/dist/types/components/StorageBrowser/useAction/types.d.ts +76 -0
  96. package/dist/types/components/StorageBrowser/useAction/useAction.d.ts +3 -0
  97. package/dist/types/components/StorageBrowser/useAction/useHandler.d.ts +3 -0
  98. package/dist/types/components/StorageBrowser/useAction/useList.d.ts +9 -0
  99. package/dist/types/components/StorageBrowser/useAction/useListFolderItems.d.ts +13 -0
  100. package/dist/types/components/StorageBrowser/useAction/useListLocationItems.d.ts +10 -0
  101. package/dist/types/components/StorageBrowser/useAction/useListLocations.d.ts +8 -0
  102. package/dist/types/components/StorageBrowser/useAction/utils.d.ts +6 -0
  103. package/dist/types/components/StorageBrowser/views/LocationActionView/CopyView/useFolders.d.ts +1 -4
  104. package/dist/types/components/StorageBrowser/views/LocationActionView/CreateFolderView/types.d.ts +2 -2
  105. package/dist/types/components/StorageBrowser/views/LocationActionView/LocationActionView.d.ts +2 -6
  106. package/dist/types/components/StorageBrowser/views/LocationActionView/getActionViewTableData.d.ts +2 -4
  107. package/dist/types/components/StorageBrowser/views/LocationActionView/index.d.ts +6 -6
  108. package/dist/types/components/StorageBrowser/views/LocationActionView/types.d.ts +4 -8
  109. package/dist/types/components/StorageBrowser/views/LocationDetailView/getLocationDetailViewTableData/getLocationDetailViewTableData.d.ts +1 -3
  110. package/dist/types/components/StorageBrowser/views/LocationDetailView/types.d.ts +16 -17
  111. package/dist/types/components/StorageBrowser/views/LocationsView/types.d.ts +8 -12
  112. package/dist/types/components/StorageBrowser/views/context/actionViews.d.ts +6 -0
  113. package/dist/types/components/StorageBrowser/views/context/getViews.d.ts +4 -0
  114. package/dist/types/components/StorageBrowser/views/context/index.d.ts +1 -0
  115. package/dist/types/components/StorageBrowser/views/context/primaryViews.d.ts +6 -0
  116. package/dist/types/components/StorageBrowser/views/context/types.d.ts +9 -0
  117. package/dist/types/components/StorageBrowser/views/context/views.d.ts +10 -0
  118. package/dist/types/components/StorageBrowser/views/index.d.ts +2 -2
  119. package/dist/types/components/StorageBrowser/views/types.d.ts +22 -0
  120. package/dist/types/components/StorageBrowser/views/useView.d.ts +16 -0
  121. package/dist/types/version.d.ts +1 -1
  122. package/package.json +10 -4
  123. package/dist/esm/components/StorageBrowser/controls/SearchControl.mjs +0 -13
  124. package/dist/esm/components/StorageBrowser/views/LocationActionView/constants.mjs +0 -3
  125. package/dist/esm/components/StorageBrowser/views/LocationActionView/useActionView.mjs +0 -20
  126. package/dist/esm/components/StorageBrowser/views/context.mjs +0 -43
  127. package/dist/types/components/StorageBrowser/actions/createUseAction.d.ts +0 -2
  128. package/dist/types/components/StorageBrowser/actions/types.d.ts +0 -8
  129. package/dist/types/components/StorageBrowser/actions/useAction/index.d.ts +0 -1
  130. package/dist/types/components/StorageBrowser/actions/useAction/useListLocations.d.ts +0 -8
  131. package/dist/types/components/StorageBrowser/controls/SearchControl.d.ts +0 -2
  132. package/dist/types/components/StorageBrowser/views/LocationActionView/constants.d.ts +0 -1
  133. package/dist/types/components/StorageBrowser/views/context.d.ts +0 -16
  134. package/dist/types/components/StorageBrowser/views/createUseView.d.ts +0 -19
  135. /package/dist/esm/components/StorageBrowser/{actions/useAction → useAction}/createEnhancedListHandler.mjs +0 -0
@@ -1,22 +1,19 @@
1
1
  import React__default from 'react';
2
- import { usePaginate } from '../hooks/usePaginate.mjs';
3
- import '../../actions/configs/context.mjs';
4
- import '@aws-amplify/storage/internals';
5
- import { createFileDataItemFromLocation } from '../../actions/handlers/utils.mjs';
6
- import '@aws-amplify/ui';
7
- import { downloadHandler } from '../../actions/handlers/download.mjs';
8
- import 'aws-amplify/storage';
9
- import { useListLocations } from '../../actions/useAction/useListLocations.mjs';
10
2
  import '../../providers/store/location/context.mjs';
11
3
  import '../../providers/store/files/context.mjs';
12
4
  import '../../providers/store/actionType/context.mjs';
13
5
  import '../../providers/store/locationItems/context.mjs';
14
6
  import { useStore } from '../../providers/store/useStore.mjs';
7
+ import '../../useAction/context.mjs';
8
+ import { useAction } from '../../useAction/useAction.mjs';
9
+ import { useList } from '../../useAction/useList.mjs';
10
+ import '@aws-amplify/ui';
11
+ import '@aws-amplify/storage/internals';
12
+ import { getFileKey } from '../../actions/handlers/utils.mjs';
13
+ import 'aws-amplify/storage';
14
+ import '../../actions/configs/context.mjs';
15
+ import { usePaginate } from '../hooks/usePaginate.mjs';
15
16
  import { useSearch } from '../hooks/useSearch.mjs';
16
- import { useGetActionInput } from '../../providers/configuration/context.mjs';
17
- import '@aws-amplify/ui-react-core/elements';
18
- import '../../providers/configuration/credentials/context.mjs';
19
- import { useProcessTasks } from '../../tasks/useProcessTasks.mjs';
20
17
 
21
18
  const DEFAULT_EXCLUDE = {
22
19
  exactPermissions: ['delete', 'write'],
@@ -27,11 +24,10 @@ const DEFAULT_LIST_OPTIONS = {
27
24
  pageSize: DEFAULT_PAGE_SIZE,
28
25
  };
29
26
  const useLocationsView = (options) => {
30
- const getConfig = useGetActionInput();
31
- const [state, handleList] = useListLocations();
27
+ const handleDownload = useAction('download')[1];
28
+ const [state, handleList] = useList('locations');
29
+ const dispatchStoreAction = useStore()[1];
32
30
  const { data, message, hasError, isLoading } = state;
33
- const [_, handleDownload] = useProcessTasks(downloadHandler);
34
- const [, dispatchStoreAction] = useStore();
35
31
  const { items, nextToken, search } = data;
36
32
  const hasNextToken = !!nextToken;
37
33
  const { hasExhaustedSearch = false } = search ?? {};
@@ -44,17 +40,13 @@ const useLocationsView = (options) => {
44
40
  const listOptions = listOptionsRef.current;
45
41
  // initial load
46
42
  React__default.useEffect(() => {
47
- handleList({
48
- options: { ...listOptions, refresh: true },
49
- });
43
+ handleList({ options: { ...listOptions, refresh: true } });
50
44
  }, [handleList, listOptions]);
51
45
  // set up pagination
52
46
  const paginateCallback = () => {
53
47
  if (!nextToken)
54
48
  return;
55
- handleList({
56
- options: { ...listOptions, nextToken },
57
- });
49
+ handleList({ options: { ...listOptions, nextToken } });
58
50
  };
59
51
  const { currentPage, onPaginate, handleReset, highestPageVisited, pageItems, } = usePaginate({
60
52
  items,
@@ -77,7 +69,6 @@ const useLocationsView = (options) => {
77
69
  });
78
70
  };
79
71
  const { searchQuery, onSearchQueryChange, onSearchSubmit, resetSearch } = useSearch({ onSearch });
80
- const shouldShowEmptyMessage = pageItems.length === 0 && !isLoading && !hasError;
81
72
  return {
82
73
  isLoading,
83
74
  hasError,
@@ -86,13 +77,17 @@ const useLocationsView = (options) => {
86
77
  hasNextPage: hasNextToken,
87
78
  highestPageVisited,
88
79
  pageItems,
89
- shouldShowEmptyMessage,
90
80
  searchQuery,
91
81
  hasExhaustedSearch,
92
82
  onDownload: (location) => {
83
+ const { prefix: key } = location;
93
84
  handleDownload({
94
- config: getConfig(location),
95
- data: createFileDataItemFromLocation(location),
85
+ data: {
86
+ fileKey: getFileKey(key),
87
+ key,
88
+ id: crypto.randomUUID(),
89
+ },
90
+ location,
96
91
  });
97
92
  },
98
93
  onNavigate: (location) => {
@@ -102,9 +97,7 @@ const useLocationsView = (options) => {
102
97
  onRefresh: () => {
103
98
  resetSearch();
104
99
  handleReset();
105
- handleList({
106
- options: { ...listOptions, refresh: true },
107
- });
100
+ handleList({ options: { ...listOptions, refresh: true } });
108
101
  },
109
102
  onPaginate,
110
103
  onSearch: onSearchSubmit,
@@ -0,0 +1,33 @@
1
+ import React__default from 'react';
2
+ import { UploadView } from '../LocationActionView/UploadView/UploadView.mjs';
3
+ import '@aws-amplify/ui';
4
+ import '../../providers/store/location/context.mjs';
5
+ import '../../providers/store/files/context.mjs';
6
+ import '../../providers/store/actionType/context.mjs';
7
+ import '../../providers/store/locationItems/context.mjs';
8
+ import '../../useAction/context.mjs';
9
+ import '../../providers/configuration/context.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 '@aws-amplify/storage/internals';
14
+ import 'aws-amplify/storage';
15
+ import '../../actions/configs/context.mjs';
16
+ import { CreateFolderView } from '../LocationActionView/CreateFolderView/CreateFolderView.mjs';
17
+ import { CopyView } from '../LocationActionView/CopyView/CopyView.mjs';
18
+ import { DeleteView } from '../LocationActionView/DeleteView/DeleteView.mjs';
19
+
20
+ const DEFAULT_ACTION_VIEWS = {
21
+ createFolder: CreateFolderView,
22
+ copy: CopyView,
23
+ delete: DeleteView,
24
+ upload: UploadView,
25
+ };
26
+ const ActionViewsContext = React__default.createContext({
27
+ action: DEFAULT_ACTION_VIEWS,
28
+ });
29
+ function useActionViews() {
30
+ return React__default.useContext(ActionViewsContext);
31
+ }
32
+
33
+ export { ActionViewsContext, DEFAULT_ACTION_VIEWS, useActionViews };
@@ -0,0 +1,32 @@
1
+ import { capitalize, isObject, isFunction } from '@aws-amplify/ui';
2
+ import { DEFAULT_ACTION_VIEWS } from './actionViews.mjs';
3
+ import { DEFAULT_PRIMARY_VIEWS } from './primaryViews.mjs';
4
+
5
+ const getViews = (views, customConfigs) => {
6
+ const resolvedDefaultActionViews = Object.entries(DEFAULT_ACTION_VIEWS).reduce((output, [actionName, component]) => {
7
+ // use viewName to lookup overrides for default action views
8
+ const viewName = capitalize(`${actionName}View`);
9
+ return {
10
+ ...output,
11
+ [actionName]: (views?.[viewName] ?? component),
12
+ };
13
+ }, {});
14
+ const customActionViews = !isObject(customConfigs)
15
+ ? {}
16
+ : Object.entries(customConfigs).reduce((acc, [key, config]) => {
17
+ // ignore custom actions that are only handlers
18
+ return !isObject(config) || isFunction(config)
19
+ ? acc
20
+ : { ...acc, [key]: views?.[config.viewName] };
21
+ }, {});
22
+ return {
23
+ action: { ...resolvedDefaultActionViews, ...customActionViews },
24
+ primary: {
25
+ LocationActionView: views?.LocationActionView ?? DEFAULT_PRIMARY_VIEWS.LocationActionView,
26
+ LocationDetailView: views?.LocationDetailView ?? DEFAULT_PRIMARY_VIEWS.LocationDetailView,
27
+ LocationsView: views?.LocationsView ?? DEFAULT_PRIMARY_VIEWS.LocationsView,
28
+ },
29
+ };
30
+ };
31
+
32
+ export { getViews };
@@ -0,0 +1,32 @@
1
+ import React__default from 'react';
2
+ import '../LocationActionView/CopyView/CopyView.mjs';
3
+ import '@aws-amplify/ui';
4
+ import '../../providers/store/location/context.mjs';
5
+ import '../../providers/store/files/context.mjs';
6
+ import '../../providers/store/actionType/context.mjs';
7
+ import '../../providers/store/locationItems/context.mjs';
8
+ import '../../useAction/context.mjs';
9
+ import '../../providers/configuration/context.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 '@aws-amplify/storage/internals';
14
+ import 'aws-amplify/storage';
15
+ import '../../actions/configs/context.mjs';
16
+ import '../LocationActionView/CreateFolderView/CreateFolderView.mjs';
17
+ import '../LocationActionView/DeleteView/DeleteView.mjs';
18
+ import { LocationActionView } from '../LocationActionView/LocationActionView.mjs';
19
+ import '../LocationActionView/UploadView/UploadView.mjs';
20
+ import { LocationDetailView } from '../LocationDetailView/LocationDetailView.mjs';
21
+ import { LocationsView } from '../LocationsView/LocationsView.mjs';
22
+
23
+ const DEFAULT_PRIMARY_VIEWS = {
24
+ LocationActionView: LocationActionView,
25
+ LocationDetailView: LocationDetailView,
26
+ LocationsView: LocationsView,
27
+ };
28
+ const PrimaryViewsContext = React__default.createContext({
29
+ primary: DEFAULT_PRIMARY_VIEWS,
30
+ });
31
+
32
+ export { DEFAULT_PRIMARY_VIEWS, PrimaryViewsContext };
@@ -0,0 +1,19 @@
1
+ import React__default from 'react';
2
+ import { getViews } from './getViews.mjs';
3
+ import { ActionViewsContext } from './actionViews.mjs';
4
+ import { PrimaryViewsContext } from './primaryViews.mjs';
5
+
6
+ function ViewsProvider({ children, views, actions, }) {
7
+ const { custom } = actions ?? {};
8
+ const value = React__default.useMemo(() => getViews(views, custom), [custom, views]);
9
+ return (React__default.createElement(PrimaryViewsContext.Provider, { value: value },
10
+ React__default.createElement(ActionViewsContext.Provider, { value: value }, children)));
11
+ }
12
+ function useViews() {
13
+ return {
14
+ primary: React__default.useContext(PrimaryViewsContext).primary,
15
+ action: React__default.useContext(ActionViewsContext).action,
16
+ };
17
+ }
18
+
19
+ export { ViewsProvider, useViews };
@@ -4,44 +4,35 @@ 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/UploadView/UploadView.mjs';
8
- import { useUploadView } from './LocationActionView/UploadView/useUploadView.mjs';
9
- import { useActionView } from './LocationActionView/useActionView.mjs';
10
7
  import 'react';
11
- import '../actions/configs/context.mjs';
12
- import '@aws-amplify/storage/internals';
13
- import '@aws-amplify/ui';
14
- import 'aws-amplify/storage';
15
- import '@aws-amplify/ui-react-core';
16
8
  import '../providers/store/location/context.mjs';
17
9
  import '../providers/store/files/context.mjs';
18
10
  import '../providers/store/actionType/context.mjs';
19
11
  import '../providers/store/locationItems/context.mjs';
12
+ import './context/actionViews.mjs';
13
+ import './LocationActionView/UploadView/UploadView.mjs';
14
+ import { useUploadView } from './LocationActionView/UploadView/useUploadView.mjs';
15
+ import '@aws-amplify/ui';
20
16
  import './LocationsView/LocationsView.mjs';
21
17
  import { useLocationsView } from './LocationsView/useLocationsView.mjs';
22
18
  import './LocationDetailView/LocationDetailView.mjs';
23
19
  import { useLocationDetailView } from './LocationDetailView/useLocationDetailView.mjs';
24
20
 
25
- const DEFAULT_USE_VIEWS = {
26
- CopyView: useCopyView,
27
- CreateFolderView: useCreateFolderView,
28
- DeleteView: useDeleteView,
29
- LocationDetailView: useLocationDetailView,
30
- LocationsView: useLocationsView,
31
- UploadView: useUploadView,
21
+ const USE_VIEW_HOOKS = {
22
+ Copy: useCopyView,
23
+ CreateFolder: useCreateFolderView,
24
+ Delete: useDeleteView,
25
+ LocationDetail: useLocationDetailView,
26
+ Locations: useLocationsView,
27
+ Upload: useUploadView,
32
28
  };
33
- const isDefaultUseViewName = (viewName) => Object.keys(DEFAULT_USE_VIEWS).some((key) => key === viewName);
34
- const createUseView = (configs) => {
35
- const hooks = Object.values(configs).reduce((out, { componentName }) => ({
36
- ...out,
37
- [componentName.slice(0, -4)]: isDefaultUseViewName(componentName)
38
- ? DEFAULT_USE_VIEWS[componentName]
39
- : useActionView,
40
- }), {});
41
- return function useView(type) {
42
- // todo: add assertion here
43
- return hooks[type](type);
44
- };
29
+ const isUseViewType = (value) => !!USE_VIEW_HOOKS?.[value];
30
+ // @ts-expect-error
31
+ const useView = (type) => {
32
+ if (!isUseViewType(type)) {
33
+ throw new Error(`Value of \`${type}\` cannot be used to index \`useView\``);
34
+ }
35
+ return USE_VIEW_HOOKS[type]();
45
36
  };
46
37
 
47
- export { createUseView };
38
+ export { useView };
@@ -1,3 +1,3 @@
1
- const VERSION = '3.4.0';
1
+ const VERSION = '3.5.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 createAmplifyAuthAdapter = require('./createAmplifyAuthAdapter-BRctUWdR.js');
12
+ var createAmplifyAuthAdapter = require('./createAmplifyAuthAdapter-BUDNgORg.js');
13
13
  require('@aws-amplify/storage/internals');
14
14
  require('@aws-amplify/ui-react-core/elements');
15
15
  require('aws-amplify');
@@ -329,7 +329,7 @@ const getInput = ({ accessLevel, file, key, onProgress, path, processFile, useAc
329
329
  else {
330
330
  const { identityId } = await auth.fetchAuthSession();
331
331
  const resolvedPath = `${hasCallbackPath ? path({ identityId }) : path}${processedKey}`;
332
- inputResult = { data: file, path: resolvedPath, options };
332
+ inputResult = { data, path: resolvedPath, options };
333
333
  }
334
334
  return inputResult;
335
335
  };
@@ -551,7 +551,7 @@ function FilePicker$1({ children, className = ui.ComponentClassName.FileUploader
551
551
  return (React__namespace["default"].createElement(uiReact.Button, { ...props, className: className, size: size }, children));
552
552
  }
553
553
 
554
- const VERSION = '3.4.0';
554
+ const VERSION = '3.5.0';
555
555
 
556
556
  const logger$1 = ui.getLogger('Storage');
557
557
  const MISSING_REQUIRED_PROPS_MESSAGE$1 = '`FileUploader` requires a `maxFileCount` prop to be provided.';
@@ -1055,10 +1055,7 @@ const StorageManager = Object.assign({}, StorageManagerBase, {
1055
1055
  });
1056
1056
 
1057
1057
  const StorageBrowser = ({ views, displayText, }) => {
1058
- const { StorageBrowser } = React__namespace["default"].useRef(createAmplifyAuthAdapter.createStorageBrowser({
1059
- components: createAmplifyAuthAdapter.componentsDefault,
1060
- config: createAmplifyAuthAdapter.createAmplifyAuthAdapter(),
1061
- })).current;
1058
+ const { StorageBrowser } = React__namespace["default"].useRef(createAmplifyAuthAdapter.createStorageBrowser({ config: createAmplifyAuthAdapter.createAmplifyAuthAdapter() })).current;
1062
1059
  return React__namespace["default"].createElement(StorageBrowser, { views: views, displayText: displayText });
1063
1060
  };
1064
1061
 
package/dist/styles.css CHANGED
@@ -6842,12 +6842,16 @@ html[dir=rtl] .amplify-field-group__inner-start {
6842
6842
  flex-direction: row;
6843
6843
  align-items: flex-start;
6844
6844
  gap: var(--amplify-components-ai-conversation-form-gap);
6845
- padding: var(--amplify-components-ai-conversation-form-padding);
6846
6845
  }
6847
6846
  .amplify-ai-conversation__form__dropzone {
6848
6847
  text-align: initial;
6849
6848
  border: none;
6849
+ padding: var(--amplify-components-ai-conversation-form-padding);
6850
+ }
6851
+ .amplify-ai-conversation__form__error {
6850
6852
  padding: 0;
6853
+ padding-block-start: var(--amplify-components-ai-conversation-attachment-list-padding-block-start);
6854
+ gap: var(--amplify-components-ai-conversation-attachment-gap);
6851
6855
  }
6852
6856
  .amplify-ai-conversation__attachment {
6853
6857
  display: flex;
@@ -6867,7 +6871,7 @@ html[dir=rtl] .amplify-field-group__inner-start {
6867
6871
  flex-direction: row;
6868
6872
  flex-wrap: wrap;
6869
6873
  gap: var(--amplify-components-ai-conversation-attachment-list-gap);
6870
- padding-block-start: var(--amplify-components-ai-conversation-attachment-padding-block-start);
6874
+ padding-block-start: var(--amplify-components-ai-conversation-attachment-list-padding-block-start);
6871
6875
  }
6872
6876
  .amplify-ai-conversation__attachment__image {
6873
6877
  width: var(--amplify-components-ai-conversation-attachment-image-width);
@@ -1,14 +1,13 @@
1
1
  /// <reference types="react" />
2
- import { ActionConfigs } from './types';
2
+ import { ActionViewConfigs } from './types';
3
3
  export interface ActionConfigsProviderProps {
4
- actions?: ActionConfigs;
4
+ actionConfigs: ActionViewConfigs;
5
5
  children?: React.ReactNode;
6
6
  }
7
7
  export declare const useActionConfigs: (params?: {
8
8
  errorMessage?: string | undefined;
9
9
  } | undefined) => {
10
- actions?: ActionConfigs | undefined;
10
+ actionConfigs: ActionViewConfigs | undefined;
11
11
  }, ActionConfigsProvider: import("react").ComponentType<import("react").PropsWithChildren<{
12
- actions?: ActionConfigs | undefined;
12
+ actionConfigs: ActionViewConfigs | undefined;
13
13
  }>>;
14
- export declare function useActionConfig<T extends keyof ActionConfigs>(type?: T): ActionConfigs[T];
@@ -1,24 +1,23 @@
1
- import { CopyActionConfig, CreateFolderActionConfig, DeleteActionConfig, ListLocationItemsActionConfig, ListLocationsActionConfig, UploadActionConfig } from './types';
1
+ import { CopyActionConfig, CreateFolderActionConfig, DeleteActionConfig, 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
- export declare const listLocationItemsActionConfig: ListLocationItemsActionConfig;
6
- export declare const listLocationsActionConfig: ListLocationsActionConfig;
7
5
  export declare const uploadActionConfig: UploadActionConfig;
8
6
  export declare const defaultActionViewConfigs: {
9
7
  copy: CopyActionConfig;
10
8
  createFolder: CreateFolderActionConfig;
9
+ download: import("../handlers").DownloadHandler;
11
10
  delete: DeleteActionConfig;
12
11
  upload: UploadActionConfig;
13
12
  };
14
13
  export type DefaultActionViewType = keyof typeof defaultActionViewConfigs;
15
- export declare const DEFAULT_ACTION_VIEW_TYPES: ("upload" | "copy" | "delete" | "createFolder")[];
16
- export declare const isDefaultActionViewType: (value?: string) => value is "upload" | "copy" | "delete" | "createFolder";
14
+ export declare const DEFAULT_ACTION_VIEW_TYPES: ("upload" | "copy" | "delete" | "download" | "createFolder")[];
15
+ export declare const isDefaultActionViewType: (value?: string) => value is "upload" | "copy" | "delete" | "download" | "createFolder";
17
16
  export declare const defaultActionConfigs: {
18
- listLocationItems: ListLocationItemsActionConfig;
19
- listLocations: ListLocationsActionConfig;
17
+ listLocationItems: import("../handlers").ListLocationItemsHandler;
20
18
  copy: CopyActionConfig;
21
19
  createFolder: CreateFolderActionConfig;
20
+ download: import("../handlers").DownloadHandler;
22
21
  delete: DeleteActionConfig;
23
22
  upload: UploadActionConfig;
24
23
  };
@@ -1,3 +1,4 @@
1
- export { ActionConfigsProvider, ActionConfigsProviderProps, useActionConfig, } from './context';
2
- export { defaultActionConfigs, defaultActionViewConfigs, isDefaultActionViewType, } from './defaults';
1
+ export { ActionConfigsProvider, ActionConfigsProviderProps, useActionConfigs, } from './context';
2
+ export { defaultActionConfigs, defaultActionViewConfigs, DefaultActionViewType, isDefaultActionViewType, } from './defaults';
3
3
  export * from './types';
4
+ export { getActionConfigs } from './utils';
@@ -1,38 +1,15 @@
1
1
  import { StorageBrowserIconType } from '../../context/elements';
2
- import { LocationPermissions } from '../../actions';
3
- import { ListLocationsHandler, ListLocationItemsHandler, LocationItemData, LocationItemType, UploadHandler, CreateFolderHandler, DeleteHandler, CopyHandler, TaskHandler } from '../handlers';
2
+ import { CopyHandler, CreateFolderHandler, DeleteHandler, DownloadHandler, ListLocationItemsHandler, ListLocations, LocationItemData, LocationPermissions, TaskData, TaskHandler, TaskHandlerInput, TaskHandlerOutput, UploadHandler } from '../handlers';
3
+ export type ActionHandler<TData = any, RValue = any> = TaskHandler<TaskHandlerInput<TData & TaskData>, TaskHandlerOutput<RValue>>;
4
4
  type StringWithoutSpaces<T extends string> = Exclude<T, ` ${string}` | `${string} ` | `${string} ${string}`>;
5
- export type ComponentName = Capitalize<`${string}View`>;
6
- type ActionName = StringWithoutSpaces<string>;
7
- /**
8
- * native OS file picker type. to restrict selectable file types, define the picker types
9
- * followed by accepted file types as strings
10
- * @example
11
- * ```ts
12
- * type JPEGOnly = ['FOLDER', '.jpeg'];
13
- * ```
14
- */
15
- export type SelectionType = LocationItemType | [LocationItemType, ...string[]];
16
- export interface ActionConfigTemplate<T> {
17
- /**
18
- * The name of the component associated with the action
19
- */
20
- componentName: ComponentName;
21
- /**
22
- * action handler
23
- */
24
- handler: T;
25
- }
5
+ export type ViewName = Capitalize<`${string}View`>;
6
+ export type ActionName<T extends string = string> = StringWithoutSpaces<T>;
26
7
  export interface ActionListItemConfig {
27
8
  /**
28
9
  * conditionally disable item selection based on currently selected values
29
10
  * @default false
30
11
  */
31
12
  disable?: (selectedValues: LocationItemData[] | undefined) => boolean;
32
- /**
33
- * open native OS file picker with associated selection type on item select
34
- */
35
- fileSelection?: SelectionType;
36
13
  /**
37
14
  * conditionally render list item based on location permission
38
15
  * @default false
@@ -51,61 +28,54 @@ export interface ActionListItemConfig {
51
28
  * defines an action to be included in the actions list of the `LocationDetailView` with
52
29
  * a dedicated subcomponent of the `LocationActionView`
53
30
  */
54
- export interface TaskActionConfig<T extends TaskHandler = TaskHandler> extends ActionConfigTemplate<T> {
55
- /**
56
- * configure action list item behavior. provide multiple configs
57
- * to create additional list items for a single action
58
- */
59
- actionsListItemConfig?: ActionListItemConfig;
31
+ export interface ActionViewConfig<T extends ActionHandler = ActionHandler, K extends ViewName = ViewName> {
60
32
  /**
61
- * whether the provided `handler` allow inflight cancellation
62
- * @default false
33
+ * action handler
63
34
  */
64
- isCancelable?: boolean;
35
+ handler: T;
65
36
  /**
66
- * show per task progress in the action task table
67
- * @default false
37
+ * The view slot name associated with the action provided on the
38
+ * `StorageBrowser` through the `views` prop
68
39
  */
69
- includeProgress?: boolean;
40
+ viewName: K;
70
41
  /**
71
- * default display name value displayed on action view
42
+ * configure action list item behavior. provide multiple configs
43
+ * to create additional list items for a single action
72
44
  */
73
- displayName: string;
45
+ actionListItem: ActionListItemConfig;
74
46
  }
75
- export interface ListActionConfig<T> extends ActionConfigTemplate<T> {
47
+ export interface UploadActionConfig extends ActionViewConfig<UploadHandler, 'UploadView'> {
76
48
  }
77
- export interface UploadActionConfig extends TaskActionConfig<UploadHandler> {
78
- componentName: 'UploadView';
49
+ export interface DeleteActionConfig extends ActionViewConfig<DeleteHandler, 'DeleteView'> {
79
50
  }
80
- export interface DeleteActionConfig extends TaskActionConfig<DeleteHandler> {
81
- componentName: 'DeleteView';
51
+ export interface CopyActionConfig extends ActionViewConfig<CopyHandler, 'CopyView'> {
82
52
  }
83
- export interface CopyActionConfig extends TaskActionConfig<CopyHandler> {
84
- componentName: 'CopyView';
53
+ export interface CreateFolderActionConfig extends ActionViewConfig<CreateFolderHandler, 'CreateFolderView'> {
85
54
  }
86
- export interface CreateFolderActionConfig extends TaskActionConfig<CreateFolderHandler> {
87
- componentName: 'CreateFolderView';
55
+ export interface ListActionConfig<T> {
56
+ /**
57
+ * action handler
58
+ */
59
+ handler: T;
88
60
  }
89
- export interface ListLocationsActionConfig extends ListActionConfig<ListLocationsHandler> {
90
- componentName: 'LocationsView';
91
- displayName: string;
61
+ export interface DefaultActionConfigs {
62
+ createFolder?: CreateFolderActionConfig;
63
+ listLocationItems?: ListLocationItemsHandler;
64
+ upload?: UploadActionConfig;
65
+ delete?: DeleteActionConfig;
66
+ download?: DownloadHandler;
67
+ copy?: CopyActionConfig;
92
68
  }
93
- export interface ListLocationItemsActionConfig extends ListActionConfig<ListLocationItemsHandler> {
94
- componentName: 'LocationDetailView';
95
- displayName: (bucket: string | undefined, prefix: string | undefined) => string;
69
+ export interface ExtendedDefaultActionConfigs extends Required<DefaultActionConfigs> {
70
+ listLocations: ListLocations;
96
71
  }
97
- export interface DefaultActionConfigs {
98
- ListLocationItems: ListLocationItemsActionConfig;
99
- ListLocations: ListLocationsActionConfig;
100
- CreateFolder: CreateFolderActionConfig;
101
- Upload: UploadActionConfig;
102
- Delete: DeleteActionConfig;
103
- Copy: CopyActionConfig;
72
+ export type CustomActionConfigs = Record<ActionName, ActionViewConfig | ActionHandler>;
73
+ /**
74
+ * @internal @unstable
75
+ */
76
+ export interface ExtendedActionConfigs {
77
+ default?: ExtendedDefaultActionConfigs;
78
+ custom?: CustomActionConfigs;
104
79
  }
105
- export type DefaultActionKey = keyof DefaultActionConfigs;
106
- export type ActionConfigs<ActionsKeys extends ActionName = ActionName> = Record<ActionsKeys, ListLocationItemsActionConfig | ListLocationsActionConfig | CreateFolderActionConfig | UploadActionConfig | TaskActionConfig>;
107
- export type ResolveActionHandler<T> = T extends TaskActionConfig<infer K> | ListActionConfig<infer K> ? K : never;
108
- export type ResolveActionHandlers<T> = {
109
- [K in keyof T]: ResolveActionHandler<T[K]>;
110
- };
80
+ export type ActionViewConfigs<ActionsKeys extends ActionName = ActionName> = Record<ActionsKeys, ActionViewConfig>;
111
81
  export {};
@@ -0,0 +1,2 @@
1
+ import { ExtendedActionConfigs, ActionViewConfigs } from './types';
2
+ export declare const getActionConfigs: (configs: ExtendedActionConfigs) => ActionViewConfigs;
@@ -1,10 +1,17 @@
1
- import { FileDataItem, TaskHandler, TaskHandlerInput, TaskHandlerOptions, TaskHandlerOutput } from './types';
2
- export interface CopyHandlerData extends FileDataItem {
1
+ import { TaskData, TaskHandler, TaskHandlerInput, TaskHandlerOptions, TaskHandlerOutput } from './types';
2
+ export interface CopyHandlerData extends TaskData {
3
+ sourceKey: string;
4
+ eTag?: string;
5
+ fileKey: string;
6
+ lastModified: Date;
3
7
  }
4
- export interface CopyHandlerInput extends TaskHandlerInput<CopyHandlerData, TaskHandlerOptions> {
5
- destinationPrefix: string;
8
+ export interface CopyHandlerInput extends TaskHandlerInput<CopyHandlerData, TaskHandlerOptions<{
9
+ key: string;
10
+ }>> {
6
11
  }
7
- export interface CopyHandlerOutput extends TaskHandlerOutput {
12
+ export interface CopyHandlerOutput extends TaskHandlerOutput<{
13
+ key: string;
14
+ }> {
8
15
  }
9
16
  export interface CopyHandler extends TaskHandler<CopyHandlerInput, CopyHandlerOutput> {
10
17
  }
@@ -1,13 +1,16 @@
1
1
  import { TaskData, TaskHandler, TaskHandlerInput, TaskHandlerOutput, TaskHandlerOptions } from './types';
2
2
  export interface CreateFolderHandlerData extends TaskData {
3
- }
4
- export interface CreateFolderHandlerOptions extends TaskHandlerOptions {
5
3
  preventOverwrite?: boolean;
6
4
  }
5
+ export interface CreateFolderHandlerOptions extends TaskHandlerOptions<{
6
+ key: string;
7
+ }> {
8
+ }
7
9
  export interface CreateFolderHandlerInput extends TaskHandlerInput<CreateFolderHandlerData, CreateFolderHandlerOptions> {
8
- destinationPrefix: string;
9
10
  }
10
- export interface CreateFolderHandlerOutput extends TaskHandlerOutput {
11
+ export interface CreateFolderHandlerOutput extends TaskHandlerOutput<{
12
+ key: string;
13
+ }> {
11
14
  }
12
15
  export interface CreateFolderHandler extends TaskHandler<CreateFolderHandlerInput, CreateFolderHandlerOutput> {
13
16
  }
@@ -1,11 +1,14 @@
1
- import { TaskHandler, TaskHandlerOptions, TaskHandlerInput, TaskHandlerOutput, FileDataItem } from './types';
1
+ import { TaskHandler, TaskHandlerOptions, TaskHandlerInput, TaskHandlerOutput, TaskData } from './types';
2
2
  export interface DeleteHandlerOptions extends TaskHandlerOptions {
3
3
  }
4
- export interface DeleteHandlerData extends FileDataItem {
4
+ export interface DeleteHandlerData extends TaskData {
5
+ fileKey: string;
5
6
  }
6
7
  export interface DeleteHandlerInput extends TaskHandlerInput<DeleteHandlerData, DeleteHandlerOptions> {
7
8
  }
8
- export interface DeleteHandlerOutput extends TaskHandlerOutput {
9
+ export interface DeleteHandlerOutput extends TaskHandlerOutput<{
10
+ key: string;
11
+ }> {
9
12
  }
10
13
  export interface DeleteHandler extends TaskHandler<DeleteHandlerInput, DeleteHandlerOutput> {
11
14
  }