react-instantsearch-hooks
Advanced tools
Comparing version 6.15.0 to 6.16.0
@@ -90,2 +90,30 @@ "use strict"; | ||
var _useHierarchicalMenu = require("./useHierarchicalMenu"); | ||
Object.keys(_useHierarchicalMenu).forEach(function (key) { | ||
if (key === "default" || key === "__esModule") return; | ||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; | ||
if (key in exports && exports[key] === _useHierarchicalMenu[key]) return; | ||
Object.defineProperty(exports, key, { | ||
enumerable: true, | ||
get: function get() { | ||
return _useHierarchicalMenu[key]; | ||
} | ||
}); | ||
}); | ||
var _usePagination = require("./usePagination"); | ||
Object.keys(_usePagination).forEach(function (key) { | ||
if (key === "default" || key === "__esModule") return; | ||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; | ||
if (key in exports && exports[key] === _usePagination[key]) return; | ||
Object.defineProperty(exports, key, { | ||
enumerable: true, | ||
get: function get() { | ||
return _usePagination[key]; | ||
} | ||
}); | ||
}); | ||
var _useRefinementList = require("./useRefinementList"); | ||
@@ -117,2 +145,16 @@ | ||
}); | ||
}); | ||
var _useSortBy = require("./useSortBy"); | ||
Object.keys(_useSortBy).forEach(function (key) { | ||
if (key === "default" || key === "__esModule") return; | ||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; | ||
if (key in exports && exports[key] === _useSortBy[key]) return; | ||
Object.defineProperty(exports, key, { | ||
enumerable: true, | ||
get: function get() { | ||
return _useSortBy[key]; | ||
} | ||
}); | ||
}); |
@@ -7,3 +7,3 @@ "use strict"; | ||
exports.default = void 0; | ||
var _default = '6.15.0'; | ||
var _default = '6.16.0'; | ||
exports.default = _default; |
@@ -7,3 +7,6 @@ export { default as version } from './version'; | ||
export * from './useHits'; | ||
export * from './useHierarchicalMenu'; | ||
export * from './usePagination'; | ||
export * from './useRefinementList'; | ||
export * from './useSearchBox'; | ||
export * from './useSortBy'; |
@@ -7,3 +7,6 @@ export { default as version } from './version'; | ||
export * from './useHits'; | ||
export * from './useHierarchicalMenu'; | ||
export * from './usePagination'; | ||
export * from './useRefinementList'; | ||
export * from './useSearchBox'; | ||
export * from './useSearchBox'; | ||
export * from './useSortBy'; |
@@ -1,2 +0,2 @@ | ||
declare const _default: "6.15.0"; | ||
declare const _default: "6.16.0"; | ||
export default _default; |
@@ -1,1 +0,1 @@ | ||
export default '6.15.0'; | ||
export default '6.16.0'; |
{ | ||
"name": "react-instantsearch-hooks", | ||
"version": "6.15.0", | ||
"version": "6.16.0", | ||
"description": "⚡ Lightning-fast search for React, by Algolia", | ||
@@ -5,0 +5,0 @@ "source": "src/index.ts", |
233
README.md
@@ -471,2 +471,149 @@ # react-instantsearch-hooks | ||
### `useHierarchicalMenu` | ||
> `(props: UseHierarchicalMenuProps) => HierarchicalMenuRenderState` | ||
Hook to use a [hierarchical menu](https://www.algolia.com/doc/api-reference/widgets/hierarchical-menu/js/). | ||
**Types** | ||
<details> | ||
<summary><code>UseHierarchicalMenuProps</code></summary> | ||
```ts | ||
type UseHierarchicalMenuProps = { | ||
/** | ||
* The name of the attributes in the records. | ||
*/ | ||
attributes: string[]; | ||
/** | ||
* Separator used in the attributes to separate level values. | ||
*/ | ||
separator?: string; | ||
/** | ||
* Prefix path to use if the first level is not the root level. | ||
*/ | ||
rootPath?: string | null; | ||
/** | ||
* Show the siblings of the selected parent levels of the current refined value. This | ||
* does not impact the root level. | ||
*/ | ||
showParentLevel?: boolean; | ||
/** | ||
* The max number of items to display when | ||
* `showMoreLimit` is not set or if the widget is showing less value. | ||
*/ | ||
limit?: number; | ||
/** | ||
* Whether to display a button that expands the number of items. | ||
*/ | ||
showMore?: boolean; | ||
/** | ||
* The max number of items to display if the widget | ||
* is showing more items. | ||
*/ | ||
showMoreLimit?: number; | ||
/** | ||
* How to sort refinements. Possible values: `count|isRefined|name:asc|name:desc`. | ||
* | ||
* You can also use a sort function that behaves like the standard Javascript [compareFunction](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#Syntax). | ||
* | ||
* If a facetOrdering is set in the index settings, it is used when sortBy isn't passed | ||
*/ | ||
sortBy?: SortBy<HierarchicalMenuItem>; | ||
/** | ||
* Function to transform the items passed to the templates. | ||
*/ | ||
transformItems?: TransformItems<HierarchicalMenuItem>; | ||
}; | ||
``` | ||
</details> | ||
<details> | ||
<summary><code>HierarchicalMenuRenderState</code></summary> | ||
```ts | ||
export type HierarchicalMenuItem = { | ||
/** | ||
* The value of the refinement list item. | ||
*/ | ||
value: string; | ||
/** | ||
* Human-readable value of the refinement list item. | ||
*/ | ||
label: string; | ||
/** | ||
* Human-readable value of the searched refinement list item. | ||
*/ | ||
highlighted?: string; | ||
/** | ||
* Number of matched results after refinement is applied. | ||
*/ | ||
count: number; | ||
/** | ||
* Indicates if the list item is refined. | ||
*/ | ||
isRefined: boolean; | ||
/** | ||
* n+1 level of items, same structure HierarchicalMenuItem | ||
*/ | ||
data: HierarchicalMenuItem[] | null; | ||
}; | ||
type HierarchicalMenuRenderState = { | ||
/** | ||
* The list of filtering values returned from Algolia API. | ||
*/ | ||
items: HierarchicalMenuItem[]; | ||
/** | ||
* Creates the next state url for a selected refinement. | ||
*/ | ||
createURL: (value: string) => string; | ||
/** | ||
* Action to apply selected refinements. | ||
*/ | ||
refine(value: string): void; | ||
/** | ||
* Send event to insights middleware | ||
*/ | ||
sendEvent: ( | ||
eventType: string, | ||
facetValue: string, | ||
eventName?: string | ||
) => void; | ||
/** | ||
* `true` if a refinement can be applied. | ||
*/ | ||
canRefine: boolean; | ||
/** | ||
* `true` if the toggleShowMore button can be activated (enough items to display more or | ||
* already displaying more than `limit` items) | ||
*/ | ||
canToggleShowMore: boolean; | ||
/** | ||
* True if the menu is displaying all the menu items. | ||
*/ | ||
isShowingMore: boolean; | ||
/** | ||
* Toggles the number of values displayed between `limit` and `showMoreLimit`. | ||
*/ | ||
toggleShowMore: () => void; | ||
}; | ||
``` | ||
</details> | ||
**Example** | ||
```jsx | ||
function HierarchicalMenu(props) { | ||
const { items } = useHierarchicalMenu(props); | ||
return { | ||
/* Markup */ | ||
}; | ||
} | ||
``` | ||
### `useRefinementList` | ||
@@ -622,2 +769,88 @@ | ||
### `useSortBy` | ||
> `(props: UseSortByProps) => SortByRenderState` | ||
Hook to [sort by](https://www.algolia.com/doc/api-reference/widgets/sort-by/js/) specified indices. | ||
**Types** | ||
<details> | ||
<summary><code>SortByItem</code></summary> | ||
```ts | ||
type SortByItem = { | ||
/** | ||
* The name of the index to target. | ||
*/ | ||
value: string; | ||
/** | ||
* The label of the index to display. | ||
*/ | ||
label: string; | ||
}; | ||
``` | ||
</details> | ||
<details> | ||
<summary><code>UseSortByProps</code></summary> | ||
```ts | ||
type UseSortByProps = { | ||
/** | ||
* Array of objects defining the different indices to choose from. | ||
*/ | ||
items: SortByItem[]; | ||
/** | ||
* Function to transform the items passed to the templates. | ||
*/ | ||
transformItems?: TransformItems<SortByItem>; | ||
}; | ||
``` | ||
</details> | ||
<details> | ||
<summary><code>SortByRenderState</code></summary> | ||
```ts | ||
type SortByRenderState = { | ||
/** | ||
* The initially selected index. | ||
*/ | ||
initialIndex?: string; | ||
/** | ||
* The currently selected index. | ||
*/ | ||
currentRefinement: string; | ||
/** | ||
* All the available indices | ||
*/ | ||
options: SortByItem[]; | ||
/** | ||
* Switches indices and triggers a new search. | ||
*/ | ||
refine: (value: string) => void; | ||
/** | ||
* `true` if the last search contains no result. | ||
*/ | ||
hasNoResults: boolean; | ||
}; | ||
``` | ||
</details> | ||
**Example** | ||
```jsx | ||
function SortBy(props) { | ||
const { currentRefinement, options, refine } = useSortBy(props); | ||
return { | ||
/* Markup */ | ||
}; | ||
} | ||
``` | ||
### `useConnector` | ||
@@ -624,0 +857,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1857390
81
10629
889