instantsearch.js 4.45.1 → 4.46.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (230) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/cjs/components/Hits/Hits.js +3 -1
  3. package/cjs/components/InfiniteHits/InfiniteHits.js +3 -1
  4. package/cjs/components/Template/Template.js +13 -3
  5. package/cjs/connectors/toggle-refinement/connectToggleRefinement.js +3 -1
  6. package/cjs/helpers/components/Highlight.js +7 -7
  7. package/cjs/helpers/components/ReverseHighlight.js +7 -7
  8. package/cjs/helpers/components/ReverseSnippet.js +7 -7
  9. package/cjs/helpers/components/Snippet.js +7 -7
  10. package/cjs/lib/InstantSearch.js +33 -24
  11. package/cjs/lib/createHelpers.js +3 -1
  12. package/cjs/lib/formatNumber.js +10 -0
  13. package/cjs/lib/utils/capitalize.js +2 -5
  14. package/cjs/lib/utils/checkIndexUiState.js +3 -5
  15. package/cjs/lib/utils/checkRendering.js +4 -9
  16. package/cjs/lib/utils/clearRefinements.js +3 -9
  17. package/cjs/lib/utils/concatHighlightedParts.js +1 -1
  18. package/cjs/lib/utils/createSendEventForFacet.js +2 -4
  19. package/cjs/lib/utils/cx.js +10 -0
  20. package/cjs/lib/utils/defer.js +3 -6
  21. package/cjs/lib/utils/detect-insights-client.js +1 -1
  22. package/cjs/lib/utils/documentation.js +6 -9
  23. package/cjs/lib/utils/escape-highlight.js +4 -6
  24. package/cjs/lib/utils/escape-html.js +60 -0
  25. package/cjs/lib/utils/find.js +2 -5
  26. package/cjs/lib/utils/findIndex.js +2 -5
  27. package/cjs/lib/utils/getContainerNode.js +4 -9
  28. package/cjs/lib/utils/getHighlightFromSiblings.js +3 -5
  29. package/cjs/lib/utils/getHighlightedParts.js +1 -1
  30. package/cjs/lib/utils/getObjectType.js +2 -5
  31. package/cjs/lib/utils/getPropertyByPath.js +2 -5
  32. package/cjs/lib/utils/getRefinements.js +4 -6
  33. package/cjs/lib/utils/index.js +563 -432
  34. package/cjs/lib/utils/isDomElement.js +2 -5
  35. package/cjs/lib/utils/isEqual.js +2 -5
  36. package/cjs/lib/utils/isFacetRefined.js +1 -1
  37. package/cjs/lib/utils/isFiniteNumber.js +3 -5
  38. package/cjs/lib/utils/isIndexWidget.js +10 -0
  39. package/cjs/lib/utils/isPlainObject.js +2 -5
  40. package/cjs/lib/utils/isSpecialClick.js +2 -5
  41. package/cjs/lib/utils/logger.js +3 -5
  42. package/cjs/lib/utils/mergeSearchParameters.js +7 -10
  43. package/cjs/lib/utils/noop.js +2 -5
  44. package/cjs/lib/utils/prepareTemplateProps.js +4 -9
  45. package/cjs/lib/utils/range.js +2 -5
  46. package/cjs/lib/utils/renderTemplate.js +19 -7
  47. package/cjs/lib/utils/resolveSearchParameters.js +3 -6
  48. package/cjs/lib/utils/reverseHighlightedParts.js +3 -5
  49. package/cjs/lib/utils/setIndexHelperState.js +28 -0
  50. package/cjs/lib/utils/toArray.js +2 -5
  51. package/cjs/lib/utils/uniq.js +2 -5
  52. package/cjs/lib/version.js +1 -1
  53. package/cjs/middlewares/createInsightsMiddleware.js +23 -30
  54. package/cjs/middlewares/createMetadataMiddleware.js +1 -0
  55. package/cjs/middlewares/createRouterMiddleware.js +1 -0
  56. package/cjs/widgets/answers/defaultTemplates.js +6 -2
  57. package/cjs/widgets/breadcrumb/defaultTemplates.js +6 -2
  58. package/cjs/widgets/clear-refinements/defaultTemplates.js +3 -1
  59. package/cjs/widgets/geo-search/createHTMLMarker.js +10 -4
  60. package/cjs/widgets/geo-search/defaultTemplates.js +18 -4
  61. package/cjs/widgets/hierarchical-menu/defaultTemplates.js +26 -2
  62. package/cjs/widgets/hits/defaultTemplates.js +3 -1
  63. package/cjs/widgets/index/index.js +8 -12
  64. package/cjs/widgets/infinite-hits/defaultTemplates.js +9 -3
  65. package/cjs/widgets/menu/defaultTemplates.js +26 -2
  66. package/cjs/widgets/menu-select/defaultTemplates.js +11 -2
  67. package/cjs/widgets/numeric-menu/defaultTemplates.js +20 -1
  68. package/cjs/widgets/range-input/range-input.js +6 -2
  69. package/cjs/widgets/rating-menu/defaultTemplates.js +57 -1
  70. package/cjs/widgets/refinement-list/defaultTemplates.js +38 -3
  71. package/cjs/widgets/relevant-sort/defaultTemplates.js +3 -1
  72. package/cjs/widgets/search-box/defaultTemplates.js +62 -3
  73. package/cjs/widgets/stats/stats.js +70 -22
  74. package/cjs/widgets/toggle-refinement/defaultTemplates.js +4 -1
  75. package/cjs/widgets/voice-search/defaultTemplates.js +81 -9
  76. package/dist/instantsearch.development.d.ts +153 -22
  77. package/dist/instantsearch.development.js +2842 -2112
  78. package/dist/instantsearch.development.js.map +1 -1
  79. package/dist/instantsearch.production.d.ts +153 -22
  80. package/dist/instantsearch.production.min.d.ts +153 -22
  81. package/dist/instantsearch.production.min.js +2 -2
  82. package/dist/instantsearch.production.min.js.map +1 -1
  83. package/es/components/Breadcrumb/Breadcrumb.d.ts +1 -1
  84. package/es/components/ClearRefinements/ClearRefinements.d.ts +1 -1
  85. package/es/components/GeoSearchControls/GeoSearchControls.d.ts +1 -1
  86. package/es/components/Hits/Hits.d.ts +2 -3
  87. package/es/components/Hits/Hits.js +3 -1
  88. package/es/components/InfiniteHits/InfiniteHits.d.ts +1 -1
  89. package/es/components/InfiniteHits/InfiniteHits.js +3 -1
  90. package/es/components/RefinementList/RefinementList.d.ts +1 -1
  91. package/es/components/Template/Template.d.ts +4 -3
  92. package/es/components/Template/Template.js +14 -4
  93. package/es/components/ToggleRefinement/ToggleRefinement.d.ts +1 -4
  94. package/es/components/ToggleRefinement/ToggleRefinement.js +0 -4
  95. package/es/connectors/toggle-refinement/connectToggleRefinement.d.ts +3 -2
  96. package/es/connectors/toggle-refinement/connectToggleRefinement.js +3 -1
  97. package/es/helpers/components/Highlight.js +7 -5
  98. package/es/helpers/components/ReverseHighlight.js +7 -5
  99. package/es/helpers/components/ReverseSnippet.js +7 -5
  100. package/es/helpers/components/Snippet.js +7 -5
  101. package/es/lib/InstantSearch.d.ts +6 -1
  102. package/es/lib/InstantSearch.js +34 -21
  103. package/es/lib/createHelpers.js +2 -1
  104. package/es/lib/formatNumber.d.ts +1 -0
  105. package/es/lib/formatNumber.js +3 -0
  106. package/es/lib/utils/capitalize.d.ts +1 -2
  107. package/es/lib/utils/capitalize.js +2 -4
  108. package/es/lib/utils/checkIndexUiState.js +1 -1
  109. package/es/lib/utils/checkRendering.d.ts +1 -2
  110. package/es/lib/utils/checkRendering.js +3 -6
  111. package/es/lib/utils/clearRefinements.d.ts +4 -8
  112. package/es/lib/utils/clearRefinements.js +3 -8
  113. package/es/lib/utils/concatHighlightedParts.d.ts +1 -1
  114. package/es/lib/utils/concatHighlightedParts.js +1 -1
  115. package/es/lib/utils/createSendEventForFacet.js +1 -1
  116. package/es/lib/utils/createSendEventForHits.d.ts +0 -3
  117. package/es/lib/utils/createSendEventForHits.js +0 -3
  118. package/es/lib/utils/cx.d.ts +1 -0
  119. package/es/lib/utils/cx.js +3 -0
  120. package/es/lib/utils/defer.d.ts +2 -2
  121. package/es/lib/utils/defer.js +2 -5
  122. package/es/lib/utils/detect-insights-client.d.ts +1 -1
  123. package/es/lib/utils/detect-insights-client.js +1 -1
  124. package/es/lib/utils/documentation.d.ts +2 -2
  125. package/es/lib/utils/documentation.js +4 -4
  126. package/es/lib/utils/escape-highlight.js +2 -2
  127. package/es/lib/utils/{escape.d.ts → escape-html.d.ts} +6 -2
  128. package/es/lib/utils/escape-html.js +51 -0
  129. package/es/lib/utils/escapeFacetValue.d.ts +1 -1
  130. package/es/lib/utils/find.d.ts +1 -2
  131. package/es/lib/utils/find.js +2 -4
  132. package/es/lib/utils/findIndex.d.ts +1 -2
  133. package/es/lib/utils/findIndex.js +2 -4
  134. package/es/lib/utils/getContainerNode.d.ts +1 -2
  135. package/es/lib/utils/getContainerNode.js +3 -5
  136. package/es/lib/utils/getHighlightFromSiblings.d.ts +1 -1
  137. package/es/lib/utils/getHighlightFromSiblings.js +2 -2
  138. package/es/lib/utils/getHighlightedParts.d.ts +1 -1
  139. package/es/lib/utils/getHighlightedParts.js +1 -1
  140. package/es/lib/utils/getObjectType.d.ts +1 -2
  141. package/es/lib/utils/getObjectType.js +2 -4
  142. package/es/lib/utils/getPropertyByPath.d.ts +1 -2
  143. package/es/lib/utils/getPropertyByPath.js +2 -4
  144. package/es/lib/utils/getRefinements.d.ts +1 -1
  145. package/es/lib/utils/getRefinements.js +2 -2
  146. package/es/lib/utils/index.d.ts +46 -45
  147. package/es/lib/utils/index.js +46 -45
  148. package/es/lib/utils/isDomElement.d.ts +1 -2
  149. package/es/lib/utils/isDomElement.js +2 -4
  150. package/es/lib/utils/isEqual.d.ts +1 -2
  151. package/es/lib/utils/isEqual.js +2 -4
  152. package/es/lib/utils/isFacetRefined.d.ts +1 -1
  153. package/es/lib/utils/isFacetRefined.js +1 -1
  154. package/es/lib/utils/isFiniteNumber.d.ts +1 -2
  155. package/es/lib/utils/isFiniteNumber.js +3 -4
  156. package/es/lib/utils/isIndexWidget.d.ts +3 -0
  157. package/es/lib/utils/isIndexWidget.js +3 -0
  158. package/es/lib/utils/isPlainObject.d.ts +1 -2
  159. package/es/lib/utils/isPlainObject.js +2 -4
  160. package/es/lib/utils/isSpecialClick.d.ts +1 -2
  161. package/es/lib/utils/isSpecialClick.js +2 -4
  162. package/es/lib/utils/logger.js +1 -1
  163. package/es/lib/utils/mergeSearchParameters.d.ts +1 -2
  164. package/es/lib/utils/mergeSearchParameters.js +4 -6
  165. package/es/lib/utils/noop.d.ts +1 -2
  166. package/es/lib/utils/noop.js +1 -3
  167. package/es/lib/utils/prepareTemplateProps.d.ts +2 -2
  168. package/es/lib/utils/prepareTemplateProps.js +3 -5
  169. package/es/lib/utils/range.d.ts +2 -2
  170. package/es/lib/utils/range.js +2 -4
  171. package/es/lib/utils/renderTemplate.d.ts +4 -4
  172. package/es/lib/utils/renderTemplate.js +17 -6
  173. package/es/lib/utils/resolveSearchParameters.d.ts +1 -2
  174. package/es/lib/utils/resolveSearchParameters.js +2 -4
  175. package/es/lib/utils/reverseHighlightedParts.d.ts +1 -1
  176. package/es/lib/utils/reverseHighlightedParts.js +2 -2
  177. package/es/lib/utils/setIndexHelperState.d.ts +3 -0
  178. package/es/lib/utils/setIndexHelperState.js +19 -0
  179. package/es/lib/utils/toArray.d.ts +3 -2
  180. package/es/lib/utils/toArray.js +2 -4
  181. package/es/lib/utils/uniq.d.ts +1 -2
  182. package/es/lib/utils/uniq.js +2 -4
  183. package/es/lib/version.d.ts +1 -1
  184. package/es/lib/version.js +1 -1
  185. package/es/middlewares/createInsightsMiddleware.js +23 -27
  186. package/es/middlewares/createMetadataMiddleware.js +1 -0
  187. package/es/middlewares/createRouterMiddleware.js +1 -0
  188. package/es/types/middleware.d.ts +1 -0
  189. package/es/types/templates.d.ts +16 -3
  190. package/es/widgets/answers/defaultTemplates.js +6 -2
  191. package/es/widgets/breadcrumb/defaultTemplates.js +6 -2
  192. package/es/widgets/clear-refinements/clear-refinements.d.ts +3 -1
  193. package/es/widgets/clear-refinements/defaultTemplates.js +3 -1
  194. package/es/widgets/geo-search/createHTMLMarker.d.ts +2 -1
  195. package/es/widgets/geo-search/createHTMLMarker.js +8 -1
  196. package/es/widgets/geo-search/defaultTemplates.d.ts +1 -0
  197. package/es/widgets/geo-search/defaultTemplates.js +17 -4
  198. package/es/widgets/hierarchical-menu/defaultTemplates.js +22 -2
  199. package/es/widgets/hierarchical-menu/hierarchical-menu.d.ts +2 -0
  200. package/es/widgets/hits/defaultTemplates.js +3 -1
  201. package/es/widgets/hits/hits.d.ts +2 -1
  202. package/es/widgets/index/index.d.ts +0 -1
  203. package/es/widgets/index/index.js +5 -6
  204. package/es/widgets/infinite-hits/defaultTemplates.js +9 -3
  205. package/es/widgets/infinite-hits/infinite-hits.d.ts +1 -3
  206. package/es/widgets/menu/defaultTemplates.js +22 -2
  207. package/es/widgets/menu-select/defaultTemplates.js +9 -2
  208. package/es/widgets/numeric-menu/defaultTemplates.js +18 -1
  209. package/es/widgets/range-input/range-input.js +6 -2
  210. package/es/widgets/rating-menu/defaultTemplates.js +54 -1
  211. package/es/widgets/rating-menu/rating-menu.d.ts +6 -0
  212. package/es/widgets/refinement-list/defaultTemplates.js +34 -3
  213. package/es/widgets/refinement-list/refinement-list.d.ts +7 -1
  214. package/es/widgets/relevant-sort/defaultTemplates.js +3 -1
  215. package/es/widgets/search-box/defaultTemplates.js +61 -3
  216. package/es/widgets/search-box/search-box.d.ts +10 -3
  217. package/es/widgets/stats/stats.d.ts +10 -6
  218. package/es/widgets/stats/stats.js +69 -22
  219. package/es/widgets/toggle-refinement/defaultTemplates.js +4 -1
  220. package/es/widgets/toggle-refinement/toggle-refinement.d.ts +3 -1
  221. package/es/widgets/voice-search/defaultTemplates.js +81 -9
  222. package/package.json +8 -7
  223. package/cjs/lib/utils/convertNumericRefinementsToFilters.js +0 -31
  224. package/cjs/lib/utils/escape.js +0 -35
  225. package/cjs/lib/utils/unescape.js +0 -32
  226. package/es/lib/utils/convertNumericRefinementsToFilters.d.ts +0 -2
  227. package/es/lib/utils/convertNumericRefinementsToFilters.js +0 -24
  228. package/es/lib/utils/escape.js +0 -27
  229. package/es/lib/utils/unescape.d.ts +0 -9
  230. package/es/lib/utils/unescape.js +0 -25
@@ -5,22 +5,94 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
- var getButtonInnerElement = function getButtonInnerElement(status, errorCode, isListening) {
8
+ var _preact = require("preact");
9
+
10
+ /** @jsx h */
11
+ var _ref2 = (0, _preact.h)(_preact.Fragment, null, (0, _preact.h)("line", {
12
+ x1: "1",
13
+ y1: "1",
14
+ x2: "23",
15
+ y2: "23"
16
+ }), (0, _preact.h)("path", {
17
+ d: "M9 9v3a3 3 0 0 0 5.12 2.12M15 9.34V4a3 3 0 0 0-5.94-.6"
18
+ }), (0, _preact.h)("path", {
19
+ d: "M17 16.95A7 7 0 0 1 5 12v-2m14 0v2a7 7 0 0 1-.11 1.23"
20
+ }), (0, _preact.h)("line", {
21
+ x1: "12",
22
+ y1: "19",
23
+ x2: "12",
24
+ y2: "23"
25
+ }), (0, _preact.h)("line", {
26
+ x1: "8",
27
+ y1: "23",
28
+ x2: "16",
29
+ y2: "23"
30
+ }));
31
+
32
+ var _ref3 = (0, _preact.h)("path", {
33
+ d: "M19 10v2a7 7 0 0 1-14 0v-2"
34
+ });
35
+
36
+ var _ref4 = (0, _preact.h)("line", {
37
+ x1: "12",
38
+ y1: "19",
39
+ x2: "12",
40
+ y2: "23"
41
+ });
42
+
43
+ var _ref5 = (0, _preact.h)("line", {
44
+ x1: "8",
45
+ y1: "23",
46
+ x2: "16",
47
+ y2: "23"
48
+ });
49
+
50
+ var ButtonInnerElement = function ButtonInnerElement(_ref) {
51
+ var status = _ref.status,
52
+ errorCode = _ref.errorCode,
53
+ isListening = _ref.isListening;
54
+
9
55
  if (status === 'error' && errorCode === 'not-allowed') {
10
- return "<line x1=\"1\" y1=\"1\" x2=\"23\" y2=\"23\"></line>\n <path d=\"M9 9v3a3 3 0 0 0 5.12 2.12M15 9.34V4a3 3 0 0 0-5.94-.6\"></path>\n <path d=\"M17 16.95A7 7 0 0 1 5 12v-2m14 0v2a7 7 0 0 1-.11 1.23\"></path>\n <line x1=\"12\" y1=\"19\" x2=\"12\" y2=\"23\"></line>\n <line x1=\"8\" y1=\"23\" x2=\"16\" y2=\"23\"></line>";
56
+ return _ref2;
11
57
  }
12
58
 
13
- return "<path\n d=\"M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z\"\n fill=\"".concat(isListening ? 'currentColor' : 'none', "\">\n </path>\n <path d=\"M19 10v2a7 7 0 0 1-14 0v-2\"></path>\n <line x1=\"12\" y1=\"19\" x2=\"12\" y2=\"23\"></line>\n <line x1=\"8\" y1=\"23\" x2=\"16\" y2=\"23\"></line>");
59
+ return (0, _preact.h)(_preact.Fragment, null, (0, _preact.h)("path", {
60
+ d: "M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z",
61
+ fill: isListening ? 'currentColor' : 'none'
62
+ }), _ref3, _ref4, _ref5);
14
63
  };
15
64
 
16
65
  var defaultTemplates = {
17
- buttonText: function buttonText(_ref) {
18
- var status = _ref.status,
19
- errorCode = _ref.errorCode,
20
- isListening = _ref.isListening;
21
- return "<svg\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n >\n ".concat(getButtonInnerElement(status, errorCode, isListening), "\n </svg>");
66
+ buttonText: function buttonText(_ref6) {
67
+ var status = _ref6.status,
68
+ errorCode = _ref6.errorCode,
69
+ isListening = _ref6.isListening;
70
+ return (0, _preact.h)("svg", {
71
+ width: "16",
72
+ height: "16",
73
+ viewBox: "0 0 24 24",
74
+ fill: "none",
75
+ stroke: "currentColor"
76
+ /* eslint-disable react/no-unknown-property */
77
+ // Preact supports kebab case attributes, and using camel case would
78
+ // require using `preact/compat`.
79
+ // @TODO: reconsider using the `react` ESLint preset
80
+ ,
81
+ "stroke-width": "2",
82
+ "stroke-linecap": "round",
83
+ "stroke-linejoin": "round"
84
+ /* eslint-enable react/no-unknown-property */
85
+
86
+ }, (0, _preact.h)(ButtonInnerElement, {
87
+ status: status,
88
+ errorCode: errorCode,
89
+ isListening: isListening
90
+ }));
22
91
  },
23
- status: "<p>{{transcript}}</p>"
92
+ status: function status(_ref7) {
93
+ var transcript = _ref7.transcript;
94
+ return (0, _preact.h)("p", null, transcript);
95
+ }
24
96
  };
25
97
  var _default = defaultTemplates;
26
98
  exports.default = _default;
@@ -3,6 +3,11 @@
3
3
  import type { AlgoliaSearchHelper } from 'algoliasearch-helper';
4
4
  import EventEmitter from '@algolia/events';
5
5
  import { FindAnswersOptions } from 'algoliasearch-helper/types/algoliasearch.js';
6
+ import { h } from 'preact';
7
+ import type { HighlightClassNames as HighlightClassNames_2 } from '@algolia/ui-components-highlight-vdom';
8
+ import type { HighlightProps as HighlightProps_3 } from '@algolia/ui-components-highlight-vdom';
9
+ import type { HoganOptions } from 'hogan.js';
10
+ import type { html } from 'htm/preact';
6
11
  import type { InsightsClient as InsightsClient_2 } from 'search-insights';
7
12
  import type { InsightsMethodMap } from 'search-insights';
8
13
  import type * as Places from 'places.js';
@@ -11,6 +16,7 @@ import { default as qs_2 } from 'qs';
11
16
  import { SearchClient } from 'algoliasearch-helper/types/algoliasearch.js';
12
17
  import type { SearchParameters } from 'algoliasearch-helper';
13
18
  import type { SearchResults } from 'algoliasearch-helper';
19
+ import { VNode } from 'preact';
14
20
 
15
21
  declare type AlgoliaHit<THit extends BaseHit = Record<string, any>> = {
16
22
  objectID: string;
@@ -584,7 +590,9 @@ declare type ClearRefinementsTemplates = Partial<{
584
590
  /**
585
591
  * Template for the content of the button
586
592
  */
587
- resetLabel: Template;
593
+ resetLabel: Template<{
594
+ hasRefinements: boolean;
595
+ }>;
588
596
  }>;
589
597
 
590
598
  declare type ClearRefinementsWidget = WidgetFactory<ClearRefinementsWidgetDescription & {
@@ -1169,6 +1177,8 @@ declare const EXPERIMENTAL_connectDynamicWidgets: DynamicWidgetsConnector;
1169
1177
  /** @deprecated use dynamicWidgets */
1170
1178
  declare const EXPERIMENTAL_dynamicWidgets: DynamicWidgetsWidget;
1171
1179
 
1180
+ declare type FacetValue = string | boolean | number;
1181
+
1172
1182
  declare type GeoHit<THit extends BaseHit = Record<string, any>> = Hit<THit> & Required<Pick<Hit, '_geoloc'>>;
1173
1183
 
1174
1184
  declare type GeoLoc = {
@@ -1588,6 +1598,8 @@ declare type HierarchicalMenuTemplates = Partial<{
1588
1598
  count: number;
1589
1599
  isRefined: boolean;
1590
1600
  url: string;
1601
+ label: string;
1602
+ cssClasses: HierarchicalMenuCSSClasses;
1591
1603
  }>;
1592
1604
  /**
1593
1605
  * Template used for the show more text, provided with `isShowingMore` data property.
@@ -1738,8 +1750,12 @@ declare type HierarchicalMenuWidgetParams = {
1738
1750
  cssClasses?: HierarchicalMenuCSSClasses;
1739
1751
  };
1740
1752
 
1753
+ declare function Highlight<THit extends Hit<BaseHit>>({ hit, attribute, cssClasses, ...props }: HighlightProps<THit>): h.JSX.Element;
1754
+
1741
1755
  declare function highlight({ attribute, highlightedTagName, hit, cssClasses, }: HighlightOptions): string;
1742
1756
 
1757
+ declare type HighlightClassNames = HighlightClassNames_2;
1758
+
1743
1759
  declare type HighlightOptions = {
1744
1760
  attribute: string | string[];
1745
1761
  highlightedTagName?: string;
@@ -1749,6 +1765,16 @@ declare type HighlightOptions = {
1749
1765
  }>;
1750
1766
  };
1751
1767
 
1768
+ declare type HighlightProps<THit extends Hit<BaseHit>> = {
1769
+ hit: THit;
1770
+ attribute: keyof THit | string[];
1771
+ cssClasses?: HighlightProps_2['classNames'];
1772
+ } & PartialKeys<Omit<HighlightProps_2, 'parts' | 'classNames'>, 'highlightedTagName' | 'nonHighlightedTagName' | 'separator'>;
1773
+
1774
+ declare type HighlightProps_2 = Omit<HighlightProps_3, 'classNames'> & {
1775
+ classNames?: Partial<HighlightClassNames>;
1776
+ };
1777
+
1752
1778
  declare function historyRouter<TRouteState = UiState>({ createURL, parseURL, writeDelay, windowTitle, getLocation, }?: Partial<BrowserHistoryArgs<TRouteState>>): BrowserHistory<TRouteState>;
1753
1779
 
1754
1780
  declare type Hit<THit extends BaseHit = Record<string, any>> = {
@@ -1942,7 +1968,7 @@ declare type HitsTemplates = Partial<{
1942
1968
  *
1943
1969
  * @default 'No Results'
1944
1970
  */
1945
- empty: Template;
1971
+ empty: Template<SearchResults>;
1946
1972
  /**
1947
1973
  * Template to use for each result. This template will receive an object containing a single record.
1948
1974
  *
@@ -1980,11 +2006,13 @@ declare type HitsWidgetParams = {
1980
2006
  cssClasses?: HitsCSSClasses;
1981
2007
  };
1982
2008
 
2009
+ declare type HoganHelpers<TKeys extends string = string> = Record<TKeys, (text: string, render: (value: string) => string) => string>;
2010
+
1983
2011
  declare type HTMLMarkerArguments = {
1984
2012
  __id: string;
1985
2013
  position: google.maps.LatLngLiteral;
1986
2014
  map: google.maps.Map;
1987
- template: string;
2015
+ template: ReturnType<typeof renderTemplate>;
1988
2016
  title?: string;
1989
2017
  className: string;
1990
2018
  anchor?: {
@@ -2163,9 +2191,7 @@ declare type InfiniteHitsTemplates = Partial<{
2163
2191
  /**
2164
2192
  * The template to use when there are no results.
2165
2193
  */
2166
- empty: Template<{
2167
- results: SearchResults;
2168
- }>;
2194
+ empty: Template<SearchResults>;
2169
2195
  /**
2170
2196
  * The template to use for the “Show previous” label.
2171
2197
  */
@@ -2360,7 +2386,12 @@ declare class InstantSearch<TUiState extends UiState = UiState, TRouteState = TU
2360
2386
  cancel(): void;
2361
2387
  };
2362
2388
  scheduleStalledRender(): void;
2363
- setUiState(uiState: TUiState | ((previousUiState: TUiState) => TUiState)): void;
2389
+ /**
2390
+ * Set the UI state and trigger a search.
2391
+ * @param uiState The next UI state or a function computing it from the current state
2392
+ * @param callOnStateChange private parameter used to know if the method is called from a state change
2393
+ */
2394
+ setUiState(uiState: TUiState | ((previousUiState: TUiState) => TUiState), callOnStateChange?: boolean): void;
2364
2395
  getUiState(): TUiState;
2365
2396
  onInternalStateChange: ((...args: any[]) => void) & {
2366
2397
  wait(): Promise<void>;
@@ -2755,6 +2786,7 @@ declare type MiddlewareDefinition<TUiState extends UiState = UiState> = {
2755
2786
  uiState: TUiState;
2756
2787
  }): void;
2757
2788
  subscribe(): void;
2789
+ started(): void;
2758
2790
  unsubscribe(): void;
2759
2791
  };
2760
2792
 
@@ -3235,6 +3267,11 @@ declare type ParseURL<TRouteState> = (args: {
3235
3267
  location: Location;
3236
3268
  }) => TRouteState;
3237
3269
 
3270
+ /**
3271
+ * Make certain keys of an object optional.
3272
+ */
3273
+ declare type PartialKeys<TObj, TKeys extends keyof TObj> = Omit<TObj, TKeys> & Partial<Pick<TObj, TKeys>>;
3274
+
3238
3275
  declare type PlacesInstance = Places.PlacesInstance;
3239
3276
 
3240
3277
  declare type PlacesWidget = WidgetFactory<PlacesWidgetDescription, PlacesWidgetParams, PlacesWidgetParams>;
@@ -3749,9 +3786,15 @@ declare type RatingMenuTemplates = Partial<{
3749
3786
  */
3750
3787
  item: Template<{
3751
3788
  name: string;
3789
+ label: string;
3790
+ value: string;
3752
3791
  count: number;
3753
3792
  isRefined: boolean;
3754
3793
  url: string;
3794
+ stars: [boolean, boolean, boolean, boolean, boolean];
3795
+ cssClasses: RatingMenuCSSClasses;
3796
+ attribute?: string;
3797
+ isFromSearch?: boolean;
3755
3798
  }>;
3756
3799
  }>;
3757
3800
 
@@ -3954,6 +3997,10 @@ declare type RefinementListItemData = {
3954
3997
  * Object containing all the classes computed for the item.
3955
3998
  */
3956
3999
  cssClasses: RefinementListCSSClasses;
4000
+ /**
4001
+ * Whether the `items` prop contains facet values from the global search or from the search inside the items.
4002
+ */
4003
+ isFromSearch: boolean;
3957
4004
  };
3958
4005
 
3959
4006
  declare type RefinementListOwnCSSClasses = Partial<{
@@ -4019,7 +4066,9 @@ declare type RefinementListOwnTemplates = Partial<{
4019
4066
  /**
4020
4067
  * Template used for the show more text, provided with `isShowingMore` data property.
4021
4068
  */
4022
- showMoreText: Template;
4069
+ showMoreText: Template<{
4070
+ isShowingMore: boolean;
4071
+ }>;
4023
4072
  /**
4024
4073
  * Templates to use for search for facet values when there are no results.
4025
4074
  */
@@ -4271,6 +4320,16 @@ declare type RenderState = {
4271
4320
 
4272
4321
  declare type RenderStateLifeCycle<TWidgetDescription extends WidgetDescription & WidgetParams> = TWidgetDescription extends RequiredKeys<WidgetDescription, 'renderState' | 'indexRenderState'> & WidgetParams ? RequiredRenderStateLifeCycle<TWidgetDescription> : Partial<RequiredRenderStateLifeCycle<TWidgetDescription>>;
4273
4322
 
4323
+ declare function renderTemplate({ templates, templateKey, compileOptions, helpers, data, bindEvent, sendEvent, }: {
4324
+ templates: Templates;
4325
+ templateKey: string;
4326
+ compileOptions?: HoganOptions;
4327
+ helpers?: HoganHelpers;
4328
+ data?: Record<string, any>;
4329
+ bindEvent?: BindEventForHits;
4330
+ sendEvent?: SendEventForHits;
4331
+ }): string | VNode< {}> | VNode< {}>[];
4332
+
4274
4333
  declare type RequiredKeys<TObject, TKeys extends keyof TObject> = Expand<Required<Pick<TObject, TKeys>> & Omit<TObject, TKeys>>;
4275
4334
 
4276
4335
  declare type RequiredRenderStateLifeCycle<TWidgetDescription extends WidgetDescription & WidgetParams> = {
@@ -4348,8 +4407,12 @@ declare type RequiredWidgetType<TWidgetDescription extends WidgetDescription> =
4348
4407
  $$widgetType: TWidgetDescription['$$widgetType'];
4349
4408
  };
4350
4409
 
4410
+ declare function ReverseHighlight<THit extends Hit<BaseHit>>({ hit, attribute, cssClasses, ...props }: ReverseHighlightProps<THit>): h.JSX.Element;
4411
+
4351
4412
  declare function reverseHighlight({ attribute, highlightedTagName, hit, cssClasses, }: ReverseHighlightOptions): string;
4352
4413
 
4414
+ declare type ReverseHighlightClassNames = HighlightClassNames_2;
4415
+
4353
4416
  declare type ReverseHighlightOptions = {
4354
4417
  attribute: string | string[];
4355
4418
  highlightedTagName?: string;
@@ -4359,8 +4422,22 @@ declare type ReverseHighlightOptions = {
4359
4422
  }>;
4360
4423
  };
4361
4424
 
4425
+ declare type ReverseHighlightProps<THit extends Hit<BaseHit>> = {
4426
+ hit: THit;
4427
+ attribute: keyof THit | string[];
4428
+ cssClasses?: ReverseHighlightProps_2['classNames'];
4429
+ } & PartialKeys<Omit<ReverseHighlightProps_2, 'parts' | 'classNames'>, 'highlightedTagName' | 'nonHighlightedTagName' | 'separator'>;
4430
+
4431
+ declare type ReverseHighlightProps_2 = Omit<HighlightProps_3, 'classNames'> & {
4432
+ classNames?: Partial<ReverseHighlightClassNames>;
4433
+ };
4434
+
4435
+ declare function ReverseSnippet<THit extends Hit<BaseHit>>({ hit, attribute, cssClasses, ...props }: ReverseSnippetProps<THit>): h.JSX.Element;
4436
+
4362
4437
  declare function reverseSnippet({ attribute, highlightedTagName, hit, cssClasses, }: ReverseSnippetOptions): string;
4363
4438
 
4439
+ declare type ReverseSnippetClassNames = HighlightClassNames_2;
4440
+
4364
4441
  declare type ReverseSnippetOptions = {
4365
4442
  attribute: string | string[];
4366
4443
  highlightedTagName?: string;
@@ -4370,6 +4447,16 @@ declare type ReverseSnippetOptions = {
4370
4447
  }>;
4371
4448
  };
4372
4449
 
4450
+ declare type ReverseSnippetProps<THit extends Hit<BaseHit>> = {
4451
+ hit: THit;
4452
+ attribute: keyof THit | string[];
4453
+ cssClasses?: ReverseSnippetProps_2['classNames'];
4454
+ } & PartialKeys<Omit<ReverseSnippetProps_2, 'parts' | 'classNames'>, 'highlightedTagName' | 'nonHighlightedTagName' | 'separator'>;
4455
+
4456
+ declare type ReverseSnippetProps_2 = Omit<HighlightProps_3, 'classNames'> & {
4457
+ classNames?: Partial<ReverseSnippetClassNames>;
4458
+ };
4459
+
4373
4460
  /**
4374
4461
  * The router is the part that saves and reads the object from the storage.
4375
4462
  * Usually this is the URL.
@@ -4422,6 +4509,8 @@ declare type ScopedResult = {
4422
4509
 
4423
4510
  declare const searchBox: SearchBoxWidget;
4424
4511
 
4512
+ declare type SearchBoxComponentCSSClasses = ComponentCSSClasses<SearchBoxCSSClasses>;
4513
+
4425
4514
  declare type SearchBoxConnector = Connector<SearchBoxWidgetDescription, SearchBoxConnectorParams>;
4426
4515
 
4427
4516
  declare type SearchBoxConnectorParams = {
@@ -4507,15 +4596,21 @@ declare type SearchBoxTemplates = Partial<{
4507
4596
  /**
4508
4597
  * Template used for displaying the submit button. Can accept a function or a Hogan string.
4509
4598
  */
4510
- submit: Template;
4599
+ submit: Template<{
4600
+ cssClasses: SearchBoxComponentCSSClasses;
4601
+ }>;
4511
4602
  /**
4512
4603
  * Template used for displaying the reset button. Can accept a function or a Hogan string.
4513
4604
  */
4514
- reset: Template;
4605
+ reset: Template<{
4606
+ cssClasses: SearchBoxComponentCSSClasses;
4607
+ }>;
4515
4608
  /**
4516
4609
  * Template used for displaying the loading indicator. Can accept a function or a Hogan string.
4517
4610
  */
4518
- loadingIndicator: Template;
4611
+ loadingIndicator: Template<{
4612
+ cssClasses: SearchBoxComponentCSSClasses;
4613
+ }>;
4519
4614
  }>;
4520
4615
 
4521
4616
  /**
@@ -4614,8 +4709,12 @@ declare function simpleStateMapping<TUiState extends UiState = UiState>(): State
4614
4709
 
4615
4710
  declare function singleIndexStateMapping<TUiState extends UiState = UiState>(indexName: keyof TUiState): StateMapping<TUiState, TUiState[typeof indexName]>;
4616
4711
 
4712
+ declare function Snippet<THit extends Hit<BaseHit>>({ hit, attribute, cssClasses, ...props }: SnippetProps<THit>): h.JSX.Element;
4713
+
4617
4714
  declare function snippet({ attribute, highlightedTagName, hit, cssClasses, }: SnippetOptions): string;
4618
4715
 
4716
+ declare type SnippetClassNames = HighlightClassNames_2;
4717
+
4619
4718
  declare type SnippetOptions = {
4620
4719
  attribute: string | string[];
4621
4720
  highlightedTagName?: string;
@@ -4625,6 +4724,16 @@ declare type SnippetOptions = {
4625
4724
  };
4626
4725
  };
4627
4726
 
4727
+ declare type SnippetProps<THit extends Hit<BaseHit>> = {
4728
+ hit: THit;
4729
+ attribute: keyof THit | string[];
4730
+ cssClasses?: SnippetProps_2['classNames'];
4731
+ } & PartialKeys<Omit<SnippetProps_2, 'parts' | 'classNames'>, 'highlightedTagName' | 'nonHighlightedTagName' | 'separator'>;
4732
+
4733
+ declare type SnippetProps_2 = Omit<HighlightProps_3, 'classNames'> & {
4734
+ classNames?: Partial<SnippetClassNames>;
4735
+ };
4736
+
4628
4737
  /**
4629
4738
  * Transforms the given items.
4630
4739
  */
@@ -4877,13 +4986,9 @@ declare type StatsRenderState = {
4877
4986
 
4878
4987
  declare type StatsTemplates = Partial<{
4879
4988
  /**
4880
- * Text template, provided with `hasManyResults`, `hasNoResults`, `hasOneResult`, `hitsPerPage`, `nbHits`, `nbSortedHits`, `nbPages`, `areHitsSorted`, `page`, `processingTimeMS`, `query`.
4989
+ * Text template, provided with `hasManyResults`, `hasNoResults`, `hasOneResult`, `hasNoSortedResults`, `hasOneSortedResults`, `hasManySortedResults`, `hitsPerPage`, `nbHits`, `nbSortedHits`, `nbPages`, `areHitsSorted`, `page`, `processingTimeMS`, `query`.
4881
4990
  */
4882
- text: Template<{
4883
- hasManyResults: boolean;
4884
- hasNoResults: boolean;
4885
- hasOneResult: boolean;
4886
- } & StatsRenderState>;
4991
+ text: Template<TextTemplateProps & StatsRenderState>;
4887
4992
  }>;
4888
4993
 
4889
4994
  declare type StatsWidget = WidgetFactory<StatsWidgetDescription & {
@@ -4915,9 +5020,33 @@ declare type StatsWidgetParams = {
4915
5020
 
4916
5021
  declare type Status = 'initial' | 'askingPermission' | 'waiting' | 'recognizing' | 'finished' | 'error';
4917
5022
 
4918
- declare type Template<TTemplateData = void> = string | ((data: TTemplateData) => string);
5023
+ declare type Template<TTemplateData = void> = string | ((data: TTemplateData, params: TemplateParams) => VNode | VNode[] | string);
5024
+
5025
+ declare type TemplateParams = BindEventForHits & {
5026
+ html: typeof html;
5027
+ components: {
5028
+ Highlight: typeof Highlight;
5029
+ ReverseHighlight: typeof ReverseHighlight;
5030
+ Snippet: typeof Snippet;
5031
+ ReverseSnippet: typeof ReverseSnippet;
5032
+ };
5033
+ sendEvent?: SendEventForHits;
5034
+ };
5035
+
5036
+ declare type Templates = {
5037
+ [key: string]: Template<any> | TemplateWithBindEvent<any> | undefined;
5038
+ };
4919
5039
 
4920
- declare type TemplateWithBindEvent<TTemplateData = void> = string | ((data: TTemplateData, bindEvent: BindEventForHits) => string);
5040
+ declare type TemplateWithBindEvent<TTemplateData = void> = string | ((data: TTemplateData, params: TemplateParams) => VNode | VNode[] | string);
5041
+
5042
+ declare type TextTemplateProps = {
5043
+ hasManyResults: boolean;
5044
+ hasNoResults: boolean;
5045
+ hasOneResult: boolean;
5046
+ hasNoSortedResults: boolean;
5047
+ hasOneSortedResults: boolean;
5048
+ hasManySortedResults: boolean;
5049
+ };
4921
5050
 
4922
5051
  /**
4923
5052
  * The toggleRefinement widget lets the user either:
@@ -4944,11 +5073,11 @@ declare type ToggleRefinementConnectorParams = {
4944
5073
  * Value to filter on when toggled.
4945
5074
  * @default "true"
4946
5075
  */
4947
- on?: string | string[] | boolean | boolean[] | number | number[];
5076
+ on?: FacetValue | FacetValue[];
4948
5077
  /**
4949
5078
  * Value to filter on when not toggled.
4950
5079
  */
4951
- off?: string | string[] | boolean | boolean[] | number | number[];
5080
+ off?: FacetValue | FacetValue[];
4952
5081
  };
4953
5082
 
4954
5083
  declare type ToggleRefinementCSSClasses = Partial<{
@@ -5018,7 +5147,9 @@ declare type ToggleRefinementTemplates = Partial<{
5018
5147
  /**
5019
5148
  * the text that describes the toggle action
5020
5149
  */
5021
- labelText: Template<ToggleRefinementValue>;
5150
+ labelText: Template<ToggleRefinementValue & {
5151
+ name: string;
5152
+ }>;
5022
5153
  }>;
5023
5154
 
5024
5155
  declare type ToggleRefinementValue = {