@aws-amplify/ui-react-storage 3.9.0 → 3.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.js +3 -1
- package/dist/{createAmplifyAuthAdapter-BcuxpEzi.js → createAmplifyAuthAdapter-BJjOYxQA.js} +541 -394
- package/dist/esm/browser.mjs +6 -0
- package/dist/esm/components/StorageBrowser/StorageBrowserAmplify.mjs +1 -0
- package/dist/esm/components/StorageBrowser/StorageBrowserDefault.mjs +3 -2
- package/dist/esm/components/StorageBrowser/actions/configs/defaults.mjs +10 -12
- package/dist/esm/components/StorageBrowser/actions/handlers/constants.mjs +4 -1
- package/dist/esm/components/StorageBrowser/actions/handlers/copy.mjs +4 -1
- package/dist/esm/components/StorageBrowser/actions/handlers/createFolder.mjs +4 -3
- package/dist/esm/components/StorageBrowser/actions/handlers/defaults.mjs +17 -0
- package/dist/esm/components/StorageBrowser/actions/handlers/delete.mjs +4 -1
- package/dist/esm/components/StorageBrowser/actions/handlers/download.mjs +4 -1
- package/dist/esm/components/StorageBrowser/actions/handlers/upload.mjs +6 -11
- package/dist/esm/components/StorageBrowser/actions/handlers/utils.mjs +4 -3
- package/dist/esm/components/StorageBrowser/adapters/createManagedAuthAdapter/createManagedAuthAdapter.mjs +2 -1
- package/dist/esm/components/StorageBrowser/componentsDefault.mjs +4 -4
- package/dist/esm/components/StorageBrowser/createStorageBrowser.mjs +7 -1
- package/dist/esm/components/StorageBrowser/displayText/libraries/en/shared.mjs +0 -1
- package/dist/esm/components/StorageBrowser/displayText/libraries/en/uploadView.mjs +3 -2
- package/dist/esm/components/StorageBrowser/displayText/utils.mjs +7 -0
- package/dist/esm/components/StorageBrowser/providers/store/locationItems/context.mjs +1 -0
- package/dist/esm/components/StorageBrowser/tasks/useProcessTasks.mjs +20 -22
- package/dist/esm/components/StorageBrowser/useAction/useAction.mjs +14 -7
- package/dist/esm/components/StorageBrowser/useAction/useHandler.mjs +26 -32
- package/dist/esm/components/StorageBrowser/useAction/useList.mjs +0 -1
- package/dist/esm/components/StorageBrowser/views/LocationActionView/CopyView/CopyViewProvider.mjs +8 -10
- package/dist/esm/components/StorageBrowser/views/LocationActionView/CopyView/useCopyView.mjs +1 -0
- package/dist/esm/components/StorageBrowser/views/LocationActionView/CopyView/useFolders.mjs +11 -13
- package/dist/esm/components/StorageBrowser/views/LocationActionView/CreateFolderView/useCreateFolderView.mjs +1 -0
- package/dist/esm/components/StorageBrowser/views/LocationActionView/DeleteView/DeleteViewProvider.mjs +6 -8
- package/dist/esm/components/StorageBrowser/views/LocationActionView/DeleteView/useDeleteView.mjs +6 -9
- package/dist/esm/components/StorageBrowser/views/LocationActionView/UploadView/UploadViewProvider.mjs +14 -10
- package/dist/esm/components/StorageBrowser/views/LocationActionView/UploadView/useUploadView.mjs +2 -1
- package/dist/esm/components/StorageBrowser/views/LocationDetailView/getLocationDetailViewTableData/getLocationDetailViewTableData.mjs +1 -0
- package/dist/esm/components/StorageBrowser/views/LocationDetailView/useLocationDetailView.mjs +7 -11
- package/dist/esm/components/StorageBrowser/views/LocationsView/useLocationsView.mjs +5 -5
- package/dist/esm/components/StorageBrowser/views/context/actionViews.mjs +3 -2
- package/dist/esm/components/StorageBrowser/views/context/getViews.mjs +4 -1
- package/dist/esm/components/StorageBrowser/views/context/primaryViews.mjs +3 -2
- package/dist/esm/components/StorageBrowser/views/hooks/usePaginate.mjs +19 -21
- package/dist/esm/components/StorageBrowser/views/hooks/useResolveTableData/useResolveTableData.mjs +15 -0
- package/dist/esm/components/StorageBrowser/views/useView.mjs +6 -7
- package/dist/esm/components/StorageBrowser/views/utils/tableResolvers/constants.mjs +18 -0
- package/dist/esm/components/StorageBrowser/views/utils/tableResolvers/copyResolvers.mjs +82 -0
- package/dist/esm/components/StorageBrowser/views/utils/tableResolvers/deleteResolvers.mjs +82 -0
- package/dist/esm/components/StorageBrowser/views/utils/tableResolvers/uploadResolvers.mjs +112 -0
- package/dist/esm/components/StorageBrowser/views/utils/tableResolvers/utils.mjs +49 -0
- package/dist/esm/version.mjs +1 -1
- package/dist/index.js +1 -1
- package/dist/types/components/StorageBrowser/ComponentsProvider.d.ts +4 -1
- package/dist/types/components/StorageBrowser/actions/configs/types.d.ts +41 -2
- package/dist/types/components/StorageBrowser/actions/handlers/constants.d.ts +1 -0
- package/dist/types/components/StorageBrowser/actions/handlers/copy.d.ts +4 -7
- package/dist/types/components/StorageBrowser/actions/handlers/createFolder.d.ts +1 -3
- package/dist/types/components/StorageBrowser/actions/handlers/defaults.d.ts +15 -0
- package/dist/types/components/StorageBrowser/actions/handlers/delete.d.ts +2 -2
- package/dist/types/components/StorageBrowser/actions/handlers/index.d.ts +1 -0
- package/dist/types/components/StorageBrowser/actions/handlers/listLocations.d.ts +4 -12
- package/dist/types/components/StorageBrowser/actions/handlers/types.d.ts +26 -17
- package/dist/types/components/StorageBrowser/actions/handlers/upload.d.ts +1 -4
- package/dist/types/components/StorageBrowser/actions/handlers/utils.d.ts +2 -2
- package/dist/types/components/StorageBrowser/actions/index.d.ts +1 -1
- package/dist/types/components/StorageBrowser/componentsDefault.d.ts +2 -2
- package/dist/types/components/StorageBrowser/createStorageBrowser.d.ts +6 -0
- package/dist/types/components/StorageBrowser/displayText/index.d.ts +1 -0
- package/dist/types/components/StorageBrowser/displayText/types.d.ts +16 -5
- package/dist/types/components/StorageBrowser/displayText/utils.d.ts +3 -0
- package/dist/types/components/StorageBrowser/index.d.ts +4 -3
- package/dist/types/components/StorageBrowser/providers/configuration/createConfigurationProvider.d.ts +1 -1
- package/dist/types/components/StorageBrowser/providers/configuration/types.d.ts +3 -3
- package/dist/types/components/StorageBrowser/providers/index.d.ts +1 -1
- package/dist/types/components/StorageBrowser/providers/store/actionType/types.d.ts +4 -0
- package/dist/types/components/StorageBrowser/providers/store/files/types.d.ts +1 -4
- package/dist/types/components/StorageBrowser/providers/store/index.d.ts +1 -1
- package/dist/types/components/StorageBrowser/providers/store/location/context.d.ts +6 -0
- package/dist/types/components/StorageBrowser/storage-internal.d.ts +1 -1
- package/dist/types/components/StorageBrowser/tasks/index.d.ts +1 -1
- package/dist/types/components/StorageBrowser/tasks/types.d.ts +41 -23
- package/dist/types/components/StorageBrowser/tasks/useProcessTasks.d.ts +3 -3
- package/dist/types/components/StorageBrowser/types.d.ts +191 -15
- package/dist/types/components/StorageBrowser/useAction/types.d.ts +60 -32
- package/dist/types/components/StorageBrowser/useAction/useHandler.d.ts +4 -3
- package/dist/types/components/StorageBrowser/useAction/useList.d.ts +10 -7
- package/dist/types/components/StorageBrowser/views/LocationActionView/CopyView/types.d.ts +5 -0
- package/dist/types/components/StorageBrowser/views/LocationActionView/UploadView/types.d.ts +2 -2
- package/dist/types/components/StorageBrowser/views/LocationActionView/types.d.ts +4 -4
- package/dist/types/components/StorageBrowser/views/LocationDetailView/index.d.ts +1 -1
- package/dist/types/components/StorageBrowser/views/LocationsView/index.d.ts +1 -1
- package/dist/types/components/StorageBrowser/views/context/getViews.d.ts +2 -2
- package/dist/types/components/StorageBrowser/views/context/views.d.ts +2 -2
- package/dist/types/components/StorageBrowser/views/hooks/usePaginate.d.ts +8 -8
- package/dist/types/components/StorageBrowser/views/hooks/useResolveTableData/index.d.ts +2 -0
- package/dist/types/components/StorageBrowser/views/hooks/useResolveTableData/types.d.ts +26 -0
- package/dist/types/components/StorageBrowser/views/hooks/useResolveTableData/useResolveTableData.d.ts +6 -0
- package/dist/types/components/StorageBrowser/views/types.d.ts +1 -1
- package/dist/types/components/StorageBrowser/views/useView.d.ts +16 -13
- package/dist/types/components/StorageBrowser/views/utils/index.d.ts +1 -0
- package/dist/types/components/StorageBrowser/views/utils/tableResolvers/__testUtils__/tasks.d.ts +23 -0
- package/dist/types/components/StorageBrowser/views/utils/tableResolvers/constants.d.ts +16 -0
- package/dist/types/components/StorageBrowser/views/utils/tableResolvers/copyResolvers.d.ts +3 -0
- package/dist/types/components/StorageBrowser/views/utils/tableResolvers/deleteResolvers.d.ts +3 -0
- package/dist/types/components/StorageBrowser/views/utils/tableResolvers/index.d.ts +3 -0
- package/dist/types/components/StorageBrowser/views/utils/tableResolvers/types.d.ts +36 -0
- package/dist/types/components/StorageBrowser/views/utils/tableResolvers/uploadResolvers.d.ts +3 -0
- package/dist/types/components/StorageBrowser/views/utils/tableResolvers/utils.d.ts +12 -0
- package/dist/types/version.d.ts +1 -1
- package/package.json +5 -5
- package/dist/esm/components/StorageBrowser/views/LocationActionView/getActionIcon.mjs +0 -25
- package/dist/esm/components/StorageBrowser/views/LocationActionView/getActionViewTableData.mjs +0 -155
- package/dist/esm/components/StorageBrowser/views/LocationActionView/getDefaultActionViewHeaders.mjs +0 -24
- package/dist/esm/components/StorageBrowser/views/LocationActionView/getFileTypeDisplayValue.mjs +0 -5
- package/dist/esm/components/StorageBrowser/views/LocationActionView/getPercentValue.mjs +0 -3
- package/dist/types/components/StorageBrowser/displayText/en.d.ts +0 -9
- package/dist/types/components/StorageBrowser/views/LocationActionView/getActionIcon.d.ts +0 -3
- package/dist/types/components/StorageBrowser/views/LocationActionView/getActionViewTableData.d.ts +0 -14
- package/dist/types/components/StorageBrowser/views/LocationActionView/getDefaultActionViewHeaders.d.ts +0 -5
- package/dist/types/components/StorageBrowser/views/LocationActionView/getFileTypeDisplayValue.d.ts +0 -1
- package/dist/types/components/StorageBrowser/views/LocationActionView/getPercentValue.d.ts +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
export { AWSTemporaryCredentials, CopyInput, CredentialsLocation, CredentialsProvider, GetUrlInput, ListLocations, ListLocationsOutput, ListOutput, ListPaginateInput, LocationAccess, LocationCredentials, LocationCredentialsProvider, Permission, RemoveInput, StorageAccess, StorageSubpathStrategy, StorageValidationErrorCode, UploadDataInput, ListPathsOutput, assertValidationError, copy, getDataAccess, getUrl, list, listCallerAccessGrants, listPaths, remove, uploadData, validationErrorMap, } from '@aws-amplify/storage/internals';
|
|
1
|
+
export { AWSTemporaryCredentials, CopyInput, CopyOutput, CredentialsLocation, CredentialsProvider, GetUrlInput, ListLocations, ListLocationsOutput, ListOutput, ListPaginateInput, LocationAccess, LocationCredentials, LocationCredentialsProvider, Permission, RemoveInput, StorageAccess, StorageSubpathStrategy, StorageValidationErrorCode, UploadDataInput, ListPathsOutput, assertValidationError, copy, getDataAccess, getUrl, list, listCallerAccessGrants, listPaths, remove, uploadData, validationErrorMap, } from '@aws-amplify/storage/internals';
|
|
@@ -1,33 +1,51 @@
|
|
|
1
|
-
import { TaskHandlerInput, TaskData } from '../actions';
|
|
2
|
-
|
|
1
|
+
import { TaskHandlerInput, TaskData, TaskResult, TaskResultStatus } from '../actions';
|
|
2
|
+
/**
|
|
3
|
+
* extends {@link TaskResultStatus} to include `QUEUED` and `PENDING` statuses
|
|
4
|
+
* used in task processing
|
|
5
|
+
*/
|
|
6
|
+
export type TaskStatus = TaskResultStatus | 'QUEUED' | 'PENDING';
|
|
7
|
+
/**
|
|
8
|
+
* aggregate task status counts
|
|
9
|
+
*/
|
|
3
10
|
export type StatusCounts = Record<TaskStatus | 'TOTAL', number>;
|
|
4
|
-
export interface ProcessTasksOptions<
|
|
5
|
-
concurrency?:
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
export interface ProcessTasksOptions<TTask extends Task, TItems = []> {
|
|
12
|
+
concurrency?: number;
|
|
13
|
+
items?: TItems;
|
|
14
|
+
onTaskCancel?: (task: TTask) => void;
|
|
15
|
+
onTaskComplete?: (task: TTask) => void;
|
|
16
|
+
onTaskError?: (task: TTask, error: unknown) => void;
|
|
17
|
+
onTaskProgress?: (task: TTask, progress: number | undefined) => void;
|
|
18
|
+
onTaskSuccess?: (task: TTask, value: TTask['value'] | undefined) => void;
|
|
19
|
+
onTaskRemove?: (task: TTask) => void;
|
|
12
20
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
21
|
+
/**
|
|
22
|
+
* `task` properties, extends {@link TaskResult} with task data, optional cancel
|
|
23
|
+
* handler and progress
|
|
24
|
+
*/
|
|
25
|
+
export interface Task<TData = unknown, TValue = any> extends TaskResult<TaskStatus, TValue> {
|
|
26
|
+
/**
|
|
27
|
+
* task specific data
|
|
28
|
+
*/
|
|
29
|
+
data: TData & TaskData;
|
|
30
|
+
/**
|
|
31
|
+
* task progress
|
|
32
|
+
*/
|
|
33
|
+
progress?: number;
|
|
34
|
+
/**
|
|
35
|
+
* cancel handler
|
|
36
|
+
*/
|
|
18
37
|
cancel?: () => void;
|
|
19
|
-
value?: V;
|
|
20
38
|
}
|
|
21
|
-
export type
|
|
22
|
-
export
|
|
23
|
-
export interface TasksState<T extends TaskData = TaskData> {
|
|
39
|
+
export type HandleProcessTasks<TInput> = (input: TInput) => void;
|
|
40
|
+
export interface TasksState<TTask> {
|
|
24
41
|
isProcessing: boolean;
|
|
25
42
|
isProcessingComplete: boolean;
|
|
26
43
|
reset: () => void;
|
|
27
44
|
statusCounts: StatusCounts;
|
|
28
|
-
tasks:
|
|
45
|
+
tasks: TTask[];
|
|
29
46
|
}
|
|
30
|
-
export type UseProcessTasksState<
|
|
31
|
-
TasksState<
|
|
32
|
-
HandleProcessTasks<
|
|
47
|
+
export type UseProcessTasksState<TTask, TInput> = [
|
|
48
|
+
TasksState<TTask>,
|
|
49
|
+
HandleProcessTasks<TInput>
|
|
33
50
|
];
|
|
51
|
+
export type InferHandleTasksInput<TItems, TData extends TaskData> = TItems extends NonNullable<TItems> ? Omit<TaskHandlerInput<TData>, 'data'> : TaskHandlerInput<TData>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { ActionHandler
|
|
2
|
-
import { ProcessTasksOptions, UseProcessTasksState } from './types';
|
|
3
|
-
export declare
|
|
1
|
+
import { ActionHandler } from '../actions';
|
|
2
|
+
import { InferHandleTasksInput, Task, ProcessTasksOptions, UseProcessTasksState } from './types';
|
|
3
|
+
export declare function useProcessTasks<TData, TValue, TTask extends Task<TData, TValue>, TInput extends InferHandleTasksInput<TItems, TTask['data']>, TItems extends TTask['data'][] | undefined = undefined>(handler: ActionHandler<TData, TValue>, options?: ProcessTasksOptions<TTask, TItems>): UseProcessTasksState<TTask, TInput>;
|
|
@@ -1,57 +1,213 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { CustomActionConfigs, DefaultActionConfigs, ExtendedActionConfigs, ListLocations } from './actions';
|
|
2
|
+
import { CustomActionConfigs, DefaultActionConfigs, ExtendedActionConfigs, ListLocations, LocationData } from './actions';
|
|
3
3
|
import { GetLocationCredentials } from './credentials/types';
|
|
4
|
-
import { Components } from './ComponentsProvider';
|
|
5
4
|
import { ErrorBoundaryType } from './ErrorBoundary';
|
|
5
|
+
import { StorageBrowserComponents } from './ComponentsProvider';
|
|
6
6
|
import { RegisterAuthListener, StoreProviderProps } from './providers';
|
|
7
|
-
import { CopyViewType, CreateFolderViewType, DeleteViewType, UploadViewType, LocationActionViewType, LocationDetailViewType, LocationsViewType,
|
|
7
|
+
import { CopyViewType, CreateFolderViewType, DeleteViewType, UploadViewType, LocationActionViewType, LocationDetailViewType, LocationsViewType, UseView, StorageBrowserViews } from './views';
|
|
8
8
|
import { StorageBrowserDisplayText } from './displayText';
|
|
9
9
|
import { DerivedActionHandlers, UseAction } from './useAction';
|
|
10
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Configuration properties
|
|
12
|
+
*/
|
|
13
|
+
export interface StorageBrowserConfig {
|
|
14
|
+
/**
|
|
15
|
+
* AWS account Id
|
|
16
|
+
*/
|
|
11
17
|
accountId?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Custom S3 endpoint used in action handler calls
|
|
20
|
+
*/
|
|
12
21
|
customEndpoint?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Location credentials retrieval handler
|
|
24
|
+
*/
|
|
13
25
|
getLocationCredentials: GetLocationCredentials;
|
|
26
|
+
/**
|
|
27
|
+
* @required
|
|
28
|
+
*
|
|
29
|
+
* Locations list handler
|
|
30
|
+
*/
|
|
14
31
|
listLocations: ListLocations;
|
|
32
|
+
/**
|
|
33
|
+
* @required
|
|
34
|
+
*
|
|
35
|
+
* Provided handler receives an `onStateChange` callback to be called from
|
|
36
|
+
* the consumer on auth status changes to clear in-memory credentials
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```tsx
|
|
40
|
+
* // src/auth.ts
|
|
41
|
+
* class MyAuth {
|
|
42
|
+
* // ...other private fields
|
|
43
|
+
* private onStateChange: () => void | undefined;
|
|
44
|
+
*
|
|
45
|
+
* registerAuthListener = (onStateChange: () => void) => {
|
|
46
|
+
* // set `onStateChange` callback
|
|
47
|
+
* this.onStateChange = onStateChange;
|
|
48
|
+
* };
|
|
49
|
+
*
|
|
50
|
+
* signOut() {
|
|
51
|
+
* // ...do sign out stuff
|
|
52
|
+
*
|
|
53
|
+
* // run `onStateChange` callback
|
|
54
|
+
* this.onStateChange?.();
|
|
55
|
+
* }
|
|
56
|
+
* }
|
|
57
|
+
*
|
|
58
|
+
* export const myAuth = new MyAuth();
|
|
59
|
+
*
|
|
60
|
+
* // src/storage-browser.ts
|
|
61
|
+
* import {
|
|
62
|
+
* createStorageBrowser,
|
|
63
|
+
* createManagedAuthAdapter
|
|
64
|
+
* } from '@aws-amplify/ui-react-storage/browser';
|
|
65
|
+
*
|
|
66
|
+
* import { myAuth } from './auth.ts';
|
|
67
|
+
*
|
|
68
|
+
* const managedAuthAdapter = createManagedAuthAdapter({
|
|
69
|
+
* accountId: myAuth.accountId,
|
|
70
|
+
* credentialsProvider: myAuth.credentialsProvider,
|
|
71
|
+
* region: myAuth.region,
|
|
72
|
+
* registerAuthListener: myAuth.registerAuthListener,
|
|
73
|
+
* });
|
|
74
|
+
*
|
|
75
|
+
* export const { StorageBrowser } = createStorageBrowser({
|
|
76
|
+
* config: managedAuthAdapter,
|
|
77
|
+
* });
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
15
80
|
registerAuthListener: RegisterAuthListener;
|
|
81
|
+
/**
|
|
82
|
+
* @required
|
|
83
|
+
*
|
|
84
|
+
* AWS account region
|
|
85
|
+
*/
|
|
16
86
|
region: string;
|
|
17
87
|
}
|
|
18
88
|
export interface StorageBrowserActions {
|
|
19
89
|
default?: DefaultActionConfigs;
|
|
20
90
|
custom?: CustomActionConfigs;
|
|
21
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
* Configuration and options for `createStorageBrowser`
|
|
94
|
+
*/
|
|
22
95
|
export interface CreateStorageBrowserInput {
|
|
96
|
+
/**
|
|
97
|
+
* Override and default `StorageBrowser` actions and action view configs
|
|
98
|
+
*/
|
|
23
99
|
actions?: StorageBrowserActions;
|
|
24
|
-
|
|
25
|
-
|
|
100
|
+
/**
|
|
101
|
+
* `StorageBrowser` configuration properties
|
|
102
|
+
*/
|
|
103
|
+
config: StorageBrowserConfig;
|
|
26
104
|
/**
|
|
27
105
|
* Custom ErrorBoundary class. If omitted, a default ErrorBoundary is provided.
|
|
28
106
|
* To disable ErrorBoundary, set to `null`.
|
|
29
107
|
*/
|
|
30
108
|
ErrorBoundary?: ErrorBoundaryType | null;
|
|
109
|
+
/**
|
|
110
|
+
* Overrides default `components` used within `StorageBrowser`
|
|
111
|
+
*/
|
|
112
|
+
components?: StorageBrowserComponents;
|
|
31
113
|
}
|
|
114
|
+
/**
|
|
115
|
+
* `StorageBrowser` component properties
|
|
116
|
+
*/
|
|
32
117
|
export interface StorageBrowserProps<K = string, V = {}> {
|
|
118
|
+
/**
|
|
119
|
+
* Overrides default display string values. Supports resolving of static and dynamic text
|
|
120
|
+
* values and error messages
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* ```tsx
|
|
124
|
+
* const myDisplayText = {
|
|
125
|
+
* CreateFolderView: {
|
|
126
|
+
* // static text
|
|
127
|
+
* // default: "Create folder"
|
|
128
|
+
* title: 'Add subfolder",
|
|
129
|
+
*
|
|
130
|
+
* // dynamic text
|
|
131
|
+
* // default: () => 'Folder name cannot contain "/", nor start or end with "."'
|
|
132
|
+
* getValidationMessage?: (folderName) =>
|
|
133
|
+
* `Folder name "${folderName}" cannot contain "/", nor start or end with "."`
|
|
134
|
+
* }
|
|
135
|
+
* }
|
|
136
|
+
*
|
|
137
|
+
* <StorageBrowser displayText={{ displayText: myDisplayText }} />
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
33
140
|
displayText?: StorageBrowserDisplayText;
|
|
34
|
-
|
|
141
|
+
/**
|
|
142
|
+
* Accepts default top level `views` overrides and custom `views` defined by the `actions`
|
|
143
|
+
* parameter of `createStorageBrowser`
|
|
144
|
+
*/
|
|
145
|
+
views?: StorageBrowserViews<K, V>;
|
|
35
146
|
}
|
|
36
|
-
|
|
37
|
-
|
|
147
|
+
/**
|
|
148
|
+
* `StorageBrowser.Provider` component properties
|
|
149
|
+
*/
|
|
150
|
+
export interface StorageBrowserProviderProps<V = {}> extends StoreProviderProps, Pick<StorageBrowserProps, 'displayText'> {
|
|
151
|
+
/**
|
|
152
|
+
* Accepts custom action views rendered by `LocationActionView`
|
|
153
|
+
*/
|
|
38
154
|
views?: V;
|
|
155
|
+
/**
|
|
156
|
+
* Sets initial `location` data. Provide to initialize the `StorageBrowser` with an initial
|
|
157
|
+
* `location`
|
|
158
|
+
*/
|
|
159
|
+
location?: LocationData;
|
|
39
160
|
}
|
|
161
|
+
/**
|
|
162
|
+
* `StorageBrowser` component, provider and view components
|
|
163
|
+
*/
|
|
40
164
|
export interface StorageBrowserType<K = string, V = {}> {
|
|
41
165
|
(props: StorageBrowserProps<K, V>): React.JSX.Element;
|
|
42
166
|
displayName: string;
|
|
167
|
+
/**
|
|
168
|
+
* `StorageBrowser` React.Context provider. Composed `StorageBrowser` components
|
|
169
|
+
* must be a descendant of a `Provider` element
|
|
170
|
+
*
|
|
171
|
+
* @example
|
|
172
|
+
* ```tsx
|
|
173
|
+
* <StorageBrowser.Provider>
|
|
174
|
+
* <Modal content={<StorageBrowser.UploadView />}>
|
|
175
|
+
* </StorageBrowser.Provider>
|
|
176
|
+
* ```
|
|
177
|
+
*/
|
|
43
178
|
Provider: (props: StorageBrowserProviderProps<V>) => React.JSX.Element;
|
|
179
|
+
/**
|
|
180
|
+
* Utility view aggregating all action views. Can be used to render a standalone
|
|
181
|
+
* action view
|
|
182
|
+
*
|
|
183
|
+
* @example
|
|
184
|
+
* ```tsx
|
|
185
|
+
* <StorageBrowser.LocationActionView type="copy" />
|
|
186
|
+
* ```
|
|
187
|
+
*/
|
|
188
|
+
LocationActionView: LocationActionViewType<K>;
|
|
189
|
+
/**
|
|
190
|
+
* Displays data related to the selected or provided `location` and action
|
|
191
|
+
* selection
|
|
192
|
+
*/
|
|
193
|
+
LocationDetailView: LocationDetailViewType;
|
|
194
|
+
/**
|
|
195
|
+
* Entry point view displaying `locations` returned from `listLocations`
|
|
196
|
+
*/
|
|
197
|
+
LocationsView: LocationsViewType;
|
|
198
|
+
/**
|
|
199
|
+
* Standalone composable default action view components
|
|
200
|
+
*/
|
|
44
201
|
CopyView: CopyViewType;
|
|
45
202
|
CreateFolderView: CreateFolderViewType;
|
|
46
203
|
DeleteView: DeleteViewType;
|
|
47
204
|
UploadView: UploadViewType;
|
|
48
|
-
LocationActionView: LocationActionViewType<K>;
|
|
49
|
-
LocationDetailView: LocationDetailViewType;
|
|
50
|
-
LocationsView: LocationsViewType;
|
|
51
205
|
}
|
|
52
206
|
type DefaultActionType<T = string> = Exclude<T, keyof DefaultActionConfigs>;
|
|
53
207
|
/**
|
|
54
|
-
* @internal @unstable
|
|
208
|
+
* @internal @unstable interface subject to change, not recommended for public use
|
|
209
|
+
*
|
|
210
|
+
* Utility type resolving available custom action view component slots
|
|
55
211
|
*/
|
|
56
212
|
export type DerivedActionViews<T extends StorageBrowserActions> = {
|
|
57
213
|
[K in keyof T['custom'] as K extends DefaultActionType<K> ? T['custom'][K] extends {
|
|
@@ -59,16 +215,36 @@ export type DerivedActionViews<T extends StorageBrowserActions> = {
|
|
|
59
215
|
} ? T['custom'][K]['viewName'] : never : never]?: () => React.JSX.Element | null;
|
|
60
216
|
};
|
|
61
217
|
/**
|
|
62
|
-
* @internal @unstable
|
|
218
|
+
* @internal @unstable interface subject to change, not recommended for public use
|
|
219
|
+
*
|
|
220
|
+
* Utility type of excluded action keys that do not have a corresponding action view
|
|
221
|
+
*/
|
|
222
|
+
type DefaultActionWithoutViewType = 'download';
|
|
223
|
+
/**
|
|
224
|
+
* @internal @unstable interface subject to change, not recommended for public use
|
|
225
|
+
*
|
|
226
|
+
* Utility type resolving available location action view types
|
|
63
227
|
*/
|
|
64
228
|
export type DerivedActionViewType<T extends StorageBrowserActions> = keyof {
|
|
65
229
|
[K in keyof T['custom'] as K extends DefaultActionType<K> ? T['custom'][K] extends {
|
|
66
230
|
viewName: `${string}View`;
|
|
67
231
|
} ? K : never : never]?: any;
|
|
68
|
-
} | Exclude<keyof DefaultActionConfigs,
|
|
232
|
+
} | Exclude<keyof DefaultActionConfigs, DefaultActionWithoutViewType>;
|
|
233
|
+
/**
|
|
234
|
+
* Return values of `createStorageBrowser`
|
|
235
|
+
*/
|
|
69
236
|
export interface CreateStorageBrowserOutput<C extends ExtendedActionConfigs = ExtendedActionConfigs> {
|
|
237
|
+
/**
|
|
238
|
+
* `StorageBrowser` component and subcomponents
|
|
239
|
+
*/
|
|
70
240
|
StorageBrowser: StorageBrowserType<DerivedActionViewType<C>, DerivedActionViews<C>>;
|
|
241
|
+
/**
|
|
242
|
+
* Action handler utility hook
|
|
243
|
+
*/
|
|
71
244
|
useAction: UseAction<DerivedActionHandlers<C>>;
|
|
245
|
+
/**
|
|
246
|
+
* View state utility hook
|
|
247
|
+
*/
|
|
72
248
|
useView: UseView;
|
|
73
249
|
}
|
|
74
250
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { DataState } from '@aws-amplify/ui-react-core';
|
|
3
|
-
import { ActionHandler, ExtendedActionConfigs, CopyHandler, CreateFolderHandler, DeleteHandler, DownloadHandler, ListLocationItemsHandler, ListLocations, LocationData,
|
|
4
|
-
import { StatusCounts, Task
|
|
3
|
+
import { ActionHandler, ExtendedActionConfigs, CopyHandler, CreateFolderHandler, DeleteHandler, DownloadHandler, ListLocationItemsHandler, ListLocations, LocationData, UploadHandler } from '../actions';
|
|
4
|
+
import { ProcessTasksOptions, StatusCounts, Task } from '../tasks';
|
|
5
5
|
export type ListActionState<T = any, K = any> = [
|
|
6
6
|
state: DataState<T>,
|
|
7
7
|
handleAction: (...input: K[]) => void
|
|
@@ -29,48 +29,76 @@ export type ResolveHandlerType<T> = T extends {
|
|
|
29
29
|
export type DerivedActionHandlers<C extends ExtendedActionConfigs = ExtendedActionConfigs, D extends DerivedCustomActions<C> = DerivedCustomActions<C>> = DefaultActionHandlers & {
|
|
30
30
|
[K in keyof D]: ResolveHandlerType<D[K]>;
|
|
31
31
|
};
|
|
32
|
-
export
|
|
33
|
-
|
|
34
|
-
onTaskSuccess?: (task: Task<U>) => void;
|
|
32
|
+
export type InferTask<THandler> = THandler extends ActionHandler<infer TData, infer TValue> ? Task<TData, TValue> : never;
|
|
33
|
+
export interface UseHandlerOptions<TTask extends Task> extends Pick<ProcessTasksOptions<TTask>, 'onTaskError' | 'onTaskProgress' | 'onTaskSuccess'> {
|
|
35
34
|
}
|
|
36
|
-
interface
|
|
37
|
-
|
|
35
|
+
export interface UseHandlerOptionsWithItems<TTask extends Task> extends UseHandlerOptions<TTask> {
|
|
36
|
+
items: TTask['data'][];
|
|
38
37
|
}
|
|
39
|
-
export interface
|
|
40
|
-
data: T;
|
|
38
|
+
export interface HandleTasksInput {
|
|
41
39
|
location?: LocationData;
|
|
42
|
-
options?: {
|
|
43
|
-
onSuccess?: (data: {
|
|
44
|
-
id: string;
|
|
45
|
-
key: string;
|
|
46
|
-
}, value: K) => void;
|
|
47
|
-
onError?: (data: {
|
|
48
|
-
id: string;
|
|
49
|
-
key: string;
|
|
50
|
-
}, message: string | undefined) => void;
|
|
51
|
-
};
|
|
52
40
|
}
|
|
53
|
-
export
|
|
54
|
-
export interface TasksState<T extends TaskData, V = any> {
|
|
41
|
+
export interface TasksState<TTask> {
|
|
55
42
|
isProcessing: boolean;
|
|
56
43
|
isProcessingComplete: boolean;
|
|
57
44
|
reset: () => void;
|
|
58
45
|
statusCounts: StatusCounts;
|
|
59
|
-
tasks:
|
|
46
|
+
tasks: TTask[];
|
|
60
47
|
}
|
|
61
|
-
export type
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
HandleTasks
|
|
48
|
+
export type HandleTasksState<TTask> = [
|
|
49
|
+
TasksState<TTask>,
|
|
50
|
+
(input?: HandleTasksInput) => void
|
|
65
51
|
];
|
|
66
|
-
export type
|
|
67
|
-
export type UseTaskState<T extends TaskData, R> = [
|
|
52
|
+
export type HandleTaskState<TTask extends Task> = [
|
|
68
53
|
{
|
|
69
|
-
task:
|
|
54
|
+
task: TTask;
|
|
70
55
|
isProcessing: boolean;
|
|
71
56
|
},
|
|
72
|
-
|
|
57
|
+
(input: HandleTaskInput<TTask['data']>) => void
|
|
58
|
+
];
|
|
59
|
+
export interface HandleTaskInput<TData> {
|
|
60
|
+
data: TData;
|
|
61
|
+
location?: LocationData;
|
|
62
|
+
}
|
|
63
|
+
export interface UseActionOptions<TTask extends Task> extends UseHandlerOptions<TTask> {
|
|
64
|
+
}
|
|
65
|
+
export interface UseActionOptionsWithItems<TTask extends Task> extends UseActionOptions<TTask> {
|
|
66
|
+
items: TTask['data'][];
|
|
67
|
+
}
|
|
68
|
+
interface HandleActionsInput extends HandleTasksInput {
|
|
69
|
+
}
|
|
70
|
+
export type UseActionsState<TTask> = [
|
|
71
|
+
TasksState<TTask>,
|
|
72
|
+
(input?: HandleActionsInput) => void
|
|
73
73
|
];
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
interface HandleActionInput<TTask> extends HandleTaskInput<TTask> {
|
|
75
|
+
}
|
|
76
|
+
export type UseActionState<TTask extends Task> = [
|
|
77
|
+
{
|
|
78
|
+
task: TTask | undefined;
|
|
79
|
+
isProcessing: boolean;
|
|
80
|
+
},
|
|
81
|
+
(input: HandleActionInput<TTask['data']>) => void
|
|
82
|
+
];
|
|
83
|
+
/**
|
|
84
|
+
* `StorageBrowser` utility hook used to run default and custom action handlers
|
|
85
|
+
* from within a parent `StorageBrowser.Provider`. `useAction` provides the
|
|
86
|
+
* action handler with the current `location` state and credentials values,
|
|
87
|
+
* as well as any parameters provided as `data` at the `useAction` call site
|
|
88
|
+
*/
|
|
89
|
+
export interface UseAction<Handlers extends Record<keyof Handlers, ActionHandler>> {
|
|
90
|
+
/**
|
|
91
|
+
* accepts `handler` to be run as initial argument and `options` with `items`
|
|
92
|
+
* as second. Returns batch task state and `handler` accoeting optional input
|
|
93
|
+
* allowing for location override
|
|
94
|
+
*/
|
|
95
|
+
<K extends keyof Handlers, TTask extends InferTask<Handlers[K]>>(key: K, options: UseActionOptionsWithItems<TTask>): UseActionsState<TTask>;
|
|
96
|
+
/**
|
|
97
|
+
* * accepts `handler` to be run as initial argument and `options` as second.
|
|
98
|
+
* Returns atomic task `state` and `handler``input`, `handler` requires `input`
|
|
99
|
+
* containing `data` and `options`
|
|
100
|
+
*/
|
|
101
|
+
<K extends keyof Handlers, TTask extends InferTask<Handlers[K]>>(key: K, options?: UseActionOptions<TTask>): UseActionState<TTask>;
|
|
102
|
+
<K extends keyof Handlers, TTask extends InferTask<Handlers[K]>>(key: K, options?: UseActionOptionsWithItems<TTask> | UseActionOptions<TTask>): UseActionsState<TTask> | UseActionState<TTask>;
|
|
103
|
+
}
|
|
76
104
|
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export declare
|
|
1
|
+
import { ActionHandler } from '../actions';
|
|
2
|
+
import { InferTask, HandleTaskState, HandleTasksState, UseHandlerOptions, UseHandlerOptionsWithItems } from './types';
|
|
3
|
+
export declare function useHandler<THandler extends ActionHandler, TTask extends InferTask<THandler>>(handler: THandler, options: UseHandlerOptionsWithItems<TTask>): HandleTasksState<TTask>;
|
|
4
|
+
export declare function useHandler<THandler extends ActionHandler, TTask extends InferTask<THandler>>(handler: THandler, options?: UseHandlerOptions<TTask>): HandleTaskState<TTask>;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { UseListLocationsState } from './useListLocations';
|
|
2
|
+
import { UseListLocationItemsState } from './useListLocationItems';
|
|
3
|
+
import { UseListFolderItemsState } from './useListFolderItems';
|
|
4
|
+
interface DefaultUseListStates {
|
|
5
|
+
folderItems: UseListFolderItemsState;
|
|
6
|
+
locationItems: UseListLocationItemsState;
|
|
7
|
+
locations: UseListLocationsState;
|
|
8
|
+
}
|
|
9
|
+
type UseListType = keyof DefaultUseListStates;
|
|
10
|
+
export type UseList = <K extends UseListType>(type: K) => DefaultUseListStates[K];
|
|
8
11
|
export declare const useList: UseList;
|
|
9
12
|
export {};
|
|
@@ -47,3 +47,8 @@ export interface FoldersState {
|
|
|
47
47
|
onSearchClear: () => void;
|
|
48
48
|
onSelectFolder: (id: string, folderLocationPath: string) => void;
|
|
49
49
|
}
|
|
50
|
+
export interface CopyViewState extends ActionViewState<CopyHandlerData> {
|
|
51
|
+
folders: FoldersState;
|
|
52
|
+
destination: LocationState;
|
|
53
|
+
onSelectDestination: (location: LocationData, path?: string) => void;
|
|
54
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { LocationData, UploadHandlerData } from '../../../actions';
|
|
2
|
-
import {
|
|
2
|
+
import { FileItems } from '../../../providers';
|
|
3
3
|
import { ActionViewType, ActionViewProps, ActionViewState } from '../types';
|
|
4
|
-
export interface UploadViewState extends ActionViewState<
|
|
4
|
+
export interface UploadViewState extends ActionViewState<UploadHandlerData> {
|
|
5
5
|
isOverwritingEnabled: boolean;
|
|
6
6
|
onDropFiles: (files: File[]) => void;
|
|
7
7
|
onSelectFiles: (type: 'FILE' | 'FOLDER') => void;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { LocationData, TaskData } from '../../actions';
|
|
2
|
-
import { LocationState } from '../../providers/store/location';
|
|
3
|
-
import { StatusCounts, Task, Tasks } from '../../tasks';
|
|
4
|
-
import { DataTableProps } from '../../composables/DataTable';
|
|
5
2
|
import { WithKey } from '../../components/types';
|
|
3
|
+
import { DataTableProps } from '../../composables/DataTable';
|
|
4
|
+
import { LocationState } from '../../providers/store/location';
|
|
5
|
+
import { StatusCounts, Task } from '../../tasks';
|
|
6
6
|
export interface ActionViewState<T extends TaskData = TaskData> {
|
|
7
7
|
isProcessing: boolean;
|
|
8
8
|
isProcessingComplete: boolean;
|
|
@@ -12,7 +12,7 @@ export interface ActionViewState<T extends TaskData = TaskData> {
|
|
|
12
12
|
onActionStart: () => void;
|
|
13
13
|
onTaskRemove?: (task: Task<T>) => void;
|
|
14
14
|
statusCounts: StatusCounts;
|
|
15
|
-
tasks:
|
|
15
|
+
tasks: Task<T>[];
|
|
16
16
|
}
|
|
17
17
|
export interface ActionViewProps {
|
|
18
18
|
children?: React.ReactNode;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { LocationDetailView } from './LocationDetailView';
|
|
2
|
-
export { LocationDetailViewProps, LocationDetailViewType } from './types';
|
|
2
|
+
export { LocationDetailViewProps, LocationDetailViewState, LocationDetailViewType, } from './types';
|
|
3
3
|
export { useLocationDetailView } from './useLocationDetailView';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { CustomActionConfigs } from '../../actions';
|
|
2
|
-
import {
|
|
2
|
+
import { StorageBrowserViews } from '../types';
|
|
3
3
|
import { ViewsContextType } from './types';
|
|
4
|
-
export declare const getViews: (views?:
|
|
4
|
+
export declare const getViews: (views?: StorageBrowserViews, customConfigs?: CustomActionConfigs) => ViewsContextType;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ExtendedActionConfigs } from '../../actions';
|
|
3
|
-
import {
|
|
3
|
+
import { StorageBrowserViews } from '../types';
|
|
4
4
|
import { ViewsContextType } from './types';
|
|
5
5
|
export declare function ViewsProvider({ children, views, actions, }: {
|
|
6
6
|
children?: React.ReactNode;
|
|
7
7
|
actions?: ExtendedActionConfigs;
|
|
8
|
-
views?:
|
|
8
|
+
views?: StorageBrowserViews;
|
|
9
9
|
}): React.JSX.Element;
|
|
10
10
|
export declare function useViews(): ViewsContextType;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
interface
|
|
1
|
+
interface UsePaginateState<T> {
|
|
2
2
|
currentPage: number;
|
|
3
3
|
highestPageVisited: number;
|
|
4
|
-
|
|
4
|
+
handlePaginate: (page: number) => void;
|
|
5
5
|
handleReset: () => void;
|
|
6
6
|
pageItems: T[];
|
|
7
7
|
}
|
|
8
|
-
interface
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
pageSize
|
|
8
|
+
interface UsePaginateInput<T> {
|
|
9
|
+
items?: T[];
|
|
10
|
+
onPaginate?: (page?: number) => void;
|
|
11
|
+
page?: number;
|
|
12
|
+
pageSize?: number;
|
|
13
13
|
}
|
|
14
|
-
export declare const usePaginate: <T>({
|
|
14
|
+
export declare const usePaginate: <T>({ items, onPaginate, page, pageSize, }: UsePaginateInput<T>) => UsePaginateState<T>;
|
|
15
15
|
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { WithKey } from '../../../components/types';
|
|
2
|
+
import { DataTableHeader, DataTableDataCell } from '../../../composables/DataTable';
|
|
3
|
+
interface ResolverProps<P> {
|
|
4
|
+
/**
|
|
5
|
+
* additional props provided from consumer
|
|
6
|
+
*/
|
|
7
|
+
props: P;
|
|
8
|
+
}
|
|
9
|
+
type ResolveData<TData, TDataCell> = (data: TData) => WithKey<TDataCell>;
|
|
10
|
+
export interface CellData<TProps, TItem> extends ResolverProps<TProps> {
|
|
11
|
+
/**
|
|
12
|
+
* cell item
|
|
13
|
+
*/
|
|
14
|
+
item: TItem;
|
|
15
|
+
}
|
|
16
|
+
export type GetCell<K, TProps, TItem> = ResolveData<WithKey<CellData<TProps, TItem>, K>, DataTableDataCell>;
|
|
17
|
+
export interface HeaderData<TProps> extends ResolverProps<TProps> {
|
|
18
|
+
}
|
|
19
|
+
export type GetHeader<K, TProps> = ResolveData<WithKey<HeaderData<TProps>, K>, DataTableHeader>;
|
|
20
|
+
export type GetRowKey<TProps, TItem> = (data: CellData<TProps, TItem>) => string;
|
|
21
|
+
export interface DataTableResolvers<K, TProps, TItem> {
|
|
22
|
+
getCell: GetCell<K, TProps, TItem>;
|
|
23
|
+
getHeader: GetHeader<K, TProps>;
|
|
24
|
+
getRowKey: GetRowKey<TProps, TItem>;
|
|
25
|
+
}
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { DataTableProps } from '../../../composables/DataTable';
|
|
2
|
+
import { DataTableResolvers } from './types';
|
|
3
|
+
export default function useResolveDataTable<K extends string, TItem = {}, TProps = {}>(keys: readonly K[] | K[], { getCell, getHeader, getRowKey }: DataTableResolvers<K, TProps, TItem>, { items, props }: {
|
|
4
|
+
items?: TItem[];
|
|
5
|
+
props: TProps;
|
|
6
|
+
}): DataTableProps;
|