@aws-amplify/ui-react-storage 3.16.0 → 3.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/browser.js +1 -1
  2. package/dist/{createStorageBrowser-B-J76Lyp.js → createStorageBrowser-De4hcP-u.js} +87 -54
  3. package/dist/esm/browser.mjs +1 -0
  4. package/dist/esm/components/StorageBrowser/ErrorBoundary/ErrorBoundary.mjs +1 -0
  5. package/dist/esm/components/StorageBrowser/components/ComponentsProvider.mjs +1 -0
  6. package/dist/esm/components/StorageBrowser/components/base/preview/DownloadButton.mjs +1 -0
  7. package/dist/esm/components/StorageBrowser/configuration/paginationContext.mjs +15 -0
  8. package/dist/esm/components/StorageBrowser/controls/DataTableControl.mjs +1 -0
  9. package/dist/esm/components/StorageBrowser/createStorageBrowser/StorageBrowserDefault.mjs +1 -0
  10. package/dist/esm/components/StorageBrowser/createStorageBrowser/createProvider.mjs +11 -9
  11. package/dist/esm/components/StorageBrowser/createStorageBrowser/createStorageBrowser.mjs +1 -0
  12. package/dist/esm/components/StorageBrowser/useAction/useHandler.mjs +1 -0
  13. package/dist/esm/components/StorageBrowser/useAction/useListFolderItems.mjs +1 -0
  14. package/dist/esm/components/StorageBrowser/useAction/useListLocationItems.mjs +1 -0
  15. package/dist/esm/components/StorageBrowser/utils/validatePageSize.mjs +12 -0
  16. package/dist/esm/components/StorageBrowser/views/LocationActionView/CopyView/CopyView.mjs +1 -0
  17. package/dist/esm/components/StorageBrowser/views/LocationActionView/CopyView/CopyViewProvider.mjs +1 -0
  18. package/dist/esm/components/StorageBrowser/views/LocationActionView/CopyView/FoldersMessageControl.mjs +1 -0
  19. package/dist/esm/components/StorageBrowser/views/LocationActionView/CopyView/useCopyView.mjs +1 -0
  20. package/dist/esm/components/StorageBrowser/views/LocationActionView/CopyView/useFolders.mjs +1 -0
  21. package/dist/esm/components/StorageBrowser/views/LocationActionView/CreateFolderView/CreateFolderView.mjs +1 -0
  22. package/dist/esm/components/StorageBrowser/views/LocationActionView/CreateFolderView/useCreateFolderView.mjs +1 -0
  23. package/dist/esm/components/StorageBrowser/views/LocationActionView/DeleteView/DeleteView.mjs +1 -0
  24. package/dist/esm/components/StorageBrowser/views/LocationActionView/DeleteView/useDeleteView.mjs +1 -0
  25. package/dist/esm/components/StorageBrowser/views/LocationActionView/DownloadView/DownloadView.mjs +1 -0
  26. package/dist/esm/components/StorageBrowser/views/LocationActionView/DownloadView/useDownloadView.mjs +1 -0
  27. package/dist/esm/components/StorageBrowser/views/LocationActionView/UploadView/UploadView.mjs +2 -1
  28. package/dist/esm/components/StorageBrowser/views/LocationActionView/UploadView/useUploadView.mjs +11 -8
  29. package/dist/esm/components/StorageBrowser/views/LocationDetailView/LocationDetailView.mjs +1 -0
  30. package/dist/esm/components/StorageBrowser/views/LocationDetailView/useLocationDetailView.mjs +14 -11
  31. package/dist/esm/components/StorageBrowser/views/LocationsView/LocationsView.mjs +1 -0
  32. package/dist/esm/components/StorageBrowser/views/LocationsView/LocationsViewProvider.mjs +1 -0
  33. package/dist/esm/components/StorageBrowser/views/LocationsView/useLocationsView.mjs +13 -10
  34. package/dist/esm/components/StorageBrowser/views/context/actionViews.mjs +5 -4
  35. package/dist/esm/components/StorageBrowser/views/context/primaryViews.mjs +1 -0
  36. package/dist/esm/components/StorageBrowser/views/hooks/usePaginate.mjs +18 -7
  37. package/dist/esm/version.mjs +1 -1
  38. package/dist/index.js +1 -1
  39. package/dist/types/components/StorageBrowser/StorageBrowserAmplify.d.ts +3 -1
  40. package/dist/types/components/StorageBrowser/configuration/index.d.ts +2 -0
  41. package/dist/types/components/StorageBrowser/configuration/paginationContext.d.ts +12 -0
  42. package/dist/types/components/StorageBrowser/createStorageBrowser/types.d.ts +7 -1
  43. package/dist/types/components/StorageBrowser/store/types.d.ts +7 -0
  44. package/dist/types/components/StorageBrowser/utils/index.d.ts +1 -0
  45. package/dist/types/components/StorageBrowser/utils/validatePageSize.d.ts +1 -0
  46. package/dist/types/components/StorageBrowser/views/LocationActionView/UploadView/types.d.ts +7 -0
  47. package/dist/types/components/StorageBrowser/views/LocationDetailView/types.d.ts +2 -2
  48. package/dist/types/components/StorageBrowser/views/LocationsView/types.d.ts +2 -2
  49. package/dist/types/components/StorageBrowser/views/hooks/usePaginate.d.ts +1 -1
  50. package/dist/types/components/StorageBrowser/views/types.d.ts +6 -0
  51. package/dist/types/index.d.ts +1 -1
  52. package/dist/types/version.d.ts +1 -1
  53. package/package.json +5 -5
package/dist/browser.js CHANGED
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var internals = require('@aws-amplify/storage/internals');
6
6
  require('aws-amplify');
7
7
  require('@aws-amplify/ui');
8
- var createStorageBrowser = require('./createStorageBrowser-B-J76Lyp.js');
8
+ var createStorageBrowser = require('./createStorageBrowser-De4hcP-u.js');
9
9
  require('jszip');
10
10
  require('aws-amplify/storage');
11
11
  require('react');
@@ -36,7 +36,7 @@ function _interopNamespace(e) {
36
36
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
37
37
  var JSZip__default = /*#__PURE__*/_interopDefault(JSZip);
38
38
 
39
- const VERSION = '3.16.0';
39
+ const VERSION = '3.17.0';
40
40
 
41
41
  const DEFAULT_CHECKSUM_ALGORITHM = 'crc-32';
42
42
  // 5MiB for multipart upload
@@ -665,7 +665,7 @@ const downloadHandler = (() => {
665
665
  return handler;
666
666
  })();
667
667
 
668
- const DEFAULT_PAGE_SIZE$5 = 1000;
668
+ const DEFAULT_PAGE_SIZE$2 = 1000;
669
669
  const parseItems = (items, excludedPath) => items
670
670
  // remove root `key` from results
671
671
  .filter(({ path }) => path !== excludedPath)
@@ -698,7 +698,7 @@ const parseResult = ({ excludedSubpaths, items }, prefix) => filterDotItems([...
698
698
  const listLocationItemsHandler = async (input) => {
699
699
  const { config, prefix, options } = input;
700
700
  const { bucket: _bucket, credentials, customEndpoint, region: globalRegion, accountId, } = config;
701
- const { exclude, delimiter, nextToken, pageSize: _pageSize = DEFAULT_PAGE_SIZE$5, ..._options } = options ?? {};
701
+ const { exclude, delimiter, nextToken, pageSize: _pageSize = DEFAULT_PAGE_SIZE$2, ..._options } = options ?? {};
702
702
  const bucketRegion = getBucketRegion(_bucket, globalRegion);
703
703
  const bucket = { bucketName: _bucket, region: bucketRegion };
704
704
  const subpathStrategy = {
@@ -1814,10 +1814,10 @@ function useCredentialsStore({ getLocationCredentials: handler, initialValue, on
1814
1814
  return store;
1815
1815
  }
1816
1816
 
1817
- const ERROR_MESSAGE$2 = '`useCredentials` must be called from within a `CredentialsProvider`.';
1817
+ const ERROR_MESSAGE$3 = '`useCredentials` must be called from within a `CredentialsProvider`.';
1818
1818
  const { useCredentials, CredentialsContext } = uiReactCore.createContextUtilities({
1819
1819
  contextName: 'Credentials',
1820
- errorMessage: ERROR_MESSAGE$2,
1820
+ errorMessage: ERROR_MESSAGE$3,
1821
1821
  });
1822
1822
  function CredentialsProvider({ children, ...props }) {
1823
1823
  const initialValue = React__namespace["default"].useContext(CredentialsContext);
@@ -2017,10 +2017,10 @@ function useGetActionInputCallback({ accountId, customEndpoint, region, }) {
2017
2017
  }, [accountId, current, customEndpoint, getCredentials, key, region]);
2018
2018
  }
2019
2019
 
2020
- const ERROR_MESSAGE$1 = '`useGetActionInput` must be called from within a `ConfigurationProvider`.';
2020
+ const ERROR_MESSAGE$2 = '`useGetActionInput` must be called from within a `ConfigurationProvider`.';
2021
2021
  const { useGetActionInput, GetActionInputContext } = uiReactCore.createContextUtilities({
2022
2022
  contextName: 'GetActionInput',
2023
- errorMessage: ERROR_MESSAGE$1,
2023
+ errorMessage: ERROR_MESSAGE$2,
2024
2024
  });
2025
2025
  function GetActionInputProvider({ accountId, children, customEndpoint, region, }) {
2026
2026
  const value = useGetActionInputCallback({
@@ -2042,6 +2042,27 @@ function createConfigurationProvider(input) {
2042
2042
  return Provider;
2043
2043
  }
2044
2044
 
2045
+ const DEFAULT_PAGE_SIZE$1 = 100;
2046
+ const validatePageSize = (pageSize) => {
2047
+ if (pageSize === undefined ||
2048
+ pageSize === null ||
2049
+ !Number.isInteger(pageSize) ||
2050
+ pageSize < 1) {
2051
+ return DEFAULT_PAGE_SIZE$1;
2052
+ }
2053
+ return pageSize;
2054
+ };
2055
+
2056
+ const ERROR_MESSAGE$1 = '`usePaginationConfig` must be called from within a `PaginationConfigProvider`.';
2057
+ const { usePaginationConfig, PaginationConfigContext } = uiReactCore.createContextUtilities({
2058
+ contextName: 'PaginationConfig',
2059
+ errorMessage: ERROR_MESSAGE$1,
2060
+ });
2061
+ function PaginationConfigProvider({ children, pageSize, }) {
2062
+ const value = React__namespace["default"].useMemo(() => ({ pageSize: validatePageSize(pageSize) }), [pageSize]);
2063
+ return (React__namespace["default"].createElement(PaginationConfigContext.Provider, { value: value }, children));
2064
+ }
2065
+
2045
2066
  const DEFAULT_ACTION_CONCURRENCY = 4;
2046
2067
  const USE_LIST_ERROR_MESSAGE = '`useList` must be called from within `StorageBrowser.Provider`';
2047
2068
 
@@ -4994,8 +5015,7 @@ function FileItemsProvider({ children, validateFile, }) {
4994
5015
 
4995
5016
  const DEFAULT_OVERWRITE_ENABLED = false;
4996
5017
 
4997
- const DEFAULT_PAGE_SIZE$4 = 100;
4998
- const usePaginate = ({ items, onPaginate, page = 1, pageSize = DEFAULT_PAGE_SIZE$4, }) => {
5018
+ const usePaginate = ({ items, onPaginate, page = 1, pageSize, }) => {
4999
5019
  const [currentPage, setCurrentPage] = React__namespace["default"].useState(page);
5000
5020
  const visitedRef = React__namespace["default"].useRef(page);
5001
5021
  const handleReset = React__namespace["default"].useRef(() => {
@@ -5005,19 +5025,31 @@ const usePaginate = ({ items, onPaginate, page = 1, pageSize = DEFAULT_PAGE_SIZE
5005
5025
  }).current;
5006
5026
  return React__namespace["default"].useMemo(() => {
5007
5027
  const hasItems = Array.isArray(items);
5028
+ const totalItems = hasItems ? items.length : 0;
5029
+ const totalPages = Math.max(1, Math.ceil(totalItems / pageSize));
5030
+ // Auto-adjust current page if it's beyond available pages
5031
+ // For server-side pagination, don't auto-adjust if onPaginate callback is provided
5032
+ let adjustedCurrentPage = currentPage;
5033
+ if (currentPage > totalPages && !ui.isFunction(onPaginate)) {
5034
+ adjustedCurrentPage = totalPages;
5035
+ setCurrentPage(adjustedCurrentPage);
5036
+ }
5008
5037
  const highestPageVisited = visitedRef.current;
5009
- const isFirstPage = currentPage === 1;
5010
- const start = isFirstPage ? 0 : (currentPage - 1) * pageSize;
5011
- const end = isFirstPage ? pageSize : currentPage * pageSize;
5038
+ const isFirstPage = adjustedCurrentPage === 1;
5039
+ const start = isFirstPage ? 0 : (adjustedCurrentPage - 1) * pageSize;
5040
+ const end = isFirstPage ? pageSize : adjustedCurrentPage * pageSize;
5012
5041
  const pageItems = hasItems ? items.slice(start, end) : [];
5013
5042
  return {
5014
- currentPage,
5043
+ currentPage: adjustedCurrentPage,
5015
5044
  handlePaginate: (page) => {
5016
5045
  if (page < 1)
5017
5046
  return;
5047
+ // For server-side pagination, allow going beyond totalPages if onPaginate is provided
5048
+ if (page > totalPages && !ui.isFunction(onPaginate))
5049
+ return;
5018
5050
  if (ui.isFunction(onPaginate))
5019
5051
  onPaginate(page);
5020
- if (page > currentPage && page > highestPageVisited)
5052
+ if (page > adjustedCurrentPage && page > highestPageVisited)
5021
5053
  visitedRef.current = page;
5022
5054
  setCurrentPage(page);
5023
5055
  },
@@ -5028,9 +5060,10 @@ const usePaginate = ({ items, onPaginate, page = 1, pageSize = DEFAULT_PAGE_SIZE
5028
5060
  }, [currentPage, handleReset, items, onPaginate, pageSize]);
5029
5061
  };
5030
5062
 
5031
- const DEFAULT_PAGE_SIZE$3 = 100;
5032
5063
  const useUploadView = (options) => {
5033
- const { onExit: _onExit } = options ?? {};
5064
+ const { pageSize: configPageSize } = usePaginationConfig();
5065
+ const { onExit: _onExit, pageSize: propPageSize } = options ?? {};
5066
+ const pageSize = propPageSize ?? configPageSize;
5034
5067
  const [{ location }, storeDispatch] = useStore();
5035
5068
  const [{ validItems, invalidItems: invalidFiles }, fileItemsDispatch] = useFileItems();
5036
5069
  const { current } = location;
@@ -5043,6 +5076,7 @@ const useUploadView = (options) => {
5043
5076
  const [{ isProcessing, isProcessingComplete, statusCounts, tasks }, handleUploads,] = useAction('upload', { items });
5044
5077
  const { currentPage, handlePaginate, pageItems: pageTasks, } = usePaginate({
5045
5078
  items: tasks,
5079
+ pageSize,
5046
5080
  });
5047
5081
  const onDropFiles = (files) => {
5048
5082
  if (files) {
@@ -5080,8 +5114,8 @@ const useUploadView = (options) => {
5080
5114
  statusCounts,
5081
5115
  tasks: pageTasks,
5082
5116
  page: currentPage,
5083
- hasNextPage: currentPage * DEFAULT_PAGE_SIZE$3 < items.length,
5084
- highestPageVisited: Math.ceil(items.length / DEFAULT_PAGE_SIZE$3),
5117
+ hasNextPage: currentPage * pageSize < items.length,
5118
+ highestPageVisited: Math.ceil(items.length / pageSize),
5085
5119
  onActionCancel,
5086
5120
  onActionExit,
5087
5121
  onActionStart,
@@ -5095,7 +5129,7 @@ const useUploadView = (options) => {
5095
5129
 
5096
5130
  const UploadView = ({ className, ...props }) => {
5097
5131
  const state = useUploadView(props);
5098
- return (React__namespace["default"].createElement(ViewElement, { className: ui.classNames(STORAGE_BROWSER_BLOCK, className) },
5132
+ return (React__namespace["default"].createElement(ViewElement, { className: ui.classNames(STORAGE_BROWSER_BLOCK, className), "data-testid": "UPLOAD_VIEW" },
5099
5133
  React__namespace["default"].createElement(UploadViewProvider, { ...state },
5100
5134
  React__namespace["default"].createElement(ActionExitControl, null),
5101
5135
  React__namespace["default"].createElement(TitleControl, null),
@@ -5419,13 +5453,13 @@ function useSearch(props) {
5419
5453
  };
5420
5454
  }
5421
5455
 
5422
- const DEFAULT_PAGE_SIZE$2 = 100;
5423
- const DEFAULT_LIST_OPTIONS$2 = {
5424
- pageSize: DEFAULT_PAGE_SIZE$2,
5456
+ const DEFAULT_PAGE_SIZE = 100;
5457
+ const DEFAULT_LIST_OPTIONS = {
5458
+ pageSize: DEFAULT_PAGE_SIZE,
5425
5459
  delimiter: '/',
5426
5460
  exclude: 'FILE',
5427
5461
  };
5428
- const DEFAULT_REFRESH_OPTIONS = { ...DEFAULT_LIST_OPTIONS$2, refresh: true };
5462
+ const DEFAULT_REFRESH_OPTIONS = { ...DEFAULT_LIST_OPTIONS, refresh: true };
5429
5463
  const useFolders = ({ destination, setDestination, }) => {
5430
5464
  const { current, key } = destination;
5431
5465
  const [{ value, hasError, isLoading, message }, handleList] = useList('folderItems');
@@ -5442,19 +5476,19 @@ const useFolders = ({ destination, setDestination, }) => {
5442
5476
  return;
5443
5477
  handleList({
5444
5478
  prefix: key,
5445
- options: { ...DEFAULT_LIST_OPTIONS$2, nextToken },
5479
+ options: { ...DEFAULT_LIST_OPTIONS, nextToken },
5446
5480
  });
5447
5481
  };
5448
5482
  const { currentPage: page, handlePaginate, highestPageVisited, pageItems, handleReset, } = usePaginate({
5449
5483
  items,
5450
5484
  onPaginate,
5451
- pageSize: DEFAULT_PAGE_SIZE$2,
5485
+ pageSize: DEFAULT_PAGE_SIZE,
5452
5486
  });
5453
5487
  const onSearch = (query) => {
5454
5488
  handleReset();
5455
5489
  handleList({
5456
5490
  prefix: key,
5457
- options: { ...DEFAULT_LIST_OPTIONS$2, search: { query, filterBy: 'key' } },
5491
+ options: { ...DEFAULT_LIST_OPTIONS, search: { query, filterBy: 'key' } },
5458
5492
  });
5459
5493
  };
5460
5494
  const { onSearchSubmit, searchQuery: query, resetSearch, onSearchQueryChange: onQuery, } = useSearch({ onSearch });
@@ -6383,23 +6417,22 @@ function useFilePreview({ activeFile, }) {
6383
6417
  }, [getFilePreview, filePreviewContext, filePreviewContent, enabled]);
6384
6418
  }
6385
6419
 
6386
- const DEFAULT_PAGE_SIZE$1 = 100;
6387
- const DEFAULT_LIST_OPTIONS$1 = {
6388
- delimiter: '/',
6389
- pageSize: DEFAULT_PAGE_SIZE$1,
6390
- };
6391
6420
  const getDownloadErrorMessageFromFailedDownloadTask = (task) => {
6392
6421
  if (!task)
6393
6422
  return;
6394
6423
  return `Failed to download ${task.data.fileKey ?? task.data.key} due to error: ${task.message}.`;
6395
6424
  };
6396
6425
  const useLocationDetailView = (options) => {
6397
- const { initialValues, onExit, onNavigate } = options ?? {};
6398
- const listOptionsRef = React__namespace["default"].useRef({
6399
- ...DEFAULT_LIST_OPTIONS$1,
6426
+ const { pageSize: configPageSize } = usePaginationConfig();
6427
+ const { initialValues = {}, onExit, onNavigate, pageSize: propPageSize, } = options ?? {};
6428
+ const pageSize = propPageSize ?? configPageSize;
6429
+ const listOptions = React__namespace["default"].useMemo(() => ({
6400
6430
  ...initialValues,
6401
- });
6402
- const listOptions = listOptionsRef.current;
6431
+ delimiter: '/',
6432
+ pageSize,
6433
+ }),
6434
+ // eslint-disable-next-line react-hooks/exhaustive-deps
6435
+ [pageSize, initialValues.delimiter, initialValues.pageSize]);
6403
6436
  const [{ location, actionType }, storeDispatch] = useStore();
6404
6437
  const [locationItems, locationItemsDispatch] = useLocationItems();
6405
6438
  const fileItemsDispatch = useFileItems()[1];
@@ -6829,12 +6862,8 @@ function LocationsViewProvider({ children, ...props }) {
6829
6862
  const DEFAULT_EXCLUDE = {
6830
6863
  exactPermissions: ['delete', 'write'],
6831
6864
  };
6832
- const DEFAULT_PAGE_SIZE = 100;
6833
- const DEFAULT_LIST_OPTIONS = {
6834
- exclude: DEFAULT_EXCLUDE,
6835
- pageSize: DEFAULT_PAGE_SIZE,
6836
- };
6837
6865
  const useLocationsView = (options) => {
6866
+ const { pageSize: configPageSize } = usePaginationConfig();
6838
6867
  const handleDownload = useAction('download')[1];
6839
6868
  const [state, handleList] = useList('locations');
6840
6869
  const dispatchStoreAction = useStore()[1];
@@ -6842,12 +6871,15 @@ const useLocationsView = (options) => {
6842
6871
  const { items, nextToken, hasExhaustedSearch = false } = value;
6843
6872
  const hasNextToken = !!nextToken;
6844
6873
  const onNavigate = options?.onNavigate;
6874
+ const pageSize = options?.pageSize ?? configPageSize;
6845
6875
  const initialValues = options?.initialValues ?? {};
6846
- const listOptionsRef = React__namespace["default"].useRef({
6847
- ...DEFAULT_LIST_OPTIONS,
6876
+ const listOptions = React__namespace["default"].useMemo(() => ({
6848
6877
  ...initialValues,
6849
- });
6850
- const listOptions = listOptionsRef.current;
6878
+ exclude: DEFAULT_EXCLUDE,
6879
+ pageSize,
6880
+ }),
6881
+ // eslint-disable-next-line react-hooks/exhaustive-deps
6882
+ [pageSize, initialValues.pageSize]);
6851
6883
  // initial load
6852
6884
  React__namespace["default"].useEffect(() => {
6853
6885
  handleList({ options: { ...listOptions, refresh: true } });
@@ -7051,17 +7083,18 @@ function createProvider({ actions, components, config, options, filePreview = {}
7051
7083
  * Provides state, configuration and action values that are shared between
7052
7084
  * the primary View components
7053
7085
  */
7054
- function Provider({ children, displayText, views, ...props }) {
7086
+ function Provider({ children, displayText, views, pageSize, ...props }) {
7055
7087
  return (React__namespace["default"].createElement(StoreProvider, { ...props },
7056
7088
  React__namespace["default"].createElement(ConfigurationProvider, null,
7057
- React__namespace["default"].createElement(ActionConfigsProvider, { actionConfigs: actionConfigs },
7058
- React__namespace["default"].createElement(ActionHandlersProvider, { handlers: handlers },
7059
- React__namespace["default"].createElement(DisplayTextProvider, { displayText: displayText },
7060
- React__namespace["default"].createElement(ViewsProvider, { actions: resolvedActions, views: views },
7061
- React__namespace["default"].createElement(ComponentsProvider, { composables: composables },
7062
- React__namespace["default"].createElement(LocationItemsProvider, null,
7063
- React__namespace["default"].createElement(FileItemsProvider, { validateFile: validateFile },
7064
- React__namespace["default"].createElement(FilePreviewProvider, { filePreview: filePreview }, children)))))))))));
7089
+ React__namespace["default"].createElement(PaginationConfigProvider, { pageSize: pageSize },
7090
+ React__namespace["default"].createElement(ActionConfigsProvider, { actionConfigs: actionConfigs },
7091
+ React__namespace["default"].createElement(ActionHandlersProvider, { handlers: handlers },
7092
+ React__namespace["default"].createElement(DisplayTextProvider, { displayText: displayText },
7093
+ React__namespace["default"].createElement(ViewsProvider, { actions: resolvedActions, views: views },
7094
+ React__namespace["default"].createElement(ComponentsProvider, { composables: composables },
7095
+ React__namespace["default"].createElement(LocationItemsProvider, null,
7096
+ React__namespace["default"].createElement(FileItemsProvider, { validateFile: validateFile },
7097
+ React__namespace["default"].createElement(FilePreviewProvider, { filePreview: filePreview }, children))))))))))));
7065
7098
  }
7066
7099
  return Provider;
7067
7100
  }
@@ -18,6 +18,7 @@ import './components/StorageBrowser/useAction/context.mjs';
18
18
  import '@aws-amplify/ui-react-core/elements';
19
19
  import './components/StorageBrowser/credentials/context.mjs';
20
20
  import './components/StorageBrowser/configuration/context.mjs';
21
+ import './components/StorageBrowser/configuration/paginationContext.mjs';
21
22
  import './components/StorageBrowser/displayText/context.mjs';
22
23
  export { DEFAULT_STORAGE_BROWSER_DISPLAY_TEXT as DefaultStorageBrowserDisplayText } from './components/StorageBrowser/displayText/libraries/en/default.mjs';
23
24
  import './components/StorageBrowser/filePreview/context.mjs';
@@ -11,6 +11,7 @@ import '@aws-amplify/ui-react-core/elements';
11
11
  import '../credentials/context.mjs';
12
12
  import '@aws-amplify/storage/internals';
13
13
  import '../configuration/context.mjs';
14
+ import '../configuration/paginationContext.mjs';
14
15
  import '../actions/configs/defaults.mjs';
15
16
  import '../displayText/context.mjs';
16
17
  import '../filePreview/context.mjs';
@@ -11,6 +11,7 @@ import '../useAction/context.mjs';
11
11
  import '../credentials/context.mjs';
12
12
  import '@aws-amplify/storage/internals';
13
13
  import '../configuration/context.mjs';
14
+ import '../configuration/paginationContext.mjs';
14
15
  import '../actions/configs/defaults.mjs';
15
16
  import '../displayText/context.mjs';
16
17
  import '../filePreview/context.mjs';
@@ -11,6 +11,7 @@ import '@aws-amplify/ui-react-core/elements';
11
11
  import '../../../credentials/context.mjs';
12
12
  import '@aws-amplify/storage/internals';
13
13
  import '../../../configuration/context.mjs';
14
+ import '../../../configuration/paginationContext.mjs';
14
15
  import '@aws-amplify/ui';
15
16
  import '../../../actions/configs/defaults.mjs';
16
17
  import { useDisplayText } from '../../../displayText/context.mjs';
@@ -0,0 +1,15 @@
1
+ import React__default from 'react';
2
+ import { createContextUtilities } from '@aws-amplify/ui-react-core';
3
+ import { validatePageSize } from '../utils/validatePageSize.mjs';
4
+
5
+ const ERROR_MESSAGE = '`usePaginationConfig` must be called from within a `PaginationConfigProvider`.';
6
+ const { usePaginationConfig, PaginationConfigContext } = createContextUtilities({
7
+ contextName: 'PaginationConfig',
8
+ errorMessage: ERROR_MESSAGE,
9
+ });
10
+ function PaginationConfigProvider({ children, pageSize, }) {
11
+ const value = React__default.useMemo(() => ({ pageSize: validatePageSize(pageSize) }), [pageSize]);
12
+ return (React__default.createElement(PaginationConfigContext.Provider, { value: value }, children));
13
+ }
14
+
15
+ export { PaginationConfigContext, PaginationConfigProvider, usePaginationConfig };
@@ -11,6 +11,7 @@ import '@aws-amplify/ui-react-core/elements';
11
11
  import '../credentials/context.mjs';
12
12
  import '@aws-amplify/storage/internals';
13
13
  import '../configuration/context.mjs';
14
+ import '../configuration/paginationContext.mjs';
14
15
  import '../actions/configs/defaults.mjs';
15
16
  import '../displayText/context.mjs';
16
17
  import '../filePreview/context.mjs';
@@ -9,6 +9,7 @@ import '@aws-amplify/ui-react-core/elements';
9
9
  import '../credentials/context.mjs';
10
10
  import '@aws-amplify/storage/internals';
11
11
  import '../configuration/context.mjs';
12
+ import '../configuration/paginationContext.mjs';
12
13
  import '@aws-amplify/ui-react-core';
13
14
  import '../actions/configs/defaults.mjs';
14
15
  import '../views/LocationActionView/CreateFolderView/CreateFolderView.mjs';
@@ -16,6 +16,7 @@ import { ComponentsProvider } from '../components/ComponentsProvider.mjs';
16
16
  import { componentsDefault } from '../components/defaults.mjs';
17
17
  import { createConfigurationProvider } from '../configuration/createConfigurationProvider.mjs';
18
18
  import '../configuration/context.mjs';
19
+ import { PaginationConfigProvider } from '../configuration/paginationContext.mjs';
19
20
  import { DisplayTextProvider } from '../displayText/context.mjs';
20
21
  import { FileItemsProvider } from '../fileItems/context.mjs';
21
22
  import { defaultValidateFile } from '../fileItems/utils.mjs';
@@ -69,17 +70,18 @@ function createProvider({ actions, components, config, options, filePreview = {}
69
70
  * Provides state, configuration and action values that are shared between
70
71
  * the primary View components
71
72
  */
72
- function Provider({ children, displayText, views, ...props }) {
73
+ function Provider({ children, displayText, views, pageSize, ...props }) {
73
74
  return (React__default.createElement(StoreProvider, { ...props },
74
75
  React__default.createElement(ConfigurationProvider, null,
75
- React__default.createElement(ActionConfigsProvider, { actionConfigs: actionConfigs },
76
- React__default.createElement(ActionHandlersProvider, { handlers: handlers },
77
- React__default.createElement(DisplayTextProvider, { displayText: displayText },
78
- React__default.createElement(ViewsProvider, { actions: resolvedActions, views: views },
79
- React__default.createElement(ComponentsProvider, { composables: composables },
80
- React__default.createElement(LocationItemsProvider, null,
81
- React__default.createElement(FileItemsProvider, { validateFile: validateFile },
82
- React__default.createElement(FilePreviewProvider, { filePreview: filePreview }, children)))))))))));
76
+ React__default.createElement(PaginationConfigProvider, { pageSize: pageSize },
77
+ React__default.createElement(ActionConfigsProvider, { actionConfigs: actionConfigs },
78
+ React__default.createElement(ActionHandlersProvider, { handlers: handlers },
79
+ React__default.createElement(DisplayTextProvider, { displayText: displayText },
80
+ React__default.createElement(ViewsProvider, { actions: resolvedActions, views: views },
81
+ React__default.createElement(ComponentsProvider, { composables: composables },
82
+ React__default.createElement(LocationItemsProvider, null,
83
+ React__default.createElement(FileItemsProvider, { validateFile: validateFile },
84
+ React__default.createElement(FilePreviewProvider, { filePreview: filePreview }, children))))))))))));
83
85
  }
84
86
  return Provider;
85
87
  }
@@ -9,6 +9,7 @@ import '@aws-amplify/ui-react-core/elements';
9
9
  import '../credentials/context.mjs';
10
10
  import '@aws-amplify/storage/internals';
11
11
  import '../configuration/context.mjs';
12
+ import '../configuration/paginationContext.mjs';
12
13
  import '../actions/configs/defaults.mjs';
13
14
  import { assertRegisterAuthListener } from '../validators/assertRegisterAuthListener.mjs';
14
15
  import '../views/context/actionViews.mjs';
@@ -3,6 +3,7 @@ import '@aws-amplify/ui-react-core/elements';
3
3
  import '../credentials/context.mjs';
4
4
  import '@aws-amplify/storage/internals';
5
5
  import { useGetActionInput } from '../configuration/context.mjs';
6
+ import '../configuration/paginationContext.mjs';
6
7
  import { DEFAULT_ACTION_CONCURRENCY } from './constants.mjs';
7
8
  import { useProcessTasks } from '../tasks/useProcessTasks.mjs';
8
9
 
@@ -7,6 +7,7 @@ import '@aws-amplify/ui-react-core/elements';
7
7
  import '../credentials/context.mjs';
8
8
  import '@aws-amplify/storage/internals';
9
9
  import { useGetActionInput } from '../configuration/context.mjs';
10
+ import '../configuration/paginationContext.mjs';
10
11
 
11
12
  const useListFolderItems = () => {
12
13
  const { handlers } = useActionHandlers({
@@ -4,6 +4,7 @@ import '@aws-amplify/ui-react-core/elements';
4
4
  import '../credentials/context.mjs';
5
5
  import '@aws-amplify/storage/internals';
6
6
  import { useGetActionInput } from '../configuration/context.mjs';
7
+ import '../configuration/paginationContext.mjs';
7
8
  import { USE_LIST_ERROR_MESSAGE } from './constants.mjs';
8
9
  import { useActionHandlers } from './context.mjs';
9
10
  import { createEnhancedListHandler } from './createEnhancedListHandler.mjs';
@@ -0,0 +1,12 @@
1
+ const DEFAULT_PAGE_SIZE = 100;
2
+ const validatePageSize = (pageSize) => {
3
+ if (pageSize === undefined ||
4
+ pageSize === null ||
5
+ !Number.isInteger(pageSize) ||
6
+ pageSize < 1) {
7
+ return DEFAULT_PAGE_SIZE;
8
+ }
9
+ return pageSize;
10
+ };
11
+
12
+ export { validatePageSize };
@@ -11,6 +11,7 @@ import '@aws-amplify/ui-react-core/elements';
11
11
  import '../../../credentials/context.mjs';
12
12
  import '@aws-amplify/storage/internals';
13
13
  import '../../../configuration/context.mjs';
14
+ import '../../../configuration/paginationContext.mjs';
14
15
  import '../../../actions/configs/defaults.mjs';
15
16
  import '../../../displayText/context.mjs';
16
17
  import '../../../filePreview/context.mjs';
@@ -11,6 +11,7 @@ import '@aws-amplify/ui-react-core/elements';
11
11
  import '../../../credentials/context.mjs';
12
12
  import '@aws-amplify/storage/internals';
13
13
  import '../../../configuration/context.mjs';
14
+ import '../../../configuration/paginationContext.mjs';
14
15
  import '../../../actions/configs/defaults.mjs';
15
16
  import { useDisplayText } from '../../../displayText/context.mjs';
16
17
  import '../../../filePreview/context.mjs';
@@ -13,6 +13,7 @@ import '@aws-amplify/ui-react-core/elements';
13
13
  import '../../../credentials/context.mjs';
14
14
  import '@aws-amplify/storage/internals';
15
15
  import '../../../configuration/context.mjs';
16
+ import '../../../configuration/paginationContext.mjs';
16
17
  import '../../../actions/configs/defaults.mjs';
17
18
  import { useDisplayText } from '../../../displayText/context.mjs';
18
19
  import '../../../filePreview/context.mjs';
@@ -9,6 +9,7 @@ import '@aws-amplify/ui-react-core/elements';
9
9
  import '../../../credentials/context.mjs';
10
10
  import '@aws-amplify/storage/internals';
11
11
  import '../../../configuration/context.mjs';
12
+ import '../../../configuration/paginationContext.mjs';
12
13
  import '../../../actions/configs/defaults.mjs';
13
14
  import { useFolders } from './useFolders.mjs';
14
15
 
@@ -4,6 +4,7 @@ import '@aws-amplify/ui-react-core/elements';
4
4
  import '../../../credentials/context.mjs';
5
5
  import '@aws-amplify/storage/internals';
6
6
  import '../../../configuration/context.mjs';
7
+ import '../../../configuration/paginationContext.mjs';
7
8
  import '@aws-amplify/ui';
8
9
  import { useList } from '../../../useAction/useList.mjs';
9
10
  import '../../../actions/configs/defaults.mjs';
@@ -11,6 +11,7 @@ import '@aws-amplify/ui-react-core/elements';
11
11
  import '../../../credentials/context.mjs';
12
12
  import '@aws-amplify/storage/internals';
13
13
  import '../../../configuration/context.mjs';
14
+ import '../../../configuration/paginationContext.mjs';
14
15
  import '../../../actions/configs/defaults.mjs';
15
16
  import '../../../displayText/context.mjs';
16
17
  import '../../../filePreview/context.mjs';
@@ -7,6 +7,7 @@ import '@aws-amplify/ui-react-core/elements';
7
7
  import '../../../credentials/context.mjs';
8
8
  import '@aws-amplify/storage/internals';
9
9
  import '../../../configuration/context.mjs';
10
+ import '../../../configuration/paginationContext.mjs';
10
11
  import '../../../actions/configs/defaults.mjs';
11
12
  import { useStore } from '../../../store/context.mjs';
12
13
 
@@ -19,6 +19,7 @@ import '@aws-amplify/ui-react-core/elements';
19
19
  import '../../../credentials/context.mjs';
20
20
  import '@aws-amplify/storage/internals';
21
21
  import '../../../configuration/context.mjs';
22
+ import '../../../configuration/paginationContext.mjs';
22
23
  import '../../../actions/configs/defaults.mjs';
23
24
  import '../../../displayText/context.mjs';
24
25
  import '../../../filePreview/context.mjs';
@@ -10,6 +10,7 @@ import '@aws-amplify/ui-react-core/elements';
10
10
  import '../../../credentials/context.mjs';
11
11
  import '@aws-amplify/storage/internals';
12
12
  import { useGetActionInput } from '../../../configuration/context.mjs';
13
+ import '../../../configuration/paginationContext.mjs';
13
14
  import '../../../actions/configs/defaults.mjs';
14
15
  import { useDisplayText } from '../../../displayText/context.mjs';
15
16
  import { createDeleteConfirmationModalProps, countFilesInFolder } from './utils.mjs';
@@ -18,6 +18,7 @@ import '@aws-amplify/ui-react-core/elements';
18
18
  import '../../../credentials/context.mjs';
19
19
  import '@aws-amplify/storage/internals';
20
20
  import '../../../configuration/context.mjs';
21
+ import '../../../configuration/paginationContext.mjs';
21
22
  import '../../../actions/configs/defaults.mjs';
22
23
  import '../../../displayText/context.mjs';
23
24
  import '../../../filePreview/context.mjs';
@@ -9,6 +9,7 @@ import '@aws-amplify/ui-react-core/elements';
9
9
  import '../../../credentials/context.mjs';
10
10
  import '@aws-amplify/storage/internals';
11
11
  import '../../../configuration/context.mjs';
12
+ import '../../../configuration/paginationContext.mjs';
12
13
  import '../../../actions/configs/defaults.mjs';
13
14
 
14
15
  // assign to constant to ensure referential equality
@@ -11,6 +11,7 @@ import '@aws-amplify/ui-react-core/elements';
11
11
  import '../../../credentials/context.mjs';
12
12
  import '@aws-amplify/storage/internals';
13
13
  import '../../../configuration/context.mjs';
14
+ import '../../../configuration/paginationContext.mjs';
14
15
  import '../../../actions/configs/defaults.mjs';
15
16
  import '../../../displayText/context.mjs';
16
17
  import '../../../filePreview/context.mjs';
@@ -33,7 +34,7 @@ import { useUploadView } from './useUploadView.mjs';
33
34
 
34
35
  const UploadView = ({ className, ...props }) => {
35
36
  const state = useUploadView(props);
36
- return (React__default.createElement(ViewElement, { className: classNames(STORAGE_BROWSER_BLOCK, className) },
37
+ return (React__default.createElement(ViewElement, { className: classNames(STORAGE_BROWSER_BLOCK, className), "data-testid": "UPLOAD_VIEW" },
37
38
  React__default.createElement(UploadViewProvider, { ...state },
38
39
  React__default.createElement(ActionExitControl, null),
39
40
  React__default.createElement(TitleControl, null),
@@ -1,21 +1,23 @@
1
1
  import React__default from 'react';
2
+ import '@aws-amplify/ui-react-core/elements';
3
+ import '../../../credentials/context.mjs';
4
+ import '@aws-amplify/storage/internals';
5
+ import '../../../configuration/context.mjs';
6
+ import { usePaginationConfig } from '../../../configuration/paginationContext.mjs';
2
7
  import { useFileItems } from '../../../fileItems/context.mjs';
3
8
  import '@aws-amplify/ui';
4
9
  import { useStore } from '../../../store/context.mjs';
5
10
  import '../../../useAction/context.mjs';
6
11
  import { useAction } from '../../../useAction/useAction.mjs';
7
12
  import '@aws-amplify/ui-react-core';
8
- import '@aws-amplify/ui-react-core/elements';
9
- import '../../../credentials/context.mjs';
10
- import '@aws-amplify/storage/internals';
11
- import '../../../configuration/context.mjs';
12
13
  import '../../../actions/configs/defaults.mjs';
13
14
  import { DEFAULT_OVERWRITE_ENABLED } from './constants.mjs';
14
15
  import { usePaginate } from '../../hooks/usePaginate.mjs';
15
16
 
16
- const DEFAULT_PAGE_SIZE = 100;
17
17
  const useUploadView = (options) => {
18
- const { onExit: _onExit } = options ?? {};
18
+ const { pageSize: configPageSize } = usePaginationConfig();
19
+ const { onExit: _onExit, pageSize: propPageSize } = options ?? {};
20
+ const pageSize = propPageSize ?? configPageSize;
19
21
  const [{ location }, storeDispatch] = useStore();
20
22
  const [{ validItems, invalidItems: invalidFiles }, fileItemsDispatch] = useFileItems();
21
23
  const { current } = location;
@@ -28,6 +30,7 @@ const useUploadView = (options) => {
28
30
  const [{ isProcessing, isProcessingComplete, statusCounts, tasks }, handleUploads,] = useAction('upload', { items });
29
31
  const { currentPage, handlePaginate, pageItems: pageTasks, } = usePaginate({
30
32
  items: tasks,
33
+ pageSize,
31
34
  });
32
35
  const onDropFiles = (files) => {
33
36
  if (files) {
@@ -65,8 +68,8 @@ const useUploadView = (options) => {
65
68
  statusCounts,
66
69
  tasks: pageTasks,
67
70
  page: currentPage,
68
- hasNextPage: currentPage * DEFAULT_PAGE_SIZE < items.length,
69
- highestPageVisited: Math.ceil(items.length / DEFAULT_PAGE_SIZE),
71
+ hasNextPage: currentPage * pageSize < items.length,
72
+ highestPageVisited: Math.ceil(items.length / pageSize),
70
73
  onActionCancel,
71
74
  onActionExit,
72
75
  onActionStart,
@@ -11,6 +11,7 @@ import '@aws-amplify/ui-react-core/elements';
11
11
  import '../../credentials/context.mjs';
12
12
  import '@aws-amplify/storage/internals';
13
13
  import '../../configuration/context.mjs';
14
+ import '../../configuration/paginationContext.mjs';
14
15
  import '../../actions/configs/defaults.mjs';
15
16
  import '../../displayText/context.mjs';
16
17
  import '../../filePreview/context.mjs';
@@ -7,6 +7,10 @@ import 'jszip';
7
7
  import 'aws-amplify/storage';
8
8
  import { useActionConfigs } from '../../actions/configs/context.mjs';
9
9
  import '../../actions/configs/defaults.mjs';
10
+ import '@aws-amplify/ui-react-core/elements';
11
+ import '../../credentials/context.mjs';
12
+ import '../../configuration/context.mjs';
13
+ import { usePaginationConfig } from '../../configuration/paginationContext.mjs';
10
14
  import { useFileItems } from '../../fileItems/context.mjs';
11
15
  import { useLocationItems } from '../../locationItems/context.mjs';
12
16
  import { useStore } from '../../store/context.mjs';
@@ -16,23 +20,22 @@ import { useList } from '../../useAction/useList.mjs';
16
20
  import { useSearch } from '../hooks/useSearch.mjs';
17
21
  import { useFilePreview } from '../hooks/useFilePreview/useFilePreview.mjs';
18
22
 
19
- const DEFAULT_PAGE_SIZE = 100;
20
- const DEFAULT_LIST_OPTIONS = {
21
- delimiter: '/',
22
- pageSize: DEFAULT_PAGE_SIZE,
23
- };
24
23
  const getDownloadErrorMessageFromFailedDownloadTask = (task) => {
25
24
  if (!task)
26
25
  return;
27
26
  return `Failed to download ${task.data.fileKey ?? task.data.key} due to error: ${task.message}.`;
28
27
  };
29
28
  const useLocationDetailView = (options) => {
30
- const { initialValues, onExit, onNavigate } = options ?? {};
31
- const listOptionsRef = React__default.useRef({
32
- ...DEFAULT_LIST_OPTIONS,
29
+ const { pageSize: configPageSize } = usePaginationConfig();
30
+ const { initialValues = {}, onExit, onNavigate, pageSize: propPageSize, } = options ?? {};
31
+ const pageSize = propPageSize ?? configPageSize;
32
+ const listOptions = React__default.useMemo(() => ({
33
33
  ...initialValues,
34
- });
35
- const listOptions = listOptionsRef.current;
34
+ delimiter: '/',
35
+ pageSize,
36
+ }),
37
+ // eslint-disable-next-line react-hooks/exhaustive-deps
38
+ [pageSize, initialValues.delimiter, initialValues.pageSize]);
36
39
  const [{ location, actionType }, storeDispatch] = useStore();
37
40
  const [locationItems, locationItemsDispatch] = useLocationItems();
38
41
  const fileItemsDispatch = useFileItems()[1];
@@ -267,4 +270,4 @@ const useLocationDetailView = (options) => {
267
270
  };
268
271
  };
269
272
 
270
- export { DEFAULT_LIST_OPTIONS, useLocationDetailView };
273
+ export { useLocationDetailView };
@@ -11,6 +11,7 @@ import '@aws-amplify/ui-react-core/elements';
11
11
  import '../../credentials/context.mjs';
12
12
  import '@aws-amplify/storage/internals';
13
13
  import '../../configuration/context.mjs';
14
+ import '../../configuration/paginationContext.mjs';
14
15
  import '../../actions/configs/defaults.mjs';
15
16
  import '../../displayText/context.mjs';
16
17
  import '../../filePreview/context.mjs';
@@ -11,6 +11,7 @@ import '@aws-amplify/ui-react-core/elements';
11
11
  import '../../credentials/context.mjs';
12
12
  import '@aws-amplify/storage/internals';
13
13
  import '../../configuration/context.mjs';
14
+ import '../../configuration/paginationContext.mjs';
14
15
  import '../../actions/configs/defaults.mjs';
15
16
  import { useDisplayText } from '../../displayText/context.mjs';
16
17
  import '../../filePreview/context.mjs';
@@ -6,6 +6,10 @@ import 'jszip';
6
6
  import 'aws-amplify/storage';
7
7
  import '../../actions/configs/context.mjs';
8
8
  import '../../actions/configs/defaults.mjs';
9
+ import '@aws-amplify/ui-react-core/elements';
10
+ import '../../credentials/context.mjs';
11
+ import '../../configuration/context.mjs';
12
+ import { usePaginationConfig } from '../../configuration/paginationContext.mjs';
9
13
  import { useStore } from '../../store/context.mjs';
10
14
  import '../../useAction/context.mjs';
11
15
  import { useAction } from '../../useAction/useAction.mjs';
@@ -16,12 +20,8 @@ import { useSearch } from '../hooks/useSearch.mjs';
16
20
  const DEFAULT_EXCLUDE = {
17
21
  exactPermissions: ['delete', 'write'],
18
22
  };
19
- const DEFAULT_PAGE_SIZE = 100;
20
- const DEFAULT_LIST_OPTIONS = {
21
- exclude: DEFAULT_EXCLUDE,
22
- pageSize: DEFAULT_PAGE_SIZE,
23
- };
24
23
  const useLocationsView = (options) => {
24
+ const { pageSize: configPageSize } = usePaginationConfig();
25
25
  const handleDownload = useAction('download')[1];
26
26
  const [state, handleList] = useList('locations');
27
27
  const dispatchStoreAction = useStore()[1];
@@ -29,12 +29,15 @@ const useLocationsView = (options) => {
29
29
  const { items, nextToken, hasExhaustedSearch = false } = value;
30
30
  const hasNextToken = !!nextToken;
31
31
  const onNavigate = options?.onNavigate;
32
+ const pageSize = options?.pageSize ?? configPageSize;
32
33
  const initialValues = options?.initialValues ?? {};
33
- const listOptionsRef = React__default.useRef({
34
- ...DEFAULT_LIST_OPTIONS,
34
+ const listOptions = React__default.useMemo(() => ({
35
35
  ...initialValues,
36
- });
37
- const listOptions = listOptionsRef.current;
36
+ exclude: DEFAULT_EXCLUDE,
37
+ pageSize,
38
+ }),
39
+ // eslint-disable-next-line react-hooks/exhaustive-deps
40
+ [pageSize, initialValues.pageSize]);
38
41
  // initial load
39
42
  React__default.useEffect(() => {
40
43
  handleList({ options: { ...listOptions, refresh: true } });
@@ -108,4 +111,4 @@ const useLocationsView = (options) => {
108
111
  };
109
112
  };
110
113
 
111
- export { DEFAULT_LIST_OPTIONS, useLocationsView };
114
+ export { useLocationsView };
@@ -1,13 +1,14 @@
1
1
  import React__default from 'react';
2
2
  import { UploadView } from '../LocationActionView/UploadView/UploadView.mjs';
3
- import '../../fileItems/context.mjs';
4
- import '@aws-amplify/ui';
5
- import '../../store/context.mjs';
6
- import '../../useAction/context.mjs';
7
3
  import '@aws-amplify/ui-react-core/elements';
8
4
  import '../../credentials/context.mjs';
9
5
  import '@aws-amplify/storage/internals';
10
6
  import '../../configuration/context.mjs';
7
+ import '../../configuration/paginationContext.mjs';
8
+ import '../../fileItems/context.mjs';
9
+ import '@aws-amplify/ui';
10
+ import '../../store/context.mjs';
11
+ import '../../useAction/context.mjs';
11
12
  import '@aws-amplify/ui-react-core';
12
13
  import '../../actions/configs/defaults.mjs';
13
14
  import { CreateFolderView } from '../LocationActionView/CreateFolderView/CreateFolderView.mjs';
@@ -8,6 +8,7 @@ import '@aws-amplify/ui-react-core/elements';
8
8
  import '../../credentials/context.mjs';
9
9
  import '@aws-amplify/storage/internals';
10
10
  import '../../configuration/context.mjs';
11
+ import '../../configuration/paginationContext.mjs';
11
12
  import '@aws-amplify/ui-react-core';
12
13
  import '../../actions/configs/defaults.mjs';
13
14
  import '../LocationActionView/CreateFolderView/CreateFolderView.mjs';
@@ -1,8 +1,7 @@
1
1
  import React__default from 'react';
2
2
  import { isFunction } from '@aws-amplify/ui';
3
3
 
4
- const DEFAULT_PAGE_SIZE = 100;
5
- const usePaginate = ({ items, onPaginate, page = 1, pageSize = DEFAULT_PAGE_SIZE, }) => {
4
+ const usePaginate = ({ items, onPaginate, page = 1, pageSize, }) => {
6
5
  const [currentPage, setCurrentPage] = React__default.useState(page);
7
6
  const visitedRef = React__default.useRef(page);
8
7
  const handleReset = React__default.useRef(() => {
@@ -12,19 +11,31 @@ const usePaginate = ({ items, onPaginate, page = 1, pageSize = DEFAULT_PAGE_SIZE
12
11
  }).current;
13
12
  return React__default.useMemo(() => {
14
13
  const hasItems = Array.isArray(items);
14
+ const totalItems = hasItems ? items.length : 0;
15
+ const totalPages = Math.max(1, Math.ceil(totalItems / pageSize));
16
+ // Auto-adjust current page if it's beyond available pages
17
+ // For server-side pagination, don't auto-adjust if onPaginate callback is provided
18
+ let adjustedCurrentPage = currentPage;
19
+ if (currentPage > totalPages && !isFunction(onPaginate)) {
20
+ adjustedCurrentPage = totalPages;
21
+ setCurrentPage(adjustedCurrentPage);
22
+ }
15
23
  const highestPageVisited = visitedRef.current;
16
- const isFirstPage = currentPage === 1;
17
- const start = isFirstPage ? 0 : (currentPage - 1) * pageSize;
18
- const end = isFirstPage ? pageSize : currentPage * pageSize;
24
+ const isFirstPage = adjustedCurrentPage === 1;
25
+ const start = isFirstPage ? 0 : (adjustedCurrentPage - 1) * pageSize;
26
+ const end = isFirstPage ? pageSize : adjustedCurrentPage * pageSize;
19
27
  const pageItems = hasItems ? items.slice(start, end) : [];
20
28
  return {
21
- currentPage,
29
+ currentPage: adjustedCurrentPage,
22
30
  handlePaginate: (page) => {
23
31
  if (page < 1)
24
32
  return;
33
+ // For server-side pagination, allow going beyond totalPages if onPaginate is provided
34
+ if (page > totalPages && !isFunction(onPaginate))
35
+ return;
25
36
  if (isFunction(onPaginate))
26
37
  onPaginate(page);
27
- if (page > currentPage && page > highestPageVisited)
38
+ if (page > adjustedCurrentPage && page > highestPageVisited)
28
39
  visitedRef.current = page;
29
40
  setCurrentPage(page);
30
41
  },
@@ -1,3 +1,3 @@
1
- const VERSION = '3.16.0';
1
+ const VERSION = '3.17.0';
2
2
 
3
3
  export { VERSION };
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@ var uiReactCore = require('@aws-amplify/ui-react-core');
9
9
  var auth = require('aws-amplify/auth');
10
10
  var storage = require('aws-amplify/storage');
11
11
  var internal = require('@aws-amplify/ui-react/internal');
12
- var createStorageBrowser = require('./createStorageBrowser-B-J76Lyp.js');
12
+ var createStorageBrowser = require('./createStorageBrowser-De4hcP-u.js');
13
13
  require('@aws-amplify/storage/internals');
14
14
  require('aws-amplify');
15
15
  require('jszip');
@@ -1,5 +1,7 @@
1
1
  import React from 'react';
2
- import type { StorageBrowserProps as StorageBrowserPropsBase } from './createStorageBrowser';
2
+ import type { StorageBrowserProps as StorageBrowserPropsBase, StorageBrowserProviderProps as StorageBrowserProviderPropsBase } from './createStorageBrowser';
3
3
  export interface StorageBrowserProps extends StorageBrowserPropsBase {
4
4
  }
5
+ export interface StorageBrowserProviderProps extends StorageBrowserProviderPropsBase {
6
+ }
5
7
  export declare function StorageBrowser(props: StorageBrowserProps): React.JSX.Element;
@@ -1,3 +1,5 @@
1
1
  export { createConfigurationProvider } from './createConfigurationProvider';
2
2
  export { useGetActionInput } from './context';
3
3
  export type { GetActionInput } from './types';
4
+ export { usePaginationConfig, PaginationConfigProvider, } from './paginationContext';
5
+ export type { PaginationConfig } from './paginationContext';
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ export interface PaginationConfig {
3
+ pageSize: number;
4
+ }
5
+ export declare const usePaginationConfig: (params?: {
6
+ errorMessage?: string | undefined;
7
+ } | undefined) => PaginationConfig, PaginationConfigContext: React.Context<PaginationConfig>;
8
+ export interface PaginationConfigProviderProps {
9
+ children?: React.ReactNode;
10
+ pageSize?: number;
11
+ }
12
+ export declare function PaginationConfigProvider({ children, pageSize, }: PaginationConfigProviderProps): React.JSX.Element;
@@ -245,12 +245,18 @@ export interface StorageBrowserProps<TActionType = string, TViews = {}> {
245
245
  * @description accepts default top level `views` overrides and custom `views` defined by the `actions` parameter of `createStorageBrowser`
246
246
  */
247
247
  views?: StorageBrowserViews<TActionType, TViews>;
248
+ /**
249
+ * @description Number of items to display per page in listings
250
+ * @default 100
251
+ * @minimum 1
252
+ */
253
+ pageSize?: number;
248
254
  }
249
255
  /**
250
256
  * @description `StorageBrowser.Provider` component properties
251
257
  * @template TViews Optional type of custom action view components.
252
258
  */
253
- export interface StorageBrowserProviderProps<TViews = {}> extends StoreProviderProps, Pick<StorageBrowserProps, 'defaultValue' | 'displayText' | 'onValueChange' | 'value'> {
259
+ export interface StorageBrowserProviderProps<TViews = {}> extends StoreProviderProps, Pick<StorageBrowserProps, 'defaultValue' | 'displayText' | 'onValueChange' | 'value' | 'pageSize'> {
254
260
  /**
255
261
  * @description accepts custom action views rendered by `LocationActionView`
256
262
  */
@@ -54,6 +54,13 @@ export interface StoreProviderProps {
54
54
  * @deprecated
55
55
  */
56
56
  path?: string;
57
+ /**
58
+ * @description Number of items to display per page in listings
59
+ * @default 100
60
+ * @minimum 1
61
+ * @maximum 1000
62
+ */
63
+ pageSize?: number;
57
64
  }
58
65
  export type StoreActionType = {
59
66
  type: 'CHANGE_ACTION_TYPE';
@@ -0,0 +1 @@
1
+ export { validatePageSize } from './validatePageSize';
@@ -0,0 +1 @@
1
+ export declare const validatePageSize: (pageSize: number | undefined) => number;
@@ -13,6 +13,12 @@ export interface UploadViewState extends ActionViewState<UploadHandlerData> {
13
13
  invalidFiles: FileItems | undefined;
14
14
  }
15
15
  export interface UploadViewProps extends ActionViewProps, Partial<UploadViewState> {
16
+ /**
17
+ * @description Number of items to display per page in task listings
18
+ * @default 100
19
+ * @minimum 1
20
+ */
21
+ pageSize?: number;
16
22
  }
17
23
  export interface UploadViewProviderProps extends UploadViewState {
18
24
  children?: React.ReactNode;
@@ -37,4 +43,5 @@ export interface UploadViewType extends ActionViewType<UploadHandlerData, Upload
37
43
  }
38
44
  export interface UseUploadViewOptions {
39
45
  onExit?: (location?: LocationData) => void;
46
+ pageSize?: number;
40
47
  }
@@ -79,7 +79,7 @@ export interface LocationDetailViewType {
79
79
  Title: () => React.JSX.Element | null;
80
80
  FilePreview: (props: FilePreviewProps) => React.JSX.Element | null;
81
81
  }
82
- interface InitialValues {
82
+ export interface InitialValues {
83
83
  pageSize?: number;
84
84
  delimiter?: string;
85
85
  }
@@ -88,5 +88,5 @@ export interface UseLocationDetailViewOptions {
88
88
  onActionSelect?: (actionType: string) => void;
89
89
  onExit?: () => void;
90
90
  onNavigate?: (location: LocationData, path?: string) => void;
91
+ pageSize?: number;
91
92
  }
92
- export {};
@@ -35,11 +35,11 @@ export interface LocationsViewType {
35
35
  Search: () => React.JSX.Element | null;
36
36
  Title: () => React.JSX.Element | null;
37
37
  }
38
- interface InitialValues {
38
+ export interface InitialValues {
39
39
  pageSize?: number;
40
40
  }
41
41
  export interface UseLocationsViewOptions {
42
42
  initialValues?: InitialValues;
43
43
  onNavigate?: (location: LocationData) => void;
44
+ pageSize?: number;
44
45
  }
45
- export {};
@@ -9,7 +9,7 @@ interface UsePaginateInput<T> {
9
9
  items?: T[];
10
10
  onPaginate?: (page?: number) => void;
11
11
  page?: number;
12
- pageSize?: number;
12
+ pageSize: number;
13
13
  }
14
14
  export declare const usePaginate: <T>({ items, onPaginate, page, pageSize, }: UsePaginateInput<T>) => UsePaginateState<T>;
15
15
  export {};
@@ -13,6 +13,12 @@ export interface ListViewState<T = any> {
13
13
  pageItems: T[];
14
14
  }
15
15
  export interface ListViewProps extends ActionViewProps, Partial<ListViewState> {
16
+ /**
17
+ * @description Number of items to display per page in listings
18
+ * @default 100
19
+ * @minimum 1
20
+ */
21
+ pageSize?: number;
16
22
  }
17
23
  export type StorageBrowserViews<T = string, K = {}> = Partial<PrimaryViews<T> & DefaultActionViews & K>;
18
24
  export interface PrimaryViews<T = string> {
@@ -1,4 +1,4 @@
1
1
  export type { FileUploaderHandle, FileUploaderProps, StorageImageProps, StorageManagerHandle, StorageManagerProps, DropZoneProps, ContainerProps, FileListProps, FilePickerProps, FileListHeaderProps, FileListFooterProps, } from './components';
2
2
  export { FileUploader, StorageImage, StorageManager } from './components';
3
- export type { StorageBrowserProps } from './components/StorageBrowser/StorageBrowserAmplify';
3
+ export type { StorageBrowserProps, StorageBrowserProviderProps, } from './components/StorageBrowser/StorageBrowserAmplify';
4
4
  export { StorageBrowser } from './components/StorageBrowser/StorageBrowserAmplify';
@@ -1 +1 @@
1
- export declare const VERSION = "3.16.0";
1
+ export declare const VERSION = "3.17.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-amplify/ui-react-storage",
3
- "version": "3.16.0",
3
+ "version": "3.17.0",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/esm/index.mjs",
6
6
  "exports": {
@@ -46,9 +46,9 @@
46
46
  "typecheck": "tsc --noEmit"
47
47
  },
48
48
  "dependencies": {
49
- "@aws-amplify/ui": "6.15.0",
50
- "@aws-amplify/ui-react": "6.15.0",
51
- "@aws-amplify/ui-react-core": "3.6.0",
49
+ "@aws-amplify/ui": "6.15.1",
50
+ "@aws-amplify/ui-react": "6.15.1",
51
+ "@aws-amplify/ui-react-core": "3.6.1",
52
52
  "tslib": "^2.5.2",
53
53
  "jszip": "^3.10.1"
54
54
  },
@@ -78,7 +78,7 @@
78
78
  "name": "StorageBrowser",
79
79
  "path": "dist/esm/index.mjs",
80
80
  "import": "{ StorageBrowser }",
81
- "limit": "121 kB"
81
+ "limit": "121.1 kB"
82
82
  },
83
83
  {
84
84
  "name": "FileUploader",