react-instantsearch-core 6.40.3 → 7.0.0

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 (263) hide show
  1. package/README.md +70 -2
  2. package/dist/cjs/components/Configure.js +13 -0
  3. package/dist/cjs/components/DynamicWidgets.js +63 -0
  4. package/dist/cjs/components/Index.js +24 -0
  5. package/dist/cjs/components/InstantSearch.js +27 -0
  6. package/dist/cjs/{connectors/connectConfigure.js → components/InstantSearchSSRProvider.js} +27 -63
  7. package/dist/cjs/components/InstantSearchServerContext.js +12 -0
  8. package/dist/cjs/connectors/useBreadcrumb.js +12 -0
  9. package/dist/cjs/connectors/useClearRefinements.js +12 -0
  10. package/dist/cjs/connectors/useConfigure.js +14 -0
  11. package/dist/cjs/connectors/useCurrentRefinements.js +12 -0
  12. package/dist/cjs/connectors/useDynamicWidgets.js +22 -0
  13. package/dist/cjs/connectors/useGeoSearch.js +12 -0
  14. package/dist/cjs/connectors/useHierarchicalMenu.js +12 -0
  15. package/dist/cjs/connectors/useHits.js +12 -0
  16. package/dist/cjs/connectors/useHitsPerPage.js +12 -0
  17. package/dist/cjs/connectors/useInfiniteHits.js +12 -0
  18. package/dist/cjs/connectors/useMenu.js +12 -0
  19. package/dist/cjs/connectors/useNumericMenu.js +12 -0
  20. package/dist/cjs/connectors/usePagination.js +12 -0
  21. package/dist/cjs/connectors/usePoweredBy.js +21 -0
  22. package/dist/cjs/connectors/useQueryRules.js +12 -0
  23. package/dist/cjs/connectors/useRange.js +12 -0
  24. package/dist/cjs/connectors/useRefinementList.js +12 -0
  25. package/dist/cjs/connectors/useSearchBox.js +12 -0
  26. package/dist/cjs/connectors/useSortBy.js +12 -0
  27. package/dist/cjs/connectors/useStats.js +12 -0
  28. package/dist/cjs/connectors/useToggleRefinement.js +12 -0
  29. package/dist/cjs/hooks/useConnector.js +136 -0
  30. package/dist/cjs/hooks/useInstantSearch.js +58 -0
  31. package/dist/cjs/index.js +328 -320
  32. package/dist/cjs/lib/IndexContext.js +12 -0
  33. package/dist/cjs/lib/InstantSearchContext.js +12 -0
  34. package/dist/cjs/lib/InstantSearchSSRContext.js +12 -0
  35. package/dist/cjs/lib/createSearchResults.js +27 -0
  36. package/dist/cjs/lib/dequal.js +53 -0
  37. package/dist/cjs/lib/getIndexSearchResults.js +32 -0
  38. package/dist/cjs/lib/invariant.js +25 -0
  39. package/dist/cjs/lib/noop.js +8 -0
  40. package/dist/cjs/lib/useForceUpdate.js +25 -0
  41. package/dist/cjs/lib/useIndex.js +38 -0
  42. package/dist/cjs/lib/useIndexContext.js +14 -0
  43. package/dist/cjs/lib/useInstantSearchApi.js +191 -0
  44. package/dist/cjs/lib/useInstantSearchContext.js +14 -0
  45. package/dist/cjs/lib/useInstantSearchSSRContext.js +11 -0
  46. package/dist/cjs/lib/useInstantSearchServerContext.js +11 -0
  47. package/dist/cjs/lib/useIsomorphicLayoutEffect.js +14 -0
  48. package/dist/cjs/lib/useSearchResults.js +46 -0
  49. package/dist/cjs/lib/useSearchState.js +48 -0
  50. package/dist/cjs/lib/useStableValue.js +26 -0
  51. package/dist/cjs/lib/useWidget.js +78 -0
  52. package/dist/cjs/lib/warn.js +41 -0
  53. package/dist/cjs/package.json +1 -0
  54. package/dist/cjs/server/getServerState.js +93 -0
  55. package/dist/cjs/{types → server}/index.js +4 -4
  56. package/dist/cjs/{core/version.js → version.js} +1 -1
  57. package/dist/es/components/Configure.d.ts +3 -0
  58. package/dist/es/components/Configure.js +7 -0
  59. package/dist/es/components/DynamicWidgets.d.ts +13 -0
  60. package/dist/es/components/DynamicWidgets.js +55 -0
  61. package/dist/es/components/Index.d.ts +6 -0
  62. package/dist/es/components/Index.js +17 -0
  63. package/dist/es/components/InstantSearch.d.ts +7 -0
  64. package/dist/es/components/InstantSearch.js +20 -0
  65. package/dist/es/components/InstantSearchSSRProvider.d.ts +13 -0
  66. package/dist/es/{connectors/connectConfigure.js → components/InstantSearchSSRProvider.js} +26 -61
  67. package/dist/es/components/InstantSearchServerContext.d.ts +12 -0
  68. package/dist/es/components/InstantSearchServerContext.js +5 -0
  69. package/dist/es/connectors/useBreadcrumb.d.ts +4 -0
  70. package/dist/es/connectors/useBreadcrumb.js +5 -0
  71. package/dist/es/connectors/useClearRefinements.d.ts +4 -0
  72. package/dist/es/connectors/useClearRefinements.js +5 -0
  73. package/dist/es/connectors/useConfigure.d.ts +4 -0
  74. package/dist/es/connectors/useConfigure.js +7 -0
  75. package/dist/es/connectors/useCurrentRefinements.d.ts +4 -0
  76. package/dist/es/connectors/useCurrentRefinements.js +5 -0
  77. package/dist/es/connectors/useDynamicWidgets.d.ts +4 -0
  78. package/dist/es/connectors/useDynamicWidgets.js +15 -0
  79. package/dist/es/connectors/useGeoSearch.d.ts +6 -0
  80. package/dist/es/connectors/useGeoSearch.js +5 -0
  81. package/dist/es/connectors/useHierarchicalMenu.d.ts +4 -0
  82. package/dist/es/connectors/useHierarchicalMenu.js +5 -0
  83. package/dist/es/connectors/useHits.d.ts +5 -0
  84. package/dist/es/connectors/useHits.js +5 -0
  85. package/dist/es/connectors/useHitsPerPage.d.ts +4 -0
  86. package/dist/es/connectors/useHitsPerPage.js +5 -0
  87. package/dist/es/connectors/useInfiniteHits.d.ts +5 -0
  88. package/dist/es/connectors/useInfiniteHits.js +5 -0
  89. package/dist/es/connectors/useMenu.d.ts +4 -0
  90. package/dist/es/connectors/useMenu.js +5 -0
  91. package/dist/es/connectors/useNumericMenu.d.ts +4 -0
  92. package/dist/es/connectors/useNumericMenu.js +5 -0
  93. package/dist/es/connectors/usePagination.d.ts +4 -0
  94. package/dist/es/connectors/usePagination.js +5 -0
  95. package/dist/es/connectors/usePoweredBy.d.ts +2 -0
  96. package/dist/es/connectors/usePoweredBy.js +15 -0
  97. package/dist/es/connectors/useQueryRules.d.ts +4 -0
  98. package/dist/es/connectors/useQueryRules.js +5 -0
  99. package/dist/es/connectors/useRange.d.ts +4 -0
  100. package/dist/es/connectors/useRange.js +5 -0
  101. package/dist/es/connectors/useRefinementList.d.ts +4 -0
  102. package/dist/es/connectors/useRefinementList.js +5 -0
  103. package/dist/es/connectors/useSearchBox.d.ts +4 -0
  104. package/dist/es/connectors/useSearchBox.js +5 -0
  105. package/dist/es/connectors/useSortBy.d.ts +4 -0
  106. package/dist/es/connectors/useSortBy.js +5 -0
  107. package/dist/es/connectors/useStats.d.ts +4 -0
  108. package/dist/es/connectors/useStats.js +5 -0
  109. package/dist/es/connectors/useToggleRefinement.d.ts +4 -0
  110. package/dist/es/connectors/useToggleRefinement.js +5 -0
  111. package/dist/es/hooks/useConnector.d.ts +3 -0
  112. package/dist/es/hooks/useConnector.js +130 -0
  113. package/dist/es/hooks/useInstantSearch.d.ts +32 -0
  114. package/dist/es/hooks/useInstantSearch.js +52 -0
  115. package/dist/es/index.d.ts +31 -0
  116. package/dist/es/index.js +31 -86
  117. package/dist/es/lib/IndexContext.d.ts +3 -0
  118. package/dist/es/lib/IndexContext.js +5 -0
  119. package/dist/es/lib/InstantSearchContext.d.ts +3 -0
  120. package/dist/es/lib/InstantSearchContext.js +5 -0
  121. package/dist/es/lib/InstantSearchSSRContext.d.ts +8 -0
  122. package/dist/es/lib/InstantSearchSSRContext.js +5 -0
  123. package/dist/es/lib/createSearchResults.d.ts +3 -0
  124. package/dist/es/lib/createSearchResults.js +20 -0
  125. package/dist/es/lib/dequal.d.ts +1 -0
  126. package/dist/es/lib/dequal.js +47 -0
  127. package/dist/es/lib/getIndexSearchResults.d.ts +9 -0
  128. package/dist/es/lib/getIndexSearchResults.js +26 -0
  129. package/dist/es/lib/invariant.d.ts +9 -0
  130. package/dist/es/lib/invariant.js +19 -0
  131. package/dist/es/lib/noop.d.ts +1 -0
  132. package/dist/es/lib/noop.js +1 -0
  133. package/dist/es/lib/useForceUpdate.d.ts +6 -0
  134. package/dist/es/lib/useForceUpdate.js +20 -0
  135. package/dist/es/lib/useIndex.d.ts +3 -0
  136. package/dist/es/lib/useIndex.js +31 -0
  137. package/dist/es/lib/useIndexContext.d.ts +2 -0
  138. package/dist/es/lib/useIndexContext.js +8 -0
  139. package/dist/es/lib/useInstantSearchApi.d.ts +21 -0
  140. package/dist/es/lib/useInstantSearchApi.js +184 -0
  141. package/dist/es/lib/useInstantSearchContext.d.ts +3 -0
  142. package/dist/es/lib/useInstantSearchContext.js +8 -0
  143. package/dist/es/lib/useInstantSearchSSRContext.d.ts +3 -0
  144. package/dist/es/lib/useInstantSearchSSRContext.js +5 -0
  145. package/dist/es/lib/useInstantSearchServerContext.d.ts +3 -0
  146. package/dist/es/lib/useInstantSearchServerContext.js +5 -0
  147. package/dist/es/lib/useIsomorphicLayoutEffect.d.ts +7 -0
  148. package/dist/es/lib/useIsomorphicLayoutEffect.js +8 -0
  149. package/dist/es/lib/useSearchResults.d.ts +7 -0
  150. package/dist/es/lib/useSearchResults.js +40 -0
  151. package/dist/es/lib/useSearchState.d.ts +8 -0
  152. package/dist/es/lib/useSearchState.js +42 -0
  153. package/dist/es/lib/useStableValue.d.ts +1 -0
  154. package/dist/es/lib/useStableValue.js +20 -0
  155. package/dist/es/lib/useWidget.d.ts +8 -0
  156. package/dist/es/lib/useWidget.js +72 -0
  157. package/dist/es/lib/warn.d.ts +10 -0
  158. package/dist/es/lib/warn.js +33 -0
  159. package/dist/es/server/getServerState.d.ts +10 -0
  160. package/dist/es/server/getServerState.js +86 -0
  161. package/dist/es/server/index.d.ts +1 -0
  162. package/dist/es/server/index.js +1 -0
  163. package/dist/es/version.d.ts +2 -0
  164. package/dist/es/version.js +1 -0
  165. package/dist/umd/ReactInstantSearchCore.js +16316 -10183
  166. package/dist/umd/ReactInstantSearchCore.js.map +1 -1
  167. package/dist/umd/ReactInstantSearchCore.min.js +1 -1
  168. package/dist/umd/ReactInstantSearchCore.min.js.map +1 -1
  169. package/package.json +24 -9
  170. package/dist/cjs/connectors/connectAutoComplete.js +0 -104
  171. package/dist/cjs/connectors/connectBreadcrumb.js +0 -123
  172. package/dist/cjs/connectors/connectConfigureRelatedItems.js +0 -127
  173. package/dist/cjs/connectors/connectCurrentRefinements.js +0 -69
  174. package/dist/cjs/connectors/connectDynamicWidgets.js +0 -65
  175. package/dist/cjs/connectors/connectGeoSearch.js +0 -189
  176. package/dist/cjs/connectors/connectHierarchicalMenu.js +0 -273
  177. package/dist/cjs/connectors/connectHighlight.js +0 -87
  178. package/dist/cjs/connectors/connectHitInsights.js +0 -76
  179. package/dist/cjs/connectors/connectHits.js +0 -88
  180. package/dist/cjs/connectors/connectHitsPerPage.js +0 -97
  181. package/dist/cjs/connectors/connectInfiniteHits.js +0 -154
  182. package/dist/cjs/connectors/connectMenu.js +0 -221
  183. package/dist/cjs/connectors/connectNumericMenu.js +0 -215
  184. package/dist/cjs/connectors/connectPagination.js +0 -94
  185. package/dist/cjs/connectors/connectPoweredBy.js +0 -27
  186. package/dist/cjs/connectors/connectQueryRules.js +0 -129
  187. package/dist/cjs/connectors/connectRange.js +0 -287
  188. package/dist/cjs/connectors/connectRefinementList.js +0 -243
  189. package/dist/cjs/connectors/connectRelevantSort.js +0 -56
  190. package/dist/cjs/connectors/connectScrollTo.js +0 -70
  191. package/dist/cjs/connectors/connectSearchBox.js +0 -104
  192. package/dist/cjs/connectors/connectSortBy.js +0 -100
  193. package/dist/cjs/connectors/connectStateResults.js +0 -79
  194. package/dist/cjs/connectors/connectStats.js +0 -39
  195. package/dist/cjs/connectors/connectToggleRefinement.js +0 -163
  196. package/dist/cjs/connectors/connectVoiceSearch.js +0 -124
  197. package/dist/cjs/core/context.js +0 -37
  198. package/dist/cjs/core/createConnector.js +0 -268
  199. package/dist/cjs/core/createInstantSearchManager.d.js +0 -1
  200. package/dist/cjs/core/createInstantSearchManager.js +0 -541
  201. package/dist/cjs/core/createStore.js +0 -27
  202. package/dist/cjs/core/createWidgetsManager.js +0 -39
  203. package/dist/cjs/core/highlight.js +0 -102
  204. package/dist/cjs/core/indexUtils.js +0 -214
  205. package/dist/cjs/core/metadata.js +0 -46
  206. package/dist/cjs/core/translatable.js +0 -82
  207. package/dist/cjs/core/utils.js +0 -161
  208. package/dist/cjs/types/algoliasearch.js +0 -1
  209. package/dist/cjs/types/translatable.js +0 -1
  210. package/dist/cjs/widgets/Configure.js +0 -48
  211. package/dist/cjs/widgets/ConfigureRelatedItems.js +0 -21
  212. package/dist/cjs/widgets/DynamicWidgets.js +0 -61
  213. package/dist/cjs/widgets/Index.js +0 -149
  214. package/dist/cjs/widgets/InstantSearch.js +0 -251
  215. package/dist/cjs/widgets/QueryRuleContext.js +0 -14
  216. package/dist/es/connectors/connectAutoComplete.js +0 -96
  217. package/dist/es/connectors/connectBreadcrumb.js +0 -115
  218. package/dist/es/connectors/connectConfigureRelatedItems.js +0 -121
  219. package/dist/es/connectors/connectCurrentRefinements.js +0 -62
  220. package/dist/es/connectors/connectDynamicWidgets.js +0 -56
  221. package/dist/es/connectors/connectGeoSearch.js +0 -182
  222. package/dist/es/connectors/connectHierarchicalMenu.js +0 -264
  223. package/dist/es/connectors/connectHighlight.js +0 -79
  224. package/dist/es/connectors/connectHitInsights.js +0 -69
  225. package/dist/es/connectors/connectHits.js +0 -81
  226. package/dist/es/connectors/connectHitsPerPage.js +0 -89
  227. package/dist/es/connectors/connectInfiniteHits.js +0 -146
  228. package/dist/es/connectors/connectMenu.js +0 -213
  229. package/dist/es/connectors/connectNumericMenu.js +0 -207
  230. package/dist/es/connectors/connectPagination.js +0 -86
  231. package/dist/es/connectors/connectPoweredBy.js +0 -20
  232. package/dist/es/connectors/connectQueryRules.js +0 -122
  233. package/dist/es/connectors/connectRange.js +0 -280
  234. package/dist/es/connectors/connectRefinementList.js +0 -235
  235. package/dist/es/connectors/connectRelevantSort.js +0 -50
  236. package/dist/es/connectors/connectScrollTo.js +0 -63
  237. package/dist/es/connectors/connectSearchBox.js +0 -96
  238. package/dist/es/connectors/connectSortBy.js +0 -92
  239. package/dist/es/connectors/connectStateResults.js +0 -72
  240. package/dist/es/connectors/connectStats.js +0 -32
  241. package/dist/es/connectors/connectToggleRefinement.js +0 -155
  242. package/dist/es/connectors/connectVoiceSearch.js +0 -116
  243. package/dist/es/core/context.js +0 -28
  244. package/dist/es/core/createConnector.js +0 -257
  245. package/dist/es/core/createInstantSearchManager.d.js +0 -0
  246. package/dist/es/core/createInstantSearchManager.js +0 -534
  247. package/dist/es/core/createStore.js +0 -21
  248. package/dist/es/core/createWidgetsManager.js +0 -33
  249. package/dist/es/core/highlight.js +0 -94
  250. package/dist/es/core/indexUtils.js +0 -203
  251. package/dist/es/core/metadata.js +0 -38
  252. package/dist/es/core/translatable.js +0 -74
  253. package/dist/es/core/utils.js +0 -139
  254. package/dist/es/core/version.js +0 -1
  255. package/dist/es/types/algoliasearch.js +0 -1
  256. package/dist/es/types/index.js +0 -1
  257. package/dist/es/types/translatable.js +0 -1
  258. package/dist/es/widgets/Configure.js +0 -42
  259. package/dist/es/widgets/ConfigureRelatedItems.js +0 -13
  260. package/dist/es/widgets/DynamicWidgets.js +0 -51
  261. package/dist/es/widgets/Index.js +0 -138
  262. package/dist/es/widgets/InstantSearch.js +0 -241
  263. package/dist/es/widgets/QueryRuleContext.js +0 -6
@@ -1,115 +0,0 @@
1
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
3
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
4
- function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
5
- import PropTypes from 'prop-types';
6
- import createConnector from "../core/createConnector.js";
7
- import { refineValue, getResults } from "../core/indexUtils.js";
8
- export var getId = function getId(props) {
9
- return props.attributes[0];
10
- };
11
- var namespace = 'hierarchicalMenu';
12
- function _refine(props, searchState, nextRefinement, context) {
13
- var id = getId(props);
14
- var nextValue = _defineProperty({}, id, nextRefinement || '');
15
- var resetPage = true;
16
- return refineValue(searchState, nextValue, context, resetPage, namespace);
17
- }
18
- function transformValue(values) {
19
- return values.reduce(function (acc, item) {
20
- if (item.isRefined) {
21
- acc.push({
22
- label: item.name,
23
- // If dealing with a nested "items", "value" is equal to the previous value concatenated with the current value
24
- // If dealing with the first level, "value" is equal to the current value
25
- value: item.escapedValue
26
- });
27
- // Create a variable in order to keep the same acc for the recursion, otherwise "reduce" returns a new one
28
- if (item.data) {
29
- acc = acc.concat(transformValue(item.data, acc));
30
- }
31
- }
32
- return acc;
33
- }, []);
34
- }
35
-
36
- /**
37
- * The breadcrumb component is s a type of secondary navigation scheme that
38
- * reveals the user’s location in a website or web application.
39
- *
40
- * @name connectBreadcrumb
41
- * @requirements To use this widget, your attributes must be formatted in a specific way.
42
- * If you want for example to have a Breadcrumb of categories, objects in your index
43
- * should be formatted this way:
44
- *
45
- * ```json
46
- * {
47
- * "categories.lvl0": "products",
48
- * "categories.lvl1": "products > fruits",
49
- * "categories.lvl2": "products > fruits > citrus"
50
- * }
51
- * ```
52
- *
53
- * It's also possible to provide more than one path for each level:
54
- *
55
- * ```json
56
- * {
57
- * "categories.lvl0": ["products", "goods"],
58
- * "categories.lvl1": ["products > fruits", "goods > to eat"]
59
- * }
60
- * ```
61
- *
62
- * All attributes passed to the `attributes` prop must be present in "attributes for faceting"
63
- * on the Algolia dashboard or configured as `attributesForFaceting` via a set settings call to the Algolia API.
64
- *
65
- * @kind connector
66
- * @propType {array.<string>} attributes - List of attributes to use to generate the hierarchy of the menu. See the example for the convention to follow.
67
- * @propType {function} [transformItems] - Function to modify the items being displayed, e.g. for filtering or sorting them. Takes an items as parameter and expects it back in return.
68
- * @providedPropType {function} refine - a function to toggle a refinement
69
- * @providedPropType {function} createURL - a function to generate a URL for the corresponding search state
70
- * @providedPropType {array.<{items: object, count: number, isRefined: boolean, label: string, value: string}>} items - the list of items the Breadcrumb can display.
71
- */
72
-
73
- export default createConnector({
74
- displayName: 'AlgoliaBreadcrumb',
75
- $$type: 'ais.breadcrumb',
76
- propTypes: {
77
- attributes: function attributes(props, propName, componentName) {
78
- var isNotString = function isNotString(val) {
79
- return typeof val !== 'string';
80
- };
81
- if (!Array.isArray(props[propName]) || props[propName].some(isNotString) || props[propName].length < 1) {
82
- return new Error("Invalid prop ".concat(propName, " supplied to ").concat(componentName, ". Expected an Array of Strings"));
83
- }
84
- return undefined;
85
- },
86
- transformItems: PropTypes.func
87
- },
88
- getProvidedProps: function getProvidedProps(props, searchState, searchResults) {
89
- var id = getId(props);
90
- var results = getResults(searchResults, {
91
- ais: props.contextValue,
92
- multiIndexContext: props.indexContextValue
93
- });
94
- var isFacetPresent = Boolean(results) && Boolean(results.getFacetByName(id));
95
- if (!isFacetPresent) {
96
- return {
97
- items: [],
98
- canRefine: false
99
- };
100
- }
101
- var values = results.getFacetValues(id);
102
- var items = values.data ? transformValue(values.data) : [];
103
- var transformedItems = props.transformItems ? props.transformItems(items) : items;
104
- return {
105
- canRefine: transformedItems.length > 0,
106
- items: transformedItems
107
- };
108
- },
109
- refine: function refine(props, searchState, nextRefinement) {
110
- return _refine(props, searchState, nextRefinement, {
111
- ais: props.contextValue,
112
- multiIndexContext: props.indexContextValue
113
- });
114
- }
115
- });
@@ -1,121 +0,0 @@
1
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
3
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
5
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
6
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
7
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
8
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
9
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
10
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
11
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
12
- function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
13
- import algoliasearchHelper from 'algoliasearch-helper';
14
- import createConnector from "../core/createConnector.js";
15
- import { omit, getObjectType, getPropertyByPath, removeEmptyKey, removeEmptyArraysFromObject } from "../core/utils.js";
16
- import { refineValue, getIndexId, hasMultipleIndices
17
- // @ts-ignore
18
- } from "../core/indexUtils.js";
19
- function createOptionalFilter(_ref) {
20
- var attributeName = _ref.attributeName,
21
- attributeValue = _ref.attributeValue,
22
- attributeScore = _ref.attributeScore;
23
- return "".concat(attributeName, ":").concat(attributeValue, "<score=").concat(attributeScore || 1, ">");
24
- }
25
- var defaultProps = {
26
- transformSearchParameters: function transformSearchParameters(x) {
27
- return _objectSpread({}, x);
28
- }
29
- };
30
- function getId() {
31
- // We store the search state of this widget in `configure`.
32
- return 'configure';
33
- }
34
- function getSearchParametersFromProps(props) {
35
- var optionalFilters = Object.keys(props.matchingPatterns).reduce(function (acc, attributeName) {
36
- var attributePattern = props.matchingPatterns[attributeName];
37
- var attributeValue = getPropertyByPath(props.hit, attributeName);
38
- var attributeScore = attributePattern.score;
39
- if (Array.isArray(attributeValue)) {
40
- return [].concat(_toConsumableArray(acc), [attributeValue.map(function (attributeSubValue) {
41
- return createOptionalFilter({
42
- attributeName: attributeName,
43
- attributeValue: attributeSubValue,
44
- attributeScore: attributeScore
45
- });
46
- })]);
47
- }
48
- if (typeof attributeValue === 'string') {
49
- return [].concat(_toConsumableArray(acc), [createOptionalFilter({
50
- attributeName: attributeName,
51
- attributeValue: attributeValue,
52
- attributeScore: attributeScore
53
- })]);
54
- }
55
- if (process.env.NODE_ENV === 'development') {
56
- // eslint-disable-next-line no-console
57
- console.warn("The `matchingPatterns` option returned a value of type ".concat(getObjectType(attributeValue), " for the \"").concat(attributeName, "\" key. This value was not sent to Algolia because `optionalFilters` only supports strings and array of strings.\n\nYou can remove the \"").concat(attributeName, "\" key from the `matchingPatterns` option.\n\nSee https://www.algolia.com/doc/api-reference/api-parameters/optionalFilters/"));
58
- }
59
- return acc;
60
- }, []);
61
- return props.transformSearchParameters(new algoliasearchHelper.SearchParameters({
62
- // @ts-ignore @TODO algoliasearch-helper@3.0.1 will contain the type
63
- // `sumOrFiltersScores`.
64
- // See https://github.com/algolia/algoliasearch-helper-js/pull/753
65
- sumOrFiltersScores: true,
66
- facetFilters: ["objectID:-".concat(props.hit.objectID)],
67
- optionalFilters: optionalFilters
68
- }));
69
- }
70
- export default createConnector({
71
- displayName: 'AlgoliaConfigureRelatedItems',
72
- $$type: 'ais.configureRelatedItems',
73
- defaultProps: defaultProps,
74
- getProvidedProps: function getProvidedProps() {
75
- return {};
76
- },
77
- getSearchParameters: function getSearchParameters(searchParameters, props) {
78
- return searchParameters.setQueryParameters(getSearchParametersFromProps(props));
79
- },
80
- transitionState: function transitionState(props, _prevSearchState, nextSearchState) {
81
- var id = getId();
82
- // We need to transform the exhaustive search parameters back to clean
83
- // search parameters without the empty default keys so we don't pollute the
84
- // `configure` search state.
85
- var searchParameters = removeEmptyArraysFromObject(removeEmptyKey(getSearchParametersFromProps(props)));
86
- var searchParametersKeys = Object.keys(searchParameters);
87
- var nonPresentKeys = this._searchParameters ? Object.keys(this._searchParameters).filter(function (prop) {
88
- return searchParametersKeys.indexOf(prop) === -1;
89
- }) : [];
90
- this._searchParameters = searchParameters;
91
- var nextValue = _defineProperty({}, id, _objectSpread(_objectSpread({}, omit(nextSearchState[id], nonPresentKeys)), searchParameters));
92
- return refineValue(nextSearchState, nextValue, {
93
- ais: props.contextValue,
94
- multiIndexContext: props.indexContextValue
95
- });
96
- },
97
- cleanUp: function cleanUp(props, searchState) {
98
- var _this = this;
99
- var id = getId();
100
- var indexId = getIndexId({
101
- ais: props.contextValue,
102
- multiIndexContext: props.indexContextValue
103
- });
104
- var subState = hasMultipleIndices({
105
- ais: props.contextValue,
106
- multiIndexContext: props.indexContextValue
107
- }) && searchState.indices ? searchState.indices[indexId] : searchState;
108
- var configureKeys = subState && subState[id] ? Object.keys(subState[id]) : [];
109
- var configureState = configureKeys.reduce(function (acc, item) {
110
- if (!_this._searchParameters[item]) {
111
- acc[item] = subState[id][item];
112
- }
113
- return acc;
114
- }, {});
115
- var nextValue = _defineProperty({}, id, configureState);
116
- return refineValue(searchState, nextValue, {
117
- ais: props.contextValue,
118
- multiIndexContext: props.indexContextValue
119
- });
120
- }
121
- });
@@ -1,62 +0,0 @@
1
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
6
- function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
7
- import PropTypes from 'prop-types';
8
- import createConnector from "../core/createConnector.js";
9
-
10
- /**
11
- * connectCurrentRefinements connector provides the logic to build a widget that will
12
- * give the user the ability to remove all or some of the filters that were
13
- * set.
14
- * @name connectCurrentRefinements
15
- * @kind connector
16
- * @propType {function} [transformItems] - Function to modify the items being displayed, e.g. for filtering or sorting them. Takes an items as parameter and expects it back in return.
17
- * @propType {function} [clearsQuery=false] - Pass true to also clear the search query
18
- * @providedPropType {function} refine - a function to remove a single filter
19
- * @providedPropType {array.<{label: string, attribute: string, currentRefinement: string || object, items: array, value: function}>} items - all the filters, the `value` is to pass to the `refine` function for removing all currentrefinements, `label` is for the display. When existing several refinements for the same atribute name, then you get a nested `items` object that contains a `label` and a `value` function to use to remove a single filter. `attribute` and `currentRefinement` are metadata containing row values.
20
- * @providedPropType {string} query - the search query
21
- */
22
- export default createConnector({
23
- displayName: 'AlgoliaCurrentRefinements',
24
- $$type: 'ais.currentRefinements',
25
- propTypes: {
26
- transformItems: PropTypes.func
27
- },
28
- getProvidedProps: function getProvidedProps(props, searchState, searchResults, metadata) {
29
- var items = metadata.reduce(function (res, meta) {
30
- if (typeof meta.items !== 'undefined') {
31
- if (!props.clearsQuery && meta.id === 'query') {
32
- return res;
33
- } else {
34
- if (props.clearsQuery && meta.id === 'query' && meta.items[0].currentRefinement === '') {
35
- return res;
36
- }
37
- return res.concat(meta.items.map(function (item) {
38
- return _objectSpread(_objectSpread({}, item), {}, {
39
- id: meta.id,
40
- index: meta.index
41
- });
42
- }));
43
- }
44
- }
45
- return res;
46
- }, []);
47
- var transformedItems = props.transformItems ? props.transformItems(items) : items;
48
- return {
49
- items: transformedItems,
50
- canRefine: transformedItems.length > 0
51
- };
52
- },
53
- refine: function refine(props, searchState, items) {
54
- // `value` corresponds to our internal clear function computed in each connector metadata.
55
- var refinementsToClear = items instanceof Array ? items.map(function (item) {
56
- return item.value;
57
- }) : [items];
58
- return refinementsToClear.reduce(function (res, clear) {
59
- return clear(res);
60
- }, searchState);
61
- }
62
- });
@@ -1,56 +0,0 @@
1
- import PropTypes from 'prop-types';
2
- import createConnector from "../core/createConnector.js";
3
- // @ts-ignore
4
- import { getResults } from "../core/indexUtils.js";
5
- var MAX_WILDCARD_FACETS = 20;
6
- export default createConnector({
7
- displayName: 'AlgoliaDynamicWidgets',
8
- $$type: 'ais.dynamicWidgets',
9
- defaultProps: {
10
- transformItems: function transformItems(items) {
11
- return items;
12
- },
13
- maxValuesPerFacet: 20
14
- },
15
- propTypes: {
16
- transformItems: PropTypes.func,
17
- facets: PropTypes.arrayOf(PropTypes.string),
18
- maxValuesPerFacet: PropTypes.number
19
- },
20
- getProvidedProps: function getProvidedProps(props, _searchState, searchResults) {
21
- var results = getResults(searchResults, {
22
- ais: props.contextValue,
23
- multiIndexContext: props.indexContextValue
24
- });
25
- if (props.facets && !(Array.isArray(props.facets) && props.facets.length <= 1 && (props.facets[0] === '*' || props.facets[0] === undefined))) {
26
- throw new Error("The `facets` prop only accepts [] or [\"*\"], you passed ".concat(JSON.stringify(props.facets)));
27
- }
28
- if (!results) {
29
- return {
30
- attributesToRender: []
31
- };
32
- }
33
- var facetOrder = results.renderingContent && results.renderingContent.facetOrdering && results.renderingContent.facetOrdering.facets && results.renderingContent.facetOrdering.facets.order || [];
34
- var attributesToRender = props.transformItems(facetOrder, {
35
- results: results
36
- });
37
- if (attributesToRender.length > MAX_WILDCARD_FACETS && !props.facets) {
38
- // eslint-disable-next-line no-console
39
- console.warn("More than ".concat(MAX_WILDCARD_FACETS, " facets are requested to be displayed without explicitly setting which facets to retrieve. This could have a performance impact. Set \"facets\" to [] to do two smaller network requests, or explicitly to ['*'] to avoid this warning."));
40
- }
41
- if (props.maxValuesPerFacet < results._state.maxValuesPerFacet) {
42
- // eslint-disable-next-line no-console
43
- console.warn("The maxValuesPerFacet set by dynamic widgets (".concat(props.maxValuesPerFacet, ") is smaller than one of the limits set by a widget (").concat(results._state.maxValuesPerFacet, "). This causes a mismatch in query parameters and thus an extra network request when that widget is mounted."));
44
- }
45
- return {
46
- attributesToRender: attributesToRender
47
- };
48
- },
49
- getSearchParameters: function getSearchParameters(searchParameters, props) {
50
- return (props.facets || ['*']).reduce(function (acc, curr) {
51
- return acc.addFacet(curr);
52
- }, searchParameters.setQueryParameters({
53
- maxValuesPerFacet: Math.max(props.maxValuesPerFacet || 0, searchParameters.maxValuesPerFacet || 0)
54
- }));
55
- }
56
- });
@@ -1,182 +0,0 @@
1
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
- var _excluded = ["defaultRefinement"];
3
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
5
- function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
6
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
7
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
8
- import { objectHasKeys } from "../core/utils.js";
9
- import createConnector from "../core/createConnector.js";
10
- import { getResults, getCurrentRefinementValue, getIndexId, refineValue, cleanUpValue } from "../core/indexUtils.js";
11
-
12
- /**
13
- * The GeoSearch connector provides the logic to build a widget that will display the results on a map.
14
- * It also provides a way to search for results based on their position. The connector provides function to manage the search experience (search on map interaction).
15
- * @name connectGeoSearch
16
- * @kind connector
17
- * @requirements Note that the GeoSearch connector uses the [geosearch](https://www.algolia.com/doc/guides/searching/geo-search) capabilities of Algolia.
18
- * Your hits **must** have a `_geoloc` attribute in order to be passed to the rendering function. Currently, the feature is not compatible with multiple values in the `_geoloc` attribute
19
- * (e.g. a restaurant with multiple locations). In that case you can duplicate your records and use the [distinct](https://www.algolia.com/doc/guides/ranking/distinct) feature of Algolia to only retrieve unique results.
20
- * @propType {{ northEast: { lat: number, lng: number }, southWest: { lat: number, lng: number } }} [defaultRefinement] - Default search state of the widget containing the bounds for the map
21
- * @providedPropType {function({ northEast: { lat: number, lng: number }, southWest: { lat: number, lng: number } })} refine - a function to toggle the refinement
22
- * @providedPropType {function} createURL - a function to generate a URL for the corresponding search state
23
- * @providedPropType {array.<object>} hits - the records that matched the search
24
- * @providedPropType {boolean} isRefinedWithMap - true if the current refinement is set with the map bounds
25
- * @providedPropType {{ northEast: { lat: number, lng: number }, southWest: { lat: number, lng: number } }} [currentRefinement] - the refinement currently applied
26
- * @providedPropType {{ lat: number, lng: number }} [position] - the position of the search
27
- */
28
-
29
- // To control the map with an external widget the other widget
30
- // **must** write the value in the attribute `aroundLatLng`
31
- var getBoundingBoxId = function getBoundingBoxId() {
32
- return 'boundingBox';
33
- };
34
- var getAroundLatLngId = function getAroundLatLngId() {
35
- return 'aroundLatLng';
36
- };
37
- var getConfigureAroundLatLngId = function getConfigureAroundLatLngId() {
38
- return 'configure.aroundLatLng';
39
- };
40
- var currentRefinementToString = function currentRefinementToString(currentRefinement) {
41
- return [currentRefinement.northEast.lat, currentRefinement.northEast.lng, currentRefinement.southWest.lat, currentRefinement.southWest.lng].join();
42
- };
43
- var stringToCurrentRefinement = function stringToCurrentRefinement(value) {
44
- var values = value.split(',');
45
- return {
46
- northEast: {
47
- lat: parseFloat(values[0]),
48
- lng: parseFloat(values[1])
49
- },
50
- southWest: {
51
- lat: parseFloat(values[2]),
52
- lng: parseFloat(values[3])
53
- }
54
- };
55
- };
56
- var latLngRegExp = /^(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)$/;
57
- var stringToPosition = function stringToPosition(value) {
58
- var pattern = value.match(latLngRegExp);
59
- return {
60
- lat: parseFloat(pattern[1]),
61
- lng: parseFloat(pattern[2])
62
- };
63
- };
64
- var getCurrentRefinement = function getCurrentRefinement(props, searchState, context) {
65
- var refinement = getCurrentRefinementValue(props, searchState, context, getBoundingBoxId(), {});
66
- if (!objectHasKeys(refinement)) {
67
- return;
68
- }
69
-
70
- // eslint-disable-next-line consistent-return
71
- return {
72
- northEast: {
73
- lat: parseFloat(refinement.northEast.lat),
74
- lng: parseFloat(refinement.northEast.lng)
75
- },
76
- southWest: {
77
- lat: parseFloat(refinement.southWest.lat),
78
- lng: parseFloat(refinement.southWest.lng)
79
- }
80
- };
81
- };
82
- var getCurrentPosition = function getCurrentPosition(props, searchState, context) {
83
- var defaultRefinement = props.defaultRefinement,
84
- propsWithoutDefaultRefinement = _objectWithoutProperties(props, _excluded);
85
- var aroundLatLng = getCurrentRefinementValue(propsWithoutDefaultRefinement, searchState, context, getAroundLatLngId());
86
- if (!aroundLatLng) {
87
- // Fallback on `configure.aroundLatLng`
88
- var configureAroundLatLng = getCurrentRefinementValue(propsWithoutDefaultRefinement, searchState, context, getConfigureAroundLatLngId());
89
- return configureAroundLatLng && stringToPosition(configureAroundLatLng);
90
- }
91
- return aroundLatLng;
92
- };
93
- var _refine = function refine(searchState, nextValue, context) {
94
- var resetPage = true;
95
- var nextRefinement = _defineProperty({}, getBoundingBoxId(), nextValue);
96
- return refineValue(searchState, nextRefinement, context, resetPage);
97
- };
98
- export default createConnector({
99
- displayName: 'AlgoliaGeoSearch',
100
- $$type: 'ais.geoSearch',
101
- getProvidedProps: function getProvidedProps(props, searchState, searchResults) {
102
- var context = {
103
- ais: props.contextValue,
104
- multiIndexContext: props.indexContextValue
105
- };
106
- var results = getResults(searchResults, context);
107
-
108
- // We read it from both because the SearchParameters & the searchState are not always
109
- // in sync. When we set the refinement the searchState is used but when we clear the refinement
110
- // the SearchParameters is used. In the first case when we render, the results are not there
111
- // so we can't find the value from the results. The most up to date value is the searchState.
112
- // But when we clear the refinement the searchState is immediately cleared even when the items
113
- // retrieved are still the one from the previous query with the bounding box. It leads to some
114
- // issue with the position of the map. We should rely on 1 source of truth or at least always
115
- // be sync.
116
-
117
- var currentRefinementFromSearchState = getCurrentRefinement(props, searchState, context);
118
- var currentRefinementFromSearchParameters = results && results._state.insideBoundingBox && stringToCurrentRefinement(results._state.insideBoundingBox) || undefined;
119
- var currentPositionFromSearchState = getCurrentPosition(props, searchState, context);
120
- var currentPositionFromSearchParameters = results && results._state.aroundLatLng && stringToPosition(results._state.aroundLatLng) || undefined;
121
- var currentRefinement = currentRefinementFromSearchState || currentRefinementFromSearchParameters;
122
- var position = currentPositionFromSearchState || currentPositionFromSearchParameters;
123
- return {
124
- hits: !results ? [] : results.hits.filter(function (_) {
125
- return Boolean(_._geoloc);
126
- }),
127
- isRefinedWithMap: Boolean(currentRefinement),
128
- currentRefinement: currentRefinement,
129
- position: position
130
- };
131
- },
132
- refine: function refine(props, searchState, nextValue) {
133
- return _refine(searchState, nextValue, {
134
- ais: props.contextValue,
135
- multiIndexContext: props.indexContextValue
136
- });
137
- },
138
- getSearchParameters: function getSearchParameters(searchParameters, props, searchState) {
139
- var currentRefinement = getCurrentRefinement(props, searchState, {
140
- ais: props.contextValue,
141
- multiIndexContext: props.indexContextValue
142
- });
143
- if (!currentRefinement) {
144
- return searchParameters;
145
- }
146
- return searchParameters.setQueryParameter('insideBoundingBox', currentRefinementToString(currentRefinement));
147
- },
148
- cleanUp: function cleanUp(props, searchState) {
149
- return cleanUpValue(searchState, {
150
- ais: props.contextValue,
151
- multiIndexContext: props.indexContextValue
152
- }, getBoundingBoxId());
153
- },
154
- getMetadata: function getMetadata(props, searchState) {
155
- var items = [];
156
- var id = getBoundingBoxId();
157
- var context = {
158
- ais: props.contextValue,
159
- multiIndexContext: props.indexContextValue
160
- };
161
- var index = getIndexId(context);
162
- var nextRefinement = {};
163
- var currentRefinement = getCurrentRefinement(props, searchState, context);
164
- if (currentRefinement) {
165
- items.push({
166
- label: "".concat(id, ": ").concat(currentRefinementToString(currentRefinement)),
167
- value: function value(nextState) {
168
- return _refine(nextState, nextRefinement, context);
169
- },
170
- currentRefinement: currentRefinement
171
- });
172
- }
173
- return {
174
- id: id,
175
- index: index,
176
- items: items
177
- };
178
- },
179
- shouldComponentUpdate: function shouldComponentUpdate() {
180
- return true;
181
- }
182
- });