@aws-amplify/ui-react-storage 3.9.1 → 3.9.2

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 (124) hide show
  1. package/dist/browser.js +3 -1
  2. package/dist/{createAmplifyAuthAdapter-Cf4yJo1e.js → createAmplifyAuthAdapter-BJjOYxQA.js} +533 -377
  3. package/dist/esm/browser.mjs +6 -0
  4. package/dist/esm/components/StorageBrowser/StorageBrowserAmplify.mjs +1 -0
  5. package/dist/esm/components/StorageBrowser/StorageBrowserDefault.mjs +3 -2
  6. package/dist/esm/components/StorageBrowser/actions/configs/defaults.mjs +10 -12
  7. package/dist/esm/components/StorageBrowser/actions/handlers/constants.mjs +4 -1
  8. package/dist/esm/components/StorageBrowser/actions/handlers/copy.mjs +4 -1
  9. package/dist/esm/components/StorageBrowser/actions/handlers/createFolder.mjs +4 -3
  10. package/dist/esm/components/StorageBrowser/actions/handlers/defaults.mjs +17 -0
  11. package/dist/esm/components/StorageBrowser/actions/handlers/delete.mjs +4 -1
  12. package/dist/esm/components/StorageBrowser/actions/handlers/download.mjs +4 -1
  13. package/dist/esm/components/StorageBrowser/actions/handlers/upload.mjs +6 -11
  14. package/dist/esm/components/StorageBrowser/actions/handlers/utils.mjs +4 -3
  15. package/dist/esm/components/StorageBrowser/adapters/createManagedAuthAdapter/createManagedAuthAdapter.mjs +2 -1
  16. package/dist/esm/components/StorageBrowser/componentsDefault.mjs +4 -4
  17. package/dist/esm/components/StorageBrowser/createStorageBrowser.mjs +7 -1
  18. package/dist/esm/components/StorageBrowser/displayText/libraries/en/shared.mjs +0 -1
  19. package/dist/esm/components/StorageBrowser/displayText/libraries/en/uploadView.mjs +3 -2
  20. package/dist/esm/components/StorageBrowser/displayText/utils.mjs +7 -0
  21. package/dist/esm/components/StorageBrowser/providers/store/locationItems/context.mjs +1 -0
  22. package/dist/esm/components/StorageBrowser/tasks/useProcessTasks.mjs +20 -22
  23. package/dist/esm/components/StorageBrowser/useAction/useAction.mjs +14 -7
  24. package/dist/esm/components/StorageBrowser/useAction/useHandler.mjs +26 -32
  25. package/dist/esm/components/StorageBrowser/useAction/useList.mjs +0 -1
  26. package/dist/esm/components/StorageBrowser/views/LocationActionView/CopyView/CopyViewProvider.mjs +6 -9
  27. package/dist/esm/components/StorageBrowser/views/LocationActionView/CopyView/useCopyView.mjs +1 -0
  28. package/dist/esm/components/StorageBrowser/views/LocationActionView/CopyView/useFolders.mjs +11 -13
  29. package/dist/esm/components/StorageBrowser/views/LocationActionView/CreateFolderView/useCreateFolderView.mjs +1 -0
  30. package/dist/esm/components/StorageBrowser/views/LocationActionView/DeleteView/DeleteViewProvider.mjs +6 -9
  31. package/dist/esm/components/StorageBrowser/views/LocationActionView/DeleteView/useDeleteView.mjs +1 -0
  32. package/dist/esm/components/StorageBrowser/views/LocationActionView/UploadView/UploadViewProvider.mjs +14 -12
  33. package/dist/esm/components/StorageBrowser/views/LocationActionView/UploadView/useUploadView.mjs +2 -1
  34. package/dist/esm/components/StorageBrowser/views/LocationDetailView/getLocationDetailViewTableData/getLocationDetailViewTableData.mjs +1 -0
  35. package/dist/esm/components/StorageBrowser/views/LocationDetailView/useLocationDetailView.mjs +7 -11
  36. package/dist/esm/components/StorageBrowser/views/LocationsView/useLocationsView.mjs +5 -5
  37. package/dist/esm/components/StorageBrowser/views/context/actionViews.mjs +3 -2
  38. package/dist/esm/components/StorageBrowser/views/context/getViews.mjs +4 -1
  39. package/dist/esm/components/StorageBrowser/views/context/primaryViews.mjs +3 -2
  40. package/dist/esm/components/StorageBrowser/views/hooks/usePaginate.mjs +19 -21
  41. package/dist/esm/components/StorageBrowser/views/hooks/useResolveTableData/useResolveTableData.mjs +15 -0
  42. package/dist/esm/components/StorageBrowser/views/useView.mjs +6 -7
  43. package/dist/esm/components/StorageBrowser/views/utils/tableResolvers/constants.mjs +18 -0
  44. package/dist/esm/components/StorageBrowser/views/utils/tableResolvers/copyResolvers.mjs +82 -0
  45. package/dist/esm/components/StorageBrowser/views/utils/tableResolvers/deleteResolvers.mjs +82 -0
  46. package/dist/esm/components/StorageBrowser/views/utils/tableResolvers/uploadResolvers.mjs +112 -0
  47. package/dist/esm/components/StorageBrowser/views/utils/tableResolvers/utils.mjs +49 -0
  48. package/dist/esm/version.mjs +1 -1
  49. package/dist/index.js +1 -1
  50. package/dist/types/components/StorageBrowser/ComponentsProvider.d.ts +4 -1
  51. package/dist/types/components/StorageBrowser/actions/configs/types.d.ts +41 -2
  52. package/dist/types/components/StorageBrowser/actions/handlers/constants.d.ts +1 -0
  53. package/dist/types/components/StorageBrowser/actions/handlers/copy.d.ts +4 -7
  54. package/dist/types/components/StorageBrowser/actions/handlers/createFolder.d.ts +1 -3
  55. package/dist/types/components/StorageBrowser/actions/handlers/defaults.d.ts +15 -0
  56. package/dist/types/components/StorageBrowser/actions/handlers/delete.d.ts +2 -2
  57. package/dist/types/components/StorageBrowser/actions/handlers/index.d.ts +1 -0
  58. package/dist/types/components/StorageBrowser/actions/handlers/listLocations.d.ts +4 -12
  59. package/dist/types/components/StorageBrowser/actions/handlers/types.d.ts +26 -17
  60. package/dist/types/components/StorageBrowser/actions/handlers/upload.d.ts +1 -4
  61. package/dist/types/components/StorageBrowser/actions/handlers/utils.d.ts +2 -2
  62. package/dist/types/components/StorageBrowser/actions/index.d.ts +1 -1
  63. package/dist/types/components/StorageBrowser/componentsDefault.d.ts +2 -2
  64. package/dist/types/components/StorageBrowser/createStorageBrowser.d.ts +6 -0
  65. package/dist/types/components/StorageBrowser/displayText/index.d.ts +1 -0
  66. package/dist/types/components/StorageBrowser/displayText/types.d.ts +16 -5
  67. package/dist/types/components/StorageBrowser/displayText/utils.d.ts +3 -0
  68. package/dist/types/components/StorageBrowser/index.d.ts +4 -3
  69. package/dist/types/components/StorageBrowser/providers/configuration/createConfigurationProvider.d.ts +1 -1
  70. package/dist/types/components/StorageBrowser/providers/configuration/types.d.ts +3 -3
  71. package/dist/types/components/StorageBrowser/providers/index.d.ts +1 -1
  72. package/dist/types/components/StorageBrowser/providers/store/actionType/types.d.ts +4 -0
  73. package/dist/types/components/StorageBrowser/providers/store/files/types.d.ts +1 -4
  74. package/dist/types/components/StorageBrowser/providers/store/index.d.ts +1 -1
  75. package/dist/types/components/StorageBrowser/providers/store/location/context.d.ts +6 -0
  76. package/dist/types/components/StorageBrowser/storage-internal.d.ts +1 -1
  77. package/dist/types/components/StorageBrowser/tasks/index.d.ts +1 -1
  78. package/dist/types/components/StorageBrowser/tasks/types.d.ts +41 -23
  79. package/dist/types/components/StorageBrowser/tasks/useProcessTasks.d.ts +3 -3
  80. package/dist/types/components/StorageBrowser/types.d.ts +191 -15
  81. package/dist/types/components/StorageBrowser/useAction/types.d.ts +60 -32
  82. package/dist/types/components/StorageBrowser/useAction/useHandler.d.ts +4 -3
  83. package/dist/types/components/StorageBrowser/useAction/useList.d.ts +10 -7
  84. package/dist/types/components/StorageBrowser/views/LocationActionView/CopyView/types.d.ts +5 -0
  85. package/dist/types/components/StorageBrowser/views/LocationActionView/UploadView/types.d.ts +2 -2
  86. package/dist/types/components/StorageBrowser/views/LocationActionView/types.d.ts +4 -4
  87. package/dist/types/components/StorageBrowser/views/LocationDetailView/index.d.ts +1 -1
  88. package/dist/types/components/StorageBrowser/views/LocationsView/index.d.ts +1 -1
  89. package/dist/types/components/StorageBrowser/views/context/getViews.d.ts +2 -2
  90. package/dist/types/components/StorageBrowser/views/context/views.d.ts +2 -2
  91. package/dist/types/components/StorageBrowser/views/hooks/usePaginate.d.ts +8 -8
  92. package/dist/types/components/StorageBrowser/views/hooks/useResolveTableData/index.d.ts +2 -0
  93. package/dist/types/components/StorageBrowser/views/hooks/useResolveTableData/types.d.ts +26 -0
  94. package/dist/types/components/StorageBrowser/views/hooks/useResolveTableData/useResolveTableData.d.ts +6 -0
  95. package/dist/types/components/StorageBrowser/views/types.d.ts +1 -1
  96. package/dist/types/components/StorageBrowser/views/useView.d.ts +16 -13
  97. package/dist/types/components/StorageBrowser/views/utils/index.d.ts +1 -0
  98. package/dist/types/components/StorageBrowser/views/utils/tableResolvers/__testUtils__/tasks.d.ts +23 -0
  99. package/dist/types/components/StorageBrowser/views/utils/tableResolvers/constants.d.ts +16 -0
  100. package/dist/types/components/StorageBrowser/views/utils/tableResolvers/copyResolvers.d.ts +3 -0
  101. package/dist/types/components/StorageBrowser/views/utils/tableResolvers/deleteResolvers.d.ts +3 -0
  102. package/dist/types/components/StorageBrowser/views/utils/tableResolvers/index.d.ts +3 -0
  103. package/dist/types/components/StorageBrowser/views/utils/tableResolvers/types.d.ts +36 -0
  104. package/dist/types/components/StorageBrowser/views/utils/tableResolvers/uploadResolvers.d.ts +3 -0
  105. package/dist/types/components/StorageBrowser/views/utils/tableResolvers/utils.d.ts +12 -0
  106. package/dist/types/version.d.ts +1 -1
  107. package/package.json +5 -5
  108. package/dist/esm/components/StorageBrowser/views/LocationActionView/CopyView/utils.mjs +0 -3
  109. package/dist/esm/components/StorageBrowser/views/LocationActionView/DeleteView/utils.mjs +0 -3
  110. package/dist/esm/components/StorageBrowser/views/LocationActionView/UploadView/utils.mjs +0 -5
  111. package/dist/esm/components/StorageBrowser/views/LocationActionView/getActionIcon.mjs +0 -25
  112. package/dist/esm/components/StorageBrowser/views/LocationActionView/getActionViewTableData.mjs +0 -141
  113. package/dist/esm/components/StorageBrowser/views/LocationActionView/getDefaultActionViewHeaders.mjs +0 -24
  114. package/dist/esm/components/StorageBrowser/views/LocationActionView/getFileTypeDisplayValue.mjs +0 -5
  115. package/dist/esm/components/StorageBrowser/views/LocationActionView/getPercentValue.mjs +0 -3
  116. package/dist/types/components/StorageBrowser/displayText/en.d.ts +0 -9
  117. package/dist/types/components/StorageBrowser/views/LocationActionView/CopyView/utils.d.ts +0 -3
  118. package/dist/types/components/StorageBrowser/views/LocationActionView/DeleteView/utils.d.ts +0 -3
  119. package/dist/types/components/StorageBrowser/views/LocationActionView/UploadView/utils.d.ts +0 -3
  120. package/dist/types/components/StorageBrowser/views/LocationActionView/getActionIcon.d.ts +0 -3
  121. package/dist/types/components/StorageBrowser/views/LocationActionView/getActionViewTableData.d.ts +0 -14
  122. package/dist/types/components/StorageBrowser/views/LocationActionView/getDefaultActionViewHeaders.d.ts +0 -5
  123. package/dist/types/components/StorageBrowser/views/LocationActionView/getFileTypeDisplayValue.d.ts +0 -1
  124. package/dist/types/components/StorageBrowser/views/LocationActionView/getPercentValue.d.ts +0 -1
@@ -0,0 +1,112 @@
1
+ import { capitalize } from '@aws-amplify/ui';
2
+ import { STATUS_ICONS, STATUS_LABELS } from './constants.mjs';
3
+ import { getCellName, getUploadCellFolder, getFileType, getFileSize, getUploadCellProgress } from './utils.mjs';
4
+
5
+ const UPLOAD_TABLE_KEYS = [
6
+ 'name',
7
+ 'folder',
8
+ 'type',
9
+ 'size',
10
+ 'status',
11
+ 'progress',
12
+ 'cancel',
13
+ ];
14
+ const getUploadCellKey = ({ key, item, }) => `${key}-${item.data.id}`;
15
+ const name = (data) => {
16
+ const key = getUploadCellKey(data);
17
+ const { item } = data;
18
+ const icon = STATUS_ICONS[item.status];
19
+ const text = getCellName(item.data.key);
20
+ return { key, type: 'text', content: { icon, text } };
21
+ };
22
+ const folder = (data) => {
23
+ const key = getUploadCellKey(data);
24
+ const text = getUploadCellFolder(data.item);
25
+ return { key, type: 'text', content: { text } };
26
+ };
27
+ const type = (data) => {
28
+ const key = getUploadCellKey(data);
29
+ const { item } = data;
30
+ const text = getFileType(getCellName(item.data.key));
31
+ return { key, type: 'text', content: { text } };
32
+ };
33
+ const size = (data) => {
34
+ const key = getUploadCellKey(data);
35
+ const { size: value } = data.item.data.file;
36
+ const displayValue = getFileSize(value);
37
+ return { key, type: 'number', content: { value, displayValue } };
38
+ };
39
+ const status = (data) => {
40
+ const key = getUploadCellKey(data);
41
+ const { item: { status }, props: { displayText }, } = data;
42
+ const text = displayText[STATUS_LABELS[status]];
43
+ return { key, type: 'text', content: { text } };
44
+ };
45
+ const progress = (data) => {
46
+ const key = getUploadCellKey(data);
47
+ const content = getUploadCellProgress(data.item);
48
+ return { key, type: 'number', content };
49
+ };
50
+ const cancel = (data) => {
51
+ const key = getUploadCellKey(data);
52
+ const { item, props } = data;
53
+ const { cancel, data: taskData, status, progress } = item;
54
+ const { isMultipartUpload, isProcessing, onTaskRemove } = props;
55
+ const isQueued = status === 'QUEUED';
56
+ const isPending = status === 'PENDING';
57
+ // cancelability is dependent on differing conditions for multipart and single part uploads
58
+ let isCancelable;
59
+ if (isMultipartUpload(taskData.file)) {
60
+ // signals MPU complete has been reached
61
+ const hasUploadedAllBytes = progress === 1;
62
+ // MPU allows cancel when tasks processing has begun and task is queued or
63
+ // pending but not yet reached MPU complete
64
+ isCancelable =
65
+ isProcessing && (isQueued || isPending) && !hasUploadedAllBytes;
66
+ }
67
+ else {
68
+ // single part upload allows cancel when processing has begun and task is queued
69
+ isCancelable = isProcessing && isQueued;
70
+ }
71
+ // all uploads are removable prior to processing start. Including `isQueued`
72
+ // ensures that `isRemovable` is `false` on all tasks processing complete
73
+ const isRemovable = !isProcessing && isQueued;
74
+ const isDisabled = !isRemovable && !isCancelable;
75
+ const ariaLabel = `${isRemovable ? 'Remove' : 'Cancel'} item: ${getCellName(item.data.key)}`;
76
+ // resolve to `undefined` if not cancelable or removable
77
+ const onClick = !isCancelable && !isRemovable
78
+ ? undefined
79
+ : () => {
80
+ if (isRemovable) {
81
+ onTaskRemove?.(item);
82
+ // do not run cancel handler on remove
83
+ return;
84
+ }
85
+ if (!!cancel && isCancelable)
86
+ cancel();
87
+ };
88
+ const content = { ariaLabel, isDisabled, onClick, icon: 'cancel' };
89
+ return { key, type: 'button', content };
90
+ };
91
+ const UPLOAD_CELL_RESOLVERS = {
92
+ cancel,
93
+ folder,
94
+ name,
95
+ progress,
96
+ size,
97
+ status,
98
+ type,
99
+ };
100
+ const UPLOAD_TABLE_RESOLVERS = {
101
+ getCell: (data) => UPLOAD_CELL_RESOLVERS[data.key](data),
102
+ getHeader: ({ key, props: { displayText } }) => {
103
+ const text = displayText[`tableColumn${capitalize(key)}Header`];
104
+ if (key === 'cancel') {
105
+ return { key, type: 'text', content: { text } };
106
+ }
107
+ return { key, type: 'sort', content: { label: text } };
108
+ },
109
+ getRowKey: ({ item }) => item.data.id,
110
+ };
111
+
112
+ export { UPLOAD_TABLE_KEYS, UPLOAD_TABLE_RESOLVERS };
@@ -0,0 +1,49 @@
1
+ import { humanFileSize } from '@aws-amplify/ui';
2
+
3
+ const getFileType = (value, fallback = '') => value.lastIndexOf('.') !== -1
4
+ ? value.slice(value.lastIndexOf('.') + 1)
5
+ : fallback;
6
+ const getCellName = (value) =>
7
+ // `value.split` always returns an array with at least one entry
8
+ // ensruing `.pop()` will always return a string
9
+ value.split('/').pop();
10
+ const getUploadCellFolder = ({ data: { file: { webkitRelativePath }, }, }, fallback = '-') => webkitRelativePath
11
+ ? webkitRelativePath.slice(0, webkitRelativePath.lastIndexOf('/') + 1)
12
+ : fallback;
13
+ const getCopyCellFolder = ({ data: { fileKey, sourceKey }, }) => sourceKey.slice(0, -fileKey.length);
14
+ const getDeleteCellFolder = ({ data: { fileKey, key }, }) => key.slice(0, -fileKey.length);
15
+ const getUploadCellProgress = ({ progress, status, }) => {
16
+ // prefer `progress` if available, 1 if status is complete, default 0
17
+ const value = progress ?? (status === 'COMPLETE' ? 1 : 0);
18
+ const displayValue = `${Math.round(value * 100)}%`;
19
+ return { displayValue, value };
20
+ };
21
+ const getFileSize = (value, fallback = '-') => (!value ? fallback : humanFileSize(value, true));
22
+ const getCopyOrDeleteCancelCellContent = (data) => {
23
+ const { item, props } = data;
24
+ const { cancel, status } = item;
25
+ const { isProcessing, onTaskRemove } = props;
26
+ const isQueued = status === 'QUEUED';
27
+ // a task is removable prior to processing start. Including `isQueued` ensures
28
+ // that `isRemovable` is `false` on all tasks processing complete
29
+ const isRemovable = isQueued && !isProcessing;
30
+ // a task is cancelable while processing is true, and the task has a cancel handler
31
+ const isCancelable = isProcessing && !!cancel;
32
+ const ariaLabel = `${isRemovable ? 'Remove' : 'Cancel'} item: ${getCellName(item.data.fileKey)}`;
33
+ const isDisabled = !isRemovable && !isCancelable;
34
+ // resolve to `undefined` if not cancelable or removable
35
+ const onClick = !isCancelable && !isRemovable
36
+ ? undefined
37
+ : () => {
38
+ if (isRemovable) {
39
+ onTaskRemove?.(item);
40
+ // do not run cancel handler on remove
41
+ return;
42
+ }
43
+ if (isCancelable)
44
+ cancel();
45
+ };
46
+ return { ariaLabel, isDisabled, onClick, icon: 'cancel' };
47
+ };
48
+
49
+ export { getCellName, getCopyCellFolder, getCopyOrDeleteCancelCellContent, getDeleteCellFolder, getFileSize, getFileType, getUploadCellFolder, getUploadCellProgress };
@@ -1,3 +1,3 @@
1
- const VERSION = '3.9.1';
1
+ const VERSION = '3.9.2';
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-Cf4yJo1e.js');
12
+ var createAmplifyAuthAdapter = require('./createAmplifyAuthAdapter-BJjOYxQA.js');
13
13
  require('@aws-amplify/storage/internals');
14
14
  require('@aws-amplify/ui-react-core/elements');
15
15
  require('aws-amplify');
@@ -1,7 +1,10 @@
1
1
  import React from 'react';
2
2
  import { Composables } from './composables';
3
3
  import { StorageBrowserElements } from './context/elements';
4
- export interface Components extends Partial<Composables> {
4
+ /**
5
+ * Override/Custom component slots
6
+ */
7
+ export interface StorageBrowserComponents extends Partial<Composables> {
5
8
  }
6
9
  export interface ComponentsProviderProps {
7
10
  children?: React.ReactNode;
@@ -1,9 +1,44 @@
1
1
  import { StorageBrowserIconType } from '../../context/elements';
2
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>>;
3
+ /**
4
+ * Utility type representing the function signature of `StorageBrowser` action handlers. First
5
+ * positional generic adds additional properties to `data` parameter, second positional
6
+ * generic specifies optional return value provided to `options.onSuccess` callback and
7
+ * `Task.value`.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * interface MyData {
12
+ * user: {
13
+ * name: string
14
+ * id: string
15
+ * };
16
+ * }
17
+ *
18
+ * interface MyReturnValue {
19
+ * link: string;
20
+ * }
21
+ *
22
+ * type CreateDownloadLink = ActionHandler<MyData, MyReturnValue>;
23
+ *
24
+ * const createDownloadLink: CreateDownloadLink = (input) => {
25
+ * // `config` is provided to handler, includes location data, credentials
26
+ * const { config, data } = input;
27
+ * const { user } = data;
28
+ *
29
+ * const result = generatePresignedUrl(user, credentials).then((res) => ({
30
+ * status: 'COMPLETE' as const,
31
+ * value: { link: res.url.toString() },
32
+ * }));
33
+ *
34
+ * return { result };
35
+ * }
36
+ * ```
37
+ */
38
+ export type ActionHandler<TData = any, TValue = any> = TaskHandler<TaskHandlerInput<TData & TaskData>, TaskHandlerOutput<TValue>>;
4
39
  type StringWithoutSpaces<T extends string> = Exclude<T, ` ${string}` | `${string} ` | `${string} ${string}`>;
5
40
  export type ViewName = Capitalize<`${string}View`>;
6
- export type ActionName<T extends string = string> = StringWithoutSpaces<T>;
41
+ export type ActionName<K extends string = string> = StringWithoutSpaces<K>;
7
42
  export interface ActionListItemConfig {
8
43
  /**
9
44
  * conditionally disable item selection based on currently selected values
@@ -69,6 +104,10 @@ export interface DefaultActionConfigs {
69
104
  export interface ExtendedDefaultActionConfigs extends Required<DefaultActionConfigs> {
70
105
  listLocations: ListLocations;
71
106
  }
107
+ /**
108
+ * Accepts either an `ActionViewConfig` for creation of an action list item and corresponding
109
+ * view slot or an action handler for standalone action usage
110
+ */
72
111
  export type CustomActionConfigs = Record<ActionName, ActionViewConfig | ActionHandler>;
73
112
  /**
74
113
  * @internal @unstable
@@ -1 +1,2 @@
1
1
  export declare const DEFAULT_CHECKSUM_ALGORITHM = "crc-32";
2
+ export declare const MULTIPART_UPLOAD_THRESHOLD_BYTES: number;
@@ -1,13 +1,10 @@
1
- import { TaskData, TaskHandler, TaskHandlerInput, TaskHandlerOptions, TaskHandlerOutput } from './types';
2
- export interface CopyHandlerData extends TaskData {
3
- sourceKey: string;
4
- eTag?: string;
1
+ import { OptionalFileData, TaskData, TaskHandler, TaskHandlerInput, TaskHandlerOptions, TaskHandlerOutput } from './types';
2
+ export interface CopyHandlerData extends OptionalFileData, TaskData {
5
3
  fileKey: string;
6
4
  lastModified: Date;
5
+ sourceKey: string;
7
6
  }
8
- export interface CopyHandlerInput extends TaskHandlerInput<CopyHandlerData, TaskHandlerOptions<{
9
- key: string;
10
- }>> {
7
+ export interface CopyHandlerInput extends TaskHandlerInput<CopyHandlerData, TaskHandlerOptions> {
11
8
  }
12
9
  export interface CopyHandlerOutput extends TaskHandlerOutput<{
13
10
  key: string;
@@ -2,9 +2,7 @@ import { TaskData, TaskHandler, TaskHandlerInput, TaskHandlerOutput, TaskHandler
2
2
  export interface CreateFolderHandlerData extends TaskData {
3
3
  preventOverwrite?: boolean;
4
4
  }
5
- export interface CreateFolderHandlerOptions extends TaskHandlerOptions<{
6
- key: string;
7
- }> {
5
+ export interface CreateFolderHandlerOptions extends TaskHandlerOptions {
8
6
  }
9
7
  export interface CreateFolderHandlerInput extends TaskHandlerInput<CreateFolderHandlerData, CreateFolderHandlerOptions> {
10
8
  }
@@ -0,0 +1,15 @@
1
+ import { CopyHandler } from './copy';
2
+ import { CreateFolderHandler } from './createFolder';
3
+ import { DeleteHandler } from './delete';
4
+ import { DownloadHandler } from './download';
5
+ import { ListLocationItemsHandler } from './listLocationItems';
6
+ import { UploadHandler } from './upload';
7
+ export interface DefaultHandlers {
8
+ copy: CopyHandler;
9
+ createFolder: CreateFolderHandler;
10
+ delete: DeleteHandler;
11
+ download: DownloadHandler;
12
+ listLocationItems: ListLocationItemsHandler;
13
+ upload: UploadHandler;
14
+ }
15
+ export declare const defaultHandlers: DefaultHandlers;
@@ -1,7 +1,7 @@
1
- import { TaskHandler, TaskHandlerOptions, TaskHandlerInput, TaskHandlerOutput, TaskData } from './types';
1
+ import { OptionalFileData, TaskHandler, TaskHandlerOptions, TaskHandlerInput, TaskHandlerOutput, TaskData } from './types';
2
2
  export interface DeleteHandlerOptions extends TaskHandlerOptions {
3
3
  }
4
- export interface DeleteHandlerData extends TaskData {
4
+ export interface DeleteHandlerData extends OptionalFileData, TaskData {
5
5
  fileKey: string;
6
6
  }
7
7
  export interface DeleteHandlerInput extends TaskHandlerInput<DeleteHandlerData, DeleteHandlerOptions> {
@@ -1,5 +1,6 @@
1
1
  export * from './copy';
2
2
  export * from './createFolder';
3
+ export * from './defaults';
3
4
  export * from './delete';
4
5
  export * from './download';
5
6
  export * from './listLocationItems';
@@ -1,5 +1,4 @@
1
- import { LocationCredentialsProvider } from '../../storage-internal';
2
- import { ListHandlerOptions, ListHandler, ListLocationsExcludeOptions, LocationData } from './types';
1
+ import { ListHandlerOptions, ListHandler, ListLocationsExcludeOptions, LocationData, ActionInputConfig } from './types';
3
2
  export interface ListLocationsOptions extends ListLocationsHandlerOptions {
4
3
  }
5
4
  export interface ListLocationsInput {
@@ -15,16 +14,9 @@ export interface ListLocationsHandlerOptions extends ListHandlerOptions<ListLoca
15
14
  }
16
15
  export interface ListLocationsHandlerInput {
17
16
  options?: ListLocationsHandlerOptions;
18
- config: {
19
- accountId?: string;
20
- credentials: LocationCredentialsProvider;
21
- customEndpoint?: string;
22
- region: string;
23
- };
24
- }
25
- export interface ListLocationsHandlerOutput {
26
- items: LocationData[];
27
- nextToken: string | undefined;
17
+ config: Omit<ActionInputConfig, 'bucket'>;
18
+ }
19
+ export interface ListLocationsHandlerOutput extends ListLocationsOutput {
28
20
  }
29
21
  export interface ListLocationsHandler extends ListHandler<ListLocationsHandlerInput, ListLocationsHandlerOutput> {
30
22
  }
@@ -48,6 +48,8 @@ export interface FileDataItem extends FileData, TaskData {
48
48
  export interface FileItem extends TaskData {
49
49
  file: File;
50
50
  }
51
+ export interface OptionalFileData extends Partial<Omit<FileData, 'id' | 'key'>> {
52
+ }
51
53
  export interface ActionInputConfig {
52
54
  accountId?: string;
53
55
  bucket: string;
@@ -64,32 +66,39 @@ export interface TaskData {
64
66
  key: string;
65
67
  id: string;
66
68
  }
67
- export interface TaskHandlerOptions<V = any> {
69
+ export interface TaskHandlerOptions {
68
70
  onProgress?: (data: {
69
71
  key: string;
70
72
  id: string;
71
73
  }, progress: number | undefined) => void;
72
- onSuccess?: (data: {
73
- key: string;
74
- id: string;
75
- }, value: V) => void;
76
- onError?: (data: {
77
- key: string;
78
- id: string;
79
- }, message: string | undefined) => void;
80
74
  }
81
- export interface TaskHandlerInput<T extends TaskData = TaskData, K extends TaskHandlerOptions = TaskHandlerOptions> {
75
+ export interface TaskHandlerInput<TData extends TaskData = TaskData, TOptions extends TaskHandlerOptions = TaskHandlerOptions> {
82
76
  config: ActionInputConfig;
83
- data: T;
84
- options?: K;
77
+ data: TData;
78
+ options?: TOptions;
79
+ }
80
+ export type TaskResultStatus = 'CANCELED' | 'COMPLETE' | 'FAILED' | 'OVERWRITE_PREVENTED';
81
+ export interface TaskResult<TStatus, TValue> {
82
+ /**
83
+ * result error (if any)
84
+ */
85
+ error?: Error;
86
+ /**
87
+ * result message (if any)
88
+ */
89
+ message?: string;
90
+ /**
91
+ * task result status
92
+ */
93
+ status: TStatus;
94
+ /**
95
+ * task result value (if any)
96
+ */
97
+ value?: TValue;
85
98
  }
86
99
  export interface TaskHandlerOutput<K = any> {
87
100
  cancel?: () => void;
88
- result: Promise<{
89
- message?: string;
90
- status: 'CANCELED' | 'COMPLETE' | 'FAILED' | 'OVERWRITE_PREVENTED';
91
- value?: K;
92
- }>;
101
+ result: Promise<TaskResult<TaskResultStatus, K>>;
93
102
  }
94
103
  export type TaskHandler<T = any, K = any> = (input: T) => K;
95
104
  export interface ListHandlerOptions<T = never> {
@@ -1,7 +1,5 @@
1
1
  import { TaskData, TaskHandler, TaskHandlerInput, TaskHandlerOutput, TaskHandlerOptions } from './types';
2
- export interface UploadHandlerOptions extends TaskHandlerOptions<{
3
- key: string;
4
- }> {
2
+ export interface UploadHandlerOptions extends TaskHandlerOptions {
5
3
  }
6
4
  export interface UploadHandlerData extends TaskData {
7
5
  file: File;
@@ -15,7 +13,6 @@ export interface UploadHandlerOutput extends TaskHandlerOutput<{
15
13
  }
16
14
  export interface UploadHandler extends TaskHandler<UploadHandlerInput, UploadHandlerOutput> {
17
15
  }
18
- export declare const MULTIPART_UPLOAD_THRESHOLD_BYTES: number;
19
16
  export declare const UNDEFINED_CALLBACKS: {
20
17
  cancel: undefined;
21
18
  pause: undefined;
@@ -1,7 +1,6 @@
1
1
  import { TransferProgressEvent } from 'aws-amplify/storage';
2
2
  import { LocationAccess as AccessGrantLocation } from '../../storage-internal';
3
- import { ListLocationsExcludeOptions } from './types';
4
- import { ActionInputConfig, FileData, FileDataItem, FileItem, LocationData } from './types';
3
+ import { ActionInputConfig, FileData, FileDataItem, FileItem, ListLocationsExcludeOptions, LocationData } from './types';
5
4
  export declare const constructBucket: ({ bucket: bucketName, region, }: Pick<ActionInputConfig, 'bucket' | 'region'>) => {
6
5
  bucketName: string;
7
6
  region: string;
@@ -14,3 +13,4 @@ export declare const createFileDataItem: (data: FileData) => FileDataItem;
14
13
  export declare const isFileItem: (value: unknown) => value is FileItem;
15
14
  export declare const isFileDataItem: (item: unknown) => item is FileDataItem;
16
15
  export declare const getProgress: ({ totalBytes, transferredBytes, }: TransferProgressEvent) => number | undefined;
16
+ export declare const isMultipartUpload: (file: File) => boolean;
@@ -1,2 +1,2 @@
1
- export { ActionInputConfig, copyHandler, CopyHandler, CopyHandlerData, CopyHandlerInput, CopyHandlerOutput, createFileDataItem, createFolderHandler, CreateFolderHandler, CreateFolderHandlerData, CreateFolderHandlerInput, CreateFolderHandlerOptions, CreateFolderHandlerOutput, downloadHandler, DownloadHandler, DownloadHandlerData, DownloadHandlerInput, DownloadHandlerOptions, DownloadHandlerOutput, DeleteHandler, DeleteHandlerData, DeleteHandlerInput, DeleteHandlerOptions, DeleteHandlerOutput, FileData, FileDataItem, FileItem, FolderData, isFileDataItem, isFileItem, ListHandler, ListHandlerInput, ListHandlerOptions, ListHandlerOutput, listLocationItemsHandler, ListLocationItemsHandler, ListLocationItemsHandlerInput, ListLocationItemsHandlerOptions, ListLocationItemsHandlerOutput, ListLocationsExcludeOptions, ListLocations, ListLocationsInput, ListLocationsOutput, listLocationsHandler, ListLocationsHandler, ListLocationsHandlerInput, ListLocationsHandlerOptions, ListLocationsHandlerOutput, LocationData, LocationItemData, LocationItemType, LocationPermissions, LocationType, TaskData, TaskHandler, TaskHandlerInput, TaskHandlerOptions, TaskHandlerOutput, uploadHandler, UploadHandler, UploadHandlerData, UploadHandlerInput, UploadHandlerOptions, UploadHandlerOutput, } from './handlers';
1
+ export { ActionInputConfig, copyHandler, CopyHandler, CopyHandlerData, CopyHandlerInput, CopyHandlerOutput, createFileDataItem, createFolderHandler, CreateFolderHandler, CreateFolderHandlerData, CreateFolderHandlerInput, CreateFolderHandlerOptions, CreateFolderHandlerOutput, defaultHandlers, DefaultHandlers, downloadHandler, DownloadHandler, DownloadHandlerData, DownloadHandlerInput, DownloadHandlerOptions, DownloadHandlerOutput, DeleteHandler, DeleteHandlerData, DeleteHandlerInput, DeleteHandlerOptions, DeleteHandlerOutput, FileData, FileDataItem, FileItem, FolderData, isFileDataItem, isFileItem, isMultipartUpload, ListHandler, ListHandlerInput, ListHandlerOptions, ListHandlerOutput, listLocationItemsHandler, ListLocationItemsHandler, ListLocationItemsHandlerInput, ListLocationItemsHandlerOptions, ListLocationItemsHandlerOutput, ListLocationsExcludeOptions, ListLocations, ListLocationsInput, ListLocationsOutput, listLocationsHandler, ListLocationsHandler, ListLocationsHandlerInput, ListLocationsHandlerOptions, ListLocationsHandlerOutput, LocationData, LocationItemData, LocationItemType, LocationPermissions, LocationType, TaskData, TaskHandler, TaskHandlerInput, TaskHandlerOptions, TaskHandlerOutput, TaskResult, TaskResultStatus, uploadHandler, UploadHandler, UploadHandlerData, UploadHandlerInput, UploadHandlerOptions, UploadHandlerOutput, } from './handlers';
2
2
  export { ExtendedActionConfigs, ActionViewConfig, ActionViewConfigs, ActionConfigsProvider, ActionConfigsProviderProps, ActionHandler, CustomActionConfigs, defaultActionConfigs, DefaultActionConfigs, defaultActionViewConfigs, getActionConfigs, isDefaultActionViewType, useActionConfigs, } from './configs';
@@ -1,2 +1,2 @@
1
- import { Components } from './ComponentsProvider';
2
- export declare const componentsDefault: Components;
1
+ import { StorageBrowserComponents } from './ComponentsProvider';
2
+ export declare const componentsDefault: StorageBrowserComponents;
@@ -1,3 +1,9 @@
1
1
  import { ExtendedActionConfigs } from './actions';
2
2
  import { CreateStorageBrowserInput, CreateStorageBrowserOutput } from './types';
3
+ /**
4
+ * Creates a `StorageBrowser` component and utility hooks from provided configuration `input`.
5
+ *
6
+ * @param input - `StorageBrowser` auth, actions and ui configuration values
7
+ * @returns `StorageBrowser` component, `useAction` and `useView` hooks
8
+ */
3
9
  export declare function createStorageBrowser<Input extends CreateStorageBrowserInput, RInput extends Input['actions'] extends ExtendedActionConfigs ? Input['actions'] : ExtendedActionConfigs>(input: Input): CreateStorageBrowserOutput<RInput>;
@@ -1,3 +1,4 @@
1
1
  export { DisplayTextProvider, useDisplayText } from './context';
2
2
  export { DEFAULT_STORAGE_BROWSER_DISPLAY_TEXT as DefaultStorageBrowserDisplayText } from './libraries';
3
3
  export { LocationDetailViewDisplayText, LocationsViewDisplayText, CreateFolderViewDisplayText, CopyViewDisplayText, UploadViewDisplayText, DeleteViewDisplayText, StorageBrowserDisplayText, } from './types';
4
+ export { isCopyViewDisplayTextKey, isDeleteViewDisplayTextKey } from './utils';
@@ -1,4 +1,4 @@
1
- import { StatusCounts, Tasks } from '../tasks';
1
+ import { StatusCounts, Task } from '../tasks';
2
2
  import { CopyHandlerData, CreateFolderHandlerData, DeleteHandlerData, FolderData, LocationData, LocationItemData, TaskData, UploadHandlerData, LocationPermissions } from '../actions';
3
3
  import { LocationState } from '../providers/store/location';
4
4
  import { MessageType } from '../composables/Message';
@@ -67,7 +67,7 @@ export interface DefaultActionViewDisplayText<T extends TaskData = TaskData> {
67
67
  actionStartLabel: string;
68
68
  getActionCompleteMessage: (data?: {
69
69
  counts?: StatusCounts;
70
- tasks?: Tasks<T>;
70
+ tasks?: Task<T>[];
71
71
  }) => {
72
72
  content?: string;
73
73
  type?: MessageType;
@@ -85,7 +85,6 @@ export interface DefaultActionViewDisplayText<T extends TaskData = TaskData> {
85
85
  tableColumnNameHeader: string;
86
86
  tableColumnTypeHeader: string;
87
87
  tableColumnSizeHeader: string;
88
- tableColumnProgressHeader: string;
89
88
  }
90
89
  export interface DefaultCreateFolderViewDisplayText extends Omit<DefaultActionViewDisplayText<CreateFolderHandlerData>, `${'tableColumn' | 'statusDisplay'}${string}`> {
91
90
  folderNameLabel: string;
@@ -105,20 +104,29 @@ export interface DefaultCopyViewDisplayText extends DefaultActionViewDisplayText
105
104
  searchPlaceholder: string;
106
105
  searchSubmitLabel: string;
107
106
  searchClearLabel: string;
107
+ /**
108
+ * @deprecated `CopyView` does not render a "progress" header
109
+ */
110
+ tableColumnProgressHeader?: string;
108
111
  }
109
112
  export interface DefaultDeleteViewDisplayText extends DefaultActionViewDisplayText<DeleteHandlerData> {
113
+ /**
114
+ * @deprecated `DeleteView` does not render a "progress" header
115
+ */
116
+ tableColumnProgressHeader?: string;
110
117
  }
111
118
  export interface DefaultUploadViewDisplayText extends DefaultActionViewDisplayText<UploadHandlerData> {
112
119
  addFilesLabel: string;
113
120
  addFolderLabel: string;
114
- statusDisplayOverwritePreventedLabel: string;
115
- overwriteToggleLabel: string;
116
121
  getFilesValidationMessage: (data?: {
117
122
  invalidFiles?: FileItems;
118
123
  }) => {
119
124
  content?: string;
120
125
  type?: MessageType;
121
126
  } | undefined;
127
+ overwriteToggleLabel: string;
128
+ statusDisplayOverwritePreventedLabel: string;
129
+ tableColumnProgressHeader: string;
122
130
  }
123
131
  export interface DefaultStorageBrowserDisplayText {
124
132
  CopyView: DefaultCopyViewDisplayText;
@@ -140,6 +148,9 @@ export interface LocationDetailViewDisplayText extends Partial<DefaultLocationDe
140
148
  }
141
149
  export interface UploadViewDisplayText extends Partial<DefaultUploadViewDisplayText> {
142
150
  }
151
+ /**
152
+ * `StorageBrowser` display text strings/resolver functions
153
+ */
143
154
  export interface StorageBrowserDisplayText {
144
155
  LocationsView?: LocationsViewDisplayText;
145
156
  LocationDetailView?: LocationDetailViewDisplayText;
@@ -0,0 +1,3 @@
1
+ import { CopyViewDisplayText, DeleteViewDisplayText } from './types';
2
+ export declare const isCopyViewDisplayTextKey: (value: string) => value is keyof CopyViewDisplayText;
3
+ export declare const isDeleteViewDisplayTextKey: (value: string) => value is keyof DeleteViewDisplayText;
@@ -1,7 +1,8 @@
1
1
  export { componentsDefault } from './componentsDefault';
2
2
  export { createStorageBrowser } from './createStorageBrowser';
3
- export { ActionViewConfig, ActionHandler, FileDataItem, ExtendedActionConfigs, } from './actions';
3
+ export { ActionHandler, ActionViewConfig, CopyHandlerInput, CopyHandlerOutput, CreateFolderHandlerInput, CreateFolderHandlerOutput, defaultActionConfigs, defaultHandlers, DefaultHandlers, DeleteHandlerInput, DeleteHandlerOutput, DownloadHandlerInput, DownloadHandlerOutput, ExtendedActionConfigs, ListLocations, ListLocationsInput, ListLocationsOutput, LocationData, ListLocationItemsHandlerInput, ListLocationItemsHandlerOutput, ListLocationsHandlerInput, ListLocationsHandlerOutput, UploadHandlerInput, UploadHandlerOutput, } from './actions';
4
4
  export { createAmplifyAuthAdapter, createManagedAuthAdapter, CreateManagedAuthAdapterInput, StorageBrowserAuthAdapter, } from './adapters';
5
- export { DefaultStorageBrowserDisplayText } from './displayText';
6
- export { CreateStorageBrowserInput, StorageBrowserType, DerivedActionViewType, DerivedActionViews, } from './types';
5
+ export { StorageBrowserComponents } from './ComponentsProvider';
6
+ export { DefaultStorageBrowserDisplayText, StorageBrowserDisplayText, } from './displayText';
7
+ export { CreateStorageBrowserInput, CreateStorageBrowserOutput, DerivedActionViews, DerivedActionViewType, StorageBrowserConfig, StorageBrowserProps, StorageBrowserProviderProps, StorageBrowserType, } from './types';
7
8
  export { UseView } from './views';
@@ -1,3 +1,3 @@
1
1
  import React from 'react';
2
2
  import { CreateConfigurationProviderInput, ConfigurationProviderComponent } from './types';
3
- export declare function createConfigurationProvider<T extends React.ComponentType<any>>(input: CreateConfigurationProviderInput<T>): ConfigurationProviderComponent<T>;
3
+ export declare function createConfigurationProvider<T extends React.ComponentType<any>, P extends React.ComponentProps<T>>(input: CreateConfigurationProviderInput<T>): ConfigurationProviderComponent<P>;
@@ -8,12 +8,12 @@ export interface GetActionInputProviderProps {
8
8
  region: string;
9
9
  customEndpoint?: string;
10
10
  }
11
- export interface CreateConfigurationProviderInput<T extends React.ComponentType<any>> extends GetActionInputProviderProps, CredentialsProviderProps {
11
+ export interface CreateConfigurationProviderInput<T> extends GetActionInputProviderProps, CredentialsProviderProps {
12
12
  ChildComponent?: T;
13
13
  displayName: string;
14
14
  region: string;
15
15
  }
16
- export interface ConfigurationProviderComponent<T extends React.ComponentType<any>> {
17
- (props: React.ComponentProps<T>): React.JSX.Element;
16
+ export interface ConfigurationProviderComponent<P> {
17
+ (props: P): React.JSX.Element;
18
18
  displayName: string;
19
19
  }
@@ -1,2 +1,2 @@
1
1
  export { createConfigurationProvider, CredentialsProviderProps, RegisterAuthListener, } from './configuration';
2
- export { FileItem, FileItems, StoreProviderProps, StoreProvider, } from './store';
2
+ export { FileItems, StoreProviderProps, StoreProvider } from './store';
@@ -10,6 +10,10 @@ export type ActionTypeStateContext = [
10
10
  HandleActionTypeAction
11
11
  ];
12
12
  export interface ActionTypeProviderProps {
13
+ /**
14
+ * Sets initial `actionType`. Provide to initialize the `StorageBrowser` with an initial
15
+ * `actionType`
16
+ */
13
17
  actionType?: string;
14
18
  children?: React.ReactNode;
15
19
  }
@@ -1,4 +1,4 @@
1
- import { LocationItemType, TaskData } from '../../../actions';
1
+ import { FileItem, LocationItemType } from '../../../actions';
2
2
  /**
3
3
  * native OS file picker type. to restrict selectable file types, define the picker types
4
4
  * followed by accepted file types as strings
@@ -21,9 +21,6 @@ export type FilesActionType = {
21
21
  type: 'RESET_FILE_ITEMS';
22
22
  };
23
23
  export type HandleFilesAction = (input: FilesActionType) => void;
24
- export interface FileItem extends TaskData {
25
- file: File;
26
- }
27
24
  export type FileItems = FileItem[];
28
25
  export type FilesContextType = [FileItems | undefined, HandleFilesAction];
29
26
  export interface FilesProviderProps {
@@ -1,3 +1,3 @@
1
- export { FileItem, FileItems } from './files';
1
+ export { FileItems } from './files';
2
2
  export { StoreProvider, StoreProviderProps } from './StoreProvider';
3
3
  export { useStore, UseStoreState } from './useStore';
@@ -49,7 +49,13 @@ export type LocationStateContext = [
49
49
  ];
50
50
  export interface LocationProviderProps {
51
51
  children?: React.ReactNode;
52
+ /**
53
+ * Sets initial `location` data
54
+ */
52
55
  location?: LocationData;
56
+ /**
57
+ * Sets initial `location` subpath to establish initial navigation state
58
+ */
53
59
  path?: string;
54
60
  }
55
61
  export declare const LocationContext: React.Context<LocationStateContext>, useLocation: (params?: {