Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix JS docs (@typedef) #9752

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -15,7 +15,7 @@ import { CreateControllerResult } from './useCreateController';
*
* The given props will take precedence over context values.
*
* @typedef {Object} CreateControllerProps
* @param {Object} CreateControllerProps
*
* @returns {CreateControllerResult} create controller props
*
Expand Down
2 changes: 1 addition & 1 deletion packages/ra-core/src/controller/edit/useEditContext.tsx
Expand Up @@ -15,7 +15,7 @@ import { EditControllerResult } from './useEditController';
*
* The given props will take precedence over context values.
*
* @typedef {Object} EditControllerProps
* @param {Object} EditControllerProps
*
* @returns {EditControllerResult} edit controller props
*
Expand Down
Expand Up @@ -35,13 +35,13 @@ export interface UseReferenceOneFieldControllerParams<
* target: 'author_id',
* });
*
* @typedef {Object} UseReferenceOneFieldControllerParams
* @prop {Object} props.record The current resource record
* @prop {string} props.reference The linked resource name
* @prop {string} props.target The target resource key
* @prop {string} props.source The key current record identifier ('id' by default)
* @prop {Object} props.sort The sort to apply to the referenced records
* @prop {Object} props.filter The filter to apply to the referenced records
* @param {Object} UseReferenceOneFieldControllerParams
* @param {Object} props.record The current resource record
* @param {string} props.reference The linked resource name
* @param {string} props.target The target resource key
* @param {string} props.source The key current record identifier ('id' by default)
* @param {Object} props.sort The sort to apply to the referenced records
* @param {Object} props.filter The filter to apply to the referenced records
* @returns {UseReferenceResult} The request state. Destructure as { referenceRecord, isLoading, error }.
*/
export const useReferenceOneFieldController = <
Expand Down
Expand Up @@ -6,9 +6,9 @@ import { InfiniteListControllerResult } from './useInfiniteListController';
*
* Use the useInfinitePaginationContext() hook to read the pagination callbacks.
*
* @typedef {Object} InfinitePaginationContextValue
* @prop {Function} fetchNextPage a callback to fetch the next page
* @prop {Function} fetchPreviousPage a callback to fetch the previous page
* @param {Object} InfinitePaginationContextValue
* @param {Function} fetchNextPage a callback to fetch the next page
* @param {Function} fetchPreviousPage a callback to fetch the previous page

* @example
*
Expand Down
53 changes: 25 additions & 28 deletions packages/ra-core/src/controller/list/ListContext.tsx
Expand Up @@ -7,34 +7,31 @@ import { ListControllerResult } from './useListController';
* Use the useListContext() hook to read the context. That's what many
* List components do in react-admin (e.g. <Datagrid>, <FilterForm>, <Pagination>).
*
* @typedef {Object} ListControllerProps
* @prop {Array} data an array of the list records, e.g. [{ id: 123, title: 'hello world' }, { ... }]
* @prop {integer} total the total number of results for the current filters, excluding pagination. Useful to build the pagination controls. e.g. 23
* @prop {boolean} isFetching boolean that is true on mount, and false once the data was fetched
* @prop {boolean} isLoading boolean that is false until the data is available
* @prop {integer} page the current page. Starts at 1
* @prop {Function} setPage a callback to change the page, e.g. setPage(3)
* @prop {integer} perPage the number of results per page. Defaults to 25
* @prop {Function} setPerPage a callback to change the number of results per page, e.g. setPerPage(25)
* @prop {Object} sort a sort object { field, order }, e.g. { field: 'date', order: 'DESC' }
* @prop {Function} setSort a callback to change the sort, e.g. setSort({ field: 'name', order: 'ASC' })
* @prop {Object} filterValues a dictionary of filter values, e.g. { title: 'lorem', nationality: 'fr' }
* @prop {Function} setFilters a callback to update the filters, e.g. setFilters(filters, displayedFilters)
* @prop {Object} displayedFilters a dictionary of the displayed filters, e.g. { title: true, nationality: true }
* @prop {Function} showFilter a callback to show one of the filters, e.g. showFilter('title', defaultValue)
* @prop {Function} hideFilter a callback to hide one of the filters, e.g. hideFilter('title')
* @prop {Array} selectedIds an array listing the ids of the selected rows, e.g. [123, 456]
* @prop {Function} onSelect callback to change the list of selected rows, e.g. onSelect([456, 789])
* @prop {Function} onToggleItem callback to toggle the selection of a given record based on its id, e.g. onToggleItem(456)
* @prop {Function} onUnselectItems callback to clear the selection, e.g. onUnselectItems();
* @prop {string} defaultTitle the translated title based on the resource, e.g. 'Posts'
* @prop {string} resource the resource name, deduced from the location. e.g. 'posts'
* @prop {Function} refetch a function for triggering a refetch of the list data
*
* @typedef Props
* @prop {ListControllerResult} value
*
* @param {Props}
* @param {Props} Props
* @param {Object} ListControllerProps
* @param {Array} data an array of the list records, e.g. [{ id: 123, title: 'hello world' }, { ... }]
* @param {integer} total the total number of results for the current filters, excluding pagination. Useful to build the pagination controls. e.g. 23
* @param {boolean} isFetching boolean that is true on mount, and false once the data was fetched
* @param {boolean} isLoading boolean that is false until the data is available
* @param {integer} page the current page. Starts at 1
* @param {Function} setPage a callback to change the page, e.g. setPage(3)
* @param {integer} perPage the number of results per page. Defaults to 25
* @param {Function} setPerPage a callback to change the number of results per page, e.g. setPerPage(25)
* @param {Object} sort a sort object { field, order }, e.g. { field: 'date', order: 'DESC' }
* @param {Function} setSort a callback to change the sort, e.g. setSort({ field: 'name', order: 'ASC' })
* @param {Object} filterValues a dictionary of filter values, e.g. { title: 'lorem', nationality: 'fr' }
* @param {Function} setFilters a callback to update the filters, e.g. setFilters(filters, displayedFilters)
* @param {Object} displayedFilters a dictionary of the displayed filters, e.g. { title: true, nationality: true }
* @param {Function} showFilter a callback to show one of the filters, e.g. showFilter('title', defaultValue)
* @param {Function} hideFilter a callback to hide one of the filters, e.g. hideFilter('title')
* @param {Array} selectedIds an array listing the ids of the selected rows, e.g. [123, 456]
* @param {Function} onSelect callback to change the list of selected rows, e.g. onSelect([456, 789])
* @param {Function} onToggleItem callback to toggle the selection of a given record based on its id, e.g. onToggleItem(456)
* @param {Function} onUnselectItems callback to clear the selection, e.g. onUnselectItems();
* @param {string} defaultTitle the translated title based on the resource, e.g. 'Posts'
* @param {string} resource the resource name, deduced from the location. e.g. 'posts'
* @param {Function} refetch a function for triggering a refetch of the list data
* @param {ListControllerResult} value
*
* @see useListController
* @see useListContext
Expand Down
19 changes: 9 additions & 10 deletions packages/ra-core/src/controller/list/ListFilterContext.tsx
Expand Up @@ -8,16 +8,15 @@ import { ListControllerResult } from './useListController';
* Use the useListFilterContext() hook to read the context. That's what many
* List components do in react-admin (e.g. <FilterForm>, <FilterListItem>).
*
* @typedef {Object} ListFilterContextValue
* @prop {Object} filterValues a dictionary of filter values, e.g. { title: 'lorem', nationality: 'fr' }
* @prop {Function} setFilters a callback to update the filters, e.g. setFilters(filters, displayedFilters)
* @prop {Object} displayedFilters a dictionary of the displayed filters, e.g. { title: true, nationality: true }
* @prop {Function} showFilter a callback to show one of the filters, e.g. showFilter('title', defaultValue)
* @prop {Function} hideFilter a callback to hide one of the filters, e.g. hideFilter('title')
* @prop {string} resource the resource name, deduced from the location. e.g. 'posts'
*
* @typedef Props
* @prop {ListFilterContextValue} value
* @param {Object} Props
* @param {Object} ListFilterContextValue
* @param {Object} filterValues a dictionary of filter values, e.g. { title: 'lorem', nationality: 'fr' }
* @param {Function} setFilters a callback to update the filters, e.g. setFilters(filters, displayedFilters)
* @param {Object} displayedFilters a dictionary of the displayed filters, e.g. { title: true, nationality: true }
* @param {Function} showFilter a callback to show one of the filters, e.g. showFilter('title', defaultValue)
* @param {Function} hideFilter a callback to hide one of the filters, e.g. hideFilter('title')
* @param {string} resource the resource name, deduced from the location. e.g. 'posts'
* @param {ListFilterContextValue} value
*
* @param {Props}
*
Expand Down
28 changes: 12 additions & 16 deletions packages/ra-core/src/controller/list/ListPaginationContext.tsx
Expand Up @@ -8,22 +8,18 @@ import { ListControllerResult } from './useListController';
* Use the useListPaginationContext() hook to read the pagination information.
* That's what List components do in react-admin (e.g. <Pagination>).
*
* @typedef {Object} ListPaginationContextValue
* @prop {boolean} isLoading boolean that is false until the data is available
* @prop {integer} total the total number of results for the current filters, excluding pagination. Useful to build the pagination controls. e.g. 23
* @prop {integer} page the current page. Starts at 1
* @prop {Function} setPage a callback to change the page, e.g. setPage(3)
* @prop {integer} perPage the number of results per page. Defaults to 25
* @prop {Function} setPerPage a callback to change the number of results per page, e.g. setPerPage(25)
* @prop {Boolean} hasPreviousPage true if the current page is not the first one
* @prop {Boolean} hasNextPage true if the current page is not the last one

* @prop {string} resource the resource name, deduced from the location. e.g. 'posts'
*
* @typedef Props
* @prop {ListPaginationContextValue} value
*
* @param {Props}
* @param {Props} Props
* @param {Object} ListPaginationContextValue
* @param {boolean} isLoading boolean that is false until the data is available
* @param {integer} total the total number of results for the current filters, excluding pagination. Useful to build the pagination controls. e.g. 23
* @param {integer} page the current page. Starts at 1
* @param {Function} setPage a callback to change the page, e.g. setPage(3)
* @param {integer} perPage the number of results per page. Defaults to 25
* @param {Function} setPerPage a callback to change the number of results per page, e.g. setPerPage(25)
* @param {Boolean} hasPreviousPage true if the current page is not the first one
* @param {Boolean} hasNextPage true if the current page is not the last one
* @param {string} resource the resource name, deduced from the location. e.g. 'posts'
* @param {ListPaginationContextValue} value
*
* @see useListController
* @see useListContext
Expand Down
15 changes: 6 additions & 9 deletions packages/ra-core/src/controller/list/ListSortContext.tsx
Expand Up @@ -8,15 +8,12 @@ import { ListControllerResult } from './useListController';
* Use the useListSortContext() hook to read the context. That's what many
* List components do in react-admin (e.g. <SortButton>).
*
* @typedef {Object} ListSortContextValue
* @prop {Object} sort a sort object { field, order }, e.g. { field: 'date', order: 'DESC' }
* @prop {Function} setSort a callback to change the sort, e.g. setSort({ field: 'name', order: 'ASC' })
* @prop {string} resource the resource name, deduced from the location. e.g. 'posts'
*
* @typedef Props
* @prop {ListSortContextValue} value
*
* @param {Props}
* @param {Props} Props
* @param {Object} ListSortContextValue
* @param {Object} sort a sort object { field, order }, e.g. { field: 'date', order: 'DESC' }
* @param {Function} setSort a callback to change the sort, e.g. setSort({ field: 'name', order: 'ASC' })
* @param {string} resource the resource name, deduced from the location. e.g. 'posts'
* @param {ListSortContextValue} value
*
* @see useListController
* @see useListSortContext
Expand Down
Expand Up @@ -11,9 +11,9 @@ import {
* Must be used within a <InfinitePaginationContext.Provider> (e.g. as a descendent of <InfiniteList>
* or <InfiniteListBase>).
*
* @typedef {Object} InfinitePaginationContextValue
* @prop {Function} fetchNextPage a callback to fetch the next page
* @prop {Function} fetchPreviousPage a callback to fetch the previous page
* @param {Object} InfinitePaginationContextValue
* @param {Function} fetchNextPage a callback to fetch the next page
* @param {Function} fetchPreviousPage a callback to fetch the previous page
*
* @returns {InfinitePaginationContextValue} infinite pagination callbacks
*
Expand Down
44 changes: 22 additions & 22 deletions packages/ra-core/src/controller/list/useListContext.ts
Expand Up @@ -16,28 +16,28 @@ import { RaRecord } from '../../types';
*
* The given props will take precedence over context values.
*
* @typedef {Object} ListControllerProps
* @prop {Object} data an array of the list records, e.g. [{ id: 123, title: 'hello world' }, { ... }]
* @prop {integer} total the total number of results for the current filters, excluding pagination. Useful to build the pagination controls. e.g. 23
* @prop {boolean} isFetching boolean that is true on mount, and false once the data was fetched
* @prop {boolean} isLoading boolean that is false until the data is available
* @prop {integer} page the current page. Starts at 1
* @prop {Function} setPage a callback to change the page, e.g. setPage(3)
* @prop {integer} perPage the number of results per page. Defaults to 25
* @prop {Function} setPerPage a callback to change the number of results per page, e.g. setPerPage(25)
* @prop {Object} sort a sort object { field, order }, e.g. { field: 'date', order: 'DESC' }
* @prop {Function} setSort a callback to change the sort, e.g. setSort({ field : 'name', order: 'ASC' })
* @prop {Object} filterValues a dictionary of filter values, e.g. { title: 'lorem', nationality: 'fr' }
* @prop {Function} setFilters a callback to update the filters, e.g. setFilters(filters, displayedFilters)
* @prop {Object} displayedFilters a dictionary of the displayed filters, e.g. { title: true, nationality: true }
* @prop {Function} showFilter a callback to show one of the filters, e.g. showFilter('title', defaultValue)
* @prop {Function} hideFilter a callback to hide one of the filters, e.g. hideFilter('title')
* @prop {Array} selectedIds an array listing the ids of the selected rows, e.g. [123, 456]
* @prop {Function} onSelect callback to change the list of selected rows, e.g. onSelect([456, 789])
* @prop {Function} onToggleItem callback to toggle the selection of a given record based on its id, e.g. onToggleItem(456)
* @prop {Function} onUnselectItems callback to clear the selection, e.g. onUnselectItems();
* @prop {string} defaultTitle the translated title based on the resource, e.g. 'Posts'
* @prop {string} resource the resource name, deduced from the location. e.g. 'posts'
* @param {Object} ListControllerProps
* @param {Object} data an array of the list records, e.g. [{ id: 123, title: 'hello world' }, { ... }]
* @param {integer} total the total number of results for the current filters, excluding pagination. Useful to build the pagination controls. e.g. 23
* @param {boolean} isFetching boolean that is true on mount, and false once the data was fetched
* @param {boolean} isLoading boolean that is false until the data is available
* @param {integer} page the current page. Starts at 1
* @param {Function} setPage a callback to change the page, e.g. setPage(3)
* @param {integer} perPage the number of results per page. Defaults to 25
* @param {Function} setPerPage a callback to change the number of results per page, e.g. setPerPage(25)
* @param {Object} sort a sort object { field, order }, e.g. { field: 'date', order: 'DESC' }
* @param {Function} setSort a callback to change the sort, e.g. setSort({ field : 'name', order: 'ASC' })
* @param {Object} filterValues a dictionary of filter values, e.g. { title: 'lorem', nationality: 'fr' }
* @param {Function} setFilters a callback to update the filters, e.g. setFilters(filters, displayedFilters)
* @param {Object} displayedFilters a dictionary of the displayed filters, e.g. { title: true, nationality: true }
* @param {Function} showFilter a callback to show one of the filters, e.g. showFilter('title', defaultValue)
* @param {Function} hideFilter a callback to hide one of the filters, e.g. hideFilter('title')
* @param {Array} selectedIds an array listing the ids of the selected rows, e.g. [123, 456]
* @param {Function} onSelect callback to change the list of selected rows, e.g. onSelect([456, 789])
* @param {Function} onToggleItem callback to toggle the selection of a given record based on its id, e.g. onToggleItem(456)
* @param {Function} onUnselectItems callback to clear the selection, e.g. onUnselectItems();
* @param {string} defaultTitle the translated title based on the resource, e.g. 'Posts'
* @param {string} resource the resource name, deduced from the location. e.g. 'posts'
*
* @returns {ListControllerResult} list controller props
*
Expand Down
14 changes: 7 additions & 7 deletions packages/ra-core/src/controller/list/useListFilterContext.ts
Expand Up @@ -8,13 +8,13 @@ import { ListFilterContext, ListFilterContextValue } from './ListFilterContext';
* Must be used within a <ListContextProvider> (e.g. as a descendent of <List>
* or <ListBase>).
*
* @typedef {Object} ListFilterContextValue
* @prop {Object} filterValues a dictionary of filter values, e.g. { title: 'lorem', nationality: 'fr' }
* @prop {Function} setFilters a callback to update the filters, e.g. setFilters(filters, displayedFilters)
* @prop {Object} displayedFilters a dictionary of the displayed filters, e.g. { title: true, nationality: true }
* @prop {Function} showFilter a callback to show one of the filters, e.g. showFilter('title', defaultValue)
* @prop {Function} hideFilter a callback to hide one of the filters, e.g. hideFilter('title')
* @prop {string} resource the resource name, deduced from the location. e.g. 'posts'
* @param {Object} ListFilterContextValue
* @param {Object} filterValues a dictionary of filter values, e.g. { title: 'lorem', nationality: 'fr' }
* @param {Function} setFilters a callback to update the filters, e.g. setFilters(filters, displayedFilters)
* @param {Object} displayedFilters a dictionary of the displayed filters, e.g. { title: true, nationality: true }
* @param {Function} showFilter a callback to show one of the filters, e.g. showFilter('title', defaultValue)
* @param {Function} hideFilter a callback to hide one of the filters, e.g. hideFilter('title')
* @param {string} resource the resource name, deduced from the location. e.g. 'posts'
*
* @returns {ListFilterContextValue} list controller props
*
Expand Down