@aws-amplify/ui-react-storage 3.7.2 → 3.8.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 (31) hide show
  1. package/dist/browser.js +1 -1
  2. package/dist/{createAmplifyAuthAdapter-C0qoSzPO.js → createAmplifyAuthAdapter-D6jJJVE_.js} +131 -63
  3. package/dist/esm/components/FileUploader/FileUploader.mjs +3 -2
  4. package/dist/esm/components/FileUploader/hooks/useUploadFiles/useUploadFiles.mjs +3 -1
  5. package/dist/esm/components/FileUploader/utils/getInput.mjs +8 -2
  6. package/dist/esm/components/StorageBrowser/composables/DataTable/DataTable.mjs +40 -38
  7. package/dist/esm/components/StorageBrowser/controls/hooks/useDataTable.mjs +2 -1
  8. package/dist/esm/components/StorageBrowser/views/LocationActionView/getActionViewTableData.mjs +1 -1
  9. package/dist/esm/components/StorageBrowser/views/LocationDetailView/LocationDetailViewProvider.mjs +2 -0
  10. package/dist/esm/components/StorageBrowser/views/LocationDetailView/getLocationDetailViewTableData/constants.mjs +6 -6
  11. package/dist/esm/components/StorageBrowser/views/LocationDetailView/getLocationDetailViewTableData/getFileRowContent.mjs +1 -1
  12. package/dist/esm/components/StorageBrowser/views/LocationDetailView/getLocationDetailViewTableData/getFolderRowContent.mjs +1 -1
  13. package/dist/esm/components/StorageBrowser/views/LocationDetailView/getLocationDetailViewTableData/getHeaders.mjs +68 -0
  14. package/dist/esm/components/StorageBrowser/views/LocationDetailView/getLocationDetailViewTableData/getLocationDetailViewTableData.mjs +13 -15
  15. package/dist/esm/components/StorageImage/StorageImage.mjs +11 -2
  16. package/dist/esm/components/StorageManager/StorageManager.mjs +2 -1
  17. package/dist/esm/version.mjs +1 -1
  18. package/dist/index.js +28 -9
  19. package/dist/types/components/FileUploader/FileUploader.d.ts +1 -1
  20. package/dist/types/components/FileUploader/hooks/useUploadFiles/useUploadFiles.d.ts +3 -2
  21. package/dist/types/components/FileUploader/types.d.ts +8 -1
  22. package/dist/types/components/FileUploader/utils/getInput.d.ts +3 -2
  23. package/dist/types/components/StorageBrowser/composables/DataTable/DataTable.d.ts +2 -1
  24. package/dist/types/components/StorageBrowser/views/LocationDetailView/getLocationDetailViewTableData/constants.d.ts +2 -2
  25. package/dist/types/components/StorageBrowser/views/LocationDetailView/getLocationDetailViewTableData/getHeaders.d.ts +11 -0
  26. package/dist/types/components/StorageBrowser/views/LocationDetailView/getLocationDetailViewTableData/getLocationDetailViewTableData.d.ts +3 -1
  27. package/dist/types/components/StorageImage/StorageImage.d.ts +1 -1
  28. package/dist/types/components/StorageImage/types.d.ts +4 -1
  29. package/dist/types/components/StorageManager/types.d.ts +15 -88
  30. package/dist/types/version.d.ts +1 -1
  31. package/package.json +4 -4
package/dist/browser.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var createAmplifyAuthAdapter = require('./createAmplifyAuthAdapter-C0qoSzPO.js');
5
+ var createAmplifyAuthAdapter = require('./createAmplifyAuthAdapter-D6jJJVE_.js');
6
6
  var internals = require('@aws-amplify/storage/internals');
7
7
  require('@aws-amplify/ui');
8
8
  require('aws-amplify/storage');
@@ -32,7 +32,7 @@ function _interopNamespace(e) {
32
32
 
33
33
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
34
34
 
35
- const VERSION = '3.7.2';
35
+ const VERSION = '3.8.1';
36
36
 
37
37
  const constructBucket = ({ bucket: bucketName, region, }) => ({ bucketName, region });
38
38
  const parseAccessGrantLocation = (location) => {
@@ -845,7 +845,7 @@ const CheckboxHeader = ({ content, }) => {
845
845
  return (React__namespace["default"].createElement(uiReact.Checkbox, { name: label ?? '', checked: checked, labelHidden: true, label: label, onChange: onSelect, id: id }));
846
846
  };
847
847
 
848
- const DataTable = ({ headers, rows, }) => {
848
+ const DataTable = ({ headers, isLoading, rows, }) => {
849
849
  const mappedHeaders = headers.map(({ key, content, type }) => {
850
850
  switch (type) {
851
851
  case 'checkbox': {
@@ -869,44 +869,46 @@ const DataTable = ({ headers, rows, }) => {
869
869
  }
870
870
  }
871
871
  });
872
- const mappedRows = rows.map(({ key, content }) => ({
873
- key,
874
- content: content.map(({ key, content, type }) => {
875
- switch (type) {
876
- case 'button': {
877
- return {
878
- key,
879
- content: React__namespace["default"].createElement(ButtonDataCell, { content: content }),
880
- };
881
- }
882
- case 'checkbox': {
883
- return {
884
- key,
885
- content: React__namespace["default"].createElement(CheckboxDataCell, { content: content }),
886
- };
887
- }
888
- case 'date': {
889
- return {
890
- key,
891
- content: React__namespace["default"].createElement(DateDataCell, { content: content }),
892
- };
893
- }
894
- case 'number': {
895
- return {
896
- key,
897
- content: React__namespace["default"].createElement(NumberDataCell, { content: content }),
898
- };
899
- }
900
- case 'text':
901
- default: {
902
- return {
903
- key,
904
- content: React__namespace["default"].createElement(TextDataCell, { content: content }),
905
- };
872
+ const mappedRows = isLoading
873
+ ? []
874
+ : rows.map(({ key, content }) => ({
875
+ key,
876
+ content: content.map(({ key, content, type }) => {
877
+ switch (type) {
878
+ case 'button': {
879
+ return {
880
+ key,
881
+ content: React__namespace["default"].createElement(ButtonDataCell, { content: content }),
882
+ };
883
+ }
884
+ case 'checkbox': {
885
+ return {
886
+ key,
887
+ content: React__namespace["default"].createElement(CheckboxDataCell, { content: content }),
888
+ };
889
+ }
890
+ case 'date': {
891
+ return {
892
+ key,
893
+ content: React__namespace["default"].createElement(DateDataCell, { content: content }),
894
+ };
895
+ }
896
+ case 'number': {
897
+ return {
898
+ key,
899
+ content: React__namespace["default"].createElement(NumberDataCell, { content: content }),
900
+ };
901
+ }
902
+ case 'text':
903
+ default: {
904
+ return {
905
+ key,
906
+ content: React__namespace["default"].createElement(TextDataCell, { content: content }),
907
+ };
908
+ }
906
909
  }
907
- }
908
- }),
909
- }));
910
+ }),
911
+ }));
910
912
  return React__namespace["default"].createElement(Table, { headers: mappedHeaders, rows: mappedRows });
911
913
  };
912
914
 
@@ -2291,7 +2293,7 @@ const GROUP_ORDER = [
2291
2293
  const UNSORTABLE_GROUPS = ['checkbox'];
2292
2294
  const useDataTable = () => {
2293
2295
  const { data } = useControlsContext();
2294
- const { tableData } = data;
2296
+ const { isLoading, tableData } = data;
2295
2297
  const defaultSortIndex = React__namespace["default"].useMemo(() => tableData?.headers?.findIndex(({ type }) => type === 'sort') ?? -1, [tableData]);
2296
2298
  const [sortState, setSortState] = React__namespace["default"].useState({
2297
2299
  index: defaultSortIndex,
@@ -2375,6 +2377,7 @@ const useDataTable = () => {
2375
2377
  }, [sortState, tableData]);
2376
2378
  return {
2377
2379
  headers: mappedHeaders ?? [],
2380
+ isLoading,
2378
2381
  rows: sortedRows ?? [],
2379
2382
  };
2380
2383
  };
@@ -2624,7 +2627,7 @@ const getActionViewTableData = ({ tasks, displayText, isProcessing, locationKey,
2624
2627
  value: progress,
2625
2628
  displayValue: `${getPercentValue(
2626
2629
  // Default progress to 100% if progress value is unavailable but status is recognized as complete
2627
- progress ?? status === 'COMPLETE' ? 1 : 0)}%`,
2630
+ progress ?? (status === 'COMPLETE' ? 1 : 0))}%`,
2628
2631
  },
2629
2632
  };
2630
2633
  }
@@ -4187,15 +4190,15 @@ const useLocationDetailView = (options) => {
4187
4190
  };
4188
4191
 
4189
4192
  const LOCATION_DETAIL_VIEW_HEADERS = [
4190
- { key: 'checkbox', type: 'text', content: { text: '' } },
4191
- { key: 'name', type: 'sort', content: { label: 'Name' } },
4192
- { key: 'type', type: 'sort', content: { label: 'Type' } },
4193
- { key: 'last-modified', type: 'sort', content: { label: 'Last modified' } },
4194
- { key: 'size', type: 'sort', content: { label: 'Size' } },
4195
- { key: 'download', type: 'text', content: { text: '' } },
4193
+ 'checkbox',
4194
+ 'name',
4195
+ 'type',
4196
+ 'last-modified',
4197
+ 'size',
4198
+ 'download',
4196
4199
  ];
4197
4200
 
4198
- const getFileRowContent = ({ permissions, isSelected, itemLocationKey, getDateDisplayValue, lastModified, rowId, rowKey, selectFileLabel, size, onDownload, onSelect, }) => LOCATION_DETAIL_VIEW_HEADERS.map(({ key: columnKey }) => {
4201
+ const getFileRowContent = ({ permissions, isSelected, itemLocationKey, getDateDisplayValue, lastModified, rowId, rowKey, selectFileLabel, size, onDownload, onSelect, }) => LOCATION_DETAIL_VIEW_HEADERS.map((columnKey) => {
4199
4202
  const key = `${columnKey}-${rowId}`;
4200
4203
  switch (columnKey) {
4201
4204
  case 'checkbox': {
@@ -4267,7 +4270,7 @@ const getFileRowContent = ({ permissions, isSelected, itemLocationKey, getDateDi
4267
4270
  }
4268
4271
  });
4269
4272
 
4270
- const getFolderRowContent = ({ itemSubPath, rowId, onNavigate, }) => LOCATION_DETAIL_VIEW_HEADERS.map(({ key: columnKey }) => {
4273
+ const getFolderRowContent = ({ itemSubPath, rowId, onNavigate, }) => LOCATION_DETAIL_VIEW_HEADERS.map((columnKey) => {
4271
4274
  const key = `${columnKey}-${rowId}`;
4272
4275
  switch (columnKey) {
4273
4276
  case 'checkbox': {
@@ -4296,20 +4299,83 @@ const getFolderRowContent = ({ itemSubPath, rowId, onNavigate, }) => LOCATION_DE
4296
4299
  }
4297
4300
  });
4298
4301
 
4299
- const getLocationDetailViewTableData = ({ areAllFilesSelected, location, fileDataItems, hasFiles, pageItems, selectFileLabel, selectAllFilesLabel, getDateDisplayValue, onDownload, onNavigate, onSelect, onSelectAll, }) => {
4300
- const headerCheckbox = {
4301
- key: 'checkbox',
4302
- type: 'checkbox',
4303
- content: {
4304
- checked: areAllFilesSelected,
4305
- label: selectAllFilesLabel,
4306
- onSelect: onSelectAll,
4307
- id: 'header-checkbox',
4308
- },
4309
- };
4310
- const headers = hasFiles
4311
- ? [headerCheckbox, ...LOCATION_DETAIL_VIEW_HEADERS.slice(1)]
4312
- : LOCATION_DETAIL_VIEW_HEADERS;
4302
+ const getHeaders$1 = ({ tableColumnLastModifiedHeader, tableColumnNameHeader, tableColumnSizeHeader, tableColumnTypeHeader, areAllFilesSelected, selectAllFilesLabel, onSelectAll, hasFiles, }) => LOCATION_DETAIL_VIEW_HEADERS.map((key) => {
4303
+ switch (key) {
4304
+ case 'checkbox': {
4305
+ if (hasFiles) {
4306
+ return {
4307
+ key,
4308
+ type: 'checkbox',
4309
+ content: {
4310
+ checked: areAllFilesSelected,
4311
+ label: selectAllFilesLabel,
4312
+ id: 'header-checkbox',
4313
+ onSelect: onSelectAll,
4314
+ },
4315
+ };
4316
+ }
4317
+ else {
4318
+ return {
4319
+ key,
4320
+ type: 'text',
4321
+ content: { text: '' },
4322
+ };
4323
+ }
4324
+ }
4325
+ case 'name': {
4326
+ return {
4327
+ key,
4328
+ type: 'sort',
4329
+ content: {
4330
+ label: tableColumnNameHeader,
4331
+ },
4332
+ };
4333
+ }
4334
+ case 'type': {
4335
+ return {
4336
+ key,
4337
+ type: 'sort',
4338
+ content: {
4339
+ label: tableColumnTypeHeader,
4340
+ },
4341
+ };
4342
+ }
4343
+ case 'last-modified': {
4344
+ return {
4345
+ key,
4346
+ type: 'sort',
4347
+ content: {
4348
+ label: tableColumnLastModifiedHeader,
4349
+ },
4350
+ };
4351
+ }
4352
+ case 'size': {
4353
+ return {
4354
+ key,
4355
+ type: 'sort',
4356
+ content: {
4357
+ label: tableColumnSizeHeader,
4358
+ },
4359
+ };
4360
+ }
4361
+ case 'download': {
4362
+ return { key, type: 'text', content: { text: '' } };
4363
+ }
4364
+ }
4365
+ });
4366
+
4367
+ const getLocationDetailViewTableData = ({ areAllFilesSelected, displayText, location, fileDataItems, hasFiles, pageItems, selectFileLabel, selectAllFilesLabel, getDateDisplayValue, onDownload, onNavigate, onSelect, onSelectAll, }) => {
4368
+ const { tableColumnLastModifiedHeader, tableColumnNameHeader, tableColumnSizeHeader, tableColumnTypeHeader, } = displayText;
4369
+ const headers = getHeaders$1({
4370
+ areAllFilesSelected,
4371
+ selectAllFilesLabel,
4372
+ hasFiles,
4373
+ onSelectAll,
4374
+ tableColumnLastModifiedHeader,
4375
+ tableColumnNameHeader,
4376
+ tableColumnSizeHeader,
4377
+ tableColumnTypeHeader,
4378
+ });
4313
4379
  const rows = pageItems.map((locationItem) => {
4314
4380
  const { id, key, type } = locationItem;
4315
4381
  switch (type) {
@@ -4365,6 +4431,7 @@ const getLocationDetailViewTableData = ({ areAllFilesSelected, location, fileDat
4365
4431
  };
4366
4432
 
4367
4433
  function LocationDetailViewProvider({ children, ...props }) {
4434
+ const { LocationDetailView: displayText } = useDisplayText();
4368
4435
  const { LocationDetailView: { loadingIndicatorLabel, searchSubfoldersToggleLabel, selectFileLabel, selectAllFilesLabel, searchPlaceholder, searchSubmitLabel, searchClearLabel, getActionListItemLabel, getDateDisplayValue, getTitle, getListItemsResultMessage, }, } = useDisplayText();
4369
4436
  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;
4370
4437
  const actionsWithDisplayText = actionItems.map((item) => ({
@@ -4404,6 +4471,7 @@ function LocationDetailViewProvider({ children, ...props }) {
4404
4471
  searchQuery,
4405
4472
  tableData: getLocationDetailViewTableData({
4406
4473
  areAllFilesSelected,
4474
+ displayText,
4407
4475
  location,
4408
4476
  fileDataItems,
4409
4477
  getDateDisplayValue,
@@ -21,8 +21,8 @@ import { VERSION } from '../../version.mjs';
21
21
  const logger = getLogger('Storage');
22
22
  const MISSING_REQUIRED_PROPS_MESSAGE = '`FileUploader` requires a `maxFileCount` prop to be provided.';
23
23
  const ACCESS_LEVEL_WITH_PATH_CALLBACK_MESSAGE = '`FileUploader` does not allow usage of a `path` callback prop with an `accessLevel` prop.';
24
- const ACCESS_LEVEL_DEPRECATION_MESSAGE = '`accessLevel` has been deprecated and will be removed in a future major version. See migration notes at https://ui.docs.amplify.aws/react/connected-components/storage/FileUploader';
25
- const FileUploaderBase = React.forwardRef(function FileUploader({ acceptedFileTypes = [], accessLevel, autoUpload = true, components, defaultFiles, displayText: overrideDisplayText, isResumable = false, maxFileCount, maxFileSize, onFileRemove, onUploadError, onUploadStart, onUploadSuccess, path, processFile, showThumbnails = true, useAccelerateEndpoint, }, ref) {
24
+ const ACCESS_LEVEL_DEPRECATION_MESSAGE = '`accessLevel` has been deprecated and will be removed in a future major version. See migration notes at https://ui.docs.amplify.aws/react/connected-components/storage/fileuploader#deprecated-props';
25
+ const FileUploaderBase = React.forwardRef(function FileUploader({ acceptedFileTypes = [], accessLevel, autoUpload = true, bucket, components, defaultFiles, displayText: overrideDisplayText, isResumable = false, maxFileCount, maxFileSize, onFileRemove, onUploadError, onUploadStart, onUploadSuccess, path, processFile, showThumbnails = true, useAccelerateEndpoint, }, ref) {
26
26
  if (!maxFileCount) {
27
27
  // eslint-disable-next-line no-console
28
28
  console.warn(MISSING_REQUIRED_PROPS_MESSAGE);
@@ -77,6 +77,7 @@ const FileUploaderBase = React.forwardRef(function FileUploader({ acceptedFileTy
77
77
  });
78
78
  useUploadFiles({
79
79
  accessLevel,
80
+ bucket,
80
81
  files,
81
82
  isResumable,
82
83
  maxFileCount,
@@ -4,7 +4,7 @@ import { getInput } from '../../utils/getInput.mjs';
4
4
  import { uploadFile } from '../../utils/uploadFile.mjs';
5
5
  import { FileStatus } from '../../types.mjs';
6
6
 
7
- function useUploadFiles({ accessLevel, files, isResumable, maxFileCount, onUploadError, onUploadStart, onUploadSuccess, path, processFile, setUploadingFile, setUploadProgress, setUploadSuccess, useAccelerateEndpoint, }) {
7
+ function useUploadFiles({ accessLevel, bucket, files, isResumable, maxFileCount, onUploadError, onUploadStart, onUploadSuccess, path, processFile, setUploadingFile, setUploadProgress, setUploadSuccess, useAccelerateEndpoint, }) {
8
8
  React.useEffect(() => {
9
9
  const filesReadyToUpload = files.filter((file) => file.status === FileStatus.QUEUED);
10
10
  if (filesReadyToUpload.length > maxFileCount) {
@@ -24,6 +24,7 @@ function useUploadFiles({ accessLevel, files, isResumable, maxFileCount, onUploa
24
24
  if (file) {
25
25
  const input = getInput({
26
26
  accessLevel,
27
+ bucket,
27
28
  file,
28
29
  key,
29
30
  onProgress,
@@ -58,6 +59,7 @@ function useUploadFiles({ accessLevel, files, isResumable, maxFileCount, onUploa
58
59
  }, [
59
60
  files,
60
61
  accessLevel,
62
+ bucket,
61
63
  isResumable,
62
64
  setUploadProgress,
63
65
  setUploadingFile,
@@ -2,7 +2,7 @@ import { fetchAuthSession } from 'aws-amplify/auth';
2
2
  import { isFunction, isString } from '@aws-amplify/ui';
3
3
  import { resolveFile } from './resolveFile.mjs';
4
4
 
5
- const getInput = ({ accessLevel, file, key, onProgress, path, processFile, useAccelerateEndpoint, }) => {
5
+ const getInput = ({ accessLevel, bucket, file, key, onProgress, path, processFile, useAccelerateEndpoint, }) => {
6
6
  return async () => {
7
7
  const hasCallbackPath = isFunction(path);
8
8
  const hasStringPath = isString(path);
@@ -10,7 +10,13 @@ const getInput = ({ accessLevel, file, key, onProgress, path, processFile, useAc
10
10
  const { file: data, key: processedKey, ...rest } = await resolveFile({ file, key, processFile });
11
11
  const contentType = file.type || 'binary/octet-stream';
12
12
  // IMPORTANT: always pass `...rest` here for backwards compatibility
13
- const options = { contentType, onProgress, useAccelerateEndpoint, ...rest };
13
+ const options = {
14
+ bucket,
15
+ contentType,
16
+ onProgress,
17
+ useAccelerateEndpoint,
18
+ ...rest,
19
+ };
14
20
  let inputResult;
15
21
  if (hasKeyInput) {
16
22
  // legacy handling of `path` is to prefix to `fileKey`
@@ -9,7 +9,7 @@ import { CheckboxDataCell } from './dataCells/CheckboxDataCell.mjs';
9
9
  import { TextDataCell } from './dataCells/TextDataCell.mjs';
10
10
  import { CheckboxHeader } from './headers/CheckboxHeader.mjs';
11
11
 
12
- const DataTable = ({ headers, rows, }) => {
12
+ const DataTable = ({ headers, isLoading, rows, }) => {
13
13
  const mappedHeaders = headers.map(({ key, content, type }) => {
14
14
  switch (type) {
15
15
  case 'checkbox': {
@@ -33,44 +33,46 @@ const DataTable = ({ headers, rows, }) => {
33
33
  }
34
34
  }
35
35
  });
36
- const mappedRows = rows.map(({ key, content }) => ({
37
- key,
38
- content: content.map(({ key, content, type }) => {
39
- switch (type) {
40
- case 'button': {
41
- return {
42
- key,
43
- content: React__default.createElement(ButtonDataCell, { content: content }),
44
- };
36
+ const mappedRows = isLoading
37
+ ? []
38
+ : rows.map(({ key, content }) => ({
39
+ key,
40
+ content: content.map(({ key, content, type }) => {
41
+ switch (type) {
42
+ case 'button': {
43
+ return {
44
+ key,
45
+ content: React__default.createElement(ButtonDataCell, { content: content }),
46
+ };
47
+ }
48
+ case 'checkbox': {
49
+ return {
50
+ key,
51
+ content: React__default.createElement(CheckboxDataCell, { content: content }),
52
+ };
53
+ }
54
+ case 'date': {
55
+ return {
56
+ key,
57
+ content: React__default.createElement(DateDataCell, { content: content }),
58
+ };
59
+ }
60
+ case 'number': {
61
+ return {
62
+ key,
63
+ content: React__default.createElement(NumberDataCell, { content: content }),
64
+ };
65
+ }
66
+ case 'text':
67
+ default: {
68
+ return {
69
+ key,
70
+ content: React__default.createElement(TextDataCell, { content: content }),
71
+ };
72
+ }
45
73
  }
46
- case 'checkbox': {
47
- return {
48
- key,
49
- content: React__default.createElement(CheckboxDataCell, { content: content }),
50
- };
51
- }
52
- case 'date': {
53
- return {
54
- key,
55
- content: React__default.createElement(DateDataCell, { content: content }),
56
- };
57
- }
58
- case 'number': {
59
- return {
60
- key,
61
- content: React__default.createElement(NumberDataCell, { content: content }),
62
- };
63
- }
64
- case 'text':
65
- default: {
66
- return {
67
- key,
68
- content: React__default.createElement(TextDataCell, { content: content }),
69
- };
70
- }
71
- }
72
- }),
73
- }));
74
+ }),
75
+ }));
74
76
  return React__default.createElement(Table, { headers: mappedHeaders, rows: mappedRows });
75
77
  };
76
78
 
@@ -15,7 +15,7 @@ const GROUP_ORDER = [
15
15
  const UNSORTABLE_GROUPS = ['checkbox'];
16
16
  const useDataTable = () => {
17
17
  const { data } = useControlsContext();
18
- const { tableData } = data;
18
+ const { isLoading, tableData } = data;
19
19
  const defaultSortIndex = React__default.useMemo(() => tableData?.headers?.findIndex(({ type }) => type === 'sort') ?? -1, [tableData]);
20
20
  const [sortState, setSortState] = React__default.useState({
21
21
  index: defaultSortIndex,
@@ -99,6 +99,7 @@ const useDataTable = () => {
99
99
  }, [sortState, tableData]);
100
100
  return {
101
101
  headers: mappedHeaders ?? [],
102
+ isLoading,
102
103
  rows: sortedRows ?? [],
103
104
  };
104
105
  };
@@ -118,7 +118,7 @@ const getActionViewTableData = ({ tasks, displayText, isProcessing, locationKey,
118
118
  value: progress,
119
119
  displayValue: `${getPercentValue(
120
120
  // Default progress to 100% if progress value is unavailable but status is recognized as complete
121
- progress ?? status === 'COMPLETE' ? 1 : 0)}%`,
121
+ progress ?? (status === 'COMPLETE' ? 1 : 0))}%`,
122
122
  },
123
123
  };
124
124
  }
@@ -5,6 +5,7 @@ import '@aws-amplify/ui';
5
5
  import { getLocationDetailViewTableData } from './getLocationDetailViewTableData/getLocationDetailViewTableData.mjs';
6
6
 
7
7
  function LocationDetailViewProvider({ children, ...props }) {
8
+ const { LocationDetailView: displayText } = useDisplayText();
8
9
  const { LocationDetailView: { loadingIndicatorLabel, searchSubfoldersToggleLabel, selectFileLabel, selectAllFilesLabel, searchPlaceholder, searchSubmitLabel, searchClearLabel, getActionListItemLabel, getDateDisplayValue, getTitle, getListItemsResultMessage, }, } = useDisplayText();
9
10
  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
11
  const actionsWithDisplayText = actionItems.map((item) => ({
@@ -44,6 +45,7 @@ function LocationDetailViewProvider({ children, ...props }) {
44
45
  searchQuery,
45
46
  tableData: getLocationDetailViewTableData({
46
47
  areAllFilesSelected,
48
+ displayText,
47
49
  location,
48
50
  fileDataItems,
49
51
  getDateDisplayValue,
@@ -1,10 +1,10 @@
1
1
  const LOCATION_DETAIL_VIEW_HEADERS = [
2
- { key: 'checkbox', type: 'text', content: { text: '' } },
3
- { key: 'name', type: 'sort', content: { label: 'Name' } },
4
- { key: 'type', type: 'sort', content: { label: 'Type' } },
5
- { key: 'last-modified', type: 'sort', content: { label: 'Last modified' } },
6
- { key: 'size', type: 'sort', content: { label: 'Size' } },
7
- { key: 'download', type: 'text', content: { text: '' } },
2
+ 'checkbox',
3
+ 'name',
4
+ 'type',
5
+ 'last-modified',
6
+ 'size',
7
+ 'download',
8
8
  ];
9
9
 
10
10
  export { LOCATION_DETAIL_VIEW_HEADERS };
@@ -1,7 +1,7 @@
1
1
  import { humanFileSize } from '@aws-amplify/ui';
2
2
  import { LOCATION_DETAIL_VIEW_HEADERS } from './constants.mjs';
3
3
 
4
- const getFileRowContent = ({ permissions, isSelected, itemLocationKey, getDateDisplayValue, lastModified, rowId, rowKey, selectFileLabel, size, onDownload, onSelect, }) => LOCATION_DETAIL_VIEW_HEADERS.map(({ key: columnKey }) => {
4
+ const getFileRowContent = ({ permissions, isSelected, itemLocationKey, getDateDisplayValue, lastModified, rowId, rowKey, selectFileLabel, size, onDownload, onSelect, }) => LOCATION_DETAIL_VIEW_HEADERS.map((columnKey) => {
5
5
  const key = `${columnKey}-${rowId}`;
6
6
  switch (columnKey) {
7
7
  case 'checkbox': {
@@ -1,6 +1,6 @@
1
1
  import { LOCATION_DETAIL_VIEW_HEADERS } from './constants.mjs';
2
2
 
3
- const getFolderRowContent = ({ itemSubPath, rowId, onNavigate, }) => LOCATION_DETAIL_VIEW_HEADERS.map(({ key: columnKey }) => {
3
+ const getFolderRowContent = ({ itemSubPath, rowId, onNavigate, }) => LOCATION_DETAIL_VIEW_HEADERS.map((columnKey) => {
4
4
  const key = `${columnKey}-${rowId}`;
5
5
  switch (columnKey) {
6
6
  case 'checkbox': {
@@ -0,0 +1,68 @@
1
+ import { LOCATION_DETAIL_VIEW_HEADERS } from './constants.mjs';
2
+
3
+ const getHeaders = ({ tableColumnLastModifiedHeader, tableColumnNameHeader, tableColumnSizeHeader, tableColumnTypeHeader, areAllFilesSelected, selectAllFilesLabel, onSelectAll, hasFiles, }) => LOCATION_DETAIL_VIEW_HEADERS.map((key) => {
4
+ switch (key) {
5
+ case 'checkbox': {
6
+ if (hasFiles) {
7
+ return {
8
+ key,
9
+ type: 'checkbox',
10
+ content: {
11
+ checked: areAllFilesSelected,
12
+ label: selectAllFilesLabel,
13
+ id: 'header-checkbox',
14
+ onSelect: onSelectAll,
15
+ },
16
+ };
17
+ }
18
+ else {
19
+ return {
20
+ key,
21
+ type: 'text',
22
+ content: { text: '' },
23
+ };
24
+ }
25
+ }
26
+ case 'name': {
27
+ return {
28
+ key,
29
+ type: 'sort',
30
+ content: {
31
+ label: tableColumnNameHeader,
32
+ },
33
+ };
34
+ }
35
+ case 'type': {
36
+ return {
37
+ key,
38
+ type: 'sort',
39
+ content: {
40
+ label: tableColumnTypeHeader,
41
+ },
42
+ };
43
+ }
44
+ case 'last-modified': {
45
+ return {
46
+ key,
47
+ type: 'sort',
48
+ content: {
49
+ label: tableColumnLastModifiedHeader,
50
+ },
51
+ };
52
+ }
53
+ case 'size': {
54
+ return {
55
+ key,
56
+ type: 'sort',
57
+ content: {
58
+ label: tableColumnSizeHeader,
59
+ },
60
+ };
61
+ }
62
+ case 'download': {
63
+ return { key, type: 'text', content: { text: '' } };
64
+ }
65
+ }
66
+ });
67
+
68
+ export { getHeaders };
@@ -5,22 +5,20 @@ import 'aws-amplify/storage';
5
5
  import '../../../actions/configs/context.mjs';
6
6
  import { getFileRowContent } from './getFileRowContent.mjs';
7
7
  import { getFolderRowContent } from './getFolderRowContent.mjs';
8
- import { LOCATION_DETAIL_VIEW_HEADERS } from './constants.mjs';
8
+ import { getHeaders } from './getHeaders.mjs';
9
9
 
10
- const getLocationDetailViewTableData = ({ areAllFilesSelected, location, fileDataItems, hasFiles, pageItems, selectFileLabel, selectAllFilesLabel, getDateDisplayValue, onDownload, onNavigate, onSelect, onSelectAll, }) => {
11
- const headerCheckbox = {
12
- key: 'checkbox',
13
- type: 'checkbox',
14
- content: {
15
- checked: areAllFilesSelected,
16
- label: selectAllFilesLabel,
17
- onSelect: onSelectAll,
18
- id: 'header-checkbox',
19
- },
20
- };
21
- const headers = hasFiles
22
- ? [headerCheckbox, ...LOCATION_DETAIL_VIEW_HEADERS.slice(1)]
23
- : LOCATION_DETAIL_VIEW_HEADERS;
10
+ const getLocationDetailViewTableData = ({ areAllFilesSelected, displayText, location, fileDataItems, hasFiles, pageItems, selectFileLabel, selectAllFilesLabel, getDateDisplayValue, onDownload, onNavigate, onSelect, onSelectAll, }) => {
11
+ const { tableColumnLastModifiedHeader, tableColumnNameHeader, tableColumnSizeHeader, tableColumnTypeHeader, } = displayText;
12
+ const headers = getHeaders({
13
+ areAllFilesSelected,
14
+ selectAllFilesLabel,
15
+ hasFiles,
16
+ onSelectAll,
17
+ tableColumnLastModifiedHeader,
18
+ tableColumnNameHeader,
19
+ tableColumnSizeHeader,
20
+ tableColumnTypeHeader,
21
+ });
24
22
  const rows = pageItems.map((locationItem) => {
25
23
  const { id, key, type } = locationItem;
26
24
  switch (type) {
@@ -22,7 +22,7 @@ const getDeprecationMessage = ({ hasImgkey, hasPath, hasDeprecatedOptions, }) =>
22
22
  }
23
23
  return message;
24
24
  };
25
- const StorageImage = ({ accessLevel, className, fallbackSrc, identityId, imgKey, path, onStorageGetError, onGetUrlError, validateObjectExistence = true, ...rest }) => {
25
+ const StorageImage = ({ accessLevel, bucket, className, fallbackSrc, identityId, imgKey, path, onStorageGetError, onGetUrlError, validateObjectExistence = true, ...rest }) => {
26
26
  const hasImgkey = !!imgKey;
27
27
  const hasPath = !!path;
28
28
  const hasDeprecatedOptions = !!accessLevel || !!identityId;
@@ -46,10 +46,19 @@ const StorageImage = ({ accessLevel, className, fallbackSrc, identityId, imgKey,
46
46
  onError,
47
47
  options: {
48
48
  accessLevel,
49
+ bucket,
49
50
  targetIdentityId: identityId,
50
51
  validateObjectExistence,
51
52
  },
52
- }), [accessLevel, imgKey, identityId, onError, path, validateObjectExistence]);
53
+ }), [
54
+ accessLevel,
55
+ bucket,
56
+ imgKey,
57
+ identityId,
58
+ onError,
59
+ path,
60
+ validateObjectExistence,
61
+ ]);
53
62
  const { url } = useGetUrl(input);
54
63
  return (React.createElement(Image, { ...rest, className: classNames(ComponentClassName.StorageImage, className), src: url?.toString() ?? fallbackSrc }));
55
64
  };
@@ -22,7 +22,7 @@ const logger = getLogger('Storage');
22
22
  const MISSING_REQUIRED_PROPS_MESSAGE = '`StorageManager` requires a `maxFileCount` prop to be provided.';
23
23
  const ACCESS_LEVEL_WITH_PATH_CALLBACK_MESSAGE = '`StorageManager` does not allow usage of a `path` callback prop with an `accessLevel` prop.';
24
24
  const ACCESS_LEVEL_DEPRECATION_MESSAGE = '`accessLevel` has been deprecated and will be removed in a future major version. See migration notes at https://ui.docs.amplify.aws/react/connected-components/storage/storagemanager';
25
- const StorageManagerBase = React.forwardRef(function StorageManager({ acceptedFileTypes = [], accessLevel, autoUpload = true, components, defaultFiles, displayText: overrideDisplayText, isResumable = false, maxFileCount, maxFileSize, onFileRemove, onUploadError, onUploadStart, onUploadSuccess, path, processFile, showThumbnails = true, useAccelerateEndpoint, }, ref) {
25
+ const StorageManagerBase = React.forwardRef(function StorageManager({ acceptedFileTypes = [], accessLevel, autoUpload = true, bucket, components, defaultFiles, displayText: overrideDisplayText, isResumable = false, maxFileCount, maxFileSize, onFileRemove, onUploadError, onUploadStart, onUploadSuccess, path, processFile, showThumbnails = true, useAccelerateEndpoint, }, ref) {
26
26
  useDeprecationWarning({
27
27
  message: 'The `StorageManager` component has been renamed as the `FileUploader` component.',
28
28
  shouldWarn: false,
@@ -81,6 +81,7 @@ const StorageManagerBase = React.forwardRef(function StorageManager({ acceptedFi
81
81
  });
82
82
  useUploadFiles({
83
83
  accessLevel,
84
+ bucket,
84
85
  files,
85
86
  isResumable,
86
87
  maxFileCount,
@@ -1,3 +1,3 @@
1
- const VERSION = '3.7.2';
1
+ const VERSION = '3.8.1';
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-C0qoSzPO.js');
12
+ var createAmplifyAuthAdapter = require('./createAmplifyAuthAdapter-D6jJJVE_.js');
13
13
  require('@aws-amplify/storage/internals');
14
14
  require('@aws-amplify/ui-react-core/elements');
15
15
  require('aws-amplify');
@@ -305,7 +305,7 @@ const resolveFile = ({ processFile, ...input }) => {
305
305
  });
306
306
  };
307
307
 
308
- const getInput = ({ accessLevel, file, key, onProgress, path, processFile, useAccelerateEndpoint, }) => {
308
+ const getInput = ({ accessLevel, bucket, file, key, onProgress, path, processFile, useAccelerateEndpoint, }) => {
309
309
  return async () => {
310
310
  const hasCallbackPath = ui.isFunction(path);
311
311
  const hasStringPath = ui.isString(path);
@@ -313,7 +313,13 @@ const getInput = ({ accessLevel, file, key, onProgress, path, processFile, useAc
313
313
  const { file: data, key: processedKey, ...rest } = await resolveFile({ file, key, processFile });
314
314
  const contentType = file.type || 'binary/octet-stream';
315
315
  // IMPORTANT: always pass `...rest` here for backwards compatibility
316
- const options = { contentType, onProgress, useAccelerateEndpoint, ...rest };
316
+ const options = {
317
+ bucket,
318
+ contentType,
319
+ onProgress,
320
+ useAccelerateEndpoint,
321
+ ...rest,
322
+ };
317
323
  let inputResult;
318
324
  if (hasKeyInput) {
319
325
  // legacy handling of `path` is to prefix to `fileKey`
@@ -357,7 +363,7 @@ async function uploadFile({ input, onError, onStart, onComplete, }) {
357
363
  return uploadTask;
358
364
  }
359
365
 
360
- function useUploadFiles({ accessLevel, files, isResumable, maxFileCount, onUploadError, onUploadStart, onUploadSuccess, path, processFile, setUploadingFile, setUploadProgress, setUploadSuccess, useAccelerateEndpoint, }) {
366
+ function useUploadFiles({ accessLevel, bucket, files, isResumable, maxFileCount, onUploadError, onUploadStart, onUploadSuccess, path, processFile, setUploadingFile, setUploadProgress, setUploadSuccess, useAccelerateEndpoint, }) {
361
367
  React__namespace.useEffect(() => {
362
368
  const filesReadyToUpload = files.filter((file) => file.status === FileStatus.QUEUED);
363
369
  if (filesReadyToUpload.length > maxFileCount) {
@@ -377,6 +383,7 @@ function useUploadFiles({ accessLevel, files, isResumable, maxFileCount, onUploa
377
383
  if (file) {
378
384
  const input = getInput({
379
385
  accessLevel,
386
+ bucket,
380
387
  file,
381
388
  key,
382
389
  onProgress,
@@ -411,6 +418,7 @@ function useUploadFiles({ accessLevel, files, isResumable, maxFileCount, onUploa
411
418
  }, [
412
419
  files,
413
420
  accessLevel,
421
+ bucket,
414
422
  isResumable,
415
423
  setUploadProgress,
416
424
  setUploadingFile,
@@ -554,8 +562,8 @@ function FilePicker$1({ children, className = ui.ComponentClassName.FileUploader
554
562
  const logger$1 = ui.getLogger('Storage');
555
563
  const MISSING_REQUIRED_PROPS_MESSAGE$1 = '`FileUploader` requires a `maxFileCount` prop to be provided.';
556
564
  const ACCESS_LEVEL_WITH_PATH_CALLBACK_MESSAGE$1 = '`FileUploader` does not allow usage of a `path` callback prop with an `accessLevel` prop.';
557
- const ACCESS_LEVEL_DEPRECATION_MESSAGE$1 = '`accessLevel` has been deprecated and will be removed in a future major version. See migration notes at https://ui.docs.amplify.aws/react/connected-components/storage/FileUploader';
558
- const FileUploaderBase = React__namespace.forwardRef(function FileUploader({ acceptedFileTypes = [], accessLevel, autoUpload = true, components, defaultFiles, displayText: overrideDisplayText, isResumable = false, maxFileCount, maxFileSize, onFileRemove, onUploadError, onUploadStart, onUploadSuccess, path, processFile, showThumbnails = true, useAccelerateEndpoint, }, ref) {
565
+ const ACCESS_LEVEL_DEPRECATION_MESSAGE$1 = '`accessLevel` has been deprecated and will be removed in a future major version. See migration notes at https://ui.docs.amplify.aws/react/connected-components/storage/fileuploader#deprecated-props';
566
+ const FileUploaderBase = React__namespace.forwardRef(function FileUploader({ acceptedFileTypes = [], accessLevel, autoUpload = true, bucket, components, defaultFiles, displayText: overrideDisplayText, isResumable = false, maxFileCount, maxFileSize, onFileRemove, onUploadError, onUploadStart, onUploadSuccess, path, processFile, showThumbnails = true, useAccelerateEndpoint, }, ref) {
559
567
  if (!maxFileCount) {
560
568
  // eslint-disable-next-line no-console
561
569
  console.warn(MISSING_REQUIRED_PROPS_MESSAGE$1);
@@ -610,6 +618,7 @@ const FileUploaderBase = React__namespace.forwardRef(function FileUploader({ acc
610
618
  });
611
619
  useUploadFiles({
612
620
  accessLevel,
621
+ bucket,
613
622
  files,
614
623
  isResumable,
615
624
  maxFileCount,
@@ -729,7 +738,7 @@ const getDeprecationMessage = ({ hasImgkey, hasPath, hasDeprecatedOptions, }) =>
729
738
  }
730
739
  return message;
731
740
  };
732
- const StorageImage = ({ accessLevel, className, fallbackSrc, identityId, imgKey, path, onStorageGetError, onGetUrlError, validateObjectExistence = true, ...rest }) => {
741
+ const StorageImage = ({ accessLevel, bucket, className, fallbackSrc, identityId, imgKey, path, onStorageGetError, onGetUrlError, validateObjectExistence = true, ...rest }) => {
733
742
  const hasImgkey = !!imgKey;
734
743
  const hasPath = !!path;
735
744
  const hasDeprecatedOptions = !!accessLevel || !!identityId;
@@ -753,10 +762,19 @@ const StorageImage = ({ accessLevel, className, fallbackSrc, identityId, imgKey,
753
762
  onError,
754
763
  options: {
755
764
  accessLevel,
765
+ bucket,
756
766
  targetIdentityId: identityId,
757
767
  validateObjectExistence,
758
768
  },
759
- }), [accessLevel, imgKey, identityId, onError, path, validateObjectExistence]);
769
+ }), [
770
+ accessLevel,
771
+ bucket,
772
+ imgKey,
773
+ identityId,
774
+ onError,
775
+ path,
776
+ validateObjectExistence,
777
+ ]);
760
778
  const { url } = uiReactCore.useGetUrl(input);
761
779
  return (React__namespace.createElement(uiReact.Image, { ...rest, className: ui.classNames(ui.ComponentClassName.StorageImage, className), src: url?.toString() ?? fallbackSrc }));
762
780
  };
@@ -891,7 +909,7 @@ const logger = ui.getLogger('Storage');
891
909
  const MISSING_REQUIRED_PROPS_MESSAGE = '`StorageManager` requires a `maxFileCount` prop to be provided.';
892
910
  const ACCESS_LEVEL_WITH_PATH_CALLBACK_MESSAGE = '`StorageManager` does not allow usage of a `path` callback prop with an `accessLevel` prop.';
893
911
  const ACCESS_LEVEL_DEPRECATION_MESSAGE = '`accessLevel` has been deprecated and will be removed in a future major version. See migration notes at https://ui.docs.amplify.aws/react/connected-components/storage/storagemanager';
894
- const StorageManagerBase = React__namespace.forwardRef(function StorageManager({ acceptedFileTypes = [], accessLevel, autoUpload = true, components, defaultFiles, displayText: overrideDisplayText, isResumable = false, maxFileCount, maxFileSize, onFileRemove, onUploadError, onUploadStart, onUploadSuccess, path, processFile, showThumbnails = true, useAccelerateEndpoint, }, ref) {
912
+ const StorageManagerBase = React__namespace.forwardRef(function StorageManager({ acceptedFileTypes = [], accessLevel, autoUpload = true, bucket, components, defaultFiles, displayText: overrideDisplayText, isResumable = false, maxFileCount, maxFileSize, onFileRemove, onUploadError, onUploadStart, onUploadSuccess, path, processFile, showThumbnails = true, useAccelerateEndpoint, }, ref) {
895
913
  uiReactCore.useDeprecationWarning({
896
914
  message: 'The `StorageManager` component has been renamed as the `FileUploader` component.',
897
915
  shouldWarn: false,
@@ -950,6 +968,7 @@ const StorageManagerBase = React__namespace.forwardRef(function StorageManager({
950
968
  });
951
969
  useUploadFiles({
952
970
  accessLevel,
971
+ bucket,
953
972
  files,
954
973
  isResumable,
955
974
  maxFileCount,
@@ -3,7 +3,7 @@ import { FileUploaderProps, FileUploaderPathProps, FileUploaderHandle } from './
3
3
  import { Container, DropZone, FileList, FileListHeader, FileListFooter, FilePicker } from './ui';
4
4
  export declare const MISSING_REQUIRED_PROPS_MESSAGE = "`FileUploader` requires a `maxFileCount` prop to be provided.";
5
5
  export declare const ACCESS_LEVEL_WITH_PATH_CALLBACK_MESSAGE = "`FileUploader` does not allow usage of a `path` callback prop with an `accessLevel` prop.";
6
- export declare const ACCESS_LEVEL_DEPRECATION_MESSAGE = "`accessLevel` has been deprecated and will be removed in a future major version. See migration notes at https://ui.docs.amplify.aws/react/connected-components/storage/FileUploader";
6
+ export declare const ACCESS_LEVEL_DEPRECATION_MESSAGE = "`accessLevel` has been deprecated and will be removed in a future major version. See migration notes at https://ui.docs.amplify.aws/react/connected-components/storage/fileuploader#deprecated-props";
7
7
  declare const FileUploader: React.ForwardRefExoticComponent<(FileUploaderProps | FileUploaderPathProps) & React.RefAttributes<FileUploaderHandle>> & {
8
8
  Container: typeof Container;
9
9
  DropZone: typeof DropZone;
@@ -1,8 +1,9 @@
1
1
  import { PathCallback } from '../../utils';
2
- import { FileUploaderProps } from '../../types';
2
+ import { FileUploaderProps, StorageBucket } from '../../types';
3
3
  import { UseFileUploader } from '../useFileUploader';
4
4
  export interface UseUploadFilesProps extends Pick<FileUploaderProps, 'isResumable' | 'onUploadSuccess' | 'onUploadError' | 'onUploadStart' | 'maxFileCount' | 'processFile' | 'useAccelerateEndpoint'>, Pick<UseFileUploader, 'setUploadingFile' | 'setUploadProgress' | 'setUploadSuccess' | 'files'> {
5
5
  accessLevel?: FileUploaderProps['accessLevel'];
6
+ bucket?: StorageBucket;
6
7
  path?: string | PathCallback;
7
8
  }
8
- export declare function useUploadFiles({ accessLevel, files, isResumable, maxFileCount, onUploadError, onUploadStart, onUploadSuccess, path, processFile, setUploadingFile, setUploadProgress, setUploadSuccess, useAccelerateEndpoint, }: UseUploadFilesProps): void;
9
+ export declare function useUploadFiles({ accessLevel, bucket, files, isResumable, maxFileCount, onUploadError, onUploadStart, onUploadSuccess, path, processFile, setUploadingFile, setUploadProgress, setUploadSuccess, useAccelerateEndpoint, }: UseUploadFilesProps): void;
@@ -1,6 +1,11 @@
1
1
  import * as React from 'react';
2
2
  import { ContainerProps, DropZoneProps, FileListHeaderProps, FileListFooterProps, FileListProps, FilePickerProps } from './ui';
3
3
  import { FileUploaderDisplayText, PathCallback, UploadTask } from './utils';
4
+ export interface BucketInfo {
5
+ bucketName: string;
6
+ region: string;
7
+ }
8
+ export type StorageBucket = string | BucketInfo;
4
9
  export declare enum FileStatus {
5
10
  ADDED = "added",
6
11
  QUEUED = "queued",
@@ -115,8 +120,9 @@ export interface FileUploaderProps {
115
120
  */
116
121
  path?: string;
117
122
  useAccelerateEndpoint?: boolean;
123
+ bucket?: never;
118
124
  }
119
- export interface FileUploaderPathProps extends Omit<FileUploaderProps, 'accessLevel' | 'path'> {
125
+ export interface FileUploaderPathProps extends Omit<FileUploaderProps, 'accessLevel' | 'bucket' | 'path'> {
120
126
  /**
121
127
  * S3 bucket key, allows either a `string` or a `PathCallback`:
122
128
  * - `string`: `path` is prefixed to the file `key` for each file
@@ -125,5 +131,6 @@ export interface FileUploaderPathProps extends Omit<FileUploaderProps, 'accessLe
125
131
  */
126
132
  path: string | PathCallback;
127
133
  accessLevel?: never;
134
+ bucket?: StorageBucket;
128
135
  useAccelerateEndpoint?: boolean;
129
136
  }
@@ -1,8 +1,9 @@
1
1
  import { UploadDataWithPathInput, UploadDataInput } from 'aws-amplify/storage';
2
- import { ProcessFile, StorageAccessLevel } from '../types';
2
+ import { ProcessFile, StorageAccessLevel, StorageBucket } from '../types';
3
3
  import { PathCallback, PathInput } from './uploadFile';
4
4
  export interface GetInputParams {
5
5
  accessLevel: StorageAccessLevel | undefined;
6
+ bucket?: StorageBucket;
6
7
  file: File;
7
8
  key: string;
8
9
  onProgress: NonNullable<UploadDataWithPathInput['options']>['onProgress'];
@@ -10,4 +11,4 @@ export interface GetInputParams {
10
11
  processFile: ProcessFile | undefined;
11
12
  useAccelerateEndpoint?: boolean;
12
13
  }
13
- export declare const getInput: ({ accessLevel, file, key, onProgress, path, processFile, useAccelerateEndpoint, }: GetInputParams) => () => Promise<PathInput | UploadDataInput>;
14
+ export declare const getInput: ({ accessLevel, bucket, file, key, onProgress, path, processFile, useAccelerateEndpoint, }: GetInputParams) => () => Promise<PathInput | UploadDataInput>;
@@ -6,6 +6,7 @@ export interface DataTableRow {
6
6
  }
7
7
  export interface DataTableProps {
8
8
  headers: WithKey<DataTableHeader>[];
9
+ isLoading?: boolean;
9
10
  rows: WithKey<DataTableRow>[];
10
11
  }
11
- export declare const DataTable: ({ headers, rows, }: DataTableProps) => React.JSX.Element;
12
+ export declare const DataTable: ({ headers, isLoading, rows, }: DataTableProps) => React.JSX.Element;
@@ -1,2 +1,2 @@
1
- import { LocationDetailViewHeaders } from './types';
2
- export declare const LOCATION_DETAIL_VIEW_HEADERS: LocationDetailViewHeaders;
1
+ import { HeaderKeys } from './types';
2
+ export declare const LOCATION_DETAIL_VIEW_HEADERS: HeaderKeys[];
@@ -0,0 +1,11 @@
1
+ import { LocationDetailViewHeaders } from './types';
2
+ export declare const getHeaders: ({ tableColumnLastModifiedHeader, tableColumnNameHeader, tableColumnSizeHeader, tableColumnTypeHeader, areAllFilesSelected, selectAllFilesLabel, onSelectAll, hasFiles, }: {
3
+ tableColumnLastModifiedHeader: string;
4
+ tableColumnNameHeader: string;
5
+ tableColumnSizeHeader: string;
6
+ tableColumnTypeHeader: string;
7
+ areAllFilesSelected: boolean;
8
+ selectAllFilesLabel: string;
9
+ onSelectAll: () => void;
10
+ hasFiles: boolean;
11
+ }) => LocationDetailViewHeaders;
@@ -1,8 +1,10 @@
1
1
  import { FileData, FileDataItem, LocationItemData, LocationData } from '../../../actions';
2
2
  import { DataTableProps } from '../../../composables/DataTable';
3
+ import { DefaultLocationDetailViewDisplayText } from '../../../displayText/types';
3
4
  import { LocationState } from '../../../providers/store/location';
4
- export declare const getLocationDetailViewTableData: ({ areAllFilesSelected, location, fileDataItems, hasFiles, pageItems, selectFileLabel, selectAllFilesLabel, getDateDisplayValue, onDownload, onNavigate, onSelect, onSelectAll, }: {
5
+ export declare const getLocationDetailViewTableData: ({ areAllFilesSelected, displayText, location, fileDataItems, hasFiles, pageItems, selectFileLabel, selectAllFilesLabel, getDateDisplayValue, onDownload, onNavigate, onSelect, onSelectAll, }: {
5
6
  areAllFilesSelected: boolean;
7
+ displayText: DefaultLocationDetailViewDisplayText;
6
8
  location: LocationState;
7
9
  fileDataItems?: FileData[] | undefined;
8
10
  hasFiles: boolean;
@@ -4,4 +4,4 @@ export declare const MISSING_REQUIRED_PROP_MESSAGE = "`StorageImage` requires ei
4
4
  export declare const HAS_DEPRECATED_PROPS_MESSAGE = "`imgKey`, `accessLevel`, and `identityId` will be replaced with `path` in a future major version. See https://ui.docs.amplify.aws/react/connected-components/storage/storageimage#props";
5
5
  export declare const HAS_PATH_AND_KEY_MESSAGE = "`imgKey` is ignored when both `imgKey` and `path` props are provided.";
6
6
  export declare const HAS_PATH_AND_UNSUPPORTED_OPTIONS_MESSAGE = "`accessLevel` and `identityId` are ignored when the `path` prop is provided.";
7
- export declare const StorageImage: ({ accessLevel, className, fallbackSrc, identityId, imgKey, path, onStorageGetError, onGetUrlError, validateObjectExistence, ...rest }: StorageImageProps | StorageImagePathProps) => React.JSX.Element;
7
+ export declare const StorageImage: ({ accessLevel, bucket, className, fallbackSrc, identityId, imgKey, path, onStorageGetError, onGetUrlError, validateObjectExistence, ...rest }: StorageImageProps | StorageImagePathProps) => React.JSX.Element;
@@ -1,4 +1,5 @@
1
1
  import { ImageProps } from '@aws-amplify/ui-react';
2
+ import { StorageBucket } from '../FileUploader/types';
2
3
  type StorageAccessLevel = 'guest' | 'protected' | 'private';
3
4
  export interface StorageImageProps extends Omit<ImageProps, 'src'> {
4
5
  /**
@@ -11,6 +12,7 @@ export interface StorageImageProps extends Omit<ImageProps, 'src'> {
11
12
  * `accessLevel` will be replaced with `path` in a future major version of Amplify UI. See https://ui.docs.amplify.aws/react/connected-components/storage/storageimage#props
12
13
  */
13
14
  accessLevel: StorageAccessLevel;
15
+ bucket?: never;
14
16
  /**
15
17
  * @deprecated
16
18
  * `identityId` will be replaced with `path` in a future major version of Amplify UI. See https://ui.docs.amplify.aws/react/connected-components/storage/storageimage#props
@@ -27,13 +29,14 @@ export interface StorageImageProps extends Omit<ImageProps, 'src'> {
27
29
  onGetUrlError?: (error: Error) => void;
28
30
  path?: never;
29
31
  }
30
- type OmittedPropKey = 'accessLevel' | 'imgKey' | 'identityId' | 'onStorageGetError' | 'path';
32
+ type OmittedPropKey = 'accessLevel' | 'bucket' | 'imgKey' | 'identityId' | 'onStorageGetError' | 'path';
31
33
  export interface StorageImagePathProps extends Omit<StorageImageProps, OmittedPropKey> {
32
34
  path: string | ((input: {
33
35
  identityId?: string;
34
36
  }) => string);
35
37
  imgKey?: never;
36
38
  accessLevel?: never;
39
+ bucket?: StorageBucket;
37
40
  identityId?: never;
38
41
  onStorageGetError?: never;
39
42
  }
@@ -1,7 +1,10 @@
1
- import * as React from 'react';
2
- import { FileStatus, StorageAccessLevel } from '../FileUploader/types';
3
- import { FileUploaderDisplayText as StorageManagerDisplayText, PathCallback, UploadTask } from '../FileUploader/utils';
4
- import { ContainerProps, DropZoneProps, FileListHeaderProps, FileListFooterProps, FileListProps, FilePickerProps } from './ui';
1
+ import { FileStatus, FileUploaderProps } from '../FileUploader/types';
2
+ import { PathCallback, UploadTask } from '../FileUploader/utils';
3
+ interface BucketInfo {
4
+ bucketName: string;
5
+ region: string;
6
+ }
7
+ export type StorageBucket = string | BucketInfo;
5
8
  export interface StorageFile {
6
9
  id: string;
7
10
  file?: File;
@@ -24,91 +27,14 @@ export type ProcessFile = (params: ProcessFileParams) => Promise<ProcessFilePara
24
27
  export interface StorageManagerHandle {
25
28
  clearFiles: () => void;
26
29
  }
27
- export interface StorageManagerProps {
28
- /**
29
- * List of accepted File types, values of `['*']` or undefined allow any files
30
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/accept
31
- */
32
- acceptedFileTypes?: string[];
33
- /**
34
- * Access level for file uploads
35
- * @see https://docs.amplify.aws/lib/storage/configureaccess/q/platform/js/
36
- */
37
- accessLevel: StorageAccessLevel;
38
- /**
39
- * Determines if the upload will automatically start after a file is selected, default value: true
40
- */
41
- autoUpload?: boolean;
42
- /**
43
- * Component overrides
44
- */
45
- components?: {
46
- Container?: React.ComponentType<ContainerProps>;
47
- DropZone?: React.ComponentType<DropZoneProps>;
48
- FileList?: React.ComponentType<FileListProps>;
49
- FilePicker?: React.ComponentType<FilePickerProps>;
50
- FileListHeader?: React.ComponentType<FileListHeaderProps>;
51
- FileListFooter?: React.ComponentType<FileListFooterProps>;
52
- };
53
- /**
54
- * List of default files already uploaded
55
- */
56
- defaultFiles?: DefaultFile[];
57
- /**
58
- * Overrides default display text
59
- */
60
- displayText?: StorageManagerDisplayText;
61
- /**
62
- * Determines if upload can be paused / resumed
63
- */
64
- isResumable?: boolean;
65
- /**
66
- * Maximum total files to upload in each batch
67
- */
68
- maxFileCount: number;
69
- /**
70
- * Maximum file size in bytes
71
- */
72
- maxFileSize?: number;
73
- /**
74
- * When a file is removed
75
- */
76
- onFileRemove?: (file: {
77
- key: string;
78
- }) => void;
79
- /**
80
- * Monitor upload errors
81
- */
82
- onUploadError?: (error: string, file: {
83
- key: string;
84
- }) => void;
85
- /**
86
- * Monitor upload success
87
- */
88
- onUploadSuccess?: (event: {
89
- key?: string;
90
- }) => void;
91
- /**
92
- * When a file begins uploading
93
- */
94
- onUploadStart?: (event: {
95
- key?: string;
96
- }) => void;
97
- /**
98
- * Process file before upload
99
- */
100
- processFile?: ProcessFile;
101
- /**
102
- * Determines if thumbnails show for image files
103
- */
104
- showThumbnails?: boolean;
105
- /**
106
- * Provided value is prefixed to the file `key` for each file
107
- */
108
- path?: string;
109
- useAccelerateEndpoint?: boolean;
30
+ export interface StorageManagerProps extends FileUploaderProps {
110
31
  }
111
- export interface StorageManagerPathProps extends Omit<StorageManagerProps, 'accessLevel' | 'path'> {
32
+ export interface StorageManagerPathProps extends Omit<StorageManagerProps, 'accessLevel' | 'bucket' | 'path'> {
33
+ /** S3 bucket, allows either a string or `BucketInfo`:
34
+ * - `string`: the "friendly name" assigned to the bucket
35
+ * - `BucketInfo`: object containing the actual S3 bucket name and its region
36
+ */
37
+ bucket?: StorageBucket;
112
38
  /**
113
39
  * S3 bucket key, allows either a `string` or a `PathCallback`:
114
40
  * - `string`: `path` is prefixed to the file `key` for each file
@@ -119,3 +45,4 @@ export interface StorageManagerPathProps extends Omit<StorageManagerProps, 'acce
119
45
  accessLevel?: never;
120
46
  useAccelerateEndpoint?: boolean;
121
47
  }
48
+ export {};
@@ -1 +1 @@
1
- export declare const VERSION = "3.7.2";
1
+ export declare const VERSION = "3.8.1";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-amplify/ui-react-storage",
3
- "version": "3.7.2",
3
+ "version": "3.8.1",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/esm/index.mjs",
6
6
  "exports": {
@@ -45,9 +45,9 @@
45
45
  "typecheck": "tsc --noEmit"
46
46
  },
47
47
  "dependencies": {
48
- "@aws-amplify/ui": "6.8.1",
49
- "@aws-amplify/ui-react": "6.9.1",
50
- "@aws-amplify/ui-react-core": "3.3.1",
48
+ "@aws-amplify/ui": "6.8.2",
49
+ "@aws-amplify/ui-react": "6.9.2",
50
+ "@aws-amplify/ui-react-core": "3.3.2",
51
51
  "tslib": "^2.5.2"
52
52
  },
53
53
  "peerDependencies": {