WooCommerce navigation utilities.
npm install @woocommerce/navigationA collection of navigation-related functions for handling query parameter objects, serializing query parameters, updating query parameters, and triggering path changes.
Install the module
``bash`
pnpm install @woocommerce/navigation --save
A single history object used to perform path changes. This needs to be passed into ReactRouter to use the other path functions from this library.
`jsx
import { getHistory } from '@woocommerce/navigation';
render() {
return (
…
);
}
`
Returns: String - Current path.
Returns: Object - Object containing the time related queries.
| Param | Type | Description |
| --- | --- | --- |
| query | Object | Query containing the parameters. |
Returns: Array - List of IDs converted to an array of unique integers.
| Param | Type | Description |
| --- | --- | --- |
| queryString | string | string value extracted from URL. |
Returns: String - Updated URL merging query params into existing params.
| Param | Type | Description |
| --- | --- | --- |
| query | Object | object of params to be updated. |
| path | String | Relative path (defaults to current path). |
| currentQuery | Object | object of current query params (defaults to current querystring). |
Returns: Object - Current query object, defaults to empty object.
Returns: function - A callback which will update
param to the passed value when called.| Param | Type | Description |
| --- | --- | --- |
| param | string | The parameter in the querystring which should be updated (ex
page, per_page`) |string | Relative path (defaults to current path). |string | object of current query params (defaults to current querystring). || Param | Type | Description |
| --- | --- | --- |
| query | Object | object of params to be updated. |
| path | String | Relative path (defaults to current path). |
| currentQuery | Object | object of current query params (defaults to current querystring). |
Returns: Array - Flattened array of all filters.
| Param | Type | Description |
| --- | --- | --- |
| filters | Array | Set of filters with possible subfilters. |
Returns: Array.<activeFilters> - - array of activeFilters
| Param | Type | Description |
| --- | --- | --- |
| query | object | query oject |
| config | object | config object |
defaultOption is provided.Returns: string \| undefined - - the value of the default option.
| Param | Type | Description |
| --- | --- | --- |
| config | object | a filter config object. |
| options | array | select options. |
Returns: object - - query object representing the new parameters
| Param | Type | Description |
| --- | --- | --- |
| activeFilters | Array.<activeFilters> | activeFilters shown in the UI |
| query | object | the current url query object |
| config | object | config object |
Returns: string - - url query key.
| Param | Type | Description |
| --- | --- | --- |
| key | string | filter key. |
| rule | string | filter rule. |
Properties
| Name | Type | Description |
| --- | --- | --- |
| key | string | filter key. |
| [rule] | string | a modifying rule for a filter, eg 'includes' or 'is_not'. |
| value | string | filter value(s). |