Skip to content

Commit

Permalink
Merge pull request #5420 from marmelab/fix-types
Browse files Browse the repository at this point in the history
Export and Rename Types
  • Loading branch information
Luwangel authored Oct 19, 2020
2 parents 159aa03 + 02ca835 commit 18b8869
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 9 deletions.
4 changes: 2 additions & 2 deletions packages/ra-core/src/controller/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import useVersion from './useVersion';
import useExpanded from './useExpanded';
import useFilterState from './useFilterState';
import useSortState, { SortProps } from './useSortState';
import usePaginationState, { PaginationProps } from './usePaginationState';
import usePaginationState, { PaginationHookResult } from './usePaginationState';
import useListController, {
getListControllerProps,
sanitizeListRestProps,
Expand All @@ -39,7 +39,7 @@ export type {
CreateControllerProps,
ShowControllerProps,
UseReferenceProps,
PaginationProps,
PaginationHookResult,
SortProps,
};

Expand Down
6 changes: 3 additions & 3 deletions packages/ra-core/src/controller/usePaginationState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { PaginationPayload } from '../types';
* @property {Function} setPerPage: Set the per page number
* @property {Function} setPagination: Set page and perPage pagination numbers
*/
export interface PaginationProps {
export interface PaginationHookResult {
page: number;
perPage: number;
pagination: PaginationPayload;
Expand Down Expand Up @@ -42,11 +42,11 @@ const defaultPagination = {
* const { page, setpage, perPage, setPerPage } = usePagination(initialPerPage);
*
* @param {number} initialPagination the initial value per page
* @returns {PaginationProps} The pagination props
* @returns {PaginationHookResult} The pagination props
*/
export default (
initialPagination: { perPage?: number; page?: number } = {}
): PaginationProps => {
): PaginationHookResult => {
const [pagination, setPagination] = useReducer(paginationReducer, {
...defaultPagination,
...initialPagination,
Expand Down
8 changes: 6 additions & 2 deletions packages/ra-core/src/form/FormDataConsumer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@ import get from 'lodash/get';

import warning from '../util/warning';

interface ChildrenFunctionParams {
export interface FormDataConsumerRenderParams {
formData: any;
scopedFormData?: any;
getSource?: (source: string) => string;
}

export type FormDataConsumerRender = (
params: FormDataConsumerRenderParams
) => ReactNode;

interface ConnectedProps {
children: (params: ChildrenFunctionParams) => ReactNode;
children: FormDataConsumerRender;
form?: string;
record?: any;
source?: string;
Expand Down
7 changes: 6 additions & 1 deletion packages/ra-core/src/form/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import addField from './addField';
import FormDataConsumer from './FormDataConsumer';
import FormDataConsumer, {
FormDataConsumerRender,
FormDataConsumerRenderParams,
} from './FormDataConsumer';
import FormContext from './FormContext';
import FormField from './FormField';
import FormWithRedirect, {
Expand All @@ -23,6 +26,8 @@ import useWarnWhenUnsavedChanges from './useWarnWhenUnsavedChanges';
export type {
ChoicesProps,
ChoicesInputProps,
FormDataConsumerRender,
FormDataConsumerRenderParams,
FormWithRedirectProps,
HandleSubmitWithRedirect,
InputProps,
Expand Down
4 changes: 3 additions & 1 deletion packages/ra-ui-materialui/src/list/pagination/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import Pagination from './Pagination';
import Pagination, { PaginationProps } from './Pagination';
import PaginationActions from './PaginationActions';
import PaginationLimit from './PaginationLimit';

export type { PaginationProps };

export { Pagination, PaginationActions, PaginationLimit };

0 comments on commit 18b8869

Please sign in to comment.