diff --git a/packages/ra-core/src/dataProvider/useDataProviderWithDeclarativeSideEffects.ts b/packages/ra-core/src/dataProvider/useDataProviderWithDeclarativeSideEffects.ts index 1affe5eac7d..6c8353fc896 100644 --- a/packages/ra-core/src/dataProvider/useDataProviderWithDeclarativeSideEffects.ts +++ b/packages/ra-core/src/dataProvider/useDataProviderWithDeclarativeSideEffects.ts @@ -1,6 +1,10 @@ import useDataProvider from './useDataProvider'; import { useMemo } from 'react'; -import { DataProvider, UseDataProviderOptions } from '../types'; +import { + DataProvider, + DataProviderProxy, + UseDataProviderOptions, +} from '../types'; import useDeclarativeSideEffects from './useDeclarativeSideEffects'; /** @@ -9,10 +13,11 @@ import useDeclarativeSideEffects from './useDeclarativeSideEffects'; * * @deprecated This is for backward compatibility only and will be removed in next major version. */ -const useDataProviderWithDeclarativeSideEffects = (): DataProvider => { +const useDataProviderWithDeclarativeSideEffects = (): DataProviderProxy => { const dataProvider = useDataProvider(); const getSideEffects = useDeclarativeSideEffects(); + // @ts-ignore const dataProviderProxy = useMemo(() => { return new Proxy(dataProvider, { get: (target, name) => { diff --git a/packages/ra-core/src/export/fetchRelatedRecords.ts b/packages/ra-core/src/export/fetchRelatedRecords.ts index 498307b2fbd..6319a876f4d 100644 --- a/packages/ra-core/src/export/fetchRelatedRecords.ts +++ b/packages/ra-core/src/export/fetchRelatedRecords.ts @@ -1,4 +1,4 @@ -import { DataProvider, Record, Identifier } from '../types'; +import { Record, Identifier, DataProviderProxy } from '../types'; /** * Helper function for calling the dataProvider.getMany() method, @@ -11,7 +11,7 @@ import { DataProvider, Record, Identifier } from '../types'; * post_title: posts[record.post_id].title, * })); */ -const fetchRelatedRecords = (dataProvider: DataProvider) => ( +const fetchRelatedRecords = (dataProvider: DataProviderProxy) => ( data, field, resource diff --git a/packages/ra-core/src/types.ts b/packages/ra-core/src/types.ts index d13f06b14e9..77182707746 100644 --- a/packages/ra-core/src/types.ts +++ b/packages/ra-core/src/types.ts @@ -85,27 +85,27 @@ export type LegacyAuthProvider = ( */ export type DataProvider = { - getList: ( + getList: ( resource: string, params: GetListParams ) => Promise>; - getOne: ( + getOne: ( resource: string, params: GetOneParams ) => Promise>; - getMany: ( + getMany: ( resource: string, params: GetManyParams ) => Promise>; - getManyReference: ( + getManyReference: ( resource: string, params: GetManyReferenceParams ) => Promise>; - update: ( + update: ( resource: string, params: UpdateParams ) => Promise>; @@ -115,12 +115,12 @@ export type DataProvider = { params: UpdateManyParams ) => Promise; - create: ( + create: ( resource: string, params: CreateParams ) => Promise>; - delete: ( + delete: ( resource: string, params: DeleteParams ) => Promise>; @@ -227,31 +227,31 @@ export type DataProviderResult = | UpdateManyResult; export type DataProviderProxy = { - getList: ( + getList: ( resource: string, params: GetListParams, options?: UseDataProviderOptions ) => Promise>; - getOne: ( + getOne: ( resource: string, params: GetOneParams, options?: UseDataProviderOptions ) => Promise>; - getMany: ( + getMany: ( resource: string, params: GetManyParams, options?: UseDataProviderOptions ) => Promise>; - getManyReference: ( + getManyReference: ( resource: string, params: GetManyReferenceParams, options?: UseDataProviderOptions ) => Promise>; - update: ( + update: ( resource: string, params: UpdateParams, options?: UseDataProviderOptions @@ -263,13 +263,13 @@ export type DataProviderProxy = { options?: UseDataProviderOptions ) => Promise; - create: ( + create: ( resource: string, params: CreateParams, options?: UseDataProviderOptions ) => Promise>; - delete: ( + delete: ( resource: string, params: DeleteParams, options?: UseDataProviderOptions diff --git a/packages/ra-ui-materialui/src/list/ListActions.tsx b/packages/ra-ui-materialui/src/list/ListActions.tsx index 84d6cb32bcb..98237c67130 100644 --- a/packages/ra-ui-materialui/src/list/ListActions.tsx +++ b/packages/ra-ui-materialui/src/list/ListActions.tsx @@ -73,7 +73,7 @@ ListActions.defaultProps = { onUnselectItems: () => null, }; -interface ListActionsProps extends ToolbarProps { +export interface ListActionsProps extends ToolbarProps { currentSort?: SortPayload; className?: string; resource?: string; diff --git a/packages/ra-ui-materialui/src/list/index.ts b/packages/ra-ui-materialui/src/list/index.ts index 4f067650c6c..5bbbf1003e6 100644 --- a/packages/ra-ui-materialui/src/list/index.ts +++ b/packages/ra-ui-materialui/src/list/index.ts @@ -1,12 +1,14 @@ -import BulkActionsToolbar from './BulkActionsToolbar'; +import BulkActionsToolbar, { + BulkActionsToolbarProps, +} from './BulkActionsToolbar'; import BulkDeleteAction from './BulkDeleteAction'; import List from './List'; -import ListActions from './ListActions'; +import ListActions, { ListActionsProps } from './ListActions'; import ListGuesser from './ListGuesser'; -import ListToolbar from './ListToolbar'; +import ListToolbar, { ListToolbarProps } from './ListToolbar'; import ListView from './ListView'; import Placeholder from './Placeholder'; -import SimpleList from './SimpleList'; +import SimpleList, { SimpleListProps } from './SimpleList'; import SimpleListLoading from './SimpleListLoading'; import SingleFieldList from './SingleFieldList'; @@ -14,6 +16,13 @@ export * from './filter'; export * from './datagrid'; export * from './pagination'; +export type { + BulkActionsToolbarProps, + ListActionsProps, + ListToolbarProps, + SimpleListProps, +}; + export { BulkActionsToolbar, BulkDeleteAction,