A simple React library for managing table filters and pagination through the URL
npm install react-use-table-query-paramsA simple React library for managing filtering and pagination through the URL
``typescript
useTableQueryParams(args: UseTableQueryParamsArgs<
QKey extends string,
QObj extends Partial
FObj extends Record
OKey extends string,
ODirection extends OrderDirection>
) => UseTableQueryParamsResponse
interface UseTableQueryParamsResponse<
QKey extends string,
QObj extends Partial
FObj extends Record
OKey extends string,
ODirection extends OrderDirection,
> extends UsePaginationParamsResponse {
filtersForRequest: QObj,
filtersForRender: FObj,
onSubmitFilters: (data: FObj) => void,
clearFilters: () => void,
changeOrder: (key: OKey) => void,
orderBy: Optional
orderDirection: Optional
offset?: number,
limit?: number,
}
`usePaginationParams
Parameter extends from parameters of
| Parameter | Type | Required? | Description |
|-------------------------------|--------------------------------------------------------|-----------|------------------------------------------------------------------------|
| keys | QKey[] | required | List of keys, which be used for filters |parseFiltersForRequest
| | (params: URLSearchParams) => QObj | required | Function which for convert URLSearchParams to object for request |prepareFiltersForComponents
| | (params: URLSearchParams) => FObj | required | Function which for convert URLSearchParams to object for filters in UI |beforeSubmit
| | (data: FObj) => QObj | required | Function which for convert filter object to object for URL |validateOrderBy
| | validateOrderBy: (params: string) => Optional | required | Function which for validate orderKey |defaultOrderKey
| | defaultOrderKey?: OKey | optional | Default order key |defaultParams
| | defaultParams?: QObj | optional | Default object for URLSearchParams |defaultDirection
| | defaultDirection?: ODirection | optional | Default order direction |limit
| | number | optional | Default limit |offset
| | number` | optional | Default offset |